var process={env:{NODE_ENV:"production"}};!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("worker_threads"),require("module"),require("path")):"function"==typeof define&&define.amd?define(["worker_threads","module","path"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WorkerThreads,t.Module,t.path)}(this,(function(t,e,i){"use strict";function n(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(i){if("default"!==i){var n=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return t[i]}})}})),e.default=t,Object.freeze(e)}var s=r(t),a=n(e),l=n(i);class c{state;constructor(t){this.state=t}get value(){return this.state}set value(t){this.state=t}}function u(t){return new c(t)}function h(t,e){let i=-1;const n=t.length;for(;++it&&("object"==typeof t.position||Array.isArray(t.position)||""!=t.lng&&""!=t.lat)))}function d(t,e){const i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[];let r;if(e=e||i.length,t)for(r=0;r{e(t[i],i,t)}))}return t}function m(...t){class e{}function i(t,e){for(const i of Reflect.ownKeys(e))if("constructor"!==i&&"prototype"!==i&&"name"!==i){const n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n)}}for(const n of t)i(e,n),i(e.prototype,n.prototype),i(e.prototype,n.prototype.__proto__);return e}function g(t,e){if(Array.isArray(e)){let i=!1;return e.forEach((e=>{const n=g(t,e);n&&(i=n)})),i}return v(t)===y(e)}const y=t=>t.toLowerCase(),v=t=>y(Object.prototype.toString.call(t).replace(/\[/g,"").replace(/\]/g,"").replace(/\s/g,"").replace(/object/g,"")),_=Array.isArray,x=t=>g(t,"object"),b=t=>g(t,"function"),w=t=>g(t,"string");function A(t,e){let i;if(w(t))return(n=t)?document.createTextNode(n):null;if(t instanceof Element)return t;if(b(t)){if(t.tag.toString().startsWith("class ")){return A((new t.tag).render())}return A(t.tag())}if(!x(t))return t;var n;i=document.createElement(t.tag);const{attrs:r,children:o}=t;return function(t,e={}){f(e,((e,i)=>{"style"===i?function(t,e){w(e)?t.style=e:x(e)&&f(e,((e,i)=>{t.style[i]=e}))}(t,e):["class","className"].includes(i)?function(t,e){const i=[];if("string"==typeof e)e=e.split(" ");else if(x(e)){const t=[];f(e,((e,n)=>{e?t.push(n):i.push(n)})),e=[...t]}if(!_(e))return t;{const n=t.classList;e.forEach((t=>{n.contains(t)?i.includes(t)&&n.remove(t):n.add(t)}))}}(t,e):i.includes("on")?function(t,e,i,n={}){"passive"in n&&E?t.addEventListener(e,i,n):t.addEventListener(e,i,n.capture)}(t,i.slice(2).toLowerCase(),e):!function(t,e){_(e)||(e=[e]);const i=[];return e.forEach((e=>{i.push(t.getAttribute(e))})),1===i.length?i[0]:i}(t,i)?t[i]=e:t.setAttribute(i,e)}))}(i,r),o&&o.forEach((t=>{const e=t.element?t.element:t,n=t=>{_(t)?t.forEach((t=>n(t))):i.appendChild(A(t))};n(e)})),t.element=i,e&&function(t,e){_(e)?e.forEach((e=>{e&&(x(e)&&e.tag?t.appendChild(A(e)):t.appendChild(e))})):t.appendChild(e)}(e,i),t.element}const E=!1;class S{option;constructor(t){this.option=Object.assign({minimumLevel:1,maximumLevel:20,show:!0,layer:d(0,25),tileSize:256},t);const e={type:"raster",tiles:[this.option.url],tileSize:this.option.tileSize};cNt.value.addSource(this.option.layer+"source",e);const i={id:this.option.layer,type:"raster",source:this.option.layer+"source",minzoom:this.option.minimumLevel,maxzoom:this.option.maximumLevel,layout:{visibility:this.option.show?"visible":"none"},paint:{"raster-opacity":1}};cNt.value.addLayer(i)}destroy(){cNt.value.removeLayer(this.option.layer),cNt.value.removeSource(this.option.layer+"source")}setLayerShowOrHidden(t){if(!cNt.value.getLayer(this.option.layer))throw new Error(`Layer name "${this.option.layer}" does not exist.`);{const e=t?"visible":"none";cNt.value.setLayoutProperty(this.option.layer,"visibility",e)}}}class M{option;constructor(t){if(this.option=Object.assign({layer:d(0,25),url:"",sourceLayer:"",minimumLevel:1,maximumLevel:20,type:"line",style:{paint:{"line-color":"red","line-width":1.5}}},t),cNt.value.getSource(this.option.layer+"source")||cNt.value.getLayer(this.option.layer))throw new Error(`Layer name "${this.option.layer}" exists.`);cNt.value.addSource(this.option.layer+"source",{type:"vector",tiles:[this.option.url]}),cNt.value.addLayer({id:this.option.layer,type:this.option.type,source:this.option.layer+"source","source-layer":this.option.sourceLayer,minzoom:this.option.minimumLevel,maxzoom:this.option.maximumLevel,...this.option.style})}destroy(){cNt.value.removeLayer(this.option.layer),cNt.value.removeSource(this.option.layer+"source")}setLayerShowOrHidden(t){if(!cNt.value.getLayer(this.option.layer))throw new Error(`Layer name "${this.option.layer}" does not exist.`);{const e=t?"visible":"none";cNt.value.setLayoutProperty(this.option.layer,"visibility",e)}}}var T;!function(t){t[t.click=0]="click",t[t.mouseIn=1]="mouseIn",t[t.mouseOut=2]="mouseOut",t[t.mouseMove=3]="mouseMove",t[t.rightClick=4]="rightClick",t[t.clusterClick=5]="clusterClick"}(T||(T={}));const I=u({click:{},mouseIn:{},mouseOut:{},mouseMove:{},rightClick:{},clusterClick:{}});class C{id;bbox;_options;addEventListener(t,e){switch(t){case"mouseIn":I.value[t][this.id]=t=>{if(!t.features||t.defaultPrevented)return;const i=t.features[0];e(i.properties)},cNt.value.on("mouseover",this.id,I.value[t][this.id]);break;case"mouseOut":I.value[t][this.id]=t=>{t.defaultPrevented||e(t)},cNt.value.on("mouseout",this.id,I.value[t][this.id]);break;case"mouseMove":I.value[t][this.id]=t=>{if(!t.features||t.defaultPrevented)return;const i=t.features[0];e(i.properties)},cNt.value.on("mousemove",this.id,I.value[t][this.id]);break;case"rightClick":I.value[t][this.id]=t=>{if(!t.features||t.defaultPrevented)return;const i=t.features[0];e(i.properties)},cNt.value.on("contextmenu",this.id,I.value[t][this.id]);break;case"click":I.value[t][this.id]=t=>{if(!t.features||t.defaultPrevented)return;const i=t.features[0];e(i.properties)},cNt.value.on("click",this.id,I.value[t][this.id]);break;case"clusterClick":I.value[t][this.id]=t=>{const i=cNt.value.queryRenderedFeatures(t.point,{layers:[`${this.id}-clusters`]}),n=i[0].properties.cluster_id,r=i[0].properties.point_count;cNt.value.getSource(`${this.id}source`).getClusterLeaves(n,r,0,((t,i)=>{let n=i;this._options.originData instanceof Array&&(n=i.map((t=>t.properties))),e(n)}))},cNt.value.on("click",`${this.id}-clusters`,I.value[t][this.id])}}removeEventListener(t){switch(t){case"mouseIn":cNt.value.off("mouseover",this.id,I.value[t][this.id]);break;case"mouseOut":cNt.value.off("mouseout",this.id,I.value[t][this.id]);break;case"mouseMove":cNt.value.off("mousemove",this.id,I.value[t][this.id]);break;case"rightClick":cNt.value.off("contextmenu",this.id,I.value[t][this.id]);break;case"click":cNt.value.off("click",this.id,I.value[t][this.id]);break;case"clusterClick":cNt.value.off("click",`${this.id}-clusters`,I.value[t][this.id])}I.value[t][this.id]&&delete I.value[t][this.id]}flyTo(){cNt.value.fitBounds(this.bbox,{padding:{top:30,bottom:30,left:30,right:30}})}destroy(){cNt.value.removeLayer(this.id),cNt.value.getSource(this.id+"source")&&cNt.value.removeSource(this.id+"source"),cNt.value.getLayer(this.id+"Highlight")&&(cNt.value.removeLayer(this.id+"Highlight"),cNt.value.removeSource(this.id+"Highlightsource")),cNt.value.hasImage(this.id+"icon")&&cNt.value.removeImage(this.id+"icon"),cNt.value.getLayer(this.id+"label")&&(cNt.value.removeLayer(this.id+"label"),cNt.value.removeSource(this.id+"labelsource")),cNt.value.getLayer(this.id+"line")&&(cNt.value.removeLayer(this.id+"line"),cNt.value.removeSource(this.id+"linesource"));const t=cNt.value.listImages();t.length>0&&t.forEach((t=>{-1!=t.indexOf(this.id)&&cNt.value.removeImage(t)}))}show(t){if(!cNt.value.getLayer(this.id))throw new Error(`Layer name "${this.id}" does not exist.`);{const e=t?"visible":"none";cNt.value.setLayoutProperty(this.id,"visibility",e),cNt.value.getLayer(this.id+"Highlight")&&cNt.value.setLayoutProperty(this.id+"Highlight","visibility",e),cNt.value.getLayer(this.id+"label")&&cNt.value.setLayoutProperty(this.id+"label","visibility",e),cNt.value.getLayer(this.id+"line")&&cNt.value.setLayoutProperty(this.id+"line","visibility",e)}}}var P=6371008.8,L={centimeters:100*P,centimetres:100*P,degrees:P/111325,feet:3.28084*P,inches:39.37*P,kilometers:P/1e3,kilometres:P/1e3,meters:P,metres:P,miles:P/1609.344,millimeters:1e3*P,millimetres:1e3*P,nauticalmiles:P/1852,radians:1,yards:1.0936*P};function D(t,e,i){void 0===i&&(i={});var n={type:"Feature"};return(0===i.id||i.id)&&(n.id=i.id),i.bbox&&(n.bbox=i.bbox),n.properties=e||{},n.geometry=t,n}function R(t,e,i){if(void 0===i&&(i={}),!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(!H(t[0])||!H(t[1]))throw new Error("coordinates must contain numbers");return D({type:"Point",coordinates:t},e,i)}function O(t,e,i){void 0===i&&(i={});for(var n=0,r=t;na||p>l||d>c)return s=o,a=i,l=p,c=d,void(r=0);var f=k([s,o],t.properties);if(!1===e(f,i,n,d,r))return!1;r++,s=o}))&&void 0}}}))}function K(t){var e=[1/0,1/0,-1/0,-1/0];return q(t,(function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]=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 tt(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 et(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}K.default=K;var nt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function rt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function ot(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),i}function st(t,e,i,n,r){at(t,e,i||0,n||t.length-1,r||ct)}function at(t,e,i,n,r){for(;n>i;){if(n-i>600){var o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);at(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(n,Math.floor(e+(o-s)*l/o+c)),r)}var u=t[e],h=i,p=n;for(lt(t,i,e),r(t[n],u)>0&<(t,i,n);h0;)p--}0===r(t[i],u)?lt(t,i,p):lt(t,++p,n),p<=e&&(i=p+1),e<=p&&(n=p-1)}}function lt(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function ct(t,e){return te?1:0}function ut(t,e,i){if(void 0===i&&(i={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var n=$(t),r=et(e),o=r.type,s=e.bbox,a=r.coordinates;if(s&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(n,s))return!1;"Polygon"===o&&(a=[a]);for(var l=!1,c=0;ct[1]!=c>t[1]&&t[0]<(l-s)*(t[1]-a)/(c-a)+s&&(n=!n)}return n}function pt(t,e,i){void 0===i&&(i={});var n=$(t),r=$(e),o=j(r[1]-n[1]),s=j(r[0]-n[0]),a=j(n[1]),l=j(r[1]),c=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(l);return V(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)),i.units)}function dt(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return ft(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach((function(i){switch(i){case"type":case"features":return;default:e[i]=t[i]}})),e.features=t.features.map((function(t){return ft(t)})),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return gt(t);default:throw new Error("unknown GeoJSON type")}}function ft(t){var e={type:"Feature"};return Object.keys(t).forEach((function(i){switch(i){case"type":case"properties":case"geometry":return;default:e[i]=t[i]}})),e.properties=mt(t.properties),e.geometry=gt(t.geometry),e}function mt(t){var e={};return t?(Object.keys(t).forEach((function(i){var n=t[i];"object"==typeof n?null===n?e[i]=null:Array.isArray(n)?e[i]=n.map((function(t){return t})):e[i]=mt(n):e[i]=n})),e):e}function gt(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map((function(t){return gt(t)})),e):(e.coordinates=yt(t.coordinates),e)}function yt(t){var e=t;return"object"!=typeof e[0]?e.slice():e.map((function(t){return yt(t)}))}function vt(t){return function(t,e){void 0===e&&(e={});var i=Number(t[0]),n=Number(t[1]),r=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 s=[i,n];return O([[s,[r,n],[r,o],[i,o],s]],e.properties,{bbox:t,id:e.id})}(K(t))}function _t(t,e,i,n){void 0===n&&(n={});var r=$(t),o=j(r[0]),s=j(r[1]),a=j(i),l=U(e,n.units),c=Math.asin(Math.sin(s)*Math.cos(l)+Math.cos(s)*Math.sin(l)*Math.cos(a));return R([G(o+Math.atan2(Math.sin(a)*Math.sin(l)*Math.cos(s),Math.cos(l)-Math.sin(s)*Math.sin(c))),G(c)],n.properties)}function xt(t,e,i){if(void 0===i&&(i={}),!0===i.final)return function(t,e){var i=xt(e,t);return i=(i+180)%360}(t,e);var n=$(t),r=$(e),o=j(n[0]),s=j(r[0]),a=j(n[1]),l=j(r[1]),c=Math.sin(s-o)*Math.cos(l),u=Math.cos(a)*Math.sin(l)-Math.sin(a)*Math.cos(l)*Math.cos(s-o);return G(Math.atan2(c,u))}function bt(t,e){void 0===e&&(e={});var i=K(t);return R([(i[0]+i[2])/2,(i[1]+i[3])/2],e.properties,e)}function wt(t,e){void 0===e&&(e={});var i=0,n=0,r=0;return q(t,(function(t){i+=t[0],n+=t[1],r++}),!0),R([i/r,n/r],e.properties)}function At(t){if(!t)throw new Error("geojson is required");var e=[];return Q(t,(function(t){!function(t,e){var i=[],n=t.geometry;if(null!==n){switch(n.type){case"Polygon":i=tt(n);break;case"LineString":i=[tt(n)]}i.forEach((function(i){var n=function(t,e){var i=[];return t.reduce((function(t,n){var r=k([t,n],e);return r.bbox=function(t,e){var i=t[0],n=t[1],r=e[0],o=e[1],s=ir?i:r,c=n>o?n:o;return[s,a,l,c]}(t,n),i.push(r),n})),i}(i,t.properties);n.forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),N(e)}var Et={exports:{}};function St(t,e,i){if(!i)return e.indexOf(t);for(let n=0;n=t.minX&&e.maxY>=t.minY}function Bt(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function zt(t,e,i,n,r){const o=[e,i];for(;o.length;){if((i=o.pop())-(e=o.pop())<=n)continue;const s=e+Math.ceil((i-e)/n/2)*n;st(t,s,e,i,r),o.push(e,s,s,i)}}var Ft=Object.freeze({__proto__:null,default:class{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(t){let e=this.data;const i=[];if(!Nt(t,e))return i;const n=this.toBBox,r=[];for(;e;){for(let o=0;o=0&&r[e].children.length>this._maxEntries;)this._split(r,e),e--;this._adjustParentBBoxes(n,r,e)}_split(t,e){const i=t[e],n=i.children.length,r=this._minEntries;this._chooseSplitAxis(i,r,n);const o=this._chooseSplitIndex(i,r,n),s=Bt(i.children.splice(o,i.children.length-o));s.height=i.height,s.leaf=i.leaf,Mt(i,this.toBBox),Mt(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(i,s)}_splitRoot(t,e){this.data=Bt([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Mt(this.data,this.toBBox)}_chooseSplitIndex(t,e,i){let n,r=1/0,o=1/0;for(let s=e;s<=i-e;s++){const e=Tt(t,0,s,this.toBBox),a=Tt(t,s,i,this.toBBox),l=Ot(e,a),c=Lt(e)+Lt(a);l=e;n--){const e=t.children[n];It(s,t.leaf?r(e):e),a+=Dt(s)}return a}_adjustParentBBoxes(t,e,i){for(let n=i;n>=0;n--)It(e[n],t)}_condense(t){for(let e,i=t.length-1;i>=0;i--)0===t[i].children.length?i>0?(e=t[i-1].children,e.splice(e.indexOf(t[i]),1)):this.clear():Mt(t[i],this.toBBox)}}}),Vt=ot(Ft),Ut={};!function(t){function e(t,e,i){void 0===i&&(i={});var n={type:"Feature"};return(0===i.id||i.id)&&(n.id=i.id),i.bbox&&(n.bbox=i.bbox),n.properties=e||{},n.geometry=t,n}function i(t,i,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(!p(t[0])||!p(t[1]))throw new Error("coordinates must contain numbers");return e({type:"Point",coordinates:t},i,n)}function n(t,i,n){void 0===n&&(n={});for(var r=0,o=t;r=0))throw new Error("precision must be a positive number");var i=Math.pow(10,e||0);return Math.round(t*i)/i},t.radiansToLength=c,t.lengthToRadians=u,t.lengthToDegrees=function(t,e){return h(u(t,e))},t.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},t.radiansToDegrees=h,t.degreesToRadians=function(t){return t%360*Math.PI/180},t.convertLength=function(t,e,i){if(void 0===e&&(e="kilometers"),void 0===i&&(i="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(u(t,e),i)},t.convertArea=function(e,i,n){if(void 0===i&&(i="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var r=t.areaFactors[i];if(!r)throw new Error("invalid original units");var o=t.areaFactors[n];if(!o)throw new Error("invalid final units");return e/r*o},t.isNumber=p,t.isObject=function(t){return!!t&&t.constructor===Object},t.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(!p(t))throw new Error("bbox must only contain numbers")}))},t.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")}}(Ut);var Gt={};Object.defineProperty(Gt,"__esModule",{value:!0});var jt=Ut;function Ht(t,e,i){if(null!==t)for(var n,r,o,s,a,l,c,u,h=0,p=0,d=t.type,f="FeatureCollection"===d,m="Feature"===d,g=f?t.features.length:1,y=0;ya||p>l||d>c)return s=o,a=i,l=p,c=d,void(r=0);var f=jt.lineString([s,o],t.properties);if(!1===e(f,i,n,d,r))return!1;r++,s=o}))&&void 0}}}))}function Qt(t,e){if(!t)throw new Error("geojson is required");Zt(t,(function(t,i,n){if(null!==t.geometry){var r=t.geometry.type,o=t.geometry.coordinates;switch(r){case"LineString":if(!1===e(t,i,n,0,0))return!1;break;case"Polygon":for(var s=0;st[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2] line1 must only contain 2 coordinates");if(2!==n.length)throw new Error(" line2 must only contain 2 coordinates");var r=i[0][0],o=i[0][1],s=i[1][0],a=i[1][1],l=n[0][0],c=n[0][1],u=n[1][0],h=n[1][1],p=(h-c)*(s-r)-(u-l)*(a-o),d=(u-l)*(o-c)-(h-c)*(r-l),f=(s-r)*(o-c)-(a-o)*(r-l);if(0===p)return null;var m=d/p,g=f/p;return m>=0&&m<=1&&g>=0&&g<=1?R([r+m*(s-r),o+m*(a-o)]):null}function ue(t,e,i){void 0===i&&(i={});var n=R([1/0,1/0],{dist:1/0}),r=0;return Q(t,(function(t){for(var o=tt(t),s=0;s0&&((m=f.features[0]).properties.dist=pt(e,m,i),m.properties.location=r+pt(a,m,i)),a.properties.dist0){e+=Math.abs(fe(t[0]));for(var i=1;i2){for(s=0;s=r&&o===n.length-1);o++){if(r>=e){var s=e-r;if(s){var a=xt(n[o],n[o-1])-180;return _t(n[o],s,a,i)}return R(n[o])}r+=pt(n[o],n[o+1],i)}return R(n[n.length-1])}function ye(t,e){return void 0===e&&(e={}),function(t,e,i){var n=i,r=!1;return J(t,(function(t,o,s,a,l){n=!1===r&&void 0===i?t:e(n,t,o,s,a,l),r=!0})),n}(t,(function(t,i){var n=i.geometry.coordinates;return t+pt(n[0],n[1],e)}),0)}function ve(t,e,i,n){if(!W(n=n||{}))throw new Error("options is invalid");var r,o=[];if("Feature"===t.type)r=t.geometry.coordinates;else{if("LineString"!==t.type)throw new Error("input must be a LineString Feature or Geometry");r=t.coordinates}for(var s,a,l,c=r.length,u=0,h=0;h=u&&h===r.length-1);h++){if(u>e&&0===o.length){if(!(s=e-u))return o.push(r[h]),k(o);a=xt(r[h],r[h-1])-180,l=_t(r[h],s,a,n),o.push(l.geometry.coordinates)}if(u>=i)return(s=i-u)?(a=xt(r[h],r[h-1])-180,l=_t(r[h],s,a,n),o.push(l.geometry.coordinates),k(o)):(o.push(r[h]),k(o));if(u>=e&&o.push(r[h]),h===r.length-1)return k(o);u+=pt(r[h],r[h+1],n)}if(ur)return!1}else if(0!==d)return!1;return n?"start"===n?Math.abs(h)>=Math.abs(p)?h>0?a0?l=Math.abs(p)?h>0?a<=o&&o0?l<=s&&s=Math.abs(p)?h>0?a0?l=Math.abs(p)?h>0?a<=o&&o<=c:c<=o&&o<=a:p>0?l<=s&&s<=u:u<=s&&s<=l}function be(t,e){var i=et(t),n=et(e),r=i.type,o=n.type;switch(r){case"Point":switch(o){case"MultiPoint":return function(t,e){var i,n=!1;for(i=0;ie[0])&&(!(t[2]e[1])&&!(t[3]1?B(t,e):k(t[0],e)}var Ce,Pe,Le=Object.prototype.toString,De=function(t){var e=Le.call(t),i="[object Arguments]"===e;return i||(i="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===Le.call(t.callee)),i};var Re=Array.prototype.slice,Oe=De,ke=Object.keys,Ne=ke?function(t){return ke(t)}:function(){if(Pe)return Ce;var t;if(Pe=1,!Object.keys){var e=Object.prototype.hasOwnProperty,i=Object.prototype.toString,n=De,r=Object.prototype.propertyIsEnumerable,o=!r.call({toString:null},"toString"),s=r.call((function(){}),"prototype"),a=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},c={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},u=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!c["$"+t]&&e.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();t=function(t){var r=null!==t&&"object"==typeof t,c="[object Function]"===i.call(t),h=n(t),p=r&&"[object String]"===i.call(t),d=[];if(!r&&!c&&!h)throw new TypeError("Object.keys called on a non-object");var f=s&&c;if(p&&t.length>0&&!e.call(t,0))for(var m=0;m0)for(var g=0;g1&&"boolean"!=typeof e)throw new ni('"allowMissing" argument must be a boolean');if(null===Ai(/^%?[^%]*%?$/,t))throw new ei("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(t){var e=wi(t,0,1),i=wi(t,-1);if("%"===e&&"%"!==i)throw new ei("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==e)throw new ei("invalid intrinsic syntax, expected opening `%`");var n=[];return bi(t,Ei,(function(t,e,i,r){n[n.length]=i?bi(r,Si,"$1"):e||t})),n}(t),n=i.length>0?i[0]:"",r=Mi("%"+n+"%",e),o=r.name,s=r.value,a=!1,l=r.alias;l&&(n=l[0],xi(i,_i([0,1],l)));for(var c=1,u=!0;c=i.length){var f=oi(s,h);s=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:s[h]}else u=vi(s,h),s=s[h];u&&!a&&(di[o]=s)}}return s},Ii={exports:{}},Ci=Ti("%Object.defineProperty%",!0),Pi=function(){if(Ci)try{return Ci({},"a",{value:1}),!0}catch(t){return!1}return!1};Pi.hasArrayLengthDefineBug=function(){if(!Pi())return null;try{return 1!==Ci([],"length",{value:1}).length}catch(t){return!0}};var Li=Pi,Di=Ti("%Object.getOwnPropertyDescriptor%",!0);if(Di)try{Di([],"length")}catch(zO){Di=null}var Ri=Di,Oi=Li(),ki=Ti,Ni=Oi&&ki("%Object.defineProperty%",!0);if(Ni)try{Ni({},"a",{value:1})}catch(zO){Ni=!1}var Bi=ki("%SyntaxError%"),zi=ki("%TypeError%"),Fi=Ri,Vi=function(t,e,i){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new zi("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new zi("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new zi("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new zi("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new zi("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new zi("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,r=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!Fi&&Fi(t,e);if(Ni)Ni(t,e,{configurable:null===o&&a?a.configurable:!o,enumerable:null===n&&a?a.enumerable:!n,value:i,writable:null===r&&a?a.writable:!r});else{if(!s&&(n||r||o))throw new Bi("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=i}},Ui=Ti,Gi=Vi,ji=Li(),Hi=Ri,Wi=Ui("%TypeError%"),qi=Ui("%Math.floor%"),Xi=function(t,e){if("function"!=typeof t)throw new Wi("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||qi(e)!==e)throw new Wi("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],n=!0,r=!0;if("length"in t&&Hi){var o=Hi(t,"length");o&&!o.configurable&&(n=!1),o&&!o.writable&&(r=!1)}return(n||r||!i)&&(ji?Gi(t,"length",e,!0,!0):Gi(t,"length",e)),t};!function(t){var e=Je,i=Ti,n=Xi,r=i("%TypeError%"),o=i("%Function.prototype.apply%"),s=i("%Function.prototype.call%"),a=i("%Reflect.apply%",!0)||e.call(s,o),l=i("%Object.defineProperty%",!0),c=i("%Math.max%");if(l)try{l({},"a",{value:1})}catch(t){l=null}t.exports=function(t){if("function"!=typeof t)throw new r("a function is required");var i=a(e,s,arguments);return n(i,1+c(0,t.length-(arguments.length-1)),!0)};var u=function(){return a(e,o,arguments)};l?l(t.exports,"apply",{value:u}):t.exports.apply=u}(Ii);var Zi=Ii.exports,Yi=Ti,Qi=Zi,Ji=Qi(Yi("String.prototype.indexOf")),Ki=function(t,e){var i=Yi(t,!!e);return"function"==typeof i&&Ji(t,".prototype.")>-1?Qi(i):i},$i=Ge(),tn=Ki("Object.prototype.toString"),en=function(t){return!($i&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===tn(t)},nn=function(t){return!!en(t)||null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==tn(t)&&"[object Function]"===tn(t.callee)},rn=function(){return en(arguments)}();en.isLegacyArguments=nn;var on=rn?en:nn,sn=Fe,an="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),ln=Object.prototype.toString,cn=Array.prototype.concat,un=Vi,hn=Li(),pn=function(t,e,i,n){if(e in t)if(!0===n){if(t[e]===i)return}else if("function"!=typeof(r=n)||"[object Function]"!==ln.call(r)||!n())return;var r;hn?un(t,e,i,!0):un(t,e,i)},dn=function(t,e){var i=arguments.length>2?arguments[2]:{},n=sn(e);an&&(n=cn.call(n,Object.getOwnPropertySymbols(e)));for(var r=0;r2&&!!arguments[2]&&!jn||(Gn?Un(t,"name",e,!0,!0):Un(t,"name",e)),t},qn=Object,Xn=TypeError,Zn=Wn((function(){if(null!=this&&this!==qn(this))throw new Xn("RegExp.prototype.flags getter called on non-object");var t="";return this.hasIndices&&(t+="d"),this.global&&(t+="g"),this.ignoreCase&&(t+="i"),this.multiline&&(t+="m"),this.dotAll&&(t+="s"),this.unicode&&(t+="u"),this.unicodeSets&&(t+="v"),this.sticky&&(t+="y"),t}),"get flags",!0),Yn=Zn,Qn=fn.supportsDescriptors,Jn=Object.getOwnPropertyDescriptor,Kn=function(){if(Qn&&"gim"===/a/gim.flags){var t=Jn(RegExp.prototype,"flags");if(t&&"function"==typeof t.get&&"boolean"==typeof RegExp.prototype.dotAll&&"boolean"==typeof RegExp.prototype.hasIndices){var e="",i={};if(Object.defineProperty(i,"hasIndices",{get:function(){e+="d"}}),Object.defineProperty(i,"sticky",{get:function(){e+="y"}}),"dy"===e)return t.get}}return Yn},$n=fn.supportsDescriptors,tr=Kn,er=Object.getOwnPropertyDescriptor,ir=Object.defineProperty,nr=TypeError,rr=Object.getPrototypeOf,or=/a/,sr=fn,ar=Zn,lr=Kn,cr=function(){if(!$n||!rr)throw new nr("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var t=tr(),e=rr(or),i=er(e,"flags");return i&&i.get===t||ir(e,"flags",{configurable:!0,enumerable:!1,get:t}),t},ur=Zi(lr());sr(ur,{getPolyfill:lr,implementation:ar,shim:cr});var hr=ur,pr=Date.prototype.getDay,dr=Object.prototype.toString,fr=Ge(),mr=Fe,gr=on,yr=Pn,vr=Nn,_r=hr,xr=function(t){return"object"==typeof t&&null!==t&&(fr?function(t){try{return pr.call(t),!0}catch(t){return!1}}(t):"[object Date]"===dr.call(t))},br=Date.prototype.getTime;function wr(t,e,i){var n=i||{};return!!(n.strict?yr(t,e):t===e)||(!t||!e||"object"!=typeof t&&"object"!=typeof e?n.strict?yr(t,e):t==e:function(t,e,i){var n,r;if(typeof t!=typeof e)return!1;if(Ar(t)||Ar(e))return!1;if(t.prototype!==e.prototype)return!1;if(gr(t)!==gr(e))return!1;var o=vr(t),s=vr(e);if(o!==s)return!1;if(o||s)return t.source===e.source&&_r(t)===_r(e);if(xr(t)&&xr(e))return br.call(t)===br.call(e);var a=Er(t),l=Er(e);if(a!==l)return!1;if(a||l){if(t.length!==e.length)return!1;for(n=0;n=0;n--)if(c[n]!=u[n])return!1;for(n=c.length-1;n>=0;n--)if(!wr(t[r=c[n]],e[r],i))return!1;return!0}(t,e,n))}function Ar(t){return null==t}function Er(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]))}var Sr=wr,Mr=rt(Sr);function Tr(t,e){var i=tt(e),n=tt(t),r=n[0],o=n[n.length-1],s=t.geometry.coordinates;return Mr(i[0],r)?s.unshift(i[1]):Mr(i[0],o)?s.push(i[1]):Mr(i[1],r)?s.unshift(i[0]):Mr(i[1],o)&&s.push(i[0]),t}function Ir(t,e){var i=!0;return Q(t,(function(t){Q(e,(function(e){if(!1===i)return!1;i=function(t,e){switch(t.type){case"Point":switch(e.type){case"Point":return i=t.coordinates,n=e.coordinates,!(i[0]===n[0]&&i[1]===n[1]);case"LineString":return!Cr(e,t);case"Polygon":return!ut(t,e)}break;case"LineString":switch(e.type){case"Point":return!Cr(t,e);case"LineString":return!function(t,e){if(le(t,e).features.length>0)return!0;return!1}(t,e);case"Polygon":return!Pr(e,t)}break;case"Polygon":switch(e.type){case"Point":return!ut(e,t);case"LineString":return!Pr(t,e);case"Polygon":return!function(t,e){for(var i=0,n=t.coordinates[0];i0)return!0;return!1}(e,t)}}var i,n;return!1}(t.geometry,e.geometry)}))})),i}function Cr(t,e){for(var i=0;i0}function Lr(t,e,i){var n=i[0]-t[0],r=i[1]-t[1],o=e[0]-t[0],s=e[1]-t[1];return 0==n*s-r*o&&(Math.abs(o)>=Math.abs(s)?o>0?t[0]<=i[0]&&i[0]<=e[0]:e[0]<=i[0]&&i[0]<=t[0]:s>0?t[1]<=i[1]&&i[1]<=e[1]:e[1]<=i[1]&&i[1]<=t[1])}function Dr(t,e){var i=et(t),n=et(e),r=i.type,o=n.type,s=i.coordinates,a=n.coordinates;switch(r){case"Point":if("Point"===o)return Or(s,a);throw new Error("feature2 "+o+" geometry not supported");case"MultiPoint":switch(o){case"Point":return function(t,e){var i,n=!1;for(i=0;ie[0])&&(!(t[2]e[1])&&!(t[3]=0&&(i=[].concat(t.slice(n,t.length),t.slice(1,n+1))),i},Br.prototype.comparePath=function(t,e){var i=this;return t.every((function(t,e){return i.compareCoord(t,this[e])}),e)},Br.prototype.comparePolygon=function(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var i=t.coordinates.slice(1,t.coordinates.length),n=e.coordinates.slice(1,e.coordinates.length),r=this;return i.every((function(t){return this.some((function(e){return r.compareLine(t,e,1,!0)}))}),n)}return!1},Br.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)},Br.prototype.compareBBox=function(t,e){return!!(!t.bbox&&!e.bbox||t.bbox&&e.bbox&&this.compareCoord(t.bbox,e.bbox))},Br.prototype.removePseudo=function(t){return t};var Ur=rt(Br);function Gr(t,e){var i=et(t),n=et(e),r=i.type,o=n.type;if("MultiPoint"===r&&"MultiPoint"!==o||("LineString"===r||"MultiLineString"===r)&&"LineString"!==o&&"MultiLineString"!==o||("Polygon"===r||"MultiPolygon"===r)&&"Polygon"!==o&&"MultiPolygon"!==o)throw new Error("features must be of the same type");if("Point"===r)throw new Error("Point geometry not supported");if(new Ur({precision:6}).compare(t,e))return!1;var s=0;switch(r){case"MultiPoint":for(var a=0;a0}function jr(t,e){var i=!1;return Q(t,(function(t){Q(e,(function(e){if(!0===i)return!0;i=!Ir(t.geometry,e.geometry)}))})),i} /** * splaytree v3.1.2 * Fast Splay tree for Node and browser * * @author Alexander Milevski * @license MIT * @preserve */ /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function Hr(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]e?1:t0))break;if(null===e.right)break;if(i(t,e.right.key)>0){a=e.right;if(e.right=a.left,a.left=e,null===(e=a).right)break}r.right=e,r=e,e=e.right}}return r.right=e.left,o.left=e.right,e.left=n.right,e.right=n.left,e}function Zr(t,e,i,n){var r=new Wr(t,e);if(null===i)return r.left=r.right=null,r;var o=n(t,(i=Xr(t,i,n)).key);return o<0?(r.left=i.left,r.right=i,i.left=null):o>=0&&(r.right=i.right,r.left=i,i.right=null),r}function Yr(t,e,i){var n=null,r=null;if(e){var o=i((e=Xr(t,e,i)).key,t);0===o?(n=e.left,r=e.right):o<0?(r=e.right,e.right=null,n=e):(n=e.left,e.left=null,r=e)}return{left:n,right:r}}function Qr(t,e,i,n,r){if(t){n(e+(i?"└── ":"├── ")+r(t)+"\n");var o=e+(i?" ":"│ ");t.left&&Qr(t.left,o,!1,n,r),t.right&&Qr(t.right,o,!0,n,r)}}var Jr=function(){function t(t){void 0===t&&(t=qr),this._root=null,this._size=0,this._comparator=t}return t.prototype.insert=function(t,e){return this._size++,this._root=Zr(t,e,this._root,this._comparator)},t.prototype.add=function(t,e){var i=new Wr(t,e);null===this._root&&(i.left=i.right=null,this._size++,this._root=i);var n=this._comparator,r=Xr(t,this._root,n),o=n(t,r.key);return 0===o?this._root=r:(o<0?(i.left=r.left,i.right=r,r.left=null):o>0&&(i.right=r.right,i.left=r,r.right=null),this._size++,this._root=i),this._root},t.prototype.remove=function(t){this._root=this._remove(t,this._root,this._comparator)},t.prototype._remove=function(t,e,i){var n;return null===e?null:0===i(t,(e=Xr(t,e,i)).key)?(null===e.left?n=e.right:(n=Xr(t,e.left,i)).right=e.right,this._size--,n):e},t.prototype.pop=function(){var t=this._root;if(t){for(;t.left;)t=t.left;return this._root=Xr(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,i=this._comparator;e;){var n=i(t,e.key);if(0===n)return e;e=n<0?e.left:e.right}return null},t.prototype.find=function(t){return this._root&&(this._root=Xr(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,i=this._comparator;e;){var n=i(t,e.key);if(0===n)return!0;e=n<0?e.left:e.right}return!1},t.prototype.forEach=function(t,e){for(var i=this._root,n=[],r=!1;!r;)null!==i?(n.push(i),i=i.left):0!==n.length?(i=n.pop(),t.call(e,i),i=i.right):r=!0;return this},t.prototype.range=function(t,e,i,n){for(var r=[],o=this._comparator,s=this._root;0!==r.length||s;)if(s)r.push(s),s=s.left;else{if(o((s=r.pop()).key,e)>0)break;if(o(s.key,t)>=0&&i.call(n,s))return this;s=s.right}return this},t.prototype.keys=function(){var t=[];return this.forEach((function(e){var i=e.key;return t.push(i)})),t},t.prototype.values=function(){var t=[];return this.forEach((function(e){var i=e.data;return t.push(i)})),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,i=!1,n=0,r=[];!i;)if(e)r.push(e),e=e.left;else if(r.length>0){if(e=r.pop(),n===t)return e;n++,e=e.right}else i=!0;return null},t.prototype.next=function(t){var e=this._root,i=null;if(t.right){for(i=t.right;i.left;)i=i.left;return i}for(var n=this._comparator;e;){var r=n(t.key,e.key);if(0===r)break;r<0?(i=e,e=e.left):e=e.right}return i},t.prototype.prev=function(t){var e=this._root,i=null;if(null!==t.left){for(i=t.left;i.right;)i=i.right;return i}for(var n=this._comparator;e;){var r=n(t.key,e.key);if(0===r)break;r<0?e=e.left:(i=e,e=e.right)}return i},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return function(t){var e=t,i=[],n=!1,r=new Wr(null,null),o=r;for(;!n;)e?(i.push(e),e=e.left):i.length>0?e=(e=o=o.next=i.pop()).right:n=!0;return o.next=null,r.next}(this._root)},t.prototype.load=function(t,e,i){void 0===e&&(e=[]),void 0===i&&(i=!1);var n=t.length,r=this._comparator;if(i&&to(t,e,0,n-1,r),null===this._root)this._root=Kr(t,e,0,n),this._size=n;else{var o=function(t,e,i){var n=new Wr(null,null),r=n,o=t,s=e;for(;null!==o&&null!==s;)i(o.key,s.key)<0?(r.next=o,o=o.next):(r.next=s,s=s.next),r=r.next;null!==o?r.next=o:null!==s&&(r.next=s);return n.next}(this.toList(),function(t,e){for(var i=new Wr(null,null),n=i,r=0;r0){var o=i+Math.floor(r/2),s=t[o],a=e[o],l=new Wr(s,a);return l.left=Kr(t,e,i,o),l.right=Kr(t,e,o+1,n),l}return null}function $r(t,e,i){var n=i-e;if(n>0){var r=e+Math.floor(n/2),o=$r(t,e,r),s=t.head;return s.left=o,t.head=t.head.next,s.right=$r(t,r+1,i),s}return null}function to(t,e,i,n,r){if(!(i>=n)){for(var o=t[i+n>>1],s=i-1,a=n+1;;){do{s++}while(r(t[s],o)<0);do{a--}while(r(t[a],o)>0);if(s>=a)break;var l=t[s];t[s]=t[a],t[a]=l,l=e[s],e[s]=e[a],e[a]=l}to(t,e,i,a,r),to(t,e,a+1,n,r)}}function eo(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function io(t,e){for(var i=0;ie.x?1:t.ye.y?1:0}}]),no(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,i=0,n=e.length;i=0&&l>=0?sc?-1:0:o<0&&l<0?sc?1:0:lo?1:0}}}]),t}(),wo=0,Ao=function(){function t(e,i,n,r){eo(this,t),this.id=++wo,this.leftSE=e,e.segment=this,e.otherSE=i,this.rightSE=i,i.segment=this,i.otherSE=e,this.rings=n,this.windings=r}return no(t,null,[{key:"compare",value:function(t,e){var i=t.leftSE.point.x,n=e.leftSE.point.x,r=t.rightSE.point.x,o=e.rightSE.point.x;if(os&&a>l)return-1;var u=t.comparePoint(e.leftSE.point);if(u<0)return 1;if(u>0)return-1;var h=e.comparePoint(t.rightSE.point);return 0!==h?h:-1}if(i>n){if(sa&&s>c)return 1;var p=e.comparePoint(t.leftSE.point);if(0!==p)return p;var d=t.comparePoint(e.rightSE.point);return d<0?1:d>0?-1:1}if(sa)return 1;if(ro){var m=t.comparePoint(e.rightSE.point);if(m<0)return 1;if(m>0)return-1}if(r!==o){var g=l-s,y=r-i,v=c-a,_=o-n;if(g>y&&v<_)return 1;if(g_)return-1}return r>o?1:rc?1:t.ide.id?1:0}}]),no(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:te?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,i=this.rightSE.point,n=this.vector();if(e.x===i.x)return t.x===e.x?0:t.x0&&a.swapEvents(),bo.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),n&&(r.checkForConsuming(),o.checkForConsuming()),i}},{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,i=this.windings.length;e0){var o=i;i=n,n=o}if(i.prev===n){var s=i;i=n,n=s}for(var a=0,l=n.rings.length;a0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));r=i,o=e,s=-1}return new t(new bo(r,!0),new bo(o,!1),[n],[s])}}]),t}(),Eo=function(){function t(e,i,n){if(eo(this,t),!Array.isArray(e)||0===e.length)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=i,this.isExterior=n,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 r=ho.round(e[0][0],e[0][1]);this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};for(var o=r,s=1,a=e.length;sthis.bbox.ur.x&&(this.bbox.ur.x=l.x),l.y>this.bbox.ur.y&&(this.bbox.ur.y=l.y),o=l)}r.x===o.x&&r.y===o.y||this.segments.push(Ao.fromRing(o,r,this))}return no(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,i=this.segments.length;ethis.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=i}return no(t,[{key:"getSweepEvents",value:function(){for(var t=this.exteriorRing.getSweepEvents(),e=0,i=this.interiorRings.length;ethis.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=i}return no(t,[{key:"getSweepEvents",value:function(){for(var t=[],e=0,i=this.polys.length;e0&&(t=n)}for(var r=t.segment.prevInResult(),o=r?r.prevInResult():null;;){if(!r)return null;if(!o)return r.ringOut;if(o.ringOut!==r.ringOut)return o.ringOut.enclosingRing()!==r.ringOut?r.ringOut:r.ringOut.enclosingRing();r=o.prevInResult(),o=r?r.prevInResult():null}}}]),t}(),Io=function(){function t(e){eo(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return no(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,i=this.interiorRings.length;e1&&void 0!==arguments[1]?arguments[1]:Ao.compare;eo(this,t),this.queue=e,this.tree=new Jr(i),this.segments=[]}return no(t,[{key:"process",value:function(t){var e=t.segment,i=[];if(t.consumedBy)return t.isLeft?this.queue.remove(t.otherSE):this.tree.remove(e),i;var n=t.isLeft?this.tree.insert(e):this.tree.find(e);if(!n)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 r=n,o=n,s=void 0,a=void 0;void 0===s;)null===(r=this.tree.prev(r))?s=null:void 0===r.key.consumedBy&&(s=r.key);for(;void 0===a;)null===(o=this.tree.next(o))?a=null:void 0===o.key.consumedBy&&(a=o.key);if(t.isLeft){var l=null;if(s){var c=s.getIntersection(e);if(null!==c&&(e.isAnEndpoint(c)||(l=c),!s.isAnEndpoint(c)))for(var u=this._splitSafely(s,c),h=0,p=u.length;h0?(this.tree.remove(e),i.push(t)):(this.segments.push(e),e.prev=s)}else{if(s&&a){var w=s.getIntersection(a);if(null!==w){if(!s.isAnEndpoint(w))for(var A=this._splitSafely(s,w),E=0,S=A.length;ELo)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 Po(d),x=d.size,b=d.pop();b;){var w=b.key;if(d.size===x){var A=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(A.id," ")+"[".concat(A.leftSE.point.x,", ").concat(A.leftSE.point.y,"] -> ")+"[".concat(A.rightSE.point.x,", ").concat(A.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(d.size>Lo)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(_.segments.length>Do)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var E=_.process(w),S=0,M=E.length;S1?e-1:0),n=1;n1?e-1:0),n=1;n1?e-1:0),n=1;n1?e-1:0),n=1;ne.x?1:this.ye.y?1:0},Wo.prototype.clone=function(){},Wo.prototype.copy=function(){return new Wo(this)},Wo.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},Wo.prototype.distance3D=function(t){var e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return Math.sqrt(e*e+i*i+n*n)},Wo.prototype.distance=function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},Wo.prototype.hashCode=function(){var t=17;return t=37*(t=37*t+Wo.hashCode(this.x))+Wo.hashCode(this.y)},Wo.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z},Wo.prototype.interfaces_=function(){return[Uo,Go,Ho]},Wo.prototype.getClass=function(){return Wo},Wo.hashCode=function(){if(1===arguments.length){var t=Fo.doubleToLongBits(arguments[0]);return Math.trunc((t^t)>>>32)}},qo.DimensionalComparator.get=function(){return Xo},qo.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800},qo.NULL_ORDINATE.get=function(){return Fo.NaN},qo.X.get=function(){return 0},qo.Y.get=function(){return 1},qo.Z.get=function(){return 2},Object.defineProperties(Wo,qo);var Xo=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 zo("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}};Xo.prototype.compare=function(t,e){var i=t,n=e,r=Xo.compare(i.x,n.x);if(0!==r)return r;var o=Xo.compare(i.y,n.y);return 0!==o?o:this._dimensionsToTest<=2?0:Xo.compare(i.z,n.z)},Xo.prototype.interfaces_=function(){return[jo]},Xo.prototype.getClass=function(){return Xo},Xo.compare=function(t,e){return te?1:Fo.isNaN(t)?Fo.isNaN(e)?0:-1:Fo.isNaN(e)?1:0};var Zo=function(){};Zo.prototype.create=function(){},Zo.prototype.interfaces_=function(){return[]},Zo.prototype.getClass=function(){return Zo};var Yo=function(){},Qo={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};Yo.prototype.interfaces_=function(){return[]},Yo.prototype.getClass=function(){return Yo},Yo.toLocationSymbol=function(t){switch(t){case Yo.EXTERIOR:return"e";case Yo.BOUNDARY:return"b";case Yo.INTERIOR:return"i";case Yo.NONE:return"-"}throw new zo("Unknown location value: "+t)},Qo.INTERIOR.get=function(){return 0},Qo.BOUNDARY.get=function(){return 1},Qo.EXTERIOR.get=function(){return 2},Qo.NONE.get=function(){return-1},Object.defineProperties(Yo,Qo);var Jo=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},Ko=function(){},$o={LOG_10:{configurable:!0}};Ko.prototype.interfaces_=function(){return[]},Ko.prototype.getClass=function(){return Ko},Ko.log10=function(t){var e=Math.log(t);return Fo.isInfinite(e)||Fo.isNaN(e)?e:e/Ko.LOG_10},Ko.min=function(t,e,i,n){var r=t;return ei?i:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var n=arguments[0],r=arguments[1],o=arguments[2];return no?o:n}},Ko.wrap=function(t,e){return t<0?e- -t%e:t%e},Ko.max=function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],i=arguments[0];return t>i&&(i=t),e>i&&(i=e),i}if(4===arguments.length){var n=arguments[1],r=arguments[2],o=arguments[3],s=arguments[0];return n>s&&(s=n),r>s&&(s=r),o>s&&(s=o),s}},Ko.average=function(t,e){return(t+e)/2},$o.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(Ko,$o);var ts=function(t){this.str=t};ts.prototype.append=function(t){this.str+=t},ts.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},ts.prototype.toString=function(t){return this.str};var es=function(t){this.value=t};es.prototype.intValue=function(){return this.value},es.prototype.compareTo=function(t){return this.valuet?1:0},es.isNaN=function(t){return Number.isNaN(t)};var is=function(){};is.isWhitespace=function(t){return t<=32&&t>=0||127===t},is.toUpperCase=function(t){return t.toUpperCase()};var ns=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 i=arguments[0];this.init(i)}else if("string"==typeof arguments[0]){t.call(this,t.parse(arguments[0]))}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n,r)}},rs={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}};ns.prototype.le=function(t){return(this._hi9?(u=!0,h="9"):h="0"+c,s.append(h),i=i.subtract(ns.valueOf(c)).multiply(ns.TEN),u&&i.selfAdd(ns.TEN);var p=!0,d=ns.magnitude(i._hi);if(d<0&&Math.abs(d)>=a-l&&(p=!1),!p)break}return e[0]=n,s.toString()},ns.prototype.sqr=function(){return this.multiply(this)},ns.prototype.doubleValue=function(){return this._hi+this._lo},ns.prototype.subtract=function(){if(arguments[0]instanceof ns){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e)}},ns.prototype.equals=function(){if(1===arguments.length){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}},ns.prototype.isZero=function(){return 0===this._hi&&0===this._lo},ns.prototype.selfSubtract=function(){if(arguments[0]instanceof ns){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)}},ns.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},ns.prototype.min=function(t){return this.le(t)?this:t},ns.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof ns){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 i,n,r,o,s=arguments[0],a=arguments[1],l=null,c=null,u=null,h=null;return r=this._hi/s,h=(l=(u=ns.SPLIT*r)-(l=u-r))*(c=(h=ns.SPLIT*s)-(c=h-s))-(o=r*s)+l*(n=s-c)+(i=r-l)*c+i*n,h=r+(u=(this._hi-o-h+this._lo-r*a)/s),this._hi=h,this._lo=r-h+u,this}},ns.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">"},ns.prototype.divide=function(){if(arguments[0]instanceof ns){var t,e,i,n,r=arguments[0],o=null,s=null,a=null,l=null;return t=(i=this._hi/r._hi)-(o=(a=ns.SPLIT*i)-(o=a-i)),l=o*(s=(l=ns.SPLIT*r._hi)-(s=l-r._hi))-(n=i*r._hi)+o*(e=r._hi-s)+t*s+t*e,a=(this._hi-n-l+this._lo-i*r._lo)/r._hi,new ns(l=i+a,i-l+a)}if("number"==typeof arguments[0]){var c=arguments[0];return Fo.isNaN(c)?ns.createNaN():ns.copy(this).selfDivide(c,0)}},ns.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo},ns.prototype.pow=function(t){if(0===t)return ns.valueOf(1);var e=new ns(this),i=ns.valueOf(1),n=Math.abs(t);if(n>1)for(;n>0;)n%2==1&&i.selfMultiply(e),(n/=2)>0&&(e=e.sqr());else i=e;return t<0?i.reciprocal():i},ns.prototype.ceil=function(){if(this.isNaN())return ns.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new ns(t,e)},ns.prototype.compareTo=function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0},ns.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor()},ns.prototype.setValue=function(){if(arguments[0]instanceof ns){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this}},ns.prototype.max=function(t){return this.ge(t)?this:t},ns.prototype.sqrt=function(){if(this.isZero())return ns.valueOf(0);if(this.isNegative())return ns.NaN;var t=1/Math.sqrt(this._hi),e=this._hi*t,i=ns.valueOf(e),n=this.subtract(i.sqr())._hi*(.5*t);return i.add(n)},ns.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof ns){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var e,i,n,r,o,s=arguments[0],a=null;return a=(n=this._hi+s)-(r=n-this._hi),i=(o=(a=s-r+(this._hi-a))+this._lo)+(n-(e=n+o)),this._hi=e+i,this._lo=i+(e-this._hi),this}}else if(2===arguments.length){var l,c,u,h,p=arguments[0],d=arguments[1],f=null,m=null,g=null;u=this._hi+p,c=this._lo+d,m=u-(g=u-this._hi),f=c-(h=c-this._lo);var y=(l=u+(g=(m=p-g+(this._hi-m))+c))+(g=(f=d-h+(this._lo-f))+(g+(u-l))),v=g+(l-y);return this._hi=y,this._lo=v,this}},ns.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof ns){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 i,n,r=arguments[0],o=arguments[1],s=null,a=null,l=null,c=null;s=(l=ns.SPLIT*this._hi)-this._hi,c=ns.SPLIT*r,s=l-s,i=this._hi-s,a=c-r;var u=(l=this._hi*r)+(c=s*(a=c-a)-l+s*(n=r-a)+i*a+i*n+(this._hi*o+this._lo*r)),h=c+(s=l-u);return this._hi=u,this._lo=h,this}},ns.prototype.selfSqr=function(){return this.selfMultiply(this)},ns.prototype.floor=function(){if(this.isNaN())return ns.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new ns(t,e)},ns.prototype.negate=function(){return this.isNaN()?this:new ns(-this._hi,-this._lo)},ns.prototype.clone=function(){},ns.prototype.multiply=function(){if(arguments[0]instanceof ns){var t=arguments[0];return t.isNaN()?ns.createNaN():ns.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return Fo.isNaN(e)?ns.createNaN():ns.copy(this).selfMultiply(e,0)}},ns.prototype.isNaN=function(){return Fo.isNaN(this._hi)},ns.prototype.intValue=function(){return Math.trunc(this._hi)},ns.prototype.toString=function(){var t=ns.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},ns.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),i=this.extractSignificantDigits(!0,e),n=e[0]+1,r=i;if("."===i.charAt(0))r="0"+i;else if(n<0)r="0."+ns.stringOfChar("0",-n)+i;else if(-1===i.indexOf(".")){var o=n-i.length;r=i+ns.stringOfChar("0",o)+".0"}return this.isNegative()?"-"+r:r},ns.prototype.reciprocal=function(){var t,e,i,n,r=null,o=null,s=null,a=null;t=(i=1/this._hi)-(r=(s=ns.SPLIT*i)-(r=s-i)),o=(a=ns.SPLIT*this._hi)-this._hi;var l=i+(s=(1-(n=i*this._hi)-(a=r*(o=a-o)-n+r*(e=this._hi-o)+t*o+t*e)-i*this._lo)/this._hi);return new ns(l,i-l+s)},ns.prototype.toSciNotation=function(){if(this.isZero())return ns.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),i=this.extractSignificantDigits(!1,e),n=ns.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===i.charAt(0))throw new Error("Found leading zero: "+i);var r="";i.length>1&&(r=i.substring(1));var o=i.charAt(0)+"."+r;return this.isNegative()?"-"+o+n:o+n},ns.prototype.abs=function(){return this.isNaN()?ns.NaN:this.isNegative()?this.negate():new ns(this)},ns.prototype.isPositive=function(){return(this._hi>0||0===this._hi)&&this._lo>0},ns.prototype.lt=function(t){return(this._hit._hi||this._hi===t._hi)&&this._lo>t._lo},ns.prototype.isNegative=function(){return(this._hi<0||0===this._hi)&&this._lo<0},ns.prototype.trunc=function(){return this.isNaN()?ns.NaN:this.isPositive()?this.floor():this.ceil()},ns.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0},ns.prototype.interfaces_=function(){return[Ho,Uo,Go]},ns.prototype.getClass=function(){return ns},ns.sqr=function(t){return ns.valueOf(t).selfMultiply(t)},ns.valueOf=function(){return"string"==typeof arguments[0]?ns.parse(arguments[0]):"number"==typeof arguments[0]?new ns(arguments[0]):void 0},ns.sqrt=function(t){return ns.valueOf(t).sqrt()},ns.parse=function(t){for(var e=0,i=t.length;is.isWhitespace(t.charAt(e));)e++;var n=!1;if(e=i);){var c=t.charAt(e);if(e++,is.isDigit(c)){var u=c-"0";o.selfMultiply(ns.TEN),o.selfAdd(u),s++}else{if("."!==c){if("e"===c||"E"===c){var h=t.substring(e);try{l=es.parseInt(h)}catch(e){throw e instanceof Error?new Error("Invalid exponent "+h+" in string "+t):e}break}throw new Error("Unexpected character '"+c+"' at position "+e+" in string "+t)}a=s}}var p=o,d=s-a-l;if(0===d)p=o;else if(d>0){var f=ns.TEN.pow(d);p=o.divide(f)}else if(d<0){var m=ns.TEN.pow(-d);p=o.multiply(m)}return n?p.negate():p},ns.createNaN=function(){return new ns(Fo.NaN,Fo.NaN)},ns.copy=function(t){return new ns(t)},ns.magnitude=function(t){var e=Math.abs(t),i=Math.log(e)/Math.log(10),n=Math.trunc(Math.floor(i));return 10*Math.pow(10,n)<=e&&(n+=1),n},ns.stringOfChar=function(t,e){for(var i=new ts,n=0;n0){if(o<=0)return os.signum(s);n=r+o}else{if(!(r<0))return os.signum(s);if(o>=0)return os.signum(s);n=-r-o}var a=os.DP_SAFE_EPSILON*n;return s>=a||-s>=a?os.signum(s):2},os.signum=function(t){return t>0?1:t<0?-1:0},ss.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties(os,ss);var as=function(){},ls={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};ls.X.get=function(){return 0},ls.Y.get=function(){return 1},ls.Z.get=function(){return 2},ls.M.get=function(){return 3},as.prototype.setOrdinate=function(t,e,i){},as.prototype.size=function(){},as.prototype.getOrdinate=function(t,e){},as.prototype.getCoordinate=function(){},as.prototype.getCoordinateCopy=function(t){},as.prototype.getDimension=function(){},as.prototype.getX=function(t){},as.prototype.clone=function(){},as.prototype.expandEnvelope=function(t){},as.prototype.copy=function(){},as.prototype.getY=function(t){},as.prototype.toCoordinateArray=function(){},as.prototype.interfaces_=function(){return[Go]},as.prototype.getClass=function(){return as},Object.defineProperties(as,ls);var cs=function(){},us=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}(cs),hs=function(){};hs.arraycopy=function(t,e,i,n,r){for(var o=0,s=e;st._minx?this._minx:t._minx,i=this._miny>t._miny?this._miny:t._miny,n=this._maxx=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy)}}else if(2===arguments.length){var i=arguments[0],n=arguments[1];return!this.isNull()&&(i>=this._minx&&i<=this._maxx&&n>=this._miny&&n<=this._maxy)}},ds.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof ds){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx||ithis._maxy||nthis._maxx&&(this._maxx=e._maxx),e._minythis._maxy&&(this._maxy=e._maxy))}}else if(2===arguments.length){var i=arguments[0],n=arguments[1];this.isNull()?(this._minx=i,this._maxx=i,this._miny=n,this._maxy=n):(ithis._maxx&&(this._maxx=i),nthis._maxy&&(this._maxy=n))}},ds.prototype.minExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0},ds.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},ds.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"},ds.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1},ds.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny},ds.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},ds.prototype.expandBy=function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],i=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=i,this._maxy+=i,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}},ds.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof ds){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof Wo){var e=arguments[0];return this.covers(e)}}else if(2===arguments.length){var i=arguments[0],n=arguments[1];return this.covers(i,n)}},ds.prototype.centre=function(){return this.isNull()?null:new Wo((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},ds.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof Wo){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof ds){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 i=arguments[0],n=arguments[1];this.init(i.x,n.x,i.y,n.y)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];rt._maxx&&(e=this._minx-t._maxx);var i=0;return this._maxyt._maxy&&(i=this._miny-t._maxy),0===e?i:0===i?e:Math.sqrt(e*e+i*i)},ds.prototype.hashCode=function(){var t=17;return t=37*(t=37*(t=37*(t=37*t+Wo.hashCode(this._minx))+Wo.hashCode(this._maxx))+Wo.hashCode(this._miny))+Wo.hashCode(this._maxy)},ds.prototype.interfaces_=function(){return[Uo,Ho]},ds.prototype.getClass=function(){return ds},ds.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],i=arguments[2];return i.x>=(t.xe.x?t.x:e.x)&&i.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),l=Math.max(o.x,s.x),c=Math.min(n.x,r.x),u=Math.max(n.x,r.x);return!(c>l)&&(!(ul)&&!(uthis.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}},As.prototype.isProper=function(){return this.hasIntersection()&&this._isProper},As.prototype.setPrecisionModel=function(t){this._precisionModel=t},As.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],i=0;ir?n:r;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=n>r?s:a)||t.equals(e)||(o=Math.max(s,a))}return ws.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o},As.nonRobustComputeEdgeDistance=function(t,e,i){var n=t.x-e.x,r=t.y-e.y,o=Math.sqrt(n*n+r*r);return ws.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o},Es.DONT_INTERSECT.get=function(){return 0},Es.DO_INTERSECT.get=function(){return 1},Es.COLLINEAR.get=function(){return 2},Es.NO_INTERSECTION.get=function(){return 0},Es.POINT_INTERSECTION.get=function(){return 1},Es.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(As,Es);var Ss=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 ds(this._inputLines[0][0],this._inputLines[0][1]),i=new ds(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&i.contains(t)},e.prototype.computeIntersection=function(){if(3!==arguments.length)return t.prototype.computeIntersection.apply(this,arguments);var e=arguments[0],i=arguments[1],n=arguments[2];if(this._isProper=!1,ds.intersects(i,n,e)&&0===Is.orientationIndex(i,n,e)&&0===Is.orientationIndex(n,i,e))return this._isProper=!0,(e.equals(i)||e.equals(n))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION},e.prototype.normalizeToMinimum=function(t,e,i,n,r){r.x=this.smallestInAbsValue(t.x,e.x,i.x,n.x),r.y=this.smallestInAbsValue(t.y,e.y,i.y,n.y),t.x-=r.x,t.y-=r.y,e.x-=r.x,e.y-=r.y,i.x-=r.x,i.y-=r.y,n.x-=r.x,n.y-=r.y},e.prototype.safeHCoordinateIntersection=function(t,i,n,r){var o=null;try{o=ps.intersection(t,i,n,r)}catch(s){if(!(s instanceof us))throw s;o=e.nearestEndpoint(t,i,n,r)}return o},e.prototype.intersection=function(t,i,n,r){var o=this.intersectionWithNormalization(t,i,n,r);return this.isInSegmentEnvelopes(o)||(o=new Wo(e.nearestEndpoint(t,i,n,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o},e.prototype.smallestInAbsValue=function(t,e,i,n){var r=t,o=Math.abs(r);return Math.abs(e)1e-4&&hs.out.println("Distance = "+r.distance(o))},e.prototype.intersectionWithNormalization=function(t,e,i,n){var r=new Wo(t),o=new Wo(e),s=new Wo(i),a=new Wo(n),l=new Wo;this.normalizeToEnvCentre(r,o,s,a,l);var c=this.safeHCoordinateIntersection(r,o,s,a);return c.x+=l.x,c.y+=l.y,c},e.prototype.computeCollinearIntersection=function(e,i,n,r){var o=ds.intersects(e,i,n),s=ds.intersects(e,i,r),a=ds.intersects(n,r,e),l=ds.intersects(n,r,i);return o&&s?(this._intPt[0]=n,this._intPt[1]=r,t.COLLINEAR_INTERSECTION):a&&l?(this._intPt[0]=e,this._intPt[1]=i,t.COLLINEAR_INTERSECTION):o&&a?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||s||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):o&&l?(this._intPt[0]=n,this._intPt[1]=i,!n.equals(i)||s||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&a?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||o||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&l?(this._intPt[0]=r,this._intPt[1]=i,!r.equals(i)||o||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION},e.prototype.normalizeToEnvCentre=function(t,e,i,n,r){var o=t.xe.x?t.x:e.x,l=t.y>e.y?t.y:e.y,c=i.xn.x?i.x:n.x,p=i.y>n.y?i.y:n.y,d=((o>c?o:c)+(au?s:u)+(l0&&s>0||o<0&&s<0)return t.NO_INTERSECTION;var a=Is.orientationIndex(n,r,e),l=Is.orientationIndex(n,r,i);return a>0&&l>0||a<0&&l<0?t.NO_INTERSECTION:0===o&&0===s&&0===a&&0===l?this.computeCollinearIntersection(e,i,n,r):(0===o||0===s||0===a||0===l?(this._isProper=!1,e.equals2D(n)||e.equals2D(r)?this._intPt[0]=e:i.equals2D(n)||i.equals2D(r)?this._intPt[0]=i:0===o?this._intPt[0]=new Wo(n):0===s?this._intPt[0]=new Wo(r):0===a?this._intPt[0]=new Wo(e):0===l&&(this._intPt[0]=new Wo(i))):(this._isProper=!0,this._intPt[0]=this.intersection(e,i,n,r)),t.POINT_INTERSECTION)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.nearestEndpoint=function(t,e,i,n){var r=t,o=Is.distancePointLine(t,i,n),s=Is.distancePointLine(e,i,n);return s0?i>0?-r:r:i>0?r:-r;if(0===e||0===i)return n>0?t>0?r:-r:t>0?-r:r;if(e>0?n>0?e<=n||(r=-r,o=t,t=i,i=o,o=e,e=n,n=o):e<=-n?(r=-r,i=-i,n=-n):(o=t,t=-i,i=o,o=e,e=-n,n=o):n>0?-e<=n?(r=-r,t=-t,e=-e):(o=-t,t=i,i=o,o=-e,e=n,n=o):e>=n?(t=-t,e=-e,i=-i,n=-n):(r=-r,o=-t,t=-i,i=o,o=-e,e=-n,n=o),t>0){if(!(i>0))return r;if(!(t<=i))return r}else{if(i>0)return-r;if(!(t>=i))return-r;r=-r,t=-t,i=-i}for(;;){if((n-=(s=Math.floor(i/t))*e)<0)return-r;if(n>e)return r;if(t>(i-=s*t)+i){if(en+n)return-r;i=t-i,n=e-n,r=-r}if(0===n)return 0===i?0:-r;if(0===i)return r;if((e-=(s=Math.floor(t/i))*n)<0)return r;if(e>n)return-r;if(i>(t-=s*i)+t){if(ne+e)return r;t=i-t,e=n-e,r=-r}if(0===e)return 0===t?0:r;if(0===t)return-r}};var Ts=function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t};Ts.prototype.countSegment=function(t,e){if(t.xn&&(i=e.x,n=t.x),this._p.x>=i&&this._p.x<=n&&(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 r=t.x-this._p.x,o=t.y-this._p.y,s=e.x-this._p.x,a=e.y-this._p.y,l=Ms.signOfDet2x2(r,o,s,a);if(0===l)return this._isPointOnSegment=!0,null;a0&&this._crossingCount++}},Ts.prototype.isPointInPolygon=function(){return this.getLocation()!==Yo.EXTERIOR},Ts.prototype.getLocation=function(){return this._isPointOnSegment?Yo.BOUNDARY:this._crossingCount%2==1?Yo.INTERIOR:Yo.EXTERIOR},Ts.prototype.isOnSegment=function(){return this._isPointOnSegment},Ts.prototype.interfaces_=function(){return[]},Ts.prototype.getClass=function(){return Ts},Ts.locatePointInRing=function(){if(arguments[0]instanceof Wo&&Jo(arguments[1],as)){for(var t=arguments[1],e=new Ts(arguments[0]),i=new Wo,n=new Wo,r=1;r1||a<0||a>1)&&(r=!0)}}else r=!0;return r?Ko.min(Is.distancePointLine(t,i,n),Is.distancePointLine(e,i,n),Is.distancePointLine(i,t,e),Is.distancePointLine(n,t,e)):0},Is.isPointInRing=function(t,e){return Is.locatePointInRing(t,e)!==Yo.EXTERIOR},Is.computeLength=function(t){var e=t.size();if(e<=1)return 0;var i=0,n=new Wo;t.getCoordinate(0,n);for(var r=n.x,o=n.y,s=1;si.y&&(i=o,n=r)}var s=n;do{(s-=1)<0&&(s=e)}while(t[s].equals2D(i)&&s!==n);var a=n;do{a=(a+1)%e}while(t[a].equals2D(i)&&a!==n);var l=t[s],c=t[a];if(l.equals2D(i)||c.equals2D(i)||l.equals2D(c))return!1;var u=Is.computeOrientation(l,i,c),h=!1;return h=0===u?l.x>c.x:u>0,h},Is.locatePointInRing=function(t,e){return Ts.locatePointInRing(t,e)},Is.distancePointLinePerpendicular=function(t,e,i){var n=(i.x-e.x)*(i.x-e.x)+(i.y-e.y)*(i.y-e.y),r=((e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y))/n;return Math.abs(r)*Math.sqrt(n)},Is.computeOrientation=function(t,e,i){return Is.orientationIndex(t,e,i)},Is.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new zo("Line array must contain at least one vertex");for(var i=t.distance(e[0]),n=0;n=1)return o.distance(a);var u=((s.y-o.y)*(a.x-s.x)-(s.x-o.x)*(a.y-s.y))/l;return Math.abs(u)*Math.sqrt(l)}},Is.isOnLine=function(t,e){for(var i=new Ss,n=1;n0},zs.prototype.interfaces_=function(){return[ks]},zs.prototype.getClass=function(){return zs};var Fs=function(){};Fs.prototype.isInBoundary=function(t){return t>1},Fs.prototype.interfaces_=function(){return[ks]},Fs.prototype.getClass=function(){return Fs};var Vs=function(){};Vs.prototype.isInBoundary=function(t){return 1===t},Vs.prototype.interfaces_=function(){return[ks]},Vs.prototype.getClass=function(){return Vs};var Us=function(){};function Gs(t){this.message=t||""}Us.prototype.add=function(){},Us.prototype.addAll=function(){},Us.prototype.isEmpty=function(){},Us.prototype.iterator=function(){},Us.prototype.size=function(){},Us.prototype.toArray=function(){},Us.prototype.remove=function(){},Gs.prototype=new Error,Gs.prototype.name="IndexOutOfBoundsException";var js=function(){};js.prototype.hasNext=function(){},js.prototype.next=function(){},js.prototype.remove=function(){};var Hs=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}(Us);function Ws(t){this.message=t||""}Ws.prototype=new Error,Ws.prototype.name="NoSuchElementException";var qs=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof Us&&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,Us]},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 i=this.array_[t];return this.array_[t]=e,i},e.prototype.iterator=function(){return new Xs(this)},e.prototype.get=function(t){if(t<0||t>=this.size())throw new Gs;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,i=this.array_.length;e=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 s=arguments[0],a=arguments[1];return this.add(s,a),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var l=arguments[0],c=arguments[1];if(arguments[2])for(var u=0;u=0;h--)e.add(l[h],c);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof Wo){var p=arguments[0],d=arguments[1];if(!arguments[2]){var f=this.size();if(f>0){if(p>0)if(this.get(p-1).equals2D(d))return null;if(pv&&(_=-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 Wo(this.get(0)),!1)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},Object.defineProperties(e,i),e}(qs),Ys=function(){},Qs={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};Qs.ForwardComparator.get=function(){return Js},Qs.BidirectionalComparator.get=function(){return Ks},Qs.coordArrayType.get=function(){return new Array(0).fill(null)},Ys.prototype.interfaces_=function(){return[]},Ys.prototype.getClass=function(){return Ys},Ys.isRing=function(t){return!(t.length<4)&&!!t[0].equals2D(t[t.length-1])},Ys.ptNotInList=function(t,e){for(var i=0;i=t?e:[]},Ys.indexOf=function(t,e){for(var i=0;i0)&&(e=t[i]);return e},Ys.extract=function(t,e,i){e=Ko.clamp(e,0,t.length);var n=(i=Ko.clamp(i,-1,t.length))-e+1;i<0&&(n=0),e>=t.length&&(n=0),in.length)return 1;if(0===i.length)return 0;var r=Ys.compare(i,n);return Ys.isEqualReversed(i,n)?0:r},Ks.prototype.OLDcompare=function(t,e){var i=t,n=e;if(i.lengthn.length)return 1;if(0===i.length)return 0;for(var r=Ys.increasingDirection(i),o=Ys.increasingDirection(n),s=r>0?0:i.length-1,a=o>0?0:i.length-1,l=0;l0))return e.value;e=e.right}}return null},ua.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 i,n,r=this.root_;do{if(i=r,(n=t.compareTo(r.key))<0)r=r.left;else{if(!(n>0)){var o=r.value;return r.value=e,o}r=r.right}}while(null!==r);var s={key:t,left:null,right:null,value:e,parent:i,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return n<0?i.left=s:i.right=s,this.fixAfterInsertion(s),this.size_++,null},ua.prototype.fixAfterInsertion=function(t){var e=this;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)if(sa(t)===la(sa(sa(t)))){var i=ca(sa(sa(t)));1===oa(i)?(aa(sa(t),0),aa(i,0),aa(sa(sa(t)),1),t=sa(sa(t))):(t===ca(sa(t))&&(t=sa(t),e.rotateLeft(t)),aa(sa(t),0),aa(sa(sa(t)),1),e.rotateRight(sa(sa(t))))}else{var n=la(sa(sa(t)));1===oa(n)?(aa(sa(t),0),aa(n,0),aa(sa(sa(t)),1),t=sa(sa(t))):(t===la(sa(t))&&(t=sa(t),e.rotateRight(t)),aa(sa(t),0),aa(sa(sa(t)),1),e.rotateLeft(sa(sa(t))))}this.root_.color=0},ua.prototype.values=function(){var t=new qs,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=ua.successor(e));)t.add(e.value);return t},ua.prototype.entrySet=function(){var t=new na,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=ua.successor(e));)t.add(e);return t},ua.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}},ua.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}},ua.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},ua.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 i=t.parent,n=t;null!==i&&n===i.right;)n=i,i=i.parent;return i},ua.prototype.size=function(){return this.size_};var ha=function(){};function pa(){}function da(){this.array_=[],arguments[0]instanceof Us&&this.addAll(arguments[0])}ha.prototype.interfaces_=function(){return[]},ha.prototype.getClass=function(){return ha},pa.prototype=new ia,da.prototype=new pa,da.prototype.contains=function(t){for(var e=0,i=this.array_.length;e=0;){var s=r.substring(0,o);n.add(s),o=(r=r.substring(o+i)).indexOf(e)}r.length>0&&n.add(r);for(var a=new Array(n.size()).fill(null),l=0;l0)for(var o=r;o0&&n.append(" ");for(var o=0;o0&&n.append(","),n.append(Pa.toString(t.getOrdinate(r,o)))}return n.append(")"),n.toString()}},Da.ensureValidRing=function(t,e){var i=e.size();return 0===i?e:i<=3?Da.createClosedRing(t,e,4):e.getOrdinate(0,as.X)===e.getOrdinate(i-1,as.X)&&e.getOrdinate(0,as.Y)===e.getOrdinate(i-1,as.Y)?e:Da.createClosedRing(t,e,i+1)},Da.createClosedRing=function(t,e,i){var n=t.create(i,e.getDimension()),r=e.size();Da.copy(e,0,n,0,r);for(var o=r;o0&&Da.reverse(t._points),null}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?ga.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 Is.computeLength(this._points)},e.prototype.getNumPoints=function(){return this._points.size()},e.prototype.reverse=function(){var t=this._points.copy();return Da.reverse(t),this.getFactory().createLineString(t)},e.prototype.compareToSameClass=function(){if(1===arguments.length){for(var t=arguments[0],e=0,i=0;e= 2)");this._points=t},e.prototype.isCoordinate=function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 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},i.MINIMUM_VALID_SIZE.get=function(){return 4},i.serialVersionUID.get=function(){return-0x3b229e262367a600},Object.defineProperties(e,i),e}(Ra),Va=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var i={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return Ls.SORTINDEX_MULTIPOLYGON},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],i=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,i)}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),i=0;i0?e.createPoint(i[0]):e.createPoint():t},Ha.prototype.interfaces_=function(){return[Ua.GeometryEditorOperation]},Ha.prototype.getClass=function(){return Ha};var Wa=function(){};Wa.prototype.edit=function(t,e){return t instanceof Fa?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof Ra?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof ka?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},Wa.prototype.interfaces_=function(){return[Ua.GeometryEditorOperation]},Wa.prototype.getClass=function(){return Wa};var qa=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 i=0;i0){var t=new ts(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(e=3),e<2?new qa(t):new qa(t,e)}},Za.prototype.interfaces_=function(){return[Zo,Ho]},Za.prototype.getClass=function(){return Za},Za.instance=function(){return Za.instanceObject},Ya.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},Ya.instanceObject.get=function(){return new Za},Object.defineProperties(Za,Ya);var Qa=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 qs,e=this.map_.values(),i=e.next();!i.done;)t.add(i.value),i=e.next();return t},e.prototype.entrySet=function(){var t=new na;return this.map_.entries().forEach((function(e){return t.add(e)})),t},e.prototype.size=function(){return this.map_.size()},e}($s),Ja=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 $a){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var i=arguments[0];this._modelType=t.FIXED,this.setScale(i)}else if(arguments[0]instanceof t){var n=arguments[0];this._modelType=n._modelType,this._scale=n._scale}},Ka={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};Ja.prototype.equals=function(t){if(!(t instanceof Ja))return!1;var e=t;return this._modelType===e._modelType&&this._scale===e._scale},Ja.prototype.compareTo=function(t){var e=t,i=this.getMaximumSignificantDigits(),n=e.getMaximumSignificantDigits();return new es(i).compareTo(new es(n))},Ja.prototype.getScale=function(){return this._scale},Ja.prototype.isFloating=function(){return this._modelType===Ja.FLOATING||this._modelType===Ja.FLOATING_SINGLE},Ja.prototype.getType=function(){return this._modelType},Ja.prototype.toString=function(){var t="UNKNOWN";return this._modelType===Ja.FLOATING?t="Floating":this._modelType===Ja.FLOATING_SINGLE?t="Floating-Single":this._modelType===Ja.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},Ja.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var t=arguments[0];return Fo.isNaN(t)||this._modelType===Ja.FLOATING_SINGLE?t:this._modelType===Ja.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof Wo){var e=arguments[0];if(this._modelType===Ja.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},Ja.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===Ja.FLOATING?t=16:this._modelType===Ja.FLOATING_SINGLE?t=6:this._modelType===Ja.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},Ja.prototype.setScale=function(t){this._scale=Math.abs(t)},Ja.prototype.interfaces_=function(){return[Ho,Uo]},Ja.prototype.getClass=function(){return Ja},Ja.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},Ka.serialVersionUID.get=function(){return 0x6bee6404e9a25c00},Ka.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(Ja,Ka);var $a=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this)},tl={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};$a.prototype.readResolve=function(){return $a.nameToTypeMap.get(this._name)},$a.prototype.toString=function(){return this._name},$a.prototype.interfaces_=function(){return[Ho]},$a.prototype.getClass=function(){return $a},tl.serialVersionUID.get=function(){return-552860263173159e4},tl.nameToTypeMap.get=function(){return new Qa},Object.defineProperties($a,tl),Ja.Type=$a,Ja.FIXED=new $a("FIXED"),Ja.FLOATING=new $a("FLOATING"),Ja.FLOATING_SINGLE=new $a("FLOATING SINGLE");var el=function t(){this._precisionModel=new Ja,this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?Jo(arguments[0],Zo)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof Ja&&(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]))},il={serialVersionUID:{configurable:!0}};el.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new Wo(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new Wo(t.getMinX(),t.getMinY()),new Wo(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new Wo(t.getMinX(),t.getMinY()),new Wo(t.getMinX(),t.getMaxY()),new Wo(t.getMaxX(),t.getMaxY()),new Wo(t.getMaxX(),t.getMinY()),new Wo(t.getMinX(),t.getMinY())]),null)},el.prototype.createLineString=function(t){return t?t instanceof Array?new Ra(this.getCoordinateSequenceFactory().create(t),this):Jo(t,as)?new Ra(t,this):void 0:new Ra(this.getCoordinateSequenceFactory().create([]),this)},el.prototype.createMultiLineString=function(){return 0===arguments.length?new ba(null,this):1===arguments.length?new ba(arguments[0],this):void 0},el.prototype.buildGeometry=function(t){for(var e=null,i=!1,n=!1,r=t.iterator();r.hasNext();){var o=r.next(),s=o.getClass();null===e&&(e=s),s!==e&&(i=!0),o.isGeometryCollectionOrDerived()&&(n=!0)}if(null===e)return this.createGeometryCollection();if(i||n)return this.createGeometryCollection(el.toGeometryArray(t));var a=t.iterator().next();if(t.size()>1){if(a instanceof Ba)return this.createMultiPolygon(el.toPolygonArray(t));if(a instanceof Ra)return this.createMultiLineString(el.toLineStringArray(t));if(a instanceof ka)return this.createMultiPoint(el.toPointArray(t));ws.shouldNeverReachHere("Unhandled class: "+a.getClass().getName())}return a},el.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},el.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Wo){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(Jo(arguments[0],as))return new ka(arguments[0],this)}},el.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory},el.prototype.createPolygon=function(){if(0===arguments.length)return new Ba(null,null,this);if(1===arguments.length){if(Jo(arguments[0],as)){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 Fa){var i=arguments[0];return this.createPolygon(i,null)}}else if(2===arguments.length){return new Ba(arguments[0],arguments[1],this)}},el.prototype.getSRID=function(){return this._SRID},el.prototype.createGeometryCollection=function(){return 0===arguments.length?new xa(null,this):1===arguments.length?new xa(arguments[0],this):void 0},el.prototype.createGeometry=function(t){return new Ua(this).edit(t,{edit:function(){if(2===arguments.length){var t=arguments[0];return this._coordinateSequenceFactory.create(t)}}})},el.prototype.getPrecisionModel=function(){return this._precisionModel},el.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(Jo(arguments[0],as))return new Fa(arguments[0],this)}},el.prototype.createMultiPolygon=function(){return 0===arguments.length?new Va(null,this):1===arguments.length?new Va(arguments[0],this):void 0},el.prototype.createMultiPoint=function(){if(0===arguments.length)return new za(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new za(arguments[0],this);if(arguments[0]instanceof Array){var t=arguments[0];return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(Jo(arguments[0],as)){var e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));for(var i=new Array(e.size()).fill(null),n=0;n=this.size())throw new Error;return this.array_[t]},pl.prototype.push=function(t){return this.array_.push(t),t},pl.prototype.pop=function(t){if(0===this.array_.length)throw new hl;return this.array_.pop()},pl.prototype.peek=function(){if(0===this.array_.length)throw new hl;return this.array_[this.array_.length-1]},pl.prototype.empty=function(){return 0===this.array_.length},pl.prototype.isEmpty=function(){return this.empty()},pl.prototype.search=function(t){return this.array_.indexOf(t)},pl.prototype.size=function(){return this.array_.length},pl.prototype.toArray=function(){for(var t=[],e=0,i=this.array_.length;e0&&this._minIndexthis._minCoord.y&&i.y>this._minCoord.y&&n===Is.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)},dl.prototype.getRightmostSideOfSegment=function(t,e){var i=t.getEdge().getCoordinates();if(e<0||e+1>=i.length)return-1;if(i[e].y===i[e+1].y)return-1;var n=cl.LEFT;return i[e].ye._minCoord.x)&&(e._minDe=t,e._minIndex=n,e._minCoord=i[n])},dl.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)},dl.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var i=e.next();i.isForward()&&this.checkForRightmostCoordinate(i)}ws.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)===cl.LEFT&&(this._orientedDe=this._minDe.getSym())},dl.prototype.interfaces_=function(){return[]},dl.prototype.getClass=function(){return dl};var fl=function(t){function e(i,n){t.call(this,e.msgWithCoord(i,n)),this.pt=n?new Wo(n):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}(xs),ml=function(){this.array_=[]};ml.prototype.addLast=function(t){this.array_.push(t)},ml.prototype.removeFirst=function(){return this.array_.shift()},ml.prototype.isEmpty=function(){return 0===this.array_.length};var gl=function(){this._finder=null,this._dirEdgeList=new qs,this._nodes=new qs,this._rightMostCoord=null,this._env=null,this._finder=new dl};gl.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){t.next().setVisited(!1)}},gl.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},gl.prototype.computeNodeDepth=function(t){for(var e=null,i=t.getEdges().iterator();i.hasNext();){var n=i.next();if(n.isVisited()||n.getSym().isVisited()){e=n;break}}if(null===e)throw new fl("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var r=t.getEdges().iterator();r.hasNext();){var o=r.next();o.setVisited(!0),this.copySymDepths(o)}},gl.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(cl.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},gl.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},gl.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(cl.RIGHT)>=1&&e.getDepth(cl.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},gl.prototype.computeDepths=function(t){var e=new na,i=new ml,n=t.getNode();for(i.addLast(n),e.add(n),t.setVisited(!0);!i.isEmpty();){var r=i.removeFirst();e.add(r),this.computeNodeDepth(r);for(var o=r.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(i.addLast(a),e.add(a))}}}},gl.prototype.compareTo=function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0},gl.prototype.getEnvelope=function(){if(null===this._env){for(var t=new ds,e=this._dirEdgeList.iterator();e.hasNext();)for(var i=e.next().getEdge().getCoordinates(),n=0;nthis.location.length){var e=new Array(3).fill(null);e[cl.ON]=this.location[cl.ON],e[cl.LEFT]=Yo.NONE,e[cl.RIGHT]=Yo.NONE,this.location=e}for(var i=0;i1&&t.append(Yo.toLocationSymbol(this.location[cl.LEFT])),t.append(Yo.toLocationSymbol(this.location[cl.ON])),this.location.length>1&&t.append(Yo.toLocationSymbol(this.location[cl.RIGHT])),t.toString()},yl.prototype.setLocations=function(t,e,i){this.location[cl.ON]=t,this.location[cl.LEFT]=e,this.location[cl.RIGHT]=i},yl.prototype.get=function(t){return t1},yl.prototype.isAnyNull=function(){for(var t=0;tt._maxNodeDegree&&(t._maxNodeDegree=i),e=t.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2},_l.prototype.addPoints=function(t,e,i){var n=t.getCoordinates();if(e){var r=1;i&&(r=0);for(var o=r;o=0;a--)this._pts.add(n[a])}},_l.prototype.isHole=function(){return this._isHole},_l.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)},_l.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!Is.isPointInRing(t,e.getCoordinates()))return!1;for(var i=this._holes.iterator();i.hasNext();){if(i.next().containsPoint(t))return!1}return!0},_l.prototype.addHole=function(t){this._holes.add(t)},_l.prototype.isShell=function(){return null===this._shell},_l.prototype.getLabel=function(){return this._label},_l.prototype.getEdges=function(){return this._edges},_l.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},_l.prototype.getShell=function(){return this._shell},_l.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],i=arguments[0].getLocation(e,cl.RIGHT);if(i===Yo.NONE)return null;if(this._label.getLocation(e)===Yo.NONE)return this._label.setLocation(e,i),null}},_l.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this)},_l.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),i=0;i=2,"found partial label"),this.computeIM(t)},wl.prototype.isInResult=function(){return this._isInResult},wl.prototype.isVisited=function(){return this._isVisited},wl.prototype.interfaces_=function(){return[]},wl.prototype.getClass=function(){return wl};var Al=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var e=arguments[0],i=arguments[1];this._coord=e,this._edges=i,this._label=new vl(0,Yo.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 i=Yo.NONE;if(i=this._label.getLocation(e),!t.isNull(e)){var n=t.getLocation(e);i!==Yo.BOUNDARY&&(i=n)}return i},e.prototype.setLabel=function(){if(2!==arguments.length)return t.prototype.setLabel.apply(this,arguments);var e=arguments[0],i=arguments[1];null===this._label?this._label=new vl(e,i):this._label.setLocation(e,i)},e.prototype.getEdges=function(){return this._edges},e.prototype.mergeLabel=function(){var t=this;if(arguments[0]instanceof e){var i=arguments[0];this.mergeLabel(i._label)}else if(arguments[0]instanceof vl)for(var n=arguments[0],r=0;r<2;r++){var o=t.computeMergedLocation(n,r);t._label.getLocation(r)===Yo.NONE&&t._label.setLocation(r,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=Yo.NONE;null!==this._label&&(e=this._label.getLocation(t));var i=null;if(e===Yo.BOUNDARY)i=Yo.INTERIOR;else i=Yo.BOUNDARY;this._label.setLocation(t,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(wl),El=function(){this.nodeMap=new ua,this.nodeFact=null;var t=arguments[0];this.nodeFact=t};El.prototype.find=function(t){return this.nodeMap.get(t)},El.prototype.addNode=function(){if(arguments[0]instanceof Wo){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 Al){var i=arguments[0],n=this.nodeMap.get(i.getCoordinate());return null===n?(this.nodeMap.put(i.getCoordinate(),i),i):(n.mergeLabel(i),n)}},El.prototype.print=function(t){for(var e=this.iterator();e.hasNext();){e.next().print(t)}},El.prototype.iterator=function(){return this.nodeMap.values().iterator()},El.prototype.values=function(){return this.nodeMap.values()},El.prototype.getBoundaryNodes=function(t){for(var e=new qs,i=this.iterator();i.hasNext();){var n=i.next();n.getLabel().getLocation(t)===Yo.BOUNDARY&&e.add(n)}return e},El.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t)},El.prototype.interfaces_=function(){return[]},El.prototype.getClass=function(){return El};var Sl=function(){},Ml={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};Sl.prototype.interfaces_=function(){return[]},Sl.prototype.getClass=function(){return Sl},Sl.isNorthern=function(t){return t===Sl.NE||t===Sl.NW},Sl.isOpposite=function(t,e){return t!==e&&2===(t-e+4)%4},Sl.commonHalfPlane=function(t,e){if(t===e)return t;if(2===(t-e+4)%4)return-1;var i=te?t:e)?3:i},Sl.isInHalfPlane=function(t,e){return e===Sl.SE?t===Sl.SE||t===Sl.SW:t===e||t===e+1},Sl.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 zo("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?Sl.NE:Sl.SE:e>=0?Sl.NW:Sl.SW}if(arguments[0]instanceof Wo&&arguments[1]instanceof Wo){var i=arguments[0],n=arguments[1];if(n.x===i.x&&n.y===i.y)throw new zo("Cannot compute the quadrant for two identical points "+i);return n.x>=i.x?n.y>=i.y?Sl.NE:Sl.SE:n.y>=i.y?Sl.NW:Sl.SW}},Ml.NE.get=function(){return 0},Ml.NW.get=function(){return 1},Ml.SW.get=function(){return 2},Ml.SE.get=function(){return 3},Object.defineProperties(Sl,Ml);var Tl=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],i=arguments[1],n=arguments[2];this._edge=e,this.init(i,n),this._label=null}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this._edge=r,this.init(o,s),this._label=a}};Tl.prototype.compareDirection=function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):i.addAll(s)}else n.add(o)}return n},Ll.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();){if(e.next().containsPoint(t))return!0}return!1},Ll.prototype.buildMaximalEdgeRings=function(t){for(var e=new qs,i=t.iterator();i.hasNext();){var n=i.next();if(n.isInResult()&&n.getLabel().isArea()&&null===n.getEdgeRing()){var r=new bl(n,this._geometryFactory);e.add(r),r.setInResult()}}return e},Ll.prototype.placePolygonHoles=function(t,e){for(var i=e.iterator();i.hasNext();){var n=i.next();n.isHole()&&n.setShell(t)}},Ll.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},Ll.prototype.findEdgeRingContaining=function(t,e){for(var i=t.getLinearRing(),n=i.getEnvelopeInternal(),r=i.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var l=a.next(),c=l.getLinearRing(),u=c.getEnvelopeInternal();null!==o&&(s=o.getLinearRing().getEnvelopeInternal());var h=!1;u.contains(n)&&Is.isPointInRing(r,c.getCoordinates())&&(h=!0),h&&(null===o||s.contains(u))&&(o=l)}return o},Ll.prototype.findShell=function(t){for(var e=0,i=null,n=t.iterator();n.hasNext();){var r=n.next();r.isHole()||(i=r,e++)}return ws.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),i},Ll.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];Pl.linkResultDirectedEdges(arguments[1]);var i=this.buildMaximalEdgeRings(e),n=new qs,r=this.buildMinimalEdgeRings(i,this._shellList,n);this.sortShellsAndHoles(r,this._shellList,n),this.placeFreeHoles(this._shellList,n)}},Ll.prototype.interfaces_=function(){return[]},Ll.prototype.getClass=function(){return Ll};var Dl=function(){};Dl.prototype.getBounds=function(){},Dl.prototype.interfaces_=function(){return[]},Dl.prototype.getClass=function(){return Dl};var Rl=function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e};Rl.prototype.getItem=function(){return this._item},Rl.prototype.getBounds=function(){return this._bounds},Rl.prototype.interfaces_=function(){return[Dl,Ho]},Rl.prototype.getClass=function(){return Rl};var Ol=function(){this._size=null,this._items=null,this._size=0,this._items=new qs,this._items.add(null)};Ol.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},Ol.prototype.size=function(){return this._size},Ol.prototype.reorder=function(t){for(var e=this,i=null,n=this._items.get(t);2*t<=this._size&&((i=2*t)!==e._size&&e._items.get(i+1).compareTo(e._items.get(i))<0&&i++,e._items.get(i).compareTo(n)<0);t=i)e._items.set(t,e._items.get(i));this._items.set(t,n)},Ol.prototype.clear=function(){this._size=0,this._items.clear()},Ol.prototype.isEmpty=function(){return 0===this._size},Ol.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)},Ol.prototype.interfaces_=function(){return[]},Ol.prototype.getClass=function(){return Ol};var kl=function(){};kl.prototype.visitItem=function(t){},kl.prototype.interfaces_=function(){return[]},kl.prototype.getClass=function(){return kl};var Nl=function(){};Nl.prototype.insert=function(t,e){},Nl.prototype.remove=function(t,e){},Nl.prototype.query=function(){},Nl.prototype.interfaces_=function(){return[]},Nl.prototype.getClass=function(){return Nl};var Bl=function(){if(this._childBoundables=new qs,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}},zl={serialVersionUID:{configurable:!0}};Bl.prototype.getLevel=function(){return this._level},Bl.prototype.size=function(){return this._childBoundables.size()},Bl.prototype.getChildBoundables=function(){return this._childBoundables},Bl.prototype.addChildBoundable=function(t){ws.isTrue(null===this._bounds),this._childBoundables.add(t)},Bl.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},Bl.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds},Bl.prototype.interfaces_=function(){return[Dl,Ho]},Bl.prototype.getClass=function(){return Bl},zl.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties(Bl,zl);var Fl=function(){};Fl.reverseOrder=function(){return{compare:function(t,e){return e.compareTo(t)}}},Fl.min=function(t){return Fl.sort(t),t.get(0)},Fl.sort=function(t,e){var i=t.toArray();e?ma.sort(i,e):ma.sort(i);for(var n=t.iterator(),r=0,o=i.length;rVl.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,t,e),null):(this.expand(this._boundable2,this._boundable1,t,e),null);if(i)return this.expand(this._boundable1,this._boundable2,t,e),null;if(n)return this.expand(this._boundable2,this._boundable1,t,e),null;throw new zo("neither boundable is composite")},Vl.prototype.isLeaves=function(){return!(Vl.isComposite(this._boundable1)||Vl.isComposite(this._boundable2))},Vl.prototype.compareTo=function(t){var e=t;return this._distancee._distance?1:0},Vl.prototype.expand=function(t,e,i,n){for(var r=t.getChildBoundables().iterator();r.hasNext();){var o=r.next(),s=new Vl(o,e,this._itemDistance);s.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=i}},Gl={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};Ul.prototype.getNodeCapacity=function(){return this._nodeCapacity},Ul.prototype.lastNode=function(t){return t.get(t.size()-1)},Ul.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 i=e.next();i instanceof Bl?t+=this.size(i):i instanceof Rl&&(t+=1)}return t}},Ul.prototype.removeItem=function(t,e){for(var i=null,n=t.getChildBoundables().iterator();n.hasNext();){var r=n.next();r instanceof Rl&&r.getItem()===e&&(i=r)}return null!==i&&(t.getChildBoundables().remove(i),!0)},Ul.prototype.itemsTree=function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new qs:t}if(1===arguments.length){for(var e=arguments[0],i=new qs,n=e.getChildBoundables().iterator();n.hasNext();){var r=n.next();if(r instanceof Bl){var o=this.itemsTree(r);null!==o&&i.add(o)}else r instanceof Rl?i.add(r.getItem()):ws.shouldNeverReachHere()}return i.size()<=0?null:i}},Ul.prototype.insert=function(t,e){ws.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Rl(t,e))},Ul.prototype.boundablesAtLevel=function(){if(1===arguments.length){var t=arguments[0],e=new qs;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var i=arguments[0],n=arguments[1],r=arguments[2];if(ws.isTrue(i>-2),n.getLevel()===i)return r.add(n),null;for(var o=n.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof Bl?this.boundablesAtLevel(i,s,r):(ws.isTrue(s instanceof Rl),-1===i&&r.add(s))}return null}},Ul.prototype.query=function(){var t=this;if(1===arguments.length){var e=arguments[0];this.build();var i=new qs;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.query(e,this._root,i),i}if(2===arguments.length){var n=arguments[0],r=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.query(n,this._root,r)}else if(3===arguments.length)if(Jo(arguments[2],kl)&&arguments[0]instanceof Object&&arguments[1]instanceof Bl)for(var o=arguments[0],s=arguments[2],a=arguments[1].getChildBoundables(),l=0;lt&&(t=n)}}return t+1}},Ul.prototype.createParentBoundables=function(t,e){var i=this;ws.isTrue(!t.isEmpty());var n=new qs;n.add(this.createNode(e));var r=new qs(t);Fl.sort(r,this.getComparator());for(var o=r.iterator();o.hasNext();){var s=o.next();i.lastNode(n).getChildBoundables().size()===i.getNodeCapacity()&&n.add(i.createNode(e)),i.lastNode(n).addChildBoundable(s)}return n},Ul.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()},Ul.prototype.interfaces_=function(){return[Ho]},Ul.prototype.getClass=function(){return Ul},Ul.compareDoubles=function(t,e){return t>e?1:t0);for(var i=new qs,n=0;n0;){var h=u.poll(),p=h.getDistance();if(p>=l)break;h.isLeaves()?(l=p,c=h):h.expandToQueue(u,l)}return[c.getBoundable(0).getItem(),c.getBoundable(1).getItem()]}}else if(3===arguments.length){var d=arguments[2],f=new Rl(arguments[0],arguments[1]),m=new Vl(this.getRoot(),f,d);return this.nearestNeighbour(m)[0]}},e.prototype.interfaces_=function(){return[Nl,Ho]},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())},i.STRtreeNode.get=function(){return ql},i.serialVersionUID.get=function(){return 0x39920f7d5f261e0},i.xComparator.get=function(){return{interfaces_:function(){return[jo]},compare:function(i,n){return t.compareDoubles(e.centreX(i.getBounds()),e.centreX(n.getBounds()))}}},i.yComparator.get=function(){return{interfaces_:function(){return[jo]},compare:function(i,n){return t.compareDoubles(e.centreY(i.getBounds()),e.centreY(n.getBounds()))}}},i.intersectsOp.get=function(){return{interfaces_:function(){return[t.IntersectsOp]},intersects:function(t,e){return t.intersects(e)}}},i.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(e,i),e}(Ul),ql=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 i=e.next();null===t?t=new ds(i.getBounds()):t.expandToInclude(i.getBounds())}return t},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Bl),Xl=function(){};Xl.prototype.interfaces_=function(){return[]},Xl.prototype.getClass=function(){return Xl},Xl.relativeSign=function(t,e){return te?1:0},Xl.compare=function(t,e,i){if(e.equals2D(i))return 0;var n=Xl.relativeSign(e.x,i.x),r=Xl.relativeSign(e.y,i.y);switch(t){case 0:return Xl.compareValue(n,r);case 1:return Xl.compareValue(r,n);case 2:return Xl.compareValue(r,-n);case 3:return Xl.compareValue(-n,r);case 4:return Xl.compareValue(-n,-r);case 5:return Xl.compareValue(-r,-n);case 6:return Xl.compareValue(-r,n);case 7:return Xl.compareValue(n,-r)}return ws.shouldNeverReachHere("invalid octant value"),0},Xl.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0};var Zl=function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],i=arguments[2],n=arguments[3];this._segString=t,this.coord=new Wo(e),this.segmentIndex=i,this._segmentOctant=n,this._isInterior=!e.equals2D(t.getCoordinate(i))};Zl.prototype.getCoordinate=function(){return this.coord},Zl.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},Zl.prototype.compareTo=function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:Xl.compare(this._segmentOctant,this.coord,e.coord)},Zl.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},Zl.prototype.isInterior=function(){return this._isInterior},Zl.prototype.interfaces_=function(){return[Uo]},Zl.prototype.getClass=function(){return Zl};var Yl=function(){this._nodeMap=new ua,this._edge=null;var t=arguments[0];this._edge=t};Yl.prototype.getSplitCoordinates=function(){var t=new Zs;this.addEndpoints();for(var e=this.iterator(),i=e.next();e.hasNext();){var n=e.next();this.addEdgeCoordinates(i,n,t),i=n}return t.toCoordinateArray()},Yl.prototype.addCollapsedNodes=function(){var t=new qs;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var i=e.next().intValue();this.add(this._edge.getCoordinate(i),i)}},Yl.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){e.next().print(t)}},Yl.prototype.findCollapsesFromExistingVertices=function(t){for(var e=0;e=0?e>=0?i>=n?0:1:i>=n?7:6:e>=0?i>=n?3:2:i>=n?4:5}if(arguments[0]instanceof Wo&&arguments[1]instanceof Wo){var r=arguments[0],o=arguments[1],s=o.x-r.x,a=o.y-r.y;if(0===s&&0===a)throw new zo("Cannot compute the octant for two identical points "+r);return Ql.octant(s,a)}};var Jl=function(){};Jl.prototype.getCoordinates=function(){},Jl.prototype.size=function(){},Jl.prototype.getCoordinate=function(t){},Jl.prototype.isClosed=function(){},Jl.prototype.setData=function(t){},Jl.prototype.getData=function(){},Jl.prototype.interfaces_=function(){return[]},Jl.prototype.getClass=function(){return Jl};var Kl=function(){};Kl.prototype.addIntersection=function(t,e){},Kl.prototype.interfaces_=function(){return[Jl]},Kl.prototype.getClass=function(){return Kl};var $l=function(){this._nodeList=new Yl(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};$l.prototype.getCoordinates=function(){return this._pts},$l.prototype.size=function(){return this._pts.length},$l.prototype.getCoordinate=function(t){return this._pts[t]},$l.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},$l.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},$l.prototype.setData=function(t){this._data=t},$l.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:Ql.octant(t,e)},$l.prototype.getData=function(){return this._data},$l.prototype.addIntersection=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var i=arguments[1],n=arguments[3],r=new Wo(arguments[0].getIntersection(n));this.addIntersection(r,i)}},$l.prototype.toString=function(){return _s.toLineString(new qa(this._pts))},$l.prototype.getNodeList=function(){return this._nodeList},$l.prototype.addIntersectionNode=function(t,e){var i=e,n=i+1;if(n=0&&i>=0||e<=0&&i<=0?Math.max(e,i):0}if(arguments[0]instanceof Wo){var n=arguments[0];return Is.orientationIndex(this.p0,this.p1,n)}},tc.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1])},tc.prototype.isVertical=function(){return this.p0.x===this.p1.x},tc.prototype.equals=function(t){if(!(t instanceof tc))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},tc.prototype.intersection=function(t){var e=new Ss;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},tc.prototype.project=function(){if(arguments[0]instanceof Wo){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new Wo(t);var e=this.projectionFactor(t),i=new Wo;return i.x=this.p0.x+e*(this.p1.x-this.p0.x),i.y=this.p0.y+e*(this.p1.y-this.p0.y),i}if(arguments[0]instanceof tc){var n=arguments[0],r=this.projectionFactor(n.p0),o=this.projectionFactor(n.p1);if(r>=1&&o>=1)return null;if(r<=0&&o<=0)return null;var s=this.project(n.p0);r<0&&(s=this.p0),r>1&&(s=this.p1);var a=this.project(n.p1);return o<0&&(a=this.p0),o>1&&(a=this.p1),new tc(s,a)}},tc.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},tc.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},tc.prototype.getCoordinate=function(t){return 0===t?this.p0:this.p1},tc.prototype.distancePerpendicular=function(t){return Is.distancePointLinePerpendicular(t,this.p0,this.p1)},tc.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},tc.prototype.midPoint=function(){return tc.midPoint(this.p0,this.p1)},tc.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,i=this.p1.y-this.p0.y,n=e*e+i*i;return n<=0?Fo.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*i)/n},tc.prototype.closestPoints=function(t){var e=this.intersection(t);if(null!==e)return[e,e];var i=new Array(2).fill(null),n=Fo.MAX_VALUE,r=null,o=this.closestPoint(t.p0);n=o.distance(t.p0),i[0]=o,i[1]=t.p0;var s=this.closestPoint(t.p1);(r=s.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||Fo.isNaN(e))&&(e=1),e},tc.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},tc.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},tc.prototype.distance=function(){if(arguments[0]instanceof tc){var t=arguments[0];return Is.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof Wo){var e=arguments[0];return Is.distancePointLine(e,this.p0,this.p1)}},tc.prototype.pointAlong=function(t){var e=new Wo;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},tc.prototype.hashCode=function(){var t=Fo.doubleToLongBits(this.p0.x);t^=31*Fo.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),i=Fo.doubleToLongBits(this.p1.x);return i^=31*Fo.doubleToLongBits(this.p1.y),e^(Math.trunc(i)^Math.trunc(i>>32))},tc.prototype.interfaces_=function(){return[Uo,Ho]},tc.prototype.getClass=function(){return tc},tc.midPoint=function(t,e){return new Wo((t.x+e.x)/2,(t.y+e.y)/2)},ec.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(tc,ec);var ic=function(){this.tempEnv1=new ds,this.tempEnv2=new ds,this._overlapSeg1=new tc,this._overlapSeg2=new tc};ic.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],i=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(i,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}},ic.prototype.interfaces_=function(){return[]},ic.prototype.getClass=function(){return ic};var nc=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],i=arguments[2],n=arguments[3];this._pts=t,this._start=e,this._end=i,this._context=n};nc.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]},nc.prototype.computeSelect=function(t,e,i,n){var r=this._pts[e],o=this._pts[i];if(n.tempEnv1.init(r,o),i-e==1)return n.select(this,e),null;if(!t.intersects(n.tempEnv1))return null;var s=Math.trunc((e+i)/2);e=t.length-1)return t.length-1;for(var n=Sl.quadrant(t[i],t[i+1]),r=e+1;rn.getId()&&(n.computeOverlaps(o,e),t._nOverlaps++),t._segInt.isDone())return null}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},i.SegmentOverlapAction.get=function(){return lc},Object.defineProperties(e,i),e}(sc),lc=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],i=arguments[2],n=arguments[3],r=arguments[0].getContext(),o=i.getContext();this._si.processIntersections(r,e,o,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ic),cc=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 i=arguments[0],n=arguments[1];this.setQuadrantSegments(i),this.setEndCapStyle(n)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a)}},uc={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}};cc.prototype.getEndCapStyle=function(){return this._endCapStyle},cc.prototype.isSingleSided=function(){return this._isSingleSided},cc.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=cc.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=cc.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==cc.JOIN_ROUND&&(this._quadrantSegments=cc.DEFAULT_QUADRANT_SEGMENTS)},cc.prototype.getJoinStyle=function(){return this._joinStyle},cc.prototype.setJoinStyle=function(t){this._joinStyle=t},cc.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t},cc.prototype.getSimplifyFactor=function(){return this._simplifyFactor},cc.prototype.getQuadrantSegments=function(){return this._quadrantSegments},cc.prototype.setEndCapStyle=function(t){this._endCapStyle=t},cc.prototype.getMitreLimit=function(){return this._mitreLimit},cc.prototype.setMitreLimit=function(t){this._mitreLimit=t},cc.prototype.setSingleSided=function(t){this._isSingleSided=t},cc.prototype.interfaces_=function(){return[]},cc.prototype.getClass=function(){return cc},cc.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)},uc.CAP_ROUND.get=function(){return 1},uc.CAP_FLAT.get=function(){return 2},uc.CAP_SQUARE.get=function(){return 3},uc.JOIN_ROUND.get=function(){return 1},uc.JOIN_MITRE.get=function(){return 2},uc.JOIN_BEVEL.get=function(){return 3},uc.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},uc.DEFAULT_MITRE_LIMIT.get=function(){return 5},uc.DEFAULT_SIMPLIFY_FACTOR.get=function(){return.01},Object.defineProperties(cc,uc);var hc=function(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=Is.COUNTERCLOCKWISE,this._inputLine=t||null},pc={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};hc.prototype.isDeletable=function(t,e,i,n){var r=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[i];return!!this.isConcave(r,o,s)&&(!!this.isShallow(r,o,s,n)&&this.isShallowSampled(r,o,t,i,n))},hc.prototype.deleteShallowConcavities=function(){for(var t=this,e=1,i=this.findNextNonDeletedIndex(e),n=this.findNextNonDeletedIndex(i),r=!1;n=0;n--)this.addPt(t[n])},dc.prototype.isRedundant=function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)Math.PI;)t-=mc.PI_TIMES_2;for(;t<=-Math.PI;)t+=mc.PI_TIMES_2;return t},mc.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],i=arguments[1],n=i.x-e.x,r=i.y-e.y;return Math.atan2(r,n)}},mc.isAcute=function(t,e,i){var n=t.x-e.x,r=t.y-e.y;return n*(i.x-e.x)+r*(i.y-e.y)>0},mc.isObtuse=function(t,e,i){var n=t.x-e.x,r=t.y-e.y;return n*(i.x-e.x)+r*(i.y-e.y)<0},mc.interiorAngle=function(t,e,i){var n=mc.angle(e,t),r=mc.angle(e,i);return Math.abs(r-n)},mc.normalizePositive=function(t){if(t<0){for(;t<0;)t+=mc.PI_TIMES_2;t>=mc.PI_TIMES_2&&(t=0)}else{for(;t>=mc.PI_TIMES_2;)t-=mc.PI_TIMES_2;t<0&&(t=0)}return t},mc.angleBetween=function(t,e,i){var n=mc.angle(e,t),r=mc.angle(e,i);return mc.diff(n,r)},mc.diff=function(t,e){var i=null;return(i=tMath.PI&&(i=2*Math.PI-i),i},mc.toRadians=function(t){return t*Math.PI/180},mc.getTurn=function(t,e){var i=Math.sin(e-t);return i>0?mc.COUNTERCLOCKWISE:i<0?mc.CLOCKWISE:mc.NONE},mc.angleBetweenOriented=function(t,e,i){var n=mc.angle(e,t),r=mc.angle(e,i)-n;return r<=-Math.PI?r+mc.PI_TIMES_2:r>Math.PI?r-mc.PI_TIMES_2:r},gc.PI_TIMES_2.get=function(){return 2*Math.PI},gc.PI_OVER_2.get=function(){return Math.PI/2},gc.PI_OVER_4.get=function(){return Math.PI/4},gc.COUNTERCLOCKWISE.get=function(){return Is.COUNTERCLOCKWISE},gc.CLOCKWISE.get=function(){return Is.CLOCKWISE},gc.NONE.get=function(){return Is.COLLINEAR},Object.defineProperties(mc,gc);var yc=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 tc,this._seg1=new tc,this._offset0=new tc,this._offset1=new tc,this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[0],i=arguments[1],n=arguments[2];this._precisionModel=e,this._bufParams=i,this._li=new Ss,this._filletAngleQuantum=Math.PI/2/i.getQuadrantSegments(),i.getQuadrantSegments()>=8&&i.getJoinStyle()===cc.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)},vc={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}};yc.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 i=Is.computeOrientation(this._s0,this._s1,this._s2),n=i===Is.CLOCKWISE&&this._side===cl.LEFT||i===Is.COUNTERCLOCKWISE&&this._side===cl.RIGHT;0===i?this.addCollinear(e):n?this.addOutsideTurn(i,e):this.addInsideTurn(i,e)},yc.prototype.addLineEndCap=function(t,e){var i=new tc(t,e),n=new tc;this.computeOffsetSegment(i,cl.LEFT,this._distance,n);var r=new tc;this.computeOffsetSegment(i,cl.RIGHT,this._distance,r);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case cc.CAP_ROUND:this._segList.addPt(n.p1),this.addFilletArc(e,a+Math.PI/2,a-Math.PI/2,Is.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case cc.CAP_FLAT:this._segList.addPt(n.p1),this._segList.addPt(r.p1);break;case cc.CAP_SQUARE:var l=new Wo;l.x=Math.abs(this._distance)*Math.cos(a),l.y=Math.abs(this._distance)*Math.sin(a);var c=new Wo(n.p1.x+l.x,n.p1.y+l.y),u=new Wo(r.p1.x+l.x,r.p1.y+l.y);this._segList.addPt(c),this._segList.addPt(u)}},yc.prototype.getCoordinates=function(){return this._segList.getCoordinates()},yc.prototype.addMitreJoin=function(t,e,i,n){var r=!0,o=null;try{o=ps.intersection(e.p0,e.p1,i.p0,i.p1),(n<=0?1:o.distance(t)/Math.abs(n))>this._bufParams.getMitreLimit()&&(r=!1)}catch(t){if(!(t instanceof us))throw t;o=new Wo(0,0),r=!1}r?this._segList.addPt(o):this.addLimitedMitreJoin(e,i,n,this._bufParams.getMitreLimit())},yc.prototype.addFilletCorner=function(t,e,i,n,r){var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o),l=i.x-t.x,c=i.y-t.y,u=Math.atan2(c,l);n===Is.CLOCKWISE?a<=u&&(a+=2*Math.PI):a>=u&&(a-=2*Math.PI),this._segList.addPt(e),this.addFilletArc(t,a,u,n,r),this._segList.addPt(i)},yc.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)0){var i=new Wo((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(i);var n=new Wo((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(n)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}},yc.prototype.createCircle=function(t){var e=new Wo(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()},yc.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},yc.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new dc,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*yc.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},yc.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===cc.JOIN_BEVEL||this._bufParams.getJoinStyle()===cc.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,Is.CLOCKWISE,this._distance))},yc.prototype.closeRing=function(){this._segList.closeRing()},yc.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},yc.prototype.interfaces_=function(){return[]},yc.prototype.getClass=function(){return yc},vc.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},vc.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},vc.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},vc.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(yc,vc);var _c=function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e};_c.prototype.getOffsetCurve=function(t,e){if(this._distance=e,0===e)return null;var i=e<0,n=Math.abs(e),r=this.getSegGen(n);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,i,r);var o=r.getCoordinates();return i&&Ys.reverse(o),o},_c.prototype.computeSingleSidedBufferCurve=function(t,e,i){var n=this.simplifyTolerance(this._distance);if(e){i.addSegments(t,!0);var r=hc.simplify(t,-n),o=r.length-1;i.initSideSegments(r[o],r[o-1],cl.LEFT),i.addFirstSegment();for(var s=o-2;s>=0;s--)i.addNextSegment(r[s],!0)}else{i.addSegments(t,!1);var a=hc.simplify(t,n),l=a.length-1;i.initSideSegments(a[0],a[1],cl.LEFT),i.addFirstSegment();for(var c=2;c<=l;c++)i.addNextSegment(a[c],!0)}i.addLastSegment(),i.closeRing()},_c.prototype.computeRingBufferCurve=function(t,e,i){var n=this.simplifyTolerance(this._distance);e===cl.RIGHT&&(n=-n);var r=hc.simplify(t,n),o=r.length-1;i.initSideSegments(r[o-1],r[0],e);for(var s=1;s<=o;s++){var a=1!==s;i.addNextSegment(r[s],a)}i.closeRing()},_c.prototype.computeLineBufferCurve=function(t,e){var i=this.simplifyTolerance(this._distance),n=hc.simplify(t,i),r=n.length-1;e.initSideSegments(n[0],n[1],cl.LEFT);for(var o=2;o<=r;o++)e.addNextSegment(n[o],!0);e.addLastSegment(),e.addLineEndCap(n[r-1],n[r]);var s=hc.simplify(t,-i),a=s.length-1;e.initSideSegments(s[a],s[a-1],cl.LEFT);for(var l=a-2;l>=0;l--)e.addNextSegment(s[l],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()},_c.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case cc.CAP_ROUND:e.createCircle(t);break;case cc.CAP_SQUARE:e.createSquare(t)}},_c.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided())return null;if(0===e)return null;var i=Math.abs(e),n=this.getSegGen(i);if(t.length<=1)this.computePointCurve(t[0],n);else if(this._bufParams.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,n)}else this.computeLineBufferCurve(t,n);return n.getCoordinates()},_c.prototype.getBufferParameters=function(){return this._bufParams},_c.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor()},_c.prototype.getRingCurve=function(t,e,i){if(this._distance=i,t.length<=2)return this.getLineCurve(t,i);if(0===i)return _c.copyCoordinates(t);var n=this.getSegGen(i);return this.computeRingBufferCurve(t,e,n),n.getCoordinates()},_c.prototype.computeOffsetCurve=function(t,e,i){var n=this.simplifyTolerance(this._distance);if(e){var r=hc.simplify(t,-n),o=r.length-1;i.initSideSegments(r[o],r[o-1],cl.LEFT),i.addFirstSegment();for(var s=o-2;s>=0;s--)i.addNextSegment(r[s],!0)}else{var a=hc.simplify(t,n),l=a.length-1;i.initSideSegments(a[0],a[1],cl.LEFT),i.addFirstSegment();for(var c=2;c<=l;c++)i.addNextSegment(a[c],!0)}i.addLastSegment()},_c.prototype.getSegGen=function(t){return new yc(this._precisionModel,this._bufParams,t)},_c.prototype.interfaces_=function(){return[]},_c.prototype.getClass=function(){return _c},_c.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),i=0;io.getMaxY()||t.findStabbedSegments(e,r.getDirectedEdges(),i)}return i}if(3===arguments.length)if(Jo(arguments[2],Hs)&&arguments[0]instanceof Wo&&arguments[1]instanceof Il)for(var s=arguments[0],a=arguments[1],l=arguments[2],c=a.getEdge().getCoordinates(),u=0;ut._seg.p1.y&&t._seg.reverse(),!(Math.max(t._seg.p0.x,t._seg.p1.x)t._seg.p1.y||Is.computeOrientation(t._seg.p0,t._seg.p1,s)===Is.RIGHT)){var h=a.getDepth(cl.LEFT);t._seg.p0.equals(c[u])||(h=a.getDepth(cl.RIGHT));var p=new wc(t._seg,h);l.add(p)}}else if(Jo(arguments[2],Hs)&&arguments[0]instanceof Wo&&Jo(arguments[1],Hs))for(var d=arguments[0],f=arguments[2],m=arguments[1].iterator();m.hasNext();){var g=m.next();g.isForward()&&t.findStabbedSegments(d,g,f)}},xc.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:Fl.min(e)._leftDepth},xc.prototype.interfaces_=function(){return[]},xc.prototype.getClass=function(){return xc},bc.DepthSegment.get=function(){return wc},Object.defineProperties(xc,bc);var wc=function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new tc(t),this._leftDepth=e};wc.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 i=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==i||0!==(i=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?i:this._upwardSeg.compareTo(e._upwardSeg)},wc.prototype.compareX=function(t,e){var i=t.p0.compareTo(e.p0);return 0!==i?i:t.p1.compareTo(e.p1)},wc.prototype.toString=function(){return this._upwardSeg.toString()},wc.prototype.interfaces_=function(){return[Uo]},wc.prototype.getClass=function(){return wc};var Ac=function(t,e,i){this.p0=t||null,this.p1=e||null,this.p2=i||null};Ac.prototype.area=function(){return Ac.area(this.p0,this.p1,this.p2)},Ac.prototype.signedArea=function(){return Ac.signedArea(this.p0,this.p1,this.p2)},Ac.prototype.interpolateZ=function(t){if(null===t)throw new zo("Supplied point is null.");return Ac.interpolateZ(t,this.p0,this.p1,this.p2)},Ac.prototype.longestSideLength=function(){return Ac.longestSideLength(this.p0,this.p1,this.p2)},Ac.prototype.isAcute=function(){return Ac.isAcute(this.p0,this.p1,this.p2)},Ac.prototype.circumcentre=function(){return Ac.circumcentre(this.p0,this.p1,this.p2)},Ac.prototype.area3D=function(){return Ac.area3D(this.p0,this.p1,this.p2)},Ac.prototype.centroid=function(){return Ac.centroid(this.p0,this.p1,this.p2)},Ac.prototype.inCentre=function(){return Ac.inCentre(this.p0,this.p1,this.p2)},Ac.prototype.interfaces_=function(){return[]},Ac.prototype.getClass=function(){return Ac},Ac.area=function(t,e,i){return Math.abs(((i.x-t.x)*(e.y-t.y)-(e.x-t.x)*(i.y-t.y))/2)},Ac.signedArea=function(t,e,i){return((i.x-t.x)*(e.y-t.y)-(e.x-t.x)*(i.y-t.y))/2},Ac.det=function(t,e,i,n){return t*n-e*i},Ac.interpolateZ=function(t,e,i,n){var r=e.x,o=e.y,s=i.x-r,a=n.x-r,l=i.y-o,c=n.y-o,u=s*c-a*l,h=t.x-r,p=t.y-o,d=(c*h-a*p)/u,f=(-l*h+s*p)/u;return e.z+d*(i.z-e.z)+f*(n.z-e.z)},Ac.longestSideLength=function(t,e,i){var n=t.distance(e),r=e.distance(i),o=i.distance(t),s=n;return r>s&&(s=r),o>s&&(s=o),s},Ac.isAcute=function(t,e,i){return!!mc.isAcute(t,e,i)&&(!!mc.isAcute(e,i,t)&&!!mc.isAcute(i,t,e))},Ac.circumcentre=function(t,e,i){var n=i.x,r=i.y,o=t.x-n,s=t.y-r,a=e.x-n,l=e.y-r,c=2*Ac.det(o,s,a,l),u=Ac.det(s,o*o+s*s,l,a*a+l*l),h=Ac.det(o,o*o+s*s,a,a*a+l*l);return new Wo(n-u/c,r+h/c)},Ac.perpendicularBisector=function(t,e){var i=e.x-t.x,n=e.y-t.y,r=new ps(t.x+i/2,t.y+n/2,1),o=new ps(t.x-n+i/2,t.y+i+n/2,1);return new ps(r,o)},Ac.angleBisector=function(t,e,i){var n=e.distance(t),r=n/(n+e.distance(i)),o=i.x-t.x,s=i.y-t.y;return new Wo(t.x+r*o,t.y+r*s)},Ac.area3D=function(t,e,i){var n=e.x-t.x,r=e.y-t.y,o=e.z-t.z,s=i.x-t.x,a=i.y-t.y,l=i.z-t.z,c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,p=c*c+u*u+h*h,d=Math.sqrt(p)/2;return d},Ac.centroid=function(t,e,i){var n=(t.x+e.x+i.x)/3,r=(t.y+e.y+i.y)/3;return new Wo(n,r)},Ac.inCentre=function(t,e,i){var n=e.distance(i),r=t.distance(i),o=t.distance(e),s=n+r+o,a=(n*t.x+r*e.x+o*i.x)/s,l=(n*t.y+r*e.y+o*i.y)/s;return new Wo(a,l)};var Ec=function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new qs;var t=arguments[0],e=arguments[1],i=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=i};Ec.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),i=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(i,Yo.EXTERIOR,Yo.INTERIOR)},Ec.prototype.addPolygon=function(t){var e=this,i=this._distance,n=cl.LEFT;this._distance<0&&(i=-this._distance,n=cl.RIGHT);var r=t.getExteriorRing(),o=Ys.removeRepeatedPoints(r.getCoordinates());if(this._distance<0&&this.isErodedCompletely(r,this._distance))return null;if(this._distance<=0&&o.length<3)return null;this.addPolygonRing(o,i,n,Yo.EXTERIOR,Yo.INTERIOR);for(var s=0;s0&&e.isErodedCompletely(a,-e._distance)||e.addPolygonRing(l,i,cl.opposite(n),Yo.INTERIOR,Yo.EXTERIOR)}},Ec.prototype.isTriangleErodedCompletely=function(t,e){var i=new Ac(t[0],t[1],t[2]),n=i.inCentre();return Is.distancePointLine(n,i.p0,i.p1)=Fa.MINIMUM_VALID_SIZE&&Is.isCCW(t)&&(o=r,s=n,i=cl.opposite(i));var a=this._curveBuilder.getRingCurve(t,i,e);this.addCurve(a,o,s)},Ec.prototype.add=function(t){if(t.isEmpty())return null;t instanceof Ba?this.addPolygon(t):t instanceof Ra?this.addLineString(t):t instanceof ka?this.addPoint(t):(t instanceof za||t instanceof ba||t instanceof Va||t instanceof xa)&&this.addCollection(t)},Ec.prototype.isErodedCompletely=function(t,e){var i=t.getCoordinates();if(i.length<4)return e<0;if(4===i.length)return this.isTriangleErodedCompletely(i,e);var n=t.getEnvelopeInternal(),r=Math.min(n.getHeight(),n.getWidth());return e<0&&2*Math.abs(e)>r},Ec.prototype.addCollection=function(t){for(var e=0;e=this._max)throw new Ws;var t=this._parent.getGeometryN(this._index++);return t instanceof xa?(this._subcollectionIterator=new Mc(t),this._subcollectionIterator.next()):t},Mc.prototype.remove=function(){throw new Error(this.getClass().getName())},Mc.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)},Mc.prototype.interfaces_=function(){return[js]},Mc.prototype.getClass=function(){return Mc},Mc.isAtomic=function(t){return!(t instanceof xa)};var Tc=function(){this._geom=null;var t=arguments[0];this._geom=t};Tc.prototype.locate=function(t){return Tc.locate(t,this._geom)},Tc.prototype.interfaces_=function(){return[Sc]},Tc.prototype.getClass=function(){return Tc},Tc.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&Is.isPointInRing(t,e.getCoordinates())},Tc.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var i=e.getExteriorRing();if(!Tc.isPointInRing(t,i))return!1;for(var n=0;n=0;i--){var n=this._edgeList.get(i),r=n.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=n}e.setNext(t)},e.prototype.computeDepths=function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),i=t.getDepth(cl.LEFT),n=t.getDepth(cl.RIGHT),r=this.computeDepths(e+1,this._edgeList.size(),i);if(this.computeDepths(0,e,r)!==n)throw new fl("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],s=arguments[2],a=arguments[0];a=0;o--){var s=e._resultAreaEdgeList.get(o),a=s.getSym();switch(null===i&&s.getEdgeRing()===t&&(i=s),r){case e._SCANNING_FOR_INCOMING:if(a.getEdgeRing()!==t)continue;n=a,r=e._LINKING_TO_OUTGOING;break;case e._LINKING_TO_OUTGOING:if(s.getEdgeRing()!==t)continue;n.setNextMin(s),r=e._SCANNING_FOR_INCOMING}}r===this._LINKING_TO_OUTGOING&&(ws.isTrue(null!==i,"found null for first outgoing dirEdge"),ws.isTrue(i.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(i))},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 i=arguments[0],n=0,r=this.iterator();r.hasNext();){r.next().getEdgeRing()===i&&n++}return n}},e.prototype.getLabel=function(){return this._label},e.prototype.findCoveredLineEdges=function(){for(var t=Yo.NONE,e=this.iterator();e.hasNext();){var i=e.next(),n=i.getSym();if(!i.isLineEdge()){if(i.isInResult()){t=Yo.INTERIOR;break}if(n.isInResult()){t=Yo.EXTERIOR;break}}}if(t===Yo.NONE)return null;for(var r=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(r===Yo.INTERIOR):(s.isInResult()&&(r=Yo.EXTERIOR),a.isInResult()&&(r=Yo.INTERIOR))}},e.prototype.computeLabelling=function(e){t.prototype.computeLabelling.call(this,e),this._label=new vl(Yo.NONE);for(var i=this.iterator();i.hasNext();)for(var n=i.next().getEdge().getLabel(),r=0;r<2;r++){var o=n.getLocation(r);o!==Yo.INTERIOR&&o!==Yo.BOUNDARY||this._label.setLocation(r,Yo.INTERIOR)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ic),Pc=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 Al(t,new Cc)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Cl),Lc=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)};Lc.prototype.compareTo=function(t){var e=t;return Lc.compareOriented(this._pts,this._orientation,e._pts,e._orientation)},Lc.prototype.interfaces_=function(){return[Uo]},Lc.prototype.getClass=function(){return Lc},Lc.orientation=function(t){return 1===Ys.increasingDirection(t)},Lc.compareOriented=function(t,e,i,n){for(var r=e?1:-1,o=n?1:-1,s=e?t.length:-1,a=n?i.length:-1,l=e?0:t.length-1,c=n?0:i.length-1;;){var u=t[l].compareTo(i[c]);if(0!==u)return u;var h=(l+=r)===s,p=(c+=o)===a;if(h&&!p)return-1;if(!h&&p)return 1;if(h&&p)return 0}};var Dc=function(){this._edges=new qs,this._ocaMap=new ua};Dc.prototype.print=function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var n=i.getCoordinates(),r=0;r0&&t.print(","),t.print(n[r].x+" "+n[r].y);t.println(")")}t.print(") ")},Dc.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},Dc.prototype.findEdgeIndex=function(t){for(var e=0;e0||!e.coord.equals2D(n);r||i--;var o=new Array(i).fill(null),s=0;o[s++]=new Wo(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return r&&(o[s]=e.coord),new Uc(o,new vl(this.edge._label))},Nc.prototype.add=function(t,e,i){var n=new kc(t,e,i),r=this._nodeMap.get(n);return null!==r?r:(this._nodeMap.put(n,n),n)},Nc.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();){if(e.next().coord.equals(t))return!0}return!1},Nc.prototype.interfaces_=function(){return[]},Nc.prototype.getClass=function(){return Nc};var Bc=function(){};Bc.prototype.getChainStartIndices=function(t){var e=0,i=new qs;i.add(new es(e));do{var n=this.findChainEnd(t,e);i.add(new es(n)),e=n}while(ei?e:i},zc.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,i=this.pts[this.startIndex[t+1]].x;return ei&&(r=1),t._depth[e][n]=r}}},Fc.prototype.getDelta=function(t){return this._depth[t][cl.RIGHT]-this._depth[t][cl.LEFT]},Fc.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?Yo.EXTERIOR:Yo.INTERIOR},Fc.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]},Fc.prototype.add=function(){var t=this;if(1===arguments.length)for(var e=arguments[0],i=0;i<2;i++)for(var n=1;n<3;n++){var r=e.getLocation(i,n);r!==Yo.EXTERIOR&&r!==Yo.INTERIOR||(t.isNull(i,n)?t._depth[i][n]=Fc.depthAtLocation(r):t._depth[i][n]+=Fc.depthAtLocation(r))}else if(3===arguments.length){var o=arguments[0],s=arguments[1];arguments[2]===Yo.INTERIOR&&this._depth[o][s]++}},Fc.prototype.interfaces_=function(){return[]},Fc.prototype.getClass=function(){return Fc},Fc.depthAtLocation=function(t){return t===Yo.EXTERIOR?0:t===Yo.INTERIOR?1:Fc.NULL_VALUE},Vc.NULL_VALUE.get=function(){return-1},Object.defineProperties(Fc,Vc);var Uc=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new Nc(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new Fc,this._depthDelta=0,1===arguments.length){var i=arguments[0];e.call(this,i,null)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.pts=n,this._label=r}}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,vl.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 i=t;if(this.pts.length!==i.pts.length)return!1;for(var n=!0,r=!0,o=this.pts.length,s=0;s0?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;e0&&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 zc(this)),this._mce},e.prototype.getEnvelope=function(){if(null===this._env){this._env=new ds;for(var t=0;t0&&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;en||this._maxyo;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return ws.isTrue(!(s&&a),"Found bad envelope test"),a},qc.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 Wo(this._maxx,this._maxy),this._corner[1]=new Wo(this._minx,this._maxy),this._corner[2]=new Wo(this._minx,this._miny),this._corner[3]=new Wo(this._maxx,this._miny)},qc.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))},qc.prototype.scale=function(t){return Math.round(t*this._scaleFactor)},qc.prototype.getCoordinate=function(){return this._originalPt},qc.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},qc.prototype.getSafeEnvelope=function(){if(null===this._safeEnv){var t=qc.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new ds(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv},qc.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())))},qc.prototype.intersectsToleranceSquare=function(t,e){var i=!1,n=!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()&&(i=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.isProper()||(!(!i||!n)||(!!t.equals(this._pt)||!!e.equals(this._pt))))))},qc.prototype.addSnappedNode=function(t,e){var i=t.getCoordinate(e),n=t.getCoordinate(e+1);return!!this.intersects(i,n)&&(t.addIntersection(this.getCoordinate(),e),!0)},qc.prototype.interfaces_=function(){return[]},qc.prototype.getClass=function(){return qc},Xc.SAFE_ENV_EXPANSION_FACTOR.get=function(){return.75},Object.defineProperties(qc,Xc);var Zc=function(){this.tempEnv1=new ds,this.selectedSegment=new tc};Zc.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)}},Zc.prototype.interfaces_=function(){return[]},Zc.prototype.getClass=function(){return Zc};var Yc=function(){this._index=null;var t=arguments[0];this._index=t},Qc={HotPixelSnapAction:{configurable:!0}};Yc.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],i=arguments[1],n=arguments[2],r=e.getSafeEnvelope(),o=new Jc(e,i,n);return this._index.query(r,{interfaces_:function(){return[kl]},visitItem:function(t){t.select(r,o)}}),o.isNodeAdded()}},Yc.prototype.interfaces_=function(){return[]},Yc.prototype.getClass=function(){return Yc},Qc.HotPixelSnapAction.get=function(){return Jc},Object.defineProperties(Yc,Qc);var Jc=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[0],i=arguments[1],n=arguments[2];this._hotPixel=e,this._parentEdge=i,this._hotPixelVertexIndex=n}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],i=arguments[0].getContext();if(null!==this._parentEdge&&i===this._parentEdge&&e===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(i,e)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Zc),Kc=function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new qs};Kc.prototype.processIntersections=function(t,e,i,n){if(t===i&&e===n)return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=i.getCoordinates()[n],a=i.getCoordinates()[n+1];if(this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var l=0;l=0;e--){try{t.bufferReducedPrecision(e)}catch(e){if(!(e instanceof fl))throw e;t._saveException=e}if(null!==t._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var i=arguments[0],n=tu.precisionScaleFactor(this._argGeom,this._distance,i),r=new Ja(n);this.bufferFixedPrecision(r)}},tu.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===Ja.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},tu.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t)},tu.prototype.bufferOriginalPrecision=function(){try{var t=new Gc(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof xs))throw t;this._saveException=t}},tu.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry},tu.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t)},tu.prototype.interfaces_=function(){return[]},tu.prototype.getClass=function(){return tu},tu.bufferOp=function(){if(2===arguments.length){var t=arguments[1];return new tu(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Ls&&"number"==typeof arguments[1]){var e=arguments[1],i=arguments[2],n=new tu(arguments[0]);return n.setQuadrantSegments(i),n.getResultGeometry(e)}if(arguments[2]instanceof cc&&arguments[0]instanceof Ls&&"number"==typeof arguments[1]){var r=arguments[1];return new tu(arguments[0],arguments[2]).getResultGeometry(r)}}else if(4===arguments.length){var o=arguments[1],s=arguments[2],a=arguments[3],l=new tu(arguments[0]);return l.setQuadrantSegments(s),l.setEndCapStyle(a),l.getResultGeometry(o)}},tu.precisionScaleFactor=function(t,e,i){var n=t.getEnvelopeInternal(),r=Ko.max(Math.abs(n.getMaxX()),Math.abs(n.getMaxY()),Math.abs(n.getMinX()),Math.abs(n.getMinY()))+2*(e>0?e:0),o=i-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,o)},eu.CAP_ROUND.get=function(){return cc.CAP_ROUND},eu.CAP_BUTT.get=function(){return cc.CAP_FLAT},eu.CAP_FLAT.get=function(){return cc.CAP_FLAT},eu.CAP_SQUARE.get=function(){return cc.CAP_SQUARE},eu.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(tu,eu);var iu=function(){this._pt=[new Wo,new Wo],this._distance=Fo.NaN,this._isNull=!0};iu.prototype.getCoordinates=function(){return this._pt},iu.prototype.getCoordinate=function(t){return this._pt[t]},iu.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],i=arguments[1];if(this._isNull)return this.initialize(e,i),null;var n=e.distance(i);nthis._distance&&this.initialize(e,i,n)}},iu.prototype.interfaces_=function(){return[]},iu.prototype.getClass=function(){return iu};var nu=function(){};nu.prototype.interfaces_=function(){return[]},nu.prototype.getClass=function(){return nu},nu.computeDistance=function(){if(arguments[2]instanceof iu&&arguments[0]instanceof Ra&&arguments[1]instanceof Wo)for(var t=arguments[1],e=arguments[2],i=arguments[0].getCoordinates(),n=new tc,r=0;r0||this._isIn?Yo.INTERIOR:Yo.EXTERIOR)},uu.prototype.interfaces_=function(){return[]},uu.prototype.getClass=function(){return uu};var hu=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],i=arguments[1],n=arguments[2];this._component=e,this._segIndex=i,this._pt=n}},pu={INSIDE_AREA:{configurable:!0}};hu.prototype.isInsideArea=function(){return this._segIndex===hu.INSIDE_AREA},hu.prototype.getCoordinate=function(){return this._pt},hu.prototype.getGeometryComponent=function(){return this._component},hu.prototype.getSegmentIndex=function(){return this._segIndex},hu.prototype.interfaces_=function(){return[]},hu.prototype.getClass=function(){return hu},pu.INSIDE_AREA.get=function(){return-1},Object.defineProperties(hu,pu);var du=function(t){this._pts=t||null};du.prototype.filter=function(t){t instanceof ka&&this._pts.add(t)},du.prototype.interfaces_=function(){return[va]},du.prototype.getClass=function(){return du},du.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof ka?Fl.singletonList(t):du.getPoints(t,new qs)}if(2===arguments.length){var e=arguments[0],i=arguments[1];return e instanceof ka?i.add(e):e instanceof xa&&e.apply(new du(i)),i}};var fu=function(){this._locations=null;var t=arguments[0];this._locations=t};fu.prototype.filter=function(t){(t instanceof ka||t instanceof Ra||t instanceof Ba)&&this._locations.add(new hu(t,0,t.getCoordinate()))},fu.prototype.interfaces_=function(){return[va]},fu.prototype.getClass=function(){return fu},fu.getLocations=function(t){var e=new qs;return t.apply(new fu(e)),e};var mu=function(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new uu,this._minDistanceLocation=null,this._minDistance=Fo.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 i=arguments[0],n=arguments[1],r=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=i,this._geom[1]=n,this._terminateDistance=r}};mu.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 i=arguments[0],n=arguments[1],r=1-i,o=lu.getPolygons(this._geom[i]);if(o.size()>0){var s=fu.getLocations(this._geom[r]);if(this.computeContainmentDistance(s,o,n),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[r]=n[0],this._minDistanceLocation[i]=n[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&Jo(arguments[0],Hs)&&Jo(arguments[1],Hs)){for(var a=arguments[0],l=arguments[1],c=arguments[2],u=0;uthis._minDistance)return null;for(var r=e.getCoordinates(),o=i.getCoordinate(),s=0;sthis._minDistance)return null;for(var p=c.getCoordinates(),d=u.getCoordinates(),f=0;fthis._distance&&this.initialize(e,i,n)}},gu.prototype.interfaces_=function(){return[]},gu.prototype.getClass=function(){return gu};var yu=function(){};yu.prototype.interfaces_=function(){return[]},yu.prototype.getClass=function(){return yu},yu.computeDistance=function(){if(arguments[2]instanceof gu&&arguments[0]instanceof Ra&&arguments[1]instanceof Wo)for(var t=arguments[0],e=arguments[1],i=arguments[2],n=new tc,r=t.getCoordinates(),o=0;o1||t<=0)throw new zo("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},vu.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},vu.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},vu.prototype.computeOrientedDistance=function(t,e,i){var n=new xu(e);if(t.apply(n),i.setMaximum(n.getMaxPointDistance()),this._densifyFrac>0){var r=new bu(e,this._densifyFrac);t.apply(r),i.setMaximum(r.getMaxPointDistance())}},vu.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},vu.prototype.interfaces_=function(){return[]},vu.prototype.getClass=function(){return vu},vu.distance=function(){if(2===arguments.length)return new vu(arguments[0],arguments[1]).distance();if(3===arguments.length){var t=arguments[2],e=new vu(arguments[0],arguments[1]);return e.setDensifyFraction(t),e.distance()}},_u.MaxPointDistanceFilter.get=function(){return xu},_u.MaxDensifiedByFractionDistanceFilter.get=function(){return bu},Object.defineProperties(vu,_u);var xu=function(){this._maxPtDist=new gu,this._minPtDist=new gu,this._euclideanDist=new yu,this._geom=null;var t=arguments[0];this._geom=t};xu.prototype.filter=function(t){this._minPtDist.initialize(),yu.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},xu.prototype.getMaxPointDistance=function(){return this._maxPtDist},xu.prototype.interfaces_=function(){return[Os]},xu.prototype.getClass=function(){return xu};var bu=function(){this._maxPtDist=new gu,this._minPtDist=new gu,this._geom=null,this._numSubSegs=0;var t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e))};bu.prototype.filter=function(t,e){var i=this;if(0===e)return null;for(var n=t.getCoordinate(e-1),r=t.getCoordinate(e),o=(r.x-n.x)/this._numSubSegs,s=(r.y-n.y)/this._numSubSegs,a=0;ai){this._isValid=!1;var r=n.getCoordinates();this._errorLocation=r[1],this._errorIndicator=t.getFactory().createLineString(r),this._errMsg="Distance between buffer curve and input is too large ("+this._maxDistanceFound+" at "+_s.toLineString(r[0],r[1])+")"}},wu.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=wu.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(),wu.VERBOSE&&hs.out.println("Min Dist= "+this._minDistanceFound+" err= "+(1-this._minDistanceFound/this._bufDistance)+" Max Dist= "+this._maxDistanceFound+" err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid)},wu.prototype.checkNegativeValid=function(){if(!(this._input instanceof Ba||this._input instanceof Va||this._input instanceof xa))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)},wu.prototype.getErrorIndicator=function(){return this._errorIndicator},wu.prototype.checkMinimumDistance=function(t,e,i){var n=new mu(t,e,i);if(this._minDistanceFound=n.distance(),this._minDistanceFound0&&t>e&&(this._isValid=!1,this._errorMsg="Area of positive buffer is smaller than input",this._errorIndicator=this._result),this._distance<0&&t=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"))},Eu.prototype.report=function(t){if(!Eu.VERBOSE)return null;hs.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},Eu.prototype.getErrorMessage=function(){return this._errorMsg},Eu.prototype.interfaces_=function(){return[]},Eu.prototype.getClass=function(){return Eu},Eu.isValidMsg=function(t,e,i){var n=new Eu(t,e,i);return n.isValid()?null:n.getErrorMessage()},Eu.isValid=function(t,e,i){return!!new Eu(t,e,i).isValid()},Su.VERBOSE.get=function(){return!1},Su.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(Eu,Su);var Mu=function(){this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};Mu.prototype.getCoordinates=function(){return this._pts},Mu.prototype.size=function(){return this._pts.length},Mu.prototype.getCoordinate=function(t){return this._pts[t]},Mu.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},Mu.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:Ql.octant(this.getCoordinate(t),this.getCoordinate(t+1))},Mu.prototype.setData=function(t){this._data=t},Mu.prototype.getData=function(){return this._data},Mu.prototype.toString=function(){return _s.toLineString(new qa(this._pts))},Mu.prototype.interfaces_=function(){return[Jl]},Mu.prototype.getClass=function(){return Mu};var Tu=function(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new qs,this._intersectionCount=0,this._keepIntersections=!0;var t=arguments[0];this._li=t,this._interiorIntersection=null};Tu.prototype.getInteriorIntersection=function(){return this._interiorIntersection},Tu.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t},Tu.prototype.getIntersectionSegments=function(){return this._intSegments},Tu.prototype.count=function(){return this._intersectionCount},Tu.prototype.getIntersections=function(){return this._intersections},Tu.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Tu.prototype.setKeepIntersections=function(t){this._keepIntersections=t},Tu.prototype.processIntersections=function(t,e,i,n){if(!this._findAllIntersections&&this.hasIntersection())return null;if(t===i&&e===n)return null;if(this._isCheckEndSegmentsOnly&&!(this.isEndSegment(t,e)||this.isEndSegment(i,n)))return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=i.getCoordinates()[n],a=i.getCoordinates()[n+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=r,this._intSegments[1]=o,this._intSegments[2]=s,this._intSegments[3]=a,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)},Tu.prototype.isEndSegment=function(t,e){return 0===e||e>=t.size()-2},Tu.prototype.hasIntersection=function(){return null!==this._interiorIntersection},Tu.prototype.isDone=function(){return!this._findAllIntersections&&null!==this._interiorIntersection},Tu.prototype.interfaces_=function(){return[Rc]},Tu.prototype.getClass=function(){return Tu},Tu.createAllIntersectionsFinder=function(t){var e=new Tu(t);return e.setFindAllIntersections(!0),e},Tu.createAnyIntersectionFinder=function(t){return new Tu(t)},Tu.createIntersectionCounter=function(t){var e=new Tu(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e};var Iu=function(){this._li=new Ss,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;var t=arguments[0];this._segStrings=t};Iu.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections()},Iu.prototype.getIntersections=function(){return this._segInt.getIntersections()},Iu.prototype.isValid=function(){return this.execute(),this._isValid},Iu.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Iu.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new Tu(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new ac;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null},Iu.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new fl(this.getErrorMessage(),this._segInt.getInteriorIntersection())},Iu.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+_s.toLineString(t[0],t[1])+" and "+_s.toLineString(t[2],t[3])},Iu.prototype.interfaces_=function(){return[]},Iu.prototype.getClass=function(){return Iu},Iu.computeIntersections=function(t){var e=new Iu(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Cu=function t(){this._nv=null;var e=arguments[0];this._nv=new Iu(t.toSegmentStrings(e))};Cu.prototype.checkValid=function(){this._nv.checkValid()},Cu.prototype.interfaces_=function(){return[]},Cu.prototype.getClass=function(){return Cu},Cu.toSegmentStrings=function(t){for(var e=new qs,i=t.iterator();i.hasNext();){var n=i.next();e.add(new Mu(n.getCoordinates(),n))}return e},Cu.checkValid=function(t){new Cu(t).checkValid()};var Pu=function(t){this._mapOp=t};Pu.prototype.map=function(t){for(var e=new qs,i=0;i0&&n<4&&!this._preserveType?this._factory.createLineString(i):this._factory.createLinearRing(i)},Ru.prototype.interfaces_=function(){return[]},Ru.prototype.getClass=function(){return Ru};var Ou=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new tc,this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof Ra&&"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 i=arguments[0],n=arguments[1];this._srcPts=i,this._isClosed=t.isClosed(i),this._snapTolerance=n}};Ou.prototype.snapVertices=function(t,e){for(var i=this._isClosed?t.size()-1:t.size(),n=0;n=0&&t.add(o+1,new Wo(r),!1)}},Ou.prototype.findSegmentIndexToSnap=function(t,e){for(var i=this,n=Fo.MAX_VALUE,r=-1,o=0;oe&&(e=n)}return e}if(2===arguments.length){var r=arguments[0],o=arguments[1];return Math.min(ku.computeOverlaySnapTolerance(r),ku.computeOverlaySnapTolerance(o))}},ku.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*ku.SNAP_PRECISION_FACTOR},ku.snapToSelf=function(t,e,i){return new ku(t).snapToSelf(e,i)},Nu.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(ku,Nu);var Bu=function(t){function e(e,i,n){t.call(this),this._snapTolerance=e||null,this._snapPts=i||null,this._isSelfSnap=void 0!==n&&n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(t,e){var i=new Ou(t,this._snapTolerance);return i.setAllowSnappingToSourceVertices(this._isSelfSnap),i.snapTo(e)},e.prototype.transformCoordinates=function(t,e){var i=t.toCoordinateArray(),n=this.snapLine(i,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ru),zu=function(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null};zu.prototype.getCommon=function(){return Fo.longBitsToDouble(this._commonBits)},zu.prototype.add=function(t){var e=Fo.doubleToLongBits(t);return this._isFirst?(this._commonBits=e,this._commonSignExp=zu.signExpBits(this._commonBits),this._isFirst=!1,null):zu.signExpBits(e)!==this._commonSignExp?(this._commonBits=0,null):(this._commonMantissaBitsCount=zu.numCommonMostSigMantissaBits(this._commonBits,e),void(this._commonBits=zu.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))))},zu.prototype.toString=function(){if(1===arguments.length){var t=arguments[0],e=Fo.longBitsToDouble(t),i="0000000000000000000000000000000000000000000000000000000000000000"+Fo.toBinaryString(t),n=i.substring(i.length-64);return n.substring(0,1)+" "+n.substring(1,12)+"(exp) "+n.substring(12)+" [ "+e+" ]"}},zu.prototype.interfaces_=function(){return[]},zu.prototype.getClass=function(){return zu},zu.getBit=function(t,e){return 0!=(t&1<>52},zu.zeroLowerBits=function(t,e){return t&~((1<=0;n--){if(zu.getBit(t,n)!==zu.getBit(e,n))return i;i++}return 52};var Fu=function(){this._commonCoord=null,this._ccFilter=new Uu},Vu={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};Fu.prototype.addCommonBits=function(t){var e=new Gu(this._commonCoord);t.apply(e),t.geometryChanged()},Fu.prototype.removeCommonBits=function(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;var e=new Wo(this._commonCoord);e.x=-e.x,e.y=-e.y;var i=new Gu(e);return t.apply(i),t.geometryChanged(),t},Fu.prototype.getCommonCoordinate=function(){return this._commonCoord},Fu.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()},Fu.prototype.interfaces_=function(){return[]},Fu.prototype.getClass=function(){return Fu},Vu.CommonCoordinateFilter.get=function(){return Uu},Vu.Translater.get=function(){return Gu},Object.defineProperties(Fu,Vu);var Uu=function(){this._commonBitsX=new zu,this._commonBitsY=new zu};Uu.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)},Uu.prototype.getCommonCoordinate=function(){return new Wo(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())},Uu.prototype.interfaces_=function(){return[Os]},Uu.prototype.getClass=function(){return Uu};var Gu=function(){this.trans=null;var t=arguments[0];this.trans=t};Gu.prototype.filter=function(t,e){var i=t.getOrdinate(e,0)+this.trans.x,n=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,i),t.setOrdinate(e,1,n)},Gu.prototype.isDone=function(){return!1},Gu.prototype.isGeometryChanged=function(){return!0},Gu.prototype.interfaces_=function(){return[_a]},Gu.prototype.getClass=function(){return Gu};var ju=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()};ju.prototype.selfSnap=function(t){return new ku(t).snapTo(t,this._snapTolerance)},ju.prototype.removeCommonBits=function(t){this._cbr=new Fu,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},ju.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t},ju.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),i=hh.overlayOp(e[0],e[1],t);return this.prepareResult(i)},ju.prototype.checkValid=function(t){t.isValid()||hs.out.println("Snapped geometry is invalid")},ju.prototype.computeSnapTolerance=function(){this._snapTolerance=ku.computeOverlaySnapTolerance(this._geom[0],this._geom[1])},ju.prototype.snap=function(t){var e=this.removeCommonBits(t);return ku.snap(e[0],e[1],this._snapTolerance)},ju.prototype.interfaces_=function(){return[]},ju.prototype.getClass=function(){return ju},ju.overlayOp=function(t,e,i){return new ju(t,e).getResultGeometry(i)},ju.union=function(t,e){return ju.overlayOp(t,e,hh.UNION)},ju.intersection=function(t,e){return ju.overlayOp(t,e,hh.INTERSECTION)},ju.symDifference=function(t,e){return ju.overlayOp(t,e,hh.SYMDIFFERENCE)},ju.difference=function(t,e){return ju.overlayOp(t,e,hh.DIFFERENCE)};var Hu=function(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e};Hu.prototype.getResultGeometry=function(t){var e=null,i=!1,n=null;try{e=hh.overlayOp(this._geom[0],this._geom[1],t);i=!0}catch(t){if(!(t instanceof xs))throw t;n=t}if(!i)try{e=ju.overlayOp(this._geom[0],this._geom[1],t)}catch(t){throw t instanceof xs?n:t}return e},Hu.prototype.interfaces_=function(){return[]},Hu.prototype.getClass=function(){return Hu},Hu.overlayOp=function(t,e,i){return new Hu(t,e).getResultGeometry(i)},Hu.union=function(t,e){return Hu.overlayOp(t,e,hh.UNION)},Hu.intersection=function(t,e){return Hu.overlayOp(t,e,hh.INTERSECTION)},Hu.symDifference=function(t,e){return Hu.overlayOp(t,e,hh.SYMDIFFERENCE)},Hu.difference=function(t,e){return Hu.overlayOp(t,e,hh.DIFFERENCE)};var Wu=function(){this.mce=null,this.chainIndex=null;var t=arguments[0],e=arguments[1];this.mce=t,this.chainIndex=e};Wu.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},Wu.prototype.interfaces_=function(){return[]},Wu.prototype.getClass=function(){return Wu};var qu=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],i=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=i}else if(3===arguments.length){var n=arguments[0],r=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=n,this._xValue=r,this._obj=o}},Xu={INSERT:{configurable:!0},DELETE:{configurable:!0}};qu.prototype.isDelete=function(){return this._eventType===qu.DELETE},qu.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t},qu.prototype.getObject=function(){return this._obj},qu.prototype.compareTo=function(t){var e=t;return this._xValuee._xValue?1:this._eventTypee._eventType?1:0},qu.prototype.getInsertEvent=function(){return this._insertEvent},qu.prototype.isInsert=function(){return this._eventType===qu.INSERT},qu.prototype.isSameLabel=function(t){return null!==this._label&&this._label===t._label},qu.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex},qu.prototype.interfaces_=function(){return[Uo]},qu.prototype.getClass=function(){return qu},Xu.INSERT.get=function(){return 1},Xu.DELETE.get=function(){return 2},Object.defineProperties(qu,Xu);var Zu=function(){};Zu.prototype.interfaces_=function(){return[]},Zu.prototype.getClass=function(){return Zu};var Yu=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],i=arguments[2];this._li=t,this._includeProper=e,this._recordIsolated=i};Yu.prototype.isTrivialIntersection=function(t,e,i,n){if(t===i&&1===this._li.getIntersectionNum()){if(Yu.isAdjacentSegments(e,n))return!0;if(t.isClosed()){var r=t.getNumPoints()-1;if(0===e&&n===r||0===n&&e===r)return!0}}return!1},Yu.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},Yu.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t},Yu.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},Yu.prototype.isBoundaryPointInternal=function(t,e){for(var i=e.iterator();i.hasNext();){var n=i.next().getCoordinate();if(t.isIntersection(n))return!0}return!1},Yu.prototype.hasProperIntersection=function(){return this._hasProper},Yu.prototype.hasIntersection=function(){return this._hasIntersection},Yu.prototype.isDone=function(){return this._isDone},Yu.prototype.isBoundaryPoint=function(t,e){return null!==e&&(!!this.isBoundaryPointInternal(t,e[0])||!!this.isBoundaryPointInternal(t,e[1]))},Yu.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e},Yu.prototype.addIntersections=function(t,e,i,n){if(t===i&&e===n)return null;this.numTests++;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=i.getCoordinates()[n],a=i.getCoordinates()[n+1];this._li.computeIntersection(r,o,s,a),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),i.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,i,n)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),i.addIntersections(this._li,n,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))))},Yu.prototype.interfaces_=function(){return[]},Yu.prototype.getClass=function(){return Yu},Yu.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var Qu=function(t){function e(){t.call(this),this.events=new qs,this.nOverlaps=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){Fl.sort(this.events);for(var t=0;te||this._maxo?1:0},$u.prototype.interfaces_=function(){return[jo]},$u.prototype.getClass=function(){return $u};var th=function(t){function e(){t.call(this),this._item=null;var e=arguments[0],i=arguments[1],n=arguments[2];this._min=e,this._max=i,this._item=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(t,e,i){if(!this.intersects(t,e))return null;i.visitItem(this._item)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ju),eh=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var e=arguments[0],i=arguments[1];this._node1=e,this._node2=i,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,i){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,i),null!==this._node2&&this._node2.query(t,e,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ju),ih=function(){this._leaves=new qs,this._root=null,this._level=0};ih.prototype.buildTree=function(){Fl.sort(this._leaves,new Ju.NodeComparator);for(var t=this._leaves,e=null,i=new qs;;){if(this.buildLevel(t,i),1===i.size())return i.get(0);e=t,t=i,i=e}},ih.prototype.insert=function(t,e,i){if(null!==this._root)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new th(t,e,i))},ih.prototype.query=function(t,e,i){this.init(),this._root.query(t,e,i)},ih.prototype.buildRoot=function(){if(null!==this._root)return null;this._root=this.buildTree()},ih.prototype.printNode=function(t){hs.out.println(_s.toLineString(new Wo(t._min,this._level),new Wo(t._max,this._level)))},ih.prototype.init=function(){if(null!==this._root)return null;this.buildRoot()},ih.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var i=0;i=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),i=0,n=t.iterator();n.hasNext();){var r=n.next();e[i++]=r.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,i){if(this.isBoundaryNode(t,e))return null;i===Yo.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,i)},e.prototype.addPolygonRing=function(t,e,i){if(t.isEmpty())return null;var n=Ys.removeRepeatedPoints(t.getCoordinates());if(n.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=n[0],null;var r=e,o=i;Is.isCCW(n)&&(r=i,o=e);var s=new Uc(n,new vl(this._argIndex,Yo.BOUNDARY,r,o));this._lineEdgeMap.put(t,s),this.insertEdge(s),this.insertPoint(this._argIndex,n[0],Yo.BOUNDARY)},e.prototype.insertPoint=function(t,e,i){var n=this._nodes.addNode(e),r=n.getLabel();null===r?n._label=new vl(t,i):r.setLocation(t,i)},e.prototype.createEdgeSetIntersector=function(){return new Qu},e.prototype.addSelfIntersectionNodes=function(t){for(var e=this._edges.iterator();e.hasNext();)for(var i=e.next(),n=i.getLabel().getLocation(t),r=i.eiList.iterator();r.hasNext();){var o=r.next();this.addSelfIntersectionNode(t,o.coord,n)}},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 Va&&(this._useBoundaryDeterminationRule=!1),e instanceof Ba)this.addPolygon(e);else if(e instanceof Ra)this.addLineString(e);else if(e instanceof ka)this.addPoint(e);else if(e instanceof za)this.addCollection(e);else if(e instanceof ba)this.addCollection(e);else if(e instanceof Va)this.addCollection(e);else{if(!(e instanceof xa))throw new Error(e.getClass().getName());this.addCollection(e)}},e.prototype.addCollection=function(t){for(var e=0;e50?(null===this._areaPtLocator&&(this._areaPtLocator=new rh(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)?Yo.BOUNDARY:Yo.INTERIOR},e}(Pl),ch=function(){if(this._li=new Ss,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 lh(0,t)}else if(2===arguments.length){var e=arguments[0],i=arguments[1],n=ks.OGC_SFS_BOUNDARY_RULE;e.getPrecisionModel().compareTo(i.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(i.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new lh(0,e,n),this._arg[1]=new lh(1,i,n)}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];r.getPrecisionModel().compareTo(o.getPrecisionModel())>=0?this.setComputationPrecision(r.getPrecisionModel()):this.setComputationPrecision(o.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new lh(0,r,s),this._arg[1]=new lh(1,o,s)}};ch.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry()},ch.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)},ch.prototype.interfaces_=function(){return[]},ch.prototype.getClass=function(){return ch};var uh=function(){};uh.prototype.interfaces_=function(){return[]},uh.prototype.getClass=function(){return uh},uh.map=function(){if(arguments[0]instanceof Ls&&Jo(arguments[1],uh.MapOp)){for(var t=arguments[0],e=arguments[1],i=new qs,n=0;n=t.size()?null:t.get(e)},vh.union=function(t){return new vh(t).union()},_h.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(vh,_h);var xh=function(){};function bh(){return new wh}function wh(){this.reset()}xh.prototype.interfaces_=function(){return[]},xh.prototype.getClass=function(){return xh},xh.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return hh.createEmptyResult(hh.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),Hu.overlayOp(t,e,hh.UNION)},wh.prototype={constructor:wh,reset:function(){this.s=this.t=0},add:function(t){Eh(Ah,t,this.t),Eh(this,Ah.s,this.s),this.s?this.t+=Ah.t:this.s=Ah.t},valueOf:function(){return this.s}};var Ah=new wh;function Eh(t,e,i){var n=t.s=e+i,r=n-e,o=n-r;t.t=e-o+(i-r)}var Sh=1e-6,Mh=Math.PI,Th=Mh/2,Ih=Mh/4,Ch=2*Mh,Ph=180/Mh,Lh=Mh/180,Dh=Math.abs,Rh=Math.atan,Oh=Math.atan2,kh=Math.cos,Nh=Math.sin,Bh=Math.sqrt;function zh(t){return t>1?0:t<-1?Mh:Math.acos(t)}function Fh(t){return t>1?Th:t<-1?-Th:Math.asin(t)}function Vh(){}function Uh(t,e){t&&jh.hasOwnProperty(t.type)&&jh[t.type](t,e)}var Gh={Feature:function(t,e){Uh(t.geometry,e)},FeatureCollection:function(t,e){for(var i=t.features,n=-1,r=i.length;++nMh?t-Ch:t<-Mh?t+Ch:t,e]}function ep(t){return function(e,i){return[(e+=t)>Mh?e-Ch:e<-Mh?e+Ch:e,i]}}function ip(t){var e=ep(t);return e.invert=ep(-t),e}function np(t,e){var i=kh(t),n=Nh(t),r=kh(e),o=Nh(e);function s(t,e){var s=kh(e),a=kh(t)*s,l=Nh(t)*s,c=Nh(e),u=c*i+a*n;return[Oh(l*r-u*o,a*i-c*n),Fh(u*r+l*o)]}return s.invert=function(t,e){var s=kh(e),a=kh(t)*s,l=Nh(t)*s,c=Nh(e),u=c*r-l*o;return[Oh(l*r+c*o,a*i+u*n),Fh(u*i-a*n)]},s}function rp(t,e){(e=Xh(e))[0]-=t,Kh(e);var i=zh(-e[1]);return((-e[2]<0?-i:i)+Ch-Sh)%Ch}function op(){var t,e=[];return{point:function(e,i){t.push([e,i])},lineStart:function(){e.push(t=[])},lineEnd:Vh,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var i=e;return e=[],t=null,i}}}function sp(t,e){return Dh(t[0]-e[0])=0;--o)r.point((u=c[o])[0],u[1]);else n(p.x,p.p.x,-1,r);p=p.p}c=(p=p.o).z,d=!d}while(!p.v);r.lineEnd()}}}function cp(t){if(e=t.length){for(var e,i,n=0,r=t[0];++ne?1:t>=e?0:NaN}function hp(t){for(var e,i,n,r=t.length,o=-1,s=0;++o=0;)for(e=(n=t[r]).length;--e>=0;)i[--s]=n[e];return i}bh(),bh(),bh(),tp.invert=tp,function(t){1===t.length&&(t=function(t){return function(e,i){return up(t(e),i)}}(t))}(up);var pp=1e9,dp=-pp;function fp(t,e,i,n){function r(r,o){return t<=r&&r<=i&&e<=o&&o<=n}function o(r,o,a,c){var u=0,h=0;if(null==r||(u=s(r,a))!==(h=s(o,a))||l(r,o)<0^a>0)do{c.point(0===u||3===u?t:i,u>1?n:e)}while((u=(u+a+4)%4)!==h);else c.point(o[0],o[1])}function s(n,r){return Dh(n[0]-t)0?0:3:Dh(n[0]-i)0?2:1:Dh(n[1]-e)0?1:0:r>0?3:2}function a(t,e){return l(t.x,e.x)}function l(t,e){var i=s(t,1),n=s(e,1);return i!==n?i-n:0===i?e[1]-t[1]:1===i?t[0]-e[0]:2===i?t[1]-e[1]:e[0]-t[0]}return function(s){var l,c,u,h,p,d,f,m,g,y,v,_=s,x=op(),b={point:w,lineStart:function(){b.point=A,c&&c.push(u=[]);y=!0,g=!1,f=m=NaN},lineEnd:function(){l&&(A(h,p),d&&g&&x.rejoin(),l.push(x.result()));b.point=w,g&&_.lineEnd()},polygonStart:function(){_=x,l=[],c=[],v=!0},polygonEnd:function(){var e=function(){for(var e=0,i=0,r=c.length;in&&(p-o)*(n-s)>(d-s)*(t-o)&&++e:d<=n&&(p-o)*(n-s)<(d-s)*(t-o)&&--e;return e}(),i=v&&e,r=(l=hp(l)).length;(i||r)&&(s.polygonStart(),i&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),r&&lp(l,a,e,o,s),s.polygonEnd());_=s,l=c=u=null}};function w(t,e){r(t,e)&&_.point(t,e)}function A(o,s){var a=r(o,s);if(c&&u.push([o,s]),y)h=o,p=s,d=a,y=!1,a&&(_.lineStart(),_.point(o,s));else if(a&&g)_.point(o,s);else{var l=[f=Math.max(dp,Math.min(pp,f)),m=Math.max(dp,Math.min(pp,m))],x=[o=Math.max(dp,Math.min(pp,o)),s=Math.max(dp,Math.min(pp,s))];!function(t,e,i,n,r,o){var s,a=t[0],l=t[1],c=0,u=1,h=e[0]-a,p=e[1]-l;if(s=i-a,h||!(s>0)){if(s/=h,h<0){if(s0){if(s>u)return;s>c&&(c=s)}if(s=r-a,h||!(s<0)){if(s/=h,h<0){if(s>u)return;s>c&&(c=s)}else if(h>0){if(s0)){if(s/=p,p<0){if(s0){if(s>u)return;s>c&&(c=s)}if(s=o-l,p||!(s<0)){if(s/=p,p<0){if(s>u)return;s>c&&(c=s)}else if(p>0){if(s0&&(t[0]=a+c*h,t[1]=l+c*p),u<1&&(e[0]=a+u*h,e[1]=l+u*p),!0}}}}}(l,x,t,e,i,n)?a&&(_.lineStart(),_.point(o,s),v=!1):(g||(_.lineStart(),_.point(l[0],l[1])),_.point(x[0],x[1]),a||_.lineEnd(),v=!1)}f=o,m=s,g=a}return b}}var mp=bh();function gp(t){return t}bh(),bh(),bh();var yp=1/0,vp=yp,_p=-yp,xp=_p,bp={point:function(t,e){t_p&&(_p=t);exp&&(xp=e)},lineStart:Vh,lineEnd:Vh,polygonStart:Vh,polygonEnd:Vh,result:function(){var t=[[yp,vp],[_p,xp]];return _p=xp=-(vp=yp=1/0),t}};function wp(t,e,i,n){return function(r,o){var s,a,l,c=e(o),u=r.invert(n[0],n[1]),h=op(),p=e(h),d=!1,f={point:m,lineStart:y,lineEnd:v,polygonStart:function(){f.point=_,f.lineStart=x,f.lineEnd=b,a=[],s=[]},polygonEnd:function(){f.point=m,f.lineStart=y,f.lineEnd=v,a=hp(a);var t=function(t,e){var i=e[0],n=e[1],r=[Nh(i),-kh(i),0],o=0,s=0;mp.reset();for(var a=0,l=t.length;a=0?1:-1,E=A*w,S=E>Mh,M=f*x;if(mp.add(Oh(M*A*Nh(E),m*b+M*kh(E))),o+=S?w+A*Ch:w,S^p>=i^v>=i){var T=Yh(Xh(h),Xh(y));Kh(T);var I=Yh(r,T);Kh(I);var C=(S^w>=0?-1:1)*Fh(I[2]);(n>C||n===C&&(T[0]||T[1]))&&(s+=S^w>=0?1:-1)}}return(o<-Sh||o0){for(d||(o.polygonStart(),d=!0),o.lineStart(),t=0;t1&&2&r&&c.push(c.pop().concat(c.shift())),a.push(c.filter(Ap))}return f}}function Ap(t){return t.length>1}function Ep(t,e){return((t=t.x)[0]<0?t[1]-Th-Sh:Th-t[1])-((e=e.x)[0]<0?e[1]-Th-Sh:Th-e[1])}bh();var Sp=wp((function(){return!0}),(function(t){var e,i=NaN,n=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?Mh:-Mh,l=Dh(o-i);Dh(l-Mh)0?Th:-Th),t.point(r,n),t.lineEnd(),t.lineStart(),t.point(a,n),t.point(o,n),e=0):r!==a&&l>=Mh&&(Dh(i-r)Sh?Rh((Nh(e)*(o=kh(n))*Nh(i)-Nh(n)*(r=kh(e))*Nh(t))/(r*o*s)):(e+n)/2}(i,n,o,s),t.point(r,n),t.lineEnd(),t.lineStart(),t.point(a,n),e=0),t.point(i=o,n=s),r=a},lineEnd:function(){t.lineEnd(),i=n=NaN},clean:function(){return 2-e}}}),(function(t,e,i,n){var r;if(null==t)r=i*Th,n.point(-Mh,r),n.point(0,r),n.point(Mh,r),n.point(Mh,0),n.point(Mh,-r),n.point(0,-r),n.point(-Mh,-r),n.point(-Mh,0),n.point(-Mh,r);else if(Dh(t[0]-e[0])>Sh){var o=t[0]0,r=Dh(i)>Sh;function o(t,e){return kh(t)*kh(e)>i}function s(t,e,n){var r=[1,0,0],o=Yh(Xh(t),Xh(e)),s=Zh(o,o),a=o[0],l=s-a*a;if(!l)return!n&&t;var c=i*s/l,u=-i*a/l,h=Yh(r,o),p=Jh(r,c);Qh(p,Jh(o,u));var d=h,f=Zh(p,d),m=Zh(d,d),g=f*f-m*(Zh(p,p)-1);if(!(g<0)){var y=Bh(g),v=Jh(d,(-f-y)/m);if(Qh(v,p),v=qh(v),!n)return v;var _,x=t[0],b=e[0],w=t[1],A=e[1];b0^v[1]<(Dh(v[0]-x)Mh^(x<=v[0]&&v[0]<=b)){var M=Jh(d,(-f+y)/m);return Qh(M,p),[v,qh(M)]}}}function a(e,i){var r=n?t:Mh-t,o=0;return e<-r?o|=1:e>r&&(o|=2),i<-r?o|=4:i>r&&(o|=8),o}return wp(o,(function(t){var e,i,l,c,u;return{lineStart:function(){c=l=!1,u=1},point:function(h,p){var d,f=[h,p],m=o(h,p),g=n?m?0:a(h,p):m?a(h+(h<0?Mh:-Mh),p):0;if(!e&&(c=l=m)&&t.lineStart(),m!==l&&(!(d=s(e,f))||sp(e,d)||sp(f,d))&&(f[0]+=Sh,f[1]+=Sh,m=o(f[0],f[1])),m!==l)u=0,m?(t.lineStart(),d=s(f,e),t.point(d[0],d[1])):(d=s(e,f),t.point(d[0],d[1]),t.lineEnd()),e=d;else if(r&&e&&n^m){var y;g&i||!(y=s(f,e,!0))||(u=0,n?(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&&sp(e,f)||t.point(f[0],f[1]),e=f,l=m,i=g},lineEnd:function(){l&&t.lineEnd(),e=null},clean:function(){return u|(c&&l)<<1}}}),(function(i,n,r,o){!function(t,e,i,n,r,o){if(i){var s=kh(e),a=Nh(e),l=n*i;null==r?(r=e+n*Ch,o=e-l/2):(r=rp(s,r),o=rp(s,o),(n>0?ro)&&(r+=n*Ch));for(var c,u=r;n>0?u>o:u4*e&&m--){var x=s+p,b=a+d,w=l+f,A=Bh(x*x+b*b+w*w),E=Fh(w/=A),S=Dh(Dh(w)-1)e||Dh((y*C+v*P)/_-.5)>.3||s*p+a*d+l*f2?t[2]%360*Lh:0,I()):[g*Ph,y*Ph,v*Ph]},S.precision=function(t){return arguments.length?(E=Dp(T,A=t*t),C()):Bh(A)},S.fitExtent=function(t,e){return Cp(S,t,e)},S.fitSize=function(t,e){return function(t,e,i){return Cp(t,[[0,0],e],i)}(S,t,e)},function(){return e=t.apply(this,arguments),S.invert=e.invert&&M,I()}}((function(){return t}))()}function kp(t){return function(e,i){var n=kh(e),r=kh(i),o=t(n*r);return[o*r*Nh(e),o*Nh(i)]}}function Np(t){return function(e,i){var n=Bh(e*e+i*i),r=t(n),o=Nh(r),s=kh(r);return[Oh(e*o,n*s),Fh(n&&i*o/n)]}}kp((function(t){return Bh(2/(1+t))})).invert=Np((function(t){return 2*Fh(t/2)}));var Bp,zp=kp((function(t){return(t=zh(t))&&t/Nh(t)}));function Fp(){return Op(zp).scale(79.4188).clipAngle(179.999)}function Vp(t,e){return[t,e]}function Up(t,e,i){var n=(i=i||{}).units||"kilometers",r=i.steps||8;if(!t)throw new Error("geojson is required");if("object"!=typeof i)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(void 0===e)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");var o=[];switch(t.type){case"GeometryCollection":return Y(t,(function(t){var i=Gp(t,e,n,r);i&&o.push(i)})),N(o);case"FeatureCollection":return X(t,(function(t){var i=Gp(t,e,n,r);i&&X(i,(function(t){t&&o.push(t)}))})),N(o)}return Gp(t,e,n,r)}function Gp(t,e,i,n){var r=t.properties||{},o="Feature"===t.type?t.geometry:t;if("GeometryCollection"===o.type){var s=[];return Y(t,(function(t){var r=Gp(t,e,i,n);r&&s.push(r)})),N(s)}var a=function(t){var e=bt(t).geometry.coordinates,i=[-e[0],-e[1]];return Fp().rotate(i).scale(P)}(o),l={type:o.type,coordinates:Hp(o.coordinates,a)},c=(new al).read(l),u=V(U(e,i),"meters"),h=tu.bufferOp(c,u,n);if(!jp((h=(new ll).write(h)).coordinates))return D({type:h.type,coordinates:Wp(h.coordinates,a)},r)}function jp(t){return Array.isArray(t[0])?jp(t[0]):isNaN(t[0])}function Hp(t,e){return"object"!=typeof t[0]?e(t):t.map((function(t){return Hp(t,e)}))}function Wp(t,e){return"object"!=typeof t[0]?e.invert(t):t.map((function(t){return Wp(t,e)}))}function qp(t,e,i){void 0===i&&(i={});var n=et(t),r=et(e),o=No.intersection(n.coordinates,r.coordinates);return 0===o.length?null:1===o.length?O(o[0],i.properties):F(o,i.properties)}function Xp(t,e,i,n,r,o){for(var s=[],a=0;a<6;a++){var l=t[0]+e*r[a],c=t[1]+i*o[a];s.push([l,c])}return s.push(s[0].slice()),O([s],n)}function Zp(t,e,i,n,r,o){for(var s=[],a=0;a<6;a++){var l=[];l.push(t),l.push([t[0]+e*r[a],t[1]+i*o[a]]),l.push([t[0]+e*r[(a+1)%6],t[1]+i*o[(a+1)%6]]),l.push(t),s.push(O([l],n))}return s}function Yp(t,e,i){return void 0===i&&(i={}),function(t,e,i,n){void 0===n&&(n={});for(var r=[],o=t[0],s=t[1],a=t[2],l=t[3],c=e/pt([o,s],[a,s],n)*(a-o),u=i/pt([o,s],[o,l],n)*(l-s),h=a-o,p=l-s,d=Math.floor(h/c),f=Math.floor(p/u),m=(p-f*u)/2,g=o+(h-d*c)/2,y=0;yf/2;E&&(A-=f/4);for(var S=[],M=[],T=0;T<6;T++){var I=2*Math.PI/6*T;S.push(Math.cos(I)),M.push(Math.sin(I))}for(var C=[],P=0;P<=x;P++)for(var L=0;L<=w;L++){var D=P%2==1;if(!(0===L&&D||0===L&&E)){var R=P*y+r-b,O=L*v+o+A;if(D&&(O-=f/2),!0===i.triangles)Zp([R,O],u/2,h/2,JSON.parse(n),S,M).forEach((function(t){i.mask?qp(i.mask,t)&&C.push(t):C.push(t)}));else{var k=Xp([R,O],u/2,h/2,JSON.parse(n),S,M);i.mask?qp(i.mask,k)&&C.push(k):C.push(k)}}}return N(C)}(a,e,i);break;case"triangle":case"triangles":s=function(t,e,i){void 0===i&&(i={});for(var n=[],r=e/pt([t[0],t[1]],[t[2],t[1]],i)*(t[2]-t[0]),o=e/pt([t[0],t[1]],[t[0],t[3]],i)*(t[3]-t[1]),s=0,a=t[0];a<=t[2];){for(var l=0,c=t[1];c<=t[3];){var u=null,h=null;s%2==0&&l%2==0?(u=O([[[a,c],[a,c+o],[a+r,c],[a,c]]],i.properties),h=O([[[a,c+o],[a+r,c+o],[a+r,c],[a,c+o]]],i.properties)):s%2==0&&l%2==1?(u=O([[[a,c],[a+r,c+o],[a+r,c],[a,c]]],i.properties),h=O([[[a,c],[a,c+o],[a+r,c+o],[a,c]]],i.properties)):l%2==0&&s%2==1?(u=O([[[a,c],[a,c+o],[a+r,c+o],[a,c]]],i.properties),h=O([[[a,c],[a+r,c+o],[a+r,c],[a,c]]],i.properties)):l%2==1&&s%2==1&&(u=O([[[a,c],[a,c+o],[a+r,c],[a,c]]],i.properties),h=O([[[a,c+o],[a+r,c+o],[a+r,c],[a,c+o]]],i.properties)),i.mask?(qp(i.mask,u)&&n.push(u),qp(i.mask,h)&&n.push(h)):(n.push(u),n.push(h)),c+=o,l++}s++,a+=r}return N(n)}(a,e,i);break;default:throw new Error("invalid gridType")}var l=[];return X(s,(function(e){var s=0,a=0;X(t,(function(t){var l,c=pt("point"===n?e:wt(e),t,i);if(void 0!==r&&(l=t.properties[r]),void 0===l&&(l=t.geometry.coordinates[2]),void 0===l)throw new Error("zValue is missing");0===c&&(s=l);var u=1/Math.pow(c,o);a+=u,s+=u*l}));var c=dt(e);c.properties[r]=s/a,l.push(c)})),N(l)}zp.invert=Np((function(t){return t})),Vp.invert=Vp;class Jp{_data;constructor(t,e){const i=[];t.forEach((t=>{let n=t.position||[t.lng,t.lat];"multiPoint"!=e&&"multiLineString"!=e&&"multiPolygon"!=e||(n=[n]);const r={point:R,lineString:k,polygon:O,multiPoint:z,multiLineString:B,multiPolygon:F}[e](n,{...t.userData,...t});!function(t,e,i){if(!t)throw new Error("No feature passed");if(!i)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+i+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+i+": must be a "+e+", given "+t.geometry.type)}(r,e.charAt(0).toUpperCase()+e.slice(1),"a"),i.push(r)})),this._data=N(i)}}function Kp(t){const e=K(t);return[[e[0],e[1]],[e[2],e[3]]]}function $p(t,e){return new Jp(t,e)._data}async function td(t,e){const i=[],n=t=>{const n=K(t);if(i.push([n[0],n[1]],[n[2],n[3]]),e)if(hNt.value){const t=cNt.value.cameraForBounds(i);cNt.value.flyTo({center:t.center,zoom:Math.floor(t.zoom)})}else cNt.value.fitBounds(i)};if("string"==typeof t){n(cNt.value.getSource(t)._data)}else n(t);return i}!function(t){t[t.solid=0]="solid",t[t.dash=1]="dash",t[t.glowPower=2]="glowPower",t[t.FlowColor=3]="FlowColor",t[t.FlowColorLight=4]="FlowColorLight",t[t.RoadLine=5]="RoadLine",t[t.VerticalFlyingLine=6]="VerticalFlyingLine"}(Bp||(Bp={}));class ed extends(m(C)){options;id;step=200;arcs=[];bbox;defaultStyle;FlowColorLightPercent=.4;constructor(t,e,i){super(),this.id=i||d(0,3),this.options=Object.assign({width:1,color:"#ffffff",labelOption:{},speed:10,type:"solid",isShow:!0},e),this.step=this.options.flowAnimationSpeed?100*(1-this.options.flowAnimationSpeed)*5:300,this.bbox=Kp(t),this.options.image&&cNt.value.loadImage(this.options.image,((t,e)=>{if(t)throw t;cNt.value.hasImage(this.id+"icon")||cNt.value.addImage(this.id+"icon",e)})),"RoadLine"==this.options.type?(this.FlowColorLightPercent=this.options.FlowColorLightPercent?1-this.options.FlowColorLightPercent:.4,cNt.value.addSource(this.id+"source",{type:"geojson",lineMetrics:!0,data:null}),this._split(t),setTimeout((()=>{this._animation()}))):cNt.value.addSource(this.id+"source",{type:"geojson",lineMetrics:!0,data:t});let n=[];"FlowColor"==this.options.type?n=["interpolate",["linear"],["line-progress"],.14,"red",.28,"orange",.42,"yellow",.56,"green",.7,"blue",.84,"cyan",1,"purple"]:"RoadLine"==this.options.type&&(n=["interpolate",["linear"],["line-progress"],0,"rgba(255, 255, 255, 0)",this.FlowColorLightPercent,"rgba(255, 255, 255, 0.1)",1,this.options.color]),this.defaultStyle=n;let r={"line-pattern":this.options.image?this.id+"icon":"","line-width":this.options.width,"line-dasharray":"dash"==this.options.type?[2,2]:[2,0]};0!=n.length?r["line-gradient"]=n:r["line-color"]=this.options.color,!uNt.value||"EPSG:4326"!=uNt.value&&"EPSG:4490"!=uNt.value||(r={"line-width":this.options.width,"line-dasharray":"dash"==this.options.type?[2,2]:[2,0],"line-color":this.options.color}),cNt.value.addLayer({id:this.id,source:this.id+"source",type:"line",layout:{visibility:this.options.isShow?"visible":"none","line-join":"round","line-cap":"round"},paint:r}),this.options.highlightColor&&(cNt.value.getLayer(this.id+"Highlight")||(cNt.value.addSource(this.id+"Highlightsource",{type:"geojson",lineMetrics:!0,data:t}),cNt.value.addLayer({id:this.id+"Highlight",source:this.id+"Highlightsource",type:"line",filter:["in","id",""],layout:{visibility:this.options.isShow?"visible":"none","line-join":"round","line-cap":"round"},paint:{"line-color":this.options.highlightColor,"line-width":this.options.width}})))}_split(t){for(const e of t.features){const t=Me(e,ye(e)/this.step);this.arcs.push(t)}}_animation(){const t={type:"FeatureCollection",features:[]};let e=0;const i=cNt.value.getSource(this.id+"source"),n=()=>{e>=this.step&&(e=0,t.features.forEach((t=>t.geometry.coordinates.length=0))),this.arcs.forEach(((i,n)=>{t.features[n]||(t.features[n]={type:"Feature",geometry:{type:"LineString",coordinates:[]}});t.features[n].geometry.coordinates.push(...i.features[e].geometry.coordinates)})),i.setData(t),requestAnimationFrame(n),e++};n()}highlight(t){cNt.value.getLayer(this.id+"Highlight")&&cNt.value.setFilter(this.id+"Highlight",["in","id",t])}removeHighlight(){cNt.value.getLayer(this.id+"Highlight")&&cNt.value.setFilter(this.id+"Highlight",["in","id",""])}update(t){let e=t;this._isFeatureCollectionData(t)&&(e=$p(t,"multiLineString")),this.bbox=Kp(e),this.updateSource("source",e),this.updateSource("Highlightsource",e)}updateSource(t,e){const i=cNt.value.getSource(this.id+t);i&&i.setData(e)}_isFeatureCollectionData(t){return t instanceof Array}}class id extends(m(C)){id;sourceId;_options;_data;bbox;_loadImagesList;_layout;_paint;hoveredPolygonId;constructor(t,e,i){super(),this.id=i||d(0,5),this.sourceId=this.id+"source",this._data=t,this.hoveredPolygonId=null,this.bbox=Kp(t),this._options=Object.assign({scale:1,color:"#ffffff",imageName:"",highlightImageName:"",cluster:!1,clusterRadius:0,clusterProperties:{},clusterMinPoints:2,iconOffset:[0,0],symbolPlacement:"point",symbolSpacing:250,isShow:!0,minimumLevel:0,maximumLevel:24},e);const n={...e,...e?e.labelOption:{}};this._options.labelOption=Object.assign({pixelOffset:[0,0],allShow:!0,fontSize:"30px",fontColor:"#fff",fontFamily:["Microsoft YaHei"],horizontalOrigin:"center",verticalOrigin:"center",outlineColor:"rgba(0, 0, 0, 0)",outlineWidth:0,outlineBlur:0,iconOverlap:!1,textOverlap:!1},n||{}),this._layout={visibility:this._options.isShow?"visible":"none","icon-size":this._options.scale,"text-field":["get","text"],"text-size":this.getTextSize(),"text-offset":this._options.labelOption.pixelOffset,"icon-offset":this._options.iconOffset,"text-font":this._options.labelOption.fontFamily,"text-justify":this._options.labelOption.horizontalOrigin,"text-anchor":this._options.labelOption.verticalOrigin,"icon-allow-overlap":this.getOver("iconOverlap"),"text-allow-overlap":this.getOver("textOverlap"),"symbol-placement":this._options.symbolPlacement,"symbol-spacing":this._options.symbolSpacing},this._paint={"text-color":this._options.labelOption.fontColor,"text-opacity":this._options.labelOption.allShow?1:0,"text-halo-color":this._options.labelOption.outlineColor,"text-halo-width":this._options.labelOption.outlineWidth,"text-halo-blur":this._options.labelOption.outlineBlur},this.renderSource(),this._loadImagesList=[],this._options.highlightImage&&this.addImage("highlightImage"),this._options.image&&this.addImage("image"),this._options.highlightImage||this._options.image||this.render()}addImage(t){let e=[];const i="string"==typeof this._options[t];if(i){e=[{[d(0,2)]:this._options[t]}]}else this._options[t].length&&(e=this._options[t]);const n=[];e.forEach((e=>{const r=new Promise(((n,r)=>{const o=Object.keys(e).length?Object.keys(e)[0]:d(0,2),s=e[o]?e[o]:e;"image"==t?this._layout["icon-image"]=i?o:["get","imageName"]:this._options.highlightImageName=i?o:["get","highlightImageName"],cNt.value.loadImage(s,((t,e)=>{t?r(t):cNt.value.hasImage(o)?r(`An image name named "${o}" already exists`):(cNt.value.addImage(o,e),this._loadImagesList.push(o),n())}))}));n.push(r)})),Promise.all(n).then((()=>{"image"==t&&this.render()})).catch((t=>{console.error("Error loading images:",t)}))}renderSource(){const t={type:"geojson",data:this._data,cluster:this._options.cluster,clusterRadius:this._options.clusterRadius,clusterProperties:this._options.clusterProperties,clusterMinPoints:this._options.clusterMinPoints};this._options.clusterMaxZoom&&(t.clusterMaxZoom=this._options.clusterMaxZoom),"massivePoints"==this._options.type&&(t.cluster=!0,t.clusterRadius=0),cNt.value.addSource(this.sourceId,t)}render(){const t={id:this.id,source:this.sourceId,type:"symbol",layout:this._layout,paint:this._paint,minzoom:this._options.minimumLevel,maxzoom:this._options.maximumLevel};"assemblage"==this._options.type&&(t.filter=["!",["has","point_count"]]),cNt.value.addLayer(t),this._options.labelOption&&0==this._options.labelOption.allShow&&(cNt.value.on("mouseenter",this.id,(t=>this.mouseenter(t))),cNt.value.on("mouseleave",this.id,(()=>this.mouseleave())))}mouseenter(t){this.hoveredPolygonId=t.features[0].properties.id;cNt.value.queryRenderedFeatures(t.point,{layers:[this.id]})[0].properties.text&&this.hoveredPolygonId?null!=cNt.value.getPaintProperty(this.id,"text-opacity")&&cNt.value.setPaintProperty(this.id,"text-opacity",["case",["boolean",["==",["get","id"],this.hoveredPolygonId],!1],1,0]):this.hoveredPolygonId}mouseleave(){null!==this.hoveredPolygonId&&cNt.value.setPaintProperty(this.id,"text-opacity",0),this.hoveredPolygonId=null}highlight(t){if(this._options.highlightImageName){const e=cNt.value.querySourceFeatures(this.sourceId,{filter:["in","id",t]});if(!e.length)throw new Error(`The highlight id is ${t} does not exist`);{const t=e[0];cNt.value.addSource(this.id+"Highlightsource",{type:"geojson",data:t});let i={visibility:this._options.isShow?"visible":"none","icon-image":this._options.highlightImageName,"icon-size":this._options.scale,"text-field":["get","text"],"text-size":this.getTextSize(),"icon-offset":this._options.iconOffset,"icon-allow-overlap":this.getOver("iconOverlap"),"text-allow-overlap":this.getOver("textOverlap"),"symbol-placement":this._options.symbolPlacement,"symbol-spacing":this._options.symbolSpacing};this._options.labelOption&&(i={visibility:this._options.isShow?"visible":"none","icon-image":this._options.highlightImageName,"icon-size":this._options.scale,"text-field":["get","text"],"text-size":this.getTextSize(),"text-offset":this._options.labelOption.pixelOffset,"icon-offset":this._options.iconOffset,"text-font":this._options.labelOption.fontFamily,"text-justify":this._options.labelOption.horizontalOrigin,"text-anchor":this._options.labelOption.verticalOrigin,"icon-allow-overlap":this.getOver("iconOverlap"),"text-allow-overlap":this.getOver("textOverlap"),"symbol-placement":this._options.symbolPlacement,"symbol-spacing":this._options.symbolSpacing});let n={};this._options.labelOption&&(n={"text-color":this._options.labelOption.fontColor,"text-opacity":this._options.labelOption.allShow?1:0,"text-halo-color":this._options.labelOption.outlineColor,"text-halo-width":this._options.labelOption.outlineWidth,"text-halo-blur":this._options.labelOption.outlineBlur}),cNt.value.addLayer({id:this.id+"Highlight",source:this.id+"Highlightsource",type:"symbol",layout:i,paint:n})}}}removeHighlight(){cNt.value.removeLayer(this.id+"Highlight"),cNt.value.removeSource(this.id+"Highlightsource")}destroy(){this._loadImagesList.forEach((t=>{cNt.value.hasImage(t)&&cNt.value.removeImage(t)})),super.destroy()}_isFeatureCollectionData(t){return t instanceof Array}update(t){let e=t;this._isFeatureCollectionData(t)&&(e=$p(t,"point")),this.bbox=Kp(e),this.updateSource("source",e),this.updateSource("Highlightsource",e)}updateSource(t,e){const i=cNt.value.getSource(this.id+t);if(i)i.setData(e);else if("source"==t)throw new Error("This source does not exist")}getTextSize(){if(this._options.labelOption)return"number"==typeof this._options.labelOption.fontSize?this._options.labelOption.fontSize:Number(Number(this._options.labelOption.fontSize?this._options.labelOption.fontSize.split("px")[0]:"0")*Number(this._options.scale))}getOver(t){let e=!1;return"massivePoints"==this._options.type?e=!0:this._options.labelOption&&(e=this._options.labelOption[t]),e}}class nd extends(m(C)){id;sourceId;_options;_data;bbox;constructor(t,e,i){super(),this.id=i||d(0,5),this.sourceId=this.id+"source",this._data=t,this.bbox=Kp(t),this._options=Object.assign({color:"rgb(255,0,0)",pixelSize:20,outlineColor:"rgb(255,0,0)",outlineWidth:0,isShow:!0},e),this._options.labelOption=Object.assign({pixelOffset:[0,0],allShow:!0,fontSize:"30px",fontColor:"#fff",fontFamily:["Microsoft YaHei"],horizontalOrigin:"center",verticalOrigin:"center",outlineColor:"#fff",outlineWidth:0,outlineBlur:0},e?e.labelOption:{}),this.reander()}reander(){const t={type:"geojson",data:this._data};cNt.value.addSource(this.sourceId,t),cNt.value.addLayer({id:this.id,type:"circle",source:`${this.id}source`,layout:{visibility:this._options.isShow?"visible":"none"},paint:{"circle-color":this._options.color,"circle-radius":this._options.pixelSize,"circle-stroke-color":this._options.outlineColor,"circle-stroke-width":this._options.outlineWidth}}),cNt.value.addLayer({id:`${this.id}-label`,type:"symbol",source:`${this.id}source`,layout:{visibility:this._options.isShow?"visible":"none","text-field":["get","text"],"text-offset":this._options.labelOption?this._options.labelOption.pixelOffset:null,"text-font":this._options.labelOption?this._options.labelOption.fontFamily:null,"text-justify":this._options.labelOption?this._options.labelOption.horizontalOrigin:null,"text-anchor":this._options.labelOption?this._options.labelOption.verticalOrigin:null,"text-size":Number(this._options.labelOption&&this._options.labelOption.fontSize?this._options.labelOption.fontSize.split("px")[0]:""),"text-allow-overlap":!0},paint:{"text-color":this._options.labelOption?this._options.labelOption.fontColor:null,"text-halo-color":this._options.labelOption?this._options.labelOption.outlineColor:null,"text-halo-width":this._options.labelOption?this._options.labelOption.outlineWidth:null,"text-opacity":this._options.labelOption&&this._options.labelOption.allShow?1:0}}),this._options.labelOption&&0==this._options.labelOption.allShow&&(cNt.value.on("mouseenter",this.id,(t=>this.mouseenter(t))),cNt.value.on("mouseleave",this.id,(()=>this.mouseleave())))}mouseenter(t){const e=t.features[0].properties.id;cNt.value.queryRenderedFeatures(t.point,{layers:[`${this.id}`]})[0].properties.text&&cNt.value.setPaintProperty(`${this.id}-label`,"text-opacity",["case",["boolean",["==",["get","id"],e],!1],1,0])}mouseleave(){cNt.value.setPaintProperty(`${this.id}-label`,"text-opacity",0)}destroy(){cNt.value.removeLayer(`${this.id}-label`),this._options.labelOption&&0==this._options.labelOption.allShow&&(cNt.value.off("mouseenter",this.id,(t=>this.mouseenter(t))),cNt.value.off("mouseleave",this.id,(()=>this.mouseleave()))),super.destroy()}}function rd(t,e,i){let n;return n=p(t)?$p(t,"point"):t,new id(n,e,i)}var od={exports:{}},sd={exports:{}},ad={exports:{}};!function(t,e){!function(t){const e="132",i=100,n=300,r=301,o=302,s=303,a=304,l=306,c=307,u=1e3,h=1001,p=1002,d=1003,f=1004,m=1005,g=1006,y=1007,v=1008,_=1009,x=1012,b=1014,w=1015,A=1016,E=1020,S=1022,M=1023,T=1026,I=1027,C=33776,P=33777,L=33778,D=33779,R=35840,O=35841,k=35842,N=35843,B=37492,z=37496,F=2300,V=2301,U=2302,G=2400,j=2401,H=2402,W=2500,q=2501,X=3e3,Z=3001,Y=3007,Q=3002,J=3004,K=3005,$=3006,tt=7680,et=35044,it=35048,nt="300 es";class rt{addEventListener(t,e){void 0===this._listeners&&(this._listeners={});const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){if(void 0===this._listeners)return!1;const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const i=this._listeners[t];if(void 0!==i){const t=i.indexOf(e);-1!==t&&i.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 i=e.slice(0);for(let e=0,n=i.length;e>8&255]+ot[t>>16&255]+ot[t>>24&255]+"-"+ot[255&e]+ot[e>>8&255]+"-"+ot[e>>16&15|64]+ot[e>>24&255]+"-"+ot[63&i|128]+ot[i>>8&255]+"-"+ot[i>>16&255]+ot[i>>24&255]+ot[255&n]+ot[n>>8&255]+ot[n>>16&255]+ot[n>>24&255]).toUpperCase()}function ut(t,e,i){return Math.max(e,Math.min(i,t))}function ht(t,e){return(t%e+e)%e}function pt(t,e,i){return(1-i)*t+i*e}function dt(t){return 0==(t&t-1)&&0!==t}function ft(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function mt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var gt=Object.freeze({__proto__:null,DEG2RAD:at,RAD2DEG:lt,generateUUID:ct,clamp:ut,euclideanModulo:ht,mapLinear:function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},inverseLerp:function(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:pt,damp:function(t,e,i,n){return pt(t,e,1-Math.exp(-i*n))},pingpong:function(t,e=1){return e-Math.abs(ht(t,2*e)-e)},smoothstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-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&&(st=t%2147483647),st=16807*st%2147483647,(st-1)/2147483646},degToRad:function(t){return t*at},radToDeg:function(t){return t*lt},isPowerOfTwo:dt,ceilPowerOfTwo:ft,floorPowerOfTwo:mt,setQuaternionFromProperEuler:function(t,e,i,n,r){const o=Math.cos,s=Math.sin,a=o(i/2),l=s(i/2),c=o((e+n)/2),u=s((e+n)/2),h=o((e-n)/2),p=s((e-n)/2),d=o((n-e)/2),f=s((n-e)/2);switch(r){case"XYX":t.set(a*u,l*h,l*p,a*c);break;case"YZY":t.set(l*p,a*u,l*h,a*c);break;case"ZXZ":t.set(l*h,l*p,a*u,a*c);break;case"XZX":t.set(a*u,l*f,l*d,a*c);break;case"YXY":t.set(l*d,a*u,l*f,a*c);break;case"ZYZ":t.set(l*f,l*d,a*u,a*c);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}});class yt{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,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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,i){return void 0!==i&&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 i=Math.cos(e),n=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*i-o*n+t.x,this.y=r*n+o*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}}yt.prototype.isVector2=!0;class vt{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,i,n,r,o,s,a,l){const c=this.elements;return c[0]=t,c[1]=n,c[2]=s,c[3]=e,c[4]=r,c[5]=a,c[6]=i,c[7]=o,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,n=e.elements,r=this.elements,o=i[0],s=i[3],a=i[6],l=i[1],c=i[4],u=i[7],h=i[2],p=i[5],d=i[8],f=n[0],m=n[3],g=n[6],y=n[1],v=n[4],_=n[7],x=n[2],b=n[5],w=n[8];return r[0]=o*f+s*y+a*x,r[3]=o*m+s*v+a*b,r[6]=o*g+s*_+a*w,r[1]=l*f+c*y+u*x,r[4]=l*m+c*v+u*b,r[7]=l*g+c*_+u*w,r[2]=h*f+p*y+d*x,r[5]=h*m+p*v+d*b,r[8]=h*g+p*_+d*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8];return e*o*c-e*s*l-i*r*c+i*s*a+n*r*l-n*o*a}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=c*o-s*l,h=s*a-c*r,p=l*r-o*a,d=e*u+i*h+n*p;if(0===d)return this.set(0,0,0,0,0,0,0,0,0);const f=1/d;return t[0]=u*f,t[1]=(n*l-c*i)*f,t[2]=(s*i-n*o)*f,t[3]=h*f,t[4]=(c*e-n*a)*f,t[5]=(n*r-s*e)*f,t[6]=p*f,t[7]=(i*a-l*e)*f,t[8]=(o*e-i*r)*f,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,i,n,r,o,s){const a=Math.cos(r),l=Math.sin(r);return this.set(i*a,i*l,-i*(a*o+l*s)+o+t,-n*l,n*a,-n*(-l*o+a*s)+s+e,0,0,1),this}scale(t,e){const i=this.elements;return i[0]*=t,i[3]*=t,i[6]*=t,i[1]*=e,i[4]*=e,i[7]*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),n=this.elements,r=n[0],o=n[3],s=n[6],a=n[1],l=n[4],c=n[7];return n[0]=e*r+i*a,n[3]=e*o+i*l,n[6]=e*s+i*c,n[1]=-i*r+e*a,n[4]=-i*o+e*l,n[7]=-i*s+e*c,this}translate(t,e){const i=this.elements;return i[0]+=t*i[2],i[3]+=t*i[5],i[6]+=t*i[8],i[1]+=e*i[2],i[4]+=e*i[5],i[7]+=e*i[8],this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return(new this.constructor).fromArray(this.elements)}}let _t;vt.prototype.isMatrix3=!0;class xt{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===_t&&(_t=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),_t.width=t.width,_t.height=t.height;const i=_t.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=_t}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 bt=0;class wt extends rt{constructor(t=wt.DEFAULT_IMAGE,e=wt.DEFAULT_MAPPING,i=1001,n=1001,r=1006,o=1008,s=1023,a=1009,l=1,c=3e3){super(),Object.defineProperty(this,"id",{value:bt++}),this.uuid=ct(),this.name="",this.image=t,this.mipmaps=[],this.mapping=e,this.wrapS=i,this.wrapT=n,this.magFilter=r,this.minFilter=o,this.anisotropy=l,this.format=s,this.internalFormat=null,this.type=a,this.offset=new yt(0,0),this.repeat=new yt(1,1),this.center=new yt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new vt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,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 i={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 n=this.image;if(void 0===n.uuid&&(n.uuid=ct()),!e&&void 0===t.images[n.uuid]){let e;if(Array.isArray(n)){e=[];for(let t=0,i=n.length;t1)switch(this.wrapS){case u: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 u: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 At(t){return"undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap?xt.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."),{})}wt.DEFAULT_IMAGE=void 0,wt.DEFAULT_MAPPING=n,wt.prototype.isTexture=!0;class Et{constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("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,i=this.y,n=this.z,r=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*n+o[12]*r,this.y=o[1]*e+o[5]*i+o[9]*n+o[13]*r,this.z=o[2]*e+o[6]*i+o[10]*n+o[14]*r,this.w=o[3]*e+o[7]*i+o[11]*n+o[15]*r,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,i,n,r;const o=.01,s=.1,a=t.elements,l=a[0],c=a[4],u=a[8],h=a[1],p=a[5],d=a[9],f=a[2],m=a[6],g=a[10];if(Math.abs(c-h)a&&t>y?ty?a=0?1:-1,n=1-e*e;if(n>Number.EPSILON){const r=Math.sqrt(n),o=Math.atan2(r,e*i);t=Math.sin(t*o)/r,s=Math.sin(s*o)/r}const r=s*i;if(a=a*t+h*r,l=l*t+p*r,c=c*t+d*r,u=u*t+f*r,t===1-s){const t=1/Math.sqrt(a*a+l*l+c*c+u*u);a*=t,l*=t,c*=t,u*=t}}t[e]=a,t[e+1]=l,t[e+2]=c,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,n,r,o){const s=i[n],a=i[n+1],l=i[n+2],c=i[n+3],u=r[o],h=r[o+1],p=r[o+2],d=r[o+3];return t[e]=s*d+c*u+a*p-l*h,t[e+1]=a*d+c*h+l*u-s*p,t[e+2]=l*d+c*p+s*h-a*u,t[e+3]=c*d-s*u-a*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,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e){if(!t||!t.isEuler)throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const i=t._x,n=t._y,r=t._z,o=t._order,s=Math.cos,a=Math.sin,l=s(i/2),c=s(n/2),u=s(r/2),h=a(i/2),p=a(n/2),d=a(r/2);switch(o){case"XYZ":this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d;break;case"YXZ":this._x=h*c*u+l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d;break;case"ZXY":this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u-h*p*d;break;case"ZYX":this._x=h*c*u-l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u+h*p*d;break;case"YZX":this._x=h*c*u+l*p*d,this._y=l*p*u+h*c*d,this._z=l*c*d-h*p*u,this._w=l*c*u-h*p*d;break;case"XZY":this._x=h*c*u-l*p*d,this._y=l*p*u-h*c*d,this._z=l*c*d+h*p*u,this._w=l*c*u+h*p*d;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return!1!==e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],r=e[8],o=e[1],s=e[5],a=e[9],l=e[2],c=e[6],u=e[10],h=i+s+u;if(h>0){const t=.5/Math.sqrt(h+1);this._w=.25/t,this._x=(c-a)*t,this._y=(r-l)*t,this._z=(o-n)*t}else if(i>s&&i>u){const t=2*Math.sqrt(1+i-s-u);this._w=(c-a)/t,this._x=.25*t,this._y=(n+o)/t,this._z=(r+l)/t}else if(s>u){const t=2*Math.sqrt(1+s-i-u);this._w=(r-l)/t,this._x=(n+o)/t,this._y=.25*t,this._z=(a+c)/t}else{const t=2*Math.sqrt(1+u-i-s);this._w=(o-n)/t,this._x=(r+l)/t,this._y=(a+c)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(ut(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t,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 i=t._x,n=t._y,r=t._z,o=t._w,s=e._x,a=e._y,l=e._z,c=e._w;return this._x=i*c+o*s+n*l-r*a,this._y=n*c+o*a+r*s-i*l,this._z=r*c+o*l+i*a-n*s,this._w=o*c-i*s-n*a-r*l,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,n=this._y,r=this._z,o=this._w;let s=o*t._w+i*t._x+n*t._y+r*t._z;if(s<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,s=-s):this.copy(t),s>=1)return this._w=o,this._x=i,this._y=n,this._z=r,this;const a=1-s*s;if(a<=Number.EPSILON){const t=1-e;return this._w=t*o+e*this._w,this._x=t*i+e*this._x,this._y=t*n+e*this._y,this._z=t*r+e*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(a),c=Math.atan2(l,s),u=Math.sin((1-e)*c)/l,h=Math.sin(e*c)/l;return this._w=o*u+this._w*h,this._x=i*u+this._x*h,this._y=n*u+this._y*h,this._z=r*u+this._z*h,this._onChangeCallback(),this}slerpQuaternions(t,e,i){this.copy(t).slerp(e,i)}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(){}}It.prototype.isQuaternion=!0;class Ct{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,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,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*n,this.y=r[1]*e+r[4]*i+r[7]*n,this.z=r[2]*e+r[5]*i+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,r=t.elements,o=1/(r[3]*e+r[7]*i+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*n+r[12])*o,this.y=(r[1]*e+r[5]*i+r[9]*n+r[13])*o,this.z=(r[2]*e+r[6]*i+r[10]*n+r[14])*o,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,r=t.x,o=t.y,s=t.z,a=t.w,l=a*e+o*n-s*i,c=a*i+s*e-r*n,u=a*n+r*i-o*e,h=-r*e-o*i-s*n;return this.x=l*a+h*-r+c*-s-u*-o,this.y=c*a+h*-o+u*-r-l*-s,this.z=u*a+h*-s+l*-o-c*-r,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,i=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n,this.y=r[1]*e+r[5]*i+r[9]*n,this.z=r[2]*e+r[6]*i+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,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 i=t.x,n=t.y,r=t.z,o=e.x,s=e.y,a=e.z;return this.x=n*a-r*s,this.y=r*o-i*a,this.z=i*s-n*o,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Pt.copy(this).projectOnVector(t),this.sub(Pt)}reflect(t){return this.sub(Pt.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 i=this.dot(t)/e;return Math.acos(ut(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,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,i){return void 0!==i&&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}}Ct.prototype.isVector3=!0;const Pt=new Ct,Lt=new It;class Dt{constructor(t=new Ct(1/0,1/0,1/0),e=new Ct(-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,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,l=t.length;ar&&(r=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(e,i,n),this.max.set(r,o,s),this}setFromBufferAttribute(t){let e=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;for(let a=0,l=t.count;ar&&(r=l),c>o&&(o=c),u>s&&(s=u)}return this.min.set(e,i,n),this.max.set(r,o,s),this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;ethis.max.x||t.ythis.max.y||t.zthis.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.xthis.max.x||t.max.ythis.max.y||t.max.zthis.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Ot),Ot.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Gt),jt.subVectors(this.max,Gt),Nt.subVectors(t.a,Gt),Bt.subVectors(t.b,Gt),zt.subVectors(t.c,Gt),Ft.subVectors(Bt,Nt),Vt.subVectors(zt,Bt),Ut.subVectors(Nt,zt);let e=[0,-Ft.z,Ft.y,0,-Vt.z,Vt.y,0,-Ut.z,Ut.y,Ft.z,0,-Ft.x,Vt.z,0,-Vt.x,Ut.z,0,-Ut.x,-Ft.y,Ft.x,0,-Vt.y,Vt.x,0,-Ut.y,Ut.x,0];return!!qt(e,Nt,Bt,zt,jt)&&(e=[1,0,0,0,1,0,0,0,1],!!qt(e,Nt,Bt,zt,jt)&&(Ht.crossVectors(Ft,Vt),e=[Ht.x,Ht.y,Ht.z],qt(e,Nt,Bt,zt,jt)))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Ot.copy(t).clamp(this.min,this.max).sub(t).length()}getBoundingSphere(t){return this.getCenter(t.center),t.radius=.5*this.getSize(Ot).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)}}Dt.prototype.isBox3=!0;const Rt=[new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct,new Ct],Ot=new Ct,kt=new Dt,Nt=new Ct,Bt=new Ct,zt=new Ct,Ft=new Ct,Vt=new Ct,Ut=new Ct,Gt=new Ct,jt=new Ct,Ht=new Ct,Wt=new Ct;function qt(t,e,i,n,r){for(let o=0,s=t.length-3;o<=s;o+=3){Wt.fromArray(t,o);const s=r.x*Math.abs(Wt.x)+r.y*Math.abs(Wt.y)+r.z*Math.abs(Wt.z),a=e.dot(Wt),l=i.dot(Wt),c=n.dot(Wt);if(Math.max(-Math.max(a,l,c),Math.min(a,l,c))>s)return!1}return!0}const Xt=new Dt,Zt=new Ct,Yt=new Ct,Qt=new Ct;class Jt{constructor(t=new Ct,e=-1){this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;void 0!==e?i.copy(e):Xt.setFromPoints(t).getCenter(i);let n=0;for(let e=0,r=t.length;ethis.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){Qt.subVectors(t,this.center);const e=Qt.lengthSq();if(e>this.radius*this.radius){const t=Math.sqrt(e),i=.5*(t-this.radius);this.center.add(Qt.multiplyScalar(i/t)),this.radius+=i}return this}union(t){return Yt.subVectors(t.center,this.center).normalize().multiplyScalar(t.radius),this.expandByPoint(Zt.copy(t.center).add(Yt)),this.expandByPoint(Zt.copy(t.center).sub(Yt)),this}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Kt=new Ct,$t=new Ct,te=new Ct,ee=new Ct,ie=new Ct,ne=new Ct,re=new Ct;class oe{constructor(t=new Ct,e=new Ct(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 i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.direction).multiplyScalar(i).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,i,n){$t.copy(t).add(e).multiplyScalar(.5),te.copy(e).sub(t).normalize(),ee.copy(this.origin).sub($t);const r=.5*t.distanceTo(e),o=-this.direction.dot(te),s=ee.dot(this.direction),a=-ee.dot(te),l=ee.lengthSq(),c=Math.abs(1-o*o);let u,h,p,d;if(c>0)if(u=o*a-s,h=o*s-a,d=r*c,u>=0)if(h>=-d)if(h<=d){const t=1/c;u*=t,h*=t,p=u*(u+o*h+2*s)+h*(o*u+h+2*a)+l}else h=r,u=Math.max(0,-(o*h+s)),p=-u*u+h*(h+2*a)+l;else h=-r,u=Math.max(0,-(o*h+s)),p=-u*u+h*(h+2*a)+l;else h<=-d?(u=Math.max(0,-(-o*r+s)),h=u>0?-r:Math.min(Math.max(-r,-a),r),p=-u*u+h*(h+2*a)+l):h<=d?(u=0,h=Math.min(Math.max(-r,-a),r),p=h*(h+2*a)+l):(u=Math.max(0,-(o*r+s)),h=u>0?r:Math.min(Math.max(-r,-a),r),p=-u*u+h*(h+2*a)+l);else h=o>0?-r:r,u=Math.max(0,-(o*h+s)),p=-u*u+h*(h+2*a)+l;return i&&i.copy(this.direction).multiplyScalar(u).add(this.origin),n&&n.copy(te).multiplyScalar(h).add($t),p}intersectSphere(t,e){Kt.subVectors(t.center,this.origin);const i=Kt.dot(this.direction),n=Kt.dot(Kt)-i*i,r=t.radius*t.radius;if(n>r)return null;const o=Math.sqrt(r-n),s=i-o,a=i+o;return s<0&&a<0?null:s<0?this.at(a,e):this.at(s,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 i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return null===i?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return 0===e||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,r,o,s,a;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,h=this.origin;return l>=0?(i=(t.min.x-h.x)*l,n=(t.max.x-h.x)*l):(i=(t.max.x-h.x)*l,n=(t.min.x-h.x)*l),c>=0?(r=(t.min.y-h.y)*c,o=(t.max.y-h.y)*c):(r=(t.max.y-h.y)*c,o=(t.min.y-h.y)*c),i>o||r>n?null:((r>i||i!=i)&&(i=r),(o=0?(s=(t.min.z-h.z)*u,a=(t.max.z-h.z)*u):(s=(t.max.z-h.z)*u,a=(t.min.z-h.z)*u),i>a||s>n?null:((s>i||i!=i)&&(i=s),(a=0?i:n,e)))}intersectsBox(t){return null!==this.intersectBox(t,Kt)}intersectTriangle(t,e,i,n,r){ie.subVectors(e,t),ne.subVectors(i,t),re.crossVectors(ie,ne);let o,s=this.direction.dot(re);if(s>0){if(n)return null;o=1}else{if(!(s<0))return null;o=-1,s=-s}ee.subVectors(this.origin,t);const a=o*this.direction.dot(ne.crossVectors(ee,ne));if(a<0)return null;const l=o*this.direction.dot(ie.cross(ee));if(l<0)return null;if(a+l>s)return null;const c=-o*ee.dot(re);return c<0?null:this.at(c/s,r)}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 se{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,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=r,g[5]=o,g[9]=s,g[13]=a,g[2]=l,g[6]=c,g[10]=u,g[14]=h,g[3]=p,g[7]=d,g[11]=f,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 se).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/ae.setFromMatrixColumn(t,0).length(),r=1/ae.setFromMatrixColumn(t,1).length(),o=1/ae.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[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,i=t.x,n=t.y,r=t.z,o=Math.cos(i),s=Math.sin(i),a=Math.cos(n),l=Math.sin(n),c=Math.cos(r),u=Math.sin(r);if("XYZ"===t.order){const t=o*c,i=o*u,n=s*c,r=s*u;e[0]=a*c,e[4]=-a*u,e[8]=l,e[1]=i+n*l,e[5]=t-r*l,e[9]=-s*a,e[2]=r-t*l,e[6]=n+i*l,e[10]=o*a}else if("YXZ"===t.order){const t=a*c,i=a*u,n=l*c,r=l*u;e[0]=t+r*s,e[4]=n*s-i,e[8]=o*l,e[1]=o*u,e[5]=o*c,e[9]=-s,e[2]=i*s-n,e[6]=r+t*s,e[10]=o*a}else if("ZXY"===t.order){const t=a*c,i=a*u,n=l*c,r=l*u;e[0]=t-r*s,e[4]=-o*u,e[8]=n+i*s,e[1]=i+n*s,e[5]=o*c,e[9]=r-t*s,e[2]=-o*l,e[6]=s,e[10]=o*a}else if("ZYX"===t.order){const t=o*c,i=o*u,n=s*c,r=s*u;e[0]=a*c,e[4]=n*l-i,e[8]=t*l+r,e[1]=a*u,e[5]=r*l+t,e[9]=i*l-n,e[2]=-l,e[6]=s*a,e[10]=o*a}else if("YZX"===t.order){const t=o*a,i=o*l,n=s*a,r=s*l;e[0]=a*c,e[4]=r-t*u,e[8]=n*u+i,e[1]=u,e[5]=o*c,e[9]=-s*c,e[2]=-l*c,e[6]=i*u+n,e[10]=t-r*u}else if("XZY"===t.order){const t=o*a,i=o*l,n=s*a,r=s*l;e[0]=a*c,e[4]=-u,e[8]=l*c,e[1]=t*u+r,e[5]=o*c,e[9]=i*u-n,e[2]=n*u-i,e[6]=s*c,e[10]=r*u+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(ce,t,ue)}lookAt(t,e,i){const n=this.elements;return de.subVectors(t,e),0===de.lengthSq()&&(de.z=1),de.normalize(),he.crossVectors(i,de),0===he.lengthSq()&&(1===Math.abs(i.z)?de.x+=1e-4:de.z+=1e-4,de.normalize(),he.crossVectors(i,de)),he.normalize(),pe.crossVectors(de,he),n[0]=he.x,n[4]=pe.x,n[8]=de.x,n[1]=he.y,n[5]=pe.y,n[9]=de.y,n[2]=he.z,n[6]=pe.z,n[10]=de.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 i=t.elements,n=e.elements,r=this.elements,o=i[0],s=i[4],a=i[8],l=i[12],c=i[1],u=i[5],h=i[9],p=i[13],d=i[2],f=i[6],m=i[10],g=i[14],y=i[3],v=i[7],_=i[11],x=i[15],b=n[0],w=n[4],A=n[8],E=n[12],S=n[1],M=n[5],T=n[9],I=n[13],C=n[2],P=n[6],L=n[10],D=n[14],R=n[3],O=n[7],k=n[11],N=n[15];return r[0]=o*b+s*S+a*C+l*R,r[4]=o*w+s*M+a*P+l*O,r[8]=o*A+s*T+a*L+l*k,r[12]=o*E+s*I+a*D+l*N,r[1]=c*b+u*S+h*C+p*R,r[5]=c*w+u*M+h*P+p*O,r[9]=c*A+u*T+h*L+p*k,r[13]=c*E+u*I+h*D+p*N,r[2]=d*b+f*S+m*C+g*R,r[6]=d*w+f*M+m*P+g*O,r[10]=d*A+f*T+m*L+g*k,r[14]=d*E+f*I+m*D+g*N,r[3]=y*b+v*S+_*C+x*R,r[7]=y*w+v*M+_*P+x*O,r[11]=y*A+v*T+_*L+x*k,r[15]=y*E+v*I+_*D+x*N,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],r=t[12],o=t[1],s=t[5],a=t[9],l=t[13],c=t[2],u=t[6],h=t[10],p=t[14];return t[3]*(+r*a*u-n*l*u-r*s*h+i*l*h+n*s*p-i*a*p)+t[7]*(+e*a*p-e*l*h+r*o*h-n*o*p+n*l*c-r*a*c)+t[11]*(+e*l*u-e*s*p-r*o*u+i*o*p+r*s*c-i*l*c)+t[15]*(-n*s*c-e*a*u+e*s*h+n*o*u-i*o*h+i*a*c)}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,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],r=t[3],o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=t[9],h=t[10],p=t[11],d=t[12],f=t[13],m=t[14],g=t[15],y=u*m*l-f*h*l+f*a*p-s*m*p-u*a*g+s*h*g,v=d*h*l-c*m*l-d*a*p+o*m*p+c*a*g-o*h*g,_=c*f*l-d*u*l+d*s*p-o*f*p-c*s*g+o*u*g,x=d*u*a-c*f*a-d*s*h+o*f*h+c*s*m-o*u*m,b=e*y+i*v+n*_+r*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]=(f*h*r-u*m*r-f*n*p+i*m*p+u*n*g-i*h*g)*w,t[2]=(s*m*r-f*a*r+f*n*l-i*m*l-s*n*g+i*a*g)*w,t[3]=(u*a*r-s*h*r-u*n*l+i*h*l+s*n*p-i*a*p)*w,t[4]=v*w,t[5]=(c*m*r-d*h*r+d*n*p-e*m*p-c*n*g+e*h*g)*w,t[6]=(d*a*r-o*m*r-d*n*l+e*m*l+o*n*g-e*a*g)*w,t[7]=(o*h*r-c*a*r+c*n*l-e*h*l-o*n*p+e*a*p)*w,t[8]=_*w,t[9]=(d*u*r-c*f*r-d*i*p+e*f*p+c*i*g-e*u*g)*w,t[10]=(o*f*r-d*s*r+d*i*l-e*f*l-o*i*g+e*s*g)*w,t[11]=(c*s*r-o*u*r-c*i*l+e*u*l+o*i*p-e*s*p)*w,t[12]=x*w,t[13]=(c*f*n-d*u*n+d*i*h-e*f*h-c*i*m+e*u*m)*w,t[14]=(d*s*n-o*f*n-d*i*a+e*f*a+o*i*m-e*s*m)*w,t[15]=(o*u*n-c*s*n+c*i*a-e*u*a-o*i*h+e*s*h)*w,this}scale(t){const e=this.elements,i=t.x,n=t.y,r=t.z;return e[0]*=i,e[4]*=n,e[8]*=r,e[1]*=i,e[5]*=n,e[9]*=r,e[2]*=i,e[6]*=n,e[10]*=r,e[3]*=i,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),r=1-i,o=t.x,s=t.y,a=t.z,l=r*o,c=r*s;return this.set(l*o+i,l*s-n*a,l*a+n*s,0,l*s+n*a,c*s+i,c*a-n*o,0,l*a-n*s,c*a+n*o,r*a*a+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,r,o){return this.set(1,i,r,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,r=e._x,o=e._y,s=e._z,a=e._w,l=r+r,c=o+o,u=s+s,h=r*l,p=r*c,d=r*u,f=o*c,m=o*u,g=s*u,y=a*l,v=a*c,_=a*u,x=i.x,b=i.y,w=i.z;return n[0]=(1-(f+g))*x,n[1]=(p+_)*x,n[2]=(d-v)*x,n[3]=0,n[4]=(p-_)*b,n[5]=(1-(h+g))*b,n[6]=(m+y)*b,n[7]=0,n[8]=(d+v)*w,n[9]=(m-y)*w,n[10]=(1-(h+f))*w,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let r=ae.set(n[0],n[1],n[2]).length();const o=ae.set(n[4],n[5],n[6]).length(),s=ae.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],le.copy(this);const a=1/r,l=1/o,c=1/s;return le.elements[0]*=a,le.elements[1]*=a,le.elements[2]*=a,le.elements[4]*=l,le.elements[5]*=l,le.elements[6]*=l,le.elements[8]*=c,le.elements[9]*=c,le.elements[10]*=c,e.setFromRotationMatrix(le),i.x=r,i.y=o,i.z=s,this}makePerspective(t,e,i,n,r,o){void 0===o&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const s=this.elements,a=2*r/(e-t),l=2*r/(i-n),c=(e+t)/(e-t),u=(i+n)/(i-n),h=-(o+r)/(o-r),p=-2*o*r/(o-r);return s[0]=a,s[4]=0,s[8]=c,s[12]=0,s[1]=0,s[5]=l,s[9]=u,s[13]=0,s[2]=0,s[6]=0,s[10]=h,s[14]=p,s[3]=0,s[7]=0,s[11]=-1,s[15]=0,this}makeOrthographic(t,e,i,n,r,o){const s=this.elements,a=1/(e-t),l=1/(i-n),c=1/(o-r),u=(e+t)*a,h=(i+n)*l,p=(o+r)*c;return s[0]=2*a,s[4]=0,s[8]=0,s[12]=-u,s[1]=0,s[5]=2*l,s[9]=0,s[13]=-h,s[2]=0,s[6]=0,s[10]=-2*c,s[14]=-p,s[3]=0,s[7]=0,s[11]=0,s[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}se.prototype.isMatrix4=!0;const ae=new Ct,le=new se,ce=new Ct(0,0,0),ue=new Ct(1,1,1),he=new Ct,pe=new Ct,de=new Ct,fe=new se,me=new It;class ge{constructor(t=0,e=0,i=0,n=ge.DefaultOrder){this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,r=n[0],o=n[4],s=n[8],a=n[1],l=n[5],c=n[9],u=n[2],h=n[6],p=n[10];switch(e){case"XYZ":this._y=Math.asin(ut(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,p),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(h,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ut(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(s,p),this._z=Math.atan2(a,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(ut(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-ut(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(h,p),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-o,l));break;case"YZX":this._z=Math.asin(ut(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(s,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(s,r)):(this._x=Math.atan2(-c,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return fe.makeRotationFromQuaternion(t),this.setFromRotationMatrix(fe,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return me.setFromEuler(this),this.setFromQuaternion(me,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 Ct(this._x,this._y,this._z)}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}}ge.prototype.isEuler=!0,ge.DefaultOrder="XYZ",ge.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class ye{constructor(){this.mask=1}set(t){this.mask=1<1){for(let t=0;t1){for(let t=0;t0){n.children=[];for(let e=0;e0){n.animations=[];for(let e=0;e0&&(i.geometries=e),n.length>0&&(i.materials=n),r.length>0&&(i.textures=r),s.length>0&&(i.images=s),a.length>0&&(i.shapes=a),l.length>0&&(i.skeletons=l),c.length>0&&(i.animations=c)}return i.object=n,i;function o(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}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;e0?n.multiplyScalar(1/Math.sqrt(r)):n.set(0,0,0)}static getBarycoord(t,e,i,n,r){De.subVectors(n,e),Re.subVectors(i,e),Oe.subVectors(t,e);const o=De.dot(De),s=De.dot(Re),a=De.dot(Oe),l=Re.dot(Re),c=Re.dot(Oe),u=o*l-s*s;if(0===u)return r.set(-2,-1,-1);const h=1/u,p=(l*a-s*c)*h,d=(o*c-s*a)*h;return r.set(1-p-d,d,p)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,ke),ke.x>=0&&ke.y>=0&&ke.x+ke.y<=1}static getUV(t,e,i,n,r,o,s,a){return this.getBarycoord(t,e,i,n,ke),a.set(0,0),a.addScaledVector(r,ke.x),a.addScaledVector(o,ke.y),a.addScaledVector(s,ke.z),a}static isFrontFacing(t,e,i,n){return De.subVectors(i,e),Re.subVectors(t,e),De.cross(Re).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),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 De.subVectors(this.c,this.b),Re.subVectors(this.a,this.b),.5*De.cross(Re).length()}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Ge.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Ge.getBarycoord(t,this.a,this.b,this.c,e)}getUV(t,e,i,n,r){return Ge.getUV(t,this.a,this.b,this.c,e,i,n,r)}containsPoint(t){return Ge.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Ge.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,r=this.c;let o,s;Ne.subVectors(n,i),Be.subVectors(r,i),Fe.subVectors(t,i);const a=Ne.dot(Fe),l=Be.dot(Fe);if(a<=0&&l<=0)return e.copy(i);Ve.subVectors(t,n);const c=Ne.dot(Ve),u=Be.dot(Ve);if(c>=0&&u<=c)return e.copy(n);const h=a*u-c*l;if(h<=0&&a>=0&&c<=0)return o=a/(a-c),e.copy(i).addScaledVector(Ne,o);Ue.subVectors(t,r);const p=Ne.dot(Ue),d=Be.dot(Ue);if(d>=0&&p<=d)return e.copy(r);const f=p*l-a*d;if(f<=0&&l>=0&&d<=0)return s=l/(l-d),e.copy(i).addScaledVector(Be,s);const m=c*d-p*u;if(m<=0&&u-c>=0&&p-d>=0)return ze.subVectors(r,n),s=(u-c)/(u-c+(p-d)),e.copy(n).addScaledVector(ze,s);const g=1/(m+f+h);return o=f*g,s=h*g,e.copy(i).addScaledVector(Ne,o).addScaledVector(Be,s)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}let je=0;class He extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:je++}),this.uuid=ct(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.format=M,this.transparent=!1,this.blendSrc=204,this.blendDst=205,this.blendEquation=i,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=tt,this.stencilZFail=tt,this.stencilZPass=tt,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 i=t[e];if(void 0===i){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===i;continue}const n=this[e];void 0!==n?n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i: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 i={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function n(t){const e=[];for(const i in t){const n=t[i];delete n.metadata,e.push(n)}return e}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),void 0!==this.roughness&&(i.roughness=this.roughness),void 0!==this.metalness&&(i.metalness=this.metalness),this.sheenTint&&this.sheenTint.isColor&&(i.sheenTint=this.sheenTint.getHex()),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(i.specularIntensity=this.specularIntensity),this.specularTint&&this.specularTint.isColor&&(i.specularTint=this.specularTint.getHex()),void 0!==this.shininess&&(i.shininess=this.shininess),void 0!==this.clearcoat&&(i.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularTintMap&&this.specularTintMap.isTexture&&(i.specularTintMap=this.specularTintMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,void 0!==this.combine&&(i.combine=this.combine)),void 0!==this.envMapIntensity&&(i.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(i.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),void 0!==this.transmission&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),void 0!==this.thickness&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),void 0!==this.attenuationDistance&&(i.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationTint&&(i.attenuationTint=this.attenuationTint.getHex()),void 0!==this.size&&(i.size=this.size),null!==this.shadowSide&&(i.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(i.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(i.blending=this.blending),0!==this.side&&(i.side=this.side),this.vertexColors&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.format!==M&&(i.format=this.format),!0===this.transparent&&(i.transparent=this.transparent),i.depthFunc=this.depthFunc,i.depthTest=this.depthTest,i.depthWrite=this.depthWrite,i.colorWrite=this.colorWrite,i.stencilWrite=this.stencilWrite,i.stencilWriteMask=this.stencilWriteMask,i.stencilFunc=this.stencilFunc,i.stencilRef=this.stencilRef,i.stencilFuncMask=this.stencilFuncMask,i.stencilFail=this.stencilFail,i.stencilZFail=this.stencilZFail,i.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(i.rotation=this.rotation),!0===this.polygonOffset&&(i.polygonOffset=!0),0!==this.polygonOffsetFactor&&(i.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(i.linewidth=this.linewidth),void 0!==this.dashSize&&(i.dashSize=this.dashSize),void 0!==this.gapSize&&(i.gapSize=this.gapSize),void 0!==this.scale&&(i.scale=this.scale),!0===this.dithering&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(i.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(i.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(i.wireframe=this.wireframe),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(i.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(i.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(i.flatShading=this.flatShading),!1===this.visible&&(i.visible=!1),!1===this.toneMapped&&(i.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(i.userData=this.userData),e){const e=n(t.textures),r=n(t.images);e.length>0&&(i.textures=e),r.length>0&&(i.images=r)}return i}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 i=null;if(null!==e){const t=e.length;i=new Array(t);for(let n=0;n!==t;++n)i[n]=e[n].clone()}return this.clippingPlanes=i,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++}}He.prototype.isMaterial=!0;const We={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},Xe={h:0,s:0,l:0};function Ze(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+6*(e-t)*(2/3-i):t}function Ye(t){return t<.04045?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function Qe(t){return t<.0031308?12.92*t:1.055*Math.pow(t,.41666)-.055}class Je{constructor(t,e,i){return void 0===e&&void 0===i?this.set(t):this.setRGB(t,e,i)}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,i){return this.r=t,this.g=e,this.b=i,this}setHSL(t,e,i){if(t=ht(t,1),e=ut(e,0,1),i=ut(i,0,1),0===e)this.r=this.g=this.b=i;else{const n=i<=.5?i*(1+e):i+e-i*e,r=2*i-n;this.r=Ze(r,n,t+1/3),this.g=Ze(r,n,t),this.b=Ze(r,n,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 i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(t)){let t;const n=i[1],r=i[2];switch(n){case"rgb":case"rgba":if(t=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))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(r))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(r)){const i=parseFloat(t[1])/360,n=parseInt(t[2],10)/100,r=parseInt(t[3],10)/100;return e(t[4]),this.setHSL(i,n,r)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const t=i[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=We[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 i=e>0?1/e:1;return this.r=Math.pow(t.r,i),this.g=Math.pow(t.g,i),this.b=Math.pow(t.b,i),this}convertGammaToLinear(t){return this.copyGammaToLinear(this,t),this}convertLinearToGamma(t){return this.copyLinearToGamma(this,t),this}copySRGBToLinear(t){return this.r=Ye(t.r),this.g=Ye(t.g),this.b=Ye(t.b),this}copyLinearToSRGB(t){return this.r=Qe(t.r),this.g=Qe(t.g),this.b=Qe(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,i=this.g,n=this.b,r=Math.max(e,i,n),o=Math.min(e,i,n);let s,a;const l=(o+r)/2;if(o===r)s=0,a=0;else{const t=r-o;switch(a=l<=.5?t/(r+o):t/(2-r-o),r){case e:s=(i-n)/t+(ie&&(e=t[i]);return e}const di={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function fi(t,e){return new di[t](e)}let mi=0;const gi=new se,yi=new Le,vi=new Ct,_i=new Dt,xi=new Dt,bi=new Ct;class wi extends rt{constructor(){super(),Object.defineProperty(this,"id",{value:mi++}),this.uuid=ct(),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(pi(t)>65535?li:si)(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,i=0){this.groups.push({start:t,count:e,materialIndex:i})}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 i=this.attributes.normal;if(void 0!==i){const e=(new vt).getNormalMatrix(t);i.applyNormalMatrix(e),i.needsUpdate=!0}const n=this.attributes.tangent;return void 0!==n&&(n.transformDirection(t),n.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(t){return gi.makeRotationFromQuaternion(t),this.applyMatrix4(gi),this}rotateX(t){return gi.makeRotationX(t),this.applyMatrix4(gi),this}rotateY(t){return gi.makeRotationY(t),this.applyMatrix4(gi),this}rotateZ(t){return gi.makeRotationZ(t),this.applyMatrix4(gi),this}translate(t,e,i){return gi.makeTranslation(t,e,i),this.applyMatrix4(gi),this}scale(t,e,i){return gi.makeScale(t,e,i),this.applyMatrix4(gi),this}lookAt(t){return yi.lookAt(t),yi.updateMatrix(),this.applyMatrix4(yi.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(vi).negate(),this.translate(vi.x,vi.y,vi.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i0&&(t.userData=this.userData),void 0!==this.parameters){const e=this.parameters;for(const i in e)void 0!==e[i]&&(t[i]=e[i]);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 i=this.attributes;for(const e in i){const n=i[e];t.data.attributes[e]=n.toJSON(t.data)}const n={};let r=!1;for(const e in this.morphAttributes){const i=this.morphAttributes[e],o=[];for(let e=0,n=i.length;e0&&(n[e]=o,r=!0)}r&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const s=this.boundingSphere;return null!==s&&(t.data.boundingSphere={center:s.center.toArray(),radius:s.radius}),t}clone(){return(new wi).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 i=t.index;null!==i&&this.setIndex(i.clone(e));const n=t.attributes;for(const t in n){const i=n[t];this.setAttribute(t,i.clone(e))}const r=t.morphAttributes;for(const t in r){const i=[],n=r[t];for(let t=0,r=n.length;t0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e0&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}}raycast(t,e){const i=this.geometry,n=this.material,r=this.matrixWorld;if(void 0===n)return;if(null===i.boundingSphere&&i.computeBoundingSphere(),Si.copy(i.boundingSphere),Si.applyMatrix4(r),!1===t.ray.intersectsSphere(Si))return;if(Ai.copy(r).invert(),Ei.copy(t.ray).applyMatrix4(Ai),null!==i.boundingBox&&!1===Ei.intersectsBox(i.boundingBox))return;let o;if(i.isBufferGeometry){const r=i.index,s=i.attributes.position,a=i.morphAttributes.position,l=i.morphTargetsRelative,c=i.attributes.uv,u=i.attributes.uv2,h=i.groups,p=i.drawRange;if(null!==r)if(Array.isArray(n))for(let i=0,d=h.length;ii.far?null:{distance:c,point:Fi.clone(),object:t}}(t,e,i,n,Mi,Ti,Ii,zi);if(d){a&&(ki.fromBufferAttribute(a,c),Ni.fromBufferAttribute(a,u),Bi.fromBufferAttribute(a,h),d.uv=Ge.getUV(zi,Mi,Ti,Ii,ki,Ni,Bi,new yt)),l&&(ki.fromBufferAttribute(l,c),Ni.fromBufferAttribute(l,u),Bi.fromBufferAttribute(l,h),d.uv2=Ge.getUV(zi,Mi,Ti,Ii,ki,Ni,Bi,new yt));const t={a:c,b:u,c:h,normal:new Ct,materialIndex:0};Ge.getNormal(Mi,Ti,Ii,t.normal),d.face=t}return d}Vi.prototype.isMesh=!0;class Gi extends wi{constructor(t=1,e=1,i=1,n=1,r=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:r,depthSegments:o};const s=this;n=Math.floor(n),r=Math.floor(r),o=Math.floor(o);const a=[],l=[],c=[],u=[];let h=0,p=0;function d(t,e,i,n,r,o,d,f,m,g,y){const v=o/m,_=d/g,x=o/2,b=d/2,w=f/2,A=m+1,E=g+1;let S=0,M=0;const T=new Ct;for(let o=0;o0?1:-1,c.push(T.x,T.y,T.z),u.push(a/m),u.push(1-o/g),S+=1}}for(let t=0;t0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader;const i={};for(const t in this.extensions)!0===this.extensions[t]&&(i[t]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}}qi.prototype.isShaderMaterial=!0;class Xi extends Le{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new se,this.projectionMatrix=new se,this.projectionMatrixInverse=new se}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)}}Xi.prototype.isCamera=!0;class Zi extends Xi{constructor(t=50,e=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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*lt*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(.5*at*this.fov);return.5*this.getFilmHeight()/t}getEffectiveFOV(){return 2*lt*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,i,n,r,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=i,this.view.offsetY=n,this.view.width=r,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,i=2*e,n=this.aspect*i,r=-.5*n;const o=this.view;if(null!==this.view&&this.view.enabled){const t=o.fullWidth,s=o.fullHeight;r+=o.offsetX*n/t,e-=o.offsetY*i/s,n*=o.width/t,i*=o.height/s}const s=this.filmOffset;0!==s&&(r+=t*s/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+n,e,e-i,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}}Zi.prototype.isPerspectiveCamera=!0;const Yi=90;class Qi extends Le{constructor(t,e,i){if(super(),this.type="CubeCamera",!0!==i.isWebGLCubeRenderTarget)return void console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=i;const n=new Zi(Yi,1,t,e);n.layers=this.layers,n.up.set(0,-1,0),n.lookAt(new Ct(1,0,0)),this.add(n);const r=new Zi(Yi,1,t,e);r.layers=this.layers,r.up.set(0,-1,0),r.lookAt(new Ct(-1,0,0)),this.add(r);const o=new Zi(Yi,1,t,e);o.layers=this.layers,o.up.set(0,0,1),o.lookAt(new Ct(0,1,0)),this.add(o);const s=new Zi(Yi,1,t,e);s.layers=this.layers,s.up.set(0,0,-1),s.lookAt(new Ct(0,-1,0)),this.add(s);const a=new Zi(Yi,1,t,e);a.layers=this.layers,a.up.set(0,-1,0),a.lookAt(new Ct(0,0,1)),this.add(a);const l=new Zi(Yi,1,t,e);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Ct(0,0,-1)),this.add(l)}update(t,e){null===this.parent&&this.updateMatrixWorld();const i=this.renderTarget,[n,r,o,s,a,l]=this.children,c=t.xr.enabled,u=t.getRenderTarget();t.xr.enabled=!1;const h=i.texture.generateMipmaps;i.texture.generateMipmaps=!1,t.setRenderTarget(i,0),t.render(e,n),t.setRenderTarget(i,1),t.render(e,r),t.setRenderTarget(i,2),t.render(e,o),t.setRenderTarget(i,3),t.render(e,s),t.setRenderTarget(i,4),t.render(e,a),i.texture.generateMipmaps=h,t.setRenderTarget(i,5),t.render(e,l),t.setRenderTarget(u),t.xr.enabled=c}}class Ji extends wt{constructor(t,e,i,n,o,s,a,l,c,u){super(t=void 0!==t?t:[],e=void 0!==e?e:r,i,n,o,s,a=void 0!==a?a:S,l,c,u),this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}Ji.prototype.isCubeTexture=!0;class Ki extends St{constructor(t,e,i){Number.isInteger(e)&&(console.warn("THREE.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget( size, options )"),e=i),super(t,t,e),e=e||{},this.texture=new Ji(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=M,this.texture.encoding=e.encoding,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const i={uniforms:{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 \n\t\t\t\t\t#include \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 \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"},n=new Gi(5,5,5),r=new qi({name:"CubemapFromEquirect",uniforms:ji(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:1,blending:0});r.uniforms.tEquirect.value=e;const o=new Vi(n,r),s=e.minFilter;return e.minFilter===v&&(e.minFilter=g),new Qi(1,10,this).update(t,o),e.minFilter=s,o.geometry.dispose(),o.material.dispose(),this}clear(t,e,i,n){const r=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(r)}}Ki.prototype.isWebGLCubeRenderTarget=!0;const $i=new Ct,tn=new Ct,en=new vt;class nn{constructor(t=new Ct(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,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=$i.subVectors(i,e).cross(tn.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,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 i=t.delta($i),n=this.normal.dot(i);if(0===n)return 0===this.distanceToPoint(t.start)?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:e.copy(i).multiplyScalar(r).add(t.start)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||en.getNormalMatrix(t),n=this.coplanarPoint($i).applyMatrix4(t),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),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)}}nn.prototype.isPlane=!0;const rn=new Jt,on=new Ct;class sn{constructor(t=new nn,e=new nn,i=new nn,n=new nn,r=new nn,o=new nn){this.planes=[t,e,i,n,r,o]}set(t,e,i,n,r,o){const s=this.planes;return s[0].copy(t),s[1].copy(e),s[2].copy(i),s[3].copy(n),s[4].copy(r),s[5].copy(o),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t){const e=this.planes,i=t.elements,n=i[0],r=i[1],o=i[2],s=i[3],a=i[4],l=i[5],c=i[6],u=i[7],h=i[8],p=i[9],d=i[10],f=i[11],m=i[12],g=i[13],y=i[14],v=i[15];return e[0].setComponents(s-n,u-a,f-h,v-m).normalize(),e[1].setComponents(s+n,u+a,f+h,v+m).normalize(),e[2].setComponents(s+r,u+l,f+p,v+g).normalize(),e[3].setComponents(s-r,u-l,f-p,v-g).normalize(),e[4].setComponents(s-o,u-c,f-d,v-y).normalize(),e[5].setComponents(s+o,u+c,f+d,v+y).normalize(),this}intersectsObject(t){const e=t.geometry;return null===e.boundingSphere&&e.computeBoundingSphere(),rn.copy(e.boundingSphere).applyMatrix4(t.matrixWorld),this.intersectsSphere(rn)}intersectsSprite(t){return rn.center.set(0,0,0),rn.radius=.7071067811865476,rn.applyMatrix4(t.matrixWorld),this.intersectsSphere(rn)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let t=0;t<6;t++)if(e[t].distanceToPoint(i)0?t.max.x:t.min.x,on.y=n.normal.y>0?t.max.y:t.min.y,on.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(on)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function an(){let t=null,e=!1,i=null,n=null;function r(e,o){i(e,o),n=t.requestAnimationFrame(r)}return{start:function(){!0!==e&&null!==i&&(n=t.requestAnimationFrame(r),e=!0)},stop:function(){t.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(t){i=t},setContext:function(e){t=e}}}function ln(t,e){const i=e.isWebGL2,n=new WeakMap;return{get:function(t){return t.isInterleavedBufferAttribute&&(t=t.data),n.get(t)},remove:function(e){e.isInterleavedBufferAttribute&&(e=e.data);const i=n.get(e);i&&(t.deleteBuffer(i.buffer),n.delete(e))},update:function(e,r){if(e.isGLBufferAttribute){const t=n.get(e);return void((!t||t.version 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 \n\t#include \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 \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\t#include \n\t#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec2 vHighPrecisionZW;\nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvHighPrecisionZW = gl_Position.zw;\n}",distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main () {\n\t#include \n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvWorldPosition = worldPosition.xyz;\n}",equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include \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 \n\t#include \n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include \n\t#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tvLineDistance = scale * lineDistance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \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 \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n\tvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n\tvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \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 \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \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 \n\t#include \n\t#include \n\t#include \n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include \n\t#include \n\t#include \n}",shadow_vert:"#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\t#include \n\t#include \n\t#include \n\t#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \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 \n\t#include \n\t#include \n}"},hn={common:{diffuse:{value:new Je(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new vt},uv2Transform:{value:new vt},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 yt(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 vt}},sprite:{diffuse:{value:new Je(16777215)},opacity:{value:1},center:{value:new yt(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new vt}}},pn={basic:{uniforms:Hi([hn.common,hn.specularmap,hn.envmap,hn.aomap,hn.lightmap,hn.fog]),vertexShader:un.meshbasic_vert,fragmentShader:un.meshbasic_frag},lambert:{uniforms:Hi([hn.common,hn.specularmap,hn.envmap,hn.aomap,hn.lightmap,hn.emissivemap,hn.fog,hn.lights,{emissive:{value:new Je(0)}}]),vertexShader:un.meshlambert_vert,fragmentShader:un.meshlambert_frag},phong:{uniforms:Hi([hn.common,hn.specularmap,hn.envmap,hn.aomap,hn.lightmap,hn.emissivemap,hn.bumpmap,hn.normalmap,hn.displacementmap,hn.fog,hn.lights,{emissive:{value:new Je(0)},specular:{value:new Je(1118481)},shininess:{value:30}}]),vertexShader:un.meshphong_vert,fragmentShader:un.meshphong_frag},standard:{uniforms:Hi([hn.common,hn.envmap,hn.aomap,hn.lightmap,hn.emissivemap,hn.bumpmap,hn.normalmap,hn.displacementmap,hn.roughnessmap,hn.metalnessmap,hn.fog,hn.lights,{emissive:{value:new Je(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:un.meshphysical_vert,fragmentShader:un.meshphysical_frag},toon:{uniforms:Hi([hn.common,hn.aomap,hn.lightmap,hn.emissivemap,hn.bumpmap,hn.normalmap,hn.displacementmap,hn.gradientmap,hn.fog,hn.lights,{emissive:{value:new Je(0)}}]),vertexShader:un.meshtoon_vert,fragmentShader:un.meshtoon_frag},matcap:{uniforms:Hi([hn.common,hn.bumpmap,hn.normalmap,hn.displacementmap,hn.fog,{matcap:{value:null}}]),vertexShader:un.meshmatcap_vert,fragmentShader:un.meshmatcap_frag},points:{uniforms:Hi([hn.points,hn.fog]),vertexShader:un.points_vert,fragmentShader:un.points_frag},dashed:{uniforms:Hi([hn.common,hn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:un.linedashed_vert,fragmentShader:un.linedashed_frag},depth:{uniforms:Hi([hn.common,hn.displacementmap]),vertexShader:un.depth_vert,fragmentShader:un.depth_frag},normal:{uniforms:Hi([hn.common,hn.bumpmap,hn.normalmap,hn.displacementmap,{opacity:{value:1}}]),vertexShader:un.meshnormal_vert,fragmentShader:un.meshnormal_frag},sprite:{uniforms:Hi([hn.sprite,hn.fog]),vertexShader:un.sprite_vert,fragmentShader:un.sprite_frag},background:{uniforms:{uvTransform:{value:new vt},t2D:{value:null}},vertexShader:un.background_vert,fragmentShader:un.background_frag},cube:{uniforms:Hi([hn.envmap,{opacity:{value:1}}]),vertexShader:un.cube_vert,fragmentShader:un.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:un.equirect_vert,fragmentShader:un.equirect_frag},distanceRGBA:{uniforms:Hi([hn.common,hn.displacementmap,{referencePosition:{value:new Ct},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:un.distanceRGBA_vert,fragmentShader:un.distanceRGBA_frag},shadow:{uniforms:Hi([hn.lights,hn.fog,{color:{value:new Je(0)},opacity:{value:1}}]),vertexShader:un.shadow_vert,fragmentShader:un.shadow_frag}};function dn(t,e,i,n,r){const o=new Je(0);let s,a,c=0,u=null,h=0,p=null;function d(t,e){i.buffers.color.setClear(t.r,t.g,t.b,e,r)}return{getClearColor:function(){return o},setClearColor:function(t,e=1){o.set(t),c=e,d(o,c)},getClearAlpha:function(){return c},setClearAlpha:function(t){c=t,d(o,c)},render:function(i,r){let f=!1,m=!0===r.isScene?r.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?d(o,c):m&&m.isColor&&(d(m,1),f=!0),(t.autoClear||f)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),m&&(m.isCubeTexture||m.mapping===l)?(void 0===a&&(a=new Vi(new Gi(1,1,1),new qi({name:"BackgroundCubeMaterial",uniforms:ji(pn.cube.uniforms),vertexShader:pn.cube.vertexShader,fragmentShader:pn.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),a.geometry.deleteAttribute("normal"),a.geometry.deleteAttribute("uv"),a.onBeforeRender=function(t,e,i){this.matrixWorld.copyPosition(i.matrixWorld)},Object.defineProperty(a.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(a)),a.material.uniforms.envMap.value=m,a.material.uniforms.flipEnvMap.value=m.isCubeTexture&&!1===m.isRenderTargetTexture?-1:1,u===m&&h===m.version&&p===t.toneMapping||(a.material.needsUpdate=!0,u=m,h=m.version,p=t.toneMapping),i.unshift(a,a.geometry,a.material,0,0,null)):m&&m.isTexture&&(void 0===s&&(s=new Vi(new cn(2,2),new qi({name:"BackgroundMaterial",uniforms:ji(pn.background.uniforms),vertexShader:pn.background.vertexShader,fragmentShader:pn.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(s)),s.material.uniforms.t2D.value=m,!0===m.matrixAutoUpdate&&m.updateMatrix(),s.material.uniforms.uvTransform.value.copy(m.matrix),u===m&&h===m.version&&p===t.toneMapping||(s.material.needsUpdate=!0,u=m,h=m.version,p=t.toneMapping),i.unshift(s,s.geometry,s.material,0,0,null))}}}function fn(t,e,i,n){const r=t.getParameter(34921),o=n.isWebGL2?null:e.get("OES_vertex_array_object"),s=n.isWebGL2||null!==o,a={},l=p(null);let c=l;function u(e){return n.isWebGL2?t.bindVertexArray(e):o.bindVertexArrayOES(e)}function h(e){return n.isWebGL2?t.deleteVertexArray(e):o.deleteVertexArrayOES(e)}function p(t){const e=[],i=[],n=[];for(let t=0;t=0){let o=l[e];if(void 0===o&&("instanceMatrix"===e&&r.instanceMatrix&&(o=r.instanceMatrix),"instanceColor"===e&&r.instanceColor&&(o=r.instanceColor)),void 0!==o){const e=o.normalized,s=o.itemSize,l=i.get(o);if(void 0===l)continue;const c=l.buffer,u=l.type,h=l.bytesPerElement;if(o.isInterleavedBufferAttribute){const i=o.data,l=i.stride,p=o.offset;if(i&&i.isInstancedInterleavedBuffer){for(let t=0;t0&&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 s=void 0!==i.precision?i.precision:"highp";const a=r(s);a!==s&&(console.warn("THREE.WebGLRenderer:",s,"not supported, using",a,"instead."),s=a);const l=o||e.has("WEBGL_draw_buffers"),c=!0===i.logarithmicDepthBuffer,u=t.getParameter(34930),h=t.getParameter(35660),p=t.getParameter(3379),d=t.getParameter(34076),f=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!==n)return n;if(!0===e.has("EXT_texture_filter_anisotropic")){const i=e.get("EXT_texture_filter_anisotropic");n=t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n},getMaxPrecision:r,precision:s,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:h,maxTextureSize:p,maxCubemapSize:d,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:y,vertexTextures:v,floatFragmentTextures:_,floatVertexTextures:v&&_,maxSamples:o?t.getParameter(36183):0}}function yn(t){const e=this;let i=null,n=0,r=!1,o=!1;const s=new nn,a=new vt,l={value:null,needsUpdate:!1};function c(){l.value!==i&&(l.value=i,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function u(t,i,n,r){const o=null!==t?t.length:0;let c=null;if(0!==o){if(c=l.value,!0!==r||null===c){const e=n+4*o,r=i.matrixWorldInverse;a.getNormalMatrix(r),(null===c||c.length0){const s=t.getRenderTarget(),a=new Ki(o.height/2);return a.fromEquirectangularTexture(t,r),e.set(r,a),t.setRenderTarget(s),r.addEventListener("dispose",n),i(a.texture,r.mapping)}return null}}}return r},dispose:function(){e=new WeakMap}}}pn.physical={uniforms:Hi([pn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new yt(1,1)},clearcoatNormalMap:{value:null},sheenTint:{value:new Je(0)},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new yt},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:un.meshphysical_vert,fragmentShader:un.meshphysical_frag};class _n extends Xi{constructor(t=-1,e=1,i=1,n=-1,r=.1,o=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=r,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,i,n,r,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=i,this.view.offsetY=n,this.view.width=r,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),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let r=i-t,o=i+t,s=n+e,a=n-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;r+=t*this.view.offsetX,o=r+t*this.view.width,s-=e*this.view.offsetY,a=s-e*this.view.height}this.projectionMatrix.makeOrthographic(r,o,s,a,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}}_n.prototype.isOrthographicCamera=!0;class xn extends qi{constructor(t){super(t),this.type="RawShaderMaterial"}}xn.prototype.isRawShaderMaterial=!0;const bn=Math.pow(2,8),wn=[.125,.215,.35,.446,.526,.582],An=5+wn.length,En=20,Sn={[X]:0,[Z]:1,[Q]:2,[J]:3,[K]:4,[$]:5,[Y]:6},Mn=new _n,{_lodPlanes:Tn,_sizeLods:In,_sigmas:Cn}=Bn(),Pn=new Je;let Ln=null;const Dn=(1+Math.sqrt(5))/2,Rn=1/Dn,On=[new Ct(1,1,1),new Ct(-1,1,1),new Ct(1,1,-1),new Ct(-1,1,-1),new Ct(0,Dn,Rn),new Ct(0,Dn,-Rn),new Ct(Rn,0,Dn),new Ct(-Rn,0,Dn),new Ct(Dn,Rn,0),new Ct(-Dn,Rn,0)];class kn{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._blurMaterial=function(t){const e=new Float32Array(t),i=new Ct(0,1,0);return new xn({name:"SphericalGaussianBlur",defines:{n:t},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:e},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i},inputEncoding:{value:Sn[3e3]},outputEncoding:{value:Sn[3e3]}},vertexShader:Gn(),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${jn()}\n\n\t\t\t#define ENVMAP_TYPE_CUBE_UV\n\t\t\t#include \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})}(En),this._equirectShader=null,this._cubemapShader=null,this._compileMaterial(this._blurMaterial)}fromScene(t,e=0,i=.1,n=100){Ln=this._renderer.getRenderTarget();const r=this._allocateTargets();return this._sceneToCubeUV(t,i,n,r),e>0&&this._blur(r,0,0,e),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(t){return this._fromTexture(t)}fromCubemap(t){return this._fromTexture(t)}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=Un(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=Vn(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let t=0;t2?bn:0,bn,bn),a.setRenderTarget(n),d&&a.render(p,r),a.render(t,r)}p.geometry.dispose(),p.material.dispose(),a.toneMapping=u,a.outputEncoding=c,a.autoClear=l,t.background=f}_textureToCubeUV(t,e){const i=this._renderer;t.isCubeTexture?null==this._cubemapShader&&(this._cubemapShader=Un()):null==this._equirectShader&&(this._equirectShader=Vn());const n=t.isCubeTexture?this._cubemapShader:this._equirectShader,r=new Vi(Tn[0],n),o=n.uniforms;o.envMap.value=t,t.isCubeTexture||o.texelSize.value.set(1/t.image.width,1/t.image.height),o.inputEncoding.value=Sn[t.encoding],o.outputEncoding.value=Sn[e.texture.encoding],Fn(e,0,0,3*bn,2*bn),i.setRenderTarget(e),i.render(r,Mn)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;for(let e=1;eEn&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${f} samples when the maximum is set to 20`);const m=[];let g=0;for(let t=0;t4?n-8+4:0),3*y,2*y),a.setRenderTarget(e),a.render(c,Mn)}}function Nn(t){return void 0!==t&&t.type===_&&(t.encoding===X||t.encoding===Z||t.encoding===Y)}function Bn(){const t=[],e=[],i=[];let n=8;for(let r=0;r4?s=wn[r-8+4-1]:0==r&&(s=0),i.push(s);const a=1/(o-1),l=-a/2,c=1+a/2,u=[l,l,c,l,c,c,l,l,c,c,l,c],h=6,p=6,d=3,f=2,m=1,g=new Float32Array(d*p*h),y=new Float32Array(f*p*h),v=new Float32Array(m*p*h);for(let t=0;t2?0:-1,n=[e,i,0,e+2/3,i,0,e+2/3,i+1,0,e,i,0,e+2/3,i+1,0,e,i+1,0];g.set(n,d*p*t),y.set(u,f*p*t);const r=[t,t,t,t,t,t];v.set(r,m*p*t)}const _=new wi;_.setAttribute("position",new ei(g,d)),_.setAttribute("uv",new ei(y,f)),_.setAttribute("faceIndex",new ei(v,m)),t.push(_),n>4&&n--}return{_lodPlanes:t,_sizeLods:e,_sigmas:i}}function zn(t){const e=new St(3*bn,3*bn,t);return e.texture.mapping=l,e.texture.name="PMREM.cubeUv",e.scissorTest=!0,e}function Fn(t,e,i,n,r){t.viewport.set(e,i,n,r),t.scissor.set(e,i,n,r)}function Vn(){const t=new yt(1,1);return new xn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:t},inputEncoding:{value:Sn[3e3]},outputEncoding:{value:Sn[3e3]}},vertexShader:Gn(),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${jn()}\n\n\t\t\t#include \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 Un(){return new xn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},inputEncoding:{value:Sn[3e3]},outputEncoding:{value:Sn[3e3]}},vertexShader:Gn(),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${jn()}\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 Gn(){return"\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"}function jn(){return"\n\n\t\tuniform int inputEncoding;\n\t\tuniform int outputEncoding;\n\n\t\t#include \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"}function Hn(t){let e=new WeakMap,i=null;function n(t){const i=t.target;i.removeEventListener("dispose",n);const r=e.get(i);void 0!==r&&(e.delete(i),r.dispose())}return{get:function(l){if(l&&l.isTexture&&!1===l.isRenderTargetTexture){const c=l.mapping,u=c===s||c===a,h=c===r||c===o;if(u||h){if(e.has(l))return e.get(l).texture;{const r=l.image;if(u&&r&&r.height>0||h&&r&&function(t){let e=0;const i=6;for(let n=0;n65535?li:si)(i,1);a.version=s;const l=o.get(t);l&&e.remove(l),o.set(t,a)}return{get:function(t,e){return!0===r[e.id]||(e.addEventListener("dispose",s),r[e.id]=!0,i.memory.geometries++),e},update:function(t){const i=t.attributes;for(const t in i)e.update(i[t],34962);const n=t.morphAttributes;for(const t in n){const i=n[t];for(let t=0,n=i.length;t0)return t;const r=e*i;let o=or[r];if(void 0===o&&(o=new Float32Array(r),or[r]=o),0!==e){n.toArray(o,0);for(let n=1,r=0;n!==e;++n)r+=i,t[n].toArray(o,r)}return o}function hr(t,e){if(t.length!==e.length)return!1;for(let i=0,n=t.length;i/gm;function mo(t){return t.replace(fo,go)}function go(t,e){const i=un[e];if(void 0===i)throw new Error("Can not resolve #include <"+e+">");return mo(i)}const yo=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,vo=/#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 _o(t){return t.replace(vo,bo).replace(yo,xo)}function xo(t,e,i,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),bo(t,e,i,n)}function bo(t,e,i,n){let r="";for(let t=parseInt(e);t0?t.gammaFactor:1,y=i.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(uo).join("\n")}(i),v=function(t){const e=[];for(const i in t){const n=t[i];!1!==n&&e.push("#define "+i+" "+n)}return e.join("\n")}(a),_=s.createProgram();let x,b,w=i.glslVersion?"#version "+i.glslVersion+"\n":"";i.isRawShaderMaterial?(x=[v].filter(uo).join("\n"),x.length>0&&(x+="\n"),b=[y,v].filter(uo).join("\n"),b.length>0&&(b+="\n")):(x=[wo(i),"#define SHADER_NAME "+i.shaderName,v,i.instancing?"#define USE_INSTANCING":"",i.instancingColor?"#define USE_INSTANCING_COLOR":"",i.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+g,"#define MAX_BONES "+i.maxBones,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+f:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.displacementMap&&i.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularTintMap?"#define USE_SPECULARTINTMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.flatShading?"#define FLAT_SHADED":"",i.skinning?"#define USE_SKINNING":"",i.useVertexTexture?"#define BONE_TEXTURE":"",i.morphTargets?"#define USE_MORPHTARGETS":"",i.morphNormals&&!1===i.flatShading?"#define USE_MORPHNORMALS":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+p:"",i.sizeAttenuation?"#define USE_SIZEATTENUATION":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.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(uo).join("\n"),b=[y,wo(i),"#define SHADER_NAME "+i.shaderName,v,"#define GAMMA_FACTOR "+g,i.useFog&&i.fog?"#define USE_FOG":"",i.useFog&&i.fogExp2?"#define FOG_EXP2":"",i.map?"#define USE_MAP":"",i.matcap?"#define USE_MATCAP":"",i.envMap?"#define USE_ENVMAP":"",i.envMap?"#define "+d:"",i.envMap?"#define "+f:"",i.envMap?"#define "+m:"",i.lightMap?"#define USE_LIGHTMAP":"",i.aoMap?"#define USE_AOMAP":"",i.emissiveMap?"#define USE_EMISSIVEMAP":"",i.bumpMap?"#define USE_BUMPMAP":"",i.normalMap?"#define USE_NORMALMAP":"",i.normalMap&&i.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",i.normalMap&&i.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",i.clearcoat?"#define USE_CLEARCOAT":"",i.clearcoatMap?"#define USE_CLEARCOATMAP":"",i.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",i.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",i.specularMap?"#define USE_SPECULARMAP":"",i.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",i.specularTintMap?"#define USE_SPECULARTINTMAP":"",i.roughnessMap?"#define USE_ROUGHNESSMAP":"",i.metalnessMap?"#define USE_METALNESSMAP":"",i.alphaMap?"#define USE_ALPHAMAP":"",i.alphaTest?"#define USE_ALPHATEST":"",i.sheenTint?"#define USE_SHEEN":"",i.transmission?"#define USE_TRANSMISSION":"",i.transmissionMap?"#define USE_TRANSMISSIONMAP":"",i.thicknessMap?"#define USE_THICKNESSMAP":"",i.vertexTangents?"#define USE_TANGENT":"",i.vertexColors||i.instancingColor?"#define USE_COLOR":"",i.vertexAlphas?"#define USE_COLOR_ALPHA":"",i.vertexUvs?"#define USE_UV":"",i.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",i.gradientMap?"#define USE_GRADIENTMAP":"",i.flatShading?"#define FLAT_SHADED":"",i.doubleSided?"#define DOUBLE_SIDED":"",i.flipSided?"#define FLIP_SIDED":"",i.shadowMapEnabled?"#define USE_SHADOWMAP":"",i.shadowMapEnabled?"#define "+p:"",i.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",i.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",i.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",i.logarithmicDepthBuffer&&i.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(i.extensionShaderTextureLOD||i.envMap)&&i.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0!==i.toneMapping?"#define TONE_MAPPING":"",0!==i.toneMapping?un.tonemapping_pars_fragment:"",0!==i.toneMapping?co("toneMapping",i.toneMapping):"",i.dithering?"#define DITHERING":"",i.format===S?"#define OPAQUE":"",un.encodings_pars_fragment,i.map?ao("mapTexelToLinear",i.mapEncoding):"",i.matcap?ao("matcapTexelToLinear",i.matcapEncoding):"",i.envMap?ao("envMapTexelToLinear",i.envMapEncoding):"",i.emissiveMap?ao("emissiveMapTexelToLinear",i.emissiveMapEncoding):"",i.specularTintMap?ao("specularTintMapTexelToLinear",i.specularTintMapEncoding):"",i.lightMap?ao("lightMapTexelToLinear",i.lightMapEncoding):"",lo("linearToOutputTexel",i.outputEncoding),i.depthPacking?"#define DEPTH_PACKING "+i.depthPacking:"","\n"].filter(uo).join("\n")),u=mo(u),u=ho(u,i),u=po(u,i),h=mo(h),h=ho(h,i),h=po(h,i),u=_o(u),h=_o(h),i.isWebGL2&&!0!==i.isRawShaderMaterial&&(w="#version 300 es\n",x=["#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+x,b=["#define varying in",i.glslVersion===nt?"":"out highp vec4 pc_fragColor;",i.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 A=w+b+h,E=no(s,35633,w+x+u),M=no(s,35632,A);if(s.attachShader(_,E),s.attachShader(_,M),void 0!==i.index0AttributeName?s.bindAttribLocation(_,0,i.index0AttributeName):!0===i.morphTargets&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_),t.debug.checkShaderErrors){const t=s.getProgramInfoLog(_).trim(),e=s.getShaderInfoLog(E).trim(),i=s.getShaderInfoLog(M).trim();let n=!0,r=!0;if(!1===s.getProgramParameter(_,35714)){n=!1;const e=so(s,E,"vertex"),i=so(s,M,"fragment");console.error("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,35715)+"\n\nProgram Info Log: "+t+"\n"+e+"\n"+i)}else""!==t?console.warn("THREE.WebGLProgram: Program Info Log:",t):""!==e&&""!==i||(r=!1);r&&(this.diagnostics={runnable:n,programLog:t,vertexShader:{log:e,prefix:x},fragmentShader:{log:i,prefix:b}})}let T,I;return s.deleteShader(E),s.deleteShader(M),this.getUniforms=function(){return void 0===T&&(T=new io(s,_)),T},this.getAttributes=function(){return void 0===I&&(I=function(t,e){const i={},n=t.getProgramParameter(e,35721);for(let r=0;r0,P=o.clearcoat>0;return{isWebGL2:u,shaderID:E,shaderName:o.type,vertexShader:M,fragmentShader:T,defines:o.defines,isRawShaderMaterial:!0===o.isRawShaderMaterial,glslVersion:o.glslVersion,precision:m,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:f,outputEncoding:null!==I?v(I.texture):t.outputEncoding,map:!!o.map,mapEncoding:v(o.map),matcap:!!o.matcap,matcapEncoding:v(o.matcap),envMap:!!A,envMapMode:A&&A.mapping,envMapEncoding:v(A),envMapCubeUV:!!A&&(A.mapping===l||A.mapping===c),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:P,clearcoatMap:P&&!!o.clearcoatMap,clearcoatRoughnessMap:P&&!!o.clearcoatRoughnessMap,clearcoatNormalMap:P&&!!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:C,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&&S>0,maxBones:S,useVertexTexture:p,morphTargets:!!x.geometry&&!!x.geometry.morphAttributes.position,morphNormals:!!x.geometry&&!!x.geometry.morphAttributes.normal,numDirLights:a.directional.length,numPointLights:a.point.length,numSpotLights:a.spot.length,numRectAreaLights:a.rectArea.length,numHemiLights:a.hemi.length,numDirLightShadows:a.directionalShadowMap.length,numPointLightShadows:a.pointShadowMap.length,numSpotLightShadows:a.spotShadowMap.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.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:u||n.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||n.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||n.has("EXT_shader_texture_lod"),customProgramCacheKey:o.customProgramCacheKey()}},getProgramCacheKey:function(e){const i=[];if(e.shaderID?i.push(e.shaderID):(i.push(e.fragmentShader),i.push(e.vertexShader)),void 0!==e.defines)for(const t in e.defines)i.push(t),i.push(e.defines[t]);if(!1===e.isRawShaderMaterial){for(let t=0;t0?r.push(u):!0===i.transparent?o.push(u):n.push(u)},unshift:function(t,e,i,s,l,c){const u=a(t,e,i,s,l,c);i.transmission>0?r.unshift(u):!0===i.transparent?o.unshift(u):n.unshift(u)},finish:function(){for(let t=i,n=e.length;t1&&n.sort(t||Mo),r.length>1&&r.sort(e||To),o.length>1&&o.sort(e||To)}}}function Co(t){let e=new WeakMap;return{get:function(i,n){let r;return!1===e.has(i)?(r=new Io(t),e.set(i,[r])):n>=e.get(i).length?(r=new Io(t),e.get(i).push(r)):r=e.get(i)[n],r},dispose:function(){e=new WeakMap}}}function Po(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":i={direction:new Ct,color:new Je};break;case"SpotLight":i={position:new Ct,direction:new Ct,color:new Je,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":i={position:new Ct,color:new Je,distance:0,decay:0};break;case"HemisphereLight":i={direction:new Ct,skyColor:new Je,groundColor:new Je};break;case"RectAreaLight":i={color:new Je,position:new Ct,halfWidth:new Ct,halfHeight:new Ct}}return t[e.id]=i,i}}}let Lo=0;function Do(t,e){return(e.castShadow?1:0)-(t.castShadow?1:0)}function Ro(t,e){const i=new Po,n=function(){const t={};return{get:function(e){if(void 0!==t[e.id])return t[e.id];let i;switch(e.type){case"DirectionalLight":case"SpotLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yt};break;case"PointLight":i={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yt,shadowCameraNear:1,shadowCameraFar:1e3}}return t[e.id]=i,i}}}(),r={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++)r.probe.push(new Ct);const o=new Ct,s=new se,a=new se;return{setup:function(o,s){let a=0,l=0,c=0;for(let t=0;t<9;t++)r.probe[t].set(0,0,0);let u=0,h=0,p=0,d=0,f=0,m=0,g=0,y=0;o.sort(Do);const v=!0!==s?Math.PI:1;for(let t=0,e=o.length;t0&&(e.isWebGL2||!0===t.has("OES_texture_float_linear")?(r.rectAreaLTC1=hn.LTC_FLOAT_1,r.rectAreaLTC2=hn.LTC_FLOAT_2):!0===t.has("OES_texture_half_float_linear")?(r.rectAreaLTC1=hn.LTC_HALF_1,r.rectAreaLTC2=hn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),r.ambient[0]=a,r.ambient[1]=l,r.ambient[2]=c;const _=r.hash;_.directionalLength===u&&_.pointLength===h&&_.spotLength===p&&_.rectAreaLength===d&&_.hemiLength===f&&_.numDirectionalShadows===m&&_.numPointShadows===g&&_.numSpotShadows===y||(r.directional.length=u,r.spot.length=p,r.rectArea.length=d,r.point.length=h,r.hemi.length=f,r.directionalShadow.length=m,r.directionalShadowMap.length=m,r.pointShadow.length=g,r.pointShadowMap.length=g,r.spotShadow.length=y,r.spotShadowMap.length=y,r.directionalShadowMatrix.length=m,r.pointShadowMatrix.length=g,r.spotShadowMatrix.length=y,_.directionalLength=u,_.pointLength=h,_.spotLength=p,_.rectAreaLength=d,_.hemiLength=f,_.numDirectionalShadows=m,_.numPointShadows=g,_.numSpotShadows=y,r.version=Lo++)},setupView:function(t,e){let i=0,n=0,l=0,c=0,u=0;const h=e.matrixWorldInverse;for(let e=0,p=t.length;e=i.get(n).length?(o=new Oo(t,e),i.get(n).push(o)):o=i.get(n)[r],o},dispose:function(){i=new WeakMap}}}class No extends He{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}}No.prototype.isMeshDepthMaterial=!0;class Bo extends He{constructor(t){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Ct,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 zo(t,e,i){let n=new sn;const r=new yt,o=new yt,s=new Et,a=new No({depthPacking:3201}),l=new Bo,c={},u=i.maxTextureSize,h={0:1,1:0,2:2},p=new qi({uniforms:{shadow_pass:{value:null},resolution:{value:new yt},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 \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}"}),f=p.clone();f.defines.HORIZONTAL_PASS=1;const m=new wi;m.setAttribute("position",new ei(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Vi(m,p),v=this;function _(i,n){const r=e.update(y);p.uniforms.shadow_pass.value=i.map.texture,p.uniforms.resolution.value=i.mapSize,p.uniforms.radius.value=i.radius,p.uniforms.samples.value=i.blurSamples,t.setRenderTarget(i.mapPass),t.clear(),t.renderBufferDirect(n,null,r,p,y,null),f.uniforms.shadow_pass.value=i.mapPass.texture,f.uniforms.resolution.value=i.mapSize,f.uniforms.radius.value=i.radius,f.uniforms.samples.value=i.blurSamples,t.setRenderTarget(i.map),t.clear(),t.renderBufferDirect(n,null,r,f,y,null)}function x(e,i,n,r,o,s,u){let p=null;const d=!0===r.isPointLight?e.customDistanceMaterial:e.customDepthMaterial;if(p=void 0!==d?d:!0===r.isPointLight?l:a,t.localClippingEnabled&&!0===n.clipShadows&&0!==n.clippingPlanes.length||n.displacementMap&&0!==n.displacementScale||n.alphaMap&&n.alphaTest>0){const t=p.uuid,e=n.uuid;let i=c[t];void 0===i&&(i={},c[t]=i);let r=i[e];void 0===r&&(r=p.clone(),i[e]=r),p=r}return p.visible=n.visible,p.wireframe=n.wireframe,p.side=3===u?null!==n.shadowSide?n.shadowSide:n.side:null!==n.shadowSide?n.shadowSide:h[n.side],p.alphaMap=n.alphaMap,p.alphaTest=n.alphaTest,p.clipShadows=n.clipShadows,p.clippingPlanes=n.clippingPlanes,p.clipIntersection=n.clipIntersection,p.displacementMap=n.displacementMap,p.displacementScale=n.displacementScale,p.displacementBias=n.displacementBias,p.wireframeLinewidth=n.wireframeLinewidth,p.linewidth=n.linewidth,!0===r.isPointLight&&!0===p.isMeshDistanceMaterial&&(p.referencePosition.setFromMatrixPosition(r.matrixWorld),p.nearDistance=o,p.farDistance=s),p}function b(i,r,o,s,a){if(!1===i.visible)return;if(i.layers.test(r.layers)&&(i.isMesh||i.isLine||i.isPoints)&&(i.castShadow||i.receiveShadow&&3===a)&&(!i.frustumCulled||n.intersectsObject(i))){i.modelViewMatrix.multiplyMatrices(o.matrixWorldInverse,i.matrixWorld);const n=e.update(i),r=i.material;if(Array.isArray(r)){const e=n.groups;for(let l=0,c=e.length;lu||r.y>u)&&(r.x>u&&(o.x=Math.floor(u/f.x),r.x=o.x*f.x,h.mapSize.x=o.x),r.y>u&&(o.y=Math.floor(u/f.y),r.y=o.y*f.y,h.mapSize.y=o.y)),null===h.map&&!h.isPointLightShadow&&3===this.type){const t={minFilter:g,magFilter:g,format:M};h.map=new St(r.x,r.y,t),h.map.texture.name=c.name+".shadowMap",h.mapPass=new St(r.x,r.y,t),h.camera.updateProjectionMatrix()}if(null===h.map){const t={minFilter:d,magFilter:d,format:M};h.map=new St(r.x,r.y,t),h.map.texture.name=c.name+".shadowMap",h.camera.updateProjectionMatrix()}t.setRenderTarget(h.map),t.clear();const m=h.getViewportCount();for(let t=0;t=1):-1!==C.indexOf("OpenGL ES")&&(I=parseFloat(/^OpenGL ES (\d)/.exec(C)[1]),T=I>=2);let P=null,L={};const D=t.getParameter(3088),R=t.getParameter(2978),O=(new Et).fromArray(D),k=(new Et).fromArray(R);function N(e,i,n){const r=new Uint8Array(4),o=t.createTexture();t.bindTexture(e,o),t.texParameteri(e,10241,9728),t.texParameteri(e,10240,9728);for(let e=0;en||t.height>n)&&(r=n/Math.max(t.width,t.height)),r<1||!0===e){if("undefined"!=typeof HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap){const n=e?mt:Math.floor,o=n(r*t.width),s=n(r*t.height);void 0===L&&(L=R(o,s));const a=i?R(o,s):L;return a.width=o,a.height=s,a.getContext("2d").drawImage(t,0,0,o,s),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+t.width+"x"+t.height+") to ("+o+"x"+s+")."),a}return"data"in t&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+t.width+"x"+t.height+")."),t}return t}function k(t){return dt(t.width)&&dt(t.height)}function N(t,e){return t.generateMipmaps&&e&&t.minFilter!==d&&t.minFilter!==g}function B(e,i,r,o,s=1){t.generateMipmap(e),n.get(i).__maxMipLevel=Math.log2(Math.max(r,o,s))}function z(i,n,r){if(!1===a)return n;if(null!==i){if(void 0!==t[i])return t[i];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+i+"'")}let o=n;return 6403===n&&(5126===r&&(o=33326),5131===r&&(o=33325),5121===r&&(o=33321)),6407===n&&(5126===r&&(o=34837),5131===r&&(o=34843),5121===r&&(o=32849)),6408===n&&(5126===r&&(o=34836),5131===r&&(o=34842),5121===r&&(o=32856)),33325!==o&&33326!==o&&34842!==o&&34836!==o||e.get("EXT_color_buffer_float"),o}function F(t){return t===d||t===f||t===m?9728:9729}function V(e){const i=e.target;i.removeEventListener("dispose",V),function(e){const i=n.get(e);void 0!==i.__webglInit&&(t.deleteTexture(i.__webglTexture),n.remove(e))}(i),i.isVideoTexture&&P.delete(i),s.memory.textures--}function U(e){const i=e.target;i.removeEventListener("dispose",U),function(e){const i=e.texture,r=n.get(e),o=n.get(i);if(e){if(void 0!==o.__webglTexture&&(t.deleteTexture(o.__webglTexture),s.memory.textures--),e.depthTexture&&e.depthTexture.dispose(),e.isWebGLCubeRenderTarget)for(let e=0;e<6;e++)t.deleteFramebuffer(r.__webglFramebuffer[e]),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer[e]);else t.deleteFramebuffer(r.__webglFramebuffer),r.__webglDepthbuffer&&t.deleteRenderbuffer(r.__webglDepthbuffer),r.__webglMultisampledFramebuffer&&t.deleteFramebuffer(r.__webglMultisampledFramebuffer),r.__webglColorRenderbuffer&&t.deleteRenderbuffer(r.__webglColorRenderbuffer),r.__webglDepthRenderbuffer&&t.deleteRenderbuffer(r.__webglDepthRenderbuffer);if(e.isWebGLMultipleRenderTargets)for(let e=0,r=i.length;e0&&r.__version!==t.version){const i=t.image;if(void 0===i)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==i.complete)return void Y(r,t,e);console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete")}}i.activeTexture(33984+e),i.bindTexture(3553,r.__webglTexture)}function H(e,r){const s=n.get(e);e.version>0&&s.__version!==e.version?function(e,n,r){if(6!==n.image.length)return;Z(e,n),i.activeTexture(33984+r),i.bindTexture(34067,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const s=n&&(n.isCompressedTexture||n.image[0].isCompressedTexture),l=n.image[0]&&n.image[0].isDataTexture,u=[];for(let t=0;t<6;t++)u[t]=s||l?l?n.image[t].image:n.image[t]:O(n.image[t],!1,!0,c);const h=u[0],p=k(h)||a,d=o.convert(n.format),f=o.convert(n.type),m=z(n.internalFormat,d,f);let g;if(X(34067,n,p),s){for(let t=0;t<6;t++){g=u[t].mipmaps;for(let e=0;e1||n.get(o).__currentAnisotropy)&&(t.texParameterf(i,s.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o.anisotropy,r.getMaxAnisotropy())),n.get(o).__currentAnisotropy=o.anisotropy)}}function Z(e,i){void 0===e.__webglInit&&(e.__webglInit=!0,i.addEventListener("dispose",V),e.__webglTexture=t.createTexture(),s.memory.textures++)}function Y(e,n,r){let s=3553;n.isDataTexture2DArray&&(s=35866),n.isDataTexture3D&&(s=32879),Z(e,n),i.activeTexture(33984+r),i.bindTexture(s,e.__webglTexture),t.pixelStorei(37440,n.flipY),t.pixelStorei(37441,n.premultiplyAlpha),t.pixelStorei(3317,n.unpackAlignment),t.pixelStorei(37443,0);const l=function(t){return!a&&(t.wrapS!==h||t.wrapT!==h||t.minFilter!==d&&t.minFilter!==g)}(n)&&!1===k(n.image),c=O(n.image,l,!1,_),u=k(c)||a,p=o.convert(n.format);let f,m=o.convert(n.type),y=z(n.internalFormat,p,m);X(s,n,u);const v=n.mipmaps;if(n.isDepthTexture)y=6402,a?y=n.type===w?36012:n.type===b?33190:n.type===E?35056:33189:n.type===w&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),n.format===T&&6402===y&&n.type!==x&&n.type!==b&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),n.type=x,m=o.convert(n.type)),n.format===I&&6402===y&&(y=34041,n.type!==E&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),n.type=E,m=o.convert(n.type))),i.texImage2D(3553,0,y,c.width,c.height,0,p,m,null);else if(n.isDataTexture)if(v.length>0&&u){for(let t=0,e=v.length;t0&&u){for(let t=0,e=v.length;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 r=n.get(t);t.version>0&&r.__version!==t.version?Y(r,t,e):(i.activeTexture(33984+e),i.bindTexture(35866,r.__webglTexture))},this.setTexture3D=function(t,e){const r=n.get(t);t.version>0&&r.__version!==t.version?Y(r,t,e):(i.activeTexture(33984+e),i.bindTexture(32879,r.__webglTexture))},this.setTextureCube=H,this.setupRenderTarget=function(e){const l=e.texture,c=n.get(e),u=n.get(l);e.addEventListener("dispose",U),!0!==e.isWebGLMultipleRenderTargets&&(u.__webglTexture=t.createTexture(),u.__version=l.version,s.memory.textures++);const h=!0===e.isWebGLCubeRenderTarget,p=!0===e.isWebGLMultipleRenderTargets,d=!0===e.isWebGLMultisampleRenderTarget,f=l.isDataTexture3D||l.isDataTexture2DArray,m=k(e)||a;if(!a||l.format!==S||l.type!==w&&l.type!==A||(l.format=M,console.warn("THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.")),h){c.__webglFramebuffer=[];for(let e=0;e<6;e++)c.__webglFramebuffer[e]=t.createFramebuffer()}else if(c.__webglFramebuffer=t.createFramebuffer(),p)if(r.drawBuffers){const i=e.texture;for(let e=0,r=i.length;ea+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&s<=a-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else null!==a&&t.gripSpace&&(r=e.getPose(t.gripSpace,i),null!==r&&(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));return null!==s&&(s.visible=null!==n),null!==a&&(a.visible=null!==r),null!==l&&(l.visible=null!==o),this}}class qo extends rt{constructor(t,e){super();const i=this,n=t.state;let r=null,o=1,s=null,a="local-floor",l=null,c=null,u=null,h=null,p=null,d=!1,f=null,m=null,g=null,y=null,v=null,_=null;const x=[],b=new Map,w=new Zi;w.layers.enable(1),w.viewport=new Et;const A=new Zi;A.layers.enable(2),A.viewport=new Et;const E=[w,A],S=new Go;S.layers.enable(1),S.layers.enable(2);let M=null,T=null;function I(t){const e=b.get(t.inputSource);e&&e.dispatchEvent({type:t.type,data:t.inputSource})}function C(){b.forEach((function(t,e){t.disconnect(e)})),b.clear(),M=null,T=null,n.bindXRFramebuffer(null),t.setRenderTarget(t.getRenderTarget()),u&&e.deleteFramebuffer(u),f&&e.deleteFramebuffer(f),m&&e.deleteRenderbuffer(m),g&&e.deleteRenderbuffer(g),u=null,f=null,m=null,g=null,p=null,h=null,c=null,r=null,k.stop(),i.isPresenting=!1,i.dispatchEvent({type:"sessionend"})}function P(t){const e=r.inputSources;for(let t=0;t0&&(e.alphaTest.value=i.alphaTest);const n=t.get(i).envMap;if(n){e.envMap.value=n,e.flipEnvMap.value=n.isCubeTexture&&!1===n.isRenderTargetTexture?-1:1,e.reflectivity.value=i.reflectivity,e.ior.value=i.ior,e.refractionRatio.value=i.refractionRatio;const r=t.get(n).__maxMipLevel;void 0!==r&&(e.maxMipLevel.value=r)}let r,o;i.lightMap&&(e.lightMap.value=i.lightMap,e.lightMapIntensity.value=i.lightMapIntensity),i.aoMap&&(e.aoMap.value=i.aoMap,e.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap?r=i.clearcoatRoughnessMap:i.specularIntensityMap?r=i.specularIntensityMap:i.specularTintMap?r=i.specularTintMap:i.transmissionMap?r=i.transmissionMap:i.thicknessMap&&(r=i.thicknessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),e.uvTransform.value.copy(r.matrix)),i.aoMap?o=i.aoMap:i.lightMap&&(o=i.lightMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uv2Transform.value.copy(o.matrix))}function i(e,i){e.roughness.value=i.roughness,e.metalness.value=i.metalness,i.roughnessMap&&(e.roughnessMap.value=i.roughnessMap),i.metalnessMap&&(e.metalnessMap.value=i.metalnessMap),i.emissiveMap&&(e.emissiveMap.value=i.emissiveMap),i.bumpMap&&(e.bumpMap.value=i.bumpMap,e.bumpScale.value=i.bumpScale,1===i.side&&(e.bumpScale.value*=-1)),i.normalMap&&(e.normalMap.value=i.normalMap,e.normalScale.value.copy(i.normalScale),1===i.side&&e.normalScale.value.negate()),i.displacementMap&&(e.displacementMap.value=i.displacementMap,e.displacementScale.value=i.displacementScale,e.displacementBias.value=i.displacementBias),t.get(i).envMap&&(e.envMapIntensity.value=i.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,n,r,o,s){n.isMeshBasicMaterial?e(t,n):n.isMeshLambertMaterial?(e(t,n),function(t,e){e.emissiveMap&&(t.emissiveMap.value=e.emissiveMap)}(t,n)):n.isMeshToonMaterial?(e(t,n),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,n)):n.isMeshPhongMaterial?(e(t,n),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,n)):n.isMeshStandardMaterial?(e(t,n),n.isMeshPhysicalMaterial?function(t,e,n){i(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=n.texture,t.transmissionSamplerSize.value.set(n.width,n.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,n,s):i(t,n)):n.isMeshMatcapMaterial?(e(t,n),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,n)):n.isMeshDepthMaterial?(e(t,n),function(t,e){e.displacementMap&&(t.displacementMap.value=e.displacementMap,t.displacementScale.value=e.displacementScale,t.displacementBias.value=e.displacementBias)}(t,n)):n.isMeshDistanceMaterial?(e(t,n),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,n)):n.isMeshNormalMaterial?(e(t,n),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,n)):n.isLineBasicMaterial?(function(t,e){t.diffuse.value.copy(e.color),t.opacity.value=e.opacity}(t,n),n.isLineDashedMaterial&&function(t,e){t.dashSize.value=e.dashSize,t.totalSize.value=e.dashSize+e.gapSize,t.scale.value=e.scale}(t,n)):n.isPointsMaterial?function(t,e,i,n){let r;t.diffuse.value.copy(e.color),t.opacity.value=e.opacity,t.size.value=e.size*i,t.scale.value=.5*n,e.map&&(t.map.value=e.map),e.alphaMap&&(t.alphaMap.value=e.alphaMap),e.alphaTest>0&&(t.alphaTest.value=e.alphaTest),e.map?r=e.map:e.alphaMap&&(r=e.alphaMap),void 0!==r&&(!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uvTransform.value.copy(r.matrix))}(t,n,r,o):n.isSpriteMaterial?function(t,e){let i;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?i=e.map:e.alphaMap&&(i=e.alphaMap),void 0!==i&&(!0===i.matrixAutoUpdate&&i.updateMatrix(),t.uvTransform.value.copy(i.matrix))}(t,n):n.isShadowMaterial?(t.color.value.copy(n.color),t.opacity.value=n.opacity):n.isShaderMaterial&&(n.uniformsNeedUpdate=!1)}}}function Zo(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}(),i=void 0!==t.context?t.context:null,n=void 0!==t.alpha&&t.alpha,r=void 0===t.depth||t.depth,o=void 0===t.stencil||t.stencil,s=void 0!==t.antialias&&t.antialias,a=void 0===t.premultipliedAlpha||t.premultipliedAlpha,l=void 0!==t.preserveDrawingBuffer&&t.preserveDrawingBuffer,c=void 0!==t.powerPreference?t.powerPreference:"default",u=void 0!==t.failIfMajorPerformanceCaveat&&t.failIfMajorPerformanceCaveat;let p=null,f=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,E=0,S=null,T=-1,I=null;const C=new Et,P=new Et;let L=null,D=e.width,R=e.height,O=1,k=null,N=null;const B=new Et(0,0,D,R),z=new Et(0,0,D,R);let F=!1;const V=[],U=new sn;let G=!1,j=!1,H=null;const W=new se,q=new Ct,Z={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Y(){return null===S?O:1}let Q,J,K,$,tt,et,it,nt,rt,ot,st,at,lt,ct,ut,ht,pt,dt,ft,mt,gt,yt,vt,_t=i;function xt(t,i){for(let n=0;n0&&function(t,e,i){if(null===H){const t=!0===s&&!0===J.isWebGL2;H=new(t?Tt:St)(1024,1024,{generateMipmaps:!0,type:null!==yt.convert(A)?A:_,minFilter:v,magFilter:d,wrapS:h,wrapT:h})}const n=y.getRenderTarget();y.setRenderTarget(H),y.clear();const r=y.toneMapping;y.toneMapping=0,Nt(t,e,i),y.toneMapping=r,et.updateMultisampleRenderTarget(H),et.updateRenderTargetMipmap(H),y.setRenderTarget(n)}(r,e,i),n&&K.viewport(C.copy(n)),r.length>0&&Nt(r,e,i),o.length>0&&Nt(o,e,i),a.length>0&&Nt(a,e,i)}function Nt(t,e,i){const n=!0===e.isScene?e.overrideMaterial:null;for(let r=0,o=t.length;r0?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 E},this.getRenderTarget=function(){return S},this.setRenderTarget=function(t,e=0,i=0){S=t,b=e,E=i,t&&void 0===tt.get(t).__webglFramebuffer&&et.setupRenderTarget(t);let n=null,r=!1,o=!1;if(t){const i=t.texture;(i.isDataTexture3D||i.isDataTexture2DArray)&&(o=!0);const s=tt.get(t).__webglFramebuffer;t.isWebGLCubeRenderTarget?(n=s[e],r=!0):n=t.isWebGLMultisampleRenderTarget?tt.get(t).__webglMultisampledFramebuffer:s,C.copy(t.viewport),P.copy(t.scissor),L=t.scissorTest}else C.copy(B).multiplyScalar(O).floor(),P.copy(z).multiplyScalar(O).floor(),L=F;if(K.bindFramebuffer(36160,n)&&J.drawBuffers){let e=!1;if(t)if(t.isWebGLMultipleRenderTargets){const i=t.texture;if(V.length!==i.length||36064!==V[0]){for(let t=0,e=i.length;t=0&&e<=t.width-n&&i>=0&&i<=t.height-r&&_t.readPixels(e,i,n,r,yt.convert(a),yt.convert(l),o):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const t=null!==S?tt.get(S).__webglFramebuffer:null;K.bindFramebuffer(36160,t)}}},this.copyFramebufferToTexture=function(t,e,i=0){const n=Math.pow(2,-i),r=Math.floor(e.image.width*n),o=Math.floor(e.image.height*n);let s=yt.convert(e.format);J.isWebGL2&&(6407===s&&(s=32849),6408===s&&(s=32856)),et.setTexture2D(e,0),_t.copyTexImage2D(3553,i,s,t.x,t.y,r,o,0),K.unbindTexture()},this.copyTextureToTexture=function(t,e,i,n=0){const r=e.image.width,o=e.image.height,s=yt.convert(i.format),a=yt.convert(i.type);et.setTexture2D(i,0),_t.pixelStorei(37440,i.flipY),_t.pixelStorei(37441,i.premultiplyAlpha),_t.pixelStorei(3317,i.unpackAlignment),e.isDataTexture?_t.texSubImage2D(3553,n,t.x,t.y,r,o,s,a,e.image.data):e.isCompressedTexture?_t.compressedTexSubImage2D(3553,n,t.x,t.y,e.mipmaps[0].width,e.mipmaps[0].height,s,e.mipmaps[0].data):_t.texSubImage2D(3553,n,t.x,t.y,s,a,e.image),0===n&&i.generateMipmaps&&_t.generateMipmap(3553),K.unbindTexture()},this.copyTextureToTexture3D=function(t,e,i,n,r=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,s=t.max.y-t.min.y+1,a=t.max.z-t.min.z+1,l=yt.convert(n.format),c=yt.convert(n.type);let u;if(n.isDataTexture3D)et.setTexture3D(n,0),u=32879;else{if(!n.isDataTexture2DArray)return void console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");et.setTexture2DArray(n,0),u=35866}_t.pixelStorei(37440,n.flipY),_t.pixelStorei(37441,n.premultiplyAlpha),_t.pixelStorei(3317,n.unpackAlignment);const h=_t.getParameter(3314),p=_t.getParameter(32878),d=_t.getParameter(3316),f=_t.getParameter(3315),m=_t.getParameter(32877),g=i.isCompressedTexture?i.mipmaps[0]:i.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),i.isDataTexture||i.isDataTexture3D?_t.texSubImage3D(u,r,e.x,e.y,e.z,o,s,a,l,c,g.data):i.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),_t.compressedTexSubImage3D(u,r,e.x,e.y,e.z,o,s,a,l,g.data)):_t.texSubImage3D(u,r,e.x,e.y,e.z,o,s,a,l,c,g),_t.pixelStorei(3314,h),_t.pixelStorei(32878,p),_t.pixelStorei(3316,d),_t.pixelStorei(3315,f),_t.pixelStorei(32877,m),0===r&&n.generateMipmaps&&_t.generateMipmap(u),K.unbindTexture()},this.initTexture=function(t){et.setTexture2D(t,0),K.unbindTexture()},this.resetState=function(){b=0,E=0,S=null,K.reset(),vt.reset()},"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class Yo extends Zo{}Yo.prototype.isWebGL1Renderer=!0;class Qo{constructor(t,e=25e-5){this.name="",this.color=new Je(t),this.density=e}clone(){return new Qo(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}Qo.prototype.isFogExp2=!0;class Jo{constructor(t,e=1,i=1e3){this.name="",this.color=new Je(t),this.near=e,this.far=i}clone(){return new Jo(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}Jo.prototype.isFog=!0;class Ko 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}}Ko.prototype.isScene=!0;class $o{constructor(t,e){this.array=t,this.stride=e,this.count=void 0!==t?t.length/e:0,this.usage=et,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=ct()}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,i){t*=this.stride,i*=e.stride;for(let n=0,r=this.stride;nt.far||e.push({distance:a,point:rs.clone(),uv:Ge.getUV(rs,us,hs,ps,ds,fs,ms,new yt),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 ys(t,e,i,n,r,o){as.subVectors(t,i).addScalar(.5).multiply(n),void 0!==r?(ls.x=o*as.x-r*as.y,ls.y=r*as.x+o*as.y):ls.copy(as),t.copy(e),t.x+=ls.x,t.y+=ls.y,t.applyMatrix4(cs)}gs.prototype.isSprite=!0;const vs=new Ct,_s=new Ct;class xs 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,i=e.length;t0){let i,n;for(i=1,n=e.length;i0){vs.setFromMatrixPosition(this.matrixWorld);const i=t.ray.origin.distanceTo(vs);this.getObjectForDistance(i).raycast(t,e)}}update(t){const e=this.levels;if(e.length>1){vs.setFromMatrixPosition(t.matrixWorld),_s.setFromMatrixPosition(this.matrixWorld);const i=vs.distanceTo(_s)/t.zoom;let n,r;for(e[0].object.visible=!0,n=1,r=e.length;n=e[n].distance;n++)e[n-1].object.visible=!1,e[n].object.visible=!0;for(this._currentLevel=n-1;na)continue;h.applyMatrix4(this.matrixWorld);const p=t.ray.origin.distanceTo(h);pt.far||e.push({distance:p,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}else for(let i=Math.max(0,o.start),n=Math.min(r.count,o.start+o.count)-1;ia)continue;h.applyMatrix4(this.matrixWorld);const n=t.ray.origin.distanceTo(h);nt.far||e.push({distance:n,point:u.clone().applyMatrix4(this.matrixWorld),index:i,face:null,faceIndex:null,object:this})}}else i.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,i=Object.keys(e);if(i.length>0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}Hs.prototype.isLine=!0;const Ws=new Ct,qs=new Ct;class Xs extends Hs{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,i=[];for(let t=0,n=e.count;t0){const t=e[i[0]];if(void 0!==t){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,i=t.length;e0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function ea(t,e,i,n,r,o,s){const a=Js.distanceSqToPoint(t);if(ar.far)return;o.push({distance:l,distanceToRay:Math.sqrt(a),point:i,index:e,face:null,object:s})}}ta.prototype.isPoints=!0;class ia extends wt{constructor(t,e,i,n,r,o,s,a,l){super(t,e,i,n,r,o,s,a,l),this.format=void 0!==s?s:S,this.minFilter=void 0!==o?o:g,this.magFilter=void 0!==r?r:g,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in t&&t.requestVideoFrameCallback((function e(){c.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)}}ia.prototype.isVideoTexture=!0;class na extends wt{constructor(t,e,i,n,r,o,s,a,l,c,u,h){super(null,o,s,a,l,c,n,r,u,h),this.image={width:e,height:i},this.mipmaps=t,this.flipY=!1,this.generateMipmaps=!1}}na.prototype.isCompressedTexture=!0;class ra extends wt{constructor(t,e,i,n,r,o,s,a,l){super(t,e,i,n,r,o,s,a,l),this.needsUpdate=!0}}ra.prototype.isCanvasTexture=!0;class oa extends wt{constructor(t,e,i,n,r,o,s,a,l,c){if((c=void 0!==c?c:T)!==T&&c!==I)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===i&&c===T&&(i=x),void 0===i&&c===I&&(i=E),super(null,n,r,o,s,a,c,i,l),this.image={width:t,height:e},this.magFilter=void 0!==s?s:d,this.minFilter=void 0!==a?a:d,this.flipY=!1,this.generateMipmaps=!1}}oa.prototype.isDepthTexture=!0;class sa extends wi{constructor(t=1,e=8,i=0,n=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const r=[],o=[],s=[],a=[],l=new Ct,c=new yt;o.push(0,0,0),s.push(0,0,1),a.push(.5,.5);for(let r=0,u=3;r<=e;r++,u+=3){const h=i+r/e*n;l.x=t*Math.cos(h),l.y=t*Math.sin(h),o.push(l.x,l.y,l.z),s.push(0,0,1),c.x=(o[u]/t+1)/2,c.y=(o[u+1]/t+1)/2,a.push(c.x,c.y)}for(let t=1;t<=e;t++)r.push(t,t+1,0);this.setIndex(r),this.setAttribute("position",new ui(o,3)),this.setAttribute("normal",new ui(s,3)),this.setAttribute("uv",new ui(a,2))}static fromJSON(t){return new sa(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class aa extends wi{constructor(t=1,e=1,i=1,n=8,r=1,o=!1,s=0,a=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:s,thetaLength:a};const l=this;n=Math.floor(n),r=Math.floor(r);const c=[],u=[],h=[],p=[];let d=0;const f=[],m=i/2;let g=0;function y(i){const r=d,o=new yt,f=new Ct;let y=0;const v=!0===i?t:e,_=!0===i?1:-1;for(let t=1;t<=n;t++)u.push(0,m*_,0),h.push(0,_,0),p.push(.5,.5),d++;const x=d;for(let t=0;t<=n;t++){const e=t/n*a+s,i=Math.cos(e),r=Math.sin(e);f.x=v*r,f.y=m*_,f.z=v*i,u.push(f.x,f.y,f.z),h.push(0,_,0),o.x=.5*i+.5,o.y=.5*r*_+.5,p.push(o.x,o.y),d++}for(let t=0;t0&&y(!0),e>0&&y(!1)),this.setIndex(c),this.setAttribute("position",new ui(u,3)),this.setAttribute("normal",new ui(h,3)),this.setAttribute("uv",new ui(p,2))}static fromJSON(t){return new aa(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class la extends aa{constructor(t=1,e=1,i=8,n=1,r=!1,o=0,s=2*Math.PI){super(0,t,e,i,n,r,o,s),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:r,thetaStart:o,thetaLength:s}}static fromJSON(t){return new la(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class ca extends wi{constructor(t,e,i=1,n=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:t,indices:e,radius:i,detail:n};const r=[],o=[];function s(t,e,i,n){const r=n+1,o=[];for(let n=0;n<=r;n++){o[n]=[];const s=t.clone().lerp(i,n/r),a=e.clone().lerp(i,n/r),l=r-n;for(let t=0;t<=l;t++)o[n][t]=0===t&&n===r?s:s.clone().lerp(a,t/l)}for(let t=0;t.9&&s<.1&&(e<.2&&(o[t+0]+=1),i<.2&&(o[t+2]+=1),n<.2&&(o[t+4]+=1))}}()}(),this.setAttribute("position",new ui(r,3)),this.setAttribute("normal",new ui(r.slice(),3)),this.setAttribute("uv",new ui(o,2)),0===n?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(t){return new ca(t.vertices,t.indices,t.radius,t.details)}}class ua extends ca{constructor(t=1,e=0){const i=(1+Math.sqrt(5))/2,n=1/i;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,-n,-i,0,-n,i,0,n,-i,0,n,i,-n,-i,0,-n,i,0,n,-i,0,n,i,0,-i,0,-n,i,0,-n,-i,0,n,i,0,n],[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 ua(t.radius,t.detail)}}const ha=new Ct,pa=new Ct,da=new Ct,fa=new Ge;class ma extends wi{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 i=Math.pow(10,4),n=Math.cos(at*e),r=t.getIndex(),o=t.getAttribute("position"),s=r?r.count:o.count,a=[0,0,0],l=["a","b","c"],c=new Array(3),u={},h=[];for(let t=0;t0)){l=n;break}l=n-1}if(n=l,i[n]===o)return n/(r-1);const c=i[n];return(n+(o-c)/(i[n+1]-c))/(r-1)}getTangent(t,e){const i=1e-4;let n=t-i,r=t+i;n<0&&(n=0),r>1&&(r=1);const o=this.getPoint(n),s=this.getPoint(r),a=e||(o.isVector2?new yt:new Ct);return a.copy(s).sub(o).normalize(),a}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new Ct,n=[],r=[],o=[],s=new Ct,a=new se;for(let e=0;e<=t;e++){const i=e/t;n[e]=this.getTangentAt(i,new Ct),n[e].normalize()}r[0]=new Ct,o[0]=new Ct;let l=Number.MAX_VALUE;const c=Math.abs(n[0].x),u=Math.abs(n[0].y),h=Math.abs(n[0].z);c<=l&&(l=c,i.set(1,0,0)),u<=l&&(l=u,i.set(0,1,0)),h<=l&&i.set(0,0,1),s.crossVectors(n[0],i).normalize(),r[0].crossVectors(n[0],s),o[0].crossVectors(n[0],r[0]);for(let e=1;e<=t;e++){if(r[e]=r[e-1].clone(),o[e]=o[e-1].clone(),s.crossVectors(n[e-1],n[e]),s.length()>Number.EPSILON){s.normalize();const t=Math.acos(ut(n[e-1].dot(n[e]),-1,1));r[e].applyMatrix4(a.makeRotationAxis(s,t))}o[e].crossVectors(n[e],r[e])}if(!0===e){let e=Math.acos(ut(r[0].dot(r[t]),-1,1));e/=t,n[0].dot(s.crossVectors(r[0],r[t]))>0&&(e=-e);for(let i=1;i<=t;i++)r[i].applyMatrix4(a.makeRotationAxis(n[i],e*i)),o[i].crossVectors(n[i],r[i])}return{tangents:n,normals:r,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 ya extends ga{constructor(t=0,e=0,i=1,n=1,r=0,o=2*Math.PI,s=!1,a=0){super(),this.type="EllipseCurve",this.aX=t,this.aY=e,this.xRadius=i,this.yRadius=n,this.aStartAngle=r,this.aEndAngle=o,this.aClockwise=s,this.aRotation=a}getPoint(t,e){const i=e||new yt,n=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const o=Math.abs(r)n;)r-=n;r0?0:(Math.floor(Math.abs(l)/r)+1)*r:0===c&&l===r-1&&(l=r-2,c=1),this.closed||l>0?s=n[(l-1)%r]:(xa.subVectors(n[0],n[1]).add(n[0]),s=xa);const u=n[l%r],h=n[(l+1)%r];if(this.closed||l+2n.length-2?n.length-1:o+1],u=n[o>n.length-3?n.length-1:o+2];return i.set(Sa(s,a.x,l.x,c.x,u.x),Sa(s,a.y,l.y,c.y,u.y)),i}copy(t){super.copy(t),this.points=[];for(let e=0,i=t.points.length;e80*i){a=c=t[0],l=u=t[1];for(let e=i;ec&&(c=h),p>u&&(u=p);d=Math.max(c-a,u-l),d=0!==d?1/d:0}return Fa(o,s,i,a,l,d),s};function Ba(t,e,i,n,r){let o,s;if(r===function(t,e,i,n){let r=0;for(let o=e,s=i-n;o0)for(o=e;o=e;o-=n)s=rl(o,t[o],t[o+1],s);return s&&Ka(s,s.next)&&(ol(s),s=s.next),s}function za(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!Ka(n,n.next)&&0!==Ja(n.prev,n,n.next))n=n.next;else{if(ol(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Fa(t,e,i,n,r,o,s){if(!t)return;!s&&o&&function(t,e,i,n){let r=t;do{null===r.z&&(r.z=Xa(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let e,i,n,r,o,s,a,l,c=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,n=i,a=0,e=0;e0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(t,n,r,o);let a,l,c=t;for(;t.prev!==t.next;)if(a=t.prev,l=t.next,o?Ua(t,n,r,o):Va(t))e.push(a.i/i),e.push(t.i/i),e.push(l.i/i),ol(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?Fa(t=Ga(za(t),e,i),e,i,n,r,o,2):2===s&&ja(t,e,i,n,r,o):Fa(za(t),e,i,n,r,o,1);break}}function Va(t){const e=t.prev,i=t,n=t.next;if(Ja(e,i,n)>=0)return!1;let r=t.next.next;for(;r!==t.prev;){if(Ya(e.x,e.y,i.x,i.y,n.x,n.y,r.x,r.y)&&Ja(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function Ua(t,e,i,n){const r=t.prev,o=t,s=t.next;if(Ja(r,o,s)>=0)return!1;const a=r.xo.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,u=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,h=Xa(a,l,e,i,n),p=Xa(c,u,e,i,n);let d=t.prevZ,f=t.nextZ;for(;d&&d.z>=h&&f&&f.z<=p;){if(d!==t.prev&&d!==t.next&&Ya(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ja(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,f!==t.prev&&f!==t.next&&Ya(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ja(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;d&&d.z>=h;){if(d!==t.prev&&d!==t.next&&Ya(r.x,r.y,o.x,o.y,s.x,s.y,d.x,d.y)&&Ja(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&Ya(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ja(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function Ga(t,e,i){let n=t;do{const r=n.prev,o=n.next.next;!Ka(r,o)&&$a(r,n,n.next,o)&&il(r,o)&&il(o,r)&&(e.push(r.i/i),e.push(n.i/i),e.push(o.i/i),ol(n),ol(n.next),n=t=o),n=n.next}while(n!==t);return za(n)}function ja(t,e,i,n,r,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Qa(s,t)){let a=nl(s,t);return s=za(s,s.next),a=za(a,a.next),Fa(s,e,i,n,r,o),void Fa(a,e,i,n,r,o)}t=t.next}s=s.next}while(s!==t)}function Ha(t,e){return t.x-e.x}function Wa(t,e){if(e=function(t,e){let i=e;const n=t.x,r=t.y;let o,s=-1/0;do{if(r<=i.y&&r>=i.next.y&&i.next.y!==i.y){const t=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>s){if(s=t,t===n){if(r===i.y)return i;if(r===i.next.y)return i.next}o=i.x=i.x&&i.x>=l&&n!==i.x&&Ya(ro.x||i.x===o.x&&qa(o,i)))&&(o=i,h=u)),i=i.next}while(i!==a);return o}(t,e)){const i=nl(e,t);za(e,e.next),za(i,i.next)}}function qa(t,e){return Ja(t.prev,t,e.prev)<0&&Ja(e.next,t,t.next)<0}function Xa(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Za(t){let e=t,i=t;do{(e.x=0&&(t-s)*(n-a)-(i-s)*(e-a)>=0&&(i-s)*(o-a)-(r-s)*(n-a)>=0}function Qa(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&$a(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(il(t,e)&&il(e,t)&&function(t,e){let i=t,n=!1;const r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(Ja(t.prev,t,e.prev)||Ja(t,e.prev,e))||Ka(t,e)&&Ja(t.prev,t,t.next)>0&&Ja(e.prev,e,e.next)>0)}function Ja(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Ka(t,e){return t.x===e.x&&t.y===e.y}function $a(t,e,i,n){const r=el(Ja(t,e,i)),o=el(Ja(t,e,n)),s=el(Ja(i,n,t)),a=el(Ja(i,n,e));return r!==o&&s!==a||!(0!==r||!tl(t,i,e))||!(0!==o||!tl(t,n,e))||!(0!==s||!tl(i,t,n))||!(0!==a||!tl(i,e,n))}function tl(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function el(t){return t>0?1:t<0?-1:0}function il(t,e){return Ja(t.prev,t,t.next)<0?Ja(t,e,t.next)>=0&&Ja(t,t.prev,e)>=0:Ja(t,e,t.prev)<0||Ja(t,t.next,e)<0}function nl(t,e){const i=new sl(t.i,t.x,t.y),n=new sl(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function rl(t,e,i,n){const r=new sl(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ol(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 sl(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class al{static area(t){const e=t.length;let i=0;for(let n=e-1,r=0;r2&&t[e-1].equals(t[0])&&t.pop()}function cl(t,e){for(let i=0;iNumber.EPSILON){const h=Math.sqrt(u),p=Math.sqrt(l*l+c*c),d=e.x-a/h,f=e.y+s/h,m=((i.x-c/p-d)*c-(i.y+l/p-f)*l)/(s*c-a*l);n=d+s*m-t.x,r=f+a*m-t.y;const g=n*n+r*r;if(g<=2)return new yt(n,r);o=Math.sqrt(g/2)}else{let t=!1;s>Number.EPSILON?l>Number.EPSILON&&(t=!0):s<-Number.EPSILON?l<-Number.EPSILON&&(t=!0):Math.sign(a)===Math.sign(c)&&(t=!0),t?(n=-a,r=s,o=Math.sqrt(u)):(n=s,r=a,o=Math.sqrt(u/2))}return new yt(n/o,r/o)}const L=[];for(let t=0,e=M.length,i=e-1,n=t+1;t=0;t--){const e=t/d,i=u*Math.cos(e*Math.PI/2),n=h*Math.sin(e*Math.PI/2)+p;for(let t=0,e=M.length;t=0;){const n=i;let r=i-1;r<0&&(r=t.length-1);for(let t=0,i=a+2*d;t=0?(t(n-a,d,u),h.subVectors(c,u)):(t(n+a,d,u),h.subVectors(u,c)),d-a>=0?(t(n,d-a,u),p.subVectors(c,u)):(t(n,d+a,u),p.subVectors(u,c)),l.crossVectors(h,p).normalize(),o.push(l.x,l.y,l.z),s.push(n,d)}}for(let t=0;t0)&&p.push(e,r,l),(t!==i-1||a0!=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}}Cl.prototype.isMeshPhysicalMaterial=!0;class Pl extends He{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 yt(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}}Pl.prototype.isMeshPhongMaterial=!0;class Ll extends He{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 yt(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}}Ll.prototype.isMeshToonMaterial=!0;class Dl extends He{constructor(t){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new yt(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}}Dl.prototype.isMeshNormalMaterial=!0;class Rl extends He{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}}Rl.prototype.isMeshLambertMaterial=!0;class Ol extends He{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 yt(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}}Ol.prototype.isMeshMatcapMaterial=!0;class kl extends zs{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}}kl.prototype.isLineDashedMaterial=!0;var Nl=Object.freeze({__proto__:null,ShadowMaterial:Tl,SpriteMaterial:is,RawShaderMaterial:xn,ShaderMaterial:qi,PointsMaterial:Ys,MeshPhysicalMaterial:Cl,MeshStandardMaterial:Il,MeshPhongMaterial:Pl,MeshToonMaterial:Ll,MeshNormalMaterial:Dl,MeshLambertMaterial:Rl,MeshDepthMaterial:No,MeshDistanceMaterial:Bo,MeshBasicMaterial:Ke,MeshMatcapMaterial:Ol,LineDashedMaterial:kl,LineBasicMaterial:zs,Material:He});const Bl={arraySlice:function(t,e,i){return Bl.isTypedArray(t)?new t.constructor(t.subarray(e,void 0!==i?i:t.length)):t.slice(e,i)},convertArray:function(t,e,i){return!t||!i&&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,i=new Array(e);for(let t=0;t!==e;++t)i[t]=t;return i.sort((function(e,i){return t[e]-t[i]})),i},sortedArray:function(t,e,i){const n=t.length,r=new t.constructor(n);for(let o=0,s=0;s!==n;++o){const n=i[o]*e;for(let i=0;i!==e;++i)r[s++]=t[n+i]}return r},flattenJSON:function(t,e,i,n){let r=1,o=t[0];for(;void 0!==o&&void 0===o[n];)o=t[r++];if(void 0===o)return;let s=o[n];if(void 0!==s)if(Array.isArray(s))do{s=o[n],void 0!==s&&(e.push(o.time),i.push.apply(i,s)),o=t[r++]}while(void 0!==o);else if(void 0!==s.toArray)do{s=o[n],void 0!==s&&(e.push(o.time),s.toArray(i,i.length)),o=t[r++]}while(void 0!==o);else do{s=o[n],void 0!==s&&(e.push(o.time),i.push(s)),o=t[r++]}while(void 0!==o)},subclip:function(t,e,i,n,r=30){const o=t.clone();o.name=e;const s=[];for(let t=0;t=n)){l.push(e.times[t]);for(let i=0;io.tracks[t].times[0]&&(a=o.tracks[t].times[0]);for(let t=0;t=n.times[h]){const t=h*l+a,e=t+l-a;p=Bl.arraySlice(n.values,t,e)}else{const t=n.createInterpolant(),e=a,i=l-a;t.evaluate(o),p=Bl.arraySlice(t.resultBuffer,e,i)}"quaternion"===r&&(new It).fromArray(p).normalize().conjugate().toArray(p);const d=s.times.length;for(let t=0;t=r)break t;{const s=e[1];t=r)break e}o=i,i=0}}for(;i>>1;te;)--o;if(++o,0!==r||o!==n){r>=o&&(o=Math.max(o,1),r=o-1);const t=this.getValueSize();this.times=Bl.arraySlice(i,r,o),this.values=Bl.arraySlice(this.values,r*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 i=this.times,n=this.values,r=i.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let e=0;e!==r;e++){const n=i[e];if("number"==typeof n&&isNaN(n)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,e,n),t=!1;break}if(null!==o&&o>n){console.error("THREE.KeyframeTrack: Out of order keys.",this,e,n,o),t=!1;break}o=n}if(void 0!==n&&Bl.isTypedArray(n))for(let e=0,i=n.length;e!==i;++e){const i=n[e];if(isNaN(i)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,e,i),t=!1;break}}return t}optimize(){const t=Bl.arraySlice(this.times),e=Bl.arraySlice(this.values),i=this.getValueSize(),n=this.getInterpolation()===U,r=t.length-1;let o=1;for(let s=1;s0){t[o]=t[r];for(let t=r*i,n=o*i,s=0;s!==i;++s)e[n+s]=e[t+s];++o}return o!==t.length?(this.times=Bl.arraySlice(t,0,o),this.values=Bl.arraySlice(e,0,o*i)):(this.times=t,this.values=e),this}clone(){const t=Bl.arraySlice(this.times,0),e=Bl.arraySlice(this.values,0),i=new this.constructor(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}Gl.prototype.TimeBufferType=Float32Array,Gl.prototype.ValueBufferType=Float32Array,Gl.prototype.DefaultInterpolation=V;class jl extends Gl{}jl.prototype.ValueTypeName="bool",jl.prototype.ValueBufferType=Array,jl.prototype.DefaultInterpolation=F,jl.prototype.InterpolantFactoryMethodLinear=void 0,jl.prototype.InterpolantFactoryMethodSmooth=void 0;class Hl extends Gl{}Hl.prototype.ValueTypeName="color";class Wl extends Gl{}Wl.prototype.ValueTypeName="number";class ql extends zl{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=(i-e)/(n-e);let l=t*s;for(let t=l+s;l!==t;l+=4)It.slerpFlat(r,0,o,l-s,o,l,a);return r}}class Xl extends Gl{InterpolantFactoryMethodLinear(t){return new ql(this.times,this.values,this.getValueSize(),t)}}Xl.prototype.ValueTypeName="quaternion",Xl.prototype.DefaultInterpolation=V,Xl.prototype.InterpolantFactoryMethodSmooth=void 0;class Zl extends Gl{}Zl.prototype.ValueTypeName="string",Zl.prototype.ValueBufferType=Array,Zl.prototype.DefaultInterpolation=F,Zl.prototype.InterpolantFactoryMethodLinear=void 0,Zl.prototype.InterpolantFactoryMethodSmooth=void 0;class Yl extends Gl{}Yl.prototype.ValueTypeName="vector";class Ql{constructor(t,e=-1,i,n=2500){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=ct(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let t=0,r=i.length;t!==r;++t)e.push(Jl(i[t]).scale(n));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let t=0,n=i.length;t!==n;++t)e.push(Gl.toJSON(i[t]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const r=e.length,o=[];for(let t=0;t1){const t=o[1];let e=n[t];e||(n[t]=e=[]),e.push(i)}}const o=[];for(const t in n)o.push(this.CreateFromMorphTargetSequence(t,n[t],e,i));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(t,e,i,n,r){if(0!==i.length){const o=[],s=[];Bl.flattenJSON(i,o,s,n),0!==o.length&&r.push(new t(e,o,s))}},n=[],r=t.name||"default",o=t.fps||30,s=t.blendMode;let a=t.length||-1;const l=t.hierarchy||[];for(let t=0;t0||0===t.search(/^data\:image\/jpeg/);r.format=n?S:M,r.needsUpdate=!0,void 0!==e&&e(r)}),i,n),r}}class lc extends ga{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 Pa(e,t))}getPoint(t){const e=t*this.getLength(),i=this.getCurveLengths();let n=0;for(;n=e){const t=i[n]-e,r=this.curves[n],o=r.getLength(),s=0===o?0:1-t/o;return r.getPointAt(s)}n++}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 i=0,n=this.curves.length;i1&&!e[e.length-1].equals(e[0])&&e.push(e[0]),e}copy(t){super.copy(t),this.curves=[];for(let e=0,i=t.curves.length;e0){const t=l.getPoint(0);t.equals(this.currentPoint)||this.lineTo(t.x,t.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),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 uc extends cc{constructor(t){super(t),this.uuid=ct(),this.type="Shape",this.holes=[]}getPointsHoles(t){const e=[];for(let i=0,n=this.holes.length;i0:n.vertexColors=t.vertexColors),void 0!==t.uniforms)for(const e in t.uniforms){const r=t.uniforms[e];switch(n.uniforms[e]={},r.type){case"t":n.uniforms[e].value=i(r.value);break;case"c":n.uniforms[e].value=(new Je).setHex(r.value);break;case"v2":n.uniforms[e].value=(new yt).fromArray(r.value);break;case"v3":n.uniforms[e].value=(new Ct).fromArray(r.value);break;case"v4":n.uniforms[e].value=(new Et).fromArray(r.value);break;case"m3":n.uniforms[e].value=(new vt).fromArray(r.value);break;case"m4":n.uniforms[e].value=(new se).fromArray(r.value);break;default:n.uniforms[e].value=r.value}}if(void 0!==t.defines&&(n.defines=t.defines),void 0!==t.vertexShader&&(n.vertexShader=t.vertexShader),void 0!==t.fragmentShader&&(n.fragmentShader=t.fragmentShader),void 0!==t.extensions)for(const e in t.extensions)n.extensions[e]=t.extensions[e];if(void 0!==t.shading&&(n.flatShading=1===t.shading),void 0!==t.size&&(n.size=t.size),void 0!==t.sizeAttenuation&&(n.sizeAttenuation=t.sizeAttenuation),void 0!==t.map&&(n.map=i(t.map)),void 0!==t.matcap&&(n.matcap=i(t.matcap)),void 0!==t.alphaMap&&(n.alphaMap=i(t.alphaMap)),void 0!==t.bumpMap&&(n.bumpMap=i(t.bumpMap)),void 0!==t.bumpScale&&(n.bumpScale=t.bumpScale),void 0!==t.normalMap&&(n.normalMap=i(t.normalMap)),void 0!==t.normalMapType&&(n.normalMapType=t.normalMapType),void 0!==t.normalScale){let e=t.normalScale;!1===Array.isArray(e)&&(e=[e,e]),n.normalScale=(new yt).fromArray(e)}return void 0!==t.displacementMap&&(n.displacementMap=i(t.displacementMap)),void 0!==t.displacementScale&&(n.displacementScale=t.displacementScale),void 0!==t.displacementBias&&(n.displacementBias=t.displacementBias),void 0!==t.roughnessMap&&(n.roughnessMap=i(t.roughnessMap)),void 0!==t.metalnessMap&&(n.metalnessMap=i(t.metalnessMap)),void 0!==t.emissiveMap&&(n.emissiveMap=i(t.emissiveMap)),void 0!==t.emissiveIntensity&&(n.emissiveIntensity=t.emissiveIntensity),void 0!==t.specularMap&&(n.specularMap=i(t.specularMap)),void 0!==t.specularIntensityMap&&(n.specularIntensityMap=i(t.specularIntensityMap)),void 0!==t.specularTintMap&&(n.specularTintMap=i(t.specularTintMap)),void 0!==t.envMap&&(n.envMap=i(t.envMap)),void 0!==t.envMapIntensity&&(n.envMapIntensity=t.envMapIntensity),void 0!==t.reflectivity&&(n.reflectivity=t.reflectivity),void 0!==t.refractionRatio&&(n.refractionRatio=t.refractionRatio),void 0!==t.lightMap&&(n.lightMap=i(t.lightMap)),void 0!==t.lightMapIntensity&&(n.lightMapIntensity=t.lightMapIntensity),void 0!==t.aoMap&&(n.aoMap=i(t.aoMap)),void 0!==t.aoMapIntensity&&(n.aoMapIntensity=t.aoMapIntensity),void 0!==t.gradientMap&&(n.gradientMap=i(t.gradientMap)),void 0!==t.clearcoatMap&&(n.clearcoatMap=i(t.clearcoatMap)),void 0!==t.clearcoatRoughnessMap&&(n.clearcoatRoughnessMap=i(t.clearcoatRoughnessMap)),void 0!==t.clearcoatNormalMap&&(n.clearcoatNormalMap=i(t.clearcoatNormalMap)),void 0!==t.clearcoatNormalScale&&(n.clearcoatNormalScale=(new yt).fromArray(t.clearcoatNormalScale)),void 0!==t.transmissionMap&&(n.transmissionMap=i(t.transmissionMap)),void 0!==t.thicknessMap&&(n.thicknessMap=i(t.thicknessMap)),n}setTextures(t){return this.textures=t,this}}class Lc{static decodeText(t){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(t);let e="";for(let i=0,n=t.length;iNumber.EPSILON){if(l<0&&(i=e[o],a=-a,s=e[r],l=-l),t.ys.y)continue;if(t.y===i.y){if(t.x===i.x)return!0}else{const e=l*(t.x-i.x)-a*(t.y-i.y);if(0===e)return!0;if(e<0)continue;n=!n}}else{if(t.y!==i.y)continue;if(s.x<=t.x&&t.x<=i.x||i.x<=t.x&&t.x<=s.x)return!0}}return n}const r=al.isClockWise,o=this.subPaths;if(0===o.length)return[];if(!0===e)return i(o);let s,a,l;const c=[];if(1===o.length)return a=o[0],l=new uc,l.curves=a.curves,c.push(l),c;let u=!r(o[0].getPoints());u=t?!u:u;const h=[],p=[];let d,f,m=[],g=0;p[g]=void 0,m[g]=[];for(let e=0,i=o.length;e1){let t=!1;const e=[];for(let t=0,e=p.length;t0&&(t||(m=h))}for(let t=0,e=p.length;t0){this.source.connect(this.filters[0]);for(let t=1,e=this.filters.length;t0){this.source.disconnect(this.filters[0]);for(let t=1,e=this.filters.length;t0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let t=e,r=e+e;t!==r;++t)if(i[t]!==i[t+e]){s.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let t=i,r=n;t!==r;++t)e[t]=e[n+t%i];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 i=t;i=.5)for(let n=0;n!==r;++n)t[e+n]=t[i+n]}_slerp(t,e,i,n){It.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,r){const o=this._workIndex*r;It.multiplyQuaternionsFlat(t,o,t,e,t,i),It.slerpFlat(t,e,t,e,t,o,n)}_lerp(t,e,i,n,r){const o=1-n;for(let s=0;s!==r;++s){const r=e+s;t[r]=t[r]*o+t[i+s]*n}}_lerpAdditive(t,e,i,n,r){for(let o=0;o!==r;++o){const r=e+o;t[r]=t[r]+t[i+o]*n}}}const au="\\[\\]\\.:\\/",lu=new RegExp("[\\[\\]\\.:\\/]","g"),cu="[^\\[\\]\\.:\\/]",uu="[^"+au.replace("\\.","")+"]",hu=/((?:WC+[\/:])*)/.source.replace("WC",cu),pu=/(WCOD+)?/.source.replace("WCOD",uu),du=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",cu),fu=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",cu),mu=new RegExp("^"+hu+pu+du+fu+"$"),gu=["material","materials","bones"];class yu{constructor(t,e,i){this.path=e,this.parsedPath=i||yu.parseTrackName(e),this.node=yu.findNode(t,this.parsedPath.nodeName)||t,this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new yu.Composite(t,e,i):new yu(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(lu,"")}static parseTrackName(t){const e=mu.exec(t);if(!e)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(void 0!==n&&-1!==n){const t=i.nodeName.substring(n+1);-1!==gu.indexOf(t)&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=t)}if(null===i.propertyName||0===i.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(!e||""===e||"."===e||-1===e||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(void 0!==i)return i}if(t.children){const i=function(t){for(let n=0;n=r){const o=r++,c=t[o];e[c.uuid]=l,t[l]=c,e[a]=o,t[o]=s;for(let t=0,e=n;t!==e;++t){const e=i[t],n=e[o],r=e[l];e[l]=n,e[o]=r}}}this.nCachedObjects_=r}uncache(){const t=this._objects,e=this._indicesByUUID,i=this._bindings,n=i.length;let r=this.nCachedObjects_,o=t.length;for(let s=0,a=arguments.length;s!==a;++s){const a=arguments[s].uuid,l=e[a];if(void 0!==l)if(delete e[a],l0&&(e[s.uuid]=l),t[l]=s,t.pop();for(let t=0,e=n;t!==e;++t){const e=i[t];e[l]=e[r],e.pop()}}}this.nCachedObjects_=r}subscribe_(t,e){const i=this._bindingsIndicesByPath;let n=i[t];const r=this._bindings;if(void 0!==n)return r[n];const o=this._paths,s=this._parsedPaths,a=this._objects,l=a.length,c=this.nCachedObjects_,u=new Array(l);n=r.length,i[t]=n,o.push(t),s.push(e),r.push(u);for(let i=c,n=a.length;i!==n;++i){const n=a[i];u[i]=new yu(n,t,e)}return u}unsubscribe_(t){const e=this._bindingsIndicesByPath,i=e[t];if(void 0!==i){const n=this._paths,r=this._parsedPaths,o=this._bindings,s=o.length-1,a=o[s];e[t[s]]=i,o[i]=a,o.pop(),r[i]=r[s],r.pop(),n[i]=n[s],n.pop()}}}vu.prototype.isAnimationObjectGroup=!0;class _u{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const r=e.tracks,o=r.length,s=new Array(o),a={endingStart:G,endingEnd:G};for(let t=0;t!==o;++t){const e=r[t].createInterpolant(null);s[t]=e,e.settings=a}this._interpolantSettings=a,this._interpolants=s,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,i){if(t.fadeOut(e),this.fadeIn(e),i){const i=this._clip.duration,n=t._clip.duration,r=n/i,o=i/n;t.warp(1,r,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,i){return t.crossFadeFrom(this,e,i)}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,i){const n=this._mixer,r=n.time,o=this.timeScale;let s=this._timeScaleInterpolant;null===s&&(s=n._lendControlInterpolant(),this._timeScaleInterpolant=s);const a=s.parameterPositions,l=s.sampleValues;return a[0]=r,a[1]=r+i,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,i,n){if(!this.enabled)return void this._updateWeight(t);const r=this._startTime;if(null!==r){const n=(t-r)*i;if(n<0||0===i)return;this._startTime=null,e=i*n}e*=this._updateTimeScale(t);const o=this._updateTime(e),s=this._updateWeight(t);if(s>0){const t=this._interpolants,e=this._propertyBindings;if(this.blendMode===q)for(let i=0,n=t.length;i!==n;++i)t[i].evaluate(o),e[i].accumulateAdditive(s);else for(let i=0,r=t.length;i!==r;++i)t[i].evaluate(o),e[i].accumulate(n,s)}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(null!==i){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),0===n&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;null!==i&&(e*=i.evaluate(t)[0],t>i.parameterPositions[1]&&(this.stopWarping(),0===e?this.paused=!0:this.timeScale=e))}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,r=this._loopCount;const o=2202===i;if(0===t)return-1===r?n:o&&1==(1&r)?e-n:n;if(2200===i){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else{if(!(n<0)){this.time=n;break t}n=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(-1===r&&(t>=0?(r=0,this._setEndings(!0,0===this.repetitions,o)):this._setEndings(0===this.repetitions,!0,o)),n>=e||n<0){const i=Math.floor(n/e);n-=e*i,r+=Math.abs(i);const s=this.repetitions-r;if(s<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(1===s){const e=t<0;this._setEndings(e,!e,o)}else this._setEndings(!1,!1,o);this._loopCount=r,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=n;if(o&&1==(1&r))return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=j,n.endingEnd=j):(n.endingStart=t?this.zeroSlopeAtStart?j:G:H,n.endingEnd=e?this.zeroSlopeAtEnd?j:G:H)}_scheduleFading(t,e,i){const n=this._mixer,r=n.time;let o=this._weightInterpolant;null===o&&(o=n._lendControlInterpolant(),this._weightInterpolant=o);const s=o.parameterPositions,a=o.sampleValues;return s[0]=r,a[0]=e,s[1]=r+t,a[1]=i,this}}class xu extends rt{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,r=n.length,o=t._propertyBindings,s=t._interpolants,a=i.uuid,l=this._bindingsByRootAndName;let c=l[a];void 0===c&&(c={},l[a]=c);for(let t=0;t!==r;++t){const r=n[t],l=r.name;let u=c[l];if(void 0!==u)o[t]=u;else{if(u=o[t],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,l));continue}const n=e&&e._propertyBindings[t].binding.parsedPath;u=new su(yu.create(i,l,n),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,a,l),o[t]=u}s[t].resultBuffer=u.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(null===t._cacheIndex){const e=(t._localRoot||this._root).uuid,i=t._clip.uuid,n=this._actionsByClip[i];this._bindAction(t,n&&n.knownActions[0]),this._addInactiveAction(t,i,e)}const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==i.useCount++&&(this._lendBinding(i),i.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let t=0,i=e.length;t!==i;++t){const i=e[t];0==--i.useCount&&(i.restoreOriginalState(),this._takeBackBinding(i))}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=0;--e)t[e].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,r=Math.sign(t),o=this._accuIndex^=1;for(let s=0;s!==i;++s)e[s]._update(n,t,r,o);const s=this._bindings,a=this._nActiveBindings;for(let t=0;t!==a;++t)s[t].apply(o);return this}setTime(t){this.time=0;for(let t=0;tthis.max.x||t.ythis.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.xthis.max.x||t.max.ythis.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return Mu.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)}}Tu.prototype.isBox2=!0;const Iu=new Ct,Cu=new Ct;class Pu{constructor(t=new Ct,e=new Ct){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){Iu.subVectors(t,this.start),Cu.subVectors(this.end,this.start);const i=Cu.dot(Cu);let n=Cu.dot(Iu)/i;return e&&(n=ut(n,0,1)),n}closestPointToPoint(t,e,i){const n=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(n).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 Lu 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}}Lu.prototype.isImmediateRenderObject=!0;const Du=new Ct,Ru=new Ct,Ou=new se,ku=new se;class Nu extends Xs{constructor(t){const e=Bu(t),i=new wi,n=[],r=[],o=new Je(0,0,1),s=new Je(0,1,0);for(let t=0;t.99999)this.quaternion.set(0,0,0,1);else if(t.y<-.99999)this.quaternion.set(1,0,0,0);else{Qu.set(t.z,0,-t.x).normalize();const e=Math.acos(t.y);this.quaternion.setFromAxisAngle(Qu,e)}}setLength(t,e=.2*t,i=.2*e){this.line.scale.set(1,Math.max(1e-4,t-e),1),this.line.updateMatrix(),this.cone.scale.set(i,e,i),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=tu,t.AudioAnalyser=ou,t.AudioContext=Gc,t.AudioListener=class extends Le{constructor(){super(),this.type="AudioListener",this.context=Gc.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Zc}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,i=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Qc,Jc,Kc),$c.set(0,0,-1).applyQuaternion(Jc),e.positionX){const t=this.context.currentTime+this.timeDelta;e.positionX.linearRampToValueAtTime(Qc.x,t),e.positionY.linearRampToValueAtTime(Qc.y,t),e.positionZ.linearRampToValueAtTime(Qc.z,t),e.forwardX.linearRampToValueAtTime($c.x,t),e.forwardY.linearRampToValueAtTime($c.y,t),e.forwardZ.linearRampToValueAtTime($c.z,t),e.upX.linearRampToValueAtTime(i.x,t),e.upY.linearRampToValueAtTime(i.y,t),e.upZ.linearRampToValueAtTime(i.z,t)}else e.setPosition(Qc.x,Qc.y,Qc.z),e.setOrientation($c.x,$c.y,$c.z,i.x,i.y,i.z)}},t.AudioLoader=jc,t.AxesHelper=$u,t.AxisHelper=function(t){return console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper."),new $u(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 sc(t)},t.Bone=Ts,t.BooleanKeyframeTrack=jl,t.BoundingBoxHelper=function(t,e){return console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead."),new Yu(t,e)},t.Box2=Tu,t.Box3=Dt,t.Box3Helper=class extends Xs{constructor(t,e=16776960){const i=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]),n=new wi;n.setIndex(new ei(i,1)),n.setAttribute("position",new ui([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(n,new zs({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=Gi,t.BoxGeometry=Gi,t.BoxHelper=Yu,t.BufferAttribute=ei,t.BufferGeometry=wi,t.BufferGeometryLoader=Rc,t.ByteType=1010,t.Cache=Kl,t.Camera=Xi,t.CameraHelper=class extends Xs{constructor(t){const e=new wi,i=new zs({color:16777215,vertexColors:!0,toneMapped:!1}),n=[],r=[],o={},s=new Je(16755200),a=new Je(16711680),l=new Je(43775),c=new Je(16777215),u=new Je(3355443);function h(t,e,i){p(t,i),p(e,i)}function p(t,e){n.push(0,0,0),r.push(e.r,e.g,e.b),void 0===o[t]&&(o[t]=[]),o[t].push(n.length/3-1)}h("n1","n2",s),h("n2","n4",s),h("n4","n3",s),h("n3","n1",s),h("f1","f2",s),h("f2","f4",s),h("f4","f3",s),h("f3","f1",s),h("n1","f1",s),h("n2","f2",s),h("n3","f3",s),h("n4","f4",s),h("p","n1",a),h("p","n2",a),h("p","n3",a),h("p","n4",a),h("u1","u2",l),h("u2","u3",l),h("u3","u1",l),h("c","t",c),h("p","c",u),h("cn1","cn2",u),h("cn3","cn4",u),h("cf1","cf2",u),h("cf3","cf4",u),e.setAttribute("position",new ui(n,3)),e.setAttribute("color",new ui(r,3)),super(e,i),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;qu.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Xu("c",e,t,qu,0,0,-1),Xu("t",e,t,qu,0,0,1),Xu("n1",e,t,qu,-1,-1,-1),Xu("n2",e,t,qu,1,-1,-1),Xu("n3",e,t,qu,-1,1,-1),Xu("n4",e,t,qu,1,1,-1),Xu("f1",e,t,qu,-1,-1,1),Xu("f2",e,t,qu,1,-1,1),Xu("f3",e,t,qu,-1,1,1),Xu("f4",e,t,qu,1,1,1),Xu("u1",e,t,qu,.7,1.1,-1),Xu("u2",e,t,qu,-.7,1.1,-1),Xu("u3",e,t,qu,0,2,-1),Xu("cf1",e,t,qu,-1,0,1),Xu("cf2",e,t,qu,1,0,1),Xu("cf3",e,t,qu,0,-1,1),Xu("cf4",e,t,qu,0,1,1),Xu("cn1",e,t,qu,-1,0,-1),Xu("cn2",e,t,qu,1,0,-1),Xu("cn3",e,t,qu,0,-1,-1),Xu("cn4",e,t,qu,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=ra,t.CatmullRomCurve3=Ea,t.CineonToneMapping=3,t.CircleBufferGeometry=sa,t.CircleGeometry=sa,t.ClampToEdgeWrapping=h,t.Clock=Zc,t.Color=Je,t.ColorKeyframeTrack=Hl,t.CompressedTexture=na,t.CompressedTextureLoader=class extends ec{constructor(t){super(t)}load(t,e,i,n){const r=this,o=[],s=new na,a=new nc(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(r.withCredentials);let l=0;function c(c){a.load(t[c],(function(t){const i=r.parse(t,!0);o[c]={width:i.width,height:i.height,format:i.format,mipmaps:i.mipmaps},l+=1,6===l&&(1===i.mipmapCount&&(s.minFilter=g),s.image=o,s.format=i.format,s.needsUpdate=!0,e&&e(s))}),i,n)}if(Array.isArray(t))for(let e=0,i=t.length;e>16&32768,n=e>>12&2047;const r=e>>23&255;return r<103?i:r>142?(i|=31744,i|=(255==r?0:1)&&8388607&e,i):r<113?(n|=2048,i|=(n>>114-r)+(n>>113-r&1),i):(i|=r-112<<10|n>>1,i+=1&n,i)}},t.DecrementStencilOp=7683,t.DecrementWrapStencilOp=34056,t.DefaultLoadingManager=tc,t.DepthFormat=T,t.DepthStencilFormat=I,t.DepthTexture=oa,t.DirectionalLight=Sc,t.DirectionalLightHelper=class extends Le{constructor(t,e,i){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i,void 0===e&&(e=1);let n=new wi;n.setAttribute("position",new ui([-e,e,0,e,e,0,e,-e,0,-e,-e,0,-e,e,0],3));const r=new zs({fog:!1,toneMapped:!1});this.lightPlane=new Hs(n,r),this.add(this.lightPlane),n=new wi,n.setAttribute("position",new ui([0,0,0,0,0,1],3)),this.targetLine=new Hs(n,r),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){Gu.setFromMatrixPosition(this.light.matrixWorld),ju.setFromMatrixPosition(this.light.target.matrixWorld),Hu.subVectors(ju,Gu),this.lightPlane.lookAt(ju),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(ju),this.targetLine.scale.z=Hu.length()}},t.DiscreteInterpolant=Ul,t.DodecahedronBufferGeometry=ua,t.DodecahedronGeometry=ua,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 ei(t,e).setUsage(it)},t.DynamicCopyUsage=35050,t.DynamicDrawUsage=it,t.DynamicReadUsage=35049,t.EdgesGeometry=ma,t.EdgesHelper=function(t,e){return console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead."),new Xs(new ma(t.geometry),new zs({color:void 0!==e?e:16777215}))},t.EllipseCurve=ya,t.EqualDepth=4,t.EqualStencilFunc=514,t.EquirectangularReflectionMapping=s,t.EquirectangularRefractionMapping=a,t.Euler=ge,t.EventDispatcher=rt,t.ExtrudeBufferGeometry=ul,t.ExtrudeGeometry=ul,t.FaceColors=1,t.FileLoader=nc,t.FlatShading=1,t.Float16BufferAttribute=ci,t.Float32Attribute=function(t,e){return console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead."),new ui(t,e)},t.Float32BufferAttribute=ui,t.Float64Attribute=function(t,e){return console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead."),new hi(t,e)},t.Float64BufferAttribute=hi,t.FloatType=w,t.Fog=Jo,t.FogExp2=Qo,t.Font=Fc,t.FontLoader=class extends ec{constructor(t){super(t)}load(t,e,i,n){const r=this,o=new nc(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(r.withCredentials),o.load(t,(function(t){let i;try{i=JSON.parse(t)}catch(e){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),i=JSON.parse(t.substring(65,t.length-2))}const n=r.parse(i);e&&e(n)}),i,n)}parse(t){return new Fc(t)}},t.FrontSide=0,t.Frustum=sn,t.GLBufferAttribute=Au,t.GLSL1="100",t.GLSL3=nt,t.GammaEncoding=Y,t.GreaterDepth=6,t.GreaterEqualDepth=5,t.GreaterEqualStencilFunc=518,t.GreaterStencilFunc=516,t.GridHelper=Uu,t.Group=jo,t.HalfFloatType=A,t.HemisphereLight=pc,t.HemisphereLightHelper=class extends Le{constructor(t,e,i){super(),this.light=t,this.light.updateMatrixWorld(),this.matrix=t.matrixWorld,this.matrixAutoUpdate=!1,this.color=i;const n=new fl(e);n.rotateY(.5*Math.PI),this.material=new Ke({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const r=n.getAttribute("position"),o=new Float32Array(3*r.count);n.setAttribute("color",new ei(o,3)),this.add(new Vi(n,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");Fu.copy(this.light.color),Vu.copy(this.light.groundColor);for(let t=0,i=e.count;t0){const i=new $l(e);r=new rc(i),r.setCrossOrigin(this.crossOrigin);for(let e=0,i=t.length;e0){n=new rc(this.manager),n.setCrossOrigin(this.crossOrigin);for(let e=0,n=t.length;e90))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}},t.exports=i}(dd);var fd=dd.exports;!function(t,e){var i=ld,n=pd,r={prettyPrintMatrix:function(t){for(var e=0;e<4;e++){var i=[t[e],t[e+4],t[e+8],t[e+12]];console.log(i.map((function(t){return t.toFixed(4)})))}},makePerspectiveMatrix:function(t,e,n,r){var o=new i.Matrix4,s=1/Math.tan(t/2),a=1/(n-r),l=[s/e,0,0,0,0,s,0,0,0,0,(r+n)*a,-1,0,0,2*r*n*a,0];return o.elements=l,o},makeOrthographicMatrix:function(t,e,n,r,o,s){var a=new i.Matrix4;const l=1/(e-t),c=1/(n-r),u=1/(s-o);var h=[2*l,0,0,0,0,2*c,0,0,0,0,-1*u,0,-((e+t)*l),-((n+r)*c),-(o*u),1];return a.elements=h,a},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=[-n.MERCATOR_A*n.DEG2RAD*t[0]*n.PROJECTION_WORLD_SIZE,-n.MERCATOR_A*Math.log(Math.tan(.25*Math.PI+.5*n.DEG2RAD*t[1]))*n.PROJECTION_WORLD_SIZE];if(t[2]){var r=this.projectedUnitsPerMeter(t[1]);e.push(t[2]*r)}else e.push(0);return new i.Vector3(e[0],e[1],e[2])},projectedUnitsPerMeter:function(t){return Math.abs(n.WORLD_SIZE/Math.cos(n.DEG2RAD*t)/n.EARTH_CIRCUMFERENCE)},_circumferenceAtLatitude:function(t){return n.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180)},mercatorZfromAltitude:function(t,e){return t/this._circumferenceAtLatitude(e)},_scaleVerticesToMeters:function(t,e){var i=this.projectedUnitsPerMeter(t[1]);this.projectToWorld(t);for(var n=0;n{let{width:n,color:r}=e,o=(new i.BufferGeometry).setFromPoints(t.getPoints(100)),s=new i.LineBasicMaterial({color:r,linewidth:n});return new i.Line(o,s)},curvesToLines:t=>{var e=[16711680,2031360,2490623],i=t.map(((t,i)=>curveToLine(t,{width:3,color:e[i]||"purple"})));return i},_validate:function(t,e){t=t||{};var i={};r.extend(i,t);for(let n of Object.keys(e))if(void 0===t[n]){if(null===e[n])return void console.error(n+" is required");i[n]=e[n]}else i[n]=t[n];return i},Validator:new fd,exposedMethods:["projectToWorld","projectedUnitsPerMeter","extend","unprojectFromWorld"]};t.exports=r}(ud);var md=ud.exports;!function(t,e){const i=ld,n=md,r=pd;function o(t,e,n){this.map=t,this.camera=e,this.active=!0,this.camera.matrixAutoUpdate=!1,this.world=n||new i.Group,this.world.position.x=this.world.position.y=r.WORLD_SIZE/2,this.world.matrixAutoUpdate=!1,this.state={translateCenter:(new i.Matrix4).makeTranslation(r.WORLD_SIZE/2,-r.WORLD_SIZE/2,0),worldSizeRatio:r.TILE_SIZE/r.WORLD_SIZE,worldSize:r.TILE_SIZE*this.map.transform.scale};let o=this;this.map.on("move",(function(){o.updateCamera()})).on("resize",(function(){o.setupCamera()})),this.setupCamera()}o.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 r=e.centerOffset||new i.Vector3;let s=0,a=0;this.halfFov=e._fov/2;const l=Math.PI/2+e._pitch,c=Math.cos(Math.PI/2-e._pitch);this.cameraToCenterDistance=.5/Math.tan(this.halfFov)*e.height;let u=1;const h=this.worldSize();if(this.map.tb.mapboxVersion>=2){u=this.mercatorZfromAltitude(1,e.center.lat)*h;const t=e._fov*(.5+e.centerOffset.y/e.height),i=e.elevation?e.elevation.getMinElevationBelowMSL()*u:0,r=(e._camera.position[2]*h-i)/Math.cos(e._pitch);a=c*(Math.sin(t)*r/Math.sin(n.clamp(Math.PI-l-t,.01,Math.PI-.01)))+r;const o=r*(1/e._horizonShift);s=Math.min(1.01*a,o)}else{a=c*(Math.sin(this.halfFov)*this.cameraToCenterDistance/Math.sin(Math.PI-l-this.halfFov))+this.cameraToCenterDistance,s=1.01*a}this.cameraTranslateZ=(new i.Matrix4).makeTranslation(0,0,this.cameraToCenterDistance);const p=e.height/50,d=Math.max(p*c,p),f=e.height,m=e.width;this.camera instanceof i.OrthographicCamera?this.camera.projectionMatrix=n.makeOrthographicMatrix(m/-2,m/2,f/2,f/-2,d,s):this.camera.projectionMatrix=n.makePerspectiveMatrix(e._fov,m/f,d,s),this.camera.projectionMatrix.elements[8]=2*-r.x/e.width,this.camera.projectionMatrix.elements[9]=2*r.y/e.height;let g=this.calcCameraMatrix(e._pitch,e.angle);e.elevation&&(g.elements[14]=e._camera.position[2]*h),this.camera.matrixWorld.copy(g);let y=e.scale*this.state.worldSizeRatio,v=new i.Matrix4,_=new i.Matrix4,x=new i.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 i.Matrix4).premultiply(x).premultiply(this.state.translateCenter).premultiply(v).premultiply(_),this.map.fire("CameraSynced",{detail:{nearZ:d,farZ:s,pitch:e._pitch,angle:e.angle,furthestDistance:a,cameraToCenterDistance:this.cameraToCenterDistance,t:this.map.transform,tbProjMatrix:this.camera.projectionMatrix.elements,tbWorldMatrix:this.world.matrix.elements,cameraSyn:o}})},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=>r.EARTH_CIRCUMFERENCE*Math.cos(t*Math.PI/180),calcCameraMatrix(t,e,n){const r=this.map.transform,o=void 0===t?r._pitch:t,s=void 0===e?r.angle:e,a=void 0===n?this.cameraTranslateZ:n;return(new i.Matrix4).premultiply(a).premultiply((new i.Matrix4).makeRotationX(o)).premultiply((new i.Matrix4).makeRotationZ(s))},updateCameraState(){let t=this.map.transform;if(!t.height)return;const e=t._camera.forward(),i=t.cameraToCenterDistance,n=t.point;t._cameraZoom?t._cameraZoom:t._zoom;const r=this.mercatorZfromZoom(t)-this.mercatorZfromAltitude(t._centerAltitude,t.center.lat),o=t.cameraToCenterDistance/r;return[n.x/this.worldSize()-e[0]*i/o,n.y/this.worldSize()-e[1]*i/o,this.mercatorZfromAltitude(t._centerAltitude,t._center.lat)+-e[2]*i/o]},getWorldToCamera(t,e){let n=this.map.transform;const r=new i.Matrix4,o=new i.Matrix4,s=n._camera._orientation,a=n._camera.position,l=new i.Vector3(a[0],a[1],a[2]),c=new i.Quaternion;c.set(s[0],s[1],s[2],s[3]);const u=c.conjugate();return l.multiplyScalar(-t),o.makeTranslation(l.x,l.y,l.z),r.makeRotationFromQuaternion(u).premultiply(o),r.elements[1]*=-1,r.elements[5]*=-1,r.elements[9]*=-1,r.elements[13]*=-1,r.elements[8]*=e,r.elements[9]*=e,r.elements[10]*=e,r.elements[11]*=e,r},translate(t,e,i){let n,r,o,s,a,l,c,u,h,p,d,f,m=i[0]||i.x,g=i[1]||i.y,y=i[2]||i.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]):(n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],f=e[11],t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=c,t[7]=u,t[8]=h,t[9]=p,t[10]=d,t[11]=f,t[12]=n*m+a*g+h*y+e[12],t[13]=r*m+l*g+p*y+e[13],t[14]=o*m+c*g+d*y+e[14],t[15]=s*m+u*g+f*y+e[15]),t}},t.exports=o}(cd);var gd=cd.exports,yd={exports:{}};!function(t,e){!function(){var e=Math.PI,i=Math.sin,n=Math.cos,r=Math.tan,o=Math.asin,s=Math.atan2,a=Math.acos,l=e/180,c=864e5,u=2440588,h=2451545;function p(t){return t.valueOf()/c-.5+u}function d(t){return new Date((t+.5-u)*c)}function f(t){return p(t)-h}var m=23.4397*l;function g(t,e){return s(i(t)*n(m)-r(e)*i(m),n(t))}function y(t,e){return o(i(e)*n(m)+n(e)*i(m)*i(t))}function v(t,e,o){return s(i(t),n(t)*i(e)-r(o)*n(e))}function _(t,e,r){return o(i(e)*i(r)+n(e)*n(r)*n(t))}function x(t,e){return l*(280.16+360.9856235*t)-e}function b(t){return l*(357.5291+.98560028*t)}function w(t){return t+l*(1.9148*i(t)+.02*i(2*t)+3e-4*i(3*t))+102.9372*l+e}function A(t){var e=w(b(t));return{dec:y(e,0),ra:g(e,0)}}var E={getPosition:function(t,e,i){var n=l*-i,r=l*e,o=f(t),s=A(o),a=x(o,n)-s.ra;return{azimuth:v(a,r,s.dec),altitude:_(a,r,s.dec)}},toJulian:function(t){return p(t)}},S=E.times=[[-.833,"sunrise","sunset"],[-.3,"sunriseEnd","sunsetStart"],[-6,"dawn","dusk"],[-12,"nauticalDawn","nauticalDusk"],[-18,"nightEnd","night"],[6,"goldenHourEnd","goldenHour"]];E.addTime=function(t,e,i){S.push([t,e,i])};var M=9e-4;function T(t,i,n){return M+(t+i)/(2*e)+n}function I(t,e,n){return h+t+.0053*i(e)-.0069*i(2*n)}function C(t,e,r,o,s,l,c){var u=function(t,e,r){return a((i(t)-i(e)*i(r))/(n(e)*n(r)))}(t,r,o);return I(T(u,e,s),l,c)}function P(t){var e=l*(134.963+13.064993*t),r=l*(93.272+13.22935*t),o=l*(218.316+13.176396*t)+6.289*l*i(e),s=5.128*l*i(r),a=385001-20905*n(e);return{ra:g(o,s),dec:y(o,s),dist:a}}function L(t,e){return new Date(t.valueOf()+e*c/24)}E.getTimes=function(t,i,n,r){var o,s,a,c,u,h=l*-n,p=l*i,m=function(t){return-2.076*Math.sqrt(t)/60}(r=r||0),g=function(t,i){return Math.round(t-M-i/(2*e))}(f(t),h),v=T(0,h,g),_=b(v),x=w(_),A=y(x,0),E=I(v,_,x),P={solarNoon:d(E),nadir:d(E-.5)};for(o=0,s=S.length;o=0&&(g=p-(v=Math.sqrt(f)/(2*Math.abs(u))),y=p+v,Math.abs(g)<=1&&m++,Math.abs(y)<=1&&m++,g<-1&&(g=y)),1===m?x<0?a=b+g:c=b+g:2===m&&(a=b+(d<0?y:g),c=b+(d<0?g:y)),!a||!c);b+=2)x=s;var w={};return a&&(w.rise=L(r,a)),c&&(w.set=L(r,c)),a||c||(w[d>0?"alwaysUp":"alwaysDown"]=!0),w},t.exports=E}()}(yd);var vd=yd.exports,_d={exports:{}},xd={exports:{}};!function(t,e){var i=md,n=ld,r={material:"MeshBasicMaterial",color:"black",opacity:1};t.exports=function(t){var e;function o(){return new n[r.material]({color:r.color})}return t?((e=(t=i._validate(t,r)).material&&t.material.isMaterial?t.material:t.material||t.color||t.opacity?new n[t.material]({color:t.color,transparent:t.opacity<1}):o()).opacity=t.opacity,t.side&&(e.side=t.side)):e=o(),e}}(xd);var bd=xd.exports,wd={exports:{}};!function(t,e){const i=ld,n=md;function r(t){this.map=t,this.enrolledObjects=[],this.previousFrameTime}r.prototype={unenroll:function(t){this.enrolledObjects.splice(this.enrolledObjects.indexOf(t),1)},enroll:function(t){if(t.clock=new i.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 i.AnimationMixer(t),e(n)}function e(e){for(let i=0;it.animations.length&&console.log("The animation index "+e+" doesn't exist for this object");let n=t.animations[i],r=t.mixer.clipAction(n);t.actions.push(r),e===i?(t.defaultAction=r,r.setEffectiveWeight(1)):r.setEffectiveWeight(0),r.play()}}let r=!1;Object.defineProperty(t,"isPlaying",{get:()=>r,set(e){r!=e&&(r=e,t.dispatchEvent({type:"IsPlayingChanged",detail:t}))}}),this.enrolledObjects.push(t),t.animationQueue=[],t.set=function(e){if(e.duration>0){let r={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};n.extend(e,r);let o=e.coords,s=e.rotation,a=e.scale||e.scaleX||e.scaleY||e.scaleZ;if(s){let i=t.rotation;e.startRotation=[i.x,i.y,i.z],e.endState.rotation=n.types.rotation(e.rotation,e.startRotation),e.rotationPerMs=e.endState.rotation.map((function(t,i){return(t-e.startRotation[i])/e.duration}))}if(a){let i=t.scale;e.startScale=[i.x,i.y,i.z],e.endState.scale=n.types.scale(e.scale,e.startScale),e.scalePerMs=e.endState.scale.map((function(t,i){return(t-e.startScale[i])/e.duration}))}o&&(e.pathCurve=new i.CatmullRomCurve3(n.lnglatsToWorld([t.coordinates,e.coords])));let l={type:"set",parameters:e};this.animationQueue.push(l),tb.map.repaint=!0}else this.stop(),e.rotation=n.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 r={type:"followPath",parameters:n._validate(t,o.followPath)};return n.extend(r.parameters,{pathCurve:new i.CatmullRomCurve3(n.lnglatsToWorld(t.path)),start:Date.now(),expiration:Date.now()+r.parameters.duration,cb:e}),this.animationQueue.push(r),tb.map.repaint=!0,this},t._setObject=function(e){t.setScale();let r=e.position,o=e.rotation,s=e.scale,a=e.worldCoordinates,l=e.quaternion,c=e.translate,u=e.worldTranslate;if(r){this.coordinates=r;let t=n.projectToWorld(r);this.position.copy(t)}if(c){this.coordinates=[this.coordinates[0]+c[0],this.coordinates[1]+c[1],this.coordinates[2]+c[2]];let t=n.projectToWorld(c);this.position.copy(t),e.position=this.coordinates}if(u){this.translateX(u.x),this.translateY(u.y),this.translateZ(u.z);let t=n.unprojectFromWorld(this.position);this.coordinates=e.position=t}if(o&&(this.rotation.set(o[0],o[1],o[2]),e.rotation=new i.Vector3(o[0],o[1],o[2])),s&&(this.scale.set(s[0],s[1],s[2]),e.scale=this.scale),l&&(this.quaternion.setFromAxisAngle(l[0],l[1]),e.rotation=l[0].multiplyScalar(l[1])),a){this.position.copy(a);let t=n.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 i={start:Date.now(),expiration:Date.now()+e.duration,endState:{}};n.extend(e,i),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(i){t.mixer&&(i.animation&&e(i.animation),t.playDefault(i))},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 r=n.animationQueue[e];if(!r)continue;let o=r.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"===r.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"===r.type){let t={};o.pathCurve&&(t.worldCoordinates=o.pathCurve.getPoint(e)),o.rotationPerMs&&(t.rotation=o.startRotation.map((function(t,i){return t+o.rotationPerMs[i]*e*o.duration}))),o.scalePerMs&&(t.scale=o.startScale.map((function(t,i){return t+o.scalePerMs[i]*e*o.duration}))),n._setObject(t)}if("followPath"===r.type){let t={worldCoordinates:o.pathCurve.getPointAt(e)};if(o.trackHeading){let n=o.pathCurve.getTangentAt(e).normalize(),r=new i.Vector3(0,0,0),s=new i.Vector3(0,1,0);r.crossVectors(s,n).normalize();let a=Math.acos(s.dot(n));t.quaternion=[r,a]}n._setObject(t)}"playDefault"===r.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 o={followPath:{path:null,duration:1e3,trackHeading:!0}};t.exports=r}(wd);var Ad=wd.exports,Ed={exports:{}};!function(t,e){const i=ld;!function(){class t extends i.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 i.Vector3,n=new i.Matrix4,r=new i.Matrix4,o=new i.Vector3,s=new i.Vector3;i.CSS2DObject=t,i.CSS2DRenderer=class{constructor(){const t=this;let i,a,l,c;const u={objects:new WeakMap,list:new Map};this.cacheList=u.list;const h=document.createElement("div");function p(i,n,o){if(i.isCSS2DObject)if(i.visible){i.onBeforeRender(t,n,o),e.setFromMatrixPosition(i.matrixWorld),e.applyMatrix4(r);const a=i.element;var s;s=/apple/i.test(navigator.vendor)?"translate(-50%,-50%) translate("+Math.round(e.x*l+l)+"px,"+Math.round(-e.y*c+c)+"px)":"translate(-50%,-50%) translate("+(e.x*l+l)+"px,"+(-e.y*c+c)+"px)",a.style.WebkitTransform=s,a.style.MozTransform=s,a.style.oTransform=s,a.style.transform=s,a.style.display=i.visible&&e.z>=-1&&e.z<=1?"":"none";const p={distanceToCameraSquared:d(o,i)};u.objects.set({key:i.uuid},p),u.list.set(i.uuid,i),a.parentNode!==h&&h.appendChild(a),i.onAfterRender(t,n,o)}else u.objects.delete({key:i.uuid}),u.list.delete(i.uuid),i.remove();for(let t=0,e=i.children.length;tt.getObjectByName("model")}),Object.defineProperty(t,"animations",{get(){const e=t.model;return e?e.animations:null}}),r.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:i.radify(e.x)||t.rotation.x,y:i.radify(e.y)||t.rotation.y,z:i.radify(e.z)||t.rotation.z};t._setObject({rotation:[n.x,n.y,n.z]})},t.calculateAdjustedPosition=function(e,n,r){let o=e.slice(),s=i.unprojectFromWorld(t.modelSize);return r?(o[0]-=0!=n.x?s[0]/n.x:0,o[1]-=0!=n.y?s[1]/n.y:0,o[2]-=0!=n.z?s[2]/n.z:0):(o[0]+=0!=n.x?s[0]/n.x:0,o[1]+=0!=n.y?s[1]/n.y:0,o[2]+=0!=n.z?s[2]/n.z:0),o},t.setRotationAxis=function(e){"number"==typeof e&&(e={z:e});let i=t.modelBox(),r=new n.Vector3(i.max.x,i.max.y,i.min.z);0!=e.x&&p(t,r,new n.Vector3(0,0,1),e.x),0!=e.y&&p(t,r,new n.Vector3(0,0,1),e.y),0!=e.z&&p(t,r,new n.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(),i=new n.Group;i.name="boxGroup",i.updateMatrixWorld(!0);let r=new n.Box3Helper(e,a.prototype._defaults.colors.yellow);r.name="boxModel",i.add(r),r.layers.disable(0);let o=e.clone();o.max.z=o.min.z;let s=new n.Box3Helper(o,a.prototype._defaults.colors.black);s.name="boxShadow",i.add(s),s.layers.disable(0),i.visible=!1,t.scaleGroup.add(i),t.setBoundingBoxShadowFloor()},t.setBoundingBoxShadowFloor=function(){if(t.boundingBoxShadow){let e=-t.modelHeight,i=t.rotation,n=t.boundingBoxShadow;n.box.max.z=n.box.min.z=e,n.rotation.y=i.y,n.rotation.x=-i.x}},t.setAnchor=function(e){const i=t.box3(),r=i.getCenter(new n.Vector3);switch(t.none={x:0,y:0,z:0},t.center={x:r.x,y:r.y,z:i.min.z},t.bottom={x:r.x,y:i.max.y,z:i.min.z},t.bottomLeft={x:i.max.x,y:i.max.y,z:i.min.z},t.bottomRight={x:i.min.x,y:i.max.y,z:i.min.z},t.top={x:r.x,y:i.min.y,z:i.min.z},t.topLeft={x:i.max.x,y:i.min.y,z:i.min.z},t.topRight={x:i.min.x,y:i.min.y,z:i.min.z},t.left={x:i.max.x,y:r.y,z:i.min.z},t.right={x:i.min.x,y:r.y,z:i.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 i=t.getSize();t.anchor={x:t.anchor.x-i.x*e.x,y:t.anchor.y-i.y*e.y,z:t.anchor.z-i.z*e.z},t.model.position.set(-t.anchor.x,-t.anchor.y,-t.anchor.z)}},Object.defineProperty(t,"label",{get:()=>t.getObjectByName(o)}),Object.defineProperty(t,"tooltip",{get:()=>t.getObjectByName(l)}),Object.defineProperty(t,"help",{get:()=>t.getObjectByName(c)});let d=!1;Object.defineProperty(t,"hidden",{get:()=>d,set(e){d!=e&&(d=e,t.visibility=!d)}}),Object.defineProperty(t,"visibility",{get:()=>t.visible,set(e){let i=e;if("visible"==e||1==e)i=!0,t.label&&(t.label.visible=i);else{if("none"!=e&&0!=e)return;i=!1,t.label&&t.label.alwaysVisible&&(t.label.visible=i),t.tooltip&&(t.tooltip.visible=i)}if(t.visible!=i){if(t.hidden&&i)return;t.visible=i,t.model&&t.model.traverse((function(e){"Mesh"!=e.type&&"SkinnedMesh"!=e.type||(i&&t.raycasted?e.layers.enable(0):e.layers.disable(0)),"LineSegments"==e.type&&e.layers.disableAll()}))}}}),t.addLabel=function(e,i,n,r){e&&t.drawLabelHTML(e,i,n,r)},t.removeLabel=function(){t.removeCSS2D(o)},t.drawLabelHTML=function(e,i=!1,n=t.anchor,s=.5){let l=r.drawLabelHTML(e,a.prototype._defaults.label.cssClass),c=t.addCSS2D(l,o,n,s);return c.alwaysVisible=i,c.visible=i,c},t.addTooltip=function(e,i,n,r=!0,o=1){let s=t.addHelp(e,l,i,n,o);s.visible=!1,s.custom=r},t.removeTooltip=function(){t.removeCSS2D(l)},t.addHelp=function(e,i=c,n=!1,o=t.anchor,s=0){let a=r.drawTooltip(e,n),l=t.addCSS2D(a,i,o,s);return l.visible=!0,l},t.removeHelp=function(){t.removeCSS2D(c)},t.addCSS2D=function(e,i,r=t.anchor,o=1){if(e){const a=t.box3(),l=a.getSize(new n.Vector3);let c={x:a.max.x,y:a.max.y,z:a.min.z};t.removeCSS2D(i);let u=new s.CSS2DObject(e);return u.name=i,u.position.set(.5*-l.x-t.model.position.x-r.x+c.x,.5*-l.y-t.model.position.y-r.y+c.y,l.z*o),u.visible=!1,t.scaleGroup.add(u),u}},t.removeCSS2D=function(e){let i=t.getObjectByName(e);if(i){i.dispose();let e=t.scaleGroup.children;e.splice(e.indexOf(i),1)}},Object.defineProperty(t,"shadowPlane",{get:()=>t.getObjectByName(u)});let f=!1;Object.defineProperty(t,"castShadow",{get:()=>f,set(e){if(t.model&&f!==e){if(t.model.traverse((function(t){t.isMesh&&(t.castShadow=!0)})),e){const i=t.modelSize,r=[i.x,i.y,i.z,t.modelHeight],o=10*Math.max(...r),s=new n.PlaneBufferGeometry(o,o),a=new n.ShadowMaterial;a.opacity=.5;let l=new n.Mesh(s,a);l.name=u,l.layers.enable(1),l.layers.disable(0),l.receiveShadow=e,t.add(l)}else t.traverse((function(e){e.isMesh&&e.material instanceof n.ShadowMaterial&&t.remove(e)}));f=e}}}),t.setReceiveShadowFloor=function(){if(t.castShadow){let e=t.shadowPlane,i=e.position,n=e.rotation;if(i.z=-t.modelHeight,n.y=t.rotation.y,n.x=-t.rotation.x,"meters"===t.userData.units){const n=t.modelSize,r=[n.x,n.y,n.z,-i.z],o=10*Math.max(...r)/e.geometry.parameters.width;e.scale.set(o,o,o)}}};let m=!1;Object.defineProperty(t,"receiveShadow",{get:()=>m,set(e){t.model&&m!==e&&(t.model.traverse((function(t){t.isMesh&&(t.receiveShadow=!0)})),m=e)}});let g=!1;Object.defineProperty(t,"wireframe",{get:()=>g,set(e){t.model&&g!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let i=[];Array.isArray(t.material)?i=t.material:i.push(t.material);let n=i[0];e?(t.userData.materials=n,t.material=n.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()})),g=e,t.dispatchEvent({type:"Wireframed",detail:t}))}});let y=null;Object.defineProperty(t,"color",{get:()=>y,set(e){t.model&&y!==e&&(t.model.traverse((function(t){if("Mesh"==t.type||"SkinnedMesh"==t.type){let i=[];Array.isArray(t.material)?i=t.material:i.push(t.material);let r=i[0];e?(t.userData.materials=r,t.material=new n.MeshStandardMaterial,t.material.color.setHex(e)):(t.material.dispose(),t.material=t.userData.materials,t.userData.materials.dispose(),t.userData.materials=null)}})),y=e)}});let v=!1;Object.defineProperty(t,"selected",{get:()=>v,set(e){e?(t.userData.bbox&&!t.boundingBox&&t.drawBoundingBox(),t.boxGroup&&(t.boundingBox.material=a.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),v!=e&&(v=e,t.dispatchEvent({type:"SelectedChange",detail:t}))}});let _=!0;Object.defineProperty(t,"raycasted",{get:()=>_,set(e){t.model&&_!==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)))})),_=e)}});let x=!1;Object.defineProperty(t,"over",{get:()=>x,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=a.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),x=e}}),t.box3=function(){let e;if(t.updateMatrix(),t.updateMatrixWorld(!0,!0),t.model){let i=t.clone(!0),r=t.model.clone();if(e=(new n.Box3).setFromObject(r),t.parent){let o=new n.Matrix4,s=new n.Matrix4;t.matrix.extractRotation(o),s.copy(o).invert(),i.setRotationFromMatrix(s),e=(new n.Box3).setFromObject(r)}}return e},t.modelBox=function(){return t.box3()},t.getSize=function(){return t.box3().getSize(new n.Vector3(0,0,0))};let b=!1;Object.defineProperty(t,"modelSize",{get:()=>(b=t.getSize(),b),set(t){b!=t&&(b=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(i.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 n=(i=t.fixedZoom,Math.pow(2,i));if(n>e){let i=n/e;t.scale.set(i,i,i)}else t.scale.set(1,1,1)}var i},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)h(t.material);else for(const e of t.material)h(e);t.dispose&&t.dispose()})),t.scaleGroup.remove(e),tb.map.repaint=!0)},t.duplicate=function(e){let n=t.clone(!0);if(n.getObjectByName("model").animations=t.animations,n.userData.feature&&(e&&e.feature&&(n.userData.feature=e.feature),n.userData.feature.properties.uuid=n.uuid),r._addMethods(n),!e||i.equal(e.scale,t.userData.scale))return n.copyAnchor(t),n;{n.userData=e,n.userData.isGeoGroup=!0,n.remove(n.boxGroup);const t=i.types.rotation(e.rotation,[0,0,0]),r=i.types.scale(e.scale,[1,1,1]);return n.model.position.set(0,0,0),n.model.rotation.set(t[0],t[1],t[2]),n.model.scale.set(r[0],r[1],r[2]),n.setAnchor(e.anchor),n.setCenter(e.adjustment),n}},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(){a.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)h(t.material);else for(const e of t.material)h(e);t.dispose&&t.dispose()}})),t.children=[]};const h=t=>{t.dispose();for(const e of Object.keys(t)){const i=t[e];i&&"object"==typeof i&&"minFilter"in i&&i.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 i=new n.Group;i.name="scaleGroup",i.add(t);var r=new n.Group;if(r.userData=e||{},r.userData.isGeoGroup=!0,r.userData.feature&&(r.userData.feature.properties.uuid=r.uuid),i.length)for(o of i)r.add(o);else r.add(i);return r.name="threeboxObject",r},animationManager:new r,drawTooltip:function(t,e=!1){if(t){let i;if(e){let e=document.createElement("div");e.className="mapboxgl-popup-content";let n=document.createElement("strong");n.innerHTML=t,e.appendChild(n);let r=document.createElement("div");r.className="mapboxgl-popup-tip";let o=document.createElement("div");o.className="marker mapboxgl-popup-anchor-bottom",o.appendChild(r),o.appendChild(e),i=document.createElement("div"),i.className+="label3D",i.appendChild(o)}else i=document.createElement("span"),i.className=this._defaults.tooltip.cssClass,i.innerHTML=t;return i}},drawLabelHTML:function(t,e){let i=document.createElement("div");return i.className+=e,i.innerHTML="string"==typeof t?t:t.outerHTML,i},_defaults:{colors:{red:new n.Color(16711680),yellow:new n.Color(16776960),green:new n.Color(65280),black:new n.Color(0)},materials:{boxNormalMaterial:new n.LineBasicMaterial({color:new n.Color(16711680)}),boxOverMaterial:new n.LineBasicMaterial({color:new n.Color(16776960)}),boxSelectedMaterial:new n.LineBasicMaterial({color:new n.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 n.MeshPhongMaterial({color:6684672,side:n.DoubleSide}),scale:1,rotation:0,units:"scene",anchor:"center",bbox:!0,tooltip:!0,raycasted:!0}},geometries:{line:["LineString"],tube:["LineString"],sphere:["Point"]}},t.exports=a}(_d);var Md=_d.exports,Td={exports:{}},Id={exports:{}};!function(t,e){const i=Md,n=md;t.exports=function(t){let e=(t=n._validate(t,i.prototype._defaults.Object3D)).obj;const r=n.types.rotation(t.rotation,[0,0,0]),o=n.types.scale(t.scale,[1,1,1]);e.rotation.set(r[0],r[1],r[2]),e.scale.set(o[0],o[1],o[2]),e.name="model";let s=i.prototype._makeGroup(e,t);return t.obj.name="model",i.prototype._addMethods(s),s.setAnchor(t.anchor),s.setCenter(t.adjustment),s.raycasted=t.raycasted,s.visibility=!0,s}}(Id);var Cd=Id.exports;!function(t,e){const i=md,n=bd,r=ld,o=Md,s=Cd;t.exports=function(t){t=i._validate(t,o.prototype._defaults.sphere);let e=new r.SphereBufferGeometry(t.radius,t.sides,t.sides),a=n(t),l=new r.Mesh(e,a);return new s({obj:l,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})}}(Td);var Pd=Td.exports,Ld={exports:{}};!function(t,e){const i=Md,n=md,r=ld,o=Cd;function s(t){t=n._validate(t,i.prototype._defaults.extrusion);let e=s.prototype.buildShape(t.coordinates),a=s.prototype.buildGeometry(e,t.geometryOptions),l=new r.Mesh(a,t.materials);return t.obj=l,new o(t)}s.prototype={buildShape:function(t){if(t[0]instanceof(r.Vector2||r.Vector3))return new r.Shape(t);let e=new r.Shape;for(let i=0;i0?e[e.length-1]:"",smooth:void 0!==i?i.smooth:this.smooth,groupStart:void 0!==i?i.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(n),n},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}},i&&i.name&&"function"==typeof i.clone){const t=i.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 i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseNormalIndex:function(t,e){const i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},parseUVIndex:function(t,e){const i=parseInt(t,10);return 2*(i>=0?i-1:i+e/2)},addVertex:function(t,e,i){const n=this.vertices,r=this.object.geometry.vertices;r.push(n[t+0],n[t+1],n[t+2]),r.push(n[e+0],n[e+1],n[e+2]),r.push(n[i+0],n[i+1],n[i+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,i){const n=this.normals,r=this.object.geometry.normals;r.push(n[t+0],n[t+1],n[t+2]),r.push(n[e+0],n[e+1],n[e+2]),r.push(n[i+0],n[i+1],n[i+2])},addFaceNormal:function(t,e,i){const n=this.vertices,r=this.object.geometry.normals;o.fromArray(n,t),s.fromArray(n,e),a.fromArray(n,i),c.subVectors(a,s),l.subVectors(o,s),c.cross(l),c.normalize(),r.push(c.x,c.y,c.z),r.push(c.x,c.y,c.z),r.push(c.x,c.y,c.z)},addColor:function(t,e,i){const n=this.colors,r=this.object.geometry.colors;void 0!==n[t]&&r.push(n[t+0],n[t+1],n[t+2]),void 0!==n[e]&&r.push(n[e+0],n[e+1],n[e+2]),void 0!==n[i]&&r.push(n[i+0],n[i+1],n[i+2])},addUV:function(t,e,i){const n=this.uvs,r=this.object.geometry.uvs;r.push(n[t+0],n[t+1]),r.push(n[e+0],n[e+1]),r.push(n[i+0],n[i+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,i,n,r,o,s,a,l){const c=this.vertices.length;let u=this.parseVertexIndex(t,c),h=this.parseVertexIndex(e,c),p=this.parseVertexIndex(i,c);if(this.addVertex(u,h,p),this.addColor(u,h,p),void 0!==s&&""!==s){const t=this.normals.length;u=this.parseNormalIndex(s,t),h=this.parseNormalIndex(a,t),p=this.parseNormalIndex(l,t),this.addNormal(u,h,p)}else this.addFaceNormal(u,h,p);if(void 0!==n&&""!==n){const t=this.uvs.length;u=this.parseUVIndex(n,t),h=this.parseUVIndex(r,t),p=this.parseUVIndex(o,t),this.addUV(u,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 i=0,n=t.length;i=7?s.colors.push(parseFloat(t[4]),parseFloat(t[5]),parseFloat(t[6])):s.colors.push(void 0,void 0,void 0);break;case"vn":s.normals.push(parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3]));break;case"vt":s.uvs.push(parseFloat(t[1]),parseFloat(t[2]))}}else if("f"===c){const t=l.substr(1).trim().split(/\s+/),e=[];for(let i=0,n=t.length;i0){const t=n.split("/");e.push(t)}}const i=e[0];for(let t=1,n=e.length-1;t1){const t=p[1].trim().toLowerCase();s.object.smooth="0"!==t&&"off"!==t}else s.object.smooth=!0;const t=s.object.currentMaterial();t&&(t.smooth=s.object.smooth)}else{if("\0"===l)continue;console.warn('THREE.OBJLoader: Unexpected line: "'+l+'"')}s.finalize();const f=new i.Group;f.materialLibraries=[].concat(s.materialLibraries);if(!0===!(1===s.objects.length&&0===s.objects[0].geometry.vertices.length))for(let t=0,e=s.objects.length;t0&&c.setAttribute("normal",new i.Float32BufferAttribute(n.normals,3)),n.colors.length>0&&(l=!0,c.setAttribute("color",new i.Float32BufferAttribute(n.colors,3))),!0===n.hasUVIndices&&c.setAttribute("uv",new i.Float32BufferAttribute(n.uvs,2));const u=[];for(let t=0,e=r.length;t1){for(let t=0,e=r.length;t0){const t=new i.PointsMaterial({size:1,sizeAttenuation:!1}),e=new i.BufferGeometry;e.setAttribute("position",new i.Float32BufferAttribute(s.vertices,3)),s.colors.length>0&&void 0!==s.colors[0]&&(e.setAttribute("color",new i.Float32BufferAttribute(s.colors,3)),t.vertexColors=!0);const n=new i.Points(e,t);f.add(n)}return f}}i.OBJLoader=h}(),t.exports=i.OBJLoader}(zd);var Fd=zd.exports,Vd={exports:{}};!function(t,e){const i=ld;!function(){class t extends i.Loader{constructor(t){super(t)}load(t,e,n,r){const o=this,s=""===this.path?i.LoaderUtils.extractUrlBase(t||""):this.path,a=new i.FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(t,(function(i){try{e(o.parse(i,s))}catch(e){r?r(e):console.error(e),o.manager.itemError(t)}}),n,r)}setMaterialOptions(t){return this.materialOptions=t,this}parse(t,i){const n=t.split("\n");let r={};const o=/\s+/,s={};for(let t=0;t=0?e.substring(0,i):e;a=a.toLowerCase();let l=i>=0?e.substring(i+1):"";if(l=l.trim(),"newmtl"===a)r={name:l},s[l]=r;else if("ka"===a||"kd"===a||"ks"===a||"ke"===a){const t=l.split(o,3);r[a]=[parseFloat(t[0]),parseFloat(t[1]),parseFloat(t[2])]}else r[a]=l}const a=new e(this.resourcePath||i,this.materialOptions);return a.setCrossOrigin(this.crossOrigin),a.setManager(this.manager),a.setMaterials(s),a}}class e{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:i.FrontSide,this.wrap=void 0!==this.options.wrap?this.options.wrap:i.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 i in t){const n=t[i],r={};e[i]=r;for(const t in n){let e=!0,i=n[t];const o=t.toLowerCase();switch(o){case"kd":case"ka":case"ks":this.options&&this.options.normalizeRGB&&(i=[i[0]/255,i[1]/255,i[2]/255]),this.options&&this.options.ignoreZeroRGBs&&0===i[0]&&0===i[1]&&0===i[2]&&(e=!1)}e&&(r[o]=i)}}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],r={name:t,side:this.side};function o(t,i){if(r[t])return;const n=e.getTextureParams(i,r),o=e.loadTexture((s=e.baseUrl,"string"!=typeof(a=n.url)||""===a?"":/^https?:\/\//i.test(a)?a:s+a));var s,a;o.repeat.copy(n.scale),o.offset.copy(n.offset),o.wrapS=e.wrap,o.wrapT=e.wrap,r[t]=o}for(const t in n){const e=n[t];let s;if(""!==e)switch(t.toLowerCase()){case"kd":r.color=(new i.Color).fromArray(e);break;case"ks":r.specular=(new i.Color).fromArray(e);break;case"ke":r.emissive=(new i.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),r.transparent=!0;break;case"ns":r.shininess=parseFloat(e);break;case"d":s=parseFloat(e),s<1&&(r.opacity=s,r.transparent=!0);break;case"tr":s=parseFloat(e),this.options&&this.options.invertTrProperty&&(s=1-s),s>0&&(r.opacity=1-s,r.transparent=!0)}}return this.materials[t]=new i.MeshPhongMaterial(r),this.materials[t]}getTextureParams(t,e){const n={scale:new i.Vector2(1,1),offset:new i.Vector2(0,0)},r=t.split(/\s+/);let o;return o=r.indexOf("-bm"),o>=0&&(e.bumpScale=parseFloat(r[o+1]),r.splice(o,2)),o=r.indexOf("-s"),o>=0&&(n.scale.set(parseFloat(r[o+1]),parseFloat(r[o+2])),r.splice(o,4)),o=r.indexOf("-o"),o>=0&&(n.offset.set(parseFloat(r[o+1]),parseFloat(r[o+2])),r.splice(o,4)),n.url=r.join(" ").trim(),n}loadTexture(t,e,n,r,o){const s=void 0!==this.manager?this.manager:i.DefaultLoadingManager;let a=s.getHandler(t);null===a&&(a=new i.TextureLoader(s)),a.setCrossOrigin&&a.setCrossOrigin(this.crossOrigin);const l=a.load(t,n,r,o);return void 0!==e&&(l.mapping=e),l}}i.MTLLoader=t}(),t.exports=i.MTLLoader}(Vd);var Ud=Vd.exports,Gd={exports:{}},jd={exports:{}};!function(t,e){t.exports=function(){var t={__esModule:!0},i=function(t){var i;try{i("require('worker_threads')").Worker}catch(i){}return e.default=function(t,e,i,n,r){setImmediate((function(){return r(Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"),null)}));var o=function(){};return{terminate:o,postMessage:o}},t}({}),n=Uint8Array,r=Uint16Array,o=Uint32Array,s=new n([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]),a=new n([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 n([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),c=function(t,e){for(var i=new r(31),n=0;n<31;++n)i[n]=e+=1<>>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,i){for(var n=t.length,o=0,s=new r(e);o>>c]=u}else for(a=new r(n),o=0;o>>15-t[o]);return a},x=new n(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 n(32);for(y=0;y<32;++y)b[y]=5;var w=_(x,9,0),A=_(x,9,1),E=_(b,5,0),S=_(b,5,1),M=function(t){for(var e=t[0],i=1;ie&&(e=t[i]);return e},T=function(t,e,i){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(7&e)&i},I=function(t,e){var i=e/8|0;return(t[i]|t[i+1]<<8|t[i+2]<<16)>>(7&e)},C=function(t){return(t/8|0)+(7&t&&1)},P=function(t,e,i){(null==e||e<0)&&(e=0),(null==i||i>t.length)&&(i=t.length);var s=new(t instanceof r?r:t instanceof o?o:n)(i-e);return s.set(t.subarray(e,i)),s},L=function(t,e,i){var r=t.length;if(!r||i&&!i.l&&r<5)return e||new n(0);var o=!e||i,c=!i||i.i;i||(i={}),e||(e=new n(3*r));var u=function(t){var i=e.length;if(t>i){var r=new n(Math.max(2*i,t));r.set(e),e=r}},p=i.f||0,d=i.p||0,m=i.b||0,g=i.l,y=i.d,v=i.m,x=i.n,b=8*r;do{if(!g){i.f=p=T(t,d,1);var w=T(t,d+1,3);if(d+=3,!w){var E=t[(U=C(d)+4)-4]|t[U-3]<<8,L=U+E;if(L>r){if(c)throw"unexpected EOF";break}o&&u(m+E),e.set(t.subarray(U,L),m),i.b=m+=E,i.p=d=8*L;continue}if(1==w)g=A,y=S,v=9,x=5;else{if(2!=w)throw"invalid block type";var D=T(t,d,31)+257,R=T(t,d+10,15)+4,O=D+T(t,d+5,31)+1;d+=14;for(var k=new n(O),N=new n(19),B=0;Bb)break;var V=_(N,z,1);for(B=0;B>>4)<16)k[B++]=U;else{var j=0,H=0;for(16==U?(H=3+T(t,d,3),d+=2,j=k[B-1]):17==U?(H=3+T(t,d,7),d+=3):18==U&&(H=11+T(t,d,127),d+=7);H--;)k[B++]=j}}var W=k.subarray(0,D),q=k.subarray(D);v=M(W),x=M(q),g=_(W,v,1),y=_(q,x,1)}if(d>b)throw"unexpected EOF"}o&&u(m+131072);for(var X=(1<>>4;if((d+=15&j)>b)throw"unexpected EOF";if(!j)throw"invalid length/literal";if(Q<256)e[m++]=Q;else{if(256==Q){g=null;break}var J=Q-254;Q>264&&(J=T(t,d,(1<<(tt=s[B=Q-257]))-1)+h[B],d+=tt);var K=y[I(t,d)&Z],$=K>>>4;if(!K)throw"invalid distance";if(d+=15&K,q=f[$],$>3){var tt=a[$];q+=I(t,d)&(1<b)throw"unexpected EOF";o&&u(m+131072);for(var et=m+J;m>>8},R=function(t,e,i){var n=e/8|0;t[n]|=i<<=7&e,t[n+1]|=i>>>8,t[n+2]|=i>>>16},O=function(t,e){for(var i=[],o=0;of&&(f=a[o].s);var m=new r(f+1),g=k(i[p-1],m,0);if(g>e){o=0;var y=0,v=g-e,_=1<e))break;y+=_-(1<>>=v;y>0;){var b=a[o].s;m[b]=0&&y;--o){var w=a[o].s;m[w]==e&&(--m[w],++y)}g=e}return[new n(m),g]},k=function(t,e,i){return-1==t.s?Math.max(k(t.l,e,i+1),k(t.r,e,i+1)):e[t.s]=i},N=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new r(++e),n=0,o=t[0],s=1,a=function(t){i[n++]=t},l=1;l<=e;++l)if(t[l]==o&&l!=e)++s;else{if(!o&&s>2){for(;s>138;s-=138)a(32754);s>2&&(a(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(a(o),--s;s>6;s-=6)a(8304);s>2&&(a(s-3<<5|8208),s=0)}for(;s--;)a(o);s=1,o=t[l]}return[i.subarray(0,n),e]},B=function(t,e){for(var i=0,n=0;n>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var o=0;o4&&!U[l[j-1]];--j);var H,W,q,X,Z=d+5<<3,Y=B(o,x)+B(c,b)+u,Q=B(o,g)+B(c,A)+u+14+3*j+B(k,U)+(2*k[16]+3*k[17]+7*k[18]);if(Z<=Y&&Z<=Q)return z(e,f,t.subarray(p,p+d));if(D(e,f,1+(Q15&&(D(e,f,tt[F]>>>5&127),f+=tt[F]>>>12)}}else H=w,W=x,q=E,X=b;for(F=0;F255){var et;R(e,f,H[257+(et=n[F]>>>18&31)]),f+=W[et+257],et>7&&(D(e,f,n[F]>>>23&31),f+=s[et]);var it=31&n[F];R(e,f,q[it]),f+=X[it],it>3&&(R(e,f,n[F]>>>5&8191),f+=a[it])}else R(e,f,H[n[F]]),f+=W[n[F]];return R(e,f,H[256]),f+W[256]},V=new o([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),U=new n(0),G=function(t,e,i,l,c,u){var h=t.length,d=new n(l+h+5*(1+Math.ceil(h/7e3))+c),f=d.subarray(l,d.length-c),g=0;if(!e||h<8)for(var y=0;y<=h;y+=65535){var v=y+65535;v>>13,b=8191&_,w=(1<7e3||k>24576)&&W>423){g=F(t,f,0,I,L,D,O,k,B,y-B,g),k=R=O=0,B=y;for(var q=0;q<286;++q)L[q]=0;for(q=0;q<30;++q)D[q]=0}var X=2,Z=0,Y=b,Q=j-H&32767;if(W>2&&G==T(y-Q))for(var J=Math.min(x,W)-1,K=Math.min(32767,y),$=Math.min(258,W);Q<=K&&--Y&&j!=H;){if(t[y+X]==t[y+X-Q]){for(var tt=0;tt<$&&t[y+tt]==t[y+tt-Q];++tt);if(tt>X){if(X=tt,Z=Q,tt>J)break;var et=Math.min(Q,tt-2),it=0;for(q=0;qit&&(it=rt,H=nt)}}}Q+=(j=H)-(H=A[j])+32768&32767}if(Z){I[k++]=268435456|p[X]<<18|m[Z];var ot=31&p[X],st=31&m[Z];O+=s[ot]+a[st],++L[257+ot],++D[st],N=y+X,++R}else I[k++]=t[y],++L[t[y]]}}g=F(t,f,u,I,L,D,O,k,B,y-B,g),!u&&7&g&&(g=z(f,g+1,U))}return P(d,0,l+C(g)+c)},j=function(){for(var t=new o(256),e=0;e<256;++e){for(var i=e,n=9;--n;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t}(),H=function(){var t=-1;return{p:function(e){for(var i=t,n=0;n>>8;t=i},d:function(){return~t}}},W=function(){var t=1,e=0;return{p:function(i){for(var n=t,r=e,o=i.length,s=0;s!=o;){for(var a=Math.min(s+2655,o);s>16),r=(65535&r)+15*(r>>16)}t=n,e=r},d:function(){return((t%=65521)>>>8<<16|(255&(e%=65521))<<8|e>>>8)+2*((255&t)<<23)}}},q=function(t,e,i,n,r){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,i,n,!r)},X=function(t,e){var i={};for(var n in t)i[n]=t[n];for(var n in e)i[n]=e[n];return i},Z=function(t,e,i){for(var n=t(),r=""+t,o=r.slice(r.indexOf("[")+1,r.lastIndexOf("]")).replace(/ /g,"").split(","),s=0;s>>=8},dt=function(t,e){var i=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&&pt(t,4,Math.floor(new Date(e.mtime||Date.now())/1e3)),i){t[3]=8;for(var n=0;n<=i.length;++n)t[n+10]=i.charCodeAt(n)}},ft=function(t){if(31!=t[0]||139!=t[1]||8!=t[2])throw"invalid gzip data";var e=t[3],i=10;4&e&&(i+=t[10]|2+(t[11]<<8));for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[i++]);return i+(2&e)},mt=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16)+2*(t[e-1]<<23)},gt=function(t){return 10+(t.filename&&t.filename.length+1||0)},yt=function(t,e){var i=e.level,n=0==i?0:i<6?1:9==i?3:2;t[0]=120,t[1]=n<<6|(n?32-2*n:1)},vt=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 _t(t,e){return e||"function"!=typeof t||(e=t,t={}),this.ondata=e,t}var xt=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(q(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}();t.Deflate=xt;var bt=function(t,e){lt([$,function(){return[at,xt]}],this,_t.call(this,t,e),(function(t){var e=new xt(t.data);onmessage=at(e)}),6)};function wt(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return st(t,e,[$],(function(t){return rt(At(t.data[0],t.data[1]))}),0,i)}function At(t,e){return q(t,e||{},0,0)}t.AsyncDeflate=bt,t.deflate=wt,t.deflateSync=At;var Et=function(){function t(t){this.s={},this.p=new n(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,i=new n(e+t.length);i.set(this.p),i.set(t,e),this.p=i},t.prototype.c=function(t){this.d=this.s.i=t||!1;var e=this.s.b,i=L(this.p,this.o,this.s);this.ondata(P(i,e,this.s.b),this.d),this.o=P(i,this.s.b-32768),this.s.b=this.o.length,this.p=P(this.p,this.s.p/8|0),this.s.p&=7},t.prototype.push=function(t,e){this.e(t),this.c(e)},t}();t.Inflate=Et;var St=function(t){this.ondata=t,lt([K,function(){return[at,Et]}],this,0,(function(){var t=new Et;onmessage=at(t)}),7)};function Mt(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return st(t,e,[K],(function(t){return rt(Tt(t.data[0],ot(t.data[1])))}),1,i)}function Tt(t,e){return L(t,e)}t.AsyncInflate=St,t.inflate=Mt,t.inflateSync=Tt;var It=function(){function t(t,e){this.c=H(),this.l=0,this.v=1,xt.call(this,t,e)}return t.prototype.push=function(t,e){xt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t),this.l+=t.length;var i=q(t,this.o,this.v&>(this.o),e&&8,!e);this.v&&(dt(i,this.o),this.v=0),e&&(pt(i,i.length-8,this.c.d()),pt(i,i.length-4,this.l)),this.ondata(i,e)},t}();t.Gzip=It,t.Compress=It;var Ct=function(t,e){lt([$,tt,function(){return[at,xt,It]}],this,_t.call(this,t,e),(function(t){var e=new It(t.data);onmessage=at(e)}),8)};function Pt(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return st(t,e,[$,tt,function(){return[Lt]}],(function(t){return rt(Lt(t.data[0],t.data[1]))}),2,i)}function Lt(t,e){e||(e={});var i=H(),n=t.length;i.p(t);var r=q(t,e,gt(e),8),o=r.length;return dt(r,e),pt(r,o-8,i.d()),pt(r,o-4,n),r}t.AsyncGzip=Ct,t.AsyncCompress=Ct,t.gzip=Pt,t.compress=Pt,t.gzipSync=Lt,t.compressSync=Lt;var Dt=function(){function t(t){this.v=1,Et.call(this,t)}return t.prototype.push=function(t,e){if(Et.prototype.e.call(this,t),this.v){var i=this.p.length>3?ft(this.p):4;if(i>=this.p.length&&!e)return;this.p=this.p.subarray(i),this.v=0}if(e){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}Et.prototype.c.call(this,e)},t}();t.Gunzip=Dt;var Rt=function(t){this.ondata=t,lt([K,et,function(){return[at,Et,Dt]}],this,0,(function(){var t=new Dt;onmessage=at(t)}),9)};function Ot(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return st(t,e,[K,et,function(){return[kt]}],(function(t){return rt(kt(t.data[0]))}),3,i)}function kt(t,e){return L(t.subarray(ft(t),-8),e||new n(mt(t)))}t.AsyncGunzip=Rt,t.gunzip=Ot,t.gunzipSync=kt;var Nt=function(){function t(t,e){this.c=W(),this.v=1,xt.call(this,t,e)}return t.prototype.push=function(t,e){xt.prototype.push.call(this,t,e)},t.prototype.p=function(t,e){this.c.p(t);var i=q(t,this.o,this.v&&2,e&&4,!e);this.v&&(yt(i,this.o),this.v=0),e&&pt(i,i.length-4,this.c.d()),this.ondata(i,e)},t}();t.Zlib=Nt;var Bt=function(t,e){lt([$,it,function(){return[at,xt,Nt]}],this,_t.call(this,t,e),(function(t){var e=new Nt(t.data);onmessage=at(e)}),10)};function zt(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return st(t,e,[$,it,function(){return[Ft]}],(function(t){return rt(Ft(t.data[0],t.data[1]))}),4,i)}function Ft(t,e){e||(e={});var i=W();i.p(t);var n=q(t,e,2,4);return yt(n,e),pt(n,n.length-4,i.d()),n}t.AsyncZlib=Bt,t.zlib=zt,t.zlibSync=Ft;var Vt=function(){function t(t){this.v=1,Et.call(this,t)}return t.prototype.push=function(t,e){if(Et.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)}Et.prototype.c.call(this,e)},t}();t.Unzlib=Vt;var Ut=function(t){this.ondata=t,lt([K,nt,function(){return[at,Et,Vt]}],this,0,(function(){var t=new Vt;onmessage=at(t)}),11)};function Gt(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return st(t,e,[K,nt,function(){return[jt]}],(function(t){return rt(jt(t.data[0],ot(t.data[1])))}),5,i)}function jt(t,e){return L((vt(t),t.subarray(2,-4)),e)}t.AsyncUnzlib=Ut,t.unzlib=Gt,t.unzlibSync=jt;var Ht=function(){function t(t){this.G=Dt,this.I=Et,this.Z=Vt,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 i=new n(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length)}else this.p=t;if(this.p.length>2){var r=this,o=function(){r.ondata.apply(r,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}();t.Decompress=Ht;var Wt=function(){function t(t){this.G=Rt,this.I=St,this.Z=Ut,this.ondata=t}return t.prototype.push=function(t,e){Ht.prototype.push.call(this,t,e)},t}();function qt(t,e,i){if(i||(i=e,e={}),"function"!=typeof i)throw"no callback";return 31==t[0]&&139==t[1]&&8==t[2]?Ot(t,e,i):8!=(15&t[0])||t[0]>>4>7||(t[0]<<8|t[1])%31?Mt(t,e,i):Gt(t,e,i)}function Xt(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?Tt(t,e):jt(t,e)}t.AsyncDecompress=Wt,t.decompress=qt,t.decompressSync=Xt;var Zt=function(t,e,i,r){for(var o in t){var s=t[o],a=e+o;s instanceof n?i[a]=[s,r]:Array.isArray(s)?i[a]=[s[0],X(r,s[1])]:Zt(s,a+"/",i,r)}},Yt="undefined"!=typeof TextEncoder&&new TextEncoder,Qt="undefined"!=typeof TextDecoder&&new TextDecoder,Jt=0;try{Qt.decode(U,{stream:!0}),Jt=1}catch(i){}var Kt=function(t){for(var e="",i=0;;){var n=t[i++],r=(n>127)+(n>223)+(n>239);if(i+r>t.length)return[e,P(t,i-1)];r?3==r?(n=((15&n)<<18|(63&t[i++])<<12|(63&t[i++])<<6|63&t[i++])-65536,e+=String.fromCharCode(55296|n>>10,56320|1023&n)):e+=String.fromCharCode(1&r?(31&n)<<6|63&t[i++]:(15&n)<<12|(63&t[i++])<<6|63&t[i++]):e+=String.fromCharCode(n)}},$t=function(){function t(t){this.ondata=t,Jt?this.t=new TextDecoder:this.p=U}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 i=new n(this.p.length+t.length);i.set(this.p),i.set(t,this.p.length);var r=Kt(i),o=r[0],s=r[1];if(e&&s.length)throw"invalid utf-8 data";this.p=s,this.ondata(o,e)},t}();t.DecodeUTF8=$t;var te=function(){function t(t){this.ondata=t}return t.prototype.push=function(t,e){if(!this.ondata)throw"no callback";this.ondata(ee(t),e||!1)},t}();function ee(t,e){if(e){for(var i=new n(t.length),r=0;r>1)),a=0,l=function(t){s[a++]=t};for(r=0;rs.length){var c=new n(a+8+(o-r<<1));c.set(s),s=c}var u=t.charCodeAt(r);u<128||e?l(u):u<2048?(l(192|u>>>6),l(128|63&u)):u>55295&&u<57344?(l(240|(u=65536+(1047552&u)|1023&t.charCodeAt(++r))>>>18),l(128|u>>>12&63),l(128|u>>>6&63),l(128|63&u)):(l(224|u>>>12),l(128|u>>>6&63),l(128|63&u))}return P(s,0,a)}function ie(t,e){if(e){for(var i="",n=0;n65535)throw"extra field too long";e+=n+4}return e},le=function(t,e,i,n,r,o,s,a){var l=n.length,c=i.extra,u=a&&a.length,h=ae(c);pt(t,e,null!=s?33639248:67324752),e+=4,null!=s&&(t[e++]=20,t[e++]=i.os),t[e]=20,e+=2,t[e++]=i.flag<<1|(null==o&&8),t[e++]=r&&8,t[e++]=255&i.compression,t[e++]=i.compression>>8;var p=new Date(null==i.mtime?Date.now():i.mtime),d=p.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(pt(t,e,2*(d<<24)|p.getMonth()+1<<21|p.getDate()<<16|p.getHours()<<11|p.getMinutes()<<5|p.getSeconds()>>>1),e+=4,null!=o&&(pt(t,e,i.crc),pt(t,e+4,o),pt(t,e+8,i.size)),pt(t,e+12,l),pt(t,e+14,h),e+=16,null!=s&&(pt(t,e,u),pt(t,e+6,i.attrs),pt(t,e+10,s),e+=14),t.set(n,e),e+=l,h)for(var f in c){var m=c[f],g=m.length;pt(t,e,+f),pt(t,e+2,g),t.set(m,e+4),e+=4+g}return u&&(t.set(a,e),e+=u),e},ce=function(t,e,i,n,r){pt(t,e,101010256),pt(t,e+8,i),pt(t,e+10,i),pt(t,e+12,n),pt(t,e+16,r)},ue=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}();t.ZipPassThrough=ue;var he=function(){function t(t,e){var i=this;e||(e={}),ue.call(this,t),this.d=new xt(e,(function(t,e){i.ondata(null,t,e)})),this.compression=8,this.flag=ne(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){ue.prototype.push.call(this,t,e)},t}();t.ZipDeflate=he;var pe=function(){function t(t,e){var i=this;e||(e={}),ue.call(this,t),this.d=new bt(e,(function(t,e,n){i.ondata(t,e,n)})),this.compression=8,this.flag=ne(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){ue.prototype.push.call(this,t,e)},t}();t.AsyncZipDeflate=pe;var de=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 i=ee(t.filename),r=i.length,o=t.comment,s=o&&ee(o),a=r!=t.filename.length||s&&o.length!=s.length,l=r+ae(t.extra)+30;if(r>65535)throw"filename too long";var c=new n(l);le(c,0,t,i,a);var u=[c],h=function(){for(var t=0,i=u;t65535&&E("filename too long",null),A)if(g<16e4)try{E(null,At(c,f))}catch(t){E(t,null)}else h.push(wt(c,f,E));else E(null,c)},m=0;m65535)throw"filename too long";var y=h?At(c,u):c,v=y.length,_=H();_.p(c),r.push(X(u,{size:c.length,crc:_.d(),c:y,f:E,m:f,u:p!=a.length||f&&d.length!=m,o:o,compression:h})),o+=30+p+g+v,s+=76+2*(p+g)+(m||0)+v}for(var x=new n(s+22),b=o,w=s-o,A=0;A0){var r=Math.min(this.c,t.length),o=t.subarray(0,r);if(this.c-=r,this.d?this.d.push(o,!this.c):this.k[0].push(o),(t=t.subarray(r)).length)return this.push(t,e)}else{var s=0,a=0,l=void 0,c=void 0;this.p.length?t.length?((c=new n(this.p.length+t.length)).set(this.p),c.set(t,this.p.length)):c=this.p:c=t;for(var u=c.length,h=this.c,p=h&&this.d,d=function(){var t,e=ut(c,a);if(67324752==e){s=1,l=a,f.d=null,f.c=0;var n=ct(c,a+6),r=ct(c,a+8),o=2048&n,p=8&n,d=ct(c,a+26),m=ct(c,a+28);if(u>a+30+d+m){var g=[];f.k.unshift(g),s=2;var y=ut(c,a+18),v=ut(c,a+22),_=ie(c.subarray(a+30,a+=30+d),!o);4294967295==y?(t=p?[-2]:se(c,a),y=t[0],v=t[1]):p&&(y=-1),a+=m,f.c=y;var x={name:_,compression:r,start:function(){if(!x.ondata)throw"no callback";if(y){var t=i.o[r];if(!t)throw"unknown compression type "+r;var e=y<0?new t(_):new t(_,y,v);e.ondata=function(t,e,i){x.ondata(t,e,i)};for(var n=0,o=g;n=0&&(x.size=y,x.originalSize=v),f.onfile(x)}return"break"}if(h){if(134695760==e)return l=a+=12+(-2==h&&8),s=2,f.c=0,"break";if(33639248==e)return l=a-=4,s=2,f.c=0,"break"}},f=this;a65558)return void e("invalid zip file",null);var a=ct(t,s+8);a||e(null,{});var l=a,c=ut(t,s+16),u=4294967295==c;if(u){if(s=ut(t,s-12),101075792!=ut(t,s))return void e("invalid zip file",null);l=a=ut(t,s+32),c=ut(t,s+48)}for(var h=function(s){var l=oe(t,c,u),h=l[0],p=l[1],d=l[2],f=l[3],m=l[4],g=re(t,l[5]);c=m;var y=function(t,i){t?(r(),e(t,null)):(o[f]=i,--a||e(null,o))};if(h)if(8==h){var v=t.subarray(g,g+p);if(p<32e4)try{y(null,Tt(v,new n(d)))}catch(t){y(t,null)}else i.push(Mt(v,{size:d},y))}else y("unknown compression type "+h,null);else y(null,P(t,g,g+p))},p=0;p65558)throw"invalid zip file";var r=ct(t,i+8);if(!r)return{};var o=ut(t,i+16),s=4294967295==o;if(s){if(i=ut(t,i-12),101075792!=ut(t,i))throw"invalid zip file";r=ut(t,i+32),o=ut(t,i+48)}for(var a=0;a=e.length&&e===w(t,0,e.length)}(e))t=(new u).parse(e);else{const i=w(e);if(!function(t){const e=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let i=0;function n(e){const n=t[e-1];return t=t.slice(i+e),i++,n}for(let t=0;t0,o="string"==typeof r.Content&&""!==r.Content;if(e||o){const e=this.parseImage(n[t]);i[r.RelativeFilename||r.Filename]=e}}}}for(const t in e){const n=e[t];void 0!==i[n]?e[t]=i[n]:e[t]=e[t].split("\\").pop()}return e}parseImage(t){const e=t.Content,i=t.RelativeFilename||t.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();let r;switch(n){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",i),r="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+n+'" is not supported.')}if("string"==typeof e)return"data:"+r+";base64,"+e;{const t=new Uint8Array(e);return window.URL.createObjectURL(new Blob([t],{type:r}))}}parseTextures(e){const i=new Map;if("Texture"in t.Objects){const n=t.Objects.Texture;for(const t in n){const r=this.parseTexture(n[t],e);i.set(parseInt(t),r)}}return i}parseTexture(t,e){const n=this.loadTexture(t,e);n.ID=t.id,n.name=t.attrName;const r=t.WrapModeU,o=t.WrapModeV,s=void 0!==r?r.value:0,a=void 0!==o?o.value:0;if(n.wrapS=0===s?i.RepeatWrapping:i.ClampToEdgeWrapping,n.wrapT=0===a?i.RepeatWrapping:i.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 r;const o=this.textureLoader.path,s=e.get(t.id).children;let a;void 0!==s&&s.length>0&&void 0!==n[s[0].ID]&&(r=n[s[0].ID],0!==r.indexOf("blob:")&&0!==r.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),a=new i.Texture):(e.setPath(this.textureLoader.path),a=e.load(r))}else"psd"===l?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),a=new i.Texture):a=this.textureLoader.load(r);return this.textureLoader.setPath(o),a}parseMaterials(e){const i=new Map;if("Material"in t.Objects){const n=t.Objects.Material;for(const t in n){const r=this.parseMaterial(n[t],e);null!==r&&i.set(parseInt(t),r)}}return i}parseMaterial(t,n){const r=t.id,o=t.attrName;let s=t.ShadingModel;if("object"==typeof s&&(s=s.value),!e.has(r))return null;const a=this.parseParameters(t,n,r);let l;switch(s.toLowerCase()){case"phong":l=new i.MeshPhongMaterial;break;case"lambert":l=new i.MeshLambertMaterial;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to THREE.MeshPhongMaterial.',s),l=new i.MeshPhongMaterial}return l.setValues(a),l.name=o,l}parseParameters(t,n,r){const o={};t.BumpFactor&&(o.bumpScale=t.BumpFactor.value),t.Diffuse?o.color=(new i.Color).fromArray(t.Diffuse.value):!t.DiffuseColor||"Color"!==t.DiffuseColor.type&&"ColorRGB"!==t.DiffuseColor.type||(o.color=(new i.Color).fromArray(t.DiffuseColor.value)),t.DisplacementFactor&&(o.displacementScale=t.DisplacementFactor.value),t.Emissive?o.emissive=(new i.Color).fromArray(t.Emissive.value):!t.EmissiveColor||"Color"!==t.EmissiveColor.type&&"ColorRGB"!==t.EmissiveColor.type||(o.emissive=(new i.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 i.Color).fromArray(t.Specular.value):t.SpecularColor&&"Color"===t.SpecularColor.type&&(o.specular=(new i.Color).fromArray(t.SpecularColor.value));const s=this;return e.get(r).children.forEach((function(t){const e=t.relationship;switch(e){case"Bump":o.bumpMap=s.getTexture(n,t.ID);break;case"Maya|TEX_ao_map":o.aoMap=s.getTexture(n,t.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":o.map=s.getTexture(n,t.ID),void 0!==o.map&&(o.map.encoding=i.sRGBEncoding);break;case"DisplacementColor":o.displacementMap=s.getTexture(n,t.ID);break;case"EmissiveColor":o.emissiveMap=s.getTexture(n,t.ID),void 0!==o.emissiveMap&&(o.emissiveMap.encoding=i.sRGBEncoding);break;case"NormalMap":case"Maya|TEX_normal_map":o.normalMap=s.getTexture(n,t.ID);break;case"ReflectionColor":o.envMap=s.getTexture(n,t.ID),void 0!==o.envMap&&(o.envMap.mapping=i.EquirectangularReflectionMapping,o.envMap.encoding=i.sRGBEncoding);break;case"SpecularColor":o.specularMap=s.getTexture(n,t.ID),void 0!==o.specularMap&&(o.specularMap.encoding=i.sRGBEncoding);break;case"TransparentColor":case"TransparencyFactor":o.alphaMap=s.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(i,n){return"LayeredTexture"in t.Objects&&n in t.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),n=e.get(n).children[0].ID),i.get(n)}parseDeformers(){const i={},n={};if("Deformer"in t.Objects){const r=t.Objects.Deformer;for(const t in r){const o=r[t],s=e.get(parseInt(t));if("Skin"===o.attrType){const e=this.parseSkeleton(s,r);e.ID=t,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),e.geometryID=s.parents[0].ID,i[t]=e}else if("BlendShape"===o.attrType){const e={id:t};e.rawTargets=this.parseMorphTargets(s,r),e.id=t,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),n[t]=e}}}return{skeletons:i,morphTargets:n}}parseSkeleton(t,e){const n=[];return t.children.forEach((function(t){const r=e[t.ID];if("Cluster"!==r.attrType)return;const o={ID:t.ID,indices:[],weights:[],transformLink:(new i.Matrix4).fromArray(r.TransformLink.a)};"Indexes"in r&&(o.indices=r.Indexes.a,o.weights=r.Weights.a),n.push(o)})),{rawBones:n,bones:[]}}parseMorphTargets(t,i){const n=[];for(let r=0;r1?s=a:a.length>0?s=a[0]:(s=new i.MeshPhongMaterial({color:13421772}),a.push(s)),"color"in o.attributes&&a.forEach((function(t){t.vertexColors=!0})),o.FBX_Deformer?(r=new i.SkinnedMesh(o,s),r.normalizeSkinWeights()):r=new i.Mesh(o,s),r}createCurve(t,e){const n=t.children.reduce((function(t,i){return e.has(i.ID)&&(t=e.get(i.ID)),t}),null),r=new i.LineBasicMaterial({color:3342591,linewidth:1});return new i.Line(n,r)}getTransformData(t,e){const i={};"InheritType"in e&&(i.inheritType=parseInt(e.InheritType.value)),i.eulerOrder="RotationOrder"in e?x(e.RotationOrder.value):"ZYX","Lcl_Translation"in e&&(i.translation=e.Lcl_Translation.value),"PreRotation"in e&&(i.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(i.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(i.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(i.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(i.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(i.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(i.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(i.rotationPivot=e.RotationPivot.value),t.userData.transformData=i}setLookAtProperties(n,o){if("LookAtProperty"in o){e.get(n.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!==n.target?(n.target.position.fromArray(t),r.add(n.target)):n.lookAt((new i.Vector3).fromArray(t))}}}))}}bindSkeleton(t,n,r){const o=this.parsePoseNodes();for(const s in t){const a=t[s];e.get(parseInt(a.ID)).parents.forEach((function(t){if(n.has(t.ID)){const n=t.ID;e.get(n).parents.forEach((function(t){if(r.has(t.ID)){r.get(t.ID).bind(new i.Skeleton(a.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 r=n[t].PoseNode;Array.isArray(r)?r.forEach((function(t){e[t.Node]=(new i.Matrix4).fromArray(t.Matrix.a)})):e[r.Node]=(new i.Matrix4).fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in t&&"AmbientColor"in t.GlobalSettings){const e=t.GlobalSettings.AmbientColor.value,n=e[0],o=e[1],s=e[2];if(0!==n||0!==o||0!==s){const t=new i.Color(n,o,s);r.add(new i.AmbientLight(t,1))}}}}class a{parse(i){const n=new Map;if("Geometry"in t.Objects){const r=t.Objects.Geometry;for(const t in r){const o=e.get(parseInt(t)),s=this.parseGeometry(o,r[t],i);n.set(parseInt(t),s)}}return n}parseGeometry(t,e,i){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,i);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(e,i,n){const r=n.skeletons,o=[],s=e.parents.map((function(e){return t.Objects.Model[e.ID]}));if(0===s.length)return;const a=e.children.reduce((function(t,e){return void 0!==r[e.ID]&&(t=r[e.ID]),t}),null);e.children.forEach((function(t){void 0!==n.morphTargets[t.ID]&&o.push(n.morphTargets[t.ID])}));const l=s[0],c={};"RotationOrder"in l&&(c.eulerOrder=x(l.RotationOrder.value)),"InheritType"in l&&(c.inheritType=parseInt(l.InheritType.value)),"GeometricTranslation"in l&&(c.translation=l.GeometricTranslation.value),"GeometricRotation"in l&&(c.rotation=l.GeometricRotation.value),"GeometricScaling"in l&&(c.scale=l.GeometricScaling.value);const u=_(c);return this.genGeometry(i,a,o,u)}genGeometry(t,e,n,r){const o=new i.BufferGeometry;t.attrName&&(o.name=t.attrName);const s=this.parseGeoNode(t,e),a=this.genBuffers(s),l=new i.Float32BufferAttribute(a.vertex,3);if(l.applyMatrix4(r),o.setAttribute("position",l),a.colors.length>0&&o.setAttribute("color",new i.Float32BufferAttribute(a.colors,3)),e&&(o.setAttribute("skinIndex",new i.Uint16BufferAttribute(a.weightsIndices,4)),o.setAttribute("skinWeight",new i.Float32BufferAttribute(a.vertexWeights,4)),o.FBX_Deformer=e),a.normal.length>0){const t=(new i.Matrix3).getNormalMatrix(r),e=new i.Float32BufferAttribute(a.normal,3);e.applyNormalMatrix(t),o.setAttribute("normal",e)}if(a.uvs.forEach((function(t,e){let n="uv"+(e+1).toString();0===e&&(n="uv"),o.setAttribute(n,new i.Float32BufferAttribute(a.uvs[e],2))})),s.material&&"AllSame"!==s.material.mappingType){let t=a.materialIndex[0],e=0;if(a.materialIndex.forEach((function(i,n){i!==t&&(o.addGroup(e,n-e,t),t=i,e=n)})),o.groups.length>0){const e=o.groups[o.groups.length-1],i=e.start+e.count;i!==a.materialIndex.length&&o.addGroup(i,a.materialIndex.length-i,t)}0===o.groups.length&&o.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(o,t,n,r),o}parseGeoNode(t,e){const i={};if(i.vertexPositions=void 0!==t.Vertices?t.Vertices.a:[],i.vertexIndices=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(i.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(i.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(i.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){i.uv=[];let e=0;for(;t.LayerElementUV[e];)t.LayerElementUV[e].UV&&i.uv.push(this.parseUVs(t.LayerElementUV[e])),e++}return i.weightTable={},null!==e&&(i.skeleton=e,e.rawBones.forEach((function(t,e){t.indices.forEach((function(n,r){void 0===i.weightTable[n]&&(i.weightTable[n]=[]),i.weightTable[n].push({id:e,weight:t.weights[r]})}))}))),i}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,n=0,r=!1,o=[],s=[],a=[],l=[],c=[],u=[];const h=this;return t.vertexIndices.forEach((function(p,d){let f,m=!1;p<0&&(p^=-1,m=!0);let y=[],v=[];if(o.push(3*p,3*p+1,3*p+2),t.color){const e=g(d,i,p,t.color);a.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){r||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),r=!0);const t=[0,0,0,0],e=[0,0,0,0];v.forEach((function(i,n){let r=i,o=y[n];e.forEach((function(e,i,n){if(r>e){n[i]=r,r=e;const s=t[i];t[i]=o,o=s}}))})),y=t,v=e}for(;v.length<4;)v.push(0),y.push(0);for(let t=0;t<4;++t)c.push(v[t]),u.push(y[t])}if(t.normal){const e=g(d,i,p,t.normal);s.push(e[0],e[1],e[2])}t.material&&"AllSame"!==t.material.mappingType&&(f=g(d,i,p,t.material)[0]),t.uv&&t.uv.forEach((function(t,e){const n=g(d,i,p,t);void 0===l[e]&&(l[e]=[]),l[e].push(n[0]),l[e].push(n[1])})),n++,m&&(h.genFace(e,t,o,f,s,a,l,c,u,n),i++,n=0,o=[],s=[],a=[],l=[],c=[],u=[])})),e}genFace(t,e,i,n,r,o,s,a,l,c){for(let u=2;u1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=i.get(o[0].ID);r[t]={name:n[t].attrName,layer:s}}return r}addClip(t){let e=[];const n=this;return t.layer.forEach((function(t){e=e.concat(n.generateTracks(t))})),new i.AnimationClip(t.name,-1,e)}generateTracks(t){const e=[];let n=new i.Vector3,r=new i.Quaternion,o=new i.Vector3;if(t.transform&&t.transform.decompose(n,r,o),n=n.toArray(),r=(new i.Euler).setFromQuaternion(r,t.eulerOrder).toArray(),o=o.toArray(),void 0!==t.T&&Object.keys(t.T.curves).length>0){const i=this.generateVectorTrack(t.modelName,t.T.curves,n,"position");void 0!==i&&e.push(i)}if(void 0!==t.R&&Object.keys(t.R.curves).length>0){const i=this.generateRotationTrack(t.modelName,t.R.curves,r,t.preRotation,t.postRotation,t.eulerOrder);void 0!==i&&e.push(i)}if(void 0!==t.S&&Object.keys(t.S.curves).length>0){const i=this.generateVectorTrack(t.modelName,t.S.curves,o,"scale");void 0!==i&&e.push(i)}if(void 0!==t.DeformPercent){const i=this.generateMorphTrack(t);void 0!==i&&e.push(i)}return e}generateVectorTrack(t,e,n,r){const o=this.getTimesForAllAxes(e),s=this.getKeyframeTrackValues(o,e,n);return new i.VectorKeyframeTrack(t+"."+r,o,s)}generateRotationTrack(t,e,n,r,o,s){void 0!==e.x&&(this.interpolateRotations(e.x),e.x.values=e.x.values.map(i.MathUtils.degToRad)),void 0!==e.y&&(this.interpolateRotations(e.y),e.y.values=e.y.values.map(i.MathUtils.degToRad)),void 0!==e.z&&(this.interpolateRotations(e.z),e.z.values=e.z.values.map(i.MathUtils.degToRad));const a=this.getTimesForAllAxes(e),l=this.getKeyframeTrackValues(a,e,n);void 0!==r&&((r=r.map(i.MathUtils.degToRad)).push(s),r=(new i.Euler).fromArray(r),r=(new i.Quaternion).setFromEuler(r)),void 0!==o&&((o=o.map(i.MathUtils.degToRad)).push(s),o=(new i.Euler).fromArray(o),o=(new i.Quaternion).setFromEuler(o).invert());const c=new i.Quaternion,u=new i.Euler,h=[];for(let t=0;t1){let t=1,i=e[0];for(let n=1;n=180){const o=r/180,s=n/o;let a=i+s;const l=t.times[e-1],c=(t.times[e]-l)/o;let u=l+c;const h=[],p=[];for(;u1&&(i=t[1].replace(/^(\w+)::/,""),n=t[2]),{id:e,name:i,type:n}}parseNodeProperty(t,e,i){let n=e[1].replace(/^"/,"").replace(/"$/,"").trim(),r=e[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===r&&(r=i.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if("Properties70"!==o.name){if("C"===n){const t=r.split(",").slice(1),e=parseInt(t[0]),i=parseInt(t[1]);let s=r.split(",").slice(3);s=s.map((function(t){return t.trim().replace(/^"/,"")})),n="connections",r=[e,i],function(t,e){for(let i=0,n=t.length,r=e.length;i=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const i={},n=e>=7500?t.getUint64():t.getUint32(),r=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const o=t.getUint8(),s=t.getString(o);if(0===n)return null;const a=[];for(let e=0;e0?a[0]:"",c=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(i.singleProperty=1===r&&t.getOffset()===n;n>t.getOffset();){const n=this.parseNode(t,e);null!==n&&this.parseSubNode(s,i,n)}return i.propertyList=a,"number"==typeof l&&(i.id=l),""!==c&&(i.attrName=c),""!==u&&(i.attrType=u),""!==s&&(i.name=s),i}parseSubNode(t,e,i){if(!0===i.singleProperty){const t=i.propertyList[0];Array.isArray(t)?(e[i.name]=i,i.a=t):e[i.name]=t}else if("Connections"===t&&"C"===i.name){const t=[];i.propertyList.forEach((function(e,i){0!==i&&t.push(e)})),void 0===e.connections&&(e.connections=[]),e.connections.push(t)}else if("Properties70"===i.name){Object.keys(i).forEach((function(t){e[t]=i[t]}))}else if("Properties70"===t&&"P"===i.name){let t=i.propertyList[0],n=i.propertyList[1];const r=i.propertyList[2],o=i.propertyList[3];let s;0===t.indexOf("Lcl ")&&(t=t.replace("Lcl ","Lcl_")),0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),s="Color"===n||"ColorRGB"===n||"Vector"===n||"Vector3D"===n||0===n.indexOf("Lcl_")?[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:i.propertyList[4],e[t]={type:n,type2:r,flag:o,value:s}}else void 0===e[i.name]?"number"==typeof i.id?(e[i.name]={},e[i.name][i.id]=i):e[i.name]=i:"PoseNode"===i.name?(Array.isArray(e[i.name])||(e[i.name]=[e[i.name]]),e[i.name].push(i)):void 0===e[i.name][i.id]&&(e[i.name][i.id]=i)}parseProperty(t){const e=t.getString(1);let i;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 i=t.getUint32(),t.getArrayBuffer(i);case"S":return i=t.getUint32(),t.getString(i);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=t.getUint32(),o=t.getUint32(),s=t.getUint32();if(0===o)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===n&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const a=n.unzlibSync(new Uint8Array(t.getArrayBuffer(s))),l=new h(a.buffer);switch(e){case"b":case"c":return l.getBooleanArray(r);case"d":return l.getFloat64Array(r);case"f":return l.getFloat32Array(r);case"i":return l.getInt32Array(r);case"l":return l.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class h{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 i=0;i=0&&(e=e.slice(0,n)),i.LoaderUtils.decodeText(new Uint8Array(e))}}class p{add(t,e){this[t]=e}}function d(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 f(t){return t/46186158e3}const m=[];function g(t,e,i,n){let r;switch(n.mappingType){case"ByPolygonVertex":r=t;break;case"ByPolygon":r=e;break;case"ByVertice":r=i;break;case"AllSame":r=n.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+n.mappingType)}"IndexToDirect"===n.referenceType&&(r=n.indices[r]);const o=r*n.dataSize,s=o+n.dataSize;return function(t,e,i,n){for(let r=i,o=0;r=2.0 are supported.")));const h=new J(u,{path:e||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let t=0;t=0&&void 0===c[e]&&console.warn('THREE.GLTFLoader: Unknown extension "'+e+'".')}}h.setExtensions(l),h.setPlugins(c),h.parse(r,s)}}function e(){let t={};return{get:function(e){return t[e]},add:function(e,i){t[e]=i},remove:function(e){delete t[e]},removeAll:function(){t={}}}}const n={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class r{constructor(t){this.parser=t,this.name=n.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const t=this.parser,e=this.parser.json.nodes||[];for(let i=0,n=e.length;i=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return e.loadTextureImage(t,o,s)}}class p{constructor(t){this.parser=t,this.name=n.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(t){const e=this.name,i=this.parser,n=i.json,r=n.textures[t];if(!r.extensions||!r.extensions[e])return null;const o=r.extensions[e],s=n.images[o.source];let a=i.textureLoader;if(s.uri){const t=i.options.manager.getHandler(s.uri);null!==t&&(a=t)}return this.detectSupport().then((function(r){if(r)return i.loadTextureImage(t,s,a);if(n.extensionsRequired&&n.extensionsRequired.indexOf(e)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return i.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 d{constructor(t){this.name=n.EXT_MESHOPT_COMPRESSION,this.parser=t}loadBufferView(t){const e=this.parser.json,i=e.bufferViews[t];if(i.extensions&&i.extensions[this.name]){const t=i.extensions[this.name],n=this.parser.getDependency("buffer",t.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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([n,r.ready]).then((function(e){const i=t.byteOffset||0,n=t.byteLength||0,o=t.count,s=t.byteStride,a=new ArrayBuffer(o*s),l=new Uint8Array(e[0],i,n);return r.decodeGltfBuffer(new Uint8Array(a),o,s,l,t.mode,t.filter),a}))}return null}}const f="glTF",m=1313821514,g=5130562;class y{constructor(t){this.name=n.KHR_BINARY_GLTF,this.content=null,this.body=null;const e=new DataView(t,0,12);if(this.header={magic:i.LoaderUtils.decodeText(new Uint8Array(t.slice(0,4))),version:e.getUint32(4,!0),length:e.getUint32(8,!0)},this.header.magic!==f)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,o=new DataView(t,12);let s=0;for(;s",e).replace("#include ",n).replace("#include ",r).replace("#include ",o).replace("#include ",s)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(t){a.specular.value=t}},specularMap:{get:function(){return a.specularMap.value},set:function(t){a.specularMap.value=t,t?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(t){a.glossiness.value=t}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(t){a.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 b{constructor(){this.name=n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,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 x}extendParams(t,e,n){const r=e.extensions[this.name];t.color=new i.Color(1,1,1),t.opacity=1;const o=[];if(Array.isArray(r.diffuseFactor)){const e=r.diffuseFactor;t.color.fromArray(e),t.opacity=e[3]}if(void 0!==r.diffuseTexture&&o.push(n.assignTexture(t,"map",r.diffuseTexture)),t.emissive=new i.Color(0,0,0),t.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,t.specular=new i.Color(1,1,1),Array.isArray(r.specularFactor)&&t.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const e=r.specularGlossinessTexture;o.push(n.assignTexture(t,"glossinessMap",e)),o.push(n.assignTexture(t,"specularMap",e))}return Promise.all(o)}createMaterial(t){const e=new x(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=i.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 w{constructor(){this.name=n.KHR_MESH_QUANTIZATION}}class A extends i.Interpolant{constructor(t,e,i,n){super(t,e,i,n)}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,r=t*n*3+n;for(let t=0;t!==n;t++)e[t]=i[r+t];return e}}A.prototype.beforeStart_=A.prototype.copySampleValue_,A.prototype.afterEnd_=A.prototype.copySampleValue_,A.prototype.interpolate_=function(t,e,i,n){const r=this.resultBuffer,o=this.sampleValues,s=this.valueSize,a=2*s,l=3*s,c=n-e,u=(i-e)/c,h=u*u,p=h*u,d=t*l,f=d-l,m=-2*p+3*h,g=p-h,y=1-m,v=g-h+u;for(let t=0;t!==s;t++){const e=o[f+t+s],i=o[f+t+a]*c,n=o[d+t+s],l=o[d+t]*c;r[t]=y*e+v*i+m*n+g*l}return r};const E=new i.Quaternion;class S extends A{interpolate_(t,e,i,n){const r=super.interpolate_(t,e,i,n);return E.fromArray(r).normalize().toArray(r),r}}const M=0,T=1,I=2,C=3,P=4,L=5,D=6,R={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},O={9728:i.NearestFilter,9729:i.LinearFilter,9984:i.NearestMipmapNearestFilter,9985:i.LinearMipmapNearestFilter,9986:i.NearestMipmapLinearFilter,9987:i.LinearMipmapLinearFilter},k={33071:i.ClampToEdgeWrapping,33648:i.MirroredRepeatWrapping,10497:i.RepeatWrapping},N={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},B={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},z={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},F={CUBICSPLINE:void 0,LINEAR:i.InterpolateLinear,STEP:i.InterpolateDiscrete},V="OPAQUE",U="MASK",G="BLEND";function j(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 H(t){return void 0===t.DefaultMaterial&&(t.DefaultMaterial=new i.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:i.FrontSide})),t.DefaultMaterial}function W(t,e,i){for(const n in i.extensions)void 0===t[n]&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=i.extensions[n])}function q(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 X(t,e){if(t.updateMorphTargets(),void 0!==e.weights)for(let i=0,n=e.weights.length;i=2&&f.setY(e,h[t*s+1]),s>=3&&f.setZ(e,h[t*s+2]),s>=4&&f.setW(e,h[t*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse THREE.BufferAttribute.")}}return f}))}loadTexture(t){const e=this.json,i=this.options,n=e.textures[t],r=e.images[n.source];let o=this.textureLoader;if(r.uri){const t=i.manager.getHandler(r.uri);null!==t&&(o=t)}return this.loadTextureImage(t,r,o)}loadTextureImage(t,e,n){const r=this,o=this.json,s=this.options,a=o.textures[t],l=(e.uri||e.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=self.URL||self.webkitURL;let u=e.uri||"",h=!1,p=!0;const d=u.search(/\.jpe?g($|\?)/i)>0||0===u.search(/^data\:image\/jpeg/);if(("image/jpeg"===e.mimeType||d)&&(p=!1),void 0!==e.bufferView)u=r.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 i=new Blob([t],{type:e.mimeType});return u=c.createObjectURL(i),u}));else if(void 0===e.uri)throw new Error("THREE.GLTFLoader: Image "+t+" is missing URI and bufferView");const f=Promise.resolve(u).then((function(t){return new Promise((function(e,r){let o=e;!0===n.isImageBitmapLoader&&(o=function(t){const n=new i.Texture(t);n.needsUpdate=!0,e(n)}),n.load(j(t,s.path),o,void 0,r)}))})).then((function(e){!0===h&&c.revokeObjectURL(u),e.flipY=!1,a.name&&(e.name=a.name),p||(e.format=i.RGBFormat);const n=(o.samplers||{})[a.sampler]||{};return e.magFilter=O[n.magFilter]||i.LinearFilter,e.minFilter=O[n.minFilter]||i.LinearMipmapLinearFilter,e.wrapS=k[n.wrapS]||i.RepeatWrapping,e.wrapT=k[n.wrapT]||i.RepeatWrapping,r.associations.set(e,{type:"textures",index:t}),e})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",u),null}));return this.textureCache[l]=f,f}assignTexture(t,e,i){const r=this;return this.getDependency("texture",i.index).then((function(o){if(void 0===i.texCoord||0==i.texCoord||"aoMap"===e&&1==i.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+i.texCoord+" for texture "+e+" not yet supported."),r.extensions[n.KHR_TEXTURE_TRANSFORM]){const t=void 0!==i.extensions?i.extensions[n.KHR_TEXTURE_TRANSFORM]:void 0;if(t){const e=r.associations.get(o);o=r.extensions[n.KHR_TEXTURE_TRANSFORM].extendTexture(o,t),r.associations.set(o,e)}}return t[e]=o,o}))}assignFinalMaterial(t){const e=t.geometry;let n=t.material;const r=void 0!==e.attributes.tangent,o=void 0!==e.attributes.color,s=void 0===e.attributes.normal;if(t.isPoints){const t="PointsMaterial:"+n.uuid;let e=this.cache.get(t);e||(e=new i.PointsMaterial,i.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 i.LineBasicMaterial,i.Material.prototype.copy.call(e,n),e.color.copy(n.color),this.cache.add(t,e)),n=e}if(r||o||s){let t="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(t+="specular-glossiness:"),r&&(t+="vertex-tangents:"),o&&(t+="vertex-colors:"),s&&(t+="flat-shading:");let e=this.cache.get(t);e||(e=n.clone(),o&&(e.vertexColors=!0),s&&(e.flatShading=!0),r&&(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 i.MeshStandardMaterial}loadMaterial(t){const e=this,r=this.json,o=this.extensions,s=r.materials[t];let a;const l={},c=s.extensions||{},u=[];if(c[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const t=o[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];a=t.getMaterialType(),u.push(t.extendParams(l,s,e))}else if(c[n.KHR_MATERIALS_UNLIT]){const t=o[n.KHR_MATERIALS_UNLIT];a=t.getMaterialType(),u.push(t.extendParams(l,s,e))}else{const n=s.pbrMetallicRoughness||{};if(l.color=new i.Color(1,1,1),l.opacity=1,Array.isArray(n.baseColorFactor)){const t=n.baseColorFactor;l.color.fromArray(t),l.opacity=t[3]}void 0!==n.baseColorTexture&&u.push(e.assignTexture(l,"map",n.baseColorTexture)),l.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,l.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(u.push(e.assignTexture(l,"metalnessMap",n.metallicRoughnessTexture)),u.push(e.assignTexture(l,"roughnessMap",n.metallicRoughnessTexture))),a=this._invokeOne((function(e){return e.getMaterialType&&e.getMaterialType(t)})),u.push(Promise.all(this._invokeAll((function(e){return e.extendMaterialParams&&e.extendMaterialParams(t,l)}))))}!0===s.doubleSided&&(l.side=i.DoubleSide);const h=s.alphaMode||V;return h===G?(l.transparent=!0,l.depthWrite=!1):(l.format=i.RGBFormat,l.transparent=!1,h===U&&(l.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&a!==i.MeshBasicMaterial&&(u.push(e.assignTexture(l,"normalMap",s.normalTexture)),l.normalScale=new i.Vector2(1,-1),void 0!==s.normalTexture.scale&&l.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&a!==i.MeshBasicMaterial&&(u.push(e.assignTexture(l,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(l.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&a!==i.MeshBasicMaterial&&(l.emissive=(new i.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&a!==i.MeshBasicMaterial&&u.push(e.assignTexture(l,"emissiveMap",s.emissiveTexture)),Promise.all(u).then((function(){let r;return r=a===x?o[n.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(l):new a(l),s.name&&(r.name=s.name),r.map&&(r.map.encoding=i.sRGBEncoding),r.emissiveMap&&(r.emissiveMap.encoding=i.sRGBEncoding),q(r,s),e.associations.set(r,{type:"materials",index:t}),s.extensions&&W(o,r,s),r}))}createUniqueName(t){const e=i.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,r=this.extensions,o=this.primitiveCache;function s(t){return r[n.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(t,e).then((function(i){return $(i,t,e)}))}const a=[];for(let r=0,l=t.length;r0&&X(p,o),p.name=e.createUniqueName(o.name||"mesh_"+t),q(p,o),h.extensions&&W(r,p,h),e.assignFinalMaterial(p),c.push(p)}if(1===c.length)return c[0];const u=new i.Group;for(let t=0,e=c.length;t1?new i.Group:1===e.length?e[0]:new i.Object3D,a!==e[0])for(let t=0,i=e.length;t0&&e.push(new i.VectorKeyframeTrack(r+".position",o,s)),a.length>0&&e.push(new i.QuaternionKeyframeTrack(r+".quaternion",o,a)),l.length>0&&e.push(new i.VectorKeyframeTrack(r+".scale",o,l)),e}function A(t,e,i){let n,r,o,s=!0;for(r=0,o=t.length;r=0;){const n=t[e];if(null!==n.value[i])return n;e--}return null}function S(t,e,i){for(;e>>0));i=i.toLowerCase(),e="tga"===i?Wt:Ht;return e}(r);if(void 0!==e){const n=e.load(r),o=t.extra;if(void 0!==o&&void 0!==o.technique&&!1===l(o.technique)){const t=o.technique;n.wrapS=t.wrapU?i.RepeatWrapping:i.ClampToEdgeWrapping,n.wrapT=t.wrapV?i.RepeatWrapping:i.ClampToEdgeWrapping,n.offset.set(t.offsetU||0,t.offsetV||0),n.repeat.set(t.repeatU||1,t.repeatV||1)}else n.wrapS=i.RepeatWrapping,n.wrapT=i.RepeatWrapping;return n}return console.warn("THREE.ColladaLoader: THREE.Loader for texture %s not found.",r),null}return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",t.id),null}s.name=t.name||"";const c=r.parameters;for(const t in c){const e=c[t];switch(t){case"diffuse":e.color&&s.color.fromArray(e.color),e.texture&&(s.map=a(e.texture));break;case"specular":e.color&&s.specular&&s.specular.fromArray(e.color),e.texture&&(s.specularMap=a(e.texture));break;case"bump":e.texture&&(s.normalMap=a(e.texture));break;case"ambient":e.texture&&(s.lightMap=a(e.texture));break;case"shininess":e.float&&s.shininess&&(s.shininess=e.float);break;case"emission":e.color&&s.emissive&&s.emissive.fromArray(e.color),e.texture&&(s.emissiveMap=a(e.texture))}}let u=c.transparent,h=c.transparency;if(void 0===h&&u&&(h={float:1}),void 0===u&&h&&(u={opaque:"A_ONE",data:{color:[1,1,1,1]}}),u&&h)if(u.data.texture)s.transparent=!0;else{const t=u.data.color;switch(u.opaque){case"A_ONE":s.opacity=t[3]*h.float;break;case"RGB_ZERO":s.opacity=1-t[0]*h.float;break;case"A_ZERO":s.opacity=1-t[3]*h.float;break;case"RGB_ONE":s.opacity=t[0]*h.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',u.opaque)}s.opacity<1&&(s.transparent=!0)}return void 0!==o&&void 0!==o.technique&&1===o.technique.double_sided&&(s.side=i.DoubleSide),s}function Y(t){return d(Yt.materials[t],Z)}function Q(t){for(let e=0;e0?i+o:i;e.inputs[l]={id:t,offset:r},e.stride=Math.max(e.stride,r+1),"TEXCOORD"===i&&(e.hasUV=!0);break;case"vcount":e.vcount=s(n.textContent);break;case"p":e.p=s(n.textContent)}}return e}function lt(t){let e=0;for(let i=0,n=t.length;i0&&e0&&f.setAttribute("position",new i.Float32BufferAttribute(o.array,o.stride)),s.array.length>0&&f.setAttribute("normal",new i.Float32BufferAttribute(s.array,s.stride)),c.array.length>0&&f.setAttribute("color",new i.Float32BufferAttribute(c.array,c.stride)),a.array.length>0&&f.setAttribute("uv",new i.Float32BufferAttribute(a.array,a.stride)),l.array.length>0&&f.setAttribute("uv2",new i.Float32BufferAttribute(l.array,l.stride)),u.length>0&&f.setAttribute("skinIndex",new i.Float32BufferAttribute(u,h)),p.length>0&&f.setAttribute("skinWeight",new i.Float32BufferAttribute(p,d)),r.data=f,r.type=t[0].type,r.materialKeys=m,r}function ht(t,e,i,n){const r=t.p,o=t.stride,s=t.vcount;function a(t){let e=r[t+i]*c;const o=e+c;for(;e4)for(let e=1,n=i-2;e<=n;e++){const i=t+o*e,n=t+o*(e+1);a(t+0*o),a(i),a(n)}t+=o*i}}else for(let t=0,e=r.length;t=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 i=0;ir.limits.max||e{let s=[];switch(t.type){case"mtl":o=o.children[0];break;case"gltf":case"glb":case"dae":s=o.animations,o=o.scene;break;case"fbx":s=o.animations}o.animations=s;const a=i.types.rotation(t.rotation,[0,0,0]),l=i.types.scale(t.scale,[1,1,1]);o.rotation.set(a[0],a[1],a[2]),o.scale.set(l[0],l[1],l[2]),t.normalize&&o.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)}})),o.name="model";let c=n.prototype._makeGroup(o,t);n.prototype._addMethods(c),c.setAnchor(t.anchor),c.setCenter(t.adjustment),c.raycasted=t.raycasted,r(c),e(c),c.setFixedZoom(t.mapScale),c.idle()}),(()=>null),(e=>{console.error("Could not load model file: "+t.obj+" \n "+e.stack),r("Error loading the model")}))}),(()=>null),(t=>{console.warn("No material file found "+t.stack)}))}}(Bd);var Qd=Bd.exports,Jd={exports:{}};!function(t,e){const i=ld,n=md,r=Md;function o(t){t=n._validate(t,r.prototype._defaults.line);var e=n.lnglatsToWorld(t.geometry),s=n.normalizeVertices(e),a=n.flattenVectors(s.vertices),l=new i.LineGeometry;l.setPositions(a);let c=new i.LineMaterial({color:t.color,linewidth:t.width,dashed:!1,opacity:t.opacity});return c.resolution.set(window.innerWidth,window.innerHeight),c.isMaterial=!0,c.transparent=!0,c.depthWrite=!1,(o=new i.Line2(l,c)).position.copy(s.position),o.computeLineDistances(),o}t.exports=o,function(){const t=new i.Box3,e=new i.Vector3;class n extends i.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 i.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 i.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,i=this.attributes.instanceEnd;return void 0!==e&&(e.applyMatrix4(t),i.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 i.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceStart",new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceEnd",new i.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 i.InstancedInterleavedBuffer(e,6,1);return this.setAttribute("instanceColorStart",new i.InterleavedBufferAttribute(n,3,0)),this.setAttribute("instanceColorEnd",new i.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 i.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 i.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 i.Sphere),null===this.boundingBox&&this.computeBoundingBox();const t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(void 0!==t&&void 0!==n){const i=this.boundingSphere.center;this.boundingBox.getCenter(i);let r=0;for(let o=0,s=t.count;o\n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \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 \n\t\t\t#include \n\t\t\t#include \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 \n\t\t#include \n\t\t#include \n\t\t#include \n\t\t#include \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 \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 \n\t\t\t#include \n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\t\t\t#include \n\n\t\t}\n\t\t"};class t extends i.ShaderMaterial{constructor(t){super({type:"LineMaterial",uniforms:i.UniformsUtils.clone(i.ShaderLib.line.uniforms),vertexShader:i.ShaderLib.line.vertexShader,fragmentShader:i.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,i.LineMaterial=t}(),function(){const t=new i.Vector3,e=new i.Vector3,n=new i.Vector4,r=new i.Vector4,o=new i.Vector4,s=new i.Vector3,a=new i.Matrix4,l=new i.Line3,c=new i.Vector3,u=new i.Box3,h=new i.Sphere,p=new i.Vector4;class d extends i.Mesh{constructor(t=new i.LineSegmentsGeometry,e=new i.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="LineSegments2"}computeLineDistances(){const n=this.geometry,r=n.attributes.instanceStart,o=n.attributes.instanceEnd,s=new Float32Array(2*r.count);for(let i=0,n=0,a=r.count;iE&&r.z>E)continue;if(n.z>E){const t=n.z-r.z,e=(n.z-E)/t;n.lerp(r,e)}else if(r.z>E){const t=r.z-n.z,e=(r.z-E)/t;r.lerp(n,e)}n.applyMatrix4(g),r.applyMatrix4(g),n.multiplyScalar(1/n.w),r.multiplyScalar(1/r.w),n.x*=x.x/2,n.y*=x.y/2,r.x*=x.x/2,r.y*=x.y/2,l.start.copy(n),l.start.z=0,l.end.copy(r),l.end.z=0;const o=l.closestPointToPointParameter(s,!0);l.at(o,c);const u=i.MathUtils.lerp(n.z,r.z,o),h=u>=-1&&u<=1,p=s.distanceTo(c)<.5*b;if(h&&p){l.start.fromBufferAttribute(w,t),l.end.fromBufferAttribute(A,t),l.start.applyMatrix4(y),l.end.applyMatrix4(y);const n=new i.Vector3,r=new i.Vector3;f.distanceSqToSegment(l.start,l.end,r,n),e.push({point:r,pointOnLine:n,distance:f.origin.distanceTo(r),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}}d.prototype.LineSegments2=!0,i.LineSegments2=d}(),function(){class t extends i.LineSegments2{constructor(t=new i.LineGeometry,e=new i.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Line2"}}t.prototype.isLine2=!0,i.Line2=t}(),function(){const t=new i.Vector3,e=new i.Vector3;class n extends i.Mesh{constructor(t=new i.LineSegmentsGeometry,e=new i.LineMaterial({color:16777215*Math.random()})){super(t,e),this.type="Wireframe"}computeLineDistances(){const n=this.geometry,r=n.attributes.instanceStart,o=n.attributes.instanceEnd,s=new Float32Array(2*r.count);for(let i=0,n=0,a=r.count;i{a.push(new o.Vector3(t[0],t[1],t[2]))}));const l=new o.CatmullRomCurve3(a);let c=new o.TubeGeometry(l,a.length,t.radius,t.sides,!1),u=n(t),h=new o.Mesh(c,u);return new s({obj:h,units:t.units,anchor:t.anchor,adjustment:t.adjustment,bbox:t.bbox,tooltip:t.tooltip,raycasted:t.raycasted})}}($d);var tf=$d.exports,ef={exports:{}};!function(t,e){const i=Sd;t.exports=function(t){this.map=t,this.renderer=new i.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((i=>{i(this.renderer.render(t,e))}))},this.toggleLabels=async function(t,e){return new Promise((i=>{i(this.setVisibility(t,e,this.scene,this.camera,this.renderer))}))},this.setVisibility=function(t,e,i,n,r){this.renderer.cacheList.forEach((function(o){o.visible!=e&&o.layer===t&&(e&&o.alwaysVisible||!e)&&(o.visible=e,r.renderObject(o,i,n))}))}}}(ef);var nf=ef.exports,rf={exports:{}};!function(t,e){t.exports=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 i=e.createShader(e.VERTEX_SHADER);e.shaderSource(i,"\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(i);const n=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(n,"\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(n),this.program=e.createProgram(),e.attachShader(this.program,i),e.attachShader(this.program,n),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 i=this.map.style.sourceCaches.composite,n=i.getVisibleCoordinates().reverse(),r=this.map.getLayer(this.buildingsLayerId),o=this.map.painter.context,{lng:s,lat:a}=this.map.getCenter(),l=this.tb.getSunPosition(this.tb.lightDateTime,[s,a]);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 n){const n=i.getTile(e),s=n.getBucket(r);if(!s)continue;const[a,l]=s.programConfigurations.programConfigurations[this.buildingsLayerId]._buffers;t.uniformMatrix4fv(this.uMatrix,!1,e.posMatrix),t.uniform1f(this.uHeightFactor,Math.pow(2,e.overscaledZ)/n.tileSize/8);for(const e of s.segments.get()){const i=o.currentNumAttributes||0,n=2;for(let e=n;e{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 i,n=this.getCanvasContainer();this.getCanvasContainer().style.cursor=this.tb.defaultCursor;let o,s,a,l,c=[];function u(t){var e=n.getBoundingClientRect();return{x:t.originalEvent.clientX-e.left-n.clientLeft,y:t.originalEvent.clientY-e.top-n.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),i=this.tb.tooltip({text:t.properties.name||t.id||t.type,mapboxStyle:!0,feature:t});i.setCoords(e),this.tb.add(i,t.layer.id),t.tooltip=i,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 i,n=[];if(t.tb.enableSelectingObjects&&(n=this.tb.queryRenderedFeatures(e.point)),i="object"==typeof n[0],i){let t=_.prototype.findParent3DObject(n[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 i=[];if(t.tb.enableSelectingFeatures&&(i=this.queryRenderedFeatures(e.point)),i.length>0&&"fill-extrusion"==i[0].layer.type&&void 0!==i[0].id)if(this.selectedObject&&this.unselectObject(),this.selectedFeature){if(this.selectedFeature.id!=i[0].id)this.unselectFeature(this.selectedFeature),this.selectFeature(i[0]);else if(this.selectedFeature.id==i[0].id)return void this.unselectFeature(this.selectedFeature)}else this.selectFeature(i[0])}},this.onMouseMove=function(n){let r,c=u(n);if(this.getCanvasContainer().style.cursor=this.tb.defaultCursor,n.originalEvent.altKey&&this.draggedObject){if(!t.tb.enableRotatingObjects)return;e="rotate",this.getCanvasContainer().style.cursor="move",Math.min(i.x,c.x),Math.max(i.x,c.x),Math.min(i.y,c.y),Math.max(i.y,c.y);let n={x:0,y:0,z:Math.round(l[2]+~~((c.x-i.x)/this.tb.rotationStep)%360*this.tb.rotationStep%360)};return this.draggedObject.setRotation(n),void(t.tb.enableHelpTooltips&&this.draggedObject.addHelp("rot: "+n.z+"°"))}if(n.originalEvent.shiftKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="translate",this.getCanvasContainer().style.cursor="move";let i=n.lngLat,r=[Number((i.lng+o).toFixed(this.tb.gridStep)),Number((i.lat+s).toFixed(this.tb.gridStep)),this.draggedObject.modelHeight];return this.draggedObject.setCoords(r),void(t.tb.enableHelpTooltips&&this.draggedObject.addHelp("lng: "+r[0]+"°, lat: "+r[1]+"°"))}if(n.originalEvent.ctrlKey&&this.draggedObject){if(!t.tb.enableDraggingObjects)return;e="altitude",this.getCanvasContainer().style.cursor="move";let i=n.point.y*this.tb.altitudeStep,r=[this.draggedObject.coordinates[0],this.draggedObject.coordinates[1],Number((-i-a).toFixed(this.tb.gridStep))];return this.draggedObject.setCoords(r),void(t.tb.enableHelpTooltips&&this.draggedObject.addHelp("alt: "+r[2]+"m"))}let h=[];if(t.tb.enableSelectingObjects&&(h=this.tb.queryRenderedFeatures(n.point)),r="object"==typeof h[0],r){let t=_.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,n.preventDefault())}else{this.overedObject&&this.outObject();let e=[];t.tb.enableSelectingFeatures&&(e=this.queryRenderedFeatures(n.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,i=u(e),c=this.draggedObject.coordinates,l=r.degreeify(this.draggedObject.rotation),o=c[0]-e.lngLat.lng,s=c[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;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(e){17===e.which||e.which,16===e.which&&(h=!0);let i=this.selectedObject;if(h&&83===e.which&&i){let e=r.toDecimal;if(i.help)i.removeHelp();else{let n=i.modelSize,o=1;"meters"!==i.userData.units&&(o=r.projectedUnitsPerMeter(i.coordinates[1]),o||(o=1),o=e(o,7)),t.tb.enableHelpTooltips&&i.addHelp("size(m): "+e(n.x/o,3)+" W, "+e(n.y/o,3)+" L, "+e(n.z/o,3)+" H"),this.repaint=!0}return!1}}.bind(this),!0),document.addEventListener("keyup",function(t){17==t.which||t.which,16===t.which&&(h=!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 i.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,r=this.map.getCanvas().clientWidth;t?(this.map.transform.fov=0,this.camera=new i.OrthographicCamera(r/-2,r/2,e/2,e/-2,.1,1e21)):(this.map.transform.fov=this.fov,this.camera=new i.PerspectiveCamera(this.map.transform.fov,r/e,.1,1e21)),this.camera.layers.enable(0),this.camera.layers.enable(1),this.cameraSync=new n(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),c(t,this.world)},line:m,label:h,tooltip:p,tube:function(t){return this.setDefaultView(t,this.options),g(t,this.world)},extrusion:function(t){return this.setDefaultView(t,this.options),u(t)},Object3D:function(t){return this.setDefaultView(t,this.options),f(t)},loadObj:async function(t,e){if(this.setDefaultView(t,this.options),!1===t.clone)return new Promise((async i=>{d(t,e,(async t=>{i(t)}))}));{let i=this.objectsCache.get(t.obj);i?i.promise.then((i=>{e(i.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(i,n)=>{d(t,e,(async t=>{t.duplicate?i(t.duplicate()):n(t)}))}))})}},material:function(t){return l(t)},initLights:{ambientLight:null,dirLight:null,dirLightBack:null,dirLightHelper:null,hemiLight:null,pointLight:null},utils:r,SunCalc:o,Constants:s,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,i){return r.getFeatureCenter(t,e,i)},getObjectHeightOnFloor:function(t,e,i){return r.getObjectHeightOnFloor(t,e,i)},queryRenderedFeatures:function(t){let e=new i.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,i){this.map.setLayoutProperty(t,e,i),null!=i&&"visibility"===e&&this.world.children.filter((e=>e.layer===t)).forEach((t=>{t.visibility=i}))},setLayerZoomRange:function(t,e,i){this.map.getLayer(t)&&(this.map.setLayerZoomRange(t,e,i),this.zoomLayers.includes(t)||this.zoomLayers.push(t),this.toggleLayer(t))},setLayerHeigthProperty:function(t,e){let i=this.map.getLayer(t);if(i)if("fill-extrusion"==i.type){let t=this.map.getStyle().sources[i.source].data;t.features.forEach((function(t){t.properties.level=e})),this.map.getSource(i.source).setData(t)}else"custom"==i.type&&this.world.children.forEach((function(i){let n=i.userData.feature;if(n&&n.layer===t){let t=this.tb.getFeatureCenter(n,i,e);i.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 i=this.map.getLayer(t);if(i){if(!e)return void this.toggle(i.id,!1);let t=this.map.getZoom();if(i.minzoom&&t=i.maxzoom)return void this.toggle(i.id,!1);this.toggle(i.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,i){if(!this.enableTooltips&&t.tooltip&&(t.tooltip.visibility=!1),this.world.add(t),e){t.layer=e,t.source=i;let n=this.map.getLayer(e);if(n){let e=n.visibility,i=void 0===e;t.visibility=!(!i&&"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(((i,n)=>{let r=[];this.world.children.forEach((function(t){r.push(t)}));for(let e=0;e{t.promise.then((t=>{t.dispose(),t=null}))})),i("clear")}))},removeLayer:function(t){this.clear(t,!0).then((()=>{this.map.removeLayer(t)}))},getSunPosition:function(t,e){return o.getPosition(t||Date.now(),e[1],e[0])},getSunTimes:function(t,e){return o.getTimes(t,e[1],e[0],e[2]?e[2]:0)},setBuildingShadows:function(t){if(this.map.getLayer(t.buildingsLayerId)){let e=new v(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 i=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()===i.getTime()&&this.lightLng===this.mapCenter.lng&&this.lightLat===this.mapCenter.lat)return;this.lightDateTime=i,this.lightLng=this.mapCenter.lng,this.lightLat=this.mapCenter.lat,this.sunPosition=this.getSunPosition(i,[this.mapCenter.lng,this.mapCenter.lat]);let n=this.sunPosition.altitude,r=Math.PI+this.sunPosition.azimuth,o=s.WORLD_SIZE/2,a=Math.sin(n),l=Math.cos(n),c=Math.cos(r)*l,u=Math.sin(r)*l;this.lights.dirLight.position.set(u,c,a),this.lights.dirLight.position.multiplyScalar(o),this.lights.dirLight.intensity=Math.max(a,0),this.lights.hemiLight.intensity=Math.max(1*a,.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(i,this.sunPosition)))},getSunSky:function(t,e){if(!e){var i=this.map.getCenter();e=this.getSunPosition(t||Date.now(),[i.lng,i.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 i.AmbientLight(new i.Color("hsl(0, 0%, 100%)"),.75),this.scene.add(this.lights.ambientLight),this.lights.dirLightBack=new i.DirectionalLight(new i.Color("hsl(0, 0%, 100%)"),.25),this.lights.dirLightBack.position.set(30,100,100),this.scene.add(this.lights.dirLightBack),this.lights.dirLight=new i.DirectionalLight(new i.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 i.DirectionalLight(16777215,1),this.scene.add(this.lights.dirLight),t&&(this.lights.dirLightHelper=new i.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 i.HemisphereLight(new i.Color(16777215),new i.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.7"};var x={defaultLights:!1,realSunlight:!1,realSunlightHelper:!1,passiveRendering:!0,preserveDrawingBuffer:!1,enableSelectingFeatures:!1,enableSelectingObjects:!1,enableDraggingObjects:!1,enableRotatingObjects:!1,enableTooltips:!1,enableHelpTooltips:!1,multiLayer:!1,orthographic:!1,fov:s.FOV_DEGREES,sky:!1,terrain:!1};t.exports=_}(sd);var sf=sd.exports;!function(t,e){t.exports={Threebox:sf,THREE:ld}}(od);var af=od.exports,lf=Object.freeze({Linear:Object.freeze({None:function(t){return t},In:function(t){return this.None(t)},Out:function(t){return this.None(t)},InOut:function(t){return this.None(t)}}),Quadratic:Object.freeze({In:function(t){return t*t},Out:function(t){return t*(2-t)},InOut:function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)}}),Cubic:Object.freeze({In:function(t){return t*t*t},Out:function(t){return--t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)}}),Quartic:Object.freeze({In:function(t){return t*t*t*t},Out:function(t){return 1- --t*t*t*t},InOut:function(t){return(t*=2)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)}}),Quintic:Object.freeze({In:function(t){return t*t*t*t*t},Out:function(t){return--t*t*t*t*t+1},InOut:function(t){return(t*=2)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)}}),Sinusoidal:Object.freeze({In:function(t){return 1-Math.sin((1-t)*Math.PI/2)},Out:function(t){return Math.sin(t*Math.PI/2)},InOut:function(t){return.5*(1-Math.sin(Math.PI*(.5-t)))}}),Exponential:Object.freeze({In:function(t){return 0===t?0:Math.pow(1024,t-1)},Out:function(t){return 1===t?1:1-Math.pow(2,-10*t)},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?.5*Math.pow(1024,t-1):.5*(2-Math.pow(2,-10*(t-1)))}}),Circular:Object.freeze({In:function(t){return 1-Math.sqrt(1-t*t)},Out:function(t){return Math.sqrt(1- --t*t)},InOut:function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)}}),Elastic:Object.freeze({In:function(t){return 0===t?0:1===t?1:-Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)},Out:function(t){return 0===t?0:1===t?1:Math.pow(2,-10*t)*Math.sin(5*(t-.1)*Math.PI)+1},InOut:function(t){return 0===t?0:1===t?1:(t*=2)<1?-.5*Math.pow(2,10*(t-1))*Math.sin(5*(t-1.1)*Math.PI):.5*Math.pow(2,-10*(t-1))*Math.sin(5*(t-1.1)*Math.PI)+1}}),Back:Object.freeze({In:function(t){var e=1.70158;return 1===t?1:t*t*((e+1)*t-e)},Out:function(t){var e=1.70158;return 0===t?0:--t*t*((e+1)*t+e)+1},InOut:function(t){var e=2.5949095;return(t*=2)<1?t*t*((e+1)*t-e)*.5:.5*((t-=2)*t*((e+1)*t+e)+2)}}),Bounce:Object.freeze({In:function(t){return 1-lf.Bounce.Out(1-t)},Out:function(t){return t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},InOut:function(t){return t<.5?.5*lf.Bounce.In(2*t):.5*lf.Bounce.Out(2*t-1)+.5}}),generatePow:function(t){return void 0===t&&(t=4),t=(t=t1e4?1e4:t,{In:function(e){return Math.pow(e,t)},Out:function(e){return 1-Math.pow(1-e,t)},InOut:function(e){return e<.5?Math.pow(2*e,t)/2:(1-Math.pow(2-2*e,t))/2+.5}}}}),cf=function(){return performance.now()},uf=function(){function t(){this._tweens={},this._tweensAddedDuringUpdate={}}return t.prototype.getAll=function(){var t=this;return Object.keys(this._tweens).map((function(e){return t._tweens[e]}))},t.prototype.removeAll=function(){this._tweens={}},t.prototype.add=function(t){this._tweens[t.getId()]=t,this._tweensAddedDuringUpdate[t.getId()]=t},t.prototype.remove=function(t){delete this._tweens[t.getId()],delete this._tweensAddedDuringUpdate[t.getId()]},t.prototype.update=function(t,e){void 0===t&&(t=cf()),void 0===e&&(e=!1);var i=Object.keys(this._tweens);if(0===i.length)return!1;for(;i.length>0;){this._tweensAddedDuringUpdate={};for(var n=0;n1?o(t[i],t[i-1],i-n):o(t[r],t[r+1>i?i:r+1],n-r)},Bezier:function(t,e){for(var i=0,n=t.length-1,r=Math.pow,o=hf.Utils.Bernstein,s=0;s<=n;s++)i+=r(1-e,n-s)*r(e,s)*t[s]*o(n,s);return i},CatmullRom:function(t,e){var i=t.length-1,n=i*e,r=Math.floor(n),o=hf.Utils.CatmullRom;return t[0]===t[i]?(e<0&&(r=Math.floor(n=i*(1+e))),o(t[(r-1+i)%i],t[r],t[(r+1)%i],t[(r+2)%i],n-r)):e<0?t[0]-(o(t[0],t[0],t[1],t[1],-n)-t[0]):e>1?t[i]-(o(t[i],t[i],t[i-1],t[i-1],n-i)-t[i]):o(t[r?r-1:0],t[r],t[i1;n--)i*=n;return t[e]=i,i}}(),CatmullRom:function(t,e,i,n,r){var o=.5*(i-t),s=.5*(n-e),a=r*r;return(2*e-2*i+o+s)*(r*a)+(-3*e+3*i-2*o-s)*a+o*r+e}}},pf=function(){function t(){}return t.nextId=function(){return t._nextId++},t._nextId=0,t}(),df=new uf,ff=function(){function t(t,e){void 0===e&&(e=df),this._object=t,this._group=e,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=lf.Linear.None,this._interpolationFunction=hf.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=pf.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return t.prototype.getId=function(){return this._id},t.prototype.isPlaying=function(){return this._isPlaying},t.prototype.isPaused=function(){return this._isPaused},t.prototype.to=function(t,e){if(void 0===e&&(e=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=t,this._propertiesAreSetUp=!1,this._duration=e,this},t.prototype.duration=function(t){return void 0===t&&(t=1e3),this._duration=t,this},t.prototype.dynamic=function(t){return void 0===t&&(t=!1),this._isDynamic=t,this},t.prototype.start=function(t,e){if(void 0===t&&(t=cf()),void 0===e&&(e=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed)for(var i in this._reversed=!1,this._valuesStartRepeat)this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=t,this._startTime+=this._delayTime,!this._propertiesAreSetUp||e){if(this._propertiesAreSetUp=!0,!this._isDynamic){var n={};for(var r in this._valuesEnd)n[r]=this._valuesEnd[r];this._valuesEnd=n}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,e)}return this},t.prototype.startFromCurrentValues=function(t){return this.start(t,!0)},t.prototype._setupProperties=function(t,e,i,n,r){for(var o in i){var s=t[o],a=Array.isArray(s),l=a?"array":typeof s,c=!a&&Array.isArray(i[o]);if("undefined"!==l&&"function"!==l){if(c){if(0===(g=i[o]).length)continue;for(var u=[s],h=0,p=g.length;hr)return!1;e&&this.start(t,!0)}if(this._goToEnd=!1,t1?1:n;var o=this._easingFunction(n);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,o),this._onUpdateCallback&&this._onUpdateCallback(this._object,n),1===n){if(this._repeat>0){for(i in isFinite(this._repeat)&&this._repeat--,this._valuesStartRepeat)this._yoyo||"string"!=typeof this._valuesEnd[i]||(this._valuesStartRepeat[i]=this._valuesStartRepeat[i]+parseFloat(this._valuesEnd[i])),this._yoyo&&this._swapEndStartRepeatValues(i),this._valuesStart[i]=this._valuesStartRepeat[i];return this._yoyo&&(this._reversed=!this._reversed),void 0!==this._repeatDelayTime?this._startTime=t+this._repeatDelayTime:this._startTime=t+this._delayTime,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var s=0,a=this._chainedTweens.length;s{this.map=e,this.tb=new af.Threebox(e,i,{defaultLights:!0});const n=this.draw2(t);this.tb.add(n)},render:()=>{this.map&&this.map.triggerRepaint(),this.tb&&this.tb.update(),wf.update()}})}draw2(t){const e=new af.THREE.Group;return e.name=this.id+"lineGroup",t.forEach((t=>{const i=t.position[0],n=t.position[1],r=this.tb.utils.lnglatsToWorld([[...i]]),o=this.tb.utils.lnglatsToWorld([[...n]]),s=[new af.THREE.Vector3(r[0].x,r[0].y,r[0].z),new af.THREE.Vector3((r[0].x+o[0].x)/2,(r[0].y+o[0].y)/2,(r[0].z+o[0].z)/2),new af.THREE.Vector3(o[0].x,o[0].y,o[0].z)],a=this._option.width?this._option.width+1:60,l=new af.THREE.CatmullRomCurve3(s).getSpacedPoints(1e3),c=[];l.forEach(((t,e)=>{c.push(e)}));const u=(new af.THREE.BufferGeometry).setFromPoints(l);u.setAttribute("aIndex",new af.THREE.Float32BufferAttribute(c,1));const h=new af.THREE.ShaderMaterial({uniforms:{uColor:{value:new af.THREE.Color(this._option.color)},uTime:{value:0},uLength:{value:l.length},uWidth:{value:a}},vertexShader:"\n attribute float aIndex;\n \n uniform float uTime;\n uniform vec3 uColor;\n uniform float uWidth;\n \n varying float vSize;\n \n void main(){\n vec4 viewPosition = viewMatrix * modelMatrix *vec4(position,1);\n gl_Position = projectionMatrix * viewPosition;\n \n if(aIndex < uTime + 100.0 && aIndex > uTime - 100.0){\n vSize = (aIndex + 100.0 - uTime) / (300.0/uWidth );\n } \n gl_PointSize =vSize;\n }\n ",fragmentShader:"\n varying float vSize;\n uniform vec3 uColor;\n void main(){\n \n if(vSize<=0.0){\n gl_FragColor = vec4(1,0,0,0);\n }else{\n gl_FragColor = vec4(uColor,1);\n }\n \n }\n ",transparent:!0});e.add(new af.THREE.Points(u,h));new wf.Tween({index:1}).to({index:1e3},this._option.speed?100*this._option.speed:2e3).onUpdate((function(t){const e=Math.ceil(t.index);h.uniforms.uTime.value=e})).repeat(1/0).start()})),e}draw1(){const t=new af.THREE.Group;t.name="lineGroup";const e=this.tb.utils.lnglatsToWorld([[104.807073,29.35702,0]]),i=this.tb.utils.lnglatsToWorld([[104.807073,29.35702,0]]),n=[new af.THREE.Vector3(e[0].x,e[0].y,0),new af.THREE.Vector3((e[0].x+i[0].x)/2,(e[0].y+i[0].y)/2,5e3),new af.THREE.Vector3(e[0].x,e[0].y,1e4)],r=new af.THREE.CatmullRomCurve3(n),o=new af.THREE.TubeBufferGeometry(r,100,1,20,!1),s=(new af.THREE.TextureLoader).load("");s.repeat.set(20,20),s.needsUpdate=!0,s.wrapS=af.THREE.RepeatWrapping,s.wrapT=af.THREE.RepeatWrapping;const a=new af.THREE.MeshBasicMaterial({map:s,transparent:!0});t.add(new af.THREE.Mesh(o,a));return new wf.Tween({x:0}).to({x:100},2e3).onUpdate((function(){s.offset.x-=.01})).repeat(1/0).start(),t}}function Ef(t,e,i){let n;n=p(t)?$p(t,"multiLineString"):t;const r=e.labelOption?JSON.parse(JSON.stringify(e.labelOption)):{};let o;o=e.type&&"VerticalFlyingLine"==e.type?function(t,e,i){return new Af(t,e,i)}(t,e,i):new ed(n,e,i);const s=rd(n,{...r,allShow:!1!==r.allShow},o.id+"label");return!1===r.allShow&&(o.addEventListener("mouseIn",(t=>{s.hoveredPolygonId=t.id,cNt.value.setPaintProperty(s.id,"text-opacity",["case",["boolean",["==",["get","id"],s.hoveredPolygonId],!1],1,0])})),o.addEventListener("mouseOut",(()=>{s.hoveredPolygonId&&cNt.value.setPaintProperty(s.id,"text-opacity",0),s.hoveredPolygonId=null}))),o}class Sf extends(m(C)){options;id;bbox;LABEL;LINE;constructor(t,e,i){super(),this.bbox=[],this.id=i||d(0,3),this.options=Object.assign({color:"#ffffff",labelOption:{},type:"color",minzoom:0,maxzoom:24,opacity:1,isShow:!0},e),t&&(t.features.forEach((t=>{t.properties.imageurl=t.properties.image,t.properties.image=this.id+t.properties.imageurl,t.properties.highlightImageurl=t.properties.highlightImage,t.properties.highlightImage=this.id+t.properties.highlightImageurl})),this.bbox=Kp(t),cNt.value.addSource(this.id+"source",{type:"geojson",lineMetrics:!0,data:t})),"image"==this.options.type&&this.options.image&&this._addImages(t);const n={id:this.id,source:this.options.source?this.options.source:this.id+"source",minzoom:this.options.minzoom,maxzoom:this.options.maxzoom,type:null!=this.options.extrudedHeight?"fill-extrusion":"fill",layout:{visibility:this.options.isShow?"visible":"none"}};if(this.options.sourceLayer&&(n["source-layer"]=this.options.sourceLayer),null!=this.options.extrudedHeight?n.paint={"fill-extrusion-color":this.options.color,"fill-extrusion-height":this.options.extrudedHeight,"fill-extrusion-opacity":this.options.opacity,"fill-extrusion-pattern":this.options.image?Array.isArray(this.options.image)?this.options.image:this.id+this.options.image:""}:(n.paint={"fill-color":this.options.color,"fill-outline-color":this.options.color},uNt.value&&"EPSG:3857"!=uNt.value||(n.paint={...n.paint,"fill-pattern":this.options.image?Array.isArray(this.options.image)?this.options.image:this.id+this.options.image:""})),cNt.value.addLayer(n),this.options.filter&&cNt.value.setFilter(this.id,this.options.filter),(this.options.highlightColor||this.options.highlightImage)&&null==this.options.extrudedHeight&&!cNt.value.getLayer(this.id+"Highlight")){cNt.value.addSource(this.id+"Highlightsource",{type:"geojson",lineMetrics:!0,data:t});let e={};e=this.options.highlightColor?{"fill-color":this.options.highlightColor}:{"fill-pattern":this.options.highlightImage?Array.isArray(this.options.highlightImage)?this.options.highlightImage:this.id+this.options.highlightImage:""},cNt.value.addLayer({id:this.id+"Highlight",source:this.id+"Highlightsource",type:"fill",filter:["in","id",""],layout:{visibility:this.options.isShow?"visible":"none"},paint:e})}}_addImages(t){if(Array.isArray(this.options.image)){const{features:e}=t;e.forEach((t=>{this._addImage(t.properties.imageurl,t.properties.image),this._addImage(t.properties.highlightImageurl,t.properties.highlightImage)}))}else this._addImage(this.options.image,this.id+this.options.image),this._addImage(this.options.highlightImage,this.id+this.options.highlightImage)}_addImage(t,e){cNt.value.loadImage(t,((t,i)=>{if(t)throw t;cNt.value.hasImage(e)||cNt.value.addImage(e,i)}))}getId(){return this.id}highlight(t,e){cNt.value.getLayer(this.id+"Highlight")&&cNt.value.setFilter(this.id+"Highlight",["in","id",t]),this.options.extrudedHeight&&(this.options.highlightColor||this.options.highlightImage)&&(this.options.highlightColor?cNt.value.setPaintProperty(this.id,"fill-extrusion-color",["case",["boolean",["==",["get",e||"id"],t],!1],this.options.highlightColor,this.options.color]):cNt.value.setPaintProperty(this.id,"fill-extrusion-pattern",["case",["boolean",["==",["get",e||"id"],t],!1],this.id+this.options.highlightImage,this.id+this.options.image]))}removeHighlight(){cNt.value.getLayer(this.id+"Highlight")&&cNt.value.setFilter(this.id+"Highlight",["in","id",""])}_update(t){this.bbox=Kp(t),this._updateSource("source",t),this._updateSource("Highlightsource",t)}_updateSource(t,e){const i=cNt.value.getSource(this.id+t);i&&i.setData(e)}_isFeatureCollectionData(t){return t instanceof Array}_addLabel(t){this.LABEL&&(this.LABEL.destroy(),this.LABEL="");const e=this.options.labelOption?JSON.parse(JSON.stringify(this.options.labelOption)):"";this.LABEL=rd(t,{...e,allShow:!1!==e.allShow},this.id+"label"),!1===e.allShow&&(this.addEventListener("mouseIn",(t=>{this.LABEL.hoveredPolygonId=t.id,t.id&&cNt.value.setPaintProperty(this.LABEL.id,"text-opacity",["case",["boolean",["==",["get","id"],this.LABEL.hoveredPolygonId],!1],1,0])})),this.addEventListener("mouseOut",(()=>{this.LABEL.hoveredPolygonId&&cNt.value.setPaintProperty(this.LABEL.id,"text-opacity",0),this.LABEL.hoveredPolygonId=null})))}_addLine(t){if(this.options.outLineColor){const e={width:this.options.outLineWidth?this.options.outLineWidth:1,color:this.options.outLineColor,highlightColor:this.options.highlightColor?this.options.highlightColor:"",isShow:this.options.isShow};this.LINE=Ef(t,e,this.id+"line")}}}class Mf extends Sf{constructor(t,e,i){super(t,e,i)}update(t){let e=t;if(t instanceof Array){e=$p(Tf(t),"multiPolygon");const i=t.map((t=>({position:t.center,text:t.text,id:t.id,userData:t.userData})));this._addLabel(i);const n=Tf(t).map((t=>({position:t.position[0],id:t.id})));this.LINE.update(n)}this._update(e)}}function Tf(t){return t.map((t=>({position:[Z(Up(R(t.center),t.radius,{units:"kilometers",steps:50}))],text:t.text?t.text:"",id:t.id?t.id:"",userData:t.userData?t.userData:{}})))}class If extends Sf{constructor(t,e,i){super(t,e,i)}update(t){let e=t;if(t instanceof Array){e=$p(Cf(t),"multiPolygon");const i=e.map((t=>({position:t.center,text:t.text,id:t.id,userData:t.userData})));this._addLabel(i);const n=e.map((t=>({position:t.position[0],id:t.id})));this.LINE.update(n)}this._update(e)}}function Cf(t){const e=t.map((t=>{const e=[];t.position.forEach((t=>{e.push(R(t))}));const i=N(e),n=Z(vt(i)),r=bt(i);return{position:[n],text:t.text?t.text:"",id:t.id?t.id:"",userData:t.userData?t.userData:{},center:r.geometry.coordinates}}));return e}class Pf extends Sf{constructor(t,e,i){super(t,e,i)}update(t){let e=t;if(t instanceof Array){e=$p(t,"multiPolygon"),this._addLabel(function(t){const e=t.map((t=>({position:t.position[0][0],text:t.text?t.text:null,id:t.id?t.id:null,userData:t.userData?t.userData:null})));return e}(t));const i=[];t.map((t=>{t.position.forEach((t=>{i.push({position:[...t,t[0]]})}))})),this.LINE.update(i)}this._update(e)}}class Lf extends Sf{_featureArr;_flag;_heighConfig;_timeOver;constructor(t,e,i){super(t,e,i),this._featureArr=[],this._heighConfig={key:"id",properties:{},height:0,upSpeed:2e3,downSpeed:400},this._flag=0,this._timeOver=!1}stretchHeight(t){this._heighConfig={...this._heighConfig,...t},this._featureArr.unshift(this._heighConfig.properties[this._heighConfig.key]),this._featureArr=this._featureArr.filter(((t,e)=>e<=1)),(1==this._featureArr.length||this._timeOver)&&(this.animate(),this.tweenDown())}removeStretchHeight(){cNt.value.setPaintProperty(this.id,"fill-extrusion-height",this.options.extrudedHeight)}animate(){this._flag=requestAnimationFrame((()=>this.animate())),bf()}tweenUp(){const t={h:0};new ff(t).to({h:this._heighConfig.height},this._heighConfig.upSpeed).easing(lf.Quadratic.InOut).onUpdate((()=>{cNt.value.getLayer(this.id)&&cNt.value.setPaintProperty(this.id,"fill-extrusion-height",["case",["boolean",["==",["get",this._heighConfig.key],this._featureArr[0]],!1],t.h,this.options.extrudedHeight])})).onComplete((()=>{window.cancelAnimationFrame(this._flag),this._timeOver=!0})).start()}tweenDown(){const t={h:this._heighConfig.height};new ff(t).to({h:0},this._heighConfig.downSpeed).onUpdate((()=>{this._featureArr.length>1&&(this._timeOver=!1,cNt.value.getLayer(this.id)&&cNt.value.setPaintProperty(this.id,"fill-extrusion-height",["case",["boolean",["==",["get",this._heighConfig.key],this._featureArr[1]],!1],t.h,this.options.extrudedHeight]))})).onComplete((()=>{this.tweenUp()})).start()}}function Df(t,e,i){let n,r;if(t&&p(t)?r=$p(t,"multiPolygon"):t&&(r=t),e&&(e.source||null!=e.extrudedHeight)?n=new Lf(r,e,i):r&&(n=new Pf(r,e,i)),r){n&&n._addLabel(r);const t=JSON.parse(JSON.stringify(r.features)).map((t=>{let e=[];return"Polygon"==t.geometry.type?e=t.geometry.coordinates[0]:"MultiPolygon"==t.geometry.type&&(e=t.geometry.coordinates[0][0]),{position:e,id:t.properties.id}}));n&&n._addLine(t)}return n}function Rf(t,e){void 0===e&&(e={});var i=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===i&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}Rf(".mapboxgl-marker {\r\n\tposition: absolute;\r\n\ttop: 0;\r\n\tleft: 0;\r\n\twill-change: transform;\r\n\topacity: 1;\r\n\t-webkit-transition: opacity 0.2s;\r\n\ttransition: opacity 0.2s;\r\n}\r\n/* .mapboxgl-marker-anchor-left {\r\n\tbackground: #333 !important;\r\n\tcolor: #fff;\r\n} */\r\n/* .measure-result {\r\n\ttext-align: left;\r\n\tpadding: 0 10px;\r\n\tbackground: #333 !important;\r\n\tcolor: #fff;\r\n} */\r\n\r\n/* .measure-result-Length {\r\n\tbackground: #333 !important;\r\n\tpadding: 0 10px;\r\n\tcolor: #fff;\r\n} */\r\n\r\n.measure-area {\r\n\tbackground: #333;\r\n\tpadding: 0 10px;\r\n\tcolor: #fff;\r\n}\r\n\r\n.measure-area-html {\r\n\tposition: relative;\r\n\tpadding-right: 14px;\r\n}\r\n\r\n/* .measure-result-close {\r\n\tposition: absolute;\r\n\ttop: 1px;\r\n\tright: 2px;\r\n\tcursor: pointer !important;\r\n} */\r\n\r\n.popup-set-styles {\r\n\tfont-size: 14px;\r\n\tfont-weight: bold;\r\n}\r\n");class Of{option;ele;tooltipDistance;markers;jsonPoint;jsonLine;points;mapClick;mapMousemove;mapDblclick;id;callJson;constructor(t){this.option=t,this.markers={tooltipDistance:null,clearLength:null},this.jsonPoint={type:"FeatureCollection",features:[]},this.jsonLine={type:"FeatureCollection",features:[]},this.callJson={type:"Feature",geometry:{type:"LineString",coordinates:[]},properties:{}},this.points=[[0,0]],this.points.pop(),this.id=d(0,10)}initElement(){this.ele=document.createElement("div"),this.ele.setAttribute("style",`text-align: left;\n\t\t\tpadding: 3px 10px;\n\t\t\tfont-size: ${this.option?this.option.fontSize:"14px"};\n\t\t\tbackground: ${this.option?this.option.backgroundColor:"#333"} !important;\n\t\t\tcolor: ${this.option?this.option.fontColor:"#fff"};\n\t\t\tz-index: 10;`);const t={element:this.ele,anchor:"left",offset:[8,0]};this.tooltipDistance=new cNt.value.mapboxgl.Marker(t).setLngLat([0,0]).addTo(cNt.value),this.markers.tooltipDistance=this.tooltipDistance}initLayer(){cNt.value.getSource(this.id+"pointsMeasure")?(this.id=d(0,10),this.initLayer()):(cNt.value.addSource(this.id+"pointsMeasure",{type:"geojson",data:this.jsonPoint}),cNt.value.addLayer({id:this.id+"pointsMeasure",type:"circle",source:this.id+"pointsMeasure",paint:{"circle-color":"#ffffff","circle-radius":this.option?this.option.pixelSize:3,"circle-stroke-width":2,"circle-stroke-color":this.option?this.option.color:"#ff0000"}}),cNt.value.addSource(this.id+"lineMeasure",{type:"geojson",data:this.jsonLine}),cNt.value.addLayer({id:this.id+"lineMeasure",type:"line",source:this.id+"lineMeasure",paint:{"line-color":this.option?this.option.lineColor:"#ff0000","line-width":this.option?this.option.lineWidth:2}}))}initLineLayer(){cNt.value.getSource(this.id+"lineMoveMeasure")?(this.id=d(0,10),this.initLineLayer()):(this.initLayer(),cNt.value.addSource(this.id+"lineMoveMeasure",{type:"geojson",data:this.jsonLine}),cNt.value.addLayer({id:this.id+"lineMoveMeasure",type:"line",source:this.id+"lineMoveMeasure",paint:{"line-color":this.option?this.option.lineColor:"#ff0000","line-width":this.option?this.option.lineWidth:2,"line-opacity":this.option?this.option.lineOpacity:.65}}))}initAreaLayer(){cNt.value.getSource(this.id+"areaMeasure")?(this.id=d(0,10),this.initAreaLayer()):(this.initLayer(),cNt.value.addSource(this.id+"areaMeasure",{type:"geojson",data:this.jsonPoint}),cNt.value.addLayer({id:this.id+"areaMeasure",type:"fill",source:this.id+"areaMeasure",paint:{"fill-color":this.option?this.option.fillColor:"#ff0000","fill-opacity":this.option?this.option.fillOpacity:.1}}),cNt.value.addLayer({id:this.id+"strokeMeasure",type:"line",source:this.id+"areaMeasure",paint:{"line-color":this.option?this.option.lineColor:"#ff0000","line-width":this.option?this.option.lineWidth:2,"line-opacity":this.option?this.option.lineOpacity:.65}}))}addPoint(t){if(this.jsonPoint.features.length>0){const e=this.jsonPoint.features[this.jsonPoint.features.length-1];this.jsonLine.features.push({type:"Feature",geometry:{type:"LineString",coordinates:[e.geometry.coordinates,t]},properties:null}),cNt.value.getSource(this.id+"lineMeasure").setData(this.jsonLine)}this.jsonPoint.features.push({type:"Feature",geometry:{type:"Point",coordinates:t},properties:null}),cNt.value.getSource(this.id+"pointsMeasure").setData(this.jsonPoint)}clearMapEvent(){cNt.value.off("click",this.mapClick),cNt.value.off("mousemove",this.mapMousemove),cNt.value.off("dblclick",this.mapDblclick),cNt.value.off("contextmenu",this.mapDblclick)}}function kf(t,e){const i=ye(k(t),{units:e&&e.units?e.units:"kilometers"}),n=e&&e.digit?e.digit:2;return i.toFixed(n)}class Nf extends(m(Of)){constructor(t){super(),this.option=t,this.jsonPoint={type:"FeatureCollection",features:[]},this.jsonLine={type:"FeatureCollection",features:[]},this.markers={tooltipDistance:null,clearLength:null},this.points=[[0,0]],this.points.pop(),this.initLineLayer(),this.initElement()}measureLength(t){cNt.value.doubleClickZoom.disable(),cNt.value.getCanvas().style.cursor="crosshair";const e=t=>{const e=[t.lngLat.lng,t.lngLat.lat];this.points.push(e),this.addMeasureRes(e),this.addPoint(e)};this.mapClick=e,cNt.value.on("click",e);const i=t=>{const e=[t.lngLat.lng,t.lngLat.lat];if(this.jsonPoint.features.length>0){const t={type:"Feature",geometry:{type:"LineString",coordinates:[this.jsonPoint.features[this.jsonPoint.features.length-1].geometry.coordinates,e]},properties:{}};cNt.value.getSource(this.id+"lineMoveMeasure").setData(t),this.ele&&(this.ele.innerHTML=this.getLength(e))}else this.ele&&(this.ele.innerHTML="点击地图开始测量");this.tooltipDistance.setLngLat(e)};this.mapMousemove=i,cNt.value.on("mousemove",i);const n=e=>{const i=[e.lngLat.lng,e.lngLat.lat];this.addPoint(i),cNt.value.getCanvas().style.cursor="",this.tooltipDistance.remove();const n=document.createElement("div"),r=document.createElement("span");r.setAttribute("style",`background: ${this.option?this.option.backgroundColor:"#333"} !important;\n\t\t\t\tfont-size: ${this.option?this.option.fontSize:"14px"};\n\t\t\t\tpadding: 3px 18px 3px 10px;\n\t\t\t\tcolor: ${this.option?this.option.fontColor:"#fff"};`);const o=document.createElement("span");o.setAttribute("style",`position: absolute;\n\t\t\t\ttop: 0px;\n\t\t\t\tright: 4px;\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tfont-size: ${this.option?this.option.fontSize:"14px"};\n\t\t\t\tcolor: ${this.option?this.option.fontColor:"#fff"};`),o.innerHTML="×",n.appendChild(r),n.appendChild(o);const s={element:n,anchor:"left",offset:[8,0]},a=this.getLength(i);r.innerHTML=0===this.points.length?"起点":a,t&&t(this.jsonLine,a);const l=new cNt.value.mapboxgl.Marker(s).setLngLat(i).addTo(cNt.value);this.markers.clearLength=l,this.clearMapEvent(),o.onclick=t=>{t.stopPropagation(),cNt.value.doubleClickZoom.enable(),this.clear()}};this.mapDblclick=n,cNt.value.on("dblclick",n),cNt.value.on("contextmenu",n)}addMeasureRes(t){const e=document.createElement("div");e.setAttribute("style",`background: ${this.option?this.option.backgroundColor:"#333"} !important;\n\t\t\tfont-size: ${this.option?this.option.fontSize:"14px"};\n\t\t\tpadding: 3px 10px;\n\t\t\tcolor: ${this.option?this.option.fontColor:"#fff"};`);const i={element:e,anchor:"left",offset:[8,0]};e.innerHTML=0===this.points.length?"起点":this.getLength(t);const n=new cNt.value.mapboxgl.Marker(i).setLngLat(t).addTo(cNt.value);this.markers["markerLength"+this.points.length]=n}getLength(t){const e=this.points.concat([t]),i=Number(kf(e,{units:"meters"}));let n="";return n=i<1e3?i+"m":(i/1e3).toFixed(2)+"km",n}clear(){this.clearMapEvent(),cNt.value.getLayer(this.id+"pointsMeasure")&&(cNt.value.removeLayer(this.id+"pointsMeasure"),cNt.value.removeLayer(this.id+"lineMeasure"),cNt.value.removeLayer(this.id+"lineMoveMeasure"),cNt.value.removeSource(this.id+"pointsMeasure"),cNt.value.removeSource(this.id+"lineMeasure"),cNt.value.removeSource(this.id+"lineMoveMeasure"));for(const t in this.markers)t&&this.markers[t]&&(this.markers[t].remove(),this.markers[t]=null);this.points=[],this.jsonPoint={type:"FeatureCollection",features:[]},this.jsonLine={type:"FeatureCollection",features:[]},this.ele,this.tooltipDistance,this.mapClick,this.mapMousemove,this.mapDblclick}}function Bf(t,e){const i=e||2;return pe(O(t)).toFixed(i)}class zf extends(m(Of)){option;constructor(t){super(),this.option=t,this.jsonPoint={type:"FeatureCollection",features:[]},this.jsonLine={type:"FeatureCollection",features:[]},this.markers={tooltipDistance:null,clearLength:null},this.points=[[0,0]],this.points.pop(),this.initAreaLayer(),this.initElement()}measureArea(t){cNt.value.doubleClickZoom.disable(),cNt.value.getCanvas().style.cursor="crosshair";const e=t=>{const e=[t.lngLat.lng,t.lngLat.lat];this.points.push(e),this.addPoint(e)};this.mapClick=e,cNt.value.on("click",e);const i=t=>{const e=[t.lngLat.lng,t.lngLat.lat],i=this.jsonPoint.features.length;if(0===i)this.ele&&(this.ele.innerHTML="点击地图开始测量");else if(1===i)this.ele&&(this.ele.innerHTML="点击地图继续绘制");else{let t=this.points.concat([e]);t=t.concat([this.points[0]]);const i={type:"Feature",geometry:{type:"Polygon",coordinates:[t]},properties:{}};cNt.value.getSource(this.id+"areaMeasure").setData(i),this.callJson=i,this.ele&&(this.ele.innerHTML=this.getArea(e))}this.tooltipDistance.setLngLat(e)};this.mapMousemove=i,cNt.value.on("mousemove",i);const n=e=>{const i=[e.lngLat.lng,e.lngLat.lat];this.points.push(i);const n=this.getArea(i);this.tooltipDistance.remove();const r=document.createElement("div");r.setAttribute("class","measure-area"),r.setAttribute("style",`background: ${this.option?this.option.backgroundColor:"#333"} !important;\n\t\t\t\tfont-size: ${this.option?this.option.fontSize:"14px"};\n\t\t\t\tcolor: ${this.option?this.option.fontColor:"#fff"};`);const o=document.createElement("div");o.setAttribute("class","measure-area-html"),o.innerHTML=n;const s=document.createElement("div");s.setAttribute("style",`position: absolute;\n\t\t\t\ttop: 0px;\n\t\t\t\tright: 4px;\n\t\t\t\tcursor: pointer !important;\n\t\t\t\tfont-size: ${this.option?this.option.fontSize:"14px"};\n\t\t\t\tcolor: ${this.option?this.option.fontColor:"#fff"};`),this.clearMapEvent(),s.onclick=t=>{t.stopPropagation(),cNt.value.doubleClickZoom.enable(),this.clear()},s.innerHTML="×",o.appendChild(s),r.appendChild(o);const a={element:r,anchor:"bottom-left",offset:[-5,-10]},l={type:"Feature",geometry:{type:"Polygon",coordinates:[this.points]}};t&&t(this.callJson,n);const c=wt(l),u=new cNt.value.mapboxgl.Marker(a).setLngLat(c.geometry.coordinates).addTo(cNt.value);this.markers.lineAreas=u,cNt.value.getCanvas().style.cursor=""};this.mapDblclick=n,cNt.value.on("dblclick",n),cNt.value.on("contextmenu",n)}getArea(t){let e=this.points.concat([t]);e=e.concat([this.points[0]]);const i=Number(Bf([e]));let n="";return n=i<1e4?Math.round(i)+"m²":(i/1e6).toFixed(2)+"km²",n}clear(){this.clearMapEvent(),cNt.value.getLayer(this.id+"areaMeasure")&&(cNt.value.removeLayer(this.id+"pointsMeasure"),cNt.value.removeLayer(this.id+"lineMeasure"),cNt.value.removeLayer(this.id+"strokeMeasure"),cNt.value.removeLayer(this.id+"areaMeasure"),cNt.value.removeSource(this.id+"pointsMeasure"),cNt.value.removeSource(this.id+"lineMeasure"),cNt.value.removeSource(this.id+"areaMeasure"));for(const t in this.markers)t&&this.markers[t]&&(this.markers[t].remove(),this.markers[t]=null);this.points=[],this.jsonPoint={type:"FeatureCollection",features:[]},this.jsonLine={type:"FeatureCollection",features:[]},this.ele,this.tooltipDistance,this.mapClick,this.mapMousemove,this.mapDblclick}}class Ff{distanceObj;areaObj;option;ele;tooltipDistance;markers;jsonPoint;jsonLine;constructor(t){this.option=t,this.markers={tooltipDistance:null,clearLength:null},this.jsonPoint={type:"FeatureCollection",features:[]},this.jsonLine={type:"FeatureCollection",features:[]}}clearAll(){this.clearDistance(),this.clearArea()}measureDistance(t){const e=new Nf(this.option);this.distanceObj||(this.distanceObj=[]),this.distanceObj.push(e),e.measureLength(((e,i)=>{t&&t(e,i)}))}clearDistance(){if(this.distanceObj){for(const t of this.distanceObj)t.clear();this.distanceObj=[]}}measureArea(t){const e=new zf(this.option);this.areaObj||(this.areaObj=[]),this.areaObj.push(e),e.measureArea(((e,i)=>{t&&t(e,i)}))}clearArea(){if(this.areaObj){for(const t of this.areaObj)t.clear();this.areaObj=[]}}}class Vf extends id{id;_clusterOption;imageList;imageFormat;fontFormat;constructor(t,e,i){super(t,i,e),this.id=e,this._clusterOption=Object.assign({size:18,pixelRange:60,gradient:{1:"#00BFFF",10:"#008000",100:"#FFA500",1e3:"#FF0000"},fontSize:12,fontColor:"#fff",style:"circle",image:"./data/image/monitor.png",fontFamily:["Open Sans Regular","Arial Unicode MS Regular"],clustersFly:!0,isShow:!0},i),this.imageList={},this.imageFormat=["step",["get","point_count"]],this.fontFormat=["step",["get","point_count"],this._clusterOption.fontSize],this._addImage()}_addImage(){const t=[];Object.getOwnPropertyNames(this._clusterOption.gradient).forEach(((e,i)=>{const n=new Promise(((t,n)=>{let r;"circle"==this._clusterOption.style&&this._clusterOption.gradient?r=this._drawCircle(this._clusterOption.gradient[e],i):"spiral"==this._clusterOption.style&&this._clusterOption.gradient?r=this._drawClustering(this._clusterOption.gradient[e],i):"custom"==this._clusterOption.style&&this._clusterOption.gradient&&(r=this._clusterOption.gradient[e]),this.fontFormat.push(Number(e),(this._clusterOption.fontSize||12)+3*i);const o=`${this.id}-${e}-custer`;this.imageList[o]=r,0==i&&this.imageFormat.push(o),this.imageFormat.push(Number(e),o),cNt.value.loadImage(r,((e,i)=>{e?n(e):cNt.value.hasImage(o)?n("Image name already exists"):(cNt.value.addImage(o,i),t())}))}));t.push(n)})),Promise.all(t).then((()=>{this.renderCircle()})).catch((t=>{console.error("Error loading images:",t)}))}renderCircle(){cNt.value.addLayer({id:`${this.id}-clusters`,type:"symbol",source:`${this.id}source`,filter:["has","point_count"],layout:{"icon-image":this.imageFormat,"icon-allow-overlap":!0,visibility:this._options.isShow?"visible":"none"}}),cNt.value.addLayer({id:`${this.id}-clusters-count`,type:"symbol",source:`${this.id}source`,filter:["has","point_count"],layout:{"text-field":"{point_count}","text-font":this._clusterOption.fontFamily,"text-size":this.fontFormat,"text-allow-overlap":!0,visibility:this._options.isShow?"visible":"none"},paint:{"text-color":this._clusterOption.fontColor,"text-halo-width":.3,"text-halo-color":this._clusterOption.fontColor}}),this._clusterOption.clustersFly&&cNt.value.on("click",`${this.id}-clusters`,(t=>this.circleClick(t))),cNt.value.on("mouseenter",`${this.id}-clusters`,this.setCursor),cNt.value.on("mouseleave",`${this.id}-clusters`,this.setCursor)}setCursor=t=>{"mouseenter"==t.type?cNt.value.getCanvas().style.cursor="pointer":"mouseleave"==t.type&&(cNt.value.getCanvas().style.cursor="")};circleClick(t){const e=cNt.value.queryRenderedFeatures(t.point,{layers:[`${this.id}-clusters`]}),i=e[0].properties.cluster_id;cNt.value.getSource(`${this.id}source`).getClusterExpansionZoom(i,((t,i)=>{t||cNt.value.easeTo({center:e[0].geometry.coordinates,zoom:i})}))}flyToClusterPoint(t){let e;e=p(t)?$p(t,"point"):t,td(e,!0)}destroy(){cNt.value.getLayer(`${this.id}-clusters`)&&cNt.value.removeLayer(`${this.id}-clusters`),cNt.value.getLayer(`${this.id}-clusters-count`)&&cNt.value.removeLayer(`${this.id}-clusters-count`),cNt.value.off("click",`${this.id}-clusters`,(t=>this.circleClick(t))),cNt.value.off("mouseenter",`${this.id}-clusters`,this.setCursor),cNt.value.off("mouseleave",`${this.id}-clusters`,this.setCursor),this.removeImage(),super.destroy()}show(t){if(!cNt.value.getLayer(this.id))throw new Error(`Layer name "${this.id}" does not exist.`);{const e=t?"visible":"none";cNt.value.setLayoutProperty(`${this.id}-clusters`,"visibility",e),cNt.value.setLayoutProperty(`${this.id}-clusters-count`,"visibility",e),super.show(t)}}update(t){super.update(t)}highlight(t,e=!0){const i=cNt.value.getSource(this.id+"source")._data.features.find((e=>e.properties.id==t));if(e&&td(i,!0),!i||!this._options.highlightImageName)throw new Error(`The highlight id is ${t} does not exist`);{const t=i;cNt.value.addSource(this.id+"Highlightsource",{type:"geojson",data:t});const e="string"==typeof this._options.highlightImageName;cNt.value.addLayer({id:this.id+"Highlight",source:this.id+"Highlightsource",type:"symbol",layout:{visibility:this._options.isShow?"visible":"none","icon-image":e?this._options.highlightImageName:["get","highlightImageName"],"icon-size":this._options.scale},paint:{}})}}removeHighlight(){cNt.value.getLayer(this.id+"Highlight")&&cNt.value.removeLayer(this.id+"Highlight"),cNt.value.getSource(this.id+"Highlightsource")&&cNt.value.removeSource(this.id+"Highlightsource")}removeImage(t){t?cNt.value.hasImage(t+"-custer")&&cNt.value.removeImage(t+"-custer"):Object.keys(this.imageList).forEach((t=>{cNt.value.hasImage(t)&&cNt.value.removeImage(t)}))}_drawCircle(t,e){const i=2.5*(this._clusterOption.size?this._clusterOption.size:0)+15*e,n=document.createElement("canvas");n.width=i,n.height=i;const r=n.getContext("2d");return r&&(r.save(),r.scale(i/24,i/24),r.fillStyle=this._rgbToRgba(t,.2),r.beginPath(),r.arc(12,12,9,0,2*Math.PI),r.closePath(),r.fill(),r.beginPath(),r.arc(12,12,6,0,2*Math.PI),r.fillStyle=this._rgbToRgba(t,1),r.fill(),r.closePath(),r.restore()),n.toDataURL()}_drawClustering(t,e){const i=2.5*(this._clusterOption.size?this._clusterOption.size:0)+15*e;let n=-Math.PI/12;const r=Math.PI/2,o=Math.PI/6,s=document.createElement("canvas");s.width=i,s.height=i;const a=s.getContext("2d");if(a){a.save(),a.scale(i/24,i/24),a.beginPath(),a.arc(12,12,6,0,2*Math.PI),a.fillStyle=this._rgbToRgba(t,1),a.fill(),a.closePath(),a.lineWidth=2;for(let e=0;e<3;e++)a.beginPath(),a.arc(12,12,8,n,n+r,!1),a.strokeStyle=this._rgbToRgba(t,.4),a.stroke(),a.arc(12,12,11,n,n+r,!1),a.strokeStyle=this._rgbToRgba(t,.2),a.stroke(),a.closePath(),n=n+r+o;a.restore()}return s.toDataURL()}_hexTo10(t){if("#"===t.charAt(0)&&(t=t.substr(1)),6!==t.length)throw new Error("输入的不是有效的16进制颜色代码。");return`rgb(${parseInt(t.substr(0,2),16)},${parseInt(t.substr(2,2),16)},${parseInt(t.substr(4,2),16)})`}_rgbToRgba(t,e){const i=this._hexTo10(t).match(/(\d+),(\d+),(\d+)/);if(!i)throw new Error("输入的不是有效的 RGB 颜色值。");const n=parseInt(i[1]),r=parseInt(i[2]),o=parseInt(i[3]);if(e<0||e>1)throw new Error("透明度值必须在0到1之间。");return`rgba(${n},${r},${o},${e})`}}var Uf={exports:{}};!function(t,e){t.exports=function(){var t=function(t,e){var i={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},n={on:function(t,e,n){if(void 0===i[t])throw new Error("Invalid event type: "+t);i[t].push({selector:e,fn:n})},render:function(t){e.store.featureChanged(t)}},r=function(t,r){for(var o=i[t],s=o.length;s--;){var a=o[s];if(a.selector(r)){a.fn.call(n,r)||e.store.render(),e.ui.updateMapClasses();break}}};return t.start.call(n),{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){r("drag",t)},click:function(t){r("click",t)},mousemove:function(t){r("mousemove",t)},mousedown:function(t){r("mousedown",t)},mouseup:function(t){r("mouseup",t)},mouseout:function(t){r("mouseout",t)},keydown:function(t){r("keydown",t)},keyup:function(t){r("keyup",t)},touchstart:function(t){r("touchstart",t)},touchmove:function(t){r("touchmove",t)},touchend:function(t){r("touchend",t)},tap:function(t){r("tap",t)}}};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function i(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var i=function t(){if(this instanceof t){var i=[null];return i.push.apply(i,arguments),new(Function.bind.apply(e,i))}return e.apply(this,arguments)};i.prototype=e.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(i,e,n.get?n:{enumerable:!0,get:function(){return t[e]}})})),i}var n={},r={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:6356752.3142},o=r;function s(t){var e=0;if(t&&t.length>0){e+=Math.abs(a(t[0]));for(var i=1;i2){for(a=0;a=Math.pow(2,t)?k(t,e):o};k.rack=function(t,e,i){var n=function(n){var o=0;do{if(o++>10){if(!i)throw new Error("too many ID collisions, use more bits");t+=i}var s=k(t,e)}while(Object.hasOwnProperty.call(r,s));return r[s]=n,s},r=n.hats={};return n.get=function(t){return n.hats[t]},n.set=function(t,e){return n.hats[t]=e,n},n.bits=t||128,n.base=e||16,n};var N=e(O.exports),B=function(t,e){this.ctx=t,this.properties=e.properties||{},this.coordinates=e.geometry.coordinates,this.id=e.id||N(),this.type=e.geometry.type};B.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},B.prototype.incomingCoords=function(t){this.setCoordinates(t)},B.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},B.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},B.prototype.setProperty=function(t,e){this.properties[t]=e},B.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:d.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},B.prototype.internal=function(t){var e={id:this.id,meta:y.FEATURE,"meta:type":this.type,active:v.INACTIVE,mode:t};if(this.ctx.options.userProperties)for(var i in this.properties)e["user_"+i]=this.properties[i];return{type:d.FEATURE,properties:e,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var z=function(t,e){B.call(this,t,e)};(z.prototype=Object.create(B.prototype)).isValid=function(){return"number"==typeof this.coordinates[0]&&"number"==typeof this.coordinates[1]},z.prototype.updateCoordinate=function(t,e,i){this.coordinates=3===arguments.length?[e,i]:[t,e],this.changed()},z.prototype.getCoordinate=function(){return this.getCoordinates()};var F=function(t,e){B.call(this,t,e)};(F.prototype=Object.create(B.prototype)).isValid=function(){return this.coordinates.length>1},F.prototype.addCoordinate=function(t,e,i){this.changed();var n=parseInt(t,10);this.coordinates.splice(n,0,[e,i])},F.prototype.getCoordinate=function(t){var e=parseInt(t,10);return JSON.parse(JSON.stringify(this.coordinates[e]))},F.prototype.removeCoordinate=function(t){this.changed(),this.coordinates.splice(parseInt(t,10),1)},F.prototype.updateCoordinate=function(t,e,i){var n=parseInt(t,10);this.coordinates[n]=[e,i],this.changed()};var V=function(t,e){B.call(this,t,e),this.coordinates=this.coordinates.map((function(t){return t.slice(0,-1)}))};(V.prototype=Object.create(B.prototype)).isValid=function(){return 0!==this.coordinates.length&&this.coordinates.every((function(t){return t.length>2}))},V.prototype.incomingCoords=function(t){this.coordinates=t.map((function(t){return t.slice(0,-1)})),this.changed()},V.prototype.setCoordinates=function(t){this.coordinates=t,this.changed()},V.prototype.addCoordinate=function(t,e,i){this.changed();var n=t.split(".").map((function(t){return parseInt(t,10)}));this.coordinates[n[0]].splice(n[1],0,[e,i])},V.prototype.removeCoordinate=function(t){this.changed();var e=t.split(".").map((function(t){return parseInt(t,10)})),i=this.coordinates[e[0]];i&&(i.splice(e[1],1),i.length<3&&this.coordinates.splice(e[0],1))},V.prototype.getCoordinate=function(t){var e=t.split(".").map((function(t){return parseInt(t,10)})),i=this.coordinates[e[0]];return JSON.parse(JSON.stringify(i[e[1]]))},V.prototype.getCoordinates=function(){return this.coordinates.map((function(t){return t.concat([t[0]])}))},V.prototype.updateCoordinate=function(t,e,i){this.changed();var n=t.split("."),r=parseInt(n[0],10),o=parseInt(n[1],10);void 0===this.coordinates[r]&&(this.coordinates[r]=[]),this.coordinates[r][o]=[e,i]};var U={MultiPoint:z,MultiLineString:F,MultiPolygon:V},G=function(t,e,i,n,r){var o=i.split("."),s=parseInt(o[0],10),a=o[1]?o.slice(1).join("."):null;return t[s][e](a,n,r)},j=function(t,e){if(B.call(this,t,e),delete this.coordinates,this.model=U[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 H(t){this.map=t.map,this.drawConfig=JSON.parse(JSON.stringify(t.options||{})),this._ctx=t}(j.prototype=Object.create(B.prototype))._coordinatesToFeatures=function(t){var e=this,i=this.model.bind(this);return t.map((function(t){return new i(e.ctx,{id:N(),type:d.FEATURE,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 G(this.features,"getCoordinate",t)},j.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map((function(t){return t.type===d.POLYGON?t.getCoordinates():t.coordinates}))))},j.prototype.updateCoordinate=function(t,e,i){G(this.features,"updateCoordinate",t,e,i),this.changed()},j.prototype.addCoordinate=function(t,e,i){G(this.features,"addCoordinate",t,e,i),this.changed()},j.prototype.removeCoordinate=function(t){G(this.features,"removeCoordinate",t),this.changed()},j.prototype.getFeatures=function(){return this.features},H.prototype.setSelected=function(t){return this._ctx.store.setSelected(t)},H.prototype.setSelectedCoordinates=function(t){var e=this;this._ctx.store.setSelectedCoordinates(t),t.reduce((function(t,i){return void 0===t[i.feature_id]&&(t[i.feature_id]=!0,e._ctx.store.get(i.feature_id).changed()),t}),{})},H.prototype.getSelected=function(){return this._ctx.store.getSelected()},H.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},H.prototype.isSelected=function(t){return this._ctx.store.isSelected(t)},H.prototype.getFeature=function(t){return this._ctx.store.get(t)},H.prototype.select=function(t){return this._ctx.store.select(t)},H.prototype.deselect=function(t){return this._ctx.store.deselect(t)},H.prototype.deleteFeature=function(t,e){return void 0===e&&(e={}),this._ctx.store.delete(t,e)},H.prototype.addFeature=function(t){return this._ctx.store.add(t)},H.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},H.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},H.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)},H.prototype.changeMode=function(t,e,i){return void 0===e&&(e={}),void 0===i&&(i={}),this._ctx.events.changeMode(t,e,i)},H.prototype.updateUIClasses=function(t){return this._ctx.ui.queueMapClasses(t)},H.prototype.activateUIButton=function(t){return this._ctx.ui.setActiveButton(t)},H.prototype.featuresAt=function(t,e,i){if(void 0===i&&(i="click"),"click"!==i&&"touch"!==i)throw new Error("invalid buffer type");return I[i](t,e,this._ctx)},H.prototype.newFeature=function(t){var e=t.geometry.type;return e===d.POINT?new z(this._ctx,t):e===d.LINE_STRING?new F(this._ctx,t):e===d.POLYGON?new V(this._ctx,t):new j(this._ctx,t)},H.prototype.isInstanceOf=function(t,e){if(t===d.POINT)return e instanceof z;if(t===d.LINE_STRING)return e instanceof F;if(t===d.POLYGON)return e instanceof V;if("MultiFeature"===t)return e instanceof j;throw new Error("Unknown feature class: "+t)},H.prototype.doRender=function(t){return this._ctx.store.featureChanged(t)},H.prototype.onSetup=function(){},H.prototype.onDrag=function(){},H.prototype.onClick=function(){},H.prototype.onMouseMove=function(){},H.prototype.onMouseDown=function(){},H.prototype.onMouseUp=function(){},H.prototype.onMouseOut=function(){},H.prototype.onKeyUp=function(){},H.prototype.onKeyDown=function(){},H.prototype.onTouchStart=function(){},H.prototype.onTouchMove=function(){},H.prototype.onTouchEnd=function(){},H.prototype.onTap=function(){},H.prototype.onStop=function(){},H.prototype.onTrash=function(){},H.prototype.onCombineFeature=function(){},H.prototype.onUncombineFeature=function(){},H.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var W={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},q=Object.keys(W);function X(t){var e=Object.keys(t);return function(i,n){void 0===n&&(n={});var r={},o=e.reduce((function(e,i){return e[i]=t[i],e}),new H(i));return{start:function(){var e=this;r=o.onSetup(n),q.forEach((function(i){var n,s=W[i],a=function(){return!1};t[s]&&(a=function(){return!0}),e.on(i,a,(n=s,function(t){return o[n](r,t)}))}))},stop:function(){o.onStop(r)},trash:function(){o.onTrash(r)},combineFeatures:function(){o.onCombineFeatures(r)},uncombineFeatures:function(){o.onUncombineFeatures(r)},render:function(t,e){o.toDisplayFeatures(r,t,e)}}}}function Z(t){return[].concat(t).filter((function(t){return void 0!==t}))}function Y(){var t=this;if(!t.ctx.map||void 0===t.ctx.map.getSource(u.HOT))return l();var e=t.ctx.events.currentModeName();t.ctx.ui.queueMapClasses({mode:e});var i=[],n=[];t.isDirty?n=t.getAllIds():(i=t.getChangedIds().filter((function(e){return void 0!==t.get(e)})),n=t.sources.hot.filter((function(e){return e.properties.id&&-1===i.indexOf(e.properties.id)&&void 0!==t.get(e.properties.id)})).map((function(t){return t.properties.id}))),t.sources.hot=[];var r=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===i.indexOf(e)}));var o=r!==t.sources.cold.length||n.length>0;function s(i,n){var r=t.get(i).internal(e);t.ctx.events.currentModeRender(r,(function(e){t.sources[n].push(e)}))}if(i.forEach((function(t){return s(t,"hot")})),n.forEach((function(t){return s(t,"cold")})),o&&t.ctx.map.getSource(u.COLD).setData({type:d.FEATURE_COLLECTION,features:t.sources.cold}),t.ctx.map.getSource(u.HOT).setData({type:d.FEATURE_COLLECTION,features:t.sources.hot}),t._emitSelectionChange&&(t.ctx.map.fire(m.SELECTION_CHANGE,{features:t.getSelected().map((function(t){return t.toGeoJSON()})),points:t.getSelectedCoordinates().map((function(t){return{type:d.FEATURE,properties:{},geometry:{type:d.POINT,coordinates:t.coordinates}}}))}),t._emitSelectionChange=!1),t._deletedFeaturesToEmit.length){var a=t._deletedFeaturesToEmit.map((function(t){return t.toGeoJSON()}));t._deletedFeaturesToEmit=[],t.ctx.map.fire(m.DELETE,{features:a})}function l(){t.isDirty=!1,t.clearChangedIds()}l(),t.ctx.map.fire(m.RENDER,{})}function Q(t){var e,i=this;this._features={},this._featureIds=new M,this._selectedFeatureIds=new M,this._selectedCoordinates=[],this._changedFeatureIds=new M,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=t,this.sources={hot:[],cold:[]},this.render=function(){e||(e=requestAnimationFrame((function(){e=null,Y.call(i)})))},this.isDirty=!1}function J(t,e){var i=t._selectedCoordinates.filter((function(e){return t._selectedFeatureIds.has(e.feature_id)}));t._selectedCoordinates.length===i.length||e.silent||(t._emitSelectionChange=!0),t._selectedCoordinates=i}Q.prototype.createRenderBatch=function(){var t=this,e=this.render,i=0;return this.render=function(){i++},function(){t.render=e,i>0&&t.render()}},Q.prototype.setDirty=function(){return this.isDirty=!0,this},Q.prototype.featureChanged=function(t){return this._changedFeatureIds.add(t),this},Q.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Q.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Q.prototype.getAllIds=function(){return this._featureIds.values()},Q.prototype.add=function(t){return this.featureChanged(t.id),this._features[t.id]=t,this._featureIds.add(t.id),this},Q.prototype.delete=function(t,e){var i=this;return void 0===e&&(e={}),Z(t).forEach((function(t){i._featureIds.has(t)&&(i._featureIds.delete(t),i._selectedFeatureIds.delete(t),e.silent||-1===i._deletedFeaturesToEmit.indexOf(i._features[t])&&i._deletedFeaturesToEmit.push(i._features[t]),delete i._features[t],i.isDirty=!0)})),J(this,e),this},Q.prototype.get=function(t){return this._features[t]},Q.prototype.getAll=function(){var t=this;return Object.keys(this._features).map((function(e){return t._features[e]}))},Q.prototype.select=function(t,e){var i=this;return void 0===e&&(e={}),Z(t).forEach((function(t){i._selectedFeatureIds.has(t)||(i._selectedFeatureIds.add(t),i._changedFeatureIds.add(t),e.silent||(i._emitSelectionChange=!0))})),this},Q.prototype.deselect=function(t,e){var i=this;return void 0===e&&(e={}),Z(t).forEach((function(t){i._selectedFeatureIds.has(t)&&(i._selectedFeatureIds.delete(t),i._changedFeatureIds.add(t),e.silent||(i._emitSelectionChange=!0))})),J(this,e),this},Q.prototype.clearSelected=function(t){return void 0===t&&(t={}),this.deselect(this._selectedFeatureIds.values(),{silent:t.silent}),this},Q.prototype.setSelected=function(t,e){var i=this;return void 0===e&&(e={}),t=Z(t),this.deselect(this._selectedFeatureIds.values().filter((function(e){return-1===t.indexOf(e)})),{silent:e.silent}),this.select(t.filter((function(t){return!i._selectedFeatureIds.has(t)})),{silent:e.silent}),this},Q.prototype.setSelectedCoordinates=function(t){return this._selectedCoordinates=t,this._emitSelectionChange=!0,this},Q.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Q.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Q.prototype.getSelected=function(){var t=this;return this._selectedFeatureIds.values().map((function(e){return t.get(e)}))},Q.prototype.getSelectedCoordinates=function(){var t=this;return this._selectedCoordinates.map((function(e){return{coordinates:t.get(e.feature_id).getCoordinate(e.coord_path)}}))},Q.prototype.isSelected=function(t){return this._selectedFeatureIds.has(t)},Q.prototype.setFeatureProperty=function(t,e,i){this.get(t).setProperty(e,i),this.featureChanged(t)},Q.prototype.storeMapConfig=function(){var t=this;_.forEach((function(e){t.ctx.map[e]&&(t._mapInitialConfig[e]=t.ctx.map[e].isEnabled())}))},Q.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()}))},Q.prototype.getInitialConfigValue=function(t){return void 0===this._mapInitialConfig[t]||this._mapInitialConfig[t]};var K=function(){for(var t=arguments,e={},i=0;i=48&&t<=57)};function c(n,r,o){void 0===o&&(o={}),a.stop();var l=i[n];if(void 0===l)throw new Error(n+" is not valid");s=n;var c=l(e,r);a=t(c,e),o.silent||e.map.fire(m.MODE_CHANGE,{mode:n}),e.store.setDirty(),e.store.render()}o.keydown=function(t){(t.srcElement||t.target).classList.contains("mapboxgl-canvas")&&(8!==t.keyCode&&46!==t.keyCode||!e.options.controls.trash?l(t.keyCode)?a.keydown(t):49===t.keyCode&&e.options.controls.point?c(f.DRAW_POINT):50===t.keyCode&&e.options.controls.line_string?c(f.DRAW_LINE_STRING):51===t.keyCode&&e.options.controls.polygon&&c(f.DRAW_POLYGON):(t.preventDefault(),a.trash()))},o.keyup=function(t){l(t.keyCode)&&a.keyup(t)},o.zoomend=function(){e.store.changeZoom()},o.data=function(t){if("style"===t.dataType){var i=e.setup,n=e.map,r=e.options,o=e.store;r.styles.some((function(t){return n.getLayer(t.id)}))||(i.addLayers(),o.setDirty(),o.render())}};var u={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){s=e.options.defaultMode,a=t(i[s](e),e)},changeMode:c,actionable:function(t){var i=!1;Object.keys(t).forEach((function(e){if(void 0===u[e])throw new Error("Invalid action type");u[e]!==t[e]&&(i=!0),u[e]=t[e]})),i&&e.map.fire(m.ACTIONABLE,{actions:u})},currentModeName:function(){return s},currentModeRender:function(t,e){return a.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){a.trash(t)},combineFeatures:function(){a.combineFeatures()},uncombineFeatures:function(){a.uncombineFeatures()},getMode:function(){return s}}}(e),e.ui=function(t){var e={},i=null,n={mode:null,feature:null,mouse:null},r={mode:null,feature:null,mouse:null};function o(t){r=tt(r,t)}function s(){var e,i;if(t.container){var o=[],s=[];et.forEach((function(t){r[t]!==n[t]&&(o.push(t+"-"+n[t]),null!==r[t]&&s.push(t+"-"+r[t]))})),o.length>0&&(e=t.container.classList).remove.apply(e,o),s.length>0&&(i=t.container.classList).add.apply(i,s),n=tt(n,r)}}function a(t,e){void 0===e&&(e={});var n=document.createElement("button");return n.className=c.CONTROL_BUTTON+" "+e.className,n.setAttribute("title",e.title),e.container.appendChild(n),n.addEventListener("click",(function(n){if(n.preventDefault(),n.stopPropagation(),n.target===i)return l(),void e.onDeactivate();u(t),e.onActivate()}),!0),n}function l(){i&&(i.classList.remove(c.ACTIVE_BUTTON),i=null)}function u(t){l();var n=e[t];n&&n&&"trash"!==t&&(n.classList.add(c.ACTIVE_BUTTON),i=n)}return{setActiveButton:u,queueMapClasses:o,updateMapClasses:s,clearMapClasses:function(){o({mode:null,feature:null,mouse:null}),s()},addButtons:function(){var i=t.options.controls,n=document.createElement("div");return n.className=c.CONTROL_GROUP+" "+c.CONTROL_BASE,i?(i[p.LINE]&&(e[p.LINE]=a(p.LINE,{container:n,className:c.CONTROL_BUTTON_LINE,title:"LineString tool "+(t.options.keybindings?"(l)":""),onActivate:function(){return t.events.changeMode(f.DRAW_LINE_STRING)},onDeactivate:function(){return t.events.trash()}})),i[p.POLYGON]&&(e[p.POLYGON]=a(p.POLYGON,{container:n,className:c.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(t.options.keybindings?"(p)":""),onActivate:function(){return t.events.changeMode(f.DRAW_POLYGON)},onDeactivate:function(){return t.events.trash()}})),i[p.POINT]&&(e[p.POINT]=a(p.POINT,{container:n,className:c.CONTROL_BUTTON_POINT,title:"Marker tool "+(t.options.keybindings?"(m)":""),onActivate:function(){return t.events.changeMode(f.DRAW_POINT)},onDeactivate:function(){return t.events.trash()}})),i.trash&&(e.trash=a("trash",{container:n,className:c.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){t.events.trash()}})),i.combine_features&&(e.combine_features=a("combineFeatures",{container:n,className:c.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){t.events.combineFeatures()}})),i.uncombine_features&&(e.uncombine_features=a("uncombineFeatures",{container:n,className:c.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){t.events.uncombineFeatures()}})),n):n},removeButtons:function(){Object.keys(e).forEach((function(t){var i=e[t];i.parentNode&&i.parentNode.removeChild(i),delete e[t]}))}}}(e),e.container=o.getContainer(),e.store=new Q(e),i=e.ui.addButtons(),e.options.boxSelect&&(e.boxZoomInitial=o.boxZoom.isEnabled(),o.boxZoom.disable(),o.dragPan.disable(),o.dragPan.enable()),o.loaded()?r.connect():(o.on("load",r.connect),n=setInterval((function(){o.loaded()&&r.connect()}),16)),e.events.start(),i},addLayers:function(){e.map.addSource(u.COLD,{data:{type:d.FEATURE_COLLECTION,features:[]},type:"geojson"}),e.map.addSource(u.HOT,{data:{type:d.FEATURE_COLLECTION,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(u.COLD)&&e.map.removeSource(u.COLD),e.map.getSource(u.HOT)&&e.map.removeSource(u.HOT)}};return e.setup=r,r}var rt=[{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"}}];function ot(t){return function(e){var i=e.featureTarget;return!!i&&!!i.properties&&i.properties.meta===t}}function st(t){return!!t.originalEvent&&!!t.originalEvent.shiftKey&&0===t.originalEvent.button}function at(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===v.ACTIVE&&t.featureTarget.properties.meta===y.FEATURE}function lt(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.active===v.INACTIVE&&t.featureTarget.properties.meta===y.FEATURE}function ct(t){return void 0===t.featureTarget}function ut(t){return!!t.featureTarget&&!!t.featureTarget.properties&&t.featureTarget.properties.meta===y.FEATURE}function ht(t){var e=t.featureTarget;return!!e&&!!e.properties&&e.properties.meta===y.VERTEX}function pt(t){return!!t.originalEvent&&!0===t.originalEvent.shiftKey}function dt(t){return 27===t.keyCode}function ft(t){return 13===t.keyCode}var mt=Object.freeze({__proto__:null,isOfMetaType:ot,isShiftMousedown:st,isActiveFeature:at,isInactiveFeature:lt,noTarget:ct,isFeature:ut,isVertex:ht,isShiftDown:pt,isEscapeKey:dt,isEnterKey:ft,isTrue:function(){return!0}}),gt=yt;function yt(t,e){this.x=t,this.y=e}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,i=t.y-this.y;return e*e+i*i},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,i=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=i,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),i=Math.sin(t),n=e*this.x-i*this.y,r=i*this.x+e*this.y;return this.x=n,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),r=e.x+i*(this.x-e.x)-n*(this.y-e.y),o=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=r,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 vt=e(gt);function _t(t,e){var i=e.getBoundingClientRect();return new vt(t.clientX-i.left-(e.clientLeft||0),t.clientY-i.top-(e.clientTop||0))}function xt(t,e,i,n){return{type:d.FEATURE,properties:{meta:y.VERTEX,parent:t,coord_path:i,active:n?v.ACTIVE:v.INACTIVE},geometry:{type:d.POINT,coordinates:e}}}function bt(t,e,i){var n=e.geometry.coordinates,r=i.geometry.coordinates;if(n[1]>85||n[1]85||r[1]=e&&this._bbox[3]>=i},Ht.prototype.intersect=function(t){return this._valid?(e=t instanceof Ht?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]e[3])):null;var e},Ht.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)},Ht.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 Wt=function(t){if(!t)return[];var e=Pt(Ct(t)),i=[];return e.features.forEach((function(t){t.geometry&&(i=i.concat(Lt(t.geometry.coordinates)))})),i},qt=Gt,Xt=jt,Zt={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},Yt=Object.keys(Zt);function Qt(t){for(var e=Xt(),i=Wt(t),n=0;ni&&(i=l),cr&&(r=c),la&&(a=h)}));var l=e;return i+l.lat>85&&(l.lat=85-i),r+l.lat>90&&(l.lat=90-r),n+l.lat<-85&&(l.lat=-85-n),o+l.lat=270&&(l.lng-=360*Math.ceil(Math.abs(l.lng)/360)),l}function te(t,e){var i=$t(t.map((function(t){return t.toGeoJSON()})),e);t.forEach((function(t){var e,n=t.getCoordinates(),r=function(t){var e={lng:t[0]+i.lng,lat:t[1]+i.lat};return[e.lng,e.lat]},o=function(t){return t.map((function(t){return r(t)}))};t.type===d.POINT?e=r(n):t.type===d.LINE_STRING||t.type===d.MULTI_POINT?e=n.map(r):t.type===d.POLYGON||t.type===d.MULTI_LINE_STRING?e=n.map(o):t.type===d.MULTI_POLYGON&&(e=n.map((function(t){return t.map((function(t){return o(t)}))}))),t.incomingCoords(e)}))}var ee={onSetup:function(t){var e=this,i={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(i.initiallySelectedFeatureIds.filter((function(t){return void 0!==e.getFeature(t)}))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),i},fireUpdate:function(){this.map.fire(m.UPDATE,{action:g.MOVE,features:this.getSelected().map((function(t){return t.toGeoJSON()}))})},fireActionable:function(){var t=this,e=this.getSelected(),i=e.filter((function(e){return t.isInstanceOf("MultiFeature",e)})),n=!1;if(e.length>1){n=!0;var r=e[0].type.replace("Multi","");e.forEach((function(t){t.type.replace("Multi","")!==r&&(n=!1)}))}var o=i.length>0,s=e.length>0;this.setActionableState({combineFeatures:n,uncombineFeatures:o,trash:s})},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 M).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(){At.enable(this)},onMouseMove:function(t,e){return ut(e)&&t.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return!t.dragMoving||this.fireUpdate()}};ee.onTap=ee.onClick=function(t,e){return ct(e)?this.clickAnywhere(t,e):ot(y.VERTEX)(e)?this.clickOnVertex(t,e):ut(e)?this.clickOnFeature(t,e):void 0},ee.clickAnywhere=function(t){var e=this,i=this.getSelectedIds();i.length&&(this.clearSelectedFeatures(),i.forEach((function(t){return e.doRender(t)}))),At.enable(this),this.stopExtendedInteractions(t)},ee.clickOnVertex=function(t,e){this.changeMode(f.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:h.MOVE})},ee.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},ee.clickOnFeature=function(t,e){var i=this;At.disable(this),this.stopExtendedInteractions(t);var n=pt(e),r=this.getSelectedIds(),o=e.featureTarget.properties.id,s=this.isSelected(o);if(!n&&s&&this.getFeature(o).type!==d.POINT)return this.changeMode(f.DIRECT_SELECT,{featureId:o});s&&n?(this.deselect(o),this.updateUIClasses({mouse:h.POINTER}),1===r.length&&At.enable(this)):!s&&n?(this.select(o),this.updateUIClasses({mouse:h.MOVE})):s||n||(r.forEach((function(t){return i.doRender(t)})),this.setSelected(o),this.updateUIClasses({mouse:h.MOVE})),this.doRender(o)},ee.onMouseDown=function(t,e){return at(e)?this.startOnActiveFeature(t,e):this.drawConfig.boxSelect&&st(e)?this.startBoxSelect(t,e):void 0},ee.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=_t(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0},ee.onTouchStart=function(t,e){if(at(e))return this.startOnActiveFeature(t,e)},ee.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},ee.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:h.ADD}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add(c.BOX_SELECT),this.map.getContainer().appendChild(t.boxSelectElement));var i=_t(e.originalEvent,this.map.getContainer()),n=Math.min(t.boxSelectStartLocation.x,i.x),r=Math.max(t.boxSelectStartLocation.x,i.x),o=Math.min(t.boxSelectStartLocation.y,i.y),s=Math.max(t.boxSelectStartLocation.y,i.y),a="translate("+n+"px, "+o+"px)";t.boxSelectElement.style.transform=a,t.boxSelectElement.style.WebkitTransform=a,t.boxSelectElement.style.width=r-n+"px",t.boxSelectElement.style.height=s-o+"px"},ee.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();var i={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};te(this.getSelected(),i),t.dragMoveLocation=e.lngLat},ee.onTouchEnd=ee.onMouseUp=function(t,e){var i=this;if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){var n=[t.boxSelectStartLocation,_t(e.originalEvent,this.map.getContainer())],r=this.featuresAt(null,n,"click"),o=this.getUniqueIds(r).filter((function(t){return!i.isSelected(t)}));o.length&&(this.select(o),o.forEach((function(t){return i.doRender(t)})),this.updateUIClasses({mouse:h.MOVE}))}this.stopExtendedInteractions(t)},ee.toDisplayFeatures=function(t,e,i){e.properties.active=this.isSelected(e.properties.id)?v.ACTIVE:v.INACTIVE,i(e),this.fireActionable(),e.properties.active===v.ACTIVE&&e.geometry.type!==d.POINT&&wt(e).forEach(i)},ee.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},ee.onCombineFeatures=function(){var t=this.getSelected();if(!(0===t.length||t.length<2)){for(var e=[],i=[],n=t[0].type.replace("Multi",""),r=0;r1){var s=this.newFeature({type:d.FEATURE,properties:i[0].properties,geometry:{type:"Multi"+n,coordinates:e}});this.addFeature(s),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([s.id]),this.map.fire(m.COMBINE_FEATURES,{createdFeatures:[s.toGeoJSON()],deletedFeatures:i})}this.fireActionable()}},ee.onUncombineFeatures=function(){var t=this,e=this.getSelected();if(0!==e.length){for(var i=[],n=[],r=function(r){var o=e[r];t.isInstanceOf("MultiFeature",o)&&(o.getFeatures().forEach((function(e){t.addFeature(e),e.properties=o.properties,i.push(e.toGeoJSON()),t.select([e.id])})),t.deleteFeature(o.id,{silent:!0}),n.push(o.toGeoJSON()))},o=0;o1&&this.map.fire(m.UNCOMBINE_FEATURES,{createdFeatures:i,deletedFeatures:n}),this.fireActionable()}};var ie=ot(y.VERTEX),ne=ot(y.MIDPOINT),re={fireUpdate:function(){this.map.fire(m.UPDATE,{action:g.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 i=e.featureTarget.properties,n=t.selectedCoordPaths.indexOf(i.coord_path);pt(e)||-1!==n?pt(e)&&-1===n&&t.selectedCoordPaths.push(i.coord_path):t.selectedCoordPaths=[i.coord_path];var r=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(r)},onMidpoint:function(t,e){this.startDragging(t,e);var i=e.featureTarget.properties;t.feature.addCoordinate(i.coord_path,i.lng,i.lat),this.fireUpdate(),t.selectedCoordPaths=[i.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,i){te(this.getSelected(),i),t.dragMoveLocation=e.lngLat},dragVertex:function(t,e,i){for(var n=t.selectedCoordPaths.map((function(e){return t.feature.getCoordinate(e)})),r=$t(n.map((function(t){return{type:d.FEATURE,properties:{},geometry:{type:d.POINT,coordinates:t}}})),i),o=0;o0?this.dragVertex(t,e,i):this.dragFeature(t,e,i),t.dragMoveLocation=e.lngLat}},re.onClick=function(t,e){return ct(e)?this.clickNoTarget(t,e):at(e)?this.clickActiveFeature(t,e):lt(e)?this.clickInactive(t,e):void this.stopDragging(t)},re.onTap=function(t,e){return ct(e)?this.clickNoTarget(t,e):at(e)?this.clickActiveFeature(t,e):lt(e)?this.clickInactive(t,e):void 0},re.onTouchEnd=re.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t)};var oe={};function se(t,e){return!!t.lngLat&&t.lngLat.lng===e[0]&&t.lngLat.lat===e[1]}oe.onSetup=function(){var t=this.newFeature({type:d.FEATURE,properties:{},geometry:{type:d.POINT,coordinates:[]}});return this.addFeature(t),this.clearSelectedFeatures(),this.updateUIClasses({mouse:h.ADD}),this.activateUIButton(p.POINT),this.setActionableState({trash:!0}),{point:t}},oe.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)},oe.onTap=oe.onClick=function(t,e){this.updateUIClasses({mouse:h.MOVE}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(m.CREATE,{features:[t.point.toGeoJSON()]}),this.changeMode(f.SIMPLE_SELECT,{featureIds:[t.point.id]})},oe.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0})},oe.toDisplayFeatures=function(t,e,i){var n=e.properties.id===t.point.id;if(e.properties.active=n?v.ACTIVE:v.INACTIVE,!n)return i(e)},oe.onTrash=oe.stopDrawingAndRemove,oe.onKeyUp=function(t,e){if(dt(e)||ft(e))return this.stopDrawingAndRemove(t,e)};var ae={onSetup:function(){var t=this.newFeature({type:d.FEATURE,properties:{},geometry:{type:d.POLYGON,coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),At.disable(this),this.updateUIClasses({mouse:h.ADD}),this.activateUIButton(p.POLYGON),this.setActionableState({trash:!0}),{polygon:t,currentVertexPosition:0}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&se(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(f.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:h.ADD}),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(f.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate("0."+t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),ht(e)&&this.updateUIClasses({mouse:h.POINTER})}};ae.onTap=ae.onClick=function(t,e){return ht(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},ae.onKeyUp=function(t,e){dt(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)):ft(e)&&this.changeMode(f.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},ae.onStop=function(t){this.updateUIClasses({mouse:h.NONE}),At.enable(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate("0."+t.currentVertexPosition),t.polygon.isValid()?this.map.fire(m.CREATE,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT,{},{silent:!0})))},ae.toDisplayFeatures=function(t,e,i){var n=e.properties.id===t.polygon.id;if(e.properties.active=n?v.ACTIVE:v.INACTIVE,!n)return i(e);if(0!==e.geometry.coordinates.length){var r=e.geometry.coordinates[0].length;if(!(r<3)){if(e.properties.meta=y.FEATURE,i(xt(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1)),r>3){var o=e.geometry.coordinates[0].length-3;i(xt(t.polygon.id,e.geometry.coordinates[0][o],"0."+o,!1))}if(r<=4){var s=[[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(i({type:d.FEATURE,properties:e.properties,geometry:{coordinates:s,type:d.LINE_STRING}}),3===r)return}return i(e)}}},ae.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)};var le={onSetup:function(t){var e,i,n=(t=t||{}).featureId,r="forward";if(n){if(!(e=this.getFeature(n)))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 s=e.coordinates.length-1;if(e.coordinates[s][0]===o[0]&&e.coordinates[s][1]===o[1])i=s+1,e.addCoordinate.apply(e,[i].concat(e.coordinates[s]));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");r="backwards",i=0,e.addCoordinate.apply(e,[i].concat(e.coordinates[0]))}}else e=this.newFeature({type:d.FEATURE,properties:{},geometry:{type:d.LINE_STRING,coordinates:[]}}),i=0,this.addFeature(e);return this.clearSelectedFeatures(),At.disable(this),this.updateUIClasses({mouse:h.ADD}),this.activateUIButton(p.LINE),this.setActionableState({trash:!0}),{line:e,currentVertexPosition:i,direction:r}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&se(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&se(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(f.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:h.ADD}),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(f.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),ht(e)&&this.updateUIClasses({mouse:h.POINTER})}};le.onTap=le.onClick=function(t,e){if(ht(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e)},le.onKeyUp=function(t,e){ft(e)?this.changeMode(f.SIMPLE_SELECT,{featureIds:[t.line.id]}):dt(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT))},le.onStop=function(t){At.enable(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(""+t.currentVertexPosition),t.line.isValid()?this.map.fire(m.CREATE,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT,{},{silent:!0})))},le.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(f.SIMPLE_SELECT)},le.toDisplayFeatures=function(t,e,i){var n=e.properties.id===t.line.id;if(e.properties.active=n?v.ACTIVE:v.INACTIVE,!n)return i(e);e.geometry.coordinates.length<2||(e.properties.meta=y.FEATURE,i(xt(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)),i(e))};var ce={simple_select:ee,direct_select:re,draw_point:oe,draw_polygon:ae,draw_line_string:le},ue={defaultMode:f.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:rt,modes:ce,controls:{},userProperties:!1},he={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},pe={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function de(t,e){return t.map((function(t){return t.source?t:tt(t,{id:t.id+"."+e,source:"hot"===e?u.HOT:u.COLD})}))}var fe={exports:{}};!function(t,e){var i="__lodash_hash_undefined__",n=9007199254740991,r="[object Arguments]",o="[object Array]",s="[object Boolean]",a="[object Date]",l="[object Error]",c="[object Function]",u="[object Map]",h="[object Number]",p="[object Object]",d="[object Promise]",f="[object RegExp]",m="[object Set]",g="[object String]",y="[object Symbol]",v="[object WeakMap]",_="[object ArrayBuffer]",x="[object DataView]",b=/^\[object .+?Constructor\]$/,w=/^(?:0|[1-9]\d*)$/,A={};A["[object Float32Array]"]=A["[object Float64Array]"]=A["[object Int8Array]"]=A["[object Int16Array]"]=A["[object Int32Array]"]=A["[object Uint8Array]"]=A["[object Uint8ClampedArray]"]=A["[object Uint16Array]"]=A["[object Uint32Array]"]=!0,A[r]=A[o]=A[_]=A[s]=A[x]=A[a]=A[l]=A[c]=A[u]=A[h]=A[p]=A[f]=A[m]=A[g]=A[v]=!1;var E="object"==typeof nt&&nt&&nt.Object===Object&&nt,S="object"==typeof self&&self&&self.Object===Object&&self,M=E||S||Function("return this")(),T=e&&!e.nodeType&&e,I=T&&t&&!t.nodeType&&t,C=I&&I.exports===T,P=C&&E.process,L=function(){try{return P&&P.binding&&P.binding("util")}catch(t){}}(),D=L&&L.isTypedArray;function R(t,e){for(var i=-1,n=null==t?0:t.length;++ia))return!1;var c=o.get(t);if(c&&o.get(e))return c==e;var u=-1,h=!0,p=2&i?new xt:void 0;for(o.set(t,e),o.set(e,t);++u-1},vt.prototype.set=function(t,e){var i=this.__data__,n=At(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},_t.prototype.clear=function(){this.size=0,this.__data__={hash:new yt,map:new(ot||vt),string:new yt}},_t.prototype.delete=function(t){var e=Lt(this,t).delete(t);return this.size-=e?1:0,e},_t.prototype.get=function(t){return Lt(this,t).get(t)},_t.prototype.has=function(t){return Lt(this,t).has(t)},_t.prototype.set=function(t,e){var i=Lt(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this},xt.prototype.add=xt.prototype.push=function(t){return this.__data__.set(t,i),this},xt.prototype.has=function(t){return this.__data__.has(t)},bt.prototype.clear=function(){this.__data__=new vt,this.size=0},bt.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},bt.prototype.get=function(t){return this.__data__.get(t)},bt.prototype.has=function(t){return this.__data__.has(t)},bt.prototype.set=function(t,e){var i=this.__data__;if(i instanceof vt){var n=i.__data__;if(!ot||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new _t(n)}return i.set(t,e),this.size=i.size,this};var Rt=tt?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,n=null==t?0:t.length,r=0,o=[];++i-1&&t%1==0&&t-1&&t%1==0&&t<=n}function jt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Ht(t){return null!=t&&"object"==typeof t}var Wt=D?function(t){return function(e){return t(e)}}(D):function(t){return Ht(t)&&Gt(t.length)&&!!A[Et(t)]};function qt(t){return null!=(e=t)&&Gt(e.length)&&!Ut(e)?wt(t):It(t);var e}t.exports=function(t,e){return Mt(t,e)}}(fe,fe.exports);var me=e(fe.exports);function ge(t,e){return t.length===e.length&&JSON.stringify(t.map((function(t){return t})).sort())===JSON.stringify(e.map((function(t){return t})).sort())}var ye={Polygon:V,LineString:F,Point:z,MultiPolygon:j,MultiLineString:j,MultiPoint:j},ve=Object.freeze({__proto__:null,CommonSelectors:mt,constrainFeatureMovement:$t,createMidPoint:bt,createSupplementaryPoints:wt,createVertex:xt,doubleClickZoom:At,euclideanDistance:L,featuresAt:I,getFeatureAtAndSetCursors:P,isClick:D,isEventAtCoordinates:se,isTap:R,mapEventToBoundingBox:S,ModeHandler:t,moveFeatures:te,sortFeatures:E,stringSetsAreEqual:ge,StringSet:M,theme:rt,toDenseArray:Z}),_e=function(t,e){var i={options:t=function(t){void 0===t&&(t={});var e=tt(t);return t.controls||(e.controls={}),!1===t.displayControlsDefault?e.controls=tt(pe,t.controls):e.controls=tt(he,t.controls),(e=tt(ue,e)).styles=de(e.styles,"cold").concat(de(e.styles,"hot")),e}(t)};e=function(t,e){return e.modes=f,e.getFeatureIdsAt=function(e){return I.click({point:e},null,t).map((function(t){return t.properties.id}))},e.getSelectedIds=function(){return t.store.getSelectedIds()},e.getSelected=function(){return{type:d.FEATURE_COLLECTION,features:t.store.getSelectedIds().map((function(e){return t.store.get(e)})).map((function(t){return t.toGeoJSON()}))}},e.getSelectedPoints=function(){return{type:d.FEATURE_COLLECTION,features:t.store.getSelectedCoordinates().map((function(t){return{type:d.FEATURE,properties:{},geometry:{type:d.POINT,coordinates:t.coordinates}}}))}},e.set=function(i){if(void 0===i.type||i.type!==d.FEATURE_COLLECTION||!Array.isArray(i.features))throw new Error("Invalid FeatureCollection");var n=t.store.createRenderBatch(),r=t.store.getAllIds().slice(),o=e.add(i),s=new M(o);return(r=r.filter((function(t){return!s.has(t)}))).length&&e.delete(r),n(),o},e.add=function(e){var i=JSON.parse(JSON.stringify(Tt(e))).features.map((function(e){if(e.id=e.id||N(),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 i=ye[e.geometry.type];if(void 0===i)throw new Error("Invalid geometry type: "+e.geometry.type+".");var n=new i(t,e);t.store.add(n)}else{var r=t.store.get(e.id);r.properties=e.properties,me(r.properties,e.properties)||t.store.featureChanged(r.id),me(r.getCoordinates(),e.geometry.coordinates)||r.incomingCoords(e.geometry.coordinates)}return e.id}));return t.store.render(),i},e.get=function(e){var i=t.store.get(e);if(i)return i.toGeoJSON()},e.getAll=function(){return{type:d.FEATURE_COLLECTION,features:t.store.getAll().map((function(t){return t.toGeoJSON()}))}},e.delete=function(i){return t.store.delete(i,{silent:!0}),e.getMode()!==f.DIRECT_SELECT||t.store.getSelectedIds().length?t.store.render():t.events.changeMode(f.SIMPLE_SELECT,void 0,{silent:!0}),e},e.deleteAll=function(){return t.store.delete(t.store.getAllIds(),{silent:!0}),e.getMode()===f.DIRECT_SELECT?t.events.changeMode(f.SIMPLE_SELECT,void 0,{silent:!0}):t.store.render(),e},e.changeMode=function(i,n){return void 0===n&&(n={}),i===f.SIMPLE_SELECT&&e.getMode()===f.SIMPLE_SELECT?(ge(n.featureIds||[],t.store.getSelectedIds())||(t.store.setSelected(n.featureIds,{silent:!0}),t.store.render()),e):(i===f.DIRECT_SELECT&&e.getMode()===f.DIRECT_SELECT&&n.featureId===t.store.getSelectedIds()[0]||t.events.changeMode(i,n,{silent:!0}),e)},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(i,n,r){return t.store.setFeatureProperty(i,n,r),e},e}(i,e),i.api=e;var n=it(i);return e.onAdd=n.onAdd,e.onRemove=n.onRemove,e.types=p,e.options=t,e};function xe(t){_e(t,this)}return xe.modes=ce,xe.constants=b,xe.lib=ve,xe}()}(Uf);var Gf=rt(Uf.exports);function jf(t){return Math.pow(Hf(t),.99)}function Hf(t){let e=0;for(let i=0;i=t[1]&&e[0]>=t[0]?i=n+Math.PI:e[1]>=t[1]&&e[0]=t[0]&&(i=Math.PI-n),i}function Zf(t,e,i,n,r){const o=Xf(t,e),s=r?o+i:o-i,a=n*Math.cos(s),l=n*Math.sin(s);return[e[0]+a,e[1]+l]}function Yf(t){if(t.length<=2)return t;const e=[],i=t.length-2-1;e.push(t[0]);for(let n=0;n<=i;n++)for(let i=0;i<=1;i+=.05){let r=0,o=0;for(let e=0;e<=2;e++){const s=Qf(e,i);r+=s*t[n+e][0],o+=s*t[n+e][1]}e.push([r,o])}return e.push(t[t.length-1]),e}function Qf(t,e){return 0==t?Math.pow(e-1,2)/2:1==t?(-2*Math.pow(e,2)+2*e+1)/2:2==t?Math.pow(e,2)/2:0}const Jf=.18,Kf=.3,$f=.85,tm=.15,em=.8,im=2*Math.PI,nm=Math.PI/2;function rm(t,e){const i=[];for(const e in t)-1!=e.indexOf("attackArrowPoint")&&i.push(t[e]);"move"==e&&(i[i.length]=t.movePoint);for(let t=0;t(e[1]-t[1])*(i[0]-t[0])})(i[0],i[1],i[2])&&(n=i[1],r=i[0]);const o=function(t,e){return[(t[0]+e[0])/2,(t[1]+e[1])/2]}(n,r),s=[o].concat(i.slice(2)),a=function(t,e,i){let n=jf(t),r=n*Jf,o=t[t.length-1];n=Wf(o,t[t.length-2]);const s=Wf(e,i);r>s*em&&(r=s*em);const a=r*Kf,l=r*tm;r=r>n?n:r;const c=r*$f,u=Zf(t[t.length-2],o,0,r,!0),h=Zf(t[t.length-2],o,0,c,!0),p=Zf(o,u,nm,a,!1),d=Zf(o,u,nm,a,!0);return[Zf(o,h,nm,l,!1),p,o,d,Zf(o,h,nm,l,!0)]}(s,n,r),l=a[0],c=a[4];if(window.isNaN(c[0]))return!1;const u=function(t,e,i,n){const r=Hf(t),o=jf(t)*n,s=(o-Wf(e,i))/2,a=[],l=[];let c=0;for(let e=1;e{t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()}),0)},disable(t){setTimeout((()=>{t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()}),0)}},Cm={onSetup(t){const e=this.newFeature({type:lm.FEATURE,properties:{isAttackArrow:!0,lineColor:t.lineColor,lineWidth:t.lineWidth,fillColor:t.fillColor,polygonType:t.polygonType,polygonImage:t.polygonImage||""},geometry:{type:lm.POLYGON,coordinates:[[]]}});return this.addFeature(e),this.clearSelectedFeatures(),Im.disable(this),this.updateUIClasses({mouse:sm.ADD}),this.activateUIButton(am.POLYGON),this.setActionableState({trash:!0}),{attackArrow:e,currentVertexPosition:0,...t}},onTap(t,e){t.attackArrow.properties.attackArrowPoint1&&this.onMouseMove(t,e),this.onClick(t,e)},onKeyUp(t,e){Sm(e)?(this.deleteFeature([t.attackArrow.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT)):Mm(e)&&this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.attackArrow.id]})},onTrash(t){this.deleteFeature([t.attackArrow.id],{silent:!0}),this.changeMode("simple_select")},onStop(t){this.updateUIClasses({mouse:sm.NONE}),Im.enable(this),this.activateUIButton(),this.getFeature(t.attackArrow.id)},onClick(t,e){if(Am(e))return this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.attackArrow.id]});if(t.currentVertexPosition>0&&Tm(e,t.attackArrow.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.attackArrow.id]});if(this.updateUIClasses({mouse:sm.ADD}),t.attackArrow.updateCoordinate(`0.${t.currentVertexPosition}`,e.lngLat.lng,e.lngLat.lat),t.currentVertexPosition++,t.attackArrow.updateCoordinate(`0.${t.currentVertexPosition}`,e.lngLat.lng,e.lngLat.lat),t.attackArrow.properties["attackArrowPoint"+t.currentVertexPosition]=[e.lngLat.lng,e.lngLat.lat],t.attackArrow.properties.attackArrowPoint3){const e=rm(t.attackArrow.properties);t.attackArrow.incomingCoords(e)}},onMouseMove(t,e){if(t.attackArrow.updateCoordinate(`0.${t.currentVertexPosition}`,e.lngLat.lng,e.lngLat.lat),Am(e)&&this.updateUIClasses({mouse:sm.POINTER}),t.attackArrow.properties.attackArrowPoint1&&(t.attackArrow.properties.attackArrowPoint2||t.attackArrow.updateCoordinate(`0.${t.currentVertexPosition}`,e.lngLat.lng,e.lngLat.lat),t.attackArrow.properties.movePoint=[e.lngLat.lng,e.lngLat.lat],t.attackArrow.properties.attackArrowPoint2)){const e=rm(t.attackArrow.properties,"move");t.attackArrow.incomingCoords(e)}},toDisplayFeatures(t,e,i){const n=e.properties.id===t.attackArrow.id;if(e.properties.active=n?dm.ACTIVE:dm.INACTIVE,!n)return i(e);if(0===e.geometry.coordinates.length)return;const r=e.geometry.coordinates[0].length;if(!(r<3)){if(Object.getOwnPropertyNames(t.attackArrow.properties).forEach((function(e,n){-1!=e.indexOf("attackArrowPoint")&&(console.log(e,t.attackArrow),i(ym(t.attackArrow.id,t.attackArrow.properties[e],`0.${n}`,!1,t)))})),r<=4){const t=[[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(i({type:lm.FEATURE,properties:e.properties,geometry:{coordinates:t,type:lm.LINE_STRING}}),3===r)return}return i(e)}}};var Pm={exports:{}};!function(t,e){t.exports=function(){var t,e,i;function n(n,r){if(t)if(e){var o="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+t+")(sharedChunk); ("+e+")(sharedChunk); self.onerror = null;",s={};t(s),i=r(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else e=r;else t=r}n(["exports"],(function(t){var e="undefined"!=typeof self?self:{},i="2.15.0";let n;const r={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(null==n){const t=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{n=null!=process.env.API_URL_REGEX?new RegExp(process.env.API_URL_REGEX):t}catch(e){n=t}}return n},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!r.API_URL)return null;try{const t=new URL(r.API_URL);return"api.mapbox.cn"===t.hostname?"https://events.mapbox.cn/events/v2":"api.mapbox.com"===t.hostname?"https://events.mapbox.com/events/v2":null}catch(t){return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},o={supported:!1,testSupport:function(t){!l&&a&&(c?u(t):s=t)}};let s,a,l=!1,c=!1;function u(t){const e=t.createTexture();t.bindTexture(t.TEXTURE_2D,e);try{if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,a),t.isContextLost())return;o.supported=!0}catch(t){}t.deleteTexture(e),l=!0}e.document&&(a=e.document.createElement("img"),a.onload=function(){s&&u(s),s=null,c=!0},a.onerror=function(){l=!0,s=null},a.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const h="01";function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d=f;function f(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=n}f.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,n=0;n<8;n++){var r=this.sampleCurveX(i)-t;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var m=p(d),g=y;function y(t,e){this.x=t,this.y=e}y.prototype={clone:function(){return new y(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,i=t.y-this.y;return e*e+i*i},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),i=Math.sin(t),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),r=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-n*(this.y-e.y),this.y=r,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},y.convert=function(t){return t instanceof y?t:Array.isArray(t)?new y(t[0],t[1]):t};var v=p(g);const _=Math.PI/180,x=180/Math.PI;function b(t){return t*_}function w(t){return t*x}const A=[[0,0],[1,0],[1,1],[0,1]];function E(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function S(t,e,i,n){const r=new m(t,e,i,n);return function(t){return r.solve(t)}}const M=S(.25,.1,.25,1);function T(t,e,i){return Math.min(i,Math.max(e,t))}function I(t,e,i){return(i=T((i-t)/(e-t),0,1))*i*(3-2*i)}function C(t,e,i){const n=i-e,r=((t-e)%n+n)%n+e;return r===e?i:r}function P(t,e,i){if(!t.length)return i(null,[]);let n=t.length;const r=new Array(t.length);let o=null;t.forEach(((t,s)=>{e(t,((t,e)=>{t&&(o=t),r[s]=e,0==--n&&i(o,r)}))}))}function L(t){const e=[];for(const i in t)e.push(t[i]);return e}function D(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let R=1;function O(){return R++}function k(){return function t(e){return e?(e^Math.random()*(16>>e/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,t)}()}function N(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function B(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 z(t,e){t.forEach((t=>{e[t]&&(e[t]=e[t].bind(e))}))}function F(t,e){return-1!==t.indexOf(e,t.length-e.length)}function V(t,e,i){const n={};for(const r in t)n[r]=e.call(i||this,t[r],r,t);return n}function U(t,e,i){const n={};for(const r in t)e.call(i||this,t[r],r,t)&&(n[r]=t[r]);return n}function G(t){return Array.isArray(t)?t.map(G):"object"==typeof t&&t?V(t,G):t}const j={};function H(t){j[t]||("undefined"!=typeof console&&console.warn(t),j[t]=!0)}function W(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function q(t){let e=0;for(let i,n,r=0,o=t.length,s=o-1;r@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,n,r)=>{const o=n||r;return e[i]=!o||o.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}let Y=null;function Q(t){if(null==Y){const e=t.navigator?t.navigator.userAgent:null;Y=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Y}function J(t){try{const i=e[t];return i.setItem("_mapbox_test_",1),i.removeItem("_mapbox_test_"),!0}catch(t){return!1}}function K(t,e){return[t[4*e],t[4*e+1],t[4*e+2],t[4*e+3]]}const $="mapbox-tiles";let tt,et,it=500,nt=50;function rt(){try{return e.caches}catch(t){}}function ot(){rt()&&!tt&&(tt=e.caches.open($))}function st(t){const e=t.indexOf("?");if(e<0)return t;const i=function(t){const e=t.indexOf("?");return e>0?t.slice(e+1).split("&"):[]}(t),n=i.filter((t=>{const e=t.split("=");return"language"===e[0]||"worldview"===e[0]}));return n.length?`${t.slice(0,e)}?${n.join("&")}`:t.slice(0,e)}let at=1/0;const lt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(lt);class ct extends Error{constructor(t,e,i){401===e&&xt(i)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=e,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const ut=X()?()=>self.worker&&self.worker.referrer:()=>("blob:"===e.location.protocol?e.parent:e).location.href,ht=function(t,i){if(!(/^file:/.test(n=t.url)||/^file:/.test(ut())&&!/^\w+:/.test(n))){if(e.fetch&&e.Request&&e.AbortController&&e.Request.prototype.hasOwnProperty("signal"))return function(t,i){const n=new e.AbortController,r=new e.Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,referrer:ut(),referrerPolicy:t.referrerPolicy,signal:n.signal});let o=!1,s=!1;const a=(l=r.url).indexOf("sku=")>0&&xt(l);var l;"json"===t.type&&r.headers.set("Accept","application/json");const c=(n,o,l)=>{if(s)return;if(n&&"SecurityError"!==n.message&&H(n.toString()),o&&l)return u(o);const c=Date.now();e.fetch(r).then((e=>{if(e.ok){const t=a?e.clone():null;return u(e,t,c)}return i(new ct(e.statusText,e.status,t.url))})).catch((e=>{"AbortError"!==e.name&&i(new Error(`${e.message} ${t.url}`))}))},u=(n,a,l)=>{("arrayBuffer"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text()).then((t=>{s||(a&&l&&function(t,i,n){if(ot(),!tt)return;const r={status:i.status,statusText:i.statusText,headers:new e.Headers};i.headers.forEach(((t,e)=>r.headers.set(e,t)));const o=Z(i.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&r.headers.set("Expires",new Date(n+1e3*o["max-age"]).toUTCString());const s=r.headers.get("Expires");s&&(new Date(s).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)}(i,(i=>{const n=new e.Response(i,r);ot(),tt&&tt.then((e=>e.put(st(t.url),n))).catch((t=>H(t.message)))})))}(r,a,l),o=!0,i(null,t,n.headers.get("Cache-Control"),n.headers.get("Expires")))})).catch((t=>{s||i(new Error(t.message))}))};return a?function(t,e){if(ot(),!tt)return e(null);const i=st(t.url);tt.then((t=>{t.match(i).then((n=>{const r=function(t){if(!t)return!1;const e=new Date(t.headers.get("Expires")||0),i=Z(t.headers.get("Cache-Control")||"");return e>Date.now()&&!i["no-cache"]}(n);t.delete(i),r&&t.put(i,n.clone()),e(null,n,r)})).catch(e)})).catch(e)}(r,c):c(null,null),{cancel:()=>{s=!0,o||n.abort()}}}(t,i);if(X()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",t,i,void 0,!0)}var n;return function(t,i){const n=new e.XMLHttpRequest;n.open(t.method||"GET",t.url,!0),"arrayBuffer"===t.type&&(n.responseType="arraybuffer");for(const e in t.headers)n.setRequestHeader(e,t.headers[e]);return"json"===t.type&&(n.responseType="text",n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===t.credentials,n.onerror=()=>{i(new Error(n.statusText))},n.onload=()=>{if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let e=n.response;if("json"===t.type)try{e=JSON.parse(n.response)}catch(t){return i(t)}i(null,e,n.getResponseHeader("Cache-Control"),n.getResponseHeader("Expires"))}else i(new ct(n.statusText,n.status,t.url))},n.send(t.body),{cancel:()=>n.abort()}}(t,i)},pt=function(t,e){return ht(D(t,{type:"arrayBuffer"}),e)};function dt(t){const i=e.document.createElement("a");return i.href=t,i.protocol===e.document.location.protocol&&i.host===e.document.location.host}const ft="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let mt,gt;mt=[],gt=0;const yt=function(t,i){if(o.supported&&(t.headers||(t.headers={}),t.headers.accept="image/webp,*/*"),gt>=r.MAX_PARALLEL_IMAGE_REQUESTS){const e={requestParameters:t,callback:i,cancelled:!1,cancel(){this.cancelled=!0}};return mt.push(e),e}gt++;let n=!1;const s=()=>{if(!n)for(n=!0,gt--;mt.length&>{s(),t?i(t):n&&(e.createImageBitmap?function(t,i){const n=new e.Blob([new Uint8Array(t)],{type:"image/png"});e.createImageBitmap(n).then((t=>{i(null,t)})).catch((t=>{i(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,((t,e)=>i(t,e,r,o))):function(t,i){const n=new e.Image,r=e.URL;n.onload=()=>{i(null,n),r.revokeObjectURL(n.src),n.onload=null,e.requestAnimationFrame((()=>{n.src=ft}))},n.onerror=()=>i(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."));const o=new e.Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?r.createObjectURL(o):ft}(n,((t,e)=>i(t,e,r,o))))}));return{cancel:()=>{a.cancel(),s()}}},vt="NO_ACCESS_TOKEN";function _t(t){return 0===t.indexOf("mapbox:")}function xt(t){return r.API_URL_REGEX.test(t)}function bt(t){return r.API_CDN_URL_REGEX.test(t)}function wt(t){return r.API_STYLE_REGEX.test(t)&&!At(t)}function At(t){return r.API_SPRITE_REGEX.test(t)}const Et=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function St(t){const e=t.match(Et);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 Mt(t){const e=t.params.length?`?${t.params.join("&")}`:"";return`${t.protocol}://${t.authority}${t.path}${e}`}const Tt="mapbox.eventData";function It(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(decodeURIComponent(e.atob(i[1]).split("").map((t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2))).join("")))}catch(t){return null}}class Ct{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=It(r.ACCESS_TOKEN);let n="";return n=i&&i.u?e.btoa(encodeURIComponent(i.u).replace(/%([0-9A-F]{2})/g,((t,e)=>String.fromCharCode(Number("0x"+e))))):r.ACCESS_TOKEN||"",t?`${Tt}.${t}:${n}`:`${Tt}:${n}`}fetchEventData(){const t=J("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{const t=e.localStorage.getItem(i);t&&(this.eventData=JSON.parse(t));const r=e.localStorage.getItem(n);r&&(this.anonId=r)}catch(t){H("Unable to read from LocalStorage")}}saveEventData(){const t=J("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid");if(t)try{e.localStorage.setItem(n,this.anonId),Object.keys(this.eventData).length>=1&&e.localStorage.setItem(i,JSON.stringify(this.eventData))}catch(t){H("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,e,i,n){if(!r.EVENTS_URL)return;const o=St(r.EVENTS_URL);o.params.push(`access_token=${n||r.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=e?D(s,e):s,l={url:Mt(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=function(t,e){return ht(D(t,{method:"POST"}),e)}(l,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(n)}))}queueRequest(t,e){this.queue.push(t),this.processRequests(e)}}const Pt=new class extends Ct{constructor(t){super("appUserTurnstile"),this._customAccessToken=t}postTurnstileEvent(t,e){r.EVENTS_URL&&r.ACCESS_TOKEN&&Array.isArray(t)&&t.some((t=>_t(t)||xt(t)))&&this.queueRequest(Date.now(),e)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const e=It(r.ACCESS_TOKEN),n=e?e.u:r.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;B(this.anonId)||(this.anonId=k(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const t=new Date(this.eventData.lastSuccess),e=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||t.getDate()!==e.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:h,"enabled.telemetry":!1,userId:this.anonId},(t=>{t||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)}),t):this.processRequests()}},Lt=Pt.postTurnstileEvent.bind(Pt),Dt=new class extends Ct{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,e,i,n){this.skuToken=e,this.errorCb=n,r.EVENTS_URL&&(i||r.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(vt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:n}=this.queue.shift();e&&this.success[e]||(this.anonId||this.fetchEventData(),B(this.anonId)||(this.anonId=k()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:i,skuId:h,skuToken:this.skuToken,userId:this.anonId},(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t))}},Rt=Dt.postMapLoadEvent.bind(Dt),Ot=new class extends Ct{constructor(){super("gljs.performance")}postPerformanceEvent(t,e){r.EVENTS_URL&&(t||r.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:e},t)}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:n,performanceData:r}=this.queue.shift(),o=function(t){const n=e.performance.getEntriesByType("resource"),r=e.performance.getEntriesByType("mark"),o=function(t){const e={};if(t)for(const i in t)if("other"!==i)for(const n of t[i]){const t=`${i}ResolveRangeMin`,r=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;e[t]=Math.min(e[t]||1/0,n.startTime),e[r]=Math.max(e[r]||-1/0,n.responseEnd);const a=t=>{void 0===e[t]&&(e[t]=0),++e[t]};void 0!==n.transferSize&&0===n.transferSize&&a(s),a(o)}return e}(function(t,e){const i={};if(t)for(const n of t){const t=e(n);void 0===i[t]&&(i[t]=[]),i[t].push(n)}return i}(n,Ut)),s=e.devicePixelRatio,a=e.navigator.connection||e.navigator.mozConnection||e.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},c=(t,e,i)=>{null!=i&&t.push({name:e,value:i.toString()})};for(const t in o)c(l.counters,t,o[t]);if(t.interactionRange[0]!==1/0&&t.interactionRange[1]!==-1/0&&(c(l.counters,"interactionRangeMin",t.interactionRange[0]),c(l.counters,"interactionRangeMax",t.interactionRange[1])),r)for(const t of Object.keys(Ft)){const e=Ft[t],i=r.find((t=>t.name===e));i&&c(l.counters,e,i.startTime)}return c(l.counters,"visibilityHidden",t.visibilityHidden),c(l.attributes,"style",function(t){if(t)for(const e of t){const t=e.name.split("?")[0];if(wt(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(n)),c(l.attributes,"terrainEnabled",t.terrainEnabled?"true":"false"),c(l.attributes,"fogEnabled",t.fogEnabled?"true":"false"),c(l.attributes,"projection",t.projection),c(l.attributes,"zoom",t.zoom),c(l.metadata,"devicePixelRatio",s),c(l.metadata,"connectionEffectiveType",a?a.effectiveType:void 0),c(l.metadata,"navigatorUserAgent",e.navigator.userAgent),c(l.metadata,"screenWidth",e.screen.width),c(l.metadata,"screenHeight",e.screen.height),c(l.metadata,"windowWidth",e.innerWidth),c(l.metadata,"windowHeight",e.innerHeight),c(l.metadata,"mapWidth",t.width/s),c(l.metadata,"mapHeight",t.height/s),c(l.metadata,"webglRenderer",t.renderer),c(l.metadata,"webglVendor",t.vendor),c(l.metadata,"sdkVersion",i),c(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(r);for(const t of o.metadata);for(const t of o.counters);for(const t of o.attributes);this.postEvent(n,o,(()=>{}),t)}},kt=Ot.postPerformanceEvent.bind(Ot),Nt=new class extends Ct{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,e,i,n){if(!r.API_URL||!r.SESSION_PATH)return;const o=St(r.API_URL+r.SESSION_PATH);o.params.push(`sku=${e||""}`),o.params.push(`access_token=${n||r.ACCESS_TOKEN||""}`);const s={url:Mt(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(t,e){return ht(D(t,{method:"GET"}),e)}(s,(t=>{this.pendingRequest=null,i(t),this.saveEventData(),this.processRequests(n)}))}getSessionAPI(t,e,i,n){this.skuToken=e,this.errorCb=n,r.SESSION_PATH&&r.API_URL&&(i||r.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},i):this.errorCb(new Error(vt)))}processRequests(t){if(this.pendingRequest||0===this.queue.length)return;const{id:e,timestamp:i}=this.queue.shift();e&&this.success[e]||this.getSession(i,this.skuToken,(t=>{t?this.errorCb(t):e&&(this.success[e]=!0)}),t)}},Bt=Nt.getSessionAPI.bind(Nt),zt=new Set,Ft={create:"create",load:"load",fullLoad:"fullLoad"},Vt={mark(t){e.performance.mark(t)},measure(t,i,n){e.performance.measure(t,i,n)}};function Ut(t){const e=t.name.split("?")[0];return bt(e)&&e.includes("mapbox-gl.js")?"javascript":bt(e)&&e.includes("mapbox-gl.css")?"css":function(t){return r.API_FONTS_REGEX.test(t)}(e)?"fontRange":At(e)?"sprite":wt(e)?"style":function(t){return r.API_TILEJSON_REGEX.test(t)}(e)?"tilejson":"other"}const Gt=e.performance;function jt(t){const e=t?t.url.toString():void 0;return Gt.getEntriesByName(e)}let Ht,Wt,qt,Xt;const Zt={now:()=>void 0!==qt?qt:e.performance.now(),setNow(t){qt=t},restoreNow(){qt=void 0},frame(t){const i=e.requestAnimationFrame(t);return{cancel:()=>e.cancelAnimationFrame(i)}},getImageData(t,i=0){const{width:n,height:r}=t;Xt||(Xt=e.document.createElement("canvas"));const o=Xt.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(n>Xt.width||r>Xt.height)&&(Xt.width=n,Xt.height=r),o.clearRect(-i,-i,n+2*i,r+2*i),o.drawImage(t,0,0,n,r),o.getImageData(-i,-i,n+2*i,r+2*i)},resolveURL:t=>(Ht||(Ht=e.document.createElement("a")),Ht.href=t,Ht.href),get devicePixelRatio(){return e.devicePixelRatio},get prefersReducedMotion(){return!!e.matchMedia&&(null==Wt&&(Wt=e.matchMedia("(prefers-reduced-motion: reduce)")),Wt.matches)}};function Yt(t,e,i){i[t]&&-1!==i[t].indexOf(e)||(i[t]=i[t]||[],i[t].push(e))}function Qt(t,e,i){if(i&&i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class Jt{constructor(t,e={}){D(this,e),this.type=t}}class Kt extends Jt{constructor(t,e={}){super("error",D({error:t},e))}}class $t{on(t,e){return this._listeners=this._listeners||{},Yt(t,e,this._listeners),this}off(t,e){return Qt(t,e,this._listeners),Qt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners=this._oneTimeListeners||{},Yt(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){"string"==typeof t&&(t=new Jt(t,e||{}));const i=t.type;if(this.listens(i)){t.target=this;const e=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of e)i.call(this,t);const n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const e of n)Qt(i,e,this._oneTimeListeners),e.call(this,t);const r=this._eventedParent;r&&(D(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(t))}else t instanceof Kt&&console.error(t.error);return this}listens(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))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var te=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"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"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"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":true,"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":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"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":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"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":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"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_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"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"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"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":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"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":true,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"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":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"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":true,"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":false,"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":false,"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":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"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":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"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_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"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":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"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"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function ee(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}function ie(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function ne(t){if(Array.isArray(t))return t.map(ne);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=ne(t[i]);return e}return ie(t)}class re extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var oe=re;class se{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new se(this,t)}get(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.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var ae=se;const le={kind:"null"},ce={kind:"number"},ue={kind:"string"},he={kind:"boolean"},pe={kind:"color"},de={kind:"object"},fe={kind:"value"},me={kind:"collator"},ge={kind:"formatted"},ye={kind:"resolvedImage"};function ve(t,e){return{kind:"array",itemType:t,N:e}}function _e(t){if("array"===t.kind){const e=_e(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const xe=[le,ce,ue,he,pe,ge,de,ve(fe),ye];function be(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!be(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(const t of xe)if(!be(t,e))return null}return`Expected ${_e(t)} but found ${_e(e)} instead.`}function we(t,e){return e.some((e=>e.kind===t.kind))}function Ae(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}var Ee,Se={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 Me(t){return(t=Math.round(t))<0?0:t>255?255:t}function Te(t){return Me("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function Ie(t){return(e="%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))<0?0:e>1?1:e;var e}function Ce(t,e,i){return i<0?i+=1:i>1&&(i-=1),6*i<1?t+(e-t)*i*6:2*i<1?e:3*i<2?t+(e-t)*(2/3-i)*6:t}try{Ee={}.parseCSSColor=function(t){var e,i=t.replace(/ /g,"").toLowerCase();if(i in Se)return Se[i].slice();if("#"===i[0])return 4===i.length?(e=parseInt(i.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===i.length&&(e=parseInt(i.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var n=i.indexOf("("),r=i.indexOf(")");if(-1!==n&&r+1===i.length){var o=i.substr(0,n),s=i.substr(n+1,r-(n+1)).split(","),a=1;switch(o){case"rgba":if(4!==s.length)return null;a=Ie(s.pop());case"rgb":return 3!==s.length?null:[Te(s[0]),Te(s[1]),Te(s[2]),a];case"hsla":if(4!==s.length)return null;a=Ie(s.pop());case"hsl":if(3!==s.length)return null;var l=(parseFloat(s[0])%360+360)%360/360,c=Ie(s[1]),u=Ie(s[2]),h=u<=.5?u*(c+1):u+c-u*c,p=2*u-h;return[Me(255*Ce(p,h,l+1/3)),Me(255*Ce(p,h,l)),Me(255*Ce(p,h,l-1/3)),a];default:return null}}return null}}catch(t){}class Pe{constructor(t,e,i,n=1){this.r=t,this.g=e,this.b=i,this.a=n}static parse(t){if(!t)return;if(t instanceof Pe)return t;if("string"!=typeof t)return;const e=Ee(t);return e?new Pe(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,i,n]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(i)},${n})`}toArray(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[255*t/n,255*e/n,255*i/n,n]}toArray01(){const{r:t,g:e,b:i,a:n}=this;return 0===n?[0,0,0,0]:[t/n,e/n,i/n,n]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:i,a:n}=this;return[t,e,i,n]}}Pe.black=new Pe(0,0,0,1),Pe.white=new Pe(1,1,1,1),Pe.transparent=new Pe(0,0,0,0),Pe.red=new Pe(1,0,0,1),Pe.blue=new Pe(0,0,1,1);var Le=Pe;class De{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Re{constructor(t,e,i,n,r){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=r}}class Oe{constructor(t){this.sections=t}static fromString(t){return new Oe([new Re(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Oe?t:Oe.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const i={};e.fontStack&&(i["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(i["font-scale"]=e.scale),e.textColor&&(i["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(i)}return t}}class ke{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new ke({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Ne(t,e,i,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,i,n]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Be(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 Le)return!0;if(t instanceof De)return!0;if(t instanceof Oe)return!0;if(t instanceof ke)return!0;if(Array.isArray(t)){for(const e of t)if(!Be(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Be(t[e]))return!1;return!0}return!1}function ze(t){if(null===t)return le;if("string"==typeof t)return ue;if("boolean"==typeof t)return he;if("number"==typeof t)return ce;if(t instanceof Le)return pe;if(t instanceof De)return me;if(t instanceof Oe)return ge;if(t instanceof ke)return ye;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=ze(e);if(i){if(i===t)continue;i=fe;break}i=t}return ve(i||fe,e)}return de}function Fe(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Le||t instanceof Oe||t instanceof ke?t.toString():JSON.stringify(t)}class Ve{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Be(t[1]))return e.error("invalid value");const i=t[1];let n=ze(i);const r=e.expectedType;return"array"!==n.kind||0!==n.N||!r||"array"!==r.kind||"number"==typeof r.N&&0!==r.N||(n=r),new Ve(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Le?["rgba"].concat(this.value.toArray()):this.value instanceof Oe?this.value.serialize():this.value}}var Ue=Ve,Ge=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const je={string:ue,number:ce,boolean:he,object:de};class He{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,n=1;const r=t[0];if("array"===r){let r,o;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in je)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);r=je[i],n++}else r=fe;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);o=t[2],n++}i=ve(r,o)}else i=je[r];const o=[];for(;nt.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const i=t.itemType;if("string"===i.kind||"number"===i.kind||"boolean"===i.kind){e.push(i.kind);const n=t.N;("number"==typeof n||this.args.length>1)&&e.push(n)}}return e.concat(this.args.map((t=>t.serialize())))}}var We=He;class qe{constructor(t){this.type=ge,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const n=[];let r=!1;for(let i=1;i<=t.length-1;++i){const o=t[i];if(r&&"object"==typeof o&&!Array.isArray(o)){r=!1;let t=null;if(o["font-scale"]&&(t=e.parse(o["font-scale"],1,ce),!t))return null;let i=null;if(o["text-font"]&&(i=e.parse(o["text-font"],1,ve(ue)),!i))return null;let s=null;if(o["text-color"]&&(s=e.parse(o["text-color"],1,pe),!s))return null;const a=n[n.length-1];a.scale=t,a.font=i,a.textColor=s}else{const o=e.parse(t[i],1,fe);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null})}}return new qe(n)}evaluate(t){return new Oe(this.sections.map((e=>{const i=e.content.evaluate(t);return ze(i)===ye?new Re("",i,null,null,null):new Re(Fe(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const i={};e.scale&&(i["font-scale"]=e.scale.serialize()),e.font&&(i["text-font"]=e.font.serialize()),e.textColor&&(i["text-color"]=e.textColor.serialize()),t.push(i)}return t}}class Xe{constructor(t){this.type=ye,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ue);return i?new Xe(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=ke.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const Ze={"to-boolean":he,"to-color":pe,"to-number":ce,"to-string":ue};class Ye{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const n=Ze[i],r=[];for(let i=1;i4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Ne(e[0],e[1],e[2],e[3]),!i))return new Le(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new Ge(i||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new Ge(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Oe.fromString(Fe(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?ke.fromString(Fe(this.args[0].evaluate(t))):Fe(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new qe([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Xe(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild((e=>{t.push(e.serialize())})),t}}var Qe=Ye;const Je=["Unknown","Point","LineString","Polygon"];var Ke=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Je[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:i,y:n}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*e-t[0])+this.featureDistanceData.bearing[1]*(n*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Le.parse(t)),e}};class $e{constructor(t,e,i,n){this.name=t,this.type=e,this._evaluate=i,this.args=n}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const i=t[0],n=$e.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const r=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,s=o.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[n,o]of s){a=new Mi(e.registry,e.path,null,e.scope);const s=[];let l=!1;for(let e=1;e{return e=t,Array.isArray(e)?`(${e.map(_e).join(", ")})`:`(${_e(e.type)}...)`;var e})).join(" | "),n=[];for(let i=1;i=e[2]||t[1]<=e[1]||t[3]>=e[3])}function oi(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,r=Math.pow(2,e.z);return[Math.round(i*r*ii),Math.round(n*r*ii)]}function si(t,e,i){const n=t[0]-e[0],r=t[1]-e[1],o=t[0]-i[0],s=t[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function ai(t,e){let i=!1;for(let s=0,a=e.length;s(n=t)[1]!=(o=a[e+1])[1]>n[1]&&n[0]<(o[0]-r[0])*(n[1]-r[1])/(o[1]-r[1])+r[0]&&(i=!i)}}var n,r,o;return i}function li(t,e){for(let i=0;i0&&a<0||s<0&&a>0}function ui(t,e,i){for(const c of i)for(let i=0;ii[2]){const e=.5*n;let r=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===r&&(r=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=r}ni(e,t)}function gi(t,e,i,n){const r=Math.pow(2,n.z)*ii,o=[n.x*ii,n.y*ii],s=[];if(!t)return s;for(const n of t)for(const t of n){const n=[t.x+o[0],t.y+o[1]];mi(n,e,i,r),s.push(n)}return s}function yi(t,e,i,n){const r=Math.pow(2,n.z)*ii,o=[n.x*ii,n.y*ii],s=[];if(!t)return s;for(const i of t){const t=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];ni(e,i),t.push(i)}s.push(t)}if(e[2]-e[0]<=r/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of s)for(const n of t)mi(n,e,i,r)}var a;return s}class vi{constructor(t,e){this.type=he,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Be(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t{e&&!xi(t)&&(e=!1)})),e}function bi(t){if(t instanceof ti&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!bi(t)&&(e=!1)})),e}function wi(t,e){if(t instanceof ti&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!wi(t,e)&&(i=!1)})),i}class Ai{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new Ai(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Ei=Ai;class Si{constructor(t,e=[],i,n=new ae,r=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=r,this.expectedType=i}parse(t,e,i,n,r={}){return e?this.concat(e,i,n)._parse(t,r):this._parse(t,r)}_parse(t,e){function i(t,e,i){return"assert"===i?new We(e,[t]):"coerce"===i?new Qe(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", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];if(r){let n=r.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,r=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==r.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(t,r))return null}else n=i(n,t,e.typeAnnotation||"coerce");else n=i(n,t,e.typeAnnotation||"assert")}if(!(n instanceof Ue)&&"resolvedImage"!==n.type.kind&&Ti(n)){const e=new Ke;try{n=new Ue(n.type,n.evaluate(e))}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". 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.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,r=i?this.scope.concat(i):this.scope;return new Si(this.registry,n,e||null,r,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new oe(i,t))}checkSubtype(t,e){const i=be(t,e);return i&&this.error(i),i}}var Mi=Si;function Ti(t){if(t instanceof Ei)return Ti(t.boundExpression);if(t instanceof ti&&"error"===t.name)return!1;if(t instanceof ei)return!1;if(t instanceof _i)return!1;const e=t instanceof Qe||t instanceof We;let i=!0;return t.eachChild((t=>{i=e?i&&Ti(t):i&&t instanceof Ue})),!!i&&xi(t)&&wi(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function Ii(t,e){const i=t.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=t[a],r=t[a+1],n<=e){if(a===i||ee))throw new Ge("Input is not a number.");s=a-1}return 0}class Ci{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(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.");const i=e.parse(t[1],1,ce);if(!i)return null;const n=[];let r=null;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);for(let i=1;i=o)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=e.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new Ci(r,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return i[0].evaluate(t);const r=e.length;return n>=e[r-1]?i[r-1].evaluate(t):i[Ii(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var Pi=Ci;function Li(t,e,i){return t*(1-i)+e*i}var Di=Object.freeze({__proto__:null,array:function(t,e,i){return t.map(((t,n)=>Li(t,e[n],i)))},color:function(t,e,i){return new Le(Li(t.r,e.r,i),Li(t.g,e.g,i),Li(t.b,e.b,i),Li(t.a,e.a,i))},number:Li});const Ri=.95047,Oi=1.08883,ki=4/29,Ni=6/29,Bi=3*Ni*Ni,zi=Ni*Ni*Ni,Fi=Math.PI/180,Vi=180/Math.PI;function Ui(t){return t>zi?Math.pow(t,1/3):t/Bi+ki}function Gi(t){return t>Ni?t*t*t:Bi*(t-ki)}function ji(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Hi(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Wi(t){const e=Hi(t.r),i=Hi(t.g),n=Hi(t.b),r=Ui((.4124564*e+.3575761*i+.1804375*n)/Ri),o=Ui((.2126729*e+.7151522*i+.072175*n)/1);return{l:116*o-16,a:500*(r-o),b:200*(o-Ui((.0193339*e+.119192*i+.9503041*n)/Oi)),alpha:t.a}}function qi(t){let e=(t.l+16)/116,i=isNaN(t.a)?e:e+t.a/500,n=isNaN(t.b)?e:e-t.b/200;return e=1*Gi(e),i=Ri*Gi(i),n=Oi*Gi(n),new Le(ji(3.2404542*i-1.5371385*e-.4985314*n),ji(-.969266*i+1.8760108*e+.041556*n),ji(.0556434*i-.2040259*e+1.0572252*n),t.alpha)}function Xi(t,e,i){const n=e-t;return t+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const Zi={forward:Wi,reverse:qi,interpolate:function(t,e,i){return{l:Li(t.l,e.l,i),a:Li(t.a,e.a,i),b:Li(t.b,e.b,i),alpha:Li(t.alpha,e.alpha,i)}}},Yi={forward:function(t){const{l:e,a:i,b:n}=Wi(t),r=Math.atan2(n,i)*Vi;return{h:r<0?r+360:r,c:Math.sqrt(i*i+n*n),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Fi,i=t.c;return qi({l:t.l,a:Math.cos(e)*i,b:Math.sin(e)*i,alpha:t.alpha})},interpolate:function(t,e,i){return{h:Xi(t.h,e.h,i),c:Li(t.c,e.c,i),l:Li(t.l,e.l,i),alpha:Li(t.alpha,e.alpha,i)}}};var Qi=Object.freeze({__proto__:null,hcl:Yi,lab:Zi});class Ji{constructor(t,e,i,n,r){this.type=t,this.operator=e,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of r)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,n){let r=0;if("exponential"===t.name)r=Ki(e,t.base,i,n);else if("linear"===t.name)r=Ki(e,1,i,n);else if("cubic-bezier"===t.name){const o=t.controlPoints;r=new m(o[0],o[1],o[2],o[3]).solve(Ki(e,1,i,n))}return r}static parse(t,e){let[i,n,r,...o]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t}}else{if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}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(r=e.parse(r,2,ce),!r)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=pe:e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType);for(let t=0;t=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=e.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Ji(a,i,n,r,s):e.error(`Type ${_e(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return i[0].evaluate(t);const r=e.length;if(n>=e[r-1])return i[r-1].evaluate(t);const o=Ii(e,n),s=Ji.interpolationFactor(this.interpolation,n,e[o],e[o+1]),a=i[o].evaluate(t),l=i[o+1].evaluate(t);return"interpolate"===this.operator?Di[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Yi.reverse(Yi.interpolate(Yi.forward(a),Yi.forward(l),s)):Zi.reverse(Zi.interpolate(Zi.forward(a),Zi.forward(l),s))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let 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);const e=[this.operator,t,this.input.serialize()];for(let t=0;tbe(n,t.type)));return new tn(o?fe:i,r)}evaluate(t){let e,i=null,n=0;for(const r of this.args){if(n++,i=r.evaluate(t),i&&i instanceof ke&&!i.available&&(e||(e=i),i=null,n===this.args.length))return e;if(null!==i)break}return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var en=tn;class nn{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let n=1;n=i.length)throw new Ge(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new Ge(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var sn=on;class an{constructor(t,e){this.type=he,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,fe),n=e.parse(t[2],2,fe);return i&&n?we(i.type,[he,ue,ce,le,fe])?new an(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${_e(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(null==i)return!1;if(!Ae(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${_e(ze(e))} instead.`);if(!Ae(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${_e(ze(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var ln=an;class cn{constructor(t,e,i){this.type=ce,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,fe),n=e.parse(t[2],2,fe);if(!i||!n)return null;if(!we(i.type,[he,ue,ce,le,fe]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${_e(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ce);return r?new cn(i,n,r):null}return new cn(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!Ae(e,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${_e(ze(e))} instead.`);if(!Ae(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${_e(ze(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(t);return i.indexOf(e,n)}return i.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var un=cn;class hn{constructor(t,e,i,n,r,o){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=r,this.otherwise=o}static parse(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.");let i,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const r={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,ze(t)))return null}else i=ze(t);if(void 0!==r[String(t)])return c.error("Branch labels must be unique.");r[String(t)]=o.length}const u=e.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=e.parse(t[1],1,fe);if(!s)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==s.type.kind&&e.concat(1).checkSubtype(i,s.type)?null:new hn(i,n,s,r,o,a):null}evaluate(t){const e=this.input.evaluate(t);return(ze(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),i=[],n={};for(const t of e){const e=n[this.cases[t]];void 0===e?(n[this.cases[t]]=i.length,i.push([this.cases[t],[t]])):i[e][1].push(t)}const r=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,n]of i)t.push(1===n.length?r(n[0]):n.map(r)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var pn=hn;class dn{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(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.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const n=[];for(let r=1;re.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var fn=dn;class mn{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,fe),n=e.parse(t[2],2,ce);if(!i||!n)return null;if(!we(i.type,[ve(fe),ue,fe]))return e.error(`Expected first argument to be of type array or string, but found ${_e(i.type)} instead`);if(4===t.length){const r=e.parse(t[3],3,ce);return r?new mn(i.type,i,n,r):null}return new mn(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);if(!Ae(e,["string","array"]))throw new Ge(`Expected first argument to be of type array or string, but found ${_e(ze(e))} instead.`);if(this.endIndex){const n=this.endIndex.evaluate(t);return e.slice(i,n)}return e.slice(i)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var gn=mn;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,i,n){return 0===n.compare(e,i)}function _n(t,e,i){const n="=="!==t&&"!="!==t;return class r{constructor(t,e,i){this.type=he,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let o=e.parse(t[1],1,fe);if(!o)return null;if(!yn(i,o.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${_e(o.type)}'.`);let s=e.parse(t[2],2,fe);if(!s)return null;if(!yn(i,s.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${_e(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error(`Cannot compare types '${_e(o.type)}' and '${_e(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new We(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new We(o.type,[s])));let a=null;if(4===t.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,me),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const e=ze(o),i=ze(s);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new Ge(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=ze(o),i=ze(s);if("string"!==t.kind||"string"!==i.kind)return e(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):e(r,o,s)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const xn=_n("==",(function(t,e,i){return e===i}),vn),bn=_n("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!vn(0,e,i,n)})),wn=_n("<",(function(t,e,i){return e",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),En=_n("<=",(function(t,e,i){return e<=i}),(function(t,e,i,n){return n.compare(e,i)<=0})),Sn=_n(">=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class Mn{constructor(t,e,i,n,r,o){this.type=ue,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=r,this.maxFractionDigits=o}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,ce);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let r=null;if(n.locale&&(r=e.parse(n.locale,1,ue),!r))return null;let o=null;if(n.currency&&(o=e.parse(n.currency,1,ue),!o))return null;let s=null;if(n.unit&&(s=e.parse(n.unit,1,ue),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,ce),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=e.parse(n["max-fraction-digits"],1,ce),!l)?null:new Mn(i,r,o,s,a,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.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))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.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]}}class Tn{constructor(t){this.type=ce,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${_e(i.type)} instead.`):new Tn(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new Ge(`Expected value to be of type string or array, but found ${_e(ze(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const In={"==":xn,"!=":bn,">":An,"<":wn,">=":Sn,"<=":En,array:We,at:sn,boolean:We,case:fn,coalesce:en,collator:ei,format:qe,image:Xe,in:ln,"index-of":un,interpolate:$i,"interpolate-hcl":$i,"interpolate-lab":$i,length:Tn,let:rn,literal:Ue,match:pn,number:We,"number-format":Mn,object:We,slice:gn,step:Pi,string:We,"to-boolean":Qe,"to-color":Qe,"to-number":Qe,"to-string":Qe,var:Ei,within:_i};function Cn(t,[e,i,n,r]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const o=r?r.evaluate(t):1,s=Ne(e,i,n,o);if(s)throw new Ge(s);return new Le(e/255*o,i/255*o,n/255*o,o)}function Pn(t,e){return t in e}function Ln(t,e){const i=e[t];return void 0===i?null:i}function Dn(t){return{type:t}}ti.register(In,{error:[{kind:"error"},[ue],(t,[e])=>{throw new Ge(e.evaluate(t))}],typeof:[ue,[fe],(t,[e])=>_e(ze(e.evaluate(t)))],"to-rgba":[ve(ce,4),[pe],(t,[e])=>e.evaluate(t).toArray()],rgb:[pe,[ce,ce,ce],Cn],rgba:[pe,[ce,ce,ce,ce],Cn],has:{type:he,overloads:[[[ue],(t,[e])=>Pn(e.evaluate(t),t.properties())],[[ue,de],(t,[e,i])=>Pn(e.evaluate(t),i.evaluate(t))]]},get:{type:fe,overloads:[[[ue],(t,[e])=>Ln(e.evaluate(t),t.properties())],[[ue,de],(t,[e,i])=>Ln(e.evaluate(t),i.evaluate(t))]]},"feature-state":[fe,[ue],(t,[e])=>Ln(e.evaluate(t),t.featureState||{})],properties:[de,[],t=>t.properties()],"geometry-type":[ue,[],t=>t.geometryType()],id:[fe,[],t=>t.id()],zoom:[ce,[],t=>t.globals.zoom],pitch:[ce,[],t=>t.globals.pitch||0],"distance-from-center":[ce,[],t=>t.distanceFromCenter()],"heatmap-density":[ce,[],t=>t.globals.heatmapDensity||0],"line-progress":[ce,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[ce,[],t=>t.globals.skyRadialProgress||0],accumulated:[fe,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[ce,Dn(ce),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[ce,Dn(ce),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:ce,overloads:[[[ce,ce],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[ce],(t,[e])=>-e.evaluate(t)]]},"/":[ce,[ce,ce],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[ce,[ce,ce],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[ce,[],()=>Math.LN2],pi:[ce,[],()=>Math.PI],e:[ce,[],()=>Math.E],"^":[ce,[ce,ce],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[ce,[ce],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[ce,[ce],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[ce,[ce],(t,[e])=>Math.log(e.evaluate(t))],log2:[ce,[ce],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[ce,[ce],(t,[e])=>Math.sin(e.evaluate(t))],cos:[ce,[ce],(t,[e])=>Math.cos(e.evaluate(t))],tan:[ce,[ce],(t,[e])=>Math.tan(e.evaluate(t))],asin:[ce,[ce],(t,[e])=>Math.asin(e.evaluate(t))],acos:[ce,[ce],(t,[e])=>Math.acos(e.evaluate(t))],atan:[ce,[ce],(t,[e])=>Math.atan(e.evaluate(t))],min:[ce,Dn(ce),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[ce,Dn(ce),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[ce,[ce],(t,[e])=>Math.abs(e.evaluate(t))],round:[ce,[ce],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[ce,[ce],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[ce,[ce],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[he,[ue,fe],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[he,[fe],(t,[e])=>t.id()===e.value],"filter-type-==":[he,[ue],(t,[e])=>t.geometryType()===e.value],"filter-<":[he,[ue,fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n{const i=t.id(),n=e.value;return typeof i==typeof n&&i":[he,[ue,fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[he,[fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-<=":[he,[ue,fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[he,[fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<=n}],"filter->=":[he,[ue,fe],(t,[e,i])=>{const n=t.properties()[e.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[he,[fe],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[he,[fe],(t,[e])=>e.value in t.properties()],"filter-has-id":[he,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[he,[ve(ue)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[he,[ve(fe)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[he,[ue,ve(fe)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[he,[ue,ve(fe)],(t,[e,i])=>function(t,e,i,n){for(;i<=n;){const r=i+n>>1;if(e[r]===t)return!0;e[r]>t?n=r-1:i=r+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:he,overloads:[[[he,he],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[Dn(he),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:he,overloads:[[[he,he],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[Dn(he),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[he,[he],(t,[e])=>!e.evaluate(t)],"is-supported-script":[he,[ue],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[ue,[ue],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[ue,[ue],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[ue,Dn(fe),(t,e)=>e.map((e=>Fe(e.evaluate(t)))).join("")],"resolved-locale":[ue,[me],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Rn=In;function On(t){return{result:"success",value:t}}function kn(t){return{result:"error",value:t}}function Nn(t){return"data-driven"===t["property-type"]}function Bn(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 Vn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Un(t){return t}function Gn(t,e){const i="color"===e.type,n=t.stops&&"object"==typeof t.stops[0][0],r=n||!(n||void 0!==t.property),o=t.type||(zn(e)?"exponential":"interval");if(i&&((t=ee({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],Le.parse(t[1])]))),t.default=Le.parse(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Qi[t.colorSpace])throw new Error(`Unknown color space: ${t.colorSpace}`);let s,a,l;if("exponential"===o)s=qn;else if("interval"===o)s=Wn;else if("categorical"===o){s=Hn,a=Object.create(null);for(const e of t.stops)a[e[0]]=e[1];l=typeof t.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=Xn}if(n){const i={},n=[];for(let e=0;et[0])),evaluate:({zoom:i},n)=>qn({stops:r,base:t.base},e,i).evaluate(i,n)}}if(r){const i="exponential"===o?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:$i.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>s(t,e,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[t.property]:void 0;return void 0===r?jn(t.default,e.default):s(t,e,r,a,l)}}}function jn(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Hn(t,e,i,n,r){return jn(typeof i===r?n[i]:void 0,t.default,e.default)}function Wn(t,e,i){if("number"!==Fn(i))return jn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const r=Ii(t.stops.map((t=>t[0])),i);return t.stops[r][1]}function qn(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==Fn(i))return jn(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];const o=Ii(t.stops.map((t=>t[0])),i),s=function(t,e,i,n){const r=n-i,o=t-i;return 0===r?0:1===e?o/r:(Math.pow(e,o)-1)/(Math.pow(e,r)-1)}(i,n,t.stops[o][0],t.stops[o+1][0]),a=t.stops[o][1],l=t.stops[o+1][1];let c=Di[e.type]||Un;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=Qi[t.colorSpace];c=(t,i)=>e.reverse(e.interpolate(e.forward(t),e.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...t){const e=a.evaluate.apply(void 0,t),i=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==i)return c(e,i,s)}}:c(a,l,s)}function Xn(t,e,i){return"color"===e.type?i=Le.parse(i):"formatted"===e.type?i=Oe.fromString(i.toString()):"resolvedImage"===e.type?i=ke.fromString(i.toString()):Fn(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0),jn(i,t.default,e.default)}class Zn{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=e?function(t){return"color"===t.type&&(Vn(t.default)||Array.isArray(t.default))?new Le(0,0,0,0):"color"===t.type?Le.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,i,n,r,o,s,a){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,n,r,o,s,a){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n||null,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=s||null,this._evaluator.featureDistanceData=a||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new Ge(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function Yn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Rn}function Qn(t,e){const i=new Mi(Rn,[],e?function(t){const e={color:pe,string:ue,number:ce,enum:ue,boolean:he,formatted:ge,resolvedImage:ye};return"array"===t.type?ve(e[t.value]||fe,t.length):e[t.type]}(e):void 0),n=i.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return n?On(new Zn(n,e)):kn(i.errors)}class Jn{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!bi(e.expression)}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}}class Kn{constructor(t,e,i,n){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!bi(e.expression),this.interpolationType=n}evaluateWithoutErrorHandling(t,e,i,n,r,o){return this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,r,o)}evaluate(t,e,i,n,r,o){return this._styleExpression.evaluate(t,e,i,n,r,o)}interpolationFactor(t,e,i){return this.interpolationType?$i.interpolationFactor(this.interpolationType,t,e,i):0}}function $n(t,e){if("error"===(t=Qn(t,e)).result)return t;const i=t.value.expression,n=xi(i);if(!n&&!Nn(e))return kn([new oe("","data expressions not supported")]);const r=wi(i,["zoom","pitch","distance-from-center"]);if(!r&&!Bn(e))return kn([new oe("","zoom expressions not supported")]);const o=er(i);return o||r?o instanceof oe?kn([o]):o instanceof $i&&!zn(e)?kn([new oe("",'"interpolate" expressions cannot be used with this property')]):On(o?new Kn(n?"camera":"composite",t.value,o.labels,o instanceof $i?o.interpolation:void 0):new Jn(n?"constant":"source",t.value)):kn([new oe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class tr{constructor(t,e){this._parameters=t,this._specification=e,ee(this,Gn(this._parameters,this._specification))}static deserialize(t){return new tr(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function er(t){let e=null;if(t instanceof rn)e=er(t.result);else if(t instanceof en){for(const i of t.args)if(e=er(i),e)break}else(t instanceof Pi||t instanceof $i)&&t.input instanceof ti&&"zoom"===t.input.name&&(e=t);return e instanceof oe||t.eachChild((t=>{const i=er(t);i instanceof oe?e=i:!e&&i?e=new oe("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new oe("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}class ir{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function nr(t){const e=t.key,i=t.value,n=t.valueSpec||{},r=t.objectElementValidators||{},o=t.style,s=t.styleSpec;let a=[];const l=Fn(i);if("object"!==l)return[new ir(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0];let c;r[l]?c=r[l]:n[l]?c=Br:r["*"]?c=r["*"]:n["*"]&&(c=Br),c?a=a.concat(c({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:n[l]||n["*"],style:o,styleSpec:s,object:i,objectKey:t},i)):a.push(new ir(e,i[t],`unknown property "${t}"`))}for(const t in n)r[t]||n[t].required&&void 0===n[t].default&&void 0===i[t]&&a.push(new ir(e,i,`missing required property "${t}"`));return a}function rr(t){const e=t.value,i=t.valueSpec,n=t.style,r=t.styleSpec,o=t.key,s=t.arrayElementValidator||Br;if("array"!==Fn(e))return[new ir(o,e,`array expected, ${Fn(e)} found`)];if(i.length&&e.length!==i.length)return[new ir(o,e,`array length ${i.length} expected, length ${e.length} found`)];if(i["min-length"]&&e.lengthr)return[new ir(e,i,`${i} is greater than the maximum value ${r}`)]}return[]}function sr(t){const e=t.valueSpec,i=ie(t.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===t.value.property,l=!a,c="array"===Fn(t.value.stops)&&"array"===Fn(t.value.stops[0])&&"object"===Fn(t.value.stops[0][0]),u=nr({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new ir(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(rr({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 ir(t.key,n,"array must have at least one stop")),e},default:function(t){return Br({key:t.key,value:t.value,valueSpec:e,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&u.push(new ir(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||u.push(new ir(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!zn(t.valueSpec)&&u.push(new ir(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!Nn(t.valueSpec)?u.push(new ir(t.key,t.value,"property functions not supported")):a&&!Bn(t.valueSpec)&&u.push(new ir(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==t.value.property||u.push(new ir(t.key,t.value,'"property" property is required')),u;function h(t){let i=[];const n=t.value,a=t.key;if("array"!==Fn(n))return[new ir(a,n,`array expected, ${Fn(n)} found`)];if(2!==n.length)return[new ir(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Fn(n[0]))return[new ir(a,n,`object expected, ${Fn(n[0])} found`)];if(void 0===n[0].zoom)return[new ir(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new ir(a,n,"object stop key must have value")];const e=ie(n[0].zoom);if("number"!=typeof e)return[new ir(a,n[0].zoom,"stop zoom values must be numbers")];if(o&&o>e)return[new ir(a,n[0].zoom,"stop zoom values must appear in ascending order")];e!==o&&(o=e,r=void 0,s={}),i=i.concat(nr({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:or,value:p}}))}else i=i.concat(p({key:`${a}[0]`,value:n[0],valueSpec:{},style:t.style,styleSpec:t.styleSpec},n));return Yn(ne(n[1]))?i.concat([new ir(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(Br({key:`${a}[1]`,value:n[1],valueSpec:e,style:t.style,styleSpec:t.styleSpec}))}function p(t,o){const a=Fn(t.value),l=ie(t.value),c=null!==t.value?t.value:o;if(n){if(a!==n)return[new ir(t.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new ir(t.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return Nn(e)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ir(t.key,c,n)]}return"categorical"!==i||"number"!==a||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&"number"==typeof l&&"number"==typeof r&&void 0!==r&&lnew ir(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new ir(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&&!bi(i))return[new ir(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return lr(i,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!wi(i,["zoom","feature-state"]))return[new ir(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!xi(i))return[new ir(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function lr(t,e){const i=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(e.valueSpec&&e.valueSpec.expression)for(const t of e.valueSpec.expression.parameters)i.delete(t);if(0===i.size)return[];const n=[];return t instanceof ti&&i.has(t.name)?[new ir(e.key,e.value,`["${t.name}"] expression is not supported in a filter for a ${e.object.type} layer with id: ${e.object.id}`)]:(t.eachChild((t=>{n.push(...lr(t,e))})),n)}function cr(t){const e=t.key,i=t.value,n=t.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(ie(i))&&r.push(new ir(e,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(ie(i))&&r.push(new ir(e,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function ur(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(const e of t.slice(1))if(!ur(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}function hr(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};ur(t)||(t=vr(t));const i=t;let n=!0;try{n=function(t){if(!fr(t))return t;let e=ne(t);return dr(e),e=pr(e),e}(i)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(i,null,2)}\n `)}const r=te[`filter_${e}`],o=Qn(n,r);let s=null;if("error"===o.result)throw new Error(o.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,i)=>o.value.evaluate(t,e,{},i);let a=null,l=null;if(n!==i){const t=Qn(i,r);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,i,n,r,o)=>t.value.evaluate(e,i,{},n,void 0,void 0,r,o),l=!xi(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:yr(n),needFeature:!!l}}function pr(t){if(!Array.isArray(t))return t;const e=function(t){if(mr.has(t[0]))for(let e=1;epr(t)))}function dr(t){let e=!1;const i=[];if("case"===t[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function gr(t,e){return te?1:0}function yr(t){if(!Array.isArray(t))return!1;if("within"===t[0])return!0;for(let e=1;e"===e||"<="===e||">="===e?_r(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(vr))):"all"===e?["all"].concat(t.slice(1).map(vr)):"none"===e?["all"].concat(t.slice(1).map(vr).map(wr)):"in"===e?xr(t[1],t.slice(2)):"!in"===e?wr(xr(t[1],t.slice(2))):"has"===e?br(t[1]):"!has"===e?wr(br(t[1])):"within"!==e||t;var i}function _r(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function xr(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((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(gr)]]:["filter-in-small",t,["literal",e]]}}function br(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function wr(t){return["!",t]}function Ar(t){return ur(ne(t.value))?ar(ee({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):Er(t)}function Er(t){const e=t.value,i=t.key;if("array"!==Fn(e))return[new ir(i,e,`array expected, ${Fn(e)} found`)];const n=t.styleSpec;let r,o=[];if(e.length<1)return[new ir(i,e,"filter array must have at least 1 element")];switch(o=o.concat(cr({key:`${i}[0]`,value:e[0],valueSpec:n.filter_operator,style:t.style,styleSpec:t.styleSpec})),ie(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===ie(e[1])&&o.push(new ir(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&o.push(new ir(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(r=Fn(e[1]),"string"!==r&&o.push(new ir(`${i}[1]`,e[1],`string expected, ${r} found`)));for(let s=2;s{t in i&&e.push(new ir(n,i[t],`"${t}" is prohibited for ref layers`))})),r.layers.forEach((e=>{ie(e.id)===a&&(t=e)})),t?t.ref?e.push(new ir(n,i.ref,"ref cannot reference another ref layer")):s=ie(t.type):"string"==typeof a&&e.push(new ir(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s&&"sky"!==s)if(i.source){const t=r.sources&&r.sources[i.source],o=t&&ie(t.type);t?"vector"===o&&"raster"===s?e.push(new ir(n,i.source,`layer "${i.id}" requires a raster source`)):"raster"===o&&"raster"!==s?e.push(new ir(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s?e.push(new ir(n,i.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]&&!i.paint["line-trim-offset"]||"geojson"===o&&t.lineMetrics||e.push(new ir(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new ir(n,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new ir(n,i.source,`source "${i.source}" not found`))}else e.push(new ir(n,i,'missing required property "source"'));return e=e.concat(nr({key:n,value:i,valueSpec:o.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>Br({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:t.style,styleSpec:t.styleSpec,object:i,objectKey:"type"}),filter:t=>Ar(ee({layerType:s},t)),layout:t=>nr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Tr(ee({layerType:s},t))}}),paint:t=>nr({layer:i,key:t.key,value:t.value,valueSpec:{},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":t=>Mr(ee({layerType:s},t))}})}})),e}function Cr(t){const e=t.value,i=t.key,n=Fn(e);return"string"!==n?[new ir(i,e,`string expected, ${n} found`)]:[]}const Pr={promoteId:function({key:t,value:e}){if("string"===Fn(e))return Cr({key:t,value:e});{const i=[];for(const n in e)i.push(...Cr({key:`${t}.${n}`,value:e[n]}));return i}}};function Lr(t){const e=t.value,i=t.key,n=t.styleSpec,r=t.style;if(!e.type)return[new ir(i,e,'"type" is required')];const o=ie(e.type);let s;switch(o){case"vector":case"raster":case"raster-dem":return s=nr({key:i,value:e,valueSpec:n[`source_${o.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Pr}),s;case"geojson":if(s=nr({key:i,value:e,valueSpec:n.source_geojson,style:r,styleSpec:n,objectElementValidators:Pr}),e.cluster)for(const t in e.clusterProperties){const[n,r]=e.clusterProperties[t],o="string"==typeof n?[n,["accumulated"],["get",t]]:n;s.push(...ar({key:`${i}.${t}.map`,value:r,expressionContext:"cluster-map"})),s.push(...ar({key:`${i}.${t}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return s;case"video":return nr({key:i,value:e,valueSpec:n.source_video,style:r,styleSpec:n});case"image":return nr({key:i,value:e,valueSpec:n.source_image,style:r,styleSpec:n});case"canvas":return[new ir(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return cr({key:`${i}.type`,value:e.type,valueSpec:{values:Dr(n)},style:r,styleSpec:n})}}function Dr(t){return t.source.reduce(((e,i)=>{const n=t[i];return"enum"===n.type.type&&(e=e.concat(Object.keys(n.type.values))),e}),[])}function Rr(t){const e=t.value,i=t.styleSpec,n=i.light,r=t.style;let o=[];const s=Fn(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new ir("light",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&n[s[1]]&&n[s[1]].transition?Br({key:t,value:e[t],valueSpec:i.transition,style:r,styleSpec:i}):n[t]?Br({key:t,value:e[t],valueSpec:n[t],style:r,styleSpec:i}):[new ir(t,e[t],`unknown property "${t}"`)])}return o}function Or(t){const e=t.value,i=t.key,n=t.style,r=t.styleSpec,o=r.terrain;let s=[];const a=Fn(e);if(void 0===e)return s;if("object"!==a)return s=s.concat([new ir("terrain",e,`object expected, ${a} found`)]),s;for(const t in e){const i=t.match(/^(.*)-transition$/);s=s.concat(i&&o[i[1]]&&o[i[1]].transition?Br({key:t,value:e[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?Br({key:t,value:e[t],valueSpec:o[t],style:n,styleSpec:r}):[new ir(t,e[t],`unknown property "${t}"`)])}if(e.source){const t=n.sources&&n.sources[e.source],r=t&&ie(t.type);t?"raster-dem"!==r&&s.push(new ir(i,e.source,`terrain cannot be used with a source of type ${String(r)}, it only be used with a "raster-dem" source type`)):s.push(new ir(i,e.source,`source "${e.source}" not found`))}else s.push(new ir(i,e,'terrain is missing required property "source"'));return s}function kr(t){const e=t.value,i=t.style,n=t.styleSpec,r=n.fog;let o=[];const s=Fn(e);if(void 0===e)return o;if("object"!==s)return o=o.concat([new ir("fog",e,`object expected, ${s} found`)]),o;for(const t in e){const s=t.match(/^(.*)-transition$/);o=o.concat(s&&r[s[1]]&&r[s[1]].transition?Br({key:t,value:e[t],valueSpec:n.transition,style:i,styleSpec:n}):r[t]?Br({key:t,value:e[t],valueSpec:r[t],style:i,styleSpec:n}):[new ir(t,e[t],`unknown property "${t}"`)])}return o}const Nr={"*":()=>[],array:rr,boolean:function(t){const e=t.value,i=t.key,n=Fn(e);return"boolean"!==n?[new ir(i,e,`boolean expected, ${n} found`)]:[]},number:or,color:function(t){const e=t.key,i=t.value,n=Fn(i);return"string"!==n?[new ir(e,i,`color expected, ${n} found`)]:null===Ee(i)?[new ir(e,i,`color expected, "${i}" found`)]:[]},enum:cr,filter:Ar,function:sr,layer:Ir,object:nr,source:Lr,light:Rr,terrain:Or,fog:kr,string:Cr,formatted:function(t){return 0===Cr(t).length?[]:ar(t)},resolvedImage:function(t){return 0===Cr(t).length?[]:ar(t)},projection:function(t){const e=t.value,i=t.styleSpec,n=i.projection,r=t.style;let o=[];const s=Fn(e);if("object"===s)for(const t in e)o=o.concat(Br({key:t,value:e[t],valueSpec:n[t],style:r,styleSpec:i}));else"string"!==s&&(o=o.concat([new ir("projection",e,`object or string expected, ${s} found`)]));return o}};function Br(t){const e=t.value,i=t.valueSpec,n=t.styleSpec;return i.expression&&Vn(ie(e))?sr(t):i.expression&&Yn(ne(e))?ar(t):i.type&&Nr[i.type]?Nr[i.type](t):nr(ee({},t,{valueSpec:i.type?n[i.type]:i}))}function zr(t){const e=t.value,i=t.key,n=Cr(t);return n.length||(-1===e.indexOf("{fontstack}")&&n.push(new ir(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&n.push(new ir(i,e,'"glyphs" url must include a "{range}" token'))),n}function Fr(t,e=te){return Gr(Br({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,objectElementValidators:{glyphs:zr,"*":()=>[]}}))}const Vr=t=>Gr(Mr(t)),Ur=t=>Gr(Tr(t));function Gr(t){return t.slice().sort(((t,e)=>t.line&&e.line?t.line-e.line:0))}function jr(t,e){let i=!1;if(e&&e.length)for(const n of e)t.fire(new Kt(new Error(n.message))),i=!0;return i}var Hr=qr,Wr=3;function qr(t,e,i){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var r=new Int32Array(this.arrayBuffer);t=r[0],this.d=(e=r[1])+2*(i=r[2]);for(var o=0;o=u[d+0]&&n>=u[d+1])?(s[p]=!0,o.push(c[p])):s[p]=!1}}},qr.prototype._forEachCell=function(t,e,i,n,r,o,s,a){for(var l=this._convertToCellCoord(t),c=this._convertToCellCoord(e),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n),p=l;p<=u;p++)for(var d=c;d<=h;d++){var f=this.d*d+p;if((!a||a(this._convertFromCellCoord(p),this._convertFromCellCoord(d),this._convertFromCellCoord(p+1),this._convertFromCellCoord(d+1)))&&r.call(this,t,e,i,n,f,o,s,a))return}},qr.prototype._convertFromCellCoord=function(t){return(t-this.padding)/this.scale},qr.prototype._convertToCellCoord=function(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))},qr.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,e=Wr+this.cells.length+1+1,i=0,n=0;n=0||(r[e]=Kr(t[e],i)));t instanceof Error&&(r.message=t.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof t)}function $r(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||Qr(t)||Jr(t)||ArrayBuffer.isView(t)||t instanceof e.ImageData)return t;if(Array.isArray(t))return t.map($r);if("object"==typeof t){const e=t.$name||"Object",{klass:i}=Zr[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const e of Object.keys(t))"$name"!==e&&(n[e]=$r(t[e]));return n}throw new Error("can't deserialize object of type "+typeof t)}const to={"Latin-1 Supplement":t=>t>=128&&t<=255,Arabic:t=>t>=1536&&t<=1791,"Arabic Supplement":t=>t>=1872&&t<=1919,"Arabic Extended-A":t=>t>=2208&&t<=2303,"Hangul Jamo":t=>t>=4352&&t<=4607,"Unified Canadian Aboriginal Syllabics":t=>t>=5120&&t<=5759,Khmer:t=>t>=6016&&t<=6143,"Unified Canadian Aboriginal Syllabics Extended":t=>t>=6320&&t<=6399,"General Punctuation":t=>t>=8192&&t<=8303,"Letterlike Symbols":t=>t>=8448&&t<=8527,"Number Forms":t=>t>=8528&&t<=8591,"Miscellaneous Technical":t=>t>=8960&&t<=9215,"Control Pictures":t=>t>=9216&&t<=9279,"Optical Character Recognition":t=>t>=9280&&t<=9311,"Enclosed Alphanumerics":t=>t>=9312&&t<=9471,"Geometric Shapes":t=>t>=9632&&t<=9727,"Miscellaneous Symbols":t=>t>=9728&&t<=9983,"Miscellaneous Symbols and Arrows":t=>t>=11008&&t<=11263,"CJK Radicals Supplement":t=>t>=11904&&t<=12031,"Kangxi Radicals":t=>t>=12032&&t<=12255,"Ideographic Description Characters":t=>t>=12272&&t<=12287,"CJK Symbols and Punctuation":t=>t>=12288&&t<=12351,Hiragana:t=>t>=12352&&t<=12447,Katakana:t=>t>=12448&&t<=12543,Bopomofo:t=>t>=12544&&t<=12591,"Hangul Compatibility Jamo":t=>t>=12592&&t<=12687,Kanbun:t=>t>=12688&&t<=12703,"Bopomofo Extended":t=>t>=12704&&t<=12735,"CJK Strokes":t=>t>=12736&&t<=12783,"Katakana Phonetic Extensions":t=>t>=12784&&t<=12799,"Enclosed CJK Letters and Months":t=>t>=12800&&t<=13055,"CJK Compatibility":t=>t>=13056&&t<=13311,"CJK Unified Ideographs Extension A":t=>t>=13312&&t<=19903,"Yijing Hexagram Symbols":t=>t>=19904&&t<=19967,"CJK Unified Ideographs":t=>t>=19968&&t<=40959,"Yi Syllables":t=>t>=40960&&t<=42127,"Yi Radicals":t=>t>=42128&&t<=42191,"Hangul Jamo Extended-A":t=>t>=43360&&t<=43391,"Hangul Syllables":t=>t>=44032&&t<=55215,"Hangul Jamo Extended-B":t=>t>=55216&&t<=55295,"Private Use Area":t=>t>=57344&&t<=63743,"CJK Compatibility Ideographs":t=>t>=63744&&t<=64255,"Arabic Presentation Forms-A":t=>t>=64336&&t<=65023,"Vertical Forms":t=>t>=65040&&t<=65055,"CJK Compatibility Forms":t=>t>=65072&&t<=65103,"Small Form Variants":t=>t>=65104&&t<=65135,"Arabic Presentation Forms-B":t=>t>=65136&&t<=65279,"Halfwidth and Fullwidth Forms":t=>t>=65280&&t<=65519};function eo(t){for(const e of t)if(ro(e.charCodeAt(0)))return!0;return!1}function io(t){for(const e of t)if(!no(e.charCodeAt(0)))return!1;return!0}function no(t){return!(to.Arabic(t)||to["Arabic Supplement"](t)||to["Arabic Extended-A"](t)||to["Arabic Presentation Forms-A"](t)||to["Arabic Presentation Forms-B"](t))}function ro(t){return!(746!==t&&747!==t&&(t<4352||!(to["Bopomofo Extended"](t)||to.Bopomofo(t)||to["CJK Compatibility Forms"](t)&&!(t>=65097&&t<=65103)||to["CJK Compatibility Ideographs"](t)||to["CJK Compatibility"](t)||to["CJK Radicals Supplement"](t)||to["CJK Strokes"](t)||!(!to["CJK Symbols and Punctuation"](t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||to["CJK Unified Ideographs Extension A"](t)||to["CJK Unified Ideographs"](t)||to["Enclosed CJK Letters and Months"](t)||to["Hangul Compatibility Jamo"](t)||to["Hangul Jamo Extended-A"](t)||to["Hangul Jamo Extended-B"](t)||to["Hangul Jamo"](t)||to["Hangul Syllables"](t)||to.Hiragana(t)||to["Ideographic Description Characters"](t)||to.Kanbun(t)||to["Kangxi Radicals"](t)||to["Katakana Phonetic Extensions"](t)||to.Katakana(t)&&12540!==t||!(!to["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)||!(!to["Small Form Variants"](t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||to["Unified Canadian Aboriginal Syllabics"](t)||to["Unified Canadian Aboriginal Syllabics Extended"](t)||to["Vertical Forms"](t)||to["Yijing Hexagram Symbols"](t)||to["Yi Syllables"](t)||to["Yi Radicals"](t))))}function oo(t){return!(ro(t)||function(t){return!!(to["Latin-1 Supplement"](t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||to["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)||to["Letterlike Symbols"](t)||to["Number Forms"](t)||to["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)||to["Control Pictures"](t)&&9251!==t||to["Optical Character Recognition"](t)||to["Enclosed Alphanumerics"](t)||to["Geometric Shapes"](t)||to["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||to["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||to["CJK Symbols and Punctuation"](t)||to.Katakana(t)||to["Private Use Area"](t)||to["CJK Compatibility Forms"](t)||to["Small Form Variants"](t)||to["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 so(t){return t>=1424&&t<=2303||to["Arabic Presentation Forms-A"](t)||to["Arabic Presentation Forms-B"](t)}function ao(t,e){return!(!e&&so(t)||t>=2304&&t<=3583||t>=3840&&t<=4255||to.Khmer(t))}function lo(t){for(const e of t)if(so(e.charCodeAt(0)))return!0;return!1}const co="deferred",uo="loading",ho="loaded";let po=null,fo="unavailable",mo=null;const go=function(t){t&&"string"==typeof t&&t.indexOf("NetworkError")>-1&&(fo="error"),po&&po(t)};function yo(){vo.fire(new Jt("pluginStateChange",{pluginStatus:fo,pluginURL:mo}))}const vo=new $t,_o=function(){return fo},xo=function(){if(fo!==co||!mo)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");fo=uo,yo(),mo&&pt({url:mo},(t=>{t?go(t):(fo=ho,yo())}))},bo={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>fo===ho||null!=bo.applyArabicShaping,isLoading:()=>fo===uo,setState(t){fo=t.pluginStatus,mo=t.pluginURL},isParsed:()=>null!=bo.applyArabicShaping&&null!=bo.processBidirectionalText&&null!=bo.processStyledBidirectionalText,getPluginURL:()=>mo};class wo{constructor(t,e){this.zoom=t,e?(this.now=e.now,this.fadeDuration=e.fadeDuration,this.transition=e.transition,this.pitch=e.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(t){return function(t,e){for(const i of t)if(!ao(i.charCodeAt(0),e))return!1;return!0}(t,bo.isLoaded())}}class Ao{constructor(t,e){this.property=t,this.value=e,this.expression=function(t,e){if(Vn(t))return new tr(t,e);if(Yn(t)){const i=$n(t,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return i.value}{let i=t;return"string"==typeof t&&"color"===e.type&&(i=Le.parse(t)),{kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Eo{constructor(t){this.property=t,this.value=new Ao(t,void 0)}transitioned(t,e){return new Mo(this.property,this.value,e,D({},t.transition,this.transition),t.now)}untransitioned(){return new Mo(this.property,this.value,null,{},0)}}class So{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return G(this._values[t].value.value)}setValue(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Eo(this._values[t].property)),this._values[t].value=new Ao(this._values[t].property,null===e?void 0:G(e))}getTransition(t){return G(this._values[t].transition)}setTransition(t,e){this._values.hasOwnProperty(t)||(this._values[t]=new Eo(this._values[t].property)),this._values[t].transition=G(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}-transition`]=n)}return t}transitioned(t,e){const i=new To(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new To(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Mo{constructor(t,e,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=t,this.value=e,this.begin=r+o,this.end=this.begin+s,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,r=this.value.possiblyEvaluate(t,e,i),o=this.prior;if(o){if(n>this.end)return this.prior=null,r;if(this.value.isDataDriven())return this.prior=null,r;if(nthis.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Fo(t,e=1){let i=0,n=0;return{members:t.map((t=>{const r=No[t.type].BYTES_PER_ELEMENT,o=i=Vo(i,Math.max(e,r)),s=t.components||1;return n=Math.max(n,r),i+=r*s,{name:t.name,type:t.type,components:s,offset:o}})),size:Vo(i,Math.max(n,e)),alignment:e}}function Vo(t,e){return Math.ceil(t/e)*e}class Uo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}Uo.prototype.bytesPerElement=4,Yr(Uo,"StructArrayLayout2i4");class Go extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,t}}Go.prototype.bytesPerElement=6,Yr(Go,"StructArrayLayout3i6");class jo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.int16[o+0]=e,this.int16[o+1]=i,this.int16[o+2]=n,this.int16[o+3]=r,t}}jo.prototype.bytesPerElement=8,Yr(jo,"StructArrayLayout4i8");class Ho extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=6*t,c=12*t,u=3*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,t}}Ho.prototype.bytesPerElement=12,Yr(Ho,"StructArrayLayout2i4ub1f12");class Wo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.float32[o+3]=r,t}}Wo.prototype.bytesPerElement=16,Yr(Wo,"StructArrayLayout4f16");class qo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=6*t,a=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,t}}qo.prototype.bytesPerElement=12,Yr(qo,"StructArrayLayout4ui1f12");class Xo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=4*t;return this.uint16[o+0]=e,this.uint16[o+1]=i,this.uint16[o+2]=n,this.uint16[o+3]=r,t}}Xo.prototype.bytesPerElement=8,Yr(Xo,"StructArrayLayout4ui8");class Zo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=r,this.int16[a+4]=o,this.int16[a+5]=s,t}}Zo.prototype.bytesPerElement=12,Yr(Zo,"StructArrayLayout6i12");class Yo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,u,h){const p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,n,r,o,s,a,l,c,u,h)}emplace(t,e,i,n,r,o,s,a,l,c,u,h,p){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=n,this.int16[d+3]=r,this.uint16[d+4]=o,this.uint16[d+5]=s,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=c,this.int16[d+9]=u,this.int16[d+10]=h,this.int16[d+11]=p,t}}Yo.prototype.bytesPerElement=24,Yr(Yo,"StructArrayLayout4i4ui4i24");class Qo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n,r,o)}emplace(t,e,i,n,r,o,s){const a=10*t,l=5*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,t}}Qo.prototype.bytesPerElement=20,Yr(Qo,"StructArrayLayout3i3f20");class Jo extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}Jo.prototype.bytesPerElement=4,Yr(Jo,"StructArrayLayout1ul4");class Ko extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,u,h,p){const d=this.length;return this.resize(d+1),this.emplace(d,t,e,i,n,r,o,s,a,l,c,u,h,p)}emplace(t,e,i,n,r,o,s,a,l,c,u,h,p,d){const f=20*t,m=10*t;return this.int16[f+0]=e,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=p,this.uint16[f+19]=d,t}}Ko.prototype.bytesPerElement=40,Yr(Ko,"StructArrayLayout5i4f1i1ul2ui40");class $o extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,t,e,i,n,r,o,s)}emplace(t,e,i,n,r,o,s,a){const l=8*t;return this.int16[l+0]=e,this.int16[l+1]=i,this.int16[l+2]=n,this.int16[l+4]=r,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,t}}$o.prototype.bytesPerElement=16,Yr($o,"StructArrayLayout3i2i2i16");class ts extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=4*t,a=8*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,t}}ts.prototype.bytesPerElement=16,Yr(ts,"StructArrayLayout2f1f2i16");class es extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=12*t,s=3*t;return this.uint8[o+0]=e,this.uint8[o+1]=i,this.float32[s+1]=n,this.float32[s+2]=r,t}}es.prototype.bytesPerElement=12,Yr(es,"StructArrayLayout2ub2f12");class is extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,t}}is.prototype.bytesPerElement=12,Yr(is,"StructArrayLayout3f12");class ns extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const r=3*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,this.uint16[r+2]=n,t}}ns.prototype.bytesPerElement=6,Yr(ns,"StructArrayLayout3ui6");class rs extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x){const b=this.length;return this.resize(b+1),this.emplace(b,t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x)}emplace(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x,b){const w=30*t,A=15*t,E=60*t;return this.int16[w+0]=e,this.int16[w+1]=i,this.int16[w+2]=n,this.float32[A+2]=r,this.float32[A+3]=o,this.uint16[w+8]=s,this.uint16[w+9]=a,this.uint32[A+5]=l,this.uint32[A+6]=c,this.uint32[A+7]=u,this.uint16[w+16]=h,this.uint16[w+17]=p,this.uint16[w+18]=d,this.float32[A+10]=f,this.float32[A+11]=m,this.uint8[E+48]=g,this.uint8[E+49]=y,this.uint8[E+50]=v,this.uint32[A+13]=_,this.int16[w+28]=x,this.uint8[E+58]=b,t}}rs.prototype.bytesPerElement=60,Yr(rs,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class os extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x,b,w,A,E,S,M,T,I,C){const P=this.length;return this.resize(P+1),this.emplace(P,t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x,b,w,A,E,S,M,T,I,C)}emplace(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x,b,w,A,E,S,M,T,I,C,P){const L=38*t,D=19*t;return this.int16[L+0]=e,this.int16[L+1]=i,this.int16[L+2]=n,this.float32[D+2]=r,this.float32[D+3]=o,this.int16[L+8]=s,this.int16[L+9]=a,this.int16[L+10]=l,this.int16[L+11]=c,this.int16[L+12]=u,this.int16[L+13]=h,this.uint16[L+14]=p,this.uint16[L+15]=d,this.uint16[L+16]=f,this.uint16[L+17]=m,this.uint16[L+18]=g,this.uint16[L+19]=y,this.uint16[L+20]=v,this.uint16[L+21]=_,this.uint16[L+22]=x,this.uint16[L+23]=b,this.uint16[L+24]=w,this.uint16[L+25]=A,this.uint16[L+26]=E,this.uint16[L+27]=S,this.uint16[L+28]=M,this.uint32[D+15]=T,this.float32[D+16]=I,this.float32[D+17]=C,this.float32[D+18]=P,t}}os.prototype.bytesPerElement=76,Yr(os,"StructArrayLayout3i2f6i15ui1ul3f76");class ss extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}ss.prototype.bytesPerElement=4,Yr(ss,"StructArrayLayout1f4");class as extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,r)}emplace(t,e,i,n,r,o){const s=5*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,this.float32[s+3]=r,this.float32[s+4]=o,t}}as.prototype.bytesPerElement=20,Yr(as,"StructArrayLayout5f20");class ls extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n)}emplace(t,e,i,n,r){const o=6*t;return this.uint32[3*t+0]=e,this.uint16[o+2]=i,this.uint16[o+3]=n,this.uint16[o+4]=r,t}}ls.prototype.bytesPerElement=12,Yr(ls,"StructArrayLayout1ul3ui12");class cs extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}cs.prototype.bytesPerElement=4,Yr(cs,"StructArrayLayout2ui4");class us extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}us.prototype.bytesPerElement=2,Yr(us,"StructArrayLayout1ui2");class hs extends zo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}hs.prototype.bytesPerElement=8,Yr(hs,"StructArrayLayout2f8");class ps extends Bo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}ps.prototype.size=40;class ds extends Ko{get(t){return new ps(this,t)}}Yr(ds,"CollisionBoxArray");class fs extends Bo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}fs.prototype.size=60;class ms extends rs{get(t){return new fs(this,t)}}Yr(ms,"PlacedSymbolArray");class gs extends Bo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}gs.prototype.size=76;class ys extends os{get(t){return new gs(this,t)}}Yr(ys,"SymbolInstanceArray");class vs extends ss{getoffsetX(t){return this.float32[1*t+0]}}Yr(vs,"GlyphOffsetArray");class _s extends Uo{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}Yr(_s,"SymbolLineVertexArray");class xs extends Bo{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}xs.prototype.size=12;class bs extends ls{get(t){return new xs(this,t)}}Yr(bs,"FeatureIndexArray");class ws extends cs{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}Yr(ws,"FillExtrusionCentroidArray");const As=Fo([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Es=Fo([{name:"a_dash",components:4,type:"Uint16"}]);var Ss={exports:{}},Ms={exports:{}};Ms.exports=function(t,e){var i,n,r,o,s,a,l,c;for(n=t.length-(i=3&t.length),r=e,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&t.charCodeAt(c+2))<<16;case 2:l^=(255&t.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&t.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=t.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0};var Ts=Ms.exports,Is={exports:{}};Is.exports=function(t,e){for(var i,n=t.length,r=e^n,o=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(o)|(255&t.charCodeAt(++o))<<8|(255&t.charCodeAt(++o))<<16|(255&t.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&t.charCodeAt(o+2))<<16;case 2:r^=(255&t.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&t.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0};var Cs=Ts,Ps=Is.exports;Ss.exports=Cs,Ss.exports.murmur3=Cs,Ss.exports.murmur2=Ps;var Ls=p(Ss.exports);class Ds{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(Rs(t)),this.positions.push(e,i,n)}getPositions(t){const e=Rs(t);let i=0,n=this.ids.length-1;for(;i>1;this.ids[t]>=e?n=t:i=t+1}const r=[];for(;this.ids[i]===e;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return Os(i,n,0,i.length-1),e&&e.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(t){const e=new Ds;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function Rs(t){const e=+t;return!isNaN(e)&&Number.MIN_SAFE_INTEGER<=e&&e<=Number.MAX_SAFE_INTEGER?e:Ls(String(t))}function Os(t,e,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(t[o]r);if(o>=s)break;ks(t,o,s),ks(e,3*o,3*s),ks(e,3*o+1,3*s+1),ks(e,3*o+2,3*s+2)}s-i`u_${t}`)),this.type=i}setUniform(t,e,i,n,r){e.set(t,r,n.constantOr(this.value))}getBinding(t,e){return"color"===this.type?new Fs(t):new Bs(t)}}class Ws{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,e,i,n,r){const o="u_pattern"===r||"u_dash"===r?this.pattern:"u_pixel_ratio"===r?this.pixelRatio:null;o&&e.set(t,r,o)}getBinding(t,e){return"u_pattern"===e||"u_dash"===e?new zs(t):new Bs(t)}}class qs{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i,n,r,o){const s=this.paintVertexArray.length,a=this.expression.evaluate(new wo(0),e,{},r,n,o);this.paintVertexArray.resize(t),this._setPaintValue(s,t,a)}updatePaintArray(t,e,i,n,r){const o=this.expression.evaluate({zoom:0},i,n,void 0,r);this._setPaintValue(t,e,o)}_setPaintValue(t,e,i){if("color"===this.type){const n=js(i);for(let i=t;i`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.zoom=r,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new o}populatePaintArray(t,e,i,n,r,o){const s=this.expression.evaluate(new wo(this.zoom),e,{},r,n,o),a=this.expression.evaluate(new wo(this.zoom+1),e,{},r,n,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(l,t,s,a)}updatePaintArray(t,e,i,n,r){const o=this.expression.evaluate({zoom:this.zoom},i,n,void 0,r),s=this.expression.evaluate({zoom:this.zoom+1},i,n,void 0,r);this._setPaintValue(t,e,o,s)}_setPaintValue(t,e,i,n){if("color"===this.type){const r=js(i),o=js(n);for(let i=t;i!0)){this.binders={},this._buffers=[];const n=[];for(const r in t.paint._values){if(!i(r))continue;const o=t.paint.get(r);if(!(o instanceof Co&&Nn(o.property.specification)))continue;const s=Ks(r,t.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===r||r.endsWith("pattern"),h="line-dasharray"===r&&"constant"!==t.layout.get("line-cap").value.kind;if("constant"!==a.kind||h)if("source"===a.kind||h||u){const e=ea(r,l,"source");this.binders[r]=u?new Zs(a,s,l,e,t.id):new qs(a,s,l,e),n.push(`/a_${r}`)}else{const t=ea(r,l,"composite");this.binders[r]=new Xs(a,s,l,c,e,t),n.push(`/z_${r}`)}else this.binders[r]=u?new Ws(a.value,s):new Hs(a.value,s,l),n.push(`/u_${r}`)}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof qs||e instanceof Xs?e.maxValue:0}populatePaintArrays(t,e,i,n,r,o){for(const s in this.binders){const a=this.binders[s];(a instanceof qs||a instanceof Xs||a instanceof Zs)&&a.populatePaintArray(t,e,i,n,r,o)}}setConstantPatternPositions(t){for(const e in this.binders){const i=this.binders[e];i instanceof Ws&&i.setConstantPatternPositions(t)}}updatePaintArrays(t,e,i,n,r,o){let s=!1;for(const a in t){const l=e.getPositions(a);for(const e of l){const l=i.feature(e.index);for(const i in this.binders){const c=this.binders[i];if((c instanceof qs||c instanceof Xs||c instanceof Zs)&&!0===c.expression.isStateDependent){const u=n.paint.get(i);c.expression=u.value,c.updatePaintArray(e.start,e.end,l,t[a],r,o),s=!0}}}}return s}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Hs||i instanceof Ws)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof qs||i instanceof Xs||i instanceof Zs)for(let e=0;e!0)){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new Ys(n,e,i);this.needsUpload=!1,this._featureMap=new Ds,this._bufferOffset=0}populatePaintArrays(t,e,i,n,r,o,s){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n,r,o,s);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n,r){for(const o of i)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(t,this._featureMap,e,o,n,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const Js={"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","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function Ks(t,e){return Js[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}const $s={"line-pattern":{source:qo,composite:qo},"fill-pattern":{source:qo,composite:qo},"fill-extrusion-pattern":{source:qo,composite:qo},"line-dasharray":{source:Xo,composite:Xo}},ta={color:{source:hs,composite:Wo},number:{source:ss,composite:hs}};function ea(t,e,i){const n=$s[t];return n&&n[i]||ta[e][i]}Yr(Hs,"ConstantBinder"),Yr(Ws,"PatternConstantBinder"),Yr(qs,"SourceExpressionBinder"),Yr(Zs,"PatternCompositeBinder"),Yr(Xs,"CompositeExpressionBinder"),Yr(Ys,"ProgramConfiguration",{omit:["_buffers"]}),Yr(Qs,"ProgramConfigurationSet");const ia="-transition";class na extends $t{constructor(t,e){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&"sky"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),e.layout&&(this._unevaluatedLayout=new Io(e.layout)),e.paint)){this._transitionablePaint=new So(e.paint);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Po(e.paint)}}getLayoutProperty(t){return"visibility"===t?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,e,i={}){null!=e&&this._validate(Ur,`layers.${this.id}.layout.${t}`,t,e,i)||("visibility"!==t?this._unevaluatedLayout.setValue(t,e):this.visibility=e)}getPaintProperty(t){return F(t,ia)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if(null!=e&&this._validate(Vr,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(F(t,ia))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const i=this._transitionablePaint._values[t],n=i.value.isDataDriven(),r=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value,s=o.isDataDriven(),a=F(t,"pattern")||"line-dasharray"===t;return s||n||a||this._handleOverridablePaintPropertyUpdate(t,r,o)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t){return!!(this.minzoom&&t=this.maxzoom)||"none"===this.visibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,e){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){const 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),U(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,n,r={}){return(!r||!1!==r.validate)&&jr(this,t.call(Fr,{key:e,layerType:this.type,objectKey:i,value:n,styleSpec:te,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Co&&Nn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=hr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ra=Fo([{name:"a_pos",components:2,type:"Int16"}],4),oa=Fo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class sa{constructor(t=[]){this.segments=t}prepareSegment(t,e,i,n){let r=this.segments[this.segments.length-1];return t>sa.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${sa.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!r||r.vertexLength+t>sa.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:e.length,primitiveOffset:i.length,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new sa([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}sa.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Yr(sa,"SegmentVector");var aa=8192;class la{constructor(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]))}setNorthEast(t){return this._ne=t instanceof Gl?new Gl(t.lng,t.lat):Gl.convert(t),this}setSouthWest(t){return this._sw=t instanceof Gl?new Gl(t.lng,t.lat):Gl.convert(t),this}extend(t){const e=this._sw,i=this._ne;let n,r;if(t instanceof Gl)n=t,r=t;else{if(!(t instanceof la))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(la.convert(t)):this.extend(Gl.convert(t)):"object"==typeof t&&null!==t&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(Gl.convert(t)):this;if(n=t._sw,r=t._ne,!n||!r)return this}return e||i?(e.lng=Math.min(n.lng,e.lng),e.lat=Math.min(n.lat,e.lat),i.lng=Math.max(r.lng,i.lng),i.lat=Math.max(r.lat,i.lat)):(this._sw=new Gl(n.lng,n.lat),this._ne=new Gl(r.lng,r.lat)),this}getCenter(){return new Gl((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Gl(this.getWest(),this.getNorth())}getSouthEast(){return new Gl(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:e,lat:i}=Gl.convert(t);let n=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&n}static convert(t){return!t||t instanceof la?t:new la(t)}}var ca=1e-6,ua="undefined"!=typeof Float32Array?Float32Array:Array;function ha(){var t=new ua(9);return ua!=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}function pa(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=i[0],d=i[1],f=i[2],m=i[3],g=i[4],y=i[5],v=i[6],_=i[7],x=i[8];return t[0]=p*n+d*s+f*c,t[1]=p*r+d*a+f*u,t[2]=p*o+d*l+f*h,t[3]=m*n+g*s+y*c,t[4]=m*r+g*a+y*u,t[5]=m*o+g*l+y*h,t[6]=v*n+_*s+x*c,t[7]=v*r+_*a+x*u,t[8]=v*o+_*l+x*h,t}function da(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 fa(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],d=e[11],f=e[12],m=e[13],g=e[14],y=e[15],v=i*a-n*s,_=i*l-r*s,x=i*c-o*s,b=n*l-r*a,w=n*c-o*a,A=r*c-o*l,E=u*m-h*f,S=u*g-p*f,M=u*y-d*f,T=h*g-p*m,I=h*y-d*m,C=p*y-d*g,P=v*C-_*I+x*T+b*M-w*S+A*E;return P?(t[0]=(a*C-l*I+c*T)*(P=1/P),t[1]=(r*I-n*C-o*T)*P,t[2]=(m*A-g*w+y*b)*P,t[3]=(p*w-h*A-d*b)*P,t[4]=(l*M-s*C-c*S)*P,t[5]=(i*C-r*M+o*S)*P,t[6]=(g*x-f*A-y*_)*P,t[7]=(u*A-p*x+d*_)*P,t[8]=(s*I-a*M+c*E)*P,t[9]=(n*M-i*I-o*E)*P,t[10]=(f*w-m*x+y*v)*P,t[11]=(h*x-u*w-d*v)*P,t[12]=(a*S-s*T-l*E)*P,t[13]=(i*T-n*S+r*E)*P,t[14]=(m*_-f*b-g*v)*P,t[15]=(u*b-h*_+p*v)*P,t):null}function ma(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],f=e[11],m=e[12],g=e[13],y=e[14],v=e[15],_=i[0],x=i[1],b=i[2],w=i[3];return t[0]=_*n+x*a+b*h+w*m,t[1]=_*r+x*l+b*p+w*g,t[2]=_*o+x*c+b*d+w*y,t[3]=_*s+x*u+b*f+w*v,t[4]=(_=i[4])*n+(x=i[5])*a+(b=i[6])*h+(w=i[7])*m,t[5]=_*r+x*l+b*p+w*g,t[6]=_*o+x*c+b*d+w*y,t[7]=_*s+x*u+b*f+w*v,t[8]=(_=i[8])*n+(x=i[9])*a+(b=i[10])*h+(w=i[11])*m,t[9]=_*r+x*l+b*p+w*g,t[10]=_*o+x*c+b*d+w*y,t[11]=_*s+x*u+b*f+w*v,t[12]=(_=i[12])*n+(x=i[13])*a+(b=i[14])*h+(w=i[15])*m,t[13]=_*r+x*l+b*p+w*g,t[14]=_*o+x*c+b*d+w*y,t[15]=_*s+x*u+b*f+w*v,t}function ga(t,e,i){var n,r,o,s,a,l,c,u,h,p,d,f,m=i[0],g=i[1],y=i[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]):(r=e[1],o=e[2],s=e[3],a=e[4],l=e[5],c=e[6],u=e[7],h=e[8],p=e[9],d=e[10],f=e[11],t[0]=n=e[0],t[1]=r,t[2]=o,t[3]=s,t[4]=a,t[5]=l,t[6]=c,t[7]=u,t[8]=h,t[9]=p,t[10]=d,t[11]=f,t[12]=n*m+a*g+h*y+e[12],t[13]=r*m+l*g+p*y+e[13],t[14]=o*m+c*g+d*y+e[14],t[15]=s*m+u*g+f*y+e[15]),t}function ya(t,e,i){var n=i[0],r=i[1],o=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,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}function va(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=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*r+c*n,t[5]=s*r+u*n,t[6]=a*r+h*n,t[7]=l*r+p*n,t[8]=c*r-o*n,t[9]=u*r-s*n,t[10]=h*r-a*n,t[11]=p*r-l*n,t}function _a(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[8],u=e[9],h=e[10],p=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*r-c*n,t[1]=s*r-u*n,t[2]=a*r-h*n,t[3]=l*r-p*n,t[8]=o*n+c*r,t[9]=s*n+u*r,t[10]=a*n+h*r,t[11]=l*n+p*r,t}function xa(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function ba(t,e,i){var n,r,o,s=i[0],a=i[1],l=i[2],c=Math.hypot(s,a,l);return c0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function ka(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Na(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[0],a=i[1],l=i[2];return t[0]=r*l-o*a,t[1]=o*s-n*l,t[2]=n*a-r*s,t}function Ba(t,e,i){var n=e[0],r=e[1],o=e[2],s=i[3]*n+i[7]*r+i[11]*o+i[15];return t[0]=(i[0]*n+i[4]*r+i[8]*o+i[12])/(s=s||1),t[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,t[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,t}function za(t,e,i){var n=i[0],r=i[1],o=i[2],s=e[0],a=e[1],l=e[2],c=r*l-o*a,u=o*s-n*l,h=n*a-r*s,p=r*h-o*u,d=o*c-n*h,f=n*u-r*c,m=2*i[3];return u*=m,h*=m,d*=2,f*=2,t[0]=s+(c*=m)+(p*=2),t[1]=a+u+d,t[2]=l+h+f,t}var Fa,Va=Ia,Ua=Ca,Ga=Sa;function ja(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Ha(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),t[0]=i*s,t[1]=n*s,t[2]=r*s,t[3]=o*s,t}function Wa(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3];return t[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,t[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,t[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,t[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,t}function qa(){var t=new ua(4);return ua!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Xa(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function Za(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l+s*a,t[1]=r*l+o*a,t[2]=o*l-r*a,t[3]=s*l-n*a,t}function Ya(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l-o*a,t[1]=r*l+s*a,t[2]=o*l+n*a,t[3]=s*l-r*a,t}Aa(),Fa=new ua(4),ua!=Float32Array&&(Fa[0]=0,Fa[1]=0,Fa[2]=0,Fa[3]=0);var Qa=Ha;Aa(),Ma(1,0,0),Ma(0,1,0),qa(),qa(),ha();const Ja=Fo([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:Ka}=Ja,$a=Fo([{name:"a_pos_3",components:3,type:"Int16"}]);var tl=Fo([{name:"a_pos",type:"Int16",components:2}]);class el{constructor(t,e){this.pos=t,this.dir=e}intersectsPlane(t,e,i){const n=ka(e,this.dir);if(Math.abs(n)<1e-6)return!1;const r=((t[0]-this.pos[0])*e[0]+(t[1]-this.pos[1])*e[1]+(t[2]-this.pos[2])*e[2])/n;return i[0]=this.pos[0]+this.dir[0]*r,i[1]=this.pos[1]+this.dir[1]*r,i[2]=this.pos[2]+this.dir[2]*r,!0}closestPointOnSphere(t,e,i){if(function(t,e){var i=t[0],n=t[1],r=t[2],o=e[0],s=e[1],a=e[2];return Math.abs(i-o)<=ca*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(n-s)<=ca*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-a)<=ca*Math.max(1,Math.abs(r),Math.abs(a))}(this.pos,t)||0===e)return i[0]=i[1]=i[2]=0,!1;const[n,r,o]=this.dir,s=this.pos[0]-t[0],a=this.pos[1]-t[1],l=this.pos[2]-t[2],c=n*n+r*r+o*o,u=2*(s*n+a*r+l*o),h=u*u-4*c*(s*s+a*a+l*l-e*e);if(h<0){const t=Math.max(-u/2,0),c=s+n*t,h=a+r*t,p=l+o*t,d=Math.hypot(c,h,p);return i[0]=c*e/d,i[1]=h*e/d,i[2]=p*e/d,!1}{const t=(-u-Math.sqrt(h))/(2*c);if(t<0){const t=Math.hypot(s,a,l);return i[0]=s*e/t,i[1]=a*e/t,i[2]=l*e/t,!1}return i[0]=s+n*t,i[1]=a+r*t,i[2]=l+o*t,!0}}}class il{constructor(t,e,i,n,r){this.TL=t,this.TR=e,this.BR=i,this.BL=n,this.horizon=r}static fromInvProjectionMatrix(t,e,i){const n=[-1,1,1],r=[1,1,1],o=[1,-1,1],s=[-1,-1,1],a=Ba(n,n,t),l=Ba(r,r,t),c=Ba(o,o,t),u=Ba(s,s,t);return new il(a,l,c,u,e/i)}}class nl{constructor(t,e){this.points=t,this.planes=e}static fromInvProjectionMatrix(t,e,i,n){const r=Math.pow(2,i),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((i=>{const o=Wa([],i,t),s=1/o[3]/e*r;return function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t}(o,o,[s,s,n?1/o[3]:s,s])})),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map((t=>{const e=Oa([],Na([],Va([],o[t[0]],o[t[1]]),Va([],o[t[2]],o[t[1]]))),i=-ka(e,o[t[1]]);return e.concat(i)}));return new nl(o,s)}}class rl{static fromPoints(t){const e=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const n of t)Pa(e,e,n),La(i,i,n);return new rl(e,i)}static applyTransform(t,e){const i=t.getCorners();for(let t=0;t=0;if(0===o)return 0;o!==e.length&&(i=!1)}if(i)return 2;for(let e=0;e<3;e++){let i=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let r=0;rthis.max[e]-this.min[e])return 0}return 1}}const ol=5,sl=6,al=aa/Math.PI/2,ll=16383,cl=64,ul=[cl,32,16],hl=-al,pl=al,dl=[new rl([hl,hl,hl],[pl,pl,pl]),new rl([hl,hl,hl],[0,0,pl]),new rl([0,hl,hl],[pl,0,pl]),new rl([hl,0,hl],[0,pl,pl]),new rl([0,0,hl],[pl,pl,pl])];function fl(t){return t*al/Fl}function ml(t,e,i,n=!0){const r=Da([],t._camera.position,t.worldSize),o=[e,i,1,1];Wa(o,o,t.pixelMatrixInverse),ja(o,o,1/o[3]);const s=Oa([],Va([],o,r)),a=t.globeMatrix,l=[a[12],a[13],a[14]],c=Va([],l,r),u=Sa(c),h=Oa([],c),p=t.worldSize/(2*Math.PI),d=ka(h,s),f=Math.asin(p/u);if(f1?null:function(t,e,i,n){const r=Math.sin(i);return t*(Math.sin((1-n)*i)/r)+e*(Math.sin(n*i)/r)}(t.a[e],t.b[e],t.angle,T(i,0,1))+t.center[e]}function vl(t){if(t.z<=1)return dl[t.z+2*t.y+t.x];const e=El(Al(t));return rl.fromPoints(e)}function _l(t,e,i){return Da(t,t,1-i),Ra(t,t,e,i)}function xl(t,e){const i=Rl(e.zoom);if(0===i)return vl(t);const n=Al(t),r=El(n),o=Hl(n.getWest())*e.worldSize,s=Hl(n.getEast())*e.worldSize,a=Wl(n.getNorth())*e.worldSize,l=Wl(n.getSouth())*e.worldSize,c=[o,a,0],u=[s,a,0],h=[o,l,0],p=[s,l,0],d=fa([],e.globeMatrix);return Ba(c,c,d),Ba(u,u,d),Ba(h,h,d),Ba(p,p,d),r[0]=_l(r[0],h,i),r[1]=_l(r[1],p,i),r[2]=_l(r[2],u,i),r[3]=_l(r[3],c,i),rl.fromPoints(r)}function bl(t,e,i){for(const n of t)Ba(n,n,e),Da(n,n,i)}function wl(t,e,i){const n=e/t.worldSize,r=t.globeMatrix;if(i.z<=1){const t=vl(i).getCorners();return bl(t,r,n),rl.fromPoints(t)}const o=Al(i),s=El(o);bl(s,r,n);const a=Number.MAX_VALUE,l=[-a,-a,-a],c=[a,a,a];if(o.contains(t.center)){for(const t of s)Pa(c,c,t),La(l,l,t);l[2]=0;const e=t.point,i=[e.x*n,e.y*n,0];return Pa(c,c,i),La(l,l,i),new rl(c,l)}const u=[r[12]*n,r[13]*n,r[14]*n],h=o.getCenter(),p=T(t.center.lat,-Ql,Ql),d=T(h.lat,-Ql,Ql),f=Hl(t.center.lng),m=Wl(p);let g=f-Hl(h.lng);const y=m-Wl(d);g>.5?g-=1:g<-.5&&(g+=1);let v=0;Math.abs(g)>Math.abs(y)?v=g>=0?1:3:(v=y>=0?0:2,Ra(u,u,[r[4]*n,r[5]*n,r[6]*n],-Math.sin(b(y>=0?o.getSouth():o.getNorth()))*al));const _=s[v],x=s[(v+1)%4],w=new gl(_,x,u),A=[yl(w,0)||_[0],yl(w,1)||_[1],yl(w,2)||_[2]],E=Rl(t.zoom);if(E>0){const n=function({x:t,y:e,z:i},n,r,o,s){const a=1/(1<.5?p=-1:d<-.5&&(p=1),l=((l+p)*n-(o*=n))*r+o,c=((c+p)*n-o)*r+o,u=(u*n-(s*=n))*r+s,h=(h*n-s)*r+s,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]}(i,e,t._pixelsPerMercatorPixel,f,m);for(let t=0;tMath.PI/2*1.01}const Nl=b(85),Bl=Math.cos(Nl),zl=Math.sin(Nl),Fl=6371008.8,Vl=2*Math.PI*Fl;class Ul{constructor(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")}wrap(){return new Ul(C(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,n=t.lat*e,r=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Fl*Math.acos(Math.min(r,1))}toBounds(t=0){const e=360*t/40075017,i=e/Math.cos(Math.PI/180*this.lat);return new la(new Ul(this.lng-i,this.lat-e),new Ul(this.lng+i,this.lat+e))}toEcef(t){const e=fl(t);return Ml(this.lat,this.lng,al+e)}static convert(t){if(t instanceof Ul)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Ul(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Ul(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}var Gl=Ul;function jl(t){return Vl*Math.cos(t*Math.PI/180)}function Hl(t){return(180+t)/360}function Wl(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function ql(t,e){return t/jl(e)}function Xl(t){return 360*t-180}function Zl(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Yl(t,e){return t*jl(Zl(e))}const Ql=85.051129;function Jl(t){return 1/Math.cos(t*Math.PI/180)}class Kl{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Gl.convert(t);return new Kl(Hl(i.lng),Wl(i.lat),ql(e,i.lat))}toLngLat(){return new Gl(Xl(this.x),Zl(this.y))}toAltitude(){return Yl(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Vl*Jl(Zl(this.y))}}function $l(t,e,i,n,r,o,s,a,l){const c=(e+n)/2,u=(i+r)/2,h=new v(c,u);a(h),function(t,e,i,n,r,o){const s=i-r,a=n-o;return Math.abs((n-e)*s-(i-t)*a)/Math.hypot(s,a)}(h.x,h.y,o.x,o.y,s.x,s.y)>=l?($l(t,e,i,c,u,o,h,a,l),$l(t,c,u,n,r,h,s,a,l)):t.push(s)}function tc(t,e,i){let n=t[0],r=n.x,o=n.y;e(n);const s=[n];for(let a=1;at.x+1||nt.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size"),t}function sc(t,e,i){const n=t.loadGeometry(),r=t.extent,o=aa/r;if(e&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=Xl((e.x+t.x/r)/o),n=Zl((e.y+t.y/r)/o),u=c.project(i,n);t.x=(u.x*s-a)*r,t.y=(u.y*s-l)*r};for(let e=0;e=r||i.y<0||i.y>=r||(u(i),t.push(i));n[e]=t}}for(const t of n)for(const e of t)oc(e,o);return n}function ac(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?sc(t):[]}}function lc(t,e,i,n,r){t.emplaceBack(2*e+(n+1)/2,2*i+(r+1)/2)}function cc(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class uc{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Uo,this.indexArray=new ns,this.segments=new sa,this.programConfigurations=new Qs(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:e,id:r,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ac(e,t);if(!this.layers[0]._featureFilter.filter(new wo(this.zoom),c,i))continue;const u=s?s.evaluate(c,{},i):void 0,h={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:sc(e,i,n),patterns:{},sortKey:u};o.push(h)}s&&o.sort(((t,e)=>t.sortKey-e.sortKey));let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Zo,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=t[o].feature;this.addFeature(n,r,o,e.availableImages,i,a),e.featureIndex.insert(l,r,o,s,this.index)}}update(t,e,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ra.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,oa.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,e,i,n,r,o){for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i<0||i>=aa||n<0||n>=aa)continue;if(o){const t=o.projectTilePoint(i,n,r),e=o.upVector(r,i,n),s=this.globeExtVertexArray;cc(s,t,e),cc(s,t,e),cc(s,t,e),cc(s,t,e)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;lc(this.layoutVertexArray,i,n,-1,-1),lc(this.layoutVertexArray,i,n,1,-1),lc(this.layoutVertexArray,i,n,1,1),lc(this.layoutVertexArray,i,n,-1,1),this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{},n,r)}}function hc(t,e){for(let i=0;i1){if(mc(t,e))return!0;for(let n=0;n1?i:i.sub(e)._mult(r)._add(e))}function _c(t,e){let i,n,r,o=!1;for(let s=0;se.y!=r.y>e.y&&e.x<(r.x-n.x)*(e.y-n.y)/(r.y-n.y)+n.x&&(o=!o)}return o}function xc(t,e){let i=!1;for(let n=0,r=t.length-1;ne.y!=s.y>e.y&&e.x<(s.x-o.x)*(e.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function bc(t,e,i,n,r){for(const o of t)if(e<=o.x&&i<=o.y&&n>=o.x&&r>=o.y)return!0;const o=[new v(e,i),new v(e,r),new v(n,r),new v(n,i)];if(t.length>2)for(const e of o)if(xc(t,e))return!0;for(let e=0;er.x&&e.x>r.x||t.yr.y&&e.y>r.y)return!1;const o=W(t,e,i[0]);return o!==W(t,e,i[1])||o!==W(t,e,i[2])||o!==W(t,e,i[3])}function Ac(t,e,i){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Ec(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Sc(t,e,i,n,r){if(!e[0]&&!e[1])return t;const o=v.convert(e)._mult(r);"viewport"===i&&o._rotate(-n);const s=[];for(let e=0;e0){const t=i.projection.upVector(c,h.x,h.y);d.x+=t[0]*u*p,d.y+=t[1]*u*p,d.z+=t[2]*u*p}const f=o?h:Pc(d.x,d.y,d.z,n),m=o?t.tilespaceRays.map((t=>Rc(t,p))):t.queryGeometry.screenGeometry,g=Wa([],[d.x,d.y,d.z,1],n);if(!s&&o?l*=g[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/g[3]),o){const t=Zl((e.y/aa+c.y)/(1<t.width||r.height>t.height||i.x>t.width-r.width||i.y>t.height-r.height)throw new RangeError("out of range source coordinates for image copy");if(r.width>e.width||r.height>e.height||n.x>e.width-r.width||n.y>e.height-r.height)throw new RangeError("out of range destination coordinates for image copy");const s=t.data,a=e.data;for(let l=0;l{e[t.evaluationKey]=o;const s=t.expression.evaluate(e);r.data[i+n+0]=Math.floor(255*s.r/s.a),r.data[i+n+1]=Math.floor(255*s.g/s.a),r.data[i+n+2]=Math.floor(255*s.b/s.a),r.data[i+n+3]=Math.floor(255*s.a)};if(t.clips)for(let e=0,r=0;e80*i){n=o=t[0],r=s=t[1];for(var f=i;fo&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-n,s-r))?32767/c:0}return Yc(p,d,i,n,r,c,0),d}function Xc(t,e,i,n,r){var o,s;if(r===yu(t,e,i,n)>0)for(o=e;o=e;o-=n)s=fu(o,t[o],t[o+1],s);return s&&lu(s,s.next)&&(mu(s),s=s.next),s}function Zc(t,e){if(!t)return t;e||(e=t);var i,n=t;do{if(i=!1,n.steiner||!lu(n,n.next)&&0!==au(n.prev,n,n.next))n=n.next;else{if(mu(n),(n=e=n.prev)===n.next)break;i=!0}}while(i||n!==e);return e}function Yc(t,e,i,n,r,o,s){if(t){!s&&o&&function(t,e,i,n){var r=t;do{0===r.z&&(r.z=nu(r.x,r.y,e,i,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,i,n,r,o,s,a,l,c=1;do{for(i=t,t=null,o=null,s=0;i;){for(s++,n=i,a=0,e=0;e0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(t,n,r,o);for(var a,l,c=t;t.prev!==t.next;)if(a=t.prev,l=t.next,o?Jc(t,n,r,o):Qc(t))e.push(a.i/i|0),e.push(t.i/i|0),e.push(l.i/i|0),mu(t),t=l.next,c=l.next;else if((t=l)===c){s?1===s?Yc(t=Kc(Zc(t),e,i),e,i,n,r,o,2):2===s&&$c(t,e,i,n,r,o):Yc(Zc(t),e,i,n,r,o,1);break}}}function Qc(t){var e=t.prev,i=t,n=t.next;if(au(e,i,n)>=0)return!1;for(var r=e.x,o=i.x,s=n.x,a=e.y,l=i.y,c=n.y,u=ro?r>s?r:s:o>s?o:s,d=a>l?a>c?a:c:l>c?l:c,f=n.next;f!==e;){if(f.x>=u&&f.x<=p&&f.y>=h&&f.y<=d&&ou(r,a,o,l,s,c,f.x,f.y)&&au(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Jc(t,e,i,n){var r=t.prev,o=t,s=t.next;if(au(r,o,s)>=0)return!1;for(var a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,p=s.y,d=al?a>c?a:c:l>c?l:c,g=u>h?u>p?u:p:h>p?h:p,y=nu(d,f,e,i,n),v=nu(m,g,e,i,n),_=t.prevZ,x=t.nextZ;_&&_.z>=y&&x&&x.z<=v;){if(_.x>=d&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&ou(a,u,l,h,c,p,_.x,_.y)&&au(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=d&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&ou(a,u,l,h,c,p,x.x,x.y)&&au(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=y;){if(_.x>=d&&_.x<=m&&_.y>=f&&_.y<=g&&_!==r&&_!==s&&ou(a,u,l,h,c,p,_.x,_.y)&&au(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=v;){if(x.x>=d&&x.x<=m&&x.y>=f&&x.y<=g&&x!==r&&x!==s&&ou(a,u,l,h,c,p,x.x,x.y)&&au(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Kc(t,e,i){var n=t;do{var r=n.prev,o=n.next.next;!lu(r,o)&&cu(r,n,n.next,o)&&pu(r,o)&&pu(o,r)&&(e.push(r.i/i|0),e.push(n.i/i|0),e.push(o.i/i|0),mu(n),mu(n.next),n=t=o),n=n.next}while(n!==t);return Zc(n)}function $c(t,e,i,n,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&su(s,a)){var l=du(s,a);return s=Zc(s,s.next),l=Zc(l,l.next),Yc(s,e,i,n,r,o,0),void Yc(l,e,i,n,r,o,0)}a=a.next}s=s.next}while(s!==t)}function tu(t,e){return t.x-e.x}function eu(t,e){var i=function(t,e){var i,n=e,r=t.x,o=t.y,s=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var a=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>s&&(s=a,i=n.x=n.x&&n.x>=u&&r!==n.x&&ou(oi.x||n.x===i.x&&iu(i,n)))&&(i=n,p=l)),n=n.next}while(n!==c);return i}(t,e);if(!i)return e;var n=du(i,t);return Zc(n,n.next),Zc(i,i.next)}function iu(t,e){return au(t.prev,t,e.prev)<0&&au(e.next,t,t.next)<0}function nu(t,e,i,n,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function ru(t){var e=t,i=t;do{(e.x=(t-s)*(o-a)&&(t-s)*(n-a)>=(i-s)*(e-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function su(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&cu(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(pu(t,e)&&pu(e,t)&&function(t,e){var i=t,n=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&r<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(au(t.prev,t,e.prev)||au(t,e.prev,e))||lu(t,e)&&au(t.prev,t,t.next)>0&&au(e.prev,e,e.next)>0)}function au(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function lu(t,e){return t.x===e.x&&t.y===e.y}function cu(t,e,i,n){var r=hu(au(t,e,i)),o=hu(au(t,e,n)),s=hu(au(i,n,t)),a=hu(au(i,n,e));return r!==o&&s!==a||!(0!==r||!uu(t,i,e))||!(0!==o||!uu(t,n,e))||!(0!==s||!uu(i,t,n))||!(0!==a||!uu(i,e,n))}function uu(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function hu(t){return t>0?1:t<0?-1:0}function pu(t,e){return au(t.prev,t,t.next)<0?au(t,e,t.next)>=0&&au(t,t.prev,e)>=0:au(t,e,t.prev)<0||au(t,t.next,e)<0}function du(t,e){var i=new gu(t.i,t.x,t.y),n=new gu(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,i.next=r,r.prev=i,n.next=i,i.prev=n,o.next=n,n.prev=o,n}function fu(t,e,i,n){var r=new gu(t,e,i);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function mu(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 gu(t,e,i){this.i=t,this.x=e,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function yu(t,e,i,n){for(var r=0,o=e,s=i-n;o0&&i.holes.push(n+=t[r-1].length)}return i};var vu=p(Wc.exports);function _u(t,e,i,n,r){xu(t,e,i||0,n||t.length-1,r||wu)}function xu(t,e,i,n,r){for(;n>i;){if(n-i>600){var o=n-i+1,s=e-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);xu(t,e,Math.max(i,Math.floor(e-s*l/o+c)),Math.min(n,Math.floor(e+(o-s)*l/o+c)),r)}var u=t[e],h=i,p=n;for(bu(t,i,e),r(t[n],u)>0&&bu(t,i,n);h0;)p--}0===r(t[i],u)?bu(t,i,p):bu(t,++p,n),p<=e&&(i=p+1),e<=p&&(n=p-1)}}function bu(t,e,i){var n=t[e];t[e]=t[i],t[i]=n}function wu(t,e){return te?1:0}function Au(t,e){const i=t.length;if(i<=1)return[t];const n=[];let r,o;for(let e=0;e1)for(let t=0;tt.id)),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Uo,this.indexArray=new ns,this.indexArray2=new cs,this.programConfigurations=new Qs(t.layers,t.zoom),this.segments=new sa,this.segments2=new sa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.projection=t.projection}populate(t,e,i,n){this.hasPattern=Su("fill",this.layers,e);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of t){const t=this.layers[0]._featureFilter.needGeometry,u=ac(s,t);if(!this.layers[0]._featureFilter.filter(new wo(this.zoom),u,i))continue;const h=r?r.evaluate(u,{},i,e.availableImages):void 0,p={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:t?u.geometry:sc(s,i,n),patterns:{},sortKey:h};o.push(p)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(this.hasPattern){const t=Mu("fill",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,{},e.availableImages);e.featureIndex.insert(t[o].feature,r,o,s,this.index)}}update(t,e,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,n)}addFeatures(t,e,i,n,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Hc),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,r,o=[]){for(const t of Au(e,500)){let e=0;for(const i of t)e+=i.length;const i=this.segments.prepareSegment(e,this.layoutVertexArray,this.indexArray),n=i.vertexLength,r=[],o=[];for(const e of t){if(0===e.length)continue;e!==t[0]&&o.push(r.length/2);const i=this.segments2.prepareSegment(e.length,this.layoutVertexArray,this.indexArray2),n=i.vertexLength;this.layoutVertexArray.emplaceBack(e[0].x,e[0].y),this.indexArray2.emplaceBack(n+e.length-1,n),r.push(e[0].x),r.push(e[0].y);for(let t=1;t>3}if(r--,1===n||2===n)o+=t.readSVarint(),s+=t.readSVarint(),1===n&&(e&&a.push(e),e=[]),e.push(new ku(o,s));else{if(7!==n)throw new Error("unknown command "+n);e&&e.push(e[0].clone())}}return e&&a.push(e),a},Bu.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;t.pos>3}if(n--,1===i||2===i)(r+=t.readSVarint())a&&(a=r),(o+=t.readSVarint())c&&(c=o);else if(7!==i)throw new Error("unknown command "+i)}return[s,l,a,c]},Bu.prototype.toGeoJSON=function(t,e,i){var n,r,o=this.extent*Math.pow(2,i),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),c=Bu.types[this.type];function u(t){for(var e=0;e>3;e=1===n?t.readString():2===n?t.readFloat():3===n?t.readDouble():4===n?t.readVarint64():5===n?t.readVarint():6===n?t.readSVarint():7===n?t.readBoolean():null}return e}(i))}Gu.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 Vu(this._pbf,e,this.extent,this._keys,this._values)};var Hu=Uu;function Wu(t,e,i){if(3===t){var n=new Hu(i,i.readVarint()+i.pos);n.length&&(e[n.name]=n)}}var qu=Ou.VectorTile=function(t,e){this.layers=t.readFields(Wu,{},e)},Xu=Ou.VectorTileFeature=Nu;function Zu(t,e,i,n){const r=[],o=0===n?(t,e,i,n,r,o)=>{t.push(new v(o,i+(o-e)/(n-e)*(r-i)))}:(t,e,i,n,r,o)=>{t.push(new v(e+(o-i)/(r-i)*(n-e),o))};for(const s of t){const t=[];for(const r of s){if(r.length<=2)continue;const s=[];for(let t=0;te&&o(s,a,l,c,u,e):h>i?p=e&&o(s,a,l,c,u,e),p>i&&h<=i&&o(s,a,l,c,u,i)}let a=r[r.length-1];const l=0===n?a.x:a.y;l>=e&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),t.push(s))}t.length&&r.push(t)}return r}Ou.VectorTileLayer=Uu;const Yu=Xu.types,Qu=Math.pow(2,13);function Ju(t,e,i,n,r,o,s,a){t.emplaceBack((e<<1)+s,(i<<1)+o,(Math.floor(n*Qu)<<1)+r,Math.round(a))}function Ku(t,e,i){const n=16384;t.emplaceBack(e.x,e.y,e.z,i[0]*n,i[1]*n,i[2]*n)}class $u{constructor(){this.acc=new v(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new v(t.x,t.y),this.max=new v(t.x,t.y))}append(t,e){this.currentPolyCount.edges++,this.acc._add(t);const i=this.min,n=this.max;t.xn.x&&(n.x=t.x),t.yn.y&&(n.y=t.y),((0===t.x||t.x===aa)&&t.x===e.x)!=((0===t.y||t.y===aa)&&t.y===e.y)&&this.processBorderOverlap(t,e),e.x<0!=t.x<0&&this.addBorderIntersection(0,Li(e.y,t.y,(0-e.x)/(t.x-e.x))),e.x>aa!=t.x>aa&&this.addBorderIntersection(1,Li(e.y,t.y,(aa-e.x)/(t.x-e.x))),e.y<0!=t.y<0&&this.addBorderIntersection(2,Li(e.x,t.x,(0-e.y)/(t.y-e.y))),e.y>aa!=t.y>aa&&this.addBorderIntersection(3,Li(e.x,t.x,(aa-e.y)/(t.y-e.y)))}addBorderIntersection(t,e){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const i=this.borders[t];ei[1]&&(i[1]=e)}processBorderOverlap(t,e){if(t.x===e.x){if(t.y===e.y)return;const i=0===t.x?0:1;this.addBorderIntersection(i,e.y),this.addBorderIntersection(i,t.y)}else{const i=0===t.y?2:3;this.addBorderIntersection(i,e.x),this.addBorderIntersection(i,t.x)}}centroid(){const t=this.polyCount.reduce(((t,e)=>t+e.edges),0);return 0!==t?this.acc.div(t)._round():new v(0,0)}span(){return new v(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce(((t,e)=>t+ +(e[0]!==Number.MAX_VALUE)),0)}}class th{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.layoutVertexArray=new jo,this.centroidVertexArray=new ws,this.indexArray=new ns,this.programConfigurations=new Qs(t.layers,t.zoom),this.segments=new sa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.enableTerrain=t.enableTerrain}populate(t,e,i,n){this.features=[],this.hasPattern=Su("fill-extrusion",this.layers,e),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(t){const e=Math.exp(Math.PI*(1-t.y/(1<=0;t--){const e=p[t];(0===e.length||(d=e[0]).every((t=>t.x<=0))||d.every((t=>t.x>=aa))||d.every((t=>t.y<=0))||d.every((t=>t.y>=aa)))&&p.splice(t,1)}var d;let f;if(c)f=lh(p,a,n);else{f=[];for(const t of p)f.push({polygon:t,bounds:a})}const m=h?this.edgeRadius:0;for(const{polygon:t,bounds:e}of f){let i=0,r=0;for(const e of t)h&&!e[0].equals(e[e.length-1])&&e.push(e[0]),r+=h?e.length-1:e.length;const o=this.segments.prepareSegment((h?5:4)*r,this.layoutVertexArray,this.indexArray);if(h){const e=[],r=[];i=o.vertexLength;for(const i of t){let s,a;i.length&&i!==t[0]&&r.push(e.length/2),s=i[1].sub(i[0])._perp()._unit();for(let t=1;t4&&oh(r[r.length-2],r[0],r[1]),d=m?ih(r[r.length-2],r[0],r[1],m):0;s=r[1].sub(r[0])._perp()._unit();let f=!0;for(let g=1,y=0;g0?1:0,E=v.dist(_);if(y+E>32768&&(y=0),m){a=x.sub(_)._perp()._unit();let t=nh(v,_,x,eh(s,a),m);isNaN(t)&&(t=0);const e=_.sub(v)._unit();v=v.add(e.mult(d))._round(),_=_.add(e.mult(-t))._round(),d=t,s=a}const S=o.vertexLength,M=r.length>4&&oh(v,_,x);let T=sh(y,p,f);if(Ju(this.layoutVertexArray,v.x,v.y,w,A,0,0,T),Ju(this.layoutVertexArray,v.x,v.y,w,A,0,1,T),y+=E,T=sh(y,M,!f),p=M,Ju(this.layoutVertexArray,_.x,_.y,w,A,0,0,T),Ju(this.layoutVertexArray,_.x,_.y,w,A,0,1,T),o.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),o.primitiveLength+=2,m){const n=i+(1===g?r.length-2:g-2),s=1===g?i:n+1;if(this.indexArray.emplaceBack(S+1,n,S+3),this.indexArray.emplaceBack(n,s,S+3),o.primitiveLength+=2,void 0===t&&(t=S),!rh(x,r[g],e)){const e=g===r.length-1?t:o.vertexLength;this.indexArray.emplaceBack(S+2,S+3,e),this.indexArray.emplaceBack(S+3,e+1,e),this.indexArray.emplaceBack(S+3,s,e+1),o.primitiveLength+=3}f=!f}if(c){const t=this.layoutVertexExtArray,e=l.projectTilePoint(v.x,v.y,n),i=l.projectTilePoint(_.x,_.y,n),r=l.upVector(n,v.x,v.y),o=l.upVector(n,_.x,_.y);Ku(t,e,r),Ku(t,e,r),Ku(t,i,o),Ku(t,i,o)}}h&&(i+=r.length-1)}}if(u&&u.polyCount.length>0){if(u.borders){u.vertexArrayOffset=this.centroidVertexArray.length;const t=u.borders,e=this.featuresOnBorder.push(u)-1;for(let i=0;i<4;i++)t[i][0]!==Number.MAX_VALUE&&this.borders[i].push(e)}this.encodeCentroid(u.borders?void 0:u.centroid(),u)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort(((e,i)=>this.featuresOnBorder[e].borders[t][0]-this.featuresOnBorder[i].borders[t][0]))}encodeCentroid(t,e,i=!0){let n,r;if(t)if(0!==t.y){const i=e.span()._mult(this.tileToMeter);n=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(i.x/10)),r=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(i.y/10))}else n=Math.ceil(7*(t.x+450)),r=0;else n=0,r=+i;let o=i?this.centroidVertexArray.length:e.vertexArrayOffset;for(const t of e.polyCount){i&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*t.edges+t.top);for(let e=0;ei[1].x&&e.x>i[1].x||t.yi[1].y&&e.y>i[1].y}function oh(t,e,i){if(t.x<0||t.x>=aa||e.x<0||e.x>=aa||i.x<0||i.x>=aa)return!1;const n=i.sub(e),r=n.perp(),o=t.sub(e);return(n.x*o.x+n.y*o.y)/Math.sqrt((n.x*n.x+n.y*n.y)*(o.x*o.x+o.y*o.y))>-.866&&r.x*o.x+r.y*o.y<0}function sh(t,e,i){const n=e?2|t:-3&t;return i?1|n:-2&n}function ah(){const t=Math.PI/32,e=Math.tan(t),i=Fl;return i*Math.sqrt(1+2*e*e)-i}function lh(t,e,i){const n=1<{for(const i of t)s.push({polygon:i,bounds:e})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),u=l-c,h=[];for(let t=0;t0?0:1);for(let t=0;te+1?d.push({polygons:p,bounds:t,depth:e+1}):a(p,t)}if(f.length){const t=[new v(0===i?u:n.x,1===i?u:n.y),s];h.length>e+1?d.push({polygons:f,bounds:t,depth:e+1}):a(f,t)}}return s}(t,e,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,((t,e,r)=>{if(0===t)return.5*(e+r);{const t=Zl((i.y+e/aa)/n);return(Wl(.5*(Zl((i.y+r/aa)/n)+t))*n-i.y)*aa}}))}Yr(th,"FillExtrusionBucket",{omit:["layers","features"]}),Yr($u,"PartMetadata");const ch=new Oo({"fill-extrusion-edge-radius":new Lo(te["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var uh={paint:new Oo({"fill-extrusion-opacity":new Lo(te["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Do(te["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Lo(te["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Lo(te["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Do(te["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Do(te["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Do(te["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Lo(te["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new Lo(te["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new Lo(te["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new Lo(te["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:ch};function hh(t,e,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class ph{constructor(t,e,i){this.z=t,this.x=e,this.y=i,this.key=mh(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e){const i=function(t,e,i){var n=hh(256*t,256*(e=Math.pow(2,i)-e-1),i),r=hh(256*(t+1),256*(e+1),i);return n[0]+","+n[1]+","+r[0]+","+r[1]}(this.x,this.y,this.z),n=function(t,e,i){let n,r="";for(let o=t;o>0;o--)n=1<this.canonical.z?new fh(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new fh(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}calculateScaledKey(t,e=!0){if(this.overscaledZ===t&&e)return this.key;if(t>this.canonical.z)return mh(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-t;return mh(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const e=this.canonical.z-t.canonical.z;return 0===t.overscaledZ||t.overscaledZ>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new fh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new fh(e,this.wrap,e,i,n),new fh(e,this.wrap,e,i+1,n),new fh(e,this.wrap,e,i,n+1),new fh(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrapt.wrap)&&(this.overscaledZt.overscaledZ)&&(this.canonical.xt.canonical.x)&&this.canonical.yt.id)),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach((t=>{this.gradients[t.id]={}})),this.layoutVertexArray=new Ho,this.layoutVertexArray2=new Wo,this.indexArray=new ns,this.programConfigurations=new Qs(t.layers,t.zoom),this.segments=new sa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i,n){this.hasPattern=Su("line",this.layers,e);const r=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:e,id:s,index:a,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=ac(e,t);if(!this.layers[0]._featureFilter.filter(new wo(this.zoom),c,i))continue;const u=r?r.evaluate(c,{},i):void 0,h={id:s,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:t?c.geometry:sc(e,i,n),patterns:{},sortKey:u};o.push(h)}r&&o.sort(((t,e)=>t.sortKey-e.sortKey));const{lineAtlas:s,featureIndex:a}=e,l=this.addConstantDashes(s);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:c}=n;if(l&&this.addFeatureDashes(n,s),this.hasPattern){const t=Mu("line",this.layers,n,this.zoom,e);this.patternFeatures.push(t)}else this.addFeature(n,r,o,i,s.positions,e.availableImages);a.insert(t[o].feature,r,o,c,this.index)}}addConstantDashes(t){let e=!1;for(const i of this.layers){const n=i.paint.get("line-dasharray").value,r=i.layout.get("line-cap").value;if("constant"!==n.kind||"constant"!==r.kind)e=!0;else{const e=r.value,i=n.value;if(!i)continue;t.addDash(i,e)}}return e}addFeatureDashes(t,e){const i=this.zoom;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,o=n.layout.get("line-cap").value;if("constant"===r.kind&&"constant"===o.kind)continue;let s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},t);a="constant"===o.kind?o.value:o.evaluate({zoom:i},t),e.addDash(s,a),t.patterns[n.id]=e.getKey(s,a)}}update(t,e,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,i,n)}addFeatures(t,e,i,n,r){for(const t of this.patternFeatures)this.addFeature(t,t.geometry,t.index,e,i,n)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,Ah)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,bh),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(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}}addFeature(t,e,i,n,r,o){const s=this.layers[0].layout,a=s.get("line-join").evaluate(t,{}),l=s.get("line-cap").evaluate(t,{}),c=s.get("line-miter-limit"),u=s.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,a,l,c,u);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,r,o,n)}addLine(t,e,i,n,r,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e=2&&t[a-1].equals(t[a-2]);)a--;let l=0;for(;l0;if(b&&e>l){const t=h.dist(p);if(t>2*c){const e=h.sub(h.sub(p)._mult(c/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,f,0,0,u),p=e}}const A=p&&d;let E=A?i:s?"butt":n;if(A&&"round"===E&&(_r&&(E="bevel"),"bevel"===E&&(_>2&&(E="flipbevel"),_100)g=m.mult(-1);else{const t=_*f.add(m).mag()/f.sub(m).mag();g._perp()._mult(t*(w?-1:1))}this.addCurrentVertex(h,g,0,0,u),this.addCurrentVertex(h,g.mult(-1),0,0,u)}else if("bevel"===E||"fakeround"===E){const t=-Math.sqrt(_*_-1),e=w?t:0,i=w?0:t;if(p&&this.addCurrentVertex(h,f,e,i,u),"fakeround"===E){const t=Math.round(180*x/Math.PI/20);for(let e=1;e2*c){const e=h.add(d.sub(h)._mult(c/t)._round());this.updateDistance(h,e),this.addCurrentVertex(e,m,0,0,u),h=e}}}}addCurrentVertex(t,e,i,n,r,o=!1){const s=e.y*n-e.x,a=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,o,!1,i,r),this.addHalfVertex(t,s,a,o,!0,-n,r)}addHalfVertex({x:t,y:e},i,n,r,o,s,a){this.layoutVertexArray.emplaceBack((t<<1)+(r?1:0),(e<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===s?0:s<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),a.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}}Yr(Mh,"LineBucket",{omit:["layers","patternFeatures"]});const Th=new Oo({"line-cap":new Do(te.layout_line["line-cap"]),"line-join":new Do(te.layout_line["line-join"]),"line-miter-limit":new Lo(te.layout_line["line-miter-limit"]),"line-round-limit":new Lo(te.layout_line["line-round-limit"]),"line-sort-key":new Do(te.layout_line["line-sort-key"])});var Ih={paint:new Oo({"line-opacity":new Do(te.paint_line["line-opacity"]),"line-color":new Do(te.paint_line["line-color"]),"line-translate":new Lo(te.paint_line["line-translate"]),"line-translate-anchor":new Lo(te.paint_line["line-translate-anchor"]),"line-width":new Do(te.paint_line["line-width"]),"line-gap-width":new Do(te.paint_line["line-gap-width"]),"line-offset":new Do(te.paint_line["line-offset"]),"line-blur":new Do(te.paint_line["line-blur"]),"line-dasharray":new Do(te.paint_line["line-dasharray"]),"line-pattern":new Do(te.paint_line["line-pattern"]),"line-gradient":new Ro(te.paint_line["line-gradient"]),"line-trim-offset":new Lo(te.paint_line["line-trim-offset"])}),layout:Th};const Ch=new class extends Do{possiblyEvaluate(t,e){return e=new wo(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=D({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}(Ih.paint.properties["line-width"].specification);function Ph(t,e){return e>0?e+2*t:t}Ch.useIntegerZoom=!0;const Lh=Fo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Dh=Fo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Rh=Fo([{name:"a_projected_pos",components:4,type:"Float32"}],4);Fo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Oh=Fo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),kh=Fo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Fo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Nh=Fo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Bh=Fo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Fo([{name:"triangle",components:3,type:"Uint16"}]),Fo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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"},{type:"Uint8",name:"flipState"}]),Fo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{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",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Fo([{type:"Float32",name:"offsetX"}]),Fo([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var zh=24;const Fh=128;function Vh(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new wo(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let r=0;for(;r{t.text=function(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),bo.applyArabicShaping&&(t=bo.applyArabicShaping(t)),t}(t.text,e,i)})),t}const Wh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function qh(t){return"︶"===t||"﹈"===t||"︸"===t||"﹄"===t||"﹂"===t||"︾"===t||"︼"===t||"︺"===t||"︘"===t||"﹀"===t||"︐"===t||"︓"===t||"︔"===t||"`"===t||" ̄"===t||"︑"===t||"︒"===t}function Xh(t){return"︵"===t||"﹇"===t||"︷"===t||"﹃"===t||"﹁"===t||"︽"===t||"︻"===t||"︹"===t||"︗"===t||"︿"===t}var Zh=Jh,Yh=function(t,e,i,n,r){var o,s,a=8*r-n-1,l=(1<>1,u=-7,h=i?r-1:0,p=i?-1:1,d=t[e+h];for(h+=p,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=256*o+t[e+h],h+=p,u-=8);for(s=o&(1<<-u)-1,o>>=-u,u+=n;u>0;s=256*s+t[e+h],h+=p,u-=8);if(0===o)o=1-c;else{if(o===l)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,n),o-=c}return(d?-1:1)*s*Math.pow(2,o-n)},Qh=function(t,e,i,n,r,o){var s,a,l,c=8*o-r-1,u=(1<>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,f=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+h>=1?p/l:p*Math.pow(2,1-h))*l>=2&&(s++,l/=2),s+h>=u?(a=0,s=u):s+h>=1?(a=(e*l-1)*Math.pow(2,r),s+=h):(a=e*Math.pow(2,h-1)*Math.pow(2,r),s=0));r>=8;t[i+d]=255&a,d+=f,a/=256,r-=8);for(s=s<0;t[i+d]=255&s,d+=f,s/=256,c-=8);t[i+d-f]|=128*m}; /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function Jh(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Jh.Varint=0,Jh.Fixed64=1,Jh.Bytes=2,Jh.Fixed32=5;var Kh=4294967296,$h=1/Kh,tp="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function ep(t){return t.type===Jh.Bytes?t.readVarint()+t.pos:t.pos+1}function ip(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function np(t,e,i){var n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(var r=i.pos-1;r>=t;r--)i.buf[r+n]=i.buf[r]}function rp(t,e){for(var i=0;i>>8,t[i+2]=e>>>16,t[i+3]=e>>>24}function mp(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}Jh.prototype={destroy:function(){this.buf=null},readFields:function(t,e,i){for(i=i||this.length;this.pos>3,o=this.pos;this.type=7&n,t(r,e,this),this.pos===o&&this.skip(n)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=dp(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=mp(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=dp(this.buf,this.pos)+dp(this.buf,this.pos+4)*Kh;return this.pos+=8,t},readSFixed64:function(){var t=dp(this.buf,this.pos)+mp(this.buf,this.pos+4)*Kh;return this.pos+=8,t},readFloat:function(){var t=Yh(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Yh(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,i,n=this.buf;return e=127&(i=n[this.pos++]),i<128?e:(e|=(127&(i=n[this.pos++]))<<7,i<128?e:(e|=(127&(i=n[this.pos++]))<<14,i<128?e:(e|=(127&(i=n[this.pos++]))<<21,i<128?e:function(t,e,i){var n,r,o=i.buf;if(n=(112&(r=o[i.pos++]))>>4,r<128)return ip(t,n,e);if(n|=(127&(r=o[i.pos++]))<<3,r<128)return ip(t,n,e);if(n|=(127&(r=o[i.pos++]))<<10,r<128)return ip(t,n,e);if(n|=(127&(r=o[i.pos++]))<<17,r<128)return ip(t,n,e);if(n|=(127&(r=o[i.pos++]))<<24,r<128)return ip(t,n,e);if(n|=(1&(r=o[i.pos++]))<<31,r<128)return ip(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(i=n[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&&tp?function(t,e,i){return tp.decode(t.subarray(e,i))}(this.buf,e,t):function(t,e,i){for(var n="",r=e;r239?4:l>223?3:l>191?2:1;if(r+u>i)break;1===u?l<128&&(c=l):2===u?128==(192&(o=t[r+1]))&&(c=(31&l)<<6|63&o)<=127&&(c=null):3===u?(s=t[r+2],128==(192&(o=t[r+1]))&&128==(192&s)&&((c=(15&l)<<12|(63&o)<<6|63&s)<=2047||c>=55296&&c<=57343)&&(c=null)):4===u&&(s=t[r+2],a=t[r+3],128==(192&(o=t[r+1]))&&128==(192&s)&&128==(192&a)&&((c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||c>=1114112)&&(c=null)),null===c?(c=65533,u=1):c>65535&&(c-=65536,n+=String.fromCharCode(c>>>10&1023|55296),c=56320|1023&c),n+=String.fromCharCode(c),r+=u}return n}(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!==Jh.Bytes)return t.push(this.readVarint(e));var i=ep(this);for(t=t||[];this.pos127;);else if(e===Jh.Bytes)this.pos=this.readVarint()+this.pos;else if(e===Jh.Fixed32)this.pos+=4;else{if(e!==Jh.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;e268435455||t<0?function(t,e){var i,n;if(t>=0?(i=t%4294967296|0,n=t/4294967296|0):(n=~(-t/4294967296),4294967295^(i=~(-t%4294967296))?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((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)))))}(n,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,i){for(var n,r,o=0;o55295&&n<57344){if(!r){n>56319||o+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):r=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,r=n;continue}n=r-55296<<10|n-56320|65536,r=null}else r&&(t[i++]=239,t[i++]=191,t[i++]=189,r=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);var i=this.pos-e;i>=128&&np(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i},writeFloat:function(t){this.realloc(4),Qh(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Qh(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 i=0;i=128&&np(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n},writeMessage:function(t,e,i){this.writeTag(t,Jh.Bytes),this.writeRawMessage(e,i)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,rp,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,op,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,lp,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,sp,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,ap,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,cp,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,up,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,hp,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,pp,e)},writeBytesField:function(t,e){this.writeTag(t,Jh.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,Jh.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,Jh.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,Jh.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,Jh.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,Jh.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,Jh.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,Jh.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,Jh.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,Jh.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var gp=p(Zh);const yp=3;function vp(t,e,i){e.glyphs=[],1===t&&i.readMessage(_p,e)}function _p(t,e,i){if(3===t){const{id:t,bitmap:n,width:r,height:o,left:s,top:a,advance:l}=i.readMessage(xp,{});e.glyphs.push({id:t,bitmap:new zc({width:r+2*yp,height:o+2*yp},n),metrics:{width:r,height:o,left:s,top:a,advance:l}})}else 4===t?e.ascender=i.readSVarint():5===t&&(e.descender=i.readSVarint())}function xp(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}const bp=yp;function wp(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let r=0,o=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,o=Math.max(o,e.y+e.h),r=Math.max(r,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();tt.hasImage(e))),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,r]=t.tl;i.update(e.data,void 0,{x:n,y:r})}}Yr(Ep,"ImagePosition"),Yr(Sp,"ImageAtlas");const Mp={horizontal:1,vertical:2,horizontalOnly:3},Tp=-17;class Ip{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,e){const i=new Ip;return i.scale=t||1,i.fontStack=e,i}static forImage(t){const e=new Ip;return e.imageName=t,e}}class Cp{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,e){const i=new Cp;for(let n=0;n=0&&i>=t&&Lp[this.text.charCodeAt(i)];i--)e--;this.text=this.text.substring(t,e),this.sectionIndex=this.sectionIndex.slice(t,e)}substring(t,e){const i=new Cp;return i.text=this.text.substring(t,e),i.sectionIndex=this.sectionIndex.slice(t,e),i.sections=this.sections,i}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}addTextSection(t,e){this.text+=t.text,this.sections.push(Ip.forText(t.scale,t.fontStack||e));const i=this.sections.length-1;for(let e=0;e=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Pp(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f){const m=Cp.fromFeature(t,r);h===Mp.vertical&&m.verticalizePunctuation(p);let g=[];const y=function(t,e,i,n,r,o){if(!t)return[];const s=[],a=function(t,e,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>b&&(b=o)}else{const t=i[a.fontStack];if(!t)continue;t[m]&&(E=t[m]);const n=e[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(_=o.metrics,M=8203!==m?zh:0,g){const t=void 0!==n.ascender?Math.abs(n.ascender):0,e=void 0!==n.descender?Math.abs(n.descender):0,i=(t+e)*y;w-i/2;){if(s--,s<0)return!1;a-=t[s].dist(o),o=t[s]}a+=t[s].dist(t[s+1]),s++;const l=[];let c=0;for(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=e.dist(i)}return!0}function Hp(t){let e=0;for(let i=0;ic){const u=(c-l)/o,h=Li(n.x,r.x,u),p=Li(n.y,r.y,u),d=new Gp(h,p,0,r.angleTo(n),i);return!s||jp(t,d,a,s,e)?d:void 0}l+=o}}function Zp(t,e,i,n,r,o,s,a,l){const c=Wp(n,o,s),u=qp(n,r),h=u*s,p=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-h=0&&y=0&&v=0&&p+c<=u){const i=new Gp(y,v,0,m,e);i._round(),n&&!jp(t,i,o,n,r)||d.push(i)}}h+=f}return a||d.length||s||(d=Yp(t,h/2,i,n,r,o,s,!0,l)),d}function Qp(t,e,i,n,r){const o=[];for(let s=0;s=n&&c.x>=n||(s.x>=n?s=new v(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round():c.x>=n&&(c=new v(n,s.y+(n-s.x)/(c.x-s.x)*(c.y-s.y))._round()),s.y>=r&&c.y>=r||(s.y>=r?s=new v(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round():c.y>=r&&(c=new v(s.x+(r-s.y)/(c.y-s.y)*(c.x-s.x),r)._round()),l&&s.equals(l[l.length-1])||(l=[s],o.push(l)),l.push(c)))))}}return o}Yr(Gp,"Anchor");const Jp=1e20;function Kp(t,e,i,n,r,o,s,a,l){for(let c=e;c-1);l++,o[l]=a,s[l]=c,s[l+1]=Jp}for(let a=0,l=0;a{let n=this.entries[t];n||(n=this.entries[t]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let r=n.glyphs[e];if(void 0!==r)return void i(null,{stack:t,id:e,glyph:r});if(r=this._tinySDF(n,t,e),r)return n.glyphs[e]=r,void i(null,{stack:t,id:e,glyph:r});const o=Math.floor(e/256);if(256*o>65535)return void i(new Error("glyphs > 65535 not supported"));if(n.ranges[o])return void i(null,{stack:t,id:e,glyph:r});let s=n.requests[o];s||(s=n.requests[o]=[],id.loadGlyphRange(t,o,this.url,this.requestManager,((t,e)=>{if(e){n.ascender=e.ascender,n.descender=e.descender;for(const t in e.glyphs)this._doesCharSupportLocalGlyph(+t)||(n.glyphs[+t]=e.glyphs[+t]);n.ranges[o]=!0}for(const i of s)i(t,e);delete n.requests[o]}))),s.push(((n,r)=>{n?i(n):r&&i(null,{stack:t,id:e,glyph:r.glyphs[e]||null})}))}),((t,i)=>{if(t)e(t);else if(i){const t={};for(const{stack:e,id:n,glyph:r}of i)void 0===t[e]&&(t[e]={}),void 0===t[e].glyphs&&(t[e].glyphs={}),t[e].glyphs[n]=r&&{id:r.id,bitmap:r.bitmap.clone(),metrics:r.metrics},t[e].ascender=this.entries[e].ascender,t[e].descender=this.entries[e].descender;e(null,t)}}))}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==ed.none&&(this.localGlyphMode===ed.all?!!this.localFontFamily:!!this.localFontFamily&&(to["CJK Unified Ideographs"](t)||to["Hangul Syllables"](t)||to.Hiragana(t)||to.Katakana(t)||to["CJK Symbols and Punctuation"](t)))}_tinySDF(t,e,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=t.tinySDF;if(!r){let i="400";/bold/i.test(e)?i="900":/medium/i.test(e)?i="500":/light/i.test(e)&&(i="200"),r=t.tinySDF=new id.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*td,buffer:3*td,radius:8*td}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCharCode(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:p,glyphAdvance:d}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new zc({width:a,height:l},s),metrics:{width:c/td,height:u/td,left:h/td,top:p/td-27,advance:d/td,localGlyph:!0}}}}id.loadGlyphRange=function(t,e,i,n,r){const o=256*e,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",t).replace("{range}",`${o}-${s}`),lt.Glyphs);pt(a,((t,e)=>{if(t)r(t);else if(e){const t={},i=function(t){return new gp(t).readFields(vp,{})}(e);for(const e of i.glyphs)t[e.id]=e;r(null,{glyphs:t,ascender:i.ascender,descender:i.descender})}}))},id.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal"}={}){this.buffer=e,this.cutoff=n,this.radius=i;const a=this.size=t+4*e,l=this._createCanvas(a),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${s} ${o} ${t}px ${r}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a)}_createCanvas(t){const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(t),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),p=new Uint8ClampedArray(h),d={data:p,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:e};if(0===a||0===l)return d;const{ctx:f,buffer:m,gridInner:g,gridOuter:y}=this;f.clearRect(m,m,a,l),f.fillText(t,m,m+s);const v=f.getImageData(m,m,a,l);y.fill(Jp,0,h),g.fill(0,0,h);for(let t=0;t0?t*t:0,g[n]=t<0?t*t:0}}Kp(y,0,0,c,u,c,this.f,this.v,this.z),Kp(g,m,m,a,l,c,this.f,this.v,this.z);for(let t=0;tt+e[1]-e[0],f=h.reduce(d,0),m=p.reduce(d,0),g=a-f,y=l-m;let _=0,x=f,b=0,w=m,A=0,E=g,S=0,M=y;if(o.content&&n){const t=o.content;_=od(h,0,t[0]),b=od(p,0,t[1]),x=od(h,t[0],t[2]),w=od(p,t[1],t[3]),A=t[0]-_,S=t[1]-b,E=t[2]-t[0]-x,M=t[3]-t[1]-w}const T=(n,r,a,l)=>{const h=ad(n.stretch-_,x,c,t.left),p=ld(n.fixed-A,E,n.stretch,f),d=ad(r.stretch-b,w,u,t.top),g=ld(r.fixed-S,M,r.stretch,m),y=ad(a.stretch-_,x,c,t.left),T=ld(a.fixed-A,E,a.stretch,f),I=ad(l.stretch-b,w,u,t.top),C=ld(l.fixed-S,M,l.stretch,m),P=new v(h,d),L=new v(y,d),D=new v(y,I),R=new v(h,I),O=new v(p/s,g/s),k=new v(T/s,C/s),N=e*Math.PI/180;if(N){const t=Math.sin(N),e=Math.cos(N),i=[e,-t,t,e];P._matMult(i),L._matMult(i),R._matMult(i),D._matMult(i)}const B=n.stretch+n.fixed,z=r.stretch+r.fixed;return{tl:P,tr:L,bl:R,br:D,tex:{x:o.paddedRect.x+nd+B,y:o.paddedRect.y+nd+z,w:a.stretch+a.fixed-B,h:l.stretch+l.fixed-z},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:O,pixelOffsetBR:k,minFontScaleX:E/s/c,minFontScaleY:M/s/u,isSDF:i}};if(n&&(o.stretchX||o.stretchY)){const t=sd(h,g,f),e=sd(p,y,m);for(let i=0;i0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const r=t-1>>1,o=e[r];if(i(n,o)>=0)break;e[t]=o,t=r}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,r=e[t];for(;t=0)break;e[t]=o,t=n}e[t]=r}}function hd(t,e){return te?1:0}function pd(t,e=1,i=!1){let n=1/0,r=1/0,o=-1/0,s=-1/0;const a=t[0];for(let t=0;to)&&(o=e.x),(!t||e.y>s)&&(s=e.y)}const l=Math.min(o-n,s-r);let c=l/2;const u=new ud([],dd);if(0===l)return new v(n,r);for(let e=n;eh.d||!h.d)&&(h=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,p)),n.max-h.d<=e||(c=n.h/2,u.push(new fd(n.p.x-c,n.p.y-c,c,t)),u.push(new fd(n.p.x+c,n.p.y-c,c,t)),u.push(new fd(n.p.x-c,n.p.y+c,c,t)),u.push(new fd(n.p.x+c,n.p.y+c,c,t)),p+=4)}return i&&(console.log(`num probes: ${p}`),console.log(`best distance: ${h.d}`)),h.p}function dd(t,e){return e.max-t.max}class fd{constructor(t,e,i,n){this.p=new v(t,e),this.h=i,this.d=function(t,e){let i=!1,n=1/0;for(let r=0;rt.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,vc(t,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}}const md=7,gd=Number.POSITIVE_INFINITY,yd=Math.sqrt(2);function vd(t,[e,i]){let n=0,r=0;if(i===gd){e<0&&(e=0);const i=e/yd;switch(t){case"top-right":case"top-left":r=i-md;break;case"bottom-right":case"bottom-left":r=-i+md;break;case"bottom":r=-e+md;break;case"top":r=e-md}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}}else{switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":r=i-md;break;case"bottom-right":case"bottom-left":case"bottom":r=-i+md}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}}return[n,r]}function _d(t,e,i,n,r,o,s,a,l,c){t.createArrays(),t.tilePixelRatio=aa/(512*t.overscaling),t.compareText={},t.iconsNeedLinear=!1;const u=t.layers[0].layout,h=t.layers[0]._unevaluatedLayout._values,p={};if("composite"===t.textSizeData.kind){const{minZoom:e,maxZoom:i}=t.textSizeData;p.compositeTextSizes=[h["text-size"].possiblyEvaluate(new wo(e),a),h["text-size"].possiblyEvaluate(new wo(i),a)]}if("composite"===t.iconSizeData.kind){const{minZoom:e,maxZoom:i}=t.iconSizeData;p.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new wo(e),a),h["icon-size"].possiblyEvaluate(new wo(i),a)]}p.layoutTextSize=h["text-size"].possiblyEvaluate(new wo(l+1),a),p.layoutIconSize=h["icon-size"].possiblyEvaluate(new wo(l+1),a),p.textMaxSize=h["text-size"].possiblyEvaluate(new wo(18),a);const d="map"===u.get("text-rotation-alignment")&&"point"!==u.get("symbol-placement"),f=u.get("text-size");for(const o of t.features){const l=u.get("text-font").evaluate(o,{},a).join(","),h=f.evaluate(o,{},a),m=p.layoutTextSize.evaluate(o,{},a),g=(p.layoutIconSize.evaluate(o,{},a),{horizontal:{},vertical:void 0}),y=o.text;let v,_=[0,0];if(y){const n=y.toString(),s=u.get("text-letter-spacing").evaluate(o,{},a)*zh,c=u.get("text-line-height").evaluate(o,{},a)*zh,p=io(n)?s:0,f=u.get("text-anchor").evaluate(o,{},a),v=u.get("text-variable-anchor");if(!v){const t=u.get("text-radial-offset").evaluate(o,{},a);_=t?vd(f,[t*zh,gd]):u.get("text-offset").evaluate(o,{},a).map((t=>t*zh))}let x=d?"center":u.get("text-justify").evaluate(o,{},a);const b="point"===u.get("symbol-placement"),w=b?u.get("text-max-width").evaluate(o,{},a)*zh:1/0,A=o=>{t.allowVerticalPlacement&&eo(n)&&(g.vertical=Pp(y,e,i,r,l,w,c,f,o,p,_,Mp.vertical,!0,m,h))};if(!d&&v){const t="auto"===x?v.map((t=>xd(t))):[x];let n=!1;for(let o=0;o=0||!eo(n)){const t=Pp(y,e,i,r,l,w,c,f,x,p,_,Mp.horizontal,!1,m,h);t&&(g.horizontal[x]=t)}A(b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const e=n[o.icon.name];e&&(v=Vp(r[o.icon.name],u.get("icon-offset").evaluate(o,{},a),u.get("icon-anchor").evaluate(o,{},a)),x=e.sdf,void 0===t.sdfIcons?t.sdfIcons=e.sdf:t.sdfIcons!==e.sdf&&H("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(e.pixelRatio!==t.pixelRatio||0!==u.get("icon-rotate").constantOr(1))&&(t.iconsNeedLinear=!0))}const b=Sd(g.horizontal)||g.vertical;t.iconsInText||(t.iconsInText=!!b&&b.iconsInText),(b||v)&&bd(t,o,g,v,n,p,m,0,_,x,s,a,c)}o&&t.generateCollisionDebugBuffers(l,t.collisionBoxArray)}function xd(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 bd(t,e,i,n,r,o,s,a,l,c,u,h,p){let d=o.textMaxSize.evaluate(e,{},h);void 0===d&&(d=s);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(e,{},h),g=Sd(i.horizontal)||i.vertical,y="globe"===p.name,v=zh,_=s/v,x=t.tilePixelRatio*d/v,w=(P=t.overscaling,t.zoom>18&&P>2&&(P>>=1),Math.max(aa/(512*P),1)*f.get("symbol-spacing")),A=f.get("text-padding")*t.tilePixelRatio,E=f.get("icon-padding")*t.tilePixelRatio,S=b(f.get("text-max-angle")),M="map"===f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),T="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),I=f.get("symbol-placement"),C=w/2;var P;const L=f.get("icon-text-fit");let D;n&&"none"!==L&&(t.allowVerticalPlacement&&i.vertical&&(D=Up(n,i.vertical,L,f.get("icon-text-fit-padding"),m,_)),g&&(n=Up(n,g,L,f.get("icon-text-fit-padding"),m,_)));const R=(s,a,d)=>{if(a.x<0||a.x>=aa||a.y<0||a.y>=aa)return;let f=null;if(y){const{x:t,y:e,z:i}=p.projectTilePoint(a.x,a.y,d);f={anchor:new Gp(t,e,i,0,void 0),up:p.upVector(d,a.x,a.y)}}!function(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_,x,b,w,A,E){const S=t.addToLineVertexArray(e,n);let M,T,I,C,P,L,D,R=0,O=0,k=0,N=0,B=-1,z=-1;const F={};let V=Ls("");const U=i?i.anchor:e;let G=0,j=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,j]=l.layout.get("text-offset").evaluate(x,{},E).map((t=>t*zh)):(G=l.layout.get("text-radial-offset").evaluate(x,{},E)*zh,j=gd),t.allowVerticalPlacement&&r.vertical){const t=r.vertical;if(f)L=Td(t),a&&(D=Td(a));else{const i=l.layout.get("text-rotate").evaluate(x,{},E)+90;I=Md(c,U,e,u,h,p,t,d,i,m),a&&(C=Md(c,U,e,u,h,p,a,y,i))}}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{},E),r="none"!==l.layout.get("icon-text-fit"),s=rd(o,n,w,r),d=a?rd(a,n,w,r):void 0;T=Md(c,U,e,u,h,p,o,y,n),R=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Fh*l.layout.get("icon-size").evaluate(x,{},E)],m[0]>Ad&&H(`${t.layerIds[0]}: Value for "icon-size" is >= ${wd}. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Fh*b.compositeIconSizes[0].evaluate(x,{},E),Fh*b.compositeIconSizes[1].evaluate(x,{},E)],(m[0]>Ad||m[1]>Ad)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= ${wd}. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,_,v,x,!1,i,e,S.lineStartIndex,S.lineLength,-1,A,E),B=t.icon.placedSymbolArray.length-1,d&&(O=4*d.length,t.addSymbols(t.icon,d,m,_,v,x,Mp.vertical,i,e,S.lineStartIndex,S.lineLength,-1,A,E),z=t.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=r.horizontal[n];M||(V=Ls(o.text),f?P=Td(o):M=Md(c,U,e,u,h,p,o,d,l.layout.get("text-rotate").evaluate(x,{},E),m));const a=1===o.positionedLines.length;if(k+=Ed(t,i,e,o,s,l,f,x,m,S,r.vertical?Mp.horizontal:Mp.horizontalOnly,a?Object.keys(r.horizontal):[n],F,B,b,A,E),a)break}r.vertical&&(N+=Ed(t,i,e,r.vertical,s,l,f,x,m,S,Mp.vertical,["vertical"],F,z,b,A,E));let W=-1;const q=(t,e)=>t?Math.max(t,e):e;W=q(P,W),W=q(L,W),W=q(D,W);const X=W>-1?1:0;t.glyphOffsetArray.length>=af.MAX_GLYPHS&&H("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(U.x,U.y,U.z,e.x,e.y,F.right>=0?F.right:-1,F.center>=0?F.center:-1,F.left>=0?F.left:-1,F.vertical>=0?F.vertical:-1,B,z,V,void 0!==M?M:t.collisionBoxArray.length,void 0!==M?M+1:t.collisionBoxArray.length,void 0!==I?I:t.collisionBoxArray.length,void 0!==I?I+1:t.collisionBoxArray.length,void 0!==T?T:t.collisionBoxArray.length,void 0!==T?T+1:t.collisionBoxArray.length,C||t.collisionBoxArray.length,C?C+1:t.collisionBoxArray.length,u,k,N,R,O,X,0,G,j,W)}(t,a,f,s,i,n,r,D,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,A,M,l,0,E,T,m,e,o,c,u,h)};if("line"===I)for(const r of Qp(e.geometry,0,0,aa,aa)){const e=Zp(r,w,S,i.vertical||g,n,v,x,t.overscaling,aa);for(const i of e)g&&Id(t,g.text,C,i)||R(r,i,h)}else if("line-center"===I){for(const t of e.geometry)if(t.length>1){const e=Xp(t,S,i.vertical||g,n,v,x);e&&R(t,e,h)}}else if("Polygon"===e.type)for(const t of Au(e.geometry,0)){const e=pd(t,16);R(t[0],new Gp(e.x,e.y,0,0,void 0),h)}else if("LineString"===e.type)for(const t of e.geometry)R(t,new Gp(t[0].x,t[0].y,0,0,void 0),h);else if("Point"===e.type)for(const t of e.geometry)for(const e of t)R([e],new Gp(e.x,e.y,0,0,void 0),h)}const wd=255,Ad=wd*Fh;function Ed(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g){const y=function(t,e,i,n,r,o,s,a){const l=[];if(0===e.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=function(t){const e=t[0],i=t[1],n=e*i;return n>0?[e,-i]:n<0?[-e,i]:0===e?[i,e]:[i,-e]}(i);let h=Math.abs(e.top-e.bottom);for(const t of e.positionedLines)h-=t.lineOffset;const p=e.positionedLines.length,d=h/p;let f=e.top-i[1];for(let t=0;tAd&&H(`${t.layerIds[0]}: Value for "text-size" is >= ${wd}. Reduce your "text-size".`)):"composite"===_.kind&&(x=[Fh*f.compositeTextSizes[0].evaluate(a,{},g),Fh*f.compositeTextSizes[1].evaluate(a,{},g)],(x[0]>Ad||x[1]>Ad)&&H(`${t.layerIds[0]}: Value for "text-size" is >= ${wd}. Reduce your "text-size".`)),t.addSymbols(t.text,y,x,l,s,a,u,e,i,c.lineStartIndex,c.lineLength,d,m,g);for(const e of h)p[e]=t.text.placedSymbolArray.length-1;return 4*y.length}function Sd(t){for(const e in t)return t[e];return null}function Md(t,e,i,n,r,o,s,a,l,c){let u=s.top,h=s.bottom,p=s.left,d=s.right;const f=s.collisionPadding;if(f&&(p-=f[0],u-=f[1],d+=f[2],h+=f[3]),l){const t=new v(p,u),e=new v(d,u),i=new v(p,h),n=new v(d,h),r=b(l);let o=new v(0,0);c&&(o=new v(c[0],c[1])),t._rotateAround(r,o),e._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),p=Math.min(t.x,e.x,i.x,n.x),d=Math.max(t.x,e.x,i.x,n.x),u=Math.min(t.y,e.y,i.y,n.y),h=Math.max(t.y,e.y,i.y,n.y)}return t.emplaceBack(e.x,e.y,e.z,i.x,i.y,p,u,d,h,a,n,r,o),t.length-1}function Td(t){t.collisionPadding&&(t.top-=t.collisionPadding[1],t.bottom+=t.collisionPadding[3]);const e=t.bottom-t.top;return e>0?Math.max(10,e):null}function Id(t,e,i,n){const r=t.compareText;if(e in r){const t=r[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])_&&(x(t,c,n,r,a,l),x(c,i,a,l,o,s))}x(h,p,n,o,r,o),x(p,d,r,o,r,s),x(d,f,r,s,n,s),x(f,h,n,s,n,o),m-=_,g-=_,y+=_,v+=_;const b=1/Math.max(y-m,v-g);return{scale:b,x:m*b,y:g*b,x2:y*b,y2:v*b,projection:e}}const Ld=da(new Float32Array(16));class Dd{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,e){return{x:0,y:0,z:0}}unproject(t,e){return new Gl(0,0)}projectTilePoint(t,e,i){return{x:t,y:e,z:0}}locationPoint(t,e,i=!0){return t._coordinatePoint(t.locationCoordinate(e),i)}pixelsPerMeter(t,e){return ql(1,t)*e}pixelSpaceConversion(t,e,i){return 1}farthestPixelDistance(t){return Cd(t,t.pixelsPerMeter)}pointCoordinate(t,e,i,n){const r=t.horizonLineFromTop(!1),o=new v(e,Math.max(r,i));return t.rayIntersectionCoordinate(t.pointRayIntersection(o,n))}pointCoordinate3D(t,e,i){const n=new v(e,i);if(t.elevation)return t.elevation.pointCoordinate(n);{const e=this.pointCoordinate(t,n.x,n.y,0);return[e.x,e.y,e.z]}}isPointAboveHorizon(t,e){if(t.elevation)return!this.pointCoordinate3D(t,e.x,e.y);const i=t.horizonLineFromTop();return e.y0?e<-Ud+i&&(e=-Ud+i):e>Ud-i&&(e=Ud-i);const o=r/Math.pow(Gd(e),n);let s=o*Math.sin(n*t),a=r-o*Math.cos(n*t);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,z:0}}unproject(t,e){t=(2*t-.5)*Math.PI,this.southernCenter&&(e=1-e),e=(2*(1-e)-.5)*Math.PI;const{n:i,f:n}=this,r=n-e,o=Math.sign(r),s=Math.sign(i)*Math.sqrt(t*t+r*r);let a=Math.atan2(t,Math.abs(r))*o;r*i<0&&(a-=Math.PI*Math.sign(t)*o);const l=T(w(a/i)+this.center[0],-180,180),c=T(w(2*Math.atan(Math.pow(n/s,1/i))-Ud),-Ql,Ql);return new Gl(l,this.southernCenter?-c:c)}}class Hd extends Dd{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,e){return{x:Hl(t),y:Wl(e),z:0}}unproject(t,e){const i=Xl(t),n=Zl(e);return new Gl(i,n)}}const Wd=b(Ql);class qd extends Dd{project(t,e){const i=(e=b(e))*e,n=i*i;return{x:.5*((t=b(t))*(.8707-.131979*i+n*(n*(.003971*i-.001529*n)-.013791))/Math.PI+.5),y:1-.5*(e*(1.007226+i*(.015085+n*(.028874*i-.044475-.005916*n)))/Math.PI+1),z:0}}unproject(t,e){t=(2*t-.5)*Math.PI;let i=e=(2*(1-e)-1)*Math.PI,n=25,r=0,o=i*i;do{o=i*i;const t=o*o;r=(i*(1.007226+o*(.015085+t*(.028874*o-.044475-.005916*t)))-e)/(1.007226+o*(.045255+t*(.259866*o-.311325-.005916*11*t))),i=T(i-r,-Wd,Wd)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const s=T(w(t/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=w(i);return new Gl(s,a)}}const Xd=b(Ql);class Zd extends Dd{project(t,e){e=b(e),t=b(t);const i=Math.cos(e),n=2/Math.PI,r=Math.acos(i*Math.cos(t/2)),o=Math.sin(r)/r,s=.5*(t*n+2*i*Math.sin(t/2)/o)||0,a=.5*(e+Math.sin(e)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(t,e){let i=t=(2*t-.5)*Math.PI,n=e=(2*(1-e)-1)*Math.PI,r=25;const o=1e-6;let s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,h=Math.cos(i/2),p=Math.sin(i/2),d=2*h*p,f=p*p,m=1-u*h*h,g=m?1/m:0,y=m?Math.acos(r*h)*Math.sqrt(1/m):0,v=.5*(2*y*r*p+2*i/Math.PI)-t,_=.5*(y*o+n)-e,x=.5*g*(u*f+y*r*h*c)+1/Math.PI,b=g*(d*l/4-y*o*p),w=.125*g*(l*p-y*o*u*d),A=.5*g*(c*h+y*f*r)+.5,E=b*w-A*x;s=(_*b-v*A)/E,a=(v*w-_*x)/E,i=T(i-s,-Math.PI,Math.PI),n=T(n-a,-Xd,Xd)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new Gl(w(i),w(n))}}class Yd extends Dd{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(b(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,e){const{scale:i,cosPhi:n}=this;return{x:b(t)*n*i+.5,y:-Math.sin(b(e))/n*i+.5,z:0}}unproject(t,e){const{scale:i,cosPhi:n}=this,r=-(e-.5)/i,o=T(w((t-.5)/i)/n,-180,180),s=Math.asin(T(r*n,-1,1)),a=T(w(s),-Ql,Ql);return new Gl(o,a)}}class Qd extends Hd{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,e,i){const n=Tl(t,e,i);return Ba(n,n,Pl(vl(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(t,e){const i=Ml(e.lat,e.lng),n=Oa([],i),r=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(e),t._centerAltitude):t._centerAltitude;Ra(i,i,n,ql(1,0)*aa*r);const o=da(new Float64Array(16));return ma(o,t.pixelMatrix,t.globeMatrix),Ba(i,i,o),new v(i[0],i[1])}pixelsPerMeter(t,e){return ql(1,0)*e}pixelSpaceConversion(t,e,i){const n=ql(1,t)*e,r=Li(ql(1,45)*e,n,i);return this.pixelsPerMeter(t,e)/r}createTileMatrix(t,e,i){const n=Ll(vl(i.canonical));return ma(new Float64Array(16),t.globeMatrix,n)}createInversionMatrix(t,e){const{center:i}=t,n=Pl(vl(e));return _a(n,n,b(i.lng)),va(n,n,b(i.lat)),ya(n,n,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(t,e,i,n){return ml(t,e,i,!0)||new Kl(0,0)}pointCoordinate3D(t,e,i){const n=this.pointCoordinate(t,e,i,0);return[n.x,n.y,n.z]}isPointAboveHorizon(t,e){return!ml(t,e.x,e.y,!1)}farthestPixelDistance(t){const e=function(t,e){const i=t.cameraToCenterDistance,n=t._centerAltitude*e,r=t._camera,o=t._camera.forward(),s=Ta([],Da([],o,-i),[0,0,n]),a=t.worldSize/(2*Math.PI),l=[0,0,-a],c=t.width/t.height,u=Math.tan(t.fovAboveCenter),h=Da([],r.up(),u),p=Da([],r.right(),u*c),d=Oa([],Ta([],Ta([],o,h),p)),f=[];let m;if(new el(s,d).closestPointOnSphere(l,a,f)){const e=Ta([],f,l),i=Va([],e,s);m=Math.cos(t.fovAboveCenter)*Sa(i)}else{const t=Va([],s,l),e=Va([],l,s);Oa(e,e);const i=Sa(t)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(ka(o,e));m*=Math.cos(n)}return 1.01*m}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),i=Rl(t.zoom);if(i>0){const n=Cd(t,ql(1,t.center.lat)*t.worldSize),r=t.worldSize/(2*Math.PI),o=Math.max(t.width,t.height)/t.worldSize*Math.PI;return Li(e,n+r*(1-Math.cos(o)),Math.pow(i,10))}return e}upVector(t,e,i){return Tl(e,i,t,1)}upVectorScale(t){return{metersToTile:fl(Il(vl(t)))}}}function Jd(t){const e=t.parallels,i=!!e&&Math.abs(e[0]+e[1])<.01;switch(t.name){case"mercator":return new Hd(t);case"equirectangular":return new Vd(t);case"naturalEarth":return new qd(t);case"equalEarth":return new Fd(t);case"winkelTripel":return new Zd(t);case"albers":return i?new Yd(t):new Rd(t);case"lambertConformalConic":return i?new Yd(t):new jd(t);case"globe":return new Qd(t)}throw new Error(`Invalid projection name: ${t.name}`)}const Kd=Xu.types,$d=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function tf(t,e,i,n,r,o,s,a,l,c,u,h,p){const d=a?Math.min(Ad,Math.round(a[0])):0,f=a?Math.min(Ad,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*n),Math.round(32*r),o,s,(d<<1)+(l?1:0),f,16*c,16*u,256*h,256*p)}function ef(t,e,i,n,r,o,s){t.emplaceBack(e,i,n,r,o,s)}function nf(t,e,i,n,r){t.emplaceBack(e,i,n,r),t.emplaceBack(e,i,n,r),t.emplaceBack(e,i,n,r),t.emplaceBack(e,i,n,r)}function rf(t){for(const e of t.sections)if(lo(e.text))return!0;return!1}class of{constructor(t){this.layoutVertexArray=new Yo,this.indexArray=new ns,this.programConfigurations=t,this.segments=new sa,this.dynamicLayoutVertexArray=new Wo,this.opacityVertexArray=new Jo,this.placedSymbolArray=new ms,this.globeExtVertexArray=new Qo}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Lh.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Rh.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,$d,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Dh.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Yr(of,"SymbolBuffers");class sf{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new sa,this.collisionVertexArray=new es,this.collisionVertexArrayExt=new is}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Oh.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,kh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Yr(sf,"CollisionBuffers");class af{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=da([]),this.placementViewportMatrix=da([]);const e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Vh(this.zoom,e["text-size"]),this.iconSizeData=Vh(this.zoom,e["icon-size"]);const i=this.layers[0].layout,n=i.get("symbol-sort-key"),r=i.get("symbol-z-order");this.canOverlap=i.get("text-allow-overlap")||i.get("icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&void 0!==n.constantOr(1),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map((t=>Mp[t])),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new of(new Qs(this.layers,this.zoom,(t=>/^text/.test(t)))),this.icon=new of(new Qs(this.layers,this.zoom,(t=>/^icon/.test(t)))),this.glyphOffsetArray=new vs,this.lineVertexArray=new _s,this.symbolInstances=new ys}calculateGlyphDependencies(t,e,i,n,r){for(let i=0;i0)&&("constant"!==a.value.kind||a.value.value.length>0),h="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,p=o.get("symbol-sort-key");if(this.features=[],!u&&!h)return;const d=e.iconDependencies,f=e.glyphDependencies,m=e.availableImages,g=new wo(this.zoom);for(const{feature:e,id:l,index:c,sourceLayerIndex:y}of t){const t=r._featureFilter.needGeometry,v=ac(e,t);if(!r._featureFilter.filter(g,v,i))continue;if(t||(v.geometry=sc(e,i,n)),s&&1!==e.type&&i.z<=5){const t=v.geometry,e=.98078528056,n=(t,n)=>ka(Tl(t.x,t.y,i,1),Tl(n.x,n.y,i,1))=0;for(const i of _.sections)if(i.image)d[i.image.name]=!0;else{const n=eo(_.toString()),r=i.fontStack||t,o=f[r]=f[r]||{};this.calculateGlyphDependencies(i.text,o,e,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let r=0;function o(e){n.push(t[e]),r++}function s(t,e,r){const o=i[t];return delete i[t],i[e]=o,n[o].geometry[0].pop(),n[o].geometry[0]=n[o].geometry[0].concat(r[0]),o}function a(t,i,r){const o=e[i];return delete e[i],e[t]=o,n[o].geometry[0].shift(),n[o].geometry[0]=r[0].concat(n[o].geometry[0]),o}function l(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let c=0;ct.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i,n){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,i,n),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,i,n))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(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}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Jd(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment)for(const{x:t,y:i}of e)this.lineVertexArray.emplaceBack(t,i);return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,n,r,o,s,a,l,c,u,h,p,d){const f=t.indexArray,m=t.layoutVertexArray,g=t.globeExtVertexArray,y=t.segments.prepareSegment(4*e.length,m,f,this.canOverlap?o.sortKey:void 0),v=this.glyphOffsetArray.length,_=y.vertexLength,x=this.allowVerticalPlacement&&s===Mp.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let n=0;n=0?e.rightJustifiedTextSymbolIndex:e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.leftJustifiedTextSymbolIndex>=0?e.leftJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex>=0?e.verticalPlacedTextSymbolIndex:n),o=Uh(this.textSizeData,t,r)/zh;return this.tilePixelRatio*o}getSymbolInstanceIconSize(t,e,i){const n=this.icon.placedSymbolArray.get(i),r=Uh(this.iconSizeData,t,n);return this.tilePixelRatio*r}_commitDebugCollisionVertexUpdate(t,e,i){t.emplaceBack(e,-i,-i),t.emplaceBack(e,i,-i),t.emplaceBack(e,i,i),t.emplaceBack(e,-i,i)}_updateTextDebugCollisionBoxes(t,e,i,n,r,o){for(let s=n;s0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;en[t]-n[e]||r[e]-r[t])),o}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];i&&i.sortKey===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){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(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=e;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),n>=0&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Yr(af,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),af.MAX_GLYPHS=65535,af.addDynamicAttributes=nf;const lf=new Oo({"symbol-placement":new Lo(te.layout_symbol["symbol-placement"]),"symbol-spacing":new Lo(te.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Lo(te.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Do(te.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Lo(te.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Lo(te.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Lo(te.layout_symbol["icon-ignore-placement"]),"icon-optional":new Lo(te.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Lo(te.layout_symbol["icon-rotation-alignment"]),"icon-size":new Do(te.layout_symbol["icon-size"]),"icon-text-fit":new Lo(te.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Lo(te.layout_symbol["icon-text-fit-padding"]),"icon-image":new Do(te.layout_symbol["icon-image"]),"icon-rotate":new Do(te.layout_symbol["icon-rotate"]),"icon-padding":new Lo(te.layout_symbol["icon-padding"]),"icon-keep-upright":new Lo(te.layout_symbol["icon-keep-upright"]),"icon-offset":new Do(te.layout_symbol["icon-offset"]),"icon-anchor":new Do(te.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Lo(te.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Lo(te.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Lo(te.layout_symbol["text-rotation-alignment"]),"text-field":new Do(te.layout_symbol["text-field"]),"text-font":new Do(te.layout_symbol["text-font"]),"text-size":new Do(te.layout_symbol["text-size"]),"text-max-width":new Do(te.layout_symbol["text-max-width"]),"text-line-height":new Do(te.layout_symbol["text-line-height"]),"text-letter-spacing":new Do(te.layout_symbol["text-letter-spacing"]),"text-justify":new Do(te.layout_symbol["text-justify"]),"text-radial-offset":new Do(te.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Lo(te.layout_symbol["text-variable-anchor"]),"text-anchor":new Do(te.layout_symbol["text-anchor"]),"text-max-angle":new Lo(te.layout_symbol["text-max-angle"]),"text-writing-mode":new Lo(te.layout_symbol["text-writing-mode"]),"text-rotate":new Do(te.layout_symbol["text-rotate"]),"text-padding":new Lo(te.layout_symbol["text-padding"]),"text-keep-upright":new Lo(te.layout_symbol["text-keep-upright"]),"text-transform":new Do(te.layout_symbol["text-transform"]),"text-offset":new Do(te.layout_symbol["text-offset"]),"text-allow-overlap":new Lo(te.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Lo(te.layout_symbol["text-ignore-placement"]),"text-optional":new Lo(te.layout_symbol["text-optional"])});var cf={paint:new Oo({"icon-opacity":new Do(te.paint_symbol["icon-opacity"]),"icon-color":new Do(te.paint_symbol["icon-color"]),"icon-halo-color":new Do(te.paint_symbol["icon-halo-color"]),"icon-halo-width":new Do(te.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Do(te.paint_symbol["icon-halo-blur"]),"icon-translate":new Lo(te.paint_symbol["icon-translate"]),"icon-translate-anchor":new Lo(te.paint_symbol["icon-translate-anchor"]),"text-opacity":new Do(te.paint_symbol["text-opacity"]),"text-color":new Do(te.paint_symbol["text-color"],{runtimeType:pe,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Do(te.paint_symbol["text-halo-color"]),"text-halo-width":new Do(te.paint_symbol["text-halo-width"]),"text-halo-blur":new Do(te.paint_symbol["text-halo-blur"]),"text-translate":new Lo(te.paint_symbol["text-translate"]),"text-translate-anchor":new Lo(te.paint_symbol["text-translate-anchor"])}),layout:lf};class uf{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:le,this.defaultValue=t}evaluate(t){if(t.formattedSection){const 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}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}Yr(uf,"FormatSectionOverride",{omit:["defaultValue"]});class hf extends na{constructor(t){super(t,cf)}recalculate(t,e){super.recalculate(t,e),"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"));const i=this.layout.get("text-writing-mode");if(i){const t=[];for(const e of i)t.indexOf(e)<0&&t.push(e);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,n){const r=this.layout.get(t).evaluate(e,{},i,n),o=this._unevaluatedLayout._values[t];return o.isDataDriven()||Yn(o.value)||!r?r:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>i in t?String(t[i]):""))}(e.properties,r)}createBucket(t){return new af(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of cf.paint.overridableProperties){if(!hf.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new uf(e),n=new Zn(i,e.property.specification);let r=null;r="constant"===e.value.kind||"source"===e.value.kind?new Jn("source",n):new Kn("composite",n,e.value.zoomStops,e.value._interpolationType),this.paint._values[t]=new Co(e.property,r,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&hf.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=cf.paint.properties[e];let r=!1;const o=t=>{for(const e of t)if(n.overrides&&n.overrides.hasOverride(e))return void(r=!0)};if("constant"===i.value.kind&&i.value.value instanceof Oe)o(i.value.value.sections);else if("source"===i.value.kind){const t=e=>{r||(e instanceof Ue&&ze(e.value)===ge?o(e.value.sections):e instanceof qe?o(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return r}getProgramConfiguration(t){return new Ys(this,t)}}var pf={paint:new Oo({"background-color":new Lo(te.paint_background["background-color"]),"background-pattern":new Lo(te.paint_background["background-pattern"]),"background-opacity":new Lo(te.paint_background["background-opacity"])})},df={paint:new Oo({"raster-opacity":new Lo(te.paint_raster["raster-opacity"]),"raster-hue-rotate":new Lo(te.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Lo(te.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Lo(te.paint_raster["raster-brightness-max"]),"raster-saturation":new Lo(te.paint_raster["raster-saturation"]),"raster-contrast":new Lo(te.paint_raster["raster-contrast"]),"raster-resampling":new Lo(te.paint_raster["raster-resampling"]),"raster-fade-duration":new Lo(te.paint_raster["raster-fade-duration"])})};class ff extends na{constructor(t){super(t,{}),this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}isLayerDraped(){return void 0!==this.implementation.renderToTile}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var mf={paint:new Oo({"sky-type":new Lo(te.paint_sky["sky-type"]),"sky-atmosphere-sun":new Lo(te.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new Lo(te.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new Lo(te.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new Lo(te.paint_sky["sky-gradient-radius"]),"sky-gradient":new Ro(te.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new Lo(te.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new Lo(te.paint_sky["sky-atmosphere-color"]),"sky-opacity":new Lo(te.paint_sky["sky-opacity"])})};function gf(t,e,i){const n=[0,0,1],r=Xa([]);return Ya(r,r,i?-b(t)+Math.PI:b(t)),Za(r,r,-b(e)),za(n,n,r),Oa(n,n)}const yf={circle:class extends na{constructor(t){super(t,Ic)}createBucket(t){return new uc(t)}queryRadius(t){const e=t;return Ac("circle-radius",this,e)+Ac("circle-stroke-width",this,e)+Ec(this.paint.get("circle-translate"))}queryIntersectsFeature(t,e,i,n,r,o,s,a){const l=Mc(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i);return Cc(t,n,o,s,a,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,c)}getProgramIds(){return["circle"]}getProgramConfiguration(t){return new Ys(this,t)}},heatmap:class extends na{createBucket(t){return new Oc(t)}constructor(t){super(t,Vc),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Uc({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(t){return Ac("heatmap-radius",this,t)}queryIntersectsFeature(t,e,i,n,r,o,s,a){const l=this.paint.get("heatmap-radius").evaluate(e,i);return Cc(t,n,o,s,a,!0,!0,new v(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(t){return new Ys(this,t)}},hillshade:class extends na{constructor(t){super(t,Gc)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends na{constructor(t){super(t,Cu)}getProgramIds(){const t=this.paint.get("fill-pattern"),e=t&&t.constantOr(1),i=[e?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&i.push(e&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),i}getProgramConfiguration(t){return new Ys(this,t)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Tu(t)}queryRadius(){return Ec(this.paint.get("fill-translate"))}queryIntersectsFeature(t,e,i,n,r,o){return!t.queryGeometry.isAboveHorizon&&dc(Sc(t.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),n)}isTileClipped(){return!0}},"fill-extrusion":class extends na{constructor(t){super(t,uh)}createBucket(t){return new th(t)}queryRadius(){return Ec(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(t){return new Ys(this,t)}queryIntersectsFeature(t,e,i,n,r,o,s,a,l){const c=Mc(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,t.pixelToTileUnitsFactor),u=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),p=[0,0],d=a&&o.elevation,f=o.elevation?o.elevation.exaggeration():1,m=t.tile.getBucket(this);if(d&&m instanceof th){const t=m.centroidVertexArray,e=l+1;et.polygon)).flat());const g=d?a:null,[y,_]=function(t,e,i,n,r,o,s,a,l,c,u){return"globe"===t.projection.name?function(t,e,i,n,r,o,s,a,l,c,u){const h=[],p=[],d=t.projection.upVectorScale(u,t.center.lat,t.worldSize).metersToTile,f=[0,0,0,1],m=[0,0,0,1],g=(t,e,i,n)=>{t[0]=e,t[1]=i,t[2]=n,t[3]=1},y=ah();i>0&&(i+=y),n+=y;for(const y of e){const e=[],v=[];for(const h of y){const p=h.x+r.x,y=h.y+r.y,_=t.projection.projectTilePoint(p,y,u),x=t.projection.upVector(u,h.x,h.y);let b=i,w=n;if(s){const t=_h(p,y,i,n,s,a,l,c);b+=t.base,w+=t.top}0!==i?g(f,_.x+x[0]*d*b,_.y+x[1]*d*b,_.z+x[2]*d*b):g(f,_.x,_.y,_.z),g(m,_.x+x[0]*d*w,_.y+x[1]*d*w,_.z+x[2]*d*w),Ba(f,f,o),Ba(m,m,o),e.push(new gh(f[0],f[1],f[2])),v.push(new gh(m[0],m[1],m[2]))}h.push(e),p.push(v)}return[h,p]}(t,e,i,n,r,o,s,a,l,c,u):s?function(t,e,i,n,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const p of t){const t=[],d=[];for(const c of p){const u=c.x+n.x,p=c.y+n.y,f=_h(u,p,e,i,o,s,a,l);h[0]=u,h[1]=p,h[2]=f.base,h[3]=1,Wa(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new gh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=p,h[2]=f.top,h[3]=1,Wa(h,h,r),h[3]=Math.max(h[3],1e-5);const g=new gh(h[0]/h[3],h[1]/h[3],h[2]/h[3]);t.push(m),d.push(g)}c.push(t),u.push(d)}return[c,u]}(e,i,n,r,o,s,a,l,c):function(t,e,i,n,r){const o=[],s=[],a=r[8]*e,l=r[9]*e,c=r[10]*e,u=r[11]*e,h=r[8]*i,p=r[9]*i,d=r[10]*i,f=r[11]*i;for(const e of t){const t=[],i=[];for(const o of e){const e=o.x+n.x,s=o.y+n.y,m=r[0]*e+r[4]*s+r[12],g=r[1]*e+r[5]*s+r[13],y=r[2]*e+r[6]*s+r[14],v=r[3]*e+r[7]*s+r[15],_=m+a,x=g+l,b=y+c,w=Math.max(v+u,1e-5),A=m+h,E=g+p,S=y+d,M=Math.max(v+f,1e-5);t.push(new gh(_/w,x/w,b/w)),i.push(new gh(A/M,E/M,S/M))}o.push(t),s.push(i)}return[o,s]}(e,i,n,r,o)}(o,n,h,u,c,s,g,p,f,o.center.lat,t.tileID.canonical),x=t.queryGeometry;return function(t,e,i){let n=1/0;dc(i,e)&&(n=vh(i,e[0]));for(let r=0;r=3)for(let e=0;e{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout((()=>{this._triggered=!1,this._callback()}),0))}remove(){this._channel=void 0,this._callback=()=>{}}}class xf{constructor(){this.tasks={},this.taskQueue=[],z(["process"],this),this.invoker=new _f(this.process),this.nextId=0}add(t,e){const i=this.nextId++,n=function({type:t,isSymbolTile:e,zoom:i}){return i=i||0,"message"===t?0:"maybePrepare"!==t||e?"parseTile"!==t||e?"parseTile"===t&&e?300-i:"maybePrepare"===t&&e?400-i:500:200-i:100-i}(e);if(0===n){X();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[i]={fn:t,metadata:e,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){X();try{if(this.taskQueue=this.taskQueue.filter((t=>!!this.tasks[t])),!this.taskQueue.length)return;const t=this.pick();if(null===t)return;const e=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!e)return;e.fn()}finally{}}pick(){let t=null,e=1/0;for(let i=0;i>=1)>1;){const t=i+r>>1,l=n+o>>1;1&e?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=t,a=l}const l=4*t;Mf[l+0]=i,Mf[l+1]=n,Mf[l+2]=r,Mf[l+3]=o}const Tf=new Uint16Array(2178),If=new Uint8Array(1089),Cf=new Uint16Array(1089);function Pf(t){return 0===t?-.03125:32===t?.03125:0}var Lf=Fo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Df={type:2,extent:aa,loadGeometry:()=>[[new v(0,0),new v(aa+1,0),new v(aa+1,aa+1),new v(0,aa+1),new v(0,0)]]};class Rf{constructor(t,e,i,n,r){this.tileID=t,this.uid=O(),this.uses=0,this.tileSize=e,this.tileZoom=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=r,this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection)}registerFadeDuration(t){const e=t+this.timeAdded;ee.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=n}}return i}(t.buckets,e.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const e=this.buckets[t];if(e instanceof af){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const e=this.buckets[t];if(e instanceof af&&e.hasRTLText){this.hasRTLText=!0,bo.isLoading()||bo.isLoaded()||"deferred"!==_o()||xo();break}}this.queryPadding=0;for(const t in this.buckets){const i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new ds}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new vf(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new vf(t,this.glyphAtlasImage,e.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new vf(t,this.lineAtlas.image,e.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,n,r,o,s,a){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:n,pixelPosMatrix:s,transform:o,params:r,tileTransform:this.tileTransform},t,e,i):{}}querySourceFeatures(t,e){const i=this.latestFeatureIndex;if(!i||!i.rawTileData)return;const n=i.loadVTLayers(),r=e?e.sourceLayer:"",o=n._geojsonTileLayer||n[r];if(!o)return;const s=hr(e&&e.filter),{z:a,x:l,y:c}=this.tileID.canonical,u={z:a,x:l,y:c};for(let e=0;et)i=!1;else if(e)if(this.expirationTime=0;t--){const e=4*t,i=Mf[e+0],n=Mf[e+1],r=Mf[e+2],o=Mf[e+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,u=n*Sf+i,h=o*Sf+r,p=a*Sf+s,d=Math.hypot((Tf[2*u+0]+Tf[2*h+0])/2-Tf[2*p+0],(Tf[2*u+1]+Tf[2*h+1])/2-Tf[2*p+1])>=16;If[p]=If[p]||(d?1:0),t<1022&&(If[p]=If[p]||If[(n+c>>1)*Sf+(i+l>>1)]||If[(o+c>>1)*Sf+(r+l>>1)])}const r=new jo,o=new ns;let s=0;function a(t,e){const i=e*Sf+t;return 0===Cf[i]&&(r.emplaceBack(Tf[2*i+0],Tf[2*i+1],t*aa/Ef,e*aa/Ef),Cf[i]=++s),Cf[i]-1}function l(t,e,i,n,r,s){const c=t+i>>1,u=e+n>>1;if(Math.abs(t-r)+Math.abs(e-s)>1&&If[u*Sf+c])l(r,s,t,e,c,u),l(i,n,r,s,c,u);else{const l=a(t,e),c=a(i,n),u=a(r,s);o.emplaceBack(l,c,u)}}return l(0,0,Ef,Ef,Ef,0),l(Ef,Ef,0,0,0,Ef),{vertices:r,indices:o}}(this.tileID.canonical,e);n=t.vertices,r=t.indices}else{n=new jo,r=new ns;for(const{x:t,y:e}of i)n.emplaceBack(t,e,0,0);const t=vu(n.int16,void 0,4);for(let e=0;e0&&(s=fa(new Float64Array(16),e.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,e,r,s,o),this._makeGlobeTileDebugTextBuffer(t,n,e,r,s,o)}_globePoint(t,e,i,n,r,o,s){let a=Tl(t,e,i);if(o){const r=1<.5?h=-1:u<-.5&&(h=1);let p=(t/aa+i.x)/r+h,d=(e/aa+i.y)/r;p=(p-l)*n._pixelsPerMercatorPixel+l,d=(d-c)*n._pixelsPerMercatorPixel+c;const f=[p*n.worldSize,d*n.worldSize,0];Ba(f,f,o),a=_l(a,f,s)}return Ba(a,a,r)}_makeGlobeTileDebugBorderBuffer(t,e,i,n,r,o){const s=new Uo,a=new us,l=new Go,c=(t,c,u,h,p)=>{const d=(u-t)/(p-1),f=(h-c)/(p-1),m=s.length;for(let u=0;uu*t+e;for(let t=0;te[s])return null}else{const a=1/n[s];let l=(t[s]-i[s])*a,c=(e[s]-i[s])*a;if(l>c){const t=l;l=c,c=t}if(l>r&&(r=l),co)return null}return r}function Bf(t,e,i,n,r,o,s,a,l,c,u){const h=n-t,p=r-e,d=o-i,f=s-t,m=a-e,g=l-i,y=u[1]*g-u[2]*m,v=u[2]*f-u[0]*g,_=u[0]*m-u[1]*f,x=h*y+p*v+d*_;if(Math.abs(x)<1e-15)return null;const b=1/x,w=c[0]-t,A=c[1]-e,E=c[2]-i,S=(w*y+A*v+E*_)*b;if(S<0||S>1)return null;const M=A*d-E*p,T=E*h-w*d,I=w*p-A*h,C=(u[0]*M+u[1]*T+u[2]*I)*b;return C<0||S+C>1?null:(f*M+m*T+g*I)*b}function zf(t,e,i){return(t-e)/(i-e)}function Ff(t,e,i,n,r,o,s,a,l){const c=1<{const o=n?1:0,s=(t+1)*i-o,a=e*i,l=(e+1)*i-o;r[0]=t*i,r[1]=a,r[2]=s,r[3]=l};let s=new kf(n);const a=[];for(let e=0;e=1;n/=2){const t=i[i.length-1];s=new kf(n);for(let e=0;e0;){const{idx:a,t:d,nodex:f,nodey:m,depth:g}=p.pop();if(this.leaves[a]){Ff(f,m,g,t,e,i,n,u,h);const a=1<=t[2])return d}continue}let y=0;for(let p=0;p=l[c[i]]&&(c.splice(i,0,p),e=!0);e||(c[y]=p),y++}}for(let t=0;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)}static pack(t,e){const i=[0,0,0,0],n=qf.getUnpackVector(e);let r=Math.floor((t+n[3])/n[2]);return i[2]=r%256,r=Math.floor(r/256),i[1]=r%256,r=Math.floor(r/256),i[0]=r,i}getPixels(){return new Fc({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,r=e*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(e){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-e*this.dim,l=-i*this.dim;for(let e=o;e{this.remove(t,r)}),i)),this.data[n].push(r),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const 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}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),r=this.data[i][n];return this.data[i].splice(n,1),r.timeout&&clearTimeout(r.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(r.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}}class Zf{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}Zf.ReadOnly=!1,Zf.ReadWrite=!0,Zf.disabled=new Zf(519,Zf.ReadOnly,[0,1]);const Yf=7680;class Qf{constructor(t,e,i,n,r,o){this.test=t,this.ref=e,this.mask=i,this.fail=n,this.depthFail=r,this.pass=o}}Qf.disabled=new Qf({func:519,mask:0},0,0,Yf,Yf,Yf);class Jf{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}Jf.Replace=[1,0],Jf.disabled=new Jf(Jf.Replace,Le.transparent,[!1,!1,!1,!1]),Jf.unblended=new Jf(Jf.Replace,Le.transparent,[!0,!0,!0,!0]),Jf.alphaBlended=new Jf([1,771],Le.transparent,[!0,!0,!0,!0]);const Kf=1029,$f=2305;class tm{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}tm.disabled=new tm(!1,Kf,$f),tm.backCCW=new tm(!0,Kf,$f),tm.backCW=new tm(!0,Kf,2304),tm.frontCW=new tm(!0,1028,2304),tm.frontCCW=new tm(!0,1028,$f);class em extends $t{constructor(t,e,i){super(),this.id=t,this._onlySymbols=i,e.on("data",(t=>{"source"===t.dataType&&"metadata"===t.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===t.dataType&&"content"===t.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))})),e.on("error",(()=>{this._sourceErrored=!0})),this._source=e,this._tiles={},this._cache=new Xf(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Of,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(t){this.map=t,this._minTileCacheSize=void 0===this._minTileCacheSize&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const t in this._tiles){const e=this._tiles[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,e){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,e)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,(()=>{}))}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,(()=>{}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const e in this._tiles){const i=this._tiles[e];i.upload(t),i.prepare(this.map.style.imageManager)}}getIds(){return L(this._tiles).map((t=>t.tileID)).sort(im).map((t=>t.key))}getRenderableIds(t){const e=[];for(const i in this._tiles)this._isIdRenderable(+i,t)&&e.push(this._tiles[i]);return t?e.sort(((t,e)=>{const i=t.tileID,n=e.tileID,r=new v(i.canonical.x,i.canonical.y)._rotate(this.transform.angle),o=new v(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return i.overscaledZ-n.overscaledZ||o.y-r.y||o.x-r.x})).map((t=>t.tileID.key)):e.map((t=>t.tileID)).sort(im).map((t=>t.key))}hasRenderableParent(t){const e=this.findLoadedParent(t,0);return!!e&&this._isIdRenderable(e.tileID.key)}_isIdRenderable(t,e){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(e||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)"errored"!==this._tiles[t].state&&this._reloadTile(+t,"reloading")}}_reloadTile(t,e){const i=this._tiles[t];i&&("loading"!==i.state&&(i.state=e),this._loadTile(i,this._tileLoaded.bind(this,i,t,e)))}_tileLoaded(t,e,i,n){if(n)if(t.state="errored",404!==n.status)this._source.fire(new Kt(n,{tile:t}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const t=this.map.painter.terrain;this.update(this.transform,t.getScaledDemTileSize(),!0),t.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=Zt.now(),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),"raster-dem"===this._source.type&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Jt("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const e=this.getRenderableIds();for(let n=0;n1||(Math.abs(i)>1&&(1===Math.abs(i+r)?i+=r:1===Math.abs(i-r)&&(i-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,n),t.neighboringTiles&&t.neighboringTiles[o]&&(t.neighboringTiles[o].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,e,i,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZ<=e||o.tileID.overscaledZ>i)continue;let s=o.tileID;for(;o&&o.tileID.overscaledZ>e+1;){const t=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[t.key],o&&o.hasData()&&(s=t)}let a=s;for(;a.overscaledZ>e;)if(a=a.scaledTo(a.overscaledZ-1),t[a.key]){n[s.key]=s;break}}}findLoadedParent(t,e){if(t.key in this._loadedParentTiles){const i=this._loadedParentTiles[t.key];return i&&i.tileID.overscaledZ>=e?i:null}for(let i=t.overscaledZ-1;i>=e;i--){const e=t.scaledTo(i),n=this._getLoadedTile(e);if(n)return n}}_getLoadedTile(t){const e=this._tiles[t.key];return e&&e.hasData()?e:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,e){e=e||this._source.tileSize;const i=Math.ceil(t.width/e)+1,n=Math.ceil(t.height/e)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);if(this._prevLng=t,e){const t={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),t[n.tileID.key]=n}this._tiles=t;for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t in this._tiles)this._setTileReloadTimer(+t,this._tiles[t])}}update(t,e,i){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!i)return;let n;this.updateCacheSize(t,e),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new fh(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=t.coveringTiles({tileSize:e||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!i,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(n=n.filter((t=>this._source.hasTile(t))))):n=[];const r=this._updateRetainedTiles(n);if(nm(this._source.type)&&0!==n.length){const t={},e={},i=Object.keys(r);for(const n of i){const i=r[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=Zt.now())continue;const s=this.findLoadedParent(i,Math.max(i.overscaledZ-em.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),e[n]=i}const o=n[n.length-1].overscaledZ;for(const t in this._tiles){const i=this._tiles[t];if(r[t]||!i.hasData())continue;let n=i.tileID;for(;n.overscaledZ>o;){n=n.scaledTo(n.overscaledZ-1);const o=this._tiles[n.key];if(o&&o.hasData()&&e[n.key]){r[t]=i.tileID;break}}}for(const e in t)r[e]||(this._coveredTiles[e]=!0,r[e]=t[e])}for(const t in r)this._tiles[t].clearFadeHold();const o=function(t,e){const i=[];for(const n in t)n in e||i.push(n);return i}(this._tiles,r);for(const t of o){const e=this._tiles[t];e.hasSymbolBuckets&&!e.holdingForFade()?e.setHoldDuration(this.map._fadeDuration):e.hasSymbolBuckets&&!e.symbolFadeFinished()||this._removeTile(+t)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const e={};if(0===t.length)return e;const i={},n=t.reduce(((t,e)=>Math.min(t,e.overscaledZ)),1/0),r=t[0].overscaledZ,o=Math.max(r-em.maxOverzooming,this._source.minzoom),s=Math.max(r+em.maxUnderzooming,this._source.minzoom),a={};for(const i of t){const t=this._addTile(i);e[i.key]=i,t.hasData()||n=this._source.maxzoom){const t=n.children(this._source.maxzoom)[0],i=this.getTile(t);if(i&&i.hasData()){e[t.key]=t;continue}}else{const t=n.children(this._source.maxzoom);if(e[t[0].key]&&e[t[1].key]&&e[t[2].key]&&e[t[3].key])continue}let r=t.wasRequested();for(let s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,t=this.getTile(o),!t&&r&&(t=this._addTile(o)),t&&(e[o.key]=o,r=t.wasRequested(),t.hasData()))break}}return e}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const e=[];let i,n=this._tiles[t].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}e.push(n.key);const t=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(t),i)break;n=t}for(const t of e)this._loadedParentTiles[t]=i}}_addTile(t){let e=this._tiles[t.key];if(e)return e;e=this._cache.getAndRemove(t),e&&(this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,e)));const i=Boolean(e);if(!i){const i=this.map?this.map.painter:null;e=new Rf(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,i,this._isRaster),this._loadTile(e,this._tileLoaded.bind(this,e,t.key,e.state))}return e?(e.uses++,this._tiles[t.key]=e,i||this._source.fire(new Jt("dataloading",{tile:e,coord:e.tileID,dataType:"source"})),e):null}_setTileReloadTimer(t,e){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_removeTile(t){const 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))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,e,i){const n=[],r=this.transform;if(!r)return n;const o="globe"===r.projection.name,s=Hl(r.center.lng);for(const a in this._tiles){const l=this._tiles[a];if(i&&l.clearQueryDebugViz(),l.holdingForFade())continue;let c;if(o){const t=l.tileID.canonical;if(0===t.z){const e=[Math.abs(T(s,...rm(t,-1))-s),Math.abs(T(s,...rm(t,1))-s)];c=[0,2*e.indexOf(Math.min(...e))-1]}else{const e=[Math.abs(T(s,...rm(t,-1))-s),Math.abs(T(s,...rm(t,0))-s),Math.abs(T(s,...rm(t,1))-s)];c=[e.indexOf(Math.min(...e))-1]}}else c=[0];for(const i of c){const o=t.containsTile(l,r,e,i);o&&n.push(o)}}return n}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._tiles[t].tileID));for(const t of e)t.projMatrix=this.transform.calculateProjMatrix(t.toUnwrapped());return e}hasTransition(){if(this._source.hasTransition())return!0;if(nm(this._source.type))for(const t in this._tiles){const e=this._tiles[t];if(void 0!==e.fadeEndTime&&e.fadeEndTime>=Zt.now())return!0}return!1}setFeatureState(t,e,i){this._state.updateState(t=t||"_geojsonTileLayer",e,i)}removeFeatureState(t,e,i){this._state.removeFeatureState(t=t||"_geojsonTileLayer",e,i)}getFeatureState(t,e){return this._state.getState(t=t||"_geojsonTileLayer",e)}setDependencies(t,e,i){const n=this._tiles[t];n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i in this._tiles)this._tiles[i].hasDependency(t,e)&&this._reloadTile(+i,"reloading");this._cache.filter((i=>!i.hasDependency(t,e)))}_preloadTiles(t,e){if(!this._sourceLoaded){const i=()=>{this._sourceLoaded&&(this._source.off("data",i),this._preloadTiles(t,e))};return void this._source.on("data",i)}const i=new Map,n=Array.isArray(t)?t:[t],r=this.map.painter.terrain,o=this.usedForTerrain&&r?r.getScaledDemTileSize():this._source.tileSize;for(const t of n){const e=t.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const t of e)i.set(t.key,t);this.usedForTerrain&&t.updateElevation(!1)}P(Array.from(i.values()),((t,e)=>{const i=new Rf(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(i,(t=>{"raster-dem"===this._source.type&&i.dem&&this._backfillDEM(i),e(t,i)}))}),e)}}function im(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}function nm(t){return"raster"===t||"image"===t||"video"===t||"custom"===t}function rm(t,e){const i=1<=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new qu(new gp(this.rawTileData)).layers,this.sourceLayerCoder=new bf(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,e,i,n){this.loadVTLayers();const r=t.params||{},o=hr(r.filter),s=t.tileResult,a=t.transform,l=s.bufferedTilespaceBounds,c=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,((t,e,i,n)=>bc(s.bufferedTilespaceGeometry,t,e,i,n)));c.sort(lm);let u=null;a.elevation&&c.length>0&&(u=om.create(a.elevation,this.tileID));const h={};let p;for(let a=0;a(f||(f=sc(e,this.tileID.canonical,t.tileTransform)),i.queryIntersectsFeature(s,e,n,f,this.z,t.transform,t.pixelPosMatrix,u,r))))}return h}loadMatchingFeature(t,e,i,n,r,o,s,a,l){const{featureIndex:c,bucketIndex:u,sourceLayerIndex:h,layoutVertexArrayOffset:p}=e,d=this.bucketLayerIDs[u];if(n&&!function(t,e){for(let i=0;i=0)return!0;return!1}(n,d))return;const f=this.sourceLayerCoder.decode(h),m=this.vtLayers[f].feature(c);if(i.needGeometry){const t=ac(m,!0);if(!i.filter(new wo(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!i.filter(new wo(this.tileID.overscaledZ),m))return;const g=this.getId(m,f);for(let e=0;e{const s=e instanceof Po?e.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s}))}function lm(t,e){return e-t}Yr(sm,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class cm{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.image=new zc({width:t,height:e}),this.positions={},this.uploaded=!1}getDash(t,e){const i=this.getKey(t,e);return this.positions[i]}trim(){const t=this.width,e=this.height=N(this.nextRow);this.image.resize({width:t,height:e})}getKey(t,e){return t.join(",")+e}getDashRanges(t,e,i){const n=[];let r=t.length%2==1?-t[t.length-1]*i:0,o=t[0]*i,s=!0;n.push({left:r,right:o,isDash:s,zeroLength:0===t[0]});let a=t[0];for(let e=1;e1&&(s=t[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const p=e/i*(n+1);if(s.isDash){const t=n-Math.abs(p);h=Math.sqrt(u*u+t*t)}else h=n-Math.sqrt(u*u+p*p);this.image.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(t,e){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const i=t[0],n=t[t.length-1];i.isDash===n.isDash&&(i.left=n.left-this.width,n.right=i.right+this.width);const r=this.width*this.nextRow;let o=0,s=t[o];for(let i=0;i1&&(s=t[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+e+128))}}addDash(t,e){const i=this.getKey(t,e);if(this.positions[i])return this.positions[i];const n="round"===e,r=n?7:0,o=2*r+1;if(this.nextRow+o>this.height)return H("LineAtlas out of space"),null;0===t.length&&t.push(1);let s=0;for(let e=0;e=e.maxzoom||"none"!==e.visibility&&(dm(t,this.zoom,i),(a[e.id]=e.createBucket({index:s.bucketLayerIDs.length,layers:t,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:i})).populate(p,c,this.tileID.canonical,this.tileTransform),s.bucketLayerIDs.push(t.map((t=>t.id))))}}let h,p,d,f;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},g=()=>{if(h)return r(h);if(p&&d&&f){const t=new hm(p),e=new Sp(d,f);for(const n in a){const r=a[n];r instanceof af?(dm(r.layers,this.zoom,i),_d(r,p,t.positions,d,e.iconPositions,this.showCollisionBoxes,i,this.tileID.canonical,this.tileZoom,this.projection)):r.hasPattern&&(r instanceof Mh||r instanceof Tu||r instanceof th)&&(dm(r.layers,this.zoom,i),r.addFeatures(c,this.tileID.canonical,e.patternPositions,i,this.tileTransform))}this.status="done",r(null,{buckets:L(a).filter((t=>!t.isEmpty())),featureIndex:s,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:t.image,lineAtlas:l,imageAtlas:e,glyphMap:this.returnDependencies?p:null,iconMap:this.returnDependencies?d:null,glyphPositions:this.returnDependencies?t.positions:null})}},y=V(c.glyphDependencies,(t=>Object.keys(t).map(Number)));Object.keys(y).length?n.send("getGlyphs",{uid:this.uid,stacks:y},((t,e)=>{h||(h=t,p=e,g())}),void 0,!1,m):p={};const v=Object.keys(c.iconDependencies);v.length?n.send("getImages",{icons:v,source:this.source,tileID:this.tileID,type:"icons"},((t,e)=>{h||(h=t,d=e,g())}),void 0,!1,m):d={};const _=Object.keys(c.patternDependencies);_.length?n.send("getImages",{icons:_,source:this.source,tileID:this.tileID,type:"patterns"},((t,e)=>{h||(h=t,f=e,g())}),void 0,!1,m):f={},g()}}function dm(t,e,i){const n=new wo(e);for(const e of t)e.recalculate(n,i)}class fm{constructor(t){this.entries={},this.scheduler=t}request(t,e,i,n){const r=this.entries[t]=this.entries[t]||{callbacks:[]};if(r.result){const[t,i]=r.result;return this.scheduler?this.scheduler.add((()=>{n(t,i)}),e):n(t,i),()=>{}}return r.callbacks.push(n),r.cancel||(r.cancel=i(((i,n)=>{r.result=[i,n];for(const t of r.callbacks)this.scheduler?this.scheduler.add((()=>{t(i,n)}),e):t(i,n);setTimeout((()=>delete this.entries[t]),3e3)}))),()=>{r.result||(r.callbacks=r.callbacks.filter((t=>t!==n)),r.callbacks.length||(r.cancel(),delete this.entries[t]))}}}function mm(t,e,i){const n=JSON.stringify(t.request);return t.data&&(this.deduped.entries[n]={result:[null,t.data]}),this.deduped.request(n,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom},(e=>{const n=pt(t.request,((t,n,r,o)=>{t?e(t):n&&e(null,{vectorTile:i?void 0:new qu(new gp(n)),rawData:n,cacheControl:r,expires:o})}));return()=>{n.cancel(),e()}}),e)}const gm=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class ym{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=gm[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new ym(s,o,r,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const r=gm.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+s+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+r]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return vm(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:o,nodeSize:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=t&&a<=i&&c>=e&&c<=n&&l.push(r[s])}continue}const p=h+u>>1,d=o[2*p],f=o[2*p+1];d>=t&&d<=i&&f>=e&&f<=n&&l.push(r[p]),(0===c?t<=d:e<=f)&&(a.push(h),a.push(p-1),a.push(1-c)),(0===c?i>=d:n>=f)&&(a.push(p+1),a.push(u),a.push(1-c))}return l}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)wm(r[2*i],r[2*i+1],t,e)<=l&&a.push(n[i]);continue}const p=h+u>>1,d=r[2*p],f=r[2*p+1];wm(d,f,t,e)<=l&&a.push(n[p]),(0===c?t-i<=d:e-i<=f)&&(s.push(h),s.push(p-1),s.push(1-c)),(0===c?t+i>=d:e+i>=f)&&(s.push(p+1),s.push(u),s.push(1-c))}return a}}function vm(t,e,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;_m(t,e,s,n,r,o),vm(t,e,i,n,s-1,1-o),vm(t,e,i,s+1,r,1-o)}function _m(t,e,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);_m(t,e,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=e[2*i+o];let a=n,l=r;for(xm(t,e,n,i),e[2*r+o]>s&&xm(t,e,n,r);as;)l--}e[2*n+o]===s?xm(t,e,n,l):(l++,xm(t,e,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function xm(t,e,i,n){bm(t,i,n),bm(e,2*i,2*n),bm(e,2*i+1,2*n+1)}function bm(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function wm(t,e,i,n){const r=t-i,o=e-n;return r*r+o*o}t.ARRAY_TYPE=ua,t.AUTH_ERR_MSG=vt,t.Aabb=rl,t.Actor=class{constructor(t,i,n){this.target=t,this.parent=i,this.mapId=n,this.callbacks={},this.cancelCallbacks={},z(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=X()?t:e,this.scheduler=new xf}send(t,e,i,n,r=!1,o){const s=Math.round(1e18*Math.random()).toString(36).substring(0,10);i&&(i.metadata=o,this.callbacks[s]=i);const a=Q(this.globalScope)?void 0:[];return this.target.postMessage({id:s,type:t,hasCallback:!!i,targetMapId:n,mustQueue:r,sourceMapId:this.mapId,data:Kr(e,a)},a),{cancel:()=>{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(t){const e=t.data,i=e.id;if(i&&(!e.targetMapId||this.mapId===e.targetMapId))if(""===e.type){const t=this.cancelCallbacks[i];delete this.cancelCallbacks[i],t&&t.cancel()}else if(e.mustQueue||X()){const t=this.callbacks[i];this.cancelCallbacks[i]=this.scheduler.add((()=>this.processTask(i,e)),t&&t.metadata||{type:"message"})}else this.processTask(i,e)}processTask(t,e){if(""===e.type){const i=this.callbacks[t];delete this.callbacks[t],i&&(e.error?i($r(e.error)):i(null,$r(e.data)))}else{const i=Q(this.globalScope)?void 0:[],n=e.hasCallback?(e,n)=>{delete this.cancelCallbacks[t],this.target.postMessage({id:t,type:"",sourceMapId:this.mapId,error:e?Kr(e):null,data:Kr(n,i)},i)}:t=>{},r=$r(e.data);if(this.parent[e.type])this.parent[e.type](e.sourceMapId,r,n);else if(this.parent.getWorkerSource){const t=e.type.split(".");this.parent.getWorkerSource(e.sourceMapId,t[0],r.source)[t[1]](r,n)}else n(new Error(`Could not find function ${e.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},t.CanonicalTileID=ph,t.Color=Le,t.ColorMode=Jf,t.CullFaceMode=tm,t.DEMData=qf,t.DataConstantProperty=Lo,t.DedupedRequest=fm,t.DepthMode=Zf,t.EXTENT=aa,t.Elevation=class{isDataAvailableAtPoint(t){const e=this._source();if(this.isUsingMockSource()||!e||t.y<0||t.y>1)return!1;const i=e.getSource().maxzoom,n=1<1)return e;const r=n.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(t,r.x,r.y),s=n.upVector(t.canonical,r.x,r.y);return Da(s,s,o*n.upVectorScale(t.canonical,e,i).metersToTile),s}}getForTilePoints(t,e,i,n){if(this.isUsingMockSource())return!1;const r=om.create(this,t,n);return!!r&&(e.forEach((t=>{t[2]=this.exaggeration()*r.getElevationAt(t[0],t[1],i)})),!0)}getMinMaxForTile(t){if(this.isUsingMockSource())return null;const e=this.findDEMTileFor(t);if(!e||!e.dem)return null;const i=e.dem.tree,n=e.tileID,r=1<{let n=t===o-1?t-2:0===t?t:t-1;return n+=i?24575:0,[n,e]};for(let t=0;tthis._skuTokenExpiresAt}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}normalizeStyleURL(t,e){if(!_t(t))return t;const i=St(t);return i.path=`/styles/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeGlyphsURL(t,e){if(!_t(t))return t;const i=St(t);return i.path=`/fonts/v1${i.path}`,this._makeAPIURL(i,this._customAccessToken||e)}normalizeSourceURL(t,e,i,n){if(!_t(t))return t;const r=St(t);return r.path=`/v4/${r.authority}.json`,r.params.push("secure"),i&&r.params.push(`language=${i}`),n&&r.params.push(`worldview=${n}`),this._makeAPIURL(r,this._customAccessToken||e)}normalizeSpriteURL(t,e,i,n){const r=St(t);return _t(t)?(r.path=`/styles/v1${r.path}/sprite${e}${i}`,this._makeAPIURL(r,this._customAccessToken||n)):(r.path+=`${e}${i}`,Mt(r))}normalizeTileURL(t,e,i){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!_t(t))return t;const n=St(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${e||i&&"raster"!==n.authority&&512===i?"@2x":""}${o.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${r.RASTER_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${r.TILE_URL_VERSION}${n.path}`);const s=this._customAccessToken||function(t){for(const e of t){const t=e.match(/^access_token=(.*)$/);if(t)return t[1]}return null}(n.params)||r.ACCESS_TOKEN;return r.REQUIRE_ACCESS_TOKEN&&s&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,s)}canonicalizeTileURL(t,e){const i=St(t);if(!i.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!i.path.match(/\.[\w]+$/))return t;let n="mapbox://";i.path.match(/^\/raster\/v1\//)?n+=`raster/${i.path.replace(`/${r.RASTER_URL_PREFIX}/`,"")}`:n+=`tiles/${i.path.replace(`/${r.TILE_URL_VERSION}/`,"")}`;let o=i.params;return e&&(o=o.filter((t=>!t.match(/^access_token=/)))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(t,e){const i=!!e&&_t(e),n=[];for(const e of t.tiles||[])xt(e)?n.push(this.canonicalizeTileURL(e,i)):n.push(e);return n}_makeAPIURL(t,e){const i="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=St(r.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!r.REQUIRE_ACCESS_TOKEN)return Mt(t);if(e=e||r.ACCESS_TOKEN,!this._silenceAuthErrors){if(!e)throw new Error(`An API access token is required to use Mapbox GL. ${i}`);if("s"===e[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${i}`)}return t.params=t.params.filter((t=>-1===t.indexOf("access_token"))),t.params.push(`access_token=${e||""}`),Mt(t)}},t.ResourceType=lt,t.SegmentVector=sa,t.SourceCache=em,t.StencilMode=Qf,t.StructArrayLayout1ui2=us,t.StructArrayLayout2f1f2i16=ts,t.StructArrayLayout2i4=Uo,t.StructArrayLayout2ui4=cs,t.StructArrayLayout3f12=is,t.StructArrayLayout3ui6=ns,t.StructArrayLayout4i8=jo,t.StructArrayLayout5f20=as,t.Texture=vf,t.Tile=Rf,t.Transitionable=So,t.Uniform1f=Bs,t.Uniform1i=class extends Ns{constructor(t){super(t),this.current=0}set(t,e,i){this.fetchUniformLocation(t,e)&&this.current!==i&&(this.current=i,this.gl.uniform1i(this.location,i))}},t.Uniform2f=class extends Ns{constructor(t){super(t),this.current=[0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]||(this.current=i,this.gl.uniform2f(this.location,i[0],i[1])))}},t.Uniform3f=class extends Ns{constructor(t){super(t),this.current=[0,0,0]}set(t,e,i){this.fetchUniformLocation(t,e)&&(i[0]===this.current[0]&&i[1]===this.current[1]&&i[2]===this.current[2]||(this.current=i,this.gl.uniform3f(this.location,i[0],i[1],i[2])))}},t.Uniform4f=zs,t.UniformColor=Fs,t.UniformMatrix2f=class extends Ns{constructor(t){super(t),this.current=Gs}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t<4;t++)if(i[t]!==this.current[t]){this.current=i,this.gl.uniformMatrix2fv(this.location,!1,i);break}}},t.UniformMatrix3f=class extends Ns{constructor(t){super(t),this.current=Us}set(t,e,i){if(this.fetchUniformLocation(t,e))for(let t=0;t<9;t++)if(i[t]!==this.current[t]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},t.UniformMatrix4f=class extends Ns{constructor(t){super(t),this.current=Vs}set(t,e,i){if(this.fetchUniformLocation(t,e)){if(i[12]!==this.current[12]||i[0]!==this.current[0])return this.current=i,void this.gl.uniformMatrix4fv(this.location,!1,i);for(let t=1;t<16;t++)if(i[t]!==this.current[t]){this.current=i,this.gl.uniformMatrix4fv(this.location,!1,i);break}}}},t.UnwrappedTileID=dh,t.ValidationError=ir,t.VectorTileFeature=Xu,t.VectorTileWorkerSource=class extends $t{constructor(t,e,i,n,r){super(),this.actor=t,this.layerIndex=e,this.availableImages=i,this.loadVectorData=r||mm,this.loading={},this.loaded={},this.deduped=new fm(t.scheduler),this.isSpriteLoaded=n,this.scheduler=t.scheduler}loadTile(t,e){const i=t.uid,n=t&&t.request,r=n&&n.collectResourceTiming,o=this.loading[i]=new pm(t);o.abort=this.loadVectorData(t,((s,a)=>{const l=!this.loading[i];if(delete this.loading[i],l||s||!a)return o.status="done",l||(this.loaded[i]=o),e(s);const c=a.rawData,u={};a.expires&&(u.expires=a.expires),a.cacheControl&&(u.cacheControl=a.cacheControl),o.vectorTile=a.vectorTile||new qu(new gp(c));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,((t,i)=>{if(t||!i)return e(t);const o={};if(r){const t=jt(n);t.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(t)))}e(null,D({rawTileData:c.slice(0)},i,u,o))}))};this.isSpriteLoaded?h():this.once("isSpriteLoaded",(()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:t.isSymbolTile,zoom:t.tileZoom}):h()})),this.loaded=this.loaded||{},this.loaded[i]=o}))}reloadTile(t,e){const i=this.loaded,n=t.uid,r=this;if(i&&i[n]){const o=i[n];o.showCollisionBoxes=t.showCollisionBoxes,o.enableTerrain=!!t.enableTerrain,o.projection=t.projection,o.tileTransform=Pd(t.tileID.canonical,t.projection);const s=(t,i)=>{const n=o.reloadCallback;n&&(delete o.reloadCallback,o.parse(o.vectorTile,r.layerIndex,this.availableImages,r.actor,n)),e(t,i)};"parsing"===o.status?o.reloadCallback=s:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,s):s())}}abortTile(t,e){const i=t.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),e()}removeTile(t,e){const i=this.loaded,n=t.uid;i&&i[n]&&delete i[n],e()}},t.WritingMode=Mp,t.ZoomDependentExpression=Kn,t.add=Ta,t.addDynamicAttributes=nf,t.adjoint=function(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8];return t[0]=s*u-a*c,t[1]=r*c-n*u,t[2]=n*a-r*s,t[3]=a*l-o*u,t[4]=i*u-r*l,t[5]=r*o-i*a,t[6]=o*c-s*l,t[7]=n*l-i*c,t[8]=i*s-n*o,t},t.asyncAll=P,t.bezier=S,t.bindAll=z,t.boundsAttributes=Lf,t.bufferConvexPolygon=function(t,e){const i=[];for(let n=0;nnt&&(t.getActor().send("enforceCacheSizeLimit",it),at=0)},t.calculateGlobeLabelMatrix=function(t,e){const{x:i,y:n}=t.point,r=Dl(i,n,t.worldSize/t._pixelsPerMercatorPixel,0,0);return ma(r,r,Ll(vl(e)))},t.calculateGlobeMatrix=function(t){const{x:e,y:i}=t.point,{lng:n,lat:r}=t._center;return Dl(e,i,t.worldSize,n,r)},t.calculateGlobeMercatorMatrix=function(t){const e=t.pixelsPerMeter,i=e/ql(1,t.center.lat),n=da(new Float64Array(16));return ga(n,n,[t.point.x,t.point.y,0]),ya(n,n,[i,i,e]),Float32Array.from(n)},t.circumferenceAtLatitude=jl,t.clamp=T,t.clearTileCache=function(t){if(!rt())return;const i=e.caches.delete($);t&&i.catch(t).then((()=>t()))},t.clipLine=Qp,t.clone=function(t){var e=new ua(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=G,t.collisionCircleLayout=Bh,t.config=r,t.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},t.create=function(){var t=new ua(16);return ua!=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=ha,t.createExpression=Qn,t.createLayout=Fo,t.createStyleLayer=function(t){return"custom"===t.type?new ff(t):new yf[t.type](t)},t.cross=Na,t.degToRad=b,t.distance=function(t,e){return Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2])},t.div=function(t,e,i){return t[0]=e[0]/i[0],t[1]=e[1]/i[1],t[2]=e[2]/i[2],t},t.dot=ka,t.earthRadius=Fl,t.ease=M,t.easeCubicInOut=E,t.ecefToLatLng=function([t,e,i]){const n=Math.hypot(t,e,i),r=Math.atan2(t,i),o=.5*Math.PI-Math.acos(-e/n);return new Gl(w(r),w(o))},t.emitValidationErrors=jr,t.endsWith=F,t.enforceCacheSizeLimit=function(t){ot(),tt&&tt.then((e=>{e.keys().then((i=>{for(let n=0;no&&(n+=(t[r]-o)*(t[r]-o)),e[r]0){const t=180/n;pa(d,d,[t/c+1,0,0,0,t/u+1,0,-.5*t/h,.5*t/p,1])}return d[2]=l,d[5]=t.x,d[8]=t.y,d},t.getImage=yt,t.getJSON=function(t,e){return ht(D(t,{type:"json"}),e)},t.getLatitudinalLod=function(t){const e=Ql-5;t=T(t,-e,e)/e*90;const i=Math.pow(Math.abs(Math.sin(b(t))),3);return Math.round(i*(ul.length-1))},t.getMapSessionAPI=Bt,t.getPerformanceMeasurement=jt,t.getProjection=Jd,t.getRTLTextPluginStatus=_o,t.getReferrer=ut,t.getTilePoint=function(t,{x:e,y:i},n=0){return new v(((e-n)*t.scale-t.x)*aa,(i*t.scale-t.y)*aa)},t.getTileVec3=function(t,e,i=0){return Ma(((e.x-i)*t.scale-t.x)*aa,(e.y*t.scale-t.y)*aa,Yl(e.z,e.y))},t.getVideo=function(t,i){const n=e.document.createElement("video");n.muted=!0,n.onloadstart=function(){i(null,n)};for(let i=0;i{}}},t.globeCenterToScreenPoint=function(t){const e=[0,0,0],i=da(new Float64Array(16));return ma(i,t.pixelMatrix,t.globeMatrix),Ba(e,e,i),new v(e[0],e[1])},t.globeDenormalizeECEF=Ll,t.globeECEFOrigin=function(t,e){const i=[0,0,0];return Ba(i,i,Pl(vl(e.canonical))),Ba(i,i,t),i},t.globeMetersToEcef=fl,t.globeNormalizeECEF=Pl,t.globePixelsToTileUnits=function(t,e){return aa/(512*Math.pow(2,t))*Il(vl(e))},t.globePoleMatrixForTile=function(t,e,i){const n=da(new Float64Array(16)),r=(e/(1<0;return 0===n&&!r&&!s&&o},t.identity=da,t.identity$1=Xa,t.invert=fa,t.isFullscreen=function(){return!!e.document.fullscreenElement||!!e.document.webkitFullscreenElement},t.isLngLatBehindGlobe=kl,t.isMapAuthenticated=function(t){return zt.has(t)},t.isMapboxURL=_t,t.isSafariWithAntialiasingBug=function(t){const e=t.navigator?t.navigator.userAgent:null;return!!Q(t)&&e&&(e.match("Version/15.4")||e.match("Version/15.5")||e.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},t.latFromMercatorY=Zl,t.latLngToECEF=Ml,t.len=Ga,t.length=Sa,t.length$1=function(t){return Math.hypot(t[0],t[1],t[2],t[3])},t.lngFromMercatorX=Xl,t.loadVectorTile=mm,t.makeRequest=ht,t.mapValue=function(t,e,i,n,r){return T((t-e)/(i-e)*(r-n)+n,n,r)},t.mercatorScale=Jl,t.mercatorXfromLng=Hl,t.mercatorYfromLat=Wl,t.mercatorZfromAltitude=ql,t.mul=wa,t.mul$1=Ua,t.multiply=ma,t.multiply$1=pa,t.multiply$2=Ca,t.nextPowerOfTwo=N,t.normalize=Oa,t.normalize$1=Qa,t.normalize$2=Ha,t.number=Li,t.ortho=function(t,e,i,n,r,o,s){var a=1/(e-i),l=1/(n-r),c=1/(o-s);return t[0]=-2*a,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*c,t[11]=0,t[12]=(e+i)*a,t[13]=(r+n)*l,t[14]=(s+o)*c,t[15]=1,t},t.pbf=Zh,t.perspective=function(t,e,i,n,r){var o,s=1/Math.tan(e/2);return t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,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!=r&&r!==1/0?(t[10]=(r+n)*(o=1/(n-r)),t[14]=2*r*n*o):(t[10]=-1,t[14]=-2*n),t},t.pick=function(t,e){const i={};for(let n=0;n0&&i[0]<=t.width&&i[1]>0&&i[1]<=t.height&&!kl(t,new Gl(t.center.lat,90)),n[0]>0&&n[0]<=t.width&&n[1]>0&&n[1]<=t.height&&!kl(t,new Gl(t.center.lat,-90))]},t.polygonContainsPoint=xc,t.polygonIntersectsBox=bc,t.polygonIntersectsPolygon=hc,t.polygonizeBounds=function(t,e,i=0,n=!0){const r=new v(i,i),o=t.sub(r),s=e.add(r),a=[o,new v(s.x,o.y),s,new v(o.x,s.y)];return n&&a.push(o.clone()),a},t.posAttributes=tl,t.postMapLoadEvent=Rt,t.postPerformanceEvent=kt,t.postTurnstileEvent=Lt,t.potpack=wp,t.prevPowerOfTwo=function(t){return t<=1?1:Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},t.radToDeg=w,t.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],t.registerForPluginStateChange=function(t){return t({pluginStatus:fo,pluginURL:mo}),vo.on("pluginStateChange",t),t},t.removeAuthState=function(t){zt.delete(t)},t.renderColorRamp=Uc,t.resample=tc,t.rotateX=va,t.rotateX$1=Za,t.rotateY=_a,t.rotateY$1=Ya,t.rotateZ=function(t,e,i){var n=Math.sin(i),r=Math.cos(i),o=e[0],s=e[1],a=e[2],l=e[3],c=e[4],u=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*r+c*n,t[1]=s*r+u*n,t[2]=a*r+h*n,t[3]=l*r+p*n,t[4]=c*r-o*n,t[5]=u*r-s*n,t[6]=h*r-a*n,t[7]=p*r-l*n,t},t.rotateZ$1=function(t,e,i){i*=.5;var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);return t[0]=n*l+r*a,t[1]=r*l-n*a,t[2]=o*l+s*a,t[3]=s*l-o*a,t},t.scale=ya,t.scale$1=ja,t.scale$2=Da,t.scaleAndAdd=Ra,t.set=function(t,e,i,n){return t[0]=e,t[1]=i,t[2]=n,t},t.setCacheLimits=function(t,e){it=t,nt=e},t.setColumn=function(t,e,i){t[4*e+0]=i[0],t[4*e+1]=i[1],t[4*e+2]=i[2],t[4*e+3]=i[3]},t.setRTLTextPlugin=function(t,e,i=!1){if(fo===co||fo===uo||fo===ho)throw new Error("setRTLTextPlugin cannot be called multiple times.");mo=Zt.resolveURL(t),fo=co,po=e,yo(),i||xo()},t.smoothstep=I,t.spec=te,t.squaredLength=function(t){var e=t[0],i=t[1],n=t[2];return e*e+i*i+n*n},t.storeAuthState=function(t,e){e?zt.add(t):zt.delete(t)},t.sub=Va,t.subtract=Ia,t.symbolSize=jh,t.tileAABB=function(t,e,i,n,r,o,s,a,l){if("globe"===l.name)return wl(t,e,new ph(i,n,r));const c=Pd({z:i,x:n,y:r},l);return new rl([(o+c.x/c.scale)*e,e*(c.y/c.scale),s],[(o+c.x2/c.scale)*e,e*(c.y2/c.scale),a])},t.tileCornersToBounds=Al,t.tileTransform=Pd,t.transformMat3=function(t,e,i){var n=e[0],r=e[1],o=e[2];return t[0]=n*i[0]+r*i[3]+o*i[6],t[1]=n*i[1]+r*i[4]+o*i[7],t[2]=n*i[2]+r*i[5]+o*i[8],t},t.transformMat4=Ba,t.transformMat4$1=Wa,t.transformQuat=za,t.transitionTileAABBinECEF=xl,t.translate=ga,t.transpose=function(t,e){if(t===e){var i=e[1],n=e[2],r=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=n,t[7]=r}else 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];return t},t.triggerPluginCompletionEvent=go,t.uniqueId=O,t.updateGlobeVertexNormal=function(t,e,i,n,r){const o=5*e+2;t.float32[o+0]=i,t.float32[o+1]=n,t.float32[o+2]=r},t.validateCustomStyleLayer=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.validateFilter=t=>Gr(Ar(t)),t.validateFog=t=>Gr(kr(t)),t.validateLayer=t=>Gr(Ir(t)),t.validateLight=t=>Gr(Rr(t)),t.validateSource=t=>Gr(Lr(t)),t.validateStyle=Fr,t.validateTerrain=t=>Gr(Or(t)),t.values=L,t.vectorTile=Ou,t.version=i,t.warnOnce=H,t.window=e,t.wrap=C})),n(["./shared"],(function(t){function e(t){if("number"==typeof t||"boolean"==typeof t||"string"==typeof t||null==t)return JSON.stringify(t);if(Array.isArray(t)){let i="[";for(const n of t)i+=`${e(n)},`;return`${i}]`}let i="{";for(const n of Object.keys(t).sort())i+=`${n}:${e(t[n])},`;return`${i}}`}function i(i){let n="";for(const r of t.refProperties)n+=`/${e(i[r])}`;return n}class n{constructor(t){this.keyCache={},t&&this.replace(t)}replace(t){this._layerConfigs={},this._layers={},this.update(t,[])}update(e,n){for(const i of e)this._layerConfigs[i.id]=i,(this._layers[i.id]=t.createStyleLayer(i)).compileFilter(),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const t of n)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const r=function(t,e){const n={};for(let r=0;rthis._layers[t.id])),i=e[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(e)}}}class r{loadTile(e,i){const{uid:n,encoding:r,rawImageData:o,padding:s,buildQuadTree:a}=e,l=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap?this.getImageData(o,s):o;i(null,new t.DEMData(n,l,r,s<1,a))}getImageData(t,e){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(t.width,t.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=t.width,this.offscreenCanvas.height=t.height,this.offscreenCanvasContext.drawImage(t,0,0,t.width,t.height);const i=this.offscreenCanvasContext.getImageData(-e,-e,t.width+2*e,t.height+2*e);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),i}}function o(t,e){if(0!==t.length){s(t[0],e);for(var i=1;i=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!e&&t.reverse()}var a=t.getDefaultExportFromCjs((function t(e,i){var n,r=e&&e.type;if("FeatureCollection"===r)for(n=0;n>31}function A(t,e){for(var i=t.loadGeometry(),n=t.type,r=0,o=0,s=i.length,a=0;at},T=Math.fround||(I=new Float32Array(1),t=>(I[0]=+t,I[0]));var I;const C=3,P=5,L=6;class D{constructor(t){this.options=Object.assign(Object.create(M),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const r=`prepare ${t.length} points`;e&&console.time(r),this.points=t;const o=[];for(let e=0;e=i;t--){const i=+Date.now();s=this.trees[t]=this._createTree(this._cluster(s,t)),e&&console.log("z%d: %d clusters in %dms",t,s.numItems,+Date.now()-i)}return e&&console.timeEnd("total time"),this}getClusters(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let r=180===t[2]?180:((t[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,r=180;else if(i>r){const t=this.getClusters([i,n,180,o],e),s=this.getClusters([-180,n,r,o],e);return t.concat(s)}const s=this.trees[this._limitZoom(e)],a=s.range(k(i),N(o),k(r),N(n)),l=s.data,c=[];for(const t of a){const e=this.stride*t;c.push(l[e+P]>1?R(l,e,this.clusterProps):this.points[l[e+C]])}return c}getChildren(t){const e=this._getOriginId(t),i=this._getOriginZoom(t),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(e*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[e*this.stride],o[e*this.stride+1],s),l=[];for(const e of a){const i=e*this.stride;o[i+4]===t&&l.push(o[i+P]>1?R(o,i,this.clusterProps):this.points[o[i+C]])}if(0===l.length)throw new Error(n);return l}getLeaves(t,e,i){const n=[];return this._appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this._limitZoom(t)],r=Math.pow(2,t),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((e-a)/r,l,(e+1+a)/r,c),n.data,e,i,r,u),0===e&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),e===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(t){let e=this._getOriginZoom(t)-1;for(;e<=this.options.maxZoom;){const i=this.getChildren(t);if(e++,1!==i.length)break;t=i[0].properties.cluster_id}return e}_appendLeaves(t,e,i,n,r){const o=this.getChildren(e);for(const e of o){const o=e.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(t,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=O(e,t,this.clusterProps),c=e[t],u=e[t+1];else{const i=this.points[e[t+C]];l=i.properties;const[n,r]=i.geometry.coordinates;c=k(n),u=N(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let p;p=a||this.options.generateId?e[t+C]:this.points[e[t+C]].id,void 0!==p&&(h.id=p),o.features.push(h)}}_limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}_cluster(t,e){const{radius:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,e)),a=t.data,l=[],c=this.stride;for(let i=0;ie&&(d+=a[i+P])}if(d>p&&d>=o){let t,o=n*p,s=u*p,f=-1;const m=((i/c|0)<<5)+(e+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=e)continue;a[l+2]=e;const u=a[l+P];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(t||(t=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(t)),r(t,this._map(a,l)))}a[i+4]=m,l.push(o/d,s/d,1/0,m,-1,d),r&&l.push(f)}else{for(let t=0;t1)for(const t of h){const i=t*c;if(!(a[i+2]<=e)){a[i+2]=e;for(let t=0;t>5}_getOriginZoom(t){return(t-this.points.length)%32}_map(t,e,i){if(t[e+P]>1){const n=this.clusterProps[t[e+L]];return i?Object.assign({},n):n}const n=this.points[t[e+C]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function R(t,e,i){return{type:"Feature",id:t[e+C],properties:O(t,e,i),geometry:{type:"Point",coordinates:[(n=t[e],360*(n-.5)),B(t[e+1])]}};var n}function O(t,e,i){const n=t[e+P],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=t[e+L],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:t[e+C],point_count:n,point_count_abbreviated:r})}function k(t){return t/360+.5}function N(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function B(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}function z(t,e,i,n){for(var r,o=n,s=i-e>>1,a=i-e,l=t[e],c=t[e+1],u=t[i],h=t[i+1],p=e+3;po)r=p,o=d;else if(d===o){var f=Math.abs(p-s);fn&&(r-e>3&&z(t,e,r,n),t[r+2]=o,i-r>3&&z(t,r,i,n))}function F(t,e,i,n,r,o){var s=r-i,a=o-n;if(0!==s||0!==a){var l=((t-i)*s+(e-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return(s=t-i)*s+(a=e-n)*a}function V(t,e,i,n){var r={id:void 0===t?null:t,type:e,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(t){var e=t.geometry,i=t.type;if("Point"===i||"MultiPoint"===i||"LineString"===i)U(t,e);else if("Polygon"===i||"MultiLineString"===i)for(var n=0;n0&&(s+=n?(r*c-l*o)/2:Math.sqrt(Math.pow(l-r,2)+Math.pow(c-o,2))),r=l,o=c}var u=e.length-3;e[2]=1,z(e,0,u,i),e[u+2]=1,e.size=Math.abs(s),e.start=0,e.end=e.size}function W(t,e,i,n){for(var r=0;r1?1:i}function Z(t,e,i,n,r,o,s,a){if(n/=e,o>=(i/=e)&&s=n)return null;for(var l=[],c=0;c=i&&f=n)){var m=[];if("Point"===p||"MultiPoint"===p)Y(h,m,i,n,r);else if("LineString"===p)Q(h,m,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===p)K(h,m,i,n,r,!1);else if("Polygon"===p)K(h,m,i,n,r,!0);else if("MultiPolygon"===p)for(var g=0;g=i&&s<=n&&(e.push(t[o]),e.push(t[o+1]),e.push(t[o+2]))}}function Q(t,e,i,n,r,o,s){for(var a,l,c=J(t),u=0===r?tt:et,h=t.start,p=0;pi&&(l=u(c,d,f,g,y,i),s&&(c.start=h+a*l)):v>n?_=i&&(l=u(c,d,f,g,y,i),x=!0),_>n&&v<=n&&(l=u(c,d,f,g,y,n),x=!0),!o&&x&&(s&&(c.end=h+a*l),e.push(c),c=J(t)),s&&(h+=a)}var b=t.length-3;d=t[b],f=t[b+1],m=t[b+2],(v=0===r?d:f)>=i&&v<=n&&$(c,d,f,m),b=c.length-3,o&&b>=3&&(c[b]!==c[0]||c[b+1]!==c[1])&&$(c,c[0],c[1],c[2]),c.length&&e.push(c)}function J(t){var e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function K(t,e,i,n,r,o){for(var s=0;ss.maxX&&(s.maxX=u),h>s.maxY&&(s.maxY=h)}return s}function at(t,e,i,n){var r=e.geometry,o=e.type,s=[];if("Point"===o||"MultiPoint"===o)for(var a=0;a0&&e.size<(r?s:n))i.numPoints+=e.length/3;else{for(var a=[],l=0;ls)&&(i.numSimplified++,a.push(e[l]),a.push(e[l+1])),i.numPoints++;r&&function(t,e){for(var i=0,n=0,r=t.length,o=r-2;n0===e)for(n=0,r=t.length;n24)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 n=function(t,e){var i=[];if("FeatureCollection"===t.type)for(var n=0;n1&&console.time("creation"),p=this.tiles[h]=st(t,e,i,n,l),this.tileCoords.push({z:e,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,n,p.numFeatures,p.numPoints,p.numSimplified),console.timeEnd("creation"));var d="z"+e;this.stats[d]=(this.stats[d]||0)+1,this.total++}if(p.source=t,r){if(e===l.maxZoom||e===r)continue;var f=1<1&&console.time("clipping");var m,g,y,v,_,x,b=.5*l.buffer/l.extent,w=.5-b,A=.5+b,E=1+b;m=g=y=v=null,_=Z(t,u,i-b,i+A,0,p.minX,p.maxX,l),x=Z(t,u,i+w,i+E,0,p.minX,p.maxX,l),t=null,_&&(m=Z(_,u,n-b,n+A,1,p.minY,p.maxY,l),g=Z(_,u,n+w,n+E,1,p.minY,p.maxY,l),_=null),x&&(y=Z(x,u,n-b,n+A,1,p.minY,p.maxY,l),v=Z(x,u,n+w,n+E,1,p.minY,p.maxY,l),x=null),c>1&&console.timeEnd("clipping"),a.push(m||[],e+1,2*i,2*n),a.push(g||[],e+1,2*i,2*n+1),a.push(y||[],e+1,2*i+1,2*n),a.push(v||[],e+1,2*i+1,2*n+1)}}},ct.prototype.getTile=function(t,e,i){var n=this.options,r=n.extent,o=n.debug;if(t<0||t>24)return null;var s=1<1&&console.log("drilling down to z%d-%d-%d",t,e,i);for(var l,c=t,u=e,h=i;!l&&c>0;)c--,u=Math.floor(u/2),h=Math.floor(h/2),l=this.tiles[ut(c,u,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",c,u,h),o>1&&console.time("drilling down"),this.splitTile(l.source,c,u,h,t,e,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?rt(this.tiles[a],r):null):null};class pt extends t.VectorTileWorkerSource{constructor(t,e,i,n,r){super(t,e,i,n,ht),r&&(this.loadGeoJSON=r)}loadData(e,i){const n=e&&e.request,r=n&&n.collectResourceTiming;this.loadGeoJSON(e,((o,s)=>{if(o||!s)return i(o);if("object"!=typeof s)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));{a(s,!0);try{if(e.filter){const i=t.createExpression(e.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));const n=s.features.filter((t=>i.value.evaluate({zoom:0},t)));s={type:"FeatureCollection",features:n}}this._geoJSONIndex=e.cluster?new D(function({superclusterOptions:e,clusterProperties:i}){if(!i||!e)return e;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const e of a){const[o,s]=i[e],a=t.createExpression(s),l=t.createExpression("string"==typeof o?[o,["accumulated"],["get",e]]:o);n[e]=a.value,r[e]=l.value}return e.map=t=>{s.properties=t;const e={};for(const t of a)e[t]=n[t].evaluate(o,s);return e},e.reduce=(t,e)=>{s.properties=e;for(const e of a)o.accumulated=t[e],t[e]=r[e].evaluate(o,s)},e}(e)).load(s.features):function(t,e){return new ct(t,e)}(s,e.geojsonVtOptions)}catch(o){return i(o)}this.loaded={};const l={};if(r){const i=t.getPerformanceMeasurement(n);i&&(l.resourceTiming={},l.resourceTiming[e.source]=JSON.parse(JSON.stringify(i)))}i(null,l)}}))}reloadTile(t,e){const i=this.loaded;return i&&i[t.uid]?super.reloadTile(t,e):this.loadTile(t,e)}loadGeoJSON(e,i){if(e.request)t.getJSON(e.request,i);else{if("string"!=typeof e.data)return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`));try{return i(null,JSON.parse(e.data))}catch(t){return i(new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(t,e){try{e(null,this._geoJSONIndex.getClusterExpansionZoom(t.clusterId))}catch(t){e(t)}}getClusterChildren(t,e){try{e(null,this._geoJSONIndex.getChildren(t.clusterId))}catch(t){e(t)}}getClusterLeaves(t,e){try{e(null,this._geoJSONIndex.getLeaves(t.clusterId,t.limit,t.offset))}catch(t){e(t)}}}class dt{constructor(e){this.self=e,this.actor=new t.Actor(e,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=t.getProjection({name:"mercator"}),this.workerSourceTypes={vector:t.VectorTileWorkerSource,geojson:pt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(t,e)=>{if(this.workerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.workerSourceTypes[t]=e},this.self.registerRTLTextPlugin=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}}clearCaches(t,e,i){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],i()}checkIfReady(t,e,i){i()}setReferrer(t,e){this.referrer=e}spriteLoaded(e,i){this.isSpriteLoaded[e]=i;for(const n in this.workerSources[e]){const r=this.workerSources[e][n];for(const e in r)r[e]instanceof t.VectorTileWorkerSource&&(r[e].isSpriteLoaded=i,r[e].fire(new t.Event("isSpriteLoaded")))}}setImages(t,e,i){this.availableImages[t]=e;for(const i in this.workerSources[t]){const n=this.workerSources[t][i];for(const t in n)n[t].availableImages=e}i()}enableTerrain(t,e,i){this.terrain=e,i()}setProjection(e,i){this.projections[e]=t.getProjection(i)}setLayers(t,e,i){this.getLayerIndex(t).replace(e),i()}updateLayers(t,e,i){this.getLayerIndex(t).update(e.layers,e.removedIds),i()}loadTile(e,i,n){const r=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).loadTile(r,n)}loadDEMTile(e,i,n){const r=this.enableTerrain?t.extend({buildQuadTree:this.terrain},i):i;this.getDEMWorkerSource(e,i.source).loadTile(r,n)}reloadTile(e,i,n){const r=this.enableTerrain?t.extend({enableTerrain:this.terrain},i):i;r.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,i.type,i.source).reloadTile(r,n)}abortTile(t,e,i){this.getWorkerSource(t,e.type,e.source).abortTile(e,i)}removeTile(t,e,i){this.getWorkerSource(t,e.type,e.source).removeTile(e,i)}removeSource(t,e,i){if(!this.workerSources[t]||!this.workerSources[t][e.type]||!this.workerSources[t][e.type][e.source])return;const n=this.workerSources[t][e.type][e.source];delete this.workerSources[t][e.type][e.source],void 0!==n.removeSource?n.removeSource(e,i):i()}loadWorkerSource(t,e,i){try{this.self.importScripts(e.url),i()}catch(t){i(t.toString())}}syncRTLPluginState(e,i,n){try{t.plugin.setState(i);const e=t.plugin.getPluginURL();if(t.plugin.isLoaded()&&!t.plugin.isParsed()&&null!=e){this.self.importScripts(e);const i=t.plugin.isParsed();n(i?void 0:new Error(`RTL Text Plugin failed to import scripts from ${e}`),i)}}catch(t){n(t.toString())}}getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}getLayerIndex(t){let e=this.layerIndexes[t];return e||(e=this.layerIndexes[t]=new n),e}getWorkerSource(t,e,i){if(this.workerSources[t]||(this.workerSources[t]={}),this.workerSources[t][e]||(this.workerSources[t][e]={}),!this.workerSources[t][e][i]){const n={send:(e,i,n,r,o,s)=>{this.actor.send(e,i,n,t,o,s)},scheduler:this.actor.scheduler};this.workerSources[t][e][i]=new this.workerSourceTypes[e](n,this.getLayerIndex(t),this.getAvailableImages(t),this.isSpriteLoaded[t])}return this.workerSources[t][e][i]}getDEMWorkerSource(t,e){return this.demWorkerSources[t]||(this.demWorkerSources[t]={}),this.demWorkerSources[t][e]||(this.demWorkerSources[t][e]=new r),this.demWorkerSources[t][e]}enforceCacheSizeLimit(e,i){t.enforceCacheSizeLimit(i)}getWorkerPerformanceMetrics(t,e,i){i(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new dt(self)),dt})),n(["./shared"],(function(t){function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n{t.window.removeEventListener("click",p,!0)}),0)}function f(t,e){const i=t.getBoundingClientRect();return y(t,i,e)}function m(t,e){const i=t.getBoundingClientRect(),n=[];for(let r=0;r=0?0:e.button}function y(e,i,n){const r=e.offsetWidth===i.width?1:e.offsetWidth/i.width;return new t.Point((n.clientX-i.left)*r,(n.clientY-i.top)*r)}function v(t,e){var i=e[0],n=e[1],r=e[2],o=e[3],s=i*o-r*n;return s?(t[0]=o*(s=1/s),t[1]=-n*s,t[2]=-r*s,t[3]=i*s,t):null}function _(t){const{userImage:e}=t;return!!(e&&e.render&&e.render())&&(t.data.replace(new Uint8Array(e.data.buffer)),!0)}class x extends t.Evented{constructor(){super(),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}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,callback:e}of this.requestors)this._notify(t,e);this.requestors=[]}}hasImage(t){return!!this.getImage(t)}getImage(t){return this.images[t]}addImage(t,e){this._validate(t,e)&&(this.images[t]=e)}_validate(e,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.ErrorEvent(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(t,e){if(!t)return!0;let i=0;for(const n of t){if(n[0]{this.ready=!0}))}broadcast(e,i,n){t.asyncAll(this.actors,((t,n)=>{t.send(e,i,n)}),n=n||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach((t=>{t.remove()})),this.actors=[],this.workerPool.release(this.id)}}function P(e,i,n){return i*(t.EXTENT/(e.tileSize*Math.pow(2,n-e.tileID.overscaledZ)))}C.Actor=t.Actor;class L{constructor(t,e,i,n){this.screenBounds=t,this.cameraPoint=e,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=i,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,n)}static createFromScreenPoints(e,i){let n,r;if(e instanceof t.Point||"number"==typeof e[0]){const o=t.Point.convert(e);n=[o],r=i.isPointAboveHorizon(o)}else{const o=t.Point.convert(e[0]),s=t.Point.convert(e[1]);n=[o,s],r=t.polygonizeBounds(o,s).every((t=>i.isPointAboveHorizon(t)))}return new L(n,i.getCameraPoint(),r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(e){return t.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],e)}bufferedCameraGeometry(e){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new t.Point(1,1)):this.screenBounds[1],r=t.polygonizeBounds(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),t.bufferConvexPolygon(r,e)}bufferedCameraGeometryGlobe(e){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new t.Point(1,1)):this.screenBounds[1],r=t.polygonizeBounds(i,n,e),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>n.y))+((o.x>i.x)+(o.x>n.x))){case 0:r[0]=o,r[4]=o.clone();break;case 1:r.splice(1,0,o);break;case 2:r[1]=o;break;case 3:r.splice(4,0,o);break;case 5:r.splice(2,0,o);break;case 6:r[3]=o;break;case 7:r.splice(3,0,o);break;case 8:r[2]=o}return r}containsTile(e,i,n,r=0){const o=e.queryPadding/i._pixelsPerMercatorPixel+1,s=n?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=e.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map((i=>t.getTilePoint(e.tileTransform,i,a)));if(!t.polygonIntersectsBox(l,0,0,t.EXTENT,t.EXTENT))return;a=e.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map((i=>t.getTileVec3(e.tileTransform,i,a))),u=c.map((e=>new t.Point(e[0],e[1]))),h=i.getFreeCameraOptions().position||new t.MercatorCoordinate(0,0,0),p=t.getTileVec3(e.tileTransform,h,a),d=c.map((e=>{const i=t.sub(e,e,p);return t.normalize(i,i),new t.Ray(p,i)})),f=P(e,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:d,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=t.getBounds(l),m.min.x=t.clamp(m.min.x,0,t.EXTENT),m.min.y=t.clamp(m.min.y,0,t.EXTENT),m.max.x=t.clamp(m.max.x,0,t.EXTENT),m.max.y=t.clamp(m.max.y,0,t.EXTENT),m),tile:e,tileID:e.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(t,e){const i=O(t);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===e.projection.name?this._projectAndResample(this.bufferedScreenGeometry(t),e):{polygon:this.bufferedScreenGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(t,e){const i=O(t);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===e.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(t),e):{polygon:this.bufferedCameraGeometry(t).map((t=>e.pointCoordinate3D(t))),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(e,i){const n=function(e,i){const n=t.multiply([],i.pixelMatrix,i.globeMatrix),r=[0,-t.GLOBE_RADIUS,0,1],o=[0,t.GLOBE_RADIUS,0,1],s=[0,0,0,1];t.transformMat4$1(r,r,n),t.transformMat4$1(o,o,n),t.transformMat4$1(s,s,n);const a=new t.Point(r[0]/r[3],r[1]/r[3]),l=new t.Point(o[0]/o[3],o[1]/o[3]),c=t.polygonContainsPoint(e,a)&&r[3]1?D(e.slice(0,p),i):[],m=pnew t.Point(R(e.x),e.y))),m=m.map((e=>new t.Point(R(e.x),e.y)));const g=[...f];0===g.length&&g.push(m[m.length-1]);const y=t.number(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,d);let v;return v=c?[new t.Point(0,y),new t.Point(0,0),new t.Point(1,0),new t.Point(1,y)]:[new t.Point(1,y),new t.Point(1,1),new t.Point(0,1),new t.Point(0,y)],g.push(...v),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:!1}}(e,i);if(n)return n;const r=function(e,i){let n=!1,r=-1/0,o=0;for(let t=0;tr&&(r=e[t].x,o=t);for(let t=0;t.5&&(r.x{t.x-=1})),{polygon:e,unwrapped:n}}(D(e,i).map((e=>new t.Point(R(e.x),e.y))),i);return{polygon:r.polygon.map((e=>new t.MercatorCoordinate(e.x,e.y))),unwrapped:r.unwrapped}}}function D(e,i){return t.resample(e,(t=>{const e=i.pointCoordinate3D(t);t.x=e.x,t.y=e.y}),1/256)}function R(t){return t<0?1+t%1:t%1}function O(t){return 100*t|0}function k(e,i,n,r,o){const s=function(n,r){if(n)return o(n);if(r){e.url&&r.tiles&&e.tiles&&delete e.tiles;const n=t.pick(t.extend(r,e),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);r.vector_layers&&(n.vectorLayers=r.vector_layers,n.vectorLayerIds=n.vectorLayers.map((t=>t.id))),n.tiles=i.canonicalizeTileset(n,e.url),o(null,n)}};return e.url?t.getJSON(i.transformRequest(i.normalizeSourceURL(e.url,null,n,r),t.ResourceType.Source),s):t.exported.frame((()=>s(null,e)))}class N{constructor(e,i,n){this.bounds=t.LngLatBounds.convert(this.validateBounds(e)),this.minzoom=i||0,this.maxzoom=n||24}validateBounds(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]}contains(e){const i=Math.pow(2,e.z),n=Math.floor(t.mercatorXfromLng(this.bounds.getWest())*i),r=Math.floor(t.mercatorYfromLat(this.bounds.getNorth())*i),o=Math.ceil(t.mercatorXfromLng(this.bounds.getEast())*i),s=Math.ceil(t.mercatorYfromLat(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y{this._tileJSONRequest=null,this._loaded=!0,r?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new t.ErrorEvent(r))):o&&(t.extend(this,o),o.bounds&&(this.tileBounds=new N(o.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(r)}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest(),this.load((()=>this.map.style._clearSource(this.id)))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return t.extend({},this._options)}loadTile(e,i){const n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,t.ResourceType.Tile),data:void 0,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:e.isSymbolTile};if(r.request.collectResourceTiming=this._collectResourceTiming,e.actor&&"expired"!==e.state)"loading"===e.state?e.reloadCallback=i:e.request=e.actor.send("reloadTile",r,o.bind(this));else if(e.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)e.request=e.actor.send("loadTile",r,o.bind(this),void 0,!0);else{const i=t.loadVectorTile.call({deduped:this._deduped},r,((t,i)=>{t||!i?o.call(this,t):(r.data={cacheControl:i.cacheControl,expires:i.expires,rawData:i.rawData.slice(0)},e.actor&&e.actor.send("loadTile",r,o.bind(this),void 0,!0))}),!0);e.request={cancel:i}}function o(n,r){return delete e.request,e.aborted?i(null):n&&404!==n.status?i(n):(r&&r.resourceTiming&&(e.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&e.setExpiryData(r),e.loadVectorData(r,this.map.painter),t.cacheEntryPossiblyAdded(this.dispatcher),i(null),void(e.reloadCallback&&(this.loadTile(e,e.reloadCallback),e.reloadCallback=null)))}}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.actor&&t.actor.send("abortTile",{uid:t.uid,type:this.type,source:this.id})}unloadTile(t){t.unloadVectorData(),t.actor&&t.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Mt extends t.Evented{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,this.setEventedParent(r),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"},i),t.extend(this,t.pick(i,["url","scheme","tileSize"]))}load(e){this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=k(this._options,this.map._requestManager,null,null,((i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new t.ErrorEvent(i)):n&&(t.extend(this,n),n.bounds&&(this.tileBounds=new N(n.bounds,this.minzoom,this.maxzoom)),t.postTurnstileEvent(n.tiles),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))),e&&e(i)}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}reload(){this.cancelTileJSONRequest(),this.load((()=>this.map.style._clearSource(this.id)))}setTiles(t){return this._options.tiles=t,this.reload(),this}setUrl(t){return this.url=t,this._options.url=t,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return t.extend({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const n=t.exported.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);e.request=t.getImage(this.map._requestManager.transformRequest(r,t.ResourceType.Tile),((n,r,o,s)=>(delete e.request,e.aborted?(e.state="unloaded",i(null)):n?(e.state="errored",i(n)):r?(this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:o,expires:s}),e.setTexture(r,this.map.painter),e.state="loaded",t.cacheEntryPossiblyAdded(this.dispatcher),void i(null)):i(null))))}static loadTileData(t,e,i){t.setTexture(e,i)}static unloadTileData(t,e){t.texture&&e.saveTileTexture(t.texture)}abortTile(t,e){t.request&&(t.request.cancel(),delete t.request),e()}unloadTile(t,e){t.texture&&this.map.painter.saveTileTexture(t.texture),e()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function Tt(e,i,n,r,o,s,a,l){const c=[e,n,o,i,r,s,1,1,1],u=[a,l,1],h=t.adjoint([],c),[p,d,f]=t.transformMat3(u,u,t.transpose(h,h));return t.multiply$1(c,[p,0,0,0,d,0,0,0,f],c)}class It extends t.Evented{constructor(t,e,i,n){super(),this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(n),this.options=e,this._dirty=!1}load(e,i){this._loaded=i||!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=t.getImage(this.map._requestManager.transformRequest(this.url,t.ResourceType.Image),((i,n)=>{if(this._imageRequest=null,this._loaded=!0,i)this.fire(new t.ErrorEvent(i));else if(n){const{HTMLImageElement:i}=t.window;this.image=n instanceof i?t.exported.getImageData(n):n,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading()}}))}loaded(){return this._loaded}updateImage(t){return this.image&&t.url?(this._imageRequest&&t.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=t.url,this.load(t.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(e){this.coordinates=e,this._boundsArray=void 0;const i=e.map(t.MercatorCoordinate.fromLngLat);return this.tileID=function(e){let i=1/0,n=1/0,r=-1/0,o=-1/0;for(const t of e)i=Math.min(i,t.x),n=Math.min(n,t.y),r=Math.max(r,t.x),o=Math.max(o,t.y);const s=Math.max(r-i,o-n),a=Math.max(0,Math.floor(-Math.log(s)/Math.LN2)),l=Math.pow(2,a);return new t.CanonicalTileID(a,Math.floor((i+r)/2*l),Math.floor((n+o)/2*l))}(i),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(e){for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture)}if(this._boundsArray)return;const i=t.tileTransform(this.tileID,this.map.transform.projection),[n,r,o,s]=this.coordinates.map((e=>{const n=i.projection.project(e[0],e[1]);return t.getTilePoint(i,n)._round()}));this.perspectiveTransform=function(e,i,n,r,o,s,a,l,c,u){const h=Tt(0,0,e,0,0,i,e,i),p=Tt(n,r,o,s,a,l,c,u);return t.multiply$1(p,t.adjoint(h,h),p),[p[6]/p[8]*e/t.EXTENT,p[7]/p[8]*i/t.EXTENT]}(this.width,this.height,n.x,n.y,r.x,r.y,s.x,s.y,o.x,o.y);const a=this._boundsArray=new t.StructArrayLayout4i8;a.emplaceBack(n.x,n.y,0,0),a.emplaceBack(r.x,r.y,t.EXTENT,0),a.emplaceBack(s.x,s.y,0,t.EXTENT),a.emplaceBack(o.x,o.y,t.EXTENT,t.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=e.createVertexBuffer(a,t.boundsAttributes.members),this.boundsSegments=t.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new t.Texture(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(e)}loadTile(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))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Ct={vector:St,raster:Mt,"raster-dem":class extends Mt{constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.extend({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox"}loadTile(e,i){const n=this.map._requestManager.normalizeTileURL(e.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function r(t,n){t&&(e.state="errored",i(t)),n&&(e.dem=n,e.dem.onDeserialize(),e.needsHillshadePrepare=!0,e.needsDEMTextureUpload=!0,e.state="loaded",i(null))}e.request=t.getImage(this.map._requestManager.transformRequest(n,t.ResourceType.Tile),function(n,o,s,a){if(delete e.request,e.aborted)e.state="unloaded",i(null);else if(n)e.state="errored",i(n);else if(o){this.map._refreshExpiredTiles&&e.setExpiryData({cacheControl:s,expires:a});const i=t.window.ImageBitmap&&o instanceof t.window.ImageBitmap&&(null==st&&(st=t.window.OffscreenCanvas&&new t.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof t.window.createImageBitmap),st),n=1-(o.width-t.prevPowerOfTwo(o.width))/2;n<1||e.neighboringTiles||(e.neighboringTiles=this._getNeighboringTiles(e.tileID));const l=i?o:t.exported.getImageData(o,n),c={uid:e.uid,coord:e.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:n};e.actor&&"expired"!==e.state||(e.actor=this.dispatcher.getActor(),e.actor.send("loadDEMTile",c,r.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.OverscaledTileID(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.OverscaledTileID(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.OverscaledTileID(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,e)this.fire(new t.ErrorEvent(e));else{const e={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&i&&i.resourceTiming&&i.resourceTiming[this.id]&&(e.resourceTiming=i.resourceTiming[this.id]),this.fire(new t.Event("data",e)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)}))}loaded(){return this._loaded}loadTile(e,i){const n=e.actor?"reloadTile":"loadTile";e.actor=this.actor,e.request=this.actor.send(n,{type:this.type,uid:e.uid,tileID:e.tileID,tileZoom:e.tileZoom,zoom:e.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:t.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},((t,r)=>(delete e.request,e.unloadVectorData(),e.aborted?i(null):t?i(t):(e.loadVectorData(r,this.map.painter,"reloadTile"===n),i(null)))),void 0,"loadTile"===n)}abortTile(t){t.request&&(t.request.cancel(),delete t.request),t.aborted=!0}unloadTile(t){t.unloadVectorData(),this.actor.send("removeTile",{uid:t.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return t.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends It{constructor(t,e,i,n){super(t,e,i,n),this.roundZoom=!0,this.type="video",this.options=e}load(){this._loaded=!1;const e=this.options;this.urls=[];for(const i of e.urls)this.urls.push(this.map._requestManager.transformRequest(i,t.ResourceType.Source).url);t.getVideo(this.urls,((e,i)=>{this._loaded=!0,e?this.fire(new t.ErrorEvent(e)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",(()=>{this.map.triggerRepaint()})),this.map&&this.video.play(),this._finishLoading())}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=e}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const e=this.map.painter.context,i=e.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new t.Texture(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(e)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:It,canvas:class extends It{constructor(e,i,n,r){super(e,i,n,r),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof t.window.HTMLCanvasElement||this.fire(new t.ErrorEvent(new t.ValidationError(`sources.${e}`,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.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){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())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let 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())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.Texture(i,this.canvas,i.gl.RGBA,{premultiply:!0}),this._prepareData(i)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}},custom:class extends t.Evented{constructor(e,i,n,r){super(),this.id=e,this.type="custom",this._dataType="raster",this._dispatcher=n,this._implementation=i,this.setEventedParent(r),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new t.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new t.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new N(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),t.extend(this,t.pick(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return t.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new t.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(e){this._map=e,this._loaded=!1,this.fire(new t.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(e),this.load()}onRemove(t){this._implementation.onRemove&&this._implementation.onRemove(t)}hasTile(t){if(this._implementation.hasTile){const{x:e,y:i,z:n}=t.canonical;return this._implementation.hasTile({x:e,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(e,i){const{x:n,y:r,z:o}=e.tileID.canonical,s=new t.window.AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:n,y:r,z:o},{signal:s.signal})).then(function(n){return delete e.request,e.aborted?(e.state="unloaded",i(null)):void 0===n?(e.state="errored",i(null)):null===n?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",i(null)):function(e){return e instanceof t.window.ImageData||e instanceof t.window.HTMLCanvasElement||e instanceof t.window.ImageBitmap||e instanceof t.window.HTMLImageElement}(n)?(this.loadTileData(e,n),e.state="loaded",void i(null)):(e.state="errored",i(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch((t=>{20!==t.code&&(e.state="errored",i(t))})),e.request.cancel=()=>s.abort()}loadTileData(t,e){Mt.loadTileData(t,e,this._map.painter)}unloadTileData(t){Mt.unloadTileData(t,this._map.painter)}unloadTile(t,e){if(this.unloadTileData(t),this._implementation.unloadTile){const{x:e,y:i,z:n}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:n})}e()}abortTile(t,e){t.request&&t.request.cancel&&(t.request.cancel(),delete t.request),e()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map((t=>({x:t.canonical.x,y:t.canonical.y,z:t.canonical.z})))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new t.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Pt=function(e,i,n,r){const o=new Ct[i.type](e,i,n,r);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};function Lt(e,i){const n=t.identity([]);return t.scale(n,n,[.5*e.width,.5*-e.height,1]),t.translate(n,n,[1,-1,0]),t.multiply(n,n,e.calculateProjMatrix(i.toUnwrapped())),Float32Array.from(n)}function Dt(t,e,i,n,r,o,s,a=!1){const l=t.tilesIn(n,s,a);l.sort(Ot);const c=[];for(const n of l)c.push({wrappedTileID:n.tile.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(e,i,t._state,n,r,o,Lt(t.transform,n.tile.tileID),a)});const u=function(t){const e={},i={};for(const n of t){const t=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in t){const n=t[i],r=o[i]=o[i]||{},s=e[i]=e[i]||[];for(const t of n)r[t.featureIndex]||(r[t.featureIndex]=!0,s.push(t))}}return e}(c);for(const e in u)u[e].forEach((e=>{const i=e.feature,n=i.layer;n&&"background"!==n.type&&"sky"!==n.type&&(i.source=n.source,n["source-layer"]&&(i.sourceLayer=n["source-layer"]),i.state=void 0!==i.id?t.getFeatureState(n["source-layer"],i.id):{})}));return u}function Rt(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),n=[],r={};for(let t=0;t{t.terminate()})),this.workers=null)}isPreloaded(){return!!this.active[Nt]}numActive(){return Object.keys(this.active).length}}let zt;function Ft(){return zt||(zt=new Bt),zt}function Vt(e,i){const n={};for(const t in e)"ref"!==t&&(n[t]=e[t]);return t.refProperties.forEach((t=>{t in i&&(n[t]=i[t])})),n}function Ut(t){t=t.slice();const e=Object.create(null);for(let i=0;i0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Jt{constructor(t,e,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;tthis.width||n<0||e>this.height)return!r&&[];const s=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=n){if(r)return!0;for(let t=0;t0:s}_queryCircle(t,e,i,n,r){const o=t-i,s=t+i,a=e-i,l=e+i;if(s<0||o>this.width||l<0||a>this.height)return!n&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:n,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},r),n?c.length>0:c}query(t,e,i,n,r){return this._query(t,e,i,n,!1,r)}hitTest(t,e,i,n,r){return this._query(t,e,i,n,!0,r)}hitTestCircle(t,e,i,n){return this._queryCircle(t,e,i,!0,n)}_queryCell(t,e,i,n,r,o,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(t<=r[c+2]&&e<=r[c+3]&&i>=r[c+0]&&n>=r[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]})}}}const u=this.circleCells[r];if(null!==u){const r=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(r[u],r[u+1],r[u+2],t,e,i,n)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const t=r[u],e=r[u+1],i=r[u+2];o.push({key:this.circleKeys[c],x1:t-i,y1:e-i,x2:t+i,y2:e+i})}}}}}_queryCellCircle(t,e,i,n,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const t=this.bboxes;for(const e of u)if(!c.box[e]){c.box[e]=!0;const i=4*e;if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(this.boxKeys[e])))return o.push(!0),!0}}const h=this.circleCells[r];if(null!==h){const t=this.circles;for(const e of h)if(!c.circle[e]){c.circle[e]=!0;const i=3*e;if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[e])))return o.push(!0),!0}}}_forEachCell(t,e,i,n,r,o,s,a){const l=this._convertToXCellCoord(t),c=this._convertToYCellCoord(e),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let p=l;p<=u;p++)for(let l=c;l<=h;l++)if(r.call(this,t,e,i,n,this.xCellCount*l+p,o,s,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,n,r,o){const s=n-t,a=r-e,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(t,e,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(t-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(e-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,p=u-c;return h*h+p*p<=i*i}}const Kt={unknown:0,flipRequired:1,flipNotRequired:2},$t=Math.tan(85*Math.PI/180);function te(e,i,n,r,o,s,a){const l=t.create();if(n)if("globe"===s.name){const e=t.calculateGlobeLabelMatrix(o,i);t.multiply(l,l,e)}else{const e=v([],a);l[0]=e[0],l[1]=e[1],l[4]=e[2],l[5]=e[3],r||t.rotateZ(l,l,o.angle)}else t.multiply(l,o.labelPlaneMatrix,e);return l}function ee(t,e,i,n,r,o,s){const a=te(t,e,i,n,r,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ie(e,i,n,r,o,s,a){if(n){if("globe"===s.name){const l=te(e,i,n,r,o,s,a);return t.invert(l,l),t.multiply(l,e,l),l}{const i=t.clone(e),n=t.identity([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],t.multiply(i,i,n),r||t.rotateZ(i,i,-o.angle),i}}return o.glCoordMatrix}function ne(e,i,n,r){const o=[e,i,n,1];n?t.transformMat4$1(o,o,r):fe(o,o,r);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function re(t,e){return Math.min(.5+t/e*.5,1.5)}function oe(t,e){const i=t[0]/t[3],n=t[1]/t[3];return i>=-e[0]&&i<=e[0]&&n>=-e[1]&&n<=e[1]}function se(e,i,n,r,o,s,a,l,c,u){const h=n.transform,p=r?e.textSizeData:e.iconSizeData,d=t.evaluateSizeForZoom(p,n.transform.zoom),f="globe"===h.projection.name,m=[256/n.width*2+1,256/n.height*2+1],g=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;g.clear();let y=null;f&&(y=r?e.text.globeExtVertexArray:e.icon.globeExtVertexArray);const v=e.lineVertexArray,_=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b,w=!1;for(let r=0;r<_.length;r++){const f=_.get(r),{numGlyphs:A,writingMode:E}=f;if(E!==t.WritingMode.vertical||w||b===t.WritingMode.horizontal||(w=!0),b=E,(f.hidden||E===t.WritingMode.vertical)&&!w){de(A,g);continue}w=!1;const S=new t.Point(f.tileAnchorX,f.tileAnchorY);let{x:M,y:T,z:I}=h.projection.projectTilePoint(S.x,S.y,u.canonical);if(c){const[t,e,i]=c(S);M+=t,T+=e,I+=i}const C=[M,T,I,1];if(t.transformMat4$1(C,C,i),!oe(C,m)){de(A,g);continue}const P=re(n.transform.cameraToCenterDistance,C[3]),L=t.evaluateSizeForFeature(p,d,f),D=a?L/P:L*P,R=ne(M,T,I,o);if(R[3]<=0){de(A,g);continue}let O={};const k=a?null:c,N=ce(f,D,!1,l,i,o,s,e.glyphOffsetArray,v,g,y,R,S,O,x,k,h.projection,u,a);w=N.useVertical,k&&N.needsFlipping&&(O={}),(N.notEnoughRoom||w||N.needsFlipping&&ce(f,D,!0,l,i,o,s,e.glyphOffsetArray,v,g,y,R,S,O,x,k,h.projection,u,a).notEnoughRoom)&&de(A,g)}r?(e.text.dynamicLayoutVertexBuffer.updateData(g),y&&e.text.globeExtVertexBuffer.updateData(y)):(e.icon.dynamicLayoutVertexBuffer.updateData(g),y&&e.icon.globeExtVertexBuffer.updateData(y))}function ae(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const{lineStartIndex:g,glyphStartIndex:y,segment:v}=a,_=y+a.numGlyphs,x=g+a.lineLength,b=e.getoffsetX(y),w=e.getoffsetX(_-1),A=pe(t*b,i,n,r,o,s,v,g,x,l,c,u,h,p,!0,d,f,m);if(!A)return null;const E=pe(t*w,i,n,r,o,s,v,g,x,l,c,u,h,p,!0,d,f,m);return E?{first:A,last:E}:null}function le(e,i,n,r){return e===t.WritingMode.horizontal&&Math.abs(r)>Math.abs(n)?{useVertical:!0}:e===t.WritingMode.vertical?r>0?{needsFlipping:!0}:null:i!==Kt.unknown&&function(t,e){return 0===t||Math.abs(e/t)>$t}(n,r)?i===Kt.flipRequired?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function ce(e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v,_){const x=i/24,b=e.lineOffsetX*x,w=e.lineOffsetY*x,{lineStartIndex:A,glyphStartIndex:E,numGlyphs:S,segment:M,writingMode:T,flipState:I}=e,C=A+e.lineLength,P=e=>{if(h){const[i,n,r]=e.up,o=u.length;t.updateGlobeVertexNormal(h,o+0,i,n,r),t.updateGlobeVertexNormal(h,o+1,i,n,r),t.updateGlobeVertexNormal(h,o+2,i,n,r),t.updateGlobeVertexNormal(h,o+3,i,n,r)}const[i,n,r]=e.point;t.addDynamicAttributes(u,i,n,r,e.angle)};if(S>1){const t=ae(x,l,b,w,n,p,d,e,c,s,f,g,!1,y,v,_);if(!t)return{notEnoughRoom:!0};if(r&&!n){let[i,n,r]=t.first.point,[o,s,l]=t.last.point;[i,n]=ne(i,n,r,a),[o,s]=ne(o,s,l,a);const c=le(T,I,(o-i)*m,s-n);if(e.flipState=c&&c.needsFlipping?Kt.flipRequired:Kt.flipNotRequired,c)return c}P(t.first);for(let t=E+1;t0?s:he(d,r,i,1,o,void 0,y,v.canonical),l=le(T,I,(a[0]-i[0])*m,a[1]-i[1]);if(e.flipState=l&&l.needsFlipping?Kt.flipRequired:Kt.flipNotRequired,l)return l}const i=pe(x*l.getoffsetX(E),b,w,n,p,d,M,A,C,c,s,f,g,!1,!1,y,v,_);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function ue(t,e,i,n,r){const{x:o,y:s,z:a}=n.projectTilePoint(t.x,t.y,e);if(!r)return ne(o,s,a,i);const[l,c,u]=r(t);return ne(o+l,s+c,a+u,i)}function he(e,i,n,r,o,s,a,l){const c=ue(e.sub(i)._unit()._add(e),l,o,a,s);return t.sub(c,n,c),t.normalize(c,c),t.scaleAndAdd(c,n,c,r)}function pe(e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y,v){const _=r?e-i:e+i;let x=_>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+a+(x>0?0:1)|0,A=o,E=o,S=0,M=0;const T=Math.abs(_),I=[],C=[];let P=s,L=P;const D=()=>he(L,P,E,T-S+1,h,d,g,y.canonical);for(;S+M<=T;){if(w+=x,w=c)return null;if(E=A,L=P,I.push(E),f&&C.push(L),P=new t.Point(u.getx(w),u.gety(w)),A=p[w],!A){const t=ue(P,y.canonical,h,g,d);A=t[3]>0?p[w]=t:D()}S+=M,M=t.distance(E,A)}m&&d&&(p[w]&&(A=D(),M=t.distance(E,A)),p[w]=A);const R=(T-S)/M,O=P.sub(L)._mult(R)._add(L),k=t.sub([],A,E),N=t.scaleAndAdd([],E,k,R);let B=[0,0,1],z=k[0],F=k[1];if(v&&(B=g.upVector(y.canonical,O.x,O.y),0!==B[0]||0!==B[1]||1!==B[2])){const e=[B[2],0,-B[0]],i=t.cross([],B,e);t.normalize(e,e),t.normalize(i,i),z=t.dot(k,e),F=t.dot(k,i)}if(n){const e=t.cross([],B,k);t.normalize(e,e),t.scaleAndAdd(N,N,e,n*x)}const V=b+Math.atan2(F,z);return I.push(N),f&&C.push(O),{point:N,angle:V,path:I,tilePath:C,up:B}}function de(t,e){const i=e.length,n=i+4*t;e.resize(n),e.float32.fill(-1/0,4*i,4*n)}function fe(t,e,i){const n=e[0],r=e[1];return t[0]=i[0]*n+i[4]*r+i[12],t[1]=i[1]*n+i[5]*r+i[13],t[3]=i[3]*n+i[7]*r+i[15],t}const me=100;class ge{constructor(t,e,i=new Jt(t.width+200,t.height+200,25),n=new Jt(t.width+200,t.height+200,25)){this.transform=t,this.grid=i,this.ignoredGrid=n,this.pitchfactor=Math.cos(t._pitch)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+me,this.screenBottomBoundary=t.height+me,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.fogState=e}placeCollisionBox(t,e,i,n,r,o,s,a){let l=i.projectedAnchorX,c=i.projectedAnchorY,u=i.projectedAnchorZ;const h=i.elevation,p=i.tileID,d=t.getProjection();if(h&&p){const[t,e,n]=d.upVector(p.canonical,i.tileAnchorX,i.tileAnchorY),r=d.upVectorScale(p.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=t*h*r,c+=e*h*r,u+=n*h*r}const f=this.projectAndGetPerspectiveRatio(s,l,c,u,i.tileID,"globe"===d.name||!!h||this.transform.pitch>0,d),m=o*f.perspectiveRatio,g=(i.x1*e+n.x-i.padding)*m+f.point.x,y=(i.y1*e+n.y-i.padding)*m+f.point.y,v=(i.x2*e+n.x+i.padding)*m+f.point.x,_=(i.y2*e+n.y+i.padding)*m+f.point.y,x=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(g,y,v,_)||!r&&this.grid.hitTest(g,y,v,_,a)||x?{box:[],offscreen:!1,occluded:f.occluded}:{box:[g,y,v,_],offscreen:this.isOffscreen(g,y,v,_),occluded:!1}}placeCollisionCircles(e,i,n,r,o,s,a,l,c,u,h,p,d,f,m){const g=[],y=this.transform.elevation,v=e.getProjection(),_=y?y.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,v):null,x=new t.Point(n.tileAnchorX,n.tileAnchorY);let{x:b,y:w,z:A}=v.projectTilePoint(x.x,x.y,m.canonical);if(_){const[t,e,i]=_(x);b+=t,w+=e,A+=i}const E="globe"===v.name,S=this.projectAndGetPerspectiveRatio(a,b,w,A,m,E||!!y||this.transform.pitch>0,v),{perspectiveRatio:M}=S,T=(h?s/M:s*M)/t.ONE_EM,I=ne(b,w,A,l),C=S.signedDistanceFromCamera>0?ae(T,o,n.lineOffsetX*T,n.lineOffsetY*T,!1,I,x,n,r,l,{},y&&!h?_:null,h&&!!y,v,m,h):null;let P=!1,L=!1,D=!0;if(C&&!S.occluded){const e=.5*d*M+f,n=new t.Point(-100,-100),r=new t.Point(this.screenRightBoundary,this.screenBottomBoundary),o=new Qt,{first:s,last:a}=C,l=s.path.length;let h=[];for(let t=l-1;t>=1;t--)h.push(s.path[t]);for(let t=1;t(_&&!E&&(i=_(nt[3]<=0))&&(h=[]));let y=[];if(h.length>0){let e=1/0,i=-1/0,o=1/0,s=-1/0;for(const t of h)e=Math.min(e,t[0]),o=Math.min(o,t[1]),i=Math.max(i,t[0]),s=Math.max(s,t[1]);i>=n.x&&e<=r.x&&s>=n.y&&o<=r.y&&(y=[h.map((e=>new t.Point(e[0],e[1])))],(er.x||or.y)&&(y=t.clipLine(y,n.x,n.y,r.x,r.y)))}for(const t of y){o.reset(t,.25*e);let n=0;n=o.length<=.5*e?1:Math.ceil(o.paddedLength/m)+1;for(let t=0;t0){if(t.transformMat4$1(l,l,e),this.fogState&&o&&"globe"!==a.name){const e=function(e,i,n,r,o,s){const a=s.calculateFogTileMatrix(o),l=[i,n,r];return t.transformMat4(l,l,a),S(e,l,s.pitch,s._fov)}(this.fogState,i,n,r,o.toUnwrapped(),this.transform);c=e>.9}}else fe(l,l,e);const u=l[3];return{point:new t.Point((l[0]/u+1)/2*this.transform.width+me,(-l[1]/u+1)/2*this.transform.height+me),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(t,e,i,n){return i=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(t,e,i,n){return i>=0&&t=0&&et.collisionGroupID===e}}return this.collisionGroups[t]}}function Me(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.getAnchorAlignment(e),l=-(s-.5)*i,c=-(a-.5)*n,u=t.evaluateVariableOffset(e,r);return new t.Point(l+u[0]*o,c+u[1]*o)}function Te(e,i,n,r,o){const s=new t.Point(e,i);return n&&s._rotate(r?o:-o),s}class Ie{constructor(t,e,i,n,r){this.transform=t.clone(),this.projection=t.projection.name,this.collisionIndex=new ge(this.transform,r),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=e,this.retainedQueryData={},this.collisionGroups=new Se(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=o.layers[0].layout,l=n.collisionBoxArray,c=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),u=n.tileSize/t.EXTENT,h=n.tileID.toUnwrapped();this.transform.setProjection(o.projection);const p=(d=n.tileID,f=o.getProjection(),m=this.transform,f.name===this.projection?m.calculateProjMatrix(d.toUnwrapped()):ye(m,f,d));var d,f,m;const g="map"===a.get("text-pitch-alignment"),y="map"===a.get("text-rotation-alignment");i.compileFilter();const v=i.dynamicFilter(),_=i.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(n),b=ee(p,n.tileID.canonical,g,y,this.transform,o.getProjection(),x);let w=null;if(g){const e=ie(p,n.tileID.canonical,g,y,this.transform,o.getProjection(),x);w=t.multiply([],this.transform.labelPlaneMatrix,e)}let A=null;v&&n.latestFeatureIndex&&(A={unwrappedTileID:h,dynamicFilter:v,dynamicFilterNeedsFeature:_,featureIndex:n.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Ee(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const E={bucket:o,layout:a,posMatrix:p,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:A,scale:c,textPixelRatio:u,holdingForFade:n.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:t.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:t.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:E})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:E})}attemptAnchorPlacement(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g,y){const{textOffset0:v,textOffset1:_,crossTileID:x}=h,b=[v,_],w=Me(t,i,n,b,r),A=this.collisionIndex.placeCollisionBox(d,r,e,Te(w.x,w.y,o,s,this.transform.angle),u,a,l,c.predicate);if(m){const t=d.getSymbolInstanceIconSize(y,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(d,t,m,Te(w.x,w.y,o,s,this.transform.angle),u,a,l,c.predicate).box.length)return}if(A.box.length>0){let e;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(e=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:b,width:i,height:n,anchor:t,textScale:r,prevAnchor:e},this.markUsedJustification(d,t,h,f),d.allowVerticalPlacement&&(this.markUsedOrientation(d,f,h),this.placedOrientations[x]=f),{shift:w,placedGlyphBoxes:A}}}placeLayerBucketPart(e,i,n,r){const{bucket:o,layout:s,posMatrix:a,textLabelPlaneMatrix:l,labelToScreenMatrix:c,clippingData:u,textPixelRatio:h,holdingForFade:p,collisionBoxArray:d,partiallyEvaluatedTextSize:f,partiallyEvaluatedIconSize:m,collisionGroup:g}=e.parameters,y=s.get("text-optional"),v=s.get("icon-optional"),_=s.get("text-allow-overlap"),x=s.get("icon-allow-overlap"),b="map"===s.get("text-rotation-alignment"),w="map"===s.get("text-pitch-alignment"),A="none"!==s.get("icon-text-fit"),E="viewport-y"===s.get("symbol-z-order");this.transform.setProjection(o.projection);let S=_&&(x||!o.hasIconData()||v),M=x&&(_||!o.hasTextData()||y);!o.collisionArrays&&d&&o.deserializeCollisionBoxes(d),n&&r&&o.updateCollisionDebugBuffers(this.transform.zoom,d);const T=(e,r,d)=>{const{crossTileID:E,numVerticalGlyphVertices:T}=e;if(u){const n={zoom:this.transform.zoom,pitch:this.transform.pitch};let r=null;if(u.dynamicFilterNeedsFeature){const t=this.retainedQueryData[o.bucketInstanceId];r=u.featureIndex.loadFeature({featureIndex:e.featureIndex,bucketIndex:t.bucketIndex,sourceLayerIndex:t.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,u.dynamicFilter)(n,r,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new t.Point(e.tileAnchorX,e.tileAnchorY),this.transform.calculateDistanceTileData(u.unwrappedTileID)))return this.placements[E]=new we(!1,!1,!1,!0),void i.add(E)}if(i.has(E))return;if(p)return void(this.placements[E]=new we(!1,!1,!1));let I=!1,C=!1,P=!0,L=!1,D=!1,R=null,O={box:null,offscreen:null,occluded:null},k={box:null,offscreen:null,occluded:null},N=null,B=null,z=null,F=0,V=0,U=0;d.textFeatureIndex?F=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(F=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=t=>{t.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const e=this.transform.elevation;(e||t.elevation)&&(t.elevation=e?e.getAtTileOffset(t.tileID,t.tileAnchorX,t.tileAnchorY):0)},j=d.textBox;if(j){G(j);const i=i=>{let n=t.WritingMode.horizontal;if(o.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[E];t&&(this.placedOrientations[E]=t,n=t,this.markUsedOrientation(o,n,e))}return n},n=(e,i)=>{if(o.allowVerticalPlacement&&T>0&&d.verticalTextBox){for(const n of o.writingModes)if(n===t.WritingMode.vertical?(O=i(),k=O):O=e(),O&&O.box&&O.box.length)break}else O=e()};if(s.get("text-variable-anchor")){let l=s.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[E]){const t=this.prevPlacement.variableOffsets[E];l.indexOf(t.anchor)>0&&(l=l.filter((e=>e!==t.anchor)),l.unshift(t.anchor))}const c=(t,i,n)=>{const s=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),c=(t.x2-t.x1)*s+2*t.padding,u=(t.y2-t.y1)*s+2*t.padding,p=A&&!x?i:null;p&&G(p);let d={box:[],offscreen:!1,occluded:!1};const y=_?2*l.length:l.length;for(let i=0;i=l.length,e,r,o,n,p,f,m);if(y&&(d=y.placedGlyphBoxes,d&&d.box&&d.box.length)){I=!0,R=y.shift;break}}return d};n((()=>c(j,d.iconBox,t.WritingMode.horizontal)),(()=>{const e=d.verticalTextBox;return e&&G(e),o.allowVerticalPlacement&&!(O&&O.box&&O.box.length)&&T>0&&e?c(e,d.verticalIconBox,t.WritingMode.vertical):{box:null,offscreen:null,occluded:null}})),O&&(I=O.box,P=O.offscreen,L=O.occluded);const u=i(!(!O||!O.box));if(!I&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[E];t&&(this.variableOffsets[E]=t,this.markUsedJustification(o,t.anchor,e,u))}}else{const s=(i,n)=>{const s=o.getSymbolInstanceTextSize(f,e,this.transform.zoom,r),l=this.collisionIndex.placeCollisionBox(o,s,i,new t.Point(0,0),_,h,a,g.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,n,e),this.placedOrientations[E]=n),l};n((()=>s(j,t.WritingMode.horizontal)),(()=>{const e=d.verticalTextBox;return o.allowVerticalPlacement&&T>0&&e?(G(e),s(e,t.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}})),i(!!(O&&O.box&&O.box.length))}}if(N=O,I=N&&N.box&&N.box.length>0,P=N&&N.offscreen,L=N&&N.occluded,e.useRuntimeCollisionCircles){const i=o.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex>=0?e.centerJustifiedTextSymbolIndex:e.verticalPlacedTextSymbolIndex),r=t.evaluateSizeForFeature(o.textSizeData,f,i),u=s.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,_,i,o.lineVertexArray,o.glyphOffsetArray,r,a,l,c,n,w,g.predicate,e.collisionCircleDiameter*r/t.ONE_EM,u,this.retainedQueryData[o.bucketInstanceId].tileID),I=_||B.circles.length>0&&!B.collisionDetected,P=P&&B.offscreen,L=B.occluded}if(d.iconFeatureIndex&&(U=d.iconFeatureIndex),d.iconBox){const i=i=>{G(i);const n=A&&R?Te(R.x,R.y,b,w,this.transform.angle):new t.Point(0,0),r=o.getSymbolInstanceIconSize(m,this.transform.zoom,e.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,r,i,n,x,h,a,g.predicate)};k&&k.box&&k.box.length&&d.verticalIconBox?(z=i(d.verticalIconBox),C=z.box.length>0):(z=i(d.iconBox),C=z.box.length>0),P=P&&z.offscreen,D=z.occluded}const H=y||0===e.numHorizontalGlyphVertices&&0===T,W=v||0===e.numIconVertices;if(H||W?W?H||(C=C&&I):I=C&&I:C=I=C&&I,I&&N&&N.box&&this.collisionIndex.insertCollisionBox(N.box,s.get("text-ignore-placement"),o.bucketInstanceId,k&&k.box&&V?V:F,g.ID),C&&z&&this.collisionIndex.insertCollisionBox(z.box,s.get("icon-ignore-placement"),o.bucketInstanceId,U,g.ID),B&&(I&&this.collisionIndex.insertCollisionCircles(B.circles,s.get("text-ignore-placement"),o.bucketInstanceId,F,g.ID),n)){const t=o.bucketInstanceId;let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=new Ae);for(let t=0;t=0;--e){const i=t[e];T(o.symbolInstances.get(i),i,o.collisionArrays[i])}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(e.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(e.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(e.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(e,i,n){const r=i===t.WritingMode.horizontal||i===t.WritingMode.horizontalOnly?i:0,o=i===t.WritingMode.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=n,u=e.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=r),c>=0&&(u.get(c).placedOrientation=o)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const n=e?e.symbolFadeChange(t):1,r=e?e.opacities:{},o=e?e.variableOffsets:{},s=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],o=r[t];o?(this.opacities[t]=new be(o,n,e.text,e.icon,null,e.clipped),i=i||e.text!==o.text.placed||e.icon!==o.icon.placed):(this.opacities[t]=new be(null,n,e.text,e.icon,e.skipFade,e.clipped),i=i||e.text||e.icon)}for(const t in r){const e=r[t];if(!this.opacities[t]){const r=new be(e,n,!1,!1);r.isHidden()||(this.opacities[t]=r,i=i||e.text.placed||e.icon.placed)}}for(const t in o)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=o[t]);for(const t in s)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=s[t]);i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i=new Set;for(const n of e){const e=n.getBucket(t);e&&n.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n){e.hasTextData()&&e.text.opacityVertexArray.clear(),e.hasIconData()&&e.icon.opacityVertexArray.clear(),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const r=e.layers[0].layout,o=!!e.layers[0].dynamicFilter(),s=new be(null,0,!1,!1,!0),a=r.get("text-allow-overlap"),l=r.get("icon-allow-overlap"),c=r.get("text-variable-anchor"),u="map"===r.get("text-rotation-alignment"),h="map"===r.get("text-pitch-alignment"),p="none"!==r.get("icon-text-fit"),d=new be(null,0,a&&(l||!e.hasIconData()||r.get("icon-optional")),l&&(a||!e.hasTextData()||r.get("text-optional")),!0);!e.collisionArrays&&n&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(n);const f=(t,e,i)=>{for(let n=0;n0||l>0,b=y>0,w=this.placedOrientations[g],A=w===t.WritingMode.vertical,E=w===t.WritingMode.horizontal||w===t.WritingMode.horizontalOnly;if(!x&&!b||_.isHidden()||m++,x){const t=Be(_.text);f(e.text,a,A?ze:t),f(e.text,l,E?ze:t);const i=_.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:s,verticalPlacedTextSymbolIndex:c}=r,u=e.text.placedSymbolArray,h=i||A?1:0;n>=0&&(u.get(n).hidden=h),o>=0&&(u.get(o).hidden=h),s>=0&&(u.get(s).hidden=h),c>=0&&(u.get(c).hidden=i||E?1:0);const p=this.variableOffsets[g];p&&this.markUsedJustification(e,p.anchor,r,w);const d=this.placedOrientations[g];d&&(this.markUsedJustification(e,"left",r,d),this.markUsedOrientation(e,d,r))}if(b){const t=Be(_.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=r,o=e.icon.placedSymbolArray,s=_.icon.isHidden()?1:0;i>=0&&(f(e.icon,y,A?ze:t),o.get(i).hidden=s),n>=0&&(f(e.icon,r.numVerticalIconVertices,E?ze:t),o.get(n).hidden=s)}if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const i=e.collisionArrays[n];if(i){let n=new t.Point(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(c){const t=this.variableOffsets[g];t?(n=Me(t.anchor,t.width,t.height,t.textOffset,t.textScale),u&&n._rotate(h?this.transform.angle:-this.transform.angle)):r=!1}o&&(r=!_.clipped),i.textBox&&Ce(e.textCollisionBox.collisionVertexArray,_.text.placed,!r||A,n.x,n.y),i.verticalTextBox&&Ce(e.textCollisionBox.collisionVertexArray,_.text.placed,!r||E,n.x,n.y)}const s=r&&Boolean(!E&&i.verticalIconBox);i.iconBox&&Ce(e.iconCollisionBox.collisionVertexArray,_.icon.placed,s,p?n.x:0,p?n.y:0),i.verticalIconBox&&Ce(e.iconCollisionBox.collisionVertexArray,_.icon.placed,!s,p?n.x:0,p?n.y:0)}}}if(e.fullyClipped=0===m,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){const t=this.collisionCircleArrays[e.bucketInstanceId];e.placementInvProjMatrix=t.invProjMatrix,e.placementViewportMatrix=t.viewportMatrix,e.collisionCircleArray=t.circles,delete this.collisionCircleArrays[e.bucketInstanceId]}}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function Ce(t,e,i,n,r){t.emplaceBack(e?1:0,i?1:0,n||0,r||0),t.emplaceBack(e?1:0,i?1:0,n||0,r||0),t.emplaceBack(e?1:0,i?1:0,n||0,r||0),t.emplaceBack(e?1:0,i?1:0,n||0,r||0)}const Pe=Math.pow(2,25),Le=Math.pow(2,24),De=Math.pow(2,17),Re=Math.pow(2,16),Oe=Math.pow(2,9),ke=Math.pow(2,8),Ne=Math.pow(2,1);function Be(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*Pe+e*Le+i*De+e*Re+i*Oe+e*ke+i*Ne+e}const ze=0;class Fe{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&void 0!==t.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(t,e,i,n,r){const o=this._bucketParts;for(;this._currentTileIndext.sortKey-e.sortKey)));this._currentPartIndex{const e=t.exported.now()-r;return!this._forceFullPlacement&&e>2};for(;this._currentPlacementIndex>=0;){const t=i[e[this._currentPlacementIndex]],r=this.placement.collisionIndex.transform.zoom;if("symbol"===t.type&&(!t.minzoom||t.minzoom<=r)&&(!t.maxzoom||t.maxzoom>r)){if(this._inProgressLayer||(this._inProgressLayer=new Fe(t)),this._inProgressLayer.continuePlacement(n[t.source],this.placement,this._showCollisionBoxes,t,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Ue=512/t.EXTENT/2;class Ge{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this.index=new t.KDBush(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=e.canonical.x*t.EXTENT,o=e.canonical.y*t.EXTENT;for(let t=0;tt.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(t)&&o.findMatches(e.symbolInstances,t,n)}else{const o=r[t.scaledTo(Number(i)).key];o&&o.findMatches(e.symbolInstances,t,n)}}for(let t=0;t{e[t]=!0}));for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}const qe=(e,i)=>t.emitValidationErrors(e,i&&i.filter((t=>"source.canvas"!==t.identifier))),Xe=t.pick(Gt,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Ze=t.pick(Gt,["setCenter","setZoom","setBearing","setPitch"]),Ye={version:8,layers:[],sources:{}},Qe={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Je extends t.Evented{constructor(e,i={}){super(),this.map=e,this.dispatcher=new C(Ft(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new t.GlyphManager(e._requestManager,i.localFontFamily?t.LocalGlyphMode.all:i.localIdeographFontFamily?t.LocalGlyphMode.ideographs:t.LocalGlyphMode.none,i.localFontFamily||i.localIdeographFontFamily),this.crossTileSymbolIndex=new We,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",t.getReferrer());const n=this;this._rtlTextPluginCallback=Je.registerForPluginStateChange((e=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:e.pluginStatus,pluginURL:e.pluginURL},((e,i)=>{if(t.triggerPluginCompletionEvent(e),i&&i.every((t=>t)))for(const t in n._sourceCaches){const e=n._sourceCaches[t],i=e.getSource().type;"vector"!==i&&"geojson"!==i||e.reload()}}))})),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.getSource(t.sourceId);if(e&&e.vectorLayerIds)for(const t in this._layers){const i=this._layers[t];i.source===e.id&&this._validateLayer(i)}}))}loadURL(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!t.isMapboxURL(e);e=this.map._requestManager.normalizeStyleURL(e,i.accessToken);const r=this.map._requestManager.transformRequest(e,t.ResourceType.Style);this._request=t.getJSON(r,((e,i)=>{this._request=null,e?this.fire(new t.ErrorEvent(e)):i&&this._load(i,n)}))}loadJSON(e,i={}){this.fire(new t.Event("dataloading",{dataType:"style"})),this._request=t.exported.frame((()=>{this._request=null,this._load(e,!1!==i.validate)}))}loadEmpty(){this.fire(new t.Event("dataloading",{dataType:"style"})),this._load(Ye,!1)}_updateLayerCount(t,e){const i=e?1:-1;t.is3D()&&(this._num3DLayers+=i),"circle"===t.type&&(this._numCircleLayers+=i),"symbol"===t.type&&(this._numSymbolLayers+=i)}_load(e,i){if(i&&qe(this,t.validateStyle(e)))return;this._loaded=!0,this.stylesheet=t.clone$1(e),this._updateMapProjection();for(const t in e.sources)this.addSource(t,e.sources[t],{validate:!1});this._changed=!1,e.sprite?this._loadSprite(e.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(e.glyphs);const n=Ut(this.stylesheet.layers);this._order=n.map((t=>t.id)),this._layers={},this._serializedLayers={};for(const e of n){const i=t.createStyleLayer(e);i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i,this._serializedLayers[i.id]=i.serialize(),this._updateLayerCount(i,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new w(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new t.Event("data",{dataType:"style"})),this.fire(new t.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(t){t?this.stylesheet.projection=t:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(e){this._spriteRequest=function(e,i,n){let r,o,s;const a=t.exported.devicePixelRatio>1?"@2x":"";let l=t.getJSON(i.transformRequest(i.normalizeSpriteURL(e,a,".json"),t.ResourceType.SpriteJSON),((t,e)=>{l=null,s||(s=t,r=e,u())})),c=t.getImage(i.transformRequest(i.normalizeSpriteURL(e,a,".png"),t.ResourceType.SpriteImage),((t,e)=>{c=null,s||(s=t,o=e,u())}));function u(){if(s)n(s);else if(r&&o){const e=t.exported.getImageData(o),i={};for(const n in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:p,content:d}=r[n],f=new t.RGBAImage({width:o,height:s});t.RGBAImage.copy(e,f,{x:a,y:l},{x:0,y:0},{width:o,height:s}),i[n]={data:f,pixelRatio:u,sdf:c,stretchX:h,stretchY:p,content:d}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(e,this.map._requestManager,((e,i)=>{if(this._spriteRequest=null,e)this.fire(new t.ErrorEvent(e));else if(i)for(const t in i)this.imageManager.addImage(t,i[t]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new t.Event("data",{dataType:"style"}))}))}_validateLayer(e){const i=this.getSource(e.source);if(!i)return;const n=e.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new t.ErrorEvent(new Error(`Source layer "${n}" does not exist on source "${i.id}" as specified by style layer "${e.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this._sourceCaches)if(!this._sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(t){const e=[];for(const i of t){const t=this._layers[i];"custom"!==t.type&&e.push(t.serialize())}return e}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const t in this._sourceCaches)if(this._sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(t){return!!this.terrain&&("function"==typeof t.isLayerDraped?t.isLayerDraped():Qe[t.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(e){if(!this._loaded)return;const i=this._changed;if(this._changed){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const t in this._updatedSources){const e=this._updatedSources[t];"reload"===e?this._reloadSource(t):"clear"===e&&this._clearSource(t)}this._updateTilesForChangedImages();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.fog&&this.fog.updateTransitions(e),this._resetUpdates()}const n={};for(const t in this._sourceCaches){const e=this._sourceCaches[t];n[t]=e.used,e.used=!1}for(const t of this._order){const i=this._layers[t];if(i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)){const t=this._getLayerSourceCache(i);t&&(t.used=!0)}const n=this.map.painter;if(n){const t=i.getProgramIds();if(!t)continue;const r=i.getProgramConfiguration(e.zoom);for(const e of t)n.useProgram(e,r)}}for(const e in n){const i=this._sourceCaches[e];n[e]!==i.used&&i.getSource().fire(new t.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:i.getSource().id}))}this.light.recalculate(e),this.terrain&&this.terrain.recalculate(e),this.fog&&this.fog.recalculate(e),this.z=e.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),i&&this.fire(new t.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this._sourceCaches)this._sourceCaches[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(t),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(i){if(this._checkLoaded(),qe(this,t.validateStyle(i)))return!1;(i=t.clone$1(i)).layers=Ut(i.layers);const n=function(t,i){if(!t)return[{command:Gt.setStyle,args:[i]}];let n=[];try{if(!e(t.version,i.version))return[{command:Gt.setStyle,args:[i]}];e(t.center,i.center)||n.push({command:Gt.setCenter,args:[i.center]}),e(t.zoom,i.zoom)||n.push({command:Gt.setZoom,args:[i.zoom]}),e(t.bearing,i.bearing)||n.push({command:Gt.setBearing,args:[i.bearing]}),e(t.pitch,i.pitch)||n.push({command:Gt.setPitch,args:[i.pitch]}),e(t.sprite,i.sprite)||n.push({command:Gt.setSprite,args:[i.sprite]}),e(t.glyphs,i.glyphs)||n.push({command:Gt.setGlyphs,args:[i.glyphs]}),e(t.transition,i.transition)||n.push({command:Gt.setTransition,args:[i.transition]}),e(t.light,i.light)||n.push({command:Gt.setLight,args:[i.light]}),e(t.fog,i.fog)||n.push({command:Gt.setFog,args:[i.fog]}),e(t.projection,i.projection)||n.push({command:Gt.setProjection,args:[i.projection]});const r={},o=[];!function(t,i,n,r){let o;for(o in i=i||{},t=t||{})t.hasOwnProperty(o)&&(i.hasOwnProperty(o)||Ht(o,n,r));for(o in i){if(!i.hasOwnProperty(o))continue;const s=i[o];t.hasOwnProperty(o)?e(t[o],s)||("geojson"===t[o].type&&"geojson"===s.type&&qt(t,i,o)?n.push({command:Gt.setGeoJSONSourceData,args:[o,s.data]}):Wt(o,i,n,r)):jt(o,i,n)}}(t.sources,i.sources,o,r);const s=[];t.layers&&t.layers.forEach((t=>{t.source&&r[t.source]?n.push({command:Gt.removeLayer,args:[t.id]}):s.push(t)}));let a=t.terrain;a&&r[a.source]&&(n.push({command:Gt.setTerrain,args:[void 0]}),a=void 0),n=n.concat(o),e(a,i.terrain)||n.push({command:Gt.setTerrain,args:[i.terrain]}),function(t,i,n){i=i||[];const r=(t=t||[]).map(Zt),o=i.map(Zt),s=t.reduce(Yt,{}),a=i.reduce(Yt,{}),l=r.slice(),c=Object.create(null);let u,h,p,d,f,m,g;for(u=0,h=0;u!(t.command in Ze)));if(0===n.length)return!1;const r=n.filter((t=>!(t.command in Xe)));if(r.length>0)throw new Error(`Unimplemented: ${r.map((t=>t.command)).join(", ")}.`);return n.forEach((t=>{"setTransition"!==t.command&&"setProjection"!==t.command&&this[t.command].apply(this,t.args)})),this.stylesheet=i,this._updateMapProjection(),!0}addImage(e,i){return this.getImage(e)?this.fire(new t.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(e,i),this._afterImageUpdated(e),this)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(e){return this.getImage(e)?(this.imageManager.removeImage(e),this._afterImageUpdated(e),this):this.fire(new t.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(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"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(e,i,n={}){if(this._checkLoaded(),void 0!==this.getSource(e))throw new Error("There is already a source with this ID");if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(i.type)>=0&&this._validate(t.validateSource,`sources.${e}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=Pt(e,i,this.dispatcher,this);r.setEventedParent(this,(()=>({isSourceLoaded:this._isSourceCacheLoaded(e),source:r.serialize(),sourceId:e})));const o=i=>{const n=(i?"symbol:":"other:")+e,o=this._sourceCaches[n]=new t.SourceCache(n,r,i);(i?this._symbolSourceCaches:this._otherSourceCaches)[e]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),r.onAdd&&r.onAdd(this.map),this._changed=!0}removeSource(e){this._checkLoaded();const i=this.getSource(e);if(!i)throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));if(this.terrain&&this.terrain.get().source===e)return this.fire(new t.ErrorEvent(new Error(`Source "${e}" cannot be removed while terrain is using it.`)));const n=this._getSourceCaches(e);for(const e of n)delete this._sourceCaches[e.id],delete this._updatedSources[e.id],e.fire(new t.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:e.getSource().id})),e.setEventedParent(null),e.clearTiles();return delete this._otherSourceCaches[e],delete this._symbolSourceCaches[e],i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(t,e){this._checkLoaded(),this.getSource(t).setData(e),this._changed=!0}getSource(t){const e=this._getSourceCache(t);return e&&e.getSource()}_getSources(){const t=[];for(const e in this._otherSourceCaches){const i=this._getSourceCache(e);i&&t.push(i.getSource())}return t}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===e.type){if(qe(this,t.validateCustomStyleLayer(e)))return;o=t.createStyleLayer(e)}else{if("object"==typeof e.source&&(this.addSource(r,e.source),e=t.clone$1(e),e=t.extend(e,{source:r})),this._validate(t.validateLayer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.createStyleLayer(e),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)return void this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`)));this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o;const a=this._getLayerSourceCache(o);if(this._removedLayers[r]&&o.source&&a&&"custom"!==o.type){const t=this._removedLayers[r];delete this._removedLayers[r],t.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",a.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.ErrorEvent(new Error(`Layer with id "${i}" does not exist on this map.`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot be removed.`)));i.setEventedParent(null),this._updateLayerCount(i,!1);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(t){return this._layers[t]}hasLayer(t){return t in this._layers}hasLayerType(t){for(const e in this._layers)if(this._layers[e].type===t)return!0;return!1}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(i,n,r={}){this._checkLoaded();const o=this.getLayer(i);if(o){if(!e(o.filter,n))return null==n?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(t.validateFilter,`layers.${o.id}.filter`,n,{layerType:o.type},r)||(o.filter=t.clone$1(n),this._updateLayer(o)))}else this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be filtered.`)))}getFilter(e){const i=this.getLayer(e);return i&&t.clone$1(i.filter)}setLayoutProperty(i,n,r,o={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getLayoutProperty(n),r)||(s.setLayoutProperty(n,r,o),this._updateLayer(s)):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.ErrorEvent(new Error(`The layer '${e}' does not exist in the map's style.`)))}setPaintProperty(i,n,r,o={}){this._checkLoaded();const s=this.getLayer(i);s?e(s.getPaintProperty(n),r)||(s.setPaintProperty(n,r,o)&&this._updateLayer(s),this._changed=!0,this._updatedPaintProps[i]=!0):this.fire(new t.ErrorEvent(new Error(`The layer '${i}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(t,e){const i=this.getLayer(t);return i&&i.getPaintProperty(e)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.getSource(n);if(!o)return void this.fire(new t.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.type;if("geojson"===s&&r)return void this.fire(new t.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided.")));const a=this._getSourceCaches(n);for(const t of a)t.setFeatureState(r,e.id,i)}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.getSource(n);if(!r)return void this.fire(new t.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.type,s="vector"===o?e.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new t.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(i&&"string"!=typeof e.id&&"number"!=typeof e.id)return void this.fire(new t.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const a=this._getSourceCaches(n);for(const t of a)t.removeFeatureState(s,e.id,i)}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.getSource(i);if(r){if("vector"!==r.type||n)return void 0===e.id&&this.fire(new t.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(i)[0].getFeatureState(n,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 '${i}' does not exist in the map's style.`)))}getTransition(){return t.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const e={};for(const t in this._sourceCaches){const i=this._sourceCaches[t].getSource();e[i.id]||(e[i.id]=i.serialize())}return t.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,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,projection:this.stylesheet.projection,sources:e,layers:this._serializeLayers(this._order)},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0;const e=this._getLayerSourceCache(t);t.source&&!this._updatedSources[t.source]&&e&&"raster"!==e.getSource().type&&(this._updatedSources[t.source]="reload",e.pause()),this._changed=!0,t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(e(o)){i[o]=r;for(const e of t){const t=e[o];if(t)for(const e of t)n.push(e)}}}n.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(e(s))for(let t=n.length-1;t>=0;t--){const e=n[t].feature;if(i[e.layer.id]{const e=this.getLayer(t);return e&&e.is3D()})):this.has3DLayers(),a=L.createFromScreenPoints(e,n);for(const t in this._sourceCaches){const e=this._sourceCaches[t].getSource().id;i.layers&&!r[e]||o.push(Dt(this._sourceCaches[t],this._layers,this._serializedLayers,a,i,n,s,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(t,e,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const t of Object.keys(l).map(Number))c.push(s[t]);c.sort(Ot);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,r.filter,r.layers,r.availableImages,t);for(const t in n){const e=a[t]=a[t]||[],r=n[t];r.sort(((t,e)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(t.featureIndex);return n.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const t of r)e.push(t)}}for(const e in a)a[e].forEach((n=>{const r=n.feature,o=i(t[e]);if(!o)return;const s=o.getFeatureState(r.layer["source-layer"],r.id);r.source=r.layer.source,r.layer["source-layer"]&&(r.sourceLayer=r.layer["source-layer"]),r.state=s}));return a}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),a.screenGeometry,i,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){i&&i.filter&&this._validate(t.validateFilter,"querySourceFeatures.filter",i.filter,null,i);const n=this._getSourceCaches(e);let r=[];for(const t of n)r=r.concat(Rt(t,i));return r}addSourceType(t,e,i){return Je.getSourceType(t)?i(new Error(`A source type called "${t}" already exists.`)):(Je.setSourceType(t,e),e.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:t,url:e.workerSourceURL},i):i(null,null))}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const n=this.light.getLight();let r=!1;for(const i in t)if(!e(t[i],n[i])){r=!0;break}if(!r)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(t,i),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(i,n=1){if(this._checkLoaded(),!i)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let r=i;if(1===n){if("object"==typeof r.source){const e="terrain-dem-src";this.addSource(e,r.source),r=t.clone$1(r),r=t.extend(r,{source:e})}if(this._validate(t.validateTerrain,"terrain",r))return}if(!this.terrain||this.terrain&&n!==this.terrain.drapeRenderMode){if(!r)return;this._createTerrain(r,n)}else{const i=this.terrain,n=i.get();for(const e of Object.keys(t.spec.terrain))!r.hasOwnProperty(e)&&t.spec.terrain[e].default&&(r[e]=t.spec.terrain[e].default);for(const t in r)if(!e(r[t],n[t])){i.set(r),this.stylesheet.terrain=r;const t=this._setTransitionParameters({duration:0});i.updateTransitions(t);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(t){const e=this.fog=new I(t,this.map.transform);this.stylesheet.fog=t;const i=this._setTransitionParameters({duration:0});e.updateTransitions(i)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask((()=>{for(const t of this.map._markers)t._evaluateOpacity()}))}getFog(){return this.fog?this.fog.get():null}setFog(t){if(this._checkLoaded(),!t)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog,n=i.get();0===Object.keys(t).length&&i.set(t);for(const r in t)if(!e(t[r],n[r])){i.set(t),this.stylesheet.fog=t;const e=this._setTransitionParameters({duration:0});i.updateTransitions(e);break}}else this._createFog(t);this._markersNeedUpdate=!0}_setTransitionParameters(e){return{now:t.exported.now(),transition:t.extend(e,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const t=this._order.filter((t=>this.isLayerDraped(this._layers[t]))),e=this._order.filter((t=>!this.isLayerDraped(this._layers[t])));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...t),this._drapedFirstOrder.push(...e)}_createTerrain(t,e){const i=this.terrain=new E(t,e);this.stylesheet.terrain=t,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const n=this._setTransitionParameters({duration:0});i.updateTransitions(n)}_force3DLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"fill-extrusion"===e.type&&this._updateLayer(e)}}_forceSymbolLayerUpdate(){for(const t in this._layers){const e=this._layers[t];"symbol"===e.type&&this._updateLayer(e)}}_validate(e,i,n,r,o={}){return(!o||!1!==o.validate)&&qe(this,e.call(t.validateStyle,t.extend({key:i,style:this.serialize(),value:n,styleSpec:t.spec},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),t.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this._sourceCaches)this._sourceCaches[t].clearTiles(),this._sourceCaches[t].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(t){const e=this._getSourceCaches(t);for(const t of e)t.clearTiles()}_reloadSource(t){const e=this._getSourceCaches(t);for(const t of e)t.resume(),t.reload()}_reloadSources(){for(const t of this._getSources())t.reload&&t.reload()}_updateSources(t){for(const e in this._sourceCaches)this._sourceCaches[e].update(t)}_generateCollisionBoxes(){for(const t in this._sourceCaches){const e=this._sourceCaches[t];e.resume(),e.reload()}}_updatePlacement(e,i,n,r,o=!1){let s=!1,a=!1;const l={};for(const t of this._order){const i=this._layers[t];if("symbol"!==i.type)continue;if(!l[i.source]){const t=this._getLayerSourceCache(i);if(!t)continue;l[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const n=this.crossTileSymbolIndex.addLayer(i,l[i.source],e.center.lng,e.projection);s=s||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new t.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(t.exported.now(),e.zoom))&&(this.pauseablePlacement=new Ve(e,this._order,o,i,n,r,this.placement,this.fog&&e.projection.supportsFog?this.fog.state:null),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.exported.now()),a=!0),s&&this.pauseablePlacement.placement.setStale()),a||s)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,l[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(t.exported.now())}_releaseSymbolFadeTiles(){for(const t in this._sourceCaches)this._sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,e,i){this.imageManager.getImages(e.icons,i),this._updateTilesForChangedImages();const n=t=>{t&&t.setDependencies(e.tileID.key,e.type,e.icons)};n(this._otherSourceCaches[e.source]),n(this._symbolSourceCaches[e.source])}getGlyphs(t,e,i){this.glyphManager.getGlyphs(e.stacks,i)}getResource(e,i,n){return t.makeRequest(i,n)}_getSourceCache(t){return this._otherSourceCaches[t]}_getLayerSourceCache(t){return"symbol"===t.type?this._symbolSourceCaches[t.source]:this._otherSourceCaches[t.source]}_getSourceCaches(t){const e=[];return this._otherSourceCaches[t]&&e.push(this._otherSourceCaches[t]),this._symbolSourceCaches[t]&&e.push(this._symbolSourceCaches[t]),e}_isSourceCacheLoaded(e){const i=this._getSourceCaches(e);return 0===i.length?(this.fire(new t.ErrorEvent(new Error(`There is no source with ID '${e}'`))),!1):i.every((t=>t.loaded()))}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Je.getSourceType=function(t){return Ct[t]},Je.setSourceType=function(t,e){Ct[t]=e},Je.registerForPluginStateChange=t.registerForPluginStateChange;var Ke="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",$e="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",ti="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\nconst float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",ei="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",ii="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif";let ni={},ri={};const oi=[];ui(Ke,oi),ui(ti,oi),ui(ei,oi),ui(ii,oi),ni=hi("",ti),ri=hi(ii,ei);const si=hi("\n#if __VERSION__ >=300\n#define varying in\n#define gl_FragColor glFragColor\n#define texture2D texture\n#define textureCube texture\nout vec4 glFragColor;\n#endif\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\n#if __VERSION__ >=300\n#define attribute in\n#define varying out\n#define texture2D texture\n#endif\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\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(\nunpack_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;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),ai=Ke,li="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var ci={background:hi("uniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform vec4 u_color;varying vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(u_color);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:hi("uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:hi("varying vec3 v_data;varying float v_visibility;\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(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\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\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void 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);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:hi("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);}"),heatmap:hi("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 FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying 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;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:hi("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}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:hi("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;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_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:hi("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_2f;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_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-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(\n0.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);}"),debug:hi("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;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:hi("#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\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_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);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:hi("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);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:hi("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(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 float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:hi("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*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 float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:hi("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=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;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\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\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(color,NdotL);\n#else\nv_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef LIGHTING_3D_MODE\nv_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));\n#else\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:hi("uniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,v_NdotL)*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\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 float u_tile_units_to_pixels;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 vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_NdotL=NdotL;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:hi("#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) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));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(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.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;}"),hillshade:hi("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;void 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 LIGHTING_3D_MODE\ngl_FragColor=apply_lighting(gl_FragColor);\n#endif\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\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;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:hi("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\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);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\nfloat trimmed=1.0;\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}\n#else\nout_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);\n#endif\n}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;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 vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\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 floorwidth\n#pragma mapbox: initialize lowp vec4 dash\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;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*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat 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;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:hi("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;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\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.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=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_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_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;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\n#pragma mapbox: define lowp float pixel_ratio\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\n#pragma mapbox: initialize lowp float pixel_ratio\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;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_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat 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;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:hi("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(\ndot(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);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*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 vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:hi("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}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_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(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:hi("#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}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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 vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 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(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:hi("#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}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform 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 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 vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying 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_tex_size.xy;vec2 a_size=a_tex_size.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[3];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;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.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(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp 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);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat 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(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:hi("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=wireframeOffset;\n#endif\nv_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:hi("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:hi("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",$e),skyboxGradient:hi("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",$e),skyboxCapture:hi("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:hi("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;\n#ifdef GLOBE_POLES\nvec3 up_vector=globe_derived_up_vector;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifndef GLOBE_POLES\nglobe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;\n#endif\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:hi("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function ui(t,e){const i=t.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let t of i)if(t=t.trim(),"#"===t[0]&&t.includes("if")&&!t.includes("endif")){t=t.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=t.split(" ");for(const t of i)e.includes(t)||e.push(t)}}function hi(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=e.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),r={},o=[...oi];return ui(t,o),ui(e,o),{fragmentSource:t=t.replace(i,((t,e,i,n,o)=>(r[o]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${n} ${o} = u_${o};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,n,o)=>{const s="float"===n?"vec2":"vec4",a=o.match(/color/)?"color":s;return r[o]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${s} a_${o};\nvarying ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${i} ${s} a_${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"vec4"===a?`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${n} ${o} = a_${o};\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${i} ${n} ${o} = unpack_mix_${a}(a_${o}, u_${o}_t);\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`})),staticAttributes:n,usedDefines:o}}class pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(t,e,i,n,r,o,s){this.context=t;let a=this.boundPaintVertexBuffers.length!==n.length;for(let t=0;!a&&t{const r=i.paint.get("hillshade-shadow-color"),o=i.paint.get("hillshade-highlight-color"),s=i.paint.get("hillshade-accent-color");let a=i.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===i.paint.get("hillshade-illumination-anchor")&&(a-=t.transform.angle);const l=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(e.tileID.toUnwrapped(),l),u_image:0,u_latrange:di(0,e.tileID),u_light:[i.paint.get("hillshade-exaggeration"),a],u_shadow:r,u_highlight:o,u_accent:s}})(e,n,r,e.terrain?i.projMatrix:null);e.prepareDrawProgram(l,h,i.toUnwrapped());const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:m}=e.getTileBoundsBuffers(n);h.draw(l,c.TRIANGLES,o,s,a,t.CullFaceMode.disabled,p,r.id,d,f,m)}function mi(e,i,n){if(!i.needsDEMTextureUpload)return;const r=e.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||e.getTileTexture(n.stride);const s=n.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new t.Texture(r,s,o.RGBA,{premultiply:!1}),i.needsDEMTextureUpload=!1}function gi(e,i,n,r,o,s){const a=e.context,l=a.gl;if(!i.dem)return;const c=i.dem;if(a.activeTexture.set(l.TEXTURE1),mi(e,i,c),!i.demTexture)return;i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const u=c.dim;a.activeTexture.set(l.TEXTURE0);let h=i.fbo;if(!h){const e=new t.Texture(a,{width:u,height:u,data:null},l.RGBA);e.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=i.fbo=a.createFramebuffer(u,u,!0),h.colorAttachment.set(e.texture)}a.bindFramebuffer.set(h.framebuffer),a.viewport.set([0,0,u,u]);const{tileBoundsBuffer:p,tileBoundsIndexBuffer:d,tileBoundsSegments:f}=e.getMercatorTileBoundsBuffers();e.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,r,o,s,t.CullFaceMode.disabled,((e,i)=>{const n=i.stride,r=t.create();return t.ortho(r,0,t.EXTENT,-t.EXTENT,0,0,1),t.translate(r,r,[0,-t.EXTENT,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.unpackVector}})(i.tileID,c),n.id,p,d,f),i.needsHillshadePrepare=!1}const yi=e=>({u_matrix:new t.UniformMatrix4f(e),u_image0:new t.Uniform1i(e),u_skirt_height:new t.Uniform1f(e)}),vi=(t,e)=>({u_matrix:t,u_image0:0,u_skirt_height:e}),_i=(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f)=>({u_proj_matrix:Float32Array.from(t),u_globe_matrix:e,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:p,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9),u_skirt_height:d});function xi(t,e){return null!=t&&null!=e&&!(!t.hasData()||!e.hasData())&&null!=t.demTexture&&null!=e.demTexture&&t.tileID.key!==e.tileID.key}const bi=new class{constructor(){this.operations={}}newMorphing(t,e,i,n,r){if(t in this.operations){const e=this.operations[t];e.to.tileID.key!==i.tileID.key&&(e.queued=i)}else this.operations[t]={startTime:n,phase:0,duration:r,from:e,to:i,queued:null}}getMorphValuesForProxy(t){if(!(t in this.operations))return null;const e=this.operations[t];return{from:e.from,to:e.to,phase:e.phase}}update(t){for(const e in this.operations){const i=this.operations[e];for(i.phase=(t-i.startTime)/i.duration;i.phase>=1||!this._validOp(i);)if(!this._nextOp(i,t)){delete this.operations[e];break}}}_nextOp(t,e){return!!t.queued&&(t.from=t.to,t.to=t.queued,t.queued=null,t.phase=0,t.startTime=e,!0)}_validOp(t){return t.from.hasData()&&t.to.hasData()}},wi={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Ai(t){return 6*Math.pow(1.5,22-t)}function Ei(t,e){const i=1<({u_matrix:t});function Mi(e,i,n,r,o){if(o>0){const s=t.exported.now(),a=(s-e.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(e.tileID.overscaledZ-u),p=h&&e.refreshedUponExpiration?1:t.clamp(h?a:1-l,0,1);return e.refreshedUponExpiration&&a>=1&&(e.refreshedUponExpiration=!1),i?{opacity:1,mix:1-p}:{opacity:p,mix:0}}return{opacity:1,mix:0}}class Ti extends t.SourceCache{constructor(t){const e={type:"raster-dem",maxzoom:t.transform.maxZoom},i=new C(Ft(),null),n=Pt("mock-dem",e,i,t.style);super("mock-dem",n,!1),n.setEventedParent(this),this._sourceLoaded=!0}_loadTile(t,e){t.state="loaded",e(null)}}class Ii extends t.SourceCache{constructor(t){const e=Pt("proxy",{type:"geojson",maxzoom:t.transform.maxZoom},new C(Ft(),null),t.style);super("proxy",e,!1),e.setEventedParent(this),this.map=this.getSource().map=t,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(e,i,n){if(e.freezeTileCoverage)return;this.transform=e;const r=e.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce(((i,n)=>{if(i[n.key]="",!this._tiles[n.key]){const i=new t.Tile(n,this._source.tileSize*n.overscaleFactor(),e.tileZoom);i.state="loaded",this._tiles[n.key]=i}return i}),{});for(const t in this._tiles)t in r||(this.freeFBO(t),this._tiles[t].unloadVectorData(),delete this._tiles[t])}freeFBO(t){const e=this.proxyCachedFBO[t];if(void 0!==e){const i=Object.values(e);this.renderCachePool.push(...i),delete this.proxyCachedFBO[t]}}deallocRenderCache(){this.renderCache.forEach((t=>t.fb.destroy())),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Ci extends t.OverscaledTileID{constructor(t,e,i){super(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y),this.proxyTileKey=e,this.projMatrix=i}}class Pi extends t.Elevation{constructor(e,i){super(),this.painter=e,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,o]=function(e){const i=new t.StructArrayLayout2i4,n=new t.StructArrayLayout3ui6,r=131;i.reserve(17161),n.reserve(33800);const o=t.EXTENT/128,s=t.EXTENT+o/2,a=s+o;for(let e=-o;es||e<0||e>s?24575:0,o=t.clamp(Math.round(n),0,t.EXTENT),a=t.clamp(Math.round(e),0,t.EXTENT);i.emplaceBack(o+r,a)}const l=(t,e)=>{const i=e*r+t;n.emplaceBack(i+1,i,i+r),n.emplaceBack(i+r,i+r+1,i+1)};for(let t=1;t<129;t++)for(let e=1;e<129;e++)l(e,t);return[0,129].forEach((t=>{for(let e=0;e<130;e++)l(e,t),l(t,e)})),[i,n,32768]}(),s=e.context;this.gridBuffer=s.createVertexBuffer(n,t.posAttributes.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=t.SegmentVector.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=t.SegmentVector.simpleSegment(0,0,n.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Ii(i.map),this.orthoMatrix=t.create(),t.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,t.EXTENT,0,t.EXTENT,0,1);const a=s.gl;this._overlapStencilMode=new t.StencilMode({func:a.GEQUAL,mask:255},0,255,a.KEEP,a.KEEP,a.REPLACE),this._previousZoom=e.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=i,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Ti(i.map)}set style(t){t.on("data",this._onStyleDataEvent.bind(this)),t.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=t,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",(()=>{this._clearLineLayersFromRenderCache()}))}update(e,i,n){if(e&&e.terrain){this._style!==e&&(this.style=e),this.enabled=!0;const r=e.terrain.properties;this.sourceCache=0===e.terrain.drapeRenderMode?this._mockSourceCache:e._getSourceCache(r.get("source")),this._exaggeration=r.get("exaggeration");const o=()=>{this.sourceCache.used&&t.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const e=this.getScaledDemTileSize();this.sourceCache.update(i,e,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),i.updateElevation(!0,n),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(i),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(t){this._findCoveringTileCache[t]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const e=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==e.efficiency&&t.warnOnce(`Terrain render cache efficiency is not optimal (${e.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${e.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(t){t.coord&&"source"===t.dataType?this._clearRenderCacheForTile(t.sourceCacheId,t.coord):"style"===t.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const t in this._style._sourceCaches)this._style._sourceCaches[t].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach((t=>t.fb.destroy())),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const t=2*this.proxySourceCache.getSource().tileSize;return[t,t]}set useVertexMorphing(t){this._useVertexMorphing=t}updateTileBinding(e){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const i=this.proxySourceCache,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map((t=>{const e=i.getTileByID(t).tileID;return e.projMatrix=n.calculateProjMatrix(e.toUnwrapped()),e}));!function(e,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new t.Point(n.x,n.y);e.sort(((e,i)=>{if(i.overscaledZ-e.overscaledZ)return i.overscaledZ-e.overscaledZ;const n=new t.Point(e.canonical.x+(1<{this.proxyToSource[t.key]={}})),this.terrainTileForTile={};const s=this._style._sourceCaches;for(const t in s){const i=s[t];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,e[t],o),i.usedForTerrain)continue;const n=e[t];i.getSource().reparseOverscaled&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map((t=>new Ci(t,t.key,this.orthoMatrix))),this._assignTerrainTiles(r),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=t.exported.now();const a={};this._visibleDemTiles=[];for(const t of this.proxyCoords){const e=this.terrainTileForTile[t.key];if(!e)continue;const i=e.tileID.key;i in a||(this._visibleDemTiles.push(e),a[i]=i)}}_assignTerrainTiles(t){this._initializing||t.forEach((t=>{if(this.terrainTileForTile[t.key])return;const e=this._findTileCoveringTileID(t,this.sourceCache);e&&(this.terrainTileForTile[t.key]=e)}))}_prepareDEMTextures(){const t=this.painter.context,e=t.gl;for(const i in this.terrainTileForTile){const n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(t.activeTexture.set(e.TEXTURE1),mi(this.painter,n,r))}}_prepareDemTileUniforms(t,e,i,n){if(!e||null==e.demTexture)return!1;const r=t.tileID.canonical,o=Math.pow(2,e.tileID.canonical.z-r.z),s=n||"";return i[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${s}`]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const e=this.painter.context,i=e.gl;if(!this._emptyDepthBufferTexture){const n=new t.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new t.Texture(e,n,i.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let t=0;const e=this._visibleDemTiles.reduce(((e,i)=>{if(!i.dem)return e;const n=i.dem.tree.minimums[0];return n>0&&t++,e+n}),0);return t?e/t:0}_updateEmptyDEMTexture(){const e=this.painter.context,i=e.gl;e.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new t.RGBAImage({width:1,height:1},new Uint8Array(t.DEMData.pack(n,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(r,{premultiply:!1}):o=this._emptyDEMTexture=new t.Texture(e,r,i.RGBA,{premultiply:!1}),o}setupElevationDraw(e,i,n){const r=this.painter.context,o=r.gl,s=(a=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:t.DEMData.getUnpackVector(a),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var a;s.u_dem_size=this.sourceCache.getSource().tileSize,s.u_exaggeration=this.exaggeration();let l=null,c=null,u=1;if(n&&n.morphing&&this._useVertexMorphing){const t=n.morphing.srcDemTile,i=n.morphing.dstDemTile;u=n.morphing.phase,t&&i&&(this._prepareDemTileUniforms(e,t,s,"_prev")&&(c=t),this._prepareDemTileUniforms(e,i,s)&&(l=i))}if(c&&l?(r.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),r.activeTexture.set(o.TEXTURE4),c.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),s.u_dem_lerp=u):(l=this.terrainTileForTile[e.tileID.key],r.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(e,l,s)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),r.activeTexture.set(o.TEXTURE3),n&&n.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(s.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),s.u_depth_size_inv=[1,1]),n&&n.useMeterToDem&&l){const e=(1<{if(c===t)return;const n=[wi[t],"PROJECTION_GLOBE_VIEW"];p&&n.push("CUSTOM_ANTIALIASING"),i&&n.push(wi[u]),l=e.useProgram("globeRaster",null,n),c=t},f=e.colorModeForRenderPass(),m=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);bi.update(o);const g=t.calculateGlobeMercatorMatrix(h),y=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],v=u?[!1,!0]:[!1],_=e.globeSharedBuffers,x=[h.width*t.exported.devicePixelRatio,h.height*t.exported.devicePixelRatio],b=Float32Array.from(h.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(v.forEach((u=>{const h=e.transform,p=Ai(h.zoom)*i.exaggeration();c=-1;const v=u?a.LINES:a.TRIANGLES;for(const c of r){const r=n.getTile(c),A=t.StencilMode.disabled,E=i.prevTerrainTileForTile[c.key],S=i.terrainTileForTile[c.key];xi(E,S)&&bi.newMorphing(c.key,E,S,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const M=bi.getMorphValuesForProxy(c.key),T=M?1:0;M&&t.extend$1(w,{morphing:{srcDemTile:M.from,dstDemTile:M.to,phase:t.easeCubicInOut(M.phase)}});const I=t.tileCornersToBounds(c.canonical),C=t.getLatitudinalLod(I.getCenter().lat),P=t.getGridMatrix(c.canonical,I,C,h.worldSize/h._pixelsPerMercatorPixel),L=t.globeNormalizeECEF(t.globeTileBounds(c.canonical)),D=_i(h.projMatrix,b,g,L,t.globeToMercatorTransition(h.zoom),y,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,p,P);if(d(T,u),i.setupElevationDraw(r,l,w),e.prepareDrawProgram(s,l,c.toUnwrapped()),_){const[i,n,r]=u?_.getWirefameBuffers(e.context,C):_.getGridBuffers(C,0!==p);l.draw(s,v,m,A,f,t.CullFaceMode.backCCW,D,"globe_raster",i,n,r)}}})),_){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];p&&o.push("CUSTOM_ANTIALIASING"),l=e.useProgram("globeRaster",null,o);for(const o of r){const{x:r,y:c,z:u}=o.canonical,p=0===c,d=c===(1<e.draw(s,a.TRIANGLES,m,t.StencilMode.disabled,f,t.CullFaceMode.disabled,_i(h.projMatrix,_,_,E,0,y,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,0),"globe_pole_raster",i,b,A);i.setupElevationDraw(c,l,w),e.prepareDrawProgram(s,l,o.toUnwrapped()),p&&S(l,g),d&&(_=t.scale(t.create(),_,[1,-1,1]),S(l,v))}}}}(e,i,n,r,o);else{const s=e.context,a=s.gl;let l,c;const u=e.options.showTerrainWireframe?2:0,h=(t,i)=>{if(c===t)return;const n=[wi[t]];i&&n.push(wi[u]),l=e.useProgram("terrainRaster",null,n),c=t},p=e.colorModeForRenderPass(),d=new t.DepthMode(a.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);bi.update(o);const f=e.transform,m=Ai(f.zoom)*i.exaggeration();(u?[!1,!0]:[!1]).forEach((u=>{c=-1;const g=u?a.LINES:a.TRIANGLES,[y,v]=u?i.getWirefameBuffer():[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),_=t.StencilMode.disabled,x=i.prevTerrainTileForTile[c.key],b=i.terrainTileForTile[c.key];xi(x,b)&&bi.newMorphing(c.key,x,b,o,250),s.activeTexture.set(a.TEXTURE0),r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE,a.LINEAR_MIPMAP_NEAREST);const w=bi.getMorphValuesForProxy(c.key),A=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:t.easeCubicInOut(w.phase)}});const S=vi(c.projMatrix,Ei(c.canonical,f.renderWorldCopies)?m/10:m);h(A,u),i.setupElevationDraw(r,l,E),e.prepareDrawProgram(s,l,c.toUnwrapped()),l.draw(s,g,d,_,p,t.CullFaceMode.backCCW,S,"terrain_raster",i.gridBuffer,y,v)}}))}}(i,this,this.proxySourceCache,e,this._updateTimestamp),this.renderingToTexture=!0,i.gpuTimingDeferredRenderEnd(),e.splice(0,e.length))}renderBatch(e){if(0===this._drapedRenderBatches.length)return e+1;this.renderingToTexture=!0;const i=this.painter,n=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=[],l=i.style.order;let c=0;for(const u of o){const o=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][e]:void 0,p=void 0!==h?r.renderCache[h]:this.pool[c++],d=void 0!==h;if(o.texture=p.tex,d&&!p.dirty){a.push(o.tileID);continue}let f;n.bindFramebuffer.set(p.fb.framebuffer),this.renderedToTile=!1,p.dirty&&(n.clear({color:t.Color.transparent,stencil:0}),p.dirty=!1);for(let t=s.start;t<=s.end;++t){const e=i.style._layers[l[t]];if(e.isHidden(i.transform.zoom))continue;const r=i.style._getLayerSourceCache(e),o=r?this.proxyToSource[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,p.fb.width,p.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(p,o,e,r),f=r?r.id:null),i.renderLayer(i,r,e,s)}this.renderedToTile?(p.dirty=!0,a.push(o.tileID)):d||--c,5===c&&(c=0,this.renderToBackBuffer(a))}return this.renderToBackBuffer(a),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}renderCacheEfficiency(t){const e=t.order.length;if(0===e)return{efficiency:100};let i,n=0,r=0,o=!1;for(let s=0;st.dem)).forEach((e=>{t=Math.min(t,e.dem.tree.minimums[0])})),0===t?t:(t-30)*this._exaggeration}raycast(t,e,i){if(!this._visibleDemTiles)return null;const n=this._visibleDemTiles.filter((t=>t.dem)).map((n=>{const r=n.tileID,o=1<(null!==t.t?t.t:Number.MAX_VALUE)-(null!==e.t?e.t:Number.MAX_VALUE)));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,t,e,i);if(null!=n)return n}return null}_createFBO(){const e=this.painter.context,i=e.gl,n=this.drapeBufferSize;e.activeTexture.set(i.TEXTURE0);const r=new t.Texture(e,{width:n[0],height:n[1],data:null},i.RGBA);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=e.createFramebuffer(n[0],n[1],!1);return o.colorAttachment.set(r.texture),o.depthAttachment=new wt(e,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=e.createRenderbuffer(e.gl.DEPTH_STENCIL,n[0],n[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),e.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),e.extTextureFilterAnisotropic&&!e.extTextureFilterAnisotropicForceOff&&i.texParameterf(i.TEXTURE_2D,e.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,e.extTextureFilterAnisotropicMax),{fb:o,tex:r,dirty:!1}}_initFBOPool(){for(;this.pool.length{const e=this._style._layers[t],i=e.isHidden(this.painter.transform.zoom);return"custom"===e.type?!i&&e.shouldRedrape():!i&&e.hasTransition()}))}_clearLineLayersFromRenderCache(){let e=!1;for(const t of this._style._getSources())if(t instanceof St){e=!0;break}if(!e)return;const i={};for(let e=0;ee.renderCachePool.length){const t=Object.values(e.proxyCachedFBO);e.proxyCachedFBO={};for(let i=0;i=0;r--){const o=i[r];if(e.getTileByID(o.key),void 0!==e.proxyCachedFBO[o.key]){const i=t[o.key],r=this.proxyToSource[o.key];let s=0;for(const t in r){const e=r[t],o=i[t];if(!o||o.length!==e.length||e.some(((e,i)=>e!==o[i]||n[t]&&n[t].hasOwnProperty(e.key)))){s=-1;break}++s}for(const t in e.proxyCachedFBO[o.key])e.renderCache[e.proxyCachedFBO[o.key][t]].dirty=s<0||s!==Object.values(i).length}}const r=[...this._drapedRenderBatches];r.sort(((t,e)=>e.end-e.start-(t.end-t.start)));for(const t of r)for(const n of i){if(e.proxyCachedFBO[n.key])continue;let i=e.renderCachePool.pop();void 0===i&&e.renderCache.length<50&&(i=e.renderCache.length,e.renderCache.push(this._createFBO())),void 0!==i&&(e.proxyCachedFBO[n.key]={},e.proxyCachedFBO[n.key][t.start]=i,e.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(t,e,i,n){if(!n||!this._sourceTilesOverlap[n.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const r=this.painter.context,o=r.gl;if(e.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=e.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(e[0].overscaledZ>e[e.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(e,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):t.StencilMode.disabled}_renderTileClippingMasks(e,i){const n=this.painter,r=this.painter.context,o=r.gl;n._tileClippingMaskIDs={},r.setColorMode(t.ColorMode.disabled),r.setDepthMode(t.DepthMode.disabled);const s=n.useProgram("clippingMask");for(const a of e){const e=n._tileClippingMaskIDs[a.key]=--i;s.draw(r,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,Si(a.projMatrix),"$clipping",n.tileExtentBuffer,n.quadTriangleIndexBuffer,n.tileExtentSegments)}}pointCoordinate(e){const i=this.painter.transform;if(e.x<0||e.x>i.width||e.y<0||e.y>i.height)return null;const n=[e.x,e.y,1,1];t.transformMat4$1(n,n,i.pixelMatrixInverse),t.scale$1(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,o=t.mercatorZfromAltitude(1,i.center.lat),s=[r[0],r[1],r[2]/o,0],a=t.subtract([],n.slice(0,3),s);t.normalize(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(t.scaleAndAdd(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}drawDepth(){const e=this.painter,i=e.context,n=this.proxySourceCache,r=Math.ceil(e.width),o=Math.ceil(e.height);if(!this._depthFBO||this._depthFBO.width===r&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const e=i.gl,n=i.createFramebuffer(r,o,!0);i.activeTexture.set(e.TEXTURE0);const s=new t.Texture(i,{width:r,height:o,data:null},e.RGBA);s.bind(e.NEAREST,e.CLAMP_TO_EDGE),n.colorAttachment.set(s.texture);const a=i.createRenderbuffer(i.gl.DEPTH_COMPONENT16,r,o);n.depthAttachment.set(a),this._depthFBO=n,this._depthTexture=s}i.bindFramebuffer.set(this._depthFBO.framebuffer),i.viewport.set([0,0,r,o]),function(e,i,n,r){if("globe"===e.transform.projection.name)return;const o=e.context,s=o.gl;o.clear({depth:1});const a=e.useProgram("terrainDepth"),l=new t.DepthMode(s.LESS,t.DepthMode.ReadWrite,e.depthRangeFor3D);for(const e of r){const r=n.getTile(e),c=vi(e.projMatrix,0);i.setupElevationDraw(r,a),a.draw(o,s.TRIANGLES,l,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.backCCW,c,"terrain_depth",i.gridBuffer,i.gridIndexBuffer,i.gridNoSkirtSegments)}}(e,this,n,this.proxyCoords)}_setupProxiedCoordsForOrtho(t,e,i){if(t.getSource()instanceof It)return this._setupProxiedCoordsForImageSource(t,e,i);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],r=this.proxyCoords;for(let e=0;e(t.min.x=Math.min(t.min.x,e.x-a.x),t.min.y=Math.min(t.min.y,e.y-a.y),t.max.x=Math.max(t.max.x,e.x-a.x),t.max.y=Math.max(t.max.y,e.y-a.y),t)),{min:new t.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new t.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),c=(e,i)=>{const n=e.wrap+e.canonical.x/(1<s+l.max.x||r+oa+l.max.y};for(let t=0;tt.key===i.tileID.key));if(t)return t}if(i.tileID.key!==e.key){const n=e.canonical.z-i.tileID.canonical.z;let o,s,a;r=t.create();const l=i.tileID.wrap-e.wrap<0?(o=t.EXTENT>>n,s=o*((i.tileID.canonical.x<=r){const n=e.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(e.canonical.z+2,i.transform.tileZoom),s=new t.OverscaledTileID(a,e.wrap,r,e.canonical.x>>n,e.canonical.y>>n)):0!==n&&(a=r,s=new t.OverscaledTileID(a,e.wrap,r,e.canonical.x>>n,e.canonical.y>>n))}s.key!==e.key&&(c.push(s.key),n=i.getTile(s))}const u=t=>{c.forEach((e=>{r[e]=t})),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const t=s.calculateScaledKey(a);if(n=i.getTileByID(t),n&&n.hasData())break;const e=r[t];if(null===e)break;void 0===e?c.push(t):n=i.getTileByID(e)}return u(n?n.tileID.key:null),n&&n.hasData()?n:null}findDEMTileFor(t){return this.enabled?this._findTileCoveringTileID(t,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(t,e){let i=this._tilesDirty[t];i||(i=this._tilesDirty[t]={}),i[e.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const e=function(e){let i=0;const n=new t.StructArrayLayout2ui4,r=131;for(let t=1;t<129;t++){for(let e=1;e<129;e++)i=t*r+e,n.emplaceBack(i,i+1),n.emplaceBack(i,i+r),n.emplaceBack(i+1,i+r),128===t&&n.emplaceBack(i+r,i+r+1);n.emplaceBack(i+1,i+1+r)}return n}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(e),this.wireframeSegments=t.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,e.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Li{static cacheKey(t,e,i,n){let r=`${e}${n?n.cacheKey:""}`;for(const e of i)t.usedDefines.includes(e)&&(r+=`/${e}`);return r}constructor(e,i,n,r,o,s){const a=e.gl;this.program=a.createProgram();const l=function(t){const e=[];for(let i=0;i`#define ${t}`)));const p=e.isWebGL2?"#version 300 es\n":"",d=p+h.concat(e.extStandardDerivatives&&0===p.length?"#extension GL_OES_standard_derivatives : enable\n".concat(li):li,li,ai,si.fragmentSource,ri.fragmentSource,n.fragmentSource).join("\n"),f=p+h.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",ai,si.vertexSource,ri.vertexSource,ni.vertexSource,n.vertexSource).join("\n"),m=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(m,d),a.compileShader(m),a.attachShader(this.program,m);const g=a.createShader(a.VERTEX_SHADER);if(a.isContextLost())this.failedToCreate=!0;else{a.shaderSource(g,f),a.compileShader(g),a.attachShader(this.program,g),this.attributes={},this.numAttributes=u.length;for(let t=0;t({u_dem:new t.Uniform1i(e),u_dem_prev:new t.Uniform1i(e),u_dem_unpack:new t.Uniform4f(e),u_dem_tl:new t.Uniform2f(e),u_dem_scale:new t.Uniform1f(e),u_dem_tl_prev:new t.Uniform2f(e),u_dem_scale_prev:new t.Uniform1f(e),u_dem_size:new t.Uniform1f(e),u_dem_lerp:new t.Uniform1f(e),u_exaggeration:new t.Uniform1f(e),u_depth:new t.Uniform1i(e),u_depth_size_inv:new t.Uniform2f(e),u_meter_to_dem:new t.Uniform1f(e),u_label_plane_matrix_inv:new t.UniformMatrix4f(e)}))(e)),s.includes("GLOBE")&&(this.globeUniforms=(e=>({u_tile_tl_up:new t.Uniform3f(e),u_tile_tr_up:new t.Uniform3f(e),u_tile_br_up:new t.Uniform3f(e),u_tile_bl_up:new t.Uniform3f(e),u_tile_up_scale:new t.Uniform1f(e)}))(e)),s.includes("FOG")&&(this.fogUniforms=(e=>({u_fog_matrix:new t.UniformMatrix4f(e),u_fog_range:new t.Uniform2f(e),u_fog_color:new t.Uniform4f(e),u_fog_horizon_blend:new t.Uniform1f(e),u_fog_temporal_offset:new t.Uniform1f(e),u_frustum_tl:new t.Uniform3f(e),u_frustum_tr:new t.Uniform3f(e),u_frustum_br:new t.Uniform3f(e),u_frustum_bl:new t.Uniform3f(e),u_globe_pos:new t.Uniform3f(e),u_globe_radius:new t.Uniform1f(e),u_globe_transition:new t.Uniform1f(e),u_is_globe:new t.Uniform1i(e),u_viewport:new t.Uniform2f(e)}))(e))}}setTerrainUniformValues(t,e){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t]&&i[t].set(this.program,t,e[t])}}setGlobeUniformValues(t,e){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t]&&i[t].set(this.program,t,e[t])}}setFogUniformValues(t,e){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){t.program.set(this.program);for(const t in e)i[t].set(this.program,t,e[t])}}draw(t,e,i,n,r,o,s,a,l,c,u,h,p,d,f){const m=t.gl;if(this.failedToCreate)return;t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(n),t.setColorMode(r),t.setCullFace(o);for(const t of Object.keys(this.fixedUniforms))this.fixedUniforms[t].set(this.program,t,s[t]);d&&d.setUniforms(this.program,t,this.binderUniforms,h,{zoom:p});const g={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[e];for(const i of u.get()){const n=i.vaos||(i.vaos={});(n[a]||(n[a]=new pi)).bind(t,this,l,d?d.getPaintVertexBuffers():[],c,i.vertexOffset,f||[]),m.drawElements(e,i.primitiveLength*g,m.UNSIGNED_SHORT,i.primitiveOffset*g*2)}}}function Di(t,e){const i=Math.pow(2,e.tileID.overscaledZ),n=e.tileSize*Math.pow(2,t.transform.tileZoom)/i,r=n*(e.tileID.canonical.x+e.tileID.wrap*i),o=n*e.tileID.canonical.y;return{u_image:0,u_texsize:e.imageAtlasTexture.size,u_tile_units_to_pixels:1/P(e,1,t.transform.tileZoom),u_pixel_coord_upper:[r>>16,o>>16],u_pixel_coord_lower:[65535&r,65535&o]}}const Ri=t.create(),Oi=(e,i,n,r,o,s,a,l,c,u,h)=>{const p=i.style.light,d=p.properties.get("position"),f=[d.x,d.y,d.z],m=t.create$1();"viewport"===p.properties.get("anchor")&&(t.fromRotation(m,-i.transform.angle),t.transformMat3(f,f,m));const g=p.properties.get("color"),y=i.transform,v={u_matrix:e,u_lightpos:f,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[g.r,g.g,g.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Ri,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:s};return"globe"===y.projection.name&&(v.u_tile_id=[a.canonical.x,a.canonical.y,1<{const d=Oi(e,i,n,r,o,s,a,c,u,h,p),f={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return t.extend(d,Di(i,l),f)},Ni=t=>({u_matrix:t}),Bi=(e,i,n)=>t.extend(Ni(e),Di(i,n)),zi=(t,e)=>({u_matrix:t,u_world:e}),Fi=(e,i,n,r)=>t.extend(Bi(e,i,n),{u_world:r}),Vi=t.create(),Ui=(e,i,n,r,o,s)=>{const a=e.transform,l="globe"===a.projection.name;let c;if("map"===s.paint.get("circle-pitch-alignment"))if(l){const e=t.globePixelsToTileUnits(a.zoom,i.canonical)*a._pixelsPerMercatorPixel;c=Float32Array.from([e,0,0,e])}else c=a.calculatePixelsToTileUnitsMatrix(n);else c=new Float32Array([a.pixelsToGLUnits[0],0,0,a.pixelsToGLUnits[1]]);const u={u_camera_to_center_distance:a.cameraToCenterDistance,u_matrix:e.translatePosMatrix(i.projMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_device_pixel_ratio:t.exported.devicePixelRatio,u_extrude_scale:c,u_inv_rot_matrix:Vi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){u.u_inv_rot_matrix=r,u.u_merc_center=o,u.u_tile_id=[i.canonical.x,i.canonical.y,1<{const e=[];return"map"===t.paint.get("circle-pitch-alignment")&&e.push("PITCH_WITH_MAP"),"map"===t.paint.get("circle-pitch-scale")&&e.push("SCALE_WITH_MAP"),e},ji=(e,i,n,r)=>{const o=t.EXTENT/n.tileSize;return{u_matrix:e,u_camera_to_center_distance:i.getCameraToCenterDistance(r),u_extrude_scale:[i.pixelsToGLUnits[0]/o,i.pixelsToGLUnits[1]/o]}},Hi=(t,e,i=1)=>({u_matrix:t,u_color:e,u_overlay:0,u_overlay_scale:i}),Wi=t.create(),qi=(e,i,n,r,o,s,a)=>{const l=e.transform,c="globe"===l.projection.name,u=c?t.globePixelsToTileUnits(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:P(n,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:Wi,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=r,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<{const a=t.transform,l=a.calculatePixelsToTileUnitsMatrix(e);return{u_matrix:Qi(t,e,i,n),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:Ji(i)?e.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Yi(e,t.transform),u_alpha_discard_threshold:0,u_trim_offset:s}},Zi=(t,e,i,n,r)=>{const o=t.transform;return{u_matrix:Qi(t,e,i,n),u_texsize:e.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(e),u_device_pixel_ratio:r,u_image:0,u_tile_units_to_pixels:Yi(e,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Yi(t,e){return 1/P(t,1,e.tileZoom)}function Qi(t,e,i,n){return t.translatePosMatrix(n||e.tileID.projMatrix,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}function Ji(t){const e=t.paint.get("line-dasharray").value;return e.value||"constant"!==e.kind}const Ki=(t,e,i,n,r,o)=>{return{u_matrix:t,u_tl_parent:e,u_scale_parent:i,u_fade_t:n.mix,u_opacity:n.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(a=r.paint.get("raster-saturation"),a>0?1-1/(1.001-a):-a),u_contrast_factor:(s=r.paint.get("raster-contrast"),s>0?1/(1-s):1+s),u_spin_weights:$i(r.paint.get("raster-hue-rotate")),u_perspective_transform:o};var s,a};function $i(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const tn=t.create(),en=(e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g)=>{const y=o.transform,v={u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:i?i.uSizeT:0,u_size:i?i.uSize:0,u_camera_to_center_distance:y.cameraToCenterDistance,u_rotate_symbol:+n,u_aspect_ratio:y.width/y.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+c,u_pitch_with_map:+r,u_texsize:u,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:tn,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:tn,u_up_vector:[0,-1,0]};return"globe"===g.name&&(v.u_tile_id=[h.canonical.x,h.canonical.y,1<t.extend(en(e,i,n,r,o,s,a,l,c,u,p,d,f,m,g,y),{u_gamma_scale:r?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:t.exported.devicePixelRatio,u_is_halo:+h}),rn=(e,i,n,r,o,s,a,l,c,u,h,p,d,f,m,g)=>t.extend(nn(e,i,n,r,o,s,a,l,!0,c,!0,h,p,d,f,m,g),{u_texsize_icon:u,u_texture_icon:1}),on=(t,e,i)=>({u_matrix:t,u_opacity:e,u_color:i}),sn=(e,i,n,r,o)=>t.extend(function(t,e,i){const n=e.imageManager.getPattern(t.toString()),{width:r,height:o}=e.imageManager.getPixelSize(),s=Math.pow(2,i.tileID.overscaledZ),a=i.tileSize*Math.pow(2,e.transform.tileZoom)/s,l=a*(i.tileID.canonical.x+i.tileID.wrap*s),c=a*i.tileID.canonical.y;return{u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[r,o],u_pattern_size:n.displaySize,u_tile_units_to_pixels:1/P(i,1,e.transform.tileZoom),u_pixel_coord_upper:[l>>16,c>>16],u_pixel_coord_lower:[65535&l,65535&c]}}(r,n,o),{u_matrix:e,u_opacity:i}),an={fillExtrusion:e=>({u_matrix:new t.UniformMatrix4f(e),u_lightpos:new t.Uniform3f(e),u_lightintensity:new t.Uniform1f(e),u_lightcolor:new t.Uniform3f(e),u_vertical_gradient:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e),u_edge_radius:new t.Uniform1f(e),u_ao:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_up_dir:new t.Uniform3f(e),u_height_lift:new t.Uniform1f(e)}),fillExtrusionPattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_lightpos:new t.Uniform3f(e),u_lightintensity:new t.Uniform1f(e),u_lightcolor:new t.Uniform3f(e),u_vertical_gradient:new t.Uniform1f(e),u_height_factor:new t.Uniform1f(e),u_edge_radius:new t.Uniform1f(e),u_ao:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_up_dir:new t.Uniform3f(e),u_height_lift:new t.Uniform1f(e),u_image:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e)}),fill:e=>({u_matrix:new t.UniformMatrix4f(e)}),fillPattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_image:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e)}),fillOutline:e=>({u_matrix:new t.UniformMatrix4f(e),u_world:new t.Uniform2f(e)}),fillOutlinePattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_world:new t.Uniform2f(e),u_image:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e)}),circle:e=>({u_camera_to_center_distance:new t.Uniform1f(e),u_extrude_scale:new t.UniformMatrix2f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_up_dir:new t.Uniform3f(e)}),collisionBox:e=>({u_matrix:new t.UniformMatrix4f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_extrude_scale:new t.Uniform2f(e)}),collisionCircle:e=>({u_matrix:new t.UniformMatrix4f(e),u_inv_matrix:new t.UniformMatrix4f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_viewport_size:new t.Uniform2f(e)}),debug:e=>({u_color:new t.UniformColor(e),u_matrix:new t.UniformMatrix4f(e),u_overlay:new t.Uniform1i(e),u_overlay_scale:new t.Uniform1f(e)}),clippingMask:e=>({u_matrix:new t.UniformMatrix4f(e)}),heatmap:e=>({u_extrude_scale:new t.Uniform1f(e),u_intensity:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_up_dir:new t.Uniform3f(e)}),heatmapTexture:e=>({u_image:new t.Uniform1i(e),u_color_ramp:new t.Uniform1i(e),u_opacity:new t.Uniform1f(e)}),hillshade:e=>({u_matrix:new t.UniformMatrix4f(e),u_image:new t.Uniform1i(e),u_latrange:new t.Uniform2f(e),u_light:new t.Uniform2f(e),u_shadow:new t.UniformColor(e),u_highlight:new t.UniformColor(e),u_accent:new t.UniformColor(e)}),hillshadePrepare:e=>({u_matrix:new t.UniformMatrix4f(e),u_image:new t.Uniform1i(e),u_dimension:new t.Uniform2f(e),u_zoom:new t.Uniform1f(e),u_unpack:new t.Uniform4f(e)}),line:e=>({u_matrix:new t.UniformMatrix4f(e),u_pixels_to_tile_units:new t.UniformMatrix2f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_units_to_pixels:new t.Uniform2f(e),u_dash_image:new t.Uniform1i(e),u_gradient_image:new t.Uniform1i(e),u_image_height:new t.Uniform1f(e),u_texsize:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e),u_alpha_discard_threshold:new t.Uniform1f(e),u_trim_offset:new t.Uniform2f(e)}),linePattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_texsize:new t.Uniform2f(e),u_pixels_to_tile_units:new t.UniformMatrix2f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_image:new t.Uniform1i(e),u_units_to_pixels:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e),u_alpha_discard_threshold:new t.Uniform1f(e)}),raster:e=>({u_matrix:new t.UniformMatrix4f(e),u_tl_parent:new t.Uniform2f(e),u_scale_parent:new t.Uniform1f(e),u_fade_t:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e),u_image0:new t.Uniform1i(e),u_image1:new t.Uniform1i(e),u_brightness_low:new t.Uniform1f(e),u_brightness_high:new t.Uniform1f(e),u_saturation_factor:new t.Uniform1f(e),u_contrast_factor:new t.Uniform1f(e),u_spin_weights:new t.Uniform3f(e),u_perspective_transform:new t.Uniform2f(e)}),symbolIcon:e=>({u_is_size_zoom_constant:new t.Uniform1i(e),u_is_size_feature_constant:new t.Uniform1i(e),u_size_t:new t.Uniform1f(e),u_size:new t.Uniform1f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_rotate_symbol:new t.Uniform1i(e),u_aspect_ratio:new t.Uniform1f(e),u_fade_change:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_label_plane_matrix:new t.UniformMatrix4f(e),u_coord_matrix:new t.UniformMatrix4f(e),u_is_text:new t.Uniform1i(e),u_pitch_with_map:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_camera_forward:new t.Uniform3f(e),u_tile_matrix:new t.UniformMatrix4f(e),u_up_vector:new t.Uniform3f(e),u_ecef_origin:new t.Uniform3f(e),u_texture:new t.Uniform1i(e)}),symbolSDF:e=>({u_is_size_zoom_constant:new t.Uniform1i(e),u_is_size_feature_constant:new t.Uniform1i(e),u_size_t:new t.Uniform1f(e),u_size:new t.Uniform1f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_rotate_symbol:new t.Uniform1i(e),u_aspect_ratio:new t.Uniform1f(e),u_fade_change:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_label_plane_matrix:new t.UniformMatrix4f(e),u_coord_matrix:new t.UniformMatrix4f(e),u_is_text:new t.Uniform1i(e),u_pitch_with_map:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_texture:new t.Uniform1i(e),u_gamma_scale:new t.Uniform1f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_tile_id:new t.Uniform3f(e),u_zoom_transition:new t.Uniform1f(e),u_inv_rot_matrix:new t.UniformMatrix4f(e),u_merc_center:new t.Uniform2f(e),u_camera_forward:new t.Uniform3f(e),u_tile_matrix:new t.UniformMatrix4f(e),u_up_vector:new t.Uniform3f(e),u_ecef_origin:new t.Uniform3f(e),u_is_halo:new t.Uniform1i(e)}),symbolTextAndIcon:e=>({u_is_size_zoom_constant:new t.Uniform1i(e),u_is_size_feature_constant:new t.Uniform1i(e),u_size_t:new t.Uniform1f(e),u_size:new t.Uniform1f(e),u_camera_to_center_distance:new t.Uniform1f(e),u_rotate_symbol:new t.Uniform1i(e),u_aspect_ratio:new t.Uniform1f(e),u_fade_change:new t.Uniform1f(e),u_matrix:new t.UniformMatrix4f(e),u_label_plane_matrix:new t.UniformMatrix4f(e),u_coord_matrix:new t.UniformMatrix4f(e),u_is_text:new t.Uniform1i(e),u_pitch_with_map:new t.Uniform1i(e),u_texsize:new t.Uniform2f(e),u_texsize_icon:new t.Uniform2f(e),u_texture:new t.Uniform1i(e),u_texture_icon:new t.Uniform1i(e),u_gamma_scale:new t.Uniform1f(e),u_device_pixel_ratio:new t.Uniform1f(e),u_is_halo:new t.Uniform1i(e)}),background:e=>({u_matrix:new t.UniformMatrix4f(e),u_opacity:new t.Uniform1f(e),u_color:new t.UniformColor(e)}),backgroundPattern:e=>({u_matrix:new t.UniformMatrix4f(e),u_opacity:new t.Uniform1f(e),u_image:new t.Uniform1i(e),u_pattern_tl:new t.Uniform2f(e),u_pattern_br:new t.Uniform2f(e),u_texsize:new t.Uniform2f(e),u_pattern_size:new t.Uniform2f(e),u_pixel_coord_upper:new t.Uniform2f(e),u_pixel_coord_lower:new t.Uniform2f(e),u_tile_units_to_pixels:new t.Uniform1f(e)}),terrainRaster:yi,terrainDepth:yi,skybox:e=>({u_matrix:new t.UniformMatrix4f(e),u_sun_direction:new t.Uniform3f(e),u_cubemap:new t.Uniform1i(e),u_opacity:new t.Uniform1f(e),u_temporal_offset:new t.Uniform1f(e)}),skyboxGradient:e=>({u_matrix:new t.UniformMatrix4f(e),u_color_ramp:new t.Uniform1i(e),u_center_direction:new t.Uniform3f(e),u_radius:new t.Uniform1f(e),u_opacity:new t.Uniform1f(e),u_temporal_offset:new t.Uniform1f(e)}),skyboxCapture:e=>({u_matrix_3f:new t.UniformMatrix3f(e),u_sun_direction:new t.Uniform3f(e),u_sun_intensity:new t.Uniform1f(e),u_color_tint_r:new t.Uniform4f(e),u_color_tint_m:new t.Uniform4f(e),u_luminance:new t.Uniform1f(e)}),globeRaster:e=>({u_proj_matrix:new t.UniformMatrix4f(e),u_globe_matrix:new t.UniformMatrix4f(e),u_normalize_matrix:new t.UniformMatrix4f(e),u_merc_matrix:new t.UniformMatrix4f(e),u_zoom_transition:new t.Uniform1f(e),u_merc_center:new t.Uniform2f(e),u_image0:new t.Uniform1i(e),u_grid_matrix:new t.UniformMatrix3f(e),u_skirt_height:new t.Uniform1f(e),u_frustum_tl:new t.Uniform3f(e),u_frustum_tr:new t.Uniform3f(e),u_frustum_br:new t.Uniform3f(e),u_frustum_bl:new t.Uniform3f(e),u_globe_pos:new t.Uniform3f(e),u_globe_radius:new t.Uniform1f(e),u_viewport:new t.Uniform2f(e)}),globeAtmosphere:e=>({u_frustum_tl:new t.Uniform3f(e),u_frustum_tr:new t.Uniform3f(e),u_frustum_br:new t.Uniform3f(e),u_frustum_bl:new t.Uniform3f(e),u_horizon:new t.Uniform1f(e),u_transition:new t.Uniform1f(e),u_fadeout_range:new t.Uniform1f(e),u_color:new t.Uniform4f(e),u_high_color:new t.Uniform4f(e),u_space_color:new t.Uniform4f(e),u_star_intensity:new t.Uniform1f(e),u_star_density:new t.Uniform1f(e),u_star_size:new t.Uniform1f(e),u_temporal_offset:new t.Uniform1f(e),u_horizon_angle:new t.Uniform1f(e),u_rotation_matrix:new t.UniformMatrix4f(e)})};let ln;function cn(e,i,n,r,o,s,a){const l=e.context,c=l.gl,u=e.transform,h=e.useProgram("collisionBox"),p=[];let d=0,f=0;for(let m=0;m0){const e=t.create(),i=x;t.mul(e,v.placementInvProjMatrix,u.glCoordMatrix),t.mul(e,e,v.placementViewportMatrix),p.push({circleArray:w,circleOffset:f,transform:i,invTransform:e,projection:v.getProjection()}),d+=w.length/4,f=d}b&&(e.terrain&&e.terrain.setupElevationDraw(y,h),h.draw(l,c.LINES,t.DepthMode.disabled,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.disabled,ji(x,u,y,v.getProjection()),n.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,u.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}if(!a||!p.length)return;const m=e.useProgram("collisionCircle"),g=new t.StructArrayLayout2f1f2i16;g.resize(4*d),g._trim();let y=0;for(const t of p)for(let e=0;e=0&&(m[x.associatedIconIndex]={x:S,y:M,z:T,angle:D})}else de(A,d)}if(h){f.clear();const i=e.icon.placedSymbolArray;for(let e=0;et.sortKey-e.sortKey));for(const t of M){const i=t.state;if(e.terrain&&e.terrain.setupElevationDraw(i.tile,i.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:i.labelPlaneMatrixInv}),d.activeTexture.set(f.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,f.CLAMP_TO_EDGE),i.atlasTextureIcon&&(d.activeTexture.set(f.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,f.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,mn(i.buffers,t.segments,n,e,i.program,w,h,p,r)),r.u_is_halo=0}mn(i.buffers,t.segments,n,e,i.program,w,h,p,i.uniformValues)}}function mn(e,i,n,r,o,s,a,l,c){const u=r.context,h=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.globeExtVertexBuffer];o.draw(u,u.gl.TRIANGLES,s,a,l,t.CullFaceMode.disabled,c,n.id,e.layoutVertexBuffer,e.indexBuffer,i,n.paint,r.transform.zoom,e.programConfigurations.get(n.id),h)}function gn(e,i,n,r,o,s,a){const l=e.context.gl,c=n.paint.get("fill-pattern"),u=c&&c.constantOr(1);let h,p,d,f,m;a?(p=u&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=l.LINES):(p=u?"fillPattern":"fill",h=l.TRIANGLES);for(const g of r){const r=i.getTile(g);if(u&&!r.patternsLoaded())continue;const y=r.getBucket(n);if(!y)continue;e.prepareDrawTile();const v=y.programConfigurations.get(n.id),_=e.useProgram(p,v);u&&(e.context.activeTexture.set(l.TEXTURE0),r.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers());const x=c.constantOr(null);if(x&&r.imageAtlas){const t=r.imageAtlas.patternPositions[x.toString()];t&&v.setConstantPatternPositions(t)}const b=e.translatePosMatrix(g.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(a){f=y.indexBuffer2,m=y.segments2;const t=e.terrain&&e.terrain.renderingToTexture?e.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];d="fillOutlinePattern"===p&&u?Fi(b,e,r,t):zi(b,t)}else f=y.indexBuffer,m=y.segments,d=u?Bi(b,e,r):Ni(b);e.prepareDrawProgram(e.context,_,g.toUnwrapped()),_.draw(e.context,h,o,e.stencilModeForClipping(g),s,t.CullFaceMode.disabled,d,n.id,y.layoutVertexBuffer,f,m,n.paint,e.transform.zoom,v)}}function yn(e,i,n,r,o,s,a){const l=e.context,c=l.gl,u=e.transform,h=n.paint.get("fill-extrusion-pattern"),p=h.constantOr(1),d=n.paint.get("fill-extrusion-opacity"),f=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),n.paint.get("fill-extrusion-ambient-occlusion-radius")],m=n.layout.get("fill-extrusion-edge-radius"),g=m>0&&!n.paint.get("fill-extrusion-rounded-roof"),y=g?0:m,v="globe"===u.projection.name?t.fillExtrusionHeightLift():0,_="globe"===u.projection.name,x=_?t.globeToMercatorTransition(u.zoom):0,b=[t.mercatorXfromLng(u.center.lng),t.mercatorYfromLat(u.center.lat)],w=[];_&&w.push("PROJECTION_GLOBE_VIEW"),f[0]>0&&w.push("FAUX_AO"),g&&w.push("ZERO_ROOF_RADIUS");for(const m of r){const r=i.getTile(m),g=r.getBucket(n);if(!g||g.projection.name!==u.projection.name)continue;const A=g.programConfigurations.get(n.id),E=e.useProgram(p?"fillExtrusionPattern":"fillExtrusion",A,w);if(e.terrain){const t=e.terrain;if(e.style.terrainSetForDrapingOnly())t.setupElevationDraw(r,E,{useMeterToDem:!0});else{if(!g.enableTerrain)continue;if(t.setupElevationDraw(r,E,{useMeterToDem:!0}),vn(l,i,m,g,n,t),!g.centroidVertexBuffer){const t=E.attributes.a_centroid_pos;void 0!==t&&c.vertexAttrib2f(t,0,0)}}}p&&(e.context.activeTexture.set(c.TEXTURE0),r.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),A.updatePaintBuffers());const S=h.constantOr(null);if(S&&r.imageAtlas){const t=r.imageAtlas.patternPositions[S.toString()];t&&A.setConstantPatternPositions(t)}const M=e.translatePosMatrix(m.projMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),T=u.projection.createInversionMatrix(u,m.canonical),I=n.paint.get("fill-extrusion-vertical-gradient"),C=p?ki(M,e,I,d,f,y,m,r,v,x,b,T):Oi(M,e,I,d,f,y,m,v,x,b,T);e.prepareDrawProgram(l,E,m.toUnwrapped());const P=[];e.terrain&&P.push(g.centroidVertexBuffer),_&&P.push(g.layoutVertexExtBuffer),E.draw(l,l.gl.TRIANGLES,o,s,a,t.CullFaceMode.backCCW,C,n.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,n.paint,e.transform.zoom,A,P)}}function vn(e,i,n,r,o,s){const a=[e=>{let i=e.canonical.x-1,n=e.wrap;return i<0&&(i=(1<{let i=e.canonical.x+1,n=e.wrap;return i===1<new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new t.OverscaledTileID(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<{const e=i.getSource().minzoom,n=t=>{const e=i.getTileByID(t);if(e&&e.hasData())return e.getBucket(o)},r=[0,-1,1];for(const i of r){if(t.overscaledZ+i(c[0]=Math.min(e.min.y,i.min.y),c[1]=Math.max(e.max.y,i.max.y),c[2]=t.EXTENT-i.min.x>e.max.x?i.min.x-t.EXTENT:e.max.x,c),h=(e,i)=>(c[0]=Math.min(e.min.x,i.min.x),c[1]=Math.max(e.max.x,i.max.x),c[2]=t.EXTENT-i.min.y>e.max.y?i.min.y-t.EXTENT:e.max.y,c),p=[(t,e)=>u(t,e),(t,e)=>u(e,t),(t,e)=>h(t,e),(t,e)=>h(e,t)],d=new t.Point(0,0);let f,m,g;const y=(e,i,r,o,a)=>{const l=[[o?r:e,o?e:r,0],[o?r:i,o?i:r,0]],c=a<0?t.EXTENT+a:a,u=[o?c:(e+i)/2,o?(e+i)/2:c,0];return 0===r&&a<0||0!==r&&a>0?s.getForTilePoints(g,[u],!0,m):l.push(u),s.getForTilePoints(n,l,!0,f),Math.max(l[0][2],l[1][2],u[2])/s.exaggeration()};for(let e=0;e<4;e++){const i=(e<2?1:5)-e,o=r.borders[e];if(0===o.length)continue;const c=g=a[e](n),u=l(c);if(!(u&&u instanceof t.FillExtrusionBucket&&u.enableTerrain))continue;if(r.borderDoneWithNeighborZ[e]===u.canonical.z&&u.borderDoneWithNeighborZ[i]===r.canonical.z)continue;if(m=s.findDEMTileFor(c),!m||!m.dem)continue;if(!f){const t=s.findDEMTileFor(n);if(!t||!t.dem)return;f=t}const h=u.borders[i];let v=0;const _=u.borderDoneWithNeighborZ[i]!==r.canonical.z;if(r.canonical.z===u.canonical.z){for(let n=0;na[0]+3));)_&&u.encodeCentroid(void 0,l,!1),v++;if(l&&va[1]-3)&&(o++,++v!==h.length);)l=u.featuresOnBorder[h[v]];if(l=u.featuresOnBorder[h[n]],s.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(v=n),r.encodeCentroid(void 0,s,!1),_&&u.encodeCentroid(void 0,l,!1);continue}const c=p[e](s,l),f=e%2?t.EXTENT-1:0;d.x=y(c[0],Math.min(t.EXTENT-1,c[1]),f,e<2,c[2]),d.y=0,r.encodeCentroid(d,s,!1),_&&u.encodeCentroid(d,l,!1)}else r.encodeCentroid(void 0,s,!1)}r.borderDoneWithNeighborZ[e]=u.canonical.z,r.needsCentroidUpdate=!0,_&&(u.borderDoneWithNeighborZ[i]=r.canonical.z,u.needsCentroidUpdate=!0)}else{for(const t of o)r.encodeCentroid(void 0,r.featuresOnBorder[t],!1);if(_){for(const t of h)u.encodeCentroid(void 0,u.featuresOnBorder[t],!1);u.borderDoneWithNeighborZ[i]=r.canonical.z,u.needsCentroidUpdate=!0}r.borderDoneWithNeighborZ[e]=u.canonical.z,r.needsCentroidUpdate=!0}}(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(e)}const _n=new t.Color(1,0,0,1),xn=new t.Color(0,1,0,1),bn=new t.Color(0,0,1,1),wn=new t.Color(1,0,1,1),An=new t.Color(0,1,1,1);function En(e,i,n){const r=e.context,o=e.transform,s=r.gl,a="globe"===o.projection.name,l=a?["PROJECTION_GLOBE_VIEW"]:null;let c=n.projMatrix;if(a&&t.globeToMercatorTransition(o.zoom)>0){const e=t.transitionTileAABBinECEF(n.canonical,o),i=t.globeDenormalizeECEF(e);c=t.multiply(new Float32Array(16),o.globeMatrix,i),t.multiply(c,o.projMatrix,c)}const u=e.useProgram("debug",null,l),h=i.getTileByID(n.key);e.terrain&&e.terrain.setupElevationDraw(h,u);const p=t.DepthMode.disabled,d=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="$debug";r.activeTexture.set(s.TEXTURE0),e.emptyTexture.bind(s.LINEAR,s.CLAMP_TO_EDGE),a?h._makeGlobeTileDebugBuffers(e.context,o):h._makeDebugTileBoundsBuffers(e.context,o.projection);const g=h._tileDebugBuffer||e.debugBuffer,y=h._tileDebugIndexBuffer||e.debugIndexBuffer,v=h._tileDebugSegments||e.debugSegments;u.draw(r,s.LINE_STRIP,p,d,f,t.CullFaceMode.disabled,Hi(c,t.Color.red),m,g,y,v,null,null,null,[h._globeTileDebugBorderBuffer]);const _=h.latestRawTileData,x=Math.floor((_&&_.byteLength||0)/1024),b=i.getTile(n).tileSize,w=512/Math.min(b,512)*(n.overscaledZ/o.zoom)*.5;let A=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(A+=` => ${n.overscaledZ}`),A+=` ${x}kb`,function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,n=t.context.gl,r=t.debugOverlayCanvas.getContext("2d");r.clearRect(0,0,i.width,i.height),r.shadowColor="white",r.shadowBlur=2,r.lineWidth=1.5,r.strokeStyle="white",r.textBaseline="top",r.font="bold 36px Open Sans, sans-serif",r.fillText(e,5,5),r.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(e,A);const E=h._tileDebugTextBuffer||e.debugBuffer,S=h._tileDebugTextIndexBuffer||e.quadTriangleIndexBuffer,M=h._tileDebugTextSegments||e.debugSegments;u.draw(r,s.TRIANGLES,p,d,t.ColorMode.alphaBlended,t.CullFaceMode.disabled,Hi(c,t.Color.transparent,w),m,E,S,M,null,null,null,[h._globeTileDebugTextBuffer])}function Sn(t,e,i,n){Tn(t,0,e+i/2,t.transform.width,i,n)}function Mn(t,e,i,n){Tn(t,e-i/2,0,i,t.transform.height,n)}function Tn(e,i,n,r,o,s){const a=e.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*t.exported.devicePixelRatio,n*t.exported.devicePixelRatio,r*t.exported.devicePixelRatio,o*t.exported.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const In=t.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Cn}=In;function Pn(t,e,i,n){t.emplaceBack(e,i,n)}class Ln{constructor(e){this.vertexArray=new t.StructArrayLayout3f12,this.indices=new t.StructArrayLayout3ui6,Pn(this.vertexArray,-1,-1,1),Pn(this.vertexArray,1,-1,1),Pn(this.vertexArray,-1,1,1),Pn(this.vertexArray,1,1,1),Pn(this.vertexArray,-1,-1,-1),Pn(this.vertexArray,1,-1,-1),Pn(this.vertexArray,-1,1,-1),Pn(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=e.createVertexBuffer(this.vertexArray,Cn),this.indexBuffer=e.createIndexBuffer(this.indices),this.segment=t.SegmentVector.simpleSegment(0,0,36,12)}}function Dn(e,i,n,r,o,s){const a=e.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((t,e,i,n,r)=>({u_matrix_3f:t,u_sun_direction:e,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(t.fromMat4(t.create$1(),r),o,u,l,c);a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),n.draw(e,a.TRIANGLES,t.DepthMode.disabled,t.StencilMode.disabled,t.ColorMode.unblended,t.CullFaceMode.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Rn=t.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class On{constructor(e){const i=new t.StructArrayLayout5f20;i.emplaceBack(-1,1,1,0,0),i.emplaceBack(1,1,1,1,0),i.emplaceBack(1,-1,1,1,1),i.emplaceBack(-1,-1,1,0,1);const n=new t.StructArrayLayout3ui6;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=e.createVertexBuffer(i,Rn.members),this.indexBuffer=e.createIndexBuffer(n),this.segments=t.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const kn={symbol:function(e,i,n,r,o){if("translucent"!==e.renderPass)return;const s=t.StencilMode.disabled,a=e.colorModeForRenderPass();n.layout.get("text-variable-anchor")&&function(e,i,n,r,o,s,a){const l=i.transform,c="map"===o,u="map"===s;for(const i of e){const e=r.getTile(i),o=e.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;const s=t.evaluateSizeForZoom(o.textSizeData,l.zoom),h=_e(i,o.getProjection(),l),p=l.calculatePixelsToTileUnitsMatrix(e),d=te(h,e.tileID.canonical,u,c,l,o.getProjection(),p),f="none"!==n.layout.get("icon-text-fit")&&o.hasIconData();if(s){const n=Math.pow(2,l.zoom-e.tileID.overscaledZ);pn(o,c,u,a,t.symbolSize,l,d,i,n,s,f)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&fn(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),s,a),0!==n.paint.get("text-opacity").constantOr(1)&&fn(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),s,a),i.map.showCollisionBoxes&&(cn(e,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),cn(e,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(e,i,n,r){if("translucent"!==e.renderPass)return;const o=n.paint.get("circle-opacity"),s=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const c=e.context,u=c.gl,h=e.transform,p=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),d=t.StencilMode.disabled,f=e.colorModeForRenderPass(),m="globe"===h.projection.name,g=[t.mercatorXfromLng(h.center.lng),t.mercatorYfromLat(h.center.lat)],y=[];for(let o=0;ot.sortKey-e.sortKey));const v={useDepthForOcclusion:!m};for(const i of y){const{programConfiguration:r,program:o,layoutVertexBuffer:s,globeExtVertexBuffer:a,indexBuffer:l,uniformValues:m,tile:g}=i.state,y=i.segments;e.terrain&&e.terrain.setupElevationDraw(g,o,v),e.prepareDrawProgram(c,o,g.tileID.toUnwrapped()),o.draw(c,u.TRIANGLES,p,d,f,t.CullFaceMode.disabled,m,n.id,s,l,y,n.paint,h.zoom,r,[a])}},heatmap:function(e,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===e.renderPass){const o=e.context,s=o.gl,a=t.StencilMode.disabled,l=new t.ColorMode([s.ONE,s.ONE],t.Color.transparent,[!0,!0,!0,!0]);!function(t,e,i,n){const r=t.gl,o=e.width*n,s=e.height*n;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const e=r.createTexture();r.bindTexture(r.TEXTURE_2D,e),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),a=i.heatmapFbo=t.createFramebuffer(o,s,!1),function(t,e,i,n,r,o){const s=t.gl;s.texImage2D(s.TEXTURE_2D,0,t.isWebGL2&&t.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,r,o,0,s.RGBA,t.extRenderToTextureHalfFloat?t.isWebGL2?s.HALF_FLOAT:t.extTextureHalfFloat.HALF_FLOAT_OES:s.UNSIGNED_BYTE,null),n.colorAttachment.set(i)}(t,0,e,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),t.bindFramebuffer.set(a.framebuffer)}(o,e,n,"globe"===e.transform.projection.name?.5:.25),o.clear({color:t.Color.transparent});const c=e.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:null,p=u?t.CullFaceMode.frontCCW:t.CullFaceMode.disabled,d=[t.mercatorXfromLng(c.center.lng),t.mercatorYfromLat(c.center.lat)];for(let f=0;f({u_image:0,u_color_ramp:1,u_opacity:e.paint.get("heatmap-opacity")}))(0,i),i.id,e.viewportBuffer,e.quadTriangleIndexBuffer,e.viewportSegments,i.paint,e.transform.zoom)}(e,n))},line:function(e,i,n,r){if("translucent"!==e.renderPass)return;const o=n.paint.get("line-opacity"),s=n.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),l=e.colorModeForRenderPass(),c=e.terrain&&e.terrain.renderingToTexture?1:t.exported.devicePixelRatio,u=n.paint.get("line-dasharray"),h=u.constantOr(1),p=n.layout.get("line-cap"),d=n.paint.get("line-pattern"),f=d.constantOr(1),m=n.paint.get("line-gradient"),g=f?"linePattern":"line",y=e.context,v=y.gl,_=(t=>{const e=[];Ji(t)&&e.push("RENDER_LINE_DASH"),t.paint.get("line-gradient")&&e.push("RENDER_LINE_GRADIENT");const i=t.paint.get("line-trim-offset");0===i[0]&&0===i[1]||e.push("RENDER_LINE_TRIM_OFFSET");const n=t.paint.get("line-pattern").constantOr(1),r=1!==t.paint.get("line-opacity").constantOr(1);return!n&&r&&e.push("RENDER_LINE_ALPHA_DISCARD"),e})(n);let x=_.includes("RENDER_LINE_ALPHA_DISCARD");e.terrain&&e.terrain.clipOrMaskOverlapStencilType()&&(x=!1);for(const o of r){const r=i.getTile(o);if(f&&!r.patternsLoaded())continue;const s=r.getBucket(n);if(!s)continue;e.prepareDrawTile();const b=s.programConfigurations.get(n.id),w=e.useProgram(g,b,_),A=d.constantOr(null);if(A&&r.imageAtlas){const t=r.imageAtlas.patternPositions[A.toString()];t&&b.setConstantPatternPositions(t)}const E=u.constantOr(null),S=p.constantOr(null);if(!f&&E&&S&&r.lineAtlas){const t=r.lineAtlas.getDash(E,S);t&&b.setConstantPatternPositions(t)}let[M,T]=n.paint.get("line-trim-offset");if("round"===S||"square"===S){const t=1;M!==T&&(0===M&&(M-=t),1===T&&(T+=t))}const I=e.terrain?o.projMatrix:null,C=f?Zi(e,r,n,I,c):Xi(e,r,n,I,s.lineClipsArray.length,c,[M,T]);if(m){const r=s.gradients[n.id];let a=r.texture;if(n.gradientVersion!==r.version){let l=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=o.canonical.z===n?Math.ceil(1<{w.draw(y,v.TRIANGLES,a,i,l,t.CullFaceMode.disabled,C,n.id,s.layoutVertexBuffer,s.indexBuffer,s.segments,n.paint,e.transform.zoom,b,[s.layoutVertexBuffer2])};if(x){const i=e.stencilModeForClipping(o).ref;0===i&&e.terrain&&y.clear({stencil:0});const n={func:v.EQUAL,mask:255};C.u_alpha_discard_threshold=.8,P(new t.StencilMode(n,i,255,v.KEEP,v.KEEP,v.INVERT)),C.u_alpha_discard_threshold=0,P(new t.StencilMode(n,i,255,v.KEEP,v.KEEP,v.KEEP))}else P(e.stencilModeForClipping(o))}x&&(e.resetStencilClippingMasks(),e.terrain&&y.clear({stencil:0}))},fill:function(e,i,n,r){const o=n.paint.get("fill-color"),s=n.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=e.colorModeForRenderPass(),l=n.paint.get("fill-pattern"),c=e.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(t.Color.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";if(e.renderPass===c){const o=e.depthModeForSublayer(1,"opaque"===e.renderPass?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly);gn(e,i,n,r,o,a,!1)}if("translucent"===e.renderPass&&n.paint.get("fill-antialias")){const o=e.depthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,t.DepthMode.ReadOnly);gn(e,i,n,r,o,a,!0)}},"fill-extrusion":function(e,i,n,r){const o=n.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===e.renderPass){const s=new t.DepthMode(e.context.gl.LEQUAL,t.DepthMode.ReadWrite,e.depthRangeFor3D);if(1!==o||n.paint.get("fill-extrusion-pattern").constantOr(1))yn(e,i,n,r,s,t.StencilMode.disabled,t.ColorMode.disabled),yn(e,i,n,r,s,e.stencilModeFor3D(),e.colorModeForRenderPass()),e.resetStencilClippingMasks();else{const o=e.colorModeForRenderPass();yn(e,i,n,r,s,t.StencilMode.disabled,o)}}},hillshade:function(e,i,n,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;const o=e.context,s=e.depthModeForSublayer(0,t.DepthMode.ReadOnly),a=e.colorModeForRenderPass(),l=e.terrain&&e.terrain.renderingToTexture,[c,u]="translucent"!==e.renderPass||l?[{},r]:e.stencilConfigForOverlap(r);for(const r of u){const o=i.getTile(r);if(o.needsHillshadePrepare&&"offscreen"===e.renderPass)gi(e,o,n,s,t.StencilMode.disabled,a);else if("translucent"===e.renderPass){const t=l&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):c[r.overscaledZ];fi(e,r,o,n,s,t,a)}}o.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(e,i,n,r,o,s){if("translucent"!==e.renderPass)return;if(0===n.paint.get("raster-opacity"))return;if(!r.length)return;const a=e.context,l=a.gl,c=i.getSource(),u=e.useProgram("raster"),h=e.colorModeForRenderPass(),p=e.terrain&&e.terrain.renderingToTexture,[d,f]=c instanceof It||p?[{},r]:e.stencilConfigForOverlap(r),m=f[f.length-1].overscaledZ,g=!e.options.moving;for(const r of f){const o=p?t.DepthMode.disabled:e.depthModeForSublayer(r.overscaledZ-m,1===n.paint.get("raster-opacity")?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly,l.LESS),f=r.toUnwrapped(),y=i.getTile(r);if(p&&(!y||!y.hasData()))continue;const v=p?r.projMatrix:e.transform.calculateProjMatrix(f,g),_=e.terrain&&p?e.terrain.stencilModeForRTTOverlap(r):d[r.overscaledZ],x=s?0:n.paint.get("raster-fade-duration");y.registerFadeDuration(x);const b=i.findLoadedParent(r,0),w=Mi(y,b,i,e.transform,x);let A,E;e.terrain&&e.terrain.prepareDrawTile();const S="nearest"===n.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;a.activeTexture.set(l.TEXTURE0),y.texture.bind(S,l.CLAMP_TO_EDGE),a.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),A=Math.pow(2,b.tileID.overscaledZ-y.tileID.overscaledZ),E=[y.tileID.canonical.x*A%1,y.tileID.canonical.y*A%1]):y.texture.bind(S,l.CLAMP_TO_EDGE),y.texture.useMipmap&&a.extTextureFilterAnisotropic&&e.transform.pitch>20&&l.texParameterf(l.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax);const M=Ki(v,E||[0,0],A||1,w,n,c instanceof It?c.perspectiveTransform:[0,0]);if(e.prepareDrawProgram(a,u,f),c instanceof It)c.boundsBuffer&&c.boundsSegments&&u.draw(a,l.TRIANGLES,o,t.StencilMode.disabled,h,t.CullFaceMode.disabled,M,n.id,c.boundsBuffer,e.quadTriangleIndexBuffer,c.boundsSegments);else{const{tileBoundsBuffer:i,tileBoundsIndexBuffer:r,tileBoundsSegments:s}=e.getTileBoundsBuffers(y);u.draw(a,l.TRIANGLES,o,_,h,t.CullFaceMode.disabled,M,n.id,i,r,s)}}e.resetStencilClippingMasks()},background:function(e,i,n,r){const o=n.paint.get("background-color"),s=n.paint.get("background-opacity");if(0===s)return;const a=e.context,l=a.gl,c=e.transform,u=c.tileSize,h=n.paint.get("background-pattern");if(e.isPatternMissing(h))return;const p=!h&&1===o.a&&1===s&&e.opaquePassEnabledForLayer()?"opaque":"translucent";if(e.renderPass!==p)return;const d=t.StencilMode.disabled,f=e.depthModeForSublayer(0,"opaque"===p?t.DepthMode.ReadWrite:t.DepthMode.ReadOnly),m=e.colorModeForRenderPass(),g=e.useProgram(h?"backgroundPattern":"background");let y,v=r;v||(y=e.getBackgroundTiles(),v=Object.values(y).map((t=>t.tileID))),h&&(a.activeTexture.set(l.TEXTURE0),e.imageManager.bind(e.context));for(const p of v){const v=p.toUnwrapped(),_=r?p.projMatrix:e.transform.calculateProjMatrix(v);e.prepareDrawTile();const x=i?i.getTile(p):y?y[p.key]:new t.Tile(p,u,c.zoom,e),b=h?sn(_,s,e,h,{tileID:p,tileSize:u}):on(_,s,o);e.prepareDrawProgram(a,g,v);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:A,tileBoundsSegments:E}=e.getTileBoundsBuffers(x);g.draw(a,l.TRIANGLES,f,d,m,t.CullFaceMode.disabled,b,n.id,w,A,E)}},sky:function(e,i,n){const r=e.transform,o="mercator"===r.projection.name||"globe"===r.projection.name?1:t.smoothstep(7,8,r.zoom),s=n.paint.get("sky-opacity")*o;if(0===s)return;const a=e.context,l=n.paint.get("sky-type"),c=new t.DepthMode(a.gl.LEQUAL,t.DepthMode.ReadOnly,[0,1]),u=e.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===e.renderPass?n.needsSkyboxCapture(e)&&(function(e,i,n,r){const o=e.context,s=o.gl;let a=i.skyboxFbo;if(!a){a=i.skyboxFbo=o.createFramebuffer(32,32,!1),i.skyboxGeometry=new Ln(o),i.skyboxTexture=o.gl.createTexture(),s.bindTexture(s.TEXTURE_CUBE_MAP,i.skyboxTexture),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR);for(let t=0;t<6;++t)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,s.RGBA,32,32,0,s.RGBA,s.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(a.framebuffer),o.viewport.set([0,0,32,32]);const l=i.getCenter(e,!0),c=e.useProgram("skyboxCapture"),u=new Float64Array(16);t.identity(u),t.rotateY(u,u,.5*-Math.PI),Dn(o,i,c,u,l,0),t.identity(u),t.rotateY(u,u,.5*Math.PI),Dn(o,i,c,u,l,1),t.identity(u),t.rotateX(u,u,.5*-Math.PI),Dn(o,i,c,u,l,2),t.identity(u),t.rotateX(u,u,.5*Math.PI),Dn(o,i,c,u,l,3),t.identity(u),Dn(o,i,c,u,l,4),t.identity(u),t.rotateY(u,u,Math.PI),Dn(o,i,c,u,l,5),o.viewport.set([0,0,e.width,e.height])}(e,n),n.markSkyboxValid(e)):"sky"===e.renderPass&&function(e,i,n,r,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skybox");s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_CUBE_MAP,i.skyboxTexture);const u=((t,e,i,n,r)=>({u_matrix:t,u_sun_direction:e,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(l.skyboxMatrix,i.getCenter(e,!1),0,r,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,n,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,u,"skybox",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,n,c,s,u):"gradient"===l&&"sky"===e.renderPass&&function(e,i,n,r,o){const s=e.context,a=s.gl,l=e.transform,c=e.useProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ln(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new t.Texture(s,i.colorRamp,a.RGBA)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((e,i,n,r,o)=>({u_matrix:e,u_color_ramp:0,u_center_direction:i,u_radius:t.degToRad(n),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(e,!1),i.paint.get("sky-gradient-radius"),r,o);e.prepareDrawProgram(s,c),c.draw(s,a.TRIANGLES,n,t.StencilMode.disabled,e.colorModeForRenderPass(),t.CullFaceMode.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(e,n,c,s,u)},debug:function(t,e,i){for(let n=0;nn)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-i);this.transform.fogCullDistSq=r*r}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(e,i){if(this.width=e*t.exported.devicePixelRatio,this.height=i*t.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style.order)this.style._layers[t].resize()}setup(){const e=this.context,i=new t.StructArrayLayout2i4;i.emplaceBack(0,0),i.emplaceBack(t.EXTENT,0),i.emplaceBack(0,t.EXTENT),i.emplaceBack(t.EXTENT,t.EXTENT),this.tileExtentBuffer=e.createVertexBuffer(i,t.posAttributes.members),this.tileExtentSegments=t.SegmentVector.simpleSegment(0,0,4,2);const 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.debugBuffer=e.createVertexBuffer(n,t.posAttributes.members),this.debugSegments=t.SegmentVector.simpleSegment(0,0,4,5);const r=new t.StructArrayLayout2i4;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(-1,1),r.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(r,t.posAttributes.members),this.viewportSegments=t.SegmentVector.simpleSegment(0,0,4,2);const o=new t.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(t.EXTENT,0,t.EXTENT,0),o.emplaceBack(0,t.EXTENT,0,t.EXTENT),o.emplaceBack(t.EXTENT,t.EXTENT,t.EXTENT,t.EXTENT),this.mercatorBoundsBuffer=e.createVertexBuffer(o,t.boundsAttributes.members),this.mercatorBoundsSegments=t.SegmentVector.simpleSegment(0,0,4,2);const s=new t.StructArrayLayout3ui6;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(s);const a=new t.StructArrayLayout1ui2;for(const t of[0,1,3,2,0])a.emplaceBack(t);this.debugIndexBuffer=e.createIndexBuffer(a),this.emptyTexture=new t.Texture(e,new t.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),e.gl.RGBA),this.identityMat=t.create();const l=this.context.gl;this.stencilClearMode=new t.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(t.window.performance.now()),this.atmosphereBuffer=new On(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(t){return t._makeTileBoundsBuffers(this.context,this.transform.projection),t._tileBoundsBuffer?{tileBoundsBuffer:t._tileBoundsBuffer,tileBoundsIndexBuffer:t._tileBoundsIndexBuffer,tileBoundsSegments:t._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(e,i.TRIANGLES,t.DepthMode.disabled,this.stencilClearMode,t.ColorMode.disabled,t.CullFaceMode.disabled,Si(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,i,n){if(!i||this.currentStencilSource===i.id||!e.isTileClipped()||!n||0===n.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let t=!1;for(const e of n)if(void 0===this._tileClippingMaskIDs[e.key]){t=!0;break}if(!t)return}this.currentStencilSource=i.id;const r=this.context,o=r.gl;this.nextStencilID+n.length>256&&this.clearStencil(),r.setColorMode(t.ColorMode.disabled),r.setDepthMode(t.DepthMode.disabled);const s=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of n){const n=i.getTile(e),a=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:c,tileBoundsSegments:u}=this.getTileBoundsBuffers(n);s.draw(r,o.TRIANGLES,t.DepthMode.disabled,new t.StencilMode({func:o.ALWAYS,mask:0},a,255,o.KEEP,o.KEEP,o.REPLACE),t.ColorMode.disabled,t.CullFaceMode.disabled,Si(e.projMatrix),"$clipping",l,c,u)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,i=this.context.gl;return new t.StencilMode({func:i.NOTEQUAL,mask:255},e,255,i.KEEP,i.KEEP,i.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const i=this.context.gl;return new t.StencilMode({func:i.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,i.KEEP,i.KEEP,i.REPLACE)}stencilConfigForOverlap(e){const i=this.context.gl,n=e.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=n[n.length-1].overscaledZ,o=n[0].overscaledZ-r+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const e={};for(let n=0;n=0;this.currentLayer--){const t=this.style._layers[n[this.currentLayer]],i=e._getLayerSourceCache(t);if(t.isSky())continue;const r=i?s[i.id]:void 0;this._renderTileClippingMasks(t,i,r),this.renderLayer(this,i,t,r)}if(this.style.fog&&this.transform.projection.supportsFog&&function(e,i){const n=e.context,r=n.gl,o=e.transform,s=new t.DepthMode(r.LEQUAL,t.DepthMode.ReadOnly,[0,1]),a=e.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=t.globeToMercatorTransition(o.zoom),c=i.properties.get("color").toArray01(),u=i.properties.get("high-color").toArray01(),h=i.properties.get("space-color").toArray01PremultipliedAlpha(),p=t.identity$1([]);t.rotateY$1(p,p,-t.degToRad(o._center.lng)),t.rotateX$1(p,p,t.degToRad(o._center.lat)),t.rotateZ$1(p,p,o.angle),t.rotateX$1(p,p,-o._pitch);const d=t.fromQuat(new Float32Array(16),p),f=t.mapValue(i.properties.get("star-intensity"),0,1,0,.25),m=5e-4,g=t.mapValue(i.properties.get("horizon-blend"),0,1,m,.25),y=t.globeUseCustomAntiAliasing(e,n,o)&&g===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,v=e.frameCounter/1e3%1,_=t.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(_,2)-Math.pow(y,2)),b=Math.acos(x/_),w=((e,i,n,r,o,s,a,l,c,u,h,p,d,f)=>({u_frustum_tl:e,u_frustum_tr:i,u_frustum_br:n,u_frustum_bl:r,u_horizon:o,u_transition:s,u_fadeout_range:a,u_color:l,u_high_color:c,u_space_color:u,u_star_intensity:h,u_star_size:5*t.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:p,u_horizon_angle:d,u_rotation_matrix:f}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,g,c,u,h,f,v,b,d);e.prepareDrawProgram(n,a);const A=e.atmosphereBuffer;A&&a.draw(n,r.TRIANGLES,s,t.StencilMode.disabled,t.ColorMode.alphaBlended,t.CullFaceMode.backCW,w,"skybox",A.vertexBuffer,A.indexBuffer,A.segments)}(this,this.style.fog),this.renderPass="sky",(t.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const n=e._getLayerSourceCache(t);n&&!t.isHidden(this.transform.zoom)&&(!i||i.getSource().maxzoom0?e.pop():null}isPatternMissing(t){return null===t||void 0!==t&&!this.imageManager.getPattern(t.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const t=this.terrain&&this.terrain.renderingToTexture,e=this.terrain&&0===this.terrain.exaggeration(),i=this.style&&this.style.fog,n=[];return this.terrainRenderModeElevated()&&n.push("TERRAIN"),"globe"===this.transform.projection.name&&n.push("GLOBE"),e&&n.push("ZERO_EXAGGERATION"),i&&!t&&0!==i.getOpacity(this.transform.pitch)&&n.push("FOG"),t&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}useProgram(t,e,i){this.cache=this.cache||{};const n=i||[],r=this.currentGlobalDefines().concat(n),o=Li.cacheKey(ci[t],t,r,e);return this.cache[o]||(this.cache[o]=new Li(this.context,t,ci[t],e,an[t],r)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const 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)}initDebugOverlayCanvas(){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))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(e,i,n){if(this.terrain&&this.terrain.renderingToTexture)return;const r=this.style.fog;if(r){const o=r.getOpacity(this.transform.pitch),s=((e,i,n,r,o,s,a,l,c,u,h)=>{const p=e.transform,d=i.properties.get("color").toArray01();d[3]=r;const f=e.frameCounter/1e3%1;return{u_fog_matrix:n?p.calculateFogTileMatrix(n):e.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:d,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_temporal_offset:f,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:t.globeToMercatorTransition(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,r,n,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*t.exported.devicePixelRatio,this.transform.height*t.exported.devicePixelRatio]);i.setFogUniformValues(e,s)}}setTileLoadedFlag(t){this.tileLoaded=t}saveCanvasCopy(){const t=this.canvasCopy();t&&(this.frameCopies.push(t),this.tileLoaded=!1)}canvasCopy(){const t=this.context.gl,e=t.createTexture();return t.bindTexture(t.TEXTURE_2D,e),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGBA,0,0,t.drawingBufferWidth,t.drawingBufferHeight,0),e}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const t=this.style&&this.style.fog;return!!t&&0!==t.getOpacity(this.transform.pitch)}getBackgroundTiles(){const e=this._backgroundTiles,i=this._backgroundTiles={},n=this.transform.coveringTiles({tileSize:512});for(const r of n)i[r.key]=e[r.key]||new t.Tile(r,512,this.transform.tileZoom,this);return i}clearBackgroundTiles(){this._backgroundTiles={}}}class Bn{constructor(t=0,e=0,i=0,n=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(n)||n<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=i,this.right=n}interpolate(e,i,n){return null!=i.top&&null!=e.top&&(this.top=t.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.clamp((this.left+e-this.right)/2,0,e),r=t.clamp((this.top+i-this.bottom)/2,0,i);return new t.Point(n,r)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Bn(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function zn(e,i){const n=t.getColumn(e,3);t.fromQuat(e,i),t.setColumn(e,3,n)}function Fn(e,i){const n=t.identity$1([]);return t.rotateZ$1(n,n,-i),t.rotateX$1(n,n,-e),n}function Vn(e,i){const n=[e[0],e[1],0],r=[i[0],i[1],0];if(t.length(n)>=1e-15){const e=t.normalize([],n);t.scale$2(r,e,t.dot(r,e)),i[0]=r[0],i[1]=r[1]}const o=t.cross([],i,e);if(t.len(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Fn(Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2]),s)}class Un{constructor(t,e){this.position=t,this.orientation=e}get position(){return this._position}set position(e){if(e){const i=e instanceof t.MercatorCoordinate?e:new t.MercatorCoordinate(e[0],e[1],e[2]);this._renderWorldCopies&&(i.x=t.wrap(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(e,i){if(this.orientation=null,!this.position)return;const n=this.position,r=this._elevation?this._elevation.getAtPointOrZero(t.MercatorCoordinate.fromLngLat(e)):0,o=t.MercatorCoordinate.fromLngLat(e,r),s=[o.x-n.x,o.y-n.y,o.z-n.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=Vn(s,i)}setPitchBearing(e,i){this.orientation=Fn(t.degToRad(e),t.degToRad(-i))}}class Gn{constructor(e,i){this._transform=t.identity([]),this.orientation=i,this.position=e}get mercatorPosition(){const e=this.position;return new t.MercatorCoordinate(e[0],e[1],e[2])}get position(){const e=t.getColumn(this._transform,3);return[e[0],e[1],e[2]]}set position(e){var i;e&&t.setColumn(this._transform,3,[(i=e)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(e){this._orientation=e||t.identity$1([]),e&&zn(this._transform,this._orientation)}getPitchBearing(){const t=this.forward(),e=this.right();return{bearing:Math.atan2(-e[1],e[0]),pitch:Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2])}}setPitchBearing(t,e){this._orientation=Fn(t,e),zn(this._transform,this._orientation)}forward(){const e=t.getColumn(this._transform,2);return[-e[0],-e[1],-e[2]]}up(){const e=t.getColumn(this._transform,1);return[-e[0],-e[1],-e[2]]}right(){const e=t.getColumn(this._transform,0);return[e[0],e[1],e[2]]}getCameraToWorld(e,i){const n=new Float64Array(16);return t.invert(n,this.getWorldToCamera(e,i)),n}getWorldToCameraPosition(e,i,n){const r=this.position;t.scale$2(r,r,-e);const o=new Float64Array(16);return t.fromScaling(o,[n,n,n]),t.translate(o,o,r),o[10]*=i,o}getWorldToCamera(e,i){const n=new Float64Array(16),r=new Float64Array(4),o=this.position;return t.conjugate(r,this._orientation),t.scale$2(o,o,-e),t.fromQuat(n,r),t.translate(n,n,o),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(e,i,n,r){const o=new Float64Array(16);return t.perspective(o,e,i,n,r),o}getDistanceToElevation(e,i=!1){const n=0===e?0:t.mercatorZfromAltitude(e,i?t.latFromMercatorY(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new Gn([...this.position],[...this.orientation])}}function jn(e,i){const n=Wn(e.projection,e.zoom,e.width,e.height),r=function(e,i,n,r,o){const s=new t.LngLat(n.lng-180*qn,n.lat),a=new t.LngLat(n.lng+180*qn,n.lat),l=e.project(s.lng,s.lat),c=e.project(a.lng,a.lat),u=-Math.atan2(c.y-l.y,c.x-l.x),h=t.MercatorCoordinate.fromLngLat(n);h.y=t.clamp(h.y,-1+qn,1-qn);const p=h.toLngLat(),d=e.project(p.lng,p.lat),f=t.MercatorCoordinate.fromLngLat(p);f.x+=qn;const m=f.toLngLat(),g=e.project(m.lng,m.lat),y=Zn(g.x-d.x,g.y-d.y,u),v=t.MercatorCoordinate.fromLngLat(p);v.y+=qn;const _=v.toLngLat(),x=e.project(_.lng,_.lat),b=Zn(x.x-d.x,x.y-d.y,u),w=Math.abs(y.x)/Math.abs(b.y),A=t.identity([]);t.rotateZ(A,A,-u*(1-(o?0:r)));const E=t.identity([]);return t.scale(E,E,[1,1-(1-w)*r,1]),E[4]=-b.x/b.y*r,t.rotateZ(E,E,u),t.multiply(E,A,E),E}(e.projection,0,e.center,n,i),o=Hn(e);return t.scale(r,r,[o,o,1]),r}function Hn(e){const i=e.projection,n=Wn(e.projection,e.zoom,e.width,e.height),r=Xn(i,e.center),o=Xn(i,t.LngLat.convert(i.center));return Math.pow(2,r*n+(1-n)*o)}function Wn(e,i,n,r,o=1/0){const s=e.range;if(!s)return 0;const a=Math.min(o,Math.max(n,r)),l=Math.log(a/1024)/Math.LN2;return t.smoothstep(s[0]+l,s[1]+l,i)}const qn=1/4e4;function Xn(e,i){const n=t.clamp(i.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),r=new t.LngLat(i.lng-180*qn,n),o=new t.LngLat(i.lng+180*qn,n),s=e.project(r.lng,n),a=e.project(o.lng,n),l=t.MercatorCoordinate.fromLngLat(r),c=t.MercatorCoordinate.fromLngLat(o),u=a.x-s.x,h=a.y-s.y,p=c.x-l.x,d=c.y-l.y,f=Math.sqrt((p*p+d*d)/(u*u+h*h));return Math.log(f)/Math.LN2}function Zn(t,e,i){const n=Math.cos(i),r=Math.sin(i);return{x:t*n-e*r,y:t*r+e*n}}class Yn{constructor(e,i,n,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=e||0,this._maxZoom=i||22,this._minPitch=null==n?0:n,this._maxPitch=null==r?60:r,this.setProjection(s),this.setMaxBounds(a),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._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Bn,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Gn,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const t=new Yn(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return t._elevation=this._elevation,t._centerAltitude=this._centerAltitude,t._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,t.tileSize=this.tileSize,t.mercatorFromTransition=this.mercatorFromTransition,t.width=this.width,t.height=this.height,t.cameraElevationReference=this.cameraElevationReference,t._center=this._center,t._setZoom(this.zoom),t._seaLevelZoom=this._seaLevelZoom,t.angle=this.angle,t._fov=this._fov,t._pitch=this._pitch,t._nearZ=this._nearZ,t._farZ=this._farZ,t._averageElevation=this._averageElevation,t._unmodified=this._unmodified,t._edgeInsets=this._edgeInsets.clone(),t._camera=this._camera.clone(),t._calcMatrices(),t.freezeTileCoverage=this.freezeTileCoverage,t.frustumCorners=this.frustumCorners,t}get elevation(){return this._elevation}set elevation(t){this._elevation!==t&&(this._elevation=t,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(t,e=!1){const i=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||i)&&this._updateCameraOnTerrain(),(t||i)&&this._constrainCamera(e),this._calcMatrices()}getProjection(){return t.pick(this.projection,["name","center","parallels"])}setProjection(i){this.projectionOptions=i||{name:"mercator"};const n=this.projection?this.getProjection():void 0;this.projection=t.getProjection(this.projectionOptions);const r=!e(n,this.getProjection());return r&&this._calcMatrices(),this.mercatorFromTransition=!1,r}setMercatorFromTransition(){const e=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=t.getProjection({name:"mercator"});const i=e!==this.projection.name;return i&&this._calcMatrices(),i}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get cameraWorldSize(){const t=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(t))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return t.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.Point(this.width,this.height)}get bearing(){return t.wrap(this.rotation,-180,180)}set bearing(t){this.rotation=t}get rotation(){return-this.angle/Math.PI*180}set rotation(e){const i=-e*Math.PI/180;var n;this.angle!==i&&(this._unmodified=!1,this.angle=i,this._calcMatrices(),this.rotationMatrix=(n=new t.ARRAY_TYPE(4),t.ARRAY_TYPE!=Float32Array&&(n[1]=0,n[2]=0),n[0]=1,n[3]=1,n),function(t,e,i){var n=e[0],r=e[1],o=e[2],s=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=n*l+o*a,t[1]=r*l+s*a,t[2]=n*-a+o*l,t[3]=r*-a+s*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(e){const i=t.clamp(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==i&&(this._unmodified=!1,this._pitch=i,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const t=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/t)}set fov(e){e=Math.max(.01,Math.min(60,e)),this._fov!==e&&(this._unmodified=!1,this._fov=t.degToRad(e),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(t){this._averageElevation=t,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(t){const e=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==e&&(this._unmodified=!1,this._setZoom(e),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(t){this._zoom=t,this.scale=this.zoomScale(t),this.tileZoom=Math.floor(t),this.zoomFraction=t-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const t=this._elevation;this._centerAltitude=t.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=t.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const e=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,o=0;for(let s=0;se.maxzoom&&(i=e.maxzoom);const s=this.locationCoordinate(this.center),a=this.center.lat,l=1<{const i=1/4e4,n=new t.MercatorCoordinate(e.x+i,e.y,e.z),r=new t.MercatorCoordinate(e.x,e.y+i,e.z),o=e.toLngLat(),s=n.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),p=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*p)*b/i},A=e=>{const i=_,n=x;return{aabb:t.tileAABB(this,l,0,0,0,e,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:e,fullyVisible:!1}},E=[];let S=[];const M=i,T=e.reparseOverscaled?n:i,I=t=>t*t,C=I((m-this._centerAltitude)*f),P=t=>{if(!this._elevation||!t.tileID||!o)return;const e=this._elevation.getMinMaxForTile(t.tileID),i=t.aabb;e?(i.min[2]=e.min,i.max[2]=e.max,i.center[2]=(i.min[2]+i.max[2])/2):(t.shouldSplit=L(t),t.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},L=e=>{if(e.zoom=.9)return!0}else if(r&&(s=I(e.aabb.distanceZ(g)*f)),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,e.zoom),n=w(new t.MercatorCoordinate((e.x+.5)/i,(e.y+.5)/i));l=n>.85?1:n}const c=i*i+o*o+s,h=I((1<{if(e*I(.707)0;){const n=E.pop(),s=n.x,a=n.y;let h=n.fullyVisible;if(!h){const t=n.aabb.intersects(p);if(0===t)continue;h=2===t}if(n.zoom!==M&&L(n))for(let e=0;e<4;e++){const i=(s<<1)+e%2,c=(a<<1)+(e>>1),p={aabb:o?n.aabb.quadrant(e):t.tileAABB(this,l,n.zoom+1,i,c,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:c,wrap:n.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};r&&!u&&(p.tileID=new t.OverscaledTileID(n.zoom+1===M?T:n.zoom+1,n.wrap,n.zoom+1,i,c),P(p)),E.push(p)}else{const r=n.zoom===M?T:n.zoom;if(e.minzoom&&e.minzoom>r)continue;const o=c[0]-(.5+s+(n.wrap<{const o=[0,0,0,1],s=[t.EXTENT,t.EXTENT,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());t.transformMat4$1(o,o,a),t.transformMat4$1(s,s,a);const l=t.getAABBPointSquareDist(o,s);if(0===l)return!0;let c=!1;const u=this._elevation;if(u&&l>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;e.isTerrainDEM||(o=u.getMinMaxForTile(r.tileID)),o||(o={min:x,max:_});const s=t.furthestTileCorner(this.rotation),a=[s[0]*t.EXTENT,s[1]*t.EXTENT,o.max];t.transformMat4(a,a,i),c=(1-a[1])*this.height*.5t.distanceSq-e.distanceSq)).map((t=>t.tileID))}resize(t,e){this.width=t,this.height=e,this.pixelsToGLUnits=[2/t,-2/e],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(e){const i=t.clamp(e.lat,-t.MAX_MERCATOR_LATITUDE,t.MAX_MERCATOR_LATITUDE),n=this.projection.project(e.lng,i);return new t.Point(n.x*this.worldSize,n.y*this.worldSize)}unproject(t){return this.projection.unproject(t.x/this.worldSize,t.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/t.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(e,i){let n,r;const o=this.centerPoint;if("globe"===this.projection.name){const t=this.worldSize;n=(i.x-o.x)/t,r=(i.y-o.y)/t}else{const t=this.pointCoordinate(i),e=this.pointCoordinate(o);n=t.x-e.x,r=t.y-e.y}const s=this.locationCoordinate(e);this.setLocation(new t.MercatorCoordinate(s.x-n,s.y-r))}setLocation(t){this.center=this.coordinateLocation(t),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(t){return this.projection.locationPoint(this,t)}locationPoint3D(t){return this.projection.locationPoint(this,t,!0)}pointLocation(t){return this.coordinateLocation(this.pointCoordinate(t))}pointLocation3D(t){return this.coordinateLocation(this.pointCoordinate3D(t))}locationCoordinate(e,i){const n=i?t.mercatorZfromAltitude(i,e.lat):void 0,r=this.projection.project(e.lng,e.lat);return new t.MercatorCoordinate(r.x,r.y,n)}coordinateLocation(t){return this.projection.unproject(t.x,t.y)}pointRayIntersection(e,i){const n=null!=i?i:this._centerAltitude,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.transformMat4$1(r,r,this.pixelMatrixInverse),t.transformMat4$1(o,o,this.pixelMatrixInverse);const s=o[3];t.scale$1(r,r,1/r[3]),t.scale$1(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(e){const i=[e.x,e.y,0,1],n=[e.x,e.y,1,1];return t.transformMat4$1(i,i,this.pixelMatrixInverse),t.transformMat4$1(n,n,this.pixelMatrixInverse),t.scale$1(i,i,1/i[3]),t.scale$1(n,n,1/n[3]),i[2]=t.mercatorZfromAltitude(i[2],this._center.lat)*this.worldSize,n[2]=t.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,t.scale$1(i,i,1/this.worldSize),t.scale$1(n,n,1/this.worldSize),new t.Ray([i[0],i[1],i[2]],t.normalize([],t.sub([],n,i)))}rayIntersectionCoordinate(e){const{p0:i,p1:n,t:r}=e,o=t.mercatorZfromAltitude(i[2],this._center.lat),s=t.mercatorZfromAltitude(n[2],this._center.lat);return new t.MercatorCoordinate(t.number(i[0],n[0],r)/this.worldSize,t.number(i[1],n[1],r)/this.worldSize,t.number(o,s,r))}pointCoordinate(t,e=this._centerAltitude){return this.projection.pointCoordinate(this,t.x,t.y,e)}pointCoordinate3D(e){if(!this.elevation)return this.pointCoordinate(e);let i=this.projection.pointCoordinate3D(this,e.x,e.y);if(i)return new t.MercatorCoordinate(i[0],i[1],i[2]);let n=0,r=this.horizonLineFromTop();if(e.y>r)return this.pointCoordinate(e);const o=.02*r,s=e.clone();for(let e=0;e<10&&r-n>o;e++){s.y=t.number(n,r,.66);const e=this.projection.pointCoordinate3D(this,s.x,s.y);e?(r=s.y,i=e):n=s.y}return i?new t.MercatorCoordinate(i[0],i[1],i[2]):this.pointCoordinate(e)}isPointAboveHorizon(t){return this.projection.isPointAboveHorizon(this,t)}isPointOnSurface(e){if(e.y<0||e.y>this.height||e.x<0||e.x>this.width)return!1;if(this.elevation||this.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(e);const i=this.pointCoordinate(e);return i.y>=0&&i.y<=1}_coordinatePoint(e,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(e,this._centerAltitude):this._centerAltitude,r=[e.x*this.worldSize,e.y*this.worldSize,n+e.toAltitude(),1];return t.transformMat4$1(r,r,this.pixelMatrix),r[3]>0?new t.Point(r[0]/r[3],r[1]/r[3]):new t.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:e,left:i}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,o=this.pointLocation3D(new t.Point(i,e)),s=this.pointLocation3D(new t.Point(r,e)),a=this.pointLocation3D(new t.Point(r,n)),l=this.pointLocation3D(new t.Point(i,n));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),p=Math.max(o.lat,s.lat,a.lat,l.lat);const d=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(e,i,n,r,o)=>{const s=(e+n)/2,a=(i+r)/2,l=new t.Point(s,a),{lng:g,lat:y}=this.pointLocation3D(l),v=Math.max(0,c-g,h-y,g-u,y-p);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,y),p=Math.max(p,y),(od)&&(m(e,i,s,a,o+1),m(s,a,n,r,o+1))};if(m(i,e,r,e,1),m(r,e,r,n,1),m(r,n,i,n,1),m(i,n,i,e,1),"globe"===this.projection.name){const[e,i]=t.polesInViewport(this);e?(p=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new t.LngLatBounds(new t.LngLat(c,h),new t.LngLat(u,p))}_getBoundsRectangular(e,i){const{top:n,left:r}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new t.Point(r,n),l=new t.Point(s,n),c=new t.Point(s,o),u=new t.Point(r,o);let h=this.pointCoordinate(a,e),p=this.pointCoordinate(l,e);const d=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(t,e)=>(e.y-t.y)/(e.x-t.x);return h.y>1&&p.y>=0?h=new t.MercatorCoordinate((1-f.y)/m(f,h)+f.x,1):h.y<0&&p.y<=1&&(h=new t.MercatorCoordinate(-f.y/m(f,h)+f.x,0)),p.y>1&&h.y>=0?p=new t.MercatorCoordinate((1-d.y)/m(d,p)+d.x,1):p.y<0&&h.y<=1&&(p=new t.MercatorCoordinate(-d.y/m(d,p)+d.x,0)),(new t.LngLatBounds).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(p)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(d))}_getBoundsRectangularTerrain(){const t=this.elevation;if(!t.visibleDemTiles.length||t.isUsingMockSource())return this._getBoundsRectangular(0,0);const e=t.visibleDemTiles.reduce(((t,e)=>{if(e.dem){const i=e.dem.tree;t.min=Math.min(t.min,i.minimums[0]),t.max=Math.max(t.max,i.maximums[0])}return t}),{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(e.min*t.exaggeration(),e.max*t.exaggeration())}getBounds(){return"mercator"===this.projection.name||"equirectangular"===this.projection.name?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(t=!0){const e=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,i=this.height/2-e*(1-this._horizonShift);return t?Math.max(0,i):i}getMaxBounds(){return this.maxBounds}setMaxBounds(e){this.maxBounds=e,this.minLat=-t.MAX_MERCATOR_LATITUDE,this.maxLat=t.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,e&&(this.minLat=e.getSouth(),this.maxLat=e.getNorth(),this.minLng=e.getWest(),this.maxLng=e.getEast(),this.maxLngh&&(a=h-c),h-ue&&(s=e-l),e-t.5?x-1:x,b>.5?b-1:b,0]),this.alignedProjMatrix=w,a=t.create(),t.scale(a,a,[this.width/2,-this.height/2,1]),t.translate(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=t.create(),t.scale(a,a,[1,-1,1]),t.translate(a,a,[-1,-1,0]),t.scale(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a,this.pixelMatrix=t.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},a=t.invert(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=a,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=t.calculateGlobeMatrix(this);const e=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=t.transformMat4(e,e,o),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=a;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const e=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,o=[e,e,i];t.scale$2(o,o,r),t.scale$2(n,n,-1),t.multiply$2(n,n,o);const s=t.create();t.translate(s,s,n),t.scale(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(e,i,r)}_computeCameraPosition(t){const e=(t=t||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),n=this.point,r=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*e-t/this.worldSize*this._centerAltitude;return[n.x/this.worldSize-i[0]*r,n.y/this.worldSize-i[1]*r,t/this.worldSize*this._centerAltitude-i[2]*r]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(e){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=e[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(o=Math.min((i-n)/r,1)),this._camera.position=t.scaleAndAdd([],this._camera.position,e,o),this._updateStateFromCamera()}_updateStateFromCamera(){const e=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),o=t.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(t.degToRad(this._maxPitch)),a=Math.max((e[2]-o)/Math.cos(n),s),l=this._zoomFromMercatorZ(a);t.scaleAndAdd(e,e,i,a),this._pitch=t.clamp(n,t.degToRad(this.minPitch),t.degToRad(this.maxPitch)),this.angle=t.wrap(r,-Math.PI,Math.PI),this._setZoom(t.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new t.MercatorCoordinate(e[0],e[1],e[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(t){return Math.pow(2,t)*this.tileSize}_mercatorZfromZoom(t){return this.cameraToCenterDistance/this._worldSizeFromZoom(t)}_minimumHeightOverTerrain(){const t=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(t)}_zoomFromMercatorZ(t){return this.scaleZoom(this.cameraToCenterDistance/(t*this.tileSize))}zoomFromMercatorZAdjusted(e){let i=0,n=t.GLOBE_ZOOM_THRESHOLD_MAX,r=0,o=1/0;for(;n-i>1e-6&&n>i;){const t=i+.5*(n-i),s=this.tileSize*Math.pow(2,t),a=this.getCameraToCenterDistance(this.projection,t,s),l=this.scaleZoom(a/(e*this.tileSize)),c=Math.abs(t-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+t.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new t.Point(0,0),new t.Point(this.width,this.height))}zoomDeltaToMovement(e,i){const n=t.length(t.sub([],this._camera.position,e)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const e=function([e,i,n],r){const o=[e,i,n,1];t.transformMat4$1(o,o,r);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new t.Point(e[0],e[1])}{const e=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.Point(0,e))}}getCameraToCenterDistance(t,e=this.zoom,i=this.worldSize){const n=Wn(t,e,this.width,this.height,1024),r=t.pixelSpaceConversion(this.center.lat,i,n);return.5/Math.tan(.5*this._fov)*this.height*r}getWorldToCameraMatrix(){const e=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&t.multiply(e,e,this.globeMatrix),e}}function Qn(t,e){let i=!1,n=null;const r=()=>{n=null,i&&(t(),n=setTimeout(r,e),i=!1)};return()=>(i=!0,n||r(),n)}class Jn{constructor(e){this._hashName=e&&encodeURIComponent(e),t.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Qn(this._updateHashUnthrottled.bind(this),300)}addTo(e){return this._map=e,t.window.addEventListener("hashchange",this._onHashChange,!1),e.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),t.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const e=this._map;if(!e)return"";const i=Kn(e);if(this._hashName){const e=this._hashName;let n=!1;const r=t.window.location.hash.slice(1).split("&").map((t=>{const r=t.split("=")[0];return r===e?(n=!0,`${r}=${i}`):t})).filter((t=>t));return n||r.push(`${e}=${i}`),`#${r.join("&")}`}return`#${i}`}_getCurrentHash(){const e=t.window.location.hash.replace("#","");if(this._hashName){let t;return e.split("&").map((t=>t.split("="))).forEach((e=>{e[0]===this._hashName&&(t=e)})),(t&&t[1]||"").split("/")}return e.split("/")}_onHashChange(){const t=this._map;if(!t)return!1;const e=this._getCurrentHash();if(e.length>=3&&!e.some((t=>isNaN(t)))){const i=t.dragRotate.isEnabled()&&t.touchZoomRotate.isEnabled()?+(e[3]||0):t.getBearing();return t.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:i,pitch:+(e[4]||0)}),!0}return!1}_updateHashUnthrottled(){const e=t.window.location.href.replace(/(#.+)?$/,this.getHashString());t.window.history.replaceState(t.window.history.state,null,e)}}function Kn(t,e){const i=t.getCenter(),n=Math.round(100*t.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=t.getBearing(),c=t.getPitch();let u=e?`/${s}/${a}/${n}`:`${n}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const $n={linearity:.3,easing:t.bezier(0,0,.3,1)},tr=t.extend({deceleration:2500,maxSpeed:1400},$n),er=t.extend({deceleration:20,maxSpeed:1400},$n),ir=t.extend({deceleration:1e3,maxSpeed:360},$n),nr=t.extend({deceleration:1e3,maxSpeed:90},$n);class rr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:t.exported.now(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,i=t.exported.now();for(;e.length>0&&i-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._map._prefersReducedMotion())return;if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,pan:new t.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=sr(i.pan.mag(),n,t.extend({},tr,e||{}));r.offset=i.pan.mult(o.amount/i.pan.mag()),r.center=this._map.transform.center,or(r,o)}if(i.zoom){const t=sr(i.zoom,n,er);r.zoom=this._map.transform.zoom+t.amount,or(r,t)}if(i.bearing){const e=sr(i.bearing,n,ir);r.bearing=this._map.transform.bearing+t.clamp(e.amount,-179,179),or(r,e)}if(i.pitch){const t=sr(i.pitch,n,nr);r.pitch=this._map.transform.pitch+t.amount,or(r,t)}if(r.zoom||r.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;r.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),r.noMoveStart=!0,r}}function or(t,e){(!t.duration||t.durationi.unproject(t))),a=o.reduce(((t,e,i,n)=>t.add(e.div(n.length))),new t.Point(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class cr extends t.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class ur{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._mousedownPos=void 0}wheel(t){return this._firePreventable(new cr(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ar(t.type,this._map,t))}mouseup(t){this._map.fire(new ar(t.type,this._map,t))}preclick(e){const i=t.extend({},e);i.type="preclick",this._map.fire(new ar(i.type,this._map,i))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||(this.preclick(t),this._map.fire(new ar(t.type,this._map,t)))}dblclick(t){return this._firePreventable(new ar(t.type,this._map,t))}mouseover(t){this._map.fire(new ar(t.type,this._map,t))}mouseout(t){this._map.fire(new ar(t.type,this._map,t))}touchstart(t){return this._firePreventable(new lr(t.type,this._map,t))}touchmove(t){this._map.fire(new lr(t.type,this._map,t))}touchend(t){this._map.fire(new lr(t.type,this._map,t))}touchcancel(t){this._map.fire(new lr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class hr{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(t){this._map.fire(new ar(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ar("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._map.fire(new ar(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pr{constructor(t,e){this._map=t,this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(u(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e,n=this._startPos,r=this._lastPos;if(!n||!r||r.equals(i)||!this._box&&i.dist(n){this._box&&(this._box.style.transform=`translate(${s}px,${l}px)`,this._box.style.width=a-s+"px",this._box.style.height=c-l+"px")}))}mouseupWindow(e,i){if(!this._active)return;const n=this._startPos,r=i;if(n&&0===e.button){if(this.reset(),d(),n.x!==r.x||n.y!==r.y)return this._map.fire(new t.Event("boxzoomend",{originalEvent:e})),{cameraAnimation:t=>t.fitScreenCoordinates(n,r,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",e)}}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.Event(e,{originalEvent:i}))}}function dr(t,e){const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.Point(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=dr(n,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const n=dr(i,e);for(const t in this.touches){const e=n[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class mr{constructor(t){this.singleTap=new fr(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const n=this.singleTap.touchend(t,e,i);if(n){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class gr{constructor(){this._zoomIn=new mr({numTouches:1,numTaps:2}),this._zoomOut=new mr({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,e,i){const n=this._zoomIn.touchend(t,e,i),r=this._zoomOut.touchend(t,e,i);return n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()+1,around:e.unproject(n)},{originalEvent:t})}):r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:e.getZoom()-1,around:e.unproject(r)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const yr={0:1,2:2};class vr{constructor(t){this.reset(),this._clickTolerance=t.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(t,e){return!1}_move(t,e){return{}}mousedown(t,e){if(this._lastPoint)return;const i=g(t);this._correctButton(t,i)&&(this._lastPoint=e,this._eventButton=i)}mousemoveWindow(t,e){const i=this._lastPoint;if(i)if(t.preventDefault(),null!=this._eventButton&&function(t,e){const i=yr[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton))this.reset();else if(this._moved||!(e.dist(i)0&&(this._active=!0);const r=dr(n,i),o=new t.Point(0,0),s=new t.Point(0,0);let a=0;for(const t in r){const e=r[t],i=this._touches[t];i&&(o._add(e),s._add(e.sub(i)),a++,r[t]=e)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")}),500)}}class Ar{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(t){}_move(t,e,i){return{}}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){const n=this._firstTwoTouches;if(!n)return;t.preventDefault();const[r,o]=n,s=Er(i,e,r),a=Er(i,e,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[n,r]=this._firstTwoTouches,o=Er(i,e,n),s=Er(i,e,r);o&&s||(this._active&&d(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Er(t,e,i){for(let n=0;nMath.abs(t.x)}class Pr extends Ar{constructor(t){super(),this._map=t}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(t){this._lastPoints=t,Cr(t[0].sub(t[1]))&&(this._valid=!1)}_move(e,i,n){const r=this._lastPoints;if(!r)return;const o=e[0].sub(r[0]),s=e[1].sub(r[1]);return this._map._cooperativeGestures&&!t.isFullscreen()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,n.timeStamp),!this._valid)?void 0:(this._lastPoints=e,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const n=t.mag()>=2,r=e.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=t.y>0==e.y>0;return Cr(t)&&Cr(e)&&o}}const Lr={panStep:100,bearingStep:15,pitchStep:10};class Dr{constructor(){const t=Lr;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,n=0,r=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),r=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),r=1);break;case 38:t.shiftKey?n=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?n=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:Rr,zoom:e?Math.round(a)+e*(t.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Rr(t){return t*(2-t)}const Or=4.000244140625;class kr{constructor(e,i){this._map=e,this._el=e.getCanvasContainer(),this._handler=i,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,t.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(e){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(e.ctrlKey||e.metaKey||this.isZooming()||t.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let i=e.deltaMode===t.window.WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const n=t.exported.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%Or==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=i,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*i)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,i+=this._lastValue)),e.shiftKey&&i&&(i/=4),this._type&&(this._lastWheelEvent=e,this._delta-=i,this._active||this._start(e)),e.preventDefault()}_onTimeout(t){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)}_start(t){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const e=f(this._el,t);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:e,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._map.transform;"wheel"===this._type&&e.projection.wrap&&(e._center.lng>=180||e._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const i=()=>e._terrainEnabled()&&this._aroundCoord?e.computeZoomRelativeTo(this._aroundCoord):e.zoom;if(0!==this._delta){const t="wheel"===this._type&&Math.abs(this._delta)>Or?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*t)));this._delta<0&&0!==n&&(n=1/n);const r=i(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?e.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(e.maxZoom,Math.max(e.minZoom,e.scaleZoom(s*n))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const e=Math.min((t.exported.now()-this._lastWheelEventTime)/200,1),i=o(e);s=t.number(r,n,i),e<1?this._frameId||(this._frameId=!0):a=!0}else s=n,a=!0;return this._active=!0,a&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout}),200)),{noInertia:!0,needsRenderFrame:!a,zoomDelta:s-i(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.ease;if(this._prevEase){const e=this._prevEase,n=(t.exported.now()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.bezier(o,s,.25,1)}return this._prevEase={start:t.exported.now(),duration:e,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(t.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout((()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")}),200)}}class Nr{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Br{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:i.getZoom()+(t.shiftKey?-1:1),around:i.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class zr{constructor(){this._tap=new mr({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(t,e,i){this._swipePoint||(this._tapTime&&t.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?i.length>0&&(this._swipePoint=e[0],this._swipeTouch=i[0].identifier):this._tap.touchstart(t,e,i))}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=e[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,t.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){this._tapTime?this._swipePoint&&0===i.length&&this.reset():this._tap.touchend(t,e,i)&&(this._tapTime=t.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fr{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Vr{constructor(t,e,i){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=e,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Ur{constructor(t,e,i,n){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Gr=t=>t.zoom||t.drag||t.pitch||t.rotate;class jr extends t.Event{}class Hr{constructor(){this.constants=[1,1,.01],this.radius=0}setup(e,i){const n=t.sub([],i,e);this.radius=t.length(n[2]<0?t.div([],n,this.constants):[n[0],n[1],0])}projectRay(e){t.div(e,e,this.constants),t.normalize(e,e),t.mul$1(e,e,this.constants);const i=t.scale$2([],e,this.radius);if(i[2]>0){const e=t.scale$2([],[0,0,1],t.dot(i,[0,0,1])),n=t.scale$2([],t.normalize([],[i[0],i[1],0]),this.radius),r=t.add([],i,t.scale$2([],t.sub([],t.add([],n,e),i),2));i[0]=r[0],i[1]=r[1]}return i}}function Wr(t){return t.panDelta&&t.panDelta.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta}class qr{constructor(e,i){this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new rr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Hr,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),t.bindAll(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[t.window.document,"mousemove",{capture:!0}],[t.window.document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[t.window,"blur",void 0]];for(const[e,i,n]of this._listeners)e.addEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,n)}destroy(){for(const[e,i,n]of this._listeners)e.removeEventListener(i,e===t.window.document?this.handleWindowEvent:this.handleEvent,n)}_addDefaultHandlers(t){const e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new ur(e,t));const n=e.boxZoom=new pr(e,t);this._add("boxZoom",n);const r=new gr,o=new Br;e.doubleClickZoom=new Nr(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new zr;this._add("tapDragZoom",s);const a=e.touchPitch=new Pr(e);this._add("touchPitch",a);const l=new xr(t),c=new br(t);e.dragRotate=new Vr(t,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new _r(t),h=new wr(e,t);e.dragPan=new Fr(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const p=new Ir,d=new Mr;e.touchZoomRotate=new Ur(i,d,p,s),this._add("touchRotate",p,["touchPan","touchZoom"]),this._add("touchZoom",d,["touchPan","touchRotate"]),this._add("blockableMapEvent",new hr(e));const f=e.scrollZoom=new kr(e,this);this._add("scrollZoom",f,["mousePan"]);const m=e.keyboard=new Dr;this._add("keyboard",m);for(const i of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])t.interactive&&t[i]&&e[i].enable(t[i])}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Gr(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(t,e,i){for(const n in t)if(n!==i&&(!e||e.indexOf(n)<0))return!0;return!1}handleWindowEvent(t){this.handleEvent(t,`${t.type}Window`)}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}handleEvent(t,e){this._updatingCamera=!0;const i="renderFrame"===t.type,n=i?void 0:t,r={needsRenderFrame:!1},o={},s={},a=t.touches?this._getMapTouches(t.touches):void 0,l=a?m(this._el,a):i?void 0:f(this._el,t);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[e||t.type]&&(h=c[e||t.type](t,l,a),this.mergeHandlerResult(r,o,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const t in this._previousActiveHandlers)s[t]||(c[t]=n);this._previousActiveHandlers=s,(Object.keys(c).length||Wr(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||Wr(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.extend(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.Point(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.aroundCoord&&(e.aroundCoord=r.aroundCoord),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.extend(i,o),t.extend(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,i,n){const r=this._map,o=r.transform,s=t=>[t.x,t.y,t.z];if((t=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!Wr(e)){const t=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",t!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&r._stop(!0),!Wr(e))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:p,pinchAround:d}=e;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==d&&(h=d),(l||(t=>i[t]&&!this._eventsInProgress[t])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=e[0]-t[0],f[1]=e[1]-t[1]}else{const e=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*t.mercatorScale(t.latFromMercatorY(e.y))*i,f[1]=-a.y*t.mercatorScale(o.center.lat)*i}else{const t=o.pointCoordinate(h.sub(a));e&&t&&(f[0]=t.x-e.x,f[1]=t.y-e.y)}}const m=o.zoom,g=[0,0,0];if(l){const e=s(p||o.pointCoordinate3D(h)),i={dir:t.normalize([],t.sub([],e,o._camera.position))};if(i.dir[2]<0){const n=o.zoomDeltaToMovement(e,l);t.scale$2(g,i.dir,n)}}const y=t.add(f,f,g);o._translateCameraConstrained(y),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(i,n,!0)}_fireEvents(e,i,n){const r=Gr(this._eventsInProgress),o=Gr(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const t in s)this._fireEvent(t,s[t]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const a={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:n}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||n,a[`${t}end`]=l)}for(const t in a)this._fireEvent(t,a[t]);const c=Gr(this._eventsInProgress);if(n&&(r||o)&&!c){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new jr("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Xr="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Zr extends t.Evented{constructor(e,i){super(),this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this._respectPrefersReducedMotion=!1!==i.respectPrefersReducedMotion,t.bindAll(["_renderFrameCallback"],this)}getCenter(){return new t.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}panBy(e,i,n){return e=t.Point.convert(e).mult(-1),this.panTo(this.transform.center,t.extend({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.extend({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(e,i,n){return this.easeTo(t.extend({zoom:e},i),n)}zoomIn(t,e){return this.zoomTo(this.getZoom()+1,t,e),this}zoomOut(t,e){return this.zoomTo(this.getZoom()-1,t,e),this}getBearing(){return this.transform.bearing}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(e,i,n){return this.easeTo(t.extend({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.extend({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.extend({bearing:0,pitch:0,duration:1e3},e),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())t.aspect?i/(2*Math.tan(.5*t.fovX)*t.aspect):n/(2*Math.tan(.5*t.fovY)*t.aspect)}_cameraForBoundsOnGlobe(e,i,n,r,o,s){const a=e.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=t.LngLat.convert(i),u=t.LngLat.convert(n),h=.5*(c.lat+u.lat),p=.5*(c.lng+u.lng),d=t.latLngToECEF(h,p),f=t.normalize([],d),m=t.normalize([],t.cross([],f,[0,1,0])),g=t.cross([],m,f),y=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,f[0],f[1],f[2],0,0,0,0,1],v=[d,t.latLngToECEF(c.lat,c.lng),t.latLngToECEF(u.lat,c.lng),t.latLngToECEF(u.lat,u.lng),t.latLngToECEF(c.lat,u.lng),t.latLngToECEF(h,c.lng),t.latLngToECEF(h,u.lng),t.latLngToECEF(c.lat,p),t.latLngToECEF(u.lat,p)];let _=t.Aabb.fromPoints(v.map((e=>[t.dot(m,e),t.dot(g,e),t.dot(f,e)])));const x=t.transformMat4([],_.center,y);0===t.squaredLength(x)&&t.set(x,0,0,1),t.normalize(x,x),t.scale$2(x,x,t.GLOBE_RADIUS),a.center=t.ecefToLatLng(x);const b=a.getWorldToCameraMatrix(),w=t.invert(new Float64Array(16),b);_=t.Aabb.applyTransform(_,t.multiply([],b,y)),t.transformMat4(x,x,b);const A=.5*(_.max[2]-_.min[2]),E=this._minimumAABBFrustumDistance(a,_),S=t.scale$2([],[0,0,1],A),M=t.add(S,x,S),T=E+(0===a.pitch?0:t.distance(x,M)),I=a.globeCenterInViewSpace,C=t.sub([],x,[I[0],I[1],I[2]]);t.normalize(C,C),t.scale$2(C,C,T);const P=t.add([],x,C);t.transformMat4(P,P,w);const L=t.earthRadius/t.GLOBE_RADIUS,D=t.length(P),R=t.mercatorZfromAltitude(Math.max(D*L-t.earthRadius,Number.EPSILON),0),O=Math.min(a.zoomFromMercatorZAdjusted(R),l.maxZoom);return O>.5*(t.GLOBE_ZOOM_THRESHOLD_MIN+t.GLOBE_ZOOM_THRESHOLD_MAX)?(a.setProjection({name:"mercator"}),a.zoom=O,this._cameraForBounds(a,i,n,r,o,s)):{center:a.center,zoom:O,bearing:r,pitch:o}}queryTerrainElevation(e,i){const n=this.transform.elevation;return n?(i=t.extend({},{exaggerated:!0},i),n.getAtPoint(t.MercatorCoordinate.fromLngLat(e),null,i.exaggerated)):null}_cameraForBounds(e,i,n,r,o,s){if("globe"===e.projection.name)return this._cameraForBoundsOnGlobe(e,i,n,r,o,s);const a=e.clone(),l=this._extendCameraOptions(s),c=a.padding;a.bearing=r,a.pitch=o;const u=t.LngLat.convert(i),h=t.LngLat.convert(n),p=new t.LngLat(u.lng,h.lat),d=new t.LngLat(h.lng,u.lat),f=a.project(u),m=a.project(h),g=this.queryTerrainElevation(u),y=this.queryTerrainElevation(h),v=this.queryTerrainElevation(p),_=this.queryTerrainElevation(d),x=[[f.x,f.y,Math.min(g||0,y||0,v||0,_||0)],[m.x,m.y,Math.max(g||0,y||0,v||0,_||0)]];let b=t.Aabb.fromPoints(x);const w=a.getWorldToCameraMatrix(),A=t.invert(new Float64Array(16),w);b=t.Aabb.applyTransform(b,w);const E=t.sub([],b.max,b.min),S=c.left||0,M=c.right||0,T=c.bottom||0,I=c.top||0,{left:C,right:P,top:L,bottom:D}=l.padding,R=.5*(S+M),O=.5*(I+T),k=Math.min(a.scaleZoom(a.scale*Math.min((a.width-(S+M+C+P))/E[0],(a.height-(T+I+D+L))/E[1])),l.maxZoom),N=a.scale/a.zoomScale(k);b=new t.Aabb([b.min[0]-(C+R)*N,b.min[1]-(D+O)*N,b.min[2]],[b.max[0]+(P+R)*N,b.max[1]+(L+O)*N,b.max[2]]);const B=.5*E[2],z=this._minimumAABBFrustumDistance(a,b),F=[0,0,1,0];t.transformMat4$1(F,F,w),t.normalize$2(F,F);const V=t.scale$2([],F,z+B),U=t.add([],b.center,V),G=("number"==typeof l.offset.x&&"number"==typeof l.offset.y?new t.Point(l.offset.x,l.offset.y):t.Point.convert(l.offset)).rotate(-t.degToRad(r));b.center[0]-=G.x*N,b.center[1]+=G.y*N,t.transformMat4(b.center,b.center,A),t.transformMat4(U,U,A);const j=[b.center[0],b.center[1],U[2]*a.pixelsPerMeter];t.scale$2(j,j,1/a.worldSize);const H=t.lngFromMercatorX(j[0]),W=t.latFromMercatorY(j[1]),q=Math.min(a._zoomFromMercatorZ(j[2]),l.maxZoom),X=new t.LngLat(H,W);return a.mercatorFromTransition&&q<.5*(t.GLOBE_ZOOM_THRESHOLD_MIN+t.GLOBE_ZOOM_THRESHOLD_MAX)?(a.setProjection({name:"globe"}),a.zoom=q,this._cameraForBounds(a,i,n,r,o,s)):{center:X,zoom:q,bearing:r,pitch:o}}fitBounds(t,e,i){const n=this.cameraForBounds(t,e);return this._fitInternal(n,e,i)}fitScreenCoordinates(e,i,n,r,o){const s=t.Point.convert(e),a=t.Point.convert(i),l=new t.Point(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new t.Point(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),p=this.transform.pointLocation3D(new t.Point(l.x,c.y)),d=this.transform.pointLocation3D(new t.Point(c.x,l.y)),f=[Math.min(u.lng,h.lng,p.lng,d.lng),Math.min(u.lat,h.lat,p.lat,d.lat)],m=[Math.max(u.lng,h.lng,p.lng,d.lng),Math.max(u.lat,h.lat,p.lat,d.lat)],g=r&&r.pitch?r.pitch:this.getPitch(),y=this._cameraForBounds(this.transform,f,m,n,g,r);return this._fitInternal(y,r,o)}_fitInternal(e,i,n){return e?(delete(i=t.extend(e,i)).padding,i.linear?this.easeTo(i,n):this.flyTo(i,n)):this}jumpTo(e,i){this.stop();const n=e.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,s=!1;return"zoom"in e&&n.zoom!==+e.zoom&&(r=!0,n.zoom=+e.zoom),void 0!==e.center&&(n.center=t.LngLat.convert(e.center)),"bearing"in e&&n.bearing!==+e.bearing&&(o=!0,n.bearing=+e.bearing),"pitch"in e&&n.pitch!==+e.pitch&&(s=!0,n.pitch=+e.pitch),null==e.padding||n.isPaddingEqual(e.padding)||(n.padding=e.padding),e.preloadOnly?(this._preloadTiles(n),this):(this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),r&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),o&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),s&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||t.warnOnce(Xr),this.transform.getFreeCameraOptions()}setFreeCameraOptions(e,i){const n=this.transform;if(!n.projection.supportsFreeCamera)return t.warnOnce(Xr),this;this.stop();const r=n.zoom,o=n.pitch,s=n.bearing;n.setFreeCameraOptions(e);const a=r!==n.zoom,l=o!==n.pitch,c=s!==n.bearing;return this.fire(new t.Event("movestart",i)).fire(new t.Event("move",i)),a&&this.fire(new t.Event("zoomstart",i)).fire(new t.Event("zoom",i)).fire(new t.Event("zoomend",i)),c&&this.fire(new t.Event("rotatestart",i)).fire(new t.Event("rotate",i)).fire(new t.Event("rotateend",i)),l&&this.fire(new t.Event("pitchstart",i)).fire(new t.Event("pitch",i)).fire(new t.Event("pitchend",i)),this.fire(new t.Event("moveend",i)),this}easeTo(e,i){this._stop(!1,e.easeId),(!1===(e=t.extend({offset:[0,0],duration:500,easing:t.ease},e)).animate||this._prefersReducedMotion(e))&&(e.duration=0);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?+e.zoom:r,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:n.padding,p=t.Point.convert(e.offset);let d,f,m;if("globe"===n.projection.name){const i=t.MercatorCoordinate.fromLngLat(n.center),r=p.rotate(-n.angle);i.x+=r.x/n.worldSize,i.y+=r.y/n.worldSize;const o=i.toLngLat(),s=t.LngLat.convert(e.center||o);this._normalizeCenter(s),d=n.centerPoint.add(r),f=new t.Point(i.x,i.y).mult(n.worldSize),m=new t.Point(t.mercatorXfromLng(s.lng),t.mercatorYfromLat(s.lat)).mult(n.worldSize).sub(f)}else{d=n.centerPoint.add(p);const i=n.pointLocation(d),r=t.LngLat.convert(e.center||i);this._normalizeCenter(r),f=n.project(i),m=n.project(r).sub(f)}const g=n.zoomScale(l-r);let y,v;e.around&&(y=t.LngLat.convert(e.around),v=n.locationPoint(y));const _=this._zooming||l!==r,x=this._rotating||o!==c,b=this._pitching||u!==s,w=!n.isPaddingEqual(h),A=n=>A=>{if(_&&(n.zoom=t.number(r,l,A)),x&&(n.bearing=t.number(o,c,A)),b&&(n.pitch=t.number(s,u,A)),w&&(n.interpolatePadding(a,h,A),d=n.centerPoint.add(p)),y)n.setLocationAtPoint(y,v);else{const t=n.zoomScale(n.zoom-r),e=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(e,1-A),o=n.unproject(f.add(m.mult(A*i)).mult(t));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,d)}return e.preloadOnly||this._fireMoveEvents(i),n};if(e.preloadOnly){const t=this._emulate(A,e.duration,n);return this._preloadTiles(t),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=_,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=e.easeId,this._prepareEase(i,e.noMoveStart,E),this._ease(A(n),(t=>{n.recenterOnTerrain(),this._afterEase(i,t)}),e),this}_prepareEase(e,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",i||n.moving||this.fire(new t.Event("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.Event("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.Event("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.Event("pitchstart",e))}_fireMoveEvents(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))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new t.Event("zoomend",e)),r&&this.fire(new t.Event("rotateend",e)),o&&this.fire(new t.Event("pitchend",e)),this.fire(new t.Event("moveend",e))}flyTo(e,i){if(this._prefersReducedMotion(e)){const n=t.pick(e,["center","zoom","bearing","pitch","around"]);return this.jumpTo(n,i)}this.stop(),e=t.extend({offset:[0,0],speed:1.2,curve:1.42,easing:t.ease},e);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in e?t.clamp(+e.zoom,n.minZoom,n.maxZoom):r,c="bearing"in e?this._normalizeBearing(e.bearing,o):o,u="pitch"in e?+e.pitch:s,h="padding"in e?e.padding:n.padding,p=n.zoomScale(l-r),d=t.Point.convert(e.offset);let f=n.centerPoint.add(d);const m=n.pointLocation(f),g=t.LngLat.convert(e.center||m);this._normalizeCenter(g);const y=n.project(m),v=n.project(g).sub(y);let _=e.curve;const x=Math.max(n.width,n.height),b=x/p,w=v.mag();if("minZoom"in e){const i=t.clamp(Math.min(e.minZoom,r,l),n.minZoom,n.maxZoom),o=x/n.zoomScale(i-r);_=Math.sqrt(o/w*2)}const A=_*_;function E(t){const e=(b*b-x*x+(t?-1:1)*A*A*w*w)/(2*(t?b:x)*A*w);return Math.log(Math.sqrt(e*e+1)-e)}function S(t){return(Math.exp(t)-Math.exp(-t))/2}function M(t){return(Math.exp(t)+Math.exp(-t))/2}const T=E(0);let I=function(t){return M(T)/M(T+_*t)},C=function(t){return x*((M(T)*(S(e=T+_*t)/M(e))-S(T))/A)/w;var e},P=(E(1)-T)/_;if(Math.abs(w)<1e-6||!isFinite(P)){if(Math.abs(x-b)<1e-6)return this.easeTo(e,i);const t=be.maxDuration&&(e.duration=0);const L=o!==c,D=u!==s,R=!n.isPaddingEqual(h),O=n=>p=>{const m=p*P,_=1/I(m);n.zoom=1===p?l:r+n.scaleZoom(_),L&&(n.bearing=t.number(o,c,p)),D&&(n.pitch=t.number(s,u,p)),R&&(n.interpolatePadding(a,h,p),f=n.centerPoint.add(d));const x=1===p?g:n.unproject(y.add(v.mult(C(m))).mult(_));return n.setLocationAtPoint(n.renderWorldCopies?x.wrap():x,f),n._updateCameraOnTerrain(),e.preloadOnly||this._fireMoveEvents(i),n};if(e.preloadOnly){const t=this._emulate(O,e.duration,n);return this._preloadTiles(t),this}return this._zooming=!0,this._rotating=L,this._pitching=D,this._padding=R,this._prepareEase(i,!1),this._ease(O(n),(()=>this._afterEase(i)),e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const t=this._onEaseEnd;this._onEaseEnd=void 0,t.call(this,e)}if(!t){const t=this.handlers;t&&t.stop(!1)}return this}_ease(e,i,n){!1===n.animate||0===n.duration?(e(1),i()):(this._easeStart=t.exported.now(),this._easeOptions=n,this._onEaseFrame=e,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const e=Math.min((t.exported.now()-this._easeStart)/this._easeOptions.duration,1),i=this._onEaseFrame;i&&i(this._easeOptions.easing(e)),e<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(e,i){e=t.wrap(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(e){return this._respectPrefersReducedMotion&&t.exported.prefersReducedMotion&&!(e&&e.essential)}_emulate(t,e,i){const n=Math.ceil(15*e/1e3),r=[],o=t(i.clone());for(let t=0;t<=n;t++){const e=o(t/n);r.push(e.clone())}return r}}class Yr{constructor(e={}){this.options=e,t.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(t){const e=this.options&&this.options.compact;return this._map=t,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),e&&this._container.classList.add("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}onRemove(){this._container.remove(),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}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.setAttribute("aria-label",i),t.removeAttribute("title"),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let e=this._editLink;e||(e=this._editLink=this._container.querySelector(".mapbox-improve-map"));const i=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||t.config.ACCESS_TOKEN}];if(e){const n=i.reduce(((t,e,n)=>(e.value&&(t+=`${e.key}=${e.value}${nt.length-e.length)),t=t.filter(((e,i)=>{for(let n=i+1;n=0)return!1;return!0})),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=[...this.options.customAttribution,...t]:t.unshift(this.options.customAttribution));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=i,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Qr{constructor(){t.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(t){this._map=t,this._container=o("div","mapboxgl-ctrl");const e=o("a","mapboxgl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://www.mapbox.com/",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}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(t){t&&"metadata"!==t.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const t=this._map.style._sourceCaches;if(0===Object.entries(t).length)return!0;for(const e in t){const i=t[e].getSource();if(i.hasOwnProperty("mapbox_logo")&&!i.mapbox_logo)return!1}return!0}_updateCompact(){const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<250?e.classList.add("mapboxgl-compact"):e.classList.remove("mapboxgl-compact")}}}class Jr{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Kr(e,i,n){if(e=new t.LngLat(e.lng,e.lat),i){const r=new t.LngLat(e.lng-360,e.lat),o=new t.LngLat(e.lng+360,e.lat),s=360*Math.ceil(Math.abs(e.lng-n.center.lng)/360),a=n.locationPoint(e).distSqr(i),l=i.x<0||i.y<0||i.x>n.width||i.y>n.height;n.locationPoint(r).distSqr(i)180;){const t=n.locationPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e}const $r={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%)"};class to extends t.Evented{constructor(e,i){if(super(),(e instanceof t.window.HTMLElement||i)&&(e=t.extend({element:e},i)),t.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&e.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=e&&e.occludedOpacity||.2,e&&e.element)this._element=e.element,this._offset=t.Point.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const i=41,n=27,r=s("svg",{display:"block",height:i*this._scale+"px",width:n*this._scale+"px",viewBox:`0 0 ${n} ${i}`},this._element),a=s("radialGradient",{id:"shadowGradient"},s("defs",{},r));s("stop",{offset:"10%","stop-opacity":.4},a),s("stop",{offset:"100%","stop-opacity":.05},a),s("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},r),s("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},r),s("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},r),s("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},r),this._offset=t.Point.convert(e&&e.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()}));const n=this._element.classList;for(const t in $r)n.remove(`mapboxgl-marker-anchor-${t}`);n.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(t){return t===this._map||(this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._updateMoving),t.on("moveend",this._update),t.on("remove",this._clearFadeTimer),t._addMarker(this),this.setDraggable(this._draggable),this._update(),t.on("click",this._onMapClick)),this}remove(){const t=this._map;return t&&(t.off("click",this._onMapClick),t.off("move",this._updateMoving),t.off("moveend",this._update),t.off("mousedown",this._addDragHandler),t.off("touchstart",this._addDragHandler),t.off("mouseup",this._onUp),t.off("touchend",this._onUp),t.off("mousemove",this._onMove),t.off("touchmove",this._onMove),t.off("remove",this._clearFadeTimer),t._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.LngLat.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,n=Math.sqrt(Math.pow(i,2)/2);t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[n,-1*(e-i+n)],"bottom-right":[-n,-1*(e-i+n)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,t._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(t){const e=t.code,i=t.charCode||t.keyCode;"Space"!==e&&"Enter"!==e&&32!==i&&13!==i||this.togglePopup()}_onMapClick(t){const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const t=this._popup;return t?(t.isOpen()?(t.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(t.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const t=this._map,e=this._pos;if(!t||!e)return!1;const i=t.unproject(e),n=t.getFreeCameraOptions();if(!n.position)return!1;const r=n.position.toLngLat();return r.distanceTo(i)<.9*r.distanceTo(this._lngLat)}_evaluateOpacity(){const e=this._map;if(!e)return;const i=this._pos;if(!i||i.x<0||i.x>e.transform.width||i.y<0||i.y>e.transform.height)return void this._clearFadeTimer();const n=e.unproject(i);let r;e._showingGlobe()&&t.isLngLatBehindGlobe(e.transform,this._lngLat)?r=0:(r=1-e._queryFogOpacity(n),e.transform._terrainEnabled()&&e.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",this._popup&&this._popup._setOpacity(r),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const t=this._pos;if(!t||!this._map)return;const e=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${t.x}px,${t.y}px)\n ${$r[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${e.x}px,${e.y}px)\n `}_calculateXYTransform(){const e=this._pos,i=this._map,n=this.getPitchAlignment();if(!i||!e||"map"!==n)return"";if(!i._showingGlobe()){const t=i.getPitch();return t?`rotateX(${t}deg)`:""}const r=t.radToDeg(t.globeTiltAtLngLat(i.transform,this._lngLat)),o=e.sub(t.globeCenterToScreenPoint(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=r/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const e=this._pos,i=this._map;if(!i||!e)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const e=i.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),r=i.project(new t.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(e);n=t.radToDeg(Math.atan2(r.y,r.x))-90}else n=-i.getBearing();else if("horizon"===r){const r=t.smoothstep(4,6,i.getZoom()),o=t.globeCenterToScreenPoint(i.transform);o.y+=r*i.transform.height;const s=e.sub(o),a=t.radToDeg(Math.atan2(s.y,s.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){t.window.cancelAnimationFrame(this._updateFrameId);const i=this._map;i&&(i.transform.renderWorldCopies&&(this._lngLat=Kr(this._lngLat,this._pos,i.transform)),this._pos=i.project(this._lngLat),!0===e?this._updateFrameId=t.window.requestAnimationFrame((()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())})):this._pos=this._pos.round(),i._requestDomTask((()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(i._showingGlobe()||i.getTerrain()||i.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))})))}getOffset(){return this._offset}setOffset(e){return this._offset=t.Point.convert(e),this._update(),this}_onMove(e){const i=this._map;if(!i)return;const n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const t=this._clickTolerance||i._clickTolerance;if(e.point.dist(n)=this._endTime)return this._end;const i=t.easeCubicInOut((e-this._startTime)/(this._endTime-this._startTime));return this._start*(1-i)+this._end*i}isEasing(t){return t>=this._startTime&&t<=this._endTime}jumpTo(t){this._startTime=-1/0,this._endTime=-1/0,this._start=t,this._end=t}easeTo(t,e,i){this._start=this.getValue(e),this._end=t,this._startTime=e,this._endTime=e+i}}const oo={"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","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},so={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},ao={showCompass:!0,showZoom:!0,visualizePitch:!1};class lo{constructor(e,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new xr({clickTolerance:e.dragRotate._mouseRotate._clickTolerance}),this.map=e,n&&(this.mousePitch=new br({clickTolerance:e.dragRotate._mousePitch._clickTolerance})),t.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchmove",this.touchmove),i.addEventListener("touchend",this.touchend),i.addEventListener("touchcancel",this.reset)}down(t,e){this.mouseRotate.mousedown(t,e),this.mousePitch&&this.mousePitch.mousedown(t,e),u()}move(t,e){const i=this.map,n=this.mouseRotate.mousemoveWindow(t,e),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(t,e),r=n&&n.pitchDelta;r&&i.setPitch(i.getPitch()+r)}}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart,{passive:!1}),t.removeEventListener("touchmove",this.touchmove),t.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),t.window.removeEventListener("mousemove",this.mousemove),t.window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(t.extend({},e,{ctrlKey:!0,preventDefault:()=>e.preventDefault()}),f(this.element,e)),t.window.addEventListener("mousemove",this.mousemove),t.window.addEventListener("mouseup",this.mouseup)}mousemove(t){this.move(t,f(this.element,t))}mouseup(t){this.mouseRotate.mouseupWindow(t),this.mousePitch&&this.mousePitch.mouseupWindow(t),this.offTemp()}touchstart(t){1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,t.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>t.preventDefault()},this._startPos))}touchmove(t){1!==t.targetTouches.length?this.reset():(this._lastPos=m(this.element,t.targetTouches)[0],this.move({preventDefault:()=>t.preventDefault()},this._lastPos))}touchend(t){0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)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>85)throw new Error("maxPitch must be less than or equal to 85");if(e.antialias&&t.isSafariWithAntialiasingBug(t.window)&&(e.antialias=!1,t.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Yn(e.minZoom,e.maxZoom,e.minPitch,e.maxPitch,e.renderWorldCopies),e),this._interactive=e.interactive,this._minTileCacheSize=e.minTileCacheSize,this._maxTileCacheSize=e.maxTileCacheSize,this._failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=e.preserveDrawingBuffer,this._antialias=e.antialias,this._useWebGL2=e.useWebGL2,this._trackResize=e.trackResize,this._bearingSnap=e.bearingSnap,this._refreshExpiredTiles=e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=e.crossSourceCollisions,this._collectResourceTiming=e.collectResourceTiming,this._optimizeForTerrain=e.optimizeForTerrain,this._language=this._parseLanguage(e.language),this._worldview=e.worldview,this._renderTaskQueue=new Jr,this._domRenderTaskQueue=new Jr,this._controls=[],this._markers=[],this._popups=[],this._mapId=t.uniqueId(),this._locale=t.extend({},oo,e.locale),this._clickTolerance=e.clickTolerance,this._cooperativeGestures=e.cooperativeGestures,this._performanceMetricsCollection=e.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ro(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new t.RequestManager(e.transformRequest,e.accessToken,e.testMode),this._silenceAuthErrors=!!e.testMode,"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 t.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=e.container}if(this._container.childNodes.length>0&&t.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),e.maxBounds&&this.setMaxBounds(e.maxBounds),t.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._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),t.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),t.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new qr(this,e),this._localFontFamily=e.localFontFamily,this._localIdeographFontFamily=e.localIdeographFontFamily,e.style&&this.setStyle(e.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),e.projection&&this.setProjection(e.projection),this._hash=e.hash&&new Jn("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(),e.attributionControl&&this.addControl(new Yr({customAttribution:e.customAttribution})),this._logoControl=new Qr,this.addControl(this._logoControl,e.logoPosition),this.on("style.load",(()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)})),this.on("data",(e=>{this._update("style"===e.dataType),this.fire(new t.Event(`${e.dataType}data`,e))})),this.on("dataloading",(e=>{this.fire(new t.Event(`${e.dataType}dataloading`,e))}))}_getMapId(){return this._mapId}addControl(e,i){if(void 0===i&&(i=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.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(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.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(t){return this._controls.indexOf(t)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(e){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const i=!this._moving;return i&&this.fire(new t.Event("movestart",e)).fire(new t.Event("move",e)),this.fire(new t.Event("resize",e)),i&&this.fire(new t.Event("moveend",e)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(e){return this.transform.setMaxBounds(t.LngLatBounds.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.minZoom=e,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=e,this._update(),this.getZoom()>e?this.setZoom(e):this.fire(new t.Event("zoomstart")).fire(new t.Event("zoom")).fire(new t.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.minPitch=e,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(e>=this.transform.minPitch)return this.transform.maxPitch=e,this._update(),this.getPitch()>e?this.setPitch(e):this.fire(new t.Event("pitchstart")).fire(new t.Event("pitch")).fire(new t.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.renderWorldCopies=t,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(e){return"auto"===e?t.window.navigator.language:Array.isArray(e)?0===e.length?void 0:e.map((e=>"auto"===e?t.window.navigator.language:e)):e}setLanguage(t){const e=this._parseLanguage(t);if(!this.style||e===this._language)return this;this._language=e,this.style._reloadSources();for(const t of this._controls)t._setLanguage&&t._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(t){return this.style&&t!==this._worldview?(this._worldview=t,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(t){return this._lazyInitEmptyStyle(),t?"string"==typeof t&&(t={name:t}):t=null,this._useExplicitProjection=!!t,this._prioritizeAndUpdateProjection(t,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const e=this.transform,i=e.projection.name;let n;"globe"===i&&e.zoom>=t.GLOBE_ZOOM_THRESHOLD_MAX?(e.setMercatorFromTransition(),n=!0):"mercator"===i&&e.zoom=t.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(e),this.style.applyProjectionUpdate(),i){this.painter.clearBackgroundTiles();for(const t in this.style._sourceCaches)this.style._sourceCaches[t].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(e){return this.transform.locationPoint3D(t.LngLat.convert(e))}unproject(e){return this.transform.pointLocation3D(t.Point.convert(e))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let n=!1;const r=r=>{const o=e.filter((t=>this.getLayer(t))),s=o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new ar(t,this,r.originalEvent,{features:s}))):n=!1},o=()=>{n=!1};return{layers:new Set(e),listener:i,delegates:{mousemove:r,mouseout:o}}}if("mouseleave"===t||"mouseout"===t){let n=!1;const r=r=>{const o=e.filter((t=>this.getLayer(t)));(o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new ar(t,this,r.originalEvent)))},o=e=>{n&&(n=!1,i.call(this,new ar(t,this,e.originalEvent)))};return{layers:new Set(e),listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=t=>{const n=e.filter((t=>this.getLayer(t))),r=n.length?this.queryRenderedFeatures(t.point,{layers:n}):[];r.length&&(t.features=r,i.call(this,t),delete t.features)};return{layers:new Set(e),listener:i,delegates:{[t]:n}}}}on(t,e,i){if(void 0===i)return super.on(t,e);Array.isArray(e)||(e=[e]);const n=this._createDelegatedListener(t,e,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[t]=this._delegatedListeners[t]||[],this._delegatedListeners[t].push(n);for(const t in n.delegates)this.on(t,n.delegates[t]);return this}once(t,e,i){if(void 0===i)return super.once(t,e);Array.isArray(e)||(e=[e]);const n=this._createDelegatedListener(t,e,i);for(const t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){if(void 0===i)return super.off(t,e);e=new Set(Array.isArray(e)?e:[e]);const n=(t,e)=>{if(t.size!==e.size)return!1;for(const i of t)if(!e.has(i))return!1;return!0},r=this._delegatedListeners?this._delegatedListeners[t]:void 0;return r&&(t=>{for(let r=0;r{e?this.fire(new t.ErrorEvent(e)):n&&this._updateDiff(n,i)}))}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e)&&this._update(!0)}catch(n){t.warnOnce(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(t.warnOnce("There is no style added to the map."),!1)}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){return!!this.style&&this.style._isSourceCacheLoaded(t)}areTilesLoaded(){const t=this.style&&this.style._sourceCaches;for(const e in t){const i=t[e]._tiles;for(const t in i){const e=i[t];if("loaded"!==e.state&&"errored"!==e.state)return!1}}return!0}addSourceType(t,e,i){this._lazyInitEmptyStyle(),this.style.addSourceType(t,e,i)}removeSource(t){return this.style.removeSource(t),this._updateTerrain(),this._update(!0)}getSource(t){return this.style.getSource(t)}addImage(e,i,{pixelRatio:n=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){if(this._lazyInitEmptyStyle(),i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap){const{width:l,height:c,data:u}=t.exported.getImageData(i);this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},u),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0})}else if(void 0===i.width||void 0===i.height)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`")));else{const{width:l,height:c}=i,u=i;this.style.addImage(e,{data:new t.RGBAImage({width:l,height:c},new Uint8Array(u.data)),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0,userImage:u}),u.onAdd&&u.onAdd(this,e)}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return void 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.")));const r=i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap?t.exported.getImageData(i):i,{width:o,height:s}=r;void 0!==o&&void 0!==s?o===n.data.width&&s===n.data.height?(n.data.replace(r.data,!(i instanceof t.window.HTMLImageElement||t.window.ImageBitmap&&i instanceof t.window.ImageBitmap)),this.style.updateImage(e,n)):this.fire(new t.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${s})\n must be that same as the previous version of the image\n (${n.data.width}, ${n.data.height})`))):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`")))}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(e,i){t.getImage(this._requestManager.transformRequest(e,t.ResourceType.Image),((e,n)=>{i(e,n instanceof t.window.HTMLImageElement?t.exported.getImageData(n):n)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,n={}){return this.style.setPaintProperty(t,e,i,n),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,n={}){return this.style.setLayoutProperty(t,e,i,n),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(t){return this._lazyInitEmptyStyle(),!t&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(t),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(t){return this._lazyInitEmptyStyle(),this.style.setFog(t),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(e){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(t.LngLat.convert(e),this.transform):0}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,i=this._container.getBoundingClientRect().height||300;let n,r,o,s=this._container;for(;s&&(!r||!o);){const e=t.window.getComputedStyle(s).transform;e&&"none"!==e&&(n=e.match(/matrix.*\((.+)\)/)[1].split(", "),n[0]&&"0"!==n[0]&&"1"!==n[0]&&(r=n[0]),n[3]&&"0"!==n[3]&&"1"!==n[3]&&(o=n[3])),s=s.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=o?Math.abs(i/o):i}_detectMissingCSS(){"rgb(250, 128, 114)"!==t.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&t.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const t=this._container;t.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",t)).style.visibility="hidden",this._detectMissingCSS();const e=this._canvasContainer=o("div","mapboxgl-canvas-container",t);this._interactive&&e.classList.add("mapboxgl-interactive"),this._canvas=o("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",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const i=this._controlContainer=o("div","mapboxgl-control-container",t),n=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach((t=>{n[t]=o("div",`mapboxgl-ctrl-${t}`,i)})),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,i){const n=t.exported.devicePixelRatio||1;this._canvas.width=n*Math.ceil(e),this._canvas.height=n*Math.ceil(i),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${i}px`}_addMarker(t){this._markers.push(t)}_removeMarker(t){const e=this._markers.indexOf(t);-1!==e&&this._markers.splice(e,1)}_addPopup(t){this._popups.push(t)}_removePopup(t){const e=this._popups.indexOf(t);-1!==e&&this._popups.splice(e,1)}_setupPainter(){const e=t.extend({},i.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),n=this._useWebGL2&&this._canvas.getContext("webgl2",e),r=n||this._canvas.getContext("webgl",e)||this._canvas.getContext("experimental-webgl",e);r?(this._useWebGL2&&!n&&t.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),t.storeAuthState(r,!0),this.painter=new Nn(r,this.transform,!!n),this.on("data",(t=>{"source"===t.dataType&&this.painter.setTileLoadedFlag(!0)})),t.exported$1.testSupport(r)):this.fire(new t.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(e){e.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new t.Event("webglcontextlost",{originalEvent:e}))}_contextRestored(e){this._setupPainter(),this.resize(),this._update(),this.fire(new t.Event("webglcontextrestored",{originalEvent:e}))}_onMapScroll(t){if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?(this._styleDirty=this._styleDirty||t,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_requestDomTask(t){!this.loaded()||this.loaded()&&!this.isMoving()?t():this._domRenderTaskQueue.add(t)}_render(e){let i;const n=this.painter.context.extTimerQuery,r=t.exported.now();if(this.listens("gpu-timing-frame")&&(i=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,i)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],t.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],t.window.performance.now())),this._renderTaskQueue.run(e),this._domRenderTaskQueue.run(e),this._removed)return;this._updateProjectionTransition();const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=this.transform.pitch,n=t.exported.now(),r=new t.EvaluationParameters(e,{now:n,fadeDuration:o,pitch:i,transition:this.style.getTransition()});this.style.update(r)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(r),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(r),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:o,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new t.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new t.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),i){const e=t.exported.now()-r;n.endQueryEXT(n.TIME_ELAPSED_EXT,i),setTimeout((()=>{const o=n.getQueryObjectEXT(i,n.QUERY_RESULT_EXT)/1e6;n.deleteQueryEXT(i),this.fire(new t.Event("gpu-timing-frame",{cpuTime:e,gpuTime:o})),t.window.performance.mark("frame-gpu",{startTime:r,detail:{gpuTime:o}})}),50)}if(this.listens("gpu-timing-layer")){const e=this.painter.collectGpuTimers();setTimeout((()=>{const i=this.painter.queryGpuTimers(e);this.fire(new t.Event("gpu-timing-layer",{layerTimes:i}))}),50)}if(this.listens("gpu-timing-deferred-render")){const e=this.painter.collectDeferredRenderGpuQueries();setTimeout((()=>{const i=this.painter.queryGpuTimeDeferredRender(e);this.fire(new t.Event("gpu-timing-deferred-render",{gpuTime:i}))}),50)}const a=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(a||this._repaint)this.triggerRepaint();else{const e=!this.isMoving()&&this.loaded();if(e&&(s=this._updateAverageElevation(r,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),e&&(this.fire(new t.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const e=this._calculateSpeedIndex();this.fire(new t.Event("speedindexcompleted",{speedIndex:e})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||a||(this._fullyLoaded=!0,t.LivePerformanceUtils.mark(t.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&t.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(t){for(const e of this._markers)t&&!this.getRenderWorldCopies()&&(e._lngLat=e._lngLat.wrap()),e._update();for(const e of this._popups)!t||this.getRenderWorldCopies()||e._trackPointer||(e._lngLat=e._lngLat.wrap()),e._update()}_updateAverageElevation(t,e=!1){const i=t=>(this.transform.averageElevation=t,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&i(0);if((e||t-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(t)){const e=this.transform.averageElevation;let n=this.transform.sampleAverageElevation(),r=!1;this.transform.elevation&&(r=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=t;const o=Math.abs(e-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,t,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(t)&&i(this._averageElevation.getValue(t))}_authenticate(){t.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(e=>{if(e&&(e.message===t.AUTH_ERR_MSG||401===e.status)){const e=this.painter.context.gl;t.storeAuthState(e,!1),this._logoControl instanceof Qr&&this._logoControl._updateLogo(),e&&e.clear(e.DEPTH_BUFFER_BIT|e.COLOR_BUFFER_BIT|e.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new t.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}})),t.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,(()=>{}))}_updateTerrain(){const t=this._isDragging();this.painter.updateTerrain(this.style,t)}_calculateSpeedIndex(){const t=this.painter.canvasCopy(),e=this.painter.getCanvasCopiesAndTimestamps();e.timeStamps.push(performance.now());const i=this.painter.context.gl,n=i.createFramebuffer();function r(t){i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,t,0);const e=new Uint8Array(i.drawingBufferWidth*i.drawingBufferHeight*4);return i.readPixels(0,0,i.drawingBufferWidth,i.drawingBufferHeight,i.RGBA,i.UNSIGNED_BYTE,e),e}return i.bindFramebuffer(i.FRAMEBUFFER,n),this._canvasPixelComparison(r(t),e.canvasCopies.map(r),e.timeStamps)}_canvasPixelComparison(t,e,i){let n=i[1]-i[0];const r=t.length/4;for(let o=0;o{const e=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,e&&this._render(t)})))}_preloadTiles(e){const i=this.style?Object.values(this.style._sourceCaches):[];return t.asyncAll(i,((t,i)=>t._preloadTiles(e,i)),(()=>{this.triggerRepaint()})),this}_onWindowOnline(){this._update()}_onWindowResize(t){this._trackResize&&this.resize({originalEvent:t})._update()}_onVisibilityChange(){"hidden"===t.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(t){this._showTerrainWireframe!==t&&(this._showTerrainWireframe=t,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(t){this._speedIndexTiming!==t&&(this._speedIndexTiming=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(t){this._showTileAABBs!==t&&(this._showTileAABBs=t,t&&this._update())}_setCacheLimits(e,i){t.setCacheLimits(e,i)}get version(){return t.version}},NavigationControl:class{constructor(e){this.options=t.extend({},ao,e),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(t.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",(t=>{this._map&&this._map.zoomIn({},{originalEvent:t})})),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",(t=>{this._map&&this._map.zoomOut({},{originalEvent:t})})),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(t.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",(t=>{const e=this._map;e&&(this.options.visualizePitch?e.resetNorthPitch({},{originalEvent:t}):e.resetNorth({},{originalEvent:t}))})),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const t=this._map;if(!t)return;const e=t.getZoom(),i=e===t.getMaxZoom(),n=e===t.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.toString())}_rotateCompassArrow(){const t=this._map;if(!t)return;const e=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(t.transform.pitch*(Math.PI/180)),.5)}) rotateX(${t.transform.pitch}deg) rotateZ(${t.transform.angle*(180/Math.PI)}deg)`:`rotate(${t.transform.angle*(180/Math.PI)}deg)`;t._requestDomTask((()=>{this._compassIcon&&(this._compassIcon.style.transform=e)}))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),t.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&t.on("pitch",this._rotateCompassArrow),t.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new lo(t,this._compass,this.options.visualizePitch)),this._container}onRemove(){const t=this._map;t&&(this._container.remove(),this.options.showZoom&&t.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&t.off("pitch",this._rotateCompassArrow),t.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(t,e){const i=o("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}_setButtonTitle(t,e){if(!this._map)return;const i=this._map._getUIString(`NavigationControl.${e}`);t.setAttribute("aria-label",i),t.firstElementChild&&t.firstElementChild.setAttribute("title",i)}},GeolocateControl:class extends t.Evented{constructor(e){super(),this.options=t.extend({geolocation:t.window.navigator.geolocation},co,e),t.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Qn(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(t){return this._map=t,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(e){const i=(t=!!this.options.geolocation)=>{this._supportsGeolocation=t,e(t)};void 0!==this._supportsGeolocation?e(this._supportsGeolocation):void 0!==t.window.navigator.permissions?t.window.navigator.permissions.query({name:"geolocation"}).then((t=>i("denied"!==t.state))).catch((()=>i())):i()}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return!!e&&(i.longitudee.getEast()||i.latitudee.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(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("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("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("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("geolocate",e)),this._finish()}}_updateCamera(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.extend({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),o,{geolocateSource:!0})}_updateMarker(e){if(e){const i=new t.LngLat(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const e=this._map.transform,i=t.mercatorZfromAltitude(1,e._center.lat)*e.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(e){if(this._map){if(this.options.trackUserLocation)if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new t.Event("error",e)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(e){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===e){t.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new to({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new to({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",(e=>{e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||e.originalEvent&&"resize"===e.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new t.Event("trackuserlocationend")))}))}}_onDeviceOrientation(t){this._userLocationDotMarker&&(t.webkitCompassHeading?this._heading=t.webkitCompassHeading:!0===t.absolute&&(this._heading=-1*t.alpha),this._updateMarkerRotationThrottled())}trigger(){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":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new t.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("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("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(t={maximumAge:6e5,timeout:0},this._noTimeout=!0):(t=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,t),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{t.window.addEventListener("ondeviceorientationabsolute"in t.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==t.window.DeviceMotionEvent&&"function"==typeof t.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((t=>{"granted"===t&&e()})).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),t.window.removeEventListener("deviceorientation",this._onDeviceOrientation),t.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Yr,ScaleControl:class{constructor(e){this.options=t.extend({},uo,e),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(t){return!1}}(),t.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const t=this.options.maxWidth||100,e=this._map,i=e._containerHeight/2,n=e._containerWidth/2-t/2,r=e.unproject([n,i]),o=e.unproject([n+t,i]),s=r.distanceTo(o);if("imperial"===this.options.unit){const e=3.2808*s;e>5280?this._setScale(t,e/5280,"mile"):this._setScale(t,e,"foot")}else"nautical"===this.options.unit?this._setScale(t,s/1852,"nautical-mile"):s>=1e3?this._setScale(t,s/1e3,"kilometer"):this._setScale(t,s,"meter")}_setScale(t,e,i){this._map._requestDomTask((()=>{const n=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(e),r=n/e;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(n):`${n} ${ho[i]}`,this._container.style.width=t*r+"px"}))}onAdd(t){return this._map=t,this._language=t.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",t.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(t){this._language=t,this._update()}setUnit(t){this.options.unit=t,this._update()}},FullscreenControl:class{constructor(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":"onwebkitfullscreenchange"in t.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","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}onRemove(){this._controlContainer.remove(),this._map=null,t.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!t.window.document.fullscreenEnabled&&!t.window.document.webkitFullscreenEnabled)}_setupUI(){const e=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),t.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",t)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(t.window.document.fullscreenElement||t.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?t.window.document.exitFullscreen?t.window.document.exitFullscreen():t.window.document.webkitCancelFullScreen&&t.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends t.Evented{constructor(e){super(),this.options=t.extend(Object.create(eo),e),t.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(e&&e.className?e.className.trim().split(/\s+/):[])}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&e.on("preclick",this._onClose),this.options.closeOnMove&&e.on("move",this._onClose),e.on("remove",this.remove),this._update(),e._addPopup(this),this._focusFirstElement(),this._trackPointer?(e.on("mousemove",this._onMouseEvent),e.on("mouseup",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")):e.on("move",this._update),this.fire(new t.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const e=this._map;return e&&(e.off("move",this._update),e.off("move",this._onClose),e.off("preclick",this._onClose),e.off("click",this._onClose),e.off("remove",this.remove),e.off("mousemove",this._onMouseEvent),e.off("mouseup",this._onMouseEvent),e.off("drag",this._onMouseEvent),e._canvasContainer&&e._canvasContainer.classList.remove("mapboxgl-track-pointer"),e._removePopup(this),this._map=void 0),this.fire(new t.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(e){this._lngLat=t.LngLat.convert(e),this._pos=null,this._trackPointer=!1,this._update();const i=this._map;return i&&(i.on("move",this._update),i.off("mousemove",this._onMouseEvent),i._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const t=this._map;return t&&(t.off("move",this._update),t.on("mousemove",this._onMouseEvent),t.on("drag",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(t.window.document.createTextNode(e))}setHTML(e){const i=t.window.document.createDocumentFragment(),n=t.window.document.createElement("body");let r;for(n.innerHTML=e;r=n.firstChild,r;)i.appendChild(r);return this.setDOMContent(i)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){let e=this._content;if(e)for(;e.hasChildNodes();)e.firstChild&&e.removeChild(e.firstChild);else e=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(e.appendChild(t),this.options.closeButton){const t=this._closeButton=o("button","mapboxgl-popup-close-button",e);t.type="button",t.setAttribute("aria-label","Close popup"),t.setAttribute("aria-hidden","true"),t.innerHTML="×",t.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(t){return this._classList.add(t),this._updateClassList(),this}removeClassName(t){return this._classList.delete(t),this._updateClassList(),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){let e;return this._classList.delete(t)?e=!1:(this._classList.add(t),e=!0),this._updateClassList(),e}_onMouseEvent(t){this._update(t.point)}_getAnchor(t){if(this.options.anchor)return this.options.anchor;const e=this._map,i=this._container,n=this._pos;if(!e||!i||!n)return"bottom";const r=i.offsetWidth,o=i.offsetHeight,s=n.xe.transform.width-r/2;if(n.y+te.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"left":a?"right":"bottom"}_updateClassList(){const t=this._container;if(!t)return;const e=[...this._classList];e.push("mapboxgl-popup"),this._anchor&&e.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&e.push("mapboxgl-popup-track-pointer"),t.className=e.join(" ")}_update(e){const i=this._map,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=o("div","mapboxgl-popup",i.getContainer()),this._tip=o("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Kr(this._lngLat,this._pos,i.transform)),!this._trackPointer||e){const t=this._pos=this._trackPointer&&e?e:i.project(this._lngLat),n=no(this.options.offset),r=this._anchor=this._getAnchor(n.y),o=no(this.options.offset,r),s=t.add(o).round();i._requestDomTask((()=>{this._container&&r&&(this._container.style.transform=`${$r[r]} translate(${s.x}px,${s.y}px)`)}))}if(!this._marker&&i._showingGlobe()){const e=t.isLngLatBehindGlobe(i.transform,this._lngLat)?0:1;this._setOpacity(e)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(io);t&&t.focus()}_onClose(){this.remove()}_setOpacity(t){this._container&&(this._container.style.opacity=`${t}`),this._content&&(this._content.style.pointerEvents=t?"auto":"none")}},Marker:to,Style:Je,LngLat:t.LngLat,LngLatBounds:t.LngLatBounds,Point:t.Point,MercatorCoordinate:t.MercatorCoordinate,FreeCameraOptions:Un,Evented:t.Evented,config:t.config,prewarm:function(){Ft().acquire(Nt)},clearPrewarmedResources:function(){const t=zt;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(Nt),zt=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 Bt.workerCount},set workerCount(t){Bt.workerCount=t},get maxParallelImageRequests(){return t.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(e){t.config.MAX_PARALLEL_IMAGE_REQUESTS=e},clearStorage(e){t.clearTileCache(e)},workerUrl:"",workerClass:null,setNow:t.exported.setNow,restoreNow:t.exported.restoreNow};return po}));var r=i;return r}()}(Pm);var Lm=Pm.exports,Dm=rt(Lm);function Rm(t,e,i){const n=Om(t,e);return function(t,e,i){void 0===i&&(i={});for(var n=i.steps||64,r=i.properties?i.properties:!Array.isArray(t)&&"Feature"===t.type&&t.properties?t.properties:{},o=[],s=0;s\n 再次点击结束绘制`}else t.text="点击拖拽开始绘制";t.popup?t.popup.setLngLat([+i.lng,+i.lat]).setHTML(t.text):t.popup=km(t.text,[+i.lng,+i.lat])},toDisplayFeatures:function(t,e,i){i(e)}},Bm={onSetup:function(t){const e={};return e.pointIcon=t.pointIcon,e.iconSize=t.iconSize,e.iconOffset=t.iconOffset,e},onClick:function(t,e){const i=this.newFeature({type:"Feature",properties:{pointIcon:t.pointIcon,iconSize:t.iconSize,iconOffset:t.iconOffset},geometry:{type:"Point",coordinates:[e.lngLat.lng,e.lngLat.lat]}});this.addFeature(i);const n=JSON.parse(JSON.stringify(i.coordinates)),r=JSON.parse(JSON.stringify({id:i.id,type:"Feature",geometry:{type:"Point",properties:{pointIcon:t.pointIcon,iconSize:t.iconSize,iconOffset:t.iconOffset},coordinates:n}}));return this.map.fire("draw.create",{features:[r]}),this.changeMode("simple_select")},toDisplayFeatures:function(t,e,i){i(e)}};var zm={enable(t){setTimeout((()=>{t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()}),0)},disable(t){setTimeout((()=>{t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()}),0)}};const Fm={onSetup:function(t){const e=(t=t||{}).featureId;let i,n,r="forward";if(e){if(i=this.getFeature(e),!i)throw new Error("Could not find a feature with the provided featureId");let 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");const s=i.coordinates.length-1;if(i.coordinates[s][0]===o[0]&&i.coordinates[s][1]===o[1])n=s+1,i.addCoordinate(n,...i.coordinates[s]);else{if(i.coordinates[0][0]!==o[0]||i.coordinates[0][1]!==o[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");r="backwards",n=0,i.addCoordinate(n,...i.coordinates[0])}}else i=this.newFeature({type:lm.FEATURE,properties:{lineColor:t.lineColor,lineWidth:t.lineWidth},geometry:{type:lm.LINE_STRING,coordinates:[]}}),n=0,this.addFeature(i);return this.clearSelectedFeatures(),zm.disable(this),this.updateUIClasses({mouse:sm.ADD}),this.activateUIButton(am.LINE),this.setActionableState({trash:!0}),{line:i,currentVertexPosition:n,direction:r,text:"点击开始绘制",popup:null,opts:t}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Tm(e,t.line.coordinates[t.currentVertexPosition-1])||"backwards"===t.direction&&Tm(e,t.line.coordinates[t.currentVertexPosition+1]))return this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.line.id]});this.updateUIClasses({mouse:sm.ADD}),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(cm.SIMPLE_SELECT,{featureIds:[t.line.id]})},onMouseMove:function(t,e){t.line.updateCoordinate(t.currentVertexPosition,e.lngLat.lng,e.lngLat.lat),Am(e)&&this.updateUIClasses({mouse:sm.POINTER});const{lngLat:i}=e;t.currentVertexPosition?t.text="双击结束绘制":t.text="点击开始绘制",t.popup?t.popup.setLngLat([+i.lng,+i.lat]).setHTML(t.text):t.popup=km(t.text,[+i.lng,+i.lat])}};Fm.onTap=Fm.onClick=function(t,e){if(Am(e))return this.clickOnVertex(t,e);this.clickAnywhere(t,e)},Fm.onKeyUp=function(t,e){Mm(e)?this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.line.id]}):Sm(e)&&(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT))},Fm.onStop=function(t){t.popup&&t.popup.remove(),zm.enable(this),this.activateUIButton(),void 0!==this.getFeature(t.line.id)&&(t.line.removeCoordinate(`${t.currentVertexPosition}`),t.line.isValid()?this.map.fire(um.CREATE,{features:[t.line.toGeoJSON()]}):(this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT,{},{silent:!0})))},Fm.onTrash=function(t){this.deleteFeature([t.line.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT)},Fm.toDisplayFeatures=function(t,e,i){const n=e.properties.id===t.line.id;if(e.properties.active=n?dm.ACTIVE:dm.INACTIVE,!n)return i(e);e.geometry.coordinates.length<2||(e.properties.meta=pm.FEATURE,i(ym(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,t.opts)),i(e))};const Vm={onSetup:function(t){const e=t||{},i=this.newFeature({type:lm.FEATURE,properties:{lineColor:e.lineColor,lineWidth:e.lineWidth,fillColor:e.fillColor,polygonType:e.polygonType,polygonImage:e.polygonImage||""},geometry:{type:lm.POLYGON,coordinates:[[]]}});return this.addFeature(i),this.clearSelectedFeatures(),zm.disable(this),this.updateUIClasses({mouse:sm.ADD}),this.activateUIButton(am.POLYGON),this.setActionableState({trash:!0}),{polygon:i,currentVertexPosition:0,text:"点击开始绘制",popup:null,opts:e}},clickAnywhere:function(t,e){if(t.currentVertexPosition>0&&Tm(e,t.polygon.coordinates[0][t.currentVertexPosition-1]))return this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.polygon.id]});this.updateUIClasses({mouse:sm.ADD}),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(cm.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},onMouseMove:function(t,e){t.polygon.updateCoordinate(`0.${t.currentVertexPosition}`,e.lngLat.lng,e.lngLat.lat),Am(e)&&this.updateUIClasses({mouse:sm.POINTER});const{lngLat:i}=e;t.currentVertexPosition?t.text="双击结束绘制":t.text="点击开始绘制",t.popup?t.popup.setLngLat([+i.lng,+i.lat]).setHTML(t.text):t.popup=km(t.text,[+i.lng,+i.lat])}};Vm.onTap=Vm.onClick=function(t,e){return Am(e)?this.clickOnVertex(t,e):this.clickAnywhere(t,e)},Vm.onKeyUp=function(t,e){Sm(e)?(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT)):Mm(e)&&this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.polygon.id]})},Vm.onStop=function(t){t.popup&&t.popup.remove(),this.updateUIClasses({mouse:sm.NONE}),zm.enable(this),this.activateUIButton(),void 0!==this.getFeature(t.polygon.id)&&(t.polygon.removeCoordinate(`0.${t.currentVertexPosition}`),t.polygon.isValid()?this.map.fire(um.CREATE,{features:[t.polygon.toGeoJSON()]}):(this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT,{},{silent:!0})))},Vm.toDisplayFeatures=function(t,e,i){const n=e.properties.id===t.polygon.id;if(e.properties.active=n?dm.ACTIVE:dm.INACTIVE,!n)return i(e);if(0===e.geometry.coordinates.length)return;const r=e.geometry.coordinates[0].length;if(!(r<3)){if(e.properties.meta=pm.FEATURE,i(ym(t.polygon.id,e.geometry.coordinates[0][0],"0.0",!1,t.opts)),r>3){const n=e.geometry.coordinates[0].length-3;i(ym(t.polygon.id,e.geometry.coordinates[0][n],`0.${n}`,!1,t.opts))}if(r<=4){const t=[[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(i({type:lm.FEATURE,properties:e.properties,geometry:{coordinates:t,type:lm.LINE_STRING}}),3===r)return}return i(e)}},Vm.onTrash=function(t){this.deleteFeature([t.polygon.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT)};const Um={enable:t=>{setTimeout((()=>{t.map&&t.map.doubleClickZoom&&t._ctx&&t._ctx.store&&t._ctx.store.getInitialConfigValue&&t._ctx.store.getInitialConfigValue("doubleClickZoom")&&t.map.doubleClickZoom.enable()}),0)},disable(t){setTimeout((()=>{t.map&&t.map.doubleClickZoom&&t.map.doubleClickZoom.disable()}),0)}},Gm={onSetup(t){const e=t||{},i=this.newFeature({type:"Feature",properties:{lineColor:e.lineColor,lineWidth:e.lineWidth,fillColor:e.fillColor,polygonType:e.polygonType,polygonImage:e.polygonImage||""},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(i),this.clearSelectedFeatures(),Um.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:i,text:"点击开始绘制",popup:null}},onTap(t,e){t.startPoint&&this.onMouseMove(t,e),this.onClick(t,e)},onClick(t,e){t.startPoint&&t.startPoint[0]!==e.lngLat.lng&&t.startPoint[1]!==e.lngLat.lat&&(this.updateUIClasses({mouse:"pointer"}),t.endPoint=[e.lngLat.lng,e.lngLat.lat],this.changeMode("simple_select",{featuresId:t.rectangle.id}));const i=[e.lngLat.lng,e.lngLat.lat];t.startPoint=i},onMouseMove(t,e){t.startPoint&&(t.rectangle.updateCoordinate("0.0",t.startPoint[0],t.startPoint[1]),t.rectangle.updateCoordinate("0.1",e.lngLat.lng,t.startPoint[1]),t.rectangle.updateCoordinate("0.2",e.lngLat.lng,e.lngLat.lat),t.rectangle.updateCoordinate("0.3",t.startPoint[0],e.lngLat.lat),t.rectangle.updateCoordinate("0.4",t.startPoint[0],t.startPoint[1]));const{lngLat:i}=e;t.startPoint?t.text="再次点击结束绘制":t.text="点击开始绘制",t.popup?t.popup.setLngLat([+i.lng,+i.lat]).setHTML(t.text):t.popup=km(t.text,[+i.lng,+i.lat])},onKeyUp(t,e){if(27===e.keyCode)return this.changeMode("simple_select")},onStop(t){t.popup&&t.popup.remove(),Um.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),void 0!==this.getFeature(t.rectangle.id)&&(t.rectangle.removeCoordinate("0.4"),t.rectangle.isValid()?this.map.fire("draw.create",{features:[t.rectangle.toGeoJSON()]}):(this.deleteFeature([t.rectangle.id],{silent:!0}),this.changeMode("simple_select",{},{silent:!0})))},toDisplayFeatures(t,e,i){const n=e.properties.id===t.rectangle.id;return e.properties.active=n?"true":"false",n?t.startPoint?i(e):void 0:i(e)},onTrash(t){this.deleteFeature([t.rectangle.id],{silent:!0}),this.changeMode("simple_select")}},jm={};function Hm(t,e,i=null){e=e||{};const{type:n,coordinates:r}=t.geometry,o=t.properties&&t.properties.id;let s=[];const a={lineColor:t.properties.user_lineColor,lineWidth:t.properties.user_lineWidth};function l(t,i,n){let r="",a=null;t.forEach(((t,l)=>{const u=null!=i?`${i}.${l}`:String(l),h=ym(o,t,u,c(u),n);if(e.midpoints&&a){const t=function(t,e,i,n){const r=e.geometry.coordinates,o=i.geometry.coordinates;if(r[1]>mm||r[1]mm||o[1]{l(t,null!==i?`${i}.${e}`:String(e),a)})):n===lm.LINE_STRING?l(r,i,a):0===n.indexOf(lm.MULTI_PREFIX)&&function(){const i=n.replace(lm.MULTI_PREFIX,"");r.forEach(((n,r)=>{const o={type:lm.FEATURE,properties:t.properties,geometry:{type:i,coordinates:n}};s=s.concat(Hm(o,e,r))}))}(),s}jm.onSetup=function(t){const e=this.newFeature({type:lm.FEATURE,properties:{pixelSize:t.pixelSize,color:t.color},geometry:{type:lm.POINT,coordinates:[]}});return this.addFeature(e),this.clearSelectedFeatures(),this.updateUIClasses({mouse:sm.ADD}),this.activateUIButton(am.POINT),this.setActionableState({trash:!0}),{point:e}},jm.stopDrawingAndRemove=function(t){this.deleteFeature([t.point.id],{silent:!0}),this.changeMode(cm.SIMPLE_SELECT)},jm.onTap=jm.onClick=function(t,e){this.updateUIClasses({mouse:sm.MOVE}),t.point.updateCoordinate("",e.lngLat.lng,e.lngLat.lat),this.map.fire(um.CREATE,{features:[t.point.toGeoJSON()]}),this.changeMode(cm.SIMPLE_SELECT,{featureIds:[t.point.id]})},jm.onStop=function(t){this.activateUIButton(),t.point.getCoordinate().length||this.deleteFeature([t.point.id],{silent:!0})},jm.toDisplayFeatures=function(t,e,i){const n=e.properties.id===t.point.id;if(e.properties.active=n?dm.ACTIVE:dm.INACTIVE,!n)return i(e)},jm.onTrash=jm.stopDrawingAndRemove,jm.onKeyUp=function(t,e){if(Sm(e)||Mm(e))return this.stopDrawingAndRemove(t,e)};var Wm={exports:{}},qm=function(t){if(!t||!t.type)return null;var e=Xm[t.type];if(!e)return null;if("geometry"===e)return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:t}]};if("feature"===e)return{type:"FeatureCollection",features:[t]};if("featurecollection"===e)return t},Xm={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"};var Zm=Object.freeze({__proto__:null,default:function t(e){switch(e&&e.type||null){case"FeatureCollection":return e.features=e.features.reduce((function(e,i){return e.concat(t(i))}),[]),e;case"Feature":return e.geometry?t(e.geometry).map((function(t){var i={type:"Feature",properties:JSON.parse(JSON.stringify(e.properties)),geometry:t};return void 0!==e.id&&(i.id=e.id),i})):[e];case"MultiPoint":return e.coordinates.map((function(t){return{type:"Point",coordinates:t}}));case"MultiPolygon":return e.coordinates.map((function(t){return{type:"Polygon",coordinates:t}}));case"MultiLineString":return e.coordinates.map((function(t){return{type:"LineString",coordinates:t}}));case"GeometryCollection":return e.geometries.map(t).reduce((function(t,e){return t.concat(e)}),[]);case"Point":case"Polygon":case"LineString":return[e]}}}),Ym=qm,Qm=ot(Zm),Jm=function(t){return function t(e){if(Array.isArray(e)&&e.length&&"number"==typeof e[0])return[e];return e.reduce((function(e,i){return Array.isArray(i)&&Array.isArray(i[0])?e.concat(t(i)):(e.push(i),e)}),[])}(t)};Qm instanceof Function||(Qm=Qm.default);function Km(t){return Object.prototype.toString.call(t)}var $m=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function tg(t,e){if(t.forEach)return t.forEach(e);for(var i=0;i=e&&this._bbox[3]>=i},cg.prototype.intersect=function(t){return this._valid?(e=t instanceof cg?t.bbox():t,!(this._bbox[0]>e[2]||this._bbox[2]e[3])):null;var e},cg.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)},cg.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 ug=function(t){if(!t)return[];var e=Qm(Ym(t)),i=[];return e.features.forEach((function(t){t.geometry&&(i=i.concat(Jm(t.geometry.coordinates)))})),i},hg=ag,pg=lg,dg={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},fg=Object.keys(dg);function mg(t){for(var e=pg(),i=ug(t),n=0;n{const e=gg(t),l=e[1],c=e[3],u=e[0],h=e[2];l>i&&(i=l),cr&&(r=c),la&&(a=h)}));const l=e;return i+l.lat>xg&&(l.lat=xg-i),r+l.lat>vg&&(l.lat=vg-r),n+l.lat<_g&&(l.lat=_g-n),o+l.lat=wg&&(l.lng-=360*Math.ceil(Math.abs(l.lng)/360)),l}function Eg(t,e){const i=Ag(t.map((t=>t.toGeoJSON())),e);t.forEach((t=>{const e=t.getCoordinates(),n=t=>{const e={lng:t[0]+i.lng,lat:t[1]+i.lat};return[e.lng,e.lat]},r=t=>t.map((t=>n(t))),o=t=>t.map((t=>r(t)));let s;t.type===lm.POINT?s=n(e):t.type===lm.LINE_STRING||t.type===lm.MULTI_POINT?s=e.map(n):t.type===lm.POLYGON||t.type===lm.MULTI_LINE_STRING?s=e.map(r):t.type===lm.MULTI_POLYGON&&(s=e.map(o)),t.incomingCoords(s)}))}const Sg=vm(pm.VERTEX),Mg=vm(pm.MIDPOINT),Tg={fireUpdate:function(){this.map.fire(um.UPDATE,{action:hm.CHANGE_COORDINATES,features:this.getSelected().map((t=>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);const i=e.featureTarget.properties,n=t.selectedCoordPaths.indexOf(i.coord_path);Em(e)||-1!==n?Em(e)&&-1===n&&t.selectedCoordPaths.push(i.coord_path):t.selectedCoordPaths=[i.coord_path];const r=this.pathsToCoordinates(t.featureId,t.selectedCoordPaths);this.setSelectedCoordinates(r)},onMidpoint:function(t,e){this.startDragging(t,e);const i=e.featureTarget.properties;t.feature.addCoordinate(i.coord_path,i.lng,i.lat),this.fireUpdate(),t.selectedCoordPaths=[i.coord_path]},pathsToCoordinates:function(t,e){return e.map((e=>({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,i){Eg(this.getSelected(),i),t.dragMoveLocation=e.lngLat},dragVertex:function(t,e,i){const n=t.selectedCoordPaths.map((e=>t.feature.getCoordinate(e))),r=Ag(n.map((t=>({type:lm.FEATURE,properties:{},geometry:{type:lm.POINT,coordinates:t}}))),i);for(let e=0;ee.localeCompare(t,"en",{numeric:!0}))).forEach((e=>t.feature.removeCoordinate(e))),this.fireUpdate(),t.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(t),!1===t.feature.isValid()&&(this.deleteFeature([t.featureId]),this.changeMode(cm.SIMPLE_SELECT,{}))},onMouseMove:function(t,e){const i=_m(e),n=Sg(e),r=Mg(e),o=0===t.selectedCoordPaths.length;i&&o||n&&!o?this.updateUIClasses({mouse:sm.MOVE}):this.updateUIClasses({mouse:sm.NONE});return(n||i||r)&&t.dragMoving&&this.fireUpdate(),this.stopDragging(t),!0},onMouseOut:function(t){return t.dragMoving&&this.fireUpdate(),!0}};Tg.onTouchStart=Tg.onMouseDown=function(t,e){return Sg(e)?this.onVertex(t,e):_m(e)?this.onFeature(t,e):Mg(e)?this.onMidpoint(t,e):void 0},Tg.onDrag=function(t,e){if(!0!==t.canDragMove)return;t.dragMoving=!0,e.originalEvent.stopPropagation();const i={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};t.selectedCoordPaths.length>0?this.dragVertex(t,e,i):this.dragFeature(t,e,i),t.dragMoveLocation=e.lngLat},Tg.onClick=function(t,e){return bm(e)?this.clickNoTarget(t,e):_m(e)?this.clickActiveFeature(t,e):xm(e)?this.clickInactive(t,e):void this.stopDragging(t)},Tg.onTap=function(t,e){return bm(e)?this.clickNoTarget(t,e):_m(e)?this.clickActiveFeature(t,e):xm(e)?this.clickInactive(t,e):void 0},Tg.onTouchEnd=Tg.onMouseUp=function(t){t.dragMoving&&this.fireUpdate(),this.stopDragging(t)};var Ig=Cg;function Cg(t,e){this.x=t,this.y=e}Cg.prototype={clone:function(){return new Cg(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,i=t.y-this.y;return e*e+i*i},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,i=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=i,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),i=Math.sin(t),n=e*this.x-i*this.y,r=i*this.x+e*this.y;return this.x=n,this.y=r,this},_rotateAround:function(t,e){var i=Math.cos(t),n=Math.sin(t),r=e.x+i*(this.x-e.x)-n*(this.y-e.y),o=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=r,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Cg.convert=function(t){return t instanceof Cg?t:Array.isArray(t)?new Cg(t[0],t[1]):t};var Pg=rt(Ig);function Lg(t,e){const i=e.getBoundingClientRect();return new Pg(t.clientX-i.left-(e.clientLeft||0),t.clientY-i.top-(e.clientTop||0))}function Dg(t){if(this._items={},this._nums={},this._length=t?t.length:0,t)for(let e=0,i=t.length;e{t.push({k:e,v:this._items[e]})})),Object.keys(this._nums).forEach((e=>{t.push({k:JSON.parse(e),v:this._nums[e]})})),t.sort(((t,e)=>t.v-e.v)).map((t=>t.k))},Dg.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};const Rg={onSetup:function(t){const e={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:t.featureIds||[]};return this.setSelected(e.initiallySelectedFeatureIds.filter((t=>void 0!==this.getFeature(t)))),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),e},fireUpdate:function(){this.map.fire(um.UPDATE,{action:hm.MOVE,features:this.getSelected().map((t=>t.toGeoJSON()))})},fireActionable:function(){const t=this.getSelected(),e=t.filter((t=>this.isInstanceOf("MultiFeature",t)));let i=!1;if(t.length>1){i=!0;const e=t[0].type.replace("Multi","");t.forEach((t=>{t.type.replace("Multi","")!==e&&(i=!1)}))}const n=e.length>0,r=t.length>0;this.setActionableState({combineFeatures:i,uncombineFeatures:n,trash:r})},getUniqueIds:function(t){if(!t.length)return[];const e=t.map((t=>t.properties.id)).filter((t=>void 0!==t)).reduce(((t,e)=>(t.add(e),t)),new(Dg()));return e.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(){zm.enable(this)},onMouseMove:function(t,e){return wm(e)&&t.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(t),!0},onMouseOut:function(t){return!t.dragMoving||this.fireUpdate()}};Rg.onTap=Rg.onClick=function(t,e){return bm(e)?this.clickAnywhere(t,e):vm(pm.VERTEX)(e)?this.clickOnVertex(t,e):wm(e)?this.clickOnFeature(t,e):void 0},Rg.clickAnywhere=function(t){const e=this.getSelectedIds();e.length&&(this.clearSelectedFeatures(),e.forEach((t=>this.doRender(t)))),zm.enable(this),this.stopExtendedInteractions(t)},Rg.clickOnVertex=function(t,e){this.changeMode(cm.DIRECT_SELECT,{featureId:e.featureTarget.properties.parent,coordPath:e.featureTarget.properties.coord_path,startPos:e.lngLat}),this.updateUIClasses({mouse:sm.MOVE})},Rg.startOnActiveFeature=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),this.doRender(e.featureTarget.properties.id),t.canDragMove=!0,t.dragMoveLocation=e.lngLat},Rg.clickOnFeature=function(t,e){zm.disable(this),this.stopExtendedInteractions(t);const i=Em(e),n=this.getSelectedIds(),r=e.featureTarget.properties.id,o=this.isSelected(r);if(!i&&o&&this.getFeature(r).type!==lm.POINT)return this.changeMode(cm.DIRECT_SELECT,{featureId:r});o&&i?(this.deselect(r),this.updateUIClasses({mouse:sm.POINTER}),1===n.length&&zm.enable(this)):!o&&i?(this.select(r),this.updateUIClasses({mouse:sm.MOVE})):o||i||(n.forEach((t=>this.doRender(t))),this.setSelected(r),this.updateUIClasses({mouse:sm.MOVE})),this.doRender(r)},Rg.onMouseDown=function(t,e){return _m(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},Rg.startBoxSelect=function(t,e){this.stopExtendedInteractions(t),this.map.dragPan.disable(),t.boxSelectStartLocation=Lg(e.originalEvent,this.map.getContainer()),t.canBoxSelect=!0},Rg.onTouchStart=function(t,e){if(_m(e))return this.startOnActiveFeature(t,e)},Rg.onDrag=function(t,e){return t.canDragMove?this.dragMove(t,e):this.drawConfig.boxSelect&&t.canBoxSelect?this.whileBoxSelect(t,e):void 0},Rg.whileBoxSelect=function(t,e){t.boxSelecting=!0,this.updateUIClasses({mouse:sm.ADD}),t.boxSelectElement||(t.boxSelectElement=document.createElement("div"),t.boxSelectElement.classList.add(om.BOX_SELECT),this.map.getContainer().appendChild(t.boxSelectElement));const i=Lg(e.originalEvent,this.map.getContainer()),n=Math.min(t.boxSelectStartLocation.x,i.x),r=Math.max(t.boxSelectStartLocation.x,i.x),o=Math.min(t.boxSelectStartLocation.y,i.y),s=Math.max(t.boxSelectStartLocation.y,i.y),a=`translate(${n}px, ${o}px)`;t.boxSelectElement.style.transform=a,t.boxSelectElement.style.WebkitTransform=a,t.boxSelectElement.style.width=r-n+"px",t.boxSelectElement.style.height=s-o+"px"},Rg.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();const i={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat};Eg(this.getSelected(),i),t.dragMoveLocation=e.lngLat},Rg.onTouchEnd=Rg.onMouseUp=function(t,e){if(t.dragMoving)this.fireUpdate();else if(t.boxSelecting){const i=[t.boxSelectStartLocation,Lg(e.originalEvent,this.map.getContainer())],n=this.featuresAt(null,i,"click"),r=this.getUniqueIds(n).filter((t=>!this.isSelected(t)));r.length&&(this.select(r),r.forEach((t=>this.doRender(t))),this.updateUIClasses({mouse:sm.MOVE}))}this.stopExtendedInteractions(t)},Rg.toDisplayFeatures=function(t,e,i){e.properties.active=this.isSelected(e.properties.id)?dm.ACTIVE:dm.INACTIVE,i(e),this.fireActionable(),e.properties.active===dm.ACTIVE&&e.geometry.type!==lm.POINT&&Hm(e,{}).forEach(i)},Rg.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Rg.onCombineFeatures=function(){const t=this.getSelected();if(0===t.length||t.length<2)return;const e=[],i=[],n=t[0].type.replace("Multi","");for(let r=0;r{e.push(t)})):e.push(o.getCoordinates()),i.push(o.toGeoJSON())}if(i.length>1){const t=this.newFeature({type:lm.FEATURE,properties:i[0].properties,geometry:{type:`Multi${n}`,coordinates:e}});this.addFeature(t),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([t.id]),this.map.fire(um.COMBINE_FEATURES,{createdFeatures:[t.toGeoJSON()],deletedFeatures:i})}this.fireActionable()},Rg.onUncombineFeatures=function(){const t=this.getSelected();if(0===t.length)return;const e=[],i=[];for(let n=0;n{this.addFeature(t),t.properties=r.properties,e.push(t.toGeoJSON()),this.select([t.id])})),this.deleteFeature(r.id,{silent:!0}),i.push(r.toGeoJSON()))}e.length>1&&this.map.fire(um.UNCOMBINE_FEATURES,{createdFeatures:e,deletedFeatures:i}),this.fireActionable()};Rg.dragMove=function(t,e){t.dragMoving=!0,e.originalEvent.stopPropagation();const i={lng:e.lngLat.lng-t.dragMoveLocation.lng,lat:e.lngLat.lat-t.dragMoveLocation.lat},n=this.getSelected();n.forEach((t=>{if(t.properties&&t.properties.isCircle){const e=t.properties.center;t.setProperty("center",[e[0]+i.lng,e[1]+i.lat])}})),Eg(n,i),t.dragMoveLocation=e.lngLat};const Og=Tg;Og.dragVertex=function(t,e,i){const n=t.selectedCoordPaths.map((e=>t.feature.getCoordinate(e))),r=t.feature.properties;if(t.feature.properties&&t.feature.properties.isCircle){const i=Rm(t.feature.properties.center,[e.lngLat.lng,e.lngLat.lat],r);t.feature.setProperty("radiusInKm",i.properties.radiusInKm),t.feature.setCoordinates(i.geometry.coordinates)}else{const e=Ag(n.map((t=>({type:"Feature",properties:r,geometry:{type:"Point",coordinates:t}}))),i);for(let i=0;i{if(t.properties&&t.properties.isCircle){const e=t.properties.center;t.setProperty("center",[e[0]+i.lng,e[1]+i.lat])}})),Eg(n,i),t.dragMoveLocation=e.lngLat};var kg={exports:{}},Ng=kg.exports={};Ng.onSetup=function(){return this.setActionableState(),{}},Ng.toDisplayFeatures=function(t,e,i){i(e)};var Bg=rt(kg.exports);class zg{_map;_draw;drawType;_option;_featureObj={};_callback={};constructor(t){const e=t&&t.lineWidth?t.lineWidth/5:1;this._option=Object.assign({color:"rgba(223,168,32,1)",lineColor:"rgba(223,168,32,1)",fillColor:"rgba(223,168,32,0.1)",lineWidth:2,pixelSize:4,pointType:"circle",dash:e,iconSize:1,iconOffset:[0,0],polygonType:"color"},t),this._map=cNt.value;let i=[];this._option.pointType&&(i=this._setPointStyle(this._option.pointType));let n={};n="image"==this._option.polygonType?{"fill-pattern":["get","user_polygonImage"]}:{"fill-color":["get","user_fillColor"]},this._draw=new Gf({userProperties:!0,displayControlsDefault:!1,modes:{...Gf.modes,direct_select:Tg,simple_select:Rg,static:Bg,drawRectangle:Gm,radiusCircleMode:Nm,drawSymbol:Bm,drawLineString:Fm,drawPolygon:Vm,drawPoint:jm,drawAttackArrow:Cm},styles:[{id:"gl-draw-polygon-fill",type:"fill",filter:["all",["==","$type","Polygon"],["!=","mode","static"]],paint:n},{id:"gl-draw-line",type:"line",filter:["all",["==","$type","LineString"],["!=","mode","static"]],layout:{},paint:{"line-color":["get","user_lineColor"],"line-width":["get","user_lineWidth"]}},...i,{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":["get","lineWidth"],"circle-color":["get","lineColor"]}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["!=","mode","static"]],layout:{},paint:{"line-color":["get","user_lineColor"],"line-width":["get","user_lineWidth"]}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":["get","lineWidth"],"circle-color":["get","lineColor"],"circle-stroke-width":1,"circle-stroke-color":"#ffffff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":["get","lineWidth"],"circle-color":["get","lineColor"],"circle-stroke-width":1,"circle-stroke-color":"#ffffff"}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","$type","LineString"],["==","mode","static"]],layout:{},paint:{"line-color":["get","user_lineColor"],"line-width":["get","user_lineWidth"]}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","$type","Polygon"],["==","mode","static"]],paint:n},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","$type","Polygon"],["==","mode","static"]],layout:{},paint:{"line-color":["get","user_lineColor"],"line-width":["get","user_lineWidth"]}}]}),this.drawType="multiple",this._map.addControl(this._draw),"view"===this.drawType&&this.enableEdit(!1)}initListener(t,e){this._map._listeners["draw.create"]&&(this._map._listeners["draw.create"]=void 0),this._map._listeners["draw.update"]&&(this._map._listeners["draw.update"]=void 0),this._map._listeners["draw.delete"]&&(this._map._listeners["draw.delete"]=void 0),this._map.on("draw.create",(i=>{if("function"==typeof t){const n=i.features[0].geometry.coordinates,r=i.features[0].id,o={id:r,positionData:n};if(this._featureObj[r]=i.features,this._callback[r]=t,"circle"===e){const{centerPoint:t,radius:e}=this._getCenterAndRadius(n);o.centerPoint=t,o.radius=e}t(o)}const n=i.features[0].id;this.singleClear(n)})),this._map.on("draw.update",(i=>{if("function"==typeof t){const n=i.features[0].geometry.coordinates,r=i.features[0].id,o={id:r,positionData:n};if(this._featureObj[r]=i.features,this._callback[r]=t,"circle"===e){const{centerPoint:t,radius:e}=this._getCenterAndRadius(n);o.centerPoint=t,o.radius=e}t(o)}}))}_getCenterAndRadius(t){const e=wt(O(t)),i=pt(R(t[0][0]),R(e.geometry.coordinates),{units:"kilometers"});return{centerPoint:e.geometry.coordinates,radius:i}}addRectangle(t,e){if(e=e||{},this._draw){const t=this._setPolygonStyle(e);this._draw.changeMode("drawRectangle",t),console.log("开始绘制")}this.initListener(t)}addCircle(t,e){if(e=e||{},this._draw){const t=this._setPolygonStyle(e);this._draw.changeMode("radiusCircleMode",t)}this.initListener(t,"circle")}addPolygon(t,e){e=e||{};if(this._draw){const t=this._setPolygonStyle(e);this._draw.changeMode("drawPolygon",t)}this.initListener(t)}addPoint(t,e){e=e||{};let i="drawPoint",n={};if("icon"==this._option.pointType&&e.color)throw new Error("'pointType' is 'icon'. need to get 'pointIcon', but get 'color'");if("circle"==this._option.pointType&&e.pointIcon)throw new Error("'polygonType' is 'circle'. need to get 'color', but get 'pointIcon'");if("icon"==this._option.pointType){if(i="drawSymbol",n={pointIcon:"",iconSize:e.iconSize||this._option.iconSize,iconOffset:e.iconOffset||this._option.iconOffset},e.pointIcon||this._option.pointIcon){const t=d(0,25);this._option.pointIcon&&this.initImage(this._option.pointIcon,t),e.pointIcon&&this.initImage(e.pointIcon,t),n.pointIcon=t}}else n={pixelSize:e.pixelSize||this._option.pixelSize,color:e.color||this._option.color};this._draw&&this._draw.changeMode(i,n),this.initListener(t)}addLine(t,e){e=e||{},this._draw&&this._draw.changeMode("drawLineString",{featureId:"",from:[],lineColor:e.lineColor||this._option.lineColor,lineWidth:e.lineWidth||this._option.lineWidth}),this.initListener(t)}addGeoJson(t,e){let i=[];Array.isArray(t)?t.forEach((t=>{this._draw&&(t&&t.features.length&&t.features.forEach((i=>{const n=JSON.parse(JSON.stringify(this._option));this._featureObj[i.id]=[t],this._callback[i.id]=e;const r=Object.assign(n,i.properties);if(r.pointIcon){const t=d(0,25);r.pointIcon&&this.initImage(r.pointIcon,t),r.pointIcon=t}if(r.polygonImage){const t=d(0,25);r.polygonImage&&this.initImage(r.polygonImage,t),r.polygonImage=t}i.properties={...r}})),i=i.concat(this._draw.add(t)))})):(t&&t.features.length&&t.features.forEach((t=>{const i=JSON.parse(JSON.stringify(this._option)),n=Object.assign(i,t.properties);if(this._featureObj[t.id]=[t],this._callback[t.id]=e,n.pointIcon){const t=d(0,25);n.pointIcon&&this.initImage(n.pointIcon,t),n.pointIcon=t}if(n.polygonImage){const t=d(0,25);n.polygonImage&&this.initImage(n.polygonImage,t),n.polygonImage=t}t.properties={...n}})),this._draw&&(i=this._draw.add(t))),this.singleClear(i),this.initListener(e)}stopDraw(){this._draw&&this._draw.changeMode("simpleSelect",{featureIds:[]})}enableEdit(t){t?this._draw&&this._draw.changeMode("simpleSelect",{featureIds:[]}):this._draw&&this._draw.changeMode("static")}singleClear(t){if("single"===this.drawType){this._draw.getAll().features.forEach((e=>{if(-1===t.indexOf(e.id)){const t=[e.id];this._draw.delete(t)}}))}}updateStyle(t,e){if(!t||!this._featureObj[t])throw new Error(`ID '${t}' does not exist. `);this.clear(t);const i=this._featureObj[t];i&&(i.map((t=>{t.properties={...t.properties,...e}})),this.addGeoJson({type:"FeatureCollection",features:i},this._callback[t]))}clear(t){t?this._draw.delete([t]):this.clearAll()}clearAll(){this._draw.deleteAll(),this._featureObj={}}destroy(){this._draw&&(this.clearAll(),this._draw.onRemove(this._map))}initImage(t,e){cNt.value.loadImage(t,((t,i)=>{if(t)throw t;cNt.value.hasImage(e)?(cNt.value.removeImage(e),cNt.value.addImage(e,i)):cNt.value.addImage(e,i)}))}_setPointStyle(t){let e=[];return e="circle"==t?[{id:"gl-draw-point",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","meta","vertex"],["!=","mode","static"]],layout:{},paint:{"circle-radius":["get","user_pixelSize"],"circle-color":["get","user_color"]}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","$type","Point"],["==","mode","static"]],layout:{},paint:{"circle-radius":["get","user_pixelSize"],"circle-color":["get","user_color"]}}]:[{id:"gl-draw-point",type:"symbol",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","meta","vertex"],["!=","mode","static"]],layout:{"icon-image":["get","user_pointIcon"],"icon-size":["get","user_iconSize"],"icon-offset":["get","user_iconOffset"],"icon-anchor":"bottom","icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{}},{id:"gl-draw-point-static",type:"symbol",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","meta","vertex"],["!=","mode","static"]],layout:{"icon-image":["get","user_pointIcon"],"icon-size":["get","user_iconSize"],"icon-offset":["get","user_iconOffset"],"icon-anchor":"bottom","icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{}}],e}_setPolygonStyle(t){if("image"==this._option.polygonType&&t.fillColor)throw new Error("'polygonType' is 'image'. need to get 'polygonImage', but get 'fillColor'");if("color"==this._option.polygonType&&t.polygonImage)throw new Error("'polygonType' is 'color'. need to get 'fillColor', but get 'polygonImage'");const e={fillColor:t.fillColor||this._option.fillColor,lineColor:t.lineColor||this._option.lineColor,lineWidth:t.lineWidth||this._option.lineWidth,polygonType:t.polygonType||this._option.polygonType,polygonImage:""};if(("image"==t.polygonType||"image"==this._option.polygonType)&&(t.polygonImage||this._option.polygonImage)){const i=d(0,25);this._option.polygonImage&&this.initImage(this._option.polygonImage,i),t.polygonImage&&this.initImage(t.polygonImage,i),e.polygonImage=i}return e}}Rf(".ePopup {\n border-radius: 6px;\n width: 418px;\n height: 318px;\n display: flex;\n justify-content: center;\n}\n.ePopup-light-triangle {\n background-size: 100% 100%;\n}\n.ePopup-light-notriangle {\n background-size: 100% 100%;\n}\n.ePopup-dark-triangle {\n background-size: 100% 100%;\n}\n.ePopup-dark-notriangle {\n background-size: 100% 100%;\n}\n.ePopup-content {\n width: 400px;\n height: 280px;\n margin-top: 6px;\n border-radius: 6px;\n padding: 0 10px;\n box-sizing: border-box;\n}\n.ePopup-content-title {\n width: 100%;\n height: 40px;\n padding-left: 35px;\n padding-right: 14px;\n padding-top: 10px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n font-family: Source Han Sans CN;\n font-size: 18px;\n font-weight: bold;\n line-height: normal;\n box-sizing: border-box;\n}\n.ePopup-content-title--text {\n width: calc(100% - 50px);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ePopup-content-title--close {\n width: 16px;\n height: 16px;\n cursor: pointer;\n}\n.ePopup-content-title--close-light {\n background-size: cover;\n}\n.ePopup-content-title--close-dark {\n background-size: cover;\n}\n.ePopup-content-main {\n width: 100%;\n height: calc(100% - 50px);\n padding: 25px;\n padding-right: 16px;\n box-sizing: border-box;\n}\n.ePopup-content-main-light {\n overflow: auto;\n width: 100%;\n height: 100%;\n}\n.ePopup-content-main-dark {\n overflow: auto;\n width: 100%;\n height: 100%;\n}\n.ePopup-content-main-item {\n display: flex;\n justify-content: space-between;\n font-family: Source Han Sans CN;\n margin-bottom: 16px;\n}\n.ePopup-content-main-item--label {\n font-size: 14px;\n}\n.ePopup-content-main-item--text {\n font-size: 14px;\n font-weight: 600;\n}\n\n.ePopup-content-main::-webkit-scrollbar {\n width: 4px;\n}\n\n.ePopup-content-main-light::-webkit-scrollbar-thumb {\n background: #66A2FE;\n border-radius: 4px;\n -webkit-box-shadow: none;\n}\n\n.ePopup-content-main-light::-webkit-scrollbar-track {\n background: #E0EDFF;\n border-radius: 4px;\n -webkit-box-shadow: none;\n}\n\n.ePopup-content-main-dark::-webkit-scrollbar-thumb {\n background: #FFFFFF;\n border-radius: 4px;\n -webkit-box-shadow: none;\n}\n\n.ePopup-content-main-dark::-webkit-scrollbar-track {\n background: #5076B2;\n border-radius: 4px;\n -webkit-box-shadow: none;\n}");function Fg(t,e){const i=Object.create(null),n=t.split(",");for(let t=0;t!!i[t.toLowerCase()]:t=>!!i[t]}const Vg="production"!==process.env.NODE_ENV?Object.freeze({}):{},Ug="production"!==process.env.NODE_ENV?Object.freeze([]):[],Gg=()=>{},jg=()=>!1,Hg=/^on[^a-z]/,Wg=t=>Hg.test(t),qg=t=>t.startsWith("onUpdate:"),Xg=Object.assign,Zg=(t,e)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)},Yg=Object.prototype.hasOwnProperty,Qg=(t,e)=>Yg.call(t,e),Jg=Array.isArray,Kg=t=>"[object Map]"===sy(t),$g=t=>"[object Set]"===sy(t),ty=t=>"function"==typeof t,ey=t=>"string"==typeof t,iy=t=>"symbol"==typeof t,ny=t=>null!==t&&"object"==typeof t,ry=t=>(ny(t)||ty(t))&&ty(t.then)&&ty(t.catch),oy=Object.prototype.toString,sy=t=>oy.call(t),ay=t=>sy(t).slice(8,-1),ly=t=>"[object Object]"===sy(t),cy=t=>ey(t)&&"NaN"!==t&&"-"!==t[0]&&""+parseInt(t,10)===t,uy=Fg(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),hy=Fg("bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"),py=t=>{const e=Object.create(null);return i=>e[i]||(e[i]=t(i))},dy=/-(\w)/g,fy=py((t=>t.replace(dy,((t,e)=>e?e.toUpperCase():"")))),my=/\B([A-Z])/g,gy=py((t=>t.replace(my,"-$1").toLowerCase())),yy=py((t=>t.charAt(0).toUpperCase()+t.slice(1))),vy=py((t=>t?`on${yy(t)}`:"")),_y=(t,e)=>!Object.is(t,e),xy=(t,e)=>{for(let i=0;i{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,value:i})},wy=t=>{const e=parseFloat(t);return isNaN(e)?t:e};let Ay;const Ey=()=>Ay||(Ay="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{});function Sy(t){if(Jg(t)){const e={};for(let i=0;i{if(t){const i=t.split(Ty);i.length>1&&(e[i[0].trim()]=i[1].trim())}})),e}function Py(t){let e="";if(ey(t))e=t;else if(Jg(t))for(let i=0;i{const e=new Set(t);return e.w=0,e.n=0,e},Fy=t=>(t.w&jy)>0,Vy=t=>(t.n&jy)>0,Uy=new WeakMap;let Gy=0,jy=1;const Hy=30;let Wy;const qy=Symbol("production"!==process.env.NODE_ENV?"iterate":""),Xy=Symbol("production"!==process.env.NODE_ENV?"Map key iterate":"");class Zy{constructor(t,e=null,i){this.fn=t,this.scheduler=e,this.active=!0,this.deps=[],this.parent=void 0,function(t,e=Ny){e&&e.active&&e.effects.push(t)}(this,i)}run(){if(!this.active)return this.fn();let t=Wy,e=Qy;for(;t;){if(t===this)return;t=t.parent}try{return this.parent=Wy,Wy=this,Qy=!0,jy=1<<++Gy,Gy<=Hy?(({deps:t})=>{if(t.length)for(let e=0;e{const{deps:e}=t;if(e.length){let i=0;for(let n=0;n{("length"===i||!iy(i)&&i>=t)&&a.push(e)}))}else switch(void 0!==i&&a.push(s.get(i)),e){case"add":Jg(t)?cy(i)&&a.push(s.get("length")):(a.push(s.get(qy)),Kg(t)&&a.push(s.get(Xy)));break;case"delete":Jg(t)||(a.push(s.get(qy)),Kg(t)&&a.push(s.get(Xy)));break;case"set":Kg(t)&&a.push(s.get(qy))}const l="production"!==process.env.NODE_ENV?{target:t,type:e,key:i,newValue:n,oldValue:r,oldTarget:o}:void 0;if(1===a.length)a[0]&&("production"!==process.env.NODE_ENV?nv(a[0],l):nv(a[0]));else{const t=[];for(const e of a)e&&t.push(...e);"production"!==process.env.NODE_ENV?nv(zy(t),l):nv(zy(t))}}function nv(t,e){const i=Jg(t)?t:[...t];for(const t of i)t.computed&&rv(t,e);for(const t of i)t.computed||rv(t,e)}function rv(t,e){(t!==Wy||t.allowRecurse)&&("production"!==process.env.NODE_ENV&&t.onTrigger&&t.onTrigger(Xg({effect:t},e)),t.scheduler?t.scheduler():t.run())}const ov=Fg("__proto__,__v_isRef,__isVue"),sv=new Set(Object.getOwnPropertyNames(Symbol).filter((t=>"arguments"!==t&&"caller"!==t)).map((t=>Symbol[t])).filter(iy)),av=lv();function lv(){const t={};return["includes","indexOf","lastIndexOf"].forEach((e=>{t[e]=function(...t){const i=Kv(this);for(let t=0,e=this.length;t{t[e]=function(...t){Ky();const i=Kv(this)[e].apply(this,t);return $y(),i}})),t}function cv(t){const e=Kv(this);return tv(e,"has",t),e.hasOwnProperty(t)}class uv{constructor(t=!1,e=!1){this._isReadonly=t,this._shallow=e}get(t,e,i){const n=this._isReadonly,r=this._shallow;if("__v_isReactive"===e)return!n;if("__v_isReadonly"===e)return n;if("__v_isShallow"===e)return r;if("__v_raw"===e&&i===(n?r?jv:Gv:r?Uv:Vv).get(t))return t;const o=Jg(t);if(!n){if(o&&Qg(av,e))return Reflect.get(av,e,i);if("hasOwnProperty"===e)return cv}const s=Reflect.get(t,e,i);return(iy(e)?sv.has(e):ov(e))?s:(n||tv(t,"get",e),r?s:i_(s)?o&&cy(e)?s:s.value:ny(s)?n?Wv(s):Hv(s):s)}}class hv extends uv{constructor(t=!1){super(!1,t)}set(t,e,i,n){let r=t[e];if(Yv(r)&&i_(r)&&!i_(i))return!1;if(!this._shallow&&(Qv(i)||Yv(i)||(r=Kv(r),i=Kv(i)),!Jg(t)&&i_(r)&&!i_(i)))return r.value=i,!0;const o=Jg(t)&&cy(e)?Number(e)t,vv=t=>Reflect.getPrototypeOf(t);function _v(t,e,i=!1,n=!1){const r=Kv(t=t.__v_raw),o=Kv(e);i||(_y(e,o)&&tv(r,"get",e),tv(r,"get",o));const{has:s}=vv(r),a=n?yv:i?e_:t_;return s.call(r,e)?a(t.get(e)):s.call(r,o)?a(t.get(o)):void(t!==r&&t.get(e))}function xv(t,e=!1){const i=this.__v_raw,n=Kv(i),r=Kv(t);return e||(_y(t,r)&&tv(n,"has",t),tv(n,"has",r)),t===r?i.has(t):i.has(t)||i.has(r)}function bv(t,e=!1){return t=t.__v_raw,!e&&tv(Kv(t),"iterate",qy),Reflect.get(t,"size",t)}function wv(t){t=Kv(t);const e=Kv(this);return vv(e).has.call(e,t)||(e.add(t),iv(e,"add",t,t)),this}function Av(t,e){e=Kv(e);const i=Kv(this),{has:n,get:r}=vv(i);let o=n.call(i,t);o?"production"!==process.env.NODE_ENV&&Fv(i,n,t):(t=Kv(t),o=n.call(i,t));const s=r.call(i,t);return i.set(t,e),o?_y(e,s)&&iv(i,"set",t,e,s):iv(i,"add",t,e),this}function Ev(t){const e=Kv(this),{has:i,get:n}=vv(e);let r=i.call(e,t);r?"production"!==process.env.NODE_ENV&&Fv(e,i,t):(t=Kv(t),r=i.call(e,t));const o=n?n.call(e,t):void 0,s=e.delete(t);return r&&iv(e,"delete",t,void 0,o),s}function Sv(){const t=Kv(this),e=0!==t.size,i="production"!==process.env.NODE_ENV?Kg(t)?new Map(t):new Set(t):void 0,n=t.clear();return e&&iv(t,"clear",void 0,void 0,i),n}function Mv(t,e){return function(i,n){const r=this,o=r.__v_raw,s=Kv(o),a=e?yv:t?e_:t_;return!t&&tv(s,"iterate",qy),o.forEach(((t,e)=>i.call(n,a(t),a(e),r)))}}function Tv(t,e,i){return function(...n){const r=this.__v_raw,o=Kv(r),s=Kg(o),a="entries"===t||t===Symbol.iterator&&s,l="keys"===t&&s,c=r[t](...n),u=i?yv:e?e_:t_;return!e&&tv(o,"iterate",l?Xy:qy),{next(){const{value:t,done:e}=c.next();return e?{value:t,done:e}:{value:a?[u(t[0]),u(t[1])]:u(t),done:e}},[Symbol.iterator](){return this}}}}function Iv(t){return function(...e){if("production"!==process.env.NODE_ENV){const i=e[0]?`on key "${e[0]}" `:"";console.warn(`${yy(t)} operation ${i}failed: target is readonly.`,Kv(this))}return"delete"!==t&&this}}function Cv(){const t={get(t){return _v(this,t)},get size(){return bv(this)},has:xv,add:wv,set:Av,delete:Ev,clear:Sv,forEach:Mv(!1,!1)},e={get(t){return _v(this,t,!1,!0)},get size(){return bv(this)},has:xv,add:wv,set:Av,delete:Ev,clear:Sv,forEach:Mv(!1,!0)},i={get(t){return _v(this,t,!0)},get size(){return bv(this,!0)},has(t){return xv.call(this,t,!0)},add:Iv("add"),set:Iv("set"),delete:Iv("delete"),clear:Iv("clear"),forEach:Mv(!0,!1)},n={get(t){return _v(this,t,!0,!0)},get size(){return bv(this,!0)},has(t){return xv.call(this,t,!0)},add:Iv("add"),set:Iv("set"),delete:Iv("delete"),clear:Iv("clear"),forEach:Mv(!0,!0)};return["keys","values","entries",Symbol.iterator].forEach((r=>{t[r]=Tv(r,!1,!1),i[r]=Tv(r,!0,!1),e[r]=Tv(r,!1,!0),n[r]=Tv(r,!0,!0)})),[t,i,e,n]}const[Pv,Lv,Dv,Rv]=Cv();function Ov(t,e){const i=e?t?Rv:Dv:t?Lv:Pv;return(e,n,r)=>"__v_isReactive"===n?!t:"__v_isReadonly"===n?t:"__v_raw"===n?e:Reflect.get(Qg(i,n)&&n in e?i:e,n,r)}const kv={get:Ov(!1,!1)},Nv={get:Ov(!1,!0)},Bv={get:Ov(!0,!1)},zv={get:Ov(!0,!0)};function Fv(t,e,i){const n=Kv(i);if(n!==i&&e.call(t,n)){const e=ay(t);console.warn(`Reactive ${e} contains both the raw and reactive versions of the same object${"Map"===e?" as keys":""}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`)}}const Vv=new WeakMap,Uv=new WeakMap,Gv=new WeakMap,jv=new WeakMap;function Hv(t){return Yv(t)?t:Xv(t,!1,dv,kv,Vv)}function Wv(t){return Xv(t,!0,fv,Bv,Gv)}function qv(t){return Xv(t,!0,gv,zv,jv)}function Xv(t,e,i,n,r){if(!ny(t))return"production"!==process.env.NODE_ENV&&console.warn(`value cannot be made reactive: ${String(t)}`),t;if(t.__v_raw&&(!e||!t.__v_isReactive))return t;const o=r.get(t);if(o)return o;const s=(a=t).__v_skip||!Object.isExtensible(a)?0:function(t){switch(t){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}(ay(a));var a;if(0===s)return t;const l=new Proxy(t,2===s?n:i);return r.set(t,l),l}function Zv(t){return Yv(t)?Zv(t.__v_raw):!(!t||!t.__v_isReactive)}function Yv(t){return!(!t||!t.__v_isReadonly)}function Qv(t){return!(!t||!t.__v_isShallow)}function Jv(t){return Zv(t)||Yv(t)}function Kv(t){const e=t&&t.__v_raw;return e?Kv(e):t}function $v(t){return by(t,"__v_skip",!0),t}const t_=t=>ny(t)?Hv(t):t,e_=t=>ny(t)?Wv(t):t;function i_(t){return!(!t||!0!==t.__v_isRef)}const n_={get:(t,e,i)=>{return i_(n=Reflect.get(t,e,i))?n.value:n;var n},set:(t,e,i,n)=>{const r=t[e];return i_(r)&&!i_(i)?(r.value=i,!0):Reflect.set(t,e,i,n)}};function r_(t){return Zv(t)?t:new Proxy(t,n_)}class o_{constructor(t,e,i,n){this._setter=e,this.dep=void 0,this.__v_isRef=!0,this.__v_isReadonly=!1,this._dirty=!0,this.effect=new Zy(t,(()=>{this._dirty||(this._dirty=!0,function(t,e){const i=(t=Kv(t)).dep;i&&("production"!==process.env.NODE_ENV?nv(i,{target:t,type:"set",key:"value",newValue:e}):nv(i))}(this))})),this.effect.computed=this,this.effect.active=this._cacheable=!n,this.__v_isReadonly=i}get value(){const t=Kv(this);var e;return e=t,Qy&&Wy&&(e=Kv(e),"production"!==process.env.NODE_ENV?ev(e.dep||(e.dep=zy()),{target:e,type:"get",key:"value"}):ev(e.dep||(e.dep=zy()))),!t._dirty&&t._cacheable||(t._dirty=!1,t._value=t.effect.run()),t._value}set value(t){this._setter(t)}}const s_=[];function a_(t){s_.push(t)}function l_(){s_.pop()}function c_(t,...e){if("production"===process.env.NODE_ENV)return;Ky();const i=s_.length?s_[s_.length-1].component:null,n=i&&i.appContext.config.warnHandler,r=function(){let t=s_[s_.length-1];if(!t)return[];const e=[];for(;t;){const i=e[0];i&&i.vnode===t?i.recurseCount++:e.push({vnode:t,recurseCount:0});const n=t.component&&t.component.parent;t=n&&n.vnode}return e}();if(n)d_(n,i,11,[t+e.join(""),i&&i.proxy,r.map((({vnode:t})=>`at <${Ow(i,t.type)}>`)).join("\n"),r]);else{const i=[`[Vue warn]: ${t}`,...e];r.length&&i.push("\n",...function(t){const e=[];return t.forEach(((t,i)=>{e.push(...0===i?[]:["\n"],...function({vnode:t,recurseCount:e}){const i=e>0?`... (${e} recursive calls)`:"",n=!!t.component&&null==t.component.parent,r=` at <${Ow(t.component,t.type,n)}`,o=">"+i;return t.props?[r,...u_(t.props),o]:[r+o]}(t))})),e}(r)),console.warn(...i)}$y()}function u_(t){const e=[],i=Object.keys(t);return i.slice(0,3).forEach((i=>{e.push(...h_(i,t[i]))})),i.length>3&&e.push(" ..."),e}function h_(t,e,i){return ey(e)?(e=JSON.stringify(e),i?e:[`${t}=${e}`]):"number"==typeof e||"boolean"==typeof e||null==e?i?e:[`${t}=${e}`]:i_(e)?(e=h_(t,Kv(e.value),!0),i?e:[`${t}=Ref<`,e,">"]):ty(e)?[`${t}=fn${e.name?`<${e.name}>`:""}`]:(e=Kv(e),i?e:[`${t}=`,e])}const p_={sp:"serverPrefetch hook",bc:"beforeCreate hook",c:"created hook",bm:"beforeMount hook",m:"mounted hook",bu:"beforeUpdate hook",u:"updated",bum:"beforeUnmount hook",um:"unmounted hook",a:"activated hook",da:"deactivated hook",ec:"errorCaptured hook",rtc:"renderTracked hook",rtg:"renderTriggered hook",0:"setup function",1:"render function",2:"watcher getter",3:"watcher callback",4:"watcher cleanup function",5:"native event handler",6:"component event handler",7:"vnode hook",8:"directive hook",9:"transition hook",10:"app errorHandler",11:"app warnHandler",12:"ref function",13:"async component loader",14:"scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core"};function d_(t,e,i,n){let r;try{r=n?t(...n):t()}catch(t){m_(t,e,i)}return r}function f_(t,e,i,n){if(ty(t)){const r=d_(t,e,i,n);return r&&ry(r)&&r.catch((t=>{m_(t,e,i)})),r}const r=[];for(let o=0;o>>1,r=v_[n],o=D_(r);oD_(t)-D_(e))),w_=0;w_null==t.id?1/0:t.id,R_=(t,e)=>{const i=D_(t)-D_(e);if(0===i){if(t.pre&&!e.pre)return-1;if(e.pre&&!t.pre)return 1}return i};function O_(t){y_=!1,g_=!0,"production"!==process.env.NODE_ENV&&(t=t||new Map),v_.sort(R_);const e="production"!==process.env.NODE_ENV?e=>k_(t,e):Gg;try{for(__=0;__S_){const t=e.ownerInstance,i=t&&Rw(t.type);return c_(`Maximum recursive updates exceeded${i?` in component <${i}>`:""}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`),!0}t.set(e,i+1)}else t.set(e,1)}let N_=!1;const B_=new Set;"production"!==process.env.NODE_ENV&&(Ey().__VUE_HMR_RUNTIME__={createRecord:G_(F_),rerender:G_((function(t,e){const i=z_.get(t);if(!i)return;i.initialDef.render=e,[...i.instances].forEach((t=>{e&&(t.render=e,V_(t.type).render=e),t.renderCache=[],N_=!0,t.update(),N_=!1}))})),reload:G_((function(t,e){const i=z_.get(t);if(!i)return;e=V_(e),U_(i.initialDef,e);const n=[...i.instances];for(const t of n){const n=V_(t.type);B_.has(n)||(n!==i.initialDef&&U_(n,e),B_.add(n)),t.appContext.propsCache.delete(t.type),t.appContext.emitsCache.delete(t.type),t.appContext.optionsCache.delete(t.type),t.ceReload?(B_.add(n),t.ceReload(e.styles),B_.delete(n)):t.parent?T_(t.parent.update):t.appContext.reload?t.appContext.reload():"undefined"!=typeof window?window.location.reload():console.warn("[HMR] Root or manually mounted instance modified. Full reload required.")}C_((()=>{for(const t of n)B_.delete(V_(t.type))}))}))});const z_=new Map;function F_(t,e){return!z_.has(t)&&(z_.set(t,{initialDef:V_(e),instances:new Set}),!0)}function V_(t){return kw(t)?t.__vccOpts:t}function U_(t,e){Xg(t,e);for(const i in t)"__file"===i||i in e||delete t[i]}function G_(t){return(e,i)=>{try{return t(e,i)}catch(t){console.error(t),console.warn("[HMR] Something went wrong during Vue component hot-reload. Full reload required.")}}}let j_,H_=[],W_=!1;function q_(t,...e){j_?j_.emit(t,...e):W_||H_.push({event:t,args:e})}function X_(t,e){var i,n;if(j_=t,j_)j_.enabled=!0,H_.forEach((({event:t,args:e})=>j_.emit(t,...e))),H_=[];else if("undefined"!=typeof window&&window.HTMLElement&&!(null==(n=null==(i=window.navigator)?void 0:i.userAgent)?void 0:n.includes("jsdom"))){(e.__VUE_DEVTOOLS_HOOK_REPLAY__=e.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push((t=>{X_(t,e)})),setTimeout((()=>{j_||(e.__VUE_DEVTOOLS_HOOK_REPLAY__=null,W_=!0,H_=[])}),3e3)}else W_=!0,H_=[]}const Z_=K_("component:added"),Y_=K_("component:updated"),Q_=K_("component:removed"),J_=t=>{j_&&"function"==typeof j_.cleanupBuffer&&!j_.cleanupBuffer(t)&&Q_(t)};function K_(t){return e=>{q_(t,e.appContext.app,e.uid,e.parent?e.parent.uid:void 0,e)}}const $_=ex("perf:start"),tx=ex("perf:end");function ex(t){return(e,i,n)=>{q_(t,e.appContext.app,e.uid,e,i,n)}}function ix(t,e,...i){if(t.isUnmounted)return;const n=t.vnode.props||Vg;if("production"!==process.env.NODE_ENV){const{emitsOptions:n,propsOptions:[r]}=t;if(n)if(e in n){const t=n[e];if(ty(t)){t(...i)||c_(`Invalid event arguments: event validation failed for event "${e}".`)}}else r&&vy(e)in r||c_(`Component emitted event "${e}" but it is neither declared in the emits option nor as an "${vy(e)}" prop.`)}let r=i;const o=e.startsWith("update:"),s=o&&e.slice(7);if(s&&s in n){const t=`${"modelValue"===s?"model":s}Modifiers`,{number:e,trim:o}=n[t]||Vg;o&&(r=i.map((t=>ey(t)?t.trim():t))),e&&(r=i.map(wy))}if(("production"!==process.env.NODE_ENV||__VUE_PROD_DEVTOOLS__)&&function(t,e,i){q_("component:emit",t.appContext.app,t,e,i)}(t,e,r),"production"!==process.env.NODE_ENV){const i=e.toLowerCase();i!==e&&n[vy(i)]&&c_(`Event "${i}" is emitted in component ${Ow(t,t.type)} but the handler is registered for "${e}". Note that HTML attributes are case-insensitive and you cannot use v-on to listen to camelCase events when using in-DOM templates. You should probably use "${gy(e)}" instead of "${e}".`)}let a,l=n[a=vy(e)]||n[a=vy(fy(e))];!l&&o&&(l=n[a=vy(gy(e))]),l&&f_(l,t,6,r);const c=n[a+"Once"];if(c){if(t.emitted){if(t.emitted[a])return}else t.emitted={};t.emitted[a]=!0,f_(c,t,6,r)}}function nx(t,e,i=!1){const n=e.emitsCache,r=n.get(t);if(void 0!==r)return r;const o=t.emits;let s={},a=!1;if(__VUE_OPTIONS_API__&&!ty(t)){const n=t=>{const i=nx(t,e,!0);i&&(a=!0,Xg(s,i))};!i&&e.mixins.length&&e.mixins.forEach(n),t.extends&&n(t.extends),t.mixins&&t.mixins.forEach(n)}return o||a?(Jg(o)?o.forEach((t=>s[t]=null)):Xg(s,o),ny(t)&&n.set(t,s),s):(ny(t)&&n.set(t,null),null)}function rx(t,e){return!(!t||!Wg(e))&&(e=e.slice(2).replace(/Once$/,""),Qg(t,e[0].toLowerCase()+e.slice(1))||Qg(t,gy(e))||Qg(t,e))}let ox=null,sx=null;function ax(t){const e=ox;return ox=t,sx=t&&t.type.__scopeId||null,e}let lx=!1;function cx(){lx=!0}function ux(t){const{type:e,vnode:i,proxy:n,withProxy:r,props:o,propsOptions:[s],slots:a,attrs:l,emit:c,render:u,renderCache:h,data:p,setupState:d,ctx:f,inheritAttrs:m}=t;let g,y;const v=ax(t);"production"!==process.env.NODE_ENV&&(lx=!1);try{if(4&i.shapeFlag){const t=r||n;g=cw(u.call(t,t,h,o,d,p,f)),y=l}else{const t=e;"production"!==process.env.NODE_ENV&&l===o&&cx(),g=cw(t.length>1?t(o,"production"!==process.env.NODE_ENV?{get attrs(){return cx(),l},slots:a,emit:c}:{attrs:l,slots:a,emit:c}):t(o,null)),y=e.props?l:dx(l)}}catch(e){m_(e,t,1),g=rw(Zb)}let _,x=g;if("production"!==process.env.NODE_ENV&&g.patchFlag>0&&2048&g.patchFlag&&([x,_]=hx(g)),y&&!1!==m){const t=Object.keys(y),{shapeFlag:e}=x;if(t.length)if(7&e)s&&t.some(qg)&&(y=fx(y,s)),x=sw(x,y);else if("production"!==process.env.NODE_ENV&&!lx&&x.type!==Zb){const t=Object.keys(l),e=[],i=[];for(let n=0,r=t.length;n renders non-element root node that cannot be animated."),x.transition=i.transition),"production"!==process.env.NODE_ENV&&_?_(x):g=x,ax(v),g}const hx=t=>{const e=t.children,i=t.dynamicChildren,n=px(e);if(!n)return[t,void 0];const r=e.indexOf(n),o=i?i.indexOf(n):-1;return[cw(n),n=>{e[r]=n,i&&(o>-1?i[o]=n:n.patchFlag>0&&(t.dynamicChildren=[...i,n]))}]};function px(t){let e;for(let i=0;i{let e;for(const i in t)("class"===i||"style"===i||Wg(i))&&((e||(e={}))[i]=t[i]);return e},fx=(t,e)=>{const i={};for(const n in t)qg(n)&&n.slice(9)in e||(i[n]=t[n]);return i},mx=t=>7&t.shapeFlag||t.type===Zb;function gx(t,e,i){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!0;for(let r=0;r{c_("Invalid watch source: ",t,"A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types.")},c=Ny===(null==(a=yw)?void 0:a.scope)?yw:null;let u,h,p=!1,d=!1;if(i_(t)?(u=()=>t.value,p=Qv(t)):Zv(t)?(u=()=>t,n=!0):Jg(t)?(d=!0,p=t.some((t=>Zv(t)||Qv(t))),u=()=>t.map((t=>i_(t)?t.value:Zv(t)?Ax(t):ty(t)?d_(t,c,2):void("production"!==process.env.NODE_ENV&&l(t))))):ty(t)?u=e?()=>d_(t,c,2):()=>{if(!c||!c.isUnmounted)return h&&h(),f_(t,c,3,[m])}:(u=Gg,"production"!==process.env.NODE_ENV&&l(t)),e&&n){const t=u;u=()=>Ax(t())}let f,m=t=>{h=_.onStop=()=>{d_(t,c,4)}};if(Sw){if(m=Gg,e?i&&f_(e,c,3,[u(),d?[]:void 0,m]):u(),"sync"!==r)return Gg;{const t=Fw();f=t.__watcherHandles||(t.__watcherHandles=[])}}let g=d?new Array(t.length).fill(yx):yx;const y=()=>{if(_.active)if(e){const t=_.run();(n||p||(d?t.some(((t,e)=>_y(t,g[e]))):_y(t,g)))&&(h&&h(),f_(e,c,3,[t,g===yx?void 0:d&&g[0]===yx?[]:g,m]),g=t)}else _.run()};let v;y.allowRecurse=!!e,"sync"===r?v=y:"post"===r?v=()=>Gb(y,c&&c.suspense):(y.pre=!0,c&&(y.id=c.uid),v=()=>T_(y));const _=new Zy(u,v);"production"!==process.env.NODE_ENV&&(_.onTrack=o,_.onTrigger=s),e?i?y():g=_.run():"post"===r?Gb(_.run.bind(_),c&&c.suspense):_.run();const x=()=>{_.stop(),c&&c.scope&&Zg(c.scope.effects,_)};return f&&f.push(x),x}function xx(t,e,i){const n=this.proxy,r=ey(t)?t.includes(".")?bx(n,t):()=>n[t]:t.bind(n,n);let o;ty(e)?o=e:(o=e.handler,i=e);const s=yw;_w(this);const a=_x(r,o.bind(n),i);return s?_w(s):xw(),a}function bx(t,e){const i=e.split(".");return()=>{let e=t;for(let t=0;t{Ax(t,e)}));else if(ly(t))for(const i in t)Ax(t[i],e);return t}function Ex(t){hy(t)&&c_("Do not use built-in directive ids as custom directive id: "+t)}function Sx(t,e,i,n){const r=t.dirs,o=e&&e.dirs;for(let s=0;s!!t.type.__asyncLoader,Tx=t=>t.type.__isKeepAlive;function Ix(t,e){Px(t,"a",e)}function Cx(t,e){Px(t,"da",e)}function Px(t,e,i=yw){const n=t.__wdc||(t.__wdc=()=>{let e=i;for(;e;){if(e.isDeactivated)return;e=e.parent}return t()});if(Dx(e,n,i),i){let t=i.parent;for(;t&&t.parent;)Tx(t.parent.vnode)&&Lx(n,e,i,t),t=t.parent}}function Lx(t,e,i,n){const r=Dx(e,t,n,!0);Fx((()=>{Zg(n[e],r)}),i)}function Dx(t,e,i=yw,n=!1){if(i){const r=i[t]||(i[t]=[]),o=e.__weh||(e.__weh=(...n)=>{if(i.isUnmounted)return;Ky(),_w(i);const r=f_(e,i,t,n);return xw(),$y(),r});return n?r.unshift(o):r.push(o),o}if("production"!==process.env.NODE_ENV){c_(`${vy(p_[t].replace(/ hook$/,""))} is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.`)}}const Rx=t=>(e,i=yw)=>(!Sw||"sp"===t)&&Dx(t,((...t)=>e(...t)),i),Ox=Rx("bm"),kx=Rx("m"),Nx=Rx("bu"),Bx=Rx("u"),zx=Rx("bum"),Fx=Rx("um"),Vx=Rx("sp"),Ux=Rx("rtg"),Gx=Rx("rtc");function jx(t,e=yw){Dx("ec",t,e)}const Hx=Symbol.for("v-ndc"),Wx=t=>t?Aw(t)?Pw(t)||t.proxy:Wx(t.parent):null,qx=Xg(Object.create(null),{$:t=>t,$el:t=>t.vnode.el,$data:t=>t.data,$props:t=>"production"!==process.env.NODE_ENV?qv(t.props):t.props,$attrs:t=>"production"!==process.env.NODE_ENV?qv(t.attrs):t.attrs,$slots:t=>"production"!==process.env.NODE_ENV?qv(t.slots):t.slots,$refs:t=>"production"!==process.env.NODE_ENV?qv(t.refs):t.refs,$parent:t=>Wx(t.parent),$root:t=>Wx(t.root),$emit:t=>t.emit,$options:t=>__VUE_OPTIONS_API__?ib(t):t.type,$forceUpdate:t=>t.f||(t.f=()=>T_(t.update)),$nextTick:t=>t.n||(t.n=M_.bind(t.proxy)),$watch:t=>__VUE_OPTIONS_API__?xx.bind(t):Gg}),Xx=t=>"_"===t||"$"===t,Zx=(t,e)=>t!==Vg&&!t.__isScriptSetup&&Qg(t,e),Yx={get({_:t},e){const{ctx:i,setupState:n,data:r,props:o,accessCache:s,type:a,appContext:l}=t;if("production"!==process.env.NODE_ENV&&"__isVue"===e)return!0;let c;if("$"!==e[0]){const a=s[e];if(void 0!==a)switch(a){case 1:return n[e];case 2:return r[e];case 4:return i[e];case 3:return o[e]}else{if(Zx(n,e))return s[e]=1,n[e];if(r!==Vg&&Qg(r,e))return s[e]=2,r[e];if((c=t.propsOptions[0])&&Qg(c,e))return s[e]=3,o[e];if(i!==Vg&&Qg(i,e))return s[e]=4,i[e];__VUE_OPTIONS_API__&&!Jx||(s[e]=0)}}const u=qx[e];let h,p;return u?("$attrs"===e?(tv(t,"get",e),"production"!==process.env.NODE_ENV&&cx()):"production"!==process.env.NODE_ENV&&"$slots"===e&&tv(t,"get",e),u(t)):(h=a.__cssModules)&&(h=h[e])?h:i!==Vg&&Qg(i,e)?(s[e]=4,i[e]):(p=l.config.globalProperties,Qg(p,e)?p[e]:void("production"===process.env.NODE_ENV||!ox||ey(e)&&0===e.indexOf("__v")||(r!==Vg&&Xx(e[0])&&Qg(r,e)?c_(`Property ${JSON.stringify(e)} must be accessed via $data because it starts with a reserved character ("$" or "_") and is not proxied on the render context.`):t===ox&&c_(`Property ${JSON.stringify(e)} was accessed during render but is not defined on instance.`))))},set({_:t},e,i){const{data:n,setupState:r,ctx:o}=t;return Zx(r,e)?(r[e]=i,!0):"production"!==process.env.NODE_ENV&&r.__isScriptSetup&&Qg(r,e)?(c_(`Cannot mutate