@maptalks/vt 0.108.1 → 0.108.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @maptalks/vt v0.108.1
2
+ * @maptalks/vt v0.108.3
3
3
  * LICENSE : undefined
4
4
  * (c) 2016-2025 maptalks.org
5
5
  */
@@ -21,7 +21,7 @@
21
21
  })), t.default = e, Object.freeze(t);
22
22
  }
23
23
  var r = i(t), o = i(n);
24
- const s = "${", a = `function(t){let e;const n={width:100,height:10};let r=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),r=!0}catch(t){r=!1}function i(){if(!e){const{width:t,height:i}=n;r?e=new OffscreenCanvas(t,i):(e=document.createElement("canvas"),e.width=t,e.height=i)}return e}class o{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let r=1/0,i=-1/0;for(let e=0,n=t.length;e<n;e++){const n=t[e][0];r=Math.min(n,r),i=Math.max(n,i)}this.min=r,this.max=i,this.valueOffset=this.max-this.min,this.options=Object.assign({},n,e),this._initImgData()}getImageData(){return this.imgData}_initImgData(){const t=i(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const o=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:a}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/a;o.addColorStop(r,n)}r.fillStyle=o,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var s;function a(t){return null==t}function l(t){return!a(t)}function u(t){return""===t}function h(t,e){var n,r,i;if(w(t)){var o,s=t.stops&&"object"==typeof t.stops[0][0],a=s||l(t.property),u=s||!a,d=t.type||e||"exponential";if("exponential"===d)o=p;else if("interval"===d)o=f;else if("categorical"===d)o=c;else if("identity"===d)o=y;else if("color-interpolate"===d)o=g;else{if("calculate-expression"!==d)throw new Error('Unknown function type "'+d+'"');o=x}if(s){var m={},v=[];for(let e=0;e<t.stops.length;e++){var M=t.stops[e];void 0===m[M[0].zoom]&&(m[M[0].zoom]={zoom:M[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),m[M[0].zoom].stops.push([M[0].value,M[1]])}for(let t in m)v.push([m[t].zoom,h(m[t])]);n=function(e,n){const r=p({stops:v,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else u?(n=function(e){const n=o(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=o(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function c(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function f(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function p(t,e){for(var n=l(t.base)&&!u(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:m(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(s=new Map);const d={width:100,height:1};function g(t,e){const n=t.stops;if(n&&n.length>1){let t;if(s){const e=JSON.stringify(n);if(!s.has(e)){const t=new o(n,d);s.set(e,t)}t=s.get(e)}else t=new o(n,d);const[r,i,a,l]=t.getColor(e);return[r/255,i/255,a/255,l/255]}return n&&1===n.length?n[0][1]:null}function y(t,e){return n=e,r=t.default,l(n)?n:l(r)?r:l(i)?i:null;var n,r,i}function x(t,e){const n=String(t.property),r=t.expression,i=e;function o(e){return a(e)||u(e)||isNaN(e)?t.default:e}if(!l(e)||u(e)||isNaN(e)||e<0)return o(t.default);{const e=function t(e,n,r){const i=Number(r),o=String(n);return Array.isArray(e)?e.map((e=>t(e,o,i))):e===o?i:e}(r,n,i);return o(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(\`Unknown operator: ${s}r}\`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(\`Unsupported operator: ${s}r}\`)}}}(e))}}function m(t,e,n,r,i,o){return"function"==typeof i?function(){var s=i.apply(void 0,arguments),a=o.apply(void 0,arguments);return m(t,e,n,r,s,a)}:i.length?function(t,e,n,r,i,o){var s=[];for(let a=0;a<i.length;a++)s[a]=v(t,e,n,r,i[a],o[a]);return s}(t,e,n,r,i,o):v(t,e,n,r,i,o)}function v(t,e,n,r,i,o){var s,a=r-n,l=t-n;return i*(1-(s=1===e?l/a:(Math.pow(e,l)-1)/(Math.pow(e,a)-1)))+o*s}function w(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function M(t){return b(t,"interval")}function b(t,e){if(!w(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(w(i[t][1])){const o=b(i[t][1],e);n=n&&o.isZoomConstant,r=r&&o.isFeatureConstant,i[t]=[i[t][0],o]}const o=h(t,e);return o.isZoomConstant=n&&o.isZoomConstant,o.isFeatureConstant=r&&o.isFeatureConstant,o}let P=0;const _="function"==typeof Object.assign;function I(t,...e){if(_)return Object.assign(t,...e),t;for(let n=0;n<e.length;n++){const r=e[n];for(const e in r)t[e]=r[e]}return t}function A(t){return!k(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function S(t){return"number"==typeof t&&!isNaN(t)}function T(t){return!k(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function F(t){return!Array.isArray(t)&&"object"==typeof t&&!!t}function k(t){return null==t}function B(t){return w(t)&&t.property}const L="function"==typeof fetch&&"function"==typeof AbortController,C={jsonp:function(t,e){const n="_maptalks_jsonp_"+P++;t.match(/\\?/)?t+="&callback="+n:t+="?callback="+n;let r=document.createElement("script");return r.type="text/javascript",r.src=t,window[n]=function(t){e(null,t),document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[n]},document.getElementsByTagName("head")[0].appendChild(r),this},get:function(t,e,n){if(T(e)){const t=n;n=e,e=t}(e=e||{}).method&&(e.method=e.method.toUpperCase());const r="POST"===e.method;if(L){const r=new AbortController,i=e;i.signal=r.signal,i.referrerPolicy=i.referrerPolicy||"origin",i.method=i.method||"GET";const o=new Request(t,i);return e.returnJSON&&o.headers.set("Accept","application/json"),fetch(o).then((r=>{const i=this._parseResponse(r,e.returnJSON,e.responseType);i.message?(i.url=t,n(i)):i.then((t=>{"arraybuffer"===e.responseType?n(null,{data:t,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),contentType:r.headers.get("Content-Type")}):n(null,t)})).catch((e=>{e.code&&e.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,e),n(e))}))})).catch((e=>{e.code&&e.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,e),n(e))})),r}{const i=C._getClient(n);if(i.open(e.method||"GET",t,!0),e){for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);i.withCredentials="include"===e.credentials,e.responseType&&(i.responseType=e.responseType)}return i.send(r?e.body:null),i}},_parseResponse:(t,e,n)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${s}t.status}): ${s}t.statusText}\`}:"arraybuffer"===n?t.arrayBuffer():e?t.json():t.text(),_wrapCallback:function(t,e){return function(){if(4===t.readyState)if(200===t.status)if("arraybuffer"===t.responseType){0===t.response.byteLength?e({status:200,statusText:t.statusText,message:"http status 200 returned without content."}):e(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")})}else e(null,t.responseText);else e({status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${s}t.status}): ${s}t.statusText}\`})}},_getClient:function(t){let e;try{e=new XMLHttpRequest}catch(t){try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}}return e.onreadystatechange=C._wrapCallback(e,t),e},getArrayBuffer(t,e,n){if(T(e)){const t=n;n=e,e=t}return e||(e={}),e.responseType="arraybuffer",C.get(t,e,n)}};function Y(t,e,n,r,i=3){let o=r;const s=n-e>>1;let a,l=n-e;const u=t[e],h=t[e+1],c=t[n],f=t[n+1];for(let r=e+i;r<n;r+=i){const e=V(t[r],t[r+1],u,h,c,f);if(e>o)a=r,o=e;else if(e===o){const t=Math.abs(r-s);t<l&&(a=r,l=t)}}o>r&&(a-e>i&&Y(t,e,a,r,i),t[a+2]=o,n-a>i&&Y(t,a,n,r,i))}function V(t,e,n,r,i,o){let s=i-n,a=o-r;if(0!==s||0!==a){const l=((t-n)*s+(e-r)*a)/(s*s+a*a);l>1?(n=i,r=o):l>0&&(n+=s*l,r+=a*l)}return s=t-n,a=e-r,s*s+a*a}function O(t,e,n,r,i,o){const s={id:null==t?null:t,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};i&&(s.layer=i);return function(t,e){const n=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)X(t,n,e);else if("Polygon"===r)X(t,n[0],e);else if("MultiLineString"===r)for(const r of n)X(t,r,e);else if("MultiPolygon"===r)for(const r of n)X(t,r[0],e)}(s,o?4:3),s}function X(t,e,n){for(let r=0;r<e.length;r+=n)t.minX=Math.min(t.minX,e[r]),t.minY=Math.min(t.minY,e[r+1]),t.maxX=Math.max(t.maxX,e[r]),t.maxY=Math.max(t.maxY,e[r+1])}function N(t,e,n,r){if(r.layer=e,"FeatureCollection"===n.type)for(let e=0;e<n.features.length;e++)E(t,n.features[e],r,e);else"Feature"===n.type?E(t,n,r):E(t,{geometry:n},r)}function E(t,e,n,r){if(!e.geometry)return;const i=e.geometry.coordinates,o=e.geometry.type,s=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2);let a=[],l=e.id;if(n.promoteId?l=e.properties[n.promoteId]:n.generateId&&(l=r||0),"Point"===o)z(i,a,n);else if("MultiPoint"===o)for(const t of i)z(t,a,n);else if("LineString"===o)$(i,a,s,!1,n);else if("MultiLineString"===o){if(n.lineMetrics){for(const r of i)a=[],$(r,a,s,!1,n),t.push(O(l,"LineString",a,e.properties,n.layer,n.hasAltitude));return}D(i,a,s,!1,n)}else if("Polygon"===o)D(i,a,s,!0,n);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(const i of e.geometry.geometries)E(t,{id:l,geometry:i,properties:e.properties},n,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const t of i){const e=[];D(t,e,s,!0,n),a.push(e)}}t.push(O(l,o,a,e.properties,n.layer,n.hasAltitude))}function z(t,e,n){e.push(q(t[0]),j(t[1],n.projection),0),n.hasAltitude&&(t.length>2?e.push(t[2]):e.push(0))}function $(t,e,n,r,i){let o,s,a=0;for(let n=0;n<t.length;n++){const l=q(t[n][0]),u=j(t[n][1],i.projection);e.push(l,u,0),i.hasAltitude&&(t[n].length>2?e.push(t[n][2]):e.push(0)),n>0&&(a+=r?(o*u-l*s)/2:Math.sqrt(Math.pow(l-o,2)+Math.pow(u-s,2))),o=l,s=u}const l=i.hasAltitude?4:3,u=e.length-l;e[2]=1,Y(e,0,u,n,l),e[u+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function D(t,e,n,r,i){for(let o=0;o<t.length;o++){const s=[];$(t[o],s,n,r,i),e.push(s)}}function q(t){return t/360+.5}function j(t,e){if("EPSG:4326"===e)return(90-t)/360;const n=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+n)/(1-n))/Math.PI;return r<0?0:r>1?1:r}function G(t,e,n,r,i,o,s,a){if(r/=e,o>=(n/=e)&&s<r)return t;if(s<n||o>=r)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===i?e.minX:e.minY,u=0===i?e.maxX:e.maxY;if(s>=n&&u<r){l.push(e);continue}if(u<n||s>=r)continue;let h=[];if("Point"===o||"MultiPoint"===o)Z(t,h,n,r,i,a.hasAltitude);else if("LineString"===o)U(t,h,n,r,i,!1,a.lineMetrics,a.hasAltitude);else if("MultiLineString"===o)J(t,h,n,r,i,!1,a.hasAltitude);else if("Polygon"===o)J(t,h,n,r,i,!0,a.hasAltitude);else if("MultiPolygon"===o)for(const e of t){const t=[];J(e,t,n,r,i,!0,a.hasAltitude),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(O(e.id,o,t,e.tags,e.layer,a.hasAltitude));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(O(e.id,o,h,e.tags,e.layer,a.hasAltitude))}}return l.length?l:null}function Z(t,e,n,r,i,o){const s=o?4:3;for(let a=0;a<t.length;a+=s){const s=t[a+i];s>=n&&s<=r&&(H(e,t[a],t[a+1],t[a+2]),o&&e.push(t[a+3]))}}function U(t,e,n,r,i,o,s,a){let l=R(t);const u=0===i?W:K;let h,c,f=t.start;const p=a?4:3,d=o?t.length:t.length-p;for(let g=0;g<d;g+=p){const y=t[g],x=t[g+1],m=t[g+2];let v,w,M,b;o&&g===d-p?(v=t[0],w=t[1]):(v=t[g+p],w=t[g+p+1]),a&&(M=t[g+3],b=o&&g===d-p?t[3]:t[g+p+3]);const P=0===i?y:x,_=0===i?v:w;let I=!1;s&&(h=Math.sqrt(Math.pow(y-v,2)+Math.pow(x-w,2))),P<n?_>n&&(c=u(l,y,x,v,w,n),a&&l.push(Q(M,b,c)),s&&(l.start=f+h*c)):P>r?_<r&&(c=u(l,y,x,v,w,r),a&&l.push(Q(M,b,c)),s&&(l.start=f+h*c)):(H(l,y,x,m),a&&l.push(M)),_<n&&P>=n&&(c=u(l,y,x,v,w,n),a&&l.push(Q(M,b,c)),I=!0),_>r&&P<=r&&(c=u(l,y,x,v,w,r),a&&l.push(Q(M,b,c)),I=!0),!o&&I&&(s&&(l.end=f+h*c),e.push(l),l=R(t)),s&&(f+=h)}let g=t.length-p;if(!o){const e=t[g],o=t[g+1],s=t[g+2],u=0===i?e:o;if(u>=n&&u<=r&&H(l,e,o,s),u>=n&&u<=r&&a){const e=t[g+3];l.push(e)}}g=l.length-p,o&&g>=p&&(l[g]!==l[0]||l[g+1]!==l[1])&&(H(l,l[0],l[1],l[2]),a&&l.push(l[3])),l.length&&e.push(l)}function R(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function J(t,e,n,r,i,o,s){for(const a of t)U(a,e,n,r,i,o,!1,s)}function H(t,e,n,r){t.push(e,n,r)}function W(t,e,n,r,i,o){const s=(o-e)/(r-e);return H(t,o,n+(i-n)*s,1),s}function K(t,e,n,r,i,o){const s=(o-n)/(i-n);return H(t,e+(r-e)*s,o,1),s}function Q(t,e,n){return t+(e-t)*n}function tt(t,e,n){const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=o.type;let a;if("Point"===s||"MultiPoint"===s||"LineString"===s)a=et(o.geometry,e,n);else if("MultiLineString"===s||"Polygon"===s){a=[];for(const t of o.geometry)a.push(et(t,e,n))}else if("MultiPolygon"===s){a=[];for(const t of o.geometry){const r=[];for(const i of t)r.push(et(i,e,n));a.push(r)}}r.push(O(o.id,s,a,o.tags,o.layer,n))}return r}function et(t,e,n){const r=[];r.size=t.size,void 0!==t.start&&(r.start=t.start,r.end=t.end);const i=n?4:3;for(let o=0;o<t.length;o+=i)r.push(t[o]+e,t[o+1],t[o+2]),n&&r.push(t[o+3]);return r}function nt(t,e,n){if(t.transformed)return t;const r=1<<t.z,i=t.x,o=t.y,s=n?3:2;for(const a of t.features){const t=a.geometry,l=a.type;if(a.geometry=[],1===l)for(let l=0;l<t.length;l+=s)a.geometry.push(rt(t[l],t[l+1],e,r,i,o)),n&&a.geometry[a.geometry.length-1].push(t[l+2]);else for(let l=0;l<t.length;l++){const u=[];for(let a=0;a<t[l].length;a+=s)u.push(rt(t[l][a],t[l][a+1],e,r,i,o)),n&&u[u.length-1].push(t[l][a+2]);a.geometry.push(u)}}return t.transformed=!0,t}function rt(t,e,n,r,i,o){return[Math.round(n*(t*r-i)),Math.round(n*(e*r-o))]}function it(t,e,n,r,i){const o=e===i.maxZoom?0:i.tolerance/((1<<e)*i.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:n,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const e of t)ot(s,e,o,i);return s}function ot(t,e,n,r){const i=e.geometry,o=e.type,s=[],a=r.hasAltitude?4:3;if(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),"Point"===o||"MultiPoint"===o)for(let e=0;e<i.length;e+=a)s.push(i[e],i[e+1]),r.hasAltitude&&s.push(i[e+3]),t.numPoints++,t.numSimplified++;else if("LineString"===o)at(s,i,t,n,!1,!1,r);else if("MultiLineString"===o||"Polygon"===o)for(let e=0;e<i.length;e++)at(s,i[e],t,n,"Polygon"===o,0===e,r);else if("MultiPolygon"===o)for(let e=0;e<i.length;e++){const o=i[e];for(let e=0;e<o.length;e++)at(s,o[e],t,n,!0,0===e,r)}if(s.length){let n=e.tags||null;if("LineString"===o&&r.lineMetrics){n={};for(const t in e.tags)n[t]=e.tags[t];n.mapbox_clip_start=i.start/i.size,n.mapbox_clip_end=i.end/i.size}const a={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:n};e.layer&&(a.layer=e.layer),null!==e.id&&(a.id=e.id),t.features.push(a)}}function st(t,e,n){return 0===t[e+2]&&t[e+3]>0&&n}function at(t,e,n,r,i,o,s){const a=r*r,{hasAltitude:l,disableFilter:u}=s,h=l?4:3;if(!u&&r>0&&e.size<(i?a:r))return void(n.numPoints+=e.length/h);const c=[];for(let t=0;t<e.length;t+=h)(0===r||e[t+2]>a||st(e,t,l))&&(n.numSimplified++,c.push(e[t],e[t+1]),l&&c.push(e[t+3])),n.numPoints++;i&&function(t,e,n){const r=n?3:2;let i=0;for(let e=0,n=t.length,o=n-r;e<n;o=e,e+=r)i+=(t[e]-t[o])*(t[e+1]+t[o+1]);if(i>0===e){const e=r,i=r-1,o=r-2;for(let s=0,a=t.length;s<a/2;s+=r){const r=t[s],l=t[s+1];let u;n&&(u=t[s+2]),t[s]=t[a-e-s],t[s+1]=t[a-i-s],n&&(t[s+2]=t[a-o-s]),t[a-e-s]=r,t[a-i-s]=l,n&&(t[a-o-s]=u)}}}(c,o,l),t.push(c)}C.getJSON=function(t,e,n){if(T(e)){const t=n;n=e,e=t}const r=function(t,e){const r="string"==typeof e?JSON.parse(e):e||null;n(t,r)};return e&&e.jsonp?C.jsonp(t,r):((e=e||{}).returnJSON=!0,C.get(t,e,r))};const lt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,hasAltitude:!1,disableFilter:!1,debug:0};class ut{constructor(t,e){const n=(e=this.options=function(t,e){for(const n in e)t[n]=e[n];return t}(Object.create(lt),e)).debug;if(n&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=function(t,e){const n=[];if(Array.isArray(t)){for(let r=0;r<t.length;r++)N(n,t[r].layer,t[r].data,e);return n}if("FeatureCollection"===t.type)for(let r=0;r<t.features.length;r++)E(n,t.features[r],e,r);else"Feature"===t.type?E(n,t,e):E(n,{geometry:t},e);return n}(t,e);this.tiles={},this.tileCoords=[],n&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(t,e){const n=e.buffer/e.extent;let r=t;const i=G(t,1,-1-n,n,0,-1,2,e),o=G(t,1,1-n,2+n,0,-1,2,e);return(i||o)&&(r=G(t,1,-n,1+n,0,-1,2,e)||[],i&&(r=tt(i,1,e.hasAltitude).concat(r)),o&&(r=r.concat(tt(o,-1,e.hasAltitude)))),r}(r,e),r.length&&this.splitTile(r,0,0,0),n&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,n,r,i,o,s){const a=[t,e,n,r],l=this.options,u=l.debug;for(;a.length;){r=a.pop(),n=a.pop(),e=a.pop(),t=a.pop();const h=1<<e,c=ht(e,n,r);let f=this.tiles[c];if(!f&&(u>1&&console.time("creation"),f=this.tiles[c]=it(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));const t=\`z${s}e}\`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(f.source=t,null==i){if(e===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(n!==o>>t||r!==s>>t)continue}}if(f.source=null,0===t.length)continue;u>1&&console.time("clipping");const p=.5*l.buffer/l.extent,d=.5-p,g=.5+p,y=1+p;let x=null,m=null,v=null,w=null,M=G(t,h,n-p,n+g,0,f.minX,f.maxX,l),b=G(t,h,n+d,n+y,0,f.minX,f.maxX,l);t=null,M&&(x=G(M,h,r-p,r+g,1,f.minY,f.maxY,l),m=G(M,h,r+d,r+y,1,f.minY,f.maxY,l),M=null),b&&(v=G(b,h,r-p,r+g,1,f.minY,f.maxY,l),w=G(b,h,r+d,r+y,1,f.minY,f.maxY,l),b=null),u>1&&console.timeEnd("clipping"),a.push(x||[],e+1,2*n,2*r),a.push(m||[],e+1,2*n,2*r+1),a.push(v||[],e+1,2*n+1,2*r),a.push(w||[],e+1,2*n+1,2*r+1)}}getTile(t,e,n){t=+t,e=+e,n=+n;const r=this.options,{extent:i,debug:o}=r,{hasAltitude:s,wrapX:a}=r;if(t<0||t>24)return null;if(a){const n=1<<t;e=e+n&n-1}const l=ht(t,e,n);if(this.tiles[l])return nt(this.tiles[l],i,s);o>1&&console.log("drilling down to z%d-%d-%d",t,e,n);let u,h=t,c=e,f=n;for(;!u&&h>0;)h--,c>>=1,f>>=1,u=this.tiles[ht(h,c,f)];return u&&u.source?(o>1&&(console.log("found parent tile z%d-%d-%d",h,c,f),console.time("drilling down")),this.splitTile(u.source,h,c,f,t,e,n),o>1&&console.timeEnd("drilling down"),this.tiles[l]?nt(this.tiles[l],i,s):null):null}}function ht(t,e,n){return 32*((1<<t)*n+e)+t}function ct(t,e,n,r,i,o,s){const a=n&&Array.isArray(n[0]);for(let l=0,u=n.length;l<u;l++){t[e]=(a?n[l][0]:n[l].x)*r,t[e+1]=(a?n[l][1]:n[l].y)*r,s!==Float32Array&&(t[e]=Math.round(t[e]),t[e+1]=Math.round(t[e+1]));let h=i||0;Array.isArray(i)&&(h=i[l]),h=h?Math.round(r*h):0,t[e+2]=h,e+=3,o&&0!==l&&l!==u-1&&(t[e]=t[e-3],t[e+1]=t[e-2],t[e+2]=t[e-1],e+=3)}return t.trySetLength&&t.trySetLength(e),e}function ft(t,e,n,r){const i=t[3*e],o=t[3*e+1],s=t[3*n],a=t[3*n+1];return i===s&&(i<0||i>r)||o===a&&(o<0||o>r)}var pt="undefined"!=typeof Float32Array?Float32Array:Array;function dt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function gt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function yt(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function xt(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t}function mt(t,e,n){return t[0]=e,t[1]=n,t}function vt(t,e){var n=e[0]-t[0],r=e[1]-t[1];return Math.hypot(n,r)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),function(){var t,e=(t=new pt(3),pt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t)}(),function(){var t,e=(t=new pt(4),pt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}(),function(){var t,e=(t=new pt(2),pt!=Float32Array&&(t[0]=0,t[1]=0),t)}();const wt=Math.PI/180,Mt=6378137*Math.PI/180,bt=85.0511287798;function Pt(t,e,n){if("EPSG:3857"===n)return function(t,e){const n=bt,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let o;o=0===i?0:Math.log(Math.tan((90+i)*wt/2))/wt;return t[0]=r*Mt,t[1]=o*Mt,t}(t,e);if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return _t(t,e);if("baidu"===n)return _t(t,e);throw new Error("unsupported projection:"+n)}function _t(t,e){return t[0]=e[0],t[1]=e[1],t}function It(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d){0===t?function(t,e,n,r,i,o,s,a,l,u){const h=1/(100*o[0]),c=1/(100*o[1]),f=u&&u[0]||0,p=u&&u[1]||0,d=[0,0];for(let i=t;i<e;i+=3){const t=i/3*2,e=r[i]-f,o=r[i+1]-p;n[t]=d[0]+e/s*h/a,n[t+1]=d[1]-o/s*c/l}}(e,n,r,i,0,s,a,l,u,d):1===t&&function(t,e,n,r,i,o,s,a,l,u,h){if(!t)return;let c,f,p,d;0===t[4]?(c=t[0],f=t[1],p=t[2],d=t[3]):(c=t[1],f=t[2],p=t[3],d=t[0]);const g=vt(c,f),y=vt(f,p),x=[],m=[],v=[];for(let t=e;t<n;t+=3){const e=t/3*2;mt(x,(o.x/l+i[t]/s)*a,o.y/l*a+(h?i[t+1]:-i[t+1])/s*a),"EPSG:4326"!==u&&"EPSG:4490"!==u||Pt(x,x,"EPSG:3857"),At(m,x,c,f),At(v,x,d,c),r[e]=vt(c,m)/g,r[e+1]=vt(c,v)/y}}(h,e,n,r,i,o,a,c,f,p,!!d)}function At(t,e,n,r){const i=n[0]-r[0],o=n[1]-r[1];let s=(e[0]-n[0])*(n[0]-r[0])+(e[1]-n[1])*(n[1]-r[1]);return s/=i*i+o*o,t[0]=n[0]+s*i,t[1]=n[1]+s*o,t}function St(t,e,n,r,i){const o=3*e[n-1],s=3*e[n-1]+1,a=t[o],l=t[s];return u=r,h=i,c=a,f=l,Math.sqrt((c-u)*(c-u)+(f-h)*(f-h));var u,h,c,f}function Tt(t,e,n=2){const r=e&&e.length,i=r?e[0]*n:t.length;let o=Ft(t,0,i,n,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,u;if(r&&(o=function(t,e,n,r){const i=[];for(let n=0,o=e.length;n<o;n++){const s=Ft(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1);s===s.next&&(s.steiner=!0),i.push(zt(s))}i.sort(Ot);for(let t=0;t<i.length;t++)n=Xt(i[t],n);return n}(t,e,o,n)),t.length>80*n){a=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=n;o<i;o+=n){const n=t[o],i=t[o+1];n<a&&(a=n),i<l&&(l=i),n>e&&(e=n),i>r&&(r=i)}u=Math.max(e-a,r-l),u=0!==u?32767/u:0}return Bt(o,s,n,a,l,u,0),s}function Ft(t,e,n,r,i){let o;if(i===function(t,e,n,r){let i=0;for(let o=e,s=n-r;o<n;o+=r)i+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return i}(t,e,n,r)>0)for(let i=e;i<n;i+=r)o=Wt(i/r|0,t[i],t[i+1],o);else for(let i=n-r;i>=e;i-=r)o=Wt(i/r|0,t[i],t[i+1],o);return o&&Gt(o,o.next)&&(Kt(o),o=o.next),o}function kt(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!Gt(r,r.next)&&0!==jt(r.prev,r,r.next))r=r.next;else{if(Kt(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function Bt(t,e,n,r,i,o,s){if(!t)return;!s&&o&&function(t,e,n,r){let i=t;do{0===i.z&&(i.z=Et(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n=1;do{let r,i=t;t=null;let o=null;for(e=0;i;){e++;let s=i,a=0;for(let t=0;t<n&&(a++,s=s.nextZ,s);t++);let l=n;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(r=i,i=i.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=s}o.nextZ=null,n*=2}while(e>1)}(i)}(t,r,i,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(o?Ct(t,r,i,o):Lt(t))e.push(l.i,t.i,u.i),Kt(t),t=u.next,a=u.next;else if((t=u)===a){s?1===s?Bt(t=Yt(kt(t),e),e,n,r,i,o,2):2===s&&Vt(t,e,n,r,i,o):Bt(kt(t),e,n,r,i,o,1);break}}}function Lt(t){const e=t.prev,n=t,r=t.next;if(jt(e,n,r)>=0)return!1;const i=e.x,o=n.x,s=r.x,a=e.y,l=n.y,u=r.y,h=Math.min(i,o,s),c=Math.min(a,l,u),f=Math.max(i,o,s),p=Math.max(a,l,u);let d=r.next;for(;d!==e;){if(d.x>=h&&d.x<=f&&d.y>=c&&d.y<=p&&Dt(i,a,o,l,s,u,d.x,d.y)&&jt(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Ct(t,e,n,r){const i=t.prev,o=t,s=t.next;if(jt(i,o,s)>=0)return!1;const a=i.x,l=o.x,u=s.x,h=i.y,c=o.y,f=s.y,p=Math.min(a,l,u),d=Math.min(h,c,f),g=Math.max(a,l,u),y=Math.max(h,c,f),x=Et(p,d,e,n,r),m=Et(g,y,e,n,r);let v=t.prevZ,w=t.nextZ;for(;v&&v.z>=x&&w&&w.z<=m;){if(v.x>=p&&v.x<=g&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&Dt(a,h,l,c,u,f,v.x,v.y)&&jt(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,w.x>=p&&w.x<=g&&w.y>=d&&w.y<=y&&w!==i&&w!==s&&Dt(a,h,l,c,u,f,w.x,w.y)&&jt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=g&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&Dt(a,h,l,c,u,f,v.x,v.y)&&jt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;w&&w.z<=m;){if(w.x>=p&&w.x<=g&&w.y>=d&&w.y<=y&&w!==i&&w!==s&&Dt(a,h,l,c,u,f,w.x,w.y)&&jt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Yt(t,e){let n=t;do{const r=n.prev,i=n.next.next;!Gt(r,i)&&Zt(r,n,n.next,i)&&Jt(r,i)&&Jt(i,r)&&(e.push(r.i,n.i,i.i),Kt(n),Kt(n.next),n=t=i),n=n.next}while(n!==t);return kt(n)}function Vt(t,e,n,r,i,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&qt(s,t)){let a=Ht(s,t);return s=kt(s,s.next),a=kt(a,a.next),Bt(s,e,n,r,i,o,0),void Bt(a,e,n,r,i,o,0)}t=t.next}s=s.next}while(s!==t)}function Ot(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function Xt(t,e){const n=function(t,e){let n=e;const r=t.x,i=t.y;let o,s=-1/0;if(Gt(t,n))return n;do{if(Gt(t,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const t=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>s&&(s=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const a=o,l=o.x,u=o.y;let h=1/0;n=o;do{if(r>=n.x&&n.x>=l&&r!==n.x&&$t(i<u?r:s,i,l,u,i<u?s:r,i,n.x,n.y)){const e=Math.abs(i-n.y)/(r-n.x);Jt(n,t)&&(e<h||e===h&&(n.x>o.x||n.x===o.x&&Nt(o,n)))&&(o=n,h=e)}n=n.next}while(n!==a);return o}(t,e);if(!n)return e;const r=Ht(n,t);return kt(r,r.next),kt(n,n.next)}function Nt(t,e){return jt(t.prev,t,e.prev)<0&&jt(e.next,t,t.next)<0}function Et(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function zt(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function $t(t,e,n,r,i,o,s,a){return(i-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(r-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(i-s)*(r-a)}function Dt(t,e,n,r,i,o,s,a){return!(t===s&&e===a)&&$t(t,e,n,r,i,o,s,a)}function qt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Zt(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Jt(t,e)&&Jt(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(jt(t.prev,t,e.prev)||jt(t,e.prev,e))||Gt(t,e)&&jt(t.prev,t,t.next)>0&&jt(e.prev,e,e.next)>0)}function jt(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Gt(t,e){return t.x===e.x&&t.y===e.y}function Zt(t,e,n,r){const i=Rt(jt(t,e,n)),o=Rt(jt(t,e,r)),s=Rt(jt(n,r,t)),a=Rt(jt(n,r,e));return i!==o&&s!==a||(!(0!==i||!Ut(t,n,e))||(!(0!==o||!Ut(t,r,e))||(!(0!==s||!Ut(n,t,r))||!(0!==a||!Ut(n,e,r)))))}function Ut(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Rt(t){return t>0?1:t<0?-1:0}function Jt(t,e){return jt(t.prev,t,t.next)<0?jt(t,e,t.next)>=0&&jt(t,t.prev,e)>=0:jt(t,e,t.prev)<0||jt(t,t.next,e)<0}function Ht(t,e){const n=Qt(t.i,t.x,t.y),r=Qt(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Wt(t,e,n,r){const i=Qt(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Kt(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 Qt(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}const te="__fea_idx";new Float32Array([-1e12])[0];const ee="maptalks_ombb";function ne(){return function(){if("undefined"!=typeof undefinedThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")}().maptalks_vt_packers}const{PackUtil:re,ArrayPool:ie}=ne();function oe(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d,g,y){const x=e.getLength(),m=i/3;for(let n=2,r=x;n<r;n+=3)t[i+n-2]=e[n-2],t[i+n-1]=e[n-1],t[i+n-0]=e[n]-s;i+=x;for(let n=2,r=x;n<r;n+=3)t[i+n-2]=e[n-2],t[i+n-1]=e[n-1],t[i+n-0]=e[n]-a;i+=x,t.trySetLength(i+x),t.copyWithin(i,i-2*x,i-x),i+=x,t.trySetLength(i+x),t.copyWithin(i,i-2*x,i-x),i+=x,(n=n||[]).push(x/3);const v=n.getLength();for(let e=0;e<v;e++){se(m+(n[e-1]||0),m+n[e],t,x/3,l,r,u,h,c,f,o,p,d,g,y)}return i}function se(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d){const g=o.getLength();let y,x;for(let s=t,a=e;s<a-1;s++)if(y=s,x=s+1,i===1/0||!ft(n,y,x,i))if((s-t)%2==1&&(y+=2*r,x+=2*r),d){let t=o.currentIndex;o[t++]=y+r,o[t++]=x,o[t++]=y,o[t++]=x+r,o[t++]=x,o[t++]=y+r,o.currentIndex=t}else{let t=o.currentIndex;o[t++]=y+r,o[t++]=y,o[t++]=x,o[t++]=x,o[t++]=x+r,o[t++]=y+r,o.currentIndex=t}s&&function(t,e,n,r,i,o,s,a,l,u,h,c){let f,p=0,d=0,g=0,y=0;const x=c?[1,3,4]:[2,3,4];for(let c=o.getLength()-1;c>=s;c--){const s=o[c],m=3*s+1,v=3*s+2,w=i[3*s],M=i[m],b=i[v];p||d||(p=Math.max(i[v],i[3*o[c-3]+2]),d=Math.min(i[v],i[3*o[c-3]+2]),f=p-d);let P=g;const _=c%6;0===t?(5===_&&(y=St(i,o,c,w,M)),P=_===x[0]||_===x[1]||_===x[2]?g:g+y):1===t&&(_===x[0]||_===x[1]||_===x[2]?P=0:5===_?(y=St(i,o,c,w,M),P=y):P=y);const I=P/u*(1/(100*h))/a;let A;A=1===e?b===p?1:0:"bottom"===n?b===p?f/100/l:0:b===p?0:-f/100/l,r[2*s]=I,r[2*s+1]=A,0===_&&(g+=y)}}(a,l,u,h,n,o,g,c[0],c[1],f,p,d)}function ae(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++)Array.isArray(t[r])?t[r][0]===n[0]&&t[r][1]===n[1]&&t[r][2]===n[2]||e.push(t[r]):t[r].x===n.x&&t[r].y===n.y&&t[r].z===n.z||e.push(t[r]),n=t[r];return e}var le="undefined"!=typeof Float32Array?Float32Array:Array;function ue(){var t=new le(3);return le!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function he(t,e,n){var r=new le(3);return r[0]=t,r[1]=e,r[2]=n,r}function ce(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function fe(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function pe(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function de(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function ge(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ye(t,e,n){var r=e[0],i=e[1],o=e[2],s=n[0],a=n[1],l=n[2];return t[0]=i*l-o*a,t[1]=o*s-r*l,t[2]=r*a-i*s,t}var xe=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};function me(){var t=new le(4);return le!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ve(t,e){var n=e[0]+e[4]+e[8],r=void 0;if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var o=(i+1)%3,s=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*o+o]-e[3*s+s]+1),t[i]=.5*r,r=.5/r,t[3]=(e[3*o+s]-e[3*s+o])*r,t[o]=(e[3*o+i]+e[3*i+o])*r,t[s]=(e[3*s+i]+e[3*i+s])*r}return t}!function(){var t=ue()}(),function(){var t,e=(t=new le(4),le!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var we,Me=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},be=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],s=n*n+r*r+i*i+o*o;return s>0&&(s=1/Math.sqrt(s),t[0]=n*s,t[1]=r*s,t[2]=i*s,t[3]=o*s),t};ue(),he(1,0,0),he(0,1,0),me(),me(),we=new le(9),le!=Float32Array&&(we[1]=0,we[2]=0,we[3]=0,we[5]=0,we[6]=0,we[7]=0),we[0]=1,we[4]=1,we[8]=1;\n/*!\n * Contains code from google filament\n * https://github.com/google/filament/\n * License Apache-2.0\n */\nconst Pe=8,_e=[],Ie=[],Ae=[],Se=[];function Te(t,e,n){const r=ye(Ie,e,n),i=function(t,e,n,r,i,o,s,a,l,u){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=a,t[7]=l,t[8]=u,t}(_e,n[0],n[1],n[2],...r,...e);t=ve(t,i),t=function(t){return t[3]<0?Me(t,t,-1):t}(t=be(t,t));const o=1/((1<<2*Pe-1)-1);if(t[3]<o){t[3]=o;const e=Math.sqrt(1-o*o);t[0]*=e,t[1]*=e,t[2]*=e}const s=n[3]>0?ye(Ae,n,e):ye(Ae,e,n);return ge(ye(Se,n,e),s)<0&&Me(t,t,-1),t}const Fe=[];const ke=[],Be=[],Le=[],Ce=[],Ye=[],Ve=[],Oe=[];function Xe(t,e,n,r,i,o){fe(Ce,t[3*e],t[3*e+1],t[3*e+2]),fe(Ye,t[3*n],t[3*n+1],t[3*n+2]),fe(Ve,t[3*r],t[3*r+1],t[3*r+2]);const s=xe(ke,Ve,Ye),a=xe(Be,Ce,Ye),l=ye(Le,s,a);de(Oe,l),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=Oe[0],i[3*n]+=Oe[0],i[3*r]+=Oe[0],i[3*e+1]+=Oe[1],i[3*n+1]+=Oe[1],i[3*r+1]+=Oe[1],i[3*e+2]+=Oe[2],i[3*n+2]+=Oe[2],i[3*r+2]+=Oe[2],o[e]+=1,o[n]+=1,o[r]+=1}\n/*!\n * Contains code from THREE.JS\n * https://github.com/mrdoob/three.js/\n * License MIT\n * \n * Generate tangents per vertex.\n */function Ne(t,e,n){return t[0]=e[n],t[1]=e[n+1],t[2]=e[n+2],t}function Ee(t,e,n){return t[0]=e[n],t[1]=e[n+1],t}const{StyleUtil:ze,PackUtil:$e,ArrayPool:De}=ne(),qe=De.getInstance();function je(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d,g){void 0===e.top&&(e.top=!0),void 0===e.side&&(e.side=!0),qe.reset();const{altitudeScale:y,altitudeProperty:x,defaultAltitude:m,heightProperty:v,minHeightProperty:P,defaultHeight:_,tangent:I,uv:A,topUVMode:T,sideUVMode:F,sideVerticalUVMode:k,top:L,side:C,textureYOrigin:Y,topThickness:V}=e,O=function(t,e,{altitudeScale:n,altitudeProperty:r,defaultAltitude:i,heightProperty:o,minHeightProperty:s,defaultHeight:a},{center:l,side:u,top:h,topThickness:c,uvOrigin:f,uv:p,uvSize:d,topUVMode:g,sideUVMode:y,sideVerticalUVMode:x,textureYOrigin:m,tileRatio:v,centimeterToPoint:w,verticalCentimeterToPoint:M,positionType:b,res:P,glScale:_,projectionCode:I},A,T){let F=e/t[0].extent;e===1/0&&(F=1);const k=e===1/0,B=T.get(),L=T.get(),C=T.get(),Y=T.getProxy(),V=T.get(),O=T.get(),X=T.get(),N=!!p,E=!!h,z=!!u,$=N?T.get():null;function D(t,n,r,i,o,s){let a=n;if(E){const u=Tt(Y,r,3);if(0===u.length)return n;let h=Y.getLength(),p=V.currentIndex;for(let t=0;t<h;t++)V[p++]=Y[t];if(V.currentIndex=p,n+=Y.getLength(),s)for(let e=2,n=u.length;e<n;e+=3)u[e]+=t/3,u[e-1]+=t/3,u[e-2]+=t/3;else{let e;for(let n=2,r=u.length;n<r;n+=3)e=u[n-1],u[n-1]=u[n]+t/3,u[n]=e+t/3,u[n-2]+=t/3}h=u.length,p=O.currentIndex;for(let t=0;t<h;t++)O[p++]=u[t];O.currentIndex=p,N&&It(g||0,t,n,$,V,f,w,v,d[0],d[1],o,P,_,I,l),c>0&&!z&&(n=oe(V,Y,r,O,n,$,0,c,e,N,y||0,x||0,m,d,v,M,i<0?!s:s)),X.setLength(n/3),X.fill(1,a/3,n/3)}if(z){E&&(c=0),a=n,n=oe(V,Y,r,O,n,$,c,i,e,N,y||0,x||0,m,d,v,M,i<0?!s:s),X.setLength(n/3);const t=Y.getLength()/3;X.fill(1,a/3,a/3+t),X.fill(0,a/3+t,a/3+2*t),X.fill(1,a/3+2*t,a/3+3*t),X.fill(0,a/3+3*t,n/3)}return n}let q=-1/0,j=1/0,G=0;const Z=[-1,-1,e+1,e+1];let U=0,R=t.length;S(A)&&(U=A,R=A+1);let J=0,H=!1;const W=T.getProxy();let K=!1;for(;U<R;U++){const l=t[U],u=l.id;S(u)&&(Math.abs(u)>J&&(J=Math.abs(u)),u<0&&(H=!0));const h=l.geometry,c=l.properties[ee];let f=Array.isArray(c&&c[0]&&c[0][0])?c[0]:c;const{altitude:p,height:d}=re.getFeaAltitudeAndHeight(l,n,r,i,o,a,s);d<0?(K=!0,j=Math.min(p,j),q=Math.max(p-d,q)):(q=Math.max(p,q),j=Math.min(p-d,j));const g=V.getLength();let y=0,x=G;W.setLength(0),Y.setLength(0);const m=re.calculateSignedArea(h[0])<0;for(let t=0,n=h.length;t<n;t++){let r=h[t];m&&(r=r.reverse()),r=ae(r);const i=re.calculateSignedArea(r)<0;if(!i&&t>0&&(y++,f=c&&c[y],G=D(x,G,W,d*F,f,k),Y.setLength(0),W.setLength(0),x=G),e!==1/0&&(r=re.clipPolygon(r,Z)),!r.length){t===n-1&&(G=D(x,G,W,d*F,f,k));continue}const o=r.length;if(Array.isArray(r[0])?r[0][0]===r[o-1][0]&&r[0][1]===r[o-1][1]||r.push([r[0][0],r[0][1]]):r[0].x===r[o-1].x&&r[0].y===r[o-1].y||r.push(r[0]),i){let t=W.currentIndex;W[t++]=Y.getLength()/3,W.currentIndex=t}ct(Y,Y.getLength(),r,F,p,!1,b),t===n-1&&(G=D(x,G,W,d*F,f,k))}const v=V.getLength()-g,w=(te+"").trim();for(let t=0;t<v/3;t++){let t=L.currentIndex;L[t++]=void 0===l[w]?U:l[w],L.currentIndex=t,t=B.currentIndex,B[t++]=U,B.currentIndex=t,S(u)&&(t=C.currentIndex,C[t++]=u,C.currentIndex=t)}}const Q=re.getUnsignedArrayType(L.getLength()?L[L.getLength()-1]:0),tt={hasNegativeHeight:K,maxAltitude:q===-1/0?0:q,minAltitude:j===1/0?0:j,vertices:V,verticeTypes:X,indices:O,pickingIds:ie.createTypedArray(L,Q),featureIndexes:B};if(C.getLength()){const t=H?re.getPosArrayType(J):re.getUnsignedArrayType(J);tt.featureIds=ie.createTypedArray(C,t)}else tt.featureIds=[];return $&&($.setLength(V.getLength()/3*2),tt.uvs=$),tt}(t,n,{altitudeScale:y,altitudeProperty:x,defaultAltitude:m||0,heightProperty:v,minHeightProperty:P,defaultHeight:_||0},{center:g,top:L,side:C,topThickness:10*V||0,uv:A||I,uvSize:[i,i],uvOrigin:r,topUVMode:T,sideUVMode:F,sideVerticalUVMode:k,textureYOrigin:Y,tileRatio:a,centimeterToPoint:l,verticalCentimeterToPoint:u,positionType:d,res:o,glScale:s,projectionCode:f},p,qe),X=[],N=O.vertices.getLength()/3,E=$e.getIndexArrayType(N),z=De.createTypedArray(O.indices,E);delete O.indices,X.push(z.buffer,O.pickingIds.buffer);const $=Math.max(Math.abs(O.maxAltitude),Math.abs(O.minAltitude)),D=$e.getPosArrayType(Math.max(512,$));O.vertices=De.createTypedArray(O.vertices,D);const q=I?qe.getProxy():new Float32Array(3*N);q.setLength&&q.setLength(3*N);const j=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=Fe;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Xe(t,3*n,3*n+1,3*n+2,r,i):Xe(t,e[3*n],e[3*n+1],e[3*n+2],r,i);for(let t=0;t<r.length;t+=3){const e=i[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(O.vertices,z,q);let G=!0;const Z=j.getLength?j.getLength():j.length;for(let t=0;t<Z;t++){j[t]=-j[t];const e=j[t]%1;1-Math.abs(e)>1e-6?G=!1:0!==e&&(j[t]=Math.round(j[t]))}if(O.normals=j,I){let t=qe.get();t.setLength(4*N),t=function(t,e,n,r,i){const o=t.length/3,s=i||new Array(4*o),a=[],l=[];for(let t=0;t<o;t++)a[t]=[0,0,0],l[t]=[0,0,0];const u=[0,0,0],h=[0,0,0],c=[0,0,0],f=[0,0],p=[0,0],d=[0,0],g=[0,0,0],y=[0,0,0];function x(e,r,i){Ne(u,t,3*e),Ne(h,t,3*r),Ne(c,t,3*i),Ee(f,n,2*e),Ee(p,n,2*r),Ee(d,n,2*i);const o=h[0]-u[0],s=c[0]-u[0],x=h[1]-u[1],m=c[1]-u[1],v=h[2]-u[2],w=c[2]-u[2],M=p[0]-f[0],b=d[0]-f[0],P=p[1]-f[1],_=d[1]-f[1],I=1/(M*_-b*P);fe(g,(_*o-P*s)*I,(_*x-P*m)*I,(_*v-P*w)*I),fe(y,(M*s-b*o)*I,(M*m-b*x)*I,(M*w-b*v)*I),pe(a[e],a[e],g),pe(a[r],a[r],g),pe(a[i],a[i],g),pe(l[e],l[e],y),pe(l[r],l[r],y),pe(l[i],l[i],y)}for(let t=0,e=r.length;t<e;t+=3)x(r[t+0],r[t+1],r[t+2]);const m=[],v=[],w=[],M=[];let b,P,_;function I(t){Ne(w,e,3*t),ce(M,w),P=a[t],ce(m,P),xe(m,m,function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(w,w,ge(w,P))),de(m,m),ye(v,M,P),_=ge(v,l[t]),b=_<0?-1:1,s[4*t]=m[0],s[4*t+1]=m[1],s[4*t+2]=m[2],s[4*t+3]=b}for(let t=0,e=r.length;t<e;t+=3)I(r[t+0]),I(r[t+1]),I(r[t+2]);return s}(O.vertices,O.normals,O.uvs,z,t),t=function(t,e){const n=e.getLength(),r=new Float32Array(n),i=[],o=[],s=[];for(let a=0;a<n;a+=4){const n=a/4*3;dt(o,t[n]||0,t[n+1]||0,t[n+2]||0),yt(i,e[a]||0,e[a+1]||0,e[a+2]||0,e[a+3]||0),Te(s,o,i),gt(r.subarray(a,a+4),s)}return r}(O.normals,t),O.tangents=t,X.push(t.buffer),delete O.normals}if(O.normals&&(G&&(O.normals=De.createTypedArray(O.normals,Int8Array)),X.push(O.normals.buffer)),O.uvs){const t=O.uvs;O.uvs=De.createTypedArray(t,Float32Array),X.push(O.uvs.buffer)}const U=function(t,e,n,r){const i={},o={},s=r.getLength();if(B(e.polygonFill)){let a=M(e.polygonFill);const l=new Uint8Array(4*s);l.fill(255);for(let e=0;e<s;e++){const o=t[r[e]],s=o.properties||{};s.$layer=o.layer,s.$type=o.type;let u=a(n,s);w(u)&&(i.aColor=1,a=M(u),u=a(n,s)),delete s.$layer,delete s.$type,ze.normalizeColor(Ge,u),l[4*e]=Ge[0],l[4*e+1]=Ge[1],l[4*e+2]=Ge[2],l[4*e+3]=Ge[3]}o.aColor=l}if(B(e.polygonOpacity)){let a=b(e.polygonOpacity,"exponential");const l=new Uint8Array(s);l.fill(255);for(let e=0;e<s;e++){const o=t[r[e]],s=o.properties||{};s.$layer=o.layer,s.$type=o.type;let u=a(n,s);w(u)&&(i.aOpacity=1,a=M(u),u=a(n,s)),delete s.$layer,delete s.$type,l[e]=255*u}o.aOpacity=l}return o.dynamicAttributes=i,o}(t,h,c,O.featureIndexes),R=function(t,e,n,r,i){const o=[[],[]],s=B(r.topPolygonFill),a=B(r.bottomPolygonFill),l=[255,255,255,255],u=e.getLength();if(s||a){let h=s&&M(r.topPolygonFill),c=a&&M(r.bottomPolygonFill),f=null,p=null,d=null,g=null;for(let r=0;r<u;r++){if(1===t[r]&&!s||0===t[r]&&!a)continue;const u=1===t[r];if(u&&e[r]===f){t[r]=d;continue}if(!u&&e[r]===p){t[r]=g;continue}const y=n[e[r]],x=y.properties||{};x.$layer=y.layer,x.$type=y.type;let m=u?h:c,v=m(i,x);w(v)&&(m=M(v),v=m(i,x)),delete x.$layer,delete x.$type,ze.normalizeColor(Ge,v),xt(Ge,Ge,l);let b=Ze(o,Ge);b<0&&(b=o.length,o.push(gt([],Ge))),t[r]=b,u?(f=e[r],d=b):(p=e[r],g=b)}}return o.slice(2)}(O.verticeTypes,O.featureIndexes,t,h,c),J={data:{data:{aVertexColorType:R.length<=252?De.createTypedArray(O.verticeTypes,Uint8Array):De.createTypedArray(O.verticeTypes,Uint16Array),aPosition:O.vertices,aNormal:O.normals,aTexCoord0:O.uvs,aTangent:O.tangents,aPickingId:O.pickingIds},indices:z,properties:{maxAltitude:O.maxAltitude/100,minAltitude:O.minAltitude/100,hasNegativeHeight:O.hasNegativeHeight},dynamicAttributes:U.dynamicAttributes,vertexColors:R},buffers:X};return O.featureIds.length?(J.data.featureIds=O.featureIds,X.push(J.data.featureIds.buffer)):J.data.featureIds=[],U.aColor&&(J.data.data.aColor=U.aColor,J.buffers.push(U.aColor.buffer)),U.aOpacity&&(J.data.data.aOpacity=U.aOpacity,J.buffers.push(U.aOpacity.buffer)),J.buffers.push(J.data.data.aPosition.buffer),J.data.pickingIdIndiceMap=$e.generatePickingIndiceIndex(J.data.data.aPickingId,J.data.indices),J}const Ge=[];function Ze(t,e){for(let i=0;i<t.length;i++)if(n=e,r=t[i],n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3])return i;var n,r;return-1}const{PackUtil:Ue,StyleUtil:Re,FilterUtil:Je}=ne();function He(t,e,n,r,{altitudeScale:i,altitudeProperty:o,defaultAltitude:s,heightProperty:a,minHeightProperty:l,defaultHeight:u,bottom:h}){const c=h,f=e/t[0].extent,p=2*function(t,e){let n=0;for(let e=0,r=t.length;e<r;e++){const r=t[e];if(S(r.geometry[0][0]))n+=3*r.geometry.length;else for(let t=0,e=r.geometry.length;t<e;t++){let e=3*r.geometry[t].length;3===r.type&&(e-=3),n+=e}}return n}(t)+3*t.length*2,d=[],g=new Int16Array(p),y=new Uint8Array(g.length/3*4);w(n)&&(n=Je.compileFilter(n));const x=[];function m(t,n,r){const i=n-t,o=g.subarray(t,n),s=g.subarray(n,n+i);s.set(o);for(let t=2,e=s.length;t<e;t+=3)s[t]=o[t]-r;const a=t/3,l=i/3;let u,h;for(let t=a,n=l+a;t<n;t++)t<n-1?(u=t,h=t+1):(u=t,h=a),ft(g,u,h,e)||(x.push(u,h),c&&x.push(u+l,h+l),We(g,u,e)||x.push(u,u+l));return n+i}let v=0,M=-1/0,b=1/0;const P=(te+"").trim(),_=[];for(let e=0,h=t.length;e<h;e++){const h=t[e],c=h.geometry;if(n){let t;t="function"==typeof n?n(h&&h.properties):n,Re.normalizeColor(_,t)}else dt(_,255,255,255);const p=v/3*4,{altitude:w,height:I}=Ue.getFeaAltitudeAndHeight(h,i,o,s,a,u,l);I<0?(b=Math.min(w,b),M=Math.max(w-I,M)):(b=Math.min(w-I,b),M=Math.max(w,M));let A=v;for(let t=0,e=c.length;t<e;t++){let e=c[t];const n=e.length;e[0][0]===e[n-1][0]&&e[0][1]===e[n-1][1]&&(e=e.slice(0,n-1)),v=ct(g,A,e,f,w),v=m(A,v,I*f),A=v}const S=A/3*4;for(let t=p;t<S;t+=4)y[t]=_[0],y[t+1]=_[1],y[t+2]=_[2],y[t+3]=255*(r||1);const T=x.length-d.length;for(let t=0;t<T;t++)d.push(h[P])}const I=x.reduce(((t,e)=>Math.max(t,e)),0),A=new(Ue.getIndexArrayType(I))(x),T=Ue.getUnsignedArrayType(t.length),F=Math.max(Math.abs(M,Math.abs(b)));return{aPosition:new(Ue.getPosArrayType(Math.max(512,F)))(g),indices:A,aPickingId:new T(d),aColor:y,maxAltitude:M===-1/0?0:M/100,minAltitude:b===1/0?0:b/100}}function We(t,e,n){const r=t[3*e],i=t[3*e+1];return r<0||r>n||i<0||i>n}function Ke(t,e,n,r){const i=He(t,e,n.lineColor,n.lineOpacity,r),{minAltitude:o,maxAltitude:s}=i;delete i.minAltitude,delete i.maxAltitude;const a=[i.aPosition.buffer,i.indices.buffer,i.aPickingId.buffer],l=i.indices;return delete i.indices,{data:{data:i,properties:{minAltitude:o,maxAltitude:s},indices:l},buffers:a}}\n/*!\n Feature Filter by\n\n (c) mapbox 2016 and maptalks 2018\n www.mapbox.com | www.maptalks.org\n License: MIT, header required.\n */const Qe=["Unknown","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"];function tn(t){if(!t)return"true";const e=t[0];if(t.length<=1)return"any"===e?"false":"true";return\`(${s}"=="===e?nn(t[1],t[2],"===",!1):"!="===e?nn(t[1],t[2],"!==",!1):"<"===e||">"===e||"<="===e||">="===e?nn(t[1],t[2],e,!0):"any"===e?on(t.slice(1),"||"):"all"===e?on(t.slice(1),"&&"):"none"===e?ln(on(t.slice(1),"||")):"in"===e?sn(t[1],t.slice(2)):"!in"===e?ln(sn(t[1],t.slice(2))):"has"===e?an(t[1]):"!has"===e?ln(an(t[1])):"contains"===e?function(t,e,n){const r=en(t);return void 0!==n?\`(${s}r} + '').indexOf("${s}e}") === ${s}n}\`:\`(${s}r} + '').indexOf("${s}e}") >= 0\`}(t[1],t[2],t[3]):"true"})\`}function en(t){return"$"===t[0]?"f."+t.substring(1):"p["+JSON.stringify(t)+"]"}function nn(t,e,n,r){if("object"==typeof(i=t)&&i&&t.op)return function(t,e,n,r){const i=t.property,o=t.op;let s=en(i);return"length"!==o?(console.error(\`not support ${s}o} op\`),"false"):(s=\`((${s}s}+='').length)\`,rn(s,i,e,n,r))}(t,e,n,r);var i;return rn(en(t),t,e,n,r)}function rn(t,e,n,r,i){const o="$type"===e?Qe.indexOf(n):JSON.stringify(n);return(i?\`typeof ${s}t}=== typeof ${s}o}&&\`:"")+t+r+o}function on(t,e){return t.map(tn).join(e)}function sn(t,e){"$type"===t&&(e=e.map((t=>Qe.indexOf(t))));const n=JSON.stringify(e.sort(un)),r=en(t);return e.length<=200?\`${s}n}.indexOf(${s}r}) !== -1\`:\`function(v, a, i, j) {\\n while (i <= j) { var m = (i + j) >> 1;\\n if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\\n }\\n return false; }(${s}r}, ${s}n},0,${s}e.length-1})\`}function an(t){return"$id"===t?'"id" in f':\`${s}JSON.stringify(t)} in p\`}function ln(t){return\`!(${s}t})\`}function un(t,e){return t<e?-1:t>e?1:0}let hn=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),hn=!0}catch(t){hn=!1}var cn=hn;const{VectorPack:fn,PolygonPack:pn,NativeLinePack:dn,LinePack:gn,PointPack:yn,NativePointPack:xn,LineExtrusionPack:mn,CirclePack:vn,RoundTubePack:wn,SquareTubePack:Mn,FilterUtil:bn,PackUtil:Pn,StyleUtil:_n,TextUtil:In,DEFAULT_TEX_WIDTH:An,GlyphRequestor:Sn}=ne(),Tn="__original_properties",Fn="__fn-type_properties";class kn{constructor(t,e,n,r,i){this.id=t,this.options=e,this.upload=n,this._compileStyle(e.style),this.requests={},this._cache=r,this._styleCounter=1,this.loadings=i}updateStyle(t,e){this.options.style=t,this._styleCounter=t.styleCounter,this._compileStyle(t),e()}updateOptions(t,e){this.options=I(this.options,t),e()}loadTile(t,e){const n=this.loadings,r=t.tileInfo.url,i=this.options.debugTile;if(i){const{x:n,y:r,z:o}=t.tileInfo;let s=!1;for(let t=0;t<i.length;t++)if(n===i[t].x&&r===i[t].y&&o===i[t].z){s=!0;break}if(!s)return void e()}if(n[r])return void n[r].push({context:t,callback:e,ref:this});n[r]=[{context:t,callback:e,ref:this}];const o=this.options.featureIdProperty;this.requests[r]=this.getTileFeatures(t,((e,i,s,a)=>{const l=n[r];if(delete n[r],this.checkIfCanceled(r))return delete this.requests[r],void this._callWaitings(l,null,{canceled:!0});if(delete this.requests[r],(this.options.debug||o)&&i)for(let e=0;e<i.length;e++)if(this.options.debug&&(i[e]._debug_info={index:e,id:i[e].id,tileId:t.tileInfo.id}),o){const t=F(o)?o[i[e].layer]:o,n=i[e].properties;i[e].id=n&&n[t]||null}if(e)this._callWaitings(l,e);else if(i&&i.length){if(l)for(let t=0;t<l.length;t++)this._onTileLoad.call(l[t].ref,l[t].context,l[t].callback,r,s,i,a)}else this._callWaitings(l)}))}_onTileLoad(t,e,n,r,i,o){this._createTileData(r,i,t).then((n=>{n.canceled?e(null,{canceled:!0}):(n.data.styleCounter=t.styleCounter,o&&I(n.data,o),e(null,n.data,n.buffers))})).catch((t=>{e(t)}))}abortTile(t,e){delete this.requests[t],this._cancelLoadings(t),e()}_cancelLoadings(t){const e=this.loadings[t];if(e)for(let t=0;t<e.length;t++)e[t].callback(null,{canceled:!0});delete this.loadings[t]}_callWaitings(t,e,n){if(t)for(let r=0;r<t.length;r++)t[r].callback(e,n)}checkIfCanceled(t){return!this.requests[t]}onRemove(){this.loadings={},delete this._cache,this.requests={}}fetchIconGlyphs(t,e,n){if(this.options.workerGlyph&&cn){const r=[];if(t&&Object.keys(t).length){const e=new Promise((e=>{this.upload("fetchIconGlyphs",{icons:t},null,((t,n)=>{e({err:t,iconData:n})}))}));r.push(e)}if(e&&Object.keys(e).length){const t=new Promise((t=>{this._glyphRequestor||(this._glyphRequestor=new Sn),this._glyphRequestor.getGlyphs(e,((e,n)=>{t({err:e,glyphData:n})}))}));r.push(t)}Promise.all(r).then((t=>{const e={icons:null,glyphs:null};for(let r=0;r<t.length;r++){if(t[r].err)return void n(t[r].err);t[r].iconData?e.icons=t[r].iconData.icons:t[r].glyphData&&(e.glyphs=t[r].glyphData.glyphs)}return e})).then((t=>{n(null,t)}))}else this.upload("fetchIconGlyphs",{icons:t,glyphs:e},null,n)}_createTileData(t,e,n){if(!e.length)return Promise.resolve({data:null,buffers:[]});const{glScale:r,tileInfo:i}=n,o=!this.options.style.style.length&&!this.options.style.featureStyle.length;let s=this.pluginConfig.slice(0);o&&(s=this._updateLayerPluginConfig(t)),this.featurePlugins&&function(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}t.length}(s,this.featurePlugins);const a={};for(let t=0;t<s.length;t++)Xn(e,n.tileInfo.z,s[t],a);const l=[],u=[];for(let t=0;t<e.length;t++){const n=e[t],r=a[t];if(r){u.fill(null);let t=0;for(const e in r){let i=0;const o=r[e].values();for(const t of o){let r=u[i];r||(r=$n(n),u[i]=r),r.properties[e]=t,i++}i>t&&(t=i)}for(let e=0;e<t;e++)l.push(u[e])}else l.push(n)}const h=(e=l)[0].extent,c=i.z,f={x:i.extent2d.xmin*r,y:i.extent2d.ymax*r},p=[],d=[],g=[],y=this.options,x=[],m={},v=[Promise.resolve(n.styleCounter)];let w=0,M=-1;const b=[];let P=!1;for(let t=0;t<s.length;t++){M++;const r=s[t];r.type!==w&&(M=0,w=r.type);const a=0===r.type?p:d;if(r.symbol&&!1===r.symbol.visible){a[M]=null;continue}jn(r.symbol,b,t),P=P||b[t]&&b[t].size>0;const{tileFeatures:l,tileFeaIndexes:u}=this._filterFeatures(c,r.type,r.filter,e,m,t);if(!l.length){a[M]=null;continue}const y=u[u.length-1],_=Pn.getIndexArrayType(y);a[M]={styledFeatures:new _(u)},g.push({idx:t,typeIdx:M}),x.push(a[M].styledFeatures.buffer);const A=I({},n,{extent:h,zoom:c,tilePoint:f});if(this.options.debugTile){const t=this.options.debugTile;for(let e=0;e<t.length;e++){const{x:n,y:r,z:o}=t[e];if(i.x===n&&i.y===r&&i.z===o){A.debugIndex=t[e].index;break}}}let S=this._createTileGeometry(l,r,A);o&&(S=S.then((t=>{if(!t)return null;if(t.data)t.data.layer=l[0].layer;else if(Array.isArray(t))for(let e=0;e<t.length;e++)t[e]&&t[e].data&&(t[e].data.layer=l[0].layer);return t}))),v.push(S)}return Promise.all(v).then((([n,...r])=>{if(n!==this._styleCounter)return{canceled:!0};function i(t,e){if(void 0!==t.data.ref)return;const n=s[g[e].idx],r=n.renderPlugin.dataConfig;if(t.data.type=r.type,t.data.filter=n.filter.def,r.altitudeOffset&&(t.data.properties.minAltitude+=r.altitudeOffset,t.data.properties.maxAltitude+=r.altitudeOffset),t.buffers&&t.buffers.length)for(let e=0;e<t.buffers.length;e++)x.push(t.buffers[e])}for(let t=0;t<r.length;t++){if(!r[t])continue;const e=r[t],n=0===s[g[t].idx].type?p:d;if(Array.isArray(e)){const r=[];for(let n=0;n<e.length;n++)e[n]&&(i(e[n],t),(void 0===e[n].data.ref||e[e[n].data.ref])&&r.push(e[n].data));r.length&&(n[g[t].typeIdx].data=r)}else i(e,t),n[g[t].typeIdx].data=e.data}const o={},a=t;if(y.features||y.schema||P){let t,n=!1;for(let r=0,i=e.length;r<i;r++)if(t=e[r],a[t.layer].properties||(a[t.layer].properties=Cn(t.properties)),t&&(y.features||P&&m[r]))if("id"===y.features)o[r]=t.id;else{y.pickingGeometry||delete t.geometry,delete t.extent,delete t.properties.$layer,delete t.properties.$type,delete t.__index;const e=t.originalFeature;if(e){const e=t.properties,n=I({},t.originalFeature);delete e[Tn],n.customProps=I({},e),t=n}const i=I({},t);if(P&&m[r]&&(!y.features||"transient"===y.features)){const i=m[r];for(let r=0;r<i.length;r++){const i=b[r];i&&i.forEach((r=>{const i=e?e.properties:t.properties;i[Fn]||(i[Fn]=new Set),i[Fn].add(r),n=!0}))}}o[r]=i}if(n)for(const t in o){const e=o[t],n=e.properties[Fn];if(n){delete e.properties[Fn],"transient"===y.features&&(e.fnTypeProps=I({},e.properties));for(const t in e.properties)n.has(t)||("transient"===y.features?delete e.fnTypeProps[t]:delete e.properties[t])}}}return{data:{styleCounter:n,schema:a,data:p,featureData:d,extent:h,features:o},buffers:x}})).catch((t=>{console.error(t)}))}_createTileGeometry(t,e,n){let r=t;const i=e.renderPlugin.dataConfig,o=e.symbol,s=this.options.tileSize,{extent:a,glScale:l,zScale:u,zoom:h,tilePoint:c,centimeterToPoint:f,verticalCentimeterToPoint:p}=n,d=a/s,g=i.type,y=n.debugIndex;let x=I({},i,{EXTENT:a,zoom:h,debugIndex:y,features:this.options.features,isWebGPU:this.options.isWebGPU});if("3d-extrusion"===g){Yn(o)&&(i.uv=1);const t=this.options.projectionCode,e=o.material&&o.material.textureWidth||An;return Promise.all([Promise.resolve(je(r,i,a,c,e,n.tileInfo.res,l,a/this.options.tileSize,f,p,o,h,t,y))])}if("3d-wireframe"===g)return Promise.all([Promise.resolve(Ke(r,a,o,i))]);if("point"===g){x=I(x,{requestor:this.fetchIconGlyphs.bind(this),altitudeToTileScale:u*a/this.options.tileSize/l,pluginType:e.renderPlugin.type});let t=o;return Array.isArray(o)||(t=[o]),t=t.map(((t,e)=>(t&&(t.index={index:e},t.isIconText=function(t){return t.markerType||t.markerFile}(t)),t))).filter((t=>!!t)),Promise.all(t.map((t=>{const e=fn.genFnTypes(t);let n=r;return yn.needMerge(t,e,h)&&(n=yn.mergeLineFeatures(r,t,e,h)),new yn(n,t,x).load(d)})))}if("native-point"===g){const t=u*a/this.options.tileSize/l;return x.altitudeToTileScale=t,Vn(r,o,x,xn,d)}if("line"===g)return x=I(x,{requestor:this.fetchIconGlyphs.bind(this),tileRatio:d}),Vn(r,o,x,gn,1,!0);if("native-line"===g)return Vn(r,o,x,dn,1,!0);if("fill"===g)return x=I(x,{requestor:this.fetchIconGlyphs.bind(this)}),Vn(r,o,x,pn);if("line-extrusion"===g){delete o.lineGradientProperty,o.lineJoin="miter",o.lineCap="butt";const t=Yn(o);if(t&&(i.uv=1),x=I(x,{tileSize:s,zScale:u,glScale:l}),o.mergeOnProperty){const t=fn.genFnTypes(o);r=gn.mergeLineFeatures(r,o,t,x.zoom)}if(t){const t=[];if(!1!==i.top){const e=I({},x);e.side=!1,t.push(new mn(r,o,e))}return!1!==i.side&&(x.side=!0,x.top=!1,t.push(new mn(r,o,x))),Promise.all(t.map((t=>t.load())))}return Promise.all([new mn(r,o,x).load()])}if("circle"===g)return Vn(r,o,x,vn);if("round-tube"===g||"square-tube"===g){const t="round-tube"===g?wn:Mn;return x=I(x,{requestor:this.fetchIconGlyphs.bind(this),radialSegments:"round-tube"===g?i.radialSegments||8:4,centimeterToPoint:f,verticalCentimeterToPoint:p,tileRatio:d,isTube:!0}),Vn(r,o,x,t)}return Promise.resolve([])}_filterFeatures(t,e,n,r,i,o){const s=(te+"").trim(),a=[],l=[],u=r.length;for(let h=0;h<u;h++)if((1===e||void 0===r[h].id||!this.styledFeatures[r[h].id])&&((!n.def||"default"===n.def)&&!i[h]||!0===n.def||n.def&&(void 0!==n.def.condition||Array.isArray(n.def))&&n(r[h],t))){const t=r[h];if(void 0===t[s]&&(t[s]=h),i[h]||(i[h]=[]),i[h].push(o),l.push(t),a.push(h),1===e)break}return{tileFeatures:l,tileFeaIndexes:a}}_compileStyle(t){const{style:e,featureStyle:n}=t,r={};n.forEach((t=>{Array.isArray(t.id)?(t.id.forEach((t=>{r[t]=1})),t.filter=["in","$id",...t.id]):(r[t.id]=1,t.filter=["==","$id",t.id])}));const i=bn.compileStyle(e);for(let t=0;t<e.length;t++)i[t].filter&&(i[t].filter.def=e[t].filter?e[t].filter.value||e[t].filter:void 0),i[t].type=0;const o=[],s=bn.compileStyle(n);for(let t=0;t<n.length;t++)s[t].type=1,s[t].filter.def=n[t].filter?n[t].filter.value||n[t].filter:void 0,s[t].renderPlugin&&o.push(s[t]);this.pluginConfig=i,this.featurePlugins=o,this.styledFeatures=r}_updateLayerPluginConfig(t){let e=this._layerPlugins;this._layerPlugins||(e=this._layerPlugins={});const n=["","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"],r=[];for(const o in t){const s=o;if(!e[o]){const r=[];for(let e=0;e<t[o].types.length;e++){const a=t[o].types[e],l=["all",["==","$layer",s],["==","$type",n[a]]],u={filter:(i=l,new Function("f",\`var p = (f && f.properties || {}); return ${s}tn(i)}\`)),renderPlugin:Bn(a),symbol:Ln(a)};u.filter.def=l,u.type=0,r.push(u)}e[s]=r}r.push(...e[s])}var i;return r}}function Bn(t){switch(t){case 1:return{type:"native-point",dataConfig:{type:"native-point",only2D:!0}};case 2:return{type:"native-line",dataConfig:{type:"native-line",only2D:!0}};case 3:return{type:"fill",dataConfig:{type:"fill",only2D:!0}}}return null}function Ln(t){switch(t){case 1:return{markerFill:"#f00",markerSize:10};case 2:return{lineColor:"#fff"};case 3:return{polygonFill:"#00f",polygonOpacity:.4}}return null}function Cn(t){if(Array.isArray(t)||!F(t))return{};const e={};for(const n in t){const r=t[n];A(r)?e[n]="string":S(r)?e[n]="number":!0===r||!1===r?e[n]="boolean":Array.isArray(r)?e[n]="array":e[n]="object"}return e}function Yn(t){if(!t)return 0;let e=0;for(const n in t){if(("normalTexture"===n||"bumpTexture"===n)&&t[n])return 2;if(n.indexOf("Texture")>0&&t[n])e=1;else if(F(t[n])){const r=Yn(t[n]);if(2===r)return r;1===r&&(e=1)}}return e}function Vn(t,e,n,r,i,o){const s={},a=Array.isArray(e)?e:[e];let l=-1;for(let t=0;t<a.length;t++)s[t]=On(a[t]),!s[t]&&a[t]&&-1===l&&(l=t);const u=[];for(let e=0;e<a.length;e++){if(!a[e])continue;a[e].index={index:e};let h=t;if(o&&a[e].mergeOnProperty){const r=fn.genFnTypes(a[e]);h=gn.mergeLineFeatures(t,a[0],r,n.zoom)}s[e]||e===l?u.push(new r(h,a[e],n).load(i)):u.push({data:{ref:l,symbolIndex:{index:e}}})}return Promise.all(u)}function On(t){if(!t)return 0;for(const e in t)if(B(t[e]))return 1;return 0}function Xn(t,e,n,r){const i=n.customProperties;if(!i)return t;if(i)for(let t=0;t<i.length;t++)i[t].fn=bn.compileFilter(i[t].filter);for(let n=0;n<i.length;n++)for(let o=0,s=t.length;o<s;o++)if(i[n].fn(t[o],e))for(const t in i[n].properties){const e=i[n].properties[t];k(e)||(r[o]||(r[o]={}),r[o][t]||(r[o][t]=new Set),r[o][t].add(e))}}const Nn={get:(t,e)=>e in t?t[e]:t.originalFeature[e],has:(t,e)=>e in t||e in t.originalFeature},En={get:function(t,e){return e in t?t[e]:t[Tn][e]},has:(t,e)=>e in t||e in t[Tn]},zn={};function $n(t){const e={};e.originalFeature=t;const n=new Proxy(e,Nn);return n.properties=new Proxy({},En),n.properties[Tn]=t.properties||zn,n}function Dn(t,e,n){t[e]||(t[e]=new Set),t[e].add(n)}const qn=[];function jn(t,e,n){if(!t)return qn;for(const r in t){if(!t[r]||!_n.checkIfZoomFnTypeSymbol(r))continue;if(B(t[r]))Dn(e,n,t[r].property);else{if("lineGradientProperty"===r){Dn(e,n,t[r]);continue}if("textName"===r)if(A(t[r])){const i=In.resolveVarNames(t[r]);if(i)for(let t=0;t<i.length;t++)Dn(e,n,i[t])}else if(bn.isExpression(t[r])){const i=[];In.resolveExpVarNames(i,t[r]);for(let t=0;t<i.length;t++)Dn(e,n,i[t])}}const i=t[r].stops;if(i&&i.length)for(let t=0;t<i.length;t++)B(i[t][1])&&Dn(e,t,i[t][1].property)}return e[n]}function Gn(t,e){Zn(t.geometry,e)}function Zn(t,e){if(t)switch(t.type){case"Point":Un(t.coordinates,e);break;case"MultiPoint":case"LineString":Rn(t.coordinates,e);break;case"MultiLineString":!function(t,e){for(let n=0,r=t.length;n<r;n++)Rn(t[n],e)}(t.coordinates,e);break;case"Polygon":Jn(t.coordinates,e);break;case"MultiPolygon":!function(t,e){for(let n=0,r=t.length;n<r;n++)Jn(t[n],e)}(t.coordinates,e);break;case"GeometryCollection":const n=t.geometries.length;for(let r=0;r<n;r++)Zn(t.geometries[r],e)}}function Un(t,e){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Rn(t,e){for(let n=0,r=t.length;n<r;n++)Un(t[n],e)}function Jn(t,e){t.length&&Rn(t[0],e)}function Hn(t,e,n,r,i){Wn(t,e,n||0,r||t.length-1,i||Qn)}function Wn(t,e,n,r,i){for(;r>n;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Wn(t,e,Math.max(n,Math.floor(e-s*l/o+u)),Math.min(r,Math.floor(e+(o-s)*l/o+u)),i)}var h=t[e],c=n,f=r;for(Kn(t,n,e),i(t[r],h)>0&&Kn(t,n,r);c<f;){for(Kn(t,c,f),c++,f--;i(t[c],h)<0;)c++;for(;i(t[f],h)>0;)f--}0===i(t[n],h)?Kn(t,n,f):Kn(t,++f,r),f<=e&&(n=f+1),e<=f&&(r=f-1)}}function Kn(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Qn(t,e){return t<e?-1:t>e?1:0}class tr{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 n=[];if(!cr(t,e))return n;const r=this.toBBox,i=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],a=e.leaf?r(s):s;cr(t,a)&&(e.leaf?n.push(s):hr(t,a)?this._all(s,n):i.push(s))}e=i.pop()}return n}collides(t){let e=this.data;if(!cr(t,e))return!1;const n=[];for(;e;){for(let r=0;r<e.children.length;r++){const i=e.children[r],o=e.leaf?this.toBBox(i):i;if(cr(t,o)){if(e.leaf||hr(t,o))return!0;n.push(i)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=fr([]),this}remove(t,e){if(!t)return this;let n=this.data;const r=this.toBBox(t),i=[],o=[];let s,a,l;for(;n||i.length;){if(n||(n=i.pop(),a=i[i.length-1],s=o.pop(),l=!0),n.leaf){const r=er(t,n.children,e);if(-1!==r)return n.children.splice(r,1),i.push(n),this._condense(i),this}l||n.leaf||!hr(n,r)?a?(s++,n=a.children[s],l=!1):n=null:(i.push(n),o.push(s),s=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,r){const i=n-e+1;let o,s=this._maxEntries;if(i<=s)return o=fr(t.slice(e,n+1)),nr(o,this.toBBox),o;r||(r=Math.ceil(Math.log(i)/Math.log(s)),s=Math.ceil(i/Math.pow(s,r-1))),o=fr([]),o.leaf=!1,o.height=r;const a=Math.ceil(i/s),l=a*Math.ceil(Math.sqrt(s));pr(t,e,n,l,this.compareMinX);for(let i=e;i<=n;i+=l){const e=Math.min(i+l-1,n);pr(t,i,e,a,this.compareMinY);for(let n=i;n<=e;n+=a){const i=Math.min(n+a-1,e);o.children.push(this._build(t,n,i,r-1))}}return nr(o,this.toBBox),o}_chooseSubtree(t,e,n,r){for(;r.push(e),!e.leaf&&r.length-1!==n;){let n,r=1/0,s=1/0;for(let a=0;a<e.children.length;a++){const l=e.children[a],u=ar(l),h=(i=t,o=l,(Math.max(o.maxX,i.maxX)-Math.min(o.minX,i.minX))*(Math.max(o.maxY,i.maxY)-Math.min(o.minY,i.minY))-u);h<s?(s=h,r=u<r?u:r,n=l):h===s&&u<r&&(r=u,n=l)}e=n||e.children[0]}var i,o;return e}_insert(t,e,n){const r=n?t:this.toBBox(t),i=[],o=this._chooseSubtree(r,this.data,e,i);for(o.children.push(t),ir(o,r);e>=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)}_split(t,e){const n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);const o=this._chooseSplitIndex(n,i,r),s=fr(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,nr(n,this.toBBox),nr(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=fr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,nr(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let r,i=1/0,o=1/0;for(let s=e;s<=n-e;s++){const e=rr(t,0,s,this.toBBox),a=rr(t,s,n,this.toBBox),l=ur(e,a),u=ar(e)+ar(a);l<i?(i=l,r=s,o=u<o?u:o):l===i&&u<o&&(o=u,r=s)}return r||n-e}_chooseSplitAxis(t,e,n){const r=t.leaf?this.compareMinX:or,i=t.leaf?this.compareMinY:sr;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)}_allDistMargin(t,e,n,r){t.children.sort(r);const i=this.toBBox,o=rr(t,0,e,i),s=rr(t,n-e,n,i);let a=lr(o)+lr(s);for(let r=e;r<n-e;r++){const e=t.children[r];ir(o,t.leaf?i(e):e),a+=lr(o)}for(let r=n-e-1;r>=e;r--){const e=t.children[r];ir(s,t.leaf?i(e):e),a+=lr(s)}return a}_adjustParentBBoxes(t,e,n){for(let r=n;r>=0;r--)ir(e[r],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():nr(t[n],this.toBBox)}}function er(t,e,n){if(!n)return e.indexOf(t);for(let r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function nr(t,e){rr(t,0,t.children.length,e,t)}function rr(t,e,n,r,i){i||(i=fr(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let o=e;o<n;o++){const e=t.children[o];ir(i,t.leaf?r(e):e)}return i}function ir(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function or(t,e){return t.minX-e.minX}function sr(t,e){return t.minY-e.minY}function ar(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function lr(t){return t.maxX-t.minX+(t.maxY-t.minY)}function ur(t,e){const n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}function hr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function cr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function fr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function pr(t,e,n,r,i){const o=[e,n];for(;o.length;){if((n=o.pop())-(e=o.pop())<=r)continue;const s=e+Math.ceil((n-e)/r/2)*r;Hn(t,s,e,n,i),o.push(e,s,s,n)}}class dr{constructor(t=[],e=gr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)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:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let r=1+(t<<1),o=e[r];const s=r+1;if(s<this.length&&n(e[s],o)<0&&(r=s,o=e[s]),n(o,i)>=0)break;e[t]=o,t=r}e[t]=i}}function gr(t,e){return t<e?-1:t>e?1:0}function yr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xr={exports:{}},mr=function(t,e,n,r){var i=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var a=(r-n)/2,l=0,u=a-1;l<a;u=l++){var h=e[n+2*l+0],c=e[n+2*l+1],f=e[n+2*u+0],p=e[n+2*u+1];c>o!=p>o&&i<(f-h)*(o-c)/(p-c)+h&&(s=!s)}return s},vr=function(t,e,n,r){var i=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var a=r-n,l=0,u=a-1;l<a;u=l++){var h=e[l+n][0],c=e[l+n][1],f=e[u+n][0],p=e[u+n][1];c>o!=p>o&&i<(f-h)*(o-c)/(p-c)+h&&(s=!s)}return s};xr.exports=function(t,e,n,r){return e.length>0&&Array.isArray(e[0])?vr(t,e,n,r):mr(t,e,n,r)};var wr=xr.exports.nested=vr;xr.exports.flat=mr;const Mr=11102230246251565e-32,br=134217729,Pr=(3+8*Mr)*Mr;function _r(t,e,n,r,i){let o,s,a,l,u=e[0],h=r[0],c=0,f=0;h>u==h>-u?(o=u,u=e[++c]):(o=h,h=r[++f]);let p=0;if(c<t&&f<n)for(h>u==h>-u?(s=u+o,a=o-(s-u),u=e[++c]):(s=h+o,a=o-(s-h),h=r[++f]),o=s,0!==a&&(i[p++]=a);c<t&&f<n;)h>u==h>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c]):(s=o+h,l=s-o,a=o-(s-l)+(h-l),h=r[++f]),o=s,0!==a&&(i[p++]=a);for(;c<t;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c],o=s,0!==a&&(i[p++]=a);for(;f<n;)s=o+h,l=s-o,a=o-(s-l)+(h-l),h=r[++f],o=s,0!==a&&(i[p++]=a);return 0===o&&0!==p||(i[p++]=o),p}function Ir(t){return new Float64Array(t)}const Ar=33306690738754716e-32,Sr=22204460492503146e-32,Tr=11093356479670487e-47,Fr=Ir(4),kr=Ir(8),Br=Ir(12),Lr=Ir(16),Cr=Ir(4);function Yr(t,e,n,r,i,o){const s=(e-o)*(n-i),a=(t-i)*(r-o),l=s-a;if(0===s||0===a||s>0!=a>0)return l;const u=Math.abs(s+a);return Math.abs(l)>=Ar*u?l:-function(t,e,n,r,i,o,s){let a,l,u,h,c,f,p,d,g,y,x,m,v,w,M,b,P,_;const I=t-i,A=n-i,S=e-o,T=r-o;w=I*T,f=br*I,p=f-(f-I),d=I-p,f=br*T,g=f-(f-T),y=T-g,M=d*y-(w-p*g-d*g-p*y),b=S*A,f=br*S,p=f-(f-S),d=S-p,f=br*A,g=f-(f-A),y=A-g,P=d*y-(b-p*g-d*g-p*y),x=M-P,c=M-x,Fr[0]=M-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-b,c=v-x,Fr[1]=v-(x+c)+(c-b),_=m+x,c=_-m,Fr[2]=m-(_-c)+(x-c),Fr[3]=_;let F=function(t,e){let n=e[0];for(let r=1;r<t;r++)n+=e[r];return n}(4,Fr),k=Sr*s;if(F>=k||-F>=k)return F;if(c=t-I,a=t-(I+c)+(c-i),c=n-A,u=n-(A+c)+(c-i),c=e-S,l=e-(S+c)+(c-o),c=r-T,h=r-(T+c)+(c-o),0===a&&0===l&&0===u&&0===h)return F;if(k=Tr*s+Pr*Math.abs(F),F+=I*h+T*a-(S*u+A*l),F>=k||-F>=k)return F;w=a*T,f=br*a,p=f-(f-a),d=a-p,f=br*T,g=f-(f-T),y=T-g,M=d*y-(w-p*g-d*g-p*y),b=l*A,f=br*l,p=f-(f-l),d=l-p,f=br*A,g=f-(f-A),y=A-g,P=d*y-(b-p*g-d*g-p*y),x=M-P,c=M-x,Cr[0]=M-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-b,c=v-x,Cr[1]=v-(x+c)+(c-b),_=m+x,c=_-m,Cr[2]=m-(_-c)+(x-c),Cr[3]=_;const B=_r(4,Fr,4,Cr,kr);w=I*h,f=br*I,p=f-(f-I),d=I-p,f=br*h,g=f-(f-h),y=h-g,M=d*y-(w-p*g-d*g-p*y),b=S*u,f=br*S,p=f-(f-S),d=S-p,f=br*u,g=f-(f-u),y=u-g,P=d*y-(b-p*g-d*g-p*y),x=M-P,c=M-x,Cr[0]=M-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-b,c=v-x,Cr[1]=v-(x+c)+(c-b),_=m+x,c=_-m,Cr[2]=m-(_-c)+(x-c),Cr[3]=_;const L=_r(B,kr,4,Cr,Br);w=a*h,f=br*a,p=f-(f-a),d=a-p,f=br*h,g=f-(f-h),y=h-g,M=d*y-(w-p*g-d*g-p*y),b=l*u,f=br*l,p=f-(f-l),d=l-p,f=br*u,g=f-(f-u),y=u-g,P=d*y-(b-p*g-d*g-p*y),x=M-P,c=M-x,Cr[0]=M-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-b,c=v-x,Cr[1]=v-(x+c)+(c-b),_=m+x,c=_-m,Cr[2]=m-(_-c)+(x-c),Cr[3]=_;const C=_r(L,Br,4,Cr,Lr);return Lr[C-1]}(t,e,n,r,i,o,u)}function Vr(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;var r=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;o<t.length;o++){var s=t[o];s[0]<e[0]&&(e=s),s[0]>r[0]&&(r=s),s[1]<n[1]&&(n=s),s[1]>i[1]&&(i=s)}var a=[e,n,r,i],l=a.slice();for(o=0;o<t.length;o++)wr(t[o],a)||l.push(t[o]);return function(t){t.sort(Ur);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&$r(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var r=[],i=t.length-1;i>=0;i--){for(;r.length>=2&&$r(r[r.length-2],r[r.length-1],t[i])<=0;)r.pop();r.push(t[i])}return r.pop(),e.pop(),e.concat(r)}(l)}(t),i=new tr(16);i.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},i.compareMinX=function(t,e){return t[0]-e[0]},i.compareMinY=function(t,e){return t[1]-e[1]},i.load(t);for(var o,s=[],a=0;a<r.length;a++){var l=r[a];i.remove(l),o=qr(l,o),s.push(o)}var u=new tr(16);for(a=0;a<s.length;a++)u.insert(Dr(s[a]));for(var h=e*e,c=n*n;s.length;){var f=s.shift(),p=f.p,d=f.next.p,g=jr(p,d);if(!(g<c)){var y=g/h;(l=Or(i,f.prev.p,p,d,f.next.next.p,y,u))&&Math.min(jr(l,p),jr(l,d))<=y&&(s.push(f),s.push(qr(l,f)),i.remove(l),u.remove(f),u.insert(Dr(f)),u.insert(Dr(f.next)))}}f=o;var x=[];do{x.push(f.p),f=f.next}while(f!==o);return x.push(f.p),x}function Or(t,e,n,r,i,o,s){for(var a=new dr([],Xr),l=t.data;l;){for(var u=0;u<l.children.length;u++){var h=l.children[u],c=l.leaf?Gr(h,n,r):Nr(n,r,h);c>o||a.push({node:h,dist:c})}for(;a.length&&!a.peek().node.children;){var f=a.pop(),p=f.node,d=Gr(p,e,n),g=Gr(p,r,i);if(f.dist<d&&f.dist<g&&zr(n,p,s)&&zr(r,p,s))return p}(l=a.pop())&&(l=l.node)}return null}function Xr(t,e){return t.dist-e.dist}function Nr(t,e,n){if(Er(t,n)||Er(e,n))return 0;var r=Zr(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===r)return 0;var i=Zr(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===i)return 0;var o=Zr(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=Zr(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(r,i,o,s)}function Er(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function zr(t,e,n){for(var r,i,o,s,a=Math.min(t[0],e[0]),l=Math.min(t[1],e[1]),u=Math.max(t[0],e[0]),h=Math.max(t[1],e[1]),c=n.search({minX:a,minY:l,maxX:u,maxY:h}),f=0;f<c.length;f++)if(r=c[f].p,i=c[f].next.p,o=t,r!==(s=e)&&i!==o&&$r(r,i,o)>0!=$r(r,i,s)>0&&$r(o,s,r)>0!=$r(o,s,i)>0)return!1;return!0}function $r(t,e,n){return Yr(t[0],t[1],e[0],e[1],n[0],n[1])}function Dr(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function qr(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function jr(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function Gr(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(0!==o||0!==s){var a=((t[0]-r)*o+(t[1]-i)*s)/(o*o+s*s);a>1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a)}return(o=t[0]-r)*o+(s=t[1]-i)*s}function Zr(t,e,n,r,i,o,s,a){var l,u,h,c,f=n-t,p=r-e,d=s-i,g=a-o,y=t-i,x=e-o,m=f*f+p*p,v=f*d+p*g,w=d*d+g*g,M=f*y+p*x,b=d*y+g*x,P=m*w-v*v,_=P,I=P;0===P?(u=0,_=1,c=b,I=w):(c=m*b-v*M,(u=v*b-w*M)<0?(u=0,c=b,I=w):u>_&&(u=_,c=b+v,I=w)),c<0?(c=0,-M<0?u=0:-M>m?u=_:(u=-M,_=m)):c>I&&(c=I,-M+v<0?u=0:-M+v>m?u=_:(u=-M+v,_=m));var A=(1-(h=0===c?0:c/I))*i+h*s-((1-(l=0===u?0:u/_))*t+l*n),S=(1-h)*o+h*a-((1-l)*e+l*r);return A*A+S*S}function Ur(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}const{PackUtil:Rr}=ne();class Jr{constructor(t,e){this.x=t,this.y=e}clone(){return new Jr(this.x,this.y)}normalize(){const t=this.length();this.x/=t,this.y/=t}negate(){this.x=-this.x,this.y=-this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}diff(t){return new Jr(this.x-t.x,this.y-t.y)}distance(t){const e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x===t.x&&this.y===t.y}orthogonal(){return new Jr(this.y,-this.x)}}function Hr(t,e,n,r){const i=e.x*r.y-e.y*r.x,o=n.x-t.x,s=n.y-t.y,a=(o*r.y-s*r.x)/i;return new Jr(t.x+a*e.x,t.y+a*e.y)}const Wr=[],Kr=[];function Qr(t){if(S(t[0]&&t[0].x)){const e=[];let n=0;for(let r=0;r<t.length;r++)Kr[n]?(Kr[n][0]=t[r].x,Kr[n][1]=t[r].y):Kr[n]=[t[r].x,t[r].y],e.push(Kr[n]),n++;t=e}try{const e=Vr(t,1/0);let n=[1/0,1/0],r=[-1/0,-1/0];for(let t=0;t<e.length;t++)e[t][0]<n[0]&&(n[0]=e[t][0]),e[t][0]>r[0]&&(r[0]=e[t][0]),e[t][1]<n[1]&&(n[1]=e[t][1]),e[t][1]>r[1]&&(r[1]=e[t][1]);const i=[];let o=[],s=0;for(let t=0;t<e.length;t++)t===e.length-1&&e[t][0]===e[0][0]&&e[t][1]===e[0][1]||(Pt(i,e[t],"EPSG:3857"),Wr[s]?(Wr[s].x=i[0],Wr[s].y=i[1]):Wr[s]=new Jr(i[0],i[1]),o.push(Wr[s]),s++);Rr.calculateSignedArea(o)<0&&(o=o.reverse());const a=function(t){let e,n=Number.MAX_VALUE;const r=function(t,r,i,o,s,a,l,u){var h=Hr(t,r,s,a),c=Hr(i,o,s,a),f=Hr(l,u,t,r),p=Hr(l,u,i,o),d=h.distance(c)*h.distance(f);0!==d&&d<n&&(e=[h,f,p,c],n=d)};var i=[];for(let e=0;e<t.length;e++)i.push(t[(e+1)%t.length].diff(t[e])),i[e].normalize();var o,s,a,l,u=new Jr(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new Jr(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let e=0;e<t.length;e++){var c=t[e];c.x<u.x&&(u.x=c.x,o=e),c.x>h.x&&(h.x=c.x,s=e),c.y<u.y&&(u.y=c.y,l=e),c.y>h.y&&(h.y=c.y,a=e)}var f=new Jr(0,-1),p=new Jr(0,1),d=new Jr(-1,0),g=new Jr(1,0);for(let e=0;e<t.length;e++){var y=[Math.acos(f.dot(i[o])),Math.acos(p.dot(i[s])),Math.acos(d.dot(i[a])),Math.acos(g.dot(i[l]))];switch(y.indexOf(Math.min.apply(Math,y))){case 0:(p=(f=i[o].clone()).clone()).negate(),(g=(d=f.orthogonal()).clone()).negate(),o=(o+1)%t.length;break;case 1:(f=(p=i[s].clone()).clone()).negate(),(g=(d=f.orthogonal()).clone()).negate(),s=(s+1)%t.length;break;case 2:(g=(d=i[a].clone()).clone()).negate(),(p=(f=g.orthogonal()).clone()).negate(),a=(a+1)%t.length;break;case 3:(d=(g=i[l].clone()).clone()).negate(),(p=(f=g.orthogonal()).clone()).negate(),l=(l+1)%t.length}r(t[o],f,t[s],p,t[a],d,t[l],g)}return e}(o);if(!a||4!==a.length)return null;const l=a[0].distance(a[1]),u=a[1].distance(a[2]),h=a.map((t=>[t.x,t.y]));return h.push(+(u>l)),h}catch(t){return null}}const ti=[];function ei(t,e){const n=Array.isArray(t&&t[0]&&t[0][0]);for(let r=0;r<t.length;r++)n?t[r]=ei(t[r]):(Pt(ti,t[r],e),t[r][0]=ti[0],t[r][1]=ti[1]);return t}const{PackUtil:ni}=ne();class ri extends kn{constructor(t,e,n,r,i,o){super(t,e,n,r,i),(e=e||{}).extent||(e.extent=8192),this.setData(e.data,o)}setData(t,e){if(delete this.index,function(t){if(!t)return!0;if(Array.isArray(t)&&!t.length)return!0;if(t.features&&!t.features.length)return!0;return!1}(t))return this.empty=!0,void e();const n={maxZoom:24,tolerance:this.options.simplifyTolerance,extent:this.options.extent,buffer:S(this.options.tileBuffer)?this.options.tileBuffer:64,hasAltitude:!!this.options.hasAltitude,debug:0,lineMetrics:!0,indexMaxZoom:5,indexMaxPoints:1e5,disableFilter:!0};if(this.options.projection&&(n.projection=this.options.projection,"EPSG:4490"===n.projection&&(n.projection="EPSG:4326")),A(t)&&"{"!=t.substring(0,1)||t.url){const r=t.url?t.url:t;C.getJSON(r,t.url?t:{},((t,i)=>{if(t&&(console.error("Failed to fetch geojson:"+r),e(t)),!i)return void e(null,{extent:null,idMap:{}});let o=i;if(this.options.convertFn){o=new Function("data",this.options.convertFn+"\\nreturn convert(data)")(o)}const s=Array.isArray(o)?o:o.features;this._genOMBB(s);const{sample1000:a,idMap:l}=this._generateId(s);this._generate(a,l,o,n,e)}))}else{"string"==typeof t&&(t=JSON.parse(t));const r=Array.isArray(t)?t:t.features,i=r&&r.length;this._genOMBB(r);let o=r;if(r&&i>1e3){o=[];for(let t=0;t<i;t++)ii(r[t],o,t,i)}this._generate(o,null,t,n,e)}}_genOMBB(t){if(this.options.generateOMBB&&t)for(let e=0;e<t.length;e++){const n=t[e];if(n&&n.geometry&&n.geometry.coordinates)if("Polygon"===n.geometry.type){const t=n.geometry.coordinates[0];if(!t)continue;const e=Qr(t,t.length);n.properties=n.properties||{},n.properties[ee]=e}else if("MultiPolygon"===n.geometry.type){const t=n.geometry.coordinates;for(let e=0;e<t.length;e++){if(!t[e])continue;const r=t[e][0];if(!r)continue;const i=Qr(r,r.length);n.properties=n.properties||{},n.properties[ee]=n.properties[ee]||[],n.properties[ee][e]=i}}}}_generate(t,e,n,r,i){try{const o=t&&t.length?function(t){let e=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];switch(t.type){case"FeatureCollection":const n=t.features.length;for(let r=0;r<n;r++)Gn(t.features[r],e);break;case"Feature":Gn(t,e);break;default:Zn(t,e)}return e}({type:"FeatureCollection",features:t}):null;this.index=function(t,e){return new ut(t,e)}(n,this.options.geojsonvt||r),i(null,{extent:o,idMap:e})}catch(t){console.warn(t),i({error:t.message})}}_generateId(t){const e=[],n={};let r=0;const i=this.options.featureIdProperty;if(t){const o=t.length;t.forEach(((t,s)=>{!function(t,o,s){if(t&&("Feature"!==t.type||t.geometry)){if(S(t.id)||(t.id=r++),i){let e=i;F(i)&&(e=i[t.layer||"0"]),t.id=t.properties[e]}n[t.id]=I({},t),t.geometry?(n[t.id].geometry=I({},t.geometry),n[t.id].geometry.coordinates=null):t.coordinates&&(n[t.id].coordinates=null),ii(t,e,o,s)}}(t,s,o)}))}return{sample1000:e,idMap:n}}getTileFeatures(t,e){const n=t.tileInfo,r=[];if(!this.index)return this.empty?(setTimeout((function(){e(null,r,[])}),1),1):(setTimeout((function(){e({loading:!0})}),1),1);const i=this.index.getTile(n.z,n.x,n.y);if(!i||0===i.features.length)return setTimeout((function(){e(null,r,[])}),1),1;const o=[];for(let t=0,e=i.features.length;t<e;t++){const e=i.features[t];let n=e.layer;void 0===n&&(n="0"),o[n]={types:{}};o[n].types[e.type]=1,e.tags=e.tags||{},e.geometry.converted||(ni.convertGeometry(e),e.geometry.converted=1),r.push({type:e.type,layer:n,id:e.id,geometry:e.geometry,properties:e.tags,extent:this.options.extent})}for(const t in o)o[t].types=Object.keys(o[t].types).map((t=>+t));return setTimeout((function(){e(null,r,o)}),1),1}onRemove(){super.onRemove(),delete this.index}}function ii(t,e,n,r){const i=Math.floor(r/998);(0===n||n===r-1||(0===i||n%i==0)&&e.length<999)&&e.push(t)}var oi={\n/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nread:function(t,e,n,r,i){var o,s,a=8*i-r-1,l=(1<<a)-1,u=l>>1,h=-7,c=n?i-1:0,f=n?-1:1,p=t[e+c];for(c+=f,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+c],c+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+t[e+c],c+=f,h-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=u}return(p?-1:1)*s*Math.pow(2,o-r)},write:function(t,e,n,r,i,o){var s,a,l,u=8*o-i-1,h=(1<<u)-1,c=h>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=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=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+c>=1?f/l:f*Math.pow(2,1-c))*l>=2&&(s++,l/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(e*l-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[n+p]=255&s,p+=d,s/=256,u-=8);t[n+p-d]|=128*g}},si=li,ai=oi;function li(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}li.Varint=0,li.Fixed64=1,li.Bytes=2,li.Fixed32=5;var ui=4294967296,hi=1/ui,ci="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function fi(t){return t.type===li.Bytes?t.readVarint()+t.pos:t.pos+1}function pi(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function di(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function gi(t,e){for(var n=0;n<t.length;n++)e.writeVarint(t[n])}function yi(t,e){for(var n=0;n<t.length;n++)e.writeSVarint(t[n])}function xi(t,e){for(var n=0;n<t.length;n++)e.writeFloat(t[n])}function mi(t,e){for(var n=0;n<t.length;n++)e.writeDouble(t[n])}function vi(t,e){for(var n=0;n<t.length;n++)e.writeBoolean(t[n])}function wi(t,e){for(var n=0;n<t.length;n++)e.writeFixed32(t[n])}function Mi(t,e){for(var n=0;n<t.length;n++)e.writeSFixed32(t[n])}function bi(t,e){for(var n=0;n<t.length;n++)e.writeFixed64(t[n])}function Pi(t,e){for(var n=0;n<t.length;n++)e.writeSFixed64(t[n])}function _i(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function Ii(t,e,n){t[n]=e,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function Ai(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}li.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,o=this.pos;this.type=7&r,t(i,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=_i(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Ai(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_i(this.buf,this.pos)+_i(this.buf,this.pos+4)*ui;return this.pos+=8,t},readSFixed64:function(){var t=_i(this.buf,this.pos)+Ai(this.buf,this.pos+4)*ui;return this.pos+=8,t},readFloat:function(){var t=ai.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ai.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,o=n.buf;if(i=o[n.pos++],r=(112&i)>>4,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<3,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<10,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<17,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<24,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(1&i)<<31,i<128)return pi(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&ci?function(t,e,n){return ci.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){var r="",i=e;for(;i<n;){var o,s,a,l=t[i],u=null,h=l>239?4:l>223?3:l>191?2:1;if(i+h>n)break;1===h?l<128&&(u=l):2===h?128==(192&(o=t[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===h?(o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&((u=(15&l)<<12|(63&o)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===h&&(o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&((u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,h=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==li.Bytes)return t.push(this.readVarint(e));var n=fi(this);for(t=t||[];this.pos<n;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==li.Bytes)return t.push(this.readSVarint());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==li.Bytes)return t.push(this.readBoolean());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==li.Bytes)return t.push(this.readFloat());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==li.Bytes)return t.push(this.readDouble());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==li.Bytes)return t.push(this.readFixed32());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==li.Bytes)return t.push(this.readSFixed32());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==li.Bytes)return t.push(this.readFixed64());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==li.Bytes)return t.push(this.readSFixed64());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===li.Varint)for(;this.buf[this.pos++]>127;);else if(e===li.Bytes)this.pos=this.readVarint()+this.pos;else if(e===li.Fixed32)this.pos+=4;else{if(e!==li.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Ii(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Ii(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Ii(this.buf,-1&t,this.pos),Ii(this.buf,Math.floor(t*hi),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Ii(this.buf,-1&t,this.pos),Ii(this.buf,Math.floor(t*hi),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var n,r;t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){var n=(7&t)<<4;if(e.buf[e.pos++]|=n|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var r,i,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){r>56319||o+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&di(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),ai.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ai.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n<e;n++)this.buf[this.pos++]=t[n]},writeRawMessage:function(t,e){this.pos++;var n=this.pos;t(e,this);var r=this.pos-n;r>=128&&di(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,li.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,gi,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,yi,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,vi,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xi,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,mi,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,wi,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,Mi,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,bi,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Pi,e)},writeBytesField:function(t,e){this.writeTag(t,li.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,li.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,li.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,li.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,li.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,li.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,li.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,li.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,li.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,li.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Si=yr(si),Ti=Fi;function Fi(t,e){this.x=t,this.y=e}Fi.prototype={clone:function(){return new Fi(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,i=n*this.x+e*this.y;return this.x=r,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.x+n*(this.x-e.x)-r*(this.y-e.y),o=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=i,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Fi.convert=function(t){return t instanceof Fi?t:Array.isArray(t)?new Fi(t[0],t[1]):t};var ki=Ti,Bi=Li;function Li(t,e,n,r,i){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=i,t.readFields(Ci,this,e)}function Ci(t,e,n){1==t?e.id=n.readVarint():2==t?function(t,e){var n=t.readVarint()+t.pos;for(;t.pos<n;){var r=e._keys[t.readVarint()],i=e._values[t.readVarint()];e.properties[r]=i}}(n,e):3==t?e.type=n.readVarint():4==t&&(e._geometry=n.pos)}function Yi(t){for(var e,n,r=0,i=0,o=t.length,s=o-1;i<o;s=i++)e=t[i],r+=((n=t[s]).x-e.x)*(e.y+n.y);return r}Li.types=["Unknown","Point","LineString","Polygon"],Li.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,n=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,a=[];t.pos<n;){if(i<=0){var l=t.readVarint();r=7&l,i=l>>3}if(i--,1===r||2===r)o+=t.readSVarint(),s+=t.readSVarint(),1===r&&(e&&a.push(e),e=[]),e.push(new ki(o,s));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&a.push(e),a},Li.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();n=7&h,r=h>>3}if(r--,1===n||2===n)(i+=t.readSVarint())<s&&(s=i),i>a&&(a=i),(o+=t.readSVarint())<l&&(l=o),o>u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[s,l,a,u]},Li.prototype.toGeoJSON=function(t,e,n){var r,i,o=this.extent*Math.pow(2,n),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),u=Li.types[this.type];function h(t){for(var e=0;e<t.length;e++){var n=t[e],r=180-360*(n.y+a)/o;t[e]=[360*(n.x+s)/o-180,360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90]}}switch(this.type){case 1:var c=[];for(r=0;r<l.length;r++)c[r]=l[r][0];h(l=c);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var n,r,i=[],o=0;o<e;o++){var s=Yi(t[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(n&&i.push(n),n=[t[o]]):n.push(t[o]))}n&&i.push(n);return i}(l),r=0;r<l.length;r++)for(i=0;i<l[r].length;i++)h(l[r][i])}1===l.length?l=l[0]:u="Multi"+u;var f={type:"Feature",geometry:{type:u,coordinates:l},properties:this.properties};return"id"in this&&(f.id=this.id),f};var Vi=Bi,Oi=Xi;function Xi(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ni,this,e),this.length=this._features.length}function Ni(t,e,n){15===t?e.version=n.readVarint():1===t?e.name=n.readString():5===t?e.extent=n.readVarint():2===t?e._features.push(n.pos):3===t?e._keys.push(n.readString()):4===t&&e._values.push(function(t){var e=null,n=t.readVarint()+t.pos;for(;t.pos<n;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}Xi.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 Vi(this._pbf,e,this.extent,this._keys,this._values)};var Ei=Oi,zi=function(t,e){this.layers=t.readFields($i,{},e)};function $i(t,e,n){if(3===t){var r=new Ei(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}var Di=zi;const qi=2,ji=new TextDecoder("utf-8");class Gi extends kn{constructor(t,e,n,r,i,o){super(t,e,n,r,i),e=e||{},o()}getTileFeatures(t,e){const n=t.tileInfo.url,r=t.fetchOptions||{},{altitudePropertyName:i,disableAltitudeWarning:o}=t,s=this._cache.get(n);if(s&&s.cacheIndex===t.workerCacheIndex){const{err:t,data:r}=s;return setTimeout((()=>{this._readTile(n,i,o,t,r,e)}),1)}const{tileArrayBuffer:a}=t;return a?setTimeout((()=>{this._readTile(n,i,o,null,a,e)}),1):(r.referrer=t.referrer,C.getArrayBuffer(n,r,((r,s)=>{this._cache&&(r?r.loading||this._cache.add(n,{err:r,data:s&&s.data,cacheIndex:t.workerCacheIndex}):s&&s.data&&this._cache.add(n,{err:null,data:s.data,cacheIndex:t.workerCacheIndex}),this._readTile(n,i,o,r,s&&s.data,e))})))}_readTile(t,e,n,r,i,o){if(r)return void o(r);let s;try{s=new Di(new Si(i))}catch(r){const e=ji.decode(i);return r.message+="\\n"+t+"\\n"+e,void o(r.message,[],[])}const a=[];if(!s.layers)return void o(null,a,[]);const l={};let u;for(const t in s.layers)if(h=s.layers,c=t,Object.prototype.hasOwnProperty.call(h,c)){l[t]={types:{}};const i=l[t].types;for(let o=0,l=s.layers[t].length;o<l;o++)try{u=s.layers[t].feature(o),i[u.type]=1;const r={type:u.type,layer:t,geometry:u.loadGeometry(),properties:u.properties,extent:u.extent};void 0!==u.id&&(r.id=u.id);let l=r.properties[ee];l&&(A(l)&&(l=JSON.parse(l)),r.properties[ee]=ei(l,"EPSG:3857"));const h=e&&r.properties[e];if(h){const t=Zi(h),e=[];Ui(r.geometry,t,e),e.length&&!n&&(console.warn("feature.geometry is not consistent with altitude values:"),console.warn(JSON.stringify(r,null,2)))}a.push(r)}catch(r){console.warn("error when load vt geometry:",r)}}var h,c;for(const t in l)l[t].types=Object.keys(l[t].types).map((t=>+t));o(null,a,l,{byteLength:i.byteLength})}abortTile(t,e){const n=this.requests[t];delete this.requests[t],n&&n.abort&&n.abort(),this._cancelLoadings(t),e()}onRemove(){super.onRemove();for(const t in this.requests){const e=this.requests[t];e&&e.abort&&e.abort()}this.requests={}}}function Zi(t){const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return new Float32Array(n.buffer)}function Ui(t,e,n,r){r||(r={index:0});for(let i=0;i<t.length;i++)if(Array.isArray(t[i]))Ui(t[i],e,n,r);else{const o=r.index;k(e[o])?n.push(qi):t[i].z=100*e[o],r.index++}}const{LRUCache:Ri}=ne();let Ji=0;const Hi=new Ri(128);class Wi{constructor(t){this._layers={},this._callbacks={},this.workerId=t}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this._getLayerById(e,n))return;const o=this._genKey(e,n),s=r.type,a=r.options,l=this.send.bind(this,t);this._layers[o]="GeoJSONVectorTileLayer"===s?new ri(n,a,l,Hi,{},i):new Gi(n,a,l,Hi,{},i)}removeLayer({mapId:t,layerId:e},n){const r=this._getLayerById(t,e),i=this._genKey(t,e);delete this._layers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.loadTile(n,r)}abortTile({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.abortTile&&i.abortTile(n.url,r)}removeTile({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.removeTile(n,r)}updateStyle({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.updateStyle(n,r)}updateOptions({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.updateOptions(n,r)}setData({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.setData(n.data,r)}receive(t){const e=t.callback,n=this._callbacks[e];delete this._callbacks[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,i){const o=i?\`${s}t}-${s}Ji++}\`:null;i&&(this._callbacks[o]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}_genKey(t,e){return\`${s}t}-${s}e}\`}_getLayerById(t,e){const n=this._genKey(t,e);return this._layers[n]}_resetCache(){Hi.reset()}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;if(this.dispatcher||(this.dispatcher=new Wi(t.workerId)),"<response>"===t.type)this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t);else{const r=n.command;this.dispatcher[r]({actorId:t.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,i)=>{t&&404!==t.status&&204!==t.status&&!t.loading&&console.error(r,t),e(t,n,i)}))}}}`;
24
+ const s = "${", a = `function(t){let e;const n={width:100,height:10};let r=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),r=!0}catch(t){r=!1}function i(){if(!e){const{width:t,height:i}=n;r?e=new OffscreenCanvas(t,i):(e=document.createElement("canvas"),e.width=t,e.height=i)}return e}class o{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let r=1/0,i=-1/0;for(let e=0,n=t.length;e<n;e++){const n=t[e][0];r=Math.min(n,r),i=Math.max(n,i)}this.min=r,this.max=i,this.valueOffset=this.max-this.min,this.options=Object.assign({},n,e),this._initImgData()}getImageData(){return this.imgData}_initImgData(){const t=i(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const o=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:a}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/a;o.addColorStop(r,n)}r.fillStyle=o,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var s;function a(t){return null==t}function l(t){return!a(t)}function u(t){return""===t}function h(t,e){var n,r,i;if(w(t)){var o,s=t.stops&&"object"==typeof t.stops[0][0],a=s||l(t.property),u=s||!a,d=t.type||e||"exponential";if("exponential"===d)o=p;else if("interval"===d)o=f;else if("categorical"===d)o=c;else if("identity"===d)o=y;else if("color-interpolate"===d)o=g;else{if("calculate-expression"!==d)throw new Error('Unknown function type "'+d+'"');o=x}if(s){var m={},v=[];for(let e=0;e<t.stops.length;e++){var b=t.stops[e];void 0===m[b[0].zoom]&&(m[b[0].zoom]={zoom:b[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),m[b[0].zoom].stops.push([b[0].value,b[1]])}for(let t in m)v.push([m[t].zoom,h(m[t])]);n=function(e,n){const r=p({stops:v,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else u?(n=function(e){const n=o(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=o(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function c(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function f(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function p(t,e){for(var n=l(t.base)&&!u(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:m(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(s=new Map);const d={width:100,height:1};function g(t,e){const n=t.stops;if(n&&n.length>1){let t;if(s){const e=JSON.stringify(n);if(!s.has(e)){const t=new o(n,d);s.set(e,t)}t=s.get(e)}else t=new o(n,d);const[r,i,a,l]=t.getColor(e);return[r/255,i/255,a/255,l/255]}return n&&1===n.length?n[0][1]:null}function y(t,e){return n=e,r=t.default,l(n)?n:l(r)?r:l(i)?i:null;var n,r,i}function x(t,e){const n=String(t.property),r=t.expression,i=e;function o(e){return a(e)||u(e)||isNaN(e)?t.default:e}if(!l(e)||u(e)||isNaN(e)||e<0)return o(t.default);{const e=function t(e,n,r){const i=Number(r),o=String(n);return Array.isArray(e)?e.map((e=>t(e,o,i))):e===o?i:e}(r,n,i);return o(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(\`Unknown operator: ${s}r}\`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(\`Unsupported operator: ${s}r}\`)}}}(e))}}function m(t,e,n,r,i,o){return"function"==typeof i?function(){var s=i.apply(void 0,arguments),a=o.apply(void 0,arguments);return m(t,e,n,r,s,a)}:i.length?function(t,e,n,r,i,o){var s=[];for(let a=0;a<i.length;a++)s[a]=v(t,e,n,r,i[a],o[a]);return s}(t,e,n,r,i,o):v(t,e,n,r,i,o)}function v(t,e,n,r,i,o){var s,a=r-n,l=t-n;return i*(1-(s=1===e?l/a:(Math.pow(e,l)-1)/(Math.pow(e,a)-1)))+o*s}function w(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function b(t){return M(t,"interval")}function M(t,e){if(!w(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(w(i[t][1])){const o=M(i[t][1],e);n=n&&o.isZoomConstant,r=r&&o.isFeatureConstant,i[t]=[i[t][0],o]}const o=h(t,e);return o.isZoomConstant=n&&o.isZoomConstant,o.isFeatureConstant=r&&o.isFeatureConstant,o}let P=0;const _="function"==typeof Object.assign;function I(t,...e){if(_)return Object.assign(t,...e),t;for(let n=0;n<e.length;n++){const r=e[n];for(const e in r)t[e]=r[e]}return t}function A(t){return!k(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function S(t){return"number"==typeof t&&!isNaN(t)}function T(t){return!k(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function F(t){return!Array.isArray(t)&&"object"==typeof t&&!!t}function k(t){return null==t}function B(t){return w(t)&&t.property}const L="function"==typeof fetch&&"function"==typeof AbortController,C={jsonp:function(t,e){const n="_maptalks_jsonp_"+P++;t.match(/\\?/)?t+="&callback="+n:t+="?callback="+n;let r=document.createElement("script");return r.type="text/javascript",r.src=t,window[n]=function(t){e(null,t),document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[n]},document.getElementsByTagName("head")[0].appendChild(r),this},get:function(t,e,n){if(T(e)){const t=n;n=e,e=t}(e=e||{}).method&&(e.method=e.method.toUpperCase());const r="POST"===e.method;if(L){const r=new AbortController,i=e;i.signal=r.signal,i.referrerPolicy=i.referrerPolicy||"origin",i.method=i.method||"GET";const o=new Request(t,i);return e.returnJSON&&o.headers.set("Accept","application/json"),fetch(o).then((r=>{const i=this._parseResponse(r,e.returnJSON,e.responseType);i.message?(i.url=t,n(i)):i.then((t=>{"arraybuffer"===e.responseType?n(null,{data:t,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),contentType:r.headers.get("Content-Type")}):n(null,t)})).catch((e=>{e.code&&e.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,e),n(e))}))})).catch((e=>{e.code&&e.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,e),n(e))})),r}{const i=C._getClient(n);if(i.open(e.method||"GET",t,!0),e){for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);i.withCredentials="include"===e.credentials,e.responseType&&(i.responseType=e.responseType)}return i.send(r?e.body:null),i}},_parseResponse:(t,e,n)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${s}t.status}): ${s}t.statusText}\`}:"arraybuffer"===n?t.arrayBuffer():e?t.json():t.text(),_wrapCallback:function(t,e){return function(){if(4===t.readyState)if(200===t.status)if("arraybuffer"===t.responseType){0===t.response.byteLength?e({status:200,statusText:t.statusText,message:"http status 200 returned without content."}):e(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")})}else e(null,t.responseText);else e({status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${s}t.status}): ${s}t.statusText}\`})}},_getClient:function(t){let e;try{e=new XMLHttpRequest}catch(t){try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}}return e.onreadystatechange=C._wrapCallback(e,t),e},getArrayBuffer(t,e,n){if(T(e)){const t=n;n=e,e=t}return e||(e={}),e.responseType="arraybuffer",C.get(t,e,n)}};function Y(t,e,n,r,i=3){let o=r;const s=n-e>>1;let a,l=n-e;const u=t[e],h=t[e+1],c=t[n],f=t[n+1];for(let r=e+i;r<n;r+=i){const e=V(t[r],t[r+1],u,h,c,f);if(e>o)a=r,o=e;else if(e===o){const t=Math.abs(r-s);t<l&&(a=r,l=t)}}o>r&&(a-e>i&&Y(t,e,a,r,i),t[a+2]=o,n-a>i&&Y(t,a,n,r,i))}function V(t,e,n,r,i,o){let s=i-n,a=o-r;if(0!==s||0!==a){const l=((t-n)*s+(e-r)*a)/(s*s+a*a);l>1?(n=i,r=o):l>0&&(n+=s*l,r+=a*l)}return s=t-n,a=e-r,s*s+a*a}function O(t,e,n,r,i,o){const s={id:null==t?null:t,type:e,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};i&&(s.layer=i);return function(t,e){const n=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)X(t,n,e);else if("Polygon"===r)X(t,n[0],e);else if("MultiLineString"===r)for(const r of n)X(t,r,e);else if("MultiPolygon"===r)for(const r of n)X(t,r[0],e)}(s,o?4:3),s}function X(t,e,n){for(let r=0;r<e.length;r+=n)t.minX=Math.min(t.minX,e[r]),t.minY=Math.min(t.minY,e[r+1]),t.maxX=Math.max(t.maxX,e[r]),t.maxY=Math.max(t.maxY,e[r+1])}function N(t,e,n,r){if(r.layer=e,"FeatureCollection"===n.type)for(let e=0;e<n.features.length;e++)E(t,n.features[e],r,e);else"Feature"===n.type?E(t,n,r):E(t,{geometry:n},r)}function E(t,e,n,r){if(!e.geometry)return;const i=e.geometry.coordinates,o=e.geometry.type,s=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2);let a=[],l=e.id;if(n.promoteId?l=e.properties[n.promoteId]:n.generateId&&(l=r||0),"Point"===o)z(i,a,n);else if("MultiPoint"===o)for(const t of i)z(t,a,n);else if("LineString"===o)D(i,a,s,!1,n);else if("MultiLineString"===o){if(n.lineMetrics){for(const r of i)a=[],D(r,a,s,!1,n),t.push(O(l,"LineString",a,e.properties,n.layer,n.hasAltitude));return}$(i,a,s,!1,n)}else if("Polygon"===o)$(i,a,s,!0,n);else{if("MultiPolygon"!==o){if("GeometryCollection"===o){for(const i of e.geometry.geometries)E(t,{id:l,geometry:i,properties:e.properties},n,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const t of i){const e=[];$(t,e,s,!0,n),a.push(e)}}t.push(O(l,o,a,e.properties,n.layer,n.hasAltitude))}function z(t,e,n){e.push(q(t[0]),j(t[1],n.projection),0),n.hasAltitude&&(t.length>2?e.push(t[2]):e.push(0))}function D(t,e,n,r,i){let o,s,a=0;for(let n=0;n<t.length;n++){const l=q(t[n][0]),u=j(t[n][1],i.projection);e.push(l,u,0),i.hasAltitude&&(t[n].length>2?e.push(t[n][2]):e.push(0)),n>0&&(a+=r?(o*u-l*s)/2:Math.sqrt(Math.pow(l-o,2)+Math.pow(u-s,2))),o=l,s=u}const l=i.hasAltitude?4:3,u=e.length-l;e[2]=1,Y(e,0,u,n,l),e[u+2]=1,e.size=Math.abs(a),e.start=0,e.end=e.size}function $(t,e,n,r,i){for(let o=0;o<t.length;o++){const s=[];D(t[o],s,n,r,i),e.push(s)}}function q(t){return t/360+.5}function j(t,e){if("EPSG:4326"===e)return(90-t)/360;const n=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+n)/(1-n))/Math.PI;return r<0?0:r>1?1:r}function G(t,e,n,r,i,o,s,a){if(r/=e,o>=(n/=e)&&s<r)return t;if(s<n||o>=r)return null;const l=[];for(const e of t){const t=e.geometry;let o=e.type;const s=0===i?e.minX:e.minY,u=0===i?e.maxX:e.maxY;if(s>=n&&u<r){l.push(e);continue}if(u<n||s>=r)continue;let h=[];if("Point"===o||"MultiPoint"===o)Z(t,h,n,r,i,a.hasAltitude);else if("LineString"===o)U(t,h,n,r,i,!1,a.lineMetrics,a.hasAltitude);else if("MultiLineString"===o)J(t,h,n,r,i,!1,a.hasAltitude);else if("Polygon"===o)J(t,h,n,r,i,!0,a.hasAltitude);else if("MultiPolygon"===o)for(const e of t){const t=[];J(e,t,n,r,i,!0,a.hasAltitude),t.length&&h.push(t)}if(h.length){if(a.lineMetrics&&"LineString"===o){for(const t of h)l.push(O(e.id,o,t,e.tags,e.layer,a.hasAltitude));continue}"LineString"!==o&&"MultiLineString"!==o||(1===h.length?(o="LineString",h=h[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===h.length?"Point":"MultiPoint"),l.push(O(e.id,o,h,e.tags,e.layer,a.hasAltitude))}}return l.length?l:null}function Z(t,e,n,r,i,o){const s=o?4:3;for(let a=0;a<t.length;a+=s){const s=t[a+i];s>=n&&s<=r&&(H(e,t[a],t[a+1],t[a+2]),o&&e.push(t[a+3]))}}function U(t,e,n,r,i,o,s,a){let l=R(t);const u=0===i?W:K;let h,c,f=t.start;const p=a?4:3,d=o?t.length:t.length-p;for(let g=0;g<d;g+=p){const y=t[g],x=t[g+1],m=t[g+2];let v,w,b,M;o&&g===d-p?(v=t[0],w=t[1]):(v=t[g+p],w=t[g+p+1]),a&&(b=t[g+3],M=o&&g===d-p?t[3]:t[g+p+3]);const P=0===i?y:x,_=0===i?v:w;let I=!1;s&&(h=Math.sqrt(Math.pow(y-v,2)+Math.pow(x-w,2))),P<n?_>n&&(c=u(l,y,x,v,w,n),a&&l.push(Q(b,M,c)),s&&(l.start=f+h*c)):P>r?_<r&&(c=u(l,y,x,v,w,r),a&&l.push(Q(b,M,c)),s&&(l.start=f+h*c)):(H(l,y,x,m),a&&l.push(b)),_<n&&P>=n&&(c=u(l,y,x,v,w,n),a&&l.push(Q(b,M,c)),I=!0),_>r&&P<=r&&(c=u(l,y,x,v,w,r),a&&l.push(Q(b,M,c)),I=!0),!o&&I&&(s&&(l.end=f+h*c),e.push(l),l=R(t)),s&&(f+=h)}let g=t.length-p;if(!o){const e=t[g],o=t[g+1],s=t[g+2],u=0===i?e:o;if(u>=n&&u<=r&&H(l,e,o,s),u>=n&&u<=r&&a){const e=t[g+3];l.push(e)}}g=l.length-p,o&&g>=p&&(l[g]!==l[0]||l[g+1]!==l[1])&&(H(l,l[0],l[1],l[2]),a&&l.push(l[3])),l.length&&e.push(l)}function R(t){const e=[];return e.size=t.size,e.start=t.start,e.end=t.end,e}function J(t,e,n,r,i,o,s){for(const a of t)U(a,e,n,r,i,o,!1,s)}function H(t,e,n,r){t.push(e,n,r)}function W(t,e,n,r,i,o){const s=(o-e)/(r-e);return H(t,o,n+(i-n)*s,1),s}function K(t,e,n,r,i,o){const s=(o-n)/(i-n);return H(t,e+(r-e)*s,o,1),s}function Q(t,e,n){return t+(e-t)*n}function tt(t,e,n){const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=o.type;let a;if("Point"===s||"MultiPoint"===s||"LineString"===s)a=et(o.geometry,e,n);else if("MultiLineString"===s||"Polygon"===s){a=[];for(const t of o.geometry)a.push(et(t,e,n))}else if("MultiPolygon"===s){a=[];for(const t of o.geometry){const r=[];for(const i of t)r.push(et(i,e,n));a.push(r)}}r.push(O(o.id,s,a,o.tags,o.layer,n))}return r}function et(t,e,n){const r=[];r.size=t.size,void 0!==t.start&&(r.start=t.start,r.end=t.end);const i=n?4:3;for(let o=0;o<t.length;o+=i)r.push(t[o]+e,t[o+1],t[o+2]),n&&r.push(t[o+3]);return r}function nt(t,e,n){if(t.transformed)return t;const r=1<<t.z,i=t.x,o=t.y,s=n?3:2;for(const a of t.features){const t=a.geometry,l=a.type;if(a.geometry=[],1===l)for(let l=0;l<t.length;l+=s)a.geometry.push(rt(t[l],t[l+1],e,r,i,o)),n&&a.geometry[a.geometry.length-1].push(t[l+2]);else for(let l=0;l<t.length;l++){const u=[];for(let a=0;a<t[l].length;a+=s)u.push(rt(t[l][a],t[l][a+1],e,r,i,o)),n&&u[u.length-1].push(t[l][a+2]);a.geometry.push(u)}}return t.transformed=!0,t}function rt(t,e,n,r,i,o){return[Math.round(n*(t*r-i)),Math.round(n*(e*r-o))]}function it(t,e,n,r,i){const o=e===i.maxZoom?0:i.tolerance/((1<<e)*i.extent),s={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:n,y:r,z:e,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const e of t)ot(s,e,o,i);return s}function ot(t,e,n,r){const i=e.geometry,o=e.type,s=[],a=r.hasAltitude?4:3;if(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),"Point"===o||"MultiPoint"===o)for(let e=0;e<i.length;e+=a)s.push(i[e],i[e+1]),r.hasAltitude&&s.push(i[e+3]),t.numPoints++,t.numSimplified++;else if("LineString"===o)at(s,i,t,n,!1,!1,r);else if("MultiLineString"===o||"Polygon"===o)for(let e=0;e<i.length;e++)at(s,i[e],t,n,"Polygon"===o,0===e,r);else if("MultiPolygon"===o)for(let e=0;e<i.length;e++){const o=i[e];for(let e=0;e<o.length;e++)at(s,o[e],t,n,!0,0===e,r)}if(s.length){let n=e.tags||null;if("LineString"===o&&r.lineMetrics){n={};for(const t in e.tags)n[t]=e.tags[t];n.mapbox_clip_start=i.start/i.size,n.mapbox_clip_end=i.end/i.size}const a={geometry:s,type:"Polygon"===o||"MultiPolygon"===o?3:"LineString"===o||"MultiLineString"===o?2:1,tags:n};e.layer&&(a.layer=e.layer),null!==e.id&&(a.id=e.id),t.features.push(a)}}function st(t,e,n){return 0===t[e+2]&&t[e+3]>0&&n}function at(t,e,n,r,i,o,s){const a=r*r,{hasAltitude:l,disableFilter:u}=s,h=l?4:3;if(!u&&r>0&&e.size<(i?a:r))return void(n.numPoints+=e.length/h);const c=[];for(let t=0;t<e.length;t+=h)(0===r||e[t+2]>a||st(e,t,l))&&(n.numSimplified++,c.push(e[t],e[t+1]),l&&c.push(e[t+3])),n.numPoints++;i&&function(t,e,n){const r=n?3:2;let i=0;for(let e=0,n=t.length,o=n-r;e<n;o=e,e+=r)i+=(t[e]-t[o])*(t[e+1]+t[o+1]);if(i>0===e){const e=r,i=r-1,o=r-2;for(let s=0,a=t.length;s<a/2;s+=r){const r=t[s],l=t[s+1];let u;n&&(u=t[s+2]),t[s]=t[a-e-s],t[s+1]=t[a-i-s],n&&(t[s+2]=t[a-o-s]),t[a-e-s]=r,t[a-i-s]=l,n&&(t[a-o-s]=u)}}}(c,o,l),t.push(c)}C.getJSON=function(t,e,n){if(T(e)){const t=n;n=e,e=t}const r=function(t,e){const r="string"==typeof e?JSON.parse(e):e||null;n(t,r)};return e&&e.jsonp?C.jsonp(t,r):((e=e||{}).returnJSON=!0,C.get(t,e,r))};const lt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,hasAltitude:!1,disableFilter:!1,debug:0};class ut{constructor(t,e){const n=(e=this.options=function(t,e){for(const n in e)t[n]=e[n];return t}(Object.create(lt),e)).debug;if(n&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=function(t,e){const n=[];if(Array.isArray(t)){for(let r=0;r<t.length;r++)N(n,t[r].layer,t[r].data,e);return n}if("FeatureCollection"===t.type)for(let r=0;r<t.features.length;r++)E(n,t.features[r],e,r);else"Feature"===t.type?E(n,t,e):E(n,{geometry:t},e);return n}(t,e);this.tiles={},this.tileCoords=[],n&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(t,e){const n=e.buffer/e.extent;let r=t;const i=G(t,1,-1-n,n,0,-1,2,e),o=G(t,1,1-n,2+n,0,-1,2,e);return(i||o)&&(r=G(t,1,-n,1+n,0,-1,2,e)||[],i&&(r=tt(i,1,e.hasAltitude).concat(r)),o&&(r=r.concat(tt(o,-1,e.hasAltitude)))),r}(r,e),r.length&&this.splitTile(r,0,0,0),n&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,e,n,r,i,o,s){const a=[t,e,n,r],l=this.options,u=l.debug;for(;a.length;){r=a.pop(),n=a.pop(),e=a.pop(),t=a.pop();const h=1<<e,c=ht(e,n,r);let f=this.tiles[c];if(!f&&(u>1&&console.time("creation"),f=this.tiles[c]=it(t,e,n,r,l),this.tileCoords.push({z:e,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,n,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));const t=\`z${s}e}\`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(f.source=t,null==i){if(e===l.indexMaxZoom||f.numPoints<=l.indexMaxPoints)continue}else{if(e===l.maxZoom||e===i)continue;if(null!=i){const t=i-e;if(n!==o>>t||r!==s>>t)continue}}if(f.source=null,0===t.length)continue;u>1&&console.time("clipping");const p=.5*l.buffer/l.extent,d=.5-p,g=.5+p,y=1+p;let x=null,m=null,v=null,w=null,b=G(t,h,n-p,n+g,0,f.minX,f.maxX,l),M=G(t,h,n+d,n+y,0,f.minX,f.maxX,l);t=null,b&&(x=G(b,h,r-p,r+g,1,f.minY,f.maxY,l),m=G(b,h,r+d,r+y,1,f.minY,f.maxY,l),b=null),M&&(v=G(M,h,r-p,r+g,1,f.minY,f.maxY,l),w=G(M,h,r+d,r+y,1,f.minY,f.maxY,l),M=null),u>1&&console.timeEnd("clipping"),a.push(x||[],e+1,2*n,2*r),a.push(m||[],e+1,2*n,2*r+1),a.push(v||[],e+1,2*n+1,2*r),a.push(w||[],e+1,2*n+1,2*r+1)}}getTile(t,e,n){t=+t,e=+e,n=+n;const r=this.options,{extent:i,debug:o}=r,{hasAltitude:s,wrapX:a}=r;if(t<0||t>24)return null;if(a){const n=1<<t;e=e+n&n-1}const l=ht(t,e,n);if(this.tiles[l])return nt(this.tiles[l],i,s);o>1&&console.log("drilling down to z%d-%d-%d",t,e,n);let u,h=t,c=e,f=n;for(;!u&&h>0;)h--,c>>=1,f>>=1,u=this.tiles[ht(h,c,f)];return u&&u.source?(o>1&&(console.log("found parent tile z%d-%d-%d",h,c,f),console.time("drilling down")),this.splitTile(u.source,h,c,f,t,e,n),o>1&&console.timeEnd("drilling down"),this.tiles[l]?nt(this.tiles[l],i,s):null):null}}function ht(t,e,n){return 32*((1<<t)*n+e)+t}function ct(t,e,n,r,i,o,s){const a=n&&Array.isArray(n[0]);for(let l=0,u=n.length;l<u;l++){t[e]=(a?n[l][0]:n[l].x)*r,t[e+1]=(a?n[l][1]:n[l].y)*r,s!==Float32Array&&(t[e]=Math.round(t[e]),t[e+1]=Math.round(t[e+1]));let h=i||0;Array.isArray(i)&&(h=i[l]),h=h?Math.round(r*h):0,t[e+2]=h,e+=3,o&&0!==l&&l!==u-1&&(t[e]=t[e-3],t[e+1]=t[e-2],t[e+2]=t[e-1],e+=3)}return t.trySetLength&&t.trySetLength(e),e}function ft(t,e,n,r){const i=t[3*e],o=t[3*e+1],s=t[3*n],a=t[3*n+1];return i===s&&(i<0||i>r)||o===a&&(o<0||o>r)}var pt="undefined"!=typeof Float32Array?Float32Array:Array;function dt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function gt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function yt(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function xt(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t}function mt(t,e,n){return t[0]=e,t[1]=n,t}function vt(t,e){var n=e[0]-t[0],r=e[1]-t[1];return Math.hypot(n,r)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),function(){var t,e=(t=new pt(3),pt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t)}(),function(){var t,e=(t=new pt(4),pt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}(),function(){var t,e=(t=new pt(2),pt!=Float32Array&&(t[0]=0,t[1]=0),t)}();const wt=Math.PI/180,bt=6378137*Math.PI/180,Mt=85.0511287798;function Pt(t,e,n){if("EPSG:3857"===n)return function(t,e){const n=Mt,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let o;o=0===i?0:Math.log(Math.tan((90+i)*wt/2))/wt;return t[0]=r*bt,t[1]=o*bt,t}(t,e);if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return _t(t,e);if("baidu"===n)return _t(t,e);throw new Error("unsupported projection:"+n)}function _t(t,e){return t[0]=e[0],t[1]=e[1],t}function It(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d){0===t?function(t,e,n,r,i,o,s,a,l,u){const h=1/(100*o[0]),c=1/(100*o[1]),f=u&&u[0]||0,p=u&&u[1]||0,d=[0,0];for(let i=t;i<e;i+=3){const t=i/3*2,e=r[i]-f,o=r[i+1]-p;n[t]=d[0]+e/s*h/a,n[t+1]=d[1]-o/s*c/l}}(e,n,r,i,0,s,a,l,u,d):1===t&&function(t,e,n,r,i,o,s,a,l,u,h){if(!t)return;let c,f,p,d;0===t[4]?(c=t[0],f=t[1],p=t[2],d=t[3]):(c=t[1],f=t[2],p=t[3],d=t[0]);const g=vt(c,f),y=vt(f,p),x=[],m=[],v=[];for(let t=e;t<n;t+=3){const e=t/3*2;mt(x,(o.x/l+i[t]/s)*a,o.y/l*a+(h?i[t+1]:-i[t+1])/s*a),"EPSG:4326"!==u&&"EPSG:4490"!==u||Pt(x,x,"EPSG:3857"),At(m,x,c,f),At(v,x,d,c),r[e]=vt(c,m)/g,r[e+1]=vt(c,v)/y}}(h,e,n,r,i,o,a,c,f,p,!!d)}function At(t,e,n,r){const i=n[0]-r[0],o=n[1]-r[1];let s=(e[0]-n[0])*(n[0]-r[0])+(e[1]-n[1])*(n[1]-r[1]);return s/=i*i+o*o,t[0]=n[0]+s*i,t[1]=n[1]+s*o,t}function St(t,e,n,r,i){const o=3*e[n-1],s=3*e[n-1]+1,a=t[o],l=t[s];return u=r,h=i,c=a,f=l,Math.sqrt((c-u)*(c-u)+(f-h)*(f-h));var u,h,c,f}function Tt(t,e,n=2){const r=e&&e.length,i=r?e[0]*n:t.length;let o=Ft(t,0,i,n,!0);const s=[];if(!o||o.next===o.prev)return s;let a,l,u;if(r&&(o=function(t,e,n,r){const i=[];for(let n=0,o=e.length;n<o;n++){const s=Ft(t,e[n]*r,n<o-1?e[n+1]*r:t.length,r,!1);s===s.next&&(s.steiner=!0),i.push(zt(s))}i.sort(Ot);for(let t=0;t<i.length;t++)n=Xt(i[t],n);return n}(t,e,o,n)),t.length>80*n){a=1/0,l=1/0;let e=-1/0,r=-1/0;for(let o=n;o<i;o+=n){const n=t[o],i=t[o+1];n<a&&(a=n),i<l&&(l=i),n>e&&(e=n),i>r&&(r=i)}u=Math.max(e-a,r-l),u=0!==u?32767/u:0}return Bt(o,s,n,a,l,u,0),s}function Ft(t,e,n,r,i){let o;if(i===function(t,e,n,r){let i=0;for(let o=e,s=n-r;o<n;o+=r)i+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return i}(t,e,n,r)>0)for(let i=e;i<n;i+=r)o=Wt(i/r|0,t[i],t[i+1],o);else for(let i=n-r;i>=e;i-=r)o=Wt(i/r|0,t[i],t[i+1],o);return o&&Gt(o,o.next)&&(Kt(o),o=o.next),o}function kt(t,e){if(!t)return t;e||(e=t);let n,r=t;do{if(n=!1,r.steiner||!Gt(r,r.next)&&0!==jt(r.prev,r,r.next))r=r.next;else{if(Kt(r),r=e=r.prev,r===r.next)break;n=!0}}while(n||r!==e);return e}function Bt(t,e,n,r,i,o,s){if(!t)return;!s&&o&&function(t,e,n,r){let i=t;do{0===i.z&&(i.z=Et(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){let e,n=1;do{let r,i=t;t=null;let o=null;for(e=0;i;){e++;let s=i,a=0;for(let t=0;t<n&&(a++,s=s.nextZ,s);t++);let l=n;for(;a>0||l>0&&s;)0!==a&&(0===l||!s||i.z<=s.z)?(r=i,i=i.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;i=s}o.nextZ=null,n*=2}while(e>1)}(i)}(t,r,i,o);let a=t;for(;t.prev!==t.next;){const l=t.prev,u=t.next;if(o?Ct(t,r,i,o):Lt(t))e.push(l.i,t.i,u.i),Kt(t),t=u.next,a=u.next;else if((t=u)===a){s?1===s?Bt(t=Yt(kt(t),e),e,n,r,i,o,2):2===s&&Vt(t,e,n,r,i,o):Bt(kt(t),e,n,r,i,o,1);break}}}function Lt(t){const e=t.prev,n=t,r=t.next;if(jt(e,n,r)>=0)return!1;const i=e.x,o=n.x,s=r.x,a=e.y,l=n.y,u=r.y,h=Math.min(i,o,s),c=Math.min(a,l,u),f=Math.max(i,o,s),p=Math.max(a,l,u);let d=r.next;for(;d!==e;){if(d.x>=h&&d.x<=f&&d.y>=c&&d.y<=p&&$t(i,a,o,l,s,u,d.x,d.y)&&jt(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function Ct(t,e,n,r){const i=t.prev,o=t,s=t.next;if(jt(i,o,s)>=0)return!1;const a=i.x,l=o.x,u=s.x,h=i.y,c=o.y,f=s.y,p=Math.min(a,l,u),d=Math.min(h,c,f),g=Math.max(a,l,u),y=Math.max(h,c,f),x=Et(p,d,e,n,r),m=Et(g,y,e,n,r);let v=t.prevZ,w=t.nextZ;for(;v&&v.z>=x&&w&&w.z<=m;){if(v.x>=p&&v.x<=g&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&$t(a,h,l,c,u,f,v.x,v.y)&&jt(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,w.x>=p&&w.x<=g&&w.y>=d&&w.y<=y&&w!==i&&w!==s&&$t(a,h,l,c,u,f,w.x,w.y)&&jt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;v&&v.z>=x;){if(v.x>=p&&v.x<=g&&v.y>=d&&v.y<=y&&v!==i&&v!==s&&$t(a,h,l,c,u,f,v.x,v.y)&&jt(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;w&&w.z<=m;){if(w.x>=p&&w.x<=g&&w.y>=d&&w.y<=y&&w!==i&&w!==s&&$t(a,h,l,c,u,f,w.x,w.y)&&jt(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Yt(t,e){let n=t;do{const r=n.prev,i=n.next.next;!Gt(r,i)&&Zt(r,n,n.next,i)&&Jt(r,i)&&Jt(i,r)&&(e.push(r.i,n.i,i.i),Kt(n),Kt(n.next),n=t=i),n=n.next}while(n!==t);return kt(n)}function Vt(t,e,n,r,i,o){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&qt(s,t)){let a=Ht(s,t);return s=kt(s,s.next),a=kt(a,a.next),Bt(s,e,n,r,i,o,0),void Bt(a,e,n,r,i,o,0)}t=t.next}s=s.next}while(s!==t)}function Ot(t,e){let n=t.x-e.x;if(0===n&&(n=t.y-e.y,0===n)){n=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}return n}function Xt(t,e){const n=function(t,e){let n=e;const r=t.x,i=t.y;let o,s=-1/0;if(Gt(t,n))return n;do{if(Gt(t,n.next))return n.next;if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const t=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(t<=r&&t>s&&(s=t,o=n.x<n.next.x?n:n.next,t===r))return o}n=n.next}while(n!==e);if(!o)return null;const a=o,l=o.x,u=o.y;let h=1/0;n=o;do{if(r>=n.x&&n.x>=l&&r!==n.x&&Dt(i<u?r:s,i,l,u,i<u?s:r,i,n.x,n.y)){const e=Math.abs(i-n.y)/(r-n.x);Jt(n,t)&&(e<h||e===h&&(n.x>o.x||n.x===o.x&&Nt(o,n)))&&(o=n,h=e)}n=n.next}while(n!==a);return o}(t,e);if(!n)return e;const r=Ht(n,t);return kt(r,r.next),kt(n,n.next)}function Nt(t,e){return jt(t.prev,t,e.prev)<0&&jt(e.next,t,t.next)<0}function Et(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function zt(t){let e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function Dt(t,e,n,r,i,o,s,a){return(i-s)*(e-a)>=(t-s)*(o-a)&&(t-s)*(r-a)>=(n-s)*(e-a)&&(n-s)*(o-a)>=(i-s)*(r-a)}function $t(t,e,n,r,i,o,s,a){return!(t===s&&e===a)&&Dt(t,e,n,r,i,o,s,a)}function qt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Zt(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(Jt(t,e)&&Jt(e,t)&&function(t,e){let n=t,r=!1;const i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)&&(jt(t.prev,t,e.prev)||jt(t,e.prev,e))||Gt(t,e)&&jt(t.prev,t,t.next)>0&&jt(e.prev,e,e.next)>0)}function jt(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Gt(t,e){return t.x===e.x&&t.y===e.y}function Zt(t,e,n,r){const i=Rt(jt(t,e,n)),o=Rt(jt(t,e,r)),s=Rt(jt(n,r,t)),a=Rt(jt(n,r,e));return i!==o&&s!==a||(!(0!==i||!Ut(t,n,e))||(!(0!==o||!Ut(t,r,e))||(!(0!==s||!Ut(n,t,r))||!(0!==a||!Ut(n,e,r)))))}function Ut(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function Rt(t){return t>0?1:t<0?-1:0}function Jt(t,e){return jt(t.prev,t,t.next)<0?jt(t,e,t.next)>=0&&jt(t,t.prev,e)>=0:jt(t,e,t.prev)<0||jt(t,t.next,e)<0}function Ht(t,e){const n=Qt(t.i,t.x,t.y),r=Qt(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Wt(t,e,n,r){const i=Qt(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Kt(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 Qt(t,e,n){return{i:t,x:e,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}const te="__fea_idx";new Float32Array([-1e12])[0];const ee="maptalks_ombb";function ne(){return function(){if("undefined"!=typeof undefinedThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")}().maptalks_vt_packers}const{PackUtil:re,ArrayPool:ie}=ne();function oe(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d,g,y){const x=e.getLength(),m=i/3;for(let n=2,r=x;n<r;n+=3)t[i+n-2]=e[n-2],t[i+n-1]=e[n-1],t[i+n-0]=e[n]-s;i+=x;for(let n=2,r=x;n<r;n+=3)t[i+n-2]=e[n-2],t[i+n-1]=e[n-1],t[i+n-0]=e[n]-a;i+=x,t.trySetLength(i+x),t.copyWithin(i,i-2*x,i-x),i+=x,t.trySetLength(i+x),t.copyWithin(i,i-2*x,i-x),i+=x,(n=n||[]).push(x/3);const v=n.getLength();for(let e=0;e<v;e++){se(m+(n[e-1]||0),m+n[e],t,x/3,l,r,u,h,c,f,o,p,d,g,y)}return i}function se(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d){const g=o.getLength();let y,x;for(let s=t,a=e;s<a-1;s++)if(y=s,x=s+1,i===1/0||!ft(n,y,x,i))if((s-t)%2==1&&(y+=2*r,x+=2*r),d){let t=o.currentIndex;o[t++]=y+r,o[t++]=x,o[t++]=y,o[t++]=x+r,o[t++]=x,o[t++]=y+r,o.currentIndex=t}else{let t=o.currentIndex;o[t++]=y+r,o[t++]=y,o[t++]=x,o[t++]=x,o[t++]=x+r,o[t++]=y+r,o.currentIndex=t}s&&function(t,e,n,r,i,o,s,a,l,u,h,c){let f,p=0,d=0,g=0,y=0;const x=c?[1,3,4]:[2,3,4];for(let c=o.getLength()-1;c>=s;c--){const s=o[c],m=3*s+1,v=3*s+2,w=i[3*s],b=i[m],M=i[v];p||d||(p=Math.max(i[v],i[3*o[c-3]+2]),d=Math.min(i[v],i[3*o[c-3]+2]),f=p-d);let P=g;const _=c%6;0===t?(5===_&&(y=St(i,o,c,w,b)),P=_===x[0]||_===x[1]||_===x[2]?g:g+y):1===t&&(_===x[0]||_===x[1]||_===x[2]?P=0:5===_?(y=St(i,o,c,w,b),P=y):P=y);const I=P/u*(1/(100*h))/a;let A;A=1===e?M===p?1:0:"bottom"===n?M===p?f/100/l:0:M===p?0:-f/100/l,r[2*s]=I,r[2*s+1]=A,0===_&&(g+=y)}}(a,l,u,h,n,o,g,c[0],c[1],f,p,d)}function ae(t){const e=[t[0]];let n=t[0];for(let r=1;r<t.length;r++)Array.isArray(t[r])?t[r][0]===n[0]&&t[r][1]===n[1]&&t[r][2]===n[2]||e.push(t[r]):t[r].x===n.x&&t[r].y===n.y&&t[r].z===n.z||e.push(t[r]),n=t[r];return e}var le="undefined"!=typeof Float32Array?Float32Array:Array;function ue(){var t=new le(3);return le!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function he(t,e,n){var r=new le(3);return r[0]=t,r[1]=e,r[2]=n,r}function ce(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function fe(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function pe(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function de(t,e){var n=e[0],r=e[1],i=e[2],o=n*n+r*r+i*i;return o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function ge(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ye(t,e,n){var r=e[0],i=e[1],o=e[2],s=n[0],a=n[1],l=n[2];return t[0]=i*l-o*a,t[1]=o*s-r*l,t[2]=r*a-i*s,t}var xe=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};function me(){var t=new le(4);return le!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ve(t,e){var n=e[0]+e[4]+e[8],r=void 0;if(n>0)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[3*i+i]&&(i=2);var o=(i+1)%3,s=(i+2)%3;r=Math.sqrt(e[3*i+i]-e[3*o+o]-e[3*s+s]+1),t[i]=.5*r,r=.5/r,t[3]=(e[3*o+s]-e[3*s+o])*r,t[o]=(e[3*o+i]+e[3*i+o])*r,t[s]=(e[3*s+i]+e[3*i+s])*r}return t}!function(){var t=ue()}(),function(){var t,e=(t=new le(4),le!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var we,be=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},Me=function(t,e){var n=e[0],r=e[1],i=e[2],o=e[3],s=n*n+r*r+i*i+o*o;return s>0&&(s=1/Math.sqrt(s),t[0]=n*s,t[1]=r*s,t[2]=i*s,t[3]=o*s),t};ue(),he(1,0,0),he(0,1,0),me(),me(),we=new le(9),le!=Float32Array&&(we[1]=0,we[2]=0,we[3]=0,we[5]=0,we[6]=0,we[7]=0),we[0]=1,we[4]=1,we[8]=1;\n/*!\n * Contains code from google filament\n * https://github.com/google/filament/\n * License Apache-2.0\n */\nconst Pe=8,_e=[],Ie=[],Ae=[],Se=[];function Te(t,e,n){const r=ye(Ie,e,n),i=function(t,e,n,r,i,o,s,a,l,u){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=o,t[5]=s,t[6]=a,t[7]=l,t[8]=u,t}(_e,n[0],n[1],n[2],...r,...e);t=ve(t,i),t=function(t){return t[3]<0?be(t,t,-1):t}(t=Me(t,t));const o=1/((1<<2*Pe-1)-1);if(t[3]<o){t[3]=o;const e=Math.sqrt(1-o*o);t[0]*=e,t[1]*=e,t[2]*=e}const s=n[3]>0?ye(Ae,n,e):ye(Ae,e,n);return ge(ye(Se,n,e),s)<0&&be(t,t,-1),t}const Fe=[];const ke=[],Be=[],Le=[],Ce=[],Ye=[],Ve=[],Oe=[];function Xe(t,e,n,r,i,o){fe(Ce,t[3*e],t[3*e+1],t[3*e+2]),fe(Ye,t[3*n],t[3*n+1],t[3*n+2]),fe(Ve,t[3*r],t[3*r+1],t[3*r+2]);const s=xe(ke,Ve,Ye),a=xe(Be,Ce,Ye),l=ye(Le,s,a);de(Oe,l),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=Oe[0],i[3*n]+=Oe[0],i[3*r]+=Oe[0],i[3*e+1]+=Oe[1],i[3*n+1]+=Oe[1],i[3*r+1]+=Oe[1],i[3*e+2]+=Oe[2],i[3*n+2]+=Oe[2],i[3*r+2]+=Oe[2],o[e]+=1,o[n]+=1,o[r]+=1}\n/*!\n * Contains code from THREE.JS\n * https://github.com/mrdoob/three.js/\n * License MIT\n * \n * Generate tangents per vertex.\n */function Ne(t,e,n){return t[0]=e[n],t[1]=e[n+1],t[2]=e[n+2],t}function Ee(t,e,n){return t[0]=e[n],t[1]=e[n+1],t}const{StyleUtil:ze,PackUtil:De,ArrayPool:$e}=ne(),qe=$e.getInstance();function je(t,e,n,r,i,o,s,a,l,u,h,c,f,p,d,g){void 0===e.top&&(e.top=!0),void 0===e.side&&(e.side=!0),qe.reset();const{altitudeScale:y,altitudeProperty:x,defaultAltitude:m,heightProperty:v,minHeightProperty:P,defaultHeight:_,tangent:I,uv:A,topUVMode:T,sideUVMode:F,sideVerticalUVMode:k,top:L,side:C,textureYOrigin:Y,topThickness:V}=e,O=function(t,e,{altitudeScale:n,altitudeProperty:r,defaultAltitude:i,heightProperty:o,minHeightProperty:s,defaultHeight:a},{center:l,side:u,top:h,topThickness:c,uvOrigin:f,uv:p,uvSize:d,topUVMode:g,sideUVMode:y,sideVerticalUVMode:x,textureYOrigin:m,tileRatio:v,centimeterToPoint:w,verticalCentimeterToPoint:b,positionType:M,res:P,glScale:_,projectionCode:I},A,T){let F=e/t[0].extent;e===1/0&&(F=1);const k=e===1/0,B=T.get(),L=T.get(),C=T.get(),Y=T.getProxy(),V=T.get(),O=T.get(),X=T.get(),N=!!p,E=!!h,z=!!u,D=N?T.get():null;function $(t,n,r,i,o,s){let a=n;if(E){const u=Tt(Y,r,3);if(0===u.length)return n;let h=Y.getLength(),p=V.currentIndex;for(let t=0;t<h;t++)V[p++]=Y[t];if(V.currentIndex=p,n+=Y.getLength(),s)for(let e=2,n=u.length;e<n;e+=3)u[e]+=t/3,u[e-1]+=t/3,u[e-2]+=t/3;else{let e;for(let n=2,r=u.length;n<r;n+=3)e=u[n-1],u[n-1]=u[n]+t/3,u[n]=e+t/3,u[n-2]+=t/3}h=u.length,p=O.currentIndex;for(let t=0;t<h;t++)O[p++]=u[t];O.currentIndex=p,N&&It(g||0,t,n,D,V,f,w,v,d[0],d[1],o,P,_,I,l),c>0&&!z&&(n=oe(V,Y,r,O,n,D,0,c,e,N,y||0,x||0,m,d,v,b,i<0?!s:s)),X.setLength(n/3),X.fill(1,a/3,n/3)}if(z){E&&(c=0),a=n,n=oe(V,Y,r,O,n,D,c,i,e,N,y||0,x||0,m,d,v,b,i<0?!s:s),X.setLength(n/3);const t=Y.getLength()/3;X.fill(1,a/3,a/3+t),X.fill(0,a/3+t,a/3+2*t),X.fill(1,a/3+2*t,a/3+3*t),X.fill(0,a/3+3*t,n/3)}return n}let q=-1/0,j=1/0,G=0;const Z=[-1,-1,e+1,e+1];let U=0,R=t.length;S(A)&&(U=A,R=A+1);let J=0,H=!1;const W=T.getProxy();let K=!1;for(;U<R;U++){const l=t[U],u=l.id;S(u)&&(Math.abs(u)>J&&(J=Math.abs(u)),u<0&&(H=!0));const h=l.geometry,c=l.properties[ee];let f=Array.isArray(c&&c[0]&&c[0][0])?c[0]:c;const{altitude:p,height:d}=re.getFeaAltitudeAndHeight(l,n,r,i,o,a,s);d<0?(K=!0,j=Math.min(p,j),q=Math.max(p-d,q)):(q=Math.max(p,q),j=Math.min(p-d,j));const g=V.getLength();let y=0,x=G;W.setLength(0),Y.setLength(0);const m=re.calculateSignedArea(h[0])<0;for(let t=0,n=h.length;t<n;t++){let r=h[t];m&&(r=r.reverse()),r=ae(r);const i=re.calculateSignedArea(r)<0;if(!i&&t>0&&(y++,f=c&&c[y],G=$(x,G,W,d*F,f,k),Y.setLength(0),W.setLength(0),x=G),e!==1/0&&(r=re.clipPolygon(r,Z)),!r.length){t===n-1&&(G=$(x,G,W,d*F,f,k));continue}const o=r.length;if(Array.isArray(r[0])?r[0][0]===r[o-1][0]&&r[0][1]===r[o-1][1]||r.push([r[0][0],r[0][1]]):r[0].x===r[o-1].x&&r[0].y===r[o-1].y||r.push(r[0]),i){let t=W.currentIndex;W[t++]=Y.getLength()/3,W.currentIndex=t}ct(Y,Y.getLength(),r,F,p,!1,M),t===n-1&&(G=$(x,G,W,d*F,f,k))}const v=V.getLength()-g,w=(te+"").trim();for(let t=0;t<v/3;t++){let t=L.currentIndex;L[t++]=void 0===l[w]?U:l[w],L.currentIndex=t,t=B.currentIndex,B[t++]=U,B.currentIndex=t,S(u)&&(t=C.currentIndex,C[t++]=u,C.currentIndex=t)}}const Q=re.getUnsignedArrayType(L.getLength()?L[L.getLength()-1]:0),tt={hasNegativeHeight:K,maxAltitude:q===-1/0?0:q,minAltitude:j===1/0?0:j,vertices:V,verticeTypes:X,indices:O,pickingIds:ie.createTypedArray(L,Q),featureIndexes:B};if(C.getLength()){const t=H?re.getPosArrayType(J):re.getUnsignedArrayType(J);tt.featureIds=ie.createTypedArray(C,t)}else tt.featureIds=[];return D&&(D.setLength(V.getLength()/3*2),tt.uvs=D),tt}(t,n,{altitudeScale:y,altitudeProperty:x,defaultAltitude:m||0,heightProperty:v,minHeightProperty:P,defaultHeight:_||0},{center:g,top:L,side:C,topThickness:10*V||0,uv:A||I,uvSize:[i,i],uvOrigin:r,topUVMode:T,sideUVMode:F,sideVerticalUVMode:k,textureYOrigin:Y,tileRatio:a,centimeterToPoint:l,verticalCentimeterToPoint:u,positionType:d,res:o,glScale:s,projectionCode:f},p,qe),X=[],N=O.vertices.getLength()/3,E=De.getIndexArrayType(N),z=$e.createTypedArray(O.indices,E);delete O.indices,X.push(z.buffer,O.pickingIds.buffer);const D=Math.max(Math.abs(O.maxAltitude),Math.abs(O.minAltitude)),$=De.getPosArrayType(Math.max(512,D));O.vertices=$e.createTypedArray(O.vertices,$);const q=I?qe.getProxy():new Float32Array(3*N);q.setLength&&q.setLength(3*N);const j=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=Fe;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Xe(t,3*n,3*n+1,3*n+2,r,i):Xe(t,e[3*n],e[3*n+1],e[3*n+2],r,i);for(let t=0;t<r.length;t+=3){const e=i[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(O.vertices,z,q);let G=!0;const Z=j.getLength?j.getLength():j.length;for(let t=0;t<Z;t++){j[t]=-j[t];const e=j[t]%1;1-Math.abs(e)>1e-6?G=!1:0!==e&&(j[t]=Math.round(j[t]))}if(O.normals=j,I){let t=qe.get();t.setLength(4*N),t=function(t,e,n,r,i){const o=t.length/3,s=i||new Array(4*o),a=[],l=[];for(let t=0;t<o;t++)a[t]=[0,0,0],l[t]=[0,0,0];const u=[0,0,0],h=[0,0,0],c=[0,0,0],f=[0,0],p=[0,0],d=[0,0],g=[0,0,0],y=[0,0,0];function x(e,r,i){Ne(u,t,3*e),Ne(h,t,3*r),Ne(c,t,3*i),Ee(f,n,2*e),Ee(p,n,2*r),Ee(d,n,2*i);const o=h[0]-u[0],s=c[0]-u[0],x=h[1]-u[1],m=c[1]-u[1],v=h[2]-u[2],w=c[2]-u[2],b=p[0]-f[0],M=d[0]-f[0],P=p[1]-f[1],_=d[1]-f[1],I=1/(b*_-M*P);fe(g,(_*o-P*s)*I,(_*x-P*m)*I,(_*v-P*w)*I),fe(y,(b*s-M*o)*I,(b*m-M*x)*I,(b*w-M*v)*I),pe(a[e],a[e],g),pe(a[r],a[r],g),pe(a[i],a[i],g),pe(l[e],l[e],y),pe(l[r],l[r],y),pe(l[i],l[i],y)}for(let t=0,e=r.length;t<e;t+=3)x(r[t+0],r[t+1],r[t+2]);const m=[],v=[],w=[],b=[];let M,P,_;function I(t){Ne(w,e,3*t),ce(b,w),P=a[t],ce(m,P),xe(m,m,function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(w,w,ge(w,P))),de(m,m),ye(v,b,P),_=ge(v,l[t]),M=_<0?-1:1,s[4*t]=m[0],s[4*t+1]=m[1],s[4*t+2]=m[2],s[4*t+3]=M}for(let t=0,e=r.length;t<e;t+=3)I(r[t+0]),I(r[t+1]),I(r[t+2]);return s}(O.vertices,O.normals,O.uvs,z,t),t=function(t,e){const n=e.getLength(),r=new Float32Array(n),i=[],o=[],s=[];for(let a=0;a<n;a+=4){const n=a/4*3;dt(o,t[n]||0,t[n+1]||0,t[n+2]||0),yt(i,e[a]||0,e[a+1]||0,e[a+2]||0,e[a+3]||0),Te(s,o,i),gt(r.subarray(a,a+4),s)}return r}(O.normals,t),O.tangents=t,X.push(t.buffer),delete O.normals}if(O.normals&&(G&&(O.normals=$e.createTypedArray(O.normals,Int8Array)),X.push(O.normals.buffer)),O.uvs){const t=O.uvs;O.uvs=$e.createTypedArray(t,Float32Array),X.push(O.uvs.buffer)}const U=function(t,e,n,r){const i={},o={},s=r.getLength();if(B(e.polygonFill)){let a=b(e.polygonFill);const l=new Uint8Array(4*s);l.fill(255);for(let e=0;e<s;e++){const o=t[r[e]],s=o.properties||{};s.$layer=o.layer,s.$type=o.type;let u=a(n,s);w(u)&&(i.aColor=1,a=b(u),u=a(n,s)),delete s.$layer,delete s.$type,ze.normalizeColor(Ge,u),l[4*e]=Ge[0],l[4*e+1]=Ge[1],l[4*e+2]=Ge[2],l[4*e+3]=Ge[3]}o.aColor=l}if(B(e.polygonOpacity)){let a=M(e.polygonOpacity,"exponential");const l=new Uint8Array(s);l.fill(255);for(let e=0;e<s;e++){const o=t[r[e]],s=o.properties||{};s.$layer=o.layer,s.$type=o.type;let u=a(n,s);w(u)&&(i.aOpacity=1,a=b(u),u=a(n,s)),delete s.$layer,delete s.$type,l[e]=255*u}o.aOpacity=l}return o.dynamicAttributes=i,o}(t,h,c,O.featureIndexes),R=function(t,e,n,r,i){const o=[[],[]],s=B(r.topPolygonFill),a=B(r.bottomPolygonFill),l=[255,255,255,255],u=e.getLength();if(s||a){let h=s&&b(r.topPolygonFill),c=a&&b(r.bottomPolygonFill),f=null,p=null,d=null,g=null;for(let r=0;r<u;r++){if(1===t[r]&&!s||0===t[r]&&!a)continue;const u=1===t[r];if(u&&e[r]===f){t[r]=d;continue}if(!u&&e[r]===p){t[r]=g;continue}const y=n[e[r]],x=y.properties||{};x.$layer=y.layer,x.$type=y.type;let m=u?h:c,v=m(i,x);w(v)&&(m=b(v),v=m(i,x)),delete x.$layer,delete x.$type,ze.normalizeColor(Ge,v),xt(Ge,Ge,l);let M=Ze(o,Ge);M<0&&(M=o.length,o.push(gt([],Ge))),t[r]=M,u?(f=e[r],d=M):(p=e[r],g=M)}}return o.slice(2)}(O.verticeTypes,O.featureIndexes,t,h,c),J={data:{data:{aVertexColorType:R.length<=252?$e.createTypedArray(O.verticeTypes,Uint8Array):$e.createTypedArray(O.verticeTypes,Uint16Array),aPosition:O.vertices,aNormal:O.normals,aTexCoord0:O.uvs,aTangent:O.tangents,aPickingId:O.pickingIds},indices:z,properties:{maxAltitude:O.maxAltitude/100,minAltitude:O.minAltitude/100,hasNegativeHeight:O.hasNegativeHeight},dynamicAttributes:U.dynamicAttributes,vertexColors:R},buffers:X};return O.featureIds.length?(J.data.featureIds=O.featureIds,X.push(J.data.featureIds.buffer)):J.data.featureIds=[],U.aColor&&(J.data.data.aColor=U.aColor,J.buffers.push(U.aColor.buffer)),U.aOpacity&&(J.data.data.aOpacity=U.aOpacity,J.buffers.push(U.aOpacity.buffer)),J.buffers.push(J.data.data.aPosition.buffer),J.data.pickingIdIndiceMap=De.generatePickingIndiceIndex(J.data.data.aPickingId,J.data.indices),J}const Ge=[];function Ze(t,e){for(let i=0;i<t.length;i++)if(n=e,r=t[i],n[0]===r[0]&&n[1]===r[1]&&n[2]===r[2]&&n[3]===r[3])return i;var n,r;return-1}const{PackUtil:Ue,StyleUtil:Re,FilterUtil:Je}=ne();function He(t,e,n,r,{altitudeScale:i,altitudeProperty:o,defaultAltitude:s,heightProperty:a,minHeightProperty:l,defaultHeight:u,bottom:h}){const c=h,f=e/t[0].extent,p=2*function(t,e){let n=0;for(let e=0,r=t.length;e<r;e++){const r=t[e];if(S(r.geometry[0][0]))n+=3*r.geometry.length;else for(let t=0,e=r.geometry.length;t<e;t++){let e=3*r.geometry[t].length;3===r.type&&(e-=3),n+=e}}return n}(t)+3*t.length*2,d=[],g=new Int16Array(p),y=new Uint8Array(g.length/3*4);w(n)&&(n=Je.compileFilter(n));const x=[];function m(t,n,r){const i=n-t,o=g.subarray(t,n),s=g.subarray(n,n+i);s.set(o);for(let t=2,e=s.length;t<e;t+=3)s[t]=o[t]-r;const a=t/3,l=i/3;let u,h;for(let t=a,n=l+a;t<n;t++)t<n-1?(u=t,h=t+1):(u=t,h=a),ft(g,u,h,e)||(x.push(u,h),c&&x.push(u+l,h+l),We(g,u,e)||x.push(u,u+l));return n+i}let v=0,b=-1/0,M=1/0;const P=(te+"").trim(),_=[];for(let e=0,h=t.length;e<h;e++){const h=t[e],c=h.geometry;if(n){let t;t="function"==typeof n?n(h&&h.properties):n,Re.normalizeColor(_,t)}else dt(_,255,255,255);const p=v/3*4,{altitude:w,height:I}=Ue.getFeaAltitudeAndHeight(h,i,o,s,a,u,l);I<0?(M=Math.min(w,M),b=Math.max(w-I,b)):(M=Math.min(w-I,M),b=Math.max(w,b));let A=v;for(let t=0,e=c.length;t<e;t++){let e=c[t];const n=e.length;e[0][0]===e[n-1][0]&&e[0][1]===e[n-1][1]&&(e=e.slice(0,n-1)),v=ct(g,A,e,f,w),v=m(A,v,I*f),A=v}const S=A/3*4;for(let t=p;t<S;t+=4)y[t]=_[0],y[t+1]=_[1],y[t+2]=_[2],y[t+3]=255*(r||1);const T=x.length-d.length;for(let t=0;t<T;t++)d.push(h[P])}const I=x.reduce(((t,e)=>Math.max(t,e)),0),A=new(Ue.getIndexArrayType(I))(x),T=Ue.getUnsignedArrayType(t.length),F=Math.max(Math.abs(b,Math.abs(M)));return{aPosition:new(Ue.getPosArrayType(Math.max(512,F)))(g),indices:A,aPickingId:new T(d),aColor:y,maxAltitude:b===-1/0?0:b/100,minAltitude:M===1/0?0:M/100}}function We(t,e,n){const r=t[3*e],i=t[3*e+1];return r<0||r>n||i<0||i>n}function Ke(t,e,n,r){const i=He(t,e,n.lineColor,n.lineOpacity,r),{minAltitude:o,maxAltitude:s}=i;delete i.minAltitude,delete i.maxAltitude;const a=[i.aPosition.buffer,i.indices.buffer,i.aPickingId.buffer],l=i.indices;return delete i.indices,{data:{data:i,properties:{minAltitude:o,maxAltitude:s},indices:l},buffers:a}}\n/*!\n Feature Filter by\n\n (c) mapbox 2016 and maptalks 2018\n www.mapbox.com | www.maptalks.org\n License: MIT, header required.\n */const Qe=["Unknown","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"];function tn(t){if(!t)return"true";const e=t[0];if(t.length<=1)return"any"===e?"false":"true";return\`(${s}"=="===e?nn(t[1],t[2],"===",!1):"!="===e?nn(t[1],t[2],"!==",!1):"<"===e||">"===e||"<="===e||">="===e?nn(t[1],t[2],e,!0):"any"===e?on(t.slice(1),"||"):"all"===e?on(t.slice(1),"&&"):"none"===e?ln(on(t.slice(1),"||")):"in"===e?sn(t[1],t.slice(2)):"!in"===e?ln(sn(t[1],t.slice(2))):"has"===e?an(t[1]):"!has"===e?ln(an(t[1])):"contains"===e?function(t,e,n){const r=en(t);return void 0!==n?\`(${s}r} + '').indexOf("${s}e}") === ${s}n}\`:\`(${s}r} + '').indexOf("${s}e}") >= 0\`}(t[1],t[2],t[3]):"true"})\`}function en(t){return"$"===t[0]?"f."+t.substring(1):"p["+JSON.stringify(t)+"]"}function nn(t,e,n,r){if("object"==typeof(i=t)&&i&&t.op)return function(t,e,n,r){const i=t.property,o=t.op;let s=en(i);return"length"!==o?(console.error(\`not support ${s}o} op\`),"false"):(s=\`((${s}s}+='').length)\`,rn(s,i,e,n,r))}(t,e,n,r);var i;return rn(en(t),t,e,n,r)}function rn(t,e,n,r,i){const o="$type"===e?Qe.indexOf(n):JSON.stringify(n);return(i?\`typeof ${s}t}=== typeof ${s}o}&&\`:"")+t+r+o}function on(t,e){return t.map(tn).join(e)}function sn(t,e){"$type"===t&&(e=e.map((t=>Qe.indexOf(t))));const n=JSON.stringify(e.sort(un)),r=en(t);return e.length<=200?\`${s}n}.indexOf(${s}r}) !== -1\`:\`function(v, a, i, j) {\\n while (i <= j) { var m = (i + j) >> 1;\\n if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\\n }\\n return false; }(${s}r}, ${s}n},0,${s}e.length-1})\`}function an(t){return"$id"===t?'"id" in f':\`${s}JSON.stringify(t)} in p\`}function ln(t){return\`!(${s}t})\`}function un(t,e){return t<e?-1:t>e?1:0}let hn=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),hn=!0}catch(t){hn=!1}var cn=hn;const{VectorPack:fn,PolygonPack:pn,NativeLinePack:dn,LinePack:gn,PointPack:yn,NativePointPack:xn,LineExtrusionPack:mn,CirclePack:vn,RoundTubePack:wn,SquareTubePack:bn,FilterUtil:Mn,PackUtil:Pn,StyleUtil:_n,TextUtil:In,DEFAULT_TEX_WIDTH:An,GlyphRequestor:Sn}=ne(),Tn="__original_properties",Fn="__fn-type_properties";class kn{constructor(t,e,n,r,i){this.id=t,this.options=e,this.upload=n,this._compileStyle(e.style),this.requests={},this._cache=r,this._styleCounter=1,this.loadings=i}updateStyle(t,e){this.options.style=t,this._styleCounter=t.styleCounter,this._compileStyle(t),e()}updateOptions(t,e){this.options=I(this.options,t),e()}loadTile(t,e){const n=this.loadings,r=t.tileInfo.url,i=this.options.debugTile;if(i){const{x:n,y:r,z:o}=t.tileInfo;let s=!1;for(let t=0;t<i.length;t++)if(n===i[t].x&&r===i[t].y&&o===i[t].z){s=!0;break}if(!s)return void e()}if(n[r])return void n[r].push({context:t,callback:e,ref:this});n[r]=[{context:t,callback:e,ref:this}];const o=this.options.featureIdProperty;this.requests[r]=this.getTileFeatures(t,((e,i,s,a)=>{const l=n[r];if(delete n[r],this.checkIfCanceled(r))return delete this.requests[r],void this._callWaitings(l,null,{canceled:!0});if(delete this.requests[r],(this.options.debug||o)&&i)for(let e=0;e<i.length;e++)if(this.options.debug&&(i[e]._debug_info={index:e,id:i[e].id,tileId:t.tileInfo.id}),o){const t=F(o)?o[i[e].layer]:o,n=i[e].properties;i[e].id=n&&n[t]||null}if(e)this._callWaitings(l,e);else if(i&&i.length){if(l)for(let t=0;t<l.length;t++)this._onTileLoad.call(l[t].ref,l[t].context,l[t].callback,r,s,i,a)}else this._callWaitings(l)}))}_onTileLoad(t,e,n,r,i,o){this._createTileData(r,i,t).then((n=>{n.canceled?e(null,{canceled:!0}):(n.data.styleCounter=t.styleCounter,o&&I(n.data,o),e(null,n.data,n.buffers))})).catch((t=>{e(t)}))}abortTile(t,e){delete this.requests[t],this._cancelLoadings(t),e()}_cancelLoadings(t){const e=this.loadings[t];if(e)for(let t=0;t<e.length;t++)e[t].callback(null,{canceled:!0});delete this.loadings[t]}_callWaitings(t,e,n){if(t)for(let r=0;r<t.length;r++)t[r].callback(e,n)}checkIfCanceled(t){return!this.requests[t]}onRemove(){this.loadings={},delete this._cache,this.requests={}}fetchIconGlyphs(t,e,n){if(this.options.workerGlyph&&cn){const r=[];if(t&&Object.keys(t).length){const e=new Promise((e=>{this.upload("fetchIconGlyphs",{icons:t},null,((t,n)=>{e({err:t,iconData:n})}))}));r.push(e)}if(e&&Object.keys(e).length){const t=new Promise((t=>{this._glyphRequestor||(this._glyphRequestor=new Sn),this._glyphRequestor.getGlyphs(e,((e,n)=>{t({err:e,glyphData:n})}))}));r.push(t)}Promise.all(r).then((t=>{const e={icons:null,glyphs:null};for(let r=0;r<t.length;r++){if(t[r].err)return void n(t[r].err);t[r].iconData?e.icons=t[r].iconData.icons:t[r].glyphData&&(e.glyphs=t[r].glyphData.glyphs)}return e})).then((t=>{n(null,t)}))}else this.upload("fetchIconGlyphs",{icons:t,glyphs:e},null,n)}_createTileData(t,e,n){if(!e.length)return Promise.resolve({data:null,buffers:[]});const{glScale:r,tileInfo:i}=n,o=!this.options.style.style.length&&!this.options.style.featureStyle.length;let s=this.pluginConfig.slice(0);o&&(s=this._updateLayerPluginConfig(t)),this.featurePlugins&&function(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}t.length}(s,this.featurePlugins);const a={};for(let t=0;t<s.length;t++)Xn(e,n.tileInfo.z,s[t],a);const l=[],u=[];for(let t=0;t<e.length;t++){const n=e[t],r=a[t];if(r){u.fill(null);let t=0;for(const e in r){let i=0;const o=r[e].values();for(const t of o){let r=u[i];r||(r=Dn(n),u[i]=r),r.properties[e]=t,i++}i>t&&(t=i)}for(let e=0;e<t;e++)l.push(u[e])}else l.push(n)}const h=(e=l)[0].extent,c=i.z,f={x:i.extent2d.xmin*r,y:i.extent2d.ymax*r},p=[],d=[],g=[],y=this.options,x=[],m={},v=[Promise.resolve(n.styleCounter)];let w=0,b=-1;const M=[];let P=!1;for(let t=0;t<s.length;t++){b++;const r=s[t];r.type!==w&&(b=0,w=r.type);const a=0===r.type?p:d;if(r.symbol&&!1===r.symbol.visible){a[b]=null;continue}jn(r.symbol,M,t),P=P||M[t]&&M[t].size>0;const{tileFeatures:l,tileFeaIndexes:u}=this._filterFeatures(c,r.type,r.filter,e,m,t);if(!l.length){a[b]=null;continue}const y=u[u.length-1],_=Pn.getIndexArrayType(y);a[b]={styledFeatures:new _(u)},g.push({idx:t,typeIdx:b}),x.push(a[b].styledFeatures.buffer);const A=I({},n,{extent:h,zoom:c,tilePoint:f});if(this.options.debugTile){const t=this.options.debugTile;for(let e=0;e<t.length;e++){const{x:n,y:r,z:o}=t[e];if(i.x===n&&i.y===r&&i.z===o){A.debugIndex=t[e].index;break}}}let S=this._createTileGeometry(l,r,A);o&&(S=S.then((t=>{if(!t)return null;if(t.data)t.data.layer=l[0].layer;else if(Array.isArray(t))for(let e=0;e<t.length;e++)t[e]&&t[e].data&&(t[e].data.layer=l[0].layer);return t}))),v.push(S)}return Promise.all(v).then((([n,...r])=>{if(n!==this._styleCounter)return{canceled:!0};function i(t,e){if(void 0!==t.data.ref)return;const n=s[g[e].idx],r=n.renderPlugin.dataConfig;if(t.data.type=r.type,t.data.filter=n.filter.def,r.altitudeOffset&&(t.data.properties.minAltitude+=r.altitudeOffset,t.data.properties.maxAltitude+=r.altitudeOffset),t.buffers&&t.buffers.length)for(let e=0;e<t.buffers.length;e++)x.push(t.buffers[e])}for(let t=0;t<r.length;t++){if(!r[t])continue;const e=r[t],n=0===s[g[t].idx].type?p:d;if(Array.isArray(e)){const r=[];for(let n=0;n<e.length;n++)e[n]&&(i(e[n],t),(void 0===e[n].data.ref||e[e[n].data.ref])&&r.push(e[n].data));r.length&&(n[g[t].typeIdx].data=r)}else i(e,t),n[g[t].typeIdx].data=e.data}const o={},a=t;if(y.features||y.schema||P){let t,n=!1;for(let r=0,i=e.length;r<i;r++)if(t=e[r],a[t.layer].properties||(a[t.layer].properties=Cn(t.properties)),t&&(y.features||P&&m[r]))if("id"===y.features)o[r]=t.id;else{y.pickingGeometry||delete t.geometry,delete t.extent,delete t.properties.$layer,delete t.properties.$type,delete t.__index;const e=t.originalFeature;if(e){const e=t.properties,n=I({},t.originalFeature);delete e[Tn],n.customProps=I({},e),t=n}const i=I({},t);if(P&&m[r]&&(!y.features||"transient"===y.features)){const i=m[r];for(let r=0;r<i.length;r++){const i=M[r];i&&i.forEach((r=>{const i=e?e.properties:t.properties;i[Fn]||(i[Fn]=new Set),i[Fn].add(r),n=!0}))}}o[r]=i}if(n)for(const t in o){const e=o[t],n=e.properties[Fn];if(n){delete e.properties[Fn],"transient"===y.features&&(e.fnTypeProps=I({},e.properties));for(const t in e.properties)n.has(t)||("transient"===y.features?delete e.fnTypeProps[t]:delete e.properties[t])}}}return{data:{styleCounter:n,schema:a,data:p,featureData:d,extent:h,features:o},buffers:x}})).catch((t=>{console.error(t)}))}_createTileGeometry(t,e,n){let r=t;const i=e.renderPlugin.dataConfig,o=e.symbol,s=this.options.tileSize,{extent:a,glScale:l,zScale:u,zoom:h,tilePoint:c,centimeterToPoint:f,verticalCentimeterToPoint:p}=n,d=a/s,g=i.type,y=n.debugIndex;let x=I({},i,{EXTENT:a,zoom:h,debugIndex:y,features:this.options.features,isWebGPU:this.options.isWebGPU});if("3d-extrusion"===g){Yn(o)&&(i.uv=1);const t=this.options.projectionCode,e=o.material&&o.material.textureWidth||An;return Promise.all([Promise.resolve(je(r,i,a,c,e,n.tileInfo.res,l,a/this.options.tileSize,f,p,o,h,t,y))])}if("3d-wireframe"===g)return Promise.all([Promise.resolve(Ke(r,a,o,i))]);if("point"===g){x=I(x,{requestor:this.fetchIconGlyphs.bind(this),altitudeToTileScale:u*a/this.options.tileSize/l,pluginType:e.renderPlugin.type});let t=o;return Array.isArray(o)||(t=[o]),t=t.map(((t,e)=>(t&&(t.index={index:e},t.isIconText=function(t){return t.markerType||t.markerFile}(t)),t))).filter((t=>!!t)),Promise.all(t.map((t=>{const e=fn.genFnTypes(t);let n=r;return yn.needMerge(t,e,h)&&(n=yn.mergeLineFeatures(r,t,e,h)),new yn(n,t,x).load(d)})))}if("native-point"===g){const t=u*a/this.options.tileSize/l;return x.altitudeToTileScale=t,Vn(r,o,x,xn,d)}if("line"===g)return x=I(x,{requestor:this.fetchIconGlyphs.bind(this),tileRatio:d}),Vn(r,o,x,gn,1,!0);if("native-line"===g)return Vn(r,o,x,dn,1,!0);if("fill"===g)return x=I(x,{requestor:this.fetchIconGlyphs.bind(this)}),Vn(r,o,x,pn);if("line-extrusion"===g){delete o.lineGradientProperty,o.lineJoin="miter",o.lineCap="butt";const t=Yn(o);if(t&&(i.uv=1),x=I(x,{tileSize:s,zScale:u,glScale:l}),o.mergeOnProperty){const t=fn.genFnTypes(o);r=gn.mergeLineFeatures(r,o,t,x.zoom)}if(t){const t=[];if(!1!==i.top){const e=I({},x);e.side=!1,t.push(new mn(r,o,e))}return!1!==i.side&&(x.side=!0,x.top=!1,t.push(new mn(r,o,x))),Promise.all(t.map((t=>t.load())))}return Promise.all([new mn(r,o,x).load()])}if("circle"===g)return Vn(r,o,x,vn);if("round-tube"===g||"square-tube"===g){const t="round-tube"===g?wn:bn;return x=I(x,{requestor:this.fetchIconGlyphs.bind(this),radialSegments:"round-tube"===g?i.radialSegments||8:4,centimeterToPoint:f,verticalCentimeterToPoint:p,tileRatio:d,isTube:!0}),Vn(r,o,x,t)}return Promise.resolve([])}_filterFeatures(t,e,n,r,i,o){const s=(te+"").trim(),a=[],l=[],u=r.length;for(let h=0;h<u;h++)if((1===e||void 0===r[h].id||!this.styledFeatures[r[h].id])&&((!n.def||"default"===n.def)&&!i[h]||!0===n.def||n.def&&(void 0!==n.def.condition||Array.isArray(n.def))&&n(r[h],t))){const t=r[h];if(void 0===t[s]&&(t[s]=h),i[h]||(i[h]=[]),i[h].push(o),l.push(t),a.push(h),1===e)break}return{tileFeatures:l,tileFeaIndexes:a}}_compileStyle(t){const{style:e,featureStyle:n}=t,r={};n.forEach((t=>{Array.isArray(t.id)?(t.id.forEach((t=>{r[t]=1})),t.filter=["in","$id",...t.id]):(r[t.id]=1,t.filter=["==","$id",t.id])}));const i=Mn.compileStyle(e);for(let t=0;t<e.length;t++)i[t].filter&&(i[t].filter.def=e[t].filter?e[t].filter.value||e[t].filter:void 0),i[t].type=0;const o=[],s=Mn.compileStyle(n);for(let t=0;t<n.length;t++)s[t].type=1,s[t].filter.def=n[t].filter?n[t].filter.value||n[t].filter:void 0,s[t].renderPlugin&&o.push(s[t]);this.pluginConfig=i,this.featurePlugins=o,this.styledFeatures=r}_updateLayerPluginConfig(t){let e=this._layerPlugins;this._layerPlugins||(e=this._layerPlugins={});const n=["","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"],r=[];for(const o in t){const s=o;if(!e[o]){const r=[];for(let e=0;e<t[o].types.length;e++){const a=t[o].types[e],l=["all",["==","$layer",s],["==","$type",n[a]]],u={filter:(i=l,new Function("f",\`var p = (f && f.properties || {}); return ${s}tn(i)}\`)),renderPlugin:Bn(a),symbol:Ln(a)};u.filter.def=l,u.type=0,r.push(u)}e[s]=r}r.push(...e[s])}var i;return r}}function Bn(t){switch(t){case 1:return{type:"native-point",dataConfig:{type:"native-point",only2D:!0}};case 2:return{type:"native-line",dataConfig:{type:"native-line",only2D:!0}};case 3:return{type:"fill",dataConfig:{type:"fill",only2D:!0}}}return null}function Ln(t){switch(t){case 1:return{markerFill:"#f00",markerSize:10};case 2:return{lineColor:"#fff"};case 3:return{polygonFill:"#00f",polygonOpacity:.4}}return null}function Cn(t){if(Array.isArray(t)||!F(t))return{};const e={};for(const n in t){const r=t[n];A(r)?e[n]="string":S(r)?e[n]="number":!0===r||!1===r?e[n]="boolean":Array.isArray(r)?e[n]="array":e[n]="object"}return e}function Yn(t){if(!t)return 0;let e=0;for(const n in t){if(("normalTexture"===n||"bumpTexture"===n)&&t[n])return 2;if(n.indexOf("Texture")>0&&t[n])e=1;else if(F(t[n])){const r=Yn(t[n]);if(2===r)return r;1===r&&(e=1)}}return e}function Vn(t,e,n,r,i,o){const s={},a=Array.isArray(e)?e:[e];let l=-1;for(let t=0;t<a.length;t++)s[t]=On(a[t]),!s[t]&&a[t]&&-1===l&&(l=t);const u=[];for(let e=0;e<a.length;e++){if(!a[e])continue;a[e].index={index:e};let h=t;if(o&&a[e].mergeOnProperty){const r=fn.genFnTypes(a[e]);h=gn.mergeLineFeatures(t,a[0],r,n.zoom)}s[e]||e===l?u.push(new r(h,a[e],n).load(i)):u.push({data:{ref:l,symbolIndex:{index:e}}})}return Promise.all(u)}function On(t){if(!t)return 0;for(const e in t)if(B(t[e]))return 1;return 0}function Xn(t,e,n,r){const i=n.customProperties;if(!i)return t;if(i)for(let t=0;t<i.length;t++)i[t].fn=Mn.compileFilter(i[t].filter);for(let n=0;n<i.length;n++)for(let o=0,s=t.length;o<s;o++)if(i[n].fn(t[o],e))for(const t in i[n].properties){const e=i[n].properties[t];k(e)||(r[o]||(r[o]={}),r[o][t]||(r[o][t]=new Set),r[o][t].add(e))}}const Nn={get:(t,e)=>e in t?t[e]:t.originalFeature[e],has:(t,e)=>e in t||e in t.originalFeature},En={get:function(t,e){return e in t?t[e]:t[Tn][e]},has:(t,e)=>e in t||e in t[Tn]},zn={};function Dn(t){const e={};e.originalFeature=t;const n=new Proxy(e,Nn);return n.properties=new Proxy({},En),n.properties[Tn]=t.properties||zn,n}function $n(t,e,n){t[e]||(t[e]=new Set),t[e].add(n)}const qn=[];function jn(t,e,n){if(!t)return qn;for(const r in t){if(!t[r]||!_n.checkIfZoomFnTypeSymbol(r))continue;if(B(t[r]))$n(e,n,t[r].property);else{if("lineGradientProperty"===r){$n(e,n,t[r]);continue}if("textName"===r)if(A(t[r])){const i=In.resolveVarNames(t[r]);if(i)for(let t=0;t<i.length;t++)$n(e,n,i[t])}else if(Mn.isExpression(t[r])){const i=[];In.resolveExpVarNames(i,t[r]);for(let t=0;t<i.length;t++)$n(e,n,i[t])}}const i=t[r].stops;if(i&&i.length)for(let t=0;t<i.length;t++)B(i[t][1])&&$n(e,t,i[t][1].property)}return e[n]}function Gn(t,e){Zn(t.geometry,e)}function Zn(t,e){if(t)switch(t.type){case"Point":Un(t.coordinates,e);break;case"MultiPoint":case"LineString":Rn(t.coordinates,e);break;case"MultiLineString":!function(t,e){for(let n=0,r=t.length;n<r;n++)Rn(t[n],e)}(t.coordinates,e);break;case"Polygon":Jn(t.coordinates,e);break;case"MultiPolygon":!function(t,e){for(let n=0,r=t.length;n<r;n++)Jn(t[n],e)}(t.coordinates,e);break;case"GeometryCollection":const n=t.geometries.length;for(let r=0;r<n;r++)Zn(t.geometries[r],e)}}function Un(t,e){e[0]=Math.min(e[0],t[0]),e[1]=Math.min(e[1],t[1]),e[2]=Math.max(e[2],t[0]),e[3]=Math.max(e[3],t[1])}function Rn(t,e){for(let n=0,r=t.length;n<r;n++)Un(t[n],e)}function Jn(t,e){t.length&&Rn(t[0],e)}function Hn(t,e,n,r,i){Wn(t,e,n||0,r||t.length-1,i||Qn)}function Wn(t,e,n,r,i){for(;r>n;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Wn(t,e,Math.max(n,Math.floor(e-s*l/o+u)),Math.min(r,Math.floor(e+(o-s)*l/o+u)),i)}var h=t[e],c=n,f=r;for(Kn(t,n,e),i(t[r],h)>0&&Kn(t,n,r);c<f;){for(Kn(t,c,f),c++,f--;i(t[c],h)<0;)c++;for(;i(t[f],h)>0;)f--}0===i(t[n],h)?Kn(t,n,f):Kn(t,++f,r),f<=e&&(n=f+1),e<=f&&(r=f-1)}}function Kn(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Qn(t,e){return t<e?-1:t>e?1:0}class tr{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 n=[];if(!cr(t,e))return n;const r=this.toBBox,i=[];for(;e;){for(let o=0;o<e.children.length;o++){const s=e.children[o],a=e.leaf?r(s):s;cr(t,a)&&(e.leaf?n.push(s):hr(t,a)?this._all(s,n):i.push(s))}e=i.pop()}return n}collides(t){let e=this.data;if(!cr(t,e))return!1;const n=[];for(;e;){for(let r=0;r<e.children.length;r++){const i=e.children[r],o=e.leaf?this.toBBox(i):i;if(cr(t,o)){if(e.leaf||hr(t,o))return!0;n.push(i)}}e=n.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this._minEntries){for(let e=0;e<t.length;e++)this.insert(t[e]);return this}let e=this._build(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===e.height)this._splitRoot(this.data,e);else{if(this.data.height<e.height){const t=this.data;this.data=e,e=t}this._insert(e,this.data.height-e.height-1,!0)}else this.data=e;return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=fr([]),this}remove(t,e){if(!t)return this;let n=this.data;const r=this.toBBox(t),i=[],o=[];let s,a,l;for(;n||i.length;){if(n||(n=i.pop(),a=i[i.length-1],s=o.pop(),l=!0),n.leaf){const r=er(t,n.children,e);if(-1!==r)return n.children.splice(r,1),i.push(n),this._condense(i),this}l||n.leaf||!hr(n,r)?a?(s++,n=a.children[s],l=!1):n=null:(i.push(n),o.push(s),s=0,a=n,n=n.children[0])}return this}toBBox(t){return t}compareMinX(t,e){return t.minX-e.minX}compareMinY(t,e){return t.minY-e.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,e){const n=[];for(;t;)t.leaf?e.push(...t.children):n.push(...t.children),t=n.pop();return e}_build(t,e,n,r){const i=n-e+1;let o,s=this._maxEntries;if(i<=s)return o=fr(t.slice(e,n+1)),nr(o,this.toBBox),o;r||(r=Math.ceil(Math.log(i)/Math.log(s)),s=Math.ceil(i/Math.pow(s,r-1))),o=fr([]),o.leaf=!1,o.height=r;const a=Math.ceil(i/s),l=a*Math.ceil(Math.sqrt(s));pr(t,e,n,l,this.compareMinX);for(let i=e;i<=n;i+=l){const e=Math.min(i+l-1,n);pr(t,i,e,a,this.compareMinY);for(let n=i;n<=e;n+=a){const i=Math.min(n+a-1,e);o.children.push(this._build(t,n,i,r-1))}}return nr(o,this.toBBox),o}_chooseSubtree(t,e,n,r){for(;r.push(e),!e.leaf&&r.length-1!==n;){let n,r=1/0,s=1/0;for(let a=0;a<e.children.length;a++){const l=e.children[a],u=ar(l),h=(i=t,o=l,(Math.max(o.maxX,i.maxX)-Math.min(o.minX,i.minX))*(Math.max(o.maxY,i.maxY)-Math.min(o.minY,i.minY))-u);h<s?(s=h,r=u<r?u:r,n=l):h===s&&u<r&&(r=u,n=l)}e=n||e.children[0]}var i,o;return e}_insert(t,e,n){const r=n?t:this.toBBox(t),i=[],o=this._chooseSubtree(r,this.data,e,i);for(o.children.push(t),ir(o,r);e>=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)}_split(t,e){const n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);const o=this._chooseSplitIndex(n,i,r),s=fr(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,nr(n,this.toBBox),nr(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)}_splitRoot(t,e){this.data=fr([t,e]),this.data.height=t.height+1,this.data.leaf=!1,nr(this.data,this.toBBox)}_chooseSplitIndex(t,e,n){let r,i=1/0,o=1/0;for(let s=e;s<=n-e;s++){const e=rr(t,0,s,this.toBBox),a=rr(t,s,n,this.toBBox),l=ur(e,a),u=ar(e)+ar(a);l<i?(i=l,r=s,o=u<o?u:o):l===i&&u<o&&(o=u,r=s)}return r||n-e}_chooseSplitAxis(t,e,n){const r=t.leaf?this.compareMinX:or,i=t.leaf?this.compareMinY:sr;this._allDistMargin(t,e,n,r)<this._allDistMargin(t,e,n,i)&&t.children.sort(r)}_allDistMargin(t,e,n,r){t.children.sort(r);const i=this.toBBox,o=rr(t,0,e,i),s=rr(t,n-e,n,i);let a=lr(o)+lr(s);for(let r=e;r<n-e;r++){const e=t.children[r];ir(o,t.leaf?i(e):e),a+=lr(o)}for(let r=n-e-1;r>=e;r--){const e=t.children[r];ir(s,t.leaf?i(e):e),a+=lr(s)}return a}_adjustParentBBoxes(t,e,n){for(let r=n;r>=0;r--)ir(e[r],t)}_condense(t){for(let e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():nr(t[n],this.toBBox)}}function er(t,e,n){if(!n)return e.indexOf(t);for(let r=0;r<e.length;r++)if(n(t,e[r]))return r;return-1}function nr(t,e){rr(t,0,t.children.length,e,t)}function rr(t,e,n,r,i){i||(i=fr(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let o=e;o<n;o++){const e=t.children[o];ir(i,t.leaf?r(e):e)}return i}function ir(t,e){return t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),t}function or(t,e){return t.minX-e.minX}function sr(t,e){return t.minY-e.minY}function ar(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function lr(t){return t.maxX-t.minX+(t.maxY-t.minY)}function ur(t,e){const n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}function hr(t,e){return t.minX<=e.minX&&t.minY<=e.minY&&e.maxX<=t.maxX&&e.maxY<=t.maxY}function cr(t,e){return e.minX<=t.maxX&&e.minY<=t.maxY&&e.maxX>=t.minX&&e.maxY>=t.minY}function fr(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function pr(t,e,n,r,i){const o=[e,n];for(;o.length;){if((n=o.pop())-(e=o.pop())<=r)continue;const s=e+Math.ceil((n-e)/r/2)*r;Hn(t,s,e,n,i),o.push(e,s,s,n)}}class dr{constructor(t=[],e=gr){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)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:n}=this,r=e[t];for(;t>0;){const i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}_down(t){const{data:e,compare:n}=this,r=this.length>>1,i=e[t];for(;t<r;){let r=1+(t<<1),o=e[r];const s=r+1;if(s<this.length&&n(e[s],o)<0&&(r=s,o=e[s]),n(o,i)>=0)break;e[t]=o,t=r}e[t]=i}}function gr(t,e){return t<e?-1:t>e?1:0}function yr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xr={exports:{}},mr=function(t,e,n,r){var i=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var a=(r-n)/2,l=0,u=a-1;l<a;u=l++){var h=e[n+2*l+0],c=e[n+2*l+1],f=e[n+2*u+0],p=e[n+2*u+1];c>o!=p>o&&i<(f-h)*(o-c)/(p-c)+h&&(s=!s)}return s},vr=function(t,e,n,r){var i=t[0],o=t[1],s=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var a=r-n,l=0,u=a-1;l<a;u=l++){var h=e[l+n][0],c=e[l+n][1],f=e[u+n][0],p=e[u+n][1];c>o!=p>o&&i<(f-h)*(o-c)/(p-c)+h&&(s=!s)}return s};xr.exports=function(t,e,n,r){return e.length>0&&Array.isArray(e[0])?vr(t,e,n,r):mr(t,e,n,r)};var wr=xr.exports.nested=vr;xr.exports.flat=mr;const br=11102230246251565e-32,Mr=134217729,Pr=(3+8*br)*br;function _r(t,e,n,r,i){let o,s,a,l,u=e[0],h=r[0],c=0,f=0;h>u==h>-u?(o=u,u=e[++c]):(o=h,h=r[++f]);let p=0;if(c<t&&f<n)for(h>u==h>-u?(s=u+o,a=o-(s-u),u=e[++c]):(s=h+o,a=o-(s-h),h=r[++f]),o=s,0!==a&&(i[p++]=a);c<t&&f<n;)h>u==h>-u?(s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c]):(s=o+h,l=s-o,a=o-(s-l)+(h-l),h=r[++f]),o=s,0!==a&&(i[p++]=a);for(;c<t;)s=o+u,l=s-o,a=o-(s-l)+(u-l),u=e[++c],o=s,0!==a&&(i[p++]=a);for(;f<n;)s=o+h,l=s-o,a=o-(s-l)+(h-l),h=r[++f],o=s,0!==a&&(i[p++]=a);return 0===o&&0!==p||(i[p++]=o),p}function Ir(t){return new Float64Array(t)}const Ar=33306690738754716e-32,Sr=22204460492503146e-32,Tr=11093356479670487e-47,Fr=Ir(4),kr=Ir(8),Br=Ir(12),Lr=Ir(16),Cr=Ir(4);function Yr(t,e,n,r,i,o){const s=(e-o)*(n-i),a=(t-i)*(r-o),l=s-a;if(0===s||0===a||s>0!=a>0)return l;const u=Math.abs(s+a);return Math.abs(l)>=Ar*u?l:-function(t,e,n,r,i,o,s){let a,l,u,h,c,f,p,d,g,y,x,m,v,w,b,M,P,_;const I=t-i,A=n-i,S=e-o,T=r-o;w=I*T,f=Mr*I,p=f-(f-I),d=I-p,f=Mr*T,g=f-(f-T),y=T-g,b=d*y-(w-p*g-d*g-p*y),M=S*A,f=Mr*S,p=f-(f-S),d=S-p,f=Mr*A,g=f-(f-A),y=A-g,P=d*y-(M-p*g-d*g-p*y),x=b-P,c=b-x,Fr[0]=b-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-M,c=v-x,Fr[1]=v-(x+c)+(c-M),_=m+x,c=_-m,Fr[2]=m-(_-c)+(x-c),Fr[3]=_;let F=function(t,e){let n=e[0];for(let r=1;r<t;r++)n+=e[r];return n}(4,Fr),k=Sr*s;if(F>=k||-F>=k)return F;if(c=t-I,a=t-(I+c)+(c-i),c=n-A,u=n-(A+c)+(c-i),c=e-S,l=e-(S+c)+(c-o),c=r-T,h=r-(T+c)+(c-o),0===a&&0===l&&0===u&&0===h)return F;if(k=Tr*s+Pr*Math.abs(F),F+=I*h+T*a-(S*u+A*l),F>=k||-F>=k)return F;w=a*T,f=Mr*a,p=f-(f-a),d=a-p,f=Mr*T,g=f-(f-T),y=T-g,b=d*y-(w-p*g-d*g-p*y),M=l*A,f=Mr*l,p=f-(f-l),d=l-p,f=Mr*A,g=f-(f-A),y=A-g,P=d*y-(M-p*g-d*g-p*y),x=b-P,c=b-x,Cr[0]=b-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-M,c=v-x,Cr[1]=v-(x+c)+(c-M),_=m+x,c=_-m,Cr[2]=m-(_-c)+(x-c),Cr[3]=_;const B=_r(4,Fr,4,Cr,kr);w=I*h,f=Mr*I,p=f-(f-I),d=I-p,f=Mr*h,g=f-(f-h),y=h-g,b=d*y-(w-p*g-d*g-p*y),M=S*u,f=Mr*S,p=f-(f-S),d=S-p,f=Mr*u,g=f-(f-u),y=u-g,P=d*y-(M-p*g-d*g-p*y),x=b-P,c=b-x,Cr[0]=b-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-M,c=v-x,Cr[1]=v-(x+c)+(c-M),_=m+x,c=_-m,Cr[2]=m-(_-c)+(x-c),Cr[3]=_;const L=_r(B,kr,4,Cr,Br);w=a*h,f=Mr*a,p=f-(f-a),d=a-p,f=Mr*h,g=f-(f-h),y=h-g,b=d*y-(w-p*g-d*g-p*y),M=l*u,f=Mr*l,p=f-(f-l),d=l-p,f=Mr*u,g=f-(f-u),y=u-g,P=d*y-(M-p*g-d*g-p*y),x=b-P,c=b-x,Cr[0]=b-(x+c)+(c-P),m=w+x,c=m-w,v=w-(m-c)+(x-c),x=v-M,c=v-x,Cr[1]=v-(x+c)+(c-M),_=m+x,c=_-m,Cr[2]=m-(_-c)+(x-c),Cr[3]=_;const C=_r(L,Br,4,Cr,Lr);return Lr[C-1]}(t,e,n,r,i,o,u)}function Vr(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;var r=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;o<t.length;o++){var s=t[o];s[0]<e[0]&&(e=s),s[0]>r[0]&&(r=s),s[1]<n[1]&&(n=s),s[1]>i[1]&&(i=s)}var a=[e,n,r,i],l=a.slice();for(o=0;o<t.length;o++)wr(t[o],a)||l.push(t[o]);return function(t){t.sort(Ur);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&Dr(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var r=[],i=t.length-1;i>=0;i--){for(;r.length>=2&&Dr(r[r.length-2],r[r.length-1],t[i])<=0;)r.pop();r.push(t[i])}return r.pop(),e.pop(),e.concat(r)}(l)}(t),i=new tr(16);i.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},i.compareMinX=function(t,e){return t[0]-e[0]},i.compareMinY=function(t,e){return t[1]-e[1]},i.load(t);for(var o,s=[],a=0;a<r.length;a++){var l=r[a];i.remove(l),o=qr(l,o),s.push(o)}var u=new tr(16);for(a=0;a<s.length;a++)u.insert($r(s[a]));for(var h=e*e,c=n*n;s.length;){var f=s.shift(),p=f.p,d=f.next.p,g=jr(p,d);if(!(g<c)){var y=g/h;(l=Or(i,f.prev.p,p,d,f.next.next.p,y,u))&&Math.min(jr(l,p),jr(l,d))<=y&&(s.push(f),s.push(qr(l,f)),i.remove(l),u.remove(f),u.insert($r(f)),u.insert($r(f.next)))}}f=o;var x=[];do{x.push(f.p),f=f.next}while(f!==o);return x.push(f.p),x}function Or(t,e,n,r,i,o,s){for(var a=new dr([],Xr),l=t.data;l;){for(var u=0;u<l.children.length;u++){var h=l.children[u],c=l.leaf?Gr(h,n,r):Nr(n,r,h);c>o||a.push({node:h,dist:c})}for(;a.length&&!a.peek().node.children;){var f=a.pop(),p=f.node,d=Gr(p,e,n),g=Gr(p,r,i);if(f.dist<d&&f.dist<g&&zr(n,p,s)&&zr(r,p,s))return p}(l=a.pop())&&(l=l.node)}return null}function Xr(t,e){return t.dist-e.dist}function Nr(t,e,n){if(Er(t,n)||Er(e,n))return 0;var r=Zr(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===r)return 0;var i=Zr(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===i)return 0;var o=Zr(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===o)return 0;var s=Zr(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===s?0:Math.min(r,i,o,s)}function Er(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function zr(t,e,n){for(var r,i,o,s,a=Math.min(t[0],e[0]),l=Math.min(t[1],e[1]),u=Math.max(t[0],e[0]),h=Math.max(t[1],e[1]),c=n.search({minX:a,minY:l,maxX:u,maxY:h}),f=0;f<c.length;f++)if(r=c[f].p,i=c[f].next.p,o=t,r!==(s=e)&&i!==o&&Dr(r,i,o)>0!=Dr(r,i,s)>0&&Dr(o,s,r)>0!=Dr(o,s,i)>0)return!1;return!0}function Dr(t,e,n){return Yr(t[0],t[1],e[0],e[1],n[0],n[1])}function $r(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function qr(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function jr(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function Gr(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(0!==o||0!==s){var a=((t[0]-r)*o+(t[1]-i)*s)/(o*o+s*s);a>1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a)}return(o=t[0]-r)*o+(s=t[1]-i)*s}function Zr(t,e,n,r,i,o,s,a){var l,u,h,c,f=n-t,p=r-e,d=s-i,g=a-o,y=t-i,x=e-o,m=f*f+p*p,v=f*d+p*g,w=d*d+g*g,b=f*y+p*x,M=d*y+g*x,P=m*w-v*v,_=P,I=P;0===P?(u=0,_=1,c=M,I=w):(c=m*M-v*b,(u=v*M-w*b)<0?(u=0,c=M,I=w):u>_&&(u=_,c=M+v,I=w)),c<0?(c=0,-b<0?u=0:-b>m?u=_:(u=-b,_=m)):c>I&&(c=I,-b+v<0?u=0:-b+v>m?u=_:(u=-b+v,_=m));var A=(1-(h=0===c?0:c/I))*i+h*s-((1-(l=0===u?0:u/_))*t+l*n),S=(1-h)*o+h*a-((1-l)*e+l*r);return A*A+S*S}function Ur(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}const{PackUtil:Rr}=ne();class Jr{constructor(t,e){this.x=t,this.y=e}clone(){return new Jr(this.x,this.y)}normalize(){const t=this.length();this.x/=t,this.y/=t}negate(){this.x=-this.x,this.y=-this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}diff(t){return new Jr(this.x-t.x,this.y-t.y)}distance(t){const e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x===t.x&&this.y===t.y}orthogonal(){return new Jr(this.y,-this.x)}}function Hr(t,e,n,r){const i=e.x*r.y-e.y*r.x,o=n.x-t.x,s=n.y-t.y,a=(o*r.y-s*r.x)/i;return new Jr(t.x+a*e.x,t.y+a*e.y)}const Wr=[],Kr=[];function Qr(t){if(S(t[0]&&t[0].x)){const e=[];let n=0;for(let r=0;r<t.length;r++)Kr[n]?(Kr[n][0]=t[r].x,Kr[n][1]=t[r].y):Kr[n]=[t[r].x,t[r].y],e.push(Kr[n]),n++;t=e}try{const e=Vr(t,1/0);let n=[1/0,1/0],r=[-1/0,-1/0];for(let t=0;t<e.length;t++)e[t][0]<n[0]&&(n[0]=e[t][0]),e[t][0]>r[0]&&(r[0]=e[t][0]),e[t][1]<n[1]&&(n[1]=e[t][1]),e[t][1]>r[1]&&(r[1]=e[t][1]);const i=[];let o=[],s=0;for(let t=0;t<e.length;t++)t===e.length-1&&e[t][0]===e[0][0]&&e[t][1]===e[0][1]||(Pt(i,e[t],"EPSG:3857"),Wr[s]?(Wr[s].x=i[0],Wr[s].y=i[1]):Wr[s]=new Jr(i[0],i[1]),o.push(Wr[s]),s++);Rr.calculateSignedArea(o)<0&&(o=o.reverse());const a=function(t){let e,n=Number.MAX_VALUE;const r=function(t,r,i,o,s,a,l,u){var h=Hr(t,r,s,a),c=Hr(i,o,s,a),f=Hr(l,u,t,r),p=Hr(l,u,i,o),d=h.distance(c)*h.distance(f);0!==d&&d<n&&(e=[h,f,p,c],n=d)};var i=[];for(let e=0;e<t.length;e++)i.push(t[(e+1)%t.length].diff(t[e])),i[e].normalize();var o,s,a,l,u=new Jr(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),h=new Jr(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let e=0;e<t.length;e++){var c=t[e];c.x<u.x&&(u.x=c.x,o=e),c.x>h.x&&(h.x=c.x,s=e),c.y<u.y&&(u.y=c.y,l=e),c.y>h.y&&(h.y=c.y,a=e)}var f=new Jr(0,-1),p=new Jr(0,1),d=new Jr(-1,0),g=new Jr(1,0);for(let e=0;e<t.length;e++){var y=[Math.acos(f.dot(i[o])),Math.acos(p.dot(i[s])),Math.acos(d.dot(i[a])),Math.acos(g.dot(i[l]))];switch(y.indexOf(Math.min.apply(Math,y))){case 0:(p=(f=i[o].clone()).clone()).negate(),(g=(d=f.orthogonal()).clone()).negate(),o=(o+1)%t.length;break;case 1:(f=(p=i[s].clone()).clone()).negate(),(g=(d=f.orthogonal()).clone()).negate(),s=(s+1)%t.length;break;case 2:(g=(d=i[a].clone()).clone()).negate(),(p=(f=g.orthogonal()).clone()).negate(),a=(a+1)%t.length;break;case 3:(d=(g=i[l].clone()).clone()).negate(),(p=(f=g.orthogonal()).clone()).negate(),l=(l+1)%t.length}r(t[o],f,t[s],p,t[a],d,t[l],g)}return e}(o);if(!a||4!==a.length)return null;const l=a[0].distance(a[1]),u=a[1].distance(a[2]),h=a.map((t=>[t.x,t.y]));return h.push(+(u>l)),h}catch(t){return null}}const ti=[];function ei(t,e){const n=Array.isArray(t&&t[0]&&t[0][0]);for(let r=0;r<t.length;r++)n?t[r]=ei(t[r]):(Pt(ti,t[r],e),t[r][0]=ti[0],t[r][1]=ti[1]);return t}const{PackUtil:ni}=ne();class ri extends kn{constructor(t,e,n,r,i,o){super(t,e,n,r,i),(e=e||{}).extent||(e.extent=8192),this.setData(e.data,o)}clearData(){delete this.index}setData(t,e){if(delete this.index,function(t){if(!t)return!0;if(Array.isArray(t)&&!t.length)return!0;if(t.features&&!t.features.length)return!0;return!1}(t))return this.empty=!0,void e();const n={maxZoom:24,tolerance:this.options.simplifyTolerance,extent:this.options.extent,buffer:S(this.options.tileBuffer)?this.options.tileBuffer:64,hasAltitude:!!this.options.hasAltitude,debug:0,lineMetrics:!0,indexMaxZoom:5,indexMaxPoints:1e5,disableFilter:!0};if(this.options.projection&&(n.projection=this.options.projection,"EPSG:4490"===n.projection&&(n.projection="EPSG:4326")),A(t)&&"{"!=t.substring(0,1)||t.url){const r=t.url?t.url:t;C.getJSON(r,t.url?t:{},((t,i)=>{if(t&&(console.error("Failed to fetch geojson:"+r),e(t)),!i)return void e(null,{extent:null,idMap:{}});let o=i;if(this.options.convertFn){o=new Function("data",this.options.convertFn+"\\nreturn convert(data)")(o)}const s=Array.isArray(o)?o:o.features;this._genOMBB(s);const{sample1000:a,idMap:l}=this._generateId(s);this._generate(a,l,o,n,e)}))}else{"string"==typeof t&&(t=JSON.parse(t));const r=Array.isArray(t)?t:t.features,i=r&&r.length;this._genOMBB(r);let o=r;if(r&&i>1e3){o=[];for(let t=0;t<i;t++)ii(r[t],o,t,i)}this._generate(o,null,t,n,e)}}_genOMBB(t){if(this.options.generateOMBB&&t)for(let e=0;e<t.length;e++){const n=t[e];if(n&&n.geometry&&n.geometry.coordinates)if("Polygon"===n.geometry.type){const t=n.geometry.coordinates[0];if(!t)continue;const e=Qr(t,t.length);n.properties=n.properties||{},n.properties[ee]=e}else if("MultiPolygon"===n.geometry.type){const t=n.geometry.coordinates;for(let e=0;e<t.length;e++){if(!t[e])continue;const r=t[e][0];if(!r)continue;const i=Qr(r,r.length);n.properties=n.properties||{},n.properties[ee]=n.properties[ee]||[],n.properties[ee][e]=i}}}}_generate(t,e,n,r,i){try{const o=t&&t.length?function(t){let e=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];switch(t.type){case"FeatureCollection":const n=t.features.length;for(let r=0;r<n;r++)Gn(t.features[r],e);break;case"Feature":Gn(t,e);break;default:Zn(t,e)}return e}({type:"FeatureCollection",features:t}):null;this.index=function(t,e){return new ut(t,e)}(n,this.options.geojsonvt||r),i(null,{extent:o,idMap:e})}catch(t){console.warn(t),i({error:t.message})}}_generateId(t){const e=[],n={};let r=0;const i=this.options.featureIdProperty;if(t){const o=t.length;t.forEach(((t,s)=>{!function(t,o,s){if(t&&("Feature"!==t.type||t.geometry)){if(S(t.id)||(t.id=r++),i){let e=i;F(i)&&(e=i[t.layer||"0"]),t.id=t.properties[e]}n[t.id]=I({},t),t.geometry?(n[t.id].geometry=I({},t.geometry),n[t.id].geometry.coordinates=null):t.coordinates&&(n[t.id].coordinates=null),ii(t,e,o,s)}}(t,s,o)}))}return{sample1000:e,idMap:n}}getTileFeatures(t,e){const n=t.tileInfo,r=[];if(!this.index)return this.empty?(setTimeout((function(){e(null,r,[])}),1),1):(setTimeout((function(){e({loading:!0})}),1),1);const i=this.index.getTile(n.z,n.x,n.y);if(!i||0===i.features.length)return setTimeout((function(){e(null,r,[])}),1),1;const o=[];for(let t=0,e=i.features.length;t<e;t++){const e=i.features[t];let n=e.layer;void 0===n&&(n="0"),o[n]={types:{}};o[n].types[e.type]=1,e.tags=e.tags||{},e.geometry.converted||(ni.convertGeometry(e),e.geometry.converted=1),r.push({type:e.type,layer:n,id:e.id,geometry:e.geometry,properties:e.tags,extent:this.options.extent})}for(const t in o)o[t].types=Object.keys(o[t].types).map((t=>+t));return setTimeout((function(){e(null,r,o)}),1),1}onRemove(){super.onRemove(),delete this.index}}function ii(t,e,n,r){const i=Math.floor(r/998);(0===n||n===r-1||(0===i||n%i==0)&&e.length<999)&&e.push(t)}var oi={\n/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nread:function(t,e,n,r,i){var o,s,a=8*i-r-1,l=(1<<a)-1,u=l>>1,h=-7,c=n?i-1:0,f=n?-1:1,p=t[e+c];for(c+=f,o=p&(1<<-h)-1,p>>=-h,h+=a;h>0;o=256*o+t[e+c],c+=f,h-=8);for(s=o&(1<<-h)-1,o>>=-h,h+=r;h>0;s=256*s+t[e+c],c+=f,h-=8);if(0===o)o=1-u;else{if(o===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),o-=u}return(p?-1:1)*s*Math.pow(2,o-r)},write:function(t,e,n,r,i,o){var s,a,l,u=8*o-i-1,h=(1<<u)-1,c=h>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,d=r?1:-1,g=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=h):(s=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-s))<1&&(s--,l*=2),(e+=s+c>=1?f/l:f*Math.pow(2,1-c))*l>=2&&(s++,l/=2),s+c>=h?(a=0,s=h):s+c>=1?(a=(e*l-1)*Math.pow(2,i),s+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[n+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,u+=i;u>0;t[n+p]=255&s,p+=d,s/=256,u-=8);t[n+p-d]|=128*g}},si=li,ai=oi;function li(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}li.Varint=0,li.Fixed64=1,li.Bytes=2,li.Fixed32=5;var ui=4294967296,hi=1/ui,ci="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function fi(t){return t.type===li.Bytes?t.readVarint()+t.pos:t.pos+1}function pi(t,e,n){return n?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function di(t,e,n){var r=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=t;i--)n.buf[i+r]=n.buf[i]}function gi(t,e){for(var n=0;n<t.length;n++)e.writeVarint(t[n])}function yi(t,e){for(var n=0;n<t.length;n++)e.writeSVarint(t[n])}function xi(t,e){for(var n=0;n<t.length;n++)e.writeFloat(t[n])}function mi(t,e){for(var n=0;n<t.length;n++)e.writeDouble(t[n])}function vi(t,e){for(var n=0;n<t.length;n++)e.writeBoolean(t[n])}function wi(t,e){for(var n=0;n<t.length;n++)e.writeFixed32(t[n])}function bi(t,e){for(var n=0;n<t.length;n++)e.writeSFixed32(t[n])}function Mi(t,e){for(var n=0;n<t.length;n++)e.writeFixed64(t[n])}function Pi(t,e){for(var n=0;n<t.length;n++)e.writeSFixed64(t[n])}function _i(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+16777216*t[e+3]}function Ii(t,e,n){t[n]=e,t[n+1]=e>>>8,t[n+2]=e>>>16,t[n+3]=e>>>24}function Ai(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16)+(t[e+3]<<24)}li.prototype={destroy:function(){this.buf=null},readFields:function(t,e,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),i=r>>3,o=this.pos;this.type=7&r,t(i,e,this),this.pos===o&&this.skip(r)}return e},readMessage:function(t,e){return this.readFields(t,e,this.readVarint()+this.pos)},readFixed32:function(){var t=_i(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=Ai(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=_i(this.buf,this.pos)+_i(this.buf,this.pos+4)*ui;return this.pos+=8,t},readSFixed64:function(){var t=_i(this.buf,this.pos)+Ai(this.buf,this.pos+4)*ui;return this.pos+=8,t},readFloat:function(){var t=ai.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=ai.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var e,n,r=this.buf;return e=127&(n=r[this.pos++]),n<128?e:(e|=(127&(n=r[this.pos++]))<<7,n<128?e:(e|=(127&(n=r[this.pos++]))<<14,n<128?e:(e|=(127&(n=r[this.pos++]))<<21,n<128?e:function(t,e,n){var r,i,o=n.buf;if(i=o[n.pos++],r=(112&i)>>4,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<3,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<10,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<17,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(127&i)<<24,i<128)return pi(t,r,e);if(i=o[n.pos++],r|=(1&i)<<31,i<128)return pi(t,r,e);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(n=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&ci?function(t,e,n){return ci.decode(t.subarray(e,n))}(this.buf,e,t):function(t,e,n){var r="",i=e;for(;i<n;){var o,s,a,l=t[i],u=null,h=l>239?4:l>223?3:l>191?2:1;if(i+h>n)break;1===h?l<128&&(u=l):2===h?128==(192&(o=t[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===h?(o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&((u=(15&l)<<12|(63&o)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===h&&(o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&((u=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,h=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=h}return r}(this.buf,e,t)},readBytes:function(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e},readPackedVarint:function(t,e){if(this.type!==li.Bytes)return t.push(this.readVarint(e));var n=fi(this);for(t=t||[];this.pos<n;)t.push(this.readVarint(e));return t},readPackedSVarint:function(t){if(this.type!==li.Bytes)return t.push(this.readSVarint());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==li.Bytes)return t.push(this.readBoolean());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==li.Bytes)return t.push(this.readFloat());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==li.Bytes)return t.push(this.readDouble());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==li.Bytes)return t.push(this.readFixed32());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==li.Bytes)return t.push(this.readSFixed32());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==li.Bytes)return t.push(this.readFixed64());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==li.Bytes)return t.push(this.readSFixed64());var e=fi(this);for(t=t||[];this.pos<e;)t.push(this.readSFixed64());return t},skip:function(t){var e=7&t;if(e===li.Varint)for(;this.buf[this.pos++]>127;);else if(e===li.Bytes)this.pos=this.readVarint()+this.pos;else if(e===li.Fixed32)this.pos+=4;else{if(e!==li.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(t,e){this.writeVarint(t<<3|e)},realloc:function(t){for(var e=this.length||16;e<this.pos+t;)e*=2;if(e!==this.length){var n=new Uint8Array(e);n.set(this.buf),this.buf=n,this.length=e}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),Ii(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),Ii(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),Ii(this.buf,-1&t,this.pos),Ii(this.buf,Math.floor(t*hi),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),Ii(this.buf,-1&t,this.pos),Ii(this.buf,Math.floor(t*hi),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,e){var n,r;t>=0?(n=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(n=~(-t%4294967296))?n=n+1|0:(n=0,r=r+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,n){n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos++]=127&t|128,t>>>=7,n.buf[n.pos]=127&t}(n,0,e),function(t,e){var n=(7&t)<<4;if(e.buf[e.pos++]|=n|((t>>>=3)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),!t)return;e.buf[e.pos++]=127&t}(r,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(t,e,n){for(var r,i,o=0;o<e.length;o++){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){r>56319||o+1===e.length?(t[n++]=239,t[n++]=191,t[n++]=189):i=r;continue}if(r<56320){t[n++]=239,t[n++]=191,t[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[n++]=239,t[n++]=191,t[n++]=189,i=null);r<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:(r<65536?t[n++]=r>>12|224:(t[n++]=r>>18|240,t[n++]=r>>12&63|128),t[n++]=r>>6&63|128),t[n++]=63&r|128)}return n}(this.buf,t,this.pos);var n=this.pos-e;n>=128&&di(e,n,this),this.pos=e-1,this.writeVarint(n),this.pos+=n},writeFloat:function(t){this.realloc(4),ai.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),ai.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var e=t.length;this.writeVarint(e),this.realloc(e);for(var n=0;n<e;n++)this.buf[this.pos++]=t[n]},writeRawMessage:function(t,e){this.pos++;var n=this.pos;t(e,this);var r=this.pos-n;r>=128&&di(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,e,n){this.writeTag(t,li.Bytes),this.writeRawMessage(e,n)},writePackedVarint:function(t,e){e.length&&this.writeMessage(t,gi,e)},writePackedSVarint:function(t,e){e.length&&this.writeMessage(t,yi,e)},writePackedBoolean:function(t,e){e.length&&this.writeMessage(t,vi,e)},writePackedFloat:function(t,e){e.length&&this.writeMessage(t,xi,e)},writePackedDouble:function(t,e){e.length&&this.writeMessage(t,mi,e)},writePackedFixed32:function(t,e){e.length&&this.writeMessage(t,wi,e)},writePackedSFixed32:function(t,e){e.length&&this.writeMessage(t,bi,e)},writePackedFixed64:function(t,e){e.length&&this.writeMessage(t,Mi,e)},writePackedSFixed64:function(t,e){e.length&&this.writeMessage(t,Pi,e)},writeBytesField:function(t,e){this.writeTag(t,li.Bytes),this.writeBytes(e)},writeFixed32Field:function(t,e){this.writeTag(t,li.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(t,e){this.writeTag(t,li.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(t,e){this.writeTag(t,li.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(t,e){this.writeTag(t,li.Fixed64),this.writeSFixed64(e)},writeVarintField:function(t,e){this.writeTag(t,li.Varint),this.writeVarint(e)},writeSVarintField:function(t,e){this.writeTag(t,li.Varint),this.writeSVarint(e)},writeStringField:function(t,e){this.writeTag(t,li.Bytes),this.writeString(e)},writeFloatField:function(t,e){this.writeTag(t,li.Fixed32),this.writeFloat(e)},writeDoubleField:function(t,e){this.writeTag(t,li.Fixed64),this.writeDouble(e)},writeBooleanField:function(t,e){this.writeVarintField(t,Boolean(e))}};var Si=yr(si),Ti=Fi;function Fi(t,e){this.x=t,this.y=e}Fi.prototype={clone:function(){return new Fi(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,n=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=n,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),n=Math.sin(t),r=e*this.x-n*this.y,i=n*this.x+e*this.y;return this.x=r,this.y=i,this},_rotateAround:function(t,e){var n=Math.cos(t),r=Math.sin(t),i=e.x+n*(this.x-e.x)-r*(this.y-e.y),o=e.y+r*(this.x-e.x)+n*(this.y-e.y);return this.x=i,this.y=o,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Fi.convert=function(t){return t instanceof Fi?t:Array.isArray(t)?new Fi(t[0],t[1]):t};var ki=Ti,Bi=Li;function Li(t,e,n,r,i){this.properties={},this.extent=n,this.type=0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=i,t.readFields(Ci,this,e)}function Ci(t,e,n){1==t?e.id=n.readVarint():2==t?function(t,e){var n=t.readVarint()+t.pos;for(;t.pos<n;){var r=e._keys[t.readVarint()],i=e._values[t.readVarint()];e.properties[r]=i}}(n,e):3==t?e.type=n.readVarint():4==t&&(e._geometry=n.pos)}function Yi(t){for(var e,n,r=0,i=0,o=t.length,s=o-1;i<o;s=i++)e=t[i],r+=((n=t[s]).x-e.x)*(e.y+n.y);return r}Li.types=["Unknown","Point","LineString","Polygon"],Li.prototype.loadGeometry=function(){var t=this._pbf;t.pos=this._geometry;for(var e,n=t.readVarint()+t.pos,r=1,i=0,o=0,s=0,a=[];t.pos<n;){if(i<=0){var l=t.readVarint();r=7&l,i=l>>3}if(i--,1===r||2===r)o+=t.readSVarint(),s+=t.readSVarint(),1===r&&(e&&a.push(e),e=[]),e.push(new ki(o,s));else{if(7!==r)throw new Error("unknown command "+r);e&&e.push(e[0].clone())}}return e&&a.push(e),a},Li.prototype.bbox=function(){var t=this._pbf;t.pos=this._geometry;for(var e=t.readVarint()+t.pos,n=1,r=0,i=0,o=0,s=1/0,a=-1/0,l=1/0,u=-1/0;t.pos<e;){if(r<=0){var h=t.readVarint();n=7&h,r=h>>3}if(r--,1===n||2===n)(i+=t.readSVarint())<s&&(s=i),i>a&&(a=i),(o+=t.readSVarint())<l&&(l=o),o>u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[s,l,a,u]},Li.prototype.toGeoJSON=function(t,e,n){var r,i,o=this.extent*Math.pow(2,n),s=this.extent*t,a=this.extent*e,l=this.loadGeometry(),u=Li.types[this.type];function h(t){for(var e=0;e<t.length;e++){var n=t[e],r=180-360*(n.y+a)/o;t[e]=[360*(n.x+s)/o-180,360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90]}}switch(this.type){case 1:var c=[];for(r=0;r<l.length;r++)c[r]=l[r][0];h(l=c);break;case 2:for(r=0;r<l.length;r++)h(l[r]);break;case 3:for(l=function(t){var e=t.length;if(e<=1)return[t];for(var n,r,i=[],o=0;o<e;o++){var s=Yi(t[o]);0!==s&&(void 0===r&&(r=s<0),r===s<0?(n&&i.push(n),n=[t[o]]):n.push(t[o]))}n&&i.push(n);return i}(l),r=0;r<l.length;r++)for(i=0;i<l[r].length;i++)h(l[r][i])}1===l.length?l=l[0]:u="Multi"+u;var f={type:"Feature",geometry:{type:u,coordinates:l},properties:this.properties};return"id"in this&&(f.id=this.id),f};var Vi=Bi,Oi=Xi;function Xi(t,e){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ni,this,e),this.length=this._features.length}function Ni(t,e,n){15===t?e.version=n.readVarint():1===t?e.name=n.readString():5===t?e.extent=n.readVarint():2===t?e._features.push(n.pos):3===t?e._keys.push(n.readString()):4===t&&e._values.push(function(t){var e=null,n=t.readVarint()+t.pos;for(;t.pos<n;){var r=t.readVarint()>>3;e=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return e}(n))}Xi.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 Vi(this._pbf,e,this.extent,this._keys,this._values)};var Ei=Oi,zi=function(t,e){this.layers=t.readFields(Di,{},e)};function Di(t,e,n){if(3===t){var r=new Ei(n,n.readVarint()+n.pos);r.length&&(e[r.name]=r)}}var $i=zi;const qi=2,ji=new TextDecoder("utf-8");class Gi extends kn{constructor(t,e,n,r,i,o){super(t,e,n,r,i),e=e||{},o()}clearData(){this._abortRequests()}getTileFeatures(t,e){const n=t.tileInfo.url,r=t.fetchOptions||{},{altitudePropertyName:i,disableAltitudeWarning:o}=t,s=this._cache.get(n);if(s&&s.cacheIndex===t.workerCacheIndex){const{err:t,data:r}=s;return setTimeout((()=>{this._readTile(n,i,o,t,r,e)}),1)}const{tileArrayBuffer:a}=t;return a?setTimeout((()=>{this._readTile(n,i,o,null,a,e)}),1):(r.referrer=t.referrer,C.getArrayBuffer(n,r,((r,s)=>{this._cache&&(r?r.loading||this._cache.add(n,{err:r,data:s&&s.data,cacheIndex:t.workerCacheIndex}):s&&s.data&&this._cache.add(n,{err:null,data:s.data,cacheIndex:t.workerCacheIndex}),this._readTile(n,i,o,r,s&&s.data,e))})))}_readTile(t,e,n,r,i,o){if(r)return void o(r);let s;try{s=new $i(new Si(i))}catch(r){const e=ji.decode(i);return r.message+="\\n"+t+"\\n"+e,void o(r.message,[],[])}const a=[];if(!s.layers)return void o(null,a,[]);const l={};let u;for(const t in s.layers)if(h=s.layers,c=t,Object.prototype.hasOwnProperty.call(h,c)){l[t]={types:{}};const i=l[t].types;for(let o=0,l=s.layers[t].length;o<l;o++)try{u=s.layers[t].feature(o),i[u.type]=1;const r={type:u.type,layer:t,geometry:u.loadGeometry(),properties:u.properties,extent:u.extent};void 0!==u.id&&(r.id=u.id);let l=r.properties[ee];l&&(A(l)&&(l=JSON.parse(l)),r.properties[ee]=ei(l,"EPSG:3857"));const h=e&&r.properties[e];if(h){const t=Zi(h),e=[];Ui(r.geometry,t,e),e.length&&!n&&(console.warn("feature.geometry is not consistent with altitude values:"),console.warn(JSON.stringify(r,null,2)))}a.push(r)}catch(r){console.warn("error when load vt geometry:",r)}}var h,c;for(const t in l)l[t].types=Object.keys(l[t].types).map((t=>+t));o(null,a,l,{byteLength:i.byteLength})}abortTile(t,e){const n=this.requests[t];delete this.requests[t],n&&n.abort&&n.abort(),this._cancelLoadings(t),e()}onRemove(){super.onRemove(),this._abortRequests()}_abortRequests(){for(const t in this.requests){const e=this.requests[t];e&&e.abort&&e.abort()}this.requests={}}}function Zi(t){const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return new Float32Array(n.buffer)}function Ui(t,e,n,r){r||(r={index:0});for(let i=0;i<t.length;i++)if(Array.isArray(t[i]))Ui(t[i],e,n,r);else{const o=r.index;k(e[o])?n.push(qi):t[i].z=100*e[o],r.index++}}const{LRUCache:Ri}=ne();let Ji=0;const Hi=new Ri(128);class Wi{constructor(t){this._layers={},this._callbacks={},this.workerId=t}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this._getLayerById(e,n))return;const o=this._genKey(e,n),s=r.type,a=r.options,l=this.send.bind(this,t);this._layers[o]="GeoJSONVectorTileLayer"===s?new ri(n,a,l,Hi,{},i):new Gi(n,a,l,Hi,{},i)}removeLayer({mapId:t,layerId:e},n){const r=this._getLayerById(t,e),i=this._genKey(t,e);delete this._layers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.loadTile(n,r)}abortTile({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.abortTile&&i.abortTile(n.url,r)}removeTile({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.removeTile(n,r)}updateStyle({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.updateStyle(n,r)}updateOptions({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.updateOptions(n,r)}setData({mapId:t,layerId:e,params:n},r){const i=this._getLayerById(t,e);i&&i.setData(n.data,r)}clearData({mapId:t,layerId:e},n){const r=this._getLayerById(t,e);r&&(r.clearData(n),this._resetCache())}receive(t){const e=t.callback,n=this._callbacks[e];delete this._callbacks[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,i){const o=i?\`${s}t}-${s}Ji++}\`:null;i&&(this._callbacks[o]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}_genKey(t,e){return\`${s}t}-${s}e}\`}_getLayerById(t,e){const n=this._genKey(t,e);return this._layers[n]}_resetCache(){Hi.reset()}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;if(this.dispatcher||(this.dispatcher=new Wi(t.workerId)),"<response>"===t.type)this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t);else{const r=n.command;this.dispatcher[r]({actorId:t.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,i)=>{t&&404!==t.status&&204!==t.status&&!t.loading&&console.error(r,t),e(t,n,i)}))}}}`;
25
25
  function l(e) {
26
26
  const t = function() {
27
27
  return "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof window ? window : "undefined" != typeof global ? global : void 0;
@@ -9987,6 +9987,14 @@
9987
9987
  };
9988
9988
  this.send(i, null, t, this._dedicatedVTWorkers[n]);
9989
9989
  }
9990
+ clearData(e) {
9991
+ const t = this._workerLayerId, n = {
9992
+ mapId: this._mapId,
9993
+ layerId: t,
9994
+ command: "clearData"
9995
+ };
9996
+ this.send(n, null, e, this._dedicatedVTWorkers[t]);
9997
+ }
9990
9998
  _getTileKey(e) {
9991
9999
  return e.id;
9992
10000
  }
@@ -10343,6 +10351,14 @@
10343
10351
  getStyleCounter() {
10344
10352
  return this._styleCounter;
10345
10353
  }
10354
+ clearData() {
10355
+ this.clear(), this._workerConn ? (this._workersyncing = !0, this._workerConn.clearData((() => {
10356
+ this._workersyncing = !1, this._needRetire = !0, this.setToRedraw(), this.layer.fire("cleardata");
10357
+ }))) : this.layer.fire("cleardata");
10358
+ }
10359
+ clear() {
10360
+ this.clearTileCaches(), super.clear();
10361
+ }
10346
10362
  setStyle() {
10347
10363
  if (this._groundPainter && this._groundPainter.update(), this._workerConn) {
10348
10364
  this._styleCounter++, this._preservePrevTiles();
@@ -12015,6 +12031,10 @@
12015
12031
  onRemove() {
12016
12032
  super.onRemove();
12017
12033
  }
12034
+ clear() {
12035
+ const e = this.getRenderer();
12036
+ return e && e.clearData(), super.clear();
12037
+ }
12018
12038
  static fromJSON(e) {
12019
12039
  return e && "VectorTileLayer" === e.type ? new rn(e.id, e.options) : null;
12020
12040
  }
@@ -13597,6 +13617,7 @@
13597
13617
  this._outlineShaders = [];
13598
13618
  for (let t = 0; t < this.picking.length; t++) {
13599
13619
  const i = this.picking[t].getPickingVert(), r = this.picking[t].getPickingWGSLVert(), o = {
13620
+ PICKING_MODE: 1,
13600
13621
  ENABLE_PICKING: 1,
13601
13622
  HAS_PICKING_ID: 1
13602
13623
  }, s = this.picking[t].getUniformDeclares().slice(0);
@@ -22646,6 +22667,6 @@
22646
22667
  e.TerrainFlatMaskPainter = Tl, e.TerrainFlatMaskPlugin = zl, e.TextPainter = Ks,
22647
22668
  e.TextPlugin = Il, e.TubePlugin = Fl, e.Vector3DLayer = un, e.VectorTileLayer = rn,
22648
22669
  e.VectorTileLayerRenderer = jt, e.WaterPlugin = Ll, e.WireframePainter = Sa, e.WireframePlugin = kl,
22649
- "undefined" != typeof console && console.log("@maptalks/vt v0.108.1");
22670
+ "undefined" != typeof console && console.log("@maptalks/vt v0.108.3");
22650
22671
  }));
22651
22672
  //# sourceMappingURL=maptalks.vt.js.map