(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 T_=Object.defineProperty,S_=Object.defineProperties;var E_=Object.getOwnPropertyDescriptors;var ba=Object.getOwnPropertySymbols;var Vm=Object.prototype.hasOwnProperty,Hm=Object.prototype.propertyIsEnumerable;var re=Math.pow,jm=(m,He,ze)=>He in m?T_(m,He,{enumerable:!0,configurable:!0,writable:!0,value:ze}):m[He]=ze,de=(m,He)=>{for(var ze in He||(He={}))Vm.call(He,ze)&&jm(m,ze,He[ze]);if(ba)for(var ze of ba(He))Hm.call(He,ze)&&jm(m,ze,He[ze]);return m},ve=(m,He)=>S_(m,E_(He));var $m=(m,He)=>{var ze={};for(var bt in m)Vm.call(m,bt)&&He.indexOf(bt)<0&&(ze[bt]=m[bt]);if(m!=null&&ba)for(var bt of ba(m))He.indexOf(bt)<0&&Hm.call(m,bt)&&(ze[bt]=m[bt]);return ze};var Le=(m,He,ze)=>new Promise((bt,mr)=>{var Ia=an=>{try{us(ze.next(an))}catch(ds){mr(ds)}},Ma=an=>{try{us(ze.throw(an))}catch(ds){mr(ds)}},us=an=>an.done?bt(an.value):Promise.resolve(an.value).then(Ia,Ma);us((ze=ze.apply(m,He)).next())});"use strict";const He="tile{subdomain}.maps.2gis.com",ze="jam.api.2gis.com",bt="https://styles.api.2gis.com",mr="https://disk.2gis.com/styles/assets/icons",Ia="https://disk.2gis.com/styles/assets/models",Ma="https://mapgl.2gis.com/api/fonts",us="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",ds="sha512-IyuCqmcNBfZyrExDMisGi0Xhp4PXupx6AMp4cjpKcAzJo+kSmOtRTLbL1xZsfxnsIqci9Q0piqY+kcwl1hCPyw==",Wm="https://mapgl.2gis.com/api/js/plugins",Zm=107.17318798131565,fs=re(2,20),te=re(2,15),Ge=re(2,16)-1,Li=te/Ge,z=16383,Ru=2.54,hs=96,Nu=4294967296/(256/hs*Ru),Ne=.7071067811865475,Xm=4294967295,qm=1175494351e-47,Jm=3402823466e29,yr=["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"],Di="Noto_Sans",ku=1/2,Bu=-4,Ta=2147483647,Km="c080bb6a-8134-4993-93a1-5b4d8c36a59b",Qm=5,gr=4,Sa=40,e1=65e3,Uu="byModel",t1=65536,n1=512,zu="empty",Ea={minZoom:2,maxZoom:20},ei={protocol:"https",server:He,subdomains:"0123",tileSet:"vector_a",tileKey:zu,appId:"empty",cacheRatio:2,maxUniverseZoom:8,maxRegionalZoom:15,maxDetailLevel:17},Aa={minZoom:10,maxZoom:14,tileSet:"com_poi_web",rasterSizes:[96,84,72,60,48,36,24]},Gu={minZoom:15,maxZoom:15,tileSet:"vector_immersive"},ju={tileSet:"dem"},Vu=100,xa=13.5,cn=[2048,2048],wr={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}"},Hu={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)},zt={defaultUrl:Ma,gamma:.08,baseSize:24,baseLineHeight:1.2,bomCharCode:65279},$u={defaultUrl:mr},Yu={url:bt,path:"styles/{id}"},Wu={doubleClickTime:185,dragThreshold:2,pitchWaitingTime:200,pitchThreshold:7},Zu=1e3,ps={inAnimationTime:180,inAnimationType:"linear",outAnimationTime:800,outAnimationType:"linear"},_a={time:300,type:"linear"},Xu={minStyleZoom:16,duration:500,easing:"easeOutQuint"},qu={bounceType:"easeOutElastic",bounceTime:1200,growType:"easeInOutQuad",growTime:1200,stagger:0,iterationCount:1/0},Pa={pixelDensity:.5,sceneOpacity:0,cacheRefreshTime:300,pickDistance:3},vr={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},Ju={0:vr.commercialMargins.city,11:{topBottom:250,leftRight:250},12:{topBottom:170,leftRight:170}},Ku={alwaysRerender:!1,autoResizeInterval:50},Qu="en",ed={macWheelDeltaToZoomDelta:.0018,notMacTrackpadDeltaToZoomDelta:.0018*3,wheelZoomDelta:.65,animDuration:400,throttleDelay:100,mouseRotateDelta:2.5,mousePitchDelta:2.5,mobilePinchDelta:1,mobileTapDelta:10},La={duration:1300,maxSpeed:8,minSpeed:.02,nonLinearity:5},Gt={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},Ln={globeMaxZoom:8,globeInterStartZoom:7,globeInterEndZoom:16},td=1e3,nd=16,Da={enabled:!0,displayStyleZoom:{default:18,metro:16},detailLevel:16,wallMinBrightness:.8265,wallMaxBrightness:.95,viewportPadding:.2,maxStackHeight:40},id={fpsCaveat:10},sd=3e4,Oa=["Commercial_poi_city"],Ca=["Commercial_poi_premium"],rd=["Commercial_poi_default","Commercial_poi_custom","Commercial_poi_navi",...Oa,...Ca],od=["Commercial_model","Commercial_model_animated","Commercial_model_on_click"],ad=["s_personal_poi"],cd=["Landmark_poi","Landmark_point"],ld=[105,84,63,42,21],ud="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",dd=[15,46],fd=16,hd={bias:100,textureSize:[2048,2048],shadowRadius:3},i1=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIN_TIERS_STYLE_ZOOM:fd,MAP_DEFAULTS:Ea,atlasSize:cn,buildingAnimation:Xu,cityCommPoiLabelingConfig:Ju,commercialCitySublayers:Oa,commercialModelSublayers:od,commercialPoi:Aa,commercialPremiumSublayers:Ca,commercialSublayers:rd,defaultCameraConfig:Gt,defaultLang:Qu,defaultMarkerAnchor:dd,defaultMarkerIcon:ud,defaultShadowsSettings:hd,dem:ju,entranceAnimation:qu,events:Wu,floors:Da,fonts:zt,globeConfig:Ln,houseHover:ps,icons:$u,identify:Pa,inertia:La,labeling:vr,landmarkPoiSublayers:cd,landmarkRasterSizes:ld,loadModelsInfoStyleZoom:xa,maxZoomForDynamicNear:nd,metricsTimeout:sd,minCalculationScreenHeight:td,modelCacheSize:Vu,models:Gu,performanceCheck:id,personalSublayers:ad,render:Ku,styles:Yu,tileAnimation:_a,tiles:ei,traffic:Hu,urls:wr,workerResetInterval:Zu,zoom:ed},Symbol.toStringTag,{value:"Module"}));function Te(e,t,n){return e=Math.max(e,t),e=Math.min(e,n),e}function br(e){return e===0||Number.isNaN(e)?e:e>0?1:-1}function s1(e,t){return[t[0]/e[0]*2-1,-(t[1]/e[1])*2+1]}function be(e){return e*Math.PI/180}function ti(e){return e/Math.PI*180}function pd(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 Dn(e,t){const n=de({},t);for(const i in e)e[i]!==void 0&&(n[i]=e[i]);return n}function Fa(e){const t={};for(const n in e){const i=e[n];t[i]=n}return t}function md(e,t){const n=[];for(const i in e)t[i]||n.push(e[i]);return n}function Ra(e,t,n){return Te((n-e)/(t-e),0,1)}function r1(e){return e%1}function Na(e,t,n){return e>=t&&e<=n}function o1(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 a1(e,t){return e===t?!0:e.length!==t.length?!1:!e.some((n,i)=>n!==t[i])}function Oi(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(!Oi(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,u=t instanceof RegExp;if(l!==u)return!1;if(l&&u)return e.toString()===t.toString();const d=Object.keys(e);if(r=d.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,d[s]))return!1;for(s=r;s--!==0;)if(o=d[s],!Oi(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function c1(e,t){const n=e.indexOf(t);return n!==-1?(e.splice(n,1),!0):!1}function Ci(e,t,n){return e+(t-e)*n}function l1(e){return e==null}function Ir(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 yd{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 u1(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gd(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 It=1e-6;let Mt=typeof Float64Array!="undefined"?Float64Array:Array;function Ce(){let e=new Mt(2);return e[0]=0,e[1]=0,e}function d1(e){let t=new Mt(2);return t[0]=e[0],t[1]=e[1],t}function ka(e,t){let n=new Mt(2);return n[0]=e,n[1]=t,n}function Mr(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 jt(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Ba(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function f1(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function h1(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e}function _t(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function ms(e,t){var n=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(n*n+i*i)}function Tr(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)}function p1(e){var t=e[0],n=e[1];return t*t+n*n}function On(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 Cn(e,t){return e[0]*t[0]+e[1]*t[1]}function Ua(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 Sr(e,t){return e[0]===t[0]&&e[1]===t[1]}function m1(e,t){let n=e[0],i=e[1],s=t[0],r=t[1];return Math.abs(n-s)<=It*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-r)<=It*Math.max(1,Math.abs(i),Math.abs(r))}const wd=Tr,ln=Ba,Fn=ms;(function(){let e=Ce();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 vd(){let e=new Mt(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 y1(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 g1(e,t,n,i,s,r,o,a,c,l,u,d,f,h,g,w){let p=new Mt(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]=u,p[11]=d,p[12]=f,p[13]=h,p[14]=g,p[15]=w,p}function w1(e,t,n,i,s,r,o,a,c,l,u,d,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]=u,e[10]=d,e[11]=f,e[12]=h,e[13]=g,e[14]=w,e[15]=p,e}function za(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 v1(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 ys(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],u=t[8],d=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,M=n*l-r*o,E=i*c-s*a,A=i*l-r*a,D=s*l-r*c,_=u*w-d*g,O=u*p-f*g,U=u*y-h*g,B=d*p-f*w,$=d*y-h*w,V=f*y-h*p,T=b*V-v*$+M*B+E*U-A*O+D*_;return T?(T=1/T,e[0]=(a*V-c*$+l*B)*T,e[1]=(s*$-i*V-r*B)*T,e[2]=(w*D-p*A+y*E)*T,e[3]=(f*A-d*D-h*E)*T,e[4]=(c*U-o*V-l*O)*T,e[5]=(n*V-s*U+r*O)*T,e[6]=(p*M-g*D-y*v)*T,e[7]=(u*D-f*M+h*v)*T,e[8]=(o*$-a*U+l*_)*T,e[9]=(i*U-n*$-r*_)*T,e[10]=(g*A-w*M+y*b)*T,e[11]=(d*M-u*A-h*b)*T,e[12]=(a*O-o*B-c*_)*T,e[13]=(n*B-i*O+s*_)*T,e[14]=(w*v-g*E-p*b)*T,e[15]=(u*E-d*v+f*b)*T,e):null}function Ga(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],u=t[7],d=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],M=n[1],E=n[2],A=n[3];return e[0]=v*i+M*a+E*d+A*w,e[1]=v*s+M*c+E*f+A*p,e[2]=v*r+M*l+E*h+A*y,e[3]=v*o+M*u+E*g+A*b,v=n[4],M=n[5],E=n[6],A=n[7],e[4]=v*i+M*a+E*d+A*w,e[5]=v*s+M*c+E*f+A*p,e[6]=v*r+M*l+E*h+A*y,e[7]=v*o+M*u+E*g+A*b,v=n[8],M=n[9],E=n[10],A=n[11],e[8]=v*i+M*a+E*d+A*w,e[9]=v*s+M*c+E*f+A*p,e[10]=v*r+M*l+E*h+A*y,e[11]=v*o+M*u+E*g+A*b,v=n[12],M=n[13],E=n[14],A=n[15],e[12]=v*i+M*a+E*d+A*w,e[13]=v*s+M*c+E*f+A*p,e[14]=v*r+M*l+E*h+A*y,e[15]=v*o+M*u+E*g+A*b,e}function bd(e,t,n){let i=n[0],s=n[1],r=n[2],o,a,c,l,u,d,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],u=t[4],d=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]=u,e[5]=d,e[6]=f,e[7]=h,e[8]=g,e[9]=w,e[10]=p,e[11]=y,e[12]=o*i+u*s+g*r+t[12],e[13]=a*i+d*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 ja(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],u=t[9],d=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+u*i,e[6]=a*s+d*i,e[7]=c*s+f*i,e[8]=l*s-r*i,e[9]=u*s-o*i,e[10]=d*s-a*i,e[11]=f*s-c*i,e}function Id(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],u=t[9],d=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-u*i,e[2]=a*s-d*i,e[3]=c*s-f*i,e[8]=r*i+l*s,e[9]=o*i+u*s,e[10]=a*i+d*s,e[11]=c*i+f*s,e}function Er(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],u=t[5],d=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+u*i,e[2]=a*s+d*i,e[3]=c*s+f*i,e[4]=l*s-r*i,e[5]=u*s-o*i,e[6]=d*s-a*i,e[7]=f*s-c*i,e}function b1(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 Md(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)<It?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 I1(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],c=s+s,l=r+r,u=o+o,d=s*c,f=s*l,h=s*u,g=r*l,w=r*u,p=o*u,y=a*c,b=a*l,v=a*u,M=i[0],E=i[1],A=i[2];return e[0]=(1-(g+p))*M,e[1]=(f+v)*M,e[2]=(h-b)*M,e[3]=0,e[4]=(f-v)*E,e[5]=(1-(d+p))*E,e[6]=(w+y)*E,e[7]=0,e[8]=(h+b)*A,e[9]=(w-y)*A,e[10]=(1-(d+g))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function M1(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 Va(e,t,n,i){let s,r,o,a,c,l,u,d,f,h,g=t[0],w=t[1],p=t[2],y=i[0],b=i[1],v=i[2],M=n[0],E=n[1],A=n[2];return Math.abs(g-M)<It&&Math.abs(w-E)<It&&Math.abs(p-A)<It?mat4.identity(e):(u=g-M,d=w-E,f=p-A,h=1/Math.sqrt(u*u+d*d+f*f),u*=h,d*=h,f*=h,s=b*f-v*d,r=v*u-y*f,o=y*d-b*u,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=d*o-f*r,c=f*s-u*o,l=u*r-d*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]=u,e[3]=0,e[4]=r,e[5]=c,e[6]=d,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]=-(u*g+d*w+f*p),e[15]=1,e)}function T1(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 Ri=Ga;function Ar(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 Td=6378137,Ha=2*Math.PI*Td,Ie=4294967296/Ha,S1=Ar([],[-1,-1,0],[2,2,1]),E1=Ar([],[.5,.5,0],[.5,.5,1]),ni=Td*(Math.PI/2),ot=re(2,15)/4294967296;function $a(e){return Math.max(e,td)}function Ni(e,t){const n=Gt,i=$a(t[1])/2,s=4294967296/re(2,e),r=i/256*s,o=Math.tan(n.fov/2);return r/o}function A1(e,t){const n=Gt;return Math.log($a(t[1])*4294967296/(2*256*Math.tan(n.fov/2)*e))/Math.LN2}function x1(e){return Nu*Math.pow(2,-e)}function _1(e,t){return re(2,Math.round(e)-t.coords[2])}function P1(e,t){return Ru*(e/hs)/t}function Ya(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 L1(e){let t=0;if(e.length>1)for(let n=0;n<e.length-1;n++)t+=Ya(e[n],e[n+1]);return t}const D1={min:[-2147483648,-2147483648],max:[4294967296/2,4294967296/2]},O1={min:[-214748364800,-2147483648],max:[4294967296*100/2,4294967296/2]};function gs(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 Sd(e,t){return e*Math.pow(2,-t)*4294967296/256}function C1(e,t){return e*Math.pow(2,t)*256/4294967296}function Ed(e,t){return e===0?-1/0:-Math.log(t*256/(e*4294967296))/Math.LN2}const Wa=Ce(),Ad=Ce();function F1(e,t,n){Ba(Wa,n,e),Ba(Ad,t,e);const i=Cn(Wa,Ad)/Tr(Wa);return Math.atan2(i,e[2])}function R1(e){const t=e[0],n=e[1];return Na(t,-2147483648,2147483648)&&Na(n,-2147483648,2147483648)}function N1(e){const t=[...e];return R1(t)||(t[0]=(4294967296+(t[0]+2147483648)%4294967296)%4294967296-2147483648),t}function xr(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 k1(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])),[ti(r[0]),ti(r[1])]}function yt(){let e=new Mt(3);return e[0]=0,e[1]=0,e[2]=0,e}function B1(e){var t=new Mt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Rn(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 Mt(3);return i[0]=e,i[1]=t,i[2]=n,i}function Za(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 ii(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function U1(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Nn(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function xd(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 z1(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 G1(e){let t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function _d(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Jt(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 Xa(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ws(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 si(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 vs(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 j1(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],u=l*i+a*r-c*s,d=l*s+c*i-o*r,f=l*r+o*s-a*i,h=-o*i-a*s-c*r;return e[0]=u*l+h*-o+d*-c-f*-a,e[1]=d*l+h*-a+f*-o-u*-c,e[2]=f*l+h*-c+u*-a-d*-o,e}function V1(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 H1(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 $1(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 Y1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function W1(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)<=It*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-o)<=It*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=It*Math.max(1,Math.abs(s),Math.abs(a))}const Kt=U1,qa=xd,Z1=z1,_r=Rn;(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 bs(){let e=new Mt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function X1(e,t,n,i){let s=new Mt(4);return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s}function Pd(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function q1(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function J1(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 K1(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 Q1(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 ey(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 Pr(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 ty(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)<=It*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=It*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=It*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(r-l)<=It*Math.max(1,Math.abs(r),Math.abs(l))}const ny=J1;(function(){let e=bs();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 ri=bs();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*ti(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=Ni(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;ri[0]=t[0],ri[1]=t[1],ri[2]=t[2],ri[3]=1,Pr(ri,ri,this.camera.viewProjectionMatrix);const[o,a,c,l]=ri,u=l*2;if(n&&(c>u||c<-u||o>u||o<-u||a>u||a<-u))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,vs(n,n,this.camera.viewProjectionMatrixInverse),n[0]-=this.position[0],n[1]-=this.position[1],n[2]-=this.position[2],Jt(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 oi=bs();function Ld(e){return[e[2],e[0],e[1]]}class nt{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0],this.ivpMatrix=[],this.cachedVisibleArc=new yd(()=>{const i=Ni(this.state.zoom,this.state.size)/Ie;return Math.acos(ni/(ni+i))},()=>[this.state.zoom]),this.cachedPixelRadius=new yd(()=>{const i=oe.toGeo(this.state.center),s=k1(i,0,this.visibleArc),r=this.project(nt.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,wd(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=ni*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]=ti(c),n[1]=ti(a),n}update(){const{state:t}=this,n=oe.toGeo(t.center),i=Ni(t.zoom,t.size)+ni*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 u=[0,0,1];Va(this.ivpMatrix,Ld(this.position),[0,0,0],u),Ri(this.ivpMatrix,this.camera.projectionMatrix,this.ivpMatrix),ys(this.ivpMatrix,this.ivpMatrix)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state,o=bs();oi[0]=t[0],oi[1]=t[1],oi[2]=t[2],oi[3]=1,Pr(oi,oi,this.camera.globeMatrix),Pr(o,oi,this.camera.viewProjectionMatrix);const[a,c,l,u]=o,d=u*2;if(n&&(l>d||l<-d||a>d||a<-d||c>d||c<-d))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/u,i[1]=g+r.top-c*g/u,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=Ld(this.position),c=[0,0,0,1];vs(c,o,this.ivpMatrix);const l=Jt([],Kt([],c,a)),u=_d([],a),d=Xa(u,l),f=G1(u)-re(d,2),h=re(ni*Ie,2);if(f>h){if(n)return nt.fromGeo(oe.toGeo(this.state.center));const{left:b,bottom:v,top:M,right:E}=this.state.padding,A=t[0]-r.left-s[0]/2-(b-E)/2,D=t[1]-r.top-s[1]/2-(M-v)/2,_=_t([],On([],[A,D]),this.pixelRadius-1);return _[0]=_[0]+r.left+s[0]/2+(b-E)/2,_[1]=_[1]+r.top+s[1]/2+(M-v)/2,this.unproject(_,!0,i)}const g=Math.sqrt(h-f),w=d-g,p=d+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 xr(n,t)<this.visibleArc}}const iy=[0,0,1],sy=yt(),Pt=[0,0,0];class Is{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 nt(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}=Ln;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(),Ga(this.viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),ys(this.viewProjectionMatrixInverse,this.viewProjectionMatrix),ys(this.projectionMatrixInverse,this.projectionMatrix),v1(this.viewMatrixTranspose,this.viewMatrix),this.state.globeMode&&this.updateGlobeMatrix(),Ri(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(nt.fromGeo(t),n,i);{const s=this.flat.project(oe.fromGeo(t),n),r=this.ecef.project(nt.fromGeo(t),n);return Array.from(si(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),nt.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),nt.toGeo(r,r),i?(Ja(this,t,r,s,n,2),n[2]=0,n):(si(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=Ni(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:u}=r,{globeInterEndZoom:d,globeMaxZoom:f}=Ln;if(this.correctedPitch=i,this.correctedRotation=s,n<u){const h=Math.max(0,n-l)/(u-l);this.correctedPitch=Math.min(i,Ci(a!=null?a:90,c!=null?c:90,h))}if(o.globeEnabled&&n<d){const h=Math.max(0,n-f)/(d-f);if(this.correctedPitch=Math.min(this.correctedPitch,Ci(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,u=a*l,d=-u/2;d+=o.x*u/r[0],c-=o.y*l/r[1],u*=o.width/r[0],l*=o.height/r[1];const f=d+u,h=c-l,g=this.projectionMatrix;g[0]=2*i/(f-d),g[5]=2*i/(c-h),g[8]=(f+d)/(f-d),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,ys(this.projectionMatrixInverse,this.projectionMatrix)}updateNearFarState(){const{zoom:t,cameraConfig:n}=this.state,i=this.position;if(t>nd)n.near=Gt.near;else{const o=.25*i[2],a=Math.min(16-t,1);n.near=o*a+Gt.near*(1-a)}const s=re(1-Math.min(t,20.5)/21,2);n.far=Gt.far*s}restoreFixedNearFar(){const{cameraConfig:t}=this.state;t.near=Gt.near,t.far=Gt.far}correctViewAndSize(){const{size:t,padding:n}=this.state,i=Math.max(0,n.top-n.bottom)*Math.tan(this.correctedPitch),s=$a(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=qa(this.position,t);this.fogDistance=Math.max(n.minFogDistance,i)}updateViewMatrix(){Va(this.viewMatrix,this.position,this.state.center,iy)}updateGlobeMatrix(){const t=this.globeMatrix,n=[0,0,0];za(t);const i=oe.toGeo(this.state.center);Oe(n,this.state.center[0],this.state.center[1],-this.state.center[2]-ni*Ie),bd(this.globeMatrix,t,n),ja(t,t,be(i[1])),Id(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]);Kt(Pt,o,s),$1(Pt,Pt,sy,be(90)),Jt(Pt,Pt);const a=Sd(n[1]*this.state.cameraConfig.perspectiveDistanceLimitRatio,i);Nn(Pt,Pt,a),ii(Pt,r,Pt),this.flat.project(Pt,!1,Pt),this.horizonPixelOffset=Math.max(0,Math.ceil(Pt[1]))}}function Ja(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),u=Fn(l,t),d=Fn(a,t),f=Fn(c,t);if(u<r)return s;if(d<r)return n;if(f<r)return i;if(o>=10)return s;const h=d+u,g=f+u;return h>g?Ja(e,t,i,s,s,r,o+1):Ja(e,t,n,s,s,r,o+1)}function ry(e,t,n){n.zoom!==void 0&&(n.zoom=Te(n.zoom,e.minZoom,e.maxZoom));const i=de({},e);gs(i.center);const s=new Is(i),r=s.unproject(t),o=oe.fromGeo(r);n.center&&gs(n.center),s.setState(de(de({},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(Kt(c,o,a),e.globeMode&&Math.abs(r[1])>70&&e.zoom>Ln.globeInterStartZoom&&e.zoom<Ln.globeMaxZoom){const l=Math.abs(e.zoom-n.zoom);if(l>1e-4){const u=Math.abs(o[0]-a[0]),d=Math.log10(u/l),f=Math.min(1,re(10,6-d));Number.isNaN(f)||Nn(c,c,f)}}return c}function Dd(e){const n=oe.toGeo(e)[1],i=1/(2*Math.cos(be(n)));return Math.log(i)/Math.log(2)}function oy(e,t){const n=oe.scaleFactor(t[1]);return 1+e*(n-1)}function Od(e,t){const n=Dd(t)*Ra(9,10,e);return e+Te(n,-1,0)}function ay(e,t){const n=Dd(t),i=n*Ra(9,10+n,e);return e-Te(i,-1,0)}function cy(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 u=Gt,d=new Is({center:oe.fromGeo(e),zoom:t,rotation:be(n),size:i,pitch:be(s),viewport:o,padding:a,cameraConfig:u,globeMode:!1,styleState:{}}),f=oe.toGeo(d.flat.unproject(r)),h=oe.toGeo(d.flat.unproject([r[0]+c,r[1]+l]));return Math.max(1,Ya(f,h))}function Lr(e,t){return t*Ie*oe.scaleFactor(e[1])}function Ms(e,t){return{min:e||ka(1/0,1/0),max:t||ka(-1/0,-1/0)}}function ly(e){return Ms(oe.fromGeo(e.southWest),oe.fromGeo(e.northEast))}function ai(e,t){f1(e.min,e.min,t),h1(e.max,e.max,t)}function Cd(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 Ka(e){e.min[0]=1/0,e.max[0]=-1/0,e.min[1]=1/0,e.max[1]=-1/0}function Dr(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 uy(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 dy(e,t,n){e[1]=Te(n[1],t.min[1],t.max[1])}function fy(e,t){return t[0]<=e.max[0]&&t[0]>=e.min[0]&&t[1]<=e.max[1]&&t[1]>=e.min[1]}function hy(e,t){return t[1]<=e.max[1]&&t[1]>=e.min[1]}function Qa(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 py(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 my(e,t){const n=Dr([],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 ec(){let e=new Mt(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 yy(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 gy(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],u=t[7],d=t[8],f=n[0],h=n[1],g=n[2],w=n[3],p=n[4],y=n[5],b=n[6],v=n[7],M=n[8];return e[0]=f*i+h*o+g*l,e[1]=f*s+h*a+g*u,e[2]=f*r+h*c+g*d,e[3]=w*i+p*o+y*l,e[4]=w*s+p*a+y*u,e[5]=w*r+p*c+y*d,e[6]=b*i+v*o+M*l,e[7]=b*s+v*a+M*u,e[8]=b*r+v*c+M*d,e}function Or(){let e=new Mt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function wy(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function vy(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 by(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 Iy(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 Cr(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],c=n[0],l=n[1],u=n[2],d=n[3],f,h,g,w,p;return h=s*c+r*l+o*u+a*d,h<0&&(h=-h,c=-c,l=-l,u=-u,d=-d),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*u,e[3]=w*a+p*d,e}function My(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 Fd=Q1;(function(){let e=yt(),t=at(1,0,0),n=at(0,1,0);return function(i,s,r){let o=Xa(s,r);return o<-.999999?(ws(e,t,s),_r(e)<1e-6&&ws(e,n,s),Jt(e,e),vy(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(ws(e,s,r),i[0]=e[0],i[1]=e[1],i[2]=e[2],i[3]=1+o,Fd(i,i))}})(),(function(){let e=Or(),t=Or();return function(n,i,s,r,o,a){return Cr(e,i,o,a),Cr(t,s,r,a),Cr(n,e,t,2*a*(1-a)),n}})(),(function(){let e=ec();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],Fd(t,My(t,e))}})();const Qt=[0,0,0],en=[0,0,0],tc=yt();ec();function Vt(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 Rd(e,t,n,i){return Kt(Qt,n,t),Kt(en,n,i),ws(e,en,Qt),Jt(e,e),e}function tn(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 Nd(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,Tr(e)>c&&On(e,e)}else e[0]=0,e[1]=0}function $e(e){return Te(e*127,-127,127)}function nc(e,t=e){return e[0]=$e(t[0]),e[1]=$e(t[1]),e}function Ty(e,t,n,i,s){e[0]=t*i+n*s,e[1]=n*i-t*s}function kn(e,t){const n=t[0];e[0]=-t[1],e[1]=n}function ic(e,t){const n=t[0];e[0]=t[1],e[1]=-n}function Sy(e){return e[0]===0&&e[1]===0}function Ey(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])}function Ay(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function xy(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 _y(e,t,n,i,s=!0){if(Sr(t,n)||Sr(n,i)){je(e,0,0);return}ln(Qt,n,t),ln(en,i,n),s?(kn(Qt,Qt),kn(en,en)):(ic(Qt,Qt),ic(en,en)),On(Qt,Qt),On(en,en),jt(e,Qt,en),On(e,e)}function Py(e,t,n){t[0]=Rn(Oe(tc,e[0],e[1],e[2])),t[1]=Rn(Oe(tc,e[3],e[4],e[5])),t[2]=Rn(Oe(tc,e[6],e[7],e[8]))}function Ly(e,t,n,i){t[0]=Rn(at(e[0],e[1],e[2])),t[1]=Rn(at(e[4],e[5],e[6])),t[2]=Rn(at(e[8],e[9],e[10])),n[0]=e[12],n[1]=e[13],n[2]=e[14]}function Dy(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 sc=/\{(\w+)\}/g;function Ts(e,t){return e.replace(sc,(n,i)=>t[i])}function kd(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 Oy(e,t){return(typeof e=="object"?e.url:wr[e]).replace(sc,(n,i)=>{var s;return(s=t[i])!=null?s:n}).replace(sc,(n,i)=>{var s;return(s=t[i])!=null?s:n})}function Ss(e,t){const n=Ts(t.host,{subdomain:t.subdomain}),i=Ts(typeof e=="object"?e.url:wr[e],ve(de({},t),{host:n}));return kd(i)}function Es(e,t){const n=Ts(e,t);return kd(n)}function rc(e,t){let n=0;for(let i=0;i<t.length;i++)n+=t.charCodeAt(i);return e[n%e.length]}function Cy(e,t){const n=new URL(t);return e.startsWith("//")?`${n.protocol}${e}`:e.startsWith("/")?`${n.origin}${e}`:e}for(var ki="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Fy=typeof Uint8Array=="undefined"?[]:new Uint8Array(256),Fr=0;Fr<ki.length;Fr++)Fy[ki.charCodeAt(Fr)]=Fr;var Bd=function(e){var t=new Uint8Array(e),n,i=t.length,s="";for(n=0;n<i;n+=3)s+=ki[t[n]>>2],s+=ki[(t[n]&3)<<4|t[n+1]>>4],s+=ki[(t[n+1]&15)<<2|t[n+2]>>6],s+=ki[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 Ry(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*re(256,e.length-1-n);return t}function Ud(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(Bd(t.buffer))}function Ny(e,t){var s,r,o,a,c,l;const n={};e.forEach((u,d)=>{n[u]=d});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 u in t)n[u]===void 0&&(n[u]=i++);return n}function zd(e){const t=Ny(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]=Fa(e.enumerationValues[s]),i),{}),tileProps:t,tilePropsByIndex:Fa(t),defaultProps:n,vertexPropsLegacy:ac(e.vertexProps)?ky(e):{},vertexProps:ac(e.vertexProps)?[]:e.vertexProps}}function ky(e){const t=e.vertexProps,n={point:["x","y","z"],polygon:["x","y","cut","signed_z"],polyline:["x","y"]};if(!t)return n;if(!ac(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 Gd(e,t){const n={};if(t)for(let i=0;i<t.length;i++)n[t[i]]=i;return zd({enumerationValues:{db_sublayer:n},version:"7.0.0",defaultProps:{},tileProps:e,vertexProps:[]})}function As(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 ci={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++},By={version:"5.0.0",tileProps:ci,tilePropsByIndex:Fa(ci),defaultProps:{},dictionaries:{},reverseDictionaries:{},vertexPropsLegacy:{},vertexProps:[]},jd=[],oc={},Vd={sourceName:"zenith"};function ac(e){return!Array.isArray(e)}class cc{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 Uy=1;function lc(){return Uy++}let zy=1;const uc=()=>++zy,Gy=uc(),jy=uc(),dc=65536*65536,Hd=1/dc,Vy=12,$d=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8"),fc=0,Rr=1,xs=2,Nr=5;class kr{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)*dc;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*dc;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,Hy(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>=Vy&&$d?$d.decode(this.buf.subarray(n,t)):ig(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===xs?this.readVarint()+this.pos:this.pos+1}skip(t){const n=t&7;if(n===fc)for(;this.buf[this.pos++]>127;);else if(n===xs)this.pos=this.readVarint()+this.pos;else if(n===Nr)this.pos+=4;else if(n===Rr)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*Hd),!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*Hd),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){$y(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=sg(this.buf,t,this.pos);const i=this.pos-n;i>=128&&Yd(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&&Yd(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeMessage(t,n,i){this.writeTag(t,xs),this.writeRawMessage(n,i)}writePackedVarint(t,n){n.length&&this.writeMessage(t,Zy,n)}writePackedSVarint(t,n){n.length&&this.writeMessage(t,Xy,n)}writePackedBoolean(t,n){n.length&&this.writeMessage(t,Ky,n)}writePackedFloat(t,n){n.length&&this.writeMessage(t,qy,n)}writePackedDouble(t,n){n.length&&this.writeMessage(t,Jy,n)}writePackedFixed32(t,n){n.length&&this.writeMessage(t,Qy,n)}writePackedSFixed32(t,n){n.length&&this.writeMessage(t,eg,n)}writePackedFixed64(t,n){n.length&&this.writeMessage(t,tg,n)}writePackedSFixed64(t,n){n.length&&this.writeMessage(t,ng,n)}writeBytesField(t,n){this.writeTag(t,xs),this.writeBytes(n)}writeFixed32Field(t,n){this.writeTag(t,Nr),this.writeFixed32(n)}writeSFixed32Field(t,n){this.writeTag(t,Nr),this.writeSFixed32(n)}writeFixed64Field(t,n){this.writeTag(t,Rr),this.writeFixed64(n)}writeSFixed64Field(t,n){this.writeTag(t,Rr),this.writeSFixed64(n)}writeVarintField(t,n){this.writeTag(t,fc),this.writeVarint(n)}writeSVarintField(t,n){this.writeTag(t,fc),this.writeSVarint(n)}writeStringField(t,n){this.writeTag(t,xs),this.writeString(n)}writeFloatField(t,n){this.writeTag(t,Nr),this.writeFloat(n)}writeDoubleField(t,n){this.writeTag(t,Rr),this.writeDouble(n)}writeBooleanField(t,n){this.writeVarintField(t,+n)}}function Hy(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 Bi(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function Bi(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function $y(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),Yy(n,i,t),Wy(i,t)}function Yy(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 Wy(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 Yd(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 Zy(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function Xy(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function qy(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 Ky(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function Qy(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function eg(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function tg(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function ng(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function ig(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,u;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],u=e[s+3],(c&192)===128&&(l&192)===128&&(u&192)===128&&(o=(r&15)<<18|(c&63)<<12|(l&63)<<6|u&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 sg(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 li(e,t){return{a:e[1]-t[1],b:t[0]-e[0],c:e[0]*t[1]-t[0]*e[1]}}function rg(e,t){return Math.abs(Wd(e,t))}function Wd(e,t){return(t.a*e[0]+t.b*e[1]+t.c)/Math.sqrt(t.a*t.a+t.b*t.b)}function og(e,t,n){const{a:i,b:s,c:r}=li(e,t);return at(n,-(i*n+r)/s,0)}function ag(e,t,n){const{a:i,b:s,c:r}=li(e,t);return at(-(s*n+r)/i,n,0)}const ui=Ms(),gt=Ms();function cg(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],u=t[a];let d=l;if(u>i){if(!c){const f=(i-r)/(u-r);c=[],Ua(c,s,l,f)}d=c}o.push(d),s=d,r=t[a],a++}return o}function lg(e,t){let n=e[0];Ka(ui),ai(ui,n);let i=[n];const s=[i];let r=1;for(;r<e.length;){const o=e[r];let a=!1,c=o;if(Cd(gt,ui),ai(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=og(n,c,l),a=!0}if(a&&(Cd(gt,ui),ai(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=ag(n,c,l),a=!0}a?(i.push(c),Ka(ui),ai(ui,c),i=[c],s.push(i),n=c):(i.push(o),ai(ui,o),n=o,r++)}return s}function ug(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 Br(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 dg(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 Zd(e,t){const n=Br(e);if(!Qa(t,n))return!1;const i=[li(e[3],e[2]),li(e[1],e[0]),li(e[0],e[3]),li(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 fg(e,t,n){e.forEach(i=>{const s=1+t/xd(n,i);si(i,n,i,s)})}function hg(e,t){if(e.tiles)for(const n of e.tiles)t.writeMessage(1,pg,n)}function pg(e,t){e.x&&t.writeVarintField(1,e.x),e.y&&t.writeVarintField(2,e.y),e.zoom&&t.writeVarintField(3,e.zoom)}function mg(e,t){return e.readFields(yg,{tileGroups:[]},t)}function yg(e,t,n){e===1&&t.tileGroups.push(gg(n,n.readVarint()+n.pos))}function gg(e,t){return e.readFields(wg,{x:0,y:0,zoom:0,tiles:[]},t)}function wg(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(vg(n,n.readVarint()+n.pos))}function vg(e,t){return e.readFields(bg,{regionId:0,hash:void 0,data:void 0},t)}function bg(e,t,n){e===1?t.regionId=n.readVarint():e===2?t.hash=n.readBytes():e===3&&(t.data=n.readBytes())}const Ui=[0,0,0];function ct(e){return{coords:e,size:Dt(e[2]),offset:Gi(e)}}function xe(e){return Xd(e[0],e[1],e[2],e[3])}function Xd(e,t,n,i){return`${e}_${t}_${n}_${i}`}function Ig(e,t){return`${xe(e)}_${t.stringify()}`}function hc(e){const t=e.split("_");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}function qd(e){return ei.subdomains[Math.abs(e[0]+e[1])%ei.subdomains.length]}function Mg(e){const t=new kr(e),n=mg(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:Ry(c)}))}function Tg(e){return e.map(t=>({regionId:t.regionId,metatileHash:t.metatileHash}))}function Sg(e){const t=Math.ceil(e.byteLength/4)*4,n=new ArrayBuffer(t);return new Uint8Array(n).set(e),n}function Ur(e){const[t,n,i]=e;return{min:Gi([t,n,i,i]),max:Gi([t+1,n+1,i,i])}}function Eg(e,t){return Qa(Ur(e),Ur(t),.001)}function zr(e,t,n,i=0){const s=Ur(e);return s.min[0]-=i,s.min[1]-=i,s.max[0]+=i,s.max[1]+=i,n.environmentManager.isAABBInFog(s)?!1:Zd(t,s)}function Ag(e){return Math.trunc(e/2)*2+1}function pc(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 xg=(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 Jd(e,t,n){const i=_g(t,e.size),s=Math.trunc(t),r=Array.from(e.center);gs(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(pc(a.min[1],2,4),pc(a.max[1],2,4)),l=Math.max(n,s-c),u=yc(r,l,!0);u[0]=Math.round(u[0]),u[1]=Math.round(u[1]);const d=new Is(e),f=Kd(e,d,o),h=zg(u,o,f,d,e),g=[];return h.forEach(w=>{xg([NaN,2,2,NaN],w)?g.push(...tf(w,1)):g.push(w)}),g.filter(w=>$r(e,d,w))}function _g(e,t){const n=ni*Ie,i=Ni(e,t)+n,s=Gt.fov/2,r=Math.sin(s),o=Math.cos(s),a=n/i;let c=ti(Math.acos(re(r,2)/a+o*Math.sqrt(1-re(r,2)/re(a,2))));return Number.isNaN(c)&&(c=90),c}function Kd(e,t,n){const i=nt.toGeo(t.ecef.unproject([e.viewport.left,e.viewport.top]));return Math.min(3*Math.max(xr(i,n)),t.ecef.visibleArc)}function Pg(e,t,n,i,s,r){const[,,o]=e,a=Dg(e),c=i>=5?2:1,l=pc((a.max[1]+a.min[1])/2,c,3,!0),u=Math.max(Math.abs(a.min[1]),Math.abs(a.max[1])),d=Math.max(n,i-l);return o>=d||u>70&&r>0||u>82||xr(t,[(a.max[0]+a.min[0])/2,(a.max[1]+a.min[1])/2])>.75*s}function Lg(e,t){const i=Math.trunc(e.zoom),s=Array.from(e.center);gs(s),oe.toGeo(s,s);const r=[],o=new Is(e),a=Kd(e,o,s);function c(l,u=0){if(cf(s,a,l)&&$r(e,o,l))if(Pg(l,s,2,i,o.ecef.visibleArc,u))r.push(l);else for(const d of tf(l,1))c(d,u+1)}return Jd(e,Math.trunc(e.zoom),2).map(([l,u,d])=>{c([l,u,d,t])}),r}function Dg(e){return{min:Qd(e),max:Qd([e[0]+1,e[1]+1,e[2],e[3]])}}function Qd(e){const t=Gi(e);return oe.toGeo(t)}function ef(e,t,n,i,s,r=0,o=1/0,a=!1,c=!1){if(e.globeMode)return Lg(e,s);a&&(n=Ag(n),n>o&&(n-=2));const l=Br(e.tilesBounds),u=Dt(n),d=re(2,n),f=Math.floor((l.min[0]+2147483648-r)/u),h=Math.floor((l.max[0]+2147483648+r)/u),g=Math.max(Math.floor((l.min[1]+2147483648-r)/u),0),w=Math.min(Math.floor((l.max[1]+2147483648+r)/u),d-1),p=[],y=new Set;for(let b=f;b<=h;b++)for(let v=g;v<=w;v++){const M=[b,v,n,s];if(zr(M,e.tilesBounds,t,r)){M[0]=(d+M[0]%d)%d;const E=xe(M);y.has(E)||(y.add(E),p.push(M))}}return c===!0&&Og(p,y,e,t,n,i,s),p}function Og(e,t,n,i,s,r,o){const a=new Set,c=dg(n.tilesBounds);let l=e;for(let u=s;u>=r;u--){let d=0;const f=[];l.forEach(M=>{const E=Cg(M),A=xe(E);a.has(A)||(f.push(E),a.add(A),Fg(E,D=>{const _=xe(D);!t.has(_)&&!a.has(_)&&zr(D,n.extendedTilesBounds,i)&&(e.push(D),t.add(_),d++)}))});const h=Dt(u-1);fg(c,h,n.center);const g=Br(c),w=re(2,u-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 M=p;M<=y;M++)for(let E=b;E<=v;E++){const A=[M,E,u-1,o];A[0]=(w+A[0]%w)%w;const D=xe(A);!a.has(D)&&zr(A,c,i)&&(f.push(A),d++)}if(!d)break;l=f}}function Cg(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 tf(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 Fg(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 Rg(e,t,n,i,s,r,o,a,c,l,u,d){const f=new kr,h={tiles:[{x:s[0],y:s[1],zoom:s[2]}]};hg(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:u,defaultLang:l,dt:d==null?void 0:d.join(","),request:encodeURIComponent(Bd(f.finish()))};return Ss(c?{url:c}:"tiles",g)}function Ng(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?nf(e,t):nf(t,e)}function nf(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 Gr(e,t,n){return ms(e,af(t.coords,Ui))-ms(e,af(n.coords,Ui))}function Tt(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 jr=yt();function sf(e,t,n,i){var s;jr[0]=t[0][n],jr[1]=t[1][n],jr[2]=((s=t[2])!=null?s:[])[n],Tt(e,jr,i)}function Lt(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 Dt(e){return re(2,32-e)}function mc(e){return e[0]>=0&&e[0]<=te&&e[1]>=0&&e[1]<=te}function zi(e,t){return e*4294967296/(te*Math.pow(2,t))}function it(e){return Te(e/fs*te,0,Ge)}const rf=te/fs;function of(e){return e/te*fs}function Gi(e){const t=Dt(e[2]),n=2147483648;return at(e[0]*t-n,e[1]*t-n,0)}function kg(e){return[e[0]+2147483648,e[1]+2147483648,32,32]}function af(e,t){const n=Dt(e[2]),i=2147483648;return Oe(t,(e[0]+.5)*n-i,(e[1]+.5)*n-i,0)}function yc(e,t,n=!1){const s=Dt(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 Bg(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=Ce();return Dr(s,e),yc(s,i)}const Vr=e=>{const[t,n,i,s]=e;return[t,re(2,i)-1-n,i,s]},Ot=(e,t)=>{Tt(Ui,t,e);const n=oe.toGeo(Ui);return oe.scaleFactor(n[1])};function _s(e,t,n){return Tt(Ui,[e,t],n),oe.toGeo(Ui)}function Ug(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 gc(e,t){return nt.fromGeo(_s(t[0],t[1],e))}function Bn(e,t,n,i){const s=[];return Tt(s,i,n),xr(oe.toGeo(s),e)<t}function cf(e,t,n){const i=ct(n),s=te;return Bn(e,t,i,[0,s/2,0])||Bn(e,t,i,[s,s/2,0])||Bn(e,t,i,[s/2,s,0])||Bn(e,t,i,[s/2,0,0])||Bn(e,t,i,[0,0,0])||Bn(e,t,i,[0,s,0])||Bn(e,t,i,[s,s,0])||Bn(e,t,i,[s,0,0])}function Hr(e,t,n){const i=[];return Tt(i,n,t),e.ecef.project(nt.fromGeo(oe.toGeo(i)))}function $r(e,t,n){const[,i,s]=n;if(i===0||i===re(2,s)-1)return!0;const r=ct(n),o=te,a=[Hr(t,r,[0,0,0]),Hr(t,r,[0,o,0]),Hr(t,r,[o,o,0]),Hr(t,r,[o,0,0])],c=a.map(f=>f[0]),l=a.map(f=>f[1]),u={min:[Math.min(...c),Math.min(...l)],max:[Math.max(...c),Math.max(...l)]},d={min:[e.viewport.left,e.viewport.top],max:[e.viewport.left+e.size[0],e.viewport.top+e.size[1]]};return Qa(u,d)}function zg(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 u=c.shift();if(u){const[d,f,h]=u;a.set(d+"."+f+"."+h,!0),Gg(u,a,t,n).filter(w=>$r(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 Gg(e,t,n,i){const[s,r,o,a]=e,c=re(2,o)-1,l=p=>p>c?0:p<0?c:p,u=([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]),d=[l(s-1),r,o,a],f=[l(s+1),r,o,a],h=u([s,r-1,o,a]),g=u([s,r+1,o,a]);return[f,g,h,d].filter(p=>{const[y,b,v]=p;return!t.has(y+"."+b+"."+v)}).filter(p=>cf(n,i,p))}function jg(e,t,n,i=0){return""}var wc=(e=>(e[e.Tile=0]="Tile",e[e.Custom=1]="Custom",e))(wc||{});class Vg{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,lf(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 lf(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,lf(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 Hg(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 $g(e){return e}var di=(e=>(e[e.Striped=1]="Striped",e[e.Entrance=2]="Entrance",e[e.Patterned=3]="Patterned",e))(di||{}),Ps=(e=>(e[e.Line=0]="Line",e[e.Arrow=1]="Arrow",e[e.StartBorder=2]="StartBorder",e[e.LineEnding=3]="LineEnding",e))(Ps||{}),_e=(e=>(e[e.TileCut=0]="TileCut",e[e.Butt=1]="Butt",e[e.Round=2]="Round",e))(_e||{});const Xe=Ce(),Yr=Ce(),ji=Ce(),Un=Ce(),Ls=Ce(),un=Ce(),vc=Ce(),Ct=Ce();let Vi=0,zn=0;function uf(e,t,n,i,s,r,o,a,c,l,u){var d,f,h,g;if(!(r<2)){if(tn(Xe,t[0],n[0],t[1],n[1]),Vi=0,o===_e.Round){const w=l!==void 0?l[0]:0,p=u!==void 0?u[0]:0;bc(e,t[0],n[0],(d=i==null?void 0:i[0])!=null?d: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++)Yg(e,t,n,i,s,w,r,c,l,u);if(a===_e.Round){const w=l!==void 0?l[r-1]:0,p=u!==void 0?u[r-1]:0;bc(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 Yg(e,t,n,i,s,r,o,a,c,l){var h,g,w,p,y,b,v,M,E,A;const u=r===o-1;if(je(Ls,t[r-1],n[r-1]),je(un,t[r],n[r]),c!==void 0&&l!==void 0?(je(ji,c[r-1],l[r-1]),je(Un,c[r],l[r])):(je(ji,0,0),je(Un,0,0)),kn(Ct,Xe),u)zn=0;else{je(vc,t[r+1],n[r+1]),tn(Yr,un[0],un[1],vc[0],vc[1]);const D=Te(Cn(Xe,Yr),-1,1);if(D<=0)zn=0,bc(e,un[0],un[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],Un[0],Un[1],a);else{const O=Math.sqrt((1-D)/(1+D)),U=br(Cn(Ct,Yr));zn=O*U}}Wg(e,0,1,3,3,1,2);const d=Ct[0]*Ne,f=Ct[1]*Ne;fi(e,Ls[0],Ls[1],(w=i==null?void 0:i[r-1])!=null?w:0,(p=s==null?void 0:s[r-1])!=null?p:0,(Ct[0]+Xe[0]*Vi)*Ne,(Ct[1]+Xe[1]*Vi)*Ne,d,f,ji[0],ji[1],a),fi(e,Ls[0],Ls[1],(y=i==null?void 0:i[r-1])!=null?y:0,(b=s==null?void 0:s[r-1])!=null?b:0,(-Ct[0]-Xe[0]*Vi)*Ne,(-Ct[1]-Xe[1]*Vi)*Ne,-d,-f,ji[0],ji[1],a),fi(e,un[0],un[1],(v=i==null?void 0:i[r])!=null?v:0,(M=s==null?void 0:s[r])!=null?M:0,(-Ct[0]+Xe[0]*zn)*Ne,(-Ct[1]+Xe[1]*zn)*Ne,-d,-f,Un[0],Un[1],a),fi(e,un[0],un[1],(E=i==null?void 0:i[r])!=null?E:0,(A=s==null?void 0:s[r])!=null?A:0,(Ct[0]-Xe[0]*zn)*Ne,(Ct[1]-Xe[1]*zn)*Ne,d,f,Un[0],Un[1],a),u||(Mr(Xe,Yr),Vi=zn)}function bc(e,t,n,i,s,r,o,a,c,l){Zg(e,0,1,2);const u=-r*.01,d=-o*.01;fi(e,t,n,i,s,r+u,o+d,r,o,a,c,l),fi(e,t,n,i,s,-o+u,r+d,-o,r,a,c,l),fi(e,t,n,i,s,o+u,-r+d,o,-r,a,c,l)}function fi(e,t,n,i,s,r,o,a,c,l,u,d){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]=u),"localID"in e.views&&(e.views.localID[g]=d),e.elements.offset++}function Wg(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 Zg(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 Fe(e,t,n){return t.precomputes.forEach((i,s)=>{e.push(n.tileData[s])}),e}function Ds(e,t){for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}const Xg={x:0,y:1};function qg(e){const t={};for(const n in e)e[n]&&(t[n]=Array.from(e[n]));return t}function Os(e,t){for(const n in e){const i=Xg[n];i!==void 0?e[n].push(t[i]):e[n].push(NaN)}}const df=32,ff=512;function Jg(e,t,n,i,s){const r=[e[0][0],e[1][0]],o=be(90+i),a=[];Tt(a,r,s);const c=oe.toGeo(a),l=Lr(c,t),u=Lr(c,n),d=Math.sqrt(re(l,2)+re(u,2))/2,f=Math.atan(l/-u)+Math.PI+o,h=d*Math.cos(f),g=d*Math.sin(f),w=Math.atan(-l/-u)+Math.PI+o,p=d*Math.cos(w),y=d*Math.sin(w),b=Math.atan(-l/u)+2*Math.PI+o,v=d*Math.cos(b),M=d*Math.sin(b),E=Math.atan(l/u)+o,A=d*Math.cos(E),D=d*Math.sin(E),_=[],O=[],U=[],B=[];return Lt(_,[a[0]+h,a[1]+g],s),Lt(O,[a[0]+p,a[1]+y],s),Lt(U,[a[0]+v,a[1]+M],s),Lt(B,[a[0]+A,a[1]+D],s),[[_[0],O[0],U[0],B[0]],[_[1],O[1],U[1],B[1]]]}function Wr(e,t){const n=Math.max(e,t);return n*df>ff?ff/n:df}function hf(e){const t=Ot(e,[0,0]);return te/Dt(e.coords[2])*Ie*t}function Kg(e,t,n,i){if(isNaN(e.step)||isNaN(e.width))return n;const{tileProps:s,tileAttrs:r}=i,o=hf(t);let a=e.step*o;if(isNaN(a)&&(a=0),a===0)return n;const c=e.width*o,l={},u=n.x,d=n.y,f=u.length;for(const D in n)l[D]=[];let h=0;const g=[h];for(let D=1;D<f;D++)h+=Fn([u[D-1],d[D-1]],[u[D],d[D]]),g.push(h);const w=Ce(),p=Ce(),y=[0,0],b=Math.abs(h/Math.trunc(h/a)),v=[u[0],d[0]];let M=(e.stopLines?1:-1)*Math.sign(e.width),E=0,A=0;for(Os(l,v),e.stopLines&&!r[s.beginningIsCut]&&(tn(w,u[A],d[A],u[A+1],d[A+1]),kn(p,w),_t(y,p,M*c),jt(v,v,y),Os(l,v),E+=b/2,M=-M);E<=h;){for(;E>g[A+1];)A++;if(tn(w,u[A],d[A],u[A+1],d[A+1]),kn(p,w),M>0)_t(y,p,M*c),jt(v,v,y),_t(y,w,b/2),jt(v,v,y),Os(l,v);else{const D=Math.min(1,(E-g[A])/(g[A+1]-g[A]));Ua(v,[u[A],d[A]],[u[A+1],d[A+1]],D),Os(l,v)}M=-M,E+=b/2}return e.stopLines&&!r[s.endingIsCut]&&(_t(y,p,M*c),jt(v,v,y),Os(l,v)),l}function Qg(e,t,n,i){const s=hf(t),r=Ot(t,[0,0]),{tileProps:o,tileAttrs:a}=i,c=n.x.length,l=s*e.modelLength,u=s*(e.edgeMarging||0),d={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&&u>0&&!a[o.beginningIsCut]&&pf(g,h,u),f===c-1&&u>0&&!a[o.endingIsCut]&&pf(h,g,u),ew(d,g,h,l,r)}return d}function pf(e,t,n){const i=Fn(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 ew(e,t,n,i,s){const[r,o]=t,[a,c]=n,l=Fn(t,n),u=Math.max(Math.round(l/i),1),d=l/(u*i),f=a-r,h=c-o,g=f/l,w=h/l,p=l/u/2;for(let y=1;y<=u;y++){const b=y*(l/u),v=r+g*(b-p),M=o+w*(b-p),E=r+g*b,A=o+w*b;e.x.push(v),e.y.push(M),e.xScaleDirection.push(E),e.yScaleDirection.push(A),e.scaleCorrection.push(d*s)}return e}function Zr(e,t,n,i){if(!tw(e)||e.length===0)return n;let s=qg(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=Kg(r,t,s,i);break;case"to-points-modifier":s=Qg(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 tw(e){return!!e&&Array.isArray(e)}const nw=new Set(["bottomCenter","bottomRight","bottomLeft","topCenter","topRight","topLeft","rightBottom","rightCenter","rightTop","leftBottom","leftCenter","leftTop","centerCenter"]);function iw(e){return nw.has(e)}function sw(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||e===null}function Ic(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,vertexColor:!0,"color-desaturate":!0,"color-grayscale":!0,"color-lighten":!0,"color-lightness":!0,"color-darken":!0,"color-whiten":!0,"color-blacken":!0,"color-saturate":!0,"color-opacity":!0}[t[0]])return!0}return!1}function mf(e){return Ic(e)&&e[0]==="literal"}function nn(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type!==void 0&&e.type!=="color"}function rw(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="color"}function yf(e,t){return Array.isArray(e)?e.length>0&&e.every(n=>typeof n===t):!1}function ow(e){return yf(e,"string")}function dn(e){return yf(e,"number")}function gf(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="object"}function aw(e){const t=typeof e;return e===null||t==="string"||t==="number"||t==="boolean"||ow(e)||dn(e)}function wf(e){return aw(e)||rw(e)||gf(e)}function cw(e){return nn(e)&&e.type==="get"}function wt(e,t){return t!==void 0?{type:"color",value:e,mixFactor:t}:{type:"color",value:e}}function lw(e){return{type:"mix-color",color1:e.value1,color2:e.value2,factor:e.factor,factorInterpolate:e.factorInterpolate}}function Hi(e,t,n){return`${e}_${t}_${n}`}function Xr(e){return`texture-${e}`}function Mc(e,t){return e+"-"+t}function qe(e){return mf(e)&&Array.isArray(e[1])?e[1][0]:Array.isArray(e)?Ic(e)?e:e[0]:e}function fn(e){if(mf(e)&&Array.isArray(e[1]))return e[1][1];if(Array.isArray(e)&&!Ic(e)&&e[1]!==void 0)return e[1]}function st(e){if(typeof e=="number"||dn(e))return e;if(e.type==="literalArray"&&dn(e.array))return e.array;throw new Error("Unsupported simple literal expression. Can't resolve.")}function Cs(e,t=0){const n=Number(e);return isNaN(n)?t:n}function vf(e){return!!e&&typeof e=="object"&&e.type==="mix-options"}const bf=wt([0,0,0,0]);function If(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 hn(e){return!!e&&typeof e=="object"&&e.type==="color"}function uw(e){return!!e&&typeof e=="object"&&e.type==="mix-color"}function qr(e){return!!e&&typeof e=="object"&&e.type==="gradient-color"}function Fs(e){const t=e.toLowerCase();let n=bf;switch(t[0]){case"#":n=fw(t);break;case"h":n=$i(t);break;case"r":n=hw(t);break}return n}function dw(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 fw(e){if(!new RegExp(`^#[a-f0-9]{${e.length-1}}$`).test(e)||![4,5,7,9].includes(e.length))return bf;const n=dw(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 wt([i,s,r,o])}function $i(e,t){const n=Mf(e);n[0]/=360,n[1]/=100,n[2]/=100;const[i,s,r]=pw(n[0],n[1],n[2]),o=t!==void 0?t:n[3]!==void 0?n[3]*255:255;return wt([Math.round(i),Math.round(s),Math.round(r),Math.round(o)])}function hw(e){const[t,n,i,s]=Mf(e),r=s!==void 0?s*255:255;return wt([Math.round(t),Math.round(n),Math.round(i),Math.round(r)])}function Mf(e){return e.split("(")[1].split(")")[0].split(",").map(n=>parseFloat(n))}function Tc(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 pw(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[Tc(s,i,e+1/3)*255,Tc(s,i,e)*255,Tc(s,i,e-1/3)*255]}function Tf(e){const t=e[0],n=e[1];let i=e[2];const s=Yi(e)[0],r=1/255*Math.min(t,Math.min(n,i));return i=1-1/255*Math.max(t,Math.max(n,i)),[s,r*100,i*100]}function Yi(e){const t=e[0]/255,n=e[1]/255,i=e[2]/255,s=Math.min(t,n,i),r=Math.max(t,n,i),o=r-s;let a,c;r===s?a=0:t===r?a=(n-i)/o:n===r?a=2+(i-t)/o:i===r&&(a=4+(t-n)/o),a=Math.min((a||0)*60,360),a<0&&(a+=360);const l=(s+r)/2;return r===s?c=0:l<=.5?c=o/(r+s):c=o/(2-r-s),[a,c*100,l*100]}function Sf(e){const t=e[1]/100,i=1-e[2]/100,s=i-t;let r=0;return s<1&&(r=(i-s)/(1-s)),[e[0],s*100,r*100]}function Ef(e){const t=e[0]/360,n=e[1]/100,i=e[2]/100;if(n===0)return[i*255,i*255,i*255];const s=[0,0,0],r=t%1*6,o=r%1,a=1-o;let c=0;switch(Math.floor(r)){case 0:s[0]=1,s[1]=o,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=o;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=o,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return c=(1-n)*i,[(n*s[0]+c)*255,(n*s[1]+c)*255,(n*s[2]+c)*255]}function mw(e,t){const n=Yi(e.value);return n[2]+=n[2]*t,$i(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function yw(e,t){const n=Yi(e.value);return n[2]-=n[2]*t,$i(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function gw(e,t){const n=Yi(e.value);return n[1]+=n[1]*t,$i(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function ww(e,t){const n=Yi(e.value);return n[1]-=n[1]*t,$i(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function vw(e,t){const n=Yi(e.value);return n[2]=Math.min(100,Math.max(0,100*t)),$i(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function bw(e,t){const n=Tf(e.value);n[1]+=n[1]*t;const i=Ef(Sf(n));return{type:"color",value:[i[0],i[1],i[2],e.value[3]||255]}}function Iw(e,t){const n=Tf(e.value);n[2]+=n[2]*t;const i=Ef(Sf(n));return{type:"color",value:[i[0],i[1],i[2],e.value[3]||255]}}function Mw(e){const t=e.value,n=t[0]*.3+t[1]*.59+t[2]*.11;return{type:"color",value:[n,n,n,e.value[3]||255]}}function Jr(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 Sc(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 Ec(e){return Math.floor(e/256)}function Tw(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!==zt.bomCharCode&&t.add(Ec(s))}}),Array.from(t)}function Sw(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 Ew(e,t){ke(`No glyph for character ${e} (code = ${t}, range = ${Ec(t)})`)}const Af=new Set;function Aw(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 xf(e){ke(`Got an empty response from the "${e}" tile generation.`)}function ke(e){Af.has(e)||(console.log(e),Af.add(e))}const xw=2166136261,_w=16777619;function _f(e,t){let n=xw;for(const i of t)n=n^i,n=n*_w;e.randomSeed=Math.abs(n)}function Rs(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 Pw(e=128){const t=[],n=[];for(let i=0;i<e;i++)t.push(Pf(i,2)),n.push(Pf(i,3));return{base2:t,base3:n}}function Pf(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 Lw(e,t){const n=[];for(let i=0;i<t;i++){const s=Rs(e,0,2*Math.PI),r=Math.acos(Rs(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 Qe=(e=>(e[e.Uniform=1]="Uniform",e[e.Labeling=2]="Labeling",e[e.Generator=3]="Generator",e))(Qe||{});const Kr=-1;var Ns=(e=>(e.global="global",e.none="none",e))(Ns||{}),Gn=(e=>(e[e.Pixels=0]="Pixels",e[e.Meters=1]="Meters",e))(Gn||{});const Lf="bottomCenter";function et(e,t){for(const n in t)t[n]!==void 0&&(e[n]=t[n])}function Dw(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(et(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(dn(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function Ow(e){const n={color:"#000000",textureImage:"",textureSize:16,textureOpacity:1,strokeColor:"#00000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible",elevation:0};if(et(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(dn(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function Cw(e){const t={iconImage:"",color:"#FFFFFF",rotation:0,width:1,visibility:"visible"};return et(t,e),e.height===void 0&&(t.height=t.width),t}function Fw(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 et(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 Rw(e){const t={color:"#000000",width:1,shift:0,geometryModifier:["geometry-modifier"],pattern:["pattern","none"],startCap:"round",endCap:"round",mode:"2d",visibility:"visible"};return et(t,e),t}function Nw(e){const t={color:"#000000",strokeColor:"#000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible"};return et(t,e),e.strokeColor===void 0&&(t.strokeColor=t.color),t}function kw(e){const t={sideColor:"#000000",strokeColor:"#000000",strokeWidth:1,sideStrokeColor:"#000000",height:0,visibility:"visible",nearCameraFade:2500};return et(t,e),e.strokeColor===void 0&&(t.strokeColor=t.sideColor),e.sideStrokeColor===void 0&&(t.sideStrokeColor=t.sideColor),t}function Bw(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:Vn};return et(t,e),t}function Uw(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:Vn};return et(t,e),t}function zw(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 et(t,e),t}function Gw(e){const t={color:"#000000",width:1,shift:0,visibility:"visible"};return et(t,e),t}function jw(e){const t={color:"#ffffff",strokeColor:"#3388ff",strokeColor2:"#00000000",width:20,strokeWidth:3,strokeWidth2:0,visibility:"visible"};return et(t,e),t}function Vw(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:Vn,iconLabelingMargin:{topBottom:0,leftRight:0},textField:[["get","db_label"],["get","db_label2"]],textFont:"",textColor:"#000000",textFontSize:16,textLineHeight:1.2,textLetterSpacing:0,textPlacement:Lf,textOffset:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textLabelingMargin:{topBottom:0,leftRight:0},textPriority:0,textMaxLengthPerLine:30,visibility:"visible",textLabelingGroup:Vn,duplicationSpacing:100,endingOffsets:0};return et(t,e),t}function Hw(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),et(t,e),t}function $w(e){const t={opacity:1,visibility:"visible"};return et(t,e),t}function Yw(e){return Dn(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 Ww(e){return Dn(e,{shadingIntensity:["interpolate",["linear"],["zoom"],12,0,14.5,.7],verticalScale:1,shadingPalette:["interpolate",["linear"],["shading-intensity"],0,0,1,1],lightingDirection:322})}function Zw(e){return Dn(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 Xw(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 et(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 qw(e){const t={visibility:"visible",sideColor:"#000000",topColor:"#000000",bottomColor:"#000000",strokeColor:"#000000",strokeWidth:1,color:"#ffffff",nearCameraFade:0};return et(t,e),t}function Jw(e){return Dn(e,{skyColor:"#6EC0FF00",fogColor:"#FAFDFF00",starsIntensity:1})}function Kw(e){const t={sources:{sun:{type:"directional",altitude:50,azimuth:230,color:"#FFFFFF",intensity:.2},atmosphere:{type:"ambient",color:"#FFFFFF",intensity:.85}},lightingModes:{[Ns.global]:["sun","atmosphere"]},defaultLightingMode:"global"},n=Dn(e!=null?e:{},t);return n.lightingModes[Ns.none]=[],n}function Qw(e){const t={light:{},normal:{},immersive:{}},n=Dn(e!=null?e:{},t);return n.light.transparentBuildingsOff=!0,n.light.AALinesOff=!0,n}const jn="__overlapped",Ac="__commercial",Vn="default",xc={groups:[Vn,jn,Ac],overlay:[[Vn,jn]],intersect:[[]]},ev="#F5F2E0",hi=e=>{e&&Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]})},tv=e=>{var t;hi(e),e.type==="group"?(hi(e.commonDefaults),hi((t=e.commonDefaults)==null?void 0:t.style),hi(e.layerTypeDefaults),e.layerTypeDefaults&&Object.values(e.layerTypeDefaults).forEach(n=>{hi(n),hi(n==null?void 0:n.style)})):e.type!=="custom"&&hi(e.style)},Df=(e,t=!1)=>{t||console.warn("assertUnreachable: ",e)},pi=null,Of=[0,0,0];function j(e,t){var n,i,s;if(!nn(e))return e;if(t.allowedExpressions&&!t.allowedExpressions.has(e.type))return ke(`Expression of type ${e.type} is not allowed here`),pi;switch(e.type){case"schedule":return pv(e,t);case"time":return rv(e,t);case"objectAttr":return av(e,t);case"coalesce":return Ff(e,t);case"all":return nv(e,t);case"any":return sv(e,t);case"featureState":return lv(e,t);case"get":return kf(e,t);case"global":return uv(e,t);case"sourceAttr":return ov(e,t);case"in":return Iv(e,t);case"has":return Mv(e,t);case"interpolate":return dv(e,t);case"match":return fv(e,t);case"step":return hv(e,t);case"to-boolean":return gv(e,t);case"to-color":return Bf(e,t);case"mappoints-to-meters":return mv(e,t);case"meters-to-pixels":return yv(e,t);case"!":return wv(e,t);case"==":case"!=":return vv(e,t);case">":case"<":case">=":case"<=":return bv(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 Df(r),pi;case"distance":if(t.type==="binder"){const a=oe.toGeo(t.objectCenter),c=oe.scaleFactor(a[1])*Ie;return qa(t.objectCenter,t.cameraCenter)/c}else return ke(`Distance expression can't be resolved in the ${t.type} context`),pi;case"height":return 1;case"+":return Tv(e,t);case"*":return Sv(e,t);case"^":return Ev(e,t);case"log10":return Av(e,t);case"random":return xv(e,t);case"literalArray":return _v(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`),pi);case"geometry-modifier":return e.modifiers;case"line-pattern":return[e.patternType,...e.parameters.map(a=>j(a,t))];case"precompute":return(s=t.tileData[e.precomputeIndex])!=null?s:null;case"gltf-animation":return Rf(e,t);case"local-time":return Cf(e,t);case"utc-time":return Cf(e,t);case"texture-animation":return Nf(e,t);case"easing":return e.options;case"mix":return cv(e,t);case"vertexColor":return iv(e,t);case"color-saturate":return pn(e,t,"saturate");case"color-desaturate":return pn(e,t,"desaturate");case"color-grayscale":return pn(e,t,"grayscale");case"color-lighten":return pn(e,t,"lighten");case"color-lightness":return pn(e,t,"lightness");case"color-darken":return pn(e,t,"darken");case"color-whiten":return pn(e,t,"whiten");case"color-blacken":return pn(e,t,"blacken");case"color-opacity":return pn(e,t,"opacity");default:return ke(`Not supported expression type <<${e.type}>> in ${JSON.stringify(e)}`),pi}}function nv(e,t){return e.array.every(n=>j(n,t)===!0)}function iv(e,t){if(t.type==="generator"){const i=j(e.vertexValue,t);if(hn(i))return i.isVertexColor=!0,i;const s=wt([0,0,0,0]);return s.isVertexColor=!0,s}const n=j(e.uniformValue,t);return hn(n)||qr(n)?(n.mixFactor=e.mixValue?j(e.mixValue,t):1,n):wt([0,0,0,255],1)}function sv(e,t){return e.array.some(n=>j(n,t)===!0)}function Cf(e,t){const n=Date.now()+ +(t.styleState._customUserTimeOffset||0);if(e.type==="local-time"){const i=e.offset?+(j(e.offset,t)||0)*6e4:0;return n+i}if(e.type==="utc-time"){const i=e.offset?+(j(e.offset,t)||0)*6e4:0;return n+new Date().getTimezoneOffset()*6e4+i}return n}function rv(e,t){const n=i=>{const s=j(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 Ff(e,t){for(const n of e.array){const i=j(n,t);if(i!==null)return i}return null}function ov(e,t){var n;return t.type==="generator"&&(n=t.sourceAttrs[e.property])!=null?n:null}function av(e,t){return t.type==="binder"&&t.dynamicObject&&t.dynamicObject[e.property]||null}function Rf(e,t){const n={type:"animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=j(i,t)):nn(e)||(n[0]=e),n}function Nf(e,t){const n={type:"texture-animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=j(i,t)):nn(e)||(n[0]=e),n}function cv(e,t){const{factorInterpolate:n}=e,i={type:"mix-options",value1:j(e.value1,t),value2:j(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 lv(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 kf(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 uv(e,t){const n=t.styleState[e.property];return n==null?null:typeof n=="object"&&!Array.isArray(n)?{type:"object",value:n}:n}function dv(e,t){if(e.steps.length===0)return ke("Interpolate expression contains 0 steps, cannot interpolate"),pi;const n=j(e.steps[0].value,t),i=j(e.argument,t);if(typeof i!="number")return ke(`Interpolate value resolved to non-number value: ${i} ${e.argument}`),0;if(hn(n)){if(nn(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=j(r.value,t);hn(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"),pi):s}return zf(e,i,t)}return Uf(e,i,t)}function fv(e,t){var s;const n=j(e.input,t),i=e.cases.find(r=>r.values.has(n));return j((s=i==null?void 0:i.output)!=null?s:e.defaultOutput,t)}function hv(e,t){const n=Number(j(e.value,t)),i=Bs(e,n,t)-1;return j(e.steps[i].value,t)}function pv(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=j(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 M={key:a[y],value:a[y+2]};c.push(M);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 u=Number(j(e.time,t)),d=new Date(u),f=d.getHours()*60+d.getMinutes()+(d.getDay()||7)*1440,h=Bs({steps:c},f%1440,t)-1,g=Bs({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=j(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=j(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 Bf(e,t){const n=j(e.value,t);if(If(n))return Fs(n);if(hn(n))return n;if(typeof n=="number"&&Number.isInteger(n)){const i=n>>>24&255,s=n>>>16&255,r=n>>>8&255,o=n&255;return wt([s,r,o,i])}return n&&console.warn(`Can't resolve expression. Must be color, but got ${n}`),wt([0,0,0,0])}function pn(e,t,n){const i=j(e.color,t),s=Bf({value:i},t);return Ov(s,n,e.value)}function mv(e,t){if(t.type!=="generator"||!t.tileInfo)throw new Error("Выражение `mappoints-to-meters` можно резолвить только в контексте генератора");return j(e.value,t)/(Ie*Ot(t.tileInfo,[0,0]))}function yv(e,t){const n=ae(e.value,t);let i,s=n*256/Ha;if(t.type==="generator"){if(!t.tileInfo)return null;i=t.tileInfo.coords[3],s*=Ot(t.tileInfo,[0,0])}else i=t.styleZoom;return s*re(2,i+1)}function gv(e,t){return!!j(e.value,t)}function wv(e,t){return!j(e.value,t)}function vv(e,t){const n=j(e.leftValue,t),i=j(e.rightValue,t);switch(e.type){case"==":return n===i;case"!=":return n!==i}}function bv(e,t){const n=j(e.leftValue,t);if(n===null)return null;const i=j(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 Iv(e,t){const n=j(e.item,t),i=j(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):gf(i)?Object.prototype.hasOwnProperty.call(i.value,n):(ke(`InExpression second argument resolved incorrectly: ${i}`),null)}function Mv(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 Tv(e,t){const n=e.array.map(i=>j(i,t));return dn(n)?n.reduce((i,s)=>i+s,0):(ke(`Resolve AdditionExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function Sv(e,t){const n=e.array.map(i=>j(i,t));return dn(n)?n.reduce((i,s)=>i*s,1):(ke(`Resolve MultiplicationExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function Ev(e,t){const n=j(e.base,t);if(typeof n!="number")return ke(`Resolve PowExpression: base resolved as non-number value: ${n}`),null;const i=j(e.exponent,t);return typeof i!="number"?(ke(`Resolve PowExpression: exponent resolved as non-number value: ${i}`),null):Math.pow(n,i)}function Av(e,t){const n=j(e.value,t);return typeof n!="number"?(ke(`Resolve Log10Expression: value resolved as non-number value: ${n}`),null):Math.log10(n)}function xv(e,t){const n=j(e.start,t);if(typeof n!="number")return ke(`Resolve RandomizationExpression: start resolved as non-number value: ${n}`),null;const i=j(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):Rs(t,n,i)}function _v(e,t){return e.array.map(n=>j(n,t))}function Uf(e,t,n){const i=Bs(e,t,n);if(i===0)return Number(j(e.steps[0].value,n));if(i===e.steps.length)return Lv(e,n,t);const s=Number(j(e.steps[i-1].value,n));if(n.type==="labeling"&&n.interpolateExpressionAsStep)return s;const r=jf(e,t,i,n),o=Number(j(e.steps[i].value,n));return(1-r)*s+r*o}function Hn(e,t,n=!1){const i=j(e,t);return hn(i)?i:qr(i)?i.values[1]:vf(i)?hn(i.value1)&&hn(i.value2)?n?lw(i):(console.warn("Mixing color is not supported here."),wt([0,0,0,0])):(console.warn(`Mix values cannot be converted to colors in ${JSON.stringify(i)}`),wt([0,0,0,0])):(console.warn(`Can't resolve expression. Must be color, but got ${i}`),wt([0,0,0,0]))}function Pv(e,t){const n=j(e,t);return qr(n)?n:null}function ae(e,t,n=NaN){const i=j(e,t);return typeof i=="number"?i:n}function lt(e,t,n=""){const i=j(e,t);return typeof i=="string"?i:n}function Qr(e,t,n=Lf){const i=j(e,t);return iw(i)?i:n}function zf(e,t,n){const i=Bs(e,t,n);if(i===0)return Hn(e.steps[0].value,n);if(i===e.steps.length)return Hn(e.steps[e.steps.length-1].value,n);const s=jf(e,t,i,n),r=Hn(e.steps[i-1].value,n).value,o=Hn(e.steps[i].value,n).value;return wt([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 Lv(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 Gf(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:Of,objectCenter:o!=null?o:Of}}function Ht(e,t,n,i){return{type:"labeling",styleZoom:e,styleState:t,interpolateExpressionAsStep:n,randomSeed:0,tileData:i}}function ks(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 Bs(e,t,n){let i=0;for(;i<e.steps.length&&!(t<ae(e.steps[i].key,n));)i++;return i}function jf(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 Dv(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 Ov(e,t="",n){const[i,s,r,o]=e.value;switch(t){case"opacity":return wt([i,s,r,n]);case"saturate":return gw(e,n);case"desaturate":return ww(e,n);case"grayscale":return Mw(e);case"lighten":return mw(e,n);case"darken":return yw(e,n);case"whiten":return bw(e,n);case"blacken":return Iw(e,n);case"lightness":return vw(e,n)}return{type:"color",value:[i,s,r,o]}}function eo(e){const[t,n,i,s]=e.value;return s<<24|i<<16|n<<8|t}function mi(e,t,n,i=!1){const s=[];return yi(s,e,t,n),i?s:Array.from(new Set(s))}function Cv(e,t){const n={};return Object.keys(e).forEach(i=>{n[i]=Fv(e[i],t)}),n}const Wi=Or();function Vf(e,t){const n=new Float32Array(3);return Oe(n,1,0,0),wy(Wi),Iy(Wi,Wi,-be(t-90)),by(Wi,Wi,-be(e)),j1(n,n,Wi),Jt(n,n),_d(n,n),n}function Fv(e,t){var i,s;const n={ambientColorIntensity:new Float32Array(Hn(e.ambientColor,t).value.map(r=>r/255)),dir1ColorIntensity:new Float32Array(Hn(e.dir1Color,t).value.map(r=>r/255)),dir1Direction:Vf(j(e.dir1Altitude,t),j(e.dir1Azimuth,t)),dir2ColorIntensity:new Float32Array(Hn(e.dir2Color,t).value.map(r=>r/255)),dir2Direction:Vf(j(e.dir2Altitude,t),j(e.dir2Azimuth,t)),shadowLightIndex:(i=e.shadowLightIndex)!=null?i:-1,shadowRadius:(s=e.shadowRadius)!=null?s:1};return n.ambientColorIntensity[3]=j(e.ambientIntensity,t),n.dir1ColorIntensity[3]=j(e.dir1Intensity,t),n.dir2ColorIntensity[3]=j(e.dir2Intensity,t),n}function yi(e,t,n,i){if(!nn(t)){e.push(t);return}switch(t.type){case"all":return Rv(e,t,n,i);case"match":return Nv(e,t,n,i);case"step":return kv(e,t,n,i);case"interpolate":return Bv(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=Ff(t,n);e.push(s);return}case"precompute":if(i){const s=i.precomputes[t.precomputeIndex].expr;yi(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=kf(t,n);e.push(s);return}}}function Rv(e,t,n,i){t.array.forEach(s=>yi(e,s,n,i))}function Nv(e,t,n,i){yi(e,t.defaultOutput),t.cases.forEach(s=>yi(e,s.output,n,i))}function kv(e,t,n,i){t.steps.forEach(s=>yi(e,s.value,n,i))}function Bv(e,t,n,i){t.steps.forEach(s=>yi(e,s.value,n,i))}const $t=1,Yt=-1,Wt=[.5,.5],Ft=[.5,.5],Se=[.5,.5],Zi=[.5,.5],_c=[0,0];let St,ge,Me,Ee=0,Et=0,Je=0,rt=0;const Uv={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]},zv=1-1e-4,Gv=0,Hf=-.9;function jv(e,t,n,i,s,r,o,a){const c=Uv;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>zv,c.leftTurn=i*-o+s*r<0,c.sharpTurn=l<Gv&&l>Hf,c.reverseTurn=l<Hf,c}function Pc(e,t,n,i,s,r,o,a,c,l,u,d,f=!1){var U,B,$,V,T,I,S;let h,g,w,p,y,b,v,M,E,A,D,_,O;if(i!==0)if(Me=u,ge=d,St=ge.indices,Et=ge.elements.offset,Ee=0,Je=0,rt=0,e[0],t[0],i===1)h=e[0],g=t[0],w=(U=n==null?void 0:n[0])!=null?U:0,O=0,mn(St,Et,0,2,1,1,2,3),Pe(ge,Me,0,h,g,w,1,-1,1,-1,O,!1,Yt),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,Yt),Pe(ge,Me,0,h,g,w,-1,1,-1,1,O,!1,$t),Ee=Ee+4;else{switch(p=e[0],y=t[0],b=(B=n==null?void 0:n[0])!=null?B:0,v=e[1],M=t[1],E=($=n==null?void 0:n[1])!=null?$:0,O=f?Me.cDist:0,s){case _e.TileCut:Vt(Wt,p,y,o,a),Vt(Se,v,M,p,y),_=Lc(v,M,E,Wt[0],Wt[1],Se[0],Se[1],f),_.noTurn?$f(p,y,b,Se[0],Se[1],O):to(0,p,y,b,Wt[0],Wt[1],Se[0],Se[1],O,f);break;case _e.Butt:case _e.Round:Vt(Se,v,M,p,y),$f(p,y,b,Se[0],Se[1],O),s===_e.Round&&to(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 C=1;C<P;C++){p=e[C-1],y=t[C-1],b=(V=n==null?void 0:n[C-1])!=null?V:0,v=e[C],M=t[C],E=(T=n==null?void 0:n[C])!=null?T:0,A=e[C+1],D=t[C+1];const k=v-p,R=M-y;O+=Math.sqrt(k*k+R*R)/te,Vt(Wt,v,M,p,y),Vt(Se,A,D,v,M),to(C,v,M,E,Wt[0],Wt[1],Se[0],Se[1],O,f)}p=e[i-2],y=t[i-2],b=(I=n==null?void 0:n[i-2])!=null?I:0,v=e[P],M=t[P],E=(S=n==null?void 0:n[P])!=null?S:0;const x=v-p,F=M-y;switch(O+=Math.sqrt(x*x+F*F)/te,r){case _e.TileCut:Vt(Wt,v,M,p,y),Vt(Se,c,l,v,M),_=Lc(v,M,E,Wt[0],Wt[1],Se[0],Se[1],f),_.noTurn?Yf(P,v,M,E,Se[0],Se[1],O):Wf(P,O,_);break;case _e.Butt:case _e.Round:Vt(Se,v,M,p,y),Yf(P,v,M,E,Se[0],Se[1],O),r===_e.Round&&to(P,v,M,E,Se[0],Se[1],-Se[0],-Se[1],O,f);break;default:throw new Error("LoftedLine: unknown Ending Type")}}}function Lc(e,t,n,i,s,r,o,a){const c=jv(e,t,n,i,s,r,o,a);if(!c.noTurn&&!c.reverseTurn){Nd(Ft,i,s,r,o);const l=Ft[0],u=Ft[1];c.extender[0]=l,c.extender[1]=u,c.faExtender[0]=l-i*2,c.faExtender[1]=u-s*2,c.saExtender[0]=l-r*2,c.saExtender[1]=u-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 Dc(e,t,n,i,s,r,o,a,c,l){Nd(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),Ee++}function to(e,t,n,i,s,r,o,a,c,l){const u=Lc(t,n,i,s,r,o,a,l);Wf(e,c,u),Vv(e,c,u),Hv(e,c,u)}function $f(e,t,n,i,s,r){Pe(ge,Me,0,e,t,n,-i,-s,-i,-s,r,!1,$t),Pe(ge,Me,0,e,t,n,i,s,i,s,r,!1,Yt),Ee=Ee+2,Je=1,rt=0}function Yf(e,t,n,i,s,r,o){const a=Ee+1,c=Ee;Pe(ge,Me,e,t,n,i,-s,-r,-s,-r,o,!1,$t),Pe(ge,Me,e,t,n,i,s,r,s,r,o,!1,Yt),Ee=Ee+2,mn(St,Et,rt,c,Je,Je,c,a),Je=a,rt=c}function Vv(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=Ee+i):(s=Ee+i,r=rt);const o=Ee;if(Oc(St,Et,Je,rt,o),n.sharpTurn){const c=Ee+1;n.leftTurn?mn(St,Et,o,c,s,s,c,r):mn(St,Et,o,r,c,c,r,s)}else n.leftTurn,Oc(St,Et,o,r,s);const a=n.leftTurn?$t:Yt;n.sharpTurn?(n.leftTurn?Vt(Zi,n.xn2,n.yn2,n.xn1,n.yn1):Vt(Zi,n.xn1,n.yn1,n.xn2,n.yn2),Dc(e,n.x,n.y,n.z,n.xn2,n.yn2,Zi[0],Zi[1],t,a),Dc(e,n.x,n.y,n.z,Zi[0],Zi[1],n.xn1,n.yn1,t,a)):Dc(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),Ee++),rt=r,Je=s}function Wf(e,t,n){if(n.noTurn)return;const i=Ee+1,s=Ee;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,$t),Pe(ge,Me,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,Yt)):n.leftTurn?(Pe(ge,Me,e,n.x,n.y,n.z,-n.xn2,-n.yn2,n.faExtender[0],n.faExtender[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,Yt)):(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.faExtender[0],-n.faExtender[1],t,!0,Yt)),Ee=Ee+2,mn(St,Et,rt,s,Je,Je,s,i),rt=s,Je=i,!n.patternedLine&&!n.reverseTurn){const r=Ee+1,o=Ee;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),mn(St,Et,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),mn(St,Et,s,o,i,i,o,r)),Ee=Ee+2,rt=o,Je=r}}function Hv(e,t,n){if(n.noTurn||n.reverseTurn)return;const i=Ee+1,s=Ee;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,$t),Pe(ge,Me,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,Yt),Ee=Ee+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,$t),Pe(ge,Me,e,n.x,n.y,n.z,n.xn1,n.yn1,n.extender[0],n.extender[1],t,!1,Yt)):(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.saExtender[0],-n.saExtender[1],t,!1,Yt));Ee=Ee+2,n.leftTurn?mn(St,Et,rt,s,Je,Je,s,i):mn(St,Et,Je,rt,i,i,rt,s),rt=s,Je=i}function Pe(e,t,n,i,s,r,o,a,c,l,u,d,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===di.Patterned){const p=e,y=1e-5;p.views.texture[g]=(y+u)*Math.sign(f)}else if(t.type===di.Striped){const p=e;p.views.texExtender[w]=$e(o*Ne),p.views.texExtender[w+1]=$e(a*Ne),p.views.vertexDistance[g]=u,p.views.objectLength[g]=t.oLen,"componentDistance"in e.views&&(e.views.componentDistance[g]=t.cDist)}else if(t.type===di.Entrance){const p=e,{px:y,py:b,count:v}=t,M=n===0,E=n===v-1,A=M?n:n-1,D=M?n+1:n;tn(_c,y[A],b[A],y[D],b[D]),p.views.direction[h]=Math.round(_c[0]*127),p.views.direction[h+1]=Math.round(_c[1]*127),p.views.type[g]=E?Ps.LineEnding:Ps.Line,p.views.texExtender[w]=$e(o*(d||E?-1:1)*Ne),p.views.texExtender[w+1]=$e(a*(d||E?-1:1)*Ne),p.views.vertexDistance[g]=u,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 Oc(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 mn(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 Cc(e){return hs*e}function Fc(e){return e/hs}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 Yv={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 Wv(e){return Yv[e]}function Zv(e){return e!=="group"&&e!=="custom"}function Xv(e){return e==="model"?"gltfModel":e!=="group"?e:void 0}function qv(){let e=new Mt(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function Jv(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function Kv(e){return e[0]*e[3]-e[2]*e[1]}function Rc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var no={exports:{}},io={exports:{}},Qv=io.exports,Zf;function e2(){return Zf||(Zf=1,(function(e,t){(function(n,i){e.exports=i()})(Qv,(function(){function n(o,a,c,l,u){i(o,a,c||0,l||o.length-1,u||r)}function i(o,a,c,l,u){for(;l>c;){if(l-c>600){var d=l-c+1,f=a-c+1,h=Math.log(d),g=.5*Math.exp(2*h/3),w=.5*Math.sqrt(h*g*(d-g)/d)*(f-d/2<0?-1:1),p=Math.max(c,Math.floor(a-f*g/d+w)),y=Math.min(l,Math.floor(a+(d-f)*g/d+w));i(o,a,p,y,u)}var b=o[a],v=c,M=l;for(s(o,c,a),u(o[l],b)>0&&s(o,c,l);v<M;){for(s(o,v,M),v++,M--;u(o[v],b)<0;)v++;for(;u(o[M],b)>0;)M--}u(o[c],b)===0?s(o,c,M):(M++,s(o,M,l)),M<=a&&(c=M+1),a<=M&&(l=M-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}))})(io)),io.exports}var Xf;function t2(){if(Xf)return no.exports;Xf=1,no.exports=t,no.exports.default=t;var e=e2();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 M=[],E,A,D,_;y;){for(E=0,A=y.children.length;E<A;E++)D=y.children[E],_=y.leaf?v(D):D,h(p,_)&&(y.leaf?b.push(D):f(p,_)?this._all(D,b):M.push(D));y=M.pop()}return b},collides:function(p){var y=this.data,b=this.toBBox;if(!h(p,y))return!1;for(var v=[],M,E,A,D;y;){for(M=0,E=y.children.length;M<E;M++)if(A=y.children[M],D=y.leaf?b(A):A,h(p,D)){if(y.leaf||f(p,D))return!0;v.push(A)}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 M=this.data;this.data=v,v=M}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),M=[],E=[],A,D,_,O;b||M.length;){if(b||(b=M.pop(),D=M[M.length-1],A=E.pop(),O=!0),b.leaf&&(_=n(p,b.children,y),_!==-1))return b.children.splice(_,1),M.push(b),this._condense(M),this;!O&&!b.leaf&&f(b,v)?(M.push(b),E.push(A),A=0,D=b,b=b.children[0]):D?(A++,b=D.children[A],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 M=b-y+1,E=this._maxEntries,A;if(M<=E)return A=g(p.slice(y,b+1)),i(A,this.toBBox),A;v||(v=Math.ceil(Math.log(M)/Math.log(E)),E=Math.ceil(M/Math.pow(E,v-1))),A=g([]),A.leaf=!1,A.height=v;var D=Math.ceil(M/E),_=D*Math.ceil(Math.sqrt(E)),O,U,B,$;for(w(p,y,b,_,this.compareMinX),O=y;O<=b;O+=_)for(B=Math.min(O+_-1,b),w(p,O,B,D,this.compareMinY),U=O;U<=B;U+=D)$=Math.min(U+D-1,B),A.children.push(this._build(p,U,$,v-1));return i(A,this.toBBox),A},_chooseSubtree:function(p,y,b,v){for(var M,E,A,D,_,O,U,B;v.push(y),!(y.leaf||v.length-1===b);){for(U=B=1/0,M=0,E=y.children.length;M<E;M++)A=y.children[M],_=c(A),O=u(p,A)-_,O<B?(B=O,U=_<U?_:U,D=A):O===B&&_<U&&(U=_,D=A);y=D||y.children[0]}return y},_insert:function(p,y,b){var v=this.toBBox,M=b?p:v(p),E=[],A=this._chooseSubtree(M,this.data,y,E);for(A.children.push(p),r(A,M);y>=0&&E[y].children.length>this._maxEntries;)this._split(E,y),y--;this._adjustParentBBoxes(M,E,y)},_split:function(p,y){var b=p[y],v=b.children.length,M=this._minEntries;this._chooseSplitAxis(b,M,v);var E=this._chooseSplitIndex(b,M,v),A=g(b.children.splice(E,b.children.length-E));A.height=b.height,A.leaf=b.leaf,i(b,this.toBBox),i(A,this.toBBox),y?p[y-1].children.push(A):this._splitRoot(b,A)},_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,M,E,A,D,_,O,U;for(_=O=1/0,v=y;v<=b-y;v++)M=s(p,0,v,this.toBBox),E=s(p,v,b,this.toBBox),A=d(M,E),D=c(M)+c(E),A<_?(_=A,U=v,O=D<O?D:O):A===_&&D<O&&(O=D,U=v);return U},_chooseSplitAxis:function(p,y,b){var v=p.leaf?this.compareMinX:o,M=p.leaf?this.compareMinY:a,E=this._allDistMargin(p,y,b,v),A=this._allDistMargin(p,y,b,M);E<A&&p.children.sort(v)},_allDistMargin:function(p,y,b,v){p.children.sort(v);var M=this.toBBox,E=s(p,0,y,M),A=s(p,b-y,b,M),D=l(E)+l(A),_,O;for(_=y;_<b-y;_++)O=p.children[_],r(E,p.leaf?M(O):O),D+=l(E);for(_=b-y-1;_>=y;_--)O=p.children[_],r(A,p.leaf?M(O):O),D+=l(A);return D},_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,M){M||(M=g(null)),M.minX=1/0,M.minY=1/0,M.maxX=-1/0,M.maxY=-1/0;for(var E=y,A;E<b;E++)A=p.children[E],r(M,p.leaf?v(A):A);return M}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 u(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 d(p,y){var b=Math.max(p.minX,y.minX),v=Math.max(p.minY,y.minY),M=Math.min(p.maxX,y.maxX),E=Math.min(p.maxY,y.maxY);return Math.max(0,M-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,M){for(var E=[y,b],A;E.length;)b=E.pop(),y=E.pop(),!(b-y<=v)&&(A=y+Math.ceil((b-y)/v/2)*v,e(p,A,y,b,M),E.push(y,A,A,b))}return no.exports}var n2=t2();const so=Rc(n2);var Nc,qf;function i2(){if(qf)return Nc;qf=1,Nc=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 Nc}var kc,Jf;function s2(){if(Jf)return kc;Jf=1,kc=n;var e=128,t=127;function n(i,o){var r=0,o=o||0,a=0,c=o,l,u=i.length;do{if(c>=u||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 kc}var Bc,Kf;function r2(){if(Kf)return Bc;Kf=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 Bc=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},Bc}var Uc,Qf;function o2(){return Qf||(Qf=1,Uc={encode:i2(),decode:s2(),encodingLength:r2()}),Uc}var a2=o2();const eh=Rc(a2);class th{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=eh.decode(this.buf,this.pos);return this.pos+=(n=eh.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 c2(e){const t=new th(e);t.readUint32(),t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16();const n=zc(t.readInt32()),i=zc(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);nh(t,l,a,zc);const u=t.readUint32(),d=a>Ge?new Uint32Array(u):new Uint16Array(u);nh(t,d,u);const f={positions:c,heights:l,indices:d},h=t.readUint32();if(h>0){const w=[];new Int8Array(t.readBytes(h*3)).forEach(p=>w.push(l2(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 nh(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 zc(e){return e/Ie}function l2(e){return e/127}function u2(e){const t=new kr(e),n=Gc(t.readFixed32()),i=Gc(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 d=0;d<s;d++)a[d]=Gc(t.readSVarint());let c=0;const l=t.readFixed32(),u=s>Ge?new Uint32Array(l):new Uint16Array(l);for(let d=0;d<l;d++){const f=t.readSVarint(),h=c+f;c+=f,u[d]=h}return{dataGroups:[{positions:o,heights:a,indices:u}],minZ:n,maxZ:i}}function Gc(e){return e/100}function d2(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 f2(e){return Math.log(e)*256+.5<<16>>16}let h2=0;function Us(){return h2++}const zs=Us(),jc=Us(),ih=128,Rt={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",Rt.sinks.mesh2.packObjectAttributes(n,i),Rt.sinks.mesh2.binder);y2(s,t)},generateHillshade(e,t,n,i){const s=new Uint16Array(t.reduce((o,a)=>{const[c,l,u,d]=a;return o.push(c*te,l*te,At(u),At(d)),o},[]));return{symbol:Rt.symbol,sink:"hillshade",buffer:s.buffer,generatedObjects:[{drawMode:gr,attributes:Rt.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=Rt.sinks.flatBottom.packObjectAttributes(t,zs,r),u=e.getBucket("dem","flatBottom",l,Rt.sinks.flatBottom.binder);p2(u,c,o,a,i,s,!!r)}};function p2(e,t,n,i,s,r,o){let a=e.elements.offset;const c=a;if(!(t<3)){Vc(e,a++,n[0],i[0],r,s[0],o),Vc(e,a++,n[1],i[1],r,s[1],o);for(let l=2;l<t;l++)m2(e,c,l),Vc(e,a++,n[l],i[l],r,s[l],o);e.elements.offset=a}}function Vc(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 m2(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 y2(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?sh(o):o),e.views.position[r+1]=z+(n?sh(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 sh(e){return e===0?e-=ih:e===te&&(e+=ih),e}const g2=(()=>{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 w2(e,t){const n=new th(e),i=[];return rh(n,t,i),i}function rh(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,u=c>>1;for(let d=0;d<u;d++)l?v2(e,t,n):rh(e,t,n)}function v2(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 Gs=yt(),oh=yt(),b2=Ce(),I2=Ce(),ah=qv(),M2=64,ch=9,lh=(e,t,n,i,s)=>{const r=Es(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 T2(e){const t=[];return e.forEach((n,i)=>{n.symbol!=="dem"||n.sink!=="mesh2"||n.generatedObjects.forEach((s,r)=>{const o=Rt.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,u=c+o,d=c+o*2;t.push({minX:Math.min(a[l],a[u],a[d])-z,maxX:Math.max(a[l],a[u],a[d])-z,minY:Math.min(a[l+1],a[u+1],a[d+1])-z,maxY:Math.max(a[l+1],a[u+1],a[d+1])-z,posOffset:c,bucketIndex:i,batchIndex:r})}})}),t.length?g2(so(ch).load(t)):null}function Hc(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 S2(e,t){var c;if(!e.tree)return;const n=Oe(Gs,t[0],t[1],0),i=hc(e.key),s=ct(i),r=new Uint16Array(3),o=Rt.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT;Lt(r,n,s);const a=w2(e.tree,r);for(const l of a){const u=(c=e.generated[0])==null?void 0:c.collectorOutput.data[l.bucketIndex];if(!u||u.sink!=="mesh2")continue;const d=u.generatedObjects[l.bucketIndex],f=new Uint16Array(u.buffer,d.rangeStart,(d.rangeEnd-d.rangeStart)/Uint16Array.BYTES_PER_ELEMENT),h=new Float32Array(u.buffer,d.rangeStart+4,(d.rangeEnd-d.rangeStart)/Float32Array.BYTES_PER_ELEMENT-1),g=Hc(f,h,l.posOffset),w=Hc(f,h,l.posOffset+o),p=Hc(f,h,l.posOffset+o*2),y=E2(g,w,p,r,Gs);if(!y)continue;return g[2]*y[0]+w[2]*y[1]+p[2]*y[2]}}function E2(e,t,n,i,s){const r=$c(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(Yc(e,t,i)){const u=ro(e,t,i);l=si(Gs,e,t,u),s[0]=1-u,s[1]=u,s[2]=0}if(Yc(t,n,i)){const u=ro(t,n,i),d=si(oh,t,n,u);(!l||d[2]>l[2])&&(s[0]=0,s[1]=1-u,s[2]=u,l||(l=Gs),Za(l,d))}if(Yc(n,e,i)){const u=ro(n,e,i),d=si(oh,n,e,u);(!l||d[2]>l[2])&&(s[0]=u,s[1]=0,s[2]=1-u,l||(l=Gs),Za(l,d))}if(l)return s}const o=$c(i,t,n)/r,a=$c(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 $c(e,t,n){return Jv(ah,t[0]-e[0],n[0]-e[0],t[1]-e[1],n[1]-e[1]),Kv(ah)}function Yc(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 ro(e,t,n){const i=ln(b2,t,e),s=ln(I2,n,e);return Cn(s,i)/p1(i)}function A2(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?c2(e):u2(e),{positions:r,heights:o,indices:a}=n[0];return{positions:r,heights:o,indices:a,maxZ:s,minZ:i}}function Wc(e,t,n,i,s){const r=Fc(s);mi(i.textureImage).forEach(o=>{if(!o.length)return;const a=n.byKey[Xr(o)];if(!a){console.error(`Not found raster set with texture ${o}`);return}const c=x2(i.textureSize),l=i.lengthUnits===Gn.Meters;c.forEach(u=>{let[d,f]=Array.isArray(u)?u:[u,u];l&&(d=d*Wr(d,d),f=f*Wr(f,f)),a.isSvg?e.atlasPacker.packSvg(a,[{w:d,h:f}],r):e.atlasPacker.packPng(a,[{w:d,h:f}],r),a.rasters.forEach(h=>e.atlasPacker.addRastersToLoad(t,h))})})}function x2(e){return nn(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"?[st(e)]:(ke(`Unsupported texture size expression of type "${e.type}". Can't resovle.`),[0]):[e]}function Zc(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=Ci(s,r,a/o),u=Ci(s,r,c/o),d=e.tileInfo?Ot(e.tileInfo,[0,0]):1,f=Array.from({length:t.x.length});if(l===u)return f.fill(l*Ie*d),f;const h=t.x.length;for(let v=0;v<h;v++)f[v]=Ie*d*Ci(l,u,ro([t.x[0],t.y[0]],[t.x[h-1],t.y[h-1]],[t.x[v],t.y[v]]));return f}const Xc=e=>{for(let t=0;t<e.length;t++)if(e[t]!==0)return!0;return!1},ut={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 Fe([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 Fe([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 Fe([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 Fe([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=Zr(j(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i;let l=n.style.mode==="3d";const u=l?(v=o.z)!=null?v:Zc(i,o):void 0;l&&(!u||!Xc(u))&&(l=!1);const d=e.idIndexer.getIndex(i,t,n),f=j(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",ut.sinks.solid3d.packObjectAttributes(t,n,!!o.abs_z,i),ut.sinks.solid3d.binder):e.getBucket(n.type,"solid",ut.sinks.solid.packObjectAttributes(t,n,f,h,i),ut.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);uf(g,o.x,o.y,u,o.abs_z,o.x.length,w?_e.TileCut:oo(y),p?_e.TileCut:oo(b),d)},generatePatterned(e,t,n,i,s,r){var M,E;const o=Zr(j(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i,l=j(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],u=(M=a[c.db_hidden_by_metro_building_id])!=null?M:"";let d=n.style.mode==="3d";const f=d?(E=o.z)!=null?E:Zc(i,o):void 0;d&&(!f||!Xc(f))&&(d=!1);const h=d?e.getBucket("line","patterned3d",ut.sinks.patterned3d.packObjectAttributes(t,n,i),ut.sinks.patterned3d.binder):e.getBucket("line","patterned",ut.sinks.patterned.packObjectAttributes(t,n,l,u,i),ut.sinks.patterned.binder),g=e.idIndexer.getIndex(i,t,n),w=_2(a[c.componentDistanceStart]/te,a[c.componentDistanceEnd]/te,a[c.objectLength]/te,g,d?ut.sinks.patterned3d.stride/2:ut.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);Pc(o.x,o.y,f,o.x.length,p?_e.TileCut:oo(b),y?_e.TileCut:oo(v),a[c.previousPointX],a[c.previousPointY],a[c.nextPointX],a[c.nextPointY],w,h,!0)}},Xi={type:di.Patterned,cDist:0,sLen:0,oLen:0,localID:0,offsetMultiplier:8,px:[],py:[],count:0};function _2(e,t,n,i,s){return Xi.cDist=e,Xi.sLen=t-e,Xi.oLen=n,Xi.localID=i,Xi.offsetMultiplier=s,Xi}function oo(e){switch(e){case"round":return _e.Round;case"tilecut":return _e.TileCut;case"butt":default:return _e.Butt}}const ao={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 Fe([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=j(n.ignoreTier,i)?null:i.tileAttrs[o.db_tiers],u=e.getBucket(n.type,"solid",ao.sinks.solid.packObjectAttributes(t,n,l,i),ao.sinks.solid.binder);uf(u,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 dt(e,t){return e===0?0:Math.min(e*2-1,(t-e)*2)}function qc(e,t,n,i,s,r,o=0,a,c,l,u,d){let f=e.elements.offset;for(let h=0;h<t;h++){const g=dt(h,t),w=h===t-1;if((!s||s[g]!==1)&&(s||w))continue;const p=n[g],y=i[g],b=(h+1)%t,v=dt(b,t),M=n[v],E=i[v];if(u){const A=Math.hypot(M-p,E-y)*u.tileSizeMapPoints/te;if(A<u.wallPaddingMapPoints[1]+u.wallPaddingMapPoints[3]+u.textureWidthMapPoints)continue;switch(u.config.horizontal.mode){case"repeat-with-stretch":{const D=u.config.horizontal.slicesCount,_=(A-(u.wallPaddingMapPoints[1]+u.wallPaddingMapPoints[3]))/u.textureWidthMapPoints,O=Math.round(_*D);if(O<u.config.horizontal.minSliceRepeats)continue;const B=O/D/_;if(u.config.horizontal.maxResizeFactor&&B>u.config.horizontal.maxResizeFactor||u.config.horizontal.minResizeFactor&&B<u.config.horizontal.minResizeFactor)continue;break}case"repeat-with-max-interval":break;default:continue}switch(u.config.vertical.mode){case"repeat-with-stretch":{const D=u.config.vertical.slicesCount,_=(r-(u.wallPaddingMapPoints[0]+u.wallPaddingMapPoints[2]))/u.textureHeightMapPoints,O=Math.round(_*D);if(O<u.config.vertical.minSliceRepeats)continue;const B=O/D/_;if(B>u.config.vertical.maxResizeFactor||B<u.config.vertical.minResizeFactor)continue;break}case"repeat-with-max-interval":break;case"stripe-top":break;default:continue}hh(e,f),uh(e,f,p,y,M,E,r,o),L2(e,f,r-o,A)}else hh(e,f),uh(e,f,p,y,M,E,r,0);l?dh(e,f,l[0],l[1],l[0],l[1]):dh(e,f,p,y,M,E),a!==void 0&&"localID"in e.views&&e.views.localID!==void 0&&fh(e.views.localID,f,a,e.elements.stride),c!==void 0&&"labelingTextureID"in e.views&&e.views.labelingTextureID!==void 0&&fh(e.views.labelingTextureID,f,c,e.elements.stride),d!==void 0&&P2(e.views.innerColor,f,d,e.elements.stride),f=f+4}e.elements.offset=f}function P2(e,t,n,i){const s=i/e.BYTES_PER_ELEMENT;t=t*s,e[t]=n,t+=s,e[t]=n,t+=s,e[t]=n,t+=s,e[t]=n}function uh(e,t,n,i,s,r,o,a=0){const c=e.views.position,l=e.views.height,u=e.elements.stride/c.BYTES_PER_ELEMENT;t=t*u,c[t]=z+n,c[t+1]=z+i,l[t>>1]=it(a)/Ge,t+=u,c[t]=z+n,c[t+1]=z+i,l[t>>1]=it(o)/Ge,t+=u,c[t]=z+s,c[t+1]=z+r,l[t>>1]=it(a)/Ge,t+=u,c[t]=z+s,c[t+1]=z+r,l[t>>1]=it(o)/Ge}function L2(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 dh(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 fh(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 hh(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 yn=[.5,.5],gn=[.5,.5];function Jc(e,t,n,i,s,r){let o=e.elements.offset;const a=dt(t-1,t);let c=n[a],l=i[a],u=s?s[a]:0;const d=o;for(let f=0;f<t;f++){const h=dt(f,t),g=f===t-1,w=n[h],p=i[h],y=s?s[h]:g?0:1;u!==0&&(tn(gn,c,l,w,p),mh(e,o,y,g?d:o+4),C2(e,o,c,l,w,p),r?ph(e,o,r[0],r[1],r[0],r[1]):ph(e,o,c,l,w,p),nc(gn),F2(e,o,gn),R2(e,o,gn),o=o+4),c=w,l=p,u=y}e.elements.offset=o}function Kc(e,t,n,i,s,r,o,a){let c=e.elements.offset;const l=dt(t-2,t),u=dt(t-1,t);let d=n[u],f=i[u],h=s?s[l]:1,g=s?s[u]:0;Vt(yn,n[l],i[l],d,f);let w=yn[0],p=yn[1];for(let y=0;y<t;y++){const b=dt(y,t),v=y===t-1,M=n[b],E=i[b],A=s?s[b]:v?0:1;tn(gn,d,f,M,E);const D=gn[1],_=-gn[0];h!==0&&(g===0?(yn[0]=w,yn[1]=p):D2(yn,w,p,D,_),Ty(gn,w,p,yn[0],yn[1]),mh(e,c,0,0),N2(e,c,d,f,r,o!=null?o:[d,f]),k2(e,c,nc(yn),nc(gn)),B2(e,c),a!==void 0&&"innerColor"in e.views&&e.views.innerColor!==void 0&&O2(e.views.innerColor,c,a,e.elements.stride),c=c+4),d=M,f=E,h=g,g=A,w=D,p=_}e.elements.offset=c}function D2(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 O2(e,t,n,i){const s=i/e.BYTES_PER_ELEMENT;t=t*s,e[t]=n,t+=s,e[t]=n,t+=s,e[t]=n,t+=s,e[t]=n}function ph(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 C2(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 F2(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 R2(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 N2(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]=it(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]=it(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 k2(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 B2(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 mh(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 js=yt(),Vs=yt(),wn=yt();function Hs(e,t,n,i,s,r,o,a,c,l,u,d,f,h,g){Oe(js,t,n,i),Oe(Vs,s,r,o),Kt(wn,Vs,js),W1(Vs,js)||(Jt(wn,wn),Nn(wn,wn,127)),U2(e,0,1,3,3,1,2),co(e,js,wn,1,a,c,l,u,f,g),co(e,js,wn,-1,a,c,l,u,f,g),co(e,Vs,wn,-1,a,c,l,d,h,g),co(e,Vs,wn,1,a,c,l,d,h,g)}function co(e,t,n,i,s,r,o,a,c,l){const u=e.elements.offset*e.elements.stride,d=u/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 f=u/e.views.height.BYTES_PER_ELEMENT;e.views.height[f]=(r?t[2]:o?t[2]*rf:it(t[2]))/Ge}if(e.views.directionDistance[u]=n[0],e.views.directionDistance[u+1]=n[1],e.views.directionDistance[u+2]=n[2],e.views.directionDistance[u+3]=i,"demPosition"in e.views){const f=u/e.views.demPosition.BYTES_PER_ELEMENT;s=s!=null?s:t,e.views.demPosition[f]=(r?s[0]:z+s[0])/8,e.views.demPosition[f+1]=(r?s[1]:z+s[1])/8}"absZ"in e.views&&a!==void 0&&(e.views.absZ[u/e.views.absZ.BYTES_PER_ELEMENT]=a),"isPivot"in e.views&&(e.views.isPivot[u/e.views.isPivot.BYTES_PER_ELEMENT]=c!=null?c:0),"innerColor"in e.views&&l!==void 0&&(console.log("set"),e.views.innerColor[u/e.views.innerColor.BYTES_PER_ELEMENT]=l),e.elements.offset++}function U2(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 z2=/\.png$/i;function G2(e){return!!e&&e.type==="polygon"}function j2(e){return!!e&&e.type==="line"}function yh(e){return e.reduce((t,n,i)=>(t[n]=i,t),{})}function V2(e){return e===void 0||typeof e=="boolean"?!!e:!!JSON.stringify(e).match(/\["get","(db_)?sublayer"]/)}function H2(e){return!(e!=null&&e.url.match(z2))}function gh(e,t){return Oi(j(e.style.sideColor,t),j(e.style.sideStrokeColor,t))}const lo=te/2,$2=1/it(1),gi=(e,t,n,i,s,r,o)=>Fe([e,t.innerId,n,i,s,r],t,o),$s=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],floorId:e[3],isFloorStack:e[4],textureIndex:e[5],tileData:e.slice(6)}),$n={symbol:"polygonExtrusion",sinks:{sideFill:{stride:24,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),e.views.innerColor=new Uint32Array(t,20)},packObjectAttributes:gi,unpackObjectAttributes:$s},sideTexture:{stride:28,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),e.views.innerColor=new Uint32Array(t,24)},packObjectAttributes:gi,unpackObjectAttributes:$s},topFill:{stride:24,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),e.views.innerColor=new Uint32Array(t,20)},packObjectAttributes:gi,unpackObjectAttributes:$s},sideStroke:{stride:24,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),e.views.innerColor=new Uint32Array(t,20)},packObjectAttributes:gi,unpackObjectAttributes:$s},topStroke:{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.innerColor=new Uint32Array(t,16)},packObjectAttributes:gi,unpackObjectAttributes:$s}},generate(e,t,n,i,s,r){var T,I;const o=s.x,a=s.y,c=(T=s.cut)!=null?T:[],l=i.tileAttrs[i.tileProps.db_plan_id]||"",u=i.tileAttrs[i.tileProps.db_hidden_by_plan_building_id]||"",d=i.tileAttrs[i.tileProps.db_sublayer]==="Floor_half_walls_width_extended_ground",f=o.length,h=(I=i.id)!=null?I:"";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=q2(o,a,c);const w=j(n.style.height,i),p=i.tileInfo?Ot(i.tileInfo,[0,0]):1,y=Math.max(w*Ie*p,$2),b=e.idIndexer.getIndex(i,t,n,{floorId:Number.isNaN(l)?void 0:l}),v=e.pointIndexer.getIndex(h),M=gi(t,n,u,l,d,NaN,i),E=j(n.style.topColor,i),A=j(n.style.strokeColor,i),D=j(n.style.sideColor,i),_=D&&D.isVertexColor?eo(D):void 0,O=A&&A.isVertexColor?eo(A):void 0,U=E&&E.isVertexColor?eo(E):void 0;if(y>0){const S=e.getBucket("polygonExtrusion","sideFill",M,$n.sinks.sideFill.binder);let P=S.indices.offset;if(qc(S,f,o,a,c,y,0,b,v,g,void 0,_),S.objectsData[P]={objectId:h,size:S.indices.offset-P},n.style.sideTextures.forEach((x,F)=>{var N,Z;if(w<x.minWallHeight)return;const C=x.sliceSize[0]*Ie*p,k=x.sliceSize[1]*Ie*p,R=x.wallPadding.map(q=>q*Ie*p),G=Dt((Z=(N=i.tileInfo)==null?void 0:N.coords[2])!=null?Z:15),X=gi(t,n,u,l,d,F,i),H=e.getBucket("polygonExtrusion","sideTexture",X,$n.sinks.sideTexture.binder),Q=H.indices.offset,J=x.vertical.mode==="stripe-top"?y-k:0;qc(H,f,o,a,c,y,J,void 0,void 0,g,{config:x,textureWidthMapPoints:C,textureHeightMapPoints:k,wallPaddingMapPoints:R,tileSizeMapPoints:G},_),H.objectsData[Q]={objectId:h,size:H.indices.offset-Q}}),!l&&(!r.AALinesOff||!gh(n,i))){const x=e.getBucket("polygonExtrusion","sideStroke",M,$n.sinks.sideStroke.binder);P=x.indices.offset,Jc(x,f,o,a,c,g),Kc(x,f,o,a,c,y,g,O),x.objectsData[P]={objectId:h,size:x.indices.offset-P}}}const B=e.getBucket("polygonExtrusion","topFill",M,$n.sinks.topFill.binder);let $=B.indices.offset;Y2(B,f,o,a,y,b,v,g,U),B.objectsData[$]={objectId:h,size:B.indices.offset-$};const V=e.getBucket("polygonExtrusion","topStroke",M,$n.sinks.topStroke.binder);$=V.indices.offset,W2(V,f,o,a,c,y,g,O),V.objectsData[$]={objectId:h,size:V.indices.offset-$}}};function Y2(e,t,n,i,s,r,o,a,c){let l=e.elements.offset;const u=l;Qc(e,l++,n[0],i[0],s,r,o,a,c),Qc(e,l++,n[1],i[1],s,r,o,a,c);for(let d=2;d<t;d++)Z2(e,u,d),Qc(e,l++,n[d],i[d],s,r,o,a,c);e.elements.offset=l}function W2(e,t,n,i,s,r,o,a){for(let c=0;c<t;c++){const l=dt(c,t);if(s&&s[l]===1){const u=dt((c+1)%t,t);Hs(e,n[l],i[l],r,n[u],i[u],r,o,void 0,void 0,void 0,void 0,void 0,void 0,a)}}}function Qc(e,t,n,i,s,r,o,a,c){const l=e.elements.stride,u=t*(l/e.views.position.BYTES_PER_ELEMENT),d=t*(l/e.views.height.BYTES_PER_ELEMENT);e.views.position[u]=z+n,e.views.position[u+1]=z+i,e.views.height[d]=it(s)/Ge,e.views.demPosition[u]=(z+a[0])/8,e.views.demPosition[u+1]=(z+a[1])/8;const f=t*(l/e.views.localID.BYTES_PER_ELEMENT);e.views.localID[f]=r,e.views.labelingTextureID[f]=o,c!==void 0&&(e.views.innerColor[f]=c)}function Z2(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 wh(e){return re(lo-Math.abs(e[0]-lo),2)+re(lo-Math.abs(e[1]-lo),2)}function X2(e){return e[0]===0||e[0]===te||e[1]===0||e[1]===te}function q2(e,t,n){let i,s=re(te,2);const r=e.length,o=Ms();for(let a=0;a<r;a++){i||ai(o,[e[a],t[a]]);const c=dt(a,r);if(n[c]===0){const l=[e[c],t[c]],u=dt((a+1)%r,r),d=[e[u],t[u]];if(X2(l)){const f=wh(l);f<s&&(i=l,s=f);const h=wh(d);h<s&&(i=d,s=h)}else i=[(e[c]+e[u])/2,(t[c]+t[u])/2]}}return i||(i=[],Dr(i,o)),i}const Ys={type:di.Striped,cDist:0,oLen:0,sLen:0,localID:0,offsetMultiplier:14,px:[],py:[],count:0};function J2(e,t,n,i){return Ys.cDist=e,Ys.oLen=t,Ys.localID=n,Ys.offsetMultiplier=i,Ys}const vn={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 Fe([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 Fe([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=Zr(j(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:c}=i,l=j(n.ignoreTier,i)?null:i.tileAttrs[c.db_tiers],u=a[c.db_hidden_by_metro_building_id]||"";let d=n.style.mode==="3d";const f=d?(b=o.z)!=null?b:Zc(i,o):void 0;d&&(!f||!Xc(f))&&(d=!1);const h=d?e.getBucket(n.type,"stroke3d",vn.sinks.stroke3d.packObjectAttributes(t,n,i),vn.sinks.stroke3d.binder):e.getBucket(n.type,"stroke",vn.sinks.stroke.packObjectAttributes(t,n,l,u,i),vn.sinks.stroke.binder),g=e.idIndexer.getIndex(i,t,n),w=J2(a[c.componentDistanceStart]/te,a[c.objectLength]/te,g,d?vn.sinks.stroke3d.stride/2:vn.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;Pc(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)}},uo=[Ge/2,Ge/2],bn={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)=>Fe([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: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)},packObjectAttributes:(e,t,n,i,s)=>Fe([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:"",u=i.idIndexer.getIndex(n,e,t),d=i.pointIndexer.getIndex(l),f=i.getBucket(t.type,"fill",bn.sinks.fill.packObjectAttributes(e,t,a,c,l,n),bn.sinks.fill.binder,o);Q2(f,r);for(let g=0;g<s.length;g++)K2(f,s,g,u,d)},processOuterEdge(e,t,n,i,s,r,o){var l;const a=(l=n.id)!=null?l:"",c=i.getBucket(t.type,"stroke",bn.sinks.stroke.packObjectAttributes(e,t,o,a,n),bn.sinks.stroke.binder);for(let u=0;u<r.length;u+=2){const d=r[u]*5,f=r[u+1]*5;Hs(c,s[d],s[d+1],s[d+2],s[f],s[f+1],s[f+2],uo,!0)}}};function K2(e,t,n,i,s){const r=e.elements.offset,o=bn.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]=uo[0]/8,e.views.demPosition[c+1]=uo[1]/8,e.views.labelingTextureID[l]=s,e.elements.offset++}function Q2(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 qi=Ce(),Ws=Ce(),Ji={type:di.Entrance,offsetMultiplier:18,cDist:0,oLen:0,sLen:0,px:[],py:[],count:0,localID:0};function eb(e,t,n,i){return Ji.px=e.x,Ji.py=e.y,Ji.oLen=n/te,Ji.count=t,Ji.localID=i,Ji}const Zs={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 Fe([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=tb(r,o,a),l=e.getBucket(n.type,"stroke",Zs.sinks.stroke.packObjectAttributes(t,n,a,i),Zs.sinks.stroke.binder),u=e.idIndexer.getIndex(i,t,n),d=eb(s,a,c,u);Pc(s.x,s.y,void 0,a,_e.Butt,_e.Butt,0,0,0,0,d,l);let f=0;vh(l,Ps.StartBorder,r[0],o[0],r[1],o[1],0,0,f,c,u);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)}vh(l,Ps.Arrow,r[h],o[h],r[h+1],o[h+1],-1,0,f,c,u)}}};function tb(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 vh(e,t,n,i,s,r,o,a,c,l,u){nb(e,1,2,0,0,2,3),fo(e,t,n,i,s,r,o,a,-1,-1,c,l,!0,u),fo(e,t,n,i,s,r,o,a,1,-1,c,l,!1,u),fo(e,t,n,i,s,r,o,a,1,1,c,l,!1,u),fo(e,t,n,i,s,r,o,a,-1,1,c,l,!0,u)}function fo(e,t,n,i,s,r,o,a,c,l,u,d,f,h){const g=e.elements,w=g.stride*g.offset,p=w>>1,y=p>>1;tn(qi,n,i,s,r),kn(Ws,qi),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(Ws[0]*l*(f?-1:1)*Ne),e.views.texExtender[w+1]=$e(Ws[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,M=qi[0]*b+Ws[0]*v,E=qi[1]*b+Ws[1]*v;e.views.extender[p]=Math.round(M*Ne*127),e.views.extender[p+1]=Math.round(E*Ne*127),e.views.direction[p]=Math.round(qi[0]*127),e.views.direction[p+1]=Math.round(qi[1]*127),e.views.vertexDistance[y]=u/Ge,e.views.objectLength[y]=d/Ge,e.views.type[y]=t,e.views.localID[y]=h,e.elements.offset++}function nb(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:u}=c,d=a.offset;l[u]=d+t,l[u+1]=d+n,l[u+2]=d+i,l[u+3]=d+s,l[u+4]=d+r,l[u+5]=d+o,c.offset=u+6}const ho={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)=>Fe([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",ho.sinks.fill.packObjectAttributes(t,n,i),ho.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?gc(i.tileInfo,a):[0,0,0];ib(r,0,2,1,0,3,2),po(r,a,c,-1,-1,o),po(r,a,c,-1,1,o),po(r,a,c,1,1,o),po(r,a,c,1,-1,o)}};function po(e,[t,n,i],s,r,o,a){const l=e.elements.offset*e.elements.stride>>1,u=l>>1;e.views.flatPosition[l]=z+t,e.views.flatPosition[l+1]=z+n,e.views.flatPosition[l+2]=it(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[u]=a,e.elements.offset++}function ib(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:u}=c,d=a.offset;l[u]=d+t,l[u+1]=d+n,l[u+2]=d+i,l[u+3]=d+s,l[u+4]=d+r,l[u+5]=d+o,c.offset=u+6}const Ki=Ce(),Qi=Ce(),bh=Ce(),Ih=Ce(),el=(e,t,n,i)=>Fe([e,t.innerId,n],t,i),tl=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],tileData:e.slice(3)}),Xs=of(1),In={symbol:"lineExtrusion",sinks:{fill:{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.innerColor=new Uint32Array(t,12)},packObjectAttributes:el,unpackObjectAttributes:tl},topStroke:{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.innerColor=new Uint32Array(t,16)},packObjectAttributes:el,unpackObjectAttributes:tl},sideStroke:{stride:24,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:el,unpackObjectAttributes:tl}},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]||"",u=e.getBucket(n.type,"fill",In.sinks.fill.packObjectAttributes(t,n,l,i),In.sinks.fill.binder),d=e.getBucket(n.type,"topStroke",In.sinks.topStroke.packObjectAttributes(t,n,l,i),In.sinks.topStroke.binder),f=e.getBucket(n.type,"sideStroke",In.sinks.sideStroke.packObjectAttributes(t,n,l,i),In.sinks.sideStroke.binder),h=!r.AALinesOff||!gh(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(Ki,w,y),je(Qi,p,b),je(bh,y,w),je(Ih,b,p),qc(u,2,Ki,Qi,void 0,Xs,void 0,void 0,void 0,void 0,void 0,0),Hs(d,w,p,Xs,y,b,Xs),h&&(Jc(f,2,Ki,Qi,void 0),Jc(f,2,bh,Ih,void 0),Kc(f,2,Ki,Qi,void 0,Xs))}h&&(je(Ki,o[c-1],o[0]),je(Qi,a[c-1],a[0]),Kc(f,2,Ki,Qi,void 0,Xs))}},mo={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 Fe([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",mo.sinks.fill.packObjectAttributes(n,s,i,r,o),mo.sinks.fill.binder);let u=l.elements.offset;sb(l.indices,u,0,1,2,2,1,3),yo(l,u++,a[0],c[0],0,1),yo(l,u++,a[1],c[1],1,1),yo(l,u++,a[2],c[2],0,0),yo(l,u++,a[3],c[3],1,0),l.elements.offset=u}};function yo(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 sb(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 nl(e,t,n,i,s,r){return Fe([e,t.innerId,n,i,s],t,r)}const rb=(e,t,n,i,s)=>Fe([e,t.innerId,n,i],t,s),il=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],hiddenByFloorComplexId:e[4],tileData:e.slice(5)}),ob=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],tileData:e.slice(4)}),ab=(e,t)=>{const n=e.type==="polygon"&&j(e.style.color,t),i=vf(n)&&n.factor.type==="vertexAttribute";return i?{withMixFactor:i,mixFactorAttributeName:n.factor.name}:{withMixFactor:i,mixFactorAttributeName:void 0}},Zt={symbol:"polygon",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.localID=new Uint32Array(t,4)},packObjectAttributes:nl,unpackObjectAttributes:il},stroke:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.directionDistance=new Int8Array(t,4)},packObjectAttributes:nl,unpackObjectAttributes:il},shadow:{stride:4,binder:(e,t)=>{e.views.position=new Uint16Array(t)},packObjectAttributes:rb,unpackObjectAttributes:ob},fillWithMixFactor:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.mixFactor=new Uint16Array(t,4)},packObjectAttributes:nl,unpackObjectAttributes:il}},generate(e,t,n,i,s,r,o){var A;if(i.tileAttrs[i.tileProps.db_geometry_type]==="polyline")return;const{withMixFactor:c,mixFactorAttributeName:l}=ab(n,i),u=s.x,d=s.y,f=s.cut,h=i.tileAttrs[i.tileProps.db_plan_id]||"",g=c?s[l]:void 0;if(G2(n)&&o&&(Wc(e,t,o,n.style,r),n.style.normalMapTextureImage)){const D={textureImage:n.style.normalMapTextureImage,textureSize:n.style.normalMapTextureSize,lengthUnits:n.style.normalMapTextureLengthUnits};Wc(e,t,o,D,r)}const w=e.idIndexer.getIndex(i,t,n,{floorId:h||void 0}),p=(A=i.id)!=null?A:"",y=n.type==="polygon"&&!j(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",Zt.sinks.fillWithMixFactor.packObjectAttributes(t,n,y,h,b,i),Zt.sinks.fillWithMixFactor.binder):e.getBucket("polygon","fill",Zt.sinks.fill.packObjectAttributes(t,n,y,h,b,i),Zt.sinks.fill.binder),M=v.indices.offset;Mh(v,u.length,u,d,w,g),v.objectsData[M]={objectId:p,size:v.indices.offset-M};const E=e.getBucket("polygon","stroke",Zt.sinks.stroke.packObjectAttributes(t,n,y,h,b,i),Zt.sinks.stroke.binder);if(f){const D=E.indices.offset;cb(E,u.length,u,d,f),E.objectsData[D]={objectId:p,size:E.indices.offset-D}}}};function Mh(e,t,n,i,s,r){const o=e.indices.buffer;let a=e.indices.offset,c=e.elements.offset;const l=c;sl(e,c++,n[0],i[0],s,r==null?void 0:r[0]),sl(e,c++,n[1],i[1],s,r==null?void 0:r[1]);for(let u=2;u<t;u++)lb(o,a,l,u),sl(e,c++,n[u],i[u],s,r==null?void 0:r[u]),a=a+3;e.elements.offset=c,e.indices.offset=a}function cb(e,t,n,i,s){for(let r=0;r<t;r++){const o=dt(r,t);if(s[o]===1){const a=dt((r+1)%t,t);Hs(e,n[o],i[o],0,n[a],i[a],0)}}}function sl(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 lb(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 ub(e,t,n=[],i=[]){return{x:Th(n,e),y:Th(i,t)}}function Th(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:db(e)}}function db(e){var t;return!((t=e==null?void 0:e[0])!=null&&t[0])}function fb(e,t,n,i,s){return[Sh(e.x,t,i[0],s),Sh(e.y,n,i[1],s)]}function Sh(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 hb(e,t,n,i,s=0,r=0){return[Ah(Eh(e.x,t),i,s),Ah(Eh(e.y,n),i,r)]}function Eh(e,t){const{stretchSize:n,fixSize:i}=pb(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],u=s[c],d=c%2===(r?1:0),f=a[a.length-1];if(!d){a.push(f+u-l);continue}a.push(Math.round((o-i)*(u-l)/n)+f)}return a}function pb({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 Ah(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 mb(e,t,n,i,s,r,o,a,c){const l=ub(n.w,n.h,a,c),u=fb(l,n.x,n.y,t,ku),d=hb(l,i,s,ku,r,o);e.set(d,u)}function yb(e,t,n,i,s,r,o,a,c,l,u,d){const{textureX:f,textureY:h,stretchedX:g,stretchedY:w,countX:p,countY:y}=s,b=o!==-1/0?o:qm,v=a!==1/0?a:Jm,[M,E]=d;for(let A=0;A<p-1;A++){const D=f[A],_=f[A+1],O=g[A],U=g[A+1];for(let B=0;B<y-1;B++){const $=h[B],V=h[B+1],T=w[B],I=w[B+1];xh(r,0,2,1,1,2,3),go(r,e,t,n,i,O,T,D,$,M,E,b,v,c,l,u),go(r,e,t,n,i,U,T,_,$,M,E,b,v,c,l,u),go(r,e,t,n,i,O,I,D,V,M,E,b,v,c,l,u),go(r,e,t,n,i,U,I,_,V,M,E,b,v,c,l,u)}}}const wi=[0,0];function gb(e,t,n,i,s,r,o){const{stretchedX:a,stretchedY:c}=i,l=Math.ceil((a[a.length-1]-a[0])/2),u=Math.ceil((c[c.length-1]-c[0])/2),d=r*Sa/2;wi[0]=a[0]+l,wi[1]=c[0]+u;const f=wi[0]-d,h=wi[0]+d,g=wi[1]-d,w=wi[1]+d;return xh(s,0,2,1,1,2,3),wo(s,e,t,n,f,g,o),wo(s,e,t,n,h,g,o),wo(s,e,t,n,f,w,o),wo(s,e,t,n,h,w,o),wi}function go(e,t,n,i,s,r,o,a,c,l,u,d,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]=it(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]=u,e.views.texCoords[p]=At(a),e.views.texCoords[p+1]=At(c),e.views.scales[p]=f2(d),e.views.scales[p+1]=d2(f),p=p>>1,e.views.localID[p]=h,e.views.labelingTextureID[p]=g,e.views.spritePointTextureID[p]=w,e.elements.offset++}function wo(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]=it(i),e.views.cornerOffset[c]=s,e.views.cornerOffset[c+1]=-r,e.views.labelingTextureID[c>>1]=o,a.offset++}function xh(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:u}=c,d=a.offset;l[u]=d+t,l[u+1]=d+n,l[u+2]=d+i,l[u+3]=d+s,l[u+4]=d+r,l[u+5]=d+o,c.offset=u+6}class wb{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||{}),vi=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e))(vi||{}),qs=(e=>(e[e.Tile=0]="Tile",e[e.Floor=1]="Floor",e[e.DynamicObject=2]="DynamicObject",e[e.PersonalPoi=3]="PersonalPoi",e))(qs||{}),Nt=(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))(Nt||{}),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 _h=Math.random;const vb=e=>{const t={randomSeed:0};_f(t,[e]),_h=()=>Rs(t,0,1)};function bb(e,t,n,i){const s=Ph(e,n,i),r=Ph(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 Ph(e,t,n){const i=e[t];if(i!==void 0)return i[n]}var Mn=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e[e.OneWayLine=2]="OneWayLine",e))(Mn||{});function ht(e,t){return Number.isNaN(e)?t:e}function vo(e,t){if(!e)return"";const n=j(e,t);return!Number.isNaN(n)&&(n||n===0)?String(n):""}const pt=4294967295,Tn=4294967040,Ib=Tn-1,rl={},Mb=1e6,Lh=["main","parser","labeling","models"];let ol=0;Lh.forEach(e=>{const t=ol+Math.floor(Ib/Lh.length);rl[e]={min:ol,max:t-Mb},ol=t});class Tb{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=rl[t].min,this.maxIdentifyIndex=rl[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],u=l&&i.type!=="polygon3d"||i.type==="embankment";return!!r&&c&&!l&&!u?this.getIndexInternal(de({id:r,styleId:n,layer:i,sublayer:a[o.db_sublayer]},s)):pt}getIndexInternal(t){var r,o,a,c,l,u,d;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(Ta,Ta),typeof s=="string"){const f=(d=(u=t.metatile)==null?void 0:u.dictionaries.db_object_class)==null?void 0:d[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,u=new Int32Array(this.center).buffer,d=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:d,endIndex:f,phaseBuffer:s,sublayerBuffer:r,styleIdBuffer:o,layerIdBuffer:a,instanceIdBuffer:c,objectClassBuffer:l,centerBuffer:u,strings:h}}}function Sb(e){return e.type==="labelLine"||e.type==="point"||e.type==="oneWayLine"}function Eb(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||!Sb(l)){console.error(`Not found layer: ${a.layerId} in style ${a.styleId} in unpackPreLabelingResult`);continue}const u=new al(a,l,t,o.metatileHash,!!i.floorStackOn);switch(a.type){case Mn.Point:u.setSpecificPointAttributes(a,i,s);break;case Mn.Line:u.setSpecificLineAttributes(a,i,s);break;case Mn.OneWayLine:u.setSpecificOneWayAttributes(a);break}r.push(u)}return r}class al{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===Mn.Point?t.geometryType:vi.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=Ht(i,n,!0,t.tileData);this.label=Sc(vo(s.textField,r),s.textMaxLengthPerLine),s.textField2&&(this.label2=Sc(vo(s.textField2,r),s.textMaxLengthPerLine)),this.layer.type==="point"&&s.iconTextField&&(this.iconLabel=Sc(vo(s.iconTextField,r),s.textMaxLengthPerLine));const o=ct(t.tileCoords);this.mapPointVertices=[];const a=[0,0,0],c=[0,0,0];if(t.geometryType===vi.Point)sf(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],Tt(c,a,o),this.mapPointVertices.push(c[0],c[1],c[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=zi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=zi(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=Ht(i,n,!0,t.tileData);this.label=vo(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],Tt(a,o,r),this.mapPointVertices.push(a[0],a[1],a[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=zi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=zi(t.objectLength,t.tileCoords[2]),this.tiers=j(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],Tt(s,i,n),this.mapPointVertices.push(s[0],s[1],s[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=zi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=zi(t.objectLength,t.tileCoords[2]),this.tiers=t.tiers}updateRanges(){this.ranges=Tw([this.label,this.label2,this.iconLabel])}}function Yn(e,t,n){const{minX:i,maxX:s,minY:r,maxY:o}=n;e.push(i,r,s-i,o-r,t)}function Sn(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 bb(s,r,n,i)}function cl(e,t,n,i,s,r){const o=Sn(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 Dh(e,t,n,i,s){if(e.placementIndex===-1){s&&Yn(s,Nt.CommercialDead,Sn(e,0,i.leftRight,i.topBottom));return}if(cl(t,e,0,i.leftRight,i.topBottom,n))e.placementIndex=-1,s&&Yn(s,Nt.CommercialDead,Sn(e,0,i.leftRight,i.topBottom));else{e.placementIndex=0;const o=Sn(e,0,i.leftRight,i.topBottom);t.insert(o),s&&Yn(s,Nt.CommercialAlive,o)}}function ll(e,t,n,i){let s=!0;for(let r=0;r<e.boxes.length;r++)if(cl(t,e,r,e.marginLeftRight,e.marginTopBottom,n)){if(s=!1,i)for(let o=0;o<e.boxes.length;o++){const a=Sn(e,o,e.marginLeftRight,e.marginTopBottom);let c;o===r?c=Nt.Dead:o<r?c=Nt.Alive:c=Nt.Unused,Yn(i,c,a)}break}if(s)for(let r=0;r<e.boxes.length;r++){const o=Sn(e,r,e.marginLeftRight,e.marginTopBottom);t.insert(o),i&&Yn(i,Nt.Alive,o)}e.placementIndex=s?0:-1}function xb(e,t,n,i){e.placementIndex=-1;for(let s=0;s<e.boxes.length;s++)if(!(e.firstLabel&&e.firstLabel.placementIndex!==s))if(cl(t,e,s,e.marginLeftRight,e.marginTopBottom,n))i&&Yn(i,Nt.Dead,Sn(e,s,e.marginLeftRight,e.marginTopBottom));else{const r=Sn(e,s,e.marginLeftRight,e.marginTopBottom);if(t.insert(r),e.placementIndex=s,i){Yn(i,Nt.Alive,r);for(let o=s+1;o<e.boxes.length;o++)Yn(i,Nt.Unused,Sn(e,o,e.marginLeftRight,e.marginTopBottom))}break}}function Oh(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 bi(e){return e.type!==Ye.Box&&!Number.isNaN(e.commPriorityRandomFactor)}function Ch(e){return e.label.pointType===ft.CommercialCity}function _b(e){return bi(e)&&Ch(e)}function Pb(e){return bi(e)&&e.label.pointType===ft.CommercialPremium}function Js(e){return e.pointType===ft.Commercial||e.pointType===ft.CommercialCity||e.pointType===ft.CommercialPremium}function Lb(e){return e.label.pointType!==ft.CommercialCity||e.placementIndex!==-1&&e.label.pointType===ft.CommercialCity}function Db(e,t){return t.size===0?!1:e.filter(i=>Ob(i,t)?(i.adsType=0,!0):!1).length>0}function Ob(e,t){return e.type===Ye.Icon&&t.has(e.label.id)}function Cb(e){return e.type===Ye.Box&&e.labelingGroup==="markerText"&&e.parent!==void 0}function Fb(e,t,n,i,s){const r=so();Oh(e.filter(Ch),n).forEach(a=>{Dh(a,r,t,i.city,s)}),r.clear(),Oh(e.filter(Lb),n).forEach(a=>{Dh(a,r,t,i.default,s)})}function Fh(e,t,n,i,s){switch(e.type){case Ye.LineText:case Ye.Icon:if(e.placementIndex===-1&&bi(e))break;if(ll(e,n,i,s),e.adsType===0){const o=t.get(e.label.id);if(!o)break;e.placementIndex!==-1&&(o.parent=e,ll(o,n,i,s),t.delete(e.label.id))}break;case Ye.Box:if(!e.parent){ll(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)?xb(e,n,i,s):e.placementIndex=-1;break}}function Rb(e,t,n,i,s,r){const o=[],a=new Map;t.forEach(_=>{if(Cb(_)){a.set(_.parent.label.id,_),_.placementIndex=-1;return}o.push(_)});const c=new Set(a.keys());let l=[];if(n.globeMode){for(const _ of e)r.ecef.canSee(_.anchorGeo)?l.push(_):_.placementIndex=-1;for(const _ of o)r.ecef.canSee(_.anchorGeo)?l.push(_):_.placementIndex=-1}else l=e.concat(o);const u=n.debugLabels?[]:void 0,{size:d,viewport:f}=n,h=d[0],g=d[1],w=(vr.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=so(),M=Db(l,c),E=l.sort((_,O)=>{const U=_.label instanceof al?_.label.hovered:0,B=O.label instanceof al?O.label.hovered:0,$=i.has(_.id),V=i.has(O.id),T=n.disableSurvivedPoiPrevalence?0:(V?1:0)-($?1:0),I=M?(O.adsType===0?1:0)-(_.adsType===0?1:0):0;return O.groupPriority-_.groupPriority||(bi(O)?O.commPriorityRandomFactor+ +V:0)-(bi(_)?_.commPriorityRandomFactor+ +$:0)||I||T||B-U||O.itemPriority-_.itemPriority||(O.label.id>_.label.id?1:O.label.id===_.label.id?0:-1)||O.label.layer.innerId-_.label.layer.innerId||O.anchorWorld[0]-_.anchorWorld[0]||O.anchorWorld[1]-_.anchorWorld[1]});let A=-1;const D=E.filter((_,O)=>bi(_)?(A=O,!0):!1);if(A!==-1){for(let _=0;_<=A;_++)Fh(E[_],a,v,b,u);v.clear(),Fb(D,b,i,s,u)}for(let _=0;_<E.length;_++)Fh(E[_],a,v,b,u);return u}const ul=new Map;class bo{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=Vn,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*Lr(t.geoPoint,c)),this.id=t.id+"_"+n+"_"+Math.floor(i[0]/1e3)+"_"+Math.floor(i[1]/1e3)+this.getIconLabelPriorityToId(t),Pd(this.anchorWorld,i),this.anchorGeo=t.geoPoint,s!==0&&(this.anchorWorld[2]*=s),a){const l=nt.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(Js(t))if(ul.has(this.label.id))this.commPriorityRandomFactor=ul.get(this.label.id);else{const l=_h();this.commPriorityRandomFactor=l,ul.set(this.label.id,l)}n===Ye.PoiText?(this.labelingGroup=this.layer.style.allowOverlap?jn: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?jn: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?jn: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(Js(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 Rh(e,t,n,i,s,r){if(!e||s&&!r)return[0,0];if(!r)return[e.w/t,e.h/t];const o=dl(n,i,r),a=st(n.style.iconTextPadding);return[a[3]+a[1]+o[0],a[0]+a[2]+o[1]]}function Io(e,t,n){return fl(ae(e.style.textFontSize,t),e.style.textLineHeight,n)}function Nh(e,t,n){return fl(ae(e.style.textFontSize2,t),e.style.textLineHeight,n)}function dl(e,t,n){return fl(ae(e.style.iconTextFontSize,t),e.style.iconTextLineHeight,n)}function fl(e,t,n){const s=e/zt.baseSize*n.maxWidth,r=e*t*n.lines.length;return[s,r]}function kh(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 Nb(e,t,n){var a,c,l,u;const i=(a=t[0])!=null?a:.5,s=(c=t[1])!=null?c:.5,r=(l=n[0])!=null?l:0,o=(u=n[1])!=null?u:0;return[(.5-i)*e[0]+r,(.5-s)*e[1]+o]}function Bh(e,t,n,i,s){var l,u,d,f;const r=(l=n[0])!=null?l:.5,o=(u=n[1])!=null?u:.5,a=(d=s[0])!=null?d: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 Mo(e,t,n,i,s){const r=t[0],o=t[1],a=n[0],c=n[1];let l=0,u=0;const d=c/2+o/2,f=c/2-o/2,h=-d,g=-f,w=a/2+r/2,p=a/2-r/2,y=-w,b=-p;switch(e){case"bottomCenter":u=d+s;break;case"rightCenter":l=w+s;break;case"topCenter":u=h-s;break;case"leftCenter":l=y-s;break;case"bottomRight":l=p,u=d+s;break;case"topRight":l=p,u=h-s;break;case"bottomLeft":l=b,u=d+s;break;case"rightBottom":l=w+s,u=g;break;case"rightTop":l=w+s,u=f;break;case"topLeft":l=b,u=h-s;break;case"leftTop":l=y-s,u=f;break;case"leftBottom":l=y-s,u=g;break}return[l+i[0],u+i[1]]}var Ii=(e=>(e[e.Static=0]="Static",e[e.Unique=1]="Unique",e[e.Loaded=2]="Loaded",e))(Ii||{});let Uh=1e4+1;const kb={w:0,h:0,x:0,y:0,atlasIndex:0,isPacked:!1},hl={};function Bb(e,t,n,i,s,r){const o=Mc(e,s);if(!hl[o]){const a=Uh++;hl[o]={type:Ii.Unique,isSvg:!1,index:a,key:o,name:"",fileName:"",id:e,regionId:n,url:r,rasters:t.map((c,l)=>ve(de({},kb),{rasterSetIndex:a,rasterIndex:l,w:c,h:c,anchorX:i[0],anchorY:i[1]}))}}return hl[o]}function Ub(e){const t=Uh++;return{type:Ii.Loaded,isSvg:!1,index:t,key:`loaded-${t}`,name:"",fileName:"",rasters:e.map((n,i)=>ve(de({},n),{rasterIndex:i,rasterSetIndex:t}))}}function Ks(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 pl(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 ml(e,t){const n=t.precomputes;return e.map((i,s)=>{const r=n[s];return r&&r.usage===Qe.Uniform?i:null})}var yl=(e=>(e[e.Icon=0]="Icon",e[e.First=1]="First",e[e.Second=2]="Second",e))(yl||{});const gl=new wb,es=[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)=>Ds([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)=>Ds([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])=>Ds([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=Ht(r.styleZoom,r.styleState,!0,c.tileData),u=r.styleState._activeFloorIds.length>0,d=Js(c)&&!u?"":c.floorId,f=zh(l,e,s,c),h=e.icons[lt(a.style.iconImage,l)],g=pl(h),w=Rh(f,s,a,l,g,c.iconTextMetrics),p=st(a.style.iconTextOffset),y=st(a.style.iconTextPadding);let b,v=[0,0];if(f)if(c.iconTextMetrics){const A=st(a.style.iconTextAnchor);b=dl(a,l,c.iconTextMetrics),v=Bh(w,b,A,y,p)}else{const A=st(a.style.iconOffset);v=kh(f,w,A)}Lt(es,n.anchorWorld,o);const{globeInterStartZoom:M}=Ln;if(!(!(r.globeMode&&r.zoom<M)&&!mc(es)))switch(Qs=nt.fromGeo(n.anchorGeo),n.type){case Ye.Icon:if(!f||g&&!c.iconTextMetrics)return;const A=g?h.stretchX:void 0,D=g?h.stretchY:void 0;if(wl(t,c,d,es,Qs,i,f,w[0]*s,w[1]*s,v[0]*s,v[1]*s,s,A==null?void 0:A.map(([O,U])=>[O*s,U*s]),D==null?void 0:D.map(([O,U])=>[O*s,U*s])),!b)return;const _=st(a.style.iconTextAnchor);zb(e,t,c,d,es,Qs,r,i,Nb(b,_,p),a,s);return;case Ye.PoiText:Gb(e,t,n,d,es,Qs,w,r,i,v,a,s);return;case Ye.PoiText2:jb(e,t,n,d,es,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=Ht(i.styleZoom,i.styleState,!0,e.tileData),c=zh(a,n,r,e),l=n.icons[lt(o.style.iconImage,a)],u=pl(l),d=Rh(c,r,o,a,u,e.iconTextMetrics);let f,h=[0,0];if(c&&(!u||e.iconTextMetrics)){if(e.iconTextMetrics){const y=st(o.style.iconTextAnchor),b=st(o.style.iconTextOffset),v=st(o.style.iconTextPadding);f=dl(o,a,e.iconTextMetrics),h=Bh(d,f,y,v,b)}else{const y=st(o.style.iconOffset);h=kh(c,d,y)}const p=new bo(e,Ye.Icon,t,i.buildingHeight,s,n,i.globeMode,i.styleState._floorHeight);p.boxes.push([-d[0]/2+h[0],-d[1]/2+h[1],d[0]/2+h[0],d[1]/2+h[1]]),e.labelingElements.push(p)}const g=lt(o.style.textFont,a);e.label.length>0&&g.length&&(Hb(e,t,n,d,i,s,h,o),e.label2&&$b(e,t,n,d,i,s,h,o))}};function zb(e,t,n,i,s,r,o,a,c,l,u){var w;const{iconTextMetrics:d}=n;if(!d||!l.style.iconTextFont)return;const f=Ht(o.styleZoom,o.styleState,!1,n.tileData),h=lt(l.style.iconTextFont,f),g=(w=e.fontNameToIndex[h])!=null?w:e.fontNameToIndex[Di];To(t,n,i,0,d,s,r,a,c,l,g,u)}function Gb(e,t,n,i,s,r,o,a,c,l,u,d){var E;const{label:f}=n,{textMetrics:h}=f,g=Ht(a.styleZoom,a.styleState,!1,f.tileData),w=lt(u.style.textFont,g);if(!w.length)return;const p=Io(u,g,h),y=(E=e.fontNameToIndex[w])!=null?E:e.fontNameToIndex[Di],b=n.parent?Qr(u.style.textPlacement,g):"centerCenter",v=ae(u.style.textOffset,g),M=Mo(b,o,p,l,v);To(t,f,i,1,f.textMetrics,s,r,c,M,u,y,d)}function jb(e,t,n,i,s,r,o,a,c,l,u,d){var D,_;const{label:f}=n,{textMetrics:h,textMetrics2:g}=f;if(!g||!u.style.textFont2)return;const w=Ht(a.styleZoom,a.styleState,!1,f.tileData),p=lt(u.style.textFont2,w);if(!p.length)return;const y=Io(u,w,h),b=Nh(u,w,g),v=ae(u.style.textOffset,w),M=ae((D=u.style.textOffset2)!=null?D:0,w,0),E=(_=e.fontNameToIndex[p])!=null?_:e.fontNameToIndex[Di],A=Mo(Qr(u.style.textPlacement,w),o,[b[0],y[1]],l,v);A[1]+=(y[1]+b[1])/2+M,To(t,f,i,2,g,s,r,c,A,u,E,d)}function To(e,t,n,i,s,r,o,a,c,l,u,d){if(i===1&&t.labelingElements.length===1){const h=e.getBucket("point","labelingTexture",sn.sinks.labelingTexture.packObjectAttributes(t),sn.sinks.labelingTexture.binder);t.checkPointOffset=Wb(h,r,s,l,d,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,u,n,ml(t.tileData,l)),sn.sinks.text.binder);Yb(f,t,r,o,s,l,i,t.checkPointOffset)}function Vb(e,t,n,i,s,r,o,a){return wl(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 wl(e,t,n,i,s,r,o,a,c,l,u,d,f,h){if(a<=0||c<=0)return;const g=t.layer;if(g.type!=="point")return;mb(gl,cn,o,a,c,l,u,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=gb(i[0],i[1],i[2],gl,w,d,t.labelingTextureIndex);const p=e.getBucket("point","raster",sn.sinks.raster.packObjectAttributes(t,r,o.atlasIndex,f!==void 0||h!==void 0,n,ml(t.tileData,g)),sn.sinks.raster.binder);yb(i[0],i[1],i[2],s,gl,p,-1/0,1/0,t.identifyIndex,t.labelingTextureIndex,t.spritePointTextureIndex,t.checkPointOffset)}function Hb(e,t,n,i,s,r,o,a){const{textMetrics:c}=e;if(!c)return;const l=Ht(s.styleZoom,s.styleState,!1,e.tileData),u=ae(a.style.textOffset,l),d=Io(a,l,c),f=new bo(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?Qr(a.style.textPlacement,l):"centerCenter",g=Mo(h,i,d,o,u);f.boxes.push([g[0]-d[0]/2,g[1]-d[1]/2,g[0]+d[0]/2,g[1]+d[1]/2]),e.labelingElements.push(f)}function $b(e,t,n,i,s,r,o,a){var y;const{textMetrics:c,textMetrics2:l}=e;if(!l)return;const u=Ht(s.styleZoom,s.styleState,!1,e.tileData),d=Io(a,u,c),f=Nh(a,u,l),h=ae(a.style.textOffset,u),g=ae((y=a.style.textOffset2)!=null?y:0,u,0),w=new bo(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=Mo(Qr(a.style.textPlacement,u),i,[f[0],d[1]],o,h);p[1]+=(d[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 zh(e,t,n,i){const{rasterSets:s}=t,{layer:r}=i;if(r.type!=="point")return;let o;const a=Js(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=st(r.style.iconAnchor);o=s.byKey[Hi(c,l[0],l[1])]}}if(o){const c=ae(r.style.iconWidth,e),l=Ks(o.rasters,c*n,!0);if(l!==void 0)return o.rasters[l]}}const So=[0,0];function Yb(e,t,n,i,s,r,o,a){let{textLineHeight:u,textLetterSpacing:d}=r.style;o===yl.Icon&&(u=r.style.iconTextLineHeight,d=r.style.iconTextLetterSpacing);const{identifyPoiLabelIndex:f,labelingTextureIndex:h,spritePointTextureIndex:g}=t,{lines:w,maxWidth:p}=s,y=u*zt.baseSize;let b=Gh(1,y,w.length);for(let v=0;v<w.length;v++){const M=w[v].width;let E=0;E=-M/2,So[0]=E,So[1]=b;const A=w[v].glyphs;for(let D=0;D<A.length;D++){const _=A[D];_.bitmap!==void 0&&qb(e[_.range],n,i,So,_,f,h,g,a),So[0]+=_.advance+zt.baseSize*d}b-=y}}const rn=[0,0];function Wb(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*zt.baseSize,u=-a/2,d=Gh(1,l,o.length),f=a/2,h=d-(o.length-1)*l;rn[0]=s*(u+f)/2,rn[1]=s*(d+h)/2;const g=s*Sa/2,w=rn[0]-g,p=rn[0]+g,y=rn[1]+g,b=rn[1]-g,v=e.elements.offset;return Po(e.indices,v,1,0,3,2,3,0),Ao(e,t,w,y,r),Ao(e,t,p,y,r),Ao(e,t,w,b,r),Ao(e,t,p,b,r),rn}function Zb(e,t,n,i,s,r,o){const a=n[1]+i.top,c=n[0]+i.left,l=a-i.height,u=c+i.width,d=Math.sin(s),f=Math.cos(s),h=c*f-a*d,g=c*d+a*f,w=u*f-a*d,p=u*d+a*f,y=c*f-l*d,b=c*d+l*f,v=u*f-l*d,M=u*d+l*f,E=e.elements.offset;xo(e,t,h,g,i.texLeft,i.texTop,r,o),xo(e,t,w,p,i.texRight,i.texTop,r,o),xo(e,t,y,b,i.texLeft,i.texBottom,r,o),xo(e,t,v,M,i.texRight,i.texBottom,r,o),Po(e.indices,E,1,0,3,2,3,0)}function Xb(e,t,n){const i=e.elements.offset,s=$e(Math.cos(n)),r=$e(Math.sin(n));_o(e,t,s,r,-1,-1),_o(e,t,s,r,1,-1),_o(e,t,s,r,1,1),_o(e,t,s,r,-1,1),Po(e.indices,i,0,1,2,2,3,0)}function Gh(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 qb(e,t,n,i,s,r,o,a,c){const l=i[1]+s.top,u=i[0]+s.left,d=l-s.height,f=u+s.width,[h,g]=c,w=e.elements.offset;Eo(e,t,n,u,l,s.texLeft,s.texTop,h,g,r,o,a),Eo(e,t,n,f,l,s.texRight,s.texTop,h,g,r,o,a),Eo(e,t,n,u,d,s.texLeft,s.texBottom,h,g,r,o,a),Eo(e,t,n,f,d,s.texRight,s.texBottom,h,g,r,o,a),Po(e.indices,w,1,0,3,2,3,0)}function Eo(e,t,n,i,s,r,o,a,c,l,u,d){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]=it(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]=u,e.views.spritePointTextureID[g]=d,f.offset++}function Ao(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]=it(t[2]),e.views.cornerOffset[o]=n,e.views.cornerOffset[o+1]=i,e.views.labelingTextureID[o>>1]=s,r.offset++}function xo(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]=it(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 _o(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 Po(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 vl=[0,0,0],er=[0,0],Lo={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)=>Ds([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 _;const{label:a,anchorPosition:c,anchorSegmentIndex:l,halfLabelWidth:u,layer:d}=n;if(d.type!=="labelLine")return;const{axis:f}=a,{center:h,styleZoom:g}=r,w=Ht(g,r.styleState,!1,a.tileData),p=lt(d.style.textFont,w),y=(_=e.fontNameToIndex[p])!=null?_:e.fontNameToIndex[Di],b={},v=j(d.ignoreTier,w)?null:a.tiers;for(const O of a.ranges)b[O]=t.getBucket("labelLine","raster",Lo.sinks.raster.packObjectAttributes(a,i,O,y,v!=null?v:null,ml(a.tileData,d)),Lo.sinks.raster.binder);const M=a.textMetrics.lines[0],E=ae(d.style.textFontSize,w)/zt.baseSize,A=M.glyphs,D=Jb(f,c,u,r.rotation);er[0]=-M.width/2,er[1]=0;for(let O=0;O<A.length;O++){const U=A[O],B=(er[0]+U.left+U.width/2)*E*(D?-1:1),$=br(B)||1;let V=-1/0,T=1/0;for(let I=l;I>=1&&I<f.vertexCount&&!(T<n.overflowStyleZoom);I+=$,T=V){const S=$===1?I:I-1;V=Od(Ed(B,f.lengths[S]-c),h);const P=f.interpolate(c,I);Lt(vl,P,o),mc(vl)&&U.bitmap!==void 0&&Zb(b[U.range],vl,er,U,P[3]+(D?Math.PI:0),Math.max(V,n.overflowStyleZoom),T)}er[0]+=U.advance+zt.baseSize*d.style.textLetterSpacing}},getLabelingInfo(){}};function Jb(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 bl=[0,0,0],Do={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)=>Ds([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 u;const{label:a,anchorWorld:c}=n;if(Lt(bl,c,o),!mc(bl))return;const l=t.getBucket("oneWayLine","raster",Do.sinks.raster.packObjectAttributes(a,i,(u=a.tiers)!=null?u:null),Do.sinks.raster.binder);Xb(l,bl,c[3])},getLabelingInfo(){}},Mi={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(j(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",Mi.sinks.framebuffer.packObjectAttributes(t,n.innerId),Mi.sinks.framebuffer.binder);for(let l=0;l<r.length;l++)Qb(c,0,1,2,2,1,3),Co(c,r[l],o[l],-1,-1,a),Co(c,r[l],o[l],1,-1,a),Co(c,r[l],o[l],-1,1,a),Co(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",Mi.sinks.fill.packObjectAttributes(t,n,i,s),Mi.sinks.fill.binder);let c=a.elements.offset;Kb(a.indices,c,0,1,2,0,2,3),Oo(a,c++,r[0],o[0]),Oo(a,c++,r[1],o[1]),Oo(a,c++,r[2],o[2]),Oo(a,c++,r[3],o[3]),a.elements.offset=c}};function Oo(e,t,n,i){const s=t*2;e.views.position[s]=n,e.views.position[s+1]=i}function Kb(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 Co(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 Qb(e,t,n,i,s,r,o){const{elements:a,indices:c}=e,{buffer:l,offset:u}=c,d=a.offset;l[u]=d+t,l[u+1]=d+n,l[u+2]=d+i,l[u+3]=d+s,l[u+4]=d+r,l[u+5]=d+o,c.offset=u+6}const eI=new Set(rd),tI=new Set(Oa),nI=new Set(Ca),iI=new Set(ad),sI=new Set(cd),rI=new Set(od);function Fo(e){return eI.has(e)}function jh(e){return tI.has(e)}function Vh(e){return nI.has(e)}function oI(e){return iI.has(e)}function Hh(e){return sI.has(e)}function aI(e){return rI.has(e)}const $h=(e,t,n,i,s,r,o,a,c,l,u)=>{var B,$,V,T;const{tileProps:d,tileAttrs:f}=i;if(cI(e,t,n,i,l,u),u)return;let h=ft.Common;const g=f[d.db_sublayer];jh(g)?h=ft.CommercialCity:Vh(g)?h=ft.CommercialPremium:Fo(g)?h=ft.Commercial:Hh(g)&&(h=ft.Landmark);const w=c.x.length===1?vi.Point:vi.Line;let p=[],y;if(w===vi.Point){if(i&&n.style.allowElevation){const I=ae(n.style.elevation,i);if(Number.isNaN(I))typeof c.z!="undefined"&&(c.z=[r<4?of(c.z[0]):c.z[0]]);else{const S=I*Ie*Ot(ct(o),[c.x[0],c.y[0]]);c.z=[S]}}p=[[c.x[0]],[c.y[0]],typeof c.z!="undefined"?[c.z[0]]:[0]],y=[0,0,0],Tt(y,[p[0][0],p[1][0],p[2][0]],ct(o))}else p=[c.x,c.y];const b=(B=i.id)!=null?B:"",v=($=f[d.db_plan_id])!=null?$:"",M=(V=f[d.db_plan_level])!=null?V:NaN;let E=pt,A=pt;Number.isNaN(b)||(E=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[d.db_object_class],instanceId:0,metatile:s,center:y,floorId:v,ignoreHover:!0}),A=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[d.db_object_class],instanceId:1,metatile:s,center:y,floorId:v,ignoreHover:!0}));const D=f[d.db_point_building_id],_=e.pointIndexer.getIndex(D),O=e.pointIndexer.getIndex(b),U={type:Mn.Point,pointType:h,geometryType:w,styleId:t.id,layerId:n.innerId,sourceId:a,tileCoords:o,id:(T=i.id)!=null?T:"",floorId:v,planLevel:M,identifyIndex:E,identifyPoiLabelIndex:A,labelingTextureIndex:_,spritePointTextureIndex:O,labelPriority:ht(f[d.db_label_priority],0),label2Priority:ht(f[d.db_label2_priority],0),styleIconPriority:ae(n.style.iconPriority,i),styleTextPriority:ae(n.style.textPriority,i),iconPriority:ht(f[d.db_icon_priority],0),hovered:ht(f[d.hovered],0),componentDistanceStart:ht(f[d.componentDistanceStart],0),componentDistanceEnd:ht(f[d.componentDistanceEnd],0),objectLength:ht(f[d.objectLength],0),vertices:p,demElevation:NaN,tileData:[...i.tileData]};e.addLabel(U)};function cI(e,t,n,i,s,r){var w;const{tileProps:o,tileAttrs:a}=i,{rasterSets:c,icons:l}=t,u=Fc(s),d=mi(n.style.iconWidth),f=Fo(a[o.db_sublayer]),h=Hh(a[o.db_sublayer]),g=st(n.style.iconAnchor);if(f||h){if(r)return;const p=f?Aa.rasterSizes:ld,y=Bb((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,d,u)}else mi(n.style.iconImage).forEach(p=>{if(!p.length)return;const y=c.byKey[Hi(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&&pl(b)?[{w:b.width,h:b.height}]:d.map(M=>({w:M,h:M}));e.atlasPacker.packSvg(y,v,u),r&&y.rasters.forEach(M=>e.atlasPacker.addRastersToLoad(t.id,M))})}const lI=(e,t,n,i,s,r,o)=>{var c;const a={type:Mn.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:j(n.ignoreTier,r)?void 0:r.tileAttrs[r.tileProps.db_tiers]};e.addLabel(a)},uI=(e,t,n,i,s,r,o)=>{var d;const{tileProps:a,tileAttrs:c}=r,l=j(n.ignoreTier,r)?null:c[a.db_tiers],u={type:Mn.OneWayLine,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:(d=r.id)!=null?d:"",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(u)};function dI(e,t,n){return Es(n.fontUrlTemplate,{name:e,range:String(t)})}function Il(e,t,n){const i=En(e)?e:Wn(t.iconBaseUrl,e);return Es(i,{subdomain:n,appHost:window.location.host})}function fI(e,t){return En(e)?e:Wn(t.modelsBaseUrl,e)}function hI(e,t,n){return En(e)||!t?e:vI(t)?Ts(t,{modelSrc:e,subdomain:qd(n)}):Wn(t,e)}function Yh(e,t,n){return e.replace("image",`image_${t}x${n}`)}const Wh=/_i$/;function pI(e){return Wh.test(e)}function mI(e){return e.replace(Wh,"")}function yI(e,t){const n=En(t.fontsPath)?t.fontsPath:Wn(t.rootUrl,t.fontsPath),i="{name}_{range}.pbf";e.fontUrlTemplate=Wn(n,i),e.iconBaseUrl=En(t.iconsPath)?t.iconsPath:Wn(t.rootUrl,t.iconsPath),e.modelsBaseUrl=En(t.modelsPath)?t.modelsPath:Wn(t.rootUrl,t.modelsPath)}function gI(e){return En(e.stylePath)?e.stylePath:Wn(e.rootUrl,e.stylePath)}const wI=new RegExp("^(?:(?:[a-z]+:)?(?:[a-z]+:)?//|data:)","i");function En(e){return wI.test(e)}function vI(e){return/{\w+}/g.test(e)}function Wn(...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=st(n.style.iconAnchor),s=Hi(e,i[0],i[1]);return t.rasterSets.byKey[s]}function bI(e,t,n,i){const s=t.icons[n.name];if(!s)return;const r=Ks(n.rasters,i*window.devicePixelRatio,!0);if(r===void 0)return;const o=Il(s.url,t,rc(e.map.state.subdomains,n.name)),{w:a,h:c}=n.rasters[r];return{fullUrl:o,width:a,height:c}}function II(e,t,n,i){const s=mI(i),r=Zh(s,t,n);if(!r)return;const o=t.icons[r.name];if(o)return Il(o.url,t,rc(e.map.state.subdomains,r.name))}function MI(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=Gf(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=Ks(o.rasters,c*window.devicePixelRatio,!0);if(h===void 0)return;const{w:g,h:w}=o.rasters[h],p=Yh(f,g,w);return{baseUrl:f,fullUrl:p,width:g,height:w}}const l=s.style.iconImage;if(!l)return;const u=lt(l,r);if(o=Zh(u,i,s),!o)return;const d=bI(e,i,o,c);if(d){if(pI(u)){const f=II(e,i,s,u);f!==void 0&&(d.fullUrlUnhovered=f)}return d}}function TI(e){return Array.isArray(e)?e:[e]}function SI(e){return e&&e.buffer instanceof ArrayBuffer}var Ti=(e=>(e[e.None=0]="None",e[e.Zoom=1]="Zoom",e[e.Distance=2]="Distance",e))(Ti||{}),Xh=(e=>(e[e.default=0]="default",e[e.flat=1]="flat",e[e.axis=2]="axis",e[e.centroid=3]="centroid",e))(Xh||{});const Zn=[0,0,0],tr=new Int16Array([0,0,0]),Re=new Array(16),Ml=new Float32Array(9),An=[0,0,0],Tl=[0,0,0],Sl=[0,0,0],Si=[0,0,0],Ro=[0,0,0],qh=[0,0,0],EI=yt(),AI=_r([1,1,1]),Xn={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=[],u,d,f,h,g,w,p,y){return Fe([e,t.innerId,n,l,c,r,o,i,s,u,d,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,u=0){var H,Q,J;const d=Zr(j(n.style.geometryModifier,i),r,s,i);if(d===null)return;const f=j(n.style.linkedIds,i),h=f===""?[]:TI(f),g=n.style.modelSrc,w=[];let p=Ti.None;const y=mi(g,i,n,!0),b=j(n.style.scene,i);if(y.length===1)w.push(0);else if(y.length>1){if(!nn(g)||g.type!=="step"||!nn(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=Ti.Zoom;break;case"distance":p=Ti.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===Ti.Distance&&y.reverse(),y.forEach((N,Z)=>{N===null&&Z!==0&&(y[Z]=y[Z-1])}),p===Ti.Distance&&y.reverse();const v=y.map(N=>N===null?"":N).map(N=>{let Z=t.modelIndex[N];return Z===void 0&&(N=hI(N,a!=null?a:"",r.coords),Z=e.addUsedModelByUrl(N)),e.addUsedModel(Z),Z}),{tileProps:M,tileAttrs:E}=i;let A=Tn;n.interactive?i.id&&(A=E[M.hovered]?pt:e.idIndexer.getIndex(i,t.id,n,{metatile:l,objectClass:E[M.db_object_class]})):A=n.interactiveOcclusion?Tn:pt;const D=(H=i.id)!=null?H:"-1",_=E[M.db_point_building_id],O=E[M.db_hidden_by_metro_building_id]||"";let U=Tn;i.id&&(U=e.pointIndexer.getIndex(_!=null?_:i.id));const B=c!=null&&c.has(E[M.db_sublayer])&&D!=="-1"?1:0,$=d.abs_z!==void 0&&Array.from(d.abs_z).some(N=>N)?d.abs_z:void 0,V=i.styleState.terrainEnabled===!0,T=i.tileAttrs[i.tileProps.db_extension_to_relief_surface],I=V&&!!$&&!Number.isNaN(T),S=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!$&&V,P=typeof i.sourceAttrs.sourceName=="string"?i.sourceAttrs.sourceName:"",x=e.getBucket("gltfModel","instances",Xn.sinks.instances.packObjectAttributes(t.id,n,v,w,p,o,P,i,B,B?_s(d.x[0],d.y[0],r):void 0,_,!!$,E[M.db_plan_id]||"",O,jg(r,d.x[0],d.y[0],u),I,S,b),Xn.sinks.instances.binder);let F=x.meta;if(F)F.linkedIds.push(...h);else{const N=M.db_plan_id?E[M.db_plan_id]:void 0;F=x.meta={linkedIds:h.slice(),modelsPath:a!=null?a:"",buildingId:D,planId:N}}B&&(F.sublayer=E[M.db_sublayer]),_&&(F.childrenIds||(F.childrenIds=[]),F.childrenIds.push(D));let C;const k=PI(E,i);if(k){const N=d.x[0],Z=d.y[0];Tt(Ro,[N,Z],r),C=[Ro,oe.fromGeo(k)]}const R=LI(E,i),G=DI(E,i);let X=0;for(let N=0;N<d.x.length;N++){if(Oe(Tl,0,0,0),Ir(j(n.style.rotation,i),Tl),Oe(An,1,1,1),Ir(j(n.style.scale,i),An),Oe(Sl,0,0,0),Ir(j(n.style.offset,i),Sl),d.xScaleDirection&&d.yScaleDirection&&d.scaleCorrection){const Z=d.x[N],q=d.y[N];Tt(Ro,[Z,q],r);const pe=d.xScaleDirection[N],me=d.yScaleDirection[N];Tt(qh,[pe,me],r),C=[Ro,qh],X=d.scaleCorrection[N]}Jh(d.x[N],d.y[N],(J=(Q=d.z)==null?void 0:Q[N])!=null?J:0,Sl,An,Tl,C,X,R,G,r,n.minzoom<Ln.globeMaxZoom),OI(x,Zn,tr,Ml,A,U,$==null?void 0:$[N])}},patchBuffer(e,t,n,i,s,r,o,a){const c=Xn.sinks.instances.stride*t;Jh(i[0],i[1],i[2],s,r,o,void 0,void 0,void 0,void 0,n,a);const l=Zn[0]+z,u=Zn[1]+z,d=Zn[2]/(32*Ge);e.subData(c+0,new Uint16Array([l,u])),e.subData(c+4,new Float32Array([d])),a&&e.subData(c+8,tr),e.subData(c+16,Ml)}};function xI(e,t,n,i){const s=n*te/Dt(i.coords[2]);_t(t,t,s),t[2]*=n,ii(e,e,t)}function Jh(e,t,n,i,s,r,o,a,c,l,u,d){Oe(Zn,e,t,n);const f=Ot(u,Zn)*Ie;if(za(Re),Er(Re,Re,be(r[2])),Id(Re,Re,be(r[1])),ja(Re,Re,be(r[0])),Fi(Re,Re,s),o)if(a)_I(Re,o[0],o[1]),Oe(An,a*Ie,a*Ie,f),Fi(Re,Re,An);else{ln(Si,o[1],o[0]),c?Er(Re,Re,c):Er(Re,Re,Math.atan2(Si[1],Si[0]));const h=l!=null?l:Tr(Si);Oe(An,h,h,h),Fi(Re,Re,An)}else Oe(An,f,f,f),Fi(Re,Re,An);if(ja(Re,Re,Math.PI/2),yy(Ml,Re),xI(Zn,i,f,u),d){const h=gc(u,Zn);tr[0]=h[0]*ot,tr[1]=h[1]*ot,tr[2]=h[2]*ot}}function _I(e,t,n){ln(Si,n,t),Er(e,e,Math.atan2(Si[1],Si[0]))}function PI(e,t){const n=e[t.tileProps.direction];return n===void 0?null:Array.isArray(n)?n:n.type==="Point"?n.coordinates:null}function LI(e,t){return e[t.tileProps.angle]}function DI(e,t){return e[t.tileProps.scale]}function OI(e,t,n,i,s,r,o){const a=e.elements.offset*Xn.sinks.instances.stride,c=e.views,l=a/c.flatPosition.BYTES_PER_ELEMENT,u=z+t[0],d=z+t[1],f=t[2]*rf;if(c.flatPosition[l]=u,c.flatPosition[l+1]=d,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,CI(e,u,d,f,i);const h=e.indices;h.buffer[h.offset]=e.elements.offset,h.offset++,e.elements.offset++}function CI(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=EI;Py(s,o);const a=_r(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 nr=[0,0,0],ir=[0,0,0],sr=[0,0,0],No=[0,0,0],Kh=(e,t,n,i,s)=>Fe([e,t.innerId,n,i],t,s),Qh=(e,t,n,i)=>Fe([e,t.innerId,n],t,i),e0=e=>({styleId:e[0],layerId:e[1],side:e[2],absZ:e[3],tileData:e.slice(4)}),t0=e=>({styleId:e[0],layerId:e[1],absZ:e[2],tileData:e.slice(3)}),K={symbol:"mesh",sinks:{fill:{stride:32,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),e.views.innerColor=new Uint32Array(t,28)},packObjectAttributes:Kh,unpackObjectAttributes:e0},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:Qh,unpackObjectAttributes:t0},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:Qh,unpackObjectAttributes:t0},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:Kh,unpackObjectAttributes:e0}},generate(e,t,n,i,s,r,o,a,c,l,u="fill",d=!1,f){var U,B,$,V;const h=r.x,g=r.y,w=r.signed_z;let p=0;if(n.type==="polygon3d"||n.type==="embankment"){const T=j(n.style.elevation,s),I=s.tileInfo?Ot(s.tileInfo,[0,0]):1;p=T*Ie*I}const y=r.gradient,b=r.abs_z,v=r.is_pivot,M=h.length,E=s.tileAttrs[s.tileProps.hovered],A=(U=s.id)!=null?U:"",D=e.pointIndexer.getIndex(A);let _=Tn;switch(n.type){case"polygon3d":{n.interactive?(_=E?pt:e.idIndexer.getIndex(s,t,n),!E&&_===pt&&(_=Tn)):_=n.interactiveOcclusion?Tn:pt;break}case"overpass":case"tunnel":{_=e.idIndexer.getIndex(s,t,n),_===pt&&(_=Tn);break}case"embankment":{_=Tn;break}default:{const{type:T}=n}}(n.type==="embankment"||n.type==="polygon3d")&&c&&Wc(e,t,c,n.style,a);let O;if(u==="inverse")O=e.getBucket("mesh","inverse",K.sinks.inverse.packObjectAttributes(t,n,!!b,s),K.sinks.inverse.binder);else if(u==="fill")O=e.getBucket("mesh","fill",K.sinks.fill.packObjectAttributes(t,n,i,!!b,s),K.sinks.fill.binder);else if(u==="depthClear")O=e.getBucket("mesh","depthClear",K.sinks.depthClear.packObjectAttributes(t,n,!!b,s),K.sinks.depthClear.binder);else return;for(let T=0;T<M-2;T++){const I=!(T%2);FI(O);const S=d?2:1,P=d?1:2,x=I?T+S:T+P,F=I?T+P:T+S,C=te/o.size;Oe(nr,h[T],g[T],((B=w==null?void 0:w[T])!=null?B:0)*C),Oe(ir,h[x],g[x],(($=w==null?void 0:w[x])!=null?$:0)*C),Oe(sr,h[F],g[F],((V=w==null?void 0:w[F])!=null?V:0)*C),Rd(No,nr,ir,sr),nr[2]/=C,ir[2]/=C,sr[2]/=C,nr[2]+=p,ir[2]+=p,sr[2]+=p;const k=O.elements.offset;El(O,nr,No,y==null?void 0:y[T],_,D,l,b==null?void 0:b[T],v==null?void 0:v[T],f),El(O,ir,No,y==null?void 0:y[x],_,D,l,b==null?void 0:b[x],v==null?void 0:v[x],f),El(O,sr,No,y==null?void 0:y[F],_,D,l,b==null?void 0:b[F],v==null?void 0:v[F],f),O.objectsData[k]={objectId:A,size:O.elements.offset-k}}}};function El(e,t,n,i,s,r,o,a,c,l){var h,g;const u=e.elements.stride*e.elements.offset,d=u/e.views.position.BYTES_PER_ELEMENT;e.views.position[d]=z+t[0],e.views.position[d+1]=z+t[1],e.views.height[u/e.views.height.BYTES_PER_ELEMENT]=t[2];const f=u/e.views.demPosition.BYTES_PER_ELEMENT;if(e.views.demPosition[f]=(((h=o==null?void 0:o[0])!=null?h:t[0])+z)/8,e.views.demPosition[f+1]=(((g=o==null?void 0:o[1])!=null?g:t[1])+z)/8,a!==void 0&&(e.views.absZ[u/e.views.absZ.BYTES_PER_ELEMENT]=a),e.views.isPivot[u/e.views.isPivot.BYTES_PER_ELEMENT]=c!=null?c:0,"normal"in e.views){const w=u/e.views.normal.BYTES_PER_ELEMENT,p=u/e.views.localID.BYTES_PER_ELEMENT,y=u/e.views.gradient.BYTES_PER_ELEMENT;e.views.normal[w]=$e(n[0]),e.views.normal[w+1]=$e(n[1]),e.views.normal[w+2]=$e(n[2]),e.views.gradient[y]=$e(i!=null?i:0),e.views.localID[p]=s,e.views.labelingTextureID[p]=r}if("innerColor"in e.views&&l!==void 0){const w=u/e.views.innerColor.BYTES_PER_ELEMENT;e.views.innerColor[w]=l}e.elements.offset++}function FI(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 n0=[0,0,0],i0=[0,0,0],s0=[0,0,0],ko=[0,0,0],ts={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)=>Fe([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 A;const c=s.x,l=s.y,u=(A=s.signed_z)!=null?A:[],d=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",ts.sinks.fill.packObjectAttributes(t,n,r,!!h,i),ts.sinks.fill.binder),v=b.indices.buffer;let M=b.indices.offset;const E=b.elements.offset;for(let D=2;D<g;D++){const _=!(D%2),O=_?D-2:D-1,U=_?D-1:D-2;RI(v,M,E,(D-2)*3+2),Oe(s0,c[O],l[O],u[O]*y),Oe(i0,c[U],l[U],u[U]*y),Oe(n0,c[D],l[D],u[D]*y),Rd(ko,s0,i0,n0),Al(b,c[O],l[O],u[O],d==null?void 0:d[O],f==null?void 0:f[O],h==null?void 0:h[O],ko,w,p),Al(b,c[U],l[U],u[U],d==null?void 0:d[U],f==null?void 0:f[U],h==null?void 0:h[U],ko,w,p),Al(b,c[D],l[D],u[D],d==null?void 0:d[D],f==null?void 0:f[D],h==null?void 0:h[D],ko,w,p),M+=3}b.indices.offset=M}};function RI(e,t,n,i){e[t]=n+i-2,e[t+1]=n+i-1,e[t+2]=n+i}function Al(e,t,n,i,s,r,o,a,c=t,l=n){const u=e.elements.offset*e.elements.stride,d=u/e.views.position.BYTES_PER_ELEMENT,f=u/e.views.normal.BYTES_PER_ELEMENT,h=u/e.views.demPosition.BYTES_PER_ELEMENT;e.views.position[d]=z+t,e.views.position[d+1]=z+n,e.views.height[u/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[u/e.views.gradient.BYTES_PER_ELEMENT]=s!=null?s:0,e.views.isPivot[u/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[u/e.views.absZ.BYTES_PER_ELEMENT]=o),e.elements.offset++}const NI=1,xl=-1,kI=1.3,r0=-200,o0=-300,BI=Math.tan(be(175/2)),kt=[0,0,0],qn=[0,0,0],UI=[0,0,0],rr=[0,0,0],_l=[0,0,0],Be=[0,0,0];let Bo=0,or=0;const zI=(e,t)=>e<0||t<0?Math.floor(Math.min(e,t)):Math.ceil(Math.max(e,t)),a0={symbol:"overpass",sinks:{},generate(e,t,n,i,s,r,o,a){var x,F,C,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,u=i.styleState.terrainEnabled===!0,d=!l,f=i.tileAttrs[i.tileProps.db_road_part],h=i.tileAttrs[i.tileProps.db_geometry_type],g=(x=i.tileAttrs[i.tileProps.db_tiers])==null?void 0:x[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,M=s.x.length,E=s.x,A=s.y,D=(F=s.cut)!=null?F:[],_=new Uint8Array(M);c.forEach((R,G)=>{_[G]=R?0:1});const O=f==="roadbed_tunnel"||f==="roadbed_tunnel_descent"||f==="border_tunnel"||f==="border_tunnel_descent";let U=!1;O?U=!1:U=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!l&&u,U&&(c=new Int32Array(c.length));const B=d?kI:1;u&&O&&(c=new Int32Array(c).map(R=>R*B)),je(rr,0,0);const V=Ot(r,rr)*Ie,T=te/r.size*V,I=Math.max(ae(n.style.borderWidth,i,0),0)*T,S=Math.max(ae(n.style.thickness,i,0),0)*V,P=I>0?Math.max(-S,ae(n.style.borderHeight,i,0)*V):0;if(Math.max(ae(n.style.tunnelHeight,i,0),0)*V,h==="polygon"){if(g===void 0)return;const R=[E,A,D,c,new Int8Array(M),_];l&&R.push(l);const G=f==="roadbed_tunnel_descent",X=f==="roadbed_tunnel"||G;ts.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]-=S*.01:H[3][N]-=S,H[4][N]=0;K.generate(e,v,n,ne.bottom,i,le(H),r,o,a,void 0,X?"inverse":"fill",!0);const Q=[];for(let N=0;N<g;N++)Q.push(N);const J=e.getBucket("polygon","shadow",Zt.sinks.shadow.packObjectAttributes(v,n,Q,"",i),Zt.sinks.shadow.binder);if(Mh(J,R[0].length,R[0],R[1],pt),X&&!G){const N=R.slice();N[3]=Array.from(R[3]).map(Z=>Z+Math.abs(Z/B)-1),N.length=4,K.generate(e,v,n,ne.top,i,le(N),r,o,a,void 0,"inverse")}if(G&&u&&!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),X=K.sinks.stroke.packObjectAttributes(v,n,ne.bottom,!!l,i),H=GI({x:E,y:A,cut:D,signed_z:c,is_pivot:_,abs_z:l});if(f==="tunnel_arch"&&!w){const Q=Math.max(P,0),J=Uo(H),N=HI(H,I),Z=H.map(Y=>{const ee=Y.slice();return ee[2]=d?o0:r0,l&&(ee[5]=0),ee[4]=0,ee});ce(e,X,Z);const q=Bt(N,J,I).map(Y=>(Y[2]=Q,Y[4]=1,Y)),pe=N.map(Y=>{const ee=Y.slice();return ee[2]=Q,ee[4]=1,ee}),me=Ae(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(Y=>{const ee=Y.slice();return ee[2]=Q,ee[4]=1,ee});ce(e,R,ye);const se=Ae(ye,Z);do K.generate(e,v,n,ne.side,i,le(se),r,o,a);while(e.isOverloaded());const W=Ae(ye.map(Y=>{const ee=Y.slice();return ee[2]=d?o0:r0,ee[4]=0,l&&(ee[5]=0),ee}),ye.map(Y=>{const ee=Y.slice();return ee[2]=0,ee}));do K.generate(e,v,n,ne.side,i,le(W),r,o,a,void 0,"inverse");while(e.isOverloaded());if(Q){const Y=Bt(N,J,I).map(tt=>(tt[2]=0,tt[4]=0,tt));ce(e,X,Y),ce(e,R,q);const ee=Ae(Y,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(tt=>{const mt=tt.slice();return mt[2]=0,mt[4]=0,mt}),ue=Ae([pe[0],De[0]],[q[0],Y[0]]);do K.generate(e,v,n,ne.side,i,le(ue),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,R,[pe[0],q[0]]),ce(e,G,[q[0],Y[0]]),ce(e,X,[Y[0],De[0]]);const fe=pe.length-1,qt=Ae([De[fe],pe[fe]],[Y[fe],q[fe]]);do K.generate(e,v,n,ne.side,i,le(qt),r,o,a,void 0,"fill");while(e.isOverloaded());if(ce(e,R,[pe[fe],q[fe]]),ce(e,G,[q[fe],Y[fe]]),ce(e,X,[Y[fe],De[fe]]),u){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(ue),r,o,a,void 0,"depthClear");while(e.isOverloaded());do K.generate(e,v,n,ne.side,i,le(qt),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],(C=c[0])!=null?C:0,0],J=!!b[y.beginningIsCut]&&c0(H[1],H[0],Q);J&&H.splice(0,0,Q);const N=H.length-1,Z=[b[y.nextPointX],b[y.nextPointY],(k=c[c.length-1])!=null?k:0,0],q=!!b[y.endingIsCut]&&c0(H[N-1],H[N],Z);q&&H.push(Z);const pe=Uo(H);J&&(pe.shift(),H.shift()),q&&(pe.pop(),H.pop());const me=H.map(ue=>{const fe=ue.slice();return fe[2]=Math.max(fe[2]-S,0),fe[4]=0,fe});ce(e,G,H);const ye=Bt(H,pe,I).map(ue=>{const fe=ue.slice();return fe[2]=Math.max(ue[2]-S,0),fe[4]=0,fe}),se=Bt(H,pe,I).map(ue=>{const fe=ue.slice();return fe[2]=Math.max(ue[2]+P,0),fe[4]=1,fe}),W=H.map(ue=>{const fe=ue.slice();return P>0&&(fe[2]=Math.max(fe[2]+P,0)),fe[4]=1,fe});if(P>0){ce(e,R,W);const ue=Ae(W,H.map(fe=>{const qt=fe.slice();return qt[4]=0,qt}));do K.generate(e,v,n,ne.side,i,le(ue),r,o,a);while(e.isOverloaded())}ce(e,X,ye),ce(e,R,se);const Y=Ae(se,W);do K.generate(e,v,n,ne.top,i,le(Y),r,o,a);while(e.isOverloaded());const ee=Ae(me,ye);do K.generate(e,v,n,ne.bottom,i,le(ee),r,o,a,void 0,"fill");while(e.isOverloaded());const De=Ae(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 ue=Ae([W[0],me[0]],[se[0],ye[0]]);do K.generate(e,v,n,ne.side,i,le(ue),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,R,[se[0],W[0]]),ce(e,G,[W[0],me[0]]),ce(e,G,[ye[0],se[0]]),ce(e,X,[me[0],ye[0]])}if(c[c.length-1]===0){const ue=me.length-1,fe=Ae([me[ue],W[ue]],[ye[ue],se[ue]]);do K.generate(e,v,n,ne.side,i,le(fe),r,o,a,void 0,"fill");while(e.isOverloaded());ce(e,R,[W[ue],se[ue]]),ce(e,G,[me[ue],W[ue]]),ce(e,G,[se[ue],ye[ue]]),ce(e,X,[ye[ue],me[ue]])}}else{const Q=Uo(H),J=f==="border_tunnel_descent",N=f==="border_tunnel"||J,Z=N?Math.max(P,0):P,q=H.map(se=>{const W=se.slice();return W[2]-=S,J?(W[2]=0,W[5]=1):N&&(W[2]=Math.max(W[2],xl)),W[4]=0,W}),pe=Bt(H,Q,I).map(se=>(se[2]-=S,J&&(se[2]=0,se[5]=1),se[4]=0,se)),me=Bt(H,Q,I).map(se=>(se[2]+=Z,J?(se[2]=Z,se[5]=1):N&&(se[2]=Math.max(se[2],xl)),se[4]=1,se)),ye=H.map(se=>{const W=se.slice();if(W[4]=1,J)W[2]=Z,W[5]=1;else if(N){const Y=Math.abs(W[2]/B),ee=Z-W[2],De=W[2]+Y-1;W[4]=(De+Math.abs(W[2]))/ee,W[2]=De}else W[2]+=Z;return W});if(N){J&&ce(e,R,ye);const se=Ae(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 W=ye.map(ee=>{const De=ee.slice();return De[2]=Math.min(ee[2],xl),De}),Y=Ae(W,H);do K.generate(e,v,n,ne.side,i,le(Y),r,o,a,void 0,"inverse",!0);while(e.isOverloaded())}if(P>0&&(!N||J)){ce(e,X,pe),ce(e,R,me);const se=Ae(me,ye);do K.generate(e,v,n,ne.top,i,le(se),r,o,a);while(e.isOverloaded());if(J&&u)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=Ae(q,pe);do K.generate(e,v,n,ne.bottom,i,le(se),r,o,a,void 0,"fill");while(e.isOverloaded());const W=Ae(pe,me);do K.generate(e,v,n,ne.side,i,le(W),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&u)do K.generate(e,v,n,ne.side,i,le(W),r,o,a,void 0,"depthClear");while(e.isOverloaded());if(c[0]===0){const Y=Ae([ye[0],q[0]],[me[0],pe[0]]);do K.generate(e,v,n,ne.side,i,le(Y),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&u)do K.generate(e,v,n,ne.side,i,le(Y),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,X,[q[0],pe[0]])}if(c[c.length-1]===0){const Y=q.length-1,ee=Ae([q[Y],ye[Y]],[pe[Y],me[Y]]);do K.generate(e,v,n,ne.side,i,le(ee),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&u)do K.generate(e,v,n,ne.side,i,le(ee),r,o,a,void 0,"depthClear");while(e.isOverloaded());ce(e,R,[ye[Y],me[Y]]),ce(e,G,[q[Y],ye[Y]]),ce(e,G,[me[Y],pe[Y]]),ce(e,X,[pe[Y],q[Y]])}}}}}};function GI(e){var i,s,r,o,a,c;const t=[],n=e.x.length;for(let l=0;l<n;l++){const u=[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&&u.push(e.abs_z[l]),t.push(u)}return t}function Uo(e){const t=[];tn(kt,e[0][0],e[0][1],e[1][0],e[1][1]),Bo=0;for(let n=1;n<e.length;n++)jI(t,e,n);return t}function jI(e,t,n){const i=n===t.length-1;if(je(UI,t[n-1][0],t[n-1][1]),je(rr,t[n][0],t[n][1]),ic(Be,kt),i)or=0;else{je(_l,t[n+1][0],t[n+1][1]),tn(qn,rr[0],rr[1],_l[0],_l[1]);const o=Te(Cn(kt,qn),-1,1),a=Math.min(Math.sqrt((1-o)/(1+o)),BI),c=br(Cn(Be,qn));or=a*c}let s=Be[0]+kt[0]*Bo,r=Be[1]+kt[1]*Bo;e.push([s,r]),i&&(s=Be[0]+kt[0]*or,r=Be[1]+kt[1]*or,e.push([s,r])),i||(Mr(kt,qn),Bo=or)}function Bt(e,t,n){const i=[];for(let s=0;s<e.length;s++){const r=e[s].slice();Mr(Be,t[s]),_t(Be,Be,n),jt(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;Hs(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 Ae(e,t){return VI([e[0]].concat(e,t.slice().reverse()))}function VI(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=dt(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 HI(e,t){return e=e.map(n=>n.slice()),Kt(Be,e[0],e[1]),Jt(Be,Be),Nn(Be,Be,t),ii(e[0],e[0],Be),Kt(Be,e[e.length-1],e[e.length-2]),Jt(Be,Be),Nn(Be,Be,t),ii(e[e.length-1],e[e.length-1],Be),e}const c0=(function(){const e=Math.cos(be(NI));return(t,n,i)=>(ln(kt,n,t),On(kt,kt),ln(qn,n,i),On(qn,qn),Cn(kt,qn)<=e)})();function $I(e,t,n,i){return Fe([e,t.innerId,n],t,i)}const zo={symbol:"metricPoint",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texCoords=new Uint16Array(t,4)},packObjectAttributes:$I,unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tiers:e[2],tileData:e.slice(3)})}},generate(e,t,n,i,s,r,o){WI(e,i,s,n,r);const a=ae(s.style.width,r),c=ae(s.style.height,r),l=ae(s.style.rotation,r),[u,d]=Jg([t.x,t.y],a,c,l,o),f=j(s.ignoreTier,r)?null:r.tileAttrs[r.tileProps.db_tiers],h=e.getBucket("metricPoint","fill",zo.sinks.fill.packObjectAttributes(i.id,s,f,r),zo.sinks.fill.binder);let g=h.elements.offset;YI(h.indices,g,0,1,2,0,2,3),Go(h,g++,u[0],d[0],0,0),Go(h,g++,u[1],d[1],1,0),Go(h,g++,u[2],d[2],1,1),Go(h,g++,u[3],d[3],0,1),h.elements.offset=g}};function Go(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 YI(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 WI(e,t,n,i,s){const{rasterSets:r}=t,o=Fc(i);mi(n.style.iconImage).forEach(a=>{if(!a.length)return;const c=r.byKey[Xr(a)];if(!c){console.error(`Not found raster set with texture ${a}`);return}if(!c.isSvg)return;const l=ae(n.style.width,s),u=ae(n.style.height,s),d=Wr(l,u),f=l*d,h=u*d;e.atlasPacker.packSvg(c,[{w:f,h}],o),c.rasters.forEach(g=>e.atlasPacker.addRastersToLoad(t.id,g))})}const ZI=64,Ei=1e5,Pl=4;function XI(e){return e!==null&&typeof e=="object"&&e.type===ZI}function l0(e){return d0(e.lo,e.hi)}function u0(e){return[e%Ei,Math.floor(e/Ei)%Ei,0,0]}function qI(e){let n=0;for(let i=0;i<Pl;i++){const s=e[i]*4294967296+n;n=Math.floor(s/Ei),e[i]=s%Ei}}function JI(e,t){let n=0;for(let i=0;i<Pl;i++){const s=e[i]+t[i]+n;n=Math.floor(s/Ei),e[i]=s%Ei}}function KI(e){const t="00000";let n=!0,i=Pl,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 d0(e,t){const n=u0(e),i=u0(t);return qI(i),JI(i,n),KI(i)}const Ke=[0,0,0],jo=[0,0,0],Vo=new Float64Array(16),f0={symbol:"tunnel",sinks:{},generate(e,t,n,i,s,r,o,a){var H,Q,J;const{tileProps:c,tileAttrs:l}=i,u=(H=l[c.db_tiers])==null?void 0:H[0];if(l0(l[c.id])!=="70030076221371399"||!u)return;const f=t.id;je(Ke,0,0);const g=Ot(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,M=b===0?0:-5,E=175,A=243,D=v===y?0:-5;if(Number.isNaN(y)||Number.isNaN(b)||y===0)return;const _=A-E,O=E+_*b/y,U=E+_*v/y,B=3.5*w,$=5*w,V=[];let T=0;for(let N=0;N<s.x.length;N++){const Z=[s.x[N],s.y[N],0];N>0&&(T+=Fn(Z,V[N-1]),Z[2]=T),V.push(Z)}const I=QI(V),S=Uo(V);V.forEach(N=>{const Z=N[2]/I;N[2]=(M+Z*(D-M))*g,N[5]=(O+Z*(U-O))*g});const P=K.sinks.stroke.packObjectAttributes(f,n,ne.side,!0,i),x=Bt(V,S,B),F=Bt(V,S,-B),C=Ae(x,F),k=Bt(V,S,$),R=k.map(N=>{const Z=N.slice();return Z[2]=Math.max(0,Z[2]),Z});K.generate(e,f,n,ne.side,i,le(Ae(k,R)),r,o,a,void 0,"inverse");const G=Bt(V,S,-$),X=G.map(N=>{const Z=N.slice();return Z[2]=Math.max(0,Z[2]),Z});K.generate(e,f,n,ne.side,i,le(Ae(X,G)),r,o,a,void 0,"inverse"),V[0][2]!==0&&V[V.length-1][2]!==0&&K.generate(e,f,n,ne.side,i,le(Ae(R,X)),r,o,a,void 0,"inverse");do ts.generate(e,f,n,i,le(C),u,r,void 0);while(e.isOverloaded());for(let N=1;N<V.length;N++){const Z=[],q=[],pe=V[N-1],me=V[N],ye=S[N-1],se=S[N];for(let Y=0;Y<=181;Y+=15){const ee=be(Y),De=pe.slice();Oe(Ke,ye[0],ye[1],0),Nn(Ke,Ke,B),kn(jo,Ke),Md(Vo,-ee,jo),vs(Ke,Ke,Vo),Ke[2]*=p,ii(De,De,Ke),Z.push(De);const ue=me.slice();Oe(Ke,se[0],se[1],0),Nn(Ke,Ke,B),kn(jo,Ke),Md(Vo,-ee,jo),vs(Ke,Ke,Vo),Ke[2]*=p,ii(ue,ue,Ke),q.push(ue)}const W=Ae(Z,q);if(K.generate(e,f,n,ne.side,i,le(W),r,o,a,void 0,"fill"),N===1&&V[0][2]===0){ce(e,P,Z);const Y=V[0].slice(),ee=V[0].slice(),De=S[0].slice(),ue=S[0].slice();_t(De,De,$),_t(ue,ue,-$),jt(Y,Y,De),jt(ee,ee,ue);const fe=Y.slice(),qt=ee.slice();fe[2]+=$*p,qt[2]+=$*p;const tt=[Y];for(let mt=0;mt<5;mt++)tt.push(fe);for(let mt=0;mt<5;mt++)tt.push(qt);tt.push(ee),ce(e,P,tt),K.generate(e,f,n,ne.side,i,le(Ae(tt,Z)),r,o,a,void 0,"fill")}else if(N===V.length-1&&V[V.length-1][2]===0){ce(e,P,q);const Y=V[V.length-1].slice(),ee=V[V.length-1].slice(),De=S[V.length-1].slice(),ue=S[V.length-1].slice();_t(De,De,$),_t(ue,ue,-$),jt(Y,Y,De),jt(ee,ee,ue);const fe=Y.slice(),qt=ee.slice();fe[2]+=$*p,qt[2]+=$*p;const tt=[Y];for(let mt=0;mt<5;mt++)tt.push(fe);for(let mt=0;mt<5;mt++)tt.push(qt);tt.push(ee),ce(e,P,tt),K.generate(e,f,n,ne.side,i,le(Ae(q,tt)),r,o,a,void 0,"fill")}}if(V[0][2]===0||V[V.length-1][2]===0){const N=Bt(V,S,$),Z=Bt(V,S,-$),q=N.map(W=>{const Y=W.slice();return Y[2]=Math.max(0,Y[2]+$*p),Y}),pe=Z.map(W=>{const Y=W.slice();return Y[2]=Math.max(0,Y[2]+$*p),Y});N.forEach(W=>{W[2]=Math.max(0,W[2])}),Z.forEach(W=>{W[2]=Math.max(0,W[2])});const me=Ae(N,q),ye=Ae(pe,Z);ce(e,P,N),ce(e,P,Z),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=Ae(q,pe);K.generate(e,f,n,ne.top,i,le(se),r,o,a,void 0,"fill")}}};function QI(e){let t=0;for(let n=0;n<e.length-1;n++)t+=ms(e[n],e[n+1]);return t}var Ll=(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))(Ll||{});function h0(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 eM={symbol:"simpleMesh",sinks:{fill:{stride:24,binder:()=>{},packObjectAttributes(e,t,n){return Fe([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}}},tM=32,ar={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",ar.sinks.fill.packObjectAttributes(t.id,n,s),ar.sinks.fill.binder);sM(r,tM,i.coords)}}}},nM=nt.fromGeo([0,90]),iM=nt.fromGeo([0,-90]);function sM(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*ar.sinks.fill.stride/Uint16Array.BYTES_PER_ELEMENT;let l=0,u=e.indices.offset;for(let d=0;d<t;d++)for(let f=0;f<t;f++){let h;const g=[d*32768/(t-1),f*32768/(t-1)];o&&f===t-1?h=nM:a&&f===0?h=iM:h=gc(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++]=d/(t-1)*(re(2,16)-1),s[c+l++]=f/(t-1)*(re(2,16)-1)}for(let d=0;d<t-1;d++)for(let f=0;f<t-1;f++){const h=d*t+f,g=h+1,w=h+t,p=w+1;r[u++]=h,r[u++]=w,r[u++]=g,r[u++]=g,r[u++]=w,r[u++]=p}e.indices.offset=u,e.elements.offset=c+l/8}const Dl={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]]);const l=j(n.style.color,i),u=l&&l.isVertexColor?eo(l):void 0;K.generate(e,t,n,ne.top,i,s,r,o,a,c,"fill",void 0,u)}};var p0=(e=>(e[e.none=0]="none",e[e.fadeIn=1]="fadeIn",e[e.fadeOut=-1]="fadeOut",e))(p0||{});function m0({collector:e,generator:t,args:n}){do t(e,...n);while(e.isOverloaded())}const y0={arrow:Zs,line:ut,polygon:Zt,embankment:Dl,polygon3d:Dl,metricPoint:zo,labelLine:Lo,lineExtrusion:In,polygonExtrusion:$n,oneWayLine:Do,dashedLine:vn,shiftedLine:ao,circle:ho,buildingModel:bn,gltfModel:Xn,point:sn,raster:mo,heatmap:Mi,dem:Rt,mesh:K,mapMesh:ts,overpass:a0,tunnel:f0,simpleMesh:eM,globe:ar},g0={labelLine:Lo,oneWayLine:Do,point:sn};function cr(e,t){const n=y0[e];return n?n.sinks[t].stride:0}function Ol(e,t){e.precomputes.forEach((n,i)=>{t.tileData[i]=j(n.expr,t)})}function Cl(e,t,n,i,s,r,o,a,c,l,u,d,f,h){const g=i.styleState.graphicsPreset?t.graphicsPresets[i.styleState.graphicsPreset]||{}:{};n.forEach(w=>{if(_f(i,[u.x[0],u.y[0]]),!(o!==void 0&&(w.maxzoom<=o||w.minzoom>=o+1&&o!==ei.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")){Ol(w,i);do switch(w.type){case"line":const p=j(w.style.pattern,i);p&&p[0]!==Ll.None?ut.generatePatterned(e,t.id,w,i,c,u):ut.generate(e,t.id,w,i,c,u);break;case"dashedLine":vn.generate(e,t.id,w,i,c,u);break;case"shiftedLine":ao.generate(e,t.id,w,i,u);break;case"polygon":Zt.generate(e,t.id,w,i,u,l,t.rasterSets);break;case"polygon3d":case"embankment":Dl.generate(e,t.id,w,i,u,c,l,t.rasterSets);break;case"metricPoint":{zo.generate(e,u,l,t,w,i,c);break}case"polygonExtrusion":$n.generate(e,t.id,w,i,u,g);break;case"labelLine":lI(e,t.id,w,c.coords,a,i,u);break;case"oneWayLine":uI(e,t.id,w,c.coords,a,i,u);break;case"point":{$h(e,t,w,i,s,r,c.coords,a,u,l,d);break}case"lineExtrusion":In.generate(e,t.id,w,i,u,g);break;case"arrow":Zs.generate(e,t.id,w,i,u);break;case"heatmap":{Mi.generate(e,t.id,w,u,i);break}case"gltfModel":{Xn.generateInstances(e,t,w,i,u,c,a,f,h,s,2);break}case"overpass":a0.generate(e,t,w,i,u,c,l,t.rasterSets);break;case"tunnel":f0.generate(e,t,w,i,u,c,l,t.rasterSets);break}while(e.isOverloaded())}})}function rM(e,t,n,i,s,r,o,a){const c=g0[t.type];if(c)do c.processElement(e,n,i,s,r,o,a);while(n.isOverloaded())}function oM(e,t,n,i,s,r,o){const a=g0[i.type];a&&a.getLabelingInfo(e,t,n,s,r,o)}class w0{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 aM(e,t){const n=new Set;return e.forEach(i=>{t.has(i)||n.add(i)}),n}function cM(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 lM(e,t){const n=new Set;for(const i of t)e.has(i)&&n.add(i);return n}function uM(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)||!cM(i,t.get(n)))return!1;return!0}const Fl="default",dM="floor",fM="dynamicModel";var ns=(e=>(e[e.PolygonExtrusion=1]="PolygonExtrusion",e[e.FloorPolygons=2]="FloorPolygons",e[e.All=3]="All",e))(ns||{});class hM{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 uM(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 Rl{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 pM(e){const t=mM(e),{groups:n,table:i}=yM(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 u=n[l];s[c][u]=i[o][l]}}const r=n.reduce((o,a,c)=>(o[a]=c,o),{});return{indexToGroup:n,groupToIndex:r,table:s}}function mM(e){const t=(e.groups||[]).concat(xc.groups).reduce((i,s)=>(i.includes(s)||i.push(s),i),[]),n=(e.overlay||[]).concat(xc.overlay).concat(t.reduce((i,s)=>(s===Vn||s===jn||s===Ac||i.push([s,jn]),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:xc.intersect}}function yM(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 u=s[a[c]],d=s[a[l]];r[u][d]=!1,r[d][u]=!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 u=s[a[c]],d=s[a[l]];r[u][d]=!0,r[d][u]=!0}}return{groups:t,table:r}}const gM={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"},wM=e=>{var t;return(t=gM[e])!=null?t:e},vM={objectClass:"db_object_class",sublayer:"db_sublayer",db_id:"id"};function bM(e){var t;return(t=vM[e])!=null?t:e}const IM={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"},MM=e=>{var t;e.enumerationValues=Object.keys((t=e.enumerationValues)!=null?t:{}).reduce((n,i)=>{const s=IM[i];return s&&(n[s]=e.enumerationValues[i]),n},{})};class TM{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=Dn((s=i.sourceAttributes)!=null?s:{},Vd),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:u,err:d}=l;return u.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)}),(d==null?void 0:d.status)===403&&s.emit("error",{type:"invalidtilekey"}),u}))}generateTile(u,d,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(de({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=L(t,{precomputes:[]},Qe.Generator):this.dataFilter=void 0}constructTileUrl(t,n){return Rg(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:Ud(t.metatileHash)};return Ss(n?{url:n}:"metatile",i)}}const v0=[{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:Ac,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 SM(e){const t={};let n=0;for(const i in e)t[i]=n,n+=1;return t}let EM=Number.MIN_SAFE_INTEGER;function b0(){return EM++}const AM=b0(),xM=b0(),I0={NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519},_M={FRONT:1028,BACK:1029,FRONT_AND_BACK:1032},PM={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},LM={FUNC_ADD:32774,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,MIN:32775,MAX:32776},M0="__JAKARTA__DEM__LIGHTING__";class Nl extends Error{constructor(t){super(`Unknown expression type '${t[0]}' in '${JSON.stringify(t)}'`),this.name="UnknownExpressionTypeError",Object.setPrototypeOf(this,new.target.prototype)}}function L(e,t,n=Qe.Uniform){if(sw(e))return If(e)?Fs(e):e;switch(e[0]){case"coalesce":return $M(e,t,n);case"all":return HM(e,t,n);case"any":return YM(e,t,n);case"match":return DM(e,t,n);case"in":return kM(e,t,n);case"interpolate":return T0(e,t,n);case"step":return VM(e,t,n);case"featureState":case"get":case"sourceAttr":case"has":return S0(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:L(e[1]||0,t,n)};case"utc-time":return{type:"utc-time",offset:L(e[1]||0,t,n)};case"time":return ZM(e,t,n);case"schedule":return XM(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 OM(e,t,n);case"uint64":return L(e[1],t,n);case"==":case"!=":case"<":case"<=":case">":case">=":return CM(e,t,n);case"+":return FM(e,t,n);case"*":return RM(e,t,n);case"^":return NM(e,t,n);case"random":return qM(e,t,n);case"literal":return Array.isArray(e[1])?JM(e,t,n):typeof e[1]=="object"&&e[1]!==null?KM(e):e[1];case"isBehindObjects":return{type:"isBehindObjects"};case"geometry-modifier":const i=[];return e.slice(1).forEach(s=>{const r=QM(s);r&&i.push(r)}),{type:"geometry-modifier",modifiers:i};case"pattern":return{type:"line-pattern",patternType:h0(e[1]),parameters:e.slice(2).map(s=>L(s,t,n))};case"precompute":{if(!t)throw new Nl(e);const s=t.precomputes.length;return t.precomputes.push({expr:L(e[1],void 0,n),usage:n}),{type:"precompute",precomputeIndex:s}}case"color-saturate":case"color-desaturate":case"color-grayscale":case"color-lighten":case"color-lightness":case"color-darken":case"color-whiten":case"color-blacken":case"color-opacity":return BM(e,t,n);case"gltf-animation":return UM(e,t,n);case"texture-animation":return zM(e,t,n);case"easing":return GM(e);case"mix":return jM(e,t,n);case"readFromTarget":return{type:"readFromTarget",name:e[1]};case"vertexAttribute":return{type:"vertexAttribute",name:e[1]};case"vertexColor":return WM(e,t,Qe.Generator);default:throw new Nl(e)}}function Jn(e,t,n=Qe.Uniform){return dn(e)||Array.isArray(e)&&e.length===0?e:L(e,t,n)}function Ai(e,t,n){return e===void 0?e:L(e,t,n)}function DM(e,t,n){const i={type:"match",input:L(e[1],t,n),cases:[],defaultOutput:L(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 u=L(l,t,n);return wf(u)?c.push(u):console.warn("MatchExpression supports only simple types: string, number, boolean or null",l),c},[]),a={values:new Set(o),output:L(s[r+1],t,n)};i.cases.push(a)}return i}function T0(e,t,n){const i={type:"interpolate",base:1,argument:L(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:L(s[r],t,n),value:L(s[r+1],t,n)};i.steps.push(o)}return i}function OM(e,t,n){return{type:e[0],value:L(e[1],t,n)}}function CM(e,t,n){const i=L(e[1],t,n),s=L(e[2],t,n);return{type:e[0],leftValue:i,rightValue:s}}function FM(e,t,n){return{type:"+",array:e.slice(1).map(i=>L(i,t,n))}}function RM(e,t,n){return{type:"*",array:e.slice(1).map(i=>L(i,t,n))}}function NM(e,t,n){const i=L(e[1],t,n),s=L(e[2],t,n);return{type:"^",base:i,exponent:s}}function kM(e,t,n){const i=L(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=L(e[2],t,n);return{type:"in",item:i,collection:r}}function BM(e,t,n){return{type:e[0],color:L(e[1],t,n),value:L(e[2],t,n)}}function UM(e,t,n){const i={type:"gltf-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(L(s[r],t,n));return i}function zM(e,t,n){const i={type:"texture-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(L(s[r],t,n));return i}function GM(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 jM(e,t,n){const i=e.slice(1),s=L(i[2],t,n);if(s.type==="interpolate"){const{argument:r}=s;return s.argument.type==="readFromTarget"?{type:"mix",value1:L(i[0],t,n),value2:L(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:L(i[0],t,n),value2:L(i[1],t,n),factor:s}}function VM(e,t,n){const i={type:"step",steps:[],value:L(e[1],t,n)},s={key:0,value:L(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:L(r[o+1],t,n)};i.steps.push(a)}return i}function S0(e,t,n){var o;const i=e[0],s=bM(e[1]),r={type:i,property:s};if(n!==Qe.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 HM(e,t,n){return{type:"all",array:e.slice(1).map(i=>L(i,t,n))}}function $M(e,t,n){return{type:"coalesce",array:e.slice(1).map(i=>{try{return L(i,t,n)}catch(s){return console.debug(`Unknown expression in coalesce: ${s}`),null}})}}function YM(e,t,n){return{type:"any",array:e.slice(1).map(i=>L(i,t,n))}}function WM(e,t,n){return{type:"vertexColor",vertexValue:L(e[1],t,n),uniformValue:L(e[2],t,n),mixValue:L(e[3]||1,t,n)}}function ZM(e,t,n){return{type:"time",timeSource:L(e[1],t,n),format:e[2]}}function XM(e,t,n){return{type:"schedule",time:L(e[1],t,n),steps:L(e[2],t,n),detailResult:e[3]}}function qM(e,t,n){const i=L(e[1],t,n),s=L(e[2],t,n);return{type:"random",start:i,end:s}}function JM(e,t,n){return{type:"literalArray",array:e[1].map(i=>L(i,t,n))}}function KM(e){return{type:"literalObject",object:{type:"object",value:e[1]}}}function QM(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 eT(e){return e?e.map(t=>{var o,a,c,l,u,d,f,h,g,w,p,y,b,v,M,E,A,D,_,O,U,B,$,V,T,I,S;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:(u=(l=t.vertical)==null?void 0:l.mode)!=null?u:"stripe-top",slicesCount:(f=(d=t.vertical)==null?void 0:d.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:(M=(v=t.vertical)==null?void 0:v.maxInterval)!=null?M:0},horizontal:{mode:(A=(E=t.horizontal)==null?void 0:E.mode)!=null?A:"repeat-with-stretch",slicesCount:(_=(D=t.horizontal)==null?void 0:D.slicesCount)!=null?_:1,minSliceRepeats:(U=(O=t.horizontal)==null?void 0:O.minSliceRepeats)!=null?U:1,minResizeFactor:($=(B=t.horizontal)==null?void 0:B.minResizeFactor)!=null?$:0,maxResizeFactor:(T=(V=t.horizontal)==null?void 0:V.maxResizeFactor)!=null?T:9999,maxInterval:(S=(I=t.horizontal)==null?void 0:I.maxInterval)!=null?S:0}};return r.sliceSize[0]<=0||r.sliceSize[1]<=0?null:r}).filter(t=>t!==null):[]}function tT(e,t){let n=0;function i(s,r){s.type!=="custom"&&V2(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 nT(e,t,n){var u,d,f,h,g,w,p,y;const i=Bl((u=e.terrain)!=null?u:{}),s=P0((d=e.environment)!=null?d:{}),r=L0(e.light,i),o=rT(e.graphicsPresets),a={id:t,revision:0,background:{color:Fs((h=(f=e.background)==null?void 0:f.color)!=null?h:ev)},light:r,layers:[],layersById:{[zs]:i,[jc]:s},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",fonts:yr,fontNameToIndex:yh(yr),rasterSets:{byIndex:{},byKey:{}},icons:e.icons||{},models:Object.values((g=e.models)!=null?g:{}),modelIndex:SM(e.models||{}),labelingGroups:pM((w=e.labelingGroups)!=null?w:{}),dem:i,graphicsPresets:o,environment:s,targets:{_TMP_SHORELINE_GRADIENT:{channels:{r:!0},title:"Градиент береговой линии"}}},c=new Rl;let l=(p=e.layers)!=null?p:[];n&&(l=tT((y=e.layers)!=null?y:[],v0));for(const b of l){const v=E0(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 _;const A=(_=E.lightingMode)!=null?_:r.defaultLightMode;r.lightingModes[A]||console.warn(`Не найден режим освещения ${A} для слоя ${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")&&A0(E,c,a.icons).forEach(U=>{a.rasterSets.byKey[U.key]||(a.rasterSets.byIndex[U.index]=U,a.rasterSets.byKey[U.key]=U)})})}return a}function E0(e){return e.type==="group"?sT(e):Ho(e)}function A0(e,t,n){const i=[];return _0(e).forEach(({image:s,imageType:r,anchor:o})=>{s&&mi(s).forEach(a=>{typeof a!="string"||!a.length||i.push(x0(a,r,t,o,n))})}),i}function x0(e,t,n,i,s){const r=t==="icon"?Hi(e,i[0],i[1]):Xr(e);return{type:Ii.Static,index:n.getUniqueIndex(r),key:r,isSvg:H2(s[e]),name:e,fileName:e,anchorX:i[0],anchorY:i[1],rasters:[]}}function _0(e){if(e.type==="point"){const n=st(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 kl=new Rl;function iT(e,t){return e.type==="appearance"?{type:e.type,tipMovementAmplitude:L(e.tipMovementAmplitude,t)}:e.type==="repeat"?{type:e.type,tipMovementAmplitude:L(e.tipMovementAmplitude,t),iterationCount:e.iterationCount}:e}function Ho(e,t){var i,s,r,o,a,c,l,u,d,f,h,g,w,p,y,b,v,M,E,A,D,_,O,U,B,$,V;if(e.type==="custom")return{type:"custom",id:e.id,innerId:Us(),renderIndex:kl.getIndex(),filter:!1,minzoom:-1/0,maxzoom:1/0,precomputes:[],style:{}};if(!e.style||e.style.visibility==="none")return;let n;try{const T={id:e.id,innerId:Us(),renderIndex:kl.getIndex(),filter:L(e.filter||!1,void 0),minzoom:D0(e.minzoom,-1/0),maxzoom:D0(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=Rw(e.style);n=ve(de({},T),{type:e.type,interactive:(r=e.interactive)!=null?r:!0,ignoreTier:L((o=e.ignoreTier)!=null?o:!1,T),style:{visibility:We(I.visibility),color:L(I.color,T),width:L(I.width,T),shift:L(I.shift,T),pattern:L(I.pattern,T),startCap:L(I.startCap,T),endCap:L(I.endCap,T),geometryModifier:L(I.geometryModifier,T),mode:I.mode,lengthUnits:oT(e.style.pattern)}});break}case"lineExtrusion":{const I=kw(e.style);n=ve(de({},T),{type:e.type,style:{visibility:We(I.visibility),sideColor:L(I.sideColor,T),strokeWidth:L(I.strokeWidth,T),strokeColor:L(I.strokeColor,T),sideStrokeColor:L(I.sideStrokeColor,T),height:L(I.height,T),nearCameraFade:L(I.nearCameraFade,T)}});break}case"polygon":{const I=Dw(e.style),S=lr(I.textureSize)?C0(I.textureSize):I.textureSize,P=lr(I.normalMapTextureSize)?C0(I.normalMapTextureSize):I.normalMapTextureSize;T.drawToTarget==="_TMP_SHORELINE_GRADIENT"&&(I.strokeWidth=0,I.strokeColor="#00000000",I.color=["mix","#000000","#FF0000",["vertexAttribute","denormalized_distance_to_line"]]),n=ve(de({},T),{type:e.type,interactive:(a=e.interactive)!=null?a:!0,ignoreTier:L((c=e.ignoreTier)!=null?c:!1,T),style:{visibility:We(I.visibility),color:L(I.color,T),textureImage:L(I.textureImage,T),textureSize:Jn(S,T),textureOpacity:L(I.textureOpacity,T),strokeColor:L(I.strokeColor,T),strokeWidth:L(I.strokeWidth,T),lengthUnits:O0(I.textureSize),metallic:L(I.metallic,T),roughness:L(I.roughness,T),normalMapTextureImage:L(I.normalMapTextureImage,T),normalMapTextureSize:Jn(P,T),normalMapTextureAnimation:L(I.normalMapTextureAnimation,T),normalMapTextureLengthUnits:O0(I.normalMapTextureSize)}});break}case"polygon3d":case"embankment":{const I=Ow(e.style),S=e.type==="polygon3d"?{depthFunc:I0.LEQUAL}:{};n=ve(de({},T),{type:e.type,interactive:(l=e.interactive)!=null?l:!0,style:{visibility:We(I.visibility),color:L(I.color,T),textureImage:L(I.textureImage,T),textureSize:Jn(I.textureSize,T),textureOpacity:L(I.textureOpacity,T),strokeColor:L(I.strokeColor,T),strokeWidth:L(I.strokeWidth,T),nearCameraFade:L(I.nearCameraFade,T),elevation:L(I.elevation,T)},gpuState:de(de({},S),T.gpuState)}),e.type==="polygon3d"&&(n.interactiveOcclusion=(u=e.interactiveOcclusion)!=null?u:!0);break}case"metricPoint":{const I=Cw(e.style);n=ve(de({},T),{type:e.type,interactive:(d=e.interactive)!=null?d:!0,ignoreTier:L((f=e.ignoreTier)!=null?f:!1,T),style:{visibility:We(I.visibility),iconImage:L(I.iconImage,T),color:L(I.color,T),rotation:L(I.rotation,T),width:L(I.width,T),height:L(I.height,T)}});break}case"polygonExtrusion":{const I=Fw(e.style);n=ve(de({},T),{type:e.type,interactive:(h=e.interactive)!=null?h:!0,sideTextureIndices:[],style:{visibility:We(I.visibility),topColor:L(I.topColor,T),sideColor:L(I.sideColor,T),strokeColor:L(I.strokeColor,T),strokeWidth:L(I.strokeWidth,T),sideStrokeColor:L(I.sideStrokeColor,T),height:L(I.height,T,Qe.Generator),nearCameraFade:L(I.nearCameraFade,T),sideTextures:eT(I.sideTextures)}});break}case"dashedLine":{const I=zw(e.style);n=ve(de({},T),{type:e.type,interactive:(g=e.interactive)!=null?g:!0,ignoreTier:L((w=e.ignoreTier)!=null?w:!1,T),style:{visibility:We(I.visibility),color:L(I.color,T),gapColor:L(I.gapColor,T),width:L(I.width,T),shift:L(I.shift,T),gapLength:L(I.gapLength,T),dashLength:L(I.dashLength,T),gapTurnsOnly:I.gapTurnsOnly,geometryModifier:L(I.geometryModifier,T),mode:I.mode}});break}case"shiftedLine":{const I=Gw(e.style);n=ve(de({},T),{type:e.type,interactive:(p=e.interactive)!=null?p:!0,ignoreTier:L((y=e.ignoreTier)!=null?y:!1,T),style:{visibility:We(I.visibility),color:L(I.color,T),width:L(I.width,T),shift:L(I.shift,T)}});break}case"oneWayLine":{const I=Uw(e.style);n=ve(de({},T),{type:e.type,ignoreTier:L((b=e.ignoreTier)!=null?b:!1,T),interactive:(v=e.interactive)!=null?v:!1,style:{visibility:We(I.visibility),color:L(I.color,T),lineWidth:L(I.lineWidth,T),lineLength:L(I.lineLength,T),tipWidth:I.tipWidth,tipHeight:I.tipHeight,roundingRadius:L(I.roundingRadius,T),priority:I.priority,duplicationSpacing:L(I.duplicationSpacing,T),endingOffsets:I.endingOffsets,labelingGroup:I.labelingGroup}});break}case"buildingModel":{const I=Nw(e.style);n=ve(de({},T),{type:e.type,interactive:(M=e.interactive)!=null?M:!0,style:{visibility:We(I.visibility),color:L(I.color,T),strokeColor:L(I.strokeColor,T),strokeWidth:L(I.strokeWidth,T),nearCameraFade:L(I.nearCameraFade,T)}});break}case"labelLine":{const I=Bw(e.style);n=ve(de({},T),{type:e.type,interactive:(E=e.interactive)!=null?E:!1,ignoreTier:L((A=e.ignoreTier)!=null?A:!1,T),style:{visibility:We(I.visibility),textField:L(I.textField,T,Qe.Labeling),textFont:I.textFont,textColor:L(I.textColor,T),textFontSize:L(I.textFontSize,T),textLetterSpacing:I.textLetterSpacing,textHaloColor:L(I.textHaloColor,T),textHaloWidth:I.textHaloWidth,textPriority:L(I.textPriority,T),textLabelingSideMargin:I.textLabelingSideMargin,textDuplicationSpacing:L(I.textDuplicationSpacing,T),labelingGroup:I.labelingGroup,lineEndingOffsets:I.lineEndingOffsets}});break}case"point":{const I=Vw(e.style);n=ve(de({},T),{type:e.type,interactive:(D=e.interactive)!=null?D:!0,style:{visibility:We(I.visibility),allowOverlap:I.allowOverlap,allowElevation:I.allowElevation,elevation:L(I.elevation,T),iconImage:L(I.iconImage,T),iconAnchor:Jn(I.iconAnchor,T),iconOffset:Jn(I.iconOffset,T),iconWidth:L(I.iconWidth,T),iconTextField:L(I.iconTextField,T,Qe.Labeling),iconTextFont:Ai(I.iconTextFont,T),iconTextAnchor:Jn(I.iconTextAnchor,T),iconTextOffset:Jn(I.iconTextOffset,T),iconTextColor:L(I.iconTextColor,T),iconTextFontSize:L(I.iconTextFontSize,T),iconTextLineHeight:I.iconTextLineHeight,iconTextLetterSpacing:I.iconTextLetterSpacing,iconTextPadding:Jn(I.iconTextPadding,T),iconTextHaloWidth:Cs(qe(I.iconTextHaloWidth)),iconTextHaloColor:L(I.iconTextHaloColor,T),iconOpacity:L(I.iconOpacity,T),iconPriority:L(I.iconPriority,T),iconLabelingMargin:I.iconLabelingMargin,iconLabelingGroup:I.iconLabelingGroup,iconRotation:L(I.iconRotation,T),textField:L(qe(I.textField),T,Qe.Labeling),textFont:L(qe(I.textFont),T),textColor:L(qe(I.textColor),T),textFontSize:L(qe(I.textFontSize),T),textLineHeight:Cs(qe(I.textLineHeight),1.2),textLetterSpacing:Cs(qe(I.textLetterSpacing)),textField2:Ai(fn(I.textField),T,Qe.Labeling),textFont2:Ai(fn(I.textFont),T),textColor2:Ai(fn(I.textColor),T)||L(qe(I.textColor),T),textFontSize2:Ai(fn(I.textFontSize),T)||L(qe(I.textFontSize),T),textMaxLengthPerLine:I.textMaxLengthPerLine,textPlacement:L(I.textPlacement,T),textPriority:L(I.textPriority,T),textOffset:L(qe(I.textOffset),T),textOffset2:Ai(fn(I.textOffset),T),textHaloColor:L(qe(I.textHaloColor),T),textHaloColor2:Ai(fn(I.textHaloColor),T)||L(qe(I.textHaloColor),T),textHaloWidth:Cs(qe(I.textHaloWidth)),textHaloWidth2:Cs(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:L(I.duplicationSpacing,T),endingOffsets:I.endingOffsets}});break}case"arrow":{const I=Hw(e.style);n=ve(de({},T),{type:e.type,interactive:(_=e.interactive)!=null?_:!1,ignoreTier:L((O=e.ignoreTier)!=null?O:!1,T),style:{visibility:We(I.visibility),color:L(I.color,T),strokeColor:L(I.strokeColor,T),lineWidth:L(I.lineWidth,T),strokeWidth:L(I.strokeWidth,T),tipWidth:L(I.tipWidth,T),tipHeight:L(I.tipHeight,T),roundingRadius:L(I.roundingRadius,T),animation:iT(I.animation,T)}});break}case"raster":{const I=$w(e.style);n=ve(de({},T),{type:e.type,ignoreTier:L((U=e.ignoreTier)!=null?U:!1,T),style:{visibility:We(I.visibility),opacity:L(I.opacity,T)}});break}case"circle":{const I=jw(e.style);n=ve(de({},T),{type:e.type,interactive:(B=e.interactive)!=null?B:!0,style:{visibility:We(I.visibility),color:L(I.color,T),strokeColor:L(I.strokeColor,T),strokeColor2:L(I.strokeColor2,T),width:L(I.width,T),strokeWidth:L(I.strokeWidth,T),strokeWidth2:L(I.strokeWidth2,T)}});break}case"heatmap":{const I=Yw(e.style);n=ve(de({},T),{type:e.type,style:{visibility:We(I.visibility),color:L(I.color,T),radius:L(I.radius,T),opacity:L(I.opacity,T),intensity:L(I.intensity,T),weight:L(I.weight,T),downscale:I.downscale},framebufferId:{framebuffer:Kr}});break}case"model":{const I=Zw(e.style);n=ve(de({},T),{interactive:($=e.interactive)!=null?$:!0,interactiveOcclusion:(V=e.interactiveOcclusion)!=null?V:!0,type:"gltfModel",style:{visibility:We(I.visibility),modelSrc:L(I.modelSrc,T),offset:L(I.offset,T,Qe.Generator),scale:L(I.scale,T,Qe.Generator),rotation:L(I.rotation,T,Qe.Generator),scene:L(I.scene,T),color:L(I.color,T),linkedIds:L(I.linkedIds,T),colorTextureUvIndex:I.colorTextureUvIndex,roughness:I.roughness,metallic:I.metallic,preventObjectsHiding:I.preventObjectsHiding,nearCameraFade:L(I.nearCameraFade,T),ignoreGlobalLighting:I.ignoreGlobalLighting,showRatio:L(I.showRatio,T),lightingModel:I.lightingModel,playAnimation:L(I.playAnimation,T),geometryModifier:L(I.geometryModifier,T)}});break}case"overpass":{const I=Xw(e.style);n=ve(de({},T),{type:e.type,style:{visibility:We(I.visibility),debug:I.debug,sideColor:L(I.sideColor,T),bottomColor:L(I.bottomColor,T),topColor:L(I.borderTopColor,T),strokeColor:L(I.strokeColor,T),strokeWidth:L(I.strokeWidth,T),thickness:L(I.thickness,T),borderHeight:L(I.borderHeight,T),borderWidth:L(I.borderWidth,T),color:L(I.color,T),nearCameraFade:L(I.nearCameraFade,T),tunnelHeight:L(I.tunnelHeight,T)}});break}case"tunnel":{const I=qw(e.style);n=ve(de({},T),{type:e.type,style:{visibility:We(I.visibility),sideColor:L(I.sideColor,T),bottomColor:L(I.bottomColor,T),topColor:L(I.topColor,T),strokeColor:L(I.strokeColor,T),strokeWidth:L(I.strokeWidth,T),color:L(I.color,T),nearCameraFade:L(I.nearCameraFade,T)}});break}}}catch(T){if(T instanceof Nl){console.warn(`Problem with layer #${e.id}: ${T}`);return}throw T}return n}function sT(e){var n,i;const t={id:e.id,innerId:Us(),renderIndex:kl.getIndex(),type:e.type,layers:[],orderBy:[],precomputes:[]};return t.orderBy=(i=(n=e.orderBy)==null?void 0:n.map(s=>S0(s,t,Qe.Uniform)))!=null?i:[],e.layers.forEach((s,r)=>{const o=Ho(s,t);o&&(o.groupId=t.innerId,o.groupIndex=r,o.renderIndex=t.renderIndex,t.layers.push(o))}),t}function Bl(e){const t=Ww(e),n={id:"dem",type:"dem",innerId:zs,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:AM,style:{},framebufferId:{hillshade:Kr,flatBottom:Kr},lightingMode:M0};return n.style={visibility:"visible",lightingDirection:typeof t.lightingDirection!="undefined"?L(t.lightingDirection,n):null,shadingIntensity:L(t.shadingIntensity,n),shadingPalette:T0(t.shadingPalette,n),verticalScale:L(t.verticalScale,n)},n}function P0(e){const t=Jw(e),n={id:"sky",type:"custom",innerId:jc,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:xM,style:{}};return n.style={visibility:"visible",skyColor:L(t.skyColor,n),fogColor:L(t.fogColor,n),starsIntensity:L(t.starsIntensity,n)},n}function L0(e,t){var r,o;const n=Kw(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),u=n.shadows?n.sources[n.shadows.source]:void 0;let d=0;l.forEach(f=>{f.color||(f.color="#FFFFFF"),f.type==="ambient"?(c.ambientColor=L(f.color,void 0),c.ambientIntensity=L(f.intensity,void 0),a===n.defaultLightingMode&&(s.ambientColor=c.ambientColor,s.ambientIntensity=c.ambientIntensity)):f.type==="directional"&&(f===u&&(c.shadowLightIndex=d),d===0?(d++,c.dir1Color=L(f.color,void 0),c.dir1Altitude=L(f.altitude,void 0),c.dir1Azimuth=L(f.azimuth,void 0),c.dir1Intensity=L(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=L(f.intensity,void 0),s.dir1Altitude=c.dir1Altitude)):d===1&&(d++,c.dir2Color=L(f.color,void 0),c.dir2Altitude=L(f.altitude,void 0),c.dir2Azimuth=L(f.azimuth,void 0),c.dir2Intensity=L(f.intensity,void 0)))}),i[a]=c}return i[M0]=s,{defaultLightMode:n.defaultLightingMode,lightingModes:i}}function rT(e){return Qw(e)}function D0(e,t){return typeof e=="number"&&!Number.isNaN(e)?e:t}function oT(e){return e&&lr(e[2])?Gn.Meters:Gn.Pixels}function O0(e){return lr(e)?Gn.Meters:Gn.Pixels}function lr(e,t=!1){return Array.isArray(e)&&(e[0]==="meters-to-pixels"||e[0]==="literal"&&!t&&Array.isArray(e[1])&&e[1].some(n=>lr(n,!0)))}function C0(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 $o=0,aT=1,cT={type:Ii.Loaded,index:-1,key:Hi("",.5,.5),isSvg:!1,name:"",fileName:"",rasters:[]},lT=["default","marker","markerText","htmlLabel"],uT={default:0,marker:1,markerText:2,htmlLabel:3,pointLabel:4},dT={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 F0(e){const t=[],n=Object.keys(ci).length;for(let i=0;i<n;i++)t[i]=NaN;for(const i in e){if(ci[i]===void 0)throw new Error(`No such tile prop '${i}'`);t[ci[i]]=e[i]}return t}class fT{constructor(){this.needRenderIndexRebuild=!1,this.style={id:$o,revision:0,background:{color:Fs("#f6f2de")},light:{defaultLightMode:"global",lightingModes:{}},layers:[],layersById:{},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",rasterSets:{byIndex:{},byKey:{}},labelingGroups:{indexToGroup:lT,groupToIndex:uT,table:dT},fonts:yr,fontNameToIndex:yh(yr),icons:{},models:[],modelIndex:{},dem:Bl({}),environment:P0({}),graphicsPresets:{light:{},normal:{},immersive:{}},targets:{}},this.zIndexById={};const t=Ho({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]=cT}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 hT(e,t,n){const i="identify-scene",s=document.getElementById(i),r=parseInt(Pa.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 u=c.getContext("2d");u.clearRect(0,0,o,a);const d=u.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;d.data[w]=g===3?r:e[p]}u.putImageData(d,0,0),s&&s.parentNode?s.parentNode.replaceChild(c,s):document.body.appendChild(c)}function R0(e,t,n){const s=te,r={x:new Uint16Array([0,s,s,0,0]),y:new Uint16Array([0,0,s,s,0])},o=F0({}),a=ks(n,oc,ci,o,jd);m0({collector:e,generator:ut.generate,args:[$o,t,a,ct([0,0,0,0]),r]})}function N0(){try{return!!localStorage.getItem("debugStatusCompile")}catch(e){return console.warn("Error accessing localStorage in forceGlStatusCheck:",e),!1}}const Ul={defines:[],hash:""},Pi=class Pi{constructor(t,n,i=Ul,s=Ul){this.shader=null,this.type=t==="vertex"?Pi.Vertex:Pi.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===Pi.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),N0()&&!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,u){const d=o[Number(l)-1];return d?`ERROR ${c}:${l}: ${u}
Erroneous line: <<${d}>>
`: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(`
`)}};Pi.Vertex=1,Pi.Fragment=2;let Yo=Pi;function k0(e,t,n,i){for(const s of t)yT(e,n,s,i)}function pT(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 mT(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(u=>{const d=e.getShaderProgram(u.programName),f=u.vaoCreator(r,d,l);if(u.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 w0(a,{itemSize:1,dataType:Ze.UnsignedByte})}f.setAttribute("a_float_visibility",c)}o.push(f)}),{buffer:r,visibilityBuffer:a,vaos:o}}function yT(e,t,n,i){const{renderer:s,instanceLinker:r,map:o}=e,{symbol:a,sink:c,generatedObjects:l,buffer:u,elementsBuffer:d,elementSize:f}=n;if(s.symbolSettingsList[a]===void 0)return;const g=B0(s,a,c);if(g.length===0)return;const w=cr(a,c);if(g[0].instanceBinder){const E=pT(s,n,w);t.buffers.push(...E),r.enqueue(n,t);return}let p=0;d&&f?p=d.byteLength/f:p=u.byteLength/w;const{buffer:y,vaos:b,visibilityBuffer:v}=mT(s,g,u,p,d);t.pushBuffer(y),v&&t.pushBuffer(v);const M=a==="polygonExtrusion"&&!o.getFeatureFlag("transparentBuildingsOff")||a==="lineExtrusion";for(let E=0;E<l.length;E++){const{rangeStart:A,rangeEnd:D,attributes:_,drawMode:O,meta:U,objectsData:B}=l[E],$=y0[a].sinks[c].unpackObjectAttributes(_),V=[];for(let T=0;T<g.length;T++){const I=g[T],S=b[T],P=I.uniformSet||"fill",x={id:lc(),type:wc.Tile,layerSettings:I,start:A/w,count:(D-A)/w,attributes:$,renderingProperties:{},attributesHash:JSON.stringify(_)+"_"+P+"_"+t.detailLevel,vao:S,drawMode:O,tile:t,symbol:a,sink:c,meta:U,canRender:!0};M&&(x.shaderDefinitions=Yo.createShaderDefinitions([{type:"BLEND"}])),t.push(x),I.needsVisibilityBuffer&&V.push(S)}i&&V.length>0&&B&&t instanceof Xo&&gT(B,t,V,i,!!$.floorId)}}function gT(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 u=l.get(n);u||(u=[],l.set(n,u));for(const d of c)u.push(d);i.isHidden(a,ns.PolygonExtrusion)&&o.push(a)}i.triggerIdUpdate(o)}function B0(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 wT=4,vT=.001,bT=1e-7,IT=10,ur=11,Wo=1/(ur-1),MT=typeof Float32Array=="function";function U0(e,t){return 1-3*t+3*e}function z0(e,t){return 3*t-6*e}function G0(e){return 3*e}function Zo(e,t,n){return((U0(t,n)*e+z0(t,n))*e+G0(t))*e}function j0(e,t,n){return 3*U0(t,n)*e*e+2*z0(t,n)*e+G0(t)}function TT(e,t,n,i,s){let r,o,a=0;do o=t+(n-t)/2,r=Zo(o,i,s)-e,r>0?n=o:t=o;while(Math.abs(r)>bT&&++a<IT);return o}function ST(e,t,n,i){for(let s=0;s<wT;++s){const r=j0(t,n,i);if(r===0)return t;const o=Zo(t,n,i)-e;t-=o/r}return t}function ET(e){return e}function V0(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 ET;const s=MT?new Float32Array(ur):new Array(ur);for(let o=0;o<ur;++o)s[o]=Zo(o*Wo,e,n);function r(o){let a=0,c=1;const l=ur-1;for(;c!==l&&s[c]<=o;++c)a+=Wo;--c;const u=(o-s[c])/(s[c+1]-s[c]),d=a+u*Wo,f=j0(d,e,n);return f>=vT?ST(o,d,e,n):f===0?d:TT(o,a,a+Wo,e,n)}return function(a){return a===0?0:a===1?1:Zo(r(a),t,i)}}function H0(e,t,n,i){return t+n/i*e}const AT=V0(.25,.1,.25,1);function $0(e,t,n,i){return t+n*AT(e/i)}function xT(e,t,n,i){return n*(e/=i)*e+t}function _T(e,t,n,i){return-n*(e/=i)*(e-2)+t}function PT(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 OT(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function CT(e,t,n,i){return n*(e/=i)*e*e*e+t}function FT(e,t,n,i){return-n*((e=e/i-1)*e*e*e-1)+t}function RT(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 NT(e,t,n,i){return n*(e/=i)*e*e*e*e+t}function kT(e,t,n,i){return n*((e=e/i-1)*e*e*e*e+1)+t}function BT(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 UT(e,t,n,i){return-n*Math.cos(e/i*(Math.PI/2))+n+t}function zT(e,t,n,i){return n*Math.sin(e/i*(Math.PI/2))+t}function GT(e,t,n,i){return-n/2*(Math.cos(Math.PI*e/i)-1)+t}function jT(e,t,n,i){return e==0?t:n*Math.pow(2,10*(e/i-1))+t}function VT(e,t,n,i){return e==i?t+n:n*(-Math.pow(2,-10*e/i)+1)+t}function HT(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 $T(e,t,n,i){return-n*(Math.sqrt(1-(e/=i)*e)-1)+t}function YT(e,t,n,i){return n*Math.sqrt(1-(e=e/i-1)*e)+t}function WT(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 ZT(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 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)*Math.sin((e*i-o)*(2*Math.PI)/s)+n+t}function qT(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 JT(e,t,n,i,s){return s==null&&(s=1.70158),n*(e/=i)*e*((s+1)*e-s)+t}function KT(e,t,n,i,s){return s==null&&(s=1.70158),n*((e=e/i-1)*e*((s+1)*e+s)+1)+t}function QT(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 eS(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 tS(e,t,n,i){return n*(1-Math.pow(1-e/i,La.nonLinearity+1))+t}const nS=Object.freeze(Object.defineProperty({__proto__:null,ease:$0,easeInBack:JT,easeInCirc:$T,easeInCubic:LT,easeInElastic:ZT,easeInExpo:jT,easeInOutBack:QT,easeInOutCirc:WT,easeInOutCubic:OT,easeInOutElastic:qT,easeInOutExpo:HT,easeInOutQuad:PT,easeInOutQuart:RT,easeInOutQuint:BT,easeInOutSine:GT,easeInQuad:xT,easeInQuart:CT,easeInQuint:NT,easeInSine:UT,easeOutBack:KT,easeOutBounce:eS,easeOutCirc:YT,easeOutCubic:DT,easeOutElastic:XT,easeOutExpo:VT,easeOutQuad:_T,easeOutQuart:FT,easeOutQuint:kT,easeOutSine:zT,inertia:tS,linear:H0},Symbol.toStringTag,{value:"Module"})),iS={easing:"easeInOutQuad",forceFinalValue:!0,renderAfterUpdate:!0};function sS(e,t){return t.tickers[e]}function Y0(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(de(de({},iS),t),{from:i,to:s,duration:r,attributes:a,startTime:n.time,alreadyStartedGroupTickers:c,iterationCount:o})}function zl(e,t){delete t.tickers[e]}function W0(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 u=X0(i.easing,i.from[l],i.to[l],i.duration,s);r.push(u)}}else r=X0(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||zl(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 X0(e,t,n,i,s){return typeof e=="string"?nS[e](s,t,n-t,i):e(s,t,n-t,i)}let rS=0;class q0{constructor(t,n){this.isDestroyed=!1,this.id=rS++,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(Ri(o,t,s),this.mvpMatrices.set(r,o),n){const u=(c=this.demMatrices.get(r))!=null?c:new Float32Array(16);Ri(u,n,s),this.demMatrices.set(r,u)}if(i){const u=(l=this.flatMapTexMatrices.get(r))!=null?l:new Float32Array(16);Ri(u,i,s),this.flatMapTexMatrices.set(r,u)}})}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=[],zl(this.tickerName,t),this.isDestroyed=!0}updateTicker(t){Z0(this.tickerName,{step:(n,i)=>{this.readiness=i}},t)}startTicker(t,n,i,s,r){Y0(this.tickerName,{easing:n},t,s,r,i,1)}tickerFinished(t){return!W0(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 Xo extends q0{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,k0(i,n,this,a),this.setTileCoords(r,s)}setTileCoords(t,n){const i=t[2],s=t[3],r=Dt(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=Dt(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=Gi(o);this.bounds.set(r,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const c=vd();Ar(c,[a[0]-i,a[1]-i,0],at(this.size/Li,this.size/Li,fs/Li)),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 u=!1;for(const{offset:d,size:f}of o)if(l[d]!==n){for(let h=d;h<d+f;++h)l[h]=n;u=!0}if(u){a[0].rewriteData("a_float_visibility");for(const d of a)d.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 Ut=(e=>(e[e.Stationary=0]="Stationary",e[e.ZoomingIn=1]="ZoomingIn",e[e.ZoomingOut=2]="ZoomingOut",e))(Ut||{}),xt=(e=>(e[e.ByOne=0]="ByOne",e[e.WaitingLayer=1]="WaitingLayer",e[e.GlobalWaiting=2]="GlobalWaiting",e))(xt||{});function oS(e,t,n){return{key:t,labelsKey:`${e.labelsKey}_${t}`,useful:!0,ready:!1,needGenerate:!1,tile:e,status:0,params:n.clone()}}function J0(e,t,n){e.generatedData=t,n&&e.params.setTileIds(n)}function K0(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 Gl(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 Q0(e){return e.status===0}function ep(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:aS(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 Xo(e.tile.type,o,i,n,e.tile.coords,void 0,s,e.tile.sourceId)}),t.add(e.key,e));break}}function aS(e,t,n){switch(e.tile.type){case"zenith":return!!(e.useful&&e.tile.serverMetadata&&cS(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 cS(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>xa&&!s.isModelsInfoLoaded(o))return!1}return!0}class dr{constructor(t,n,i,s,r){this.selectedIds=t.slice(),this.styleState=de({},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&&Oi(t.getSelectedIds(),n.getSelectedIds())&&Oi(t.styleState,n.styleState)}clone(){return new dr(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 jl=(e=>(e[e.Initial=0]="Initial",e[e.Loading=1]="Loading",e[e.Loaded=2]="Loaded",e))(jl||{});function lS(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 tp(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){Vl(e,n,t);return}t.performanceCaveatEmitted||(r||!n.hover||n.hover.id===s)&&dS(e,t,n,s,i)}function uS(e,t){const n=Math.min(Math.floor(e.styleZoom),ei.maxDetailLevel),i=t.coords[3];return n===i}function dS(e,t,n,i,s){if(!n.idSet||!n.idSet.has(i)||!uS(t,n)){Vl(e,n,t);return}const r=e.identifier.getIdScope(Fl);r.isHidden(i,ns.PolygonExtrusion)||fS(e,n,i,s).then(o=>{Vl(e,n,t);const a={id:i,tileObjects:[],generatedData:[]},c=[];o.results.forEach(l=>{const u=new Xo("hover",l.collectorOutput.data,e,t,n.coords,void 0,r),{packedRasters:d,rastersToLoad:f}=l.collectorOutput;d!==void 0&&e.assetManager.prepareRasters(l.styleId,d),e.assetManager.loadRasters(f),a.tileObjects.push(u),e.tileManager.addObject(u),u.startTicker(t,ps.inAnimationType,ps.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",qs.Tile,c),e.identifier.queryFillCache(),n.hover=a})}function Vl(e,t,n){t.hover&&(t.hover.tileObjects.forEach(i=>{t.oldHoverTileObjects.push(i),i.startTicker(n,ps.outAnimationType,ps.outAnimationTime,1,0)}),t.hover=void 0,e.labeler.removeLabels("label_hover"),e.identifier.queryFillCache())}function fS(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 np(e){if(e.newMod&&e.newMod.needGenerate)return e.newMod.needGenerate=!1,e.newMod}function hS(e){return(!e.currentMod||Q0(e.currentMod))&&(!e.newMod||Q0(e.newMod))}function pS(e,t){e.currentMod&&Gl(e.currentMod,t),e.newMod&&Gl(e.newMod,t)}function mS(e){e.currentMod=void 0}function qo(e){if(e.currentMod&&e.currentMod.useful)return e.currentMod;if(e.newMod&&e.newMod.useful)return e.newMod}function yS(e){e.currentMod&&(e.currentMod.useful=!1),e.newMod&&(e.newMod.useful=!1)}function gS(e,t,n){if(e.idSet&&t.setTileIds(e.idSet),!e.currentMod&&!e.newMod){Hl(e,t,n);return}if(e.currentMod&&dr.equal(e.currentMod.params,t)){e.currentMod.useful=!0,e.newMod=void 0;return}if(e.newMod){dr.equal(e.newMod.params,t)?e.newMod.useful=!0:Hl(e,t,n);return}Hl(e,t,n)}function Hl(e,t,n){const i=Ig(e.coords,t),s=n.get(i);s?(e.newMod=s,e.newMod.useful=!0):(e.newMod=oS(e,i,t),e.idSet&&e.newMod.params.setTileIds(e.idSet))}function wS(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&&ep(e.currentMod,t,n,i,s),e.newMod&&(ep(e.newMod,t,n,i,s),e.newMod.needGenerate&&(e.needGenerate=!0))}function vS(e){e.newMod&&e.newMod.ready&&(e.currentMod=e.newMod,e.newMod=void 0)}function bS(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 IS(e){e.status===1&&(e.needAbortFetch=!0),e.status=0,e.serverMetadata=void 0,e.revision++}function MS(e){e.revision++}const TS=()=>{};class ip{constructor(t,n=TS){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 is(e){const t=e.viewportTiles;for(const n in e.tiles)yS(e.tiles[n]);for(const n of t){let i=e.tiles[n];i||(i=e.tiles[n]=lS(e.type,hc(n),e.sourceId,e.tileLayerId));const s=new dr(e.selectedIds,e.styleState,i.revision,e.styleId,e.styleRevision);gS(i,s,e.tileModsCache)}}function $l(e,t){for(const n of t){const i=e[n],s=qo(i);if(!s||!s.ready)return!1}return!0}function sp(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 rp(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 op(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 ap(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];hS(r)&&!t.has(s)&&e.zoomDirection===Ut.Stationary&&!n.has(r)&&i.push(r)}return i}function cp(e,t,n,i,s,r,o,a,c,l,u=0,d=!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:lp(e,c.zoom,c.styleZoom),zoomDirection:Ut.Stationary,zoomStartZoom:0,tileModsCache:new ip(0,(h,g)=>{var w;a.labeler.removeLabels(g.labelsKey),(w=g.objects)==null||w.forEach(p=>a.tileManager.removeObject(p)),Gl(g,c)}),tileModsCacheMaxCount:0,selectedIds:[],displayedMods:{},tilesAppearance:xt.ByOne,mapState:c,stopLabelAnimation:!1,viewportPadding:u,displayStats:{matched:0,shifted:0,parent:0,children:0},requestOddTiles:d,ids:l,useExtendedTilesBounds:f}}function lp(e,t,n){return e==="raster"?Math.round(t):Math.floor(n)}function Yl(e){for(const t in e.tiles)pS(e.tiles[t],e.mapState);e.tiles={},e.viewportTiles=new Set,e.zoomDirection=Ut.Stationary,e.tileModsCache.reset(),e.displayedMods={},e.tilesAppearance=xt.ByOne}function up(e,t,n,i,s=!1){const{tileManager:r,renderer:o}=e,a=n.displayedMods,c=md(a,i);c.forEach(d=>{if(d.objects!==void 0){let f=!s;for(const h in i)if(Ng(d.tile,i[h].tile)){f=!1;break}d.objects.forEach(h=>{r.addObject(h),f&&h.startTicker(t,_a.type,_a.time,0,1)})}});const l=md(i,a);l.forEach(d=>{var f;d.objects!==void 0&&(d.objects.forEach(h=>{r.removeObject(h)}),(f=d.tile.hover)==null||f.tileObjects.forEach(h=>r.removeObject(h)))});const u=c.length>0||l.length>0;return u&&(t.needLabeling=!0,o.addRerenderEvent()),u}function Wl(e){e.viewportTiles.forEach(t=>vS(e.tiles[t]))}function SS(e){switch(e){case"geojson":return 3;case"raster":return 1/0;case"dem":return 1}return 2}function Zl(e,t,n){ES(e,t.styleZoom,t.zoom),AS(e,t,n),xS(e),is(e)}function ES(e,t,n){const i=lp(e.type,n,t),s=i-e.zoomLevel;e.zoomDirection===Ut.Stationary&&(s>0?(e.zoomDirection=Ut.ZoomingIn,e.zoomStartZoom=e.zoomLevel):s<0&&(e.zoomDirection=Ut.ZoomingOut,e.zoomStartZoom=e.zoomLevel)),e.zoomLevel=i}function AS(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=Jd(t,i,e.minZoomLevel).map(xe);break;default:r=ef(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 xS(e){const t=Math.round((Object.keys(e.displayedMods).length+e.viewportTiles.size)*ei.cacheRatio);e.tileModsCacheMaxCount<t&&(e.tileModsCacheMaxCount=t),t>e.tileModsCacheMaxCount/2&&e.tileModsCache.setSize(t)}function _S(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=Ko(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 PS(e,t,n){const i=OS(e),s=Object.keys(i).reduce((d,f)=>{const h=i[f],g=Ko(h.coords[0],h.coords[1],h.coords[2]);return d[g]=h,d},{}),r=Math.min(...Object.values(i).map(d=>d.coords[2])),o=Math.min(...Array.from(t).map(d=>e[d].coords[2])),a=_S(i,o),c={},l=new Set;for(const d of t){const f=i[d];if(f){Jo(c,f),n.matched++;continue}const h=e[d],g=LS(h,i,3);if(g){n.shifted++,Jo(c,g);continue}const w=Ko(h.coords[0],h.coords[1],h.coords[2]),p=dp(h,r,s);if(p){n.parent++,Jo(c,p),l.add(p);continue}const y=a[w];if(y)for(const b of y)n.children++,Jo(c,b)}function u(d){const f=dp(d,r,s);f&&l.has(f)&&(delete c[d.currentMod.key],u(f))}for(const d in c)u(c[d].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=Xd(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 Jo(e,t){const n=t.currentMod;e[n.key]=n}function OS(e){const t={};for(const n in e){const i=e[n];DS(i)&&(t[n]=i)}return t}function dp(e,t,n){let[i,s,r]=e.coords;for(;r-->=t;){i=Math.floor(i/2),s=Math.floor(s/2);const o=Ko(i,s,r);if(n[o])return n[o]}}function Ko(e,t,n){return`${e}_${t}_${n}`}function fp(e,t,n){CS(e,t,n),FS(e),RS(e);for(const i in e.displayedMods)e.tileModsCache.get(i);NS(e),kS(e)}function CS(e,t,n){for(const i in e.tiles)wS(e.tiles[i],e.tileModsCache,t,n,e.ids)}function FS(e){switch(e.tilesAppearance){case xt.ByOne:Wl(e);break;case xt.WaitingLayer:$l(e.tiles,e.viewportTiles)&&(e.tilesAppearance=xt.ByOne,Wl(e));break;case xt.GlobalWaiting:break}}function RS(e){const{tiles:t,viewportTiles:n,displayStats:i}=e;e.displayedMods=PS(t,n,i)}function NS({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]&&mS(s)}}function kS(e){switch(e.zoomDirection){case Ut.ZoomingIn:(e.zoomLevel<=e.zoomStartZoom||hp(e))&&(e.zoomDirection=Ut.Stationary,e.zoomStartZoom=e.zoomLevel);break;case Ut.ZoomingOut:(e.zoomLevel>=e.zoomStartZoom||hp(e))&&(e.zoomDirection=Ut.Stationary,e.zoomStartZoom=e.zoomLevel);break}}function hp(e){const{tiles:t,viewportTiles:n,displayedMods:i}=e;for(const s of n){const r=t[s],o=qo(r);if(!o||i[o.key]===void 0)return!1}return!0}function BS(e,t,n,i){var s;n.selectedIds=i,n.tilesAppearance=xt.WaitingLayer,is(n);for(const r in n.tiles){const o=n.tiles[r];tp(e,t,o,n.sourceId,(s=o.hover)==null?void 0:s.id,!0)}}function pp(e,t,n,i){if(!t.disableHoverStyles){for(const s in n.tiles){const r=n.tiles[s];tp(e,t,r,n.sourceId,i)}e.labeler.disableThrottleUpdateOnce()}}function US(e,t){e.styleState=t,is(e)}function mp(e,t,n,i){i?e.tilesAppearance=xt.ByOne:e.tilesAppearance=xt.GlobalWaiting,e.styleId=t,e.styleRevision=n,is(e)}function yp(e){e.tilesAppearance=xt.ByOne,Wl(e)}function zS(e){e.tilesAppearance=xt.WaitingLayer,e.stopLabelAnimation=!0,Object.keys(e.tiles).forEach(t=>{IS(e.tiles[t])}),is(e)}function GS(e){e.tilesAppearance=xt.WaitingLayer,Object.keys(e.tiles).forEach(t=>{MS(e.tiles[t])}),is(e)}function jS(e,t,n){for(const i of e.viewportTiles){const s=e.tiles[i],r=qo(s);if(!r)continue;const o=K0(r);if(o.length===0)continue;const a=t.getLabelsDemKey(o);r.demKey!==a&&(r.demKey=a,n.addTileLabels(r.labelsKey,qs.Tile,o))}}function Xl(e){return{_src:e.memSizeJs()}}function VS(e){return{_texture:e.memSizeGPU()}}function gp(e){return{[String(e.purpose)]:{_initData:e.memSizeJs()}}}function HS(e){return{[String(e.purpose)]:{_glBuffer:e.memSizeGPU()}}}function ql(e){var n;const t={};return e.generatedData&&(t.generatedData={collectorOutput:(n=e.generatedData)==null?void 0:n.map(i=>WS(i.collectorOutput))}),e.objects&&(t.objects=e.objects.map(i=>wp(i))),t}function Jl(e){return{objects:e.objects?e.objects.map(t=>vp(t)):0}}function wp(e){return{buffers:e.buffers.map(gp)}}function vp(e){return{children:e.children.map(t=>{var n;return{[`${t.symbol}_${t.sink}`]:((n=t.instanceCount)!=null?n:t.count)*cr(t.symbol,t.sink)}}),buffers:e.buffers.filter(t=>t.purpose!=="attributes"&&t.purpose!=="instanced").map(t=>({[String(t.purpose)]:t.byteLength}))}}function $S(e){return{buffers:e.buffers.filter(t=>t instanceof Ze).map(gp).filter(t=>t._initData),textures:e.textures.map(Xl)}}function YS(e){return{buffers:e.buffers.filter(t=>t instanceof Ze).map(HS),textures:e.textures.map(Xl)}}function Kl(e){if(typeof e=="number")return e;let t=0;if(Array.isArray(e))for(const n of e)t+=Kl(n);else for(const n in e){const i=e[n];typeof i=="number"?t+=i:t+=Kl(i)}return t}function WS(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 ZS(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 bp{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:Fl),this.ids.registerTileLayer(this),this.modules=r,this.mapState=o,this.prevStyleState=o.styleState,this.sourceCore=a,this.id=lc(),this.disableTilesAnimation=!!c.disableTilesAnimation,this.gridState=cp(a.type,a.id,this.id,t,n,i,s,r,this.mapState,this.ids,c.viewportPadding,c.requestOddTiles,c.useExtendedTilesBounds),this.maxGeneratingCount=SS(a.type)}memSizeJs(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>ql(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>ql(t.tileModsCache.get(n)))}}}memSizeGpu(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>Jl(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>Jl(t.tileModsCache.get(n)))}}}destroy(){this.destroyed=!0,Yl(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),this.ids.unregisterTileLayer(this)}redraw(){Yl(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),Zl(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 $l(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(){mp(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){yp(this.gridState)}setSelectedIds(t){BS(this.modules,this.mapState,this.gridState,t)}setHoverId(t){pp(this.modules,this.mapState,this.gridState,t)}resetHoverId(){pp(this.modules,this.mapState,this.gridState)}onSourceDataChange(){zS(this.gridState)}onFeatureStateMapChange(){GS(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=qo(n);if(s&&s.ready)return!1}return!0}updateViewport(){Zl(this.gridState,this.mapState,this.modules)}update(){this.mapState.needReplicasUpdate&&this.setModObjectsSyncNecessity();const t=de({},this.gridState.displayedMods);this.mapState.styleState!==this.prevStyleState&&(US(this.gridState,this.mapState.styleState),this.prevStyleState=this.mapState.styleState,this.modules.identifier.queryFillCache()),fp(this.gridState,this.mapState,this.modules);const{demManager:n,labeler:i}=this.modules;jS(this.gridState,n,i),this.fetch(sp(this.gridState)),this.abortFetch(rp(this.gridState)),this.generate(op(this.gridState)),this.clearTiles(ap(this.gridState)),up(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)=>Gr(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===jl.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){xf(this.sourceCore.type);return}if(!Array.isArray(a.results))return;let{results:c}=a;r&&(c=c.filter(u=>!r.includes(u.regionId)));const l=new Map;if(c.forEach(u=>{u.collectorOutput.data.forEach(d=>{d.symbol!=="gltfModel"||d.sink!=="instances"||d.generatedObjects.forEach(f=>{var y;const h=Xn.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 u=xe(s.tileCoords);this.ids.updateParentChildrenData(u,l)}c.forEach(u=>{const{styleId:d,metatileHash:f,regionId:h,collectorOutput:g}=u,{packedRasters:w,rastersToLoad:p,floorHidingMap:y,dataModelsUrls:b}=g;w!==void 0&&this.modules.assetManager.prepareRasters(d,w),this.modules.assetManager.fillDataModelUrlMap(b),this.modules.assetManager.loadRasters(p),this.modules.floorManager.prepareFloors(h,f,y,this.sourceCore.type)}),n.idSet=bS(c),J0(i,c,n.idSet),this.modules.labeler.addTileLabels(i.labelsKey,qs.Tile,K0(i))}).finally(()=>{this.generatingCount=this.generatingCount-1,this.updateGenerationQueue()})}getTileToGenerate(){this.tilesGenerationQueue.sort((n,i)=>Gr(this.mapState.center,n,i));let t=this.tilesGenerationQueue.shift();for(;t;){const n=np(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)=>Gr(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,ns.PolygonExtrusion),r=+!this.ids.isHidden(i,ns.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 Ip{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(de({},this.options),{url:t}):this.options=ve(de({},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=L(t,{precomputes:[]},Qe.Generator):this.dataFilter=void 0}}let XS=1;function Mp(){return XS++}class Tp{constructor(t){this.defs=t.map(n=>new qS(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 qS{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 Sp(e,t,n){let i,s,r,o;const a=function(){const u=Date.now()-r;u<t&&u>=0?i=setTimeout(a,t-u):(i=null,n||(o=e(...s),i||(s=null)))};function c(){i!==void 0&&(clearTimeout(i),i=null)}function l(...u){s=u,r=Date.now();const d=n&&!i;return i||(i=setTimeout(a,t)),d&&(o=e(...s),s=null),o}return l.cancel=c,l}const Ep=15,Ql=17;class Ap{constructor(t,n,i){var o,a,c;this.type="geojson",this.isCustomPromoteId=!1,this.id=Mp(),this.modelsAppearStrategy=(o=n.modelsAppearStrategy)!=null?o:Uu,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 Ip(this.id,this.modules,n);const s=(a=n.minZoom)!=null?a:Ea.minZoom,r=Math.min((c=n.maxZoom)!=null?c:Ep,Ql);this.layer=new bp(s,r,s,Ql,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 Qo={type:"FeatureCollection",features:[]};let xp=class Ym extends Ap{constructor(t,n,i){n.generateId=!0,super(t,n,i),this.subtype="internal",this.data=n.data,this instanceof Ym&&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=Qo}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 JS extends Ap{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 KS=class extends xp{constructor(t,n,i){super(t,n,i),this.subtype="viewport-internal",this.destroyed=!1,this.viewportDiffer=new Tp([{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(Qo),this.viewportHandler=void 0;return}this.viewportHandler=Sp(()=>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=Qo;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 ea(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 _p(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 Pp(e){return e?e>=500&&e<=599:!1}function Lp(e){return new Promise(t=>setTimeout(t,e))}class QS{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||!Pp((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 Lp(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=ea({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=Mg(a),l=Tg(c);this.cache.set(s,c),i({metadata:l,err:o})});this.pendingRequests.set(s,{xhr:r,resolve:i})})}}class eu 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 tu(e){for(let t=1;t<e.length;t++)e[t]=e[t]+e[t-1]}function eE(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 Dp={1:tu,2:tu,4:tu,8:eE};class Op{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&&Dp[s](r),r}function ta(e,t,n){e.offset+=-e.offset&7;const i=new Uint32Array(e.buffer,e.offset,t*2);return e.offset+=8*t,n&&Dp[8](i),i}function Cp(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 Fp(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 tE(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 nE(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 iE(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 ta(e,t);case 9:return ta(e,t,!0);case 10:return Ue(e,Uint8Array,t);case 11:return tE(e,t);case 12:return nE(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 ta(e,t);case 20:return ta(e,t,!0);case 21:return Cp(e,t);case 22:return Cp(e,t,!0);case 23:return Fp(e,t);case 24:return Fp(e,t,!0);case 25:return Ue(e,Uint32Array,t);default:throw new Error("Unknown stream type "+n)}}function nu(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function sE(e,t,n){return new e.constructor(e.buffer,e.byteOffset+t*e.BYTES_PER_ELEMENT,n)}let Kn;const ss=[],Xt=new Int32Array(256);let iu;const su=[],Rp=[],Np=[],ru=[0,0,0,0,0];let kp=0,ou=0,au=0,rs={};function rE(e,t,n,i,s,r,o,a,c=!1,l,u,d,f){const{styleState:h,sourceId:g,sourceAttrs:w,tileInfo:p,pixelRatio:y,selectedIds:b,dataFilter:v,floorsEnabled:M,hoverId:E,generateOnlySelectedPoi:A,generateOnlyHoveredPoi:D,modelsPath:_}=s,{data:O}=r,U=new Set(b),B=Sg(O);if(B.byteLength<8)return i.getAccumulatedData();ss.length=0;const $=new Op(B);if($.readU32()!==1279676242)return i.getAccumulatedData();const T=$.readU16();if(T!==2&&T!==3&&T!==4)return console.error(`Unsupported tile format version: "${T}"`),i.getAccumulatedData();Kn=T,$.readU16();const I=Cc(y);return oE($),aE($),cE(Kn,e,t,h,n,i,$,p,I,U,v,o,a,M,g,w,c,E,A,D,_,l,u,d,f),i.getAccumulatedData()}function oE(e){const t=Kn===4?2:1,n=e.u8;let i=e.offset,s=e.u32[i>>2];for(i+=4,kp=s,ou=i;s--;)i=n[i++]*2+i,i=n[i++]*t+i;e.offset=i+(-i&3)}function aE(e){const t=e.u32[e.offset>>2];e.offset+=4,iu=Ue(e,Uint8Array,t);const n=Ue(e,Uint32Array,t);for(let i=0;i<t;i++){const s=iu[i];ss[i]=iE(e,n[i],s),Xt[i]=0}}function cE(e,t,n,i,s,r,o,a,c,l,u,d,f,h,g,w,p=!1,y,b,v,M,E,A,D,_){const O=Array.from(s.featureAttrs);As(d,O);const U=kp,B=Ue(o,Int32Array,U),$=nu(B),V=Ue(o,Uint8Array,$,!0),T=Ue(o,Uint8Array,nu(V),!0),I=Ue(o,Uint8Array,$,!0),S=Ue(o,Uint8Array,nu(I),!0),P=Ue(o,Uint16Array,$,!0);let x=0,F=0,C=0,k=!0;for(let R=0;R<U;R++){const G=B[R];fE(o,d,f);for(let X=0;X<G;X++){const H=V[x];H>0&&(lE(f,H,T,F,d,e,p),F+=H);const Q=I[x];if(Q>0&&(uE(f,Q,S,C),C+=Q),!f[d.tileProps.db_geometry_type]){console.error(`Geometry type not specified for data source ${g}. Metatile version ${d.version}`);return}k=H>0||Q>0;const J=d.tileProps;let N=f[J[D!=null?D:""]];Number.isNaN(N)&&(N=void 0);const Z=ks(i,w,J,f,[],N,a),q=P[x];q>0&&dE(e,t,n,i,Z,s,r,q,a,c,l,u,d,h,g,y,b,v,M,E,k,A,_),x++}}Bp()}function lE(e,t,n,i,s,r,o=!1){var a,c;for(;t--;){const l=n[i++],u=Rp[l],d=su[l],f=iu[u];if(f===8||f===9||f===19||f===20)e[d]=d0(ss[u][Xt[u]],ss[u][Xt[u]+1]),Xt[u]+=2;else{const h=ss[u][Xt[u]];switch(d){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[d]=r===2?h*Li:h;break;case s.tileProps.db_label:e[d]=Jr(h);break;case s.tileProps.db_label2:e[d]=Jr(h);break;case s.tileProps.db_schedule:e[d]=JSON.parse(Jr(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[d]=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[d]=y}break;default:if(o&&f===11)e[d]=Jr(h);else{const y=s.tilePropsByIndex[d];e[d]=(c=(a=s.reverseDictionaries[y])==null?void 0:a[h])!=null?c:h}}Xt[u]++}}}function uE(e,t,n,i){for(;t--;){const s=n[i++],r=su[s];e[r]=NaN}}let na=[];function dE(e,t,n,i,s,r,o,a,c,l,u,d,f,h,g,w,p,y,b,v=[],M,E,A){var S;const{tileProps:D,defaultProps:_}=f,{tileAttrs:O,featureAttrs:U,id:B}=s,$=c.coords[3],V=D.db_hidden_by_plan_id!==void 0;if(!M&&na.length===0){for(let P=0;P<au;P++){const x=ru[P];Xt[x]=Xt[x]+a}return}const T=O[D.db_geometry_type],I=Kn===4?f.vertexProps:f.vertexPropsLegacy[T];if(!I){console.error(`Couldn't get vertex keys for tile ${xe(c.coords)} source ${g}. Metatile version ${f.version}`);return}for(let P=0;P<au;P++){const x=Kn===4?Np[P]:P,F=ru[P],C=(S=I[x])!=null?S:"signed_z";rs[C]=hE(sE(ss[F],Xt[F],a),P,e),Kn===4&&C==="z"&&(rs.signed_z=rs.z),Xt[F]=Xt[F]+a}if(!(D.db_sublayer!==void 0&&!Number.isNaN(O[D.db_sublayer])&&Fo(O[D.db_sublayer]))&&!(V&&i._activeFloorIds&&O[D.db_hidden_by_plan_id]&&i._activeFloorIds.includes(O[D.db_hidden_by_plan_id]))){for(const P in _){const x=_[P];Number.isNaN(O[x.index])&&(O[x.index]=x.value)}if(!(w&&w!==B)){if(B!==void 0){let P=u.has(B);p&&(P=!0);const x=!!y||!!w&&w===B;if(O[D.selected]=P?1:0,O[D.hovered]=x?1:0,v.length>0){const F={};v.forEach(C=>{F[C]=O[D[C]]}),o.addPromotedObjectAttributes(B,F)}h&&$>=Da.detailLevel&&(O[D.db_hidden_by_plan_building_id]&&o.addFloorHidingMap(B,O[D.db_hidden_by_plan_building_id]),O[D.db_hidden_by_metro_building_id]&&o.addFloorHidingMap(B,O[D.db_hidden_by_metro_building_id]))}else O[D.selected]=0,O[D.hovered]=0;if(r.featureAttrs.size>0){const P=B!==void 0&&r.get(B);if(P)for(const x of r.featureAttrs)r.clearAttrs=!1,U[D[x]]=P[x];else if(r.clearAttrs===!1){r.clearAttrs=!0;for(const x in D)U[D[x]]!==void 0&&(U[D[x]]=void 0)}}if(E){const P=pE(rs,T,c);if(P){const x=mE(s,xe(c.coords));o.addFeature({type:"Feature",properties:x,geometry:P})}return}M&&(na=n.getLayers(t.id,D,O).filter(P=>j(P.filter,s)&&(d?j(d,s):!0))),na.length===0&&s.id&&o.idIndexer.addOrphanId(s.id),Cl(o,t,na,s,f,Kn,$,g,c,l,rs,p||y,b,A)}}}function fE(e,t,n){const i=Object.keys(t.tileProps).length,s=e.u8;let r,o,a=ou;for(o=1;o<i;o++)n[o]=NaN;for(r=s[a++],o=0;o<r;o++)su[o]=s[a++],Rp[o]=s[a++];for(r=s[a++],o=0;o<r;o++)Kn===4&&(Np[o]=s[a++]),ru[o]=s[a++];au=r,ou=a,Bp()}function Bp(){rs={}}function hE(e,t,n){if(n===2&&t<3&&e instanceof Uint16Array)for(let i=0;i<e.length;i++)e[i]*=Li;return e}function pE(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 u=_s(s[l],r[l],n),d=oe.scaleFactor(u[1]),f=o?o[l]*32:void 0;u[2]=(c=f!=null?f:a==null?void 0:a[l])!=null?c:0,u[2]/=Ie*d,i.push(u)}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,u)=>i[dt(u,i.length)])]};default:return}}function mE(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 yE=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},gE=e=>yE(e)>0;function wE(e){e=e.slice().sort(vE);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&&Up(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&&Up(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}return n.slice(0,i-1)}function Up(e,t,n){return(t[1]-e[1])*(n[0]-e[0])-(t[0]-e[0])*(n[1]-e[1])}function vE(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function bE(e){const t=[],n=gE(e),i=Sr(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=[];_y(c,e[r],e[o],e[a],n),t.push(c)}return i&&t.push(t[0]),t}const ia=[[0],[0],[0]],zp=[];function IE(e,t,n,i,s,r,o,a,c){const{matrix:l,offset:u,id:d,selected:f}=r,h=new Op(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 _=0;_<w;_++)g.push(h.readU8Vector());const{tileProps:p}=o,y=[],b=Object.keys(p).length;for(let _=0;_<b;_++)y[_]=NaN;if(y[p.db_sublayer]="Building_model",y[p.selected]=f?1:0,y[p.db_region]=a,c.featureAttrs.size>0){const _=Array.from(c.featureAttrs);As(o,_)}const v=[],M=typeof d!="number"&&c.get(d);if(M)for(const _ of c.featureAttrs)c.clearAttrs=!1,v[p[_]]=M[_];else if(c.clearAttrs===!1){c.clearAttrs=!0;for(const _ in p)v[p[_]]!==void 0&&(v[p[_]]=void 0)}const E=h.offset,A=ks(n,oc,p,y,v,d),D=t.getLayers(e.id,p,y).filter(_=>j(_.filter,A));return D.length===0&&A.id&&i.idIndexer.addOrphanId(A.id),D.forEach(_=>{_.type!=="buildingModel"||(Ol(_,A),!j(_.filter,A))||(h.offset=E,ME(e,_,A,i,h,l,u))}),{objects:i.getAccumulatedData(),textures:g}}function ME(e,t,n,i,s,r,o){const a=s.readU32();for(let c=0;c<a;c++){const l=s.readU32(),u=at(s.readF32(),s.readF32(),s.readF32()),d=at(s.readF32(),s.readF32(),s.readF32()),f=Kt(yt(),d,u),h=[];bd(h,r,u),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 M=s.readU32()===1?Qm:gr,E=s.readU16Vector();do bn.processSubmesh(e.id,t,n,i,g,E,M,l,h);while(i.isOverloaded())}const p=s.readU16Vector();do bn.processOuterEdge(e.id,t,n,i,g,p,h);while(i.isOverloaded());const y=wE(TE(g)),b=bE(y);for(let v=0;v<y.length-2;v++){for(let M=0;M<3;M++){const E=SE(v+M,y.length);ia[0][M]=y[E][0],ia[1][M]=y[E][1],ia[2][M]=0,zp[M]=b[E]}do Rt.generateFloorsBottomFill(i,e.id,ia,zp,uo,h);while(i.isOverloaded())}}}function TE(e){const t=[];for(let n=0;n<e.length;n+=5)t.push([e[n],e[n+1]]);return t}function SE(e,t){return e===0?0:e%2?(e+1)/2:t-e/2}function EE(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var cu={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */cu.read=function(e,t,n,i,s){var r,o,a=s*8-i-1,c=(1<<a)-1,l=c>>1,u=-7,d=n?s-1:0,f=n?-1:1,h=e[t+d];for(d+=f,r=h&(1<<-u)-1,h>>=-u,u+=a;u>0;r=r*256+e[t+d],d+=f,u-=8);for(o=r&(1<<-u)-1,r>>=-u,u+=i;u>0;o=o*256+e[t+d],d+=f,u-=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)},cu.write=function(e,t,n,i,s,r){var o,a,c,l=r*8-s-1,u=(1<<l)-1,d=u>>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=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*Math.pow(2,1-d),t*c>=2&&(o++,c/=2),o+d>=u?(a=0,o=u):o+d>=1?(a=(t*c-1)*Math.pow(2,s),o=o+d):(a=t*Math.pow(2,d-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 AE=we,sa=cu;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 lu=65536*65536,Gp=1/lu,xE=12,jp=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=ra(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Hp(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=ra(this.buf,this.pos)+ra(this.buf,this.pos+4)*lu;return this.pos+=8,e},readSFixed64:function(){var e=ra(this.buf,this.pos)+Hp(this.buf,this.pos+4)*lu;return this.pos+=8,e},readFloat:function(){var e=sa.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=sa.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,_E(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>=xE&&jp?VE(this.buf,t,e):jE(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=xn(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=xn(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=xn(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=xn(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=xn(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=xn(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=xn(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=xn(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=xn(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),os(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),os(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),os(this.buf,e&-1,this.pos),os(this.buf,Math.floor(e*Gp),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),os(this.buf,e&-1,this.pos),os(this.buf,Math.floor(e*Gp),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){LE(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=HE(this.buf,e,this.pos);var n=this.pos-t;n>=128&&Vp(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),sa.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),sa.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&&Vp(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,CE,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,FE,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,kE,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,RE,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,NE,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,BE,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,UE,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,zE,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,GE,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 _E(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 PE(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function xn(e){return e.type===we.Bytes?e.readVarint()+e.pos:e.pos+1}function PE(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function LE(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),DE(n,i,t),OE(i,t)}function DE(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 OE(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 Vp(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 CE(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function FE(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function RE(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function NE(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function kE(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function BE(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function UE(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function zE(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function GE(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function ra(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function os(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Hp(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function jE(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,u;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],u=e[s+3],(c&192)===128&&(l&192)===128&&(u&192)===128&&(o=(r&15)<<18|(c&63)<<12|(l&63)<<6|u&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 VE(e,t,n){return jp.decode(e.subarray(t,n))}function HE(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 $E=EE(AE),YE=1,uu={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]=du(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]]=du(e,s&7)}return i},6:e=>null};function du(e,t){const n=e.pbf;if(n.pos<n.length){const i=uu[t];if(!i)throw new Error(`Type ${t} is not supported`);return i(e)}}function $p(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 WE(e,t){if(!e||!e.byteLength||e.byteLength<4)throw new Error("Bad array or insufficient array length.");const n=new $E(e),i=n.readFixed32(),s=i>>24&255;if(s>YE)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(),u=new Array(l);for(let f=0;f<l;f++)u[f]=n.readString();n.pos=c;const d=n.readVarint();return du({keys:u,pbf:n},d);case 2:{const f={keys:[],pbf:n},h=n.readFixed32(),g=$p(n),w={};for(const{key:p,type:y}of g){const b=uu[y],v=[];for(let M=0;M<h;M++)v.push(b(f));w[p]=v}return w}case 3:{const f={keys:[],pbf:n},h=n.readFixed32(),g=$p(n),w=new Array(h);for(let p=0;p<h;p++)w[p]={};for(const{key:p,type:y}of g){const b=uu[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 Yp(e){const t=new eu;if(e instanceof ArrayBuffer){const s=WE(e);if(Array.isArray(s))for(const n of s){const i=n,{id:r}=i,o=$m(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 ZE{constructor(t){this.scope=t,this.tileLoader=new QS,this.tileAttrs=[],this.models={},this.featureStateMap=new eu}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:u}=t,d=xe(o.coords),f=this.tileLoader.get(d),h=[],g=[],w=[],p={};return f.forEach(y=>{var A;const{regionId:b,metatileHash:v}=y,M=this.scope.styleManager.getStyle(t.styleId);if(!M)return;if(t.areTileBoundsVisible&&t.isDefaultSource){const _=i.getStyle($o).layers.find(O=>O.id==="debug-tile-bounds");R0(s,_,t.styleState)}const E=rE(M,i,this.featureStateMap,s,t,y,r[v],this.tileAttrs,l,a,n,c,u);Object.assign(p,E.promotedObjectAttributes),h.push({regionId:b,metatileHash:v,collectorOutput:E,styleId:M.id}),w.push(...E.transferable),(A=E.debugGeoJsonData)==null||A.forEach(D=>g.push(D))}),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=Yp(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(d=>{ea({url:r},(f,h)=>{if(f||h.byteLength===0){const g=this.models[o]=new ArrayBuffer(0);d(g)}else this.models[o]=h,d(h)})})).then(d=>{if(d.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}=IE(f,a,t.styleState,this.scope.collector,d,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,d]}),this.scope.resetCollector()})})}destroy(){this.tileLoader.destroy(),this.tileAttrs=[],this.models={}}}function XE(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 oa=.8;class qE{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*oa}extend(){const t=this.buffer.byteLength*2;this.maximum=t/this.stride,this.watermark=this.maximum*oa;const n=new ArrayBuffer(t),i=new Int32Array(n);return i.set(this.view),this.buffer=n,this.view=i,n}}class JE{constructor(t){this.offset=0,this.buffer=new Int32Array(t),this.comittedOffsets=0,this.watermark=t*oa}extend(){const t=this.buffer.length*2;this.watermark=t*oa;const n=new Int32Array(t);n.set(this.buffer),this.buffer=n}}class Wp{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=cr(t,n);this.elements=new qE(a,c),this.indices=new JE(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 vt(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}vt.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},vt.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 fu(s,this.w,t),this.allocShelf(this.shelves.push(o)-1,e,t,n);if(this.autoResize){var l,u,d,f;return l=u=this.h,d=f=this.w,(d<=l||e>d)&&(f=Math.max(e,d)*2),(l<d||t>l)&&(u=Math.max(t,l)*2),this.resize(f,u),this.packOne(e,t,n)}return null},vt.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},vt.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},vt.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)}},vt.prototype.getBin=function(e){return this.bins[e]},vt.prototype.ref=function(e){if(++e.refcount===1){var t=e.h;this.stats[t]=(this.stats[t]|0)+1}return e.refcount},vt.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)},vt.prototype.clear=function(){this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0},vt.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 fu(e,t,n){this.x=0,this.y=e,this.w=this.free=t,this.h=n}fu.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 KE(n,i,this.y,e,t,e,this.h)},fu.prototype.resize=function(e){return this.free+=e-this.w,this.w=e,!0};function KE(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 QE{constructor(){this.packer=new vt(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 vt(cn[0],cn[1]),this.currentAtlasIndex++,l=this.packer.packOne(a+2,c+2));const u=s.length,d={rasterSetIndex:t.index,rasterIndex:u,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(d),this.packedRasters.push(t.index,u,d.x,d.y,d.w,d.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===Ii.Static)continue;const a=o.w*i,c=o.h*i;let l=Ks(s,a,!1),u;if(l===void 0)l=s.length,u={rasterSetIndex:t.index,rasterIndex:l,w:a,h:c,x:0,y:0,anchorX:0,anchorY:0,atlasIndex:this.currentAtlasIndex,isPacked:!1},s.push(u);else if(u=t.rasters[l],u.isPacked)continue;let d=this.packer.packOne(u.w+2,u.h+2);d===null&&(this.packer=new vt(cn[0],cn[1]),this.currentAtlasIndex++,d=this.packer.packOne(u.w+2,u.h+2)),u.x=d.x+1,u.y=d.y+1,u.atlasIndex=this.currentAtlasIndex,u.isPacked=!0,this.packedRasters.push(t.index,l,u.x,u.y,u.w,u.h,this.currentAtlasIndex)}}}const eA=re(2,32)-2,tA=gd(re(2,32)-1),nA=gd(re(2,32)-2);class iA{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%eA}}const Zp=re(2,20),Xp=["main","parser","labeling","models"],hu={};for(let e=0;e<Xp.length;e++){const t=Xp[e];hu[t]={min:1+e*Zp,max:(e+1)*Zp}}class sA{constructor(t){this.atlasPacker=new QE,this.pointIndexer=new iA,this.innerColors=new Map,this.floorHidingMap=new Map,this.usedModels=new Set,this.dataModels={},this.promotedObjectAttributes={},this.addedBuckets=[],this.labels=[],this.idIndexer=new Tb(t),this.workerName=t,this.dataModelsIndex=hu[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}=hu[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=gr){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=Wp.generateKey(i),l=a[c];if(l)return this.addedBuckets.push(l),l;const u=new Wp(t,n,i,s,r,c);return a[c]=u,this.addedBuckets.push(u),u}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=cr(h,p)/4;let v=0;for(const D in y)v+=y[D].indices.offset;if(v===0)continue;const M=[],E=new Int32Array(v*b);let A=0;for(const D in y){const _=y[D],{elements:O,indices:U,attributes:B,meta:$,objectsData:V,extents:T,maxDiag:I}=_,{view:S}=O,{buffer:P}=U;if(O.offset===0)continue;const x=A,F={};for(let C=0;C<U.offset;C++){const k=V?V[C]:null;if(k){const G=A/b;rA(k,G,F)}const R=P[C]*b;for(let G=0;G<b;G++)E[A++]=S[R+G]}M.push({attributes:B,drawMode:_.drawMode,rangeStart:x*4,rangeEnd:A*4,meta:$,objectsData:Object.keys(F).length>0?F:void 0,extents:new Float32Array(T),maxDiag:I}),_.resetOffsets(),_.resetBuildingsData(),_.resetInstancesExtents(),_.meta=void 0}n.push({symbol:h,sink:p,buffer:E.buffer,generatedObjects:M}),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,this.innerColors=new Map;const l=this.labels;this.labels=[];const u=this.promotedObjectAttributes;this.promotedObjectAttributes={};const d=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:u,debugGeoJsonData:d}}}function rA(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 oA={[Ns.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}},aA=2;class pu{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||!Pp((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 Lp(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"?_p:ea)({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 qp=Symbol("Comlink.proxy"),cA=Symbol("Comlink.endpoint"),lA=Symbol("Comlink.releaseProxy"),mu=Symbol("Comlink.finalizer"),aa=Symbol("Comlink.thrown"),Jp=e=>typeof e=="object"&&e!==null||typeof e=="function",uA={canHandle:e=>Jp(e)&&e[qp],serialize(e){const{port1:t,port2:n}=new MessageChannel;return yu(e,t),[n,[n]]},deserialize(e){return e.start(),em(e)}},dA={canHandle:e=>Jp(e)&&aa 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}},Kp=new Map([["proxy",uA],["throw",dA]]);function fA(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function yu(e,t=globalThis,n=["*"]){t.addEventListener("message",function i(s){if(!s||!s.data)return;if(!fA(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(xi);let l;try{const u=a.slice(0,-1).reduce((f,h)=>f[h],e),d=a.reduce((f,h)=>f[h],e);switch(o){case"GET":l=d;break;case"SET":u[a.slice(-1)[0]]=xi(s.data.value),l=!0;break;case"APPLY":l=d.apply(u,c);break;case"CONSTRUCT":{const f=new d(...c);l=rm(f)}break;case"ENDPOINT":{const{port1:f,port2:h}=new MessageChannel;yu(e,h),l=sm(f,[f])}break;case"RELEASE":l=void 0;break;default:return}}catch(u){l={value:u,[aa]:0}}Promise.resolve(l).catch(u=>({value:u,[aa]:0})).then(u=>{const[d,f]=da(u);t.postMessage(Object.assign(Object.assign({},d),{id:r}),f),o==="RELEASE"&&(t.removeEventListener("message",i),Qp(t),mu in e&&typeof e[mu]=="function"&&e[mu]())}).catch(u=>{const[d,f]=da({value:new TypeError("Unserializable return value"),[aa]:0});t.postMessage(Object.assign(Object.assign({},d),{id:r}),f)})}),t.start&&t.start()}function hA(e){return e.constructor.name==="MessagePort"}function Qp(e){hA(e)&&e.close()}function em(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)}}),gu(e,n,[],t)}function ca(e){if(e)throw new Error("Proxy has been released and is not useable")}function tm(e){return as(e,new Map,{type:"RELEASE"}).then(()=>{Qp(e)})}const la=new WeakMap,ua="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(la.get(e)||0)-1;la.set(e,t),t===0&&tm(e)});function pA(e,t){const n=(la.get(t)||0)+1;la.set(t,n),ua&&ua.register(e,t,e)}function mA(e){ua&&ua.unregister(e)}function gu(e,t,n=[],i=function(){}){let s=!1;const r=new Proxy(i,{get(o,a){if(ca(s),a===lA)return()=>{mA(r),tm(e),t.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>r};const c=as(e,t,{type:"GET",path:n.map(l=>l.toString())}).then(xi);return c.then.bind(c)}return gu(e,t,[...n,a])},set(o,a,c){ca(s);const[l,u]=da(c);return as(e,t,{type:"SET",path:[...n,a].map(d=>d.toString()),value:l},u).then(xi)},apply(o,a,c){ca(s);const l=n[n.length-1];if(l===cA)return as(e,t,{type:"ENDPOINT"}).then(xi);if(l==="bind")return gu(e,t,n.slice(0,-1));const[u,d]=nm(c);return as(e,t,{type:"APPLY",path:n.map(f=>f.toString()),argumentList:u},d).then(xi)},construct(o,a){ca(s);const[c,l]=nm(a);return as(e,t,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:c},l).then(xi)}});return pA(r,e),r}function yA(e){return Array.prototype.concat.apply([],e)}function nm(e){const t=e.map(da);return[t.map(n=>n[0]),yA(t.map(n=>n[1]))]}const im=new WeakMap;function sm(e,t){return im.set(e,t),e}function rm(e){return Object.assign(e,{[qp]:!0})}function da(e){for(const[t,n]of Kp)if(n.canHandle(e)){const[i,s]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},s]}return[{type:"RAW",value:e},im.get(e)||[]]}function xi(e){switch(e.type){case"HANDLER":return Kp.get(e.name).deserialize(e.value);case"RAW":return e.value}}function as(e,t,n,i){return new Promise(s=>{const r=gA();t.set(r,s),e.start&&e.start(),e.postMessage(Object.assign({id:r},n),i)})}function gA(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var Qn=(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))(Qn||{}),fr=(e=>(e[e.FunctionUse=0]="FunctionUse",e[e.FunctionResult=1]="FunctionResult",e))(fr||{});class wA extends cc{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:Qn.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:Qn.Main,msg:t};n.postMessage(s)})}routeMessage(t){const{from:n,to:i,transferable:s,msg:{type:r}}=t;if(i===Qn.Main)this.emit("message",t);else if(i===Qn.All)n!==Qn.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 vA extends cc{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:Qn.All,msg:t};this.worker.postMessage(n)}}class bA{constructor(t){this.onMessage=n=>{const{from:i,msg:s}=n;switch(s.type){case fr.FunctionUse:this.onFunctionUse(s,i);break;case fr.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:fr.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)&&om(a[0]))for(let c=0;c<a.length;c++)Promise.resolve(a[c]).then(l=>{this.sendFunctionResult(n,r,l,c)});else a&&om(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:fr.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 om(e){return typeof e=="object"&&typeof e.then=="function"}class IA{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(...d){this.id=r.idCounter++,r.fnRegistry.get(a,"createClass")({id:this.id,args:d,name:t})}}return Object.getOwnPropertyNames(n.prototype).forEach(u=>{u!=="constructor"&&typeof n.prototype[u]=="function"&&(c.prototype[u]=function(...d){const f=s&&s.includes(u)&&Array.isArray(d[0])?[...Array(d[0].length).keys()].map(h=>h):void 0;return r.fnRegistry.get(a,"classMethodUse",f)({id:this.id,name:t,method:u,args:d})})}),c}}}}const MA={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 TA(e,t){return!!MA[e][t]}function SA(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 wu(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 EA(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 am(e,t){const n=wu([e[0][0],e[1][0]],t),i=wu([e[0][1],e[1][1]],t),s=wu([e[0][2],e[1][2]],t);n.forEach(r=>i.forEach(o=>s.forEach(a=>{EA(e,r,o,a)})))}function cm(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 Gd(["id","db_label","db_label2","selected","hovered","componentDistanceStart","componentDistanceEnd","objectLength","beginningIsCut","endingIsCut","db_geometry_type","db_plan_id"],n)}function vu(e,t,n,i,s=2){const r=s+2;let o=i;const a=n-t>>1;let c=n-t,l;const u=e[t],d=e[t+1],f=e[n],h=e[n+1];for(let g=t+r;g<n;g+=r){const w=AA(e[g],e[g+1],u,d,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&&vu(e,t,l,i,s),e[l+2]=o,n-l>r&&vu(e,l,n,i,s))}function AA(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 hr(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")fa(o,n,r);else if(t==="Polygon")fa(o,n[0],r);else if(t==="MultiLineString")for(const a of n)fa(o,a,r);else if(t==="MultiPolygon")for(const a of n)fa(o,a[0],r);return o}function fa(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 xA(e,t){const n=[];if(e.type==="FeatureCollection")for(let i=0;i<e.features.length;i++)ha(n,e.features[i],t,i);else e.type==="Feature"?ha(n,e,t,0):ha(n,{geometry:e},t,0);return n}function ha(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")lm(s,a,n.dimensions);else if(r==="MultiPoint")for(const l of s)lm(l,a,n.dimensions);else if(r==="LineString")bu(s,a,o,!1,n.dimensions);else if(r==="MultiLineString")if(n.lineMetrics){for(const l of s)a=[],bu(l,a,o,!1,n.dimensions),e.push(hr(c,"LineString",a,t.properties,i,n.dimensions+2));return}else Iu(s,a,o,!1,n.dimensions);else if(r==="Polygon")Iu(s,a,o,!0,n.dimensions);else if(r==="MultiPolygon")for(const l of s){const u=[];Iu(l,u,o,!0,n.dimensions),a.push(u)}else if(r==="GeometryCollection"){for(const l of t.geometry.geometries)ha(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(hr(c,r,a,t.properties,i,n.dimensions+2))}function lm(e,t,n=2){t.push(um(e[0]),dm(e[1]),0,1);for(let i=2;i<n;i++)t.push(e[i])}function bu(e,t,n,i,s=2){let r,o,a=0;for(let l=0;l<e.length;l++){const u=um(e[l][0]),d=dm(e[l][1]);t.push(u,d,0,1);for(let f=2;f<s;f++)t.push(e[l][f]);l>0&&(i?a+=(r*d-u*o)/2:a+=Math.sqrt(Math.pow(u-r,2)+Math.pow(d-o,2))),r=u,o=d}const c=t.length-(s+2);t[2]=1,vu(t,0,c,n,s),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function Iu(e,t,n,i,s=2){for(let r=0;r<e.length;r++){const o=[];bu(e[r],o,n,i,s),t.push(o)}}function um(e){return e/360+.5}function dm(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 _n(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 u of e){const d=u.geometry;let f=u.type;const h=s===0?u.minX:u.minY,g=s===0?u.maxX:u.maxY;if(h>=n&&g<i){l.push(u);continue}else if(g<n||h>=i)continue;let w=[];if(f==="Point"||f==="MultiPoint")_A(d,w,n,i,s,c);else if(f==="LineString")fm(d,w,n,i,s,!1,a.lineMetrics,c);else if(f==="MultiLineString")Mu(d,w,n,i,s,!1,c);else if(f==="Polygon")Mu(d,w,n,i,s,!0,c);else if(f==="MultiPolygon")for(const p of d){const y=[];Mu(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(hr(u.id,f,p,u.tags,u.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(hr(u.id,f,w,u.tags,u.index,c))}}return l.length?l:null}function _A(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){cs(t,e[o],e[o+1],e[o+2]);for(let c=3;c<r;c++)t.push(e[o+c])}}}function fm(e,t,n,i,s,r,o,a=4){let c=hm(e);const l=s===0?PA:LA;let u=e.start,d,f;for(let b=0;b<e.length-a;b+=a){const v=e[b],M=e[b+1],E=e[b+2],A=e[b+a],D=e[b+a+1],_=s===0?v:M,O=s===0?A:D;let U=!1;if(o&&(d=Math.sqrt(Math.pow(v-A,2)+Math.pow(M-D,2))),_<n){if(O>n){f=l(c,v,M,A,D,n),c.push(0);for(let B=4;B<a;B++){const $=e[b+B];c.push((e[b+a+B]-$)*f+$)}o&&(c.start=u+d*f)}}else if(_>i){if(O<i){f=l(c,v,M,A,D,i),c.push(0);for(let B=4;B<a;B++){const $=e[b+B];c.push((e[b+a+B]-$)*f+$)}o&&(c.start=u+d*f)}}else{cs(c,v,M,E);for(let B=3;B<a;B++)c.push(e[b+B])}if(O<n&&_>=n){f=l(c,v,M,A,D,n),c.push(0);for(let B=4;B<a;B++){const $=e[b+B];c.push((e[b+a+B]-$)*f+$)}U=!0}if(O>i&&_<=i){f=l(c,v,M,A,D,i),c.push(0);for(let B=4;B<a;B++){const $=e[b+B];c.push((e[b+a+B]-$)*f+$)}U=!0}!r&&U&&(o&&(c.end=u+d*f),t.push(c),c=hm(e)),o&&(u+=d)}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){cs(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])){cs(c,c[0],c[1],c[2]);for(let b=3;b<a;b++)c.push(c[b])}c.length&&t.push(c)}function hm(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Mu(e,t,n,i,s,r,o){for(const a of e)fm(a,t,n,i,s,r,!1,o)}function cs(e,t,n,i){e.push(t,n,i)}function PA(e,t,n,i,s,r){const o=(r-t)/(i-t);return cs(e,r,n+(s-n)*o,1),o}function LA(e,t,n,i,s,r){const o=(r-n)/(s-n);return cs(e,t+(i-t)*o,r,1),o}function DA(e,t){const n=t.buffer/t.extent,i=t.dimensions+2;let s=e;const r=_n(e,1,-1-n,n,0,-1,2,t),o=_n(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(s=_n(e,1,-n,1+n,0,-1,2,t)||[],r&&(s=pm(r,1,i).concat(s)),o&&(s=s.concat(pm(o,-1,i)))),s}function pm(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=Tu(r.geometry,t,n);else if(o==="MultiLineString"||o==="Polygon"){a=[];for(const c of r.geometry)a.push(Tu(c,t,n))}else if(o==="MultiPolygon"){a=[];for(const c of r.geometry){const l=[];for(const u of c)l.push(Tu(u,t,n));a.push(l)}}i.push(hr(r.id,o,a,r.tags,r.index,n))}return i}function Tu(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 mm(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,u=n.dimensions+l;if(c===1)for(let d=0;d<a.length;d+=u)o.geometry.push(gm(a,d,u,t,i,s,r));else if(c===2)o.geometry=ym(a,t,i,s,r,u);else for(let d=0;d<a.length;d++)o.geometry.push(ym(a[d],t,i,s,r,u))}return e.transformed=!0,e}function ym(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(gm(e[a],l,r,t,n,i,s));o.push(c)}return o}function gm(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 OA(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)CA(o,a,r,s);return o}function CA(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")Su(a,s,e,n,!1,!1,i);else if(r==="MultiLineString"||r==="Polygon"){for(let c=0;c<s.length;c++)Su(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],u=[];for(let d=0;d<l.length;d++)Su(u,l[d],e,n,!0,d===0,i);u.length&&a.push(u)}if(a.length){let c=t.tags||null;if(r==="LineString"&&i.lineMetrics){c={};for(const u in t.tags)c[u]=t.tags[u];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 Su(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 u=[];for(let d=0;d<t.length;d+=l){if(i===0||t[d+2]>a){n.numSimplified++,u.push(t[d],t[d+1]);for(let f=4;f<l;f++)u.push(t[d+f]);c&&u.push(t[d+3])}n.numPoints++}s&&FA(u,r,l-(c?1:2)),e.push(u)}function FA(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 RA={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 NA{constructor(t,n){n=this.options=kA(Object.create(RA),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=xA(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=DA(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,u=l.debug;for(;c.length;){s=c.pop(),i=c.pop(),n=c.pop(),t=c.pop();const d=1<<n,f=Eu(n,i,s);let h=this.tiles[f];if(!h&&(u>1&&console.time("creation"),h=this.tiles[f]=OA(t,n,i,s,l),this.tileCoords.push({z:n,x:i,y:s}),u)){u>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 _=`z${n}`;this.stats[_]=(this.stats[_]||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 _=r-n;if(i!==o>>_||s!==a>>_)continue}}if(h.source=null,t.length===0)continue;u>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,M=null,E=null,A=_n(t,d,i-g,i+p,0,h.minX,h.maxX,l),D=_n(t,d,i+w,i+y,0,h.minX,h.maxX,l);t=null,A&&(b=_n(A,d,s-g,s+p,1,h.minY,h.maxY,l),v=_n(A,d,s+w,s+y,1,h.minY,h.maxY,l),A=null),D&&(M=_n(D,d,s-g,s+p,1,h.minY,h.maxY,l),E=_n(D,d,s+w,s+y,1,h.minY,h.maxY,l),D=null),u>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(M||[],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=Eu(t,n,i);if(this.tiles[c])return mm(this.tiles[c],r,s);o>1&&console.log("drilling down to z%d-%d-%d",t,n,i);let l=t,u=n,d=i,f;for(;!f&&l>0;)l--,u=u>>1,d=d>>1,f=this.tiles[Eu(l,u,d)];return!f||!f.source?null:(o>1&&(console.log("found parent tile z%d-%d-%d",l,u,d),console.time("drilling down")),this.splitTile(f.source,l,u,d,t,n,i),o>1&&console.timeEnd("drilling down"),this.tiles[c]?mm(this.tiles[c],r,s):null)}}function Eu(e,t,n){return((1<<e)*n+t)*32+e}function kA(e,t){for(const n in t)e[n]=t[n];return e}function BA(e,t){return new NA(e,t)}var pa={exports:{}},wm;function UA(){if(wm)return pa.exports;wm=1,pa.exports=e,pa.exports.default=e;function e(S,P,x){x=x||2;var F=P&&P.length,C=F?P[0]*x:S.length,k=t(S,0,C,x,!0),R=[];if(!k||k.next===k.prev)return R;var G,X,H,Q,J,N,Z;if(F&&(k=c(S,P,k,x)),S.length>80*x){G=H=S[0],X=Q=S[1];for(var q=x;q<C;q+=x)J=S[q],N=S[q+1],J<G&&(G=J),N<X&&(X=N),J>H&&(H=J),N>Q&&(Q=N);Z=Math.max(H-G,Q-X),Z=Z!==0?32767/Z:0}return i(k,R,x,G,X,Z,0),R}function t(S,P,x,F,C){var k,R;if(C===I(S,P,x,F)>0)for(k=P;k<x;k+=F)R=$(k,S[k],S[k+1],R);else for(k=x-F;k>=P;k-=F)R=$(k,S[k],S[k+1],R);return R&&M(R,R.next)&&(V(R),R=R.next),R}function n(S,P){if(!S)return S;P||(P=S);var x=S,F;do if(F=!1,!x.steiner&&(M(x,x.next)||v(x.prev,x,x.next)===0)){if(V(x),x=P=x.prev,x===x.next)break;F=!0}else x=x.next;while(F||x!==P);return P}function i(S,P,x,F,C,k,R){if(S){!R&&k&&h(S,F,C,k);for(var G=S,X,H;S.prev!==S.next;){if(X=S.prev,H=S.next,k?r(S,F,C,k):s(S)){P.push(X.i/x|0),P.push(S.i/x|0),P.push(H.i/x|0),V(S),S=H.next,G=H.next;continue}if(S=H,S===G){R?R===1?(S=o(n(S),P,x),i(S,P,x,F,C,k,2)):R===2&&a(S,P,x,F,C,k):i(n(S),P,x,F,C,k,1);break}}}}function s(S){var P=S.prev,x=S,F=S.next;if(v(P,x,F)>=0)return!1;for(var C=P.x,k=x.x,R=F.x,G=P.y,X=x.y,H=F.y,Q=C<k?C<R?C:R:k<R?k:R,J=G<X?G<H?G:H:X<H?X:H,N=C>k?C>R?C:R:k>R?k:R,Z=G>X?G>H?G:H:X>H?X:H,q=F.next;q!==P;){if(q.x>=Q&&q.x<=N&&q.y>=J&&q.y<=Z&&y(C,G,k,X,R,H,q.x,q.y)&&v(q.prev,q,q.next)>=0)return!1;q=q.next}return!0}function r(S,P,x,F){var C=S.prev,k=S,R=S.next;if(v(C,k,R)>=0)return!1;for(var G=C.x,X=k.x,H=R.x,Q=C.y,J=k.y,N=R.y,Z=G<X?G<H?G:H:X<H?X:H,q=Q<J?Q<N?Q:N:J<N?J:N,pe=G>X?G>H?G:H:X>H?X:H,me=Q>J?Q>N?Q:N:J>N?J:N,ye=w(Z,q,P,x,F),se=w(pe,me,P,x,F),W=S.prevZ,Y=S.nextZ;W&&W.z>=ye&&Y&&Y.z<=se;){if(W.x>=Z&&W.x<=pe&&W.y>=q&&W.y<=me&&W!==C&&W!==R&&y(G,Q,X,J,H,N,W.x,W.y)&&v(W.prev,W,W.next)>=0||(W=W.prevZ,Y.x>=Z&&Y.x<=pe&&Y.y>=q&&Y.y<=me&&Y!==C&&Y!==R&&y(G,Q,X,J,H,N,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0))return!1;Y=Y.nextZ}for(;W&&W.z>=ye;){if(W.x>=Z&&W.x<=pe&&W.y>=q&&W.y<=me&&W!==C&&W!==R&&y(G,Q,X,J,H,N,W.x,W.y)&&v(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;Y&&Y.z<=se;){if(Y.x>=Z&&Y.x<=pe&&Y.y>=q&&Y.y<=me&&Y!==C&&Y!==R&&y(G,Q,X,J,H,N,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0)return!1;Y=Y.nextZ}return!0}function o(S,P,x){var F=S;do{var C=F.prev,k=F.next.next;!M(C,k)&&E(C,F,F.next,k)&&O(C,k)&&O(k,C)&&(P.push(C.i/x|0),P.push(F.i/x|0),P.push(k.i/x|0),V(F),V(F.next),F=S=k),F=F.next}while(F!==S);return n(F)}function a(S,P,x,F,C,k){var R=S;do{for(var G=R.next.next;G!==R.prev;){if(R.i!==G.i&&b(R,G)){var X=B(R,G);R=n(R,R.next),X=n(X,X.next),i(R,P,x,F,C,k,0),i(X,P,x,F,C,k,0);return}G=G.next}R=R.next}while(R!==S)}function c(S,P,x,F){var C=[],k,R,G,X,H;for(k=0,R=P.length;k<R;k++)G=P[k]*F,X=k<R-1?P[k+1]*F:S.length,H=t(S,G,X,F,!1),H===H.next&&(H.steiner=!0),C.push(p(H));for(C.sort(l),k=0;k<C.length;k++)x=u(C[k],x);return x}function l(S,P){return S.x-P.x}function u(S,P){var x=d(S,P);if(!x)return P;var F=B(x,S);return n(F,F.next),n(x,x.next)}function d(S,P){var x=P,F=S.x,C=S.y,k=-1/0,R;do{if(C<=x.y&&C>=x.next.y&&x.next.y!==x.y){var G=x.x+(C-x.y)*(x.next.x-x.x)/(x.next.y-x.y);if(G<=F&&G>k&&(k=G,R=x.x<x.next.x?x:x.next,G===F))return R}x=x.next}while(x!==P);if(!R)return null;var X=R,H=R.x,Q=R.y,J=1/0,N;x=R;do F>=x.x&&x.x>=H&&F!==x.x&&y(C<Q?F:k,C,H,Q,C<Q?k:F,C,x.x,x.y)&&(N=Math.abs(C-x.y)/(F-x.x),O(x,S)&&(N<J||N===J&&(x.x>R.x||x.x===R.x&&f(R,x)))&&(R=x,J=N)),x=x.next;while(x!==X);return R}function f(S,P){return v(S.prev,S,P.prev)<0&&v(P.next,S,S.next)<0}function h(S,P,x,F){var C=S;do C.z===0&&(C.z=w(C.x,C.y,P,x,F)),C.prevZ=C.prev,C.nextZ=C.next,C=C.next;while(C!==S);C.prevZ.nextZ=null,C.prevZ=null,g(C)}function g(S){var P,x,F,C,k,R,G,X,H=1;do{for(x=S,S=null,k=null,R=0;x;){for(R++,F=x,G=0,P=0;P<H&&(G++,F=F.nextZ,!!F);P++);for(X=H;G>0||X>0&&F;)G!==0&&(X===0||!F||x.z<=F.z)?(C=x,x=x.nextZ,G--):(C=F,F=F.nextZ,X--),k?k.nextZ=C:S=C,C.prevZ=k,k=C;x=F}k.nextZ=null,H*=2}while(R>1);return S}function w(S,P,x,F,C){return S=(S-x)*C|0,P=(P-F)*C|0,S=(S|S<<8)&16711935,S=(S|S<<4)&252645135,S=(S|S<<2)&858993459,S=(S|S<<1)&1431655765,P=(P|P<<8)&16711935,P=(P|P<<4)&252645135,P=(P|P<<2)&858993459,P=(P|P<<1)&1431655765,S|P<<1}function p(S){var P=S,x=S;do(P.x<x.x||P.x===x.x&&P.y<x.y)&&(x=P),P=P.next;while(P!==S);return x}function y(S,P,x,F,C,k,R,G){return(C-R)*(P-G)>=(S-R)*(k-G)&&(S-R)*(F-G)>=(x-R)*(P-G)&&(x-R)*(k-G)>=(C-R)*(F-G)}function b(S,P){return S.next.i!==P.i&&S.prev.i!==P.i&&!_(S,P)&&(O(S,P)&&O(P,S)&&U(S,P)&&(v(S.prev,S,P.prev)||v(S,P.prev,P))||M(S,P)&&v(S.prev,S,S.next)>0&&v(P.prev,P,P.next)>0)}function v(S,P,x){return(P.y-S.y)*(x.x-P.x)-(P.x-S.x)*(x.y-P.y)}function M(S,P){return S.x===P.x&&S.y===P.y}function E(S,P,x,F){var C=D(v(S,P,x)),k=D(v(S,P,F)),R=D(v(x,F,S)),G=D(v(x,F,P));return!!(C!==k&&R!==G||C===0&&A(S,x,P)||k===0&&A(S,F,P)||R===0&&A(x,S,F)||G===0&&A(x,P,F))}function A(S,P,x){return P.x<=Math.max(S.x,x.x)&&P.x>=Math.min(S.x,x.x)&&P.y<=Math.max(S.y,x.y)&&P.y>=Math.min(S.y,x.y)}function D(S){return S>0?1:S<0?-1:0}function _(S,P){var x=S;do{if(x.i!==S.i&&x.next.i!==S.i&&x.i!==P.i&&x.next.i!==P.i&&E(x,x.next,S,P))return!0;x=x.next}while(x!==S);return!1}function O(S,P){return v(S.prev,S,S.next)<0?v(S,P,S.next)>=0&&v(S,S.prev,P)>=0:v(S,P,S.prev)<0||v(S,S.next,P)<0}function U(S,P){var x=S,F=!1,C=(S.x+P.x)/2,k=(S.y+P.y)/2;do x.y>k!=x.next.y>k&&x.next.y!==x.y&&C<(x.next.x-x.x)*(k-x.y)/(x.next.y-x.y)+x.x&&(F=!F),x=x.next;while(x!==S);return F}function B(S,P){var x=new T(S.i,S.x,S.y),F=new T(P.i,P.x,P.y),C=S.next,k=P.prev;return S.next=P,P.prev=S,x.next=C,C.prev=x,F.next=x,x.prev=F,k.next=F,F.prev=k,F}function $(S,P,x,F){var C=new T(S,P,x);return F?(C.next=F.next,C.prev=F,F.next.prev=C,F.next=C):(C.prev=C,C.next=C),C}function V(S){S.next.prev=S.prev,S.prev.next=S.next,S.prevZ&&(S.prevZ.nextZ=S.nextZ),S.nextZ&&(S.nextZ.prevZ=S.prevZ)}function T(S,P,x){this.i=S,this.x=P,this.y=x,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}e.deviation=function(S,P,x,F){var C=P&&P.length,k=C?P[0]*x:S.length,R=Math.abs(I(S,0,k,x));if(C)for(var G=0,X=P.length;G<X;G++){var H=P[G]*x,Q=G<X-1?P[G+1]*x:S.length;R-=Math.abs(I(S,H,Q,x))}var J=0;for(G=0;G<F.length;G+=3){var N=F[G]*x,Z=F[G+1]*x,q=F[G+2]*x;J+=Math.abs((S[N]-S[q])*(S[Z+1]-S[N+1])-(S[N]-S[Z])*(S[q+1]-S[N+1]))}return R===0&&J===0?0:Math.abs((J-R)/R)};function I(S,P,x,F){for(var C=0,k=P,R=x-F;k<x;k+=F)C+=(S[R]-S[k])*(S[k+1]+S[R+1]),R=k;return C}return e.flatten=function(S){for(var P=S[0][0].length,x={vertices:[],holes:[],dimensions:P},F=0,C=0;C<S.length;C++){for(var k=0;k<S[C].length;k++)for(var R=0;R<P;R++)x.vertices.push(S[C][k][R]);C>0&&(F+=S[C-1].length,x.holes.push(F))}return x},pa.exports}var zA=UA();const Au=Rc(zA);function GA(e){const t=ct(e),n=oe.scaleFactor(_s(0,0,t)[1]),i=oe.scaleFactor(_s(0,te,t)[1]);return{min:n,max:i,range:i-n}}function jA(e,t,n,i){const s=[];return e.geometry.forEach(r=>{const o=[],a=[],c=[];r.forEach(f=>{c.push(...WA(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 u=Au(l,a,n),d=new Array(n);for(let f=0;f<u.length;f+=3){const h=[];for(let g=0;g<n+1;g++)h.push([]);for(let g=0;g<3;g++)xu(d,o[u[f+2-g]],t,i),h[0][g]=d[0],h[1][g]=d[1],h[2][g]=0,n>2&&(h[3][g]=d[2]),n>3&&(h[4][g]=d[3]);c.forEach(g=>{const w=[[],[],[]];g.forEach((p,y)=>{w[0][y]=p[0],w[1][y]=p[1]}),am(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 VA(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)=>{xu(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 HA(e,t,n,i){const s=Array(n);return e.geometry.map(r=>{var a;xu(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 xu(e,t,n,i){const s=vm(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 vm(e,t){return[Te(e[0]/t*te,0,te),Te((t-e[1])/t*te,0,te)]}function $A(e,t){return e[0]<0||e[0]>t||e[1]<0||e[1]>t}function YA(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 WA(e,t){const n=[];let i=[];for(let s=0;s<e.length;s++){const r=e[s];if(i.push(vm(r,t)),!$A(r,t))continue;const o=e[s+1];if(!o)break;YA(r,o,t)&&(i.length>1&&n.push(i),i=[])}return i.length>1&&n.push(i),n}const bm=4096,Im=2,ls={maxZoom:Ep,tolerance:3,extent:bm,buffer:1,debug:0,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!0,indexMaxZoom:0,indexMaxPoints:1e5,dimensions:Im};class _u{constructor(t){this.options=t}get geoJsonVtInstance(){var t,n,i,s,r;return this.geoJsonVT||(this.geoJsonVT=BA(this.options.data,ve(de({},ls),{maxZoom:(t=this.options.maxZoom)!=null?t:ls.maxZoom,dimensions:(n=this.options.dimensions)!=null?n:ls.dimensions,extent:(i=this.options.extent)!=null?i:ls.extent,buffer:(s=this.options.buffer)!=null?s:ls.buffer,promoteId:this.options.promoteId,tolerance:(r=this.options.tolerance)!=null?r:ls.tolerance}))),this.geoJsonVT}fetchTile(t){var u,d;const[n,i,s]=Vr(t),r={components:[],byId:new Map},o=this.geoJsonVtInstance.getTile(s,n,i),a=(u=this.options.dimensions)!=null?u:Im,c=(d=this.options.extent)!=null?d:bm,l=GA(t);if(!o)return Promise.resolve(r);for(const f of o.features)switch(f.type){case 1:r.components=r.components.concat(HA(f,c,a,l));break;case 2:r.components=r.components.concat(VA(f,c,a,l));break;case 3:r.components=r.components.concat(jA(f,c,a,l));break;default:console.warn("unsupported type ",o);break}return Promise.resolve(r)}destroy(){this.geoJsonVT=void 0}}function ZA(e,t,n){const i={components:[],byId:new Map};return e.features.forEach((s,r)=>{i.components.push(...Mm(s.geometry,t).map(o=>ve(de({},o),{index:r,id:s.id,tags:s.properties||{}})))}),i}function Mm(e,t,n){switch(e.type){case"GeometryCollection":{let i=[];return e.geometries.forEach(s=>{i=i.concat(Mm(s,t))}),i}case"Point":case"MultiPoint":return XA(e,t);case"LineString":case"MultiLineString":return qA(e,t);case"Polygon":case"MultiPolygon":return JA(e,t)}}function XA(e,t){return e.type==="Point"?[Tm(e.coordinates,t)]:e.coordinates.map(n=>Tm(n,t))}function qA(e,t){return e.type==="LineString"?[Sm(e.coordinates,t)]:e.coordinates.map(n=>Sm(n,t))}function JA(e,t,n){return e.type==="Polygon"?Em(e.coordinates,t):e.coordinates.reduce((i,s)=>i.concat(Em(s,t)),[])}function Tm(e,t){const n=[0,0,0];return Lt(n,oe.fromGeo(e),t),{type:"point",vertices:{x:[n[0]],y:[n[1]]}}}function Sm(e,t){const n=[[],[]],i=[0,0,0];return e.forEach((s,r)=>{Lt(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 Em(e,t,n){const i=[],s=[],r=[],o=[],a=[];e.forEach(u=>{const d=u.map(f=>(Lt(a,oe.fromGeo(f),t),[Te(a[0],0,te),Te(a[1],0,te)]));o.push(d),s.length&&r.push(s.length),s.push(...d)});const c=[];for(let u=0;u<s.length;u++)c.push(s[u][0]),c.push(s[u][1]);const l=Au(c,r);for(let u=0;u<l.length;u+=3){const d=[[],[],[],[]];for(let h=0;h<3;h++)d[0][h]=s[l[u+h]][0],d[1][h]=s[l[u+h]][1],d[2][h]=0,d[3][h]=s[l[u+h]][2];o.forEach(h=>{const g=[[],[],[]];h.forEach((w,p)=>{g[0][p]=w[0],g[1][p]=w[1]}),am(d,g)});const f={type:"polygon",vertices:{x:d[0],y:d[1],cut:d[2]}};i.push(f)}return i}class ma{constructor(t){this.tileLoader=new pu("json",t.ignoreMissingTiles),this.options=t,this.url=n=>{const i=this.options.flipY?n:Vr(n);return Es(this.options.url,{x:i[0].toString(),y:i[1].toString(),z:i[2].toString(),subdomain:qd(i)})}}fetchTile(t){return this.tileLoader.fetch(t,this.url).then(n=>n.data?ZA(n.data,ct(t)):{components:[],byId:new Map})}abortTile(t){this.tileLoader.abortRequests([xe(t)])}destroy(){this.tileLoader.destroy()}}const Am=4;class KA{constructor(t,n,i,s){this.scope=t,this.options=n,this.id=i,this.featureStateMap=new eu,t.sources[i]=this,this.tileData={},this.styleManager=t.styleManager,this.collector=t.collector,this.sourceAttrs=this.options.attributes||{},this.metatile=cm(s),this.tileServer="url"in n?new ma(n):new _u(n)}fetchTiles(t){const n=[];for(const i of t)n.push(this.fetchTile(i));return n}abortTileFetches(t){if(this.tileServer instanceof ma)for(const n of t)this.tileServer.abortTile(n)}generateTile(t,n,i,s,r,o,a,c){const l=xe(n),u=this.tileData[l],d=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});u&&u.components.forEach((A,D)=>{const{tileProps:_}=this.metatile,O=[],U=[];if(A.tags){const C=Object.keys(A.tags);As(this.metatile,C);for(const k of C)O[_[k]]=A.tags[k]}const B=Object.keys(this.sourceAttrs);As(this.metatile,B);const $=Array.from(this.featureStateMap.featureAttrs);As(this.metatile,$);for(const C of B)O[_[C]]=this.sourceAttrs[C];const V=O[_.db_hidden_by_plan_id];if(V&&t._activeFloorIds.includes(V))return;const T=b?String(A.index+this.id*re(2,32)):p?O[_[p]]:void 0;if(T!==void 0){const C=w.has(T);if(O[_.selected]=C?1:0,u.byId.set(T,D),y[T]=A.index,this.featureStateMap.featureAttrs.size>0){const k=T!==void 0&&this.featureStateMap.get(T);if(k)for(const R of this.featureStateMap.featureAttrs)this.featureStateMap.clearAttrs=!1,U[_[R]]=k[R];else if(this.featureStateMap.clearAttrs===!1){this.featureStateMap.clearAttrs=!0;for(const R in _)U[_[R]]!==void 0&&(U[_[R]]=void 0)}}}const{coords:I}=d,S=I[3],P=Cc(r),x=ks(t,this.sourceAttrs,_,O,U,T,d),F=this.styleManager.getLayers(g.id,_,O).filter(C=>TA(A.type,C.type)&&j(C.filter,x)&&(a?j(a,x):!0));if(F.length===0&&x.id&&this.collector.idIndexer.addOrphanId(x.id),O[_.db_geometry_type]=A.type==="line"?"polyline":A.type,(A.type==="point"||A.type==="line")&&(O[_.db_label]===void 0&&(O[_.db_label]=NaN),O[_.db_label2]===void 0&&(O[_.db_label2]=NaN)),A.type==="line"){const C=SA(A);O[_.componentDistanceStart]=0,O[_.componentDistanceEnd]=C,O[_.objectLength]=C,typeof O[_.beginningIsCut]!="number"&&(O[_.beginningIsCut]=0),typeof O[_.endingIsCut]!="number"&&(O[_.endingIsCut]=0)}Cl(this.collector,g,F,x,this.metatile,Am,S,this.id,d,P,A.vertices,void 0,o,c)});const v=this.collector.getAccumulatedData(),M={regionId:0,metatileHash:Bu,collectorOutput:v,styleId:g.id};Object.keys(y).length>0&&(M.idToIndex=y),f.push(M),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=Yp(t)}setData(t){if(typeof t=="string"){if(this.tileServer instanceof ma)return this.tileServer.destroy(),this.options=ve(de({},this.options),{url:t}),this.tileServer=new ma(this.options),this.tileData={},Promise.resolve(!0)}else if(this.tileServer instanceof _u)return this.tileServer.destroy(),this.options=ve(de({},this.options),{data:t}),this.tileServer=new _u(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 QA(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:tx(e.accessors),buffers:ix(e.buffers),bufferViews:sx(e.bufferViews),cameras:rx(e.cameras),scene:(s=e.scene)!=null?s:0,scenes:cx(e.scenes),nodes:lx(e.nodes),materials:ax(e.materials),meshes:ox(e.meshes),asset:ex(e.asset),animations:nx(e.animations),images:ux(e.images),textures:dx(e.textures),samplers:fx(e.samplers),skins:hx(e.skins)}}function ex(e){return{copyright:e.copyright,generator:e.generator,version:e.version,minVersion:e.minVersion}}function tx(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 nx(e=[]){return e.map(t=>({channels:t.channels,samplers:t.samplers,name:t.name,extensions:t.extensions,extras:t.extras}))}function ix(e=[]){return e.map(t=>({uri:t.uri,byteLength:t.byteLength,name:t.name,extensions:t.extensions,extras:t.extras,buffer:void 0}))}function sx(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 rx(e=[]){return e.map(t=>({type:t.type,orthographic:t.orthographic,perspective:t.perspective,name:t.name,extensions:t.extensions,extras:t.extras}))}function ox(e=[]){return e.map(t=>({primitives:t.primitives,name:t.name,weights:t.weights,extensions:t.extensions,extras:t.extras}))}function ax(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 cx(e=[]){return e.map(t=>({nodes:t.nodes,extensions:t.extensions,extras:t.extras,name:t.name}))}function lx(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?g1(...t.matrix):void 0,rotation:X1(...n),scale:at(...i),translation:at(...s),name:t.name,mesh:t.mesh,skin:t.skin,extras:t.extras,extensions:t.extensions}})}function ux(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 dx(e=[]){return e.map(t=>({extensions:t.extensions,extras:t.extras,name:t.name,sampler:t.sampler,source:t.source}))}function fx(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 hx(e=[]){return e.map(t=>({joints:t.joints,extensions:t.extensions,extras:t.extras,inverseBindMatrices:t.inverseBindMatrices,name:t.name,skeleton:t.skeleton}))}const pr={JPEG:"image/jpeg",PNG:"image/png",GLTEXTURE:"image/texture"};function xm(e){return e.substring(0,e.lastIndexOf("/")+1)}function px(e){if(e.startsWith("data:image"))return e.split(";")[0].split(":")[1];switch(e.substring(e.lastIndexOf("."))){case".png":return pr.PNG;case".jpg":case".jpeg":default:return pr.JPEG}}function _m(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:Du,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||Du,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 ya=Ve;const Pm=5120,mx=5121,yx=5122,gx=5123,wx=5124,Lm=5125,vx=5126,bx=4,Ix="draco_decoder_gltf.js",Mx="draco_wasm_wrapper_gltf.js",Dm="draco_decoder_gltf.wasm";let Pu;function Tx(e){Pu=Ax(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 Sx(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 Ex(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 Ax(e){return Le(this,null,function*(){if(typeof WebAssembly!="object"){const t=yield Sx(`${e}/${Ix}`);return new Function(t)()()}else return Ex(`${e}/${Mx}`).then(t=>{const n=new Function(t)();return fetch(`${e}/${Dm}`).then(i=>i.arrayBuffer()).then(i=>n({wasmBinary:i,wasmBinaryFile:Dm}))})})}function xx(e){switch(e){case Pm:return"Int8Array";case mx:return"Uint8Array";case yx:return"Int16Array";case gx:return"Uint16Array";case wx:return"Int32Array";case Lm:return"Uint32Array";case vx:return"Float32Array";default:return"Float32Array"}}function _x(e,t,n,i,s,r){const o=s.num_components(),c=n.num_points()*o;let l,u,d;switch(r){case"Float32Array":d=c*4,l=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_FLOAT32,d,l),u=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),u=new Int8Array(e.HEAP8.buffer,l,c).slice(),e._free(l);break;case"Int16Array":d=c*2,l=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT16,d,l),u=new Int16Array(e.HEAP16.buffer,l,c).slice(),e._free(l);break;case"Int32Array":d=c*4,l=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT32,d,l),u=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),u=new Uint8Array(e.HEAPU8.buffer,l,c).slice(),e._free(l);break;case"Uint16Array":d=c*2,l=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT16,d,l),u=new Uint16Array(e.HEAPU16.buffer,l,c).slice(),e._free(l);break;case"Uint32Array":d=c*4,l=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT32,d,l),u=new Uint32Array(e.HEAPU32.buffer,l,c).slice(),e._free(l);break;default:throw new Error("DRACOLoader: Unexpected attribute type.")}return{name:i,array:u,itemSize:o,componentType:r}}function Px(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:{}},u=o.num_points();for(const d in i){let f=Pm,h;for(const[p,y]of Object.entries(r))if(p===d){f=s.accessors[y].componentType,h=s.accessors[y].count;break}if(u!==h)throw new Error(`DRACOLoader: Accessor vertex count ${h} does not match draco decoder vertex count  ${u}`);f=xx(f);const g=t.GetAttributeByUniqueId(o,i[d]),w=_x(e,t,o,d,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,u=new n.DecoderBuffer;u.Init(c,r.byteLength);const d=Px(n,l,u,e.attributes,t,i);return n.destroy(u),d}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 Pn(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=Lm),t.attributes.POSITION!==void 0){const r=Pn(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=Pn(t.attributes.NORMAL.array,t.attributes.NORMAL.componentType);on(r,e,n.NORMAL,34962,"normal buffer view")}for(let r=0;r<bx;++r){const o=`TEXCOORD_${r}`;if(t.attributes[o]!==void 0){const a=Pn(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=Pn(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=Pn(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=Pn(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=Pn(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=Pn(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=Pn(t.attributes.WEIGHTS_1.array,t.attributes.WEIGHTS_1.componentType);on(r,e,n.WEIGHTS_1,34963,"WEIGHTS_1 buffer view")}}function Ox(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;Pu||Tx(t);const r=yield Pu;if(!r)continue;const o=Lx(s.extensions.KHR_draco_mesh_compression,e,r,s.attributes);Dx(e,o,s.attributes,s.indices)}})}function Lu(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 Du={asset:{version:""}};function Cx(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=_m(n.uri);else{const i=En(n.uri)?n.uri:xm(e.path)+n.uri,s=yield Lu(i).then(r=>r.arrayBuffer());n.buffer=s}})))})}function Fx(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(Bx(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 Rx(e,t){return Le(this,null,function*(){if(t.uri===void 0)return!1;const n=t.mimeType||px(t.uri);if(t.mimeType=n,typeof createImageBitmap!="undefined"&&(n===pr.JPEG||n===pr.PNG))if(t.uri.startsWith("data:image")){const i=_m(t.uri);t.image=yield createImageBitmap(new Blob([i],{type:n}))}else{const i=En(t.uri)?t.uri:`${xm(e.path)}${t.uri}`,r=yield(yield Lu(i)).arrayBuffer();t.image=yield createImageBitmap(new Blob([r],{type:n}))}else return console.error(`Unsupported image type ${n}`),!1;return!0})}function Nx(e,t){return Le(this,null,function*(){yield Promise.all(e.images.map(n=>Le(null,null,function*(){if(n.image){n.mimeType!==pr.GLTEXTURE&&console.error("Image has already been loaded");return}(yield Fx(e,n,t))||(yield Rx(e,n))||console.error(`Was not able to resolve image with uri ${n.uri}`)})))})}function kx(e,t){return Le(this,null,function*(){const n=Cy(e,self.origin);try{const i=yield Lu(n);let s=Du,r;try{const o=yield i.arrayBuffer();if(ya.isGlb(o)){const f=new ya(o).extractGlbData();s=f.json,r=f.buffers}else{const d=new TextDecoder("utf-8"),f=new Uint8Array(o);s=JSON.parse(d.decode(f))}const a=QA(s,n),c=Cx(a,r),l=Nx(a,c),u=Ox(a,t);return yield Promise.all([c,l,u]),{type:"ok",result:a}}catch(o){return{type:"error",layer:"parsing",originalError:o}}}catch(i){return{type:"error",layer:"network",originalError:i}}})}function Bx(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 Ux{loadModel(t,n){return Le(this,null,function*(){return yield kx(t,n)})}}class zx{constructor(t,n){this.scope=t,this.options=n,this.tileLoader=new pu("arrayBuffer"),this.tiles=new Map,this.url=i=>{const[s,r,o]=Vr(i);return lh(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=A2(o);do Rt.generateMeshElevation(this.scope.collector,a,t,zs);while(this.scope.collector.isOverloaded());const c=this.scope.collector.getAccumulatedData();this.scope.resetCollector();const l=T2(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 Gx=1246122573,jx=1,Vx=3,Ou=2048*1024;var ga=(e=>(e[e.Magic=0]="Magic",e[e.Version=4]="Version",e[e.FrameMailbox=8]="FrameMailbox",e[e._Size=16]="_Size",e))(ga||{});const Hx=16+Vx*Ou;var Cu=(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))(Cu||{});function $x(e){e[0]=Gx,e[1]=jx,e[2]=0}function Om(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 Cm=(e=>(e[e.WebGPU=0]="WebGPU",e))(Cm||{}),Fu=(e=>(e[e.WebGPU=0]="WebGPU",e))(Fu||{}),wa=(e=>(e[e.Test=0]="Test",e))(wa||{}),_i=(e=>(e[e.Vertex=0]="Vertex",e[e.Fragment=1]="Fragment",e))(_i||{});function Fm(e,t,n){const i=JSON.stringify(n!=null?n:{});return`${e}:${t}:${i}`}const Yx=`/**
 * 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);
}
`,Wx=`/**
 * Test fragment shader
 * Красный цвет для проверки работы WebGPU pipeline
 */

@fragment
fn main() -> @location(0) vec4f {
    return vec4f(1.0, 0.0, 0.0, 1.0); // Red color
}
`,Rm=new WeakMap;function Nm(e){let t=Rm.get(e);return t||(t=new Map,Rm.set(e,t)),t}const Zx={[wa.Test]:{[_i.Vertex]:Yx,[_i.Fragment]:Wx}};function km(e,t,n){const i=Zx[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 Bm(e,t,n){return e.createShaderModule({label:n,code:t})}function Xx(e,t,n={}){const i=Nm(e),s=Fm(t,_i.Vertex,n);let r=i.get(s);if(!r){const o=km(t,_i.Vertex);r=Bm(e,o,`${t} vertex shader`),i.set(s,r)}return r}function qx(e,t,n={}){const i=Nm(e),s=Fm(t,_i.Fragment,n);let r=i.get(s);if(!r){const o=km(t,_i.Fragment);r=Bm(e,o,`${t} fragment shader`),i.set(s,r)}return r}class Jx{}class Kx extends Jx{constructor(){super(...arguments),this.renderFamily=Cm.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:Xx(s,wa.Test),entryPoint:"main"},fragment:{module:qx(s,wa.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 Qx{constructor(t,n,i){this.frameReadSlot=2,this.lastFrameId=0,this.renderLoop=()=>{this.frameReadSlot=Om(this.transportI32,ga.FrameMailbox,this.frameReadSlot);const s=ga._Size+this.frameReadSlot*Ou,r=this.transportU32[s+Cu.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 Fu.WebGPU:return new Kx;default:throw new Error(`Unknown backend: ${t}`)}}}function e_(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 Um(e,t,n){return Le(this,null,function*(){const i=yield e_(t);return new Qx(e,i,n)})}function t_(e,t,n){return Le(this,null,function*(){const i=yield Um(e,t,n);return rm(i)})}class n_{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 i_=17,va=6;class s_{constructor(){this.name="",this.range="",this.glyphs={}}}class r_{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 o_{constructor(t,n){this.stacks=t.readFields(a_,[],n)}}function a_(e,t,n){if(e===1){const i=n.readMessage(c_,new s_);t.push(i)}}function c_(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(l_,new r_);t.glyphs[i.id]=i;break}}}function l_(e,t,n){switch(e){case 1:t.id=n.readVarint(),t.range=Ec(t.id);break;case 2:t.bitmap=n.readBytes();break;case 3:t.width=n.readVarint()+va;break;case 4:t.height=n.readVarint()+va;break;case 5:t.left=n.readSVarint()-va/2;break;case 6:t.top=n.readSVarint()+i_+va/2;break;case 7:t.advance=n.readVarint();break}}class u_{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!==zt.bomCharCode&&Ew(t[o],a)}this.glyphs=s,this.width=r+zt.baseSize*i*(t.length-1)}}function d_(e,t,n){const i={lines:[],maxWidth:0},s=e.split(`
`);for(let r=0;r<s.length;r++){const o=new u_(s[r],n,t);i.lines.push(o),o.width>i.maxWidth&&(i.maxWidth=o.width)}return i}function f_(e,t,n){for(const i of t)if(!n.has(e,i))return!1;return!0}function h_(e,t,n){if(e===void 0)return;const i=lt(e,t);if(i!=="")return n.fontNameToIndex[i]===void 0?Di:i}function p_(e){const t=new o_(new kr(new Uint8Array(e))).stacks[0].glyphs,{width:n,height:i}=m_(t);y_(t,n,i);const s=g_(t,n,i);return{glyphData:t,bitmap:s,width:n,height:i}}function m_(e){const t=[],n=new vt(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:pd(n.w),height:pd(n.h)}}function y_(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 g_(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 u=0;u<o.width;u++)i[c+u]=o.bitmap[l+u]}}return i.buffer}function w_(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 v_=new Promise(e=>{m.markAsReady=()=>{m.rtlAdapterReady=!0,e()}}),b_=new Set(["ar"]);function zm(e,t){return e==="always-on"||e==="depends-on-language"&&b_.has(t)}function I_(e,t,n){const i=t.workers.labeling;function s(){i.markRtlPluginLoaded().then(()=>{m.markAsReady!==null&&m.markAsReady()})}return zm(e.scenario,n)?fetch(e.url,{integrity:e.hash}).then(r=>r.text()).then(r=>Promise.all([i.loadRtlPlugin(r),Promise.resolve(Gm(r))])).catch(r=>{s();const o=new Error,a="[RTL Plugin]: loading failed.";throw o.message=M_(r)?`${a} ${r.message}`:a,o}):(s(),Promise.resolve())}const Gm=w_(function(e){new Function(e)(),m.processRTLTextIfNeeded=self.mapglRtlPlugin.processRtl,m.markAsReady&&m.markAsReady()});function M_(e){return typeof e=="object"&&!!e&&"message"in e}m.ArrowGenerator=Zs,m.BBoxType=Nt,m.BLEND_EQUATION=LM,m.BLEND_FUNC=PM,m.BaseTileLoader=pu,m.Buffer=Ze,m.BufferChannel=w0,m.BuildingModelGenerator=bn,m.CULL_FACE_MODE=_M,m.Camera=Is,m.CircleMarkerGenerator=ho,m.ClassRegistry=IA,m.Collector=sA,m.DEFAULT_EMPTY_KEY=zu,m.DEFAULT_FONT=Di,m.DEFAULT_FRAME_SIZE=Ou,m.DEFAULT_ID_SCOPE=Fl,m.DEFAULT_LIGHTING_MODES=oA,m.DEFAULT_MAPGL_STYLE=Km,m.DEFAULT_MIN_TIERS_STYLE_ZOOM=fd,m.DEFAULT_MODELS_APPEAR_STRATEGY=Uu,m.DEM_ELEVATION_TILE_SIZE=M2,m.DEM_STYLE_LAYER_ID=zs,m.DEM_TILE_URL_FUNCTION=lh,m.DEM_TREE_SIZE=ch,m.DEPTH_FUNC=I0,m.DYNAMIC_MODEL_ID_SCOPE=fM,m.DYNAMIC_STYLE_ID=$o,m.DashedLineGenerator=vn,m.DemGenerator=Rt,m.Differ=Tp,m.DynamicStyle=fT,m.EARTH_CIRCUMFERENCE=Ha,m.EMPTY_FEATURE_COLLECTION=Qo,m.EMPTY_SHADER_DEFINITIONS=Ul,m.ENVIRONMENT_STYLE_LAYER_ID=jc,m.Ecef=nt,m.Evented=cc,m.FLOOR_ID_SCOPE=dM,m.FnRegistry=bA,m.FrameHeader=Cu,m.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL=Ql,m.GLOBE_TEXTURE_SIZE=n1,m.GL_TRIANGLES=gr,m.GeoJsonSource=xp,m.GeoJsonSourceCore=Ip,m.GeoJsonSourceWorker=KA,m.GeoJsonTileSource=JS,m.GeoJsonViewportSource=KS,m.GlobeGenerator=ar,m.GltfDemPosition=Xh,m.GltfModelGenerator=Xn,m.HALF_WORLD_SIZE=2147483648,m.HandyIndexer=Rl,m.HeatmapGenerator=Mi,m.HideLevel=ns,m.INVALID_FRAMEBUFFER_ID=Kr,m.INVALID_IDENTIFY_CENTER_COORD=Ta,m.IdScope=hM,m.LABELING_TEXTURE_BACKGROUND_COLOR=tA,m.LABELING_TEXTURE_DEM_MESH_COLOR=nA,m.LATEST_TILE_VERSION=Am,m.LRU=ip,m.LabelGeometryType=vi,m.LabelIndex=yl,m.LabelSource=qs,m.LabelingAnimation=p0,m.LabelingElementType=Ye,m.LabelingTileElement=bo,m.LengthUnits=Gn,m.LineExtrusionGenerator=In,m.LineGenerator=ut,m.LinePatternType=Ll,m.MAP_DEFAULTS=Ea,m.MAP_MESH_TEXTURE_INDEX=jy,m.MAP_POINTS_IN_METER=Ie,m.MODELS_TILES_VIEWPORT_PADDING=e1,m.MainConnector=wA,m.MapMeshGenerator=ts,m.Mercator=oe,m.MeshElevationWorker=zx,m.MeshFillSide=ne,m.MeshGenerator=K,m.ModelStepSource=Ti,m.ModelsWorker=Ux,m.PBR_TEXTURE_INDEX=Gy,m.POINT_CENTER_SIZE=Sa,m.PolygonExtrusionGenerator=$n,m.PolygonGenerator=Zt,m.PreLabelType=Mn,m.RasterGenerator=mo,m.RasterSetType=Ii,m.RenderBackendType=Fu,m.ReservedLightingMode=Ns,m.SIMPLE_MESH_STYLE_LAYER_ID=aT,m.SceneObjectType=wc,m.Shader=Yo,m.ShaderAttribute=Vg,m.TEXTURE_COORDS_TO_WEBGL=S1,m.TRANSPORT_SIZE=Hx,m.ThreadName=Qn,m.TileLayer=bp,m.TileObject=Xo,m.TileObjectBase=q0,m.TileStatus=jl,m.TransportHeader=ga,m.TwoKeyMap=n_,m.UNIVERSE_REGION_ID=t1,m.UNUSED_STYLE_ID_SHIFT=aA,m.WEBGL_COORDS_TO_TEXTURE=E1,m.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER=Zm,m.WorkerConnector=vA,m.ZenithSourceCore=TM,m.ZenithWorker=ZE,m.ZoomDirection=Ut,m.add=jt,m.add$1=ii,m.addGeneratedDataToTileMod=J0,m.adjustGlobeDragSpeed=oy,m.affineStep=Ra,m.allFontGlyphsLoaded=f_,m.applyDefaults=Dn,m.applyStyleOptions=yI,m.assertUnreachable=Df,m.atlasSize=cn,m.bezier=V0,m.bindUrl=Oy,m.buildingAnimation=Xu,m.calcAngle=Ey,m.calcMidpoint=Ay,m.center=Dr,m.cityCommPoiLabelingConfig=Ju,m.clamp=Te,m.clampLat=dy,m.clampPoint=uy,m.clone=d1,m.clone$1=B1,m.commPoiLayers=v0,m.commercialPoi=Aa,m.compare=Gr,m.compileRtlPlugin=Gm,m.componentTypeToWebGl=Hg,m.contains=fy,m.convertStyleLayerTypeToHandy=Xv,m.coordsToKey=xe,m.copy=y1,m.copy$1=Pd,m.copy$2=Za,m.copy$3=Mr,m.create=Ms,m.create$1=yt,m.create$2=vd,m.create$3=bs,m.create$4=ec,m.create$5=Or,m.create$6=Ce,m.createGeoJsonMetatile=cm,m.createGridState=cp,m.createLoadedRasterSet=Ub,m.createMetatile=Gd,m.createObjectAttributesArray=Fe,m.createRemoteRenderRunner=t_,m.createRenderRunner=Um,m.createTileInfo=ct,m.cross=ws,m.debounce=Sp,m.decomposeMat4=Ly,m.deepEqual=Oi,m.defaultCameraConfig=Gt,m.defaultLang=Qu,m.defaultMarkerAnchor=dd,m.defaultMarkerIcon=ud,m.defaultModelsPath=Ia,m.defaultShadowsSettings=hd,m.degToRad=be,m.dem=ju,m.dist=Fn,m.dist$1=qa,m.distance=ms,m.dot=Xa,m.dot$1=Cn,m.dracoDecoderUrl=Wm,m.drawIdentifyScene=hT,m.earcut=Au,m.ease=$0,m.emptyFeatureAttrs=jd,m.emptySourceAttrs=oc,m.entranceAnimation=qu,m.equalArrays=a1,m.equalSets=o1,m.equals=ty,m.equals$1=m1,m.events=Wu,m.exactEquals=T1,m.exactEquals$1=Sr,m.exactEquals$2=Y1,m.excludeItemFromArray=c1,m.exist=W0,m.expandByPoint=ai,m.expose=yu,m.expressionValues=mi,m.findVisibleTiles=ef,m.finishStyleUpdatingAction=yp,m.fixedMetatile=By,m.fixedTileProps=ci,m.floors=Da,m.fonts=zt,m.forceGlStatusCheck=N0,m.fromGeo=ly,m.fromRotationTranslationScale=I1,m.fromScaling=b1,m.fromTranslationScale=Ar,m.fromValues=at,m.fromValues$1=ka,m.generalize=Rb,m.generateHaltonSequence=Pw,m.generateHandyLayers=Cl,m.generateIconElement=wl,m.generateNotStretchableIconElement=Vb,m.generatePointsOnSphere=Lw,m.generateSafely=m0,m.generateTextElement=To,m.generateTileBounds=R0,m.geoJsonMetatileHash=Bu,m.geoLineDistance=L1,m.geoPointsDistance=Ya,m.geoToMapDistance=Lr,m.get=sS,m.getArrayBuffer=ea,m.getBoundsTileCoords=Bg,m.getCenterCorrection=ry,m.getClosestPointOnLineSegment=ug,m.getColorForShaders=Dv,m.getElevationFromTile=S2,m.getFontNameWithFallback=h_,m.getFontUrl=dI,m.getFractionalPart=r1,m.getJson=_p,m.getLabelingInfo=oM,m.getLayerImageProps=_0,m.getLineConstants=li,m.getMetersFromPixelsXY=cy,m.getModelUrl=fI,m.getPixelsPerMeter=Wr,m.getPoiIconData=MI,m.getRandomValue=Rs,m.getRawMemoryStats=ZS,m.getSizeDependentImageUrl=Yh,m.getStaticIconRasterSetKey=Hi,m.getStaticTextureRasterSetKey=Xr,m.getStyleUrl=gI,m.getStyleZoom=Od,m.getSubdomainFromString=rc,m.getSymbolLayers=B0,m.getTextMetrics=d_,m.getTierFromLevels=zI,m.getTileBounds=Ur,m.getTileCoordsByCenterAndZoom=yc,m.getTileModToGenerate=np,m.getTilesToAbortFetch=rp,m.getTilesToFetch=sp,m.getTilesToGenerate=op,m.getTilesToRemove=ap,m.getTotalMemory=Kl,m.getTriple=Ir,m.getUrl=Ss,m.getUrlForIconMapIcon=Il,m.getUrlFromTemplate=Es,m.getVisibleMapReplicas=Ug,m.getZoomFromStyleZoom=ay,m.globeConfig=Ln,m.globeTileScale=_1,m.handyColor=Fs,m.hashToString=Ud,m.heightToZoom=A1,m.icons=$u,m.identify=Pa,m.identity=za,m.index=i1,m.inertia=La,m.inferGeneratorType=$g,m.initTransportHeader=$x,m.int64ToString=l0,m.intersection=py,m.intersection$1=lM,m.invert=ys,m.isArrayOfNumbers=dn,m.isBetween=Na,m.isCommercialCityPoi=jh,m.isCommercialModel=aI,m.isCommercialPoi=Fo,m.isCommercialPoi$1=bi,m.isCommercialPoiCity=_b,m.isCommercialPoiLabel=Js,m.isCommercialPoiPremium=Pb,m.isCommercialPremiumPoi=Vh,m.isExtractableHandyExpression=cw,m.isHandyExpression=nn,m.isHandySimpleType=wf,m.isInt64=XI,m.isLatValid=hy,m.isLineStyleLayer=j2,m.isNullVector=Sy,m.isNullish=l1,m.isObject=u1,m.isPersonalPoi=oI,m.isRtlPluginRequired=zm,m.isStyleColor=hn,m.isStyleGradient=qr,m.isStyleId=$v,m.isStyleLayerHidable=Zv,m.isStyleLayerType=Wv,m.isStyleMixColor=uw,m.isTileOnSphereInViewport=$r,m.isTileVisible=zr,m.isTilesIntersects=Eg,m.isTypedArray=SI,m.keyServerPath=us,m.keyToCoords=hc,m.labeling=vr,m.len=wd,m.len$1=_r,m.length=Rn,m.lerp=si,m.lerp$1=Ua,m.lerp$2=Ci,m.lerp$3=ey,m.limitString=Sw,m.linePatternFromString=h0,m.linear=H0,m.loadModelsInfoStyleZoom=xa,m.log=ke,m.logEmptyTileGenerationResponse=xf,m.logGltfError=Aw,m.lookAt=Va,m.mailboxSwap=Om,m.makeBinderContext=Gf,m.makeGeneratorContext=ks,m.makeHandyDemLayer=Bl,m.makeHandyGroupOrLayer=E0,m.makeHandyLightStyle=L0,m.makeHandyRasterSet=x0,m.makeHandyRasterSets=A0,m.makeHandyStyle=nT,m.makeHandyStyleLayer=Ho,m.makeLabelingContext=Ht,m.mapHeightToTileHeight=it,m.mapPointPitch=F1,m.mapPointTo32ZoomTileCoords=kg,m.mapPointToTilePoint=Lt,m.mapToPixelDistance=C1,m.maxTilePoint=te,m.maxU32=Xm,m.maxUint16Value=Ge,m.metricsTimeout=sd,m.modStatsGpu=Jl,m.modStatsJs=ql,m.modelCacheSize=Vu,m.modelSizeGpu=YS,m.modelSizeJs=$S,m.models=Gu,m.mul=ny,m.mul$1=Ri,m.multiply=Ga,m.multiply$1=gy,m.newFrameAction=fp,m.normalize=Jt,m.normalize$1=On,m.normalizeMapPoint=N1,m.normalizeMousePosition=s1,m.optionsToTileAttrs=F0,m.ortho=M1,m.overlappedGroupName=jn,m.packTexCoords=At,m.performanceCheck=id,m.pixelRatioToDpi=Cc,m.pixelToMapDistance=Sd,m.pixelsAndMapDistanceToZoom=Ed,m.pointToLineDistance=rg,m.pointToLineSignedDistance=Wd,m.preLabelingPoint=$h,m.prepareMetatile=zd,m.processElement=rM,m.processFont=p_,m.projectToXyRect=Dy,m.radToDeg=ti,m.rbush=so,m.removeUndefined=tv,m.renameZenithEnumerationValues=MM,m.render=Ku,m.reserveTextureIndex=uc,m.reset=Ka,m.resetGridState=Yl,m.resolveAnimationExpression=Rf,m.resolveColor=Hn,m.resolveExpression=j,m.resolveGradient=Pv,m.resolveLightingModes=Cv,m.resolveNumber=ae,m.resolveSimpleLiteralExpression=st,m.resolveString=lt,m.resolveTextureAnimationExpression=Nf,m.rotateVec2=xy,m.rotateX=V1,m.rotateY=H1,m.rtlAdapterPromise=v_,m.rtlPluginHash=ds,m.rtlPluginUrl=an,m.runPrecomputes=Ol,m.sample=Uf,m.sampleColor=zf,m.scale=Nn,m.scale$1=my,m.scale$2=_t,m.scale$3=Fi,m.scale$4=K1,m.selectRaster=Ks,m.set=Oe,m.set$1=q1,m.set$2=w1,m.setSeed=vb,m.setupMapboxRtlAdapterIfNeeded=I_,m.sign=br,m.slerp=Cr,m.sourceUuid=Mp,m.splitPolylineByLength=cg,m.splitPolylineByMaxSize=lg,m.spreadTileObjects=k0,m.sqrDist=Z1,m.start=Y0,m.startStyleUpdatingAction=mp,m.stop=zl,m.stride=cr,m.styles=Yu,m.sub=ln,m.sub$1=Kt,m.subtract=aM,m.template=Ts,m.tetragonBounds=Br,m.tetragonIntersectsBounds=Zd,m.textureSizeGpu=VS,m.textureSizeJs=Xl,m.throttle=XE,m.tileCoordOffset=z,m.tileCoordsToMapPoint=Gi,m.tileCoordsToOSM=Vr,m.tileHeight=fs,m.tileObjectStatsGpu=vp,m.tileObjectStatsJS=wp,m.tilePointScaleFactor=Ot,m.tileSizeZpt=256,m.tileZoomToSize=Dt,m.tiles=ei,m.toStyleColor=wt,m.traffic=Hu,m.transfer=sm,m.transformMat4=Pr,m.transformMat4$1=vs,m.uint16ToTileCoords=Li,m.uniqId=lc,m.unpackPreLabelingResult=Eb,m.update=Z0,m.updateScene=up,m.urls=wr,m.vertexTilePointToMapPoint=sf,m.viewportChangeAction=Zl,m.viewportTilesReady=$l,m.workerResetInterval=Zu,m.worldBounds=D1,m.worldLoopBounds=O1,m.worldSize=4294967296,m.worldWrapX=gs,m.wrap=em,m.z0Scale=Nu,m.zenithSourceAttrs=Vd,m.zenithToJakartaPropKey=wM,m.zoom=ed,m.zoomToHeight=Ni,m.zoomToScale=x1,m.zptPerInch=hs,m.zptToSceneDistance=P1}));

_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 vw=Object.defineProperty,gw=Object.defineProperties;var yw=Object.getOwnPropertyDescriptors;var Sc=Object.getOwnPropertySymbols;var xw=Object.prototype.hasOwnProperty,bw=Object.prototype.propertyIsEnumerable;var We=Math.pow,Tc=(A,n,ze)=>n in A?vw(A,n,{enumerable:!0,configurable:!0,writable:!0,value:ze}):A[n]=ze,z=(A,n)=>{for(var ze in n||(n={}))xw.call(n,ze)&&Tc(A,ze,n[ze]);if(Sc)for(var ze of Sc(n))bw.call(n,ze)&&Tc(A,ze,n[ze]);return A},de=(A,n)=>gw(A,yw(n));var q=(A,n,ze)=>new Promise((Oi,Ni)=>{var Jn=ct=>{try{lt(ze.next(ct))}catch(di){Ni(di)}},Ee=ct=>{try{lt(ze.throw(ct))}catch(di){Ni(di)}},lt=ct=>ct.done?Oi(ct.value):Promise.resolve(ct.value).then(Jn,Ee);lt((ze=ze.apply(A,n)).next())});"use strict";var wt,jt;var ze=document.createElement("style");ze.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(ze);function Oi(s,e,t){if(s.length===0)return;const i=n.degToRad(e),o=n.create();for(const a of s){const l=n.Mercator.fromGeo(a);n.rotateVec2(l,-i),n.expandByPoint(o,l)}const r=n.create$1();return n.center(r,o),n.rotateVec2(r,i),{center:r,zoom:Ni(o,t)}}function Ni(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 Jn(s,e,t){const i=Oi(s,e,t);if(i)return{zoom:i.zoom,center:n.Mercator.toGeo(i.center)}}function Ee(s,e,t){const i=s.getBoundingClientRect();return[e-i.left-s.clientLeft,t-i.top-s.clientTop]}function lt(s,e){const t=[];for(let i=0;i<s.length;i++)t[i]=Ee(e,s[i].clientX,s[i].clientY);return t}function ct(s){return s.touches.length>1}const di=n.Mercator.fromGeo,Mc=n.Mercator.toGeo;function Ec(s,e,t,i,o,r,a={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:a,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).project(r)}function Ic(s,e,t,i,o,r,a={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:a,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).unproject(r)}function Cc(s,e,t,i,o,r,a={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,r,a,l,c,c)}function Lc(s,e){return new n.Camera(s).project(n.Mercator.toGeo(e))}const Pc=Object.freeze(Object.defineProperty({__proto__:null,geoLineDistance:n.geoLineDistance,geoToMapDistance:n.geoToMapDistance,getCenterZoomByPoints:Jn,getMetersFromPixels:Cc,getMousePositionInContainer:Ee,projectGeoToMap:di,projectGeoToScreen:Ec,projectMapToGeo:Mc,projectMapToScreen:Lc,projectScreenToGeo:Ic},Symbol.toStringTag,{value:"Module"})),Bc=Object.freeze(Object.defineProperty({__proto__:null,getMetersFromPixelsXY:n.getMetersFromPixelsXY,getUrl:n.getUrl,hashToString:n.hashToString},Symbol.toStringTag,{value:"Module"}));class $e 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 Rs=["disableDragging","enableTrackResize","loopWorld","disableHidingPois","enableTwoFingerDragging"];let An=class{constructor(e,t,i){var o,r,a,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=(r=t.modelsAppearStrategy)!=null?r: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((a=t.minZoom)!=null?a: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,z({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 Fs(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 zc(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 An)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 pt(s,e,t,i,o){const r=o.camera,a=[0,0];if(r.unproject(i,a,!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:a,originalEvent:t,point:i,targetData:f};f.emit(h,m);return}const l=Fs(o.sourceStorage,e),c=zc(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:a,originalEvent:t,point:i,target:l,targetData:c},u=s;o.map.emit(u,_)}class Ds extends $e{constructor(e,t,i){super(e,t),this.start=o=>{const{modules:r,container:a}=this,{camera:l}=r;if(o.button!==0)return;const c=Ee(a,o.clientX,o.clientY);this.contains(c)&&(r.handler.block(),r.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:r}=this.modules,{dragStartAnchorPoint:a,dragStartCursorPoint:l,container:c}=this;if(a===void 0||l===void 0)return;const d=Ee(c,o.clientX,o.clientY),_=n.clone(a);n.add(_,_,d),n.sub(_,_,l),this.setPosition(n.Mercator.fromGeo(r.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:r}=this;r.handler.unblock(),r.mouseMoveHandler.unblock(),this.emitEvent("dragend",o),this.interactive&&r.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),r=this.modules.camera.flat.project(i),a=this.modules.identifier.searchSync(r),l=a!==void 0&&a.dynamicObjectId===void 0?Fs(this.modules.sourceStorage,a):void 0;this.emit(e,{originalEvent:t,target:l,targetData:this,lngLat:o,point:r})}}const Rc=!1;let Os=class extends Ds{constructor(e,t){var x,g;super(e,t,(x=t.draggable)!=null?x:Rc),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:r,tileManager:a,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:r,generator:n.CircleMarkerGenerator.generate,args:[o.getStyle().id,this.layer,m,h]});const p=r.getAccumulatedData(),v=new n.TileObject("dynamicObject",p.data,this.modules,this.mapState,_);a.addObject(v),this.tileObjects.push(v),this.interactive&&this.identifyIds.push(p.identifyIds),c.addLayer(this),r.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(super.update(),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)),r=n.resolveNumber(t.style.width,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),a=n.resolveNumber(t.style.strokeWidth,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),l=r/2+a;return n.dist(o,e)<=l}};function Ns(s,e,t){const{top:i,right:o,bottom:r,left:a}=s.viewport,{clientWidth:l,clientHeight:c}=e;s.size=[Math.max(1,l-a-o),Math.max(1,c-i-r)],t.updateFrameBuffersSize()}const Fc=(s,e,t,i,o={})=>{const r=z({top:0,right:0,bottom:0,left:0},i);if(o.animate===!1||o.duration===0)s.viewport=r,Ns(s,e,t);else{const a=s.viewport,l=o.easing!==void 0?o.easing:"easeOutCubic",c=o.duration!==void 0?o.duration:300;n.start("viewport",{easing:l},s,[a.top,a.right,a.bottom,a.left],[r.top,r.right,r.bottom,r.left],c,1)}},Dc=(s,e,t)=>{n.update("viewport",{step:(i,o)=>{i.viewport={top:o[0],right:o[1],bottom:o[2],left:o[3]},Ns(i,e,t)}},s)};function Oc(s,e){return{top:s.top+e.top,bottom:s.bottom+e.bottom,left:s.left+e.left,right:s.right+e.right}}function Nc(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 kc(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 Uc(s,e){return kc(Nc(s),e)}function ks(s,e){const{top:t,right:i,bottom:o,left:r}=s.padding;s.padding={top:t,right:i,bottom:o,left:r},e.addRerenderEvent(),e.updateFrameBuffersSize()}const Hc=(s,e,t,i={})=>{const o=Uc(t,s.size);if(i.animate===!1||i.duration===0)s.padding=o,ks(s,e);else{const r=s.padding,a=i.easing!==void 0?i.easing:"easeOutCubic",l=i.duration!==void 0?i.duration:300;n.start("padding",{easing:a},s,[r.top,r.right,r.bottom,r.left],[o.top,o.right,o.bottom,o.left],l,1)}},Gc=(s,e)=>{n.update("padding",{step:(t,i)=>{t.padding={top:i[0],right:i[1],bottom:i[2],left:i[3]},ks(t,e)}},s)},ki="inertia",Vc=(s,e,t)=>s*Math.pow(1-(t-e)/n.inertia.duration,n.inertia.nonLinearity),Zc=(s,e,t,i,o)=>{n.start(ki,{easing:"inertia"},s,0,o,n.inertia.duration,1,{startPoint:e,startSpeed:t,direction:i,startTime:s.time})},eo=n.stop.bind(null,ki),jc=(s,e)=>{n.update(ki,{step:(t,i,o)=>{const{startPoint:r,startSpeed:a,startTime:l,direction:c}=o,d=n.clone$1(c);n.scale(d,d,i),n.add$1(d,d,r),t.loopWorld||t.globeMode?n.isLatValid(t.maxBounds,d)||(to(e,t),n.clampPoint(d,t.maxBounds,d)):n.contains(t.maxBounds,d)||(to(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 _=Vc(a,l,t.time);n.mapToPixelDistance(_,t.zoom)<n.inertia.minSpeed&&to(e,t)}},s)},to=(s,e)=>{n.stop(ki,e),s.classList.remove("mapgl-inertia")},Ui="center",Dt=(s,e,t={})=>{if(n.stop(Ui,s),eo(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(Ui,{easing:i},s,s.center,e,o,1)}},Wc=n.stop.bind(null,Ui),$c=n.update.bind(null,Ui,{step:(s,e)=>{s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e)}}),Hi="rotation";function io(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 _i(s,e,t={}){if(n.stop(Hi,s),t.animate===!1||t.duration===0)s.rotation=io(e,0);else{const i=t.normalize!==void 0?t.normalize:!0;n.start(Hi,{easing:t.easing||"linear"},s,s.rotation,i?io(e,s.rotation):e,t.duration||250,1)}}const Xc=n.stop.bind(null,Hi),Kc=n.update.bind(null,Hi,{step:(s,e)=>s.rotation=io(e,0)}),Gi="pitch";function Vi(s,e,t={}){n.stop(Gi,s);const i=n.clamp(e,s.minPitch,s.maxPitch);t.animate===!1||t.duration===0?s.pitch=i:n.start(Gi,{easing:t.easing||"linear"},s,s.pitch,i,t.duration||300,1)}const qc=n.stop.bind(null,Gi),Yc=n.update.bind(null,Gi,{step:(s,e)=>s.pitch=e}),Zi="zoom",Tt=(s,e,t={})=>{n.stop(Zi,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,r=t.useHeightForAnimation?n.zoomToHeight(i,s.size):i,a=t.easing!==void 0?t.easing:"easeOutCubic",l=t.duration!==void 0?t.duration:250;n.start(Zi,{easing:a},s,o,r,l,1,{zoomPoint:t.zoomPoint,useHeightForAnimation:!!t.useHeightForAnimation})}},Us=n.stop.bind(null,Zi),Qc=n.update.bind(null,Zi,{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)}}),Jc=navigator.msPointerEnabled&&navigator.msMaxTouchPoints&&!window.PointerEvent,Ac=window.PointerEvent&&navigator.pointerEnabled&&navigator.maxTouchPoints||Jc||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,ed=Ot("webkit"),td=Ot("chrome")||Ot("crios"),id="ActiveXObject"in window,nd=!td&&Ot("safari");Ot("gecko")&&!ed&&window.opera;const ji=navigator.platform.toUpperCase().indexOf("MAC")>=0,od=Ot("windows"),sd=Ot("firefox");function Ot(s){return navigator.userAgent.toLowerCase().indexOf(s)>=0}function vt(s){Us(s),Wc(s),Xc(s),qc(s),eo(s)}class rd{constructor(e,t){this.onWheelScroll=i=>{this.isBlocked||(i.preventDefault(),!(i.deltaMode===void 0&&i.deltaY===void 0)&&(this.state.userHasInteracted=!0,this.screenPoint=Ee(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();ji?o*=n.zoom.macWheelDeltaToZoomDelta:Number.isInteger(o)?o=n.sign(o)*n.zoom.wheelZoomDelta:o*=n.zoom.notMacTrackpadDeltaToZoomDelta;const r=i.zoom+o,a=n.clamp(r,i.minZoom,i.maxZoom);a!==i.zoom&&(vt(i),Tt(i,a,{duration:n.zoom.animDuration,animate:!ji,zoomPoint:i.keepCenterWhileUserZoomRotate?void 0:this.screenPoint}))},this.stop=()=>{this.state.userHasInteracted=!0,Us(this.state)},this.state=e,this.container=t,ji||(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 ad{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),r=n.length(o);if(n.mapToPixelDistance(r,i.zoom)<=n.inertia.minSpeed)return;const l=n.pixelToMapDistance(n.inertia.maxSpeed,i.zoom),c=Math.min(r,l),d=this.calcDistanceByStartSpeed(c),_=n.clone$1(i.center),u=n.create$1();n.normalize(u,o),Zc(i,_,c,u,d),this.container.classList.add("mapgl-inertia")},this.stop=()=>{eo(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),Ac&&(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 ld{constructor(e){this.emitMouseEvent=t=>{if(this.isBlocked)return;const i=Ee(this.container,t.clientX,t.clientY);this.emitEvent(t,i)},this.emitTouchEvent=t=>{if(this.isBlocked)return;const i=Ee(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=>{pt(i,o,e,t,this.modules)})}}class cd{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=Ee(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 r=n.degToRad(o.rotation);!this.rotationDetected&&Math.abs(r)>this.state.touchRotationThreshold&&(this.rotationDetected=!0,this.startRotation=this.state.rotation-r),this.rotationDetected&&(this.gestureRotation=r)},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(),r=e.keepCenterWhileUserZoomRotate?n.create$1():n.getCenterCorrection(e,this.screenPoint,{zoom:t,rotation:i});n.add$1(o,e.center,r),vt(e),Dt(e,o,{animate:!1}),Tt(e,t,{animate:!1}),e.disableRotationByUserInteraction||_i(e,i,{animate:!1}),this.gestureRotation=0,this.gestureZoom=0}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}class dd 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(r=>1e3/r),t=this.badDurations.map(r=>1e3/r),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((r,a)=>r+a)/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((r,a)=>r+a)/t.length:0,count:t.length},isStatic:i}}getMemoryStats(){return q(this,null,function*(){const e=yield this.getJsMemoryStats(),t=yield this.getGpuMemoryStats();return{cpu:e,gpu:t}})}check(){const e=_d(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 q(this,null,function*(){const e=yield n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.js).map(o=>o.js).reduce((o,r)=>o+r["--sum"],0)})}getGpuMemoryStats(){return q(this,null,function*(){const e=yield n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.gpu).map(o=>o.gpu).reduce((o,r)=>o+r["--sum"],0)})}}function _d(s){s.sort((t,i)=>t-i);const e=s[Math.floor(s.length*3/4)];return Math.round(1e3/e)}class ud{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 hd{constructor(e){this.onTouchStart=()=>{this.isTouchStartEmitted=!0},this.onMouseOut=t=>{if(!this.prevGeo)return;const i=Ee(this.container,t.clientX,t.clientY);pt("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=Ee(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 r=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||r)&&(pt("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.container.classList.remove("mapgl-hover"),this.modules.defaultSource.resetHoverId()),o&&(!this.prevGeo||r)&&(this.prevGeo=o,this.container.classList.add("mapgl-hover"),pt("mouseover",o,t,i,this.modules),this.modules.defaultSource.setHoverId(o.id)),pt("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 Hs=(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)},fd=(s,e,t)=>n.update.call(null,"buildingHeight"+t,{step:(i,o)=>e.set(t,o),complete:i=>i.needLabeling=!0},s),md=16;class pd{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()&&fd(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:md;return this.state.styleZoom<e?0:1}updateByZoom(e,t){const i=this.state,o=n.get("buildingHeight"+e,i),r=o!==void 0?o.to:t;i.styleZoom>=e&&this.modules.tileManager.viewportTilesReady()&&r!==1?Hs(i,this.buildingHeights,{animate:!0,easing:n.buildingAnimation.easing,from:t,to:1,duration:n.buildingAnimation.duration*(1-t)},e):i.styleZoom<e&&r!==0&&Hs(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 j=class j{constructor(e=null,t={}){this._src=null,this._glContext=null,this._texture=null,this._src=e,this.options=Object.assign({},j.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 r=this._toGlParam(o,this.options.format),a=this._toGlParam(o,(l=this.options.type)!=null?l:j.UnsignedByte);return r===null||a===null?this:(o.texSubImage2D(o.TEXTURE_2D,0,t,i,r,a,e),this.options.generateMipmaps&&this.options.minFilter!==j.NearestFilter&&this.options.minFilter!==j.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:j.UnsignedByte),o=this._toGlParam(e,this.options.wrapS),r=this._toGlParam(e,this.options.wrapT),a=this._toGlParam(e,(_=this.options.magFilter)!=null?_:j.LinearFilter),l=this._toGlParam(e,(u=this.options.minFilter)!=null?u:j.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&&r!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,r)),a!==null&&l!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,a),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!==j.NearestFilter&&this.options.minFilter!==j.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,r;if(!this._texture)return 0;const e=((i=(t=this.options.size)==null?void 0:t[0])!=null?i:0)*((r=(o=this.options.size)==null?void 0:o[1])!=null?r:0)*4;return e>0?e:this._src!==null?this.memSizeJs():0}_toGlParam(e,t){return t===j.ClampToEdgeWrapping?e.CLAMP_TO_EDGE:t===j.Repeat?e.REPEAT:t===j.MirroredRepeat?e.MIRRORED_REPEAT:t===j.NearestFilter?e.NEAREST:t===j.NearestMipMapNearestFilter?e.NEAREST_MIPMAP_NEAREST:t===j.NearestMipMapLinearFilter?e.NEAREST_MIPMAP_LINEAR:t===j.LinearFilter?e.LINEAR:t===j.LinearMipMapNearestFilter?e.LINEAR_MIPMAP_NEAREST:t===j.LinearMipMapLinearFilter?e.LINEAR_MIPMAP_LINEAR:t===j.RgbaFormat?e.RGBA:t===j.AlphaFormat?e.ALPHA:t===j.RgbFormat?e.RGB:t===j.DepthComponentFormat?e.DEPTH_COMPONENT:t===j.UnsignedByte?e.UNSIGNED_BYTE:t===j.UnsignedShort?e.UNSIGNED_SHORT:t===j.Float?e.FLOAT:t===j.UnsignedInt?e.UNSIGNED_INT:e instanceof WebGLRenderingContext?null:t===j.RedFormat?e.RED:t===j.CompareRefToTexture?e.COMPARE_REF_TO_TEXTURE:t===j.CompareNone?e.NONE:t===j.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}};j.ClampToEdgeWrapping=1,j.Repeat=2,j.MirroredRepeat=3,j.NearestFilter=4,j.NearestMipMapNearestFilter=5,j.NearestMipMapLinearFilter=6,j.LinearFilter=7,j.LinearMipMapNearestFilter=8,j.LinearMipMapLinearFilter=9,j.DepthComponentFormat=10,j.DepthComponentFormat32=11,j.RgbaFormat=14,j.AlphaFormat=15,j.RgbFormat=16,j.UnsignedByte=17,j.Float=18,j.UnsignedShort=19,j.UnsignedInt=20,j.RedFormat=21,j.CompareNone=22,j.CompareRefToTexture=23,j.defaultOptions={magFilter:j.LinearFilter,minFilter:j.LinearMipMapLinearFilter,wrapS:j.ClampToEdgeWrapping,wrapT:j.ClampToEdgeWrapping,format:j.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:j.UnsignedByte};let w=j;function Wi(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 Yn=class Yn{constructor(e={}){this._texture=null,this._glContext=null,this._frameBuffer=null,this._depthAttachment=null,this.options=Object.assign({},Yn.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,r=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,r,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}`)}}};Yn.defaultOptions=Object.assign({},w.defaultOptions,{size:[0,0],generateMipmaps:!1,depthTexture:!1,hasColorOutput:!0,useHighDepthPrecision:!1,depthInternalFormat:WebGLRenderingContext.DEPTH_COMPONENT16});let Te=Yn;function $i(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 no={};function vd(s){const e=String(s);return no[e]===void 0&&(no[e]=gd(s)),no[e]}function gd(s){const e=$i(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 Nt;function Gs(){Nt=void 0;const s=new Float32Array([-1,-1,1,-1,-1,1]),e=2,t=$i(!1);if(!t)return Nt="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 Nt=`Absent ${m} extension`,!1;const i=new Te({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),r=`attribute vec2 pos;
    void main () {
        gl_Position = vec4(pos, 0, 1);
    }`,a=`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 Nt="Cannot create shaders",!1;t.shaderSource(l,r),t.compileShader(l),t.shaderSource(c,a),t.compileShader(c);const d=t.createProgram();if(!d)return Nt="Cannot compile shader program",!1;t.attachShader(d,l),t.attachShader(d,c),t.linkProgram(d),t.useProgram(d);const _=t.createBuffer();if(!_)return Nt="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 yd(){return Nt}let nt=null;function $t(){if(nt!==null)return nt;const s=$i(!1);if(!s)return nt=!0,nt;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 nt=!0,nt;s.shaderSource(i,e),s.compileShader(i),s.shaderSource(o,t),s.compileShader(o);const r=s.createProgram();return!r||(s.attachShader(r,i),s.attachShader(r,o),s.linkProgram(r),!r||!s.getProgramParameter(r,s.LINK_STATUS))?(nt=!0,nt):(nt=!1,nt)}function xd(){const s=$i(!1);if(!s)return!1;if(!od)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 Vs(s){return s instanceof WebGLRenderingContext?!!s.getExtension("WEBGL_depth_texture"):!0}function bd(s){return!Zs(s)}function Zs(s){if(!wd())return"not a browser";if(!Td())return"insufficient Function support";if(!Ed())return"insufficient JSON support";if(!Id())return"insufficient worker support";if(!Ld())return"insufficient ArrayBuffer support";if(!Pd())return"insufficient Canvas/getImageData support";const e=vd(s&&s.failIfMajorPerformanceCaveat||!1);if(!e.ok)return`insufficient WebGL support${e.msg?`: ${e.msg}`:""}`;if(!Sd())return"insufficient Array support";if(!Md())return"insufficient Object support";if(!Cd())return"insufficient DOM support";if(!Bd())return"insufficient ECMAScript 6 support"}function wd(){return typeof window!="undefined"&&typeof document!="undefined"}function Sd(){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 Td(){var s;return typeof((s=Function.prototype)==null?void 0:s.bind)=="function"}function Md(){return!!(Object.keys&&Object.assign&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.freeze)}function Ed(){return"JSON"in window&&"parse"in JSON&&"stringify"in JSON}function Id(){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 Cd(){const s=document.createElement("div");return s&&typeof s.after=="function"}function Ld(){return!!ArrayBuffer.isView}function Pd(){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 Bd(){return!("documentMode"in document)}function zd(){return yd()}const Rd=xd,Fd=()=>q(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 dt{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 Dd{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 Vs(this._gl)}isShadowSamplerSupported(){return!(this._gl instanceof WebGLRenderingContext)&&this.isDepthTextureSupported()}isContextLost(){return this._gl.isContextLost()}storeGpuState(e){var i,o,r,a;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:(r=this._lastState.depthFunc)!=null?r:t.getParameter(t.DEPTH_FUNC),clearDepth:(a=this._lastState.clearDepth)!=null?a: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,r){const a=this._gl,l=this.webGlExtensions.ANGLE_instanced_arrays;if(a instanceof WebGLRenderingContext){if(!l)return;l.drawElementsInstancedANGLE(e,t,i,o,r)}else a.drawElementsInstanced(e,t,i,o,r)}drawInstancedArrays(e,t,i,o){const r=this._gl,a=this.webGlExtensions.ANGLE_instanced_arrays;if(r instanceof WebGLRenderingContext){if(!a)return;a.drawArraysInstancedANGLE(e,t,i,o)}else r.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 r,a,l,c,d,_,u,h,f,m,p,v,x,g,y,b,M,S;const i=this._gl;if(i.depthMask((r=t==null?void 0:t.depthMask)!=null?r:e.depthMask),((a=t==null?void 0:t.depthTest)!=null?a: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,(S=(M=t==null?void 0:t.polygonOffset)==null?void 0:M.units)!=null?S:e.polygonOffset.units)):i.disable(i.POLYGON_OFFSET_FILL)}setDepthFunc(e){const t=dt.depthFuncToWebGL(this._gl,e);this._gl.depthFunc(t)}setCullFaceMode(e){const t=dt.cullFaceModeToWebGL(this._gl,e);this._gl.cullFace(t)}setBlendFunc(e,t){const i=dt.blendFuncToWebGL(this._gl,e),o=dt.blendFuncToWebGL(this._gl,t);this._gl.blendFunc(i,o)}setBlendFuncSeparate(e,t,i,o){const r=dt.blendFuncToWebGL(this._gl,e),a=dt.blendFuncToWebGL(this._gl,t),l=dt.blendFuncToWebGL(this._gl,i),c=dt.blendFuncToWebGL(this._gl,o);this._gl.blendFuncSeparate(r,a,l,c)}setBlendEquation(e){const t=dt.blendEquationToWebGL(this._gl,e);this._gl.blendEquation(t)}setBlendEquationSeparate(e,t){const i=dt.blendEquationToWebGL(this._gl,e),o=dt.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=a=>(this._lastState.depthMask=a,e(a));const t=this._gl.enable.bind(this._gl);this._gl.enable=a=>(a===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!0),t(a));const i=this._gl.disable.bind(this._gl);this._gl.disable=a=>(a===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!1),i(a));const o=this._gl.depthFunc.bind(this._gl);this._gl.depthFunc=a=>(this._lastState.depthFunc=a,o(a));const r=this._gl.clearDepth.bind(this._gl);this._gl.clearDepth=a=>(this._lastState.clearDepth=a,r(a))}}class Od{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")}}const zi=class zi{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 Od(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)}static getStableUboBinding(e){const t=zi.fixedUboBindings[e];if(t!==void 0)return t;console.error(`Unknown UBO block "${e}". Add a fixed binding for it.`)}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 r=o.filter(c=>c!==t.INVALID_INDEX),a=t.getActiveUniforms(i,r,t.UNIFORM_OFFSET);if(a===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 _=r.indexOf(d);l[e[c]]=a[_]}}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 r=e.getActiveUniformBlockName(t,o);if(!r)continue;const a=e.getActiveUniformBlockParameter(t,o,e.UNIFORM_BLOCK_ACTIVE_UNIFORMS);if(a===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<a;d++){const _=e.getActiveUniform(t,l[d]);_&&c.push(_.name)}this._uniformBlocksMap[r]=c}return this._uniformBlocksMap}locateUniformBlocks(e){const t=this._gl;if(t instanceof WebGLRenderingContext)return;const i=this.getUniformBlocksMap();if(i)for(const o in i){const r=t.getUniformBlockIndex(e,o);if(r!==t.INVALID_INDEX){const a=zi.getStableUboBinding(o);if(a===void 0)continue;this._uniformBlocksIndices[o]=r,this._uboBindings[o]=a,t.uniformBlockBinding(e,r,a)}}}};zi.fixedUboBindings={CommonSettings:0,LightSettings:1};let oo=zi;const js=[1,1,1,1],Nd=3.7,kd=n.create$1(),Ud=n.create$1(),Ws=n.create$2(),Hd=n.create$2(),Gd=n.create$1(),Vd=n.fromValues(0,1,0),$s=(s,e,t,i)=>{_t(t,s,{u_float_rounding_factor:e.stillness},i)},ui=(s,e,t,i)=>{_t(t,s,{u_float_border_width_offset:1/window.devicePixelRatio},i)},Xi=(s,e,t,i)=>{const o=(n.POINT_CENTER_SIZE-.5)/2,{size:r}=e;_t(t,s,{u_vec2_depth_test_half_point_size:[o/r[0],o/r[1]]},i)},$=(s,e,t,i)=>{if(!t.environmentManager.isFogEnabled())return;const o=t.styleManager.getStyle(e.handyStyleId);let r=js,a=js;if(o){const _=n.makeBinderContext(e.styleZoom,e.styleState,[]);r=n.getColorForShaders(n.resolveColor(o.environment.style.skyColor,_)),a=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),Nd);_t(t,s,{u_sky_color:e.globeMode?[0,0,0,0]:r,u_fog_color:e.globeMode?[0,0,0,0]:a,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)=>{_t(t,s,{u_cam_pos:t.camera.position},i)},te=(s,e,t,i)=>{t.shadowManager.texture&&_t(t,s,{u_shadow_map_params:t.shadowManager.shadowMapParams,u_shadow_bias:t.shadowManager.bias,u_mat4_clip_to_shadow:t.shadowManager.clipToShadowMatrix},i)},hi=(s,e,t,i)=>{_t(t,s,{u_vec2_scale_limits:[0,n.z0Scale]},i)},Xs=(s,e,t,i)=>{const o=t.camera.viewMatrixTranspose,r=t.camera.projectionMatrixInverse;_t(t,s,{u_mat4_view_transposed:o,u_mat4_proj_inverted:r},i)},so=(s,e,t,i)=>{const o=window.devicePixelRatio,r=t.camera.ecef.pixelRadius*o,{left:a,bottom:l,top:c,right:d}=e.padding,[_,u]=e.size,h=[_*o,u*o],f=[(a-d)*o/2,(l-c)*o/2],m=t.environmentManager.globHaloStops.map(b=>(r+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);_t(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)},Ks=(s,e,t,i)=>{const o=e.size,r=Math.max(o[0],o[1]),a=o[0]/r,l=o[1]/r;n.ortho(Ws,-a/2,a/2,-l/2,l/2,.001,1);const c=n.Mercator.toGeo(e.center),d=n.set(Ud,0,0,0),_=n.set(kd,0,0,1);n.rotateX(_,_,d,n.degToRad(c[1])),n.rotateY(_,_,d,n.degToRad(c[0]));const u=n.lookAt(Hd,Gd,_,Vd);n.multiply(u,Ws,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);_t(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,r=window.devicePixelRatio;_t(t,s,{u_vec2_vpt_size:[o[0]*r,o[1]*r]},i)};function _t(s,e,t,i){i?i.updateData(e,t):s.renderer.bindShaderProgram(e,t)}function X(...s){return(e,t,i,o)=>{s.forEach(r=>r(e,t,i,o))}}const Zd=X($s,ui,Xi,$,W,te,hi,Xs,so,Ks,_e),qs=X(W,$),Ys=(s,e,t)=>{const{size:i}=e,o=window.devicePixelRatio;if(e.demMode){const r=t.renderer.getFramebuffer(t.demManager.getFlatFramebufferId());if(!r)return;t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[Math.trunc(r.renderTarget.options.size[0]),Math.trunc(r.renderTarget.options.size[1])]})}else t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[i[0]*o,i[1]*o]})},fi=(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]})},Qs=(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]})},Ki=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_height_factor:t.buildingHeightAnimator.getDefaultBuildingHeight()})},qi=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:0})},jd=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:-1e-5})},ut=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture:0})},Js=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture1:1})},As=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_border_color:[0,0,0,0]})},er=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_space_color:[0,0,0,0]})},Wd=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_identify_opacity:e.iconIdentifyOpacity})},tr=(s,e,t)=>{const{renderer:i}=t,{labelingTextureBuffer:o,spriteLabelingTextureBuffer:r}=i;let a=e.isLabelingDepthTestDisabled;if(!a){const c=o.getDepthAttachment(),d=o.getTexture();!(c instanceof w)||!d?a=!0:(t.renderer.enableTexture(d,il),t.renderer.enableTexture(c,nl))}const l=r.getTexture();l&&(t.renderer.enableTexture(l,ol),t.renderer.bindShaderProgram(s,{u_color_text_sprite_labeling:ol})),t.renderer.bindShaderProgram(s,{u_bool_depth_test_disable:a}),a||t.renderer.bindShaderProgram(s,{u_color_tex_labeling:il,u_depth_tex_labeling:nl})};function mi(...s){return(e,t,i)=>{s.forEach(o=>o(e,t,i))}}function Ce(...s){return(e,t,i,o,r)=>{s.forEach(a=>a(e,t,i,o,r))}}const $d=1,Xd=2,Kd=4,re=(s,e,t,i,o)=>{let r=n.ReservedLightingMode.none,a=n.DEFAULT_LIGHTING_MODES[r],l=0;const c=ir(i,t,e);c&&(a=c.lightConfig,r=c.lightingMode,l=(r===n.ReservedLightingMode.none||o?0:$d)+(i.receiveShadows!==!1&&a.shadowLightIndex===0?Xd:0)+(i.receiveShadows!==!1&&a.shadowLightIndex===1?Kd:0));const d=t.renderer.getUbo(r);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:a.dir1Direction,u_vec4_light_dir1_color:a.dir1ColorIntensity,u_vec3_light_dir2_direction:a.dir2Direction,u_vec4_light_dir2_color:a.dir2ColorIntensity,u_vec4_ambient_color:a.ambientColorIntensity})},ht=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),r=n.resolveNumber(i.style.nearCameraFade,o);t.renderer.bindShaderProgram(s,{u_sdtr_distance:r})},Yi=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),r=i.style.showRatio,a=n.resolveExpression(r,o);t.renderer.bindShaderProgram(s,{u_float_show_ratio:a})};function ir(s,e,t){var a;const i=e.styleManager.getStyle(t.handyStyleId);if(!i||!i.light.lightingModesResolved)return null;let o=(a=s.lightingMode)!=null?a:i.light.defaultLightMode;s.type==="gltfModel"&&s.style.ignoreGlobalLighting&&(o=n.ReservedLightingMode.none);let r=i.light.lightingModesResolved[o];return r||(r=i.light.lightingModesResolved[i.light.defaultLightMode]),{lightingMode:o,lightConfig:r}}class V{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 a of e)Object.assign(i,a._attributes),Object.assign(o,a.attributesAliases);const r=new V(t._shaderProgram,i,t.indicesBuffer);return r.setAttributesAliases(o),r}copy(){const e=new V(this._shaderProgram,z({},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 r in i){const l=this.attributesAliases[r]||r,c=o[l];if(!c)continue;const d=i[r];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 r=i[o]||o,a=t[r];a!=null&&a.isDirty&&a.commitData()}this.isDirty=!1}}const qd=(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 V(e,{a_vec2_vertex:i})},Yd=(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 V(e,{a_vec2_vertex:i,a_float_mix_factor:o})},Qd=(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 V(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 V(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},Ad=(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 V(e,{a_vec2_vertex:i,a_vec4_identifier:o})},e_=(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 V(e,{a_vec2_vertex:i,a_vec4_normals:o})},t_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1});return new V(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:r,a_float_abs_z:a})},i_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:r,a_float_abs_z:a,a_vec4_identifier:l})},n_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:16,offset:8,normalized:!1});return new V(e,{a_vec2_vertex:i,a_vec4_normals:o,a_vec2_shift:r})},o_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:12,offset:8,normalized:!0});return new V(e,{a_vec2_vertex:i,a_vec4_normals:o,a_vec4_identifier:r})},s_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new V(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:r,a_vec4_identifier:a})},r_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),a=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 V(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:r,a_float_height:a,a_vec4_identifier:l})},nr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:28,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_vec2_texture_widen:r,a_vec2_widen:o,a_float_vertex_distance:a,a_float_component_distance:l,a_float_object_length:c,a_vec4_identifier:d})},or=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_vec2_texture_widen:r,a_vec2_widen:o,a_float_vertex_distance:a,a_float_component_distance:l,a_float_object_length:c,a_float_height:d,a_vec4_identifier:_})},sr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),a=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 V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_check_offset:a,a_vec2_offset:r,a_vec2_texcoord:l,a_vec4_tex_identifier:c,a_vec4_sprite_identifier:d})},a_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:24,normalized:!0});return new V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:r,a_vec4_identifier:a})},Qi=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1});return new V(e,{a_vec4_position:i,a_vec2_offset:r,a_vec2_texcoord:o,a_vec2_style_zoom_limits:a})},rr=(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}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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}),u=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:28,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:r,a_float_gradient:a,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:d,a_float_is_pivot:_,a_vec4_color:u})},l_=(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}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:r,a_float_gradient:a,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:_,a_float_is_pivot:d})},ar=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_float_abs_z:a,a_float_is_pivot:l})},Ji=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_float_abs_z:a,a_float_is_pivot:l})},c_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:r,a_vec2_dem_position:a,a_float_abs_z:l,a_float_is_pivot:c})},lr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec4_color:a})},d_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec2_wall_size:a,a_vec2_quad_fraction:l,a_vec4_color:c})},cr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec4_color:a})},dr=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}),r=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:8,normalized:!0}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new V(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},_r=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}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1}),a=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:16,normalized:!0});return new V(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},ur=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}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new V(t,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r})},__=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec4_color:a})},u_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r})},hr=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:24,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:24,offset:4,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:24,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:24,offset:10,normalized:!1}),l=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:24,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:24,offset:15,normalized:!1}),d=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:24,offset:16,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:24,offset:20,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_normal:r,a_vec2_normal_delta:a,a_vec3_direction:l,a_float_distance:c,a_vec2_dem_position:d,a_vec4_color:_})},h_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),a=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 V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:r,a_vec2_check_offset:a,a_vec2_texcoord:l,a_vec2_range:c,a_vec4_tex_identifier:d})},f_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),a=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 V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:r,a_vec2_texcoord:a,a_vec2_range:l,a_vec4_identifier:c})},m_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:40,offset:12,normalized:!1}),a=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 V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_offset:r,a_vec2_texcoord:a,a_vec2_range:l,a_vec4_identifier:c})},p_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:16,offset:12,normalized:!0});return new V(e,{a_vec4_position:i,a_vec2_offset:o,a_vec4_identifier:r})},fr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:10,normalized:!1});return new V(e,{a_vec2_position:i,a_vec2_direction:o,a_vec2_widen_direction:r})},v_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_texcoord:r,a_vec2_dem_position:a})},g_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},y_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},x_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r})},b_=(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 V(e,{a_vec2_vertex:i,a_vec4_direction_distance:o})},ro=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:20,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:20,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:20,offset:16,normalized:!0});return new V(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:r,a_vec2_dem_position:a,a_vec4_color:l})},mr=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:36,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_vec2_segment_end:o,a_vec4_texture_widen_arrow_widen:r,a_vec2_widen:a,a_vec2_direction:l,a_float_distance_from_start:c,a_float_object_length:d,a_float_type:_,a_vec4_identifier:u})},ao=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1});return new V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_widen:r})},w_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new V(e,{a_vec3_flat_position:i,a_vec3_ecef_position:o,a_vec2_widen:r,a_vec4_identifier:a})},S_=(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 V(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},T_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new V(e,{a_vec2_position:i,a_vec2_widen:r,a_float_weight:o})},M_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new V(e,{a_vec2_position:t})},pr=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:12,offset:0});return new V(e,{a_vec3_position:i})},Ai=(s,e)=>new V(e,{a_vec2_position:s}),pi=(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 V(e,{a_vec2_vertex:i,a_float_height:o})},E_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!0});return new V(e,{a_vec2_vertex:i,a_vec2_centroid:o,a_vec2_extender:r})},lo=(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 V(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},en=s=>(e,t,i,o)=>{const r=n.GltfModelGenerator.sinks.instances.stride,a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:r,offset:0,normalized:!0,instanceDivisor:1}),l=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:r,offset:4,normalized:!1,instanceDivisor:1}),c=new n.BufferChannel(e,{itemSize:3,dataType:n.Buffer.Short,stride:r,offset:8,normalized:!0,instanceDivisor:1}),d=new n.BufferChannel(e,{itemSize:9,dataType:n.Buffer.Float,stride:r,offset:16,instanceDivisor:1}),_=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:r,offset:s?56:52,normalized:!0,instanceDivisor:1}),u=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:r,offset:60,normalized:!1,instanceDivisor:1});return new V(t,z({a_vec2_instance_position:a,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)},co=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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 V(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_extender:r,a_vec3_normal:a,a_float_gradient:l,a_vec2_dem_position:c,a_float_abs_z:d,a_float_is_pivot:_})},I_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new V(e,{a_vec2_vertex:t})},vi=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1});return new V(e,{a_vec2_vertex:t})},vr=(s,e,t)=>{const i=n.GlobeGenerator.sinks.fill.stride;return new V(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)},C_=(s,e)=>new V(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})}),Xt=32,gr=1/0,L_="raster";class yr extends n.TileObjectBase{constructor(e,t,i){var r;super(L_),this.children=[],this.identifyChildren=[];const o=this;this.setTileCoords(e,t.map.state),(r=t.renderer.symbolSettingsList.dem.mesh)==null||r.forEach(a=>{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:Xt*Xt*6,attributesHash:"",layerSettings:a,vao:i.mesh,canRender:!0,renderingProperties:{flatTexture:null,hillshadeTexture:null,flatIdentifyTexture:null}};a.identify?o.identifyChildren.push(l):a.depthTest?o.depthTestChildren.push(l):a.shadow?o.shadowChildren.push(l):a.dem?o.demChildren.push(l):a.demGround?o.demGroundChildren.push(l):o.children.push(l)})}setTileCoords(e,t){const i=e[2],o=e[3],r=n.tileZoomToSize(i);this.coords=e,this.size=r,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/Xt;this.bounds.clear(),this.modelMatrices.clear(),e.forEach(o=>{const r=[this.coords[0]+o*t,this.coords[1],this.coords[2],this.coords[3]],a=n.tileCoordsToMapPoint(r);a[0]-=i,a[1]-=i,this.bounds.set(o,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const l=n.create$2();n.fromTranslationScale(l,a,n.fromValues(this.size+i,this.size+i,n.tileHeight)),this.modelMatrices.set(o,l)}),this.needSync=!1}}class P_{constructor(e,t){var r;this.meshTiles=new Map,this.destroyed=!1,this.modules=e.modules,this.maxZoom=(r=t==null?void 0:t.maxZoom)!=null?r:gr;const i=[];for(let a=0;a<Xt;a++)for(let l=0;l<Xt;l++)i.push(l,a,l+1,a,l,a+1),i.push(l,a+1,l+1,a,l+1,a+1);const o=n.maxUint16Value/Xt;for(let a=0;a<i.length;a++)i[a]*=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:Ai(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=gr){e!==this.maxZoom&&(this.maxZoom=e,this.update())}update(){if(this.destroyed)return;const e=this.modules.map.state;e.needReplicasUpdate&&this.meshTiles.forEach(r=>{r.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((r,a)=>(r.set(n.coordsToKey(a),a),r),new Map);this.meshTiles.forEach((r,a)=>{o.has(a)||this.meshTiles.delete(a)}),o.forEach((r,a)=>{this.meshTiles.has(a)||this.meshTiles.set(a,new yr(r,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 B_{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[r,a,l]=n.tileCoordsToOSM(o);return this.options.url(r,a,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 r=n.getTileBounds(t);this.tree.remove({minX:r.min[0],minY:r.min[1],maxX:r.max[0],maxY:r.max[1]},(a,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 q(this,null,function*(){const i=[],o=[],r=n.coordsToKey(t),a=this.tiles.get(r);if(!a)return Promise.resolve({results:i,transferable:o});const l=this.modules.map.state.handyStyleId,{collector:c}=this.modules,d=n.tileZoomToSize(t[2]),_=a.bounds;this.tree.insert(de(z({key:r,minX:_.min[0],minY:_.min[1],maxX:_.max[0],maxY:_.max[1],cellSize:d/n.DEM_ELEVATION_TILE_SIZE},a),{tree:null,bounds:_,generated:i})),this.updateMinElevation(),this.updateRevision();do n.DemGenerator.generateMeshElevation(c,a.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,r,a]=t,l=new Uint8Array(e),c=new Float32Array(We(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),r,a])),p=n.Mercator.scaleFactor(m[1]);for(let v=0;v<u;v++){const x=v+f*u,g=(l[x]+l[We(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,r,a])}}}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,r)=>!o||o.cellSize>r.cellSize?r: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 r=e.elevation*n.MAP_POINTS_IN_METER/t+1,a=Math.max(e.pitch/e.maxPitch*30,4);n.scale$1(i,Math.min(r,a))}const o=this.tree.search({minX:i.min[0],minY:i.min[1],maxX:i.max[0],maxY:i.max[1]});e.styleZoom-bo>1?this.minElevation=o.reduce((r,a)=>{if(a.data){const l=n.intersection(i,a.bounds);n.sub(l.min,l.min,a.bounds.min),n.sub(l.max,l.max,a.bounds.min),n.scale$2(l.min,l.min,1/a.cellSize),n.scale$2(l.max,l.max,1/a.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=a.data[_];r=r===void 0?u:Math.min(r,u)}}return r},void 0):this.minElevation=o.reduce((r,a)=>r===void 0?a.minZ:Math.min(r,a.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(r=>(r.rejected||this.tiles.set(t,r.data&&r.data.byteLength?this.unpackRaw(r.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),r=new Uint16Array(i*6);let a=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&&(r[a++]=d+1,r[a++]=d,r[a++]=d+t,r[a++]=d+1,r[a++]=d+t,r[a++]=d+t+1)}return{positions:o,heights:e,indices:r}}}class z_{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,(r,a)=>i===a.key),this.tiles.delete(i))}this.updateMinElevation()}fetchTiles(e){return this.worker.fetchTiles(e)}generateTile(e,t){return q(this,null,function*(){const i=n.coordsToKey(t),{tree:o,results:r,minZ:a,maxZ:l}=yield this.worker.generateTile(e.handyStyleId,t),c=n.getTileBounds(t),d={generated:r,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:a,maxZ:l,tree:o};return this.tiles.set(i,d),this.tree.insert(d),this.updateMinElevation(),this.updateRevision(),{results:r}})}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,r)=>!o||o.cellSize>r.cellSize?r: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,r)=>o===void 0?r.minZ:Math.min(o,r.minZ),void 0)}getRevision(){return this.revision}updateRevision(){this.revision++}}const Xe=new Float64Array(16);class _o{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(Xe,this.texMatrix),this.viewport.forEach(o=>{n.transformMat4$1(o,o,Xe),o[0]-=t[0],o[1]-=t[1],o[2]-=t[2],o[2]>=0&&(o[2]=-1),n.normalize(o,o);const r=-t[2]/o[2];o[0]=t[0]+o[0]*r,o[1]=t[1]+o[1]*r,o[2]=t[2]+o[2]*r})}}class R_{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:r,extendedTilesBounds:a,zoom:l,cameraConfig:c,globeMode:d}=this.modules.map.state,_=n.getLineConstants(a[0],a[1]),u=n.pointToLineDistance(a[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:r,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(Xe,[0,-b,0],[1/Re[0],1/Re[1],1]),n.multiply(Xe,Xe,m.viewProjectionMatrix),this.textures.push(new _o(Xe,m.position,0)),n.pointToLineDistance(this.textures[0].viewport[2],_)>=u)return!0;if(y<b){const S=Math.max(Math.abs(y-b)/2,1);n.fromTranslationScale(Xe,[0,2/S+1,0],[1/Re[0],Re[1]/S,1]),n.multiply(Xe,Xe,m.viewProjectionMatrix),this.textures.push(new _o(Xe,m.position,1))}b+=1;const M=Math.pow(o[1]/749,2);[1.4,3.2,12,31].some((S,P)=>{S=(S-1)*p*M+1,n.fromTranslationScale(Xe,[0,-(b*S+1),0],[1/Re[0],S/Re[1],1]),n.multiply(Xe,Xe,m.viewProjectionMatrix),b+=2/S;const T=this.textures.push(new _o(Xe,m.position,P));if(n.pointToLineDistance(this.textures[T-1].viewport[2],_)>=u)return!0})}destroy(){this.textures=[]}}const uo={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({},uo,i)};const e=Object.assign({},uo,s);return()=>e},ge=ce({}),ho=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),F_=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}}),Kt=ce({depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),D_=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},cullFace:!1}),Fe=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:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},blendEquation:n.BLEND_EQUATION.MAX}),N_=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA,dfactor:n.BLEND_FUNC.ONE}}),xr=ce({depthMask:!1,depthTest:!1,colorMask:[!0,!1,!1,!0]}),k_=ce({depthMask:!1,depthTest:!1}),Mt=ce({depthMask:!1,depthTest:!1}),br=ce({depthMask:!1}),tn=ce({colorMask:[!1,!1,!1,!1]}),U_=ce({colorMask:[!1,!1,!1,!1],depthFunc:n.DEPTH_FUNC.ALWAYS}),wr=ce({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),H_=ce({depthFunc:n.DEPTH_FUNC.EQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),fo=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),mo=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}}),po=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}}),Sr=ce({polygonOffsetFill:!0,polygonOffset:{factor:1,units:2},blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),nn=ce({cullFaceMode:n.CULL_FACE_MODE.BACK}),on=ce({cullFace:!1}),Tr=ce({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE}}),G_=ce({depthTest:!1,cullFace:!1}),V_=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}}),Mr=ce({colorMask:[!0,!0,!0,!0],depthMask:!0}),Z_=ce({colorMask:[!0,!0,!0,!0],depthMask:!1}),j_=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}}),W_=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}}),$_=ce({depthMask:!0,depthTest:!0}),Er=ce(s=>s.map.getFeatureFlag("transparentBuildingsOff")?ge(s):H_(s)),X_=ce(()=>({depthFunc:n.DEPTH_FUNC.LEQUAL,depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}})),vo=n.reserveTextureIndex(),go=n.reserveTextureIndex(),yo=n.reserveTextureIndex(),xo=n.reserveTextureIndex(),Et=64,Ir=5,bo=12,Cr=5,Lr=15,K_=18,q_=12,Y_=18,Q_=.1,J_=.3,Re=[1.7,1],A_=300,wo=.001,Pr=1,eu=n.tileZoomToSize(n.tiles.maxRegionalZoom),tu={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"]}},sn=n.create$1(),Oe=new Float64Array(16);class iu{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=wo,this.reliefTileType="vector",this.elevationSourceType="irregular",this.groundBuffer=new Float32Array,this.differ=new n.Differ([])}enable(){if(this.isTerrainSupported===void 0&&(this.isTerrainSupported=Gs()),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,r,a,l]=i;return t.push(o*n.maxUint16Value,r*n.maxUint16Value,n.packTexCoords(a),n.packTexCoords(l)),t},[]))),this.hillshadeVao=lo(this.fullscreenBuffer,this.modules.renderer.getShaderProgram("demHillshade"));const e=this.modules.renderer.getShaderProgram("demElevationCopy");this.copyDemVao=lo(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,r;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(),(r=this.fullscreenBuffer)==null||r.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=wo,this.isAnimationStarted=!1,n.exist("changeScale",e)&&n.stop("changeScale",e)}update(){var o,r,a,l;if(!this.enabled)return;const e=this.modules.map.state;this.lastStyleId!==e.handyStyleId&&(this.updateRampTextureId(),(o=this.meshSource)==null||o.updateStyleId(),(r=this.hillshadeTile)==null||r.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(),(a=this.flatMapSource)==null||a.update(),(l=this.meshSource)==null||l.update(),this.updateDemFramebufferMatrix(),this.modules.renderer.addRerenderEvent()),this.disableAnimation||(this.isAnimationStarted?n.update("changeScale",{step:(c,d)=>{d===Pr&&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(r=>r.type===n.PreLabelType.Point),t)break;if(!t)return;n.vertexTilePointToMapPoint(sn,t.vertices,0,n.createTileInfo(t.tileCoords));let i;for(let o=this.sources.length-1;o>=0;o--){const a=this.sources[o].getElevationTile(sn);if(a!==void 0){i=a;break}}if(i)return i.key}enrichWithElevation(e){var t;if(this.enabled)for(const i of e){let o=null;for(const r of i.labels)r.type===n.PreLabelType.Point&&(o||(o=n.createTileInfo(r.tileCoords)),n.vertexTilePointToMapPoint(sn,r.vertices,0,o),r.demElevation=(t=this.getElevation(sn))!=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(vo),this.modules.renderer.disableTexture(xo),this.modules.renderer.disableTexture(go),this.modules.renderer.disableTexture(yo)}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,r=e[1]-this.modules.map.state.viewport.top;if(o<0||o>i[0]-1||r<0||r>i[1]-1)return;const l=((i[1]-r-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,wo,Pr,A_,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=nu(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 R_(this.modules.map)}addRegularElevationSources(){var a;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:Ir,maxZoom:8,attributes:{}}),this.addElevationSource({url:t,minZoom:i?9:Ir,maxZoom:bo,attributes:{}}),this.meshSource=new P_(this.modules.map,{maxZoom:this.meshMaxZoom});const o=this.hillshadeVao,r=(a=this.modules.renderer.symbolSettingsList.dem.hillshade)==null?void 0:a[0];if(o&&r){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:r,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=tu[this.tileSet])!=null?o:this.modules.map.state;this.addIrregularElevationSource({tileServer:e,tileProtocol:t,subdomains:i,tileSet:this.tileSet,minZoom:Cr,maxZoom:Lr})}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 B_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,r=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t);this.modules.tileManager.addTileLayer(r),this.tileLayers.push(r)}addIrregularElevationSource(e){const t=new z_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,r=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t,{useExtendedTilesBounds:!0});this.modules.tileManager.addTileLayer(r),this.tileLayers.push(r)}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),Et)}createGroundFramebuffer(){const e=this.modules.map.state.size,t=[0,0,0,0],i=new Te({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()*Et;const t=new Te({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()*Et;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()*Et;const i=new Te({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()*Et;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(xr);const r=0;this.modules.renderer.enableTexture(o,r);const a=this.modules.renderer.getShaderProgram("demElevationCopy");this.modules.renderer.enableShaderProgram(a),this.modules.renderer.bindShaderProgram(a,{u_mat4_mvp:n.TEXTURE_COORDS_TO_WEBGL,u_sr2d_texture:r,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()*Et;const t=new Te({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()*Et;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 Te({size:[Math.trunc(t[0]*Re[0]*e),Math.trunc(t[1]*Re[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]*Re[0]*e),Math.trunc(o[1]*Re[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 Te({size:[Math.trunc(e[0]*Re[0]*n.identify.pixelDensity),Math.trunc(e[1]*Re[1]*n.identify.pixelDensity)],magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:Ht,onResize:()=>{const i=this.modules.map.state.size;t.setSize([Math.trunc(i[0]*Re[0]*n.identify.pixelDensity),Math.trunc(i[1]*Re[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"?q_:K_),o=n.tileZoomToSize(i),r=o*this.getDemTextureSize(),a=o/Et,l=[Math.trunc(e.center[0]/a)*a+a/2,Math.trunc(e.center[1]/a)*a+a/2],c=[l[0]-r/2,l[1]-r/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(r/2-_-a-eu/2,0),h=Math.min(u,(r/2-_-a)*Math.sin(e.pitch/e.maxPitch*(Math.PI/2)));h>0&&(n.scale$2(d,d,h),d[0]=Math.trunc(d[0]/a)*a,d[1]=Math.trunc(d[1]/a)*a,n.sub(c,c,d)),n.fromTranslationScale(Oe,c,[r,r,n.tileHeight]),n.invert(this.demTextureMatrix,Oe),n.multiply(this.demFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,this.demTextureMatrix);const f=Math.min(t,Y_);this.demCorrectedScale=We(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 nu(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=[],r=t-1;for(let a=0;a<t;a++){const l=a/r,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 Br=new Float32Array(16),It=(s,e,t,i)=>{t=Eo(t,s,e),t.length>0&&s.metrics.firstcontent===void 0&&(s.metrics.firstcontent=performance.now()-s.metrics.start),Fr(t,i),s.globeMode&&s.globeReady?ou(s,e,t,i):So(s,e,t,i)},ou=(s,e,t,i)=>{const o=[],{environmentManager:r}=e,a=e.styleManager.getStyle(s.handyStyleId);if(!a||!a.environment)return;const c=n.makeBinderContext(s.styleZoom,s.styleState,[]),d=n.getColorForShaders(n.resolveColor(a.background.color,c));r.renderStars(),r.renderGlobeHaloBackground(),_u(t).forEach(_=>{if(!_.globeTile){Mo(_.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=We(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(Br,[2*v+y,2*x+y,0],[4*g,4*g,1]),u.tile.setMvpMatrix(Br)}),Mo(_.children,s,e).forEach(u=>rn(s,e,u,i)),i.useCanvas(),rn(s,e,_.globeTile.children,i)}),r.renderGlobeHalo(),o.forEach(_=>{rn(s,e,_,i)})},So=(s,e,t,i)=>{Mo(t,s,e).forEach(o=>rn(s,e,o,i))},rn=(s,e,t,i)=>{mu(e.styleManager,t,s,e).forEach(o=>{Rr(e.styleManager,o[0])?su(s,e,o,i):zr(s,e,o,i)})},su=(s,e,t,i)=>{const o=Rr(e.styleManager,t[0]);if(!o)return;const r=(a,l)=>{l>=o.orderBy.length?zr(s,e,a,i):vu(o.orderBy[l],a,s,e).forEach(c=>r(c,l+1))};r(t,0)},zr=(s,e,t,i)=>{t.sort((o,r)=>o.tile.zoomLevel-r.tile.zoomLevel),fu(e.styleManager,t,s,e).forEach(o=>ru(s,e,o,i))},ru=(s,e,t,i)=>{pu(t,s,e).forEach(o=>au(s,e,o,i))},au=(s,e,t,i)=>{var l;const o=t[0],r=wu(e.styleManager,o);if(!r||((l=r==null?void 0:r.style)==null?void 0:l.visibility)==="hidden")return;const a=r.selectedIdx;a!==void 0&&t.sort((c,d)=>{var h,f;const _=Number((h=c.attributes.tileData[a])!=null?h:0),u=Number((f=d.attributes.tileData[a])!=null?f:0);return _-u}),o.type===n.SceneObjectType.Custom?(i.useCustomLayerState(r),e.styleManager.callCustomLayerRender(o.attributes.layerId)):gu(t,s,e).forEach(c=>lu(s,e,c,i,r))},lu=(s,e,t,i,o)=>{i.useProgram(t[0],o),yu(t,s,e).forEach(r=>{cu(s,e,r,i,o)})},cu=(s,e,t,i,o)=>{i.useState(t[0],o),xu(t,s,e).forEach(r=>{i.drawSymbol(r,o,s,e)})};function Rr(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 du=(s,e)=>Number(s)-Number(e),qt=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 r=Object.keys(o);r.sort(du);const a=[];for(let l=0;l<r.length;l++)a.push(o[r[l]]);return a},To=s=>(e,t,i)=>{const o=new Map;for(let r=0;r<e.length;r++){const a=e[r],l=s(a,t,i);o.has(l)?o.get(l).push(a):o.set(l,[a])}return o},_u=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 r of i)r.globeTile&&n.isTilesIntersects(r.globeTile.coords,o.tile.coords)&&r.children.push(o);return i.push(t),i},Mo=qt(s=>{const{styleId:e}=s.attributes;return e===n.DYNAMIC_STYLE_ID?1:-e}),uu=(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},hu=(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},fu=(s,e,t,i)=>qt(o=>hu(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),mu=(s,e,t,i)=>qt(o=>uu(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),pu=qt(s=>s.type===n.SceneObjectType.Custom?0:s.layerSettings.subRenderIndex||0),Fr=(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))})},vu=(s,e,t,i)=>qt((o,r)=>{const a=n.makeBinderContext(r.styleZoom,r.styleState,o.attributes.tileData);return n.resolveNumber(s,a,0)})(e,t,i),gu=To(s=>{var e;return(e=s.shaderDefinitions)!=null&&e.hash?s.layerSettings.programName+"_"+s.shaderDefinitions.hash:s.layerSettings.programName}),yu=To(s=>s.layerSettings.stateBinder),xu=To(s=>s.sink+"_"+s.attributesHash+"_"+s.tile.readiness),bu=qt(s=>s.tile.zoomLevel);function wu(s,e){const t=s.getStyle(e.attributes.styleId);if(t)return t.layersById[e.attributes.layerId]}function Eo(s,e,t){for(const i of s)i.type!==n.SceneObjectType.Custom&&(i.canRender=Su(i,t,e));return s.filter(i=>i.canRender)}function Su(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 Dr=[0,0,0,0],gt=(s,e,t,i,o,r)=>{const a={terrain3d:!!o,noEffects:!!r,drawSymbol:(l,c,d,_)=>{const u=l[0];if(u)if(Tu(u)&&(c.type==="overpass"||c.type==="tunnel"||c.type==="gltfModel")&&!u.layerSettings.shadow){let h;c.type==="gltfModel"&&(h=Dr),a.renderTierTexture(u,c,!1,h),a.useProgram(u,c),a.useState(u),Io(l,c,d,_,a),d.hiddenImmersiveRoutesEnabled&&!u.layerSettings.identify&&c.type!=="gltfModel"&&(a.renderTierTexture(u,c,!0),a.useProgram(u,c),_.renderer.applyGpuState(F_,c),Io(l,c,d,_,a))}else Io(l,c,d,_,a)},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,r),d==null||d(f,s,e,c,r)},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,r)}},useState:(l,c)=>{e.renderer.applyGpuState(l.layerSettings.stateBinder,c)},useCustomLayerState:l=>{e.renderer.applyGpuState(G_,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=gt(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?Ht:Dr;e.renderer.clearWithColor(b,!0,-1)}else if(m)e.renderer.clearWithColor(Ht,!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(S=>{var P,T;S.updateMvpMatrix((T=(P=v.getViewProjectionMatrix)==null?void 0:P.call(v))!=null?T:e.camera.viewProjectionMatrix,void 0)});const b=d?y.objects.filter(S=>{var P;if(S.type!==n.SceneObjectType.Custom){if(S.layerSettings.stateBinder(e).depthTest&&!S.layerSettings.isOverlappedObject)return!0;const T=e.styleManager.getStyleLayer(S.attributes.styleId,S.attributes.layerId);if(T)return((P=T.gpuState)==null?void 0:P.depthTest)===!0}return!1}):y.objects,M=Eo(b,s,e);So(s,e,M,x),y.tileObjects.forEach(S=>S.updateMvpMatrix(e.camera.viewProjectionMatrix)),Fr(y.objects,a)}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)=>gt(s,e,t,l,c,d)};return a},Io=(s,e,t,i,o)=>{const r=s[0],a=r.layerSettings,l=i.renderer.getShaderProgram(a.programName,r.shaderDefinitions);a.objectBinder(l,t,i,r,e,o.terrain3d),r.layerSettings.zoomBinder?bu(s,t,i).forEach(c=>{var d,_;l&&((_=(d=r.layerSettings).zoomBinder)==null||_.call(d,l,t,i,c[0],e,o.terrain3d)),c.forEach(u=>Or(u,i,l,t,o,e))}):s.forEach(c=>Or(c,i,l,t,o,e))},Or=(s,e,t,i,o,r)=>{var c;const{renderer:a}=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,r,o))continue;a.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?a.drawInstancedElements(m,h,p,u,f):a.drawElements(m,h,p,u):f?a.drawInstancedArrays(m,u,h,f):a.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=a.triangleCountByDrawMode(m,h);i.stats.triangleCount+=(f!=null?f:1)*v}}};function Tu(s){return s.symbol==="mapMesh"||s.symbol==="gltfModel"&&s.attributes.meshTier!==void 0}const Nr=n.create$1(),Mu=n.create$1(),kr=n.create$2(),Co=n.create$1(),Eu=n.fromValues(0,0,1),Iu=n.create$1(),Cu=.3,Lu=1/2e7,Pu=.01,Bu=[1,1,1,1],Ur=n.reserveTextureIndex();class zu{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=We(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($t())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 T in o){const C=o[T];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 r=this.shadowLightDir&&!this.modules.map.getFeatureFlag("shadowsOff");if(r?this.renderTarget||(this.renderTarget=this.createRenderTarget()):this.renderTarget&&this.renderTarget.remove(),!r||!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const a=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*Lu*Math.sqrt(c),this.bias=Math.min(this.bias,Pu);let _=1;if(this.adaptiveVerticalSize){const T=Math.abs(n.dot(this.shadowLightDir,Eu));_=Math.max(T,Cu)}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(Co,m,this.shadowLightDir);const p=kr;n.lookAt(p,Iu,this.shadowLightDir,Co);const v=n.transformMat4$1(Nr,a,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(Mu,y,b!=null?b:n.identity(kr)),S=n.add$1(Nr,M,this.shadowLightDir);n.lookAt(this.shadowMatrix,M,S,Co),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=gt(this.mapState,this.modules,void 0,this.renderTarget,t),o=new Set,r=[];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 _=ir(d,this.modules,this.mapState);!_||_.lightConfig.shadowLightIndex===-1||(r.push(c),o.add(l))}const a=t?this.modules.demManager.demTextureMatrix:void 0;o.forEach(l=>{l.updateMvpMatrix(this.shadowMatrix,a)}),this.modules.renderer.bindRenderTarget(this.renderTarget),this.modules.renderer.applyGpuState(Mr),this.modules.renderer.clearWithColor(Bu,!0),this.modules.renderer.setViewport(0,0,this.renderTarget.options.size[0],this.renderTarget.options.size[1]),It(this.mapState,this.modules,r,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=vi(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(Mt),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(z({},e),{"--sum":n.getTotalMemory(e)})}}createRenderTarget(){const e=[this.shadowMapParams[0],this.shadowMapParams[1]];return this.modules.renderer.isDepthTextureSupported()?new Te({size:e,magFilter:w.LinearFilter,minFilter:w.LinearFilter,depthTexture:!0,hasColorOutput:!1,compareFunc:w.CompareRefToTexture}):new Te({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 Hr{constructor(e,t,i){this.output=e,this.input=t,this.modules=i,this.enabled=!0}}class Ru extends Hr{constructor(e,t,i,o){super(e,t,i),this.name=Yt.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!==Qt.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=vi(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,r=i.base3;t.push([0,0]);for(let a=0;a<o.length;++a)t.push([2*o[a]-1,2*r[a]-1]);return t}}class Fu extends Hr{constructor(e,t,i,o){super(e,t,i),this.name=Yt.FXAA,this.vao=null,this.buffer=o}onBeforeRender(e){this.enabled=e.aaMode===Qt.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=vi(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 Yt=(s=>(s.TAA="TAA",s.FXAA="FXAA",s))(Yt||{}),Qt=(s=>(s[s.TAA=0]="TAA",s[s.FXAA=1]="FXAA",s))(Qt||{});class Du{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 r=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=vi(r,this.copyColorProgram),this.copyColorDepthVao=vi(r,this.copyColorDepthProgram);const a=this.createRenderTarget(this.renderTargetSize,{useHighDepthPrecision:!0});this.mainFrameBufferWrapper={renderTarget:a,onResize:()=>{},clearColor:n.getColorForShaders(e.defaultBackgroundColor),clearDepth:!0};const l=e.aaMode===0,c=e.aaMode===1,d=l?Ru:c?Fu:null;if(d){const _=this.createRenderTarget(this.renderTargetSize),u=new d(_,a,t,r);this.effectsByType[l?"TAA":"FXAA"]=u,this.renderGraph.push(u)}}update(){this.renderGraph.forEach(e=>e.onBeforeRender(this.state))}render(){this.modules.renderer.applyGpuState(V_),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(z({},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,r=window.devicePixelRatio,a=this.modules.renderer.getViewportSize();this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(o.left*r,o.bottom*r,a[0],a[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 Te(Object.assign({minFilter:w.NearestFilter,magFilter:w.NearestFilter,size:e},t))}}const Ou=[0,0];function pe(...s){return(e,t,i,o,r)=>{s.forEach(a=>a(e,t,i,o,r))}}const oe=(s,e,t,i)=>{var m,p,v;if(!i){Vr(s,e,t);return}const o=(m=t.renderer.getFramebuffer(t.demManager.getDemFramebufferId()))==null?void 0:m.renderTarget.getTexture(),r=(p=t.renderer.getFramebuffer(t.demManager.getCorrectedDemFramebufferId()))==null?void 0:p.renderTarget.getTexture(),a=t.imageManager.getTexture(t.demManager.getHillshadeRampTextureId()),l=o==null?void 0:o.options.size,c=t.styleManager.getStyle(e.handyStyleId);if(!o||!r||!a||!c||!l){Vr(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"?bo:Lr))*Et);t.renderer.enableTexture(o,vo),t.renderer.enableTexture(a,yo),t.renderer.enableTexture(r,xo);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:vo,u_tex_corrected_dem:xo,u_tex_hillshade_ramp:yo,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})},Gr=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_shading_intensity:0})},Vr=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_scale:0})},an=oe,ln=pe(ut,Ki),Zr=fi,Nu=pe(Qs,Ki,ut,tr,oe),jr=pe(Qs,Ki,Wd,oe),Wr=pe(ut,Ki,tr,oe),ku=fi,ot=(s,e,t,i,o)=>{const r=t.postEffectsManager.getEffectByName(Yt.TAA),a=!o&&(r!=null&&r.jitter)?r.jitter:Ou;t.renderer.bindShaderProgram(s,{u_vec2_camera_jitter:a})},Ue=(s,e,t)=>{const i=t.shadowManager.texture;i&&(t.renderer.enableTexture(i,Ur),t.renderer.bindShaderProgram(s,{u_texture_shadow:Ur}))},Uu=(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)})},Hu=pe(oe,ot,Ue),Gu=pe(ot,Ue),cn=pe(oe,ot,Ue),Vu=fi,Zu=pe(oe,ot,Ue),$r=pe(ot,Ue),ft=pe(oe,ot,Ue),Xr=pe(oe,Ue),Jt=pe(oe,ot,Ue),Kr=pe(fi,As,er),qr=pe(fi,As,er,Ue),ju=pe(oe,qr),Wu=pe(oe,Kr),Lo=pe(Ue,oe),$u=pe(oe,ot,Ue),Xu=pe(ot,Ue),Yr=pe(ot,Ue),Ku=pe(oe,Yr),gi=new Float32Array(2),yi=new Float32Array(2),qu=[0,0],Yu=[0,0,0,0],At=.01,Le=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_opacity:1})},Po=(s,e,{renderer:t},i,o)=>{const r=De(e,i),a=n.resolveNumber(o.style.textureOpacity,r);t.bindShaderProgram(s,{u_float_texture_opacity:i.tile.readiness*a})},Ct=(s,e,{renderer:t},i)=>{i.renderingProperties.mixFactorColor&&t.bindShaderProgram(s,{u_float_mix_color:i.renderingProperties.mixFactorColor})},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})},Qr=(s,e,{renderer:t},i)=>{var c;if(!i.renderingProperties.mixColor)return;const{color2:o,factor:r,factorInterpolate:a}=i.renderingProperties.mixColor,l=n.getColorForShaders(o);switch(n.scale$4(l,l,i.tile.readiness),r.type){case"readFromTarget":{const d=(c=t.getDrawTargetFramebuffer(r.name))==null?void 0:c.renderTarget.getTexture();if(!d)return;t.enableTexture(d,2),a?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:a.base,u_vec4_factor_interpolate_ranges:a.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}=r;n.assertUnreachable(d)}}},xi=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_mat4_gradient:i.renderingProperties.mat4_gradient})},Qu=(s,e,{renderer:t},i,o)=>{const r=n.getColorForShaders(n.resolveColor(o.style.strokeColor,De(e,i)));n.scale$4(r,r,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_border_color:r})},Ne=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:o*window.devicePixelRatio})},Jr=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_float_shift:n.resolveNumber(o.style.shift,De(e,i))*window.devicePixelRatio})},Ju=(s,e,{renderer:t},i,o)=>{const r=i.renderingProperties.opacityResolved||0,a=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!1),l=o.style.iconOpacity,c=n.resolveNumber(l,a);a.isBehind=!0;const d=e.styleState.graphicsPreset==="light"?1:n.resolveNumber(l,a);t.bindShaderProgram(s,{u_vec2_opacity:[r*c,r*d]})},Rt=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.opacityResolved||0;t.bindShaderProgram(s,{u_float_opacity:o})},Bo=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.iconRotation,De(e,i));t.bindShaderProgram(s,{u_vec2_rotation:[Math.cos(r),Math.sin(r)]})},Au=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.opacity,De(e,i));t.bindShaderProgram(s,{u_float_opacity:i.tile.readiness*r})},eh=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.opacity,De(e,i));t.bindShaderProgram(s,{u_float_opacity:r})},zo=(s,e,{assetManager:t,renderer:i},o)=>{const r=t.textures[o.attributes.atlasIndex];i.enableTexture(r,0)},ei=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.fontTexture;o&&t.enableTexture(o,0)},Ar=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.texture;o&&t.enableTexture(o,0)},th=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.rampTexture;o&&(t.enableTexture(o,1),t.bindShaderProgram(s,{u_sr2d_ramp_texture:1}))},dn=(s,e,{renderer:t},i,o)=>{const{tile:r}=i,a=n.resolveColor(o.style.gapColor,De(e,i));if(!a)return;const l=n.getColorForShaders(n.resolveColor(a,De(e,i)));n.scale$4(l,l,r.readiness),t.bindShaderProgram(s,{u_vec4_space_color:l})},_n=(s,e,{renderer:t},i,o)=>{const{styleZoom:r}=e,a=De(e,i),{tile:l}=i,c=n.getColorForShaders(n.resolveColor(o.style.color,a));n.scale$4(c,c,l.readiness),a.styleZoom=Math.floor(r);const d=Math.pow(2,n.getFractionalPart(r)),_=n.resolveNumber(o.style.dashLength,a)*d,u=n.resolveNumber(o.style.gapLength,a)*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(),ea=(s,e,{renderer:t},i,o)=>{const r=De(e,i),{tile:a}=i,{pattern:l,width:c}=i.renderingProperties;if(!l||!c)return;const d=n.getColorForShaders(n.resolveColor(o.style.color,r));switch(n.scale$4(d,d,a.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})},un=(s,e,{renderer:t},i,o)=>{const r=De(e,i),a=n.resolveNumber(o.style.tipWidth,r),l=n.resolveNumber(o.style.tipHeight,r),c=a,d=0;gi[0]=-c,gi[1]=-d,n.normalize$1(gi,gi),yi[0]=a,yi[1]=l,n.normalize$1(yi,yi);const _=n.resolveNumber(o.style.roundingRadius,r);t.bindShaderProgram(s,{u_vec2_wing_normal:gi,u_vec2_tip_normal:yi,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:_})},ta=(s,e,{renderer:t},i,o)=>{const r=De(e,i),a=n.resolveNumber(o.style.lineLength,r),l=n.resolveNumber(o.style.lineWidth,r);t.bindShaderProgram(s,{u_float_length:a,u_float_width:l,u_float_border_width:0})},ia=(s,e,{renderer:t},i,o)=>{const r=De(e,i),{tile:a,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,r));const m=n.resolveNumber(o.style.roundingRadius,r);t.bindShaderProgram(s,{u_float_width_zpt:n.resolveNumber(o.style.lineWidth,r),u_float_border_width_zpt:n.resolveNumber(o.style.strokeWidth,r),u_float_tip_movement_amplitude:n.zptToSceneDistance(h,a.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})},ih=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.modelTexture;o&&t.enableTexture(o,0)},Ro=(s,e,{renderer:t},i)=>{var o,r;return t.bindShaderProgram(s,{u_int_gltf_dem_pos:i.attributes.demPosition,u_vec2_anchor:(o=i.attributes.centroid)!=null?o:qu,u_vec4_axis:(r=i.attributes.axis)!=null?r:Yu}),!0},nh=(s,e,{assetManager:t,renderer:i},o)=>{const{styleId:r}=o.attributes,{renderingProperties:a}=o,{resolvedColorTexture:l,resolvedAoTexture:c,resolvedPbrTexture:d,resolvedMetallic:_,resolvedRoughness:u}=a,{modelId:h}=a,f=t.getModel(h!=null?h:NaN,r);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)},na=(s,e,t,i,o)=>{const{renderer:r}=t,l=r.getGlobeRenderTarget(n.globeTileScale(e.zoom,i.tile)).getTexture();return l?(r.enableTexture(l,ss),r.bindShaderProgram(s,{u_sr2d_flatmap_texture:ss}),!0):!1},hn=(s,e,{renderer:t},i,o)=>{let r=i.renderingProperties.resolvedHeightFactor||0;r=At+(1-At)*r,t.bindShaderProgram(s,{u_float_height_factor:r})},fn=(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})},Fo=(s,e,{modelLayer:t,renderer:i},o,r)=>{if(o.attributes.id===void 0)return;const a=t.getOpacity(o.attributes.id,r.minzoom),c=t.getBuildingHeight(o.attributes.id)===1?1:a;i.bindShaderProgram(s,{u_float_height_factor:c})},mn=(s,e,{renderer:t},i,o)=>{const r=De(e,i),a=n.resolveNumber(o.style.height,r);t.bindShaderProgram(s,{u_float_height_factor:n.mapHeightToTileHeight(a)})},qe=(s,e,t,i,o)=>{const{floorManager:r,buildingHeightAnimator:a,modelsScene:l,modelLayer:c,renderer:d}=t;if(i.symbol==="polygonExtrusion"&&i.attributes.floorId&&i.attributes.isFloorStack){d.bindShaderProgram(s,{u_float_height_factor:r.getFloorStackObjectHeight(i.attributes.floorId)});return}let _=a.getBuildingHeight(o.minzoom);_=At+(1-At)*_;const u=l.objectIdToKey(i.id);u&&c.setBuildingHeight(u,_),d.bindShaderProgram(s,{u_float_height_factor:_})};function De(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const pn=(s,e,{renderer:t},i)=>{const{tile:o}=i,r=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:n.zptToSceneDistance(r,o.size)/2*n.uint16ToTileCoords,u_float_width_offset:n.zptToSceneDistance(n.uint16ToTileCoords/window.devicePixelRatio,o.size)/2})},oh=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.resolvedRadius;t.bindShaderProgram(s,{u_float_radius:o*window.devicePixelRatio})},sh=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.intensity,De(e,i));t.bindShaderProgram(s,{u_float_intensity:r})},kt=(s,e,{renderer:t},i,o)=>{const r=De(e,i);let a=n.resolveNumber(o.style.textFontSize,r);if(i.symbol==="point"){const l=i.attributes.labelIndex;l===n.LabelIndex.Second&&o.style.textFontSize2?a=n.resolveNumber(o.style.textFontSize2,r):l===n.LabelIndex.Icon&&o.style.iconTextFontSize&&(a=n.resolveNumber(o.style.iconTextFontSize,r))}t.bindShaderProgram(s,{u_float_scale:a*window.devicePixelRatio/n.fonts.baseSize})},vn=(s,e,{renderer:t},i,o)=>{const r=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!!i.layerSettings.isOverlappedObject),{textFontSize:a,textColor:l,textHaloWidth:c,textHaloColor:d}=o.style,_=n.resolveNumber(a,r)/n.fonts.baseSize,u=_*window.devicePixelRatio,h=n.fonts.gamma/u,f=i.layerSettings.uniformSet,m=f==="fontHalo"?(6-n.resolveNumber(c,r)/_)/8:.75;let p;f==="fontHalo"?p=n.getColorForShaders(n.resolveColor(d,r)):p=n.getColorForShaders(n.resolveColor(l,r)),t.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:h,u_vec4_color:p})},oa=(s,e,{renderer:t},i,o)=>{const{layerSettings:r}=i,{uniformSet:a}=r,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}rh(s,t,e,i,d,u,_,h,l,a)},rh=(s,e,t,i,o,r,a,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(a,_)/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(r,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(r,_))),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})},gn=(s,e,{renderer:t},i)=>{const{attributes:o}=i,{offsetX:r,offsetY:a}=o,l=window.devicePixelRatio;t.bindShaderProgram(s,{u_vec2_offset:[r*l,a*l]})},yn=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_style_zoom:e.styleZoom})},yt=(s,e,{renderer:t},i)=>{const{tile:o}=i,{zoom:r}=e,a=n.tileSizeZpt*Math.pow(2,r-o.zoomLevel)*window.devicePixelRatio;t.bindShaderProgram(s,{u_float_tile_to_pixel_ratio:n.uint16ToTileCoords/a})},sa=(s,e,{renderer:t},i,o)=>{const{tile:r}=i,{zoom:a,styleZoom:l}=e,c=o.style.lengthUnits===n.LengthUnits.Meters,d=n.tilePointScaleFactor(n.createTileInfo(r.coords),[n.maxTilePoint/2,n.maxTilePoint/2]),_=n.uint16ToTileCoords/(n.tileSizeZpt*Math.pow(2,a-r.zoomLevel)*window.devicePixelRatio),u=c?l:Math.floor(l),h=n.tileSizeZpt*Math.pow(2,u-r.zoomLevel)*window.devicePixelRatio/(n.uint16ToTileCoords*d);t.bindShaderProgram(s,{u_vec2_scales:[h,_]})},ra=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},aa=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatIdentifyTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},la=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.hillshadeTexture;o&&(t.enableTexture(o,go),t.bindShaderProgram(s,{u_hillshade_tex:go}))},ah=(s,e,t,i)=>{const{renderer:o,demManager:r}=t,a=i.renderingProperties.demTexture;a&&(o.enableTexture(a,0),o.bindShaderProgram(s,{u_tex_dem:0,u_mat4_dem_corrected:r.demCorrectedFbVpToDemTex}))},bi=(s,e,{renderer:t},i,o)=>{let r=!0;e.globeMode||(r=!!n.resolveNumber(o.style.elevation,De(e,i))),t.bindShaderProgram(s,{u_bool_skip_height_factor:r})},Ye=(s,e,{buildingHeightAnimator:t,renderer:i},o,r)=>{let a=t.getBuildingHeight(r.minzoom);a=At+(1-At)*a,i.bindShaderProgram(s,{u_float_height_factor:a})},Qe=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0})},Do=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_int_abs_z:!1})},Oo=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_tile_size:n.tileZoomToSize(i.tile.zoomLevel)})},lh=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_vec4_color:n.LABELING_TEXTURE_DEM_MESH_COLOR})},k=(s,e,{renderer:t},i,o,r)=>{t.bindShaderProgram(s,{u_float_dem_scale:r?e.elevationScale:0})},No=(s,e,{renderer:t},i)=>{if(!i.attributes.meshTier)return;const o=i.layerSettings.identify?t.getMapMeshIdFramebufferId():t.getMapMeshFramebufferId(),r=t.getFramebuffer(o),a=r==null?void 0:r.renderTarget.getTexture(),l=r==null?void 0:r.scale;a&&(t.enableTexture(a,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)}))},st=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_identify:i.layerSettings.identify||i.layerSettings.depthTest?1:0})},ch=(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,r,a)=>{s.forEach(l=>l(e,t,i,o,r,a))}}const ti=(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]})},ii=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_floor_elevation:0})},wi=(s,e,t,i)=>{t.renderer.bindShaderProgram(s,{u_int_is_roof:i.symbol==="polygonExtrusion"&&i.sink==="topFill"?1:0})},ca=(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]})},dh=(s,e,t,i,o)=>{var p;const r=i.attributes.textureIndex,a=(p=o.style.sideTextures)==null?void 0:p[r],l=t.imageManager.getTexture(o.sideTextureIndices[r]),c=n.MAP_POINTS_IN_METER*n.tilePointScaleFactor(n.createTileInfo(i.tile.coords),[0,0]),d=l.options.size,_=[a.texturePadding[3]/d[0],a.texturePadding[0]/d[1],a.texturePadding[1]/d[0],a.texturePadding[2]/d[1]],u=a.wallPadding.map(v=>v*c),h=a.sliceSize.map(v=>v*c),f=[a.horizontal.maxInterval*c,a.vertical.maxInterval*c],m=[da(a.horizontal.mode),da(a.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:[a.horizontal.slicesCount,a.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 da(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 _h="FRAGMENT",uh="VERTEX",hh="FOG",fh="SKY",mh="METALLIC_ROUGHNESS_DEBUG",ph="PBR_TEXTURE",vh="AO_TEXTURE",gh="MAP_MESH_TEXTURE",yh="COLOR_TEXTURE",_a="ALPHA_MODE",xh="1",bh="2",ua="LIGHT_MODEL",wh="1",Sh="2",Th="DEPTH_TEXTURE_SHADOW",Mh="RENDER_SHADOWS",Eh="UBO",Ih="SCREENDOOR",Ch="ENTRANCE_ARROWS_ROUNDING",Lh="MALI_GPU",Ph="VARYINGS_LIMIT_9",ko="MIX_COLOR_MODE",Bh="1",ha="2",zh="MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME",Rh="1",Fh=n.Shader.createShaderDefinitions([{type:ko,value:Bh}]),Dh=n.Shader.createShaderDefinitions([{type:ko,value:ha}]),Oh=n.Shader.createShaderDefinitions([{type:ko,value:ha},{type:zh,value:Rh}]),Nh={value:[0,0,0]};function ve(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const kh=(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},Uo=(s,e)=>{const t=e.assetManager.textures[s.attributes.atlasIndex];return t?(s.renderingProperties.atlasTexture=t,!0):!1},fa=(s,e)=>{const t=e.imageManager.getTexture(s.attributes.textureIndex);return t?(s.renderingProperties.texture=t,!0):!1},ni=(s,e)=>{const{range:t,fontIndex:i,styleId:o}=s.attributes,r=e.styleManager.getStyle(o);if(!r)return!1;const a=r.fonts[i],l=e.assetManager.getFontTextureByName(a,t);return l?(s.renderingProperties.fontTexture=l,!0):!1},Ho=(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(),r=i==null?void 0:i.scale;return!(!o||!r)},Uh=(s,{imageManager:e})=>{const t=e.getTexture(s.attributes.rampTextureIndex);return t?(s.renderingProperties.rampTexture=t,!0):!1},Hh=(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},ma=(s,{demManager:e,renderer:t,map:i})=>{var a;if(!i.state.demMode)return!1;const o=e.getHillshadeFramebufferId(),r=(a=t.getFramebuffer(o))==null?void 0:a.renderTarget.getTexture();return r?(s.renderingProperties.hillshadeTexture=r,!0):!1},pa=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getFlatFramebufferId(),r=t.getFramebuffer(o);if(!r)return!1;const a=r.renderTarget.getTexture();return a?(s.renderingProperties.flatTexture=a,!0):!1},va=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getIdentifyFlatFramebufferId(),r=t.getFramebuffer(o);if(!r)return!1;const a=r.renderTarget.getTexture();return a?(s.renderingProperties.flatIdentifyTexture=a,!0):!1},Gh=(s,e,t,i)=>{var l,c;const{renderingProperties:o}=s,{resolvedUvIndex:r}=o,{colorTextureUvIndex:a}=i.style;return a!==void 0&&r!==a&&(((c=(l=s.meta)==null?void 0:l.availableTextureCoords)!=null?c:[])[a]&&s.vao.setAttributesAliases({texcoord_color:`texcoord_${a}`}),o.resolvedUvIndex=a),!0},Vh=(s,e,t,i)=>{var h,f;const{styleId:o,colorTexture:r,aoTexture:a,pbrTexture:l,meshTier:c}=s.attributes,{renderingProperties:d}=s,{modelId:_}=d,u=e.assetManager.getModel(_!=null?_:NaN,o);return!u||(r!==void 0&&u.textures[r]&&(d.resolvedColorTexture=r),a!==void 0&&u.textures[a]&&(d.resolvedAoTexture=a),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?Ho(s,e):!0},ga=(s,{modelsScene:e})=>{const t=e.getModelOpacity(s);return s.renderingProperties.resolvedOpacity=t,t!==0},ya=(s,{modelsScene:e})=>{const t=e.getModelHeightFactor(s);return s.renderingProperties.resolvedHeightFactor=t,t!==0},xa=(s,e,t,i)=>{const o=ve(t,s),r=n.resolveNumber(i.style.width,o);if(r===0)return!1;const a=n.resolveExpression(i.style.pattern,o);return!a||a[0]===n.LinePatternType.None?!1:(s.renderingProperties.width=r,s.renderingProperties.pattern=a,!0)},Zh=(s,e,t)=>Ko(t,s.attributes.animDirection)!==0,ba=(s,e,t,i)=>{const o=ve(t,s);return n.resolveNumber(i.style.iconOpacity,o)*Ko(t,s.attributes.animDirection)!==0},wa=(s,e)=>!e.map.getFeatureFlag("transparentBuildingsOff"),Z=(s,e,t,i)=>jh(s.tile,t,i),Sa=(s,e,t)=>{var o,r,a,l,c,d;if((o=s.meta)!=null&&o.planId&&(!t.styleState._activeFloorIds||!t.styleState._activeFloorIds.includes(s.meta.planId))||(a=(r=s.meta)==null?void 0:r.linkedIds)!=null&&a.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)))},jh=(s,e,t)=>{const{purpose:i,detailLevel:o}=s,{styleZoom:r}=e;switch(i){case"zenith":case"traffic":case"geojson":const a=o<of(i)?n.clamp(r,o,o+.99999):r;return t.minzoom<=a&&a<t.maxzoom;case"dynamicObject":return t.minzoom<=r&&r<=t.maxzoom;default:return t.minzoom<=r&&r<t.maxzoom}},Wh=(s,e,t)=>{var a;const{styleZoom:i}=t,{tile:o}=s;if(o.purpose!=="zenith"||i>n.tiles.maxUniverseZoom)return!0;let r=n.tiles.maxUniverseZoom;if(o.sourceId){const l=e.sourceStorage.getSourceById(o.sourceId);r=(l==null?void 0:l.type)==="zenith"&&(a=l.getOptions().strokeMinZoom)!=null?a:n.tiles.maxUniverseZoom}return i>r},Je=(s,e,t,i)=>{const{styleZoom:o}=t;return o>=i.minzoom&&o<i.maxzoom},Go=(s,e)=>s.attributes.id===void 0?!0:!e.modelLayer.isHidden(s.attributes.id),Vo=(s,e,t,i)=>{const o=ve(t,s);return n.resolveNumber(i.style.iconWidth,o)>0},Ta=(s,e,t,i)=>{const{layerSettings:o}=s,{uniformSet:r}=o,a=s.attributes.labelIndex,l=i.style;if(r==="fontHalo"){let{textHaloColor:c}=l;switch(a){case n.LabelIndex.Icon:c=l.iconTextHaloColor;break;case n.LabelIndex.Second:c=l.textHaloColor2;break}if(!c)return!1}return!0},xn=(s,e,t,i)=>!(s.layerSettings.uniformSet==="fontHalo"&&!i.style.textHaloColor),Zo=(s,e,t,i)=>{var l,c,d,_,u,h;const o=ve(t,s),r=i.style;if(s.symbol==="point")switch(s.attributes.labelIndex){case n.LabelIndex.Second:return((c=n.resolveNumber((l=r.textHaloWidth2)!=null?l:null,o))!=null?c:0)>0&&!!r.textHaloColor2;case n.LabelIndex.Icon:return((_=n.resolveNumber((d=r.iconTextHaloWidth)!=null?d:null,o))!=null?_:0)>0&&!!r.iconTextHaloColor;case n.LabelIndex.First:break}return((h=n.resolveNumber((u=r.textHaloWidth)!=null?u:null,o))!=null?h:0)>0&&!!r.textHaloColor},Ma=(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},rt=(s,e,t,i)=>{const o=n.resolveNumber(i.style.width,ve(t,s));return s.renderingProperties.widthResolved=o,o!==0},Si=(s,e,t,i)=>{const o=ve(t,s),r=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=r,r!==0},$h=(s,e,t,i)=>{const o=ve(t,s),r=n.resolveNumber(i.style.strokeWidth,o);if(r===0)return!1;const a=n.resolveNumber(i.style.width,o);return s.renderingProperties.widthResolved=a+r*2,!0},Xh=(s,e,t,i)=>{const o=ve(t,s),r=n.resolveNumber(i.style.strokeWidth2,o);if(r===0)return!1;const a=n.resolveNumber(i.style.width,o),l=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=a+l*2+r*2,!0},Kh=(s,e,t,i)=>{const o=ve(t,s),r=n.resolveNumber(i.style.width,o),a=n.resolveNumber(i.style.strokeWidth,o),l=n.resolveNumber(i.style.strokeWidth2,o),c=r+a*2+l*2;return s.renderingProperties.widthResolved=c,c!==0},Lt=(s,e,t)=>{const i=Ko(t,s.attributes.animDirection);return s.renderingProperties.opacityResolved=i,i!==0},qh=(s,e,t,i)=>(s.renderingProperties.resolvedRadius=n.resolveNumber(i.style.radius,ve(t,s)),s.renderingProperties.resolvedRadius>0),Ea=(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 r=ve(t,s),a=n.resolveExpression(o,r);return s.renderingProperties.mat4_gradient[0]=0,n.isStyleColor(a)?et(s,a):n.isStyleGradient(a)&&(qo(a,s.tile.readiness,s.renderingProperties.mat4_gradient),a.mixFactor&&(s.renderingProperties.mixFactorColor=a.mixFactor)),!0},jo=(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),qo(o,s.tile.readiness,s.renderingProperties.mat4_gradient),o.mixFactor&&(s.renderingProperties.mixFactorColor=o.mixFactor),s.renderingProperties.color.value[3]!==0):(s.renderingProperties.mat4_gradient[0]=0,!0)},Ia=(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 r=ve(t,s),a=n.resolveColor(i.style.sideColor,r).value,l=n.equals(o.value,a),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),s.renderingProperties.mixFactorColor=d.mixFactor,qo(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,Yh=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},Ca=(s,e,t,i)=>{const o=n.makeBinderContext(t.styleZoom,t.styleState,s.attributes.tileData,!!s.layerSettings.isOverlappedObject);return et(s,n.resolveColor(i.style.color,o)),s.renderingProperties.color.value[3]!==0},Wo=(s,e,t,i)=>(et(s,n.resolveColor(i.style.topColor,ve(t,s))),s.renderingProperties.color.value[3]!==0),bn=(s,e,t,i)=>(et(s,n.resolveColor(i.style.sideColor,ve(t,s))),s.renderingProperties.color.value[3]!==0),Ti=(s,e,t,i)=>(et(s,n.resolveColor(i.style.strokeColor,ve(t,s))),s.renderingProperties.color.value[3]!==0),Qh=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:et(s,n.resolveColor(i.style.strokeColor,ve(t,s)));break;case n.MeshFillSide.side:et(s,n.resolveColor(i.style.sideColor,ve(t,s)));break;case n.MeshFillSide.bottom:et(s,n.resolveColor(i.style.bottomColor,ve(t,s)));break;default:et(s,Nh);break}return s.renderingProperties.color.value[3]!==0},Jh=(s,e,t,i)=>(et(s,n.resolveColor(i.style.strokeColor2,ve(t,s))),s.renderingProperties.color.value[3]!==0),$o=(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},La=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const r=ve(t,s),a=n.resolveColor(i.style.strokeColor,r).value,l=n.resolveNumber(i.style.strokeWidth,r);return n.equals(o.value,a)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Ah=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const r=ve(t,s),a=n.resolveColor(i.style.topColor,r).value,l=n.resolveNumber(i.style.strokeWidth,r);return n.equals(o.value,a)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Pa=(s,e,t,i)=>{const o=n.resolveColor(i.style.sideStrokeColor,ve(t,s));return et(s,o),s.renderingProperties.color.value[3]!==0},Ae=(s,e,t,i)=>{const o=n.resolveColor(i.style.color,ve(t,s),!0),r=n.isStyleMixColor(o)?o.color1:o;if(et(s,r),n.isStyleMixColor(o)&&!(o.factor.type==="readFromTarget"&&!e.renderer.doesDrawTargetFramebufferExist(o.factor.name))){if(sf(s,o),s.renderingProperties.color.value[3]===0&&s.renderingProperties.mixColor.color2.value[3]===0)return!1;const{factor:{type:a,name:l}}=s.renderingProperties.mixColor;switch(a){case"readFromTarget":{s.shaderDefinitions=Fh;break}case"vertexAttribute":{switch(l){case"denormalized_distance_to_line":s.shaderDefinitions=Oh;break;default:s.shaderDefinitions=Dh;break}break}default:n.assertUnreachable(a)}return!0}return s.renderingProperties.color.value[3]!==0},ef=(s,e,t,i)=>{et(s,n.resolveColor(i.style.color,ve(t,s)));const{color:o,resolvedOpacity:r}=s.renderingProperties;return n.mul(o.value,o.value,s.attributes.colorFactor),o.value[3]*=r!=null?r:0,o.value[3]!==0},Ba=(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 r=s==null?void 0:s.tile.ids;return!(r!=null&&r.isHidden(t,n.HideLevel.PolygonExtrusion))},Xo=O(Z,Ba,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,Sa,ga,ya,ef),tf=O(Z,Ba,fe,Sa,ga,ya),za=O(Gh,Vh),nf=(s,e,t,i)=>{var l;const o=s.attributes.textureIndex,r=(l=i.style.sideTextures)==null?void 0:l[o],a=e.imageManager.getTexture(i.sideTextureIndices[o]);return!!r&&!!a};function O(...s){return(e,t,i,o)=>{for(const r of s)if(!r(e,t,i,o))return!1;return!0}}function of(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 Ko(s,e){return e===n.LabelingAnimation.none?1:e===n.LabelingAnimation.fadeIn?s.labelingOpacity:1-s.labelingOpacity}function qo(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],r=n.getColorForShaders(o);n.scale$4(r,r,e),t[i+1]=s.steps[i];const a=(i+1)*4;t[a]=r[0],t[a+1]=r[1],t[a+2]=r[2],t[a+3]=r[3]}}function et(s,e){s.renderingProperties.color||(s.renderingProperties.color=n.toStyleColor([255,255,255,255])),n.copy$1(s.renderingProperties.color.value,e.value),e.mixFactor&&(s.renderingProperties.mixFactorColor=e.mixFactor)}function sf(s,e){s.renderingProperties.mixColor=e}function Ra(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 Fa(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 wn(s,e="image/png"){const t=new Blob([s],{type:e}),i=URL.createObjectURL(t),o=document.createElement("img");return new Promise(r=>{o.onload=()=>{URL.revokeObjectURL(i),r(o)},s.byteLength===0?o.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=":o.src=i})}function Da(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 Oa(s,e,t){var _;const i=e[s.outputBufferView],o=(_=t.get(s.actionId))!=null?_:-1,r=Math.ceil(o),a=Math.floor(o),l=(o||1)%1,c=Math.round(o);return!i||t.size<=0||a<0||r<0||c<0?void 0:{outputTransforms:new Float32Array(Jo(i),s.outputBufferOffset,s.outputBufferLength),selfKeyFrame:c,selfKeyFrameMin:a,selfKeyFrameMax:r,keyFrameLerp:l}}const rf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4};function Na(s,e,t){const{outputTransforms:i,selfKeyFrame:o,selfKeyFrameMin:r,selfKeyFrameMax:a,keyFrameLerp:l}=t,c=rf[s];if(e==="STEP")return Yo(i,o,c);const d=Yo(i,r,c),_=Yo(i,a,c);switch(s){case"SCALAR":return[n.lerp$2(d[0]||0,_[0]||0,l)];case"VEC2":{const u=n.create$6();return n.lerp$1(u,d,_,l),Array.from(u)}case"VEC3":{const u=n.create$1();return n.lerp(u,d,_,l),Array.from(u)}case"VEC4":{const u=n.create$5();return n.slerp(u,d,_,l),Array.from(u)}}}function ka(s,e,t,i){let o=[0,0],r=[1,1],a=0;i&&e.forEach(u=>{if(!u.targetPointerExtension)return;const h=Oa(u,t,i);if(!h)return;const f=Na(u.outputType,u.interpolation,h);u.outputType==="SCALAR"?u.targetPointerExtension==="KHR_texture_transform/rotation"&&(a=f[0]):u.outputType==="VEC2"&&(u.targetPointerExtension==="KHR_texture_transform/offset"&&(o=f),u.targetPointerExtension==="KHR_texture_transform/scale"&&(r=f))});const l=[1,0,0,0,1,0,o[0],o[1],1],c=[Math.cos(a),Math.sin(a),0,-Math.sin(a),Math.cos(a),0,0,0,1],d=[r[0],0,0,0,r[1],0,0,0,1],_=n.multiply$1(n.create$4(),l,c);s=n.multiply$1(s,_,d)}function Ua(s,e,t,i,o){const r=Array();o&&e.forEach(a=>{if(a.targetPointerExtension)return;const l=Oa(a,i,o);if(!l)return;const c=Na(a.outputType,a.interpolation,l);(a.outputType==="VEC4"||a.outputType==="VEC3")&&(t[a.targetMatIndex[0]][a.targetMatIndex[1]]=c)});for(let a=0;a<t.length;a++){const l=t[a];if(l.length===3){const c=n.create$2();n.fromRotationTranslationScale(c,l[1],l[0],l[2]),r.push(c)}else r.push(l)}vf(s,r)}function Yo(s,e,t){if(t!==3&&t!==4&&t!==2&&t!==1)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 af(s,e,t,i){s.animations.forEach((o,r)=>{o.channels.forEach((a,l)=>{var d,_;const c=(_=(d=a.target)==null?void 0:d.extensions)==null?void 0:_.KHR_animation_pointer;if(c){const u=c.pointer,h=cf(u);if(!h){console.warn(`Unsupported pointer target "${u}" in animation "${o.name}". Skip this animation channel.`);return}const f=u.split("/");if(f[1]==="materials"&&f[2]===i){const m=o.samplers[a.sampler],p=o.name||"default",v=s.accessors[m.input];if(v.bufferView===void 0||s.bufferViews[v.bufferView]===void 0)return;Sn(e,s,v.bufferView,v.componentType);const g=s.accessors[m.output];if(g.bufferView===void 0)return;const y=s.bufferViews[g.bufferView];if(y===void 0)return;Sn(e,s,g.bufferView,g.componentType),(m.interpolation||"LINEAR")!=="LINEAR"&&(m.interpolation||"LINEAR")!=="STEP"&&console.warn(`Unsupported interpolation type "${m.interpolation}" in animation "${p}". Fall back to LINEAR interpolation.`);const b=Ha(h);t.push({min:v.min,max:v.max,frameCount:v.count,keyFrameType:"SCALAR",interpolation:m.interpolation||"LINEAR",outputType:b.outputType,outputBufferView:g.bufferView,outputBufferOffset:y.byteOffset||0,outputBufferLength:y.byteLength/b.bufferStride,targetMatIndex:[],actionId:`${o.name}_${r}_${l}`,animationIndex:r,animationName:p,targetPointerExtension:h})}}})})}function lf(s,e,t,i,o){s.animations.forEach((r,a)=>{r.channels.forEach((l,c)=>{if(l.target.node===t){const d=r.samplers[l.sampler],_=r.name||"default",u=s.accessors[d.input];if(u.bufferView===void 0||s.bufferViews[u.bufferView]===void 0)return;Sn(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;Sn(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=Ha(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:`${r.name}_${a}_${c}`,animationIndex:a,animationName:_})}})})}function cf(s){if(s.includes("KHR_texture_transform/offset"))return"KHR_texture_transform/offset";if(s.includes("KHR_texture_transform/rotation"))return"KHR_texture_transform/rotation";if(s.includes("KHR_texture_transform/scale"))return"KHR_texture_transform/scale"}function Ha(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;break;case"KHR_texture_transform/offset":e=-1,t="VEC2";break;case"KHR_texture_transform/rotation":e=-1,t="SCALAR";break;case"KHR_texture_transform/scale":e=-1,t="VEC2";break}return{targetindex:e,outputType:t,bufferStride:i}}function Sn(s,e,t,i){const o=e.bufferViews[t];if(o===void 0)return;if(!s.buffers[t]){const a=e.buffers[o.buffer].buffer;if(!a)return;s.buffers[t]=Jo(a)}const r=s.buffers[t];if(!(r instanceof n.Buffer))return r}function df(s,e){for(let t=s.length-1;t>=0;t--){const i=s[t];if(e(i,t,s))return i}}const _f=new Set(["position","texcoord_0","texcoord_1","texcoord_2","texcoord_3","normal","tangent"]),uf=Array.from(n.create$2()),hf={pbrMetallicRoughness:{baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1};function ff(s){return Ga(s,hf),s}function Ga(s,e){for(const t in e)s[t]===void 0?s[t]=e[t]:typeof s[t]=="object"&&Ga(s[t],e[t])}var tt=(s=>(s[s.Pending=1]="Pending",s[s.Loaded=2]="Loaded",s[s.Failed=3]="Failed",s))(tt||{});function mf(s){return{buffers:[],textures:[],status:1,scenes:[],defaultScene:0,preserve:s}}function pf(s,e,t,i,o,r){var c;const a=[],l=[];for(const d of t.scenes){const _=[];Va(_,s,d.nodes,t,a,l,e,i,o,r),s.scenes.push({id:n.uniqId(),name:d.name,objects:_})}return s.defaultScene=(c=t.scene)!=null?c:0,s}function Va(s,e,t,i,o,r,a,l,c,d){var u,h,f,m,p,v;if(!t)return;const _=a.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=[...r];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),lf(i,e,x,b,y)}if(g.mesh!==void 0){const M=i.meshes[g.mesh];let S=d?n.GltfDemPosition.flat:n.GltfDemPosition.default;n.isObject(g.extras)&&(g.extras.dem==="flat"?S=n.GltfDemPosition.flat:g.extras.dem==="instance"&&(S=n.GltfDemPosition.default));const P=new Float32Array(16),T=new Float32Array(9);ka(T,b,e.buffers),Ua(P,b,y,e.buffers);let C,I;if(g.children){const E=[];for(const B of g.children){const N=i.nodes[B];xf(N)&&E.push(N)}if(E.length){const B=E[0];if(B.extras.dem==="centroid")S=n.GltfDemPosition.centroid,C=[B.translation[0],B.translation[2]];else if(B.extras.dem==="axis"){S=n.GltfDemPosition.axis;const N=df(E,J=>J.extras.dem==="axis");I=[B.translation[0],B.translation[2],(N!=null?N:B).translation[0],(N!=null?N:B).translation[2]]}}}for(const E of M.primitives){const B=[],N={};let J=0,K,F;for(const Se in E.attributes){const zt=/TEXCOORD_(\d+)/.exec(Se);zt&&(B[parseInt(zt[1],10)]=!0);const St=Se.toLowerCase();if(!_f.has(St))continue;const Wt=E.attributes[Se],je=i.accessors[Wt];if(je.bufferView===void 0)continue;const ci=i.bufferViews[je.bufferView];if(ci===void 0)continue;const Ri=Za(a,e,i,je.bufferView,je.componentType);if(Ri){if(St==="position"&&(K=je.min,F=je.max),Ri.purpose="gltfMesh",N[Se.toLowerCase()]=new n.BufferChannel(Ri,{itemSize:gf(je.type),dataType:n.componentTypeToWebGl(je.componentType),stride:(u=ci.byteStride)!=null?u:0,offset:(h=je.byteOffset)!=null?h:0,normalized:!!je.normalized}),!C&&Se.toLowerCase()==="position"){const Fi=je.min,Di=je.max;Fi&&Di&&(C=[(Di[0]+Fi[0])/2,(Di[2]+Fi[2])/2])}J===0&&(J=je.count)}}K||(K=[0,0,0]),F||(F=[0,0,0]);let ee;if(E.indices!==void 0){const Se=i.accessors[E.indices];if(Se.bufferView===void 0||(ee=Za(a,e,i,Se.bufferView,Se.componentType,!0),!ee))continue;ee.purpose="gltfIndices",J=Se.count}const be=E.material!==void 0?i.materials[E.material]:{},we=ff(be),Ke={},Ve={localMatrix:P,textureTransformMatrix:T,animationStack:b,transformStack:y,availableTextureCoords:B,attributesAliases:Ke,colorFactor:[...we.pbrMetallicRoughness.baseColorFactor],colorTexture:NaN,aoTexture:NaN,pbrTexture:NaN,centroid:C,axis:I,demPosition:S},Ze=[];we.alphaMode==="OPAQUE"?Ze.push({type:_a,value:xh}):we.alphaMode==="BLEND"&&Ze.push({type:_a,value:bh});const Pt=we.pbrMetallicRoughness.baseColorTexture;Pt&&(Ze.push({type:yh}),Ke.texcoord_color=`texcoord_${(f=Pt.texCoord)!=null?f:0}`,Qo(e,i,Pt),Ve.colorTexture=Pt.index);const Ie=we.pbrMetallicRoughness.metallicRoughnessTexture;if(Ie){Ze.push({type:ph}),Qo(e,i,Ie),Ve.pbrTexture=Ie.index;const Se=typeof Ie.texCoord=="number"?Ie.texCoord:0;Ke.texcoord_pbr=`texcoord_${Se}`,B[Se]=!1}else Ve.roughness=(m=we.pbrMetallicRoughness.roughnessFactor)!=null?m:1,Ve.metallic=(p=we.pbrMetallicRoughness.metallicFactor)!=null?p:1;Number.isNaN(c.style.roughness)||Ze.push({type:mh}),((v=g.extras)==null?void 0:v.tier)!==void 0&&(Ve.meshTier=g.extras.tier,Ze.push({type:gh})),c.style.lightingModel==="pbr"?Ze.push({type:ua,value:Sh}):Ze.push({type:ua,value:wh});const Bt=we.occlusionTexture;if(Bt){Ze.push({type:vh}),Qo(e,i,Bt),Ve.aoTexture=Bt.index;const Se=typeof Bt.texCoord=="number"?Bt.texCoord:0;Ke.texcoord_ao=`texcoord_${Se}`,B[Se]=!1}af(i,e,b,E.material),s.push({start:0,count:J,attributes:Ve,drawMode:E.mode,accessors:N,elementsBuffer:ee,shaderDefinitions:Ze,bbox:{min:K,max:F}})}}g.children&&Va(s,e,g.children,i,y,b,a,l,c,d)}}function Qo(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 r=e.images[o.source],a=e.samplers[o.sampler];if(!a||!r)return;const l={flipY:!1};if(a.magFilter&&(l.magFilter=Wi(a.magFilter)),a.minFilter&&(l.minFilter=Wi(a.minFilter)),a.wrapS&&(l.wrapS=Wi(a.wrapS)),a.wrapT&&(l.wrapT=Wi(a.wrapT)),t.texCoord!==void 0&&(l.texcoord=t.texCoord),!r.image&&r.bufferView){yf(e,r).then(d=>{d&&(r.image=d,s.textures[i]=new w(r.image,l))});return}s.textures[i]=new w(r.image,l)}function Za(s,e,t,i,o,r=!1){const a=t.bufferViews[i];if(a===void 0)return;if(!e.buffers[i]){const c=t.buffers[a.buffer].buffer;if(!c)return;const d=new DataView(Jo(c),a.byteOffset,a.byteLength),_=s.createBuffer(d,{dataType:n.componentTypeToWebGl(o)},r);e.buffers[i]=_}const l=e.buffers[i];if(!(l instanceof ArrayBuffer))return l}function vf(s=[],e){if(e.length===0)return Array.from(uf);n.copy(s,e[0]);for(let t=1;t<e.length;t++)n.mul$1(s,s,e[t]);return s}function gf(s){switch(s[0]){case"S":return 1;case"V":return Number(s[3]);case"M":return We(Number(s[3]),2)}return console.error(`Failed to determine channels count from accessor type = ${s}`),0}function Jo(s){return s instanceof ArrayBuffer?s:s.buffer}function yf(s,e){return q(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?wn(new Uint8Array(i,t.byteOffset,t.byteLength),e.mimeType):!1})}function xf(s){return s.mesh===void 0&&n.isObject(s.extras)&&(s.extras.dem==="centroid"||s.extras.dem==="axis")}const bf=n.len$1([1,1,1]),Ut=n.create$1(),Ao=n.create$1(),wf=n.create$2();function Sf(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 es(s){return s.symbol==="gltfModel"&&s.sink==="instances"}function Tf(s,e,t,i,o){var d;const r=s.modelMatrices.get(0);if(!r)return;const a=[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,a,r),n.transformMat4$1(c.max,l,r),o)if(i.tMatrix3x3){const _=Mf(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=Ut,h=Ao;n.decomposeMat4(e,u,h);const f=n.len$1(u)/bf;_*=f,_+=n.len$1(h)}_*=(d=i.maxDiag)!=null?d:1,n.set(Ut,-_,-_,-_),n.add$1(c.min,c.min,Ut),n.set(Ut,_,_,_),n.add$1(c.max,c.max,Ut)}return c}function Mf(s,e,t){const i=n.set$2(wf,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(Ut,s.min,s.max,.5),r=n.scale(Ao,n.sub$1(Ao,s.max,s.min),.5),a=n.transformMat4$1(Ut,o,i),l=n.fromValues(Math.abs(i[0])*r[0]+Math.abs(i[4])*r[1]+Math.abs(i[8])*r[2],Math.abs(i[1])*r[0]+Math.abs(i[5])*r[1]+Math.abs(i[9])*r[2],Math.abs(i[2])*r[0]+Math.abs(i[6])*r[1]+Math.abs(i[10])*r[2]),c=n.sub$1(n.create$1(),a,l),d=n.add$1(n.create$1(),a,l);return{min:c,max:d}}class Ef{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:r}=o,{symbol:a,sink:l}=r,c=n.getSymbolLayers(e,a,l);if(!c){console.error(`Cannot happen! Symbol ${a} 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,r,i,o.state);if(!_){this.queue.delete(i.id);continue}o.state=_}}}function If(s,e,t,i,o,r,a,l,c,d,_,u){const h=n.stride(r,a),f=n.getSymbolLayers(e,r,a),{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",S=JSON.stringify(Object.values(c))+"_"+M+"_"+o.detailLevel,P=e.getShaderProgram(b.programName,y),T=l.buffer;if(!T){console.error(`Expected existing buffer while linking instance, but ${T} found.`);continue}const C=b.vaoCreator(T,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:S,vao:C,drawMode:x,tile:o,bbox:g,bboxWorld:u,symbol:r,sink:a,canRender:!0,instanceCount:(l.rangeEnd-l.rangeStart)/h};o.push(I),s.push(I)}s.length&&e.addRerenderEvent({type:"instanceLink"})}function ja(s,e,t){Cf(e,i=>{var r;const o=((r=i.meta)==null?void 0:r.linkId)===t;return o&&s.push(i),!o})}function Cf(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 Lf={min:[0,0,0],max:[0,0,0]},Tn=(s,e,t,i)=>{var c,d;const{assetManager:o,modelsScene:r,renderer:a}=s;if(i||(i={}),t.destroyed){const _=[];for(const u in i){const h=i[+u];Number.isNaN(h.linkId)||ja(_,t,h.linkId)}for(const u of _)r.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=Lf,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;r.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 S=o.getModel(b,x);if(!S||S.status!==tt.Loaded)continue;const P=(d=(c=S==null?void 0:S.scenes.find(I=>I.id===m.sceneId))==null?void 0:c.objects)!=null?d:[];if(P.length===0)continue;const T=m.linkId;if(!Number.isNaN(T)){const I=[];ja(I,t,T);for(const E of I)r.removeSceneObject(E.id)}const C=n.uniqId();m.linkId=C;for(const I of P){const E=t.modelMatrices.get(0),B=new Float32Array(16);Sf(B,E);const{attributesAliases:N,availableTextureCoords:J,colorTexture:K,colorFactor:F,aoTexture:ee,pbrTexture:be,metallic:we,roughness:Ke,meshTier:Ve,animationStack:Ze,transformStack:Pt,localMatrix:Ie,demPosition:Bt,axis:Se,centroid:zt,textureTransformMatrix:St}=I.attributes,Wt=Tf(t,Ie,f,u,I.bbox);!m.referenceBbox&&Wt&&(m.referenceBbox=Wt),If(l,a,C,I,t,e.symbol,e.sink,u,z({colorTexture:K,colorFactor:F,aoTexture:ee,pbrTexture:be,metallic:we,roughness:Ke,meshTier:Ve,demPosition:Bt,axis:Se,centroid:zt},h),{modelId:b,animationStack:Ze,transformStack:Pt,localMatrix:new Float32Array(Ie!=null?Ie:[]),textureTransformMatrix:new Float32Array(St!=null?St:[]),transformMatrix:B},de(z({},u.meta),{attributesAliases:N,availableTextureCoords:J}),Wt)}}return l.forEach(_=>{r.addSceneObject(_)}),i},Mn=new Float32Array(16);let Pe,Be;function R(...s){return(t,i,o,r,a,l)=>{for(const c of s)if(!c(t,i,o,r,a,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:r,renderer:a}=t,l=r.getStyle(e.handyStyleId);return!(l==null?void 0:l.environment)||!i.tile.renderModelMatrix?!1:(a.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:o.ecefMvpMatrix,u_float_crossfade:o.globeRatio}),!0)},En=(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(Mn,i.tile.renderModelMatrix),t.renderer.bindShaderProgram(s,{u_mat4_model:Mn}),!0):!1,In=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0}),!0),U=(s,e,{renderer:t},i,o,r)=>{if(r.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 ts=(s,e,t,i,o)=>{var m;Pe=void 0;const r=oi(e,i),a=n.resolveString(o.style.textureImage,r);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(a)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.textureSize,r);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},Wa=(s,e,t,i,o)=>{var m;Be=void 0;const r=oi(e,i),a=n.resolveString(o.style.normalMapTextureImage,r),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(a)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.normalMapTextureSize,r);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||(Be=d[f]),!0},is=(s,e,{assetManager:t,renderer:i},o,r)=>{if(!Pe)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;let a,l,c,d;const{tile:_}=o,{zoom:u}=e,h=t.textures[Pe.atlasIndex];let f=!1;if(!h)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;r.type==="polygon"&&(f=r.style.lengthUnits===n.LengthUnits.Meters),i.enableTexture(h,0);let m;if(f){const p=oi(e,o),v=n.resolveExpression(r.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,S=M/x,P=M/g,T=Math.trunc(n.atlasSize[0]/S),C=Math.trunc(n.atlasSize[1]/P);a=_.coords[0]*n.atlasSize[0]%T/T,l=_.coords[1]*n.atlasSize[1]%C/C,c=n.atlasSize[0]/T,d=n.atlasSize[1]/C}else m=n.tileSizeZpt*Math.pow(2,Math.round(u)-_.zoomLevel)*window.devicePixelRatio,a=_.coords[0]*m%Pe.w/Pe.w,l=_.coords[1]*m%Pe.h/Pe.h,c=m/Pe.w,d=m/Pe.h;return i.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_params:[a,l,c,d],u_float_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},$a=(s,e,t,i,o)=>{var g;const{assetManager:r,styleManager:a,renderer:l}=t;if(!Be)return l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0;let c,d,_,u;const{tile:h}=i,{zoom:f}=e,m=r.textures[Be.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,S]=Array.isArray(b)?b:[b,b],P=n.Mercator.toGeo(n.tileCoordsToMapPoint(h.coords)),T=n.Mercator.scaleFactor(P[1]),C=n.tileZoomToSize(h.zoomLevel)/n.MAP_POINTS_IN_METER/T,I=C/M,E=C/S,B=Math.trunc(n.atlasSize[0]/I),N=Math.trunc(n.atlasSize[1]/E);c=h.coords[0]*n.atlasSize[0]%B/B,d=h.coords[1]*n.atlasSize[1]%N/N,_=n.atlasSize[0]/B,u=n.atlasSize[1]/N}else v=n.tileSizeZpt*Math.pow(2,Math.round(f)-h.zoomLevel)*window.devicePixelRatio,c=h.coords[0]*v%Be.w/Be.w,d=h.coords[1]*v%Be.h/Be.h,_=v/Be.w,u=v/Be.h;const x=(g=a.getStyle(i.attributes.styleId))==null?void 0:g.rasterSets.byIndex[Be.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:[(Be.x+.5)/n.atlasSize[0],(Be.y+Be.h-1)/n.atlasSize[1],(Be.x+Be.w-1)/n.atlasSize[0],(Be.y+.5)/n.atlasSize[1]]}),!0)},Pf=(s,e,{renderer:t})=>(t.bindShaderProgram(s,{u_int_is_textured:0,u_int_is_normal_map_textured:0}),!0),Xa=(s,e,{renderer:t},i,o)=>{if(!Be)return!0;const r=oi(e,i),a=n.resolveExpression(o.style.metallic,r),l=n.resolveExpression(o.style.roughness,r);return t.bindShaderProgram(s,{u_float_metallic:a,u_float_roughness:l}),!0},Bf=(s,e,t,i)=>{if(!Pe)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;const{tile:o}=i,{zoom:r}=e,a=t.assetManager.textures[Pe.atlasIndex];if(!a)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;t.renderer.enableTexture(a,0);const l=n.tileSizeZpt*Math.pow(2,Math.round(r)-o.zoomLevel)*window.devicePixelRatio;return t.renderer.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_vertical_scale:Pe.h*o.size/l}),!0},zf=(s,e,{styleManager:t,assetManager:i,renderer:o},r,a)=>{var y;const l=oi(e,r),c=n.resolveString(a.style.iconImage,l),d=t.getStyle(r.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(a.style.width,l),h=n.resolveNumber(a.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},Ka=new Float32Array(16);n.fromScaling(Ka,[1/n.worldSize,1/n.worldSize,1/n.worldSize]);const Cn=(s,e,{animationManager:t,assetManager:i,renderer:o},r,a)=>{const{styleId:l}=r.attributes,{localMatrix:c,transformMatrix:d,modelId:_,textureTransformMatrix:u}=r.renderingProperties;if(_===void 0)return!1;const h=i.getModel(_,l);return h===void 0?!1:(t.animateGltfObject(r,a,h),o.bindShaderProgram(s,{u_mat4_localmatrix:c,u_mat3_transform_tex_matrix:u,u_mat4_instance:e.globeMode?Ka:d}),!0)},Rf=(s,e,{renderer:t},i)=>i.tile.renderModelMatrix?(n.copy(Mn,i.tile.renderModelMatrix),t.bindShaderProgram(s,{u_mat4_model:Mn}),!0):!1,qa=(s,e,{animationManager:t,renderer:i},o,r)=>{if(!Be)return!0;let a=[0,0,0,0],l=0;const[c,d]=t.animatePolygonNormalMapTexture(o,r);return a=d,l=c?1:0,i.bindShaderProgram(s,{u_vec4_normal_map_animated_offsets:a,u_int_normal_map_is_animated:l}),!0},Ff=(s,e,t)=>!t.shadowManager.texture;function Df(){return{line:{solid:[{programName:"road",vaoCreator:e_,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:Xu,objectBinder:L(Jr,me,Ne),layerBinder:re,zoomBinder:yt,tileBinder:R(Q,D),cullMethod:O(Z,fe,rt,Ae)},{identify:!0,programName:"roadIdentify",vaoCreator:o_,stateBinder:Mt,needsVisibilityBuffer:!1,objectBinder:L(Ne),zoomBinder:yt,tileBinder:D,cullMethod:O(Z,fe,rt,Ae)}],patterned:[{programName:"patternedLine",vaoCreator:s_,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:Yr,layerBinder:re,objectBinder:L(ea,Ne,Le,ti),zoomBinder:sa,tileBinder:R(Q,D),cullMethod:O(Z,fe,rt,xa)}],solid3d:[{programName:"line3D",vaoCreator:t_,stateBinder:ho,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:Hu,objectBinder:L(me,Ne,Qe,k),layerBinder:re,zoomBinder:yt,tileBinder:R(Q,D,U),cullMethod:O(Z,rt,Ae),is3dMapAware:!0},{identify:!0,programName:"line3DIdentify",vaoCreator:i_,stateBinder:ge,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(Ne,Qe,k),zoomBinder:yt,tileBinder:R(D,U),cullMethod:O(Z,rt,Ae),is3dMapAware:!0}],patterned3d:[{programName:"patternedLine3D",vaoCreator:r_,stateBinder:ho,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:Ku,layerBinder:re,objectBinder:L(ea,Ne,Le,ti,k),zoomBinder:sa,tileBinder:R(Q,D,U),cullMethod:O(Z,rt,xa),is3dMapAware:!0}]},polygon:{fill:[{programName:"vtxColor",vaoCreator:qd,stateBinder:Fe,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:$r,layerBinder:Ce(re,ut,Js),objectBinder:L(me,Qr,Le,Po,he),tileBinder:R(ts,is,Wa,$a,D,Q,qa,Xa),cullMethod:O(Z,se,fe,Ae)},{identify:!0,programName:"vtxColorIdentify",vaoCreator:Ad,stateBinder:Mt,needsVisibilityBuffer:!0,programBinder:Ys,objectBinder:L(he),tileBinder:D,cullMethod:O(Z,se,fe)}],fillWithMixFactor:[{programName:"vtxColor",vaoCreator:Yd,stateBinder:O_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:$r,layerBinder:Ce(re,ut,Js),objectBinder:L(me,Qr,Le,Po,he),tileBinder:R(ts,is,Wa,$a,D,Q,qa,Xa),cullMethod:O(Z,se,fe,Ae)}],stroke:[{programName:"simpleLine2d",vaoCreator:b_,stateBinder:Fe,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Gu,layerBinder:Ce(Ys,qi,re),objectBinder:L(me,Ne,he),tileBinder:R(Q,D),cullMethod:O(Wh,Z,se,fe,Si,Ti,La),subRenderIndex:1}],shadow:[{programName:"vtxColor",vaoCreator:Qd,stateBinder:Fe,needsVisibilityBuffer:!0,commonBinder:X(W,$),programBinder:ot,layerBinder:ut,objectBinder:L(me,Le,he),tileBinder:R(Ff,Pf,D,Q),cullMethod:O(Z,se,fe,Yh)}]},metricPoint:{fill:[{programName:"metricPoint",vaoCreator:Jd,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(W,te,$),programBinder:Ue,layerBinder:Ce(re,ut),objectBinder:L(me,he),tileBinder:R(zf,D,Q),cullMethod:O(Z,se,Ae)}]},mesh:{fill:[{programName:"mesh",vaoCreator:rr,stateBinder:wr,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ft,layerBinder:Ce(re,ht),objectBinder:L(me,Ct,xi,Le,Ye,k,Qe,st,Po),tileBinder:R(ts,is,Bf,Q,D,U),cullMethod:O(Z,Ea),subRenderIndex:1,is3dMapAware:!0},{identify:!0,programName:"mesh",vaoCreator:rr,stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ft,objectBinder:L(Ye,k,Qe,st),tileBinder:R(D,U),cullMethod:O(Z,Ea),subRenderIndex:1,is3dMapAware:!0},{depthTest:!0,programName:"mesh",vaoCreator:l_,stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ft,objectBinder:L(Ye,k,Qe,st),tileBinder:R(D,U),cullMethod:Z,subRenderIndex:1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ar,stateBinder:on,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(Ye,k,Qe),tileBinder:R(D,U),cullMethod:Z,is3dMapAware:!0}],inverse:[{programName:"inverse",vaoCreator:Ji,stateBinder:tn,needsVisibilityBuffer:!0,commonBinder:W,programBinder:ft,objectBinder:L(Ye,k,st),tileBinder:R(D,U),cullMethod:Z,subRenderIndex:-1,is3dMapAware:!0},{identify:!0,programName:"inverse",vaoCreator:Ji,stateBinder:tn,needsVisibilityBuffer:!1,commonBinder:W,programBinder:ft,objectBinder:L(Ye,k,st),tileBinder:R(D,U),cullMethod:Z,subRenderIndex:-1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:Ji,stateBinder:on,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(Ye,k,Qe),tileBinder:R(D,U),cullMethod:Z,is3dMapAware:!0}],depthClear:[{programName:"meshDepthClear",vaoCreator:Ji,stateBinder:U_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:ft,objectBinder:L(Ye,k,st,Qe),tileBinder:R(D,U),cullMethod:Z,subRenderIndex:-2,is3dMapAware:!0,forceRenderUnderCacheInDemMode:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:c_,stateBinder:Kt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:cn,layerBinder:Ce(qi,re),objectBinder:L(me,Ne,Ye,ii,k,Qe),tileBinder:R(Q,D,U),cullMethod:O(Z,Si,kh,Qh,La),subRenderIndex:2,is3dMapAware:!0}]},polygonExtrusion:{sideFill:[{programName:"diffuse",vaoCreator:lr,stateBinder:tn,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Jt,tileBinder:R(Q,D,U),layerBinder:Ce(re,ht),objectBinder:L(me,Ct,qe,Le,k,he,wi),cullMethod:O(wa,Z,se,bn,fe),is3dMapAware:!0},{programName:"gradientDiffuse",vaoCreator:lr,stateBinder:Er,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Jt,layerBinder:Ce(re,ht),objectBinder:L(me,xi,Ct,qe,Le,k,he,ca,wi),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,bn,jo),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:dr(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:an,objectBinder:L(qe,k,he),tileBinder:R(D,U),cullMethod:O(Z,se,fe,bn,jo),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:_r(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:an,objectBinder:L(qe,k,he),tileBinder:R(D,U),cullMethod:O(Z,se,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:ur(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:nn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(qe,k,he),tileBinder:R(D,U),cullMethod:O(Z,se,fe),is3dMapAware:!0}],sideTexture:[{programName:"wallTexture",vaoCreator:d_,stateBinder:X_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Jt,layerBinder:Ce(re,ht),objectBinder:L(qe,k,he,dh,Ct),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,nf),is3dMapAware:!0}],topFill:[{programName:"diffuse",vaoCreator:cr,stateBinder:tn,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Jt,layerBinder:re,objectBinder:L(me,Ct,qe,Le,k,he,wi),tileBinder:R(Q,D,U),cullMethod:O(wa,Z,se,fe,Wo),is3dMapAware:!0},{programName:"diffuse",vaoCreator:cr,stateBinder:Er,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Jt,layerBinder:Ce(re,ht),objectBinder:L(me,Ct,qe,Le,k,he,wi),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,Wo),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:dr(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:an,objectBinder:L(qe,k,he),tileBinder:R(D,U),cullMethod:O(Z,se,fe,Wo),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:_r(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:ge,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:an,objectBinder:L(qe,k,he),tileBinder:R(D,U),cullMethod:O(Z,se,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:ur(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:nn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(qe,k,he),tileBinder:R(D,U),cullMethod:O(Z,se,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:hr,stateBinder:Kt,needsVisibilityBuffer:!0,commonBinder:X(W,te,$,_e),programBinder:Xr,layerBinder:re,objectBinder:L(me,xi,Ct,qe,Le,k,he),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,Pa,Ia),is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:ro,stateBinder:Kt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:cn,layerBinder:Ce(re,jd),objectBinder:L(me,Ct,Ne,qe,k,he,Do),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,Si,Ti,Ah),is3dMapAware:!0}]},labelLine:{raster:[{programName:"labelLine",vaoCreator:Qi,stateBinder:mo,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:ln,objectBinder:L(Rt,ei,kt,vn,yn),tileBinder:R(D,Q),zoomBinder:yt,cullMethod:O(se,Lt,Je,ni,xn,Zo),uniformSet:"fontHalo"},{programName:"labelLine",vaoCreator:Qi,stateBinder:po,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:ln,objectBinder:L(Rt,ei,kt,vn,yn),tileBinder:R(D,Q),zoomBinder:yt,cullMethod:O(se,Lt,Zo,Je,ni,xn),uniformSet:"fontHalo",isOverlappedObject:!0},{programName:"labelLine",vaoCreator:Qi,stateBinder:mo,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:ln,objectBinder:L(Rt,ei,kt,vn,yn),zoomBinder:yt,tileBinder:R(D,Q),cullMethod:O(se,Lt,Je,ni,xn),uniformSet:"fontFill",subRenderIndex:1},{programName:"labelLine",vaoCreator:Qi,stateBinder:po,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:ln,objectBinder:L(Rt,ei,kt,vn,yn),zoomBinder:yt,tileBinder:R(D,Q),cullMethod:O(se,Lt,Je,ni,xn),uniformSet:"fontFill",subRenderIndex:1,isOverlappedObject:!0}]},dashedLine:{stroke:[{programName:"stripedLine",vaoCreator:nr,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(te,W,$,_e),programBinder:qr,layerBinder:re,objectBinder:L(_n,pn,dn,Le,ti),tileBinder:R(Q,D),cullMethod:O(Z,rt,fe)},{identify:!0,programName:"stripedLineIdentify",vaoCreator:nr,stateBinder:br,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:Kr,objectBinder:L(_n,pn,Le,dn,ti),tileBinder:D,cullMethod:O(Z,rt,fe)}],stroke3d:[{programName:"stripedLine3D",vaoCreator:or,stateBinder:ho,needsVisibilityBuffer:!1,commonBinder:X(te,W,$),programBinder:ju,layerBinder:re,objectBinder:L(_n,pn,dn,Le,ti,k),tileBinder:R(Q,D,U),cullMethod:O(Z,rt),is3dMapAware:!0},{identify:!0,programName:"stripedLine3DIdentify",vaoCreator:or,stateBinder:ge,needsVisibilityBuffer:!1,programBinder:Wu,objectBinder:L(_n,pn,Le,dn,ti,k),tileBinder:R(D,U),cullMethod:O(Z,rt),is3dMapAware:!0}]},oneWayLine:{raster:[{programName:"oneWayLine",vaoCreator:fr,stateBinder:mo,needsVisibilityBuffer:!1,commonBinder:X(hi,ui,_e),programBinder:Zr,objectBinder:L(Rt,me,un,ta),tileBinder:D,cullMethod:O(Lt,Je,Ca)},{programName:"oneWayLine",vaoCreator:fr,stateBinder:po,commonBinder:X(hi,ui,_e),programBinder:Zr,needsVisibilityBuffer:!1,objectBinder:L(Rt,me,un,ta),tileBinder:D,cullMethod:O(Lt,Je,Ca),isOverlappedObject:!0}]},point:{raster:[{programName:"pointSprite",vaoCreator:h_,stateBinder:fo,needsVisibilityBuffer:!1,commonBinder:mi(W,$,$s,Xi,_e),programBinder:Nu,layerBinder:ut,objectBinder:L(Ju,zo,Bo,bi,k,he),cullMethod:O(Je,se,Vo,Uo,Lt),tileBinder:R(ke,Q,U),is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"pointSpriteIdentify",vaoCreator:m_,stateBinder:Mt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:jr,objectBinder:L(zo,Bo,bi,k,he),tileBinder:R(ke,U),cullMethod:O(Je,se,Vo,Uo,ba),is3dMapAware:!0},{labelTest:!0,programName:"pointSpriteIdentify",vaoCreator:f_,stateBinder:Mt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:jr,objectBinder:L(zo,Bo,bi,k,he),tileBinder:R(ke,U),cullMethod:O(Je,se,Vo,Uo,ba),is3dMapAware:!0}],text:[{programName:"labelPoint",vaoCreator:sr,stateBinder:fo,needsVisibilityBuffer:!1,commonBinder:mi(W,$,Xi,_e),programBinder:Wr,objectBinder:L(Rt,ei,kt,oa,gn,bi,k,he),tileBinder:R(ke,Q,U),cullMethod:O(Je,se,Lt,ni,Ta,Zo),uniformSet:"fontHalo",subRenderIndex:1,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{programName:"labelPoint",vaoCreator:sr,stateBinder:fo,needsVisibilityBuffer:!1,commonBinder:X(W,$,Xi,_e),programBinder:Wr,objectBinder:L(Rt,ei,kt,oa,gn,bi,k,he),tileBinder:R(ke,Q,U),cullMethod:O(Je,se,Lt,ni,Ta),uniformSet:"fontFill",subRenderIndex:2,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"labelPointIdentify",vaoCreator:a_,stateBinder:Mt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:pe(oe),objectBinder:L(kt,gn,k,he),tileBinder:R(ke,U),cullMethod:O(Je,se,Zh),subRenderIndex:1,is3dMapAware:!0}],labelingTexture:[{depthTest:!0,programName:"pointDepthTest",vaoCreator:p_,stateBinder:br,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:oe,objectBinder:L(gn,k,he),tileBinder:R(D,U),cullMethod:O(Je,se),is3dMapAware:!0}]},buildingModel:{fill:[{programName:"zbmModel",vaoCreator:v_,stateBinder:Sr,needsVisibilityBuffer:!1,commonBinder:X(W,$,te),programBinder:$u,layerBinder:Ce(re,ut,ht),objectBinder:L(me,Fo,ih,k),tileBinder:R(Q,D,U),cullMethod:O(Go,Z,Ma,Ae,$o),subRenderIndex:2,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:g_,stateBinder:ge,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:L(k),tileBinder:R(D,U),cullMethod:O(Go,Z,Ma,Ae,$o),subRenderIndex:2,identify:!0,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:y_,stateBinder:ge,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:L(k),tileBinder:R(D,U),cullMethod:Z,depthTest:!0,is3dMapAware:!0},{programName:"zbmShadow",vaoCreator:x_,stateBinder:nn,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(Fo,k),tileBinder:R(D,U),cullMethod:Z,shadow:!0,is3dMapAware:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:ro,stateBinder:Kt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:cn,layerBinder:Ce(re,qi),objectBinder:L(me,Ne,Fo,ii,k,Do),tileBinder:R(D,Q,U),cullMethod:O(Z,Go,Si,Ti,$o),subRenderIndex:5,is3dMapAware:!0}]},shiftedLine:{solid:[{programName:"road",commonBinder:X(W,$,te),programBinder:pe(ot,Ue),vaoCreator:n_,stateBinder:Fe,needsVisibilityBuffer:!1,layerBinder:re,objectBinder:L(me,Ne,Jr),tileBinder:R(Q,D),zoomBinder:yt,cullMethod:O(Z,rt,Ae)}]},circle:{fill:[{programName:"circleMarker",vaoCreator:ao,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(W,te,$,_e),programBinder:Lo,layerBinder:re,objectBinder:L(me,Ne,k),cullMethod:O(Z,rt,Ae),tileBinder:R(ke,Q,U),subRenderIndex:2,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:ao,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(W,te,$,_e),programBinder:Lo,layerBinder:re,objectBinder:L(me,Ne,k),cullMethod:O(Z,$h,Ti),tileBinder:R(ke,Q,U),subRenderIndex:1,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:ao,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(W,te,$,_e),programBinder:Lo,layerBinder:re,objectBinder:L(me,Ne,k),cullMethod:O(Z,Xh,Jh),tileBinder:R(ke,Q,U),is3dMapAware:!0},{identify:!0,programName:"circleMarkerIdentify",vaoCreator:w_,stateBinder:Mt,programBinder:oe,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:L(Ne,k),cullMethod:O(Z,Kh),tileBinder:R(ke,U),is3dMapAware:!0}]},arrow:{stroke:[{programName:"entrance",vaoCreator:mr,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:X(hi,ui,W,$,_e),programBinder:Vu,objectBinder:L(me,un,Qu,ia,Le),tileBinder:R(D,Q),cullMethod:O(Z,Ae)},{identify:!0,programName:"entranceIdentify",vaoCreator:mr,stateBinder:Mt,needsVisibilityBuffer:!1,commonBinder:X(hi,ui,_e),programBinder:ku,objectBinder:L(un,ia,Le),tileBinder:D,cullMethod:O(Z,Ae)}]},lineExtrusion:{fill:[{programName:"gradientDiffuse",vaoCreator:__,stateBinder:D_,needsVisibilityBuffer:!0,commonBinder:X(W,$,te),programBinder:Jt,layerBinder:Ce(re,ht),objectBinder:L(mn,me,Ct,xi,Le,k,ii,ca,wi),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,bn,jo),subRenderIndex:9,is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:u_,stateBinder:on,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:L(mn,k,ii),tileBinder:R(D,U),cullMethod:O(Z,se,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:hr,stateBinder:Kt,needsVisibilityBuffer:!0,commonBinder:X(W,te,$,_e),programBinder:Xr,layerBinder:re,objectBinder:L(mn,me,xi,Le,k,ii),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,Pa,Ia),subRenderIndex:10,is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:ro,stateBinder:Kt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,te),programBinder:cn,layerBinder:Ce(re,qi),objectBinder:L(mn,me,Ne,k,ii,Do),tileBinder:R(Q,D,U),cullMethod:O(Z,se,fe,Si,Ti),subRenderIndex:11,is3dMapAware:!0}]},gltfModel:{instances:[{programName:"gltfModel",vaoCreator:en(!1),instanceBinder:Tn,commonBinder:X(W,$,te),programBinder:Zu,layerBinder:Ce(re,ht,Yi),stateBinder:Sr,needsVisibilityBuffer:!1,objectBinder:L(me,nh,No,Ro,k,hn,he,fn),tileBinder:R(ke,Cn,Rf,U,In),cullMethod:O(Xo,za),is3dMapAware:!0},{identify:!0,programName:"gltfModelIdentify",instanceBinder:Tn,vaoCreator:en(!1),stateBinder:ge,needsVisibilityBuffer:!1,layerBinder:Yi,commonBinder:mi(W,$),programBinder:oe,objectBinder:L(k,hn,st,Ro,he,fn),tileBinder:R(ke,Cn,U,In),cullMethod:O(Xo,za),is3dMapAware:!0},{depthTest:!0,programName:"gltfModelIdentify",instanceBinder:Tn,vaoCreator:en(!0),stateBinder:ge,needsVisibilityBuffer:!1,commonBinder:mi(W,$),programBinder:oe,layerBinder:Yi,objectBinder:L(k,hn,Ro,he,fn),tileBinder:R(ke,Cn,U,In),cullMethod:Xo,is3dMapAware:!0},{shadow:!0,programName:"gltfModelShadow",instanceBinder:Tn,vaoCreator:en(!1),stateBinder:nn,needsVisibilityBuffer:!1,programBinder:oe,layerBinder:Yi,objectBinder:L(k,hn,fn),tileBinder:R(ke,Cn,U,In),cullMethod:tf,is3dMapAware:!0}]},raster:{fill:[{programName:"rectWithTexture",vaoCreator:S_,stateBinder:Fe,needsVisibilityBuffer:!1,commonBinder:mi(W,$),layerBinder:ut,objectBinder:L(Ar,Au),tileBinder:R(D,Q),cullMethod:O(fa,Z)}]},heatmap:{framebuffer:[{programName:"heatmap",vaoCreator:T_,stateBinder:Tr,needsVisibilityBuffer:!1,commonBinder:qs,objectBinder:L(oh,sh),zoomBinder:yt,tileBinder:R(D,Q),cullMethod:O(Z,qh)}],fill:[{programName:"heatmapTexture",vaoCreator:M_,stateBinder:Fe,needsVisibilityBuffer:!1,layerBinder:ut,objectBinder:L(Ar,th,eh),tileBinder:Q,cullMethod:O(Z,fa,Uh),subRenderIndex:1}]},dem:{mesh:[{programName:"demMesh",vaoCreator:Ai,commonBinder:X(W,$,te),programBinder:ft,layerBinder:re,stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(k,ra,la),tileBinder:R(D,Q,En,U),cullMethod:O(ma,pa),is3dMapAware:!0},{programName:"demGround",demGround:!0,vaoCreator:Ai,programBinder:oe,tileBinder:R(D,Q,U),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(k)},{identify:!0,programName:"demMesh",vaoCreator:Ai,programBinder:pe(oe,Gr),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(aa,k),tileBinder:R(D,En,U),cullMethod:va,is3dMapAware:!0}],mesh2:[{dem:!0,programName:"demElevation",vaoCreator:pi,stateBinder:k_,needsVisibilityBuffer:!1,tileBinder:D,objectBinder:L()},{programName:"demGround2",demGround:!0,vaoCreator:pi,programBinder:oe,tileBinder:R(D,Q,U),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(k)},{programName:"demMesh2",vaoCreator:pi,commonBinder:X(W,$,te),programBinder:ft,layerBinder:re,stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(st,ra,la,k),tileBinder:R(D,Q,En,U),cullMethod:O(ma,pa)},{identify:!0,programName:"demMesh2",vaoCreator:pi,programBinder:pe(oe,Gr),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(st,aa,k),tileBinder:R(D,En,U),cullMethod:va},{depthTest:!0,programName:"demMesh2DepthTest",vaoCreator:pi,programBinder:pe(oe),stateBinder:ge,needsVisibilityBuffer:!1,objectBinder:L(lh,k),tileBinder:R(D,U)}],hillshade:[{programName:"demHillshade",vaoCreator:lo,stateBinder:Mt,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(k),tileBinder:R(D,U)}],flatBottom:[{programName:"demFlatBottom",vaoCreator:E_,stateBinder:xr,needsVisibilityBuffer:!1,objectBinder:L(ah,k),tileBinder:R(D,U),cullMethod:Hh}]},mapMesh:{fill:[{programName:"mapMesh",vaoCreator:co,stateBinder:wr,needsVisibilityBuffer:!1,zoomBinder:L(Oo),commonBinder:X(W,$,te),programBinder:ft,layerBinder:Ce(re,ht),objectBinder:L(No,Ye,k,Qe,st),tileBinder:R(Q,D,U),cullMethod:O(Z,Ho),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{identify:!0,programName:"mapMesh",vaoCreator:co,stateBinder:ge,needsVisibilityBuffer:!1,zoomBinder:L(Oo),commonBinder:X(W,$,te),programBinder:ft,layerBinder:Ce(re,ht),objectBinder:L(No,Ye,k,Qe,st),tileBinder:R(D,U),cullMethod:O(Z,Ho),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{depthTest:!0,programName:"mapMesh",vaoCreator:co,stateBinder:ge,needsVisibilityBuffer:!1,zoomBinder:L(Oo),commonBinder:X(W,$,te),programBinder:ft,layerBinder:Ce(re,ht),objectBinder:L(Ye,k,Qe,st),tileBinder:R(D,U),cullMethod:Z,subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ar,stateBinder:on,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:L(Ye,k,Qe),tileBinder:R(D,U),cullMethod:Z,is3dMapAware:!0}]},globe:{fill:[{programName:"globe",vaoCreator:vr,stateBinder:ge,objectBinder:L(na),tileBinder:ke,needsVisibilityBuffer:!1,is3dMapAware:!0},{identify:!0,programName:"globe",vaoCreator:vr,stateBinder:ge,objectBinder:L(na),tileBinder:ke,needsVisibilityBuffer:!1,is3dMapAware:!0}]}}}class Of{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 r=t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT);return t.deleteQueryEXT(e),this.queries.shift(),Number(r)}}const Nf=`
float affine_step(const float edge0, const float edge1, const float x)
{
    return clamp((x - edge0) / (edge1 - edge0), 0., 1.);
}
`,kf=`#define ALPHA_MODE_OPAQUE 1
#define ALPHA_MODE_BLEND 2
`,Ya=`
vec4 apply_opacity(const vec4 color, const float opacity)
{
return color * opacity;
}
`,Uf=`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);
}
`,Hf=`
#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
`,Qa=`#ifndef UBO
uniform highp vec3 u_cam_pos;
#endif
`,Gf=`
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);
}
`,Vf=`
#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;
}
`,Zf=`#ifdef WEBGL1
#extension GL_OES_standard_derivatives: enable
#endif
`,jf=`
#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;
}`,Wf=`#define FRAGMENT_NORMAL
vec3 calc_fragment_normal(vec3 vertex) {
    vec3 dx = dFdx(vertex);
    vec3 dy = dFdy(vertex);
    return normalize(cross(dx, dy));
}`,$f=`precision highp float;
`,Xf=`#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);
}`,Kf=`
#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
`,qf=`#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, float alpha) {
    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 * alpha;
    return albedo * (ambient + diffuse) + specular;
}
#endif
#endif
`,Yf=`precision lowp float;
`,Qf=`precision mediump float;
`,Ja=`#define MIX_COLOR_MODE_READ_FROM_TARGET 1
#define MIX_COLOR_MODE_VERTEX_ATTRIBUTE 2
#define VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE 1
`,Jf=`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);
}`,Af=`#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
`,em=`#ifdef HAS_FRAG_DEPTH_EXT
#extension GL_EXT_frag_depth : require
#endif
`,tm=`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;
}
`,im=`#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 `,Aa=`#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
`,nm=`#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);
}
`,om=`#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;
}
`,sm=`#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);
}
`,rm=`#include <lowp_float>
#include <prelude>
#include <fog>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = apply_fog(v_vec4_color);
}
`,am=`#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
void main()
{
    gl_FragColor = v_vec4_identifier;
}
`,lm=`#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
}
`,cm=`#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 
}
`,dm=`#include <mediump_float>
#include <prelude>
varying float v_float_height;
void main()
{
  gl_FragColor = vec4(v_float_height, 0., 0., 1.);
}
`,_m=`#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);
}
`,um=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = v_vec4_color;
}
`,hm=`#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;
}
`,fm=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_coords;
void main()
{
    gl_FragColor = v_vec4_coords;
}
`,mm=`#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);
    }
}
`,pm=`#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);
}
`,vm=`#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);
}
`,gm=`#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 
}
`,ym=`#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);
}
`,xm=`#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);
}
`,bm=`#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;
}
`,wm=`#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;
}
`,Sm=`#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>
#include <alpha_mode_defs>
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;
    }
    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) {
        apply_screendoor();
        gl_FragColor = apply_fog(color);
        return;
    }
    bool skip_screendoor = false;
    #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)
            #if defined(ALPHA_MODE) && ALPHA_MODE == ALPHA_MODE_OPAQUE
                
                
                
                
                color.rgb = color_phong(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic, color.a);
                if (color.a == 0.0) {
                    skip_screendoor = true;
                }
            #else
                color.rgb = color_phong(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic, 1.0);
            #endif
        #endif
    #endif
    if (!skip_screendoor){
        apply_screendoor();
    }
    gl_FragColor = apply_fog(color);
}
`,Tm=`#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
}
`,Mm=`#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);
}
`,Em=`#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
}
`,Im=`#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.);
    }
}
`,Cm=`#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);
}
`,Lm=`#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);
}
`,Pm=`#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));
}
`,Bm=`#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);
}`,zm=`#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);
}
}
}
`,Rm=`#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);
    }
}
`,Fm=`#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());
}
`,Dm=`#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);
}
`,Om=`#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);
}
`,Nm=`#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);
}
`,km=`#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;
    }
}
`,Um=`#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);
}
`,Hm=`#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;
}
`,Gm=`#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;
}
`,Vm=`#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);
}
`,Zm=`#include <lowp_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 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 = v_vec4_color * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,jm=`#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);
}
`,Wm=`#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);
}
`,$m=`#include <mediump_float>
#include <prelude>
varying mediump float v_intensity;
void main() {
    gl_FragColor = vec4(v_intensity);
}
`,Xm=`#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);
}
`,Km=`#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);
}
`,qm=`#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, 1.0);
    } else {
        color = color * light_factor_surface();
    }
    gl_FragColor = apply_fog(color);
}
`,Ym=`#include <lowp_float>
#include <prelude>
uniform vec4 u_vec4_color;
void main()
{
    gl_FragColor = u_vec4_color;
}
`,Qm=`#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);
}
`,Jm=`#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);
}
`,Am={affine_step:Nf,alpha_mode_defs:kf,apply_opacity:Ya,arrow_functions:Uf,bit_mask:Hf,cam_pos:Qa,circle_functions:Gf,dem:Vf,enable_standard_derivatives:Zf,fog:jf,fragment_normal:Wf,highp_float:$f,light:Xf,light_pbr:Kf,light_phong:qf,lowp_float:Yf,mediump_float:Qf,mix_color_defs:Ja,pack_depth:Jf,prelude:Af,require_frag_depth:em,screendoor_transparency:tm,shadow:im,signed_distance_functions:Aa},ep={arrow_line:nm,arrow_line_identify:om,circle_marker:sm,color:rm,color_identify:am,color_with_z_fade:lm,copy:cm,dem_elevation:dm,dem_elevation_copy:_m,dem_flat_bottom:um,dem_ground:hm,dem_ground2:fm,dem_mesh:mm,dem_mesh2:pm,dem_normal:vm,depth_clear:gm,fxaa:ym,globe:xm,globe_halo:bm,globe_halo_background:wm,gltf_model:Sm,gradient_with_z_fade:Tm,heatmap:Mm,heatmap_texture:Em,inverse:Im,label:Cm,label_directional:Lm,line:Pm,main_shadow:Bm,map_mesh:zm,mesh:Rm,metric_point:Fm,one_way_line:Dm,patterned_line:Om,pointsprite:Nm,pointsprite_identify:km,rect_with_texture:Um,road:Hm,road_identify:Gm,simple_line_2d:Vm,simple_line_3d:Zm,simple_mesh:jm,sky:Wm,stars:$m,striped_line:Xm,taa:Km,textured_color:qm,uniform_color:Ym,wall_texture:Qm,zbm_model:Jm},tp=`vec4 apply_height_factor(in vec3 vertex, const float height_factor)
{
    vertex.z *= height_factor;
    return vec4(vertex, 1.0);
}
`,ip=`
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);
}
`,np=`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);
}
`,op=`
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
void save_clipspace_pos () {
    #ifdef SCREENDOOR
    v_clipspace_pos = gl_Position.xyz;
    #endif
}
`,sp=`
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;
}
`,rp=`#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;
}
`,ap=`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);
}
`,lp=`#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
}`,cp=`#ifdef TAA
uniform vec2 u_vec2_camera_jitter;
void apply_vertex_jitter(inout vec4 clipPos) {
    clipPos.xy += clipPos.w * u_vec2_camera_jitter;
}
#endif`,dp=`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;
}
`,_p=`uniform mat4 u_mat4_mvp;
`,up=`
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);
}
`,hp=`
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;
}
`,fp=`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));
}`,mp=`
const float g_circle_scale_precision_factor = 1e8;
`,pp=`#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
`,vp=`
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;
}
`,gp=`
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);
    }
}
`,yp=`#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 `,xp=`
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); 
}
`,bp=`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);
}
`,wp=`#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);
}
`,Sp=`#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;
}`,Tp=`#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);
}
`,Mp=`#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.);
    }
}
`,Ep=`#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
}
`,Ip=`#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.);
    }
}
`,Cp=`#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;
}
`,Lp=`#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;
}
`,Pp=`#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);
}
`,Bp=`#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;
}
`,zp=`#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;
}
`,Rp=`#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);
}
`,Fp=`#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);
}
`,Dp=`#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);
}
`,Op=`#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);
}
`,Np=`#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_mix_color;
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;
attribute vec4 a_vec4_color;
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 (a_vec4_color[3] > 0. ) {
        v_vec4_color = apply_opacity( mix(v_vec4_color, a_vec4_color, u_float_mix_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;
        if (a_vec4_color[3] > 0. ) {
            v_mat4_gradient[1] = mix(v_mat4_gradient[1], a_vec4_color, u_float_mix_color);
            v_mat4_gradient[2] = mix(v_mat4_gradient[2], a_vec4_color, u_float_mix_color);
        }
        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);
}
`,kp=`#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);
}
`,Up=`#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;
}`,Hp=`#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);
}
`,Gp=`#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 mat3 u_mat3_transform_tex_matrix;
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)
    vec2 uvTransformed = ( u_mat3_transform_tex_matrix * vec3(texcoord_color, 1) ).xy;
    v_vec2_texcoord_color = uvTransformed;
    #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);
}
`,Vp=`#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;
}
`,Zp=`#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);
}
`,jp=`#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));
}
`,Wp=`#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);
}
`,$p=`#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.;
}
`,Xp=`#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.);
    }
}
`,Kp=`#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_mix_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;
attribute vec4 a_vec4_color;
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;
    if (a_vec4_color[3] > 0. ) {
        v_vec4_color =  mix(v_vec4_color, a_vec4_color, u_float_mix_color);
    }
    v_vec3_normal = vec3(wall_normal, 0.0);
    if (u_mat4_gradient[0][0] !=0.)
    {
        v_mat4_gradient = u_mat4_gradient;
    
        if (a_vec4_color[3] > 0. ) {
            v_mat4_gradient[1] = mix(v_mat4_gradient[1], a_vec4_color, u_float_mix_color);
            v_mat4_gradient[2] = mix(v_mat4_gradient[2], a_vec4_color, u_float_mix_color);
        }
        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);
}
`,qp=`#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);
}
`,Yp=`#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;
}
`,Qp=`#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);
}
`,Jp=`#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 float u_float_mix_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;
attribute vec4 a_vec4_color;
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;
    }
    vec4 t_vec4_color = u_vec4_color;
    if (a_vec4_color[3] > 0. ) {
        t_vec4_color =  mix(u_vec4_color, a_vec4_color, u_float_mix_color);
    }
    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(t_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(t_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);
}
`,Ap=`#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;
}`,ev=`#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);
}
`,tv=`#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);
}
`,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 <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;
}
`,nv=`#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;
}
`,ov=`#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);
}
`,sv=`#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;
}
`,rv=`#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;
}
`,av=`#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);
}
`,lv=`#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);
}
`,cv=`#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;
}
`,dv=`#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);
}
`,_v=`#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;
uniform vec4 u_vec4_color;
uniform float u_float_mix_color;
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;
attribute vec4 a_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
varying vec4 v_vec4_color;
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;
    }
    v_vec4_color = u_vec4_color;
    if (a_vec4_color[3] > 0. ) {
        v_vec4_color =  mix(v_vec4_color, a_vec4_color, u_float_mix_color);
    }
    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);
}
`,uv=`#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);
}
`,hv=`#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);
}
`,fv=`#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);
}
`,mv=`#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);
}
`,pv=`#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.);
    }
}
`,vv=`#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;
}
`,gv=`#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);
}
`,yv=`#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.);
    }
}
`,xv=`#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;
}
`,bv={apply_height_factor:tp,apply_opacity:Ya,arrow_functions:ip,calculate_scale:np,cam_pos:Qa,clipspace_pos:op,dem:sp,depth_test:rp,ecef_mvp_mat:ap,fog:lp,jitter:cp,line_width:dp,mix_color_defs:Ja,mvp_mat:_p,packed_attributes:up,pixel_offset:hp,pos_world:fp,precision_constants:mp,prelude:pp,raster_functions:vp,round_position:gp,shadow:yp,show_ratio:xp,signed_distance_functions:Aa,striped_line_functions:bp},wv={arrow_line_entrance:wp,building_shadow:Sp,circle_marker:Tp,circle_marker_identify:Mp,color:Ep,color_identify:Ip,dem_elevation:Cp,dem_elevation_copy:Lp,dem_flat_bottom:Pp,dem_ground:Bp,dem_ground2:zp,dem_mesh:Rp,dem_mesh2:Fp,dem_mesh2_depthtest:Dp,dem_normal:Op,diffuse:Np,diffuse_identify:kp,globe:Up,globe_halo:Hp,gltf_model:Gp,gltf_shadow:Vp,heatmap:Zp,heatmap_texture:jp,label_directional:Wp,label_fixed_anchor:$p,label_fixed_anchor_identify:Xp,line:Kp,line3d:qp,line3d_identify:Yp,map_mesh:Qp,mesh:Jp,mesh_shadow:Ap,metric_point:ev,one_way_line:tv,patterned_line:iv,point_anchor:nv,pointsprite:ov,pointsprite_identify:sv,posteffect:rv,rect_with_texture:av,road:lv,road_identify:cv,simple_line_2d:dv,simple_line_3d:_v,simple_mesh:uv,sky:hv,stars:fv,striped_line:mv,striped_line_identify:pv,wall_texture:vv,zbm_model:gv,zbm_model_identify:yv,zbm_shadow:xv},Sv=/^\s*#include\s+<(.+)>.*$/gim,Tv=(s,e)=>(t,i)=>{const o=i.trim(),r=s==="vertex"?bv[o]:Am[o];if(!r)throw new Error(`Cannot resolve "include <${o}>" in ${s} shader "${e}"`);return r+`
`};function el(s,e){return[(s==="vertex"?wv[e]:ep[e]).replace(Sv,Tv(s,e))]}function H(s){const e=Ei.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Ei.webglVersion}`,value:""},{type:uh,value:""}]);return i=>new n.Shader("vertex",e.concat(el("vertex",s)),t,i)}function G(s){const e=Ei.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Ei.webglVersion}`,value:""},{type:_h,value:""}]);return i=>new n.Shader("fragment",e.concat(el("fragment",s)),t,i)}const Y={name:"u_mat4_mvp",type:"mat4"},xt=[{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"},ns=[{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"}],mt=[{name:"u_int_abs_z",type:"1i"}],ae=[{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"}],Me=[{name:"u_vec2_camera_jitter",type:"2f"}];function Mv(){return{simpleMesh:{buildFragment:G("simple_mesh"),buildVertex:H("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:H("diffuse"),buildFragment:G("color_with_z_fade"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},...ae,...ye,...xe,...ie,...le,...Me],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},{name:"a_vec4_color",location:5}]},gradientDiffuse:{buildVertex:H("diffuse"),buildFragment:G("gradient_with_z_fade"),uniforms:[Y,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},...ae,...ye,...xe,...ie,...le,...Me],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_vec4_color",location:4}]},wallTexture:{buildVertex:H("wall_texture"),buildFragment:G("wall_texture"),uniforms:[Y,ne,{name:"u_float_height_factor",type:"1f"},{name:"u_float_mix_color",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"},...ae,...ye,...xe,...ie,...le,...Me],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},{name:"a_vec4_color",location:6}]},labelLine:{buildVertex:H("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"},...ae,...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:H("label_fixed_anchor"),buildFragment:G("label"),uniforms:[...xt,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"},...ae,...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:H("label_fixed_anchor_identify"),buildFragment:G("color_identify"),uniforms:[...xt,{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:H("line"),buildFragment:G("line"),uniforms:[Y,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},...ae,...ye,...xe,...ie,...le,...Me],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},{name:"a_vec4_color",location:8}]},pointSprite:{buildVertex:H("pointsprite"),buildFragment:G("pointsprite"),uniforms:[...xt,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"},...ae,...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:H("pointsprite_identify"),buildFragment:G("pointsprite_identify"),uniforms:[...xt,{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:H("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:H("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"},...ae,...le,...Me,...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:H("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,...ae,...le,...Me,...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:H("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,...ae,...le,...Me,...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:H("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,...ae,...le,...Me,...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:H("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:H("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:H("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"},...ae,...ye,...xe,...le,...Me],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_visibility",location:1},{name:"a_float_mix_factor",location:2}]},vtxColorIdentify:{buildVertex:H("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:H("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"},...ae,...le,...ye,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},zbmModelIdentify:{buildVertex:H("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:H("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:H("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"},...ae,...le,...Me],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_direction",location:1},{name:"a_vec2_widen_direction",location:2}]},zbmModel:{buildVertex:H("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"},...ae,...ie,...le,...Me,...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:H("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:H("gltf_model"),buildFragment:G("gltf_model"),uniforms:[...xt,ne,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_mat3_transform_tex_matrix",type:"mat3"},{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"},...ae,...Me,...le,...ie,...ye,...xe,...mt,...ns],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:H("gltf_model"),buildFragment:G("color_identify"),uniforms:[...xt,ne,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_mat3_transform_tex_matrix",type:"mat3"},{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"},...ae,...le,...ie,...mt,...ns],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:H("gltf_shadow"),buildFragment:G("main_shadow"),uniforms:[...xt,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_mat3_transform_tex_matrix",type:"mat3"},{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,...mt,...ns],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:H("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"},...ae,...Me,...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:H("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_mix_color",type:"1f"},{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"},...ae,...Me,...ye,...le,...xe,...ie,...mt],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},{name:"a_vec4_color",location:7}]},road:{buildVertex:H("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"},...ae,...ye,...le,...Me,...xe],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec2_shift",location:2}]},roadIdentify:{buildVertex:H("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:H("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,...ae,...ye,...le,...Me,...xe,...mt],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:H("line3d_identify"),buildFragment:G("road_identify"),uniforms:[Y,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...ie,...mt],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:H("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"},...ae,...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:H("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:H("circle_marker"),buildFragment:G("circle_marker"),uniforms:[...xt,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},...ae,...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:H("rect_with_texture"),buildFragment:G("rect_with_texture"),uniforms:[Y,ne,{name:"u_sr2d_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...le,...ae],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},circleMarkerIdentify:{buildVertex:H("circle_marker_identify"),buildFragment:G("color_identify"),uniforms:[...xt,{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:H("heatmap"),buildFragment:G("heatmap"),uniforms:[Y,ne,...ae,{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:H("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"},...ae,...le],attributes:[{name:"a_vec2_position",location:0}]},demMesh:{buildVertex:H("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"},...ae,...ie,...le,...Me,...ye,...xe],attributes:[{name:"a_vec2_position",location:0}]},demGround:{buildVertex:H("dem_ground"),buildFragment:G("dem_ground"),uniforms:[Y,ne,...ie],attributes:[{name:"a_vec2_position",location:0}]},demMesh2:{buildVertex:H("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"},...ae,...ie,...le,...Me,...ye,...xe,{name:"u_int_identify",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demMesh2DepthTest:{buildVertex:H("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:H("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:H("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:H("dem_elevation"),buildFragment:G("dem_elevation"),uniforms:[Y],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demHillshade:{buildVertex:H("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:H("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:H("mesh"),buildFragment:G("mesh"),uniforms:[Y,ne,...ae,...ie,...mt,...ye,...xe,...le,...Me,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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},{name:"a_vec4_color",location:9}]},inverse:{buildVertex:H("mesh"),buildFragment:G("inverse"),uniforms:[Y,ne,...ae,...ie,...mt,...ye,...xe,...le,...Me,{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:H("mesh"),buildFragment:G("depth_clear"),uniforms:[Y,ne,...ae,...ie,...mt,...ye,...xe,...le,...Me,{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:H("map_mesh"),buildFragment:G("map_mesh"),uniforms:[Y,ne,...ae,...ie,...ye,...xe,...mt,...le,...Me,{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:H("sky"),buildFragment:G("sky"),uniforms:[ne,...ae,...le],attributes:[{name:"a_vec2_vertex",location:0}]},taa:{buildVertex:H("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:H("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:H("posteffect"),buildFragment:G("copy"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_depth",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0}]},buildingShadow:{buildVertex:H("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:H("mesh_shadow"),buildFragment:G("main_shadow"),uniforms:[Y,{name:"u_float_height_factor",type:"1f"},...ie,...mt],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:H("globe"),buildFragment:G("globe"),uniforms:[...xt,{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:H("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:H("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:H("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 Ev(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 tl{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 r=t[o],a=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(r)||n.isArrayOfNumbers(r))for(let c=0;c<r.length;++c)i[a+c]=r[c];else i[a]=r}}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 r=i[this.params.blockName];r||console.error(`UBO block "${this.params.blockName}" not found in shader program.`);const a=e.getUniformsIndicesOffsetsInBlock(r);if(!a){console.error("Failed to initialize UBO. Couldn't retrieve uniforms information.");return}this._uniformsMap=a}}var os=(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))(os||{});const Mi=1/0,Ln=-1/0,Pn="renderCacheManager",Iv=[0,0,0,0];class Cv{constructor(e,t){this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.cacheObjectsCount=0,this.animationLayersOverCacheMinIndex=Mi,this.animationLayersUnderCacheMaxIndex=Ln,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=Mi,this.animationLayersUnderCacheMaxIndex=Ln,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===Mi&&this.animationLayersUnderCacheMaxIndex===Ln||this.isLowZoom||this.animationLayersUnderCacheMaxIndex>=this.animationLayersOverCacheMinIndex||o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forceRenderUnderCacheInDemMode)return 1;const r=this.getUniqueRenderIndex(t.attributes.styleId,t.attributes.layerId);return r>=this.animationLayersOverCacheMinIndex?2:r<=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(Pn),this.debugMode?this.modules.renderer.applyGpuState(W_,void 0,!1):this.modules.renderer.applyGpuState(j_,void 0,!1),this.modules.postEffectsManager.copyRenderTargetToCanvas(e,!0,!1),this.modules.renderer.restoreGpuState(Pn))}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?Ln:Mi;const r=this.modules.styleManager.getMaxLayersCount();return-e*r+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,r=this.modules.renderer.getViewportSize(),a=new Te({size:[r[0],r[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();a.setSize([l[0],l[1]])},renderTarget:a,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(Pn),this.modules.renderer.applyGpuState($_,void 0,!1),this.modules.renderer.clearWithColor(Iv,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.restoreGpuState(Pn))},onRenderEnd:()=>{},isCacheFramebuffer:!0,useDem:!0,renderIndex:Mi})}}const Lv=1.3,Pv=2,il=n.reserveTextureIndex(),nl=n.reserveTextureIndex(),ol=n.reserveTextureIndex(),Bv=16,zv=0,Ht=[1,1,1,1],sl=new Float64Array(16),ss=n.reserveTextureIndex();let Ei=(wt=class extends Dd{constructor(e,t){const i=t.layout.canvas,o=e.webglVersion,r={antialias:!1,stencil:o!==2,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer};let a=null;if((!o||o===2)&&(a=i.getContext("webgl2",r),wt.webglVersion=2),(a===null||o===1)&&(a=i.getContext("webgl",r)||i.getContext("experimental-webgl",r),wt.webglVersion=1),a===null||!(a instanceof WebGLRenderingContext||a instanceof WebGL2RenderingContext))throw new Error("Failed to obtain WebGL context");super({gl:a,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=a.getExtension("WEBGL_debug_renderer_info");this.webglContextState={MAX_TEXTURE_SIZE:a.getParameter(a.MAX_TEXTURE_SIZE),MAX_VIEWPORT_DIMS:a.getParameter(a.MAX_VIEWPORT_DIMS),MAX_UNIFORM_BUFFER_BINDINGS:a instanceof WebGLRenderingContext?0:a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS),MAX_COMBINED_UNIFORM_BLOCKS:a instanceof WebGLRenderingContext?0:a.getParameter(a.MAX_COMBINED_UNIFORM_BLOCKS),RENDERER:l?a.getParameter(l.UNMASKED_RENDERER_WEBGL):a.getParameter(a.RENDERER),VENDOR:l?a.getParameter(l.UNMASKED_VENDOR_WEBGL):a.getParameter(a.VENDOR)},this.identifyBuffer=new Te({minFilter:w.NearestFilter,magFilter:w.NearestFilter}),this.labelingTextureBuffer=new Te({size:this.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,depthTexture:!0}),this.spriteLabelingTextureBuffer=new Te({size:this.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,depthTexture:!1}),this.shaderProgramOptions=Mv(),this.shaderPrograms={},t.map.once("idle",()=>Ev(this,this.shaderProgramOptions)),this.symbolSettingsList=Df(),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"),wt.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 Of(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,r=t===!0?o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT:o.COLOR_BUFFER_BIT,a=t?Mr:Z_;this.applyGpuState(a),o.clearDepth(i),o.clearColor(e[0],e[1],e[2],e[3]),o.clear(r)}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),r=new Te({size:[o,o],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});this.addFramebuffer({clearColor:[0,0,0,0],renderTarget:r,renderIndex:0,onResize:()=>{},onRenderStart:()=>{t.activeTexture(t.TEXTURE0+ss),t.bindTexture(t.TEXTURE_2D,null)}}),this.globeRenderTargets[e]=r}return this.globeRenderTargets[e]}renderTileObjects(e){this.drawTargetsFramebufferIds.forEach(r=>{const a=this.getFramebuffer(r);a&&(a.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(r=>{o.groups.some(a=>a.framebuffer===r)||this.clearFramebuffer(r)}),this.lastRenderedFramebuffers=[],o.groups.forEach(r=>{var p,v,x,g;const{objects:a,tileObjects:l,isUnderCache:c}=r;let{framebuffer:d}=r;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=gt(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(a.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)}),It(this.state,this.modules,a,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 r=this.timers.tryToGetFirstTimerValue();r&&this.modules.map.emit("gpuRenderTime",r)}for(const[r,a]of this.drawTargetsFramebufferIds){const l=this.getFramebuffer(a);(!l||!l.requestedInCurrentFrame)&&(this.drawTargetsFramebufferIds.delete(r),this.removeFramebuffer(a))}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 r=gt(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 a=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(a)}),It(this.state,this.modules,t,r),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 r=gt(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 a=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(a,this.modules.demManager.demTextureMatrix)}),It(this.state,this.modules,t,r),o.renderTarget.unbind(this._gl),(_=o.onRenderEnd)==null||_.call(o)}renderSpriteLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache())return;const t=this._gl,i=[],o=gt(this.state,this.modules,void 0,this.spriteLabelingTextureBuffer,this.modules.map.state.demMode),r=e.filter(a=>a.labelTestChildren[0]);r.forEach(a=>{a.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),r.forEach(a=>{a.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]),It(this.state,this.modules,i,o),this.spriteLabelingTextureBuffer.unbind(t)}renderLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache()||(this.state.isLabelingDepthTestDisabled=!0,this.state.styleZoom<Bv||this.state.pitch===zv||this.state.disableHidingPois))return;const t=this._gl,i=[],o=gt(this.state,this.modules,void 0,this.labelingTextureBuffer,this.modules.map.state.demMode),r=e.filter(a=>a.depthTestChildren[0]);r.forEach(a=>{a.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),r.forEach(a=>{a.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]),It(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:r,framebuffer:a,isUnderCache:l})=>{var u,h,f;const c=this.modules.map.state.demMode&&(a===void 0||a.useDem===!0),d=a?a.renderTarget:this.identifyBuffer,_=gt(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=a==null?void 0:a.getViewProjectionMatrix)==null?void 0:u.call(a))!=null?h:this.modules.camera.viewProjectionMatrix,p=c?this.modules.demManager.demTextureMatrix:void 0;r.forEach(v=>{v.updateMvpMatrix(m,p)}),It(this.state,this.modules,o,_)}d.unbind(t),a==null||a.renderTarget.unbind(this._gl),(f=a==null?void 0:a.onRenderEnd)==null||f.call(a)})}waitForGpuCommandsToFinish(){const e=new Float32Array(4);this.readPixelsFloat(0,0,1,1,e)}readPixelsFloat(e,t,i,o,r){const a=this._gl;a.readPixels(e,t,i,o,a.RGBA,a.FLOAT,r)}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 r=(c=t==null?void 0:t.hash)!=null?c:"",a=(d=t==null?void 0:t.defines)!=null?d:[];let l=o[r];return l||(l=new oo(this._gl,this.shaderProgramOptions[e],n.Shader.createShaderDefinitions([...this.commonShaderDefines.defines,...a])),o[r]=l),l}enableShaderProgram(e){var t;e.enable(),this.isUboSupported()&&((t=this.ubosMap.CommonSettings)==null||t.bind(e))}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,r=window.devicePixelRatio;t.viewport(o.left*r,o.bottom*r,i[0]*r,i[1]*r)}}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(),r=this.modules.map.state.size,a=new Te({size:i?[Math.trunc(r[0]*Re[0]*o),Math.trunc(r[1]*Re[1]*o)]:this.getViewportSize(),magFilter:w.LinearFilter,minFilter:w.LinearFilter,depthTexture:!0,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,generateMipmaps:!1,format:wt.webglVersion===2?w.RedFormat:w.RgbFormat}),l={renderTarget:a,clearColor:[0,0,0,0],clearDepth:!0,onResize:()=>{const c=this.modules.map.state.demMode,d=this.modules.map.state.size;a.setSize(c?[Math.trunc(d[0]*Re[0]*o),Math.trunc(d[1]*Re[1]*o)]:this.getViewportSize()),this.modules.renderer.bindRenderTarget(a),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:r,tiles:a}=t;if(!r)return;let l=this.modules.demManager.getFlatMapTextures();if(i&&(l=l.filter(T=>T.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:T})=>T==="mesh"||T==="mesh2")[0];if(!u)return;const h=this.state.handyStyleId,f=this.modules.styleManager.getStyleLayer(h,n.DEM_STYLE_LAYER_ID);if(!f||es(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),S=[];a.forEach((T,C)=>{S.push({objects:T,tile:C})});const P=e.copy(r.renderTarget,!1,!0);l.forEach(T=>{var N,J;const I=S.filter(K=>rl(T.viewport,K.tile.bounds.values())).reduce((K,F)=>(F.tile.updateMvpMatrix(T.mvpMatrix,this.modules.demManager.demTextureMatrix),K.concat(F.objects)),[]),E=[],B=new Map;if(I.forEach(({obj:K,framebufferId:F})=>{if(F===void 0)E.push(K);else{const ee=B.get(F);ee?ee.push(K):B.set(F,[K])}}),B.forEach((K,F)=>{var be,we;const ee=this.getFramebuffer(F);ee&&((be=ee.onRenderStart)==null||be.call(ee),ee.renderTarget.bind(this._gl),this._gl.viewport(0,0,ee.renderTarget.options.size[0],ee.renderTarget.options.size[1]),ee.clearColor&&this.clearWithColor(ee.clearColor,!1),It(this.state,this.modules,K,P),ee.renderTarget.unbind(this._gl),(we=ee.onRenderEnd)==null||we.call(ee))}),(N=r.onRenderStart)==null||N.call(r),r.renderTarget.bind(this._gl),this._gl.viewport(0,0,r.renderTarget.options.size[0],r.renderTarget.options.size[1]),r.clearColor&&this.clearWithColor(r.clearColor,!1),It(this.state,this.modules,E,P),r.renderTarget.unbind(this._gl),(J=r.onRenderEnd)==null||J.call(r),i){this.identifyBuffer.bind(this._gl);const K=this.identifyBuffer.options.size;this._gl.viewport(0,0,K[0],K[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(K=>{if(K instanceof yr&&K.needSync&&K.syncReplicas(this.state),rl(T.viewport,K.bounds.values())){K.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix,T.texMatrix);const F=(i?K.identifyChildren:K.children).filter(({sink:ee})=>ee==="mesh"||ee==="mesh2");Eo(F,this.state,this.modules),e.drawSymbol(F,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:r}=o.state,a={},l={framebuffer:void 0,objects:[],tileObjects:new Set},c={framebuffer:void 0,objects:[],tileObjects:new Set,isUnderCache:!0},d={};let _;if(r){const h=t?i.getIdentifyFlatFramebufferId():i.getFlatFramebufferId(),f=this.getFramebuffer(h);f&&(_={framebuffer:f,tiles:new Map})}this.hasAnimatedFlatObjectInDemMode=!t&&r&&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||r&&x){const M=m.attributes.tiers;if(this.state.immersiveLevel.tiers&&M){let S=!1;if(M.forEach(P=>{if(!P){S=!0;return}d[P]||(d[P]={objects:[],tileObjects:new Set}),d[P].objects.push(m),d[P].tileObjects.add(h)}),!S)return}if(r&&!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 S=this.modules.renderCacheManager.tryToCacheObjects(a,m,h,r);if(S===os.CACHED)return;S===os.RENDER_OVER_CACHE?(l.objects.push(m),l.tileObjects.add(h)):(c.objects.push(m),c.tileObjects.add(h))}return}a[g]||(a[g]={framebuffer:this.getFramebuffer(g),objects:[],tileObjects:new Set}),a[g].objects.push(m),a[g].tileObjects.add(h)})});const u=Object.values(a).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(z({},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 tl({gl:t,blockName:"CommonSettings"}),this.ubosMap.CommonSettings=o,o.bind(i)),Zd(i,this.state,this.modules,o),o.commitData();const r=this.modules.map.state,a=!isNaN(r.handyStyleId)&&this.modules.styleManager.getStyle(r.handyStyleId)||void 0,l=(c=a==null?void 0:a.light.lightingModesResolved)!=null?c:n.DEFAULT_LIGHTING_MODES;for(const d in l){let _=this.ubosMap[d];(!_||e)&&(_=new tl({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(Ht[0],Ht[1],Ht[2],Ht[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:r}=this.calculateMapMeshParams(e),a=new Te({size:r,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(sl,[0,c/d[1],0],[1/d[0],1/d[1],1]),n.multiply(this.mapMeshMvpMatrix,sl,this.modules.camera.viewProjectionMatrix),this.mapMeshMvpMatrix},onResize:()=>{const c=this.calculateMapMeshParams(e);l.scale=c.scale,a.setSize(c.size),a.bind(t),a.unbind(t)},renderTarget:a,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),r=Math.min(Lv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[0])/o[0]),a=Math.min(Pv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[1])/o[1]),l=[Math.trunc(o[0]*t*r),Math.trunc(o[1]*t*a)];return{scale:[r,a],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:hh}),this.modules.environmentManager.isSkyEnabled()&&e.push({type:fh}),this.modules.shadowManager.texture&&e.push({type:Mh}),this.state.aaMode===Qt.FXAA?e.push({type:Yt.FXAA}):this.state.aaMode===Qt.TAA&&e.push({type:Yt.TAA}),Vs(this._gl)&&e.push({type:Th}),this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS>0&&e.push({type:Eh}),this.state.isDeprecatedSystem?e.push({type:Ph}):(e.push({type:Ih}),e.push({type:Ch})),this.webglContextState.RENDERER.toLowerCase().includes("mali")&&this.webglContextState.VENDOR.toLowerCase().includes("arm")&&e.push({type:Lh}),n.Shader.createShaderDefinitions(e)}},wt.webglVersion=NaN,wt);function rl(s,e){for(const t of e)if(n.tetragonIntersectsBounds(s,t))return!0;return!1}let Ii="./worker.js";function Rv(s){Ii=s}function Fv(){return Ii}function Dv(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 Ov(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 Nv(s){return{ModelsSource:s.set("ModelsWorker",n.ModelsWorker).get(n.ThreadName.Models)}}class kv{constructor(){this.connector=new n.MainConnector,this.fnRegistry=new n.FnRegistry(this.connector),this.classRegistry=new n.ClassRegistry(this.fnRegistry),this.parserWorker=new Worker(Ii),this.labelingWorker=new Worker(Ii),this.modelsWorker=new Worker(Ii),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=Dv(this.fnRegistry,this.classRegistry),this.labeling=Ov(this.fnRegistry),this.models=Nv(this.classRegistry)}syncStyle(e){this.parser.syncStyle(e),this.labeling.syncStyle(e)}destroy(){this.parserWorker.terminate(),this.labelingWorker.terminate(),this.modelsWorker.terminate()}}function Uv(s=!1){const e=typeof window!="undefined",t=typeof SharedArrayBuffer!="undefined",i=e&&window.crossOriginIsolated===!0,o=typeof OffscreenCanvas!="undefined",r=typeof HTMLCanvasElement!="undefined",a=r&&"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:",r),console.log("[render][check] hasTransferControlToOffscreen:",a));const l=e&&t&&i&&o&&r&&a;return console.log(`[render] mode: ${l?"worker":"main thread"}`),l}function Hv(){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 Gv{constructor(e,t){var a;if(this.frameWriteSlot=1,this.frameId=0,!e.webgpu)return;const i=Uv();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=Hv();(a=t.layout.canvas.parentElement)==null||a.appendChild(o);let r;if(i){this.worker=new Worker(Fv(),{name:"Render"}),this.worker.postMessage({msg:{youare:"render"}});const l=o.transferControlToOffscreen();r=n.wrap(this.worker)(n.RenderBackendType.WebGPU,n.transfer(l,[l]),this.transportBuffer)}else r=n.createRenderRunner(n.RenderBackendType.WebGPU,o,this.transportBuffer);r.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 q(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 Vv{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(z({},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 q(this,null,function*(){const t=this.modules.renderer.getRenderingContext(),i=this.modules.renderer.identifyBuffer,o=i.options.size,r=o[0],a=o[1];if(e||t instanceof WebGLRenderingContext||this.state.forceSyncIdentify){const l=new Uint8Array(r*a*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)=>{q(this,null,function*(){const d=new Uint8Array(r*a*4);i.bind(t);const _=r*a*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,r,a,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((r,a)=>{function l(){const c=e.clientWaitSync(t,i,0);if(c===e.WAIT_FAILED){a();return}if(c===e.TIMEOUT_EXPIRED){setTimeout(l,o);return}r()}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 r=1/0,a,l=!1;const c=n.create$6();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);(!a||!l&&_||d.phase>a.phase||d.phase===a.phase&&u<r)&&(a=d,r=u,_&&(l=!0))}return a}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 r=Math.floor(e[0]*t),l=((i[1]-1-Math.floor(e[1]*t))*i[0]+r)*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 q(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(r=>this.identifyData.push(r))})}catch(e){console.warn(`Cannot fill cache: ${e}`)}finally{this.cacheBusy=!1}})}indexToIdentifierResponse(e){var t,i,o;for(let r=0;r<this.identifyData.length;r++){const a=this.identifyData[r],{dynamicObjectId:l,ids:c,metatileHash:d,sourceId:_,tileKey:u}=a,{startIndex:h,endIndex:f,idBuffer:m,floorIdBuffer:p,phaseBuffer:v,sublayerBuffer:x,styleIdBuffer:g,layerIdBuffer:y,instanceIdBuffer:b,objectClassBuffer:M,centerBuffer:S,strings:P}=c;if(e<h||e>f)continue;const T=e-h,C=m[T],I=new Uint32Array(x)[T],E=new Uint8Array(b)[T],B=new Uint32Array(M)[T];let N,J="";const K=p[T],F=this.modules.assetManager.getMetatile(d);if(F){(t=F.reverseDictionaries.db_sublayer)!=null&&t[I]&&(N=F.reverseDictionaries.db_sublayer[I]);const Ve=P[e];Ve!==void 0?J=Ve.objectClass:J=(o=(i=F==null?void 0:F.reverseDictionaries.db_object_class)==null?void 0:i[B])!=null?o:""}const ee=new Uint16Array(g)[T],be=new Uint32Array(y)[T],we=this.modules.styleManager.getStyleLayer(ee,be);if(!we||we.type==="custom")return;const Ke=new Int32Array(S,T*Int32Array.BYTES_PER_ELEMENT*2,2);return{id:C,styleId:ee,layerId:be,floorId:K,phase:new Float32Array(v)[T],dynamicObjectId:l,sourceId:_,tileKey:u,sublayer:N,symbol:we.type,instanceId:E,objectClass:J,center:Ke[0]!==n.INVALID_IDENTIFY_CENTER_COORD||Ke[1]!==n.INVALID_IDENTIFY_CENTER_COORD?[Ke[0],Ke[1]]:void 0}}}}function Zv(s,e,t){var r;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 a=Object.values(e.groupsById).find(l=>l&&l.id===t);if(a)i=e.layers.findIndex(l=>l.groupId===a.innerId);else{i=e.layers.findIndex(c=>c.id===t);const l=(r=e.layers[i])==null?void 0:r.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 a=i!==e.layers.length?e.layers[i]:void 0;if(a&&a.groupId!==void 0){const l=e.groupsById[a.groupId];if(!l){n.log(`Для слоя с id «${a.id}» находящегося в группе с groupId «${a.groupId}» отсутствует группа id в стиле c id «${e.id}»`);return}const c=l.layers.findIndex(d=>d.id===a.id);if(c===-1){n.log(`Слой с id «${a.id}» и groupId «${a.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(a=>{if(e.layersById[a.innerId]=a,e.layerIdToInnerId[a.id]=a.innerId,a.type==="point"||a.type==="polygon"||a.type==="metricPoint"||a.type==="embankment"||a.type==="polygon3d"){const l=Math.max(0,...Object.keys(e.rasterSets.byIndex).map(_=>Number(_))),c=new n.HandyIndexer(l+1);n.makeHandyRasterSets(a,c,e.icons).forEach(_=>{e.rasterSets.byKey[_.key]||(e.rasterSets.byIndex[_.index]=_,e.rasterSets.byKey[_.key]=_)})}}),al(e)}function jv(s,e,t){const i=e.layerIdToInnerId[s];if(i===void 0)return;e.revision++;let o=[];const r=e.groupsById[i];if(r){if(o=r.layers,delete e.groupsById[i],delete e.layerIdToInnerId[r.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 a=e.layers.findIndex(l=>l.id===o[0].id);a!==-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(a,o.length),al(e))}function al(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 Wv(s,e,t){const{map:{state:i},collector:o,imageManager:r,renderer:a,tileManager:l}=t;let c;try{c=$v(i,s,256)}catch(g){console.error(g);return}const d=r.addPreparedTexture(c),{downscale:_}=s.style,{size:u}=i,h=new Te({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=r.addPreparedTexture(f),p=a.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/_)]),a.bindRenderTarget(h),a.bindRenderTarget(null);const g=h.getTexture();g&&r.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),r.deleteTexture(m),r.deleteTexture(d),a.removeFramebuffer(p)}}function $v(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=e.style.color,r=[];if(!Xv(o.argument))throw new Error(`Heatmap color must be interpolate expression with 'heatmap-density' argument in layer ${e.id}`);const a=t-1;for(let l=0;l<t;l++){const c=l/a,d=n.sampleColor(o,c,i);r.push(...d.value)}return new w(new Uint8Array(r),{size:[t,1]})}function Xv(s){return typeof s=="object"&&s.type==="heatmap-density"}const ll=1,cl={type:"color",value:[0,0,0,0]};class Kv{constructor(e){this.modules=e,this.customLayers=new Map,this.maxCountStyleLayers=1e4,this.styleIndex=ll,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 r=this.styleIndex++;r-n.UNUSED_STYLE_ID_SHIFT>0&&this.handyStylesMap.delete(r-n.UNUSED_STYLE_ID_SHIFT);const a=n.makeHandyStyle(e,r,i);n.applyStyleOptions(a,t),this.handyStylesMap.set(a.id,a),this.setMaxLayersCount(a.layers.length);const l=this.waitingStyleRequests.get(r);return l&&l.resolve(a),this.modules.workers.syncStyle(a),a.layers.forEach(c=>this.initHandyLayer(r,c)),a}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&&(Zv(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)),r=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,...r].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:r,imageType:a,anchor:l})=>{n.expressionValues(r).forEach(c=>{if(c===e){const d=a==="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)||(jv(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 r;const o=(r=this.handyStylesMap.get(e))==null?void 0:r.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(r=>{o.resolve=r}),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 r=n.makeBinderContext(i.styleZoom,i.styleState,[]),a=n.resolveColor(o.environment.style.skyColor,r),l=i.globeMode?t.globeRatio:0;return n.lerp$3(cl.value,o.background.color.value,a.value,l),cl}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:r}=t;if(o&&i.layersById){const a=i.layerIdToInnerId[o];if(a){const l=i.layersById[a];if(l)l.style&&(l.style.visibility=e);else{const c=i.groupsById[a];c==null||c.layers.forEach(d=>{d&&d.style&&(d.style.visibility=e)})}}}r&&i.layers.forEach(a=>{a.type===r&&(a.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=Wv(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,r){const a={sceneObject:{type:n.SceneObjectType.Custom,attributes:{styleId:e,layerId:t.innerId,tileData:[]},tile:{zoomLevel:0},layerSettings:{},canRender:!0},layer:t,renderFunction:i};r==null||r(),this.customLayers.set(t.innerId,a),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((r,a)=>{var _;const l=(_=i==null?void 0:i.icons[r.image])==null?void 0:_.url;if(!l){console.warn(`Texture source for polygonExtrusionSideTexture ${r.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[a]=u)})}),()=>{o=!0}}}class bt{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 r=0;r<o.length;r++)o[r].call(this,t);return this}}class qv{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),r=this.modules.collector,a=this.modules.styleManager.getStyle(i);if(!a||!a.environment)return Promise.resolve({results:[]});n.generateSafely({collector:r,generator:n.GlobeGenerator.sinks.fill.generate,args:[a,a.environment,o]});const l=r.getAccumulatedData();return Promise.resolve({results:[{styleId:i,metatileHash:-1,regionId:-1,collectorOutput:l}]})}abortTileFetches(){}deleteTiles(){}setAttributes(){}getAttributes(){return{}}}const Bn="gltfModels";let dl=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 r=n.TileLayer.prototype.getLabelingData.call(this.universeTileLayer);return this.regionalTileLayer.isBlank()||(r.labelsKeys=[]),r},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:Bn}},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=z({regionalTileLayer:this.regionalTileLayer.memSizeJs(),universeTileLayer:this.universeTileLayer.memSizeJs(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeJs():{}},this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeJs()}),t=z({regionalTileLayer:this.regionalTileLayer.memSizeGpu(),universeTileLayer:this.universeTileLayer.memSizeGpu(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeGpu():{}},this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeGpu()});return{js:de(z({},e),{"--sum":n.getTotalMemory(e)}),gpu:de(z({},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(z(z({},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(z({},e),{sourceName:Bn})),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,r,a,l,c){return this.zenithSource.generateTile(e,t,i,o,r,a,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 qv(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 Yv extends bt{constructor(e,t){super(),this.loadFont=(r,a)=>{let l=this.requestFontRanges.get(r,a);return l||(l=this.createLoadFontRequest(r,a),this.requestFontRanges.set(r,a,l)),l},this.invalidateUsedGltfModels=n.throttle(()=>{var c;const r=new Set;if(this.modules.renderer.isDestroyed)return;const a=this.modules.tileManager.getTileObjects();for(const d of a)for(const _ of d.children){if(!es(_))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){r.add(y);return}if(x===g){const b=this.dataModelIdToUrl[g];if(b){const M=m===this.modules.defaultSource.getId()&&p===Bn;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(!es(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&&r.add(x)})}});for(const d in this.models){const _=this.models[d];!_.preserve&&!r.has(_)&&_.status===tt.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=(r,a,l)=>{const c=n.hashToString(a);fetch(r).then(d=>{if(!d.ok)throw new Error(`Failed to load metatile "${c}"`);return d.json()}).then(d=>this.setMetatile(a,l,d)).catch(d=>console.error(d))};const i=(r,a)=>{const l=this.modules.styleManager.getStyle(r);if(!l){console.error(`Not found style ${r} in AssetManager#addNewRasterSets`);return}const{rasterSets:c}=l;a.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((r,a)=>{var l,c;return r.push({bitmap:(c=(l=a.bitmap)==null?void 0:l.byteLength)!=null?c:0}),r},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(z({},e),{"--sum":n.getTotalMemory(e)}),gpu:de(z({},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:r}=o,a=7,l=t.length/a;for(let u=0;u<l;u++){const h=t[u*a],f=t[u*a+1],m=t[u*a+6],p=t[u*a+2],v=t[u*a+3],x=t[u*a+4],g=t[u*a+5],y=r.byIndex[h];if(y.isSvg){const S={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]=S,(d=(c=this.requestedSvgs[o.id])==null?void 0:c[h])==null||d.then(P=>{const T=this.textures[S.atlasIndex],{url:C,revokeURL:I}=Fa(P);Ra(C,S.w,S.h).then(E=>{T.subImage(E,S.x,S.y),this.modules.renderer.addRerenderEvent(),I&&I()})})}else{const S=(_=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]=S,S.x=p,S.y=v,S.atlasIndex=m,S.isPacked=!0}this.textures[m]===void 0&&(this.textures[m]=new w(void 0,{size:n.atlasSize,flipY:!1,premultiplyAlpha:!sd,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 r=e[o*3],a=e[o*3+1],l=e[o*3+2],c=a<<16|l,d=this.modules.styleManager.getStyle(r);if(!d){console.error(`Not found style ${r} in AssetManager#loadRasters`);continue}if(this.loadedRasters[r]||(this.loadedRasters[r]=new Set,this.failedRasters[r]=new Set,this.requestedRasters[r]=new Set),this.requestedRasters[r].has(c))continue;const{rasterSets:_}=d,u=_.byIndex[a];if(u.rasters[l].isPacked===!1){console.error(`Try to load not packed raster ${u.key}`);continue}this.requestedRasters[r].add(c),u.isSvg?this.loadSvg(c,d,a):this.loadPng(c,d,a,l)}}removeRasterSet(e,t){const{key:i,index:o,rasters:r}=e;delete this.requestedSvgs[t][o],r.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 a=this.modules.styleManager.getStyle(t);a&&(delete a.rasterSets.byIndex[o],delete a.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 r=this.modules.styleManager.getStyle(t);if(r===void 0){n.logGltfError({layer:"prepare",message:"Style not found. Can't determine url"});return}const a=r.models[e];if(a===void 0){n.logGltfError({layer:"prepare",message:`Model with index "${e}" is missing in the style.`});return}const l=n.getModelUrl(a.url,r);this.fetchModel(l,e,o,!1,i,!1)}loadModel(e,t,i,o,r,a,l){const c=this.getModelUniqueKey(t,i);if(this.models[c]!==void 0){l==null||l();return}this.fetchModel(e,t,c,o,r,a,l)}getModel(e,t){return this.models[this.getModelUniqueKey(e,t)]}allModelsLoaded(){for(const e in this.models)if(this.models[e].status===tt.Pending)return!1;return!0}isModelLoaded(e,t){const i=this.models[this.getModelUniqueKey(e,t)];return i&&i.status===tt.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,r,a,l){const{renderer:c}=this.modules,d=this.models[i]=mf(o);this.modelsWorker.loadModel(e,this.state.dracoDecoderUrl).then(_=>{if(_.type==="ok"){if(d.status=tt.Loaded,!_.result)return;pf(d,c,_.result,t,r,a),this.emit("modelloaded",t),this.modules.renderer.addRerenderEvent(),l==null||l()}else n.logGltfError(_),d.status=tt.Failed})}getModelUniqueKey(e,t){return e>=0?`${t},${e}`:String(e)}createLoadFontRequest(e,t){return q(this,null,function*(){this.pendingFontRanges+=1;const i=Number.isNaN(this.state.handyStyleId)?ll:this.state.handyStyleId;try{const o=yield this.modules.styleManager.waitForStyle(i),r=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()),a=n.processFont(r);return this.prepareFontAtlas(e,t,a),this.modules.workers.labeling.appendFont(e,a.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:r,height:a,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:[r,a],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 q(this,null,function*(){const r=t.rasterSets.byIndex[i],a=r.rasters[o],l=this.textures[a.atlasIndex];let c="";if(r.type===n.RasterSetType.Unique){const d=r.id;r.url?c=n.getSizeDependentImageUrl(r.url,a.w,a.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:a.w.toString(),height:a.h.toString(),regionId:String(r.regionId)})}else if(r.type===n.RasterSetType.Static){const d=t.icons[r.name];if(!d){console.error(`There is no appropriate icon config in the style for raster set: "${r.name}"`),this.failedRasters[t.id].add(e);return}c=n.getUrlForIconMapIcon(d.url,t,n.getSubdomainFromString(this.state.subdomains,r.name))}this.modules.workers.parser.prepareAtlas(c).then(d=>q(this,null,function*(){if(d){if(d.isBitmap){if((d.data[0].width!==a.w||d.data[0].height!==a.h)&&r.type===n.RasterSetType.Static){if(a.w<=0||a.h<=0)return;const _=document.createElement("canvas");_.width=a.w,_.height=a.h,_.getContext("2d").drawImage(d.data[0],0,0,_.width,_.height),l.subImage(_,a.x,a.y)}else l.subImage(d.data[0],a.x,a.y);this.modules.renderer.addRerenderEvent()}else wn(d.data[0]).then(_=>{l.subImage(_,a.x,a.y),this.modules.renderer.addRerenderEvent()});this.loadedRasters[t.id].add(e),r.isReady=!0}else this.failedRasters[t.id].add(e)}))})}loadSvg(e,t,i){return q(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 r=t.icons[o.name];if(!r){console.error(`There is no appropriate icon config in the style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const a=n.getUrlForIconMapIcon(r.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(a,{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:_}=Fa(c),u=yield Ra(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 Qv{constructor(e,t,i,o,r,a,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=r,this.selectedIds=a,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=Av(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:r,offset:a}}}=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:a,matrix:r};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 r;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?1/0:(r=o==null?void 0:o.minzoom)!=null?r:-1/0})))),this.maxStyleZoom=Math.max(...e.map(t=>Math.max(...t.children.map(i=>{var r;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?-1/0:(r=o==null?void 0:o.maxzoom)!=null?r:1/0}))))}}function Jv(s,e,t,i,o){const r=e.join("|");return`model=${s}_sId=${t}_sRev=${i}_mRev=${o}_sel=${r}`}function Av(s,e){var r,a,l;const t=new ul(s,e),i=[],o=_l((l=(a=(r=t.children[0])!=null?r:t.identifyChildren[0])!=null?a: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=_l(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 ul([],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 _l(s){if(s&&"matrix"in s.attributes)return s.attributes.matrix}class ul 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 eg{constructor(e,t,i,o,r,a){var l;this.modules=e,this.mapState=t,this.cache=i,this.regionId=o,this.metatileHash=r,this.sourceModel=a,this.revision=0,this.texturesLoaded=!1,this.textures=[],this.readiness=0,this.id=a.id,this.attributes=(l=a.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=>wn(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 r=Jv(this.id,e,t,i,o),a=this.cache.get(r);a?(this.newMod=a,this.newMod.useful=!0):this.newMod=new Qv(this.modules,this.mapState,this.cache,this,r,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 tg{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),r=Math.min(t.sourceModel.maxZoom,i.maxStyleZoom),{styleZoom:a}=this.mapState;if(!(a<o||a>=r))return{minStyleZoom:o,maxStyleZoom:r,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:r}=t.sourceModel;if(e<o||e>=r)return;const a=this.mapState.styleState._activeFloorIds,l=t.attributes.db_hidden_by_plan_id;if(l&&a.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(r=>this.modules.tileManager.removeObject(r)),e=!0)}),t.forEach((i,o)=>{this.displayedMods.has(o)||(i.objects.length&&i.objects.forEach(r=>this.modules.tileManager.addObject(r)),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(r=>{if(!r.fileName){console.error(`ZBM source "fileName" is empty. Failed to load model by url: ${e}`);return}const a=new eg(this.modules,this.mapState,this.cache,t,i,r);this.models.set(a.id,a)}),this.loadedModelsInfo.add(t)}).catch(o=>{this.loadedModelsInfo.add(t),console.error(o)}))}updateObjectsVisibility(){const e=this.ids;this.models.forEach(t=>{var r;const i=((r=this.getVisibleModelData(t.id))==null?void 0:r.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 ig{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=hl(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:r}=i,a=this.modules.map.state;this.isGenerating=!0,this.modules.workers.parser.generatePersonalPoi(t,o,r,window.devicePixelRatio,this.ids.getSelected(),a.handyStyleId,a.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:r,identifyIds:a},styleId:l}=t;this.modules.labeler.removeLabels("ppoi"),r.length&&this.modules.labeler.addLabels("ppoi",n.LabelSource.PersonalPoi,[{metatileHash:o,labels:r,styleId:l}]),this.identifyDataChunk={metatileHash:o,ids:a},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=hl(t,e))}}function hl(s,e){return`ppoi_${s}_${e.join("|")}`}let rs=(jt=class extends n.Evented{constructor(e,t){super(),this.fogFactorBreakpoint=.4,this.demElevation=0,this.demTilesRevision=NaN,this.options=n.applyDefaults(t,jt.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=ng(this.options),this.isHidden=!0,this.targetOpacity=0,this.modules.layers.addLayer(this),this.mapState=e.state,this.rounder=og(!this.options.disableRounding);let{offset:o}=this.options;const{labeling:r}=this.options;r.type!=="none"&&(r.offset!==void 0&&(o=r.offset),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:r.width,height:r.height,position:this.position.normalizedValue,offset:o,labelingGroup:this.getLabelingGroup(),parentPoiId:r.type==="pinnedToPoi"?r.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 r=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)}),a=r.map(d=>Math.abs(this.mapState.size[0]/2-(isNaN(d[0])?-1/0:d[0]))),l=a.findIndex(d=>d===Math.min(...a));return r[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,r=(this.position.normalizedValue[1]-i[1])/t,a=Math.sqrt(We(o,2)+We(r,2)),l=e[1]-e[0];return n.clamp((a-e[0])/l,0,1)<this.fogFactorBreakpoint}isInvolvedInLabeling(){return this.options.labeling.type==="full"||this.options.labeling.type==="pinnedToPoi"}},jt.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:""},jt);function ng(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 og(s){return s?sg:rg}const sg=(s,e,t,i)=>{const o=Math.round(e),r=Math.round(t),a=o-e,l=r-t;s[0]=e+i*a,s[1]=t+i*l},rg=(s,e,t)=>{s[0]=e,s[1]=t},ag="#0085a0",lg="#ffffff",cg=4,dg=1,_g=2,ug=1.5,hg=2.8,fl=6,fg=!0,mg=17.1,as=n.entranceAnimation.iterationCount,ls=n.create$1();class cs extends $e{constructor(e,t){var p,v,x,g,y,b,M,S,P,T,C,I,E;super(e,{interactive:(p=t.interactive)!=null?p:!1}),this.options=t,this.vectors=this.options.coordinates.map(B=>B.map(N=>n.Mercator.fromGeo(N))),this.bouncePosition=0,this.growPosition=1;const{tileManager:i,dynamicStyle:o,collector:r,layers:a}=this.modules,l=(v=this.options.animate)!=null?v:fg;let c;if(l&&!this.mapState.disableLayerAnimation){const B=(x=this.options.iterationCount)!=null?x:as;B>1?c={type:"repeat",tipMovementAmplitude:this.options.tipMovementAmplitude||fl,iterationCount:B}:B===1&&(c={type:"appearance",tipMovementAmplitude:this.options.tipMovementAmplitude||fl})}const d=n.makeHandyStyleLayer({type:"arrow",id:`dynamic-entrance-${this.uniqId}`,interactive:this.interactive,minzoom:(g=this.options.minZoom)!=null?g:mg,maxzoom:this.options.maxZoom,style:{color:(y=this.options.color)!=null?y:ag,strokeColor:(b=this.options.borderColor)!=null?b:lg,lineWidth:(M=this.options.width)!=null?M:cg,strokeWidth:(S=this.options.borderWidth)!=null?S:dg,tipWidth:(P=this.options.wingWidthMultiplier)!=null?P:ug,tipHeight:(T=this.options.tipHeightMultiplier)!=null?T:hg,roundingRadius:(C=this.options.roundingRadius)!=null?C:_g,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,this.interactive?"0":"");n.runPrecomputes(d,h);for(let B=0;B<this.vectors.length;B++){const N=this.vectors[B],J=this.getVertices(N,_);h.id=String(B),n.generateSafely({collector:r,generator:n.ArrowGenerator.generate,args:[o.getStyle().id,d,h,J]})}const f=r.getAccumulatedData(),m=new n.TileObject("dynamicObject",f.data,this.modules,this.mapState,_.coords,this);this.tileObjects.push(m),i.addObject(m),this.interactive&&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:(B,N)=>this.bouncePosition=N,complete:()=>{this.bounceTickerUpdate=void 0}},this.mapState),this.growTickerUpdate=n.update.bind(null,this.growTickerId,{step:(B,N)=>this.growPosition=N,complete:()=>{this.growTickerUpdate=void 0}},this.mapState),n.start(this.bounceTickerId,{easing:n.entranceAnimation.bounceType},this.mapState,-1,0,n.entranceAnimation.bounceTime,(I=this.options.iterationCount)!=null?I:as,{layerId:this.layerId,styleId:o.getStyle().id}),n.start(this.growTickerId,{easing:n.entranceAnimation.growType},this.mapState,0,1,n.entranceAnimation.growTime,(E=this.options.iterationCount)!=null?E:as,{layerId:this.layerId,styleId:o.getStyle().id})):(this.bouncePosition=0,this.growPosition=1),a.addLayer(this),r.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()}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.interactive&&this.modules.identifier.resetCache(),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 r=0;r<e.length;r++)n.mapPointToTilePoint(ls,e[r],t),i[r]=ls[0],o[r]=ls[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 pg{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 $e)}getHtmlMarkers(){return this.layers.filter(e=>e instanceof rs)}entranceAnimationFinished(){return this.layers.every(e=>e instanceof cs?!e.entranceAnimationInProgress():!0)}}const ml=()=>"",vg=[.5,.5];class gg{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.cache={}}getRasterSet(e,t,i,o){return q(this,null,function*(){const r=this.getKey(e,i,o),a=this.getFromCache(r,t);if(a)return a;const l=yield this.loadIcon(e,t,i,o);return l&&this.storeInCache(l,r,t),l})}clear(){this.cache={}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}loadIcon(e,t,i,o){return q(this,null,function*(){const{dynamicStyle:r,workers:a,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]]:vg,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]}]);r.appendRasterSet(h),a.labeling.addNewRasterSets(r.getStyle().id,[h]);const f=new Uint16Array(3);return f[0]=u[0],f[1]=u[1],f[2]=h.index,a.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(r.getStyle().id,u,[Da(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||ml)}storeInCache(e,t,i){this.cache[t]||(this.cache[t]=new Map),this.cache[t].set(i||ml,e)}getKey(e,t,i){const o=t!==void 0?`${t[0]},${t[1]}`:"",r=i!==void 0?`${i[0]},${i[1]}`:"";return`${e}_${o}_${r}`}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 pl={trafficOn:!1,parkingOn:!1,navigatorOn:!1,immersiveRoadsOn:!1,floorStackOn:!1,terrainEnabled:!1,graphicsPreset:$t()?"light":"immersive",_activeFloorIds:[],_activeFloorBuildingIds:[],_activeFloorIsMetro:!1,_floorHeight:3.5,_customUserTimeOffset:0};let zn=!1;function yg(){return z({},pl)}function Rn(s,e){return s=z({},s),(e==null?void 0:e.immersiveRoadsOff)===!0?(zn=!0,s.immersiveRoadsOn=!1):zn&&(s.immersiveRoadsOn=zn,zn=!1),s.graphicsPreset&&s.graphicsPreset!=="light"&&$t()&&(console.warn(`"${String(s.graphicsPreset)}" graphicsPreset is not supported in deprecated system. Using "light" instead.`),s.graphicsPreset="light"),z(z({},pl),s)}function vl(s,e,t){const i=de(z(z({},s),e),{_activeFloorIds:s._activeFloorIds,_activeFloorBuildingIds:s._activeFloorBuildingIds,_activeFloorIsMetro:s._activeFloorIsMetro,_floorHeight:s._floorHeight});return Rn(i,t)}function gl(s,e=[],t=[],i=!1){return de(z({},s),{_activeFloorIds:e,_activeFloorBuildingIds:t,_activeFloorIsMetro:i})}const yl=["default","metro"],ds="floorStackTicker",xg=500,Fn={MAX_DISTANCE_METERS:500,VERY_CLOSE_DISTANCE_METERS:500,DISTANCE_WEIGHT_MULTIPLIER:3,VERY_CLOSE_BONUS:1.5};class bg{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 r=this.repository.descriptors[i].get(o);return e.linked_floors_ids.some(a=>r==null?void 0:r.floorIds.includes(a))}).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((r,a)=>{let l=this.repository.floorIdsToObjectIds.get(a);l===void 0&&(l=new Set,this.repository.floorIdsToObjectIds.set(a,l));for(const c of r)l.add(c);this.loadFloor(a,e,t)})}changeFloorNumber(e,t){var a;const i=this.viewport.default.current,o=this.viewport.metro.current,r=i||o;if(r&&(r.id===e||r.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"),r.mode="building",this.displayedComplex=null,this.modules.map.emit("floorcomplexhide",{id:e});else{if(t<0||t>=r.floors.length)return;this.setFloorIdx(t),r.selectedFloorIdx=t,o&&o.mode==="metro"&&(o.mode="floor",this.modules.map.emit("floorcomplexhide",{id:o.id})),this.displayedComplex!==r&&!((a=this.displayedComplex)!=null&&a.buildings.includes(r.id))&&this.modules.map.emit("floorcomplexshow",{id:r.id,mode:"floor",currentFloor:t,floorNames:r.floors.map(({name:l})=>l),firmsToFloorIndexMap:r.firmsToFloorIndexMap}),this.displayedComplex=r,this.updateStackState(),r.mode="floor",this.modules.map.emit("floorcomplexlevelchange",{id:e,floorIndex:t,floorName:r.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 r of this.hiddenBuildingIds){if(t)break;const a=this.repository.descriptors.default.get(r);t=!!(a!=null&&a.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,r=!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 a=this.shouldIgnoreFloorState?"building":i.mode;t={id:i.id,mode:a==="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&&r&&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(r=>{if(r.ok===!1)throw new Error(r.statusText);return r.json()}).then(r=>{var _;let a=r.default_floor_idx,l="default";"is_metro"in r&&r.is_metro&&(a=r.default_metro_floor_idx,l="metro");const c=r.floors.reduce((u,h,f)=>(h.id&&(u[h.id]=f),u),{}),d={id:e,regionId:t,metatileHash:i,center:r.center,bound:r.bound,defaultFloor:a,selectedFloorIdx:a,mode:"floor",floors:r.floors,floorIds:r.floors.map(u=>u.id).filter(Boolean),buildings:r.linked_buildings_ids?r.linked_buildings_ids.concat(e):[e],firmsToFloorIndexMap:Object.entries((_=r.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 r;const o=i-this.displayedComplex.defaultFloor;t.id&&this.stack.offsets.set(t.id,o),o>e&&(e=o),(r=t.linked_floors_ids)==null||r.forEach(a=>{this.stack.offsets.set(a,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=gl(e,[],[],!1));return}const t=new Set,i=new Set,o=new Set(this.state.styleState._activeFloorIds),r=new Set(this.state.styleState._activeFloorBuildingIds),a=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(_)),(xl(o,t)||xl(r,i)||a!==(this.displayedComplex.mode==="metro"))&&(this.state.styleState=gl(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 r=this.ids.floor.getHidden(),a=n.intersection$1(i,r);this.ids.default.hide(Array.from(a),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(ds,{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(ds,{easing:"easeOutQuint"},this.state,0,1,xg,1)):(this.stack.readiness=1,n.stop(ds,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:r,viewport:a,padding:l,cameraConfig:c,globeMode:d}=this.state,_=new n.Camera({center:t,zoom:i,rotation:o,size:[Math.floor(r[0]*(1-n.floors.viewportPadding)),Math.floor(r[1]*(1-n.floors.viewportPadding))],styleState:{},pitch:0,viewport:a,padding:l,cameraConfig:c,globeMode:d}),u=_.getViewportVertices().map(m=>[m[0],m[1]]),h=wg(u),f=[[0,0],[0,0],[0,0],[0,0]];yl.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(Sg(_.position,y)){if(v){const S=bl(y);S<v.complexArea&&(v.complex=g.complex,v.complexArea=S)}else v={complex:g.complex,complexArea:bl(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=Tg(f,u);if(b.length<3)continue;const M=Eg({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)}),yl.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 xl(s,e){if(s.size!==e.size)return!0;for(const t of s)if(!e.has(t))return!0;return!1}function wg(s){let e=s[0][0],t=s[0][1],i=e,o=t;for(let r=1;r<s.length;r++){const[a,l]=s[r];a<e?e=a:a>i&&(i=a),l<t?t=l:l>o&&(o=l)}return{minX:e,minY:t,maxX:i,maxY:o}}function Sg(s,e){return s[0]>=e.min[0]&&s[0]<=e.max[0]&&s[1]>=e.min[1]&&s[1]<=e.max[1]}function bl(s){return(s.max[0]-s.min[0])*(s.max[1]-s.min[1])}function Tg(s,e){let t=s;for(let r=0;r<e.length;r++){const a=e[r],l=e[(r+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,a,l)?(i(_,a,l)||t.push(o(_,u,a,l)),t.push(u)):i(_,a,l)&&t.push(o(_,u,a,l))}}return t;function i(r,a,l){return(l[0]-a[0])*(r[1]-a[1])>(l[1]-a[1])*(r[0]-a[0])}function o(r,a,l,c){const d=a[1]-r[1],_=r[0]-a[0],u=d*r[0]+_*r[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?a:[(f*u-_*m)/p,(d*m-h*u)/p]}}function Mg(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 Eg(s){const e=Math.sqrt(We(s.complex.center[0]-s.cameraPosition[0],2)+We(s.complex.center[1]-s.cameraPosition[1],2)),t=e/(Fn.MAX_DISTANCE_METERS*n.MAP_POINTS_IN_METER),i=Math.max(0,1-t),o=e<Fn.VERY_CLOSE_DISTANCE_METERS*n.MAP_POINTS_IN_METER?Fn.VERY_CLOSE_BONUS:1;return Mg(s.intersectionPolygon)*o*(1+i*Fn.DISTANCE_WEIGHT_MULTIPLIER)}class Ig{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(z({},t),{"--sum":n.getTotalMemory(t)}),gpu:de(z({},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 Cg=(s,e,t,i,o)=>{n.start("labelingOpacity",{easing:e},s,t,i,o,1)},Lg=n.update.bind(null,"labelingOpacity",{step:(s,e)=>s.labelingOpacity=e});function Pg(s){return s?Object.keys(s).map(Number).sort((e,t)=>e-t):[]}function Bg(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 zg=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 Rg{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=zg(this.modules.workers.fnRegistry),this.setLabelingInterval(n.labeling.interval)}disableThrottleUpdateOnce(){this.useThrottleUpdate=!1}update(){Lg(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.enrichWithElevation(i,e),this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),this.alwaysActiveLabelKeys.push(e),this.state.needLabeling=!0}addTileLabels(e,t,i){this.enrichWithElevation(i,e),this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),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(z({},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 a=n.getTileBounds(e),l=We(2,e[2]),c=a.min[0]<-n.HALF_WORLD_SIZE,d=a.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:a,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(a),cameraConfig:this.state.cameraConfig})),r=Bg(this.state.styleZoom,this.state.cityCommPoiLabeling);this.worker.processLabels(i,this.alwaysActiveLabelKeys,o,window.devicePixelRatio,this.modules.floorManager.getActiveFloorHiddenIds(),z(z({},n.labeling.commercialMargins),r),this.skipHysteresisInNextLabeling,this.modules.floorManager.getPlanLevels()).then(a=>{this.survivedLabelBoxes.clear(),this.labelTiles.forEach(h=>{this.modules.tileManager.removeObject(h),h.clean(this.state)}),this.labelTiles.length=0;const l=[];a.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&&a.some(({collectorOutput:h})=>h.data.length>0)&&(c.firstlabeling=performance.now()-c.start);const{animationTime:d,animationType:_,interval:u}=n.labeling;Cg(this.state,_,0,1,Math.min(d,u)),this.modules.renderer.addRerenderEvent(),a[0].labels&&e[2]>=0&&this.modules.labelsDebug.drawLabels(a[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 r=this.demKeys[t],a=i.getLabelsDemKey(e);if(a===void 0||a===r)return;i.enrichWithElevation(e),this.demKeys[t]=a}}}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=Ee(this.handler.container,e.clientX,e.clientY);return new wl(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=Ee(this.handler.container,e.clientX,e.clientY);return this.handler.modules.identifier.search("contextmenu",t,!0).then(i=>{pt("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 Dn(this.mouseDownPoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new it(this.handler)}}class wl{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,r=(i[1]-t[1])*n.zoom.mousePitchDelta;vt(e),e.disableRotationByUserInteraction||_i(e,e.rotation+o,{animate:!1}),e.disablePitchByUserInteraction||Vi(e,n.clamp(e.pitch+r,e.minPitch,e.maxPitch),{animate:!1}),this.mouseDownPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Ee(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 Dn(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 it(this.handler)}}class Dn{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 it(this.handler)):this}processMouseMoveAction(e){const t=Ee(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 Sl(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=Ee(this.handler.container,e.clientX,e.clientY);vt(t),Tt(t,i,{duration:n.zoom.animDuration,zoomPoint:t.keepCenterWhileUserZoomRotate?void 0:o}),this.handler.modules.renderer.addRerenderEvent()}}else{const t=Ee(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(()=>{pt("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 it(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 Sl{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 a=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,a),n.scale(o,o,a)}const r=n.clone$1(e.center);n.add$1(r,r,i),n.sub$1(r,r,o),vt(e),Dt(e,r,{animate:!1}),this.dragStartPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Ee(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 it(this.handler)}}class Tl{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 ri(e,this.handler,!1)}processTouchMoveAction(e){return e.preventDefault(),this.touchMovePoints=lt(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 it(this.handler)):new ri(e,this.handler,!1)}}class On extends Tl{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]),r=i/o,a=e.zoom+Math.log(r)/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:a,rotation:d})),vt(e),Dt(e,_,{animate:!1}),Tt(e,a,{animate:!1}),this.handler.mapState.disableRotationByUserInteraction||_i(e,d,{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class Ml extends Tl{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]),a=(n.calcMidpoint(i[0],i[1])[1]-o[1])*n.zoom.mousePitchDelta;vt(e),Vi(e,n.clamp(e.pitch+a,e.minPitch,e.maxPitch),{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class ri{constructor(e,t,i){this.handler=t,this.needClickOnTouchEnd=i,this.toZoomRotate=!1,this.touchStartPoints=lt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.isTimerStarted=this.handler.dblClickTimer!==void 0,ct(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=lt(e.touches,this.handler.container),this}processTouchMoveAction(e){e.preventDefault();const t=lt(e.touches,this.handler.container);if(!ct(e))return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):this.isTimerStarted?new El(t[0],this.touchStartPoints[0],this.handler):this.handler.mapState.disableDragging?(this.touchStartPoints=t,this.needClickOnTouchEnd=!1,this):new _s(t[0],this.touchStartPoints[0],this.handler);if(this.touchStartPoints.length<2)return this.processTouchStartAction(e);const i=n.create$6(),o=n.create$6();n.sub(i,t[0],this.touchStartPoints[0]),n.sub(o,t[1],this.touchStartPoints[1]);const r=n.dot$1(i,o);if(r>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 _s(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 Ml(t,this.touchStartPoints,this.handler)}return r<0?new On(t,this.touchStartPoints,this.handler):n.isNullVector(i)||n.isNullVector(o)?this.pitchWaitingTimer?this:this.toZoomRotate?(this.toZoomRotate=!1,new On(t,this.touchStartPoints,this.handler)):(this.pitchWaitingTimer=window.setTimeout(()=>{this.toZoomRotate=!0,this.pitchWaitingTimer=void 0},n.events.pitchWaitingTime),this):new On(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 it(this.handler)):(ct(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=lt(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),r=i.keepCenterWhileUserZoomRotate?void 0:e;vt(i),Tt(i,o,{duration:n.zoom.animDuration,zoomPoint:r}),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(()=>{pt("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 it(this.handler)}}class _s{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 a=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,a),n.scale(o,o,a)}const r=n.clone$1(e.center);n.add$1(r,r,i),n.sub$1(r,r,o),vt(e),Dt(e,r,{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 ri(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=lt(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 it(this.handler)}}class El{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),r=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(r,e.center,n.getCenterCorrection(e,this.touchStartPoint,{zoom:o})),vt(e),Dt(e,r,{animate:!1}),Tt(e,o,{animate:!1}),this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),new ri(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=lt(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 it(this.handler)}}class it{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=Ee(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);pt("mousedown",i,e,t,this.handler.modules)}return new Dn(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=Ee(this.handler.container,e.changedTouches[0].clientX,e.changedTouches[0].clientY),i=this.handler.modules.identifier.searchSync(t);pt("touchstart",i,e,t,this.handler.modules)}return new ri(e,this.handler,e.touches.length===1)}}class Nn{processAction(){return this}}class Fg{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 Nn||(this.state=o)},this.state=new it(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 Nn)return;const{map:e}=this.modules;switch(this.container.classList.remove("mapgl-dragging"),this.container.classList.remove("mapgl-rotating"),this.state.constructor){case Dn:case Sl:case _s:e.emit("interactionend",{target:"center"});break;case si:case wl:e.emit("interactionend",{target:"pitch/rotation"});break;case El:e.emit("interactionend",{target:"zoom/rotation"});break;case On:case Ml:e.emit("interactionend",{target:"pitch/zoom/rotation"});break;case ri:{const t=this.state.getStartedInteractionTarget();e.emit("interactionend",{target:t});break}}this.state=new Nn}unblock(){this.state instanceof it||this.state instanceof Nn&&(this.state=new it(this))}}const Dg=new Set([n.UNIVERSE_REGION_ID]);class us extends Error{constructor(e,t){super(e),this.name="TrafficFetchMetaError",this.noRetry=t}}class Og{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=z({},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(z({},t),{"--sum":n.getTotalMemory(t)}),gpu:de(z({},t),{"--sum":n.getTotalMemory(i)})}}fetch(e,t){e.sort((i,o)=>n.compare(this.mapState.center,i,o)).forEach(i=>Ng(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,Dg)){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 us(`Request traffic timestamp error with status ${i.status}`,!1)}).then(i=>{var r,a;if(!i.length||((r=i[0])==null?void 0:r.time)===void 0||((a=i[0])==null?void 0:a.score)===void 0)throw new us(`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 us)||!i.noRetry?this.fetchMetaRetryAttempt=(o=this.fetchMetaRetryAttempt)!=null?o:0:this.fetchMetaRetryAttempt=null,this.lastUpdateTime=Date.now(),this.isMetaLoading=!1,console.error(i)})}}function Ng(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 kg{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 Ug{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.textureKeys=[],this.texturesMap=new Map}addTexture(e,t){return q(this,null,function*(){this.loadingCounter++;const i=yield wn(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 q(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(z({},e),{"--sum":n.getTotalMemory(e)}),gpu:de(z({},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,r=(m=t==null?void 0:t.imagePadding)!=null?m:1;this.decreaseLoadingCounter();const a=e.getAttribute("src")||e.currentSrc,l=Hg(a,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),_=Da(e,d);e.remove();const u=d.map(b=>b+2*r);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(_,r,r),_.remove(),this.texturesMap.set(l,h),this.textureKeys.push(l),this.modules.renderer.addRerenderEvent(),this.textureKeys.length-1}loadImage(e){return q(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 Hg(s,e){const t=e!==void 0?`_${e[0]},${e[1]}`:"";return`${s}${t}`}const Il=!0,Cl=!1,Ll=!1,Pl=[0];class Gg{constructor(e){this.isLoading=!1,this.attempts=0,this.getKeyInfo=()=>q(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 r=()=>q(this,null,function*(){return Pl.length>=this.attempts?(this.attempts&&(yield new Promise(a=>{this.lastTimeout=window.setTimeout(a,Pl[this.attempts]*1e3)}),this.clearLastTimeout()),this.attempts++,fetch(o).then(a=>a.ok?a.json():r(),r)):(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=r().then(a=>{if(this.isLoading=!1,!a||!a.result||a.meta.code!==200)return{showCommPoi:Il,hideCopyright:Ll,urbi:Cl,error:!0};const{showCommPoi:l,hideCopyright:c,urbi:d}=a.result.service.properties.public;return{showCommPoi:n.isNullish(l)?Il:!!l,hideCopyright:n.isNullish(c)?Ll:!!c,urbi:n.isNullish(d)?Cl:!!d}})}}destroy(){this.clearLastTimeout()}clearLastTimeout(){this.lastTimeout!==void 0&&(clearTimeout(this.lastTimeout),this.lastTimeout=void 0)}}class Vg{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 Zg={dead:!0,alive:!0,unused:!0,commercialDead:!1,commercialAlive:!1};class jg{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=Zg){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"},r=new Int32Array(e),a={[n.BBoxType.Dead]:[],[n.BBoxType.Alive]:[],[n.BBoxType.Unused]:[],[n.BBoxType.CommercialAlive]:[],[n.BBoxType.CommercialDead]:[]};for(let d=0;d<r.length;d+=5){const _=r[d+4];a[_].push({x:r[d],y:r[d+1],width:r[d+2],height:r[d+3]})}this.clear();const l=window.devicePixelRatio,c=d=>{t.strokeStyle=o[d],a[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 Wg=n.create$1();class $g{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=I_(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(Fe);const e=this.modules.renderer.getShaderProgram("sky");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||(Xs(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(Fe);const e=this.modules.renderer.getShaderProgram("stars");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||Ks(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(Fe);const e=this.modules.renderer.getShaderProgram("globeHaloBackground");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||so(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderGlobeHalo(){this.modules.renderer.applyGpuState(N_);const e=this.modules.renderer.getShaderProgram("globeHalo");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||so(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}isFogEnabled(){var r,a;if(this.modules.map.getFeatureFlag("fogOff")||!((r=this.envStyleLayer)!=null&&r.style.fogColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((a=this.envStyleLayer)==null?void 0:a.style.fogColor,i);return o&&o.value[3]!==0}isSkyEnabled(){var r,a;if(this.modules.map.getFeatureFlag("skyOff")||!((r=this.envStyleLayer)!=null&&r.style.skyColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((a=this.envStyleLayer)==null?void 0:a.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,Wg);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 a=0;a<e.length;++a){const l=e[a],c=n.getRandomValue(this.starsGenerationCtx,0,1);i[t*a]=l[0],i[t*a+1]=l[1],i[t*a+2]=l[2],i[t*a+3]=c}const o=this.modules.renderer.createBuffer(i),r=this.modules.renderer.getShaderProgram("stars");this.starsVao=C_(o,r)}updateFog(){const e=this.modules.camera;this.squaredDistMaxFog=We(e.fogDistance*this.fogLimits[1],2)}}class Xg{constructor(e,t){this.mapState=e,this.mapModules=t,this.state={}}add(e,t=0,i=1,o=n.buildingAnimation.easing,r=n.buildingAnimation.duration){this.state[e]||(this.state[e]={tickerConfig:{start:t,end:i,duration:r,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:r,end:a,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,r,a,l,1)}i.readiness===1&&o!==1&&e.push(t)}}return e}buildTickerKey(e){return`gltf-${e}`}}const Kg=!0,hs="#ffffffff",qg=0,Yg=0,Qg=1,fs=15,Jg=n.tileZoomToSize(fs)/n.MAP_POINTS_IN_METER,kn=n.maxTilePoint/2,Ag=["coordinates","rotation","scale","offset"];let ms=class zs extends $e{constructor(e,t){var S,P,T,C,I,E,B,N,J;super(e,{interactive:(S=t.interactive)!=null?S:!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:Kg,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:r,tileManager:a,layers:l,assetManager:c}=this.modules,{ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f}=t,m=Fl((T=t.rotation)!=null?T:qg),p=(C=t.scale)!=null?C:Qg,v=Dl((I=t.offset)!=null?I:Yg,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)||hs,["match",["objectAttr","selected"],[!0],((B=t.select)==null?void 0:B.color)||hs,t.color||hs]]},minzoom:t.minZoom,maxzoom:t.maxZoom,interactive:this.interactive,interactiveOcclusion:this.interactiveOcclusion}),!this.layer)return;(N=t.hover)!=null&&N.color&&(this.on("mouseover",this.switchToHoveredColor),this.on("mouseout",this.switchToNormalColor)),o.addLayer(this.layer,t.zIndex);const x=n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,fs),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:r,generator:n.GltfModelGenerator.generateInstances,args:[o.getStyle(),this.layer,y,{x:[kn],y:[kn],z:[(J=this.position.userValue[2])!=null?J:0]},n.createTileInfo(x),NaN]});const b=r.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"&&(a.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),r.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:(r,a)=>{t[o]=a},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 zs&&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,r;if(this.status==="destroyed"||!this.layer)return;this.stopTransformation();const t={};e.forEach(a=>{const l=ty(a);if(!l)return;const{duration:c=0,easing:d="linear"}=a;t[l]={value:a[l],duration:c,easing:d}});const i={};for(const a in t){if(!ey(a)||t[a]===void 0)continue;let l;if(a==="coordinates"?l=n.Mercator.fromGeo(t[a].value):a==="offset"?l=Dl(t[a].value,(r=(o=t.coordinates)==null?void 0:o.value[1])!=null?r:n.Mercator.toGeo(this.position.userValue)[1]):l=t[a].value,!t[a].duration){i[a]=l;continue}const c=`dynamicGltfModel-${a}-${this.uniqId}`;let d,_;if(a==="coordinates")d=this.position.userValue,_=l;else{const u=[0,0,0];n.getTriple(this.appliedTransformations[a],u),d=u;const h=[0,0,0];n.getTriple(l,h),_=h}n.start(c,{easing:t[a].easing,renderAfterUpdate:this.needRerender},this.mapState,d,_,t[a].duration,1,{layerId:this.layer.innerId,styleId:n.DYNAMIC_STYLE_ID}),this.tickerNames.set(a,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 r=this.tileObjects[0];if(!r)return;const a=r.buffers[0];if(a){if(e&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},r.setTileCoords(n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,fs),this.mapState)),t!==void 0||i!==void 0){const _=Fl(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,Rl),n.getTriple(this.appliedTransformations.scale,Bl),n.getTriple(this.appliedTransformations.rotation,zl),n.GltfModelGenerator.patchBuffer(a,0,n.createTileInfo(r.coords),[kn,kn,(l=this.position.userValue[2])!=null?l:0],Rl,Bl,zl,((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 zs&&t!==this&&t.isVisible());this.linkedIds.forEach(t=>{e.every(o=>{var r;return!((r=o.getLinkedIds())!=null&&r.includes(t))})&&this.map.showHiddenBuildingsById([t])})}};const Bl=[0,0,0],zl=[0,0,0],Rl=[0,0,0];function Fl(s){return Array.isArray(s)?s.map(e=>e%360):s%360}function Dl(s,e){const t=Jg/n.Mercator.scaleFactor(e),i=["x","y"].filter((o,r)=>{const a=Array.isArray(s)?s[r]:s;return a<-t||a>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 ey(s){return Ag.includes(s)}function ty(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 iy=[0,0,0],ny=[0,0,0],oy=[0,0,0],sy="modelshow",ry="modelhide",Un=0,Ol=.1;class ay{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 Xg(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=ps(t.attributes.styleId,t.attributes.sourceId,t.tile.coords),r=this.layerModelKeyBySourceTile.get(o);r?r.add(i):this.layerModelKeyBySourceTile.set(o,new Set([i]))}clearSourceTileMapByTiles(e,t){t.map(i=>ps(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=Hn(e);return(o=this.modelInfo[i])==null?void 0:o.modelIds[t.id]}getModelOpacity(e){var i;if(e===void 0)return Un;const t=Hn(e.attributes);return t&&(i=this.modelsAnimator.getReadiness(t))!=null?i:Un}getModelHeightFactor(e){var i;if(!e)return 1;const t=Hn(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=Hn(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(z({},e),{key:t})),this.addLayerModelToSourceTileMap(t,e))}removeSceneObject(e){this.sceneObjects.delete(e),delete this.objectIdToLayerModelKey[e]}allObjectsHaveCurrentModelId(e,t,i){var a;const o=ps(i,e,t),r=this.layerModelKeyBySourceTile.get(o);if(!r)return!0;for(const l of r){const c=(a=this.modelInfo[l])==null?void 0:a.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,r){var P,T,C,I;const{assetManager:a,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=Nl(x,u.styleZoom);break;case n.ModelStepSource.Distance:y=ly(o,i,d.position,x,r);break;default:return}if(y===-1)return;const b=v[y];if(b===void 0)return;const M=a.getModel(b,h);if(M)switch(M.status){case tt.Loaded:e.modelId=b;const E=(T=(P=M.scenes.find((B,N)=>typeof t.scene=="number"&&!Number.isNaN(t.scene)&&N===t.scene||typeof t.scene=="string"&&B.name===t.scene))!=null?P:M.scenes.find((B,N)=>N===M.defaultScene))!=null?T:M.scenes.find((B,N)=>N===0);e.sceneId=E==null?void 0:E.id,M.usedEmptyScene=((I=(C=M.scenes.find(B=>B.id===e.sceneId))==null?void 0:C.objects.length)!=null?I:0)===0;return;case tt.Failed:e.modelId=NaN;return}else{const E=c.getStyleLayer(h,f),B=a.getDataModelUrlById(b);if(E&&!this.disabled){if(B===void 0)a.loadModelByIndex(b,h,E);else if(B.length){const N=m===_.getId()&&p===Bn;a.loadModel(B,b,h,!1,E,N)}}}if(v.length===1)return;const S=l.getSourceById(m);S&&(g===n.ModelStepSource.Zoom?e.modelId=this.getModelIdByZoom(S,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:r,modelIndices:a}=t,l=e.getZoomDirection();if(l===n.ZoomDirection.Stationary)return this.getCurrentModelId(t,i);const c=a.slice(0,o).reverse(),d=a.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],r);if(h&&h.status===tt.Loaded)return _[u];if((h==null?void 0:h.status)===tt.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===tt.Loaded)return i;if((o==null?void 0:o.status)===tt.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 r=0;r<i.length;r++)this.processSceneObject(i[r],e,t);for(const r of t)this.sceneObjects.delete(r),delete this.objectIdToLayerModelKey[r];const o=this.mapState.styleZoom;for(const r of Object.keys(this.modelInfo)){const a=this.modelInfo[r];(!e.has(r)||o<a.layer.minzoom||o>=a.layer.maxzoom)&&this.removeLayerModel(r,a)}}processSceneObject(e,t,i){if(e.tile.destroyed){i.add(e.id);return}const o=e.key,r=this.modelInfo[o],a=this.mapState.disableModelsGrowthAnimation||e.tile.dynamicObject instanceof ms&&e.tile.dynamicObject.isAnimationDisabled();r&&!this.modelsAnimator.has(o)&&(this.mapModules.defaultSource.createModelsSource(),this.startAnimation(o,r,a)),r?this.objectIdToLayerModelKey[e.id]||this.indexateObject(o,e,r):this.addLayerModel(e,o,!0),t.add(o)}addLayerModel(e,t,i=!1){var a,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 r={layer:o,ids:e.tile.ids,linkedIds:[],ownerIds:new Set,modelIds:{},buildingId:((a=e.meta)==null?void 0:a.buildingId)||""};return(l=e.meta)!=null&&l.planId&&(r.planId=e.meta.planId),this.indexateObject(t,e,r),this.modelInfo[t]=r,r}startAnimation(e,t,i){var a;if(i){this.modelsAnimator.add(e,1,1);return}const o=(a=t.layer.minzoom)!=null?a: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}),r=e.visible;o!==r&&(e.visible=o,this.emitEvent(o&&!r?sy:ry,e))}addNewSceneObjectsToVisibilityMap(){var i,o,r,a;const e=this.mapModules.camera.getViewportVertices(Ol),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:((r=c.meta)==null?void 0:r.buildingId)||"",sublayer:((a=c.meta)==null?void 0:a.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(Ol);this.sceneObjectsVisibilityMap.forEach(t=>t.forEach(i=>this.maybeEmitModelEvent(i,{},e)))}indexateObject(e,t,i){var r,a,l;this.objectIdToLayerModelKey[t.id]=e,i.ownerIds.add(t.id),i.buildingId=((r=t.meta)==null?void 0:r.buildingId)||"",i.buildingId&&this.buildingIds.add(i.buildingId);const o=(l=(a=t.meta)==null?void 0:a.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 r of t.ownerIds)delete this.objectIdToLayerModelKey[r];t.buildingId&&this.buildingIds.delete(t.buildingId),this.modelsAnimator.remove(e);const i=this.sceneObjectsVisibilityMap.get(e);i&&(i.forEach(r=>this.maybeEmitModelEvent(r,{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 r=n.isCommercialModel(o);this.mapModules.map.emit(e,{sublayer:o,id:i,isCommercial:r})}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 r=this.modelInfo[o],a=r.ids;if(!a)continue;const l=(i=this.modelsAnimator.getReadiness(o))!=null?i:Un;for(const c of r.linkedIds){if(a.isHidden(c))continue;const d=r.planId!==void 0?n.HideLevel.FloorPolygons:n.HideLevel.PolygonExtrusion,_=a.isHidden(c,d);l>.5&&!_?a.hide([c],d):l<.5&&_&&a.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 Hn(s){const{layerId:e,modelIndices:t}=s;return`${e}_${t.join(",")}`}function ps(s,e,t){return`${s}_${e}_${JSON.stringify(t)}`}function ly(s,e,t,i,o){const r=s.modelMatrices.get(0);if(!r)return-1;let a=e.min,l=e.max;o||(a=n.transformMat4$1(ny,a,r),l=n.transformMat4$1(oy,l,r));const c=n.projectToXyRect(t,a,l,iy),d=n.Mercator.toGeo(c),_=n.Mercator.scaleFactor(d[1]),u=n.dist$1(t,c)/n.MAP_POINTS_IN_METER/_;return Nl(i,u)}function Nl(s,e){let t=0;for(;t<s.length&&!(e<s[t]);)t++;return t-1}const cy=n.bezier(.42,0,1,1),dy=(s,e,t,i)=>e+t*cy(s/i),_y=n.bezier(0,0,.58,1),uy=(s,e,t,i)=>e+t*_y(s/i),hy=n.bezier(.42,0,.58,1),fy=(s,e,t,i)=>e+t*hy(s/i);function kl(s){switch(s[0]){case"cubic-bezier":{const e=n.bezier(s[1],s[2],s[3],s[4]);return(t,i,o,r)=>i+o*e(t/r)}case"exponential":{const e=s[1];return(t,i,o,r)=>{const a=i,l=i+o,c=t/r,_=(We(e,c)-1)/(We(e,1)-1);return(1-_)*a+_*l}}case"ease":return n.ease;case"ease-in":return dy;case"ease-out":return uy;case"ease-in-out":return fy;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 my{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:r,transformStack:a,textureTransformMatrix:l}=e.renderingProperties;if(t.style.playAnimation===void 0||!(r!=null&&r.length)||!o||!r||!a||!l)return;const c=this.updateAnimationKeyframes(e,t);ka(l,r,i.buffers,c),Ua(o,r,a,i.buffers,c)}animatePolygonNormalMapTexture(e,t){var E;if(!t.style.normalMapTextureAnimation)return[!1,[0,0,0,0]];let i=1;const o=t.innerId,r=e.attributes.styleId,a=`${r}_${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(a))!=null?E:{lastKnownOffsets:y,animationStage:0,previousTimestamp:l},{lastKnownOffsets:M,previousTimestamp:S,animationStage:P}=b;let T=P;const C=(l-S)/1e3;switch(P){case 0:{let B=!1;const N=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),J=n.resolveString(t.style.normalMapTextureImage,N),K=this.modules.styleManager.getStyle(r);if(K){const F=K.rasterSets.byKey[n.getStaticTextureRasterSetKey(J)];F&&F.isReady&&(B=!0)}B&&(p?(n.start(`${a}_animationSpeedUp`,{easing:kl(v),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,0,1,p,1),T=1):(m!==1/0&&n.start(`${a}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),T=2));break}case 1:{n.update(`${a}_animationSpeedUp`,{keepFinished:!0,step:(B,N,J,K)=>{K?(i=1,n.stop(`${a}_animationSpeedUp`,this.mapState),m!==1/0&&n.start(`${a}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),T=2):i=N}},this.mapState);break}case 2:{m===1/0||n.update(`${a}_animationFullSpeed`,{keepFinished:!0,step:(B,N,J,K)=>{K&&(n.stop(`${a}_animationFullSpeed`,this.mapState),x?(n.start(`${a}_animationSlowDown`,{easing:kl(g),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,0,x,1),T=3):T=4)}},this.mapState);break}case 3:{n.update(`${a}_animationSlowDown`,{keepFinished:!0,step:(B,N,J,K)=>{K?(i=0,n.stop(`${a}_animationSlowDown`,this.mapState),T=4):i=N}},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(B=>B%1);return this.doubleSampledTextureAnimationStateMap.set(`${r}_${o}`,{animationStage:T,lastKnownOffsets:I,previousTimestamp:l,updatedOnThisFrame:!0,styleId:r,layerId:o}),T!==4&&this.rerenderEvents.push({type:"layerAnimationTicker",layerId:o,styleId:r,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,S,P,T,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,r=(v=i[2])!=null?v:0,a=(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=(S=i[8])!=null?S:0,h=(P=i[9])!=null?P:["linear"],f=(T=i[10])!=null?T:0,m=(C=i[11])!=null?C:["linear"];return[[o,r],[a,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,r=this.applyAnimationState(t,e);for(const a of i){const l=r.animationStateID,c=n.get(l,this.mapState);if(this.isNeedAnimation(a,r)){if(!c&&r.currentCount>0){const d=r.animationDuration||(a.max?a.max[0]:0),_=r.startOffset||0;let u=r.startOffset?a.frameCount/(a.frameCount*d/_):0,h=d*(1e3/r.playSpeed)-_*(1e3/r.playSpeed);r.elapsedTime&&(u=1-r.elapsedTime,h=d*(1e3/r.playSpeed)*r.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=(a.frameCount-1)*_;o.set(a.actionId,f),h||this.rerender(e,t,r)},complete:d=>{r.currentCount>0&&r.currentCount--,r.currentCount>0&&(n.stop(l,this.mapState),this.rerender(e,t,r))}},this.mapState),this.currentObjects.set(l,r)}}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],r=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].currentStepElapsed/1e3:void 0,a=(m=i[2])!=null?m:1/0,l=a,c=i[1]||1,d=i[4]||void 0,_=i[3]||r||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:a,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=a=>{o=a};const r=n.resolveAnimationExpression(e.style.playAnimation,i);return r[6]===void 0&&o&&(r[6]=o),r}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:(r,a)=>{o.elapsedTime?(o.elapsedTime>0||o.elapsedTime<1)&&(i.elapsedTime=o.elapsedTime):(o.elapsedTime=a,i.elapsedTime=a)}},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,py={id:"simple-mesh",type:"simpleMesh",innerId:n.SIMPLE_MESH_STYLE_LAYER_ID,filter:!1,minzoom:0,maxzoom:20,precomputes:[],renderIndex:0,style:{}},vs={polygonsQty:1e4,drawCallsQty:150,iterations:7},Ul=[18,34],vy=1e3,Ci="__MAPGL_BENCH_TIME",gy=5,ai=class ai{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=gt(this.state,this.modules),this.framebufferId=this.createFramebuffer(),this.modules.dynamicStyle.addLayer(py)}static mockResult(e){ai.mocked=e}run(){return q(this,arguments,function*(e=vs.polygonsQty,t=vs.drawCallsQty,i=vs.iterations,o=vy){if(ai.mocked)return ai.mocked;const r=this.getCachedResult();if(r)return r;this.timeout=o,this.startTs=performance.now();try{return yield this._run(e,t,t*i,i)}catch(a){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.72.0",t=localStorage.getItem(Ci);if(t){const i=t.split(":"),o=i[0];if(e===o){const r=i.slice(1).join(":").split(",").map(a=>parseFloat(a)).filter(a=>!Number.isNaN(a));if(r.length>=gy){const a=r.reduce((c,d)=>c+d,0)/r.length;return{status:"cached",tier:this.selectTier(a)}}}}}catch(e){}return null}selectTier(e){const t=Ul.findIndex(i=>e<=i);return t>-1?Ul.length-t:0}saveResult(e){try{const t="v1.72.0",i=localStorage.getItem(Ci);if(i){const o=i.split(":"),r=o[0];if(t!==r)localStorage.setItem(Ci,`${t}:${e.toPrecision(4)}`);else{const a=o.slice(1).join(":").split(",").map(l=>parseFloat(l)).filter(l=>!Number.isNaN(l));a.push(e),localStorage.setItem(Ci,`${t}:${a.map(l=>l.toPrecision(4)).join(",")}`)}}else localStorage.setItem(Ci,`${t}:${e.toPrecision(4)}`)}catch(t){}}_run(e,t,i,o){return q(this,null,function*(){const r=this.modules.renderer.getFramebuffer(this.framebufferId);if(!r)throw new Error("Failed to create framebuffer for benchmark.");this.modules.renderer.bindRenderTarget(r.renderTarget),this.modules.renderer.setViewport(0,0,this.modules.renderer.getViewportSize()[0],this.modules.renderer.getViewportSize()[1]);const a=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:a}})}prepareData(e,t){const i=performance.now();this.buffer=this.generateSphere(e);const o=performance.now(),r=performance.now();this.sceneObjects=this.createSceneObjects(t);const a=performance.now();return{generationTime:o-i,objectsTime:a-r}}measureRendering(e,t){return q(this,null,function*(){return new Promise(i=>{const o=[];let r=0,a=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(),So(this.state,this.modules,this.sceneObjects.slice(a,a+t),this.de),this.modules.renderer.waitForGpuCommandsToFinish(),o.push(performance.now()-c),r++,a+=t,r<e?Promise.resolve().then(l):i(o)};setTimeout(()=>{l()},0)})})}processResults(e){const t=e.slice();t.sort((o,r)=>o-r);const i=t.slice(0,t.length-.2*t.length);return{median:i[Math.floor(i.length/2)],mean:i.reduce((o,r)=>o+r,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),S=Math.cos(g);for(let P=0;P<i;P++){const T=P*u,C=(P+1)*u,I=Math.sin(T),E=Math.cos(T),B=Math.sin(C),N=Math.cos(C);h[0]=at*y*E,h[1]=at*b,h[2]=at*y*I,f[0]=at*y*N,f[1]=at*b,f[2]=at*y*B,m[0]=at*M*E,m[1]=at*S,m[2]=at*M*I,p[0]=at*M*N,p[1]=at*S,p[2]=at*M*B,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 Te({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:pr,stateBinder:()=>uo,programBinder:Uu,tileBinder:()=>!0,objectBinder:ch,needsVisibilityBuffer:!1},i=[],o=pr(this.modules.renderer.createBuffer(this.buffer),this.modules.renderer.getShaderProgram("simpleMesh")),r=new n.TileObject("zenith",[],this.modules,this.state),a={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:r,symbol:"simpleMesh",sink:"fill",layerSettings:t,canRender:!0,attributes:a,meta:{scale:d,transform:_},renderingProperties:{}})}return i}};ai.mocked=null;let Gn=ai;class yy{constructor(e,t,i){this.benchmark=null,this.map=i,this.camera=new n.Camera(e),this.layout=new kg(t),this.collector=new n.Collector("main"),this.workers=new kv,this.identifier=new Vv(e,this),this.styleManager=new Kv(this),this.assetManager=new Yv(e,this),this.imageManager=new Ug(this),this.floorManager=new bg(e,this),this.personalPoiManager=new ig(this),this.buildingHeightAnimator=new pd(e,this),this.modelsScene=new ay(e,this),this.renderer=new Ei(e,this),this.newRenderer=new Gv(e,this),this.layers=new pg(this),this.sourceStorage=new Vg,this.tileManager=new Ig(e,this),this.modelLayer=new tg(e,this),this.dynamicStyle=new n.DynamicStyle,this.imageCache=new gg(this),this.labeler=new Rg(e,this),this.trafficTileLayer=new Og(e,this),this.handler=new Fg(e,this),this.mouseMoveHandler=new hd(this),this.tileKeyInfo=new Gg(e),this.demManager=new iu(this),this.environmentManager=new $g(this),this.defaultSource=new dl(e,this),this.labelsDebug=new jg(e,this),this.postEffectsManager=new Du(e,this),this.renderCacheManager=new Cv(e,this),this.animationManager=new my(e,this),this.shadowManager=new zu(e,this),this.instanceLinker=new Ef(this),e.graphicsPresetMode==="auto"&&(this.benchmark=new Gn(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 gs=["light","normal","immersive"],xy=["immersiveRoadsOff","reliefOff","shadowsOff","fogOff","skyOff","modelsOff","globeOff","transparentBuildingsOff","AALinesOff"],by=.3,li=class li{constructor(e,t={},i){var h,f,m,p,v,x,g,y,b,M,S,P,T,C,I,E,B,N;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 K=window.devicePixelRatio;K!==this.lastDpr?(this.lastDpr=K,this.state.dpiChanged=!0,this.modules.map.invalidateSize(),this.modules.imageCache.clear()):this.state.dpiChanged=!1,this.modules.map.emit("framestart");const F=this.state;F.time=Date.now(),this.processMetrics(),this.state.enableTrackResize&&this.autoResize(J),this.modules.mouseMoveHandler.update(),this.handlers.forEach(be=>be.update()),Qc(F),$c(F),Kc(F),Yc(F),this.stillnessUpdater.update(F),jc(F,this.modules.layout.rootContainer),Dc(F,this.modules.layout.rootContainer,this.modules.renderer),Gc(F,this.modules.renderer),this.checkGlobeEnabled();const ee=this.modules.demManager.getReliefTileType()==="vector"&&F.styleZoom<Cr;if(F.demMode=this.checkDemEnabled()&&F.elevationScale>0&&!ee,this.modules.camera.update(),this.updateElevation(),this.updateTilesBounds(),this.replicasDiffer.check(F)&&(F.needReplicasUpdate=!0),this.modules.demManager.update(),this.modules.environmentManager.update(),this.modules.labelsDebug.update(),this.modules.trafficTileLayer.update(),this.modules.layers.getLayers().forEach(be=>{be.update!==void 0&&be.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(),F.loopWorld&&!this.modules.renderer.isNeedRerender()&&n.worldWrapX(F.center),(n.render.alwaysRerender||this.modules.renderer.isNeedRerender())&&F.collectStats&&(F.stats.drawCount=0,F.stats.vertexCount=0,F.stats.triangleCount=0,F.stats.drawCountBySymbol={}),n.render.alwaysRerender||this.modules.renderer.isNeedRerender()){const be=this.modules.tileManager.getTileObjects();this.modules.renderer.prerenderUpdate(),F.metrics.firstdraw===void 0&&(F.metrics.firstdraw=performance.now()-F.metrics.start),be.forEach(we=>{we.needSync&&we.syncReplicas(this.state)}),this.modules.renderCacheManager.frameStart(),this.modules.animationManager.frameStart(),this.modules.renderer.renderElevation(be),this.modules.shadowManager.drawShadowMap(be),this.modules.renderer.renderLabelingTexture(be),this.modules.renderer.renderSpriteLabelingTexture(be),this.modules.renderer.renderTileObjects(be),this.modules.shadowManager.drawDebugFbIfNeeded(),F.needRerender=!1,this.state.rerenderEvents=new Array,this.modules.animationManager.frameEnd(),this.modules.renderCacheManager.frameEnd(),F.collectStats&&(this.modules.map.emit("stats",F.stats),F.metricsSent||(F.metrics.vertexCount=F.stats.vertexCount,F.metrics.triangleCount=F.stats.triangleCount,F.metrics.drawCount=F.stats.drawCount))}this.finishStyleUpdatingCheck(),this.modules.map.update(),this.modules.assetManager.invalidateUsedGltfModels(),F.needReplicasUpdate=!1,F.shouldIsReadyWaitForUpdates=!1,F.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=z(z({},li.options),t),r=z(z({},li.options.padding),o.padding),a=z(z({},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(z({},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:(h=o.loopWorld)!=null?h:!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-a.left-a.right),Math.max(1,e.clientHeight-a.top-a.bottom)],tickers:{},stillness:1,needRerender:!0,needLabeling:!1,needReplicasUpdate:!1,userHasInteracted:!1,dpiChanged:!1,viewport:a,padding:r,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:(f=o.modelsTileSet)!=null?f:n.models.tileSet,modelsTilesUrl:(m=o.modelsTilesUrl)!=null?m: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:Rn(d),disableIconCache:o.disableIconCache,disableRenderingCache:o.disableRenderingCache,rtlPlugin:{scenario:(p=o.useRtlTextPlugin)!=null?p:"depends-on-language",loadFailed:!1,url:(v=o.rtlPluginUrl)!=null?v:n.rtlPluginUrl,hash:(x=o.rtlPluginHash)!=null?x:n.rtlPluginHash},mobileSdkMode:o.mobileSdkMode,dracoDecoderUrl:(g=o==null?void 0:o.dracoDecoderUrl)!=null?g: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:(y=o.iconIdentifyOpacity)!=null?y:by,disableHidingPois:(b=o.disableHidingPois)!=null?b:!1,resetFloorModeOnActivation:(M=o.resetFloorModeOnActivation)!=null?M:!1,aaMode:o.disableAntiAliasing===!1?Qt.TAA:void 0,rerenderEvents:new Array,cameraConfig:Object.assign({},n.defaultCameraConfig),cityCommPoiLabeling:{config:o.cityCommPoiLabelingConfig,ascSortedZoomNumbers:Pg(o.cityCommPoiLabelingConfig)},trafficMinZoom:(S=o.trafficMinZoom)!=null?S:n.traffic.minZoom,trafficMaxZoom:(P=o.trafficMaxZoom)!=null?P:n.traffic.maxZoom,trafficMaxDetailLevel:(T=o.trafficMaxDetailLevel)!=null?T:n.traffic.maxDetailLevel,bssHostAppParams:o.bssHostAppParams,disableStyleFallback:!!o.disableStyleFallback,hiddenImmersiveRoutesEnabled:Rd(),modelShowHideEventsSublayers:new Set((C=o.modelShowHideEventsSublayers)!=null?C:[]),graphicsPresetMode:o.graphicsPreset,shouldEmitGraphicsPresetChangeEvent:!1,isDeprecatedSystem:$t(),disableModelsGrowthAnimation:(I=o.disableModelsGrowthAnimation)!=null?I:!1,disableLayerAnimation:(E=o.disableLayerAnimation)!=null?E:!1,allowMetro:(B=o.allowMetro)!=null?B:!1,forceSyncIdentify:(N=o.forceSyncIdentify)!=null?N:!1};o.cameraConfig&&Object.assign(_.cameraConfig,o.cameraConfig),this.modules=new yy(_,e,i),typeof _.commercialPoiRandomSeed=="number"&&this.modules.workers.labeling.setCommercialPoiRandomSeed(_.commercialPoiRandomSeed),this.modules.styleManager.setDynamicStyle(this.modules.dynamicStyle.getStyle()),this.handlers=[new ad(_,this.modules.layout.mapContainer),new ld(this.modules)],o.disableZoomOnScroll||this.handlers.push(new rd(_,this.modules.layout.mapContainer)),nd&&ji&&this.handlers.push(new cd(_,e,i)),this.performanceChecker=new dd(_,this.modules),this.stillnessUpdater=new ud,(o.graphicsPreset==="auto"?this.measurePerformance():Promise.resolve(this.state.metrics.graphicsPreset=this.state.styleState.graphicsPreset)).finally(()=>{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(){return q(this,null,function*(){performance.now();const e=yield this.modules.benchmark.run();switch(this.modules.benchmark.destroy(),this.modules.benchmark=null,e.status){case"error":case"timeout":const t=gs[0];this.state.metrics.graphicsPreset=t,this.modules.map.patchStyleState({graphicsPreset:t});break;case"part-done":case"done":case"cached":{const i=gs[e.tier];this.state.metrics.graphicsPreset=e.status==="part-done"?gs[0]:i,e.status!=="cached"&&(this.state.metrics.benchRenderTime=Math.round(e.measurements.mean),this.state.metrics.benchGenTime=Math.round(e.preparation.generationTime)),this.modules.map.patchStyleState({graphicsPreset:i});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.map.getFeatureFlag("reliefOff")?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:r}=this.state,{defaultSource:a,map:l}=this.modules,c=o;if(!this.modules.styleManager.getStyleLayer(r,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&&a.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,r,a]=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(a,this.modules.camera.position,a,g),n.lerp(r,this.modules.camera.position,r,g)}let h=n.pointToLineDistance(r,l);if(h>u){const p=u/h;n.lerp(r,o,r,p),n.lerp(a,i,a,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],r),n.copy$2(this.state.extendedTilesBounds[3],a);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(r,o,r,p),n.lerp(a,i,a,p),h=m}if(this.state.demMode&&d){const p=(h+Math.abs(c))/h;n.lerp(i,a,i,p),n.lerp(o,r,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],r),n.copy$2(this.state.tilesBounds[3],a),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=Q_*(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 r=this.state.elevationScale,a=o*r,l=this.modules.camera.position[2]/n.MAP_POINTS_IN_METER,c=Math.min(30,l*.2),d=this.state.elevation*r+l-c;a>d&&(this.state.elevation+=(a-d)/r)}}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,r=window.devicePixelRatio;(t.width!==Math.floor(i*r)||t.height!==Math.floor(o*r))&&(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:yg(),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 ys=li;const wy="https://mapgl.2gis.com/api/js",Vn={minZoom:2,maxZoom:20},Sy="tile{subdomain}-sdk.maps.2gis.com",Hl="https://tile{subdomain}-sdk.maps.2gis.com/api/v3/ald",Ty="https://s1.bss.2gis.com/bss/3",xs=()=>{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},My=2;function Ey(s){const e=[My,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),r=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);return r&&o&&i?(e.push(`[${i.rangeMin},${i.rangeMax}](${i.precision})`),e.push(`[${o.rangeMin},${o.rangeMax}](${o.precision})`),e.push(`[${r.rangeMin},${r.rangeMax}](${r.precision})`)):e.push(new Array(3).fill("Unsupported")),e.push(window.devicePixelRatio),e}function Iy(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 Cy(s){var r,a;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=(r=e[t])!=null?r:{},o={};for(let l=0;l<s.length;l++)o[(a=i[l])!=null?a:l]=s[l];return o}const Ly=/(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,Py=/CrOS/,By=/android|ipad|playbook|silk/i,zy=()=>{const s=typeof navigator!="undefined"?navigator.userAgent:"";if(!s)return!1;const e=Ly.test(s)&&!Py.test(s),t=By.test(s),i=navigator.maxTouchPoints>1&&s.includes("Macintosh")&&s.includes("Safari");return e||t||i},Zn=5e3,Ry=64,Fy=16;class Dy{constructor(e,t){var i;this.queue=[],this.commPoiMsgOrderNumber=0,this.utcOffset=Ny(),this.unsentMessages=[],this.isMetricsFailed=!1,this.webglStatsValues=[],this.onCommPoiShowEvent=({commPois:o})=>{const r=Date.now(),{tileKey:a,sessionId:l}=this.map.state;for(const c of o){const d=Oy(c,r,this.commPoiMsgOrderNumber++,a,this.utcOffset,l);d&&this.queue.push(d)}this.timer||(this.timer=window.setTimeout(this.sendMessages,Zn))},this.onContextLostEvent=()=>q(this,null,function*(){const o=Date.now(),r={cpu:0,gpu:0},a={start:0,fail:!0,contextLost:!0},l=yield this.createMetricMessage(o,a,r);this.queue.push(l),this.timer||(this.timer=window.setTimeout(this.sendMessages,Zn))}),this.onMetricsEvent=o=>q(this,null,function*(){this.isMetricsFailed&&(o.fail=!0);const r=Date.now(),a=yield this.getMetricsMessage(o,r);this.queue.push(a),this.timer||(this.timer=window.setTimeout(this.sendMessages,Zn))}),this.onSendFail=o=>{this.unsentMessages.push(...o),this.timer||(this.timer=window.setTimeout(this.sendMessages,Zn))},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(r=>{r.ok||this.onSendFail(o)},()=>this.onSendFail(o))},this.markMetricsAsFailed=()=>{this.isMetricsFailed=!0},this.map=e,this.bssUrl=(i=t.bssUrl)!=null?i:Ty,this.webglStatsValues=Ey(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)}getCommonStats(){return q(this,null,function*(){const e=Cy(this.webglStatsValues),t=Iy(e),i=this.map.performanceChecker.getFpsStats(),o=Array.from(this.map.state.center),r=this.map.state.zoom,a=this.map.state.rotation,l=this.map.state.pitch,c=this.map.state.demMode,d=yield Fd();return{webglStats:t,fps:i,center:o,zoom:r,rotation:a,pitch:l,reliefEnabled:c,webGpuSupported:d}})}createMetricMessage(e,t,i){return q(this,null,function*(){const o=yield this.getCommonStats();return{type:411,eventType:"mapglCounter",eventId:xs(),timestamp:e,payload:{mapGlMapMetrics:de(z(z({},t),o),{memory:i}),mapGlHostAppParams:ky(this.map.state.bssHostAppParams)},common:{formatVersion:3,appVersion:n.limitString(Ps,Ry),product:44,deviceType:zy()?"mobile":"desktop",key:this.map.state.tileKey,styleId:this.map.state.styleId}}})}getMetricsMessage(e,t){return q(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 Oy(s,e,t,i,o,r){const a={adsHighlight:!0,entity:{id:s.id,type:"branch"}};s.adsPriority!==void 0&&(a.adsPriority=s.adsPriority);const l={type:302,eventType:"view",eventId:xs(),eventOrdinal:t,uiElement:{name:"POI",ownerName:"map"},timestamp:e,utcOffset:o,payload:{POI:a},common:{formatVersion:3,appVersion:n.limitString(Ps,Fy),product:44,apikey:i}};return r&&(l.common.sessionId=r),!i||i===n.DEFAULT_EMPTY_KEY?null:l}function Ny(){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 ky(s){if(s){const e=z({},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 Gl=s=>typeof s=="number"&&!isNaN(s)&&s!==Number.NEGATIVE_INFINITY&&s!==Number.POSITIVE_INFINITY;function Uy(s){return Array.isArray(s)&&Gl(s[0])&&Gl(s[1])}var bs=(s=>(s[s.IgnoreCall=0]="IgnoreCall",s[s.UseDefault=1]="UseDefault",s))(bs||{});const Hy={0:"Method call will be ignored.",1:"Method call will use default value."};class Gy{constructor(e){this.options=e}isValidGeoPoint(e,t){return this.processValidationResult(e,Uy(e),"Invalid GeoPoint",t)}processValidationResult(e,t,i,o){return!t&&this.options.reportToConsole&&console.warn(`${i}: ${JSON.stringify(e)}
${Hy[o]}`),t}}const Vl=new Gy({reportToConsole:!0}),jn="Style preprocessing:";function Vy(s){const e=new Map,t=i=>{i==null||i.forEach(o=>{const r={layers:i,layer:o};e.set(o.id,r),o.type==="group"&&t(o.layers)})};return t(s.layers),e}function Zy(s,e){var r,a,l;const t=new Set;performance.now(),e!=null&&e.parentStyleId&&console.warn(`${jn} 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=(r=i.layers)!=null?r:[],e){const c=Vy(i),d=(a=s.layersInserts)!=null?a:[];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(`${jn} 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(`${jn} 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(`${jn} 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]=z(z({},p),v),delete d[m].commonDefaults,delete d[m].layerTypeDefaults):d[m]=jy(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]=z(z({},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 jy(s,e,t,i,o){var l,c,d,_,u,h,f,m;const r=z({},t==null?void 0:t.commonDefaults),a=z({},i==null?void 0:i.commonDefaults);switch(e.type){case"heatmap":case"overpass":case"tunnel":{delete r.interactive,delete a.interactive,delete r.ignoreTier,delete a.ignoreTier;break}case"embankment":case"polygon3d":case"buildingModel":case"model":case"lineExtrusion":case"polygonExtrusion":case"point":{delete r.ignoreTier,delete a.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(z(z(z(z(z(z(z({},r),(l=t==null?void 0:t.layerTypeDefaults)==null?void 0:l[e.type]),e),a),(c=i==null?void 0:i.layerTypeDefaults)==null?void 0:c[e.type]),s.has(e)?e:void 0),o),{style:z(z(z(z(z(z(z({},(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 Wy(s,e,t){return q(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 r=yield o.json();if(r&&r.result)return{loadedId:e,style:r.result}})}function $y(s,e,t){return q(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}),r=yield Wy(n.getStyleUrl(o),s,e);if(!r)throw new Error;i=r.style}catch(o){throw new Error("FETCH_PARENT_STYLE_ERROR")}return i})}function Xy(s,e,t){return q(this,null,function*(){let i;return s.parentStyleId&&(i=yield $y(s.parentStyleId,e,t)),Zy(s,i)})}const Zl=["zoom","rotation","pitch","center"],Ky=150,qy=["static","immersive_roads"];class ws extends n.Evented{constructor(e,t){var r;super();const i=this.core=new ys(e,t,this);this.state=i.state,this.modules=i.modules,this.performanceChecker=i.performanceChecker,this.values={isMoveChanging:!1,isIdle:!1},Zl.forEach(a=>{this.cloneFromStateToValues(a,`${a}1`),this.cloneFromStateToValues(a,`${a}2`),this.cloneFromStateToValues(a,`${a}End1`),this.cloneFromStateToValues(a,`${a}End2`),this.values[`${a}EndTime`]=0,this.values[`is${a}Changing`]=!1}),this.cloneFromStateToValues("size","size"),this.performanceChecker.on("performancecaveat",()=>{this.emit("performancecaveat")});const o=a=>{if(a instanceof Error)throw a};this.setStyle((r=t==null?void 0:t.style)!=null?r:n.DEFAULT_MAPGL_STYLE,t==null?void 0:t.styleOptions).catch(o),this.setLang(this.state.lang),t&&!t.disableBssStatistics&&(this._bssDispatcher=new Dy(this,{disableBssStatisticsForCommPoi:!!t.disableBssStatisticsForCommPoi,bssUrl:t.bssUrl})),this.state.metrics.init=performance.now()-this.state.metrics.start,this.updateDataToggle()}setCenter(e,t){if(!Vl.isValidGeoPoint(e,bs.IgnoreCall))return this;this.state.userHasInteracted=!1;let i=n.Mercator.fromGeo(e);return this.state.loopWorld||(i=n.normalizeMapPoint(i)),Dt(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,Tt(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,Tt(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,_i(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,Vi(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,Fc(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,r,a,l;const i={top:(o=e.top)!=null?o:0,left:(r=e.left)!=null?r:0,right:(a=e.right)!=null?a:0,bottom:(l=e.bottom)!=null?l:0};return this.state.userHasInteracted=!1,Hc(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(z({},this.state),{padding:{left:0,right:0,top:0,bottom:0}}));else if(e!=null&&e.sizeExtension){const o=e.sizeExtension,[r,a]=this.state.size,l=[r+o,a+o];t=new n.Camera(de(z({},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=r=>(this.modules.styleManager.hideLayers(r),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const r=n.convertStyleLayerTypeToHandy(i);if(r)return o({type:r})}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=r=>(this.modules.styleManager.showLayers(r),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const r=n.convertStyleLayerTypeToHandy(i);if(r)return o({type:r})}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 q(this,null,function*(){let i,o=!1,r=!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),r=!0,this.emit("styleload",{style:i}),i}catch(a){if(r)throw a;if(a instanceof Error&&this.emit("error",{type:"styleloaderror",style:e}),o&&!this.currentPendingStyle)return this.setStyle(n.DEFAULT_MAPGL_STYLE);throw a}})}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=z({top:0,left:0,right:0,bottom:0},i!=null&&i.padding?i.padding:{}),r=this.getViewport(),a=this.getPadding(),l=i!=null&&i.skipMapPadding?o:Oc(a,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||_i(this.state,d,{animate:!1});const _=Oi([[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+r.left,(c[1]-l.top-l.bottom)/2+l.top+r.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=z({},x);return Dt(this.state,v,x),Tt(this.state,h,g),Vi(this.state,0,x),this}update(){const e=this.state,{time:t,userHasInteracted:i}=e,o=this.values,r={};Zl.forEach(c=>{let d=e[c];c==="zoom"&&e.zoomTypePreserving==="styleZoom"&&(d=e.styleZoom),r[`${c}start`]=!o[`is${c}Changing`]&&!this.areEqual(d,o[`${c}1`])&&this.areEqual(o[`${c}1`],o[`${c}2`]),r[`${c}start`]&&(o[`is${c}Changing`]=!0),o[`is${c}Changing`]&&(r[c]=!this.areEqual(d,o[`${c}1`]),t-o[`${c}EndTime`]>Ky&&(r[`${c}end`]=this.areEqual(d,o[`${c}End1`])&&!this.areEqual(o[`${c}End1`],o[`${c}End2`]),r[`${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`)}),r.resize=!this.areEqual(e.size,o.size),this.copyFromStateToValues(e.size,"size"),r.movestart=(r.zoomstart||r.rotationstart||r.centerstart||r.pitchstart)&&!o.isMoveChanging,r.movestart&&(o.isMoveChanging=!0),r.move=o.iszoomChanging||o.isrotationChanging||o.iscenterChanging||o.ispitchChanging,r.moveend=(r.zoomend||r.rotationend||r.centerend||r.pitchend)&&!r.move,r.moveend&&(o.isMoveChanging=!1);const a=o.isIdle,l=o.isReady;o.isIdle=this.isIdle(),o.isReady=this.isReady(),r.idle=!a&&o.isIdle,r.ready=!l&&o.isReady,e.metrics.ready===void 0&&this.isReadyForMetrics()&&(e.metrics.ready=performance.now()-e.metrics.start);for(const c in r){const d=c;r[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=$t()?"light":e.graphicsPreset;this.state.styleState=Rn(e,this.getGraphicsPresetFeatures(o))}else this.state.styleState=Rn(e);i(),this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}getStyleState(){return z({},this.state.styleState)}patchStyleState(e){if(this.state.graphicsPresetMode){const t=$t()?"light":e.graphicsPreset;this.state.styleState=vl(this.state.styleState,e,this.getGraphicsPresetFeatures(t))}else this.state.styleState=vl(this.state.styleState,e);this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}setOption(e,t){if(Rs.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(Rs.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,r=598044/(this.state.size[0]*this.state.size[1]/window.devicePixelRatio),a=[{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*r,c=t*r,d=i*r,_=((f=a.find(v=>v.draws[0]<=l&&v.draws[1]>=l))==null?void 0:f.level)||0,u=((m=a.find(v=>v.vertcles[0]<=c&&v.vertcles[1]>=c))==null?void 0:m.level)||0,h=((p=a.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 xy.reduce((t,i)=>(t[i]=this.getFeatureFlag(i,e),t),{})}setCustomStyleById(e,t){return q(this,null,function*(){this.currentPendingStyle=e;const{iconUrl:i,styleServer:o,fontUrl:r,modelUrl:a}=this.state,l=n.applyDefaults(t||{},{rootUrl:o,stylePath:n.styles.path,iconsPath:i,fontsPath:r,modelsPath:a}),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 q(this,null,function*(){this.currentPendingStyle=e;const i=n.applyDefaults(t||{},{rootUrl:e,iconsPath:"",fontsPath:"",stylePath:"style.json",modelsPath:""}),o=yield Yy(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,r=n.applyDefaults(t||{},{rootUrl:`${i}//${o}`,stylePath:"",iconsPath:"",fontsPath:"",modelsPath:""});this.currentPendingStyle=`__${Date.now()}__${performance.now()}__`;const a=e&&JSON.parse(JSON.stringify(e));return this.setCustomStyle(a,r)}setCustomStyle(e,t){return q(this,null,function*(){if(!e)throw new Error("Can't set empty style");const i=this.currentPendingStyle||"";this.currentPendingStyle=void 0;const o=yield Xy(e,this.state.tileKey,t);if(this.currentPendingStyle!==void 0)return;const{showCommPoi:r}=yield this.modules.tileKeyInfo.getKeyInfo(),a=this.modules.styleManager.createStyle(o,t,r);this.state.handyStyleId=a.id,this.state.styleId=i,this.patchStyleState({}),this.core.activateStyleUpdating()})}copyFromStateToValues(e,t){Li(e)?n.copy$3(this.values[t],e):this.values[t]=e}cloneFromStateToValues(e,t){const i=this.state[e];Li(i)?this.values[t]=n.clone(i):this.values[t]=i}copyFromValuesToValues(e,t){const i=this.values[t];Li(i)?n.copy$3(this.values[e],i):this.values[e]=i}areEqual(e,t){return Li(e)&&Li(t)?n.exactEquals$1(e,t):e===t}fetchStyleById(e,t){return q(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 r=yield o.json();if(r&&r.result)return{loadedId:t,style:r.result}})}updateDataToggle(){this.modules.defaultSource.setDataType(this.state.styleState.immersiveRoadsOn?qy:void 0)}}function Yy(s){return fetch(s).then(e=>{if(e.ok)return e.json()})}function Li(s){return s.length!==void 0}const jl=0,Qy=-1,Jy=-2,Wl=3,Ay=0,ex=0,tx="#3388ff",ix="#00000000",nx="#00000000";let $l=class extends $e{constructor(e,t){var a,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 r=0;this.distances=[],this.distances.push(r);for(let y=1;y<this.geoPoints.length;y++)r+=n.geoPointsDistance(this.geoPoints[y-1],this.geoPoints[y]),this.distances.push(r);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:(a=this.options.color)!=null?a:tx,width:(l=this.options.width)!=null?l:Wl},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:jl)),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:Wl},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?_:jl))}}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:ix,width:(h=this.options.width2)!=null?h:Ay},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:Qy))}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:nx,width:(p=this.options.width3)!=null?p:ex},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:Jy))}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,r=this.points.map(u=>t(u));let a=1/0,l=r[0],c=0;for(const u of o){const h=t(this.modules.camera.flat.unproject(e),u);for(let f=0;f<r.length-1;f++){const m=r[f],p=r[f+1],v=n.getClosestPointOnLineSegment(h,m,p),x=v[0]-h[0],g=v[1]-h[1],y=x*x+g*g;y<a&&(a=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 r=((l=this.options.showAnimation)==null?void 0:l.easing)!==void 0?this.options.showAnimation.easing:"linear",a=((c=this.options.showAnimation)==null?void 0:c.duration)!==void 0?this.options.showAnimation.duration:250;n.start(e,{easing:r,animationGroup:(d=this.options.showAnimation)==null?void 0:d.animationGroup},this.mapState,0,1,a,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 r=n.makeHandyStyleLayer(t);r&&(o.updateLayerStyle(e,r),this.modules.renderer.addRerenderEvent())}}updateShowTicker(e){n.update(e,{step:(t,i)=>{var r,a,l,c;const o=n.affineStep(((a=(r=this.options.showAnimation)==null?void 0:r.durationRange)==null?void 0:a.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:r,map:a}=this.modules,{tileProps:l}=n.fixedMetatile,c=Math.min(Math.floor(a.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],B=g[g.length-1];g.push(E-1,B+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 B=t.getStyle().layers.find(K=>K.id==="debug-tile-bounds");n.generateTileBounds(i,B,this.mapState.styleState);const N=i.getAccumulatedData(),J=new n.TileObject("dynamicObject",N.data,this.modules,this.mapState,v);this.tileObjects.push(J),o.addObject(J,e)}const M=n.createTileInfo(v),S=[],P=[];for(let E=0;E<p.length;E++)n.mapPointToTilePoint(h,p[E],M),S[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 T=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,T),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,T,M,{x:S,y:P}]}))}if(this.styleHiddenLayerId!==void 0){const E=t.getStyle().layersById[this.styleHiddenLayerId];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,T),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,T,M,{x:S,y:P}]}))}if(this.styleLayer2Id!==void 0){const E=t.getStyle().layersById[this.styleLayer2Id];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,T),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,T,M,{x:S,y:P}]}))}if(this.styleLayer3Id!==void 0){const E=t.getStyle().layersById[this.styleLayer3Id];n.isLineStyleLayer(E)&&(n.runPrecomputes(E,T),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[t.getStyle().id,E,T,M,{x:S,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&&r.resetCache(),i.reset(),e||this.modules.renderer.addRerenderEvent()}};const Xl=0,Kl=-1,ql=8,Yl=12,ox="#2480ff",sx="#ffffff",Ql=6,Jl=20,rx="#ffffff00";class Al extends $e{constructor(e,t){var o,r,a,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||ox,dashLength:(o=this.options.dashLength)!=null?o:Ql,gapColor:this.options.gapColor||rx,gapLength:(r=this.options.gapLength)!=null?r:Jl,width:(a=this.options.width)!=null?a:ql},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||sx,width:(c=(l=this.options)==null?void 0:l.width2)!=null?c:Yl},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:Ql,gapColor:this.options.hiddenPartGapColor,gapLength:(_=this.options.gapLength)!=null?_:Jl,width:(u=this.options.width)!=null?u:ql},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:Yl},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:r,hiddenPartGapColor:a,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){r!==void 0&&(this.hiddenDashLayerRaw.style.color=r),o!==void 0&&(this.hiddenDashLayerRaw.style.gapColor=a);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 r,a,l,c;const o=n.affineStep(((a=(r=this.options.showAnimation)==null?void 0:r.durationRange)==null?void 0:a.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 r=((l=this.options.showAnimation)==null?void 0:l.easing)!==void 0?this.options.showAnimation.easing:"linear",a=((c=this.options.showAnimation)==null?void 0:c.duration)!==void 0?this.options.showAnimation.duration:250;n.start(e,{easing:r,animationGroup:(d=this.options.showAnimation)==null?void 0:d.animationGroup},this.mapState,0,1,a,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:r,identifier:a}=this.modules,{tileProps:l}=n.fixedMetatile,c=Math.min(Math.floor(r.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 T=0;T<g.length;T++)n.expandByPoint(f,g[T]);n.center(h,f);const y=n.getTileCoordsByCenterAndZoom(h,c),b=n.createTileInfo(y),M=[],S=[];let P=0;for(let T=0;T<g.length;T++)if(n.mapPointToTilePoint(h,g[T],b),M[T]=h[0],S[T]=h[1],T!==0){const C=M[T]-M[T-1],I=S[T]-S[T-1];P+=Math.sqrt(C*C+I*I)}p+=P,m.push({vertices:{x:M,y:S},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 B,N,J,K;const{tileInfo:b,distance:M,vertices:S}=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 F=u[y-1],ee=F[F.length-2];n.mapPointToTilePoint(h,ee,b),this.tileAttrs[l.beginningIsCut]=1,this.tileAttrs[l.previousPointX]=h[0],this.tileAttrs[l.previousPointY]=h[1]}if(y!==m.length-1){const ee=u[y+1][1];n.mapPointToTilePoint(h,ee,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]),T=[...this.mapState.visibleMapReplicas];if(this.isOutOfMainReplica()){const F=T[0],ee=T[T.length-1];T.push(F-1,ee+1)}if(T.map(F=>[b.coords[0]+F*P,b.coords[1],b.coords[2],b.coords[3]]).every(F=>!n.isTileVisible(F,this.mapState.tilesBounds,this.modules)))return;this.dashLayer&&(t.addLayer(this.dashLayer,(B=this.options.zIndex)!=null?B:Xl),n.runPrecomputes(this.dashLayer,x),n.generateSafely({collector:i,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,this.dashLayer,x,b,S]})),this.baseLayer&&(t.addLayer(this.baseLayer,(N=this.options.zIndex2)!=null?N:Kl),n.runPrecomputes(this.baseLayer,x),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,this.baseLayer,x,b,S]})),this.hiddenDashLayer&&(t.addLayer(this.hiddenDashLayer,(J=this.options.zIndex)!=null?J:Xl),n.runPrecomputes(this.hiddenDashLayer,x),n.generateSafely({collector:i,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,this.hiddenDashLayer,x,b,S]})),this.hiddenBaseLayer&&(t.addLayer(this.hiddenBaseLayer,(K=this.options.zIndex2)!=null?K:Kl),n.runPrecomputes(this.hiddenBaseLayer,x),n.generateSafely({collector:i,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,this.hiddenBaseLayer,x,b,S]}));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&&a.resetCache(),i.reset(),e||this.modules.renderer.addRerenderEvent()}}const ax="#3388ff33",lx="#3388ff",cx=3;let ec=class extends $e{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],B=I[I.length-1];(E[0]!==B[0]||E[1]!==B[1])&&I.push(E)}return I});let o=[];const r=[],{dynamicStyle:a,collector:l,tileManager:c,identifier:d,layers:_}=this.modules;i.forEach(C=>{o.length&&r.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||ax}});if(!u)return;a.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,r),g=n.create$1(),y=[],b=[],M=[],S=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,h,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(u,S);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:[a.getStyle().id,u,S,{x:y,y:b,cut:M},n.pixelRatioToDpi(window.devicePixelRatio),a.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||lx,width:this.options.strokeWidth||cx}});C&&(a.addLayer(C,this.options.zIndex),this.borderLayerId=C.innerId,n.runPrecomputes(C,S),i.forEach(I=>{const E=[],B=[];I.forEach((N,J)=>{n.mapPointToTilePoint(g,N,p),E[J]=g[0],B[J]=g[1]}),n.generateSafely({collector:l,generator:n.LineGenerator.generate,args:[a.getStyle().id,C,S,p,{x:E,y:B}]})}))}const P=l.getAccumulatedData(),T=new n.TileObject("dynamicObject",P.data,this.modules,this.mapState,p.coords,this);c.addObject(T),this.tileObjects.push(T),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 dx="#3388ff33",_x="#3388ff",ux=1,hx=150;let tc=class extends $e{constructor(e,t){var S,P,T,C;if(super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t,t.segments&&t.segments<=0)return;const{dynamicStyle:i,collector:o,tileManager:r,identifier:a,layers:l}=this.modules,c=fx(n.Mercator.fromGeo(this.options.coordinates),n.geoToMapDistance(this.options.coordinates,this.options.radius),(S=this.options.segments)!=null?S:hx);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:dx,strokeWidth:(T=this.options.borderWidth)!=null?T:ux,strokeColor:(C=this.options.borderColor)!=null?C:_x}});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);r.addObject(M),this.tileObjects.push(M),this.interactive&&this.identifyIds.push(b.identifyIds),l.addLayer(this),o.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&a.resetCache()}remove(){this.interactive&&this.modules.identifier.resetCache(),this.layerId&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}};function fx(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 r=o;r<Math.PI;r+=o){const a=e*Math.cos(r),l=e*Math.sin(r);i.push(n.fromValues(s[0]+a,s[1]+l,s[2]),n.fromValues(s[0]+a,s[1]-l,s[2]))}i.push(n.fromValues(s[0]-e,s[1],s[2]))}return i}function Ss(s,e,t,i,o,r){if(o-i<=t)return;const a=i+o>>1;ic(s,e,a,i,o,r%2),Ss(s,e,t,i,a-1,r+1),Ss(s,e,t,a+1,o,r+1)}function ic(s,e,t,i,o,r){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));ic(s,e,t,m,p,r)}const a=e[2*t+r];let l=i,c=o;for(Pi(s,e,i,t),e[2*o+r]>a&&Pi(s,e,i,o);l<c;){for(Pi(s,e,l,c),l++,c--;e[2*l+r]<a;)l++;for(;e[2*c+r]>a;)c--}e[2*i+r]===a?Pi(s,e,i,c):(c++,Pi(s,e,c,o)),c<=t&&(i=c+1),t<=c&&(o=c-1)}}function Pi(s,e,t,i){Ts(s,t,i),Ts(e,2*t,2*i),Ts(e,2*t+1,2*i+1)}function Ts(s,e,t){const i=s[e];s[e]=s[t],s[t]=i}function mx(s,e,t,i,o,r,a){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<=a){for(let v=f;v<=h;v++)d=e[2*v],_=e[2*v+1],d>=t&&d<=o&&_>=i&&_<=r&&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&&_<=r&&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:r>=_)&&(l.push(m+1),l.push(h),l.push(p))}return c}function px(s,e,t,i,o,r){const a=[0,s.length-1,0],l=[],c=o*o;for(;a.length;){const d=a.pop(),_=a.pop(),u=a.pop();if(_-u<=r){for(let v=u;v<=_;v++)nc(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];nc(f,m,t,i)<=c&&l.push(s[h]);const p=(d+1)%2;(d===0?t-o<=f:i-o<=m)&&(a.push(u),a.push(h-1),a.push(p)),(d===0?t+o>=f:i+o>=m)&&(a.push(h+1),a.push(_),a.push(p))}return l}function nc(s,e,t,i){const o=s-t,r=e-i;return o*o+r*r}const vx=s=>s[0],gx=s=>s[1];class yx{constructor(e,t=vx,i=gx,o=64,r=Float64Array){this.nodeSize=o,this.points=e;const a=e.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(e.length),c=this.coords=new r(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]);Ss(l,c,o,0,l.length-1,0)}range(e,t,i,o){return mx(this.ids,this.coords,e,t,i,o,this.nodeSize)}within(e,t,i){return px(this.ids,this.coords,e,t,i,this.nodeSize)}}function xx(s,e,t){const i=[],o=[],r=[],a=n.create$1();return e.forEach(({mapCoords:l,weight:c})=>{bx(a,l,t);const d=a[0],_=a[1];for(let u=0;u<6;u++)i.push(d,_),r.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(r),{itemSize:1,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1})}}function bx(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 wx(s,e){const t=Sx(s),i=Tx(t,e);return new w(new Uint8Array(i),{size:[e,1]})}function Sx(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 r=Math.min(...i),a=Math.max(...i);return r>0&&(o[0]=o[r]),a<1&&(o[1]=o[a]),o}function Tx(s,e){const t=Object.keys(s).map(a=>Number(a)).sort((a,l)=>a-l);let i=0;const o=[],r=e-1;for(let a=0;a<e;a++){const l=a/r;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[a*4+f]=Ex(s[c].value[f],s[d].value[f],h)}return o.map(a=>Math.round(a))}function Mx(s,e){return s.every((t,i)=>t===e[i])}function Ex(s,e,t){return s*(1-t)+e*t}const Ix=256,Cx=.5,Lx=3,Px=10,Bx=1,zx=1,Rx={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 Fx extends $e{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&&Mx(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=xx(this.modules.renderer,y,b),this.vertexCount=y.length*6,this.vao=new V(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:r,minZoom:a,maxZoom:l,zIndex:c,pointRadius:d,intensity:_,opacity:u}=t;this.rampTextureIndex=this.modules.imageManager.addPreparedTexture(wx(o!=null?o:Rx,Ix)),this.downscale=i!=null?i:zx,this.frameBuffer=new Te({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:a,maxzoom:l,style:{opacity:u!=null?u:Cx,intensity:_!=null?_:Lx,radius:d!=null?d:Px}});if(!f)throw new Error("There is no correct style layer for heatmap");this.layer=f,this.modules.dynamicStyle.addLayer(f,c),r&&this.setPoints(r)}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:Bx})),this.tree=new yx(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:r}=this.modules;n.generateSafely({collector:i,generator:n.HeatmapGenerator.generateTexture,args:[o.getStyle().id,this.layer,this.offscreenTextureIndex,this.rampTextureIndex]});const a=i.getAccumulatedData(),l=new n.TileObject("dynamicObject",a.data,this.modules,this.mapState);r.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 r=n.makeBinderContext(i,o,[]),a=n.resolveNumber(this.layer.style.radius,r),l=n.resolveNumber(this.layer.style.intensity,r),c=n.tileSizeZpt*Math.pow(2,t-this.tileCoords[2])*window.devicePixelRatio;this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||qs(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:a*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(Tr),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 Dx="#000000",Ox=0,Nx="#ffffff",kx=0,oc=[0,0],Ux=0,Hx=[0,0,0,0],Ms=-1;class Es extends $e{constructor(e,t,i){var E,B,N,J,K,F,ee,be,we,Ke,Ve,Ze,Pt;super(e,{interactive:(E=t.interactive)!=null?E:!1},i),this.hovered=!1,this.lastLabelingRevision=Ms,this.status="visible",this.labelingStatus=0,this.options=t,this.labelKey=`point-label-${this.uniqId}`;const o=(B=t.font)!=null?B:n.DEFAULT_FONT,r=(N=t.fontSize)!=null?N:n.fonts.baseSize,a=(J=t.letterSpacing)!=null?J:kx,l=(K=t.lineHeight)!=null?K:n.fonts.baseLineHeight,c=[(ee=(F=this.options.offset)==null?void 0:F[0])!=null?ee:oc[0],(we=(be=this.options.offset)==null?void 0:be[1])!=null?we:oc[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:r,textColor:(Ke=t.color)!=null?Ke:Dx,textHaloWidth:(Ve=t.haloRadius)!=null?Ve:Ox,textHaloColor:(Ze=t.haloColor)!=null?Ze:Nx,textLetterSpacing:a,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=(Pt=this.options.zIndex)!=null?Pt:Ux;u.addLayer(d,g);const y=n.optionsToTileAttrs({db_label:this.options.text}),b=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),M={x:[0],y:[0]},S=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,y,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,S),n.generateSafely({collector:h,generator:n.preLabelingPoint,args:[u.getStyle(),d,S,n.fixedMetatile,n.LATEST_TILE_VERSION,b,x.getId(),M,n.pixelRatioToDpi(window.devicePixelRatio)]});const P=h.getAccumulatedData();if(!P.labels.length)return;const T=[{metatileHash:-1,labels:P.labels,styleId:u.getStyle().id}],C=n.unpackPreLabelingResult(T,n.LabelSource.DynamicObject,m,this.mapState.styleState,this.mapState.styleZoom);if(C.length!==1)return;const I=C[0];n.rtlAdapterPromise.then(()=>{var Ie;I.label=(Ie=n.processRTLTextIfNeeded(I.label))!=null?Ie:"",I.updateRanges()}).then(()=>Promise.all(I.ranges.map(Ie=>f.loadFont(o,Ie)))).then(()=>{if(this.status==="destroyed")return;I.textMetrics=n.getTextMetrics(I.label,a,f.getFontGlyphs(o));const Ie=Gx(t.anchor),Bt=r/n.fonts.baseSize,Se=r*l*I.textMetrics.lines.length,zt=Bt*I.textMetrics.maxWidth,St=[-zt*(Ie[0]-.5),-Se*(Ie[1]-.5)],[Wt,je]=c,ci=[Wt+St[0],je+St[1]],Ri=n.Mercator.toGeo(this.position.userValue),Fi=n.Ecef.fromGeo(Ri);n.generateSafely({collector:h,generator:n.generateTextElement,args:[I,"",1,I.textMetrics,[0,0,0],Fi,0,ci,d,u.getStyle().fontNameToIndex[o],window.devicePixelRatio]});const Di=h.getAccumulatedData(),Bs=new n.TileObject("dynamicObject",Di.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);Is(Bs,this.position.userValue[2]),v.addLayer(this),this.tileObjects.push(Bs),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:zt,height:Se,position:this.position.normalizedValue,offset:[ci[0]-Ie[0]*zt,ci[1]-Ie[1]*Se],labelingGroup:"pointLabel"},this.addLabelToLabeler(),this.update()):this.status==="visible"&&p.addObject(Bs),this.modules.renderer.addRerenderEvent(),this.initImageIfNeed(I,zt,Se,c,St)})}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),Is(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(r=>{r.attributes.animDirection=i}))}initImageIfNeed(e,t,i,o,r){return q(this,null,function*(){var E,B;if(!this.options.image)return;const{imageCache:a,dynamicStyle:l,collector:c,tileManager:d}=this.modules,_=window.devicePixelRatio,u=yield a.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||Hx,x=(t+v+m)*_,g=(i+f+p)*_,y=((m-v)/2+o[0]+r[0])*_,b=((p-f)/2+o[1]+r[1])*_,M=(E=this.options.image.stretchX)==null?void 0:E.map(([N,J])=>[N*_,J*_]),S=(B=this.options.image.stretchY)==null?void 0:B.map(([N,J])=>[N*_,J*_]),P=n.Mercator.toGeo(this.position.userValue),T=n.Ecef.fromGeo(P);n.generateSafely({collector:c,generator:n.generateIconElement,args:[e,"",[0,0,0],T,0,h,x,g,y,b,window.devicePixelRatio,M,S]});const C=c.getAccumulatedData();c.reset();const I=new n.TileObject("dynamicObject",C.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue));Is(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=Ms)})}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=Ms)}removeLabelFromLabeler(){this.labelBox&&this.modules.labeler.removeLabels(this.labelKey)}}function Gx(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 Is(s,e){s.modelMatrices.forEach(t=>{t[14]=e})}const Vx=18,Zx=[.5,.5],jx=[0,18],Wx=0,$x=0;let sc=class extends Ds{constructor(e,t){super(e,t,t.draggable),this.visible=!0,this.map=e,this.options=t;const{coordinates:i,size:o,zIndex:r,minZoom:a,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:$x),this.zIndex=r!==void 0?r:Wx,this.minZoom=a!=null?a:-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(super.update(),this.mapState.dpiChanged){const{icon:e,hoverIcon:t}=this.options;e&&this.setIconInternal(z({icon:e},this.options)),e&&t&&this.setHoverIconInternal(z({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"&&(rc({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}rc({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,r,a;this.status!=="destroyed"&&((t=this.label)==null||t.remove(),e&&(this.label=new Es(this.map,de(z({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:(r=e.fontSize)!=null?r:Vx,anchor:e.anchor||Zx,offset:e.offset||jx,zIndex:(a=e.zIndex)!=null?a: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,r=t!==void 0?t.anchor:i.anchor,a=this.modules.camera.flat.project(this.position.normalizedValue),l=a[0]-o[0]*r[0],c=a[0]+o[0]*(1-r[0]),d=a[1]-o[1]*r[1],_=a[1]+o[1]*(1-r[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:r}){const{zIndex:a,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:r,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,a),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 S=M[0],P=n.Mercator.toGeo(this.position.userValue),T=n.Ecef.fromGeo(P);n.generateNotStretchableIconElement(c,S,"",[0,0,m],T,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 q(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 q(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 rc(s,e){var t,i,o,r,a,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])!==((r=e.anchor)==null?void 0:r[1])||((a=s.size)==null?void 0:a[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 Xx=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 r=o.x,a=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;Kx(d.indices,_,0,1,2,2,1,3),Wn(d,_++,r[0],a[0],l),Wn(d,_++,r[1],a[1],l),Wn(d,_++,r[2],a[2],l),Wn(d,_++,r[3],a[3],l),d.elements.offset=_}});function Wn(s,e,t,i,o){const r=e*4;s.views.position[r]=n.tileCoordOffset+t,s.views.position[r+1]=n.tileCoordOffset+i;const a=e*2;s.views.localID[a]=o}function Kx(s,e,t,i,o,r,a,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+r,c[d+4]=e+a,c[d+5]=e+l,s.offset=d+6}const qx="#0085a0";class Yx extends $e{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i,collector:o,tileManager:r,identifier:a,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||qx}});if(!c)return;i.addLayer(c,this.options.zIndex),this.layerId=c.innerId;const d=n.optionsToTileAttrs({db_tiers:t.tiers});this.points=Qx(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:Xx.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);r.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&&a.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 Qx(s,e,t){const i=e/2,o=t/2,r=s[0],a=s[1],l=s[2];return[[r-i,a-o,l],[r+i,a-o,l],[r-i,a+o,l],[r+i,a+o,l]]}let ac=class extends $e{constructor(e,t){super(e,{interactive:!1}),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i}=this.modules;this.options=de(z({},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(r=>{this.textureIndex=r,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=Jx(this.options.bounds),this.isGeometryOutOfMainReplica=this.points.some(p=>p[0]>n.HALF_WORLD_SIZE||p[0]<-n.HALF_WORLD_SIZE);const r=n.create();for(let p=0;p<this.points.length;p++)n.expandByPoint(r,this.points[p]);const a=n.getBoundsTileCoords(r),l=n.createTileInfo(a),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,a,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 Jx(s){const{min:e,max:t}=n.fromGeo(s);return[e,[t[0],e[1]],[e[0],t[1]],t]}class Ax{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[r,a,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(r,a,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 a=this.modules.sourceStorage.getSourceById(this.id);(a==null?void 0:a.type)==="raster"&&this.modules.map.emit("error",{type:"rasterTileLoadError",tileCoords:n.tileCoordsToOSM(e),tileUrl:i,source:a,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 q(this,null,function*(){const i=[],o=[],r=this.modules.styleManager.getStyle(e.handyStyleId),a=n.coordsToKey(t),l=this.tiles.get(a);if(!l||!r)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[a]=c;const d=[],_=[],u=n.create$1(),h=eb(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);r.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:_},r.id,m,v,c,null]})});const p=this.modules.collector.getAccumulatedData();return i.push({regionId:0,metatileHash:0,styleId:r.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 eb(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 lc=class{constructor(e,t,i){var a,l;this.type="raster",this.id=n.sourceUuid(),this.modules=e.modules,this.source=new Ax(this.id,this.modules,t);const o=(a=t.minZoom)!=null?a:n.MAP_DEFAULTS.minZoom,r=(l=t.maxZoom)!=null?l:n.MAP_DEFAULTS.maxZoom;this.layer=new n.TileLayer(o,r,o,r,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 tb=0;class ib extends $e{constructor(e,t){var a;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=(a=t.zIndex)!=null?a:tb,this.isDestroyed=!1,this.labelKey=`onlineMarker-${this.uniqId}`;const o=this.options.floorId?e.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0):0,r=t.elevation?t.elevation*n.Mercator.scaleFactor(t.coordinates[1])*n.MAP_POINTS_IN_METER:0;this.elevation=r+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:r}=e;this.modules.imageCache.getRasterSet(t,i,o,r).then(a=>{if(this.isDestroyed||!a||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:r}}),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(a,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}],S=n.unpackPreLabelingResult(M,n.LabelSource.DynamicObject,u,this.mapState.styleState,this.mapState.styleZoom);if(S.length!==1)return;const P=S[0],T=n.Mercator.toGeo(this.position.userValue),C=n.Ecef.fromGeo(T);n.generateNotStretchableIconElement(d,P,"",[0,0,this.elevation],C,0,a.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:[-r[0],-r[1]],labelingGroup:"marker"}),this.modules.renderer.addRerenderEvent()})}update(){if(super.update(),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 nb(s,e,t,i,o,r){return{type:s,maxDetailLevel:r,minDetailLevel:o,maxZoomLevel:i,minZoomLevel:t,zoomLevel:Math.floor(e),tiles:{},viewportTiles:[],useExtendedTilesBounds:!1}}function ob(s){s.tiles={},s.viewportTiles=[]}function sb(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 rb(s,e,t,i,o){return nb("data",s,e,t,i,o)}function ab(s,e,t,i){if(s.zoomLevel<s.minZoomLevel){s.viewportTiles=[];return}const o=n.clamp(s.zoomLevel,s.minZoomLevel,s.maxZoomLevel),r=n.clamp(s.zoomLevel,s.minDetailLevel,s.maxDetailLevel);s.viewportTiles=n.findVisibleTiles(e,t,o,s.minZoomLevel,r,void 0,void 0,void 0,s.useExtendedTilesBounds).map(n.coordsToKey);for(let a=0;a<s.viewportTiles.length;a++){const l=s.viewportTiles[a];let c=s.tiles[l];c||(c=s.tiles[l]=i(n.keyToCoords(l)))}}function lb(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 cb(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 db(s,e){const t=new Set(s.viewportTiles),i=[];for(const o in s.tiles){const r=s.tiles[o];!t.has(o)&&!0&&i.push(r)}return i}class _b extends n.Evented{constructor(e,t,i){super(),this.prevZoomLevel=0,this.mapState=e,this.modules=t,this.config=i,this.gridState=rb(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(){ob(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,ab(this.gridState,this.mapState,this.modules,sb),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(lb(this.gridState)),this.abortFetch(cb(this.gridState)),this.clearTiles(db(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 ub=Object.freeze(Object.defineProperty({__proto__:null,Benchmark:Gn,Circle:tc,CircleMarker:Os,DashedPolyline:Al,DataTileLayer:_b,DefaultSource:dl,DynamicObject:$e,Entrance:cs,GeoJsonSource:n.GeoJsonSource,GeoJsonTileSource:n.GeoJsonTileSource,GeoJsonViewportSource:n.GeoJsonViewportSource,GltfModel:ms,Heatmap:Fx,HtmlMarker:rs,LinePatternType:n.LinePatternType,Map:ws,MapClass:ws,Marker:sc,OnlineMarker:ib,PointLabel:Es,Polygon:ec,Polyline:$l,Raster:ac,RasterTileSource:lc,Rect:Yx,ZenithSource:An,config:n.index,linePatternFromString:n.linePatternFromString,mapglUtils:Bc,utils:Pc},Symbol.toStringTag,{value:"Module"})),hb="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:hb,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 Vt={root:"mapgl_QEdaFvncPWE-",button:"mapgl_mjx-K8iaDdc-",zoomIn:"mapgl_zKZCVsRur9c-",zoomOut:"mapgl_3t-wJELDATg-"},fb=`
    <div class="${Vt.root}">
        <button type="button" class="${Vt.button} ${Vt.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="${Vt.button} ${Vt.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 cc extends Gt{constructor(e,t){super(e,fb,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(`.${Vt.zoomIn}`),this._zoomOutButton=this._wrap.querySelector(`.${Vt.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 Zt={root:"mapgl_ON-gf73kIU0-",button:"mapgl_mWyZxMObEi8-",none:"mapgl_FwnEmRmDBLg-",easy:"mapgl_uSuUHuf71nM-",medium:"mapgl_LdqAv9Ly624-",hard:"mapgl_udRZCM1quWE-"},mb=`<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 dc 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()?pb(this._score):Zt.none,t=`
            <div class="${Zt.root}">
                <button type="button" class="${Zt.button} ${e}">
                    ${this._map.isTrafficOn()&&this._score!==void 0?this._score:mb}
                </button>
            </div>
        `;this._wrap.innerHTML=t,this._wrap.querySelector(`.${Zt.button}`).addEventListener("click",this._onClick)}}function pb(s){return s===void 0?"":s>6?Zt.hard:s>3?Zt.medium:Zt.easy}const $n={container:"mapgl_K-1Yb8HCVpQ-",logos:"mapgl_CLps5xx6CNs-"};var _c=(s=>(s.osm="osm",s.api="api",s.license="license",s))(_c||{});const vb=`<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>`,gb=`<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>`,uc=s=>`
    <div class=${$n.container}>
        <div class=${$n.logos}>
            ${s==="2gis"?vb:gb}
        </div>
    </div>
`,yb=200,Ft=.4,xb=6.9,bb={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 wb extends Gt{constructor(e,t){super(e,uc(t.copyrightType),t),this._copyrightType="2gis",this._isHidden=!1,this._onViewportchange=()=>{this._throttledVisibleCopyright()},this._onClick=o=>{if(o.target&&Tb(o.target)){const r=o.target.dataset.type;Sb(r)&&this._map.emit("copyrightclick",{type:r,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(`.${$n.container}`).addEventListener("click",this._onClick),this._throttledVisibleCopyright=n.throttle(()=>{this.update()},yb)}destroy(){this._map._impl.off("viewportchange",this._onViewportchange),this._map._impl.off("idle",this._onViewportchange),this._wrap.querySelector(`.${$n.container}`).removeEventListener("click",this._onClick),super.destroy()}update(){let e=!1;if(this._map.getZoom()>xb){const t=this._map.getSize(),i=this._map._impl.unproject([t[0]*Ft,t[1]*Ft]),o=this._map._impl.unproject([t[0]*(1-Ft),t[1]*Ft]),r=this._map._impl.unproject([t[0]*Ft,t[1]*(1-Ft)]),a=this._map._impl.unproject([t[0]*(1-Ft),t[1]*(1-Ft)]);e=Mb([i,o,a,r,i],bb.features[0].geometry.coordinates[0])}e&&!this._isHidden&&(this._isHidden=!0,super.getContainer().innerHTML=""),!e&&this._isHidden&&(this._isHidden=!1,super.getContainer().innerHTML=uc(this._copyrightType))}}function Sb(s){return s!==void 0&&s in _c}function Tb(s){return s&&"href"in s&&"dataset"in s}function Mb(s,e){for(let t=0;t<s.length-1;t++){const i=s[t],o=s[t+1];for(let r=0;r<e.length-1;r++){const a=e[r],l=e[r+1];if(Eb(i,o,a,l))return!0}}return!!(hc(s[0],e)||hc(e[0],s))}function Eb(s,e,t,i){const o=Xn(t,i,s),r=Xn(t,i,e),a=Xn(s,e,t),l=Xn(s,e,i);return!!((o>0&&r<0||o<0&&r>0)&&(a>0&&l<0||a<0&&l>0)||o===0&&Kn(t,i,s)||r===0&&Kn(t,i,e)||a===0&&Kn(s,e,t)||l===0&&Kn(s,e,i))}function Xn(s,e,t){return(e[0]-s[0])*(t[1]-s[1])-(e[1]-s[1])*(t[0]-s[0])}function Kn(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 hc(s,e){const[t,i]=s;let o=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){const[l,c]=e[r],[d,_]=e[a];c>i!=_>i&&t<(d-l)*(i-c)/(_-c)+l&&(o=!o)}return o}const fc={wrap:"mapgl_r8Wn2E5pGh0-",container:"mapgl_ir0vRf5QXrk-"};class Ib{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 Cb=` <div class=${fc.container}>Your MapGL key is invalid. Please contact api@2gis.com to get MapGL key.</div> `;class Lb extends Ib{constructor(e){super(e,Cb),e._impl.on("error",t=>{t.type==="invalidtilekey"&&(this.isDisplayed()||this.display())})}initWrap(){const e=document.createElement("div");return e.classList.add(`${fc.wrap}`),e.innerHTML=this.content,e}}class mc{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],r=i>=this.southWest[1]&&i<=this.northEast[1];return o&&r}containsBounds(e){const{southWest:t,northEast:i}=e,o=this.containsPoint(t),r=this.containsPoint(i);return o&&r}intersects(e){const{southWest:t,northEast:i}=e,o=this.getPointRelatedLocation(t),r=this.getPointRelatedLocation(i),a=+o.N+ +r.N,l=+o.S+ +r.S,c=+o.W+ +r.W,d=+o.E+ +r.E;return!(a===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 He={root:"mapgl_h2pl79nAYpk-",container:"mapgl_64D1bmNQN3Q-",scroller:"mapgl_jdJbkjpLO7k-",content:"mapgl_54Rmy50n6Fw-",control:"mapgl_3i1QoGerxio-",label:"mapgl_wGplqJ4hHPc-"},Pb=`
    <div class="${He.root}">
        <div class="${He.container}">
            <div class="${He.scroller}">
                <div class="${He.content}" />
            </div>
        </div>
    </div>
`,Bb=`<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>`,zb=`<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 pc extends Gt{constructor(e,t){super(e,Pb,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:r,floorNames:a,metro:l,mode:c}=i;this._floor={mode:c,currentFloorLevelIndex:o,floorPlanId:r,floorNames:a,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(`.${He.root}`),this._content=this._wrap.querySelector(`.${He.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 r=document.createElement("button");r.className=`${He.control} ${He.hideFloorsButton}`,r.innerHTML=zb,r.name="metro",r.type="button";const a=this._controlHandler("metro");r.addEventListener("click",a),this._handlers.set(r,a),this._content.append(r),this._floor.mode==="metro"&&(r.disabled=!0,e=r)}this._floor.floorNames.forEach((r,a)=>{const l=document.createElement("button");l.className=He.control,l.innerHTML=`<div class="${He.label}">${r}</div>`,l.name=a.toLocaleString(),l.type="button",this._floor&&this._floor.mode==="floor"&&this._floor.currentFloorLevelIndex===a&&(l.disabled=!0,e=l);const c=this._controlHandler(a);l.addEventListener("click",c),this._handlers.set(l,c),this._content.append(l)});const t=document.createElement("button");t.className=`${He.control} ${He.hideFloorsButton}`,t.innerHTML=`<div class="${He.label}">${Bb}</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 r=(o=e.parentElement)==null?void 0:o.parentElement;r&&(r.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(`.${He.control}[name="${t}"]`);i&&(i.disabled=!1);const o=this._wrap.querySelector(`.${He.control}[name="${e}"]`);o&&(o.disabled=!0),typeof e=="number"?(this._floor.mode="floor",this._floor.currentFloorLevelIndex=e):this._floor.mode=e}}const Cs={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-"},Bi=10;class Rb{constructor(e,t){this.wrap=document.createElement("div"),this.wrap.className=Cs.controlPane,this.containers={};const{rootContainer:i}=e._impl.modules.layout;i.appendChild(this.wrap),this.padding={top:Bi,right:Bi,bottom:Bi,left:Bi},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:Bi,this.wrap.style[`margin${i.replace(/^\w/,r=>r.toUpperCase())}`]=`${this.padding[i]}px`})}getPadding(){return z({},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(Cs.container,Cs[e]),this.wrap.appendChild(t),t}}const vc={root:"mapgl_9m2ynAxdBT0-",label:"mapgl_sR4nXEQ3L2M-"},qn={meter:{en:"m",ru:"м"},kilometer:{en:"km",ru:"км"}},Fb=66;class gc 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 r=this._wrap.getBoundingClientRect(),a=this._calcSize([r.x,r.y],r.width||Fb,0),l=`
            <div class="${vc.root}">
                <div class="${vc.label}">
                    ${Db(a,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 Db(s,e){return s<1e3?`${s} ${qn.meter[e]||qn.meter.en}`:`${(s/1e3).toFixed(1)} ${qn.kilometer[e]||qn.kilometer.en}`}class yc{constructor(e){this._impl=e._impl.getDefaultSource()}setFeatureStateMap(e){this._impl.setFeatureStateMap(e)}}function Ge(s,e){const t=z({},s);for(const i in e){const o=i;t[o]===void 0&&(t[o]=e[o])}return t}const Ob={center:[0,0],zoom:0,minZoom:Vn.minZoom,maxZoom:Vn.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 Nb=class extends bt{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=z({},t.styleOptions),r=Ge(this._validateOptions(t),Ob),a=de(z({},r),{disableHoverStyles:(l=t.disableHoverStyles)!=null?l:!0,tileServer:t.tileServer||Sy,style:t.style||n.DEFAULT_MAPGL_STYLE,styleOptions:o,styleState:t.styleState,sessionId:xs(),tileSessionId:t.tileSessionId});this._impl=new ws(i,a),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 Rb(this,{padding:t.controlsLayoutPadding}),this._initControls(t),new Lb(this),this._defaultSource=new yc(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 mc(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 q(this,null,function*(){return this._impl.setStyle(e)})}setStyleFromUrl(e,t){return q(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:r,responseMessage:a,responseStatus:l}=t;if((r==null?void 0:r.type)==="raster"){const c=r.mapglApiSource;this.emit(e,{type:t.type,responseMessage:a,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:r,target:a,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;a!==void 0&&(d={id:a.id},a.center&&(d.center=a.center)),this.emit(e,{originalEvent:i,lngLat:o,point:r,target:d,targetData:c})}_initControls(e){if(e.copyright!==!1&&this._impl.modules.tileKeyInfo.getKeyInfo().then(t=>{!t.error&&!t.hideCopyright&&new wb(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 cc(this,{position:t})}if(e.trafficControl){const t=typeof e.trafficControl=="string"?e.trafficControl:"topRight";new dc(this,{position:t})}if(e.scaleControl){const t=typeof e.scaleControl=="string"?e.scaleControl:"bottomLeft";new gc(this,{position:t})}if(e.floorControl){const t=typeof e.floorControl=="string"?e.floorControl:"topRight";new pc(this,{position:t})}}_validateOptions(e){return e=z({},e),typeof e=="object"&&"center"in e&&(Vl.isValidGeoPoint(e.center,bs.UseDefault)||(e.center=void 0)),e}};const kb="Noto_Sans",Ub={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"},Hb={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 Gb extends bt{constructor(e,t){super(),t.icon||(t.anchor=[15,46]);const i=Ge(t,Hb);this.userData=i.userData,this.rootOptions={zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom},this._impl=new sc(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:xc(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(xc(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:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}function xc(s,e){var i,o,r;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=(r=e.zIndex)!=null?r:s.zIndex+1e-5;const t=Ge(e,Ub);return e.offset===void 0&&e.anchor!==void 0&&(t.offset=e.anchor.map(a=>-a)),{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:kb}}const Vb="Noto_Sans",Zb={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 jb extends bt{constructor(e,t){super(),this.userData=t.userData;const i=Ge(t,Zb);t.offset===void 0&&t.anchor!==void 0&&(i.offset=t.anchor.map(o=>-o)),this._impl=new Es(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:Vb,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:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Wb={minZoom:-1/0,maxZoom:1/0,zIndex:0,anchor:[-0,-0],preventMapInteractions:!0,userData:void 0,interactive:!0,disableRounding:!1,labeling:{type:"none"},floorId:""},$b=!1;class Xb{constructor(e,t){this.userData=t.userData;const i=Ge(t,Wb);this._impl=new rs(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:$b,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 Kb={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#3388ff33",strokeColor:"#3388ff",strokeWidth:1,interactive:!0,userData:void 0};class qb extends bt{constructor(e,t){super(),this.userData=t.userData;const i=Ge(t,Kb),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 tc(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Yb={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 Qb extends bt{constructor(e,t){super(),this.userData=t.userData,this.options=Ge(t,Yb);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 Os(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:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Jb={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 Ab extends bt{constructor(e,t){super(),this.userData=t.userData;const i=Ge(t,Jb);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 Al(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r))}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 $l(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r))}}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const ew={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#3388ff33",zIndex:0,strokeWidth:3,strokeColor:"#3388ff",userData:void 0};class tw extends bt{constructor(e,t){super(),this.userData=t.userData;const i=Ge(t,ew),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 ec(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const iw={minZoom:-1/0,maxZoom:1/0,zIndex:0,opacity:1};class nw{constructor(e,t){const i=Ge(t,iw),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 ac(e._impl,o)}updateImage(e){return q(this,null,function*(){yield this._impl.updateImage(e)})}destroy(){this._impl.destroy()}}const ow={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#0085a0",strokeColor:"#ffffff",width:4,strokeWidth:1,roundingRadius:2,tipWidthMultiplier:1.5,tipHeightMultiplier:2.8,tipMovementAmplitude:6,animate:!1,iterationCount:1/0,interactive:!1,userData:void 0};class sw extends bt{constructor(e,t){super(),this.userData=t.userData;const i=Ge(t,ow),a={coordinates:(l=>typeof l[0][0]=="number")(i.coordinates)?[i.coordinates]:i.coordinates,interactive:i.interactive,minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,color:i.color,borderColor:i.strokeColor,width:i.width,borderWidth:i.strokeWidth,roundingRadius:i.roundingRadius,wingWidthMultiplier:i.tipWidthMultiplier,tipHeightMultiplier:i.tipHeightMultiplier,tipMovementAmplitude:i.tipMovementAmplitude,animate:i.animate,iterationCount:i.iterationCount};this._impl=new cs(e._impl,a),this._impl.on("click",l=>this._emitPointerEvent("click",l)).on("dblclick",l=>this._emitPointerEvent("dblclick",l)).on("mousemove",l=>this._emitPointerEvent("mousemove",l)).on("mouseover",l=>this._emitPointerEvent("mouseover",l)).on("mouseout",l=>this._emitPointerEvent("mouseout",l)).on("mousedown",l=>this._emitPointerEvent("mousedown",l)).on("mouseup",l=>this._emitPointerEvent("mouseup",l)).on("touchstart",l=>this._emitPointerEvent("touchstart",l)).on("touchend",l=>this._emitPointerEvent("touchend",l))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const rw={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 aw extends bt{constructor(e,t){super(),this.userData=t.userData;const i=Ge(t,rw),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 ms(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r)).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 bc={attributes:{},maxZoom:17,dimensions:2,modelsPath:"",modelsAppearStrategy:"byModel",promoteId:"",idScope:"default",tolerance:3};class lw{constructor(e,t){this.options=Ge(t,bc),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 q(this,null,function*(){this._isDestroyed||(yield this._impl.setData(e))})}}const cw=de(z({},bc),{viewportPadding:0});class dw{constructor(e,t){this.options=Ge(t,cw);const i=de(z({},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 q(this,null,function*(){return this._impl.setDataFn(e)})}setViewportPadding(e){return this._impl.setViewportPadding(e),this}}const wc={container:"mapgl_54Xq9OUdARA-",text:"mapgl_qYE18V9u8c0-"},_w=s=>`
    <div class=${wc.container}>
        <div class=${wc.text}>${s}</div>
    </div>
`;class uw extends Gt{constructor(e,t){super(e,_w(t),{position:"bottomLeft"})}}const hw={attributes:{},attribution:"",minZoom:Vn.minZoom,maxZoom:Vn.maxZoom};class fw{constructor(e,t){this.options=Ge(t,hw),this._impl=new lc(e._impl,this.options,this),this._attribution=new uw(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 Qn=class Qn{constructor(e,t){this.options=t;const i=this.prepareOptions(this.options,e);this._impl=new An(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,r,a,l,c,d,_,u,h,f;const i={tileServer:(o=e.tileServer)!=null?o:"",tileSet:(r=e.tileSet)!=null?r:"",tileProtocol:(a=e.tileProtocol)!=null?a:"",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=`${Hl}?ts=userdata&x={x}&y={y}&z={z}&layer=${e.layerId}`),i.metatileTemplateUrl||(i.metatileTemplateUrl=`${Hl}/file/{hash}?ts=userdata&layer=${e.layerId}`)),i}};Qn.tileTemplateUrl="{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",Qn.metatileTemplateUrl="{protocol}://{host}/v2/ald/file/{hash}.json?ts={tileSet}";let Ls=Qn;function mw(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(wy));if(!s)return;const e=mw(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 pw(s){Rv(s)}const Ps="v1.72.0";A.API_VERSION=Ps,A.Arrow=sw,A.Circle=qb,A.CircleMarker=Qb,A.Control=Gt,A.DefaultSource=yc,A.FloorControl=pc,A.GeoJsonSource=lw,A.GeoJsonViewportSource=dw,A.GltfModel=aw,A.HtmlMarker=Xb,A.Label=jb,A.LngLatBoundsClass=mc,A.Map=Nb,A.Marker=Gb,A.Polygon=tw,A.Polyline=Ab,A.Raster=nw,A.RasterTileSource=fw,A.ScaleControl=gc,A.TrafficControl=dc,A.ZenithSource=Ls,A.ZoomControl=cc,A._J=ub,A.isSupported=bd,A.isTerrainSupported=Gs,A.notSupportedReason=Zs,A.setWorkerUrl=pw,A.terrainNotSupportedReason=zd,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
