(function(r){const e={},t={};function s(o,p,d){if(t[o]=d,o==="index"){var i="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);";typeof exports=="object"&&typeof module=="object"?module.exports=e:typeof exports=="object"?exports.mapgl=e:r.mapgl=e;var n={};return t.shared(n),t.index(e,n),typeof window<"u"&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([i],{type:"text/javascript"}))),typeof System=="object"&&typeof System.register=="function"&&System.register([],f=>(f(e),{execute:function(){}})),e}}r._mapgl_d=s})(self);

_mapgl_d("shared",["exports"],(function(m){var n_=Object.defineProperty,i_=Object.defineProperties;var s_=Object.getOwnPropertyDescriptors;var pa=Object.getOwnPropertySymbols;var Rm=Object.prototype.hasOwnProperty,Nm=Object.prototype.propertyIsEnumerable;var re=Math.pow,Cm=(m,He,ze)=>He in m?n_(m,He,{enumerable:!0,configurable:!0,writable:!0,value:ze}):m[He]=ze,ue=(m,He)=>{for(var ze in He||(He={}))Rm.call(He,ze)&&Cm(m,ze,He[ze]);if(pa)for(var ze of pa(He))Nm.call(He,ze)&&Cm(m,ze,He[ze]);return m},ve=(m,He)=>i_(m,s_(He));var km=(m,He)=>{var ze={};for(var vt in m)Rm.call(m,vt)&&He.indexOf(vt)<0&&(ze[vt]=m[vt]);if(m!=null&&pa)for(var vt of pa(m))He.indexOf(vt)<0&&Nm.call(m,vt)&&(ze[vt]=m[vt]);return ze};var Le=(m,He,ze)=>new Promise((vt,fr)=>{var ma=an=>{try{as(ze.next(an))}catch(cs){fr(cs)}},ya=an=>{try{as(ze.throw(an))}catch(cs){fr(cs)}},as=an=>an.done?vt(an.value):Promise.resolve(an.value).then(ma,ya);as((ze=ze.apply(m,He)).next())});"use strict";const He="tile{subdomain}.maps.2gis.com",ze="jam.api.2gis.com",vt="https://styles.api.2gis.com",fr="https://disk.2gis.com/styles/assets/icons",ma="https://disk.2gis.com/styles/assets/models",ya="https://mapgl.2gis.com/api/fonts",as="https://keys.api.2gis.com/public/v1/keys/{keyID}/services/mapgl-js-api",an="https://mapgl.2gis.com/api/js/plugins/rtl-v1.1.1.js",cs="sha512-IyuCqmcNBfZyrExDMisGi0Xhp4PXupx6AMp4cjpKcAzJo+kSmOtRTLbL1xZsfxnsIqci9Q0piqY+kcwl1hCPyw==",Um="https://mapgl.2gis.com/api/js/plugins",zm=107.17318798131565,ls=re(2,20),te=re(2,15),Ge=re(2,16)-1,Pi=te/Ge,z=16383,Pd=2.54,ds=96,Ld=4294967296/(256/ds*Pd),Ne=.7071067811865475,Gm=4294967295,jm=1175494351e-47,Vm=3402823466e29,hr=["Arial","Helvetica","HelveticaNeueCyr","Open_Sans","Open_Sans_Semibold","Open_Sans_Italic","Segoe_UI","PT_Sans_Caption","PT_Sans","Verdana","Verdana_bold","Noto_Sans","Noto_Sans_Semibold","Noto_Sans_Italic","SuisseIntl_Bold"],Li="Noto_Sans",Dd=1/2,Od=-4,ga=2147483647,Hm="c080bb6a-8134-4993-93a1-5b4d8c36a59b",$m=5,pr=4,wa=40,Ym=65e3,Fd="byModel",Wm=65536,Zm=512,Cd="empty",va={minZoom:2,maxZoom:20},Kn={protocol:"https",server:He,subdomains:"0123",tileSet:"vector_a",tileKey:Cd,appId:"empty",cacheRatio:2,maxUniverseZoom:8,maxRegionalZoom:15,maxDetailLevel:17},ba={minZoom:10,maxZoom:14,tileSet:"com_poi_web",rasterSizes:[96,84,72,60,48,36,24]},Rd={minZoom:15,maxZoom:15,tileSet:"vector_immersive"},Nd={tileSet:"dem"},kd=100,Ia=13.5,cn=[2048,2048],mr={tiles:"{protocol}://{host}/vt?r={request}&ts={tileSet}&key={tileKey}&appId={appId}&lang={lang}&default_lang={defaultLang}&s={sessionId}&dt={dt}",metatile:"{protocol}://{host}/metafiles/{hash}/metatile.json?ts={tileSet}",modelInfo:"{protocol}://{host}/metafiles/{regionId}/models.json?ts={tileSet}",model:"{protocol}://{host}/metafiles/{regionId}/{name}?ts={tileSet}",gltfModel:"{protocol}://{host}/metafiles/{modelSrc}?ts={tileSet}",convertData:"{protocol}://{host}/metafiles/{hash}/convert.json?ts={tileSet}",dynamicPoi:"{protocol}://{host}/metafiles/{regionId}/poi/{id}_{width}_{height}.png?ts={tileSet}",models:"{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}",commercialPoi:"{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",floorMeta:"{protocol}://{host}/metafiles/{regionId}/{floorComplexId}.json?ts={tileSet}"},Bd={protocol:"https",host:ze,url:"{protocol}://{host}/tiles?tls={tiles}&reg={regions}&tm={time}&fmt=json&z={z}",timestampUrl:"{protocol}://{host}/meta?reg={regions}&time&score",updateInterval:120*1e3,minZoom:10,maxZoom:16,maxDetailLevel:17,fetchMetaRetryDelays:[2,5,25].map(e=>e*1e3)},Ut={defaultUrl:ya,gamma:.08,baseSize:24,baseLineHeight:1.2,bomCharCode:65279},Ud={defaultUrl:fr},zd={url:vt,path:"styles/{id}"},Gd={doubleClickTime:185,dragThreshold:2,pitchWaitingTime:200,pitchThreshold:7},jd=1e3,us={inAnimationTime:180,inAnimationType:"linear",outAnimationTime:800,outAnimationType:"linear"},Ma={time:300,type:"linear"},Vd={minStyleZoom:16,duration:500,easing:"easeOutQuint"},Hd={bounceType:"easeOutElastic",bounceTime:1200,growType:"easeInOutQuad",growTime:1200,stagger:0,iterationCount:1/0},Ta={pixelDensity:.5,sceneOpacity:0,cacheRefreshTime:300,pickDistance:3},yr={interval:220,animationTime:200,animationType:"linear",tileMultiplier:1.5,axisAngleToleranceDeg:45,axisCheckDistancePx:13,commercialMargins:{default:{topBottom:60,leftRight:60},city:{topBottom:500,leftRight:500}},lineLabelsHidePitchDeg:40,maxLabelLength:30},$d={0:yr.commercialMargins.city,11:{topBottom:250,leftRight:250},12:{topBottom:170,leftRight:170}},Yd={alwaysRerender:!1,autoResizeInterval:50},Wd="en",Zd={macWheelDeltaToZoomDelta:.0018,notMacTrackpadDeltaToZoomDelta:.0018*3,wheelZoomDelta:.65,animDuration:400,throttleDelay:100,mouseRotateDelta:2.5,mousePitchDelta:2.5,mobilePinchDelta:1,mobileTapDelta:10},Sa={duration:1300,maxSpeed:8,minSpeed:.02,nonLinearity:5},zt={fov:60*Math.PI/180,useDynamicNearFar:!1,near:1e3,far:re(2,34),viewportLimitRatio:2.1,minTrapezeHeight:2*131072,perspectiveDistanceLimitRatio:10,minFogDistance:2e4,fogHorizonPadFactor:.15,pitchInterStartZoom:17,pitchInterEndZoom:19},_n={globeMaxZoom:8,globeInterStartZoom:7,globeInterEndZoom:16},Xd=1e3,qd=16,Aa={enabled:!0,displayStyleZoom:{default:18,metro:16},detailLevel:16,wallMinBrightness:.8265,wallMaxBrightness:.95,viewportPadding:.2,maxStackHeight:40},Jd={fpsCaveat:10},Kd=3e4,Ea=["Commercial_poi_city"],xa=["Commercial_poi_premium"],Qd=["Commercial_poi_default","Commercial_poi_custom","Commercial_poi_navi",...Ea,...xa],eu=["Commercial_model","Commercial_model_animated","Commercial_model_on_click"],tu=["s_personal_poi"],nu=["Landmark_poi","Landmark_point"],iu=[105,84,63,42,21],su="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",ru=[15,46],ou=16,au={bias:100,textureSize:[2048,2048],shadowRadius:3},Xm=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIN_TIERS_STYLE_ZOOM:ou,MAP_DEFAULTS:va,atlasSize:cn,buildingAnimation:Vd,cityCommPoiLabelingConfig:$d,commercialCitySublayers:Ea,commercialModelSublayers:eu,commercialPoi:ba,commercialPremiumSublayers:xa,commercialSublayers:Qd,defaultCameraConfig:zt,defaultLang:Wd,defaultMarkerAnchor:ru,defaultMarkerIcon:su,defaultShadowsSettings:au,dem:Nd,entranceAnimation:Hd,events:Gd,floors:Aa,fonts:Ut,globeConfig:_n,houseHover:us,icons:Ud,identify:Ta,inertia:Sa,labeling:yr,landmarkPoiSublayers:nu,landmarkRasterSizes:iu,loadModelsInfoStyleZoom:Ia,maxZoomForDynamicNear:qd,metricsTimeout:Kd,minCalculationScreenHeight:Xd,modelCacheSize:kd,models:Rd,performanceCheck:Jd,personalSublayers:tu,render:Yd,styles:zd,tileAnimation:Ma,tiles:Kn,traffic:Bd,urls:mr,workerResetInterval:jd,zoom:Zd},Symbol.toStringTag,{value:"Module"}));function Te(e,t,n){return e=Math.max(e,t),e=Math.min(e,n),e}function gr(e){return e===0||Number.isNaN(e)?e:e>0?1:-1}function qm(e,t){return[t[0]/e[0]*2-1,-(t[1]/e[1])*2+1]}function be(e){return e*Math.PI/180}function Qn(e){return e/Math.PI*180}function cu(e){return e=e>>>0,e=e-1,e=e|e>>1,e=e|e>>2,e=e|e>>4,e=e|e>>8,e=e|e>>16,e+1}function Pn(e,t){const n=ue({},t);for(const i in e)e[i]!==void 0&&(n[i]=e[i]);return n}function _a(e){const t={};for(const n in e){const i=e[n];t[i]=n}return t}function lu(e,t){const n=[];for(const i in e)t[i]||n.push(e[i]);return n}function Pa(e,t,n){return Te((n-e)/(t-e),0,1)}function Jm(e){return e%1}function La(e,t,n){return e>=t&&e<=n}function Km(e,t){if(e.size!==t.size)return!1;for(const n of Array.from(e))if(!t.has(n))return!1;return!0}function Qm(e,t){return e===t?!0:e.length!==t.length?!1:!e.some((n,i)=>n!==t[i])}function Di(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){const n=Array.isArray(e),i=Array.isArray(t);let s,r,o;if(n&&i){if(r=e.length,r!==t.length)return!1;for(s=r;s--!==0;)if(!Di(e[s],t[s]))return!1;return!0}if(n!==i)return!1;const a=e instanceof Date,c=t instanceof Date;if(a!==c)return!1;if(a&&c)return e.getTime()===t.getTime();const l=e instanceof RegExp,d=t instanceof RegExp;if(l!==d)return!1;if(l&&d)return e.toString()===t.toString();const u=Object.keys(e);if(r=u.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,u[s]))return!1;for(s=r;s--!==0;)if(o=u[s],!Di(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function e1(e,t){const n=e.indexOf(t);return n!==-1?(e.splice(n,1),!0):!1}function Oi(e,t,n){return e+(t-e)*n}function t1(e){return e==null}function wr(e,t){const n=t;typeof e=="number"?n.fill(e):Array.isArray(e)&&typeof e[0]=="number"&&typeof e[1]=="number"&&typeof e[2]=="number"&&(n[0]=e[0],n[1]=e[1],n[2]=e[2])}class du{constructor(t,n){this.getNewValidFor=n,this.getNewValue=t,this.currentValue=NaN,this.currentValidFor=new Array(n().length).fill(NaN)}get value(){const t=this.getNewValidFor();return this.currentValidFor.some((i,s)=>i!==t[s])&&(this.currentValidFor=t,this.currentValue=this.getNewValue()),this.currentValue}}function n1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function uu(e){const t=Te((e>>24&255)/255,0,1),n=Te((e>>16&255)/255,0,1),i=Te((e>>8&255)/255,0,1),s=Te((e&255)/255,0,1);return[t,n,i,s]}const bt=1e-6;let It=typeof Float64Array!="undefined"?Float64Array:Array;function Fe(){let e=new It(2);return e[0]=0,e[1]=0,e}function i1(e){let t=new It(2);return t[0]=e[0],t[1]=e[1],t}function Da(e,t){let n=new It(2);return n[0]=e,n[1]=t,n}function vr(e,t){return e[0]=t[0],e[1]=t[1],e}function je(e,t,n){return e[0]=t,e[1]=n,e}function Gt(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Oa(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function s1(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function r1(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e}function xt(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function fs(e,t){var n=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(n*n+i*i)}function br(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)}function o1(e){var t=e[0],n=e[1];return t*t+n*n}function Ln(e,t){var n=t[0],i=t[1],s=n*n+i*i;return s>0&&(s=1/Math.sqrt(s),e[0]=t[0]*s,e[1]=t[1]*s),e}function Dn(e,t){return e[0]*t[0]+e[1]*t[1]}function fu(e,t,n,i){var s=t[0],r=t[1];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e}function Ir(e,t){return e[0]===t[0]&&e[1]===t[1]}function a1(e,t){let n=e[0],i=e[1],s=t[0],r=t[1];return Math.abs(n-s)<=bt*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-r)<=bt*Math.max(1,Math.abs(i),Math.abs(r))}const hu=br,ln=Oa,On=fs;(function(){let e=Fe();return function(t,n,i,s,r,o){let a,c;for(n||(n=2),i||(i=0),s?c=Math.min(s*n+i,t.length):c=t.length,a=i;a<c;a+=n)e[0]=t[a],e[1]=t[a+1],r(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();function pu(){let e=new It(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function c1(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function l1(e,t,n,i,s,r,o,a,c,l,d,u,f,h,g,w){let p=new It(16);return p[0]=e,p[1]=t,p[2]=n,p[3]=i,p[4]=s,p[5]=r,p[6]=o,p[7]=a,p[8]=c,p[9]=l,p[10]=d,p[11]=u,p[12]=f,p[13]=h,p[14]=g,p[15]=w,p}function d1(e,t,n,i,s,r,o,a,c,l,d,u,f,h,g,w,p){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e[4]=r,e[5]=o,e[6]=a,e[7]=c,e[8]=l,e[9]=d,e[10]=u,e[11]=f,e[12]=h,e[13]=g,e[14]=w,e[15]=p,e}function Fa(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function u1(e,t){if(e===t){let n=t[1],i=t[2],s=t[3],r=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=i,e[9]=r,e[11]=t[14],e[12]=s,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function hs(e,t){let n=t[0],i=t[1],s=t[2],r=t[3],o=t[4],a=t[5],c=t[6],l=t[7],d=t[8],u=t[9],f=t[10],h=t[11],g=t[12],w=t[13],p=t[14],y=t[15],b=n*a-i*o,v=n*c-s*o,T=n*l-r*o,E=i*c-s*a,S=i*l-r*a,L=s*l-r*c,x=d*w-u*g,O=d*p-f*g,B=d*y-h*g,U=u*p-f*w,j=u*y-h*w,M=f*y-h*p,I=b*M-v*j+T*U+E*B-S*O+L*x;return I?(I=1/I,e[0]=(a*M-c*j+l*U)*I,e[1]=(s*j-i*M-r*U)*I,e[2]=(w*L-p*S+y*E)*I,e[3]=(f*S-u*L-h*E)*I,e[4]=(c*B-o*M-l*O)*I,e[5]=(n*M-s*B+r*O)*I,e[6]=(p*T-g*L-y*v)*I,e[7]=(d*L-f*T+h*v)*I,e[8]=(o*j-a*B+l*x)*I,e[9]=(i*B-n*j-r*x)*I,e[10]=(g*S-w*T+y*b)*I,e[11]=(u*T-d*S-h*b)*I,e[12]=(a*O-o*U-c*x)*I,e[13]=(n*U-i*O+s*x)*I,e[14]=(w*v-g*E-p*b)*I,e[15]=(d*E-u*v+f*b)*I,e):null}function Ca(e,t,n){let i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],c=t[5],l=t[6],d=t[7],u=t[8],f=t[9],h=t[10],g=t[11],w=t[12],p=t[13],y=t[14],b=t[15],v=n[0],T=n[1],E=n[2],S=n[3];return e[0]=v*i+T*a+E*u+S*w,e[1]=v*s+T*c+E*f+S*p,e[2]=v*r+T*l+E*h+S*y,e[3]=v*o+T*d+E*g+S*b,v=n[4],T=n[5],E=n[6],S=n[7],e[4]=v*i+T*a+E*u+S*w,e[5]=v*s+T*c+E*f+S*p,e[6]=v*r+T*l+E*h+S*y,e[7]=v*o+T*d+E*g+S*b,v=n[8],T=n[9],E=n[10],S=n[11],e[8]=v*i+T*a+E*u+S*w,e[9]=v*s+T*c+E*f+S*p,e[10]=v*r+T*l+E*h+S*y,e[11]=v*o+T*d+E*g+S*b,v=n[12],T=n[13],E=n[14],S=n[15],e[12]=v*i+T*a+E*u+S*w,e[13]=v*s+T*c+E*f+S*p,e[14]=v*r+T*l+E*h+S*y,e[15]=v*o+T*d+E*g+S*b,e}function mu(e,t,n){let i=n[0],s=n[1],r=n[2],o,a,c,l,d,u,f,h,g,w,p,y;return t===e?(e[12]=t[0]*i+t[4]*s+t[8]*r+t[12],e[13]=t[1]*i+t[5]*s+t[9]*r+t[13],e[14]=t[2]*i+t[6]*s+t[10]*r+t[14],e[15]=t[3]*i+t[7]*s+t[11]*r+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],d=t[4],u=t[5],f=t[6],h=t[7],g=t[8],w=t[9],p=t[10],y=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=d,e[5]=u,e[6]=f,e[7]=h,e[8]=g,e[9]=w,e[10]=p,e[11]=y,e[12]=o*i+d*s+g*r+t[12],e[13]=a*i+u*s+w*r+t[13],e[14]=c*i+f*s+p*r+t[14],e[15]=l*i+h*s+y*r+t[15]),e}function Fi(e,t,n){let i=n[0],s=n[1],r=n[2];return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Ra(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[4],o=t[5],a=t[6],c=t[7],l=t[8],d=t[9],u=t[10],f=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=r*s+l*i,e[5]=o*s+d*i,e[6]=a*s+u*i,e[7]=c*s+f*i,e[8]=l*s-r*i,e[9]=d*s-o*i,e[10]=u*s-a*i,e[11]=f*s-c*i,e}function yu(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],c=t[3],l=t[8],d=t[9],u=t[10],f=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=r*s-l*i,e[1]=o*s-d*i,e[2]=a*s-u*i,e[3]=c*s-f*i,e[8]=r*i+l*s,e[9]=o*i+d*s,e[10]=a*i+u*s,e[11]=c*i+f*s,e}function Mr(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],c=t[3],l=t[4],d=t[5],u=t[6],f=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=r*s+l*i,e[1]=o*s+d*i,e[2]=a*s+u*i,e[3]=c*s+f*i,e[4]=l*s-r*i,e[5]=d*s-o*i,e[6]=u*s-a*i,e[7]=f*s-c*i,e}function f1(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function gu(e,t,n){let i=n[0],s=n[1],r=n[2],o=Math.sqrt(i*i+s*s+r*r),a,c,l;return Math.abs(o)<bt?null:(o=1/o,i*=o,s*=o,r*=o,a=Math.sin(t),c=Math.cos(t),l=1-c,e[0]=i*i*l+c,e[1]=s*i*l+r*a,e[2]=r*i*l-s*a,e[3]=0,e[4]=i*s*l-r*a,e[5]=s*s*l+c,e[6]=r*s*l+i*a,e[7]=0,e[8]=i*r*l+s*a,e[9]=s*r*l-i*a,e[10]=r*r*l+c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function h1(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],c=s+s,l=r+r,d=o+o,u=s*c,f=s*l,h=s*d,g=r*l,w=r*d,p=o*d,y=a*c,b=a*l,v=a*d,T=i[0],E=i[1],S=i[2];return e[0]=(1-(g+p))*T,e[1]=(f+v)*T,e[2]=(h-b)*T,e[3]=0,e[4]=(f-v)*E,e[5]=(1-(u+p))*E,e[6]=(w+y)*E,e[7]=0,e[8]=(h+b)*S,e[9]=(w-y)*S,e[10]=(1-(u+g))*S,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function p1(e,t,n,i,s,r,o){let a=1/(t-n),c=1/(i-s),l=1/(r-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+n)*a,e[13]=(s+i)*c,e[14]=(o+r)*l,e[15]=1,e}function Na(e,t,n,i){let s,r,o,a,c,l,d,u,f,h,g=t[0],w=t[1],p=t[2],y=i[0],b=i[1],v=i[2],T=n[0],E=n[1],S=n[2];return Math.abs(g-T)<bt&&Math.abs(w-E)<bt&&Math.abs(p-S)<bt?mat4.identity(e):(d=g-T,u=w-E,f=p-S,h=1/Math.sqrt(d*d+u*u+f*f),d*=h,u*=h,f*=h,s=b*f-v*u,r=v*d-y*f,o=y*u-b*d,h=Math.sqrt(s*s+r*r+o*o),h?(h=1/h,s*=h,r*=h,o*=h):(s=0,r=0,o=0),a=u*o-f*r,c=f*s-d*o,l=d*r-u*s,h=Math.sqrt(a*a+c*c+l*l),h?(h=1/h,a*=h,c*=h,l*=h):(a=0,c=0,l=0),e[0]=s,e[1]=a,e[2]=d,e[3]=0,e[4]=r,e[5]=c,e[6]=u,e[7]=0,e[8]=o,e[9]=l,e[10]=f,e[11]=0,e[12]=-(s*g+r*w+o*p),e[13]=-(a*g+c*w+l*p),e[14]=-(d*g+u*w+f*p),e[15]=1,e)}function m1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}const Ci=Ca;function Tr(e,t,n){return e[0]=n[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=n[2],e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}const wu=6378137,ka=2*Math.PI*wu,Ie=4294967296/ka,y1=Tr([],[-1,-1,0],[2,2,1]),g1=Tr([],[.5,.5,0],[.5,.5,1]),ei=wu*(Math.PI/2),ot=re(2,15)/4294967296;function Ba(e){return Math.max(e,Xd)}function Ri(e,t){const n=zt,i=Ba(t[1])/2,s=4294967296/re(2,e),r=i/256*s,o=Math.tan(n.fov/2);return r/o}function w1(e,t){const n=zt;return Math.log(Ba(t[1])*4294967296/(2*256*Math.tan(n.fov/2)*e))/Math.LN2}function v1(e){return Ld*Math.pow(2,-e)}function b1(e,t){return re(2,Math.round(e)-t.coords[2])}function I1(e,t){return Pd*(e/ds)/t}function Ua(e,t){const i=Math.PI/180,s=e[1]*i,r=t[1]*i,o=Math.sin((t[1]-e[1])*i/2),a=Math.sin((t[0]-e[0])*i/2),c=o*o+Math.cos(s)*Math.cos(r)*a*a,l=2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c));return Math.round(6371e3*l)}function M1(e){let t=0;if(e.length>1)for(let n=0;n<e.length-1;n++)t+=Ua(e[n],e[n+1]);return t}const T1={min:[-2147483648,-2147483648],max:[4294967296/2,4294967296/2]},S1={min:[-214748364800,-2147483648],max:[4294967296*100/2,4294967296/2]};function ps(e){let i=e[0];if(i>=-2147483648&&i<=2147483648)return;const s=4294967296;i=((i- -2147483648)%s+s)%s+-2147483648,e[0]=i}function vu(e,t){return e*Math.pow(2,-t)*4294967296/256}function A1(e,t){return e*Math.pow(2,t)*256/4294967296}function bu(e,t){return e===0?-1/0:-Math.log(t*256/(e*4294967296))/Math.LN2}const za=Fe(),Iu=Fe();function E1(e,t,n){Oa(za,n,e),Oa(Iu,t,e);const i=Dn(za,Iu)/br(za);return Math.atan2(i,e[2])}function x1(e){const t=e[0],n=e[1];return La(t,-2147483648,2147483648)&&La(n,-2147483648,2147483648)}function _1(e){const t=[...e];return x1(t)||(t[0]=(4294967296+(t[0]+2147483648)%4294967296)%4294967296-2147483648),t}function Sr(e,t){const n=Math.cos(be(t[0]-e[0])),i=Math.sin(be(t[1])),s=Math.sin(be(e[1])),r=Math.cos(be(t[1])),o=Math.cos(be(e[1]));return Math.acos(i*s+r*o*n)}function P1(e,t,n){const i=be(e[0]),s=be(e[1]),r=[0,0];return r[1]=Math.asin(Math.sin(s)*Math.cos(n)+Math.cos(s)*Math.sin(n)*Math.cos(t)),r[0]=i+Math.atan2(Math.sin(t)*Math.sin(n)*Math.cos(s),Math.cos(n)-Math.sin(s)*Math.sin(r[1])),[Qn(r[0]),Qn(r[1])]}function yt(){let e=new It(3);return e[0]=0,e[1]=0,e[2]=0,e}function L1(e){var t=new It(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Fn(e){let t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function at(e,t,n){let i=new It(3);return i[0]=e,i[1]=t,i[2]=n,i}function Ga(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Oe(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function ti(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function D1(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Cn(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function Mu(e,t){let n=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(n*n+i*i+s*s)}function O1(e,t){let n=t[0]-e[0],i=t[1]-e[1],s=t[2]-e[2];return n*n+i*i+s*s}function F1(e){let t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function Tu(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function qt(e,t){let n=t[0],i=t[1],s=t[2],r=n*n+i*i+s*s;return r>0&&(r=1/Math.sqrt(r),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r),e}function ja(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ms(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],c=n[2];return e[0]=s*c-r*a,e[1]=r*o-i*c,e[2]=i*a-s*o,e}function ni(e,t,n,i){let s=t[0],r=t[1],o=t[2];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e[2]=o+i*(n[2]-o),e}function ys(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[3]*i+n[7]*s+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*i+n[4]*s+n[8]*r+n[12])/o,e[1]=(n[1]*i+n[5]*s+n[9]*r+n[13])/o,e[2]=(n[2]*i+n[6]*s+n[10]*r+n[14])/o,e}function C1(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],c=n[2],l=n[3],d=l*i+a*r-c*s,u=l*s+c*i-o*r,f=l*r+o*s-a*i,h=-o*i-a*s-c*r;return e[0]=d*l+h*-o+u*-c-f*-a,e[1]=u*l+h*-a+f*-o-d*-c,e[2]=f*l+h*-c+d*-a-u*-o,e}function R1(e,t,n,i){let s=[],r=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[0],r[1]=s[1]*Math.cos(i)-s[2]*Math.sin(i),r[2]=s[1]*Math.sin(i)+s[2]*Math.cos(i),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e}function N1(e,t,n,i){let s=[],r=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[2]*Math.sin(i)+s[0]*Math.cos(i),r[1]=s[1],r[2]=s[2]*Math.cos(i)-s[0]*Math.sin(i),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e}function k1(e,t,n,i){let s=[],r=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],r[0]=s[0]*Math.cos(i)-s[1]*Math.sin(i),r[1]=s[0]*Math.sin(i)+s[1]*Math.cos(i),r[2]=s[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e}function B1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function U1(e,t){let n=e[0],i=e[1],s=e[2],r=t[0],o=t[1],a=t[2];return Math.abs(n-r)<=bt*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-o)<=bt*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=bt*Math.max(1,Math.abs(s),Math.abs(a))}const Jt=D1,Va=Mu,z1=O1,Ar=Fn;(function(){let e=yt();return function(t,n,i,s,r,o){let a,c;for(n||(n=3),i||(i=0),s?c=Math.min(s*n+i,t.length):c=t.length,a=i;a<c;a+=n)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],r(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();function gs(){let e=new It(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function G1(e,t,n,i){let s=new It(4);return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s}function Su(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function j1(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function V1(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function H1(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function $1(e,t){let n=t[0],i=t[1],s=t[2],r=t[3],o=n*n+i*i+s*s+r*r;return o>0&&(o=1/Math.sqrt(o),e[0]=n*o,e[1]=i*o,e[2]=s*o,e[3]=r*o),e}function Y1(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3];return e[0]=s+i*(n[0]-s),e[1]=r+i*(n[1]-r),e[2]=o+i*(n[2]-o),e[3]=a+i*(n[3]-a),e}function Er(e,t,n){let i=t[0],s=t[1],r=t[2],o=t[3];return e[0]=n[0]*i+n[4]*s+n[8]*r+n[12]*o,e[1]=n[1]*i+n[5]*s+n[9]*r+n[13]*o,e[2]=n[2]*i+n[6]*s+n[10]*r+n[14]*o,e[3]=n[3]*i+n[7]*s+n[11]*r+n[15]*o,e}function W1(e,t){let n=e[0],i=e[1],s=e[2],r=e[3],o=t[0],a=t[1],c=t[2],l=t[3];return Math.abs(n-o)<=bt*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=bt*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=bt*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(r-l)<=bt*Math.max(1,Math.abs(r),Math.abs(l))}const Z1=V1;(function(){let e=gs();return function(t,n,i,s,r,o){let a,c;for(n||(n=4),i||(i=0),s?c=Math.min(s*n+i,t.length):c=t.length,a=i;a<c;a+=n)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],r(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();const ii=gs();class oe{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0]}static fromGeo(t,n=[0,0]){var c;const s=Math.sin(be(t[1])),r=t[0]*4294967296/360,o=Math.log((1+s)/(1-s))*4294967296/(4*Math.PI);let a=0;if(t.length>2){const l=oe.scaleFactor(t[1]);a=((c=t[2])!=null?c:0)*Ie*l}return n[0]=r,n[1]=Te(o,-2147483648,2147483648),n[2]=a,n}static toGeo(t,n=[0,0]){n[0]=t[0]*360/4294967296;const i=-2*Math.PI/4294967296;if(n[1]=90-2*Qn(Math.atan(Math.exp(t[1]*i))),t[2]){const s=oe.scaleFactor(n[1]);n[2]=t[2]/Ie/s}return n}static scaleFactor(t){return 1/Math.cos(be(t))}update(){const{center:t,rotation:n,zoom:i,pitch:s,size:r}=this.state,o=Ri(i,r),a=Math.max(o*Math.sin(s),1);this.position[0]=t[0]+Math.sin(n)*a,this.position[1]=t[1]-Math.cos(n)*a,this.position[2]=o*Math.cos(s)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state;ii[0]=t[0],ii[1]=t[1],ii[2]=t[2],ii[3]=1,Er(ii,ii,this.camera.viewProjectionMatrix);const[o,a,c,l]=ii,d=l*2;if(n&&(c>d||c<-d||o>d||o<-d||a>d||a<-d))return i;const f=s[0]/2,h=s[1]/2;return i[0]=f+r.left+o*f/l,i[1]=h+r.top-a*h/l,i}unproject(t,n=[0,0,0]){const{size:i,viewport:s}=this.state;n[0]=(t[0]-s.left)/i[0]*2-1,n[1]=-((Math.max(this.camera.horizonPixelOffset,t[1])-s.top)/i[1])*2+1,n[2]=0,ys(n,n,this.camera.viewProjectionMatrixInverse),n[0]-=this.position[0],n[1]-=this.position[1],n[2]-=this.position[2],qt(n,n);const r=-this.position[2]/n[2];return n[0]=this.position[0]+n[0]*r,n[1]=this.position[1]+n[1]*r,n[2]=this.position[2]+n[2]*r,n}setState(t){this.state=t}}const si=gs();function Au(e){return[e[2],e[0],e[1]]}class tt{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0],this.ivpMatrix=[],this.cachedVisibleArc=new du(()=>{const i=Ri(this.state.zoom,this.state.size)/Ie;return Math.acos(ei/(ei+i))},()=>[this.state.zoom]),this.cachedPixelRadius=new du(()=>{const i=oe.toGeo(this.state.center),s=P1(i,0,this.visibleArc),r=this.project(tt.fromGeo(s));return r[0]-=this.state.viewport.left+this.state.size[0]/2+(this.state.padding.left-this.state.padding.right)/2,r[1]-=this.state.viewport.top+this.state.size[1]/2+(this.state.padding.top-this.state.padding.bottom)/2,hu(r)},()=>[this.state.zoom,this.state.cameraConfig.fov,this.state.size[0],this.state.size[1],this.state.padding.bottom,this.state.padding.top,this.state.padding.left,this.state.padding.right,this.camera.globeMatrix[0]]),this.update()}get visibleArc(){return this.cachedVisibleArc.value}get pixelRadius(){return this.cachedPixelRadius.value}static fromGeo(t,n=[NaN,NaN,NaN]){const i=be(t[0]),s=be(t[1]),r=Math.cos(i),o=Math.sin(i),a=Math.cos(s),c=Math.sin(s),l=ei*Ie;return n[0]=o*a*l,n[1]=c*l,n[2]=r*a*l,n}static toGeo(t,n=[NaN,NaN]){const i=t[0],s=t[1],r=t[2],o=Math.sqrt(i*i+s*s+r*r),a=Math.asin(r/o),c=Math.atan2(s,i);return n[0]=Qn(c),n[1]=Qn(a),n}update(){const{state:t}=this,n=oe.toGeo(t.center),i=Ri(t.zoom,t.size)+ei*Ie,s=be(n[0]),r=be(n[1]),o=Math.cos(s),a=Math.sin(s),c=Math.cos(r),l=Math.sin(r);this.position=[a*c*i,l*i,o*c*i];const d=[0,0,1];Na(this.ivpMatrix,Au(this.position),[0,0,0],d),Ci(this.ivpMatrix,this.camera.projectionMatrix,this.ivpMatrix),hs(this.ivpMatrix,this.ivpMatrix)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state,o=gs();si[0]=t[0],si[1]=t[1],si[2]=t[2],si[3]=1,Er(si,si,this.camera.globeMatrix),Er(o,si,this.camera.viewProjectionMatrix);const[a,c,l,d]=o,u=d*2;if(n&&(l>u||l<-u||a>u||a<-u||c>u||c<-u))return i[0]=NaN,i[1]=NaN,i;const h=s[0]/2,g=s[1]/2;return i[0]=h+r.left+a*h/d,i[1]=g+r.top-c*g/d,i}unproject(t,n,i=[NaN,NaN,NaN]){const{size:s,viewport:r}=this.state,o=[(t[0]-r.left)/s[0]*2-1,-((Math.max(0,t[1])-r.top)/s[1])*2+1,0],a=Au(this.position),c=[0,0,0,1];ys(c,o,this.ivpMatrix);const l=qt([],Jt([],c,a)),d=Tu([],a),u=ja(d,l),f=F1(d)-re(u,2),h=re(ei*Ie,2);if(f>h){if(n)return tt.fromGeo(oe.toGeo(this.state.center));const{left:b,bottom:v,top:T,right:E}=this.state.padding,S=t[0]-r.left-s[0]/2-(b-E)/2,L=t[1]-r.top-s[1]/2-(T-v)/2,x=xt([],Ln([],[S,L]),this.pixelRadius-1);return x[0]=x[0]+r.left+s[0]/2+(b-E)/2,x[1]=x[1]+r.top+s[1]/2+(T-v)/2,this.unproject(x,!0,i)}const g=Math.sqrt(h-f),w=u-g,p=u+g,y=Math.min(w,p);return i[0]=a[0]+l[0]*y,i[1]=a[1]+l[1]*y,i[2]=a[2]+l[2]*y,i}setState(t){this.state=t}canSee(t){const n=oe.toGeo(this.state.center);return Sr(n,t)<this.visibleArc}}const X1=[0,0,1],q1=yt(),_t=[0,0,0];class ws{constructor(t){this.state=t,this.position=[0,0,0],this.projectionMatrix=[],this.viewMatrix=[],this.viewMatrixTranspose=[],this.projectionMatrixInverse=[],this.viewProjectionMatrix=[],this.viewProjectionMatrixInverse=[],this.globeMatrix=[],this.ecefMvpMatrix=new Float32Array(16),this.flat2ecef=0,this.fogDistance=0,this.correctedPitch=0,this.correctedRotation=0,this.horizonPixelOffset=0,this.prevZoom=0,this.horizonPixelOffset=0,this.flat=new oe(t,this),this.ecef=new tt(t,this),this.update()}get globeRatio(){return this.flat2ecef}setState(t){this.state=t,this.flat.setState(t),this.ecef.setState(t),this.update()}update(){const{globeMaxZoom:t}=_n;this.flat2ecef=this.state.globeMode?Te(t-this.state.zoom,0,1):0,this.limitPitchRotation(),this.updatePosition(),this.updateViewMatrix(),this.updateProjectionMatrices(),this.state.pitch=this.correctedPitch,this.state.rotation=this.correctedRotation,this.flat.update(),this.ecef.update(),Ca(this.viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),hs(this.viewProjectionMatrixInverse,this.viewProjectionMatrix),hs(this.projectionMatrixInverse,this.projectionMatrix),u1(this.viewMatrixTranspose,this.viewMatrix),this.state.globeMode&&this.updateGlobeMatrix(),Ci(this.ecefMvpMatrix,this.viewProjectionMatrix,this.globeMatrix),this.updateHorizonPixelOffset(),this.updateFogDistance()}project(t,n=!1,i=[NaN,NaN]){if(this.flat2ecef<Number.EPSILON)return this.flat.project(oe.fromGeo(t),n,i);if(this.flat2ecef>1-Number.EPSILON)return this.ecef.project(tt.fromGeo(t),n,i);{const s=this.flat.project(oe.fromGeo(t),n),r=this.ecef.project(tt.fromGeo(t),n);return Array.from(ni(i,s,r,this.flat2ecef))}}unproject(t,n=[0,0],i=!1){if(this.flat2ecef<Number.EPSILON){const s=[0,0,0];return this.flat.unproject(t,s),oe.toGeo(s,n),n}else if(this.flat2ecef>1-Number.EPSILON){const s=[0,0,0];return this.ecef.unproject(t,!1,s),tt.toGeo(s,n),n}else{const s=[0,0,0],r=[0,0,0];return this.flat.unproject(t,s),oe.toGeo(s,s),this.ecef.unproject(t,!1,r),tt.toGeo(r,r),i?(Ha(this,t,r,s,n,2),n[2]=0,n):(ni(n,s,r,this.flat2ecef),n[2]=0,n)}}getViewportVertices(t){const{size:n,viewport:i}=this.state;let s={top:0,right:0,bottom:0,left:0};if(t!==void 0){const o=n[0]*t,a=n[1]*t;s={top:o,right:a,bottom:o,left:a}}return[this.flat.unproject([i.left+s.left,n[1]+i.top-s.bottom,0]),this.flat.unproject([n[0]+i.left-s.right,n[1]+i.top-s.bottom,0]),this.flat.unproject([n[0]+i.left-s.right,i.top+s.top,0]),this.flat.unproject([i.left+s.left,i.top+s.top,0])]}getHorizonPixelOffset(){return this.horizonPixelOffset}updatePosition(){const{center:t,zoom:n,size:i}=this.state,s=Ri(n,i);this.prevZoom=n;const r=Math.max(s*Math.sin(this.correctedPitch),1);this.position[0]=t[0]+Math.sin(this.correctedRotation)*r,this.position[1]=t[1]-Math.cos(this.correctedRotation)*r,this.position[2]=s*Math.cos(this.correctedPitch)}limitPitchRotation(){const t=this.state,{zoom:n,pitch:i,rotation:s,cameraConfig:r,styleState:o,lowZoomMaxPitch:a,maxPitch:c}=t,{pitchInterStartZoom:l,pitchInterEndZoom:d}=r,{globeInterEndZoom:u,globeMaxZoom:f}=_n;if(this.correctedPitch=i,this.correctedRotation=s,n<d){const h=Math.max(0,n-l)/(d-l);this.correctedPitch=Math.min(i,Oi(a!=null?a:90,c!=null?c:90,h))}if(o.globeEnabled&&n<u){const h=Math.max(0,n-f)/(u-f);if(this.correctedPitch=Math.min(this.correctedPitch,Oi(0,c!=null?c:90,h)),n<=f)this.correctedRotation=0;else if(n!==this.prevZoom){const g=0-s,w=(this.prevZoom-n)/(n-f);w>0&&(this.correctedRotation+=g*w%360)}}}updateProjectionMatrices(){const t=this.state.cameraConfig,n=t.fov;t.useDynamicNearFar||this.state.globeMode?this.updateNearFarState():this.restoreFixedNearFar();const{near:i,far:s}=t,{size:r,view:o}=this.correctViewAndSize(),a=r[0]/r[1];let c=i*Math.tan(n/2),l=2*c,d=a*l,u=-d/2;u+=o.x*d/r[0],c-=o.y*l/r[1],d*=o.width/r[0],l*=o.height/r[1];const f=u+d,h=c-l,g=this.projectionMatrix;g[0]=2*i/(f-u),g[5]=2*i/(c-h),g[8]=(f+u)/(f-u),g[9]=(c+h)/(c-h),g[10]=-(s+i)/(s-i),g[11]=-1,g[14]=-2*s*i/(s-i),g[1]=g[2]=g[3]=g[4]=g[6]=g[7]=g[12]=g[13]=g[15]=0,hs(this.projectionMatrixInverse,this.projectionMatrix)}updateNearFarState(){const{zoom:t,cameraConfig:n}=this.state,i=this.position;if(t>qd)n.near=zt.near;else{const o=.25*i[2],a=Math.min(16-t,1);n.near=o*a+zt.near*(1-a)}const s=re(1-Math.min(t,20.5)/21,2);n.far=zt.far*s}restoreFixedNearFar(){const{cameraConfig:t}=this.state;t.near=zt.near,t.far=zt.far}correctViewAndSize(){const{size:t,padding:n}=this.state,i=Math.max(0,n.top-n.bottom)*Math.tan(this.correctedPitch),s=Ba(t[1])+i,r={x:(n.right-n.left)/2,y:(n.bottom-n.top)/2,width:t[0],height:t[1]};r.y+=(s-t[1])/2;const o=[t[0],s];return{view:r,size:o}}updateFogDistance(){const{center:t}=this.state,n=this.state.cameraConfig,i=Va(this.position,t);this.fogDistance=Math.max(n.minFogDistance,i)}updateViewMatrix(){Na(this.viewMatrix,this.position,this.state.center,X1)}updateGlobeMatrix(){const t=this.globeMatrix,n=[0,0,0];Fa(t);const i=oe.toGeo(this.state.center);Oe(n,this.state.center[0],this.state.center[1],-this.state.center[2]-ei*Ie),mu(this.globeMatrix,t,n),Ra(t,t,be(i[1])),yu(t,t,-be(i[0]))}updateHorizonPixelOffset(){const{viewport:t,size:n,zoom:i}=this.state,s=this.flat.unproject([t.left,n[1]+t.top,0]),r=this.flat.unproject([t.left+n[0]/2,n[1]+t.top,0]),o=this.flat.unproject([n[0]+t.left,n[1]+t.top,0]);Jt(_t,o,s),k1(_t,_t,q1,be(90)),qt(_t,_t);const a=vu(n[1]*this.state.cameraConfig.perspectiveDistanceLimitRatio,i);Cn(_t,_t,a),ti(_t,r,_t),this.flat.project(_t,!1,_t),this.horizonPixelOffset=Math.max(0,Math.ceil(_t[1]))}}function Ha(e,t,n,i,s,r,o=0){s[0]=(n[0]+i[0])/2,s[1]=(n[1]+i[1])/2;const a=e.project(n),c=e.project(i),l=e.project(s),d=On(l,t),u=On(a,t),f=On(c,t);if(d<r)return s;if(u<r)return n;if(f<r)return i;if(o>=10)return s;const h=u+d,g=f+d;return h>g?Ha(e,t,i,s,s,r,o+1):Ha(e,t,n,s,s,r,o+1)}function J1(e,t,n){n.zoom!==void 0&&(n.zoom=Te(n.zoom,e.minZoom,e.maxZoom));const i=ue({},e);ps(i.center);const s=new ws(i),r=s.unproject(t),o=oe.fromGeo(r);n.center&&ps(n.center),s.setState(ue(ue({},e),n));const a=oe.fromGeo(s.unproject(t));Math.abs(o[0]-a[0])>re(2,31)&&(a[0]+=(o[0]>0?1:-1)*re(2,32));const c=yt();if(Jt(c,o,a),e.globeMode&&Math.abs(r[1])>70&&e.zoom>_n.globeInterStartZoom&&e.zoom<_n.globeMaxZoom){const l=Math.abs(e.zoom-n.zoom);if(l>1e-4){const d=Math.abs(o[0]-a[0]),u=Math.log10(d/l),f=Math.min(1,re(10,6-u));Number.isNaN(f)||Cn(c,c,f)}}return c}function Eu(e){const n=oe.toGeo(e)[1],i=1/(2*Math.cos(be(n)));return Math.log(i)/Math.log(2)}function K1(e,t){const n=oe.scaleFactor(t[1]);return 1+e*(n-1)}function xu(e,t){const n=Eu(t)*Pa(9,10,e);return e+Te(n,-1,0)}function Q1(e,t){const n=Eu(t),i=n*Pa(9,10+n,e);return e-Te(i,-1,0)}function ey(e,t,n,i,s,r,o={top:0,right:0,bottom:0,left:0},a={top:0,right:0,bottom:0,left:0},c,l){const d=zt,u=new ws({center:oe.fromGeo(e),zoom:t,rotation:be(n),size:i,pitch:be(s),viewport:o,padding:a,cameraConfig:d,globeMode:!1,styleState:{}}),f=oe.toGeo(u.flat.unproject(r)),h=oe.toGeo(u.flat.unproject([r[0]+c,r[1]+l]));return Math.max(1,Ua(f,h))}function xr(e,t){return t*Ie*oe.scaleFactor(e[1])}function vs(e,t){return{min:e||Da(1/0,1/0),max:t||Da(-1/0,-1/0)}}function ty(e){return vs(oe.fromGeo(e.southWest),oe.fromGeo(e.northEast))}function ri(e,t){s1(e.min,e.min,t),r1(e.max,e.max,t)}function _u(e,t){e.min[0]=t.min[0],e.max[0]=t.max[0],e.min[1]=t.min[1],e.max[1]=t.max[1]}function $a(e){e.min[0]=1/0,e.max[0]=-1/0,e.min[1]=1/0,e.max[1]=-1/0}function _r(e,t){return e[0]=t.min[0]+(t.max[0]-t.min[0])/2,e[1]=t.min[1]+(t.max[1]-t.min[1])/2,e}function ny(e,t,n){e[0]=Te(n[0],t.min[0],t.max[0]),e[1]=Te(n[1],t.min[1],t.max[1])}function iy(e,t,n){e[1]=Te(n[1],t.min[1],t.max[1])}function sy(e,t){return t[0]<=e.max[0]&&t[0]>=e.min[0]&&t[1]<=e.max[1]&&t[1]>=e.min[1]}function ry(e,t){return t[1]<=e.max[1]&&t[1]>=e.min[1]}function Ya(e,t,n=0){const i=e.min[0]+n<=t.max[0]-n&&t.min[0]+n<=e.max[0]-n,s=e.min[1]+n<=t.max[1]-n&&t.min[1]+n<=e.max[1]-n;return i&&s}function oy(e,t){return{min:[Math.max(e.min[0],t.min[0]),Math.max(e.min[1],t.min[1])],max:[Math.min(e.max[0],t.max[0]),Math.min(e.max[1],t.max[1])]}}function ay(e,t){const n=_r([],e),i=(e.max[0]-e.min[0])/2*t,s=(e.max[1]-e.min[1])/2*t;e.min[0]=n[0]-i,e.min[1]=n[1]-s,e.max[0]=n[0]+i,e.max[1]=n[1]+s}function Pu(){let e=new It(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function cy(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}function Wa(){let e=new It(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ly(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function dy(e,t,n){n=n*.5;let i=Math.sin(n);return e[0]=i*t[0],e[1]=i*t[1],e[2]=i*t[2],e[3]=Math.cos(n),e}function uy(e,t,n){n*=.5;let i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);return e[0]=i*c-r*a,e[1]=s*c+o*a,e[2]=r*c+i*a,e[3]=o*c-s*a,e}function fy(e,t,n){n*=.5;let i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),c=Math.cos(n);return e[0]=i*c+s*a,e[1]=s*c-i*a,e[2]=r*c+o*a,e[3]=o*c-r*a,e}function Pr(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],c=n[0],l=n[1],d=n[2],u=n[3],f,h,g,w,p;return h=s*c+r*l+o*d+a*u,h<0&&(h=-h,c=-c,l=-l,d=-d,u=-u),1-h>1e-6?(f=Math.acos(h),g=Math.sin(f),w=Math.sin((1-i)*f)/g,p=Math.sin(i*f)/g):(w=1-i,p=i),e[0]=w*s+p*c,e[1]=w*r+p*l,e[2]=w*o+p*d,e[3]=w*a+p*u,e}function hy(e,t){let n=t[0]+t[4]+t[8],i;if(n>0)i=Math.sqrt(n+1),e[3]=.5*i,i=.5/i,e[0]=(t[5]-t[7])*i,e[1]=(t[6]-t[2])*i,e[2]=(t[1]-t[3])*i;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let r=(s+1)%3,o=(s+2)%3;i=Math.sqrt(t[s*3+s]-t[r*3+r]-t[o*3+o]+1),e[s]=.5*i,i=.5/i,e[3]=(t[r*3+o]-t[o*3+r])*i,e[r]=(t[r*3+s]+t[s*3+r])*i,e[o]=(t[o*3+s]+t[s*3+o])*i}return e}const Lu=$1;(function(){let e=yt(),t=at(1,0,0),n=at(0,1,0);return function(i,s,r){let o=ja(s,r);return o<-.999999?(ms(e,t,s),Ar(e)<1e-6&&ms(e,n,s),qt(e,e),dy(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(ms(e,s,r),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,Lu(i,i))}})(),(function(){let e=Wa(),t=Wa();return function(n,i,s,r,o,a){return Pr(e,i,o,a),Pr(t,s,r,a),Pr(n,e,t,2*a*(1-a)),n}})(),(function(){let e=Pu();return function(t,n,i,s){return e[0]=i[0],e[3]=i[1],e[6]=i[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],Lu(t,hy(t,e))}})();const Kt=[0,0,0],Qt=[0,0,0],Za=yt();Pu();function jt(e,t,n,i,s){if(t!==i||n!==s){const r=s-n,o=t-i,a=1/Math.sqrt(r*r+o*o);e[0]=r*a,e[1]=o*a}else e[0]=0,e[1]=0}function Du(e,t,n,i){return Jt(Kt,n,t),Jt(Qt,n,i),ms(e,Qt,Kt),qt(e,e),e}function en(e,t,n,i,s){if(t!==i||n!==s){const r=i-t,o=s-n,a=1/Math.sqrt(r*r+o*o);e[0]=r*a,e[1]=o*a}else e[0]=0,e[1]=0}function Ou(e,t,n,i,s){const r=t+i,o=n+s,a=t*r+n*o,c=5;if(a!==0){const l=1/a;e[0]=r*l,e[1]=o*l,br(e)>c&&Ln(e,e)}else e[0]=0,e[1]=0}function $e(e){return Te(e*127,-127,127)}function Xa(e,t=e){return e[0]=$e(t[0]),e[1]=$e(t[1]),e}function py(e,t,n,i,s){e[0]=t*i+n*s,e[1]=n*i-t*s}function Rn(e,t){const n=t[0];e[0]=-t[1],e[1]=n}function qa(e,t){const n=t[0];e[0]=t[1],e[1]=-n}function my(e){return e[0]===0&&e[1]===0}function yy(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])}function gy(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function wy(e,t){const n=Math.sin(t),i=Math.cos(t),s=i*e[0]-n*e[1],r=n*e[0]+i*e[1];je(e,s,r)}function vy(e,t,n,i,s=!0){if(Ir(t,n)||Ir(n,i)){je(e,0,0);return}ln(Kt,n,t),ln(Qt,i,n),s?(Rn(Kt,Kt),Rn(Qt,Qt)):(qa(Kt,Kt),qa(Qt,Qt)),Ln(Kt,Kt),Ln(Qt,Qt),Gt(e,Kt,Qt),Ln(e,e)}function by(e,t,n){t[0]=Fn(Oe(Za,e[0],e[1],e[2])),t[1]=Fn(Oe(Za,e[3],e[4],e[5])),t[2]=Fn(Oe(Za,e[6],e[7],e[8]))}function Iy(e,t,n,i){t[0]=Fn(at(e[0],e[1],e[2])),t[1]=Fn(at(e[4],e[5],e[6])),t[2]=Fn(at(e[8],e[9],e[10])),n[0]=e[12],n[1]=e[13],n[2]=e[14]}function My(e,t,n,i){const[s,r]=e,[o,a]=t,[c,l]=n;return i[0]=Math.min(Math.max(s,o),c),i[1]=Math.min(Math.max(r,a),l),i[2]=0,i}const Ja=/\{(\w+)\}/g;function bs(e,t){return e.replace(Ja,(n,i)=>t[i])}function Fu(e){const[t,n]=e.split("?");if(!n)return t;const s=n.split("&").map(r=>r.split("=")).filter(([,r])=>r!=="undefined").map(r=>r.join("=")).join("&");return s.length?`${t}?${s}`:t}function Ty(e,t){return(typeof e=="object"?e.url:mr[e]).replace(Ja,(n,i)=>{var s;return(s=t[i])!=null?s:n}).replace(Ja,(n,i)=>{var s;return(s=t[i])!=null?s:n})}function Is(e,t){const n=bs(t.host,{subdomain:t.subdomain}),i=bs(typeof e=="object"?e.url:mr[e],ve(ue({},t),{host:n}));return Fu(i)}function Ms(e,t){const n=bs(e,t);return Fu(n)}function Ka(e,t){let n=0;for(let i=0;i<t.length;i++)n+=t.charCodeAt(i);return e[n%e.length]}function Sy(e,t){const n=new URL(t);return e.startsWith("//")?`${n.protocol}${e}`:e.startsWith("/")?`${n.origin}${e}`:e}for(var Ni="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ay=typeof Uint8Array=="undefined"?[]:new Uint8Array(256),Lr=0;Lr<Ni.length;Lr++)Ay[Ni.charCodeAt(Lr)]=Lr;var Cu=function(e){var t=new Uint8Array(e),n,i=t.length,s="";for(n=0;n<i;n+=3)s+=Ni[t[n]>>2],s+=Ni[(t[n]&3)<<4|t[n+1]>>4],s+=Ni[(t[n+1]&15)<<2|t[n+2]>>6],s+=Ni[t[n+2]&63];return i%3===2?s=s.substring(0,s.length-1)+"=":i%3===1&&(s=s.substring(0,s.length-2)+"=="),s};function Ey(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*re(256,e.length-1-n);return t}function Ru(e){const t=new Uint8Array(6);for(let n=0;n<6;n++)t[n]=Math.floor(e/re(256,5-n))&255;return encodeURIComponent(Cu(t.buffer))}function xy(e,t){var s,r,o,a,c,l;const n={};e.forEach((d,u)=>{n[d]=u});let i=e.length;n.selected=(s=n.selected)!=null?s:i++,n.hovered=(r=n.hovered)!=null?r:i++,n.dpi=(o=n.dpi)!=null?o:i++,n.isRealtime=(a=n.isRealtime)!=null?a:i++,n.pixelDensityPreset=(c=n.pixelDensityPreset)!=null?c:i++,n.tier=(l=n.tier)!=null?l:i++;for(const d in t)n[d]===void 0&&(n[d]=i++);return n}function Nu(e){const t=xy(e.tileProps,e.defaultProps),n={};for(const i in e.defaultProps)n[i]={index:t[i],value:e.defaultProps[i]};return{version:e.version,dictionaries:e.enumerationValues,reverseDictionaries:Object.keys(e.enumerationValues).reduce((i,s)=>(i[s]=_a(e.enumerationValues[s]),i),{}),tileProps:t,tilePropsByIndex:_a(t),defaultProps:n,vertexPropsLegacy:ec(e.vertexProps)?_y(e):{},vertexProps:ec(e.vertexProps)?[]:e.vertexProps}}function _y(e){const t=e.vertexProps,n={point:["x","y","z"],polygon:["x","y","cut","signed_z"],polyline:["x","y"]};if(!t)return n;if(!ec(t))return console.warn(`Попытка сгенерировать vertexPropsLegacy для метатайла версии ${e.version}`),{};const i={0:"point",1:"polyline",2:"polygon"};return Object.keys(t).forEach(s=>{const r=i[s];if(typeof r=="undefined"){console.warn(`Неизвестный тип геометрии "${s}", нужно его поддержать`);return}n[r]=t[parseInt(s,10)]}),n}function ku(e,t){const n={};if(t)for(let i=0;i<t.length;i++)n[t[i]]=i;return Nu({enumerationValues:{db_sublayer:n},version:"7.0.0",defaultProps:{},tileProps:e,vertexProps:[]})}function Ts(e,t){const{tileProps:n}=e;let i=Object.keys(n).length;for(const s of t)n[s]===void 0&&(n[s]=i,i+=1)}let he=0;const oi={beginningIsCut:he++,class:he++,componentDistanceEnd:he++,componentDistanceStart:he++,db_icon_priority:he++,db_label_priority:he++,db_label2_priority:he++,dpi:he++,endingIsCut:he++,height:he++,db_hidden_by_plan_building_id:he++,db_hidden_by_plan_id:he++,id:he++,isRealtime:he++,db_label:he++,db_label2:he++,nextPointX:he++,nextPointY:he++,db_object_class:he++,objectLength:he++,pixelDensityPreset:he++,previousPointX:he++,previousPointY:he++,db_region:he++,selected:he++,hovered:he++,db_sublayer:he++,traffic_color:he++,traffic_road_class:he++,traffic_road_z_level:he++,db_tiers:he++,model_src:he++,linkedIds:he++,db_model_rotation_angle:he++,db_plan_id:he++,traffic_color2:he++},Py={version:"5.0.0",tileProps:oi,tilePropsByIndex:_a(oi),defaultProps:{},dictionaries:{},reverseDictionaries:{},vertexPropsLegacy:{},vertexProps:[]},Bu=[],Qa={},Uu={sourceName:"zenith"};function ec(e){return!Array.isArray(e)}class tc{constructor(){this.events={}}on(t,n){let i=this.events[t];return i||(i=this.events[t]=[]),i.push(n),this}once(t,n){const i=s=>{this.off(t,i),n.call(this,s)};return this.on(t,i),this}off(t,n){const i=this.events[t];if(!i)return this;const s=i.indexOf(n);return s!==-1&&i.splice(s,1),this}emit(t,n){const i=this.events[t];if(!i)return this;const s=i.slice();for(let r=0;r<s.length;r++)s[r].call(this,n);return this}}let Ly=1;function nc(){return Ly++}let Dy=1;const ic=()=>++Dy,Oy=ic(),Fy=ic(),sc=65536*65536,zu=1/sc,Cy=12,Gu=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8"),rc=0,Dr=1,Ss=2,Or=5;class Fr{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,n,i=this.length){for(;this.pos<i;){const s=this.readVarint(),r=s>>3,o=this.pos;this.type=s&7,t(r,n,this),this.pos===o&&this.skip(s)}return n}readMessage(t,n){return this.readFields(t,n,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*sc;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*sc;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const n=this.buf;let i,s;return s=n[this.pos++],i=s&127,s<128||(s=n[this.pos++],i|=(s&127)<<7,s<128)||(s=n[this.pos++],i|=(s&127)<<14,s<128)||(s=n[this.pos++],i|=(s&127)<<21,s<128)?i:(s=n[this.pos],i|=(s&15)<<28,Ry(i,t,this))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){const t=this.readVarint()+this.pos,n=this.pos;return this.pos=t,t-n>=Cy&&Gu?Gu.decode(this.buf.subarray(n,t)):Zy(this.buf,n,t)}readBytes(){const t=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,t);return this.pos=t,n}readPackedVarint(t=[],n){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readVarint(n));return t}readPackedSVarint(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const n=this.readPackedEnd();for(;this.pos<n;)t.push(this.readSFixed64());return t}readPackedEnd(){return this.type===Ss?this.readVarint()+this.pos:this.pos+1}skip(t){const n=t&7;if(n===rc)for(;this.buf[this.pos++]>127;);else if(n===Ss)this.pos=this.readVarint()+this.pos;else if(n===Or)this.pos+=4;else if(n===Dr)this.pos+=8;else throw new Error(`Unimplemented type: ${n}`)}writeTag(t,n){this.writeVarint(t<<3|n)}realloc(t){let n=this.length||16;for(;n<this.pos+t;)n*=2;if(n!==this.length){const i=new Uint8Array(n);i.set(this.buf),this.buf=i,this.dataView=new DataView(i.buffer),this.length=n}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*zu),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,t&-1,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*zu),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){Ny(t,this);return}this.realloc(4),this.buf[this.pos++]=t&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=(t>>>=7)&127|(t>127?128:0),!(t<=127)&&(this.buf[this.pos++]=t>>>7&127)))}writeSVarint(t){this.writeVarint(t<0?-t*2-1:t*2)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(t.length*4),this.pos++;const n=this.pos;this.pos=Xy(this.buf,t,this.pos);const i=this.pos-n;i>=128&&ju(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const n=t.length;this.writeVarint(n),this.realloc(n);for(let i=0;i<n;i++)this.buf[this.pos++]=t[i]}writeRawMessage(t,n){this.pos++;const i=this.pos;t(n,this);const s=this.pos-i;s>=128&&ju(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeMessage(t,n,i){this.writeTag(t,Ss),this.writeRawMessage(n,i)}writePackedVarint(t,n){n.length&&this.writeMessage(t,Uy,n)}writePackedSVarint(t,n){n.length&&this.writeMessage(t,zy,n)}writePackedBoolean(t,n){n.length&&this.writeMessage(t,Vy,n)}writePackedFloat(t,n){n.length&&this.writeMessage(t,Gy,n)}writePackedDouble(t,n){n.length&&this.writeMessage(t,jy,n)}writePackedFixed32(t,n){n.length&&this.writeMessage(t,Hy,n)}writePackedSFixed32(t,n){n.length&&this.writeMessage(t,$y,n)}writePackedFixed64(t,n){n.length&&this.writeMessage(t,Yy,n)}writePackedSFixed64(t,n){n.length&&this.writeMessage(t,Wy,n)}writeBytesField(t,n){this.writeTag(t,Ss),this.writeBytes(n)}writeFixed32Field(t,n){this.writeTag(t,Or),this.writeFixed32(n)}writeSFixed32Field(t,n){this.writeTag(t,Or),this.writeSFixed32(n)}writeFixed64Field(t,n){this.writeTag(t,Dr),this.writeFixed64(n)}writeSFixed64Field(t,n){this.writeTag(t,Dr),this.writeSFixed64(n)}writeVarintField(t,n){this.writeTag(t,rc),this.writeVarint(n)}writeSVarintField(t,n){this.writeTag(t,rc),this.writeSVarint(n)}writeStringField(t,n){this.writeTag(t,Ss),this.writeString(n)}writeFloatField(t,n){this.writeTag(t,Or),this.writeFloat(n)}writeDoubleField(t,n){this.writeTag(t,Dr),this.writeDouble(n)}writeBooleanField(t,n){this.writeVarintField(t,+n)}}function Ry(e,t,n){const i=n.buf;let s,r;if(r=i[n.pos++],s=(r&112)>>4,r<128||(r=i[n.pos++],s|=(r&127)<<3,r<128)||(r=i[n.pos++],s|=(r&127)<<10,r<128)||(r=i[n.pos++],s|=(r&127)<<17,r<128)||(r=i[n.pos++],s|=(r&127)<<24,r<128)||(r=i[n.pos++],s|=(r&1)<<31,r<128))return ki(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function ki(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function Ny(e,t){let n,i;if(e>=0?(n=e%4294967296|0,i=e/4294967296|0):(n=~(-e%4294967296),i=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),ky(n,i,t),By(i,t)}function ky(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function By(e,t){const n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function ju(e,t,n){const i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(i);for(let s=n.pos-1;s>=e;s--)n.buf[s+i]=n.buf[s]}function Uy(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function zy(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function Gy(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function jy(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function Vy(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function Hy(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function $y(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function Yy(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function Wy(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Zy(e,t,n){let i="",s=t;for(;s<n;){const r=e[s];let o=null,a=r>239?4:r>223?3:r>191?2:1;if(s+a>n)break;let c,l,d;a===1?r<128&&(o=r):a===2?(c=e[s+1],(c&192)===128&&(o=(r&31)<<6|c&63,o<=127&&(o=null))):a===3?(c=e[s+1],l=e[s+2],(c&192)===128&&(l&192)===128&&(o=(r&15)<<12|(c&63)<<6|l&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(c=e[s+1],l=e[s+2],d=e[s+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(o=(r&15)<<18|(c&63)<<12|(l&63)<<6|d&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),s+=a}return i}function Xy(e,t,n){for(let i=0,s,r;i<t.length;i++){if(s=t.charCodeAt(i),s>55295&&s<57344)if(r)if(s<56320){e[n++]=239,e[n++]=191,e[n++]=189,r=s;continue}else s=r-55296<<10|s-56320|65536,r=null;else{s>56319||i+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):r=s;continue}else r&&(e[n++]=239,e[n++]=191,e[n++]=189,r=null);s<128?e[n++]=s:(s<2048?e[n++]=s>>6|192:(s<65536?e[n++]=s>>12|224:(e[n++]=s>>18|240,e[n++]=s>>12&63|128),e[n++]=s>>6&63|128),e[n++]=s&63|128)}return n}Array(16);function ai(e,t){return{a:e[1]-t[1],b:t[0]-e[0],c:e[0]*t[1]-t[0]*e[1]}}function qy(e,t){return Math.abs(Vu(e,t))}function Vu(e,t){return(t.a*e[0]+t.b*e[1]+t.c)/Math.sqrt(t.a*t.a+t.b*t.b)}function Jy(e,t,n){const{a:i,b:s,c:r}=ai(e,t);return at(n,-(i*n+r)/s,0)}function Ky(e,t,n){const{a:i,b:s,c:r}=ai(e,t);return at(-(s*n+r)/i,n,0)}const ci=vs(),gt=vs();function Qy(e,t,n){const i=t[t.length-1]*n;let s=e[0],r=0;const o=[s];let a=1,c;for(;a<e.length&&!c;){const l=e[a],d=t[a];let u=l;if(d>i){if(!c){const f=(i-r)/(d-r);c=[],fu(c,s,l,f)}u=c}o.push(u),s=u,r=t[a],a++}return o}function eg(e,t){let n=e[0];$a(ci),ri(ci,n);let i=[n];const s=[i];let r=1;for(;r<e.length;){const o=e[r];let a=!1,c=o;if(_u(gt,ci),ri(gt,c),gt.max[0]-gt.min[0]>t){const l=gt.max[0]===c[0]?gt.min[0]+t:gt.max[0]-t;c=Jy(n,c,l),a=!0}if(a&&(_u(gt,ci),ri(gt,c)),gt.max[1]-gt.min[1]>t){const l=gt.max[1]===c[1]?gt.min[1]+t:gt.max[1]-t;c=Ky(n,c,l),a=!0}a?(i.push(c),$a(ci),ri(ci,c),i=[c],s.push(i),n=c):(i.push(o),ri(ci,o),n=o,r++)}return s}function tg(e,t,n){const i=e[0]-t[0],s=e[1]-t[1],r=n[0]-t[0],o=n[1]-t[1],a=i*r+s*o,c=r*r+o*o,l=c!==0?a/c:0;return l<0?t:l>1?n:[t[0]+l*r,t[1]+l*o]}function Cr(e){const t=e[0][0],n=e[0][1],i=e[1][0],s=e[1][1],r=e[2][0],o=e[2][1],a=e[3][0],c=e[3][1];return{min:[Math.min(t,i,r,a),Math.min(n,s,o,c)],max:[Math.max(t,i,r,a),Math.max(n,s,o,c)]}}function ng(e){return[[e[0][0],e[0][1],e[0][2]],[e[1][0],e[1][1],e[1][2]],[e[2][0],e[2][1],e[2][2]],[e[3][0],e[3][1],e[3][2]]]}function Hu(e,t){const n=Cr(e);if(!Ya(t,n))return!1;const i=[ai(e[3],e[2]),ai(e[1],e[0]),ai(e[0],e[3]),ai(e[2],e[1])],s=[t.min,t.max,[t.min[0],t.max[1]],[t.max[0],t.min[1]]];for(const r of i){let o=!0;for(let a=0;a<s.length;a++){const c=s[a];if(r.a*c[0]+r.b*c[1]+r.c<0){o=!1;break}}if(o)return!1}return!0}function ig(e,t,n){e.forEach(i=>{const s=1+t/Mu(n,i);ni(i,n,i,s)})}function sg(e,t){if(e.tiles)for(const n of e.tiles)t.writeMessage(1,rg,n)}function rg(e,t){e.x&&t.writeVarintField(1,e.x),e.y&&t.writeVarintField(2,e.y),e.zoom&&t.writeVarintField(3,e.zoom)}function og(e,t){return e.readFields(ag,{tileGroups:[]},t)}function ag(e,t,n){e===1&&t.tileGroups.push(cg(n,n.readVarint()+n.pos))}function cg(e,t){return e.readFields(lg,{x:0,y:0,zoom:0,tiles:[]},t)}function lg(e,t,n){e===1?t.x=n.readVarint():e===2?t.y=n.readVarint():e===3?t.zoom=n.readVarint():e===4&&t.tiles.push(dg(n,n.readVarint()+n.pos))}function dg(e,t){return e.readFields(ug,{regionId:0,hash:void 0,data:void 0},t)}function ug(e,t,n){e===1?t.regionId=n.readVarint():e===2?t.hash=n.readBytes():e===3&&(t.data=n.readBytes())}const Bi=[0,0,0];function ct(e){return{coords:e,size:Lt(e[2]),offset:zi(e)}}function xe(e){return $u(e[0],e[1],e[2],e[3])}function $u(e,t,n,i){return`${e}_${t}_${n}_${i}`}function fg(e,t){return`${xe(e)}_${t.stringify()}`}function oc(e){const t=e.split("_");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}function Yu(e){return Kn.subdomains[Math.abs(e[0]+e[1])%Kn.subdomains.length]}function hg(e){const t=new Fr(e),n=og(t),{x:i,y:s,zoom:r,tiles:o}=n.tileGroups[0];return o.map(({regionId:a,hash:c,data:l})=>(l||(console.warn(`Tile ${r}_${i}_${s} from region ${a} is corrupt (has no data)`),l=new Uint8Array(0)),{data:l,regionId:a,metatileHash:Ey(c)}))}function pg(e){return e.map(t=>({regionId:t.regionId,metatileHash:t.metatileHash}))}function mg(e){const t=Math.ceil(e.byteLength/4)*4,n=new ArrayBuffer(t);return new Uint8Array(n).set(e),n}function Rr(e){const[t,n,i]=e;return{min:zi([t,n,i,i]),max:zi([t+1,n+1,i,i])}}function yg(e,t){return Ya(Rr(e),Rr(t),.001)}function Nr(e,t,n,i=0){const s=Rr(e);return s.min[0]-=i,s.min[1]-=i,s.max[0]+=i,s.max[1]+=i,n.environmentManager.isAABBInFog(s)?!1:Hu(t,s)}function gg(e){return Math.trunc(e/2)*2+1}function ac(e,t=1,n=3,i=!1){let s=1/Math.cos(be(e));return i&&(s=Math.log2(s)),Te(Math.ceil(s),t,n)-1}const wg=(e,t)=>(isNaN(e[0])||e[0]===t[0])&&(isNaN(e[1])||e[1]===t[1])&&(isNaN(e[2])||e[2]===t[2])&&(isNaN(e[3])||e[3]===t[3]);function Wu(e,t,n){const i=vg(t,e.size),s=Math.trunc(t),r=Array.from(e.center);ps(r);const o=oe.toGeo(r),a={min:[o[0]-Te(i*2,0,90),Te(o[1]-i,-85,85)],max:[o[0]+Te(i*2,0,90),Te(o[1]+i,-85,85)]},c=Math.max(ac(a.min[1],2,4),ac(a.max[1],2,4)),l=Math.max(n,s-c),d=lc(r,l,!0);d[0]=Math.round(d[0]),d[1]=Math.round(d[1]);const u=new ws(e),f=Zu(e,u,o),h=Dg(d,o,f,u,e),g=[];return h.forEach(w=>{wg([NaN,2,2,NaN],w)?g.push(...Ju(w,1)):g.push(w)}),g.filter(w=>Gr(e,u,w))}function vg(e,t){const n=ei*Ie,i=Ri(e,t)+n,s=zt.fov/2,r=Math.sin(s),o=Math.cos(s),a=n/i;let c=Qn(Math.acos(re(r,2)/a+o*Math.sqrt(1-re(r,2)/re(a,2))));return Number.isNaN(c)&&(c=90),c}function Zu(e,t,n){const i=tt.toGeo(t.ecef.unproject([e.viewport.left,e.viewport.top]));return Math.min(3*Math.max(Sr(i,n)),t.ecef.visibleArc)}function bg(e,t,n,i,s,r){const[,,o]=e,a=Mg(e),c=i>=5?2:1,l=ac((a.max[1]+a.min[1])/2,c,3,!0),d=Math.max(Math.abs(a.min[1]),Math.abs(a.max[1])),u=Math.max(n,i-l);return o>=u||d>70&&r>0||d>82||Sr(t,[(a.max[0]+a.min[0])/2,(a.max[1]+a.min[1])/2])>.75*s}function Ig(e,t){const i=Math.trunc(e.zoom),s=Array.from(e.center);ps(s),oe.toGeo(s,s);const r=[],o=new ws(e),a=Zu(e,o,s);function c(l,d=0){if(sf(s,a,l)&&Gr(e,o,l))if(bg(l,s,2,i,o.ecef.visibleArc,d))r.push(l);else for(const u of Ju(l,1))c(u,d+1)}return Wu(e,Math.trunc(e.zoom),2).map(([l,d,u])=>{c([l,d,u,t])}),r}function Mg(e){return{min:Xu(e),max:Xu([e[0]+1,e[1]+1,e[2],e[3]])}}function Xu(e){const t=zi(e);return oe.toGeo(t)}function qu(e,t,n,i,s,r=0,o=1/0,a=!1,c=!1){if(e.globeMode)return Ig(e,s);a&&(n=gg(n),n>o&&(n-=2));const l=Cr(e.tilesBounds),d=Lt(n),u=re(2,n),f=Math.floor((l.min[0]+2147483648-r)/d),h=Math.floor((l.max[0]+2147483648+r)/d),g=Math.max(Math.floor((l.min[1]+2147483648-r)/d),0),w=Math.min(Math.floor((l.max[1]+2147483648+r)/d),u-1),p=[],y=new Set;for(let b=f;b<=h;b++)for(let v=g;v<=w;v++){const T=[b,v,n,s];if(Nr(T,e.tilesBounds,t,r)){T[0]=(u+T[0]%u)%u;const E=xe(T);y.has(E)||(y.add(E),p.push(T))}}return c===!0&&Tg(p,y,e,t,n,i,s),p}function Tg(e,t,n,i,s,r,o){const a=new Set,c=ng(n.tilesBounds);let l=e;for(let d=s;d>=r;d--){let u=0;const f=[];l.forEach(T=>{const E=Sg(T),S=xe(E);a.has(S)||(f.push(E),a.add(S),Ag(E,L=>{const x=xe(L);!t.has(x)&&!a.has(x)&&Nr(L,n.extendedTilesBounds,i)&&(e.push(L),t.add(x),u++)}))});const h=Lt(d-1);ig(c,h,n.center);const g=Cr(c),w=re(2,d-1),p=Math.floor((g.min[0]+2147483648)/h),y=Math.floor((g.max[0]+2147483648)/h),b=Math.max(Math.floor((g.min[1]+2147483648)/h),0),v=Math.min(Math.floor((g.max[1]+2147483648)/h),w-1);for(let T=p;T<=y;T++)for(let E=b;E<=v;E++){const S=[T,E,d-1,o];S[0]=(w+S[0]%w)%w;const L=xe(S);!a.has(L)&&Nr(S,c,i)&&(f.push(S),u++)}if(!u)break;l=f}}function Sg(e,t=1){const[n,i,s,r]=e,o=Math.pow(2,t);return[Math.trunc(n/o),Math.trunc(i/o),s-t,r]}function Ju(e,t){const[n,i,s,r]=e,o=Math.pow(2,t),a=[];for(let c=0;c<o;c++)for(let l=0;l<o;l++)a.push([n*o+c,i*o+l,s+t,r]);return a}function Ag(e,t){let[n,i,s]=e;const r=e[3];n*=2,i*=2,s++,t([n,i,s,r]),t([n+1,i,s,r]),t([n,i+1,s,r]),t([n+1,i+1,s,r])}function Eg(e,t,n,i,s,r,o,a,c,l,d,u){const f=new Fr,h={tiles:[{x:s[0],y:s[1],zoom:s[2]}]};sg(h,f);const g={x:s[0].toString(),y:s[1].toString(),z:s[2].toString(),protocol:n,host:e,subdomain:i[Math.abs(s[0]+s[1])%i.length],tileSet:t,lang:a,appId:o,tileKey:r,sessionId:d,defaultLang:l,dt:u==null?void 0:u.join(","),request:encodeURIComponent(Cu(f.finish()))};return Is(c?{url:c}:"tiles",g)}function xg(e,t){const n=e.coords,i=t.coords,s=n[2],r=i[2];return s===r?n[0]===i[0]&&n[1]===i[1]:s<r?Ku(e,t):Ku(t,e)}function Ku(e,t){if(t.zoomLevel<e.zoomLevel)return!1;if(t.zoomLevel===e.zoomLevel)return t.coords[0]===e.coords[0]&&t.coords[1]===e.coords[1]&&t.detailLevel>e.detailLevel;const n=Math.pow(2,t.coords[2]-e.coords[2]),i=e.coords[0]*n,s=i+n,r=e.coords[1]*n,o=r+n,a=t.coords[0],c=t.coords[1];return a>=i&&a<s&&c>=r&&c<o}function kr(e,t,n){return fs(e,nf(t.coords,Bi))-fs(e,nf(n.coords,Bi))}function Mt(e,t,n){e[0]=t[0]*n.size/te+n.offset[0],e[1]=t[1]*n.size/te+n.offset[1],e[2]=t[2]}const Br=yt();function Qu(e,t,n,i){var s;Br[0]=t[0][n],Br[1]=t[1][n],Br[2]=((s=t[2])!=null?s:[])[n],Mt(e,Br,i)}function Pt(e,t,n){e[0]=(t[0]-n.offset[0])*te/n.size,e[1]=(t[1]-n.offset[1])*te/n.size,e[2]=t[2]}function Lt(e){return re(2,32-e)}function cc(e){return e[0]>=0&&e[0]<=te&&e[1]>=0&&e[1]<=te}function Ui(e,t){return e*4294967296/(te*Math.pow(2,t))}function nt(e){return Te(e/ls*te,0,Ge)}const ef=te/ls;function tf(e){return e/te*ls}function zi(e){const t=Lt(e[2]),n=2147483648;return at(e[0]*t-n,e[1]*t-n,0)}function _g(e){return[e[0]+2147483648,e[1]+2147483648,32,32]}function nf(e,t){const n=Lt(e[2]),i=2147483648;return Oe(t,(e[0]+.5)*n-i,(e[1]+.5)*n-i,0)}function lc(e,t,n=!1){const s=Lt(t),r=n?Math.min(2147483647,e[1]):e[1],o=e[0]-s/2,a=r-s/2;return[(o+2147483648)/s,(a+2147483648)/s,t,t]}function Pg(e,t=1){const n=Math.max(e.max[0]-e.min[0],e.max[1]-e.min[1],1)*t,i=32-Math.log(n)/Math.LN2,s=Fe();return _r(s,e),lc(s,i)}const Ur=e=>{const[t,n,i,s]=e;return[t,re(2,i)-1-n,i,s]},Dt=(e,t)=>{Mt(Bi,t,e);const n=oe.toGeo(Bi);return oe.scaleFactor(n[1])};function As(e,t,n){return Mt(Bi,[e,t],n),oe.toGeo(Bi)}function Lg(e,t){const n=Math.min(e[0][0],e[1][0],e[2][0],e[3][0])+2147483648,i=Math.max(e[0][0],e[1][0],e[2][0],e[3][0])+2147483648,s=Math.floor(n/4294967296),r=Math.floor(i/4294967296);return t?[s]:Array.from({length:r-s+1},(o,a)=>a+s)}function dc(e,t){return tt.fromGeo(As(t[0],t[1],e))}function Nn(e,t,n,i){const s=[];return Mt(s,i,n),Sr(oe.toGeo(s),e)<t}function sf(e,t,n){const i=ct(n),s=te;return Nn(e,t,i,[0,s/2,0])||Nn(e,t,i,[s,s/2,0])||Nn(e,t,i,[s/2,s,0])||Nn(e,t,i,[s/2,0,0])||Nn(e,t,i,[0,0,0])||Nn(e,t,i,[0,s,0])||Nn(e,t,i,[s,s,0])||Nn(e,t,i,[s,0,0])}function zr(e,t,n){const i=[];return Mt(i,n,t),e.ecef.project(tt.fromGeo(oe.toGeo(i)))}function Gr(e,t,n){const[,i,s]=n;if(i===0||i===re(2,s)-1)return!0;const r=ct(n),o=te,a=[zr(t,r,[0,0,0]),zr(t,r,[0,o,0]),zr(t,r,[o,o,0]),zr(t,r,[o,0,0])],c=a.map(f=>f[0]),l=a.map(f=>f[1]),d={min:[Math.min(...c),Math.min(...l)],max:[Math.max(...c),Math.max(...l)]},u={min:[e.viewport.left,e.viewport.top],max:[e.viewport.left+e.size[0],e.viewport.top+e.size[1]]};return Ya(d,u)}function Dg(e,t,n,i,s){const a=new Map,c=[e],l=[];for(l.push(e);c.length;){if(l.length>300){console.warn("collectVisibleGlobeTiles: too many tiles",l.length);break}if(c.length>500){console.warn("collectVisibleGlobeTiles: queue overflow");break}const d=c.shift();if(d){const[u,f,h]=d;a.set(u+"."+f+"."+h,!0),Og(d,a,t,n).filter(w=>Gr(s,i,w)).forEach(w=>{const[p,y,b]=w;a.set(p+"."+y+"."+b,!0),l.push(w),c.push(w)})}}return l}function Og(e,t,n,i){const[s,r,o,a]=e,c=re(2,o)-1,l=p=>p>c?0:p<0?c:p,d=([p,y,b,v])=>((y>c||y<0)&&(y=y>c?c:0,p=b===0?p:(p+re(2,b-1))%re(2,b)),[p,y,b,v]),u=[l(s-1),r,o,a],f=[l(s+1),r,o,a],h=d([s,r-1,o,a]),g=d([s,r+1,o,a]);return[f,g,h,u].filter(p=>{const[y,b,v]=p;return!t.has(y+"."+b+"."+v)}).filter(p=>sf(n,i,p))}function Fg(e,t,n,i=0){return""}var uc=(e=>(e[e.Tile=0]="Tile",e[e.Custom=1]="Custom",e))(uc||{});class Cg{constructor(t){var n;this._enable=!1,this.name=t.name,this.index=t.index,this.location=t.location!==void 0?t.location:-1,this.locationsCount=(n=t.locationsCount)!=null?n:1,rf(this.locationsCount)}bindLocation(t,n){return this.location!==-1&&this.index!==!0&&t.bindAttribLocation(n,this.location,this.name),this}getLocation(t,n){return this.location===-1&&this.index!==!0&&(this.location=t.getAttribLocation(n,this.name)),this}bind(t,n){if(!this._enable&&this.index!==!0){for(let i=0;i<this.locationsCount;i++)t.enableVertexAttribArray(this.location+i);this._enable=!0}return n.bind(this.location,void 0),this}disable(t){if(this._enable&&this.index!==!0){for(let n=0;n<this.locationsCount;n++)t.disableVertexAttribArray(this.location+n);this._enable=!1}return this}}function rf(e){if(e<0||e>4)throw new Error("[WebGl] Invalid attribute location count. Must be 1, 2, 3 or 4")}const ie=class ie{constructor(t,n,i,s=!1,r=!1){var a;this.elementsType=null,this.isDirty=!0,this._glBuffer=null,this._gl=t,this._initData=n,this.byteLength=n.byteLength,this.type=s?ie.ElementArrayBuffer:ie.ArrayBuffer,this.options=Object.assign({},ie.defaultOptions,i),this.drawType=(a=i==null?void 0:i.drawType)!=null?a:ie.StaticDraw;const o=[ie.UnsignedByte,ie.UnsignedShort,ie.UnsignedInt];s&&!o.includes(this.options.dataType)&&(console.warn("Please provide dataType of one of the following values:Buffer.UnsignedByte, Buffer.UnsignedShort, Buffer.UnsignedInt. Defaulting to UnsignedInt"),this.options.dataType=ie.UnsignedInt),this._preserveData=r}static _dataTypeSize(t){switch(t){case ie.Byte:case ie.UnsignedByte:return 1;case ie.UnsignedShort:case ie.Short:return 2;case ie.Float:case ie.Int:case ie.UnsignedInt:return 4}throw new Error(`[WebGl] Unsupported Buffer data type: ${String(t)}`)}memSizeJs(){var t,n;return(n=(t=this._initData)==null?void 0:t.byteLength)!=null?n:0}memSizeGPU(){return this.byteLength}bind(t,n,i,s){const r=this._gl;if(this._glBuffer||this.prepare(),this.type===ie.ArrayBuffer){r.bindBuffer(r.ARRAY_BUFFER,this._glBuffer),t=t||0,n=n||this.options,s=s!=null?s:1,rf(s);const o=this._toGlParam(n.dataType)||r.FLOAT;if(s===1)r.vertexAttribPointer(t,n.itemSize,o,n.normalized,n.stride,n.offset),this.bindVertexAttribDivisor(t,n,i);else{const a=ie._dataTypeSize(n.dataType);for(let c=0;c<s;c++)r.vertexAttribPointer(t+c,s,o,n.normalized,n.stride,n.offset+c*s*a),this.bindVertexAttribDivisor(t+c,n,i)}}else this.type===ie.ElementArrayBuffer&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,this._glBuffer);return this}remove(){return this._unprepare(),this}subData(t,n){const i=this._gl;this._glBuffer||this.prepare();const s=this._toGlParam(this.type)||i.ARRAY_BUFFER;return i.bindBuffer(s,this._glBuffer),i.bufferSubData(s,t,n),this}replaceData(t){t&&(this._initData=t),this.isDirty=!0}commitData(){const t=this._gl,n=this._toGlParam(this.type)||t.ARRAY_BUFFER,i=this._toGlParam(this.drawType)||t.STATIC_DRAW;t.bindBuffer(n,this._glBuffer),t.bufferData(n,this._initData,i),this.isDirty=!1}getGLType(){return this._toGlParam(this.options.dataType)}getData(){return this._initData}prepare(){return this._glBuffer=this._gl.createBuffer(),this.commitData(),this._preserveData||(this._initData=null),this}_unprepare(){this._glBuffer&&this._gl.deleteBuffer(this._glBuffer),this._glBuffer=null,this._initData=null,this.isDirty=!1}_toGlParam(t){const n=this._gl;return t===ie.ArrayBuffer?n.ARRAY_BUFFER:t===ie.ElementArrayBuffer?n.ELEMENT_ARRAY_BUFFER:t===ie.StaticDraw?n.STATIC_DRAW:t===ie.DynamicDraw?n.DYNAMIC_DRAW:t===ie.Byte?n.BYTE:t===ie.Short?n.SHORT:t===ie.Int?n.INT:t===ie.Float?n.FLOAT:t===ie.UnsignedByte?n.UNSIGNED_BYTE:t===ie.UnsignedShort?n.UNSIGNED_SHORT:t===ie.UnsignedInt?n.UNSIGNED_INT:null}_hasRealWebGLContext(){return typeof window!="undefined"&&("WebGLRenderingContext"in window||"WebGL2RenderingContext"in window)}bindVertexAttribDivisor(t,n,i){const s=this._gl;n.instanceDivisor&&this._hasRealWebGLContext()&&(s instanceof WebGLRenderingContext?i?i.vertexAttribDivisorANGLE(t,n.instanceDivisor):console.error("Can't set up instanced attribute divisor. Missing ANGLE_instanced_arrays extension"):s.vertexAttribDivisor(t,n.instanceDivisor))}};ie.ArrayBuffer=1,ie.ElementArrayBuffer=2,ie.StaticDraw=10,ie.DynamicDraw=11,ie.Float=20,ie.UnsignedByte=21,ie.UnsignedShort=22,ie.UnsignedInt=23,ie.Byte=24,ie.Short=25,ie.Int=26,ie.defaultOptions={itemSize:3,dataType:ie.Float,stride:0,offset:0,normalized:!1,instanceDivisor:0,drawType:ie.StaticDraw};let Ze=ie;function Rg(e){if(e===void 0)return;const t=window.WebGLRenderingContext,i={[t.UNSIGNED_BYTE]:Ze.UnsignedByte,[t.UNSIGNED_SHORT]:Ze.UnsignedShort,[t.UNSIGNED_INT]:Ze.UnsignedInt,[t.BYTE]:Ze.Byte,[t.SHORT]:Ze.Short,[t.INT]:Ze.Int,[t.FLOAT]:Ze.Float}[e];return i===void 0?(console.error(`Cannot translate ${e} gltf componentType`),NaN):i}function Ng(e){return e}var li=(e=>(e[e.Striped=1]="Striped",e[e.Entrance=2]="Entrance",e[e.Patterned=3]="Patterned",e))(li||{}),Es=(e=>(e[e.Line=0]="Line",e[e.Arrow=1]="Arrow",e[e.StartBorder=2]="StartBorder",e[e.LineEnding=3]="LineEnding",e))(Es||{}),_e=(e=>(e[e.TileCut=0]="TileCut",e[e.Butt=1]="Butt",e[e.Round=2]="Round",e))(_e||{});const Xe=Fe(),jr=Fe(),Gi=Fe(),kn=Fe(),xs=Fe(),dn=Fe(),fc=Fe(),Ot=Fe();let ji=0,Bn=0;function of(e,t,n,i,s,r,o,a,c,l,d){var u,f,h,g;if(!(r<2)){if(en(Xe,t[0],n[0],t[1],n[1]),ji=0,o===_e.Round){const w=l!==void 0?l[0]:0,p=d!==void 0?d[0]:0;hc(e,t[0],n[0],(u=i==null?void 0:i[0])!=null?u:0,(f=s==null?void 0:s[0])!=null?f:0,-Xe[0],-Xe[1],w,p,c)}for(let w=1;w<r;w++)kg(e,t,n,i,s,w,r,c,l,d);if(a===_e.Round){const w=l!==void 0?l[r-1]:0,p=d!==void 0?d[r-1]:0;hc(e,t[r-1],n[r-1],(h=i==null?void 0:i[r-1])!=null?h:0,(g=s==null?void 0:s[r-1])!=null?g:0,Xe[0],Xe[1],w,p,c)}}}function kg(e,t,n,i,s,r,o,a,c,l){var h,g,w,p,y,b,v,T,E,S;const d=r===o-1;if(je(xs,t[r-1],n[r-1]),je(dn,t[r],n[r]),c!==void 0&&l!==void 0?(je(Gi,c[r-1],l[r-1]),je(kn,c[r],l[r])):(je(Gi,0,0),je(kn,0,0)),Rn(Ot,Xe),d)Bn=0;else{je(fc,t[r+1],n[r+1]),en(jr,dn[0],dn[1],fc[0],fc[1]);const L=Te(Dn(Xe,jr),-1,1);if(L<=0)Bn=0,hc(e,dn[0],dn[1],(h=i==null?void 0:i[r])!=null?h:0,(g=s==null?void 0:s[r])!=null?g:0,Xe[0],Xe[1],kn[0],kn[1],a);else{const O=Math.sqrt((1-L)/(1+L)),B=gr(Dn(Ot,jr));Bn=O*B}}Bg(e,0,1,3,3,1,2);const u=Ot[0]*Ne,f=Ot[1]*Ne;di(e,xs[0],xs[1],(w=i==null?void 0:i[r-1])!=null?w:0,(p=s==null?void 0:s[r-1])!=null?p:0,(Ot[0]+Xe[0]*ji)*Ne,(Ot[1]+Xe[1]*ji)*Ne,u,f,Gi[0],Gi[1],a),di(e,xs[0],xs[1],(y=i==null?void 0:i[r-1])!=null?y:0,(b=s==null?void 0:s[r-1])!=null?b:0,(-Ot[0]-Xe[0]*ji)*Ne,(-Ot[1]-Xe[1]*ji)*Ne,-u,-f,Gi[0],Gi[1],a),di(e,dn[0],dn[1],(v=i==null?void 0:i[r])!=null?v:0,(T=s==null?void 0:s[r])!=null?T:0,(-Ot[0]+Xe[0]*Bn)*Ne,(-Ot[1]+Xe[1]*Bn)*Ne,-u,-f,kn[0],kn[1],a),di(e,dn[0],dn[1],(E=i==null?void 0:i[r])!=null?E:0,(S=s==null?void 0:s[r])!=null?S:0,(Ot[0]-Xe[0]*Bn)*Ne,(Ot[1]-Xe[1]*Bn)*Ne,u,f,kn[0],kn[1],a),d||(vr(Xe,jr),ji=Bn)}function hc(e,t,n,i,s,r,o,a,c,l){Ug(e,0,1,2);const d=-r*.01,u=-o*.01;di(e,t,n,i,s,r+d,o+u,r,o,a,c,l),di(e,t,n,i,s,-o+d,r+u,-o,r,a,c,l),di(e,t,n,i,s,o+d,-r+u,o,-r,a,c,l)}function di(e,t,n,i,s,r,o,a,c,l,d,u){const f=e.elements.offset*e.elements.stride,h=f>>1,g=f>>2;e.views.position[h]=z+t,e.views.position[h+1]=z+n,e.views.extender[f]=r*127,e.views.extender[f+1]=o*127,e.views.normal[f]=a*127,e.views.normal[f+1]=c*127,"height"in e.views&&(e.views.height[g]=i),"absZ"in e.views&&(e.views.absZ[g]=s),"shift"in e.views&&(e.views.shift[g]=l,e.views.shift[g+1]=d),"localID"in e.views&&(e.views.localID[g]=u),e.elements.offset++}function Bg(e,t,n,i,s,r,o){const a=e.indices.buffer,c=e.indices.offset,l=e.elements.offset;a[c]=l+t,a[c+1]=l+n,a[c+2]=l+i,a[c+3]=l+s,a[c+4]=l+r,a[c+5]=l+o,e.indices.offset=c+6}function Ug(e,t,n,i){const s=e.indices.buffer,r=e.indices.offset,o=e.elements.offset;s[r]=o+t,s[r+1]=o+n,s[r+2]=o+i,e.indices.offset=r+3}function Ce(e,t,n){return t.precomputes.forEach((i,s)=>{e.push(n.tileData[s])}),e}function _s(e,t){for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}const zg={x:0,y:1};function Gg(e){const t={};for(const n in e)e[n]&&(t[n]=Array.from(e[n]));return t}function Ps(e,t){for(const n in e){const i=zg[n];i!==void 0?e[n].push(t[i]):e[n].push(NaN)}}const af=32,cf=512;function jg(e,t,n,i,s){const r=[e[0][0],e[1][0]],o=be(90+i),a=[];Mt(a,r,s);const c=oe.toGeo(a),l=xr(c,t),d=xr(c,n),u=Math.sqrt(re(l,2)+re(d,2))/2,f=Math.atan(l/-d)+Math.PI+o,h=u*Math.cos(f),g=u*Math.sin(f),w=Math.atan(-l/-d)+Math.PI+o,p=u*Math.cos(w),y=u*Math.sin(w),b=Math.atan(-l/d)+2*Math.PI+o,v=u*Math.cos(b),T=u*Math.sin(b),E=Math.atan(l/d)+o,S=u*Math.cos(E),L=u*Math.sin(E),x=[],O=[],B=[],U=[];return Pt(x,[a[0]+h,a[1]+g],s),Pt(O,[a[0]+p,a[1]+y],s),Pt(B,[a[0]+v,a[1]+T],s),Pt(U,[a[0]+S,a[1]+L],s),[[x[0],O[0],B[0],U[0]],[x[1],O[1],B[1],U[1]]]}function Vr(e,t){const n=Math.max(e,t);return n*af>cf?cf/n:af}function lf(e){const t=Dt(e,[0,0]);return te/Lt(e.coords[2])*Ie*t}function Vg(e,t,n,i){if(isNaN(e.step)||isNaN(e.width))return n;const{tileProps:s,tileAttrs:r}=i,o=lf(t);let a=e.step*o;if(isNaN(a)&&(a=0),a===0)return n;const c=e.width*o,l={},d=n.x,u=n.y,f=d.length;for(const L in n)l[L]=[];let h=0;const g=[h];for(let L=1;L<f;L++)h+=On([d[L-1],u[L-1]],[d[L],u[L]]),g.push(h);const w=Fe(),p=Fe(),y=[0,0],b=Math.abs(h/Math.trunc(h/a)),v=[d[0],u[0]];let T=(e.stopLines?1:-1)*Math.sign(e.width),E=0,S=0;for(Ps(l,v),e.stopLines&&!r[s.beginningIsCut]&&(en(w,d[S],u[S],d[S+1],u[S+1]),Rn(p,w),xt(y,p,T*c),Gt(v,v,y),Ps(l,v),E+=b/2,T=-T);E<=h;){for(;E>g[S+1];)S++;if(en(w,d[S],u[S],d[S+1],u[S+1]),Rn(p,w),T>0)xt(y,p,T*c),Gt(v,v,y),xt(y,w,b/2),Gt(v,v,y),Ps(l,v);else{const L=Math.min(1,(E-g[S])/(g[S+1]-g[S]));fu(v,[d[S],u[S]],[d[S+1],u[S+1]],L),Ps(l,v)}T=-T,E+=b/2}return e.stopLines&&!r[s.endingIsCut]&&(xt(y,p,T*c),Gt(v,v,y),Ps(l,v)),l}function Hg(e,t,n,i){const s=lf(t),r=Dt(t,[0,0]),{tileProps:o,tileAttrs:a}=i,c=n.x.length,l=s*e.modelLength,d=s*(e.edgeMarging||0),u={x:[],y:[],xScaleDirection:[],yScaleDirection:[],scaleCorrection:[]};for(let f=1;f<c;f++){const h=[n.x[f],n.y[f]],g=[n.x[f-1],n.y[f-1]];f===1&&d>0&&!a[o.beginningIsCut]&&df(g,h,d),f===c-1&&d>0&&!a[o.endingIsCut]&&df(h,g,d),$g(u,g,h,l,r)}return u}function df(e,t,n){const i=On(t,e),s=t[0]-e[0],r=t[1]-e[1],o=s/i,a=r/i;e[0]=e[0]+o*n,e[1]=e[1]+a*n}function $g(e,t,n,i,s){const[r,o]=t,[a,c]=n,l=On(t,n),d=Math.max(Math.round(l/i),1),u=l/(d*i),f=a-r,h=c-o,g=f/l,w=h/l,p=l/d/2;for(let y=1;y<=d;y++){const b=y*(l/d),v=r+g*(b-p),T=o+w*(b-p),E=r+g*b,S=o+w*b;e.x.push(v),e.y.push(T),e.xScaleDirection.push(E),e.yScaleDirection.push(S),e.scaleCorrection.push(u*s)}return e}function Hr(e,t,n,i){if(!Yg(e)||e.length===0)return n;let s=Gg(n);for(const r of e){if(typeof r!="object"||!r)return console.warn(`Wrong value ${r} in modifiers list.`),null;if(!("type"in r))return console.warn(`Wrong value ${r} in modifiers list.`),null;switch(r.type){case"zigzag-modifier":s=Vg(r,t,s,i);break;case"to-points-modifier":s=Hg(r,t,s,i);break;default:return console.warn(`Expression with type ${r.type} cannot be used as geometry modifier.`),null}if(s===null)return null}return s}function Yg(e){return!!e&&Array.isArray(e)}const Wg=new Set(["bottomCenter","bottomRight","bottomLeft","topCenter","topRight","topLeft","rightBottom","rightCenter","rightTop","leftBottom","leftCenter","leftTop","centerCenter"]);function Zg(e){return Wg.has(e)}function Xg(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||e===null}function pc(e){if(Array.isArray(e)){const t=e;if(!t.length)return!1;if({zoom:!0,height:!0,coalesce:!0,"heatmap-density":!0,"shading-intensity":!0,objectAttr:!0,step:!0,interpolate:!0,all:!0,get:!0,sourceAttr:!0,featureState:!0,global:!0,match:!0,in:!0,any:!0,"!":!0,"==":!0,"!=":!0,">=":!0,">":!0,"<=":!0,"<":!0,"to-boolean":!0,"to-color":!0,"+":!0,"*":!0,"^":!0,log10:!0,random:!0,literal:!0,isBehindObjects:!0,"mappoints-to-meters":!0,"meters-to-pixels":!0,uint64:!0,"geometry-modifier":!0,pattern:!0,precompute:!0,"gltf-animation":!0,distance:!0,time:!0,"local-time":!0,"utc-time":!0,"texture-animation":!0,easing:!0,schedule:!0,mix:!0,readFromTarget:!0,vertexAttribute:!0,has:!0}[t[0]])return!0}return!1}function uf(e){return pc(e)&&e[0]==="literal"}function tn(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type!==void 0&&e.type!=="color"}function qg(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="color"}function ff(e,t){return Array.isArray(e)?e.length>0&&e.every(n=>typeof n===t):!1}function Jg(e){return ff(e,"string")}function un(e){return ff(e,"number")}function hf(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="object"}function Kg(e){const t=typeof e;return e===null||t==="string"||t==="number"||t==="boolean"||Jg(e)||un(e)}function pf(e){return Kg(e)||qg(e)||hf(e)}function Qg(e){return tn(e)&&e.type==="get"}function nn(e){return{type:"color",value:e}}function ew(e){return{type:"mix-color",color1:e.value1,color2:e.value2,factor:e.factor,factorInterpolate:e.factorInterpolate}}function Vi(e,t,n){return`${e}_${t}_${n}`}function $r(e){return`texture-${e}`}function mc(e,t){return e+"-"+t}function qe(e){return uf(e)&&Array.isArray(e[1])?e[1][0]:Array.isArray(e)?pc(e)?e:e[0]:e}function fn(e){if(uf(e)&&Array.isArray(e[1]))return e[1][1];if(Array.isArray(e)&&!pc(e)&&e[1]!==void 0)return e[1]}function it(e){if(typeof e=="number"||un(e))return e;if(e.type==="literalArray"&&un(e.array))return e.array;throw new Error("Unsupported simple literal expression. Can't resolve.")}function Ls(e,t=0){const n=Number(e);return isNaN(n)?t:n}function mf(e){return!!e&&typeof e=="object"&&e.type==="mix-options"}const yf=nn([0,0,0,0]);function gf(e){return typeof e!="string"?!1:/(#(?:[0-9a-f]{2}){2,4}|#[0-9a-f]{3}|(?:rgba?|hsla?)\((?:\d+%?(?:,|\s)+){2,3}[\s\/]*[\d\.]+%?\))/i.test(e)}function ui(e){return!!e&&typeof e=="object"&&e.type==="color"}function tw(e){return!!e&&typeof e=="object"&&e.type==="mix-color"}function yc(e){return!!e&&typeof e=="object"&&e.type==="gradient-color"}function Ds(e){const t=e.toLowerCase();let n=yf;switch(t[0]){case"#":n=iw(t);break;case"h":n=sw(t);break;case"r":n=rw(t);break}return n}function nw(e){return e.length<7?e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]+(e.length===5?e[4]+e[4]:"ff"):e.length===7?e+"ff":e}function iw(e){if(!new RegExp(`^#[a-f0-9]{${e.length-1}}$`).test(e)||![4,5,7,9].includes(e.length))return yf;const n=nw(e),i=parseInt(n[1]+n[2],16),s=parseInt(n[3]+n[4],16),r=parseInt(n[5]+n[6],16),o=parseInt(n[7]+n[8],16);return nn([i,s,r,o])}function sw(e){const t=wf(e);t[0]/=360,t[1]/=100,t[2]/=100;const[n,i,s]=ow(t[0],t[1],t[2]),r=t[3]!==void 0?t[3]*255:255;return nn([Math.round(n),Math.round(i),Math.round(s),Math.round(r)])}function rw(e){const[t,n,i,s]=wf(e),r=s!==void 0?s*255:255;return nn([Math.round(t),Math.round(n),Math.round(i),Math.round(r)])}function wf(e){return e.split("(")[1].split(")")[0].split(",").map(n=>parseFloat(n))}function gc(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function ow(e,t,n){if(t===0)return[n*255,n*255,n*255];const i=n<.5?n*(1+t):n+t-n*t,s=2*n-i;return[gc(s,i,e+1/3)*255,gc(s,i,e)*255,gc(s,i,e-1/3)*255]}function Yr(e){let t="",n=0;for(;n<e.length;){let i=e[n++];if(i>127){if(i>191&&i<224){if(n>=e.length)return console.error("Incomplete 2-byte sequence"),t;i=(i&31)<<6|e[n]&63}else if(i>223&&i<240){if(n+1>=e.length)return console.error("Incomplete 3-byte sequence"),t;i=(i&15)<<12|(e[n]&63)<<6|e[++n]&63}else if(i>239&&i<248){if(n+2>=e.length)return console.error("Incomplete 4-byte sequence"),t;i=(i&7)<<18|(e[n]&63)<<12|(e[++n]&63)<<6|e[++n]&63}else return console.error(`Unknown multibyte start 0x${i.toString(16)} at index ${n-1}`),t;++n}if(i<=65535)t+=String.fromCharCode(i);else if(i<=1114111)i-=65536,t+=String.fromCharCode(i>>10|55296),t+=String.fromCharCode(i&1023|56320);else return console.error(`Code point 0x${i.toString(16)} exceeds UTF-16 reach`),t}return t}function wc(e,t){if(e.length<=t||e.indexOf(`
`)!==-1)return e;const n=[];return e.split(" ").forEach(i=>{const s=n.length-1;n.length===0||n[s].length+i.length>=t?n.push(i):n[s]+=" "+i}),n.join(`
`)}function vc(e){return Math.floor(e/256)}function aw(e){const t=new Set;return e.forEach(n=>{if(n!==void 0)for(let i=0;i<n.length;i++){const s=n.charCodeAt(i);s!==Ut.bomCharCode&&t.add(vc(s))}}),Array.from(t)}function cw(e,t,n=1,i="…"){if(e.length<=t)return e;const s=t-i.length;switch(n){case 2:return e.substring(0,s)+i;case 1:{const r=Math.ceil(s/2);return e.substring(0,r)+i+e.substring(e.length-(s-r),e.length)}}}function lw(e,t){ke(`No glyph for character ${e} (code = ${t}, range = ${vc(t)})`)}const vf=new Set;function dw(e){console.group("Gltf model error"),console.warn("Stage:",e.layer),e.message&&console.warn("Message:",e.message),e.originalError&&(console.groupCollapsed("Original error"),console.warn(e.originalError),console.groupEnd()),console.groupEnd()}function bf(e){ke(`Got an empty response from the "${e}" tile generation.`)}function ke(e){vf.has(e)||(console.log(e),vf.add(e))}const uw=2166136261,fw=16777619;function If(e,t){let n=uw;for(const i of t)n=n^i,n=n*fw;e.randomSeed=Math.abs(n)}function Os(e,t,n){let i=.5;return e.randomSeed?(e.randomSeed=e.randomSeed*16807%2147483647,i=(e.randomSeed-1)/2147483646):ke("Resolve 'random': random seed is absent, the mean value between start and end will be used."),i*(n-t)+t}function hw(e=128){const t=[],n=[];for(let i=0;i<e;i++)t.push(Mf(i,2)),n.push(Mf(i,3));return{base2:t,base3:n}}function Mf(e,t){let n=0,i=1/t;for(;e>0;)n=n+i*(e%t),e=Math.floor(e/t),i=i/t;return n}function pw(e,t){const n=[];for(let i=0;i<t;i++){const s=Os(e,0,2*Math.PI),r=Math.acos(Os(e,0,2)-1),o=Math.sin(r)*Math.cos(s),a=Math.sin(r)*Math.sin(s),c=Math.cos(r);n.push(at(o,a,c))}return n}var st=(e=>(e[e.Uniform=1]="Uniform",e[e.Labeling=2]="Labeling",e[e.Generator=3]="Generator",e))(st||{});const Wr=-1;var Fs=(e=>(e.global="global",e.none="none",e))(Fs||{}),Un=(e=>(e[e.Pixels=0]="Pixels",e[e.Meters=1]="Meters",e))(Un||{});const Tf="bottomCenter";function Qe(e,t){for(const n in t)t[n]!==void 0&&(e[n]=t[n])}function mw(e){const n={color:"#000000",textureImage:"",textureSize:16,textureOpacity:1,strokeColor:"#00000000",strokeWidth:1,visibility:"visible",metallic:1,roughness:0,normalMapTextureImage:"",normalMapTextureSize:16,normalMapTextureAnimation:null};if(Qe(n,e),e.strokeColor===void 0&&!n.textureImage&&(n.strokeColor=n.color),!Array.isArray(n.textureSize)||n.textureSize[0]==="step"||n.textureSize[0]==="literal")return n;if(!n.textureSize.length)n.textureSize=16;else if(un(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function yw(e){const n={color:"#000000",textureImage:"",textureSize:16,textureOpacity:1,strokeColor:"#00000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible",elevation:0};if(Qe(n,e),e.strokeColor===void 0&&!n.textureImage&&(n.strokeColor=n.color),!Array.isArray(n.textureSize)||n.textureSize[0]==="step"||n.textureSize[0]==="literal")return n;if(!n.textureSize.length)n.textureSize=16;else if(un(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function gw(e){const t={iconImage:"",color:"#FFFFFF",rotation:0,width:1,visibility:"visible"};return Qe(t,e),e.height===void 0&&(t.height=t.width),t}function ww(e){const t={topColor:"#000000",strokeColor:"#000000",strokeWidth:1,sideColor:"#000000",sideStrokeColor:"#000000",height:["mappoints-to-meters",["get","db_height"]],nearCameraFade:2500,visibility:"visible",sideTextures:[]};return Qe(t,e),e.strokeColor===void 0&&(t.strokeColor=t.topColor),e.sideColor===void 0&&(t.sideColor=t.topColor),e.sideStrokeColor===void 0&&(t.sideStrokeColor=t.sideColor),t}function vw(e){const t={color:"#000000",width:1,shift:0,geometryModifier:["geometry-modifier"],pattern:["pattern","none"],startCap:"round",endCap:"round",mode:"2d",visibility:"visible"};return Qe(t,e),t}function bw(e){const t={color:"#000000",strokeColor:"#000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible"};return Qe(t,e),e.strokeColor===void 0&&(t.strokeColor=t.color),t}function Iw(e){const t={sideColor:"#000000",strokeColor:"#000000",strokeWidth:1,sideStrokeColor:"#000000",height:0,visibility:"visible",nearCameraFade:2500};return Qe(t,e),e.strokeColor===void 0&&(t.strokeColor=t.sideColor),e.sideStrokeColor===void 0&&(t.sideStrokeColor=t.sideColor),t}function Mw(e){const t={textField:["get","db_label"],textFont:"Noto_Sans",textColor:"#000000",textFontSize:16,textLetterSpacing:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textPriority:0,textLabelingSideMargin:0,textDuplicationSpacing:0,lineEndingOffsets:0,visibility:"visible",labelingGroup:Gn};return Qe(t,e),t}function Tw(e){const t={color:"#000000",lineWidth:2,lineLength:10,tipWidth:1.5,tipHeight:2,roundingRadius:0,priority:0,duplicationSpacing:0,endingOffsets:0,visibility:"visible",labelingGroup:Gn};return Qe(t,e),t}function Sw(e){const t={color:"#000000",gapColor:"#00000000",width:1,shift:0,gapLength:1,dashLength:1,gapTurnsOnly:!1,geometryModifier:["geometry-modifier"],mode:"2d",visibility:"visible"};return Qe(t,e),t}function Aw(e){const t={color:"#000000",width:1,shift:0,visibility:"visible"};return Qe(t,e),t}function Ew(e){const t={color:"#ffffff",strokeColor:"#3388ff",strokeColor2:"#00000000",width:20,strokeWidth:3,strokeWidth2:0,visibility:"visible"};return Qe(t,e),t}function xw(e){const t={allowOverlap:!1,allowElevation:!1,elevation:NaN,iconOpacity:1,iconImage:"",iconAnchor:[.5,.5],iconOffset:[0,0],iconWidth:16,iconTextField:["get","db_label2"],iconTextFont:"",iconTextAnchor:[.5,.5],iconTextOffset:[0,0],iconTextColor:"#000000",iconTextFontSize:16,iconTextLineHeight:1.2,iconTextLetterSpacing:0,iconTextPadding:[0,0,0,0],iconTextHaloWidth:0,iconTextHaloColor:"rgba(0, 0, 0, 0)",iconPriority:0,iconRotation:0,iconLabelingGroup:Gn,iconLabelingMargin:{topBottom:0,leftRight:0},textField:[["get","db_label"],["get","db_label2"]],textFont:"",textColor:"#000000",textFontSize:16,textLineHeight:1.2,textLetterSpacing:0,textPlacement:Tf,textOffset:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textLabelingMargin:{topBottom:0,leftRight:0},textPriority:0,textMaxLengthPerLine:30,visibility:"visible",textLabelingGroup:Gn,duplicationSpacing:100,endingOffsets:0};return Qe(t,e),t}function _w(e){const t={color:"#000000",strokeColor:"#000000",lineWidth:1,strokeWidth:0,tipWidth:1,tipHeight:1,roundingRadius:3,animation:{type:"appearance",tipMovementAmplitude:0},visibility:"visible"};return e.strokeColor===void 0&&(t.strokeColor=t.color),Qe(t,e),t}function Pw(e){const t={opacity:1,visibility:"visible"};return Qe(t,e),t}function Lw(e){return Pn(e,{color:["interpolate",["linear"],["heatmap-density"],0,"rgba(53, 136, 253, 0)",.2,"rgba(53, 136, 253, 0.2)",.4,"rgb(255, 201, 77)",.6,"rgb(255, 202, 20)",.75,"rgb(245, 0, 7)",1,"rgb(255, 0, 0)"],radius:30,opacity:1,intensity:1,weight:1,downscale:1,visibility:"visible"})}function Dw(e){return Pn(e,{shadingIntensity:["interpolate",["linear"],["zoom"],12,0,14.5,.7],verticalScale:1,shadingPalette:["interpolate",["linear"],["shading-intensity"],0,0,1,1],lightingDirection:322})}function Ow(e){return Pn(e,{modelSrc:"",offset:0,scale:1,rotation:0,color:"#fff",linkedIds:"",visibility:"visible",colorTextureUvIndex:0,nearCameraFade:2500,ignoreGlobalLighting:!1,showRatio:1,metallic:NaN,roughness:NaN,preventObjectsHiding:!1,lightingModel:"phong",playAnimation:-1,scene:NaN,geometryModifier:["geometry-modifier"]})}function Fw(e){const t={visibility:"visible",sideColor:"#000000",borderTopColor:"#000000",bottomColor:"#000000",strokeColor:"#000000",strokeWidth:1,debug:!1,thickness:1,borderHeight:0,borderWidth:.3,color:"#000000",nearCameraFade:0,tunnelHeight:5};return Qe(t,e),e.borderTopColor===void 0&&(t.borderTopColor=t.color),e.strokeColor===void 0&&(t.strokeColor=t.color),e.sideColor===void 0&&(t.sideColor=t.color),e.bottomColor===void 0&&(t.bottomColor=t.color),t}function Cw(e){const t={visibility:"visible",sideColor:"#000000",topColor:"#000000",bottomColor:"#000000",strokeColor:"#000000",strokeWidth:1,color:"#ffffff",nearCameraFade:0};return Qe(t,e),t}function Rw(e){return Pn(e,{skyColor:"#6EC0FF00",fogColor:"#FAFDFF00",starsIntensity:1})}function Nw(e){const t={sources:{sun:{type:"directional",altitude:50,azimuth:230,color:"#FFFFFF",intensity:.2},atmosphere:{type:"ambient",color:"#FFFFFF",intensity:.85}},lightingModes:{[Fs.global]:["sun","atmosphere"]},defaultLightingMode:"global"},n=Pn(e!=null?e:{},t);return n.lightingModes[Fs.none]=[],n}function kw(e){const t={light:{},normal:{},immersive:{}},n=Pn(e!=null?e:{},t);return n.light.transparentBuildingsOff=!0,n.light.AALinesOff=!0,n}const zn="__overlapped",bc="__commercial",Gn="default",Ic={groups:[Gn,zn,bc],overlay:[[Gn,zn]],intersect:[[]]},Bw="#F5F2E0",fi=e=>{e&&Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]})},Uw=e=>{var t;fi(e),e.type==="group"?(fi(e.commonDefaults),fi((t=e.commonDefaults)==null?void 0:t.style),fi(e.layerTypeDefaults),e.layerTypeDefaults&&Object.values(e.layerTypeDefaults).forEach(n=>{fi(n),fi(n==null?void 0:n.style)})):e.type!=="custom"&&fi(e.style)},Sf=(e,t=!1)=>{t||console.warn("assertUnreachable: ",e)},hi=null,Af=[0,0,0];function $(e,t){var n,i,s;if(!tn(e))return e;if(t.allowedExpressions&&!t.allowedExpressions.has(e.type))return ke(`Expression of type ${e.type} is not allowed here`),hi;switch(e.type){case"schedule":return Jw(e,t);case"time":return jw(e,t);case"objectAttr":return Hw(e,t);case"coalesce":return xf(e,t);case"all":return zw(e,t);case"any":return Gw(e,t);case"featureState":return Yw(e,t);case"get":return Lf(e,t);case"global":return Ww(e,t);case"sourceAttr":return Vw(e,t);case"in":return rv(e,t);case"has":return ov(e,t);case"interpolate":return Zw(e,t);case"match":return Xw(e,t);case"step":return qw(e,t);case"to-boolean":return tv(e,t);case"to-color":return Kw(e,t);case"mappoints-to-meters":return Qw(e,t);case"meters-to-pixels":return ev(e,t);case"!":return nv(e,t);case"==":case"!=":return iv(e,t);case">":case"<":case">=":case"<=":return sv(e,t);case"zoom":if(t.type==="binder"||t.type==="labeling")return t.styleZoom;if(t.type==="generator")return(i=(n=t.tileInfo)==null?void 0:n.coords[3])!=null?i:0;const{type:r}=t;return Sf(r),hi;case"distance":if(t.type==="binder"){const a=oe.toGeo(t.objectCenter),c=oe.scaleFactor(a[1])*Ie;return Va(t.objectCenter,t.cameraCenter)/c}else return ke(`Distance expression can't be resolved in the ${t.type} context`),hi;case"height":return 1;case"+":return av(e,t);case"*":return cv(e,t);case"^":return lv(e,t);case"log10":return dv(e,t);case"random":return uv(e,t);case"literalArray":return fv(e,t);case"literalObject":return{type:"object",value:e.object};case"isBehindObjects":return t.type==="binder"?t.isBehind:(ke(`isBehindObjects expression cannot be used in ${t.type} context`),hi);case"geometry-modifier":return e.modifiers;case"line-pattern":return[e.patternType,...e.parameters.map(a=>$(a,t))];case"precompute":return(s=t.tileData[e.precomputeIndex])!=null?s:null;case"gltf-animation":return _f(e,t);case"local-time":return Ef(e,t);case"utc-time":return Ef(e,t);case"texture-animation":return Pf(e,t);case"easing":return e.options;case"mix":return $w(e,t);default:return ke(`Not supported expression type <<${e.type}>> in ${JSON.stringify(e)}`),hi}}function zw(e,t){return e.array.every(n=>$(n,t)===!0)}function Gw(e,t){return e.array.some(n=>$(n,t)===!0)}function Ef(e,t){const n=Date.now()+ +(t.styleState._customUserTimeOffset||0);if(e.type==="local-time"){const i=e.offset?+($(e.offset,t)||0)*6e4:0;return n+i}if(e.type==="utc-time"){const i=e.offset?+($(e.offset,t)||0)*6e4:0;return n+new Date().getTimezoneOffset()*6e4+i}return n}function jw(e,t){const n=i=>{const s=$(e.timeSource,t),r=new Date(+(s||0));return i==="day-minutes-720"?(r.getHours()%12||0)*60+r.getMinutes():r.getTime()};if(t.type==="binder"){if(t.callBackFn){const i=Date.now()+ +(t.styleState._customUserTimeOffset||0),s=Math.floor(i/6e4)*6e4+6e4;t.callBackFn(s)}return Array.isArray(e.format)?e.format.map(i=>n(i)):n(e.format)}return n("timestamp")}function xf(e,t){for(const n of e.array){const i=$(n,t);if(i!==null)return i}return null}function Vw(e,t){var n;return t.type==="generator"&&(n=t.sourceAttrs[e.property])!=null?n:null}function Hw(e,t){return t.type==="binder"&&t.dynamicObject&&t.dynamicObject[e.property]||null}function _f(e,t){const n={type:"animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=$(i,t)):tn(e)||(n[0]=e),n}function Pf(e,t){const n={type:"texture-animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=$(i,t)):tn(e)||(n[0]=e),n}function $w(e,t){const{factorInterpolate:n}=e,i={type:"mix-options",value1:$(e.value1,t),value2:$(e.value2,t),factor:e.factor};if(n){const{steps:s,base:r}=n;i.factorInterpolate={base:r,steps:[ae(s[0].key,t,0),ae(s[0].value,t,0),ae(s[1].key,t,1),ae(s[1].value,t,1)]}}return i}function Yw(e,t){var n;if(t.type==="generator"){const i=(n=t.featureAttrs[t.tileProps[e.property]])!=null?n:null;return Number.isNaN(i)?null:i}else throw new Error("Feature state expression can be resolved only in generator context")}function Lf(e,t){var n;if(t.type==="generator"){let i=(n=t.tileAttrs[t.tileProps[e.property]])!=null?n:null;return typeof i=="object"&&i!==null&&!Array.isArray(i)&&(i={type:"object",value:i}),Number.isNaN(i)?null:i}else throw new Error("Get expression can be resolved only in generator context")}function Ww(e,t){const n=t.styleState[e.property];return n==null?null:typeof n=="object"&&!Array.isArray(n)?{type:"object",value:n}:n}function Zw(e,t){if(e.steps.length===0)return ke("Interpolate expression contains 0 steps, cannot interpolate"),hi;const n=$(e.steps[0].value,t),i=$(e.argument,t);if(typeof i!="number")return ke(`Interpolate value resolved to non-number value: ${i} ${e.argument}`),0;if(ui(n)){if(tn(e.argument)&&e.argument.type==="height"){const s={type:"gradient-color",values:[],steps:[]};return e.steps.forEach(r=>{const o=ae(r.key,t),a=$(r.value,t);ui(a)&&!Number.isNaN(o)&&(s.values.push({type:"color",value:a.value}),s.steps.push(o))}),s.steps.length!==2?(ke("Gradient expression must resolve 2 steps"),hi):s}return Of(e,i,t)}return Df(e,i,t)}function Xw(e,t){var s;const n=$(e.input,t),i=e.cases.find(r=>r.values.has(n));return $((s=i==null?void 0:i.output)!=null?s:e.defaultOutput,t)}function qw(e,t){const n=Number($(e.value,t)),i=Rs(e,n,t)-1;return $(e.steps[i].value,t)}function Jw(e,t){var w,p;const s=(y,b)=>{const v=Date.now()+ +(b.styleState._customUserTimeOffset||0);return Math.floor(v/6e4)*6e4+y*6e4},r=e.detailResult||!1,o=y=>{if(t.type==="binder"&&t.callBackFn){const b=s(y,t);t.callBackFn(b)}};let a=$(e.steps,t);typeof a=="string"&&(a=JSON.parse(a));const c=new Array,l=new Array;if(Array.isArray(a)){c.push({key:0,value:a[0]});for(let y=1;y<a.length;y+=3){const v={key:Math.trunc(a[y]/1440)*1440,value:a[0]};l.push(v);const T={key:a[y],value:a[y+2]};c.push(T);const E={key:a[y+1],value:a[0]};c.push(E)}}for(const y of l)c.find(b=>b.key===y.key)||c.push(y);c.sort((y,b)=>y.key<b.key?-1:1);const d=Number($(e.time,t)),u=new Date(d),f=u.getHours()*60+u.getMinutes()+(u.getDay()||7)*1440,h=Rs({steps:c},f%1440,t)-1,g=Rs({steps:c},f,t)-1;if(c[g]&&Math.trunc(c[g]&&c[g].key/1440)===Math.trunc(f/1440)){const y=Math.min((((w=c[g+1])==null?void 0:w.key)||11519)-f,1439-f%1440);o(y);const b=$(c[g].value,t)||NaN;return r?{type:"schedule-detailed-result",value:b,nextStepStartsAt:s(y,t),currentStepElapsed:(f-c[g].key)*6e4}:b}if(c[h]){const y=Math.min(((p=c[h+1])==null?void 0:p.key)||1439,1439)-f%1440;o(y);const b=$(c[h].value,t)||NaN;return r?{type:"schedule-detailed-result",value:b,nextStepStartsAt:s(y,t),currentStepElapsed:(f%1440-c[h].key)*6e4}:b}return r?{type:"schedule-detailed-result",value:NaN,nextStepStartsAt:NaN,currentStepElapsed:NaN}:NaN}function Kw(e,t){const n=$(e.value,t);return gf(n)?Ds(n):ui(n)?n:(console.warn(`Can't resolve expression. Must be color, but got ${n}`),nn([0,0,0,0]))}function Qw(e,t){if(t.type!=="generator"||!t.tileInfo)throw new Error("Выражение `mappoints-to-meters` можно резолвить только в контексте генератора");return $(e.value,t)/(Ie*Dt(t.tileInfo,[0,0]))}function ev(e,t){const n=ae(e.value,t);let i,s=n*256/ka;if(t.type==="generator"){if(!t.tileInfo)return null;i=t.tileInfo.coords[3],s*=Dt(t.tileInfo,[0,0])}else i=t.styleZoom;return s*re(2,i+1)}function tv(e,t){return!!$(e.value,t)}function nv(e,t){return!$(e.value,t)}function iv(e,t){const n=$(e.leftValue,t),i=$(e.rightValue,t);switch(e.type){case"==":return n===i;case"!=":return n!==i}}function sv(e,t){const n=$(e.leftValue,t);if(n===null)return null;const i=$(e.rightValue,t);if(i===null)return null;switch(e.type){case"<":return n<i;case">":return n>i;case"<=":return n<=i;case">=":return n>=i}}function rv(e,t){const n=$(e.item,t),i=$(e.collection,t);return i===null?!1:typeof i!="object"?(ke(`InExpression second argument resolved to non-object/non-array value: ${i}`),null):Array.isArray(i)?i.some(s=>s===n):hf(i)?Object.prototype.hasOwnProperty.call(i.value,n):(ke(`InExpression second argument resolved incorrectly: ${i}`),null)}function ov(e,t){if(t.type==="generator"){const n=t.tileProps[e.property];return n===void 0||!(n in t.tileAttrs)?!1:!Number.isNaN(t.tileAttrs[n])}else throw new Error("Has expression can be resolved only in generator context")}function av(e,t){const n=e.array.map(i=>$(i,t));return un(n)?n.reduce((i,s)=>i+s,0):(ke(`Resolve AdditionExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function cv(e,t){const n=e.array.map(i=>$(i,t));return un(n)?n.reduce((i,s)=>i*s,1):(ke(`Resolve MultiplicationExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function lv(e,t){const n=$(e.base,t);if(typeof n!="number")return ke(`Resolve PowExpression: base resolved as non-number value: ${n}`),null;const i=$(e.exponent,t);return typeof i!="number"?(ke(`Resolve PowExpression: exponent resolved as non-number value: ${i}`),null):Math.pow(n,i)}function dv(e,t){const n=$(e.value,t);return typeof n!="number"?(ke(`Resolve Log10Expression: value resolved as non-number value: ${n}`),null):Math.log10(n)}function uv(e,t){const n=$(e.start,t);if(typeof n!="number")return ke(`Resolve RandomizationExpression: start resolved as non-number value: ${n}`),null;const i=$(e.end,t);return typeof i!="number"?(ke(`Resolve RandomizationExpression: end resolved as non-number value: ${i}`),null):i<n?(ke("Resolve RandomizationExpression: end cannot be less than start."),null):Os(t,n,i)}function fv(e,t){return e.array.map(n=>$(n,t))}function Df(e,t,n){const i=Rs(e,t,n);if(i===0)return Number($(e.steps[0].value,n));if(i===e.steps.length)return pv(e,n,t);const s=Number($(e.steps[i-1].value,n));if(n.type==="labeling"&&n.interpolateExpressionAsStep)return s;const r=Cf(e,t,i,n),o=Number($(e.steps[i].value,n));return(1-r)*s+r*o}function jn(e,t,n=!1){const i=$(e,t);return ui(i)?i:yc(i)?i.values[1]:mf(i)?ui(i.value1)&&ui(i.value2)?n?ew(i):(console.warn("Mixing color is not supported here."),nn([0,0,0,0])):(console.warn(`Mix values cannot be converted to colors in ${JSON.stringify(i)}`),nn([0,0,0,0])):(console.warn(`Can't resolve expression. Must be color, but got ${i}`),nn([0,0,0,0]))}function hv(e,t){const n=$(e,t);return yc(n)?n:null}function ae(e,t,n=NaN){const i=$(e,t);return typeof i=="number"?i:n}function lt(e,t,n=""){const i=$(e,t);return typeof i=="string"?i:n}function Zr(e,t,n=Tf){const i=$(e,t);return Zg(i)?i:n}function Of(e,t,n){const i=Rs(e,t,n);if(i===0)return jn(e.steps[0].value,n);if(i===e.steps.length)return jn(e.steps[e.steps.length-1].value,n);const s=Cf(e,t,i,n),r=jn(e.steps[i-1].value,n).value,o=jn(e.steps[i].value,n).value;return nn([r[0]*(1-s)+o[0]*s,r[1]*(1-s)+o[1]*s,r[2]*(1-s)+o[2]*s,r[3]*(1-s)+o[3]*s])}function pv(e,t,n){const i=e.steps[e.steps.length-1],s=e.base;return s===1?ae(i.value,t):ae(i.value,t)*Math.pow(s,n-ae(i.key,t))}function Ff(e,t,n,i=!1,s,r,o){return{type:"binder",styleZoom:e,styleState:t,tileData:n,randomSeed:0,isBehind:i,dynamicObject:s,cameraCenter:r!=null?r:Af,objectCenter:o!=null?o:Af}}function Vt(e,t,n,i){return{type:"labeling",styleZoom:e,styleState:t,interpolateExpressionAsStep:n,randomSeed:0,tileData:i}}function Cs(e,t,n,i,s,r,o){return{type:"generator",styleState:e,tileProps:n,tileAttrs:i,id:r,tileData:[],featureAttrs:s,sourceAttrs:t,randomSeed:0,tileInfo:o}}function Rs(e,t,n){let i=0;for(;i<e.steps.length&&!(t<ae(e.steps[i].key,n));)i++;return i}function Cf(e,t,n,i){const s=e.base,r=ae(e.steps[n].key,i)-ae(e.steps[n-1].key,i),o=t-ae(e.steps[n-1].key,i);return s===1?o/r:(Math.pow(s,o)-1)/(Math.pow(s,r)-1)}function mv(e){const[t,n,i,s]=e.value;return[((t*s+127)/255>>>0)/255,((n*s+127)/255>>>0)/255,((i*s+127)/255>>>0)/255,s/255]}function pi(e,t,n,i=!1){const s=[];return mi(s,e,t,n),i?s:Array.from(new Set(s))}function yv(e,t){const n={};return Object.keys(e).forEach(i=>{n[i]=gv(e[i],t)}),n}const Hi=Wa();function Rf(e,t){const n=new Float32Array(3);return Oe(n,1,0,0),ly(Hi),fy(Hi,Hi,-be(t-90)),uy(Hi,Hi,-be(e)),C1(n,n,Hi),qt(n,n),Tu(n,n),n}function gv(e,t){var i,s;const n={ambientColorIntensity:new Float32Array(jn(e.ambientColor,t).value.map(r=>r/255)),dir1ColorIntensity:new Float32Array(jn(e.dir1Color,t).value.map(r=>r/255)),dir1Direction:Rf($(e.dir1Altitude,t),$(e.dir1Azimuth,t)),dir2ColorIntensity:new Float32Array(jn(e.dir2Color,t).value.map(r=>r/255)),dir2Direction:Rf($(e.dir2Altitude,t),$(e.dir2Azimuth,t)),shadowLightIndex:(i=e.shadowLightIndex)!=null?i:-1,shadowRadius:(s=e.shadowRadius)!=null?s:1};return n.ambientColorIntensity[3]=$(e.ambientIntensity,t),n.dir1ColorIntensity[3]=$(e.dir1Intensity,t),n.dir2ColorIntensity[3]=$(e.dir2Intensity,t),n}function mi(e,t,n,i){if(!tn(t)){e.push(t);return}switch(t.type){case"all":return wv(e,t,n,i);case"match":return vv(e,t,n,i);case"step":return bv(e,t,n,i);case"interpolate":return Iv(e,t,n,i);case"coalesce":{if(!n){console.error("There is no context to resolve the expression. The value from data will not be added to the result.");return}const s=xf(t,n);e.push(s);return}case"precompute":if(i){const s=i.precomputes[t.precomputeIndex].expr;mi(e,s,n,i);return}break;case"get":{if(!n){console.error("There is no context to resolve the expression. The value from data will not be added to the result.");return}const s=Lf(t,n);e.push(s);return}}}function wv(e,t,n,i){t.array.forEach(s=>mi(e,s,n,i))}function vv(e,t,n,i){mi(e,t.defaultOutput),t.cases.forEach(s=>mi(e,s.output,n,i))}function bv(e,t,n,i){t.steps.forEach(s=>mi(e,s.value,n,i))}function Iv(e,t,n,i){t.steps.forEach(s=>mi(e,s.value,n,i))}const Ht=1,$t=-1,Yt=[.5,.5],Ft=[.5,.5],Se=[.5,.5],$i=[.5,.5],Mc=[0,0];let Tt,ge,Me,Ae=0,St=0,Je=0,rt=0;const Mv={x:0,y:0,z:0,xn2:0,yn2:0,xn1:0,yn1:0,patternedLine:!1,noTurn:!0,leftTurn:!1,sharpTurn:!1,reverseTurn:!1,extender:[.5,.5],faExtender:[.5,.5],saExtender:[.5,.5]},Tv=1-1e-4,Sv=0,Nf=-.9;function Av(e,t,n,i,s,r,o,a){const c=Mv;c.x=e,c.y=t,c.z=n,c.xn2=i,c.yn2=s,c.xn1=r,c.yn1=o,c.patternedLine=a;const l=i*r+s*o;return c.noTurn=l>Tv,c.leftTurn=i*-o+s*r<0,c.sharpTurn=l<Sv&&l>Nf,c.reverseTurn=l<Nf,c}function Tc(e,t,n,i,s,r,o,a,c,l,d,u,f=!1){var B,U,j,M,I,X,A;let h,g,w,p,y,b,v,T,E,S,L,x,O;if(i!==0)if(Me=d,ge=u,Tt=ge.indices,St=ge.elements.offset,Ae=0,Je=0,rt=0,e[0],t[0],i===1)h=e[0],g=t[0],w=(B=n==null?void 0:n[0])!=null?B:0,O=0,hn(Tt,St,0,2,1,1,2,3),Pe(ge,Me,0,h,g,w,1,-1,1,-1,O,!1,$t),Pe(ge,Me,0,h,g,w,-1,-1,-1,-1,O,!1,Ht),Pe(ge,Me,0,h,g,w,1,1,1,1,O,!1,$t),Pe(ge,Me,0,h,g,w,-1,1,-1,1,O,!1,Ht),Ae=Ae+4;else{switch(p=e[0],y=t[0],b=(U=n==null?void 0:n[0])!=null?U:0,v=e[1],T=t[1],E=(j=n==null?void 0:n[1])!=null?j:0,O=f?Me.cDist:0,s){case _e.TileCut:jt(Yt,p,y,o,a),jt(Se,v,T,p,y),x=Sc(v,T,E,Yt[0],Yt[1],Se[0],Se[1],f),x.noTurn?kf(p,y,b,Se[0],Se[1],O):Xr(0,p,y,b,Yt[0],Yt[1],Se[0],Se[1],O,f);break;case _e.Butt:case _e.Round:jt(Se,v,T,p,y),kf(p,y,b,Se[0],Se[1],O),s===_e.Round&&Xr(0,p,y,b,Se[0],Se[1],Se[0],Se[1],O,f);break;default:throw new Error("LoftedLine: unknown Ending Type")}const P=i-1;for(let F=1;F<P;F++){p=e[F-1],y=t[F-1],b=(M=n==null?void 0:n[F-1])!=null?M:0,v=e[F],T=t[F],E=(I=n==null?void 0:n[F])!=null?I:0,S=e[F+1],L=t[F+1];const k=v-p,R=T-y;O+=Math.sqrt(k*k+R*R)/te,jt(Yt,v,T,p,y),jt(Se,S,L,v,T),Xr(F,v,T,E,Yt[0],Yt[1],Se[0],Se[1],O,f)}p=e[i-2],y=t[i-2],b=(X=n==null?void 0:n[i-2])!=null?X:0,v=e[P],T=t[P],E=(A=n==null?void 0:n[P])!=null?A:0;const _=v-p,C=T-y;switch(O+=Math.sqrt(_*_+C*C)/te,r){case _e.TileCut:jt(Yt,v,T,p,y),jt(Se,c,l,v,T),x=Sc(v,T,E,Yt[0],Yt[1],Se[0],Se[1],f),x.noTurn?Bf(P,v,T,E,Se[0],Se[1],O):Uf(P,O,x);break;case _e.Butt:case _e.Round:jt(Se,v,T,p,y),Bf(P,v,T,E,Se[0],Se[1],O),r===_e.Round&&Xr(P,v,T,E,Se[0],Se[1],-Se[0],-Se[1],O,f);break;default:throw new Error("LoftedLine: unknown Ending Type")}}}function Sc(e,t,n,i,s,r,o,a){const c=Av(e,t,n,i,s,r,o,a);if(!c.noTurn&&!c.reverseTurn){Ou(Ft,i,s,r,o);const l=Ft[0],d=Ft[1];c.extender[0]=l,c.extender[1]=d,c.faExtender[0]=l-i*2,c.faExtender[1]=d-s*2,c.saExtender[0]=l-r*2,c.saExtender[1]=d-o*2}else c.extender[0]=0,c.extender[1]=0,c.faExtender[0]=0,c.faExtender[1]=0,c.saExtender[0]=0,c.saExtender[1]=0;return c}function Ac(e,t,n,i,s,r,o,a,c,l){Ou(Ft,s,r,o,a),s*-a+r*o<0?Pe(ge,Me,e,t,n,i,-Ft[0],-Ft[1],-Ft[0],-Ft[1],c,!1,l):Pe(ge,Me,e,t,n,i,Ft[0],Ft[1],Ft[0],Ft[1],c,!1,l),Ae++}function Xr(e,t,n,i,s,r,o,a,c,l){const d=Sc(t,n,i,s,r,o,a,l);Uf(e,c,d),Ev(e,c,d),xv(e,c,d)}function kf(e,t,n,i,s,r){Pe(ge,Me,0,e,t,n,-i,-s,-i,-s,r,!1,Ht),Pe(ge,Me,0,e,t,n,i,s,i,s,r,!1,$t),Ae=Ae+2,Je=1,rt=0}function Bf(e,t,n,i,s,r,o){const a=Ae+1,c=Ae;Pe(ge,Me,e,t,n,i,-s,-r,-s,-r,o,!1,Ht),Pe(ge,Me,e,t,n,i,s,r,s,r,o,!1,$t),Ae=Ae+2,hn(Tt,St,rt,c,Je,Je,c,a),Je=a,rt=c}function Ev(e,t,n){if(n.noTurn||n.patternedLine&&n.sharpTurn)return;const i=n.sharpTurn?2:1;let s,r;n.reverseTurn||n.patternedLine&&n.sharpTurn?(s=rt,r=Je):n.leftTurn?(s=Je,r=Ae+i):(s=Ae+i,r=rt);const o=Ae;if(Ec(Tt,St,Je,rt,o),n.sharpTurn){const c=Ae+1;n.leftTurn?hn(Tt,St,o,c,s,s,c,r):hn(Tt,St,o,r,c,c,r,s)}else n.leftTurn,Ec(Tt,St,o,r,s);const a=n.leftTurn?Ht:$t;n.sharpTurn?(n.leftTurn?jt($i,n.xn2,n.yn2,n.xn1,n.yn1):jt($i,n.xn1,n.yn1,n.xn2,n.yn2),Ac(e,n.x,n.y,n.z,n.xn2,n.yn2,$i[0],$i[1],t,a),Ac(e,n.x,n.y,n.z,$i[0],$i[1],n.xn1,n.yn1,t,a)):Ac(e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn1,n.yn1,t,a),n.reverseTurn||(n.leftTurn?Pe(ge,Me,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,a):Pe(ge,Me,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,a),Ae++),rt=r,Je=s}function Uf(e,t,n){if(n.noTurn)return;const i=Ae+1,s=Ae;if(n.reverseTurn||n.patternedLine&&n.sharpTurn?(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,Ht),Pe(ge,Me,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,$t)):n.leftTurn?(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn2,-n.yn2,n.faExtender[0],n.faExtender[1],t,!0,Ht),Pe(ge,Me,e,n.x,n.y,n.z,n.xn2,n.yn2,n.extender[0],n.extender[1],t,!0,$t)):(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.extender[0],-n.extender[1],t,!0,Ht),Pe(ge,Me,e,n.x,n.y,n.z,n.xn2,n.yn2,-n.faExtender[0],-n.faExtender[1],t,!0,$t)),Ae=Ae+2,hn(Tt,St,rt,s,Je,Je,s,i),rt=s,Je=i,!n.patternedLine&&!n.reverseTurn){const r=Ae+1,o=Ae;n.leftTurn?(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,0),Pe(ge,Me,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),hn(Tt,St,i,s,r,r,s,o)):(Pe(ge,Me,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),Pe(ge,Me,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,0),hn(Tt,St,s,o,i,i,o,r)),Ae=Ae+2,rt=o,Je=r}}function xv(e,t,n){if(n.noTurn||n.reverseTurn)return;const i=Ae+1,s=Ae;if(n.patternedLine&&n.sharpTurn){Pe(ge,Me,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,Ht),Pe(ge,Me,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,$t),Ae=Ae+2,rt=s,Je=i;return}else n.leftTurn?(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn1,-n.yn1,n.saExtender[0],n.saExtender[1],t,!1,Ht),Pe(ge,Me,e,n.x,n.y,n.z,n.xn1,n.yn1,n.extender[0],n.extender[1],t,!1,$t)):(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.extender[0],-n.extender[1],t,!1,Ht),Pe(ge,Me,e,n.x,n.y,n.z,n.xn1,n.yn1,-n.saExtender[0],-n.saExtender[1],t,!1,$t));Ae=Ae+2,n.leftTurn?hn(Tt,St,rt,s,Je,Je,s,i):hn(Tt,St,Je,rt,i,i,rt,s),rt=s,Je=i}function Pe(e,t,n,i,s,r,o,a,c,l,d,u,f){const h=e.elements.offset*t.offsetMultiplier,g=h>>1,w=h<<1;if(e.views.position[h]=z+i,e.views.position[h+1]=z+s,e.views.extender[h]=Math.floor(c*Ne*127+.5),e.views.extender[h+1]=Math.floor(l*Ne*127+.5),t.type===li.Patterned){const p=e,y=1e-5;p.views.texture[g]=(y+d)*Math.sign(f)}else if(t.type===li.Striped){const p=e;p.views.texExtender[w]=$e(o*Ne),p.views.texExtender[w+1]=$e(a*Ne),p.views.vertexDistance[g]=d,p.views.objectLength[g]=t.oLen,"componentDistance"in e.views&&(e.views.componentDistance[g]=t.cDist)}else if(t.type===li.Entrance){const p=e,{px:y,py:b,count:v}=t,T=n===0,E=n===v-1,S=T?n:n-1,L=T?n+1:n;en(Mc,y[S],b[S],y[L],b[L]),p.views.direction[h]=Math.round(Mc[0]*127),p.views.direction[h+1]=Math.round(Mc[1]*127),p.views.type[g]=E?Es.LineEnding:Es.Line,p.views.texExtender[w]=$e(o*(u||E?-1:1)*Ne),p.views.texExtender[w+1]=$e(a*(u||E?-1:1)*Ne),p.views.vertexDistance[g]=d,p.views.objectLength[g]=t.oLen}e.views.localID[g]=t.localID,"height"in e.views&&(e.views.height[g]=r),e.elements.offset++}function Ec(e,t,n,i,s){const r=e.buffer,o=e.offset;r[o]=t+n,r[o+1]=t+i,r[o+2]=t+s,e.offset=o+3}function hn(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function xc(e){return ds*e}function _c(e){return e/ds}function _v(e){return!!e.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i)}const Pv={arrow:!0,buildingModel:!0,custom:!0,dashedLine:!0,embankment:!0,group:!0,heatmap:!0,labelLine:!0,line:!0,lineExtrusion:!0,metricPoint:!0,model:!0,oneWayLine:!0,overpass:!0,point:!0,polygon:!0,polygon3d:!0,polygonExtrusion:!0,raster:!0,shiftedLine:!0,tunnel:!0};function Lv(e){return Pv[e]}function Dv(e){return e!=="group"&&e!=="custom"}function Ov(e){return e==="model"?"gltfModel":e!=="group"?e:void 0}function Fv(){let e=new It(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function Cv(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function Rv(e){return e[0]*e[3]-e[2]*e[1]}function Pc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qr={exports:{}},Jr={exports:{}},Nv=Jr.exports,zf;function kv(){return zf||(zf=1,(function(e,t){(function(n,i){e.exports=i()})(Nv,(function(){function n(o,a,c,l,d){i(o,a,c||0,l||o.length-1,d||r)}function i(o,a,c,l,d){for(;l>c;){if(l-c>600){var u=l-c+1,f=a-c+1,h=Math.log(u),g=.5*Math.exp(2*h/3),w=.5*Math.sqrt(h*g*(u-g)/u)*(f-u/2<0?-1:1),p=Math.max(c,Math.floor(a-f*g/u+w)),y=Math.min(l,Math.floor(a+(u-f)*g/u+w));i(o,a,p,y,d)}var b=o[a],v=c,T=l;for(s(o,c,a),d(o[l],b)>0&&s(o,c,l);v<T;){for(s(o,v,T),v++,T--;d(o[v],b)<0;)v++;for(;d(o[T],b)>0;)T--}d(o[c],b)===0?s(o,c,T):(T++,s(o,T,l)),T<=a&&(c=T+1),a<=T&&(l=T-1)}}function s(o,a,c){var l=o[a];o[a]=o[c],o[c]=l}function r(o,a){return o<a?-1:o>a?1:0}return n}))})(Jr)),Jr.exports}var Gf;function Bv(){if(Gf)return qr.exports;Gf=1,qr.exports=t,qr.exports.default=t;var e=kv();function t(p,y){if(!(this instanceof t))return new t(p,y);this._maxEntries=Math.max(4,p||9),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),y&&this._initFormat(y),this.clear()}t.prototype={all:function(){return this._all(this.data,[])},search:function(p){var y=this.data,b=[],v=this.toBBox;if(!h(p,y))return b;for(var T=[],E,S,L,x;y;){for(E=0,S=y.children.length;E<S;E++)L=y.children[E],x=y.leaf?v(L):L,h(p,x)&&(y.leaf?b.push(L):f(p,x)?this._all(L,b):T.push(L));y=T.pop()}return b},collides:function(p){var y=this.data,b=this.toBBox;if(!h(p,y))return!1;for(var v=[],T,E,S,L;y;){for(T=0,E=y.children.length;T<E;T++)if(S=y.children[T],L=y.leaf?b(S):S,h(p,L)){if(y.leaf||f(p,L))return!0;v.push(S)}y=v.pop()}return!1},load:function(p){if(!(p&&p.length))return this;if(p.length<this._minEntries){for(var y=0,b=p.length;y<b;y++)this.insert(p[y]);return this}var v=this._build(p.slice(),0,p.length-1,0);if(!this.data.children.length)this.data=v;else if(this.data.height===v.height)this._splitRoot(this.data,v);else{if(this.data.height<v.height){var T=this.data;this.data=v,v=T}this._insert(v,this.data.height-v.height-1,!0)}return this},insert:function(p){return p&&this._insert(p,this.data.height-1),this},clear:function(){return this.data=g([]),this},remove:function(p,y){if(!p)return this;for(var b=this.data,v=this.toBBox(p),T=[],E=[],S,L,x,O;b||T.length;){if(b||(b=T.pop(),L=T[T.length-1],S=E.pop(),O=!0),b.leaf&&(x=n(p,b.children,y),x!==-1))return b.children.splice(x,1),T.push(b),this._condense(T),this;!O&&!b.leaf&&f(b,v)?(T.push(b),E.push(S),S=0,L=b,b=b.children[0]):L?(S++,b=L.children[S],O=!1):b=null}return this},toBBox:function(p){return p},compareMinX:o,compareMinY:a,toJSON:function(){return this.data},fromJSON:function(p){return this.data=p,this},_all:function(p,y){for(var b=[];p;)p.leaf?y.push.apply(y,p.children):b.push.apply(b,p.children),p=b.pop();return y},_build:function(p,y,b,v){var T=b-y+1,E=this._maxEntries,S;if(T<=E)return S=g(p.slice(y,b+1)),i(S,this.toBBox),S;v||(v=Math.ceil(Math.log(T)/Math.log(E)),E=Math.ceil(T/Math.pow(E,v-1))),S=g([]),S.leaf=!1,S.height=v;var L=Math.ceil(T/E),x=L*Math.ceil(Math.sqrt(E)),O,B,U,j;for(w(p,y,b,x,this.compareMinX),O=y;O<=b;O+=x)for(U=Math.min(O+x-1,b),w(p,O,U,L,this.compareMinY),B=O;B<=U;B+=L)j=Math.min(B+L-1,U),S.children.push(this._build(p,B,j,v-1));return i(S,this.toBBox),S},_chooseSubtree:function(p,y,b,v){for(var T,E,S,L,x,O,B,U;v.push(y),!(y.leaf||v.length-1===b);){for(B=U=1/0,T=0,E=y.children.length;T<E;T++)S=y.children[T],x=c(S),O=d(p,S)-x,O<U?(U=O,B=x<B?x:B,L=S):O===U&&x<B&&(B=x,L=S);y=L||y.children[0]}return y},_insert:function(p,y,b){var v=this.toBBox,T=b?p:v(p),E=[],S=this._chooseSubtree(T,this.data,y,E);for(S.children.push(p),r(S,T);y>=0&&E[y].children.length>this._maxEntries;)this._split(E,y),y--;this._adjustParentBBoxes(T,E,y)},_split:function(p,y){var b=p[y],v=b.children.length,T=this._minEntries;this._chooseSplitAxis(b,T,v);var E=this._chooseSplitIndex(b,T,v),S=g(b.children.splice(E,b.children.length-E));S.height=b.height,S.leaf=b.leaf,i(b,this.toBBox),i(S,this.toBBox),y?p[y-1].children.push(S):this._splitRoot(b,S)},_splitRoot:function(p,y){this.data=g([p,y]),this.data.height=p.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},_chooseSplitIndex:function(p,y,b){var v,T,E,S,L,x,O,B;for(x=O=1/0,v=y;v<=b-y;v++)T=s(p,0,v,this.toBBox),E=s(p,v,b,this.toBBox),S=u(T,E),L=c(T)+c(E),S<x?(x=S,B=v,O=L<O?L:O):S===x&&L<O&&(O=L,B=v);return B},_chooseSplitAxis:function(p,y,b){var v=p.leaf?this.compareMinX:o,T=p.leaf?this.compareMinY:a,E=this._allDistMargin(p,y,b,v),S=this._allDistMargin(p,y,b,T);E<S&&p.children.sort(v)},_allDistMargin:function(p,y,b,v){p.children.sort(v);var T=this.toBBox,E=s(p,0,y,T),S=s(p,b-y,b,T),L=l(E)+l(S),x,O;for(x=y;x<b-y;x++)O=p.children[x],r(E,p.leaf?T(O):O),L+=l(E);for(x=b-y-1;x>=y;x--)O=p.children[x],r(S,p.leaf?T(O):O),L+=l(S);return L},_adjustParentBBoxes:function(p,y,b){for(var v=b;v>=0;v--)r(y[v],p)},_condense:function(p){for(var y=p.length-1,b;y>=0;y--)p[y].children.length===0?y>0?(b=p[y-1].children,b.splice(b.indexOf(p[y]),1)):this.clear():i(p[y],this.toBBox)},_initFormat:function(p){var y=["return a"," - b",";"];this.compareMinX=new Function("a","b",y.join(p[0])),this.compareMinY=new Function("a","b",y.join(p[1])),this.toBBox=new Function("a","return {minX: a"+p[0]+", minY: a"+p[1]+", maxX: a"+p[2]+", maxY: a"+p[3]+"};")}};function n(p,y,b){if(!b)return y.indexOf(p);for(var v=0;v<y.length;v++)if(b(p,y[v]))return v;return-1}function i(p,y){s(p,0,p.children.length,y,p)}function s(p,y,b,v,T){T||(T=g(null)),T.minX=1/0,T.minY=1/0,T.maxX=-1/0,T.maxY=-1/0;for(var E=y,S;E<b;E++)S=p.children[E],r(T,p.leaf?v(S):S);return T}function r(p,y){return p.minX=Math.min(p.minX,y.minX),p.minY=Math.min(p.minY,y.minY),p.maxX=Math.max(p.maxX,y.maxX),p.maxY=Math.max(p.maxY,y.maxY),p}function o(p,y){return p.minX-y.minX}function a(p,y){return p.minY-y.minY}function c(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function l(p){return p.maxX-p.minX+(p.maxY-p.minY)}function d(p,y){return(Math.max(y.maxX,p.maxX)-Math.min(y.minX,p.minX))*(Math.max(y.maxY,p.maxY)-Math.min(y.minY,p.minY))}function u(p,y){var b=Math.max(p.minX,y.minX),v=Math.max(p.minY,y.minY),T=Math.min(p.maxX,y.maxX),E=Math.min(p.maxY,y.maxY);return Math.max(0,T-b)*Math.max(0,E-v)}function f(p,y){return p.minX<=y.minX&&p.minY<=y.minY&&y.maxX<=p.maxX&&y.maxY<=p.maxY}function h(p,y){return y.minX<=p.maxX&&y.minY<=p.maxY&&y.maxX>=p.minX&&y.maxY>=p.minY}function g(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function w(p,y,b,v,T){for(var E=[y,b],S;E.length;)b=E.pop(),y=E.pop(),!(b-y<=v)&&(S=y+Math.ceil((b-y)/v/2)*v,e(p,S,y,b,T),E.push(y,S,S,b))}return qr.exports}var Uv=Bv();const Kr=Pc(Uv);var Lc,jf;function zv(){if(jf)return Lc;jf=1,Lc=i;var e=128,t=-128,n=Math.pow(2,31);function i(s,r,o){if(Number.MAX_SAFE_INTEGER&&s>Number.MAX_SAFE_INTEGER)throw i.bytes=0,new RangeError("Could not encode varint");r=r||[],o=o||0;for(var a=o;s>=n;)r[o++]=s&255|e,s/=128;for(;s&t;)r[o++]=s&255|e,s>>>=7;return r[o]=s|0,i.bytes=o-a+1,r}return Lc}var Dc,Vf;function Gv(){if(Vf)return Dc;Vf=1,Dc=n;var e=128,t=127;function n(i,o){var r=0,o=o||0,a=0,c=o,l,d=i.length;do{if(c>=d||a>49)throw n.bytes=0,new RangeError("Could not decode varint");l=i[c++],r+=a<28?(l&t)<<a:(l&t)*Math.pow(2,a),a+=7}while(l>=e);return n.bytes=c-o,r}return Dc}var Oc,Hf;function jv(){if(Hf)return Oc;Hf=1;var e=Math.pow(2,7),t=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),s=Math.pow(2,35),r=Math.pow(2,42),o=Math.pow(2,49),a=Math.pow(2,56),c=Math.pow(2,63);return Oc=function(l){return l<e?1:l<t?2:l<n?3:l<i?4:l<s?5:l<r?6:l<o?7:l<a?8:l<c?9:10},Oc}var Fc,$f;function Vv(){return $f||($f=1,Fc={encode:zv(),decode:Gv(),encodingLength:jv()}),Fc}var Hv=Vv();const Yf=Pc(Hv);class Wf{constructor(t){const n=ArrayBuffer.isView(t)?t.buffer:t;this.buf=new Uint8Array(n),this.view=new DataView(n),this.pos=0}readBytes(t){const n=this.buf.subarray(this.pos,this.pos+t);return this.pos+=t,n}readUint8(){const t=this.view.getUint8(this.pos);return this.pos+=Uint8Array.BYTES_PER_ELEMENT,t}readUint16(){const t=this.view.getUint16(this.pos,!0);return this.pos+=Uint16Array.BYTES_PER_ELEMENT,t}readUint32(){const t=this.view.getUint32(this.pos,!0);return this.pos+=Uint32Array.BYTES_PER_ELEMENT,t}readInt32(){const t=this.view.getInt32(this.pos,!0);return this.pos+=Int32Array.BYTES_PER_ELEMENT,t}readVarint(){var n;const t=Yf.decode(this.buf,this.pos);return this.pos+=(n=Yf.decode.bytes)!=null?n:0,t}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}skip(t){this.pos+=t}}function $v(e){const t=new Wf(e);t.readUint32(),t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16();const n=Cc(t.readInt32()),i=Cc(t.readInt32()),s=t.readUint32(),r=[];for(let o=0;o<s;o++){const a=t.readUint32(),c=new Uint16Array(a*2);for(let w=0;w<a;w++)c[w*2]=t.readUint16(),c[w*2+1]=t.readUint16();const l=new Float32Array(a);Zf(t,l,a,Cc);const d=t.readUint32(),u=a>Ge?new Uint32Array(d):new Uint16Array(d);Zf(t,u,d);const f={positions:c,heights:l,indices:u},h=t.readUint32();if(h>0){const w=[];new Int8Array(t.readBytes(h*3)).forEach(p=>w.push(Yv(p)))}const g=t.readUint32();if(g>0){const w={};for(let p=0;p<g;p++){const y=t.readUint16(),b=t.readInt32();w[y]=b}f.attributes=w}r.push(f)}return{dataGroups:r,minZ:n,maxZ:i}}function Zf(e,t,n,i){let s=0;for(let r=0;r<n;r++){const a=e.readSVarint()+s;t[r]=i?i(a):a,s=a}}function Cc(e){return e/Ie}function Yv(e){return e/127}function Wv(e){const t=new Fr(e),n=Rc(t.readFixed32()),i=Rc(t.readFixed32()),s=t.readFixed32(),r=t.readBytes(),o=new Uint16Array(r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)),a=new Float32Array(s);for(let u=0;u<s;u++)a[u]=Rc(t.readSVarint());let c=0;const l=t.readFixed32(),d=s>Ge?new Uint32Array(l):new Uint16Array(l);for(let u=0;u<l;u++){const f=t.readSVarint(),h=c+f;c+=f,d[u]=h}return{dataGroups:[{positions:o,heights:a,indices:d}],minZ:n,maxZ:i}}function Rc(e){return e/100}function Zv(e){const t=Math.log(e)*256;return t+(t<0?-.5:.5)<<16>>16}function At(e){return e*32768+.5<<16>>>16}function Xv(e){return Math.log(e)*256+.5<<16>>16}let qv=0;function Ns(){return qv++}const ks=Ns(),Nc=Ns(),Xf=128,Ct={symbol:"dem",sinks:{mesh:{stride:4,binder:(e,t)=>{},packObjectAttributes(e,t){return[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(3)}}},mesh2:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4)},packObjectAttributes(e,t){return[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}},hillshade:{stride:8,binder:(e,t)=>{},packObjectAttributes(e,t){return[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}},flatBottom:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.demPosition=new Int16Array(t,4),e.views.extender=new Int8Array(t,8)},packObjectAttributes(e,t,n){return n?[e,t,n]:[e,t]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],matrix:e[2]?e[2]:void 0,tileData:e.slice(3)}}}},generateMeshElevation(e,t,n,i){const s=e.getBucket("dem","mesh2",Ct.sinks.mesh2.packObjectAttributes(n,i),Ct.sinks.mesh2.binder);Qv(s,t)},generateHillshade(e,t,n,i){const s=new Uint16Array(t.reduce((o,a)=>{const[c,l,d,u]=a;return o.push(c*te,l*te,At(d),At(u)),o},[]));return{symbol:Ct.symbol,sink:"hillshade",buffer:s.buffer,generatedObjects:[{drawMode:pr,attributes:Ct.sinks.hillshade.packObjectAttributes(n,i),rangeStart:0,rangeEnd:s.buffer.byteLength,extents:new Float32Array(6)}]}},generateFloorsBottomFill(e,t,n,i,s,r){const o=n[0],a=n[1],c=n[0].length,l=Ct.sinks.flatBottom.packObjectAttributes(t,ks,r),d=e.getBucket("dem","flatBottom",l,Ct.sinks.flatBottom.binder);Jv(d,c,o,a,i,s,!!r)}};function Jv(e,t,n,i,s,r,o){let a=e.elements.offset;const c=a;if(!(t<3)){kc(e,a++,n[0],i[0],r,s[0],o),kc(e,a++,n[1],i[1],r,s[1],o);for(let l=2;l<t;l++)Kv(e,c,l),kc(e,a++,n[l],i[l],r,s[l],o);e.elements.offset=a}}function kc(e,t,n,i,s,r,o){const a=t*(e.elements.stride/e.views.position.BYTES_PER_ELEMENT),c=t*(e.elements.stride/e.views.extender.BYTES_PER_ELEMENT);e.views.position[a]=o?n:z+n,e.views.position[a+1]=o?i:z+i,e.views.demPosition[a]=(o?s[0]:z+s[0])/8,e.views.demPosition[a+1]=(o?s[1]:z+s[1])/8,e.views.extender[c]=r[0]*127,e.views.extender[c+1]=r[1]*127}function Kv(e,t,n){const i=e.indices.buffer;let s=e.indices.offset;n%2===0?(i[s++]=t+n-2,i[s++]=t+n-1,i[s++]=t+n):(i[s++]=t+n-1,i[s++]=t+n-2,i[s++]=t+n),e.indices.offset=s}function Qv(e,t,n=!1){for(let i=0;i<t.indices.length;i++){const s=t.indices[i],r=e.elements.offset*(e.elements.stride/e.views.position.BYTES_PER_ELEMENT),o=t.positions[s*2],a=t.positions[s*2+1];e.views.position[r]=z+(n?qf(o):o),e.views.position[r+1]=z+(n?qf(a):a);const c=e.elements.offset*(e.elements.stride/e.views.height.BYTES_PER_ELEMENT);e.views.height[c]=t.heights[s],e.elements.offset++,e.indices.buffer[e.indices.offset]=i,e.indices.offset++}}function qf(e){return e===0?e-=Xf:e===te&&(e+=Xf),e}const e2=(()=>{let e=new DataView(new ArrayBuffer(1025));return function(s){const r=s.toJSON(),o=t(r,0);return e.buffer.slice(0,o)};function t(s,r){i(r),e.setUint16(r,s.minX,!0),r+=2,e.setUint16(r,s.minY,!0),r+=2,e.setUint16(r,s.maxX,!0),r+=2,e.setUint16(r,s.maxY,!0),r+=2;const o=r;if(r+=4,s.children.length>127)throw new Error("Too many children in RBush node to serialize");return e.setUint8(r,(s.leaf?1:0)|s.children.length<<1),r+=1,s.children.forEach(a=>{s.leaf?r=n(a,r):r=t(a,r)}),e.setUint32(o,r-o-4,!0),r}function n(s,r){if(i(r),e.setUint16(r,s.minX,!0),r+=2,e.setUint16(r,s.minY,!0),r+=2,e.setUint16(r,s.maxX,!0),r+=2,e.setUint16(r,s.maxY,!0),r+=2,e.setUint32(r,s.posOffset,!0),r+=4,s.bucketIndex>255)throw new Error("[RTreeBin] Bucket index too large to serialize");if(e.setUint8(r,s.bucketIndex),r+=1,s.batchIndex>255)throw new Error("[RTreeBin] Batch index too large to serialize");return e.setUint8(r,s.batchIndex),r+=1,r}function i(s){if(e.buffer.byteLength<=s+256){const r=new ArrayBuffer(e.buffer.byteLength*2);new Uint8Array(r).set(new Uint8Array(e.buffer),0),e=new DataView(r)}}})();function t2(e,t){const n=new Wf(e),i=[];return Jf(n,t,i),i}function Jf(e,t,n){const i=e.readUint16(),s=e.readUint16(),r=e.readUint16(),o=e.readUint16(),a=e.readUint32();if(t[0]<i||t[0]>r||t[1]<s||t[1]>o){e.skip(a);return}const c=e.readUint8(),l=(c&1)===1,d=c>>1;for(let u=0;u<d;u++)l?n2(e,t,n):Jf(e,t,n)}function n2(e,t,n){const i=e.readUint16(),s=e.readUint16(),r=e.readUint16(),o=e.readUint16();if(i>t[0]||r<t[0]||s>t[1]||o<t[1]){e.skip(6);return}const a=e.readUint32(),c=e.readUint8(),l=e.readUint8();n.push({posOffset:a,bucketIndex:c,batchIndex:l,minX:i,minY:s,maxX:r,maxY:o})}const Bs=yt(),Kf=yt(),i2=Fe(),s2=Fe(),Qf=Fv(),r2=64,eh=9,th=(e,t,n,i,s)=>{const r=Ms(e.tileServer,{subdomain:e.subdomains[Math.abs(t+n)%e.subdomains.length]});return`${e.tileProtocol}://${r}/v2/ald?ts=${s}&x=${t}&y=${n}&z=${i}`};function o2(e){const t=[];return e.forEach((n,i)=>{n.symbol!=="dem"||n.sink!=="mesh2"||n.generatedObjects.forEach((s,r)=>{const o=Ct.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT,a=new Uint16Array(n.buffer,s.rangeStart,(s.rangeEnd-s.rangeStart)/Uint16Array.BYTES_PER_ELEMENT);for(let c=0;c<a.length;c+=o*3){const l=c,d=c+o,u=c+o*2;t.push({minX:Math.min(a[l],a[d],a[u])-z,maxX:Math.max(a[l],a[d],a[u])-z,minY:Math.min(a[l+1],a[d+1],a[u+1])-z,maxY:Math.max(a[l+1],a[d+1],a[u+1])-z,posOffset:c,bucketIndex:i,batchIndex:r})}})}),t.length?e2(Kr(eh).load(t)):null}function Bc(e,t,n){const i=n/(Float32Array.BYTES_PER_ELEMENT/Uint16Array.BYTES_PER_ELEMENT);return[e[n]-z,e[n+1]-z,t[i]]}function a2(e,t){var c;if(!e.tree)return;const n=Oe(Bs,t[0],t[1],0),i=oc(e.key),s=ct(i),r=new Uint16Array(3),o=Ct.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT;Pt(r,n,s);const a=t2(e.tree,r);for(const l of a){const d=(c=e.generated[0])==null?void 0:c.collectorOutput.data[l.bucketIndex];if(!d||d.sink!=="mesh2")continue;const u=d.generatedObjects[l.bucketIndex],f=new Uint16Array(d.buffer,u.rangeStart,(u.rangeEnd-u.rangeStart)/Uint16Array.BYTES_PER_ELEMENT),h=new Float32Array(d.buffer,u.rangeStart+4,(u.rangeEnd-u.rangeStart)/Float32Array.BYTES_PER_ELEMENT-1),g=Bc(f,h,l.posOffset),w=Bc(f,h,l.posOffset+o),p=Bc(f,h,l.posOffset+o*2),y=c2(g,w,p,r,Bs);if(!y)continue;return g[2]*y[0]+w[2]*y[1]+p[2]*y[2]}}function c2(e,t,n,i,s){const r=Uc(e,t,n);if(r===0){if(e[0]===t[0]&&t[0]===n[0]&&e[1]===t[1]&&t[1]===n[1])return e[0]===i[0]&&e[1]===i[1]?(s[0]=1,s[1]=0,s[2]=0,s):null;let l=null;if(zc(e,t,i)){const d=Qr(e,t,i);l=ni(Bs,e,t,d),s[0]=1-d,s[1]=d,s[2]=0}if(zc(t,n,i)){const d=Qr(t,n,i),u=ni(Kf,t,n,d);(!l||u[2]>l[2])&&(s[0]=0,s[1]=1-d,s[2]=d,l||(l=Bs),Ga(l,u))}if(zc(n,e,i)){const d=Qr(n,e,i),u=ni(Kf,n,e,d);(!l||u[2]>l[2])&&(s[0]=d,s[1]=0,s[2]=1-d,l||(l=Bs),Ga(l,u))}if(l)return s}const o=Uc(i,t,n)/r,a=Uc(i,n,e)/r,c=1-o-a;return o<0||a<0||c<0||o>1||a>1||c>1?null:(s[0]=o,s[1]=a,s[2]=c,s)}function Uc(e,t,n){return Cv(Qf,t[0]-e[0],n[0]-e[0],t[1]-e[1],n[1]-e[1]),Rv(Qf)}function zc(e,t,n){const i=(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return Math.abs(i)>1e-8?!1:(n[0]-e[0])*(n[0]-t[0])+(n[1]-e[1])*(n[1]-t[1])<=0}function Qr(e,t,n){const i=ln(i2,t,e),s=ln(s2,n,e);return Dn(s,i)/o1(i)}function l2(e){if(e.byteLength===0)return{positions:new Uint16Array,heights:new Float32Array,indices:new Uint16Array,maxZ:0,minZ:0};const t=new Uint32Array(e.slice(0,4))[0]===777275726,{dataGroups:n,minZ:i,maxZ:s}=t?$v(e):Wv(e),{positions:r,heights:o,indices:a}=n[0];return{positions:r,heights:o,indices:a,maxZ:s,minZ:i}}function Gc(e,t,n,i,s){const r=_c(s);pi(i.textureImage).forEach(o=>{if(!o.length)return;const a=n.byKey[$r(o)];if(!a){console.error(`Not found raster set with texture ${o}`);return}const c=d2(i.textureSize),l=i.lengthUnits===Un.Meters;c.forEach(d=>{let[u,f]=Array.isArray(d)?d:[d,d];l&&(u=u*Vr(u,u),f=f*Vr(f,f)),a.isSvg?e.atlasPacker.packSvg(a,[{w:u,h:f}],r):e.atlasPacker.packPng(a,[{w:u,h:f}],r),a.rasters.forEach(h=>e.atlasPacker.addRastersToLoad(t,h))})})}function d2(e){return tn(e)?e.type==="step"?e.steps.map(t=>Array.isArray(t.value)||typeof t.value=="number"?t.value:t.value.type==="literalArray"?t.value.array:(console.warn("textureSize only supports shallow step expression"),[0])):e.type==="literalArray"?[it(e)]:(ke(`Unsupported texture size expression of type "${e.type}". Can't resovle.`),[0]):[e]}function jc(e,t){var g,w,p,y,b;const{tileAttrs:n,tileProps:i}=e,s=Number.isNaN(n[i.db_begin_nominal_height])?0:(g=n[i.db_begin_nominal_height])!=null?g:0,r=Number.isNaN(n[i.db_end_nominal_height])?0:(w=n[i.db_end_nominal_height])!=null?w:0,o=(p=n[i.objectLength])!=null?p:1,a=(y=n[i.componentDistanceStart])!=null?y:0,c=(b=n[i.componentDistanceEnd])!=null?b:0,l=Oi(s,r,a/o),d=Oi(s,r,c/o),u=e.tileInfo?Dt(e.tileInfo,[0,0]):1,f=Array.from({length:t.x.length});if(l===d)return f.fill(l*Ie*u),f;const h=t.x.length;for(let v=0;v<h;v++)f[v]=Ie*u*Oi(l,d,Qr([t.x[0],t.y[0]],[t.x[h-1],t.y[h-1]],[t.x[v],t.y[v]]));return f}const Vc=e=>{for(let t=0;t<e.length;t++)if(e[t]!==0)return!0;return!1},dt={symbol:"line",sinks:{solid:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.localID=new Uint32Array(t,8)},packObjectAttributes(e,t,n,i,s){return Ce([e,t.innerId,n,i],t,s)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],tileData:e.slice(4)}}},solid3d:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.height=new Float32Array(t,8),e.views.absZ=new Float32Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes(e,t,n,i){return Ce([e,t.innerId,n],t,i)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],absZ:e[2],tileData:e.slice(3)}}},patterned:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texture=new Float32Array(t,8),e.views.localID=new Uint32Array(t,12)},packObjectAttributes(e,t,n,i,s){return Ce([e,t.innerId,n,i],t,s)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],tileData:e.slice(3)}}},patterned3d:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texture=new Float32Array(t,8),e.views.height=new Float32Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes(e,t,n){return Ce([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}},generate(e,t,n,i,s,r){var v;const o=Hr($(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i;let l=n.style.mode==="3d";const d=l?(v=o.z)!=null?v:jc(i,o):void 0;l&&(!d||!Vc(d))&&(l=!1);const u=e.idIndexer.getIndex(i,t,n),f=$(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],h=a[c.db_hidden_by_metro_building_id]||"",g=l?e.getBucket(n.type,"solid3d",dt.sinks.solid3d.packObjectAttributes(t,n,!!o.abs_z,i),dt.sinks.solid3d.binder):e.getBucket(n.type,"solid",dt.sinks.solid.packObjectAttributes(t,n,f,h,i),dt.sinks.solid.binder),w=Number.isNaN(a[c.beginningIsCut])?!1:a[c.beginningIsCut]!==0,p=Number.isNaN(a[c.endingIsCut])?!1:a[c.endingIsCut]!==0,y=lt(n.style.startCap,i),b=lt(n.style.endCap,i);of(g,o.x,o.y,d,o.abs_z,o.x.length,w?_e.TileCut:eo(y),p?_e.TileCut:eo(b),u)},generatePatterned(e,t,n,i,s,r){var T,E;const o=Hr($(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i,l=$(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],d=(T=a[c.db_hidden_by_metro_building_id])!=null?T:"";let u=n.style.mode==="3d";const f=u?(E=o.z)!=null?E:jc(i,o):void 0;u&&(!f||!Vc(f))&&(u=!1);const h=u?e.getBucket("line","patterned3d",dt.sinks.patterned3d.packObjectAttributes(t,n,i),dt.sinks.patterned3d.binder):e.getBucket("line","patterned",dt.sinks.patterned.packObjectAttributes(t,n,l,d,i),dt.sinks.patterned.binder),g=e.idIndexer.getIndex(i,t,n),w=u2(a[c.componentDistanceStart]/te,a[c.componentDistanceEnd]/te,a[c.objectLength]/te,g,u?dt.sinks.patterned3d.stride/2:dt.sinks.patterned.stride/2),p=Number.isNaN(a[c.beginningIsCut])?!1:a[c.beginningIsCut]!==0,y=Number.isNaN(a[c.endingIsCut])?!1:a[c.endingIsCut]!==0,b=lt(n.style.startCap,i),v=lt(n.style.endCap,i);Tc(o.x,o.y,f,o.x.length,p?_e.TileCut:eo(b),y?_e.TileCut:eo(v),a[c.previousPointX],a[c.previousPointY],a[c.nextPointX],a[c.nextPointY],w,h,!0)}},Yi={type:li.Patterned,cDist:0,sLen:0,oLen:0,localID:0,offsetMultiplier:8,px:[],py:[],count:0};function u2(e,t,n,i,s){return Yi.cDist=e,Yi.sLen=t-e,Yi.oLen=n,Yi.localID=i,Yi.offsetMultiplier=s,Yi}function eo(e){switch(e){case"round":return _e.Round;case"tilecut":return _e.TileCut;case"butt":default:return _e.Butt}}const to={symbol:"shiftedLine",sinks:{solid:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.shift=new Float32Array(t,8)},packObjectAttributes(e,t,n,i){return Ce([e,t.innerId,n],t,i)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],tileData:e.slice(3)}}}},generate(e,t,n,i,s){const{tileAttrs:r,tileProps:o}=i,a=Number.isNaN(r[o.beginningIsCut])?!1:r[o.beginningIsCut]!==0,c=Number.isNaN(r[o.endingIsCut])?!1:r[o.endingIsCut]!==0,l=$(n.ignoreTier,i)?null:i.tileAttrs[o.db_tiers],d=e.getBucket(n.type,"solid",to.sinks.solid.packObjectAttributes(t,n,l,i),to.sinks.solid.binder);of(d,s.x,s.y,void 0,void 0,s.x.length,a?_e.TileCut:_e.Round,c?_e.TileCut:_e.Round,0,s.normal_x,s.normal_y)}};function ut(e,t){return e===0?0:Math.min(e*2-1,(t-e)*2)}function Hc(e,t,n,i,s,r,o=0,a,c,l,d){let u=e.elements.offset;for(let f=0;f<t;f++){const h=ut(f,t),g=f===t-1;if((!s||s[h]!==1)&&(s||g))continue;const w=n[h],p=i[h],y=(f+1)%t,b=ut(y,t),v=n[b],T=i[b];if(d){const E=Math.hypot(v-w,T-p)*d.tileSizeMapPoints/te;if(E<d.wallPaddingMapPoints[1]+d.wallPaddingMapPoints[3]+d.textureWidthMapPoints)continue;switch(d.config.horizontal.mode){case"repeat-with-stretch":{const S=d.config.horizontal.slicesCount,L=(E-(d.wallPaddingMapPoints[1]+d.wallPaddingMapPoints[3]))/d.textureWidthMapPoints,x=Math.round(L*S);if(x<d.config.horizontal.minSliceRepeats)continue;const B=x/S/L;if(d.config.horizontal.maxResizeFactor&&B>d.config.horizontal.maxResizeFactor||d.config.horizontal.minResizeFactor&&B<d.config.horizontal.minResizeFactor)continue;break}case"repeat-with-max-interval":break;default:continue}switch(d.config.vertical.mode){case"repeat-with-stretch":{const S=d.config.vertical.slicesCount,L=(r-(d.wallPaddingMapPoints[0]+d.wallPaddingMapPoints[2]))/d.textureHeightMapPoints,x=Math.round(L*S);if(x<d.config.vertical.minSliceRepeats)continue;const B=x/S/L;if(B>d.config.vertical.maxResizeFactor||B<d.config.vertical.minResizeFactor)continue;break}case"repeat-with-max-interval":break;case"stripe-top":break;default:continue}rh(e,u),nh(e,u,w,p,v,T,r,o),f2(e,u,r-o,E)}else rh(e,u),nh(e,u,w,p,v,T,r,0);l?ih(e,u,l[0],l[1],l[0],l[1]):ih(e,u,w,p,v,T),a!==void 0&&"localID"in e.views&&e.views.localID!==void 0&&sh(e.views.localID,u,a,e.elements.stride),c!==void 0&&"labelingTextureID"in e.views&&e.views.labelingTextureID!==void 0&&sh(e.views.labelingTextureID,u,c,e.elements.stride),u=u+4}e.elements.offset=u}function nh(e,t,n,i,s,r,o,a=0){const c=e.views.position,l=e.views.height,d=e.elements.stride/c.BYTES_PER_ELEMENT;t=t*d,c[t]=z+n,c[t+1]=z+i,l[t>>1]=nt(a)/Ge,t+=d,c[t]=z+n,c[t+1]=z+i,l[t>>1]=nt(o)/Ge,t+=d,c[t]=z+s,c[t+1]=z+r,l[t>>1]=nt(a)/Ge,t+=d,c[t]=z+s,c[t+1]=z+r,l[t>>1]=nt(o)/Ge}function f2(e,t,n,i){const s=e.views.fillIndices,r=e.views.fillRect,o=e.elements.stride/s.BYTES_PER_ELEMENT,a=e.elements.stride/r.BYTES_PER_ELEMENT;let c=t*o,l=t*a;s[c]=0,s[c+1]=1,r[l]=i,r[l+1]=n,c+=o,l+=a,s[c]=0,s[c+1]=0,r[l]=i,r[l+1]=n,c+=o,l+=a,s[c]=1,s[c+1]=1,r[l]=i,r[l+1]=n,c+=o,l+=a,s[c]=1,s[c+1]=0,r[l]=i,r[l+1]=n}function ih(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+z)/8,i=(i+z)/8,s=(s+z)/8,r=(r+z)/8,o[t]=n,o[t+1]=i,t+=a,o[t]=n,o[t+1]=i,t+=a,o[t]=s,o[t+1]=r,t+=a,o[t]=s,o[t+1]=r}function sh(e,t,n,i){const s=i/e.BYTES_PER_ELEMENT;t=t*s,e[t]=n,e[t+=s]=n,e[t+=s]=n,e[t+=s]=n}function rh(e,t){const n=e.indices.buffer;let i=e.indices.offset;n[i++]=t,n[i++]=t+3,n[i++]=t+1,n[i++]=t,n[i++]=t+2,n[i++]=t+3,e.indices.offset=i}const pn=[.5,.5],mn=[.5,.5];function $c(e,t,n,i,s,r){let o=e.elements.offset;const a=ut(t-1,t);let c=n[a],l=i[a],d=s?s[a]:0;const u=o;for(let f=0;f<t;f++){const h=ut(f,t),g=f===t-1,w=n[h],p=i[h],y=s?s[h]:g?0:1;d!==0&&(en(mn,c,l,w,p),ah(e,o,y,g?u:o+4),p2(e,o,c,l,w,p),r?oh(e,o,r[0],r[1],r[0],r[1]):oh(e,o,c,l,w,p),Xa(mn),m2(e,o,mn),y2(e,o,mn),o=o+4),c=w,l=p,d=y}e.elements.offset=o}function Yc(e,t,n,i,s,r,o){let a=e.elements.offset;const c=ut(t-2,t),l=ut(t-1,t);let d=n[l],u=i[l],f=s?s[c]:1,h=s?s[l]:0;jt(pn,n[c],i[c],d,u);let g=pn[0],w=pn[1];for(let p=0;p<t;p++){const y=ut(p,t),b=p===t-1,v=n[y],T=i[y],E=s?s[y]:b?0:1;en(mn,d,u,v,T);const S=mn[1],L=-mn[0];f!==0&&(h===0?(pn[0]=g,pn[1]=w):h2(pn,g,w,S,L),py(mn,g,w,pn[0],pn[1]),ah(e,a,0,0),g2(e,a,d,u,r,o!=null?o:[d,u]),w2(e,a,Xa(pn),Xa(mn)),v2(e,a),a=a+4),d=v,u=T,f=h,h=E,g=S,w=L}e.elements.offset=a}function h2(e,t,n,i,s){let r,o,a;t*i+n*s>0?(r=t+i,o=n+s,a=1/Math.sqrt(r*r+o*o),e[0]=r*a,e[1]=o*a):(r=s-n,o=t-i,r!==0&&o!==0?(a=1/Math.sqrt(r*r+o*o),e[0]=r*a,e[1]=o*a):(e[0]=0,e[1]=0))}function oh(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+z)/8,i=(i+z)/8,s=(s+z)/8,r=(r+z)/8,o[t]=n,o[t+1]=i,t+=a,o[t]=n,o[t+1]=i,t+=a,o[t]=s,o[t+1]=r,t+=a,o[t]=s,o[t+1]=r}function p2(e,t,n,i,s,r){const{position:o,distance:a,height:c}=e.views,l=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*l,o[t]=z+n,o[t+1]=z+i,c[t>>1]=0,a[t<<1]=0,t+=l,o[t]=z+n,o[t+1]=z+i,c[t>>1]=0,a[t<<1]=-1,t+=l,o[t]=z+s,o[t+1]=z+r,c[t>>1]=0,a[t<<1]=-1,t+=l,o[t]=z+s,o[t+1]=z+r,c[t>>1]=0,a[t<<1]=0}function m2(e,t,n){const i=e.elements.stride/e.views.normals.BYTES_PER_ELEMENT;t=t*i;for(let s=0;s<4;s++)e.views.normals[t]=n[0],e.views.normals[t+1]=n[1],e.views.normals[t+2]=0,e.views.normals[t+3]=0,t+=i}function y2(e,t,n){const i=e.elements.stride/e.views.direction.BYTES_PER_ELEMENT;t=t*i;for(let s=0;s<4;s++)e.views.direction[t]=n[0],e.views.direction[t+1]=n[1],e.views.direction[t+2]=0,t+=i}function g2(e,t,n,i,s,r){const o=e.elements.stride/e.views.position.BYTES_PER_ELEMENT;t=t*o,e.views.position[t]=z+n,e.views.position[t+1]=z+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=1,e.views.demPosition[t]=(z+r[0])/8,e.views.demPosition[t+1]=(z+r[1])/8,t+=o,e.views.position[t]=z+n,e.views.position[t+1]=z+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(z+r[0])/8,e.views.demPosition[t+1]=(z+r[1])/8,t+=o,e.views.position[t]=z+n,e.views.position[t+1]=z+i,e.views.height[t>>1]=nt(s)/Ge,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(z+r[0])/8,e.views.demPosition[t+1]=(z+r[1])/8,t+=o,e.views.position[t]=z+n,e.views.position[t+1]=z+i,e.views.height[t>>1]=nt(s)/Ge,e.views.distance[t<<1]=1,e.views.demPosition[t]=(z+r[0])/8,e.views.demPosition[t+1]=(z+r[1])/8}function w2(e,t,n,i){const s=e.elements.stride/e.views.normals.BYTES_PER_ELEMENT;t=t*s;for(let r=0;r<4;r++)e.views.normals[t]=n[0],e.views.normals[t+1]=n[1],e.views.normals[t+2]=i[0],e.views.normals[t+3]=i[1],t+=s}function v2(e,t){const n=e.elements.stride/e.views.direction.BYTES_PER_ELEMENT;t=t*n;for(let i=0;i<4;i++)e.views.direction[t]=0,e.views.direction[t+2]=127,t+=n}function ah(e,t,n,i){const s=e.indices.buffer;let r=e.indices.offset;s[r++]=t,s[r++]=t+1,s[r++]=t+3,s[r++]=t+3,s[r++]=t+1,s[r++]=t+2,n!==0&&(s[r++]=t+2,s[r++]=i+1,s[r++]=i+0),e.indices.offset=r}const Us=yt(),zs=yt(),yn=yt();function Gs(e,t,n,i,s,r,o,a,c,l,d,u,f,h){Oe(Us,t,n,i),Oe(zs,s,r,o),Jt(yn,zs,Us),U1(zs,Us)||(qt(yn,yn),Cn(yn,yn,127)),b2(e,0,1,3,3,1,2),no(e,Us,yn,1,a,c,l,d,f),no(e,Us,yn,-1,a,c,l,d,f),no(e,zs,yn,-1,a,c,l,u,h),no(e,zs,yn,1,a,c,l,u,h)}function no(e,t,n,i,s,r,o,a,c){const l=e.elements.offset*e.elements.stride,d=l/e.views.position.BYTES_PER_ELEMENT;if(e.views.position[d]=r?t[0]:z+t[0],e.views.position[d+1]=r?t[1]:z+t[1],"height"in e.views){const u=l/e.views.height.BYTES_PER_ELEMENT;e.views.height[u]=(r?t[2]:o?t[2]*ef:nt(t[2]))/Ge}if(e.views.directionDistance[l]=n[0],e.views.directionDistance[l+1]=n[1],e.views.directionDistance[l+2]=n[2],e.views.directionDistance[l+3]=i,"demPosition"in e.views){const u=l/e.views.demPosition.BYTES_PER_ELEMENT;s=s!=null?s:t,e.views.demPosition[u]=(r?s[0]:z+s[0])/8,e.views.demPosition[u+1]=(r?s[1]:z+s[1])/8}"absZ"in e.views&&a!==void 0&&(e.views.absZ[l/e.views.absZ.BYTES_PER_ELEMENT]=a),"isPivot"in e.views&&(e.views.isPivot[l/e.views.isPivot.BYTES_PER_ELEMENT]=c!=null?c:0),e.elements.offset++}function b2(e,t,n,i,s,r,o){const a=e.indices.buffer,c=e.indices.offset,l=e.elements.offset;a[c]=l+t,a[c+1]=l+n,a[c+2]=l+i,a[c+3]=l+s,a[c+4]=l+r,a[c+5]=l+o,e.indices.offset=c+6}const I2=/\.png$/i;function M2(e){return!!e&&e.type==="polygon"}function T2(e){return!!e&&e.type==="line"}function ch(e){return e.reduce((t,n,i)=>(t[n]=i,t),{})}function S2(e){return e===void 0||typeof e=="boolean"?!!e:!!JSON.stringify(e).match(/\["get","(db_)?sublayer"]/)}function A2(e){return!(e!=null&&e.url.match(I2))}function lh(e,t){return Di($(e.style.sideColor,t),$(e.style.sideStrokeColor,t))}const io=te/2,E2=1/nt(1),yi=(e,t,n,i,s,r,o)=>Ce([e,t.innerId,n,i,s,r],t,o),js=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],floorId:e[3],isFloorStack:e[4],textureIndex:e[5],tileData:e.slice(6)}),Vn={symbol:"polygonExtrusion",sinks:{sideFill:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.localID=new Uint32Array(t,8),e.views.demPosition=new Int16Array(t,12),e.views.labelingTextureID=new Uint32Array(t,16)},packObjectAttributes:yi,unpackObjectAttributes:js},sideTexture:{stride:24,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.fillRect=new Float32Array(t,12),e.views.fillIndices=new Uint8Array(t,20)},packObjectAttributes:yi,unpackObjectAttributes:js},topFill:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.localID=new Uint32Array(t,8),e.views.demPosition=new Int16Array(t,12),e.views.labelingTextureID=new Uint32Array(t,16)},packObjectAttributes:yi,unpackObjectAttributes:js},sideStroke:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.normals=new Int8Array(t,8),e.views.direction=new Int8Array(t,12),e.views.distance=new Int8Array(t,15),e.views.demPosition=new Int16Array(t,16)},packObjectAttributes:yi,unpackObjectAttributes:js},topStroke:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12)},packObjectAttributes:yi,unpackObjectAttributes:js}},generate(e,t,n,i,s,r){var x,O;const o=s.x,a=s.y,c=(x=s.cut)!=null?x:[],l=i.tileAttrs[i.tileProps.db_plan_id]||"",d=i.tileAttrs[i.tileProps.db_hidden_by_plan_building_id]||"",u=i.tileAttrs[i.tileProps.db_sublayer]==="Floor_half_walls_width_extended_ground",f=o.length,h=(O=i.id)!=null?O:"";let g;i.tileProps.db_centroid_x!==void 0&&i.tileProps.db_centroid_y!==void 0&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_x])&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_y])?g=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]:g=D2(o,a,c);const w=$(n.style.height,i),p=i.tileInfo?Dt(i.tileInfo,[0,0]):1,y=Math.max(w*Ie*p,E2),b=e.idIndexer.getIndex(i,t,n,{floorId:Number.isNaN(l)?void 0:l}),v=e.pointIndexer.getIndex(h),T=yi(t,n,d,l,u,NaN,i);if(y>0){const B=e.getBucket("polygonExtrusion","sideFill",T,Vn.sinks.sideFill.binder);let U=B.indices.offset;if(Hc(B,f,o,a,c,y,0,b,v,g),B.objectsData[U]={objectId:h,size:B.indices.offset-U},n.style.sideTextures.forEach((j,M)=>{var R,G;if(w<j.minWallHeight)return;const I=j.sliceSize[0]*Ie*p,X=j.sliceSize[1]*Ie*p,A=j.wallPadding.map(Z=>Z*Ie*p),P=Lt((G=(R=i.tileInfo)==null?void 0:R.coords[2])!=null?G:15),_=yi(t,n,d,l,u,M,i),C=e.getBucket("polygonExtrusion","sideTexture",_,Vn.sinks.sideTexture.binder),F=C.indices.offset,k=j.vertical.mode==="stripe-top"?y-X:0;Hc(C,f,o,a,c,y,k,void 0,void 0,g,{config:j,textureWidthMapPoints:I,textureHeightMapPoints:X,wallPaddingMapPoints:A,tileSizeMapPoints:P}),C.objectsData[F]={objectId:h,size:C.indices.offset-F}}),!l&&(!r.AALinesOff||!lh(n,i))){const j=e.getBucket("polygonExtrusion","sideStroke",T,Vn.sinks.sideStroke.binder);U=j.indices.offset,$c(j,f,o,a,c,g),Yc(j,f,o,a,c,y,g),j.objectsData[U]={objectId:h,size:j.indices.offset-U}}}const E=e.getBucket("polygonExtrusion","topFill",T,Vn.sinks.topFill.binder);let S=E.indices.offset;x2(E,f,o,a,y,b,v,g),E.objectsData[S]={objectId:h,size:E.indices.offset-S};const L=e.getBucket("polygonExtrusion","topStroke",T,Vn.sinks.topStroke.binder);S=L.indices.offset,_2(L,f,o,a,c,y,g),L.objectsData[S]={objectId:h,size:L.indices.offset-S}}};function x2(e,t,n,i,s,r,o,a){let c=e.elements.offset;const l=c;Wc(e,c++,n[0],i[0],s,r,o,a),Wc(e,c++,n[1],i[1],s,r,o,a);for(let d=2;d<t;d++)P2(e,l,d),Wc(e,c++,n[d],i[d],s,r,o,a);e.elements.offset=c}function _2(e,t,n,i,s,r,o){for(let a=0;a<t;a++){const c=ut(a,t);if(s&&s[c]===1){const l=ut((a+1)%t,t);Gs(e,n[c],i[c],r,n[l],i[l],r,o)}}}function Wc(e,t,n,i,s,r,o,a){const c=e.elements.stride,l=t*(c/e.views.position.BYTES_PER_ELEMENT),d=t*(c/e.views.height.BYTES_PER_ELEMENT);e.views.position[l]=z+n,e.views.position[l+1]=z+i,e.views.height[d]=nt(s)/Ge,e.views.demPosition[l]=(z+a[0])/8,e.views.demPosition[l+1]=(z+a[1])/8;const u=t*(c/e.views.localID.BYTES_PER_ELEMENT);e.views.localID[u]=r,e.views.labelingTextureID[u]=o}function P2(e,t,n){const i=e.indices.buffer;let s=e.indices.offset;n%2===0?(i[s++]=t+n-2,i[s++]=t+n-1,i[s++]=t+n):(i[s++]=t+n-1,i[s++]=t+n-2,i[s++]=t+n),e.indices.offset=s}function dh(e){return re(io-Math.abs(e[0]-io),2)+re(io-Math.abs(e[1]-io),2)}function L2(e){return e[0]===0||e[0]===te||e[1]===0||e[1]===te}function D2(e,t,n){let i,s=re(te,2);const r=e.length,o=vs();for(let a=0;a<r;a++){i||ri(o,[e[a],t[a]]);const c=ut(a,r);if(n[c]===0){const l=[e[c],t[c]],d=ut((a+1)%r,r),u=[e[d],t[d]];if(L2(l)){const f=dh(l);f<s&&(i=l,s=f);const h=dh(u);h<s&&(i=u,s=h)}else i=[(e[c]+e[d])/2,(t[c]+t[d])/2]}}return i||(i=[],_r(i,o)),i}const Vs={type:li.Striped,cDist:0,oLen:0,sLen:0,localID:0,offsetMultiplier:14,px:[],py:[],count:0};function O2(e,t,n,i){return Vs.cDist=e,Vs.oLen=t,Vs.localID=n,Vs.offsetMultiplier=i,Vs}const gn={symbol:"dashedLine",sinks:{stroke:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.vertexDistance=new Float32Array(t,12),e.views.componentDistance=new Float32Array(t,16),e.views.objectLength=new Float32Array(t,20),e.views.localID=new Uint32Array(t,24)},packObjectAttributes(e,t,n,i,s){return Ce([e,t.innerId,n,i],t,s)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],tileData:e.slice(4)}}},stroke3d:{stride:32,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.vertexDistance=new Float32Array(t,12),e.views.componentDistance=new Float32Array(t,16),e.views.objectLength=new Float32Array(t,20),e.views.height=new Float32Array(t,24),e.views.localID=new Uint32Array(t,28)},packObjectAttributes(e,t,n){return Ce([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}},generate(e,t,n,i,s,r){var b;const o=Hr($(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i,l=$(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],d=a[c.db_hidden_by_metro_building_id]||"";let u=n.style.mode==="3d";const f=u?(b=o.z)!=null?b:jc(i,o):void 0;u&&(!f||!Vc(f))&&(u=!1);const h=u?e.getBucket(n.type,"stroke3d",gn.sinks.stroke3d.packObjectAttributes(t,n,i),gn.sinks.stroke3d.binder):e.getBucket(n.type,"stroke",gn.sinks.stroke.packObjectAttributes(t,n,l,d,i),gn.sinks.stroke.binder),g=e.idIndexer.getIndex(i,t,n),w=O2(a[c.componentDistanceStart]/te,a[c.objectLength]/te,g,u?gn.sinks.stroke3d.stride/2:gn.sinks.stroke.stride/2),p=Number.isNaN(a[c.beginningIsCut])?!1:a[c.beginningIsCut]!==0,y=Number.isNaN(a[c.endingIsCut])?!1:a[c.endingIsCut]!==0;Tc(o.x,o.y,f,o.x.length,p?_e.TileCut:_e.Butt,y?_e.TileCut:_e.Butt,a[c.previousPointX],a[c.previousPointY],a[c.nextPointX],a[c.nextPointY],w,h)}},so=[Ge/2,Ge/2],wn={symbol:"buildingModel",sinks:{fill:{stride:24,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.texCoords=new Uint16Array(t,8),e.views.localID=new Uint32Array(t,12),e.views.demPosition=new Int16Array(t,16),e.views.labelingTextureID=new Uint32Array(t,20)},packObjectAttributes:(e,t,n,i,s,r)=>Ce([e,t.innerId,n,s,i],t,r),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],texture:e[2],id:e[3],matrix:e[4],tileData:e.slice(5)})},stroke:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12)},packObjectAttributes:(e,t,n,i,s)=>Ce([e,t.innerId,i,n],t,s),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],id:e[2],matrix:e[3],tileData:e.slice(4)})}},processSubmesh(e,t,n,i,s,r,o,a,c){var h;const l=(h=n.id)!=null?h:"",d=i.idIndexer.getIndex(n,e,t),u=i.pointIndexer.getIndex(l),f=i.getBucket(t.type,"fill",wn.sinks.fill.packObjectAttributes(e,t,a,c,l,n),wn.sinks.fill.binder,o);C2(f,r);for(let g=0;g<s.length;g++)F2(f,s,g,d,u)},processOuterEdge(e,t,n,i,s,r,o){var l;const a=(l=n.id)!=null?l:"",c=i.getBucket(t.type,"stroke",wn.sinks.stroke.packObjectAttributes(e,t,o,a,n),wn.sinks.stroke.binder);for(let d=0;d<r.length;d+=2){const u=r[d]*5,f=r[d+1]*5;Gs(c,s[u],s[u+1],s[u+2],s[f],s[f+1],s[f+2],so,!0)}}};function F2(e,t,n,i,s){const r=e.elements.offset,o=wn.sinks.fill.stride,a=n*5,c=r*(o/e.views.position.BYTES_PER_ELEMENT),l=r*(o/e.views.localID.BYTES_PER_ELEMENT);e.views.position[c]=t[a],e.views.position[c+1]=t[a+1],e.views.height[l]=t[a+2]/Ge,e.views.texCoords[c]=t[a+3],e.views.texCoords[c+1]=t[a+4],e.views.localID[l]=i,e.views.demPosition[c]=so[0]/8,e.views.demPosition[c+1]=so[1]/8,e.views.labelingTextureID[l]=s,e.elements.offset++}function C2(e,t){const n=e.elements.offset;let i=e.indices.offset;for(let s=0;s<t.length;s++)e.indices.buffer[i++]=n+t[s];e.indices.offset=i}const Wi=Fe(),Hs=Fe(),Zi={type:li.Entrance,offsetMultiplier:18,cDist:0,oLen:0,sLen:0,px:[],py:[],count:0,localID:0};function R2(e,t,n,i){return Zi.px=e.x,Zi.py=e.y,Zi.oLen=n/te,Zi.count=t,Zi.localID=i,Zi}const $s={symbol:"arrow",sinks:{stroke:{stride:36,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.segmentEnd=new Uint16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.arrowExtender=new Int8Array(t,10),e.views.extender=new Int16Array(t,12),e.views.direction=new Int16Array(t,16),e.views.vertexDistance=new Float32Array(t,20),e.views.objectLength=new Float32Array(t,24),e.views.type=new Float32Array(t,28),e.views.localID=new Uint32Array(t,32)},packObjectAttributes(e,t,n,i){return Ce([e,t.innerId,n>2?1:0],t,i)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],isLongArrow:e[2],tileData:e.slice(3)}}}},generate:(e,t,n,i,s)=>{const r=s.x,o=s.y,a=s.x.length,c=N2(r,o,a),l=e.getBucket(n.type,"stroke",$s.sinks.stroke.packObjectAttributes(t,n,a,i),$s.sinks.stroke.binder),d=e.idIndexer.getIndex(i,t,n),u=R2(s,a,c,d);Tc(s.x,s.y,void 0,a,_e.Butt,_e.Butt,0,0,0,0,u,l);let f=0;uh(l,Es.StartBorder,r[0],o[0],r[1],o[1],0,0,f,c,d);for(let h=0;h<a-1;h++){if(h!==0){const g=r[h]-r[h-1],w=o[h]-o[h-1];f+=Math.sqrt(g*g+w*w)}uh(l,Es.Arrow,r[h],o[h],r[h+1],o[h+1],-1,0,f,c,d)}}};function N2(e,t,n){let i=0;for(let s=1;s<n;s++){const r=e[s]-e[s-1],o=t[s]-t[s-1];i+=Math.sqrt(r*r+o*o)}return i}function uh(e,t,n,i,s,r,o,a,c,l,d){k2(e,1,2,0,0,2,3),ro(e,t,n,i,s,r,o,a,-1,-1,c,l,!0,d),ro(e,t,n,i,s,r,o,a,1,-1,c,l,!1,d),ro(e,t,n,i,s,r,o,a,1,1,c,l,!1,d),ro(e,t,n,i,s,r,o,a,-1,1,c,l,!0,d)}function ro(e,t,n,i,s,r,o,a,c,l,d,u,f,h){const g=e.elements,w=g.stride*g.offset,p=w>>1,y=p>>1;en(Wi,n,i,s,r),Rn(Hs,Wi),e.views.position[p]=z+n,e.views.position[p+1]=z+i,e.views.segmentEnd[p]=z+s,e.views.segmentEnd[p+1]=z+r,e.views.texExtender[w]=$e(Hs[0]*l*(f?-1:1)*Ne),e.views.texExtender[w+1]=$e(Hs[1]*l*(f?-1:1)*Ne),e.views.arrowExtender[w]=$e(c*Ne),e.views.arrowExtender[w+1]=$e(l*Ne);const b=c+o,v=l+a,T=Wi[0]*b+Hs[0]*v,E=Wi[1]*b+Hs[1]*v;e.views.extender[p]=Math.round(T*Ne*127),e.views.extender[p+1]=Math.round(E*Ne*127),e.views.direction[p]=Math.round(Wi[0]*127),e.views.direction[p+1]=Math.round(Wi[1]*127),e.views.vertexDistance[y]=d/Ge,e.views.objectLength[y]=u/Ge,e.views.type[y]=t,e.views.localID[y]=h,e.elements.offset++}function k2(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,u=a.offset;l[d]=u+t,l[d+1]=u+n,l[d+2]=u+i,l[d+3]=u+s,l[d+4]=u+r,l[d+5]=u+o,c.offset=d+6}const oo={symbol:"circle",sinks:{fill:{stride:20,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.ecefPosition=new Int16Array(t,6),e.views.extender=new Int16Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes:(e,t,n)=>Ce([e,t.innerId],t,n),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tileData:e.slice(2)})}},generate(e,t,n,i,s){const r=e.getBucket(n.type,"fill",oo.sinks.fill.packObjectAttributes(t,n,i),oo.sinks.fill.binder),o=e.idIndexer.getIndex(i,t,n),a=[s.x[0],s.y[0],s.z?s.z[0]:0],c=i.tileInfo?dc(i.tileInfo,a):[0,0,0];B2(r,0,2,1,0,3,2),ao(r,a,c,-1,-1,o),ao(r,a,c,-1,1,o),ao(r,a,c,1,1,o),ao(r,a,c,1,-1,o)}};function ao(e,[t,n,i],s,r,o,a){const l=e.elements.offset*e.elements.stride>>1,d=l>>1;e.views.flatPosition[l]=z+t,e.views.flatPosition[l+1]=z+n,e.views.flatPosition[l+2]=nt(i),e.views.ecefPosition[l]=s[0]*ot,e.views.ecefPosition[l+1]=s[1]*ot,e.views.ecefPosition[l+2]=s[2]*ot,e.views.extender[l]=r,e.views.extender[l+1]=o,e.views.localID[d]=a,e.elements.offset++}function B2(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,u=a.offset;l[d]=u+t,l[d+1]=u+n,l[d+2]=u+i,l[d+3]=u+s,l[d+4]=u+r,l[d+5]=u+o,c.offset=d+6}const Xi=Fe(),qi=Fe(),fh=Fe(),hh=Fe(),Zc=(e,t,n,i)=>Ce([e,t.innerId,n],t,i),Xc=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],tileData:e.slice(3)}),Ys=tf(1),vn={symbol:"lineExtrusion",sinks:{fill:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8)},packObjectAttributes:Zc,unpackObjectAttributes:Xc},topStroke:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12)},packObjectAttributes:Zc,unpackObjectAttributes:Xc},sideStroke:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.normals=new Int8Array(t,8),e.views.direction=new Int8Array(t,12),e.views.distance=new Int8Array(t,15),e.views.demPosition=new Int16Array(t,16)},packObjectAttributes:Zc,unpackObjectAttributes:Xc}},generate(e,t,n,i,s,r){const o=s.x,a=s.y,c=o.length,l=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",d=e.getBucket(n.type,"fill",vn.sinks.fill.packObjectAttributes(t,n,l,i),vn.sinks.fill.binder),u=e.getBucket(n.type,"topStroke",vn.sinks.topStroke.packObjectAttributes(t,n,l,i),vn.sinks.topStroke.binder),f=e.getBucket(n.type,"sideStroke",vn.sinks.sideStroke.packObjectAttributes(t,n,l,i),vn.sinks.sideStroke.binder),h=!r.AALinesOff||!lh(n,i);for(let g=0;g<c-1;g++){const w=o[g],p=a[g],y=o[g+1],b=a[g+1];je(Xi,w,y),je(qi,p,b),je(fh,y,w),je(hh,b,p),Hc(d,2,Xi,qi,void 0,Ys),Gs(u,w,p,Ys,y,b,Ys),h&&($c(f,2,Xi,qi,void 0),$c(f,2,fh,hh,void 0),Yc(f,2,Xi,qi,void 0,Ys))}h&&(je(Xi,o[c-1],o[0]),je(qi,a[c-1],a[0]),Yc(f,2,Xi,qi,void 0,Ys))}},co={symbol:"raster",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.txtrCoords=new Uint16Array(t,4)},packObjectAttributes(e,t,n,i,s){return Ce([e,t.innerId,i,s],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],textureIndex:e[2],tiers:e[3],tileData:e.slice(4)}}}},generate(e,t,n,i,s,r,o){const a=t.x,c=t.y,l=e.getBucket(s.type,"fill",co.sinks.fill.packObjectAttributes(n,s,i,r,o),co.sinks.fill.binder);let d=l.elements.offset;U2(l.indices,d,0,1,2,2,1,3),lo(l,d++,a[0],c[0],0,1),lo(l,d++,a[1],c[1],1,1),lo(l,d++,a[2],c[2],0,0),lo(l,d++,a[3],c[3],1,0),l.elements.offset=d}};function lo(e,t,n,i,s,r){t=t*4,e.views.position[t]=z+n,e.views.position[t+1]=z+i,e.views.txtrCoords[t]=At(s),e.views.txtrCoords[t+1]=At(r)}function U2(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function qc(e,t,n,i,s,r){return Ce([e,t.innerId,n,i,s],t,r)}const z2=(e,t,n,i,s)=>Ce([e,t.innerId,n,i],t,s),Jc=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],hiddenByFloorComplexId:e[4],tileData:e.slice(5)}),G2=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],tileData:e.slice(4)}),j2=(e,t)=>{const n=e.type==="polygon"&&$(e.style.color,t),i=mf(n)&&n.factor.type==="vertexAttribute";return i?{withMixFactor:i,mixFactorAttributeName:n.factor.name}:{withMixFactor:i,mixFactorAttributeName:void 0}},Wt={symbol:"polygon",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.localID=new Uint32Array(t,4)},packObjectAttributes:qc,unpackObjectAttributes:Jc},stroke:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.directionDistance=new Int8Array(t,4)},packObjectAttributes:qc,unpackObjectAttributes:Jc},shadow:{stride:4,binder:(e,t)=>{e.views.position=new Uint16Array(t)},packObjectAttributes:z2,unpackObjectAttributes:G2},fillWithMixFactor:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.mixFactor=new Uint16Array(t,4)},packObjectAttributes:qc,unpackObjectAttributes:Jc}},generate(e,t,n,i,s,r,o){var S;if(i.tileAttrs[i.tileProps.db_geometry_type]==="polyline")return;const{withMixFactor:c,mixFactorAttributeName:l}=j2(n,i),d=s.x,u=s.y,f=s.cut,h=i.tileAttrs[i.tileProps.db_plan_id]||"",g=c?s[l]:void 0;if(M2(n)&&o&&(Gc(e,t,o,n.style,r),n.style.normalMapTextureImage)){const L={textureImage:n.style.normalMapTextureImage,textureSize:n.style.normalMapTextureSize,lengthUnits:n.style.normalMapTextureLengthUnits};Gc(e,t,o,L,r)}const w=e.idIndexer.getIndex(i,t,n,{floorId:h||void 0}),p=(S=i.id)!=null?S:"",y=n.type==="polygon"&&!$(n.ignoreTier,i)?i.tileAttrs[i.tileProps.db_tiers]:null,b=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",v=c?e.getBucket("polygon","fillWithMixFactor",Wt.sinks.fillWithMixFactor.packObjectAttributes(t,n,y,h,b,i),Wt.sinks.fillWithMixFactor.binder):e.getBucket("polygon","fill",Wt.sinks.fill.packObjectAttributes(t,n,y,h,b,i),Wt.sinks.fill.binder),T=v.indices.offset;ph(v,d.length,d,u,w,g),v.objectsData[T]={objectId:p,size:v.indices.offset-T};const E=e.getBucket("polygon","stroke",Wt.sinks.stroke.packObjectAttributes(t,n,y,h,b,i),Wt.sinks.stroke.binder);if(f){const L=E.indices.offset;V2(E,d.length,d,u,f),E.objectsData[L]={objectId:p,size:E.indices.offset-L}}}};function ph(e,t,n,i,s,r){const o=e.indices.buffer;let a=e.indices.offset,c=e.elements.offset;const l=c;Kc(e,c++,n[0],i[0],s,r==null?void 0:r[0]),Kc(e,c++,n[1],i[1],s,r==null?void 0:r[1]);for(let d=2;d<t;d++)H2(o,a,l,d),Kc(e,c++,n[d],i[d],s,r==null?void 0:r[d]),a=a+3;e.elements.offset=c,e.indices.offset=a}function V2(e,t,n,i,s){for(let r=0;r<t;r++){const o=ut(r,t);if(s[o]===1){const a=ut((r+1)%t,t);Gs(e,n[o],i[o],0,n[a],i[a],0)}}}function Kc(e,t,n,i,s,r){t=t*e.elements.stride/e.views.position.BYTES_PER_ELEMENT,e.views.position[t]=z+n,e.views.position[t+1]=z+i,r!==void 0&&"mixFactor"in e.views&&(e.views.mixFactor[t]=r),t=t>>1,"localID"in e.views&&(e.views.localID[t]=s)}function H2(e,t,n,i){i%2===0?(e[t]=n+i-2,e[t+1]=n+i-1,e[t+2]=n+i):(e[t]=n+i-1,e[t+1]=n+i-2,e[t+2]=n+i)}function $2(e,t,n=[],i=[]){return{x:mh(n,e),y:mh(i,t)}}function mh(e,t){const n=e.reduce((s,r)=>s.concat(r),[0]).concat(t),i=n.length-1;return{coords:n.slice(n[0]===n[1]?1:0,n[i-1]===n[i]?i:i+1),isOddStretchable:Y2(e)}}function Y2(e){var t;return!((t=e==null?void 0:e[0])!=null&&t[0])}function W2(e,t,n,i,s){return[yh(e.x,t,i[0],s),yh(e.y,n,i[1],s)]}function yh(e,t,n,i){if(e.coords.length<2)throw new Error("The source coords array must have at least two coordinates");return e.coords.map((s,r)=>(t+s+i*(r===0?-1:r===e.coords.length-1?1:0))/n)}function Z2(e,t,n,i,s=0,r=0){return[wh(gh(e.x,t),i,s),wh(gh(e.y,n),i,r)]}function gh(e,t){const{stretchSize:n,fixSize:i}=X2(e),{coords:s,isOddStretchable:r}=e,o=t<i?i:t,a=[s[0]];for(let c=1;c<s.length;c++){const l=s[c-1],d=s[c],u=c%2===(r?1:0),f=a[a.length-1];if(!u){a.push(f+d-l);continue}a.push(Math.round((o-i)*(d-l)/n)+f)}return a}function X2({coords:e,isOddStretchable:t}){if(e.length<2)throw new Error("An axis must have at least two coordinates");if(e.length===2)return{stretchSize:e[e.length-1],fixSize:0};let n=0;for(let i=t?0:1;i<e.length-1;i=i+2)n+=e[i+1]-e[i];return{stretchSize:n,fixSize:e[e.length-1]-n}}function wh(e,t,n=0){const i=e[e.length-1]-e[0],s=e.map(r=>Math.round(r-i/2+n));return s.length===2?s[s.length-1]+=2*t:(s[0]-=t,s[s.length-1]+=t),s}function q2(e,t,n,i,s,r,o,a,c){const l=$2(n.w,n.h,a,c),d=W2(l,n.x,n.y,t,Dd),u=Z2(l,i,s,Dd,r,o);e.set(u,d)}function J2(e,t,n,i,s,r,o,a,c,l,d,u){const{textureX:f,textureY:h,stretchedX:g,stretchedY:w,countX:p,countY:y}=s,b=o!==-1/0?o:jm,v=a!==1/0?a:Vm,[T,E]=u;for(let S=0;S<p-1;S++){const L=f[S],x=f[S+1],O=g[S],B=g[S+1];for(let U=0;U<y-1;U++){const j=h[U],M=h[U+1],I=w[U],X=w[U+1];vh(r,0,2,1,1,2,3),uo(r,e,t,n,i,O,I,L,j,T,E,b,v,c,l,d),uo(r,e,t,n,i,B,I,x,j,T,E,b,v,c,l,d),uo(r,e,t,n,i,O,X,L,M,T,E,b,v,c,l,d),uo(r,e,t,n,i,B,X,x,M,T,E,b,v,c,l,d)}}}const gi=[0,0];function K2(e,t,n,i,s,r,o){const{stretchedX:a,stretchedY:c}=i,l=Math.ceil((a[a.length-1]-a[0])/2),d=Math.ceil((c[c.length-1]-c[0])/2),u=r*wa/2;gi[0]=a[0]+l,gi[1]=c[0]+d;const f=gi[0]-u,h=gi[0]+u,g=gi[1]-u,w=gi[1]+u;return vh(s,0,2,1,1,2,3),fo(s,e,t,n,f,g,o),fo(s,e,t,n,h,g,o),fo(s,e,t,n,f,w,o),fo(s,e,t,n,h,w,o),gi}function uo(e,t,n,i,s,r,o,a,c,l,d,u,f,h,g,w){let p=e.elements.offset*20;e.views.flatPosition[p]=z+t,e.views.flatPosition[p+1]=z+n,e.views.flatPosition[p+2]=nt(i),e.views.ecefPosition[p]=s[0]*ot,e.views.ecefPosition[p+1]=s[1]*ot,e.views.ecefPosition[p+2]=s[2]*ot,e.views.cornerOffset[p]=r,e.views.cornerOffset[p+1]=-o,e.views.checkPointOffset[p]=l,e.views.checkPointOffset[p+1]=d,e.views.texCoords[p]=At(a),e.views.texCoords[p+1]=At(c),e.views.scales[p]=Xv(u),e.views.scales[p+1]=Zv(f),p=p>>1,e.views.localID[p]=h,e.views.labelingTextureID[p]=g,e.views.spritePointTextureID[p]=w,e.elements.offset++}function fo(e,t,n,i,s,r,o){const a=e.elements,c=a.stride*a.offset>>1;e.views.position[c]=z+t,e.views.position[c+1]=z+n,e.views.position[c+2]=nt(i),e.views.cornerOffset[c]=s,e.views.cornerOffset[c+1]=-r,e.views.labelingTextureID[c>>1]=o,a.offset++}function vh(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,u=a.offset;l[d]=u+t,l[d+1]=u+n,l[d+2]=u+i,l[d+3]=u+s,l[d+4]=u+r,l[d+5]=u+o,c.offset=d+6}class Q2{constructor(){this.countX=0,this.countY=0,this.textureX=[],this.textureY=[],this.stretchedX=[],this.stretchedY=[]}reset(){this.countX=0,this.countY=0}set(t,n){this.countX=n[0].length,this.countY=n[1].length,this.textureX=n[0],this.textureY=n[1],this.stretchedX=t[0],this.stretchedY=t[1]}isEmpty(){return this.countX===0||this.countY===0}}var ft=(e=>(e[e.Common=0]="Common",e[e.Commercial=1]="Commercial",e[e.CommercialCity=2]="CommercialCity",e[e.CommercialPremium=3]="CommercialPremium",e[e.Landmark=4]="Landmark",e))(ft||{}),wi=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e))(wi||{}),Ws=(e=>(e[e.Tile=0]="Tile",e[e.Floor=1]="Floor",e[e.DynamicObject=2]="DynamicObject",e[e.PersonalPoi=3]="PersonalPoi",e))(Ws||{}),Rt=(e=>(e[e.Dead=0]="Dead",e[e.Alive=1]="Alive",e[e.Unused=2]="Unused",e[e.CommercialAlive=3]="CommercialAlive",e[e.CommercialDead=4]="CommercialDead",e))(Rt||{}),Ye=(e=>(e[e.Text=0]="Text",e[e.Icon=1]="Icon",e[e.PoiText=2]="PoiText",e[e.PoiText2=3]="PoiText2",e[e.OneWayLine=4]="OneWayLine",e[e.LineText=5]="LineText",e[e.Box=6]="Box",e))(Ye||{});let bh=Math.random;const eb=e=>{const t={randomSeed:0};If(t,[e]),bh=()=>Os(t,0,1)};function tb(e,t,n,i){const s=Ih(e,n,i),r=Ih(t,n,i);return s===void 0&&r===void 0?!0:s===void 0?r!==void 0?r:!0:r===void 0?s!==void 0?s:!0:s||r}function Ih(e,t,n){const i=e[t];if(i!==void 0)return i[n]}var bn=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e[e.OneWayLine=2]="OneWayLine",e))(bn||{});function ht(e,t){return Number.isNaN(e)?t:e}function ho(e,t){if(!e)return"";const n=$(e,t);return!Number.isNaN(n)&&(n||n===0)?String(n):""}const pt=4294967295,In=4294967040,nb=In-1,Qc={},ib=1e6,Mh=["main","parser","labeling","models"];let el=0;Mh.forEach(e=>{const t=el+Math.floor(nb/Mh.length);Qc[e]={min:el,max:t-ib},el=t});class sb{constructor(t){this.ids=[],this.orphanIds=[],this.phases=[],this.sublayers=[],this.styleIds=[],this.layerIds=[],this.instanceIds=[],this.objectClasses=[],this.floorIds=[],this.center=[],this.strings={},this.minIdentifyIndex=Qc[t].min,this.maxIdentifyIndex=Qc[t].max,this.index=this.minIdentifyIndex}getIndex(t,n,i,s={}){const{id:r,tileProps:o,tileAttrs:a}=t,c=i.interactive,l=s.ignoreHover?!1:a[o.hovered],d=l&&i.type!=="polygon3d"||i.type==="embankment";return!!r&&c&&!l&&!d?this.getIndexInternal(ue({id:r,styleId:n,layer:i,sublayer:a[o.db_sublayer]},s)):pt}getIndexInternal(t){var r,o,a,c,l,d,u;const n=this.index+this.ids.length;this.ids.push(t.id),this.floorIds.push((r=t.floorId)!=null?r:""),this.phases.push(t.layer.renderIndex),this.sublayers.push((c=(a=(o=t.metatile)==null?void 0:o.dictionaries.db_sublayer)==null?void 0:a[t.sublayer])!=null?c:NaN),this.styleIds.push(t.styleId),this.layerIds.push(t.layer.innerId),this.instanceIds.push((l=t.instanceId)!=null?l:0);const{center:i,objectClass:s}=t;if(i?this.center.push(Math.round(i[0]),Math.round(i[1])):this.center.push(ga,ga),typeof s=="string"){const f=(u=(d=t.metatile)==null?void 0:d.dictionaries.db_object_class)==null?void 0:u[s];f?this.objectClasses.push(f):(this.objectClasses.push(0),this.strings[n]={objectClass:s})}else this.objectClasses.push(pt);return n}addOrphanId(t){this.orphanIds.push(t)}getIndexerStats(){return{ids:this.ids.length,orphanIds:this.orphanIds.length,floorIds:this.floorIds.length,phases:this.phases.length,sublayers:this.sublayers.length,styleIds:this.styleIds.length,layerIds:this.layerIds.length,instanceIds:this.instanceIds.length,objectClasses:this.objectClasses.length,strings:Object.keys(this.strings).length,center:this.center.length}}getPacked(){const t=this.ids,n=this.orphanIds,i=this.floorIds,s=new Float32Array(this.phases).buffer,r=new Uint32Array(this.sublayers).buffer,o=new Uint16Array(this.styleIds).buffer,a=new Uint32Array(this.layerIds).buffer,c=new Uint8Array(this.instanceIds).buffer,l=new Uint32Array(this.objectClasses).buffer,d=new Int32Array(this.center).buffer,u=this.index,f=this.index+this.ids.length-1;this.index=this.index+this.ids.length,this.index>this.maxIdentifyIndex&&(this.index=this.minIdentifyIndex);const h=this.strings;return this.ids=[],this.orphanIds=[],this.floorIds=[],this.phases=[],this.sublayers=[],this.styleIds=[],this.layerIds=[],this.instanceIds=[],this.objectClasses=[],this.strings={},this.center=[],{idBuffer:t,orphanIds:n,floorIdBuffer:i,startIndex:u,endIndex:f,phaseBuffer:s,sublayerBuffer:r,styleIdBuffer:o,layerIdBuffer:a,instanceIdBuffer:c,objectClassBuffer:l,centerBuffer:d,strings:h}}}function rb(e){return e.type==="labelLine"||e.type==="point"||e.type==="oneWayLine"}function ob(e,t,n,i,s){const r=[];for(const o of e)for(const a of o.labels){const c=n.getStyle(a.styleId);if(!c){console.error(`Not found style ${a.styleId} in unpackPreLabelingResult`);continue}const l=c.layersById[a.layerId];if(!l||!rb(l)){console.error(`Not found layer: ${a.layerId} in style ${a.styleId} in unpackPreLabelingResult`);continue}const d=new tl(a,l,t,o.metatileHash,!!i.floorStackOn);switch(a.type){case bn.Point:d.setSpecificPointAttributes(a,i,s);break;case bn.Line:d.setSpecificLineAttributes(a,i,s);break;case bn.OneWayLine:d.setSpecificOneWayAttributes(a);break}r.push(d)}return r}class tl{constructor(t,n,i,s,r){this.rtlProcessed=!1,this.labelingElements=[],this.id="",this.floorId="",this.planLevel=NaN,this.detailLevel=0,this.labelPriority=0,this.label="",this.ranges=[],this.pointType=ft.Common,this.iconPriority=0,this.styleIconPriority=0,this.styleTextPriority=0,this.identifyIndex=pt,this.identifyPoiLabelIndex=pt,this.labelingTextureIndex=pt,this.spritePointTextureIndex=pt,this.hovered=0,this.label2Priority=0,this.mapPointVertices=[0,0,0],this.geoPoint=[NaN,NaN],this.demElevation=0,this.elevation=0,this.componentDistanceStartWorld=0,this.componentDistanceEnd=0,this.componentDistanceStart=0,this.objectLengthWorld=0,this.checkPointOffset=[0,0],this.layer=n,this.styleId=t.styleId,this.source=i,this.sourceId=t.sourceId,this.metatileHash=s,this.geometryType=t.type===bn.Point?t.geometryType:wi.Line,this.tileData=t.tileData,this.labelPriority=t.labelPriority,this.detailLevel=t.tileCoords[2],this.styleIconPriority=t.styleIconPriority,this.styleTextPriority=t.styleTextPriority,this.id=t.id,this.floorId=t.floorId,this.planLevel=r?Math.max(0,t.planLevel):0}setSpecificPointAttributes(t,n,i){if(this.layer.type!=="point")throw new Error("Label: layer type is not a point");const s=this.layer.style;this.pointType=t.pointType,this.label2Priority=t.label2Priority,this.iconPriority=t.iconPriority,this.identifyIndex=t.identifyIndex,this.identifyPoiLabelIndex=t.identifyPoiLabelIndex,this.labelingTextureIndex=t.labelingTextureIndex,this.spritePointTextureIndex=t.spritePointTextureIndex,this.hovered=t.hovered,this.demElevation=t.demElevation;const r=Vt(i,n,!0,t.tileData);this.label=wc(ho(s.textField,r),s.textMaxLengthPerLine),s.textField2&&(this.label2=wc(ho(s.textField2,r),s.textMaxLengthPerLine)),this.layer.type==="point"&&s.iconTextField&&(this.iconLabel=wc(ho(s.iconTextField,r),s.textMaxLengthPerLine));const o=ct(t.tileCoords);this.mapPointVertices=[];const a=[0,0,0],c=[0,0,0];if(t.geometryType===wi.Point)Qu(this.mapPointVertices,t.vertices,0,o),this.geoPoint=oe.toGeo(this.mapPointVertices),this.layer.style.allowElevation||(this.mapPointVertices[2]=0);else{for(let l=0;l<t.vertices[0].length;l++)a[0]=t.vertices[0][l],a[1]=t.vertices[1][l],Mt(c,a,o),this.mapPointVertices.push(c[0],c[1],c[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Ui(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Ui(t.objectLength,t.tileCoords[2])}}setSpecificLineAttributes(t,n,i){if(this.layer.type!=="labelLine")throw new Error("Label: layer type is not a labelLine");const s=Vt(i,n,!0,t.tileData);this.label=ho(this.layer.style.textField,s);const r=ct(t.tileCoords);this.mapPointVertices=[];const o=[0,0,0],a=[0,0,0];for(let c=0;c<t.vertices[0].length;c++)o[0]=t.vertices[0][c],o[1]=t.vertices[1][c],Mt(a,o,r),this.mapPointVertices.push(a[0],a[1],a[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Ui(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Ui(t.objectLength,t.tileCoords[2]),this.tiers=$(this.layer.ignoreTier,s)?void 0:t.tiers}setSpecificOneWayAttributes(t){const n=ct(t.tileCoords);this.mapPointVertices=[];const i=[0,0,0],s=[0,0,0];for(let r=0;r<t.vertices[0].length;r++)i[0]=t.vertices[0][r],i[1]=t.vertices[1][r],Mt(s,i,n),this.mapPointVertices.push(s[0],s[1],s[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Ui(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Ui(t.objectLength,t.tileCoords[2]),this.tiers=t.tiers}updateRanges(){this.ranges=aw([this.label,this.label2,this.iconLabel])}}function Hn(e,t,n){const{minX:i,maxX:s,minY:r,maxY:o}=n;e.push(i,r,s-i,o-r,t)}function Mn(e,t,n,i){const s=e.anchorScreen,r=e.boxes[t];return{element:e,minX:s[0]+r[0]-n,maxX:s[0]+r[2]+n,minY:s[1]+r[1]-i,maxY:s[1]+r[3]+i}}function ab(e,t){if(e.parent===t||e.firstLabel===t||t.parent===e||t.firstLabel===e)return!1;const n=e.labelingGroup,i=t.labelingGroup,s=e.labelingGroupTable,r=t.labelingGroupTable;return tb(s,r,n,i)}function nl(e,t,n,i,s,r){const o=Mn(t,n,i,s);if(o.minX>r.maxX||o.maxX<r.minX||o.minY>r.maxY||o.maxY<r.minY)return!0;const a=e.search(o);for(let c=0;c<a.length;c++)if(ab(t,a[c].element))return!0;return!1}function Th(e,t,n,i,s){if(e.placementIndex===-1){s&&Hn(s,Rt.CommercialDead,Mn(e,0,i.leftRight,i.topBottom));return}if(nl(t,e,0,i.leftRight,i.topBottom,n))e.placementIndex=-1,s&&Hn(s,Rt.CommercialDead,Mn(e,0,i.leftRight,i.topBottom));else{e.placementIndex=0;const o=Mn(e,0,i.leftRight,i.topBottom);t.insert(o),s&&Hn(s,Rt.CommercialAlive,o)}}function il(e,t,n,i){let s=!0;for(let r=0;r<e.boxes.length;r++)if(nl(t,e,r,e.marginLeftRight,e.marginTopBottom,n)){if(s=!1,i)for(let o=0;o<e.boxes.length;o++){const a=Mn(e,o,e.marginLeftRight,e.marginTopBottom);let c;o===r?c=Rt.Dead:o<r?c=Rt.Alive:c=Rt.Unused,Hn(i,c,a)}break}if(s)for(let r=0;r<e.boxes.length;r++){const o=Mn(e,r,e.marginLeftRight,e.marginTopBottom);t.insert(o),i&&Hn(i,Rt.Alive,o)}e.placementIndex=s?0:-1}function cb(e,t,n,i){e.placementIndex=-1;for(let s=0;s<e.boxes.length;s++)if(!(e.firstLabel&&e.firstLabel.placementIndex!==s))if(nl(t,e,s,e.marginLeftRight,e.marginTopBottom,n))i&&Hn(i,Rt.Dead,Mn(e,s,e.marginLeftRight,e.marginTopBottom));else{const r=Mn(e,s,e.marginLeftRight,e.marginTopBottom);if(t.insert(r),e.placementIndex=s,i){Hn(i,Rt.Alive,r);for(let o=s+1;o<e.boxes.length;o++)Hn(i,Rt.Unused,Mn(e,o,e.marginLeftRight,e.marginTopBottom))}break}}function Sh(e,t){return e.sort((n,i)=>i.groupPriority-n.groupPriority||(t.has(i.id)?1:0)-(t.has(n.id)?1:0)||i.commPriorityRandomFactor-n.commPriorityRandomFactor)}function vi(e){return e.type!==Ye.Box&&!Number.isNaN(e.commPriorityRandomFactor)}function Ah(e){return e.label.pointType===ft.CommercialCity}function lb(e){return vi(e)&&Ah(e)}function db(e){return vi(e)&&e.label.pointType===ft.CommercialPremium}function Zs(e){return e.pointType===ft.Commercial||e.pointType===ft.CommercialCity||e.pointType===ft.CommercialPremium}function ub(e){return e.label.pointType!==ft.CommercialCity||e.placementIndex!==-1&&e.label.pointType===ft.CommercialCity}function fb(e,t){return t.size===0?!1:e.filter(i=>hb(i,t)?(i.adsType=0,!0):!1).length>0}function hb(e,t){return e.type===Ye.Icon&&t.has(e.label.id)}function pb(e){return e.type===Ye.Box&&e.labelingGroup==="markerText"&&e.parent!==void 0}function mb(e,t,n,i,s){const r=Kr();Sh(e.filter(Ah),n).forEach(a=>{Th(a,r,t,i.city,s)}),r.clear(),Sh(e.filter(ub),n).forEach(a=>{Th(a,r,t,i.default,s)})}function Eh(e,t,n,i,s){switch(e.type){case Ye.LineText:case Ye.Icon:if(e.placementIndex===-1&&vi(e))break;if(il(e,n,i,s),e.adsType===0){const o=t.get(e.label.id);if(!o)break;e.placementIndex!==-1&&(o.parent=e,il(o,n,i,s),t.delete(e.label.id))}break;case Ye.Box:if(!e.parent){il(e,n,i,s);break}e.placementIndex=-1;break;case Ye.PoiText:case Ye.PoiText2:(!e.parent||e.parent.placementIndex!==-1)&&(!e.firstLabel||e.firstLabel.placementIndex!==-1)?cb(e,n,i,s):e.placementIndex=-1;break}}function yb(e,t,n,i,s,r){const o=[],a=new Map;t.forEach(x=>{if(pb(x)){a.set(x.parent.label.id,x),x.placementIndex=-1;return}o.push(x)});const c=new Set(a.keys());let l=[];if(n.globeMode){for(const x of e)r.ecef.canSee(x.anchorGeo)?l.push(x):x.placementIndex=-1;for(const x of o)r.ecef.canSee(x.anchorGeo)?l.push(x):x.placementIndex=-1}else l=e.concat(o);const d=n.debugLabels?[]:void 0,{size:u,viewport:f}=n,h=u[0],g=u[1],w=(yr.tileMultiplier-1)/2,p=Math.round(h*w),y=Math.round(g*w),b={minX:f.left-p,maxX:f.left+h+p,minY:f.top-y,maxY:f.top+g+y},v=Kr(),T=fb(l,c),E=l.sort((x,O)=>{const B=x.label instanceof tl?x.label.hovered:0,U=O.label instanceof tl?O.label.hovered:0,j=i.has(x.id),M=i.has(O.id),I=n.disableSurvivedPoiPrevalence?0:(M?1:0)-(j?1:0),X=T?(O.adsType===0?1:0)-(x.adsType===0?1:0):0;return O.groupPriority-x.groupPriority||(vi(O)?O.commPriorityRandomFactor+ +M:0)-(vi(x)?x.commPriorityRandomFactor+ +j:0)||X||I||U-B||O.itemPriority-x.itemPriority||(O.label.id>x.label.id?1:O.label.id===x.label.id?0:-1)||O.label.layer.innerId-x.label.layer.innerId||O.anchorWorld[0]-x.anchorWorld[0]||O.anchorWorld[1]-x.anchorWorld[1]});let S=-1;const L=E.filter((x,O)=>vi(x)?(S=O,!0):!1);if(S!==-1){for(let x=0;x<=S;x++)Eh(E[x],a,v,b,d);v.clear(),mb(L,b,i,s,d)}for(let x=0;x<E.length;x++)Eh(E[x],a,v,b,d);return d}const sl=new Map;class po{constructor(t,n,i,s,r,o,a,c){if(this.anchorWorld=[0,0,0,0],this.anchorGeo=[0,0],this.groupPriority=0,this.labelingGroup=Gn,this.marginTopBottom=0,this.marginLeftRight=0,this.elevation=0,this.type=n,this.label=t,this.layer=t.layer,this.elevation=t.elevation,t.planLevel&&(this.elevation+=t.planLevel*xr(t.geoPoint,c)),this.id=t.id+"_"+n+"_"+Math.floor(i[0]/1e3)+"_"+Math.floor(i[1]/1e3)+this.getIconLabelPriorityToId(t),Su(this.anchorWorld,i),this.anchorGeo=t.geoPoint,s!==0&&(this.anchorWorld[2]*=s),a){const l=tt.fromGeo(this.anchorGeo);this.anchorScreen=r.ecef.project(l,!1)}else this.anchorScreen=r.flat.project([this.anchorWorld[0],this.anchorWorld[1],this.anchorWorld[2]+this.elevation,0]);switch(this.anchorPosition=0,this.anchorSegmentIndex=0,this.halfLabelWidth=0,this.commPriorityRandomFactor=NaN,this.itemPriority=n===Ye.Icon?t.iconPriority:t.labelPriority,this.layer.type){case"labelLine":this.labelingGroup=this.layer.style.labelingGroup,this.groupPriority=t.styleTextPriority;break;case"oneWayLine":this.labelingGroup=this.layer.style.labelingGroup,this.groupPriority=this.layer.style.priority;break;case"point":{if(Zs(t))if(sl.has(this.label.id))this.commPriorityRandomFactor=sl.get(this.label.id);else{const l=bh();this.commPriorityRandomFactor=l,sl.set(this.label.id,l)}n===Ye.PoiText?(this.labelingGroup=this.layer.style.allowOverlap?zn:this.layer.style.textLabelingGroup,this.groupPriority=this.layer.style.iconImage?Math.min(t.styleTextPriority,t.styleIconPriority):t.styleTextPriority,this.marginTopBottom=this.layer.style.textLabelingMargin.topBottom,this.marginLeftRight=this.layer.style.textLabelingMargin.leftRight):n===Ye.PoiText2?(this.labelingGroup=this.layer.style.allowOverlap?zn:this.layer.style.textLabelingGroup2,this.groupPriority=Math.min(t.styleTextPriority,t.styleIconPriority),this.marginTopBottom=this.layer.style.textLabelingMargin.topBottom,this.marginLeftRight=this.layer.style.textLabelingMargin.leftRight):(this.labelingGroup=this.layer.style.allowOverlap?zn:this.layer.style.iconLabelingGroup,this.groupPriority=t.styleIconPriority,this.marginTopBottom=this.layer.style.iconLabelingMargin.topBottom,this.marginLeftRight=this.layer.style.iconLabelingMargin.leftRight);break}}this.labelingGroupTable=o.labelingGroups.table,this.overflowStyleZoom=-1/0,this.boxes=[],this.placementIndex=0}getIconLabelPriorityToId(t){if(Zs(t))return"";const{layer:n}=t;if(n.type==="point"){const i=t.styleIconPriority.toFixed(0),s=t.styleTextPriority.toFixed(0);return"_"+i+"_"+s}return""}}function xh(e,t,n,i,s,r){if(!e||s&&!r)return[0,0];if(!r)return[e.w/t,e.h/t];const o=rl(n,i,r),a=it(n.style.iconTextPadding);return[a[3]+a[1]+o[0],a[0]+a[2]+o[1]]}function mo(e,t,n){return ol(ae(e.style.textFontSize,t),e.style.textLineHeight,n)}function _h(e,t,n){return ol(ae(e.style.textFontSize2,t),e.style.textLineHeight,n)}function rl(e,t,n){return ol(ae(e.style.iconTextFontSize,t),e.style.iconTextLineHeight,n)}function ol(e,t,n){const s=e/Ut.baseSize*n.maxWidth,r=e*t*n.lines.length;return[s,r]}function Ph(e,t,n){var r,o;const i=(r=n[0])!=null?r:0,s=(o=n[1])!=null?o:0;return[(.5-e.anchorX)*t[0]+i,(.5-e.anchorY)*t[1]+s]}function gb(e,t,n){var a,c,l,d;const i=(a=t[0])!=null?a:.5,s=(c=t[1])!=null?c:.5,r=(l=n[0])!=null?l:0,o=(d=n[1])!=null?d:0;return[(.5-i)*e[0]+r,(.5-s)*e[1]+o]}function Lh(e,t,n,i,s){var l,d,u,f;const r=(l=n[0])!=null?l:.5,o=(d=n[1])!=null?d:.5,a=(u=s[0])!=null?u:0,c=(f=s[1])!=null?f:0;return[e[0]/2-r*t[0]-i[3]+a,e[1]/2-o*t[1]-i[0]+c]}function yo(e,t,n,i,s){const r=t[0],o=t[1],a=n[0],c=n[1];let l=0,d=0;const u=c/2+o/2,f=c/2-o/2,h=-u,g=-f,w=a/2+r/2,p=a/2-r/2,y=-w,b=-p;switch(e){case"bottomCenter":d=u+s;break;case"rightCenter":l=w+s;break;case"topCenter":d=h-s;break;case"leftCenter":l=y-s;break;case"bottomRight":l=p,d=u+s;break;case"topRight":l=p,d=h-s;break;case"bottomLeft":l=b,d=u+s;break;case"rightBottom":l=w+s,d=g;break;case"rightTop":l=w+s,d=f;break;case"topLeft":l=b,d=h-s;break;case"leftTop":l=y-s,d=f;break;case"leftBottom":l=y-s,d=g;break}return[l+i[0],d+i[1]]}var bi=(e=>(e[e.Static=0]="Static",e[e.Unique=1]="Unique",e[e.Loaded=2]="Loaded",e))(bi||{});let Dh=1e4+1;const wb={w:0,h:0,x:0,y:0,atlasIndex:0,isPacked:!1},al={};function vb(e,t,n,i,s,r){const o=mc(e,s);if(!al[o]){const a=Dh++;al[o]={type:bi.Unique,isSvg:!1,index:a,key:o,name:"",fileName:"",id:e,regionId:n,url:r,rasters:t.map((c,l)=>ve(ue({},wb),{rasterSetIndex:a,rasterIndex:l,w:c,h:c,anchorX:i[0],anchorY:i[1]}))}}return al[o]}function bb(e){const t=Dh++;return{type:bi.Loaded,isSvg:!1,index:t,key:`loaded-${t}`,name:"",fileName:"",rasters:e.map((n,i)=>ve(ue({},n),{rasterIndex:i,rasterSetIndex:t}))}}function Xs(e,t,n){let i,s=1/0;for(let r=0;r<e.length;r++){const o=e[r];if(n&&!o.isPacked)continue;const a=Math.abs(o.w-t);a<s&&(i=r,s=a)}return i}function cl(e){return!!e&&"stretchX"in e&&Array.isArray(e.stretchX)&&"stretchY"in e&&Array.isArray(e.stretchY)&&"width"in e&&typeof e.width=="number"&&"height"in e&&typeof e.height=="number"}function ll(e,t){const n=t.precomputes;return e.map((i,s)=>{const r=n[s];return r&&r.usage===st.Uniform?i:null})}var dl=(e=>(e[e.Icon=0]="Icon",e[e.First=1]="First",e[e.Second=2]="Second",e))(dl||{});const ul=new Q2,Ji=[0,0,0];let qs=[0,0,0];const sn={symbol:"point",sinks:{raster:{stride:40,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.ecefPosition=new Int16Array(t,6),e.views.cornerOffset=new Int16Array(t,12),e.views.checkPointOffset=new Int16Array(t,16),e.views.texCoords=new Uint16Array(t,20),e.views.scales=new Int16Array(t,24),e.views.localID=new Uint32Array(t,28),e.views.labelingTextureID=new Uint32Array(t,32),e.views.spritePointTextureID=new Uint32Array(t,36)},packObjectAttributes:(e,t,n,i,s,r)=>_s([e.styleId,e.layer.innerId,t,n,i,s],r),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],animDirection:e[2],atlasIndex:e[3],labelTest:e[4],floorId:e[5],tileData:e.slice(6)})},text:{stride:36,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.ecefPosition=new Int16Array(t,6),e.views.cornerOffset=new Int16Array(t,12),e.views.checkPointOffset=new Int16Array(t,16),e.views.texCoords=new Uint16Array(t,20),e.views.localID=new Uint32Array(t,24),e.views.labelingTextureID=new Uint32Array(t,28),e.views.spritePointTextureID=new Uint32Array(t,32)},packObjectAttributes:(e,t,n,i,s,r,o,a)=>_s([e.styleId,e.layer.innerId,t,n,i[0],-i[1],s,r,o],a),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],animDirection:e[2],range:e[3],offsetX:e[4],offsetY:e[5],labelIndex:e[6],fontIndex:e[7],floorId:e[8],tileData:e.slice(9)})},labelingTexture:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.cornerOffset=new Int16Array(t,8),e.views.labelingTextureID=new Uint32Array(t,12)},packObjectAttributes:(e,t=[0,0])=>_s([e.styleId,e.layer.innerId,t[0],-t[1],e.floorId],[]),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],offsetX:e[2],offsetY:e[3],floorId:e[4],tileData:e.slice(5)})}},processElement(e,t,n,i,s,r,o){const{layer:a,label:c}=n;if(a.type!=="point")return;const l=Vt(r.styleZoom,r.styleState,!0,c.tileData),d=r.styleState._activeFloorIds.length>0,u=Zs(c)&&!d?"":c.floorId,f=Oh(l,e,s,c),h=e.icons[lt(a.style.iconImage,l)],g=cl(h),w=xh(f,s,a,l,g,c.iconTextMetrics),p=it(a.style.iconTextOffset),y=it(a.style.iconTextPadding);let b,v=[0,0];if(f)if(c.iconTextMetrics){const S=it(a.style.iconTextAnchor);b=rl(a,l,c.iconTextMetrics),v=Lh(w,b,S,y,p)}else{const S=it(a.style.iconOffset);v=Ph(f,w,S)}Pt(Ji,n.anchorWorld,o);const{globeInterStartZoom:T}=_n;if(!(!(r.globeMode&&r.zoom<T)&&!cc(Ji)))switch(qs=tt.fromGeo(n.anchorGeo),n.type){case Ye.Icon:if(!f||g&&!c.iconTextMetrics)return;const S=g?h.stretchX:void 0,L=g?h.stretchY:void 0;if(fl(t,c,u,Ji,qs,i,f,w[0]*s,w[1]*s,v[0]*s,v[1]*s,s,S==null?void 0:S.map(([O,B])=>[O*s,B*s]),L==null?void 0:L.map(([O,B])=>[O*s,B*s])),!b)return;const x=it(a.style.iconTextAnchor);Ib(e,t,c,u,Ji,qs,r,i,gb(b,x,p),a,s);return;case Ye.PoiText:Mb(e,t,n,u,Ji,qs,w,r,i,v,a,s);return;case Ye.PoiText2:Tb(e,t,n,u,Ji,qs,w,r,i,v,a,s);return}},getLabelingInfo(e,t,n,i,s,r){const{layer:o}=e;if(o.type!=="point")return;e.labelingElements.length=0;const a=Vt(i.styleZoom,i.styleState,!0,e.tileData),c=Oh(a,n,r,e),l=n.icons[lt(o.style.iconImage,a)],d=cl(l),u=xh(c,r,o,a,d,e.iconTextMetrics);let f,h=[0,0];if(c&&(!d||e.iconTextMetrics)){if(e.iconTextMetrics){const y=it(o.style.iconTextAnchor),b=it(o.style.iconTextOffset),v=it(o.style.iconTextPadding);f=rl(o,a,e.iconTextMetrics),h=Lh(u,f,y,v,b)}else{const y=it(o.style.iconOffset);h=Ph(c,u,y)}const p=new po(e,Ye.Icon,t,i.buildingHeight,s,n,i.globeMode,i.styleState._floorHeight);p.boxes.push([-u[0]/2+h[0],-u[1]/2+h[1],u[0]/2+h[0],u[1]/2+h[1]]),e.labelingElements.push(p)}const g=lt(o.style.textFont,a);e.label.length>0&&g.length&&(Ab(e,t,n,u,i,s,h,o),e.label2&&Eb(e,t,n,u,i,s,h,o))}};function Ib(e,t,n,i,s,r,o,a,c,l,d){var w;const{iconTextMetrics:u}=n;if(!u||!l.style.iconTextFont)return;const f=Vt(o.styleZoom,o.styleState,!1,n.tileData),h=lt(l.style.iconTextFont,f),g=(w=e.fontNameToIndex[h])!=null?w:e.fontNameToIndex[Li];go(t,n,i,0,u,s,r,a,c,l,g,d)}function Mb(e,t,n,i,s,r,o,a,c,l,d,u){var E;const{label:f}=n,{textMetrics:h}=f,g=Vt(a.styleZoom,a.styleState,!1,f.tileData),w=lt(d.style.textFont,g);if(!w.length)return;const p=mo(d,g,h),y=(E=e.fontNameToIndex[w])!=null?E:e.fontNameToIndex[Li],b=n.parent?Zr(d.style.textPlacement,g):"centerCenter",v=ae(d.style.textOffset,g),T=yo(b,o,p,l,v);go(t,f,i,1,f.textMetrics,s,r,c,T,d,y,u)}function Tb(e,t,n,i,s,r,o,a,c,l,d,u){var L,x;const{label:f}=n,{textMetrics:h,textMetrics2:g}=f;if(!g||!d.style.textFont2)return;const w=Vt(a.styleZoom,a.styleState,!1,f.tileData),p=lt(d.style.textFont2,w);if(!p.length)return;const y=mo(d,w,h),b=_h(d,w,g),v=ae(d.style.textOffset,w),T=ae((L=d.style.textOffset2)!=null?L:0,w,0),E=(x=e.fontNameToIndex[p])!=null?x:e.fontNameToIndex[Li],S=yo(Zr(d.style.textPlacement,w),o,[b[0],y[1]],l,v);S[1]+=(y[1]+b[1])/2+T,go(t,f,i,2,g,s,r,c,S,d,E,u)}function go(e,t,n,i,s,r,o,a,c,l,d,u){if(i===1&&t.labelingElements.length===1){const h=e.getBucket("point","labelingTexture",sn.sinks.labelingTexture.packObjectAttributes(t),sn.sinks.labelingTexture.binder);t.checkPointOffset=_b(h,r,s,l,u,t.labelingTextureIndex)}const f={};for(const h of t.ranges)f[h]=e.getBucket("point","text",sn.sinks.text.packObjectAttributes(t,a,h,c,i,d,n,ll(t.tileData,l)),sn.sinks.text.binder);xb(f,t,r,o,s,l,i,t.checkPointOffset)}function Sb(e,t,n,i,s,r,o,a){return fl(e,t,n,i,s,r,o,o.w,o.h,o.w*(.5-o.anchorX),o.h*(.5-o.anchorY),a,void 0,void 0)}function fl(e,t,n,i,s,r,o,a,c,l,d,u,f,h){if(a<=0||c<=0)return;const g=t.layer;if(g.type!=="point")return;q2(ul,cn,o,a,c,l,d,f,h),e.atlasPacker.addRastersToLoad(t.styleId,o);const w=e.getBucket("point","labelingTexture",sn.sinks.labelingTexture.packObjectAttributes(t),sn.sinks.labelingTexture.binder);t.checkPointOffset=K2(i[0],i[1],i[2],ul,w,u,t.labelingTextureIndex);const p=e.getBucket("point","raster",sn.sinks.raster.packObjectAttributes(t,r,o.atlasIndex,f!==void 0||h!==void 0,n,ll(t.tileData,g)),sn.sinks.raster.binder);J2(i[0],i[1],i[2],s,ul,p,-1/0,1/0,t.identifyIndex,t.labelingTextureIndex,t.spritePointTextureIndex,t.checkPointOffset)}function Ab(e,t,n,i,s,r,o,a){const{textMetrics:c}=e;if(!c)return;const l=Vt(s.styleZoom,s.styleState,!1,e.tileData),d=ae(a.style.textOffset,l),u=mo(a,l,c),f=new po(e,Ye.PoiText,t,s.buildingHeight,r,n,s.globeMode,s.styleState._floorHeight);e.labelingElements.length>0&&(f.parent=e.labelingElements[0]);const h=f.parent?Zr(a.style.textPlacement,l):"centerCenter",g=yo(h,i,u,o,d);f.boxes.push([g[0]-u[0]/2,g[1]-u[1]/2,g[0]+u[0]/2,g[1]+u[1]/2]),e.labelingElements.push(f)}function Eb(e,t,n,i,s,r,o,a){var y;const{textMetrics:c,textMetrics2:l}=e;if(!l)return;const d=Vt(s.styleZoom,s.styleState,!1,e.tileData),u=mo(a,d,c),f=_h(a,d,l),h=ae(a.style.textOffset,d),g=ae((y=a.style.textOffset2)!=null?y:0,d,0),w=new po(e,Ye.PoiText2,t,s.buildingHeight,r,n,s.globeMode,s.styleState._floorHeight);e.labelingElements.length>1?(w.parent=e.labelingElements[0],w.firstLabel=e.labelingElements[1]):e.labelingElements.length>0&&(w.parent=e.labelingElements[0],w.firstLabel=e.labelingElements[0]);const p=yo(Zr(a.style.textPlacement,d),i,[f[0],u[1]],o,h);p[1]+=(u[1]+f[1])/2+g,w.boxes.push([p[0]-f[0]/2,p[1]-f[1]/2,p[0]+f[0]/2,p[1]+f[1]/2]),e.labelingElements.push(w)}function Oh(e,t,n,i){const{rasterSets:s}=t,{layer:r}=i;if(r.type!=="point")return;let o;const a=Zs(i);if(a||i.pointType===ft.Landmark)o=s.byKey[mc(i.id,a?"commercial":"landmark")];else{const c=lt(r.style.iconImage,e);if(c.length){const l=it(r.style.iconAnchor);o=s.byKey[Vi(c,l[0],l[1])]}}if(o){const c=ae(r.style.iconWidth,e),l=Xs(o.rasters,c*n,!0);if(l!==void 0)return o.rasters[l]}}const wo=[0,0];function xb(e,t,n,i,s,r,o,a){let{textLineHeight:d,textLetterSpacing:u}=r.style;o===dl.Icon&&(d=r.style.iconTextLineHeight,u=r.style.iconTextLetterSpacing);const{identifyPoiLabelIndex:f,labelingTextureIndex:h,spritePointTextureIndex:g}=t,{lines:w,maxWidth:p}=s,y=d*Ut.baseSize;let b=Fh(1,y,w.length);for(let v=0;v<w.length;v++){const T=w[v].width;let E=0;E=-T/2,wo[0]=E,wo[1]=b;const S=w[v].glyphs;for(let L=0;L<S.length;L++){const x=S[L];x.bitmap!==void 0&&Db(e[x.range],n,i,wo,x,f,h,g,a),wo[0]+=x.advance+Ut.baseSize*u}b-=y}}const rn=[0,0];function _b(e,t,n,i,s,r){const{lines:o,maxWidth:a}=n;if(!o.length)return rn[0]=0,rn[1]=0,rn;const{textLineHeight:c}=i.style,l=c*Ut.baseSize,d=-a/2,u=Fh(1,l,o.length),f=a/2,h=u-(o.length-1)*l;rn[0]=s*(d+f)/2,rn[1]=s*(u+h)/2;const g=s*wa/2,w=rn[0]-g,p=rn[0]+g,y=rn[1]+g,b=rn[1]-g,v=e.elements.offset;return To(e.indices,v,1,0,3,2,3,0),bo(e,t,w,y,r),bo(e,t,p,y,r),bo(e,t,w,b,r),bo(e,t,p,b,r),rn}function Pb(e,t,n,i,s,r,o){const a=n[1]+i.top,c=n[0]+i.left,l=a-i.height,d=c+i.width,u=Math.sin(s),f=Math.cos(s),h=c*f-a*u,g=c*u+a*f,w=d*f-a*u,p=d*u+a*f,y=c*f-l*u,b=c*u+l*f,v=d*f-l*u,T=d*u+l*f,E=e.elements.offset;Io(e,t,h,g,i.texLeft,i.texTop,r,o),Io(e,t,w,p,i.texRight,i.texTop,r,o),Io(e,t,y,b,i.texLeft,i.texBottom,r,o),Io(e,t,v,T,i.texRight,i.texBottom,r,o),To(e.indices,E,1,0,3,2,3,0)}function Lb(e,t,n){const i=e.elements.offset,s=$e(Math.cos(n)),r=$e(Math.sin(n));Mo(e,t,s,r,-1,-1),Mo(e,t,s,r,1,-1),Mo(e,t,s,r,1,1),Mo(e,t,s,r,-1,1),To(e.indices,i,0,1,2,2,3,0)}function Fh(e,t,n){let i;switch(e){case 0:i=t/2+t*(n-1);break;case 2:i=-t/2;break;default:i=n&1?t*(n>>1):t/2+t*(n-1>>1)}return i}function Db(e,t,n,i,s,r,o,a,c){const l=i[1]+s.top,d=i[0]+s.left,u=l-s.height,f=d+s.width,[h,g]=c,w=e.elements.offset;vo(e,t,n,d,l,s.texLeft,s.texTop,h,g,r,o,a),vo(e,t,n,f,l,s.texRight,s.texTop,h,g,r,o,a),vo(e,t,n,d,u,s.texLeft,s.texBottom,h,g,r,o,a),vo(e,t,n,f,u,s.texRight,s.texBottom,h,g,r,o,a),To(e.indices,w,1,0,3,2,3,0)}function vo(e,t,n,i,s,r,o,a,c,l,d,u){const f=e.elements,h=f.stride*f.offset>>1,g=h>>1;e.views.flatPosition[h]=z+t[0],e.views.flatPosition[h+1]=z+t[1],e.views.flatPosition[h+2]=nt(t[2]),e.views.ecefPosition[h]=n[0]*ot,e.views.ecefPosition[h+1]=n[1]*ot,e.views.ecefPosition[h+2]=n[2]*ot,e.views.cornerOffset[h]=i,e.views.cornerOffset[h+1]=s,e.views.checkPointOffset[h]=a,e.views.checkPointOffset[h+1]=c,e.views.texCoords[h]=r,e.views.texCoords[h+1]=o,e.views.localID[g]=l,e.views.labelingTextureID[g]=d,e.views.spritePointTextureID[g]=u,f.offset++}function bo(e,t,n,i,s){const r=e.elements,o=r.stride*r.offset>>1;e.views.position[o]=z+t[0],e.views.position[o+1]=z+t[1],e.views.position[o+2]=nt(t[2]),e.views.cornerOffset[o]=n,e.views.cornerOffset[o+1]=i,e.views.labelingTextureID[o>>1]=s,r.offset++}function Io(e,t,n,i,s,r,o,a){const c=e.elements;let l=c.stride*c.offset>>1;e.views.position[l]=z+t[0],e.views.position[l+1]=z+t[1],e.views.position[l+2]=nt(t[2]),e.views.texCoords[l]=s,e.views.texCoords[l+1]=r,l=l>>1,e.views.cornerOffset[l]=n,e.views.cornerOffset[l+1]=i,e.views.styleZoomLimits[l]=o,e.views.styleZoomLimits[l+1]=a,c.offset++}function Mo(e,t,n,i,s,r){const o=e.elements.stride*e.elements.offset,a=o/e.views.position.BYTES_PER_ELEMENT,c=o/e.views.direction.BYTES_PER_ELEMENT;e.views.position[a]=z+t[0],e.views.position[a+1]=z+t[1],e.views.direction[c]=n,e.views.direction[c+1]=i,e.views.widenDirection[c]=s,e.views.widenDirection[c+1]=r,e.elements.offset++}function To(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}const hl=[0,0,0],Js=[0,0],So={symbol:"labelLine",sinks:{raster:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texCoords=new Uint16Array(t,8),e.views.cornerOffset=new Float32Array(t,12),e.views.styleZoomLimits=new Float32Array(t,20)},packObjectAttributes:(e,t,n,i,s,r)=>_s([e.styleId,e.layer.innerId,t,n,i,s],r),unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],animDirection:e[2],range:e[3],fontIndex:e[4],tiers:e[5],tileData:e.slice(6)}}}},processElement(e,t,n,i,s,r,o){var x;const{label:a,anchorPosition:c,anchorSegmentIndex:l,halfLabelWidth:d,layer:u}=n;if(u.type!=="labelLine")return;const{axis:f}=a,{center:h,styleZoom:g}=r,w=Vt(g,r.styleState,!1,a.tileData),p=lt(u.style.textFont,w),y=(x=e.fontNameToIndex[p])!=null?x:e.fontNameToIndex[Li],b={},v=$(u.ignoreTier,w)?null:a.tiers;for(const O of a.ranges)b[O]=t.getBucket("labelLine","raster",So.sinks.raster.packObjectAttributes(a,i,O,y,v!=null?v:null,ll(a.tileData,u)),So.sinks.raster.binder);const T=a.textMetrics.lines[0],E=ae(u.style.textFontSize,w)/Ut.baseSize,S=T.glyphs,L=Ob(f,c,d,r.rotation);Js[0]=-T.width/2,Js[1]=0;for(let O=0;O<S.length;O++){const B=S[O],U=(Js[0]+B.left+B.width/2)*E*(L?-1:1),j=gr(U)||1;let M=-1/0,I=1/0;for(let X=l;X>=1&&X<f.vertexCount&&!(I<n.overflowStyleZoom);X+=j,I=M){const A=j===1?X:X-1;M=xu(bu(U,f.lengths[A]-c),h);const P=f.interpolate(c,X);Pt(hl,P,o),cc(hl)&&B.bitmap!==void 0&&Pb(b[B.range],hl,Js,B,P[3]+(L?Math.PI:0),Math.max(M,n.overflowStyleZoom),I)}Js[0]+=B.advance+Ut.baseSize*u.style.textLetterSpacing}},getLabelingInfo(){}};function Ob(e,t,n,i){const s=e.interpolate(t-n,e.getSegmentIndex(t-n)),r=e.interpolate(t+n,e.getSegmentIndex(t+n)),o=Math.atan2(r[1]-s[1],r[0]-s[0])-i;return Math.cos(o)<0}const pl=[0,0,0],Ao={symbol:"oneWayLine",sinks:{raster:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.direction=new Int8Array(t,8),e.views.widenDirection=new Int8Array(t,10)},packObjectAttributes:(e,t,n)=>_s([e.styleId,e.layer.innerId,t,n],e.tileData),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],animDirection:e[2],tiers:e[3],tileData:e.slice(4)})}},processElement(e,t,n,i,s,r,o){var d;const{label:a,anchorWorld:c}=n;if(Pt(pl,c,o),!cc(pl))return;const l=t.getBucket("oneWayLine","raster",Ao.sinks.raster.packObjectAttributes(a,i,(d=a.tiers)!=null?d:null),Ao.sinks.raster.binder);Lb(l,pl,c[3])},getLabelingInfo(){}},Ii={symbol:"heatmap",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Float32Array(t)},packObjectAttributes:(e,t,n,i)=>[e,t.innerId,n,i],unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],textureIndex:e[2],rampTextureIndex:e[3],tileData:e.slice(4)})},framebuffer:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.weight=new Float32Array(t,4),e.views.widen=new Int8Array(t,8)},packObjectAttributes:(e,t)=>[e,t],unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tileData:e.slice(2)})}},generate(e,t,n,i,s){const r=i.x,o=i.y,a=Number($(n.style.weight,s));if(Number.isNaN(a)){console.error("Can't resolve style.weight to number");return}const c=e.getBucket(n.type,"framebuffer",Ii.sinks.framebuffer.packObjectAttributes(t,n.innerId),Ii.sinks.framebuffer.binder);for(let l=0;l<r.length;l++)Cb(c,0,1,2,2,1,3),xo(c,r[l],o[l],-1,-1,a),xo(c,r[l],o[l],1,-1,a),xo(c,r[l],o[l],-1,1,a),xo(c,r[l],o[l],1,1,a)},generateTexture(e,t,n,i,s){const r=[-1,1,1,-1],o=[-1,-1,1,1],a=e.getBucket(n.type,"fill",Ii.sinks.fill.packObjectAttributes(t,n,i,s),Ii.sinks.fill.binder);let c=a.elements.offset;Fb(a.indices,c,0,1,2,0,2,3),Eo(a,c++,r[0],o[0]),Eo(a,c++,r[1],o[1]),Eo(a,c++,r[2],o[2]),Eo(a,c++,r[3],o[3]),a.elements.offset=c}};function Eo(e,t,n,i){const s=t*2;e.views.position[s]=n,e.views.position[s+1]=i}function Fb(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function xo(e,t,n,i,s,r){const o=e.elements.offset*e.elements.stride,a=o>>1,c=a>>1;e.views.position[a]=z+t,e.views.position[a+1]=z+n,e.views.weight[c]=r,e.views.widen[o]=i,e.views.widen[o+1]=s,e.elements.offset++}function Cb(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:d}=c,u=a.offset;l[d]=u+t,l[d+1]=u+n,l[d+2]=u+i,l[d+3]=u+s,l[d+4]=u+r,l[d+5]=u+o,c.offset=d+6}const Rb=new Set(Qd),Nb=new Set(Ea),kb=new Set(xa),Bb=new Set(tu),Ub=new Set(nu),zb=new Set(eu);function _o(e){return Rb.has(e)}function Ch(e){return Nb.has(e)}function Rh(e){return kb.has(e)}function Gb(e){return Bb.has(e)}function Nh(e){return Ub.has(e)}function jb(e){return zb.has(e)}const kh=(e,t,n,i,s,r,o,a,c,l,d)=>{var U,j,M,I;const{tileProps:u,tileAttrs:f}=i;if(Vb(e,t,n,i,l,d),d)return;let h=ft.Common;const g=f[u.db_sublayer];Ch(g)?h=ft.CommercialCity:Rh(g)?h=ft.CommercialPremium:_o(g)?h=ft.Commercial:Nh(g)&&(h=ft.Landmark);const w=c.x.length===1?wi.Point:wi.Line;let p=[],y;if(w===wi.Point){if(i&&n.style.allowElevation){const X=ae(n.style.elevation,i);if(Number.isNaN(X))typeof c.z!="undefined"&&(c.z=[r<4?tf(c.z[0]):c.z[0]]);else{const A=X*Ie*Dt(ct(o),[c.x[0],c.y[0]]);c.z=[A]}}p=[[c.x[0]],[c.y[0]],typeof c.z!="undefined"?[c.z[0]]:[0]],y=[0,0,0],Mt(y,[p[0][0],p[1][0],p[2][0]],ct(o))}else p=[c.x,c.y];const b=(U=i.id)!=null?U:"",v=(j=f[u.db_plan_id])!=null?j:"",T=(M=f[u.db_plan_level])!=null?M:NaN;let E=pt,S=pt;Number.isNaN(b)||(E=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[u.db_object_class],instanceId:0,metatile:s,center:y,floorId:v,ignoreHover:!0}),S=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[u.db_object_class],instanceId:1,metatile:s,center:y,floorId:v,ignoreHover:!0}));const L=f[u.db_point_building_id],x=e.pointIndexer.getIndex(L),O=e.pointIndexer.getIndex(b),B={type:bn.Point,pointType:h,geometryType:w,styleId:t.id,layerId:n.innerId,sourceId:a,tileCoords:o,id:(I=i.id)!=null?I:"",floorId:v,planLevel:T,identifyIndex:E,identifyPoiLabelIndex:S,labelingTextureIndex:x,spritePointTextureIndex:O,labelPriority:ht(f[u.db_label_priority],0),label2Priority:ht(f[u.db_label2_priority],0),styleIconPriority:ae(n.style.iconPriority,i),styleTextPriority:ae(n.style.textPriority,i),iconPriority:ht(f[u.db_icon_priority],0),hovered:ht(f[u.hovered],0),componentDistanceStart:ht(f[u.componentDistanceStart],0),componentDistanceEnd:ht(f[u.componentDistanceEnd],0),objectLength:ht(f[u.objectLength],0),vertices:p,demElevation:NaN,tileData:[...i.tileData]};e.addLabel(B)};function Vb(e,t,n,i,s,r){var w;const{tileProps:o,tileAttrs:a}=i,{rasterSets:c,icons:l}=t,d=_c(s),u=pi(n.style.iconWidth),f=_o(a[o.db_sublayer]),h=Nh(a[o.db_sublayer]),g=it(n.style.iconAnchor);if(f||h){if(r)return;const p=f?ba.rasterSizes:iu,y=vb((w=i.id)!=null?w:"",p,a[o.db_region],g,f?"commercial":"landmark",o.url_src?a[o.url_src]:void 0);e.atlasPacker.addNewRasterSet(t.id,y),e.atlasPacker.pack(y,u,d)}else pi(n.style.iconImage).forEach(p=>{if(!p.length)return;const y=c.byKey[Vi(p,g[0],g[1])];if(!y){console.error(`Not found raster set with image ${p}, anchorX: ${g[0]}, anchorY: ${g[1]}`);return}if(!y.isSvg)return;const b=l[p],v=b&&cl(b)?[{w:b.width,h:b.height}]:u.map(T=>({w:T,h:T}));e.atlasPacker.packSvg(y,v,d),r&&y.rasters.forEach(T=>e.atlasPacker.addRastersToLoad(t.id,T))})}const Hb=(e,t,n,i,s,r,o)=>{var c;const a={type:bn.Line,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:(c=r.id)!=null?c:"",floorId:r.tileAttrs[r.tileProps.db_plan_id]||"",planLevel:r.tileAttrs[r.tileProps.db_plan_level]||NaN,componentDistanceStart:ht(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:ht(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:ht(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:ht(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ae(n.style.textPriority,r),styleTextPriority:ae(n.style.textPriority,r),vertices:[o.x,o.y],tileData:[...r.tileData],tiers:$(n.ignoreTier,r)?void 0:r.tileAttrs[r.tileProps.db_tiers]};e.addLabel(a)},$b=(e,t,n,i,s,r,o)=>{var u;const{tileProps:a,tileAttrs:c}=r,l=$(n.ignoreTier,r)?null:c[a.db_tiers],d={type:bn.OneWayLine,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:(u=r.id)!=null?u:"",floorId:r.tileAttrs[r.tileProps.db_plan_id]||"",planLevel:r.tileAttrs[r.tileProps.db_plan_level]||NaN,componentDistanceStart:ht(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:ht(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:ht(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:ht(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ae(n.style.priority,r),styleTextPriority:0,vertices:[o.x,o.y],tileData:[...r.tileData],tiers:l};e.addLabel(d)};function Yb(e,t,n){return Ms(n.fontUrlTemplate,{name:e,range:String(t)})}function ml(e,t,n){const i=Tn(e)?e:$n(t.iconBaseUrl,e);return Ms(i,{subdomain:n,appHost:window.location.host})}function Wb(e,t){return Tn(e)?e:$n(t.modelsBaseUrl,e)}function Zb(e,t,n){return Tn(e)||!t?e:eI(t)?bs(t,{modelSrc:e,subdomain:Yu(n)}):$n(t,e)}function Bh(e,t,n){return e.replace("image",`image_${t}x${n}`)}const Uh=/_i$/;function Xb(e){return Uh.test(e)}function qb(e){return e.replace(Uh,"")}function Jb(e,t){const n=Tn(t.fontsPath)?t.fontsPath:$n(t.rootUrl,t.fontsPath),i="{name}_{range}.pbf";e.fontUrlTemplate=$n(n,i),e.iconBaseUrl=Tn(t.iconsPath)?t.iconsPath:$n(t.rootUrl,t.iconsPath),e.modelsBaseUrl=Tn(t.modelsPath)?t.modelsPath:$n(t.rootUrl,t.modelsPath)}function Kb(e){return Tn(e.stylePath)?e.stylePath:$n(e.rootUrl,e.stylePath)}const Qb=new RegExp("^(?:(?:[a-z]+:)?(?:[a-z]+:)?//|data:)","i");function Tn(e){return Qb.test(e)}function eI(e){return/{\w+}/g.test(e)}function $n(...e){const t=e.filter(i=>i.length>0);let n=t[0];for(let i=1;i<t.length;i++){n[n.length-1]!=="/"&&(n+="/");const s=t[i];s[0]==="/"?n+=s.slice(1):n+=s}return n}function zh(e,t,n){const i=it(n.style.iconAnchor),s=Vi(e,i[0],i[1]);return t.rasterSets.byKey[s]}function tI(e,t,n,i){const s=t.icons[n.name];if(!s)return;const r=Xs(n.rasters,i*window.devicePixelRatio,!0);if(r===void 0)return;const o=ml(s.url,t,Ka(e.map.state.subdomains,n.name)),{w:a,h:c}=n.rasters[r];return{fullUrl:o,width:a,height:c}}function nI(e,t,n,i){const s=qb(i),r=zh(s,t,n);if(!r)return;const o=t.icons[r.name];if(o)return ml(o.url,t,Ka(e.map.state.subdomains,r.name))}function iI(e,t,n){const i=e.styleManager.getStyle(e.map.state.handyStyleId);if(!i)return;const s=i.layersById[t.layerId];if(!s)return;const r=Ff(e.map.state.styleZoom,e.map.state.styleState,[]);let o;const a=s.style.iconWidth,c=ae(a,r);if(n.isCommercial){o=i.rasterSets.byKey[mc(t.id,"commercial")];const f=o.url;if(!f)return;const h=Xs(o.rasters,c*window.devicePixelRatio,!0);if(h===void 0)return;const{w:g,h:w}=o.rasters[h],p=Bh(f,g,w);return{baseUrl:f,fullUrl:p,width:g,height:w}}const l=s.style.iconImage;if(!l)return;const d=lt(l,r);if(o=zh(d,i,s),!o)return;const u=tI(e,i,o,c);if(u){if(Xb(d)){const f=nI(e,i,s,d);f!==void 0&&(u.fullUrlUnhovered=f)}return u}}function sI(e){return Array.isArray(e)?e:[e]}function rI(e){return e&&e.buffer instanceof ArrayBuffer}var Mi=(e=>(e[e.None=0]="None",e[e.Zoom=1]="Zoom",e[e.Distance=2]="Distance",e))(Mi||{}),Gh=(e=>(e[e.default=0]="default",e[e.flat=1]="flat",e[e.axis=2]="axis",e[e.centroid=3]="centroid",e))(Gh||{});const Yn=[0,0,0],Ks=new Int16Array([0,0,0]),Re=new Array(16),yl=new Float32Array(9),Sn=[0,0,0],gl=[0,0,0],wl=[0,0,0],Ti=[0,0,0],Po=[0,0,0],jh=[0,0,0],oI=yt(),aI=Ar([1,1,1]),Wn={symbol:"gltfModel",sinks:{instances:{stride:64,binder:(e,t)=>{e.views.flatPosition=new Uint16Array(t),e.views.flatHeight=new Float32Array(t,4),e.views.ecefPosition=new Int16Array(t,8),e.views.matrix=new Float32Array(t,16),e.views.localID=new Uint32Array(t,52),e.views.labelingTextureID=new Uint32Array(t,56),e.views.absZ=new Float32Array(t,60)},packObjectAttributes(e,t,n,i,s,r,o,a,c,l=[],d,u,f,h,g,w,p,y){return Ce([e,t.innerId,n,l,c,r,o,i,s,d,u,f,h,g,w,p,y],t,a)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],modelIndices:e[2],lngLat:e[3],emitShowHideEvents:e[4],sourceId:e[5],sourceName:e[6],modelStepValues:e[7],modelStepSource:e[8],parentId:e[9],absZ:e[10],floorId:e[11],hiddenByFloorComplexId:e[12],subkey:e[13],extToReliefNeeded:e[14],collapseHeightNeeded:e[15],scene:e[16],tileData:e.slice(17)}}}},generateInstances(e,t,n,i,s,r,o,a,c,l,d=0){var H,Q,J;const u=Hr($(n.style.geometryModifier,i),r,s,i);if(u===null)return;const f=$(n.style.linkedIds,i),h=f===""?[]:sI(f),g=n.style.modelSrc,w=[];let p=Mi.None;const y=pi(g,i,n,!0),b=$(n.style.scene,i);if(y.length===1)w.push(0);else if(y.length>1){if(!tn(g)||g.type!=="step"||!tn(g.value)){console.error(`Only step-expression is allowed as 'modelSrc' style property. Models won't be displayed for layer ${n.id}`);return}switch(g.value.type){case"zoom":p=Mi.Zoom;break;case"distance":p=Mi.Distance;break;default:console.error(`'${g.value.type}' type in 'modelSrc' step expression is not supported. Only 'zoom' and 'distance' are supported. Models won't be displayed for layer ${n.id}`);return}g.steps.forEach(({key:N})=>{w.push(N)})}p===Mi.Distance&&y.reverse(),y.forEach((N,W)=>{N===null&&W!==0&&(y[W]=y[W-1])}),p===Mi.Distance&&y.reverse();const v=y.map(N=>N===null?"":N).map(N=>{let W=t.modelIndex[N];return W===void 0&&(N=Zb(N,a!=null?a:"",r.coords),W=e.addUsedModelByUrl(N)),e.addUsedModel(W),W}),{tileProps:T,tileAttrs:E}=i;let S=In;n.interactive?i.id&&(S=E[T.hovered]?pt:e.idIndexer.getIndex(i,t.id,n,{metatile:l,objectClass:E[T.db_object_class]})):S=n.interactiveOcclusion?In:pt;const L=(H=i.id)!=null?H:"-1",x=E[T.db_point_building_id],O=E[T.db_hidden_by_metro_building_id]||"";let B=In;i.id&&(B=e.pointIndexer.getIndex(x!=null?x:i.id));const U=c!=null&&c.has(E[T.db_sublayer])&&L!=="-1"?1:0,j=u.abs_z!==void 0&&Array.from(u.abs_z).some(N=>N)?u.abs_z:void 0,M=i.styleState.terrainEnabled===!0,I=i.tileAttrs[i.tileProps.db_extension_to_relief_surface],X=M&&!!j&&!Number.isNaN(I),A=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!j&&M,P=typeof i.sourceAttrs.sourceName=="string"?i.sourceAttrs.sourceName:"",_=e.getBucket("gltfModel","instances",Wn.sinks.instances.packObjectAttributes(t.id,n,v,w,p,o,P,i,U,U?As(u.x[0],u.y[0],r):void 0,x,!!j,E[T.db_plan_id]||"",O,Fg(r,u.x[0],u.y[0],d),X,A,b),Wn.sinks.instances.binder);let C=_.meta;if(C)C.linkedIds.push(...h);else{const N=T.db_plan_id?E[T.db_plan_id]:void 0;C=_.meta={linkedIds:h.slice(),modelsPath:a!=null?a:"",buildingId:L,planId:N}}U&&(C.sublayer=E[T.db_sublayer]),x&&(C.childrenIds||(C.childrenIds=[]),C.childrenIds.push(L));let F;const k=dI(E,i);if(k){const N=u.x[0],W=u.y[0];Mt(Po,[N,W],r),F=[Po,oe.fromGeo(k)]}const R=uI(E,i),G=fI(E,i);let Z=0;for(let N=0;N<u.x.length;N++){if(Oe(gl,0,0,0),wr($(n.style.rotation,i),gl),Oe(Sn,1,1,1),wr($(n.style.scale,i),Sn),Oe(wl,0,0,0),wr($(n.style.offset,i),wl),u.xScaleDirection&&u.yScaleDirection&&u.scaleCorrection){const W=u.x[N],q=u.y[N];Mt(Po,[W,q],r);const pe=u.xScaleDirection[N],me=u.yScaleDirection[N];Mt(jh,[pe,me],r),F=[Po,jh],Z=u.scaleCorrection[N]}Vh(u.x[N],u.y[N],(J=(Q=u.z)==null?void 0:Q[N])!=null?J:0,wl,Sn,gl,F,Z,R,G,r,n.minzoom<_n.globeMaxZoom),hI(_,Yn,Ks,yl,S,B,j==null?void 0:j[N])}},patchBuffer(e,t,n,i,s,r,o,a){const c=Wn.sinks.instances.stride*t;Vh(i[0],i[1],i[2],s,r,o,void 0,void 0,void 0,void 0,n,a);const l=Yn[0]+z,d=Yn[1]+z,u=Yn[2]/(32*Ge);e.subData(c+0,new Uint16Array([l,d])),e.subData(c+4,new Float32Array([u])),a&&e.subData(c+8,Ks),e.subData(c+16,yl)}};function cI(e,t,n,i){const s=n*te/Lt(i.coords[2]);xt(t,t,s),t[2]*=n,ti(e,e,t)}function Vh(e,t,n,i,s,r,o,a,c,l,d,u){Oe(Yn,e,t,n);const f=Dt(d,Yn)*Ie;if(Fa(Re),Mr(Re,Re,be(r[2])),yu(Re,Re,be(r[1])),Ra(Re,Re,be(r[0])),Fi(Re,Re,s),o)if(a)lI(Re,o[0],o[1]),Oe(Sn,a*Ie,a*Ie,f),Fi(Re,Re,Sn);else{ln(Ti,o[1],o[0]),c?Mr(Re,Re,c):Mr(Re,Re,Math.atan2(Ti[1],Ti[0]));const h=l!=null?l:br(Ti);Oe(Sn,h,h,h),Fi(Re,Re,Sn)}else Oe(Sn,f,f,f),Fi(Re,Re,Sn);if(Ra(Re,Re,Math.PI/2),cy(yl,Re),cI(Yn,i,f,d),u){const h=dc(d,Yn);Ks[0]=h[0]*ot,Ks[1]=h[1]*ot,Ks[2]=h[2]*ot}}function lI(e,t,n){ln(Ti,n,t),Mr(e,e,Math.atan2(Ti[1],Ti[0]))}function dI(e,t){const n=e[t.tileProps.direction];return n===void 0?null:Array.isArray(n)?n:n.type==="Point"?n.coordinates:null}function uI(e,t){return e[t.tileProps.angle]}function fI(e,t){return e[t.tileProps.scale]}function hI(e,t,n,i,s,r,o){const a=e.elements.offset*Wn.sinks.instances.stride,c=e.views,l=a/c.flatPosition.BYTES_PER_ELEMENT,d=z+t[0],u=z+t[1],f=t[2]*ef;if(c.flatPosition[l]=d,c.flatPosition[l+1]=u,c.flatHeight[a/c.flatHeight.BYTES_PER_ELEMENT]=f/Ge,c.ecefPosition[l]=n[0],c.ecefPosition[l+1]=n[1],c.ecefPosition[l+2]=n[2],e.elements.offset>e.elements.maximum-1)return;c.matrix.set(i,a/c.matrix.BYTES_PER_ELEMENT),c.localID[a/c.localID.BYTES_PER_ELEMENT]=s,c.labelingTextureID[a/c.labelingTextureID.BYTES_PER_ELEMENT]=r,c.absZ[a/c.absZ.BYTES_PER_ELEMENT]=o!=null?o:0,pI(e,d,u,f,i);const h=e.indices;h.buffer[h.offset]=e.elements.offset,h.offset++,e.elements.offset++}function pI(e,t,n,i,s){const r=e.extents;t<r[0]&&(r[0]=t),n<r[1]&&(r[1]=n),i<r[2]&&(r[2]=i),t>r[3]&&(r[3]=t),n>r[4]&&(r[4]=n),i>r[5]&&(r[5]=i);const o=oI;by(s,o);const a=Ar(o)/aI;a>e.maxDiag&&(e.maxDiag=a)}var ne=(e=>(e[e.side=0]="side",e[e.top=1]="top",e[e.bottom=2]="bottom",e))(ne||{});const Qs=[0,0,0],er=[0,0,0],tr=[0,0,0],Lo=[0,0,0],Hh=(e,t,n,i,s)=>Ce([e,t.innerId,n,i],t,s),$h=(e,t,n,i)=>Ce([e,t.innerId,n],t,i),Yh=e=>({styleId:e[0],layerId:e[1],side:e[2],absZ:e[3],tileData:e.slice(4)}),Wh=e=>({styleId:e[0],layerId:e[1],absZ:e[2],tileData:e.slice(3)}),K={symbol:"mesh",sinks:{fill:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.normal=new Int8Array(t,8),e.views.gradient=new Int8Array(t,11),e.views.localID=new Uint32Array(t,12),e.views.demPosition=new Int16Array(t,16),e.views.absZ=new Float32Array(t,16),e.views.isPivot=new Uint8Array(t,20),e.views.labelingTextureID=new Uint32Array(t,24)},packObjectAttributes:Hh,unpackObjectAttributes:Yh},inverse:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.absZ=new Float32Array(t,8),e.views.isPivot=new Uint8Array(t,12)},packObjectAttributes:$h,unpackObjectAttributes:Wh},depthClear:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.absZ=new Float32Array(t,8),e.views.isPivot=new Uint8Array(t,12)},packObjectAttributes:$h,unpackObjectAttributes:Wh},stroke:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.directionDistance=new Int8Array(t,8),e.views.demPosition=new Int16Array(t,12),e.views.absZ=new Float32Array(t,12),e.views.isPivot=new Uint8Array(t,16)},packObjectAttributes:Hh,unpackObjectAttributes:Yh}},generate(e,t,n,i,s,r,o,a,c,l,d="fill",u=!1){var O,B,U,j;const f=r.x,h=r.y,g=r.signed_z;let w=0;if(n.type==="polygon3d"||n.type==="embankment"){const M=$(n.style.elevation,s),I=s.tileInfo?Dt(s.tileInfo,[0,0]):1;w=M*Ie*I}const p=r.gradient,y=r.abs_z,b=r.is_pivot,v=f.length,T=s.tileAttrs[s.tileProps.hovered],E=(O=s.id)!=null?O:"",S=e.pointIndexer.getIndex(E);let L=In;switch(n.type){case"polygon3d":{n.interactive?(L=T?pt:e.idIndexer.getIndex(s,t,n),!T&&L===pt&&(L=In)):L=n.interactiveOcclusion?In:pt;break}case"overpass":case"tunnel":{L=e.idIndexer.getIndex(s,t,n),L===pt&&(L=In);break}case"embankment":{L=In;break}default:{const{type:M}=n}}(n.type==="embankment"||n.type==="polygon3d")&&c&&Gc(e,t,c,n.style,a);let x;if(d==="inverse")x=e.getBucket("mesh","inverse",K.sinks.inverse.packObjectAttributes(t,n,!!y,s),K.sinks.inverse.binder);else if(d==="fill")x=e.getBucket("mesh","fill",K.sinks.fill.packObjectAttributes(t,n,i,!!y,s),K.sinks.fill.binder);else if(d==="depthClear")x=e.getBucket("mesh","depthClear",K.sinks.depthClear.packObjectAttributes(t,n,!!y,s),K.sinks.depthClear.binder);else return;for(let M=0;M<v-2;M++){const I=!(M%2);mI(x);const X=u?2:1,A=u?1:2,P=I?M+X:M+A,_=I?M+A:M+X,C=te/o.size;Oe(Qs,f[M],h[M],((B=g==null?void 0:g[M])!=null?B:0)*C),Oe(er,f[P],h[P],((U=g==null?void 0:g[P])!=null?U:0)*C),Oe(tr,f[_],h[_],((j=g==null?void 0:g[_])!=null?j:0)*C),Du(Lo,Qs,er,tr),Qs[2]/=C,er[2]/=C,tr[2]/=C,Qs[2]+=w,er[2]+=w,tr[2]+=w;const F=x.elements.offset;vl(x,Qs,Lo,p==null?void 0:p[M],L,S,l,y==null?void 0:y[M],b==null?void 0:b[M]),vl(x,er,Lo,p==null?void 0:p[P],L,S,l,y==null?void 0:y[P],b==null?void 0:b[P]),vl(x,tr,Lo,p==null?void 0:p[_],L,S,l,y==null?void 0:y[_],b==null?void 0:b[_]),x.objectsData[F]={objectId:E,size:x.elements.offset-F}}}};function vl(e,t,n,i,s,r,o,a,c){var f,h;const l=e.elements.stride*e.elements.offset,d=l/e.views.position.BYTES_PER_ELEMENT;e.views.position[d]=z+t[0],e.views.position[d+1]=z+t[1],e.views.height[l/e.views.height.BYTES_PER_ELEMENT]=t[2];const u=l/e.views.demPosition.BYTES_PER_ELEMENT;if(e.views.demPosition[u]=(((f=o==null?void 0:o[0])!=null?f:t[0])+z)/8,e.views.demPosition[u+1]=(((h=o==null?void 0:o[1])!=null?h:t[1])+z)/8,a!==void 0&&(e.views.absZ[l/e.views.absZ.BYTES_PER_ELEMENT]=a),e.views.isPivot[l/e.views.isPivot.BYTES_PER_ELEMENT]=c!=null?c:0,"normal"in e.views){const g=l/e.views.normal.BYTES_PER_ELEMENT,w=l/e.views.localID.BYTES_PER_ELEMENT,p=l/e.views.gradient.BYTES_PER_ELEMENT;e.views.normal[g]=$e(n[0]),e.views.normal[g+1]=$e(n[1]),e.views.normal[g+2]=$e(n[2]),e.views.gradient[p]=$e(i!=null?i:0),e.views.localID[w]=s,e.views.labelingTextureID[w]=r}e.elements.offset++}function mI(e){const t=e.indices.buffer,n=e.indices.offset,i=e.elements.offset;t[n]=i,t[n+1]=i+1,t[n+2]=i+2,e.indices.offset+=3}const Zh=[0,0,0],Xh=[0,0,0],qh=[0,0,0],Do=[0,0,0],Ki={symbol:"mapMesh",sinks:{fill:{stride:24,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.extender=new Int16Array(t,8),e.views.normal=new Int8Array(t,12),e.views.gradient=new Int8Array(t,15),e.views.demPosition=new Int16Array(t,16),e.views.absZ=new Float32Array(t,16),e.views.isPivot=new Uint8Array(t,20)},packObjectAttributes:(e,t,n,i,s)=>Ce([e,t.innerId,n,i],t,s),unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],meshTier:e[2],absZ:e[3],tileData:e.slice(4)})}},generate(e,t,n,i,s,r,o,a){var S;const c=s.x,l=s.y,d=(S=s.signed_z)!=null?S:[],u=s.gradient,f=s.is_pivot,h=s.abs_z,g=c.length,w=a==null?void 0:a[0],p=a==null?void 0:a[1];if(g<3)return;const y=te/o.size,b=e.getBucket("mapMesh","fill",Ki.sinks.fill.packObjectAttributes(t,n,r,!!h,i),Ki.sinks.fill.binder),v=b.indices.buffer;let T=b.indices.offset;const E=b.elements.offset;for(let L=2;L<g;L++){const x=!(L%2),O=x?L-2:L-1,B=x?L-1:L-2;yI(v,T,E,(L-2)*3+2),Oe(qh,c[O],l[O],d[O]*y),Oe(Xh,c[B],l[B],d[B]*y),Oe(Zh,c[L],l[L],d[L]*y),Du(Do,qh,Xh,Zh),bl(b,c[O],l[O],d[O],u==null?void 0:u[O],f==null?void 0:f[O],h==null?void 0:h[O],Do,w,p),bl(b,c[B],l[B],d[B],u==null?void 0:u[B],f==null?void 0:f[B],h==null?void 0:h[B],Do,w,p),bl(b,c[L],l[L],d[L],u==null?void 0:u[L],f==null?void 0:f[L],h==null?void 0:h[L],Do,w,p),T+=3}b.indices.offset=T}};function yI(e,t,n,i){e[t]=n+i-2,e[t+1]=n+i-1,e[t+2]=n+i}function bl(e,t,n,i,s,r,o,a,c=t,l=n){const d=e.elements.offset*e.elements.stride,u=d/e.views.position.BYTES_PER_ELEMENT,f=d/e.views.normal.BYTES_PER_ELEMENT,h=d/e.views.demPosition.BYTES_PER_ELEMENT;e.views.position[u]=z+t,e.views.position[u+1]=z+n,e.views.height[d/e.views.height.BYTES_PER_ELEMENT]=i,e.views.normal[f]=$e(a[0]),e.views.normal[f+1]=$e(a[1]),e.views.normal[f+2]=$e(a[2]),e.views.gradient[d/e.views.gradient.BYTES_PER_ELEMENT]=s!=null?s:0,e.views.isPivot[d/e.views.isPivot.BYTES_PER_ELEMENT]=r!=null?r:0,e.views.demPosition[h]=(z+c)/8,e.views.demPosition[h+1]=(z+l)/8,o!==void 0&&(e.views.absZ[d/e.views.absZ.BYTES_PER_ELEMENT]=o),e.elements.offset++}const gI=1,Il=-1,wI=1.3,Jh=-200,Kh=-300,vI=Math.tan(be(175/2)),Nt=[0,0,0],Zn=[0,0,0],bI=[0,0,0],nr=[0,0,0],Ml=[0,0,0],Be=[0,0,0];let Oo=0,ir=0;const II=(e,t)=>e<0||t<0?Math.floor(Math.min(e,t)):Math.ceil(Math.max(e,t)),Qh={symbol:"overpass",sinks:{},generate(e,t,n,i,s,r,o,a){var _,C,F,k;let c=s.signed_z;if(!c)return;const l=s.abs_z!==void 0&&Array.from(s.abs_z).some(R=>R)?s.abs_z:void 0,d=i.styleState.terrainEnabled===!0,u=!l,f=i.tileAttrs[i.tileProps.db_road_part],h=i.tileAttrs[i.tileProps.db_geometry_type],g=(_=i.tileAttrs[i.tileProps.db_tiers])==null?void 0:_[0],w=!1;if(f==="roadbed_flat"||f==="border_tunnel_descent"&&w)return;const y=i.tileProps,b=i.tileAttrs.slice();i.id=void 0,b[y.db_tiers]=void 0;const v=t.id,T=s.x.length,E=s.x,S=s.y,L=(C=s.cut)!=null?C:[],x=new Uint8Array(T);c.forEach((R,G)=>{x[G]=R?0:1});const O=f==="roadbed_tunnel"||f==="roadbed_tunnel_descent"||f==="border_tunnel"||f==="border_tunnel_descent";let B=!1;O?B=!1:B=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!l&&d,B&&(c=new Int32Array(c.length));const U=u?wI:1;d&&O&&(c=new Int32Array(c).map(R=>R*U)),je(nr,0,0);const M=Dt(r,nr)*Ie,I=te/r.size*M,X=Math.max(ae(n.style.borderWidth,i,0),0)*I,A=Math.max(ae(n.style.thickness,i,0),0)*M,P=X>0?Math.max(-A,ae(n.style.borderHeight,i,0)*M):0;if(Math.max(ae(n.style.tunnelHeight,i,0),0)*M,h==="polygon"){if(g===void 0)return;const R=[E,S,L,c,new Int8Array(T),x];l&&R.push(l);const G=f==="roadbed_tunnel_descent",Z=f==="roadbed_tunnel"||G;Ki.generate(e,v,n,i,le(R),g,r,void 0);const H=R.map(N=>Array.from(N));for(let N=0;N<H[3].length;N++)G?H[3][N]-=A*.01:H[3][N]-=A,H[4][N]=0;K.generate(e,v,n,ne.bottom,i,le(H),r,o,a,void 0,Z?"inverse":"fill",!0);const Q=[];for(let N=0;N<g;N++)Q.push(N);const J=e.getBucket("polygon","shadow",Wt.sinks.shadow.packObjectAttributes(v,n,Q,"",i),Wt.sinks.shadow.binder);if(ph(J,R[0].length,R[0],R[1],pt),Z&&!G){const N=R.slice();N[3]=Array.from(R[3]).map(W=>W+Math.abs(W/U)-1),N.length=4,K.generate(e,v,n,ne.top,i,le(N),r,o,a,void 0,"inverse")}if(G&&d&&!w){const N=R.slice();N[3]=new Array(R[0].length).fill(Math.max(0,P)),N[5]=new Array(R[0].length).fill(1),K.generate(e,v,n,ne.top,i,le(N),r,o,a,void 0,"depthClear")}}else if(h==="polyline"){const R=K.sinks.stroke.packObjectAttributes(v,n,ne.top,!!l,i),G=K.sinks.stroke.packObjectAttributes(v,n,ne.side,!!l,i),Z=K.sinks.stroke.packObjectAttributes(v,n,ne.bottom,!!l,i),H=MI({x:E,y:S,cut:L,signed_z:c,is_pivot:x,abs_z:l});if(f==="tunnel_arch"&&!w){const Q=Math.max(P,0),J=Fo(H),N=AI(H,X),W=H.map(V=>{const ee=V.slice();return ee[2]=u?Kh:Jh,l&&(ee[5]=0),ee[4]=0,ee});ce(e,Z,W);const q=kt(N,J,X).map(V=>(V[2]=Q,V[4]=1,V)),pe=N.map(V=>{const ee=V.slice();return ee[2]=Q,ee[4]=1,ee}),me=Ee(q,pe);do K.generate(e,v,n,ne.top,i,le(me),r,o,a,void 0,Q?"fill":"inverse");while(e.isOverloaded());const ye=H.map(V=>{const ee=V.slice();return ee[2]=Q,ee[4]=1,ee});ce(e,R,ye);const se=Ee(ye,W);do K.generate(e,v,n,ne.side,i,le(se),r,o,a);while(e.isOverloaded());const Y=Ee(ye.map(V=>{const ee=V.slice();return ee[2]=u?Kh:Jh,ee[4]=0,l&&(ee[5]=0),ee}),ye.map(V=>{const ee=V.slice();return ee[2]=0,ee}));do K.generate(e,v,n,ne.side,i,le(Y),r,o,a,void 0,"inverse");while(e.isOverloaded());if(Q){const V=kt(N,J,X).map(et=>(et[2]=0,et[4]=0,et));ce(e,Z,V),ce(e,R,q);const ee=Ee(V,q);do K.generate(e,v,n,ne.side,i,le(ee),r,o,a,void 0,"fill");while(e.isOverloaded());const De=N.map(et=>{const mt=et.slice();return mt[2]=0,mt[4]=0,mt}),de=Ee([pe[0],De[0]],[q[0],V[0]]);do K.generate(e,v,n,ne.side,i,le(de),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,R,[pe[0],q[0]]),ce(e,G,[q[0],V[0]]),ce(e,Z,[V[0],De[0]]);const fe=pe.length-1,Xt=Ee([De[fe],pe[fe]],[V[fe],q[fe]]);do K.generate(e,v,n,ne.side,i,le(Xt),r,o,a,void 0,"fill");while(e.isOverloaded());if(ce(e,R,[pe[fe],q[fe]]),ce(e,G,[q[fe],V[fe]]),ce(e,Z,[V[fe],De[fe]]),d){do K.generate(e,v,n,ne.top,i,le(me),r,o,a,void 0,"depthClear");while(e.isOverloaded());do K.generate(e,v,n,ne.side,i,le(ee),r,o,a,void 0,"depthClear");while(e.isOverloaded());do K.generate(e,v,n,ne.side,i,le(de),r,o,a,void 0,"depthClear");while(e.isOverloaded());do K.generate(e,v,n,ne.side,i,le(Xt),r,o,a,void 0,"depthClear");while(e.isOverloaded())}}}else if(f==="border_overpass"||f==="border_flat"){const Q=[b[y.previousPointX],b[y.previousPointY],(F=c[0])!=null?F:0,0],J=!!b[y.beginningIsCut]&&e0(H[1],H[0],Q);J&&H.splice(0,0,Q);const N=H.length-1,W=[b[y.nextPointX],b[y.nextPointY],(k=c[c.length-1])!=null?k:0,0],q=!!b[y.endingIsCut]&&e0(H[N-1],H[N],W);q&&H.push(W);const pe=Fo(H);J&&(pe.shift(),H.shift()),q&&(pe.pop(),H.pop());const me=H.map(de=>{const fe=de.slice();return fe[2]=Math.max(fe[2]-A,0),fe[4]=0,fe});ce(e,G,H);const ye=kt(H,pe,X).map(de=>{const fe=de.slice();return fe[2]=Math.max(de[2]-A,0),fe[4]=0,fe}),se=kt(H,pe,X).map(de=>{const fe=de.slice();return fe[2]=Math.max(de[2]+P,0),fe[4]=1,fe}),Y=H.map(de=>{const fe=de.slice();return P>0&&(fe[2]=Math.max(fe[2]+P,0)),fe[4]=1,fe});if(P>0){ce(e,R,Y);const de=Ee(Y,H.map(fe=>{const Xt=fe.slice();return Xt[4]=0,Xt}));do K.generate(e,v,n,ne.side,i,le(de),r,o,a);while(e.isOverloaded())}ce(e,Z,ye),ce(e,R,se);const V=Ee(se,Y);do K.generate(e,v,n,ne.top,i,le(V),r,o,a);while(e.isOverloaded());const ee=Ee(me,ye);do K.generate(e,v,n,ne.bottom,i,le(ee),r,o,a,void 0,"fill");while(e.isOverloaded());const De=Ee(ye,se);do K.generate(e,v,n,ne.side,i,le(De),r,o,a,void 0,"fill");while(e.isOverloaded());if(c[0]===0){const de=Ee([Y[0],me[0]],[se[0],ye[0]]);do K.generate(e,v,n,ne.side,i,le(de),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,R,[se[0],Y[0]]),ce(e,G,[Y[0],me[0]]),ce(e,G,[ye[0],se[0]]),ce(e,Z,[me[0],ye[0]])}if(c[c.length-1]===0){const de=me.length-1,fe=Ee([me[de],Y[de]],[ye[de],se[de]]);do K.generate(e,v,n,ne.side,i,le(fe),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,R,[Y[de],se[de]]),ce(e,G,[me[de],Y[de]]),ce(e,G,[se[de],ye[de]]),ce(e,Z,[ye[de],me[de]])}}else{const Q=Fo(H),J=f==="border_tunnel_descent",N=f==="border_tunnel"||J,W=N?Math.max(P,0):P,q=H.map(se=>{const Y=se.slice();return Y[2]-=A,J?(Y[2]=0,Y[5]=1):N&&(Y[2]=Math.max(Y[2],Il)),Y[4]=0,Y}),pe=kt(H,Q,X).map(se=>(se[2]-=A,J&&(se[2]=0,se[5]=1),se[4]=0,se)),me=kt(H,Q,X).map(se=>(se[2]+=W,J?(se[2]=W,se[5]=1):N&&(se[2]=Math.max(se[2],Il)),se[4]=1,se)),ye=H.map(se=>{const Y=se.slice();if(Y[4]=1,J)Y[2]=W,Y[5]=1;else if(N){const V=Math.abs(Y[2]/U),ee=W-Y[2],De=Y[2]+V-1;Y[4]=(De+Math.abs(Y[2]))/ee,Y[2]=De}else Y[2]+=W;return Y});if(N){J&&ce(e,R,ye);const se=Ee(ye,H.map(ee=>{const De=ee.slice();return De[4]=0,De}));do K.generate(e,v,n,ne.side,i,le(se),r,o,a);while(e.isOverloaded());const Y=ye.map(ee=>{const De=ee.slice();return De[2]=Math.min(ee[2],Il),De}),V=Ee(Y,H);do K.generate(e,v,n,ne.side,i,le(V),r,o,a,void 0,"inverse",!0);while(e.isOverloaded())}if(P>0&&(!N||J)){ce(e,Z,pe),ce(e,R,me);const se=Ee(me,ye);do K.generate(e,v,n,ne.top,i,le(se),r,o,a);while(e.isOverloaded());if(J&&d)do K.generate(e,v,n,ne.top,i,le(se),r,o,a,void 0,"depthClear");while(e.isOverloaded())}if(!N||J){const se=Ee(q,pe);do K.generate(e,v,n,ne.bottom,i,le(se),r,o,a,void 0,"fill");while(e.isOverloaded());const Y=Ee(pe,me);do K.generate(e,v,n,ne.side,i,le(Y),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&d)do K.generate(e,v,n,ne.side,i,le(Y),r,o,a,void 0,"depthClear");while(e.isOverloaded());if(c[0]===0){const V=Ee([ye[0],q[0]],[me[0],pe[0]]);do K.generate(e,v,n,ne.side,i,le(V),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&d)do K.generate(e,v,n,ne.side,i,le(V),r,o,a,void 0,"depthClear");while(e.isOverloaded());ce(e,R,[me[0],ye[0]]),ce(e,G,[ye[0],q[0]]),ce(e,G,[pe[0],me[0]]),ce(e,Z,[q[0],pe[0]])}if(c[c.length-1]===0){const V=q.length-1,ee=Ee([q[V],ye[V]],[pe[V],me[V]]);do K.generate(e,v,n,ne.side,i,le(ee),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&d)do K.generate(e,v,n,ne.side,i,le(ee),r,o,a,void 0,"depthClear");while(e.isOverloaded());ce(e,R,[ye[V],me[V]]),ce(e,G,[q[V],ye[V]]),ce(e,G,[me[V],pe[V]]),ce(e,Z,[pe[V],q[V]])}}}}}};function MI(e){var i,s,r,o,a,c;const t=[],n=e.x.length;for(let l=0;l<n;l++){const d=[e.x[l],e.y[l],(s=(i=e.signed_z)==null?void 0:i[l])!=null?s:0,(o=(r=e.cut)==null?void 0:r[l])!=null?o:0,0,(c=(a=e.is_pivot)==null?void 0:a[l])!=null?c:0];e.abs_z&&d.push(e.abs_z[l]),t.push(d)}return t}function Fo(e){const t=[];en(Nt,e[0][0],e[0][1],e[1][0],e[1][1]),Oo=0;for(let n=1;n<e.length;n++)TI(t,e,n);return t}function TI(e,t,n){const i=n===t.length-1;if(je(bI,t[n-1][0],t[n-1][1]),je(nr,t[n][0],t[n][1]),qa(Be,Nt),i)ir=0;else{je(Ml,t[n+1][0],t[n+1][1]),en(Zn,nr[0],nr[1],Ml[0],Ml[1]);const o=Te(Dn(Nt,Zn),-1,1),a=Math.min(Math.sqrt((1-o)/(1+o)),vI),c=gr(Dn(Be,Zn));ir=a*c}let s=Be[0]+Nt[0]*Oo,r=Be[1]+Nt[1]*Oo;e.push([s,r]),i&&(s=Be[0]+Nt[0]*ir,r=Be[1]+Nt[1]*ir,e.push([s,r])),i||(vr(Nt,Zn),Oo=ir)}function kt(e,t,n){const i=[];for(let s=0;s<e.length;s++){const r=e[s].slice();vr(Be,t[s]),xt(Be,Be,n),Gt(r,r,Be),i.push(r)}return i}function ce(e,t,n){do{const i=e.getBucket("mesh","stroke",t,K.sinks.stroke.binder),s=n.length;for(let r=0;r<s-1;r++){const o=r+1;Gs(i,n[r][0],n[r][1],n[r][2],n[o][0],n[o][1],n[o][2],void 0,!1,!0,n[r][6],n[o][6],n[r][5],n[o][5])}}while(e.isOverloaded())}function Ee(e,t){return SI([e[0]].concat(e,t.slice().reverse()))}function SI(e){var i,s,r;const t=e.length,n=[[],[],[],[],[],[]];e[0][6]!==void 0&&n.push([]);for(let o=0;o<t;o++){const a=ut(o,t),c=e[o];n[0][a]=c[0],n[1][a]=c[1],n[2][a]=c[3],n[3][a]=c[2],n[4][a]=(i=c[4])!=null?i:0,n[5][a]=(s=c[5])!=null?s:0,n[6]&&(n[6][a]=(r=c[6])!=null?r:0)}return n}function le(e){return{x:e[0],y:e[1],cut:e[2],signed_z:e[3],gradient:e[4],is_pivot:e[5],abs_z:e[6]}}function AI(e,t){return e=e.map(n=>n.slice()),Jt(Be,e[0],e[1]),qt(Be,Be),Cn(Be,Be,t),ti(e[0],e[0],Be),Jt(Be,e[e.length-1],e[e.length-2]),qt(Be,Be),Cn(Be,Be,t),ti(e[e.length-1],e[e.length-1],Be),e}const e0=(function(){const e=Math.cos(be(gI));return(t,n,i)=>(ln(Nt,n,t),Ln(Nt,Nt),ln(Zn,n,i),Ln(Zn,Zn),Dn(Nt,Zn)<=e)})();function EI(e,t,n,i){return Ce([e,t.innerId,n],t,i)}const Co={symbol:"metricPoint",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texCoords=new Uint16Array(t,4)},packObjectAttributes:EI,unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tiers:e[2],tileData:e.slice(3)})}},generate(e,t,n,i,s,r,o){_I(e,i,s,n,r);const a=ae(s.style.width,r),c=ae(s.style.height,r),l=ae(s.style.rotation,r),[d,u]=jg([t.x,t.y],a,c,l,o),f=$(s.ignoreTier,r)?null:r.tileAttrs[r.tileProps.db_tiers],h=e.getBucket("metricPoint","fill",Co.sinks.fill.packObjectAttributes(i.id,s,f,r),Co.sinks.fill.binder);let g=h.elements.offset;xI(h.indices,g,0,1,2,0,2,3),Ro(h,g++,d[0],u[0],0,0),Ro(h,g++,d[1],u[1],1,0),Ro(h,g++,d[2],u[2],1,1),Ro(h,g++,d[3],u[3],0,1),h.elements.offset=g}};function Ro(e,t,n,i,s,r){t=t*4,e.views.position[t]=z+n,e.views.position[t+1]=z+i,e.views.texCoords[t]=At(s),e.views.texCoords[t+1]=At(r)}function xI(e,t,n,i,s,r,o,a){const c=e.buffer,l=e.offset;c[l]=t+n,c[l+1]=t+i,c[l+2]=t+s,c[l+3]=t+r,c[l+4]=t+o,c[l+5]=t+a,e.offset=l+6}function _I(e,t,n,i,s){const{rasterSets:r}=t,o=_c(i);pi(n.style.iconImage).forEach(a=>{if(!a.length)return;const c=r.byKey[$r(a)];if(!c){console.error(`Not found raster set with texture ${a}`);return}if(!c.isSvg)return;const l=ae(n.style.width,s),d=ae(n.style.height,s),u=Vr(l,d),f=l*u,h=d*u;e.atlasPacker.packSvg(c,[{w:f,h}],o),c.rasters.forEach(g=>e.atlasPacker.addRastersToLoad(t.id,g))})}const PI=64,Si=1e5,Tl=4;function LI(e){return e!==null&&typeof e=="object"&&e.type===PI}function t0(e){return i0(e.lo,e.hi)}function n0(e){return[e%Si,Math.floor(e/Si)%Si,0,0]}function DI(e){let n=0;for(let i=0;i<Tl;i++){const s=e[i]*4294967296+n;n=Math.floor(s/Si),e[i]=s%Si}}function OI(e,t){let n=0;for(let i=0;i<Tl;i++){const s=e[i]+t[i]+n;n=Math.floor(s/Si),e[i]=s%Si}}function FI(e){const t="00000";let n=!0,i=Tl,s="";for(;--i>=0;){const r=String(e[i]);n?e[i]!==0&&(s+=r,n=!1):s+=t.slice(r.length)+r}return s.length||(s="0"),s}function i0(e,t){const n=n0(e),i=n0(t);return DI(i),OI(i,n),FI(i)}const Ke=[0,0,0],No=[0,0,0],ko=new Float64Array(16),s0={symbol:"tunnel",sinks:{},generate(e,t,n,i,s,r,o,a){var H,Q,J;const{tileProps:c,tileAttrs:l}=i,d=(H=l[c.db_tiers])==null?void 0:H[0];if(t0(l[c.id])!=="70030076221371399"||!d)return;const f=t.id;je(Ke,0,0);const g=Dt(r,Ke)*Ie,w=te/r.size*g,p=1/(te/r.size),y=l[c.objectLength],b=(Q=l[c.componentDistanceStart])!=null?Q:0,v=(J=l[c.componentDistanceEnd])!=null?J:0,T=b===0?0:-5,E=175,S=243,L=v===y?0:-5;if(Number.isNaN(y)||Number.isNaN(b)||y===0)return;const x=S-E,O=E+x*b/y,B=E+x*v/y,U=3.5*w,j=5*w,M=[];let I=0;for(let N=0;N<s.x.length;N++){const W=[s.x[N],s.y[N],0];N>0&&(I+=On(W,M[N-1]),W[2]=I),M.push(W)}const X=CI(M),A=Fo(M);M.forEach(N=>{const W=N[2]/X;N[2]=(T+W*(L-T))*g,N[5]=(O+W*(B-O))*g});const P=K.sinks.stroke.packObjectAttributes(f,n,ne.side,!0,i),_=kt(M,A,U),C=kt(M,A,-U),F=Ee(_,C),k=kt(M,A,j),R=k.map(N=>{const W=N.slice();return W[2]=Math.max(0,W[2]),W});K.generate(e,f,n,ne.side,i,le(Ee(k,R)),r,o,a,void 0,"inverse");const G=kt(M,A,-j),Z=G.map(N=>{const W=N.slice();return W[2]=Math.max(0,W[2]),W});K.generate(e,f,n,ne.side,i,le(Ee(Z,G)),r,o,a,void 0,"inverse"),M[0][2]!==0&&M[M.length-1][2]!==0&&K.generate(e,f,n,ne.side,i,le(Ee(R,Z)),r,o,a,void 0,"inverse");do Ki.generate(e,f,n,i,le(F),d,r,void 0);while(e.isOverloaded());for(let N=1;N<M.length;N++){const W=[],q=[],pe=M[N-1],me=M[N],ye=A[N-1],se=A[N];for(let V=0;V<=181;V+=15){const ee=be(V),De=pe.slice();Oe(Ke,ye[0],ye[1],0),Cn(Ke,Ke,U),Rn(No,Ke),gu(ko,-ee,No),ys(Ke,Ke,ko),Ke[2]*=p,ti(De,De,Ke),W.push(De);const de=me.slice();Oe(Ke,se[0],se[1],0),Cn(Ke,Ke,U),Rn(No,Ke),gu(ko,-ee,No),ys(Ke,Ke,ko),Ke[2]*=p,ti(de,de,Ke),q.push(de)}const Y=Ee(W,q);if(K.generate(e,f,n,ne.side,i,le(Y),r,o,a,void 0,"fill"),N===1&&M[0][2]===0){ce(e,P,W);const V=M[0].slice(),ee=M[0].slice(),De=A[0].slice(),de=A[0].slice();xt(De,De,j),xt(de,de,-j),Gt(V,V,De),Gt(ee,ee,de);const fe=V.slice(),Xt=ee.slice();fe[2]+=j*p,Xt[2]+=j*p;const et=[V];for(let mt=0;mt<5;mt++)et.push(fe);for(let mt=0;mt<5;mt++)et.push(Xt);et.push(ee),ce(e,P,et),K.generate(e,f,n,ne.side,i,le(Ee(et,W)),r,o,a,void 0,"fill")}else if(N===M.length-1&&M[M.length-1][2]===0){ce(e,P,q);const V=M[M.length-1].slice(),ee=M[M.length-1].slice(),De=A[M.length-1].slice(),de=A[M.length-1].slice();xt(De,De,j),xt(de,de,-j),Gt(V,V,De),Gt(ee,ee,de);const fe=V.slice(),Xt=ee.slice();fe[2]+=j*p,Xt[2]+=j*p;const et=[V];for(let mt=0;mt<5;mt++)et.push(fe);for(let mt=0;mt<5;mt++)et.push(Xt);et.push(ee),ce(e,P,et),K.generate(e,f,n,ne.side,i,le(Ee(q,et)),r,o,a,void 0,"fill")}}if(M[0][2]===0||M[M.length-1][2]===0){const N=kt(M,A,j),W=kt(M,A,-j),q=N.map(Y=>{const V=Y.slice();return V[2]=Math.max(0,V[2]+j*p),V}),pe=W.map(Y=>{const V=Y.slice();return V[2]=Math.max(0,V[2]+j*p),V});N.forEach(Y=>{Y[2]=Math.max(0,Y[2])}),W.forEach(Y=>{Y[2]=Math.max(0,Y[2])});const me=Ee(N,q),ye=Ee(pe,W);ce(e,P,N),ce(e,P,W),ce(e,P,q),ce(e,P,pe),K.generate(e,f,n,ne.side,i,le(me),r,o,a,void 0,"fill"),K.generate(e,f,n,ne.side,i,le(ye),r,o,a,void 0,"fill");const se=Ee(q,pe);K.generate(e,f,n,ne.top,i,le(se),r,o,a,void 0,"fill")}}};function CI(e){let t=0;for(let n=0;n<e.length-1;n++)t+=fs(e[n],e[n+1]);return t}var Sl=(e=>(e[e.Chess=1]="Chess",e[e.DoubleDash=2]="DoubleDash",e[e.Stripe=3]="Stripe",e[e.Triangles=4]="Triangles",e[e.Circle=5]="Circle",e[e.Chevron=6]="Chevron",e[e.None=-1]="None",e))(Sl||{});function r0(e){switch(e){case"chess":return 1;case"doubledash":return 2;case"triangles":return 4;case"circle":return 5;case"heart":return 6;case"stripe":return 3;default:return-1}}const RI={symbol:"simpleMesh",sinks:{fill:{stride:24,binder:()=>{},packObjectAttributes(e,t,n){return Ce([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}}},NI=32,sr={symbol:"globe",sinks:{fill:{stride:16,binder:(e,t)=>{e.views.ecefPosition=new Int16Array(t),e.views.flatPosition=new Uint16Array(t,6),e.views.texture=new Uint16Array(t,12)},packObjectAttributes(e,t,n){return[e,t.innerId,n]},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}},generate(e,t,n,i){const s=i.coords.join("/"),r=e.getBucket("globe","fill",sr.sinks.fill.packObjectAttributes(t.id,n,s),sr.sinks.fill.binder);UI(r,NI,i.coords)}}}},kI=tt.fromGeo([0,90]),BI=tt.fromGeo([0,-90]);function UI(e,t,n){const i=ct(n),s=e.views.ecefPosition,r=e.indices.buffer,o=n[1]===re(2,n[2])-1,a=n[1]===0,c=e.elements.offset*sr.sinks.fill.stride/Uint16Array.BYTES_PER_ELEMENT;let l=0,d=e.indices.offset;for(let u=0;u<t;u++)for(let f=0;f<t;f++){let h;const g=[u*32768/(t-1),f*32768/(t-1)];o&&f===t-1?h=kI:a&&f===0?h=BI:h=dc(i,g),s[c+l++]=h[0]*ot,s[c+l++]=h[1]*ot,s[c+l++]=h[2]*ot,s[c+l++]=z+g[0],s[c+l++]=z+g[1],s[c+l++]=0,s[c+l++]=u/(t-1)*(re(2,16)-1),s[c+l++]=f/(t-1)*(re(2,16)-1)}for(let u=0;u<t-1;u++)for(let f=0;f<t-1;f++){const h=u*t+f,g=h+1,w=h+t,p=w+1;r[d++]=h,r[d++]=w,r[d++]=g,r[d++]=g,r[d++]=w,r[d++]=p}e.indices.offset=d,e.elements.offset=c+l/8}const Al={symbol:"polygon3d",sinks:{},generate(e,t,n,i,s,r,o,a){let c;i.tileProps.db_centroid_x!==void 0&&i.tileProps.db_centroid_y!==void 0&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_x])&&!Number.isNaN(i.tileAttrs[i.tileProps.db_centroid_y])&&(c=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]),K.generate(e,t,n,ne.top,i,s,r,o,a,c,"fill")}};var o0=(e=>(e[e.none=0]="none",e[e.fadeIn=1]="fadeIn",e[e.fadeOut=-1]="fadeOut",e))(o0||{});function a0({collector:e,generator:t,args:n}){do t(e,...n);while(e.isOverloaded())}const c0={arrow:$s,line:dt,polygon:Wt,embankment:Al,polygon3d:Al,metricPoint:Co,labelLine:So,lineExtrusion:vn,polygonExtrusion:Vn,oneWayLine:Ao,dashedLine:gn,shiftedLine:to,circle:oo,buildingModel:wn,gltfModel:Wn,point:sn,raster:co,heatmap:Ii,dem:Ct,mesh:K,mapMesh:Ki,overpass:Qh,tunnel:s0,simpleMesh:RI,globe:sr},l0={labelLine:So,oneWayLine:Ao,point:sn};function rr(e,t){const n=c0[e];return n?n.sinks[t].stride:0}function El(e,t){e.precomputes.forEach((n,i)=>{t.tileData[i]=$(n.expr,t)})}function xl(e,t,n,i,s,r,o,a,c,l,d,u,f,h){const g=i.styleState.graphicsPreset?t.graphicsPresets[i.styleState.graphicsPreset]||{}:{};n.forEach(w=>{if(If(i,[d.x[0],d.y[0]]),!(o!==void 0&&(w.maxzoom<=o||w.minzoom>=o+1&&o!==Kn.maxDetailLevel))&&!(i.tileProps.hovered&&!Number.isNaN(i.tileAttrs[i.tileProps.hovered])&&i.tileAttrs[i.tileProps.hovered]===1&&w.type!=="polygon"&&w.type!=="polygonExtrusion"&&w.type!=="point"&&w.type!=="polygon3d")){El(w,i);do switch(w.type){case"line":const p=$(w.style.pattern,i);p&&p[0]!==Sl.None?dt.generatePatterned(e,t.id,w,i,c,d):dt.generate(e,t.id,w,i,c,d);break;case"dashedLine":gn.generate(e,t.id,w,i,c,d);break;case"shiftedLine":to.generate(e,t.id,w,i,d);break;case"polygon":Wt.generate(e,t.id,w,i,d,l,t.rasterSets);break;case"polygon3d":case"embankment":Al.generate(e,t.id,w,i,d,c,l,t.rasterSets);break;case"metricPoint":{Co.generate(e,d,l,t,w,i,c);break}case"polygonExtrusion":Vn.generate(e,t.id,w,i,d,g);break;case"labelLine":Hb(e,t.id,w,c.coords,a,i,d);break;case"oneWayLine":$b(e,t.id,w,c.coords,a,i,d);break;case"point":{kh(e,t,w,i,s,r,c.coords,a,d,l,u);break}case"lineExtrusion":vn.generate(e,t.id,w,i,d,g);break;case"arrow":$s.generate(e,t.id,w,i,d);break;case"heatmap":{Ii.generate(e,t.id,w,d,i);break}case"gltfModel":{Wn.generateInstances(e,t,w,i,d,c,a,f,h,s,2);break}case"overpass":Qh.generate(e,t,w,i,d,c,l,t.rasterSets);break;case"tunnel":s0.generate(e,t,w,i,d,c,l,t.rasterSets);break}while(e.isOverloaded())}})}function zI(e,t,n,i,s,r,o,a){const c=l0[t.type];if(c)do c.processElement(e,n,i,s,r,o,a);while(n.isOverloaded())}function GI(e,t,n,i,s,r,o){const a=l0[i.type];a&&a.getLabelingInfo(e,t,n,s,r,o)}class d0{constructor(t,n={}){this._buffer=t,this.options=Object.assign({},Ze.defaultOptions,n)}get isDirty(){return this._buffer.isDirty}set isDirty(t){this._buffer.isDirty=t}bind(t,n,i,s){this._buffer.bind(t,n||this.options,i,s)}replaceData(t){this._buffer.replaceData(t)}commitData(){this._buffer.commitData()}getData(){return this._buffer.getData()}}function jI(e,t){const n=new Set;return e.forEach(i=>{t.has(i)||n.add(i)}),n}function VI(e,t){if(!e||!t)return e===t;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function HI(e,t){const n=new Set;for(const i of t)e.has(i)&&n.add(i);return n}function $I(e,t){if(!e||!t)return e===t;if(e.size!==t.size)return!1;for(const[n,i]of e)if(!t.has(n)||!VI(i,t.get(n)))return!1;return!0}const _l="default",YI="floor",WI="dynamicModel";var Qi=(e=>(e[e.PolygonExtrusion=1]="PolygonExtrusion",e[e.FloorPolygons=2]="FloorPolygons",e[e.All=3]="All",e))(Qi||{});class ZI{constructor(t){this.identifier=t,this.tileLayers=[],this.selected=[],this.hidden=new Map,this.parentChildrenMap=new Map,this.childParentMap=new Map,this.parentChildrenMapByTile=new Map,this.selectedIdsByApi=[]}registerTileLayer(t){this.tileLayers.push(t)}unregisterTileLayer(t){this.tileLayers=this.tileLayers.filter(n=>n!==t)}select(t){this.selectedIdsByApi=t.slice(),this.selected=this.getIdsToSelect(t),this.selected.sort();for(const n of this.tileLayers)n.setSelectedIds(this.selected);this.identifier.queryFillCache()}getSelected(){return this.selected}show(t){for(const n of t)this.hidden.delete(n);this.triggerIdUpdate(t)}hide(t,n=3){for(const i of t)this.hidden.set(i,n);this.triggerIdUpdate(t)}isHidden(t,n=3){var s;return((s=this.hidden.get(t))!=null?s:0)>=n}getHidden(t=3){const n=new Set;return this.hidden.forEach((i,s)=>{i>=t&&n.add(s)}),n}triggerIdUpdate(t){if(t.length!==0)for(const n of this.tileLayers)n.pushIdsToUpdate(t)}getRelatedChildrenIds(t){const n=new Set;return t.forEach(i=>{const s=this.parentChildrenMap.get(i);s!=null&&s.size&&s.forEach(n.add,n)}),Array.from(n)}removeParentChildrenData(t){let n=!1;t.forEach(i=>{const s=this.parentChildrenMapByTile.delete(i);!n&&s&&(n=!0)}),n&&this.rebuildMaps()}updateParentChildrenData(t,n){this.updateTileParentChildrenData(t,n)&&(this.addParentChildrenData(n),this.select(this.selectedIdsByApi))}addParentChildrenData(t){t&&t.size&&t.forEach((n,i)=>{const s=this.parentChildrenMap.get(i);s?n.forEach(r=>{s.add(r),this.childParentMap.set(r,i)}):(this.parentChildrenMap.set(i,new Set(n)),n.forEach(r=>{this.childParentMap.set(r,i)}))})}rebuildMaps(){this.parentChildrenMap.clear(),this.childParentMap.clear(),this.parentChildrenMapByTile.forEach(t=>this.addParentChildrenData(t))}updateTileParentChildrenData(t,n){const i=this.parentChildrenMapByTile.get(t);return $I(i,n)?!1:(i&&i.forEach((s,r)=>{const o=this.parentChildrenMap.get(r);s.forEach(a=>{o==null||o.delete(a),this.childParentMap.delete(a)})}),this.parentChildrenMapByTile.delete(t),n&&this.parentChildrenMapByTile.set(t,n),!0)}getIdsToSelect(t){const n=new Set(t);return t.forEach(i=>{if(this.parentChildrenMap.has(i)){const r=this.parentChildrenMap.get(i);r!=null&&r.size&&r.forEach(n.add,n)}}),Array.from(n)}}class Pl{constructor(t=0){this.index=t,this.keysMap={}}getIndex(){const t=this.index;return this.index+=1,t}getUniqueIndex(t){return this.keysMap[t]===void 0&&(this.keysMap[t]=this.index,this.index+=1),this.keysMap[t]}getIndexedKeys(){return this.keysMap}}function XI(e){const t=qI(e),{groups:n,table:i}=JI(t),s={};for(let o=0;o<i.length;o++){const a=i[o],c=n[o];s[c]={};for(let l=0;l<a.length;l++){const d=n[l];s[c][d]=i[o][l]}}const r=n.reduce((o,a,c)=>(o[a]=c,o),{});return{indexToGroup:n,groupToIndex:r,table:s}}function qI(e){const t=(e.groups||[]).concat(Ic.groups).reduce((i,s)=>(i.includes(s)||i.push(s),i),[]),n=(e.overlay||[]).concat(Ic.overlay).concat(t.reduce((i,s)=>(s===Gn||s===zn||s===bc||i.push([s,zn]),i),[])).reduce((i,s)=>{const r=[];for(const o of s)t.includes(o)&&r.push(o);return r.length>1&&i.push(r),s.length===1&&r.length===1&&i.push(r),i},[]);return{groups:t,overlay:n,intersect:Ic.intersect}}function JI(e){const{groups:t,overlay:n,intersect:i}=e,s=t.reduce((o,a,c)=>(o[a]=c,o),{}),r=[];for(let o=0;o<t.length;o++){const a=[];for(let c=0;c<t.length;c++)a.push(!0);r.push(a)}for(let o=0;o<n.length;o++){const a=n[o];for(let c=0;c<a.length;c++)for(let l=c+1;l<a.length;l++){const d=s[a[c]],u=s[a[l]];r[d][u]=!1,r[u][d]=!1}}for(let o=0;o<i.length;o++){const a=i[o];for(let c=0;c<a.length;c++)for(let l=c+1;l<a.length;l++){const d=s[a[c]],u=s[a[l]];r[d][u]=!0,r[u][d]=!0}}return{groups:t,table:r}}const KI={db_id:"id",tech_db_beginning_is_cut:"beginningIsCut",tech_db_ending_is_cut:"endingIsCut",tech_db_previous_point_x:"previousPointX",tech_db_previous_point_y:"previousPointY",tech_db_next_point_x:"nextPointX",tech_db_next_point_y:"nextPointY",tech_db_object_length:"objectLength",tech_db_component_distance_start:"componentDistanceStart",tech_db_component_distance_end:"componentDistanceEnd",tech_db_geometry_type:"db_geometry_type"},QI=e=>{var t;return(t=KI[e])!=null?t:e},eM={objectClass:"db_object_class",sublayer:"db_sublayer",db_id:"id"};function tM(e){var t;return(t=eM[e])!=null?t:e}const nM={Class:"db_class",DisputePosition:"db_dispute_position",ObjectClass:"db_object_class",ParkingType:"db_parking_type",Sublayer:"db_sublayer",Subsublayer:"db_subsublayer",Icon:"db_icon",GeometryType:"db_geometry_type",ModelType:"db_model_type",RoadSupportTypes:"tech_db_road_support_type",RoadMarkingColorType:"db_road_marking_color_type",PoiCategory:"L1_Poi_category",RoadPart:"db_road_part",TriangulationMethod:"db_triangulation_method",RequireAbsZFromReliefSurface:"db_require_abs_z_from_relief_surface",TouristRouteColor:"db_tourist_route_color",TouristRouteSportTrackType:"db_tourist_route_sport_track_type",TouristRouteType:"db_tourist_route_type"},iM=e=>{var t;e.enumerationValues=Object.keys((t=e.enumerationValues)!=null?t:{}).reduce((n,i)=>{const s=nM[i];return s&&(n[s]=e.enumerationValues[i]),n},{})};class sM{constructor(t,n,i){var s;this.id=t,this.modules=n,this.options=i,this.type="zenith",this.worker=new n.workers.parser.ZenithSource,this.sourceAttrs=Pn((s=i.sourceAttributes)!=null?s:{},Uu),this.objectAttributes={},this.dataFilter=i.dataFilter}fetchTiles(t,n){const{assetManager:i,map:s}=this.modules,r=t.map(a=>({coords:a,tileUrl:this.constructTileUrl(a,n)}));return this.worker.fetchTiles(r).map((a,c)=>a.catch(()=>Promise.resolve()).then(l=>{if(!l)return;const{metadata:d,err:u}=l;return d.forEach(f=>{const h=this.constructMetaTileUrl(f);i.loadMetatile(h,f.metatileHash,f.regionId),s.emit("tileload",{tileCoords:r[c].coords,regionId:f.regionId}),n.shownRegionIds.add(f.regionId)}),(u==null?void 0:u.status)===403&&s.emit("error",{type:"invalidtilekey"}),d}))}generateTile(d,u,f,h,g){return Le(this,arguments,function*(t,n,i,s,r,o={},a,c=this.id,l){const w=yield this.worker.generateTile(ve(ue({styleId:i,tileInfo:ct(n),pixelRatio:r,selectedIds:s,styleState:t.styleState,floorsEnabled:t.floorsEnabled,sourceAttrs:this.sourceAttrs,hoverId:a,sourceId:c,isDefaultSource:this.options.isDefaultSource,modelsPath:this.options.modelsPath,promoteAttributes:this.options.promoteAttributes,promoteId:this.options.promoteId,isCustomZenithSource:!this.options.isDefaultSource,dataFilter:this.dataFilter},o),{modelShowHideEventsSublayers:t.modelShowHideEventsSublayers}),l);return w.promotedAttrs&&(this.objectAttributes[xe(n)]=w.promotedAttrs),w})}getObjectAttributes(t,n){var i;return(i=this.objectAttributes[t])==null?void 0:i[n]}generateModel(t){return this.worker.generateModel(t)}abortTileFetches(t){const n=t.map(xe);this.worker.abortTileRequests(n)}deleteTiles(t){const n=t.map(xe);for(const i of n)this.objectAttributes[i]=void 0;this.worker.deleteTiles(n)}setAttributes(t){this.sourceAttrs=t}getAttributes(){return this.sourceAttrs}destroy(){this.worker.destroy(),this.sourceAttrs={},this.objectAttributes={}}setFeatureStateMap(t){this.worker.setFeatureStateMap(t)}setDataFilter(t){t?this.dataFilter=D(t,{precomputes:[]},st.Generator):this.dataFilter=void 0}constructTileUrl(t,n){return Eg(this.options.tileServer,this.options.tileSet,this.options.tileProtocol,this.options.subdomains,t,this.options.tileKey,this.options.appId,n.lang,this.options.tileTemplateUrl,this.options.defaultLang,this.options.sessionId,this.options.dt)}constructMetaTileUrl(t){const n=this.options.metatileTemplateUrl,i={host:this.options.tileServer,tileSet:this.options.tileSet,protocol:this.options.tileProtocol,subdomain:this.options.subdomains[0],hash:Ru(t.metatileHash)};return Is(n?{url:n}:"metatile",i)}}const u0=[{id:"__2gis_comm_poi",type:"point",style:{textFont:["Noto_Sans_Semibold",["step",["zoom"],"Noto_Sans",16,"Noto_Sans"]],iconImage:"peak",iconWidth:["interpolate",["linear"],["zoom"],15,22,16.8,30],textColor:"#3A3A3A",visibility:"visible",textFontSize:[["interpolate",["linear"],["zoom"],15.5,11,18,13],["interpolate",["linear"],["zoom"],15.5,10,18,12]],textHaloColor:"rgba(255,255,255,0.5)",textHaloWidth:.9,iconLabelingGroup:bc,iconLabelingMargin:{leftRight:6,topBottom:6}},filter:["all",["match",["get","db_sublayer"],["Commercial_poi_default","Commercial_poi_city","Commercial_poi_premium"],!0,!1],["any",["==",["in",["get","db_building_id"],["global","_activeFloorBuildingIds"]],!1],["in",["get","db_plan_id"],["global","_activeFloorIds"]]]]}];function rM(e){const t={};let n=0;for(const i in e)t[i]=n,n+=1;return t}let oM=Number.MIN_SAFE_INTEGER;function f0(){return oM++}const aM=f0(),cM=f0(),h0={NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519},lM={FRONT:1028,BACK:1029,FRONT_AND_BACK:1032},dM={ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776},uM={FUNC_ADD:32774,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,MIN:32775,MAX:32776},p0="__JAKARTA__DEM__LIGHTING__";class Ll extends Error{constructor(t){super(`Unknown expression type '${t[0]}' in '${JSON.stringify(t)}'`),this.name="UnknownExpressionTypeError",Object.setPrototypeOf(this,new.target.prototype)}}function D(e,t,n=st.Uniform){if(Xg(e))return gf(e)?Ds(e):e;switch(e[0]){case"coalesce":return AM(e,t,n);case"all":return SM(e,t,n);case"any":return EM(e,t,n);case"match":return fM(e,t,n);case"in":return wM(e,t,n);case"interpolate":return m0(e,t,n);case"step":return TM(e,t,n);case"featureState":case"get":case"sourceAttr":case"has":return y0(e,t,n);case"objectAttr":return{type:"objectAttr",property:e[1]};case"global":return{type:"global",property:e[1]};case"zoom":return{type:"zoom"};case"distance":return{type:"distance"};case"local-time":return{type:"local-time",offset:D(e[1]||0,t,n)};case"utc-time":return{type:"utc-time",offset:D(e[1]||0,t,n)};case"time":return xM(e,t,n);case"schedule":return _M(e,t,n);case"height":return{type:"height"};case"heatmap-density":return{type:"heatmap-density"};case"shading-intensity":return{type:"shading-intensity"};case"to-boolean":case"to-color":case"!":case"log10":case"mappoints-to-meters":case"meters-to-pixels":return hM(e,t,n);case"uint64":return D(e[1],t,n);case"==":case"!=":case"<":case"<=":case">":case">=":return pM(e,t,n);case"+":return mM(e,t,n);case"*":return yM(e,t,n);case"^":return gM(e,t,n);case"random":return PM(e,t,n);case"literal":return Array.isArray(e[1])?LM(e,t,n):typeof e[1]=="object"&&e[1]!==null?DM(e):e[1];case"isBehindObjects":return{type:"isBehindObjects"};case"geometry-modifier":const i=[];return e.slice(1).forEach(s=>{const r=OM(s);r&&i.push(r)}),{type:"geometry-modifier",modifiers:i};case"pattern":return{type:"line-pattern",patternType:r0(e[1]),parameters:e.slice(2).map(s=>D(s,t,n))};case"precompute":{if(!t)throw new Ll(e);const s=t.precomputes.length;return t.precomputes.push({expr:D(e[1],void 0,n),usage:n}),{type:"precompute",precomputeIndex:s}}case"gltf-animation":return vM(e,t,n);case"texture-animation":return bM(e,t,n);case"easing":return IM(e);case"mix":return MM(e,t,n);case"readFromTarget":return{type:"readFromTarget",name:e[1]};case"vertexAttribute":return{type:"vertexAttribute",name:e[1]};default:throw new Ll(e)}}function Xn(e,t,n=st.Uniform){return un(e)||Array.isArray(e)&&e.length===0?e:D(e,t,n)}function Ai(e,t,n){return e===void 0?e:D(e,t,n)}function fM(e,t,n){const i={type:"match",input:D(e[1],t,n),cases:[],defaultOutput:D(e[e.length-1],t,n)},s=e.slice(2,-1);for(let r=0;r<s.length;r+=2){const o=s[r].reduce((c,l)=>{typeof l=="boolean"&&c.push(Number(l));const d=D(l,t,n);return pf(d)?c.push(d):console.warn("MatchExpression supports only simple types: string, number, boolean or null",l),c},[]),a={values:new Set(o),output:D(s[r+1],t,n)};i.cases.push(a)}return i}function m0(e,t,n){const i={type:"interpolate",base:1,argument:D(e[2],t,n),steps:[]};e[1][0]==="exponential"&&e[1][1]!==void 0&&(i.base=e[1][1]);const s=e.slice(3);for(let r=0;r<s.length;r+=2){const o={key:D(s[r],t,n),value:D(s[r+1],t,n)};i.steps.push(o)}return i}function hM(e,t,n){return{type:e[0],value:D(e[1],t,n)}}function pM(e,t,n){const i=D(e[1],t,n),s=D(e[2],t,n);return{type:e[0],leftValue:i,rightValue:s}}function mM(e,t,n){return{type:"+",array:e.slice(1).map(i=>D(i,t,n))}}function yM(e,t,n){return{type:"*",array:e.slice(1).map(i=>D(i,t,n))}}function gM(e,t,n){const i=D(e[1],t,n),s=D(e[2],t,n);return{type:"^",base:i,exponent:s}}function wM(e,t,n){const i=D(e[1],t,n),s=e[2][0];if(s!=="get"&&s!=="global"&&s!=="sourceAttr"&&s!=="literal")throw new Error("InExpression supports only the get, global, source attr and literal expressions as a second argument");const r=D(e[2],t,n);return{type:"in",item:i,collection:r}}function vM(e,t,n){const i={type:"gltf-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(D(s[r],t,n));return i}function bM(e,t,n){const i={type:"texture-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(D(s[r],t,n));return i}function IM(e){const t={type:"easing",options:["linear"]},n=e.slice(1),i=n.slice(1);try{switch(n[0]){case"cubic-bezier":{if(i.length!==4||i.some(s=>typeof s!="number"))throw new Error;t.options=[n[0],...i];break}case"exponential":{if(i.length!==1||typeof i[0]!="number"||i[0]===1||i[0]<=0)throw new Error;t.options=[n[0],i[0]];break}case"ease":case"ease-in":case"ease-out":case"ease-in-out":case"linear":{t.options[0]=n[0];break}default:throw new Error}}catch(s){console.warn("Invalid texture animation easing expression:",e),console.warn('Fallback to ["easing", "linear"].')}return t}function MM(e,t,n){const i=e.slice(1),s=D(i[2],t,n);if(s.type==="interpolate"){const{argument:r}=s;return s.argument.type==="readFromTarget"?{type:"mix",value1:D(i[0],t,n),value2:D(i[1],t,n),factor:r,factorInterpolate:s}:(console.warn(`Unknown expression in mix < interpolation chain: ${JSON.stringify(r)}`),null)}else return{type:"mix",value1:D(i[0],t,n),value2:D(i[1],t,n),factor:s}}function TM(e,t,n){const i={type:"step",steps:[],value:D(e[1],t,n)},s={key:0,value:D(e[2],t,n)};i.steps.push(s);const r=e.slice(3);for(let o=0;o<r.length;o+=2){const a={key:r[o],value:D(r[o+1],t,n)};i.steps.push(a)}return i}function y0(e,t,n){var o;const i=e[0],s=tM(e[1]),r={type:i,property:s};if(n!==st.Generator&&t){const a=(o=t.precomputes.length)!=null?o:NaN;return t.precomputes.push({expr:r,usage:n}),s==="selected"&&"selectedIdx"in t&&(t.selectedIdx=a),{type:"precompute",precomputeIndex:a}}else return r}function SM(e,t,n){return{type:"all",array:e.slice(1).map(i=>D(i,t,n))}}function AM(e,t,n){return{type:"coalesce",array:e.slice(1).map(i=>{try{return D(i,t,n)}catch(s){return console.debug(`Unknown expression in coalesce: ${s}`),null}})}}function EM(e,t,n){return{type:"any",array:e.slice(1).map(i=>D(i,t,n))}}function xM(e,t,n){return{type:"time",timeSource:D(e[1],t,n),format:e[2]}}function _M(e,t,n){return{type:"schedule",time:D(e[1],t,n),steps:D(e[2],t,n),detailResult:e[3]}}function PM(e,t,n){const i=D(e[1],t,n),s=D(e[2],t,n);return{type:"random",start:i,end:s}}function LM(e,t,n){return{type:"literalArray",array:e[1].map(i=>D(i,t,n))}}function DM(e){return{type:"literalObject",object:{type:"object",value:e[1]}}}function OM(e){if(!(e===void 0||!Array.isArray(e)))switch(e[0]){case"line-to-zigzag":return{type:"zigzag-modifier",step:e[1],width:e[2],stopLines:Number(e[3])};case"to-points":return{type:"to-points-modifier",modelLength:e[1],edgeMarging:e[2]}}}function FM(e){return e?e.map(t=>{var o,a,c,l,d,u,f,h,g,w,p,y,b,v,T,E,S,L,x,O,B,U,j,M,I,X,A;const n=(o=t.wallPadding)!=null?o:0,i=(a=t.texturePadding)!=null?a:0,s=t.sliceSize,r={image:t.image,minWallHeight:(c=t.minWallHeight)!=null?c:0,wallPadding:Array.isArray(n)?n:[n,n,n,n],texturePadding:Array.isArray(i)?i:[i,i,i,i],sliceSize:s?Array.isArray(s)?s:[s,s]:Array.isArray(t.size)?t.size:[t.size,t.size],vertical:{mode:(d=(l=t.vertical)==null?void 0:l.mode)!=null?d:"stripe-top",slicesCount:(f=(u=t.vertical)==null?void 0:u.slicesCount)!=null?f:1,minSliceRepeats:(g=(h=t.vertical)==null?void 0:h.minSliceRepeats)!=null?g:1,minResizeFactor:(p=(w=t.vertical)==null?void 0:w.minResizeFactor)!=null?p:0,maxResizeFactor:(b=(y=t.vertical)==null?void 0:y.maxResizeFactor)!=null?b:9999,maxInterval:(T=(v=t.vertical)==null?void 0:v.maxInterval)!=null?T:0},horizontal:{mode:(S=(E=t.horizontal)==null?void 0:E.mode)!=null?S:"repeat-with-stretch",slicesCount:(x=(L=t.horizontal)==null?void 0:L.slicesCount)!=null?x:1,minSliceRepeats:(B=(O=t.horizontal)==null?void 0:O.minSliceRepeats)!=null?B:1,minResizeFactor:(j=(U=t.horizontal)==null?void 0:U.minResizeFactor)!=null?j:0,maxResizeFactor:(I=(M=t.horizontal)==null?void 0:M.maxResizeFactor)!=null?I:9999,maxInterval:(A=(X=t.horizontal)==null?void 0:X.maxInterval)!=null?A:0}};return r.sliceSize[0]<=0||r.sliceSize[1]<=0?null:r}).filter(t=>t!==null):[]}function CM(e,t){let n=0;function i(s,r){s.type!=="custom"&&S2(s.filter)&&(n=r)}return e.forEach((s,r)=>{s.type==="group"?s.layers.forEach(o=>i(o,r)):i(s,r)}),t.forEach(s=>{s.type==="point"&&(s.style.iconPriority=Number.MAX_SAFE_INTEGER)}),[...e.slice(0,n+1),...t,...e.slice(n+1)]}function RM(e,t,n){var d,u,f,h,g,w,p,y;const i=Ol((d=e.terrain)!=null?d:{}),s=I0((u=e.environment)!=null?u:{}),r=M0(e.light,i),o=BM(e.graphicsPresets),a={id:t,revision:0,background:{color:Ds((h=(f=e.background)==null?void 0:f.color)!=null?h:Bw)},light:r,layers:[],layersById:{[ks]:i,[Nc]:s},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",fonts:hr,fontNameToIndex:ch(hr),rasterSets:{byIndex:{},byKey:{}},icons:e.icons||{},models:Object.values((g=e.models)!=null?g:{}),modelIndex:rM(e.models||{}),labelingGroups:XI((w=e.labelingGroups)!=null?w:{}),dem:i,graphicsPresets:o,environment:s,targets:{_TMP_SHORELINE_GRADIENT:{channels:{r:!0},title:"Градиент береговой линии"}}},c=new Pl;let l=(p=e.layers)!=null?p:[];n&&(l=CM((y=e.layers)!=null?y:[],u0));for(const b of l){const v=g0(b);if(!v)continue;v.type==="group"&&(a.groupsById[v.innerId]=v,a.layerIdToInnerId[v.id]=v.innerId),(v.type==="group"?v.layers:[v]).forEach(E=>{var x;const S=(x=E.lightingMode)!=null?x:r.defaultLightMode;r.lightingModes[S]||console.warn(`Не найден режим освещения ${S} для слоя ${E.type}. Будет использован режим освещения по умолчанию.`),a.layers.push(E),a.layersById[E.innerId]=E,a.layerIdToInnerId[E.id]=E.innerId,(E.type==="point"||E.type==="polygon"||E.type==="metricPoint"||E.type==="embankment"||E.type==="polygon3d")&&w0(E,c,a.icons).forEach(B=>{a.rasterSets.byKey[B.key]||(a.rasterSets.byIndex[B.index]=B,a.rasterSets.byKey[B.key]=B)})})}return a}function g0(e){return e.type==="group"?kM(e):Bo(e)}function w0(e,t,n){const i=[];return b0(e).forEach(({image:s,imageType:r,anchor:o})=>{s&&pi(s).forEach(a=>{typeof a!="string"||!a.length||i.push(v0(a,r,t,o,n))})}),i}function v0(e,t,n,i,s){const r=t==="icon"?Vi(e,i[0],i[1]):$r(e);return{type:bi.Static,index:n.getUniqueIndex(r),key:r,isSvg:A2(s[e]),name:e,fileName:e,anchorX:i[0],anchorY:i[1],rasters:[]}}function b0(e){if(e.type==="point"){const n=it(e.style.iconAnchor);return[{image:e.style.iconImage,imageType:"icon",anchor:n}]}if(e.type==="metricPoint")return[{image:e.style.iconImage,imageType:"texture",anchor:[0,0]}];const t=[{image:e.style.textureImage,imageType:"texture",anchor:[0,0]}];return e.type==="polygon"&&t.push({image:e.style.normalMapTextureImage,imageType:"texture",anchor:[0,0]}),t}const Dl=new Pl;function NM(e,t){return e.type==="appearance"?{type:e.type,tipMovementAmplitude:D(e.tipMovementAmplitude,t)}:e.type==="repeat"?{type:e.type,tipMovementAmplitude:D(e.tipMovementAmplitude,t),iterationCount:e.iterationCount}:e}function Bo(e,t){var i,s,r,o,a,c,l,d,u,f,h,g,w,p,y,b,v,T,E,S,L,x,O,B,U,j;if(e.type==="custom")return{type:"custom",id:e.id,innerId:Ns(),renderIndex:Dl.getIndex(),filter:!1,minzoom:-1/0,maxzoom:1/0,precomputes:[],style:{}};if(!e.style||e.style.visibility==="none")return;let n;try{const M={id:e.id,innerId:Ns(),renderIndex:Dl.getIndex(),filter:D(e.filter||!1,void 0),minzoom:T0(e.minzoom,-1/0),maxzoom:T0(e.maxzoom,1/0),precomputes:t?t.precomputes.slice(0):[],gpuState:e.gpuState,lightingMode:e.lightingMode,castShadows:(i=e.castShadows)!=null?i:!0,receiveShadows:(s=e.receiveShadows)!=null?s:!0,drawToTarget:e.drawToTarget};switch(e.type){case"line":{const I=vw(e.style);n=ve(ue({},M),{type:e.type,interactive:(r=e.interactive)!=null?r:!0,ignoreTier:D((o=e.ignoreTier)!=null?o:!1,M),style:{visibility:We(I.visibility),color:D(I.color,M),width:D(I.width,M),shift:D(I.shift,M),pattern:D(I.pattern,M),startCap:D(I.startCap,M),endCap:D(I.endCap,M),geometryModifier:D(I.geometryModifier,M),mode:I.mode,lengthUnits:UM(e.style.pattern)}});break}case"lineExtrusion":{const I=Iw(e.style);n=ve(ue({},M),{type:e.type,style:{visibility:We(I.visibility),sideColor:D(I.sideColor,M),strokeWidth:D(I.strokeWidth,M),strokeColor:D(I.strokeColor,M),sideStrokeColor:D(I.sideStrokeColor,M),height:D(I.height,M),nearCameraFade:D(I.nearCameraFade,M)}});break}case"polygon":{const I=mw(e.style),X=or(I.textureSize)?A0(I.textureSize):I.textureSize,A=or(I.normalMapTextureSize)?A0(I.normalMapTextureSize):I.normalMapTextureSize;M.drawToTarget==="_TMP_SHORELINE_GRADIENT"&&(I.strokeWidth=0,I.strokeColor="#00000000",I.color=["mix","#000000","#FF0000",["vertexAttribute","denormalized_distance_to_line"]]),n=ve(ue({},M),{type:e.type,interactive:(a=e.interactive)!=null?a:!0,ignoreTier:D((c=e.ignoreTier)!=null?c:!1,M),style:{visibility:We(I.visibility),color:D(I.color,M),textureImage:D(I.textureImage,M),textureSize:Xn(X,M),textureOpacity:D(I.textureOpacity,M),strokeColor:D(I.strokeColor,M),strokeWidth:D(I.strokeWidth,M),lengthUnits:S0(I.textureSize),metallic:D(I.metallic,M),roughness:D(I.roughness,M),normalMapTextureImage:D(I.normalMapTextureImage,M),normalMapTextureSize:Xn(A,M),normalMapTextureAnimation:D(I.normalMapTextureAnimation,M),normalMapTextureLengthUnits:S0(I.normalMapTextureSize)}});break}case"polygon3d":case"embankment":{const I=yw(e.style),X=e.type==="polygon3d"?{depthFunc:h0.LEQUAL}:{};n=ve(ue({},M),{type:e.type,interactive:(l=e.interactive)!=null?l:!0,style:{visibility:We(I.visibility),color:D(I.color,M),textureImage:D(I.textureImage,M),textureSize:Xn(I.textureSize,M),textureOpacity:D(I.textureOpacity,M),strokeColor:D(I.strokeColor,M),strokeWidth:D(I.strokeWidth,M),nearCameraFade:D(I.nearCameraFade,M),elevation:D(I.elevation,M)},gpuState:ue(ue({},X),M.gpuState)}),e.type==="polygon3d"&&(n.interactiveOcclusion=(d=e.interactiveOcclusion)!=null?d:!0);break}case"metricPoint":{const I=gw(e.style);n=ve(ue({},M),{type:e.type,interactive:(u=e.interactive)!=null?u:!0,ignoreTier:D((f=e.ignoreTier)!=null?f:!1,M),style:{visibility:We(I.visibility),iconImage:D(I.iconImage,M),color:D(I.color,M),rotation:D(I.rotation,M),width:D(I.width,M),height:D(I.height,M)}});break}case"polygonExtrusion":{const I=ww(e.style);n=ve(ue({},M),{type:e.type,interactive:(h=e.interactive)!=null?h:!0,sideTextureIndices:[],style:{visibility:We(I.visibility),topColor:D(I.topColor,M),sideColor:D(I.sideColor,M),strokeColor:D(I.strokeColor,M),strokeWidth:D(I.strokeWidth,M),sideStrokeColor:D(I.sideStrokeColor,M),height:D(I.height,M,st.Generator),nearCameraFade:D(I.nearCameraFade,M),sideTextures:FM(I.sideTextures)}});break}case"dashedLine":{const I=Sw(e.style);n=ve(ue({},M),{type:e.type,interactive:(g=e.interactive)!=null?g:!0,ignoreTier:D((w=e.ignoreTier)!=null?w:!1,M),style:{visibility:We(I.visibility),color:D(I.color,M),gapColor:D(I.gapColor,M),width:D(I.width,M),shift:D(I.shift,M),gapLength:D(I.gapLength,M),dashLength:D(I.dashLength,M),gapTurnsOnly:I.gapTurnsOnly,geometryModifier:D(I.geometryModifier,M),mode:I.mode}});break}case"shiftedLine":{const I=Aw(e.style);n=ve(ue({},M),{type:e.type,interactive:(p=e.interactive)!=null?p:!0,ignoreTier:D((y=e.ignoreTier)!=null?y:!1,M),style:{visibility:We(I.visibility),color:D(I.color,M),width:D(I.width,M),shift:D(I.shift,M)}});break}case"oneWayLine":{const I=Tw(e.style);n=ve(ue({},M),{type:e.type,ignoreTier:D((b=e.ignoreTier)!=null?b:!1,M),interactive:(v=e.interactive)!=null?v:!1,style:{visibility:We(I.visibility),color:D(I.color,M),lineWidth:D(I.lineWidth,M),lineLength:D(I.lineLength,M),tipWidth:I.tipWidth,tipHeight:I.tipHeight,roundingRadius:D(I.roundingRadius,M),priority:I.priority,duplicationSpacing:D(I.duplicationSpacing,M),endingOffsets:I.endingOffsets,labelingGroup:I.labelingGroup}});break}case"buildingModel":{const I=bw(e.style);n=ve(ue({},M),{type:e.type,interactive:(T=e.interactive)!=null?T:!0,style:{visibility:We(I.visibility),color:D(I.color,M),strokeColor:D(I.strokeColor,M),strokeWidth:D(I.strokeWidth,M),nearCameraFade:D(I.nearCameraFade,M)}});break}case"labelLine":{const I=Mw(e.style);n=ve(ue({},M),{type:e.type,interactive:(E=e.interactive)!=null?E:!1,ignoreTier:D((S=e.ignoreTier)!=null?S:!1,M),style:{visibility:We(I.visibility),textField:D(I.textField,M,st.Labeling),textFont:I.textFont,textColor:D(I.textColor,M),textFontSize:D(I.textFontSize,M),textLetterSpacing:I.textLetterSpacing,textHaloColor:D(I.textHaloColor,M),textHaloWidth:I.textHaloWidth,textPriority:D(I.textPriority,M),textLabelingSideMargin:I.textLabelingSideMargin,textDuplicationSpacing:D(I.textDuplicationSpacing,M),labelingGroup:I.labelingGroup,lineEndingOffsets:I.lineEndingOffsets}});break}case"point":{const I=xw(e.style);n=ve(ue({},M),{type:e.type,interactive:(L=e.interactive)!=null?L:!0,style:{visibility:We(I.visibility),allowOverlap:I.allowOverlap,allowElevation:I.allowElevation,elevation:D(I.elevation,M),iconImage:D(I.iconImage,M),iconAnchor:Xn(I.iconAnchor,M),iconOffset:Xn(I.iconOffset,M),iconWidth:D(I.iconWidth,M),iconTextField:D(I.iconTextField,M,st.Labeling),iconTextFont:Ai(I.iconTextFont,M),iconTextAnchor:Xn(I.iconTextAnchor,M),iconTextOffset:Xn(I.iconTextOffset,M),iconTextColor:D(I.iconTextColor,M),iconTextFontSize:D(I.iconTextFontSize,M),iconTextLineHeight:I.iconTextLineHeight,iconTextLetterSpacing:I.iconTextLetterSpacing,iconTextPadding:Xn(I.iconTextPadding,M),iconTextHaloWidth:Ls(qe(I.iconTextHaloWidth)),iconTextHaloColor:D(I.iconTextHaloColor,M),iconOpacity:D(I.iconOpacity,M),iconPriority:D(I.iconPriority,M),iconLabelingMargin:I.iconLabelingMargin,iconLabelingGroup:I.iconLabelingGroup,iconRotation:D(I.iconRotation,M),textField:D(qe(I.textField),M,st.Labeling),textFont:D(qe(I.textFont),M),textColor:D(qe(I.textColor),M),textFontSize:D(qe(I.textFontSize),M),textLineHeight:Ls(qe(I.textLineHeight),1.2),textLetterSpacing:Ls(qe(I.textLetterSpacing)),textField2:Ai(fn(I.textField),M,st.Labeling),textFont2:Ai(fn(I.textFont),M),textColor2:Ai(fn(I.textColor),M)||D(qe(I.textColor),M),textFontSize2:Ai(fn(I.textFontSize),M)||D(qe(I.textFontSize),M),textMaxLengthPerLine:I.textMaxLengthPerLine,textPlacement:D(I.textPlacement,M),textPriority:D(I.textPriority,M),textOffset:D(qe(I.textOffset),M),textOffset2:Ai(fn(I.textOffset),M),textHaloColor:D(qe(I.textHaloColor),M),textHaloColor2:Ai(fn(I.textHaloColor),M)||D(qe(I.textHaloColor),M),textHaloWidth:Ls(qe(I.textHaloWidth)),textHaloWidth2:Ls(fn(I.textHaloWidth)||qe(I.textHaloWidth)),textLabelingMargin:qe(I.textLabelingMargin),textLabelingMargin2:fn(I.textLabelingMargin)||qe(I.textLabelingMargin),textLabelingGroup:qe(I.textLabelingGroup),textLabelingGroup2:fn(I.textLabelingGroup)||qe(I.textLabelingGroup),duplicationSpacing:D(I.duplicationSpacing,M),endingOffsets:I.endingOffsets}});break}case"arrow":{const I=_w(e.style);n=ve(ue({},M),{type:e.type,interactive:!1,ignoreTier:D((x=e.ignoreTier)!=null?x:!1,M),style:{visibility:We(I.visibility),color:D(I.color,M),strokeColor:D(I.strokeColor,M),lineWidth:D(I.lineWidth,M),strokeWidth:D(I.strokeWidth,M),tipWidth:D(I.tipWidth,M),tipHeight:D(I.tipHeight,M),roundingRadius:D(I.roundingRadius,M),animation:NM(I.animation,M)}});break}case"raster":{const I=Pw(e.style);n=ve(ue({},M),{type:e.type,ignoreTier:D((O=e.ignoreTier)!=null?O:!1,M),style:{visibility:We(I.visibility),opacity:D(I.opacity,M)}});break}case"circle":{const I=Ew(e.style);n=ve(ue({},M),{type:e.type,interactive:(B=e.interactive)!=null?B:!0,style:{visibility:We(I.visibility),color:D(I.color,M),strokeColor:D(I.strokeColor,M),strokeColor2:D(I.strokeColor2,M),width:D(I.width,M),strokeWidth:D(I.strokeWidth,M),strokeWidth2:D(I.strokeWidth2,M)}});break}case"heatmap":{const I=Lw(e.style);n=ve(ue({},M),{type:e.type,style:{visibility:We(I.visibility),color:D(I.color,M),radius:D(I.radius,M),opacity:D(I.opacity,M),intensity:D(I.intensity,M),weight:D(I.weight,M),downscale:I.downscale},framebufferId:{framebuffer:Wr}});break}case"model":{const I=Ow(e.style);n=ve(ue({},M),{interactive:(U=e.interactive)!=null?U:!0,interactiveOcclusion:(j=e.interactiveOcclusion)!=null?j:!0,type:"gltfModel",style:{visibility:We(I.visibility),modelSrc:D(I.modelSrc,M),offset:D(I.offset,M,st.Generator),scale:D(I.scale,M,st.Generator),rotation:D(I.rotation,M,st.Generator),scene:D(I.scene,M),color:D(I.color,M),linkedIds:D(I.linkedIds,M),colorTextureUvIndex:I.colorTextureUvIndex,roughness:I.roughness,metallic:I.metallic,preventObjectsHiding:I.preventObjectsHiding,nearCameraFade:D(I.nearCameraFade,M),ignoreGlobalLighting:I.ignoreGlobalLighting,showRatio:D(I.showRatio,M),lightingModel:I.lightingModel,playAnimation:D(I.playAnimation,M),geometryModifier:D(I.geometryModifier,M)}});break}case"overpass":{const I=Fw(e.style);n=ve(ue({},M),{type:e.type,style:{visibility:We(I.visibility),debug:I.debug,sideColor:D(I.sideColor,M),bottomColor:D(I.bottomColor,M),topColor:D(I.borderTopColor,M),strokeColor:D(I.strokeColor,M),strokeWidth:D(I.strokeWidth,M),thickness:D(I.thickness,M),borderHeight:D(I.borderHeight,M),borderWidth:D(I.borderWidth,M),color:D(I.color,M),nearCameraFade:D(I.nearCameraFade,M),tunnelHeight:D(I.tunnelHeight,M)}});break}case"tunnel":{const I=Cw(e.style);n=ve(ue({},M),{type:e.type,style:{visibility:We(I.visibility),sideColor:D(I.sideColor,M),bottomColor:D(I.bottomColor,M),topColor:D(I.topColor,M),strokeColor:D(I.strokeColor,M),strokeWidth:D(I.strokeWidth,M),color:D(I.color,M),nearCameraFade:D(I.nearCameraFade,M)}});break}}}catch(M){if(M instanceof Ll){console.warn(`Problem with layer #${e.id}: ${M}`);return}throw M}return n}function kM(e){var n,i;const t={id:e.id,innerId:Ns(),renderIndex:Dl.getIndex(),type:e.type,layers:[],orderBy:[],precomputes:[]};return t.orderBy=(i=(n=e.orderBy)==null?void 0:n.map(s=>y0(s,t,st.Uniform)))!=null?i:[],e.layers.forEach((s,r)=>{const o=Bo(s,t);o&&(o.groupId=t.innerId,o.groupIndex=r,o.renderIndex=t.renderIndex,t.layers.push(o))}),t}function Ol(e){const t=Dw(e),n={id:"dem",type:"dem",innerId:ks,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:aM,style:{},framebufferId:{hillshade:Wr,flatBottom:Wr},lightingMode:p0};return n.style={visibility:"visible",lightingDirection:typeof t.lightingDirection!="undefined"?D(t.lightingDirection,n):null,shadingIntensity:D(t.shadingIntensity,n),shadingPalette:m0(t.shadingPalette,n),verticalScale:D(t.verticalScale,n)},n}function I0(e){const t=Rw(e),n={id:"sky",type:"custom",innerId:Nc,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:cM,style:{}};return n.style={visibility:"visible",skyColor:D(t.skyColor,n),fogColor:D(t.fogColor,n),starsIntensity:D(t.starsIntensity,n)},n}function M0(e,t){var r,o;const n=Nw(e),i={},s={ambientColor:{type:"color",value:[255,255,255,255]},ambientIntensity:0,dir1Color:{type:"color",value:[255,255,255,255]},dir1Altitude:0,dir1Azimuth:0,dir1Intensity:0,dir2Color:{type:"color",value:[255,255,255,255]},dir2Altitude:0,dir2Azimuth:0,dir2Intensity:0,shadowRadius:(r=n.shadows)==null?void 0:r.radius};for(const a in n.lightingModes){const c={ambientColor:{type:"color",value:[255,255,255,255]},ambientIntensity:0,dir1Color:{type:"color",value:[255,255,255,255]},dir1Altitude:0,dir1Azimuth:0,dir1Intensity:0,dir2Color:{type:"color",value:[255,255,255,255]},dir2Altitude:0,dir2Azimuth:0,dir2Intensity:0,shadowRadius:(o=n.shadows)==null?void 0:o.radius},l=n.lightingModes[a].map(f=>n.sources[f]).filter(Boolean),d=n.shadows?n.sources[n.shadows.source]:void 0;let u=0;l.forEach(f=>{f.color||(f.color="#FFFFFF"),f.type==="ambient"?(c.ambientColor=D(f.color,void 0),c.ambientIntensity=D(f.intensity,void 0),a===n.defaultLightingMode&&(s.ambientColor=c.ambientColor,s.ambientIntensity=c.ambientIntensity)):f.type==="directional"&&(f===d&&(c.shadowLightIndex=u),u===0?(u++,c.dir1Color=D(f.color,void 0),c.dir1Altitude=D(f.altitude,void 0),c.dir1Azimuth=D(f.azimuth,void 0),c.dir1Intensity=D(f.intensity,void 0),a===n.defaultLightingMode&&(s.dir1Color=c.dir1Color,s.dir1Intensity=c.dir1Intensity,s.dir1Azimuth=t.style.lightingDirection===null?c.dir1Azimuth:t.style.lightingDirection,s.dir1Intensity=D(f.intensity,void 0),s.dir1Altitude=c.dir1Altitude)):u===1&&(u++,c.dir2Color=D(f.color,void 0),c.dir2Altitude=D(f.altitude,void 0),c.dir2Azimuth=D(f.azimuth,void 0),c.dir2Intensity=D(f.intensity,void 0)))}),i[a]=c}return i[p0]=s,{defaultLightMode:n.defaultLightingMode,lightingModes:i}}function BM(e){return kw(e)}function T0(e,t){return typeof e=="number"&&!Number.isNaN(e)?e:t}function UM(e){return e&&or(e[2])?Un.Meters:Un.Pixels}function S0(e){return or(e)?Un.Meters:Un.Pixels}function or(e,t=!1){return Array.isArray(e)&&(e[0]==="meters-to-pixels"||e[0]==="literal"&&!t&&Array.isArray(e[1])&&e[1].some(n=>or(n,!0)))}function A0(e){if(Array.isArray(e)){if(e[0]==="meters-to-pixels"){if(typeof e[1]=="number"&&!Number.isNaN(e[1]))return e[1]}else if(e[0]==="literal"&&Array.isArray(e[1])){const[t,n]=e[1];if([t,n].every(i=>Array.isArray(i)&&i[0]==="meters-to-pixels"&&typeof i[1]=="number"&&!Number.isNaN(i[1])))return[t[1],n[1]]}}return console.warn(`Can't extract meter-to-pixels values from expression ${JSON.stringify(e)}. Size set to 0.`),0}function We(e){return e==="none"?"hidden":e}const Uo=0,zM=1,GM={type:bi.Loaded,index:-1,key:Vi("",.5,.5),isSvg:!1,name:"",fileName:"",rasters:[]},jM=["default","marker","markerText","htmlLabel"],VM={default:0,marker:1,markerText:2,htmlLabel:3,pointLabel:4},HM={default:{default:!0,marker:!1,markerText:!0,htmlLabel:!0,pointLabel:!1},marker:{default:!1,marker:!1,markerText:!0,htmlLabel:!1,pointLabel:!1},markerText:{default:!0,marker:!0,markerText:!0,htmlLabel:!1,pointLabel:!1},htmlLabel:{default:!0,marker:!1,markerText:!1,htmlLabel:!1,pointLabel:!1},pointLabel:{default:!1,marker:!1,markerText:!1,htmlLabel:!1,pointLabel:!0}};function E0(e){const t=[],n=Object.keys(oi).length;for(let i=0;i<n;i++)t[i]=NaN;for(const i in e){if(oi[i]===void 0)throw new Error(`No such tile prop '${i}'`);t[oi[i]]=e[i]}return t}class $M{constructor(){this.needRenderIndexRebuild=!1,this.style={id:Uo,revision:0,background:{color:Ds("#f6f2de")},light:{defaultLightMode:"global",lightingModes:{}},layers:[],layersById:{},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",rasterSets:{byIndex:{},byKey:{}},labelingGroups:{indexToGroup:jM,groupToIndex:VM,table:HM},fonts:hr,fontNameToIndex:ch(hr),icons:{},models:[],modelIndex:{},dem:Ol({}),environment:I0({}),graphicsPresets:{light:{},normal:{},immersive:{}},targets:{}},this.zIndexById={};const t=Bo({type:"line",id:"debug-tile-bounds",minzoom:-1/0,maxzoom:1/0,style:{color:"#ff0000",width:1}});t&&this.addLayer(t,0)}get hasDynamicObjects(){return this.style.layers.length>1}getRenderIndexById(t){var n;return((n=this.style.layersById[t])==null?void 0:n.renderIndex)||0}getStyle(){return this.style}appendRasterSet(t,n){this.style.rasterSets.byIndex[t.index]=t,n!==void 0&&(this.style.rasterSets.byKey[n]=t)}removeRasterSet(t){this.style.rasterSets.byIndex[t]=GM}getLabelingGroupIndex(t){const{groupToIndex:n}=this.style.labelingGroups;return n[t]!==void 0?n[t]:n.default}addLayer(t,n){this.style.layersById[t.innerId]||(this.style.layers.push(t),this.style.layersById[t.innerId]=t,n!==void 0&&(this.zIndexById[t.innerId]=n),this.needRenderIndexRebuild=!0)}removeLayer(t){const n=this.style.layersById[t];if(!n)return;const i=this.style.layers.indexOf(n);i!==-1&&this.style.layers.splice(i,1),delete this.style.layersById[t],delete this.zIndexById[t]}updateLayerStyle(t,{style:n,precomputes:i}){const s=this.style.layersById[t];s&&(s.style=n,s.precomputes=i)}update(){this.needRenderIndexRebuild&&(this.rebuildRenderIndex(),this.needRenderIndexRebuild=!1)}rebuildRenderIndex(){this.style.layers.sort((t,n)=>{var r,o;const i=(r=this.zIndexById[t.innerId])!=null?r:0,s=(o=this.zIndexById[n.innerId])!=null?o:0;return i-s});for(let t=0;t<this.style.layers.length;t++)this.style.layers[t].renderIndex=t}}function YM(e,t,n){const i="identify-scene",s=document.getElementById(i),r=parseInt(Ta.sceneOpacity.toString(),10);if(r===0){s&&s.parentNode&&s.parentNode.removeChild(s);return}const o=t[0],a=t[1],c=document.createElement("canvas");c.id=i,c.width=o,c.height=a;const l=c.style;l.imageRendering="pixelated",l.pointerEvents="none",l.position="absolute",l.width=n.size[0]+"px",l.height=n.size[1]+"px",l.top=`${n.viewport.top}px`,l.left=`${n.viewport.left}px`;const d=c.getContext("2d");d.clearRect(0,0,o,a);const u=d.createImageData(o,a);for(let f=0;f<o;f++)for(let h=0;h<a;h++)for(let g=0;g<4;g++){const w=(f+h*o)*4+g,p=(f+(a-1-h)*o)*4+g;u.data[w]=g===3?r:e[p]}d.putImageData(u,0,0),s&&s.parentNode?s.parentNode.replaceChild(c,s):document.body.appendChild(c)}function x0(e,t,n){const s=te,r={x:new Uint16Array([0,s,s,0,0]),y:new Uint16Array([0,0,s,s,0])},o=E0({}),a=Cs(n,Qa,oi,o,Bu);a0({collector:e,generator:dt.generate,args:[Uo,t,a,ct([0,0,0,0]),r]})}function _0(){try{return!!localStorage.getItem("debugStatusCompile")}catch(e){return console.warn("Error accessing localStorage in forceGlStatusCheck:",e),!1}}const Fl={defines:[],hash:""},_i=class _i{constructor(t,n,i=Fl,s=Fl){this.shader=null,this.type=t==="vertex"?_i.Vertex:_i.Fragment,this.sourceCode=n,this.commonDefinitions=i,this.definitions=s}static createShaderDefinitions(t){return{defines:t,hash:t.map(i=>{var s;return`${i.type}:${(s=i.value)!=null?s:""}`}).join("")}}get(t){return this.shader||this.compile(t),this.shader}remove(t){this.shader&&(t.deleteShader(this.shader),this.shader=null)}getCode(){return this.assembleShaderText().slice()}compile(t){const n=this.type===_i.Vertex?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=this.shader=t.createShader(n);if(!i||t.isContextLost())throw new Error(`[WebGl] Failed to create shader. Shader is null: ${String(!i)}. Context is lost: ${String(t.isContextLost())}`);const s=this.assembleShaderText();if(t.shaderSource(i,s),t.compileShader(i),_0()&&!t.getShaderParameter(i,t.COMPILE_STATUS)){const r=t.getShaderInfoLog(i),o=(s||"").split(`
`);throw new Error(r?r.replace(/^ERROR:\s*(\d+):(\d+):\s*(.*?)\n/,function(a,c,l,d){const u=o[Number(l)-1];return u?`ERROR ${c}:${l}: ${d}
Erroneous line: <<${u}>>
`:a}):"Unknown shader compilation error")}}assembleShaderText(){const t=this.sourceCode,n=[...this.commonDefinitions.defines,...this.definitions.defines].map(r=>r.value!==void 0?"#define "+r.type+" "+r.value:"#define "+r.type),i=Array.isArray(t)?t:[t||""];let s=!0;for(const r of i)s&&r.indexOf("#version")!==-1?n.unshift(r):n.push(r),s=!1;return n.join(`
`)}};_i.Vertex=1,_i.Fragment=2;let zo=_i;function P0(e,t,n,i){for(const s of t)XM(e,n,s,i)}function WM(e,t,n){const i=t.buffer,s=[];for(const r of t.generatedObjects){const o=new DataView(i,r.rangeStart,r.rangeEnd-r.rangeStart),a=e.createBuffer(o);a.purpose="instanced",a.drawType=Ze.StaticDraw,r.buffer=a,r.rangeEnd-r.rangeStart===n&&(r.tMatrix3x3=new Float32Array(o.buffer,r.rangeStart+16,9)),s.push(a)}return s}function ZM(e,t,n,i,s){const r=e.createBuffer(n);r.purpose="attributes",r.drawType=Ze.StaticDraw;const o=[];let a,c,l;return s&&(l=e.createBuffer(s,{itemSize:1,dataType:Ze.UnsignedShort},!0),l.elementsType=Ze.UnsignedShort),t.forEach(d=>{const u=e.getShaderProgram(d.programName),f=d.vaoCreator(r,u,l);if(d.needsVisibilityBuffer){if(!a||!c){const h=new Uint8Array(new Array(i).fill(1));a=e.createBuffer(h,void 0,!1,!0),a.purpose="visibility",c=new d0(a,{itemSize:1,dataType:Ze.UnsignedByte})}f.setAttribute("a_float_visibility",c)}o.push(f)}),{buffer:r,visibilityBuffer:a,vaos:o}}function XM(e,t,n,i){const{renderer:s,instanceLinker:r,map:o}=e,{symbol:a,sink:c,generatedObjects:l,buffer:d,elementsBuffer:u,elementSize:f}=n;if(s.symbolSettingsList[a]===void 0)return;const g=L0(s,a,c);if(g.length===0)return;const w=rr(a,c);if(g[0].instanceBinder){const E=WM(s,n,w);t.buffers.push(...E),r.enqueue(n,t);return}let p=0;u&&f?p=u.byteLength/f:p=d.byteLength/w;const{buffer:y,vaos:b,visibilityBuffer:v}=ZM(s,g,d,p,u);t.pushBuffer(y),v&&t.pushBuffer(v);const T=a==="polygonExtrusion"&&!o.getFeatureFlag("transparentBuildingsOff")||a==="lineExtrusion";for(let E=0;E<l.length;E++){const{rangeStart:S,rangeEnd:L,attributes:x,drawMode:O,meta:B,objectsData:U}=l[E],j=c0[a].sinks[c].unpackObjectAttributes(x),M=[];for(let I=0;I<g.length;I++){const X=g[I],A=b[I],P=X.uniformSet||"fill",_={id:nc(),type:uc.Tile,layerSettings:X,start:S/w,count:(L-S)/w,attributes:j,renderingProperties:{},attributesHash:JSON.stringify(x)+"_"+P+"_"+t.detailLevel,vao:A,drawMode:O,tile:t,symbol:a,sink:c,meta:B,canRender:!0};T&&(_.shaderDefinitions=zo.createShaderDefinitions([{type:"BLEND"}])),t.push(_),X.needsVisibilityBuffer&&M.push(A)}i&&M.length>0&&U&&t instanceof Vo&&qM(U,t,M,i,!!j.floorId)}}function qM(e,t,n,i,s){const r=s?t.floorObjectsMap:t.objectsMap,o=[];for(const a in e){const c=e[a];let l=r[a];l||(l=new Map,r[a]=l);let d=l.get(n);d||(d=[],l.set(n,d));for(const u of c)d.push(u);i.isHidden(a,Qi.PolygonExtrusion)&&o.push(a)}i.triggerIdUpdate(o)}function L0(e,t,n){const i=e.symbolSettingsList[t];if(i===void 0)return[];const s=i[n];return s==null||s.length===0?[]:s}const JM=4,KM=.001,QM=1e-7,eT=10,ar=11,Go=1/(ar-1),tT=typeof Float32Array=="function";function D0(e,t){return 1-3*t+3*e}function O0(e,t){return 3*t-6*e}function F0(e){return 3*e}function jo(e,t,n){return((D0(t,n)*e+O0(t,n))*e+F0(t))*e}function C0(e,t,n){return 3*D0(t,n)*e*e+2*O0(t,n)*e+F0(t)}function nT(e,t,n,i,s){let r,o,a=0;do o=t+(n-t)/2,r=jo(o,i,s)-e,r>0?n=o:t=o;while(Math.abs(r)>QM&&++a<eT);return o}function iT(e,t,n,i){for(let s=0;s<JM;++s){const r=C0(t,n,i);if(r===0)return t;const o=jo(t,n,i)-e;t-=o/r}return t}function sT(e){return e}function R0(e,t,n,i){if(!(0<=e&&e<=1&&0<=n&&n<=1))throw new Error("bezier x values must be in [0, 1] range");if(e===t&&n===i)return sT;const s=tT?new Float32Array(ar):new Array(ar);for(let o=0;o<ar;++o)s[o]=jo(o*Go,e,n);function r(o){let a=0,c=1;const l=ar-1;for(;c!==l&&s[c]<=o;++c)a+=Go;--c;const d=(o-s[c])/(s[c+1]-s[c]),u=a+d*Go,f=C0(u,e,n);return f>=KM?iT(o,u,e,n):f===0?u:nT(o,a,a+Go,e,n)}return function(a){return a===0?0:a===1?1:jo(r(a),t,i)}}function N0(e,t,n,i){return t+n/i*e}const rT=R0(.25,.1,.25,1);function k0(e,t,n,i){return t+n*rT(e/i)}function oT(e,t,n,i){return n*(e/=i)*e+t}function aT(e,t,n,i){return-n*(e/=i)*(e-2)+t}function cT(e,t,n,i){return(e/=i/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}function lT(e,t,n,i){return n*(e/=i)*e*e+t}function dT(e,t,n,i){return n*((e=e/i-1)*e*e+1)+t}function uT(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function fT(e,t,n,i){return n*(e/=i)*e*e*e+t}function hT(e,t,n,i){return-n*((e=e/i-1)*e*e*e-1)+t}function pT(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e*e+t:-n/2*((e-=2)*e*e*e-2)+t}function mT(e,t,n,i){return n*(e/=i)*e*e*e*e+t}function yT(e,t,n,i){return n*((e=e/i-1)*e*e*e*e+1)+t}function gT(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t}function wT(e,t,n,i){return-n*Math.cos(e/i*(Math.PI/2))+n+t}function vT(e,t,n,i){return n*Math.sin(e/i*(Math.PI/2))+t}function bT(e,t,n,i){return-n/2*(Math.cos(Math.PI*e/i)-1)+t}function IT(e,t,n,i){return e==0?t:n*Math.pow(2,10*(e/i-1))+t}function MT(e,t,n,i){return e==i?t+n:n*(-Math.pow(2,-10*e/i)+1)+t}function TT(e,t,n,i){return e==0?t:e==i?t+n:(e/=i/2)<1?n/2*Math.pow(2,10*(e-1))+t:n/2*(-Math.pow(2,-10*--e)+2)+t}function ST(e,t,n,i){return-n*(Math.sqrt(1-(e/=i)*e)-1)+t}function AT(e,t,n,i){return n*Math.sqrt(1-(e=e/i-1)*e)+t}function ET(e,t,n,i){return(e/=i/2)<1?-n/2*(Math.sqrt(1-e*e)-1)+t:n/2*(Math.sqrt(1-(e-=2)*e)+1)+t}function xT(e,t,n,i){var o=1.70158,s=0,r=n;if(e==0)return t;if((e/=i)==1)return t+n;if(s||(s=i*.3),r<Math.abs(n)){r=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/r);return-(r*Math.pow(2,10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/s))+t}function _T(e,t,n,i){var o=1.70158,s=0,r=n;if(e==0)return t;if((e/=i)==1)return t+n;if(s||(s=i*.3),r<Math.abs(n)){r=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/r);return r*Math.pow(2,-10*e)*Math.sin((e*i-o)*(2*Math.PI)/s)+n+t}function PT(e,t,n,i){var o=1.70158,s=0,r=n;if(e==0)return t;if((e/=i/2)==2)return t+n;if(s||(s=i*(.3*1.5)),r<Math.abs(n)){r=n;var o=s/4}else var o=s/(2*Math.PI)*Math.asin(n/r);return e<1?-.5*(r*Math.pow(2,10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/s))+t:r*Math.pow(2,-10*(e-=1))*Math.sin((e*i-o)*(2*Math.PI)/s)*.5+n+t}function LT(e,t,n,i,s){return s==null&&(s=1.70158),n*(e/=i)*e*((s+1)*e-s)+t}function DT(e,t,n,i,s){return s==null&&(s=1.70158),n*((e=e/i-1)*e*((s+1)*e+s)+1)+t}function OT(e,t,n,i,s){return s==null&&(s=1.70158),(e/=i/2)<1?n/2*(e*e*(((s*=1.525)+1)*e-s))+t:n/2*((e-=2)*e*(((s*=1.525)+1)*e+s)+2)+t}function FT(e,t,n,i){return(e/=i)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t}function CT(e,t,n,i){return n*(1-Math.pow(1-e/i,Sa.nonLinearity+1))+t}const RT=Object.freeze(Object.defineProperty({__proto__:null,ease:k0,easeInBack:LT,easeInCirc:ST,easeInCubic:lT,easeInElastic:xT,easeInExpo:IT,easeInOutBack:OT,easeInOutCirc:ET,easeInOutCubic:uT,easeInOutElastic:PT,easeInOutExpo:TT,easeInOutQuad:cT,easeInOutQuart:pT,easeInOutQuint:gT,easeInOutSine:bT,easeInQuad:oT,easeInQuart:fT,easeInQuint:mT,easeInSine:wT,easeOutBack:DT,easeOutBounce:FT,easeOutCirc:AT,easeOutCubic:dT,easeOutElastic:_T,easeOutExpo:MT,easeOutQuad:aT,easeOutQuart:hT,easeOutQuint:yT,easeOutSine:vT,inertia:CT,linear:N0},Symbol.toStringTag,{value:"Module"})),NT={easing:"easeInOutQuad",forceFinalValue:!0,renderAfterUpdate:!0};function kT(e,t){return t.tickers[e]}function B0(e,t,n,i,s,r,o,a){let c;t.animationGroup&&(c=Object.keys(n.tickers).filter(l=>n.tickers[l].animationGroup===t.animationGroup)),n.tickers[e]=ve(ue(ue({},NT),t),{from:i,to:s,duration:r,attributes:a,startTime:n.time,alreadyStartedGroupTickers:c,iterationCount:o})}function Cl(e,t){delete t.tickers[e]}function U0(e,t){return!!t.tickers[e]}function z0(e,t,n){var c;const i=n.tickers[e];if(!i)return;if(i.alreadyStartedGroupTickers&&i.alreadyStartedGroupTickers.some(l=>!!n.tickers[l])){i.startTime=n.time;return}let s=n.time-i.startTime;if(i.iterationCount>1){const l=s;s=l%i.duration,i.iterationCount!==1/0&&l>=i.duration*i.iterationCount&&(s=i.duration)}let r;if(i.from.length){r=[];for(let l=0;l<i.from.length;l++){const d=G0(i.easing,i.from[l],i.to[l],i.duration,s);r.push(d)}}else r=G0(i.easing,i.from,i.to,i.duration,s);let o=!1;s>=i.duration&&(i.forceFinalValue&&(r=i.to),o=!0),t.step&&t.step(n,r,i.attributes,o),o&&(t.keepFinished||Cl(e,n),t.complete&&t.complete(n)),(typeof i.renderAfterUpdate=="function"?i.renderAfterUpdate():i.renderAfterUpdate)&&((c=i.attributes)!=null&&c.layerId?n.rerenderEvents.push({type:"layerAnimationTicker",layerId:i.attributes.layerId,styleId:i.attributes.styleId}):n.rerenderEvents.push({type:"coreAnimationTicker"}))}function G0(e,t,n,i,s){return typeof e=="string"?RT[e](s,t,n-t,i):e(s,t,n-t,i)}let BT=0;class j0{constructor(t,n){this.isDestroyed=!1,this.id=BT++,this.ids=n,this.tickerName=`tile-fade-${t}-${this.id}`,this.readiness=1,this.needSync=!1,this.modelMatrices=new Map,this.coords=[0,0,0,0],this.bounds=new Map,this.mvpMatrices=new Map,this.demMatrices=new Map,this.flatMapTexMatrices=new Map,this.purpose=t,this.buffers=[],this.children=[],this.identifyChildren=[],this.depthTestChildren=[],this.shadowChildren=[],this.labelTestChildren=[],this.demChildren=[],this.demGroundChildren=[]}get destroyed(){return this.isDestroyed}get empty(){return this.children.length===0}updateMvpMatrix(t,n,i){this.modelMatrices.forEach((s,r)=>{var a,c,l;const o=(a=this.mvpMatrices.get(r))!=null?a:new Float32Array(16);if(Ci(o,t,s),this.mvpMatrices.set(r,o),n){const d=(c=this.demMatrices.get(r))!=null?c:new Float32Array(16);Ci(d,n,s),this.demMatrices.set(r,d)}if(i){const d=(l=this.flatMapTexMatrices.get(r))!=null?l:new Float32Array(16);Ci(d,i,s),this.flatMapTexMatrices.set(r,d)}})}setMvpMatrix(t){this.modelMatrices.forEach((n,i)=>{this.mvpMatrices.set(i,new Float32Array(t))})}clean(t){for(const n of this.buffers)n.remove();this.buffers=[],this.children=[],this.labelTestChildren=[],this.identifyChildren=[],this.depthTestChildren=[],this.shadowChildren=[],this.demChildren=[],this.demGroundChildren=[],Cl(this.tickerName,t),this.isDestroyed=!0}updateTicker(t){z0(this.tickerName,{step:(n,i)=>{this.readiness=i}},t)}startTicker(t,n,i,s,r){B0(this.tickerName,{easing:n},t,s,r,i,1)}tickerFinished(t){return!U0(this.tickerName,t)}push(t){const n=t.layerSettings;n.identify?this.identifyChildren.push(t):n.depthTest?this.depthTestChildren.push(t):n.labelTest?t.sink==="raster"&&t.symbol==="point"&&this.labelTestChildren.push(t):n.dem?this.demChildren.push(t):n.demGround?this.demGroundChildren.push(t):n.shadow?this.shadowChildren.push(t):this.children.push(t)}pushBuffer(t){this.buffers.push(t)}}class Vo extends j0{constructor(t,n,i,s,r=[0,0,0,0],o,a,c){super(t,a),this.objectsMap={},this.floorObjectsMap={},this.dynamicObject=o,this.sourceId=c,P0(i,n,this,a),this.setTileCoords(r,s)}setTileCoords(t,n){const i=t[2],s=t[3],r=Lt(i);this.coords=t,this.size=r,this.zoomLevel=i,this.detailLevel=s,this.mvpMatrices.clear(),this.demMatrices.clear(),this.flatMapTexMatrices.clear(),this.syncReplicas(n)}syncReplicas(t){let n=[...t.visibleMapReplicas];if(this.purpose==="globe"){const{center:r}=t,o=Lt(this.coords[2]),a=Math.trunc((re(2,31)+r[0])/o);n=[Math.round((a-this.coords[0])/re(2,this.coords[2]))]}if(this.dynamicObject&&this.dynamicObject.isOutOfMainReplica()){const r=n[0],o=n[n.length-1];n.push(r-1,o+1)}const i=z/te*this.size,s=Math.pow(2,this.coords[2]);this.bounds.clear(),this.modelMatrices.clear(),n.forEach(r=>{const o=[this.coords[0]+r*s,this.coords[1],this.coords[2],this.coords[3]],a=zi(o);this.bounds.set(r,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const c=pu();Tr(c,[a[0]-i,a[1]-i,0],at(this.size/Pi,this.size/Pi,ls/Pi)),this.modelMatrices.set(r,c)}),this.needSync=!1}updateObjVisibility(t,n,i){const s=i?this.floorObjectsMap[t]:this.objectsMap[t];if(!s)return!1;let r=!1;return s.forEach((o,a)=>{const l=a[0].getBuffer("a_float_visibility").getData();if(!(l instanceof Uint8Array))return;let d=!1;for(const{offset:u,size:f}of o)if(l[u]!==n){for(let h=u;h<u+f;++h)l[h]=n;d=!0}if(d){a[0].rewriteData("a_float_visibility");for(const u of a)u.isDirty=!0;r=!0}}),r}clean(t){for(const n in this.objectsMap)this.objectsMap[n].forEach((i,s)=>{s.forEach(r=>{r.unbind(),r.remove()})});for(const n in this.floorObjectsMap)this.floorObjectsMap[n].forEach((i,s)=>{s.forEach(r=>{r.unbind(),r.remove()})});super.clean(t)}}var Bt=(e=>(e[e.Stationary=0]="Stationary",e[e.ZoomingIn=1]="ZoomingIn",e[e.ZoomingOut=2]="ZoomingOut",e))(Bt||{}),Et=(e=>(e[e.ByOne=0]="ByOne",e[e.WaitingLayer=1]="WaitingLayer",e[e.GlobalWaiting=2]="GlobalWaiting",e))(Et||{});function UT(e,t,n){return{key:t,labelsKey:`${e.labelsKey}_${t}`,useful:!0,ready:!1,needGenerate:!1,tile:e,status:0,params:n.clone()}}function V0(e,t,n){e.generatedData=t,n&&e.params.setTileIds(n)}function H0(e){const t=e.generatedData,n=[];if(!t)return n;for(let i=0;i<t.length;i++){const s=t[i];s.collectorOutput.labels&&n.push({metatileHash:s.metatileHash,labels:s.collectorOutput.labels,styleId:s.styleId})}return n}function Rl(e,t){e.status=0,e.generatedData=void 0,e.objects!==void 0&&e.objects.forEach(n=>n.clean(t)),e.objects=void 0,e.ready=!1,e.tile.currentMod===e&&(e.tile.currentMod=void 0)}function $0(e){return e.status===0}function Y0(e,t,n,i,s){switch(e.status){case 0:e.useful&&(e.status=1);break;case 1:e.useful?e.tile.serverMetadata&&(e.status=2):e.status=0;break;case 2:zT(e,n,i)&&(e.status=3,e.needGenerate=!0);break;case 3:e.generatedData&&(e.status=4,e.ready=!0,e.objects=e.generatedData.map(r=>{const{collectorOutput:{data:o}}=r;return new Vo(e.tile.type,o,i,n,e.tile.coords,void 0,s,e.tile.sourceId)}),t.add(e.key,e));break}}function zT(e,t,n){switch(e.tile.type){case"zenith":return!!(e.useful&&e.tile.serverMetadata&&GT(e.tile.serverMetadata,t,n));case"traffic":return!!(e.useful&&e.tile.serverMetadata);case"raster":case"geojson":case"globe":case"dem":return!!e.useful;default:return!1}}function GT(e,t,n){const{assetManager:i,modelLayer:s}=n;for(let r=0;r<e.length;r++){const{regionId:o,metatileHash:a}=e[r];if(!i.getMetatile(a)||t.styleZoom>Ia&&!s.isModelsInfoLoaded(o))return!1}return!0}class cr{constructor(t,n,i,s,r){this.selectedIds=t.slice(),this.styleState=ue({},n),this.tileRevision=i,this.styleRevision=r,this.styleId=s}static equal(t,n){return t.tileRevision===n.tileRevision&&t.styleId===n.styleId&&t.styleRevision===n.styleRevision&&Di(t.getSelectedIds(),n.getSelectedIds())&&Di(t.styleState,n.styleState)}clone(){return new cr(this.selectedIds,this.styleState,this.tileRevision,this.styleId,this.styleRevision)}stringify(){const t=this.selectedIds.join("|");return`sId=${this.styleId}_sRev=${this.styleRevision}_tRev=${this.tileRevision}_sel=${t}_sSt=${JSON.stringify(this.styleState)}`}getSelectedIds(){return this.tileIds?this.selectedIds.filter(t=>{var n;return(n=this.tileIds)==null?void 0:n.has(t)}):this.selectedIds.slice()}setTileIds(t){this.tileIds=t}}var Nl=(e=>(e[e.Initial=0]="Initial",e[e.Loading=1]="Loading",e[e.Loaded=2]="Loaded",e))(Nl||{});function jT(e,t,n,i){return{type:e,sourceId:n,key:xe(t),labelsKey:`${e}_${n}_${i}`,coords:t,zoomLevel:t[2],detailLevel:t[3],needFetch:!1,revision:0,needAbortFetch:!1,needGenerate:!1,status:0,oldHoverTileObjects:[]}}function W0(e,t,n,i,s,r){const o=[];if(n.oldHoverTileObjects.forEach(a=>{a.tickerFinished(t)?(e.tileManager.removeObject(a),a.clean(t)):o.push(a)}),n.oldHoverTileObjects=o,s===void 0){kl(e,n,t);return}t.performanceCaveatEmitted||(r||!n.hover||n.hover.id===s)&&HT(e,t,n,s,i)}function VT(e,t){const n=Math.min(Math.floor(e.styleZoom),Kn.maxDetailLevel),i=t.coords[3];return n===i}function HT(e,t,n,i,s){if(!n.idSet||!n.idSet.has(i)||!VT(t,n)){kl(e,n,t);return}const r=e.identifier.getIdScope(_l);r.isHidden(i,Qi.PolygonExtrusion)||$T(e,n,i,s).then(o=>{kl(e,n,t);const a={id:i,tileObjects:[],generatedData:[]},c=[];o.results.forEach(l=>{const d=new Vo("hover",l.collectorOutput.data,e,t,n.coords,void 0,r),{packedRasters:u,rastersToLoad:f}=l.collectorOutput;u!==void 0&&e.assetManager.prepareRasters(l.styleId,u),e.assetManager.loadRasters(f),a.tileObjects.push(d),e.tileManager.addObject(d),d.startTicker(t,us.inAnimationType,us.inAnimationTime,0,1),l.collectorOutput.labels.length&&c.push({metatileHash:l.metatileHash,labels:l.collectorOutput.labels,styleId:l.styleId})}),a.generatedData=o.results,e.labeler.addLabels("label_hover",Ws.Tile,c),e.identifier.queryFillCache(),n.hover=a})}function kl(e,t,n){t.hover&&(t.hover.tileObjects.forEach(i=>{t.oldHoverTileObjects.push(i),i.startTicker(n,us.outAnimationType,us.outAnimationTime,1,0)}),t.hover=void 0,e.labeler.removeLabels("label_hover"),e.identifier.queryFillCache())}function $T(e,t,n,i){const s=t.newMod||t.currentMod,r=(s==null?void 0:s.params.getSelectedIds())||[],o=e.map.state;return e.defaultSource.generateHoverTile(o,t.coords,o.handyStyleId,r,self.devicePixelRatio,{},n,i)}function Z0(e){if(e.newMod&&e.newMod.needGenerate)return e.newMod.needGenerate=!1,e.newMod}function YT(e){return(!e.currentMod||$0(e.currentMod))&&(!e.newMod||$0(e.newMod))}function WT(e,t){e.currentMod&&Rl(e.currentMod,t),e.newMod&&Rl(e.newMod,t)}function ZT(e){e.currentMod=void 0}function Ho(e){if(e.currentMod&&e.currentMod.useful)return e.currentMod;if(e.newMod&&e.newMod.useful)return e.newMod}function XT(e){e.currentMod&&(e.currentMod.useful=!1),e.newMod&&(e.newMod.useful=!1)}function qT(e,t,n){if(e.idSet&&t.setTileIds(e.idSet),!e.currentMod&&!e.newMod){Bl(e,t,n);return}if(e.currentMod&&cr.equal(e.currentMod.params,t)){e.currentMod.useful=!0,e.newMod=void 0;return}if(e.newMod){cr.equal(e.newMod.params,t)?e.newMod.useful=!0:Bl(e,t,n);return}Bl(e,t,n)}function Bl(e,t,n){const i=fg(e.coords,t),s=n.get(i);s?(e.newMod=s,e.newMod.useful=!0):(e.newMod=UT(e,i,t),e.idSet&&e.newMod.params.setTileIds(e.idSet))}function JT(e,t,n,i,s){switch(e.status){case 0:e.newMod&&e.newMod.useful&&(e.status=1,e.needFetch=!0);break;case 1:e.newMod&&e.newMod.useful?e.serverMetadata&&(e.status=2):(e.status=0,e.needAbortFetch=!0);break}e.currentMod&&Y0(e.currentMod,t,n,i,s),e.newMod&&(Y0(e.newMod,t,n,i,s),e.newMod.needGenerate&&(e.needGenerate=!0))}function KT(e){e.newMod&&e.newMod.ready&&(e.currentMod=e.newMod,e.newMod=void 0)}function QT(e){const t=new Set;return e.forEach(n=>{const{idBuffer:i,orphanIds:s}=n.collectorOutput.identifyIds;for(const r of i)t.add(r);for(const r of s)t.add(r)}),t}function eS(e){e.status===1&&(e.needAbortFetch=!0),e.status=0,e.serverMetadata=void 0,e.revision++}function tS(e){e.revision++}const nS=()=>{};class X0{constructor(t,n=nS){this.size=t,this.onRemove=n,this.map=new Map,this._length=0}add(t,n){if(this.map.has(t))return;const i={key:t,value:n};this.map.set(t,i),this._addToFront(i),this._length++,this._length>this.size&&this._removeLRU()}remove(t){const n=this.map.get(t);n&&(this._removeNode(n),this.map.delete(t),this._length--)}get(t){const n=this.map.get(t);if(n)return this._moveToFront(n),n.value}reset(){for(const[t,n]of this.map)this.onRemove(t,n.value);this.map.clear(),this.head=void 0,this.tail=void 0,this._length=0}setSize(t){for(this.size=t;this._length>this.size;)this._removeLRU()}getSize(){return this.size}keys(){return Array.from(this.map.keys())}getData(){return Array.from(this.map.values()).map(t=>t.value)}_addToFront(t){t.next=this.head,t.prev=void 0,this.head&&(this.head.prev=t),this.head=t,this.tail||(this.tail=t)}_removeNode(t){t.prev?t.prev.next=t.next:this.head=t.next,t.next?t.next.prev=t.prev:this.tail=t.prev,t.next=void 0,t.prev=void 0}_moveToFront(t){this._removeNode(t),this._addToFront(t)}_removeLRU(){if(!this.tail)return;const t=this.tail.key,n=this.tail.value;this._removeNode(this.tail),this.map.delete(t),this._length--,this.onRemove(t,n)}}function es(e){const t=e.viewportTiles;for(const n in e.tiles)XT(e.tiles[n]);for(const n of t){let i=e.tiles[n];i||(i=e.tiles[n]=jT(e.type,oc(n),e.sourceId,e.tileLayerId));const s=new cr(e.selectedIds,e.styleState,i.revision,e.styleId,e.styleRevision);qT(i,s,e.tileModsCache)}}function Ul(e,t){for(const n of t){const i=e[n],s=Ho(i);if(!s||!s.ready)return!1}return!0}function q0(e){const t=[];for(const n in e.tiles){const i=e.tiles[n];i.needFetch&&(i.needFetch=!1,t.push(i))}return t}function J0(e){const t=[];for(const n in e.tiles){const i=e.tiles[n];i.needAbortFetch&&(i.needAbortFetch=!1,t.push(i))}return t}function K0(e){const t=[];for(const n in e.tiles){const i=e.tiles[n];i.needGenerate&&(i.needGenerate=!1,t.push(i))}return t}function Q0(e){const t=e.viewportTiles,n=new Set(e.tileModsCache.getData().map(s=>s.tile)),i=[];for(const s in e.tiles){const r=e.tiles[s];YT(r)&&!t.has(s)&&e.zoomDirection===Bt.Stationary&&!n.has(r)&&i.push(r)}return i}function ep(e,t,n,i,s,r,o,a,c,l,d=0,u=!1,f=!1){return{type:e,sourceId:t,tileLayerId:n,styleId:c.handyStyleId,styleRevision:a.styleManager.getStyleRevision(c.handyStyleId),styleState:c.styleState,minZoomLevel:i,maxZoomLevel:s,minDetailLevel:r,maxDetailLevel:o,tiles:{},viewportTiles:new Set,zoomLevel:tp(e,c.zoom,c.styleZoom),zoomDirection:Bt.Stationary,zoomStartZoom:0,tileModsCache:new X0(0,(h,g)=>{var w;a.labeler.removeLabels(g.labelsKey),(w=g.objects)==null||w.forEach(p=>a.tileManager.removeObject(p)),Rl(g,c)}),tileModsCacheMaxCount:0,selectedIds:[],displayedMods:{},tilesAppearance:Et.ByOne,mapState:c,stopLabelAnimation:!1,viewportPadding:d,displayStats:{matched:0,shifted:0,parent:0,children:0},requestOddTiles:u,ids:l,useExtendedTilesBounds:f}}function tp(e,t,n){return e==="raster"?Math.round(t):Math.floor(n)}function zl(e){for(const t in e.tiles)WT(e.tiles[t],e.mapState);e.tiles={},e.viewportTiles=new Set,e.zoomDirection=Bt.Stationary,e.tileModsCache.reset(),e.displayedMods={},e.tilesAppearance=Et.ByOne}function np(e,t,n,i,s=!1){const{tileManager:r,renderer:o}=e,a=n.displayedMods,c=lu(a,i);c.forEach(u=>{if(u.objects!==void 0){let f=!s;for(const h in i)if(xg(u.tile,i[h].tile)){f=!1;break}u.objects.forEach(h=>{r.addObject(h),f&&h.startTicker(t,Ma.type,Ma.time,0,1)})}});const l=lu(i,a);l.forEach(u=>{var f;u.objects!==void 0&&(u.objects.forEach(h=>{r.removeObject(h)}),(f=u.tile.hover)==null||f.tileObjects.forEach(h=>r.removeObject(h)))});const d=c.length>0||l.length>0;return d&&(t.needLabeling=!0,o.addRerenderEvent()),d}function Gl(e){e.viewportTiles.forEach(t=>KT(e.tiles[t]))}function iS(e){switch(e){case"geojson":return 3;case"raster":return 1/0;case"dem":return 1}return 2}function jl(e,t,n){sS(e,t.styleZoom,t.zoom),rS(e,t,n),oS(e),es(e)}function sS(e,t,n){const i=tp(e.type,n,t),s=i-e.zoomLevel;e.zoomDirection===Bt.Stationary&&(s>0?(e.zoomDirection=Bt.ZoomingIn,e.zoomStartZoom=e.zoomLevel):s<0&&(e.zoomDirection=Bt.ZoomingOut,e.zoomStartZoom=e.zoomLevel)),e.zoomLevel=i}function rS(e,t,n){if(e.zoomLevel<e.minZoomLevel){e.viewportTiles=new Set;return}const i=Te(e.zoomLevel,e.minZoomLevel,e.maxZoomLevel),s=Te(e.zoomLevel,e.minDetailLevel,e.maxDetailLevel);let r;switch(e.type){case"globe":r=Wu(t,i,e.minZoomLevel).map(xe);break;default:r=qu(t,n,i,e.minZoomLevel,s,e.viewportPadding,e.maxZoomLevel,e.requestOddTiles,e.useExtendedTilesBounds).map(xe),t.stats.foundVisibleTilesCount=e.viewportTiles.size}e.viewportTiles=new Set(r)}function oS(e){const t=Math.round((Object.keys(e.displayedMods).length+e.viewportTiles.size)*Kn.cacheRatio);e.tileModsCacheMaxCount<t&&(e.tileModsCacheMaxCount=t),t>e.tileModsCacheMaxCount/2&&e.tileModsCache.setSize(t)}function aS(e,t){const n={};for(const i in e){const s=e[i];let r=Math.floor(s.coords[0]/2),o=Math.floor(s.coords[1]/2);for(let a=s.coords[2]-1;a>=t;a--){const c=Yo(r,o,a),l=n[c];l?l.push(s):n[c]=[s],r=Math.floor(r/2),o=Math.floor(o/2)}}return n}function cS(e,t,n){const i=uS(e),s=Object.keys(i).reduce((u,f)=>{const h=i[f],g=Yo(h.coords[0],h.coords[1],h.coords[2]);return u[g]=h,u},{}),r=Math.min(...Object.values(i).map(u=>u.coords[2])),o=Math.min(...Array.from(t).map(u=>e[u].coords[2])),a=aS(i,o),c={},l=new Set;for(const u of t){const f=i[u];if(f){$o(c,f),n.matched++;continue}const h=e[u],g=lS(h,i,3);if(g){n.shifted++,$o(c,g);continue}const w=Yo(h.coords[0],h.coords[1],h.coords[2]),p=ip(h,r,s);if(p){n.parent++,$o(c,p),l.add(p);continue}const y=a[w];if(y)for(const b of y)n.children++,$o(c,b)}function d(u){const f=ip(u,r,s);f&&l.has(f)&&(delete c[u.currentMod.key],d(f))}for(const u in c)d(c[u].tile);return c}function lS(e,t,n){const{coords:i}=e,s=Math.min(i[3]+n,32),r=Math.max(i[3]-n,0);for(let o=r;o<=s;o+=1){if(o===i[3])continue;const a=$u(i[0],i[1],i[2],o),c=t[a];if(c)return c}}function dS(e){const t=e.currentMod;return t===void 0?!1:t.ready}function $o(e,t){const n=t.currentMod;e[n.key]=n}function uS(e){const t={};for(const n in e){const i=e[n];dS(i)&&(t[n]=i)}return t}function ip(e,t,n){let[i,s,r]=e.coords;for(;r-->=t;){i=Math.floor(i/2),s=Math.floor(s/2);const o=Yo(i,s,r);if(n[o])return n[o]}}function Yo(e,t,n){return`${e}_${t}_${n}`}function sp(e,t,n){fS(e,t,n),hS(e),pS(e);for(const i in e.displayedMods)e.tileModsCache.get(i);mS(e),yS(e)}function fS(e,t,n){for(const i in e.tiles)JT(e.tiles[i],e.tileModsCache,t,n,e.ids)}function hS(e){switch(e.tilesAppearance){case Et.ByOne:Gl(e);break;case Et.WaitingLayer:Ul(e.tiles,e.viewportTiles)&&(e.tilesAppearance=Et.ByOne,Gl(e));break;case Et.GlobalWaiting:break}}function pS(e){const{tiles:t,viewportTiles:n,displayStats:i}=e;e.displayedMods=cS(t,n,i)}function mS({tiles:e,displayedMods:t,viewportTiles:n}){for(const i in e){if(n.has(i))continue;const s=e[i],r=s.currentMod;r&&!t[r.key]&&ZT(s)}}function yS(e){switch(e.zoomDirection){case Bt.ZoomingIn:(e.zoomLevel<=e.zoomStartZoom||rp(e))&&(e.zoomDirection=Bt.Stationary,e.zoomStartZoom=e.zoomLevel);break;case Bt.ZoomingOut:(e.zoomLevel>=e.zoomStartZoom||rp(e))&&(e.zoomDirection=Bt.Stationary,e.zoomStartZoom=e.zoomLevel);break}}function rp(e){const{tiles:t,viewportTiles:n,displayedMods:i}=e;for(const s of n){const r=t[s],o=Ho(r);if(!o||i[o.key]===void 0)return!1}return!0}function gS(e,t,n,i){var s;n.selectedIds=i,n.tilesAppearance=Et.WaitingLayer,es(n);for(const r in n.tiles){const o=n.tiles[r];W0(e,t,o,n.sourceId,(s=o.hover)==null?void 0:s.id,!0)}}function op(e,t,n,i){if(!t.disableHoverStyles){for(const s in n.tiles){const r=n.tiles[s];W0(e,t,r,n.sourceId,i)}e.labeler.disableThrottleUpdateOnce()}}function wS(e,t){e.styleState=t,es(e)}function ap(e,t,n,i){i?e.tilesAppearance=Et.ByOne:e.tilesAppearance=Et.GlobalWaiting,e.styleId=t,e.styleRevision=n,es(e)}function cp(e){e.tilesAppearance=Et.ByOne,Gl(e)}function vS(e){e.tilesAppearance=Et.WaitingLayer,e.stopLabelAnimation=!0,Object.keys(e.tiles).forEach(t=>{eS(e.tiles[t])}),es(e)}function bS(e){e.tilesAppearance=Et.WaitingLayer,Object.keys(e.tiles).forEach(t=>{tS(e.tiles[t])}),es(e)}function IS(e,t,n){for(const i of e.viewportTiles){const s=e.tiles[i],r=Ho(s);if(!r)continue;const o=H0(r);if(o.length===0)continue;const a=t.getLabelsDemKey(o);r.demKey!==a&&(r.demKey=a,n.addTileLabels(r.labelsKey,Ws.Tile,o))}}function Vl(e){return{_src:e.memSizeJs()}}function MS(e){return{_texture:e.memSizeGPU()}}function lp(e){return{[String(e.purpose)]:{_initData:e.memSizeJs()}}}function TS(e){return{[String(e.purpose)]:{_glBuffer:e.memSizeGPU()}}}function Hl(e){var n;const t={};return e.generatedData&&(t.generatedData={collectorOutput:(n=e.generatedData)==null?void 0:n.map(i=>ES(i.collectorOutput))}),e.objects&&(t.objects=e.objects.map(i=>dp(i))),t}function $l(e){return{objects:e.objects?e.objects.map(t=>up(t)):0}}function dp(e){return{buffers:e.buffers.map(lp)}}function up(e){return{children:e.children.map(t=>{var n;return{[`${t.symbol}_${t.sink}`]:((n=t.instanceCount)!=null?n:t.count)*rr(t.symbol,t.sink)}}),buffers:e.buffers.filter(t=>t.purpose!=="attributes"&&t.purpose!=="instanced").map(t=>({[String(t.purpose)]:t.byteLength}))}}function SS(e){return{buffers:e.buffers.filter(t=>t instanceof Ze).map(lp).filter(t=>t._initData),textures:e.textures.map(Vl)}}function AS(e){return{buffers:e.buffers.filter(t=>t instanceof Ze).map(TS),textures:e.textures.map(Vl)}}function Yl(e){if(typeof e=="number")return e;let t=0;if(Array.isArray(e))for(const n of e)t+=Yl(n);else for(const n in e){const i=e[n];typeof i=="number"?t+=i:t+=Yl(i)}return t}function ES(e){return{data:e.data.reduce((n,i)=>(n[`${i.symbol}_${i.sink}`]=i.buffer.byteLength,n),{}),identifyIds:{centerBuffer:e.identifyIds.centerBuffer.byteLength,instanceIdBuffer:e.identifyIds.instanceIdBuffer.byteLength,layerIdBuffer:e.identifyIds.layerIdBuffer.byteLength,objectClassBuffer:e.identifyIds.objectClassBuffer.byteLength,phaseBuffer:e.identifyIds.phaseBuffer.byteLength,styleIdBuffer:e.identifyIds.styleIdBuffer.byteLength,sublayerBuffer:e.identifyIds.sublayerBuffer.byteLength}}}function xS(e){return Le(this,null,function*(){return{defaultSource:e.defaultSource.getMemoryFootprint(),tileManager:e.tileManager.getMemoryFootprint(t=>!e.defaultSource.hasLayer(t)),identifier:e.identifier.getMemoryFootprint(),assetManager:e.assetManager.getMemoryFootprint(),trafficTileLayer:e.trafficTileLayer.getMemoryFootprint(),imageManager:e.imageManager.getMemoryFootprint(),parserThread:yield e.workers.parser.getMemoryFootprint(),labelingThread:yield e.workers.labeling.getMemoryFootprint(),renderer:e.renderer.getMemoryFootprint(),labeler:e.labeler.getMemoryFootprint(),postEffectsManager:e.postEffectsManager.getMemoryFootprint(),shadowManager:e.shadowManager.getMemoryFootprint()}})}class fp{constructor(t,n,i,s,r,o,a,c={}){var l;this.disabledRegions=null,this.generatingCount=0,this.tilesGenerationQueue=[],this.disableTilesAnimation=!1,this.idsToUpdate=new Set,this.destroyed=!1,c=Object.assign({viewportPadding:0,disableTilesAnimation:!1,requestOddTiles:!1},c),this.ids=r.identifier.getIdScope((l=c.idScope)!=null?l:_l),this.ids.registerTileLayer(this),this.modules=r,this.mapState=o,this.prevStyleState=o.styleState,this.sourceCore=a,this.id=nc(),this.disableTilesAnimation=!!c.disableTilesAnimation,this.gridState=ep(a.type,a.id,this.id,t,n,i,s,r,this.mapState,this.ids,c.viewportPadding,c.requestOddTiles,c.useExtendedTilesBounds),this.maxGeneratingCount=iS(a.type)}memSizeJs(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>Hl(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>Hl(t.tileModsCache.get(n)))}}}memSizeGpu(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>$l(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>$l(t.tileModsCache.get(n)))}}}destroy(){this.destroyed=!0,zl(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),this.ids.unregisterTileLayer(this)}redraw(){zl(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),jl(this.gridState,this.mapState,this.modules)}getZoomDirection(){return this.gridState.zoomDirection}getDisplayedTileObjects(){const t=[];for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n];i.objects&&t.push(...i.objects)}return t}getDisplayedIdentifyData(){var n,i;const t=[];for(const s in this.gridState.displayedMods){const r=this.gridState.displayedMods[s];(i=r.generatedData)==null||i.concat(((n=r.tile.hover)==null?void 0:n.generatedData)||[]).forEach(o=>t.push({ids:o.collectorOutput.identifyIds,metatileHash:o.metatileHash,sourceId:r.tile.sourceId,tileKey:r.tile.key}))}return t}getLabelingData(){const t={sourceId:this.gridState.sourceId,animate:!this.gridState.stopLabelAnimation,labelsKeys:[]};for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n];t.labelsKeys.push(i.labelsKey)}return this.gridState.stopLabelAnimation&&this.viewportTilesReady()&&(this.gridState.stopLabelAnimation=!1),t}getViewportTiles(){const t=[],n=this.gridState.viewportTiles;for(const i of n){const s=this.gridState.tiles[i];s&&t.push(s)}return t}viewportTilesReady(){return Ul(this.gridState.tiles,this.gridState.viewportTiles)}isEmpty(){return this.gridState.viewportTiles.size===0}displayedTilesAnimationFinished(){for(const t in this.gridState.displayedMods){const n=this.gridState.displayedMods[t];if(n.objects){for(const i of n.objects)if(!i.tickerFinished(this.mapState))return!1}}return!0}activateStyleUpdating(){ap(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){cp(this.gridState)}setSelectedIds(t){gS(this.modules,this.mapState,this.gridState,t)}setHoverId(t){op(this.modules,this.mapState,this.gridState,t)}resetHoverId(){op(this.modules,this.mapState,this.gridState)}onSourceDataChange(){vS(this.gridState)}onFeatureStateMapChange(){bS(this.gridState)}getTileCount(){let t=0;for(const n in this.gridState.displayedMods){const i=this.gridState.displayedMods[n].objects;i!==void 0&&(t+=i.length)}return t}isBlank(){for(const t of this.gridState.viewportTiles){const n=this.gridState.tiles[t],{serverMetadata:i}=n;if(i===void 0||i.length===0)continue;const s=Ho(n);if(s&&s.ready)return!1}return!0}updateViewport(){jl(this.gridState,this.mapState,this.modules)}update(){this.mapState.needReplicasUpdate&&this.setModObjectsSyncNecessity();const t=ue({},this.gridState.displayedMods);this.mapState.styleState!==this.prevStyleState&&(wS(this.gridState,this.mapState.styleState),this.prevStyleState=this.mapState.styleState,this.modules.identifier.queryFillCache()),sp(this.gridState,this.mapState,this.modules);const{demManager:n,labeler:i}=this.modules;IS(this.gridState,n,i),this.fetch(q0(this.gridState)),this.abortFetch(J0(this.gridState)),this.generate(K0(this.gridState)),this.clearTiles(Q0(this.gridState)),np(this.modules,this.mapState,this.gridState,t,this.disableTilesAnimation),this.updateVisibility()}pushIdsToUpdate(t){t.forEach(n=>this.idsToUpdate.add(n))}getSourceType(){return this.sourceCore.type}fetch(t){if(t.length===0)return;const n=t.sort((s,r)=>kr(this.mapState.center,s,r)).map(s=>s.coords);this.sourceCore.fetchTiles(n,this.mapState).forEach((s,r)=>{s.then(o=>{const a=t[r];a.status===Nl.Loading&&(a.serverMetadata=o)})})}abortFetch(t){t.length!==0&&this.sourceCore.abortTileFetches(t.map(n=>n.coords))}updateGenerationQueue(){if(this.destroyed||this.generatingCount>this.maxGeneratingCount)return;const t=this.getTileToGenerate();if(!t)return;++this.generatingCount;const{tile:n,mod:i}=t,s={tileCoords:n.coords,selectedIds:i.params.getSelectedIds(),styleId:i.params.styleId},r=this.disabledRegions,o={areTileBoundsVisible:this.mapState.showDefaultTileBounds};this.sourceCore.generateTile(this.mapState,s.tileCoords,s.styleId,s.selectedIds,devicePixelRatio,o).then(a=>{if(!a){bf(this.sourceCore.type);return}if(!Array.isArray(a.results))return;let{results:c}=a;r&&(c=c.filter(d=>!r.includes(d.regionId)));const l=new Map;if(c.forEach(d=>{d.collectorOutput.data.forEach(u=>{u.symbol!=="gltfModel"||u.sink!=="instances"||u.generatedObjects.forEach(f=>{var y;const h=Wn.sinks.instances.unpackObjectAttributes(f.attributes),g=(y=f.meta)==null?void 0:y.childrenIds,w=h.parentId;if(!g||!w)return;let p=l.get(w);p||(p=new Set,l.set(w,p));for(const b of g)p.add(b)})})}),l.size){const d=xe(s.tileCoords);this.ids.updateParentChildrenData(d,l)}c.forEach(d=>{const{styleId:u,metatileHash:f,regionId:h,collectorOutput:g}=d,{packedRasters:w,rastersToLoad:p,floorHidingMap:y,dataModelsUrls:b}=g;w!==void 0&&this.modules.assetManager.prepareRasters(u,w),this.modules.assetManager.fillDataModelUrlMap(b),this.modules.assetManager.loadRasters(p),this.modules.floorManager.prepareFloors(h,f,y,this.sourceCore.type)}),n.idSet=QT(c),V0(i,c,n.idSet),this.modules.labeler.addTileLabels(i.labelsKey,Ws.Tile,H0(i))}).finally(()=>{this.generatingCount=this.generatingCount-1,this.updateGenerationQueue()})}getTileToGenerate(){this.tilesGenerationQueue.sort((n,i)=>kr(this.mapState.center,n,i));let t=this.tilesGenerationQueue.shift();for(;t;){const n=Z0(t);if(n){if(n.useful)return{mod:n,tile:t};t.newMod=void 0}t=this.tilesGenerationQueue.shift()}return null}addTileToGenerationQueue(t){this.tilesGenerationQueue.push(t)}generate(t){let n=!1;t.sort((i,s)=>kr(this.mapState.center,i,s)).forEach(i=>{var s;(s=i.newMod)!=null&&s.needGenerate&&!this.tilesGenerationQueue.includes(i)&&(this.addTileToGenerationQueue(i),n=!0)}),n&&this.updateGenerationQueue()}clearTiles(t){if(!t.length)return;const n=[];this.modules.modelsScene.clearSourceTileMapByTiles(this.sourceCore.id,t),this.sourceCore.deleteTiles(t.map(i=>i.coords));for(const i of t)n.push(i.key),delete this.gridState.tiles[i.key];this.ids.removeParentChildrenData(n)}updateVisibility(){if(this.idsToUpdate.size===0)return;const t=[];this.gridState.tileModsCache.getData().forEach(i=>{i.objects&&i.objects.forEach(s=>{t.push(s)})}),t.length!==0&&this.updateObjectsVisibility(t)}updateObjectsVisibility(t){let n=!1;for(const i of this.idsToUpdate){const s=+!this.ids.isHidden(i,Qi.PolygonExtrusion),r=+!this.ids.isHidden(i,Qi.FloorPolygons);for(const o of t)o.updateObjVisibility(i,s,!1)&&(n=!0),o.updateObjVisibility(i,r,!0)&&(n=!0)}this.idsToUpdate.clear(),n&&(this.modules.renderer.addRerenderEvent(),this.modules.identifier.queryFillCache())}setModObjectsSyncNecessity(){this.gridState.tileModsCache.getData().forEach(n=>{var i;(i=n.objects)==null||i.forEach(s=>{s.needSync=!0})})}}class hp{constructor(t,n,i,s){var r;this.id=t,this.modules=n,this.options=i,this.type="geojson",this.idToIndex={},this.worker=new this.modules.workers.parser.GeoJsonSource(this.options,this.id,Array.from((r=s==null?void 0:s.modelShowHideEventsSublayers)!=null?r:new Set)),this.attributes=i.attributes||{},this.dataFilter=i.dataFilter}fetchTiles(t){return this.worker.fetchTiles(t).map(n=>n.catch(()=>Promise.resolve()).then(()=>[{regionId:0,metatileHash:-2}]))}generateTile(t,n,i,s,r){return Le(this,null,function*(){const o=this.options.modelsPath,a=yield this.worker.generateTile(t.styleState,n,i,s,r,o,this.dataFilter,t.modelShowHideEventsSublayers);return Array.isArray(a.results)?(a.results[0]&&a.results[0].idToIndex&&(this.idToIndex[xe(n)]=a.results[0].idToIndex),a):{results:[],transferable:[]}})}getObjectAttributes(t,n){return Promise.resolve(this.worker.getObjectAttributes(t,n))}abortTileFetches(t){this.worker.abortTileFetches(t)}deleteTiles(t){for(const n of t)delete this.idToIndex[xe(n)];this.worker.deleteTiles(t)}setAttributes(t){this.worker.setSourceAttrs(t),this.attributes=t}getAttributes(){return this.attributes}destroy(){this.idToIndex={},this.worker.destroy()}setFeatureStateMap(t){this.worker.setFeatureStateMap(t)}setData(t){return Le(this,null,function*(){return this.idToIndex={},this.options=typeof t=="string"?this.options=ve(ue({},this.options),{url:t}):this.options=ve(ue({},this.options),{data:t}),yield this.worker.setData(t)})}getComponentIndex(t,n){var i;return n?(i=this.idToIndex[n])==null?void 0:i[t]:(console.warn("Нет tileKey при идентификации объекта из GeoJsonSource. Пытаемся получить index из id по-старому."),Number.isNaN(+t)?void 0:+t%re(2,32))}setDataFilter(t){t?this.dataFilter=D(t,{precomputes:[]},st.Generator):this.dataFilter=void 0}}let _S=1;function pp(){return _S++}class mp{constructor(t){this.defs=t.map(n=>new PS(n))}check(t){const n=this.defs;let i=!1;for(let s=0;s<n.length;s++)i?n[s].update(t):i=!n[s].equal(t);return i}}class PS{constructor(t){this.path=Array.isArray(t.path)?t.path:[t.path],this.type=t.type,this.type==="number"?(this.last=NaN,this.compare=this.primitive,this.updateFn=this.primitiveUpdate):this.type==="boolean"?(this.last=void 0,this.compare=this.primitive,this.updateFn=this.primitiveUpdate):this.type==="vec2"?(this.last=[NaN,NaN],this.compare=this.vec2,this.updateFn=this.vec2Update):this.type==="vec3"?(this.last=[NaN,NaN,NaN],this.compare=this.vec3,this.updateFn=this.vec3Update):this.type==="string"?(this.last="",this.compare=this.primitive,this.updateFn=this.primitiveUpdate):this.type==="padding"?(this.last={left:0,right:0,bottom:0,top:0},this.compare=this.padding,this.updateFn=this.paddingUpdate):this.type==="replicas"&&(this.last={min:0,max:0},this.compare=this.replicas,this.updateFn=this.replicasUpdate)}equal(t){const n=this.take(t),i=this.compare(this.last,n);return this.updateFn(n),i}update(t){this.updateFn(this.take(t))}take(t){const n=this.path;let i=0;do t=t[n[i++]];while(i<n.length);return t}primitive(t,n){return t===n}padding(t,n){return t.top===n.top&&t.bottom===n.bottom&&t.left===n.left&&t.right===n.right}paddingUpdate(t){this.last.top=t.top,this.last.bottom=t.bottom,this.last.right=t.right,this.last.left=t.left}vec2(t,n){return t[0]===n[0]&&t[1]===n[1]}vec3(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}primitiveUpdate(t){this.last=t}vec2Update(t){this.last[0]=t[0],this.last[1]=t[1]}vec3Update(t){this.last[0]=t[0],this.last[1]=t[1],this.last[2]=t[2]}replicas(t,n){const i=n[0],s=n[n.length-1];return t.min===i&&t.max===s}replicasUpdate(t){this.last.min=t[0],this.last.max=t[t.length-1]}}function yp(e,t,n){let i,s,r,o;const a=function(){const d=Date.now()-r;d<t&&d>=0?i=setTimeout(a,t-d):(i=null,n||(o=e(...s),i||(s=null)))};function c(){i!==void 0&&(clearTimeout(i),i=null)}function l(...d){s=d,r=Date.now();const u=n&&!i;return i||(i=setTimeout(a,t)),u&&(o=e(...s),s=null),o}return l.cancel=c,l}const gp=15,Wl=17;class wp{constructor(t,n,i){var o,a,c;this.type="geojson",this.isCustomPromoteId=!1,this.id=pp(),this.modelsAppearStrategy=(o=n.modelsAppearStrategy)!=null?o:Fd,this.modules=t.modules,this.mapglApiSource=i,this.identifiedAsDefault=!!n.identifyAsDefaultSource,n.promoteId&&(this.isCustomPromoteId=!0),this.identifiedAsDefault&&!n.promoteId&&(n.promoteId="db_id"),"generateId"in n&&n.promoteId&&(n.generateId=!1),this.sourceCore=new hp(this.id,this.modules,n);const s=(a=n.minZoom)!=null?a:va.minZoom,r=Math.min((c=n.maxZoom)!=null?c:gp,Wl);this.layer=new fp(s,r,s,Wl,this.modules,t.state,this.sourceCore,n),this.modules.tileManager.addTileLayer(this.layer)}destroy(){this.modules.tileManager.removeTileLayer(this.layer),this.layer.destroy(),this.modules.sourceStorage.removeSource(this.getId()),this.sourceCore.destroy()}setAttributes(t){this.sourceCore.setAttributes(t),this.layer.redraw(),this.modules.identifier.resetCache()}getAttributes(){return this.sourceCore.getAttributes()}getZoomDirection(){return this.layer.getZoomDirection()}getId(){return this.sourceCore.id}isIdentifiedAsDefault(){return this.identifiedAsDefault}}const Wo={type:"FeatureCollection",features:[]};let vp=class Bm extends wp{constructor(t,n,i){n.generateId=!0,super(t,n,i),this.subtype="internal",this.data=n.data,this instanceof Bm&&this.modules.sourceStorage.addSource(this)}getFeatureById(t,n){if(this.data.type==="FeatureCollection"){let i;const s=this.sourceCore.getComponentIndex(t,n);return s===void 0?(this.isCustomPromoteId&&(i=this.data.features.find(r=>r.id===t)),i):this.data.features[s]}return this.data}destroy(){super.destroy(),this.data=Wo}setData(t){return Le(this,null,function*(){(yield this.sourceCore.setData(t))&&(this.data=t,this.layer.onSourceDataChange(),this.modules.identifier.resetCache())})}setDataFilter(t){this.sourceCore.setDataFilter(t)}};class LS extends wp{constructor(t,n,i){super(t,n,i),this.subtype="external",n.preventInteractions&&(n.promoteId=void 0),this.modules.sourceStorage.addSource(this)}getObjectAttributes(t,n){return this.sourceCore.getObjectAttributes(t,n)}setDataUrl(t){return Le(this,null,function*(){(yield this.sourceCore.setData(t))&&(this.layer.onSourceDataChange(),this.modules.identifier.resetCache())})}}let DS=class extends vp{constructor(t,n,i){super(t,n,i),this.subtype="viewport-internal",this.destroyed=!1,this.viewportDiffer=new mp([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this._map=t,this.viewportPadding=n.viewportPadding,this.modules.sourceStorage.addSource(this)}setDataFn(t){return Le(this,null,function*(){this.setViewportHandler(t)})}setViewportPadding(t){this.viewportPadding=t,this.viewportHandler&&this.viewportHandler()}update(){this.viewportDiffer.check(this._map.state)&&this.viewportHandler&&this.viewportHandler()}destroy(){this.destroyed=!0,this.viewportHandler&&(this.viewportHandler.cancel(),this.viewportHandler=void 0),super.destroy()}setViewportHandler(t){if(!t){this.setData(Wo),this.viewportHandler=void 0;return}this.viewportHandler=yp(()=>Le(this,null,function*(){const n=this._map.getBounds({sizeExtension:this.viewportPadding}),i=n.southWest,s=n.northEast,r=[i[0],i[1],s[0],s[1]],o=t(r);let a=Wo;try{const c=yield fetch(o);c.ok||console.error(`Failed to fetch a tile by url "${o}", status: ${c.status}`);const l=c.headers.get("content-type");(!l||!l.includes("application/json"))&&console.error(`Failed to fetch a tile by url "${o}", expected the "application/json" data but got "${l}"`),a=yield c.json()}catch(c){console.error(`Failed to fetch a tile by url "${o}", message: ${c.message}`)}this.destroyed||this.setData(a)}),500),this.viewportHandler()}};function Zo(e,t){const n=new XMLHttpRequest;if(n.open("GET",e.url,!0),n.responseType="arraybuffer",e.headers)for(const i in e.headers)n.setRequestHeader(i,e.headers[i]);return n.onerror=function(){t({status:0,message:"Network error"},new ArrayBuffer(0))},n.onload=function(){n.status>=200&&n.status<300&&n.response?t(void 0,n.response):t({status:n.status,message:n.statusText},new ArrayBuffer(0))},n.send(),n}function bp(e,t){const n=new XMLHttpRequest;if(n.open("GET",e.url,!0),e.headers)for(const i in e.headers)n.setRequestHeader(i,e.headers[i]);return n.onerror=function(){t({status:0,message:"Network error"},{})},n.onload=function(){if(n.status>=200&&n.status<300){if(!n.response||!n.response.length)return t({status:204,message:"No content"},{});let i;try{i=JSON.parse(n.response),t(void 0,i)}catch(s){t({status:0,message:`Json parse data error from url ${e.url}`},{})}}else t({status:n.status,message:n.statusText},{})},n.send(),n}function Ip(e){return e?e>=500&&e<=599:!1}function Mp(e){return new Promise(t=>setTimeout(t,e))}class OS{constructor(){this.cache=new Map,this.pendingRequests=new Map}fetch(t,n=3,i=300){return Le(this,null,function*(){var o;let s=0,r;for(;s<=n;)try{if(r=yield this.fetchAttempt(t),!r)return;if(!r.err||!Ip((o=r.err)==null?void 0:o.status))return r;throw new Error(`Fetching ${JSON.stringify(t.coords)} attempt ${s} failed.`)}catch(a){if(s>=n)return{metadata:[]};yield Mp(Math.pow(2,s)*i),s++}})}get(t){return this.cache.get(t)||[]}delete(t){this.cache.delete(t)}abortRequest(t){const n=this.pendingRequests.get(t);n!==void 0&&(n.xhr.abort(),n.resolve(),this.pendingRequests.delete(t))}destroy(){this.cache.clear(),this.pendingRequests.clear()}fetchAttempt({tileUrl:t,coords:n}){return new Promise(i=>{const s=xe(n),r=Zo({url:t},(o,a)=>{if(this.pendingRequests.delete(s),o||a.byteLength===0){o!==void 0&&console.error(o),this.cache.set(s,[]),i({metadata:[],err:o});return}const c=hg(a),l=pg(c);this.cache.set(s,c),i({metadata:l,err:o})});this.pendingRequests.set(s,{xhr:r,resolve:i})})}}class Zl extends Map{constructor(t){super(t),this.featureAttrs=(t==null?void 0:t.featureAttrs)||new Set,this.clearAttrs=!0}set(t,n){return super.set(t,n),Object.keys(n).forEach(i=>this.featureAttrs.add(i)),this}}function Xl(e){for(let t=1;t<e.length;t++)e[t]=e[t]+e[t-1]}function FS(e){let t=0,n=0,i=0;for(let s=0;s<e.length;s+=2)i=n+e[s],n=i>>>0,e[s]=n,t=t+e[s+1]+(i>4294967295?1:0)>>>0,e[s+1]=t}const Tp={1:Xl,2:Xl,4:Xl,8:FS};class Sp{constructor(t){this.offset=0,this.buffer=t,this.u8=new Uint8Array(t),this.u16=new Uint16Array(t),this.u32=new Uint32Array(t),this.s8=new Int8Array(t),this.s16=new Int16Array(t),this.s32=new Int32Array(t),this.f32=new Float32Array(t)}readS8(){return this.s8[this.offset++]}readU16(){const t=this.u16[this.offset>>1];return this.offset+=2,t}readU32(){const t=this.u32[this.offset>>2];return this.offset+=4,t}readF32(){const t=this.f32[this.offset>>2];return this.offset+=4,t}readU8Vector(t=1){const i=this.readU32()*t,s=-i&3,r=this.u8.subarray(this.offset,this.offset+i);return this.offset+=i+s,r}readU16Vector(t=1){const i=this.readU32()*t*2,s=-i&3,r=this.u16.subarray(this.offset>>1,this.offset+i>>1);return this.offset+=i+s,r}}function Ue(e,t,n,i){const s=t.BYTES_PER_ELEMENT;e.offset+=-e.offset&s-1;const r=new t(e.buffer,e.offset,n);return e.offset+=s*n,i&&Tp[s](r),r}function Xo(e,t,n){e.offset+=-e.offset&7;const i=new Uint32Array(e.buffer,e.offset,t*2);return e.offset+=8*t,n&&Tp[8](i),i}function Ap(e,t,n){e.offset+=-e.offset&3;const i=new Uint32Array(e.buffer,e.offset,t),s=new Float32Array(e.buffer,e.offset,t);e.offset+=4*t;let r;if(n){let o=0;for(r=0;r<t;r++)o=o+i[r]>>>0,s[r]=o/1e3}else for(r=0;r<t;r++)s[r]=i[r]/1e3;return s}function Ep(e,t,n){e.offset+=-e.offset&3;const i=new Int32Array(e.buffer,e.offset,t),s=new Float32Array(e.buffer,e.offset,t);e.offset+=4*t;let r;if(n){let o=0;for(r=0;r<t;r++)o=o+i[r]>>>0,s[r]=(o|0)/1e3}else for(r=0;r<t;r++)s[r]=i[r]/1e3;return s}function CS(e,t){let n=e.offset;const i=e.u8,s=e.buffer,r=[];for(;t--;)r.push(i[n++]|0);const o=[];for(;++t<r.length;){let a=r[t];a===255&&(a=i[n++]|i[n++]<<8|i[n++]<<16|0),o.push(new Uint8Array(s,n,a)),n=n+a}return e.offset=n,o}function RS(e,t){e.offset+=-e.offset&3;let n=e.offset;const i=e.u32,s=e.buffer,r=[];for(let a=0;a<t;a++)r.push(i[n>>2]),n+=4;const o=[];for(let a=0;a<t;a++){const c=r[a];n+=-n&7,o.push(new Uint8Array(s,n,c)),n+=c}return e.offset=n,o}function NS(e,t,n){switch(n){case 2:return Ue(e,Uint8Array,t);case 3:return Ue(e,Uint8Array,t,!0);case 4:return Ue(e,Uint16Array,t);case 5:return Ue(e,Uint16Array,t,!0);case 6:return Ue(e,Uint32Array,t);case 7:return Ue(e,Uint32Array,t,!0);case 8:return Xo(e,t);case 9:return Xo(e,t,!0);case 10:return Ue(e,Uint8Array,t);case 11:return CS(e,t);case 12:return RS(e,t);case 13:return Ue(e,Int8Array,t);case 14:return Ue(e,Int8Array,t,!0);case 15:return Ue(e,Int16Array,t);case 16:return Ue(e,Int16Array,t,!0);case 17:return Ue(e,Int32Array,t);case 18:return Ue(e,Int32Array,t,!0);case 19:return Xo(e,t);case 20:return Xo(e,t,!0);case 21:return Ap(e,t);case 22:return Ap(e,t,!0);case 23:return Ep(e,t);case 24:return Ep(e,t,!0);case 25:return Ue(e,Uint32Array,t);default:throw new Error("Unknown stream type "+n)}}function ql(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function kS(e,t,n){return new e.constructor(e.buffer,e.byteOffset+t*e.BYTES_PER_ELEMENT,n)}let qn;const ts=[],Zt=new Int32Array(256);let Jl;const Kl=[],xp=[],_p=[],Ql=[0,0,0,0,0];let Pp=0,ed=0,td=0,ns={};function BS(e,t,n,i,s,r,o,a,c=!1,l,d,u,f){const{styleState:h,sourceId:g,sourceAttrs:w,tileInfo:p,pixelRatio:y,selectedIds:b,dataFilter:v,floorsEnabled:T,hoverId:E,generateOnlySelectedPoi:S,generateOnlyHoveredPoi:L,modelsPath:x}=s,{data:O}=r,B=new Set(b),U=mg(O);if(U.byteLength<8)return i.getAccumulatedData();ts.length=0;const j=new Sp(U);if(j.readU32()!==1279676242)return i.getAccumulatedData();const I=j.readU16();if(I!==2&&I!==3&&I!==4)return console.error(`Unsupported tile format version: "${I}"`),i.getAccumulatedData();qn=I,j.readU16();const X=xc(y);return US(j),zS(j),GS(qn,e,t,h,n,i,j,p,X,B,v,o,a,T,g,w,c,E,S,L,x,l,d,u,f),i.getAccumulatedData()}function US(e){const t=qn===4?2:1,n=e.u8;let i=e.offset,s=e.u32[i>>2];for(i+=4,Pp=s,ed=i;s--;)i=n[i++]*2+i,i=n[i++]*t+i;e.offset=i+(-i&3)}function zS(e){const t=e.u32[e.offset>>2];e.offset+=4,Jl=Ue(e,Uint8Array,t);const n=Ue(e,Uint32Array,t);for(let i=0;i<t;i++){const s=Jl[i];ts[i]=NS(e,n[i],s),Zt[i]=0}}function GS(e,t,n,i,s,r,o,a,c,l,d,u,f,h,g,w,p=!1,y,b,v,T,E,S,L,x){const O=Array.from(s.featureAttrs);Ts(u,O);const B=Pp,U=Ue(o,Int32Array,B),j=ql(U),M=Ue(o,Uint8Array,j,!0),I=Ue(o,Uint8Array,ql(M),!0),X=Ue(o,Uint8Array,j,!0),A=Ue(o,Uint8Array,ql(X),!0),P=Ue(o,Uint16Array,j,!0);let _=0,C=0,F=0,k=!0;for(let R=0;R<B;R++){const G=U[R];$S(o,u,f);for(let Z=0;Z<G;Z++){const H=M[_];H>0&&(jS(f,H,I,C,u,e,p),C+=H);const Q=X[_];if(Q>0&&(VS(f,Q,A,F),F+=Q),!f[u.tileProps.db_geometry_type]){console.error(`Geometry type not specified for data source ${g}. Metatile version ${u.version}`);return}k=H>0||Q>0;const J=u.tileProps;let N=f[J[L!=null?L:""]];Number.isNaN(N)&&(N=void 0);const W=Cs(i,w,J,f,[],N,a),q=P[_];q>0&&HS(e,t,n,i,W,s,r,q,a,c,l,d,u,h,g,y,b,v,T,E,k,S,x),_++}}Lp()}function jS(e,t,n,i,s,r,o=!1){var a,c;for(;t--;){const l=n[i++],d=xp[l],u=Kl[l],f=Jl[d];if(f===8||f===9||f===19||f===20)e[u]=i0(ts[d][Zt[d]],ts[d][Zt[d]+1]),Zt[d]+=2;else{const h=ts[d][Zt[d]];switch(u){case s.tileProps.objectLength:case s.tileProps.db_centroid_x:case s.tileProps.db_centroid_y:case s.tileProps.componentDistanceEnd:case s.tileProps.componentDistanceStart:case s.tileProps.previousPointX:case s.tileProps.previousPointY:case s.tileProps.nextPointX:case s.tileProps.nextPointY:e[u]=r===2?h*Pi:h;break;case s.tileProps.db_label:e[u]=Yr(h);break;case s.tileProps.db_label2:e[u]=Yr(h);break;case s.tileProps.db_schedule:e[u]=JSON.parse(Yr(h));break;case s.tileProps.db_tiers:const g=h.byteLength/Int32Array.BYTES_PER_ELEMENT,w=new DataView(h.buffer,h.byteOffset,h.byteLength),p=w.getInt32(0,!0);if(g===1&&!p)e[u]=void 0;else{const y=new Array(g);y[0]=p;for(let b=1;b<g;b++)y[b]=w.getInt32(b*Int32Array.BYTES_PER_ELEMENT,!0);e[u]=y}break;default:if(o&&f===11)e[u]=Yr(h);else{const y=s.tilePropsByIndex[u];e[u]=(c=(a=s.reverseDictionaries[y])==null?void 0:a[h])!=null?c:h}}Zt[d]++}}}function VS(e,t,n,i){for(;t--;){const s=n[i++],r=Kl[s];e[r]=NaN}}let qo=[];function HS(e,t,n,i,s,r,o,a,c,l,d,u,f,h,g,w,p,y,b,v=[],T,E,S){var A;const{tileProps:L,defaultProps:x}=f,{tileAttrs:O,featureAttrs:B,id:U}=s,j=c.coords[3],M=L.db_hidden_by_plan_id!==void 0;if(!T&&qo.length===0){for(let P=0;P<td;P++){const _=Ql[P];Zt[_]=Zt[_]+a}return}const I=O[L.db_geometry_type],X=qn===4?f.vertexProps:f.vertexPropsLegacy[I];if(!X){console.error(`Couldn't get vertex keys for tile ${xe(c.coords)} source ${g}. Metatile version ${f.version}`);return}for(let P=0;P<td;P++){const _=qn===4?_p[P]:P,C=Ql[P],F=(A=X[_])!=null?A:"signed_z";ns[F]=YS(kS(ts[C],Zt[C],a),P,e),qn===4&&F==="z"&&(ns.signed_z=ns.z),Zt[C]=Zt[C]+a}if(!(L.db_sublayer!==void 0&&!Number.isNaN(O[L.db_sublayer])&&_o(O[L.db_sublayer]))&&!(M&&i._activeFloorIds&&O[L.db_hidden_by_plan_id]&&i._activeFloorIds.includes(O[L.db_hidden_by_plan_id]))){for(const P in x){const _=x[P];Number.isNaN(O[_.index])&&(O[_.index]=_.value)}if(!(w&&w!==U)){if(U!==void 0){let P=d.has(U);p&&(P=!0);const _=!!y||!!w&&w===U;if(O[L.selected]=P?1:0,O[L.hovered]=_?1:0,v.length>0){const C={};v.forEach(F=>{C[F]=O[L[F]]}),o.addPromotedObjectAttributes(U,C)}h&&j>=Aa.detailLevel&&(O[L.db_hidden_by_plan_building_id]&&o.addFloorHidingMap(U,O[L.db_hidden_by_plan_building_id]),O[L.db_hidden_by_metro_building_id]&&o.addFloorHidingMap(U,O[L.db_hidden_by_metro_building_id]))}else O[L.selected]=0,O[L.hovered]=0;if(r.featureAttrs.size>0){const P=U!==void 0&&r.get(U);if(P)for(const _ of r.featureAttrs)r.clearAttrs=!1,B[L[_]]=P[_];else if(r.clearAttrs===!1){r.clearAttrs=!0;for(const _ in L)B[L[_]]!==void 0&&(B[L[_]]=void 0)}}if(E){const P=WS(ns,I,c);if(P){const _=ZS(s,xe(c.coords));o.addFeature({type:"Feature",properties:_,geometry:P})}return}T&&(qo=n.getLayers(t.id,L,O).filter(P=>$(P.filter,s)&&(u?$(u,s):!0))),qo.length===0&&s.id&&o.idIndexer.addOrphanId(s.id),xl(o,t,qo,s,f,qn,j,g,c,l,ns,p||y,b,S)}}}function $S(e,t,n){const i=Object.keys(t.tileProps).length,s=e.u8;let r,o,a=ed;for(o=1;o<i;o++)n[o]=NaN;for(r=s[a++],o=0;o<r;o++)Kl[o]=s[a++],xp[o]=s[a++];for(r=s[a++],o=0;o<r;o++)qn===4&&(_p[o]=s[a++]),Ql[o]=s[a++];td=r,ed=a,Lp()}function Lp(){ns={}}function YS(e,t,n){if(n===2&&t<3&&e instanceof Uint16Array)for(let i=0;i<e.length;i++)e[i]*=Pi;return e}function WS(e,t,n){var c;const i=[],{x:s,y:r,z:o,signed_z:a}=e;for(let l=0;l<e.x.length;l++){const d=As(s[l],r[l],n),u=oe.scaleFactor(d[1]),f=o?o[l]*32:void 0;d[2]=(c=f!=null?f:a==null?void 0:a[l])!=null?c:0,d[2]/=Ie*u,i.push(d)}if(i.length)switch(t){case"point":return{type:"MultiPoint",coordinates:i};case"polyline":return{type:"LineString",coordinates:i};case"polygon":return{type:"Polygon",coordinates:[i.map((l,d)=>i[ut(d,i.length)])]};default:return}}function ZS(e,t){const n={tile:t};return Object.keys(e.tileProps).forEach(i=>{const s=e.tileAttrs[e.tileProps[i]];!Number.isNaN(s)&&s!==void 0&&(n[i]=s)}),n}const XS=e=>{if(e.length>2){let t=0;for(let n=e.length-1,i=n,s=0;s<=n;s++){const r=e[i],o=e[s];t+=(r[0]+o[0])*(r[1]-o[1]),i=s}return t/2}else return 0},qS=e=>XS(e)>0;function JS(e){e=e.slice().sort(KS);const t=e.length,n=new Array(t*2);let i=0;for(let r=0;r<t;r++){const o=e[r];for(;i>=2&&Dp(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}const s=i+1;for(let r=t-2;r>=0;r--){const o=e[r];for(;i>=s&&Dp(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}return n.slice(0,i-1)}function Dp(e,t,n){return(t[1]-e[1])*(n[0]-e[0])-(t[0]-e[0])*(n[1]-e[1])}function KS(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function QS(e){const t=[],n=qS(e),i=Ir(e[0],e[e.length-1]),s=i?e.length-1:e.length;for(let r=s-1,o=0,a=1;o<s;o++,r=o-1,a=(o+1)%s){const c=[];vy(c,e[r],e[o],e[a],n),t.push(c)}return i&&t.push(t[0]),t}const Jo=[[0],[0],[0]],Op=[];function eA(e,t,n,i,s,r,o,a,c){const{matrix:l,offset:d,id:u,selected:f}=r,h=new Sp(s),g=[];if(!e)return{objects:i.getAccumulatedData(),textures:g};if(h.readU32()!==1296191066||h.readU16()!==1)return{objects:i.getAccumulatedData(),textures:[]};h.readU16();const w=h.readU32();for(let x=0;x<w;x++)g.push(h.readU8Vector());const{tileProps:p}=o,y=[],b=Object.keys(p).length;for(let x=0;x<b;x++)y[x]=NaN;if(y[p.db_sublayer]="Building_model",y[p.selected]=f?1:0,y[p.db_region]=a,c.featureAttrs.size>0){const x=Array.from(c.featureAttrs);Ts(o,x)}const v=[],T=typeof u!="number"&&c.get(u);if(T)for(const x of c.featureAttrs)c.clearAttrs=!1,v[p[x]]=T[x];else if(c.clearAttrs===!1){c.clearAttrs=!0;for(const x in p)v[p[x]]!==void 0&&(v[p[x]]=void 0)}const E=h.offset,S=Cs(n,Qa,p,y,v,u),L=t.getLayers(e.id,p,y).filter(x=>$(x.filter,S));return L.length===0&&S.id&&i.idIndexer.addOrphanId(S.id),L.forEach(x=>{x.type!=="buildingModel"||(El(x,S),!$(x.filter,S))||(h.offset=E,tA(e,x,S,i,h,l,d))}),{objects:i.getAccumulatedData(),textures:g}}function tA(e,t,n,i,s,r,o){const a=s.readU32();for(let c=0;c<a;c++){const l=s.readU32(),d=at(s.readF32(),s.readF32(),s.readF32()),u=at(s.readF32(),s.readF32(),s.readF32()),f=Jt(yt(),u,d),h=[];mu(h,r,d),Fi(h,h,f),h[12]+=o[0],h[13]+=o[1];const g=s.readU16Vector(5),w=s.readU32();for(let v=0;v<w;v++){const T=s.readU32()===1?$m:pr,E=s.readU16Vector();do wn.processSubmesh(e.id,t,n,i,g,E,T,l,h);while(i.isOverloaded())}const p=s.readU16Vector();do wn.processOuterEdge(e.id,t,n,i,g,p,h);while(i.isOverloaded());const y=JS(nA(g)),b=QS(y);for(let v=0;v<y.length-2;v++){for(let T=0;T<3;T++){const E=iA(v+T,y.length);Jo[0][T]=y[E][0],Jo[1][T]=y[E][1],Jo[2][T]=0,Op[T]=b[E]}do Ct.generateFloorsBottomFill(i,e.id,Jo,Op,so,h);while(i.isOverloaded())}}}function nA(e){const t=[];for(let n=0;n<e.length;n+=5)t.push([e[n],e[n+1]]);return t}function iA(e,t){return e===0?0:e%2?(e+1)/2:t-e/2}function sA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nd={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */nd.read=function(e,t,n,i,s){var r,o,a=s*8-i-1,c=(1<<a)-1,l=c>>1,d=-7,u=n?s-1:0,f=n?-1:1,h=e[t+u];for(u+=f,r=h&(1<<-d)-1,h>>=-d,d+=a;d>0;r=r*256+e[t+u],u+=f,d-=8);for(o=r&(1<<-d)-1,r>>=-d,d+=i;d>0;o=o*256+e[t+u],u+=f,d-=8);if(r===0)r=1-l;else{if(r===c)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,i),r=r-l}return(h?-1:1)*o*Math.pow(2,r-i)},nd.write=function(e,t,n,i,s,r){var o,a,c,l=r*8-s-1,d=(1<<l)-1,u=d>>1,f=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:r-1,g=i?1:-1,w=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=d):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+u>=1?t+=f/c:t+=f*Math.pow(2,1-u),t*c>=2&&(o++,c/=2),o+u>=d?(a=0,o=d):o+u>=1?(a=(t*c-1)*Math.pow(2,s),o=o+u):(a=t*Math.pow(2,u-1)*Math.pow(2,s),o=0));s>=8;e[n+h]=a&255,h+=g,a/=256,s-=8);for(o=o<<s|a,l+=s;l>0;e[n+h]=o&255,h+=g,o/=256,l-=8);e[n+h-g]|=w*128};var rA=we,Ko=nd;function we(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}we.Varint=0,we.Fixed64=1,we.Bytes=2,we.Fixed32=5;var id=65536*65536,Fp=1/id,oA=12,Cp=typeof TextDecoder>"u"?null:new TextDecoder("utf8");we.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var i=this.readVarint(),s=i>>3,r=this.pos;this.type=i&7,e(s,t,this),this.pos===r&&this.skip(i)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Qo(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Np(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Qo(this.buf,this.pos)+Qo(this.buf,this.pos+4)*id;return this.pos+=8,e},readSFixed64:function(){var e=Qo(this.buf,this.pos)+Np(this.buf,this.pos+4)*id;return this.pos+=8,e},readFloat:function(){var e=Ko.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Ko.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,i;return i=t[this.pos++],n=i&127,i<128||(i=t[this.pos++],n|=(i&127)<<7,i<128)||(i=t[this.pos++],n|=(i&127)<<14,i<128)||(i=t[this.pos++],n|=(i&127)<<21,i<128)?n:(i=t[this.pos],n|=(i&15)<<28,aA(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=oA&&Cp?MA(this.buf,t,e):IA(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==we.Bytes)return e.push(this.readVarint(t));var n=An(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==we.Bytes)return e.push(this.readSVarint());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==we.Bytes)return e.push(this.readBoolean());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==we.Bytes)return e.push(this.readFloat());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==we.Bytes)return e.push(this.readDouble());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==we.Bytes)return e.push(this.readFixed32());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==we.Bytes)return e.push(this.readSFixed32());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==we.Bytes)return e.push(this.readFixed64());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==we.Bytes)return e.push(this.readSFixed64());var t=An(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===we.Varint)for(;this.buf[this.pos++]>127;);else if(t===we.Bytes)this.pos=this.readVarint()+this.pos;else if(t===we.Fixed32)this.pos+=4;else if(t===we.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),is(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),is(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),is(this.buf,e&-1,this.pos),is(this.buf,Math.floor(e*Fp),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),is(this.buf,e&-1,this.pos),is(this.buf,Math.floor(e*Fp),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){lA(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(!!e)},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=TA(this.buf,e,this.pos);var n=this.pos-t;n>=128&&Rp(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),Ko.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Ko.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var i=this.pos-n;i>=128&&Rp(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,we.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,fA,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,hA,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,yA,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,pA,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,mA,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,gA,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,wA,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,vA,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,bA,t)},writeBytesField:function(e,t){this.writeTag(e,we.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,we.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,we.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,we.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,we.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,we.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,we.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,we.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,we.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,we.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,!!t)}};function aA(e,t,n){var i=n.buf,s,r;if(r=i[n.pos++],s=(r&112)>>4,r<128||(r=i[n.pos++],s|=(r&127)<<3,r<128)||(r=i[n.pos++],s|=(r&127)<<10,r<128)||(r=i[n.pos++],s|=(r&127)<<17,r<128)||(r=i[n.pos++],s|=(r&127)<<24,r<128)||(r=i[n.pos++],s|=(r&1)<<31,r<128))return cA(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function An(e){return e.type===we.Bytes?e.readVarint()+e.pos:e.pos+1}function cA(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function lA(e,t){var n,i;if(e>=0?(n=e%4294967296|0,i=e/4294967296|0):(n=~(-e%4294967296),i=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,i=i+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),dA(n,i,t),uA(i,t)}function dA(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function uA(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function Rp(e,t,n){var i=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(i);for(var s=n.pos-1;s>=e;s--)n.buf[s+i]=n.buf[s]}function fA(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function hA(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function pA(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function mA(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function yA(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function gA(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function wA(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function vA(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function bA(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function Qo(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function is(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Np(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function IA(e,t,n){for(var i="",s=t;s<n;){var r=e[s],o=null,a=r>239?4:r>223?3:r>191?2:1;if(s+a>n)break;var c,l,d;a===1?r<128&&(o=r):a===2?(c=e[s+1],(c&192)===128&&(o=(r&31)<<6|c&63,o<=127&&(o=null))):a===3?(c=e[s+1],l=e[s+2],(c&192)===128&&(l&192)===128&&(o=(r&15)<<12|(c&63)<<6|l&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(c=e[s+1],l=e[s+2],d=e[s+3],(c&192)===128&&(l&192)===128&&(d&192)===128&&(o=(r&15)<<18|(c&63)<<12|(l&63)<<6|d&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),s+=a}return i}function MA(e,t,n){return Cp.decode(e.subarray(t,n))}function TA(e,t,n){for(var i=0,s,r;i<t.length;i++){if(s=t.charCodeAt(i),s>55295&&s<57344)if(r)if(s<56320){e[n++]=239,e[n++]=191,e[n++]=189,r=s;continue}else s=r-55296<<10|s-56320|65536,r=null;else{s>56319||i+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):r=s;continue}else r&&(e[n++]=239,e[n++]=191,e[n++]=189,r=null);s<128?e[n++]=s:(s<2048?e[n++]=s>>6|192:(s<65536?e[n++]=s>>12|224:(e[n++]=s>>18|240,e[n++]=s>>12&63|128),e[n++]=s>>6&63|128),e[n++]=s&63|128)}return n}const SA=sA(rA),AA=1,sd={1:({pbf:e})=>e.readBoolean(),2:({pbf:e})=>e.readDouble(),3:({pbf:e})=>e.readString(),5:e=>{const{pbf:t}=e,n=t.readVarint(),i=new Array(n);for(let s=0;s<n;s++)i[s]=rd(e,t.readVarint());return i},4:e=>{const{pbf:t}=e,n=t.readVarint(),i={};for(let r=0;r<n;r++){var s=t.readVarint();i[e.keys[s>>3]]=rd(e,s&7)}return i},6:e=>null};function rd(e,t){const n=e.pbf;if(n.pos<n.length){const i=sd[t];if(!i)throw new Error(`Type ${t} is not supported`);return i(e)}}function kp(e){const t=e.readVarint(),n=[];for(let i=0;i<t;i++){const s=e.readString(),r=e.readVarint();n.push({key:s,type:r})}return n}function EA(e,t){if(!e||!e.byteLength||e.byteLength<4)throw new Error("Bad array or insufficient array length.");const n=new SA(e),i=n.readFixed32(),s=i>>24&255;if(s>AA)throw new Error(`Version ${s} is not supported`);const r=i>>16&255,o=r;if(r===1&&o!==1)throw new Error("Packed with PackMethod.Generic cannot be unpacked with anything than UnpackMethod.Generic");switch(o){case 1:const a=n.readFixed32();if(a>=e.byteLength)return;const c=n.pos;n.pos=a;const l=n.readVarint(),d=new Array(l);for(let f=0;f<l;f++)d[f]=n.readString();n.pos=c;const u=n.readVarint();return rd({keys:d,pbf:n},u);case 2:{const f={keys:[],pbf:n},h=n.readFixed32(),g=kp(n),w={};for(const{key:p,type:y}of g){const b=sd[y],v=[];for(let T=0;T<h;T++)v.push(b(f));w[p]=v}return w}case 3:{const f={keys:[],pbf:n},h=n.readFixed32(),g=kp(n),w=new Array(h);for(let p=0;p<h;p++)w[p]={};for(const{key:p,type:y}of g){const b=sd[y];for(let v=0;v<h;v++)w[v][p]=b(f)}return w}default:throw new Error(`Method ${o} is not supported`)}}function Bp(e){const t=new Zl;if(e instanceof ArrayBuffer){const s=EA(e);if(Array.isArray(s))for(const n of s){const i=n,{id:r}=i,o=km(i,["id"]);t.set(r,o)}else for(const r in s)t.set(r,s[r])}else for(const s in e)t.set(s,e[s]);return t}class xA{constructor(t){this.scope=t,this.tileLoader=new OS,this.tileAttrs=[],this.models={},this.featureStateMap=new Zl}fetchTiles(t,n=3){const i=[];for(const s of t)i.push(this.tileLoader.fetch(s,n));return i}abortTileRequests(t){t.forEach(n=>this.tileLoader.abortRequest(n))}generateTile(t,n){const{styleManager:i,collector:s,metatiles:r}=this.scope,{tileInfo:o,promoteAttributes:a,promoteId:c,isCustomZenithSource:l,modelShowHideEventsSublayers:d}=t,u=xe(o.coords),f=this.tileLoader.get(u),h=[],g=[],w=[],p={};return f.forEach(y=>{var S;const{regionId:b,metatileHash:v}=y,T=this.scope.styleManager.getStyle(t.styleId);if(!T)return;if(t.areTileBoundsVisible&&t.isDefaultSource){const x=i.getStyle(Uo).layers.find(O=>O.id==="debug-tile-bounds");x0(s,x,t.styleState)}const E=BS(T,i,this.featureStateMap,s,t,y,r[v],this.tileAttrs,l,a,n,c,d);Object.assign(p,E.promotedObjectAttributes),h.push({regionId:b,metatileHash:v,collectorOutput:E,styleId:T.id}),w.push(...E.transferable),(S=E.debugGeoJsonData)==null||S.forEach(L=>g.push(L))}),this.scope.resetCollector(),this.scope.syncRasterSets(),Promise.resolve({results:h,transferable:w,promotedAttrs:Object.keys(p).length>0?p:void 0,geoJsonData:n?g:void 0})}deleteTiles(t){for(const n of t)this.tileLoader.delete(n)}setFeatureStateMap(t){this.featureStateMap=Bp(t)}generateModel(t){const{regionId:n,metatileHash:i,styleId:s,url:r,id:o}=t,{styleManager:a}=this.scope;return new Promise(c=>{const l=this.models[o];(l?Promise.resolve(l):new Promise(u=>{Zo({url:r},(f,h)=>{if(f||h.byteLength===0){const g=this.models[o]=new ArrayBuffer(0);u(g)}else this.models[o]=h,u(h)})})).then(u=>{if(u.byteLength===0){c({objects:this.scope.collector.getAccumulatedData(),textures:{isBitmap:!1,data:[]}});return}const f=this.scope.styleManager.getStyle(s);if(!f){c({objects:this.scope.collector.getAccumulatedData(),textures:{isBitmap:!1,data:[]}});return}const{objects:h,textures:g}=eA(f,a,t.styleState,this.scope.collector,u,t,this.scope.metatiles[i],n,this.featureStateMap);if(this.scope.createImageBitmap){const w=g.map(p=>{const y=new Blob([p],{type:"image/png"});return createImageBitmap(y)});Promise.all(w).then(p=>{c({objects:h,textures:{isBitmap:!0,data:p},transferable:[...h.transferable,...p]}),this.scope.resetCollector()})}else c({objects:h,textures:{isBitmap:!1,data:g},transferable:[...h.transferable,u]}),this.scope.resetCollector()})})}destroy(){this.tileLoader.destroy(),this.tileAttrs=[],this.models={}}}function _A(e,t){let n=!1,i;function s(){n=!1,i&&(r(...i),i=!1)}function r(...o){n?i=o:(e(...o),setTimeout(s,t),n=!0)}return r}const ea=.8;class PA{constructor(t,n){this.offset=0,this.stride=n,this.buffer=new ArrayBuffer(t),this.view=new Int32Array(this.buffer),this.comittedOffsets=0,this.maximum=t/n,this.watermark=this.maximum*ea}extend(){const t=this.buffer.byteLength*2;this.maximum=t/this.stride,this.watermark=this.maximum*ea;const n=new ArrayBuffer(t),i=new Int32Array(n);return i.set(this.view),this.buffer=n,this.view=i,n}}class LA{constructor(t){this.offset=0,this.buffer=new Int32Array(t),this.comittedOffsets=0,this.watermark=t*ea}extend(){const t=this.buffer.length*2;this.watermark=t*ea;const n=new Int32Array(t);n.set(this.buffer),this.buffer=n}}class Up{constructor(t,n,i,s,r,o){this.objectsData={},this.extents=new Float32Array([1/0,1/0,1/0,-1/0,-1/0,-1/0]),this.maxDiag=0,this.drawMode=r;const a=t!=="buildingModel"?67200:67200*5,c=rr(t,n);this.elements=new PA(a,c),this.indices=new LA(a*2/c),this.views={},this.binder=s,s(this,this.elements.buffer),this.attributes=i,this.key=o}static generateKey(t){return JSON.stringify(t)}resetOffsets(){this.elements.offset=0,this.elements.comittedOffsets=0,this.indices.offset=0,this.indices.comittedOffsets=0}resetBuildingsData(){this.objectsData={}}resetInstancesExtents(){this.extents[0]=1/0,this.extents[1]=1/0,this.extents[2]=1/0,this.extents[3]=-1/0,this.extents[4]=-1/0,this.extents[5]=-1/0,this.maxDiag=0}commit(){this.elements.comittedOffsets=this.elements.offset,this.indices.comittedOffsets=this.indices.offset}rollback(){this.elements.offset=this.elements.comittedOffsets,this.indices.offset=this.indices.comittedOffsets}checkWatermarks(){let t=0;const n=this.elements;n.offset>n.watermark&&(n.offset>=n.buffer.byteLength/n.stride&&(t=1),this.binder(this,n.extend()));const i=this.indices;return i.offset>i.watermark&&(i.offset>=i.buffer.length&&(t=1),i.extend()),t}}function wt(e,t,n){n=n||{},this.w=e||64,this.h=t||64,this.autoResize=!!n.autoResize,this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0}wt.prototype.pack=function(e,t){e=[].concat(e),t=t||{};for(var n=[],i,s,r,o,a=0;a<e.length;a++)if(i=e[a].w||e[a].width,s=e[a].h||e[a].height,r=e[a].id,i&&s){if(o=this.packOne(i,s,r),!o)continue;t.inPlace&&(e[a].x=o.x,e[a].y=o.y,e[a].id=o.id),n.push(o)}return this.shrink(),n},wt.prototype.packOne=function(e,t,n){var i={freebin:-1,shelf:-1,waste:1/0},s=0,r,o,a,c;if(typeof n=="string"||typeof n=="number"){if(r=this.getBin(n),r)return this.ref(r),r;typeof n=="number"&&(this.maxId=Math.max(n,this.maxId))}else n=++this.maxId;for(c=0;c<this.freebins.length;c++){if(r=this.freebins[c],t===r.maxh&&e===r.maxw)return this.allocFreebin(c,e,t,n);t>r.maxh||e>r.maxw||t<=r.maxh&&e<=r.maxw&&(a=r.maxw*r.maxh-e*t,a<i.waste&&(i.waste=a,i.freebin=c))}for(c=0;c<this.shelves.length;c++)if(o=this.shelves[c],s+=o.h,!(e>o.free)){if(t===o.h)return this.allocShelf(c,e,t,n);t>o.h||t<o.h&&(a=(o.h-t)*e,a<i.waste&&(i.freebin=-1,i.waste=a,i.shelf=c))}if(i.freebin!==-1)return this.allocFreebin(i.freebin,e,t,n);if(i.shelf!==-1)return this.allocShelf(i.shelf,e,t,n);if(t<=this.h-s&&e<=this.w)return o=new od(s,this.w,t),this.allocShelf(this.shelves.push(o)-1,e,t,n);if(this.autoResize){var l,d,u,f;return l=d=this.h,u=f=this.w,(u<=l||e>u)&&(f=Math.max(e,u)*2),(l<u||t>l)&&(d=Math.max(t,l)*2),this.resize(f,d),this.packOne(e,t,n)}return null},wt.prototype.allocFreebin=function(e,t,n,i){var s=this.freebins.splice(e,1)[0];return s.id=i,s.w=t,s.h=n,s.refcount=0,this.bins[i]=s,this.ref(s),s},wt.prototype.allocShelf=function(e,t,n,i){var s=this.shelves[e],r=s.alloc(t,n,i);return this.bins[i]=r,this.ref(r),r},wt.prototype.shrink=function(){if(this.shelves.length>0){for(var e=0,t=0,n=0;n<this.shelves.length;n++){var i=this.shelves[n];t+=i.h,e=Math.max(i.w-i.free,e)}this.resize(e,t)}},wt.prototype.getBin=function(e){return this.bins[e]},wt.prototype.ref=function(e){if(++e.refcount===1){var t=e.h;this.stats[t]=(this.stats[t]|0)+1}return e.refcount},wt.prototype.unref=function(e){return e.refcount===0?0:(--e.refcount===0&&(this.stats[e.h]--,delete this.bins[e.id],this.freebins.push(e)),e.refcount)},wt.prototype.clear=function(){this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0},wt.prototype.resize=function(e,t){this.w=e,this.h=t;for(var n=0;n<this.shelves.length;n++)this.shelves[n].resize(e);return!0};function od(e,t,n){this.x=0,this.y=e,this.w=this.free=t,this.h=n}od.prototype.alloc=function(e,t,n){if(e>this.free||t>this.h)return null;var i=this.x;return this.x+=e,this.free-=e,new DA(n,i,this.y,e,t,e,this.h)},od.prototype.resize=function(e){return this.free+=e-this.w,this.w=e,!0};function DA(e,t,n,i,s,r,o){this.id=e,this.x=t,this.y=n,this.w=i,this.h=s,this.maxw=r||i,this.maxh=o||s,this.refcount=0}class OA{constructor(){this.packer=new wt(cn[0],cn[1]),this.currentAtlasIndex=0,this.packedRasters=[],this.rastersToLoad=[],this.newRasterSets=new Map}addNewRasterSet(t,n){let i=this.newRasterSets.get(t);i||(i=[],this.newRasterSets.set(t,i)),i.push(n)}pack(t,n,i){t.isSvg?this.packSvg(t,n.map(s=>({w:s,h:s})),i):this.packPng(t,n.map(s=>({w:s,h:s})),i)}packSvg(t,n,i){const{rasters:s}=t,r=new Set;for(const{w:o,h:a}of s)r.add(`${o}_${a}`);for(const o of n){const a=o.w*i,c=o.h*i;if(r.has(`${a}_${c}`))continue;let l=this.packer.packOne(a+2,c+2);l===null&&(this.packer=new wt(cn[0],cn[1]),this.currentAtlasIndex++,l=this.packer.packOne(a+2,c+2));const d=s.length,u={rasterSetIndex:t.index,rasterIndex:d,w:a,h:c,x:l.x+1,y:l.y+1,anchorX:t.anchorX,anchorY:t.anchorY,atlasIndex:this.currentAtlasIndex,isPacked:!0};s.push(u),this.packedRasters.push(t.index,d,u.x,u.y,u.w,u.h,this.currentAtlasIndex)}}addRastersToLoad(t,n){this.rastersToLoad.push(t,n.rasterSetIndex,n.rasterIndex)}getNewRasterSets(){const t=this.newRasterSets;return this.newRasterSets=new Map,t}getPackedRasters(){if(this.packedRasters.length===0)return;const t=new Uint16Array(this.packedRasters);return this.packedRasters=[],t}getRastersToLoad(){const t=new Float64Array(this.rastersToLoad);return this.rastersToLoad=[],t}packPng(t,n,i){const{rasters:s}=t,r=new Set;for(const{w:o,h:a}of s)r.add(`${o}_${a}`);for(const o of n){if(r.has(`${o.w}_${o.h}`)&&t.type===bi.Static)continue;const a=o.w*i,c=o.h*i;let l=Xs(s,a,!1),d;if(l===void 0)l=s.length,d={rasterSetIndex:t.index,rasterIndex:l,w:a,h:c,x:0,y:0,anchorX:0,anchorY:0,atlasIndex:this.currentAtlasIndex,isPacked:!1},s.push(d);else if(d=t.rasters[l],d.isPacked)continue;let u=this.packer.packOne(d.w+2,d.h+2);u===null&&(this.packer=new wt(cn[0],cn[1]),this.currentAtlasIndex++,u=this.packer.packOne(d.w+2,d.h+2)),d.x=u.x+1,d.y=u.y+1,d.atlasIndex=this.currentAtlasIndex,d.isPacked=!0,this.packedRasters.push(t.index,l,d.x,d.y,d.w,d.h,this.currentAtlasIndex)}}}const FA=re(2,32)-2,CA=uu(re(2,32)-1),RA=uu(re(2,32)-2);class NA{constructor(){this.colorById=new Map,this.index=0}getIndex(t){if(!t)return this.nextIndex();const n=this.colorById.get(t);if(n!==void 0)return n;const i=this.nextIndex();return this.colorById.set(t,i),i}nextIndex(){return++this.index%FA}}const zp=re(2,20),Gp=["main","parser","labeling","models"],ad={};for(let e=0;e<Gp.length;e++){const t=Gp[e];ad[t]={min:1+e*zp,max:(e+1)*zp}}class kA{constructor(t){this.atlasPacker=new OA,this.pointIndexer=new NA,this.floorHidingMap=new Map,this.usedModels=new Set,this.dataModels={},this.promotedObjectAttributes={},this.addedBuckets=[],this.labels=[],this.idIndexer=new sb(t),this.workerName=t,this.dataModelsIndex=ad[t].min,this.buckets={},this.geoJsonData=[],this.reset()}reset(){this.buckets={},this.geoJsonData=[],this.addedBuckets=[],this.floorHidingMap.clear(),this.labels=[],this.usedModels.clear()}getStatsAfterReset(){return{buckets:Object.keys(this.buckets).length,geoJsonData:this.geoJsonData.length,addedBuckets:this.addedBuckets.length,floorHidingMap:this.floorHidingMap.size,labels:this.labels.length,usedModels:this.usedModels.size}}addLabel(t){this.labels.push(t)}addUsedModel(t){this.usedModels.add(t)}getIndexerStats(){return this.idIndexer.getIndexerStats()}getBucketsMemoryFootprint(){return Object.keys(this.buckets).map(t=>{const n=t,i=this.buckets[n];return i?{[t]:Object.keys(i).map(s=>{const r=i[s];if(r&&typeof r=="object"){const o=Object.keys(r).map(a=>{const c=r[a];if(c&&c.elements&&c.elements.buffer)return{elementsBuffer:c.elements.buffer.byteLength,indices:c.indices.buffer.byteLength}});return{[s]:o}}return{[s]:0}})}:{[t]:[]}})}addPromotedObjectAttributes(t,n){this.promotedObjectAttributes[t]=n}addFeature(t){this.geoJsonData.push(t)}addUsedModelByUrl(t){const n=this.dataModels[t];if(n!==void 0)return n;const{min:i,max:s}=ad[this.workerName];this.dataModelsIndex=i+(this.dataModelsIndex+1-i)%(s-i);const r=-this.dataModelsIndex;return this.dataModels[t]=r,r}getDataModelsUrls(){const t={};for(const n in this.dataModels)this.usedModels.has(this.dataModels[n])&&(t[n]=this.dataModels[n]);return t}getBucket(t,n,i,s,r=pr){let o=this.buckets[t];o===void 0&&(o={},this.buckets[t]=o);let a=o[n];a===void 0&&(a=o[n]={});const c=Up.generateKey(i),l=a[c];if(l)return this.addedBuckets.push(l),l;const d=new Up(t,n,i,s,r,c);return a[c]=d,this.addedBuckets.push(d),d}isOverloaded(){const t=this.addedBuckets;let n=0,i=0;for(;i<t.length;)n=n+t[i++].checkWatermarks();const s=n>0;if(s)for(;i--;)t[i].rollback();else for(;i--;)t[i].commit();return t.length=0,s}addFloorHidingMap(t,n){let i=this.floorHidingMap.get(n);i===void 0&&(i=[],this.floorHidingMap.set(n,i)),i.push(t)}getAccumulatedData(){const t=this.buckets,n=[],i=[];for(const f in t){const h=f,g=t[h];for(const w in g){const p=w,y=g[p],b=rr(h,p)/4;let v=0;for(const L in y)v+=y[L].indices.offset;if(v===0)continue;const T=[],E=new Int32Array(v*b);let S=0;for(const L in y){const x=y[L],{elements:O,indices:B,attributes:U,meta:j,objectsData:M,extents:I,maxDiag:X}=x,{view:A}=O,{buffer:P}=B;if(O.offset===0)continue;const _=S,C={};for(let F=0;F<B.offset;F++){const k=M?M[F]:null;if(k){const G=S/b;BA(k,G,C)}const R=P[F]*b;for(let G=0;G<b;G++)E[S++]=A[R+G]}T.push({attributes:U,drawMode:x.drawMode,rangeStart:_*4,rangeEnd:S*4,meta:j,objectsData:Object.keys(C).length>0?C:void 0,extents:new Float32Array(I),maxDiag:X}),x.resetOffsets(),x.resetBuildingsData(),x.resetInstancesExtents(),x.meta=void 0}n.push({symbol:h,sink:p,buffer:E.buffer,generatedObjects:T}),i.push(E.buffer)}}const s=this.idIndexer.getPacked();i.push(s.centerBuffer),i.push(s.instanceIdBuffer),i.push(s.layerIdBuffer),i.push(s.objectClassBuffer),i.push(s.phaseBuffer),i.push(s.styleIdBuffer),i.push(s.sublayerBuffer);const r=this.atlasPacker.getPackedRasters();r!==void 0&&i.push(r.buffer);const o=this.atlasPacker.getRastersToLoad();i.push(o.buffer);const a=this.getDataModelsUrls();this.usedModels=new Set;const c=this.floorHidingMap;this.floorHidingMap=new Map;const l=this.labels;this.labels=[];const d=this.promotedObjectAttributes;this.promotedObjectAttributes={};const u=this.geoJsonData.length?this.geoJsonData:void 0;return this.geoJsonData=[],{data:n,labels:l,floorHidingMap:c,packedRasters:r,rastersToLoad:o,dataModelsUrls:a,identifyIds:s,transferable:i,promotedObjectAttributes:d,debugGeoJsonData:u}}}function BA(e,t,n){const i=e.objectId;n[i]||(n[i]=[]);let s=!1;for(const r of n[i]){const o=r.offset+r.size,a=t+e.size;(r.offset<=t&&o>=t||t<=r.offset&&a>=r.offset)&&(r.offset=Math.min(t,r.offset),r.size=Math.max(o,a)-r.offset,s=!0)}s||n[i].push({offset:t,size:e.size})}const UA={[Fs.none]:{ambientColorIntensity:new Float32Array([1,1,1,0]),dir1ColorIntensity:new Float32Array([1,1,1,0]),dir1Direction:new Float32Array([0,-1,0]),dir2ColorIntensity:new Float32Array([1,1,1,0]),dir2Direction:new Float32Array([0,-1,0]),shadowLightIndex:-1,shadowRadius:1}},zA=2;class cd{constructor(t,n=!1){this.dataType=t,this.pendingRequests=new Map,this.ignoredStatusCodes=n?[204,404]:[204]}fetch(t,n,i=3,s=300){return Le(this,null,function*(){var o;let r=0;for(;r<=i;)try{const a=yield this.fetchAttempt(t,n);if(!a.error||!Ip((o=a.error)==null?void 0:o.status))return a;throw new Error(`Fetching ${t} attempt ${r} failed.`)}catch(a){if(r>=i)return{rejected:!0};yield Mp(Math.pow(2,r)*s),r++}return{rejected:!0}})}destroy(){const t=Array.from(this.pendingRequests.keys());this.abortRequests(t)}abortRequests(t){for(const n of t){const i=this.pendingRequests.get(n);if(i===void 0)return;i.xhr.abort(),i.resolve({rejected:!0}),this.pendingRequests.delete(n)}}fetchAttempt(t,n){return new Promise(i=>{const s=n(t),r=xe(t),a=(this.dataType==="json"?bp:Zo)({url:s},(c,l)=>{if(this.pendingRequests.delete(r),c!==void 0){this.ignoredStatusCodes.includes(c.status)||console.error(`Failed to fetch a tile by url "${s}" Error: status "${c.status}", message: ${c.message}`),i({error:c});return}i({data:l})});this.pendingRequests.set(r,{xhr:a,resolve:i})})}}/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */const jp=Symbol("Comlink.proxy"),GA=Symbol("Comlink.endpoint"),jA=Symbol("Comlink.releaseProxy"),ld=Symbol("Comlink.finalizer"),ta=Symbol("Comlink.thrown"),Vp=e=>typeof e=="object"&&e!==null||typeof e=="function",VA={canHandle:e=>Vp(e)&&e[jp],serialize(e){const{port1:t,port2:n}=new MessageChannel;return dd(e,t),[n,[n]]},deserialize(e){return e.start(),Yp(e)}},HA={canHandle:e=>Vp(e)&&ta in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},Hp=new Map([["proxy",VA],["throw",HA]]);function $A(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function dd(e,t=globalThis,n=["*"]){t.addEventListener("message",function i(s){if(!s||!s.data)return;if(!$A(n,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:r,type:o,path:a}=Object.assign({path:[]},s.data),c=(s.data.argumentList||[]).map(Ei);let l;try{const d=a.slice(0,-1).reduce((f,h)=>f[h],e),u=a.reduce((f,h)=>f[h],e);switch(o){case"GET":l=u;break;case"SET":d[a.slice(-1)[0]]=Ei(s.data.value),l=!0;break;case"APPLY":l=u.apply(d,c);break;case"CONSTRUCT":{const f=new u(...c);l=Jp(f)}break;case"ENDPOINT":{const{port1:f,port2:h}=new MessageChannel;dd(e,h),l=qp(f,[f])}break;case"RELEASE":l=void 0;break;default:return}}catch(d){l={value:d,[ta]:0}}Promise.resolve(l).catch(d=>({value:d,[ta]:0})).then(d=>{const[u,f]=ra(d);t.postMessage(Object.assign(Object.assign({},u),{id:r}),f),o==="RELEASE"&&(t.removeEventListener("message",i),$p(t),ld in e&&typeof e[ld]=="function"&&e[ld]())}).catch(d=>{const[u,f]=ra({value:new TypeError("Unserializable return value"),[ta]:0});t.postMessage(Object.assign(Object.assign({},u),{id:r}),f)})}),t.start&&t.start()}function YA(e){return e.constructor.name==="MessagePort"}function $p(e){YA(e)&&e.close()}function Yp(e,t){const n=new Map;return e.addEventListener("message",function(s){const{data:r}=s;if(!r||!r.id)return;const o=n.get(r.id);if(o)try{o(r)}finally{n.delete(r.id)}}),ud(e,n,[],t)}function na(e){if(e)throw new Error("Proxy has been released and is not useable")}function Wp(e){return ss(e,new Map,{type:"RELEASE"}).then(()=>{$p(e)})}const ia=new WeakMap,sa="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(ia.get(e)||0)-1;ia.set(e,t),t===0&&Wp(e)});function WA(e,t){const n=(ia.get(t)||0)+1;ia.set(t,n),sa&&sa.register(e,t,e)}function ZA(e){sa&&sa.unregister(e)}function ud(e,t,n=[],i=function(){}){let s=!1;const r=new Proxy(i,{get(o,a){if(na(s),a===jA)return()=>{ZA(r),Wp(e),t.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>r};const c=ss(e,t,{type:"GET",path:n.map(l=>l.toString())}).then(Ei);return c.then.bind(c)}return ud(e,t,[...n,a])},set(o,a,c){na(s);const[l,d]=ra(c);return ss(e,t,{type:"SET",path:[...n,a].map(u=>u.toString()),value:l},d).then(Ei)},apply(o,a,c){na(s);const l=n[n.length-1];if(l===GA)return ss(e,t,{type:"ENDPOINT"}).then(Ei);if(l==="bind")return ud(e,t,n.slice(0,-1));const[d,u]=Zp(c);return ss(e,t,{type:"APPLY",path:n.map(f=>f.toString()),argumentList:d},u).then(Ei)},construct(o,a){na(s);const[c,l]=Zp(a);return ss(e,t,{type:"CONSTRUCT",path:n.map(d=>d.toString()),argumentList:c},l).then(Ei)}});return WA(r,e),r}function XA(e){return Array.prototype.concat.apply([],e)}function Zp(e){const t=e.map(ra);return[t.map(n=>n[0]),XA(t.map(n=>n[1]))]}const Xp=new WeakMap;function qp(e,t){return Xp.set(e,t),e}function Jp(e){return Object.assign(e,{[jp]:!0})}function ra(e){for(const[t,n]of Hp)if(n.canHandle(e)){const[i,s]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},s]}return[{type:"RAW",value:e},Xp.get(e)||[]]}function Ei(e){switch(e.type){case"HANDLER":return Hp.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ss(e,t,n,i){return new Promise(s=>{const r=qA();t.set(r,s),e.start&&e.start(),e.postMessage(Object.assign({id:r},n),i)})}function qA(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Jn=(e=>(e[e.Main=0]="Main",e[e.Parser=1]="Parser",e[e.Labeling=2]="Labeling",e[e.Models=3]="Models",e[e.All=4]="All",e))(Jn||{}),lr=(e=>(e[e.FunctionUse=0]="FunctionUse",e[e.FunctionResult=1]="FunctionResult",e))(lr||{});class JA extends tc{constructor(){super(),this.workers=new Map}addWorker(t,n){this.workers.set(t,n),n.addEventListener("message",i=>{const{to:s,msg:r,transferable:o}=i.data,a={from:t,to:s,msg:r,transferable:o};this.routeMessage(a)})}send(t,n,i){const s=this.workers.get(t);if(s){const r={to:t,from:Jn.Main,msg:n,transferable:i};i!==void 0?s.postMessage(r,i):s.postMessage(r)}}broadcast(t){this.workers.forEach((n,i)=>{const s={to:i,from:Jn.Main,msg:t};n.postMessage(s)})}routeMessage(t){const{from:n,to:i,transferable:s,msg:{type:r}}=t;if(i===Jn.Main)this.emit("message",t);else if(i===Jn.All)n!==Jn.Main&&this.emit(r,t),this.workers.forEach((o,a)=>{a!==n&&(s!==void 0?o.postMessage(t,s):o.postMessage(t))});else{const o=this.workers.get(i);o&&(s!==void 0?o.postMessage(t,s):o.postMessage(t))}}}class KA extends tc{constructor(t){super(),this.worker=t,t.addEventListener("message",n=>{const i=n.data;this.emit("message",i)})}send(t,n,i){const s={to:t,msg:n,transferable:i};this.worker.postMessage(s,i)}broadcast(t){const n={to:Jn.All,msg:t};this.worker.postMessage(n)}}class QA{constructor(t){this.onMessage=n=>{const{from:i,msg:s}=n;switch(s.type){case lr.FunctionUse:this.onFunctionUse(s,i);break;case lr.FunctionResult:this.onFunctionResult(s);break}},this.connector=t,this.functions=new Map,this.functionIdCounter=0,this.pendingFunctions=new Map,t.on("message",this.onMessage)}set(t,n){this.functions.set(t,n)}get(t,n,i){return(...s)=>{const r=this.functionIdCounter++,o={type:lr.FunctionUse,data:{id:r,name:n,args:s,subids:i}};let a;return i?a=i.map(c=>new Promise(l=>{this.pendingFunctions.set(String(r)+`-${c}`,l)})):a=new Promise(c=>{this.pendingFunctions.set(String(r),c)}),this.connector.send(t,o),a}}onFunctionUse(t,n){const{data:{name:i,args:s,id:r}}=t,o=this.functions.get(i);if(o){const a=o(...s);if(Array.isArray(a)&&Kp(a[0]))for(let c=0;c<a.length;c++)Promise.resolve(a[c]).then(l=>{this.sendFunctionResult(n,r,l,c)});else a&&Kp(a)?Promise.resolve(a).then(c=>this.sendFunctionResult(n,r,c)):this.sendFunctionResult(n,r,a)}else console.error(`FnRegistry#onFunctionUse: function ${i} not found`)}sendFunctionResult(t,n,i,s){const r={type:lr.FunctionResult,data:{id:n,result:i,subid:s}};i&&i.transferable?this.connector.send(t,r,i.transferable):this.connector.send(t,r)}onFunctionResult(t){const{data:{id:n,result:i,subid:s}}=t,r=String(n)+(s!==void 0?`-${s}`:""),o=this.pendingFunctions.get(r);o?(o(i),this.pendingFunctions.delete(r)):console.error(`FnRegistry#onFunctionResult: pending function ${r} not found`)}}function Kp(e){return typeof e=="object"&&typeof e.then=="function"}class eE{constructor(t){this.fnRegistry=t,this.onClassCreate=({id:n,name:i,args:s})=>{const r=this.classes.get(i);if(!r){console.error(`ClassRegistry#onClassCreate: class ${i} not found`);return}const o=r.scope?new r.ClassConstructor(r.scope,...s):new r.ClassConstructor(...s);r.hosts.set(n,o)},this.onMethodUse=({id:n,name:i,method:s,args:r})=>{const o=this.classes.get(i);if(!o){console.error(`ClassRegistry#onMethodUse: class ${i} not found`);return}const a=o.hosts.get(n);if(!a){console.error(`ClassRegistry#onMethodUse: instance ${n} in class ${i} not found when calling the ${s} method`);return}if(!a[s]){console.error(`ClassRegistry#onMethodUse: method ${s} in instance ${n} in class ${i} not found`);return}return s==="destroy"&&o.hosts.delete(n),a[s](...r)},this.classes=new Map,this.idCounter=0,this.fnRegistry.set("createClass",this.onClassCreate),this.fnRegistry.set("classMethodUse",this.onMethodUse)}set(t,n,i,s){const r=this,o={ClassConstructor:n,hosts:new Map,proxies:new Map,scope:i};return this.classes.set(t,o),{get:a=>{class c{constructor(...u){this.id=r.idCounter++,r.fnRegistry.get(a,"createClass")({id:this.id,args:u,name:t})}}return Object.getOwnPropertyNames(n.prototype).forEach(d=>{d!=="constructor"&&typeof n.prototype[d]=="function"&&(c.prototype[d]=function(...u){const f=s&&s.includes(d)&&Array.isArray(u[0])?[...Array(u[0].length).keys()].map(h=>h):void 0;return r.fnRegistry.get(a,"classMethodUse",f)({id:this.id,name:t,method:d,args:u})})}),c}}}}const tE={point:{point:!0,heatmap:!0,gltfModel:!0,metricPoint:!0},polygon:{polygon:!0,polygonExtrusion:!0,mesh:!0,embankment:!0,polygon3d:!0,overpass:!0},line:{line:!0,lineExtrusion:!0,labelLine:!0,dashedLine:!0,oneWayLine:!0,metricPoint:!0,overpass:!0}};function nE(e,t){return!!tE[e][t]}function iE(e){const t=e.vertices.x,n=e.vertices.y;let i=0;for(let s=0;s<t.length-1;s++)i+=Math.hypot(t[s]-t[s+1],n[s]-n[s+1]);return i}function fd(e,t){const n=new Set(t[0].map((i,s)=>t[0][s]===e[0]&&e[1]===t[1][s]?s:-1));return Array.from(n)}function sE(e,t,n,i){t>=0&&n>=0&&Math.abs(t-n)===1&&(e[2][0]=1),n>=0&&i>=0&&Math.abs(n-i)===1&&(e[2][1]=1),t>=0&&i>=0&&Math.abs(t-i)===1&&(e[2][2]=1)}function Qp(e,t){const n=fd([e[0][0],e[1][0]],t),i=fd([e[0][1],e[1][1]],t),s=fd([e[0][2],e[1][2]],t);n.forEach(r=>i.forEach(o=>s.forEach(a=>{sE(e,r,o,a)})))}function em(e){const t=["GEOJSON_METATILE_UNKNOWN_SUBLAYER","Commercial_poi_default","Commercial_poi_city","Commercial_poi_premium","Commercial_model","Commercial_model_animated","Commercial_model_on_click","Immersive_model","Immersive_model_multipart","Animated_immersive_model"],n=Array.from(new Set([...t,...e])).filter(i=>typeof i=="string"&&i.length>0);return ku(["id","db_label","db_label2","selected","hovered","componentDistanceStart","componentDistanceEnd","objectLength","beginningIsCut","endingIsCut","db_geometry_type","db_plan_id"],n)}function hd(e,t,n,i,s=2){const r=s+2;let o=i;const a=n-t>>1;let c=n-t,l;const d=e[t],u=e[t+1],f=e[n],h=e[n+1];for(let g=t+r;g<n;g+=r){const w=rE(e[g],e[g+1],d,u,f,h);if(w>o)l=g,o=w;else if(w===o){const p=Math.abs(g-a);p<c&&(l=g,c=p)}}o>i&&(l-t>r&&hd(e,t,l,i,s),e[l+2]=o,n-l>r&&hd(e,l,n,i,s))}function rE(e,t,n,i,s,r){let o=s-n,a=r-i;if(o!==0||a!==0){const c=((e-n)*o+(t-i)*a)/(o*o+a*a);c>1?(n=s,i=r):c>0&&(n+=o*c,i+=a*c)}return o=e-n,a=t-i,o*o+a*a}function dr(e,t,n,i,s,r=4){const o={id:e==null?null:e,index:s,type:t,geometry:n,tags:i,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(t==="Point"||t==="MultiPoint"||t==="LineString")oa(o,n,r);else if(t==="Polygon")oa(o,n[0],r);else if(t==="MultiLineString")for(const a of n)oa(o,a,r);else if(t==="MultiPolygon")for(const a of n)oa(o,a[0],r);return o}function oa(e,t,n=4){for(let i=0;i<t.length;i+=n)e.minX=Math.min(e.minX,t[i]),e.minY=Math.min(e.minY,t[i+1]),e.maxX=Math.max(e.maxX,t[i]),e.maxY=Math.max(e.maxY,t[i+1])}function oE(e,t){const n=[];if(e.type==="FeatureCollection")for(let i=0;i<e.features.length;i++)aa(n,e.features[i],t,i);else e.type==="Feature"?aa(n,e,t,0):aa(n,{geometry:e},t,0);return n}function aa(e,t,n,i){if(!t.geometry)return;const s=t.geometry.coordinates,r=t.geometry.type,o=Math.pow(n.tolerance/((1<<n.maxZoom)*n.extent),2);let a=[],c=t.id;if(n.promoteId?c=t.properties[n.promoteId]:n.generateId&&(c=i||0),r==="Point")tm(s,a,n.dimensions);else if(r==="MultiPoint")for(const l of s)tm(l,a,n.dimensions);else if(r==="LineString")pd(s,a,o,!1,n.dimensions);else if(r==="MultiLineString")if(n.lineMetrics){for(const l of s)a=[],pd(l,a,o,!1,n.dimensions),e.push(dr(c,"LineString",a,t.properties,i,n.dimensions+2));return}else md(s,a,o,!1,n.dimensions);else if(r==="Polygon")md(s,a,o,!0,n.dimensions);else if(r==="MultiPolygon")for(const l of s){const d=[];md(l,d,o,!0,n.dimensions),a.push(d)}else if(r==="GeometryCollection"){for(const l of t.geometry.geometries)aa(e,{id:c,geometry:l,properties:t.properties},n,i);return}else throw new Error("Input data is not a valid GeoJSON object.");e.push(dr(c,r,a,t.properties,i,n.dimensions+2))}function tm(e,t,n=2){t.push(nm(e[0]),im(e[1]),0,1);for(let i=2;i<n;i++)t.push(e[i])}function pd(e,t,n,i,s=2){let r,o,a=0;for(let l=0;l<e.length;l++){const d=nm(e[l][0]),u=im(e[l][1]);t.push(d,u,0,1);for(let f=2;f<s;f++)t.push(e[l][f]);l>0&&(i?a+=(r*u-d*o)/2:a+=Math.sqrt(Math.pow(d-r,2)+Math.pow(u-o,2))),r=d,o=u}const c=t.length-(s+2);t[2]=1,hd(t,0,c,n,s),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function md(e,t,n,i,s=2){for(let r=0;r<e.length;r++){const o=[];pd(e[r],o,n,i,s),t.push(o)}}function nm(e){return e/360+.5}function im(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function En(e,t,n,i,s,r,o,a){const c=(a.dimensions===void 0?2:a.dimensions)+2;if(n/=t,i/=t,r>=n&&o<i)return e;if(o<n||r>=i)return null;const l=[];for(const d of e){const u=d.geometry;let f=d.type;const h=s===0?d.minX:d.minY,g=s===0?d.maxX:d.maxY;if(h>=n&&g<i){l.push(d);continue}else if(g<n||h>=i)continue;let w=[];if(f==="Point"||f==="MultiPoint")aE(u,w,n,i,s,c);else if(f==="LineString")sm(u,w,n,i,s,!1,a.lineMetrics,c);else if(f==="MultiLineString")yd(u,w,n,i,s,!1,c);else if(f==="Polygon")yd(u,w,n,i,s,!0,c);else if(f==="MultiPolygon")for(const p of u){const y=[];yd(p,y,n,i,s,!0,c),y.length&&w.push(y)}if(w.length){if(a.lineMetrics&&f==="LineString"){for(const p of w)l.push(dr(d.id,f,p,d.tags,d.index,c));continue}(f==="LineString"||f==="MultiLineString")&&(w.length===1?(f="LineString",w=w[0]):f="MultiLineString"),(f==="Point"||f==="MultiPoint")&&(f=w.length===c?"Point":"MultiPoint"),l.push(dr(d.id,f,w,d.tags,d.index,c))}}return l.length?l:null}function aE(e,t,n,i,s,r=4){for(let o=0;o<e.length;o+=r){const a=e[o+s];if(a>=n&&a<=i){rs(t,e[o],e[o+1],e[o+2]);for(let c=3;c<r;c++)t.push(e[o+c])}}}function sm(e,t,n,i,s,r,o,a=4){let c=rm(e);const l=s===0?cE:lE;let d=e.start,u,f;for(let b=0;b<e.length-a;b+=a){const v=e[b],T=e[b+1],E=e[b+2],S=e[b+a],L=e[b+a+1],x=s===0?v:T,O=s===0?S:L;let B=!1;if(o&&(u=Math.sqrt(Math.pow(v-S,2)+Math.pow(T-L,2))),x<n){if(O>n){f=l(c,v,T,S,L,n),c.push(0);for(let U=4;U<a;U++){const j=e[b+U];c.push((e[b+a+U]-j)*f+j)}o&&(c.start=d+u*f)}}else if(x>i){if(O<i){f=l(c,v,T,S,L,i),c.push(0);for(let U=4;U<a;U++){const j=e[b+U];c.push((e[b+a+U]-j)*f+j)}o&&(c.start=d+u*f)}}else{rs(c,v,T,E);for(let U=3;U<a;U++)c.push(e[b+U])}if(O<n&&x>=n){f=l(c,v,T,S,L,n),c.push(0);for(let U=4;U<a;U++){const j=e[b+U];c.push((e[b+a+U]-j)*f+j)}B=!0}if(O>i&&x<=i){f=l(c,v,T,S,L,i),c.push(0);for(let U=4;U<a;U++){const j=e[b+U];c.push((e[b+a+U]-j)*f+j)}B=!0}!r&&B&&(o&&(c.end=d+u*f),t.push(c),c=rm(e)),o&&(d+=u)}let h=e.length-a;const g=e[h],w=e[h+1],p=e[h+2],y=s===0?g:w;if(y>=n&&y<=i){rs(c,g,w,p);for(let b=3;b<a;b++)c.push(e[h+b])}if(h=c.length-a,r&&h>=3&&(c[h]!==c[0]||c[h+1]!==c[1])){rs(c,c[0],c[1],c[2]);for(let b=3;b<a;b++)c.push(c[b])}c.length&&t.push(c)}function rm(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function yd(e,t,n,i,s,r,o){for(const a of e)sm(a,t,n,i,s,r,!1,o)}function rs(e,t,n,i){e.push(t,n,i)}function cE(e,t,n,i,s,r){const o=(r-t)/(i-t);return rs(e,r,n+(s-n)*o,1),o}function lE(e,t,n,i,s,r){const o=(r-n)/(s-n);return rs(e,t+(i-t)*o,r,1),o}function dE(e,t){const n=t.buffer/t.extent,i=t.dimensions+2;let s=e;const r=En(e,1,-1-n,n,0,-1,2,t),o=En(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(s=En(e,1,-n,1+n,0,-1,2,t)||[],r&&(s=om(r,1,i).concat(s)),o&&(s=s.concat(om(o,-1,i)))),s}function om(e,t,n=4){const i=[];for(let s=0;s<e.length;s++){const r=e[s],o=r.type;let a;if(o==="Point"||o==="MultiPoint"||o==="LineString")a=gd(r.geometry,t,n);else if(o==="MultiLineString"||o==="Polygon"){a=[];for(const c of r.geometry)a.push(gd(c,t,n))}else if(o==="MultiPolygon"){a=[];for(const c of r.geometry){const l=[];for(const d of c)l.push(gd(d,t,n));a.push(l)}}i.push(dr(r.id,o,a,r.tags,r.index,n))}return i}function gd(e,t,n=4){const i=[];i.size=e.size,e.start!==void 0&&(i.start=e.start,i.end=e.end);for(let s=0;s<e.length;s+=n){i.push(e[s]+t,e[s+1],e[s+2],e[s+3]);for(let r=4;r<n;r++)i.push(e[s+r])}return i}function am(e,t,n){if(e.transformed)return e;const i=1<<e.z,s=e.x,r=e.y;for(const o of e.features){const a=o.geometry,c=o.type;o.geometry=[];const l=n.cuts&&c!==1?1:0,d=n.dimensions+l;if(c===1)for(let u=0;u<a.length;u+=d)o.geometry.push(lm(a,u,d,t,i,s,r));else if(c===2)o.geometry=cm(a,t,i,s,r,d);else for(let u=0;u<a.length;u++)o.geometry.push(cm(a[u],t,i,s,r,d))}return e.transformed=!0,e}function cm(e,t,n,i,s,r=3){const o=[];for(let a=0;a<e.length;a++){const c=[];for(let l=0;l<e[a].length;l+=r)c.push(lm(e[a],l,r,t,n,i,s));o.push(c)}return o}function lm(e,t,n,i,s,r,o){const a=[Math.round(i*(e[t]*s-r)),Math.round(i*(e[t+1]*s-o))];for(let c=2;c<n;c++)a.push(e[t+c]);return a}function uE(e,t,n,i,s){const r=t===s.maxZoom?0:s.tolerance/((1<<t)*s.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:e.length,source:null,x:n,y:i,z:t,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const a of e)fE(o,a,r,s);return o}function fE(e,t,n,i){const s=t.geometry,r=t.type,o=i.dimensions+2;let a=[];if(e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),r==="Point"||r==="MultiPoint")for(let c=0;c<s.length;c+=o){a.push(s[c],s[c+1]);for(let l=4;l<o;l++)a.push(s[c+l]);e.numPoints++,e.numSimplified++}else if(r==="LineString")wd(a,s,e,n,!1,!1,i);else if(r==="MultiLineString"||r==="Polygon"){for(let c=0;c<s.length;c++)wd(a,s[c],e,n,r==="Polygon",c===0,i);r==="Polygon"&&a.length&&(a=[a])}else if(r==="MultiPolygon")for(let c=0;c<s.length;c++){const l=s[c],d=[];for(let u=0;u<l.length;u++)wd(d,l[u],e,n,!0,u===0,i);d.length&&a.push(d)}if(a.length){let c=t.tags||null;if(r==="LineString"&&i.lineMetrics){c={};for(const d in t.tags)c[d]=t.tags[d];c.mapbox_clip_start=s.start/s.size,c.mapbox_clip_end=s.end/s.size}const l={geometry:a,type:r==="Polygon"||r==="MultiPolygon"?3:r==="LineString"||r==="MultiLineString"?2:1,tags:c};t.id!==null&&(l.id=t.id),i.generateIndex&&(l.index=t.index),e.features.push(l)}}function wd(e,t,n,i,s,r,o){const a=i*i,c=o&&!!o.cuts,l=o.dimensions+2;if(i>0&&t.size<(s?a:i)){n.numPoints+=t.length/l;return}const d=[];for(let u=0;u<t.length;u+=l){if(i===0||t[u+2]>a){n.numSimplified++,d.push(t[u],t[u+1]);for(let f=4;f<l;f++)d.push(t[u+f]);c&&d.push(t[u+3])}n.numPoints++}s&&hE(d,r,l-(c?1:2)),e.push(d)}function hE(e,t,n=3){let i=0;for(let s=0,r=e.length,o=r-n;s<r;o=s,s+=n)i+=(e[s]-e[o])*(e[s+1]+e[o+1]);if(i>0===t)for(let s=0,r=e.length;s<r/2;s+=n)for(let o=0;o<n;o++){const a=e[s+o],c=r-s-(n-o);e[s+o]=e[c],e[c]=a}return e}const pE={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!1,debug:0,dimensions:2,cuts:!1};class mE{constructor(t,n){n=this.options=yE(Object.create(pE),n);const i=n.debug;if(i&&console.time("preprocess data"),n.maxZoom<0||n.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(n.promoteId&&n.generateId)throw new Error("promoteId and generateId cannot be used together.");let s=oE(t,n);this.tiles={},this.tileCoords=[],i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",n.indexMaxZoom,n.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),s=dE(s,n),s.length&&this.splitTile(s,0,0,0),i&&(s.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,n,i,s,r,o,a){const c=[t,n,i,s],l=this.options,d=l.debug;for(;c.length;){s=c.pop(),i=c.pop(),n=c.pop(),t=c.pop();const u=1<<n,f=vd(n,i,s);let h=this.tiles[f];if(!h&&(d>1&&console.time("creation"),h=this.tiles[f]=uE(t,n,i,s,l),this.tileCoords.push({z:n,x:i,y:s}),d)){d>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",n,i,s,h.numFeatures,h.numPoints,h.numSimplified),console.timeEnd("creation"));const x=`z${n}`;this.stats[x]=(this.stats[x]||0)+1,this.total++}if(h.source=t,r==null){if(n===l.indexMaxZoom||h.numPoints<=l.indexMaxPoints)continue}else{if(n===l.maxZoom||n===r)continue;if(r!=null){const x=r-n;if(i!==o>>x||s!==a>>x)continue}}if(h.source=null,t.length===0)continue;d>1&&console.time("clipping");const g=.5*l.buffer/l.extent,w=.5-g,p=.5+g,y=1+g;let b=null,v=null,T=null,E=null,S=En(t,u,i-g,i+p,0,h.minX,h.maxX,l),L=En(t,u,i+w,i+y,0,h.minX,h.maxX,l);t=null,S&&(b=En(S,u,s-g,s+p,1,h.minY,h.maxY,l),v=En(S,u,s+w,s+y,1,h.minY,h.maxY,l),S=null),L&&(T=En(L,u,s-g,s+p,1,h.minY,h.maxY,l),E=En(L,u,s+w,s+y,1,h.minY,h.maxY,l),L=null),d>1&&console.timeEnd("clipping"),c.push(b||[],n+1,i*2,s*2),c.push(v||[],n+1,i*2,s*2+1),c.push(T||[],n+1,i*2+1,s*2),c.push(E||[],n+1,i*2+1,s*2+1)}}getTile(t,n,i){t=+t,n=+n,i=+i;const s=this.options,{extent:r,debug:o}=s;if(t<0||t>24)return null;const a=1<<t;n=n+a&a-1;const c=vd(t,n,i);if(this.tiles[c])return am(this.tiles[c],r,s);o>1&&console.log("drilling down to z%d-%d-%d",t,n,i);let l=t,d=n,u=i,f;for(;!f&&l>0;)l--,d=d>>1,u=u>>1,f=this.tiles[vd(l,d,u)];return!f||!f.source?null:(o>1&&(console.log("found parent tile z%d-%d-%d",l,d,u),console.time("drilling down")),this.splitTile(f.source,l,d,u,t,n,i),o>1&&console.timeEnd("drilling down"),this.tiles[c]?am(this.tiles[c],r,s):null)}}function vd(e,t,n){return((1<<e)*n+t)*32+e}function yE(e,t){for(const n in t)e[n]=t[n];return e}function gE(e,t){return new mE(e,t)}var ca={exports:{}},dm;function wE(){if(dm)return ca.exports;dm=1,ca.exports=e,ca.exports.default=e;function e(A,P,_){_=_||2;var C=P&&P.length,F=C?P[0]*_:A.length,k=t(A,0,F,_,!0),R=[];if(!k||k.next===k.prev)return R;var G,Z,H,Q,J,N,W;if(C&&(k=c(A,P,k,_)),A.length>80*_){G=H=A[0],Z=Q=A[1];for(var q=_;q<F;q+=_)J=A[q],N=A[q+1],J<G&&(G=J),N<Z&&(Z=N),J>H&&(H=J),N>Q&&(Q=N);W=Math.max(H-G,Q-Z),W=W!==0?32767/W:0}return i(k,R,_,G,Z,W,0),R}function t(A,P,_,C,F){var k,R;if(F===X(A,P,_,C)>0)for(k=P;k<_;k+=C)R=j(k,A[k],A[k+1],R);else for(k=_-C;k>=P;k-=C)R=j(k,A[k],A[k+1],R);return R&&T(R,R.next)&&(M(R),R=R.next),R}function n(A,P){if(!A)return A;P||(P=A);var _=A,C;do if(C=!1,!_.steiner&&(T(_,_.next)||v(_.prev,_,_.next)===0)){if(M(_),_=P=_.prev,_===_.next)break;C=!0}else _=_.next;while(C||_!==P);return P}function i(A,P,_,C,F,k,R){if(A){!R&&k&&h(A,C,F,k);for(var G=A,Z,H;A.prev!==A.next;){if(Z=A.prev,H=A.next,k?r(A,C,F,k):s(A)){P.push(Z.i/_|0),P.push(A.i/_|0),P.push(H.i/_|0),M(A),A=H.next,G=H.next;continue}if(A=H,A===G){R?R===1?(A=o(n(A),P,_),i(A,P,_,C,F,k,2)):R===2&&a(A,P,_,C,F,k):i(n(A),P,_,C,F,k,1);break}}}}function s(A){var P=A.prev,_=A,C=A.next;if(v(P,_,C)>=0)return!1;for(var F=P.x,k=_.x,R=C.x,G=P.y,Z=_.y,H=C.y,Q=F<k?F<R?F:R:k<R?k:R,J=G<Z?G<H?G:H:Z<H?Z:H,N=F>k?F>R?F:R:k>R?k:R,W=G>Z?G>H?G:H:Z>H?Z:H,q=C.next;q!==P;){if(q.x>=Q&&q.x<=N&&q.y>=J&&q.y<=W&&y(F,G,k,Z,R,H,q.x,q.y)&&v(q.prev,q,q.next)>=0)return!1;q=q.next}return!0}function r(A,P,_,C){var F=A.prev,k=A,R=A.next;if(v(F,k,R)>=0)return!1;for(var G=F.x,Z=k.x,H=R.x,Q=F.y,J=k.y,N=R.y,W=G<Z?G<H?G:H:Z<H?Z:H,q=Q<J?Q<N?Q:N:J<N?J:N,pe=G>Z?G>H?G:H:Z>H?Z:H,me=Q>J?Q>N?Q:N:J>N?J:N,ye=w(W,q,P,_,C),se=w(pe,me,P,_,C),Y=A.prevZ,V=A.nextZ;Y&&Y.z>=ye&&V&&V.z<=se;){if(Y.x>=W&&Y.x<=pe&&Y.y>=q&&Y.y<=me&&Y!==F&&Y!==R&&y(G,Q,Z,J,H,N,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0||(Y=Y.prevZ,V.x>=W&&V.x<=pe&&V.y>=q&&V.y<=me&&V!==F&&V!==R&&y(G,Q,Z,J,H,N,V.x,V.y)&&v(V.prev,V,V.next)>=0))return!1;V=V.nextZ}for(;Y&&Y.z>=ye;){if(Y.x>=W&&Y.x<=pe&&Y.y>=q&&Y.y<=me&&Y!==F&&Y!==R&&y(G,Q,Z,J,H,N,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0)return!1;Y=Y.prevZ}for(;V&&V.z<=se;){if(V.x>=W&&V.x<=pe&&V.y>=q&&V.y<=me&&V!==F&&V!==R&&y(G,Q,Z,J,H,N,V.x,V.y)&&v(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function o(A,P,_){var C=A;do{var F=C.prev,k=C.next.next;!T(F,k)&&E(F,C,C.next,k)&&O(F,k)&&O(k,F)&&(P.push(F.i/_|0),P.push(C.i/_|0),P.push(k.i/_|0),M(C),M(C.next),C=A=k),C=C.next}while(C!==A);return n(C)}function a(A,P,_,C,F,k){var R=A;do{for(var G=R.next.next;G!==R.prev;){if(R.i!==G.i&&b(R,G)){var Z=U(R,G);R=n(R,R.next),Z=n(Z,Z.next),i(R,P,_,C,F,k,0),i(Z,P,_,C,F,k,0);return}G=G.next}R=R.next}while(R!==A)}function c(A,P,_,C){var F=[],k,R,G,Z,H;for(k=0,R=P.length;k<R;k++)G=P[k]*C,Z=k<R-1?P[k+1]*C:A.length,H=t(A,G,Z,C,!1),H===H.next&&(H.steiner=!0),F.push(p(H));for(F.sort(l),k=0;k<F.length;k++)_=d(F[k],_);return _}function l(A,P){return A.x-P.x}function d(A,P){var _=u(A,P);if(!_)return P;var C=U(_,A);return n(C,C.next),n(_,_.next)}function u(A,P){var _=P,C=A.x,F=A.y,k=-1/0,R;do{if(F<=_.y&&F>=_.next.y&&_.next.y!==_.y){var G=_.x+(F-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(G<=C&&G>k&&(k=G,R=_.x<_.next.x?_:_.next,G===C))return R}_=_.next}while(_!==P);if(!R)return null;var Z=R,H=R.x,Q=R.y,J=1/0,N;_=R;do C>=_.x&&_.x>=H&&C!==_.x&&y(F<Q?C:k,F,H,Q,F<Q?k:C,F,_.x,_.y)&&(N=Math.abs(F-_.y)/(C-_.x),O(_,A)&&(N<J||N===J&&(_.x>R.x||_.x===R.x&&f(R,_)))&&(R=_,J=N)),_=_.next;while(_!==Z);return R}function f(A,P){return v(A.prev,A,P.prev)<0&&v(P.next,A,A.next)<0}function h(A,P,_,C){var F=A;do F.z===0&&(F.z=w(F.x,F.y,P,_,C)),F.prevZ=F.prev,F.nextZ=F.next,F=F.next;while(F!==A);F.prevZ.nextZ=null,F.prevZ=null,g(F)}function g(A){var P,_,C,F,k,R,G,Z,H=1;do{for(_=A,A=null,k=null,R=0;_;){for(R++,C=_,G=0,P=0;P<H&&(G++,C=C.nextZ,!!C);P++);for(Z=H;G>0||Z>0&&C;)G!==0&&(Z===0||!C||_.z<=C.z)?(F=_,_=_.nextZ,G--):(F=C,C=C.nextZ,Z--),k?k.nextZ=F:A=F,F.prevZ=k,k=F;_=C}k.nextZ=null,H*=2}while(R>1);return A}function w(A,P,_,C,F){return A=(A-_)*F|0,P=(P-C)*F|0,A=(A|A<<8)&16711935,A=(A|A<<4)&252645135,A=(A|A<<2)&858993459,A=(A|A<<1)&1431655765,P=(P|P<<8)&16711935,P=(P|P<<4)&252645135,P=(P|P<<2)&858993459,P=(P|P<<1)&1431655765,A|P<<1}function p(A){var P=A,_=A;do(P.x<_.x||P.x===_.x&&P.y<_.y)&&(_=P),P=P.next;while(P!==A);return _}function y(A,P,_,C,F,k,R,G){return(F-R)*(P-G)>=(A-R)*(k-G)&&(A-R)*(C-G)>=(_-R)*(P-G)&&(_-R)*(k-G)>=(F-R)*(C-G)}function b(A,P){return A.next.i!==P.i&&A.prev.i!==P.i&&!x(A,P)&&(O(A,P)&&O(P,A)&&B(A,P)&&(v(A.prev,A,P.prev)||v(A,P.prev,P))||T(A,P)&&v(A.prev,A,A.next)>0&&v(P.prev,P,P.next)>0)}function v(A,P,_){return(P.y-A.y)*(_.x-P.x)-(P.x-A.x)*(_.y-P.y)}function T(A,P){return A.x===P.x&&A.y===P.y}function E(A,P,_,C){var F=L(v(A,P,_)),k=L(v(A,P,C)),R=L(v(_,C,A)),G=L(v(_,C,P));return!!(F!==k&&R!==G||F===0&&S(A,_,P)||k===0&&S(A,C,P)||R===0&&S(_,A,C)||G===0&&S(_,P,C))}function S(A,P,_){return P.x<=Math.max(A.x,_.x)&&P.x>=Math.min(A.x,_.x)&&P.y<=Math.max(A.y,_.y)&&P.y>=Math.min(A.y,_.y)}function L(A){return A>0?1:A<0?-1:0}function x(A,P){var _=A;do{if(_.i!==A.i&&_.next.i!==A.i&&_.i!==P.i&&_.next.i!==P.i&&E(_,_.next,A,P))return!0;_=_.next}while(_!==A);return!1}function O(A,P){return v(A.prev,A,A.next)<0?v(A,P,A.next)>=0&&v(A,A.prev,P)>=0:v(A,P,A.prev)<0||v(A,A.next,P)<0}function B(A,P){var _=A,C=!1,F=(A.x+P.x)/2,k=(A.y+P.y)/2;do _.y>k!=_.next.y>k&&_.next.y!==_.y&&F<(_.next.x-_.x)*(k-_.y)/(_.next.y-_.y)+_.x&&(C=!C),_=_.next;while(_!==A);return C}function U(A,P){var _=new I(A.i,A.x,A.y),C=new I(P.i,P.x,P.y),F=A.next,k=P.prev;return A.next=P,P.prev=A,_.next=F,F.prev=_,C.next=_,_.prev=C,k.next=C,C.prev=k,C}function j(A,P,_,C){var F=new I(A,P,_);return C?(F.next=C.next,F.prev=C,C.next.prev=F,C.next=F):(F.prev=F,F.next=F),F}function M(A){A.next.prev=A.prev,A.prev.next=A.next,A.prevZ&&(A.prevZ.nextZ=A.nextZ),A.nextZ&&(A.nextZ.prevZ=A.prevZ)}function I(A,P,_){this.i=A,this.x=P,this.y=_,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}e.deviation=function(A,P,_,C){var F=P&&P.length,k=F?P[0]*_:A.length,R=Math.abs(X(A,0,k,_));if(F)for(var G=0,Z=P.length;G<Z;G++){var H=P[G]*_,Q=G<Z-1?P[G+1]*_:A.length;R-=Math.abs(X(A,H,Q,_))}var J=0;for(G=0;G<C.length;G+=3){var N=C[G]*_,W=C[G+1]*_,q=C[G+2]*_;J+=Math.abs((A[N]-A[q])*(A[W+1]-A[N+1])-(A[N]-A[W])*(A[q+1]-A[N+1]))}return R===0&&J===0?0:Math.abs((J-R)/R)};function X(A,P,_,C){for(var F=0,k=P,R=_-C;k<_;k+=C)F+=(A[R]-A[k])*(A[k+1]+A[R+1]),R=k;return F}return e.flatten=function(A){for(var P=A[0][0].length,_={vertices:[],holes:[],dimensions:P},C=0,F=0;F<A.length;F++){for(var k=0;k<A[F].length;k++)for(var R=0;R<P;R++)_.vertices.push(A[F][k][R]);F>0&&(C+=A[F-1].length,_.holes.push(C))}return _},ca.exports}var vE=wE();const bd=Pc(vE);function bE(e){const t=ct(e),n=oe.scaleFactor(As(0,0,t)[1]),i=oe.scaleFactor(As(0,te,t)[1]);return{min:n,max:i,range:i-n}}function IE(e,t,n,i){const s=[];return e.geometry.forEach(r=>{const o=[],a=[],c=[];r.forEach(f=>{c.push(...EE(f,t)),o.length&&a.push(o.length),o.push(...f)});const l=[];for(let f=0;f<o.length;f++)for(let h=0;h<n;h++)l.push(o[f][h]);const d=bd(l,a,n),u=new Array(n);for(let f=0;f<d.length;f+=3){const h=[];for(let g=0;g<n+1;g++)h.push([]);for(let g=0;g<3;g++)Id(u,o[d[f+2-g]],t,i),h[0][g]=u[0],h[1][g]=u[1],h[2][g]=0,n>2&&(h[3][g]=u[2]),n>3&&(h[4][g]=u[3]);c.forEach(g=>{const w=[[],[],[]];g.forEach((p,y)=>{w[0][y]=p[0],w[1][y]=p[1]}),Qp(h,w)}),s.push({tags:e.tags,id:e.id,index:e.index,type:"polygon",vertices:{x:h[0],y:h[1],cut:h[2],signed_z:h[3],abs_z:h[4]}})}}),s}function ME(e,t,n,i){const s=Array(n);return e.geometry.map(r=>{const o=[];for(let a=0;a<n;a++)o.push([]);return r.forEach((a,c)=>{Id(s,a,t,i),o[0][c]=s[0],o[1][c]=s[1],n>2&&(o[2][c]=s[2]),n>3&&(o[3][c]=s[3])}),{tags:e.tags,id:e.id,index:e.index,type:"line",vertices:{x:o[0],y:o[1],z:o[2],signed_z:o[2],abs_z:o[3]}}})}function TE(e,t,n,i){const s=Array(n);return e.geometry.map(r=>{var a;Id(s,r,t,i);const o={x:[s[0]],y:[s[1]],z:n>2?[(a=s[2])!=null?a:0]:void 0,abs_z:n>3&&s[3]!==void 0?[s[3]]:void 0};return{tags:e.tags,id:e.id,index:e.index,type:"point",vertices:o}})}function Id(e,t,n,i){const s=um(t,n);e[0]=s[0],e[1]=s[1];const r=i.min+s[1]/te*i.range;t[2]===void 0||isNaN(t[2])?e[2]=0:e[2]=t[2]*Ie*r,t[3]!==void 0&&(e[3]=t[3]*Ie*r)}function um(e,t){return[Te(e[0]/t*te,0,te),Te((t-e[1])/t*te,0,te)]}function SE(e,t){return e[0]<0||e[0]>t||e[1]<0||e[1]>t}function AE(e,t,n){return e[0]>n&&t[0]>n||e[0]<0&&t[0]<0||e[1]>n&&t[1]>n||e[1]<0&&t[1]<0}function EE(e,t){const n=[];let i=[];for(let s=0;s<e.length;s++){const r=e[s];if(i.push(um(r,t)),!SE(r,t))continue;const o=e[s+1];if(!o)break;AE(r,o,t)&&(i.length>1&&n.push(i),i=[])}return i.length>1&&n.push(i),n}const fm=4096,hm=2,os={maxZoom:gp,tolerance:3,extent:fm,buffer:1,debug:0,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!0,indexMaxZoom:0,indexMaxPoints:1e5,dimensions:hm};class Md{constructor(t){this.options=t}get geoJsonVtInstance(){var t,n,i,s,r;return this.geoJsonVT||(this.geoJsonVT=gE(this.options.data,ve(ue({},os),{maxZoom:(t=this.options.maxZoom)!=null?t:os.maxZoom,dimensions:(n=this.options.dimensions)!=null?n:os.dimensions,extent:(i=this.options.extent)!=null?i:os.extent,buffer:(s=this.options.buffer)!=null?s:os.buffer,promoteId:this.options.promoteId,tolerance:(r=this.options.tolerance)!=null?r:os.tolerance}))),this.geoJsonVT}fetchTile(t){var d,u;const[n,i,s]=Ur(t),r={components:[],byId:new Map},o=this.geoJsonVtInstance.getTile(s,n,i),a=(d=this.options.dimensions)!=null?d:hm,c=(u=this.options.extent)!=null?u:fm,l=bE(t);if(!o)return Promise.resolve(r);for(const f of o.features)switch(f.type){case 1:r.components=r.components.concat(TE(f,c,a,l));break;case 2:r.components=r.components.concat(ME(f,c,a,l));break;case 3:r.components=r.components.concat(IE(f,c,a,l));break;default:console.warn("unsupported type ",o);break}return Promise.resolve(r)}destroy(){this.geoJsonVT=void 0}}function xE(e,t,n){const i={components:[],byId:new Map};return e.features.forEach((s,r)=>{i.components.push(...pm(s.geometry,t).map(o=>ve(ue({},o),{index:r,id:s.id,tags:s.properties||{}})))}),i}function pm(e,t,n){switch(e.type){case"GeometryCollection":{let i=[];return e.geometries.forEach(s=>{i=i.concat(pm(s,t))}),i}case"Point":case"MultiPoint":return _E(e,t);case"LineString":case"MultiLineString":return PE(e,t);case"Polygon":case"MultiPolygon":return LE(e,t)}}function _E(e,t){return e.type==="Point"?[mm(e.coordinates,t)]:e.coordinates.map(n=>mm(n,t))}function PE(e,t){return e.type==="LineString"?[ym(e.coordinates,t)]:e.coordinates.map(n=>ym(n,t))}function LE(e,t,n){return e.type==="Polygon"?gm(e.coordinates,t):e.coordinates.reduce((i,s)=>i.concat(gm(s,t)),[])}function mm(e,t){const n=[0,0,0];return Pt(n,oe.fromGeo(e),t),{type:"point",vertices:{x:[n[0]],y:[n[1]]}}}function ym(e,t){const n=[[],[]],i=[0,0,0];return e.forEach((s,r)=>{Pt(i,oe.fromGeo(s),t),n[0][r]=i[0],n[1][r]=i[1]}),{type:"line",vertices:{x:n[0],y:n[1]}}}function gm(e,t,n){const i=[],s=[],r=[],o=[],a=[];e.forEach(d=>{const u=d.map(f=>(Pt(a,oe.fromGeo(f),t),[Te(a[0],0,te),Te(a[1],0,te)]));o.push(u),s.length&&r.push(s.length),s.push(...u)});const c=[];for(let d=0;d<s.length;d++)c.push(s[d][0]),c.push(s[d][1]);const l=bd(c,r);for(let d=0;d<l.length;d+=3){const u=[[],[],[],[]];for(let h=0;h<3;h++)u[0][h]=s[l[d+h]][0],u[1][h]=s[l[d+h]][1],u[2][h]=0,u[3][h]=s[l[d+h]][2];o.forEach(h=>{const g=[[],[],[]];h.forEach((w,p)=>{g[0][p]=w[0],g[1][p]=w[1]}),Qp(u,g)});const f={type:"polygon",vertices:{x:u[0],y:u[1],cut:u[2]}};i.push(f)}return i}class la{constructor(t){this.tileLoader=new cd("json",t.ignoreMissingTiles),this.options=t,this.url=n=>{const i=this.options.flipY?n:Ur(n);return Ms(this.options.url,{x:i[0].toString(),y:i[1].toString(),z:i[2].toString(),subdomain:Yu(i)})}}fetchTile(t){return this.tileLoader.fetch(t,this.url).then(n=>n.data?xE(n.data,ct(t)):{components:[],byId:new Map})}abortTile(t){this.tileLoader.abortRequests([xe(t)])}destroy(){this.tileLoader.destroy()}}const wm=4;class DE{constructor(t,n,i,s){this.scope=t,this.options=n,this.id=i,this.featureStateMap=new Zl,t.sources[i]=this,this.tileData={},this.styleManager=t.styleManager,this.collector=t.collector,this.sourceAttrs=this.options.attributes||{},this.metatile=em(s),this.tileServer="url"in n?new la(n):new Md(n)}fetchTiles(t){const n=[];for(const i of t)n.push(this.fetchTile(i));return n}abortTileFetches(t){if(this.tileServer instanceof la)for(const n of t)this.tileServer.abortTile(n)}generateTile(t,n,i,s,r,o,a,c){const l=xe(n),d=this.tileData[l],u=ct(n),f=[],h=[],g=this.styleManager.getStyle(i),w=new Set(s),{promoteId:p}=this.options,y={},b="generateId"in this.options?this.options.generateId:!1;if(!g)return Promise.resolve({results:f,transferable:h});d&&d.components.forEach((S,L)=>{const{tileProps:x}=this.metatile,O=[],B=[];if(S.tags){const F=Object.keys(S.tags);Ts(this.metatile,F);for(const k of F)O[x[k]]=S.tags[k]}const U=Object.keys(this.sourceAttrs);Ts(this.metatile,U);const j=Array.from(this.featureStateMap.featureAttrs);Ts(this.metatile,j);for(const F of U)O[x[F]]=this.sourceAttrs[F];const M=O[x.db_hidden_by_plan_id];if(M&&t._activeFloorIds.includes(M))return;const I=b?String(S.index+this.id*re(2,32)):p?O[x[p]]:void 0;if(I!==void 0){const F=w.has(I);if(O[x.selected]=F?1:0,d.byId.set(I,L),y[I]=S.index,this.featureStateMap.featureAttrs.size>0){const k=I!==void 0&&this.featureStateMap.get(I);if(k)for(const R of this.featureStateMap.featureAttrs)this.featureStateMap.clearAttrs=!1,B[x[R]]=k[R];else if(this.featureStateMap.clearAttrs===!1){this.featureStateMap.clearAttrs=!0;for(const R in x)B[x[R]]!==void 0&&(B[x[R]]=void 0)}}}const{coords:X}=u,A=X[3],P=xc(r),_=Cs(t,this.sourceAttrs,x,O,B,I,u),C=this.styleManager.getLayers(g.id,x,O).filter(F=>nE(S.type,F.type)&&$(F.filter,_)&&(a?$(a,_):!0));if(C.length===0&&_.id&&this.collector.idIndexer.addOrphanId(_.id),O[x.db_geometry_type]=S.type==="line"?"polyline":S.type,(S.type==="point"||S.type==="line")&&(O[x.db_label]===void 0&&(O[x.db_label]=NaN),O[x.db_label2]===void 0&&(O[x.db_label2]=NaN)),S.type==="line"){const F=iE(S);O[x.componentDistanceStart]=0,O[x.componentDistanceEnd]=F,O[x.objectLength]=F,typeof O[x.beginningIsCut]!="number"&&(O[x.beginningIsCut]=0),typeof O[x.endingIsCut]!="number"&&(O[x.endingIsCut]=0)}xl(this.collector,g,C,_,this.metatile,wm,A,this.id,u,P,S.vertices,void 0,o,c)});const v=this.collector.getAccumulatedData(),T={regionId:0,metatileHash:Od,collectorOutput:v,styleId:g.id};Object.keys(y).length>0&&(T.idToIndex=y),f.push(T),h.push(...v.transferable),this.scope.debouncedResetCollector(),this.scope.syncNewRasterSets();const E={results:f,transferable:h};return Promise.resolve(E)}getObjectAttributes(t,n){const i=this.tileData[n];if(i){const s=i.byId.get(t);if(s===void 0)return;const r=i.components[s];return r===void 0?void 0:r.tags}}deleteTiles(t){for(const n of t)delete this.tileData[xe(n)]}setSourceAttrs(t){this.sourceAttrs=t}destroy(){delete this.scope.sources[this.id],this.tileData={},this.sourceAttrs={},this.tileServer.destroy()}setFeatureStateMap(t){this.featureStateMap=Bp(t)}setData(t){if(typeof t=="string"){if(this.tileServer instanceof la)return this.tileServer.destroy(),this.options=ve(ue({},this.options),{url:t}),this.tileServer=new la(this.options),this.tileData={},Promise.resolve(!0)}else if(this.tileServer instanceof Md)return this.tileServer.destroy(),this.options=ve(ue({},this.options),{data:t}),this.tileServer=new Md(this.options),this.tileData={},Promise.resolve(!0);return Promise.resolve(!1)}fetchTile(t){const n=xe(t);return this.tileData[n]?Promise.resolve(this.tileData[n]):this.tileServer.fetchTile(t).then(i=>(this.tileData[n]=i,i))}}function OE(e,t){var n,i,s;return{path:t,extensions:e.extensions,extensionsRequired:(n=e.extensionsRequired)!=null?n:[],extensionsUsed:(i=e.extensionsUsed)!=null?i:[],extras:e.extras,accessors:CE(e.accessors),buffers:NE(e.buffers),bufferViews:kE(e.bufferViews),cameras:BE(e.cameras),scene:(s=e.scene)!=null?s:0,scenes:GE(e.scenes),nodes:jE(e.nodes),materials:zE(e.materials),meshes:UE(e.meshes),asset:FE(e.asset),animations:RE(e.animations),images:VE(e.images),textures:HE(e.textures),samplers:$E(e.samplers),skins:YE(e.skins)}}function FE(e){return{copyright:e.copyright,generator:e.generator,version:e.version,minVersion:e.minVersion}}function CE(e=[]){return e.map(t=>{var n;return{bufferView:t.bufferView,byteOffset:(n=t.byteOffset)!=null?n:0,componentType:t.componentType,normalized:t.normalized,count:t.count,type:t.type,max:t.max,min:t.min,sparse:t.sparse,name:t.name,extensions:t.extensions,extras:t.extras}})}function RE(e=[]){return e.map(t=>({channels:t.channels,samplers:t.samplers,name:t.name,extensions:t.extensions,extras:t.extras}))}function NE(e=[]){return e.map(t=>({uri:t.uri,byteLength:t.byteLength,name:t.name,extensions:t.extensions,extras:t.extras,buffer:void 0}))}function kE(e=[]){return e.map(t=>({buffer:t.buffer,byteOffset:t.byteOffset,byteLength:t.byteLength,byteStride:t.byteStride,target:t.target,name:t.name,extensions:t.extensions,extras:t.extras}))}function BE(e=[]){return e.map(t=>({type:t.type,orthographic:t.orthographic,perspective:t.perspective,name:t.name,extensions:t.extensions,extras:t.extras}))}function UE(e=[]){return e.map(t=>({primitives:t.primitives,name:t.name,weights:t.weights,extensions:t.extensions,extras:t.extras}))}function zE(e=[]){return e.map(t=>({alphaCutoff:t.alphaCutoff,alphaMode:t.alphaMode,doubleSided:t.doubleSided,emissiveFactor:t.emissiveFactor,emissiveTexture:t.emissiveTexture,normalTexture:t.normalTexture,occlusionTexture:t.occlusionTexture,pbrMetallicRoughness:t.pbrMetallicRoughness,name:t.name,extras:t.extras,extensions:t.extensions}))}function GE(e=[]){return e.map(t=>({nodes:t.nodes,extensions:t.extensions,extras:t.extras,name:t.name}))}function jE(e=[]){return e.map(t=>{var r,o,a;const n=(r=t.rotation)!=null?r:[0,0,0,1],i=(o=t.scale)!=null?o:[1,1,1],s=(a=t.translation)!=null?a:[0,0,0];return{camera:t.camera,children:t.children,matrix:t.matrix?l1(...t.matrix):void 0,rotation:G1(...n),scale:at(...i),translation:at(...s),name:t.name,mesh:t.mesh,skin:t.skin,extras:t.extras,extensions:t.extensions}})}function VE(e=[]){return e.map(t=>({bufferView:t.bufferView,mimeType:t.mimeType,name:t.name,uri:t.uri,extensions:t.extensions,extras:t.extras,image:void 0}))}function HE(e=[]){return e.map(t=>({extensions:t.extensions,extras:t.extras,name:t.name,sampler:t.sampler,source:t.source}))}function $E(e=[]){return e.map(t=>({extensions:t.extensions,extras:t.extras,name:t.name,magFilter:t.magFilter,minFilter:t.minFilter,wrapS:t.wrapS,wrapT:t.wrapT}))}function YE(e=[]){return e.map(t=>({joints:t.joints,extensions:t.extensions,extras:t.extras,inverseBindMatrices:t.inverseBindMatrices,name:t.name,skeleton:t.skeleton}))}const ur={JPEG:"image/jpeg",PNG:"image/png",GLTEXTURE:"image/texture"};function vm(e){return e.substring(0,e.lastIndexOf("/")+1)}function WE(e){if(e.startsWith("data:image"))return e.split(";")[0].split(":")[1];switch(e.substring(e.lastIndexOf("."))){case".png":return ur.PNG;case".jpg":case".jpeg":default:return ur.JPEG}}function bm(e){const t=atob(e.split(",")[1]),n=new ArrayBuffer(t.length),i=new Uint8Array(n);for(let s=0;s<t.length;s++)i[s]=t.charCodeAt(s);return n}const Ve=class Ve{constructor(t){this.data=t}static isGlb(t){const n=new Uint32Array(t,0,Ve.glbHeaderInts),i=n[0],s=n[1];return i===this.glbMagic&&s===this.glbVersion}extractGlbData(){if(this.getCheckedGlbInfo()===void 0)return{json:Ad,buffers:[]};let n;const i=[],s=this.getAllChunkInfos();for(const r of s)r.type===Ve.jsonChunkType&&!n?n=this.getJsonFromChunk(r):r.type===Ve.binaryChunkType&&i.push(this.getBufferFromChunk(r));return{json:n||Ad,buffers:i}}getCheckedGlbInfo(){const t=new Uint32Array(this.data,0,Ve.glbHeaderInts),n=t[0],i=t[1],s=t[2];if(!(!this.checkEquality(n,Ve.glbMagic,"glb magic")||!this.checkEquality(i,Ve.glbVersion,"glb header version")||!this.checkEquality(s,this.data.byteLength,"glb byte length")))return{magic:n,version:i,length:s}}getAllChunkInfos(){const t=[];let n=Ve.glbHeaderInts*4;for(;n<this.data.byteLength;){const i=this.getChunkInfo(n);t.push(i),n+=i.length+Ve.glbChunkHeaderInts*4}return t}getChunkInfo(t){const n=new Uint32Array(this.data,t,Ve.glbChunkHeaderInts),i=t+Ve.glbChunkHeaderInts*4,s=n[0],r=n[1];return{start:i,length:s,type:r}}getJsonFromChunk(t){const n=t.length,i=(Ve.glbHeaderInts+Ve.glbChunkHeaderInts)*4,s=new Uint8Array(this.data,i,n),r=new TextDecoder("utf-8").decode(s);return JSON.parse(r)}getBufferFromChunk(t){return this.data.slice(t.start,t.start+t.length)}checkEquality(t,n,i){return t===n?!0:(console.error(`[GLB MODEL PARSING ERROR] Found invalid/unsupported ${i}, expected: ${n}, but was: ${t}`),!1)}};Ve.glbHeaderInts=3,Ve.glbChunkHeaderInts=2,Ve.glbMagic=1179937895,Ve.glbVersion=2,Ve.jsonChunkType=1313821514,Ve.binaryChunkType=5130562;let da=Ve;const Im=5120,ZE=5121,XE=5122,qE=5123,JE=5124,Mm=5125,KE=5126,QE=4,ex="draco_decoder_gltf.js",tx="draco_wasm_wrapper_gltf.js",Tm="draco_decoder_gltf.wasm";let Td;function nx(e){Td=rx(e).catch(t=>{const n="Draco decoder module failed to initialize"+(t!=null&&t.message?` with the following error: ${t.message}`:".");throw new Error(n)})}function ix(e){return Le(this,null,function*(){let t=yield fetch(e).then(s=>s.text());const i=t.indexOf("if (typeof exports === 'object' && typeof module === 'object')");return i!==0&&(t=t.slice(0,i),t=t+"return DracoDecoderModule;"),t})}function sx(e){return Le(this,null,function*(){return fetch(e).then(t=>t.text()).then(t=>t.replace('"object"===typeof exports&&"object"===typeof module?module.exports=DracoDecoderModule:"function"===typeof define&&define.amd?define([],function(){return DracoDecoderModule}):"object"===typeof exports&&(exports.DracoDecoderModule=DracoDecoderModule);',"return DracoDecoderModule;"))})}function rx(e){return Le(this,null,function*(){if(typeof WebAssembly!="object"){const t=yield ix(`${e}/${ex}`);return new Function(t)()()}else return sx(`${e}/${tx}`).then(t=>{const n=new Function(t)();return fetch(`${e}/${Tm}`).then(i=>i.arrayBuffer()).then(i=>n({wasmBinary:i,wasmBinaryFile:Tm}))})})}function ox(e){switch(e){case Im:return"Int8Array";case ZE:return"Uint8Array";case XE:return"Int16Array";case qE:return"Uint16Array";case JE:return"Int32Array";case Mm:return"Uint32Array";case KE:return"Float32Array";default:return"Float32Array"}}function ax(e,t,n,i,s,r){const o=s.num_components(),c=n.num_points()*o;let l,d,u;switch(r){case"Float32Array":u=c*4,l=e._malloc(u),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_FLOAT32,u,l),d=new Float32Array(e.HEAPF32.buffer,l,c).slice(),e._free(l);break;case"Int8Array":l=e._malloc(c),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT8,c,l),d=new Int8Array(e.HEAP8.buffer,l,c).slice(),e._free(l);break;case"Int16Array":u=c*2,l=e._malloc(u),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT16,u,l),d=new Int16Array(e.HEAP16.buffer,l,c).slice(),e._free(l);break;case"Int32Array":u=c*4,l=e._malloc(u),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT32,u,l),d=new Int32Array(e.HEAP32.buffer,l,c).slice(),e._free(l);break;case"Uint8Array":l=e._malloc(c),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT8,c,l),d=new Uint8Array(e.HEAPU8.buffer,l,c).slice(),e._free(l);break;case"Uint16Array":u=c*2,l=e._malloc(u),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT16,u,l),d=new Uint16Array(e.HEAPU16.buffer,l,c).slice(),e._free(l);break;case"Uint32Array":u=c*4,l=e._malloc(u),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT32,u,l),d=new Uint32Array(e.HEAPU32.buffer,l,c).slice(),e._free(l);break;default:throw new Error("DRACOLoader: Unexpected attribute type.")}return{name:i,array:d,itemSize:o,componentType:r}}function cx(e,t,n,i,s,r){let o,a;const c=t.GetEncodedGeometryType(n);if(c===e.TRIANGULAR_MESH)o=new e.Mesh,a=t.DecodeBufferToMesh(n,o);else throw new Error("DRACOLoader: Unexpected geometry type.");if(!a.ok()||o.ptr===0)throw new Error("DRACOLoader: Decoding failed: "+a.error_msg());const l={index:null,attributes:{}},d=o.num_points();for(const u in i){let f=Im,h;for(const[p,y]of Object.entries(r))if(p===u){f=s.accessors[y].componentType,h=s.accessors[y].count;break}if(d!==h)throw new Error(`DRACOLoader: Accessor vertex count ${h} does not match draco decoder vertex count  ${d}`);f=ox(f);const g=t.GetAttributeByUniqueId(o,i[u]),w=ax(e,t,o,u,g,f);l.attributes[w.name]=w}if(c===e.TRIANGULAR_MESH){const f=o.num_faces()*3,h=f*4,g=e._malloc(h);t.GetTrianglesUInt32Array(o,h,g);const w=new Uint32Array(e.HEAPU32.buffer,g,f).slice();e._free(g),l.index={array:w,itemSize:1}}return e.destroy(o),l}function lx(e,t,n,i){const s=e.bufferView,r=t.bufferViews[s],o=t.buffers[r.buffer],c=new Int8Array(o.buffer).slice(r.byteOffset,r.byteOffset+r.byteLength),l=new n.Decoder,d=new n.DecoderBuffer;d.Init(c,r.byteLength);const u=cx(n,l,d,e.attributes,t,i);return n.destroy(d),u}function on(e,t,n,i,s){const r={buffer:e,byteLength:e.byteLength,extensions:void 0,extras:void 0,name:void 0,uri:void 0};t.buffers.push(r);const o={buffer:t.buffers.length-1,byteLength:e.byteLength,byteOffset:0,byteStride:0,extensions:void 0,extras:void 0,name:s,target:i};t.bufferViews.push(o),t.accessors[n].byteOffset=0,t.accessors[n].bufferView=t.bufferViews.length-1}function xn(e,t){let n;switch(t){case"Int8Array":n=new ArrayBuffer(e.length),new Int8Array(n).set(e);break;case"Uint8Array":n=new ArrayBuffer(e.length),new Uint8Array(n).set(e);break;case"Int16Array":n=new ArrayBuffer(e.length*2),new Int16Array(n).set(e);break;case"Uint16Array":n=new ArrayBuffer(e.length*2),new Uint16Array(n).set(e);break;case"Int32Array":n=new ArrayBuffer(e.length*4),new Int32Array(n).set(e);break;case"Uint32Array":n=new ArrayBuffer(e.length*4),new Uint32Array(n).set(e);break;default:case"Float32Array":n=new ArrayBuffer(e.length*4),new Float32Array(n).set(e);break}return n}function dx(e,t,n,i){const s=t.index.array;if(i!==void 0&&(on(s,e,i,34963,"index buffer view"),e.accessors[i].componentType=Mm),t.attributes.POSITION!==void 0){const r=xn(t.attributes.POSITION.array,t.attributes.POSITION.componentType);on(r,e,n.POSITION,34962,"position buffer view")}if(t.attributes.NORMAL!==void 0){const r=xn(t.attributes.NORMAL.array,t.attributes.NORMAL.componentType);on(r,e,n.NORMAL,34962,"normal buffer view")}for(let r=0;r<QE;++r){const o=`TEXCOORD_${r}`;if(t.attributes[o]!==void 0){const a=xn(t.attributes[o].array,t.attributes[o].componentType);on(a,e,n[o],34962,`${o} buffer view`)}}if(t.attributes.TANGENT!==void 0){const r=xn(t.attributes.TANGENT.array,t.attributes.TANGENT.componentType);on(r,e,n.TANGENT,34962,"Tangent buffer view")}if(t.attributes.COLOR_0!==void 0){const r=xn(t.attributes.COLOR_0.array,t.attributes.COLOR_0.componentType);on(r,e,n.COLOR_0,34962,"color buffer view")}if(t.attributes.JOINTS_0!==void 0){const r=xn(t.attributes.JOINTS_0.array,t.attributes.JOINTS_0.componentType);on(r,e,n.JOINTS_0,34963,"JOINTS_0 buffer view")}if(t.attributes.WEIGHTS_0!==void 0){const r=xn(t.attributes.WEIGHTS_0.array,t.attributes.WEIGHTS_0.componentType);on(r,e,n.WEIGHTS_0,34963,"WEIGHTS_0 buffer view")}if(t.attributes.JOINTS_1!==void 0){const r=xn(t.attributes.JOINTS_1.array,t.attributes.JOINTS_1.componentType);on(r,e,n.JOINTS_1,34963,"JOINTS_1 buffer view")}if(t.attributes.WEIGHTS_1!==void 0){const r=xn(t.attributes.WEIGHTS_1.array,t.attributes.WEIGHTS_1.componentType);on(r,e,n.WEIGHTS_1,34963,"WEIGHTS_1 buffer view")}}function ux(e,t){return Le(this,null,function*(){var n;if(!Array.isArray(e.meshes))return Promise.resolve();for(const i of e.meshes)if(Array.isArray(i.primitives))for(const s of i.primitives){if(((n=s.extensions)==null?void 0:n.KHR_draco_mesh_compression)===void 0)continue;Td||nx(t);const r=yield Td;if(!r)continue;const o=lx(s.extensions.KHR_draco_mesh_compression,e,r,s.attributes);dx(e,o,s.attributes,s.indices)}})}function Sd(e){return Le(this,null,function*(){const t=yield self.fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}: ${t.url}`);return t})}const Ad={asset:{version:""}};function fx(e,t){return Le(this,null,function*(){if(t){e.buffers[0].buffer=t[0]||[];return}yield Promise.all(e.buffers.map(n=>Le(null,null,function*(){if(n.buffer){console.error("Buffer is already loaded");return}if(!n.uri){console.error("Buffer can not be loaded. No uri");return}if(n.uri.startsWith("data:"))n.buffer=bm(n.uri);else{const i=Tn(n.uri)?n.uri:vm(e.path)+n.uri,s=yield Sd(i).then(r=>r.arrayBuffer());n.buffer=s}})))})}function hx(e,t,n){return Le(this,null,function*(){var o;if(!t.bufferView)return!1;const i=e.bufferViews[t.bufferView];if(i===void 0)return!1;yield n;const s=e.buffers[i.buffer].buffer;if(!s)return!1;const r=new Uint8Array(s,i.byteOffset,i.byteLength);if(typeof createImageBitmap!="undefined")if(gx(r)){const a=new Blob([r],{type:t.mimeType});t.image=yield createImageBitmap(a)}else return console.error(`Unsupported image type ${(o=t.mimeType)!=null?o:""}`),!1;else return!1;return!0})}function px(e,t){return Le(this,null,function*(){if(t.uri===void 0)return!1;const n=t.mimeType||WE(t.uri);if(t.mimeType=n,typeof createImageBitmap!="undefined"&&(n===ur.JPEG||n===ur.PNG))if(t.uri.startsWith("data:image")){const i=bm(t.uri);t.image=yield createImageBitmap(new Blob([i],{type:n}))}else{const i=Tn(t.uri)?t.uri:`${vm(e.path)}${t.uri}`,r=yield(yield Sd(i)).arrayBuffer();t.image=yield createImageBitmap(new Blob([r],{type:n}))}else return console.error(`Unsupported image type ${n}`),!1;return!0})}function mx(e,t){return Le(this,null,function*(){yield Promise.all(e.images.map(n=>Le(null,null,function*(){if(n.image){n.mimeType!==ur.GLTEXTURE&&console.error("Image has already been loaded");return}(yield hx(e,n,t))||(yield px(e,n))||console.error(`Was not able to resolve image with uri ${n.uri}`)})))})}function yx(e,t){return Le(this,null,function*(){const n=Sy(e,self.origin);try{const i=yield Sd(n);let s=Ad,r;try{const o=yield i.arrayBuffer();if(da.isGlb(o)){const f=new da(o).extractGlbData();s=f.json,r=f.buffers}else{const u=new TextDecoder("utf-8"),f=new Uint8Array(o);s=JSON.parse(u.decode(f))}const a=OE(s,n),c=fx(a,r),l=mx(a,c),d=ux(a,t);return yield Promise.all([c,l,d]),{type:"ok",result:a}}catch(o){return{type:"error",layer:"parsing",originalError:o}}}catch(i){return{type:"error",layer:"network",originalError:i}}})}function gx(e){const t=e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10,n=e[0]===255&&e[1]===216&&e[2]===255;return t||n}class wx{loadModel(t,n){return Le(this,null,function*(){return yield yx(t,n)})}}class vx{constructor(t,n){this.scope=t,this.options=n,this.tileLoader=new cd("arrayBuffer"),this.tiles=new Map,this.url=i=>{const[s,r,o]=Ur(i);return th(this.options,s,r,o,this.options.tileSet)}}abortTileFetches(t){this.tileLoader.abortRequests(t.map(xe))}deleteTiles(t){t.forEach(n=>this.tiles.delete(xe(n)))}generateTile(t,n){return Le(this,null,function*(){const i=[],s=[],r=xe(n),o=this.tiles.get(r);if(!o)return Promise.resolve({results:i,transferable:s,minZ:0,maxZ:0,tree:null});const a=l2(o);do Ct.generateMeshElevation(this.scope.collector,a,t,ks);while(this.scope.collector.isOverloaded());const c=this.scope.collector.getAccumulatedData();this.scope.resetCollector();const l=o2(c.data);return i.push({regionId:0,metatileHash:-1,styleId:t,collectorOutput:c}),s.push(...c.transferable),l&&s.push(l),Promise.resolve({results:i,tree:l,transferable:s,minZ:a.minZ,maxZ:a.maxZ})})}fetchTiles(t){return t.map(n=>this.fetchTile(n))}setOptions(t){this.options=t}fetchTile(t){const n=xe(t),i=[{regionId:0,metatileHash:-1}];if(this.tiles.has(n))return Promise.resolve(i);const s=this.url(t);return this.tileLoader.fetch(t,()=>s).then(r=>(r.rejected||this.tiles.set(n,r.data&&r.data.byteLength?r.data:void 0),i),()=>Promise.resolve(void 0))}}const bx=1246122573,Ix=1,Mx=3,Ed=2048*1024;var ua=(e=>(e[e.Magic=0]="Magic",e[e.Version=4]="Version",e[e.FrameMailbox=8]="FrameMailbox",e[e._Size=16]="_Size",e))(ua||{});const Tx=16+Mx*Ed;var xd=(e=>(e[e.Magic=0]="Magic",e[e.FrameId=4]="FrameId",e[e.CreateTime=8]="CreateTime",e[e.SubmitTime=16]="SubmitTime",e[e.CommandCount=24]="CommandCount",e[e._Size=28]="_Size",e))(xd||{});function Sx(e){e[0]=bx,e[1]=Ix,e[2]=0}function Sm(e,t,n){if(typeof SharedArrayBuffer!="undefined"&&e.buffer instanceof SharedArrayBuffer)return Atomics.exchange(e,t>>2,n);const i=t>>2,s=e[i];return e[i]=n,s}var Am=(e=>(e[e.WebGPU=0]="WebGPU",e))(Am||{}),_d=(e=>(e[e.WebGPU=0]="WebGPU",e))(_d||{}),fa=(e=>(e[e.Test=0]="Test",e))(fa||{}),xi=(e=>(e[e.Vertex=0]="Vertex",e[e.Fragment=1]="Fragment",e))(xi||{});function Em(e,t,n){const i=JSON.stringify(n!=null?n:{});return`${e}:${t}:${i}`}const Ax=`/**
 * Test vertex shader
 * Простой треугольник для проверки работы WebGPU pipeline
 */

@vertex
fn main(@builtin(vertex_index) vertexIndex: u32) -> @builtin(position) vec4f {
    var positions = array<vec2f, 3>(
        vec2f(0.0, 0.5),
        vec2f(-0.5, -0.5),
        vec2f(0.5, -0.5)
    );
    return vec4f(positions[vertexIndex], 0.0, 1.0);
}
`,Ex=`/**
 * Test fragment shader
 * Красный цвет для проверки работы WebGPU pipeline
 */

@fragment
fn main() -> @location(0) vec4f {
    return vec4f(1.0, 0.0, 0.0, 1.0); // Red color
}
`,xm=new WeakMap;function _m(e){let t=xm.get(e);return t||(t=new Map,xm.set(e,t)),t}const xx={[fa.Test]:{[xi.Vertex]:Ax,[xi.Fragment]:Ex}};function Pm(e,t,n){const i=xx[e];if(!i)throw new Error(`No shaders registered for material type: ${e}`);const s=i[t];if(!s)throw new Error(`No ${t} shader for material type: ${e}`);return s}function Lm(e,t,n){return e.createShaderModule({label:n,code:t})}function _x(e,t,n={}){const i=_m(e),s=Em(t,xi.Vertex,n);let r=i.get(s);if(!r){const o=Pm(t,xi.Vertex);r=Lm(e,o,`${t} vertex shader`),i.set(s,r)}return r}function Px(e,t,n={}){const i=_m(e),s=Em(t,xi.Fragment,n);let r=i.get(s);if(!r){const o=Pm(t,xi.Fragment);r=Lm(e,o,`${t} fragment shader`),i.set(s,r)}return r}class Lx{}class Dx extends Lx{constructor(){super(...arguments),this.renderFamily=Am.WebGPU,this.pipeline=null}drawFrame(t,n,i){const{device:s,format:r,context:o}=n;if(this.pipeline||(this.pipeline=s.createRenderPipeline({layout:"auto",vertex:{module:_x(s,fa.Test),entryPoint:"main"},fragment:{module:Px(s,fa.Test),entryPoint:"main",targets:[{format:r}]},primitive:{topology:"triangle-list"}})),t.byteLength===0)return;const a=s.createCommandEncoder(),c=a.beginRenderPass({colorAttachments:[{view:o.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});c.setPipeline(this.pipeline),c.draw(3),c.end(),s.queue.submit([a.finish()])}}class Ox{constructor(t,n,i){this.frameReadSlot=2,this.lastFrameId=0,this.renderLoop=()=>{this.frameReadSlot=Sm(this.transportI32,ua.FrameMailbox,this.frameReadSlot);const s=ua._Size+this.frameReadSlot*Ed,r=this.transportU32[s+xd.FrameId>>2];if(r<this.lastFrameId){this.renderLoop();return}this.lastFrameId=r,this.render.drawFrame(this.transportBuffer,this.webGPUState,this.frameReadSlot),this.requestedFrame=self.requestAnimationFrame(this.renderLoop)},this.canvasSize={width:1,height:1,pixelRatio:1},this.webGPUState=n,this.requestedFrame=0,this.render=this.createRender(t),this.transportBuffer=i,this.transportI32=new Int32Array(i),this.transportU32=new Uint32Array(i)}resize(t,n,i){if(this.canvasSize.width===t&&this.canvasSize.height===n&&this.canvasSize.pixelRatio===i)return;this.canvasSize.width=t,this.canvasSize.height=n,this.canvasSize.pixelRatio=i;const s=Math.floor(t*i),r=Math.floor(n*i),o=this.webGPUState.canvas;o.width!==s&&(o.width=s),o.height!==r&&(o.height=r)}start(){this.requestedFrame===0&&(this.requestedFrame=self.requestAnimationFrame(this.renderLoop))}stop(){this.requestedFrame!==0&&(self.cancelAnimationFrame(this.requestedFrame),this.requestedFrame=0)}destroy(){}createRender(t){switch(t){case _d.WebGPU:return new Dx;default:throw new Error(`Unknown backend: ${t}`)}}}function Fx(e){return Le(this,null,function*(){if(!navigator.gpu)throw new Error("WebGPU is not available in this environment");const t=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("Failed to acquire WebGPU adapter");const n=yield t.requestDevice(),i=e.getContext("webgpu");if(!i)throw new Error("Failed to acquire WebGPU canvas context");const s=navigator.gpu.getPreferredCanvasFormat();return i.configure({device:n,format:s}),{canvas:e,device:n,context:i,format:s}})}function Dm(e,t,n){return Le(this,null,function*(){const i=yield Fx(t);return new Ox(e,i,n)})}function Cx(e,t,n){return Le(this,null,function*(){const i=yield Dm(e,t,n);return Jp(i)})}class Rx{constructor(t){this.map=(t==null?void 0:t.map)||{}}set(t,n,i){this.map[t]===void 0&&(this.map[t]={}),this.map[t][n]=i}get(t,n){const i=this.map[t];if(i!==void 0)return i[n]}has(t,n){const i=this.map[t];return i===void 0?!1:i[n]!==void 0}reduce(t,n){return Object.values(this.map).reduce((i,s)=>Object.values(s).reduce((r,o,a,c)=>t(r,o,a,c),i),n)}}const Nx=17,ha=6;class kx{constructor(){this.name="",this.range="",this.glyphs={}}}class Bx{constructor(){this.id=0,this.range=0,this.bitmap=null,this.top=0,this.left=0,this.advance=0,this.x=0,this.y=0,this.width=0,this.height=0,this.texTop=0,this.texLeft=0,this.texRight=0,this.texBottom=0}}class Ux{constructor(t,n){this.stacks=t.readFields(zx,[],n)}}function zx(e,t,n){if(e===1){const i=n.readMessage(Gx,new kx);t.push(i)}}function Gx(e,t,n){switch(e){case 1:t.name=n.readString();break;case 2:t.range=n.readString();break;case 3:{const i=n.readMessage(jx,new Bx);t.glyphs[i.id]=i;break}}}function jx(e,t,n){switch(e){case 1:t.id=n.readVarint(),t.range=vc(t.id);break;case 2:t.bitmap=n.readBytes();break;case 3:t.width=n.readVarint()+ha;break;case 4:t.height=n.readVarint()+ha;break;case 5:t.left=n.readSVarint()-ha/2;break;case 6:t.top=n.readSVarint()+Nx+ha/2;break;case 7:t.advance=n.readVarint();break}}class Vx{constructor(t,n,i){const s=[];let r=0;for(let o=0;o<t.length;o++){const a=t.charCodeAt(o),c=n&&n[a];c?(s.push(c),r=r+c.advance):a!==Ut.bomCharCode&&lw(t[o],a)}this.glyphs=s,this.width=r+Ut.baseSize*i*(t.length-1)}}function Hx(e,t,n){const i={lines:[],maxWidth:0},s=e.split(`
`);for(let r=0;r<s.length;r++){const o=new Vx(s[r],n,t);i.lines.push(o),o.width>i.maxWidth&&(i.maxWidth=o.width)}return i}function $x(e,t,n){for(const i of t)if(!n.has(e,i))return!1;return!0}function Yx(e,t,n){if(e===void 0)return;const i=lt(e,t);if(i!=="")return n.fontNameToIndex[i]===void 0?Li:i}function Wx(e){const t=new Ux(new Fr(new Uint8Array(e))).stacks[0].glyphs,{width:n,height:i}=Zx(t);Xx(t,n,i);const s=qx(t,n,i);return{glyphData:t,bitmap:s,width:n,height:i}}function Zx(e){const t=[],n=new wt(512,512,{autoResize:!0}),i=Object.keys(e);for(let s=0;s<i.length;s++){const r=e[Number(i[s])];r.bitmap&&t.push({glyph:r,width:r.width,height:r.height})}n.pack(t,{inPlace:!0}),n.shrink();for(let s=0;s<t.length;s++){const r=t[s].glyph;r.x=t[s].x,r.y=t[s].y}return{width:cu(n.w),height:cu(n.h)}}function Xx(e,t,n){const i=Object.keys(e);for(let s=0;s<i.length;s++){const r=e[Number(i[s])];r.bitmap&&(r.texTop=At(r.y/n),r.texLeft=At(r.x/t),r.texBottom=At((r.y+r.height)/n),r.texRight=At((r.x+r.width)/t))}}function qx(e,t,n){const i=new Uint8Array(t*n),s=Object.keys(e);for(let r=0;r<s.length;r++){const o=e[Number(s[r])];if(o.bitmap)for(let a=0;a<o.height;a++){const c=t*(o.y+a)+o.x,l=o.width*a;for(let d=0;d<o.width;d++)i[c+d]=o.bitmap[l+d]}}return i.buffer}function Jx(e){let t=!1,n;return function(...i){return t||(t=!0,n=e.apply(this,i)),n}}m.processRTLTextIfNeeded=e=>e,m.markAsReady=null,m.rtlAdapterReady=!1;const Kx=new Promise(e=>{m.markAsReady=()=>{m.rtlAdapterReady=!0,e()}}),Qx=new Set(["ar"]);function Om(e,t){return e==="always-on"||e==="depends-on-language"&&Qx.has(t)}function e_(e,t,n){const i=t.workers.labeling;function s(){i.markRtlPluginLoaded().then(()=>{m.markAsReady!==null&&m.markAsReady()})}return Om(e.scenario,n)?fetch(e.url,{integrity:e.hash}).then(r=>r.text()).then(r=>Promise.all([i.loadRtlPlugin(r),Promise.resolve(Fm(r))])).catch(r=>{s();const o=new Error,a="[RTL Plugin]: loading failed.";throw o.message=t_(r)?`${a} ${r.message}`:a,o}):(s(),Promise.resolve())}const Fm=Jx(function(e){new Function(e)(),m.processRTLTextIfNeeded=self.mapglRtlPlugin.processRtl,m.markAsReady&&m.markAsReady()});function t_(e){return typeof e=="object"&&!!e&&"message"in e}m.ArrowGenerator=$s,m.BBoxType=Rt,m.BLEND_EQUATION=uM,m.BLEND_FUNC=dM,m.BaseTileLoader=cd,m.Buffer=Ze,m.BufferChannel=d0,m.BuildingModelGenerator=wn,m.CULL_FACE_MODE=lM,m.Camera=ws,m.CircleMarkerGenerator=oo,m.ClassRegistry=eE,m.Collector=kA,m.DEFAULT_EMPTY_KEY=Cd,m.DEFAULT_FONT=Li,m.DEFAULT_FRAME_SIZE=Ed,m.DEFAULT_ID_SCOPE=_l,m.DEFAULT_LIGHTING_MODES=UA,m.DEFAULT_MAPGL_STYLE=Hm,m.DEFAULT_MIN_TIERS_STYLE_ZOOM=ou,m.DEFAULT_MODELS_APPEAR_STRATEGY=Fd,m.DEM_ELEVATION_TILE_SIZE=r2,m.DEM_STYLE_LAYER_ID=ks,m.DEM_TILE_URL_FUNCTION=th,m.DEM_TREE_SIZE=eh,m.DEPTH_FUNC=h0,m.DYNAMIC_MODEL_ID_SCOPE=WI,m.DYNAMIC_STYLE_ID=Uo,m.DashedLineGenerator=gn,m.DemGenerator=Ct,m.Differ=mp,m.DynamicStyle=$M,m.EARTH_CIRCUMFERENCE=ka,m.EMPTY_FEATURE_COLLECTION=Wo,m.EMPTY_SHADER_DEFINITIONS=Fl,m.ENVIRONMENT_STYLE_LAYER_ID=Nc,m.Ecef=tt,m.Evented=tc,m.FLOOR_ID_SCOPE=YI,m.FnRegistry=QA,m.FrameHeader=xd,m.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL=Wl,m.GLOBE_TEXTURE_SIZE=Zm,m.GL_TRIANGLES=pr,m.GeoJsonSource=vp,m.GeoJsonSourceCore=hp,m.GeoJsonSourceWorker=DE,m.GeoJsonTileSource=LS,m.GeoJsonViewportSource=DS,m.GlobeGenerator=sr,m.GltfDemPosition=Gh,m.GltfModelGenerator=Wn,m.HALF_WORLD_SIZE=2147483648,m.HandyIndexer=Pl,m.HeatmapGenerator=Ii,m.HideLevel=Qi,m.INVALID_FRAMEBUFFER_ID=Wr,m.INVALID_IDENTIFY_CENTER_COORD=ga,m.IdScope=ZI,m.LABELING_TEXTURE_BACKGROUND_COLOR=CA,m.LABELING_TEXTURE_DEM_MESH_COLOR=RA,m.LATEST_TILE_VERSION=wm,m.LRU=X0,m.LabelGeometryType=wi,m.LabelIndex=dl,m.LabelSource=Ws,m.LabelingAnimation=o0,m.LabelingElementType=Ye,m.LabelingTileElement=po,m.LengthUnits=Un,m.LineExtrusionGenerator=vn,m.LineGenerator=dt,m.LinePatternType=Sl,m.MAP_DEFAULTS=va,m.MAP_MESH_TEXTURE_INDEX=Fy,m.MAP_POINTS_IN_METER=Ie,m.MODELS_TILES_VIEWPORT_PADDING=Ym,m.MainConnector=JA,m.MapMeshGenerator=Ki,m.Mercator=oe,m.MeshElevationWorker=vx,m.MeshFillSide=ne,m.MeshGenerator=K,m.ModelStepSource=Mi,m.ModelsWorker=wx,m.PBR_TEXTURE_INDEX=Oy,m.POINT_CENTER_SIZE=wa,m.PolygonExtrusionGenerator=Vn,m.PolygonGenerator=Wt,m.PreLabelType=bn,m.RasterGenerator=co,m.RasterSetType=bi,m.RenderBackendType=_d,m.ReservedLightingMode=Fs,m.SIMPLE_MESH_STYLE_LAYER_ID=zM,m.SceneObjectType=uc,m.Shader=zo,m.ShaderAttribute=Cg,m.TEXTURE_COORDS_TO_WEBGL=y1,m.TRANSPORT_SIZE=Tx,m.ThreadName=Jn,m.TileLayer=fp,m.TileObject=Vo,m.TileObjectBase=j0,m.TileStatus=Nl,m.TransportHeader=ua,m.TwoKeyMap=Rx,m.UNIVERSE_REGION_ID=Wm,m.UNUSED_STYLE_ID_SHIFT=zA,m.WEBGL_COORDS_TO_TEXTURE=g1,m.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER=zm,m.WorkerConnector=KA,m.ZenithSourceCore=sM,m.ZenithWorker=xA,m.ZoomDirection=Bt,m.add=Gt,m.add$1=ti,m.addGeneratedDataToTileMod=V0,m.adjustGlobeDragSpeed=K1,m.affineStep=Pa,m.allFontGlyphsLoaded=$x,m.applyDefaults=Pn,m.applyStyleOptions=Jb,m.assertUnreachable=Sf,m.atlasSize=cn,m.bezier=R0,m.bindUrl=Ty,m.buildingAnimation=Vd,m.calcAngle=yy,m.calcMidpoint=gy,m.center=_r,m.cityCommPoiLabelingConfig=$d,m.clamp=Te,m.clampLat=iy,m.clampPoint=ny,m.clone=i1,m.clone$1=L1,m.commPoiLayers=u0,m.commercialPoi=ba,m.compare=kr,m.compileRtlPlugin=Fm,m.componentTypeToWebGl=Rg,m.contains=sy,m.convertStyleLayerTypeToHandy=Ov,m.coordsToKey=xe,m.copy=c1,m.copy$1=Su,m.copy$2=Ga,m.copy$3=vr,m.create=vs,m.create$1=yt,m.create$2=pu,m.create$3=gs,m.create$4=Fe,m.createGeoJsonMetatile=em,m.createGridState=ep,m.createLoadedRasterSet=bb,m.createMetatile=ku,m.createObjectAttributesArray=Ce,m.createRemoteRenderRunner=Cx,m.createRenderRunner=Dm,m.createTileInfo=ct,m.cross=ms,m.debounce=yp,m.decomposeMat4=Iy,m.deepEqual=Di,m.defaultCameraConfig=zt,m.defaultLang=Wd,m.defaultMarkerAnchor=ru,m.defaultMarkerIcon=su,m.defaultModelsPath=ma,m.defaultShadowsSettings=au,m.degToRad=be,m.dem=Nd,m.dist=On,m.dist$1=Va,m.distance=fs,m.dot=ja,m.dot$1=Dn,m.dracoDecoderUrl=Um,m.drawIdentifyScene=YM,m.earcut=bd,m.ease=k0,m.emptyFeatureAttrs=Bu,m.emptySourceAttrs=Qa,m.entranceAnimation=Hd,m.equalArrays=Qm,m.equalSets=Km,m.equals=W1,m.equals$1=a1,m.events=Gd,m.exactEquals=m1,m.exactEquals$1=Ir,m.exactEquals$2=B1,m.excludeItemFromArray=e1,m.exist=U0,m.expandByPoint=ri,m.expose=dd,m.expressionValues=pi,m.findVisibleTiles=qu,m.finishStyleUpdatingAction=cp,m.fixedMetatile=Py,m.fixedTileProps=oi,m.floors=Aa,m.fonts=Ut,m.forceGlStatusCheck=_0,m.fromGeo=ty,m.fromRotationTranslationScale=h1,m.fromScaling=f1,m.fromTranslationScale=Tr,m.fromValues=at,m.fromValues$1=Da,m.generalize=yb,m.generateHaltonSequence=hw,m.generateHandyLayers=xl,m.generateIconElement=fl,m.generateNotStretchableIconElement=Sb,m.generatePointsOnSphere=pw,m.generateSafely=a0,m.generateTextElement=go,m.generateTileBounds=x0,m.geoJsonMetatileHash=Od,m.geoLineDistance=M1,m.geoPointsDistance=Ua,m.geoToMapDistance=xr,m.get=kT,m.getArrayBuffer=Zo,m.getBoundsTileCoords=Pg,m.getCenterCorrection=J1,m.getClosestPointOnLineSegment=tg,m.getColorForShaders=mv,m.getElevationFromTile=a2,m.getFontNameWithFallback=Yx,m.getFontUrl=Yb,m.getFractionalPart=Jm,m.getJson=bp,m.getLabelingInfo=GI,m.getLayerImageProps=b0,m.getLineConstants=ai,m.getMetersFromPixelsXY=ey,m.getModelUrl=Wb,m.getPixelsPerMeter=Vr,m.getPoiIconData=iI,m.getRandomValue=Os,m.getRawMemoryStats=xS,m.getSizeDependentImageUrl=Bh,m.getStaticIconRasterSetKey=Vi,m.getStaticTextureRasterSetKey=$r,m.getStyleUrl=Kb,m.getStyleZoom=xu,m.getSubdomainFromString=Ka,m.getSymbolLayers=L0,m.getTextMetrics=Hx,m.getTierFromLevels=II,m.getTileBounds=Rr,m.getTileCoordsByCenterAndZoom=lc,m.getTileModToGenerate=Z0,m.getTilesToAbortFetch=J0,m.getTilesToFetch=q0,m.getTilesToGenerate=K0,m.getTilesToRemove=Q0,m.getTotalMemory=Yl,m.getTriple=wr,m.getUrl=Is,m.getUrlForIconMapIcon=ml,m.getUrlFromTemplate=Ms,m.getVisibleMapReplicas=Lg,m.getZoomFromStyleZoom=Q1,m.globeConfig=_n,m.globeTileScale=b1,m.handyColor=Ds,m.hashToString=Ru,m.heightToZoom=w1,m.icons=Ud,m.identify=Ta,m.identity=Fa,m.index=Xm,m.inertia=Sa,m.inferGeneratorType=Ng,m.initTransportHeader=Sx,m.int64ToString=t0,m.intersection=oy,m.intersection$1=HI,m.invert=hs,m.isArrayOfNumbers=un,m.isBetween=La,m.isCommercialCityPoi=Ch,m.isCommercialModel=jb,m.isCommercialPoi=_o,m.isCommercialPoi$1=vi,m.isCommercialPoiCity=lb,m.isCommercialPoiLabel=Zs,m.isCommercialPoiPremium=db,m.isCommercialPremiumPoi=Rh,m.isExtractableHandyExpression=Qg,m.isHandyExpression=tn,m.isHandySimpleType=pf,m.isInt64=LI,m.isLatValid=ry,m.isLineStyleLayer=T2,m.isNullVector=my,m.isNullish=t1,m.isObject=n1,m.isPersonalPoi=Gb,m.isRtlPluginRequired=Om,m.isStyleColor=ui,m.isStyleGradient=yc,m.isStyleId=_v,m.isStyleLayerHidable=Dv,m.isStyleLayerType=Lv,m.isStyleMixColor=tw,m.isTileOnSphereInViewport=Gr,m.isTileVisible=Nr,m.isTilesIntersects=yg,m.isTypedArray=rI,m.keyServerPath=as,m.keyToCoords=oc,m.labeling=yr,m.len=hu,m.len$1=Ar,m.length=Fn,m.lerp=ni,m.lerp$1=Y1,m.lerp$2=Oi,m.limitString=cw,m.linePatternFromString=r0,m.linear=N0,m.loadModelsInfoStyleZoom=Ia,m.log=ke,m.logEmptyTileGenerationResponse=bf,m.logGltfError=dw,m.lookAt=Na,m.mailboxSwap=Sm,m.makeBinderContext=Ff,m.makeGeneratorContext=Cs,m.makeHandyDemLayer=Ol,m.makeHandyGroupOrLayer=g0,m.makeHandyLightStyle=M0,m.makeHandyRasterSet=v0,m.makeHandyRasterSets=w0,m.makeHandyStyle=RM,m.makeHandyStyleLayer=Bo,m.makeLabelingContext=Vt,m.mapHeightToTileHeight=nt,m.mapPointPitch=E1,m.mapPointTo32ZoomTileCoords=_g,m.mapPointToTilePoint=Pt,m.mapToPixelDistance=A1,m.maxTilePoint=te,m.maxU32=Gm,m.maxUint16Value=Ge,m.metricsTimeout=Kd,m.modStatsGpu=$l,m.modStatsJs=Hl,m.modelCacheSize=kd,m.modelSizeGpu=AS,m.modelSizeJs=SS,m.models=Rd,m.mul=Z1,m.mul$1=Ci,m.multiply=Ca,m.newFrameAction=sp,m.normalize=qt,m.normalize$1=Ln,m.normalizeMapPoint=_1,m.normalizeMousePosition=qm,m.optionsToTileAttrs=E0,m.ortho=p1,m.overlappedGroupName=zn,m.packTexCoords=At,m.performanceCheck=Jd,m.pixelRatioToDpi=xc,m.pixelToMapDistance=vu,m.pixelsAndMapDistanceToZoom=bu,m.pointToLineDistance=qy,m.pointToLineSignedDistance=Vu,m.preLabelingPoint=kh,m.prepareMetatile=Nu,m.processElement=zI,m.processFont=Wx,m.projectToXyRect=My,m.radToDeg=Qn,m.rbush=Kr,m.removeUndefined=Uw,m.renameZenithEnumerationValues=iM,m.render=Yd,m.reserveTextureIndex=ic,m.reset=$a,m.resetGridState=zl,m.resolveAnimationExpression=_f,m.resolveColor=jn,m.resolveExpression=$,m.resolveGradient=hv,m.resolveLightingModes=yv,m.resolveNumber=ae,m.resolveSimpleLiteralExpression=it,m.resolveString=lt,m.resolveTextureAnimationExpression=Pf,m.rotateVec2=wy,m.rotateX=R1,m.rotateY=N1,m.rtlAdapterPromise=Kx,m.rtlPluginHash=cs,m.rtlPluginUrl=an,m.runPrecomputes=El,m.sample=Df,m.sampleColor=Of,m.scale=Cn,m.scale$1=ay,m.scale$2=xt,m.scale$3=Fi,m.scale$4=H1,m.selectRaster=Xs,m.set=Oe,m.set$1=j1,m.set$2=d1,m.setSeed=eb,m.setupMapboxRtlAdapterIfNeeded=e_,m.sign=gr,m.slerp=Pr,m.sourceUuid=pp,m.splitPolylineByLength=Qy,m.splitPolylineByMaxSize=eg,m.spreadTileObjects=P0,m.sqrDist=z1,m.start=B0,m.startStyleUpdatingAction=ap,m.stop=Cl,m.stride=rr,m.styles=zd,m.sub=ln,m.sub$1=Jt,m.subtract=jI,m.template=bs,m.tetragonBounds=Cr,m.tetragonIntersectsBounds=Hu,m.textureSizeGpu=MS,m.textureSizeJs=Vl,m.throttle=_A,m.tileCoordOffset=z,m.tileCoordsToMapPoint=zi,m.tileCoordsToOSM=Ur,m.tileHeight=ls,m.tileObjectStatsGpu=up,m.tileObjectStatsJS=dp,m.tilePointScaleFactor=Dt,m.tileSizeZpt=256,m.tileZoomToSize=Lt,m.tiles=Kn,m.toStyleColor=nn,m.traffic=Bd,m.transfer=qp,m.transformMat4=Er,m.transformMat4$1=ys,m.uint16ToTileCoords=Pi,m.uniqId=nc,m.unpackPreLabelingResult=ob,m.update=z0,m.updateScene=np,m.urls=mr,m.vertexTilePointToMapPoint=Qu,m.viewportChangeAction=jl,m.viewportTilesReady=Ul,m.workerResetInterval=jd,m.worldBounds=T1,m.worldLoopBounds=S1,m.worldSize=4294967296,m.worldWrapX=ps,m.wrap=Yp,m.z0Scale=Ld,m.zenithSourceAttrs=Uu,m.zenithToJakartaPropKey=QI,m.zoom=Zd,m.zoomToHeight=Ri,m.zoomToScale=v1,m.zptPerInch=ds,m.zptToSceneDistance=I1}));

_mapgl_d("worker",["./shared"],(function(e){var Qe=Object.defineProperty,Ae=Object.defineProperties;var et=Object.getOwnPropertyDescriptors;var Pe=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var we=Math.pow,Me=(e,B,z)=>B in e?Qe(e,B,{enumerable:!0,configurable:!0,writable:!0,value:z}):e[B]=z,se=(e,B)=>{for(var z in B||(B={}))tt.call(B,z)&&Me(e,z,B[z]);if(Pe)for(var z of Pe(B))nt.call(B,z)&&Me(e,z,B[z]);return e},he=(e,B)=>Ae(e,et(B));"use strict";class B{constructor(t,n,a){this.line=t,this.lengths=[],this.angles=[];let r=n,l=t[0],i=t[1];const f=t.length/3;for(let o=0;o<f;o++){const c=t[o*3]-l,h=t[o*3+1]-i;r+=Math.sqrt(c*c+h*h),this.lengths.push(r),l+=c,i+=h}this.finishLength=this.lengths[this.lengths.length-1],this.startLength=this.lengths[0],this.midLength=a/2,this.vertexCount=f,this.angles.push(0);for(let o=1;o<f;o++){const c=this.line[(o-1)*3],h=this.line[o*3],g=this.line[(o-1)*3+1],m=this.line[o*3+1];this.angles.push(Math.atan2(m-g,h-c))}}interpolate(t,n){const a=n,r=a-1,l=this.lengths[r],i=this.lengths[a],f=this.line[r*3],o=this.line[a*3],c=this.line[r*3+1],h=this.line[a*3+1],g=(t-l)/(i-l);return[(1-g)*f+g*o,(1-g)*c+g*h,0,this.angles[n]]}getSegmentIndex(t){for(let n=0;n<this.lengths.length;n++)if(t<this.lengths[n])return n;return this.lengths.length}}class z{constructor(){this.labels={}}add(t){const n=t.id,a=t.componentDistanceStart;this.labels[n]===void 0&&(this.labels[n]={});const r=this.labels[n];r[a]===void 0&&(r[a]=[]),r[a].push(t)}merge(){const t=[];for(const n in this.labels){const a=this.labels[n],r=Object.keys(a).sort((i,f)=>Number(i)-Number(f));let l=0;for(;l<r.length;){const i=r[l];if(a[i].length===0){l++;continue}const f=[];let o=a[i].pop();for(;o!==void 0;)if(f.push(o),(o.componentDistanceStart!==0||o.componentDistanceEnd!==0)&&a[o.componentDistanceEnd]!==void 0){const c=o;if(o=a[o.componentDistanceEnd].pop(),o){const h=c.mapPointVertices.length;(c.mapPointVertices[h-3]!==o.mapPointVertices[0]||c.mapPointVertices[h-2]!==o.mapPointVertices[1])&&(o=void 0)}}else o=void 0;if(f.length===1){const c=f[0];c.axis=new B(c.mapPointVertices,c.componentDistanceStartWorld,c.objectLengthWorld),t.push(c)}else f.length>1&&t.push(this.stitch(f))}}return t}stitch(t){let n=0;for(let i=0;i<t.length;i++)n+=t[i].mapPointVertices.length;n-=(t.length-1)*3;const a=new Int32Array(n);let r=0;for(let i=0;i<t.length;i++){const f=t[i].mapPointVertices,o=i>0?3:0;for(let c=o;c<f.length;c++)a[r++]=f[c]}const l=t[0];return l.axis=new B(a,l.componentDistanceStartWorld,l.objectLengthWorld),t[0]}}class Ee{constructor(t,n,a,r,l,i,f,o,c,h,g,m){this.type=e.LabelingElementType.Box,this.marginTopBottom=0,this.marginLeftRight=0,this.id=t,this.label={layer:{innerId:0},styleId:-100,id:this.id,symbol:"nevermind",phase:NaN},this.groupPriority=m!=null?m:e.maxU32,this.itemPriority=g!=null?g:1,this.parent=h,this.placementIndex=0,this.labelingGroup=c,this.labelingGroupTable=o.labelingGroups.table,this.anchorWorld=e.create$3(),e.copy$2(this.anchorWorld,r),i!==0&&(this.anchorWorld[2]*=i),this.anchorGeo=e.Mercator.toGeo(this.anchorWorld),this.anchorScreen=f.project(this.anchorGeo),e.add(this.anchorScreen,this.anchorScreen,l),this.boxes=[[0,0,n,a]]}}const ue=e.degToRad(e.labeling.axisAngleToleranceDeg),Ne=e.labeling.axisCheckDistancePx,_e=e.degToRad(e.labeling.lineLabelsHidePitchDeg);function Ce(s,t,n,a,r,l,i,f,o,c,h,g){const m=[],d=[],k=[],E=[],p={},C=Re(s,r),T=new z;for(let D=0;D<s.length;D++){const W=s[D],_=r.get(W);if(_===void 0)continue;const N=t.styleState._activeFloorIds;for(let M=0;M<_.length;M++){const u=_[M];if(u.source===e.LabelSource.Tile&&c.has(u.id)&&!u.floorId||u.floorId&&(u.planLevel=g[u.floorId],!e.isCommercialPoiLabel(u)&&(N.length===0||!N.includes(u.floorId))))continue;const L=a.getStyle(u.styleId);if(!L){console.error(`Not found style ${u.styleId} in labeling#collectLabelingElements`);continue}if(!(u.source!==e.LabelSource.PersonalPoi&&C.personalPoi.has(u.id)&&!e.isCommercialPoiLabel(u))&&!(u.source===e.LabelSource.PersonalPoi&&C.commercialPoi.has(u.id)))switch(u.layer.type){case"point":{if(ge(u,i,f,t.styleState,t.styleZoom,L,h,t.elevation)&&ie(u,t.styleZoom))if(u.geometryType===e.LabelGeometryType.Line)T.add(u);else{const S=[u.mapPointVertices[0],u.mapPointVertices[1],u.mapPointVertices[2],0];ye(E,k,p,u,S,n,t,L,o)}break}case"labelLine":{ge(u,i,f,t.styleState,t.styleZoom,L,h,t.elevation)&&ie(u,t.styleZoom)&&T.add(u);break}case"oneWayLine":ie(u,t.styleZoom)&&T.add(u);break}}}const F=T.merge();for(let D=0;D<F.length;D++){const W=F[D],_=a.getStyle(W.styleId);if(!_){console.error(`Not found style ${W.styleId} in labeling#collectLabelingElements`);continue}W.layer.type==="point"?De(E,k,p,W,_,n,t,o):Fe(d,E,W,_,n,t)}return l.forEach(({id:D,width:W,height:_,position:N,offset:M,labelingGroup:u,parentPoiId:L})=>{let v;if(L&&(v=p[L],!v))return;const S=a.getStyle(e.DYNAMIC_STYLE_ID);if(!S){console.error(`Not found style ${e.DYNAMIC_STYLE_ID} in labeling#collectLabelingElements`);return}const y=new Ee(D,W,_,N,M,t.buildingHeight,n,S,u,v,v==null?void 0:v.itemPriority,v==null?void 0:v.groupPriority);m.push(y)}),{boxElements:m,oneWayTileElements:d,noLabelingElements:k,otherTileElements:E}}function Re(s,t){const n={personalPoi:new Set,commercialPoi:new Set};for(const a of s){const r=t.get(a);if(r!==void 0)for(const l of r)l.source===e.LabelSource.PersonalPoi?n.personalPoi.add(l.id):e.isCommercialPoiLabel(l)&&n.commercialPoi.add(l.id)}return n}function ge(s,t,n,a,r,l,i,f){var E;const{layer:o}=s;if(o.type!=="point"&&o.type!=="labelLine")return!1;Number.isNaN(s.demElevation)?s.elevation=0:s.elevation=(s.demElevation-(f!=null?f:0))*e.MAP_POINTS_IN_METER;const c=e.makeLabelingContext(r,a,!1,s.tileData);if(e.rtlAdapterReady&&!s.rtlProcessed&&(s.label=(E=e.processRTLTextIfNeeded(s.label))!=null?E:"",s.label2=e.processRTLTextIfNeeded(s.label2),s.iconLabel=e.processRTLTextIfNeeded(s.iconLabel),s.updateRanges(),i(e.DEFAULT_FONT,s.ranges),e.expressionValues(o.style.textFont).forEach(p=>{p.length&&i(p,s.ranges)}),o.type==="point"&&o.style.textFont2&&e.expressionValues(o.style.textFont2).forEach(p=>{p.length&&i(p,s.ranges)}),o.type==="point"&&o.style.iconTextFont&&e.expressionValues(o.style.iconTextFont).forEach(p=>{p.length&&i(p,s.ranges)}),s.rtlProcessed=!0),!s.rtlProcessed)return!1;const{ranges:h}=s,g=e.getFontNameWithFallback(o.style.textFont,c,l);let m;if(g&&s.label&&e.allFontGlyphsLoaded(g,h,n)&&(m=e.getTextMetrics(s.label,o.style.textLetterSpacing,t[g]),s.textMetrics=m),o.type==="labelLine")return!g||!!m;const d=e.getFontNameWithFallback(o.style.iconTextFont,c,l);d&&s.iconLabel&&e.allFontGlyphsLoaded(d,h,n)&&(s.iconTextMetrics=e.getTextMetrics(s.iconLabel,o.style.iconTextLetterSpacing,t[d]));const k=e.getFontNameWithFallback(o.style.textFont2,c,l);return g&&s.label&&k&&s.label2&&e.allFontGlyphsLoaded(k,h,n)&&(s.textMetrics2=e.getTextMetrics(s.label2,o.style.textLetterSpacing,t[k])),!g||!s.label?!d||!s.iconLabel||!!s.iconTextMetrics:!!m&&(!d||!s.iconLabel||!!s.iconTextMetrics)&&(!k||!s.label2||!!s.textMetrics2)}function ye(s,t,n,a,r,l,i,f,o){var c;e.getLabelingInfo(a,r,f,a.layer,i,l,o);for(let h=0;h<a.labelingElements.length;h++){const g=a.labelingElements[h];if(g.labelingGroup===e.overlappedGroupName||((c=g.parent)==null?void 0:c.labelingGroup)===e.overlappedGroupName){t.push(g);continue}s.push(g),g.type===e.LabelingElementType.Icon&&(n[g.label.id]=g)}}function De(s,t,n,a,r,l,i,f){const{layer:o}=a;if(o.type!=="point")return;const{zoom:c,styleZoom:h}=i,g=Math.floor(h),m=c+(g-h),{startLength:d,midLength:k,finishLength:E}=a.axis,p=e.makeLabelingContext(g,i.styleState,!1,a.tileData),C=Math.max(e.pixelToMapDistance(e.resolveNumber(o.style.duplicationSpacing,p),m),1),T=e.pixelToMapDistance(o.style.endingOffsets,c),F=d+(k-d)%C,D=d+T,W=E-T;for(let _=F;_<W;_+=C)if(_>D){const N=a.axis,M=_,u=N.getSegmentIndex(M),L=N.interpolate(M,u);ye(s,t,n,a,L,l,i,r,f)}}function Fe(s,t,n,a,r,l){const{layer:i}=n;if(i.type!=="labelLine"&&i.type!=="oneWayLine")return;const{zoom:f,styleZoom:o}=l,c=Math.floor(o),h=f+(c-o),{startLength:g,midLength:m,finishLength:d}=n.axis,k=e.makeLabelingContext(o,l.styleState,!1,n.tileData),E=e.makeLabelingContext(c,l.styleState,!1,n.tileData);let p,C,T,F;if(i.type==="labelLine"){const S=e.resolveNumber(i.style.textFontSize,k)/e.fonts.baseSize,y=e.resolveNumber(i.style.textFontSize,E)/e.fonts.baseSize;p=n.textMetrics.maxWidth*S,C=n.textMetrics.maxWidth*y,T=e.pixelToMapDistance(e.resolveNumber(i.style.textDuplicationSpacing,E),h),F=e.pixelToMapDistance(Math.max(i.style.lineEndingOffsets,i.style.textLabelingSideMargin),f)}else p=e.resolveNumber(i.style.lineLength,k),C=e.resolveNumber(i.style.lineLength,E),T=e.pixelToMapDistance(e.resolveNumber(i.style.duplicationSpacing,E),h),F=e.pixelToMapDistance(i.style.endingOffsets,f);const D=e.pixelToMapDistance(C,h),_=e.pixelToMapDistance(p,f)/2,N=T+D,M=g+(m-g)%N,u=g+_+F,L=d-_-F,v=i.type!=="labelLine"?s:t;for(let S=M;S<L;S+=N)S>u&&We(v,n,S,_,p,r,l,a)}function We(s,t,n,a,r,l,i,f){const o=t.axis,{zoom:c,styleZoom:h}=i,{startLength:g,finishLength:m}=o,d=o.getSegmentIndex(n),k=o.interpolate(n,d);if(e.mapPointPitch(l.position,k,i.center)>_e||!Ze(t,n,a,c,h,i.styleState))return;const p=t.layer.type==="oneWayLine",C=p?e.LabelingElementType.OneWayLine:e.LabelingElementType.LineText,T=new e.LabelingTileElement(t,C,k,i.buildingHeight,l,f,i.globeMode,i.styleState._floorHeight);T.anchorPosition=n,T.anchorSegmentIndex=d,T.halfLabelWidth=a,p||(T.overflowStyleZoom=e.getStyleZoom(e.pixelsAndMapDistanceToZoom(r,m-g),k),Be(T,t,n,a,i,l)),s.push(T)}function Ze(s,t,n,a,r,l){if(s.layer.type==="oneWayLine")return!0;const i=s.axis,f=e.makeLabelingContext(r,l,!1,s.tileData),o=e.resolveNumber(s.layer.style.textFontSize,f)/e.fonts.baseSize,c=i.getSegmentIndex(t-n),h=i.getSegmentIndex(t+n),g=e.pixelToMapDistance(Ne*o,a);for(let m=c;m<h;m++){if(m>1&&me(i.angles[m-1],i.angles[m])>ue)return!1;const d=i.getSegmentIndex(i.lengths[m]-g);if(d!==0){const k=i.angles[d],E=i.angles[i.getSegmentIndex(i.lengths[m]+g)];if(me(k,E)>ue)return!1}}return!0}function me(s,t){const n=Math.abs(s-t);return n>Math.PI?2*Math.PI-n:n}function Be(s,t,n,a,r,l){const{axis:i,layer:f}=t;if(f.type!=="labelLine")return;const{zoom:o,styleZoom:c}=r,h=e.makeLabelingContext(c,r.styleState,!1,t.tileData),g=e.resolveNumber(f.style.textFontSize,h),m=g/2,d=e.pixelToMapDistance(g,o),k=e.pixelToMapDistance(f.style.textLabelingSideMargin,o),E=Math.max(0,n-a+d/2-k),p=Math.min(i.lengths[i.lengths.length-1],n+a-d/2+k);let C=i.getSegmentIndex(E);for(let T=E;T<p;T+=d){for(;i.lengths[C]<T;)C++;de(s,i,T,C,l,m)}for(;i.lengths[C]<p;)C++;de(s,i,p,C,l,m)}function de(s,t,n,a,r,l){const i=r.flat.project(t.interpolate(n,a));i[0]=i[0]-s.anchorScreen[0],i[1]=i[1]-s.anchorScreen[1],s.boxes.push([i[0]-l,i[1]-l,i[0]+l,i[1]+l])}function ie(s,t){const{source:n,detailLevel:a,layer:{minzoom:r,maxzoom:l}}=s,i=n===e.LabelSource.PersonalPoi,f=i||r>a,o=i||l<a+1||a===e.tiles.maxDetailLevel;return(!f||t>=r)&&(!o||t<l)}function Q(s){return typeof s!="boolean"&&s.type==="attrs"}function be(s){return typeof s!="boolean"&&s.type==="unextractable"}function oe(s){if(!e.isHandyExpression(s))return[!!s];let t=[];const n=[];switch(s.type){case"all":const r=s.array.map(oe);for(const f of r){const o=[];for(const c of f){if(c===!1)return[!1];Q(c)?o.push(c):be(c)&&n.push(c)}o.length>0&&(t.length===0?t=o:t=xe(t,o))}break;case"match":if(!e.isExtractableHandyExpression(s.input))return[{type:"unextractable",exp:s}];if(s.input.type==="precompute")return[{type:"unextractable",exp:s}];const l=s.input.property,i=s.defaultOutput;for(const f of s.cases){const o=oe(f.output),c=[];f.values.forEach(h=>{c.push({type:"attrs",attrs:{[l]:h}})});for(const h of o)if(Q(h))for(const g of xe([h],c))t.push(g);else if(be(h)){n.push(h);for(const g of c)t.push(g)}else if(h===!0&&!i)for(const g of c)t.push(g)}break;case"==":{let f,o;if(e.isExtractableHandyExpression(s.leftValue)&&e.isHandySimpleType(s.rightValue))f=s.leftValue.property,o=s.rightValue;else if(e.isExtractableHandyExpression(s.rightValue)&&e.isHandySimpleType(s.leftValue))f=s.rightValue.property,o=s.leftValue;else return[{type:"unextractable",exp:s}];t.push({type:"attrs",attrs:{[f]:o}});break}default:return[{type:"unextractable",exp:s}]}return t.concat(n)}function xe(s,t){const n=[];for(const a of s)for(const r of t)n.push({type:"attrs",attrs:se(se({},a.attrs),r.attrs)});return n}class Ve{constructor(){this.layers=[],this.keyStat={},this.orderedKeys=[],this.tree=null,this.treeNodesCount=0,this.traverseCount=0,this.traverseIterations=0}addLayers(t){for(const n of t)n.type==="custom"||!n.filter||(this.layers.push(n),this.statLayerKeys(n));this.buildTree()}getLayers(t,n){const a=[],r=(l,i)=>{if(this.traverseIterations+=1,!l)return;for(const h of l.leafs)a.push(h);const f=this.orderedKeys[i];if(!f)return;const o=n[t[f]],c=e.isInt64(o)?e.int64ToString(o):o;c!==void 0&&r(l.children[c],i+1),r(l.novalue,i+1)};return this.traverseCount+=1,r(this.tree,0),a}stat(){const t=this.traverseIterations/this.traverseCount||0;return{tree:this.tree,treeNodes:this.treeNodesCount,layers:this.layers.length,keyStat:this.keyStat,itersPerTraverse:t}}statLayerKeys(t){const a=oe(t.filter).filter(r=>Q(r))[0];if(!(!a||!Q(a)))for(const r in a.attrs)this.keyStat[r]===void 0&&(this.keyStat[r]=0),this.keyStat[r]+=1}getOrderedKeys(){return Object.entries(this.keyStat).sort(([n,a],[r,l])=>l-a).map(([n,a])=>n)}buildTree(){this.orderedKeys=this.getOrderedKeys();const t=[];for(const n of this.layers){const r=oe(n.filter).filter(Q);r.length===0&&t.push(n);for(const l of r){const i=new Set(Object.keys(l.attrs));let f=0;const o=l.attrs;let c=this.tree;for(let h=0;h<=this.orderedKeys.length;h++){if(f===i.size){c==null||c.leafs.push(n);break}const g=this.orderedKeys[h],m=this.orderedKeys[h+1]||"";if(c||(c=this.makeTreeNode(g),this.tree===null&&(this.tree=c)),i.has(g)){const d=o[g];c.children[d]||(c.children[d]=this.makeTreeNode(m)),c=c.children[d],f+=1}else c.novalue||(c.novalue=this.makeTreeNode(m)),c=c.novalue}}}t.length>0&&(this.tree||(this.tree=this.makeTreeNode("")),this.tree.leafs=t)}makeTreeNode(t){return this.treeNodesCount+=1,{key:t,children:{},novalue:null,leafs:[]}}}class Le{constructor(){this.metaStyles=new Map,this.layerTrees=new Map}proxySyncStyle(t){const n=new Ve;n.addLayers(t.layers),this.layerTrees.set(t.id,n),this.metaStyles.set(t.id,t),this.removeUnusedStyle(t.id-e.UNUSED_STYLE_ID_SHIFT)}getStyle(t){return this.metaStyles.get(t)}getLayers(t,n,a){const r=this.layerTrees.get(t);return r?r.getLayers(n,a):[]}removeUnusedStyle(t){t<1||(this.metaStyles.delete(t),this.layerTrees.delete(t))}}const Oe=new Map;function ze(s){const t=new e.WorkerConnector(s),n=new e.FnRegistry(t),a=new e.Collector("labeling"),r=new Le,l=n.get(e.ThreadName.Main,"loadFont"),i=new Map,f=new Map;let o=[],c=new Map;const h=new e.TwoKeyMap,g=new e.TwoKeyMap,m={},d=e.throttle(()=>a.reset(),e.workerResetInterval),k=y=>{e.setSeed(y)};n.set("setComPoiRandomSeed",k);const E=()=>{const y=a.getBucketsMemoryFootprint(),b=[];let I=0;Array.from(i.keys()).forEach(x=>{const Z=i.get(x);Z&&(I+=Z.length,b.push({label:{[x]:Z.map(()=>({label:1}))}}))});const P={collector:{buckets:y},labeling:b};return{js:he(se({},P),{"--labelsCount":I,"--sum":e.getTotalMemory(P)})}};n.set("getMemoryFootprint",E);const p=(y,b,I,P,x)=>{const Z=e.unpackPreLabelingResult(I,b,r,P,x);i.set(y,Z)};n.set("appendLabels",p);function C(y,b){for(const I of b)h.has(y,I)||(l(y,I),h.set(y,I,!0))}const T=(y,b)=>{f.set(y,b)};n.set("appendLabelBox",T);const F=y=>{f.delete(y)};n.set("removeEmptyBoxLabel",F);const D=y=>{i.delete(y),f.delete(y)};n.set("removeLabels",D);function W(y,b,I){if(y.has(I.label.sourceId))return e.LabelingAnimation.none;const P=b.get(I.id);return P===void 0||P.placementIndex===void 0||P.type===e.LabelingElementType.Icon&&P.layer.innerId!==I.layer.innerId?e.LabelingAnimation.fadeIn:P.placementIndex===I.placementIndex?e.LabelingAnimation.none:e.LabelingAnimation.fadeIn}const _=(y,b,I,P,x,Z,j,O)=>{const K=new Set(x),H=[];let $=new Map;const U=[];return I.forEach(V=>{const A=new e.Camera(V),Y=new Set,G=[...b];y.forEach(({sourceId:w,animate:R,labelsKeys:X})=>{R||Y.add(w),G.push(...X)});const{boxElements:q,oneWayTileElements:Ue,otherTileElements:ae,noLabelingElements:Ye}=Ce(G,V,A,r,i,f,m,g,P,K,C,O),re=e.generalize(ae,q,V,j?Oe:c,Z,A),ee=[...Ye,...Ue,...ae],le=new Map;for(let w=0;w<ee.length;w++){const R=ee[w];R.placementIndex!==-1&&le.set(R.id,R)}for(let w=0;w<ee.length;w++){const R=ee[w],{label:{styleId:X,layer:fe}}=R;if(R.placementIndex===-1)continue;const te=W(Y,c,R),ne=r.getStyle(X);if(!ne){console.error(`Not found style ${X} in labeling#processLabels`);continue}e.processElement(ne,fe,a,R,te,P,V,V.tileInfo)}for(let w=0;w<o.length;w++){const R=o[w],{id:X,label:fe,layer:te}=R,{styleId:ne}=fe,ke=r.getStyle(ne);if(!ke){console.error(`Not found style ${ne} in labeling#processLabels`);continue}if(Y.has(R.label.sourceId))continue;const Je=R.placementIndex,J=le.get(X);Je===-1||R.placementIndex===(J==null?void 0:J.placementIndex)&&(R.type!==e.LabelingElementType.Icon||R.layer.innerId===(J==null?void 0:J.layer.innerId))||V.styleZoom<R.overflowStyleZoom||V.styleZoom<te.minzoom||V.styleZoom>=te.maxzoom||e.processElement(ke,te,a,R,e.LabelingAnimation.fadeOut,P,V,V.tileInfo)}H.push(...ee),$=new Map([...$,...le]);const pe=a.getAccumulatedData(),Te=[];for(const w of q)w.placementIndex!==-1&&Te.push(w.label.id);const ve=new Map,Xe=e.tetragonBounds(V.tilesBounds);for(const w of ae)if(w.placementIndex!==-1&&e.isCommercialPoi$1(w)&&e.contains(Xe,w.anchorWorld)){const R={};e.isCommercialPoiCity(w)?R.adsPriority="city":e.isCommercialPoiPremium(w)&&(R.adsPriority="premium"),ve.set(w.label.id,R)}const Ie={survivedLabelBoxIds:Te,survivedCommPois:Array.from(ve).map(w=>{const R={id:w[0]};return w[1].adsPriority!==void 0&&(R.adsPriority=w[1].adsPriority),R}),collectorOutput:pe,transferable:pe.transferable};if(re){const w=new Int32Array(re.length);w.set(re),Ie.labels=w.buffer}U.push(Ie)}),o=H,c=$,d(),U};n.set("processLabels",_);const N=(y,b)=>{m[y]||(m[y]={});const I=m[y];for(const P in b)I[P]=b[P]};n.set("appendFont",N);const M=(y,b)=>{g.set(y,b,!0)};n.set("markFontAsLoaded",M);const u=(y,b)=>{const I=r.getStyle(y);if(!I){console.error(`Not found style ${y} in labeling#addNewRasterSets`);return}const{rasterSets:P}=I;b.forEach(x=>{P.byIndex[x.index]=x,P.byKey[x.key]=x})};n.set("addNewRasterSets",u);const L=(y,b)=>{var j;const I=r.getStyle(y);if(!I){console.error(`Not found style ${y} in labeling#updatePackingInfo`);return}const{rasterSets:P}=I,x=7,Z=b.length/x;for(let O=0;O<Z;O++){const K=b[O*x],H=b[O*x+1],$=b[O*x+6],U=b[O*x+2],V=b[O*x+3],A=b[O*x+4],Y=b[O*x+5],G=P.byIndex[K];if(G===void 0){console.error(`Not found raster set with index ${K}`);continue}if(G.isSvg)G.rasters[H]={rasterIndex:H,rasterSetIndex:K,x:U,y:V,w:A,h:Y,anchorX:G.anchorX,anchorY:G.anchorY,atlasIndex:$,isPacked:!0};else{const q=(j=G.rasters[H])!=null?j:{rasterIndex:H,rasterSetIndex:K,x:U,y:V,w:A,h:Y,anchorX:0,anchorY:0,atlasIndex:$,isPacked:!0};G.rasters[H]=q,q.x=U,q.y=V,q.atlasIndex=$,q.isPacked=!0}}};n.set("updatePackingInfo",L);const v=()=>{o=[],c.clear()};n.set("clearPreviousLabels",v);const S=(...y)=>r.proxySyncStyle(...y);n.set("syncStyle",S),n.set("loadRtlPlugin",e.compileRtlPlugin),n.set("markRtlPluginLoaded",()=>{e.markAsReady&&e.markAsReady()})}function je(s){const t=new e.WorkerConnector(s),n=new e.FnRegistry(t);new e.ClassRegistry(n).set("ModelsWorker",e.ModelsWorker)}function Ge(s,t,n,a,r,l,i,f,o){if(!n)return s.getAccumulatedData();const c=f.coords[3],{tileProps:h}=t,g=Object.keys(h).length,m=[],d=e.pixelRatioToDpi(l),k=e.makeGeneratorContext(r,e.emptySourceAttrs,h,m,e.emptyFeatureAttrs,void 0,f);for(const E of i.tile){const{color:p=0,color2:C=0,geo:T,road:F,normals:D,zLevel:W=0,is_immersive:_,logicalLevels:N}=E;for(let M=0;M<g;M++)m[M]=NaN;m[h.db_sublayer]="Traffic_jams",m[h.traffic_color]=p,m[h.traffic_color2]=C,m[h.traffic_road_class]=F,m[h.traffic_road_z_level]=W,m[h.db_tiers]=N?[e.getTierFromLevels(N.begin,N.end)]:void 0,m[h.db_has_immersive_counterpart]=Number(_),m[h.beginningIsCut]=0,m[h.endingIsCut]=0;for(let M=0;M<T.length;M++){const u=T[M],L=D[M],v=[],S=[],y=[],b=[];for(let x=0;x<u.length;x++)v[x]=u[x][0]*e.uint16ToTileCoords,S[x]=u[x][1]*e.uint16ToTileCoords,y[x]=L[x][0],b[x]=L[x][1];const I={x:v,y:S,normal_x:y,normal_y:b},P=a.getLayers(n.id,h,m).filter(x=>e.resolveExpression(x.filter,k));P.length===0&&k.id&&s.idIndexer.addOrphanId(k.id),e.generateHandyLayers(s,n,P,k,t,e.LATEST_TILE_VERSION,c,o,f,d,I)}}return s.getAccumulatedData()}let ce=[];function Ke(s,t,n,a,r,l,i,f,o){var D,W,_;const{tileProps:c,dictionaries:h}=a,g=Object.keys(c).length,m=new Set(i),d=[];if(((D=h.db_sublayer)==null?void 0:D.s_personal_poi)===void 0)return s.getAccumulatedData();for(let N=0;N<g;N++)d[N]=NaN;const k=e.pixelRatioToDpi(l),E=e.create(),p=[];for(const N of f){const M=e.Mercator.fromGeo(N.point);e.expandByPoint(E,M),p.push(M)}const C=e.getBoundsTileCoords(E),T=e.createTileInfo(C),F=e.makeGeneratorContext(n,e.emptySourceAttrs,c,d,e.emptyFeatureAttrs,void 0,T);for(let N=0;N<f.length;N++){const M=f[N],u=e.create$1();e.mapPointToTilePoint(u,p[N],T);const L=M.id;F.id=L;const v={x:[u[0]],y:[u[1]]};for(let y=0;y<g;y++)d[y]=NaN;d[c.db_sublayer]="s_personal_poi",d[c.db_object_class]=(_=M.humanReadableClassId)!=null?_:(W=a.reverseDictionaries.db_object_class)==null?void 0:W[M.classId],d[c.db_label]=M.name,d[c.db_icon_priority]=1,d[c.db_label_priority]=0,d[c.selected]=m.has(L)?1:0,d[c.db_region]=r,ce=t.layers.filter(y=>e.resolveExpression(y.filter,F)),ce.length===0&&F.id&&s.idIndexer.addOrphanId(F.id),e.generateHandyLayers(s,t,ce,F,a,e.LATEST_TILE_VERSION,void 0,o,T,k,v)}return s.getAccumulatedData()}class He{constructor(){this.cache=new Map,this.pendingRequests=new Map}fetch(t,n,a,r,l){return new Promise(i=>{const f=qe(t,r,l,n,a),o=e.coordsToKey(t),c=e.getJson({url:f},(h,g)=>{if(this.pendingRequests.delete(o),h!==void 0){h.status!==204&&console.error(h),this.cache.set(o,void 0),i();return}const m=g[0];m?this.cache.set(o,m):this.cache.set(o,void 0),i()});this.pendingRequests.set(o,{xhr:c,resolve:i})})}get(t){return this.cache.get(t)}delete(t){this.cache.delete(t)}abortRequest(t){const n=this.pendingRequests.get(t);n!==void 0&&(n.xhr.abort(),n.resolve(),this.pendingRequests.delete(t))}}function qe(s,t,n,a,r){const l=we(2,s[2])-1,i=s[0],o=(l-s[1]&16777215)*(1<<24)+(i&16777215);return e.template(e.traffic.url,{protocol:r,host:a,z:String(s[2]),tiles:String(o),regions:t.join(","),time:String(n)})}function $e(s){const t=new e.WorkerConnector(s),n=new e.FnRegistry(t),a=new e.ClassRegistry(n),r=new He,l=new Le,i={main:{addNewRasterSets:n.get(e.ThreadName.Main,"addNewRasterSets")},labeling:{addNewRasterSets:n.get(e.ThreadName.Labeling,"addNewRasterSets")}},f={},o=new e.Collector("parser"),c=e.throttle(()=>o.reset(),e.workerResetInterval),h=()=>{const u=o.atlasPacker.getNewRasterSets();u.size&&u.forEach((L,v)=>{i.main.addNewRasterSets(v,L),i.labeling.addNewRasterSets(v,L)})},g={sources:{},collector:o,styleManager:l,syncNewRasterSets:h,debouncedResetCollector:c};a.set("GeoJsonSource",e.GeoJsonSourceWorker,g,["fetchTiles"]);const m={collector:o,metatiles:f,styleManager:l,syncRasterSets:h,resetCollector:c,createImageBitmap:s.createImageBitmap?s.createImageBitmap.bind(s):void 0};a.set("ZenithWorker",e.ZenithWorker,m,["fetchTiles"]);const d={collector:o,resetCollector:c};a.set("MeshElevationWorker",e.MeshElevationWorker,d,["fetchTiles"]);const k=(u,L)=>{f[u]=L};n.set("setMetatile",k);const E=()=>{var b;const u=o.getIndexerStats(),L=o.getStatsAfterReset(),v=o.getBucketsMemoryFootprint(),S=[];(b=a.classes.get("ZenithWorker"))==null||b.hosts.forEach(I=>{I.tileLoader&&I.tileLoader.cache.size>0&&I.tileLoader.cache.forEach((P,x)=>{S.push({[x]:I.tileLoader.cache.get(x).reduce((Z,j)=>Z+j.data.byteLength,0)})})});const y={collector:{buckets:v,reset:L,idIndexer:u},zenit:{cache:S}};return{js:he(se({},y),{"--sum":e.getTotalMemory(y)})}};n.set("getMemoryFootprint",E);const p=(...u)=>l.proxySyncStyle(...u);n.set("syncStyle",p);const C=u=>new Promise(L=>{e.getArrayBuffer({url:u},(v,S)=>{if(v||S.byteLength===0){L(void 0);return}if(s.createImageBitmap){const y=new Blob([S],{type:"image/png"});createImageBitmap(y).then(b=>{L({isBitmap:!0,data:[b],transferable:[b]})})}else L({isBitmap:!1,data:[S],transferable:[S]})})});n.set("prepareAtlas",C);const T=u=>{for(let S=0;S<u.length;S+=3){const y=u[S+2],b={type:e.RasterSetType.Loaded,isSvg:!1,index:y,key:`loaded-${y}`,name:"",fileName:"",rasters:[{rasterSetIndex:y,rasterIndex:0,w:u[S],h:u[S+1],atlasIndex:0,x:0,y:0,isPacked:!1,anchorX:0,anchorY:0}]};o.atlasPacker.pack(b,[u[S]],1)}const L=o.atlasPacker.getPackedRasters(),v=[];return L!==void 0&&v.push(L.buffer),{packedRasters:L,transferable:v}};n.set("packRasters",T);const F=u=>r.fetch(u.coords,u.tileServer,u.tileProtocol,u.regionIds,u.timestamp);n.set("fetchTrafficTile",F);const D=u=>{r.delete(u)};n.set("deleteTrafficTile",D);const W=u=>{r.abortRequest(u)};n.set("abortTrafficTileRequest",W);const _=e.createMetatile(["db_sublayer","traffic_road_class","traffic_color","traffic_road_z_level","db_tiers","db_has_immersive_counterpart","beginningIsCut","endingIsCut","traffic_color2"],["Traffic_jams"]),N=({coords:u,pixelRatio:L,styleState:v,styleId:S,sourceId:y})=>{const b=e.coordsToKey(u),I=e.createTileInfo(u),P=[],x=[],Z=1,j=l.getStyle(S);if(!j)return Promise.resolve({results:P,transferable:x});const O=r.get(b);if(O){const K=Ge(o,_,j,l,v,L,O,I,y);P.push({regionId:Z,metatileHash:0,styleId:j.id,collectorOutput:K})}return Promise.resolve({results:P,transferable:x})};n.set("generateTrafficTile",N);const M=(u,L,v,S,y,b,I,P)=>{const x=l.getStyle(b);if(!x)return;const Z=Ke(o,x,I,f[v],L,S,y,u,P);return c(),h(),{collectorOutput:Z,transferable:Z.transferable,styleId:x.id}};n.set("generatePersonalPoi",M)}const Se=s=>{const{msg:t}=s.data;if("youare"in t)switch(t.youare){case"labeling":ze(self);break;case"models":je(self);break;case"parser":$e(self);break;case"render":self.removeEventListener("message",Se),e.expose(e.createRemoteRenderRunner);break;default:throw new Error("Unknown worker type")}};self.addEventListener("message",Se)}));

_mapgl_d("index",["exports","./shared"],(function(A,n){var nw=Object.defineProperty,ow=Object.defineProperties;var sw=Object.getOwnPropertyDescriptors;var fc=Object.getOwnPropertySymbols;var aw=Object.prototype.hasOwnProperty,rw=Object.prototype.propertyIsEnumerable;var je=Math.pow,mc=(A,n,Be)=>n in A?nw(A,n,{enumerable:!0,configurable:!0,writable:!0,value:Be}):A[n]=Be,B=(A,n)=>{for(var Be in n||(n={}))aw.call(n,Be)&&mc(A,Be,n[Be]);if(fc)for(var Be of fc(n))rw.call(n,Be)&&mc(A,Be,n[Be]);return A},de=(A,n)=>ow(A,sw(n));var K=(A,n,Be)=>new Promise((Ri,Fi)=>{var qn=lt=>{try{rt(Be.next(lt))}catch(ci){Fi(ci)}},Se=lt=>{try{rt(Be.throw(lt))}catch(ci){Fi(ci)}},rt=lt=>lt.done?Ri(lt.value):Promise.resolve(lt.value).then(qn,Se);rt((Be=Be.apply(A,n)).next())});"use strict";var xt,Zt;var Be=document.createElement("style");Be.textContent=`.mapgl-hover{cursor:pointer}.mapgl-dragging{cursor:grabbing}.mapgl-rotating{cursor:move}.mapgl_QEdaFvncPWE-{width:32px;box-shadow:0 1px 3px #26262680;border-radius:4px;display:flex;flex-direction:column;overflow:hidden;background:#fff}.mapgl_mjx-K8iaDdc-{all:revert;padding:0;outline:0;border:none;cursor:pointer;background:#fff;width:32px;height:32px;color:#262626;box-sizing:border-box}.mapgl_mjx-K8iaDdc-:hover{opacity:.7}.mapgl_mjx-K8iaDdc-:active{color:#028eff}.mapgl_mjx-K8iaDdc-:disabled{background:#f2f2f2;color:#929292;cursor:default}.mapgl_zKZCVsRur9c-{border-bottom:1px solid #e6e6e6}.mapgl_3t-wJELDATg-{border-bottom:none}.mapgl_ON-gf73kIU0-{background:#fff;box-shadow:0 1px 3px #26262680;border-radius:4px;width:32px;overflow:hidden}.mapgl_mWyZxMObEi8-{all:revert;padding:0;outline:0;border:none;cursor:pointer;box-sizing:border-box;font-size:18px;font-weight:400;width:32px;height:32px;color:#262626;background:#fff}.mapgl_FwnEmRmDBLg-:hover{opacity:.7}.mapgl_uSuUHuf71nM-{background:#299400;color:#fff}.mapgl_LdqAv9Ly624-{background:#ffb81c;color:#fff}.mapgl_udRZCM1quWE-{background:#fe5000;color:#fff}.mapgl_uSuUHuf71nM-:hover,.mapgl_LdqAv9Ly624-:hover,.mapgl_udRZCM1quWE-:hover{color:#262626b3}.mapgl_K-1Yb8HCVpQ-{display:block!important}.mapgl_K-1Yb8HCVpQ- .mapgl_CLps5xx6CNs-{height:20px!important;display:block!important}.mapgl_r8Wn2E5pGh0-{pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;display:flex;justify-content:center;align-items:center;padding:10px;background-color:#0003;cursor:default}.mapgl_ir0vRf5QXrk-{text-align:center;font-size:24px;font-family:Helvetica,Arial,sans-serif;font-weight:700;color:#fff}.mapgl_h2pl79nAYpk-{position:relative}.mapgl_64D1bmNQN3Q-{display:flex;max-height:40vh;background:#fff;width:32px;overflow:hidden;border-radius:4px;box-shadow:0 1px 3px #26262680}.mapgl_jdJbkjpLO7k-{width:100%;overflow-x:hidden;overflow-y:auto;-moz-padding-end:17px;-webkit-padding-end:17px;-webkit-margin-end:-17px}.mapgl_54Rmy50n6Fw-{display:flex;flex-direction:column-reverse}.mapgl_3i1QoGerxio-{all:revert;padding:0;border:none;background:#fff;height:32px;width:32px;color:#262626;cursor:pointer;border-bottom:1px solid #e6e6e6;box-sizing:border-box;flex-shrink:0}.mapgl_3i1QoGerxio-:focus{outline:0}.mapgl_3i1QoGerxio-:first-child{border-bottom:none}.mapgl_3i1QoGerxio-:hover{color:#262626b3}.mapgl_3i1QoGerxio-:active{color:#028eff}.mapgl_3i1QoGerxio-:disabled{background:#f2f2f2;color:#929292;fill:#929292;cursor:default}.mapgl_wGplqJ4hHPc-{font-size:18px;line-height:32px;font-weight:400;overflow-wrap:break-word;position:relative;text-align:center;height:100%}.mapgl_wGplqJ4hHPc- svg{margin-top:3px}.mapgl_PkWXKxsq1Kc-:after{content:"";position:absolute;top:4px;bottom:4px;width:4px;height:4px;border-radius:50%;background:#028eff}.mapgl_z0m6n5pr5no-{position:absolute;pointer-events:none;inset:0}.mapgl_ITPUswrhaGk-{position:absolute;display:flex;z-index:50;pointer-events:none;width:100%;height:100%}.mapgl_ITPUswrhaGk->div>*{pointer-events:auto}.mapgl_Px-KwzXdVa0-{flex-direction:column;align-items:flex-start}.mapgl_SCX3EYsS-Cw-{flex-direction:row;justify-content:center;align-items:flex-start}.mapgl_i42TyWqpCPk-{flex-direction:column;align-items:flex-end}.mapgl_-zKby6nN-nU-{flex-direction:column;justify-content:center;align-items:flex-start}.mapgl_SlQM4-ZNKF0-{flex-direction:column;justify-content:center;align-items:flex-end}.mapgl_lNg3h7Hg-Mo-{flex-direction:column-reverse;align-items:flex-start}.mapgl_grOepPBwilk-{flex-direction:row;justify-content:center;align-items:flex-end}.mapgl_CiHYefDPhI0-{flex-direction:column-reverse;align-items:flex-end}.mapgl_Px-KwzXdVa0->div+div,.mapgl_i42TyWqpCPk->div+div,.mapgl_-zKby6nN-nU->div+div,.mapgl_SlQM4-ZNKF0->div+div{margin-top:10px}.mapgl_lNg3h7Hg-Mo->div+div,.mapgl_CiHYefDPhI0->div+div{margin-bottom:10px}.mapgl_SCX3EYsS-Cw->div+div,.mapgl_grOepPBwilk->div+div{margin-left:10px}.mapgl_9m2ynAxdBT0-{background:#ffffffad;border-width:0 1px 1px 1px;border-color:#7a7a7a;border-style:solid;border-radius:0;min-width:64px;height:16px;overflow:hidden;pointer-events:none!important}.mapgl_sR4nXEQ3L2M-{min-width:50px;height:12px;margin-top:2px;margin-left:6px;font-family:Helvetica,Arial,sans-serif!important;font-style:normal;font-weight:400;font-size:9px;line-height:12px;color:#262626}.mapgl_54Xq9OUdARA-{font-family:Helvetica,Arial,sans-serif!important;font-size:8px!important;line-height:8px!important;text-align:right!important;display:flex;align-items:flex-start;color:#6d7173!important}.mapgl_qYE18V9u8c0-{display:block}a.mapgl_wYSwIqldiqU-{color:#6d7173!important;text-decoration:none!important}a.mapgl_wYSwIqldiqU-:hover{color:#929292!important}
/*$vite$:1*/`,document.head.appendChild(Be);function Ri(s,e,t){if(s.length===0)return;const i=n.degToRad(e),o=n.create();for(const r of s){const l=n.Mercator.fromGeo(r);n.rotateVec2(l,-i),n.expandByPoint(o,l)}const a=n.create$1();return n.center(a,o),n.rotateVec2(a,i),{center:a,zoom:Fi(o,t)}}function Fi(s,e){return Math.min(n.pixelsAndMapDistanceToZoom(e[0],Math.abs(s.max[0]-s.min[0])),n.pixelsAndMapDistanceToZoom(e[1],Math.abs(s.max[1]-s.min[1])))}function qn(s,e,t){const i=Ri(s,e,t);if(i)return{zoom:i.zoom,center:n.Mercator.toGeo(i.center)}}function Se(s,e,t){const i=s.getBoundingClientRect();return[e-i.left-s.clientLeft,t-i.top-s.clientTop]}function rt(s,e){const t=[];for(let i=0;i<s.length;i++)t[i]=Se(e,s[i].clientX,s[i].clientY);return t}function lt(s){return s.touches.length>1}const ci=n.Mercator.fromGeo,pc=n.Mercator.toGeo;function vc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c=!1){return new n.Camera({center:n.Mercator.fromGeo(s),zoom:e,rotation:n.degToRad(t),size:i,pitch:n.degToRad(o),viewport:r,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).project(a)}function gc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c=!1){return new n.Camera({center:n.Mercator.fromGeo(s),zoom:e,rotation:n.degToRad(t),size:i,pitch:n.degToRad(o),viewport:r,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).unproject(a)}function yc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c){return n.getMetersFromPixelsXY(s,e,t,i,o,a,r,l,c,c)}function xc(s,e){return new n.Camera(s).project(n.Mercator.toGeo(e))}const bc=Object.freeze(Object.defineProperty({__proto__:null,geoLineDistance:n.geoLineDistance,geoToMapDistance:n.geoToMapDistance,getCenterZoomByPoints:qn,getMetersFromPixels:yc,getMousePositionInContainer:Se,projectGeoToMap:ci,projectGeoToScreen:vc,projectMapToGeo:pc,projectMapToScreen:xc,projectScreenToGeo:gc},Symbol.toStringTag,{value:"Module"})),wc=Object.freeze(Object.defineProperty({__proto__:null,getMetersFromPixelsXY:n.getMetersFromPixelsXY,getUrl:n.getUrl,hashToString:n.hashToString},Symbol.toStringTag,{value:"Module"}));class We extends n.Evented{constructor(e,t,i){var o;super(),this.interactive=(o=t.interactive)!=null?o:!0,this.uniqId=String(n.uniqId()),this.parentObject=i,this.modules=e.modules,this.mapState=e.state,this.tileObjects=[],this.identifyIds=[]}update(){this.mapState.needReplicasUpdate&&this.tileObjects.forEach(e=>{e.needSync=!0})}destroy(){const e=this.modules;this.tileObjects.forEach(t=>{t.clean(this.mapState),e.tileManager.removeObject(t)}),this.tileObjects=[],e.layers.removeLayer(this),e.renderer.addRerenderEvent()}getIdentifyData(){return this.identifyIds.map(e=>({dynamicObjectId:this.uniqId,metatileHash:-1,ids:e}))}isInteractive(){return this.interactive}}const Is=["disableDragging","enableTrackResize","loopWorld","disableHidingPois","enableTwoFingerDragging"];let Yn=class{constructor(e,t,i){var o,a,r,l,c,d;this.options=t,this.type="zenith",this.id=n.sourceUuid(),this.identifyAsDefaultSource=(o=t.identifyAsDefaultSource)!=null?o:!0,this.identifyAsDefaultSource&&!t.promoteId&&(t.promoteId="id"),this.sourceOptions=t,this.modelsAppearStrategy=(a=t.modelsAppearStrategy)!=null?a:n.DEFAULT_MODELS_APPEAR_STRATEGY,this.state=e.state,this.modules=e.modules,this.sourceCore=new n.ZenithSourceCore(this.id,this.modules,this.options),this.tileLayer=new n.TileLayer((r=t.minZoom)!=null?r:n.tiles.maxUniverseZoom+1,(l=t.maxZoom)!=null?l:n.tiles.maxRegionalZoom,(c=t.minZoom)!=null?c:n.tiles.maxUniverseZoom+1,(d=t.maxDetailLevel)!=null?d:n.tiles.maxDetailLevel,this.modules,this.state,this.sourceCore,this.options),this.modules.tileManager.addTileLayer(this.tileLayer),this.modules.sourceStorage.addSource(this),this.mapglApiSource=i}getObjectAttributes(e,t){return this.sourceCore.getObjectAttributes(e,t)}getId(){return this.id}getOptions(){return this.sourceOptions}getAttributes(){return this.sourceCore.getAttributes()}getZoomDirection(){return this.tileLayer.getZoomDirection()}setAttributes(e){this.sourceCore.setAttributes(e),this.tileLayer.redraw()}getUrl(e,t){return n.getUrl(e,B({host:this.options.tileServer,tileSet:this.options.tileSet,protocol:this.options.tileProtocol,subdomain:this.options.subdomains[0]},t))}destroy(){this.modules.tileManager.removeTileLayer(this.tileLayer),this.tileLayer.destroy(),this.modules.sourceStorage.removeSource(this.id),this.sourceCore.destroy()}setFeatureStateMap(e){this.sourceCore.setFeatureStateMap(e),this.tileLayer.onFeatureStateMapChange()}isIdentifiedAsDefault(){return this.identifyAsDefaultSource}};function Cs(s,e){if(e===void 0)return;if(e.sourceId){const i=s.getSourceById(e.sourceId);if(!(i!=null&&i.isIdentifiedAsDefault()))return}const t={id:e.id,symbol:e.symbol};return e.symbol==="point"&&(t.isText=e.instanceId===1),e.sublayer&&(t.isCityCommercial=n.isCommercialCityPoi(e.sublayer),t.isPremiumCommercial=n.isCommercialPremiumPoi(e.sublayer),t.isCommercial=n.isCommercialPoi(e.sublayer),t.isPersonal=n.isPersonalPoi(e.sublayer),(e.symbol==="point"&&!t.isCommercial||e.symbol==="gltfModel")&&(t.sysCode=e.objectClass)),e.center&&(t.center=n.Mercator.toGeo(e.center)),e.symbol==="gltfModel"&&(t.sublayer=e.sublayer,t.isCommercial=!!e.sublayer&&n.isCommercialModel(e.sublayer)),t}function Sc(s,e){var i;if(e===void 0)return;if(e.sourceId){const o=s.getSourceById(e.sourceId);if(o)switch(o.type){case"geojson":{if(o.subtype==="internal"&&o instanceof n.GeoJsonSource||o.subtype==="viewport-internal"&&o instanceof n.GeoJsonViewportSource)return{type:"geojson",id:e.id,feature:o.getFeatureById(e.id,e.tileKey),source:o};if(o.subtype==="external"&&o instanceof n.GeoJsonTileSource)return{type:"geojsonTile",getFeatureProperties:()=>e.tileKey===void 0?Promise.resolve():o.getObjectAttributes(e.id,e.tileKey),source:o}}case"zenith":if(o instanceof Yn)return{type:"zenith",id:e.id,source:o,attributes:o.getObjectAttributes((i=e.tileKey)!=null?i:"",e.id)}}}const t={type:"default",id:e.id};return e.floorId&&(t.floorId=e.floorId),t}function mt(s,e,t,i,o){const a=o.camera,r=[0,0];if(a.unproject(i,r,!0),e&&e.dynamicObjectId!==void 0){const h=s;let f=o.layers.getDynamicObjectLayers().find(p=>p.uniqId===e.dynamicObjectId);if(f!=null&&f.parentObject&&(f=f==null?void 0:f.parentObject),!f)return;const m={lngLat:r,originalEvent:t,point:i,targetData:f};f.emit(h,m);return}const l=Cs(o.sourceStorage,e),c=Sc(o.sourceStorage,e);if((s==="mousedown"||s==="click")&&e!==void 0&&(l==null?void 0:l.symbol)==="point"&&c!==void 0){const h=n.getPoiIconData(o,e,l)||{};h!==void 0&&(c.poiIcon=h)}if(e){const h=o.styleManager.getStyleLayer(e.styleId,e.layerId);h&&c&&(c.layerId=h.id)}const _={lngLat:r,originalEvent:t,point:i,target:l,targetData:c},u=s;o.map.emit(u,_)}class Ls extends We{constructor(e,t,i){super(e,t),this.start=o=>{const{modules:a,container:r}=this,{camera:l}=a;if(o.button!==0)return;const c=Se(r,o.clientX,o.clientY);this.contains(c)&&(a.handler.block(),a.mouseMoveHandler.block(),this.dragStartCursorPoint=c,this.dragStartAnchorPoint=l.project(n.Mercator.toGeo(this.getPosition())),document.addEventListener("mouseup",this.stop),document.addEventListener("mousemove",this.move),this.emitEvent("dragstart",o))},this.move=o=>{const{camera:a}=this.modules,{dragStartAnchorPoint:r,dragStartCursorPoint:l,container:c}=this;if(r===void 0||l===void 0)return;const d=Se(c,o.clientX,o.clientY),_=n.clone(r);n.add(_,_,d),n.sub(_,_,l),this.setPosition(n.Mercator.fromGeo(a.unproject(_))),this.emitEvent("drag",o)},this.stop=o=>{if(o.button!==0)return;this.dragStartCursorPoint=void 0,this.dragStartAnchorPoint=void 0,document.removeEventListener("mouseup",this.stop),document.removeEventListener("mousemove",this.move);const{modules:a}=this;a.handler.unblock(),a.mouseMoveHandler.unblock(),this.emitEvent("dragend",o),this.interactive&&a.identifier.resetCache()},this.container=e.modules.layout.mapContainer,i&&this.container.addEventListener("mousedown",this.start,!0)}destroy(){super.destroy(),this.container.removeEventListener("mousedown",this.start,!0),document.removeEventListener("mouseup",this.stop),document.removeEventListener("mousemove",this.move)}emitEvent(e,t){const i=this.getPosition(),o=n.Mercator.toGeo(i),a=this.modules.camera.flat.project(i),r=this.modules.identifier.searchSync(a),l=r!==void 0&&r.dynamicObjectId===void 0?Cs(this.modules.sourceStorage,r):void 0;this.emit(e,{originalEvent:t,target:l,targetData:this,lngLat:o,point:a})}}const Tc=!1;let Ps=class extends Ls{constructor(e,t){var x,g;super(e,t,(x=t.draggable)!=null?x:Tc),this.visible=!0,this.options=t;const i=n.Mercator.fromGeo(this.options.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,collector:a,tileManager:r,identifier:l,layers:c}=this.modules;if(this.layer=n.makeHandyStyleLayer({type:"circle",id:`dynamic-circleMarker-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color,strokeColor:this.options.borderColor,strokeColor2:this.options.border2Color,width:this.options.width,strokeWidth:this.options.borderWidth,strokeWidth2:this.options.border2Width}}),!this.layer)return;o.addLayer(this.layer,this.options.zIndex);const d=(g=i[2])!=null?g:0,_=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),u=n.optionsToTileAttrs({}),h={x:[0],y:[0],z:[d]},f=n.createTileInfo(_),m=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,u,n.emptyFeatureAttrs,this.interactive?"0":"",f);n.runPrecomputes(this.layer,m),n.generateSafely({collector:a,generator:n.CircleMarkerGenerator.generate,args:[o.getStyle().id,this.layer,m,h]});const p=a.getAccumulatedData(),v=new n.TileObject("dynamicObject",p.data,this.modules,this.mapState,_);r.addObject(v),this.tileObjects.push(v),this.interactive&&this.identifyIds.push(p.identifyIds),c.addLayer(this),a.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&l.resetCache()}remove(){this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.interactive&&this.modules.identifier.resetCache(),super.destroy()}update(){if(this.mapState.globeMode){const{tileManager:e}=this.modules,t=this.modules.camera.ecef.canSee(this.options.coordinates);this.visible&&!t?this.tileObjects.forEach(i=>e.removeObject(i)):!this.visible&&t&&this.tileObjects.forEach(i=>e.addObject(i)),this.visible=t}}isOutOfMainReplica(){return!1}setPosition(e){const t=this.tileObjects[0];t!==void 0&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},t.setTileCoords(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState),this.modules.renderer.addRerenderEvent())}getPosition(){return this.position.userValue}contains(e){if(!this.layer)return!1;const{layer:t}=this,{camera:i}=this.modules,o=i.project(n.Mercator.toGeo(this.position.normalizedValue)),a=n.resolveNumber(t.style.width,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),r=n.resolveNumber(t.style.strokeWidth,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),l=a/2+r;return n.dist(o,e)<=l}};function Bs(s,e,t){const{top:i,right:o,bottom:a,left:r}=s.viewport,{clientWidth:l,clientHeight:c}=e;s.size=[Math.max(1,l-r-o),Math.max(1,c-i-a)],t.updateFrameBuffersSize()}const Mc=(s,e,t,i,o={})=>{const a=B({top:0,right:0,bottom:0,left:0},i);if(o.animate===!1||o.duration===0)s.viewport=a,Bs(s,e,t);else{const r=s.viewport,l=o.easing!==void 0?o.easing:"easeOutCubic",c=o.duration!==void 0?o.duration:300;n.start("viewport",{easing:l},s,[r.top,r.right,r.bottom,r.left],[a.top,a.right,a.bottom,a.left],c,1)}},Ec=(s,e,t)=>{n.update("viewport",{step:(i,o)=>{i.viewport={top:o[0],right:o[1],bottom:o[2],left:o[3]},Bs(i,e,t)}},s)};function Ic(s,e){return{top:s.top+e.top,bottom:s.bottom+e.bottom,left:s.left+e.left,right:s.right+e.right}}function Cc(s){return{top:Math.max(s.top,0),bottom:Math.max(s.bottom,0),left:Math.max(s.left,0),right:Math.max(s.right,0)}}function Lc(s,e){return{top:Math.min(s.top,e[1]),bottom:Math.min(s.bottom,e[1]),left:Math.min(s.left,e[0]),right:Math.min(s.right,e[0])}}function Pc(s,e){return Lc(Cc(s),e)}function zs(s,e){const{top:t,right:i,bottom:o,left:a}=s.padding;s.padding={top:t,right:i,bottom:o,left:a},e.addRerenderEvent(),e.updateFrameBuffersSize()}const Bc=(s,e,t,i={})=>{const o=Pc(t,s.size);if(i.animate===!1||i.duration===0)s.padding=o,zs(s,e);else{const a=s.padding,r=i.easing!==void 0?i.easing:"easeOutCubic",l=i.duration!==void 0?i.duration:300;n.start("padding",{easing:r},s,[a.top,a.right,a.bottom,a.left],[o.top,o.right,o.bottom,o.left],l,1)}},zc=(s,e)=>{n.update("padding",{step:(t,i)=>{t.padding={top:i[0],right:i[1],bottom:i[2],left:i[3]},zs(t,e)}},s)},Di="inertia",Rc=(s,e,t)=>s*Math.pow(1-(t-e)/n.inertia.duration,n.inertia.nonLinearity),Fc=(s,e,t,i,o)=>{n.start(Di,{easing:"inertia"},s,0,o,n.inertia.duration,1,{startPoint:e,startSpeed:t,direction:i,startTime:s.time})},Qn=n.stop.bind(null,Di),Dc=(s,e)=>{n.update(Di,{step:(t,i,o)=>{const{startPoint:a,startSpeed:r,startTime:l,direction:c}=o,d=n.clone$1(c);n.scale(d,d,i),n.add$1(d,d,a),t.loopWorld||t.globeMode?n.isLatValid(t.maxBounds,d)||(Jn(e,t),n.clampPoint(d,t.maxBounds,d)):n.contains(t.maxBounds,d)||(Jn(e,t),n.clampPoint(d,t.maxBounds,d)),t.center=d,t.zoomTypePreserving==="zoom"?t.styleZoom=n.getStyleZoom(t.zoom,d):t.zoom=n.getZoomFromStyleZoom(t.styleZoom,d);const _=Rc(r,l,t.time);n.mapToPixelDistance(_,t.zoom)<n.inertia.minSpeed&&Jn(e,t)}},s)},Jn=(s,e)=>{n.stop(Di,e),s.classList.remove("mapgl-inertia")},Oi="center",Ft=(s,e,t={})=>{if(n.stop(Oi,s),Qn(s),s.globeMode?n.clampLat(e,s.maxBounds,e):n.clampPoint(e,s.maxBounds,e),t.animate===!1||t.duration===0)s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e);else{const i=t.easing!==void 0?t.easing:"linear",o=t.duration!==void 0?t.duration:250;n.start(Oi,{easing:i},s,s.center,e,o,1)}},Oc=n.stop.bind(null,Oi),Nc=n.update.bind(null,Oi,{step:(s,e)=>{s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e)}}),Ni="rotation";function An(s,e){return s=s-e,s>=Math.PI?s=(s+Math.PI)%(Math.PI*2)-Math.PI:s<-Math.PI&&(s=Math.PI-(Math.PI-s)%(Math.PI*2)),s=s+e,s}function di(s,e,t={}){if(n.stop(Ni,s),t.animate===!1||t.duration===0)s.rotation=An(e,0);else{const i=t.normalize!==void 0?t.normalize:!0;n.start(Ni,{easing:t.easing||"linear"},s,s.rotation,i?An(e,s.rotation):e,t.duration||250,1)}}const kc=n.stop.bind(null,Ni),Uc=n.update.bind(null,Ni,{step:(s,e)=>s.rotation=An(e,0)}),ki="pitch";function Ui(s,e,t={}){n.stop(ki,s);const i=n.clamp(e,s.minPitch,s.maxPitch);t.animate===!1||t.duration===0?s.pitch=i:n.start(ki,{easing:t.easing||"linear"},s,s.pitch,i,t.duration||300,1)}const Gc=n.stop.bind(null,ki),Hc=n.update.bind(null,ki,{step:(s,e)=>s.pitch=e}),Gi="zoom",wt=(s,e,t={})=>{n.stop(Gi,s);const i=n.clamp(e,s.minZoom,s.maxZoom);if(i!==s.zoom)if(t.animate===!1||t.duration===0)t.zoomPoint&&(n.add$1(s.center,s.center,n.getCenterCorrection(s,t.zoomPoint,{zoom:i})),n.clampPoint(s.center,s.maxBounds,s.center)),s.zoom=i,s.styleZoom=n.getStyleZoom(i,s.center);else{const o=t.useHeightForAnimation?n.zoomToHeight(s.zoom,s.size):s.zoom,a=t.useHeightForAnimation?n.zoomToHeight(i,s.size):i,r=t.easing!==void 0?t.easing:"easeOutCubic",l=t.duration!==void 0?t.duration:250;n.start(Gi,{easing:r},s,o,a,l,1,{zoomPoint:t.zoomPoint,useHeightForAnimation:!!t.useHeightForAnimation})}},Rs=n.stop.bind(null,Gi),Vc=n.update.bind(null,Gi,{step:(s,e,t={})=>{const i=t&&t.useHeightForAnimation?n.heightToZoom(e,s.size):e;t&&t.zoomPoint&&(n.add$1(s.center,s.center,n.getCenterCorrection(s,t.zoomPoint,{zoom:i})),n.clampPoint(s.center,s.maxBounds,s.center)),s.zoom=i,s.styleZoom=n.getStyleZoom(i,s.center)}}),Zc=navigator.msPointerEnabled&&navigator.msMaxTouchPoints&&!window.PointerEvent,jc=window.PointerEvent&&navigator.pointerEnabled&&navigator.maxTouchPoints||Zc||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,Wc=Dt("webkit"),$c=Dt("chrome")||Dt("crios"),Xc="ActiveXObject"in window,Kc=!$c&&Dt("safari");Dt("gecko")&&!Wc&&window.opera;const Hi=navigator.platform.toUpperCase().indexOf("MAC")>=0,qc=Dt("windows"),Yc=Dt("firefox");function Dt(s){return navigator.userAgent.toLowerCase().indexOf(s)>=0}function pt(s){Rs(s),Oc(s),kc(s),Gc(s),Qn(s)}class Qc{constructor(e,t){this.onWheelScroll=i=>{this.isBlocked||(i.preventDefault(),!(i.deltaMode===void 0&&i.deltaY===void 0)&&(this.state.userHasInteracted=!0,this.screenPoint=Se(this.container,i.clientX,i.clientY),i.ctrlKey?this.deltaAccumulator-=i.deltaY*10:i.deltaMode===1?this.deltaAccumulator-=i.deltaY*20:this.deltaAccumulator-=i.deltaY,this.eventCount+=1))},this.startZooming=()=>{const i=this.state;let o=this.getDelta();Hi?o*=n.zoom.macWheelDeltaToZoomDelta:Number.isInteger(o)?o=n.sign(o)*n.zoom.wheelZoomDelta:o*=n.zoom.notMacTrackpadDeltaToZoomDelta;const a=i.zoom+o,r=n.clamp(a,i.minZoom,i.maxZoom);r!==i.zoom&&(pt(i),wt(i,r,{duration:n.zoom.animDuration,animate:!Hi,zoomPoint:i.keepCenterWhileUserZoomRotate?void 0:this.screenPoint}))},this.stop=()=>{this.state.userHasInteracted=!0,Rs(this.state)},this.state=e,this.container=t,Hi||(this.startZooming=n.throttle(this.startZooming,n.zoom.throttleDelay)),this.deltaAccumulator=0,this.eventCount=0,this.screenPoint=[0,0],this.isBlocked=!1,this.container.addEventListener("wheel",this.onWheelScroll),this.container.addEventListener("mousedown",this.stop)}destroy(){this.container.removeEventListener("wheel",this.onWheelScroll),this.container.removeEventListener("mousedown",this.stop)}update(){this.eventCount!==0&&(this.startZooming(),this.state.rerenderEvents.push({type:"coreNeedRerender"}))}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}getDelta(){const e=this.deltaAccumulator/this.eventCount;return this.deltaAccumulator=0,this.eventCount=0,e}}class Jc{constructor(e,t){this.onMouseUp=i=>{this.isBlocked||i.which===1&&this.start()},this.onTouchEnd=i=>{this.isBlocked||i.touches.length===0&&this.start()},this.start=()=>{const i=this.state;i.userHasInteracted=!0;const o=this.getCurrentSpeed(i.time),a=n.length(o);if(n.mapToPixelDistance(a,i.zoom)<=n.inertia.minSpeed)return;const l=n.pixelToMapDistance(n.inertia.maxSpeed,i.zoom),c=Math.min(a,l),d=this.calcDistanceByStartSpeed(c),_=n.clone$1(i.center),u=n.create$1();n.normalize(u,o),Fc(i,_,c,u,d),this.container.classList.add("mapgl-inertia")},this.stop=()=>{Qn(this.state),this.container.classList.remove("mapgl-inertia"),this.times=[],this.positions=[]},this.state=e,this.container=t,this.isBlocked=!1,this.container.addEventListener("mouseup",this.onMouseUp),this.container.addEventListener("mousedown",this.stop),jc&&(this.container.addEventListener("touchend",this.onTouchEnd),this.container.addEventListener("touchstart",this.stop)),this.zoomDiffer=new n.Differ([{path:"zoom",type:"number"}]),this.styleZoomDiffer=new n.Differ([{path:"styleZoom",type:"number"}]),this.centerDiffer=new n.Differ([{path:"center",type:"vec2"}]),this.times=[],this.positions=[]}destroy(){this.container.removeEventListener("mouseup",this.onMouseUp),this.container.removeEventListener("mousedown",this.stop),this.container.removeEventListener("touchend",this.onTouchEnd),this.container.removeEventListener("touchstart",this.stop)}update(){const e=this.state;this.centerDiffer.check(e)&&this.rememberTimeAndPosition(e),(e.zoomTypePreserving==="zoom"?this.zoomDiffer.check(e):this.styleZoomDiffer.check(e))&&this.stop()}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}removeOldRecords(e){for(;e-this.times[0]>100&&this.times.length;)this.times.shift(),this.positions.shift()}rememberTimeAndPosition(e){const t=e.time;this.removeOldRecords(t),this.times.push(t),this.positions.push(n.clone$1(e.center))}getCurrentSpeed(e){if(this.removeOldRecords(e),this.times.length<2)return n.create$1();const t=n.clone$1(this.positions[this.positions.length-1]);return n.sub$1(t,t,this.positions[0]),n.scale(t,t,1/(this.times[this.times.length-1]-this.times[0])),t}calcDistanceByStartSpeed(e){return e*n.inertia.duration/(n.inertia.nonLinearity+1)}}class Ac{constructor(e){this.emitMouseEvent=t=>{if(this.isBlocked)return;const i=Se(this.container,t.clientX,t.clientY);this.emitEvent(t,i)},this.emitTouchEvent=t=>{if(this.isBlocked)return;const i=Se(this.container,t.changedTouches[0].clientX,t.changedTouches[0].clientY);this.emitEvent(t,i)},this.container=e.layout.mapContainer,this.modules=e,this.isBlocked=!1,this.container.addEventListener("mouseup",this.emitMouseEvent),this.container.addEventListener("touchend",this.emitTouchEvent)}destroy(){this.container.removeEventListener("mouseup",this.emitMouseEvent),this.container.removeEventListener("touchend",this.emitTouchEvent)}update(){}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}emitEvent(e,t){if(!this.modules.layout.isActionWithCanvas(e))return;const i=e.type;this.modules.identifier.search(i,t).then(o=>{mt(i,o,e,t,this.modules)})}}class ed{constructor(e,t,i){this.rotationDetected=!1,this.onGestureStart=o=>{this.isBlocked||(o.preventDefault(),this.startRotation=this.state.rotation,this.rotationDetected=!1,this.gestureRotation=0,this.isGestureStart=!0,this.startZoom=this.state.zoom,this.screenPoint=Se(this.container,o.clientX,o.clientY),this.state.userHasInteracted=!0,this.state.disableRotationByUserInteraction||this.container.classList.add("mapgl-rotating"),this.map.emit("interactionstart",{target:"zoom/rotation"}))},this.onGestureEnd=o=>{o.preventDefault(),this.isGestureStart&&(this.isGestureStart=!1,this.state.userHasInteracted=!0,this.container.classList.remove("mapgl-rotating"),this.map.emit("interactionend",{target:"zoom/rotation"}))},this.onGestureChange=o=>{if(o.preventDefault(),this.state.userHasInteracted=!0,o.scale>1?this.gestureZoom=o.scale-1:this.gestureZoom=-1/o.scale+1,this.state.disableRotationByUserInteraction)return;const a=n.degToRad(o.rotation);!this.rotationDetected&&Math.abs(a)>this.state.touchRotationThreshold&&(this.rotationDetected=!0,this.startRotation=this.state.rotation-a),this.rotationDetected&&(this.gestureRotation=a)},this.state=e,this.container=t,this.map=i,this.isBlocked=!1,this.isGestureStart=!1,this.gestureRotation=0,this.gestureZoom=0,this.screenPoint=[0,0],this.startRotation=0,this.startZoom=0,this.container.addEventListener("gesturestart",this.onGestureStart),this.container.addEventListener("gestureend",this.onGestureEnd),this.container.addEventListener("gesturechange",this.onGestureChange)}destroy(){this.container.removeEventListener("gesturestart",this.onGestureStart),this.container.removeEventListener("gestureend",this.onGestureEnd),this.container.removeEventListener("gesturechange",this.onGestureChange)}update(){if(this.gestureRotation===0&&this.gestureZoom===0)return;const e=this.state,t=this.startZoom+this.gestureZoom,i=this.startRotation+this.gestureRotation,o=n.create$1(),a=e.keepCenterWhileUserZoomRotate?n.create$1():n.getCenterCorrection(e,this.screenPoint,{zoom:t,rotation:i});n.add$1(o,e.center,a),pt(e),Ft(e,o,{animate:!1}),wt(e,t,{animate:!1}),e.disableRotationByUserInteraction||di(e,i,{animate:!1}),this.gestureRotation=0,this.gestureZoom=0}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}class td extends n.Evented{constructor(e,t){super(),this.startRenderTime=0,this.catchNextUpdate=!1,this.durations=[],this.badDurations=[],this.countToCheck=75,this.slowFrameTime=100,this.mapState=e,this.mapModules=t,this.originalMapState={center:this.mapState.center.slice(),zoom:this.mapState.zoom,rotation:this.mapState.rotation,pitch:this.mapState.pitch}}update(){const{time:e,needRerender:t,rerenderEvents:i}=this.mapState,o=e-this.startRenderTime;this.catchNextUpdate&&(this.durations.push(o),o>=this.slowFrameTime&&this.badDurations.push(o),this.catchNextUpdate=!1),(t||i.length>0)&&(this.startRenderTime=e,this.catchNextUpdate=!0),this.durations.length>this.countToCheck&&this.check()}getFpsStats(){const e=this.durations.map(a=>1e3/a),t=this.badDurations.map(a=>1e3/a),i=n.equalArrays(this.originalMapState.center,this.mapState.center)&&this.originalMapState.pitch===this.mapState.pitch&&this.originalMapState.rotation===this.mapState.rotation&&this.originalMapState.zoom===this.mapState.zoom;return{all:{min:e.length>0?Math.min(...e):0,max:e.length>0?Math.max(...e):0,avg:e.length>0?e.reduce((a,r)=>a+r)/e.length:0,count:e.length},bad:{min:t.length>0?Math.min(...t):0,max:t.length>0?Math.max(...t):0,avg:t.length>0?t.reduce((a,r)=>a+r)/t.length:0,count:t.length},isStatic:i}}getMemoryStats(){return K(this,null,function*(){const e=yield this.getJsMemoryStats(),t=yield this.getGpuMemoryStats();return{cpu:e,gpu:t}})}check(){const e=id(this.durations);this.emit("fps",e),e<n.performanceCheck.fpsCaveat&&(this.mapState.performanceCaveatEmitted=!0,this.emit("performancecaveat")),this.durations=[],this.badDurations=[],this.countToCheck=Math.min(1e3,this.countToCheck*2)}getJsMemoryStats(){return K(this,null,function*(){const e=yield n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.js).map(o=>o.js).reduce((o,a)=>o+a["--sum"],0)})}getGpuMemoryStats(){return K(this,null,function*(){const e=yield n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.gpu).map(o=>o.gpu).reduce((o,a)=>o+a["--sum"],0)})}}function id(s){s.sort((t,i)=>t-i);const e=s[Math.floor(s.length*3/4)];return Math.round(1e3/e)}class nd{constructor(){this.differ=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"rotation",type:"number"},{path:"pitch",type:"number"}]),this.debouncedSet=n.debounce(e=>{n.start("stillness",{},e,e.stillness,1,400,1)},100,!1),this.stillnessTickerUpdate=n.update.bind(null,"stillness",{step:(e,t)=>{e.stillness=t}})}update(e){this.differ.check(e)&&(e.stillness=0,n.stop("stillness",e),this.debouncedSet(e)),this.stillnessTickerUpdate(e)}}class od{constructor(e){this.onTouchStart=()=>{this.isTouchStartEmitted=!0},this.onMouseOut=t=>{if(!this.prevGeo)return;const i=Se(this.container,t.clientX,t.clientY);mt("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.skipIdentifyEvents=!0,this.modules.defaultSource.resetHoverId(),this.container.classList.remove("mapgl-hover")},this.onMouseMove=t=>{if(this.isTouchStartEmitted){this.isTouchStartEmitted=!1;return}if(this.skipIdentifyEvents=!1,this.isBlocked)return;const i=Se(this.container,t.clientX,t.clientY);Promise.resolve().then(()=>this.modules.layout.isActionWithCanvas(t)?this.modules.identifier.search("mouseMove",i):void 0).then(o=>{if(this.skipIdentifyEvents)return;const a=o&&this.prevGeo&&(o.id!==this.prevGeo.id||o.instanceId!==this.prevGeo.instanceId||o.dynamicObjectId!==this.prevGeo.dynamicObjectId||o.symbol!==this.prevGeo.symbol);this.prevGeo&&(!o||a)&&(mt("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.container.classList.remove("mapgl-hover"),this.modules.defaultSource.resetHoverId()),o&&(!this.prevGeo||a)&&(this.prevGeo=o,this.container.classList.add("mapgl-hover"),mt("mouseover",o,t,i,this.modules),this.modules.defaultSource.setHoverId(o.id)),mt("mousemove",o,t,i,this.modules)})},this.modules=e,this.isTouchStartEmitted=!1,this.skipIdentifyEvents=!1,this.isBlocked=!1,this.prevGeo=void 0,this.container=this.modules.layout.mapContainer,this.container.addEventListener("touchstart",this.onTouchStart),this.container.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("mouseout",this.onMouseOut)}destroy(){this.container.removeEventListener("touchstart",this.onTouchStart),this.container.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("mouseout",this.onMouseOut)}update(){}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}const Fs=(s,e,t,i)=>{n.stop("buildingHeight"+i,s),t.animate===!1||t.duration===0?(e.set(i,t.to),s.needLabeling=!0):n.start("buildingHeight"+i,{easing:t.easing},s,t.from,t.to,t.duration,1)},sd=(s,e,t)=>n.update.call(null,"buildingHeight"+t,{step:(i,o)=>e.set(t,o),complete:i=>i.needLabeling=!0},s),ad=16;class rd{constructor(e,t){this.state=e,this.modules=t,this.buildingHeights=new Map,this.minZoomBuildingHeight=1/0}getBuildingHeight(e){return e===-1/0?1:e!==void 0?(this.buildingHeights.has(e)||this.addBuildingHeightZoom(e),this.buildingHeights.get(e)||0):this.getDefaultBuildingHeight()}update(){this.buildingHeights.forEach((e,t)=>{this.updateByZoom(t,e),this.isAnimating()&&sd(this.state,this.buildingHeights,t)})}isAnimating(){return Array.from(this.buildingHeights.keys()).some(e=>n.get("buildingHeight"+e,this.state)!==void 0)}clearBuildingHeights(){this.buildingHeights.clear(),this.minZoomBuildingHeight=1/0}getDefaultBuildingHeight(){const e=this.minZoomBuildingHeight!==1/0?this.minZoomBuildingHeight:ad;return this.state.styleZoom<e?0:1}updateByZoom(e,t){const i=this.state,o=n.get("buildingHeight"+e,i),a=o!==void 0?o.to:t;i.styleZoom>=e&&this.modules.tileManager.viewportTilesReady()&&a!==1?Fs(i,this.buildingHeights,{animate:!0,easing:n.buildingAnimation.easing,from:t,to:1,duration:n.buildingAnimation.duration*(1-t)},e):i.styleZoom<e&&a!==0&&Fs(i,this.buildingHeights,{animate:!1,to:0},e)}addBuildingHeightZoom(e){const t=e<this.state.styleZoom?0:1;this.buildingHeights.set(e,t),this.minZoomBuildingHeight>e&&(this.minZoomBuildingHeight=e)}}const Z=class Z{constructor(e=null,t={}){this._src=null,this._glContext=null,this._texture=null,this._src=e,this.options=Object.assign({},Z.defaultOptions,t)}enable(e,t){return e.activeTexture(e.TEXTURE0+t),this._texture||this.prepare(e),e.bindTexture(e.TEXTURE_2D,this._texture),this}remove(){return this._texture&&this._glContext&&this._glContext.deleteTexture(this._texture),this._glContext=null,this._texture=null,this._src=null,this}getTexture(){return this._texture}subImage(e,t,i){var l;const o=this._glContext;if(!o)return console.warn("Texture is not prepared, cannot update sub-image"),this;o.bindTexture(o.TEXTURE_2D,this._texture),o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL,this.options.flipY),o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha);const a=this._toGlParam(o,this.options.format),r=this._toGlParam(o,(l=this.options.type)!=null?l:Z.UnsignedByte);return a===null||r===null?this:(o.texSubImage2D(o.TEXTURE_2D,0,t,i,a,r,e),this.options.generateMipmaps&&this.options.minFilter!==Z.NearestFilter&&this.options.minFilter!==Z.LinearFilter&&(console.warn("[WebGL] Generating mipmaps for texture after subImage update"),o.generateMipmap(o.TEXTURE_2D)),this)}prepare(e){var d,_,u;this._glContext=e,this._texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this._texture),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,this.options.flipY),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.options.premultiplyAlpha);const t=this._toGlParam(e,this.options.format),i=this._toGlParam(e,(d=this.options.type)!=null?d:Z.UnsignedByte),o=this._toGlParam(e,this.options.wrapS),a=this._toGlParam(e,this.options.wrapT),r=this._toGlParam(e,(_=this.options.magFilter)!=null?_:Z.LinearFilter),l=this._toGlParam(e,(u=this.options.minFilter)!=null?u:Z.LinearMipMapLinearFilter),c=this.options.compareFunc?this._toGlParam(e,this.options.compareFunc):null;if(t!==null&&i!==null){const h=this.hookInternalFormat(t,i,e);ArrayBuffer.isView(this._src)||this._src===null?this.options.size&&e.texImage2D(e.TEXTURE_2D,0,h,this.options.size[0],this.options.size[1],0,t,i,this._src):this._src&&e.texImage2D(e.TEXTURE_2D,0,t,t,i,this._src)}return o!==null&&a!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a)),r!==null&&l!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l)),c&&!(e instanceof WebGLRenderingContext)&&e.texParameteri(e.TEXTURE_2D,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),this.options.generateMipmaps&&this.options.minFilter!==Z.NearestFilter&&this.options.minFilter!==Z.LinearFilter&&e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null),this}memSizeJs(){const e=this._src;return e===null?0:ArrayBuffer.isView(e)?e.byteLength:e instanceof ImageBitmap?e.height*e.width*4:(console.warn("[Stats] Untracked texture _src size"),0)}memSizeGPU(){var t,i,o,a;if(!this._texture)return 0;const e=((i=(t=this.options.size)==null?void 0:t[0])!=null?i:0)*((a=(o=this.options.size)==null?void 0:o[1])!=null?a:0)*4;return e>0?e:this._src!==null?this.memSizeJs():0}_toGlParam(e,t){return t===Z.ClampToEdgeWrapping?e.CLAMP_TO_EDGE:t===Z.Repeat?e.REPEAT:t===Z.MirroredRepeat?e.MIRRORED_REPEAT:t===Z.NearestFilter?e.NEAREST:t===Z.NearestMipMapNearestFilter?e.NEAREST_MIPMAP_NEAREST:t===Z.NearestMipMapLinearFilter?e.NEAREST_MIPMAP_LINEAR:t===Z.LinearFilter?e.LINEAR:t===Z.LinearMipMapNearestFilter?e.LINEAR_MIPMAP_NEAREST:t===Z.LinearMipMapLinearFilter?e.LINEAR_MIPMAP_LINEAR:t===Z.RgbaFormat?e.RGBA:t===Z.AlphaFormat?e.ALPHA:t===Z.RgbFormat?e.RGB:t===Z.DepthComponentFormat?e.DEPTH_COMPONENT:t===Z.UnsignedByte?e.UNSIGNED_BYTE:t===Z.UnsignedShort?e.UNSIGNED_SHORT:t===Z.Float?e.FLOAT:t===Z.UnsignedInt?e.UNSIGNED_INT:e instanceof WebGLRenderingContext?null:t===Z.RedFormat?e.RED:t===Z.CompareRefToTexture?e.COMPARE_REF_TO_TEXTURE:t===Z.CompareNone?e.NONE:t===Z.DepthComponentFormat32?e.DEPTH_COMPONENT32F:null}hookInternalFormat(e,t,i){return i instanceof WebGLRenderingContext?e:e===i.DEPTH_COMPONENT?i.DEPTH_COMPONENT24:t===i.FLOAT&&e===i.RGBA?i.RGBA32F:t===i.FLOAT&&e===i.RED?i.R32F:t!==i.FLOAT&&e===i.RED?i.R8:e}};Z.ClampToEdgeWrapping=1,Z.Repeat=2,Z.MirroredRepeat=3,Z.NearestFilter=4,Z.NearestMipMapNearestFilter=5,Z.NearestMipMapLinearFilter=6,Z.LinearFilter=7,Z.LinearMipMapNearestFilter=8,Z.LinearMipMapLinearFilter=9,Z.DepthComponentFormat=10,Z.DepthComponentFormat32=11,Z.RgbaFormat=14,Z.AlphaFormat=15,Z.RgbFormat=16,Z.UnsignedByte=17,Z.Float=18,Z.UnsignedShort=19,Z.UnsignedInt=20,Z.RedFormat=21,Z.CompareNone=22,Z.CompareRefToTexture=23,Z.defaultOptions={magFilter:Z.LinearFilter,minFilter:Z.LinearMipMapLinearFilter,wrapS:Z.ClampToEdgeWrapping,wrapT:Z.ClampToEdgeWrapping,format:Z.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:Z.UnsignedByte};let w=Z;function Vi(s){if(s===void 0)return;const e=window.WebGLRenderingContext,i={[e.CLAMP_TO_EDGE]:w.ClampToEdgeWrapping,[e.REPEAT]:w.Repeat,[e.MIRRORED_REPEAT]:w.MirroredRepeat,[e.NEAREST]:w.NearestFilter,[e.NEAREST_MIPMAP_NEAREST]:w.NearestMipMapNearestFilter,[e.NEAREST_MIPMAP_LINEAR]:w.NearestMipMapLinearFilter,[e.LINEAR]:w.LinearFilter,[e.LINEAR_MIPMAP_NEAREST]:w.LinearMipMapNearestFilter,[e.LINEAR_MIPMAP_LINEAR]:w.LinearMipMapLinearFilter,[e.RGBA]:w.RgbaFormat,[e.ALPHA]:w.AlphaFormat,[e.RGB]:w.RgbFormat,[e.UNSIGNED_BYTE]:w.UnsignedByte,[e.FLOAT]:w.Float}[s];return i===void 0?(console.error(`Failed to translate texture parameter ${s}`),NaN):i}const $n=class $n{constructor(e={}){this._texture=null,this._glContext=null,this._frameBuffer=null,this._depthAttachment=null,this.options=Object.assign({},$n.defaultOptions,e),this.options.hasColorOutput&&(this._texture=new w(null,this.options))}bind(e,t){return this._frameBuffer||this._prepare(e),t?e.bindFramebuffer(t,this._frameBuffer):e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),this}unbind(e){return e.bindFramebuffer(e.FRAMEBUFFER,null),this}remove(){return this._unprepare(),this}setSize(e){return this.options.size=e,this._unprepare(),this}getTexture(){return this._texture}getDepthAttachment(){return this._depthAttachment}memSizeGPU(){const{_texture:e,_depthAttachment:t}=this;let i=0;if(this.options.depthTexture||this.options.useHighDepthPrecision)i=4;else switch(this.options.depthInternalFormat){case WebGLRenderingContext.DEPTH_STENCIL:i=1;break;case WebGLRenderingContext.DEPTH_COMPONENT16:i=2;break;default:!(this._glContext instanceof WebGLRenderingContext)&&WebGL2RenderingContext.DEPTH_COMPONENT24&&(i=3)}return{_texture:e?n.textureSizeGpu(e):{_texture:0},_depthAttachment:t===null?0:this.options.size[0]*this.options.size[1]*i}}_prepare(e){var t,i;if(this._glContext=e,!this._texture&&this.options.hasColorOutput&&(this._texture=new w(null,this.options)),this._frameBuffer=e.createFramebuffer(),e.bindFramebuffer(e.FRAMEBUFFER,this._frameBuffer),this._texture&&(this._texture.prepare(e),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,this._texture.getTexture(),0)),this.options.depthTexture){const o=this._depthAttachment=new w(null,{magFilter:(t=this.options.magFilter)!=null?t:w.NearestFilter,minFilter:(i=this.options.minFilter)!=null?i:w.NearestFilter,format:w.DepthComponentFormat,size:this.options.size,premultiplyAlpha:!1,generateMipmaps:!1,type:w.UnsignedInt,compareFunc:this.options.compareFunc});o.prepare(e),e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o.getTexture(),0)}else{const o=this.options.useHighDepthPrecision?e.DEPTH_STENCIL:this.options.depthInternalFormat,a=this.options.useHighDepthPrecision?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;this._depthAttachment=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthAttachment),e.renderbufferStorage(e.RENDERBUFFER,o,this.options.size[0],this.options.size[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,a,e.RENDERBUFFER,this._depthAttachment)}this._checkComplete(e),e.bindRenderbuffer(e.RENDERBUFFER,null),e.bindFramebuffer(e.FRAMEBUFFER,null)}_unprepare(){this._texture&&(this._texture.remove(),this._texture=null),this._glContext&&this._depthAttachment&&(this._depthAttachment instanceof w?this._depthAttachment.remove():this._glContext.deleteRenderbuffer(this._depthAttachment),this._depthAttachment=null),this._glContext&&this._frameBuffer&&(this._glContext.deleteFramebuffer(this._frameBuffer),this._frameBuffer=null)}_checkComplete(e){if(n.forceGlStatusCheck()){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t===e.FRAMEBUFFER_COMPLETE)return;t===e.FRAMEBUFFER_UNSUPPORTED?console.log("Framebuffer is unsupported"):t===e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT?console.log("Framebuffer incomplete attachment"):t===e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS?console.log("Framebuffer incomplete dimensions"):t===e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT?console.log("Framebuffer incomplete missing attachment"):console.log(`Unexpected framebuffer status: ${t}`)}}};$n.defaultOptions=Object.assign({},w.defaultOptions,{size:[0,0],generateMipmaps:!1,depthTexture:!1,hasColorOutput:!0,useHighDepthPrecision:!1,depthInternalFormat:WebGLRenderingContext.DEPTH_COMPONENT16});let be=$n;function Zi(s){const e=document.createElement("canvas"),t={antialias:!1,stencil:!0,failIfMajorPerformanceCaveat:s};return"WebGLRenderingContext"in window?e.getContext("webgl",t)||e.getContext("experimental-webgl",t):null}const eo={};function ld(s){const e=String(s);return eo[e]===void 0&&(eo[e]=cd(s)),eo[e]}function cd(s){const e=Zi(s);if(!e)return{ok:!1,msg:"error on get context"};for(const i of["OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object"])if(!e.getExtension(i))return{ok:!1,msg:`${i} extension is not supported`};try{const i=new Uint8Array(4);e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,i)}catch(i){return{ok:!1,msg:"readPixels is not supported"}}let t;try{t=e.createShader(e.VERTEX_SHADER)}catch(i){return{ok:!1,msg:"browser block shader API"}}return!t||e.isContextLost()?{ok:!1}:(e.shaderSource(t,"void main() {}"),e.compileShader(t),{ok:e.getShaderParameter(t,e.COMPILE_STATUS)===!0})}let Ot;function Ds(){Ot=void 0;const s=new Float32Array([-1,-1,1,-1,-1,1]),e=2,t=Zi(!1);if(!t)return Ot="Failed to obtain WebGL context",!1;for(const m of["OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_float","OES_texture_float_linear"])if(!t.getExtension(m))return Ot=`Absent ${m} extension`,!1;const i=new be({size:[e,e]});i.bind(t);const o=new w(new Float32Array([1,0,1,0]),{size:[2,2],format:w.AlphaFormat,type:w.Float,magFilter:w.LinearFilter,minFilter:w.LinearFilter}).prepare(t),a=`attribute vec2 pos;
    void main () {
        gl_Position = vec4(pos, 0, 1);
    }`,r=`precision mediump float;
    uniform sampler2D tex;
    void main () {
        gl_FragColor = vec4(texture2D(tex, vec2(0.4, 0.4)).a, 0, 0, 0);
    }`,l=t.createShader(t.VERTEX_SHADER),c=t.createShader(t.FRAGMENT_SHADER);if(!l||!c||t.isContextLost())return Ot="Cannot create shaders",!1;t.shaderSource(l,a),t.compileShader(l),t.shaderSource(c,r),t.compileShader(c);const d=t.createProgram();if(!d)return Ot="Cannot compile shader program",!1;t.attachShader(d,l),t.attachShader(d,c),t.linkProgram(d),t.useProgram(d);const _=t.createBuffer();if(!_)return Ot="Cannot create buffer",!1;t.bindBuffer(t.ARRAY_BUFFER,_),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const u=t.getAttribLocation(d,"pos");t.vertexAttribPointer(u,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(u),o.enable(t,0);const h=t.getUniformLocation(d,"tex");t.uniform1i(h,0),t.viewport(0,0,e,e),t.drawArrays(t.TRIANGLES,0,3);const f=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,f),i.unbind(t),f[0]!==255}function dd(){return Ot}let it=null;function Wt(){if(it!==null)return it;const s=Zi(!1);if(!s)return it=!0,it;const e=`
    attribute vec2 pos;
    varying float v1, v2, v3, v4, v5, v6, v7, v8, v9, v10;
    void main () {
        v1 = pos.x;
        v2 = pos.y;
        v3 = pos.x * 2.0;
        v4 = pos.y * 2.0;
        v5 = pos.x + pos.y;
        v6 = pos.x - pos.y;
        v7 = pos.x * pos.x;
        v8 = pos.y * pos.y;
        v9 = pos.x * pos.y;
        v10 = (pos.x + pos.y) / 2.0;

        gl_Position = vec4(pos, 0, 1);
    }`,t=`
    precision mediump float;
    varying float v1, v2, v3, v4, v5, v6, v7, v8, v9, v10;
    void main () {
        float result = v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10;
        gl_FragColor = vec4(result / 10.0, 0, 0, 1); // усредняем результат
    }`,i=s.createShader(s.VERTEX_SHADER),o=s.createShader(s.FRAGMENT_SHADER);if(!i||!o||s.isContextLost())return it=!0,it;s.shaderSource(i,e),s.compileShader(i),s.shaderSource(o,t),s.compileShader(o);const a=s.createProgram();return!a||(s.attachShader(a,i),s.attachShader(a,o),s.linkProgram(a),!a||!s.getProgramParameter(a,s.LINK_STATUS))?(it=!0,it):(it=!1,it)}function _d(){const s=Zi(!1);if(!s)return!1;if(!qc)return!0;const e=s.getExtension("WEBGL_debug_renderer_info");if(!e)return!1;const t=e?s.getParameter(e.UNMASKED_RENDERER_WEBGL):null;return t&&typeof t=="string"?!t.toUpperCase().includes("INTEL"):!1}function Os(s){return s instanceof WebGLRenderingContext?!!s.getExtension("WEBGL_depth_texture"):!0}function ud(s){return!Ns(s)}function Ns(s){if(!hd())return"not a browser";if(!md())return"insufficient Function support";if(!vd())return"insufficient JSON support";if(!gd())return"insufficient worker support";if(!xd())return"insufficient ArrayBuffer support";if(!bd())return"insufficient Canvas/getImageData support";const e=ld(s&&s.failIfMajorPerformanceCaveat||!1);if(!e.ok)return`insufficient WebGL support${e.msg?`: ${e.msg}`:""}`;if(!fd())return"insufficient Array support";if(!pd())return"insufficient Object support";if(!yd())return"insufficient DOM support";if(!wd())return"insufficient ECMAScript 6 support"}function hd(){return typeof window!="undefined"&&typeof document!="undefined"}function fd(){return Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.isArray}function md(){var s;return typeof((s=Function.prototype)==null?void 0:s.bind)=="function"}function pd(){return!!(Object.keys&&Object.assign&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.freeze)}function vd(){return"JSON"in window&&"parse"in JSON&&"stringify"in JSON}function gd(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;const s=new Blob([""],{type:"text/javascript"}),e=URL.createObjectURL(s);let t,i=null;try{i=new Worker(e),t=!0}catch(o){t=!1}return i&&i.terminate(),URL.revokeObjectURL(e),t}function yd(){const s=document.createElement("div");return s&&typeof s.after=="function"}function xd(){return!!ArrayBuffer.isView}function bd(){const s=document.createElement("canvas");s.width=s.height=1;const e=s.getContext("2d");if(!e)return!1;const t=e.getImageData(0,0,1,1);return t&&t.width===s.width}function wd(){return!("documentMode"in document)}function Sd(){return dd()}const Td=_d,Md=()=>K(null,null,function*(){if(!navigator)return!1;try{const s=navigator.gpu;if(typeof(s==null?void 0:s.requestAdapter)!="function"||!(yield s.requestAdapter({powerPreference:"high-performance"}))||!document.createElement("canvas").getContext("webgpu",{}))return!1}catch(s){return!1}return!0});class ct{static depthFuncToWebGL(e,t){switch(t){case n.DEPTH_FUNC.NEVER:return e.NEVER;case n.DEPTH_FUNC.LESS:return e.LESS;case n.DEPTH_FUNC.EQUAL:return e.EQUAL;case n.DEPTH_FUNC.LEQUAL:return e.LEQUAL;case n.DEPTH_FUNC.GREATER:return e.GREATER;case n.DEPTH_FUNC.NOTEQUAL:return e.NOTEQUAL;case n.DEPTH_FUNC.GEQUAL:return e.GEQUAL;case n.DEPTH_FUNC.ALWAYS:return e.ALWAYS;default:throw new Error(`Неизвестная функция теста глубины: ${t}`)}}static cullFaceModeToWebGL(e,t){switch(t){case n.CULL_FACE_MODE.FRONT:return e.FRONT;case n.CULL_FACE_MODE.BACK:return e.BACK;case n.CULL_FACE_MODE.FRONT_AND_BACK:return e.FRONT_AND_BACK;default:throw new Error(`Неизвестный режим отбрасывания: ${t}`)}}static blendFuncToWebGL(e,t){switch(t){case n.BLEND_FUNC.ZERO:return e.ZERO;case n.BLEND_FUNC.ONE:return e.ONE;case n.BLEND_FUNC.SRC_COLOR:return e.SRC_COLOR;case n.BLEND_FUNC.ONE_MINUS_SRC_COLOR:return e.ONE_MINUS_SRC_COLOR;case n.BLEND_FUNC.SRC_ALPHA:return e.SRC_ALPHA;case n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA:return e.ONE_MINUS_SRC_ALPHA;case n.BLEND_FUNC.DST_ALPHA:return e.DST_ALPHA;case n.BLEND_FUNC.ONE_MINUS_DST_ALPHA:return e.ONE_MINUS_DST_ALPHA;case n.BLEND_FUNC.DST_COLOR:return e.DST_COLOR;case n.BLEND_FUNC.ONE_MINUS_DST_COLOR:return e.ONE_MINUS_DST_COLOR;case n.BLEND_FUNC.SRC_ALPHA_SATURATE:return e.SRC_ALPHA_SATURATE;default:throw new Error(`Неизвестная функция смешивания: ${t}`)}}static blendEquationToWebGL(e,t){switch(t){case n.BLEND_EQUATION.FUNC_ADD:return e.FUNC_ADD;case n.BLEND_EQUATION.FUNC_SUBTRACT:return e.FUNC_SUBTRACT;case n.BLEND_EQUATION.FUNC_REVERSE_SUBTRACT:return e.FUNC_REVERSE_SUBTRACT;case n.BLEND_EQUATION.MIN:return n.BLEND_EQUATION.MIN;case n.BLEND_EQUATION.MAX:return n.BLEND_EQUATION.MAX;default:throw new Error(`Неизвестное уравнение смешивания: ${t}`)}}static webGLToDepthFunc(e,t){switch(t){case e.NEVER:return n.DEPTH_FUNC.NEVER;case e.LESS:return n.DEPTH_FUNC.LESS;case e.EQUAL:return n.DEPTH_FUNC.EQUAL;case e.LEQUAL:return n.DEPTH_FUNC.LEQUAL;case e.GREATER:return n.DEPTH_FUNC.GREATER;case e.NOTEQUAL:return n.DEPTH_FUNC.NOTEQUAL;case e.GEQUAL:return n.DEPTH_FUNC.GEQUAL;case e.ALWAYS:return n.DEPTH_FUNC.ALWAYS;default:throw new Error(`Неизвестная WebGL константа функции глубины: ${t}`)}}static webGLToCullFaceMode(e,t){switch(t){case e.FRONT:return n.CULL_FACE_MODE.FRONT;case e.BACK:return n.CULL_FACE_MODE.BACK;case e.FRONT_AND_BACK:return n.CULL_FACE_MODE.FRONT_AND_BACK;default:throw new Error(`Неизвестная WebGL константа режима отбрасывания: ${t}`)}}}class Ed{constructor(e){if(this.webGlExtensions={},this._canvasElement=null,this._size=[1,1],this._lastState={},this._storedStates={},e=e||{},"canvas"in e){this._canvasElement=typeof e.canvas=="string"?document.getElementById(e.canvas):e.canvas;const t={antialias:e.antialias!==void 0?e.antialias:!0,stencil:e.stencil!==void 0?e.stencil:!1,failIfMajorPerformanceCaveat:e.failIfMajorPerformanceCaveat!==void 0?e.failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer!==void 0?e.preserveDrawingBuffer:!1};this._gl=e.version===2?this._canvasElement.getContext("webgl2",t):this._canvasElement.getContext("webgl",t)||this._canvasElement.getContext("experimental-webgl",t)}else this._gl=e.gl;this._pixelRatio=e.pixelRatio||1,this.clearColor=e.clearColor||[1,1,1,1],this.webGlExtensions={},this.overrideStateMethods()}setPixelRatio(e){return this._pixelRatio=e,this}getPixelRatio(){return this._pixelRatio}setSize(e,t){return this._size=[e*this._pixelRatio,t*this._pixelRatio],this._canvasElement&&(this._canvasElement.width=this._size[0],this._canvasElement.height=this._size[1],this._canvasElement.style.width=`${e}px`,this._canvasElement.style.height=`${t}px`),this.setViewport(),this}setViewport(e=0,t=0,i,o){return i!==void 0&&o!==void 0?this._gl.viewport(e,t,i,o):this._gl.viewport(e,t,this._size[0],this._size[1]),this}getSize(){return this._size}addExtension(e){return this.webGlExtensions[e]=this._gl.getExtension(e),this}prepareTexture(e){return e.prepare(this._gl),this}bindVao(e){return e.bind({gl:this._gl,extensions:this.webGlExtensions}),this}enableTexture(e,t){return e.enable(this._gl,t),this}disableTexture(e){const t=this._gl;return t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,null),this}isDepthTextureSupported(){return Os(this._gl)}isShadowSamplerSupported(){return!(this._gl instanceof WebGLRenderingContext)&&this.isDepthTextureSupported()}isContextLost(){return this._gl.isContextLost()}storeGpuState(e){var i,o,a,r;const t=this._gl;this._storedStates[e]={depthMask:(i=this._lastState.depthMask)!=null?i:t.getParameter(t.DEPTH_WRITEMASK),depthTest:(o=this._lastState.depthTest)!=null?o:t.getParameter(t.DEPTH_TEST),depthFunc:(a=this._lastState.depthFunc)!=null?a:t.getParameter(t.DEPTH_FUNC),clearDepth:(r=this._lastState.clearDepth)!=null?r:t.getParameter(t.DEPTH_CLEAR_VALUE)}}restoreGpuState(e){const t=this._storedStates[e];if(t){const i=this._gl;this._lastState.depthMask!==t.depthMask&&i.depthMask(t.depthMask),this._lastState.depthTest!==t.depthTest&&(t.depthTest?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST)),this._lastState.depthFunc!==t.depthFunc&&i.depthFunc(t.depthFunc),this._lastState.clearDepth!==t.clearDepth&&i.clearDepth(t.clearDepth)}}drawPoints(e,t){this._gl.drawArrays(this._gl.POINTS,e,t)}drawTriangles(e,t){this._gl.drawArrays(this._gl.TRIANGLES,e,t)}drawTrianglesFan(e,t){this._gl.drawArrays(this._gl.TRIANGLE_FAN,e,t)}drawArrays(e,t,i){this._gl.drawArrays(e,t,i)}drawElements(e,t,i,o){this._gl.drawElements(e,t,i,o)}drawInstancedElements(e,t,i,o,a){const r=this._gl,l=this.webGlExtensions.ANGLE_instanced_arrays;if(r instanceof WebGLRenderingContext){if(!l)return;l.drawElementsInstancedANGLE(e,t,i,o,a)}else r.drawElementsInstanced(e,t,i,o,a)}drawInstancedArrays(e,t,i,o){const a=this._gl,r=this.webGlExtensions.ANGLE_instanced_arrays;if(a instanceof WebGLRenderingContext){if(!r)return;r.drawArraysInstancedANGLE(e,t,i,o)}else a.drawArraysInstanced(e,t,i,o)}triangleCountByDrawMode(e,t){const i=this._gl;switch(e){case i.TRIANGLES:return t/3;case i.TRIANGLE_FAN:case i.TRIANGLE_STRIP:return t-2;default:return 0}}createBuffer(e,t,i,o){return new n.Buffer(this._gl,e,t,i,o)}applyState(e,t){var a,r,l,c,d,_,u,h,f,m,p,v,x,g,y,b,M,T;const i=this._gl;if(i.depthMask((a=t==null?void 0:t.depthMask)!=null?a:e.depthMask),((r=t==null?void 0:t.depthTest)!=null?r:e.depthTest)?(i.enable(i.DEPTH_TEST),this.setDepthFunc((l=t==null?void 0:t.depthFunc)!=null?l:e.depthFunc)):i.disable(i.DEPTH_TEST),((c=t==null?void 0:t.cullFace)!=null?c:e.cullFace)?(i.enable(i.CULL_FACE),this.setCullFaceMode((d=t==null?void 0:t.cullFaceMode)!=null?d:e.cullFaceMode)):i.disable(i.CULL_FACE),(_=t==null?void 0:t.blend)!=null?_:e.blend){i.enable(i.BLEND),this.setBlendEquation((u=t==null?void 0:t.blendEquation)!=null?u:e.blendEquation);const P=(h=t==null?void 0:t.blendFuncSeparate)!=null?h:e.blendFuncSeparate;P?this.setBlendFuncSeparate(P.srcRgb,P.dstRgb,P.srcAlpha,P.dstAlpha):this.setBlendFunc((m=(f=t==null?void 0:t.blendFunc)==null?void 0:f.sfactor)!=null?m:e.blendFunc.sfactor,(v=(p=t==null?void 0:t.blendFunc)==null?void 0:p.dfactor)!=null?v:e.blendFunc.dfactor)}else i.disable(i.BLEND);const o=(x=t==null?void 0:t.colorMask)!=null?x:e.colorMask;i.colorMask(o[0],o[1],o[2],o[3]),((g=t==null?void 0:t.polygonOffsetFill)!=null?g:e.polygonOffsetFill)?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset((b=(y=t==null?void 0:t.polygonOffset)==null?void 0:y.factor)!=null?b:e.polygonOffset.factor,(T=(M=t==null?void 0:t.polygonOffset)==null?void 0:M.units)!=null?T:e.polygonOffset.units)):i.disable(i.POLYGON_OFFSET_FILL)}setDepthFunc(e){const t=ct.depthFuncToWebGL(this._gl,e);this._gl.depthFunc(t)}setCullFaceMode(e){const t=ct.cullFaceModeToWebGL(this._gl,e);this._gl.cullFace(t)}setBlendFunc(e,t){const i=ct.blendFuncToWebGL(this._gl,e),o=ct.blendFuncToWebGL(this._gl,t);this._gl.blendFunc(i,o)}setBlendFuncSeparate(e,t,i,o){const a=ct.blendFuncToWebGL(this._gl,e),r=ct.blendFuncToWebGL(this._gl,t),l=ct.blendFuncToWebGL(this._gl,i),c=ct.blendFuncToWebGL(this._gl,o);this._gl.blendFuncSeparate(a,r,l,c)}setBlendEquation(e){const t=ct.blendEquationToWebGL(this._gl,e);this._gl.blendEquation(t)}setBlendEquationSeparate(e,t){const i=ct.blendEquationToWebGL(this._gl,e),o=ct.blendEquationToWebGL(this._gl,t);this._gl.blendEquationSeparate(i,o)}setDepthMask(e){this._gl.depthMask(e)}overrideStateMethods(){const e=this._gl.depthMask.bind(this._gl);this._gl.depthMask=r=>(this._lastState.depthMask=r,e(r));const t=this._gl.enable.bind(this._gl);this._gl.enable=r=>(r===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!0),t(r));const i=this._gl.disable.bind(this._gl);this._gl.disable=r=>(r===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!1),i(r));const o=this._gl.depthFunc.bind(this._gl);this._gl.depthFunc=r=>(this._lastState.depthFunc=r,o(r));const a=this._gl.clearDepth.bind(this._gl);this._gl.clearDepth=r=>(this._lastState.clearDepth=r,a(r))}}class Id{constructor(e){this.location=null,this.name=e.name,this.type=e.type}getLocation(e,t){return this.location=e.getUniformLocation(t,this.name),this}bind(e,t){switch(this.type){case"1i":e.uniform1i(this.location,t);break;case"1f":e.uniform1f(this.location,t);break;case"2i":e.uniform2i(this.location,t[0],t[1]);break;case"2f":e.uniform2f(this.location,t[0],t[1]);break;case"3i":e.uniform3i(this.location,t[0],t[1],t[2]);break;case"3f":e.uniform3f(this.location,t[0],t[1],t[2]);break;case"4i":e.uniform4i(this.location,t[0],t[1],t[2],t[3]);break;case"4f":e.uniform4f(this.location,t[0],t[1],t[2],t[3]);break;case"1iv":e.uniform1iv(this.location,t);break;case"1fv":e.uniform1fv(this.location,t);break;case"2iv":e.uniform2iv(this.location,t);break;case"2fv":e.uniform2fv(this.location,t);break;case"3iv":e.uniform3iv(this.location,t);break;case"3fv":e.uniform3fv(this.location,t);break;case"4iv":e.uniform4iv(this.location,t);break;case"4fv":e.uniform4fv(this.location,t);break;case"mat2":e.uniformMatrix2fv(this.location,!1,t);break;case"mat3":e.uniformMatrix3fv(this.location,!1,t);break;case"mat4":e.uniformMatrix4fv(this.location,!1,t);break;default:throw new Error(`[WebGl] Unsupported uniform type: '${this.type}'`)}return this}isNonFloatType(){return this.type.includes("i")}}class Cd{constructor(e,t,i){this._gl=e,this.uniforms={},this.attributes={},this._webglProgram=null,this._linked=!1,this._located=!1,this._error=!1,this._uniformBlocksIndices={},this._uboBindings={},this._uniformBlocksMap=null,t=t||{},t.uniforms=t.uniforms||[],t.uniforms.forEach(o=>{this.uniforms[o.name]=new Id(o)}),t.attributes=t.attributes||[],t.attributes.forEach(o=>{this.attributes[o.name]=new n.ShaderAttribute(o)}),i=i!=null?i:n.EMPTY_SHADER_DEFINITIONS,this._vertexShader=t.buildVertex(i),this._fragmentShader=t.buildFragment(i)}enable(){const e=this._gl;return this._error?this:(this.link(),this.locate(),this._error?this:(e.useProgram(this._webglProgram),this))}bind(e,t){if(this._error)return this;if(e)for(const i in e)this.uniforms[i].bind(this._gl,e[i]);if(t)for(const i in t)this.attributes[i].bind(this._gl,t[i]);return this}disable(){if(this._error)return this;for(const e in this.attributes)this.attributes[e].disable(this._gl);return this}link(){if(this._linked||this._error)return this;const e=this._gl;try{if(this._webglProgram=e.createProgram(),!this._webglProgram)throw new Error("Failed to create shader program");const t=this._vertexShader.get(e),i=this._fragmentShader.get(e);t&&e.attachShader(this._webglProgram,t),i&&e.attachShader(this._webglProgram,i);for(const o in this.attributes)this.attributes[o].bindLocation(e,this._webglProgram);if(e.linkProgram(this._webglProgram),n.forceGlStatusCheck()&&!e.getProgramParameter(this._webglProgram,e.LINK_STATUS))throw new Error(e.getProgramInfoLog(this._webglProgram)||"Couldn't get shader program Info Log");this._linked=!0}catch(t){throw this._error=!0,t}return this}locate(){if(this._located||this._error||!this._webglProgram)return this;const e=this._gl;for(const t in this.attributes)this.attributes[t].getLocation(e,this._webglProgram);for(const t in this.uniforms)this.uniforms[t].getLocation(e,this._webglProgram);return this.locateUniformBlocks(this._webglProgram),this._located=!0,this}getUniformBlockIndex(e){return this._uniformBlocksIndices[e]}getUboBinding(e){return this._uboBindings[e]}getUniformBlockSize(e){if(this._gl instanceof WebGLRenderingContext)return null;const t=this._gl;let i=this._webglProgram;if(i||(this.link(),this.locate()),i=this._webglProgram,!i)return null;const o=this.getUniformBlockIndex(e);return o===void 0?null:t.getActiveUniformBlockParameter(i,o,t.UNIFORM_BLOCK_DATA_SIZE)}getUniformsIndicesOffsetsInBlock(e){if(this._gl instanceof WebGLRenderingContext)return null;const t=this._gl;let i=this._webglProgram;if(i||(this.link(),this.locate()),i=this._webglProgram,!i)return null;const o=t.getUniformIndices(i,e);if(!o)return console.error("Couldn't get UBO uniforms indices."),null;const a=o.filter(c=>c!==t.INVALID_INDEX),r=t.getActiveUniforms(i,a,t.UNIFORM_OFFSET);if(r===null)return console.error("Couldn't get active UBO uniform offsets."),null;const l={};for(let c=0;c<e.length;++c){const d=o[c];if(d!==t.INVALID_INDEX){const _=a.indexOf(d);l[e[c]]=r[_]}}return l}getUniformBlocksMap(){if(this._uniformBlocksMap)return this._uniformBlocksMap;if(this._gl instanceof WebGLRenderingContext)return null;const e=this._gl;let t=this._webglProgram;if(t||(this.link(),this.locate()),t=this._webglProgram,!t)return null;this._uniformBlocksMap={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let o=0;o<i;o++){const a=e.getActiveUniformBlockName(t,o);if(!a)continue;const r=e.getActiveUniformBlockParameter(t,o,e.UNIFORM_BLOCK_ACTIVE_UNIFORMS);if(r===null){console.error("Couldn't get number of uniforms in UBO.");continue}const l=e.getActiveUniformBlockParameter(t,o,e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);if(!l){console.error("Couldn't get uniforms indices in UBO.");continue}const c=[];for(let d=0;d<r;d++){const _=e.getActiveUniform(t,l[d]);_&&c.push(_.name)}this._uniformBlocksMap[a]=c}return this._uniformBlocksMap}locateUniformBlocks(e){const t=this._gl;if(t instanceof WebGLRenderingContext)return;let i=0;const o=this.getUniformBlocksMap();if(o)for(const a in o){const r=t.getUniformBlockIndex(e,a);r!==t.INVALID_INDEX&&(this._uniformBlocksIndices[a]=r,this._uboBindings[a]=i,t.uniformBlockBinding(e,r,i++))}}}const ks=[1,1,1,1],Ld=3.7,Pd=n.create$1(),Bd=n.create$1(),Us=n.create$2(),zd=n.create$2(),Rd=n.create$1(),Fd=n.fromValues(0,1,0),Gs=(s,e,t,i)=>{dt(t,s,{u_float_rounding_factor:e.stillness},i)},_i=(s,e,t,i)=>{dt(t,s,{u_float_border_width_offset:1/window.devicePixelRatio},i)},ji=(s,e,t,i)=>{const o=(n.POINT_CENTER_SIZE-.5)/2,{size:a}=e;dt(t,s,{u_vec2_depth_test_half_point_size:[o/a[0],o/a[1]]},i)},$=(s,e,t,i)=>{if(!t.environmentManager.isFogEnabled())return;const o=t.styleManager.getStyle(e.handyStyleId);let a=ks,r=ks;if(o){const _=n.makeBinderContext(e.styleZoom,e.styleState,[]);a=n.getColorForShaders(n.resolveColor(o.environment.style.skyColor,_)),r=n.getColorForShaders(n.resolveColor(o.environment.style.fogColor,_))}const l=t.camera,c=!e.elevation||Number.isNaN(e.elevation)?0:e.elevation*n.MAP_POINTS_IN_METER,d=Math.min(1+Math.max(c/n.zoomToHeight(e.zoom,e.size),0),Ld);dt(t,s,{u_sky_color:e.globeMode?[0,0,0,0]:a,u_fog_color:e.globeMode?[0,0,0,0]:r,u_fog_distance:e.globeMode?0:l.fogDistance,u_fog_limits:t.environmentManager.fogLimits,u_fog_horizon_blend:t.environmentManager.fogHorizonBlend,u_fog_horizon_level:t.environmentManager.fogHorizonLevel,u_fog_horizon_pad:e.cameraConfig.fogHorizonPadFactor*d},i)},W=(s,e,t,i)=>{dt(t,s,{u_cam_pos:t.camera.position},i)},te=(s,e,t,i)=>{t.shadowManager.texture&&dt(t,s,{u_shadow_map_params:t.shadowManager.shadowMapParams,u_shadow_bias:t.shadowManager.bias,u_mat4_clip_to_shadow:t.shadowManager.clipToShadowMatrix},i)},ui=(s,e,t,i)=>{dt(t,s,{u_vec2_scale_limits:[0,n.z0Scale]},i)},Hs=(s,e,t,i)=>{const o=t.camera.viewMatrixTranspose,a=t.camera.projectionMatrixInverse;dt(t,s,{u_mat4_view_transposed:o,u_mat4_proj_inverted:a},i)},to=(s,e,t,i)=>{const o=window.devicePixelRatio,a=t.camera.ecef.pixelRadius*o,{left:r,bottom:l,top:c,right:d}=e.padding,[_,u]=e.size,h=[_*o,u*o],f=[(r-d)*o/2,(l-c)*o/2],m=t.environmentManager.globHaloStops.map(b=>(a+b*o)/h[1]),p=t.styleManager.getStyle(e.handyStyleId);if(!p)return;const v=p==null?void 0:p.environment;if(!v)return;const x=n.makeBinderContext(e.styleZoom,e.styleState,[]),g=n.resolveColor(v.style.fogColor,x),y=n.resolveColor(p.background.color,x);dt(t,s,{u_vec2_halo_viewport_size:h,u_vec2_halo_viewport_center_shift:f,u_vec4_halo_radius_stops:m,u_vec4_halo_color:n.getColorForShaders(g),u_float_halo_exp_factor:t.environmentManager.globeHaloExpFactor,u_vec4_default_background_color:n.getColorForShaders(y)},i)},Vs=(s,e,t,i)=>{const o=e.size,a=Math.max(o[0],o[1]),r=o[0]/a,l=o[1]/a;n.ortho(Us,-r/2,r/2,-l/2,l/2,.001,1);const c=n.Mercator.toGeo(e.center),d=n.set(Bd,0,0,0),_=n.set(Pd,0,0,1);n.rotateX(_,_,d,n.degToRad(c[1])),n.rotateY(_,_,d,n.degToRad(c[0]));const u=n.lookAt(zd,Rd,_,Fd);n.multiply(u,Us,u);const h=t.styleManager.getStyle(e.handyStyleId);if(!h)return;const f=h==null?void 0:h.environment;if(!f)return;const m=n.makeBinderContext(e.styleZoom,e.styleState,[]),p=n.resolveNumber(f.style.starsIntensity,m);dt(t,s,{u_float_pixelratio:window.devicePixelRatio,u_float_stars_intensity:p,u_mat4_stars:u},i)},_e=(s,e,t,i)=>{const{size:o}=e,a=window.devicePixelRatio;dt(t,s,{u_vec2_vpt_size:[o[0]*a,o[1]*a]},i)};function dt(s,e,t,i){i?i.updateData(e,t):s.renderer.bindShaderProgram(e,t)}function X(...s){return(e,t,i,o)=>{s.forEach(a=>a(e,t,i,o))}}const Dd=X(Gs,_i,ji,$,W,te,ui,Hs,to,Vs,_e),Zs=X(W,$),js=(s,e,t)=>{const{size:i}=e,o=window.devicePixelRatio;if(e.demMode){const a=t.renderer.getFramebuffer(t.demManager.getFlatFramebufferId());if(!a)return;t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[Math.trunc(a.renderTarget.options.size[0]),Math.trunc(a.renderTarget.options.size[1])]})}else t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[i[0]*o,i[1]*o]})},hi=(s,e,t)=>{const i=n.zoomToScale(e.zoom);t.renderer.bindShaderProgram(s,{u_vec3_projection_scale_style_scale_dpi:[i,i,n.zptPerInch*window.devicePixelRatio]})},Ws=(s,e,t)=>{const i=n.zoomToScale(e.styleZoom);t.renderer.bindShaderProgram(s,{u_vec3_projection_scale_style_scale_dpi:[i,i,n.zptPerInch*window.devicePixelRatio]})},Wi=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_height_factor:t.buildingHeightAnimator.getDefaultBuildingHeight()})},$i=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:0})},Od=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:-1e-5})},_t=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture:0})},$s=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture1:1})},Xs=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_border_color:[0,0,0,0]})},Ks=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_space_color:[0,0,0,0]})},Nd=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_identify_opacity:e.iconIdentifyOpacity})},qs=(s,e,t)=>{const{renderer:i}=t,{labelingTextureBuffer:o,spriteLabelingTextureBuffer:a}=i;let r=e.isLabelingDepthTestDisabled;if(!r){const c=o.getDepthAttachment(),d=o.getTexture();!(c instanceof w)||!d?r=!0:(t.renderer.enableTexture(d,$r),t.renderer.enableTexture(c,Xr))}const l=a.getTexture();l&&(t.renderer.enableTexture(l,Kr),t.renderer.bindShaderProgram(s,{u_color_text_sprite_labeling:Kr})),t.renderer.bindShaderProgram(s,{u_bool_depth_test_disable:r}),r||t.renderer.bindShaderProgram(s,{u_color_tex_labeling:$r,u_depth_tex_labeling:Xr})};function fi(...s){return(e,t,i)=>{s.forEach(o=>o(e,t,i))}}function Ie(...s){return(e,t,i,o,a)=>{s.forEach(r=>r(e,t,i,o,a))}}const kd=1,Ud=2,Gd=4,ae=(s,e,t,i,o)=>{let a=n.ReservedLightingMode.none,r=n.DEFAULT_LIGHTING_MODES[a],l=0;const c=Ys(i,t,e);c&&(r=c.lightConfig,a=c.lightingMode,l=(a===n.ReservedLightingMode.none||o?0:kd)+(i.receiveShadows!==!1&&r.shadowLightIndex===0?Ud:0)+(i.receiveShadows!==!1&&r.shadowLightIndex===1?Gd:0));const d=t.renderer.getUbo(a);if(d&&t.renderer.isUboSupported()){d.bind(s),t.renderer.bindShaderProgram(s,{u_int_light_flags:l});return}t.renderer.bindShaderProgram(s,{u_int_light_flags:l,u_vec3_light_dir1_direction:r.dir1Direction,u_vec4_light_dir1_color:r.dir1ColorIntensity,u_vec3_light_dir2_direction:r.dir2Direction,u_vec4_light_dir2_color:r.dir2ColorIntensity,u_vec4_ambient_color:r.ambientColorIntensity})},ut=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),a=n.resolveNumber(i.style.nearCameraFade,o);t.renderer.bindShaderProgram(s,{u_sdtr_distance:a})},Xi=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),a=i.style.showRatio,r=n.resolveExpression(a,o);t.renderer.bindShaderProgram(s,{u_float_show_ratio:r})};function Ys(s,e,t){var r;const i=e.styleManager.getStyle(t.handyStyleId);if(!i||!i.light.lightingModesResolved)return null;let o=(r=s.lightingMode)!=null?r:i.light.defaultLightMode;s.type==="gltfModel"&&s.style.ignoreGlobalLighting&&(o=n.ReservedLightingMode.none);let a=i.light.lightingModesResolved[o];return a||(a=i.light.lightingModesResolved[i.light.defaultLightMode]),{lightingMode:o,lightConfig:a}}class H{constructor(e,t,i=null){this.isDirty=!1,this._vao=null,this._vaoExt=null,this._gl=null,this.attributesAliases={},this._attributes=t,this._shaderProgram=e,this.indicesBuffer=i}static merge(e){const t=e[0],i={},o={};for(const r of e)Object.assign(i,r._attributes),Object.assign(o,r.attributesAliases);const a=new H(t._shaderProgram,i,t.indicesBuffer);return a.setAttributesAliases(o),a}copy(){const e=new H(this._shaderProgram,B({},this._attributes),this.indicesBuffer);return e.setAttributesAliases(this.attributesAliases),e}bind(e){const t=e.extensions.OES_vertex_array_object,i=e.extensions.ANGLE_instanced_arrays;return this._bind(e.gl,t,i),this}unbind(){return this._glBindVertexArray(null),this}setAttribute(e,t){this._attributes[e]=t,this.remove()}remove(){return this._vao&&(this._glDeleteVertexArray(this._vao),this._vao=null),this}getElementsGLType(){return this.indicesBuffer?this.indicesBuffer.getGLType():null}getBuffer(e){return this._attributes[e]}rewriteData(e,t){this._attributes[e].replaceData(t),this.isDirty=!0}setAttributesAliases(e){Object.assign(this.attributesAliases,e),this.remove()}setAttributes(e,t){const i=this._shaderProgram.attributes,o=this._attributes;for(const a in i){const l=this.attributesAliases[a]||a,c=o[l];if(!c)continue;const d=i[a];if(d.index!==!0)for(let _=0;_<d.locationsCount;_++)e.enableVertexAttribArray(d.location+_);c.bind(d.location,void 0,t,d.locationsCount)}this.indicesBuffer&&this.indicesBuffer.bind()}_bind(e,t,i){this._vao?(this.isDirty&&this.updateDirtyBuffers(),this._glBindVertexArray(this._vao)):this._prepare(e,t,i)}_prepare(e,t,i){this._gl=e,t&&(this._vaoExt=t),this._vao=this._glCreateVertexArray(),this._glBindVertexArray(this._vao),this.setAttributes(e,i)}_glCreateVertexArray(){const e=this._gl,t=this._vaoExt;return e&&this._isWebGL2(e)?e.createVertexArray():t?t.createVertexArrayOES():null}_glBindVertexArray(e){const t=this._gl,i=this._vaoExt;t&&this._isWebGL2(t)?t.bindVertexArray(e):i?i.bindVertexArrayOES(e):t&&this._shaderProgram.bind(void 0,this._attributes)}_glDeleteVertexArray(e){const t=this._gl,i=this._vaoExt;t&&this._isWebGL2(t)?t.deleteVertexArray(e):i&&i.deleteVertexArrayOES(e)}_isWebGL2(e){return typeof window!="undefined"&&"WebGL2RenderingContext"in window&&e instanceof WebGL2RenderingContext}updateDirtyBuffers(){const e=this._shaderProgram.attributes,t=this._attributes,i=this.attributesAliases;for(const o in e){const a=i[o]||o,r=t[a];r!=null&&r.isDirty&&r.commitData()}this.isDirty=!1}}const Hd=(s,e)=>{const t=n.PolygonGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0});return new H(e,{a_vec2_vertex:i})},Vd=(s,e)=>{const t=n.PolygonGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedShort,stride:t,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_mix_factor:o})},Zd=(s,e)=>{const t=n.PolygonGenerator.sinks.shadow.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0});return new H(e,{a_vec2_vertex:i})},jd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},Wd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:8,offset:4,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec4_identifier:o})},$d=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:12,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec4_normals:o})},Xd=(s,e)=>{const t=n.LineGenerator.sinks.solid3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:a,a_float_abs_z:r})},Kd=(s,e)=>{const t=n.LineGenerator.sinks.solid3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:a,a_float_abs_z:r,a_vec4_identifier:l})},qd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:16,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:16,offset:8,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec4_normals:o,a_vec2_shift:a})},Yd=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:12,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:12,offset:8,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec4_normals:o,a_vec4_identifier:a})},Qd=(s,e)=>{const t=n.LineGenerator.sinks.patterned.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:a,a_vec4_identifier:r})},Jd=(s,e)=>{const t=n.LineGenerator.sinks.patterned3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:a,a_float_height:r,a_vec4_identifier:l})},Qs=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:28,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:28,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:28,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:28,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:28,offset:24,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_texture_widen:a,a_vec2_widen:o,a_float_vertex_distance:r,a_float_component_distance:l,a_float_object_length:c,a_vec4_identifier:d})},Js=(s,e)=>{const t=n.DashedLineGenerator.sinks.stroke3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:24,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:28,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_texture_widen:a,a_vec2_widen:o,a_float_vertex_distance:r,a_float_component_distance:l,a_float_object_length:c,a_float_height:d,a_vec4_identifier:_})},As=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:36,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:20,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:28,normalized:!0}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_check_offset:r,a_vec2_offset:a,a_vec2_texcoord:l,a_vec4_tex_identifier:c,a_vec4_sprite_identifier:d})},Ad=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:36,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:24,normalized:!0});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec4_identifier:r})},Ki=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:28,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:28,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1});return new H(e,{a_vec4_position:i,a_vec2_offset:a,a_vec2_texcoord:o,a_vec2_style_zoom_limits:r})},ea=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:11,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:a,a_float_gradient:r,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:d,a_float_is_pivot:_})},e_=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:11,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:a,a_float_gradient:r,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:_,a_float_is_pivot:d})},ta=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_float_abs_z:r,a_float_is_pivot:l})},qi=(s,e)=>{const t=n.MeshGenerator.sinks.inverse.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_float_abs_z:r,a_float_is_pivot:l})},t_=(s,e)=>{const t=n.MeshGenerator.sinks.stroke.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:a,a_vec2_dem_position:r,a_float_abs_z:l,a_float_is_pivot:c})},ia=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.sideFill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},i_=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.sideTexture.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_vec2_wall_size:r,a_vec2_quad_fraction:l})},na=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.topFill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},oa=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:8,normalized:!0}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new H(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},sa=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1}),r=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:16,normalized:!0});return new H(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},aa=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new H(t,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},n_=(s,e)=>{const t=n.LineExtrusionGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},o_=(s,e)=>{const t=n.LineExtrusionGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},ra=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:20,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:20,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:20,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:20,offset:10,normalized:!1}),l=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:20,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:20,offset:15,normalized:!1}),d=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:20,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_normal:a,a_vec2_normal_delta:r,a_vec3_direction:l,a_float_distance:c,a_vec2_dem_position:d})},s_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:40,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:40,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:40,offset:20,normalized:!1}),c=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:24,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:40,offset:32,normalized:!0});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec2_check_offset:r,a_vec2_texcoord:l,a_vec2_range:c,a_vec4_tex_identifier:d})},a_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:40,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:40,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:40,offset:20,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:24,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:40,offset:36,normalized:!0});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec2_texcoord:r,a_vec2_range:l,a_vec4_identifier:c})},r_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:40,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:40,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:40,offset:20,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:24,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:40,offset:28,normalized:!0});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:a,a_vec2_texcoord:r,a_vec2_range:l,a_vec4_identifier:c})},l_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:16,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:16,offset:12,normalized:!0});return new H(e,{a_vec4_position:i,a_vec2_offset:o,a_vec4_identifier:a})},la=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:10,normalized:!1});return new H(e,{a_vec2_position:i,a_vec2_direction:o,a_vec2_widen_direction:a})},c_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_texcoord:a,a_vec2_dem_position:r})},d_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},__=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},u_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},h_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:8,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:8,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec4_direction_distance:o})},io=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:16,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:16,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:16,offset:12,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:a,a_vec2_dem_position:r})},ca=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:4,normalized:!0}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:36,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:24,normalized:!1}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:28,normalized:!1}),u=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_segment_end:o,a_vec4_texture_widen_arrow_widen:a,a_vec2_widen:r,a_vec2_direction:l,a_float_distance_from_start:c,a_float_object_length:d,a_float_type:_,a_vec4_identifier:u})},no=(s,e)=>{const t=n.CircleMarkerGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:t,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_widen:a})},f_=(s,e)=>{const t=n.CircleMarkerGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:t,offset:6,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new H(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_widen:a,a_vec4_identifier:r})},m_=(s,e)=>{const t=n.RasterGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},p_=(s,e)=>{const t=n.HeatmapGenerator.sinks.framebuffer.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new H(e,{a_vec2_position:i,a_vec2_widen:a,a_float_weight:o})},v_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new H(e,{a_vec2_position:t})},da=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:12,offset:0});return new H(e,{a_vec3_position:i})},Yi=(s,e)=>new H(e,{a_vec2_position:s}),mi=(s,e)=>{const t=n.DemGenerator.sinks.mesh2.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_height:o})},g_=(s,e)=>{const t=n.DemGenerator.sinks.flatBottom.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_centroid:o,a_vec2_extender:a})},oo=(s,e)=>{const t=n.DemGenerator.sinks.hillshade.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:4,normalized:!1});return new H(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},Qi=s=>(e,t,i,o)=>{const a=n.GltfModelGenerator.sinks.instances.stride,r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:a,offset:0,normalized:!0,instanceDivisor:1}),l=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:a,offset:4,normalized:!1,instanceDivisor:1}),c=new n.BufferChannel(e,{itemSize:3,dataType:n.Buffer.Short,stride:a,offset:8,normalized:!0,instanceDivisor:1}),d=new n.BufferChannel(e,{itemSize:9,dataType:n.Buffer.Float,stride:a,offset:16,instanceDivisor:1}),_=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:a,offset:s?56:52,normalized:!0,instanceDivisor:1}),u=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:a,offset:60,normalized:!1,instanceDivisor:1});return new H(t,B({a_vec2_instance_position:r,a_float_instance_height:l,a_vec3_instance_ecef_position:c,a_mat3_instance_matrix:d,a_vec4_instance_localid:_,a_float_abs_z:u},o),i)},so=(s,e)=>{const t=n.MapMeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:15,normalized:!1}),c=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_extender:a,a_vec3_normal:r,a_float_gradient:l,a_vec2_dem_position:c,a_float_abs_z:d,a_float_is_pivot:_})},y_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new H(e,{a_vec2_vertex:t})},pi=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1});return new H(e,{a_vec2_vertex:t})},_a=(s,e,t)=>{const i=n.GlobeGenerator.sinks.fill.stride;return new H(e,{a_vec3_ecef_position:new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Short,stride:i,normalized:!0,offset:0}),a_vec3_flat_position:new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:i,normalized:!0,offset:6}),a_vec2_texture:new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:i,normalized:!0,offset:12})},t)},x_=(s,e)=>new H(e,{a_vec3_position:new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:16,offset:0,normalized:!0}),a_fade_opacity:new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:16,offset:12,normalized:!1})}),$t=32,ua=1/0,b_="raster";class ha extends n.TileObjectBase{constructor(e,t,i){var a;super(b_),this.children=[],this.identifyChildren=[];const o=this;this.setTileCoords(e,t.map.state),(a=t.renderer.symbolSettingsList.dem.mesh)==null||a.forEach(r=>{const l={id:n.uniqId(),type:n.SceneObjectType.Tile,symbol:"dem",sink:"mesh",tile:this,attributes:{layerId:n.DEM_STYLE_LAYER_ID,styleId:t.map.state.handyStyleId,tileData:[]},start:0,count:$t*$t*6,attributesHash:"",layerSettings:r,vao:i.mesh,canRender:!0,renderingProperties:{flatTexture:null,hillshadeTexture:null,flatIdentifyTexture:null}};r.identify?o.identifyChildren.push(l):r.depthTest?o.depthTestChildren.push(l):r.shadow?o.shadowChildren.push(l):r.dem?o.demChildren.push(l):r.demGround?o.demGroundChildren.push(l):o.children.push(l)})}setTileCoords(e,t){const i=e[2],o=e[3],a=n.tileZoomToSize(i);this.coords=e,this.size=a,this.zoomLevel=i,this.detailLevel=o,this.mvpMatrices.clear(),this.demMatrices.clear(),this.flatMapTexMatrices.clear(),this.syncReplicas(t)}syncReplicas({visibleMapReplicas:e}){const t=Math.pow(2,this.coords[2]),i=this.size/$t;this.bounds.clear(),this.modelMatrices.clear(),e.forEach(o=>{const a=[this.coords[0]+o*t,this.coords[1],this.coords[2],this.coords[3]],r=n.tileCoordsToMapPoint(a);r[0]-=i,r[1]-=i,this.bounds.set(o,{min:[r[0],r[1]],max:[r[0]+this.size,r[1]+this.size]});const l=n.create$2();n.fromTranslationScale(l,r,n.fromValues(this.size+i,this.size+i,n.tileHeight)),this.modelMatrices.set(o,l)}),this.needSync=!1}}class w_{constructor(e,t){var a;this.meshTiles=new Map,this.destroyed=!1,this.modules=e.modules,this.maxZoom=(a=t==null?void 0:t.maxZoom)!=null?a:ua;const i=[];for(let r=0;r<$t;r++)for(let l=0;l<$t;l++)i.push(l,r,l+1,r,l,r+1),i.push(l,r+1,l+1,r,l+1,r+1);const o=n.maxUint16Value/$t;for(let r=0;r<i.length;r++)i[r]*=o;this.buffer=this.modules.renderer.createBuffer(new Uint16Array(i),{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:0,offset:0,normalized:!0}),this.buffer.drawType=n.Buffer.StaticDraw,this.vaos={mesh:Yi(this.buffer,this.modules.renderer.getShaderProgram("demMesh"))},this.update()}destroy(){this.destroyed||(this.meshTiles=new Map,Object.values(this.vaos).forEach(e=>{e.unbind(),e.remove()}),this.buffer.remove(),this.destroyed=!0)}setMaxZoom(e=ua){e!==this.maxZoom&&(this.maxZoom=e,this.update())}update(){if(this.destroyed)return;const e=this.modules.map.state;e.needReplicasUpdate&&this.meshTiles.forEach(a=>{a.needSync=!0});const t=Math.trunc(e.styleZoom),i=Math.min(t,Math.min(this.maxZoom,t)),o=n.findVisibleTiles(this.modules.map.state,this.modules,i,0,i,void 0,void 0,void 0,!0).reduce((a,r)=>(a.set(n.coordsToKey(r),r),a),new Map);this.meshTiles.forEach((a,r)=>{o.has(r)||this.meshTiles.delete(r)}),o.forEach((a,r)=>{this.meshTiles.has(r)||this.meshTiles.set(r,new ha(a,this.modules,this.vaos))})}updateStyleId(){this.meshTiles.forEach(e=>this.updateTileStyleId(e))}updateTileStyleId(e){e.children.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.identifyChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.depthTestChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.shadowChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.demChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.demGroundChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId})}}class S_{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="dem",this.tree=n.rbush(n.DEM_TREE_SIZE),this.tileSize=n.DEM_ELEVATION_TILE_SIZE,this.minElevation=0,this.revision=0,this.tileLoader=new n.BaseTileLoader("arrayBuffer"),this.attributes={},this.tiles=new Map,this.textureIndices=new Map,this.url=o=>{const[a,r,l]=n.tileCoordsToOSM(o);return this.options.url(a,r,l)}}abortTileFetches(e){this.tileLoader.abortRequests(e.map(n.coordsToKey))}deleteTiles(e){for(const t of e){const i=n.coordsToKey(t);if(this.tiles.get(i)){const a=n.getTileBounds(t);this.tree.remove({minX:a.min[0],minY:a.min[1],maxX:a.max[0],maxY:a.max[1]},(r,l)=>i===l.key),this.updateRevision()}this.tiles.delete(i);const o=this.textureIndices.get(i);o!==void 0&&this.modules.imageManager.deleteTexture(o),this.updateMinElevation()}}fetchTiles(e){return e.map(t=>this.fetchTile(t))}generateTile(e,t){return K(this,null,function*(){const i=[],o=[],a=n.coordsToKey(t),r=this.tiles.get(a);if(!r)return Promise.resolve({results:i,transferable:o});const l=this.modules.map.state.handyStyleId,{collector:c}=this.modules,d=n.tileZoomToSize(t[2]),_=r.bounds;this.tree.insert(de(B({key:a,minX:_.min[0],minY:_.min[1],maxX:_.max[0],maxY:_.max[1],cellSize:d/n.DEM_ELEVATION_TILE_SIZE},r),{tree:null,bounds:_,generated:i})),this.updateMinElevation(),this.updateRevision();do n.DemGenerator.generateMeshElevation(c,r.mesh,l,n.DEM_STYLE_LAYER_ID);while(c.isOverloaded());const u=c.getAccumulatedData();return i.push({regionId:0,metatileHash:-1,styleId:l,collectorOutput:u}),o.push(...u.transferable),Promise.resolve({results:i,transferable:o})})}unpackRaw(e,t){const[i,o,a,r]=t,l=new Uint8Array(e),c=new Float32Array(je(this.tileSize,2));let d=1/0,_=-1/0;const u=this.tileSize;for(let f=0;f<u;f++){const m=n.Mercator.toGeo(n.tileCoordsToMapPoint([i,o+f*(1/n.DEM_ELEVATION_TILE_SIZE),a,r])),p=n.Mercator.scaleFactor(m[1]);for(let v=0;v<u;v++){const x=v+f*u,g=(l[x]+l[je(u,2)+x]*256-1e4)*p;d=Math.min(g,d),_=Math.max(g,_),c[x]=g}}const h=this.getMesh(c);return{data:c,mesh:h,minZ:d,maxZ:_,bounds:{min:n.tileCoordsToMapPoint(t),max:n.tileCoordsToMapPoint([i+1,o+1,a,r])}}}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}getId(){return this.id}destroy(){const{imageManager:e}=this.modules;this.tileLoader.destroy(),this.tiles.clear(),this.tree.clear(),this.textureIndices.forEach(t=>e.deleteTexture(t)),this.textureIndices.clear()}getElevation(e){const t=this.getElevationTile(e);if(t)return n.getElevationFromTile(t,e)}getElevationTile(e){const t=n.normalizeMapPoint(e);return this.tree.search({minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}).reduce((o,a)=>!o||o.cellSize>a.cellSize?a:o,void 0)}getMinElevation(){return this.minElevation}updateMinElevation(){const e=this.modules.map.state;if(!e.demMode)return;const t=this.modules.camera.position[2],i=n.tetragonBounds(e.tilesBounds);if(e.elevation!==void 0){const a=e.elevation*n.MAP_POINTS_IN_METER/t+1,r=Math.max(e.pitch/e.maxPitch*30,4);n.scale$1(i,Math.min(a,r))}const o=this.tree.search({minX:i.min[0],minY:i.min[1],maxX:i.max[0],maxY:i.max[1]});e.styleZoom-vo>1?this.minElevation=o.reduce((a,r)=>{if(r.data){const l=n.intersection(i,r.bounds);n.sub(l.min,l.min,r.bounds.min),n.sub(l.max,l.max,r.bounds.min),n.scale$2(l.min,l.min,1/r.cellSize),n.scale$2(l.max,l.max,1/r.cellSize);for(let c=Math.trunc(l.min[0]);c<l.max[0];c++)for(let d=Math.trunc(l.min[1]);d<l.max[1];d++){const _=c+(n.DEM_ELEVATION_TILE_SIZE-1-d)*n.DEM_ELEVATION_TILE_SIZE,u=r.data[_];a=a===void 0?u:Math.min(a,u)}}return a},void 0):this.minElevation=o.reduce((a,r)=>a===void 0?r.minZ:Math.min(a,r.minZ),void 0)}getRevision(){return this.revision}fetchTile(e){const t=n.coordsToKey(e),i=[{regionId:0,metatileHash:-1}];if(this.tiles.has(t))return Promise.resolve(i);const o=this.url(e);return this.tileLoader.fetch(e,()=>o).then(a=>(a.rejected||this.tiles.set(t,a.data&&a.data.byteLength?this.unpackRaw(a.data,e):void 0),i),()=>Promise.resolve(void 0))}updateRevision(){this.revision++}getMesh(e){const t=this.tileSize,i=t*t,o=new Uint16Array(i*2),a=new Uint16Array(i*6);let r=0;for(let l=0;l<t;l++)for(let c=0;c<t;c++){const d=l*t+c;o[2*d+0]=c/(t-1)*n.maxTilePoint,o[2*d+1]=(1-l/(t-1))*n.maxTilePoint,c<t-1&&l<t-1&&(a[r++]=d+1,a[r++]=d,a[r++]=d+t,a[r++]=d+1,a[r++]=d+t,a[r++]=d+t+1)}return{positions:o,heights:e,indices:a}}}class T_{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="dem",this.tree=n.rbush(n.DEM_TREE_SIZE),this.minElevation=0,this.revision=0,this.worker=new t.workers.parser.MeshElevationSource(this.options),this.attributes={},this.tiles=new Map}abortTileFetches(e){this.worker.abortTileFetches(e)}deleteTiles(e){this.worker.deleteTiles(e);for(const t of e){const i=n.coordsToKey(t),o=this.tiles.get(i);o&&(this.tree.remove(o,(a,r)=>i===r.key),this.tiles.delete(i))}this.updateMinElevation()}fetchTiles(e){return this.worker.fetchTiles(e)}generateTile(e,t){return K(this,null,function*(){const i=n.coordsToKey(t),{tree:o,results:a,minZ:r,maxZ:l}=yield this.worker.generateTile(e.handyStyleId,t),c=n.getTileBounds(t),d={generated:a,key:i,minX:c.min[0],minY:c.min[1],maxX:c.max[0],maxY:c.max[1],cellSize:n.tileZoomToSize(t[2])/n.DEM_ELEVATION_TILE_SIZE,bounds:c,minZ:r,maxZ:l,tree:o};return this.tiles.set(i,d),this.tree.insert(d),this.updateMinElevation(),this.updateRevision(),{results:a}})}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}getId(){return this.id}destroy(){this.tiles.clear(),this.tree.clear()}getElevation(e){const t=this.getElevationTile(e);if(t)return n.getElevationFromTile(t,e)}getElevationTile(e){const t=n.normalizeMapPoint(e);return this.tree.search({minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}).reduce((o,a)=>!o||o.cellSize>a.cellSize?a:o,void 0)}getMinElevation(){return this.minElevation}updateMinElevation(){const e=this.modules.map.state;if(!e.demMode)return;const t=n.tetragonBounds(e.tilesBounds),i=this.tree.search({minX:t.min[0],minY:t.min[1],maxX:t.max[0],maxY:t.max[1]});this.minElevation=i.reduce((o,a)=>o===void 0?a.minZ:Math.min(o,a.minZ),void 0)}getRevision(){return this.revision}updateRevision(){this.revision++}}const $e=new Float64Array(16);class ao{constructor(e,t,i){this.detailLevel=0,this.mvpMatrix=new Float64Array(16),this.texMatrix=new Float64Array(16),n.copy(this.mvpMatrix,e),n.multiply(this.texMatrix,n.WEBGL_COORDS_TO_TEXTURE,e),this.detailLevel=i,this.viewport=[[0,0,0,1],[1,0,0,1],[1,1,0,1],[0,1,0,1]],n.invert($e,this.texMatrix),this.viewport.forEach(o=>{n.transformMat4$1(o,o,$e),o[0]-=t[0],o[1]-=t[1],o[2]-=t[2],o[2]>=0&&(o[2]=-1),n.normalize(o,o);const a=-t[2]/o[2];o[0]=t[0]+o[0]*a,o[1]=t[1]+o[1]*a,o[2]=t[2]+o[2]*a})}}class M_{constructor(e){this.destroyed=!1,this.modules=e.modules,this.textures=[]}update(){if(this.destroyed)return;const{center:e,padding:t,rotation:i,size:o,viewport:a,extendedTilesBounds:r,zoom:l,cameraConfig:c,globeMode:d}=this.modules.map.state,_=n.getLineConstants(r[0],r[1]),u=n.pointToLineDistance(r[2],_);this.textures=[];const h=n.degToRad(45),f=Math.min(this.modules.map.state.pitch,h),m=new n.Camera({pitch:f,center:e,padding:t,rotation:i,size:o,viewport:a,zoom:l,cameraConfig:c,globeMode:d,styleState:{}}),p=n.clamp(Math.pow(this.modules.map.state.pitch/h,3),0,1),[v,x]=this.modules.camera.position,g=n.transformMat4([],[v,x,0,1],m.viewProjectionMatrix),y=Math.min(g[1]/g[3]+1,-.5);let b=Math.max(y,-1);if(n.fromTranslationScale($e,[0,-b,0],[1/ze[0],1/ze[1],1]),n.multiply($e,$e,m.viewProjectionMatrix),this.textures.push(new ao($e,m.position,0)),n.pointToLineDistance(this.textures[0].viewport[2],_)>=u)return!0;if(y<b){const T=Math.max(Math.abs(y-b)/2,1);n.fromTranslationScale($e,[0,2/T+1,0],[1/ze[0],ze[1]/T,1]),n.multiply($e,$e,m.viewProjectionMatrix),this.textures.push(new ao($e,m.position,1))}b+=1;const M=Math.pow(o[1]/749,2);[1.4,3.2,12,31].some((T,P)=>{T=(T-1)*p*M+1,n.fromTranslationScale($e,[0,-(b*T+1),0],[1/ze[0],T/ze[1],1]),n.multiply($e,$e,m.viewProjectionMatrix),b+=2/T;const S=this.textures.push(new ao($e,m.position,P));if(n.pointToLineDistance(this.textures[S-1].viewport[2],_)>=u)return!0})}destroy(){this.textures=[]}}const ro={depthMask:!0,depthTest:!0,depthFunc:n.DEPTH_FUNC.LESS,cullFace:!0,cullFaceMode:n.CULL_FACE_MODE.BACK,blend:!1,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ZERO},blendEquation:n.BLEND_EQUATION.FUNC_ADD,colorMask:[!0,!0,!0,!0],polygonOffsetFill:!1,polygonOffset:{factor:1,units:2}},ce=s=>{if(typeof s=="function")return t=>{const i=s(t);return Object.assign({},ro,i)};const e=Object.assign({},ro,s);return()=>e},ge=ce({}),lo=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),E_=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},depthFunc:n.DEPTH_FUNC.GREATER,depthMask:!1,cullFace:!1,polygonOffsetFill:!0,polygonOffset:{factor:1,units:2}}),Xt=ce({depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),I_=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},cullFace:!1}),Re=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),C_=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},blendEquation:n.BLEND_EQUATION.MAX}),L_=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA,dfactor:n.BLEND_FUNC.ONE}}),fa=ce({depthMask:!1,depthTest:!1,colorMask:[!0,!1,!1,!0]}),P_=ce({depthMask:!1,depthTest:!1}),St=ce({depthMask:!1,depthTest:!1}),ma=ce({depthMask:!1}),Ji=ce({colorMask:[!1,!1,!1,!1]}),B_=ce({colorMask:[!1,!1,!1,!1],depthFunc:n.DEPTH_FUNC.ALWAYS}),pa=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),z_=ce({depthFunc:n.DEPTH_FUNC.EQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),co=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),_o=ce({depthMask:!1,depthTest:!0,depthFunc:n.DEPTH_FUNC.LEQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),uo=ce({depthMask:!1,depthTest:!0,depthFunc:n.DEPTH_FUNC.GREATER,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),va=ce({polygonOffsetFill:!0,polygonOffset:{factor:1,units:2},blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),Ai=ce({cullFaceMode:n.CULL_FACE_MODE.BACK}),en=ce({cullFace:!1}),ga=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE}}),R_=ce({depthTest:!1,cullFace:!1}),F_=ce({depthTest:!1,depthMask:!1,blend:!0,blendFuncSeparate:{srcRgb:n.BLEND_FUNC.SRC_ALPHA,dstRgb:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA,srcAlpha:n.BLEND_FUNC.ONE,dstAlpha:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),ya=ce({colorMask:[!0,!0,!0,!0],depthMask:!0}),D_=ce({colorMask:[!0,!0,!0,!0],depthMask:!1}),O_=ce({depthMask:!0,depthTest:!0,depthFunc:n.DEPTH_FUNC.LEQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),N_=ce({depthMask:!0,depthTest:!0,depthFunc:n.DEPTH_FUNC.LEQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA_SATURATE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_COLOR}}),k_=ce({depthMask:!0,depthTest:!0}),xa=ce(s=>s.map.getFeatureFlag("transparentBuildingsOff")?ge(s):z_(s)),U_=ce(()=>({depthFunc:n.DEPTH_FUNC.LEQUAL,depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}})),ho=n.reserveTextureIndex(),fo=n.reserveTextureIndex(),mo=n.reserveTextureIndex(),po=n.reserveTextureIndex(),Tt=64,ba=5,vo=12,wa=5,Sa=15,G_=18,H_=12,V_=18,Z_=.1,j_=.3,ze=[1.7,1],W_=300,go=.001,Ta=1,$_=n.tileZoomToSize(n.tiles.maxRegionalZoom),X_={localhost:{tileServer:"localhost:8181",tileProtocol:"http",subdomains:[]},relief_test:{tileServer:"tileserver.web-staging.2gis.ru",tileProtocol:"https",subdomains:["0","1","2"]},relief_test2:{tileServer:"tileserver.web-staging.2gis.ru",tileProtocol:"https",subdomains:["0","1","2"]}},tn=n.create$1(),Oe=new Float64Array(16);class K_{constructor(e){this.demTextureMatrix=new Float64Array(16),this.demCorrectedFbVpToDemTex=new Float32Array(16),this.demTexToCorrectedTex=new Float32Array(16),this.correctedTexToDemTex=new Float32Array(16),this.isDemCorrectionEnabled=!1,this.demCorrectedScale=1,this.demFbVpMatrix=new Float64Array(16),this.demCorrectedFbVpMatrix=new Float64Array(16),this.demFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.correctedDemFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.flatFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.identifyFlatFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.hillshadeRampTextureId=NaN,this.hillshadeFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.groundFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.isGroundBufferValid=!1,this.lastStyleId=NaN,this.disableAnimation=!1,this.isAnimationStarted=!1,this.tilesRevision=0,this.tileSet=n.dem.tileSet,this.modules=e,this.enabled=!1,this.sources=[],this.sourcesRevision=[],this.tileLayers=[],this.terrainAnimationScaleCoef=go,this.reliefTileType="vector",this.elevationSourceType="irregular",this.groundBuffer=new Float32Array,this.differ=new n.Differ([])}enable(){if(this.isTerrainSupported===void 0&&(this.isTerrainSupported=Ds()),this.enabled||!this.isTerrainSupported)return;this.enabled=!0,this.differ=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this.demFramebufferId=this.createDemFramebuffer(),this.correctedDemFramebufferId=this.createCorrectedDemFramebuffer(),this.hillshadeFramebufferId=this.createHillshadeFramebuffer(),this.flatFramebufferId=this.createFlatFramebuffer(),this.identifyFlatFramebufferId=this.createFlatIdentifyFramebuffer(),this.groundFramebufferId=this.createGroundFramebuffer(),this.fullscreenBuffer=this.modules.renderer.createBuffer(new Uint16Array([[0,0,0,0],[1,0,1,0],[0,1,0,1],[0,1,0,1],[1,0,1,0],[1,1,1,1]].reduce((t,i)=>{const[o,a,r,l]=i;return t.push(o*n.maxUint16Value,a*n.maxUint16Value,n.packTexCoords(r),n.packTexCoords(l)),t},[]))),this.hillshadeVao=oo(this.fullscreenBuffer,this.modules.renderer.getShaderProgram("demHillshade"));const e=this.modules.renderer.getShaderProgram("demElevationCopy");this.copyDemVao=oo(this.fullscreenBuffer,e),this.addDefaultSources(),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:this.hillshadeFramebufferId,flatBottom:this.correctedDemFramebufferId}),this.updateRampTextureId(),this.startVerticalScaleAnimation()}setAnimationTerrain(e){this.modules.demManager.disableAnimation=!e}getAnimationTerrainStatus(){return this.modules.demManager.disableAnimation}onTerrainStyleChange(){this.updateRampTextureId()}disable(){var t,i,o,a;if(!this.enabled)return;this.dangerouslyDestroySourcesAndLayers(),(t=this.flatMapSource)==null||t.destroy(),this.flatMapSource=void 0,(i=this.hillshadeVao)==null||i.unbind(),(o=this.hillshadeVao)==null||o.remove(),(a=this.fullscreenBuffer)==null||a.remove(),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:n.INVALID_FRAMEBUFFER_ID,flatBottom:n.INVALID_FRAMEBUFFER_ID}),this.modules.renderer.removeFramebuffer(this.hillshadeFramebufferId),this.modules.renderer.removeFramebuffer(this.demFramebufferId),this.modules.renderer.removeFramebuffer(this.correctedDemFramebufferId),this.modules.renderer.removeFramebuffer(this.flatFramebufferId),this.modules.renderer.removeFramebuffer(this.groundFramebufferId),this.enabled=!1;const e=this.modules.map.state;this.terrainAnimationScaleCoef=go,this.isAnimationStarted=!1,n.exist("changeScale",e)&&n.stop("changeScale",e)}update(){var o,a,r,l;if(!this.enabled)return;const e=this.modules.map.state;this.lastStyleId!==e.handyStyleId&&(this.updateRampTextureId(),(o=this.meshSource)==null||o.updateStyleId(),(a=this.hillshadeTile)==null||a.children.forEach(c=>{c.attributes.styleId=e.handyStyleId}),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:this.hillshadeFramebufferId,flatBottom:this.correctedDemFramebufferId}),this.updateClearColor(),this.lastStyleId=e.handyStyleId);const t=this.updateTilesRevision(),i=this.differ.check(this.modules.map.state);(t||i)&&(this.isGroundBufferValid=!1),i&&(this.updateMinElevation(),(r=this.flatMapSource)==null||r.update(),(l=this.meshSource)==null||l.update(),this.updateDemFramebufferMatrix(),this.modules.renderer.addRerenderEvent()),this.disableAnimation||(this.isAnimationStarted?n.update("changeScale",{step:(c,d)=>{d===Ta&&n.stop("changeScale",e),this.terrainAnimationScaleCoef=d}},e):this.startVerticalScaleAnimation())}isEnabled(){return this.enabled}getDemFramebufferId(){return this.demFramebufferId}getGroundFramebufferId(){return this.groundFramebufferId}getCorrectedDemFramebufferId(){return this.correctedDemFramebufferId}getFlatFramebufferId(){return this.flatFramebufferId}getIdentifyFlatFramebufferId(){return this.identifyFlatFramebufferId}getHillshadeFramebufferId(){return this.hillshadeFramebufferId}getHillshadeRampTextureId(){return this.hillshadeRampTextureId}getElevation(e){if(this.enabled)for(let t=this.sources.length-1;t>=0;t--){const o=this.sources[t].getElevation(e);if(o!==void 0)return o}}getLabelsDemKey(e){if(!this.enabled||e.length===0)return;let t;for(const o of e)if(t=o.labels.find(a=>a.type===n.PreLabelType.Point),t)break;if(!t)return;n.vertexTilePointToMapPoint(tn,t.vertices,0,n.createTileInfo(t.tileCoords));let i;for(let o=this.sources.length-1;o>=0;o--){const r=this.sources[o].getElevationTile(tn);if(r!==void 0){i=r;break}}if(i)return i.key}enrichWithElevation(e){var t;if(this.enabled)for(const i of e){let o=null;for(const a of i.labels)a.type===n.PreLabelType.Point&&(o||(o=n.createTileInfo(a.tileCoords)),n.vertexTilePointToMapPoint(tn,a.vertices,0,o),a.demElevation=(t=this.getElevation(tn))!=null?t:NaN)}}getMinElevation(){return this.sources.reduce((e,t)=>{const i=t.getMinElevation();return i===void 0?e:e===void 0?i:Math.min(e,i)},void 0)}updateMinElevation(){this.sources.forEach(e=>e.updateMinElevation())}getMeshTiles(){return this.reliefTileType==="raster"?this.elevationSourceType==="regular"&&this.meshSource?Array.from(this.meshSource.meshTiles.values()):[]:this.tileLayers.reduce((e,t)=>{const i=t.getDisplayedTileObjects();return e.push(...i),e},[])}getReliefTileType(){return this.reliefTileType}getElevationSourceType(){return this.elevationSourceType}setReliefTileType(e){this.reliefTileType!==e&&(this.reliefTileType=e,this.enabled&&(this.dangerouslyDestroySourcesAndLayers(),this.elevationSourceType==="regular"?this.addRegularElevationSources():this.addIrregularElevationSources(),this.modules.renderer.addRerenderEvent()))}setElevationSourceType(e){this.elevationSourceType!==e&&(this.elevationSourceType=e,this.enabled&&(this.dangerouslyDestroySourcesAndLayers(),this.elevationSourceType==="regular"?this.addRegularElevationSources():this.addIrregularElevationSources(),this.modules.renderer.addRerenderEvent()))}getFlatMapTextures(){return this.flatMapSource?this.flatMapSource.textures.slice():[]}clearTextureBindings(){this.modules.renderer.disableTexture(0),this.modules.renderer.disableTexture(ho),this.modules.renderer.disableTexture(po),this.modules.renderer.disableTexture(fo),this.modules.renderer.disableTexture(mo)}setMeshMaxZoom(e){var t;this.meshMaxZoom=e,(t=this.meshSource)==null||t.setMaxZoom(e)}getVerticalScale(){const e=this.modules.map.state,t=this.modules.styleManager.getStyle(e.handyStyleId);if(!t)return 0;const i=t.dem.style,o=n.makeBinderContext(e.styleZoom,e.styleState,[]);return this.disableAnimation?n.resolveNumber(i.verticalScale,o):n.resolveNumber(i.verticalScale,o)*this.terrainAnimationScaleCoef}getTilesRevision(){return this.tilesRevision}setTileSet(e){this.tileSet=e,this.enabled&&(this.disable(),this.enable())}getGroundPoint(e){if(!this.enabled||(this.updateGround(),!this.isGroundBufferValid))return;const t=this.modules.renderer.getFramebuffer(this.groundFramebufferId);if(!t)return;const i=t.renderTarget.options.size,o=e[0]-this.modules.map.state.viewport.left,a=e[1]-this.modules.map.state.viewport.top;if(o<0||o>i[0]-1||a<0||a>i[1]-1)return;const l=((i[1]-a-1)*i[0]+o)*4;if(this.groundBuffer[l+3]===0)return;const[d,_]=n.Mercator.toGeo([this.groundBuffer[l],this.groundBuffer[l+1]]);return[d,_,this.groundBuffer[l+2]]}startVerticalScaleAnimation(){const e=this.modules.map.state;this.modules.styleManager.getStyle(e.handyStyleId)&&(this.isAnimationStarted=!0,n.start("changeScale",{easing:"linear"},e,go,Ta,W_,1))}dangerouslyDestroySourcesAndLayers(){var e;this.sources.forEach(t=>t.destroy()),this.sources=[],this.sourcesRevision=[],(e=this.meshSource)==null||e.destroy(),this.meshSource=void 0,this.tileLayers.forEach(t=>{this.modules.tileManager.removeTileLayer(t),t.destroy()}),this.tileLayers=[],this.hillshadeTile&&(this.modules.tileManager.removeObject(this.hillshadeTile),this.hillshadeTile=void 0)}updateRampTextureId(){const e=this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId);if(e!=null&&e.dem){const t=q_(this.modules.map.state,e.dem.style.shadingPalette,256);Number.isNaN(this.hillshadeRampTextureId)?this.hillshadeRampTextureId=this.modules.imageManager.addPreparedTexture(t):this.modules.imageManager.updatePreparedTexture(this.hillshadeRampTextureId,t)}}updateClearColor(){const e=this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId);if(e!=null&&e.dem){const t=this.modules.renderer.getFramebuffer(this.flatFramebufferId);t&&(t.clearColor=n.getColorForShaders(e.background.color))}}updateGround(){if(this.enabled&&!this.isGroundBufferValid){const e=this.modules.tileManager.getTileObjects();this.modules.renderer.renderGround(e);const t=this.modules.renderer.getFramebuffer(this.groundFramebufferId);if(!t)return;const i=t.renderTarget.options.size;this.validateGroundBufferSize(i),this.modules.renderer.bindRenderTarget(t.renderTarget),this.modules.renderer.readPixelsFloat(0,0,i[0],i[1],this.groundBuffer),this.modules.renderer.bindRenderTarget(null),this.isGroundBufferValid=!0}}addDefaultSources(){this.dangerouslyDestroySourcesAndLayers(),this.elevationSourceType==="irregular"?this.addIrregularElevationSources():this.addRegularElevationSources(),this.flatMapSource=new M_(this.modules.map)}addRegularElevationSources(){var r;const e=this.modules.map.state,t=(l,c,d)=>n.DEM_TILE_URL_FUNCTION(e,l,c,d,this.tileSet==="dem"?"relief":this.tileSet),i=this.reliefTileType==="raster";i&&this.addElevationSource({url:t,minZoom:ba,maxZoom:8,attributes:{}}),this.addElevationSource({url:t,minZoom:i?9:ba,maxZoom:vo,attributes:{}}),this.meshSource=new w_(this.modules.map,{maxZoom:this.meshMaxZoom});const o=this.hillshadeVao,a=(r=this.modules.renderer.symbolSettingsList.dem.hillshade)==null?void 0:r[0];if(o&&a){this.hillshadeTile=new n.TileObject("raster",[],this.modules,this.modules.map.state);const l={id:n.uniqId(),type:n.SceneObjectType.Tile,symbol:"dem",sink:"hillshade",tile:this.hillshadeTile,attributes:{layerId:n.DEM_STYLE_LAYER_ID,styleId:this.modules.map.state.handyStyleId,tileData:[]},start:0,count:6,attributesHash:"",layerSettings:a,vao:o,canRender:!0,renderingProperties:{}};this.hillshadeTile.children.push(l),this.modules.tileManager.addObject(this.hillshadeTile)}}addIrregularElevationSources(){var o;const{tileServer:e,tileProtocol:t,subdomains:i}=(o=X_[this.tileSet])!=null?o:this.modules.map.state;this.addIrregularElevationSource({tileServer:e,tileProtocol:t,subdomains:i,tileSet:this.tileSet,minZoom:wa,maxZoom:Sa})}updateTilesRevision(){let e=!1;return this.sources.forEach((t,i)=>{const o=t.getRevision();o!==this.sourcesRevision[i]&&(this.sourcesRevision[i]=o,e=!0)}),e&&this.tilesRevision++,e}addElevationSource(e){const t=new S_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,a=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t);this.modules.tileManager.addTileLayer(a),this.tileLayers.push(a)}addIrregularElevationSource(e){const t=new T_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,a=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t,{useExtendedTilesBounds:!0});this.modules.tileManager.addTileLayer(a),this.tileLayers.push(a)}getDemTextureSize(){const e=this.modules.map.state.cameraConfig,t=this.modules.map.state.size[1]*e.viewportLimitRatio;return Math.min(Math.ceil(Math.hypot(t,t)/n.tileSizeZpt),Tt)}createGroundFramebuffer(){const e=this.modules.map.state.size,t=[0,0,0,0],i=new be({size:e,magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!0,type:w.Float});return this.modules.renderer.bindRenderTarget(i),this.modules.renderer.clearWithColor(t,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.addFramebuffer({clearColor:t,useDem:!0,clearDepth:!0,onResize:()=>{const o=this.modules.map.state.size;i.setSize(o),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.clearWithColor(t,!0),this.modules.renderer.bindRenderTarget(null)},renderTarget:i,renderIndex:5,onRenderStart:()=>{},onRenderEnd:()=>{}})}createDemFramebuffer(){let e=this.getDemTextureSize()*Tt;const t=new be({size:[e,e],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!0,type:w.Float,format:w.RgbaFormat}),i=[0,0,0,0];return this.modules.renderer.bindRenderTarget(t),this.modules.renderer.clearWithColor(i),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.addFramebuffer({clearColor:i,onResize:()=>{const o=this.getDemTextureSize()*Tt;o!==e&&(e=o,t.setSize([e,e]),this.modules.renderer.bindRenderTarget(t),this.modules.renderer.clearWithColor(i),this.modules.renderer.bindRenderTarget(null))},renderTarget:t,getViewProjectionMatrix:()=>this.demFbVpMatrix,renderIndex:0,onRenderStart:()=>{this.clearTextureBindings()},onRenderEnd:()=>{this.isDemCorrectionEnabled=!1}})}createCorrectedDemFramebuffer(){const e=this.modules.renderer;let t=this.getDemTextureSize()*Tt;const i=new be({size:[t,t],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!0,type:w.Float});return e.bindRenderTarget(i),e.clearWithColor([0,0,0,1]),e.bindRenderTarget(null),this.modules.renderer.addFramebuffer({onResize:()=>{const o=this.getDemTextureSize()*Tt;o!==t&&(t=o,i.setSize([t,t]),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.clearWithColor([0,0,0,1]),this.modules.renderer.bindRenderTarget(null))},renderTarget:i,getViewProjectionMatrix:()=>this.demCorrectedFbVpMatrix,renderIndex:1,onRenderStart:()=>{var l;const o=(l=this.modules.renderer.getFramebuffer(this.demFramebufferId))==null?void 0:l.renderTarget.getTexture();if(!o||!this.copyDemVao)return;this.clearTextureBindings(),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.setViewport(0,0,i.options.size[0],i.options.size[1]),this.modules.renderer.applyGpuState(fa);const a=0;this.modules.renderer.enableTexture(o,a);const r=this.modules.renderer.getShaderProgram("demElevationCopy");this.modules.renderer.enableShaderProgram(r),this.modules.renderer.bindShaderProgram(r,{u_mat4_mvp:n.TEXTURE_COORDS_TO_WEBGL,u_sr2d_texture:a,u_mat4_dem_corrected:this.correctedTexToDemTex}),this.modules.renderer.bindVao(this.copyDemVao),this.modules.renderer.drawTriangles(0,6),this.modules.renderer.bindRenderTarget(null),this.isDemCorrectionEnabled=!0},useDem:!0})}createHillshadeFramebuffer(){let e=this.getDemTextureSize()*Tt;const t=new be({size:[e,e],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,format:w.RgbFormat,flipY:!0});return this.modules.renderer.addFramebuffer({clearColor:[0,0,0,0],onResize:()=>{const i=this.getDemTextureSize()*Tt;i!==e&&(e=i,t.setSize([e,e]),this.modules.renderer.bindRenderTarget(t),this.modules.renderer.bindRenderTarget(null))},renderTarget:t,getViewProjectionMatrix:()=>this.demFbVpMatrix,renderIndex:2,onRenderStart:()=>{this.clearTextureBindings()},useDem:!0})}createFlatFramebuffer(){const e=this.modules.renderer.getPixelRatio(),t=this.modules.map.state.size,i=new be({size:[Math.trunc(t[0]*ze[0]*e),Math.trunc(t[1]*ze[1]*e)],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:this.modules.renderer.clearColor,onResize:()=>{const o=this.modules.map.state.size;i.setSize([Math.trunc(o[0]*ze[0]*e),Math.trunc(o[1]*ze[1]*e)]),this.modules.renderer.bindRenderTarget(i),this.modules.renderer.bindRenderTarget(null)},renderTarget:i,renderIndex:3,onRenderStart:()=>{this.modules.renderer.disableTexture(0)}})}createFlatIdentifyFramebuffer(){const e=this.modules.map.state.size,t=new be({size:[Math.trunc(e[0]*ze[0]*n.identify.pixelDensity),Math.trunc(e[1]*ze[1]*n.identify.pixelDensity)],magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:Ut,onResize:()=>{const i=this.modules.map.state.size;t.setSize([Math.trunc(i[0]*ze[0]*n.identify.pixelDensity),Math.trunc(i[1]*ze[1]*n.identify.pixelDensity)]),this.modules.renderer.bindRenderTarget(t),this.modules.renderer.bindRenderTarget(null)},renderTarget:t,renderIndex:4,onRenderStart:()=>{this.modules.renderer.disableTexture(0)}})}updateDemFramebufferMatrix(){const e=this.modules.map.state,t=Math.trunc(e.styleZoom),i=Math.min(t,this.getReliefTileType()==="raster"?H_:G_),o=n.tileZoomToSize(i),a=o*this.getDemTextureSize(),r=o/Tt,l=[Math.trunc(e.center[0]/r)*r+r/2,Math.trunc(e.center[1]/r)*r+r/2],c=[l[0]-a/2,l[1]-a/2,0],d=[];n.sub(d,this.modules.camera.position,e.center);const _=n.len(d);n.normalize$1(d,d);const u=Math.max(a/2-_-r-$_/2,0),h=Math.min(u,(a/2-_-r)*Math.sin(e.pitch/e.maxPitch*(Math.PI/2)));h>0&&(n.scale$2(d,d,h),d[0]=Math.trunc(d[0]/r)*r,d[1]=Math.trunc(d[1]/r)*r,n.sub(c,c,d)),n.fromTranslationScale(Oe,c,[a,a,n.tileHeight]),n.invert(this.demTextureMatrix,Oe),n.multiply(this.demFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,this.demTextureMatrix);const f=Math.min(t,V_);this.demCorrectedScale=je(2,f-i);const p=n.tileZoomToSize(f)*this.getDemTextureSize(),v=[l[0]-p/2,l[1]-p/2,0];n.fromTranslationScale(Oe,v,[p,p,n.tileHeight]),n.invert(Oe,Oe),n.multiply(this.demCorrectedFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,Oe),n.fromScaling(Oe,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(this.demCorrectedFbVpToDemTex,n.WEBGL_COORDS_TO_TEXTURE,Oe),n.fromScaling(Oe,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(Oe,Oe,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.correctedTexToDemTex,n.WEBGL_COORDS_TO_TEXTURE,Oe),n.fromScaling(Oe,[this.demCorrectedScale,this.demCorrectedScale,1]),n.multiply(Oe,Oe,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.demTexToCorrectedTex,n.WEBGL_COORDS_TO_TEXTURE,Oe)}validateGroundBufferSize(e){const t=e[0]*e[1]*4;this.groundBuffer.length!==t&&(this.groundBuffer=new Float32Array(t))}}function q_(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=[],a=t-1;for(let r=0;r<t;r++){const l=r/a,c=n.sample(e,l,i)*256;o.push(c)}return new w(new Uint8Array(o),{size:[t,1],format:w.AlphaFormat,magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping})}const Ma=new Float32Array(16),Mt=(s,e,t,i)=>{t=wo(t,s,e),t.length>0&&s.metrics.firstcontent===void 0&&(s.metrics.firstcontent=performance.now()-s.metrics.start),Ca(t,i),s.globeMode&&s.globeReady?Y_(s,e,t,i):yo(s,e,t,i)},Y_=(s,e,t,i)=>{const o=[],{environmentManager:a}=e,r=e.styleManager.getStyle(s.handyStyleId);if(!r||!r.environment)return;const c=n.makeBinderContext(s.styleZoom,s.styleState,[]),d=n.getColorForShaders(n.resolveColor(r.background.color,c));a.renderStars(),a.renderGlobeHaloBackground(),nu(t).forEach(_=>{if(!_.globeTile){bo(_.children,s,e).forEach(u=>o.push(u));return}i.useGlobeTile(_.globeTile),e.renderer.clearWithColor(d),_.children.forEach(u=>{if(u.type===n.SceneObjectType.Custom||!_.globeTile)return;const h=_.globeTile.coords,f=u.tile.coords,m=f[2]-h[2],p=je(2,m),v=(f[0]-h[0]*p)/p,x=(f[1]-h[1]*p)/p,g=1/p,y=1-g-2;n.fromTranslationScale(Ma,[2*v+y,2*x+y,0],[4*g,4*g,1]),u.tile.setMvpMatrix(Ma)}),bo(_.children,s,e).forEach(u=>nn(s,e,u,i)),i.useCanvas(),nn(s,e,_.globeTile.children,i)}),a.renderGlobeHalo(),o.forEach(_=>{nn(s,e,_,i)})},yo=(s,e,t,i)=>{bo(t,s,e).forEach(o=>nn(s,e,o,i))},nn=(s,e,t,i)=>{ru(e.styleManager,t,s,e).forEach(o=>{Ia(e.styleManager,o[0])?Q_(s,e,o,i):Ea(s,e,o,i)})},Q_=(s,e,t,i)=>{const o=Ia(e.styleManager,t[0]);if(!o)return;const a=(r,l)=>{l>=o.orderBy.length?Ea(s,e,r,i):cu(o.orderBy[l],r,s,e).forEach(c=>a(c,l+1))};a(t,0)},Ea=(s,e,t,i)=>{t.sort((o,a)=>o.tile.zoomLevel-a.tile.zoomLevel),au(e.styleManager,t,s,e).forEach(o=>J_(s,e,o,i))},J_=(s,e,t,i)=>{lu(t,s,e).forEach(o=>A_(s,e,o,i))},A_=(s,e,t,i)=>{var l;const o=t[0],a=fu(e.styleManager,o);if(!a||((l=a==null?void 0:a.style)==null?void 0:l.visibility)==="hidden")return;const r=a.selectedIdx;r!==void 0&&t.sort((c,d)=>{var h,f;const _=Number((h=c.attributes.tileData[r])!=null?h:0),u=Number((f=d.attributes.tileData[r])!=null?f:0);return _-u}),o.type===n.SceneObjectType.Custom?(i.useCustomLayerState(a),e.styleManager.callCustomLayerRender(o.attributes.layerId)):du(t,s,e).forEach(c=>eu(s,e,c,i,a))},eu=(s,e,t,i,o)=>{i.useProgram(t[0],o),_u(t,s,e).forEach(a=>{tu(s,e,a,i,o)})},tu=(s,e,t,i,o)=>{i.useState(t[0],o),uu(t,s,e).forEach(a=>{i.drawSymbol(a,o,s,e)})};function Ia(s,e){const t=s.getStyle(e.attributes.styleId);if(!t)return;const i=t.layersById[e.attributes.layerId];if(!i||i.groupId===void 0)return;const o=t.groupsById[i.groupId];if(o&&o.type!=="group"){n.log(`Expecting layer with type 'group' but got '${o.type}'`);return}return o}const iu=(s,e)=>Number(s)-Number(e),Kt=s=>(e,t,i)=>{const o={};for(let l=0;l<e.length;l++){const c=e[l],d=s(c,t,i),_=o[d];_===void 0?o[d]=[c]:_.push(c)}const a=Object.keys(o);a.sort(iu);const r=[];for(let l=0;l<a.length;l++)r.push(o[a[l]]);return r},xo=s=>(e,t,i)=>{const o=new Map;for(let a=0;a<e.length;a++){const r=e[a],l=s(r,t,i);o.has(l)?o.get(l).push(r):o.set(l,[r])}return o},nu=s=>{const e=[],t={globeTile:null,children:[]},i=[];for(const o of s)o.type!==n.SceneObjectType.Custom&&(o.tile.purpose==="globe"?i.push({globeTile:o.tile,children:[]}):e.push(o));for(const o of e)if(o.layerSettings.is3dMapAware)t.children.push(o);else for(const a of i)a.globeTile&&n.isTilesIntersects(a.globeTile.coords,o.tile.coords)&&a.children.push(o);return i.push(t),i},bo=Kt(s=>{const{styleId:e}=s.attributes;return e===n.DYNAMIC_STYLE_ID?1:-e}),ou=(s,e,t)=>{const i=s.getStyle(e);if(!i)return n.log(`Cannot get style with id=${e} for renderIndex`),NaN;const o=i.layersById[t];return o?o.renderIndex:NaN},su=(s,e,t)=>{const i=s.getStyle(e);if(!i)return n.log(`Cannot get style with id=${e} for renderIndex`),NaN;const o=i.layersById[t];return o?o.groupIndex||0:NaN},au=(s,e,t,i)=>Kt(o=>su(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),ru=(s,e,t,i)=>Kt(o=>ou(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),lu=Kt(s=>s.type===n.SceneObjectType.Custom?0:s.layerSettings.subRenderIndex||0),Ca=(s,e)=>{const t=new Set;s.forEach(i=>{if(i.type===n.SceneObjectType.Custom)return;const o=i.layerSettings.programName;t.has(i.layerSettings.programName)||(t.add(o),e.setProgramBinder(i))})},cu=(s,e,t,i)=>Kt((o,a)=>{const r=n.makeBinderContext(a.styleZoom,a.styleState,o.attributes.tileData);return n.resolveNumber(s,r,0)})(e,t,i),du=xo(s=>{var e;return(e=s.shaderDefinitions)!=null&&e.hash?s.layerSettings.programName+"_"+s.shaderDefinitions.hash:s.layerSettings.programName}),_u=xo(s=>s.layerSettings.stateBinder),uu=xo(s=>s.sink+"_"+s.attributesHash+"_"+s.tile.readiness),hu=Kt(s=>s.tile.zoomLevel);function fu(s,e){const t=s.getStyle(e.attributes.styleId);if(t)return t.layersById[e.attributes.layerId]}function wo(s,e,t){for(const i of s)i.type!==n.SceneObjectType.Custom&&(i.canRender=mu(i,t,e));return s.filter(i=>i.canRender)}function mu(s,e,t){var o;if(!s.layerSettings.cullMethod)return!0;const i=e.styleManager.getStyleLayerForObject(s);return!(!i||((o=i==null?void 0:i.style)==null?void 0:o.visibility)==="hidden"||!s.layerSettings.cullMethod(s,e,t,i))}const La=[0,0,0,0],vt=(s,e,t,i,o,a)=>{const r={terrain3d:!!o,noEffects:!!a,drawSymbol:(l,c,d,_)=>{const u=l[0];if(u)if(pu(u)&&(c.type==="overpass"||c.type==="tunnel"||c.type==="gltfModel")&&!u.layerSettings.shadow){let h;c.type==="gltfModel"&&(h=La),r.renderTierTexture(u,c,!1,h),r.useProgram(u,c),r.useState(u),So(l,c,d,_,r),d.hiddenImmersiveRoutesEnabled&&!u.layerSettings.identify&&c.type!=="gltfModel"&&(r.renderTierTexture(u,c,!0),r.useProgram(u,c),_.renderer.applyGpuState(E_,c),So(l,c,d,_,r))}else So(l,c,d,_,r)},useProgram:(l,c)=>{const{layerBinder:d,programName:_,programBinder:u,commonBinder:h}=l.layerSettings,f=e.renderer.getShaderProgram(_,l.shaderDefinitions);e.renderer.enableShaderProgram(f),h&&!e.renderer.isUboSupported()&&h(f,s,e),u==null||u(f,s,e,o,a),d==null||d(f,s,e,c,a)},setProgramBinder:l=>{const c=l.layerSettings.programBinder,d=e.renderer.isUboSupported()?void 0:l.layerSettings.commonBinder;if(l.layerSettings.programBinder||d){const _=e.renderer.getShaderProgram(l.layerSettings.programName,l.shaderDefinitions);e.renderer.enableShaderProgram(_),d==null||d(_,s,e),c==null||c(_,s,e,o,a)}},useState:(l,c)=>{e.renderer.applyGpuState(l.layerSettings.stateBinder,c)},useCustomLayerState:l=>{e.renderer.applyGpuState(R_,l)},useGlobeTile:l=>{const c=e.renderer.getGlobeRenderTarget(n.globeTileScale(s.zoom,l));c&&e.renderer.setRenderTarget(c)},useCanvas:()=>{e.renderer.setRenderTarget(i)},renderTierTexture:(l,c,d,_)=>{const{viewport:u,size:h}=s,f=window.devicePixelRatio,m=!!l.layerSettings.identify,p=m?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),v=e.renderer.getFramebuffer(p);if(!v)return;const x=vt(s,e,void 0,i,!1,!0);if(e.renderer.disableTexture(0),e.renderer.bindRenderTarget(v.renderTarget),e.renderer.setViewport(0,0,v.renderTarget.options.size[0],v.renderTarget.options.size[1]),d){const b=m?Ut:La;e.renderer.clearWithColor(b,!0,-1)}else if(m)e.renderer.clearWithColor(Ut,!0);else{const b=n.makeBinderContext(s.styleZoom,s.styleState,l.attributes.tileData),M=_!=null?_:n.resolveColor(c.style.color,b).value;e.renderer.clearWithColor([M[0]/255,M[1]/255,M[2]/255,M[3]/255],!0)}const g=l.attributes.meshTier,y=t==null?void 0:t[g];if(y){y.tileObjects.forEach(T=>{var P,S;T.updateMvpMatrix((S=(P=v.getViewProjectionMatrix)==null?void 0:P.call(v))!=null?S:e.camera.viewProjectionMatrix,void 0)});const b=d?y.objects.filter(T=>{var P;if(T.type!==n.SceneObjectType.Custom){if(T.layerSettings.stateBinder(e).depthTest&&!T.layerSettings.isOverlappedObject)return!0;const S=e.styleManager.getStyleLayer(T.attributes.styleId,T.attributes.layerId);if(S)return((P=S.gpuState)==null?void 0:P.depthTest)===!0}return!1}):y.objects,M=wo(b,s,e);yo(s,e,M,x),y.tileObjects.forEach(T=>T.updateMvpMatrix(e.camera.viewProjectionMatrix)),Ca(y.objects,r)}i?(e.renderer.bindRenderTarget(i),e.renderer.setViewport(0,0,i.options.size[0],i.options.size[1])):(e.renderer.bindRenderTarget(null),e.renderer.setViewport(u.left*f,u.bottom*f,h[0]*f,h[1]*f))},copy:(l,c,d)=>vt(s,e,t,l,c,d)};return r},So=(s,e,t,i,o)=>{const a=s[0],r=a.layerSettings,l=i.renderer.getShaderProgram(r.programName,a.shaderDefinitions);r.objectBinder(l,t,i,a,e,o.terrain3d),a.layerSettings.zoomBinder?hu(s,t,i).forEach(c=>{var d,_;l&&((_=(d=a.layerSettings).zoomBinder)==null||_.call(d,l,t,i,c[0],e,o.terrain3d)),c.forEach(u=>Pa(u,i,l,t,o,e))}):s.forEach(c=>Pa(c,i,l,t,o,e))},Pa=(s,e,t,i,o,a)=>{var c;const{renderer:r}=e,l=s.tile;for(const d of l.modelMatrices.keys()){if(l.renderModelMatrix=l.modelMatrices.get(d),l.renderMvpMatrix=l.mvpMatrices.get(d),l.renderDemMatrix=l.demMatrices.get(d),l.renderFlatMapTexMatrix=l.flatMapTexMatrices.get(d),!s.layerSettings.tileBinder(t,i,e,s,a,o))continue;r.bindVao(s.vao);const{start:u,count:h,instanceCount:f}=s,m=(c=s.drawMode)!=null?c:n.GL_TRIANGLES,p=s.vao.getElementsGLType();if(p!==null?f?r.drawInstancedElements(m,h,p,u,f):r.drawElements(m,h,p,u):f?r.drawInstancedArrays(m,u,h,f):r.drawArrays(m,u,h),i.collectStats){i.stats.drawCount++,i.stats.vertexCount+=(f!=null?f:1)*h,i.stats.drawCountBySymbol[s.symbol]?i.stats.drawCountBySymbol[s.symbol]++:i.stats.drawCountBySymbol[s.symbol]=1;const v=r.triangleCountByDrawMode(m,h);i.stats.triangleCount+=(f!=null?f:1)*v}}};function pu(s){return s.symbol==="mapMesh"||s.symbol==="gltfModel"&&s.attributes.meshTier!==void 0}const Ba=n.create$1(),vu=n.create$1(),za=n.create$2(),To=n.create$1(),gu=n.fromValues(0,0,1),yu=n.create$1(),xu=.3,bu=1/2e7,wu=.01,Su=[1,1,1,1],Ra=n.reserveTextureIndex();class Tu{constructor(e,t){this.clipToShadowMatrix=new Float32Array(16),this.baseBias=n.defaultShadowsSettings.bias,this.bias=0,this.shadowMapParams=new Float32Array([n.defaultShadowsSettings.textureSize[0],n.defaultShadowsSettings.textureSize[1],n.defaultShadowsSettings.shadowRadius,1]),this.volumeMultiplier=2.5,this.volumeMinSize=25e3,this.discreteVolume=!1,this.volumeSizeStep=je(2,15),this.adaptiveVerticalSize=!0,this.debugDraw=!1,this.shadowMatrix=new Float64Array(16),this.orthoMath=new Float64Array(16),this.renderTarget=null,this.copyProgram=null,this.debugVao=null,this.debugSize=400,this.shadowLightDir=null,this.modules=t,this.mapState=e}get texture(){if(!this.renderTarget)return null;const e=this.renderTarget.getDepthAttachment();return e instanceof w?e:this.renderTarget.getTexture()}setShadowResolution(e,t){this.shadowMapParams[0]=e,this.shadowMapParams[1]=t,this.renderTarget&&this.renderTarget.setSize([e,t])}update(){if(Wt())return;this.shadowLightDir=null;const{handyStyleId:e}=this.mapState,t=this.modules.styleManager.getStyle(e),i=this.modules.map.state.demMode;if(!t||!t.light.lightingModesResolved||i){this.renderTarget&&this.renderTarget.remove();return}const o=t.light.lightingModesResolved;for(const S in o){const C=o[S];if(C.shadowLightIndex===0){this.shadowLightDir=C.dir1Direction,this.shadowMapParams[2]=C.shadowRadius;break}else if(C.shadowLightIndex===1){this.shadowLightDir=C.dir2Direction,this.shadowMapParams[2]=C.shadowRadius;break}}const a=this.shadowLightDir&&!this.modules.map.getFeatureFlag("shadowsOff");if(a?this.renderTarget||(this.renderTarget=this.createRenderTarget()):this.renderTarget&&this.renderTarget.remove(),!a||!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const r=this.modules.map.state.center,l=this.modules.camera.position[2];let c=Math.max(this.volumeMultiplier*l);this.discreteVolume&&(c=c-c%this.volumeSizeStep),c=Math.max(c,this.volumeMinSize);let d=this.baseBias;this.modules.renderer.isShadowSamplerSupported()&&(d*=.5),this.shadowMapParams[3]=d/c,this.bias=d*bu*Math.sqrt(c),this.bias=Math.min(this.bias,wu);let _=1;if(this.adaptiveVerticalSize){const S=Math.abs(n.dot(this.shadowLightDir,gu));_=Math.max(S,xu)}const u=c,h=_*c,f=3*c;n.ortho(this.orthoMath,-u,u,-h,h,-f,f);const m=n.fromValues(this.shadowLightDir[1],-this.shadowLightDir[0],0);n.normalize(m,m),n.cross(To,m,this.shadowLightDir);const p=za;n.lookAt(p,yu,this.shadowLightDir,To);const v=n.transformMat4$1(Ba,r,p),x=2*u/this.shadowMapParams[0],g=2*h/this.shadowMapParams[1],y=n.fromValues(v[0]-v[0]%x,v[1]-v[1]%g,v[2]),b=n.invert(p,p),M=n.transformMat4$1(vu,y,b!=null?b:n.identity(za)),T=n.add$1(Ba,M,this.shadowLightDir);n.lookAt(this.shadowMatrix,M,T,To),n.multiply(this.shadowMatrix,this.orthoMath,this.shadowMatrix);const P=this.modules.camera.viewProjectionMatrixInverse;n.multiply(this.clipToShadowMatrix,this.shadowMatrix,P)}drawShadowMap(e){if(!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const t=this.modules.map.state.demMode,i=vt(this.mapState,this.modules,void 0,this.renderTarget,t),o=new Set,a=[];for(const l of e)for(const c of l.shadowChildren){const d=this.modules.styleManager.getStyleLayerForObject(c);if(!d||d.castShadows===!1)continue;const _=Ys(d,this.modules,this.mapState);!_||_.lightConfig.shadowLightIndex===-1||(a.push(c),o.add(l))}const r=t?this.modules.demManager.demTextureMatrix:void 0;o.forEach(l=>{l.updateMvpMatrix(this.shadowMatrix,r)}),this.modules.renderer.bindRenderTarget(this.renderTarget),this.modules.renderer.applyGpuState(ya),this.modules.renderer.clearWithColor(Su,!0),this.modules.renderer.setViewport(0,0,this.renderTarget.options.size[0],this.renderTarget.options.size[1]),Mt(this.mapState,this.modules,a,i),this.modules.renderer.bindRenderTarget(null)}drawDebugFbIfNeeded(){if(!this.debugDraw){this.copyProgram&&(this.copyProgram=null),this.debugVao&&(this.debugVao.remove(),this.debugVao=null);return}if(!this.texture)return;if((!this.copyProgram||!this.debugVao)&&(this.copyProgram||(this.copyProgram=this.createDebugProgram()),!this.debugVao)){const o=this.modules.renderer.createBuffer(new Uint8Array([-1,-1,1,-1,1,1,-1,1]));this.debugVao=pi(o,this.copyProgram)}const e=this.mapState.viewport,t=this.modules.renderer.getViewportSize(),i=this.debugSize;this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(t[0]+e.left-i,e.bottom,i,i),this.modules.renderer.applyGpuState(St),this.modules.renderer.enableShaderProgram(this.copyProgram),this.modules.renderer.bindShaderProgram(this.copyProgram,{u_texture:1}),this.modules.renderer.enableTexture(this.texture,1),this.modules.renderer.bindVao(this.debugVao),this.modules.renderer.drawTrianglesFan(0,4)}getMemoryFootprint(){var t,i;const e={renderTarget:(i=(t=this.renderTarget)==null?void 0:t.memSizeGPU())!=null?i:0};return{gpu:de(B({},e),{"--sum":n.getTotalMemory(e)})}}createRenderTarget(){const e=[this.shadowMapParams[0],this.shadowMapParams[1]];return this.modules.renderer.isDepthTextureSupported()?new be({size:e,magFilter:w.LinearFilter,minFilter:w.LinearFilter,depthTexture:!0,hasColorOutput:!1,compareFunc:w.CompareRefToTexture}):new be({size:e,magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!1,type:w.UnsignedByte,useHighDepthPrecision:!0})}createDebugProgram(){const e=[];this.modules.renderer.isDepthTextureSupported()&&e.push({type:"IS_DEPTH_TEXTURE"});const t=n.Shader.createShaderDefinitions(e);return this.modules.renderer.getShaderProgram("copy",t)}}class Fa{constructor(e,t,i){this.output=e,this.input=t,this.modules=i,this.enabled=!0}}class Mu extends Fa{constructor(e,t,i,o){super(e,t,i),this.name=qt.TAA,this.jitter=[0,0],this.numMixedFrames=0,this.samples=16,this.vao=null,this.buffer=o,this.jitterSequence=this.generateJitterSequence(this.samples)}onBeforeRender(e){if(this.jitter[0]=0,this.jitter[1]=0,e.aaMode!==Yt.TAA||e.globeMode||!this.canRender()){this.enabled=!1,this.numMixedFrames=0;return}if(this.numMixedFrames>=this.samples)return;this.modules.renderer.addRerenderEvent(),this.enabled=!0;const t=window.devicePixelRatio,i=e.size,o=this.jitterSequence[this.numMixedFrames];this.jitter[0]=o[0]/Math.ceil(i[0]*t),this.jitter[1]=o[1]/Math.ceil(i[1]*t)}render(){var o;const e=1/(this.numMixedFrames+1),t=this.modules.renderer.getShaderProgram("taa");this.vao||(this.vao=pi(this.buffer,t)),this.modules.renderer.bindRenderTarget(this.output),this.modules.renderer.bindVao(this.vao);const i=(o=this.input)==null?void 0:o.getTexture();i&&this.modules.renderer.enableTexture(i,0),this.modules.renderer.enableShaderProgram(t),this.modules.renderer.bindShaderProgram(t,{u_texture:0,u_float_mix_coef:e}),this.modules.renderer.drawTrianglesFan(0,4),this.numMixedFrames++}onAfterRender(){}resize(e){this.output.setSize(e),this.numMixedFrames=0}isReady(e){return e!=null&&e.ignoreLayerAnimation&&this.modules.map.core.hasActiveLayerAnimation()?!0:this.numMixedFrames>=this.samples}canRender(){return!this.modules.renderer.isNeedRerender()}generateJitterSequence(e){const t=[],i=n.generateHaltonSequence(e),o=i.base2,a=i.base3;t.push([0,0]);for(let r=0;r<o.length;++r)t.push([2*o[r]-1,2*a[r]-1]);return t}}class Eu extends Fa{constructor(e,t,i,o){super(e,t,i),this.name=qt.FXAA,this.vao=null,this.buffer=o}onBeforeRender(e){this.enabled=e.aaMode===Yt.FXAA&&e.stillness>0}render(){var i;const e=(i=this.input)==null?void 0:i.getTexture();if(e)this.modules.renderer.enableTexture(e,0);else throw new Error("FXAA: input texture is not available");const t=this.modules.renderer.getShaderProgram("fxaa");if(this.vao||(this.vao=pi(this.buffer,t)),this.modules.renderer.bindRenderTarget(this.output),this.modules.renderer.bindVao(this.vao),this.modules.renderer.enableShaderProgram(t),this.modules.renderer.bindShaderProgram(t,{u_texture:0}),!this.modules.renderer.isUboSupported()){const o=this.modules.map.state;_e(t,o,this.modules)}this.modules.renderer.drawTrianglesFan(0,4)}onAfterRender(){}resize(e){this.output.setSize(e)}isReady(){return!0}}var qt=(s=>(s.TAA="TAA",s.FXAA="FXAA",s))(qt||{}),Yt=(s=>(s[s.TAA=0]="TAA",s[s.FXAA=1]="FXAA",s))(Yt||{});class Iu{constructor(e,t){this.renderGraph=[],this.effectsByType={},this.copyColorVao=null,this.copyColorDepthVao=null,this.copyColorProgram=null,this.copyColorDepthProgram=null,this.state=e,this.modules=t,this.renderTargetSize=this.modules.renderer.getViewportSize();const i=t.renderer.webglContextState.MAX_TEXTURE_SIZE;if(Math.max(...this.renderTargetSize)>i){n.log(`Disabling post-effects as viewport size ${this.renderTargetSize[0]}x${this.renderTargetSize[1]} exceeds hardware limits of ${i}x${i}`);return}const a=this.modules.renderer.createBuffer(new Uint8Array([-1,-1,1,-1,1,1,-1,1]));this.copyColorProgram=this.modules.renderer.getShaderProgram("copy"),this.copyColorDepthProgram=this.modules.renderer.getShaderProgram("copy",n.Shader.createShaderDefinitions([{type:"COPY_DEPTH",value:"1"},...!this.modules.renderer.isWebgl2Context()&&this.modules.renderer.fragDepthSupported()?[{type:"HAS_FRAG_DEPTH_EXT"}]:[]])),this.copyColorVao=pi(a,this.copyColorProgram),this.copyColorDepthVao=pi(a,this.copyColorDepthProgram);const r=this.createRenderTarget(this.renderTargetSize,{useHighDepthPrecision:!0});this.mainFrameBufferWrapper={renderTarget:r,onResize:()=>{},clearColor:n.getColorForShaders(e.defaultBackgroundColor),clearDepth:!0};const l=e.aaMode===0,c=e.aaMode===1,d=l?Mu:c?Eu:null;if(d){const _=this.createRenderTarget(this.renderTargetSize),u=new d(_,r,t,a);this.effectsByType[l?"TAA":"FXAA"]=u,this.renderGraph.push(u)}}update(){this.renderGraph.forEach(e=>e.onBeforeRender(this.state))}render(){this.modules.renderer.applyGpuState(F_),this.renderGraph.forEach(t=>t.render());const e=this.renderGraph[this.renderGraph.length-1].output;this.copyRenderTargetToCanvas(e),this.renderGraph.forEach(t=>t.onAfterRender(this.state))}invalidateSize(){this.mainFrameBufferWrapper&&(this.renderTargetSize=this.modules.renderer.getViewportSize(),this.mainFrameBufferWrapper.renderTarget.setSize(this.renderTargetSize),this.renderGraph.forEach(e=>e.resize(this.renderTargetSize)))}getEffectByName(e){return this.effectsByType[e]}setClearColor(e){this.mainFrameBufferWrapper&&(this.mainFrameBufferWrapper.clearColor=n.getColorForShaders(e))}hasActiveEffects(){if(!this.modules.postEffectsManager.mainFrameBufferWrapper)return!1;for(const e of this.renderGraph)if(e.enabled)return!0;return!1}isReady(e=!1){for(const t of this.renderGraph)if(!t.isReady({ignoreLayerAnimation:e}))return!1;return!0}getMemoryFootprint(){var t,i;const e={mainFrameBufferWrapper:{renderTarget:(i=(t=this.mainFrameBufferWrapper)==null?void 0:t.renderTarget.memSizeGPU())!=null?i:0}};return{gpu:de(B({},e),{"--sum":n.getTotalMemory(e)})}}copyRenderTargetToCanvas(e,t=!1,i=!0){if(!this.copyColorVao||!this.copyColorProgram||!this.copyColorDepthVao||!this.copyColorDepthProgram){n.log("PostEffectsManager: copyRenderTargetToCanvas called without vao or copyProgram");return}const{viewport:o}=this.state,a=window.devicePixelRatio,r=this.modules.renderer.getViewportSize();this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(o.left*a,o.bottom*a,r[0],r[1]),i&&this.modules.renderer.clear(!1);const l=t?this.copyColorDepthProgram:this.copyColorProgram,c=t?this.copyColorDepthVao:this.copyColorVao;this.modules.renderer.bindVao(c);const d=e.getTexture();if(d&&this.modules.renderer.enableTexture(d,0),this.modules.renderer.enableShaderProgram(l),this.modules.renderer.bindShaderProgram(l,{u_texture:0}),t){const _=e.getDepthAttachment();_ instanceof w&&(this.modules.renderer.enableTexture(_,1),this.modules.renderer.bindShaderProgram(l,{u_depth:1}))}this.modules.renderer.drawTrianglesFan(0,4),this.modules.renderer.disableTexture(0),this.modules.renderer.disableTexture(1)}createRenderTarget(e,t){return new be(Object.assign({minFilter:w.NearestFilter,magFilter:w.NearestFilter,size:e},t))}}const Cu=[0,0];function pe(...s){return(e,t,i,o,a)=>{s.forEach(r=>r(e,t,i,o,a))}}const oe=(s,e,t,i)=>{var m,p,v;if(!i){Oa(s,e,t);return}const o=(m=t.renderer.getFramebuffer(t.demManager.getDemFramebufferId()))==null?void 0:m.renderTarget.getTexture(),a=(p=t.renderer.getFramebuffer(t.demManager.getCorrectedDemFramebufferId()))==null?void 0:p.renderTarget.getTexture(),r=t.imageManager.getTexture(t.demManager.getHillshadeRampTextureId()),l=o==null?void 0:o.options.size,c=t.styleManager.getStyle(e.handyStyleId);if(!o||!a||!r||!c||!l){Oa(s,e,t);return}const d=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),_=n.clamp(n.resolveNumber(c.dem.style.shadingIntensity,d),0,1),u=t.demManager.getElevationSourceType(),h=n.EARTH_CIRCUMFERENCE/(Math.pow(2,Math.min(Math.trunc(e.styleZoom),u==="regular"?vo:Sa))*Tt);t.renderer.enableTexture(o,ho),t.renderer.enableTexture(r,mo),t.renderer.enableTexture(a,po);const f=t.demManager.demCorrectedScale;t.renderer.bindShaderProgram(s,{u_float_dem_resolution:l[0],u_float_dem_cell_size:h,u_float_dem_shading_intensity:_,u_tex_dem:ho,u_tex_corrected_dem:po,u_tex_hillshade_ramp:mo,u_float_corrected_interval:t.demManager.isDemCorrectionEnabled&&f!==1?.5/f:0,u_mat4_dem_corrected:t.demManager.demTexToCorrectedTex,u_float_map_center_elevation:(v=e.elevation)!=null?v:0})},Da=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_shading_intensity:0})},Oa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_scale:0})},on=oe,sn=pe(_t,Wi),Na=hi,Lu=pe(Ws,Wi,_t,qs,oe),ka=pe(Ws,Wi,Nd,oe),Ua=pe(_t,Wi,qs,oe),Pu=hi,nt=(s,e,t,i,o)=>{const a=t.postEffectsManager.getEffectByName(qt.TAA),r=!o&&(a!=null&&a.jitter)?a.jitter:Cu;t.renderer.bindShaderProgram(s,{u_vec2_camera_jitter:r})},He=(s,e,t)=>{const i=t.shadowManager.texture;i&&(t.renderer.enableTexture(i,Ra),t.renderer.bindShaderProgram(s,{u_texture_shadow:Ra}))},Bu=(s,e,t)=>{if(!t.benchmark)return;const i=n.create$2(),o=t.benchmark.getScale();t.renderer.bindShaderProgram(s,{u_mat4_mvp:n.scale$3(i,i,o),u_vec3_transform:n.fromValues(0,0,0)})},zu=pe(oe,nt,He),Ru=pe(nt,He),an=pe(oe,nt,He),Fu=hi,Du=pe(oe,nt,He),Ga=pe(nt,He),ht=pe(oe,nt,He),Ha=pe(oe,He),Qt=pe(oe,nt,He),Va=pe(hi,Xs,Ks),Za=pe(hi,Xs,Ks,He),Ou=pe(oe,Za),Nu=pe(oe,Va),Mo=pe(He,oe),ku=pe(oe,nt,He),Uu=pe(nt,He),ja=pe(nt,He),Gu=pe(oe,ja),vi=new Float32Array(2),gi=new Float32Array(2),Hu=[0,0],Vu=[0,0,0,0],Jt=.01,Ce=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_opacity:1})},Eo=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i),r=n.resolveNumber(o.style.textureOpacity,a);t.bindShaderProgram(s,{u_float_texture_opacity:i.tile.readiness*r})},me=(s,e,{renderer:t},i)=>{if(!i.renderingProperties.color)return;const o=n.getColorForShaders(i.renderingProperties.color);n.scale$4(o,o,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_color:o})},Wa=(s,e,{renderer:t},i)=>{var c;if(!i.renderingProperties.mixColor)return;const{color2:o,factor:a,factorInterpolate:r}=i.renderingProperties.mixColor,l=n.getColorForShaders(o);switch(n.scale$4(l,l,i.tile.readiness),a.type){case"readFromTarget":{const d=(c=t.getDrawTargetFramebuffer(a.name))==null?void 0:c.renderTarget.getTexture();if(!d)return;t.enableTexture(d,2),r?t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:1,u_float_factor_interpolate_base:r.base,u_vec4_factor_interpolate_ranges:r.steps}):t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:0});break}case"vertexAttribute":{t.bindShaderProgram(s,{u_vec4_color2:l});break}default:{const{type:d}=a;n.assertUnreachable(d)}}},yi=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_mat4_gradient:i.renderingProperties.mat4_gradient})},Zu=(s,e,{renderer:t},i,o)=>{const a=n.getColorForShaders(n.resolveColor(o.style.strokeColor,Fe(e,i)));n.scale$4(a,a,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_border_color:a})},Ne=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:o*window.devicePixelRatio})},$a=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_float_shift:n.resolveNumber(o.style.shift,Fe(e,i))*window.devicePixelRatio})},ju=(s,e,{renderer:t},i,o)=>{const a=i.renderingProperties.opacityResolved||0,r=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!1),l=o.style.iconOpacity,c=n.resolveNumber(l,r);r.isBehind=!0;const d=e.styleState.graphicsPreset==="light"?1:n.resolveNumber(l,r);t.bindShaderProgram(s,{u_vec2_opacity:[a*c,a*d]})},zt=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.opacityResolved||0;t.bindShaderProgram(s,{u_float_opacity:o})},Io=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.iconRotation,Fe(e,i));t.bindShaderProgram(s,{u_vec2_rotation:[Math.cos(a),Math.sin(a)]})},Wu=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.opacity,Fe(e,i));t.bindShaderProgram(s,{u_float_opacity:i.tile.readiness*a})},$u=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.opacity,Fe(e,i));t.bindShaderProgram(s,{u_float_opacity:a})},Co=(s,e,{assetManager:t,renderer:i},o)=>{const a=t.textures[o.attributes.atlasIndex];i.enableTexture(a,0)},At=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.fontTexture;o&&t.enableTexture(o,0)},Xa=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.texture;o&&t.enableTexture(o,0)},Xu=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.rampTexture;o&&(t.enableTexture(o,1),t.bindShaderProgram(s,{u_sr2d_ramp_texture:1}))},rn=(s,e,{renderer:t},i,o)=>{const{tile:a}=i,r=n.resolveColor(o.style.gapColor,Fe(e,i));if(!r)return;const l=n.getColorForShaders(n.resolveColor(r,Fe(e,i)));n.scale$4(l,l,a.readiness),t.bindShaderProgram(s,{u_vec4_space_color:l})},ln=(s,e,{renderer:t},i,o)=>{const{styleZoom:a}=e,r=Fe(e,i),{tile:l}=i,c=n.getColorForShaders(n.resolveColor(o.style.color,r));n.scale$4(c,c,l.readiness),r.styleZoom=Math.floor(a);const d=Math.pow(2,n.getFractionalPart(a)),_=n.resolveNumber(o.style.dashLength,r)*d,u=n.resolveNumber(o.style.gapLength,r)*d;t.bindShaderProgram(s,{u_vec4_dash_color:c,u_vec2_scaler_params:[0,n.z0Scale],u_float_dash_length:n.zptToSceneDistance(_,l.size),u_float_dash2_length:n.zptToSceneDistance(_,l.size),u_float_space_length:n.zptToSceneDistance(u,l.size),u_int_gap_turns_only:o.style.gapTurnsOnly?1:0})},ue=n.create$3(),Ka=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i),{tile:r}=i,{pattern:l,width:c}=i.renderingProperties;if(!l||!c)return;const d=n.getColorForShaders(n.resolveColor(o.style.color,a));switch(n.scale$4(d,d,r.readiness),l[0]){case n.LinePatternType.Chess:{const _=l[1];ue[0]=_,ue[1]=.5,ue[2]=.25,ue[3]=-.25;break}case n.LinePatternType.DoubleDash:{const _=l[1];ue[0]=_,ue[1]=l[2]/c,ue[2]=.5*l[3]/_,ue[3]=.5*l[4]/_,ue[2]>=.5-Number.EPSILON&&(ue[2]=.6),ue[3]>=.5-Number.EPSILON&&(ue[3]=.6);break}case n.LinePatternType.Stripe:{const _=l[1]+l[2];ue[0]=_,ue[1]=.55,ue[2]=.5*l[1]/_,ue[3]=.5*l[1]/_,ue[2]>=.5-Number.EPSILON&&(ue[2]=.6),ue[3]>=.5-Number.EPSILON&&(ue[3]=.6);break}case n.LinePatternType.Circle:{const _=l[1]+l[2];ue[0]=_,ue[1]=.5*l[1]/_;break}case n.LinePatternType.Triangles:{const _=l[1]+l[2];ue[0]=_,ue[1]=l[1]/_,ue[2]=String(l[3])==="right"?-1:1;break}case n.LinePatternType.Chevron:{const _=l[1]+l[2];ue[0]=_,ue[1]=l[1]/_,ue[2]=l[3]/_,ue[3]=l[4]/c;break}}t.bindShaderProgram(s,{u_vec4_color:d,u_int_pattern_type:l[0],u_vec4_pattern_params:ue})},cn=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i),r=n.resolveNumber(o.style.tipWidth,a),l=n.resolveNumber(o.style.tipHeight,a),c=r,d=0;vi[0]=-c,vi[1]=-d,n.normalize$1(vi,vi),gi[0]=r,gi[1]=l,n.normalize$1(gi,gi);const _=n.resolveNumber(o.style.roundingRadius,a);t.bindShaderProgram(s,{u_vec2_wing_normal:vi,u_vec2_tip_normal:gi,u_float_tip_height_multiplier:l,u_float_wing_height_multiplier:d,u_float_wing_width_multiplier:c,u_float_size_factor:n.zptToSceneDistance(n.uint16ToTileCoords,i.tile.size)/2,u_float_tip_radius_zpt:_,u_float_wing_radius_zpt:_,u_float_tail_radius_zpt:_})},qa=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i),r=n.resolveNumber(o.style.lineLength,a),l=n.resolveNumber(o.style.lineWidth,a);t.bindShaderProgram(s,{u_float_length:r,u_float_width:l,u_float_border_width:0})},Ya=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i),{tile:r,attributes:l}=i,c=l.isLongArrow,d=i.tile.dynamicObject;let _=0,u=1;d&&(c?u=d.growPosition:_=d.bouncePosition);let h=0;const f=o.style.animation.type;(f==="appearance"||f==="repeat")&&(h=n.resolveNumber(o.style.animation.tipMovementAmplitude,a));const m=n.resolveNumber(o.style.roundingRadius,a);t.bindShaderProgram(s,{u_float_width_zpt:n.resolveNumber(o.style.lineWidth,a),u_float_border_width_zpt:n.resolveNumber(o.style.strokeWidth,a),u_float_tip_movement_amplitude:n.zptToSceneDistance(h,r.size),u_float_vertex_shift:_,u_float_relative_end_position:u,u_float_tip_radius_zpt:m,u_float_wing_radius_zpt:m,u_float_tail_radius_zpt:m})},Ku=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.modelTexture;o&&t.enableTexture(o,0)},Lo=(s,e,{renderer:t},i)=>{var o,a;return t.bindShaderProgram(s,{u_int_gltf_dem_pos:i.attributes.demPosition,u_vec2_anchor:(o=i.attributes.centroid)!=null?o:Hu,u_vec4_axis:(a=i.attributes.axis)!=null?a:Vu}),!0},qu=(s,e,{assetManager:t,renderer:i},o)=>{const{styleId:a}=o.attributes,{renderingProperties:r}=o,{resolvedColorTexture:l,resolvedAoTexture:c,resolvedPbrTexture:d,resolvedMetallic:_,resolvedRoughness:u}=r,{modelId:h}=r,f=t.getModel(h!=null?h:NaN,a);if(!f)return;const m={},p=l!==void 0&&f.textures[l];p&&(i.enableTexture(p,0),m.u_sr2d_texture_0=0);const v=c!==void 0&&f.textures[c];v&&(i.enableTexture(v,1),m.u_ao_texture=1);const x=d!==void 0&&f.textures[d];x?(i.enableTexture(x,n.PBR_TEXTURE_INDEX),m.u_pbr_texture=n.PBR_TEXTURE_INDEX):(m.u_float_metallic=_,m.u_float_roughness=u),i.bindShaderProgram(s,m)},Qa=(s,e,t,i,o)=>{const{renderer:a}=t,l=a.getGlobeRenderTarget(n.globeTileScale(e.zoom,i.tile)).getTexture();return l?(a.enableTexture(l,es),a.bindShaderProgram(s,{u_sr2d_flatmap_texture:es}),!0):!1},dn=(s,e,{renderer:t},i,o)=>{let a=i.renderingProperties.resolvedHeightFactor||0;a=Jt+(1-Jt)*a,t.bindShaderProgram(s,{u_float_height_factor:a})},_n=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_int_extention_to_relief_needed:i.attributes.extToReliefNeeded?1:0,u_int_collapse_height_needed:i.attributes.collapseHeightNeeded?1:0})},Po=(s,e,{modelLayer:t,renderer:i},o,a)=>{if(o.attributes.id===void 0)return;const r=t.getOpacity(o.attributes.id,a.minzoom),c=t.getBuildingHeight(o.attributes.id)===1?1:r;i.bindShaderProgram(s,{u_float_height_factor:c})},un=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i),r=n.resolveNumber(o.style.height,a);t.bindShaderProgram(s,{u_float_height_factor:n.mapHeightToTileHeight(r)})},Ke=(s,e,t,i,o)=>{const{floorManager:a,buildingHeightAnimator:r,modelsScene:l,modelLayer:c,renderer:d}=t;if(i.symbol==="polygonExtrusion"&&i.attributes.floorId&&i.attributes.isFloorStack){d.bindShaderProgram(s,{u_float_height_factor:a.getFloorStackObjectHeight(i.attributes.floorId)});return}let _=r.getBuildingHeight(o.minzoom);_=Jt+(1-Jt)*_;const u=l.objectIdToKey(i.id);u&&c.setBuildingHeight(u,_),d.bindShaderProgram(s,{u_float_height_factor:_})};function Fe(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const hn=(s,e,{renderer:t},i)=>{const{tile:o}=i,a=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:n.zptToSceneDistance(a,o.size)/2*n.uint16ToTileCoords,u_float_width_offset:n.zptToSceneDistance(n.uint16ToTileCoords/window.devicePixelRatio,o.size)/2})},Yu=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.resolvedRadius;t.bindShaderProgram(s,{u_float_radius:o*window.devicePixelRatio})},Qu=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.intensity,Fe(e,i));t.bindShaderProgram(s,{u_float_intensity:a})},Nt=(s,e,{renderer:t},i,o)=>{const a=Fe(e,i);let r=n.resolveNumber(o.style.textFontSize,a);if(i.symbol==="point"){const l=i.attributes.labelIndex;l===n.LabelIndex.Second&&o.style.textFontSize2?r=n.resolveNumber(o.style.textFontSize2,a):l===n.LabelIndex.Icon&&o.style.iconTextFontSize&&(r=n.resolveNumber(o.style.iconTextFontSize,a))}t.bindShaderProgram(s,{u_float_scale:r*window.devicePixelRatio/n.fonts.baseSize})},fn=(s,e,{renderer:t},i,o)=>{const a=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!!i.layerSettings.isOverlappedObject),{textFontSize:r,textColor:l,textHaloWidth:c,textHaloColor:d}=o.style,_=n.resolveNumber(r,a)/n.fonts.baseSize,u=_*window.devicePixelRatio,h=n.fonts.gamma/u,f=i.layerSettings.uniformSet,m=f==="fontHalo"?(6-n.resolveNumber(c,a)/_)/8:.75;let p;f==="fontHalo"?p=n.getColorForShaders(n.resolveColor(d,a)):p=n.getColorForShaders(n.resolveColor(l,a)),t.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:h,u_vec4_color:p})},Ja=(s,e,{renderer:t},i,o)=>{const{layerSettings:a}=i,{uniformSet:r}=a,l=i.attributes.labelIndex,c=o.style;let{textFontSize:d,textHaloWidth:_,textColor:u,textHaloColor:h}=c;switch(l){case n.LabelIndex.Icon:d=c.iconTextFontSize,_=c.iconTextHaloWidth,u=c.iconTextColor,h=c.iconTextHaloColor;break;case n.LabelIndex.Second:d=c.textFontSize2,_=c.textHaloWidth2,u=c.textColor2,h=c.textHaloColor2;break}Ju(s,t,e,i,d,u,_,h,l,r)},Ju=(s,e,t,i,o,a,r,l,c,d)=>{const _=n.makeBinderContext(t.styleZoom,t.styleState,i.attributes.tileData,!1,i.tile.dynamicObject),u=n.resolveNumber(o,_)/n.fonts.baseSize,h=u*window.devicePixelRatio,f=n.fonts.gamma/h,m=d==="fontHalo"?(6-n.resolveNumber(r,_)/u)/8:.75;let p,v;d==="fontHalo"?(p=n.getColorForShaders(n.resolveColor(l,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(l,_))):(p=n.getColorForShaders(n.resolveColor(a,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(a,_))),e.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:f,u_vec4_color:p,u_vec4_hidden_color:v,u_float_label_index:c})},mn=(s,e,{renderer:t},i)=>{const{attributes:o}=i,{offsetX:a,offsetY:r}=o,l=window.devicePixelRatio;t.bindShaderProgram(s,{u_vec2_offset:[a*l,r*l]})},pn=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_style_zoom:e.styleZoom})},gt=(s,e,{renderer:t},i)=>{const{tile:o}=i,{zoom:a}=e,r=n.tileSizeZpt*Math.pow(2,a-o.zoomLevel)*window.devicePixelRatio;t.bindShaderProgram(s,{u_float_tile_to_pixel_ratio:n.uint16ToTileCoords/r})},Aa=(s,e,{renderer:t},i,o)=>{const{tile:a}=i,{zoom:r,styleZoom:l}=e,c=o.style.lengthUnits===n.LengthUnits.Meters,d=n.tilePointScaleFactor(n.createTileInfo(a.coords),[n.maxTilePoint/2,n.maxTilePoint/2]),_=n.uint16ToTileCoords/(n.tileSizeZpt*Math.pow(2,r-a.zoomLevel)*window.devicePixelRatio),u=c?l:Math.floor(l),h=n.tileSizeZpt*Math.pow(2,u-a.zoomLevel)*window.devicePixelRatio/(n.uint16ToTileCoords*d);t.bindShaderProgram(s,{u_vec2_scales:[h,_]})},er=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},tr=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatIdentifyTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},ir=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.hillshadeTexture;o&&(t.enableTexture(o,fo),t.bindShaderProgram(s,{u_hillshade_tex:fo}))},Au=(s,e,t,i)=>{const{renderer:o,demManager:a}=t,r=i.renderingProperties.demTexture;r&&(o.enableTexture(r,0),o.bindShaderProgram(s,{u_tex_dem:0,u_mat4_dem_corrected:a.demCorrectedFbVpToDemTex}))},xi=(s,e,{renderer:t},i,o)=>{let a=!0;e.globeMode||(a=!!n.resolveNumber(o.style.elevation,Fe(e,i))),t.bindShaderProgram(s,{u_bool_skip_height_factor:a})},qe=(s,e,{buildingHeightAnimator:t,renderer:i},o,a)=>{let r=t.getBuildingHeight(a.minzoom);r=Jt+(1-Jt)*r,i.bindShaderProgram(s,{u_float_height_factor:r})},Ye=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0})},Bo=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_int_abs_z:!1})},zo=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_tile_size:n.tileZoomToSize(i.tile.zoomLevel)})},eh=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_vec4_color:n.LABELING_TEXTURE_DEM_MESH_COLOR})},N=(s,e,{renderer:t},i,o,a)=>{t.bindShaderProgram(s,{u_float_dem_scale:a?e.elevationScale:0})},Ro=(s,e,{renderer:t},i)=>{if(!i.attributes.meshTier)return;const o=i.layerSettings.identify?t.getMapMeshIdFramebufferId():t.getMapMeshFramebufferId(),a=t.getFramebuffer(o),r=a==null?void 0:a.renderTarget.getTexture(),l=a==null?void 0:a.scale;r&&(t.enableTexture(r,n.MAP_MESH_TEXTURE_INDEX),t.bindShaderProgram(s,{u_sampler_map_tex:n.MAP_MESH_TEXTURE_INDEX,u_vec2_tex_scale:l,u_float_tex_shift_scale:1-Math.cos(e.pitch)}))},ot=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_identify:i.layerSettings.identify||i.layerSettings.depthTest?1:0})},th=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_scale:i.meta.scale,u_vec3_transform:i.meta.transform})};function L(...s){return(e,t,i,o,a,r)=>{s.forEach(l=>l(e,t,i,o,a,r))}}const ei=(s,e,{renderer:t},i)=>(t.bindShaderProgram(s,{u_bool_is_3d_line:i.symbol==="line"&&i.sink==="solid3d"||i.symbol==="line"&&i.sink==="patterned3d"||i.symbol==="dashedLine"&&i.sink==="stroke3d"}),!0),he=(s,e,{floorManager:t,renderer:i},o)=>{if(!o.attributes.floorId||!o.tile.renderModelMatrix){i.bindShaderProgram(s,{u_float_floor_elevation:0});return}if(o.symbol==="polygonExtrusion"&&o.attributes.isFloorStack){i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorStackObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]});return}i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]})},ti=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_floor_elevation:0})},bi=(s,e,t,i)=>{t.renderer.bindShaderProgram(s,{u_int_is_roof:i.symbol==="polygonExtrusion"&&i.sink==="topFill"?1:0})},nr=(s,e,t,i)=>{if("isFloorStack"in i.attributes&&i.attributes.isFloorStack){const o=t.floorManager.getFloorsStackObjectOffsets(i.attributes.floorId);t.renderer.bindShaderProgram(s,{u_vec2_floor_level:[o.current,o.total]})}else t.renderer.bindShaderProgram(s,{u_vec2_floor_level:[0,1]})},ih=(s,e,t,i,o)=>{var p;const a=i.attributes.textureIndex,r=(p=o.style.sideTextures)==null?void 0:p[a],l=t.imageManager.getTexture(o.sideTextureIndices[a]),c=n.MAP_POINTS_IN_METER*n.tilePointScaleFactor(n.createTileInfo(i.tile.coords),[0,0]),d=l.options.size,_=[r.texturePadding[3]/d[0],r.texturePadding[0]/d[1],r.texturePadding[1]/d[0],r.texturePadding[2]/d[1]],u=r.wallPadding.map(v=>v*c),h=r.sliceSize.map(v=>v*c),f=[r.horizontal.maxInterval*c,r.vertical.maxInterval*c],m=[or(r.horizontal.mode),or(r.vertical.mode)];t.renderer.enableTexture(l,0),t.renderer.bindShaderProgram(s,{u_sr2d_texture:0,u_vec4_wall_padding_su:[u[3],u[0],u[1],u[2]],u_vec4_texture_padding_un:_,u_vec2_texture_part_count:[r.horizontal.slicesCount,r.vertical.slicesCount],u_vec2_max_interval_su:f,u_vec2_texture_slice_size_su:h,u_ivec2_layout_mode:m,u_int_texture_index:i.attributes.textureIndex})};function or(s){switch(s){case"repeat-with-stretch":return 1;case"stripe-top":return 2;case"repeat-with-max-interval":return 3;default:return 1}}const nh="FRAGMENT",oh="VERTEX",sh="FOG",ah="SKY",rh="METALLIC_ROUGHNESS_DEBUG",lh="PBR_TEXTURE",ch="AO_TEXTURE",dh="MAP_MESH_TEXTURE",_h="COLOR_TEXTURE",sr="LIGHT_MODEL",uh="1",hh="2",fh="DEPTH_TEXTURE_SHADOW",mh="RENDER_SHADOWS",ph="UBO",vh="SCREENDOOR",gh="ENTRANCE_ARROWS_ROUNDING",yh="MALI_GPU",xh="VARYINGS_LIMIT_9",Fo="MIX_COLOR_MODE",bh="1",ar="2",wh="MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME",Sh="1",Th=n.Shader.createShaderDefinitions([{type:Fo,value:bh}]),Mh=n.Shader.createShaderDefinitions([{type:Fo,value:ar}]),Eh=n.Shader.createShaderDefinitions([{type:Fo,value:ar},{type:wh,value:Sh}]),Ih={value:[0,0,0]};function ve(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const Ch=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:if(!i.style.strokeColor)return!1;break;case n.MeshFillSide.side:if(!i.style.sideColor)return!1;break;case n.MeshFillSide.bottom:if(!i.style.bottomColor)return!1;break;default:return!1}return!0},Do=(s,e)=>{const t=e.assetManager.textures[s.attributes.atlasIndex];return t?(s.renderingProperties.atlasTexture=t,!0):!1},rr=(s,e)=>{const t=e.imageManager.getTexture(s.attributes.textureIndex);return t?(s.renderingProperties.texture=t,!0):!1},ii=(s,e)=>{const{range:t,fontIndex:i,styleId:o}=s.attributes,a=e.styleManager.getStyle(o);if(!a)return!1;const r=a.fonts[i],l=e.assetManager.getFontTextureByName(r,t);return l?(s.renderingProperties.fontTexture=l,!0):!1},Oo=(s,e)=>{const t=s.layerSettings.identify?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),i=e.renderer.getFramebuffer(t),o=i==null?void 0:i.renderTarget.getTexture(),a=i==null?void 0:i.scale;return!(!o||!a)},Lh=(s,{imageManager:e})=>{const t=e.getTexture(s.attributes.rampTextureIndex);return t?(s.renderingProperties.rampTexture=t,!0):!1},Ph=(s,e)=>{var o;const t=e.demManager.getDemFramebufferId(),i=(o=e.renderer.getFramebuffer(t))==null?void 0:o.renderTarget.getTexture();return i?(s.renderingProperties.demTexture=i,!0):!1},lr=(s,{demManager:e,renderer:t,map:i})=>{var r;if(!i.state.demMode)return!1;const o=e.getHillshadeFramebufferId(),a=(r=t.getFramebuffer(o))==null?void 0:r.renderTarget.getTexture();return a?(s.renderingProperties.hillshadeTexture=a,!0):!1},cr=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getFlatFramebufferId(),a=t.getFramebuffer(o);if(!a)return!1;const r=a.renderTarget.getTexture();return r?(s.renderingProperties.flatTexture=r,!0):!1},dr=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getIdentifyFlatFramebufferId(),a=t.getFramebuffer(o);if(!a)return!1;const r=a.renderTarget.getTexture();return r?(s.renderingProperties.flatIdentifyTexture=r,!0):!1},Bh=(s,e,t,i)=>{var l,c;const{renderingProperties:o}=s,{resolvedUvIndex:a}=o,{colorTextureUvIndex:r}=i.style;return r!==void 0&&a!==r&&(((c=(l=s.meta)==null?void 0:l.availableTextureCoords)!=null?c:[])[r]&&s.vao.setAttributesAliases({texcoord_color:`texcoord_${r}`}),o.resolvedUvIndex=r),!0},zh=(s,e,t,i)=>{var h,f;const{styleId:o,colorTexture:a,aoTexture:r,pbrTexture:l,meshTier:c}=s.attributes,{renderingProperties:d}=s,{modelId:_}=d,u=e.assetManager.getModel(_!=null?_:NaN,o);return!u||(a!==void 0&&u.textures[a]&&(d.resolvedColorTexture=a),r!==void 0&&u.textures[r]&&(d.resolvedAoTexture=r),l!==void 0&&u.textures[l]?d.resolvedPbrTexture=l:(d.resolvedMetallic=(h=s.attributes.metallic)!=null?h:i.style.metallic,d.resolvedRoughness=(f=s.attributes.roughness)!=null?f:i.style.roughness),!d.resolvedColorTexture&&!d.color)?!1:c?Oo(s,e):!0},_r=(s,{modelsScene:e})=>{const t=e.getModelOpacity(s);return s.renderingProperties.resolvedOpacity=t,t!==0},ur=(s,{modelsScene:e})=>{const t=e.getModelHeightFactor(s);return s.renderingProperties.resolvedHeightFactor=t,t!==0},hr=(s,e,t,i)=>{const o=ve(t,s),a=n.resolveNumber(i.style.width,o);if(a===0)return!1;const r=n.resolveExpression(i.style.pattern,o);return!r||r[0]===n.LinePatternType.None?!1:(s.renderingProperties.width=a,s.renderingProperties.pattern=r,!0)},Rh=(s,e,t)=>jo(t,s.attributes.animDirection)!==0,fr=(s,e,t,i)=>{const o=ve(t,s);return n.resolveNumber(i.style.iconOpacity,o)*jo(t,s.attributes.animDirection)!==0},mr=(s,e)=>!e.map.getFeatureFlag("transparentBuildingsOff"),V=(s,e,t,i)=>Fh(s.tile,t,i),pr=(s,e,t)=>{var o,a,r,l,c,d;if((o=s.meta)!=null&&o.planId&&(!t.styleState._activeFloorIds||!t.styleState._activeFloorIds.includes(s.meta.planId))||(r=(a=s.meta)==null?void 0:a.linkedIds)!=null&&r.length&&!((l=s.meta)!=null&&l.planId)&&e.floorManager.hasDisplayedFloorBuilding(s.meta.linkedIds))return!1;const i=(c=s.meta)==null?void 0:c.buildingId;return!(i&&((d=s.tile.ids)!=null&&d.isHidden(i)))},Fh=(s,e,t)=>{const{purpose:i,detailLevel:o}=s,{styleZoom:a}=e;switch(i){case"zenith":case"traffic":case"geojson":const r=o<Xh(i)?n.clamp(a,o,o+.99999):a;return t.minzoom<=r&&r<t.maxzoom;case"dynamicObject":return t.minzoom<=a&&a<=t.maxzoom;default:return t.minzoom<=a&&a<t.maxzoom}},Dh=(s,e,t)=>{var r;const{styleZoom:i}=t,{tile:o}=s;if(o.purpose!=="zenith"||i>n.tiles.maxUniverseZoom)return!0;let a=n.tiles.maxUniverseZoom;if(o.sourceId){const l=e.sourceStorage.getSourceById(o.sourceId);a=(l==null?void 0:l.type)==="zenith"&&(r=l.getOptions().strokeMinZoom)!=null?r:n.tiles.maxUniverseZoom}return i>a},Qe=(s,e,t,i)=>{const{styleZoom:o}=t;return o>=i.minzoom&&o<i.maxzoom},No=(s,e)=>s.attributes.id===void 0?!0:!e.modelLayer.isHidden(s.attributes.id),ko=(s,e,t,i)=>{const o=ve(t,s);return n.resolveNumber(i.style.iconWidth,o)>0},vr=(s,e,t,i)=>{const{layerSettings:o}=s,{uniformSet:a}=o,r=s.attributes.labelIndex,l=i.style;if(a==="fontHalo"){let{textHaloColor:c}=l;switch(r){case n.LabelIndex.Icon:c=l.iconTextHaloColor;break;case n.LabelIndex.Second:c=l.textHaloColor2;break}if(!c)return!1}return!0},vn=(s,e,t,i)=>!(s.layerSettings.uniformSet==="fontHalo"&&!i.style.textHaloColor),Uo=(s,e,t,i)=>{var l,c,d,_,u,h;const o=ve(t,s),a=i.style;if(s.symbol==="point")switch(s.attributes.labelIndex){case n.LabelIndex.Second:return((c=n.resolveNumber((l=a.textHaloWidth2)!=null?l:null,o))!=null?c:0)>0&&!!a.textHaloColor2;case n.LabelIndex.Icon:return((_=n.resolveNumber((d=a.iconTextHaloWidth)!=null?d:null,o))!=null?_:0)>0&&!!a.iconTextHaloColor;case n.LabelIndex.First:break}return((h=n.resolveNumber((u=a.textHaloWidth)!=null?u:null,o))!=null?h:0)>0&&!!a.textHaloColor},gr=(s,{modelLayer:e})=>{const{texture:t,id:i}=s.attributes;if(i===void 0)return!1;const o=e.getTexture(i,t);return o?(s.renderingProperties.modelTexture=o,!0):!1},st=(s,e,t,i)=>{const o=n.resolveNumber(i.style.width,ve(t,s));return s.renderingProperties.widthResolved=o,o!==0},wi=(s,e,t,i)=>{const o=ve(t,s),a=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=a,a!==0},Oh=(s,e,t,i)=>{const o=ve(t,s),a=n.resolveNumber(i.style.strokeWidth,o);if(a===0)return!1;const r=n.resolveNumber(i.style.width,o);return s.renderingProperties.widthResolved=r+a*2,!0},Nh=(s,e,t,i)=>{const o=ve(t,s),a=n.resolveNumber(i.style.strokeWidth2,o);if(a===0)return!1;const r=n.resolveNumber(i.style.width,o),l=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=r+l*2+a*2,!0},kh=(s,e,t,i)=>{const o=ve(t,s),a=n.resolveNumber(i.style.width,o),r=n.resolveNumber(i.style.strokeWidth,o),l=n.resolveNumber(i.style.strokeWidth2,o),c=a+r*2+l*2;return s.renderingProperties.widthResolved=c,c!==0},Et=(s,e,t)=>{const i=jo(t,s.attributes.animDirection);return s.renderingProperties.opacityResolved=i,i!==0},Uh=(s,e,t,i)=>(s.renderingProperties.resolvedRadius=n.resolveNumber(i.style.radius,ve(t,s)),s.renderingProperties.resolvedRadius>0),yr=(s,e,t,i)=>{var l;s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16));let o;switch(s.attributes.side){case n.MeshFillSide.top:o=(l=i.style.topColor)!=null?l:i.style.color;break;case n.MeshFillSide.side:o=i.style.sideColor;break;case n.MeshFillSide.bottom:o=i.style.bottomColor;break}const a=ve(t,s),r=n.resolveExpression(o,a);return s.renderingProperties.mat4_gradient[0]=0,n.isStyleColor(r)?Ae(s,r):n.isStyleGradient(r)&&Wo(r,s.tile.readiness,s.renderingProperties.mat4_gradient),!0},Go=(s,e,t,i)=>{if(s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16)),!s.renderingProperties.color)return!1;const o=n.resolveGradient(i.style.sideColor,ve(t,s));return o?(n.copy$1(s.renderingProperties.color.value,o.values[0].value),Wo(o,s.tile.readiness,s.renderingProperties.mat4_gradient),s.renderingProperties.color.value[3]!==0):(s.renderingProperties.mat4_gradient[0]=0,!0)},xr=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16));const a=ve(t,s),r=n.resolveColor(i.style.sideColor,a).value,l=n.equals(o.value,r),c=l?i.style.sideColor:i.style.sideStrokeColor,d=n.resolveGradient(c,ve(t,s));return d?(n.copy$1(o.value,d.values[0].value),Wo(d,s.tile.readiness,s.renderingProperties.mat4_gradient)):s.renderingProperties.mat4_gradient[0]=0,l&&(o.value[3]*=t.stillness),o.value[3]!==0},fe=(s,e)=>!("hiddenByFloorComplexId"in s.attributes)||!s.attributes.hiddenByFloorComplexId?!0:!e.floorManager.hasDisplayedFloorBuilding([s.attributes.hiddenByFloorComplexId]),se=(s,e)=>s.attributes.floorId?s.symbol==="polygonExtrusion"&&s.attributes.isFloorStack?e.floorManager.isVisibleFloorStackObject(s.attributes.floorId):e.floorManager.isVisibleFloorObject(s.attributes.floorId):!0,Gh=s=>{const e=s.renderingProperties.color;return e?n.set$1(e.value,0,0,0,.05*255):s.renderingProperties.color=n.toStyleColor([0,0,0,.05*255]),!0},br=(s,e,t,i)=>{const o=n.makeBinderContext(t.styleZoom,t.styleState,s.attributes.tileData,!!s.layerSettings.isOverlappedObject);return Ae(s,n.resolveColor(i.style.color,o)),s.renderingProperties.color.value[3]!==0},Ho=(s,e,t,i)=>(Ae(s,n.resolveColor(i.style.topColor,ve(t,s))),s.renderingProperties.color.value[3]!==0),gn=(s,e,t,i)=>(Ae(s,n.resolveColor(i.style.sideColor,ve(t,s))),s.renderingProperties.color.value[3]!==0),Si=(s,e,t,i)=>(Ae(s,n.resolveColor(i.style.strokeColor,ve(t,s))),s.renderingProperties.color.value[3]!==0),Hh=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:Ae(s,n.resolveColor(i.style.strokeColor,ve(t,s)));break;case n.MeshFillSide.side:Ae(s,n.resolveColor(i.style.sideColor,ve(t,s)));break;case n.MeshFillSide.bottom:Ae(s,n.resolveColor(i.style.bottomColor,ve(t,s)));break;default:Ae(s,Ih);break}return s.renderingProperties.color.value[3]!==0},Vh=(s,e,t,i)=>(Ae(s,n.resolveColor(i.style.strokeColor2,ve(t,s))),s.renderingProperties.color.value[3]!==0),Vo=(s,e,t,i)=>{if(s.attributes.id===void 0)return!1;const o=s.renderingProperties.color;return o?(o.value[3]*=e.modelLayer.getOpacity(s.attributes.id,i.minzoom),o.value[3]!==0):!1},wr=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const a=ve(t,s),r=n.resolveColor(i.style.strokeColor,a).value,l=n.resolveNumber(i.style.strokeWidth,a);return n.equals(o.value,r)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Zh=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const a=ve(t,s),r=n.resolveColor(i.style.topColor,a).value,l=n.resolveNumber(i.style.strokeWidth,a);return n.equals(o.value,r)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Sr=(s,e,t,i)=>{const o=n.resolveColor(i.style.sideStrokeColor,ve(t,s));return Ae(s,o),s.renderingProperties.color.value[3]!==0},Je=(s,e,t,i)=>{const o=n.resolveColor(i.style.color,ve(t,s),!0),a=n.isStyleMixColor(o)?o.color1:o;if(Ae(s,a),n.isStyleMixColor(o)&&!(o.factor.type==="readFromTarget"&&!e.renderer.doesDrawTargetFramebufferExist(o.factor.name))){if(Kh(s,o),s.renderingProperties.color.value[3]===0&&s.renderingProperties.mixColor.color2.value[3]===0)return!1;const{factor:{type:r,name:l}}=s.renderingProperties.mixColor;switch(r){case"readFromTarget":{s.shaderDefinitions=Th;break}case"vertexAttribute":{switch(l){case"denormalized_distance_to_line":s.shaderDefinitions=Eh;break;default:s.shaderDefinitions=Mh;break}break}default:n.assertUnreachable(r)}return!0}return s.renderingProperties.color.value[3]!==0},jh=(s,e,t,i)=>{Ae(s,n.resolveColor(i.style.color,ve(t,s)));const{color:o,resolvedOpacity:a}=s.renderingProperties;return n.mul(o.value,o.value,s.attributes.colorFactor),o.value[3]*=a!=null?a:0,o.value[3]!==0},Tr=(s,e)=>{const t=s==null?void 0:s.attributes.parentId;if(!t)return!0;const{floorManager:i}=e;if(i.hasDisplayedFloorBuilding([t])&&s.attributes.floorId)return!0;const a=s==null?void 0:s.tile.ids;return!(a!=null&&a.isHidden(t,n.HideLevel.PolygonExtrusion))},Zo=O(V,Tr,fe,(s,e)=>{if(!s.bboxWorld||s.tile.dynamicObject||s.renderingProperties.animationStack&&s.renderingProperties.animationStack.length>0)return!0;if(e.environmentManager.isAABBInFog(s.bboxWorld))return!1;const t=e.camera.getViewportVertices();return n.tetragonIntersectsBounds(t,s.bboxWorld)},se,pr,_r,ur,jh),Wh=O(V,Tr,fe,pr,_r,ur),Mr=O(Bh,zh),$h=(s,e,t,i)=>{var l;const o=s.attributes.textureIndex,a=(l=i.style.sideTextures)==null?void 0:l[o],r=e.imageManager.getTexture(i.sideTextureIndices[o]);return!!a&&!!r};function O(...s){return(e,t,i,o)=>{for(const a of s)if(!a(e,t,i,o))return!1;return!0}}function Xh(s){switch(s){case"zenith":return n.tiles.maxDetailLevel;case"traffic":return n.traffic.maxDetailLevel;case"geojson":return n.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL}}function jo(s,e){return e===n.LabelingAnimation.none?1:e===n.LabelingAnimation.fadeIn?s.labelingOpacity:1-s.labelingOpacity}function Wo(s,e,t){if(!s.steps.length){t[0]=0;return}t[0]=n.clamp(s.values.length,0,3);for(let i=0;i<t[0];i++){const o=s.values[i],a=n.getColorForShaders(o);n.scale$4(a,a,e),t[i+1]=s.steps[i];const r=(i+1)*4;t[r]=a[0],t[r+1]=a[1],t[r+2]=a[2],t[r+3]=a[3]}}function Ae(s,e){s.renderingProperties.color||(s.renderingProperties.color=n.toStyleColor([255,255,255,255])),n.copy$1(s.renderingProperties.color.value,e.value)}function Kh(s,e){s.renderingProperties.mixColor=e}function Er(s,e=void 0,t=void 0){const i=document.createElement("img");return e!==void 0&&(i.width=e),t!==void 0&&(i.height=t),new Promise(o=>{i.onload=()=>o(i),i.src=s})}function Ir(s){let e;try{e={url:`data:image/svg+xml;base64,${btoa(s)}`}}catch(t){const i=URL.createObjectURL(new Blob([s],{type:"image/svg+xml"}));e={url:i,revokeURL:()=>URL.revokeObjectURL(i)}}return e}function yn(s,e="image/png"){const t=new Blob([s],{type:e}),i=URL.createObjectURL(t),o=document.createElement("img");return new Promise(a=>{o.onload=()=>{URL.revokeObjectURL(i),a(o)},s.byteLength===0?o.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=":o.src=i})}function Cr(s,e){if(e[0]===s.width&&e[1]===s.height)return s;const t=document.createElement("canvas"),i=t.getContext("2d");return t.width=e[0],t.height=e[1],i.shadowColor="transparent",i.shadowBlur=0,i.drawImage(s,0,0,e[0],e[1]),t}function Lr(s,e,t,i,o){const a=Array();o&&e.forEach(r=>{var h,f,m;const l=i[r.outputBufferView],c=Math.ceil((h=o.get(r.actionId))!=null?h:-1),d=Math.floor((f=o.get(r.actionId))!=null?f:-1),_=(o.get(r.actionId)||1)%1,u=Math.round((m=o.get(r.actionId))!=null?m:-1);if(l&&o.size>0&&d>=0&&c>=0&&u>=0){const p=new Float32Array(Xo(l),r.outputBufferOffset,r.outputBufferLength);if(r.outputType==="VEC4")switch(r.interpolation){case"STEP":{t[r.targetMatIndex[0]][r.targetMatIndex[1]]=ni(p,u,4);break}case"LINEAR":default:{n.slerp(t[r.targetMatIndex[0]][r.targetMatIndex[1]],ni(p,d,4),ni(p,c,4),_);break}}else if(r.outputType==="VEC3")switch(r.interpolation){case"STEP":{t[r.targetMatIndex[0]][r.targetMatIndex[1]]=ni(p,u,3);break}case"LINEAR":default:{n.lerp(t[r.targetMatIndex[0]][r.targetMatIndex[1]],ni(p,d,3),ni(p,c,3),_);break}}}});for(let r=0;r<t.length;r++){const l=t[r];if(l.length===3){const c=n.create$2();n.fromRotationTranslationScale(c,l[1],l[0],l[2]),a.push(c)}else a.push(l)}sf(s,a)}function ni(s,e,t){if(t!==3&&t!==4)return console.warn("Invalid animation transform size"),[];const i=[];for(let o=0;o<t;o++)i.push(s[e*t+o]);return i}function qh(s,e,t,i,o){s.animations.forEach((a,r)=>{a.channels.forEach((l,c)=>{if(l.target.node===t){const d=a.samplers[l.sampler],_=a.name||"default",u=s.accessors[d.input];if(u.bufferView===void 0||s.bufferViews[u.bufferView]===void 0)return;Pr(e,s,u.bufferView,u.componentType);const f=s.accessors[d.output];if(f.bufferView===void 0)return;const m=s.bufferViews[f.bufferView];if(m===void 0)return;Pr(e,s,f.bufferView,f.componentType),(d.interpolation||"LINEAR")!=="LINEAR"&&(d.interpolation||"LINEAR")!=="STEP"&&console.warn(`Unsupported interpolation type "${d.interpolation}" in animation "${_}". Fall back to LINEAR interpolation.`);const p=Yh(l.target.path);i.push({min:u.min,max:u.max,frameCount:u.count,keyFrameType:"SCALAR",interpolation:d.interpolation||"LINEAR",outputType:p.outputType,outputBufferView:f.bufferView,outputBufferOffset:m.byteOffset||0,outputBufferLength:m.byteLength/p.bufferStride,targetMatIndex:[o.length-1,p.targetindex],actionId:`${a.name}_${r}_${c}`,animationIndex:r,animationName:_})}})})}function Yh(s){let e=0,t="VEC3";const i=4;switch(s){case"translation":e=0;break;case"rotation":e=1,t="VEC4";break;case"scale":e=2;break;case"weights":e=3}return{targetindex:e,outputType:t,bufferStride:i}}function Pr(s,e,t,i){const o=e.bufferViews[t];if(o===void 0)return;if(!s.buffers[t]){const r=e.buffers[o.buffer].buffer;if(!r)return;s.buffers[t]=Xo(r)}const a=s.buffers[t];if(!(a instanceof n.Buffer))return a}function Qh(s,e){for(let t=s.length-1;t>=0;t--){const i=s[t];if(e(i,t,s))return i}}const Jh=new Set(["position","texcoord_0","texcoord_1","texcoord_2","texcoord_3","normal","tangent"]),Ah=Array.from(n.create$2()),ef={pbrMetallicRoughness:{baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1};function tf(s){return Br(s,ef),s}function Br(s,e){for(const t in e)s[t]===void 0?s[t]=e[t]:typeof s[t]=="object"&&Br(s[t],e[t])}var et=(s=>(s[s.Pending=1]="Pending",s[s.Loaded=2]="Loaded",s[s.Failed=3]="Failed",s))(et||{});function nf(s){return{buffers:[],textures:[],status:1,scenes:[],defaultScene:0,preserve:s}}function of(s,e,t,i,o,a){var c;const r=[],l=[];for(const d of t.scenes){const _=[];zr(_,s,d.nodes,t,r,l,e,i,o,a),s.scenes.push({id:n.uniqId(),name:d.name,objects:_})}return s.defaultScene=(c=t.scene)!=null?c:0,s}function zr(s,e,t,i,o,a,r,l,c,d){var u,h,f,m,p,v;if(!t)return;const _=r.symbolSettingsList.gltfModel.instances;if(!(!_||_.length===0))for(const x of t){const g=i.nodes[x];if(n.isObject(g.extras)&&g.extras.ignore)continue;const y=[...o],b=[...a];if(g.matrix&&y.push(g.matrix),g.translation&&g.rotation&&g.scale){const M=[];M.push(g.translation,g.rotation,g.scale),y.push(M),qh(i,e,x,b,y)}if(g.mesh!==void 0){const M=i.meshes[g.mesh];let T=d?n.GltfDemPosition.flat:n.GltfDemPosition.default;n.isObject(g.extras)&&(g.extras.dem==="flat"?T=n.GltfDemPosition.flat:g.extras.dem==="instance"&&(T=n.GltfDemPosition.default));const P=new Float32Array(16);Lr(P,b,y,e.buffers);let S,C;if(g.children){const I=[];for(const E of g.children){const F=i.nodes[E];lf(F)&&I.push(F)}if(I.length){const E=I[0];if(E.extras.dem==="centroid")T=n.GltfDemPosition.centroid,S=[E.translation[0],E.translation[2]];else if(E.extras.dem==="axis"){T=n.GltfDemPosition.axis;const F=Qh(I,j=>j.extras.dem==="axis");C=[E.translation[0],E.translation[2],(F!=null?F:E).translation[0],(F!=null?F:E).translation[2]]}}}for(const I of M.primitives){const E=[],F={};let j=0,ee,z;for(const Ee in I.attributes){const Lt=/TEXCOORD_(\d+)/.exec(Ee);Lt&&(E[parseInt(Lt[1],10)]=!0);const Pt=Ee.toLowerCase();if(!Jh.has(Pt))continue;const Bt=I.attributes[Ee],Ze=i.accessors[Bt];if(Ze.bufferView===void 0)continue;const Kn=i.bufferViews[Ze.bufferView];if(Kn===void 0)continue;const jt=Rr(r,e,i,Ze.bufferView,Ze.componentType);if(jt){if(Pt==="position"&&(ee=Ze.min,z=Ze.max),jt.purpose="gltfMesh",F[Ee.toLowerCase()]=new n.BufferChannel(jt,{itemSize:af(Ze.type),dataType:n.componentTypeToWebGl(Ze.componentType),stride:(u=Kn.byteStride)!=null?u:0,offset:(h=Ze.byteOffset)!=null?h:0,normalized:!!Ze.normalized}),!S&&Ee.toLowerCase()==="position"){const Bi=Ze.min,zi=Ze.max;Bi&&zi&&(S=[(zi[0]+Bi[0])/2,(zi[2]+Bi[2])/2])}j===0&&(j=Ze.count)}}ee||(ee=[0,0,0]),z||(z=[0,0,0]);let J;if(I.indices!==void 0){const Ee=i.accessors[I.indices];if(Ee.bufferView===void 0||(J=Rr(r,e,i,Ee.bufferView,Ee.componentType,!0),!J))continue;J.purpose="gltfIndices",j=Ee.count}const q=I.material!==void 0?i.materials[I.material]:{},Te=tf(q),Ue={},De={localMatrix:P,animationStack:b,transformStack:y,availableTextureCoords:E,attributesAliases:Ue,colorFactor:[...Te.pbrMetallicRoughness.baseColorFactor],colorTexture:NaN,aoTexture:NaN,pbrTexture:NaN,centroid:S,axis:C,demPosition:T},Ge=[],Ct=Te.pbrMetallicRoughness.baseColorTexture;Ct&&(Ge.push({type:_h}),Ue.texcoord_color=`texcoord_${(f=Ct.texCoord)!=null?f:0}`,$o(e,i,Ct),De.colorTexture=Ct.index);const bt=Te.pbrMetallicRoughness.metallicRoughnessTexture;if(bt){Ge.push({type:lh}),$o(e,i,bt),De.pbrTexture=bt.index;const Ee=typeof bt.texCoord=="number"?bt.texCoord:0;Ue.texcoord_pbr=`texcoord_${Ee}`,E[Ee]=!1}else De.roughness=(m=Te.pbrMetallicRoughness.roughnessFactor)!=null?m:1,De.metallic=(p=Te.pbrMetallicRoughness.metallicFactor)!=null?p:1;Number.isNaN(c.style.roughness)||Ge.push({type:rh}),((v=g.extras)==null?void 0:v.tier)!==void 0&&(De.meshTier=g.extras.tier,Ge.push({type:dh})),c.style.lightingModel==="pbr"?Ge.push({type:sr,value:hh}):Ge.push({type:sr,value:uh});const Me=Te.occlusionTexture;if(Me){Ge.push({type:ch}),$o(e,i,Me),De.aoTexture=Me.index;const Ee=typeof Me.texCoord=="number"?Me.texCoord:0;Ue.texcoord_ao=`texcoord_${Ee}`,E[Ee]=!1}s.push({start:0,count:j,attributes:De,drawMode:I.mode,accessors:F,elementsBuffer:J,shaderDefinitions:Ge,bbox:{min:ee,max:z}})}}g.children&&zr(s,e,g.children,i,y,b,r,l,c,d)}}function $o(s,e,t){var c;const i=(c=t.index)!=null?c:0,o=e.textures[i];if(!o||o.source===void 0||o.sampler===void 0)return;const a=e.images[o.source],r=e.samplers[o.sampler];if(!r||!a)return;const l={flipY:!1};if(r.magFilter&&(l.magFilter=Vi(r.magFilter)),r.minFilter&&(l.minFilter=Vi(r.minFilter)),r.wrapS&&(l.wrapS=Vi(r.wrapS)),r.wrapT&&(l.wrapT=Vi(r.wrapT)),t.texCoord!==void 0&&(l.texcoord=t.texCoord),!a.image&&a.bufferView){rf(e,a).then(d=>{d&&(a.image=d,s.textures[i]=new w(a.image,l))});return}s.textures[i]=new w(a.image,l)}function Rr(s,e,t,i,o,a=!1){const r=t.bufferViews[i];if(r===void 0)return;if(!e.buffers[i]){const c=t.buffers[r.buffer].buffer;if(!c)return;const d=new DataView(Xo(c),r.byteOffset,r.byteLength),_=s.createBuffer(d,{dataType:n.componentTypeToWebGl(o)},a);e.buffers[i]=_}const l=e.buffers[i];if(!(l instanceof ArrayBuffer))return l}function sf(s=[],e){if(e.length===0)return Array.from(Ah);n.copy(s,e[0]);for(let t=1;t<e.length;t++)n.mul$1(s,s,e[t]);return s}function af(s){switch(s[0]){case"S":return 1;case"V":return Number(s[3]);case"M":return je(Number(s[3]),2)}return console.error(`Failed to determine channels count from accessor type = ${s}`),0}function Xo(s){return s instanceof ArrayBuffer?s:s.buffer}function rf(s,e){return K(this,null,function*(){if(!e.bufferView)return!1;const t=s.bufferViews[e.bufferView];if(t===void 0)return!1;const i=s.buffers[t.buffer].buffer;return i?yn(new Uint8Array(i,t.byteOffset,t.byteLength),e.mimeType):!1})}function lf(s){return s.mesh===void 0&&n.isObject(s.extras)&&(s.extras.dem==="centroid"||s.extras.dem==="axis")}const cf=n.len$1([1,1,1]),kt=n.create$1(),Ko=n.create$1(),df=n.create$2();function _f(s,e){n.invert(s,e);const t=n.create$2();t[12]+=s[12],t[13]+=s[13],n.mul$1(s,s,t)}function qo(s){return s.symbol==="gltfModel"&&s.sink==="instances"}function uf(s,e,t,i,o){var d;const a=s.modelMatrices.get(0);if(!a)return;const r=[t[0]/n.maxUint16Value,t[1]/n.maxUint16Value,t[2]/n.maxUint16Value],l=[t[3]/n.maxUint16Value,t[4]/n.maxUint16Value,t[5]/n.maxUint16Value],c={min:[0,0,0],max:[0,0,0]};if(n.transformMat4$1(c.min,r,a),n.transformMat4$1(c.max,l,a),o)if(i.tMatrix3x3){const _=hf(o,i.tMatrix3x3,e);n.add$1(c.min,c.min,_.min),n.add$1(c.max,c.max,_.max)}else{let _=Math.max(n.len$1(o.max),n.len$1(o.min));if(e){const u=kt,h=Ko;n.decomposeMat4(e,u,h);const f=n.len$1(u)/cf;_*=f,_+=n.len$1(h)}_*=(d=i.maxDiag)!=null?d:1,n.set(kt,-_,-_,-_),n.add$1(c.min,c.min,kt),n.set(kt,_,_,_),n.add$1(c.max,c.max,kt)}return c}function hf(s,e,t){const i=n.set$2(df,e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1);t&&n.mul$1(i,i,t);const o=n.lerp(kt,s.min,s.max,.5),a=n.scale(Ko,n.sub$1(Ko,s.max,s.min),.5),r=n.transformMat4$1(kt,o,i),l=n.fromValues(Math.abs(i[0])*a[0]+Math.abs(i[4])*a[1]+Math.abs(i[8])*a[2],Math.abs(i[1])*a[0]+Math.abs(i[5])*a[1]+Math.abs(i[9])*a[2],Math.abs(i[2])*a[0]+Math.abs(i[6])*a[1]+Math.abs(i[10])*a[2]),c=n.sub$1(n.create$1(),r,l),d=n.add$1(n.create$1(),r,l);return{min:c,max:d}}class ff{constructor(e){this.modules=e,this.queue=new Map}enqueue(e,t){this.queue.set(t.id,{batch:e,tile:t,state:void 0})}update(){const{renderer:e,tileManager:t}=this.modules;for(const i of t.getTileObjects()){const o=this.queue.get(i.id);if(!o)continue;const{batch:a}=o,{symbol:r,sink:l}=a,c=n.getSymbolLayers(e,r,l);if(!c){console.error(`Cannot happen! Symbol ${r} does not have sink ${l}!`);continue}const d=c[0].instanceBinder;if(!d){console.error("Cannot happen! No instanceBinder for batch inside instanceLinker queue.");continue}const _=d(this.modules,a,i,o.state);if(!_){this.queue.delete(i.id);continue}o.state=_}}}function mf(s,e,t,i,o,a,r,l,c,d,_,u){const h=n.stride(a,r),f=n.getSymbolLayers(e,a,r),{accessors:m,elementsBuffer:p,count:v,drawMode:x,bbox:g}=i,y=n.Shader.createShaderDefinitions(i.shaderDefinitions);_.linkId=t;for(const b of f){const M=b.uniformSet||"fill",T=JSON.stringify(Object.values(c))+"_"+M+"_"+o.detailLevel,P=e.getShaderProgram(b.programName,y),S=l.buffer;if(!S){console.error(`Expected existing buffer while linking instance, but ${S} found.`);continue}const C=b.vaoCreator(S,P,p,m);_.attributesAliases&&C.setAttributesAliases(_.attributesAliases);const I={id:n.uniqId(),type:n.SceneObjectType.Tile,layerSettings:b,start:0,count:v,attributes:c,shaderDefinitions:y,renderingProperties:d,meta:_,attributesHash:T,vao:C,drawMode:x,tile:o,bbox:g,bboxWorld:u,symbol:a,sink:r,canRender:!0,instanceCount:(l.rangeEnd-l.rangeStart)/h};o.push(I),s.push(I)}s.length&&e.addRerenderEvent({type:"instanceLink"})}function Fr(s,e,t){pf(e,i=>{var a;const o=((a=i.meta)==null?void 0:a.linkId)===t;return o&&s.push(i),!o})}function pf(s,e){s.children=s.children.filter(e),s.identifyChildren=s.identifyChildren.filter(e),s.depthTestChildren=s.depthTestChildren.filter(e),s.labelTestChildren=s.labelTestChildren.filter(e),s.shadowChildren=s.shadowChildren.filter(e)}const vf={min:[0,0,0],max:[0,0,0]},xn=(s,e,t,i)=>{var c,d;const{assetManager:o,modelsScene:a,renderer:r}=s;if(i||(i={}),t.destroyed){const _=[];for(const u in i){const h=i[+u];Number.isNaN(h.linkId)||Fr(_,t,h.linkId)}for(const u of _)a.removeSceneObject(u.id);return}const l=[];for(let _=0;_<e.generatedObjects.length;_++){const u=e.generatedObjects[_],h=n.GltfModelGenerator.sinks.instances.unpackObjectAttributes(u.attributes),{extents:f}=u;i[_]||(i[_]={modelId:NaN,linkId:NaN});const m=i[_];let p;const v=!!m.referenceBbox;m.referenceBbox?p=m.referenceBbox:(p=vf,p.min[0]=f[0]/n.maxUint16Value,p.min[1]=f[1]/n.maxUint16Value,p.min[2]=f[2]/n.maxUint16Value,p.max[0]=f[3]/n.maxUint16Value,p.max[1]=f[4]/n.maxUint16Value,p.max[2]=f[5]/n.maxUint16Value);const{styleId:x}=h,g=m.modelId,y=m.sceneId;a.updateModelId(m,h,p,t,v);const b=m.modelId;if(b===void 0||Number.isNaN(b))continue;const M=m.sceneId;if(M===void 0||Number.isNaN(M)||g===b&&y===M)continue;const T=o.getModel(b,x);if(!T||T.status!==et.Loaded)continue;const P=(d=(c=T==null?void 0:T.scenes.find(I=>I.id===m.sceneId))==null?void 0:c.objects)!=null?d:[];if(P.length===0)continue;const S=m.linkId;if(!Number.isNaN(S)){const I=[];Fr(I,t,S);for(const E of I)a.removeSceneObject(E.id)}const C=n.uniqId();m.linkId=C;for(const I of P){const E=t.modelMatrices.get(0),F=new Float32Array(16);_f(F,E);const{attributesAliases:j,availableTextureCoords:ee,colorTexture:z,colorFactor:J,aoTexture:q,pbrTexture:Te,metallic:Ue,roughness:De,meshTier:Ge,animationStack:Ct,transformStack:bt,localMatrix:Me,demPosition:Ee,axis:Lt,centroid:Pt}=I.attributes,Bt=uf(t,Me,f,u,I.bbox);!m.referenceBbox&&Bt&&(m.referenceBbox=Bt),mf(l,r,C,I,t,e.symbol,e.sink,u,B({colorTexture:z,colorFactor:J,aoTexture:q,pbrTexture:Te,metallic:Ue,roughness:De,meshTier:Ge,demPosition:Ee,axis:Lt,centroid:Pt},h),{modelId:b,animationStack:Ct,transformStack:bt,localMatrix:new Float32Array(Me!=null?Me:[]),transformMatrix:F},de(B({},u.meta),{attributesAliases:j,availableTextureCoords:ee}),Bt)}}return l.forEach(_=>{a.addSceneObject(_)}),i},bn=new Float32Array(16);let Le,Pe;function R(...s){return(t,i,o,a,r,l)=>{for(const c of s)if(!c(t,i,o,a,r,l))return!1;return!0}}const D=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_mvp:i.tile.renderMvpMatrix}),!0),ke=(s,e,t,i)=>{const{camera:o,styleManager:a,renderer:r}=t,l=a.getStyle(e.handyStyleId);return!(l==null?void 0:l.environment)||!i.tile.renderModelMatrix?!1:(r.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:o.ecefMvpMatrix,u_float_crossfade:o.globeRatio}),!0)},wn=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_flat_map_mvp:i.tile.renderFlatMapTexMatrix}),!0),Q=(s,e,t,i)=>i.tile.renderModelMatrix?(n.copy(bn,i.tile.renderModelMatrix),t.renderer.bindShaderProgram(s,{u_mat4_model:bn}),!0):!1,Sn=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0}),!0),k=(s,e,{renderer:t},i,o,a)=>{if(a.terrain3d){if(!i.tile.renderModelMatrix)return!1;t.bindShaderProgram(s,{u_mat4_dem_mvp:i.tile.renderDemMatrix,u_float_vertical_scale:1/i.tile.renderModelMatrix[10]})}return!0};function oi(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData)}const Yo=(s,e,t,i,o)=>{var m;Le=void 0;const a=oi(e,i),r=n.resolveString(o.style.textureImage,a);let l=!1;o.type==="polygon"&&(l=o.style.lengthUnits===n.LengthUnits.Meters);const c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=(m=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(r)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.textureSize,a);let[u,h]=Array.isArray(_)?_:[_,_];if(l&&(u=u*n.getPixelsPerMeter(u,u),h=h*n.getPixelsPerMeter(h,h)),u<=0||h<=0)return!0;const f=n.selectRaster(d,u*window.devicePixelRatio,!0);return f===void 0||(Le=d[f]),!0},Dr=(s,e,t,i,o)=>{var m;Pe=void 0;const a=oi(e,i),r=n.resolveString(o.style.normalMapTextureImage,a),l=o.style.normalMapTextureLengthUnits===n.LengthUnits.Meters,c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=(m=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(r)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.normalMapTextureSize,a);let[u,h]=Array.isArray(_)?_:[_,_];if(l&&(u=u*n.getPixelsPerMeter(u,u),h=h*n.getPixelsPerMeter(h,h)),u<=0||h<=0)return!0;const f=n.selectRaster(d,u*window.devicePixelRatio,!0);return f===void 0||(Pe=d[f]),!0},Qo=(s,e,{assetManager:t,renderer:i},o,a)=>{if(!Le)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;let r,l,c,d;const{tile:_}=o,{zoom:u}=e,h=t.textures[Le.atlasIndex];let f=!1;if(!h)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;a.type==="polygon"&&(f=a.style.lengthUnits===n.LengthUnits.Meters),i.enableTexture(h,0);let m;if(f){const p=oi(e,o),v=n.resolveExpression(a.style.textureSize,p),[x,g]=Array.isArray(v)?v:[v,v],y=n.Mercator.toGeo(n.tileCoordsToMapPoint(_.coords)),b=n.Mercator.scaleFactor(y[1]),M=n.tileZoomToSize(_.zoomLevel)/n.MAP_POINTS_IN_METER/b,T=M/x,P=M/g,S=Math.trunc(n.atlasSize[0]/T),C=Math.trunc(n.atlasSize[1]/P);r=_.coords[0]*n.atlasSize[0]%S/S,l=_.coords[1]*n.atlasSize[1]%C/C,c=n.atlasSize[0]/S,d=n.atlasSize[1]/C}else m=n.tileSizeZpt*Math.pow(2,Math.round(u)-_.zoomLevel)*window.devicePixelRatio,r=_.coords[0]*m%Le.w/Le.w,l=_.coords[1]*m%Le.h/Le.h,c=m/Le.w,d=m/Le.h;return i.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_params:[r,l,c,d],u_float_sprite_texture_coords:[(Le.x+.5)/n.atlasSize[0],(Le.y+Le.h-1)/n.atlasSize[1],(Le.x+Le.w-1)/n.atlasSize[0],(Le.y+.5)/n.atlasSize[1]]}),!0},Or=(s,e,t,i,o)=>{var g;const{assetManager:a,styleManager:r,renderer:l}=t;if(!Pe)return l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0;let c,d,_,u;const{tile:h}=i,{zoom:f}=e,m=a.textures[Pe.atlasIndex],p=o.style.normalMapTextureLengthUnits===n.LengthUnits.Meters;if(!m)return l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0;l.enableTexture(m,1);let v;if(p){const y=oi(e,i),b=n.resolveExpression(o.style.normalMapTextureSize,y),[M,T]=Array.isArray(b)?b:[b,b],P=n.Mercator.toGeo(n.tileCoordsToMapPoint(h.coords)),S=n.Mercator.scaleFactor(P[1]),C=n.tileZoomToSize(h.zoomLevel)/n.MAP_POINTS_IN_METER/S,I=C/M,E=C/T,F=Math.trunc(n.atlasSize[0]/I),j=Math.trunc(n.atlasSize[1]/E);c=h.coords[0]*n.atlasSize[0]%F/F,d=h.coords[1]*n.atlasSize[1]%j/j,_=n.atlasSize[0]/F,u=n.atlasSize[1]/j}else v=n.tileSizeZpt*Math.pow(2,Math.round(f)-h.zoomLevel)*window.devicePixelRatio,c=h.coords[0]*v%Pe.w/Pe.w,d=h.coords[1]*v%Pe.h/Pe.h,_=v/Pe.w,u=v/Pe.h;const x=(g=r.getStyle(i.attributes.styleId))==null?void 0:g.rasterSets.byIndex[Pe.rasterSetIndex];return!x||!x.isReady?(l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0):(l.bindShaderProgram(s,{u_int_is_normal_map_textured:1,u_vec4_normal_map_texture_params:[c,d,_,u],u_vec4_normal_map_sprite_texture_coords:[(Pe.x+.5)/n.atlasSize[0],(Pe.y+Pe.h-1)/n.atlasSize[1],(Pe.x+Pe.w-1)/n.atlasSize[0],(Pe.y+.5)/n.atlasSize[1]]}),!0)},gf=(s,e,{renderer:t})=>(t.bindShaderProgram(s,{u_int_is_textured:0,u_int_is_normal_map_textured:0}),!0),Nr=(s,e,{renderer:t},i,o)=>{if(!Pe)return!0;const a=oi(e,i),r=n.resolveExpression(o.style.metallic,a),l=n.resolveExpression(o.style.roughness,a);return t.bindShaderProgram(s,{u_float_metallic:r,u_float_roughness:l}),!0},yf=(s,e,t,i)=>{if(!Le)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;const{tile:o}=i,{zoom:a}=e,r=t.assetManager.textures[Le.atlasIndex];if(!r)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;t.renderer.enableTexture(r,0);const l=n.tileSizeZpt*Math.pow(2,Math.round(a)-o.zoomLevel)*window.devicePixelRatio;return t.renderer.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_vertical_scale:Le.h*o.size/l}),!0},xf=(s,e,{styleManager:t,assetManager:i,renderer:o},a,r)=>{var y;const l=oi(e,a),c=n.resolveString(r.style.iconImage,l),d=t.getStyle(a.attributes.styleId);if(!d)return!1;const _=(y=d.rasterSets.byKey[n.getStaticTextureRasterSetKey(c)])==null?void 0:y.rasters;if(!_)return!1;const u=n.resolveNumber(r.style.width,l),h=n.resolveNumber(r.style.height,l),f=n.getPixelsPerMeter(u,h),m=u*f,p=h*f;if(m<=0||p<=0)return!1;const v=n.selectRaster(_,m*window.devicePixelRatio,!0);if(v===void 0)return!1;const x=_[v],g=i.textures[x.atlasIndex];return g?(o.enableTexture(g,0),o.bindShaderProgram(s,{u_float_sprite_texture_coords:[(x.x+.5)/n.atlasSize[0],(x.y+x.h-1)/n.atlasSize[1],(x.x+x.w-1)/n.atlasSize[0],(x.y+.5)/n.atlasSize[1]]}),!0):!1},kr=new Float32Array(16);n.fromScaling(kr,[1/n.worldSize,1/n.worldSize,1/n.worldSize]);const Tn=(s,e,{animationManager:t,assetManager:i,renderer:o},a,r)=>{const{styleId:l}=a.attributes,{localMatrix:c,transformMatrix:d,modelId:_}=a.renderingProperties;if(_===void 0)return!1;const u=i.getModel(_,l);return u===void 0?!1:(t.animateGltfObject(a,r,u),o.bindShaderProgram(s,{u_mat4_localmatrix:c,u_mat4_instance:e.globeMode?kr:d}),!0)},bf=(s,e,{renderer:t},i)=>i.tile.renderModelMatrix?(n.copy(bn,i.tile.renderModelMatrix),t.bindShaderProgram(s,{u_mat4_model:bn}),!0):!1,Ur=(s,e,{animationManager:t,renderer:i},o,a)=>{if(!Pe)return!0;let r=[0,0,0,0],l=0;const[c,d]=t.animatePolygonNormalMapTexture(o,a);return r=d,l=c?1:0,i.bindShaderProgram(s,{u_vec4_normal_map_animated_offsets:r,u_int_normal_map_is_animated:l}),!0},wf=(s,e,t)=>!t.shadowManager.texture;function Sf(){return{line:{solid:[{programName:"road",vaoCreator:$d,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:Uu,objectBinder:L($a,me,Ne),layerBinder:ae,zoomBinder:gt,tileBinder:R(Q,D),cullMethod:O(V,fe,st,Je)},{identify:!0,programName:"roadIdentify",vaoCreator:Yd,stateBinder:St,needsVisibilityBuffer:!1,objectBinder:L(Ne),zoomBinder:gt,tileBinder:D,cullMethod:O(V,fe,st,Je)}],patterned:[{programName:"patternedLine",vaoCreator:Qd,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:ja,layerBinder:ae,objectBinder:L(Ka,Ne,Ce,ei),zoomBinder:Aa,tileBinder:R(Q,D),cullMethod:O(V,fe,st,hr)}],solid3d:[{programName:"line3D",vaoCreator:Xd,stateBinder:lo,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:zu,objectBinder:L(me,Ne,Ye,N),layerBinder:ae,zoomBinder:gt,tileBinder:R(Q,D,k),cullMethod:O(V,st,Je),is3dMapAware:!0},{identify:!0,programName:"line3DIdentify",vaoCreator:Kd,stateBinder:ge,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(Ne,Ye,N),zoomBinder:gt,tileBinder:R(D,k),cullMethod:O(V,st,Je),is3dMapAware:!0}],patterned3d:[{programName:"patternedLine3D",vaoCreator:Jd,stateBinder:lo,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:Gu,layerBinder:ae,objectBinder:L(Ka,Ne,Ce,ei,N),zoomBinder:Aa,tileBinder:R(Q,D,k),cullMethod:O(V,st,hr),is3dMapAware:!0}]},polygon:{fill:[{programName:"vtxColor",vaoCreator:Hd,stateBinder:Re,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Ga,layerBinder:Ie(ae,_t,$s),objectBinder:L(me,Wa,Ce,Eo,he),tileBinder:R(Yo,Qo,Dr,Or,D,Q,Ur,Nr),cullMethod:O(V,se,fe,Je)},{identify:!0,programName:"vtxColorIdentify",vaoCreator:Wd,stateBinder:St,needsVisibilityBuffer:!0,programBinder:js,objectBinder:L(he),tileBinder:D,cullMethod:O(V,se,fe)}],fillWithMixFactor:[{programName:"vtxColor",vaoCreator:Vd,stateBinder:C_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Ga,layerBinder:Ie(ae,_t,$s),objectBinder:L(me,Wa,Ce,Eo,he),tileBinder:R(Yo,Qo,Dr,Or,D,Q,Ur,Nr),cullMethod:O(V,se,fe,Je)}],stroke:[{programName:"simpleLine2d",vaoCreator:h_,stateBinder:Re,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Ru,layerBinder:Ie(js,$i,ae),objectBinder:L(me,Ne,he),tileBinder:R(Q,D),cullMethod:O(Dh,V,se,fe,wi,Si,wr),subRenderIndex:1}],shadow:[{programName:"vtxColor",vaoCreator:Zd,stateBinder:Re,needsVisibilityBuffer:!0,commonBinder:X(W,$),programBinder:nt,layerBinder:_t,objectBinder:L(me,Ce,he),tileBinder:R(wf,gf,D,Q),cullMethod:O(V,se,fe,Gh)}]},metricPoint:{fill:[{programName:"metricPoint",vaoCreator:jd,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(W,te,$),programBinder:He,layerBinder:Ie(ae,_t),objectBinder:L(me,he),tileBinder:R(xf,D,Q),cullMethod:O(V,se,Je)}]},mesh:{fill:[{programName:"mesh",vaoCreator:ea,stateBinder:pa,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ht,layerBinder:Ie(ae,ut),objectBinder:L(me,yi,Ce,qe,N,Ye,ot,Eo),tileBinder:R(Yo,Qo,yf,Q,D,k),cullMethod:O(V,yr),subRenderIndex:1,is3dMapAware:!0},{identify:!0,programName:"mesh",vaoCreator:ea,stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ht,objectBinder:L(qe,N,Ye,ot),tileBinder:R(D,k),cullMethod:O(V,yr),subRenderIndex:1,is3dMapAware:!0},{depthTest:!0,programName:"mesh",vaoCreator:e_,stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ht,objectBinder:L(qe,N,Ye,ot),tileBinder:R(D,k),cullMethod:V,subRenderIndex:1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ta,stateBinder:en,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(qe,N,Ye),tileBinder:R(D,k),cullMethod:V,is3dMapAware:!0}],inverse:[{programName:"inverse",vaoCreator:qi,stateBinder:Ji,needsVisibilityBuffer:!0,commonBinder:W,programBinder:ht,objectBinder:L(qe,N,ot),tileBinder:R(D,k),cullMethod:V,subRenderIndex:-1,is3dMapAware:!0},{identify:!0,programName:"inverse",vaoCreator:qi,stateBinder:Ji,needsVisibilityBuffer:!1,commonBinder:W,programBinder:ht,objectBinder:L(qe,N,ot),tileBinder:R(D,k),cullMethod:V,subRenderIndex:-1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:qi,stateBinder:en,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(qe,N,Ye),tileBinder:R(D,k),cullMethod:V,is3dMapAware:!0}],depthClear:[{programName:"meshDepthClear",vaoCreator:qi,stateBinder:B_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ht,objectBinder:L(qe,N,ot,Ye),tileBinder:R(D,k),cullMethod:V,subRenderIndex:-2,is3dMapAware:!0,forceRenderUnderCacheInDemMode:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:t_,stateBinder:Xt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:an,layerBinder:Ie($i,ae),objectBinder:L(me,Ne,qe,ti,N,Ye),tileBinder:R(Q,D,k),cullMethod:O(V,wi,Ch,Hh,wr),subRenderIndex:2,is3dMapAware:!0}]},polygonExtrusion:{sideFill:[{programName:"diffuse",vaoCreator:ia,stateBinder:Ji,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Qt,tileBinder:R(Q,D,k),layerBinder:Ie(ae,ut),objectBinder:L(me,Ke,Ce,N,he,bi),cullMethod:O(mr,V,se,gn,fe),is3dMapAware:!0},{programName:"gradientDiffuse",vaoCreator:ia,stateBinder:xa,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Qt,layerBinder:Ie(ae,ut),objectBinder:L(me,yi,Ke,Ce,N,he,nr,bi),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,gn,Go),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:oa(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:on,objectBinder:L(Ke,N,he),tileBinder:R(D,k),cullMethod:O(V,se,fe,gn,Go),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:sa(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:on,objectBinder:L(Ke,N,he),tileBinder:R(D,k),cullMethod:O(V,se,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:aa(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:Ai,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(Ke,N,he),tileBinder:R(D,k),cullMethod:O(V,se,fe),is3dMapAware:!0}],sideTexture:[{programName:"wallTexture",vaoCreator:i_,stateBinder:U_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Qt,layerBinder:Ie(ae,ut),objectBinder:L(Ke,N,he,ih),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,$h),is3dMapAware:!0}],topFill:[{programName:"diffuse",vaoCreator:na,stateBinder:Ji,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Qt,layerBinder:ae,objectBinder:L(me,Ke,Ce,N,he,bi),tileBinder:R(Q,D,k),cullMethod:O(mr,V,se,fe,Ho),is3dMapAware:!0},{programName:"diffuse",vaoCreator:na,stateBinder:xa,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Qt,layerBinder:Ie(ae,ut),objectBinder:L(me,Ke,Ce,N,he,bi),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,Ho),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:oa(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:on,objectBinder:L(Ke,N,he),tileBinder:R(D,k),cullMethod:O(V,se,fe,Ho),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:sa(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:on,objectBinder:L(Ke,N,he),tileBinder:R(D,k),cullMethod:O(V,se,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:aa(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:Ai,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(Ke,N,he),tileBinder:R(D,k),cullMethod:O(V,se,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:ra,stateBinder:Xt,needsVisibilityBuffer:!0,commonBinder:X(W,te,$,_e),programBinder:Ha,layerBinder:ae,objectBinder:L(me,yi,Ke,Ce,N,he),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,Sr,xr),is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:io,stateBinder:Xt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:an,layerBinder:Ie(ae,Od),objectBinder:L(me,Ne,Ke,N,he,Bo),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,wi,Si,Zh),is3dMapAware:!0}]},labelLine:{raster:[{programName:"labelLine",vaoCreator:Ki,stateBinder:_o,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:sn,objectBinder:L(zt,At,Nt,fn,pn),tileBinder:R(D,Q),zoomBinder:gt,cullMethod:O(se,Et,Qe,ii,vn,Uo),uniformSet:"fontHalo"},{programName:"labelLine",vaoCreator:Ki,stateBinder:uo,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:sn,objectBinder:L(zt,At,Nt,fn,pn),tileBinder:R(D,Q),zoomBinder:gt,cullMethod:O(se,Et,Uo,Qe,ii,vn),uniformSet:"fontHalo",isOverlappedObject:!0},{programName:"labelLine",vaoCreator:Ki,stateBinder:_o,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:sn,objectBinder:L(zt,At,Nt,fn,pn),zoomBinder:gt,tileBinder:R(D,Q),cullMethod:O(se,Et,Qe,ii,vn),uniformSet:"fontFill",subRenderIndex:1},{programName:"labelLine",vaoCreator:Ki,stateBinder:uo,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:sn,objectBinder:L(zt,At,Nt,fn,pn),zoomBinder:gt,tileBinder:R(D,Q),cullMethod:O(se,Et,Qe,ii,vn),uniformSet:"fontFill",subRenderIndex:1,isOverlappedObject:!0}]},dashedLine:{stroke:[{programName:"stripedLine",vaoCreator:Qs,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(te,W,$,_e),programBinder:Za,layerBinder:ae,objectBinder:L(ln,hn,rn,Ce,ei),tileBinder:R(Q,D),cullMethod:O(V,st,fe)},{identify:!0,programName:"stripedLineIdentify",vaoCreator:Qs,stateBinder:ma,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:Va,objectBinder:L(ln,hn,Ce,rn,ei),tileBinder:D,cullMethod:O(V,st,fe)}],stroke3d:[{programName:"stripedLine3D",vaoCreator:Js,stateBinder:lo,needsVisibilityBuffer:!1,commonBinder:X(te,W,$),programBinder:Ou,layerBinder:ae,objectBinder:L(ln,hn,rn,Ce,ei,N),tileBinder:R(Q,D,k),cullMethod:O(V,st),is3dMapAware:!0},{identify:!0,programName:"stripedLine3DIdentify",vaoCreator:Js,stateBinder:ge,needsVisibilityBuffer:!1,programBinder:Nu,objectBinder:L(ln,hn,Ce,rn,ei,N),tileBinder:R(D,k),cullMethod:O(V,st),is3dMapAware:!0}]},oneWayLine:{raster:[{programName:"oneWayLine",vaoCreator:la,stateBinder:_o,needsVisibilityBuffer:!1,commonBinder:X(ui,_i,_e),programBinder:Na,objectBinder:L(zt,me,cn,qa),tileBinder:D,cullMethod:O(Et,Qe,br)},{programName:"oneWayLine",vaoCreator:la,stateBinder:uo,commonBinder:X(ui,_i,_e),programBinder:Na,needsVisibilityBuffer:!1,objectBinder:L(zt,me,cn,qa),tileBinder:D,cullMethod:O(Et,Qe,br),isOverlappedObject:!0}]},point:{raster:[{programName:"pointSprite",vaoCreator:s_,stateBinder:co,needsVisibilityBuffer:!1,commonBinder:fi(W,$,Gs,ji,_e),programBinder:Lu,layerBinder:_t,objectBinder:L(ju,Co,Io,xi,N,he),cullMethod:O(Qe,se,ko,Do,Et),tileBinder:R(ke,Q,k),is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"pointSpriteIdentify",vaoCreator:r_,stateBinder:St,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:ka,objectBinder:L(Co,Io,xi,N,he),tileBinder:R(ke,k),cullMethod:O(Qe,se,ko,Do,fr),is3dMapAware:!0},{labelTest:!0,programName:"pointSpriteIdentify",vaoCreator:a_,stateBinder:St,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:ka,objectBinder:L(Co,Io,xi,N,he),tileBinder:R(ke,k),cullMethod:O(Qe,se,ko,Do,fr),is3dMapAware:!0}],text:[{programName:"labelPoint",vaoCreator:As,stateBinder:co,needsVisibilityBuffer:!1,commonBinder:fi(W,$,ji,_e),programBinder:Ua,objectBinder:L(zt,At,Nt,Ja,mn,xi,N,he),tileBinder:R(ke,Q,k),cullMethod:O(Qe,se,Et,ii,vr,Uo),uniformSet:"fontHalo",subRenderIndex:1,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{programName:"labelPoint",vaoCreator:As,stateBinder:co,needsVisibilityBuffer:!1,commonBinder:X(W,$,ji,_e),programBinder:Ua,objectBinder:L(zt,At,Nt,Ja,mn,xi,N,he),tileBinder:R(ke,Q,k),cullMethod:O(Qe,se,Et,ii,vr),uniformSet:"fontFill",subRenderIndex:2,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"labelPointIdentify",vaoCreator:Ad,stateBinder:St,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:pe(oe),objectBinder:L(Nt,mn,N,he),tileBinder:R(ke,k),cullMethod:O(Qe,se,Rh),subRenderIndex:1,is3dMapAware:!0}],labelingTexture:[{depthTest:!0,programName:"pointDepthTest",vaoCreator:l_,stateBinder:ma,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:oe,objectBinder:L(mn,N,he),tileBinder:R(D,k),cullMethod:O(Qe,se),is3dMapAware:!0}]},buildingModel:{fill:[{programName:"zbmModel",vaoCreator:c_,stateBinder:va,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:ku,layerBinder:Ie(ae,_t,ut),objectBinder:L(me,Po,Ku,N),tileBinder:R(Q,D,k),cullMethod:O(No,V,gr,Je,Vo),subRenderIndex:2,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:d_,stateBinder:ge,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:L(N),tileBinder:R(D,k),cullMethod:O(No,V,gr,Je,Vo),subRenderIndex:2,identify:!0,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:__,stateBinder:ge,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:L(N),tileBinder:R(D,k),cullMethod:V,depthTest:!0,is3dMapAware:!0},{programName:"zbmShadow",vaoCreator:u_,stateBinder:Ai,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(Po,N),tileBinder:R(D,k),cullMethod:V,shadow:!0,is3dMapAware:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:io,stateBinder:Xt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:an,layerBinder:Ie(ae,$i),objectBinder:L(me,Ne,Po,ti,N,Bo),tileBinder:R(D,Q,k),cullMethod:O(V,No,wi,Si,Vo),subRenderIndex:5,is3dMapAware:!0}]},shiftedLine:{solid:[{programName:"road",commonBinder:X(W,$,te),programBinder:pe(nt,He),vaoCreator:qd,stateBinder:Re,needsVisibilityBuffer:!1,layerBinder:ae,objectBinder:L(me,Ne,$a),tileBinder:R(Q,D),zoomBinder:gt,cullMethod:O(V,st,Je)}]},circle:{fill:[{programName:"circleMarker",vaoCreator:no,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(W,te,$,_e),programBinder:Mo,layerBinder:ae,objectBinder:L(me,Ne,N),cullMethod:O(V,st,Je),tileBinder:R(ke,Q,k),subRenderIndex:2,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:no,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(W,te,$,_e),programBinder:Mo,layerBinder:ae,objectBinder:L(me,Ne,N),cullMethod:O(V,Oh,Si),tileBinder:R(ke,Q,k),subRenderIndex:1,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:no,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(W,te,$,_e),programBinder:Mo,layerBinder:ae,objectBinder:L(me,Ne,N),cullMethod:O(V,Nh,Vh),tileBinder:R(ke,Q,k),is3dMapAware:!0},{identify:!0,programName:"circleMarkerIdentify",vaoCreator:f_,stateBinder:St,programBinder:oe,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:L(Ne,N),cullMethod:O(V,kh),tileBinder:R(ke,k),is3dMapAware:!0}]},arrow:{stroke:[{programName:"entrance",vaoCreator:ca,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:X(ui,_i,W,$,_e),programBinder:Fu,objectBinder:L(me,cn,Zu,Ya,Ce),tileBinder:R(D,Q),cullMethod:O(V,Je)},{identify:!0,programName:"entranceIdentify",vaoCreator:ca,stateBinder:St,needsVisibilityBuffer:!1,commonBinder:X(ui,_i,_e),programBinder:Pu,objectBinder:L(cn,Ya,Ce),tileBinder:D,cullMethod:O(V,Je)}]},lineExtrusion:{fill:[{programName:"gradientDiffuse",vaoCreator:n_,stateBinder:I_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Qt,layerBinder:Ie(ae,ut),objectBinder:L(un,me,yi,Ce,N,ti,nr,bi),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,gn,Go),subRenderIndex:9,is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:o_,stateBinder:en,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(un,N,ti),tileBinder:R(D,k),cullMethod:O(V,se,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:ra,stateBinder:Xt,needsVisibilityBuffer:!0,commonBinder:X(W,te,$,_e),programBinder:Ha,layerBinder:ae,objectBinder:L(un,me,yi,Ce,N,ti),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,Sr,xr),subRenderIndex:10,is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:io,stateBinder:Xt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:an,layerBinder:Ie(ae,$i),objectBinder:L(un,me,Ne,N,ti,Bo),tileBinder:R(Q,D,k),cullMethod:O(V,se,fe,wi,Si),subRenderIndex:11,is3dMapAware:!0}]},gltfModel:{instances:[{programName:"gltfModel",vaoCreator:Qi(!1),instanceBinder:xn,commonBinder:X(W,$,te),programBinder:Du,layerBinder:Ie(ae,ut,Xi),stateBinder:va,needsVisibilityBuffer:!1,objectBinder:L(me,qu,Ro,Lo,N,dn,he,_n),tileBinder:R(ke,Tn,bf,k,Sn),cullMethod:O(Zo,Mr),is3dMapAware:!0},{identify:!0,programName:"gltfModelIdentify",instanceBinder:xn,vaoCreator:Qi(!1),stateBinder:ge,needsVisibilityBuffer:!1,layerBinder:Xi,commonBinder:fi(W,$),programBinder:oe,objectBinder:L(N,dn,ot,Lo,he,_n),tileBinder:R(ke,Tn,k,Sn),cullMethod:O(Zo,Mr),is3dMapAware:!0},{depthTest:!0,programName:"gltfModelIdentify",instanceBinder:xn,vaoCreator:Qi(!0),stateBinder:ge,needsVisibilityBuffer:!1,commonBinder:fi(W,$),programBinder:oe,layerBinder:Xi,objectBinder:L(N,dn,Lo,he,_n),tileBinder:R(ke,Tn,k,Sn),cullMethod:Zo,is3dMapAware:!0},{shadow:!0,programName:"gltfModelShadow",instanceBinder:xn,vaoCreator:Qi(!1),stateBinder:Ai,needsVisibilityBuffer:!1,programBinder:oe,layerBinder:Xi,objectBinder:L(N,dn,_n),tileBinder:R(ke,Tn,k,Sn),cullMethod:Wh,is3dMapAware:!0}]},raster:{fill:[{programName:"rectWithTexture",vaoCreator:m_,stateBinder:Re,needsVisibilityBuffer:!1,commonBinder:fi(W,$),layerBinder:_t,objectBinder:L(Xa,Wu),tileBinder:R(D,Q),cullMethod:O(rr,V)}]},heatmap:{framebuffer:[{programName:"heatmap",vaoCreator:p_,stateBinder:ga,needsVisibilityBuffer:!1,commonBinder:Zs,objectBinder:L(Yu,Qu),zoomBinder:gt,tileBinder:R(D,Q),cullMethod:O(V,Uh)}],fill:[{programName:"heatmapTexture",vaoCreator:v_,stateBinder:Re,needsVisibilityBuffer:!1,layerBinder:_t,objectBinder:L(Xa,Xu,$u),tileBinder:Q,cullMethod:O(V,rr,Lh),subRenderIndex:1}]},dem:{mesh:[{programName:"demMesh",vaoCreator:Yi,commonBinder:X(W,$,te),programBinder:ht,layerBinder:ae,stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(N,er,ir),tileBinder:R(D,Q,wn,k),cullMethod:O(lr,cr),is3dMapAware:!0},{programName:"demGround",demGround:!0,vaoCreator:Yi,programBinder:oe,tileBinder:R(D,Q,k),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(N)},{identify:!0,programName:"demMesh",vaoCreator:Yi,programBinder:pe(oe,Da),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(tr,N),tileBinder:R(D,wn,k),cullMethod:dr,is3dMapAware:!0}],mesh2:[{dem:!0,programName:"demElevation",vaoCreator:mi,stateBinder:P_,needsVisibilityBuffer:!1,tileBinder:D,objectBinder:L()},{programName:"demGround2",demGround:!0,vaoCreator:mi,programBinder:oe,tileBinder:R(D,Q,k),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(N)},{programName:"demMesh2",vaoCreator:mi,commonBinder:X(W,$,te),programBinder:ht,layerBinder:ae,stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(ot,er,ir,N),tileBinder:R(D,Q,wn,k),cullMethod:O(lr,cr)},{identify:!0,programName:"demMesh2",vaoCreator:mi,programBinder:pe(oe,Da),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(ot,tr,N),tileBinder:R(D,wn,k),cullMethod:dr},{depthTest:!0,programName:"demMesh2DepthTest",vaoCreator:mi,programBinder:pe(oe),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(eh,N),tileBinder:R(D,k)}],hillshade:[{programName:"demHillshade",vaoCreator:oo,stateBinder:St,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(N),tileBinder:R(D,k)}],flatBottom:[{programName:"demFlatBottom",vaoCreator:g_,stateBinder:fa,needsVisibilityBuffer:!1,objectBinder:L(Au,N),tileBinder:R(D,k),cullMethod:Ph}]},mapMesh:{fill:[{programName:"mapMesh",vaoCreator:so,stateBinder:pa,needsVisibilityBuffer:!1,zoomBinder:L(zo),commonBinder:X(W,$,te),programBinder:ht,layerBinder:Ie(ae,ut),objectBinder:L(Ro,qe,N,Ye,ot),tileBinder:R(Q,D,k),cullMethod:O(V,Oo),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{identify:!0,programName:"mapMesh",vaoCreator:so,stateBinder:ge,needsVisibilityBuffer:!1,zoomBinder:L(zo),commonBinder:X(W,$,te),programBinder:ht,layerBinder:Ie(ae,ut),objectBinder:L(Ro,qe,N,Ye,ot),tileBinder:R(D,k),cullMethod:O(V,Oo),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{depthTest:!0,programName:"mapMesh",vaoCreator:so,stateBinder:ge,needsVisibilityBuffer:!1,zoomBinder:L(zo),commonBinder:X(W,$,te),programBinder:ht,layerBinder:Ie(ae,ut),objectBinder:L(qe,N,Ye,ot),tileBinder:R(D,k),cullMethod:V,subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ta,stateBinder:en,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(qe,N,Ye),tileBinder:R(D,k),cullMethod:V,is3dMapAware:!0}]},globe:{fill:[{programName:"globe",vaoCreator:_a,stateBinder:ge,objectBinder:L(Qa),tileBinder:ke,needsVisibilityBuffer:!1,is3dMapAware:!0},{identify:!0,programName:"globe",vaoCreator:_a,stateBinder:ge,objectBinder:L(Qa),tileBinder:ke,needsVisibilityBuffer:!1,is3dMapAware:!0}]}}}class Tf{constructor(e){this.gl=e,this.ext=e.getExtension("EXT_disjoint_timer_query"),this.queries=[]}addTimer(){if(!this.ext)return;const e=this.ext.createQueryEXT();this.queries.push(e),this.ext.beginQueryEXT(this.ext.TIME_ELAPSED_EXT,e)}stopTimer(){!this.ext||!this.queries.length||this.ext.endQueryEXT(this.ext.TIME_ELAPSED_EXT)}tryToGetFirstTimerValue(){if(!this.ext)return;const e=this.queries[0];if(!e)return;const t=this.ext,i=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT),o=this.gl.getParameter(t.GPU_DISJOINT_EXT);if(!i||o)return;const a=t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT);return t.deleteQueryEXT(e),this.queries.shift(),Number(a)}}const Mf=`
float affine_step(const float edge0, const float edge1, const float x)
{
    return clamp((x - edge0) / (edge1 - edge0), 0., 1.);
}
`,Gr=`
vec4 apply_opacity(const vec4 color, const float opacity)
{
return color * opacity;
}
`,Ef=`struct ArrowDistanceParameters
{
    vec2 wing_normal;
    vec2 tip_normal;
    vec2 mirrored_wing_normal;
    vec2 mirrored_tip_normal;
    float width;
    float full_length;
    float arrow_height;
    float tip_radius;
    vec2 tip_circle_center;
    float wing_radius;
    vec2 wing_circle_center;
    float border_width;
};
ArrowDistanceParameters calculate_arrow_distance_parameters(
    const vec2 wing_normal,
    const vec2 tip_normal,
    const float width_zpt,
    const float length_zpt,
    const float tip_height_multiplier,
    const float wing_height_multiplier,
    const float tip_radius_zpt,
    const float wing_radius_zpt,
    const float border_width_zpt,
    const vec2 tip_circle_center,
    const vec2 wing_circle_center)
{
    vec2 mirrored_wing_normal = vec2(wing_normal.x, -wing_normal.y);
    vec2 mirrored_tip_normal = vec2(tip_normal.x, -tip_normal.y);
    float width = 0.5 * width_zpt;
    float length = 0.5 * length_zpt;
    float arrow_height = width_zpt * (tip_height_multiplier - wing_height_multiplier);
    return ArrowDistanceParameters(
        wing_normal,
        tip_normal,
        mirrored_wing_normal,
        mirrored_tip_normal,
        width,
        length,
        arrow_height,
        tip_radius_zpt,
        tip_circle_center,
        wing_radius_zpt,
        wing_circle_center,
        border_width_zpt);
}
struct ArrowDistances
{
    float top_tip_cut;
    float bottom_tip_cut;
    float line;
    float bottom_left_wing;
    float bottom_right_wing;
    float top_left_wing;
    float top_right_wing;
    float tip_circle;
    float tip_circle_cut;
    float left_wing_circle;
    float left_wing_circle_cut;
    float right_wing_circle;
    float right_wing_circle_cut;
};
ArrowDistances calculate_arrow_distances(
    const ArrowDistanceParameters arrow_parameters,
    const vec2 texcoord,
    const float offset,
    const mat2 derivatives)
{
    float derivatives_x_multiplier = 1. / max(abs(derivatives[0].x), abs(derivatives[1].x));
    float dt = ( texcoord.x - arrow_parameters.full_length - offset) * derivatives_x_multiplier;
    float d0 = (-texcoord.x - arrow_parameters.full_length - offset) * derivatives_x_multiplier;
    float d1 = (abs(texcoord.y) - arrow_parameters.width - offset) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float d2 = (dot(texcoord - vec2(arrow_parameters.full_length - arrow_parameters.arrow_height, 0.), arrow_parameters.wing_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.wing_normal)), abs(dot(derivatives[1], arrow_parameters.wing_normal)));
    float d3 = (dot(texcoord - vec2(arrow_parameters.full_length - arrow_parameters.arrow_height, 0.), arrow_parameters.mirrored_wing_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.mirrored_wing_normal)), abs(dot(derivatives[1], arrow_parameters.mirrored_wing_normal)));
    float d4 = (dot(texcoord - vec2(arrow_parameters.full_length, 0.), arrow_parameters.tip_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.tip_normal)), abs(dot(derivatives[1], arrow_parameters.tip_normal)));
    float d5 = (dot(texcoord - vec2(arrow_parameters.full_length, 0.), arrow_parameters.mirrored_tip_normal) - offset) / max(abs(dot(derivatives[0], arrow_parameters.mirrored_tip_normal)), abs(dot(derivatives[1], arrow_parameters.mirrored_tip_normal)));
    
    float tip_circle_cut = sdf_half_planes_cut(
        texcoord,
        arrow_parameters.tip_normal,
        -arrow_parameters.mirrored_tip_normal,
        arrow_parameters.tip_circle_center,
        derivatives);
    float tip_circle = sdf_circle(
        texcoord - arrow_parameters.tip_circle_center,
        arrow_parameters.tip_radius + offset - arrow_parameters.border_width);
    vec2 tip_circle_normal = normalize(texcoord - arrow_parameters.tip_circle_center);
    tip_circle = tip_circle / max(abs(dot(derivatives[0], tip_circle_normal)), abs(dot(derivatives[1], tip_circle_normal)));
    
    vec2 right_wing_circle_center = vec2(arrow_parameters.wing_circle_center.x, -arrow_parameters.wing_circle_center.y);
    vec2 left_wing_circle_normal = normalize(texcoord - arrow_parameters.wing_circle_center);
    vec2 right_wing_circle_normal = normalize(texcoord - right_wing_circle_center);
    float left_wing_circle = sdf_circle(texcoord - arrow_parameters.wing_circle_center,
        arrow_parameters.wing_radius + offset - arrow_parameters.border_width);
        left_wing_circle = left_wing_circle / max(abs(dot(derivatives[0], left_wing_circle_normal)), abs(dot(derivatives[1], left_wing_circle_normal)));
    float right_wing_circle = sdf_circle(texcoord - right_wing_circle_center,
        arrow_parameters.wing_radius + offset - arrow_parameters.border_width);
        right_wing_circle = right_wing_circle / max(abs(dot(derivatives[0], right_wing_circle_normal)), abs(dot(derivatives[1], right_wing_circle_normal)));
    float left_wing_circle_cut = sdf_half_planes_cut(
        texcoord,
        -arrow_parameters.tip_normal,
        arrow_parameters.wing_normal,
        arrow_parameters.wing_circle_center,
        derivatives);
    float right_wing_circle_cut = sdf_half_planes_cut(
        texcoord,
        arrow_parameters.mirrored_tip_normal,
        -arrow_parameters.mirrored_wing_normal,
        right_wing_circle_center,
        derivatives);
    return ArrowDistances(
        dt,
        d0,
        d1,
        d2,
        d3,
        d4,
        d5,
        tip_circle,
        tip_circle_cut,
        left_wing_circle,
        left_wing_circle_cut,
        right_wing_circle,
        right_wing_circle_cut);
}
`,If=`
#ifdef WEBGL2
#define UNPACK_BOOL1(packedValue) ((packedValue & 0x1) != 0)
#define UNPACK_BOOL2(packedValue) ((packedValue & 0x2) != 0)
#define UNPACK_BOOL3(packedValue) ((packedValue & 0x4) != 0)
#else
#define UNPACK_BOOL1(packedValue) (int(mod(float(packedValue), 2.0)) == 1)
#define UNPACK_BOOL2(packedValue) (int(mod(float(packedValue) / 2.0, 2.0)) == 1)
#define UNPACK_BOOL3(packedValue) (int(mod(float(packedValue) / 4.0, 2.0)) == 1)
#endif
`,Hr=`#ifndef UBO
uniform highp vec3 u_cam_pos;
#endif
`,Cf=`
const float g_distance_precision_limit = 1e-4;
struct CircleDistance
{
    float distance;
    float width;
};
CircleDistance circle_color_distance(
    const mat2 derivatives,
    const vec2 circle,
    const float circle_width)
{
    float circle_length = length(circle);
    float distance = circle_length - circle_width;
    
    
    
    vec2 circle_dx = derivatives[0];
    vec2 circle_dy = derivatives[1];
    
    float distance_dx = dot(circle, circle_dx);
    float distance_dy = dot(circle, circle_dy);
    
    float derivative_denominator = circle_length;
    float width = max(abs(distance_dx), abs(distance_dy));
    return CircleDistance(
        distance * derivative_denominator,
        width);
}
vec4 distance_to_color(
    const float fill_distance,
    const float border_distance,
    const vec4 fill_color,
    const vec4 border_color)
{
    float fill_factor = affine_step(-1., 0., fill_distance);
    float border_factor = affine_step(0., 1., border_distance);
    return
        mix(mix(fill_color, border_color, fill_factor), vec4(.0), border_factor);
}
vec4 distance_to_color(
    const CircleDistance circle_distance,
    const vec4 fill_color)
{
    
    
    float fill_factor = circle_distance.distance < g_distance_precision_limit
        ? 0.
        : affine_step(0., circle_distance.width, circle_distance.distance);
    return mix(fill_color, vec4(0.), fill_factor);
}
`,Lf=`
#ifndef VARYINGS_LIMIT_9
    varying vec2 v_vec2_dem_tex_pos;
    varying float v_float_dem_invalid;
#endif
int check_dem_invalid() {
    #ifndef VARYINGS_LIMIT_9
    if (v_float_dem_invalid != 0. || v_vec2_dem_tex_pos.x < 0. || v_vec2_dem_tex_pos.x > 1. || v_vec2_dem_tex_pos.y < 0. || v_vec2_dem_tex_pos.y > 1.) {
        return 1;
    }
    #endif
    return 0;
}
`,Pf=`#ifdef WEBGL1
#extension GL_OES_standard_derivatives: enable
#endif
`,Bf=`
#define LINEAR 0
#define EXP 1
#define FOG_EQUATION (LINEAR)
#define EPSILON (0.0001)
#ifndef UBO
# ifdef FOG
uniform vec4 u_fog_color;
uniform vec2 u_fog_limits;
uniform float u_fog_horizon_blend;
uniform float u_fog_horizon_level;
# endif
#endif 
#if defined(FOG) || defined(SKY)
# ifndef UBO
uniform vec4 u_sky_color;
uniform float u_fog_horizon_pad;
# endif
varying vec3 v_fog_pos;
#endif
#ifdef FOG
float fog_horizon_blending(vec3 camera_dir, float blend) {
    blend = EPSILON + blend;
    float t = max(camera_dir.z / blend, 0.0);
    
    return exp(-3.0 * t * t);
}
float fog_exponential(float t) {
    const float decay = 6.0;
    float falloff = 1.0 - min(1.0, exp(-decay * t));
    
    falloff *= falloff * falloff;
    
    return min(1.0, 1.00747 * falloff);
}
float fog_depth(float depth) {
    float start = u_fog_limits.x;
    float end = u_fog_limits.y;
    float range = end - start;
    float fac = (depth - start) / range;
#if (FOG_EQUATION == LINEAR)
    
    fac = clamp(fac, 0.0, 1.0);
#elif (FOG_EQUATION == EXP)
    fac = fog_exponential(fac);
#endif
    return fac;
}
float calc_depth_fog() {
    float depth = length(v_fog_pos);
    float fac = fog_depth(depth);
    return fac;
}
vec3 calc_fog_color() {
    float depth = length(v_fog_pos);
    vec3 dir = v_fog_pos / depth;
    
    dir.z -= u_fog_horizon_level;
    float fog_blend = fog_horizon_blending(dir, u_fog_horizon_blend);
    if (u_sky_color.a <= 0.01) {
        return u_fog_color.rgb / u_fog_color.a;
    } else {
        
        return mix(u_sky_color.rgb / u_sky_color.a, u_fog_color.rgb / u_fog_color.a, min(fog_blend + (1.0 - u_sky_color.a), 1.0));
    }
}
#endif 
vec4 apply_fog(vec4 color) {
#ifdef FOG
    if (u_fog_color.a <= 0.01) {
        return color;
    }
    float alpha = EPSILON + color.a;
    float fac = calc_depth_fog();
    vec3 fog_color = calc_fog_color();
    color.rgb /= alpha;
    color.rgb = mix(color.rgb, fog_color, fac * u_fog_color.a);
    color.rgb *= alpha;
#endif
    return color;
}
vec4 apply_fog_alpha(vec4 color) {
#ifdef FOG
    if (u_fog_color.a <= 0.01) {
        return color;
    }
    color *= 1.0 - calc_depth_fog();
#endif
    return color;
}
vec4 apply_fog_sky(vec4 color) {
#ifdef FOG
    float alpha = EPSILON + color.a;
    float depth = length(v_fog_pos);
    vec3 dir = v_fog_pos / depth;
    
    dir.z -= u_fog_horizon_level;
    float fac = fog_horizon_blending(dir, u_fog_horizon_blend);
    color.rgb /= alpha;
    color.rgb = mix(color.rgb, u_fog_color.rgb, fac * u_fog_color.a);
    color.rgb *= alpha;
#endif
    return color;
}`,zf=`#define FRAGMENT_NORMAL
vec3 calc_fragment_normal(vec3 vertex) {
    vec3 dx = dFdx(vertex);
    vec3 dy = dFdy(vertex);
    return normalize(cross(dx, dy));
}`,Rf=`precision highp float;
`,Ff=`#ifdef UBO
uniform LightSettings
{
    vec3 u_vec3_light_dir1_direction;
    vec4 u_vec4_light_dir1_color;
    vec3 u_vec3_light_dir2_direction;
    vec4 u_vec4_light_dir2_color;
    vec4 u_vec4_ambient_color;
};
#else
uniform vec3 u_vec3_light_dir1_direction;
uniform vec4 u_vec4_light_dir1_color;
uniform vec3 u_vec3_light_dir2_direction;
uniform vec4 u_vec4_light_dir2_color;
uniform vec4 u_vec4_ambient_color;
#endif
uniform int u_int_light_flags;
vec4 light_factor(vec3 normal) {
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) { 
        return vec4(1.);
    }
    float light_1_factor = max(dot(normal, -u_vec3_light_dir1_direction), 0.0);
    float light_2_factor = max(dot(normal, -u_vec3_light_dir2_direction), 0.0);
    if (UNPACK_BOOL2(u_int_light_flags)) {
        light_1_factor *= compute_shadow_factor();
    } else if (UNPACK_BOOL3(u_int_light_flags)) {
        light_2_factor *= compute_shadow_factor();
    }
    vec3 direct_light_contrib = u_vec4_light_dir1_color[3] * light_1_factor * u_vec4_light_dir1_color.rgb;
    vec3 shading_light_contrib = u_vec4_light_dir2_color[3] * light_2_factor * u_vec4_light_dir2_color.rgb;
    return vec4(u_vec4_ambient_color[3] * u_vec4_ambient_color.rgb + direct_light_contrib + shading_light_contrib, 1.0);
}
float light_factor_dem(vec3 normal) {
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) { 
        return 1.;
    }
    float light_1_factor = dot(normal, -u_vec3_light_dir1_direction);
    
    
    
    
    return light_1_factor;
}
vec4 light_factor(vec3 normal, vec3 pos_world) {
    
    if (dot(u_cam_pos - pos_world, normal) < 0.) {
        normal *= vec3(-1.);
    }
    return light_factor(normal);
}
vec4 light_factor_surface() {
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) {
        return vec4(1.);
    }
    vec3 normal = vec3(0., 0., 1.);
    float light_1_factor = max(dot(normal, -u_vec3_light_dir1_direction), 0.0);
    float light_2_factor = max(dot(normal, -u_vec3_light_dir2_direction), 0.0);
    if (UNPACK_BOOL2(u_int_light_flags)) {
        light_1_factor *= compute_shadow_factor();
    } else if (UNPACK_BOOL3(u_int_light_flags)) {
        light_2_factor *= compute_shadow_factor();
    }
     return vec4(u_vec4_ambient_color[3] * u_vec4_ambient_color.rgb
         + u_vec4_light_dir1_color[3] * light_1_factor * u_vec4_light_dir1_color.rgb
         + u_vec4_light_dir2_color[3] * light_2_factor * u_vec4_light_dir2_color.rgb, 1.0);
}
vec4 light_factor_dem2(vec3 normal, float shade_factor) {
    vec3 normal_faded = normalize(normal * vec3(1., 1., max(1. - shade_factor, 0.01)));
    float light_1_factor = max(dot(normal_faded, -u_vec3_light_dir1_direction), - shade_factor);
    float light_2_factor = max(dot(normal_faded, -u_vec3_light_dir2_direction), - shade_factor);
    if (UNPACK_BOOL2(u_int_light_flags)) {
        light_1_factor *= compute_shadow_factor();
    } else if (UNPACK_BOOL3(u_int_light_flags)) {
        light_2_factor *= compute_shadow_factor();
    }
    vec3 direct_light_contrib = u_vec4_light_dir1_color[3] * light_1_factor * u_vec4_light_dir1_color.rgb;
    vec3 shading_light_contrib = u_vec4_light_dir2_color[3] * light_2_factor * u_vec4_light_dir2_color.rgb;
    return vec4(u_vec4_ambient_color[3] * u_vec4_ambient_color.rgb + direct_light_contrib + shading_light_contrib, 1.0);
}`,Df=`
#define LIGHT_MODEL_PBR 2
#ifdef LIGHT_MODEL
#if LIGHT_MODEL == LIGHT_MODEL_PBR
    const float PI = 3.14159265359;
    
    float D(float alpha, vec3 N, vec3 H) {
        float numerator = alpha * alpha;
        float NdotH = max(dot(N, H), 0.);
        float denominator = PI * pow(
            NdotH * NdotH * (alpha * alpha - 1.) + 1.,
            2.
        );
        return numerator / max(denominator, 0.000001);
    }
    
    float G1(float alpha, vec3 N, vec3 X) {
        float numerator = max(dot(N, X), 0.);
        float k = alpha / 2.;
        float denominator = max(dot(N, X), 0.) * (1. - k) + k;
        return numerator / max(denominator, 0.000001);
    }
    
    float G(float alpha, vec3 N, vec3 V, vec3 L) {
        return G1(alpha, N, V) * G1(alpha, N, L);
    }
    
    vec3 F(vec3 F0, vec3 V, vec3 H) {
        return F0 + (vec3(1.) - F0) * pow(1. - max(dot(V, H), 0.), 5.);
    }
    vec3 color_pbr(vec3 fragment_normal, vec3 fragment_pos_world, vec3 albedo, float roughness, float metallic) {
        float alpha = roughness * roughness;
        vec3 F0 = vec3(0.04);
        F0 = mix(F0, vec3(1.), metallic);
        
        vec3 emitted_light = u_vec4_ambient_color.rgb * u_vec4_ambient_color[3];
        vec3 N = fragment_normal;
        
        vec3 V = normalize(u_cam_pos - fragment_pos_world);
        
        vec3 L = -u_vec3_light_dir1_direction;
        
        vec3 H = normalize(V + L);
        float shadow_factor = compute_shadow_factor();
        vec3 Ks = F(F0, V, H);
        vec3 Kd = (vec3(1.0) - Ks) * (1. - metallic);
        vec3 lambert = albedo / PI;
        vec3 cookTorranceNumerator = D(alpha, N, H) * G(alpha, N, V, L) * Ks;
        float cookTorranceDenominator = 4.0 * max(dot(V, N), 0.) * max(dot(L, N), 0.);
        cookTorranceDenominator = max(cookTorranceDenominator, 0.000001);
        vec3 cookTorrance = cookTorranceNumerator / cookTorranceDenominator;
        vec3 BRDF = Kd * lambert + cookTorrance;
        vec3 outgoingLight = BRDF * u_vec4_light_dir1_color.rgb * u_vec4_light_dir1_color[3] * max(dot(L, N), 0.);
        vec3 ambient = u_vec4_ambient_color.rgb * u_vec4_ambient_color[3] * albedo;
        return ambient + outgoingLight * shadow_factor;
    }
#endif
#endif
`,Of=`#define LIGHT_MODEL_PHONG 1
#ifdef LIGHT_MODEL
#if LIGHT_MODEL == LIGHT_MODEL_PHONG
const float g_specular_power_max = 32.0;
const float g_specular_power_min = 2.0;
vec2 pbr_to_gloss(vec3 material_attributes)
{
    float weight = material_attributes.x;
    float roughness = material_attributes.y;
    float metallic = material_attributes.z;
    
    
    float specular_strength = weight * metallic;
    float specular_power = roughness * (g_specular_power_min - g_specular_power_max) + g_specular_power_max;
    return vec2(specular_strength, specular_power);
}
vec3 color_phong(vec3 fragment_normal, highp vec3 fragment_pos_world, vec3 albedo, float roughness, float metallic) {
    vec2 specular_values = pbr_to_gloss(vec3(1., roughness, metallic));
    float specular_strength = specular_values.x;
    float specular_power = specular_values.y;
    
    float shadow_factor = compute_shadow_factor();
    
    vec3 ambient = u_vec4_ambient_color.rgb * u_vec4_ambient_color[3];
    
    float diff = max(dot(fragment_normal, -u_vec3_light_dir1_direction), 0.0);
    vec3 diffuse = u_vec4_light_dir1_color.rgb * u_vec4_light_dir1_color[3] * diff * shadow_factor;
    
    
    vec3 view_dir = normalize(u_cam_pos - fragment_pos_world);
    
    vec3 reflect_dir = reflect(u_vec3_light_dir1_direction, fragment_normal);
    float spec = pow(max(dot(view_dir, reflect_dir), 0.0), specular_power);
    vec3 specular = u_vec4_light_dir1_color.rgb * u_vec4_light_dir1_color[3] * spec * specular_strength * shadow_factor;
    return albedo * (ambient + diffuse) + specular;
}
#endif
#endif
`,Nf=`precision lowp float;
`,kf=`precision mediump float;
`,Vr=`#define MIX_COLOR_MODE_READ_FROM_TARGET 1
#define MIX_COLOR_MODE_VERTEX_ATTRIBUTE 2
#define VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE 1
`,Uf=`vec4 pack_float_to_vec4(float depth)
{
    const vec4 bit_shift = vec4(255.0 * 255.0 * 255.0, 255.0 * 255.0, 255.0, 1.0);
    const vec4 bit_mask = vec4(0.0, 1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0);
    vec4 res = fract(depth * bit_shift);
    res -= res.xxyz * bit_mask;
    return res;
}
float unpack_float_from_vec4(vec4 color)
{
    const vec4 bit_shift = vec4(1.0 / (255.0 * 255.0 * 255.0), 1.0 / (255.0 * 255.0), 1.0 / 255.0, 1.0);
    return dot(color, bit_shift);
}`,Gf=`#ifdef WEBGL2
#define varying in
#define attribute in
#define texture2D texture
#define gl_FragColor fragColor
out vec4 gl_FragColor;
#endif
#ifdef UBO
uniform CommonSettings
{
    mediump float u_float_rounding_factor;
    mediump float u_float_border_width_offset;
    mediump vec2 u_vec2_scale_limits;
    mediump vec2 u_vec2_depth_test_half_point_size;
    mediump vec2 u_vec2_vpt_size;
    
    mediump vec4 u_fog_color;
    mediump vec2 u_fog_limits;
    mediump float u_fog_horizon_blend;
    mediump float u_fog_horizon_level;
    mediump float u_fog_horizon_pad;
    mediump float u_fog_distance;
    mediump vec4 u_sky_color;
    highp vec3 u_cam_pos; 
    
    
    
    
    
    
    mediump vec4 u_shadow_map_params; 
    highp mat4 u_mat4_clip_to_shadow;
    mediump float u_shadow_bias;
    mediump mat4 u_mat4_view_transposed;
    mediump mat4 u_mat4_proj_inverted;
    
    mediump vec2 u_vec2_halo_viewport_size;
    mediump vec2 u_vec2_halo_viewport_center_shift;
    mediump vec4 u_vec4_halo_radius_stops;
    mediump vec4 u_vec4_halo_color;
    mediump float u_float_halo_exp_factor;
    mediump vec4 u_vec4_default_background_color;
    
    mediump mat4 u_mat4_stars;
    mediump float u_float_pixelratio;
    mediump float u_float_stars_intensity;
};
#endif
`,Hf=`#ifdef HAS_FRAG_DEPTH_EXT
#extension GL_EXT_frag_depth : require
#endif
`,Vf=`uniform float u_sdtr_distance;
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
float interleaved_gradient_noise()
{
    const vec3 m = vec3(0.06711056, 0.00583715, 52.9829189);
    return fract(m.z * fract(dot(gl_FragCoord.xy, m.xy)));
}
void apply_screendoor() {
    #ifdef SCREENDOOR
    if (u_sdtr_distance == 0.) {
        return;
    }
    float factor = smoothstep(0., u_sdtr_distance, v_clipspace_pos.z);
    float patternValue = interleaved_gradient_noise();
    float shaped = factor - patternValue;
    if (shaped <= 0.) {
        discard;
    }
    #endif
    return;
}
`,Zf=`#ifdef RENDER_SHADOWS
# if defined(WEBGL2) && defined(DEPTH_TEXTURE_SHADOW)
uniform mediump sampler2DShadow u_texture_shadow;
# else
uniform sampler2D u_texture_shadow;
# endif
# ifndef UBO
uniform mediump vec4 u_shadow_map_params;
# endif 
varying float v_depth_metric;
varying vec4 v_pos_from_light;
float get_shadow(vec3 coords) {
# if defined(WEBGL2) && defined(DEPTH_TEXTURE_SHADOW)
    
    return texture2D( u_texture_shadow, coords );
# else
# ifdef DEPTH_TEXTURE_SHADOW
    
    float shadow_depth = texture2D(u_texture_shadow, coords.xy, 0.).r;
# else
    
    
    float shadow_depth = unpack_float_from_vec4(texture2D(u_texture_shadow, coords.xy, 0.));
# endif
    float depth_diff = v_depth_metric - shadow_depth;
    if (depth_diff <= 0.) {
        return 1.0;
    }
    return 0.0;
# endif
}
float sample_shadow_texture(vec3 shadow_coord) {
    vec2 shadow_map_size = u_shadow_map_params.xy;
    float radius = u_shadow_map_params.z;
    vec2 texelSize = vec2( 1.0 ) / shadow_map_size;
    float dx0 = - texelSize.x * radius;
    float dy0 = - texelSize.y * radius;
    float dx1 = + texelSize.x * radius;
    float dy1 = + texelSize.y * radius;
    float dx2 = dx0 / 2.0;
    float dy2 = dy0 / 2.0;
    float dx3 = dx1 / 2.0;
    float dy3 = dy1 / 2.0;
    
    
    return (
        get_shadow( shadow_coord + vec3( dx0, dy0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx1, dy0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx2, dy2, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy2, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx3, dy2, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx0, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx2, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord) +
        get_shadow( shadow_coord + vec3( dx3, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx1, 0.0, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx2, dy3, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy3, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx3, dy3, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx0, dy1, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( 0.0, dy1, 0.0 ) ) +
        get_shadow( shadow_coord + vec3( dx1, dy1, 0.0 ) )
    ) * ( 1.0 / 17.0 );
}
float compute_shadow_factor()
{
    vec4 light_pos = v_pos_from_light;
# ifdef FRAGMENT_NORMAL
    
    
    float normal_bias = u_shadow_map_params[3];
    vec3 norm_from_light = calc_fragment_normal(light_pos.xyz);
    light_pos.xyz -= normal_bias * norm_from_light;
# endif
    vec3 clip_space = light_pos.xyz / light_pos.w;
    
    float clip_factor = smoothstep(0.5, 1.0, length(clip_space));
    if (clip_factor >= 1.0) {
        return 1.0;
    }
# if defined(DEPTH_TEXTURE_SHADOW) && defined(WEBGL2)
    vec3 lightPovPositionInTexture = 0.5 * light_pos.xyz + 0.5;
    float shadow_factor = sample_shadow_texture(lightPovPositionInTexture);
# else
    vec3 uv = 0.5 * clip_space + vec3(0.5);
    float shadow_factor = sample_shadow_texture(uv);
# endif
    
    shadow_factor = mix(shadow_factor, 1.0, clip_factor);
    return shadow_factor;
}
#else  
float compute_shadow_factor()
{
    return 1.0;
}
#endif `,Zr=`#ifndef SIGNED_DISTANCE_FUNCTIONS_FSH
#define SIGNED_DISTANCE_FUNCTIONS_FSH
float sdf_intersect(const float distance1, const float distance2)
{
    return max(distance1, distance2);
}
float sdf_merge(const float distance1, const float distance2)
{
    return min(distance1, distance2);
}
float sdf_difference(const float distance1, const float distance2)
{
    return max(distance1, -distance2);
}
float sdf_half_plane(const vec2 coords, const vec2 normal)
{
    return dot(coords, normal);
}
float sdf_circle(const vec2 coords, const float radius)
{
    return length(coords) - radius;
}
float sdf_half_planes_cut(const vec2 coords, const vec2 normal1, const vec2 normal2, const vec2 cut_point, const mat2 derivatives)
{
    vec2 cut_normal1 = vec2(normal1.y, -normal1.x);
    float cut1 = sdf_half_plane(coords - cut_point, cut_normal1) /
        max(abs(dot(derivatives[0], cut_normal1)), abs(dot(derivatives[1], cut_normal1)));
    vec2 cut_normal2 = vec2(normal2.y, -normal2.x);
    float cut2 = sdf_half_plane(coords - cut_point, cut_normal2) /
        max(abs(dot(derivatives[0], cut_normal2)), abs(dot(derivatives[1], cut_normal2)));
    return sdf_merge(cut1, cut2);
}
float sdf_box( in vec2 p, in vec2 b )
{
    vec2 d = abs(p)-b;
    return length(max(d,0.0)) + min(max(d.x,d.y),0.0);
}
float sdf_triangle(in vec2 p, in float width) {
    return abs(p.x) - (p.y + .5) * width * .5;
}
float dot2(in vec2 p) {
    return dot(p, p);
}
float sdf_chevron(in vec2 p, float width, float skew, float rounding)
{
    p.x = abs(p.x);
    if (p.y + p.x > 1.0) {
        return sqrt(dot2(p - vec2(0.25, 0.75))) - sqrt(2.0)/4.0;
    }
    return sqrt(min(dot2(p - vec2(0.00, 1.00)),
                    dot2(p - 0.5 * max(p.x + p.y, 0.0)))) * sign(p.x - p.y);
}
#endif
`,jf=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <affine_step>
#include <signed_distance_functions>
#include <arrow_functions>
#include <circle_functions>
#include <fog>
uniform float u_float_tip_height_multiplier;
uniform float u_float_wing_height_multiplier;
uniform float u_float_wing_width_multiplier;
varying vec2 v_vec2_line_type_arrow_tail;
varying vec4 v_vec4_arrow_width_length_border_outer;
varying vec4 v_vec4_texcoord_arrow_line;
varying vec4 v_vec4_distance_vertex_hiding;
#ifdef ENTRANCE_ARROWS_ROUNDING
varying vec3 v_vec3_radius_tip_wing_tail;
#endif
varying vec4 v_vec4_circle_center_tip_wing;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
const float g_type_arrow = 1.;
const float g_type_start_border = 2.;
bool lookalike(const float a, const float b)
{
    return abs(a - b) < 1e-4;
}
float filter_border(const float start, const float value)
{
    return step(start, value) * 2. - 1.;
}
float arrow_distance(
    const ArrowDistanceParameters arrow_parameters,
    const vec2 texcoord,
    const float offset,
    const mat2 derivatives,
    const float line_distance,
    const float line_distance_no_offset,
    
    
    const float border_width,
    const vec2 wing_normal)
{
    ArrowDistances ad = calculate_arrow_distances(arrow_parameters, texcoord, offset, derivatives);
    float derivatives_x_multiplier = 1. / max(abs(derivatives[0].x), abs(derivatives[1].x));
    
    
    float intersection_point = arrow_parameters.full_length - arrow_parameters.arrow_height
        - arrow_parameters.width * wing_normal.y / wing_normal.x;
    float tail_arrow_intersection = filter_border(-1., (texcoord.x - intersection_point) * derivatives_x_multiplier);
    
    float top_wings;
    float bottom_wings;
    #ifdef ENTRANCE_ARROWS_ROUNDING
    top_wings = sdf_intersect(sdf_intersect(ad.top_left_wing, ad.top_right_wing), ad.tip_circle_cut);
    top_wings = sdf_merge(top_wings, ad.tip_circle);
    top_wings = sdf_intersect(top_wings, ad.top_tip_cut);
    float wings_circles = sdf_merge(ad.left_wing_circle, ad.right_wing_circle);
    float wings_radius_cut = sdf_intersect(ad.left_wing_circle_cut, ad.right_wing_circle_cut);
    bottom_wings = sdf_merge(ad.bottom_left_wing, ad.bottom_right_wing);
    bottom_wings = sdf_intersect(bottom_wings, wings_radius_cut);
    bottom_wings = sdf_merge(bottom_wings, wings_circles);
    #else
    top_wings = sdf_intersect(ad.top_left_wing, ad.top_right_wing);
    bottom_wings = sdf_merge(ad.bottom_left_wing, ad.bottom_right_wing);
    #endif
    float line_without_offset = filter_border(0., line_distance_no_offset);
    float bottom_wings_with_tail = sdf_merge(bottom_wings, line_without_offset);
    float wings_with_tail = sdf_intersect(bottom_wings_with_tail, top_wings);
    
    float tail_hide_part = v_vec2_line_type_arrow_tail.y;
    float tail_hide_mask = (-texcoord.x - tail_hide_part) * derivatives_x_multiplier;
    float clipped_tail = sdf_intersect(tail_hide_mask, sdf_intersect(line_distance, top_wings));
    return (v_vec4_distance_vertex_hiding.x < v_vec4_distance_vertex_hiding.y)
        ? sdf_intersect(-sdf_intersect(tail_arrow_intersection, line_without_offset), wings_with_tail)
        : sdf_merge(clipped_tail, sdf_intersect(-sdf_intersect(tail_arrow_intersection, line_without_offset), wings_with_tail));
}
vec4 distance_to_arrow_line_color(
    const float fill_distance,
    const float border_distance)
{
    return distance_to_color(fill_distance, border_distance, v_vec4_color, v_vec4_border_color);
}
vec4 arrow_color(
    const vec2 texcoord,
    const ArrowDistanceParameters arrow_parameters,
    const float line_fill_distance,
    const float line_border_distance,
    const vec2 wing_normal)
{
    mat2 derivatives = mat2(dFdx(texcoord), dFdy(texcoord));
    
    float border_clipping = (abs(texcoord.y) - v_vec4_arrow_width_length_border_outer.w) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float border_width = v_vec4_arrow_width_length_border_outer.z;
    float arrow_border_distance = arrow_distance(
        arrow_parameters,
        texcoord,
        v_vec4_arrow_width_length_border_outer.z,
        derivatives,
        line_border_distance,
        line_fill_distance,
        border_width,
        wing_normal);
    float border_factor = max(border_clipping, affine_step(0., 1., arrow_border_distance));
    return distance_to_arrow_line_color(
        arrow_distance(arrow_parameters, texcoord, 0., derivatives, line_fill_distance, line_fill_distance, border_width, wing_normal),
        border_factor);
}
float line_start_distance(
    const vec2 texcoord,
    const float offset,
    const mat2 derivatives,
    const float line_distance,
    const float half_width,
    const float border_width,
    const float tail_radius)
{
    float derivatives_x_multiplier = 1. / max(abs(derivatives[0].x), abs(derivatives[1].x));
    
    float tail_hide_part = v_vec2_line_type_arrow_tail.y;
    float d0 = (-texcoord.x - offset) * derivatives_x_multiplier;
    float dh = (texcoord.x - tail_hide_part) * derivatives_x_multiplier;
    float rect = max(d0, max(line_distance, dh));
    
    float radius_offset = tail_radius - border_width;
    float circle_radius = radius_offset + offset;
    vec2 left_circle_center = vec2(radius_offset, half_width - radius_offset);
    vec2 right_circle_center = vec2(radius_offset, -half_width + radius_offset);
    vec2 left_circle_normal = normalize(texcoord - left_circle_center);
    vec2 right_circle_normal = normalize(texcoord - right_circle_center);
    float cut_x = (-texcoord.x + radius_offset) * derivatives_x_multiplier;
    float cut_y = (abs(texcoord.y) - half_width + radius_offset) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float circles_cut = min(cut_x, cut_y);
    float left_circle = length(texcoord - left_circle_center) - circle_radius;
    left_circle = left_circle / max(abs(dot(derivatives[0], left_circle_normal)), abs(dot(derivatives[1], left_circle_normal)));
    float right_circle = length(texcoord - right_circle_center) - circle_radius;
    right_circle = right_circle / max(abs(dot(derivatives[0], right_circle_normal)), abs(dot(derivatives[1], right_circle_normal)));
    float circles = min(left_circle, right_circle);
    rect = min(max(rect, circles_cut), circles);
    return rect;
}
vec4 line_color(
    const float line_fill_distance,
    const float line_border_distance,
    const float line_half_width,
    const float border_width,
    const float tail_radius)
{
    float type = v_vec2_line_type_arrow_tail.x;
    float fill_distance = line_fill_distance;
    float border_distance = line_border_distance;
    if (lookalike(type, g_type_start_border))
    {
        vec2 texcoord = v_vec4_texcoord_arrow_line.xy;
        mat2 derivatives = mat2(dFdx(texcoord), dFdy(texcoord));
        fill_distance = line_start_distance(
            texcoord, 0.,
            derivatives,
            line_fill_distance,
            line_half_width,
            border_width,
            tail_radius);
        border_distance = line_start_distance(
            texcoord,
            v_vec4_arrow_width_length_border_outer.z,
            derivatives,
            line_border_distance,
            line_half_width,
            border_width,
            tail_radius);
    }
    return distance_to_arrow_line_color(fill_distance, border_distance);
}
vec4 arrow_line_color()
{
    if (lookalike(min(v_vec4_distance_vertex_hiding.y, 1.), 1.)
        || lookalike(v_vec4_distance_vertex_hiding.w, 1.)
        || !lookalike(v_vec2_line_type_arrow_tail.x, g_type_arrow) && (v_vec4_distance_vertex_hiding.x < v_vec4_distance_vertex_hiding.y || v_vec4_distance_vertex_hiding.x > v_vec4_distance_vertex_hiding.z))
    {
        discard;
    }
    vec2 wing_normal = -normalize(vec2(u_float_wing_width_multiplier, u_float_wing_height_multiplier));
    vec2 tip_normal = normalize(vec2(u_float_wing_width_multiplier, u_float_tip_height_multiplier));
    float tip_radius;
    float wing_radius;
    float tail_radius;
    #ifdef ENTRANCE_ARROWS_ROUNDING
    tip_radius = v_vec3_radius_tip_wing_tail.x;
    wing_radius = v_vec3_radius_tip_wing_tail.y;
    tail_radius = v_vec3_radius_tip_wing_tail.z;
    #else
    tip_radius = 0.;
    wing_radius = 0.;
    tail_radius = 0.;
    #endif
    ArrowDistanceParameters arrow_parameters = calculate_arrow_distance_parameters(
        wing_normal,
        tip_normal,
        v_vec4_arrow_width_length_border_outer.x,
        v_vec4_arrow_width_length_border_outer.y,
        u_float_tip_height_multiplier,
        u_float_wing_height_multiplier,
        tip_radius,
        wing_radius,
        v_vec4_arrow_width_length_border_outer.z,
        v_vec4_circle_center_tip_wing.xy,
        v_vec4_circle_center_tip_wing.zw);
    float line_width = arrow_parameters.width;
    float line_border = v_vec4_arrow_width_length_border_outer.z;
    
    vec2 line_texcoord = v_vec4_texcoord_arrow_line.zw;
    mat2 line_derivatives = mat2(dFdx(line_texcoord), dFdy(line_texcoord));
    CircleDistance circle_fill_distance = circle_color_distance(line_derivatives, line_texcoord, line_width);
    CircleDistance circle_border_distance = circle_color_distance(line_derivatives, line_texcoord, line_width + line_border);
    float line_fill_distance = affine_step(-1., 0., circle_fill_distance.distance / circle_fill_distance.width) - 1.;
    float line_border_distance = affine_step(0., circle_border_distance.width, circle_border_distance.distance);
    return lookalike(v_vec2_line_type_arrow_tail.x, g_type_arrow)
        ? arrow_color(v_vec4_texcoord_arrow_line.xy, arrow_parameters, line_fill_distance, line_border_distance, wing_normal)
        : line_color(line_fill_distance, line_border_distance, line_width, line_border, tail_radius);
}
void main()
{
    vec4 color = arrow_line_color();
    gl_FragColor = apply_fog(color);
}
`,Wf=`#include <highp_float>
#include <prelude>
varying vec2 v_vec2_line_type_arrow_tail;
varying vec4 v_vec4_distance_vertex_hiding;
varying vec4 v_vec4_identifier;
const float g_type_arrow = 1.;
bool lookalike(const float a, const float b)
{
    return abs(a - b) < 1e-5;
}
void main()
{
    if (lookalike(min(v_vec4_distance_vertex_hiding.y, 1.), 1.)
        || lookalike(v_vec4_distance_vertex_hiding.w, 1.)
        || !lookalike(v_vec2_line_type_arrow_tail.x, g_type_arrow) && (v_vec4_distance_vertex_hiding.x < v_vec4_distance_vertex_hiding.y || v_vec4_distance_vertex_hiding.x > v_vec4_distance_vertex_hiding.z))
    {
        discard;
    }
    gl_FragColor = v_vec4_identifier;
}
`,$f=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying vec2 v_vec2_circle;
varying float v_float_width;
void main() {
    float center_distance = dot(v_vec2_circle, v_vec2_circle);
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * affine_step(1.0, 1.0 - 4.0 / v_float_width, center_distance) * light;
    gl_FragColor = apply_fog_alpha(color);
}
`,Xf=`#include <lowp_float>
#include <prelude>
#include <fog>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = apply_fog(v_vec4_color);
}
`,Kf=`#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
void main()
{
    gl_FragColor = v_vec4_identifier;
}
`,qf=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying vec4 v_vec4_rotated_scaled_vertex;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    vec4 light = light_factor(normal);
    vec4 color = v_vec4_color * light;
    gl_FragColor = apply_fog(color);
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,Yf=`#ifdef COPY_DEPTH
#include <require_frag_depth>
#endif
#include <mediump_float>
#include <prelude>
#if defined(IS_DEPTH_TEXTURE) && defined(WEBGL2)
uniform mediump sampler2DShadow u_texture;
#else
uniform sampler2D u_texture;
#endif
#ifdef COPY_DEPTH
uniform sampler2D u_depth;
#endif
varying vec2 v_vec2_texcoord;
void main()
{
#if defined(IS_DEPTH_TEXTURE) && defined(WEBGL2)
    gl_FragColor = vec4(vec3(texture2D(u_texture, vec3(v_vec2_texcoord, 1.0))), 1.0);
#else
    gl_FragColor = texture2D(u_texture, v_vec2_texcoord);
#endif
#ifdef COPY_DEPTH
    float depthR = texture2D(u_depth, v_vec2_texcoord).r;
# ifdef WEBGL1
#  ifdef HAS_FRAG_DEPTH_EXT
     gl_FragDepthEXT = depthR;
#  else 
     discard;
#  endif 
# else 
     gl_FragDepth = depthR;
# endif 
#endif 
}
`,Qf=`#include <mediump_float>
#include <prelude>
varying float v_float_height;
void main()
{
  gl_FragColor = vec4(v_float_height, 0., 0., 1.);
}
`,Jf=`#include <mediump_float>
#include <prelude>
uniform sampler2D u_sr2d_texture;
varying vec2 v_vec2_texcoord;
void main()
{
  gl_FragColor = texture2D(u_sr2d_texture, v_vec2_texcoord);
}
`,Af=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = v_vec4_color;
}
`,em=`#include <mediump_float>
#include <prelude>
#include <dem>
varying vec4 v_vec4_coords;
void main()
{
    if (check_dem_invalid() != 0) {
discard;
}
    gl_FragColor = v_vec4_coords;
}
`,tm=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_coords;
void main()
{
    gl_FragColor = v_vec4_coords;
}
`,im=`#include <enable_standard_derivatives>
#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform sampler2D u_flat_tex;
uniform sampler2D u_hillshade_tex;
uniform sampler2D u_tex_hillshade_ramp;
uniform float u_float_dem_shading_intensity;
varying vec4 v_vec4_texcoord;
varying vec2 hs_tex_pos;
void main()
{
    
    if (v_vec4_texcoord.z > 0.) {
        discard;
    }
    vec4 vec4_texcoord = v_vec4_texcoord / v_vec4_texcoord.w;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
     
    if (vec4_texcoord.x < 0. || vec4_texcoord.x > 1. || vec4_texcoord.y < 0. || vec4_texcoord.y > 1.) {
        discard;
    } else {
        vec4 flatMapColor = texture2D(u_flat_tex, vec4_texcoord.xy);
        
        if (u_float_dem_shading_intensity > 0.) {
            
            vec3 normal = texture2D(u_hillshade_tex, hs_tex_pos).rgb * 2. - vec3(1.);
            
            float light_raw = light_factor_dem(normal);
            float dir1_intensity = u_vec4_light_dir1_color[3];
            float amb_intensity = u_vec4_ambient_color[3];
            float total_intensity = dir1_intensity + amb_intensity;
            
            
            float amb_intensity_shifted = u_vec4_ambient_color[3];
            float dir_intensity_shifted = dir1_intensity;
            
            float horizonatal_surface_light_dir_dot = light_factor_dem(vec3(0, 0, 1));
            float horizonatal_surface_light_intensity = amb_intensity + dir1_intensity * horizonatal_surface_light_dir_dot;
            if (u_float_dem_shading_intensity > 0.5) { 
                amb_intensity_shifted = mix(amb_intensity, 0., (u_float_dem_shading_intensity - 0.5) / 0.5);
                dir_intensity_shifted = (horizonatal_surface_light_intensity - amb_intensity_shifted) / horizonatal_surface_light_dir_dot;
            } else if (u_float_dem_shading_intensity < 0.5) { 
                dir_intensity_shifted = mix(0., dir1_intensity, u_float_dem_shading_intensity / 0.5);
                amb_intensity_shifted = horizonatal_surface_light_intensity - dir_intensity_shifted * horizonatal_surface_light_dir_dot;
            } 
            
            float tex_coord = clamp(dir_intensity_shifted * light_raw * 0.5 + 0.5, 0., 0.99);
            
            float dir_light_factor = 2. * (texture2D(u_tex_hillshade_ramp, vec2(tex_coord, 0.5)).a - 0.5);
            vec3 light_color = amb_intensity_shifted * u_vec4_ambient_color.rgb + dir_light_factor * u_vec4_light_dir1_color.rgb;
            
            gl_FragColor.rgb = light_color * flatMapColor.rgb;
            
            
            gl_FragColor.a = flatMapColor.a;
        } else {
            gl_FragColor = flatMapColor * light_factor_surface();
        }
        gl_FragColor = apply_fog(gl_FragColor);
    }
}
`,nm=`#include <enable_standard_derivatives>
#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <fragment_normal>
uniform sampler2D u_flat_tex;
uniform sampler2D u_hillshade_tex;
uniform sampler2D u_tex_hillshade_ramp;
uniform int u_int_identify;
uniform float u_float_dem_shading_intensity;
varying vec4 v_vec4_texcoord;
varying vec3 v_vec3_position;
void main() {
    vec4 vec4_texcoord = v_vec4_texcoord / v_vec4_texcoord.w;
    if(vec4_texcoord.x < 0. || vec4_texcoord.x > 1. || vec4_texcoord.y < 0. || vec4_texcoord.y > 1.) {
        discard;
    }
    vec4 flatMapColor = texture2D(u_flat_tex, vec4_texcoord.xy);
    if (u_int_identify == 1) {
        gl_FragColor = flatMapColor;
        return;
    }
    vec4 lf = light_factor_dem2(calc_fragment_normal(v_vec3_position), u_float_dem_shading_intensity);
    gl_FragColor = vec4(lf.rgb * flatMapColor.rgb, flatMapColor.a);
    gl_FragColor = apply_fog(gl_FragColor);
}
`,om=`#include <lowp_float>
#include <prelude>
uniform sampler2D u_tex_dem;
uniform float u_float_dem_resolution;
uniform float u_float_dem_cell_size;
uniform float u_float_dem_scale;
const float M_PI = 3.1415926535897932384626433832795;
varying vec2 v_vec2_texcoord;
mat3 get_kernel(vec2 pos, float step, float defval) {
    mat3 kernel;
    for (int x = 0; x < 3; x++) {
        vec3 col;
        for (int y = 0; y < 3; y++) {
            vec4 val = texture2D(u_tex_dem, vec2(pos.x + float(x - 1) * step, pos.y + float(y - 1) * step));
            col[y] = val.r;
            if (val.a < 1.) {
                col[y] = defval;
            }
        }
        kernel[x] = col;
    }
    return kernel;
}
float calc_aspect(mat3 kernel) {
    float dzdx = ((kernel[2].z + 2.0 * kernel[2].y + kernel[2].x) - (kernel[0].z + 2.0 * kernel[0].y + kernel[0].x)) / 8.;
    float dzdy = ((kernel[0].x + 2.0 * kernel[1].x + kernel[2].x) - (kernel[0].z + 2.0 * kernel[1].z + kernel[2].z)) / 8.;
    
    if (dzdx == 0. && dzdy == 0.) {
        return 0.;
    }
    
    return atan(-dzdx, dzdy);
}
float calc_slope(mat3 kernel, float cell_size) {
    float dzdx = ((kernel[2].z + 2. * kernel[2].y + kernel[2].x) - (kernel[0].z + 2. * kernel[0].y + kernel[0].x)) / (8. * cell_size);
    float dzdy = ((kernel[0].x + 2. * kernel[1].x + kernel[2].x) - (kernel[0].z + 2. * kernel[1].z + kernel[2].z)) / (8. * cell_size);
    float rise_run = sqrt(dzdx * dzdx + dzdy * dzdy);
    return atan(rise_run);
}
vec3 dem_normal(const vec2 tex_pos)
{
    
    float tex_step = 1. / u_float_dem_resolution;
    
    if (u_float_dem_scale == 0.) {
        return vec3(0.);
    }
    
    vec4 e = texture2D(u_tex_dem, tex_pos);
    if (e.a < 1.) {
        
        return vec3(0.);
    }
    mat3 kernel = get_kernel(tex_pos.xy, tex_step, e.r);
    
    float aspect = calc_aspect(kernel);
    
    
    float slope = calc_slope(kernel, u_float_dem_cell_size);
    
    slope = M_PI * 0.5 - slope; 
    aspect = aspect - M_PI * 0.5; 
    float cosSlope = cos(slope);
    vec3 normal = normalize(vec3(cosSlope * cos(aspect), -1. * cosSlope * sin(aspect), sin(slope)));
    
    return normal * 0.5 + vec3(0.5);
}
void main() {
    gl_FragColor = vec4(dem_normal(v_vec2_texcoord), 1);
}
`,sm=`#include <require_frag_depth>
#include <highp_float>
void main()
{
    
    
    
    #ifdef WEBGL1
    #ifdef HAS_FRAG_DEPTH_EXT
    gl_FragDepthEXT = 1.0;
    #else 
    discard;
    #endif 
    #else 
    gl_FragDepth = 1.0;
    #endif 
}
`,am=`#include <mediump_float>
#include <prelude>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform sampler2D u_texture;
varying vec2 v_vec2_texcoord;
#ifndef FXAA_REDUCE_MIN
    #define FXAA_REDUCE_MIN   (1.0/ 128.0)
#endif
#ifndef FXAA_REDUCE_MUL
    #define FXAA_REDUCE_MUL   (1.0 / 8.0)
#endif
#ifndef FXAA_SPAN_MAX
    #define FXAA_SPAN_MAX     8.0
#endif
void texcoords(vec2 fragCoord, vec2 resolution,
            out vec2 v_rgbNW, out vec2 v_rgbNE,
            out vec2 v_rgbSW, out vec2 v_rgbSE,
            out vec2 v_rgbM) {
    vec2 inverseVP = 1.0 / resolution.xy;
    v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
    v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
    v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
    v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
    v_rgbM = vec2(fragCoord * inverseVP);
}
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 resolution,
            vec2 v_rgbNW, vec2 v_rgbNE,
            vec2 v_rgbSW, vec2 v_rgbSE,
            vec2 v_rgbM) {
    vec4 color;
    mediump vec2 inverseVP = vec2(1.0 / resolution.x, 1.0 / resolution.y);
    vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
    vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
    vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
    vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
    vec4 texColor = texture2D(tex, v_rgbM);
    vec3 rgbM  = texColor.xyz;
    vec3 luma = vec3(0.299, 0.587, 0.114);
    float lumaNW = dot(rgbNW, luma);
    float lumaNE = dot(rgbNE, luma);
    float lumaSW = dot(rgbSW, luma);
    float lumaSE = dot(rgbSE, luma);
    float lumaM  = dot(rgbM,  luma);
    float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
    float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
    mediump vec2 dir;
    dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
    dir.y =  ((lumaNW + lumaSW) - (lumaNE + lumaSE));
    float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
                          (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
    float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
    dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
              max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
              dir * rcpDirMin)) * inverseVP;
    vec3 rgbA = 0.5 * (
        texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
        texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
    vec3 rgbB = rgbA * 0.5 + 0.25 * (
        texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
        texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
    float lumaB = dot(rgbB, luma);
    if ((lumaB < lumaMin) || (lumaB > lumaMax))
        color = vec4(rgbA, texColor.a);
    else
        color = vec4(rgbB, texColor.a);
    return color;
}
void main()
{
    mediump vec2 v_rgbNW;
    mediump vec2 v_rgbNE;
    mediump vec2 v_rgbSW;
    mediump vec2 v_rgbSE;
    mediump vec2 v_rgbM;
    vec2 fragCoord = v_vec2_texcoord * u_vec2_vpt_size;
    texcoords(fragCoord, u_vec2_vpt_size, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
    gl_FragColor = fxaa(u_texture, fragCoord, u_vec2_vpt_size, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
}
`,rm=`#include <mediump_float>
#include <prelude>
uniform sampler2D u_sr2d_flatmap_texture;
varying vec2 v_vec2_texture;
void main() {
    gl_FragColor = texture2D(u_sr2d_flatmap_texture, v_vec2_texture);
}
`,lm=`#include <mediump_float>
#include <prelude>
#ifndef UBO
uniform mediump vec4 u_vec4_halo_color;
uniform mediump vec2 u_vec2_halo_viewport_size;
uniform mediump vec2 u_vec2_halo_viewport_center_shift;
uniform mediump vec4 u_vec4_halo_radius_stops;
uniform mediump float u_float_halo_exp_factor;
#endif
varying vec2 v_vec2_uv;
void main() {
    float dist = length(v_vec2_uv);
    float halo_alpha = u_vec4_halo_color.a;
    vec4 halo_color = vec4(u_vec4_halo_color.rgb, 0.);
    vec4 empty_color = vec4(0.0);
    vec4 white_color1 = vec4(1., 1., 1., halo_alpha);
    vec4 white_color2 = vec4(white_color1.rgb, halo_alpha * 0.9);
    float r0 = u_vec4_halo_radius_stops[0];
    float r1 = u_vec4_halo_radius_stops[1];
    float r2 = u_vec4_halo_radius_stops[2];
    float r3 = u_vec4_halo_radius_stops[3];
    float t0 = max(0.0, (dist - r1) / (r3 - r1));
    float t0e = 1.0 - exp(u_float_halo_exp_factor * t0);
    
    vec4 color = mix(white_color2, halo_color, t0e);
    
    color = mix(white_color1, color, smoothstep(r1, r2, dist));
    
    color = mix(empty_color, color, smoothstep(r0, r1, dist));
    gl_FragColor = color;
}
`,cm=`#include <mediump_float>
#include <prelude>
#ifndef UBO
uniform mediump vec4 u_vec4_default_background_color;
uniform mediump vec4 u_vec4_halo_radius_stops;
#endif
varying vec2 v_vec2_uv;
void main() {
    float dist = length(v_vec2_uv);
    float r1 = u_vec4_halo_radius_stops[1];
    if(dist > r1) {
        discard;
    }
    gl_FragColor = u_vec4_default_background_color;
}
`,dm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <light_pbr>
#include <light_phong>
#include <dem>
uniform vec4 u_vec4_color;
#ifdef MAP_MESH_TEXTURE
uniform sampler2D u_sampler_map_tex;
#endif
#ifdef COLOR_TEXTURE
uniform sampler2D u_sr2d_texture_0;
#endif
#ifdef AO_TEXTURE
uniform sampler2D u_ao_texture;
#endif
#ifdef PBR_TEXTURE
uniform sampler2D u_pbr_texture;
#endif
#ifdef LIGHT_MODEL
#if  (LIGHT_MODEL == LIGHT_MODEL_PBR || LIGHT_MODEL == LIGHT_MODEL_PHONG)
uniform float u_float_metallic;
uniform float u_float_roughness;
#endif
#endif
varying vec3 v_vec3_normal;
varying vec3 v_vec3_fragment_pos_world;
#ifdef MAP_MESH_TEXTURE
uniform vec2 u_vec2_tex_scale;
uniform float u_float_tex_shift_scale;
varying vec4 v_tex_coord;
#endif
#ifdef COLOR_TEXTURE
varying vec2 v_vec2_texcoord_color;
#endif
#ifdef AO_TEXTURE
varying vec2 v_vec2_texcoord_ao;
#endif
#ifdef PBR_TEXTURE
varying vec2 v_vec2_texcoord_pbr;
#endif
varying float v_float_opacity;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = u_vec4_color;
    #ifdef COLOR_TEXTURE
        color *= texture2D(u_sr2d_texture_0, v_vec2_texcoord_color);
    #endif
    #ifdef MAP_MESH_TEXTURE
        
        vec2 coord = v_tex_coord.xy / v_tex_coord.w;
        
        coord = coord / u_vec2_tex_scale;
        
        coord.y += u_float_tex_shift_scale / u_vec2_tex_scale.y;
        
        coord = (coord / 2.) + vec2(0.5, 0.5);
        vec4 texture_color = texture2D(u_sampler_map_tex, coord);
        
        color.rgb = mix(color.rgb, texture_color.rgb, texture_color.a);
    #endif
    #ifdef AO_TEXTURE
        
        
        vec4 ao_tex_color = texture2D(u_ao_texture, v_vec2_texcoord_ao);
        color *= ao_tex_color;
    #endif
    vec3 fragment_normal = normalize(v_vec3_normal);
    color *= v_float_opacity;
    bool use_light = UNPACK_BOOL1(u_int_light_flags);
    if (!use_light) {
        gl_FragColor = apply_fog(color);
        return;
    }
    #ifdef LIGHT_MODEL
        float metallic = max(u_float_metallic, 0.1);
        float roughness = max(u_float_roughness, 0.1);
        #ifndef METALLIC_ROUGHNESS_DEBUG
            #ifdef PBR_TEXTURE
                vec4 pbr_tex_color = texture2D(u_pbr_texture, v_vec2_texcoord_pbr);
                roughness = max(pbr_tex_color.g, 0.1);
                metallic = max(pbr_tex_color.b, 0.1);
            #endif
        #endif
        #if (LIGHT_MODEL == LIGHT_MODEL_PBR)
            color.rgb = color_pbr(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic);
        #elif (LIGHT_MODEL == LIGHT_MODEL_PHONG)
            color.rgb = color_phong(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic);
        #endif
    #endif
    gl_FragColor = apply_fog(color);
}
`,_m=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying mat4 v_mat4_gradient;
varying vec4 v_vec4_color;
varying vec4 v_vec4_rotated_scaled_vertex;
uniform vec2 u_vec2_floor_level;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = v_vec4_color;
    if (v_mat4_gradient[0][0] != 0.) {
        float height_gradient = v_vec4_rotated_scaled_vertex.w;
        float gradient_position = (float(u_vec2_floor_level.x) + height_gradient) / float(u_vec2_floor_level.y);
        color = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], gradient_position));
    }
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    color *= light_factor(normal);
    gl_FragColor = apply_fog(color);
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,um=`#include <mediump_float>
#include <prelude>
#include <fog>
uniform highp float u_float_intensity;
varying float v_float_weight;
varying vec2 v_vec2_extrude;
#define GAUSS_COEF 0.3989422804014327
void main() {
    float d = -0.5 * 3.0 * 3.0 * dot(v_vec2_extrude, v_vec2_extrude);
    float val = v_float_weight * u_float_intensity * GAUSS_COEF * exp(d);
    float fog_alpha = apply_fog_alpha(vec4(1)).r;
    gl_FragColor = vec4(val, fog_alpha, 1.0, 1.0);
}
`,hm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
uniform sampler2D u_sr2d_texture;
uniform sampler2D u_sr2d_ramp_texture;
uniform float u_float_opacity;
varying vec2 v_vec2_position;
void main() {
    vec2 color_and_alpha = texture2D(u_sr2d_texture, v_vec2_position).rg;
    vec4 color = texture2D(u_sr2d_ramp_texture, vec2(color_and_alpha.r, 0.5));
    gl_FragColor = color * u_float_opacity;
    
    
    #ifdef FOG
        gl_FragColor *= color_and_alpha.g;
    #endif
}
`,fm=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <dem>
uniform mediump int u_int_identify;
varying vec4 v_vec4_identifier;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    if (u_int_identify != 0) {
        gl_FragColor = v_vec4_identifier;
    } else {
        gl_FragColor = vec4(0., 0., 0., 0.);
    }
}
`,mm=`#include <mediump_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform float u_float_buffer;
uniform float u_float_gamma;
uniform vec4 u_vec4_color;
uniform vec4 u_vec4_hidden_color;
uniform float u_float_opacity;
uniform sampler2D u_color_text_sprite_labeling;
uniform float u_float_label_index;
varying vec2 v_vec2_texcoord;
varying float v_float_behind_factor;
varying vec4 v_vec4_text_identifier;
varying vec2 v_vec2_labeling_texcoord;
const float F16_EPSILON = 0.0009765625;
void main() {
    if (check_dem_invalid() != 0) {
discard;
}
    float dist = texture2D(u_sr2d_texture, v_vec2_texcoord).a;
    float alpha = smoothstep(
        u_float_buffer - u_float_gamma,
        u_float_buffer + u_float_gamma,
        dist
    );
    vec4 color = mix(u_vec4_hidden_color, u_vec4_color, v_float_behind_factor);
    color = apply_fog_alpha(color);
    vec4 clearColor = vec4(1, 1, 1, 1);
    vec4 text_sprite_color = texture2D(u_color_text_sprite_labeling, v_vec2_labeling_texcoord);
    bvec4 clearColorDiff = bvec4(
        abs(text_sprite_color.r - clearColor.r) > F16_EPSILON,
        abs(text_sprite_color.g - clearColor.g) > F16_EPSILON,
        abs(text_sprite_color.b - clearColor.b) > F16_EPSILON,
        abs(text_sprite_color.a - clearColor.a) > F16_EPSILON
    );
    bvec4 identifierDiff = bvec4(
        abs(text_sprite_color.r - v_vec4_text_identifier.r) > F16_EPSILON,
        abs(text_sprite_color.g - v_vec4_text_identifier.g) > F16_EPSILON,
        abs(text_sprite_color.b - v_vec4_text_identifier.b) > F16_EPSILON,
        abs(text_sprite_color.a - v_vec4_text_identifier.a) > F16_EPSILON
    );
    if (u_float_label_index < F16_EPSILON && any(identifierDiff)  && any(clearColorDiff) ) {
        discard;
    }
    gl_FragColor = apply_opacity(color * alpha, u_float_opacity);
}
`,pm=`#include <highp_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
uniform sampler2D u_sr2d_texture;
uniform float u_float_buffer;
uniform float u_float_gamma;
uniform vec4 u_vec4_color;
uniform float u_float_opacity;
varying vec2 v_vec2_texcoord;
void main() {
    float dist = texture2D(u_sr2d_texture, v_vec2_texcoord).a;
    float alpha = smoothstep(
        u_float_buffer - u_float_gamma,
        u_float_buffer + u_float_gamma,
        dist
    );
    vec4 color = apply_fog_alpha(u_vec4_color);
    gl_FragColor = apply_opacity(color * alpha, u_float_opacity);
}
`,vm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec3 v_vec3_normal;
varying vec2 v_vec2_height_gradient;
uniform mat4 u_mat4_gradient;
void main()
{ 
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = v_vec4_color;
    if (u_mat4_gradient[0][0] != 0.) {
        color = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], v_vec2_height_gradient[0]));
    }
    color *= (1. - abs(v_vec2_height_gradient[1] * gl_FragCoord.w));
    gl_FragColor = apply_fog(color * light_factor(v_vec3_normal));
}
`,gm=`#include <highp_float>
#include <prelude>
#include <pack_depth>
#include <dem>
varying float v_depth_metric;
void main()
{
if (check_dem_invalid() != 0) {
discard;
}
#ifdef DEPTH_TEXTURE_SHADOW
return;
#endif
gl_FragColor = pack_float_to_vec4(v_depth_metric);
}`,ym=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform sampler2D u_sampler_map_tex;
uniform vec2 u_vec2_tex_scale;
uniform float u_float_tex_shift_scale;
uniform mediump float u_float_light_intensity;
uniform int u_int_identify;
varying vec4 v_tex_coord;
varying vec4 v_vec4_normal_gradient;
void main()
{
if (check_dem_invalid() != 0) {
        discard;
    }
vec2 coord = v_tex_coord.xy / v_tex_coord.w;
coord = coord / u_vec2_tex_scale;
coord.y += u_float_tex_shift_scale / u_vec2_tex_scale.y;
coord = (coord / 2.) + vec2(0.5, 0.5);
if (coord.x < 0. || coord.x > 1. || coord.y < 0. || coord.y > 1.) {
gl_FragColor = vec4(0, 0, 0, 0);
} else {
gl_FragColor = texture2D(u_sampler_map_tex, coord);
if (u_int_identify == 0) {
apply_screendoor();
gl_FragColor.rgb *= 1. - u_float_light_intensity * smoothstep(0.85, 1., abs(v_vec4_normal_gradient.w));
gl_FragColor *= light_factor(v_vec4_normal_gradient.xyz);
gl_FragColor = apply_fog(gl_FragColor);
}
}
}
`,xm=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <screendoor_transparency>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform float u_float_texture_opacity;
uniform vec4 u_float_sprite_texture_coords;
uniform lowp int u_int_is_textured;
uniform mediump vec4 u_vec4_color;
uniform mediump mat4 u_mat4_gradient;
uniform mediump float u_float_opacity;
uniform mediump int u_int_identify;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec2 v_vec2_tex_coord;
varying vec4 v_vec4_normal_gradient;
varying vec4 v_vec4_identifier;
void main()
{   
    if (check_dem_invalid() != 0) {
        discard;
    }
    if (u_int_identify != 0) {
        gl_FragColor = v_vec4_identifier;
    } else {
        apply_screendoor();
        vec4 light = light_factor(v_vec4_normal_gradient.xyz);
        if (u_int_is_textured != 0)  {
            vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, fract(v_vec2_tex_coord));
            vec4 color = texture2D(u_sr2d_texture, spritecoord);
            vec4 texcolor = apply_opacity(color, u_float_texture_opacity);
            gl_FragColor = texcolor + v_vec4_color * (1. - texcolor.a);
        } else if (u_mat4_gradient[0][0] != 0.) {
    gl_FragColor = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], v_vec4_normal_gradient.w));
        } else {
            gl_FragColor = v_vec4_color;
        }
        gl_FragColor = apply_fog(gl_FragColor * light);
    }
}
`,bm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
uniform sampler2D u_sr2d_texture;
uniform vec4 u_float_sprite_texture_coords;
varying vec2 v_vec2_texcoord;
void main()
{
    vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, v_vec2_texcoord);
    vec4 color = texture2D(u_sr2d_texture, spritecoord) * u_vec4_color;
    gl_FragColor = apply_fog(color * light_factor_surface());
}
`,wm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <affine_step>
#include <apply_opacity>
#include <signed_distance_functions>
#include <arrow_functions>
#include <fog>
#ifndef UBO
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_wing_normal;
uniform vec2 u_vec2_tip_normal;
uniform mediump float u_float_width;
uniform mediump float u_float_length;
uniform float u_float_tip_height_multiplier;
uniform float u_float_wing_height_multiplier;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_texcoord;
varying float v_float_border_width;
varying float v_float_zpt_to_texcoord_factor;
varying float v_float_outer_width;
varying float v_float_opacity;
float one_way_line_distance(const ArrowDistances ad)
{
    return max(max(max(ad.top_tip_cut, ad.bottom_tip_cut), max(ad.top_left_wing, ad.top_right_wing)), min(ad.line, min(ad.bottom_left_wing, ad.bottom_right_wing)));
}
void main()
{
    mat2 derivatives = mat2(dFdx(v_vec2_texcoord), dFdy(v_vec2_texcoord));
    ArrowDistanceParameters arrow_parameters = calculate_arrow_distance_parameters(
        u_vec2_wing_normal,
        u_vec2_tip_normal,
        u_float_width * v_float_zpt_to_texcoord_factor,
        u_float_length * v_float_zpt_to_texcoord_factor,
        u_float_tip_height_multiplier,
        u_float_wing_height_multiplier,
        0.,
        0.,
        0.,
        vec2(0., 0.),
        vec2(0., 0.));
    
    float border_clipping = (abs(v_vec2_texcoord.y) - v_float_outer_width) / max(abs(derivatives[0].y), abs(derivatives[1].y));
    float fill_factor = affine_step(-1., 0., one_way_line_distance(calculate_arrow_distances(arrow_parameters, v_vec2_texcoord, 0., derivatives)));
    float border_factor = max(border_clipping, affine_step(0., 1., one_way_line_distance(calculate_arrow_distances(arrow_parameters, v_vec2_texcoord, v_float_border_width, derivatives))));
    gl_FragColor = apply_opacity(mix(mix(v_vec4_color, v_vec4_border_color, fill_factor), vec4(0.), border_factor), v_float_opacity);
}
`,Sm=`#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <signed_distance_functions>
uniform int u_int_pattern_type;
varying vec4 v_vec4_color;
varying vec2 v_vec2_uv;
varying float v_float_width;
varying vec4 v_vec4_pattern_parameters;
void main()
{
    float pattern_length = v_vec4_pattern_parameters.x;
    float full_width = v_float_width + 1.;
    
    float smooth_base = max(15., max(v_float_width, pattern_length));
    float smooth_scale = (smooth_base + 1.) / smooth_base;
    float smooth_factor = smooth_scale - 1.;
    
    vec2 sdf_pos = vec2(mod(v_vec2_uv.x, 1.) - 0.5, v_vec2_uv.y * smooth_scale);
float sdf = 1.;
    
    if (u_int_pattern_type < 4) {
        
        float width = v_vec4_pattern_parameters.y;
        float left  = v_vec4_pattern_parameters.z;
        float right = v_vec4_pattern_parameters.w;
        
        
        vec2 offset;
        if (right < 0.) {
            offset = vec2(.25, .5);
        } else {
            offset = vec2(.0, .5);
        }
        
        if (width > EPSILON) {
            float leftSdf = 1.;
            if (left > EPSILON) {
                leftSdf = sdf_box(sdf_pos + offset, vec2(left, width));
            }
            float rightSdf = 1.;
            if (abs(right) > EPSILON) {
                rightSdf = sdf_box(sdf_pos - offset, vec2(abs(right), width));
            }
            sdf = min(leftSdf, rightSdf);
        }
    } else if (u_int_pattern_type == 5) {
        
        float radius = v_vec4_pattern_parameters.y;
        
        if (radius > EPSILON) {
            sdf = sdf_circle(sdf_pos, radius);
        }
    } else if (u_int_pattern_type == 4) {
        
        float width = v_vec4_pattern_parameters.y;
        float orientation = v_vec4_pattern_parameters.z;
        
        if (width > EPSILON) {
            sdf = sdf_triangle(sdf_pos * vec2(1., orientation), width);
        }
    } else if (u_int_pattern_type == 6) {
        
        sdf = sdf_chevron(sdf_pos.yx, 0., 0., 0.);
    }
    
    sdf = max(sdf, abs(sdf_pos.y) - 0.5);
    
    vec4 color = mix(
        v_vec4_color,
        vec4(0.),
        affine_step(-smooth_factor, smooth_factor, sdf)
    );
    color *= light_factor_surface();
    gl_FragColor = apply_fog(color);
}
`,Tm=`#include <mediump_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform vec2 u_vec2_opacity;
varying vec2 v_vec2_texcoord;
varying float v_float_behind_factor;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord);
    float opacity = mix(u_vec2_opacity[1], u_vec2_opacity[0], v_float_behind_factor);
    color = apply_fog_alpha(color);
    gl_FragColor = apply_opacity(color, opacity);
}
`,Mm=`#include <mediump_float>
#include <prelude>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform float u_float_identify_opacity;
varying vec2 v_vec2_texcoord;
varying vec4 v_vec4_identifier;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord);
    
    
    if (color.a < u_float_identify_opacity) {
        discard;
    } else {
        gl_FragColor = v_vec4_identifier;
    }
}
`,Em=`#include <mediump_float>
#include <prelude>
#include <apply_opacity>
#include <fog>
uniform sampler2D u_sr2d_texture;
uniform float u_float_opacity;
varying vec2 v_vec2_texcoord;
void main()
{
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord);
    color = apply_fog_alpha(color);
    gl_FragColor = apply_opacity(color, u_float_opacity);
}
`,Im=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
void main()
{
    
    float opacity = 1.0 - affine_step(
        v_float_half_width - length(fwidth(v_vec2_normal)),
        v_float_half_width,
        length(v_vec2_normal)
    );
    vec4 color = light_factor_surface() * u_vec4_color;
    color = apply_fog(color);
    gl_FragColor = color * opacity;
}
`,Cm=`#include <enable_standard_derivatives>
#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
void main()
{
    if (dot(v_vec2_normal, v_vec2_normal) > v_float_half_width * v_float_half_width) {
        discard;
    }
    gl_FragColor = v_vec4_identifier;
}
`,Lm=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
void main()
{
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,Pm=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform vec4 u_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,Bm=`#include <highp_float>
#include <prelude>
#include <enable_standard_derivatives>
varying vec3 v_position;
void main() {
    vec3 dx = dFdx(v_position);
    vec3 dy = dFdy(v_position);
    vec3 normal = normalize(cross(dx, dy));
    vec3 lightDir = normalize(vec3(1.0, 1.0, 1.0));
    float diffuse = max(dot(normal, lightDir), 0.0);
    
    gl_FragColor = vec4(normal * (0.2 + 0.8 * diffuse), 1.0);
}
`,zm=`#include <mediump_float>
#include <prelude>
#include <fog>
#define SKY_ALPHA_HORIZON_BLEND (6.0)
#define DEFAULT_SKY_COLOR (vec4(0.0))
vec4 add_sky_alpha_blend(vec4 color) {
#ifdef SKY
    
    float depth = length(v_fog_pos);
    vec3 dir = v_fog_pos / depth;
    float alpha_dir = dir.z + u_fog_horizon_pad; 
    float alpha = clamp(1.0 + SKY_ALPHA_HORIZON_BLEND * alpha_dir, 0.0, 1.0);
    color *= alpha;
#endif
    return color;
}
void main() {
#ifdef SKY
    vec4 color = add_sky_alpha_blend(u_sky_color);
#else
    vec4 color = DEFAULT_SKY_COLOR;
#endif
    gl_FragColor = apply_fog_sky(color);
}
`,Rm=`#include <mediump_float>
#include <prelude>
varying mediump float v_intensity;
void main() {
    gl_FragColor = vec4(v_intensity);
}
`,Fm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <affine_step>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform int u_int_gap_turns_only;
varying vec4 v_vec4_dash_color;
varying vec4 v_vec4_space_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_circle;
varying float v_float_width;
varying vec2 v_vec2_line_params;
vec4 distance_func_smooth(in vec4 main_color, in vec4 border_color, in vec2 circle)
{
    float circle_length = length(circle);
    float distance = circle_length - v_float_width;
    mat2 derivatives = mat2(dFdx(v_vec2_circle), dFdy(v_vec2_circle));
    
    
    
    vec2 circle_dx = derivatives[0];
    vec2 circle_dy = derivatives[1];
    
    float distance_dx = dot(v_vec2_circle, circle_dx);
    float distance_dy = dot(v_vec2_circle, circle_dy);
    
    float derivative_denominator = circle_length;
    float width = max(abs(distance_dx), abs(distance_dy));
    vec4 from_main_to_border = mix(
        main_color,
        border_color,
        affine_step(-width, 0., distance * derivative_denominator));
    vec4 from_color_to_fade = mix(
        from_main_to_border,
        vec4(0.),
        affine_step(0., +width, distance * derivative_denominator));
    return from_color_to_fade;
}
float calculate_segment_color_factor(in float distance_in_parts, in float threshold)
{
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    float color_factor = abs(fract(distance_in_parts + 0.5 - 0.5 * threshold) - 0.5);
    
    float parts_affine_step_width = fwidth(distance_in_parts);
    
    
    if (u_int_gap_turns_only == 1 && parts_affine_step_width < threshold * 0.0001) {
        return 1.0;
    }
    
    float smoothed_color_factor = affine_step(
        0.5 * threshold - 0.5 * parts_affine_step_width,
        0.5 * threshold + 0.5 * parts_affine_step_width,
        color_factor);
    return smoothed_color_factor;
}
void main()
{
    vec4 current_segment_color = mix(
        v_vec4_dash_color,
        v_vec4_space_color,
        calculate_segment_color_factor(
            v_vec2_line_params[1],
            v_vec2_line_params[0]));
    
    vec4 final_border_color = (1.0 - v_vec4_border_color.a) * current_segment_color + v_vec4_border_color;
    vec4 color = distance_func_smooth(current_segment_color, final_border_color, v_vec2_circle);
    vec4 light = light_factor_surface();
    gl_FragColor = apply_fog(light * color);
}
`,Dm=`#include <mediump_float>
#include <prelude>
uniform sampler2D u_texture;
uniform float u_float_mix_coef;
varying vec2 v_vec2_texcoord;
void main()
{
    vec4 texColor = texture2D(u_texture, v_vec2_texcoord);
    gl_FragColor = vec4(texColor.rgb, texColor.a * u_float_mix_coef);
}
`,Om=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#define LIGHT_MODEL LIGHT_MODEL_PHONG
#include <light_phong>
#include <mix_color_defs>
uniform sampler2D u_sr2d_texture;
uniform float u_float_texture_opacity;
uniform vec4 u_float_texture_params;
uniform vec4 u_float_sprite_texture_coords;
uniform int u_int_is_textured;
uniform int u_int_is_normal_map_textured; 
uniform sampler2D u_sr2d_texture1;
uniform vec4 u_vec4_normal_map_texture_params;
uniform vec4 u_vec4_normal_map_sprite_texture_coords;
uniform vec4 u_vec4_normal_map_animated_offsets;
uniform int u_int_normal_map_is_animated;
uniform float u_float_metallic;
uniform float u_float_roughness;
varying vec4 v_vec4_color;
varying highp vec2 v_vec2_texcoord;
varying highp vec3 v_vec3_fragment_pos_world;
uniform int u_int_factor_use_interpolate;
uniform float u_float_factor_interpolate_base;
uniform vec4 u_vec4_factor_interpolate_ranges;
#ifdef MIX_COLOR_MODE
varying vec4 v_vec4_color2;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
varying vec4 v_vec4_pos;
uniform sampler2D u_sr2d_read_from_target_texture;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
varying float v_float_mix_color_factor;
# endif
#endif
float interpolate(float x, float base, vec4 ranges) {
    float inMin = ranges.x;
    float outMin = ranges.y;
    float inMax = ranges.z;
    float outMax = ranges.w;
    float t = clamp(outMin + (outMax - outMin) * ((x - inMin) / (inMax - inMin)), outMin, outMax);
    return base == 1. ? t : (pow(base, t) - 1.) / (base - 1.);
}
void main() {
#ifdef MIX_COLOR_MODE
    float mix_color_factor = 0.;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    vec3 clip_space = v_vec4_pos.xyz / v_vec4_pos.w;
    vec3 uv = 0.5 * clip_space + vec3(0.5);
    
    
    
    mix_color_factor = texture2D(u_sr2d_read_from_target_texture, uv.xy).r;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
    mix_color_factor = v_float_mix_color_factor;
# endif
#endif
    bool use_normal_map = u_int_is_normal_map_textured == 1;
    vec3 normal;
    
    if(use_normal_map) {
        vec2 texcoord1 = fract(v_vec2_texcoord * u_vec4_normal_map_texture_params.zw + u_vec4_normal_map_texture_params.xy + u_vec4_normal_map_animated_offsets.xy);
        vec2 spritecoord1 = mix(u_vec4_normal_map_sprite_texture_coords.xy, u_vec4_normal_map_sprite_texture_coords.zw, texcoord1);
        vec4 texcolor1 = texture2D(u_sr2d_texture1, spritecoord1);
        
        if(u_int_normal_map_is_animated == 1) {
            vec2 texcoord2 = fract(v_vec2_texcoord * u_vec4_normal_map_texture_params.zw + u_vec4_normal_map_texture_params.xy + u_vec4_normal_map_animated_offsets.zw);
            vec2 spritecoord2 = mix(u_vec4_normal_map_sprite_texture_coords.xy, u_vec4_normal_map_sprite_texture_coords.zw, texcoord2);
            vec4 texcolor2 = texture2D(u_sr2d_texture1, spritecoord2);
            normal = normalize((texcolor1.xyz * 2.0 - 1.0) + (texcolor2.xyz * 2.0 - 1.0));
        } else {
            normal = normalize((texcolor1.xyz * 2.0 - 1.0));
        }
    }
    
    vec4 color = v_vec4_color;
    
    if(u_int_is_textured == 1) {
        vec2 texcoord = fract(v_vec2_texcoord * u_float_texture_params.zw + u_float_texture_params.xy);
        vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, texcoord);
        vec4 texcolor = apply_opacity(texture2D(u_sr2d_texture, spritecoord), u_float_texture_opacity);
        color = texcolor + color * (1. - texcolor.a);
    }
#ifdef MIX_COLOR_MODE
    
    if(u_int_factor_use_interpolate == 1) {
        mix_color_factor = interpolate(mix_color_factor, u_float_factor_interpolate_base, u_vec4_factor_interpolate_ranges);
    }
    
    color = mix(color, v_vec4_color2, mix_color_factor);
#endif
    
    if(use_normal_map) {
        color.rgb = color_phong(normal, v_vec3_fragment_pos_world, color.rgb, u_float_roughness, u_float_metallic);
    } else {
        color = color * light_factor_surface();
    }
    gl_FragColor = apply_fog(color);
}
`,Nm=`#include <lowp_float>
#include <prelude>
uniform vec4 u_vec4_color;
void main()
{
    gl_FragColor = u_vec4_color;
}
`,km=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
#ifdef WEBGL1
float round(float x) {
    return floor(x + 0.5);
}
#endif
uniform sampler2D u_sr2d_texture;
uniform vec4 u_vec4_wall_padding_su; 
uniform vec4 u_vec4_texture_padding_un; 
uniform vec2 u_vec2_texture_part_count;
uniform vec2 u_vec2_max_interval_su;
uniform vec2 u_vec2_texture_slice_size_su; 
uniform ivec2 u_ivec2_layout_mode;
varying vec4 v_vec4_rotated_scaled_vertex;
varying vec2 v_vec2_quad_fraction;
varying vec2 v_vec2_wall_size_su;
#define VL_REPEAT_WITH_STRETCH 1
#define VL_STRETCH 2
#define VL_REPEAT_WITH_MAX_INTERVAL 3
#define HL_REPEAT_WITH_STRETCH 1
#define HL_STRETCH 2
#define HL_REPEAT_WITH_MAX_INTERVAL 3
bool layout_mode_stretch(float curr_point_su, float wall_size_su, out float out_tc)
{
    out_tc = curr_point_su / wall_size_su;
    return true;
}
bool layout_mode_repeat_with_stretch(float curr_point_su, float wall_size_su, float slice_size_su, float slice_count, out float out_tc, out float out_final_slice_size_su)
{
    float raw_slice_repeats = wall_size_su / slice_size_su;
    float repeated_slice_count = round(raw_slice_repeats * slice_count);
    float rounded_image_repeats = repeated_slice_count / slice_count;
    
    out_final_slice_size_su = slice_size_su * (repeated_slice_count / raw_slice_repeats);
    
    int leftover_part_count = int(mod(repeated_slice_count, slice_count));
    float start_image_tc = (slice_count - float((leftover_part_count + 1) / 2)) / slice_count;
    out_tc = mix(start_image_tc, start_image_tc + rounded_image_repeats, curr_point_su / wall_size_su);
    return true;
}
bool layout_mode_repeat_with_max_interval(float curr_point_su, float wall_size_su, float slice_size_su, float max_interval_size_su, out float out_tc)
{
    float raw_block_repeats = (wall_size_su - slice_size_su) / (slice_size_su + max_interval_size_su);
    float interval_count = ceil(raw_block_repeats);
    float window_count = interval_count + 1.0;
    float interval_size_su = (wall_size_su - (window_count * slice_size_su)) / interval_count;
    
    
    if (raw_block_repeats < 1.0)
    {
        out_tc = (curr_point_su - (wall_size_su - slice_size_su) * 0.5) / slice_size_su;
        return out_tc >= 0.0 && out_tc <= 1.0;
    }
    
    if (curr_point_su < slice_size_su)
    {
        out_tc = curr_point_su / slice_size_su;
        return true;
    }
    float block_size_su = slice_size_su + interval_size_su;
    float block_coverege_un = (curr_point_su - slice_size_su) / block_size_su;
    block_coverege_un = fract(block_coverege_un);
    
    out_tc = (block_coverege_un * block_size_su - interval_size_su) / slice_size_su;
    return block_coverege_un * block_size_su >= interval_size_su;
}
bool layout_vertical(vec2 curr_point_su, float wall_size_su, out float out_tc_y, out float out_final_slice_size_su)
{
    if (u_ivec2_layout_mode.y == VL_STRETCH)
    {
        out_final_slice_size_su = wall_size_su;
        return layout_mode_stretch(
            curr_point_su.y,
            wall_size_su,
            out_tc_y
        );
    }
    else if (u_ivec2_layout_mode.y == VL_REPEAT_WITH_STRETCH)
    {
        return layout_mode_repeat_with_stretch(
            curr_point_su.y,
            wall_size_su,
            u_vec2_texture_slice_size_su.y,
            u_vec2_texture_part_count.y,
            out_tc_y,
            out_final_slice_size_su
        );
    }
    else if (u_ivec2_layout_mode.y == VL_REPEAT_WITH_MAX_INTERVAL)
    {
        out_final_slice_size_su = u_vec2_texture_slice_size_su.y;
        return layout_mode_repeat_with_max_interval(
            curr_point_su.y,
            wall_size_su,
            u_vec2_texture_slice_size_su.y,
            u_vec2_max_interval_su.y,
            out_tc_y
        );
    }
    return false;
}
bool layout_horizontal(vec2 curr_point_su, float wall_size_su, out float out_tc_x, out float out_final_slice_size_su)
{
    if (u_ivec2_layout_mode.x == HL_STRETCH)
    {
        out_final_slice_size_su = wall_size_su;
        return layout_mode_stretch(
            curr_point_su.x,
            wall_size_su,
            out_tc_x
        );
    }
    else if (u_ivec2_layout_mode.x == HL_REPEAT_WITH_STRETCH)
    {
        return layout_mode_repeat_with_stretch(
            curr_point_su.x,
            wall_size_su,
            u_vec2_texture_slice_size_su.x,
            u_vec2_texture_part_count.x,
            out_tc_x,
            out_final_slice_size_su
        );
    }
    else if (u_ivec2_layout_mode.x == HL_REPEAT_WITH_MAX_INTERVAL)
    {
        out_final_slice_size_su = u_vec2_texture_slice_size_su.x;
        return layout_mode_repeat_with_max_interval(
            curr_point_su.x,
            wall_size_su,
            u_vec2_texture_slice_size_su.x,
            u_vec2_max_interval_su.x,
            out_tc_x
        );
    }
    return false;
}
bool layout_internal_image(vec2 curr_point_su, vec2 wall_size_su, out vec2 out_tc, out vec2 out_final_slice_size_su)
{
    float x = 0.;
    float y = 0.;
    if (!layout_vertical(curr_point_su, wall_size_su.y, y, out_final_slice_size_su.y))
    {
        return false;
    }
    if (!layout_horizontal(curr_point_su, wall_size_su.x, x, out_final_slice_size_su.x))
    {
        return false;
    }
    out_tc = vec2(x, y);
    return true;
}
bool layout_image(out vec2 out_tc, out vec2 out_final_slice_size_su)
{
    
    
    
    
    
    
    
    
    vec2 curr_point_su = clamp(v_vec2_quad_fraction, vec2(0.0), vec2(1.0)) * v_vec2_wall_size_su;
    
    bvec4 is_in_padding_zone = bvec4(
        curr_point_su.x < u_vec4_wall_padding_su.x, 
        curr_point_su.y < u_vec4_wall_padding_su.y, 
        curr_point_su.x > (v_vec2_wall_size_su.x - u_vec4_wall_padding_su.z), 
        curr_point_su.y > (v_vec2_wall_size_su.y - u_vec4_wall_padding_su.w) 
    );
    if (any(is_in_padding_zone))
    {
        vec2 left_top_offset_un = curr_point_su / u_vec4_wall_padding_su.xy;
        vec2 right_bottom_offset_un = (curr_point_su - v_vec2_wall_size_su + u_vec4_wall_padding_su.zw) / u_vec4_wall_padding_su.zw;
        vec2 left_top_uv = left_top_offset_un * u_vec4_texture_padding_un.xy;
        vec2 right_bottom_uv = (vec2(1.0) - u_vec4_texture_padding_un.zw) + right_bottom_offset_un * u_vec4_texture_padding_un.zw;
        
        out_tc = is_in_padding_zone.x ? vec2(left_top_uv.x, v_vec2_quad_fraction.y) :
                 is_in_padding_zone.z ? vec2(right_bottom_uv.x, v_vec2_quad_fraction.y) :
                 is_in_padding_zone.y ? vec2(v_vec2_quad_fraction.x, left_top_uv.y) :
                  vec2(v_vec2_quad_fraction.x, right_bottom_uv.y);
        
        
        out_final_slice_size_su = vec2(99999.0);
        return true;
    }
    
    vec2 curr_point_in_center_image_su = curr_point_su - u_vec4_wall_padding_su.xy;
    vec2 wall_size_in_center_image_su = v_vec2_wall_size_su - u_vec4_wall_padding_su.xy - u_vec4_wall_padding_su.zw;
    bool res = layout_internal_image(curr_point_in_center_image_su, wall_size_in_center_image_su, out_tc, out_final_slice_size_su);
    if (res)
    {
        out_tc = fract(out_tc);
        
        out_tc = out_tc * (vec2(1.0) - u_vec4_texture_padding_un.xy - u_vec4_texture_padding_un.zw) + u_vec4_texture_padding_un.xy;
        
        
        
        
        out_final_slice_size_su /= vec2(1.0) - u_vec4_texture_padding_un.xy - u_vec4_texture_padding_un.zw;
    }
    return res;
}
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = vec4(0.);
    vec2 raw_tc = vec2(0.);
    vec2 final_slice_size_su = vec2(0.);
    bool should_render_texture = layout_image(raw_tc, final_slice_size_su);
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    vec2 modulo_coords = fract(raw_tc);
    vec4 texture_color;
#ifdef WEBGL1
    texture_color = texture2D(u_sr2d_texture, modulo_coords);
#else
    vec2 tc_dfdx = dFdx(v_vec2_quad_fraction);
    vec2 tc_dfdy = dFdy(v_vec2_quad_fraction);
    vec2 final_texture_size_su = final_slice_size_su * u_vec2_texture_part_count;
    vec2 derivative_scale = v_vec2_wall_size_su / final_texture_size_su;
    tc_dfdx *= derivative_scale;
    tc_dfdy *= derivative_scale;
    texture_color = textureGrad(u_sr2d_texture, modulo_coords, tc_dfdx, tc_dfdy);
#endif
    if (!should_render_texture) {
        discard;
    }
    color = texture_color;
    gl_FragColor = apply_fog(color);
}
`,Um=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
uniform sampler2D u_sr2d_texture;
uniform vec4 u_vec4_color;
varying vec3 v_vec3_rotated_scaled_vertex;
varying vec2 v_vec2_texcoord;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec3 normal = calc_fragment_normal(v_vec3_rotated_scaled_vertex);
    vec4 light = light_factor(normal);
    vec4 color = texture2D(u_sr2d_texture, v_vec2_texcoord) * u_vec4_color * light;
    gl_FragColor = apply_fog(color);
}
`,Gm={affine_step:Mf,apply_opacity:Gr,arrow_functions:Ef,bit_mask:If,cam_pos:Hr,circle_functions:Cf,dem:Lf,enable_standard_derivatives:Pf,fog:Bf,fragment_normal:zf,highp_float:Rf,light:Ff,light_pbr:Df,light_phong:Of,lowp_float:Nf,mediump_float:kf,mix_color_defs:Vr,pack_depth:Uf,prelude:Gf,require_frag_depth:Hf,screendoor_transparency:Vf,shadow:Zf,signed_distance_functions:Zr},Hm={arrow_line:jf,arrow_line_identify:Wf,circle_marker:$f,color:Xf,color_identify:Kf,color_with_z_fade:qf,copy:Yf,dem_elevation:Qf,dem_elevation_copy:Jf,dem_flat_bottom:Af,dem_ground:em,dem_ground2:tm,dem_mesh:im,dem_mesh2:nm,dem_normal:om,depth_clear:sm,fxaa:am,globe:rm,globe_halo:lm,globe_halo_background:cm,gltf_model:dm,gradient_with_z_fade:_m,heatmap:um,heatmap_texture:hm,inverse:fm,label:mm,label_directional:pm,line:vm,main_shadow:gm,map_mesh:ym,mesh:xm,metric_point:bm,one_way_line:wm,patterned_line:Sm,pointsprite:Tm,pointsprite_identify:Mm,rect_with_texture:Em,road:Im,road_identify:Cm,simple_line_2d:Lm,simple_line_3d:Pm,simple_mesh:Bm,sky:zm,stars:Rm,striped_line:Fm,taa:Dm,textured_color:Om,uniform_color:Nm,wall_texture:km,zbm_model:Um},Vm=`vec4 apply_height_factor(in vec3 vertex, const float height_factor)
{
    vertex.z *= height_factor;
    return vec4(vertex, 1.0);
}
`,Zm=`
vec2 multiply_complex(const vec2 lhs, const vec2 rhs)
{
    return vec2(lhs.x * rhs.x - lhs.y * rhs.y, lhs.x * rhs.y + lhs.y * rhs.x);
}
struct ArrowParameters
{
    float zpt_to_texcoord_factor;
    float final_size;
    float outer_width;
    vec2 widen_size;
    vec2 wing_normal;
    vec2 tip_normal;
};
ArrowParameters calculate_arrow_parameters(
    const float calculation_scale,
    const float width_zpt,
    const float border_width_zpt,
    const float segment_length_zpt,
    const float wing_width_multiplier,
    const float wing_height_multiplier,
    const float tip_height_multiplier,
    const float size_factor)
{
    float quad_width = 2.0 * border_width_zpt + 2.0 * wing_width_multiplier * width_zpt;
    float quad_height = 2.0 * border_width_zpt + segment_length_zpt;
    float max_quad_dimension = max(quad_width, quad_height);
    float zpt_to_texcoord_factor = 2.0 / max_quad_dimension;
    float final_size = calculation_scale * size_factor * max_quad_dimension;
    vec2 widen_size = 0.5 * vec2(quad_height, quad_width) * zpt_to_texcoord_factor;
    float outer_width = (width_zpt * wing_width_multiplier + border_width_zpt) * zpt_to_texcoord_factor;
    vec2 wing_normal = -normalize(vec2(wing_width_multiplier, wing_height_multiplier));
    vec2 tip_normal = normalize(vec2(wing_width_multiplier, tip_height_multiplier));
    return ArrowParameters(
        zpt_to_texcoord_factor,
        final_size,
        outer_width,
        widen_size,
        wing_normal,
        tip_normal);
}
struct VertexShiftParameters
{
    vec4 clip_space_vertex;
    float limited_factor;
};
VertexShiftParameters calculate_vertex_shift_parameters(
    const mat4 mvp,
    const vec2 vpt_size,
    const vec2 vertex,
    const vec2 widen,
    const float shift_pixels)
{
    vec2 widen_perp = vec2(-widen.y, widen.x);
    
    vec4 clip_space_widen = mvp * vec4(widen, 0., 0.);
    vec4 clip_space_widen_perp = mvp * vec4(widen_perp, 0., 0.);
    vec2 half_viewport = vpt_size / 2.;
    
    vec4 clip_space_vertex = mvp * vec4(vertex, 0.0, 1.0) + clip_space_widen;
    
    float limited_factor = calculate_multiplication_factor(
        half_viewport,
        clip_space_widen,
        clip_space_widen_perp,
        clip_space_vertex,
        shift_pixels);
    return VertexShiftParameters(
        clip_space_vertex + clip_space_widen * limited_factor,
        limited_factor);
}
`,jm=`struct Scale
{
    float projection;
    float style;
    float style_clamped;
    float calculation;
};
Scale calculate_scale(const vec3 projection_scale_style_scale_dpi, const vec2 scale_limits)
{
    float style_scale_clamped = clamp(projection_scale_style_scale_dpi.y, scale_limits.x, scale_limits.y);
    float scale_ratio = projection_scale_style_scale_dpi.x / projection_scale_style_scale_dpi.y;
    float calculation_scale = style_scale_clamped * scale_ratio;
    return Scale(
        projection_scale_style_scale_dpi.x,
        projection_scale_style_scale_dpi.y,
        style_scale_clamped,
        calculation_scale);
}
const float g_min_scale_factor = 1e-2;
const float g_max_scale_factor = 1e2;
const float g_base_scale_numerator = 1e2;
float normalize_scale_to_tile(const float scale, const float tile_size)
{
    return clamp(
        (scale - g_min_scale_factor) / (tile_size - g_min_scale_factor),
        g_min_scale_factor,
        g_max_scale_factor);
}
`,Wm=`
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
void save_clipspace_pos () {
    #ifdef SCREENDOOR
    v_clipspace_pos = gl_Position.xyz;
    #endif
}
`,$m=`
uniform sampler2D u_tex_dem;
uniform sampler2D u_tex_corrected_dem;
uniform float u_float_corrected_interval;
uniform mat4 u_mat4_dem_corrected;
uniform mat4 u_mat4_dem_mvp;
uniform float u_float_dem_scale;
uniform float u_float_map_center_elevation;
uniform float u_float_vertical_scale;
const float UNPACK_CENTROID = 8. / 65535.;
const float MAP_POINTS_IN_METER = 107.17318796639701;
#ifndef VARYINGS_LIMIT_9
    
    varying vec2 v_vec2_dem_tex_pos;
    
    varying float v_float_dem_invalid;
#endif
void reset_dem_varyings() {
    #ifndef VARYINGS_LIMIT_9
    v_vec2_dem_tex_pos = vec2(0, 0);
    v_float_dem_invalid = 0.;
    #endif
}
float dem_height_direct_meters(vec2 tex_pos) {
    
    if (u_float_dem_scale == 0.) {
        reset_dem_varyings();
        return 0.;
    }
    #ifndef VARYINGS_LIMIT_9
    v_vec2_dem_tex_pos = tex_pos;
    v_float_dem_invalid = 0.;
    #endif
    vec4 elevation;
    
    if (u_float_corrected_interval == 0.) {
        elevation = texture2D(u_tex_dem, tex_pos);
    }
    else {
        vec2 test_tex_pos = abs(tex_pos - vec2(0.5, 0.5));
        if (test_tex_pos.x < u_float_corrected_interval && test_tex_pos.y < u_float_corrected_interval) {
            elevation = texture2D(u_tex_corrected_dem, (u_mat4_dem_corrected * vec4(tex_pos, 0, 1)).xy);
        } else {
            elevation = texture2D(u_tex_dem, tex_pos);
        }
    }
    
    if (elevation.a < 1.) {
        #ifndef VARYINGS_LIMIT_9
        v_float_dem_invalid = 1.;
        #endif
        
        return 0.;
    } else {
        return elevation.r;
    }
}
float meters_to_tile_height(float height) {
    return (height - u_float_map_center_elevation) * MAP_POINTS_IN_METER * u_float_vertical_scale * u_float_dem_scale;
}
float dem_height_direct(vec2 tex_pos) {
    float height = dem_height_direct_meters(tex_pos);
    return meters_to_tile_height(height);
}
 
float dem_height(const vec2 coords) {
    
    if (u_float_dem_scale == 0.) {
        reset_dem_varyings();
        return 0.;
    }
    vec4 tex_pos = u_mat4_dem_mvp * vec4(coords, 0.0, 1.0);
    return dem_height_direct(tex_pos.xy);
}
float abs_height(float height) {
    return (height - u_float_map_center_elevation * MAP_POINTS_IN_METER) * u_float_dem_scale * u_float_vertical_scale;
}
vec2 unpack_dem_position(const vec2 pos) {
    return pos * UNPACK_CENTROID;
}
`,Xm=`#ifndef UBO
uniform vec2 u_vec2_depth_test_half_point_size;
#endif
uniform bool u_bool_depth_test_disable;
uniform sampler2D u_color_tex_labeling;
uniform sampler2D u_depth_tex_labeling;
float color_test(const vec2 pos, const vec4 color)
{
    vec2 halfPointSize = u_vec2_depth_test_half_point_size;
    float result = 0.;
    
    if (texture2D(u_color_tex_labeling, (vec2(pos.x - halfPointSize.x, pos.y + halfPointSize.y) + 1.) / 2.) == color) {
        result++;
    }
    if (texture2D(u_color_tex_labeling, (pos + halfPointSize + 1.) / 2.) == color) {
        result++;
    }
    if (texture2D(u_color_tex_labeling, (pos - halfPointSize + 1.) / 2.) == color) {
        result++;
    }
    if (texture2D(u_color_tex_labeling, (vec2(pos.x + halfPointSize.x, pos.y - halfPointSize.y) + 1.) / 2.) == color) {
        result++;
    }
    
    return step(3., result);
}
float depth_test(const vec2 pos, const float depth, const vec4 color)
{
    if (u_bool_depth_test_disable == true) {
        return 1.;
    }
    float colorCheck = color_test(pos, color);
    if (colorCheck == 1.) {
        return 1.;
    }
    float d = (depth + 1.) / 2.;
    float delta = 0.001;
    float texDepth = texture2D(u_depth_tex_labeling, (pos + 1.) / 2.).r;
    if (d <= texDepth) {
        return 1.;
    }
    if (d - texDepth > delta) {
        return 0.;
    }
    return 1. - (d - texDepth) / delta;
}
`,Km=`uniform mat4 u_mat4_flat_mvp;
uniform mat4 u_mat4_ecef_mvp;
uniform float u_float_crossfade;
const float ECEF_CF_E = 2e-16;
const float ECEF_WORLD = 4294967296.;
vec4 get_clipspace(const vec3 fpos) {
    return u_mat4_flat_mvp * vec4(fpos, 1.);
}
vec4 get_clipspace(const vec3 fpos, const vec3 epos) {
    if (u_float_crossfade < ECEF_CF_E) {
        return u_mat4_flat_mvp * vec4(fpos, 1.);
    } else if (u_float_crossfade > (1. - ECEF_CF_E)) {
        return u_mat4_ecef_mvp * vec4(epos * ECEF_WORLD, 1.);
    }
    vec4 fclip = u_mat4_flat_mvp * vec4(fpos, 1.);
    vec4 eclip = u_mat4_ecef_mvp * vec4(epos * ECEF_WORLD, 1.);
    return mix(fclip, eclip, u_float_crossfade);
}
vec4 get_clipspace(const vec3 fpos, const vec3 epos, const float elevation) {
    float R = ECEF_WORLD + elevation;
    if (u_float_crossfade < ECEF_CF_E) {
        return u_mat4_flat_mvp * vec4(fpos, 1.);
    } else if (u_float_crossfade > (1. - ECEF_CF_E)) {
        return u_mat4_ecef_mvp * vec4(epos * R, 1.);
    }
    vec4 fclip = u_mat4_flat_mvp * vec4(fpos, 1.);
    vec4 eclip = u_mat4_ecef_mvp * vec4(epos * R, 1.);
    return mix(fclip, eclip, u_float_crossfade);
}
`,qm=`#ifndef UBO
# ifdef FOG
uniform float u_fog_distance;
# endif
# ifdef SKY
uniform mat4 u_mat4_view_transposed;
uniform mat4 u_mat4_proj_inverted;
# endif
#endif 
#if defined(FOG) || defined(SKY)
varying vec3 v_fog_pos;
#endif
void calc_fog_pos(vec3 world_pos) {
#ifdef FOG
    v_fog_pos = (world_pos - u_cam_pos) / u_fog_distance;
#endif
}
void calc_fog_pos_sky(vec4 pos) {
#ifdef SKY
    v_fog_pos = mat3(u_mat4_view_transposed) * (u_mat4_proj_inverted * pos).xyz;
#endif
}`,Ym=`#ifdef TAA
uniform vec2 u_vec2_camera_jitter;
void apply_vertex_jitter(inout vec4 clipPos) {
    clipPos.xy += clipPos.w * u_vec2_camera_jitter;
}
#endif`,Qm=`float calculate_final_width(
    const Scale scale,
    const float width,
    const float width_offset)
{
    
    float final_width = max(0., scale.calculation * width - scale.projection * width_offset);
    return final_width;
}
`,Jm=`uniform mat4 u_mat4_mvp;
`,Am=`
vec2 normalize_s08(vec2 value)
{
    return value * (1. / 127.);
}
vec3 normalize_s08(vec3 value)
{
    return value * (1. / 127.);
}
float normalize_s16(float value)
{
    return value * (1. / 32767.);
}
vec2 normalize_s16(vec2 value)
{
    return value * (1. / 32767.);
}
vec3 normalize_s16(vec3 value)
{
    return value * (1. / 32767.);
}
vec2 unpack_widen(vec2 widen_packed)
{
    
    return normalize_s08(widen_packed) * sqrt(2.);
}
vec2 unpack_texcoord(vec2 texcoord)
{
    return texcoord * (1. / 32768.);
}
vec2 unpack_model_texcoord(vec2 texcoord)
{
    const float min_value = -3.0;
    const float max_value = 5.0;
    return texcoord * (max_value - min_value) / 65536.0 + min_value;
}
float normalize_u16(float value)
{
    return value * (1. / 65535.);
}
float unpack_denormalized_distance_to_line(float value)
{
    return 1. - normalize_u16(value);
}
`,ep=`
const float g_min_denominator = 1e-7;
const float g_max_factor = 10000.;
float calculate_multiplication_factor(
    vec2 half_viewport,
    
    vec4 clip_space_widen,
    vec4 clip_space_widen_perp,
    
    vec4 clip_space_vertex,
    float shift_pixels)
{
    float limited_factor = 0.;
    {
        
        vec2 screen_space_widen = (clip_space_widen.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_widen.w) * half_viewport;
        vec2 screen_space_widen_perp = (clip_space_widen_perp.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_widen_perp.w) * half_viewport;
        
        vec2 perp = vec2(screen_space_widen_perp.y, -screen_space_widen_perp.x);
        
        float perp_length = length(perp);
        vec4 v = clip_space_vertex;
        vec4 n = clip_space_widen;
        float denominator = dot(perp, screen_space_widen) / shift_pixels - n.w * v.w * perp_length;
        if (abs(denominator) > g_min_denominator)
        {
            float factor = v.w * v.w * perp_length / denominator;
            
            
            
            
            
            
            
            
            
            if (factor != factor){
                return limited_factor;
            }
            limited_factor = sign(factor) * min(g_max_factor, abs(factor));
        }
    }
    return limited_factor;
}
`,tp=`uniform mat4 u_mat4_model;
vec3 calc_pos_world(vec4 pos) {
    
    
    
    return (u_mat4_model * pos).xyz;
}
vec3 calc_pos_world(vec3 pos) {
    return calc_pos_world(vec4(pos, 1.0));
}
vec3 calc_pos_world(vec2 pos) {
    return calc_pos_world(vec4(pos, 0.0, 1.0));
}`,ip=`
const float g_circle_scale_precision_factor = 1e8;
`,np=`#ifdef WEBGL2
#define varying out
#define attribute in
#define texture2D texture
#endif
#ifdef UBO
uniform CommonSettings
{
    mediump float u_float_rounding_factor;
    mediump float u_float_border_width_offset;
    mediump vec2 u_vec2_scale_limits;
    mediump vec2 u_vec2_depth_test_half_point_size;
    mediump vec2 u_vec2_vpt_size;
    
    mediump vec4 u_fog_color;
    mediump vec2 u_fog_limits;
    mediump float u_fog_horizon_blend;
    mediump float u_fog_horizon_level;
    mediump float u_fog_horizon_pad;
    mediump float u_fog_distance;
    mediump vec4 u_sky_color;
    highp vec3 u_cam_pos;
    
    
    
    
    
    
    mediump vec4 u_shadow_map_params;
    highp mat4 u_mat4_clip_to_shadow;
    mediump float u_shadow_bias;
    mediump mat4 u_mat4_view_transposed;
    mediump mat4 u_mat4_proj_inverted;
    
    mediump vec2 u_vec2_halo_viewport_size;
    mediump vec2 u_vec2_halo_viewport_center_shift;
    mediump vec4 u_vec4_halo_radius_stops;
    mediump vec4 u_vec4_halo_color;
    mediump float u_float_halo_exp_factor;
    mediump vec4 u_vec4_default_background_color;
    
    mediump mat4 u_mat4_stars;
    mediump float u_float_pixelratio;
    mediump float u_float_stars_intensity;
};
#endif
`,op=`
float unpack_scale(float value)
{
    return exp(abs(value) / 256.) * sign(value);
}
float unpack_positive_value(float value)
{
    return exp(value / 256.);
}
vec2 make_position(const vec2 position, const float w, const vec2 inv_half_size, const float rounding_factor)
{
    vec2 non_rounded_position = (position + w) / (w * inv_half_size);
    vec2 rounded_position = floor(non_rounded_position + 0.5);
    vec2 rounding_delta = rounded_position - non_rounded_position;
    vec2 pixel_coord = non_rounded_position + rounding_factor * rounding_delta - 0.5;
    return (pixel_coord * inv_half_size) * w - w;
}
vec2 overlay_transform(const vec2 position, const vec2 inv_half_size)
{
    
    
    return position * inv_half_size;
}
float clipw(const float w, const vec2 range, const float scale)
{
    return w * (step(unpack_scale(range.x), scale) - step(unpack_positive_value(range.y), scale));
}
vec2 rescale(const vec2 corner, const vec2 rescale, const vec2 scale_range, const float style_scale)
{
    
    
    if (scale_range.x < 0.)
    {
        float default_scale_denominator = unpack_positive_value(rescale.x);
        float rescale_coeff = unpack_positive_value(rescale.y);
        float min_scale = unpack_positive_value(-scale_range.x);
        float stretch_exponent = floor(0.5 + log2(
            max(1., 1. + rescale_coeff * (1. / max(min_scale, style_scale) - default_scale_denominator))));
        return corner.xy * exp2(stretch_exponent);
    }
    return corner;
}
`,sp=`
vec4 round_position(const vec4 position, const vec2 half_viewport)
{
    if (
        position.w < 0.
        || position.x < -position.w
        || position.x > position.w
        || position.y < -position.w
        || position.y > position.w
        || position.z < -position.w
        || position.z > position.w)
    {
        return position;
    }
    else
    {
        
        return vec4(
            sign(position.xy) * floor(abs(position.xy) * half_viewport / position.w + .5)
                * position.w / half_viewport,
            position.zw);
    }
}
`,ap=`#ifdef RENDER_SHADOWS
varying vec4 v_pos_from_light;
varying float v_depth_metric;
#ifndef UBO
uniform mat4 u_mat4_clip_to_shadow;
uniform mediump vec4 u_shadow_map_params;
uniform mediump float u_shadow_bias;
#endif
void compute_shadow_vertex(vec4 clip_pos)
{
    v_pos_from_light = u_mat4_clip_to_shadow * clip_pos;
    v_pos_from_light.z -= u_shadow_bias;
    v_depth_metric = 0.5 * v_pos_from_light.z + 0.5;
}
void compute_shadow_vertex(vec4 clip_pos, vec3 normal, mat4 mvp_mat)
{
    
    float normal_bias = u_shadow_map_params[3];
    vec3 norm_from_light = (u_mat4_clip_to_shadow * mvp_mat * vec4(normal, 0.0)).xyz;
    v_pos_from_light = u_mat4_clip_to_shadow * clip_pos;
    v_pos_from_light.xyz += normal_bias * normalize(norm_from_light);
    v_pos_from_light.z -= u_shadow_bias;
    v_depth_metric = 0.5 * v_pos_from_light.z + 0.5;
}
#else 
void compute_shadow_vertex(vec4 clip_pos) { }
void compute_shadow_vertex(vec4 clip_pos, vec3 normal, mat4 mvp_mat) { }
#endif `,rp=`
const float FADE_THRESHOLD = 0.06;
float interleaved_gradient_noise(vec3 coords)
{
    const vec3 m = vec3(0.06711056, 0.00583715, 52.9829189);
    return fract(m.z * fract(dot(coords.xy, m.xy)));
}
float apply_show_ratio(const float show_ratio, const vec3 instance_wp) {
    float noise = interleaved_gradient_noise(instance_wp);
    float threshold_range = 1. - FADE_THRESHOLD * 2.;
    float adjusted_noise = FADE_THRESHOLD + noise * threshold_range;
    float opacity = (show_ratio - adjusted_noise + FADE_THRESHOLD) / (FADE_THRESHOLD * 2.);
    return clamp(opacity, 0.0, 1.0); 
}
`,lp=`struct PolylineDistance
{
    
    float vertex_distance_from_start;
    
    float segment_distance_from_start;
    
    float total_length;
};
struct StripedLineInParams
{
    float dash_length;
    float space_length;
    float dash2_length;
    float line_width;
};
struct StripedLineOutParams
{
    
    float part_color_swap_threshold;
    float distance_in_parts;
};
void calculate_line_params(in PolylineDistance polyline_distance, in StripedLineInParams striped_line_params, out StripedLineOutParams line_params)
{
    
    float requested_part_length =
        striped_line_params.dash_length
        + striped_line_params.space_length;
    
    float space2_length = requested_part_length - striped_line_params.dash2_length;
    
    float part_count = max(
        floor(polyline_distance.total_length / requested_part_length + 0.5),
        1.0);
    
    float part_length = polyline_distance.total_length / part_count;
    
    float dash_length = (part_length / requested_part_length) * striped_line_params.dash2_length;
    float part_color_swap_threshold = dash_length / part_length;
    
    
    float segment_start = fract((polyline_distance.segment_distance_from_start + 0.5 * dash_length) / part_length);
    float vertex_normalized_distance = segment_start + polyline_distance.vertex_distance_from_start / part_length;
    line_params = StripedLineOutParams(
        part_color_swap_threshold,
        vertex_normalized_distance);
}
`,cp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <signed_distance_functions>
#include <arrow_functions>
#include <calculate_scale>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#ifndef UBO
uniform float u_float_border_width_offset;
uniform vec2 u_vec2_scale_limits;
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_width_zpt;
uniform float u_float_wing_height_multiplier;
uniform float u_float_wing_width_multiplier;
uniform float u_float_border_width_zpt;
uniform float u_float_size_factor;
uniform float u_float_tip_height_multiplier;
uniform float u_float_relative_end_position;
uniform float u_float_tip_movement_amplitude;
uniform float u_float_vertex_shift; 
uniform float u_float_opacity;
uniform float u_float_tip_radius_zpt;
uniform float u_float_wing_radius_zpt;
uniform float u_float_tail_radius_zpt;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_segment_end;
attribute vec4 a_vec4_texture_widen_arrow_widen;
attribute vec2 a_vec2_widen;
attribute vec2 a_vec2_direction; 
attribute float a_float_distance_from_start;
attribute float a_float_object_length;
attribute float a_float_type;
attribute vec4 a_vec4_identifier; 
varying vec2 v_vec2_line_type_arrow_tail;
varying vec4 v_vec4_arrow_width_length_border_outer;
varying vec4 v_vec4_texcoord_arrow_line;
varying vec4 v_vec4_distance_vertex_hiding;
varying vec4 v_vec4_identifier;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
#ifdef ENTRANCE_ARROWS_ROUNDING
varying vec3 v_vec3_radius_tip_wing_tail;
#endif
varying vec4 v_vec4_circle_center_tip_wing;
const float g_w_factor = 1e-7;
const float g_type_line = 0.;
const float g_type_arrow = 1.;
const float g_type_start_border = 2.;
const float g_type_line_ending = 3.;
const float g_type_line_cut = 4.;
const float g_shift_pixels = 2.;
const float g_line_overlapping_part = .2;
struct ArrowLineViewParameters
{
    float vertex_type;
    float width_zpt;
    float border_width_zpt;
    float border_width_offset;
    float tip_radius_zpt;
    float wing_radius_zpt;
    float tail_radius_zpt;
    float arrow_segment_length_zpt;
    float tip_height_multiplier;
    float wing_height_multiplier;
    float wing_width_multiplier;
    float size_factor;
    vec2 vertex_position;
    vec2 vertex_widen;
    vec2 line_texture_widen;
    vec2 arrow_texture_widen;
    vec2 segment_direction;
    float segment_length;
    float distance_to_end;
};
struct DistanceShiftParameters
{
    float shift;
    bool invisible;
};
vec2 perp(const vec2 vector)
{
    return vec2(-vector.y, vector.x);
}
vec2 vertex_shift(const Scale scale)
{
    return u_float_vertex_shift * u_float_tip_movement_amplitude * normalize_s08(a_vec2_direction) * scale.calculation;
}
vec2 arrow_shift(const ArrowLineViewParameters view)
{
    
    
    
    return view.segment_direction * view.distance_to_end;
}
float erase_length_end()
{
    return clamp(u_float_relative_end_position, 0., 1.) * a_float_object_length;
}
void set_texcoord_varyings(const vec2 arrow_texcoord, const vec2 line_texcoord)
{
    v_vec4_texcoord_arrow_line = vec4(arrow_texcoord, line_texcoord);
}
void set_arrow_varyings(
    const float arrow_width,
    const float arrow_length,
    const float arrow_border,
    const float arrow_outer_width,
    const float arrow_tail_hide_part,
    const float arrow_tip_radius,
    const float arrow_wing_radius,
    const float tail_radius,
    const vec2 tip_circle_center,
    const vec2 wing_circle_center)
{
    v_vec4_arrow_width_length_border_outer = vec4(
        arrow_width,
        arrow_length,
        arrow_border,
        arrow_outer_width);
    v_vec2_line_type_arrow_tail = vec2(
        a_float_type,
        arrow_tail_hide_part);
    #ifdef ENTRANCE_ARROWS_ROUNDING
    v_vec3_radius_tip_wing_tail = vec3(
        arrow_tip_radius,
        arrow_wing_radius,
        tail_radius);
    #endif
    v_vec4_circle_center_tip_wing = vec4(tip_circle_center.xy, wing_circle_center.xy);
}
DistanceShiftParameters calculate_entrance_arrow_distances(
    const ArrowLineViewParameters view,
    const float signed_distance_shift,
    const float arrow_final_size,
    const float entrance_arrow_distance_shift)
{
    DistanceShiftParameters line_distance_parameters = DistanceShiftParameters(
        signed_distance_shift + entrance_arrow_distance_shift,
        false);
    if (a_float_type == g_type_arrow)
    {
        
        
        bool outside_of_current_segment = view.distance_to_end > view.segment_length + entrance_arrow_distance_shift;
        
        bool inside_end_hide = a_float_distance_from_start + entrance_arrow_distance_shift > erase_length_end();
        return DistanceShiftParameters(
            
            line_distance_parameters.shift + view.distance_to_end,
            outside_of_current_segment || inside_end_hide
        );
    }
    else
    {
        return line_distance_parameters;
    }
}
void set_distance_varyings(
    const ArrowLineViewParameters view,
    const float arrow_final_size,
    const float signed_shift_distance)
{
    float entrance_arrow_distance_shift = arrow_final_size * (2. - g_line_overlapping_part);
    DistanceShiftParameters distance_shift_parameters = calculate_entrance_arrow_distances(
        view,
        signed_shift_distance,
        arrow_final_size,
        entrance_arrow_distance_shift);
    v_vec4_distance_vertex_hiding =
        vec4(
            a_float_distance_from_start + distance_shift_parameters.shift,
            0.,
            erase_length_end(),
            distance_shift_parameters.invisible
                ? a_float_object_length
                : 0.
        ) / a_float_object_length;
}
ArrowLineViewParameters decode_arrow_line_view_parameters()
{
    float width_zpt = u_float_width_zpt;
    float border_width_zpt = u_float_border_width_zpt;
    float arrow_segment_length_zpt = width_zpt * u_float_tip_height_multiplier + border_width_zpt;
    float vertex_type = a_float_type;
    
    vec2 segment_direction = (vertex_type == g_type_line_ending || vertex_type == g_type_line_cut)
        ? normalize(a_vec2_vertex - a_vec2_segment_end)
        : normalize(a_vec2_segment_end - a_vec2_vertex);
    float segment_length = length(a_vec2_segment_end - a_vec2_vertex);
    float distance_to_end = erase_length_end() - a_float_distance_from_start;
    return ArrowLineViewParameters(
        vertex_type,
        width_zpt,
        border_width_zpt,
        u_float_border_width_offset,
        u_float_tip_radius_zpt,
        u_float_wing_radius_zpt,
        u_float_tail_radius_zpt,
        arrow_segment_length_zpt,
        u_float_tip_height_multiplier,
        u_float_wing_height_multiplier,
        u_float_wing_width_multiplier,
        u_float_size_factor,
        a_vec2_vertex,
        unpack_widen(a_vec2_widen),
        unpack_widen(a_vec4_texture_widen_arrow_widen.xy),
        unpack_widen(a_vec4_texture_widen_arrow_widen.zw),
        segment_direction,
        segment_length,
        distance_to_end);
}
vec4 process_arrow_line_vertex(const Scale scale, const mat4 mvp, const vec2 vpt_size)
{
    ArrowLineViewParameters view = decode_arrow_line_view_parameters();
    
    ArrowParameters arrow_parameters = calculate_arrow_parameters(
        scale.calculation,
        view.width_zpt,
        view.border_width_zpt,
        view.arrow_segment_length_zpt,
        view.wing_width_multiplier,
        view.wing_height_multiplier,
        view.tip_height_multiplier,
        view.size_factor);
    vec2 vertex_widen = view.vertex_widen;
    vec2 texture_widen_with_sign = view.line_texture_widen;
    
    
    float shift_sign = sign(dot(vertex_widen, texture_widen_with_sign));
    vec2 line_texture_widen = shift_sign * texture_widen_with_sign;
    
    float line_final_size = (view.width_zpt + 2. * view.border_width_zpt) * view.size_factor * scale.calculation;
    float final_size = (view.vertex_type == g_type_arrow)
        ? arrow_parameters.final_size
        : line_final_size;
    
    
    
    
    vec2 line_texture_widen_perp = perp(line_texture_widen);
    float shift_distance = abs(dot(vertex_widen, line_texture_widen_perp)) * final_size;
    vec2 shift_direction = line_texture_widen_perp * sign(dot(vertex_widen, line_texture_widen_perp));
    vec2 line_vertex_shift = vertex_widen * final_size - shift_direction * max(0., shift_distance - .5 * view.segment_length);
    
    vec2 arrow_vertex_widen = vertex_widen * arrow_parameters.final_size;
    vec2 scene_vertex_shift = (view.vertex_type == g_type_arrow)
        ? arrow_vertex_widen
        : line_vertex_shift;
    vec2 arrow_position_shift = (view.vertex_type == g_type_arrow)
        ? arrow_shift(view)
        : vec2(0.);
    
    float shift_pixels = g_shift_pixels * sqrt(2.);
    VertexShiftParameters line_shift_parameters = calculate_vertex_shift_parameters(
        mvp,
        vpt_size,
        view.vertex_position + (vertex_shift(scale) + arrow_position_shift),
        scene_vertex_shift,
        shift_pixels);
    float arrow_line_texcoord_scale = line_final_size / arrow_parameters.final_size;
    float line_texcoord_scale = (view.vertex_type != g_type_arrow)
        ? arrow_line_texcoord_scale
        : 1.;
    vec2 line_texcoord = line_texture_widen * (1. + line_shift_parameters.limited_factor) * line_texcoord_scale;
    
    float arrow_texcoord_scale = (view.vertex_type == g_type_start_border)
        ? arrow_line_texcoord_scale
        : 1.;
    vec2 arrow_texcoord = view.arrow_texture_widen * (1. + line_shift_parameters.limited_factor) * arrow_texcoord_scale;
    set_texcoord_varyings(arrow_texcoord, line_texcoord);
    float arrow_width = view.width_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_length = view.arrow_segment_length_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_tip_radius = view.tip_radius_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_wing_radius = view.wing_radius_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float tail_radius = view.tail_radius_zpt * arrow_parameters.zpt_to_texcoord_factor;
    
    float texcoord_border_width = view.border_width_zpt * arrow_parameters.zpt_to_texcoord_factor;
    float border_width_texcoord_offset = view.border_width_offset * arrow_parameters.zpt_to_texcoord_factor;
    float arrow_border = max(0., texcoord_border_width - scale.style / scale.style_clamped * border_width_texcoord_offset);
    
    float tail_shift_direction = (view.vertex_type == g_type_line_ending || view.vertex_type == g_type_start_border) ? 1. : -1.;
    float tail_hide_shift = dot(arrow_vertex_widen, tail_shift_direction * view.segment_direction);
    float arrow_tail_hide_part = (view.distance_to_end - tail_hide_shift) * arrow_parameters.zpt_to_texcoord_factor / view.size_factor;
    
    
    float half_length = arrow_length / 2.;
    float arrow_height = arrow_width * (view.tip_height_multiplier - view.wing_height_multiplier);
    float A1 = arrow_parameters.tip_normal.x;
    float B1 = arrow_parameters.tip_normal.y;
    float C1 = -half_length * A1 - arrow_border + arrow_wing_radius;
    float A2 = arrow_parameters.wing_normal.x;
    float B2 = arrow_parameters.wing_normal.y;
    float C2 = (arrow_height - half_length) * A2 - arrow_border + arrow_wing_radius;
    float denominator = A1 * B2 - A2 * B1;
    float wing_circle_center_x = (C2 * B1 - C1 * B2) / denominator;
    float wing_circle_center_y = (A2 * C1 - A1 * C2) / denominator;
    vec2 wing_circle_center = vec2(wing_circle_center_x, wing_circle_center_y);
    vec2 tip_circle_center = vec2(half_length - (arrow_tip_radius - arrow_border) / arrow_parameters.tip_normal.x, 0.);
    set_arrow_varyings(
        arrow_width,
        arrow_length,
        arrow_border,
        arrow_parameters.outer_width,
        arrow_tail_hide_part,
        arrow_tip_radius,
        arrow_wing_radius,
        tail_radius,
        tip_circle_center,
        wing_circle_center);
    set_distance_varyings(
        view,
        arrow_parameters.final_size,
        shift_sign * shift_distance);
    
    
    return line_shift_parameters.clip_space_vertex / final_size;
}
void main()
{
    v_vec4_identifier = a_vec4_identifier; 
    Scale scale = calculate_scale(u_vec3_projection_scale_style_scale_dpi, u_vec2_scale_limits);
    vec4 processed_vertex = process_arrow_line_vertex(scale, u_mat4_mvp, u_vec2_vpt_size);
    gl_Position = processed_vertex * g_w_factor;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    v_vec4_border_color = apply_opacity(u_vec4_border_color, u_float_opacity);
    
    vec3 pos_world = calc_pos_world(a_vec2_vertex);
    calc_fog_pos(pos_world);
}
`,dp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying float v_depth_metric;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    gl_Position = u_mat4_mvp * vertex_hf;
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}`,_p=`#include <prelude>
#include <ecef_mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <dem>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_widen;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
varying vec2 v_vec2_circle;
varying float v_float_width;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    vec3 anchor = a_vec3_flat_position;
    anchor.z += height;
    vec4 pos = get_clipspace(anchor, a_vec3_ecef_position);
    vec4 ndc_position = pos / pos.w;
    ndc_position.xy += a_vec2_widen * u_float_width / u_vec2_vpt_size;
    gl_Position = ndc_position;
    v_vec2_circle = a_vec2_widen;
    v_float_width = u_float_width;
    vec3 pos_world = calc_pos_world(anchor);
    calc_fog_pos(pos_world);
}
`,up=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_widen;
attribute vec4 a_vec4_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
varying vec2 v_vec2_circle;
varying vec4 v_vec4_identifier;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    v_vec2_circle = a_vec2_widen;
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        vec3 position_on_dem = a_vec3_flat_position;
        position_on_dem.z += height;
        vec4 pos = get_clipspace(position_on_dem, a_vec3_ecef_position);
        vec4 ndc_position = pos / pos.w;
        ndc_position.xy += a_vec2_widen * u_float_width / u_vec2_vpt_size;
        gl_Position = ndc_position;
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,hp=`#include <prelude>
#include <mvp_mat>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#include <mix_color_defs>
#include <packed_attributes>
uniform vec4 u_vec4_color;
uniform float u_float_opacity;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_visibility;
varying vec4 v_vec4_color;
varying vec2 v_vec2_texcoord;
#ifdef MIX_COLOR_MODE
uniform vec4 u_vec4_color2;
varying vec4 v_vec4_color2;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
varying vec4 v_vec4_pos;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
varying float v_float_mix_color_factor;
attribute float a_float_mix_factor;
# endif
#endif
varying vec3 v_vec3_fragment_pos_world;
void main()
{
#ifdef MIX_COLOR_MODE
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    v_vec4_pos = vec4(0, 0, 0, 1);
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
    v_float_mix_color_factor = a_float_mix_factor;
#  ifdef MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME
#   if MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME == VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE
    v_float_mix_color_factor = unpack_denormalized_distance_to_line(a_float_mix_factor);
#   endif
#  endif
# endif
#endif
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 0, 1);
        return;
    }
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
#ifdef MIX_COLOR_MODE
    v_vec4_color2 = apply_opacity(u_vec4_color2, u_float_opacity);
#endif
    vec4 vertex = vec4(a_vec2_vertex, u_float_floor_elevation, 1.0);
    gl_Position = u_mat4_mvp * vertex;
    vec3 pos_world = calc_pos_world(vertex.xyz);
    calc_fog_pos(pos_world);
    
    
    
    
    
    
    
    v_vec2_texcoord = fract(abs((a_vec2_vertex - 0.25) * 2.));
    v_vec3_fragment_pos_world = pos_world;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
#ifdef MIX_COLOR_MODE
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    v_vec4_pos = gl_Position;
# endif
#endif
}
`,fp=`#include <prelude>
#include <mvp_mat>
#include <round_position>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_identifier;
attribute float a_float_visibility;
varying vec4 v_vec4_identifier;
void main()
{
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier && a_float_visibility != 0.0)
    {
        gl_Position = round_position(u_mat4_mvp * vec4(a_vec2_vertex, u_float_floor_elevation, 1.), .5 * u_vec2_vpt_size);
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,mp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
varying float v_float_height;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    v_float_height = a_float_height;
}
`,pp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
uniform mat4 u_mat4_dem_corrected;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    v_vec2_texcoord = (u_mat4_dem_corrected * vec4(unpack_texcoord(a_vec2_texcoord), 0, 1)).xy;
}
`,vp=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_centroid;
attribute vec2 a_vec2_extender;
varying vec4 v_vec4_color;
void main()
{
    vec4 tex_pos = u_mat4_dem_corrected * u_mat4_mvp * vec4(unpack_dem_position(a_vec2_centroid), 0.0, 1.0);
    v_vec4_color = texture2D(u_tex_dem, tex_pos.xy);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex + a_vec2_extender * 1./64., 0.0, 1.0);
}
`,gp=`#include <prelude>
#include <mvp_mat>
#include <dem>
uniform mat4 u_mat4_model;
attribute vec2 a_vec2_position;
varying vec4 v_vec4_coords;
void main()
{
    vec4 tex_pos = u_mat4_dem_mvp * vec4(a_vec2_position, 0.0, 1.0);
    float height = dem_height_direct_meters(tex_pos.xy / tex_pos.w);
    float tile_height = meters_to_tile_height(height);
    gl_Position = u_mat4_mvp * vec4(a_vec2_position, tile_height, 1.0);
    v_vec4_coords = u_mat4_model * vec4(a_vec2_position, 0, 1.0);
    
    v_vec4_coords[2] = height;
}
`,yp=`#include <prelude>
#include <mvp_mat>
#include <dem>
uniform mat4 u_mat4_model;
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
varying vec4 v_vec4_coords;
void main()
{
    float tile_height = meters_to_tile_height(a_float_height);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, tile_height, 1.0);
    v_vec4_coords = u_mat4_model * vec4(a_vec2_vertex, 0, 1.0);
    
    v_vec4_coords[2] = a_float_height;
}
`,xp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <jitter>
uniform mat4 u_mat4_flat_map_mvp;
attribute vec2 a_vec2_position;
varying vec4 v_vec4_texcoord;
varying vec2 hs_tex_pos;
void main()
{
    vec4 coords = u_mat4_mvp * vec4(a_vec2_position, 0.0, 1.0);
    vec4 tex_pos = u_mat4_dem_mvp * vec4(a_vec2_position, 0.0, 1.0);
    float height = dem_height_direct(tex_pos.xy / tex_pos.w);
    gl_Position = u_mat4_mvp * vec4(a_vec2_position, height, 1.0);
    vec4 flat_coord = u_mat4_flat_map_mvp * vec4(a_vec2_position, 0.0, 1.0);
    v_vec4_texcoord = vec4(flat_coord.xy, 0., flat_coord.w);
    hs_tex_pos = tex_pos.xy;
    vec3 pos_world = calc_pos_world(vec4(a_vec2_position, height, 1.0));
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,bp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <jitter>
uniform mat4 u_mat4_flat_map_mvp;
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
varying vec4 v_vec4_texcoord;
varying vec3 v_vec3_position;
void main() {
    float height_tile = meters_to_tile_height(a_float_height);
    vec4 tex_pos = u_mat4_dem_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, height_tile, 1.0);
    vec4 flat_coord = u_mat4_flat_map_mvp * vec4(a_vec2_vertex, 0., 1.0);
    v_vec4_texcoord = vec4(flat_coord.xy, 1., flat_coord.w);
    vec3 pos_world = calc_pos_world(vec4(a_vec2_vertex, height_tile, 1.0));
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec3_position = rotation_scale_mat * vec3(a_vec2_vertex, height_tile);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,wp=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
void main() {
    float height_tile = meters_to_tile_height(a_float_height);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, height_tile, 1.0);
}
`,Sp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = vec4((a_vec2_vertex * 2. - vec2(1, 1)), 0.0, 1.0);
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,Tp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform vec4 u_vec4_color;
uniform mat4 u_mat4_gradient;
uniform float u_float_height_factor;
uniform float u_float_opacity;
uniform float u_float_floor_elevation;
uniform int u_int_is_roof;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec4 v_vec4_rotated_scaled_vertex;
const float g_wall_offset_isometric = .001;
const float g_wall_offset_perspective = 8.;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vertex_hf = apply_height_factor(vertex, u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    vec4 clip_pos = u_mat4_mvp * vertex_hf;
    gl_Position = clip_pos;
    if (u_int_is_roof == 0)
    {
        
        if ((u_mat4_mvp[0][3] == 0.) && (u_mat4_mvp[1][3] == 0.) && (u_mat4_mvp[2][3] == 0.))
        {
            gl_Position.z += g_wall_offset_isometric;
        }
        else
        {
            
            
            
            if (height == 0.) {
                gl_Position.z += g_wall_offset_perspective;
            } else {
                gl_Position.z += g_wall_offset_isometric;
            }
        }
    }
    vec3 pos_world = calc_pos_world(vertex_hf);
    calc_fog_pos(pos_world);
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec4_rotated_scaled_vertex.xyz = rotation_scale_mat * vertex;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    if (u_mat4_gradient[0][0] !=0.)
    {
        
        if (a_float_z > 0.0)
        {
            v_vec4_rotated_scaled_vertex.w = 1.;
        } else {
            v_vec4_rotated_scaled_vertex.w = 0.;
        }
        v_mat4_gradient = u_mat4_gradient;
        for (int i = 1; i <= 2; i++) {
            v_mat4_gradient[i] = apply_opacity(v_mat4_gradient[i], u_float_opacity);
        }
    }
    
    compute_shadow_vertex(clip_pos);
}
`,Mp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <round_position>
#include <apply_height_factor>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_identifier;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_identifier;
void main()
{
    
    
    
    if (a_float_visibility == 0.0 || a_vec4_identifier == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    v_vec4_identifier = a_vec4_identifier;
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    gl_Position = round_position(
        u_mat4_mvp * vertex_hf,
        .5 * u_vec2_vpt_size);
}
`,Ep=`#include <prelude>
#include <ecef_mvp_mat>
attribute vec3 a_vec3_ecef_position;
attribute vec3 a_vec3_flat_position;
attribute vec2 a_vec2_texture;
uniform vec4 u_vec4_extent;
varying vec2 v_vec2_texture;
void main()
{
    v_vec2_texture = a_vec2_texture;
    vec4 pos = get_clipspace(a_vec3_flat_position, a_vec3_ecef_position);
    gl_Position = pos;
}`,Ip=`#include <prelude>
#ifndef UBO
uniform mediump vec2 u_vec2_halo_viewport_size;
uniform mediump vec2 u_vec2_halo_viewport_center_shift;
uniform mediump vec4 u_vec4_halo_radius_stops;
uniform mediump float u_float_halo_exp_factor;
#endif
attribute vec2 a_vec2_vertex;
varying vec2 v_vec2_uv;
void main() {
    
    
    
    
    
    
    
    float globe_halo_padding_factor = log(0.005) / u_float_halo_exp_factor;
    
    vec4 pixel_radius_stops = u_vec4_halo_radius_stops * u_vec2_halo_viewport_size.y;
    
    
    
    
    float maxR = pixel_radius_stops[1] + (pixel_radius_stops[3] - pixel_radius_stops[1]) * globe_halo_padding_factor;
    
    float scale = maxR / u_vec2_halo_viewport_size.y;
    v_vec2_uv = a_vec2_vertex * scale;
    vec2 center = u_vec2_halo_viewport_size / 2.0 + u_vec2_halo_viewport_center_shift;
    vec2 p = center - a_vec2_vertex * maxR;
    vec2 p_result = 2.0 * (p - 0.5 * u_vec2_halo_viewport_size) / u_vec2_halo_viewport_size;
    gl_Position = vec4(p_result, 0.0, 1.0);
}
`,Cp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
#include <show_ratio>
#define EPSILON (0.0001)
#define DEM_POS_INSTANCE 0
#define DEM_POS_FLAT 1
#define DEM_POS_AXIS 2
#define DEM_POS_CENTROID 3
uniform mat4 u_mat4_instance;
uniform vec2 u_vec2_anchor;
uniform vec4 u_vec4_axis;
uniform int u_int_gltf_dem_pos;
uniform mat4 u_mat4_localmatrix;
uniform float u_float_height_factor;
uniform float u_float_show_ratio;
uniform mediump int u_int_identify;
uniform float u_float_floor_elevation;
uniform int u_int_abs_z;
uniform int u_int_extention_to_relief_needed;
uniform int u_int_collapse_height_needed;
attribute vec3 a_position;
attribute vec3 a_normal;
attribute vec2 a_tangent;
attribute vec2 a_vec2_instance_position;
attribute float a_float_instance_height;
#ifndef MALI_GPU
attribute vec3 a_vec3_instance_ecef_position;
attribute float a_float_abs_z;
#endif
attribute mat3 a_mat3_instance_matrix;
attribute vec4 a_vec4_instance_localid;
#ifdef COLOR_TEXTURE
attribute vec2 texcoord_color;
#endif
#ifdef AO_TEXTURE
attribute vec2 texcoord_ao;
#endif
#ifdef PBR_TEXTURE
attribute vec2 texcoord_pbr;
#endif
varying vec4 v_vec4_identifier;
varying vec3 v_vec3_normal;
varying vec3 v_vec3_fragment_pos_world;
#ifdef MAP_MESH_TEXTURE
varying vec4 v_tex_coord;
#endif
#ifdef COLOR_TEXTURE
varying vec2 v_vec2_texcoord_color;
#endif
#ifdef AO_TEXTURE
varying vec2 v_vec2_texcoord_ao;
#endif
#ifdef PBR_TEXTURE
varying vec2 v_vec2_texcoord_pbr;
#endif
varying float v_float_opacity;
void calc_texcoords(mat4 instance_matrix, float height) {
    #ifdef MAP_MESH_TEXTURE
    
    vec4 vertexTier = instance_matrix * vec4(a_position, 1.);
    vertexTier *= u_mat4_instance;
    vertexTier.z *= u_float_height_factor;
    vertexTier.xyz *= v_float_opacity;
    vec4 vflatTier = vec4(a_vec2_instance_position,a_float_instance_height, 1.);
    vflatTier.z += height;
    vflatTier.xyz += vertexTier.xyz;
    v_tex_coord = u_mat4_flat_mvp * vec4(vflatTier.xy, 0, 1.0);
    #endif
    #if defined(COLOR_TEXTURE)
    v_vec2_texcoord_color = texcoord_color;
    #endif
    #ifdef AO_TEXTURE
    v_vec2_texcoord_ao = texcoord_ao;
    #endif
    #ifdef PBR_TEXTURE
    v_vec2_texcoord_pbr = texcoord_pbr;
    #endif
}
void main()
{
    if (u_int_identify != 0 && a_vec4_instance_localid == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 0, 0);
        return;
    }
    mat4 instance_matrix = mat4(
        vec4(a_mat3_instance_matrix[0], 0),
        vec4(a_mat3_instance_matrix[1], 0),
        vec4(a_mat3_instance_matrix[2], 0),
        vec4(0, 0, 0, 1)
    );
    float height = 0.;
    
    if (u_int_gltf_dem_pos == DEM_POS_CENTROID) {
        vec4 center = (instance_matrix * u_mat4_localmatrix) * vec4(u_vec2_anchor.x, 0, u_vec2_anchor.y, 1);
        center *= u_mat4_instance;
        center.xy += a_vec2_instance_position;
        height = dem_height(center.xy);
    } else if (u_int_gltf_dem_pos == DEM_POS_AXIS)  {
        vec2 a = a_position.xz - u_vec4_axis.xy;
        vec2 b = u_vec4_axis.zw - u_vec4_axis.xy;
        float b_length = length(b);
        a /= b_length;
        b /= b_length;
        float coef = clamp(dot(a, b), 0., 1.);
        vec4 axis_start = (instance_matrix * u_mat4_localmatrix) * vec4(u_vec4_axis.x, 0, u_vec4_axis.y, 1);
        axis_start *= u_mat4_instance;
        axis_start.xy += a_vec2_instance_position;
        float height_start = dem_height(axis_start.xy);
        vec4 axis_end = (instance_matrix * u_mat4_localmatrix) * vec4(u_vec4_axis.z, 0, u_vec4_axis.w, 1);
        axis_end *= u_mat4_instance;
        axis_end.xy += a_vec2_instance_position;
        float height_end = dem_height(axis_end.xy);
        height = mix(height_start, height_end, coef);
    } else if (u_int_gltf_dem_pos == DEM_POS_FLAT) {
        vec4 pos = (instance_matrix * u_mat4_localmatrix) * vec4(a_position, 1);
        pos *= u_mat4_instance;
        pos.xy += a_vec2_instance_position;
        height = dem_height(pos.xy);
    } else {
#ifdef MALI_GPU 
        
        
        height = dem_height(a_vec2_instance_position); 
#else
        if (u_int_abs_z == 0) {
            height = dem_height(a_vec2_instance_position);
        } else {
            height = abs_height(a_float_abs_z);
        }
#endif
    }
    height += u_float_floor_elevation;
    vec3 instance_position = vec3(a_vec2_instance_position, a_float_instance_height);
    if (u_float_show_ratio < 1.0) {
        vec3 instance_wp = a_mat3_instance_matrix * instance_position;
        v_float_opacity = apply_show_ratio(u_float_show_ratio, instance_wp);
    } else {
        v_float_opacity = 1.;
    }
    v_vec4_identifier = a_vec4_instance_localid;
    vec4 vertex = (instance_matrix * u_mat4_localmatrix) * vec4(a_position, 1.);
    vertex *= u_mat4_instance;
    vertex.xyz *= v_float_opacity;
    vertex.z *= u_float_height_factor;
#ifndef MALI_GPU
    if (u_int_abs_z == 1) {
        bool is_base = vertex.z < EPSILON;
        if (is_base) {
            
            
            if (u_int_extention_to_relief_needed == 1) {
                float relief_height = dem_height(a_vec2_instance_position);
                vertex.z -= abs_height(a_float_abs_z) - relief_height;
            }
        } else {
            
            
            if (u_int_collapse_height_needed == 1) {
                vertex.z = 0.;
            }
        }
    }
#endif
    vec4 vflat = vec4(instance_position, 1.);
    vflat.z += height;
    vflat.xyz += vertex.xyz;
    vec3 pos_world = calc_pos_world(vflat);
    calc_fog_pos(pos_world);
#ifdef MALI_GPU
    
    
    
    gl_Position = get_clipspace(vflat.xyz);
#else
    vec4 vecef = vec4(a_vec3_instance_ecef_position, 1.);
    vecef.xyz += vertex.xyz;
    gl_Position = get_clipspace(vflat.xyz, vecef.xyz, a_float_abs_z);
#endif
    calc_texcoords(instance_matrix, height);
    
    v_vec3_normal = ((instance_matrix * u_mat4_localmatrix) * vec4(a_normal, 0)).xyz;
    v_vec3_fragment_pos_world = pos_world;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    save_clipspace_pos();
    compute_shadow_vertex(gl_Position, v_vec3_normal, u_mat4_flat_mvp);
}
`,Lp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <show_ratio>
#define EPSILON (0.0001)
uniform mat4 u_mat4_instance;
uniform mat4 u_mat4_localmatrix;
uniform float u_float_height_factor;
uniform float u_float_show_ratio;
uniform int u_int_abs_z;
uniform int u_int_extention_to_relief_needed;
uniform int u_int_collapse_height_needed;
attribute vec3 a_position;
attribute vec2 a_vec2_instance_position;
attribute float a_float_instance_height;
#ifndef MALI_GPU
attribute vec3 a_vec3_instance_ecef_position;
attribute float a_float_abs_z;
#endif
attribute mat3 a_mat3_instance_matrix;
varying float v_depth_metric;
void main()
{
    float height = 0.;
#ifdef MALI_GPU
    height = dem_height(a_vec2_instance_position);
#else
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec2_instance_position);
    } else {
        height = abs_height(a_float_abs_z);
    }
#endif
    vec3 instance_position = vec3(a_vec2_instance_position, a_float_instance_height);
    float opacity = 1.0;
    if (u_float_show_ratio < 1.0) {
        vec3 instance_wp = a_mat3_instance_matrix * instance_position;
        opacity = apply_show_ratio(u_float_show_ratio, instance_wp);
    }
    mat4 instance_matrix = mat4(
        vec4(a_mat3_instance_matrix[0], 0),
        vec4(a_mat3_instance_matrix[1], 0),
        vec4(a_mat3_instance_matrix[2], 0),
        vec4(0, 0, 0, 1)
    );
    vec4 vertex = (instance_matrix * u_mat4_localmatrix) * vec4(a_position, 1);
    vertex *= u_mat4_instance;
    vertex.xyz *= opacity;
    vertex.z *= u_float_height_factor;
#ifndef MALI_GPU
    if (u_int_abs_z == 1) {
        bool is_base = vertex.z < EPSILON;
        if (is_base) {
            
            
            if (u_int_extention_to_relief_needed == 1) {
                float relief_height = dem_height(a_vec2_instance_position);
                vertex.z -= abs_height(a_float_abs_z) - relief_height;
            }
        } else {
            
            
            if (u_int_collapse_height_needed == 1) {
                vertex.z = 0.;
            }
        }
    }
#endif
    vec4 vflat = vec4(instance_position, 1.);
    vflat.z += height;
    vflat.xyz += vertex.xyz;
#ifdef MALI_GPU
    
    
    
    gl_Position = get_clipspace(vflat.xyz);
#else
    vec4 vecef = vec4(a_vec3_instance_ecef_position, 1.);
    vecef.xyz += vertex.xyz;
    gl_Position = get_clipspace(vflat.xyz, vecef.xyz, a_float_abs_z);
#endif
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}
`,Pp=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_position;
attribute vec2 a_vec2_widen;
attribute float a_float_weight;
varying vec2 v_vec2_extrude;
varying float v_float_weight;
uniform float u_float_radius;
uniform float u_float_intensity;
uniform float u_float_tile_to_pixel_ratio;
const highp float ZERO = 1.0 / 255.0 / 16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
    float S = sqrt(-2.0 * log(ZERO / a_float_weight / u_float_intensity / GAUSS_COEF)) / 3.0;
    v_vec2_extrude = S * a_vec2_widen;
    v_float_weight = a_float_weight;
    vec2 pos = a_vec2_position + a_vec2_widen * u_float_radius * u_float_tile_to_pixel_ratio;
    calc_fog_pos(calc_pos_world(pos));
    gl_Position = u_mat4_mvp * vec4(pos, 0.0, 1.0);
}
`,Bp=`#include <prelude>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_position;
varying vec2 v_vec2_position;
void main() {
    gl_Position = vec4(a_vec2_position, 0.0, 1.0);
    v_vec2_position = clamp(a_vec2_position, vec2(0,0), vec2(1,1));
}
`,zp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec4 a_vec4_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_style_zoom_limits;
uniform float u_float_style_zoom;
uniform float u_float_scale;
uniform float u_float_tile_to_pixel_ratio;
varying vec2 v_vec2_texcoord;
float clipw(const float w, const vec2 range, const float zoom) {
    return w * (step(range.x, zoom) - step(range.y, zoom));
}
void main() {
    vec4 newPosition = a_vec4_position;
    newPosition.xy += a_vec2_offset * u_float_scale * u_float_tile_to_pixel_ratio;
    vec3 pos_world = calc_pos_world(newPosition);
    calc_fog_pos(pos_world);
    newPosition = u_mat4_mvp * newPosition;
    gl_Position = vec4(newPosition.xyz, clipw(newPosition.w, a_vec2_style_zoom_limits, u_float_style_zoom));
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,Rp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <depth_test>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_check_offset;
attribute vec4 a_vec4_tex_identifier;
attribute vec4 a_vec4_sprite_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_offset;
uniform float u_float_scale;
uniform float u_float_height_factor;
uniform bool u_bool_skip_height_factor;
uniform float u_float_floor_elevation;
varying vec2 v_vec2_texcoord;
varying vec2 v_vec2_labeling_texcoord;
varying float v_float_behind_factor;
varying vec4 v_vec4_text_identifier;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    height += u_float_floor_elevation;
    vec4 pos;
    
    
    
    if (u_bool_skip_height_factor == true) {
        pos = vec4(a_vec3_flat_position, 1.0);
    } else {
        pos = apply_height_factor(a_vec3_flat_position, u_float_height_factor);
    }
    pos.z += height;
    vec3 pos_world = calc_pos_world(a_vec3_flat_position);
    calc_fog_pos(pos_world);
    pos = get_clipspace(pos.xyz, a_vec3_ecef_position);
    pos.xyz = pos.xyz / pos.w;
    pos.w = 1.0;
    v_float_behind_factor = depth_test(pos.xy + a_vec2_check_offset / u_vec2_vpt_size, pos.z, a_vec4_tex_identifier);
    pos.xy += (a_vec2_offset * u_float_scale + u_vec2_offset) / u_vec2_vpt_size * 2.0;
    gl_Position = pos;
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
    v_vec4_text_identifier = a_vec4_sprite_identifier;
    v_vec2_labeling_texcoord = (pos.xy + 1.) / 2.;
}
`,Fp=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec4 a_vec4_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_offset;
uniform float u_float_scale;
uniform float u_float_floor_elevation;
varying vec4 v_vec4_identifier;
void main() {
    float height = dem_height(a_vec3_flat_position.xy);
    height += u_float_floor_elevation;
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        vec4 pos = get_clipspace(a_vec3_flat_position, a_vec3_ecef_position);
        pos.xyz = pos.xyz / pos.w;
        pos.w = 1.0;
        pos.xy += (a_vec2_offset * u_float_scale + u_vec2_offset) / u_vec2_vpt_size * 2.0;
        gl_Position = pos;
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,Dp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_color;
uniform float u_float_height_factor;
uniform float u_float_opacity;
uniform mediump mat4 u_mat4_gradient;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_normal;
attribute vec2 a_vec2_normal_delta;
attribute vec3 a_vec3_direction;
attribute float a_float_distance;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec3 v_vec3_normal;
varying vec2 v_vec2_height_gradient;
const float g_shift_pixels = 1.;
const float g_min_denominator = 1e-4;
const float g_w_factor = 1e-6;
vec2 multiply_complex(vec2 lhs, vec2 rhs)
{
    return vec2(lhs.x * rhs.x - lhs.y * rhs.y, lhs.x * rhs.y + lhs.y * rhs.x);
}
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec2 half_viewport = u_vec2_vpt_size / vec2(2.);
    
    if (a_float_z > 0.0)
    {
        v_vec2_height_gradient[0] = 1.;
    } else {
        v_vec2_height_gradient[0] = 0.;
    }
    vec4 clip_space_direction = u_mat4_mvp * vec4(normalize_s08(vec3(a_vec3_direction.xy, a_vec3_direction.z + height)), 0.);
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    vec4 clip_space_vertex = u_mat4_mvp * vertex_hf;
    vec2 screen_space_direction = (clip_space_direction.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_direction.w) * half_viewport;
    vec2 screen_space_perp = vec2(-screen_space_direction.y, screen_space_direction.x);
    float denominator = max(g_min_denominator, length(screen_space_perp));
    vec2 bevel_normal = normalize_s08(a_vec2_normal);
    vec2 normal_delta = normalize_s08(a_vec2_normal_delta);
    vec4 clip_space_bevel_normal = u_mat4_mvp * vec4(bevel_normal, 0., 0.);
    vec2 screen_space_bevel_normal = (clip_space_bevel_normal.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_bevel_normal.w) * half_viewport;
    float bevel_denominator = max(g_min_denominator, length(screen_space_bevel_normal));
    
    float normal_factor = -dot(screen_space_bevel_normal, screen_space_perp) / denominator / bevel_denominator;
    vec2 wall_normal = multiply_complex(bevel_normal, vec2(normal_delta.x, sign(normal_factor) * normal_delta.y));
    gl_Position = g_w_factor * (clip_space_vertex + vec4(screen_space_perp / half_viewport, 0., 0.) * g_shift_pixels * a_float_distance / denominator * clip_space_vertex.w);
    vec3 pos_world = calc_pos_world(vertex_hf);
    v_vec4_color = u_vec4_color;
    v_vec3_normal = vec3(wall_normal, 0.0);
    if (u_mat4_gradient[0][0] !=0.)
    {
        v_mat4_gradient = u_mat4_gradient;
        for (int i = 1; i <= 2; i++) {
            v_mat4_gradient[i] = apply_opacity(v_mat4_gradient[i], u_float_opacity);
        }
    }
    v_vec2_height_gradient.y = a_float_distance * gl_Position.w;
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,Op=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute float a_float_height;
attribute float a_float_abs_z;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform int u_int_abs_z;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec2_vertex);
    } else {
        height = abs_height(a_float_abs_z);
    }
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    vec4 base_vertex = vec4(
        a_vec2_vertex.x,
        a_vec2_vertex.y,
        height + a_float_height / (65535. * 32.),
        1.0
    );
    vec3 pos_world = calc_pos_world(base_vertex);
    vec3 base_normal = vec3(0.0, 0.0, 1.0);
    vec3 extender_vector = vec3(extender * u_float_tile_to_pixel_ratio, 0.0);
    vec3 V = normalize(u_cam_pos - pos_world);
    vec3 rotated_extender;
    
    vec3 rotation_axis = cross(base_normal, V);
    float sin_angle = length(rotation_axis);
    float cos_angle = dot(base_normal, V);
    const float EPSILON = 1e-3;
    if (sin_angle < EPSILON) {
        rotated_extender = extender_vector * sign(cos_angle);
    } else {
        vec3 k = rotation_axis / sin_angle;
        rotated_extender = extender_vector * cos_angle + 
                        cross(k, extender_vector) * sin_angle + 
                        k * dot(k, extender_vector) * (1.0 - cos_angle);
    }
    vec4 rotated_vertex = vec4(base_vertex.xyz + rotated_extender, 1.0);
    vec4 base_clip = u_mat4_mvp * base_vertex;
    vec3 base_ndc = base_clip.xyz / base_clip.w;
    vec4 rotated_clip = u_mat4_mvp * rotated_vertex;
    vec3 rotated_ndc = rotated_clip.xyz / rotated_clip.w;
    
    vec2 base_screen = (base_ndc.xy + 1.0) * 0.5 * u_vec2_vpt_size;
    vec2 rotated_screen = (rotated_ndc.xy + 1.0) * 0.5 * u_vec2_vpt_size;
    float pixel_distance = length(base_screen - rotated_screen);
    float scale_factor = half_width / pixel_distance;
    
    if (base_clip.w < 0.0) {
        scale_factor = 0.;
    }
    rotated_extender = rotated_extender * scale_factor;
    rotated_vertex = vec4(base_vertex.xyz + rotated_extender, 1.0);
    vec4 clip_pos = u_mat4_mvp * rotated_vertex;
    gl_Position = g_w_factor * clip_pos;
    v_vec2_normal = normal;
    v_float_half_width = half_width;
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(clip_pos, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,Np=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute float a_float_height;
attribute float a_float_abs_z;
attribute vec4 a_vec4_identifier;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform int u_int_abs_z;
varying vec2 v_vec2_normal;
varying vec4 v_vec4_identifier;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec2_vertex);
    } else {
        height = abs_height(a_float_abs_z);
    }
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier) {
        
        vec4 shifted_vertex = vec4(
            a_vec2_vertex + extender * u_float_tile_to_pixel_ratio,
            height + a_float_height / (65535. * 32.),
            1.0
        );
        gl_Position = g_w_factor * u_mat4_mvp * shifted_vertex;
    } else {
        gl_Position = vec4(1., 1., 1., 1.);
    }
    v_vec2_normal = normal;
    v_vec4_identifier = a_vec4_identifier;
    v_float_half_width = half_width;
}
`,kp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <clipspace_pos>
#include <jitter>
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_extender;
attribute vec3 a_vec3_normal;
attribute float a_float_gradient;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_is_pivot;
uniform float u_float_tile_size;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
varying vec4 v_tex_coord;
varying vec4 v_vec4_normal_gradient;
void main()
{
#ifndef VARYINGS_LIMIT_9
    v_float_dem_invalid = 0.;
#endif
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    
    vec3 vec3_vertex = vec3(a_vec2_vertex, a_float_z / (65535. * 32.));
    v_tex_coord = u_mat4_mvp * vec4(vec3_vertex.xy, 0, 1.0);
    v_vec4_normal_gradient.xyz = normalize_s08(a_vec3_normal);
    v_vec4_normal_gradient.w = a_float_gradient;
    vec4 pos = vec4(vec3_vertex.xy, vec3_vertex.z * u_float_height_factor + height, 1.0);
    vec3 world_pos = calc_pos_world(pos);
    calc_fog_pos(world_pos);
    gl_Position = u_mat4_mvp * pos;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    save_clipspace_pos();
    compute_shadow_vertex(gl_Position, v_vec4_normal_gradient.xyz, u_mat4_mvp);
}
`,Up=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <clipspace_pos>
#include <jitter>
uniform mediump vec4 u_vec4_color;
uniform mediump mat4 u_mat4_gradient;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
uniform lowp int u_int_is_textured;
uniform mediump float u_float_opacity;
uniform vec4 u_float_texture_params;
uniform float u_float_texture_vertical_scale;
uniform mediump int u_int_identify;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec3 a_vec3_normal;
attribute float a_float_gradient;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute vec4 a_vec4_identifier;
attribute float a_float_visibility;
attribute float a_float_is_pivot;
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec2 v_vec2_tex_coord;
varying vec4 v_vec4_normal_gradient;
varying vec4 v_vec4_identifier;
void main()
{
    if (u_int_identify != 0 && a_vec4_identifier == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 0, 0);
        return;
    }
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    v_vec4_identifier = a_vec4_identifier;
    
    vec4 vec4_pos = apply_height_factor(vec3(a_vec2_vertex.xy, a_float_z / (65535. * 32.)), u_float_height_factor);
    vec4_pos.z += height;
    vec3 pos_world = calc_pos_world(vec4_pos);
    calc_fog_pos(pos_world);
    gl_Position = u_mat4_mvp * vec4_pos;
    vec3 vec3_normal = normalize(a_vec3_normal);
    v_vec4_normal_gradient.xyz = vec3_normal;
    v_vec4_normal_gradient.w = a_float_gradient / 127.; 
    if (u_int_is_textured != 0) {
        
        vec2 vec2_vertex = a_vec2_vertex * 2. - 0.5;
        
        
        vec3 tex_coord = abs(vec3(
            vec2_vertex * u_float_texture_params.zw + u_float_texture_params.xy,
            a_float_z / u_float_texture_vertical_scale
        ));
        
        if (vec3_normal.x == 0. && vec3_normal.y == 0.) {
            v_vec2_tex_coord = tex_coord.xy;
        } else {
            float scale = abs(vec3_normal.z);
            tex_coord.z /= sqrt(1.0 - vec3_normal.z * vec3_normal.z);;
            if (abs(vec3_normal).y > abs(vec3_normal).x) {
                v_vec2_tex_coord = tex_coord.xz;
            } else {
                v_vec2_tex_coord = tex_coord.yz;
            }
        }
        v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    }
    
    else if (u_mat4_gradient[0][0] != 0.)
    {
        v_mat4_gradient = u_mat4_gradient;
        for (int i = 1; i <= 2; i++) {
            v_mat4_gradient[i] = apply_opacity(v_mat4_gradient[i], u_float_opacity);
        }
    } else {
        v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    }
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    save_clipspace_pos();
    compute_shadow_vertex(gl_Position, vec3_normal, u_mat4_mvp);
}
`,Gp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_visibility;
attribute float a_float_is_pivot;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
varying float v_depth_metric;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    
    vec4 vec4_pos = apply_height_factor(vec3(a_vec2_vertex.xy, a_float_z / (65535. * 32.)), u_float_height_factor);
    vec4_pos.z += height;
    gl_Position = u_mat4_mvp * vec4_pos;
    v_depth_metric = 0.5 * gl_Position.z + 0.5;
}`,Hp=`#include <prelude>
#include <mvp_mat>
#include <apply_opacity>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, u_float_floor_elevation, 1.0);
    vec3 pos_world = calc_pos_world(a_vec2_vertex);
    calc_fog_pos(pos_world);
    compute_shadow_vertex(gl_Position, vec3(0,0,1), u_mat4_mvp);
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,Vp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <signed_distance_functions>
#include <arrow_functions>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#ifndef UBO
uniform float u_float_border_width_offset;
uniform vec2 u_vec2_scale_limits;
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_border_width;
uniform float u_float_size_factor;
uniform mediump float u_float_width;
uniform mediump float u_float_length;
uniform float u_float_wing_width_multiplier;
uniform float u_float_wing_height_multiplier;
uniform float u_float_tip_height_multiplier;
uniform float u_float_opacity;
attribute vec2 a_vec2_position;
attribute vec2 a_vec2_direction;
attribute vec2 a_vec2_widen_direction;
varying vec4 v_vec4_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_texcoord;
varying float v_float_border_width;
varying float v_float_zpt_to_texcoord_factor;
varying float v_float_outer_width;
varying float v_float_opacity;
const float g_shift_pixels = 2.;
const float g_w_factor = 1e-7;
void main()
{
    float style_scale_clamped = clamp(u_vec3_projection_scale_style_scale_dpi.y, u_vec2_scale_limits.x, u_vec2_scale_limits.y);
    float scale_ratio = u_vec3_projection_scale_style_scale_dpi.x / u_vec3_projection_scale_style_scale_dpi.y;
    float calculation_scale = style_scale_clamped * scale_ratio;
    ArrowParameters arrow_parameters = calculate_arrow_parameters(
        calculation_scale,
        u_float_width,
        u_float_border_width,
        u_float_length,
        u_float_wing_width_multiplier,
        u_float_wing_height_multiplier,
        u_float_tip_height_multiplier,
        u_float_size_factor);
    v_float_zpt_to_texcoord_factor = arrow_parameters.zpt_to_texcoord_factor;
    v_float_outer_width = arrow_parameters.outer_width;
    vec2 direction = normalize_s08(a_vec2_direction);
    vec2 untransformed_widen = a_vec2_widen_direction * arrow_parameters.widen_size;
    vec2 widen = multiply_complex(untransformed_widen * arrow_parameters.final_size, direction);
    
    float shift_pixels = g_shift_pixels * sqrt(2.) / min(abs(untransformed_widen.x), abs(untransformed_widen.y));
    VertexShiftParameters shift_parameters = calculate_vertex_shift_parameters(
        u_mat4_mvp,
        u_vec2_vpt_size,
        a_vec2_position,
        widen,
        shift_pixels);
    
    
    gl_Position = shift_parameters.clip_space_vertex / arrow_parameters.final_size * g_w_factor;
    v_vec2_texcoord = untransformed_widen * (1. + shift_parameters.limited_factor);
    
    float border_width = u_float_border_width * v_float_zpt_to_texcoord_factor;
    float border_width_offset = u_float_border_width_offset * v_float_zpt_to_texcoord_factor;
    v_float_border_width = max(0., border_width - u_vec3_projection_scale_style_scale_dpi.y / style_scale_clamped * border_width_offset);
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    v_vec4_border_color = apply_opacity(u_vec4_border_color, u_float_opacity);
    v_float_opacity = u_float_opacity;
    vec3 pos_world = calc_pos_world(a_vec2_position);
    calc_fog_pos(pos_world);
}
`,Zp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <calculate_scale>
#include <line_width>
#include <apply_opacity>
#include <precision_constants>
#include <striped_line_functions>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <jitter>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_widen;
attribute float a_float_texture;
attribute float a_float_height;
uniform vec2 u_vec2_scales;
uniform float u_float_width;
uniform vec4 u_vec4_color;
uniform float u_float_opacity;
uniform vec4 u_vec4_pattern_params;
uniform bool u_bool_is_3d_line;
varying vec2 v_vec2_uv;
varying float v_float_period;
varying float v_float_width;
varying vec4 v_vec4_color;
varying vec4 v_vec4_pattern_parameters;
const float g_w_factor = 1e-6;
void main() {
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec2_vertex);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    
    v_float_width = u_float_width;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    v_vec2_uv = vec2(abs(a_float_texture), sign(a_float_texture) / 2.);
    v_vec2_uv.x *= u_vec2_scales.x / u_vec4_pattern_params.x;
    v_vec4_pattern_parameters = u_vec4_pattern_params;
    
    float full_width = u_float_width + 1.;
    
    vec2 widen = unpack_widen(a_vec2_widen);
    vec2 extender = widen * full_width * 0.5;
    
    
    vec2 shift = vec2(0.);
    vec4 shifted_vertex = vec4(a_vec2_vertex + (shift + extender) * u_vec2_scales.y, height, 1.0);
    vec3 pos_world = calc_pos_world(shifted_vertex); 
    calc_fog_pos(pos_world);
    gl_Position = u_mat4_mvp * shifted_vertex;
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(gl_Position, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
    gl_Position *= g_w_factor;
}
`,jp=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec4 a_vec4_position;
attribute vec2 a_vec2_offset;
attribute vec4 a_vec4_identifier;
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec2 u_vec2_offset;
uniform float u_float_floor_elevation;
varying vec4 v_vec4_identifier;
void main() {
    float height = dem_height(a_vec4_position.xy);
    height += u_float_floor_elevation;
    vec4 ndcPosition = u_mat4_mvp * vec4(a_vec4_position.xy, a_vec4_position.z + height, a_vec4_position.w);
    ndcPosition.xyz = ndcPosition.xyz / ndcPosition.w;
    ndcPosition.w = 1.0;
    ndcPosition.xy += (a_vec2_offset + u_vec2_offset) / u_vec2_vpt_size * 2.0;
    gl_Position = ndcPosition;
    v_vec4_identifier = a_vec4_identifier;
}
`,Wp=`#include <prelude>
#include <ecef_mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <raster_functions>
#include <depth_test>
#ifndef UBO
uniform float u_float_rounding_factor;
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_height_factor;
uniform vec2 u_vec2_rotation; 
uniform bool u_bool_skip_height_factor;
uniform float u_float_floor_elevation;
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_check_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_range;
attribute vec2 a_vec2_rescale;
attribute vec4 a_vec4_tex_identifier;
varying vec2 v_vec2_texcoord;
varying float v_float_behind_factor;
void main()
{
    float height = dem_height(a_vec3_flat_position.xy);
    height += u_float_floor_elevation;
    mat2 rotation_matrix = mat2(
        u_vec2_rotation.x, -u_vec2_rotation.y,
        u_vec2_rotation.y, u_vec2_rotation.x
    );
    vec2 inv_half_size = 2.0 / u_vec2_vpt_size;
    vec4 anchor;
    
    
    
    if (u_bool_skip_height_factor == true) {
        anchor = vec4(a_vec3_flat_position, 1.0);
    } else {
        anchor = apply_height_factor(a_vec3_flat_position, u_float_height_factor);
    }
    anchor.z += height;
    vec3 pos_world = calc_pos_world(anchor);
    calc_fog_pos(pos_world);
    anchor = get_clipspace(anchor.xyz, a_vec3_ecef_position);
    vec2 offset = rescale(rotation_matrix * a_vec2_offset, a_vec2_rescale, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y);
    vec2 pos_2d = anchor.xy + overlay_transform(offset, inv_half_size) * anchor.w;
    vec2 corner = make_position(pos_2d, anchor.w, inv_half_size, u_float_rounding_factor);
    v_float_behind_factor = depth_test(anchor.xy / anchor.w + a_vec2_check_offset / u_vec2_vpt_size, anchor.z / anchor.w, a_vec4_tex_identifier);
    gl_Position = vec4(corner, anchor.z, clipw(anchor.w, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y));
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,$p=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <raster_functions>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_height_factor;
uniform vec2 u_vec2_rotation; 
uniform bool u_bool_skip_height_factor;
uniform float u_float_floor_elevation;
attribute vec3 a_vec3_flat_position;
attribute vec3 a_vec3_ecef_position;
attribute vec2 a_vec2_offset;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_range;
attribute vec2 a_vec2_rescale;
attribute vec4 a_vec4_identifier;
varying vec2 v_vec2_texcoord;
varying vec4 v_vec4_identifier;
void main()
{
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        float height = dem_height(a_vec3_flat_position.xy);
        height += u_float_floor_elevation;
        mat2 rotation_matrix = mat2(
            u_vec2_rotation.x, -u_vec2_rotation.y,
            u_vec2_rotation.y, u_vec2_rotation.x
        );
        vec2 inv_half_size = 2.0 / u_vec2_vpt_size;
        vec4 anchor;
        
        
        
        if (u_bool_skip_height_factor == true) {
            anchor = vec4(a_vec3_flat_position, 1.0);
        } else {
            anchor = apply_height_factor(a_vec3_flat_position, u_float_height_factor);
        }
        anchor.z += height;
        anchor = get_clipspace(anchor.xyz, a_vec3_ecef_position);
        vec2 offset = rescale(rotation_matrix * a_vec2_offset, a_vec2_rescale, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y);
        vec2 pos_2d = anchor.xy + overlay_transform(offset, inv_half_size) * anchor.w;
        vec2 corner = make_position(pos_2d, anchor.w, inv_half_size, 1.0);
        gl_Position = vec4(corner, anchor.z, clipw(anchor.w, a_vec2_range, u_vec3_projection_scale_style_scale_dpi.y));
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
    v_vec4_identifier = a_vec4_identifier;
}
`,Xp=`#include <prelude>
attribute vec2 a_vec2_vertex;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = vec4(a_vec2_vertex, 0.0, 1.0);
    v_vec2_texcoord = 0.5 * a_vec2_vertex + 0.5;
}
`,Kp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <apply_opacity>
#include <raster_functions>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texcoord;
varying vec2 v_vec2_texcoord;
void main()
{
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, 0.0, 1.0);
    calc_fog_pos(calc_pos_world(a_vec2_vertex));
    v_vec2_texcoord = unpack_texcoord(a_vec2_texcoord);
}
`,qp=`#include <prelude>
#include <mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute vec2 a_vec2_shift;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform float u_float_shift;
varying vec2 v_vec2_normal;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    vec2 shift = a_vec2_shift * u_float_shift;
    
    vec4 shifted_vertex = vec4(a_vec2_vertex + (shift + extender) * u_float_tile_to_pixel_ratio, 0.0, 1.0);
    vec4 clip_pos = u_mat4_mvp * shifted_vertex;
    gl_Position = g_w_factor * clip_pos;
    v_vec2_normal = normal;
    v_float_half_width = half_width;
    vec3 pos_world = calc_pos_world(shifted_vertex);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(clip_pos, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,Yp=`#include <prelude>
#include <mvp_mat>
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_normals;
attribute vec4 a_vec4_identifier;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
varying vec2 v_vec2_normal;
varying vec4 v_vec4_identifier;
varying float v_float_half_width;
const float g_w_factor = 1e-6;
const float normal_unpack_multiplier = 0.011135539861205473;
void main()
{
    
    float half_width = 0.5 * (u_float_width + 1.0);
    
    vec4 normals = a_vec4_normals * normal_unpack_multiplier * half_width;
    vec2 extender = normals.xy;
    vec2 normal = normals.zw;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier) {
        
        vec4 shifted_vertex = vec4(a_vec2_vertex + extender * u_float_tile_to_pixel_ratio, 0.0, 1.0);
        gl_Position = g_w_factor * u_mat4_mvp * shifted_vertex;
    } else {
        gl_Position = vec4(1., 1., 1., 1.);
    }
    v_vec2_normal = normal;
    v_vec4_identifier = a_vec4_identifier;
    v_float_half_width = half_width;
}
`,Qp=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
uniform float u_float_z_offset;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute vec4 a_vec4_direction_distance;
attribute float a_float_visibility;
varying float v_float_distance;
varying float v_float_distance_offset;
const float g_smooth_width = 1.;
const float g_min_denominator = 1e-4;
const float g_w_factor = 1e-6;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float shift_pixels = 0.5 * max(u_float_width - 1., 0.);
    float shift_pixels_added = shift_pixels + g_smooth_width;
    vec3 direction = a_vec4_direction_distance.xyz;
    float distance = a_vec4_direction_distance.w;
    vec2 half_viewport = u_vec2_vpt_size / vec2(2.);
    
    
    vec4 clip_space_direction = normalize(u_mat4_mvp * vec4(normalize_s08(direction), 0.));
    
    vec4 vertex = vec4(a_vec2_vertex, u_float_floor_elevation, 1.0);
    vec4 clip_space_vertex = u_mat4_mvp * vertex;
    vec2 screen_space_direction =
        (clip_space_direction.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_direction.w) * half_viewport;
    vec2 screen_space_perp = vec2(-screen_space_direction.y, screen_space_direction.x);
    float denominator = max(g_min_denominator, length(screen_space_perp));
    gl_Position = g_w_factor * (clip_space_vertex + vec4(screen_space_perp / half_viewport, 0., 0.)
        * distance * shift_pixels_added / denominator * clip_space_vertex.w);
    gl_Position.z += u_float_z_offset;
    v_float_distance = shift_pixels_added * distance * gl_Position.w;
    v_float_distance_offset = shift_pixels;
    vec3 pos_world = calc_pos_world(vertex.xyz);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,Jp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_width;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
uniform float u_float_z_offset;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_direction_distance;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_is_pivot;
attribute float a_float_visibility;
varying float v_float_distance;
varying float v_float_distance_offset;
const float g_smooth_width = 1.;
const float g_min_denominator = 1e-4;
const float g_w_factor = 1e-6;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
        
        if (a_float_z == 0.) {
            float posHeight = dem_height(a_vec2_vertex);
            if (height > posHeight) {
                height = posHeight;
            }
        }
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    height += u_float_floor_elevation;
    float shift_pixels = 0.5 * max(u_float_width - 1., 0.);
    float shift_pixels_added = shift_pixels + g_smooth_width;
    vec3 direction = a_vec4_direction_distance.xyz;
    float distance = a_vec4_direction_distance.w;
    vec2 half_viewport = u_vec2_vpt_size / vec2(2.);
    
    
    vec4 clip_space_direction = normalize(u_mat4_mvp * vec4(normalize_s08(direction), 0.));
    
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    vec4 clip_space_vertex = u_mat4_mvp * vertex_hf;
    vec2 screen_space_direction =
        (clip_space_direction.xy * clip_space_vertex.w - clip_space_vertex.xy * clip_space_direction.w) * half_viewport;
    vec2 screen_space_perp = vec2(-screen_space_direction.y, screen_space_direction.x);
    float denominator = max(g_min_denominator, length(screen_space_perp));
    gl_Position = g_w_factor * (clip_space_vertex + vec4(screen_space_perp / half_viewport, 0., 0.)
        * distance * shift_pixels_added / denominator * clip_space_vertex.w);
    gl_Position.z += u_float_z_offset;
    v_float_distance = shift_pixels_added * distance * gl_Position.w;
    v_float_distance_offset = shift_pixels;
    vec3 pos_world = calc_pos_world(vertex_hf.xyz);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,Ap=`#include <prelude>
#include <mvp_mat>
uniform float u_float_scale;
uniform vec3 u_vec3_transform;
attribute vec3 a_vec3_position;
varying vec3 v_position;
void main() {
    vec3 scaled_transformed = u_vec3_transform + a_vec3_position * u_float_scale;
    v_position = scaled_transformed;
    gl_Position = u_mat4_mvp * vec4(scaled_transformed, 1.0);
}
`,ev=`#include <prelude>
#include <pos_world>
#include <cam_pos>
#include <fog>
attribute vec2 a_vec2_vertex;
void main()
{
    gl_Position = vec4(a_vec2_vertex, 1.0, 1.0);
    calc_fog_pos_sky(gl_Position);
}
`,tv=`#include <prelude>
attribute vec3 a_vec3_position;
attribute float a_fade_opacity;
#ifndef UBO
uniform mat4 u_mat4_stars;
uniform float u_float_stars_intensity;
uniform float u_float_pixelratio;
#endif
varying mediump float v_intensity;
void main() {
    v_intensity = a_fade_opacity * u_float_stars_intensity;
    gl_PointSize = u_float_pixelratio;
    gl_Position = u_mat4_stars * vec4(a_vec3_position, 1.0);
}
`,iv=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <calculate_scale>
#include <line_width>
#include <apply_opacity>
#include <precision_constants>
#include <striped_line_functions>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
#include <dem>
#ifndef UBO
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_dash_color;
uniform vec4 u_vec4_space_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_width;
uniform float u_float_width_offset;
uniform vec2 u_vec2_scaler_params;
uniform float u_float_dash_length;
uniform float u_float_space_length;
uniform float u_float_dash2_length;
uniform float u_float_opacity;
uniform bool u_bool_is_3d_line;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texture_widen;
attribute vec2 a_vec2_widen;
attribute float a_float_vertex_distance;
attribute float a_float_component_distance;
attribute float a_float_object_length;
attribute float a_float_height;
varying vec4 v_vec4_dash_color;
varying vec4 v_vec4_space_color;
varying vec4 v_vec4_border_color;
varying vec2 v_vec2_circle;
varying float v_float_width;
varying vec2 v_vec2_line_params;
const float g_shift_pixels = 2.;
const float g_w_factor = 1e-7;
PolylineDistance decode_line_distance()
{
    return PolylineDistance(
        a_float_vertex_distance,
        a_float_component_distance,
        a_float_object_length);
}
StripedLineInParams decode_line_params(const Scale scale)
{
    float width = calculate_final_width(scale, u_float_width, u_float_width_offset);
    float dash_length  = scale.calculation * u_float_dash_length;
    float space_length = scale.calculation * u_float_space_length;
    float dash2_length = scale.calculation * u_float_dash2_length;
    return StripedLineInParams(
        dash_length,
        space_length,
        dash2_length,
        width);
}
void main()
{
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec2_vertex);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    Scale scale = calculate_scale(u_vec3_projection_scale_style_scale_dpi, u_vec2_scaler_params);
    StripedLineInParams params = decode_line_params(scale);
    vec2 widen = unpack_widen(a_vec2_widen);
    vec2 widen_perp = vec2(-widen.y, widen.x);
    
    vec4 clip_space_widen = u_mat4_mvp * vec4(widen, 0., 0.);
    vec4 clip_space_widen_perp = u_mat4_mvp * vec4(widen_perp, 0., 0.);
    
    vec4 clip_space_vertex = u_mat4_mvp * vec4(a_vec2_vertex, height, 1.0) + clip_space_widen * params.line_width;
    vec2 half_viewport = 0.5 * u_vec2_vpt_size;
    
    float limited_factor = calculate_multiplication_factor(
        half_viewport,
        clip_space_widen,
        clip_space_widen_perp,
        clip_space_vertex,
        g_shift_pixels);
    PolylineDistance distance_decoded = decode_line_distance();
    StripedLineOutParams output_params;
    calculate_line_params(distance_decoded, params, output_params);
    
    
    vec2 texture_widen_with_shift_sign = unpack_widen(a_vec2_texture_widen);
    float shift_sign = sign(dot(widen, texture_widen_with_shift_sign));
    vec2 texture_widen = shift_sign * texture_widen_with_shift_sign;
    vec2 texture_widen_perp = vec2(-texture_widen.y, texture_widen.x);
    float distance_shift = shift_sign * abs(dot(widen, texture_widen_perp)) * params.line_width;
    float circle_factor = g_circle_scale_precision_factor / scale.calculation;
    v_vec2_circle = texture_widen * (params.line_width + limited_factor) * circle_factor;
    v_float_width = params.line_width * circle_factor;
    v_vec2_line_params[0] = output_params.part_color_swap_threshold;
    v_vec2_line_params[1] = output_params.distance_in_parts;
    v_vec4_dash_color = apply_opacity(u_vec4_dash_color, u_float_opacity);
    v_vec4_space_color = apply_opacity(u_vec4_space_color, u_float_opacity);
    v_vec4_border_color = apply_opacity(u_vec4_border_color, u_float_opacity);
    gl_Position = clip_space_vertex + clip_space_widen * limited_factor;
    vec3 pos_world = calc_pos_world(a_vec2_vertex);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    gl_Position *= g_w_factor;
    compute_shadow_vertex(clip_space_vertex, vec3(0.0, 0.0, 1.0), u_mat4_mvp);
}
`,nv=`#include <prelude>
#include <mvp_mat>
#include <packed_attributes>
#include <pixel_offset>
#include <calculate_scale>
#include <line_width>
#include <apply_opacity>
#include <precision_constants>
#include <striped_line_functions>
#include <dem>
#ifndef UBO
uniform mediump vec2 u_vec2_vpt_size;
#endif
uniform vec4 u_vec4_dash_color;
uniform vec4 u_vec4_space_color;
uniform vec4 u_vec4_border_color;
uniform vec3 u_vec3_projection_scale_style_scale_dpi;
uniform float u_float_width;
uniform float u_float_width_offset;
uniform vec2 u_vec2_scaler_params;
uniform float u_float_dash_length;
uniform float u_float_space_length;
uniform float u_float_dash2_length;
uniform float u_float_opacity;
uniform bool u_bool_is_3d_line;
attribute vec2 a_vec2_vertex;
attribute vec2 a_vec2_texture_widen;
attribute vec2 a_vec2_widen;
attribute float a_float_vertex_distance;
attribute float a_float_component_distance;
attribute float a_float_object_length;
attribute vec4 a_vec4_identifier;
attribute float a_float_height;
varying vec4 v_vec4_identifier;
const float g_shift_pixels = 2.;
const float g_w_factor = 1e-7;
PolylineDistance decode_line_distance()
{
    return PolylineDistance(
        a_float_vertex_distance,
        a_float_component_distance,
        a_float_object_length);
}
StripedLineInParams decode_line_params(const Scale scale)
{
    float width = calculate_final_width(scale, u_float_width, u_float_width_offset);
    float dash_length  = scale.calculation * u_float_dash_length;
    float space_length = scale.calculation * u_float_space_length;
    float dash2_length = scale.calculation * u_float_dash2_length;
    return StripedLineInParams(
        dash_length,
        space_length,
        dash2_length,
        width);
}
void main()
{
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec2_vertex);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    Scale scale = calculate_scale(u_vec3_projection_scale_style_scale_dpi, u_vec2_scaler_params);
    StripedLineInParams params = decode_line_params(scale);
    vec2 widen = unpack_widen(a_vec2_widen);
    vec2 widen_perp = vec2(-widen.y, widen.x);
    
    vec4 clip_space_widen = u_mat4_mvp * vec4(widen, 0., 0.);
    vec4 clip_space_widen_perp = u_mat4_mvp * vec4(widen_perp, 0., 0.);
    
    vec4 clip_space_vertex = u_mat4_mvp * vec4(a_vec2_vertex, height, 1.0) + clip_space_widen * params.line_width;
    vec2 half_viewport = 0.5 * u_vec2_vpt_size;
    
    float limited_factor = calculate_multiplication_factor(
        half_viewport,
        clip_space_widen,
        clip_space_widen_perp,
        clip_space_vertex,
        g_shift_pixels);
    PolylineDistance distance_decoded = decode_line_distance();
    StripedLineOutParams output_params;
    calculate_line_params(distance_decoded, params, output_params);
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        gl_Position = (clip_space_vertex + clip_space_widen * limited_factor) * g_w_factor;
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,ov=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
uniform int u_int_texture_index;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
attribute vec2 a_vec2_wall_size; 
attribute vec2 a_vec2_quad_fraction; 
varying vec4 v_vec4_rotated_scaled_vertex;
varying vec2 v_vec2_quad_fraction;
varying vec2 v_vec2_wall_size_su;
const float g_wall_offset_isometric = 0.001;
const float g_wall_offset_perspective = 8.;
const float g_wall_texture_offset = 0.0000000005;
void main()
{
    
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vertex_hf = apply_height_factor(vertex, u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    
    
    vec3 cam_dir = normalize(u_cam_pos - calc_pos_world(vertex_hf));
    float dist = length(u_cam_pos - calc_pos_world(vertex_hf));
    float scaled_offset = (g_wall_texture_offset + 0.0000000001 * float(u_int_texture_index)) * dist;
    vertex_hf.xyz += cam_dir * scaled_offset;
    vec4 clip_pos = u_mat4_mvp * vertex_hf;
    gl_Position = clip_pos;
    
    
    if ((u_mat4_mvp[0][3] == 0.) && (u_mat4_mvp[1][3] == 0.) && (u_mat4_mvp[2][3] == 0.))
    {
        gl_Position.z += g_wall_offset_isometric;
    }
    else
    {
        
        
        
        if (height == 0.) {
            gl_Position.z += g_wall_offset_perspective;
        } else {
            gl_Position.z += g_wall_offset_isometric;
        }
    }
    vec3 pos_world = calc_pos_world(vertex_hf);
    calc_fog_pos(pos_world);
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec4_rotated_scaled_vertex.xyz = rotation_scale_mat * vertex;
    
    compute_shadow_vertex(clip_pos);
    v_vec2_quad_fraction = a_vec2_quad_fraction;
    v_vec2_wall_size_su = a_vec2_wall_size;
}
`,sv=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform float u_float_height_factor;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_texcoord;
attribute vec2 a_vec2_dem_position;
varying vec2 v_vec2_texcoord;
varying vec3 v_vec3_rotated_scaled_vertex;
void main()
{
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    v_vec2_texcoord = unpack_model_texcoord(a_vec2_texcoord);
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vh = apply_height_factor(vertex, u_float_height_factor);
    vh.z += height;
    vec3 pos_world = calc_pos_world(vh);
    calc_fog_pos(pos_world);
    gl_Position = u_mat4_mvp * vh;
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec3_rotated_scaled_vertex = rotation_scale_mat * vertex;
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    compute_shadow_vertex(gl_Position);
}
`,av=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <round_position>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_identifier;
attribute vec2 a_vec2_dem_position;
varying vec4 v_vec4_identifier;
void main()
{
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        gl_Position = round_position(u_mat4_mvp * vec4(a_vec2_vertex, a_float_z + height, 1.), .5 * u_vec2_vpt_size);
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,rv=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
uniform float u_float_height_factor;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
varying float v_depth_metric;
void main()
{
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    vec4 vh = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vh.z += height;
    gl_Position = u_mat4_mvp * vh;
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}
`,lv={apply_height_factor:Vm,apply_opacity:Gr,arrow_functions:Zm,calculate_scale:jm,cam_pos:Hr,clipspace_pos:Wm,dem:$m,depth_test:Xm,ecef_mvp_mat:Km,fog:qm,jitter:Ym,line_width:Qm,mix_color_defs:Vr,mvp_mat:Jm,packed_attributes:Am,pixel_offset:ep,pos_world:tp,precision_constants:ip,prelude:np,raster_functions:op,round_position:sp,shadow:ap,show_ratio:rp,signed_distance_functions:Zr,striped_line_functions:lp},cv={arrow_line_entrance:cp,building_shadow:dp,circle_marker:_p,circle_marker_identify:up,color:hp,color_identify:fp,dem_elevation:mp,dem_elevation_copy:pp,dem_flat_bottom:vp,dem_ground:gp,dem_ground2:yp,dem_mesh:xp,dem_mesh2:bp,dem_mesh2_depthtest:wp,dem_normal:Sp,diffuse:Tp,diffuse_identify:Mp,globe:Ep,globe_halo:Ip,gltf_model:Cp,gltf_shadow:Lp,heatmap:Pp,heatmap_texture:Bp,label_directional:zp,label_fixed_anchor:Rp,label_fixed_anchor_identify:Fp,line:Dp,line3d:Op,line3d_identify:Np,map_mesh:kp,mesh:Up,mesh_shadow:Gp,metric_point:Hp,one_way_line:Vp,patterned_line:Zp,point_anchor:jp,pointsprite:Wp,pointsprite_identify:$p,posteffect:Xp,rect_with_texture:Kp,road:qp,road_identify:Yp,simple_line_2d:Qp,simple_line_3d:Jp,simple_mesh:Ap,sky:ev,stars:tv,striped_line:iv,striped_line_identify:nv,wall_texture:ov,zbm_model:sv,zbm_model_identify:av,zbm_shadow:rv},dv=/^\s*#include\s+<(.+)>.*$/gim,_v=(s,e)=>(t,i)=>{const o=i.trim(),a=s==="vertex"?lv[o]:Gm[o];if(!a)throw new Error(`Cannot resolve "include <${o}>" in ${s} shader "${e}"`);return a+`
`};function jr(s,e){return[(s==="vertex"?cv[e]:Hm[e]).replace(dv,_v(s,e))]}function U(s){const e=Mi.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Mi.webglVersion}`,value:""},{type:oh,value:""}]);return i=>new n.Shader("vertex",e.concat(jr("vertex",s)),t,i)}function G(s){const e=Mi.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Mi.webglVersion}`,value:""},{type:nh,value:""}]);return i=>new n.Shader("fragment",e.concat(jr("fragment",s)),t,i)}const Y={name:"u_mat4_mvp",type:"mat4"},yt=[{name:"u_mat4_flat_mvp",type:"mat4"},{name:"u_mat4_ecef_mvp",type:"mat4"},{name:"u_float_crossfade",type:"1f"}],ne={name:"u_mat4_model",type:"mat4"},Jo=[{name:"u_vec2_anchor",type:"2f"},{name:"u_vec4_axis",type:"4f"},{name:"u_int_gltf_dem_pos",type:"1i"}],ie=[{name:"u_tex_dem",type:"1i"},{name:"u_tex_corrected_dem",type:"1i"},{name:"u_float_corrected_interval",type:"1f"},{name:"u_mat4_dem_corrected",type:"mat4"},{name:"u_tex_hillshade_ramp",type:"1i"},{name:"u_mat4_dem_mvp",type:"mat4"},{name:"u_float_dem_scale",type:"1f"},{name:"u_float_vertical_scale",type:"1f"},{name:"u_float_dem_resolution",type:"1f"},{name:"u_float_dem_cell_size",type:"1f"},{name:"u_float_dem_shading_intensity",type:"1f"},{name:"u_float_map_center_elevation",type:"1f"}],ft=[{name:"u_int_abs_z",type:"1i"}],re=[{name:"u_cam_pos",type:"3f"}],ye=[{name:"u_int_light_flags",type:"1i"},{name:"u_vec4_ambient_color",type:"4fv"},{name:"u_vec3_light_dir1_direction",type:"3fv"},{name:"u_vec4_light_dir1_color",type:"4fv"},{name:"u_vec3_light_dir2_direction",type:"3fv"},{name:"u_vec4_light_dir2_color",type:"4fv"}],xe=[{name:"u_texture_shadow",type:"1i"},{name:"u_mat4_clip_to_shadow",type:"mat4"},{name:"u_shadow_map_params",type:"4f"},{name:"u_shadow_bias",type:"1f"}],le=[{name:"u_fog_color",type:"4f"},{name:"u_sky_color",type:"4f"},{name:"u_fog_limits",type:"2f"},{name:"u_fog_horizon_blend",type:"1f"},{name:"u_fog_horizon_level",type:"1f"},{name:"u_fog_horizon_pad",type:"1f"},{name:"u_mat4_model",type:"mat4"},{name:"u_fog_distance",type:"1f"},{name:"u_mat4_proj_inverted",type:"mat4"},{name:"u_mat4_view_transposed",type:"mat4"}],we=[{name:"u_vec2_camera_jitter",type:"2f"}];function uv(){return{simpleMesh:{buildFragment:G("simple_mesh"),buildVertex:U("simple_mesh"),attributes:[{name:"a_vec3_position",location:0},{name:"a_vec3_normal",location:1}],uniforms:[Y,{name:"u_float_scale",type:"1f"},{name:"u_vec3_transform",type:"3fv"}]},diffuse:{buildVertex:U("diffuse"),buildFragment:G("color_with_z_fade"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_is_roof",type:"1i"},...re,...ye,...xe,...ie,...le,...we],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3},{name:"a_vec2_tex_coords",location:4}]},gradientDiffuse:{buildVertex:U("diffuse"),buildFragment:G("gradient_with_z_fade"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_vec2_floor_level",type:"2fv"},{name:"u_int_is_roof",type:"1i"},...re,...ye,...xe,...ie,...le,...we],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3}]},wallTexture:{buildVertex:U("wall_texture"),buildFragment:G("wall_texture"),uniforms:[Y,ne,{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_vec4_wall_padding_su",type:"4fv"},{name:"u_vec4_texture_padding_un",type:"4fv"},{name:"u_vec2_texture_part_count",type:"2fv"},{name:"u_vec2_max_interval_su",type:"2fv"},{name:"u_vec2_texture_slice_size_su",type:"2fv"},{name:"u_ivec2_layout_mode",type:"2iv"},{name:"u_int_texture_index",type:"1i"},...re,...ye,...xe,...ie,...le,...we],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3},{name:"a_vec2_wall_size",location:4},{name:"a_vec2_quad_fraction",location:5}]},labelLine:{buildVertex:U("label_directional"),buildFragment:G("label_directional"),uniforms:[Y,ne,{name:"u_float_tile_to_pixel_ratio",type:"1f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_buffer",type:"1f"},{name:"u_float_gamma",type:"1f"},{name:"u_float_scale",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_style_zoom",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},...re,...le],attributes:[{name:"a_vec4_position",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec2_texcoord",location:2},{name:"a_vec2_style_zoom_limits",location:3}]},labelPoint:{buildVertex:U("label_fixed_anchor"),buildFragment:G("label"),uniforms:[...yt,ne,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_buffer",type:"1f"},{name:"u_float_gamma",type:"1f"},{name:"u_float_scale",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_vec4_hidden_color",type:"4fv"},{name:"u_float_label_index",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_height_factor",type:"1f"},{name:"u_depth_tex_labeling",type:"1i"},{name:"u_color_tex_labeling",type:"1i"},{name:"u_color_text_sprite_labeling",type:"1i"},{name:"u_vec2_depth_test_half_point_size",type:"2f"},{name:"u_bool_skip_height_factor",type:"1i"},{name:"u_bool_depth_test_disable",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},...re,...ie,...le],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec2_texcoord",location:3},{name:"a_vec2_check_offset",location:4},{name:"a_vec4_tex_identifier",location:5},{name:"a_vec4_sprite_identifier",location:6}]},labelPointIdentify:{buildVertex:U("label_fixed_anchor_identify"),buildFragment:G("color_identify"),uniforms:[...yt,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_float_scale",type:"1f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_floor_elevation",type:"1f"},...ie],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec4_identifier",location:3}]},line:{buildVertex:U("line"),buildFragment:G("line"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_float_floor_elevation",type:"1f"},...re,...ye,...xe,...ie,...le,...we],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_normal",location:2},{name:"a_vec2_normal_delta",location:3},{name:"a_vec3_direction",location:4},{name:"a_float_distance",location:5},{name:"a_vec2_dem_position",location:6},{name:"a_float_visibility",location:7}]},pointSprite:{buildVertex:U("pointsprite"),buildFragment:G("pointsprite"),uniforms:[...yt,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_rounding_factor",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_vec2_opacity",type:"2f"},{name:"u_vec2_rotation",type:"2fv"},{name:"u_depth_tex_labeling",type:"1i"},{name:"u_color_tex_labeling",type:"1i"},{name:"u_color_text_sprite_labeling",type:"1i"},{name:"u_vec2_depth_test_half_point_size",type:"2f"},{name:"u_bool_skip_height_factor",type:"1i"},{name:"u_bool_depth_test_disable",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},...re,...ie,...le],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec2_check_offset",location:3},{name:"a_vec2_texcoord",location:4},{name:"a_vec2_range",location:5},{name:"a_vec2_rescale",location:6},{name:"a_vec4_tex_identifier",location:7}]},pointSpriteIdentify:{buildVertex:U("pointsprite_identify"),buildFragment:G("pointsprite_identify"),uniforms:[...yt,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_height_factor",type:"1f"},{name:"u_vec2_rotation",type:"2fv"},{name:"u_bool_skip_height_factor",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_float_identify_opacity",type:"1f"},...ie],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_offset",location:2},{name:"a_vec2_texcoord",location:3},{name:"a_vec2_range",location:4},{name:"a_vec2_rescale",location:5},{name:"a_vec4_identifier",location:6}]},pointDepthTest:{buildVertex:U("point_anchor"),buildFragment:G("color_identify"),uniforms:[Y,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_floor_elevation",type:"1f"},...ie],attributes:[{name:"a_vec4_position",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec4_identifier",location:2}]},stripedLine:{buildVertex:U("striped_line"),buildFragment:G("striped_line"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"},...re,...le,...we,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6}]},stripedLine3D:{buildVertex:U("striped_line"),buildFragment:G("striped_line"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"},...ie,...re,...le,...we,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_height",location:7}]},patternedLine:{buildVertex:U("patterned_line"),buildFragment:G("patterned_line"),uniforms:[Y,{name:"u_vec2_scales",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_int_pattern_type",type:"1i"},{name:"u_vec4_pattern_params",type:"4fv"},{name:"u_bool_is_3d_line",type:"1i"},ne,...re,...le,...we,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_texture",location:2},{name:"a_vec4_identifier",location:3}]},patternedLine3D:{buildVertex:U("patterned_line"),buildFragment:G("patterned_line"),uniforms:[Y,{name:"u_vec2_scales",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_opacity",type:"1f"},{name:"u_int_pattern_type",type:"1i"},{name:"u_vec4_pattern_params",type:"4fv"},{name:"u_bool_is_3d_line",type:"1i"},ne,...ie,...re,...le,...we,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_texture",location:2},{name:"a_vec4_identifier",location:3},{name:"a_float_height",location:4}]},stripedLineIdentify:{buildVertex:U("striped_line_identify"),buildFragment:G("color_identify"),uniforms:[Y,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6}]},stripedLine3DIdentify:{buildVertex:U("striped_line_identify"),buildFragment:G("color_identify"),uniforms:[Y,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scaler_params",type:"2fv"},{name:"u_float_dash_length",type:"1f"},{name:"u_float_space_length",type:"1f"},{name:"u_float_dash2_length",type:"1f"},{name:"u_vec4_dash_color",type:"4fv"},{name:"u_vec4_space_color",type:"4fv"},{name:"u_vec4_border_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_width_offset",type:"1f"},{name:"u_int_gap_turns_only",type:"1i"},{name:"u_float_opacity",type:"1f"},{name:"u_bool_is_3d_line",type:"1i"},...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texture_widen",location:1},{name:"a_vec2_widen",location:2},{name:"a_float_vertex_distance",location:3},{name:"a_float_component_distance",location:4},{name:"a_float_object_length",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_height",location:7}]},vtxColor:{buildVertex:U("color"),buildFragment:G("textured_color"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_opacity",type:"1f"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_texture_opacity",type:"1f"},{name:"u_float_texture_params",type:"4fv"},{name:"u_float_sprite_texture_coords",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_is_normal_map_textured",type:"1i"},{name:"u_sr2d_texture1",type:"1i"},{name:"u_vec4_normal_map_texture_params",type:"4fv"},{name:"u_vec4_normal_map_sprite_texture_coords",type:"4fv"},{name:"u_int_normal_map_is_animated",type:"1i"},{name:"u_vec4_normal_map_animated_offsets",type:"4fv"},{name:"u_float_metallic",type:"1f"},{name:"u_float_roughness",type:"1f"},{name:"u_vec4_color2",type:"4fv"},{name:"u_sr2d_read_from_target_texture",type:"1i"},{name:"u_float_factor_interpolate_base",type:"1f"},{name:"u_vec4_factor_interpolate_ranges",type:"4f"},{name:"u_int_factor_use_interpolate",type:"1i"},...re,...ye,...xe,...le,...we],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_visibility",location:1},{name:"a_float_mix_factor",location:2}]},vtxColorIdentify:{buildVertex:U("color_identify"),buildFragment:G("color_identify"),uniforms:[Y,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_identifier",location:1},{name:"a_float_visibility",location:2}]},metricPoint:{buildVertex:U("metric_point"),buildFragment:G("metric_point"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_sprite_texture_coords",type:"4fv"},{name:"u_float_floor_elevation",type:"1f"},...re,...le,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},zbmModelIdentify:{buildVertex:U("zbm_model_identify"),buildFragment:G("color_identify"),uniforms:[Y,{name:"u_vec2_vpt_size",type:"2fv"},...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec4_identifier",location:2},{name:"a_vec2_dem_position",location:3}]},buildingIdentify:{buildVertex:U("diffuse_identify"),buildFragment:G("color_identify"),uniforms:[Y,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec4_identifier",location:2},{name:"a_vec2_dem_position",location:3},{name:"a_float_visibility",location:4}]},oneWayLine:{buildVertex:U("one_way_line"),buildFragment:G("one_way_line"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec4_color",type:"4f"},{name:"u_vec4_border_color",type:"4f"},{name:"u_vec2_wing_normal",type:"2f"},{name:"u_vec2_tip_normal",type:"2f"},{name:"u_float_width",type:"1f"},{name:"u_float_length",type:"1f"},{name:"u_float_tip_radius_zpt",type:"1f"},{name:"u_float_wing_radius_zpt",type:"1f"},{name:"u_float_tail_radius_zpt",type:"1f"},{name:"u_float_border_width",type:"1f"},{name:"u_float_border_width_offset",type:"1f"},{name:"u_float_size_factor",type:"1f"},{name:"u_vec2_scale_limits",type:"2fv"},{name:"u_float_tip_height_multiplier",type:"1f"},{name:"u_float_wing_height_multiplier",type:"1f"},{name:"u_float_wing_width_multiplier",type:"1f"},{name:"u_float_opacity",type:"1f"},...re,...le,...we],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_direction",location:1},{name:"a_vec2_widen_direction",location:2}]},zbmModel:{buildVertex:U("zbm_model"),buildFragment:G("zbm_model"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},...re,...ie,...le,...we,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_texcoord",location:2},{name:"a_vec2_dem_position",location:3}]},zbmShadow:{buildVertex:U("zbm_shadow"),buildFragment:G("main_shadow"),uniforms:[Y,{name:"u_float_height_factor",type:"1f"},...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2}]},gltfModel:{buildVertex:U("gltf_model"),buildFragment:G("gltf_model"),uniforms:[...yt,ne,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture_0",type:"1i"},{name:"u_ao_texture",type:"1i"},{name:"u_pbr_texture",type:"1i"},{name:"u_float_identify",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_show_ratio",type:"1f"},{name:"u_float_metallic",type:"1f"},{name:"u_float_roughness",type:"1f"},{name:"u_sampler_map_tex",type:"1i"},{name:"u_vec2_tex_scale",type:"2f"},{name:"u_float_tex_shift_scale",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_extention_to_relief_needed",type:"1i"},{name:"u_int_collapse_height_needed",type:"1i"},...re,...we,...le,...ie,...ye,...xe,...ft,...Jo],attributes:[{name:"position",location:0},{name:"normal",location:1},{name:"tangent",location:2},{name:"a_vec2_instance_position",location:3},{name:"a_vec3_instance_ecef_position",location:4},{name:"a_mat3_instance_matrix",location:5,locationsCount:3},{name:"a_vec4_instance_localid",location:8},{name:"texcoord_color",location:9},{name:"texcoord_ao",location:10},{name:"texcoord_pbr",location:11},{name:"a_float_abs_z",location:12},{name:"a_float_instance_height",location:13}]},gltfModelIdentify:{buildVertex:U("gltf_model"),buildFragment:G("color_identify"),uniforms:[...yt,ne,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_vec4_color",type:"4fv"},{name:"u_sr2d_texture_0",type:"1i"},{name:"u_float_identify",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_show_ratio",type:"1f"},{name:"u_int_identify",type:"1i"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_extention_to_relief_needed",type:"1i"},{name:"u_int_collapse_height_needed",type:"1i"},...re,...le,...ie,...ft,...Jo],attributes:[{name:"position",location:0},{name:"normal",location:1},{name:"tangent",location:2},{name:"a_vec2_instance_position",location:3},{name:"a_vec3_instance_ecef_position",location:4},{name:"a_mat3_instance_matrix",location:5,locationsCount:3},{name:"a_vec4_instance_localid",location:8},{name:"a_float_abs_z",location:12},{name:"a_float_instance_height",location:13},{name:"texcoord_color",location:9},{name:"texcoord_ao",location:10},{name:"texcoord_pbr",location:11}]},gltfModelShadow:{buildVertex:U("gltf_shadow"),buildFragment:G("main_shadow"),uniforms:[...yt,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_show_ratio",type:"1f"},{name:"u_int_extention_to_relief_needed",type:"1i"},{name:"u_int_collapse_height_needed",type:"1i"},...ie,...ft,...Jo],attributes:[{name:"position",location:0},{name:"a_vec2_instance_position",location:3},{name:"a_vec3_instance_ecef_position",location:4},{name:"a_mat3_instance_matrix",location:5,locationsCount:3},{name:"a_float_abs_z",location:12},{name:"a_float_instance_height",location:13}]},simpleLine2d:{buildVertex:U("simple_line_2d"),buildFragment:G("simple_line_2d"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_z_offset",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...re,...we,...ye,...le,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_direction_distance",location:1},{name:"a_float_visibility",location:2}]},simpleLine3d:{buildVertex:U("simple_line_3d"),buildFragment:G("simple_line_3d"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_z_offset",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...re,...we,...ye,...le,...xe,...ie,...ft],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec4_direction_distance",location:2},{name:"a_vec2_dem_position",location:3},{name:"a_float_abs_z",location:4},{name:"a_float_is_pivot",location:5},{name:"a_float_visibility",location:6}]},road:{buildVertex:U("road"),buildFragment:G("road"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},{name:"u_float_shift",type:"1f"},...re,...ye,...le,...we,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec2_shift",location:2}]},roadIdentify:{buildVertex:U("road_identify"),buildFragment:G("road_identify"),uniforms:[Y,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec4_identifier",location:2}]},line3D:{buildVertex:U("line3d"),buildFragment:G("road"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...ie,...re,...ye,...le,...we,...xe,...ft],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_float_height",location:2},{name:"a_float_abs_z",location:3}]},line3DIdentify:{buildVertex:U("line3d_identify"),buildFragment:G("road_identify"),uniforms:[Y,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...ie,...ft],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_float_height",location:2},{name:"a_float_abs_z",location:3},{name:"a_vec4_identifier",location:4}]},entrance:{buildVertex:U("arrow_line_entrance"),buildFragment:G("arrow_line"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scale_limits",type:"2fv"},{name:"u_vec4_color",type:"4f"},{name:"u_vec4_border_color",type:"4f"},{name:"u_vec2_wing_normal",type:"2f"},{name:"u_vec2_tip_normal",type:"2f"},{name:"u_float_width_zpt",type:"1f"},{name:"u_float_tip_radius_zpt",type:"1f"},{name:"u_float_wing_radius_zpt",type:"1f"},{name:"u_float_tail_radius_zpt",type:"1f"},{name:"u_float_tip_height_multiplier",type:"1f"},{name:"u_float_wing_width_multiplier",type:"1f"},{name:"u_float_wing_height_multiplier",type:"1f"},{name:"u_float_border_width_zpt",type:"1f"},{name:"u_float_size_factor",type:"1f"},{name:"u_float_border_width_offset",type:"1f"},{name:"u_float_total_line_length",type:"1f"},{name:"u_float_relative_end_position",type:"1f"},{name:"u_float_vertex_shift",type:"1f"},{name:"u_float_tip_movement_amplitude",type:"1f"},{name:"u_vec2_bounce_direction",type:"2f"},{name:"u_float_opacity",type:"1f"},...re,...le],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_segment_end",location:1},{name:"a_vec4_texture_widen_arrow_widen",location:2},{name:"a_vec2_widen",location:3},{name:"a_vec2_direction",location:4},{name:"a_float_distance_from_start",location:5},{name:"a_float_object_length",location:6},{name:"a_float_type",location:7},{name:"a_vec4_identifier",location:8}]},entranceIdentify:{buildVertex:U("arrow_line_entrance"),buildFragment:G("arrow_line_identify"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec3_projection_scale_style_scale_dpi",type:"3fv"},{name:"u_vec2_scale_limits",type:"2fv"},{name:"u_vec4_color",type:"4f"},{name:"u_vec4_border_color",type:"4f"},{name:"u_vec2_wing_normal",type:"2f"},{name:"u_vec2_tip_normal",type:"2f"},{name:"u_float_width_zpt",type:"1f"},{name:"u_float_tip_radius_zpt",type:"1f"},{name:"u_float_wing_radius_zpt",type:"1f"},{name:"u_float_tail_radius_zpt",type:"1f"},{name:"u_float_tip_height_multiplier",type:"1f"},{name:"u_float_wing_width_multiplier",type:"1f"},{name:"u_float_wing_height_multiplier",type:"1f"},{name:"u_float_border_width_zpt",type:"1f"},{name:"u_float_size_factor",type:"1f"},{name:"u_float_border_width_offset",type:"1f"},{name:"u_float_total_line_length",type:"1f"},{name:"u_float_relative_end_position",type:"1f"},{name:"u_float_vertex_shift",type:"1f"},{name:"u_float_tip_movement_amplitude",type:"1f"},{name:"u_vec2_bounce_direction",type:"2f"},{name:"u_float_opacity",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_segment_end",location:1},{name:"a_vec4_texture_widen_arrow_widen",location:2},{name:"a_vec2_widen",location:3},{name:"a_vec2_direction",location:4},{name:"a_float_distance_from_start",location:5},{name:"a_float_object_length",location:6},{name:"a_float_type",location:7},{name:"a_vec4_identifier",location:8}]},circleMarker:{buildVertex:U("circle_marker"),buildFragment:G("circle_marker"),uniforms:[...yt,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},...re,...le,...ye,...xe,...ie],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_widen",location:2}]},rectWithTexture:{buildVertex:U("rect_with_texture"),buildFragment:G("rect_with_texture"),uniforms:[Y,ne,{name:"u_sr2d_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...le,...re],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},circleMarkerIdentify:{buildVertex:U("circle_marker_identify"),buildFragment:G("color_identify"),uniforms:[...yt,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_width",type:"1f"},...ie],attributes:[{name:"a_vec3_flat_position",location:0},{name:"a_vec3_ecef_position",location:1},{name:"a_vec2_widen",location:2},{name:"a_vec4_identifier",location:3}]},heatmap:{buildVertex:U("heatmap"),buildFragment:G("heatmap"),uniforms:[Y,ne,...re,{name:"u_float_radius",type:"1f"},{name:"u_float_intensity",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...le],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_weight",location:2}]},heatmapTexture:{buildVertex:U("heatmap_texture"),buildFragment:G("heatmap_texture"),uniforms:[ne,{name:"u_sr2d_texture",type:"1i"},{name:"u_sr2d_ramp_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...re,...le],attributes:[{name:"a_vec2_position",location:0}]},demMesh:{buildVertex:U("dem_mesh"),buildFragment:G("dem_mesh"),uniforms:[Y,ne,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...re,...ie,...le,...we,...ye,...xe],attributes:[{name:"a_vec2_position",location:0}]},demGround:{buildVertex:U("dem_ground"),buildFragment:G("dem_ground"),uniforms:[Y,ne,...ie],attributes:[{name:"a_vec2_position",location:0}]},demMesh2:{buildVertex:U("dem_mesh2"),buildFragment:G("dem_mesh2"),uniforms:[Y,ne,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...re,...ie,...le,...we,...ye,...xe,{name:"u_int_identify",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demMesh2DepthTest:{buildVertex:U("dem_mesh2_depthtest"),buildFragment:G("uniform_color"),uniforms:[Y,...ie,{name:"u_vec4_color",type:"4fv"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demGround2:{buildVertex:U("dem_ground2"),buildFragment:G("dem_ground2"),uniforms:[Y,ne,...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demElevationCopy:{buildVertex:U("dem_elevation_copy"),buildFragment:G("dem_elevation_copy"),uniforms:[Y,{name:"u_sr2d_texture",type:"1i"},{name:"u_mat4_dem_corrected",type:"mat4"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},demElevation:{buildVertex:U("dem_elevation"),buildFragment:G("dem_elevation"),uniforms:[Y],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demHillshade:{buildVertex:U("dem_normal"),buildFragment:G("dem_normal"),uniforms:[...ie,...ye,...xe,Y,{name:"u_sr2d_texture",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},demFlatBottom:{buildVertex:U("dem_flat_bottom"),buildFragment:G("dem_flat_bottom"),uniforms:[Y,...ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_centroid",location:1},{name:"a_vec2_extender",location:2}]},mesh:{buildVertex:U("mesh"),buildFragment:G("mesh"),uniforms:[Y,ne,...re,...ie,...ft,...ye,...xe,...le,...we,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_sr2d_texture",type:"1i"},{name:"u_float_texture_opacity",type:"1f"},{name:"u_float_texture_params",type:"4fv"},{name:"u_float_sprite_texture_coords",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},inverse:{buildVertex:U("mesh"),buildFragment:G("inverse"),uniforms:[Y,ne,...re,...ie,...ft,...ye,...xe,...le,...we,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_float_texture_params",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},meshDepthClear:{buildVertex:U("mesh"),buildFragment:G("depth_clear"),uniforms:[Y,ne,...re,...ie,...ft,...ye,...xe,...le,...we,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_float_texture_params",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},mapMesh:{buildVertex:U("map_mesh"),buildFragment:G("map_mesh"),uniforms:[Y,ne,...re,...ie,...ye,...xe,...ft,...le,...we,{name:"u_float_tile_size",type:"1f"},{name:"u_sampler_map_tex",type:"1i"},{name:"u_vec2_tex_scale",type:"2f"},{name:"u_float_tex_shift_scale",type:"1f"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_int_identify",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_extender",location:2},{name:"a_vec3_normal",location:3},{name:"a_float_gradient",location:4},{name:"a_vec2_dem_position",location:5},{name:"a_float_abs_z",location:6},{name:"a_float_is_pivot",location:7}]},sky:{buildVertex:U("sky"),buildFragment:G("sky"),uniforms:[ne,...re,...le],attributes:[{name:"a_vec2_vertex",location:0}]},taa:{buildVertex:U("posteffect"),buildFragment:G("taa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_float_mix_coef",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0}]},fxaa:{buildVertex:U("posteffect"),buildFragment:G("fxaa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_vec2_vpt_size",type:"2f"}],attributes:[{name:"a_vec2_vertex",location:0}]},copy:{buildVertex:U("posteffect"),buildFragment:G("copy"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_depth",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0}]},buildingShadow:{buildVertex:U("building_shadow"),buildFragment:G("main_shadow"),uniforms:[...ie,Y,{name:"u_float_height_factor",type:"1f"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_visibility",location:3}]},meshShadow:{buildVertex:U("mesh_shadow"),buildFragment:G("main_shadow"),uniforms:[Y,{name:"u_float_height_factor",type:"1f"},...ie,...ft],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2},{name:"a_float_abs_z",location:3},{name:"a_float_visibility",location:4},{name:"a_float_is_pivot",location:5}]},globe:{buildVertex:U("globe"),buildFragment:G("globe"),uniforms:[...yt,{name:"u_sr2d_flatmap_texture",type:"1i"},{name:"u_vec4_extent",type:"4f"}],attributes:[{name:"a_vec3_ecef_position",location:0},{name:"a_vec3_flat_position",location:1},{name:"a_vec2_texture",location:2}]},globeHalo:{buildVertex:U("globe_halo"),buildFragment:G("globe_halo"),uniforms:[{name:"u_vec2_halo_viewport_size",type:"2f"},{name:"u_vec2_halo_viewport_center_shift",type:"2f"},{name:"u_vec4_halo_radius_stops",type:"4f"},{name:"u_vec4_halo_color",type:"4f"},{name:"u_float_halo_exp_factor",type:"1f"},{name:"u_vec4_default_background_color",type:"4f"}],attributes:[{name:"a_vec2_vertex",location:0}]},stars:{buildVertex:U("stars"),buildFragment:G("stars"),uniforms:[{name:"u_mat4_stars",type:"mat4"},{name:"u_float_pixelratio",type:"1f"},{name:"u_float_stars_intensity",type:"1f"}],attributes:[{name:"a_vec3_position",location:0},{name:"a_fade_opacity",location:1}]},globeHaloBackground:{buildVertex:U("globe_halo"),buildFragment:G("globe_halo_background"),uniforms:[{name:"u_vec2_halo_viewport_size",type:"2f"},{name:"u_vec2_halo_viewport_center_shift",type:"2f"},{name:"u_vec4_halo_radius_stops",type:"4f"},{name:"u_vec4_halo_color",type:"4f"},{name:"u_float_halo_exp_factor",type:"1f"},{name:"u_vec4_default_background_color",type:"4f"}],attributes:[{name:"a_vec2_vertex",location:0}]}}}function hv(s,e){if(window.requestIdleCallback)for(const t in e){const i=t;window.requestIdleCallback(()=>{if(s.isContextLost())return;const o=s.getShaderProgram(i);o.link(),setTimeout(()=>{window.requestIdleCallback(()=>{s.isContextLost()||o.locate()})},2e3)})}}class Wr{constructor(e){this.params=e,this._uniformsMap={},this._buffer=null,this._data=null,this._gl=e.gl}bind(e){const t=this._gl,i=e.getUboBinding(this.params.blockName);i!==void 0&&(this._buffer||this.prepare(e),t.bindBufferBase(t.UNIFORM_BUFFER,i,this._buffer))}updateData(e,t){this._buffer||this.prepare(e);const i=this._data;for(const o in t)if(o in this._uniformsMap){const a=t[o],r=this._uniformsMap[o]/4,l=e.uniforms[o];if(l!=null&&l.isNonFloatType()&&n.log(`[UBO Warn]: Currenty only float uniform types are supported. Uniform "${o}" has unsupported type`),n.isTypedArray(a)||n.isArrayOfNumbers(a))for(let c=0;c<a.length;++c)i[r+c]=a[c];else i[r]=a}}commitData(){if(!this._data)return;const e=this._gl;e.bindBuffer(e.UNIFORM_BUFFER,this._buffer),e.bufferData(e.UNIFORM_BUFFER,this._data,e.DYNAMIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null)}cleanup(){this._buffer&&this._gl.deleteBuffer(this._buffer)}prepare(e){const t=this._gl;this._buffer=t.createBuffer();const i=e.getUniformBlocksMap();if(!i){console.error("Failed to initialize UBO. Uniform blocks are not supported.");return}const o=e.getUniformBlockSize(this.params.blockName);if(o===null){console.error("Failed to initialize UBO. Invalid UBO block is provided.");return}this._data=new Float32Array(new ArrayBuffer(o));const a=i[this.params.blockName];a||console.error(`UBO block "${this.params.blockName}" not found in shader program.`);const r=e.getUniformsIndicesOffsetsInBlock(a);if(!r){console.error("Failed to initialize UBO. Couldn't retrieve uniforms information.");return}this._uniformsMap=r}}var Ao=(s=>(s[s.CACHED=0]="CACHED",s[s.RENDER_UNDER_CACHE=1]="RENDER_UNDER_CACHE",s[s.RENDER_OVER_CACHE=2]="RENDER_OVER_CACHE",s))(Ao||{});const Ti=1/0,Mn=-1/0,En="renderCacheManager",fv=[0,0,0,0];class mv{constructor(e,t){this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.cacheObjectsCount=0,this.animationLayersOverCacheMinIndex=Ti,this.animationLayersUnderCacheMaxIndex=Mn,this.state=e,this.modules=t,this.cacheFramebufferId=void 0,this.isReadyCache=!1,this.isLowZoom=this.state.zoom<6,this.cacheDisabled=this.state.disableRenderingCache,this.animationLayersUniqueIds=new Set,this.debugMode=!1,this.debugSkipRenderToCanvas=!1,this.cachedLayersMap=new Map}isLayerAnimated(e,t){const i=this.getUniqueRenderIndex(e,t);return!!this.animationLayersUniqueIds.has(i)}isLayerInCache(e,t){if(!this.isReadyCache)return!1;const i=this.cachedLayersMap.get(e);return!!i&&i.has(t)}frameEnd(){}initInDebugMode(){this.debugMode=!0}setDebugSkipRenderToCanvas(e){this.debugSkipRenderToCanvas=e,this.modules.renderer.addRerenderEvent()}frameStart(){this.cachedLayersMap=new Map,this.cacheObjectsCount=0,this.isLowZoom=this.state.zoom<6,this.isReadyCache=!1;let e=!1;this.cacheDisabled||(this.animationLayersUniqueIds.clear(),this.cacheFramebufferId===void 0&&(this.cacheFramebufferId=this.createCacheFramebuffer()),this.animationLayersOverCacheMinIndex=Ti,this.animationLayersUnderCacheMaxIndex=Mn,this.state.rerenderEvents.forEach(t=>{if(t.type==="layerAnimationTicker"){const i=this.getUniqueRenderIndex(t.styleId,t.layerId,t.underCache);this.animationLayersUniqueIds.add(i),t.underCache?this.animationLayersUnderCacheMaxIndex=Math.max(this.animationLayersUnderCacheMaxIndex,i):this.animationLayersOverCacheMinIndex=Math.min(this.animationLayersOverCacheMinIndex,i)}else e=!0}),this.isReadyCache=!0,(this.animationLayersOverCacheMinIndex!==this.prevFrameAnimationLayerOverCacheIndex||this.animationLayersUnderCacheMaxIndex!==this.prevFrameAnimationLayerUnderCacheIndex)&&(this.isReadyCache=!1),(this.state.needRerender||e)&&(this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.isReadyCache=!1))}tryToCacheObjects(e,t,i,o){if(this.modules.renderer.hasAnimatedFlatObjectInDemMode||this.cacheDisabled||this.cacheFramebufferId===void 0||this.animationLayersOverCacheMinIndex===Ti&&this.animationLayersUnderCacheMaxIndex===Mn||this.isLowZoom||this.animationLayersUnderCacheMaxIndex>=this.animationLayersOverCacheMinIndex||o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forceRenderUnderCacheInDemMode)return 1;const a=this.getUniqueRenderIndex(t.attributes.styleId,t.attributes.layerId);return a>=this.animationLayersOverCacheMinIndex?2:a<=this.animationLayersUnderCacheMaxIndex||(e[this.cacheFramebufferId]||(e[this.cacheFramebufferId]={framebuffer:this.modules.renderer.getFramebuffer(this.cacheFramebufferId),objects:[],tileObjects:new Set}),this.isReadyCache||(e[this.cacheFramebufferId].objects.push(t),e[this.cacheFramebufferId].tileObjects.add(i)),this.cacheObjectsCount++,this.markLayerInCache(t.attributes.styleId,t.attributes.layerId),o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forcePrerenderUnderCacheInDemMode)?1:0}hasReadyCache(){return this.isReadyCache&&!this.cacheDisabled}hasCachedObjects(){return!!this.cacheObjectsCount}render(){var t;if(this.cacheDisabled)return!1;if(this.cacheFramebufferId===void 0||this.cacheObjectsCount===0||this.isLowZoom)return;this.prevFrameAnimationLayerOverCacheIndex=this.animationLayersOverCacheMinIndex,this.prevFrameAnimationLayerUnderCacheIndex=this.animationLayersUnderCacheMaxIndex;const e=(t=this.modules.renderer.getFramebuffer(this.cacheFramebufferId))==null?void 0:t.renderTarget;e&&!this.debugSkipRenderToCanvas&&(this.modules.renderer.storeGpuState(En),this.debugMode?this.modules.renderer.applyGpuState(N_,void 0,!1):this.modules.renderer.applyGpuState(O_,void 0,!1),this.modules.postEffectsManager.copyRenderTargetToCanvas(e,!0,!1),this.modules.renderer.restoreGpuState(En))}destroy(){this.cacheFramebufferId=void 0}markLayerInCache(e,t){let i=this.cachedLayersMap.get(e);i||(i=new Set,this.cachedLayersMap.set(e,i)),i.add(t)}getUniqueRenderIndex(e,t,i){const o=this.modules.styleManager.getStyleLayer(e,t);if(!o)return i?Mn:Ti;const a=this.modules.styleManager.getMaxLayersCount();return-e*a+o.renderIndex}createCacheFramebuffer(){if(!this.modules.renderer.fragDepthSupported()){console.warn("Render cache disabled - Fragment Depth write not supported"),this.cacheDisabled=!0;return}const e=this.modules.renderer.getViewportSize(),t=this.modules.renderer.webglContextState.MAX_TEXTURE_SIZE;if(Math.max(...e)>t){n.log(`Render cache disabled as viewport size ${e[0]}x${e[1]} exceeds hardware limits of ${t}x${t}`),this.cacheDisabled=!0;return}const o=w.NearestFilter,a=this.modules.renderer.getViewportSize(),r=new be({size:[a[0],a[1]],magFilter:o,minFilter:o,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,depthTexture:!0,format:w.RgbaFormat});return this.modules.renderer.addFramebuffer({onResize:()=>{const l=this.modules.renderer.getViewportSize();r.setSize([l[0],l[1]])},renderTarget:r,onRenderStart:()=>{if(this.isReadyCache||this.cacheFramebufferId===void 0)return;const l=this.modules.renderer.getFramebuffer(this.cacheFramebufferId);l&&(this.modules.renderer.bindRenderTarget(l.renderTarget),this.modules.renderer.storeGpuState(En),this.modules.renderer.applyGpuState(k_,void 0,!1),this.modules.renderer.clearWithColor(fv,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.restoreGpuState(En))},onRenderEnd:()=>{},isCacheFramebuffer:!0,useDem:!0,renderIndex:Ti})}}const pv=1.3,vv=2,$r=n.reserveTextureIndex(),Xr=n.reserveTextureIndex(),Kr=n.reserveTextureIndex(),gv=16,yv=0,Ut=[1,1,1,1],qr=new Float64Array(16),es=n.reserveTextureIndex();let Mi=(xt=class extends Ed{constructor(e,t){const i=t.layout.canvas,o=e.webglVersion,a={antialias:!1,stencil:o!==2,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer};let r=null;if((!o||o===2)&&(r=i.getContext("webgl2",a),xt.webglVersion=2),(r===null||o===1)&&(r=i.getContext("webgl",a)||i.getContext("experimental-webgl",a),xt.webglVersion=1),r===null||!(r instanceof WebGLRenderingContext||r instanceof WebGL2RenderingContext))throw new Error("Failed to obtain WebGL context");super({gl:r,clearColor:n.getColorForShaders(e.defaultBackgroundColor)}),this.commonShaderDefines=n.EMPTY_SHADER_DEFINITIONS,this.hasAnimatedFlatObjectInDemMode=!1,this.destroyed=!1,this.framebuffers=[],this.globeRenderTargets=[],this.lastRenderedFramebuffers=[],this.mapMeshMvpMatrix=new Float64Array(16),this.drawTargetsFramebufferIds=new Map,this.ubosMap={},this.lastAppliedGpuState={state:null},this.applyGpuState=(c,d,_=!0)=>{const u=c(this.modules),h=this.lastAppliedGpuState,f=d==null?void 0:d.gpuState;h.state===u&&h.layerState===(d==null?void 0:d.gpuState)||(this.applyState(u,f),_&&(h.state=u,h.layerState=d==null?void 0:d.gpuState))},this.trackContextLost=c=>{this.destroyed||(c.preventDefault(),this.modules.map.emit("error",{type:"webglcontextlost"}),this.modules.map.destroy())},this.debugRenderOnlyCache=!1,this.state=e,this.modules=t;const l=r.getExtension("WEBGL_debug_renderer_info");this.webglContextState={MAX_TEXTURE_SIZE:r.getParameter(r.MAX_TEXTURE_SIZE),MAX_VIEWPORT_DIMS:r.getParameter(r.MAX_VIEWPORT_DIMS),MAX_UNIFORM_BUFFER_BINDINGS:r instanceof WebGLRenderingContext?0:r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS),MAX_COMBINED_UNIFORM_BLOCKS:r instanceof WebGLRenderingContext?0:r.getParameter(r.MAX_COMBINED_UNIFORM_BLOCKS),RENDERER:l?r.getParameter(l.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER),VENDOR:l?r.getParameter(l.UNMASKED_VENDOR_WEBGL):r.getParameter(r.VENDOR)},this.identifyBuffer=new be({minFilter:w.NearestFilter,magFilter:w.NearestFilter}),this.labelingTextureBuffer=new be({size:this.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,depthTexture:!0}),this.spriteLabelingTextureBuffer=new be({size:this.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,depthTexture:!1}),this.shaderProgramOptions=uv(),this.shaderPrograms={},t.map.once("idle",()=>hv(this,this.shaderProgramOptions)),this.symbolSettingsList=Sf(),this.addExtension("OES_vertex_array_object").addExtension("OES_element_index_uint").addExtension("OES_standard_derivatives").addExtension("OES_texture_float").addExtension("OES_texture_float_linear").addExtension("ANGLE_instanced_arrays").addExtension("WEBGL_depth_texture").addExtension("EXT_frag_depth").addExtension("EXT_blend_minmax"),xt.webglVersion===2&&this.addExtension("EXT_color_buffer_float"),this.setPixelRatio(window.devicePixelRatio).setSize(t.layout.mapContainer.clientWidth,t.layout.mapContainer.clientHeight),e.collectStats&&(this.timers=new Tf(this._gl)),t.layout.canvas.addEventListener("webglcontextlost",this.trackContextLost)}get isDestroyed(){return this.destroyed}setDebugRenderOnlyCache(e){this.debugRenderOnlyCache=e,this.modules.renderer.addRerenderEvent()}getViewportSize(e=1){const t=this.getPixelRatio();return this.state.size.map(i=>Math.floor(i*t/e))}setClearColor(e){const t=n.getColorForShaders(e);if(!n.deepEqual(t,this.clearColor))return this.clearColor=t,this.addRerenderEvent(),this}setSize(e,t){return this.modules.layout.setCanvasSize(e,t),this.updateFrameBuffersSize(),this}updateFrameBuffersSize(){var i;this.framebuffers.forEach(o=>{o&&o.onResize()});const e=this.getPixelRatio(),t=this.state.size.map(o=>Math.ceil(o*e));(i=this.modules.postEffectsManager)==null||i.invalidateSize(),this.identifyBuffer.setSize(t.map(o=>Math.ceil(o*n.identify.pixelDensity))),this.labelingTextureBuffer.setSize(t),this.spriteLabelingTextureBuffer.setSize(t)}clear(e=!0){return this.clearWithColor(this.clearColor,e),this}addRerenderEvent(e){this.state.rerenderEvents.push(e||{type:"coreNeedRerender"})}isNeedRerender(e=!1){return this.state.needRerender||(e?this.state.rerenderEvents.filter(t=>t.type!=="layerAnimationTicker"):this.state.rerenderEvents).length>0}clearWithColor(e,t=!0,i=1){const o=this._gl,a=t===!0?o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT:o.COLOR_BUFFER_BIT,r=t?ya:D_;this.applyGpuState(r),o.clearDepth(i),o.clearColor(e[0],e[1],e[2],e[3]),o.clear(a)}getGlobeRenderTarget(e){if(e=n.clamp(Math.trunc(e),1,4),!this.globeRenderTargets[e]){const t=this._gl,i=n.clamp(self.devicePixelRatio,1,2),o=Math.min(this.webglContextState.MAX_TEXTURE_SIZE,n.GLOBE_TEXTURE_SIZE*e*i),a=new be({size:[o,o],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});this.addFramebuffer({clearColor:[0,0,0,0],renderTarget:a,renderIndex:0,onResize:()=>{},onRenderStart:()=>{t.activeTexture(t.TEXTURE0+es),t.bindTexture(t.TEXTURE_2D,null)}}),this.globeRenderTargets[e]=a}return this.globeRenderTargets[e]}renderTileObjects(e){this.drawTargetsFramebufferIds.forEach(a=>{const r=this.getFramebuffer(a);r&&(r.requestedInCurrentFrame=!1)}),this.state.collectStats&&this.timers&&this.timers.addTimer();let t=!1,i=!1;const o=this.getRenderObjectsByGroups(e,!1);if(this.lastRenderedFramebuffers.forEach(a=>{o.groups.some(r=>r.framebuffer===a)||this.clearFramebuffer(a)}),this.lastRenderedFramebuffers=[],o.groups.forEach(a=>{var p,v,x,g;const{objects:r,tileObjects:l,isUnderCache:c}=a;let{framebuffer:d}=a;const _=this.modules.map.state.demMode&&(d===void 0||d.useDem===!0),u=!d,h=(d==null?void 0:d.isCacheFramebuffer)&&!this.modules.renderCacheManager.hasReadyCache(),f=!d&&this.modules.postEffectsManager.hasActiveEffects();f&&(d=this.modules.postEffectsManager.mainFrameBufferWrapper);const m=vt(this.state,this.modules,o.tiers,d==null?void 0:d.renderTarget,_);if(d)(p=d.onRenderStart)==null||p.call(d),this.lastRenderedFramebuffers.push(d),d.renderTarget.bind(this._gl),this._gl.viewport(0,0,d.renderTarget.options.size[0],d.renderTarget.options.size[1]),d.clearColor&&(!f||f&&c)&&this.clearWithColor(d.clearColor,!!d.clearDepth);else{const{size:y,viewport:b}=this.state,M=window.devicePixelRatio;this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.viewport(b.left*M,b.bottom*M,y[0]*M,y[1]*M),u&&c&&this.clear(!0)}if(u||h){u&&c&&this.modules.environmentManager.renderSky();const y=_&&u&&(!this.modules.renderCacheManager.hasCachedObjects()||this.hasAnimatedFlatObjectInDemMode)&&!t,b=_&&h&&this.modules.renderCacheManager.hasCachedObjects()&&!this.hasAnimatedFlatObjectInDemMode&&!i;o.flatObjectsGroup&&(y||b)&&(b&&(i=!0),y&&(t=!0),this.renderDemMesh(m,o.flatObjectsGroup,!1,d))}if(r.length){const y=(x=(v=d==null?void 0:d.getViewProjectionMatrix)==null?void 0:v.call(d))!=null?x:this.modules.camera.viewProjectionMatrix,b=_?this.modules.demManager.demTextureMatrix:void 0;l.forEach(M=>{M.updateMvpMatrix(y,b)}),Mt(this.state,this.modules,r,m)}u&&c&&this.modules.renderCacheManager.render(),d==null||d.renderTarget.unbind(this._gl),(g=d==null?void 0:d.onRenderEnd)==null||g.call(d),f&&!c&&this.modules.postEffectsManager.render(),this.debugRenderOnlyCache&&u&&!c&&(this.clearWithColor([1,0,1,1],!0),this.modules.renderCacheManager.render())}),this.state.collectStats&&this.timers){this.timers.stopTimer();const a=this.timers.tryToGetFirstTimerValue();a&&this.modules.map.emit("gpuRenderTime",a)}for(const[a,r]of this.drawTargetsFramebufferIds){const l=this.getFramebuffer(r);(!l||!l.requestedInCurrentFrame)&&(this.drawTargetsFramebufferIds.delete(a),this.removeFramebuffer(r))}return this}renderElevation(e){var l,c,d,_;if(!this.state.demMode)return;const t=[];if(e.forEach(u=>u.demChildren.forEach(h=>t.push(h))),!t.length)return;const i=this.modules.demManager.getDemFramebufferId();if(i===n.INVALID_FRAMEBUFFER_ID)return;const o=this.getFramebuffer(i);if(!o)return;const a=vt(this.state,this.modules,void 0,o.renderTarget);(l=o.onRenderStart)==null||l.call(o),o.renderTarget.bind(this._gl),this._gl.viewport(0,0,o.renderTarget.options.size[0],o.renderTarget.options.size[1]),o.clearColor&&this.clearWithColor(o.clearColor,!!o.clearDepth);const r=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(r)}),Mt(this.state,this.modules,t,a),o.renderTarget.unbind(this._gl),(_=o.onRenderEnd)==null||_.call(o)}renderGround(e){var l,c,d,_;if(!this.state.demMode)return;const t=[];if(e.forEach(u=>u.demGroundChildren.forEach(h=>t.push(h))),!t.length)return;const i=this.modules.demManager.getGroundFramebufferId();if(i===n.INVALID_FRAMEBUFFER_ID)return;const o=this.getFramebuffer(i);if(!o)return;const a=vt(this.state,this.modules,void 0,o.renderTarget,!0,!0);(l=o.onRenderStart)==null||l.call(o),o.renderTarget.bind(this._gl),this._gl.viewport(0,0,o.renderTarget.options.size[0],o.renderTarget.options.size[1]),o.clearColor&&this.clearWithColor(o.clearColor,!!o.clearDepth);const r=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(r,this.modules.demManager.demTextureMatrix)}),Mt(this.state,this.modules,t,a),o.renderTarget.unbind(this._gl),(_=o.onRenderEnd)==null||_.call(o)}renderSpriteLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache())return;const t=this._gl,i=[],o=vt(this.state,this.modules,void 0,this.spriteLabelingTextureBuffer,this.modules.map.state.demMode),a=e.filter(r=>r.labelTestChildren[0]);a.forEach(r=>{r.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),a.forEach(r=>{r.labelTestChildren.forEach(l=>{l.attributes.labelTest===!0&&i.push(l)})}),this.spriteLabelingTextureBuffer.bind(t),this.clearWithColor([1,1,1,1]),t.viewport(0,0,this.spriteLabelingTextureBuffer.options.size[0],this.spriteLabelingTextureBuffer.options.size[1]),Mt(this.state,this.modules,i,o),this.spriteLabelingTextureBuffer.unbind(t)}renderLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache()||(this.state.isLabelingDepthTestDisabled=!0,this.state.styleZoom<gv||this.state.pitch===yv||this.state.disableHidingPois))return;const t=this._gl,i=[],o=vt(this.state,this.modules,void 0,this.labelingTextureBuffer,this.modules.map.state.demMode),a=e.filter(r=>r.depthTestChildren[0]);a.forEach(r=>{r.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),a.forEach(r=>{r.depthTestChildren.forEach(l=>{const c=this.modules.styleManager.getStyleLayer(l.attributes.styleId,l.attributes.layerId);(c&&c.type!=="gltfModel"||!(c!=null&&c.style.preventObjectsHiding))&&i.push(l)})}),this.state.isLabelingDepthTestDisabled=!1,this.labelingTextureBuffer.bind(t),this.clearWithColor(n.LABELING_TEXTURE_BACKGROUND_COLOR),t.viewport(0,0,this.labelingTextureBuffer.options.size[0],this.labelingTextureBuffer.options.size[1]),Mt(this.state,this.modules,i,o),this.labelingTextureBuffer.unbind(t)}renderIdentify(e){const t=this._gl,i=this.getRenderObjectsByGroups(e,!0);i.groups.forEach(({objects:o,tileObjects:a,framebuffer:r,isUnderCache:l})=>{var u,h,f;const c=this.modules.map.state.demMode&&(r===void 0||r.useDem===!0),d=r?r.renderTarget:this.identifyBuffer,_=vt(this.state,this.modules,i.tiers,d,c);if(d.bind(t),(d!==this.identifyBuffer||l)&&this.clearIdentify(),c&&i.flatObjectsGroup&&this.renderDemMesh(_,i.flatObjectsGroup,!0),d.bind(t),t.viewport(0,0,d.options.size[0],d.options.size[1]),o.length){const m=(h=(u=r==null?void 0:r.getViewProjectionMatrix)==null?void 0:u.call(r))!=null?h:this.modules.camera.viewProjectionMatrix,p=c?this.modules.demManager.demTextureMatrix:void 0;a.forEach(v=>{v.updateMvpMatrix(m,p)}),Mt(this.state,this.modules,o,_)}d.unbind(t),r==null||r.renderTarget.unbind(this._gl),(f=r==null?void 0:r.onRenderEnd)==null||f.call(r)})}waitForGpuCommandsToFinish(){const e=new Float32Array(4);this.readPixelsFloat(0,0,1,1,e)}readPixelsFloat(e,t,i,o,a){const r=this._gl;r.readPixels(e,t,i,o,r.RGBA,r.FLOAT,a)}getRenderingContext(){return this._gl}getShaderProgram(e,t){var c,d;let i=this.shaderPrograms[e];i||(i={},this.shaderPrograms[e]=i);let o=i[this.commonShaderDefines.hash];o||(o={},i[this.commonShaderDefines.hash]=o);const a=(c=t==null?void 0:t.hash)!=null?c:"",r=(d=t==null?void 0:t.defines)!=null?d:[];let l=o[a];return l||(l=new Cd(this._gl,this.shaderProgramOptions[e],n.Shader.createShaderDefinitions([...this.commonShaderDefines.defines,...r])),o[a]=l),l}enableShaderProgram(e){e.enable()}bindShaderProgram(e,t,i){e.bind(t,i)}destroy(){if(this.destroyed)return;this.lastRenderedFramebuffers=[],this.framebuffers.forEach(t=>{t==null||t.renderTarget.remove()}),this.modules.layout.canvas.removeEventListener("webglcontextlost",this.trackContextLost);const e=this._gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.modules.layout.destroy(),this.mapMeshFramebufferId=void 0,this.mapMeshIdFramebufferId=void 0,this.destroyed=!0}addFramebuffer(e){return this.framebuffers.push(e),this.framebuffers.length-1}getFramebuffer(e){if(e!==n.INVALID_FRAMEBUFFER_ID)return this.framebuffers[e]}removeFramebuffer(e){var t;(t=this.framebuffers[e])==null||t.renderTarget.remove(),this.framebuffers[e]=void 0}setRenderTarget(e){this.currentTarget=e;const t=this._gl;if(e)e.bind(t),t.viewport(0,0,e.options.size[0],e.options.size[1]);else{t.bindFramebuffer(t.FRAMEBUFFER,null);const{size:i,viewport:o}=this.state,a=window.devicePixelRatio;t.viewport(o.left*a,o.bottom*a,i[0]*a,i[1]*a)}}getRenderTarget(){return this.currentTarget}getDrawTargetFramebuffer(e){const t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0)return this.getFramebuffer(t)}doesDrawTargetFramebufferExist(e){const t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0){const i=this.getFramebuffer(t);return i&&i.requestedInCurrentFrame}return!1}getDrawTargetFramebufferId(e){let t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0){const c=this.getFramebuffer(t);return c&&(c.requestedInCurrentFrame=!0),t}const i=this.modules.map.state.demMode,o=this.modules.renderer.getPixelRatio(),a=this.modules.map.state.size,r=new be({size:i?[Math.trunc(a[0]*ze[0]*o),Math.trunc(a[1]*ze[1]*o)]:this.getViewportSize(),magFilter:w.LinearFilter,minFilter:w.LinearFilter,depthTexture:!0,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,generateMipmaps:!1,format:xt.webglVersion===2?w.RedFormat:w.RgbFormat}),l={renderTarget:r,clearColor:[0,0,0,0],clearDepth:!0,onResize:()=>{const c=this.modules.map.state.demMode,d=this.modules.map.state.size;r.setSize(c?[Math.trunc(d[0]*ze[0]*o),Math.trunc(d[1]*ze[1]*o)]:this.getViewportSize()),this.modules.renderer.bindRenderTarget(r),this.modules.renderer.bindRenderTarget(null)},renderIndex:-1/0,useDem:!1,requestedInCurrentFrame:!0};return t=this.modules.renderer.addFramebuffer(l),this.drawTargetsFramebufferIds.set(e,t),t}renderDemMesh(e,t,i=!1,o){const{framebuffer:a,tiles:r}=t;if(!a)return;let l=this.modules.demManager.getFlatMapTextures();if(i&&(l=l.filter(S=>S.detailLevel===0)),!l.length)return;const c=this.modules.demManager.getMeshTiles();if(!c.length)return;const d=c[0],u=(i?d.identifyChildren:d.children).filter(({sink:S})=>S==="mesh"||S==="mesh2")[0];if(!u)return;const h=this.state.handyStyleId,f=this.modules.styleManager.getStyleLayer(h,n.DEM_STYLE_LAYER_ID);if(!f||qo(u))return;const{size:m,viewport:p}=this.state,v=window.devicePixelRatio,{commonBinder:x,programBinder:g,layerBinder:y,programName:b}=u.layerSettings,M=this.getShaderProgram(b),T=[];r.forEach((S,C)=>{T.push({objects:S,tile:C})});const P=e.copy(a.renderTarget,!1,!0);l.forEach(S=>{var j,ee;const I=T.filter(z=>Yr(S.viewport,z.tile.bounds.values())).reduce((z,J)=>(J.tile.updateMvpMatrix(S.mvpMatrix,this.modules.demManager.demTextureMatrix),z.concat(J.objects)),[]),E=[],F=new Map;if(I.forEach(({obj:z,framebufferId:J})=>{if(J===void 0)E.push(z);else{const q=F.get(J);q?q.push(z):F.set(J,[z])}}),F.forEach((z,J)=>{var Te,Ue;const q=this.getFramebuffer(J);q&&((Te=q.onRenderStart)==null||Te.call(q),q.renderTarget.bind(this._gl),this._gl.viewport(0,0,q.renderTarget.options.size[0],q.renderTarget.options.size[1]),q.clearColor&&this.clearWithColor(q.clearColor,!1),Mt(this.state,this.modules,z,P),q.renderTarget.unbind(this._gl),(Ue=q.onRenderEnd)==null||Ue.call(q))}),(j=a.onRenderStart)==null||j.call(a),a.renderTarget.bind(this._gl),this._gl.viewport(0,0,a.renderTarget.options.size[0],a.renderTarget.options.size[1]),a.clearColor&&this.clearWithColor(a.clearColor,!1),Mt(this.state,this.modules,E,P),a.renderTarget.unbind(this._gl),(ee=a.onRenderEnd)==null||ee.call(a),i){this.identifyBuffer.bind(this._gl);const z=this.identifyBuffer.options.size;this._gl.viewport(0,0,z[0],z[1])}else o?(this._gl.viewport(0,0,o.renderTarget.options.size[0],o.renderTarget.options.size[1]),o.renderTarget.bind(this._gl)):this._gl.viewport(p.left*v,p.bottom*v,m[0]*v,m[1]*v);this.enableShaderProgram(M),this._gl instanceof WebGLRenderingContext&&(x==null||x(M,this.state,this.modules)),g==null||g(M,this.state,this.modules,!0),y==null||y(M,this.state,this.modules,f),e.useState(u,f),c.forEach(z=>{if(z instanceof ha&&z.needSync&&z.syncReplicas(this.state),Yr(S.viewport,z.bounds.values())){z.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix,S.texMatrix);const J=(i?z.identifyChildren:z.children).filter(({sink:q})=>q==="mesh"||q==="mesh2");wo(J,this.state,this.modules),e.drawSymbol(J,f,this.state,this.modules)}}),i&&this.identifyBuffer.unbind(this._gl)})}getMapMeshFramebufferId(){return this.mapMeshFramebufferId===void 0&&(this.mapMeshFramebufferId=this.createMapMeshFramebuffer()),this.mapMeshFramebufferId}getMapMeshIdFramebufferId(){return this.mapMeshIdFramebufferId===void 0&&(this.mapMeshIdFramebufferId=this.createMapMeshFramebuffer(!0)),this.mapMeshIdFramebufferId}prerenderUpdate(){const e=this.rebuildExternalShaderDefinitions();this.updateUbos(e)}getRenderObjectsByGroups(e,t){const{demManager:i,map:o}=this.modules,{demMode:a}=o.state,r={},l={framebuffer:void 0,objects:[],tileObjects:new Set},c={framebuffer:void 0,objects:[],tileObjects:new Set,isUnderCache:!0},d={};let _;if(a){const h=t?i.getIdentifyFlatFramebufferId():i.getFlatFramebufferId(),f=this.getFramebuffer(h);f&&(_={framebuffer:f,tiles:new Map})}this.hasAnimatedFlatObjectInDemMode=!t&&a&&e.some(h=>h.children.some(f=>!f.layerSettings.is3dMapAware&&this.modules.renderCacheManager.isLayerAnimated(f.attributes.styleId,f.attributes.layerId))),e.forEach(h=>{(t?h.identifyChildren:h.children).forEach(m=>{var b;if(m.sink==="mesh2")return;const{ids:p,defaultId:v,isDrawTarget:x}=this.modules.styleManager.getFramebufferId(m.attributes.styleId,m.attributes.layerId),g=p?p[m.sink]:v;if(g===n.INVALID_FRAMEBUFFER_ID)return;if(g===void 0||a&&x){const M=m.attributes.tiers;if(this.state.immersiveLevel.tiers&&M){let T=!1;if(M.forEach(P=>{if(!P){T=!0;return}d[P]||(d[P]={objects:[],tileObjects:new Set}),d[P].objects.push(m),d[P].tileObjects.add(h)}),!T)return}if(a&&!m.layerSettings.is3dMapAware)_!=null&&_.tiles.has(h)?(b=_==null?void 0:_.tiles.get(h))==null||b.push({obj:m,framebufferId:g}):_==null||_.tiles.set(h,[{obj:m,framebufferId:g}]),this.hasAnimatedFlatObjectInDemMode||this.modules.renderCacheManager.markLayerInCache(m.attributes.styleId,m.attributes.layerId);else if(t)c.objects.push(m),c.tileObjects.add(h);else{const T=this.modules.renderCacheManager.tryToCacheObjects(r,m,h,a);if(T===Ao.CACHED)return;T===Ao.RENDER_OVER_CACHE?(l.objects.push(m),l.tileObjects.add(h)):(c.objects.push(m),c.tileObjects.add(h))}return}r[g]||(r[g]={framebuffer:this.getFramebuffer(g),objects:[],tileObjects:new Set}),r[g].objects.push(m),r[g].tileObjects.add(h)})});const u=Object.values(r).filter(h=>!!h.framebuffer);return u.sort((h,f)=>{var v,x,g,y;const m=(x=(v=h.framebuffer)==null?void 0:v.renderIndex)!=null?x:0,p=(y=(g=f.framebuffer)==null?void 0:g.renderIndex)!=null?y:0;return m-p}),u.push(c),t||(u.findIndex(f=>{var m;return(m=f.framebuffer)==null?void 0:m.isCacheFramebuffer})>=0?l.objects.push(...this.modules.styleManager.getCustomSceneObjects()):c.objects.push(...this.modules.styleManager.getCustomSceneObjects())),u.push(l),{flatObjectsGroup:_,groups:u,tiers:d}}getUbo(e){return this.ubosMap[e]}getMemoryFootprint(){const e={framebuffers:this.framebuffers.filter(t=>t!==void 0).map(t=>t.renderTarget.memSizeGPU()),identifyBuffer:this.identifyBuffer.memSizeGPU(),labelingTextureBuffer:this.labelingTextureBuffer.memSizeGPU()};return{gpu:de(B({},e),{"--sum":n.getTotalMemory(e)})}}bindRenderTarget(e){const t=this._gl;e?e.bind(t):t.bindFramebuffer(t.FRAMEBUFFER,null)}isUboSupported(){return!(this._gl instanceof WebGLRenderingContext)}isWebgl2Context(){return!(this._gl instanceof WebGLRenderingContext)}fragDepthSupported(){return this.isWebgl2Context()||!!this.modules.renderer.webGlExtensions.EXT_frag_depth}updateUbos(e=!1){var c;const t=this._gl;if(t instanceof WebGLRenderingContext)return;e&&this.cleanupUbos(t);const i=this.getShaderProgram("diffuse");i.link(),i.locate();let o=this.ubosMap.CommonSettings;(!o||e)&&(o=new Wr({gl:t,blockName:"CommonSettings"}),this.ubosMap.CommonSettings=o,o.bind(i)),Dd(i,this.state,this.modules,o),o.commitData();const a=this.modules.map.state,r=!isNaN(a.handyStyleId)&&this.modules.styleManager.getStyle(a.handyStyleId)||void 0,l=(c=r==null?void 0:r.light.lightingModesResolved)!=null?c:n.DEFAULT_LIGHTING_MODES;for(const d in l){let _=this.ubosMap[d];(!_||e)&&(_=new Wr({gl:t,blockName:"LightSettings"}));const u=l[d];_.updateData(i,{u_vec3_light_dir1_direction:u.dir1Direction,u_vec4_light_dir1_color:u.dir1ColorIntensity,u_vec3_light_dir2_direction:u.dir2Direction,u_vec4_light_dir2_color:u.dir2ColorIntensity,u_vec4_ambient_color:u.ambientColorIntensity}),this.ubosMap[d]=_,_.commitData()}}cleanupUbos(e){for(const t in this.ubosMap)this.ubosMap[t].cleanup();this.ubosMap={};for(let t=0;t<this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS;t++)e.bindBufferBase(e.UNIFORM_BUFFER,t,null)}rebuildExternalShaderDefinitions(){const e=this.prepareExternalShaderDefinitions();return this.commonShaderDefines.hash!==e.hash?(this.commonShaderDefines=e,!0):!1}clearIdentify(){const e=this._gl;e.depthMask(!0),e.clearColor(Ut[0],Ut[1],Ut[2],Ut[3]),e.clearDepth(1),e.clearStencil(0),e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)}clearFramebuffer(e){e.clearColor&&(e.renderTarget.bind(this._gl),this._gl.viewport(0,0,e.renderTarget.options.size[0],e.renderTarget.options.size[1]),this.clearWithColor(e.clearColor,!1),e.renderTarget.unbind(this._gl))}createMapMeshFramebuffer(e){const t=this.getRenderingContext(),i=e?w.NearestFilter:w.LinearFilter,{scale:o,size:a}=this.calculateMapMeshParams(e),r=new be({size:a,magFilter:i,minFilter:i,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping}),l={getViewProjectionMatrix:()=>{var _;const c=1-Math.cos(this.modules.map.state.pitch),d=(_=l.scale)!=null?_:this.calculateMapMeshParams(e).scale;return n.fromTranslationScale(qr,[0,c/d[1],0],[1/d[0],1/d[1],1]),n.multiply(this.mapMeshMvpMatrix,qr,this.modules.camera.viewProjectionMatrix),this.mapMeshMvpMatrix},onResize:()=>{const c=this.calculateMapMeshParams(e);l.scale=c.scale,r.setSize(c.size),r.bind(t),r.unbind(t)},renderTarget:r,scale:o};return this.addFramebuffer(l)}calculateMapMeshParams(e){const t=e?n.identify.pixelDensity:1,i=window.devicePixelRatio,o=n.scale$2([],this.modules.map.state.size,i),a=Math.min(pv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[0])/o[0]),r=Math.min(vv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[1])/o[1]),l=[Math.trunc(o[0]*t*a),Math.trunc(o[1]*t*r)];return{scale:[a,r],size:l}}prepareExternalShaderDefinitions(){const e=[];return this.webGlExtensions.EXT_frag_depth&&e.push({type:"HAS_FRAG_DEPTH_EXT"}),this.modules.environmentManager.isFogEnabled()&&e.push({type:sh}),this.modules.environmentManager.isSkyEnabled()&&e.push({type:ah}),this.modules.shadowManager.texture&&e.push({type:mh}),this.state.aaMode===Yt.FXAA?e.push({type:qt.FXAA}):this.state.aaMode===Yt.TAA&&e.push({type:qt.TAA}),Os(this._gl)&&e.push({type:fh}),this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS>0&&e.push({type:ph}),this.state.isDeprecatedSystem?e.push({type:xh}):(e.push({type:vh}),e.push({type:gh})),this.webglContextState.RENDERER.toLowerCase().includes("mali")&&this.webglContextState.VENDOR.toLowerCase().includes("arm")&&e.push({type:yh}),n.Shader.createShaderDefinitions(e)}},xt.webglVersion=NaN,xt);function Yr(s,e){for(const t of e)if(n.tetragonIntersectsBounds(s,t))return!0;return!1}let Ei="./worker.js";function xv(s){Ei=s}function bv(){return Ei}function wv(s,e){return{setMetatile:s.get(n.ThreadName.Parser,"setMetatile"),getMemoryFootprint:s.get(n.ThreadName.Parser,"getMemoryFootprint"),prepareAtlas:s.get(n.ThreadName.Parser,"prepareAtlas"),packRasters:s.get(n.ThreadName.Parser,"packRasters"),fetchTrafficTile:s.get(n.ThreadName.Parser,"fetchTrafficTile"),deleteTrafficTile:s.get(n.ThreadName.Parser,"deleteTrafficTile"),abortTrafficTileRequest:s.get(n.ThreadName.Parser,"abortTrafficTileRequest"),generateTrafficTile:s.get(n.ThreadName.Parser,"generateTrafficTile"),generatePersonalPoi:s.get(n.ThreadName.Parser,"generatePersonalPoi"),syncStyle:s.get(n.ThreadName.Parser,"syncStyle"),GeoJsonSource:e.set("GeoJsonSource",n.GeoJsonSourceWorker,void 0,["fetchTiles"]).get(n.ThreadName.Parser),ZenithSource:e.set("ZenithWorker",n.ZenithWorker,void 0,["fetchTiles"]).get(n.ThreadName.Parser),MeshElevationSource:e.set("MeshElevationWorker",n.MeshElevationWorker,void 0,["fetchTiles"]).get(n.ThreadName.Parser)}}function Sv(s){return{setCommercialPoiRandomSeed:s.get(n.ThreadName.Labeling,"setComPoiRandomSeed"),getMemoryFootprint:s.get(n.ThreadName.Labeling,"getMemoryFootprint"),appendFont:s.get(n.ThreadName.Labeling,"appendFont"),markFontAsLoaded:s.get(n.ThreadName.Labeling,"markFontAsLoaded"),addNewRasterSets:s.get(n.ThreadName.Labeling,"addNewRasterSets"),updatePackingInfo:s.get(n.ThreadName.Labeling,"updatePackingInfo"),syncStyle:s.get(n.ThreadName.Labeling,"syncStyle"),loadRtlPlugin:s.get(n.ThreadName.Labeling,"loadRtlPlugin"),markRtlPluginLoaded:s.get(n.ThreadName.Labeling,"markRtlPluginLoaded")}}function Tv(s){return{ModelsSource:s.set("ModelsWorker",n.ModelsWorker).get(n.ThreadName.Models)}}class Mv{constructor(){this.connector=new n.MainConnector,this.fnRegistry=new n.FnRegistry(this.connector),this.classRegistry=new n.ClassRegistry(this.fnRegistry),this.parserWorker=new Worker(Ei),this.labelingWorker=new Worker(Ei),this.modelsWorker=new Worker(Ei),this.parserWorker.postMessage({msg:{youare:"parser"}}),this.labelingWorker.postMessage({msg:{youare:"labeling"}}),this.connector.addWorker(n.ThreadName.Parser,this.parserWorker),this.connector.addWorker(n.ThreadName.Labeling,this.labelingWorker),this.modelsWorker.postMessage({msg:{youare:"models"}}),this.connector.addWorker(n.ThreadName.Models,this.modelsWorker),this.parser=wv(this.fnRegistry,this.classRegistry),this.labeling=Sv(this.fnRegistry),this.models=Tv(this.classRegistry)}syncStyle(e){this.parser.syncStyle(e),this.labeling.syncStyle(e)}destroy(){this.parserWorker.terminate(),this.labelingWorker.terminate(),this.modelsWorker.terminate()}}function Ev(s=!1){const e=typeof window!="undefined",t=typeof SharedArrayBuffer!="undefined",i=e&&window.crossOriginIsolated===!0,o=typeof OffscreenCanvas!="undefined",a=typeof HTMLCanvasElement!="undefined",r=a&&"transferControlToOffscreen"in HTMLCanvasElement.prototype;s&&(console.log("[render][check] hasWindow:",e),console.log("[render][check] hasSharedArrayBuffer:",t),console.log("[render][check] isCrossOriginIsolated:",i),console.log("[render][check] hasOffscreenCanvas:",o),console.log("[render][check] hasHTMLCanvasElement:",a),console.log("[render][check] hasTransferControlToOffscreen:",r));const l=e&&t&&i&&o&&a&&r;return console.log(`[render] mode: ${l?"worker":"main thread"}`),l}function Iv(){const s=document.createElement("canvas");return s.style.position="absolute",s.style.bottom="100px",s.style.left="0",s.style.width="50%",s.style.height="50%",s.style.pointerEvents="none",s}class Cv{constructor(e,t){var r;if(this.frameWriteSlot=1,this.frameId=0,!e.webgpu)return;const i=Ev();this.transportBuffer=i?new SharedArrayBuffer(n.TRANSPORT_SIZE):new ArrayBuffer(n.TRANSPORT_SIZE),this.transportI32=new Int32Array(this.transportBuffer),this.transportU32=new Uint32Array(this.transportBuffer),this.transportF64=new Float64Array(this.transportBuffer),n.initTransportHeader(this.transportU32);const o=Iv();(r=t.layout.canvas.parentElement)==null||r.appendChild(o);let a;if(i){this.worker=new Worker(bv(),{name:"Render"}),this.worker.postMessage({msg:{youare:"render"}});const l=o.transferControlToOffscreen();a=n.wrap(this.worker)(n.RenderBackendType.WebGPU,n.transfer(l,[l]),this.transportBuffer)}else a=n.createRenderRunner(n.RenderBackendType.WebGPU,o,this.transportBuffer);a.then(l=>this.runner=l).then(()=>t.map.invalidateSize()).then(()=>{var l;return(l=this.runner)==null?void 0:l.start()})}submit(e){const t=n.TransportHeader._Size+this.frameWriteSlot*n.DEFAULT_FRAME_SIZE,i=new Uint8Array(this.transportBuffer,t,e.bytesUsed),o=new Uint8Array(e.buffer,0,e.bytesUsed);i.set(o),this.frameId=this.frameId+1|0,this.transportU32[t+n.FrameHeader.FrameId>>2]=this.frameId,this.transportF64[t+n.FrameHeader.SubmitTime>>3]=performance.now(),this.frameWriteSlot=n.mailboxSwap(this.transportI32,n.TransportHeader.FrameMailbox,this.frameWriteSlot)}resize(e,t,i){return K(this,null,function*(){var o;(o=this.runner)==null||o.resize(e,t,i)})}destroy(){var e;this.worker?(this.worker.terminate(),this.worker=void 0):(e=this.runner)==null||e.destroy(),this.runner=void 0}}class Lv{constructor(e,t){this.idScopes={},this.pixelPackBuffer=null,this.pixelPackBufferSize=0,this.isIdle=()=>this.searchQueue.size===0&&!this.needsUpdate,this.state=e,this.modules=t,this.identifyData=[],this.needsUpdate=!1,this.forceUpdate=!1,this.searchQueue=new Map,this.lastUpdateTime=NaN,this.cacheBusy=!1,this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}])}queryFillCache(){this.needsUpdate=!0}getMemoryFootprint(){var t,i;const e={colorBuffer:(i=(t=this.colorBuffer)==null?void 0:t.byteLength)!=null?i:0};return{js:de(B({},e),{"--sum":n.getTotalMemory(e)})}}resetCache(){this.colorBuffer=void 0,this.queryFillCache()}search(e,t,i=!1){return this.colorBuffer===void 0&&i&&(this.needsUpdate=!0),this.forceUpdate=i,new Promise(o=>{this.searchQueue.set(e,{point:t,resolve:o})})}searchSync(e){return this.searchHigherPriority(e)}update(){if(this.cacheBusy)return;this.stateDiffer.check(this.state)&&(this.resetCache(),this.searchQueue.size>0&&this.searchQueue.clear());const e=this.modules.labeler.isIdle()&&!this.modules.buildingHeightAnimator.isAnimating(),t=Number.isNaN(this.lastUpdateTime)?!0:Date.now()-this.lastUpdateTime>=n.identify.cacheRefreshTime;this.needsUpdate&&(this.forceUpdate||e&&t)&&(this.lastUpdateTime=Date.now(),this.fillCache(),this.needsUpdate=!1,this.forceUpdate=!1),this.colorBuffer!==void 0&&this.searchQueue.size>0&&(this.searchQueue.forEach(i=>{i.resolve(this.searchHigherPriority(i.point))}),this.searchQueue.clear())}getIdScope(e){return this.idScopes[e]||(this.idScopes[e]=new n.IdScope(this)),this.idScopes[e]}readIdentifyPixels(e=!1){return K(this,null,function*(){const t=this.modules.renderer.getRenderingContext(),i=this.modules.renderer.identifyBuffer,o=i.options.size,a=o[0],r=o[1];if(e||t instanceof WebGLRenderingContext||this.state.forceSyncIdentify){const l=new Uint8Array(a*r*4);return i.bind(t),t.readPixels(0,0,o[0],o[1],t.RGBA,t.UNSIGNED_BYTE,l),i.unbind(t),l}else return this._pendingReadIdentifyPixelsPromise?this._pendingReadIdentifyPixelsPromise:(this._pendingReadIdentifyPixelsPromise=new Promise((l,c)=>{K(this,null,function*(){const d=new Uint8Array(a*r*4);i.bind(t);const _=a*r*4;!this.pixelPackBuffer||this.pixelPackBufferSize!==_?(this.pixelPackBuffer&&t.deleteBuffer(this.pixelPackBuffer),this.pixelPackBuffer=t.createBuffer(),this.pixelPackBufferSize=_,t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.bufferData(t.PIXEL_PACK_BUFFER,_,t.STREAM_READ)):t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.readPixels(0,0,a,r,t.RGBA,t.UNSIGNED_BYTE,0);const u=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);if(t.flush(),!u){i.unbind(t),c("Failed to create sync object"),this._pendingReadIdentifyPixelsPromise=void 0;return}yield this.clientWaitAsync(t,u,0,10),t.deleteSync(u),t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,d),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),i.unbind(t),l(d),this._pendingReadIdentifyPixelsPromise=void 0})}),this._pendingReadIdentifyPixelsPromise)})}destroy(){const e=this.modules.renderer.getRenderingContext();this.pixelPackBuffer&&e instanceof WebGL2RenderingContext&&(e.deleteBuffer(this.pixelPackBuffer),this.pixelPackBuffer=null)}clientWaitAsync(e,t,i,o){return new Promise((a,r)=>{function l(){const c=e.clientWaitSync(t,i,0);if(c===e.WAIT_FAILED){r();return}if(c===e.TIMEOUT_EXPIRED){setTimeout(l,o);return}a()}l()})}searchHigherPriority(e){const{viewport:t}=this.state,i=n.fromValues$1(e[0]-t.left,e[1]-t.top),o=this.state.identifyPickDistance*window.devicePixelRatio;let a=1/0,r,l=!1;const c=n.create$4();for(c[0]=i[0]-o;c[0]<i[0]+o;c[0]++)for(c[1]=i[1]-o;c[1]<i[1]+o;c[1]++){const d=this.searchPointInCache(c);if(!d)continue;const _=d.dynamicObjectId!==void 0;if(_&&(d.phase=this.modules.dynamicStyle.getRenderIndexById(d.layerId)),l&&!_)continue;const u=n.distance(i,c);(!r||!l&&_||d.phase>r.phase||d.phase===r.phase&&u<a)&&(r=d,a=u,_&&(l=!0))}return r}searchPointInCache(e){if(this.colorBuffer===void 0)return;const t=n.identify.pixelDensity*window.devicePixelRatio,i=this.modules.renderer.identifyBuffer.options.size,o=this.state.size;if(e[0]<0||e[0]>o[0]-1||e[1]<0||e[1]>o[1]-1)return;const a=Math.floor(e[0]*t),l=((i[1]-1-Math.floor(e[1]*t))*i[0]+a)*4,c=(this.colorBuffer[l+3]<<24|this.colorBuffer[l+2]<<16|this.colorBuffer[l+1]<<8|this.colorBuffer[l])>>>0;return this.indexToIdentifierResponse(c)}fillCache(){return K(this,null,function*(){if(!this.cacheBusy)try{this.cacheBusy=!0;const e=this.modules.tileManager.getTileObjects();this.modules.renderer.renderIdentify(e),this.colorBuffer=yield this.readIdentifyPixels();const t=this.state.metrics;t.interactive===void 0&&(t.interactive=performance.now()-t.start),this.identifyData=this.modules.tileManager.getDisplayedIdentifyData(),this.modules.modelLayer.getDisplayedIdentifyData().forEach(o=>this.identifyData.push(o));const i=this.modules.personalPoiManager.getIdentifyDataChunk();i!==void 0&&this.identifyData.push(i),this.modules.layers.getDynamicObjectLayers().forEach(o=>{o.getIdentifyData().forEach(a=>this.identifyData.push(a))})}catch(e){console.warn(`Cannot fill cache: ${e}`)}finally{this.cacheBusy=!1}})}indexToIdentifierResponse(e){var t,i,o;for(let a=0;a<this.identifyData.length;a++){const r=this.identifyData[a],{dynamicObjectId:l,ids:c,metatileHash:d,sourceId:_,tileKey:u}=r,{startIndex:h,endIndex:f,idBuffer:m,floorIdBuffer:p,phaseBuffer:v,sublayerBuffer:x,styleIdBuffer:g,layerIdBuffer:y,instanceIdBuffer:b,objectClassBuffer:M,centerBuffer:T,strings:P}=c;if(e<h||e>f)continue;const S=e-h,C=m[S],I=new Uint32Array(x)[S],E=new Uint8Array(b)[S],F=new Uint32Array(M)[S];let j,ee="";const z=p[S],J=this.modules.assetManager.getMetatile(d);if(J){(t=J.reverseDictionaries.db_sublayer)!=null&&t[I]&&(j=J.reverseDictionaries.db_sublayer[I]);const Ge=P[e];Ge!==void 0?ee=Ge.objectClass:ee=(o=(i=J==null?void 0:J.reverseDictionaries.db_object_class)==null?void 0:i[F])!=null?o:""}const q=new Uint16Array(g)[S],Te=new Uint32Array(y)[S],Ue=this.modules.styleManager.getStyleLayer(q,Te);if(!Ue||Ue.type==="custom")return;const De=new Int32Array(T,S*Int32Array.BYTES_PER_ELEMENT*2,2);return{id:C,styleId:q,layerId:Te,floorId:z,phase:new Float32Array(v)[S],dynamicObjectId:l,sourceId:_,tileKey:u,sublayer:j,symbol:Ue.type,instanceId:E,objectClass:ee,center:De[0]!==n.INVALID_IDENTIFY_CENTER_COORD||De[1]!==n.INVALID_IDENTIFY_CENTER_COORD?[De[0],De[1]]:void 0}}}}function Pv(s,e,t){var a;if(s.id===void 0)throw new Error("The layer id must be set.");if(e.layerIdToInnerId[s.id])throw new Error(`The layer with id «${s.id}» already exists in the map style.`);let i=-1;if(t){const r=Object.values(e.groupsById).find(l=>l&&l.id===t);if(r)i=e.layers.findIndex(l=>l.groupId===r.innerId);else{i=e.layers.findIndex(c=>c.id===t);const l=(a=e.layers[i])==null?void 0:a.groupId;if(l!==void 0&&s.type==="group")throw new Error(`Group layer with id «${s.id}» can't be added before layer with id «${t}» in group with innerId «${l}». Layer groups doesn't support nesting.`)}}else i=e.layers.length;if(i===-1)throw new Error(`The layer with beforeId «${t}» doesn't exist in the map style.`);let o=[];if(s.type!=="group"){o=[s];const r=i!==e.layers.length?e.layers[i]:void 0;if(r&&r.groupId!==void 0){const l=e.groupsById[r.groupId];if(!l){n.log(`Для слоя с id «${r.id}» находящегося в группе с groupId «${r.groupId}» отсутствует группа id в стиле c id «${e.id}»`);return}const c=l.layers.findIndex(d=>d.id===r.id);if(c===-1){n.log(`Слой с id «${r.id}» и groupId «${r.groupId}» отсутствует группе в стиле c id «${e.id}»`);return}s.groupId=l.innerId,l.layers.splice(c,0,s),l.layers.forEach((d,_)=>d.groupIndex=_)}}else e.groupsById[s.innerId]=s,e.layerIdToInnerId[s.id]=s.innerId,o=s.layers;e.revision++,e.layers.splice(i,0,...o),o.forEach(r=>{if(e.layersById[r.innerId]=r,e.layerIdToInnerId[r.id]=r.innerId,r.type==="point"||r.type==="polygon"||r.type==="metricPoint"||r.type==="embankment"||r.type==="polygon3d"){const l=Math.max(0,...Object.keys(e.rasterSets.byIndex).map(_=>Number(_))),c=new n.HandyIndexer(l+1);n.makeHandyRasterSets(r,c,e.icons).forEach(_=>{e.rasterSets.byKey[_.key]||(e.rasterSets.byIndex[_.index]=_,e.rasterSets.byKey[_.key]=_)})}}),Qr(e)}function Bv(s,e,t){const i=e.layerIdToInnerId[s];if(i===void 0)return;e.revision++;let o=[];const a=e.groupsById[i];if(a){if(o=a.layers,delete e.groupsById[i],delete e.layerIdToInnerId[a.id],o.length===0)return}else{const l=e.layersById[i];if(!l){n.log(`Слой с id «${s}» есть в списке идентификаторов слоев стиля, но при этом отсутствует в стиле c id «${e.id}»`);return}if(l.groupId!==void 0&&l.groupIndex!==void 0){const c=e.groupsById[l.groupId];c&&(c.layers.splice(l.groupIndex,1),c.layers.forEach((d,_)=>d.groupIndex=_))}o=[l]}const r=e.layers.findIndex(l=>l.id===o[0].id);r!==-1&&(o.forEach(l=>{const{styleManager:c,map:{state:d}}=t,_=c.getRemoveLayerHook(l.innerId);_&&(_(d),c.clearRemoveLayerHook(l.innerId)),delete e.layersById[l.innerId],delete e.layerIdToInnerId[l.id]}),e.layers.splice(r,o.length),Qr(e))}function Qr(s){const e=new n.HandyIndexer;let t;for(const i of s.layers)i.groupId!==void 0&&t&&i.groupId===t.groupId?i.renderIndex=t.renderIndex:i.renderIndex=e.getIndex(),t=i;for(const i in s.groupsById){const o=s.groupsById[i];o&&o.layers[0]&&(o.renderIndex=o.layers[0].renderIndex)}}function zv(s,e,t){const{map:{state:i},collector:o,imageManager:a,renderer:r,tileManager:l}=t;let c;try{c=Rv(i,s,256)}catch(g){console.error(g);return}const d=a.addPreparedTexture(c),{downscale:_}=s.style,{size:u}=i,h=new be({size:[Math.ceil(u[0]*window.devicePixelRatio/_),Math.ceil(u[1]*window.devicePixelRatio/_)],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping}),f=h.getTexture();if(!f){console.error("Can't init HeatMap Layer. Missing FrameBuffer texture");return}const m=a.addPreparedTexture(f),p=r.addFramebuffer({renderTarget:h,clearColor:[0,0,0,0],onResize:()=>{h.setSize([Math.ceil(i.size[0]*window.devicePixelRatio/_),Math.ceil(i.size[1]*window.devicePixelRatio/_)]),r.bindRenderTarget(h),r.bindRenderTarget(null);const g=h.getTexture();g&&a.updatePreparedTexture(m,g)}});n.generateSafely({collector:o,generator:n.HeatmapGenerator.generateTexture,args:[e,s,m,d]});const v=o.getAccumulatedData(),x=new n.TileObject("dynamicObject",v.data,t,i);return l.addObject(x),o.reset(),s.framebufferId={framebuffer:p},g=>{l.removeObject(x),x.clean(g),a.deleteTexture(m),a.deleteTexture(d),r.removeFramebuffer(p)}}function Rv(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=e.style.color,a=[];if(!Fv(o.argument))throw new Error(`Heatmap color must be interpolate expression with 'heatmap-density' argument in layer ${e.id}`);const r=t-1;for(let l=0;l<t;l++){const c=l/r,d=n.sampleColor(o,c,i);a.push(...d.value)}return new w(new Uint8Array(a),{size:[t,1]})}function Fv(s){return typeof s=="object"&&s.type==="heatmap-density"}const Jr=1,Ar={type:"color",value:[0,0,0,0]};class Dv{constructor(e){this.modules=e,this.customLayers=new Map,this.maxCountStyleLayers=1e4,this.styleIndex=Jr,this.handyStylesMap=new Map,this.waitingStyleRequests=new Map,this.onRemoveLayerHooks=new Map}createStyle(e,t,i){const{state:o}=this.modules.map;if(!Number.isNaN(o.handyStyleId)){const c=this.getStyle(o.handyStyleId);c&&(c.layers.forEach(d=>{const _=this.onRemoveLayerHooks.get(d.innerId);_&&_(o)}),this.onRemoveLayerHooks.clear())}const a=this.styleIndex++;a-n.UNUSED_STYLE_ID_SHIFT>0&&this.handyStylesMap.delete(a-n.UNUSED_STYLE_ID_SHIFT);const r=n.makeHandyStyle(e,a,i);n.applyStyleOptions(r,t),this.handyStylesMap.set(r.id,r),this.setMaxLayersCount(r.layers.length);const l=this.waitingStyleRequests.get(a);return l&&l.resolve(r),this.modules.workers.syncStyle(r),r.layers.forEach(c=>this.initHandyLayer(a,c)),r}hasLayer(e){const t=this.getStyle(this.modules.map.state.handyStyleId);return(t==null?void 0:t.layerIdToInnerId[e])!==void 0}addLayer(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);if(!i){console.error('Cannot add layer before map style was completely set. Please use "styleload" event.');return}const o=n.makeHandyGroupOrLayer(e);o&&(Pv(o,i,t),this.setMaxLayersCount(i.layers.length),e.type==="custom"&&o.type==="custom"?this.initCustomLayer(i.id,o,e.render,e.onRemove,e.onAdd):this.initHandyLayer(i.id,o),this.modules.workers.syncStyle(i))}setTerrainStyle(e){const t=this.getStyle(this.modules.map.state.handyStyleId);t&&(t.dem=n.makeHandyDemLayer(e),this.modules.demManager.onTerrainStyleChange(),this.modules.renderer.addRerenderEvent())}addIcon(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);if(!i)return console.error('Cannot add icons before map style was completely set. Please use "styleload" event.'),!1;const o=i.layers.filter(d=>(d.type==="point"||d.type==="metricPoint")&&d.style.iconImage!==void 0&&n.expressionValues(d.style.iconImage).some(_=>_===e)),a=i.layers.filter(d=>(d.type==="polygon"||d.type==="embankment"||d.type==="polygon3d")&&!!d.style.textureImage&&n.expressionValues(d.style.textureImage).some(_=>_===e));if(!!i.icons[e])return console.error(`The icon with the name ${e} already exists.`),!1;const l=Math.max(0,...Object.keys(i.rasterSets.byIndex).map(d=>Number(d))),c=new n.HandyIndexer(l+1);return i.icons[e]=t,[...o,...a].forEach(d=>{n.getLayerImageProps(d).forEach(({imageType:_,anchor:u})=>{const h=n.makeHandyRasterSet(e,_,c,u,i.icons);i.rasterSets.byIndex[h.index]=h,i.rasterSets.byKey[h.key]=h})}),i.revision++,this.modules.workers.syncStyle(i),!0}removeIcon(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t)return console.error('Cannot remove icons before map style was completely set. Please use "styleload" event.'),!1;delete t.icons[e];let i=!1;return t.layers.filter(o=>o.type==="point"&&!!o.style.iconImage||o.type==="polygon"&&!!o.style.textureImage||o.type==="metricPoint"&&!!o.style.iconImage||o.type==="embankment"&&!!o.style.textureImage||o.type==="polygon3d"&&!!o.style.textureImage).forEach(o=>{n.getLayerImageProps(o).forEach(({image:a,imageType:r,anchor:l})=>{n.expressionValues(a).forEach(c=>{if(c===e){const d=r==="icon"?n.getStaticIconRasterSetKey(c,l[0],l[1]):n.getStaticTextureRasterSetKey(c),_=t.rasterSets.byKey[d];_&&(this.modules.assetManager.removeRasterSet(_,t.id),i=!0)}})})}),i?(t.revision++,this.modules.workers.syncStyle(t),!0):!1}addModel(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);return i?i.modelIndex[e]!==void 0?(console.error(`The model with the name ${e} already exists.`),!1):(i.models.push(t),i.modelIndex[e]=i.models.length-1,i.revision++,this.modules.workers.syncStyle(i),!0):(console.error('Cannot add models before map style was completely set. Please use "styleload" event.'),!1)}removeLayer(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot remove layer before map style was completely set. Please use "styleload" event.');return}n.commPoiLayers.some(i=>i.id===e)||(Bv(e,t,this.modules),this.modules.workers.syncStyle(t))}showLayers(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot hide layer or group before map style was completely set. Please use "styleload" event.');return}this.setLayerVisibility("visible",e,t)}hideLayers(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot hide layer or group before map style was completely set. Please use "styleload" event.');return}this.setLayerVisibility("hidden",e,t)}setDynamicStyle(e){this.handyStylesMap.set(n.DYNAMIC_STYLE_ID,e),this.modules.workers.syncStyle(e)}getStyle(e){return this.handyStylesMap.get(e)}getStyleLayer(e,t){var i;return(i=this.handyStylesMap.get(e))==null?void 0:i.layersById[t]}getStyleRevision(e){var t;return((t=this.getStyle(e))==null?void 0:t.revision)||0}setFramebufferId(e,t,i){var a;const o=(a=this.handyStylesMap.get(e))==null?void 0:a.layersById[t];o&&(o.framebufferId=i)}getFramebufferId(e,t){var o;const i=(o=this.handyStylesMap.get(e))==null?void 0:o.layersById[t];return i!=null&&i.drawToTarget?{ids:void 0,defaultId:this.modules.renderer.getDrawTargetFramebufferId(i.drawToTarget),isDrawTarget:!0}:{ids:i==null?void 0:i.framebufferId,defaultId:void 0,isDrawTarget:!1}}waitForStyle(e){const t=this.handyStylesMap.get(e);if(t)return Promise.resolve(t);const i=this.waitingStyleRequests.get(e);if(i)return i.promise;const o={resolve:void 0,promise:void 0};return o.promise=new Promise(a=>{o.resolve=a}),this.waitingStyleRequests.set(e,o),o.promise}addRemoveLayerHook(e,t){this.onRemoveLayerHooks.set(e,t)}getRemoveLayerHook(e){return this.onRemoveLayerHooks.get(e)}clearRemoveLayerHook(e){this.onRemoveLayerHooks.delete(e)}callCustomLayerRender(e){const t=this.customLayers.get(e);t&&t.renderFunction(this.modules.renderer.getRenderingContext())}getCustomSceneObjects(){const e=[];return this.customLayers.forEach(t=>e.push(t.sceneObject)),e}getMaxLayersCount(){return this.maxCountStyleLayers}getStyleLayerForObject(e){const t=this.getStyle(e.attributes.styleId);return t?t.layersById[e.attributes.layerId]:null}getFeatureFlag(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);return i?i.graphicsPresets[t][e]===!0:!1}getClearColor(){const{map:e,camera:t}=this.modules,{state:i}=e,o=this.handyStylesMap.get(i==null?void 0:i.handyStyleId);if(!o)return i.defaultBackgroundColor;const a=n.makeBinderContext(i.styleZoom,i.styleState,[]),r=n.resolveColor(o.environment.style.skyColor,a),l=i.globeMode?t.globeRatio:0;return n.lerp$1(Ar.value,o.background.color.value,r.value,l),Ar}update(){const e=this.getStyle(this.modules.map.state.handyStyleId);e&&(e.light.lightingModesResolved=n.resolveLightingModes(e.light.lightingModes,n.makeBinderContext(this.modules.map.state.styleZoom,this.modules.map.state.styleState,[],!1)))}setLayerVisibility(e,t,i){const{id:o,type:a}=t;if(o&&i.layersById){const r=i.layerIdToInnerId[o];if(r){const l=i.layersById[r];if(l)l.style&&(l.style.visibility=e);else{const c=i.groupsById[r];c==null||c.layers.forEach(d=>{d&&d.style&&(d.style.visibility=e)})}}}a&&i.layers.forEach(r=>{r.type===a&&(r.style.visibility=e)})}initHandyLayer(e,t){let i;switch(t.type){case"group":t.layers.forEach(o=>this.initHandyLayer(e,o));return;case"heatmap":i=zv(t,e,this.modules);break;case"polygonExtrusion":i=this.initPolygonExtrusionLayer(e,t);break}i&&this.modules.styleManager.addRemoveLayerHook(t.innerId,i)}setMaxLayersCount(e){this.maxCountStyleLayers<e&&(this.maxCountStyleLayers=e)}initCustomLayer(e,t,i,o,a){const r={sceneObject:{type:n.SceneObjectType.Custom,attributes:{styleId:e,layerId:t.innerId,tileData:[]},tile:{zoomLevel:0},layerSettings:{},canRender:!0},layer:t,renderFunction:i};a==null||a(),this.customLayers.set(t.innerId,r),this.modules.styleManager.addRemoveLayerHook(t.innerId,()=>{o==null||o(),this.customLayers.delete(t.innerId)})}initPolygonExtrusionLayer(e,t){const i=this.getStyle(e);if(!i)return;let o=!1;return t.style.sideTextures.forEach((a,r)=>{var _;const l=(_=i==null?void 0:i.icons[a.image])==null?void 0:_.url;if(!l){console.warn(`Texture source for polygonExtrusionSideTexture ${a.image} not found inside style.`);return}const c=n.getUrlForIconMapIcon(l,i,"");this.modules.imageManager.loadTexture(c,{skipAtlasSizeChecking:!0,generateMipmaps:this.modules.renderer.isWebgl2Context(),minFilter:this.modules.renderer.isWebgl2Context()?w.LinearMipMapLinearFilter:w.LinearFilter,imagePadding:0,premultiplyAlpha:!0}).then(u=>{u!==void 0&&!o&&(t.sideTextureIndices[r]=u)})}),()=>{o=!0}}}class It{constructor(){this.events={}}on(e,t){let i=this.events[e];return i||(i=this.events[e]=[]),i.push(t),this}once(e,t){const i=o=>{this.off(e,i),t.call(this,o)};return this.on(e,i),this}off(e,t){const i=this.events[e];if(!i)return this;const o=i.indexOf(t);return o!==-1&&i.splice(o,1),this}emit(e,t){const i=this.events[e];if(!i)return this;const o=i.slice();for(let a=0;a<o.length;a++)o[a].call(this,t);return this}}class Ov{constructor(e){this.modules=e,this.id=n.sourceUuid(),this.type="globe"}destroy(){}update(){}fetchTiles(e){return e.map(()=>Promise.resolve([]))}generateTile(e,t,i){const o=n.createTileInfo(t),a=this.modules.collector,r=this.modules.styleManager.getStyle(i);if(!r||!r.environment)return Promise.resolve({results:[]});n.generateSafely({collector:a,generator:n.GlobeGenerator.sinks.fill.generate,args:[r,r.environment,o]});const l=a.getAccumulatedData();return Promise.resolve({results:[{styleId:i,metatileHash:-1,regionId:-1,collectorOutput:l}]})}abortTileFetches(){}deleteTiles(){}setAttributes(){}getAttributes(){return{}}}const In="gltfModels";let el=class{constructor(e,t){var i,o;this.modules=t,this.type="default",this.id=n.sourceUuid(),this.state=e,this.options={tileServer:e.tileServer,tileSet:e.tileSet,tileProtocol:e.tileProtocol,tileKey:e.tileKey,subdomains:e.subdomains,appId:e.appId,defaultLang:e.tileServerDefaultLang,sessionId:(i=e.tileSessionId)!=null?i:e.sessionId,isDefaultSource:!0,modelsPath:e.defaultSourceModelsRootUrl,promoteId:"id",idScope:n.DEFAULT_ID_SCOPE,identifyAsDefaultSource:!0},this.modelsAppearStrategy=(o=e.defaultSourceModelsAppearStrategy)!=null?o:n.DEFAULT_MODELS_APPEAR_STRATEGY,this.zenithSource=new n.ZenithSourceCore(this.id,this.modules,this.options),this.universeTileLayer=new n.TileLayer(0,n.tiles.maxUniverseZoom,0,n.tiles.maxUniverseZoom,this.modules,e,this.zenithSource,{requestOddTiles:e.mobileSdkMode,useExtendedTilesBounds:!0}),this.universeTileLayer.getLabelingData=()=>{const a=n.TileLayer.prototype.getLabelingData.call(this.universeTileLayer);return this.regionalTileLayer.isBlank()||(a.labelsKeys=[]),a},this.modules.tileManager.addTileLayer(this.universeTileLayer),this.regionalTileLayer=new n.TileLayer(n.tiles.maxUniverseZoom+1,n.tiles.maxRegionalZoom,n.tiles.maxUniverseZoom+1,n.tiles.maxDetailLevel,this.modules,e,this.zenithSource,{requestOddTiles:e.mobileSdkMode}),this.modules.tileManager.addTileLayer(this.regionalTileLayer),this.commercialPoiSource=new n.GeoJsonSourceCore(this.id,this.modules,{url:n.bindUrl("commercialPoi",{host:e.tileServer,tileSet:e.commercialTileSet,protocol:n.tiles.protocol,lang:e.lang}),flipY:!0,identifyAsDefaultSource:!0,promoteId:"db_id"},this.state),this.commercialPoiTileLayer=new n.TileLayer(n.commercialPoi.minZoom,n.commercialPoi.maxZoom,n.commercialPoi.minZoom,n.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL,this.modules,e,this.commercialPoiSource,{viewportPadding:n.MODELS_TILES_VIEWPORT_PADDING}),this.modules.tileManager.addTileLayer(this.commercialPoiTileLayer),this.createModelsSource(),this.modules.sourceStorage.addSource(this)}destroyModelsSource(){this.modelsSource&&(this.modelsSource=null,this.modelsTileLayer&&this.modules.tileManager.removeTileLayer(this.modelsTileLayer))}createModelsSource(){var e;this.modelsSource||(this.modelsSource=new n.GeoJsonSourceCore(this.id,this.modules,{minZoom:n.models.minZoom,maxZoom:n.models.maxZoom,url:n.bindUrl({url:this.state.modelsTilesUrl},{host:this.state.tileServer,tileSet:this.state.modelsTileSet,protocol:n.tiles.protocol,lang:this.state.lang}),ignoreMissingTiles:!0,identifyAsDefaultSource:!0,promoteId:"building_id",modelsPath:(e=this.state.defaultSourceModelsRootUrl)!=null?e:n.bindUrl("gltfModel",{host:this.state.tileServer,tileSet:this.state.tileSet,protocol:n.tiles.protocol,lang:this.state.lang}),flipY:!0,attributes:{sourceName:In}},this.state),this.modelsTileLayer=new n.TileLayer(n.models.minZoom,n.models.maxZoom,n.models.minZoom,n.tiles.maxDetailLevel,this.modules,this.state,this.modelsSource,{viewportPadding:n.MODELS_TILES_VIEWPORT_PADDING}),this.modules.tileManager.addTileLayer(this.modelsTileLayer))}getMemoryFootprint(){const e=B({regionalTileLayer:this.regionalTileLayer.memSizeJs(),universeTileLayer:this.universeTileLayer.memSizeJs(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeJs():{}},this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeJs()}),t=B({regionalTileLayer:this.regionalTileLayer.memSizeGpu(),universeTileLayer:this.universeTileLayer.memSizeGpu(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeGpu():{}},this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeGpu()});return{js:de(B({},e),{"--sum":n.getTotalMemory(e)}),gpu:de(B({},t),{"--sum":n.getTotalMemory(t)})}}destroy(){var e,t;this.modules.tileManager.removeTileLayer(this.universeTileLayer),this.universeTileLayer.destroy(),this.modules.tileManager.removeTileLayer(this.regionalTileLayer),this.regionalTileLayer.destroy(),this.zenithSource.destroy(),this.commercialPoiTileLayer&&(this.modules.tileManager.removeTileLayer(this.commercialPoiTileLayer),this.commercialPoiTileLayer.destroy()),(e=this.commercialPoiSource)==null||e.destroy(),this.modelsTileLayer&&(this.modules.tileManager.removeTileLayer(this.modelsTileLayer),this.modelsTileLayer.destroy()),(t=this.modelsSource)==null||t.destroy(),this.modules.sourceStorage.removeSource(this.id),this.removeGlobeSource()}setAttributes(e){var t,i,o;this.zenithSource.setAttributes(B(B({},e),n.zenithSourceAttrs)),this.universeTileLayer.redraw(),this.regionalTileLayer.redraw(),(t=this.commercialPoiSource)==null||t.setAttributes(e),(i=this.commercialPoiTileLayer)==null||i.redraw(),(o=this.modelsSource)==null||o.setAttributes(de(B({},e),{sourceName:In})),this.modelsTileLayer&&this.modelsTileLayer.redraw()}getAttributes(){return this.zenithSource.getAttributes()}getId(){return this.id}getZoomDirection(){return this.regionalTileLayer.getZoomDirection()}setHoverId(e){this.regionalTileLayer.setHoverId(e)}setDisabledRegionsId(e){this.regionalTileLayer.disabledRegions=e,this.universeTileLayer.disabledRegions=e}resetHoverId(){this.regionalTileLayer.resetHoverId()}setFeatureStateMap(e){var t,i;this.zenithSource.setFeatureStateMap(e),(t=this.modelsSource)==null||t.setFeatureStateMap(e),this.universeTileLayer.onFeatureStateMapChange(),this.regionalTileLayer.onFeatureStateMapChange(),(i=this.modelsTileLayer)==null||i.onFeatureStateMapChange(),this.modules.modelLayer.onFeatureStateMapChange()}generateHoverTile(e,t,i,o,a,r,l,c){return this.zenithSource.generateTile(e,t,i,o,a,r,l,c)}generateModel(e){return this.zenithSource.generateModel(e)}isIdentifiedAsDefault(){return!0}setDataType(e){this.options.dt!==e&&(!this.options.dt||!e||!n.equalArrays(this.options.dt,e))&&(this.options.dt=e,this.regionalTileLayer.redraw())}getDataType(){return this.options.dt}setDataFilter(e){var t;this.zenithSource.setDataFilter(e),(t=this.modelsSource)==null||t.setDataFilter(e)}hasLayer(e){return this.modelsTileLayer===e||this.regionalTileLayer===e||this.universeTileLayer===e||this.commercialPoiTileLayer===e}addGlobeSource(){const{modules:e}=this,t=e.map.state;e.styleManager.getStyleLayer(t.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID)&&(this.globeSource=new Ov(this.modules),this.globeTileLayer=new n.TileLayer(t.minZoom,n.globeConfig.globeMaxZoom,t.minZoom,n.globeConfig.globeMaxZoom,e,e.map.state,this.globeSource),e.tileManager.addTileLayer(this.globeTileLayer))}removeGlobeSource(){this.globeSource&&(this.globeSource.destroy(),this.globeSource=void 0),this.globeTileLayer&&(this.modules.tileManager.removeTileLayer(this.globeTileLayer),this.globeTileLayer.destroy(),this.globeTileLayer=void 0)}isGlobeTilesReady(){return this.globeTileLayer?this.globeTileLayer.viewportTilesReady()&&!this.globeTileLayer.isEmpty():!1}};class Nv extends It{constructor(e,t){super(),this.loadFont=(a,r)=>{let l=this.requestFontRanges.get(a,r);return l||(l=this.createLoadFontRequest(a,r),this.requestFontRanges.set(a,r,l)),l},this.invalidateUsedGltfModels=n.throttle(()=>{var c;const a=new Set;if(this.modules.renderer.isDestroyed)return;const r=this.modules.tileManager.getTileObjects();for(const d of r)for(const _ of d.children){if(!qo(_))continue;const{styleId:u,layerId:h,modelIndices:f,sourceId:m,sourceName:p}=_.attributes,v=this.modules.styleManager.getStyleLayer(u,h);if(!v||v.type!=="gltfModel")continue;const x=this.modules.modelsScene.getCurrentLayerModelId(_.attributes,_.tile);f.forEach(g=>{const y=this.getModel(g,u);if(y){a.add(y);return}if(x===g){const b=this.dataModelIdToUrl[g];if(b){const M=m===this.modules.defaultSource.getId()&&p===In;this.loadModel(b,g,u,!1,v,M)}else this.loadModelByIndex(g,u,v)}})}const l=this.modules.tileManager.getCachedMods();for(const d of l)(c=d.objects)==null||c.forEach(_=>{for(const u of _.children){if(!qo(u))continue;const{styleId:h,layerId:f,modelIndices:m}=u.attributes,p=this.modules.styleManager.getStyleLayer(h,f);if(!p||p.type!=="gltfModel")return;m.forEach(v=>{const x=this.getModel(v,u.attributes.styleId);x&&a.add(x)})}});for(const d in this.models){const _=this.models[d];!_.preserve&&!a.has(_)&&_.status===et.Loaded&&_.usedEmptyScene!==!0?this.removeModel(d):_.usedEmptyScene=!1}},n.workerResetInterval),this.state=e,this.modules=t,this.modelsWorker=new this.modules.workers.models.ModelsSource,this.requestedMetatiles=new Set,this.metatiles={},this.loadedRasters={},this.failedRasters={},this.requestedRasters={},this.requestedSvgs={},this.disableIconCache=e.disableIconCache,this.textures=[],this.fontGlyphs={},this.fontTextures=new n.TwoKeyMap,this.requestFontRanges=new n.TwoKeyMap,this.pendingFontRanges=0,this.loadedFontRanges=0,this.models={},this.dataModelIdToUrl={},this.visibleBuildingIds=new Set,this.metatileLoader=(a,r,l)=>{const c=n.hashToString(r);fetch(a).then(d=>{if(!d.ok)throw new Error(`Failed to load metatile "${c}"`);return d.json()}).then(d=>this.setMetatile(r,l,d)).catch(d=>console.error(d))};const i=(a,r)=>{const l=this.modules.styleManager.getStyle(a);if(!l){console.error(`Not found style ${a} in AssetManager#addNewRasterSets`);return}const{rasterSets:c}=l;r.forEach(d=>{c.byIndex[d.index]=d,c.byKey[d.key]=d})},{fnRegistry:o}=this.modules.workers;o.set("addNewRasterSets",i),o.set("loadFont",this.loadFont),this.setPreparedMetatile(-1,n.fixedMetatile),this.setPreparedMetatile(n.geoJsonMetatileHash,n.createGeoJsonMetatile(Array.from(this.state.modelShowHideEventsSublayers)))}getMemoryFootprint(){const e={textures:this.textures.map(n.textureSizeJs),fontTextures:this.fontTextures.reduce((i,o)=>(i.push(n.textureSizeJs(o)),i),[]),fontGlyphs:Object.values(this.fontGlyphs).reduce((i,o)=>Object.values(o).reduce((a,r)=>{var l,c;return a.push({bitmap:(c=(l=r.bitmap)==null?void 0:l.byteLength)!=null?c:0}),a},i),[]),models:Object.values(this.models).map(n.modelSizeJs).filter(i=>i.buffers.length>0||i.textures.length>0)},t={textures:this.textures.map(n.textureSizeGpu),fontTextures:this.fontTextures.reduce((i,o)=>(i.push(n.textureSizeGpu(o)),i),[]),models:Object.values(this.models).map(n.modelSizeGpu).filter(i=>i.buffers.length>0||i.textures.length>0)};return{js:de(B({},e),{"--sum":n.getTotalMemory(e)}),gpu:de(B({},t),{"--sum":n.getTotalMemory(t)})}}fillDataModelUrlMap(e){for(const t in e)this.dataModelIdToUrl[e[t]]=t}getDataModelUrlById(e){return this.dataModelIdToUrl[e]}loadMetatile(e,t,i){this.requestedMetatiles.has(t)||(this.requestedMetatiles.add(t),this.metatileLoader(e,t,i))}setMetatile(e,t,i){n.renameZenithEnumerationValues(i),i.tileProps=i.tileProps.map(n.zenithToJakartaPropKey);const o=n.prepareMetatile(i);this.setPreparedMetatile(e,o),this.projectMetatileMetadata===void 0&&(this.projectMetatileMetadata={regionId:t,metatileHash:e})}setPreparedMetatile(e,t){this.metatiles[e]=t,this.modules.workers.parser.setMetatile(e,t)}prepareRasters(e,t,i){var c,d,_;const o=this.modules.styleManager.getStyle(e);if(!o){console.error(`Not found style ${e} in AssetManager#prepareRasters`);return}const{rasterSets:a}=o,r=7,l=t.length/r;for(let u=0;u<l;u++){const h=t[u*r],f=t[u*r+1],m=t[u*r+6],p=t[u*r+2],v=t[u*r+3],x=t[u*r+4],g=t[u*r+5],y=a.byIndex[h];if(y.isSvg){const T={rasterIndex:f,rasterSetIndex:h,x:p,y:v,w:x,h:g,anchorX:y.anchorX,anchorY:y.anchorY,atlasIndex:m,isPacked:!0};y.rasters[f]=T,(d=(c=this.requestedSvgs[o.id])==null?void 0:c[h])==null||d.then(P=>{const S=this.textures[T.atlasIndex],{url:C,revokeURL:I}=Ir(P);Er(C,T.w,T.h).then(E=>{S.subImage(E,T.x,T.y),this.modules.renderer.addRerenderEvent(),I&&I()})})}else{const T=(_=y.rasters[f])!=null?_:{rasterIndex:f,rasterSetIndex:h,x:p,y:v,w:x,h:g,anchorX:0,anchorY:0,atlasIndex:m,isPacked:!0};y.rasters[f]=T,T.x=p,T.y=v,T.atlasIndex=m,T.isPacked=!0}this.textures[m]===void 0&&(this.textures[m]=new w(void 0,{size:n.atlasSize,flipY:!1,premultiplyAlpha:!Yc,magFilter:w.LinearFilter,minFilter:w.LinearFilter}),this.modules.renderer.prepareTexture(this.textures[m]));const b=this.textures[m],M=i&&i[u];if(M!==void 0){b.subImage(M,p,v),this.modules.renderer.addRerenderEvent();continue}}this.modules.workers.labeling.updatePackingInfo(e,t)}loadRasters(e){const i=e.length/3;for(let o=0;o<i;o++){const a=e[o*3],r=e[o*3+1],l=e[o*3+2],c=r<<16|l,d=this.modules.styleManager.getStyle(a);if(!d){console.error(`Not found style ${a} in AssetManager#loadRasters`);continue}if(this.loadedRasters[a]||(this.loadedRasters[a]=new Set,this.failedRasters[a]=new Set,this.requestedRasters[a]=new Set),this.requestedRasters[a].has(c))continue;const{rasterSets:_}=d,u=_.byIndex[r];if(u.rasters[l].isPacked===!1){console.error(`Try to load not packed raster ${u.key}`);continue}this.requestedRasters[a].add(c),u.isSvg?this.loadSvg(c,d,r):this.loadPng(c,d,r,l)}}removeRasterSet(e,t){const{key:i,index:o,rasters:a}=e;delete this.requestedSvgs[t][o],a.forEach(({rasterSetIndex:l,rasterIndex:c})=>{var _,u,h;const d=l<<16|c;(_=this.loadedRasters[t])==null||_.delete(d),(u=this.failedRasters[t])==null||u.delete(d),(h=this.requestedRasters[t])==null||h.delete(d)}),e.rasters.length=0;const r=this.modules.styleManager.getStyle(t);r&&(delete r.rasterSets.byIndex[o],delete r.rasterSets.byKey[i])}getMetatile(e){return this.metatiles[e]}getProjectMetadata(){return this.projectMetatileMetadata}getFontGlyphs(e){return this.fontGlyphs[e]||{}}getFontTextureByName(e,t){return this.fontTextures.get(e,t)}isIdle(){let e=0,t=0;for(const i in this.requestedRasters)e+=this.requestedRasters[i].size,t+=this.loadedRasters[i].size+this.failedRasters[i].size;return e===t&&this.pendingFontRanges===this.loadedFontRanges&&this.allModelsLoaded()}dangerouslySetMetatiles(e){this.metatiles=e}dangerouslySetRasters(e,t){this.loadedRasters=e,this.failedRasters=t}loadModelByIndex(e,t,i){const o=this.getModelUniqueKey(e,t);if(this.models[o]!==void 0)return;const a=this.modules.styleManager.getStyle(t);if(a===void 0){n.logGltfError({layer:"prepare",message:"Style not found. Can't determine url"});return}const r=a.models[e];if(r===void 0){n.logGltfError({layer:"prepare",message:`Model with index "${e}" is missing in the style.`});return}const l=n.getModelUrl(r.url,a);this.fetchModel(l,e,o,!1,i,!1)}loadModel(e,t,i,o,a,r,l){const c=this.getModelUniqueKey(t,i);if(this.models[c]!==void 0){l==null||l();return}this.fetchModel(e,t,c,o,a,r,l)}getModel(e,t){return this.models[this.getModelUniqueKey(e,t)]}allModelsLoaded(){for(const e in this.models)if(this.models[e].status===et.Pending)return!1;return!0}isModelLoaded(e,t){const i=this.models[this.getModelUniqueKey(e,t)];return i&&i.status===et.Loaded}removeModel(e){const t=this.models[e];if(t){for(const i of t.scenes)i.objects.forEach(o=>{o.elementsBuffer&&o.elementsBuffer.remove()}),i.objects.splice(0,i.objects.length);t.scenes.splice(0,t.scenes.length),t.buffers.forEach(i=>{i instanceof n.Buffer&&i.remove()}),t.buffers=[],t.textures.forEach(i=>i.remove()),t.textures=[],delete this.models[e]}}fetchModel(e,t,i,o,a,r,l){const{renderer:c}=this.modules,d=this.models[i]=nf(o);this.modelsWorker.loadModel(e,this.state.dracoDecoderUrl).then(_=>{if(_.type==="ok"){if(d.status=et.Loaded,!_.result)return;of(d,c,_.result,t,a,r),this.emit("modelloaded",t),this.modules.renderer.addRerenderEvent(),l==null||l()}else n.logGltfError(_),d.status=et.Failed})}getModelUniqueKey(e,t){return e>=0?`${t},${e}`:String(e)}createLoadFontRequest(e,t){return K(this,null,function*(){this.pendingFontRanges+=1;const i=Number.isNaN(this.state.handyStyleId)?Jr:this.state.handyStyleId;try{const o=yield this.modules.styleManager.waitForStyle(i),a=yield fetch(n.getFontUrl(e,t,o)).then(l=>{if(!l.ok)throw new Error;return l}).catch(()=>(console.error(`Could not load font ${e} for range ${t} fallback to the default font ${n.DEFAULT_FONT}`),fetch(n.getFontUrl(n.DEFAULT_FONT,t,o)).then(l=>{if(!l.ok)throw new Error(`Could not load default font ${n.DEFAULT_FONT} for range ${t}`);return l}))).then(l=>l.arrayBuffer()),r=n.processFont(a);return this.prepareFontAtlas(e,t,r),this.modules.workers.labeling.appendFont(e,r.glyphData),this.loadedFontRanges+=1,this.modules.workers.labeling.markFontAsLoaded(e,t)}catch(o){return console.error(o),this.loadedFontRanges+=1,this.modules.workers.labeling.markFontAsLoaded(e,t)}})}prepareFontAtlas(e,t,i){const{bitmap:o,width:a,height:r,glyphData:l}=i;this.fontGlyphs[e]||(this.fontGlyphs[e]={});for(const d in l)this.fontGlyphs[e][d]=l[d];const c=new w(new Uint8Array(o),{size:[a,r],magFilter:w.LinearFilter,minFilter:w.LinearFilter,format:w.AlphaFormat,premultiplyAlpha:!1,flipY:!1});this.fontTextures.set(e,t,c),this.state.needLabeling=!0}loadPng(e,t,i,o){return K(this,null,function*(){const a=t.rasterSets.byIndex[i],r=a.rasters[o],l=this.textures[r.atlasIndex];let c="";if(a.type===n.RasterSetType.Unique){const d=a.id;a.url?c=n.getSizeDependentImageUrl(a.url,r.w,r.h):c=n.getUrl("dynamicPoi",{host:this.state.tileServer,tileSet:this.state.tileSet,protocol:this.state.tileProtocol,subdomain:n.getSubdomainFromString(this.state.subdomains,d),id:d,width:r.w.toString(),height:r.h.toString(),regionId:String(a.regionId)})}else if(a.type===n.RasterSetType.Static){const d=t.icons[a.name];if(!d){console.error(`There is no appropriate icon config in the style for raster set: "${a.name}"`),this.failedRasters[t.id].add(e);return}c=n.getUrlForIconMapIcon(d.url,t,n.getSubdomainFromString(this.state.subdomains,a.name))}this.modules.workers.parser.prepareAtlas(c).then(d=>K(this,null,function*(){if(d){if(d.isBitmap){if((d.data[0].width!==r.w||d.data[0].height!==r.h)&&a.type===n.RasterSetType.Static){if(r.w<=0||r.h<=0)return;const _=document.createElement("canvas");_.width=r.w,_.height=r.h,_.getContext("2d").drawImage(d.data[0],0,0,_.width,_.height),l.subImage(_,r.x,r.y)}else l.subImage(d.data[0],r.x,r.y);this.modules.renderer.addRerenderEvent()}else yn(d.data[0]).then(_=>{l.subImage(_,r.x,r.y),this.modules.renderer.addRerenderEvent()});this.loadedRasters[t.id].add(e),a.isReady=!0}else this.failedRasters[t.id].add(e)}))})}loadSvg(e,t,i){return K(this,null,function*(){const o=t.rasterSets.byIndex[i];if(!t.iconBaseUrl){console.error(`Attempt to load svg without existing style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const a=t.icons[o.name];if(!a){console.error(`There is no appropriate icon config in the style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const r=n.getUrlForIconMapIcon(a.url,t,n.getSubdomainFromString(this.state.subdomains,o.name));this.requestedSvgs[t.id]||(this.requestedSvgs[t.id]={});let l=this.requestedSvgs[t.id][i];(!l||this.disableIconCache)&&(l=fetch(r,{cache:this.disableIconCache?"no-cache":"default"}).then(c=>{if(!c.ok)throw new Error("Not 2xx response");return c.text()}),this.requestedSvgs[t.id][i]=l);try{const c=yield l,{url:d,revokeURL:_}=Ir(c),u=yield Er(d),h=t.rasterSets.byIndex[i];for(const f of h.rasters){if(f.w<=0||f.h<=0)continue;const m=this.textures[f.atlasIndex];u.width=f.w,u.height=f.h,m.subImage(u,f.x,f.y),this.modules.renderer.addRerenderEvent()}u.remove(),_&&_(),this.loadedRasters[t.id].add(e),h.isReady=!0}catch(c){console.error(`Can't load an SVG for the "${o.name}" raster set. Error: `,c),this.failedRasters[t.id].add(e)}})}}class kv{constructor(e,t,i,o,a,r,l,c){this.modules=e,this.mapState=t,this.cache=i,this.maxStyleZoom=-1/0,this.minStyleZoom=1/0,this.ready=!1,this.useful=!1,this.status="initial",this.model=o,this.key=a,this.selectedIds=r,this.styleId=l,this.styleRevision=c,this.modelRevision=o.revision,this.objects=[]}update(){switch(this.status){case"initial":{this.useful&&(this.loadModel(),this.status="generating");break}case"generating":{if(this.useful&&this.processResponse&&this.model.texturesLoaded){const{objects:{data:e}}=this.processResponse;this.objects=Gv(e,this.modules),this.updateMinAndMaxStyleZoom(this.objects),this.status="generated",this.ready=!0,this.cache.add(this.key,this)}break}}}getIdentifyIds(){var e;return(e=this.processResponse)==null?void 0:e.objects.identifyIds}remove(){this.status==="generated"&&this.cache.remove(this.key),this.status="initial",this.objects.length&&(this.objects.forEach(e=>e.clean(this.mapState)),this.objects=[]),this.ready=!1}canBeRemoved(){return this.status==="initial"}loadModel(){const{model:{regionId:e,metatileHash:t,id:i,sourceModel:{fileName:o,matrix:a,offset:r}}}=this,c={url:n.getUrl("model",{host:this.mapState.tileServer,tileSet:this.mapState.tileSet,protocol:this.mapState.tileProtocol,subdomain:n.getSubdomainFromString(this.mapState.subdomains,o),regionId:e.toString(),name:o}),id:i,regionId:e,metatileHash:t,selected:this.selectedIds.some(d=>d===i),pixelRatio:window.devicePixelRatio,styleState:this.mapState.styleState,styleId:this.mapState.handyStyleId,offset:r,matrix:a};this.modules.defaultSource.generateModel(c).then(d=>{this.model.prepareTextures(d.textures),this.processResponse=d})}updateMinAndMaxStyleZoom(e){this.minStyleZoom=Math.min(...e.map(t=>Math.min(...t.children.map(i=>{var a;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?1/0:(a=o==null?void 0:o.minzoom)!=null?a:-1/0})))),this.maxStyleZoom=Math.max(...e.map(t=>Math.max(...t.children.map(i=>{var a;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?-1/0:(a=o==null?void 0:o.maxzoom)!=null?a:1/0}))))}}function Uv(s,e,t,i,o){const a=e.join("|");return`model=${s}_sId=${t}_sRev=${i}_mRev=${o}_sel=${a}`}function Gv(s,e){var a,r,l;const t=new il(s,e),i=[],o=tl((l=(r=(a=t.children[0])!=null?a:t.identifyChildren[0])!=null?r:t.depthTestChildren[0])!=null?l:t.shadowChildren[0]);return o&&["children","identifyChildren","depthTestChildren","shadowChildren"].forEach(c=>{var u;const d=(u=t.modelMatrices.get(0))!=null?u:n.create$2();n.copy(d,o),t.modelMatrices.set(0,d);let _=t[c].length;for(;_--;){const h=t[c][_],f=tl(h);if(!f||n.exactEquals(d,f))continue;let m=i.find(p=>{const v=p.modelMatrices.get(0);return v?n.exactEquals(v,f):!1});m||(m=new il([],e),m.modelMatrices.set(0,n.copy(n.create$2(),f)),i.push(m)),m[c].push(h),h.tile=m,t[c].splice(_,1)}}),[t,...i]}function tl(s){if(s&&"matrix"in s.attributes)return s.attributes.matrix}class il extends n.TileObjectBase{constructor(e,t){super("model");const{identifier:i}=t;n.spreadTileObjects(t,e,this,i.getIdScope(n.DEFAULT_ID_SCOPE)),this.size=n.tileZoomToSize(this.coords[2]),this.zoomLevel=this.coords[2],this.detailLevel=this.coords[3]}setTileCoords(e,t){}syncReplicas(e){}}class Hv{constructor(e,t,i,o,a,r){var l;this.modules=e,this.mapState=t,this.cache=i,this.regionId=o,this.metatileHash=a,this.sourceModel=r,this.revision=0,this.texturesLoaded=!1,this.textures=[],this.readiness=0,this.id=r.id,this.attributes=(l=r.attributes)!=null?l:{},this.readinessTickerName=`model-readiness-${this.id}`,this.ids=e.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}update(){var e,t;(e=this.currentMod)!=null&&e.useful&&this.currentMod.update(),(t=this.newMod)!=null&&t.useful&&this.newMod.update(),n.update(this.readinessTickerName,{step:(i,o)=>this.readiness=o},this.mapState)}isAnimating(){return n.exist(this.readinessTickerName,this.mapState)}commitMod(){this.newMod&&this.newMod.ready&&(this.currentMod=this.newMod,this.newMod=void 0)}setUsefulMod(){const e=this.mapState.handyStyleId,t=this.modules.styleManager.getStyleRevision(e),i=this.ids.getSelected().filter(o=>o===this.id);if(!this.currentMod&&!this.newMod){this.createNewMod(i,e,t,this.revision);return}if(this.currentMod&&n.deepEqual(this.currentMod.selectedIds,i)&&this.currentMod.styleId===e&&this.currentMod.styleRevision===t&&this.currentMod.modelRevision===this.revision){this.currentMod.useful=!0,this.newMod=void 0;return}if(this.newMod){n.deepEqual(this.newMod.selectedIds,i)&&this.newMod.styleId===e&&this.newMod.styleRevision===t&&this.newMod.modelRevision===this.revision?this.newMod.useful=!0:this.createNewMod(i,e,t,this.revision);return}this.createNewMod(i,e,t,this.revision)}getUsefulMod(){if(this.currentMod&&this.currentMod.useful)return this.currentMod;if(this.newMod&&this.newMod.useful)return this.newMod}getCurrentMod(){return this.currentMod}setAllModsNeedless(){this.currentMod&&(this.currentMod.useful=!1),this.newMod&&(this.newMod.useful=!1)}getOpacity(e){return this.readiness*this.modules.buildingHeightAnimator.getBuildingHeight(e)}getTexture(e){return this.textures[e]}prepareTextures(e){this.texturesLoaded||(e.isBitmap?(this.textures=e.data.map(t=>new w(t,{flipY:!1})),this.texturesLoaded=!0,this.startReadinessTicker()):Promise.all(e.data.map(t=>yn(t))).then(t=>{this.textures=t.map(i=>new w(i,{flipY:!1})),this.texturesLoaded=!0,this.startReadinessTicker()}))}clean(){this.canBeCleaned()&&(this.texturesLoaded&&(this.textures.forEach(e=>e.remove()),this.textures=[],this.texturesLoaded=!1),this.stopReadinessTicker())}canBeCleaned(){return(!this.currentMod||this.currentMod.canBeRemoved())&&(!this.newMod||this.newMod.canBeRemoved())}createNewMod(e,t,i,o){const a=Uv(this.id,e,t,i,o),r=this.cache.get(a);r?(this.newMod=r,this.newMod.useful=!0):this.newMod=new kv(this.modules,this.mapState,this.cache,this,a,e,t,i)}startReadinessTicker(){this.readiness=0,n.start(this.readinessTickerName,{easing:n.buildingAnimation.easing},this.mapState,0,1,n.buildingAnimation.duration,1)}stopReadinessTicker(){this.readiness=0,n.stop(this.readinessTickerName,this.mapState)}}class Vv{constructor(e,t){this.mapState=e,this.modules=t,this.buildingsHeight=new Map,this.models=new Map,this.displayedMods=new Map,this.viewportModels=[],this.requestedModelsInfo=new Set,this.loadedModelsInfo=new Set,this.isStyleUpdateInProgress=!1,this.hiddenBuildingIds=new Set,this.cache=new n.LRU(n.modelCacheSize,(i,o)=>o.remove()),this.ids=t.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}onFeatureStateMapChange(){this.models.forEach(e=>{e.revision++})}update(){this.findViewportModels(),this.mapState.styleZoom>n.loadModelsInfoStyleZoom&&this.modules.tileManager.getViewportTiles().forEach(e=>{e.type==="zenith"&&e.serverMetadata&&e.serverMetadata.forEach(t=>{const i=this.modules.sourceStorage.getSourceById(e.sourceId);if(i!==void 0&&"getUrl"in i){const o=i.getUrl("modelInfo",{regionId:t.regionId.toString()});this.loadModelsInfo(o,t.regionId,t.metatileHash)}else{const o=n.getUrl("modelInfo",{host:this.mapState.tileServer,tileSet:this.mapState.tileSet,protocol:this.mapState.tileProtocol,subdomain:this.mapState.subdomains[0],regionId:t.regionId.toString()});this.loadModelsInfo(o,t.regionId,t.metatileHash)}})}),this.models.forEach(e=>e.setAllModsNeedless()),this.viewportModels.forEach(e=>e.setUsefulMod()),this.models.forEach(e=>e.update()),this.isStyleUpdateInProgress||this.models.forEach(e=>e.commitMod()),this.updateScene(),this.cleanUnnessasaryModels(),this.updateObjectsVisibility()}activateStyleUpdating(){this.isStyleUpdateInProgress=!0}finishStyleUpdating(){this.isStyleUpdateInProgress=!1}redraw(){this.cache.reset(),this.cleanUnnessasaryModels()}isModelsInfoLoaded(e){return this.loadedModelsInfo.has(e)}getTexture(e,t){var i;return(i=this.models.get(e))==null?void 0:i.getTexture(t)}getDisplayedIdentifyData(){const e=[];return this.viewportModels.forEach(t=>{const i=t.getUsefulMod();if(!i)return;const o=i.getIdentifyIds();o&&e.push({metatileHash:t.metatileHash,ids:o})}),e}getOpacity(e,t){var i;return((i=this.models.get(e))==null?void 0:i.getOpacity(t))||0}hasModel(e){return this.models.has(e)}setBuildingHeight(e,t){this.buildingsHeight.set(e,t)}getBuildingHeight(e){return this.buildingsHeight.get(e)||0}isHidden(e){return this.ids.isHidden(e)}getVisibleModelData(e){const t=this.models.get(e);if(!t)return;const i=t.getCurrentMod();if(!i||!i.ready)return;const o=Math.max(t.sourceModel.minZoom,i.minStyleZoom),a=Math.min(t.sourceModel.maxZoom,i.maxStyleZoom),{styleZoom:r}=this.mapState;if(!(r<o||r>=a))return{minStyleZoom:o,maxStyleZoom:a,opacity:this.getOpacity(e,o)}}isIdle(){return this.viewportModelsReady()&&!this.viewportModels.some(e=>e.isAnimating())}viewportModelsReady(){return this.viewportModels.every(e=>{const t=e.getUsefulMod();return t&&t.ready})}setHiddenBuildingIds(e){e.forEach(t=>{this.hiddenBuildingIds.add(t)})}unsetHiddenBuildingIds(e){e.forEach(t=>{this.hiddenBuildingIds.delete(t)})}findViewportModels(){const{styleZoom:e}=this.mapState;this.viewportModels=[],this.models.forEach(t=>{const{bound:i,minZoom:o,maxZoom:a}=t.sourceModel;if(e<o||e>=a)return;const r=this.mapState.styleState._activeFloorIds,l=t.attributes.db_hidden_by_plan_id;if(l&&r.includes(l)||this.modules.floorManager.hasDisplayedFloorBuilding([t.id])||!!!this.modules.assetManager.getMetatile(t.metatileHash)||this.hiddenBuildingIds.has(t.id))return;n.tetragonIntersectsBounds(this.mapState.tilesBounds,i)&&this.viewportModels.push(t)})}updateScene(){let e=!1;const t=new Map;this.viewportModels.forEach(i=>{const o=i.getCurrentMod();o&&o.ready&&t.set(o.key,o)}),this.displayedMods.forEach((i,o)=>{t.has(o)||(i.objects.length&&i.objects.forEach(a=>this.modules.tileManager.removeObject(a)),e=!0)}),t.forEach((i,o)=>{this.displayedMods.has(o)||(i.objects.length&&i.objects.forEach(a=>this.modules.tileManager.addObject(a)),e=!0),this.cache.get(o)}),e&&(this.displayedMods=t,this.modules.renderer.addRerenderEvent(),this.modules.identifier.resetCache())}cleanUnnessasaryModels(){const e=new Set(this.cache.getData().map(t=>t.model));this.models.forEach(t=>{e.has(t)||t.clean()})}loadModelsInfo(e,t,i){this.requestedModelsInfo.has(t)||(this.requestedModelsInfo.add(t),fetch(e).then(o=>{if(!o.ok)throw new Error(`Failed to load models info for region ${t}`);return o.json()}).then(o=>{o.forEach(a=>{if(!a.fileName){console.error(`ZBM source "fileName" is empty. Failed to load model by url: ${e}`);return}const r=new Hv(this.modules,this.mapState,this.cache,t,i,a);this.models.set(r.id,r)}),this.loadedModelsInfo.add(t)}).catch(o=>{this.loadedModelsInfo.add(t),console.error(o)}))}updateObjectsVisibility(){const e=this.ids;this.models.forEach(t=>{var a;const i=((a=this.getVisibleModelData(t.id))==null?void 0:a.opacity)||0,o=e.isHidden(t.id,n.HideLevel.PolygonExtrusion);i>=.5&&!o?e.hide([t.id],n.HideLevel.PolygonExtrusion):i<.5&&o&&e.show([t.id])})}}class Zv{constructor(e){this.modules=e,this.isIdle=()=>!this.isGenerating,this.modCache=new Map,this.isGenerating=!1,this.currentPois=[],this.currentIdSet=new Set,this.currentTrafficState=!1,this.currentSelectedIds=[],this.currentModKey=nl(this.currentTrafficState,this.currentSelectedIds),this.ids=e.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}setPersonalPoi(e){this.currentPois=e;const t=new Set;for(const i of e)t.add(i.id);this.currentIdSet=t,this.modCache.clear(),this.displayedModKey=void 0}redraw(){this.modCache.clear(),this.displayedModKey=void 0}getIdentifyDataChunk(){return this.identifyDataChunk}update(){if(this.regionMetadata===void 0&&(this.regionMetadata=this.modules.assetManager.getProjectMetadata()),this.regionMetadata===void 0)return;this.updateModKey();const e=this.currentModKey,t=this.modCache.get(e);t===void 0&&!this.isGenerating&&this.generate(e,this.currentPois,this.regionMetadata),t!==void 0&&e!==this.displayedModKey&&this.show(e,t,this.regionMetadata)}generate(e,t,i){const{regionId:o,metatileHash:a}=i,r=this.modules.map.state;this.isGenerating=!0,this.modules.workers.parser.generatePersonalPoi(t,o,a,window.devicePixelRatio,this.ids.getSelected(),r.handyStyleId,r.styleState,this.modules.defaultSource.getId()).then(l=>{if(l===void 0){this.isGenerating=!1;return}const{collectorOutput:c,styleId:d}=l,{packedRasters:_,rastersToLoad:u}=c;_!==void 0&&this.modules.assetManager.prepareRasters(d,_),this.modules.assetManager.loadRasters(u),this.modCache.set(e,l),this.isGenerating=!1})}show(e,t,i){const{metatileHash:o}=i,{collectorOutput:{labels:a,identifyIds:r},styleId:l}=t;this.modules.labeler.removeLabels("ppoi"),a.length&&this.modules.labeler.addLabels("ppoi",n.LabelSource.PersonalPoi,[{metatileHash:o,labels:a,styleId:l}]),this.identifyDataChunk={metatileHash:o,ids:r},this.modules.identifier.resetCache(),this.displayedModKey=e}updateModKey(){const e=this.ids.getSelected().filter(i=>this.currentIdSet.has(i)),t=this.modules.trafficTileLayer.isEnabled();(!n.deepEqual(this.currentSelectedIds,e)||this.currentTrafficState!==t)&&(this.currentTrafficState=t,this.currentSelectedIds=e,this.currentModKey=nl(t,e))}}function nl(s,e){return`ppoi_${s}_${e.join("|")}`}let ts=(Zt=class extends n.Evented{constructor(e,t){super(),this.fogFactorBreakpoint=.4,this.demElevation=0,this.demTilesRevision=NaN,this.options=n.applyDefaults(t,Zt.options),this.uniqId=String(n.uniqId()),this.labelKey=`html-${this.uniqId}`,this.modules=e.modules;const i=n.Mercator.fromGeo(this.options.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)},this.screenPoint=[0,0],this.html=jv(this.options),this.isHidden=!0,this.targetOpacity=0,this.modules.layers.addLayer(this),this.mapState=e.state,this.rounder=Wv(!this.options.disableRounding);let{offset:o}=this.options;const{labeling:a}=this.options;a.type!=="none"&&(a.offset!==void 0&&(o=a.offset),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:a.width,height:a.height,position:this.position.normalizedValue,offset:o,labelingGroup:this.getLabelingGroup(),parentPoiId:a.type==="pinnedToPoi"?a.poiId:void 0}))}destroy(){this.removeHtml(),this.modules.labeler.removeLabels(this.labelKey),this.modules.layers.removeLayer(this)}update(){const e=this.checkZoom(),t=this.checkFog(),i=!this.isInvolvedInLabeling()||this.modules.labeler.isLabelBoxSurvived(this.uniqId);e&&t&&i?this.show():this.hide(),this.updatePosition()}setZIndex(e){this.options.zIndex=e,this.html.style.zIndex=String(e)}setContent(e){this.options.html=e,this.html.innerHTML="";const t=document.createElement("div");typeof e=="string"?t.innerHTML=e:t.append(e),this.html.append(t)}setLabelingSize(e,t){this.options.labeling.type!=="none"&&(this.options.labeling.width=e,this.options.labeling.height=t,this.updateLabelBox())}setPosition(e){const t=n.Mercator.fromGeo(e);this.position={userValue:t,normalizedValue:n.normalizeMapPoint(t)},this.mapState.demMode&&this.updateDemElevation(),this.updateLabelBox()}setOffset(e){this.options.offset=[e[0],e[1]],this.updateLabelBox()}setMinZoom(e){this.options.minZoom=e}setMaxZoom(e){this.options.maxZoom=e}getZIndex(){return this.options.zIndex}getOffset(){return this.options.offset}getPosition(){return n.Mercator.toGeo(this.position.userValue)}getHtmlElement(){return this.html.firstChild}dangerouslyGetRootElement(){return this.html}isShown(){return!this.isHidden}show(){if(this.isHidden&&(this.isHidden=!1,this.appendHtml(),this.emit("shown",{id:this.uniqId.toString(),point:[this.screenPoint[0],this.screenPoint[1]],object:this}),this.options.animate)){if(this.showAnimationTimer)return;this.hideAnimationTimer&&(clearTimeout(this.hideAnimationTimer),this.hideAnimationTimer=void 0),this.targetOpacity!==1&&(this.showAnimationTimer=window.setTimeout(()=>{this.setHtmlOpacity(1),this.showAnimationTimer=void 0},0))}}hide(){if(!this.isHidden)if(this.isHidden=!0,this.options.animate){if(this.hideAnimationTimer)return;this.showAnimationTimer&&(clearTimeout(this.showAnimationTimer),this.showAnimationTimer=void 0),this.setHtmlOpacity(0),this.hideAnimationTimer=window.setTimeout(()=>{this.removeHtml(),this.hideAnimationTimer=void 0},this.options.duration)}else this.removeHtml()}setHtmlOpacity(e){this.html.style.opacity=String(e),this.targetOpacity=e}removeHtml(){this.html.remove(),this.screenPoint=[0,0]}appendHtml(){this.getMarkerContainer().appendChild(this.html)}getMarkerContainer(){return this.options.preventMapInteractions?this.modules.layout.htmlContainerOutMap:this.modules.layout.htmlContainerInMap}updateDemElevation(){var e;this.demElevation=(e=this.modules.demManager.getElevation(this.position.normalizedValue))!=null?e:0,this.demTilesRevision=this.modules.demManager.getTilesRevision()}nearCenterScreenPosition(){var c;const e=this.modules.demManager,t=this.mapState;let i=0,o=0;if(t.demMode){const d=e.getTilesRevision();this.demTilesRevision!==d&&this.updateDemElevation(),i=(this.demElevation-((c=t.elevation)!=null?c:0))*t.elevationScale}this.options.floorId&&(o=this.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0));const a=this.mapState.visibleMapReplicas.map(d=>{const _=[this.position.normalizedValue[0]+n.worldSize*d,this.position.normalizedValue[1],this.position.normalizedValue[2]+i*n.MAP_POINTS_IN_METER+o];return n.Mercator.toGeo(_,_),this.modules.camera.project(_,!0)}),r=a.map(d=>Math.abs(this.mapState.size[0]/2-(isNaN(d[0])?-1/0:d[0]))),l=r.findIndex(d=>d===Math.min(...r));return a[l]}updatePosition(){const e=this.nearCenterScreenPosition();this.html.hidden=Number.isNaN(e[0]),this.rounder(e,e[0]+this.options.offset[0],e[1]+this.options.offset[1],this.mapState.stillness),this.mapState.globeMode&&(this.html.hidden=!this.modules.camera.ecef.canSee(this.getPosition())),n.equals$1(this.screenPoint,e)||(this.html.style.transform=`translate3d(${e[0]}px, ${e[1]}px, 0px)`,this.screenPoint=e)}updateLabelBox(){if(this.options.labeling.type==="none")return;const{labeling:{width:e,height:t},offset:i}=this.options;this.modules.labeler.removeLabels(this.labelKey),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:e,height:t,position:this.position.normalizedValue,offset:i,labelingGroup:this.getLabelingGroup(),parentPoiId:this.options.labeling.type==="pinnedToPoi"?this.options.labeling.poiId:void 0})}getLabelingGroup(){return this.isInvolvedInLabeling()?"markerText":"htmlLabel"}checkZoom(){const{zoom:e}=this.mapState,{minZoom:t,maxZoom:i}=this.options;return e>=t&&e<i}checkFog(){if(!this.modules.environmentManager.isFogEnabled()||this.mapState.globeMode)return!0;const{fogLimits:e}=this.modules.environmentManager,{fogDistance:t,position:i}=this.modules.camera,o=(this.position.normalizedValue[0]-i[0])/t,a=(this.position.normalizedValue[1]-i[1])/t,r=Math.sqrt(je(o,2)+je(a,2)),l=e[1]-e[0];return n.clamp((r-e[0])/l,0,1)<this.fogFactorBreakpoint}isInvolvedInLabeling(){return this.options.labeling.type==="full"||this.options.labeling.type==="pinnedToPoi"}},Zt.options={coordinates:[0,0],html:"",offset:[0,0],animate:!0,duration:500,labeling:{type:"none"},interactive:!0,preventMapInteractions:!1,zIndex:0,minZoom:-1/0,maxZoom:1/0,disableRounding:!1,floorId:""},Zt);function jv(s){const e=document.createElement("div");e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.zIndex=String(s.zIndex),s.interactive||(e.style.pointerEvents="none"),s.animate&&(e.style.opacity="0",e.style.transition=`opacity ${s.duration}ms`,e.style.willChange="opacity");const t=document.createElement("div");return typeof s.html=="string"?t.innerHTML=s.html:t.append(s.html),e.append(t),e}function Wv(s){return s?$v:Xv}const $v=(s,e,t,i)=>{const o=Math.round(e),a=Math.round(t),r=o-e,l=a-t;s[0]=e+i*r,s[1]=t+i*l},Xv=(s,e,t)=>{s[0]=e,s[1]=t},Kv="#0085a0",qv="#ffffff",Yv=4,Qv=1,Jv=2,Av=1.5,eg=2.8,ol=6,tg=!0,ig=17.1,is=n.entranceAnimation.iterationCount,ns=n.create$1();class sl extends We{constructor(e,t){var p,v,x,g,y,b,M,T,P,S,C,I;super(e,{interactive:!1}),this.options=t,this.vectors=this.options.coordinates.map(E=>E.map(F=>n.Mercator.fromGeo(F))),this.bouncePosition=0,this.growPosition=1;const{tileManager:i,dynamicStyle:o,collector:a,layers:r}=this.modules,l=(p=this.options.animate)!=null?p:tg;let c;if(l&&!this.mapState.disableLayerAnimation){const E=(v=this.options.iterationCount)!=null?v:is;E>1?c={type:"repeat",tipMovementAmplitude:this.options.tipMovementAmplitude||ol,iterationCount:E}:E===1&&(c={type:"appearance",tipMovementAmplitude:this.options.tipMovementAmplitude||ol})}const d=n.makeHandyStyleLayer({type:"arrow",id:`dynamic-entrance-${this.uniqId}`,minzoom:(x=this.options.minZoom)!=null?x:ig,maxzoom:this.options.maxZoom,style:{color:(g=this.options.color)!=null?g:Kv,strokeColor:(y=this.options.borderColor)!=null?y:qv,lineWidth:(b=this.options.width)!=null?b:Yv,strokeWidth:(M=this.options.borderWidth)!=null?M:Qv,tipWidth:(T=this.options.wingWidthMultiplier)!=null?T:Av,tipHeight:(P=this.options.tipHeightMultiplier)!=null?P:eg,roundingRadius:(S=this.options.roundingRadius)!=null?S:Jv,animation:c}});if(!d)return;o.addLayer(d,this.options.zIndex),this.layerId=d.innerId;const _=this.getTileInfo(),u=[],h=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,u,n.emptyFeatureAttrs);n.runPrecomputes(d,h);for(let E=0;E<this.vectors.length;E++){const F=this.vectors[E],j=this.getVertices(F,_);h.id=String(E),n.generateSafely({collector:a,generator:n.ArrowGenerator.generate,args:[o.getStyle().id,d,h,j]})}const f=a.getAccumulatedData(),m=new n.TileObject("dynamicObject",f.data,this.modules,this.mapState,_.coords,this);this.tileObjects.push(m),i.addObject(m),this.identifyIds.push(f.identifyIds),l&&!this.mapState.disableLayerAnimation?(this.bounceTickerId=`entrance-bounce-${this.uniqId}`,this.growTickerId=`entrance-grow-${this.uniqId}`,this.bounceTickerUpdate=n.update.bind(null,this.bounceTickerId,{step:(E,F)=>this.bouncePosition=F,complete:()=>{this.bounceTickerUpdate=void 0}},this.mapState),this.growTickerUpdate=n.update.bind(null,this.growTickerId,{step:(E,F)=>this.growPosition=F,complete:()=>{this.growTickerUpdate=void 0}},this.mapState),n.start(this.bounceTickerId,{easing:n.entranceAnimation.bounceType},this.mapState,-1,0,n.entranceAnimation.bounceTime,(C=this.options.iterationCount)!=null?C:is,{layerId:this.layerId,styleId:o.getStyle().id}),n.start(this.growTickerId,{easing:n.entranceAnimation.growType},this.mapState,0,1,n.entranceAnimation.growTime,(I=this.options.iterationCount)!=null?I:is,{layerId:this.layerId,styleId:o.getStyle().id})):(this.bouncePosition=0,this.growPosition=1),r.addLayer(this),a.reset(),this.modules.renderer.addRerenderEvent()}update(){super.update(),this.stopTickersOnGlobalAnimationDisabling(),this.bounceTickerUpdate&&this.bounceTickerUpdate(),this.growTickerUpdate&&this.growTickerUpdate()}isOutOfMainReplica(){return!1}entranceAnimationInProgress(){return this.bounceTickerUpdate!==void 0||this.growTickerUpdate!==void 0}remove(){this.destroy()}destroy(){this.bounceTickerUpdate=void 0,this.growTickerUpdate=void 0,this.bounceTickerId&&n.stop(this.bounceTickerId,this.mapState),this.growTickerId&&n.stop(this.growTickerId,this.mapState),this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}getTileInfo(){const e=n.create();for(let t=0;t<this.vectors.length;t++){const i=this.vectors[t];for(let o=0;o<i.length;o++)n.expandByPoint(e,i[o])}return n.createTileInfo(n.getBoundsTileCoords(e))}getVertices(e,t){const i=[],o=[];for(let a=0;a<e.length;a++)n.mapPointToTilePoint(ns,e[a],t),i[a]=ns[0],o[a]=ns[1];return{x:i,y:o}}stopTickersOnGlobalAnimationDisabling(){this.mapState.disableLayerAnimation&&(this.bounceTickerId&&(this.bounceTickerUpdate=void 0,n.stop(this.bounceTickerId,this.mapState)),this.growTickerId&&(this.growTickerUpdate=void 0,n.stop(this.growTickerId,this.mapState)))}}class ng{constructor(e){this.layers=[],this.renderer=e.renderer}addLayer(e){this.layers.push(e),this.renderer.addRerenderEvent()}removeLayer(e){const t=this.layers.indexOf(e);t!==-1&&(this.layers.splice(t,1),this.renderer.addRerenderEvent())}getLayers(){return this.layers}getDynamicObjectLayers(){return this.layers.filter(e=>e instanceof We)}getHtmlMarkers(){return this.layers.filter(e=>e instanceof ts)}entranceAnimationFinished(){return this.layers.every(e=>e instanceof sl?!e.entranceAnimationInProgress():!0)}}const al=()=>"",og=[.5,.5];class sg{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.cache={}}getRasterSet(e,t,i,o){return K(this,null,function*(){const a=this.getKey(e,i,o),r=this.getFromCache(a,t);if(r)return r;const l=yield this.loadIcon(e,t,i,o);return l&&this.storeInCache(l,a,t),l})}clear(){this.cache={}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}loadIcon(e,t,i,o){return K(this,null,function*(){const{dynamicStyle:a,workers:r,assetManager:l}=this.modules;let c=e;this.loadingCounter++,t&&(c=yield this.loadImageForTransformer(e).then(_=>t(_)).catch(()=>e));const d=yield this.loadImage(c);return d?Promise.resolve().then(()=>{i=i!==void 0?i:[d.width,d.height];const _=o!==void 0?[o[0]/i[0],o[1]/i[1]]:og,u=[i[0]*window.devicePixelRatio,i[1]*window.devicePixelRatio],h=n.createLoadedRasterSet([{w:u[0],h:u[1],x:0,y:0,atlasIndex:0,isPacked:!1,anchorX:_[0],anchorY:_[1]}]);a.appendRasterSet(h),r.labeling.addNewRasterSets(a.getStyle().id,[h]);const f=new Uint16Array(3);return f[0]=u[0],f[1]=u[1],f[2]=h.index,r.parser.packRasters(f).then(m=>({packedRasters:m.packedRasters,rasterSet:h,scaledSize:u}))}).then(_=>{const{packedRasters:u,rasterSet:h,scaledSize:f}=_;return u!==void 0&&l.prepareRasters(a.getStyle().id,u,[Cr(d,f)]),this.decreaseLoadingCounter(),h}):(this.decreaseLoadingCounter(),Promise.resolve(void 0))})}getFromCache(e,t){const i=this.cache[e];if(i)return i.get(t||al)}storeInCache(e,t,i){this.cache[t]||(this.cache[t]=new Map),this.cache[t].set(i||al,e)}getKey(e,t,i){const o=t!==void 0?`${t[0]},${t[1]}`:"",a=i!==void 0?`${i[0]},${i[1]}`:"";return`${e}_${o}_${a}`}loadImage(e){return new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>t(i),i.onerror=()=>t(void 0)})}loadImageForTransformer(e){return e.indexOf(".svg")===-1?new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>{t({type:"raster",source:i})},i.onerror=()=>{t({type:"unknown"})}}):new Promise(t=>{const i=new XMLHttpRequest;i.open("GET",e,!0),i.onload=function(){if(i.status!==200||i.response.byteLength===0){t({type:"unknown"});return}t({type:"vector",source:i.response})},i.onerror=function(){t({type:"unknown"})},i.send()})}}const rl={trafficOn:!1,parkingOn:!1,navigatorOn:!1,immersiveRoadsOn:!1,floorStackOn:!1,terrainEnabled:!1,graphicsPreset:Wt()?"light":"immersive",_activeFloorIds:[],_activeFloorBuildingIds:[],_activeFloorIsMetro:!1,_floorHeight:3.5,_customUserTimeOffset:0};let Cn=!1;function ag(){return B({},rl)}function Ln(s,e){return s=B({},s),(e==null?void 0:e.immersiveRoadsOff)===!0?(Cn=!0,s.immersiveRoadsOn=!1):Cn&&(s.immersiveRoadsOn=Cn,Cn=!1),s.graphicsPreset&&s.graphicsPreset!=="light"&&Wt()&&(console.warn(`"${String(s.graphicsPreset)}" graphicsPreset is not supported in deprecated system. Using "light" instead.`),s.graphicsPreset="light"),B(B({},rl),s)}function ll(s,e,t){const i=de(B(B({},s),e),{_activeFloorIds:s._activeFloorIds,_activeFloorBuildingIds:s._activeFloorBuildingIds,_activeFloorIsMetro:s._activeFloorIsMetro,_floorHeight:s._floorHeight});return Ln(i,t)}function cl(s,e=[],t=[],i=!1){return de(B({},s),{_activeFloorIds:e,_activeFloorBuildingIds:t,_activeFloorIsMetro:i})}const dl=["default","metro"],os="floorStackTicker",rg=500,Pn={MAX_DISTANCE_METERS:500,VERY_CLOSE_DISTANCE_METERS:500,DISTANCE_WEIGHT_MULTIPLIER:3,VERY_CLOSE_BONUS:1.5};class lg{constructor(e,t){this.state=e,this.modules=t,this.repository={descriptors:{default:new Map,metro:new Map},requestedFloors:new Set,failedRequestedFloors:new Set,floorIdsToObjectIds:new Map},this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.stack={readiness:0,offsets:new Map,maxOffset:1},this.viewport={index:{metro:n.rbush(),default:n.rbush()},metro:{in:null,current:null,out:null},default:{in:null,current:null,out:null}},this.displayedComplex=null,this.needUpdate=!1,this.allowedFloors=new Set,this.hiddenObjectIds=new Set,this.pendingUpdateCall=!1,this.ids={default:t.identifier.getIdScope(n.DEFAULT_ID_SCOPE),floor:t.identifier.getIdScope(n.FLOOR_ID_SCOPE)};const i=n.throttle(this._update.bind(this),60);this.prevStyleState=this.state.styleState,this.update=()=>{this.updateReadiness();const o=this.needUpdate||this.stateDiffer.check(this.state);o&&(this.pendingUpdateCall=!0,i()),(o||this.prevStyleState!==this.state.styleState)&&(this.updateStyleState(),this.prevStyleState=this.state.styleState),o&&this.updateHiddenIds()}}get maxFloorOffset(){var t;const e=(t=this.state.styleState._floorHeight)!=null?t:0;return Math.floor(n.floors.maxStackHeight/e)}get floorHeight(){var i;const e=(i=this.state.styleState._floorHeight)!=null?i:0,t=n.Mercator.toGeo(this.state.center);return n.geoToMapDistance(t,e)}get isMetroEnabled(){return this.state.allowMetro&&this.state.styleZoom>=n.floors.displayStyleZoom.metro}get isDefaultEnabled(){return this.state.styleZoom>=n.floors.displayStyleZoom.default}get isEnabled(){return this.state.floorsEnabled&&(this.isDefaultEnabled||this.isMetroEnabled)}get isStackEnabled(){return!this.state.demMode&&this.state.styleState.floorStackOn&&this.floorHeight>0}get shouldIgnoreFloorState(){return!!this.state.resetFloorModeOnActivation}get hiddenBuildingIds(){if(!this.displayedComplex||this.displayedComplex.mode==="building"||this.activeFloorIdx===void 0)return[];const e=this.displayedComplex.floors[this.activeFloorIdx];if(!e)return[];const t=[];if(e.id&&t.push(this.displayedComplex.id),!e.linked_floors_ids)return t;const i=this.repository.descriptors.default.has(this.displayedComplex.id)?"default":"metro";return this.displayedComplex.buildings.filter(o=>{const a=this.repository.descriptors[i].get(o);return e.linked_floors_ids.some(r=>a==null?void 0:a.floorIds.includes(r))}).forEach(o=>t.push(o)),t}getActiveFloorHiddenIds(){const e=this.ids.default.getRelatedChildrenIds(this.hiddenObjectIds);return Array.from(this.hiddenObjectIds).concat(e)}prepareFloors(e,t,i,o){o==="zenith"&&i.forEach((a,r)=>{let l=this.repository.floorIdsToObjectIds.get(r);l===void 0&&(l=new Set,this.repository.floorIdsToObjectIds.set(r,l));for(const c of a)l.add(c);this.loadFloor(r,e,t)})}changeFloorNumber(e,t){var r;const i=this.viewport.default.current,o=this.viewport.metro.current,a=i||o;if(a&&(a.id===e||a.buildings.includes(e)))if(this.needUpdate=!0,t==="metro"){if(!o)return;o.mode="metro",this.displayedComplex&&this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=o,this.setFloorIdx(o.defaultFloor),this.modules.map.emit("floorcomplexshow",{id:o.id,mode:"metro",currentFloor:o.defaultFloor,floorNames:o.floors.map(l=>l.name),firmsToFloorIndexMap:o.firmsToFloorIndexMap})}else if(t==="building")o&&(o.mode="floor"),a.mode="building",this.displayedComplex=null,this.modules.map.emit("floorcomplexhide",{id:e});else{if(t<0||t>=a.floors.length)return;this.setFloorIdx(t),a.selectedFloorIdx=t,o&&o.mode==="metro"&&(o.mode="floor",this.modules.map.emit("floorcomplexhide",{id:o.id})),this.displayedComplex!==a&&!((r=this.displayedComplex)!=null&&r.buildings.includes(a.id))&&this.modules.map.emit("floorcomplexshow",{id:a.id,mode:"floor",currentFloor:t,floorNames:a.floors.map(({name:l})=>l),firmsToFloorIndexMap:a.firmsToFloorIndexMap}),this.displayedComplex=a,this.updateStackState(),a.mode="floor",this.modules.map.emit("floorcomplexlevelchange",{id:e,floorIndex:t,floorName:a.floors[t].name})}}hasDisplayedFloorBuilding(e){if(!this.displayedComplex||this.displayedComplex.mode==="building")return!1;for(const t of this.hiddenBuildingIds){const i=this.repository.floorIdsToObjectIds.get(t);if(i&&(Array.isArray(e)&&e.some(o=>i.has(o))||typeof e=="string"&&i.has(e)))return!0}return!1}floorsReady(){return!this.pendingUpdateCall&&Array.from(this.repository.requestedFloors).every(e=>this.repository.failedRequestedFloors.has(e)||this.repository.descriptors.default.has(e)||this.repository.descriptors.metro.has(e))}setAllowedFloorIds(e){this.allowedFloors=new Set(e!=null?e:[]),this.needUpdate=!0}isVisibleFloorObject(e){return this.displayedComplex?this.state.styleState._activeFloorIds.includes(e):!1}isVisibleFloorStackObject(e){if(!this.isStackEnabled||!this.displayedComplex||this.activeFloorIdx===void 0)return!1;let t=!1;for(const a of this.hiddenBuildingIds){if(t)break;const r=this.repository.descriptors.default.get(a);t=!!(r!=null&&r.floors.some(l=>l.id===e))}if(!t)return!1;const i=this.activeFloorIdx-this.displayedComplex.defaultFloor,o=this.stack.offsets.get(e);return o<this.maxFloorOffset&&i>0&&o>=0&&o<i}getFloorObjectElevation(e,t){if(!this.isStackEnabled||!this.stack.offsets.has(e))return 0;const i=this.stack.offsets.get(e),o=this.floorHeight*i;return i<=0?0:i>this.maxFloorOffset?this.floorHeight*this.maxFloorOffset:t?o:n.lerp$2((i-1)/i,1,this.stack.readiness)*o}getFloorStackObjectElevation(e){return this.stack.offsets.has(e)?this.stack.offsets.get(e)*this.floorHeight:0}getFloorsStackObjectOffsets(e){return this.stack.offsets.has(e)?{current:this.stack.offsets.get(e),total:this.stack.maxOffset}:{current:0,total:1}}getPlanLevels(){return this.isStackEnabled?Object.fromEntries(this.stack.offsets):{}}getFloorStackObjectHeight(e){return!this.isStackEnabled||this.displayedComplex.floors.findIndex(i=>{var o;return i.id===e||((o=i.linked_floors_ids)==null?void 0:o.includes(e))})<this.activeFloorIdx-1?1:this.stack.readiness}_update(){this.pendingUpdateCall=!1,this.updateViewport();const e=!!(this.viewport.default.out&&this.viewport.default.in&&this.viewport.default.in.buildings.includes(this.viewport.default.out.id));this.viewport.default.out?e||this.modules.map.emit("floorcomplexout",{id:this.viewport.default.out.id}):this.viewport.metro.out&&this.modules.map.emit("floorcomplexout",{id:this.viewport.metro.out.id}),this.displayedComplex&&(!e&&this.viewport.default.out&&(this.displayedComplex===this.viewport.default.out||this.displayedComplex.buildings.includes(this.viewport.default.out.id))&&this.displayedComplex.mode==="floor"?(this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=null):this.displayedComplex===this.viewport.metro.out&&this.displayedComplex.mode==="metro"&&(this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=null));let t=null;const i=this.viewport.default.in||this.viewport.default.current,o=this.viewport.metro.in||this.viewport.metro.current,a=!e&&this.viewport.default.in||this.viewport.metro.in||this.viewport.default.out&&this.viewport.metro.current||this.viewport.metro.out&&!this.viewport.default.out&&i;if(i){const r=this.shouldIgnoreFloorState?"building":i.mode;t={id:i.id,mode:r==="floor"?"floor":"building",currentFloor:i.selectedFloorIdx,floorNames:i.floors.map(l=>l.name),firmsToFloorIndexMap:i.firmsToFloorIndexMap},this.viewport.metro.current&&((this.shouldIgnoreFloorState?"building":this.viewport.metro.current.mode)==="metro"&&(t.mode="metro"),t.metro={id:this.viewport.metro.current.id,floorNames:this.viewport.metro.current.floors.map(c=>c.name)})}if(o){if(t){t.metro={id:o.id,floorNames:o.floors.map(l=>l.name)};for(const l in o.firmsToFloorIndexMap)t.firmsToFloorIndexMap[l]=o.firmsToFloorIndexMap[l];o.mode==="metro"&&(t.mode="metro")}else t={id:o.id,mode:"building",currentFloor:o.defaultFloor,floorNames:[],firmsToFloorIndexMap:o.firmsToFloorIndexMap,metro:{id:o.id,floorNames:o.floors.map(l=>l.name)}};(this.shouldIgnoreFloorState?"building":o.mode)==="metro"&&(t.mode="metro")}t&&a&&this.modules.map.emit("floorcomplexin",t),this.displayFloorComplex(),this.needUpdate=!1}loadFloor(e,t,i){if(this.repository.requestedFloors.has(e))return;const o=n.getUrl("floorMeta",{protocol:this.state.tileProtocol,tileSet:this.state.tileSet,host:this.state.tileServer,subdomain:this.state.subdomains[0],regionId:t.toString(10),floorComplexId:e});this.repository.requestedFloors.add(e),fetch(o).then(a=>{if(a.ok===!1)throw new Error(a.statusText);return a.json()}).then(a=>{var _;let r=a.default_floor_idx,l="default";"is_metro"in a&&a.is_metro&&(r=a.default_metro_floor_idx,l="metro");const c=a.floors.reduce((u,h,f)=>(h.id&&(u[h.id]=f),u),{}),d={id:e,regionId:t,metatileHash:i,center:a.center,bound:a.bound,defaultFloor:r,selectedFloorIdx:r,mode:"floor",floors:a.floors,floorIds:a.floors.map(u=>u.id).filter(Boolean),buildings:a.linked_buildings_ids?a.linked_buildings_ids.concat(e):[e],firmsToFloorIndexMap:Object.entries((_=a.firm_id_to_floor_id)!=null?_:{}).reduce((u,[h,f])=>(u[h]=c[f],u),{})};this.repository.descriptors[l].set(e,d),this.viewport.index[l].insert({complex:d,minX:d.bound.min[0],minY:d.bound.min[1],maxX:d.bound.max[0],maxY:d.bound.max[1]}),this.needUpdate=!0}).catch(()=>{this.repository.failedRequestedFloors.add(e)})}updateStackState(){if(this.stack.offsets.clear(),!this.displayedComplex)return;let e=1;this.displayedComplex.floors.forEach((t,i)=>{var a;const o=i-this.displayedComplex.defaultFloor;t.id&&this.stack.offsets.set(t.id,o),o>e&&(e=o),(a=t.linked_floors_ids)==null||a.forEach(r=>{this.stack.offsets.set(r,o)})}),this.stack.maxOffset=e}updateStyleState(){var d;const{styleState:e}=this.state;if(!this.displayedComplex){(Array.isArray(e._activeFloorIds)&&e._activeFloorIds.length>0||Array.isArray(e._activeFloorBuildingIds)&&e._activeFloorBuildingIds.length>0)&&(this.state.styleState=cl(e,[],[],!1));return}const t=new Set,i=new Set,o=new Set(this.state.styleState._activeFloorIds),a=new Set(this.state.styleState._activeFloorBuildingIds),r=e._activeFloorIsMetro===!0,l=this.displayedComplex;if(!l||this.activeFloorIdx===void 0||l.mode==="building")return;const c=l.floors[this.activeFloorIdx];c&&(c.id&&t.add(c.id),(d=c.linked_floors_ids)==null||d.forEach(_=>{t.add(_)}),this.hiddenBuildingIds.forEach(_=>i.add(_)),(_l(o,t)||_l(a,i)||r!==(this.displayedComplex.mode==="metro"))&&(this.state.styleState=cl(e,Array.from(t),Array.from(i),this.displayedComplex.mode==="metro")))}updateHiddenIds(){if(!this.displayedComplex){this.markHiddenObjectsForUpdate();return}const e=new Set;this.hiddenBuildingIds.forEach(t=>{const i=this.repository.floorIdsToObjectIds.get(t);i&&i.forEach(o=>e.add(o))}),this.markHiddenObjectsForUpdate(e)}markHiddenObjectsForUpdate(e){if(e){const t=this.ids.default.getHidden(n.HideLevel.PolygonExtrusion),i=n.subtract(e,t),o=n.subtract(this.hiddenObjectIds,e);this.ids.default.hide(Array.from(i),n.HideLevel.PolygonExtrusion);const a=this.ids.floor.getHidden(),r=n.intersection$1(i,a);this.ids.default.hide(Array.from(r),n.HideLevel.All),this.ids.default.show(Array.from(o)),this.hiddenObjectIds=new Set(e)}else this.ids.default.show(Array.from(this.hiddenObjectIds)),this.hiddenObjectIds.clear()}updateReadiness(){n.update(os,{step:(e,t)=>this.stack.readiness=t},this.state)}setFloorIdx(e){this.prevActiveFloorIdx=this.activeFloorIdx,this.activeFloorIdx=e,!Number.isNaN(e)&&this.isStackEnabled&&this.prevActiveFloorIdx!==void 0&&this.activeFloorIdx>this.prevActiveFloorIdx?(this.stack.readiness=0,n.start(os,{easing:"easeOutQuint"},this.state,0,1,rg,1)):(this.stack.readiness=1,n.stop(os,this.state))}updateViewport(){if(!this.isEnabled){this.viewport.default={in:null,current:null,out:this.viewport.default.current},this.viewport.metro={in:null,current:null,out:this.viewport.metro.current};return}const e={default:null,metro:null},{center:t,zoom:i,rotation:o,size:a,viewport:r,padding:l,cameraConfig:c,globeMode:d}=this.state,_=new n.Camera({center:t,zoom:i,rotation:o,size:[Math.floor(a[0]*(1-n.floors.viewportPadding)),Math.floor(a[1]*(1-n.floors.viewportPadding))],styleState:{},pitch:0,viewport:r,padding:l,cameraConfig:c,globeMode:d}),u=_.getViewportVertices().map(m=>[m[0],m[1]]),h=cg(u),f=[[0,0],[0,0],[0,0],[0,0]];dl.forEach(m=>{if(m==="default"&&!this.isDefaultEnabled||m==="metro"&&!this.isMetroEnabled)return;const p=this.viewport.index[m].search(h);let v,x;for(const g of p){if(this.allowedFloors.size>0&&!this.allowedFloors.has(g.complex.id))continue;const y=g.complex.bound;if(dg(_.position,y)){if(v){const T=ul(y);T<v.complexArea&&(v.complex=g.complex,v.complexArea=T)}else v={complex:g.complex,complexArea:ul(y)};continue}f[0][0]=y.min[0],f[0][1]=y.min[1],f[1][0]=y.max[0],f[1][1]=y.min[1],f[2][0]=y.max[0],f[2][1]=y.max[1],f[3][0]=y.min[0],f[3][1]=y.max[1];const b=_g(f,u);if(b.length<3)continue;const M=hg({complex:g.complex,cameraPosition:_.position,intersectionPolygon:b});x?x.score<M&&(x.complex=g.complex,x.score=M):x={complex:g.complex,score:M}}v?e[m]=v.complex:x&&(e[m]=x.complex)}),dl.forEach(m=>{const p=this.viewport[m].current,v=e[m];this.shouldIgnoreFloorState&&v&&v!==p&&(v.mode="building"),this.viewport[m].out=p!==v?p:null,this.viewport[m].in=v!==p?v:null,this.viewport[m].current=v})}displayFloorComplex(){var i;const e=this.viewport.default.current,t=this.viewport.metro.current;if(t&&t.mode==="metro"){if(t===this.displayedComplex)return;this.displayedComplex=t,this.setFloorIdx(t.defaultFloor),this.modules.map.emit("floorcomplexshow",{id:t.id,mode:"metro",currentFloor:t.defaultFloor,floorNames:t.floors.map(o=>o.name),firmsToFloorIndexMap:t.firmsToFloorIndexMap}),this.updateStyleState()}else if(e&&e.mode==="floor"){if(e===this.displayedComplex||(i=this.displayedComplex)!=null&&i.buildings.includes(e.id))return;this.displayedComplex=e,this.updateStackState(),this.setFloorIdx(this.displayedComplex.selectedFloorIdx),this.modules.map.emit("floorcomplexshow",{id:e.id,mode:"floor",currentFloor:e.selectedFloorIdx,floorNames:e.floors.map(o=>o.name),firmsToFloorIndexMap:e.firmsToFloorIndexMap}),this.updateStyleState()}}}function _l(s,e){if(s.size!==e.size)return!0;for(const t of s)if(!e.has(t))return!0;return!1}function cg(s){let e=s[0][0],t=s[0][1],i=e,o=t;for(let a=1;a<s.length;a++){const[r,l]=s[a];r<e?e=r:r>i&&(i=r),l<t?t=l:l>o&&(o=l)}return{minX:e,minY:t,maxX:i,maxY:o}}function dg(s,e){return s[0]>=e.min[0]&&s[0]<=e.max[0]&&s[1]>=e.min[1]&&s[1]<=e.max[1]}function ul(s){return(s.max[0]-s.min[0])*(s.max[1]-s.min[1])}function _g(s,e){let t=s;for(let a=0;a<e.length;a++){const r=e[a],l=e[(a+1)%e.length],c=t;t=[];for(let d=0;d<c.length;d++){const _=c[d],u=c[(d+1)%c.length];i(u,r,l)?(i(_,r,l)||t.push(o(_,u,r,l)),t.push(u)):i(_,r,l)&&t.push(o(_,u,r,l))}}return t;function i(a,r,l){return(l[0]-r[0])*(a[1]-r[1])>(l[1]-r[1])*(a[0]-r[0])}function o(a,r,l,c){const d=r[1]-a[1],_=a[0]-r[0],u=d*a[0]+_*a[1],h=c[1]-l[1],f=l[0]-c[0],m=h*l[0]+f*l[1],p=d*f-h*_;return p===0?r:[(f*u-_*m)/p,(d*m-h*u)/p]}}function ug(s){let e=0;for(let t=0,i=s.length-1;t<s.length;i=t++)e+=(s[i][0]+s[t][0])*(s[i][1]-s[t][1]);return Math.abs(e/2)}function hg(s){const e=Math.sqrt(je(s.complex.center[0]-s.cameraPosition[0],2)+je(s.complex.center[1]-s.cameraPosition[1],2)),t=e/(Pn.MAX_DISTANCE_METERS*n.MAP_POINTS_IN_METER),i=Math.max(0,1-t),o=e<Pn.VERY_CLOSE_DISTANCE_METERS*n.MAP_POINTS_IN_METER?Pn.VERY_CLOSE_BONUS:1;return ug(s.intersectionPolygon)*o*(1+i*Pn.DISTANCE_WEIGHT_MULTIPLIER)}class fg{constructor(e,t){this.state=e,this.modules=t,this.tileLayers=[],this.objects=[],this.viewportDiffer=new n.Differ([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"globeMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"},{path:"handyStyleId",type:"string"}])}getMemoryFootprint(e=()=>!0){const t={tileLayers:this.tileLayers.filter(e).map(o=>({[o.getSourceType()]:o.memSizeJs()})),objects:this.objects.filter(o=>o.purpose==="dynamicObject").map(o=>({[o.purpose]:n.tileObjectStatsJS(o)}))},i={tileLayers:this.tileLayers.filter(e).map(o=>({[o.getSourceType()]:o.memSizeGpu()})),objects:this.objects.filter(o=>o.purpose==="dynamicObject").map(o=>({[o.purpose]:n.tileObjectStatsGpu(o)}))};return{js:de(B({},t),{"--sum":n.getTotalMemory(t)}),gpu:de(B({},i),{"--sum":n.getTotalMemory(i)})}}addTileLayer(e){this.tileLayers.indexOf(e)===-1&&(this.tileLayers.push(e),e.redraw(),this.modules.identifier.resetCache(),this.state.needLabeling=!0,this.modules.renderer.addRerenderEvent())}removeTileLayer(e){n.excludeItemFromArray(this.tileLayers,e)&&(e.resetHoverId(),this.modules.identifier.resetCache(),this.state.needLabeling=!0,this.modules.renderer.addRerenderEvent())}redraw(){this.modules.labeler.clearPreviousLabels();for(const e of this.tileLayers)e.resetHoverId(),e.redraw();this.modules.renderer.addRerenderEvent()}activateStyleUpdating(){this.tileLayers.forEach(e=>e.activateStyleUpdating())}finishStyleUpdating(){this.tileLayers.forEach(e=>e.finishStyleUpdating())}getViewportTiles(){const e=[];for(const t of this.tileLayers)e.push(...t.getViewportTiles());return e}viewportTilesReady(){return this.tileLayers.every(e=>e.viewportTilesReady())}displayedTilesAnimationFinished(){return this.tileLayers.every(e=>e.displayedTilesAnimationFinished())}getDisplayedIdentifyData(){const e=[];for(const t of this.tileLayers)e.push(...t.getDisplayedIdentifyData());return e}getLabelingData(){return this.tileLayers.map(e=>e.getLabelingData())}isIdle(){return this.viewportTilesReady()&&this.displayedTilesAnimationFinished()}update(){const e=this.state;this.viewportDiffer.check(e)&&(this.tileLayers.forEach(t=>t.updateViewport()),this.modules.map.emit("viewportchange"));for(const t of this.tileLayers)t.update();if(this.updateTickers(),e.collectStats){this.state.stats.tileCount=0;for(const t of this.tileLayers)this.state.stats.tileCount+=t.getTileCount();this.state.stats.globeTileCount=this.objects.filter(t=>t.purpose==="globe").length,this.state.stats.dynamicTileCount=this.objects.filter(t=>t.purpose==="dynamicObject"||t.purpose==="floor").length}}getTileObjects(){return this.objects}addObject(e,t){if(this.objects.indexOf(e)===-1){if(this.objects.push(e),t)return;this.modules.renderer.addRerenderEvent()}}removeObject(e,t){if(n.excludeItemFromArray(this.objects,e)){if(t)return;this.modules.renderer.addRerenderEvent()}}getCachedMods(){const e=[];for(const t of this.tileLayers){const i=t.gridState.tileModsCache.getData();for(const o of i)e.push(o)}return e}destroy(){for(const e of this.tileLayers)e.destroy();this.objects.forEach(e=>e.clean(this.state))}updateTickers(){this.objects.forEach(e=>e.updateTicker(this.state))}}const mg=(s,e,t,i,o)=>{n.start("labelingOpacity",{easing:e},s,t,i,o,1)},pg=n.update.bind(null,"labelingOpacity",{step:(s,e)=>s.labelingOpacity=e});function vg(s){return s?Object.keys(s).map(Number).sort((e,t)=>e-t):[]}function gg(s,e){const{config:t,ascSortedZoomNumbers:i}=e;if(i.length===0)return{city:n.labeling.commercialMargins.city};if(s<i[0])return{city:t[i[0]]};if(s>=i[i.length-1])return{city:t[i[i.length-1]]};for(let o=1;o<i.length;o++)if(s<i[o])return{city:t[i[o-1]]};return{city:n.labeling.commercialMargins.city}}const yg=s=>({appendLabels:s.get(n.ThreadName.Labeling,"appendLabels"),appendLabelBox:s.get(n.ThreadName.Labeling,"appendLabelBox"),removeLabels:s.get(n.ThreadName.Labeling,"removeLabels"),processLabels:s.get(n.ThreadName.Labeling,"processLabels"),clearPreviousLabels:s.get(n.ThreadName.Labeling,"clearPreviousLabels")});class xg{constructor(e,t){this.state=e,this.modules=t,this.labelTileRevision=0,this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.useThrottleUpdate=!0,this.isLabelingInProgress=!1,this.skipHysteresisInNextLabeling=!1,this.alwaysActiveLabelKeys=[],this.survivedLabelBoxes=new Set,this.prevSurvivedCommPoiIds=new Set,this.demKeys={},this.labelTiles=[],this.worker=yg(this.modules.workers.fnRegistry),this.setLabelingInterval(n.labeling.interval)}disableThrottleUpdateOnce(){this.useThrottleUpdate=!1}update(){pg(this.state),this.state.needReplicasUpdate&&this.labelTiles.forEach(e=>{e.needSync=!0}),(this.viewportDiffer.check(this.state)||this.state.needLabeling)&&!this.isLabelingInProgress&&(this.state.needLabeling=!1,this.isLabelingInProgress=!0,this.useThrottleUpdate?this.throttledUpdateLabeling():(this.useThrottleUpdate=!0,this.generateLabelingTile()))}isIdle(){return this.state.tickers.labelingOpacity===void 0&&!this.isLabelingInProgress&&!this.state.needLabeling}setLabelingInterval(e){this.throttledUpdateLabeling=n.throttle(()=>{this.generateLabelingTile()},e)}addLabels(e,t,i){this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),this.enrichWithElevation(i,e),this.alwaysActiveLabelKeys.push(e),this.state.needLabeling=!0}addTileLabels(e,t,i){this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),this.enrichWithElevation(i,e),this.state.needLabeling=!0}addLabelBox(e,t){this.worker.appendLabelBox(e,t),this.state.needLabeling=!0}removeLabels(e){this.worker.removeLabels(e);const t=this.alwaysActiveLabelKeys.indexOf(e);t!==-1&&this.alwaysActiveLabelKeys.splice(t,1),this.state.needLabeling=!0}isLabelBoxSurvived(e){return this.survivedLabelBoxes.has(e)}clearPreviousLabels(){this.worker.clearPreviousLabels()}resetHysteresis(){this.skipHysteresisInNextLabeling=!0,this.state.needLabeling=!0}getLabelingRevision(){return this.labelTileRevision}getMemoryFootprint(){const e={labelTiles:this.labelTiles.map(t=>({[t.purpose]:n.tileObjectStatsGpu(t)}))};return{gpu:de(B({},e),{"--sum":n.getTotalMemory(e)})}}generateLabelingTile(){const e=n.getBoundsTileCoords(n.tetragonBounds(this.state.tilesBounds),n.labeling.tileMultiplier);let t=[{coords:e,center:this.state.center,tilesBounds:this.state.tilesBounds}];if(!this.state.globeMode)if(e[2]<0)t=[{coords:[0,0,0,0],center:[0,0,0],tilesBounds:[[-n.HALF_WORLD_SIZE,-n.HALF_WORLD_SIZE,0],[n.HALF_WORLD_SIZE,-n.HALF_WORLD_SIZE,0],[n.HALF_WORLD_SIZE,n.HALF_WORLD_SIZE,0],[-n.HALF_WORLD_SIZE,n.HALF_WORLD_SIZE,0]]}];else{const r=n.getTileBounds(e),l=je(2,e[2]),c=r.min[0]<-n.HALF_WORLD_SIZE,d=r.max[0]>n.HALF_WORLD_SIZE;if(c||d){const _=[...e];_[0]+=c?l:-l;const u=[...this.state.center];u[0]+=c?n.worldSize:-n.worldSize;const{min:h,max:f}=n.getTileBounds(_);t.push({coords:_,center:u,tilesBounds:[[h[0],h[1],0],[f[0],h[1],0],[f[0],f[1],0],[h[0],f[1],0]]})}}const i=this.modules.tileManager.getLabelingData(),o=t.map(({coords:r,center:l,tilesBounds:c})=>({center:l,elevation:this.state.elevation,zoom:this.state.zoom,styleZoom:this.state.styleZoom,rotation:this.state.rotation,size:this.state.size,pitch:this.state.pitch,viewport:this.state.viewport,padding:this.state.padding,globeMode:this.state.globeMode,styleState:this.state.styleState,buildingHeight:this.modules.buildingHeightAnimator.getDefaultBuildingHeight(),tilesBounds:c,debugLabels:this.modules.labelsDebug.isEnabled(),disableSurvivedPoiPrevalence:this.state.disableSurvivedPoiPrevalence,tileInfo:n.createTileInfo(r),cameraConfig:this.state.cameraConfig})),a=gg(this.state.styleZoom,this.state.cityCommPoiLabeling);this.worker.processLabels(i,this.alwaysActiveLabelKeys,o,window.devicePixelRatio,this.modules.floorManager.getActiveFloorHiddenIds(),B(B({},n.labeling.commercialMargins),a),this.skipHysteresisInNextLabeling,this.modules.floorManager.getPlanLevels()).then(r=>{this.survivedLabelBoxes.clear(),this.labelTiles.forEach(h=>{this.modules.tileManager.removeObject(h),h.clean(this.state)}),this.labelTiles.length=0;const l=[];r.forEach((h,f)=>{h.survivedLabelBoxIds.forEach(p=>this.survivedLabelBoxes.add(p)),l.push(...h.survivedCommPois),this.modules.assetManager.loadRasters(h.collectorOutput.rastersToLoad);const m=new n.TileObject("labeling",h.collectorOutput.data,this.modules,this.state,t[f].coords,void 0,void 0);this.labelTiles.push(m),this.modules.tileManager.addObject(m)}),this.processSurvivedCommPoiIds(l),this.labelTileRevision++;const c=this.state.metrics;c.firstlabeling===void 0&&r.some(({collectorOutput:h})=>h.data.length>0)&&(c.firstlabeling=performance.now()-c.start);const{animationTime:d,animationType:_,interval:u}=n.labeling;mg(this.state,_,0,1,Math.min(d,u)),this.modules.renderer.addRerenderEvent(),r[0].labels&&e[2]>=0&&this.modules.labelsDebug.drawLabels(r[0].labels),this.isLabelingInProgress=!1}),this.skipHysteresisInNextLabeling=!1}processSurvivedCommPoiIds(e){if(e.length===0){this.prevSurvivedCommPoiIds.clear();return}const t=e.filter(i=>!this.prevSurvivedCommPoiIds.has(i.id));t.length!==0&&this.modules.map.emit("commpoishow",{commPois:t}),this.prevSurvivedCommPoiIds=new Set(e.map(i=>i.id))}enrichWithElevation(e,t){const{demManager:i,map:o}=this.modules;if(o.state.demMode){const a=this.demKeys[t],r=i.getLabelsDemKey(e);if(r===void 0||r===a)return;i.enrichWithElevation(e),this.demKeys[t]=r}}}class si{constructor(e,t,i){this.type=e,this.handler=i,this.mouseDownPoint=t,this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionstart",{target:"pitch/rotation"})}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseup":return this.processMouseUpAction(e);case"keyup":return this.processKeyUpAction(e);default:return this}}processMouseMoveAction(e){const t=Se(this.handler.container,e.clientX,e.clientY);return new hl(this.type,this.mouseDownPoint,t,this.handler)}processMouseUpAction(e){switch(this.type){case"keyPrimary":if(e.button===0&&(e.ctrlKey||e.metaKey))return this.returnToInitialState();break;case"secondary":if(e.button===2){const t=Se(this.handler.container,e.clientX,e.clientY);return this.handler.modules.identifier.search("contextmenu",t,!0).then(i=>{mt("contextmenu",i,e,t,this.handler.modules)}),this.returnToInitialState()}break;case"auxiliary":if(e.button===1)return this.returnToInitialState();break}return this}processKeyUpAction(e){return this.type==="keyPrimary"&&(e.key==="Control"||e.key==="Meta")?(this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new Bn(this.mouseDownPoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new tt(this.handler)}}class hl{constructor(e,t,i,o){this.type=e,this.mouseDownPoint=t,this.mouseMovePoint=i,this.handler=o,this.handler.mapState.userHasInteracted=!0,(!this.handler.mapState.disablePitchByUserInteraction||!this.handler.mapState.disableRotationByUserInteraction)&&this.handler.container.classList.add("mapgl-rotating"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseleave":return this.returnToInitialState();case"mouseup":return this.processMouseUpAction(e);case"keyup":return this.processKeyUpAction(e);default:return this}}update(e){this.mouseDownPoint[0]===0&&this.mouseDownPoint[1]===0&&(this.mouseDownPoint=this.mouseMovePoint);const t=n.normalizeMousePosition(e.size,this.mouseDownPoint),i=n.normalizeMousePosition(e.size,this.mouseMovePoint),o=(t[0]-i[0])*n.zoom.mouseRotateDelta,a=(i[1]-t[1])*n.zoom.mousePitchDelta;pt(e),e.disableRotationByUserInteraction||di(e,e.rotation+o,{animate:!1}),e.disablePitchByUserInteraction||Ui(e,n.clamp(e.pitch+a,e.minPitch,e.maxPitch),{animate:!1}),this.mouseDownPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Se(this.handler.container,e.clientX,e.clientY),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processMouseUpAction(e){switch(this.type){case"keyPrimary":if(e.button===0&&(e.ctrlKey||e.metaKey))return this.returnToInitialState();break;case"secondary":if(e.button===2)return this.returnToInitialState();break;case"auxiliary":if(e.button===1)return this.returnToInitialState();break}return this}processKeyUpAction(e){return this.type==="keyPrimary"&&(e.key==="Control"||e.key==="Meta")?(this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new Bn(this.mouseMovePoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new tt(this.handler)}}class Bn{constructor(e,t){this.handler=t,this.toInitialOnMouseUp=!1,this.mouseDownPoint=e,this.dragStartPoint=e,this.isTimerStarted=this.handler.dblClickTimer!==void 0,this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionstart",{target:"center"}),this.isTimerStarted&&(window.clearTimeout(this.handler.dblClickTimer),this.handler.dblClickTimer=void 0)}processAction(e){switch(e.type){case"mousedown":return this.toInitialOnMouseUp=!0,this;case"mouseup":return this.processMouseUpAction(e);case"mousemove":return this.processMouseMoveAction(e);case"click":return this.processMouseClickAction(e);case"keydown":return this.processKeyDownAction(e);default:return this}}processMouseUpAction(e){return e.button===0&&(this.toInitialOnMouseUp||!this.handler.modules.layout.isActionWithCanvas(e))?(this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"center"}),new tt(this.handler)):this}processMouseMoveAction(e){const t=Se(this.handler.container,e.clientX,e.clientY);return this.handler.mapState.disableDragging?(this.mouseDownPoint=t,this.dragStartPoint=t,this.toInitialOnMouseUp=!0,this):n.distance(this.mouseDownPoint,t)<n.events.dragThreshold?(this.dragStartPoint=t,this):new fl(t,this.dragStartPoint,this.handler)}processMouseClickAction(e){if(!this.handler.modules.layout.isActionWithCanvas(e))return this;if(this.isTimerStarted){if(this.handler.mapState.zoom<this.handler.mapState.maxZoom){const t=this.handler.mapState,i=Math.min(t.zoom+1,t.maxZoom),o=Se(this.handler.container,e.clientX,e.clientY);pt(t),wt(t,i,{duration:n.zoom.animDuration,zoomPoint:t.keepCenterWhileUserZoomRotate?void 0:o}),this.handler.modules.renderer.addRerenderEvent()}}else{const t=Se(this.handler.container,e.clientX,e.clientY);this.handler.modules.identifier.search("mouseClick",t,!0).then(i=>{this.handler.dblClickTimer||(this.handler.dblClickTimer=window.setTimeout(()=>{mt("click",i,e,t,this.handler.modules),this.handler.dblClickTimer=void 0},n.events.doubleClickTime))})}return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"center"}),new tt(this.handler)}processKeyDownAction(e){return e.key==="Control"||e.key==="Meta"?(this.handler.modules.map.emit("interactionend",{target:"center"}),new si("keyPrimary",this.mouseDownPoint,this.handler)):this}}class fl{constructor(e,t,i){this.mouseMovePoint=e,this.dragStartPoint=t,this.handler=i,this.handler.container.classList.add("mapgl-dragging"),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState)}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseup":return this.processMouseUpAction(e);case"keydown":return this.processKeyDownAction(e);default:return this}}update(e){const t=this.handler.modules.camera,i=t.flat.unproject(this.dragStartPoint),o=t.flat.unproject(this.mouseMovePoint);if(e.globeMode){const r=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,r),n.scale(o,o,r)}const a=n.clone$1(e.center);n.add$1(a,a,i),n.sub$1(a,a,o),pt(e),Ft(e,a,{animate:!1}),this.dragStartPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Se(this.handler.container,e.clientX,e.clientY),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processMouseUpAction(e){return e.button===0?this.returnToInitialState():this}processKeyDownAction(e){return e.key==="Control"||e.key==="Meta"?(this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),new si("keyPrimary",this.mouseMovePoint,this.handler)):this}returnToInitialState(){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),this.handler.mapState.userHasInteracted=!0,new tt(this.handler)}}class ml{constructor(e,t,i){this.handler=i,this.touchStartPoints=t,this.touchMovePoints=e,this.handler.mapState.userHasInteracted=!0,this.handler.mapState.disablePitchByUserInteraction||this.handler.container.classList.add("mapgl-rotating"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction(e);default:return this}}processTouchStartAction(e){return this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),new ai(e,this.handler,!1)}processTouchMoveAction(e){return e.preventDefault(),this.touchMovePoints=rt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(e){return this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),e.touches.length===0?(this.handler.mapState.userHasInteracted=!0,new tt(this.handler)):new ai(e,this.handler,!1)}}class zn extends ml{constructor(e,t,i){super(e,t,i),this.startPxAngle=0,this.rotationDetected=!1,t.length>1&&(this.startPxAngle=n.calcAngle(t[0],t[1]))}update(e){if(this.touchStartPoints.length<2||this.touchMovePoints.length<2)return;const t=n.calcMidpoint(this.touchMovePoints[0],this.touchMovePoints[1]),i=n.dist(this.touchMovePoints[0],this.touchMovePoints[1]),o=n.dist(this.touchStartPoints[0],this.touchStartPoints[1]),a=i/o,r=e.zoom+Math.log(a)/Math.log(2)*n.zoom.mobilePinchDelta;let l=0,c=0;if(!this.rotationDetected){const u=n.calcAngle(this.touchMovePoints[0],this.touchMovePoints[1]);c=Math.abs(this.startPxAngle-u),c>Math.PI&&(c=2*Math.PI-c),c>=this.handler.mapState.touchRotationThreshold&&(this.rotationDetected=!0)}if(this.rotationDetected){const u=this.handler.modules.camera.flat.unproject(this.touchStartPoints[0]),h=this.handler.modules.camera.flat.unproject(this.touchStartPoints[1]),f=this.handler.modules.camera.flat.unproject(this.touchMovePoints[0]),m=this.handler.modules.camera.flat.unproject(this.touchMovePoints[1]);if(u&&h&&f&&m){const p=n.calcAngle(u,h),v=n.calcAngle(f,m);l=p-v}}const d=e.rotation+l,_=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(_,e.center,n.getCenterCorrection(e,t,{zoom:r,rotation:d})),pt(e),Ft(e,_,{animate:!1}),wt(e,r,{animate:!1}),this.handler.mapState.disableRotationByUserInteraction||di(e,d,{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class pl extends ml{constructor(e,t,i){super(e,t,i)}update(e){const t=this.touchStartPoints.map(l=>n.normalizeMousePosition(e.size,l)),i=this.touchMovePoints.map(l=>n.normalizeMousePosition(e.size,l)),o=n.calcMidpoint(t[0],t[1]),r=(n.calcMidpoint(i[0],i[1])[1]-o[1])*n.zoom.mousePitchDelta;pt(e),Ui(e,n.clamp(e.pitch+r,e.minPitch,e.maxPitch),{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class ai{constructor(e,t,i){this.handler=t,this.needClickOnTouchEnd=i,this.toZoomRotate=!1,this.touchStartPoints=rt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.isTimerStarted=this.handler.dblClickTimer!==void 0,lt(e)?this.startedInteractionTarget="pitch/zoom/rotation":this.isTimerStarted?(this.startedInteractionTarget="zoom/rotation",window.clearTimeout(this.handler.dblClickTimer),this.handler.dblClickTimer=void 0):this.startedInteractionTarget="center",this.handler.modules.map.emit("interactionstart",{target:this.startedInteractionTarget})}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction(e);default:return this}}getStartedInteractionTarget(){return this.startedInteractionTarget}processTouchStartAction(e){return e.preventDefault(),this.touchStartPoints.length===1&&(this.needClickOnTouchEnd=!1,this.handler.modules.map.emit("interactionend",{target:"center"}),this.startedInteractionTarget="pitch/zoom/rotation",this.handler.modules.map.emit("interactionstart",{target:this.startedInteractionTarget}),this.handler.mapState.userHasInteracted=!0),this.touchStartPoints=rt(e.touches,this.handler.container),this}processTouchMoveAction(e){e.preventDefault();const t=rt(e.touches,this.handler.container);if(!lt(e))return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):this.isTimerStarted?new vl(t[0],this.touchStartPoints[0],this.handler):this.handler.mapState.disableDragging?(this.touchStartPoints=t,this.needClickOnTouchEnd=!1,this):new ss(t[0],this.touchStartPoints[0],this.handler);if(this.touchStartPoints.length<2)return this.processTouchStartAction(e);const i=n.create$4(),o=n.create$4();n.sub(i,t[0],this.touchStartPoints[0]),n.sub(o,t[1],this.touchStartPoints[1]);const a=n.dot$1(i,o);if(a>0){if(this.handler.mapState.enableTwoFingerDragging&&this.touchStartPoints.length===2)return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):new ss(t[0],this.touchStartPoints[0],this.handler);const l=n.distance(this.touchStartPoints[0],t[0]),c=n.distance(this.touchStartPoints[1],t[1]);return l<n.events.pitchThreshold||c<n.events.pitchThreshold?(this.touchStartPoints=t,this):this.handler.mapState.disablePitchByUserInteraction?this:new pl(t,this.touchStartPoints,this.handler)}return a<0?new zn(t,this.touchStartPoints,this.handler):n.isNullVector(i)||n.isNullVector(o)?this.pitchWaitingTimer?this:this.toZoomRotate?(this.toZoomRotate=!1,new zn(t,this.touchStartPoints,this.handler)):(this.pitchWaitingTimer=window.setTimeout(()=>{this.toZoomRotate=!0,this.pitchWaitingTimer=void 0},n.events.pitchWaitingTime),this):new zn(t,this.touchStartPoints,this.handler)}processTouchEndAction(e){return e.cancelable&&e.preventDefault(),e.touches.length===0?e.changedTouches.length===1&&this.needClickOnTouchEnd?this.processTouchClickAction(this.touchStartPoints[0],e):(this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:e.changedTouches.length>1?"pitch/zoom/rotation":"center"}),new tt(this.handler)):(lt(e)||(this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),this.startedInteractionTarget="center",this.handler.modules.map.emit("interactionstart",{target:this.startedInteractionTarget}),this.handler.mapState.userHasInteracted=!0),this.touchStartPoints=rt(e.touches,this.handler.container),this)}processTouchClickAction(e,t){if(this.isTimerStarted){if(this.handler.mapState.zoom<this.handler.mapState.maxZoom){const i=this.handler.mapState,o=Math.min(i.zoom+1,i.maxZoom),a=i.keepCenterWhileUserZoomRotate?void 0:e;pt(i),wt(i,o,{duration:n.zoom.animDuration,zoomPoint:a}),this.handler.modules.renderer.addRerenderEvent()}}else if(this.handler.modules.layout.isActionWithCanvas(t))this.handler.modules.identifier.search("mouseClick",e,!0).then(i=>{this.handler.dblClickTimer||(this.handler.dblClickTimer=window.setTimeout(()=>{mt("click",i,t,e,this.handler.modules),this.handler.dblClickTimer=void 0},n.events.doubleClickTime))});else{const i=t.changedTouches[0];t.target&&i&&t.target.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0,clientX:i.clientX,clientY:i.clientY}))}return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"center"}),new tt(this.handler)}}class ss{constructor(e,t,i){this.handler=i,this.touchMovePoint=e,this.touchStartPoint=t,this.handler.mapState.userHasInteracted=!0,this.handler.container.classList.add("mapgl-dragging"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction();default:return this}}update(e){const t=this.handler.modules.camera,i=t.flat.unproject(this.touchStartPoint),o=t.flat.unproject(this.touchMovePoint);if(e.globeMode){const r=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,r),n.scale(o,o,r)}const a=n.clone$1(e.center);n.add$1(a,a,i),n.sub$1(a,a,o),pt(e),Ft(e,a,{animate:!1}),this.touchStartPoint=this.touchMovePoint,this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),new ai(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=rt(e.touches,this.handler.container);return this.touchMovePoint=t[0],this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),this.handler.mapState.userHasInteracted=!0,new tt(this.handler)}}class vl{constructor(e,t,i){this.handler=i,this.mapHeight=i.mapState.size[1],this.startZoom=i.mapState.zoom,this.touchMovePointY=e[1],this.touchStartPoint=t,this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction();default:return this}}update(e){const t=this.touchMovePointY-this.touchStartPoint[1];if(t===0)return;const i=t/this.mapHeight,o=n.clamp(this.startZoom+i*n.zoom.mobileTapDelta,e.minZoom,e.maxZoom),a=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(a,e.center,n.getCenterCorrection(e,this.touchStartPoint,{zoom:o})),pt(e),Ft(e,a,{animate:!1}),wt(e,o,{animate:!1}),this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),new ai(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=rt(e.touches,this.handler.container);return this.touchMovePointY=t[0][1],this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),this.handler.mapState.userHasInteracted=!0,new tt(this.handler)}}class tt{constructor(e){this.handler=e}processAction(e){switch(e.type){case"mousedown":return this.processMouseDownAction(e);case"touchstart":return this.processTouchStartAction(e);default:return this}}processMouseDownAction(e){const t=Se(this.handler.container,e.clientX,e.clientY);switch(e.button){case 0:if(e.ctrlKey||e.metaKey)return new si("keyPrimary",t,this.handler);if(this.handler.modules.layout.isActionWithCanvas(e)){const i=this.handler.modules.identifier.searchSync(t);mt("mousedown",i,e,t,this.handler.modules)}return new Bn(t,this.handler);case 1:return new si("auxiliary",t,this.handler);case 2:return new si("secondary",t,this.handler);default:return this}}processTouchStartAction(e){if(e.preventDefault(),!e.touches)return this;if(this.handler.modules.layout.isActionWithCanvas(e)){const t=Se(this.handler.container,e.changedTouches[0].clientX,e.changedTouches[0].clientY),i=this.handler.modules.identifier.searchSync(t);mt("touchstart",i,e,t,this.handler.modules)}return new ai(e,this.handler,e.touches.length===1)}}class Rn{processAction(){return this}}class bg{constructor(e,t){this.preventDefault=i=>{i.preventDefault()},this.onMouseMove=i=>{this.dblClickTimer&&(this.dblClickTimer=void 0),this.switchState(i)},this.onTouchStart=i=>{this.modules.layout.isActionWithMap(i)&&this.switchState(i)},this.switchState=i=>{this.state;const o=this.state.processAction(i);this.state instanceof Rn||(this.state=o)},this.state=new tt(this),this.mapState=e,this.modules=t,this.container=t.layout.mapContainer,document.addEventListener("mouseup",this.switchState),document.addEventListener("keydown",this.switchState),document.addEventListener("keyup",this.switchState),document.addEventListener("mouseleave",this.switchState),document.addEventListener("mousemove",this.onMouseMove),this.container.addEventListener("click",this.switchState),this.container.addEventListener("mousedown",this.switchState),this.container.addEventListener("mouseout",this.switchState),document.addEventListener("touchstart",this.onTouchStart),document.addEventListener("touchend",this.switchState),document.addEventListener("touchmove",this.switchState),this.container.addEventListener("dragstart",this.preventDefault),this.container.addEventListener("drag",this.preventDefault),this.container.addEventListener("dragend",this.preventDefault),this.container.addEventListener("contextmenu",this.preventDefault),this.container.addEventListener("touchmove",this.preventDefault)}destroy(){document.removeEventListener("mouseup",this.switchState),document.removeEventListener("keydown",this.switchState),document.removeEventListener("keyup",this.switchState),document.removeEventListener("mouseleave",this.switchState),document.removeEventListener("mousemove",this.onMouseMove),this.container.removeEventListener("click",this.switchState),this.container.removeEventListener("mousedown",this.switchState),this.container.removeEventListener("mouseout",this.switchState),document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchend",this.switchState),document.removeEventListener("touchmove",this.switchState),this.container.removeEventListener("dragstart",this.preventDefault),this.container.removeEventListener("drag",this.preventDefault),this.container.removeEventListener("dragend",this.preventDefault),this.container.removeEventListener("contextmenu",this.preventDefault),this.container.removeEventListener("touchmove",this.preventDefault)}block(){if(this.state instanceof Rn)return;const{map:e}=this.modules;switch(this.container.classList.remove("mapgl-dragging"),this.container.classList.remove("mapgl-rotating"),this.state.constructor){case Bn:case fl:case ss:e.emit("interactionend",{target:"center"});break;case si:case hl:e.emit("interactionend",{target:"pitch/rotation"});break;case vl:e.emit("interactionend",{target:"zoom/rotation"});break;case zn:case pl:e.emit("interactionend",{target:"pitch/zoom/rotation"});break;case ai:{const t=this.state.getStartedInteractionTarget();e.emit("interactionend",{target:t});break}}this.state=new Rn}unblock(){this.state instanceof tt||this.state instanceof Rn&&(this.state=new tt(this))}}const wg=new Set([n.UNIVERSE_REGION_ID]);class as extends Error{constructor(e,t){super(e),this.name="TrafficFetchMetaError",this.noRetry=t}}class Sg{constructor(e,t){this.mapState=e,this.modules=t,this.fetchMetaRetryAttempt=null,this.justEnabled=this.mapState.trafficOn,this.isMetaLoading=!1,this.lastUpdateTime=-1/0,this.regionIds=new Set,this.id=n.uniqId();const i=t.identifier.getIdScope(n.DEFAULT_ID_SCOPE);this.gridState=n.createGridState("traffic",0,this.id,e.trafficMinZoom,e.trafficMaxZoom,e.trafficMinZoom,e.trafficMaxDetailLevel,t,e,i),this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"}])}show(){this.mapState.trafficOn||(this.mapState.trafficOn=!0,this.justEnabled=!0,this.modules.map.patchStyleState({trafficOn:!0}),this.modules.map.emit("trafficshow"))}hide(){this.mapState.trafficOn&&(n.resetGridState(this.gridState),this.mapState.trafficOn=!1,this.justEnabled=!1,this.modules.map.patchStyleState({trafficOn:!1}),this.modules.map.emit("traffichide"))}isEnabled(){return this.mapState.trafficOn}destroy(){n.resetGridState(this.gridState)}redraw(){this.mapState.trafficOn&&(n.resetGridState(this.gridState),n.viewportChangeAction(this.gridState,this.mapState,this.modules))}activateStyleUpdating(){this.mapState.trafficOn&&n.startStyleUpdatingAction(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){this.mapState.trafficOn&&n.finishStyleUpdatingAction(this.gridState)}update(){if(!this.mapState.trafficOn)return;let e=!1;if(n.equalSets(this.regionIds,this.mapState.shownRegionIds)||(this.regionIds=new Set(this.mapState.shownRegionIds),e=!0),Date.now()-this.lastUpdateTime>n.traffic.updateInterval&&(e=!0,this.fetchMetaRetryAttempt=null),this.fetchMetaRetryAttempt!==null&&this.fetchMetaRetryAttempt<n.traffic.fetchMetaRetryDelays.length&&Date.now()-this.lastUpdateTime>n.traffic.fetchMetaRetryDelays[this.fetchMetaRetryAttempt]&&(this.fetchMetaRetryAttempt++,e=!0),e&&this.fetchMeta(),this.timestamp===void 0)return;(this.viewportDiffer.check(this.mapState)||this.justEnabled)&&(this.justEnabled=!1,n.viewportChangeAction(this.gridState,this.mapState,this.modules),this.modules.renderer.addRerenderEvent());const t=B({},this.gridState.displayedMods);n.newFrameAction(this.gridState,this.mapState,this.modules),this.fetch(n.getTilesToFetch(this.gridState),this.timestamp),this.abortFetch(n.getTilesToAbortFetch(this.gridState)),this.generate(n.getTilesToGenerate(this.gridState)),this.clearTiles(n.getTilesToRemove(this.gridState)),n.updateScene(this.modules,this.mapState,this.gridState,t)}viewportTilesReady(){return n.viewportTilesReady(this.gridState.tiles,this.gridState.viewportTiles)}getMemoryFootprint(){const e=this.gridState,t={gridState:{displayedMods:Object.keys(e.displayedMods).map(o=>n.modStatsJs(e.displayedMods[o])),tileModsCache:e.tileModsCache.keys().filter(o=>!e.displayedMods[o]).map(o=>n.modStatsJs(e.tileModsCache.get(o)))}},i={gridState:{displayedMods:Object.keys(e.displayedMods).map(o=>n.modStatsGpu(e.displayedMods[o])),tileModsCache:e.tileModsCache.keys().filter(o=>!e.displayedMods[o]).map(o=>n.modStatsGpu(e.tileModsCache.get(o)))}};return{js:de(B({},t),{"--sum":n.getTotalMemory(t)}),gpu:de(B({},t),{"--sum":n.getTotalMemory(i)})}}fetch(e,t){e.sort((i,o)=>n.compare(this.mapState.center,i,o)).forEach(i=>Tg(i,this.modules,this.mapState,this.regionIds,t))}abortFetch(e){e.forEach(t=>{this.modules.workers.parser.abortTrafficTileRequest(t.key)})}generate(e){e.sort((t,i)=>n.compare(this.mapState.center,t,i)).forEach(t=>{const i=n.getTileModToGenerate(t);i&&this.modules.workers.parser.generateTrafficTile({styleId:this.mapState.handyStyleId,coords:t.coords,pixelRatio:window.devicePixelRatio,styleState:this.mapState.styleState,sourceId:this.modules.defaultSource.getId()}).then(o=>{if(!o){n.logEmptyTileGenerationResponse("traffic");return}Array.isArray(o.results)&&n.addGeneratedDataToTileMod(i,o.results)})})}clearTiles(e){for(const t of e)this.modules.workers.parser.deleteTrafficTile(t.key),delete this.gridState.tiles[t.key]}fetchMeta(){if(this.isMetaLoading||!this.regionIds.size)return;if(n.equalSets(this.regionIds,wg)){console.warn("Traffic metadata request skip: only Universe"),this.lastUpdateTime=Date.now();return}this.isMetaLoading=!0;const e=this.mapState,t=n.template(n.traffic.timestampUrl,{host:e.trafficServer,protocol:e.trafficProtocol||e.tileProtocol,regions:Array.from(this.regionIds).join(",")});fetch(t).then(i=>{if(i.ok)return i.json();throw new as(`Request traffic timestamp error with status ${i.status}`,!1)}).then(i=>{var a,r;if(!i.length||((a=i[0])==null?void 0:a.time)===void 0||((r=i[0])==null?void 0:r.score)===void 0)throw new as(`Bad traffic timestamp and score response ${i.toString()}`,!0);let o=0;i.forEach(l=>o+=l.score),o=Math.round(o/i.length),this.modules.map.emit("trafficscore",{score:o}),this.timestamp=i[0].time,this.isMetaLoading=!1,this.lastUpdateTime=Date.now(),this.fetchMetaRetryAttempt=null,this.redraw()}).catch(i=>{var o;!(i instanceof as)||!i.noRetry?this.fetchMetaRetryAttempt=(o=this.fetchMetaRetryAttempt)!=null?o:0:this.fetchMetaRetryAttempt=null,this.lastUpdateTime=Date.now(),this.isMetaLoading=!1,console.error(i)})}}function Tg(s,e,t,i,o){i.size&&e.workers.parser.fetchTrafficTile({coords:s.coords,tileServer:t.trafficServer,tileProtocol:t.trafficProtocol||t.tileProtocol,regionIds:Array.from(i),timestamp:o}).then(()=>{s.status===n.TileStatus.Loading&&(s.serverMetadata=[{regionId:0,metatileHash:-2}])})}class Mg{constructor(e){this.externalContainer=e,this.rootContainer=document.createElement("div"),this.rootContainer.style.position="relative",this.rootContainer.style.height="100%",this.rootContainer.style.width="100%",this.rootContainer.style.overflow="hidden",this.externalContainer.appendChild(this.rootContainer),this.mapContainer=document.createElement("div"),this.mapContainer.style.position="relative",this.mapContainer.style.height="100%",this.mapContainer.style.width="100%",this.mapContainer.style.touchAction="none",this.mapContainer.style.webkitUserSelect="none",this.mapContainer.style.userSelect="none",this.rootContainer.appendChild(this.mapContainer),this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.mapContainer.appendChild(this.canvas),this.htmlContainerInMap=document.createElement("div"),this.htmlContainerInMap.style.position="absolute",this.htmlContainerInMap.style.left="0",this.htmlContainerInMap.style.top="0",this.htmlContainerInMap.style.width="100%",this.htmlContainerInMap.style.height="0",this.htmlContainerInMap.style.webkitUserSelect="auto",this.htmlContainerInMap.style.userSelect="auto",this.mapContainer.appendChild(this.htmlContainerInMap),this.htmlContainerOutMap=document.createElement("div"),this.htmlContainerOutMap.style.position="absolute",this.htmlContainerOutMap.style.left="0",this.htmlContainerOutMap.style.top="0",this.htmlContainerOutMap.style.width="100%",this.htmlContainerOutMap.style.height="0",this.mapContainer.after(this.htmlContainerOutMap)}setCanvasSize(e,t){const i=window.devicePixelRatio;return this.canvas.width=e*i,this.canvas.height=t*i,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px",this}destroy(){for(;this.externalContainer.lastChild;)this.externalContainer.removeChild(this.externalContainer.lastChild)}isActionWithCanvas(e){return e.target===this.canvas}isActionWithMap(e){return e instanceof MouseEvent||e instanceof KeyboardEvent?this.isTargetInMap(e.target):Array.from(e.touches).map(i=>i.target).some(i=>this.isTargetInMap(i))}isTargetInMap(e){return!e||!(e instanceof Node)?!1:this.mapContainer.contains(e)}}class Eg{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.textureKeys=[],this.texturesMap=new Map}addTexture(e,t){return K(this,null,function*(){this.loadingCounter++;const i=yield yn(e);return this.storeTexture(i,t)})}addPreparedTexture(e){const t=`prepared-${n.uniqId()}`;return this.textureKeys.push(t),this.texturesMap.set(t,e),this.textureKeys.length-1}updatePreparedTexture(e,t){this.deleteTexture(e),this.texturesMap.set(this.textureKeys[e],t)}loadTexture(e,t){return K(this,null,function*(){this.loadingCounter++;const i=yield this.loadImage(e);if(!i){this.decreaseLoadingCounter();return}return this.storeTexture(i,t)})}getTexture(e){return this.texturesMap.get(this.textureKeys[e])}destroy(){this.textureKeys=[],this.texturesMap.clear()}deleteTexture(e){var i;const t=this.textureKeys[e];return(i=this.texturesMap.get(t))==null||i.remove(),this.texturesMap.delete(t)}getMemoryFootprint(){const e={texturesMap:Array.from(this.texturesMap.values()).map(n.textureSizeJs)},t={texturesMap:Array.from(this.texturesMap.values()).map(n.textureSizeGpu)};return{js:de(B({},e),{"--sum":n.getTotalMemory(e)}),gpu:de(B({},t),{"--sum":n.getTotalMemory(t)})}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}storeTexture(e,t){var f,m,p,v,x,g,y;const i=t==null?void 0:t.size,o=(f=t==null?void 0:t.pixelRatio)!=null?f:window.devicePixelRatio,a=(m=t==null?void 0:t.imagePadding)!=null?m:1;this.decreaseLoadingCounter();const r=e.getAttribute("src")||e.currentSrc,l=Ig(r,i),c=this.textureKeys.indexOf(l);if(c>-1&&this.texturesMap.has(l))return c;const d=(i?[i[0],i[1]]:[e.width,e.height]).map(b=>b*o),_=Cr(e,d);e.remove();const u=d.map(b=>b+2*a);if(!(t!=null&&t.skipAtlasSizeChecking)&&(u[0]>n.atlasSize[0]||u[1]>n.atlasSize[1]))throw new Error(`Image texture dimensions ${u} are larger than the maximum possible ${n.atlasSize}`);const h=new w(void 0,{size:u,flipY:(p=t==null?void 0:t.flipY)!=null?p:!1,generateMipmaps:t==null?void 0:t.generateMipmaps,magFilter:w.LinearFilter,minFilter:(v=t==null?void 0:t.minFilter)!=null?v:w.LinearFilter,wrapS:(x=t==null?void 0:t.wrapS)!=null?x:w.defaultOptions.wrapS,wrapT:(g=t==null?void 0:t.wrapT)!=null?g:w.defaultOptions.wrapT,premultiplyAlpha:(y=t==null?void 0:t.premultiplyAlpha)!=null?y:w.defaultOptions.premultiplyAlpha});return this.modules.renderer.prepareTexture(h),h.subImage(_,a,a),_.remove(),this.texturesMap.set(l,h),this.textureKeys.push(l),this.modules.renderer.addRerenderEvent(),this.textureKeys.length-1}loadImage(e){return K(this,null,function*(){return new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>t(i),i.onerror=()=>t(void 0)})})}}function Ig(s,e){const t=e!==void 0?`_${e[0]},${e[1]}`:"";return`${s}${t}`}const gl=!0,yl=!1,xl=!1,bl=[0];class Cg{constructor(e){this.isLoading=!1,this.attempts=0,this.getKeyInfo=()=>K(this,null,function*(){return yield this.request}),this.isIdle=()=>!this.isLoading;const{tileKey:t,keyUrl:i}=e;if(t===n.tiles.tileKey||!n.keyServerPath)this.request=Promise.resolve({showCommPoi:!1,urbi:!1,hideCopyright:!0});else{const o=n.getUrlFromTemplate(i,{keyID:t});this.isLoading=!0;const a=()=>K(this,null,function*(){return bl.length>=this.attempts?(this.attempts&&(yield new Promise(r=>{this.lastTimeout=window.setTimeout(r,bl[this.attempts]*1e3)}),this.clearLastTimeout()),this.attempts++,fetch(o).then(r=>r.ok?r.json():a(),a)):(console.error("Could not load tile key info. A style layers with commercial POI will be added to applied styles."),Promise.resolve(void 0))});this.request=a().then(r=>{if(this.isLoading=!1,!r||!r.result||r.meta.code!==200)return{showCommPoi:gl,hideCopyright:xl,urbi:yl,error:!0};const{showCommPoi:l,hideCopyright:c,urbi:d}=r.result.service.properties.public;return{showCommPoi:n.isNullish(l)?gl:!!l,hideCopyright:n.isNullish(c)?xl:!!c,urbi:n.isNullish(d)?yl:!!d}})}}destroy(){this.clearLastTimeout()}clearLastTimeout(){this.lastTimeout!==void 0&&(clearTimeout(this.lastTimeout),this.lastTimeout=void 0)}}class Lg{constructor(){this.sources=[],this.viewportSources=[]}addSource(e){this.sources.push(e),e.type==="geojson"&&e.subtype==="viewport-internal"&&e instanceof n.GeoJsonViewportSource&&this.viewportSources.push(e)}removeSource(e){this.sources=this.sources.filter(t=>t.getId()!==e),this.viewportSources=this.viewportSources.filter(t=>t.getId()!==e)}getSourceById(e){return this.sources.find(t=>t.getId()===e)}updateViewportSources(){this.viewportSources.forEach(e=>e.update())}}const Pg={dead:!0,alive:!0,unused:!0,commercialDead:!1,commercialAlive:!1};class Bg{constructor(e,t){this.mapState=e,this.modules=t,this.options={},this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.sizeDiffer=new n.Differ([{path:"size",type:"vec2"}])}update(){this.isEnabled()&&(this.sizeDiffer.check(this.mapState)&&this.updateSize(),this.viewportDiffer.check(this.mapState)&&this.clear())}isEnabled(){return!!this.canvas}show(e=Pg){this.options=e,Object.values(e).every(i=>i===!1)?this.hide():(this.createCanvas(),this.mapState.needLabeling=!0)}hide(){this.canvas&&(this.modules.layout.mapContainer.removeChild(this.canvas),this.ctx=void 0,this.canvas=void 0)}drawLabels(e){if(!this.canvas||!this.ctx)return;const t=this.ctx,i=this.options,o={[n.BBoxType.Dead]:"#ff0000",[n.BBoxType.Alive]:"#30763c",[n.BBoxType.Unused]:"#aaa",[n.BBoxType.CommercialAlive]:"#3a9f22",[n.BBoxType.CommercialDead]:"#ff0000"},a=new Int32Array(e),r={[n.BBoxType.Dead]:[],[n.BBoxType.Alive]:[],[n.BBoxType.Unused]:[],[n.BBoxType.CommercialAlive]:[],[n.BBoxType.CommercialDead]:[]};for(let d=0;d<a.length;d+=5){const _=a[d+4];r[_].push({x:a[d],y:a[d+1],width:a[d+2],height:a[d+3]})}this.clear();const l=window.devicePixelRatio,c=d=>{t.strokeStyle=o[d],r[d].forEach(_=>t.strokeRect(_.x*l+.5,_.y*l+.5,_.width*l,_.height*l))};t.setLineDash([]),i.unused&&c(n.BBoxType.Unused),i.dead&&c(n.BBoxType.Dead),i.alive&&c(n.BBoxType.Alive),t.setLineDash([6]),i.commercialDead&&c(n.BBoxType.CommercialDead),i.commercialAlive&&c(n.BBoxType.CommercialAlive)}clear(){if(this.canvas&&this.ctx){const{clientWidth:e,clientHeight:t}=this.canvas;this.ctx.clearRect(0,0,e*window.devicePixelRatio,t*window.devicePixelRatio)}}createCanvas(){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.pointerEvents="none",this.modules.layout.mapContainer.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")||void 0,this.updateSize())}updateSize(){if(!this.canvas)return;const{clientWidth:e,clientHeight:t}=this.modules.layout.rootContainer;this.canvas.width=e*window.devicePixelRatio,this.canvas.height=t*window.devicePixelRatio,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px"}}const zg=n.create$1();class Rg{constructor(e){this.globHaloStops=[-2.5,0,1.5,13],this.globeHaloExpFactor=-1,this.fogLimits=new Float32Array([3.7,4.5]),this.fogHorizonBlend=.12,this.fogHorizonLevel=-.07,this.squaredDistMaxFog=0,this.lastStyleId=NaN,this.starsCount=2e4,this.starsGenerationCtx={randomSeed:12345},this.starsUpdateNeeded=!0,this.modules=e;const t=this.modules.renderer.getShaderProgram("sky"),i=this.modules.renderer.createBuffer(new Float32Array([-1,-1,1,-1,1,1,-1,1]));this.vao=y_(i,t)}update(){this.updateFog();const e=this.modules.map.state;isNaN(e.handyStyleId)||this.lastStyleId!==e.handyStyleId&&(this.updateSky(),this.updateStars(),this.lastStyleId=e.handyStyleId)}setParameters(e){const t=this.modules.map.state;e.min!==void 0&&(this.fogLimits[0]=e.min),e.max!==void 0&&(this.fogLimits[1]=e.max),e.horizonBlend!==void 0&&(this.fogHorizonBlend=e.horizonBlend),e.horizonLevel!==void 0&&(this.fogHorizonLevel=e.horizonLevel);const i=this.modules.styleManager.getStyleLayer(t.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID);i&&(e.fogColor!==void 0&&(i.style.fogColor=n.isArrayOfNumbers(e.fogColor)?n.toStyleColor(e.fogColor):e.fogColor),e.skyColor!==void 0&&(i.style.skyColor=n.isArrayOfNumbers(e.skyColor)?n.toStyleColor(e.skyColor):e.skyColor),this.modules.renderer.addRerenderEvent())}renderSky(){if(!this.isSkyEnabled())return;this.modules.renderer.applyGpuState(Re);const e=this.modules.renderer.getShaderProgram("sky");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||(Hs(e,this.modules.map.state,this.modules),W(e,this.modules.map.state,this.modules),$(e,this.modules.map.state,this.modules)),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderStars(){if(!this.starsVao)return;this.modules.renderer.applyGpuState(Re);const e=this.modules.renderer.getShaderProgram("stars");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Vs(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.starsVao),this.modules.renderer.drawPoints(0,this.starsCount)}renderGlobeHaloBackground(){this.modules.renderer.applyGpuState(Re);const e=this.modules.renderer.getShaderProgram("globeHaloBackground");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||to(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderGlobeHalo(){this.modules.renderer.applyGpuState(L_);const e=this.modules.renderer.getShaderProgram("globeHalo");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||to(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}isFogEnabled(){var a,r;if(this.modules.map.getFeatureFlag("fogOff")||!((a=this.envStyleLayer)!=null&&a.style.fogColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((r=this.envStyleLayer)==null?void 0:r.style.fogColor,i);return o&&o.value[3]!==0}isSkyEnabled(){var a,r;if(this.modules.map.getFeatureFlag("skyOff")||!((a=this.envStyleLayer)!=null&&a.style.skyColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((r=this.envStyleLayer)==null?void 0:r.style.skyColor,i);return o&&o.value[3]!==0}isPointInFog(e){const t=this.modules.camera;return n.sqrDist(e,t.position)>this.squaredDistMaxFog}isAABBInFog(e){if(!this.modules.environmentManager.isFogEnabled())return!1;const t=this.modules.camera,i=n.projectToXyRect(t.position,e.min,e.max,zg);return this.isPointInFog(i)}updateSky(){const e=this.modules.styleManager.getStyleLayer(this.modules.map.state.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID);this.envStyleLayer=e}updateStars(){if(!this.starsUpdateNeeded)return;this.starsUpdateNeeded=!1;const e=n.generatePointsOnSphere(this.starsGenerationCtx,this.starsCount),t=4,i=new Float32Array(t*e.length);for(let r=0;r<e.length;++r){const l=e[r],c=n.getRandomValue(this.starsGenerationCtx,0,1);i[t*r]=l[0],i[t*r+1]=l[1],i[t*r+2]=l[2],i[t*r+3]=c}const o=this.modules.renderer.createBuffer(i),a=this.modules.renderer.getShaderProgram("stars");this.starsVao=x_(o,a)}updateFog(){const e=this.modules.camera;this.squaredDistMaxFog=je(e.fogDistance*this.fogLimits[1],2)}}class Fg{constructor(e,t){this.mapState=e,this.mapModules=t,this.state={}}add(e,t=0,i=1,o=n.buildingAnimation.easing,a=n.buildingAnimation.duration){this.state[e]||(this.state[e]={tickerConfig:{start:t,end:i,duration:a,easing:o},tickerKey:"",readiness:t===i?1:0})}has(e){return!!this.state[e]}remove(e){this.state[e]&&delete this.state[e];const t=this.buildTickerKey(e);n.exist(t,this.mapState)&&n.stop(t,this.mapState)}getReadiness(e){var t;return(t=this.state[e])==null?void 0:t.readiness}isAnimating(e){if(!e){for(const t in this.state)if(n.get(this.state[t].tickerKey,this.mapState)!==void 0)return!0;return!1}return this.state[e]?n.get(this.state[e].tickerKey,this.mapState)!==void 0:!1}update(){const e=[];for(const t in this.state){const i=this.state[t];if(this.mapModules.tileManager.viewportTilesReady()){const o=i.readiness,{start:a,end:r,duration:l,easing:c}=i.tickerConfig;if(i.tickerKey)n.update(i.tickerKey,{step:(d,_)=>{i.readiness=_}},this.mapState);else{const d=this.buildTickerKey(t);i.tickerKey=d,n.start(d,{easing:c},this.mapState,a,r,l,1)}i.readiness===1&&o!==1&&e.push(t)}}return e}buildTickerKey(e){return`gltf-${e}`}}const Dg=!0,rs="#ffffffff",Og=0,Ng=0,kg=1,ls=15,Ug=n.tileZoomToSize(ls)/n.MAP_POINTS_IN_METER,Fn=n.maxTilePoint/2,Gg=["coordinates","rotation","scale","offset"];let cs=class Es extends We{constructor(e,t){var T,P,S,C,I,E,F,j,ee;super(e,{interactive:(T=t.interactive)!=null?T:!1}),this.map=e,this.needRerender=()=>this.isVisible()&&n.isTileVisible(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState.tilesBounds,this.modules,n.MODELS_TILES_VIEWPORT_PADDING),this.hovered=!1,this.selected=!1,this.status=t.hideOnInit?"hidden":"visible",this.interactiveOcclusion=(P=t.interactiveOcclusion)!=null?P:Dg,this.disableAnimation=t.disableAnimation,this.linkedIds=t.linkedIds,this.planId=t.planId,this.tickerNames=new Map;const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,collector:a,tileManager:r,layers:l,assetManager:c}=this.modules,{ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f}=t,m=Ml((S=t.rotation)!=null?S:Og),p=(C=t.scale)!=null?C:kg,v=El((I=t.offset)!=null?I:Ng,t.coordinates[1]);if(this.appliedTransformations={scale:p,rotation:m,offset:v},this.layer=n.makeHandyStyleLayer({type:"model",id:`dynamic-gltf-model-${this.uniqId}`,style:{modelSrc:["get","model_src"],rotation:Array.isArray(m)?["literal",m]:m,scale:Array.isArray(p)?["literal",p]:p,offset:Array.isArray(v)?["literal",v]:v,linkedIds:["get","linkedIds"],ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f,color:["match",["objectAttr","hovered"],[!0],((E=t.hover)==null?void 0:E.color)||rs,["match",["objectAttr","selected"],[!0],((F=t.select)==null?void 0:F.color)||rs,t.color||rs]]},minzoom:t.minZoom,maxzoom:t.maxZoom,interactive:this.interactive,interactiveOcclusion:this.interactiveOcclusion}),!this.layer)return;(j=t.hover)!=null&&j.color&&(this.on("mouseover",this.switchToHoveredColor),this.on("mouseout",this.switchToNormalColor)),o.addLayer(this.layer,t.zIndex);const x=n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,ls),g=n.optionsToTileAttrs({model_src:t.modelSrc,linkedIds:t.linkedIds,db_plan_id:t.planId}),y=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,g,n.emptyFeatureAttrs,t.interactive?"0":"");n.runPrecomputes(this.layer,y),n.generateSafely({collector:a,generator:n.GltfModelGenerator.generateInstances,args:[o.getStyle(),this.layer,y,{x:[Fn],y:[Fn],z:[(ee=this.position.userValue[2])!=null?ee:0]},n.createTileInfo(x),NaN]});const b=a.getAccumulatedData(),M=new n.TileObject("dynamicObject",b.data,this.modules,this.mapState,x,this);c.fillDataModelUrlMap(b.dataModelsUrls),this.modelId=b.dataModelsUrls[t.modelSrc],this.modelId!==void 0&&(c.loadModel(t.modelSrc,this.modelId,n.DYNAMIC_STYLE_ID,!0,this.layer,!1,()=>{this.status==="visible"&&(r.addObject(M),this.modules.renderer.addRerenderEvent(),this.linkedIds&&this.map.hideBuildingsById(this.linkedIds),this.updateIdentifier()),setTimeout(()=>this.emit("modelloaded"),0)}),this.tileObjects.push(M),t.interactive&&this.identifyIds.push(b.identifyIds),l.addLayer(this),a.reset(),this.status==="visible"&&this.hideLinkedObjects())}update(){if(super.update(),!this.tickerNames.size)return;const e=[],t={};this.tickerNames.forEach((i,o)=>{n.update(i,{step:(a,r)=>{t[o]=r},complete:()=>{e.push(o)}},this.mapState)}),(t.coordinates!==void 0||t.rotation!==void 0||t.scale!==void 0||t.offset!==void 0)&&this.applyTransformations(t.coordinates,t.rotation,t.scale,t.offset),e.forEach(i=>{this.tickerNames.delete(i)}),this.interactive&&this.needRerender()&&this.modules.identifier.queryFillCache()}setState({hovered:e,selected:t}){e!==void 0&&e!==this.hovered&&(this.hovered=e,this.modules.renderer.addRerenderEvent()),t!==void 0&&t!==this.selected&&(this.selected=t,this.modules.renderer.addRerenderEvent())}isAnimationDisabled(){return this.disableAnimation}getLinkedIds(){return this.linkedIds}isVisible(){return this.status==="visible"}hide(){this.status==="visible"&&(this.status="hidden",this.tileObjects.forEach(e=>{this.modules.tileManager.removeObject(e)}),this.showHiddenBuildings(),this.showLinkedObjects(),this.mapState.shouldIsIdleWaitForUpdates=!0,this.modules.renderer.addRerenderEvent(),this.updateIdentifier())}isOutOfMainReplica(){return!1}show(){this.status==="hidden"&&(this.status="visible",this.tileObjects.forEach(e=>{this.modules.tileManager.addObject(e)}),this.linkedIds&&this.map.hideBuildingsById(this.linkedIds),this.hideLinkedObjects(),this.mapState.shouldIsIdleWaitForUpdates=!0,this.modules.renderer.addRerenderEvent(),this.updateIdentifier())}destroy(e){this.status!=="destroyed"&&(this.stopTransformation(),this.status="destroyed",this.modelId!==void 0&&!this.modules.layers.getDynamicObjectLayers().filter(i=>i instanceof Es&&i!==this).some(i=>i.modelId===this.modelId)&&!e&&this.modules.assetManager.removeModel(String(this.modelId)),this.updateIdentifier(),this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.showHiddenBuildings(),this.off("mouseover",this.switchToHoveredColor),this.off("mouseout",this.switchToNormalColor),this.showLinkedObjects(),super.destroy())}transform(e){var o,a;if(this.status==="destroyed"||!this.layer)return;this.stopTransformation();const t={};e.forEach(r=>{const l=Vg(r);if(!l)return;const{duration:c=0,easing:d="linear"}=r;t[l]={value:r[l],duration:c,easing:d}});const i={};for(const r in t){if(!Hg(r)||t[r]===void 0)continue;let l;if(r==="coordinates"?l=n.Mercator.fromGeo(t[r].value):r==="offset"?l=El(t[r].value,(a=(o=t.coordinates)==null?void 0:o.value[1])!=null?a:n.Mercator.toGeo(this.position.userValue)[1]):l=t[r].value,!t[r].duration){i[r]=l;continue}const c=`dynamicGltfModel-${r}-${this.uniqId}`;let d,_;if(r==="coordinates")d=this.position.userValue,_=l;else{const u=[0,0,0];n.getTriple(this.appliedTransformations[r],u),d=u;const h=[0,0,0];n.getTriple(l,h),_=h}n.start(c,{easing:t[r].easing,renderAfterUpdate:this.needRerender},this.mapState,d,_,t[r].duration,1,{layerId:this.layer.innerId,styleId:n.DYNAMIC_STYLE_ID}),this.tickerNames.set(r,c)}(i.coordinates!==void 0||i.rotation!==void 0||i.scale!==void 0||i.offset!==void 0)&&(this.applyTransformations(i.coordinates,i.rotation,i.scale,i.offset),this.modules.renderer.addRerenderEvent(),this.updateIdentifier())}stopTransformation(){this.tickerNames.forEach(e=>{n.stop(e,this.mapState)}),this.tickerNames.clear()}getCoordinates(){return n.Mercator.toGeo(this.position.userValue)}getScale(){const e=[0,0,0];return n.getTriple(this.appliedTransformations.scale,e),e}getRotation(){const e=[0,0,0];return n.getTriple(this.appliedTransformations.rotation,e),e}getOffset(){const e=[0,0,0];return n.getTriple(this.appliedTransformations.offset,e),e}applyTransformations(e,t,i,o){var l,c,d;const a=this.tileObjects[0];if(!a)return;const r=a.buffers[0];if(r){if(e&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},a.setTileCoords(n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,ls),this.mapState)),t!==void 0||i!==void 0){const _=Ml(t!=null?t:this.appliedTransformations.rotation),u=i!=null?i:this.appliedTransformations.scale;this.appliedTransformations.rotation=_,this.appliedTransformations.scale=u}if(o!==void 0){const _=o!=null?o:this.appliedTransformations.offset;this.appliedTransformations.offset=_}n.getTriple(this.appliedTransformations.offset,Tl),n.getTriple(this.appliedTransformations.scale,wl),n.getTriple(this.appliedTransformations.rotation,Sl),n.GltfModelGenerator.patchBuffer(r,0,n.createTileInfo(a.coords),[Fn,Fn,(l=this.position.userValue[2])!=null?l:0],Tl,wl,Sl,((d=(c=this.layer)==null?void 0:c.minzoom)!=null?d:0)<n.globeConfig.globeMaxZoom)}}switchToHoveredColor(){this.hovered=!0,this.modules.renderer.addRerenderEvent()}switchToNormalColor(){this.hovered=!1,this.modules.renderer.addRerenderEvent()}updateIdentifier(){this.interactive&&this.modules.identifier.resetCache()}showLinkedObjects(){const e=this.planId?n.FLOOR_ID_SCOPE:n.DYNAMIC_MODEL_ID_SCOPE;this.linkedIds&&this.modules.identifier.getIdScope(e).show(this.linkedIds)}hideLinkedObjects(){const e=this.planId?n.FLOOR_ID_SCOPE:n.DYNAMIC_MODEL_ID_SCOPE;this.linkedIds&&this.modules.identifier.getIdScope(e).hide(this.linkedIds)}showHiddenBuildings(){if(!this.linkedIds)return;const e=this.modules.layers.getDynamicObjectLayers().filter(t=>t instanceof Es&&t!==this&&t.isVisible());this.linkedIds.forEach(t=>{e.every(o=>{var a;return!((a=o.getLinkedIds())!=null&&a.includes(t))})&&this.map.showHiddenBuildingsById([t])})}};const wl=[0,0,0],Sl=[0,0,0],Tl=[0,0,0];function Ml(s){return Array.isArray(s)?s.map(e=>e%360):s%360}function El(s,e){const t=Ug/n.Mercator.scaleFactor(e),i=["x","y"].filter((o,a)=>{const r=Array.isArray(s)?s[a]:s;return r<-t||r>t});return i.length&&console.warn(`
            The offset is too big along ${i.map(o=>`${o}-axis`).join(" and ")} at the current latitude.
            Please, use more accurate coordinates to place the model.
        `),Array.isArray(s)?[s[0]%t,s[1]%t,s[2]]:[s%t,s%t,s]}function Hg(s){return Gg.includes(s)}function Vg(s){if("coordinates"in s)return"coordinates";if("rotation"in s)return"rotation";if("scale"in s)return"scale";if("offset"in s)return"offset"}const Zg=[0,0,0],jg=[0,0,0],Wg=[0,0,0],$g="modelshow",Xg="modelhide",Dn=0,Il=.1;class Kg{constructor(e,t){this.sceneObjects=new Map,this.sceneObjectsVisibilityMap=new Map,this.viewportDiffer=new n.Differ([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this.mapState=e,this.mapModules=t,this.modelsAnimator=new Fg(e,t),this.modelInfo={},this.buildingIds=new Set,this.objectIdToLayerModelKey={},this.linkedIdToObjectId={},this.layerModelKeyBySourceTile=new Map,this.disabled=!1}addLayerModelToSourceTileMap(e,t){const i=e,o=ds(t.attributes.styleId,t.attributes.sourceId,t.tile.coords),a=this.layerModelKeyBySourceTile.get(o);a?a.add(i):this.layerModelKeyBySourceTile.set(o,new Set([i]))}clearSourceTileMapByTiles(e,t){t.map(i=>ds(this.mapState.handyStyleId,e,i.coords)).forEach(i=>this.layerModelKeyBySourceTile.delete(i))}clearSourceTileMapBySource(e){Array.from(this.layerModelKeyBySourceTile).map(i=>i[0]).filter(i=>i.split("_")[1]===String(e)).forEach(i=>this.layerModelKeyBySourceTile.delete(i))}getCurrentLayerModelId(e,t){var o;const i=On(e);return(o=this.modelInfo[i])==null?void 0:o.modelIds[t.id]}getModelOpacity(e){var i;if(e===void 0)return Dn;const t=On(e.attributes);return t&&(i=this.modelsAnimator.getReadiness(t))!=null?i:Dn}getModelHeightFactor(e){var i;if(!e)return 1;const t=On(e.attributes);return(i=this.modelsAnimator.getReadiness(t))!=null?i:1}isAnimating(e){if(!e)return this.modelsAnimator.isAnimating();const t=this.linkedIdToLayerModelKey(e);return t?this.modelsAnimator.isAnimating(t):!1}objectIdToKey(e){return this.objectIdToLayerModelKey[e]}update(){this.syncStateWithSceneObjects(),this.modelsAnimator.update().length&&this.addNewSceneObjectsToVisibilityMap(),this.viewportDiffer.check(this.mapState)&&this.checkSceneObjectsVisibilityMap(),this.updateObjectsVisibility()}addSceneObject(e){const t=On(e.attributes);let i=this.modelInfo[t];i?this.objectIdToLayerModelKey[e.id]||this.indexateObject(t,e,i):i=this.addLayerModel(e,t),i&&(i.modelIds[e.tile.id]=e.renderingProperties.modelId,this.sceneObjects.set(e.id,de(B({},e),{key:t})),this.addLayerModelToSourceTileMap(t,e))}removeSceneObject(e){this.sceneObjects.delete(e),delete this.objectIdToLayerModelKey[e]}allObjectsHaveCurrentModelId(e,t,i){var r;const o=ds(i,e,t),a=this.layerModelKeyBySourceTile.get(o);if(!a)return!0;for(const l of a){const c=(r=this.modelInfo[l])==null?void 0:r.modelIds;if(!c)return!1;for(const d in c)if(c[d]===void 0)return!1}return!0}finishStyleUpdating(){Array.from(this.layerModelKeyBySourceTile).map(t=>t[0]).filter(t=>t.split("_")[0]!==String(this.mapState.handyStyleId)).forEach(t=>this.layerModelKeyBySourceTile.delete(t))}updateModelId(e,t,i,o,a){var P,S,C,I;const{assetManager:r,sourceStorage:l,styleManager:c,camera:d,defaultSource:_}=this.mapModules,u=this.mapState;e.modelId=void 0;const{styleId:h,layerId:f,sourceId:m,sourceName:p,modelIndices:v,modelStepValues:x,modelStepSource:g}=t;if(!v.length)return;let y;switch(g){case n.ModelStepSource.None:y=0;break;case n.ModelStepSource.Zoom:y=Cl(x,u.styleZoom);break;case n.ModelStepSource.Distance:y=qg(o,i,d.position,x,a);break;default:return}if(y===-1)return;const b=v[y];if(b===void 0)return;const M=r.getModel(b,h);if(M)switch(M.status){case et.Loaded:e.modelId=b;const E=(S=(P=M.scenes.find((F,j)=>typeof t.scene=="number"&&!Number.isNaN(t.scene)&&j===t.scene||typeof t.scene=="string"&&F.name===t.scene))!=null?P:M.scenes.find((F,j)=>j===M.defaultScene))!=null?S:M.scenes.find((F,j)=>j===0);e.sceneId=E==null?void 0:E.id,M.usedEmptyScene=((I=(C=M.scenes.find(F=>F.id===e.sceneId))==null?void 0:C.objects.length)!=null?I:0)===0;return;case et.Failed:e.modelId=NaN;return}else{const E=c.getStyleLayer(h,f),F=r.getDataModelUrlById(b);if(E&&!this.disabled){if(F===void 0)r.loadModelByIndex(b,h,E);else if(F.length){const j=m===_.getId()&&p===In;r.loadModel(F,b,h,!1,E,j)}}}if(v.length===1)return;const T=l.getSourceById(m);T&&(g===n.ModelStepSource.Zoom?e.modelId=this.getModelIdByZoom(T,t,o,y):g===n.ModelStepSource.Distance&&(e.modelId=this.getModelIdByDistance(t,o)))}getModelIdByDistance(e,t){return this.getCurrentModelId(e,t)}getModelIdByZoom(e,t,i,o){const{styleId:a,modelIndices:r}=t,l=e.getZoomDirection();if(l===n.ZoomDirection.Stationary)return this.getCurrentModelId(t,i);const c=r.slice(0,o).reverse(),d=r.slice(o+1),_=l===n.ZoomDirection.ZoomingIn?c.concat(d):d.concat(c);for(let u=0;u<_.length;u++){const h=this.mapModules.assetManager.getModel(_[u],a);if(h&&h.status===et.Loaded)return _[u];if((h==null?void 0:h.status)===et.Failed)return NaN}}getCurrentModelId(e,t){const i=this.getCurrentLayerModelId(e,t);if(!i)return;const o=this.mapModules.assetManager.getModel(i,e.styleId);if(o&&o.status===et.Loaded)return i;if((o==null?void 0:o.status)===et.Failed)return NaN}syncStateWithSceneObjects(){if(this.disabled=this.mapModules.map.getFeatureFlag("modelsOff"),this.disabled){this.destroy();return}const e=new Set,t=new Set,i=Array.from(this.sceneObjects.values());for(let a=0;a<i.length;a++)this.processSceneObject(i[a],e,t);for(const a of t)this.sceneObjects.delete(a),delete this.objectIdToLayerModelKey[a];const o=this.mapState.styleZoom;for(const a of Object.keys(this.modelInfo)){const r=this.modelInfo[a];(!e.has(a)||o<r.layer.minzoom||o>=r.layer.maxzoom)&&this.removeLayerModel(a,r)}}processSceneObject(e,t,i){if(e.tile.destroyed){i.add(e.id);return}const o=e.key,a=this.modelInfo[o],r=this.mapState.disableModelsGrowthAnimation||e.tile.dynamicObject instanceof cs&&e.tile.dynamicObject.isAnimationDisabled();a&&!this.modelsAnimator.has(o)&&(this.mapModules.defaultSource.createModelsSource(),this.startAnimation(o,a,r)),a?this.objectIdToLayerModelKey[e.id]||this.indexateObject(o,e,a):this.addLayerModel(e,o,!0),t.add(o)}addLayerModel(e,t,i=!1){var r,l;const o=this.mapModules.styleManager.getStyleLayer(e.attributes.styleId,e.attributes.layerId);if(!o)return;if(i){const c=this.mapState.styleZoom;if(c<o.minzoom||c>=o.maxzoom)return}const a={layer:o,ids:e.tile.ids,linkedIds:[],ownerIds:new Set,modelIds:{},buildingId:((r=e.meta)==null?void 0:r.buildingId)||""};return(l=e.meta)!=null&&l.planId&&(a.planId=e.meta.planId),this.indexateObject(t,e,a),this.modelInfo[t]=a,a}startAnimation(e,t,i){var r;if(i){this.modelsAnimator.add(e,1,1);return}const o=(r=t.layer.minzoom)!=null?r:NaN;t.linkedIds.length>0&&this.mapModules.buildingHeightAnimator.getBuildingHeight(o)>.5?this.modelsAnimator.add(e,.5,1):this.modelsAnimator.add(e)}maybeEmitModelEvent(e,t,i){const o=!t.onKeyRemove&&!!i&&n.tetragonIntersectsBounds(i,{min:e.mapPoint,max:e.mapPoint}),a=e.visible;o!==a&&(e.visible=o,this.emitEvent(o&&!a?$g:Xg,e))}addNewSceneObjectsToVisibilityMap(){var i,o,a,r;const e=this.mapModules.camera.getViewportVertices(Il),t=Array.from(this.sceneObjects.values());for(let l=0;l<t.length;l++){const c=t[l];if((i=c.attributes)!=null&&i.emitShowHideEvents&&((o=c.meta)!=null&&o.buildingId)&&c.attributes.lngLat){const d=c.key,_={visible:!1,mapPoint:n.Mercator.fromGeo(c.attributes.lngLat),buildingId:((a=c.meta)==null?void 0:a.buildingId)||"",sublayer:((r=c.meta)==null?void 0:r.sublayer)||"",key:d};let u=this.sceneObjectsVisibilityMap.get(d);u||(u=new Map,this.sceneObjectsVisibilityMap.set(d,u)),u.get(c.meta.buildingId)||(u.set(c.meta.buildingId,_),this.maybeEmitModelEvent(_,{onKeyShow:!0},e))}}}checkSceneObjectsVisibilityMap(){const e=this.mapModules.camera.getViewportVertices(Il);this.sceneObjectsVisibilityMap.forEach(t=>t.forEach(i=>this.maybeEmitModelEvent(i,{},e)))}indexateObject(e,t,i){var a,r,l;this.objectIdToLayerModelKey[t.id]=e,i.ownerIds.add(t.id),i.buildingId=((a=t.meta)==null?void 0:a.buildingId)||"",i.buildingId&&this.buildingIds.add(i.buildingId);const o=(l=(r=t.meta)==null?void 0:r.linkedIds)!=null?l:[];if(i.linkedIds.push(...o),t.tile.purpose!=="c3d")for(const c of o)this.linkedIdToObjectId[c]=t.id}removeLayerModel(e,t){var o;(o=t.ids)==null||o.show(t.linkedIds);for(const a of t.ownerIds)delete this.objectIdToLayerModelKey[a];t.buildingId&&this.buildingIds.delete(t.buildingId),this.modelsAnimator.remove(e);const i=this.sceneObjectsVisibilityMap.get(e);i&&(i.forEach(a=>this.maybeEmitModelEvent(a,{onKeyRemove:!0})),this.sceneObjectsVisibilityMap.delete(e)),delete this.modelInfo[e]}linkedIdToLayerModelKey(e){const t=this.linkedIdToObjectId[e];if(!t)return null;const i=this.objectIdToLayerModelKey[t];return i||null}emitEvent(e,t){const{buildingId:i,sublayer:o}=t;if(!o){console.warn(`No sublayer for model ${t.key}`);return}if(!i){console.warn(`No buildingId for model ${t.key}`);return}const a=n.isCommercialModel(o);this.mapModules.map.emit(e,{sublayer:o,id:i,isCommercial:a})}updateObjectsVisibility(){var i;const e=this.mapModules.identifier.getIdScope(n.DYNAMIC_MODEL_ID_SCOPE),t=this.mapModules.identifier.getIdScope(n.DEFAULT_ID_SCOPE);e.getHidden().forEach(o=>{t.hide([o],n.HideLevel.All)});for(const o in this.modelInfo){const a=this.modelInfo[o],r=a.ids;if(!r)continue;const l=(i=this.modelsAnimator.getReadiness(o))!=null?i:Dn;for(const c of a.linkedIds){if(r.isHidden(c))continue;const d=a.planId!==void 0?n.HideLevel.FloorPolygons:n.HideLevel.PolygonExtrusion,_=r.isHidden(c,d);l>.5&&!_?r.hide([c],d):l<.5&&_&&r.show([c])}}}destroy(){this.mapModules.defaultSource.destroyModelsSource();for(const e in this.modelInfo){const t=this.modelInfo[e];this.removeLayerModel(e,t)}this.sceneObjects.clear()}}function On(s){const{layerId:e,modelIndices:t}=s;return`${e}_${t.join(",")}`}function ds(s,e,t){return`${s}_${e}_${JSON.stringify(t)}`}function qg(s,e,t,i,o){const a=s.modelMatrices.get(0);if(!a)return-1;let r=e.min,l=e.max;o||(r=n.transformMat4$1(jg,r,a),l=n.transformMat4$1(Wg,l,a));const c=n.projectToXyRect(t,r,l,Zg),d=n.Mercator.toGeo(c),_=n.Mercator.scaleFactor(d[1]),u=n.dist$1(t,c)/n.MAP_POINTS_IN_METER/_;return Cl(i,u)}function Cl(s,e){let t=0;for(;t<s.length&&!(e<s[t]);)t++;return t-1}const Yg=n.bezier(.42,0,1,1),Qg=(s,e,t,i)=>e+t*Yg(s/i),Jg=n.bezier(0,0,.58,1),Ag=(s,e,t,i)=>e+t*Jg(s/i),ey=n.bezier(.42,0,.58,1),ty=(s,e,t,i)=>e+t*ey(s/i);function Ll(s){switch(s[0]){case"cubic-bezier":{const e=n.bezier(s[1],s[2],s[3],s[4]);return(t,i,o,a)=>i+o*e(t/a)}case"exponential":{const e=s[1];return(t,i,o,a)=>{const r=i,l=i+o,c=t/a,_=(je(e,c)-1)/(je(e,1)-1);return(1-_)*r+_*l}}case"ease":return n.ease;case"ease-in":return Qg;case"ease-out":return Ag;case"ease-in-out":return ty;case"linear":return n.linear;default:return n.assertUnreachable(s,!0),console.warn("Invalid texture animation easing:",s),console.warn('Fallback to "linear".'),n.linear}}class iy{constructor(e,t){this.rerenderEvents=[],this.prevObjects=new Map,this.currentObjects=new Map,this.doubleSampledTextureAnimationStateMap=new Map,this.mapState=e,this.modules=t}frameEnd(){this.rerenderEvents.forEach(e=>this.modules.renderer.addRerenderEvent(e)),this.clearUnusedAnimationState(),this.doubleSampledTextureAnimationStateCleanup()}frameStart(){this.rerenderEvents=[]}clearAllTickers(){for(const e of this.currentObjects.keys())n.stop(e,this.mapState);this.clearUnusedAnimationState(),this.prevObjects=new Map,this.currentObjects=new Map}update(){const e=Date.now()+ +(this.mapState.styleState._customUserTimeOffset||0);[...this.prevObjects.values()].some(i=>i.timeToUpdate&&i.timeToUpdate<e)&&this.refresh()}animateGltfObject(e,t,i){const{localMatrix:o,animationStack:a,transformStack:r}=e.renderingProperties;if(t.style.playAnimation===void 0||!(a!=null&&a.length)||!o||!a||!r)return;const l=this.updateAnimationKeyframes(e,t);Lr(o,a,r,i.buffers,l)}animatePolygonNormalMapTexture(e,t){var E;if(!t.style.normalMapTextureAnimation)return[!1,[0,0,0,0]];let i=1;const o=t.innerId,a=e.attributes.styleId,r=`${a}_${o}`,l=Date.now(),[[c,d],[_,u],[h,f],m,p,v,x,g]=this.resolveDoubleSampledTextureAnimationOptions(t),y=[h,f,0,0];if(this.mapState.disableLayerAnimation)return[!1,y];const b=(E=this.doubleSampledTextureAnimationStateMap.get(r))!=null?E:{lastKnownOffsets:y,animationStage:0,previousTimestamp:l},{lastKnownOffsets:M,previousTimestamp:T,animationStage:P}=b;let S=P;const C=(l-T)/1e3;switch(P){case 0:{let F=!1;const j=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),ee=n.resolveString(t.style.normalMapTextureImage,j),z=this.modules.styleManager.getStyle(a);if(z){const J=z.rasterSets.byKey[n.getStaticTextureRasterSetKey(ee)];J&&J.isReady&&(F=!0)}F&&(p?(n.start(`${r}_animationSpeedUp`,{easing:Ll(v),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,0,1,p,1),S=1):(m!==1/0&&n.start(`${r}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),S=2));break}case 1:{n.update(`${r}_animationSpeedUp`,{keepFinished:!0,step:(F,j,ee,z)=>{z?(i=1,n.stop(`${r}_animationSpeedUp`,this.mapState),m!==1/0&&n.start(`${r}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),S=2):i=j}},this.mapState);break}case 2:{m===1/0||n.update(`${r}_animationFullSpeed`,{keepFinished:!0,step:(F,j,ee,z)=>{z&&(n.stop(`${r}_animationFullSpeed`,this.mapState),x?(n.start(`${r}_animationSlowDown`,{easing:Ll(g),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,0,x,1),S=3):S=4)}},this.mapState);break}case 3:{n.update(`${r}_animationSlowDown`,{keepFinished:!0,step:(F,j,ee,z)=>{z?(i=0,n.stop(`${r}_animationSlowDown`,this.mapState),S=4):i=j}},this.mapState);break}case 4:{i=0;break}}const I=[M[0]+c*i*C,M[1]+d*i*C,M[2]+_*i*C,M[3]+u*i*C].map(F=>F%1);return this.doubleSampledTextureAnimationStateMap.set(`${a}_${o}`,{animationStage:S,lastKnownOffsets:I,previousTimestamp:l,updatedOnThisFrame:!0,styleId:a,layerId:o}),S!==4&&this.rerenderEvents.push({type:"layerAnimationTicker",layerId:o,styleId:a,underCache:!0}),[!0,I]}doubleSampledTextureAnimationStateCleanup(){for(const[e,t]of this.doubleSampledTextureAnimationStateMap)if(t.updatedOnThisFrame)t.updatedOnThisFrame=!1,this.doubleSampledTextureAnimationStateMap.set(e,t);else{if(this.modules.renderCacheManager.isLayerInCache(t.styleId,t.layerId))return;this.doubleSampledTextureAnimationStateMap.delete(e),n.stop(`${e}_animationSpeedUp`,this.mapState),n.stop(`${e}_animationFullSpeed`,this.mapState),n.stop(`${e}_animationSlowDown`,this.mapState)}}resolveDoubleSampledTextureAnimationOptions(e){var p,v,x,g,y,b,M,T,P,S,C;const t=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),i=n.resolveTextureAnimationExpression(e.style.normalMapTextureAnimation,t),o=(p=i[1])!=null?p:0,a=(v=i[2])!=null?v:0,r=(x=i[3])!=null?x:0,l=(g=i[4])!=null?g:0,c=(y=i[5])!=null?y:0,d=(b=i[6])!=null?b:0,_=(M=i[7])!=null?M:1/0,u=(T=i[8])!=null?T:0,h=(P=i[9])!=null?P:["linear"],f=(S=i[10])!=null?S:0,m=(C=i[11])!=null?C:["linear"];return[[o,a],[r,l],[c,d],_,u,h,f,m]}clearUnusedAnimationState(){for(const e of this.prevObjects.keys())if(!this.currentObjects.has(e)){const t=this.prevObjects.get(e);t&&this.modules.renderCacheManager.isLayerInCache(t.styleId,t.layerId)?this.currentObjects.set(e,t):n.stop(e,this.mapState)}this.prevObjects=new Map(this.currentObjects),this.currentObjects=new Map}refresh(){this.modules.renderer.addRerenderEvent()}updateAnimationKeyframes(e,t){if(e.layerSettings.depthTest||e.layerSettings.shadow||this.mapState.disableLayerAnimation)return;const{animationStack:i}=e.renderingProperties;if(!i)return;const o=new Map,a=this.applyAnimationState(t,e);for(const r of i){const l=a.animationStateID,c=n.get(l,this.mapState);if(this.isNeedAnimation(r,a)){if(!c&&a.currentCount>0){const d=a.animationDuration||(r.max?r.max[0]:0),_=a.startOffset||0;let u=a.startOffset?r.frameCount/(r.frameCount*d/_):0,h=d*(1e3/a.playSpeed)-_*(1e3/a.playSpeed);a.elapsedTime&&(u=1-a.elapsedTime,h=d*(1e3/a.playSpeed)*a.elapsedTime),n.start(l,{easing:"linear",forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,u,1,h,1)}n.update(l,{keepFinished:!0,step:(d,_,u,h)=>{const f=(r.frameCount-1)*_;o.set(r.actionId,f),h||this.rerender(e,t,a)},complete:d=>{a.currentCount>0&&a.currentCount--,a.currentCount>0&&(n.stop(l,this.mapState),this.rerender(e,t,a))}},this.mapState),this.currentObjects.set(l,a)}}return o}initObjectAnimationState(e,t){var m,p;const i=this.resolveGltfAnimationOptions(e,t),o=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].value:i[0],a=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].currentStepElapsed/1e3:void 0,r=(m=i[2])!=null?m:1/0,l=r,c=i[1]||1,d=i[4]||void 0,_=i[3]||a||void 0,u=typeof o=="number"?o:void 0,h=typeof o=="string"?o:void 0,f=typeof o=="object"&&Array.isArray(o)?o:void 0;return{repeatCount:r,playSpeed:c,animationIndex:u,animationName:h,currentCount:l,animations:f,animationDuration:d,startOffset:_,tickerByStep:!!(_&&d),animationStateID:((p=i[5])==null?void 0:p.toString())||`${t.attributesHash}`,timeToUpdate:i[6],layerId:e.innerId,styleId:t.attributes.styleId}}resolveGltfAnimationOptions(e,t){if(e.type!=="gltfModel")return{type:"animation-options"};const i=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,t.attributes.tileData);let o;i.callBackFn=r=>{o=r};const a=n.resolveAnimationExpression(e.style.playAnimation,i);return a[6]===void 0&&o&&(a[6]=o),a}isNeedAnimation(e,t){return t.animationIndex!==void 0&&e.animationIndex===t.animationIndex||t.animationName!==void 0&&e.animationName===t.animationName||t.animations!==void 0&&t.animations.includes(e.animationIndex)||t.animations!==void 0&&t.animations.includes(e.animationName)}applyAnimationState(e,t){const i=this.initObjectAnimationState(e,t),o=this.prevObjects.get(i.animationStateID);return o&&(o&&((o==null?void 0:o.animationIndex)!==i.animationIndex||(o==null?void 0:o.animationName)!==i.animationName)?(n.update(i.animationStateID,{keepFinished:!0,step:(a,r)=>{o.elapsedTime?(o.elapsedTime>0||o.elapsedTime<1)&&(i.elapsedTime=o.elapsedTime):(o.elapsedTime=r,i.elapsedTime=r)}},this.mapState),n.stop(i.animationStateID,this.mapState)):i.repeatCount===o.repeatCount&&(i.currentCount=o.currentCount)),i}rerender(e,t,i){i.repeatCount!==0&&!i.tickerByStep&&(this.rerenderEvents.push({type:"layerAnimationTicker",layerId:t.innerId,styleId:e.attributes.styleId}),this.modules.identifier.queryFillCache())}}const at=.1,ny={id:"simple-mesh",type:"simpleMesh",innerId:n.SIMPLE_MESH_STYLE_LAYER_ID,filter:!1,minzoom:0,maxzoom:20,precomputes:[],renderIndex:0,style:{}},_s={polygonsQty:1e4,drawCallsQty:150,iterations:7},Pl=[18,34],oy=1e3,Ii="__MAPGL_BENCH_TIME",sy=5,ri=class ri{constructor(e,t){this.state=e,this.modules=t,this.buffer=null,this.sceneObjects=[],this.timeout=1/0,this.scale=n.fromValues(1,1,1),this.startTs=0,this.de=vt(this.state,this.modules),this.framebufferId=this.createFramebuffer(),this.modules.dynamicStyle.addLayer(ny)}static mockResult(e){ri.mocked=e}run(){return K(this,arguments,function*(e=_s.polygonsQty,t=_s.drawCallsQty,i=_s.iterations,o=oy){if(ri.mocked)return ri.mocked;const a=this.getCachedResult();if(a)return a;this.timeout=o,this.startTs=performance.now();try{return yield this._run(e,t,t*i,i)}catch(r){return{status:"error"}}})}getScale(){return this.scale}destroy(){this.modules.renderer.removeFramebuffer(this.framebufferId),this.buffer=null,this.sceneObjects=[],this.modules.dynamicStyle.removeLayer(n.SIMPLE_MESH_STYLE_LAYER_ID)}getCachedResult(){try{const e="v1.71.0",t=localStorage.getItem(Ii);if(t){const i=t.split(":"),o=i[0];if(e===o){const a=i.slice(1).join(":").split(",").map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r));if(a.length>=sy){const r=a.reduce((c,d)=>c+d,0)/a.length;return{status:"cached",tier:this.selectTier(r)}}}}}catch(e){}return null}selectTier(e){const t=Pl.findIndex(i=>e<=i);return t>-1?Pl.length-t:0}saveResult(e){try{const t="v1.71.0",i=localStorage.getItem(Ii);if(i){const o=i.split(":"),a=o[0];if(t!==a)localStorage.setItem(Ii,`${t}:${e.toPrecision(4)}`);else{const r=o.slice(1).join(":").split(",").map(l=>parseFloat(l)).filter(l=>!Number.isNaN(l));r.push(e),localStorage.setItem(Ii,`${t}:${r.map(l=>l.toPrecision(4)).join(",")}`)}}else localStorage.setItem(Ii,`${t}:${e.toPrecision(4)}`)}catch(t){}}_run(e,t,i,o){return K(this,null,function*(){const a=this.modules.renderer.getFramebuffer(this.framebufferId);if(!a)throw new Error("Failed to create framebuffer for benchmark.");this.modules.renderer.bindRenderTarget(a.renderTarget),this.modules.renderer.setViewport(0,0,this.modules.renderer.getViewportSize()[0],this.modules.renderer.getViewportSize()[1]);const r=this.prepareData(e,i),l=yield this.measureRendering(o,t);if(this.modules.renderer.bindRenderTarget(null),l.length<3)return{status:"timeout"};const c=this.processResults(l),d=Math.min(c.mean,c.median);this.saveResult(d);const _=this.selectTier(d);return{status:l.length<o?"part-done":"done",tier:_,measurements:c,preparation:r}})}prepareData(e,t){const i=performance.now();this.buffer=this.generateSphere(e);const o=performance.now(),a=performance.now();this.sceneObjects=this.createSceneObjects(t);const r=performance.now();return{generationTime:o-i,objectsTime:r-a}}measureRendering(e,t){return K(this,null,function*(){return new Promise(i=>{const o=[];let a=0,r=0;const l=()=>{const c=performance.now();if(c-this.startTs>this.timeout){i(o);return}this.modules.renderer.clear(!0),this.scale[0]+=.5-Math.random(),yo(this.state,this.modules,this.sceneObjects.slice(r,r+t),this.de),this.modules.renderer.waitForGpuCommandsToFinish(),o.push(performance.now()-c),a++,r+=t,a<e?Promise.resolve().then(l):i(o)};setTimeout(()=>{l()},0)})})}processResults(e){const t=e.slice();t.sort((o,a)=>o-a);const i=t.slice(0,t.length-.2*t.length);return{median:i[Math.floor(i.length/2)],mean:i.reduce((o,a)=>o+a,0)/i.length,min:i[0],max:i[i.length-1]}}generateSphere(e){const t=Math.floor(Math.sqrt(e/2)),i=t*2,l=t*i*2*3*3,c=new Float32Array(l);let d=0;const _=Math.PI/t,u=2*Math.PI/i,h=new Float32Array(3),f=new Float32Array(3),m=new Float32Array(3),p=new Float32Array(3);for(let v=0;v<t;v++){const x=v*_,g=(v+1)*_,y=Math.sin(x),b=Math.cos(x),M=Math.sin(g),T=Math.cos(g);for(let P=0;P<i;P++){const S=P*u,C=(P+1)*u,I=Math.sin(S),E=Math.cos(S),F=Math.sin(C),j=Math.cos(C);h[0]=at*y*E,h[1]=at*b,h[2]=at*y*I,f[0]=at*y*j,f[1]=at*b,f[2]=at*y*F,m[0]=at*M*E,m[1]=at*T,m[2]=at*M*I,p[0]=at*M*j,p[1]=at*T,p[2]=at*M*F,c.set(h,d),c.set(m,d+3),c.set(f,d+6),c.set(m,d+9),c.set(p,d+12),c.set(f,d+15),d+=18}}return c.buffer}createFramebuffer(){const e=new be({size:this.modules.renderer.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,type:w.Float,flipY:!0});return this.modules.renderer.addFramebuffer({clearColor:[0,0,0,0],renderTarget:e,onResize:()=>{}})}createSceneObjects(e){const t={programName:"simpleMesh",vaoCreator:da,stateBinder:()=>ro,programBinder:Bu,tileBinder:()=>!0,objectBinder:th,needsVisibilityBuffer:!1},i=[],o=da(this.modules.renderer.createBuffer(this.buffer),this.modules.renderer.getShaderProgram("simpleMesh")),a=new n.TileObject("zenith",[],this.modules,this.state),r={layerId:n.SIMPLE_MESH_STYLE_LAYER_ID,styleId:n.DYNAMIC_STYLE_ID,tileData:[]};for(let l=0;l<e;l++){const d=(l/20&1)===0?1-(1+l%10)/10:(1+l%10)/10,_=n.fromValues(-1+l%20/10,1-Math.floor(l/20)*2/(e/20),0);i.push({id:n.uniqId(),type:n.SceneObjectType.Tile,start:0,count:this.buffer.byteLength/12,attributesHash:`benchmark-${l}`,vao:o,drawMode:n.GL_TRIANGLES,tile:a,symbol:"simpleMesh",sink:"fill",layerSettings:t,canRender:!0,attributes:r,meta:{scale:d,transform:_},renderingProperties:{}})}return i}};ri.mocked=null;let Nn=ri;class ay{constructor(e,t,i){this.benchmark=null,this.map=i,this.camera=new n.Camera(e),this.layout=new Mg(t),this.collector=new n.Collector("main"),this.workers=new Mv,this.identifier=new Lv(e,this),this.styleManager=new Dv(this),this.assetManager=new Nv(e,this),this.imageManager=new Eg(this),this.floorManager=new lg(e,this),this.personalPoiManager=new Zv(this),this.buildingHeightAnimator=new rd(e,this),this.modelsScene=new Kg(e,this),this.renderer=new Mi(e,this),this.newRenderer=new Cv(e,this),this.layers=new ng(this),this.sourceStorage=new Lg,this.tileManager=new fg(e,this),this.modelLayer=new Vv(e,this),this.dynamicStyle=new n.DynamicStyle,this.imageCache=new sg(this),this.labeler=new xg(e,this),this.trafficTileLayer=new Sg(e,this),this.handler=new bg(e,this),this.mouseMoveHandler=new od(this),this.tileKeyInfo=new Cg(e),this.demManager=new K_(this),this.environmentManager=new Rg(this),this.defaultSource=new el(e,this),this.labelsDebug=new Bg(e,this),this.postEffectsManager=new Iu(e,this),this.renderCacheManager=new mv(e,this),this.animationManager=new iy(e,this),this.shadowManager=new Tu(e,this),this.instanceLinker=new ff(this),e.graphicsPresetMode==="auto"&&(this.benchmark=new Nn(e,this))}destroy(){this.demManager.disable(),this.imageManager.destroy(),this.trafficTileLayer.destroy(),this.tileManager.destroy(),this.workers.destroy(),this.identifier.destroy(),this.renderer.destroy(),this.newRenderer.destroy(),this.handler.destroy(),this.mouseMoveHandler.destroy(),this.labelsDebug.hide(),this.renderCacheManager.destroy(),this.tileKeyInfo.destroy(),this.layout.destroy()}}const us=["light","normal","immersive"],ry=["immersiveRoadsOff","shadowsOff","fogOff","skyOff","modelsOff","globeOff","transparentBuildingsOff","AALinesOff"],ly=.3,li=class li{constructor(e,t={},i){var u,h,f,m,p,v,x,g,y,b,M,T,P,S,C,I,E,F;this.requestedFrame=requestAnimationFrame(()=>{}),this.isStyleUpdateInProgress=!1,this.isFirstStyleUpdate=!0,this.lastResizeTime=-1/0,this.replicasDiffer=new n.Differ([{path:"visibleMapReplicas",type:"replicas"}]),this.graphicsPresetDiffer=new n.Differ([{path:"graphicsPreset",type:"string"}]),this.lastDpr=window.devicePixelRatio,this.renderLoop=j=>{if(this.modules.renderer.isDestroyed)return;this.requestedFrame=requestAnimationFrame(this.renderLoop),this.updateImmersiveLevel();const ee=window.devicePixelRatio;ee!==this.lastDpr?(this.lastDpr=ee,this.state.dpiChanged=!0,this.modules.map.invalidateSize(),this.modules.imageCache.clear()):this.state.dpiChanged=!1,this.modules.map.emit("framestart");const z=this.state;z.time=Date.now(),this.processMetrics(),this.state.enableTrackResize&&this.autoResize(j),this.modules.mouseMoveHandler.update(),this.handlers.forEach(q=>q.update()),Vc(z),Nc(z),Uc(z),Hc(z),this.stillnessUpdater.update(z),Dc(z,this.modules.layout.rootContainer),Ec(z,this.modules.layout.rootContainer,this.modules.renderer),zc(z,this.modules.renderer);const J=this.modules.demManager.getReliefTileType()==="vector"&&z.styleZoom<wa;if(z.demMode=this.checkDemEnabled()&&z.elevationScale>0&&!J,this.checkGlobeEnabled(),this.modules.camera.update(),this.updateElevation(),this.updateTilesBounds(),this.replicasDiffer.check(z)&&(z.needReplicasUpdate=!0),this.modules.demManager.update(),this.modules.environmentManager.update(),this.modules.labelsDebug.update(),this.modules.trafficTileLayer.update(),this.modules.layers.getLayers().forEach(q=>{q.update!==void 0&&q.update()}),this.modules.tileManager.update(),this.modules.instanceLinker.update(),this.modules.sourceStorage.updateViewportSources(),this.modules.floorManager.update(),this.modules.modelLayer.update(),this.modules.personalPoiManager.update(),this.modules.dynamicStyle.update(),this.modules.styleManager.update(),this.modules.buildingHeightAnimator.update(),this.modules.modelsScene.update(),this.modules.shadowManager.update(),this.modules.animationManager.update(),this.modules.map.emit("update"),this.modules.labeler.update(),this.performanceChecker.update(),this.modules.identifier.update(),this.modules.postEffectsManager.update(),z.loopWorld&&!this.modules.renderer.isNeedRerender()&&n.worldWrapX(z.center),(n.render.alwaysRerender||this.modules.renderer.isNeedRerender())&&z.collectStats&&(z.stats.drawCount=0,z.stats.vertexCount=0,z.stats.triangleCount=0,z.stats.drawCountBySymbol={}),n.render.alwaysRerender||this.modules.renderer.isNeedRerender()){const q=this.modules.tileManager.getTileObjects();this.modules.renderer.prerenderUpdate(),z.metrics.firstdraw===void 0&&(z.metrics.firstdraw=performance.now()-z.metrics.start),q.forEach(Te=>{Te.needSync&&Te.syncReplicas(this.state)}),this.modules.renderCacheManager.frameStart(),this.modules.animationManager.frameStart(),this.modules.renderer.renderElevation(q),this.modules.shadowManager.drawShadowMap(q),this.modules.renderer.renderLabelingTexture(q),this.modules.renderer.renderSpriteLabelingTexture(q),this.modules.renderer.renderTileObjects(q),this.modules.shadowManager.drawDebugFbIfNeeded(),z.needRerender=!1,this.state.rerenderEvents=new Array,this.modules.animationManager.frameEnd(),this.modules.renderCacheManager.frameEnd(),z.collectStats&&(this.modules.map.emit("stats",z.stats),z.metricsSent||(z.metrics.vertexCount=z.stats.vertexCount,z.metrics.triangleCount=z.stats.triangleCount,z.metrics.drawCount=z.stats.drawCount))}this.finishStyleUpdatingCheck(),this.modules.map.update(),this.modules.assetManager.invalidateUsedGltfModels(),z.needReplicasUpdate=!1,z.shouldIsReadyWaitForUpdates=!1,z.shouldIsIdleWaitForUpdates=!1,this.modules.map.emit("frameend"),this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId)&&this.state.graphicsPresetMode&&this.graphicsPresetDiffer.check(this.state.styleState)&&this.modules.map.emit("graphicspresetchange")};const o=B(B({},li.options),t),a=B(B({},li.options.padding),o.padding),r=B(B({},li.options.viewport),o.viewport),l=o.maxBounds?n.fromGeo(o.maxBounds):o.loopWorld?n.worldLoopBounds:n.worldBounds,c=n.Mercator.fromGeo(o.center);n.worldWrapX(c),n.clampPoint(c,l,c);const d=o.graphicsPreset&&o.graphicsPreset!=="auto"?de(B({},o.styleState),{graphicsPreset:o.graphicsPreset}):o.styleState,_=this.state={time:Date.now(),center:c,zoom:o.styleZoom!==void 0?n.getZoomFromStyleZoom(o.styleZoom,c):o.zoom,rotation:n.degToRad(o.rotation),pitch:n.degToRad(o.pitch),styleZoom:o.styleZoom!==void 0?o.styleZoom:n.getStyleZoom(o.zoom,c),zoomTypePreserving:o.styleZoom!==void 0?"styleZoom":"zoom",minZoom:o.minZoom,maxZoom:o.maxZoom,maxBounds:l,loopWorld:(u=o.loopWorld)!=null?u:!1,touchRotationThreshold:n.degToRad(o.touchRotationThreshold),minPitch:n.degToRad(o.minPitch),maxPitch:n.degToRad(o.maxPitch),lowZoomMaxPitch:o.lowZoomMaxPitch?n.degToRad(o.lowZoomMaxPitch):null,size:[Math.max(1,e.clientWidth-r.left-r.right),Math.max(1,e.clientHeight-r.top-r.bottom)],tickers:{},stillness:1,needRerender:!0,needLabeling:!1,needReplicasUpdate:!1,userHasInteracted:!1,dpiChanged:!1,viewport:r,padding:a,labelingOpacity:0,tileServer:o.tileServer,styleServer:o.styleServer||n.styles.url,fontUrl:o.fontUrl||n.fonts.defaultUrl,modelUrl:o.modelUrl||n.defaultModelsPath,iconUrl:o.iconUrl||n.icons.defaultUrl,keyUrl:o.keyUrl||n.keyServerPath,tileSet:o.tileSet,tileProtocol:o.tileProtocol,commercialTileSet:o.commercialTileSet,modelsTileSet:(h=o.modelsTileSet)!=null?h:n.models.tileSet,modelsTilesUrl:(f=o.modelsTilesUrl)!=null?f:n.urls.models,defaultSourceModelsRootUrl:o.defaultSourceModelsRootUrl,defaultSourceModelsAppearStrategy:o.defaultSourceModelsAppearStrategy,subdomains:o.subdomains.split(""),floorsEnabled:o.floorsEnabled,collectStats:o.collectStats,stats:{tileCount:0,dynamicTileCount:0,globeTileCount:0,drawCount:0,vertexCount:0,triangleCount:0,drawCountBySymbol:{},foundVisibleTilesCount:0},trafficOn:!!o.trafficOn,trafficServer:o.trafficServer,trafficProtocol:o.trafficProtocol,identifyPickDistance:n.identify.pickDistance,lang:o.lang,tileServerDefaultLang:o.tileServerDefaultLang,tileKey:o.key,appId:o.appId,disableHoverStyles:o.disableHoverStyles,keepCenterWhileUserZoomRotate:!!o.keepCenterWhileUserZoomRotate,disableRotationByUserInteraction:!!o.disableRotationByUserInteraction,disablePitchByUserInteraction:!!o.disablePitchByUserInteraction,disableDragging:!!o.disableDragging,enableTwoFingerDragging:!!o.enableTwoFingerDragging,performanceCaveatEmitted:!1,sessionId:o.sessionId,tileSessionId:o.tileSessionId,shownRegionIds:new Set,preserveDrawingBuffer:!!o.preserveDrawingBuffer,defaultBackgroundColor:n.handyColor(o.defaultBackgroundColor),handyStyleId:NaN,styleId:"",styleState:Ln(d),disableIconCache:o.disableIconCache,disableRenderingCache:o.disableRenderingCache,rtlPlugin:{scenario:(m=o.useRtlTextPlugin)!=null?m:"depends-on-language",loadFailed:!1,url:(p=o.rtlPluginUrl)!=null?p:n.rtlPluginUrl,hash:(v=o.rtlPluginHash)!=null?v:n.rtlPluginHash},mobileSdkMode:o.mobileSdkMode,dracoDecoderUrl:(x=o==null?void 0:o.dracoDecoderUrl)!=null?x:n.dracoDecoderUrl,demMode:!1,globeMode:!1,globeReady:!1,visibleMapReplicas:[0],tilesBounds:[[0,0],[0,0],[0,0],[0,0]],extendedTilesBounds:[[0,0],[0,0],[0,0],[0,0]],elevation:void 0,elevationScale:0,minElevation:void 0,skipElevationAnimation:o.skipElevationAnimation,metrics:{start:performance.now(),fail:!1,vertexCount:0,triangleCount:0,drawCount:0},metricsSent:!1,shouldIsReadyWaitForUpdates:!1,shouldIsIdleWaitForUpdates:!1,commercialPoiRandomSeed:o.commercialPoiRandomSeed,disableSurvivedPoiPrevalence:!!o.disableSurvivedPoiPrevalence,webglVersion:o.webglVersion,webgpu:o.webgpu,enableTrackResize:!!o.enableTrackResize,autoResizeInterval:n.render.autoResizeInterval,showDefaultTileBounds:!!o.showDefaultTileBounds,immersiveLevel:{tiers:!1},pitchHightLimitation:o.pitchHightLimitation===void 0?n.degToRad(90):n.degToRad(o.pitchHightLimitation),isLabelingDepthTestDisabled:!1,iconIdentifyOpacity:(g=o.iconIdentifyOpacity)!=null?g:ly,disableHidingPois:(y=o.disableHidingPois)!=null?y:!1,resetFloorModeOnActivation:(b=o.resetFloorModeOnActivation)!=null?b:!1,aaMode:o.disableAntiAliasing===!1?Yt.TAA:void 0,rerenderEvents:new Array,cameraConfig:Object.assign({},n.defaultCameraConfig),cityCommPoiLabeling:{config:o.cityCommPoiLabelingConfig,ascSortedZoomNumbers:vg(o.cityCommPoiLabelingConfig)},trafficMinZoom:(M=o.trafficMinZoom)!=null?M:n.traffic.minZoom,trafficMaxZoom:(T=o.trafficMaxZoom)!=null?T:n.traffic.maxZoom,trafficMaxDetailLevel:(P=o.trafficMaxDetailLevel)!=null?P:n.traffic.maxDetailLevel,bssHostAppParams:o.bssHostAppParams,disableStyleFallback:!!o.disableStyleFallback,hiddenImmersiveRoutesEnabled:Td(),modelShowHideEventsSublayers:new Set((S=o.modelShowHideEventsSublayers)!=null?S:[]),graphicsPresetMode:o.graphicsPreset,shouldEmitGraphicsPresetChangeEvent:!1,isDeprecatedSystem:Wt(),disableModelsGrowthAnimation:(C=o.disableModelsGrowthAnimation)!=null?C:!1,disableLayerAnimation:(I=o.disableLayerAnimation)!=null?I:!1,allowMetro:(E=o.allowMetro)!=null?E:!1,forceSyncIdentify:(F=o.forceSyncIdentify)!=null?F:!1};o.cameraConfig&&Object.assign(_.cameraConfig,o.cameraConfig),this.modules=new ay(_,e,i),typeof _.commercialPoiRandomSeed=="number"&&this.modules.workers.labeling.setCommercialPoiRandomSeed(_.commercialPoiRandomSeed),this.modules.styleManager.setDynamicStyle(this.modules.dynamicStyle.getStyle()),this.handlers=[new Jc(_,this.modules.layout.mapContainer),new Ac(this.modules)],o.disableZoomOnScroll||this.handlers.push(new Qc(_,this.modules.layout.mapContainer)),Kc&&Hi&&this.handlers.push(new ed(_,e,i)),this.performanceChecker=new td(_,this.modules),this.stillnessUpdater=new nd,this.measurePerformance(o.graphicsPreset==="auto").then(()=>{this.requestedFrame=requestAnimationFrame(this.renderLoop)})}destroy(){cancelAnimationFrame(this.requestedFrame),this.modules.destroy(),this.handlers.forEach(e=>e.destroy())}isIdle(){return!this.modules.renderer.isNeedRerender()&&!this.state.shouldIsIdleWaitForUpdates&&this.modules.tileManager.isIdle()&&this.modules.assetManager.isIdle()&&this.modules.trafficTileLayer.viewportTilesReady()&&this.modules.layers.entranceAnimationFinished()&&this.modules.modelLayer.isIdle()&&!this.modules.buildingHeightAnimator.isAnimating()&&!this.modules.modelsScene.isAnimating()&&this.modules.labeler.isIdle()}isReady(){return this.isIdle()&&this.modules.floorManager.floorsReady()&&this.modules.identifier.isIdle()&&this.modules.imageManager.isIdle()&&this.modules.imageCache.isIdle()&&this.modules.personalPoiManager.isIdle()&&this.modules.tileKeyInfo.isIdle()&&this.modules.postEffectsManager.isReady()&&!this.state.shouldIsReadyWaitForUpdates}isReadyForMetrics(){return!this.modules.renderer.isNeedRerender(!0)&&!this.state.shouldIsIdleWaitForUpdates&&this.modules.tileManager.isIdle()&&this.modules.assetManager.isIdle()&&this.modules.trafficTileLayer.viewportTilesReady()&&this.modules.modelLayer.isIdle()&&!this.modules.buildingHeightAnimator.isAnimating()&&!this.modules.modelsScene.isAnimating()&&this.modules.labeler.isIdle()&&this.modules.floorManager.floorsReady()&&this.modules.identifier.isIdle()&&this.modules.imageManager.isIdle()&&this.modules.imageCache.isIdle()&&this.modules.personalPoiManager.isIdle()&&this.modules.tileKeyInfo.isIdle()&&this.modules.postEffectsManager.isReady(!0)&&!this.state.shouldIsReadyWaitForUpdates}hasActiveLayerAnimation(){return this.state.rerenderEvents.some(e=>e.type==="layerAnimationTicker")||!this.modules.layers.entranceAnimationFinished()}redrawMap(){this.modules.tileManager.redraw(),this.modules.trafficTileLayer.redraw(),this.modules.modelLayer.redraw(),this.modules.personalPoiManager.redraw()}activateStyleUpdating(){this.modules.tileManager.activateStyleUpdating(),this.modules.modelLayer.activateStyleUpdating(),this.modules.trafficTileLayer.activateStyleUpdating(),this.isStyleUpdateInProgress=!0}getIsFirstStyleUpdate(){return this.isFirstStyleUpdate}measurePerformance(e){return K(this,null,function*(){if(!e)return;performance.now();const t=yield this.modules.benchmark.run();switch(this.modules.benchmark.destroy(),this.modules.benchmark=null,t.status){case"error":case"timeout":const i=us[0];this.state.metrics.graphicsPreset=i,this.modules.map.patchStyleState({graphicsPreset:i});break;case"part-done":case"done":case"cached":{const o=us[t.tier];this.state.metrics.graphicsPreset=t.status==="part-done"?us[0]:o,t.status!=="cached"&&(this.state.metrics.benchRenderTime=Math.round(t.measurements.mean),this.state.metrics.benchGenTime=Math.round(t.preparation.generationTime)),this.modules.map.patchStyleState({graphicsPreset:o});break}}})}processMetrics(){const e=this.state;if(e.metricsSent||e.graphicsPresetMode==="auto"&&!e.metrics.graphicsPreset)return;const t=e.metrics,i=performance.now()-t.start>n.metricsTimeout;(t.interactive!==void 0&&t.init!==void 0&&t.firstlabeling!==void 0&&t.ready!==void 0&&t.firstcontent!==void 0&&t.firstdraw!==void 0||i)&&(t.fail=i,this.modules.map.emit("metrics",t),e.metricsSent=!0)}finishStyleUpdatingCheck(){this.isStyleUpdateInProgress&&this.modules.tileManager.viewportTilesReady()&&this.modules.trafficTileLayer.viewportTilesReady()&&this.modules.modelLayer.viewportModelsReady()&&(this.modules.tileManager.finishStyleUpdating(),this.modules.trafficTileLayer.finishStyleUpdating(),this.modules.modelLayer.finishStyleUpdating(),this.modules.modelsScene.finishStyleUpdating(),this.modules.personalPoiManager.redraw(),this.updateBackgroundColor(),this.isStyleUpdateInProgress=!1,this.isFirstStyleUpdate=!1,this.modules.renderer.addRerenderEvent(),this.state.needLabeling=!0)}updateBackgroundColor(){const{renderer:e,postEffectsManager:t,styleManager:i}=this.modules,o=i.getClearColor();o!==void 0&&(e.setClearColor(o),t.setClearColor(o))}checkDemEnabled(){return this.state.styleState.terrainEnabled===!0&&!this.state.globeMode?this.modules.demManager.isEnabled()||this.modules.demManager.enable():this.modules.demManager.isEnabled()&&this.modules.demManager.disable(),this.modules.demManager.isEnabled()}checkGlobeEnabled(){const{styleState:t,styleZoom:i,globeMode:o,handyStyleId:a}=this.state,{defaultSource:r,map:l}=this.modules,c=o;if(!this.modules.styleManager.getStyleLayer(a,n.ENVIRONMENT_STYLE_LAYER_ID)){const f=this.state.globeMode;this.state.globeMode=!1,f&&!this.state.loopWorld&&n.clampPoint(this.state.center,this.state.maxBounds,this.state.center);return}const{globeMaxZoom:_}=n.globeConfig,u=!c&&i<_||c&&i<_+.2,h=t.globeEnabled===!0&&u&&!l.getFeatureFlag("globeOff");!c&&h&&(this.modules.defaultSource.addGlobeSource(),this.state.globeReady=!1),c&&!h&&(this.modules.defaultSource.removeGlobeSource(),this.state.globeReady=!1),h&&r.isGlobeTilesReady()&&(this.state.globeReady=!0),this.state.globeMode=h,c&&!h&&!this.state.loopWorld&&n.clampPoint(this.state.center,this.state.maxBounds,this.state.center),(h||c&&!h)&&this.updateBackgroundColor()}updateImmersiveLevel(){const e=!!this.state.styleState.immersiveRoadsOn;this.state.immersiveLevel.tiers=e&&this.state.styleZoom>=n.DEFAULT_MIN_TIERS_STYLE_ZOOM}updateTilesBounds(){const{size:e,zoom:t}=this.state,[i,o,a,r]=this.modules.camera.getViewportVertices(),l=n.getLineConstants(i,o),c=n.pointToLineSignedDistance(this.modules.camera.position,l),d=c<0,_=this.state.cameraConfig;let u=this.modules.environmentManager.fogLimits[1]*this.modules.camera.fogDistance;if(d&&(u+=c),this.state.demMode&&this.state.elevation!==void 0&&!Number.isNaN(this.state.elevation)){const p=this.modules.camera.position[2],v=this.state.minElevation!==void 0&&!Number.isNaN(this.state.minElevation)?this.state.minElevation:this.state.elevation,x=Math.max(this.state.elevation-v,0)*n.MAP_POINTS_IN_METER,g=Math.min(x/p+1,2),y=(g-1)*Math.max(1-this.state.pitch/this.state.maxPitch,.1)+1;n.lerp(i,this.modules.camera.position,i,y),n.lerp(o,this.modules.camera.position,o,y),n.lerp(r,this.modules.camera.position,r,g),n.lerp(a,this.modules.camera.position,a,g)}let h=n.pointToLineDistance(a,l);if(h>u){const p=u/h;n.lerp(a,o,a,p),n.lerp(r,i,r,p),h=u}n.copy$2(this.state.extendedTilesBounds[0],i),n.copy$2(this.state.extendedTilesBounds[1],o),n.copy$2(this.state.extendedTilesBounds[2],a),n.copy$2(this.state.extendedTilesBounds[3],r);const f=Math.min(_.minTrapezeHeight,u),m=Math.max(n.pixelToMapDistance(e[1],t)*_.viewportLimitRatio,f);if(h>m){const p=m/h;n.lerp(a,o,a,p),n.lerp(r,i,r,p),h=m}if(this.state.demMode&&d){const p=(h+Math.abs(c))/h;n.lerp(i,r,i,p),n.lerp(o,a,o,p)}n.copy$2(this.state.tilesBounds[0],i),n.copy$2(this.state.tilesBounds[1],o),n.copy$2(this.state.tilesBounds[2],a),n.copy$2(this.state.tilesBounds[3],r),this.state.visibleMapReplicas=this.state.loopWorld||this.state.globeMode?n.getVisibleMapReplicas(this.state.tilesBounds,this.state.globeMode):[0]}updateElevation(){if(this.state.elevationScale=this.modules.demManager.getVerticalScale(),!this.state.demMode){this.state.elevation!==void 0&&(this.modules.renderer.addRerenderEvent(),this.state.elevation=void 0);return}const e=this.modules.demManager.getElevation(this.state.center);if(e!==void 0)if(this.state.elevation===void 0||this.state.skipElevationAnimation)this.state.elevation=e;else{const i=Z_*(e-this.state.elevation);Math.abs(i)<j_?this.state.elevation=e:this.state.elevation+=i;const o=this.modules.demManager.getElevation(this.modules.camera.position);if(o!==void 0){const a=this.state.elevationScale,r=o*a,l=this.modules.camera.position[2]/n.MAP_POINTS_IN_METER,c=Math.min(30,l*.2),d=this.state.elevation*a+l-c;r>d&&(this.state.elevation+=(r-d)/a)}}const t=this.modules.demManager.getMinElevation();t!==void 0&&(this.state.minElevation=t)}autoResize(e){if(e-this.lastResizeTime>=this.state.autoResizeInterval){const t=this.modules.layout.canvas,{clientWidth:i,clientHeight:o}=this.modules.layout.rootContainer,a=window.devicePixelRatio;(t.width!==Math.floor(i*a)||t.height!==Math.floor(o*a))&&(this.lastResizeTime=e,this.modules.map.invalidateSize())}}};li.options={center:[0,0],zoom:0,minZoom:n.MAP_DEFAULTS.minZoom,maxZoom:n.MAP_DEFAULTS.maxZoom,rotation:0,touchRotationThreshold:10,pitch:0,minPitch:0,maxPitch:45,lowZoomMaxPitch:45,viewport:{top:0,right:0,bottom:0,left:0},padding:{top:0,right:0,bottom:0,left:0},tileServer:n.tiles.server,tileSet:n.tiles.tileSet,tileProtocol:n.tiles.protocol,commercialTileSet:n.commercialPoi.tileSet,key:n.tiles.tileKey,subdomains:n.tiles.subdomains,floorsEnabled:n.floors.enabled,trafficProtocol:n.traffic.protocol,trafficServer:n.traffic.host,collectStats:!1,style:"",styleState:ag(),styleOptions:{rootUrl:"",iconsPath:"",fontsPath:"",stylePath:"",modelsPath:""},lang:n.defaultLang,appId:n.tiles.appId,disableHoverStyles:!1,disableZoomOnScroll:!1,disableDragging:!1,enableTwoFingerDragging:!1,disableRotationByUserInteraction:!1,disablePitchByUserInteraction:!1,defaultBackgroundColor:"#f6f2de",disableIconCache:!1,disableRenderingCache:!1,mobileSdkMode:!1,skipElevationAnimation:!1,enableTrackResize:!1,showDefaultTileBounds:!1,immersiveOn:!1,pitchHightLimitation:90,trafficOn:!1,trafficMinZoom:n.traffic.minZoom,trafficMaxZoom:n.traffic.maxZoom,trafficMaxDetailLevel:n.traffic.maxDetailLevel,disableStyleFallback:!1,modelShowHideEventsSublayers:[],styleServer:"",fontUrl:"",modelUrl:"",iconUrl:"",keyUrl:"",disableLayerAnimation:!1};let hs=li;const cy="https://mapgl.2gis.com/api/js",kn={minZoom:2,maxZoom:20},dy="tile{subdomain}-sdk.maps.2gis.com",Bl="https://tile{subdomain}-sdk.maps.2gis.com/api/v3/ald",_y="https://s1.bss.2gis.com/bss/3",fs=()=>{let s="",e;for(let t=0;t<32;t++)e=Math.random()*16|0,t>4&&t<21&&!(t%4)&&(s+="-"),s+=(t===12?4:t===16?e&3|8:e).toString(16);return s},uy=2;function hy(s){const e=[uy,s instanceof WebGLRenderingContext?1:2,s.getParameter(s.ALIASED_LINE_WIDTH_RANGE),s.getParameter(s.ALIASED_POINT_SIZE_RANGE),s.getParameter(s.COMPRESSED_TEXTURE_FORMATS),s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),s.getParameter(s.MAX_RENDERBUFFER_SIZE),s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_TEXTURE_SIZE),s.getParameter(s.MAX_VARYING_VECTORS),s.getParameter(s.MAX_VERTEX_ATTRIBS),s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),s.getParameter(s.MAX_VIEWPORT_DIMS),s.getParameter(s.PACK_ALIGNMENT),s.getParameter(s.SUBPIXEL_BITS),s.getParameter(s.UNPACK_ALIGNMENT),s.getParameter(s.VIEWPORT),s.getParameter(s.SHADING_LANGUAGE_VERSION),s.getParameter(s.VENDOR),s.getParameter(s.RENDERER)];s instanceof WebGLRenderingContext?e.push(...new Array(28).fill(-1)):e.push(s.getParameter(s.MAX_3D_TEXTURE_SIZE),s.getParameter(s.MAX_ARRAY_TEXTURE_LAYERS),s.getParameter(s.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),s.getParameter(s.MAX_COLOR_ATTACHMENTS),s.getParameter(s.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),s.getParameter(s.MAX_COMBINED_UNIFORM_BLOCKS),s.getParameter(s.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),s.getParameter(s.MAX_DRAW_BUFFERS),s.getParameter(s.MAX_ELEMENT_INDEX),s.getParameter(s.MAX_ELEMENTS_INDICES),s.getParameter(s.MAX_ELEMENTS_VERTICES),s.getParameter(s.MAX_FRAGMENT_INPUT_COMPONENTS),s.getParameter(s.MAX_FRAGMENT_UNIFORM_BLOCKS),s.getParameter(s.MAX_FRAGMENT_UNIFORM_COMPONENTS),s.getParameter(s.MAX_PROGRAM_TEXEL_OFFSET),s.getParameter(s.MAX_SAMPLES),s.getParameter(s.MAX_SERVER_WAIT_TIMEOUT),s.getParameter(s.MAX_TEXTURE_LOD_BIAS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),s.getParameter(s.MAX_UNIFORM_BLOCK_SIZE),s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS),s.getParameter(s.MAX_VARYING_COMPONENTS),s.getParameter(s.MAX_VERTEX_OUTPUT_COMPONENTS),s.getParameter(s.MAX_VERTEX_UNIFORM_BLOCKS),s.getParameter(s.MAX_VERTEX_UNIFORM_COMPONENTS),s.getParameter(s.MIN_PROGRAM_TEXEL_OFFSET));const t=s.getExtension("WEBGL_debug_renderer_info");t?e.push(s.getParameter(t.UNMASKED_VENDOR_WEBGL),s.getParameter(t.UNMASKED_RENDERER_WEBGL)):e.push("Unsupported","Unsupported");const i=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.LOW_FLOAT),o=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT),a=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);return a&&o&&i?(e.push(`[${i.rangeMin},${i.rangeMax}](${i.precision})`),e.push(`[${o.rangeMin},${o.rangeMax}](${o.precision})`),e.push(`[${a.rangeMin},${a.rangeMax}](${a.precision})`)):e.push(new Array(3).fill("Unsupported")),e.push(window.devicePixelRatio),e}function fy(s){const e={};for(const[t,i]of Object.entries(s)){if(n.isTypedArray(i)){e[t]=Array.from(i);continue}e[t]=i}return e}function my(s){var a,r;const e={1:["stateSetVersion","webGlVersion","ALIASED_LINE_WIDTH_RANGE","ALIASED_POINT_SIZE_RANGE","COMPRESSED_TEXTURE_FORMATS","MAX_COMBINED_TEXTURE_IMAGE_UNITS","MAX_CUBE_MAP_TEXTURE_SIZE","MAX_FRAGMENT_UNIFORM_VECTORS","MAX_RENDERBUFFER_SIZE","MAX_TEXTURE_IMAGE_UNITS","MAX_TEXTURE_SIZE","MAX_VARYING_VECTORS","MAX_VERTEX_ATTRIBS","MAX_VERTEX_TEXTURE_IMAGE_UNITS","MAX_VERTEX_UNIFORM_VECTORS","MAX_VIEWPORT_DIMS","PACK_ALIGNMENT","SUBPIXEL_BITS","UNPACK_ALIGNMENT","VIEWPORT","SHADING_LANGUAGE_VERSION","VENDOR","RENDERER","MAX_3D_TEXTURE_SIZE","MAX_ARRAY_TEXTURE_LAYERS","MAX_CLIENT_WAIT_TIMEOUT_WEBGL","MAX_COLOR_ATTACHMENTS","MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS","MAX_COMBINED_UNIFORM_BLOCKS","MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS","MAX_DRAW_BUFFERS","MAX_ELEMENT_INDEX","MAX_ELEMENTS_INDICES","MAX_ELEMENTS_VERTICES","MAX_FRAGMENT_INPUT_COMPONENTS","MAX_FRAGMENT_UNIFORM_BLOCKS","MAX_FRAGMENT_UNIFORM_COMPONENTS","MAX_PROGRAM_TEXEL_OFFSET","MAX_SAMPLES","MAX_SERVER_WAIT_TIMEOUT","MAX_TEXTURE_LOD_BIAS","MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS","MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS","MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS","MAX_UNIFORM_BLOCK_SIZE","MAX_UNIFORM_BUFFER_BINDINGS","MAX_VARYING_COMPONENTS","MAX_VERTEX_OUTPUT_COMPONENTS","MAX_VERTEX_UNIFORM_BLOCKS","MAX_VERTEX_UNIFORM_COMPONENTS","MIN_PROGRAM_TEXEL_OFFSET"]};e[2]=[...e[1],"UNMASKED_VENDOR_WEBGL","UNMASKED_RENDERER_WEBGL","precisionLow","precisionMedium","precisionHigh","devicePixelRatio"];const t=s[0],i=(a=e[t])!=null?a:{},o={};for(let l=0;l<s.length;l++)o[(r=i[l])!=null?r:l]=s[l];return o}const py=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|redmi|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,vy=/CrOS/,gy=/android|ipad|playbook|silk/i,yy=()=>{const s=typeof navigator!="undefined"?navigator.userAgent:"";if(!s)return!1;const e=py.test(s)&&!vy.test(s),t=gy.test(s),i=navigator.maxTouchPoints>1&&s.includes("Macintosh")&&s.includes("Safari");return e||t||i},Un=5e3,xy=64,by=16;class wy{constructor(e,t){var i;this.queue=[],this.commPoiMsgOrderNumber=0,this.utcOffset=Ty(),this.unsentMessages=[],this.isMetricsFailed=!1,this.webglStatsValues=[],this.onCommPoiShowEvent=({commPois:o})=>{const a=Date.now(),{tileKey:r,sessionId:l}=this.map.state;for(const c of o){const d=Sy(c,a,this.commPoiMsgOrderNumber++,r,this.utcOffset,l);d&&this.queue.push(d)}this.timer||(this.timer=window.setTimeout(this.sendMessages,Un))},this.onContextLostEvent=()=>K(this,null,function*(){const o=Date.now(),a={cpu:0,gpu:0},r={start:0,fail:!0,contextLost:!0},l=yield this.createMetricMessage(o,r,a);this.queue.push(l),this.timer||(this.timer=window.setTimeout(this.sendMessages,Un))}),this.onMetricsEvent=o=>K(this,null,function*(){this.isMetricsFailed&&(o.fail=!0);const a=Date.now(),r=yield this.getMetricsMessage(o,a);this.queue.push(r),this.timer||(this.timer=window.setTimeout(this.sendMessages,Un))}),this.onSendFail=o=>{this.unsentMessages.push(...o),this.timer||(this.timer=window.setTimeout(this.sendMessages,Un))},this.sendMessages=()=>{this.timer=void 0;const o=[...this.unsentMessages,...this.queue];this.queue=[],this.unsentMessages=[],o.length&&fetch(this.bssUrl,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}}).then(a=>{a.ok||this.onSendFail(o)},()=>this.onSendFail(o))},this.markMetricsAsFailed=()=>{this.isMetricsFailed=!0},this.map=e,this.bssUrl=(i=t.bssUrl)!=null?i:_y,this.webglStatsValues=hy(this.map.getWebGLContext()),t.disableBssStatisticsForCommPoi||e.on("commpoishow",this.onCommPoiShowEvent),e.on("metrics",this.onMetricsEvent),this.map.on("error",o=>{o.type==="webglcontextlost"&&this.onContextLostEvent()}),window.addEventListener("blur",this.markMetricsAsFailed,{once:!0}),window.addEventListener("focus",this.markMetricsAsFailed,{once:!0}),document.addEventListener("visibilitychange",this.markMetricsAsFailed,{once:!0}),(!document.hasFocus()||document.hidden)&&this.markMetricsAsFailed()}destroy(){clearTimeout(this.timer),this.queue=[],this.timer=void 0,this.map.off("commpoishow",this.onCommPoiShowEvent),window.removeEventListener("blur",this.markMetricsAsFailed),window.removeEventListener("focus",this.markMetricsAsFailed),document.removeEventListener("visibilitychange",this.markMetricsAsFailed)}getDefaultStats(){return K(this,null,function*(){const e=my(this.webglStatsValues),t=fy(e),i=this.map.performanceChecker.getFpsStats(),o=Array.from(this.map.state.center),a=this.map.state.zoom,r=this.map.state.rotation,l=this.map.state.pitch,c=yield Md();return{webglStats:t,fps:i,center:o,zoom:a,rotation:r,pitch:l,webGpuSupported:c}})}createMetricMessage(e,t,i){return K(this,null,function*(){const o=yield this.getDefaultStats();return{type:411,eventType:"mapglCounter",eventId:fs(),timestamp:e,payload:{mapGlMapMetrics:de(B(B({},t),o),{memory:i}),mapGlHostAppParams:My(this.map.state.bssHostAppParams)},common:{formatVersion:3,appVersion:n.limitString(Ts,xy),product:44,deviceType:yy()?"mobile":"desktop",key:this.map.state.tileKey,styleId:this.map.state.styleId}}})}getMetricsMessage(e,t){return K(this,null,function*(){const i=yield this.map.performanceChecker.getMemoryStats(),o=yield this.createMetricMessage(t,e,i);return o.payload.mapGlMapMetrics.fail&&!o.payload.mapGlMapMetrics.fps.isStatic&&e.firstcontent!==void 0&&(o.payload.mapGlMapMetrics.fail=!1),o})}}function Sy(s,e,t,i,o,a){const r={adsHighlight:!0,entity:{id:s.id,type:"branch"}};s.adsPriority!==void 0&&(r.adsPriority=s.adsPriority);const l={type:302,eventType:"view",eventId:fs(),eventOrdinal:t,uiElement:{name:"POI",ownerName:"map"},timestamp:e,utcOffset:o,payload:{POI:r},common:{formatVersion:3,appVersion:n.limitString(Ts,by),product:44,apikey:i}};return a&&(l.common.sessionId=a),!i||i===n.DEFAULT_EMPTY_KEY?null:l}function Ty(){const e=new Date().getTimezoneOffset(),t=e>0?"-":"+",i=`${Math.floor(Math.abs(e)/60)}`,o=`${Math.abs(e)%60}`;return t+(i.length>1?i:"0"+i)+":"+(o.length>1?o:"0"+o)}function My(s){if(s){const e=B({},s);return"userId"in e&&typeof e.userId!="string"&&delete e.userId,"sessionId"in e&&typeof e.sessionId!="string"&&delete e.sessionId,"product"in e&&typeof e.product!="number"&&delete e.product,e}return s}const zl=s=>typeof s=="number"&&!isNaN(s)&&s!==Number.NEGATIVE_INFINITY&&s!==Number.POSITIVE_INFINITY;function Ey(s){return Array.isArray(s)&&zl(s[0])&&zl(s[1])}var ms=(s=>(s[s.IgnoreCall=0]="IgnoreCall",s[s.UseDefault=1]="UseDefault",s))(ms||{});const Iy={0:"Method call will be ignored.",1:"Method call will use default value."};class Cy{constructor(e){this.options=e}isValidGeoPoint(e,t){return this.processValidationResult(e,Ey(e),"Invalid GeoPoint",t)}processValidationResult(e,t,i,o){return!t&&this.options.reportToConsole&&console.warn(`${i}: ${JSON.stringify(e)}
${Iy[o]}`),t}}const Rl=new Cy({reportToConsole:!0}),Gn="Style preprocessing:";function Ly(s){const e=new Map,t=i=>{i==null||i.forEach(o=>{const a={layers:i,layer:o};e.set(o.id,a),o.type==="group"&&t(o.layers)})};return t(s.layers),e}function Py(s,e){var a,r,l;const t=new Set;performance.now(),e!=null&&e.parentStyleId&&console.warn(`${Gn} Parent style with id=${s.parentStyleId} have parent with id=${e.parentStyleId}. Recursive inheritance is not supported.`);const i=e!=null?e:s;if(i.layers=(a=i.layers)!=null?a:[],e){const c=Ly(i),d=(r=s.layersInserts)!=null?r:[];d.length&&d.forEach(({layer:u,beforeId:h})=>{var f;if(h){const m=c.get(h);if(m){const{layers:p,layer:v}=m,x=p.findIndex(g=>v===g);p.splice(x,0,u),u.type!=="custom"&&u.type!=="group"&&t.add(u)}else console.warn(`${Gn} Child style tries to insert layer with beforeId=${h}. There is no layer with such id in the parent style. Layer insertion ignored.`)}else(f=i.layers)==null||f.push(u)});const _=Object.keys((l=s.layersPatches)!=null?l:{}).reduce((u,h)=>(c.has(h)||u.push(h),u),[]);_.length&&console.warn(`${Gn} Child style tries to patch layers with ids which do not exist in parent style: ${_.join("; ")}`)}const o=(c,d,_,u,h)=>{var f;if(d)for(let m=0;m<d.length;m++){const p=d[m];if(p.type==="custom")continue;let v=(f=_==null?void 0:_.layersPatches)==null?void 0:f[p.id];v&&(v==null?void 0:v.type)!==p.type&&(console.warn(`${Gn} Layer patch ignored due type mismatch. Target layer with id=${p.id} has type=${p.type}, but the patch has type=${v.type}.`),v=void 0),n.removeUndefined(p),v&&n.removeUndefined(v),p.type==="group"?(o(c,p.layers,_,p,v),d[m]=B(B({},p),v),delete d[m].commonDefaults,delete d[m].layerTypeDefaults):d[m]=By(c,p,u,h,p.type===(v==null?void 0:v.type)?v:void 0)}};return o(t,i.layers,e?s:void 0),e&&(["background","models","icons","labelingGroups","light","graphicsPresets","terrain","environment"].forEach(c=>{(i[c]&&Object.values(i[c]).length||s[c]&&Object.values(s[c]).length)&&(i[c]=B(B({},i[c]),s[c]))}),i.name=s.name),["models","icons"].forEach(c=>{i[c]&&Object.keys(i[c]).forEach(d=>{i[c][d]===null&&delete i[c][d]})}),i}function By(s,e,t,i,o){var l,c,d,_,u,h,f,m;const a=B({},t==null?void 0:t.commonDefaults),r=B({},i==null?void 0:i.commonDefaults);switch(e.type){case"heatmap":case"overpass":case"tunnel":{delete a.interactive,delete r.interactive,delete a.ignoreTier,delete r.ignoreTier;break}case"embankment":case"polygon3d":case"buildingModel":case"model":case"lineExtrusion":case"polygonExtrusion":case"point":{delete a.ignoreTier,delete r.ignoreTier;break}case"arrow":case"dashedLine":case"labelLine":case"line":case"metricPoint":case"oneWayLine":case"polygon":case"raster":case"shiftedLine":break;default:n.assertUnreachable(e)}return de(B(B(B(B(B(B(B({},a),(l=t==null?void 0:t.layerTypeDefaults)==null?void 0:l[e.type]),e),r),(c=i==null?void 0:i.layerTypeDefaults)==null?void 0:c[e.type]),s.has(e)?e:void 0),o),{style:B(B(B(B(B(B(B({},(d=t==null?void 0:t.commonDefaults)==null?void 0:d.style),(u=(_=t==null?void 0:t.layerTypeDefaults)==null?void 0:_[e.type])==null?void 0:u.style),e.style),(h=i==null?void 0:i.commonDefaults)==null?void 0:h.style),(m=(f=i==null?void 0:i.layerTypeDefaults)==null?void 0:f[e.type])==null?void 0:m.style),s.has(e)?e.style:void 0),o==null?void 0:o.style)})}function zy(s,e,t){return K(this,null,function*(){const i=new URL(n.template(s,{id:e}));i.searchParams.append("key",t);const o=yield fetch(i.toString());if(o.status===404){console.warn(`No access to style with id «${e}».`);return}if(!o.ok)return;const a=yield o.json();if(a&&a.result)return{loadedId:e,style:a.result}})}function Ry(s,e,t){return K(this,null,function*(){let i;try{const o=n.applyDefaults(t||{},{rootUrl:n.styles.url,stylePath:n.styles.path,iconsPath:n.icons.defaultUrl,fontsPath:n.fonts.defaultUrl,modelsPath:n.defaultModelsPath}),a=yield zy(n.getStyleUrl(o),s,e);if(!a)throw new Error;i=a.style}catch(o){throw new Error("FETCH_PARENT_STYLE_ERROR")}return i})}function Fy(s,e,t){return K(this,null,function*(){let i;return s.parentStyleId&&(i=yield Ry(s.parentStyleId,e,t)),Py(s,i)})}const Fl=["zoom","rotation","pitch","center"],Dy=150,Oy=["static","immersive_roads"];class ps extends n.Evented{constructor(e,t){var a;super();const i=this.core=new hs(e,t,this);this.state=i.state,this.modules=i.modules,this.performanceChecker=i.performanceChecker,this.values={isMoveChanging:!1,isIdle:!1},Fl.forEach(r=>{this.cloneFromStateToValues(r,`${r}1`),this.cloneFromStateToValues(r,`${r}2`),this.cloneFromStateToValues(r,`${r}End1`),this.cloneFromStateToValues(r,`${r}End2`),this.values[`${r}EndTime`]=0,this.values[`is${r}Changing`]=!1}),this.cloneFromStateToValues("size","size"),this.performanceChecker.on("performancecaveat",()=>{this.emit("performancecaveat")});const o=r=>{if(r instanceof Error)throw r};this.setStyle((a=t==null?void 0:t.style)!=null?a:n.DEFAULT_MAPGL_STYLE,t==null?void 0:t.styleOptions).catch(o),this.setLang(this.state.lang),t&&!t.disableBssStatistics&&(this._bssDispatcher=new wy(this,{disableBssStatisticsForCommPoi:!!t.disableBssStatisticsForCommPoi,bssUrl:t.bssUrl})),this.state.metrics.init=performance.now()-this.state.metrics.start,this.updateDataToggle()}setCenter(e,t){if(!Rl.isValidGeoPoint(e,ms.IgnoreCall))return this;this.state.userHasInteracted=!1;let i=n.Mercator.fromGeo(e);return this.state.loopWorld||(i=n.normalizeMapPoint(i)),Ft(this.state,i,t),this}setZoom(e,t){return n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)?(this.state.zoomTypePreserving="zoom",this.state.userHasInteracted=!1,wt(this.state,e,t),this.state.shouldIsReadyWaitForUpdates=!0,this):this}setStyleZoom(e,t){if(!n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER))return this;const i=n.getZoomFromStyleZoom(e,this.state.center);return this.state.zoomTypePreserving="styleZoom",this.state.userHasInteracted=!1,wt(this.state,i,t),this}setMinZoom(e,t){return this.state.minZoom=e,this.setZoom(this.state.zoom,t),this}setMaxZoom(e,t){return this.state.maxZoom=e,this.setZoom(this.state.zoom,t),this}setRotation(e,t){return n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)?(this.state.userHasInteracted=!1,di(this.state,n.degToRad(e),t),this):this}setPitch(e,t){return n.isBetween(e,Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER)?(this.state.userHasInteracted=!1,Ui(this.state,n.degToRad(e),t),this):this}setAnimationTerrain(e){this.modules.demManager.setAnimationTerrain(e)}getAnimationTerrainStatus(){return this.modules.demManager.getAnimationTerrainStatus()}setMinPitch(e,t){return this.state.minPitch=n.degToRad(e),this.setPitch(n.radToDeg(this.state.pitch),t),this}setMaxPitch(e,t){return this.state.maxPitch=n.degToRad(e),this.setPitch(n.radToDeg(this.state.pitch),t),this}setLowZoomMaxPitch(e,t){return this.state.lowZoomMaxPitch=n.degToRad(e),this.setPitch(n.radToDeg(this.state.pitch),t),this}setViewport(e,t){return this.state.userHasInteracted=!1,Mc(this.state,this.modules.layout.rootContainer,this.modules.renderer,e,t),this}setMaxBounds(e){return this.state.maxBounds=n.fromGeo(e),this}setPadding(e,t){var o,a,r,l;const i={top:(o=e.top)!=null?o:0,left:(a=e.left)!=null?a:0,right:(r=e.right)!=null?r:0,bottom:(l=e.bottom)!=null?l:0};return this.state.userHasInteracted=!1,Bc(this.state,this.modules.renderer,i,t),this}setTime(e){this.patchStyleState({_customUserTimeOffset:e?e-this.state.time:0}),this.modules.animationManager.clearAllTickers(),this.modules.renderer.addRerenderEvent()}getTime(e){return e?this.state.time-new Date().getTimezoneOffset()*6e4+ +(this.state.styleState._customUserTimeOffset||0):this.state.time+ +(this.state.styleState._customUserTimeOffset||0)}getPadding(){return this.state.padding}getCenter(){const e=n.normalizeMapPoint(this.state.center);return n.Mercator.toGeo(e).slice(0,2)}getZoom(){return this.state.zoom}getStyleZoom(){return this.state.styleZoom}getMinZoom(){return this.state.minZoom}getMaxZoom(){return this.state.maxZoom}getRotation(){return n.radToDeg(this.state.rotation)}getPitch(){return n.radToDeg(this.state.pitch)}getViewport(){return this.state.viewport}getSize(){return[this.state.size[0],this.state.size[1]]}getBounds(e){let t=this.modules.camera;if(e!=null&&e.skipPadding)t=new n.Camera(de(B({},this.state),{padding:{left:0,right:0,top:0,bottom:0}}));else if(e!=null&&e.sizeExtension){const o=e.sizeExtension,[a,r]=this.state.size,l=[a+o,r+o];t=new n.Camera(de(B({},this.state),{size:l}))}t.update();const i=n.tetragonBounds(t.getViewportVertices());return{southWest:n.Mercator.toGeo(i.min),northEast:n.Mercator.toGeo(i.max)}}getDefaultSource(){return this.modules.defaultSource}hideBuildingsById(e,t=n.DEFAULT_ID_SCOPE){if(!e.length)return;const{identifier:i}=this.modules;i.getIdScope(t).hide(e),this.modules.renderer.addRerenderEvent({type:"triggerRerender"})}showHiddenBuildingsById(e,t=n.DEFAULT_ID_SCOPE){if(!e.length)return;const{identifier:i}=this.modules;i.getIdScope(t).show(e),this.modules.renderer.addRerenderEvent({type:"triggerRerender"})}getWebGLContext(){return this.modules.renderer.getRenderingContext()}getCanvas(){return this.modules.layout.canvas}showTraffic(){this.modules.trafficTileLayer.show()}hideTraffic(){this.modules.trafficTileLayer.hide()}isTrafficOn(){return this.modules.trafficTileLayer.isEnabled()}setPersonalPoi(e){this.modules.personalPoiManager.setPersonalPoi(e)}setSelectedIds(e=[],t=n.DEFAULT_ID_SCOPE){const{identifier:i}=this.modules,o=i.getIdScope(t);return o==null||o.select(e),this.modules.identifier.queryFillCache(),this}project(e){return this.modules.camera.project(e)}unproject(e){return this.modules.camera.unproject(e)}getCameraProjectionMatrix(){return this.modules.camera.projectionMatrix}getCameraViewMatrix(){return this.modules.camera.viewMatrix}getCameraViewProjectionMatrix(){return this.modules.camera.viewProjectionMatrix}invalidateSize(){this.state.userHasInteracted=!1;const e=window.devicePixelRatio,{viewport:t}=this.state,{clientWidth:i,clientHeight:o}=this.modules.layout.rootContainer;return this.state.size=[Math.max(1,i-t.left-t.right),Math.max(1,o-t.top-t.bottom)],this.modules.renderer.setPixelRatio(e),this.modules.renderer.setSize(i,o),this.modules.renderer.addRerenderEvent(),this.modules.newRenderer.resize(i,o,e),this}destroy(){var e;this.core.destroy(),(e=this._bssDispatcher)==null||e.destroy()}refresh(){return this.modules.renderer.addRerenderEvent(),this.state.needLabeling=!0,this.modules.identifier.resetCache(),this}changeFloorNumber(e,t){return this.modules.floorManager.changeFloorNumber(e,t),this.state.shouldIsReadyWaitForUpdates=!0,this}hasLayer(e){return this.modules.styleManager.hasLayer(e)}addLayer(e,t){return e.type==="custom"&&(this.state.aaMode=void 0),this.modules.styleManager.addLayer(e,t),this.core.activateStyleUpdating(),this}removeLayer(e){return this.modules.styleManager.removeLayer(e),this.core.activateStyleUpdating(),this}hideLayers(e){const{id:t,type:i}=e,o=a=>(this.modules.styleManager.hideLayers(a),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const a=n.convertStyleLayerTypeToHandy(i);if(a)return o({type:a})}else if(t)return o({id:t});return console.warn(`[#hideLayers] The layer with type "${i}" can't be hidden.`),this}showLayers(e){const{id:t,type:i}=e,o=a=>(this.modules.styleManager.showLayers(a),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const a=n.convertStyleLayerTypeToHandy(i);if(a)return o({type:a})}else if(t)return o({id:t});return console.warn(`[#showLayers] The layer with type "${i}" can't be shown.`),this}setStyle(e,t){return K(this,null,function*(){let i,o=!1,a=!1;try{return typeof e=="string"?n.isStyleId(e)?(o=!this.core.state.disableStyleFallback&&Number.isNaN(this.state.handyStyleId)&&e!==n.DEFAULT_MAPGL_STYLE,i=yield this.setCustomStyleById(e,t)):i=yield this.setCustomStyleFromUrl(e,t):(yield this.setCustomStyleDirectly(e,t),i=e),a=!0,this.emit("styleload",{style:i}),i}catch(r){if(a)throw r;if(r instanceof Error&&this.emit("error",{type:"styleloaderror",style:e}),o&&!this.currentPendingStyle)return this.setStyle(n.DEFAULT_MAPGL_STYLE);throw r}})}addIcon(e,t){return e?(this.modules.styleManager.addIcon(e,t)&&this.core.activateStyleUpdating(),this):(console.error("The icon name is empty."),this)}removeIcon(e){return e?(this.modules.styleManager.removeIcon(e)&&this.core.activateStyleUpdating(),this):this}addModel(e,t){return e?(this.modules.styleManager.addModel(e,t)&&this.core.activateStyleUpdating(),this):(console.error("The model name is empty."),this)}waitForGpuToFinishDrawing(){return this.modules.identifier.readIdentifyPixels(!0),this}setLang(e){const t=n.isRtlPluginRequired(this.state.rtlPlugin.scenario,e);this.state.rtlPlugin.loadFailed&&t||(this.state.lang=e,this.state.rtlPlugin.loadFailed||n.setupMapboxRtlAdapterIfNeeded(this.state.rtlPlugin,this.modules,e).catch(i=>{throw this.state.rtlPlugin.loadFailed=!0,this.setLang(n.defaultLang),i}),this.modules.tileManager.redraw())}showLabelsDebug(e){this.modules.labelsDebug.show(e)}hideLabelsDebug(){this.modules.labelsDebug.hide()}getContainer(){return this.modules.layout.mapContainer}getExternalContainer(){return this.modules.layout.externalContainer}fitBounds({northEast:e,southWest:t},i){const o=B({top:0,left:0,right:0,bottom:0},i!=null&&i.padding?i.padding:{}),a=this.getViewport(),r=this.getPadding(),l=i!=null&&i.skipMapPadding?o:Ic(r,o),c=this.getSize(),d=i!=null&&i.considerRotation?this.getRotation():0;if(c[0]-l.left-l.right<=0||c[1]-l.top-l.bottom<=0)return console.warn("Map cannot fit within canvas with the given bounds and padding."),this;i!=null&&i.considerRotation||di(this.state,d,{animate:!1});const _=Ri([[t[0],e[1]],e,[e[0],t[1]],t],d,[c[0]-l.left-l.right,c[1]-l.top-l.bottom]);if(!_)return console.warn("Map cannot fit within canvas with the given bounds and padding."),this;const u=[(c[0]-l.left-l.right)/2+l.left+a.left,(c[1]-l.top-l.bottom)/2+l.top+a.top];let h;(i==null?void 0:i.maxZoom)!==void 0?h=Math.min(_.zoom,i==null?void 0:i.maxZoom):h=_.zoom,h=n.clamp(h,this.state.minZoom,this.state.maxZoom);const m=new n.Camera({zoom:h,rotation:this.state.rotation,size:this.state.size,padding:this.state.padding,viewport:this.state.viewport,pitch:0,center:_.center,cameraConfig:this.state.cameraConfig,globeMode:this.state.globeMode,styleState:this.state.styleState}).flat.unproject(u),p=[0,0];n.sub(p,_.center,m);const v=[0,0,0];n.add(v,_.center,p);const x=i!=null&&i.animation?i.animation:{};x.easing||(x.easing="easeOutCubic");const g=B({},x);return Ft(this.state,v,x),wt(this.state,h,g),Ui(this.state,0,x),this}update(){const e=this.state,{time:t,userHasInteracted:i}=e,o=this.values,a={};Fl.forEach(c=>{let d=e[c];c==="zoom"&&e.zoomTypePreserving==="styleZoom"&&(d=e.styleZoom),a[`${c}start`]=!o[`is${c}Changing`]&&!this.areEqual(d,o[`${c}1`])&&this.areEqual(o[`${c}1`],o[`${c}2`]),a[`${c}start`]&&(o[`is${c}Changing`]=!0),o[`is${c}Changing`]&&(a[c]=!this.areEqual(d,o[`${c}1`]),t-o[`${c}EndTime`]>Dy&&(a[`${c}end`]=this.areEqual(d,o[`${c}End1`])&&!this.areEqual(o[`${c}End1`],o[`${c}End2`]),a[`${c}end`]&&(o[`is${c}Changing`]=!1),this.copyFromValuesToValues(`${c}End2`,`${c}End1`),this.copyFromStateToValues(d,`${c}End1`),o[`${c}EndTime`]=t)),this.copyFromValuesToValues(`${c}2`,`${c}1`),this.copyFromStateToValues(d,`${c}1`)}),a.resize=!this.areEqual(e.size,o.size),this.copyFromStateToValues(e.size,"size"),a.movestart=(a.zoomstart||a.rotationstart||a.centerstart||a.pitchstart)&&!o.isMoveChanging,a.movestart&&(o.isMoveChanging=!0),a.move=o.iszoomChanging||o.isrotationChanging||o.iscenterChanging||o.ispitchChanging,a.moveend=(a.zoomend||a.rotationend||a.centerend||a.pitchend)&&!a.move,a.moveend&&(o.isMoveChanging=!1);const r=o.isIdle,l=o.isReady;o.isIdle=this.isIdle(),o.isReady=this.isReady(),a.idle=!r&&o.isIdle,a.ready=!l&&o.isReady,e.metrics.ready===void 0&&this.isReadyForMetrics()&&(e.metrics.ready=performance.now()-e.metrics.start);for(const c in a){const d=c;a[d]&&this.emit(d,{isUser:i})}}isIdle(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isIdle()}isReady(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isReady()}isReadyForMetrics(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isReadyForMetrics()}setAutoHoverMode(e){this.modules.defaultSource.resetHoverId(),this.state.disableHoverStyles=!e}setStyleState(e){const{_customUserTimeOffset:t}=this.state.styleState,i=()=>{this.state.styleState._customUserTimeOffset=t};if(this.state.graphicsPresetMode){const o=Wt()?"light":e.graphicsPreset;this.state.styleState=Ln(e,this.getGraphicsPresetFeatures(o))}else this.state.styleState=Ln(e);i(),this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}getStyleState(){return B({},this.state.styleState)}patchStyleState(e){if(this.state.graphicsPresetMode){const t=Wt()?"light":e.graphicsPreset;this.state.styleState=ll(this.state.styleState,e,this.getGraphicsPresetFeatures(t))}else this.state.styleState=ll(this.state.styleState,e);this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}setOption(e,t){if(Is.indexOf(e)===-1){console.error(`Can't change the "${e}" option.`);return}switch(e){case"loopWorld":{if(this.state.loopWorld===t)return;const i=t?n.worldLoopBounds:n.worldBounds,o=this.state.maxBounds;(n.exactEquals$1(o.min,n.worldLoopBounds.min)&&n.exactEquals$1(o.max,n.worldLoopBounds.max)||n.exactEquals$1(o.min,n.worldBounds.min)&&n.exactEquals$1(o.max,n.worldBounds.max))&&(this.state.maxBounds=i),this.modules.renderer.addRerenderEvent();break}case"disableHidingPois":{if(this.state.disableHidingPois===t)return;this.modules.renderer.addRerenderEvent();break}}this.state[e]=t}getOption(e){if(Is.indexOf(e)===-1){console.error(`Can't get the value of the "${e}" option.`);return}return this.state[e]}getGroundPoint(e){return this.modules.demManager.getGroundPoint(e)}setAllowedFloorIds(e){this.modules.floorManager.setAllowedFloorIds(e)}getMapRenderStat(){var f,m,p;this.modules.renderer.addRerenderEvent();const{drawCount:e,vertexCount:t,triangleCount:i}=this.state.stats,a=598044/(this.state.size[0]*this.state.size[1]/window.devicePixelRatio),r=[{level:0,draws:[0,500],vertcles:[0,1e6],triangles:[0,333e3]},{level:1,draws:[501,1e3],vertcles:[1000001,2e6],triangles:[3330001,666e3]},{level:2,draws:[1001,1500],vertcles:[2000001,3e6],triangles:[666001,999e3]},{level:3,draws:[1501,2500],vertcles:[3000001,6e6],triangles:[999001,2e6]},{level:4,draws:[2501,3500],vertcles:[6000001,12e6],triangles:[2000001,4e6]},{level:5,draws:[3501,1/0],vertcles:[12000001,1/0],triangles:[4000001,1/0]}],l=e*a,c=t*a,d=i*a,_=((f=r.find(v=>v.draws[0]<=l&&v.draws[1]>=l))==null?void 0:f.level)||0,u=((m=r.find(v=>v.vertcles[0]<=c&&v.vertcles[1]>=c))==null?void 0:m.level)||0,h=((p=r.find(v=>v.triangles[0]<=d&&v.triangles[1]>=d))==null?void 0:p.level)||0;return{drawCount:e,vertexCount:t,drawsLevel:_,vertexLevel:u,triangleCount:i,triangleLevel:h,level:Math.ceil((_+u)/2)}}getDataToggle(){return this.modules.defaultSource.getDataType()}setLightingStyle(e){const t=this.modules.styleManager.getStyle(this.state.handyStyleId);t&&(t.light=n.makeHandyLightStyle(e,t.dem),t.light.lightingModesResolved={},this.state.needRerender=!0)}getFeatureFlag(e,t){return!this.modules||(t=t!=null?t:this.core.state.styleState.graphicsPreset,!t)?!1:this.modules.styleManager.getFeatureFlag(e,t)}getCurrentGraphicsPreset(){if(!this.state.graphicsPresetMode)throw new Error("You can get current graphics preset only when graphicsPresetMode is set.");return{name:this.state.styleState.graphicsPreset,preset:this.getGraphicsPresetFeatures()}}getGraphicsPresetFeatures(e){return ry.reduce((t,i)=>(t[i]=this.getFeatureFlag(i,e),t),{})}setCustomStyleById(e,t){return K(this,null,function*(){this.currentPendingStyle=e;const{iconUrl:i,styleServer:o,fontUrl:a,modelUrl:r}=this.state,l=n.applyDefaults(t||{},{rootUrl:o,stylePath:n.styles.path,iconsPath:i,fontsPath:a,modelsPath:r}),c=yield this.fetchStyleById(n.getStyleUrl(l),e);if(this.currentPendingStyle!==e)return Promise.reject(`Cancel setting the style «${e}», there is a newer style was set`);if(!c)throw this.currentPendingStyle=void 0,new Error(`There is no correct style with id «${e}»`);const{style:d,loadedId:_}=c;return yield this.setCustomStyle(d,l),_})}setCustomStyleFromUrl(e,t){return K(this,null,function*(){this.currentPendingStyle=e;const i=n.applyDefaults(t||{},{rootUrl:e,iconsPath:"",fontsPath:"",stylePath:"style.json",modelsPath:""}),o=yield Ny(n.getStyleUrl(i));if(e!==this.currentPendingStyle)return Promise.reject(`Cancel setting the style «${e}», there is a newer style was set`);if(!o)throw this.currentPendingStyle=void 0,new Error(`There are no correct styles by url «${e}»`);return yield this.setCustomStyle(o,i),e})}setCustomStyleDirectly(e,t){const i=window.location.protocol,o=window.location.host,a=n.applyDefaults(t||{},{rootUrl:`${i}//${o}`,stylePath:"",iconsPath:"",fontsPath:"",modelsPath:""});this.currentPendingStyle=`__${Date.now()}__${performance.now()}__`;const r=e&&JSON.parse(JSON.stringify(e));return this.setCustomStyle(r,a)}setCustomStyle(e,t){return K(this,null,function*(){if(!e)throw new Error("Can't set empty style");const i=this.currentPendingStyle||"";this.currentPendingStyle=void 0;const o=yield Fy(e,this.state.tileKey,t);if(this.currentPendingStyle!==void 0)return;const{showCommPoi:a}=yield this.modules.tileKeyInfo.getKeyInfo(),r=this.modules.styleManager.createStyle(o,t,a);this.state.handyStyleId=r.id,this.state.styleId=i,this.patchStyleState({}),this.core.activateStyleUpdating()})}copyFromStateToValues(e,t){Ci(e)?n.copy$3(this.values[t],e):this.values[t]=e}cloneFromStateToValues(e,t){const i=this.state[e];Ci(i)?this.values[t]=n.clone(i):this.values[t]=i}copyFromValuesToValues(e,t){const i=this.values[t];Ci(i)?n.copy$3(this.values[e],i):this.values[e]=i}areEqual(e,t){return Ci(e)&&Ci(t)?n.exactEquals$1(e,t):e===t}fetchStyleById(e,t){return K(this,null,function*(){const i=new URL(n.template(e,{id:t}));i.searchParams.append("key",this.state.tileKey);const o=yield fetch(i.toString());if(o.status===404){console.warn(`No access to style with id «${t}».`);return}if(!o.ok)return;const a=yield o.json();if(a&&a.result)return{loadedId:t,style:a.result}})}updateDataToggle(){this.modules.defaultSource.setDataType(this.state.styleState.immersiveRoadsOn?Oy:void 0)}}function Ny(s){return fetch(s).then(e=>{if(e.ok)return e.json()})}function Ci(s){return s.length!==void 0}const Dl=0,ky=-1,Uy=-2,Ol=3,Gy=0,Hy=0,Vy="#3388ff",Zy="#00000000",jy="#00000000";let Nl=class extends We{constructor(e,t){var r,l,c,d,_,u,h,f,m,p,v,x,g;super(e,t),this.length=1,this.isGeometryOutOfMainReplica=!1,this.removed=!1,this.options=t;const{dynamicStyle:i,layers:o}=this.modules;this.dynamicStyleId=i.getStyle().id,this.geoPoints=this.options.coordinates.filter((y,b,M)=>b===0||!n.exactEquals$2(M[b],M[b-1])),this.points=this.geoPoints.map(y=>n.Mercator.fromGeo(y)),this.isGeometryOutOfMainReplica=this.points.some(y=>y[0]>n.HALF_WORLD_SIZE||y[0]<-n.HALF_WORLD_SIZE);let a=0;this.distances=[],this.distances.push(a);for(let y=1;y<this.geoPoints.length;y++)a+=n.geoPointsDistance(this.geoPoints[y-1],this.geoPoints[y]),this.distances.push(a);if(this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.debouncedGenerate=n.debounce(()=>{this.generate()},200),this.tileAttrs=n.optionsToTileAttrs({beginningIsCut:0,endingIsCut:0,db_tiers:t.tiers}),this.options.width!==0){this.rawStyleLayer={type:"line",id:`dynamic-polyline-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(r=this.options.color)!=null?r:Vy,width:(l=this.options.width)!=null?l:Ol},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const y=n.makeHandyStyleLayer(this.rawStyleLayer);if(y&&(this.styleLayerId=y.innerId,i.addLayer(y,(c=this.options.zIndex)!=null?c:Dl)),this.options.renderingMode==="3d"&&this.options.hiddenPartColor){this.rawHiddenStyleLayer={type:"line",id:`dynamic-polyline-hidden-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.hiddenPartColor,width:(d=this.options.width)!=null?d:Ol},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}};const b=n.makeHandyStyleLayer(this.rawHiddenStyleLayer);b&&(this.styleHiddenLayerId=b.innerId,i.addLayer(b,(_=this.options.zIndex)!=null?_:Dl))}}if(this.options.width2){this.rawStyleLayer2={type:"line",id:`dynamic-polyline2-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(u=this.options.color2)!=null?u:Zy,width:(h=this.options.width2)!=null?h:Gy},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const y=n.makeHandyStyleLayer(this.rawStyleLayer2);y&&(this.styleLayer2Id=y.innerId,i.addLayer(y,(f=this.options.zIndex2)!=null?f:ky))}if(this.options.width3){this.rawStyleLayer3={type:"line",id:`dynamic-polyline3-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(m=this.options.color3)!=null?m:jy,width:(p=this.options.width3)!=null?p:Hy},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const y=n.makeHandyStyleLayer(this.rawStyleLayer3);y&&(this.styleLayer3Id=y.innerId,i.addLayer(y,(v=this.options.zIndex3)!=null?v:Uy))}if(!(this.styleLayerId===void 0&&this.styleLayer2Id===void 0&&this.styleLayer3Id===void 0)){if(t.showAnimation&&t.showAnimation.animate!==!1&&this.points.length>1){this.animationTickerName=`polyline-${this.uniqId}`;const y=(g=(x=this.styleLayer3Id)!=null?x:this.styleLayer2Id)!=null?g:this.styleLayerId;y&&this.startShowTicker(this.animationTickerName,y)}o.addLayer(this),this.generate()}}update(){this.removed||(super.update(),this.stateDiffer.check(this.mapState)&&this.debouncedGenerate(),this.animationTickerName&&this.updateShowTicker(this.animationTickerName))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}snapPoint(e){function t([u,h],f=0){return[f+(u+n.HALF_WORLD_SIZE)/n.worldSize,(h+n.HALF_WORLD_SIZE)/n.worldSize]}function i([u,h]){return[u*n.worldSize-n.HALF_WORLD_SIZE,h*n.worldSize-n.HALF_WORLD_SIZE]}const o=this.mapState.visibleMapReplicas,a=this.points.map(u=>t(u));let r=1/0,l=a[0],c=0;for(const u of o){const h=t(this.modules.camera.flat.unproject(e),u);for(let f=0;f<a.length-1;f++){const m=a[f],p=a[f+1],v=n.getClosestPointOnLineSegment(h,m,p),x=v[0]-h[0],g=v[1]-h[1],y=x*x+g*g;y<r&&(r=y,l=i(v),c=f)}}const d=n.Mercator.toGeo(l),_=this.distances[c]+n.geoPointsDistance(d,this.geoPoints[c]);return{point:d,distance:_}}setStyle(e){this.setSubLayerStyle(this.styleLayerId,this.rawStyleLayer,e.color),this.setSubLayerStyle(this.styleLayer2Id,this.rawStyleLayer2,e.color2),this.setSubLayerStyle(this.styleLayer3Id,this.rawStyleLayer3,e.color3),this.setSubLayerStyle(this.styleHiddenLayerId,this.rawHiddenStyleLayer,e.hiddenPartColor)}remove(){this.removed||(this.removed=!0,this.animationTickerName&&(n.stop(this.animationTickerName,this.mapState),this.animationTickerName=void 0),this.interactive&&this.modules.identifier.resetCache(),this.styleLayerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleLayerId),this.styleHiddenLayerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleHiddenLayerId),this.styleLayer2Id!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleLayer2Id),this.styleLayer3Id!==void 0&&this.modules.dynamicStyle.removeLayer(this.styleLayer3Id),super.destroy())}startShowTicker(e,t){var l,c,d;const a=((l=this.options.showAnimation)==null?void 0:l.easing)!==void 0?this.options.showAnimation.easing:"linear",r=((c=this.options.showAnimation)==null?void 0:c.duration)!==void 0?this.options.showAnimation.duration:250;n.start(e,{easing:a,animationGroup:(d=this.options.showAnimation)==null?void 0:d.animationGroup},this.mapState,0,1,r,1,{layerId:t,styleId:this.dynamicStyleId}),this.length=0}setSubLayerStyle(e,t,i){if(e!==void 0&&i&&t&&i!==t.style.color){const{dynamicStyle:o}=this.modules;t.style.color=i;const a=n.makeHandyStyleLayer(t);a&&(o.updateLayerStyle(e,a),this.modules.renderer.addRerenderEvent())}}updateShowTicker(e){n.update(e,{step:(t,i)=>{var a,r,l,c;const o=n.affineStep(((r=(a=this.options.showAnimation)==null?void 0:a.durationRange)==null?void 0:r.start)||0,((c=(l=this.options.showAnimation)==null?void 0:l.durationRange)==null?void 0:c.end)||1,i);o!==this.length&&(this.length=o,this.generate())}},this.mapState)}generate(){if(this.points.length<2||this.removed)return;const e=!!this.animationTickerName,{dynamicStyle:t,collector:i,tileManager:o,identifier:a,map:r}=this.modules,{tileProps:l}=n.fixedMetatile,c=Math.min(Math.floor(r.getZoom()),15),d=n.tileZoomToSize(c),_=n.splitPolylineByLength(this.points,this.distances,this.length),u=n.splitPolylineByMaxSize(_,d),h=n.create$1(),f=n.create();this.tileObjects.forEach(m=>{m.clean(this.mapState),o.removeObject(m,e)}),this.tileObjects=[];for(let m=0;m<u.length;m++){const p=u[m];n.reset(f);for(let E=0;E<p.length;E++)n.expandByPoint(f,p[E]);n.center(h,f);const v=n.getTileCoordsByCenterAndZoom(h,c),x=Math.pow(2,v[2]),g=[...this.mapState.visibleMapReplicas];if(this.isOutOfMainReplica()){const E=g[0],F=g[g.length-1];g.push(E-1,F+1)}if(!g.map(E=>[v[0]+E*x,v[1],v[2],v[3]]).some(E=>this.mapState.globeMode?n.isTileOnSphereInViewport(this.mapState,this.modules.camera,E):n.isTileVisible(E,this.mapState.tilesBounds,this.modules)))continue;if(this.options.displayTileBounds){const F=t.getStyle().layers.find(z=>z.id==="debug-tile-bounds");n.generateTileBounds(i,F,this.mapState.styleState);const j=i.getAccumulatedData(),ee=new n.TileObject("dynamicObject",j.data,this.modules,this.mapState,v);this.tileObjects.push(ee),o.addObject(ee,e)}const M=n.createTileInfo(v),T=[],P=[];for(let E=0;E<p.length;E++)n.mapPointToTilePoint(h,p[E],M),T[E]=h[0],P[E]=h[1];this.tileAttrs[l.beginningIsCut]=0,this.tileAttrs[l.endingIsCut]=0,m!==0&&(this.tileAttrs[l.beginningIsCut]=1),m+1!==u.length&&(this.tileAttrs[l.endingIsCut]=1);const S=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,this.tileAttrs,n.emptyFeatureAttrs,this.interactive?"0":"");if(this.styleLayerId!==void 0){const E=t.getStyle().layersById[this.styleLayerId];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,S,M,{x:T,y:P}]}))}if(this.styleHiddenLayerId!==void 0){const E=t.getStyle().layersById[this.styleHiddenLayerId];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,S,M,{x:T,y:P}]}))}if(this.styleLayer2Id!==void 0){const E=t.getStyle().layersById[this.styleLayer2Id];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,S,M,{x:T,y:P}]}))}if(this.styleLayer3Id!==void 0){const E=t.getStyle().layersById[this.styleLayer3Id];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,S),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,S,M,{x:T,y:P}]}))}const C=i.getAccumulatedData(),I=new n.TileObject("dynamicObject",C.data,this.modules,this.mapState,M.coords,this);o.addObject(I,e),this.tileObjects.push(I),this.interactive&&this.identifyIds.push(C.identifyIds)}this.interactive&&a.resetCache(),i.reset(),e||this.modules.renderer.addRerenderEvent()}};const kl=0,Ul=-1,Gl=8,Hl=12,Wy="#2480ff",$y="#ffffff",Vl=6,Zl=20,Xy="#ffffff00";class jl extends We{constructor(e,t){var o,a,r,l,c,d,_,u,h,f,m;super(e,t),this.isGeometryOutOfMainReplica=!1,this.length=1,this.dynamicStyleId=this.modules.dynamicStyle.getStyle().id,this.removed=!1,this.options=t,this.points=this.options.coordinates.map(p=>n.Mercator.fromGeo(p)),this.isGeometryOutOfMainReplica=this.points.some(p=>p[0]>n.HALF_WORLD_SIZE||p[0]<-n.HALF_WORLD_SIZE),this.distances=[],this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.debouncedGenerate=n.debounce(()=>{this.generate()},200),this.tileAttrs=n.optionsToTileAttrs({previousPointX:0,previousPointY:0,nextPointX:0,nextPointY:0,beginningIsCut:0,endingIsCut:0,componentDistanceStart:0,objectLength:0,db_tiers:t.tiers});const{layers:i}=this.modules;if(i.addLayer(this),this.dashLayerRaw={type:"dashedLine",id:`dynamic-dashed-polyline-dash-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.dashColor||Wy,dashLength:(o=this.options.dashLength)!=null?o:Vl,gapColor:this.options.gapColor||Xy,gapLength:(a=this.options.gapLength)!=null?a:Zl,width:(r=this.options.width)!=null?r:Gl},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}},this.baseLayerRaw={type:"line",id:`dynamic-dashed-polyline-base-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.dash2Color||$y,width:(c=(l=this.options)==null?void 0:l.width2)!=null?c:Hl},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}},this.dashLayer=n.makeHandyStyleLayer(this.dashLayerRaw),this.baseLayer=n.makeHandyStyleLayer(this.baseLayerRaw),t.renderingMode==="3d"&&t.hiddenPartDashColor&&(this.hiddenDashLayerRaw={type:"dashedLine",id:`dynamic-hidden-dashed-polyline-dash-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:t.hiddenPartDashColor,dashLength:(d=this.options.dashLength)!=null?d:Vl,gapColor:this.options.hiddenPartGapColor,gapLength:(_=this.options.gapLength)!=null?_:Zl,width:(u=this.options.width)!=null?u:Gl},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}},this.hiddenDashLayer=n.makeHandyStyleLayer(this.hiddenDashLayerRaw),this.options.hiddenPartDash2Color&&(this.hiddenBaseLayerRaw={type:"line",id:`dynamic-hidden-dashed-polyline-base-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.hiddenPartDash2Color,width:(f=(h=this.options)==null?void 0:h.width2)!=null?f:Hl},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}},this.hiddenBaseLayer=n.makeHandyStyleLayer(this.hiddenBaseLayerRaw))),t.showAnimation&&t.showAnimation.animate!==!1&&this.points.length>1){let p=0;this.distances.push(p);for(let x=1;x<this.options.coordinates.length;x++)p+=n.geoPointsDistance(this.options.coordinates[x-1],this.options.coordinates[x]),this.distances.push(p);this.animationTickerName=`dashedLine-${this.uniqId}`;const v=(m=this.baseLayer)==null?void 0:m.innerId;v&&this.startShowTicker(this.animationTickerName,v)}this.generate()}update(){this.removed||(super.update(),this.stateDiffer.check(this.mapState)&&this.debouncedGenerate(),this.animationTickerName&&this.updateShowTicker(this.animationTickerName))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}setStyle(e){const{dashColor:t,dash2Color:i,gapColor:o,hiddenPartDashColor:a,hiddenPartGapColor:r,hiddenPartDash2Color:l}=e,{dynamicStyle:c}=this.modules;if(this.dashLayer){t!==void 0&&(this.dashLayerRaw.style.color=t),o!==void 0&&(this.dashLayerRaw.style.gapColor=o);const d=n.makeHandyStyleLayer(this.dashLayerRaw);d&&c.updateLayerStyle(this.dashLayer.innerId,d)}if(this.baseLayer){i!==void 0&&(this.baseLayerRaw.style.color=i);const d=n.makeHandyStyleLayer(this.baseLayerRaw);d&&c.updateLayerStyle(this.baseLayer.innerId,d)}if(this.hiddenDashLayer&&this.hiddenDashLayerRaw){a!==void 0&&(this.hiddenDashLayerRaw.style.color=a),o!==void 0&&(this.hiddenDashLayerRaw.style.gapColor=r);const d=n.makeHandyStyleLayer(this.hiddenDashLayerRaw);d&&c.updateLayerStyle(this.hiddenDashLayer.innerId,d)}if(this.hiddenBaseLayer&&this.hiddenBaseLayerRaw){l!==void 0&&(this.hiddenBaseLayerRaw.style.color=l);const d=n.makeHandyStyleLayer(this.hiddenBaseLayerRaw);d&&c.updateLayerStyle(this.hiddenBaseLayer.innerId,d)}this.modules.renderer.addRerenderEvent()}remove(){this.removed||(this.removed=!0,this.animationTickerName&&(n.stop(this.animationTickerName,this.mapState),this.animationTickerName=void 0),this.interactive&&this.modules.identifier.resetCache(),this.baseLayer&&this.modules.dynamicStyle.removeLayer(this.baseLayer.innerId),this.dashLayer&&this.modules.dynamicStyle.removeLayer(this.dashLayer.innerId),this.hiddenBaseLayer&&this.modules.dynamicStyle.removeLayer(this.hiddenBaseLayer.innerId),this.hiddenDashLayer&&this.modules.dynamicStyle.removeLayer(this.hiddenDashLayer.innerId),super.destroy())}updateShowTicker(e){n.update(e,{step:(t,i)=>{var a,r,l,c;const o=n.affineStep(((r=(a=this.options.showAnimation)==null?void 0:a.durationRange)==null?void 0:r.start)||0,((c=(l=this.options.showAnimation)==null?void 0:l.durationRange)==null?void 0:c.end)||1,i);o!==this.length&&(this.length=o,this.generate())}},this.mapState)}startShowTicker(e,t){var l,c,d;const a=((l=this.options.showAnimation)==null?void 0:l.easing)!==void 0?this.options.showAnimation.easing:"linear",r=((c=this.options.showAnimation)==null?void 0:c.duration)!==void 0?this.options.showAnimation.duration:250;n.start(e,{easing:a,animationGroup:(d=this.options.showAnimation)==null?void 0:d.animationGroup},this.mapState,0,1,r,1,{layerId:t,styleId:this.dynamicStyleId}),this.length=0}generate(){if(this.points.length<2||this.removed)return;const e=!!this.animationTickerName,{dynamicStyle:t,collector:i,tileManager:o,map:a,identifier:r}=this.modules,{tileProps:l}=n.fixedMetatile,c=Math.min(Math.floor(a.getZoom()),12),d=n.tileZoomToSize(c),_=n.splitPolylineByLength(this.points,this.distances,this.length),u=n.splitPolylineByMaxSize(_,d),h=n.create$1(),f=n.create();this.tileObjects.forEach(g=>{g.clean(this.mapState),o.removeObject(g,e)}),this.tileObjects=[];const m=[];let p=0;for(const g of u){n.reset(f);for(let S=0;S<g.length;S++)n.expandByPoint(f,g[S]);n.center(h,f);const y=n.getTileCoordsByCenterAndZoom(h,c),b=n.createTileInfo(y),M=[],T=[];let P=0;for(let S=0;S<g.length;S++)if(n.mapPointToTilePoint(h,g[S],b),M[S]=h[0],T[S]=h[1],S!==0){const C=M[S]-M[S-1],I=T[S]-T[S-1];P+=Math.sqrt(C*C+I*I)}p+=P,m.push({vertices:{x:M,y:T},tileInfo:b,distance:P})}let v=0;const x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,this.tileAttrs,n.emptyFeatureAttrs,this.interactive?"0":"");m.forEach((g,y)=>{var F,j,ee,z;const{tileInfo:b,distance:M,vertices:T}=g;if(this.tileAttrs[l.beginningIsCut]=0,this.tileAttrs[l.endingIsCut]=0,this.tileAttrs[l.previousPointX]=0,this.tileAttrs[l.previousPointY]=0,this.tileAttrs[l.nextPointX]=0,this.tileAttrs[l.nextPointY]=0,this.tileAttrs[l.componentDistanceStart]=v,v+=M,this.tileAttrs[l.objectLength]=p,y!==0){const J=u[y-1],q=J[J.length-2];n.mapPointToTilePoint(h,q,b),this.tileAttrs[l.beginningIsCut]=1,this.tileAttrs[l.previousPointX]=h[0],this.tileAttrs[l.previousPointY]=h[1]}if(y!==m.length-1){const q=u[y+1][1];n.mapPointToTilePoint(h,q,b),this.tileAttrs[l.endingIsCut]=1,this.tileAttrs[l.nextPointX]=h[0],this.tileAttrs[l.nextPointY]=h[1]}const P=Math.pow(2,b.coords[2]),S=[...this.mapState.visibleMapReplicas];if(this.isOutOfMainReplica()){const J=S[0],q=S[S.length-1];S.push(J-1,q+1)}if(S.map(J=>[b.coords[0]+J*P,b.coords[1],b.coords[2],b.coords[3]]).every(J=>!n.isTileVisible(J,this.mapState.tilesBounds,this.modules)))return;this.dashLayer&&(t.addLayer(this.dashLayer,(F=this.options.zIndex)!=null?F:kl),n.runPrecomputes(this.dashLayer,x),n.generateSafely({collector:i,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,this.dashLayer,x,b,T]})),this.baseLayer&&(t.addLayer(this.baseLayer,(j=this.options.zIndex2)!=null?j:Ul),n.runPrecomputes(this.baseLayer,x),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,this.baseLayer,x,b,T]})),this.hiddenDashLayer&&(t.addLayer(this.hiddenDashLayer,(ee=this.options.zIndex)!=null?ee:kl),n.runPrecomputes(this.hiddenDashLayer,x),n.generateSafely({collector:i,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,this.hiddenDashLayer,x,b,T]})),this.hiddenBaseLayer&&(t.addLayer(this.hiddenBaseLayer,(z=this.options.zIndex2)!=null?z:Ul),n.runPrecomputes(this.hiddenBaseLayer,x),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,this.hiddenBaseLayer,x,b,T]}));const I=i.getAccumulatedData(),E=new n.TileObject("dynamicObject",I.data,this.modules,this.mapState,b.coords,this);o.addObject(E,e),this.tileObjects.push(E),this.interactive&&this.identifyIds.push(I.identifyIds)}),this.interactive&&r.resetCache(),i.reset(),e||this.modules.renderer.addRerenderEvent()}}const Ky="#3388ff33",qy="#3388ff",Yy=3;let Wl=class extends We{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t;const i=this.options.coordinates.map(C=>{const I=C.map(E=>n.Mercator.fromGeo(E));if(I.length>1){const E=I[0],F=I[I.length-1];(E[0]!==F[0]||E[1]!==F[1])&&I.push(E)}return I});let o=[];const a=[],{dynamicStyle:r,collector:l,tileManager:c,identifier:d,layers:_}=this.modules;i.forEach(C=>{o.length&&a.push(o.length),o=o.concat(C)}),this.isGeometryOutOfMainReplica=o.some(C=>C[0]>n.HALF_WORLD_SIZE||C[0]<-n.HALF_WORLD_SIZE);const u=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-polygon-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color||Ky}});if(!u)return;r.addLayer(u,this.options.zIndex),this.fillLayerId=u.innerId;const h=n.optionsToTileAttrs({beginningIsCut:0,endingIsCut:0,db_tiers:t.tiers}),f=n.create();for(let C=0;C<o.length;C++)n.expandByPoint(f,o[C]);const m=n.getBoundsTileCoords(f),p=n.createTileInfo(m),v=[];for(let C=0;C<o.length;C++)v.push(o[C][0]),v.push(o[C][1]);const x=n.earcut(v,a),g=n.create$1(),y=[],b=[],M=[],T=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,h,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(u,T);for(let C=0;C<x.length;C+=3){for(let I=0;I<3;I++)n.mapPointToTilePoint(g,o[x[C+I]],p),y[I]=g[0],b[I]=g[1],M[I]=0;n.generateSafely({collector:l,generator:n.PolygonGenerator.generate,args:[r.getStyle().id,u,T,{x:y,y:b,cut:M},n.pixelRatioToDpi(window.devicePixelRatio),r.getStyle().rasterSets]})}if(this.options.strokeWidth!==0){const C=n.makeHandyStyleLayer({type:"line",id:`dynamic-polygon-stroke-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.strokeColor||qy,width:this.options.strokeWidth||Yy}});C&&(r.addLayer(C,this.options.zIndex),this.borderLayerId=C.innerId,n.runPrecomputes(C,T),i.forEach(I=>{const E=[],F=[];I.forEach((j,ee)=>{n.mapPointToTilePoint(g,j,p),E[ee]=g[0],F[ee]=g[1]}),n.generateSafely({collector:l,generator:n.LineGenerator.generate,args:[r.getStyle().id,C,T,p,{x:E,y:F}]})}))}const P=l.getAccumulatedData(),S=new n.TileObject("dynamicObject",P.data,this.modules,this.mapState,p.coords,this);c.addObject(S),this.tileObjects.push(S),this.interactive&&this.identifyIds.push(P.identifyIds),_.addLayer(this),l.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&d.resetCache()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}remove(){this.interactive&&this.modules.identifier.resetCache(),this.fillLayerId&&this.modules.dynamicStyle.removeLayer(this.fillLayerId),this.borderLayerId&&this.modules.dynamicStyle.removeLayer(this.borderLayerId),super.destroy()}};const Qy="#3388ff33",Jy="#3388ff",Ay=1,ex=150;let $l=class extends We{constructor(e,t){var T,P,S,C;if(super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t,t.segments&&t.segments<=0)return;const{dynamicStyle:i,collector:o,tileManager:a,identifier:r,layers:l}=this.modules,c=tx(n.Mercator.fromGeo(this.options.coordinates),n.geoToMapDistance(this.options.coordinates,this.options.radius),(T=this.options.segments)!=null?T:ex);this.isGeometryOutOfMainReplica=c.some(I=>I[0]>n.HALF_WORLD_SIZE||I[0]<-n.HALF_WORLD_SIZE);const d=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-circle-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(P=this.options.color)!=null?P:Qy,strokeWidth:(S=this.options.borderWidth)!=null?S:Ay,strokeColor:(C=this.options.borderColor)!=null?C:Jy}});if(!d)return;i.addLayer(d,this.options.zIndex),this.layerId=d.innerId;const _=n.optionsToTileAttrs({db_tiers:t.tiers}),u=n.create();for(let I=0;I<c.length;I++)n.expandByPoint(u,c[I]);const h=n.getBoundsTileCoords(u),f=n.createTileInfo(h),m=[],p=[],v=[],x=n.create$1(),g=this.options.borderWidth!==0?1:0;for(let I=0;I<c.length;I++)n.mapPointToTilePoint(x,c[I],f),m[I]=x[0],p[I]=x[1],v[I]=g;const y=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,_,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,y),n.generateSafely({collector:o,generator:n.PolygonGenerator.generate,args:[i.getStyle().id,d,y,{x:m,y:p,cut:v},n.pixelRatioToDpi(window.devicePixelRatio)]});const b=o.getAccumulatedData(),M=new n.TileObject("dynamicObject",b.data,this.modules,this.mapState,f.coords,this);a.addObject(M),this.tileObjects.push(M),this.interactive&&this.identifyIds.push(b.identifyIds),l.addLayer(this),o.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&r.resetCache()}remove(){this.interactive&&this.modules.identifier.resetCache(),this.layerId&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}};function tx(s,e,t){const i=[];if(t>0){i.push(n.fromValues(s[0]+e,s[1],s[2]));const o=Math.PI/Math.ceil(t/2);for(let a=o;a<Math.PI;a+=o){const r=e*Math.cos(a),l=e*Math.sin(a);i.push(n.fromValues(s[0]+r,s[1]+l,s[2]),n.fromValues(s[0]+r,s[1]-l,s[2]))}i.push(n.fromValues(s[0]-e,s[1],s[2]))}return i}function vs(s,e,t,i,o,a){if(o-i<=t)return;const r=i+o>>1;Xl(s,e,r,i,o,a%2),vs(s,e,t,i,r-1,a+1),vs(s,e,t,r+1,o,a+1)}function Xl(s,e,t,i,o,a){for(;o>i;){if(o-i>600){const d=o-i+1,_=t-i+1,u=Math.log(d),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(d-h)/d)*(_-d/2<0?-1:1),m=Math.max(i,Math.floor(t-_*h/d+f)),p=Math.min(o,Math.floor(t+(d-_)*h/d+f));Xl(s,e,t,m,p,a)}const r=e[2*t+a];let l=i,c=o;for(Li(s,e,i,t),e[2*o+a]>r&&Li(s,e,i,o);l<c;){for(Li(s,e,l,c),l++,c--;e[2*l+a]<r;)l++;for(;e[2*c+a]>r;)c--}e[2*i+a]===r?Li(s,e,i,c):(c++,Li(s,e,c,o)),c<=t&&(i=c+1),t<=c&&(o=c-1)}}function Li(s,e,t,i){gs(s,t,i),gs(e,2*t,2*i),gs(e,2*t+1,2*i+1)}function gs(s,e,t){const i=s[e];s[e]=s[t],s[t]=i}function ix(s,e,t,i,o,a,r){const l=[0,s.length-1,0],c=[];let d,_;for(;l.length;){const u=l.pop(),h=l.pop(),f=l.pop();if(h-f<=r){for(let v=f;v<=h;v++)d=e[2*v],_=e[2*v+1],d>=t&&d<=o&&_>=i&&_<=a&&c.push(s[v]);continue}const m=Math.floor((f+h)/2);d=e[2*m],_=e[2*m+1],d>=t&&d<=o&&_>=i&&_<=a&&c.push(s[m]);const p=(u+1)%2;(u===0?t<=d:i<=_)&&(l.push(f),l.push(m-1),l.push(p)),(u===0?o>=d:a>=_)&&(l.push(m+1),l.push(h),l.push(p))}return c}function nx(s,e,t,i,o,a){const r=[0,s.length-1,0],l=[],c=o*o;for(;r.length;){const d=r.pop(),_=r.pop(),u=r.pop();if(_-u<=a){for(let v=u;v<=_;v++)Kl(e[2*v],e[2*v+1],t,i)<=c&&l.push(s[v]);continue}const h=Math.floor((u+_)/2),f=e[2*h],m=e[2*h+1];Kl(f,m,t,i)<=c&&l.push(s[h]);const p=(d+1)%2;(d===0?t-o<=f:i-o<=m)&&(r.push(u),r.push(h-1),r.push(p)),(d===0?t+o>=f:i+o>=m)&&(r.push(h+1),r.push(_),r.push(p))}return l}function Kl(s,e,t,i){const o=s-t,a=e-i;return o*o+a*a}const ox=s=>s[0],sx=s=>s[1];class ax{constructor(e,t=ox,i=sx,o=64,a=Float64Array){this.nodeSize=o,this.points=e;const r=e.length<65536?Uint16Array:Uint32Array,l=this.ids=new r(e.length),c=this.coords=new a(e.length*2);for(let d=0;d<e.length;d++)l[d]=d,c[2*d]=t(e[d]),c[2*d+1]=i(e[d]);vs(l,c,o,0,l.length-1,0)}range(e,t,i,o){return ix(this.ids,this.coords,e,t,i,o,this.nodeSize)}within(e,t,i){return nx(this.ids,this.coords,e,t,i,this.nodeSize)}}function rx(s,e,t){const i=[],o=[],a=[],r=n.create$1();return e.forEach(({mapCoords:l,weight:c})=>{lx(r,l,t);const d=r[0],_=r[1];for(let u=0;u<6;u++)i.push(d,_),a.push(c);o.push(-1,-1,1,-1,-1,1,-1,1,1,-1,1,1)}),{vertices:s.createBuffer(new Uint16Array(i),{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:0,offset:0,normalized:!0}),widens:s.createBuffer(new Int8Array(o),{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1}),weights:s.createBuffer(new Float32Array(a),{itemSize:1,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1})}}function lx(s,e,t){s[0]=(e[0]-t.offset[0])*n.maxUint16Value/t.size,s[1]=(e[1]-t.offset[1])*n.maxUint16Value/t.size}function cx(s,e){const t=dx(s),i=_x(t,e);return new w(new Uint8Array(i),{size:[e,1]})}function dx(s){const e=new Error("The palette is not valid. The heatmap won't be rendered."),t=Object.getOwnPropertyNames(s);if(t.length===0)throw e;const i=t.map(l=>Number(l));if(i.some(l=>Number.isNaN(l)||l<0||l>1))throw e;const o={};i.forEach(l=>{if(typeof s[l]!="string")throw e;o[l]=n.handyColor(s[l])});const a=Math.min(...i),r=Math.max(...i);return a>0&&(o[0]=o[a]),r<1&&(o[1]=o[r]),o}function _x(s,e){const t=Object.keys(s).map(r=>Number(r)).sort((r,l)=>r-l);let i=0;const o=[],a=e-1;for(let r=0;r<e;r++){const l=r/a;l>t[i+1]&&i++;const c=t[i],d=t[i+1],_=d-c,h=(l-c)/_;for(let f=0;f<4;f++)o[r*4+f]=hx(s[c].value[f],s[d].value[f],h)}return o.map(r=>Math.round(r))}function ux(s,e){return s.every((t,i)=>t===e[i])}function hx(s,e,t){return s*(1-t)+e*t}const fx=256,mx=.5,px=3,vx=10,gx=1,yx=1,xx={0:"rgba(89, 0, 89, 0)",.25:"rgba(0, 0, 89, 0.78)",.5:"rgba(0, 198, 68, 1)",.7:"rgba(198, 186, 0, 1)",.8:"rgba(249, 152, 0, 1)",1:"rgba(200, 0, 0, 1)"};class bx extends We{constructor(e,t={}){super(e,{interactive:!1}),this.offscreenTextureIndex=-1,this.fillBuffers=m=>{if(!this.tree)return;const p=n.tetragonBounds(this.mapState.tilesBounds),v=n.getBoundsTileCoords(p);if(this.tileCoords&&ux(v,this.tileCoords))return;this.resetBuffers(),this.tileCoords=v;const x=n.tileZoomToSize(v[2]),g=n.tileCoordsToMapPoint(v);n.fromTranslationScale(this.matrix,g,n.fromValues(x,x,n.tileHeight));const y=this.tree.range(g[0],g[1],g[0]+x,g[1]+x).map(M=>this.points[M]),b=n.createTileInfo(v);this.buffers=rx(this.modules.renderer,y,b),this.vertexCount=y.length*6,this.vao=new H(m,{a_vec2_position:this.buffers.vertices,a_vec2_widen:this.buffers.widens,a_float_weight:this.buffers.weights})},this.resizeFrameBuffer=()=>{this.frameBuffer.setSize([Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)]),this.modules.renderer.bindRenderTarget(this.frameBuffer),this.modules.renderer.bindRenderTarget(null);const m=this.frameBuffer.getTexture();m?this.modules.imageManager.updatePreparedTexture(this.offscreenTextureIndex,m):n.log("Can't update a non-prepared texture"),this.heatmapNeedRerender=!0,this.modules.renderer.addRerenderEvent()};const{downscale:i,palette:o,points:a,minZoom:r,maxZoom:l,zIndex:c,pointRadius:d,intensity:_,opacity:u}=t;this.rampTextureIndex=this.modules.imageManager.addPreparedTexture(cx(o!=null?o:xx,fx)),this.downscale=i!=null?i:yx,this.frameBuffer=new be({size:[Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});const h=this.frameBuffer.getTexture();h?this.offscreenTextureIndex=this.modules.imageManager.addPreparedTexture(h):n.log("Can't add a non-prepared texture."),this.points=[],this.vertexCount=0,this.isDestroyed=!1,this.heatmapNeedRerender=!1,this.matrix=n.create$2(),this.mvpMatrix=n.create$2(),this.viewDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"}]),this.sizeDiffer=new n.Differ([{path:"size",type:"vec2"}]),this.throttledFillBuffer=n.throttle(this.fillBuffers,50);const f=n.makeHandyStyleLayer({type:"heatmap",id:`dynamic-heatmap-${this.uniqId}`,minzoom:r,maxzoom:l,style:{opacity:u!=null?u:mx,intensity:_!=null?_:px,radius:d!=null?d:vx}});if(!f)throw new Error("There is no correct style layer for heatmap");this.layer=f,this.modules.dynamicStyle.addLayer(f,c),a&&this.setPoints(a)}isOutOfMainReplica(){return!1}setPoints(e){if(!this.isDestroyed){if(this.points=e.map(({coordinates:t,weight:i})=>({mapCoords:n.Mercator.fromGeo(t),weight:i!=null?i:gx})),this.tree=new ax(this.points,t=>t.mapCoords[0],t=>t.mapCoords[1]),this.tileCoords=void 0,!this.tileObjects.length){const{layers:t,collector:i,dynamicStyle:o,tileManager:a}=this.modules;n.generateSafely({collector:i,generator:n.HeatmapGenerator.generateTexture,args:[o.getStyle().id,this.layer,this.offscreenTextureIndex,this.rampTextureIndex]});const r=i.getAccumulatedData(),l=new n.TileObject("dynamicObject",r.data,this.modules,this.mapState);a.addObject(l),this.tileObjects.push(l),t.addLayer(this),i.reset()}this.modules.renderer.addRerenderEvent(),this.heatmapNeedRerender=!0}}update(){super.update();const e=this.modules.renderer.getShaderProgram("heatmap",this.modules.renderer.commonShaderDefines);if(this.sizeDiffer.check(this.mapState)&&this.resizeFrameBuffer(),!this.heatmapNeedRerender&&!this.viewDiffer.check(this.mapState)&&!this.modules.renderer.isNeedRerender()||!this.tree)return;const{zoom:t,styleZoom:i,styleState:o}=this.mapState;if(this.throttledFillBuffer(e),!this.vao||!this.buffers||!this.tree||!this.tileCoords)return;const a=n.makeBinderContext(i,o,[]),r=n.resolveNumber(this.layer.style.radius,a),l=n.resolveNumber(this.layer.style.intensity,a),c=n.tileSizeZpt*Math.pow(2,t-this.tileCoords[2])*window.devicePixelRatio;this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Zs(e,this.mapState,this.modules),this.modules.renderer.bindShaderProgram(e,{u_mat4_mvp:n.mul$1(this.mvpMatrix,this.modules.camera.viewProjectionMatrix,this.matrix),u_mat4_model:this.matrix,u_float_radius:r*window.devicePixelRatio,u_float_intensity:l,u_float_tile_to_pixel_ratio:1/c}),this.modules.renderer.bindVao(this.vao),this.modules.renderer.setViewport(0,0,Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)),this.modules.renderer.bindRenderTarget(this.frameBuffer),this.modules.renderer.clearWithColor([0,0,0,0],!1),this.modules.renderer.applyGpuState(ga),this.modules.renderer.drawTriangles(0,this.vertexCount),this.modules.renderer.bindRenderTarget(null),this.heatmapNeedRerender=!1}destroy(){if(this.isDestroyed)return;super.destroy(),this.points=[],this.tree=void 0,this.isDestroyed=!0,this.resetBuffers(),this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.frameBuffer.remove();const{imageManager:e}=this.modules;e.deleteTexture(this.offscreenTextureIndex),e.deleteTexture(this.rampTextureIndex)}resetBuffers(){this.buffers&&(Object.values(this.buffers).forEach(e=>e.remove()),this.buffers=void 0),this.vao&&(this.vao.remove(),this.vao=void 0)}}const wx="#000000",Sx=0,Tx="#ffffff",Mx=0,ql=[0,0],Ex=0,Ix=[0,0,0,0],ys=-1;class xs extends We{constructor(e,t,i){var E,F,j,ee,z,J,q,Te,Ue,De,Ge,Ct,bt;super(e,{interactive:(E=t.interactive)!=null?E:!1},i),this.hovered=!1,this.lastLabelingRevision=ys,this.status="visible",this.labelingStatus=0,this.options=t,this.labelKey=`point-label-${this.uniqId}`;const o=(F=t.font)!=null?F:n.DEFAULT_FONT,a=(j=t.fontSize)!=null?j:n.fonts.baseSize,r=(ee=t.letterSpacing)!=null?ee:Mx,l=(z=t.lineHeight)!=null?z:n.fonts.baseLineHeight,c=[(q=(J=this.options.offset)==null?void 0:J[0])!=null?q:ql[0],(Ue=(Te=this.options.offset)==null?void 0:Te[1])!=null?Ue:ql[1]],d=n.makeHandyStyleLayer({type:"point",id:`dynamic-pointLabel-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,interactive:this.interactive,style:{textFont:o,textFontSize:a,textColor:(De=t.color)!=null?De:wx,textHaloWidth:(Ge=t.haloRadius)!=null?Ge:Sx,textHaloColor:(Ct=t.haloColor)!=null?Ct:Tx,textLetterSpacing:r,textLineHeight:l,textOffset:c,allowElevation:!0}}),_=n.Mercator.fromGeo(this.options.coordinates);if(this.position={userValue:_,normalizedValue:n.normalizeMapPoint(_)},!d)return;const{dynamicStyle:u,collector:h,assetManager:f,styleManager:m,tileManager:p,layers:v,defaultSource:x}=this.modules,g=(bt=this.options.zIndex)!=null?bt:Ex;u.addLayer(d,g);const y=n.optionsToTileAttrs({db_label:this.options.text}),b=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),M={x:[0],y:[0]},T=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,y,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,T),n.generateSafely({collector:h,generator:n.preLabelingPoint,args:[u.getStyle(),d,T,n.fixedMetatile,n.LATEST_TILE_VERSION,b,x.getId(),M,n.pixelRatioToDpi(window.devicePixelRatio)]});const P=h.getAccumulatedData();if(!P.labels.length)return;const S=[{metatileHash:-1,labels:P.labels,styleId:u.getStyle().id}],C=n.unpackPreLabelingResult(S,n.LabelSource.DynamicObject,m,this.mapState.styleState,this.mapState.styleZoom);if(C.length!==1)return;const I=C[0];n.rtlAdapterPromise.then(()=>{var Me;I.label=(Me=n.processRTLTextIfNeeded(I.label))!=null?Me:"",I.updateRanges()}).then(()=>Promise.all(I.ranges.map(Me=>f.loadFont(o,Me)))).then(()=>{if(this.status==="destroyed")return;I.textMetrics=n.getTextMetrics(I.label,r,f.getFontGlyphs(o));const Me=Cx(t.anchor),Ee=a/n.fonts.baseSize,Lt=a*l*I.textMetrics.lines.length,Pt=Ee*I.textMetrics.maxWidth,Bt=[-Pt*(Me[0]-.5),-Lt*(Me[1]-.5)],[Ze,Kn]=c,jt=[Ze+Bt[0],Kn+Bt[1]],Bi=n.Mercator.toGeo(this.position.userValue),zi=n.Ecef.fromGeo(Bi);n.generateSafely({collector:h,generator:n.generateTextElement,args:[I,"",1,I.textMetrics,[0,0,0],zi,0,jt,d,u.getStyle().fontNameToIndex[o],window.devicePixelRatio]});const iw=h.getAccumulatedData(),Ms=new n.TileObject("dynamicObject",iw.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);bs(Ms,this.position.userValue[2]),v.addLayer(this),this.tileObjects.push(Ms),this.interactive&&(this.identifyIds.push(P.identifyIds),this.modules.identifier.resetCache()),h.reset(),this.options.labeling&&this.options.labeling.type!=="none"?(this.labelBox={id:this.uniqId,width:Pt,height:Lt,position:this.position.normalizedValue,offset:[jt[0]-Me[0]*Pt,jt[1]-Me[1]*Lt],labelingGroup:"pointLabel"},this.addLabelToLabeler(),this.update()):this.status==="visible"&&p.addObject(Ms),this.modules.renderer.addRerenderEvent(),this.initImageIfNeed(I,Pt,Lt,c,Bt)})}hide(){this.status==="visible"&&(this.status="hidden",this.removeLabelFromLabeler(),this.removeTilesFromMap(),this.labelingStatus=1)}show(){this.status==="hidden"&&(this.status="visible",this.labelBox||this.addTilesToMap(),this.labelingStatus=0,this.addLabelToLabeler(),this.update())}isOutOfMainReplica(){return!1}remove(){this.status!=="destroyed"&&(this.interactive&&this.modules.identifier.resetCache(),this.removeLabelFromLabeler(),super.destroy(),this.status="destroyed")}setCoordinates(e){if(this.status==="destroyed")return;const t=n.Mercator.fromGeo(e);this.position={userValue:t,normalizedValue:n.normalizeMapPoint(t)},this.tileObjects.forEach(i=>{i.setTileCoords(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState),bs(i,this.position.userValue[2])}),this.labelBox&&(this.labelBox.position=this.position.normalizedValue,this.addLabelToLabeler()),this.tileObjects.length!==0&&this.status==="visible"&&this.modules.renderer.addRerenderEvent()}getCoordinates(){return n.Mercator.toGeo(this.position.userValue)}update(){if(this.status==="destroyed"||(super.update(),this.status!=="visible"||!this.labelBox||this.lastLabelingRevision===this.modules.labeler.getLabelingRevision()))return;this.lastLabelingRevision=this.modules.labeler.getLabelingRevision();const e=this.modules.labeler.isLabelBoxSurvived(this.uniqId),t=this.labelingStatus;let i=n.LabelingAnimation.none;switch(this.labelingStatus){case 0:e?(this.addTilesToMap(),i=n.LabelingAnimation.none,this.labelingStatus=3):this.labelingStatus=1;break;case 1:e&&(this.addTilesToMap(),i=n.LabelingAnimation.fadeIn,this.labelingStatus=2);break;case 2:e?this.labelingStatus=3:(this.labelingStatus=4,i=n.LabelingAnimation.fadeOut);break;case 3:e||(i=n.LabelingAnimation.fadeOut,this.labelingStatus=4);break;case 4:e?(i=n.LabelingAnimation.fadeIn,this.labelingStatus=2):(this.removeTilesFromMap(),this.labelingStatus=1);break}t!==this.labelingStatus&&this.labelingStatus!==1&&this.tileObjects.forEach(o=>o.children.forEach(a=>{a.attributes.animDirection=i}))}initImageIfNeed(e,t,i,o,a){return K(this,null,function*(){var E,F;if(!this.options.image)return;const{imageCache:r,dynamicStyle:l,collector:c,tileManager:d}=this.modules,_=window.devicePixelRatio,u=yield r.getRasterSet(this.options.image.url,void 0,this.options.image.size,[0,0]);if(!u||this.status==="destroyed")return;const h=u.rasters[0];l.appendRasterSet(u,n.getStaticIconRasterSetKey(this.options.image.url,0,0));const[f,m,p,v]=this.options.image.padding||Ix,x=(t+v+m)*_,g=(i+f+p)*_,y=((m-v)/2+o[0]+a[0])*_,b=((p-f)/2+o[1]+a[1])*_,M=(E=this.options.image.stretchX)==null?void 0:E.map(([j,ee])=>[j*_,ee*_]),T=(F=this.options.image.stretchY)==null?void 0:F.map(([j,ee])=>[j*_,ee*_]),P=n.Mercator.toGeo(this.position.userValue),S=n.Ecef.fromGeo(P);n.generateSafely({collector:c,generator:n.generateIconElement,args:[e,"",[0,0,0],S,0,h,x,g,y,b,window.devicePixelRatio,M,T]});const C=c.getAccumulatedData();c.reset();const I=new n.TileObject("dynamicObject",C.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue));bs(I,this.position.userValue[2]),this.tileObjects.push(I),this.status!=="hidden"&&!this.labelBox&&d.addObject(I),this.labelBox&&(this.labelBox.height=i+f+p,this.labelBox.width=t+v+m,this.labelBox.offset[0]-=v,this.labelBox.offset[1]-=f,this.addLabelToLabeler(),this.labelingStatus!==1&&this.labelingStatus!==0&&(d.addObject(I),this.mapState.needRerender=!0),this.lastLabelingRevision=ys)})}addTilesToMap(){this.tileObjects.forEach(e=>{this.modules.tileManager.addObject(e)})}removeTilesFromMap(){this.tileObjects.forEach(e=>{this.modules.tileManager.removeObject(e)})}addLabelToLabeler(){this.removeLabelFromLabeler(),this.labelBox&&(this.modules.labeler.addLabelBox(this.labelKey,this.labelBox),this.lastLabelingRevision=ys)}removeLabelFromLabeler(){this.labelBox&&this.modules.labeler.removeLabels(this.labelKey)}}function Cx(s){return[s&&s[0]!==void 0?n.clamp(s[0],0,1):.5,s&&s[1]!==void 0?n.clamp(s[1],0,1):.5]}function bs(s,e){s.modelMatrices.forEach(t=>{t[14]=e})}const Lx=18,Px=[.5,.5],Bx=[0,18],zx=0,Rx=0;let Yl=class extends Ls{constructor(e,t){super(e,t,t.draggable),this.visible=!0,this.map=e,this.options=t;const{coordinates:i,size:o,zIndex:a,minZoom:r,maxZoom:l,hoverIcon:c,hoverSize:d,hoverAnchor:_,label:u,rotation:h,opacity:f,hoverOpacity:m}=t;this.status="normal";const p=n.Mercator.fromGeo(i);this.position={userValue:p,normalizedValue:n.normalizeMapPoint(p)},this.rotation=n.degToRad(h!=null?h:Rx),this.zIndex=a!==void 0?a:zx,this.minZoom=r!=null?r:-1/0,this.maxZoom=l!=null?l:1/0;const v=t.icon!==void 0?t.icon:n.defaultMarkerIcon,x=t.icon!==void 0?t.anchor:n.defaultMarkerAnchor;this.on("mouseover",this.switchToHoveredStyle),this.on("mouseout",this.switchToNormalStyle),this.modules.layers.addLayer(this),this.setIconInternal({icon:v,anchor:x,size:o,opacity:f}).then(()=>{c!==void 0&&this.setHoverIconInternal({icon:c,anchor:_,size:d,opacity:m})}),this.setLabel(u)}destroy(){var e;this.status!=="destroyed"&&(this.status="destroyed",(e=this.label)==null||e.remove(),this.interactive&&this.modules.identifier.resetCache(),this.off("mouseover",this.switchToHoveredStyle),this.off("mouseout",this.switchToNormalStyle),super.destroy())}update(){if(this.mapState.dpiChanged){const{icon:e,hoverIcon:t}=this.options;e&&this.setIconInternal(B({icon:e},this.options)),e&&t&&this.setHoverIconInternal(B({icon:e,hoverIcon:t},this.options))}if(this.mapState.globeMode){const{tileManager:e}=this.modules,t=this.modules.camera.ecef.canSee(this.options.coordinates);this.visible&&!t?this.tileObjects.forEach(i=>e.removeObject(i)):!this.visible&&t&&this.tileObjects.forEach(i=>e.addObject(i)),this.visible=t}}isOutOfMainReplica(){return!1}setRotation(e){if(this.status==="destroyed")return;const t=n.degToRad(e);t!==this.rotation&&(this.rotation=t,this.normalStateData&&(this.normalStateData.styleLayer.style.iconRotation=this.rotation,this.modules.renderer.addRerenderEvent()),this.hoverStateData&&(this.hoverStateData.styleLayer.style.iconRotation=this.rotation,this.modules.renderer.addRerenderEvent()))}getRotation(){return n.radToDeg(this.rotation)}setIcon(e){this.status!=="destroyed"&&(Ql({icon:this.options.icon,anchor:this.options.anchor,size:this.options.size,opacity:this.options.opacity},e)||(this.options.icon=e.icon,this.options.anchor=e.anchor,this.options.size=e.size,this.options.opacity=e.opacity,this.setIconInternal(e)))}setHoverIcon(e){if(this.status!=="destroyed"){if(!e){this.status==="hover"&&this.switchToNormalStyle(),this.hoverStateData&&(n.excludeItemFromArray(this.tileObjects,this.hoverStateData.tileObject),n.excludeItemFromArray(this.identifyIds,this.hoverStateData.identifyIds),this.hoverStateData.tileObject.clean(this.mapState),this.hoverStateData=void 0);return}Ql({icon:this.options.hoverIcon,anchor:this.options.hoverAnchor,size:this.options.hoverSize,opacity:this.options.hoverOpacity},e)||(this.options.hoverIcon=e.icon,this.options.hoverAnchor=e.anchor,this.options.hoverSize=e.size,this.options.hoverOpacity=e.opacity,this.setHoverIconInternal(e))}}setLabel(e){var t,i,o,a,r;this.status!=="destroyed"&&((t=this.label)==null||t.remove(),e&&(this.label=new xs(this.map,de(B({coordinates:this.getCoordinates()},e),{minZoom:Math.max((i=e.minZoom)!=null?i:this.minZoom,this.minZoom),maxZoom:Math.min((o=e.maxZoom)!=null?o:this.maxZoom,this.maxZoom),fontSize:(a=e.fontSize)!=null?a:Lx,anchor:e.anchor||Px,offset:e.offset||Bx,zIndex:(r=e.zIndex)!=null?r:this.zIndex+1e-5,interactive:this.interactive}),this)))}setCoordinates(e){var t;this.setPosition(n.Mercator.fromGeo(e)),(t=this.label)==null||t.setCoordinates(e)}getCoordinates(){return n.Mercator.toGeo(this.getPosition())}show(){var e;this.status==="hidden"&&((e=this.label)==null||e.show(),this.normalStateData&&(this.modules.tileManager.addObject(this.normalStateData.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),this.status="normal")}hide(){var t,i,o;if(this.status==="destroyed"||this.status==="hidden")return;(t=this.label)==null||t.hide();const e=this.status==="normal"?(i=this.normalStateData)==null?void 0:i.tileObject:(o=this.hoverStateData)==null?void 0:o.tileObject;e&&(this.modules.tileManager.removeObject(e),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),this.status="hidden"}setPosition(e){this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},this.tileObjects.length&&(this.tileObjects.forEach(t=>{t.setTileCoords(n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this.mapState)}),this.status!=="hidden"&&(this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()))}getPosition(){return this.position.userValue}contains(e){if(!this.normalStateData)return!1;const{hoverStateData:t,normalStateData:i}=this,o=t!==void 0?t.size:i.size,a=t!==void 0?t.anchor:i.anchor,r=this.modules.camera.flat.project(this.position.normalizedValue),l=r[0]-o[0]*a[0],c=r[0]+o[0]*(1-a[0]),d=r[1]-o[1]*a[1],_=r[1]+o[1]*(1-a[1]);return e[0]>l&&e[0]<c&&e[1]>d&&e[1]<_}switchToHoveredStyle(){if(this.status==="normal"&&this.hoverStateData&&this.normalStateData){const{tileManager:e}=this.modules;e.removeObject(this.normalStateData.tileObject),e.addObject(this.hoverStateData.tileObject),this.status="hover",this.modules.renderer.addRerenderEvent()}this.label&&(this.label.hovered=!0,this.modules.renderer.addRerenderEvent())}switchToNormalStyle(){if(this.status==="hover"&&this.normalStateData&&this.hoverStateData){const{tileManager:e}=this.modules;e.removeObject(this.hoverStateData.tileObject),e.addObject(this.normalStateData.tileObject),this.status="normal",this.modules.renderer.addRerenderEvent()}this.label&&(this.label.hovered=!1,this.modules.renderer.addRerenderEvent())}getMarkerStateData(e,{icon:t,anchor:i,size:o,opacity:a}){const{zIndex:r,position:l}=this,{collector:c,dynamicStyle:d,styleManager:_,defaultSource:u}=this.modules,h=n.optionsToTileAttrs({dpi:window.devicePixelRatio*96}),f=n.mapPointTo32ZoomTileCoords(l.normalizedValue),m=typeof this.position.userValue[2]=="number"?this.position.userValue[2]:0,p=n.makeHandyStyleLayer({type:"point",id:`dynamic-marker-${this.uniqId}`,minzoom:this.minZoom,maxzoom:this.maxZoom,style:{iconImage:t,iconAnchor:i,iconRotation:this.rotation,iconOpacity:a,elevation:m}});if(!p)throw new Error(`Marker with icon ${t} was created with null style layer`);const v=n.resolveSimpleLiteralExpression(p.style.iconAnchor);d.addLayer(p,r),d.appendRasterSet(e,n.getStaticIconRasterSetKey(t,v[0],v[1]));const x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,h,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(p,x),n.generateSafely({collector:c,generator:n.preLabelingPoint,args:[d.getStyle(),p,x,n.fixedMetatile,n.LATEST_TILE_VERSION,f,u.getId(),{x:[0],y:[0]},n.pixelRatioToDpi(window.devicePixelRatio)]});const{identifyIds:g,labels:y}=c.getAccumulatedData();if(!y.length)throw new Error(`Marker with icon ${t} was created with empty labels`);const b=[{metatileHash:-1,labels:y,styleId:d.getStyle().id}],M=n.unpackPreLabelingResult(b,n.LabelSource.DynamicObject,_,this.mapState.styleState,this.mapState.styleZoom);if(M.length!==1)throw new Error(`Marker with icon ${t} has empty unpacked labels`);const T=M[0],P=n.Mercator.toGeo(this.position.userValue),S=n.Ecef.fromGeo(P);n.generateNotStretchableIconElement(c,T,"",[0,0,m],S,0,e.rasters[0],window.devicePixelRatio);const{data:C}=c.getAccumulatedData();c.reset();const I=new n.TileObject("dynamicObject",C,this.modules,this.mapState,f,this);return{styleLayer:p,tileObject:I,identifyIds:g,icon:t,anchor:[e.rasters[0].anchorX,e.rasters[0].anchorY],size:o||[e.rasters[0].w/window.devicePixelRatio,e.rasters[0].h/window.devicePixelRatio]}}setIconInternal(e){return K(this,null,function*(){return this.modules.imageCache.getRasterSet(e.icon,void 0,e.size,e.anchor).then(t=>{if(this.status==="destroyed"||!t)return;const i=this.normalStateData,o=this.getMarkerStateData(t,e);this.status==="normal"&&(i&&this.modules.tileManager.removeObject(i.tileObject),this.modules.tileManager.addObject(o.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),i&&(n.excludeItemFromArray(this.tileObjects,i.tileObject),n.excludeItemFromArray(this.identifyIds,i.identifyIds),i.tileObject.clean(this.mapState)),this.tileObjects.push(o.tileObject),this.interactive&&this.identifyIds.push(o.identifyIds),this.normalStateData=o})})}setHoverIconInternal(e){return K(this,null,function*(){return this.modules.imageCache.getRasterSet(e.icon,void 0,e.size,e.anchor).then(t=>{if(this.status==="destroyed"||!t)return;const i=this.hoverStateData,o=this.getMarkerStateData(t,e);this.status==="hover"&&(i&&this.modules.tileManager.removeObject(i.tileObject),this.modules.tileManager.addObject(o.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),i&&(n.excludeItemFromArray(this.tileObjects,i.tileObject),n.excludeItemFromArray(this.identifyIds,i.identifyIds),i.tileObject.clean(this.mapState)),this.tileObjects.push(o.tileObject),this.interactive&&this.identifyIds.push(o.identifyIds),this.hoverStateData=o})})}};function Ql(s,e){var t,i,o,a,r,l,c,d,_,u;return!(s.icon!==e.icon||((t=s.anchor)==null?void 0:t[0])!==((i=e.anchor)==null?void 0:i[0])||((o=s.anchor)==null?void 0:o[1])!==((a=e.anchor)==null?void 0:a[1])||((r=s.size)==null?void 0:r[0])!==((l=e.size)==null?void 0:l[0])||((c=s.size)==null?void 0:c[1])!==((d=e.size)==null?void 0:d[1])||((_=s.opacity)==null?void 0:_.toString())!==((u=e.opacity)==null?void 0:u.toString()))}const Fx=n.inferGeneratorType({symbol:"polygon",sinks:{fill:{stride:8,binder:(s,e)=>{s.views.position=new Uint16Array(e),s.views.localID=new Uint32Array(e,4)},packObjectAttributes(s,e,t){return n.createObjectAttributesArray([s,e.innerId],e,t)},unpackObjectAttributes(s){return{styleId:s[0],layerId:s[1],tileData:s.slice(2)}}}},generate(s,e,t,i,o){const a=o.x,r=o.y,l=s.idIndexer.getIndex(i,e,t),c=n.resolveExpression(t.ignoreTier,i)?null:i.tileAttrs[i.tileProps.db_tiers],d=s.getBucket(t.type,"fill",n.PolygonGenerator.sinks.fill.packObjectAttributes(e,t,c,"","",i),n.PolygonGenerator.sinks.fill.binder);let _=d.elements.offset;Dx(d.indices,_,0,1,2,2,1,3),Hn(d,_++,a[0],r[0],l),Hn(d,_++,a[1],r[1],l),Hn(d,_++,a[2],r[2],l),Hn(d,_++,a[3],r[3],l),d.elements.offset=_}});function Hn(s,e,t,i,o){const a=e*4;s.views.position[a]=n.tileCoordOffset+t,s.views.position[a+1]=n.tileCoordOffset+i;const r=e*2;s.views.localID[r]=o}function Dx(s,e,t,i,o,a,r,l){const c=s.buffer,d=s.offset;c[d]=e+t,c[d+1]=e+i,c[d+2]=e+o,c[d+3]=e+a,c[d+4]=e+r,c[d+5]=e+l,s.offset=d+6}const Ox="#0085a0";class Nx extends We{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i,collector:o,tileManager:a,identifier:r,layers:l}=this.modules;this.options=t,this.points=[];const c=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-polygon-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color||Ox}});if(!c)return;i.addLayer(c,this.options.zIndex),this.layerId=c.innerId;const d=n.optionsToTileAttrs({db_tiers:t.tiers});this.points=kx(n.Mercator.fromGeo(this.options.center),n.geoToMapDistance(this.options.center,this.options.width),n.geoToMapDistance(this.options.center,this.options.height)),this.isGeometryOutOfMainReplica=this.points.some(y=>y[0]>n.HALF_WORLD_SIZE||y[0]<-n.HALF_WORLD_SIZE);const _=n.create();for(let y=0;y<this.points.length;y++)n.expandByPoint(_,this.points[y]);const u=n.getBoundsTileCoords(_),h=n.createTileInfo(u),f=[],m=[],p=n.create$1();for(let y=0;y<this.points.length;y++)n.mapPointToTilePoint(p,this.points[y],h),f[y]=p[0],m[y]=p[1];const v=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,d,n.emptyFeatureAttrs,this.options.interactive?"0":"");n.generateSafely({collector:o,generator:Fx.generate,args:[i.getStyle().id,c,v,{x:f,y:m}]});const x=o.getAccumulatedData(),g=new n.TileObject("dynamicObject",x.data,this.modules,this.mapState,u,this);a.addObject(g),this.tileObjects.push(g),this.options.interactive&&this.identifyIds.push(x.identifyIds),l.addLayer(this),o.reset(),this.modules.renderer.addRerenderEvent(),this.options.interactive&&r.resetCache()}destroy(){this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),this.options.interactive&&this.modules&&this.modules.identifier.resetCache(),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}}function kx(s,e,t){const i=e/2,o=t/2,a=s[0],r=s[1],l=s[2];return[[a-i,r-o,l],[a+i,r-o,l],[a-i,r+o,l],[a+i,r+o,l]]}let Jl=class extends We{constructor(e,t){super(e,{interactive:!1}),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i}=this.modules;this.options=de(B({},t),{image:{url:t.image.url}}),this.points=[],this.styleLayer=n.makeHandyStyleLayer({type:"raster",id:`dynamic-raster-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{opacity:this.options.opacity}}),this.styleLayer&&(i.addLayer(this.styleLayer,this.options.zIndex),this.layerId=this.styleLayer.innerId,this.modules.imageManager.loadTexture(this.options.image.url,{skipAtlasSizeChecking:!0}).then(o=>{this.textureIndex=o,this.generate()}))}destroy(){this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}updateImage(e){const{url:t,bounds:i}=e;return!t&&!i?Promise.resolve():(t&&(this.options.image.url=t),i&&(this.options.bounds=i),(t?this.modules.imageManager.loadTexture(t,{skipAtlasSizeChecking:!0}):Promise.resolve(this.textureIndex)).then(a=>{this.textureIndex=a,this.clean(),this.generate()}))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}generate(){var m;if(!this.styleLayer||this.textureIndex===void 0)return;const{collector:e,dynamicStyle:t,tileManager:i,layers:o}=this.modules;this.points=Ux(this.options.bounds),this.isGeometryOutOfMainReplica=this.points.some(p=>p[0]>n.HALF_WORLD_SIZE||p[0]<-n.HALF_WORLD_SIZE);const a=n.create();for(let p=0;p<this.points.length;p++)n.expandByPoint(a,this.points[p]);const r=n.getBoundsTileCoords(a),l=n.createTileInfo(r),c=[],d=[],_=n.create$1();for(let p=0;p<this.points.length;p++)n.mapPointToTilePoint(_,this.points[p],l),c[p]=_[0],d[p]=_[1];const u=n.makeGeneratorContext(this.mapState.styleState,{},n.fixedTileProps,[],n.emptyFeatureAttrs);n.generateSafely({collector:e,generator:n.RasterGenerator.generate,args:[{x:c,y:d},t.getStyle().id,u,this.styleLayer,this.textureIndex,(m=this.options.tiers)!=null?m:null]});const h=e.getAccumulatedData(),f=new n.TileObject("dynamicObject",h.data,this.modules,this.mapState,r,this);i.addObject(f),this.tileObjects.push(f),o.addLayer(this),e.reset(),this.modules.renderer.addRerenderEvent()}clean(){const e=this.tileObjects[0];e&&(e.clean(this.mapState),this.modules.tileManager.removeObject(e),this.modules.layers.removeLayer(this),this.tileObjects=[])}};function Ux(s){const{min:e,max:t}=n.fromGeo(s);return[e,[t[0],e[1]],[e[0],t[1]],t]}class Gx{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="raster",this.textureIndices={},this.tileLoader=new n.BaseTileLoader("arrayBuffer"),this.attributes={},this.tiles=new Map,this.sourceAttrs=i.attributes||{},this.url=o=>{const[a,r,l]=n.tileCoordsToOSM(o),{min:c,max:d}=n.getTileBounds(o),_={southWest:[c[0],c[1]].map(u=>u/n.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER),northEast:[d[0],d[1]].map(u=>u/n.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER)};return this.options.url(a,r,l,_)}}deleteTextures(){for(const e in this.textureIndices)this.modules.imageManager.deleteTexture(this.textureIndices[e]);this.textureIndices={}}abortTileFetches(e){this.tileLoader.abortRequests(e.map(n.coordsToKey))}deleteTiles(e){for(const t of e){const i=n.coordsToKey(t),o=this.textureIndices[i];isNaN(o)||this.modules.imageManager.deleteTexture(o),this.tiles.delete(i)}}fetchTiles(e){return e.map(t=>this.fetchTile(t))}fetchTile(e){const t=n.coordsToKey(e),i=this.url(e);return this.tileLoader.fetch(e,()=>i).then(o=>{if(o.error){const r=this.modules.sourceStorage.getSourceById(this.id);(r==null?void 0:r.type)==="raster"&&this.modules.map.emit("error",{type:"rasterTileLoadError",tileCoords:n.tileCoordsToOSM(e),tileUrl:i,source:r,responseMessage:o.error.message,responseStatus:o.error.status})}return o.rejected||this.tiles.set(t,o.data),[{regionId:0,metatileHash:-1}]})}generateTile(e,t){return K(this,null,function*(){const i=[],o=[],a=this.modules.styleManager.getStyle(e.handyStyleId),r=n.coordsToKey(t),l=this.tiles.get(r);if(!l||!a)return Promise.resolve({results:i,transferable:o});const c=yield this.modules.imageManager.addTexture(l,{imagePadding:0,size:[n.tileSizeZpt,n.tileSizeZpt]});if(c===void 0)return Promise.resolve({results:i,transferable:o});this.textureIndices[r]=c;const d=[],_=[],u=n.create$1(),h=Hx(n.tileCoordsToMapPoint(t),n.tileZoomToSize(t[2])),f=n.createTileInfo(t);for(let v=0;v<h.length;v++)n.mapPointToTilePoint(u,h[v],f),d[v]=u[0],_[v]=u[1];const m=n.makeGeneratorContext(e.styleState,this.sourceAttrs,n.fixedTileProps,[],n.emptyFeatureAttrs);a.layers.filter(v=>v.type==="raster"&&n.resolveExpression(v.filter,m)).forEach(v=>{n.runPrecomputes(v,m),n.generateSafely({collector:this.modules.collector,generator:n.RasterGenerator.generate,args:[{x:d,y:_},a.id,m,v,c,null]})});const p=this.modules.collector.getAccumulatedData();return i.push({regionId:0,metatileHash:0,styleId:a.id,collectorOutput:p}),o.push(...p.transferable),this.modules.collector.reset(),Promise.resolve({results:i,transferable:o})})}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}destroy(){this.tileLoader.destroy()}}function Hx(s,e){const t=s[0],i=s[1],o=s[2];return[[t,i,o],[t+e,i,o],[t,i+e,o],[t+e,i+e,o]]}let Al=class{constructor(e,t,i){var r,l;this.type="raster",this.id=n.sourceUuid(),this.modules=e.modules,this.source=new Gx(this.id,this.modules,t);const o=(r=t.minZoom)!=null?r:n.MAP_DEFAULTS.minZoom,a=(l=t.maxZoom)!=null?l:n.MAP_DEFAULTS.maxZoom;this.layer=new n.TileLayer(o,a,o,a,this.modules,e.state,this.source),this.modules.tileManager.addTileLayer(this.layer),this.modules.sourceStorage.addSource(this),this.mapglApiSource=i}destroy(){this.source.deleteTextures(),this.modules.tileManager.removeTileLayer(this.layer),this.modules.sourceStorage.removeSource(this.getId()),this.layer.destroy()}getAttributes(){return this.source.getAttributes()}getZoomDirection(){return this.layer.getZoomDirection()}getId(){return this.source.id}setAttributes(e){this.source.setAttributes(e),this.layer.redraw()}isIdentifiedAsDefault(){return!1}};const Vx=0;class Zx extends We{constructor(e,t){var r;super(e,t),this.options=t,this.visible=!0;const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)},this.zIndex=(r=t.zIndex)!=null?r:Vx,this.isDestroyed=!1,this.labelKey=`onlineMarker-${this.uniqId}`;const o=this.options.floorId?e.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0):0,a=t.elevation?t.elevation*n.Mercator.scaleFactor(t.coordinates[1])*n.MAP_POINTS_IN_METER:0;this.elevation=a+o,this.actualIcon=t.icon,this.setIcon(t.icon)}destroy(){this.isDestroyed=!0,this.modules.identifier.resetCache(),this.modules.labeler.removeLabels(this.labelKey),super.destroy()}isOutOfMainReplica(){return!1}setIcon(e){this.actualIcon=e;const{url:t,transformer:i,size:o,anchor:a}=e;this.modules.imageCache.getRasterSet(t,i,o,a).then(r=>{if(this.isDestroyed||!r||this.actualIcon!==e)return;this.removeIcon();const l=n.makeHandyStyleLayer({type:"point",id:`dynamic-onlineMarker-${this.uniqId}`,minzoom:-1/0,maxzoom:1/0,style:{iconImage:t,iconAnchor:a}}),c=n.optionsToTileAttrs({}),{collector:d,dynamicStyle:_,styleManager:u,defaultSource:h}=this.modules,f=this.zIndex;if(!l)return;const m=n.resolveSimpleLiteralExpression(l.style.iconAnchor);_.addLayer(l,f),_.appendRasterSet(r,n.getStaticIconRasterSetKey(t,m[0],m[1]));const p=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),v={x:[0],y:[0]},x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,c,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(l,x),n.generateSafely({collector:d,generator:n.preLabelingPoint,args:[_.getStyle(),l,x,n.fixedMetatile,n.LATEST_TILE_VERSION,p,h.getId(),v,n.pixelRatioToDpi(window.devicePixelRatio)]});const g=d.getAccumulatedData(),{identifyIds:y,labels:b}=g;if(!b.length)return;const M=[{metatileHash:-1,labels:b,styleId:_.getStyle().id}],T=n.unpackPreLabelingResult(M,n.LabelSource.DynamicObject,u,this.mapState.styleState,this.mapState.styleZoom);if(T.length!==1)return;const P=T[0],S=n.Mercator.toGeo(this.position.userValue),C=n.Ecef.fromGeo(S);n.generateNotStretchableIconElement(d,P,"",[0,0,this.elevation],C,0,r.rasters[0],window.devicePixelRatio);const I=d.getAccumulatedData();d.reset();const E=new n.TileObject("dynamicObject",I.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);this.tileObjects.push(E),this.identifyIds=[y],this.modules.tileManager.addObject(E),this.modules.layers.addLayer(this),this.modules.identifier.queryFillCache(),this.modules.labeler.removeLabels(this.labelKey),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:o[0],height:o[1],position:this.position.normalizedValue,offset:[-a[0],-a[1]],labelingGroup:"marker"}),this.modules.renderer.addRerenderEvent()})}update(){if(this.mapState.globeMode){const{tileManager:e}=this.modules,t=this.modules.camera.ecef.canSee(this.options.coordinates);this.visible&&!t?this.tileObjects.forEach(i=>e.removeObject(i)):!this.visible&&t&&this.tileObjects.forEach(i=>e.addObject(i)),this.visible=t}}removeIcon(){const e=this.tileObjects[0];e&&(e.clean(this.mapState),this.modules.tileManager.removeObject(e),this.tileObjects=[])}}function jx(s,e,t,i,o,a){return{type:s,maxDetailLevel:a,minDetailLevel:o,maxZoomLevel:i,minZoomLevel:t,zoomLevel:Math.floor(e),tiles:{},viewportTiles:[],useExtendedTilesBounds:!1}}function Wx(s){s.tiles={},s.viewportTiles=[]}function $x(s){return{type:"data",key:n.coordsToKey(s),coords:s,zoomLevel:s[2],detailLevel:s[3],needFetch:!1,needAbortFetch:!1,status:n.TileStatus.Initial}}function Xx(s,e,t,i,o){return jx("data",s,e,t,i,o)}function Kx(s,e,t,i){if(s.zoomLevel<s.minZoomLevel){s.viewportTiles=[];return}const o=n.clamp(s.zoomLevel,s.minZoomLevel,s.maxZoomLevel),a=n.clamp(s.zoomLevel,s.minDetailLevel,s.maxDetailLevel);s.viewportTiles=n.findVisibleTiles(e,t,o,s.minZoomLevel,a,void 0,void 0,void 0,s.useExtendedTilesBounds).map(n.coordsToKey);for(let r=0;r<s.viewportTiles.length;r++){const l=s.viewportTiles[r];let c=s.tiles[l];c||(c=s.tiles[l]=i(n.keyToCoords(l)))}}function qx(s){const e=[];for(const t in s.tiles){const i=s.tiles[t];i.needFetch&&(i.needFetch=!1,e.push(i))}return e}function Yx(s){const e=[];for(const t in s.tiles){const i=s.tiles[t];i.needAbortFetch&&(i.needAbortFetch=!1,e.push(i))}return e}function Qx(s,e){const t=new Set(s.viewportTiles),i=[];for(const o in s.tiles){const a=s.tiles[o];!t.has(o)&&!0&&i.push(a)}return i}class Jx extends n.Evented{constructor(e,t,i){super(),this.prevZoomLevel=0,this.mapState=e,this.modules=t,this.config=i,this.gridState=Xx(e.styleZoom,i.minZoom,i.maxZoom,i.minZoom,i.maxZoom),this.viewportDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"}]),this.dataTileLoader=new n.BaseTileLoader("json"),this.modules.layers.addLayer(this)}destroy(){Wx(this.gridState),this.modules.layers.removeLayer(this)}update(){let e=!0;if(this.viewportDiffer.check(this.mapState)){const t=Math.floor(this.mapState.styleZoom);t!==this.prevZoomLevel&&(e=!1),this.prevZoomLevel=t,this.gridState.zoomLevel=t,Kx(this.gridState,this.mapState,this.modules,$x),this.emit("tilesSetChanged",{tileIds:this.gridState.viewportTiles})}for(const t in this.gridState.tiles){if(!this.gridState.viewportTiles.includes(t)){this.gridState.tiles[t].status===n.TileStatus.Loading&&(this.gridState.tiles[t].needAbortFetch=!0);continue}this.gridState.tiles[t].status===n.TileStatus.Initial&&(this.gridState.tiles[t].needFetch=!0,this.gridState.tiles[t].status=n.TileStatus.Loading)}e&&(this.fetch(qx(this.gridState)),this.abortFetch(Yx(this.gridState)),this.clearTiles(Qx(this.gridState)))}fetch(e){e.sort((t,i)=>n.compare(this.mapState.center,t,i)).forEach(t=>this.fetchTile(t))}abortFetch(e){const t=e.map(i=>i.key);this.dataTileLoader.abortRequests(t)}clearTiles(e){for(const t of e)delete this.gridState.tiles[t.key],this.emit("dataTileCleared",{tileId:t.key})}fetchTile(e){const{tsURLTemplate:t}=this.config;this.dataTileLoader.fetch(e.coords,t).then(i=>{i.rejected||this.emit("dataTileLoaded",{tileId:e.key,data:i.data})})}}const Ax=Object.freeze(Object.defineProperty({__proto__:null,Benchmark:Nn,Circle:$l,CircleMarker:Ps,DashedPolyline:jl,DataTileLayer:Jx,DefaultSource:el,DynamicObject:We,Entrance:sl,GeoJsonSource:n.GeoJsonSource,GeoJsonTileSource:n.GeoJsonTileSource,GeoJsonViewportSource:n.GeoJsonViewportSource,GltfModel:cs,Heatmap:bx,HtmlMarker:ts,LinePatternType:n.LinePatternType,Map:ps,MapClass:ps,Marker:Yl,OnlineMarker:Zx,PointLabel:xs,Polygon:Wl,Polyline:Nl,Raster:Jl,RasterTileSource:Al,Rect:Nx,ZenithSource:Yn,config:n.index,linePatternFromString:n.linePatternFromString,mapglUtils:wc,utils:bc},Symbol.toStringTag,{value:"Module"})),eb="topRight";class Gt{constructor(e,t,i){var o;this._wrap=document.createElement("div"),this._wrap.style.userSelect="none",typeof t=="string"?this._wrap.innerHTML=t:this._wrap.appendChild(t),this._position=(o=i==null?void 0:i.position)!=null?o:eb,this._controlPane=e._controlPane,this._container=this._controlPane.getContainerByPosition(this._position),this._container.append(this._wrap)}destroy(){this._wrap.remove()}getPosition(){return this._position}setPosition(e){this._container.removeChild(this._wrap),this._container=this._controlPane.getContainerByPosition(e),this._container.append(this._wrap),this._position=e}getContainer(){return this._wrap}}const Ht={root:"mapgl_QEdaFvncPWE-",button:"mapgl_mjx-K8iaDdc-",zoomIn:"mapgl_zKZCVsRur9c-",zoomOut:"mapgl_3t-wJELDATg-"},tb=`
    <div class="${Ht.root}">
        <button type="button" class="${Ht.button} ${Ht.zoomIn}">
            <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 32 32"
                width="32"
                height="32"
                fill="currentColor"
            >
                <path d="M24 15h-7V8h-2v7H8v2h7v7h2v-7h7v-2z"></path>
            </svg>
        </button>
        <button type="button" class="${Ht.button} ${Ht.zoomOut}">
            <svg
                xmlns="http://www.w3.org/2000/svg"
                viewBox="0 0 32 32"
                fill="currentColor"
                width="32"
                height="32"
            >
                <path d="M8 15h16v2H8z"></path>
            </svg>
        </button>
    </div>
`;class ec extends Gt{constructor(e,t){super(e,tb,t),this._zoomIn=i=>{i.preventDefault(),this._map.setZoom(this._map.getZoom()+1,{duration:400})},this._zoomOut=i=>{i.preventDefault(),this._map.setZoom(this._map.getZoom()-1,{duration:400})},this._checkZoom=()=>{const i=this._map.getZoom();i<=this._map.getMinZoom()?this._zoomOutButton.disabled=!0:this._zoomOutButton.disabled=!1,i>=this._map.getMaxZoom()?this._zoomInButton.disabled=!0:this._zoomInButton.disabled=!1},this._map=e,this._zoomInButton=this._wrap.querySelector(`.${Ht.zoomIn}`),this._zoomOutButton=this._wrap.querySelector(`.${Ht.zoomOut}`),this._zoomInButton.addEventListener("click",this._zoomIn),this._zoomOutButton.addEventListener("click",this._zoomOut),this._map.on("zoom",this._checkZoom)}destroy(){this._map.off("zoom",this._checkZoom),this._zoomInButton.removeEventListener("click",this._zoomIn),this._zoomOutButton.removeEventListener("click",this._zoomOut),super.destroy()}}const Vt={root:"mapgl_ON-gf73kIU0-",button:"mapgl_mWyZxMObEi8-",none:"mapgl_FwnEmRmDBLg-",easy:"mapgl_uSuUHuf71nM-",medium:"mapgl_LdqAv9Ly624-",hard:"mapgl_udRZCM1quWE-"},ib=`<svg xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14" style="margin-top: 4px">
    <path d="M 18,5 C 18,4 17,1 15,1 H 12 10 C 8,1 7,4 7,5 H 5 v 2 h 1 v 4 c 0,0.6 0,1 1,1 v 2 h 2 v -2 h 7 v 2 h 2 v -2 c 1,0 1,-0.4 1,-1 V 7 h 1 V 5 H 18 z M 10,3 h 2 3 c 2,0 2,1 2,3 H 8 C 8,4 8,3 10,3 z M 9,10 H 8 C 7.4,10 7,9.6 7,9 7,8.4 7.4,8 8,8 h 1 c 0.6,0 1,0.4 1,1 0,0.6 -0.4,1 -1,1 z m 8,0 H 16 C 15.4,10 15,9.6 15,9 15,8.4 15.4,8 16,8 h 1 c 0.6,0 1,0.4 1,1 0,0.6 -0.4,1 -1,1 z M 4,4 H 6 V 3 H 4 C 1,3 1,6 1,7 H 0 v 1 h 1 v 4 H 3 V 11 H 5 V 7 H 2 C 2,6 2,4 4,4 z M 3,9 4,10 H 2 V 9 h 1 z" fill="#616161" fill-rule="evenodd"/>
    <g fill="#fff">
        <path d="m 16,8 h 1 c 0.4,0 0.7,0.2 0.8,0.5 C 17.9,8.4 18,8.2 18,8 18,7.4 17.6,7 17,7 h -1 c -0.6,0 -1,0.4 -1,1 0,0.2 0.1,0.4 0.2,0.5 C 15.3,8.2 15.6,8 16,8 z"/>
        <path d="M 8,8 H 9 C 9.4,8 9.7,8.2 9.8,8.5 9.9,8.4 10,8.2 10,8 10,7.4 9.6,7 9,7 H 8 C 7.4,7 7,7.4 7,8 7,8.2 7.1,8.4 7.2,8.5 7.3,8.2 7.6,8 8,8 z"/>
        <path d="M 6,3 H 4 C 4,3 4,3 4,3 2,3 2,5 2,6 H 2 C 2.1,5 2.5,4 4,4 H 5 6 V 3 z"/>
        <path d="M0 7H1V8H0z"/>
        <path d="M 15,2 H 12 10 C 8,2 8,3 8,5 H 8 C 8,3.7 8.3,3 10,3 h 2 3 c 1.7,0 1.9,0.7 2,2 h 0 C 17,3 17,2 15,2 z"/>
        <path d="M3 9L4 9 3 8 2 8 2 9 2 9 2 9 3 9z"/>
        <path d="M 7,11 C 6,11 6,10.6 6,10 v 1 c 0,0.6 0,1 1,1 v -1 z"/>
        <path d="m 18,11 v 1 c 1,0 1,-0.4 1,-1 v -1 c 0,0.6 0,1 -1,1 z"/>
        <path d="M19 6H20V7H19z"/>
        <path d="M3 11L1 11 1 12 3 12 3 11 5 11 5 7 5 7 5 10 3 10z"/>
        <path d="M16 13H18V14H16z"/>
        <path d="M5 6H6V7H5z"/>
        <path d="M9 13L7 13 7 14 9 14 9 12 16 12 16 11 9 11z"/>
    </g>
    <g fill="#444">
        <path d="M 2,6 C 2,6.4 2,6.7 2,7 H 5 V 6 H 2 z"/>
        <path d="M2 9L2 10 4 10 3 9z"/>
        <path d="M 4,3 H 6 V 2 H 4 C 1,2 1,5 1,6 H 0 V 7 H 1 C 1,6 1,3 4,3 z"/>
        <path d="M 18,4 C 18,3 17,0 15,0 H 12 10 C 8,0 7,3 7,4 H 6 5 V 5 H 7 C 7,4 8,1 10,1 h 2 3 c 2,0 3,3 3,4 h 2 V 4 h -2 z"/>
        <path d="M 8,10 H 9 C 9.6,10 10,9.6 10,9 10,8.8 9.9,8.6 9.8,8.5 9.7,8.8 9.4,9 9,9 H 8 C 7.6,9 7.3,8.8 7.2,8.5 7.1,8.6 7,8.8 7,9 c 0,0.6 0.4,1 1,1 z"/>
        <path d="M 17,6 C 17,5.6 17,5.3 17,5 H 8 c 0,0.3 0,0.6 0,1 h 9 z"/>
        <path d="M 17.8,8.5 C 17.7,8.8 17.4,9 17,9 H 16 C 15.6,9 15.3,8.8 15.2,8.5 15.1,8.6 15,8.8 15,9 c 0,0.6 0.4,1 1,1 h 1 c 0.6,0 1,-0.4 1,-1 0,-0.2 -0.1,-0.4 -0.2,-0.5 z"/>
    </g>
</svg>
`;class tc extends Gt{constructor(e,t){super(e,"",t),this._onClick=i=>{i.preventDefault(),this._map.isTrafficOn()?this._map.hideTraffic():this._map.showTraffic()},this._map=e,this._render(),e.on("trafficscore",({score:i})=>{this._score=i,this._render()}),e.on("trafficshow",()=>{this._render()}),e.on("traffichide",()=>{this._render()})}_render(){const e=this._map.isTrafficOn()?nb(this._score):Vt.none,t=`
            <div class="${Vt.root}">
                <button type="button" class="${Vt.button} ${e}">
                    ${this._map.isTrafficOn()&&this._score!==void 0?this._score:ib}
                </button>
            </div>
        `;this._wrap.innerHTML=t,this._wrap.querySelector(`.${Vt.button}`).addEventListener("click",this._onClick)}}function nb(s){return s===void 0?"":s>6?Vt.hard:s>3?Vt.medium:Vt.easy}const Vn={container:"mapgl_K-1Yb8HCVpQ-",logos:"mapgl_CLps5xx6CNs-"};var ic=(s=>(s.osm="osm",s.api="api",s.license="license",s))(ic||{});const ob=`<a href="https://dev.2gis.ru/link_api_map" target="_blank" style="height: 20px;">
    <svg width="40" height="20" viewBox="0 0 40 20" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path d="M2.00011 8.72731C1.98229 5.72738 4.05025 4 6.80779 4C9.47674 4 11.2797 5.58179 11.2797 8.05437C11.2797 10.1091 10.0602 11.2546 7.99196 12.2727C7.21431 12.6547 6.34807 13.1818 5.46454 13.4544H11.3681V16H2.00011V12.66C3.85604 12.0235 4.88111 11.3271 6.59576 10.4728C7.90363 9.81815 8.71666 9.23633 8.71666 8.1819C8.71666 7.16358 7.97439 6.36366 6.80779 6.36366C5.27006 6.36366 4.52753 7.52729 4.56292 8.72731H2.00011Z" fill="#6E7173"/>
        <path d="M23.6348 9.63643V10.5453C23.6348 13.5455 21.6552 16 18.067 16C14.6202 16 12.2518 13.4727 12.2518 9.99986C12.2518 6.52731 14.5497 4 18.1554 4C21.2487 4 23.1751 5.8363 23.6348 7.99991H21.0717C20.6301 6.96353 19.534 6.36366 18.2261 6.36366C15.9813 6.36366 14.7263 8.14523 14.7263 9.99986C14.7263 11.8545 15.9991 13.6363 18.2086 13.6363C19.5872 13.6363 20.736 12.9456 21.0896 11.8181H17.7313V9.63643H23.6348Z" fill="#6E7173"/>
        <path d="M27.4528 16H24.9783V4H27.4528V16Z" fill="#6E7173"/>
        <path d="M38.4292 7.63648H35.8662C35.6185 6.85461 34.947 6.18167 33.4446 6.18167C32.1543 6.18167 31.5004 6.69096 31.5004 7.41809C31.5004 8.30915 32.7375 8.56366 34.293 8.83623L34.361 8.84818C36.4076 9.20779 38.5 9.57545 38.5 12.2727C38.5 14.8 36.4672 16 33.7274 16C31.1998 16 28.9373 14.4727 28.6899 12.1818H31.2527C31.5712 13.1273 32.5079 13.8181 33.8512 13.8181C35.1415 13.8181 35.8662 13.3818 35.8662 12.5455C35.8662 11.514 34.3606 11.2653 32.8555 11.0167C32.8221 11.0112 32.7887 11.0056 32.7553 11.0001C31.1468 10.7273 28.8844 9.9818 28.8844 7.54535C28.8844 5.34534 30.7581 4 33.5332 4C36.2727 4 38.164 5.41814 38.4292 7.63648Z" fill="#6E7173"/>
    </svg>
</a>`,sb=`<a href="https://dev.urbi.ae" target="_blank" style="height: 20px; line-height: 20px;">
    <svg style="width: auto; height: 16px;" width="29" height="12" viewBox="0 0 29 12" fill="none" xmlns="http://www.w3.org/2000/svg">
        <path fill-rule="evenodd" clip-rule="evenodd" d="M5 4V8.0625C5 9.13823 4.64701 9.5 3.75 9.5C3.00479 9.5 2.5 9.15185 2.5 8.0625V4H0V8.5C0 10.6515 1.45917 12 3.75 12C6.19263 12 7.5 10.6515 7.5 8.5V4H5ZM18.5 9.5V2H16V11.9993L20.5 12C23.013 12.0276 24.5 10.4576 24.5 8C24.5 5.4872 23.2711 4 20.5 4H19.5V6.5H20.5C21.6954 6.5 22 6.9645 22 8C22 9.06311 21.3422 9.51381 20.5 9.5H18.5ZM13 4C12.1529 4 11.7541 4.19542 11.5 5L11 4H9.01412V12H11.5V7.75C11.5 6.87606 12.1106 6.5 13 6.5H15V4H13ZM28.25 12V4H25.75V12H28.25ZM27 3C27.9508 3 28.75 2.32569 28.75 1.5C28.75 0.674312 27.9508 0 27 0C26.0492 0 25.25 0.674312 25.25 1.5C25.25 2.32569 26.0492 3 27 3Z" fill="#6E7173"/>
    </svg>
</a>`,nc=s=>`
    <div class=${Vn.container}>
        <div class=${Vn.logos}>
            ${s==="2gis"?ob:sb}
        </div>
    </div>
`,ab=200,Rt=.4,rb=6.9,lb={features:[{type:"Feature",properties:{},geometry:{coordinates:[[[31.287134399571926,46.13828663057069],[32.75238568004798,45.79865765372267],[33.58288063506086,46.01903186613521],[33.61486347995313,46.2235364272577],[33.78934942202696,46.198543888421256],[35.00827602994491,45.75534495217423],[35.2288647404554,45.79620376974098],[35.17718890419883,45.90635851081622],[35.435536217844785,46.10280090340363],[35.79210757517962,46.37361688082296],[36.11428232078944,46.29643073207143],[36.55169983042855,46.510726153023995],[36.8324385653631,46.4588228565425],[37.14524285843429,46.69589191473136],[37.39260951621397,46.689280151379506],[37.627431059848774,46.82264082535376],[38.1229012131082,46.84212508154449],[38.33448922300602,46.97422615512966],[38.224662200013626,47.230888527366346],[38.32912700579817,47.25438400708447],[38.34419757143178,47.312784332059664],[38.21546574161874,47.30909993831261],[38.254518753011865,47.36826000208279],[38.31067651491526,47.38482171052604],[38.321606223663025,47.571364572295465],[38.3617938178036,47.57882910808604],[38.36170197978049,47.618956233608515],[38.45674637734251,47.62208601169297],[38.46107375227305,47.64691148544472],[38.63803321177437,47.647842642655746],[38.672098728783254,47.68762314810277],[38.775725461608346,47.68709376851825],[38.8049944923477,47.813690288503295],[38.834920351813224,47.8196727375917],[38.84241614380997,47.85748354545768],[39.07247756595089,47.86497172354581],[39.10052537670751,47.840884138531834],[39.38214421832214,47.86795888702861],[39.40746330974267,47.8256169720315],[39.482844878880115,47.85023053453213],[39.53382832770623,47.81883936134608],[39.73848854131376,47.82763637975813],[39.79371699101341,47.869042802541685],[39.83078252402845,47.99974474342423],[39.77863815152742,48.03277123184873],[39.88321233741743,48.03971572761765],[39.870917803736376,48.113006872810985],[39.93505319594328,48.18105768715421],[39.94606694701065,48.22361687262517],[40.01236868994266,48.22433847068592],[40.03218509167988,48.26056076274611],[39.984065212024376,48.320002192647365],[39.922439044370975,48.29188408842856],[39.851945001258656,48.331239182362935],[39.94636538164761,48.35223341528243],[39.941853222859265,48.388067879458134],[39.899783141900656,48.45166958120498],[39.85004077188802,48.47107700658495],[39.85404334598155,48.49815859245703],[39.871488094298144,48.507759719913],[39.83989084312387,48.58511601134842],[39.690955803936305,48.59154349398949],[39.668972082370914,48.61595180677952],[39.71340429381095,48.65723964838148],[39.72739208280473,48.68576344104625],[39.720852030234056,48.70453377084817],[39.71060957078353,48.71895533887451],[39.72773821117514,48.727349762777976],[39.742522688889096,48.74565876284592],[39.73675984758131,48.75923566351821],[39.75294236354742,48.76535707528038],[39.77230712573868,48.765131537231696],[39.78708527484656,48.792695126714506],[39.79951920927968,48.83846452038483],[39.97324551864918,48.788853683331496],[40.0854569051011,48.87270686936236],[40.054991236497585,48.91511705296017],[40.01572101314082,48.91564488817568],[39.985747700540486,48.87433169550951],[39.92581794882187,48.895346707874324],[39.85691072202724,48.89266055501065],[39.84380033698696,48.90643237682923],[39.77980530005851,48.92505561008153],[39.76769275004051,48.96624269122293],[39.75249250304927,48.988397421631134],[39.72953342924575,48.98364479695306],[39.6963475099607,49.006204908207565],[39.67412801512273,48.99350840477692],[39.688776866237845,49.04629763624743],[39.77599141224027,49.03984390969006],[39.80998946255809,49.05657174933967],[39.94020528746006,49.054672146531885],[39.94517686594733,49.08306814321608],[40.03354656530658,49.17940433543734],[40.08179564952226,49.187957220033326],[40.127812302222935,49.23339833688371],[40.21735722846822,49.24434936924021],[40.23083631365782,49.264375707391025],[40.184193609561845,49.28357807698788],[40.20554425700146,49.348627711592286],[40.0352506597566,49.460305560239135],[40.042265513048875,49.52110947883719],[40.17301947712943,49.570462036839785],[40.135367644468886,49.619991840168154],[39.930446598607006,49.58753811881613],[39.89326483911972,49.561338740411344],[39.80152397436578,49.5648154530997],[39.747824755329106,49.601752391386356],[39.65652368638126,49.620013992728445],[39.59591913143757,49.727977277611615],[39.43167355486196,49.76704897880802],[39.38482981859343,49.7428519723461],[39.28679269123114,49.7589376228415],[39.23167115889703,49.80067773683314],[39.23126430925569,49.83799228995301],[39.184177982005934,49.89212328019818],[38.939466721594385,49.8129411626972],[38.67999394500015,49.99954348208959],[38.498971405582154,49.969630683120045],[38.36122588838947,50.008962505581735],[38.33064743770436,50.10587365547255],[38.179344250662524,50.08108187117696],[38.17324129258458,49.96421343242167],[38.0243275352658,49.9126740335152],[38.00390141376576,49.80621204332192],[37.9339784494789,49.72626072303203],[37.997665462537555,49.705679809807805],[37.98195913415958,49.63338227733652],[37.87841001479606,49.55639540561637],[37.8726905583969,49.314558240834856],[37.83487442598039,49.211403426079585],[37.568531160033984,49.23978324969454],[37.49068171343487,49.18083483226363],[37.467253126665184,49.08118016596504],[37.29258016280227,48.98322524059054],[37.27222555931064,48.936467375391885],[36.983084082742096,48.80186787172613],[36.72382254183347,48.816637155788754],[36.863697512625095,48.16812695432242],[36.85276964213293,48.06101666035238],[36.63699950073965,48.1120861847823],[36.55643334225425,48.079707051057994],[36.5326892781749,47.85663993329777],[36.15757828505022,47.87029971236788],[36.007257866960344,48.150801757163464],[35.84084530869785,48.072372143164614],[35.69001200739808,48.14916424481041],[34.84251652180234,48.13828093857032],[34.93636037372508,47.54124693653375],[34.561002995692604,47.57138977148597],[33.975870854429644,47.468842659893966],[33.94579238047862,47.53020932511487],[33.65802349898351,47.49630012349715],[33.57945696368617,47.61817363276853],[33.07047295330287,47.579949515419315],[33.106438567586736,47.23712252316682],[32.87965855893614,47.10939623564883],[32.94045936300873,47.00638816222238],[32.531962255274834,46.887846448242044],[32.23541823078415,46.84566846340053],[31.99589893588245,46.69298741295057],[31.792169481175108,46.355938076969124],[31.231245271853055,46.42046225841926],[31.287134399571926,46.13828663057069]]],type:"Polygon"}}]};class cb extends Gt{constructor(e,t){super(e,nc(t.copyrightType),t),this._copyrightType="2gis",this._isHidden=!1,this._onViewportchange=()=>{this._throttledVisibleCopyright()},this._onClick=o=>{if(o.target&&_b(o.target)){const a=o.target.dataset.type;db(a)&&this._map.emit("copyrightclick",{type:a,href:o.target.href,originalEvent:o})}},this._copyrightType=t.copyrightType,this._map=e,this._map._impl.on("viewportchange",this._onViewportchange),this._map._impl.on("idle",this._onViewportchange),t.interactive===!1&&(this._wrap.style.pointerEvents="none"),this._wrap.querySelector(`.${Vn.container}`).addEventListener("click",this._onClick),this._throttledVisibleCopyright=n.throttle(()=>{this.update()},ab)}destroy(){this._map._impl.off("viewportchange",this._onViewportchange),this._map._impl.off("idle",this._onViewportchange),this._wrap.querySelector(`.${Vn.container}`).removeEventListener("click",this._onClick),super.destroy()}update(){let e=!1;if(this._map.getZoom()>rb){const t=this._map.getSize(),i=this._map._impl.unproject([t[0]*Rt,t[1]*Rt]),o=this._map._impl.unproject([t[0]*(1-Rt),t[1]*Rt]),a=this._map._impl.unproject([t[0]*Rt,t[1]*(1-Rt)]),r=this._map._impl.unproject([t[0]*(1-Rt),t[1]*(1-Rt)]);e=ub([i,o,r,a,i],lb.features[0].geometry.coordinates[0])}e&&!this._isHidden&&(this._isHidden=!0,super.getContainer().innerHTML=""),!e&&this._isHidden&&(this._isHidden=!1,super.getContainer().innerHTML=nc(this._copyrightType))}}function db(s){return s!==void 0&&s in ic}function _b(s){return s&&"href"in s&&"dataset"in s}function ub(s,e){for(let t=0;t<s.length-1;t++){const i=s[t],o=s[t+1];for(let a=0;a<e.length-1;a++){const r=e[a],l=e[a+1];if(hb(i,o,r,l))return!0}}return!!(oc(s[0],e)||oc(e[0],s))}function hb(s,e,t,i){const o=Zn(t,i,s),a=Zn(t,i,e),r=Zn(s,e,t),l=Zn(s,e,i);return!!((o>0&&a<0||o<0&&a>0)&&(r>0&&l<0||r<0&&l>0)||o===0&&jn(t,i,s)||a===0&&jn(t,i,e)||r===0&&jn(s,e,t)||l===0&&jn(s,e,i))}function Zn(s,e,t){return(e[0]-s[0])*(t[1]-s[1])-(e[1]-s[1])*(t[0]-s[0])}function jn(s,e,t){return Math.min(s[0],e[0])<=t[0]&&t[0]<=Math.max(s[0],e[0])&&Math.min(s[1],e[1])<=t[1]&&t[1]<=Math.max(s[1],e[1])}function oc(s,e){const[t,i]=s;let o=!1;for(let a=0,r=e.length-1;a<e.length;r=a++){const[l,c]=e[a],[d,_]=e[r];c>i!=_>i&&t<(d-l)*(i-c)/(_-c)+l&&(o=!o)}return o}const sc={wrap:"mapgl_r8Wn2E5pGh0-",container:"mapgl_ir0vRf5QXrk-"};class fb{constructor(e,t){this.rootContainer=e._impl.modules.layout.rootContainer,this.content=t,this.isShown=!1}display(){this.isShown||(this.wrap||(this.wrap=this.initWrap()),this.rootContainer.appendChild(this.wrap),this.isShown=!0)}hide(){this.isShown&&(this.wrap&&this.rootContainer.removeChild(this.wrap),this.isShown=!1)}isDisplayed(){return this.isShown}}const mb=` <div class=${sc.container}>Your MapGL key is invalid. Please contact api@2gis.com to get MapGL key.</div> `;class pb extends fb{constructor(e){super(e,mb),e._impl.on("error",t=>{t.type==="invalidtilekey"&&(this.isDisplayed()||this.display())})}initWrap(){const e=document.createElement("div");return e.classList.add(`${sc.wrap}`),e.innerHTML=this.content,e}}class ac{constructor(e){this.northEast=e.northEast,this.southWest=e.southWest}extend(e){return this.southWest=[Math.min(this.southWest[0],e[0]),Math.min(this.southWest[1],e[1])],this.northEast=[Math.max(this.northEast[0],e[0]),Math.max(this.northEast[1],e[1])],this}getCenter(){return[(this.southWest[0]+this.northEast[0])/2,(this.southWest[1]+this.northEast[1])/2]}containsPoint(e){const[t,i]=e,o=t>=this.southWest[0]&&t<=this.northEast[0],a=i>=this.southWest[1]&&i<=this.northEast[1];return o&&a}containsBounds(e){const{southWest:t,northEast:i}=e,o=this.containsPoint(t),a=this.containsPoint(i);return o&&a}intersects(e){const{southWest:t,northEast:i}=e,o=this.getPointRelatedLocation(t),a=this.getPointRelatedLocation(i),r=+o.N+ +a.N,l=+o.S+ +a.S,c=+o.W+ +a.W,d=+o.E+ +a.E;return!(r===2||l===2||c===2||d===2)}getPointRelatedLocation(e){return{S:e[1]<this.southWest[1],N:e[1]>this.northEast[1],W:e[0]<this.southWest[0],E:e[0]>this.northEast[0]}}}const Ve={root:"mapgl_h2pl79nAYpk-",container:"mapgl_64D1bmNQN3Q-",scroller:"mapgl_jdJbkjpLO7k-",content:"mapgl_54Rmy50n6Fw-",control:"mapgl_3i1QoGerxio-",label:"mapgl_wGplqJ4hHPc-"},vb=`
    <div class="${Ve.root}">
        <div class="${Ve.container}">
            <div class="${Ve.scroller}">
                <div class="${Ve.content}" />
            </div>
        </div>
    </div>
`,gb=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.1142 14.1859L23.2303 9.29482L18.0571 1.2998L5.55708 5.01563L5.56217 5.04408L0.599976 10.0063L1.95007 11.3564L5.59996 7.70647L6.39699 6.90943L7.09339 7.79575L12.1142 14.1859ZM21.8071 12.1061L15.1198 15.0485L12.8071 16.1326V22.6321L21.8071 18.4131V12.1061ZM6.21714 9.91771L3.21617 12.9187V18.8564L5.50707 19.9405V14.9136L8.00707 15.9136V21.1236L10.8071 22.4487V15.7594L6.21714 9.91771Z" fill="#0059D6"/>
</svg>`,yb=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="20px" height="20px" viewBox="337.5 232.3 125 85.9" xml:space="preserve">
<polygon fill="#FF0013" points="453.9,306.2 424.7,232.3 400,275.5 375.4,232.3 346.1,306.2 337.5,306.2 337.5,317.4 381.7,317.4 381.7,306.2 375.1,306.2 381.5,287.8 400,318.2 418.5,287.8 424.9,306.2 418.3,306.2 418.3,317.4 462.5,317.4 462.5,306.2 "/>
</svg>`;class rc extends Gt{constructor(e,t){super(e,vb,t),this._removeButtonsEventListeners=()=>{this._content&&this._content.childNodes.forEach(i=>{if(this._handlers.has(i)){const o=this._handlers.get(i);o!==void 0&&i.removeEventListener("click",o)}})},this._showControl=i=>{const{currentFloor:o,id:a,floorNames:r,metro:l,mode:c}=i;this._floor={mode:c,currentFloorLevelIndex:o,floorPlanId:a,floorNames:r,metro:l},this._root.style.display="block",this._renderControl()},this._hideControl=()=>{this._map._impl.state.floorsEnabled&&(this._removeButtonsEventListeners(),this._floor=void 0,this._root.style.display="none")},this._onLevelChange=i=>{this._switchCurrentFloorLevel(i.floorLevelIndex)},this._controlHandler=i=>o=>{o.preventDefault(),this._switchCurrentFloorLevel(i),this._floor&&this._map._impl.changeFloorNumber(this._floor.floorPlanId,i)},this._map=e,this._root=this._wrap.querySelector(`.${Ve.root}`),this._content=this._wrap.querySelector(`.${Ve.content}`),this._handlers=new WeakMap,this._root.style.display="none",this._map._impl.on("floorcomplexin",this._showControl),this._map._impl.on("floorcomplexout",this._hideControl),this._map.on("floorlevelchange",this._onLevelChange)}destroy(){this._map._impl.off("floorcomplexin",this._showControl),this._map._impl.off("floorcomplexout",this._hideControl),this._map.off("floorlevelchange",this._onLevelChange),this._removeButtonsEventListeners(),super.destroy()}_renderControl(){var o;if(!this._floor)return;this._content.innerHTML="";let e;if(this._floor.metro){const a=document.createElement("button");a.className=`${Ve.control} ${Ve.hideFloorsButton}`,a.innerHTML=yb,a.name="metro",a.type="button";const r=this._controlHandler("metro");a.addEventListener("click",r),this._handlers.set(a,r),this._content.append(a),this._floor.mode==="metro"&&(a.disabled=!0,e=a)}this._floor.floorNames.forEach((a,r)=>{const l=document.createElement("button");l.className=Ve.control,l.innerHTML=`<div class="${Ve.label}">${a}</div>`,l.name=r.toLocaleString(),l.type="button",this._floor&&this._floor.mode==="floor"&&this._floor.currentFloorLevelIndex===r&&(l.disabled=!0,e=l);const c=this._controlHandler(r);l.addEventListener("click",c),this._handlers.set(l,c),this._content.append(l)});const t=document.createElement("button");t.className=`${Ve.control} ${Ve.hideFloorsButton}`,t.innerHTML=`<div class="${Ve.label}">${gb}</div>`,t.name="building",t.type="button",this._floor&&this._floor.mode==="building"&&(t.disabled=!0,e=t);const i=this._controlHandler("building");if(t.addEventListener("click",i),this._handlers.set(t,i),this._content.append(t),e&&e.offsetTop){const a=(o=e.parentElement)==null?void 0:o.parentElement;a&&(a.scrollTop=e.offsetTop)}}_switchCurrentFloorLevel(e){if(!this._floor)return;const t=this._floor.mode==="floor"?this._floor.currentFloorLevelIndex:this._floor.mode==="building"?"building":"metro",i=this._wrap.querySelector(`.${Ve.control}[name="${t}"]`);i&&(i.disabled=!1);const o=this._wrap.querySelector(`.${Ve.control}[name="${e}"]`);o&&(o.disabled=!0),typeof e=="number"?(this._floor.mode="floor",this._floor.currentFloorLevelIndex=e):this._floor.mode=e}}const ws={controlPane:"mapgl_z0m6n5pr5no-",container:"mapgl_ITPUswrhaGk-",topLeft:"mapgl_Px-KwzXdVa0-",topCenter:"mapgl_SCX3EYsS-Cw-",topRight:"mapgl_i42TyWqpCPk-",centerLeft:"mapgl_-zKby6nN-nU-",centerRight:"mapgl_SlQM4-ZNKF0-",bottomLeft:"mapgl_lNg3h7Hg-Mo-",bottomCenter:"mapgl_grOepPBwilk-",bottomRight:"mapgl_CiHYefDPhI0-"},Pi=10;class xb{constructor(e,t){this.wrap=document.createElement("div"),this.wrap.className=ws.controlPane,this.containers={};const{rootContainer:i}=e._impl.modules.layout;i.appendChild(this.wrap),this.padding={top:Pi,right:Pi,bottom:Pi,left:Pi},this.setPadding(t.padding||{})}setPadding(e){Object.keys(this.padding).forEach(t=>{var o;const i=t;this.padding[i]=(o=e[i])!=null?o:Pi,this.wrap.style[`margin${i.replace(/^\w/,a=>a.toUpperCase())}`]=`${this.padding[i]}px`})}getPadding(){return B({},this.padding)}destroy(){this.wrap.remove()}getContainerByPosition(e){let t=this.containers[e];return t||(t=this.containers[e]=this._initControlContainer(e)),t}_initControlContainer(e){const t=document.createElement("div");return t.classList.add(ws.container,ws[e]),this.wrap.appendChild(t),t}}const lc={root:"mapgl_9m2ynAxdBT0-",label:"mapgl_sR4nXEQ3L2M-"},Wn={meter:{en:"m",ru:"м"},kilometer:{en:"km",ru:"км"}},bb=66;class cc extends Gt{constructor(e,t){super(e,"",t),this._render=()=>{const{state:i}=this._map._impl,o=!!i.styleState.globeEnabled&&i.zoom<n.globeConfig.globeMaxZoom;if(this._wrap.hidden=o,o)return;const a=this._wrap.getBoundingClientRect(),r=this._calcSize([a.x,a.y],a.width||bb,0),l=`
            <div class="${lc.root}">
                <div class="${lc.label}">
                    ${wb(r,this._map.getLanguage())}
                </div>
            </div>
        `;this._wrap.innerHTML=l},this._map=e,this._render(),e.on("zoom",this._render),e.on("pitch",this._render),e.on("changeLanguage",this._render),e.on("move",this._render),e.on("resize",this._render)}destroy(){this._map.off("zoom",this._render),this._map.off("pitch",this._render),this._map.off("changeLanguage",this._render),this._map.off("move",this._render),this._map.off("resize",this._render),super.destroy()}_calcSize(e,t,i){return n.getMetersFromPixelsXY(this._map.getCenter(),this._map.getZoom(),this._map.getRotation(),this._map.getSize(),this._map.getPitch(),e,void 0,this._map.getPadding(),t,i)}}function wb(s,e){return s<1e3?`${s} ${Wn.meter[e]||Wn.meter.en}`:`${(s/1e3).toFixed(1)} ${Wn.kilometer[e]||Wn.kilometer.en}`}class dc{constructor(e){this._impl=e._impl.getDefaultSource()}setFeatureStateMap(e){this._impl.setFeatureStateMap(e)}}function Xe(s,e){const t=B({},s);for(const i in e){const o=i;t[o]===void 0&&(t[o]=e[o])}return t}const Sb={center:[0,0],zoom:0,minZoom:kn.minZoom,maxZoom:kn.maxZoom,rotation:0,touchRotationThreshold:10,pitch:0,minPitch:0,maxPitch:45,lowZoomMaxPitch:45,viewport:{top:0,right:0,bottom:0,left:0},padding:{top:0,right:0,bottom:0,left:0},style:"",lang:"en",iconIdentifyOpacity:.3,disableHidingPois:!1,disableHoverStyles:!1,disableZoomOnScroll:!1,disableDragging:!1,enableTwoFingerDragging:!1,disableRotationByUserInteraction:!1,disablePitchByUserInteraction:!1,defaultBackgroundColor:"#f6f2de",disableIconCache:!1,mobileSdkMode:!1,skipElevationAnimation:!1,enableTrackResize:!1,showDefaultTileBounds:!1,immersiveOn:!1,pitchHightLimitation:90,loopWorld:!1,cityCommPoiLabelingConfig:n.cityCommPoiLabelingConfig,disableRenderingCache:!1,disableStyleFallback:!1,fontUrl:"",modelUrl:"",iconUrl:"",keyUrl:"",disableModelsGrowthAnimation:!1,disableLayerAnimation:!1,trafficOn:!1,allowMetro:!1,resetFloorModeOnActivation:!1,webgpu:!1,forceSyncIdentify:!1};let Tb=class extends It{constructor(e,t){var l;super();let i;if(typeof e=="string"){const c=document.getElementById(e);if(c)i=c;else throw new Error(`Could not found html element with id: ${e}`)}else i=e;const o=B({},t.styleOptions),a=Xe(this._validateOptions(t),Sb),r=de(B({},a),{disableHoverStyles:(l=t.disableHoverStyles)!=null?l:!0,tileServer:t.tileServer||dy,style:t.style||n.DEFAULT_MAPGL_STYLE,styleOptions:o,styleState:t.styleState,sessionId:fs(),tileSessionId:t.tileSessionId});this._impl=new ps(i,r),this._impl.on("idle",c=>this._emitMapEvent("idle",c)).on("ready",c=>this._emitMapEvent("ready",c)).on("resize",c=>this._emitMapEvent("resize",c)).on("move",c=>this._emitMapEvent("move",c)).on("movestart",c=>this._emitMapEvent("movestart",c)).on("moveend",c=>this._emitMapEvent("moveend",c)).on("center",c=>this._emitMapEvent("center",c)).on("centerstart",c=>this._emitMapEvent("centerstart",c)).on("centerend",c=>this._emitMapEvent("centerend",c)).on("zoom",c=>this._emitMapEvent("zoom",c)).on("zoomstart",c=>this._emitMapEvent("zoomstart",c)).on("zoomend",c=>this._emitMapEvent("zoomend",c)).on("rotation",c=>this._emitMapEvent("rotation",c)).on("rotationstart",c=>this._emitMapEvent("rotationstart",c)).on("rotationend",c=>this._emitMapEvent("rotationend",c)).on("pitch",c=>this._emitMapEvent("pitch",c)).on("pitchstart",c=>this._emitMapEvent("pitchstart",c)).on("pitchend",c=>this._emitMapEvent("pitchend",c)).on("trafficshow",()=>this.emit("trafficshow")).on("traffichide",()=>this.emit("traffichide")).on("floorcomplexshow",({id:c,currentFloor:d,floorNames:_})=>this.emit("floorplanshow",{floorPlanId:c,currentFloorLevelIndex:d,floorLevels:_.map((u,h)=>({floorLevelIndex:h,floorLevelName:u}))})).on("floorcomplexhide",c=>this.emit("floorplanhide",{floorPlanId:c.id})).on("floorcomplexlevelchange",c=>this.emit("floorlevelchange",{floorLevelName:c.floorName,floorLevelIndex:c.floorIndex,floorPlanId:c.id})).on("floorsactivegroupchange",c=>this.emit("floorsactivegroupchange",c)).on("modelshow",c=>this.emit("modelshow",c)).on("modelhide",c=>this.emit("modelhide",c)),this._impl.on("click",c=>this._emitMapPointerEvent("click",c)).on("dblclick",c=>this._emitMapPointerEvent("dblclick",c)).on("contextmenu",c=>this._emitMapPointerEvent("contextmenu",c)).on("mousemove",c=>this._emitMapPointerEvent("mousemove",c)).on("mouseover",c=>this._emitMapPointerEvent("mouseover",c)).on("mouseout",c=>this._emitMapPointerEvent("mouseout",c)).on("mousedown",c=>this._emitMapPointerEvent("mousedown",c)).on("mouseup",c=>this._emitMapPointerEvent("mouseup",c)).on("touchstart",c=>this._emitMapPointerEvent("touchstart",c)).on("touchend",c=>this._emitMapPointerEvent("touchend",c)),this._impl.on("error",c=>this._emitMapErrorEvent("error",c)),this._impl.on("trafficscore",({score:c})=>this.emit("trafficscore",{score:c})),this._impl.on("styleload",({style:c})=>this.emit("styleload",{style:c})),this._impl.on("graphicspresetchange",()=>this.emit("graphicspresetchange",this._impl.getCurrentGraphicsPreset())),this._controlPane=new xb(this,{padding:t.controlsLayoutPadding}),this._initControls(t),new pb(this),this._defaultSource=new dc(this)}setCenter(e,t){return this._impl.setCenter(e,t),this}getCenter(){return this._impl.getCenter()}setZoom(e,t){return this._impl.setZoom(e,t),this}getZoom(){return this._impl.getZoom()}getStyleZoom(){return this._impl.getStyleZoom()}setStyleZoom(e,t){return this._impl.setStyleZoom(e,t),this}setRotation(e,t){return this._impl.setRotation(e,t),this}getRotation(){return this._impl.getRotation()}setPitch(e,t){return this._impl.setPitch(e,t),this}getPitch(){return this._impl.getPitch()}setMinZoom(e,t){return this._impl.setMinZoom(e,t),this}getMinZoom(){return this._impl.getMinZoom()}getMaxZoom(){return this._impl.getMaxZoom()}setMaxZoom(e,t){return this._impl.setMaxZoom(e,t),this}setMinPitch(e,t){return this._impl.setMinPitch(e,t),this}setMaxPitch(e,t){return this._impl.setMaxPitch(e,t),this}setLowZoomMaxPitch(e,t){return this._impl.setLowZoomMaxPitch(e,t),this}getSize(){return this._impl.getSize()}isIdle(){return this._impl.isIdle()}getBounds(e){return new ac(this._impl.getBounds(e))}project(e){return this._impl.project(e)}unproject(e){return this._impl.unproject(e)}getProjectionMatrix(){return this._impl.getCameraViewProjectionMatrix().slice()}getProjectionMatrixForGltfPlugin(){return this._impl.getCameraProjectionMatrix().slice()}getWebGLContext(){return this._impl.getWebGLContext()}getCanvas(){return this._impl.getCanvas()}getContainer(){return this._impl.getExternalContainer()}invalidateSize(){return this._impl.invalidateSize(),this}showTraffic(){return this._impl.showTraffic(),this}hideTraffic(){return this._impl.hideTraffic(),this}isTrafficOn(){return this._impl.isTrafficOn()}setSelectedObjects(e=[],t){return this._impl.setSelectedIds(e,t),this}setStyleById(e){return K(this,null,function*(){return this._impl.setStyle(e)})}setStyleFromUrl(e,t){return K(this,null,function*(){return this._impl.setStyle(e,t)})}setLanguage(e){return this._impl.setLang(e),this.emit("changeLanguage",{lang:e}),this}getLanguage(){return this._impl.state.lang}setFloorPlanLevel(e,t){this._impl.changeFloorNumber(e,t)}setMaxBounds(e){return this._impl.setMaxBounds(e),this}getPadding(){return this._impl.getPadding()}getDefaultSource(){return this._defaultSource}setPadding(e,t){return this._impl.setPadding(e,t),this}setStyle(e,t){return this._impl.setStyle(e,t)}hasLayer(e){return this._impl.hasLayer(e)}addLayer(e,t){return this.addDraftLayer(e,t),this}addDraftLayer(e,t){return this._impl.addLayer(e,t),this}addIcon(e,t){return this._impl.addIcon(e,t),this}removeIcon(e){return this._impl.removeIcon(e),this}getMapRenderStat(){return this._impl.getMapRenderStat()}addModel(e,t){return this._impl.addModel(e,t),this}removeLayer(e){return this._impl.removeLayer(e),this}setAutoHoverMode(e){return this._impl.setAutoHoverMode(e),this}fitBounds(e,t){return this._impl.fitBounds(e,t),this}setStyleState(e){return this._impl.setStyleState(e),this}setTime(e){this._impl.setTime(e)}getTime(e){return this._impl.getTime(e)}getStyleState(){return this._impl.getStyleState()}setStyleOptions(e){return this._impl.patchStyleState({trafficOn:e.traffic}),this}setOption(e,t){return this._impl.setOption(e,t),this}getOption(e){return this._impl.getOption(e)}patchStyleState(e){return this._impl.patchStyleState(e),this}destroy(){this._controlPane.destroy(),this._impl.destroy(),this.emit("destroy")}triggerRerender(){this._impl.modules.renderer.addRerenderEvent({type:"triggerRerender"})}setControlsLayoutPadding(e){this._controlPane.setPadding(e)}getControlsLayoutPadding(){return this._controlPane.getPadding()}setHiddenObjects(e){this._impl.hideBuildingsById(e)}setEnvironmentParams(e){this._impl.modules.environmentManager.setParameters(e)}unsetHiddenObjects(e){this._impl.showHiddenBuildingsById(e)}showLabelsDebug(e){this._impl.showLabelsDebug(e)}hideLabelsDebug(){this._impl.hideLabelsDebug()}getGroundPoint(e){return this._impl.getGroundPoint(e)}setAllowedFloorIds(e){this._impl.setAllowedFloorIds(e)}setLightingStyle(e){this._impl.setLightingStyle(e)}hideLayers(e){return this._impl.hideLayers(e),this}showLayers(e){return this._impl.showLayers(e),this}getGraphicsPreset(){return this._impl.getCurrentGraphicsPreset().preset}blockInteraction(){this._impl.modules.handler.block(),this._impl.core.handlers.forEach(e=>{e.block()}),this._impl.modules.mouseMoveHandler.block()}unblockInteraction(){this._impl.modules.handler.unblock(),this._impl.core.handlers.forEach(e=>{e.unblock()}),this._impl.modules.mouseMoveHandler.unblock()}_emitMapEvent(e,t){this.emit(e,{isUser:t.isUser})}_emitMapErrorEvent(e,t){switch(t.type){case"rasterTileLoadError":{const{tileCoords:i,tileUrl:o,source:a,responseMessage:r,responseStatus:l}=t;if((a==null?void 0:a.type)==="raster"){const c=a.mapglApiSource;this.emit(e,{type:t.type,responseMessage:r,responseStatus:l,tileUrl:o,tileCoords:[i[0],i[1],i[2]],source:c})}break}case"webglcontextlost":{this.emit(e,{type:t.type});break}case"styleloaderror":{this.emit("styleloaderror",{style:t.style}),this.emit(e,{type:t.type,style:t.style});break}case"invalidtilekey":{this.emit(e,{type:t.type});break}default:n.assertUnreachable(t)}}_emitMapPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a,target:r,targetData:l}=t;let c;if(l!==void 0)switch(l.type){case"geojson":{c={type:l.type,source:l.source.mapglApiSource,feature:l.feature,id:l.id,layerId:l.layerId};break}case"zenith":{c={type:l.type,id:l.id,source:l.source.mapglApiSource,attributes:l.attributes,layerId:l.layerId};break}case"default":{c={type:l.type,id:l.id,layerId:l.layerId};const{floorId:_}=l;_&&(c.floorId=_);break}}let d;r!==void 0&&(d={id:r.id},r.center&&(d.center=r.center)),this.emit(e,{originalEvent:i,lngLat:o,point:a,target:d,targetData:c})}_initControls(e){if(e.copyright!==!1&&this._impl.modules.tileKeyInfo.getKeyInfo().then(t=>{!t.error&&!t.hideCopyright&&new cb(this,{position:typeof e.copyright=="string"?e.copyright:"bottomRight",interactive:e.interactiveCopyright,copyrightType:t.urbi?"Urbi":"2gis"})}),e.zoomControl!==!1){const t=typeof e.zoomControl=="string"?e.zoomControl:"topRight";new ec(this,{position:t})}if(e.trafficControl){const t=typeof e.trafficControl=="string"?e.trafficControl:"topRight";new tc(this,{position:t})}if(e.scaleControl){const t=typeof e.scaleControl=="string"?e.scaleControl:"bottomLeft";new cc(this,{position:t})}if(e.floorControl){const t=typeof e.floorControl=="string"?e.floorControl:"topRight";new rc(this,{position:t})}}_validateOptions(e){return e=B({},e),typeof e=="object"&&"center"in e&&(Rl.isValidGeoPoint(e.center,ms.UseDefault)||(e.center=void 0)),e}};const Mb="Noto_Sans",Eb={minZoom:-1/0,maxZoom:1/0,anchor:[.5,.5],offset:[0,18],relativeAnchor:[.5,.5],zIndex:0,lineHeight:1.2,letterSpacing:0,haloRadius:0,fontSize:18,color:"#000000",haloColor:"#ffffff"},Ib={minZoom:-1/0,maxZoom:1/0,zIndex:0,icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",interactive:!0,hoverSize:[15,43],rotation:0,userData:void 0,opacity:1,hoverOpacity:1};class Cb extends It{constructor(e,t){super(),t.icon||(t.anchor=[15,46]);const i=Xe(t,Ib);this.userData=i.userData,this.rootOptions={zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom},this._impl=new Yl(e._impl,{coordinates:i.coordinates,icon:i.icon,zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom,interactive:i.interactive,opacity:i.opacity,hoverOpacity:i.hoverOpacity,label:_c(this.rootOptions,t.label),anchor:t.anchor,size:t.size,rotation:t.rotation,hoverIcon:t.hoverIcon,hoverSize:t.hoverSize,hoverAnchor:t.hoverAnchor}),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}setIcon({icon:e,anchor:t,size:i,opacity:o}){return this._impl.setIcon({icon:e,anchor:t,size:i,opacity:o}),this}setHoverIcon(e){const t=e?{icon:e.icon,anchor:e.anchor,size:e.size,opacity:e.opacity}:void 0;return this._impl.setHoverIcon(t),this}setRotation(e){return this._impl.setRotation(e),this}getRotation(){return this._impl.getRotation()}setLabel(e){return this._impl.setLabel(_c(this.rootOptions,e)),this}setCoordinates(e){return this._impl.setCoordinates(e),this}getCoordinates(){return this._impl.getCoordinates()}show(){return this._impl.show(),this}hide(){return this._impl.hide(),this}destroy(){this._impl.destroy()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}function _c(s,e){var i,o,a;if(!e)return;e.minZoom=Math.max((i=e.minZoom)!=null?i:s.minZoom,s.minZoom),e.maxZoom=Math.min((o=e.maxZoom)!=null?o:s.maxZoom,s.maxZoom),e.zIndex=(a=e.zIndex)!=null?a:s.zIndex+1e-5;const t=Xe(e,Eb);return e.offset===void 0&&e.anchor!==void 0&&(t.offset=e.anchor.map(r=>-r)),{text:t.text,image:e.image,minZoom:t.minZoom,maxZoom:t.maxZoom,color:t.color,fontSize:t.fontSize,haloRadius:t.haloRadius,haloColor:t.haloColor,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,zIndex:t.zIndex,offset:t.offset,anchor:t.relativeAnchor,font:Mb}}const Lb="Noto_Sans",Pb={anchor:[0,0],offset:[0,0],fontSize:24,color:"#000000",haloColor:"#ffffff",haloRadius:0,minZoom:-1/0,maxZoom:1/0,zIndex:0,letterSpacing:0,lineHeight:1.2,relativeAnchor:[.5,.5],userData:void 0,interactive:!1};class Bb extends It{constructor(e,t){super(),this.userData=t.userData;const i=Xe(t,Pb);t.offset===void 0&&t.anchor!==void 0&&(i.offset=t.anchor.map(o=>-o)),this._impl=new xs(e._impl,{coordinates:i.coordinates,text:i.text,minZoom:i.minZoom,maxZoom:i.maxZoom,color:i.color,fontSize:i.fontSize,haloRadius:i.haloRadius,haloColor:i.haloColor,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,zIndex:i.zIndex,offset:i.offset,anchor:i.relativeAnchor,labeling:t.labeling,image:t.image,font:Lb,interactive:i.interactive}),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}destroy(){this._impl.remove()}show(){return this._impl.show(),this}hide(){return this._impl.hide(),this}setCoordinates(e){return this._impl.setCoordinates(e),this}getCoordinates(){return this._impl.getCoordinates()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const zb={minZoom:-1/0,maxZoom:1/0,zIndex:0,anchor:[-0,-0],preventMapInteractions:!0,userData:void 0,interactive:!0,disableRounding:!1,labeling:{type:"none"},floorId:""},Rb=!1;class Fb{constructor(e,t){this.userData=t.userData;const i=Xe(t,zb);this._impl=new ts(e._impl,{coordinates:i.coordinates,html:i.html,offset:[-i.anchor[0],-i.anchor[1]],minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,preventMapInteractions:i.preventMapInteractions,interactive:i.interactive,animate:Rb,disableRounding:i.disableRounding,labeling:i.labeling,floorId:i.floorId})}destroy(){this._impl.destroy()}setCoordinates(e){return this._impl.setPosition(e),this}setAnchor(e){return this._impl.setOffset([-e[0],-e[1]]),this}setContent(e){return this._impl.setContent(e),this}setZIndex(e){return this._impl.setZIndex(e),this}getCoordinates(){return this._impl.getPosition()}getAnchor(){const e=this._impl.getOffset();return[-e[0],-e[1]]}getContent(){return this._impl.getHtmlElement()}getZIndex(){return this._impl.getZIndex()}}const Db={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#3388ff33",strokeColor:"#3388ff",strokeWidth:1,interactive:!0,userData:void 0};class Ob extends It{constructor(e,t){super(),this.userData=t.userData;const i=Xe(t,Db),o={coordinates:i.coordinates,radius:i.radius,minZoom:i.minZoom,maxZoom:i.maxZoom,interactive:i.interactive,color:i.color,zIndex:i.zIndex,borderWidth:i.strokeWidth,borderColor:i.strokeColor,segments:150,tiers:t.tiers};this._impl=new $l(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Nb={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#ffffff",radius:20,diameter:NaN,zIndex:0,strokeWidth:3,stroke2Width:0,strokeColor:"#3388ff",stroke2Color:"#00000000",userData:void 0};class kb extends It{constructor(e,t){super(),this.userData=t.userData,this.options=Xe(t,Nb);const i={coordinates:this.options.coordinates,interactive:this.options.interactive,maxZoom:this.options.maxZoom,minZoom:this.options.minZoom,color:this.options.color,width:Number.isNaN(this.options.diameter)?this.options.radius:this.options.diameter,zIndex:this.options.zIndex,borderWidth:this.options.strokeWidth,borderColor:this.options.strokeColor,border2Width:this.options.stroke2Width,border2Color:this.options.stroke2Color,draggable:!1};this._impl=new Ps(e._impl,i),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Ub={interactive:!0,maxZoom:1/0,minZoom:-1/0,width:3,width2:0,width3:0,color:"#3388ff",color2:"#00000000",color3:"#00000000",zIndex:0,zIndex2:-1,zIndex3:-2,dashLength:0,gapLength:0,gapColor:"#ffffff00",userData:void 0,renderingMode:"2d"};class Gb extends It{constructor(e,t){super(),this.userData=t.userData;const i=Xe(t,Ub);if(t.dashLength){const o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,width:i.width,width2:i.width2,dashColor:i.color,dash2Color:i.color,gapColor:i.gapColor,dashLength:i.dashLength,dash2Length:0,zIndex:i.zIndex,zIndex2:i.zIndex2,gapLength:i.gapLength===0?i.dashLength:i.gapLength,displayTileBounds:!1,showAnimation:{animate:!1},renderingMode:i.renderingMode,hiddenPartDashColor:t.hiddenPartColor,hiddenPartDash2Color:t.hiddenPartColor,hiddenPartGapColor:t.hiddenPartGapColor,gpuState:t.gpuState,tiers:t.tiers};this._impl=new jl(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}else{const o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,width:i.width,width2:i.width2,width3:i.width3,color:i.color,color2:i.color2,color3:i.color3,zIndex:i.zIndex,zIndex2:i.zIndex2,zIndex3:i.zIndex3,displayTileBounds:!1,showAnimation:{animate:!1},gpuState:t.gpuState,renderingMode:i.renderingMode,hiddenPartColor:t.hiddenPartColor,tiers:t.tiers};this._impl=new Nl(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Hb={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#3388ff33",zIndex:0,strokeWidth:3,strokeColor:"#3388ff",userData:void 0};class Vb extends It{constructor(e,t){super(),this.userData=t.userData;const i=Xe(t,Hb),o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,color:i.color,zIndex:i.zIndex,strokeWidth:i.strokeWidth,strokeColor:i.strokeColor,tiers:t.tiers};this._impl=new Wl(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const Zb={minZoom:-1/0,maxZoom:1/0,zIndex:0,opacity:1};class jb{constructor(e,t){const i=Xe(t,Zb),o={bounds:i.bounds,image:{url:i.image.url},minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,opacity:i.opacity,tiers:t.tiers};this._impl=new Jl(e._impl,o)}updateImage(e){return K(this,null,function*(){yield this._impl.updateImage(e)})}destroy(){this._impl.destroy()}}const Wb={scale:1,rotation:0,offset:0,linkedIds:[],interactive:!1,interactiveOcclusion:!0,minZoom:-1/0,maxZoom:1/0,zIndex:0,hideOnInit:!1,ignoreGlobalLighting:!1,colorTextureUvIndex:0,nearCameraFade:2500,showRatio:1,userData:void 0,planId:"",disableAnimation:!1,hover:{},select:{},color:"#ffffffff",playAnimation:-1};class $b extends It{constructor(e,t){super(),this.userData=t.userData;const i=Xe(t,Wb),o={coordinates:i.coordinates,modelSrc:i.modelSrc,scale:i.scale,rotation:i.rotation,offset:i.offset,linkedIds:i.linkedIds,planId:i.planId,interactive:i.interactive,interactiveOcclusion:i.interactiveOcclusion,minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,hideOnInit:i.hideOnInit,ignoreGlobalLighting:i.ignoreGlobalLighting,colorTextureUvIndex:i.colorTextureUvIndex,nearCameraFade:i.nearCameraFade,showRatio:i.showRatio,disableAnimation:i.disableAnimation,hover:i.hover,select:i.select,color:i.color,playAnimation:i.playAnimation};this._impl=new cs(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a)).on("modelloaded",()=>this._emitPointerEvent("modelloaded"))}destroy(e){this._impl.destroy(e)}hide(){this._impl.hide()}show(){this._impl.show()}transform(e){this._impl.transform(e)}stopTransformation(){this._impl.stopTransformation()}getCoordinates(){return this._impl.getCoordinates()}getScale(){return this._impl.getScale()}getRotation(){return this._impl.getRotation()}getOffset(){return this._impl.getOffset()}setState(e){this._impl.setState(e)}_emitPointerEvent(e,t){this.emit(e,t?{originalEvent:t.originalEvent,lngLat:t.lngLat,point:t.point,targetData:this}:void 0)}}const uc={attributes:{},maxZoom:17,dimensions:2,modelsPath:"",modelsAppearStrategy:"byModel",promoteId:"",idScope:"default",tolerance:3};class Xb{constructor(e,t){this.options=Xe(t,uc),this._impl=new n.GeoJsonSource(e._impl,this.options,this),this._isDestroyed=!1}destroy(){this._isDestroyed=!0,this._impl.destroy()}setAttributes(e){return this._isDestroyed||this._impl.setAttributes(e),this}getAttributes(){return this._isDestroyed?{}:this._impl.getAttributes()}setData(e){return K(this,null,function*(){this._isDestroyed||(yield this._impl.setData(e))})}}const Kb=de(B({},uc),{viewportPadding:0});class qb{constructor(e,t){this.options=Xe(t,Kb);const i=de(B({},this.options),{data:n.EMPTY_FEATURE_COLLECTION});this._impl=new n.GeoJsonViewportSource(e._impl,i,this),this._impl.setDataFn(t.data),this._impl.setViewportPadding(this.options.viewportPadding)}destroy(){this._impl.destroy()}setAttributes(e){return this._impl.setAttributes(e),this}getAttributes(){return this._impl.getAttributes()}setData(e){return K(this,null,function*(){return this._impl.setDataFn(e)})}setViewportPadding(e){return this._impl.setViewportPadding(e),this}}const hc={container:"mapgl_54Xq9OUdARA-",text:"mapgl_qYE18V9u8c0-"},Yb=s=>`
    <div class=${hc.container}>
        <div class=${hc.text}>${s}</div>
    </div>
`;class Qb extends Gt{constructor(e,t){super(e,Yb(t),{position:"bottomLeft"})}}const Jb={attributes:{},attribution:"",minZoom:kn.minZoom,maxZoom:kn.maxZoom};class Ab{constructor(e,t){this.options=Xe(t,Jb),this._impl=new Al(e._impl,this.options,this),this._attribution=new Qb(e,this.options.attribution)}destroy(){this._impl.destroy(),this._attribution.destroy()}setAttributes(e){return this._impl.setAttributes(e),this}getAttributes(){return this._impl.getAttributes()}}const Xn=class Xn{constructor(e,t){this.options=t;const i=this.prepareOptions(this.options,e);this._impl=new Yn(e._impl,i,this)}destroy(){this._impl.destroy()}setAttributes(e){return this._impl.setAttributes(e),this}getAttributes(){return this._impl.getAttributes()}setFeatureStateMap(e){this._impl.setFeatureStateMap(e)}prepareOptions(e,t){var o,a,r,l,c,d,_,u,h,f;const i={tileServer:(o=e.tileServer)!=null?o:"",tileSet:(a=e.tileSet)!=null?a:"",tileProtocol:(r=e.tileProtocol)!=null?r:"",tileKey:(l=e.tileKey)!=null?l:"",subdomains:(c=e.subdomains)!=null?c:e.layerId?["0,1,2,3"]:[""],appId:(d=e.appId)!=null?d:t._impl.state.appId,tileTemplateUrl:e.tileTemplateUrl,metatileTemplateUrl:e.metatileTemplateUrl,defaultLang:e.defaultLang,sessionId:e.sessionId,sourceAttributes:e.sourceAttributes,modelsPath:e.modelsPath,disableTilesAnimation:e.disableTilesAnimation,promoteAttributes:e.promoteAttributes,promoteId:e.promoteId,idScope:e.idScope,modelsAppearStrategy:e.modelsAppearStrategy,minZoom:(_=e.minZoom)!=null?_:9,maxZoom:(u=e.maxZoom)!=null?u:15,maxDetailLevel:(h=e.maxGenerateZoom)!=null?h:17,strokeMinZoom:(f=e.strokeMinZoom)!=null?f:8};return e.layerId&&(i.tileTemplateUrl||(i.tileTemplateUrl=`${Bl}?ts=userdata&x={x}&y={y}&z={z}&layer=${e.layerId}`),i.metatileTemplateUrl||(i.metatileTemplateUrl=`${Bl}/file/{hash}?ts=userdata&layer=${e.layerId}`)),i}};Xn.tileTemplateUrl="{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",Xn.metatileTemplateUrl="{protocol}://{host}/v2/ald/file/{hash}.json?ts={tileSet}";let Ss=Xn;function ew(s){const e=s.split("?")[1];if(!e)return;const i=e.split("&").map(o=>o.split("=")).find(o=>o[0]==="callback");if(i)return i[1]}setTimeout(()=>{const s=Array.from(document.querySelectorAll("script")).find(t=>t.src.match(cy));if(!s)return;const e=ew(s.src);if(e)if(typeof window[e]=="function")window[e]();else throw new Error(`Not found callback function with name "${e}"`)},0),setTimeout(()=>{if("__mapglPlugins"in window)for(const s in window.__mapglPlugins)window.mapgl[s]=window.__mapglPlugins[s]},0);function tw(s){xv(s)}const Ts="v1.71.0";A.API_VERSION=Ts,A.Circle=Ob,A.CircleMarker=kb,A.Control=Gt,A.DefaultSource=dc,A.FloorControl=rc,A.GeoJsonSource=Xb,A.GeoJsonViewportSource=qb,A.GltfModel=$b,A.HtmlMarker=Fb,A.Label=Bb,A.LngLatBoundsClass=ac,A.Map=Tb,A.Marker=Cb,A.Polygon=Vb,A.Polyline=Gb,A.Raster=jb,A.RasterTileSource=Ab,A.ScaleControl=cc,A.TrafficControl=tc,A.ZenithSource=Ss,A.ZoomControl=ec,A._J=Ax,A.isSupported=ud,A.isTerrainSupported=Ds,A.notSupportedReason=Ns,A.setWorkerUrl=tw,A.terrainNotSupportedReason=Sd,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
