@maptiler/sdk 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/biome.json +2 -1
- package/dist/maptiler-sdk.css +0 -1
- package/dist/maptiler-sdk.d.ts +1 -1785
- package/dist/maptiler-sdk.mjs +1782 -2617
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/MLAdapters/AttributionControl.d.ts +6 -0
- package/dist/src/MLAdapters/BoxZoomHandler.d.ts +8 -0
- package/dist/src/MLAdapters/CanvasSource.d.ts +6 -0
- package/dist/src/MLAdapters/CooperativeGesturesHandler.d.ts +6 -0
- package/dist/src/MLAdapters/FullscreenControl.d.ts +6 -0
- package/dist/src/MLAdapters/GeoJSONSource.d.ts +6 -0
- package/dist/src/MLAdapters/GeolocateControl.d.ts +6 -0
- package/dist/src/MLAdapters/ImageSource.d.ts +6 -0
- package/dist/src/MLAdapters/KeyboardHandler.d.ts +6 -0
- package/dist/src/MLAdapters/LogoControl.d.ts +6 -0
- package/dist/src/MLAdapters/MapMouseEvent.d.ts +6 -0
- package/dist/src/MLAdapters/MapTouchEvent.d.ts +6 -0
- package/dist/src/MLAdapters/MapWheelEvent.d.ts +6 -0
- package/dist/src/MLAdapters/Marker.d.ts +6 -0
- package/dist/src/MLAdapters/NavigationControl.d.ts +6 -0
- package/dist/src/MLAdapters/Popup.d.ts +6 -0
- package/dist/src/MLAdapters/RasterDEMTileSource.d.ts +6 -0
- package/dist/src/MLAdapters/RasterTileSource.d.ts +6 -0
- package/dist/src/MLAdapters/ScaleControl.d.ts +6 -0
- package/dist/src/MLAdapters/ScrollZoomHandler.d.ts +6 -0
- package/dist/src/MLAdapters/Style.d.ts +6 -0
- package/dist/src/MLAdapters/TerrainControl.d.ts +6 -0
- package/dist/src/MLAdapters/TwoFingersTouchPitchHandler.d.ts +6 -0
- package/dist/src/MLAdapters/VectorTileSource.d.ts +6 -0
- package/dist/src/MLAdapters/VideoSource.d.ts +6 -0
- package/dist/src/Map.d.ts +349 -0
- package/dist/src/MaptilerGeolocateControl.d.ts +21 -0
- package/dist/src/MaptilerLogoControl.d.ts +20 -0
- package/dist/src/MaptilerNavigationControl.d.ts +18 -0
- package/dist/src/MaptilerTerrainControl.d.ts +17 -0
- package/dist/src/Minimap.d.ts +58 -0
- package/dist/src/Point.d.ts +177 -0
- package/dist/src/caching.d.ts +5 -0
- package/dist/src/colorramp.d.ts +359 -0
- package/dist/src/config.d.ts +68 -0
- package/dist/src/converters/index.d.ts +1 -0
- package/dist/src/converters/xml.d.ts +54 -0
- package/dist/src/defaults.d.ts +14 -0
- package/dist/src/helpers/index.d.ts +14 -0
- package/dist/src/helpers/screenshot.d.ts +19 -0
- package/dist/src/helpers/stylehelper.d.ts +29 -0
- package/dist/src/helpers/vectorlayerhelpers.d.ts +509 -0
- package/dist/src/index.d.ts +89 -0
- package/dist/src/language.d.ts +108 -0
- package/dist/src/mapstyle.d.ts +3 -0
- package/dist/src/tools.d.ts +46 -0
- package/dist/src/unit.d.ts +1 -0
- package/package.json +15 -21
- package/readme.md +31 -0
- package/tsconfig.json +21 -8
- package/vite.config-es.ts +48 -0
- package/vite.config-umd.ts +27 -0
- package/.github/pull_request_template.md +0 -11
- package/.github/workflows/format-lint.yml +0 -21
- package/.github/workflows/npm-publish.yml +0 -22
- package/dist/maptiler-sdk.min.mjs +0 -3
- package/rollup.config.js +0 -147
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import C,{addProtocol as we}from"maplibre-gl";import{AJAXError as Wo,AttributionControl as Ko,BoxZoomHandler as Zo,CanvasSource as Yo,CooperativeGesturesHandler as qo,DoubleClickZoomHandler as Jo,DragPanHandler as Xo,DragRotateHandler as Qo,EdgeInsets as er,Evented as tr,FullscreenControl as or,GeoJSONSource as rr,GeolocateControl as ar,Hash as nr,ImageSource as ir,KeyboardHandler as lr,LngLat as sr,LngLatBounds as cr,LogoControl as ur,Map as pr,MapMouseEvent as hr,MapTouchEvent as mr,MapWheelEvent as dr,Marker as gr,MercatorCoordinate as yr,NavigationControl as vr,Point as fr,Popup as Lr,RasterDEMTileSource as Ar,RasterTileSource as wr,ScaleControl as Cr,ScrollZoomHandler as Sr,Style as br,TerrainControl as Tr,TwoFingersTouchPitchHandler as Ir,TwoFingersTouchRotateHandler as Er,TwoFingersTouchZoomHandler as Rr,TwoFingersTouchZoomRotateHandler as xr,VectorTileSource as Nr,VideoSource as _r,addProtocol as Mr,addSourceType as Pr,clearPrewarmedResources as Or,config as kr,getVersion as Fr,getMaxParallelImageRequests as zr,getRTLTextPluginStatus as Br,getWorkerCount as Ur,getWorkerUrl as Gr,importScriptInWorkers as Hr,prewarm as Dr,removeProtocol as $r,setMaxParallelImageRequests as jr,setRTLTextPlugin as Vr,setWorkerCount as Wr,setWorkerUrl as Kr}from"maplibre-gl";import dt from"events";import{config as re,expandMapStyle as gt,MapStyleVariant as yt,ReferenceMapStyle as vt,MapStyle as ft,mapStylePresetList as Lt,geolocation as Ce}from"@maptiler/client";import{LanguageGeocoding as Yr,MapStyle as qr,MapStyleVariant as Jr,ReferenceMapStyle as Xr,ServiceError as Qr,bufferToPixelDataBrowser as ea,circumferenceAtLatitude as ta,coordinates as oa,data as ra,elevation as aa,expandMapStyle as na,geocoding as ia,geolocation as la,getAutoLanguageGeocoding as sa,getBufferToPixelDataParser as ca,getTileCache as ua,mapStylePresetList as pa,math as ha,misc as ma,staticMaps as da,styleToStyle as ga}from"@maptiler/client";import{v4 as At}from"uuid";import{Base64 as wt}from"js-base64";var Ct="@maptiler/sdk",St="2.2.1",bt="The Javascript & TypeScript map SDK tailored for MapTiler Cloud",Tt="dist/maptiler-sdk.mjs",It="dist/maptiler-sdk.d.ts",Et="dist/maptiler-sdk.css",Rt="module",xt={".":{import:"./dist/maptiler-sdk.mjs",types:"./dist/maptiler-sdk.d.ts"},"./dist/maptiler-sdk.css":{import:"./dist/maptiler-sdk.css"},"./style.css":{import:"./dist/maptiler-sdk.css"}},Nt=["maptiler","map","sdk","webmap","cloud","webGL","maplibre"],_t="https://docs.maptiler.com/sdk-js/",Mt="BSD-3-Clause",Pt={type:"git",url:"https://github.com/maptiler/maptiler-sdk-js.git"},Ot={build:"rm -rf dist/* && NODE_ENV=production rollup -c",dev:"rm -rf dist/* && NODE_ENV=development rollup -c -w",biome:"biome check --max-diagnostics=1000","biome:fix":"npx @biomejs/biome check --max-diagnostics=1000 --write",doc:"rm -rf docs/* && typedoc --out docs && cp -r images docs/",prepare:"npm run biome:fix && npm run build && npm run test","test:dev":"vitest dev",test:"vitest run"},kt="MapTiler",Ft={"@biomejs/biome":"1.8.3","@rollup/plugin-commonjs":"^26.0.1","@rollup/plugin-json":"^6.1.0","@rollup/plugin-node-resolve":"^15.2.3","@types/uuid":"^9.0.2","@types/xmldom":"^0.1.31",rollup:"^4.18.0","rollup-plugin-copy-merge":"^1.0.2","rollup-plugin-dts":"^6.1.1","rollup-plugin-esbuild":"^6.1.1","rollup-plugin-node-globals":"^1.4.0","rollup-plugin-shell":"^1.0.9","rollup-plugin-string":"^3.0.0","rollup-plugin-swc":"^0.2.1",serve:"^14.2.0",terser:"^5.17.1",typedoc:"^0.24.8",typescript:"^5.1.6",vitest:"^0.34.2",xmldom:"^0.6.0"},zt={"@maptiler/client":"^1.8.1",events:"^3.3.0","js-base64":"^3.7.4","maplibre-gl":"4.4.1",uuid:"^9.0.0"},Bt={name:Ct,version:St,description:bt,module:Tt,types:It,style:Et,type:Rt,exports:xt,keywords:Nt,homepage:_t,license:Mt,repository:Pt,scripts:Ot,author:kt,devDependencies:Ft,dependencies:zt};const A={VISITOR:"visitor",VISITOR_ENGLISH:"visitor_en",STYLE:"style",AUTO:"auto",STYLE_LOCK:"style_lock",LATIN:"name:latin",NON_LATIN:"name:nonlatin",LOCAL:"name",INTERNATIONAL:"name_int",ALBANIAN:"name:sq",AMHARIC:"name:am",ARABIC:"name:ar",ARMENIAN:"name:hy",AZERBAIJANI:"name:az",BASQUE:"name:eu",BELORUSSIAN:"name:be",BENGALI:"name:bn",BOSNIAN:"name:bs",BRETON:"name:br",BULGARIAN:"name:bg",CATALAN:"name:ca",CHINESE:"name:zh",TRADITIONAL_CHINESE:"name:zh-Hant",SIMPLIFIED_CHINESE:"name:zh-Hans",CORSICAN:"name:co",CROATIAN:"name:hr",CZECH:"name:cs",DANISH:"name:da",DUTCH:"name:nl",ENGLISH:"name:en",ESPERANTO:"name:eo",ESTONIAN:"name:et",FINNISH:"name:fi",FRENCH:"name:fr",FRISIAN:"name:fy",GEORGIAN:"name:ka",GERMAN:"name:de",GREEK:"name:el",HEBREW:"name:he",HINDI:"name:hi",HUNGARIAN:"name:hu",ICELANDIC:"name:is",INDONESIAN:"name:id",IRISH:"name:ga",ITALIAN:"name:it",JAPANESE:"name:ja",JAPANESE_HIRAGANA:"name:ja-Hira",JAPANESE_KANA:"name:ja_kana",JAPANESE_LATIN:"name:ja_rm",JAPANESE_2018:"name:ja-Latn",KANNADA:"name:kn",KAZAKH:"name:kk",KOREAN:"name:ko",KOREAN_LATIN:"name:ko-Latn",KURDISH:"name:ku",ROMAN_LATIN:"name:la",LATVIAN:"name:lv",LITHUANIAN:"name:lt",LUXEMBOURGISH:"name:lb",MACEDONIAN:"name:mk",MALAYALAM:"name:ml",MALTESE:"name:mt",NORWEGIAN:"name:no",OCCITAN:"name:oc",PERSIAN:"name:fa",POLISH:"name:pl",PORTUGUESE:"name:pt",PUNJABI:"name:pa",WESTERN_PUNJABI:"name:pnb",ROMANIAN:"name:ro",ROMANSH:"name:rm",RUSSIAN:"name:ru",SCOTTISH_GAELIC:"name:gd",SERBIAN_CYRILLIC:"name:sr",SERBIAN_LATIN:"name:sr-Latn",SLOVAK:"name:sk",SLOVENE:"name:sl",SPANISH:"name:es",SWEDISH:"name:sv",TAMIL:"name:ta",TELUGU:"name:te",THAI:"name:th",TURKISH:"name:tr",UKRAINIAN:"name:uk",URDU:"name:ur",VIETNAMIAN_LATIN:"name:vi",WELSH:"name:cy"},Ut=new Set(Object.values(A));function ae(o){return Ut.has(o)}const Gt=new Set(Object.values(A));function ne(){if(typeof navigator>"u")return`name:${Intl.DateTimeFormat().resolvedOptions().locale.split("-")[0]}`;const o=Array.from(new Set(navigator.languages.map(e=>`name:${e.split("-")[0]}`))).filter(e=>Gt.has(e));return o.length?o[0]:A.LOCAL}const M={maptilerLogoURL:"https://api.maptiler.com/resources/logo.svg",maptilerURL:"https://www.maptiler.com/",maptilerApiHost:"api.maptiler.com",rtlPluginURL:"https://cdn.maptiler.com/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.min.js",primaryLanguage:A.STYLE,secondaryLanguage:A.LOCAL,terrainSourceURL:"https://api.maptiler.com/tiles/terrain-rgb-v2/tiles.json",terrainSourceId:"maptiler-terrain"};Object.freeze(M);const Se=At();class be extends dt{constructor(){super(...arguments),this.primaryLanguage=M.primaryLanguage,this.session=!0,this.caching=!0,this._unit="metric",this._apiKey=""}set unit(e){this._unit=e,this.emit("unit",e)}get unit(){return this._unit}set apiKey(e){this._apiKey=e,re.apiKey=e,this.emit("apiKey",e)}get apiKey(){return this._apiKey}set fetch(e){re.fetch=e}get fetch(){return re.fetch}}const R=new be,ie="localcache_source",le="localcache",Ht="maptiler_sdk",Dt=1e3,$t=100,se=typeof caches<"u";function jt(o,e){if(se&&R.caching&&R.session&&o.host===M.maptilerApiHost){if(e==="Source"&&o.href.includes("tiles.json"))return o.href.replace("https://",`${ie}://`);if(e==="Tile"||e==="Glyphs")return o.href.replace("https://",`${le}://`)}return o.href}let ce;async function Te(){return ce||(ce=await caches.open(Ht)),ce}let Ie=0;async function Vt(){const o=await Te(),e=await o.keys(),t=e.slice(0,Math.max(e.length-Dt,0));for(const r of t)o.delete(r)}function Wt(){we(ie,async(o,e)=>{if(!o.url)throw new Error("");o.url=o.url.replace(`${ie}://`,"https://");const t=o;t.signal=e.signal;const r=await fetch(o.url,t),a=await r.json();return a.tiles&&a.tiles.length>0&&(a.tiles[0]+=`&last-modified=${r.headers.get("Last-Modified")}`),{data:a,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires")}}),we(le,async(o,e)=>{if(!o.url)throw new Error("");o.url=o.url.replace(`${le}://`,"https://");const t=new URL(o.url),r=new URL(t);r.searchParams.delete("mtsid"),r.searchParams.delete("key");const a=r.toString(),n=new URL(t);n.searchParams.delete("last-modified");const i=n.toString(),l=async d=>({data:await d.arrayBuffer(),cacheControl:d.headers.get("Cache-Control"),expires:d.headers.get("Expires")}),u=await Te(),s=await u.match(a);if(s)return l(s);const c=o;c.signal=e.signal;const p=await fetch(i,c);return p.status>=200&&p.status<300&&(u.put(a,p.clone()).catch(()=>{}),++Ie>$t&&(Vt(),Ie=0)),l(p)})}function Kt(){if(typeof window>"u")return;const o=C.getRTLTextPluginStatus();if(o==="unavailable"||o==="requested")try{C.setRTLTextPlugin(M.rtlPluginURL,!0)}catch{}}function Zt(o,e){for(const t of o)typeof e[t]=="function"&&(e[t]=e[t].bind(e))}function U(o,e,t){const r=window.document.createElement(o);return e!==void 0&&(r.className=e),t&&t.appendChild(r),r}function Ee(o){o.parentNode&&o.parentNode.removeChild(o)}function Re(o,e){let t=null;try{t=new URL(o)}catch{return{url:o}}return t.host===M.maptilerApiHost&&(t.searchParams.has("key")||t.searchParams.append("key",R.apiKey),R.session&&t.searchParams.append("mtsid",Se)),{url:jt(t,e)}}function xe(o){return(e,t)=>{if(o!=null){const r=o(e,t),a=Re(r?.url??"",t);return{...r,...a}}return Re(e,t)}}function Ne(){return Math.random().toString(36).substring(2)}function q(o){return/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(o)}function Yt(o){try{return JSON.parse(o)}catch{}return null}function qt(){return document.createElement("canvas").getContext("webgl2")?null:typeof WebGL2RenderingContext<"u"?"Graphic rendering with WebGL2 has been disabled or is not supported by your graphic card. The map cannot be displayed.":"Your browser does not support graphic rendering with WebGL2. The map cannot be displayed."}function Jt(o){const e=qt();if(!e)return;let t=null;if(typeof o=="string"?t=document.getElementById(o):o instanceof HTMLElement&&(t=o),!t)throw new Error("The Map container must be provided.");const r=document.createElement("div");throw r.innerHTML=e,r.classList.add("no-webgl-support-div"),t.appendChild(r),new Error(e)}class Xt extends C.Marker{addTo(e){return super.addTo(e)}}class Qt extends C.Popup{addTo(e){return super.addTo(e)}}class eo extends C.Style{constructor(e,t={}){super(e,t)}}class to extends C.CanvasSource{onAdd(e){super.onAdd(e)}}class oo extends C.GeoJSONSource{onAdd(e){super.onAdd(e)}}class ro extends C.ImageSource{onAdd(e){super.onAdd(e)}}class ao extends C.RasterTileSource{onAdd(e){super.onAdd(e)}}class no extends C.RasterDEMTileSource{onAdd(e){super.onAdd(e)}}class io extends C.VectorTileSource{onAdd(e){super.onAdd(e)}}class lo extends C.VideoSource{onAdd(e){super.onAdd(e)}}class _e extends C.NavigationControl{onAdd(e){return super.onAdd(e)}}class Me extends C.GeolocateControl{onAdd(e){return super.onAdd(e)}}class so extends C.AttributionControl{onAdd(e){return super.onAdd(e)}}class Pe extends C.LogoControl{onAdd(e){return super.onAdd(e)}}class Oe extends C.ScaleControl{onAdd(e){return super.onAdd(e)}}class ke extends C.FullscreenControl{onAdd(e){return super.onAdd(e)}}class co extends C.TerrainControl{onAdd(e){return super.onAdd(e)}}class uo extends C.BoxZoomHandler{constructor(e,t){super(e,t)}}class po extends C.ScrollZoomHandler{constructor(e,t){super(e,t)}}class ho extends C.CooperativeGesturesHandler{constructor(e,t){super(e,t)}}class mo extends C.KeyboardHandler{constructor(e){super(e)}}class go extends C.TwoFingersTouchPitchHandler{constructor(e){super(e)}}class yo extends C.MapWheelEvent{constructor(e,t,r){super(e,t,r)}}class vo extends C.MapTouchEvent{constructor(e,t,r){super(e,t,r)}}class fo extends C.MapMouseEvent{constructor(e,t,r,a={}){super(e,t,r,a)}}class ue extends Pe{constructor(e={}){super(e),this.logoURL="",this.linkURL="",this.logoURL=e.logoURL??M.maptilerLogoURL,this.linkURL=e.linkURL??M.maptilerURL}onAdd(e){this._map=e,this._compact=this.options.compact??!1,this._container=window.document.createElement("div"),this._container.className="maplibregl-ctrl";const t=window.document.createElement("a");return t.style.backgroundRepeat="no-repeat",t.style.cursor="pointer",t.style.display="block",t.style.height="23px",t.style.margin="0 0 -4px -4px",t.style.overflow="hidden",t.style.width="88px",t.style.backgroundImage=`url(${this.logoURL})`,t.style.backgroundSize="100px 30px",t.style.width="100px",t.style.height="30px",t.target="_blank",t.rel="noopener",t.href=this.linkURL,t.setAttribute("aria-label","MapTiler logo"),t.setAttribute("rel","noopener"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}}function Fe(o){return o?typeof o=="string"||o instanceof String?!o.startsWith("http")&&o.toLowerCase().includes(".json")?o:gt(o):o instanceof yt?o.getExpandedStyleURL():o instanceof vt?o.getDefaultVariant().getExpandedStyleURL():o:ft[Lt[0].referenceStyleID].getDefaultVariant().getExpandedStyleURL()}class ze{constructor(){Zt(["_toggleTerrain","_updateTerrainIcon"],this)}onAdd(e){return this._map=e,this._container=U("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=U("button","maplibregl-ctrl-terrain",this._container),U("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){Ee(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}_toggleTerrain(){this._map.hasTerrain()?this._map.disableTerrain():this._map.enableTerrain(),this._updateTerrainIcon()}_updateTerrainIcon(){this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.hasTerrain()?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))}}class Be extends _e{constructor(){super({showCompass:!0,showZoom:!0,visualizePitch:!0}),this._rotateCompassArrow=()=>{const e=this.options.visualizePitch?`scale(${Math.min(1.5,1/Math.cos(this._map.transform.pitch*(Math.PI/180))**.5)}) rotateX(${Math.min(70,this._map.transform.pitch)}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=e},this._compass.removeEventListener("click",this._compass.clickFunction),this._compass.addEventListener("click",e=>{this._map.getPitch()===0?this._map.easeTo({pitch:Math.min(this._map.getMaxPitch(),80)}):this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})})}_createButton(e,t){const r=super._createButton(e,t);return r.clickFunction=t,r}}const Ue=C.Marker,Ge=C.LngLat,Lo=C.LngLatBounds;class He extends Me{constructor(){super(...arguments),this.lastUpdatedCenter=new Ge(0,0),this._updateCamera=e=>{const t=new Ge(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,a={bearing:this._map.getBearing(),...this.options.fitBoundsOptions,linear:!0},n=this._map.getZoom();n>(this.options?.fitBoundsOptions?.maxZoom??30)&&(a.zoom=n),this._map.fitBounds(Lo.fromLngLat(t,r),a,{geolocateSource:!0});let i=!1;const l=()=>{i=!0};this._map.once("click",l),this._map.once("dblclick",l),this._map.once("dragstart",l),this._map.once("mousedown",l),this._map.once("touchstart",l),this._map.once("wheel",l),this._map.once("moveend",()=>{this._map.off("click",l),this._map.off("dblclick",l),this._map.off("dragstart",l),this._map.off("mousedown",l),this._map.off("touchstart",l),this._map.off("wheel",l),!i&&(this.lastUpdatedCenter=this._map.getCenter())})},this._setupUI=e=>{if(this.lastUpdatedCenter=this._map.getCenter(),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=U("button","maplibregl-ctrl-geolocate",this._container),U("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",e===!1){const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=U("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ue({element:this._dotElement}),this._circleElement=U("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ue({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("move",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("moveend",t=>{const r=t.originalEvent&&t.originalEvent.type==="resize",a=this.lastUpdatedCenter.distanceTo(this._map.getCenter());!t.geolocateSource&&this._watchState==="ACTIVE_LOCK"&&!r&&a>1&&(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new Event("trackuserlocationend")))})},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}}_updateCircleRadius(){if(this._watchState!=="BACKGROUND"&&this._watchState!=="ACTIVE_LOCK")return;const e=[this._lastKnownPosition.coords.longitude,this._lastKnownPosition.coords.latitude],t=this._map.project(e),r=this._map.unproject([t.x,t.y]),a=this._map.unproject([t.x+20,t.y]),n=r.distanceTo(a)/20,i=Math.ceil(2*this._accuracy/n);this._circleElement.style.width=`${i}px`,this._circleElement.style.height=`${i}px`}}var De=o=>{throw TypeError(o)},pe=(o,e,t)=>e.has(o)||De("Cannot "+t),f=(o,e,t)=>(pe(o,e,"read from private field"),t?t.call(o):e.get(o)),G=(o,e,t)=>e.has(o)?De("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,t),W=(o,e,t,r)=>(pe(o,e,"write to private field"),e.set(o,t),t),P=(o,e,t)=>(pe(o,e,"access private method"),t),O,B,D,$e,$,k,J,_,je,F,Ve;class he{constructor(e,t){G(this,_),G(this,O),G(this,B),G(this,D),G(this,$e),G(this,$),G(this,k,!1),G(this,J),e.style!==void 0&&W(this,k,!0),W(this,O,{zoomAdjust:-4,position:"top-right",...t,forceNoAttributionControl:!0,attributionControl:!1,navigationControl:!1,geolocateControl:!1,maptilerLogo:!1,minimap:!1,hash:!1,pitchAdjust:!1,...e,containerStyle:{border:"1px solid #000",width:"400px",height:"300px",...e.containerStyle??{}}}),e.lockZoom!==void 0&&(f(this,O).minZoom=e.lockZoom,f(this,O).maxZoom=e.lockZoom)}setStyle(e,t){f(this,k)||this.map.setStyle(e,t),P(this,_,F).call(this)}addLayer(e,t){return f(this,k)||this.map.addLayer(e,t),P(this,_,F).call(this),this.map}moveLayer(e,t){return f(this,k)||this.map.moveLayer(e,t),P(this,_,F).call(this),this.map}removeLayer(e){return f(this,k)||this.map.removeLayer(e),P(this,_,F).call(this),this}setLayerZoomRange(e,t,r){return f(this,k)||this.map.setLayerZoomRange(e,t,r),P(this,_,F).call(this),this}setFilter(e,t,r){return f(this,k)||this.map.setFilter(e,t,r),P(this,_,F).call(this),this}setPaintProperty(e,t,r,a){return f(this,k)||this.map.setPaintProperty(e,t,r,a),P(this,_,F).call(this),this}setLayoutProperty(e,t,r,a){return f(this,k)||this.map.setLayoutProperty(e,t,r,a),P(this,_,F).call(this),this}setGlyphs(e,t){return f(this,k)||this.map.setGlyphs(e,t),P(this,_,F).call(this),this}onAdd(e){W(this,B,e),W(this,D,U("div","maplibregl-ctrl maplibregl-ctrl-group"));for(const[t,r]of Object.entries(f(this,O).containerStyle))f(this,D).style.setProperty(t,r);return f(this,O).container=f(this,D),f(this,O).zoom=e.getZoom()+f(this,O).zoomAdjust,this.map=new Ke(f(this,O)),this.map.once("style.load",()=>{this.map.resize()}),this.map.once("load",()=>{P(this,_,je).call(this,f(this,O).parentRect),W(this,J,P(this,_,Ve).call(this))}),f(this,D)}onRemove(){var e;(e=f(this,J))==null||e.call(this),Ee(f(this,D))}}O=new WeakMap,B=new WeakMap,D=new WeakMap,$e=new WeakMap,$=new WeakMap,k=new WeakMap,J=new WeakMap,_=new WeakSet,je=function(o){o===void 0||o.linePaint===void 0&&o.fillPaint===void 0||(W(this,$,{type:"Feature",properties:{name:"parentRect"},geometry:{type:"Polygon",coordinates:[[[],[],[],[],[]]]}}),this.map.addSource("parentRect",{type:"geojson",data:f(this,$)}),(o.lineLayout!==void 0||o.linePaint!==void 0)&&this.map.addLayer({id:"parentRectOutline",type:"line",source:"parentRect",layout:{...o.lineLayout},paint:{"line-color":"#FFF","line-width":1,"line-opacity":.85,...o.linePaint}}),o.fillPaint!==void 0&&this.map.addLayer({id:"parentRectFill",type:"fill",source:"parentRect",layout:{},paint:{"fill-color":"#08F","fill-opacity":.135,...o.fillPaint}}),P(this,_,F).call(this))},F=function(){if(f(this,$)===void 0)return;const{devicePixelRatio:o}=window,e=f(this,B).getCanvas(),t=e.width/o,r=e.height/o,a=f(this,B).unproject.bind(f(this,B)),n=a([0,0]),i=a([t,0]),l=a([0,r]),u=a([t,r]);f(this,$).geometry.coordinates=[[l.toArray(),u.toArray(),i.toArray(),n.toArray(),l.toArray()]],this.map.getSource("parentRect").setData(f(this,$))},Ve=function(){const{pitchAdjust:o}=f(this,O),e=()=>{n("parent")},t=()=>{n("minimap")},r=()=>{f(this,B).on("move",e),this.map.on("move",t)},a=()=>{f(this,B).off("move",e),this.map.off("move",t)},n=i=>{a();const l=i==="parent"?f(this,B):this.map,u=i==="parent"?this.map:f(this,B),s=l.getCenter(),c=l.getZoom()+(f(this,O).zoomAdjust??-4)*(i==="parent"?1:-1),p=l.getBearing(),d=l.getPitch();u.jumpTo({center:s,zoom:c,bearing:p,pitch:o?d:0}),P(this,_,F).call(this),r()};return r(),()=>{a()}};const We={POINT:"POINT",COUNTRY:"COUNTRY"};class Ke extends C.Map{constructor(e){Jt(e.container),e.apiKey&&(R.apiKey=e.apiKey);const t=Fe(e.style),r=location.hash;R.apiKey||console.warn("MapTiler Cloud API key is not set. Visit https://maptiler.com and try Cloud for free!");let a={compact:!1};e.customAttribution?a.customAttribution=e.customAttribution:e.attributionControl&&typeof e.attributionControl=="object"&&(a={...a,...e.attributionControl}),super({...e,style:t,maplibreLogo:!1,transformRequest:xe(e.transformRequest),attributionControl:e.forceNoAttributionControl===!0?!1:a}),this.isTerrainEnabled=!1,this.terrainExaggeration=1,this.terrainGrowing=!1,this.terrainFlattening=!1,this.isReady=!1,R.caching&&!se&&console.warn("The cache API is only available in secure contexts. More info at https://developer.mozilla.org/en-US/docs/Web/API/Cache"),R.caching&&se&&Wt(),this.primaryLanguage=e.language??R.primaryLanguage,this.forceLanguageUpdate=!(this.primaryLanguage===A.STYLE||this.primaryLanguage===A.STYLE_LOCK),this.languageAlwaysBeenStyle=this.primaryLanguage===A.STYLE,this.terrainExaggeration=e.terrainExaggeration??this.terrainExaggeration,this.once("styledata",async()=>{if(!e.geolocate||e.center||e.hash&&r)return;try{if(e.geolocate===We.COUNTRY){await this.fitToIpBounds();return}}catch(c){console.warn(c.message)}let s;try{await this.centerOnIpPoint(e.zoom),s=this.getCameraHash()}catch(c){console.warn(c.message)}(await navigator.permissions.query({name:"geolocation"})).state==="granted"&&navigator.geolocation.getCurrentPosition(c=>{s===this.getCameraHash()&&(this.terrain?this.easeTo({center:[c.coords.longitude,c.coords.latitude],zoom:e.zoom||12,duration:2e3}):this.once("terrain",()=>{this.easeTo({center:[c.coords.longitude,c.coords.latitude],zoom:e.zoom||12,duration:2e3})}))},null,{maximumAge:24*3600*1e3,timeout:5e3,enableHighAccuracy:!1})}),this.on("styledata",()=>{this.setPrimaryLanguage(this.primaryLanguage)}),this.on("styledata",()=>{this.getTerrain()===null&&this.isTerrainEnabled&&this.enableTerrain(this.terrainExaggeration)}),this.once("load",async()=>{let s={logo:null};try{const c=Object.keys(this.style.sourceCaches).map(d=>this.getSource(d)).filter(d=>d&&"url"in d&&typeof d.url=="string"&&d?.url.includes("tiles.json")),p=new URL(c[0].url);p.searchParams.has("key")||p.searchParams.append("key",R.apiKey),s=await(await fetch(p.href)).json()}catch{}if(e.forceNoAttributionControl!==!0)if("logo"in s&&s.logo){const c=s.logo;this.addControl(new ue({logoURL:c}),e.logoPosition)}else e.maptilerLogo&&this.addControl(new ue,e.logoPosition);if(e.scaleControl){const c=e.scaleControl===!0||e.scaleControl===void 0?"bottom-right":e.scaleControl,p=new Oe({unit:R.unit});this.addControl(p,c),R.on("unit",d=>{p.setUnit(d)})}if(e.navigationControl!==!1){const c=e.navigationControl===!0||e.navigationControl===void 0?"top-right":e.navigationControl;this.addControl(new Be,c)}if(e.geolocateControl!==!1){const c=e.geolocateControl===!0||e.geolocateControl===void 0?"top-right":e.geolocateControl;this.addControl(new He({positionOptions:{enableHighAccuracy:!0,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!0,showAccuracyCircle:!0,showUserLocation:!0}),c)}if(e.terrainControl){const c=e.terrainControl===!0||e.terrainControl===void 0?"top-right":e.terrainControl;this.addControl(new ze,c)}if(e.fullscreenControl){const c=e.fullscreenControl===!0||e.fullscreenControl===void 0?"top-right":e.fullscreenControl;this.addControl(new ke({}),c)}this.isReady=!0,this.fire("ready",{target:this})});let n=!1,i=!1,l;this.once("ready",()=>{n=!0,i&&this.fire("loadWithTerrain",l)}),this.once("style.load",()=>{const{minimap:s}=e;if(typeof s=="object"){const{zoom:c,center:p,style:d,language:y,apiKey:v,maptilerLogo:g,antialias:w,refreshExpiredTiles:N,maxBounds:L,scrollZoom:I,minZoom:E,maxZoom:T,boxZoom:z,locale:H,fadeDuration:K,crossSourceCollisions:Z,clickTolerance:Y,bounds:ut,fitBoundsOptions:pt,pixelRatio:ht,validateStyle:mt}=e;this.minimap=new he(s,{zoom:c,center:p,style:d,language:y,apiKey:v,container:"null",maptilerLogo:g,antialias:w,refreshExpiredTiles:N,maxBounds:L,scrollZoom:I,minZoom:E,maxZoom:T,boxZoom:z,locale:H,fadeDuration:K,crossSourceCollisions:Z,clickTolerance:Y,bounds:ut,fitBoundsOptions:pt,pixelRatio:ht,validateStyle:mt}),this.addControl(this.minimap,s.position??"bottom-left")}else s===!0?(this.minimap=new he({},e),this.addControl(this.minimap,"bottom-left")):s!==void 0&&s!==!1&&(this.minimap=new he({},e),this.addControl(this.minimap,s))});const u=s=>{s.terrain&&(i=!0,l={type:"loadWithTerrain",target:this,terrain:s.terrain},this.off("terrain",u),n&&this.fire("loadWithTerrain",l))};this.on("terrain",u),e.terrain&&this.enableTerrain(e.terrainExaggeration??this.terrainExaggeration)}async onLoadAsync(){return new Promise(e=>{if(this.loaded())return e(this);this.once("load",()=>{e(this)})})}async onReadyAsync(){return new Promise(e=>{if(this.isReady)return e(this);this.once("ready",()=>{e(this)})})}async onLoadWithTerrainAsync(){return new Promise(e=>{if(this.isReady&&this.terrain)return e(this);this.once("loadWithTerrain",()=>{e(this)})})}setStyle(e,t){return this.minimap?.setStyle(e),this.forceLanguageUpdate=!0,this.once("idle",()=>{this.forceLanguageUpdate=!1}),super.setStyle(Fe(e),t)}addLayer(e,t){return this.minimap?.addLayer(e,t),super.addLayer(e,t)}moveLayer(e,t){return this.minimap?.moveLayer(e,t),super.moveLayer(e,t)}removeLayer(e){return this.minimap?.removeLayer(e),super.removeLayer(e)}setLayerZoomRange(e,t,r){return this.minimap?.setLayerZoomRange(e,t,r),super.setLayerZoomRange(e,t,r)}setFilter(e,t,r){return this.minimap?.setFilter(e,t,r),super.setFilter(e,t,r)}setPaintProperty(e,t,r,a){return this.minimap?.setPaintProperty(e,t,r,a),super.setPaintProperty(e,t,r,a)}setLayoutProperty(e,t,r,a){return this.minimap?.setLayoutProperty(e,t,r,a),super.setLayoutProperty(e,t,r,a)}setGlyphs(e,t){return this.minimap?.setGlyphs(e,t),super.setGlyphs(e,t)}getStyleLanguage(){return!this.style.stylesheet.metadata||typeof this.style.stylesheet.metadata!="object"?null:"maptiler:language"in this.style.stylesheet.metadata&&typeof this.style.stylesheet.metadata["maptiler:language"]=="string"?this.style.stylesheet.metadata["maptiler:language"]:null}setLanguage(e){this.minimap?.map?.setLanguage(e),this.onStyleReady(()=>{this.setPrimaryLanguage(e)})}setPrimaryLanguage(e){const t=this.getStyleLanguage();if(!(e===A.STYLE&&(t===A.AUTO||t===A.VISITOR))&&(e!==A.STYLE&&(this.languageAlwaysBeenStyle=!1),this.languageAlwaysBeenStyle||this.primaryLanguage===e&&!this.forceLanguageUpdate))return;if(!ae(e)){console.warn(`The language "${e}" is not supported.`);return}if(this.primaryLanguage===A.STYLE_LOCK){console.warn("The language cannot be changed because this map has been instantiated with the STYLE_LOCK language flag.");return}this.primaryLanguage=e;let r=e;if(e===A.STYLE){if(!t){console.warn("The style has no default languages.");return}if(!ae(t)){console.warn("The language defined in the style is not valid.");return}r=t}let a=A.LOCAL,n=`{${a}}`;r===A.VISITOR?(a=ne(),n=["case",["all",["has",a],["has",A.LOCAL]],["case",["==",["get",a],["get",A.LOCAL]],["get",A.LOCAL],["format",["get",a],{"font-scale":.8},`
|
|
2
|
-
`,["get",A.LOCAL],{"font-scale":1.1}]],["get",A.LOCAL]]):r===A.VISITOR_ENGLISH?(a=A.ENGLISH,n=["case",["all",["has",a],["has",A.LOCAL]],["case",["==",["get",a],["get",A.LOCAL]],["get",A.LOCAL],["format",["get",a],{"font-scale":.8},`
|
|
3
|
-
`,["get",A.LOCAL],{"font-scale":1.1}]],["get",A.LOCAL]]):r===A.AUTO?(a=ne(),n=["case",["has",a],["get",a],["get",A.LOCAL]]):r===A.LOCAL?(a=A.LOCAL,n=`{${a}}`):(a=r,n=["case",["has",a],["get",a],["get",A.LOCAL]]);const{layers:i}=this.getStyle();for(const l of i){if(l.type!=="symbol")continue;const u=l,s=this.getSource(u.source);if(!s||!("url"in s&&typeof s.url=="string")||new URL(s.url).host!==M.maptilerApiHost)continue;const{id:c,layout:p}=u;if(!p||!("text-field"in p))continue;const d=this.getLayoutProperty(c,"text-field");typeof d=="string"&&(d.toLowerCase().includes("ref")||d.toLowerCase().includes("housenumber"))||this.setLayoutProperty(c,"text-field",n)}}getPrimaryLanguage(){return this.primaryLanguage}getTerrainExaggeration(){return this.terrainExaggeration}hasTerrain(){return this.isTerrainEnabled}growTerrain(e,t=1e3){if(!this.terrain)return;const r=performance.now(),a=this.terrain.exaggeration,n=e-a,i=()=>{if(!this.terrain||this.terrainFlattening)return;const l=(performance.now()-r)/t;if(l<.99){const u=1-(1-l)**4,s=a+u*n;this.terrain.exaggeration=s,requestAnimationFrame(i)}else this.terrainGrowing=!1,this.terrainFlattening=!1,this.terrain.exaggeration=e;this.triggerRepaint()};this.terrainGrowing=!0,this.terrainFlattening=!1,requestAnimationFrame(i)}enableTerrain(e=this.terrainExaggeration){if(e<0){console.warn("Terrain exaggeration cannot be negative.");return}const t=async a=>{!this.terrain||a.type!=="data"||a.dataType!=="source"||!("source"in a)||a.sourceId!=="maptiler-terrain"||a.source.type!=="raster-dem"||a.isSourceLoaded&&(this.off("data",t),this.growTerrain(e))},r=()=>{this.isTerrainEnabled=!0,this.terrainExaggeration=e,this.on("data",t),this.addSource(M.terrainSourceId,{type:"raster-dem",url:M.terrainSourceURL}),this.setTerrain({source:M.terrainSourceId,exaggeration:0})};if(this.getTerrain()){this.isTerrainEnabled=!0,this.growTerrain(e);return}this.loaded()||this.isTerrainEnabled?r():this.once("load",()=>{this.getTerrain()&&this.getSource(M.terrainSourceId)||r()})}disableTerrain(){if(!this.terrain)return;this.isTerrainEnabled=!1;const e=1*1e3,t=performance.now(),r=this.terrain.exaggeration,a=()=>{if(!this.terrain||this.terrainGrowing)return;const n=(performance.now()-t)/e;if(n<.99){const i=(1-n)**4,l=r*i;this.terrain.exaggeration=l,requestAnimationFrame(a)}else this.terrain.exaggeration=0,this.terrainGrowing=!1,this.terrainFlattening=!1,this.setTerrain(),this.getSource(M.terrainSourceId)&&this.removeSource(M.terrainSourceId);this.triggerRepaint()};this.terrainGrowing=!1,this.terrainFlattening=!0,requestAnimationFrame(a)}setTerrainExaggeration(e,t=!0){!t&&this.terrain?(this.terrainExaggeration=e,this.terrain.exaggeration=e,this.triggerRepaint()):this.enableTerrain(e)}onStyleReady(e){this.isStyleLoaded()?e():this.once("styledata",()=>{e()})}async fitToIpBounds(){const e=await Ce.info();this.fitBounds(e.country_bounds,{duration:0,padding:100})}async centerOnIpPoint(e){const t=await Ce.info();this.jumpTo({center:[t?.longitude??0,t?.latitude??0],zoom:e||11})}getCameraHash(){const e=new Float32Array(5),t=this.getCenter();return e[0]=t.lng,e[1]=t.lat,e[2]=this.getZoom(),e[3]=this.getPitch(),e[4]=this.getBearing(),wt.fromUint8Array(new Uint8Array(e.buffer))}getSdkConfig(){return R}getMaptilerSessionId(){return Se}setTransformRequest(e){return super.setTransformRequest(xe(e)),this}}function X(o){if(typeof DOMParser<"u"){const e=new DOMParser().parseFromString(o,"application/xml");if(e.querySelector("parsererror"))throw new Error("The provided string is not valid XML");return e}throw new Error("No XML parser found")}function me(o,e){if(!o.hasChildNodes())return!1;for(const t of Array.from(o.childNodes)){const r=t.nodeName;if(typeof r=="string"&&r.trim().toLowerCase()===e.toLowerCase())return!0}return!1}function de(o){if(typeof XMLSerializer<"u")return new XMLSerializer().serializeToString(o);throw new Error("No XML serializer found")}function ge(o){const e=typeof o=="string"?X(o):o;if(!me(e,"gpx"))throw new Error("The XML document is not valid GPX");const t=x(e,"trk"),r=x(e,"rte"),a=x(e,"wpt"),n={type:"FeatureCollection",features:[]};for(const i of Array.from(t)){const l=So(i);l&&n.features.push(l)}for(const i of Array.from(r)){const l=bo(i);l&&n.features.push(l)}for(const i of Array.from(a))n.features.push(To(i));return n}function ye(o,e){let t=o;if(typeof t=="string"&&(t=X(t)),!me(t,"kml"))throw new Error("The XML document is not valid KML");const r={type:"FeatureCollection",features:[]},a={},n={},i={},l=x(t,"Placemark"),u=x(t,"Style"),s=x(t,"StyleMap");for(const c of Array.from(u)){const p=Je(e!==void 0?e(c):de(c)).toString(16);a[`#${j(c,"id")}`]=p,n[p]=c}for(const c of Array.from(s)){a[`#${j(c,"id")}`]=Je(e!==void 0?e(c):de(c)).toString(16);const p=x(c,"Pair"),d={};for(const y of Array.from(p))d[S(m(y,"key"))??""]=S(m(y,"styleUrl"));i[`#${j(c,"id")}`]=d}for(const c of Array.from(l))r.features=r.features.concat(Co(c,a,n,i));return r}function Ze(o){if(o===null)return["#000000",1];let e="",t=1,r=o;return r.substring(0,1)==="#"&&(r=r.substring(1)),(r.length===6||r.length===3)&&(e=r),r.length===8&&(t=Number.parseInt(r.substring(0,2),16)/255,e=`#${r.substring(6,8)}${r.substring(4,6)}${r.substring(2,4)}`),[e??"#000000",t??1]}function Ao(o){return Qe(o.split(" "))}function wo(o){let e=x(o,"coord");const t=[],r=[];e.length===0&&(e=x(o,"gx:coord"));for(const n of Array.from(e))t.push(Ao(S(n)??""));const a=x(o,"when");for(const n of Array.from(a))r.push(S(n));return{coords:t,times:r}}function Q(o){const e=["Polygon","LineString","Point","Track","gx:Track"];let t,r,a,n,i;const l=[],u=[];if(m(o,"MultiGeometry")!==null)return Q(m(o,"MultiGeometry"));if(m(o,"MultiTrack")!==null)return Q(m(o,"MultiTrack"));if(m(o,"gx:MultiTrack")!==null)return Q(m(o,"gx:MultiTrack"));for(a=0;a<e.length;a++)if(r=x(o,e[a]),r){for(n=0;n<r.length;n++)if(t=r[n],e[a]==="Point")l.push({type:"Point",coordinates:et(S(m(t,"coordinates"))??"")});else if(e[a]==="LineString")l.push({type:"LineString",coordinates:tt(S(m(t,"coordinates"))??"")});else if(e[a]==="Polygon"){const s=x(t,"LinearRing"),c=[];for(i=0;i<s.length;i++)c.push(tt(S(m(s[i],"coordinates"))??""));l.push({type:"Polygon",coordinates:c})}else if(e[a]==="Track"||e[a]==="gx:Track"){const s=wo(t);l.push({type:"LineString",coordinates:s.coords}),s.times.length&&u.push(s.times)}}return{geoms:l,coordTimes:u}}function Co(o,e,t,r){const a=Q(o),n={},i=S(m(o,"name")),l=S(m(o,"address")),u=S(m(o,"description")),s=m(o,"TimeSpan"),c=m(o,"TimeStamp"),p=m(o,"ExtendedData"),d=m(o,"visibility");let y,v=S(m(o,"styleUrl")),g=m(o,"LineStyle"),w=m(o,"PolyStyle");if(!a.geoms.length)return[];if(i&&(n.name=i),l&&(n.address=l),v){v[0]!=="#"&&(v=`#${v}`),n.styleUrl=v,e[v]&&(n.styleHash=e[v]),r[v]&&(n.styleMapHash=r[v],n.styleHash=e[r[v].normal??""]);const L=t[n.styleHash??""];if(L){g||(g=m(L,"LineStyle")),w||(w=m(L,"PolyStyle"));const I=m(L,"IconStyle");if(I){const E=m(I,"Icon");if(E){const T=S(m(E,"href"));T&&(n.icon=T)}}}}if(u&&(n.description=u),s){const L=S(m(s,"begin")),I=S(m(s,"end"));L&&I&&(n.timespan={begin:L,end:I})}if(c!==null&&(n.timestamp=S(m(c,"when"))??new Date().toISOString()),g!==null){const L=Ze(S(m(g,"color"))),I=L[0],E=L[1],T=Number.parseFloat(S(m(g,"width"))??"");I&&(n.stroke=I),Number.isNaN(E)||(n["stroke-opacity"]=E),Number.isNaN(T)||(n["stroke-width"]=T)}if(w){const L=Ze(S(m(w,"color"))),I=L[0],E=L[1],T=S(m(w,"fill")),z=S(m(w,"outline"));I&&(n.fill=I),Number.isNaN(E)||(n["fill-opacity"]=E),T&&(n["fill-opacity"]=T==="1"?n["fill-opacity"]||1:0),z&&(n["stroke-opacity"]=z==="1"?n["stroke-opacity"]||1:0)}if(p){const L=x(p,"Data"),I=x(p,"SimpleData");for(y=0;y<L.length;y++)n[L[y].getAttribute("name")??""]=S(m(L[y],"value"))??"";for(y=0;y<I.length;y++)n[I[y].getAttribute("name")??""]=S(I[y])??""}d!==null&&(n.visibility=S(d)??""),a.coordTimes.length!==0&&(n.coordTimes=a.coordTimes.length===1?a.coordTimes[0]:a.coordTimes);const N={type:"Feature",geometry:a.geoms.length===1?a.geoms[0]:{type:"GeometryCollection",geometries:a.geoms},properties:n};return j(o,"id")&&(N.id=j(o,"id")??void 0),[N]}function Ye(o,e){const t=x(o,e),r=[],a=[];let n=[];const i=t.length;if(!(i<2)){for(let l=0;l<i;l++){const u=ot(t[l]);r.push(u.coordinates),u.time&&a.push(u.time),(u.heartRate||n.length)&&(n.length===0&&(n=new Array(l).fill(null)),n.push(u.heartRate))}return{line:r,times:a,heartRates:n}}}function So(o){const e=x(o,"trkseg"),t=[],r=[],a=[];let n;for(let l=0;l<e.length;l++)if(n=Ye(e[l],"trkpt"),n!==void 0&&(n.line&&t.push(n.line),n.times&&n.times.length&&r.push(n.times),a.length||n.heartRates&&n.heartRates.length)){if(!a.length)for(let u=0;u<l;u++)a.push(new Array(t[u].length).fill(null));n.heartRates&&n.heartRates.length?a.push(n.heartRates):a.push(new Array(n.line.length).fill(null))}if(t.length===0)return;const i={...ve(o),...qe(m(o,"extensions"))};return r.length!==0&&(i.coordTimes=t.length===1?r[0]:r),a.length!==0&&(i.heartRates=t.length===1?a[0]:a),t.length===1?{type:"Feature",properties:i,geometry:{type:"LineString",coordinates:t[0]}}:{type:"Feature",properties:i,geometry:{type:"MultiLineString",coordinates:t}}}function bo(o){const e=Ye(o,"rtept");return e===void 0?void 0:{type:"Feature",properties:{...ve(o),...qe(m(o,"extensions"))},geometry:{type:"LineString",coordinates:e.line}}}function To(o){return{type:"Feature",properties:{...ve(o),...fe(o,["sym"])},geometry:{type:"Point",coordinates:ot(o).coordinates}}}function qe(o){const e={};if(o){const t=m(o,"line");if(t){const r=S(m(t,"color")),a=Number.parseFloat(S(m(t,"opacity"))??"0"),n=Number.parseFloat(S(m(t,"width"))??"0");r&&(e.stroke=r),Number.isNaN(a)||(e["stroke-opacity"]=a),Number.isNaN(n)||(e["stroke-width"]=n*96/25.4)}}return e}function ve(o){const e=fe(o,["name","cmt","desc","type","time","keywords"]),t=x(o,"link");if(t.length!==0){e.links=[];for(const r of Array.from(t)){const a={href:j(r,"href"),...fe(r,["text","type"])};e.links.push(a)}}return e}function Je(o){let e=0;if(!o||!o.length)return e;for(let t=0;t<o.length;t++)e=(e<<5)-e+o.charCodeAt(t)|0;return e}function x(o,e){return o.getElementsByTagName(e)}function j(o,e){return o.getAttribute(e)}function Xe(o,e){return Number.parseFloat(j(o,e)??"0")}function m(o,e){const t=x(o,e);return t.length?t[0]:null}function Io(o){return o.normalize&&o.normalize(),o}function Qe(o){return o.map(Number.parseFloat).map(e=>Number.isNaN(e)?null:e)}function S(o){return o&&Io(o),o&&o.textContent}function fe(o,e){const t={};let r,a;for(a=0;a<e.length;a++)r=m(o,e[a]),r&&(t[e[a]]=S(r)??"");return t}function et(o){return Qe(o.replace(/\s*/g,"").split(","))}function tt(o){const e=o.replace(/^\s*|\s*$/g,"").split(/\s+/),t=[];for(const r of e)t.push(et(r));return t}function ot(o){const e=[Xe(o,"lon"),Xe(o,"lat")],t=m(o,"ele"),r=m(o,"gpxtpx:hr")||m(o,"hr"),a=m(o,"time");let n;return t&&(n=Number.parseFloat(S(t)??"0"),Number.isNaN(n)||e.push(n)),{coordinates:e,time:a?S(a):null,heartRate:r!==null?Number.parseFloat(S(r)??"0"):null}}function rt(o){let e=o;try{typeof e=="string"&&(e=X(e))}catch{return null}try{return ge(e)}catch{}try{return ye(e)}catch{}return null}function ee(o){const e=o.toString(16);return e.length===1?`0${e}`:e}function Eo(o){return`#${ee(o[0])}${ee(o[1])}${ee(o[2])}${o.length===4?ee(o[3]):""}`}class h extends Array{constructor(e={}){super(),this.min=0,this.max=1,"min"in e&&(this.min=e.min),"max"in e&&(this.max=e.max),"stops"in e&&this.setStops(e.stops,{clone:!1})}static fromArrayDefinition(e){return new h({stops:e.map(t=>({value:t[0],color:t[1]}))})}setStops(e,t={clone:!0}){const r=t.clone?this.clone():this;r.length=0;let a=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i+=1)a=Math.min(a,e[i].value),n=Math.max(n,e[i].value),r.push({value:e[i].value,color:e[i].color.slice()});return r.sort((i,l)=>i.value<l.value?-1:1),this.min=a,this.max=n,r}scale(e,t,r={clone:!0}){const a=r.clone,n=this[0].value,i=this.at(-1).value-n,l=t-e,u=[];for(let s=0;s<this.length;s+=1){const c=(this[s].value-n)/i*l+e;a?u.push({value:c,color:this[s].color.slice()}):this[s].value=c}return a?new h({stops:u}):this}at(e){return e<0?this[this.length+e]:this[e]}clone(){return new h({stops:this.getRawColorStops()})}getRawColorStops(){const e=[];for(let t=0;t<this.length;t+=1)e.push({value:this[t].value,color:this[t].color});return e}reverse(e={clone:!0}){const t=e.clone?this.clone():this;for(let r=0;r<~~(t.length/2);r+=1){const a=t[r].color;t[r].color=t.at(-(r+1)).color,t.at(-(r+1)).color=a}return t}getBounds(){return{min:this.min,max:this.max}}getColor(e,t={smooth:!0}){if(e<=this[0].value)return this[0].color;if(e>=this.at(-1).value)return this.at(-1).color;for(let r=0;r<this.length-1;r+=1){if(e>this[r+1].value)continue;const a=this[r].color;if(!t.smooth)return a.slice();const n=this[r].value,i=this[r+1].value,l=this[r+1].color,u=(i-e)/(i-n);return a.map((s,c)=>Math.round(s*u+l[c]*(1-u)))}return[0,0,0]}getColorHex(e,t={smooth:!0,withAlpha:!1}){return Eo(this.getColor(e,t))}getColorRelative(e,t={smooth:!0}){const r=this.getBounds();return this.getColor(r.min+e*(r.max-r.min),t)}getCanvasStrip(e={horizontal:!0,size:512,smooth:!0}){const t=document.createElement("canvas");t.width=e.horizontal?e.size:1,t.height=e.horizontal?1:e.size;const r=t.getContext("2d");if(!r)throw new Error("Canvs context is missing");const a=r.getImageData(0,0,t.width,t.height),n=a.data,i=e.size,l=this[0].value,u=(this.at(-1).value-l)/i;for(let s=0;s<i;s+=1){const c=this.getColor(l+s*u,{smooth:e.smooth});n[s*4]=c[0],n[s*4+1]=c[1],n[s*4+2]=c[2],n[s*4+3]=c.length>3?c[3]:255}return r.putImageData(a,0,0),t}resample(e,t=15){const r=this.getBounds(),a=this.scale(0,1),n=1/(t-1);let i;if(e==="ease-in-square")i=Array.from({length:t},(l,u)=>{const s=u*n,c=s**2,p=a.getColor(c);return{value:s,color:p}});else if(e==="ease-out-square")i=Array.from({length:t},(l,u)=>{const s=u*n,c=1-(1-s)**2,p=a.getColor(c);return{value:s,color:p}});else if(e==="ease-out-sqrt")i=Array.from({length:t},(l,u)=>{const s=u*n,c=s**.5,p=a.getColor(c);return{value:s,color:p}});else if(e==="ease-in-sqrt")i=Array.from({length:t},(l,u)=>{const s=u*n,c=1-(1-s)**.5,p=a.getColor(c);return{value:s,color:p}});else if(e==="ease-out-exp")i=Array.from({length:t},(l,u)=>{const s=u*n,c=1-2**(-10*s),p=a.getColor(c);return{value:s,color:p}});else if(e==="ease-in-exp")i=Array.from({length:t},(l,u)=>{const s=u*n,c=2**(10*s-10),p=a.getColor(c);return{value:s,color:p}});else throw new Error("Invalid ressampling method.");return new h({stops:i}).scale(r.min,r.max)}transparentStart(){const e=this.getRawColorStops();e.unshift({value:e[0].value,color:e[0].color.slice()}),e[1].value+=.001;for(const t of e)t.color.length===3&&t.color.push(255);return e[0].color[3]=0,new h({stops:e})}hasTransparentStart(){return this[0].color.length===4&&this[0].color[3]===0}}const Le={NULL:new h({stops:[{value:0,color:[0,0,0,0]},{value:1,color:[0,0,0,0]}]}),GRAY:new h({stops:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}]}),JET:new h({stops:[{value:0,color:[0,0,131]},{value:.125,color:[0,60,170]},{value:.375,color:[5,255,255]},{value:.625,color:[255,255,0]},{value:.875,color:[250,0,0]},{value:1,color:[128,0,0]}]}),HSV:new h({stops:[{value:0,color:[255,0,0]},{value:.169,color:[253,255,2]},{value:.173,color:[247,255,2]},{value:.337,color:[0,252,4]},{value:.341,color:[0,252,10]},{value:.506,color:[1,249,255]},{value:.671,color:[2,0,253]},{value:.675,color:[8,0,253]},{value:.839,color:[255,0,251]},{value:.843,color:[255,0,245]},{value:1,color:[255,0,6]}]}),HOT:new h({stops:[{value:0,color:[0,0,0]},{value:.3,color:[230,0,0]},{value:.6,color:[255,210,0]},{value:1,color:[255,255,255]}]}),SPRING:new h({stops:[{value:0,color:[255,0,255]},{value:1,color:[255,255,0]}]}),SUMMER:new h({stops:[{value:0,color:[0,128,102]},{value:1,color:[255,255,102]}]}),AUTOMN:new h({stops:[{value:0,color:[255,0,0]},{value:1,color:[255,255,0]}]}),WINTER:new h({stops:[{value:0,color:[0,0,255]},{value:1,color:[0,255,128]}]}),BONE:new h({stops:[{value:0,color:[0,0,0]},{value:.376,color:[84,84,116]},{value:.753,color:[169,200,200]},{value:1,color:[255,255,255]}]}),COPPER:new h({stops:[{value:0,color:[0,0,0]},{value:.804,color:[255,160,102]},{value:1,color:[255,199,127]}]}),GREYS:new h({stops:[{value:0,color:[0,0,0]},{value:1,color:[255,255,255]}]}),YIGNBU:new h({stops:[{value:0,color:[8,29,88]},{value:.125,color:[37,52,148]},{value:.25,color:[34,94,168]},{value:.375,color:[29,145,192]},{value:.5,color:[65,182,196]},{value:.625,color:[127,205,187]},{value:.75,color:[199,233,180]},{value:.875,color:[237,248,217]},{value:1,color:[255,255,217]}]}),GREENS:new h({stops:[{value:0,color:[0,68,27]},{value:.125,color:[0,109,44]},{value:.25,color:[35,139,69]},{value:.375,color:[65,171,93]},{value:.5,color:[116,196,118]},{value:.625,color:[161,217,155]},{value:.75,color:[199,233,192]},{value:.875,color:[229,245,224]},{value:1,color:[247,252,245]}]}),YIORRD:new h({stops:[{value:0,color:[128,0,38]},{value:.125,color:[189,0,38]},{value:.25,color:[227,26,28]},{value:.375,color:[252,78,42]},{value:.5,color:[253,141,60]},{value:.625,color:[254,178,76]},{value:.75,color:[254,217,118]},{value:.875,color:[255,237,160]},{value:1,color:[255,255,204]}]}),BLUERED:new h({stops:[{value:0,color:[0,0,255]},{value:1,color:[255,0,0]}]}),RDBU:new h({stops:[{value:0,color:[5,10,172]},{value:.35,color:[106,137,247]},{value:.5,color:[190,190,190]},{value:.6,color:[220,170,132]},{value:.7,color:[230,145,90]},{value:1,color:[178,10,28]}]}),PICNIC:new h({stops:[{value:0,color:[0,0,255]},{value:.1,color:[51,153,255]},{value:.2,color:[102,204,255]},{value:.3,color:[153,204,255]},{value:.4,color:[204,204,255]},{value:.5,color:[255,255,255]},{value:.6,color:[255,204,255]},{value:.7,color:[255,153,255]},{value:.8,color:[255,102,204]},{value:.9,color:[255,102,102]},{value:1,color:[255,0,0]}]}),RAINBOW:new h({stops:[{value:0,color:[150,0,90]},{value:.125,color:[0,0,200]},{value:.25,color:[0,25,255]},{value:.375,color:[0,152,255]},{value:.5,color:[44,255,150]},{value:.625,color:[151,255,0]},{value:.75,color:[255,234,0]},{value:.875,color:[255,111,0]},{value:1,color:[255,0,0]}]}),PORTLAND:new h({stops:[{value:0,color:[12,51,131]},{value:.25,color:[10,136,186]},{value:.5,color:[242,211,56]},{value:.75,color:[242,143,56]},{value:1,color:[217,30,30]}]}),BLACKBODY:new h({stops:[{value:0,color:[0,0,0]},{value:.2,color:[230,0,0]},{value:.4,color:[230,210,0]},{value:.7,color:[255,255,255]},{value:1,color:[160,200,255]}]}),EARTH:new h({stops:[{value:0,color:[0,0,130]},{value:.1,color:[0,180,180]},{value:.2,color:[40,210,40]},{value:.4,color:[230,230,50]},{value:.6,color:[120,70,20]},{value:1,color:[255,255,255]}]}),ELECTRIC:new h({stops:[{value:0,color:[0,0,0]},{value:.15,color:[30,0,100]},{value:.4,color:[120,0,100]},{value:.6,color:[160,90,0]},{value:.8,color:[230,200,0]},{value:1,color:[255,250,220]}]}),VIRIDIS:new h({stops:[{value:0,color:[68,1,84]},{value:.13,color:[71,44,122]},{value:.25,color:[59,81,139]},{value:.38,color:[44,113,142]},{value:.5,color:[33,144,141]},{value:.63,color:[39,173,129]},{value:.75,color:[92,200,99]},{value:.88,color:[170,220,50]},{value:1,color:[253,231,37]}]}),INFERNO:new h({stops:[{value:0,color:[0,0,4]},{value:.13,color:[31,12,72]},{value:.25,color:[85,15,109]},{value:.38,color:[136,34,106]},{value:.5,color:[186,54,85]},{value:.63,color:[227,89,51]},{value:.75,color:[249,140,10]},{value:.88,color:[249,201,50]},{value:1,color:[252,255,164]}]}),MAGMA:new h({stops:[{value:0,color:[0,0,4]},{value:.13,color:[28,16,68]},{value:.25,color:[79,18,123]},{value:.38,color:[129,37,129]},{value:.5,color:[181,54,122]},{value:.63,color:[229,80,100]},{value:.75,color:[251,135,97]},{value:.88,color:[254,194,135]},{value:1,color:[252,253,191]}]}),PLASMA:new h({stops:[{value:0,color:[13,8,135]},{value:.13,color:[75,3,161]},{value:.25,color:[125,3,168]},{value:.38,color:[168,34,150]},{value:.5,color:[203,70,121]},{value:.63,color:[229,107,93]},{value:.75,color:[248,148,65]},{value:.88,color:[253,195,40]},{value:1,color:[240,249,33]}]}),WARM:new h({stops:[{value:0,color:[125,0,179]},{value:.13,color:[172,0,187]},{value:.25,color:[219,0,170]},{value:.38,color:[255,0,130]},{value:.5,color:[255,63,74]},{value:.63,color:[255,123,0]},{value:.75,color:[234,176,0]},{value:.88,color:[190,228,0]},{value:1,color:[147,255,0]}]}),COOL:new h({stops:[{value:0,color:[125,0,179]},{value:.13,color:[116,0,218]},{value:.25,color:[98,74,237]},{value:.38,color:[68,146,231]},{value:.5,color:[0,204,197]},{value:.63,color:[0,247,146]},{value:.75,color:[0,255,88]},{value:.88,color:[40,255,8]},{value:1,color:[147,255,0]}]}),RAINBOW_SOFT:new h({stops:[{value:0,color:[125,0,179]},{value:.1,color:[199,0,180]},{value:.2,color:[255,0,121]},{value:.3,color:[255,108,0]},{value:.4,color:[222,194,0]},{value:.5,color:[150,255,0]},{value:.6,color:[0,255,55]},{value:.7,color:[0,246,150]},{value:.8,color:[50,167,222]},{value:.9,color:[103,51,235]},{value:1,color:[124,0,186]}]}),BATHYMETRY:new h({stops:[{value:0,color:[40,26,44]},{value:.13,color:[59,49,90]},{value:.25,color:[64,76,139]},{value:.38,color:[63,110,151]},{value:.5,color:[72,142,158]},{value:.63,color:[85,174,163]},{value:.75,color:[120,206,163]},{value:.88,color:[187,230,172]},{value:1,color:[253,254,204]}]}),CDOM:new h({stops:[{value:0,color:[47,15,62]},{value:.13,color:[87,23,86]},{value:.25,color:[130,28,99]},{value:.38,color:[171,41,96]},{value:.5,color:[206,67,86]},{value:.63,color:[230,106,84]},{value:.75,color:[242,149,103]},{value:.88,color:[249,193,135]},{value:1,color:[254,237,176]}]}),CHLOROPHYLL:new h({stops:[{value:0,color:[18,36,20]},{value:.13,color:[25,63,41]},{value:.25,color:[24,91,59]},{value:.38,color:[13,119,72]},{value:.5,color:[18,148,80]},{value:.63,color:[80,173,89]},{value:.75,color:[132,196,122]},{value:.88,color:[175,221,162]},{value:1,color:[215,249,208]}]}),DENSITY:new h({stops:[{value:0,color:[54,14,36]},{value:.13,color:[89,23,80]},{value:.25,color:[110,45,132]},{value:.38,color:[120,77,178]},{value:.5,color:[120,113,213]},{value:.63,color:[115,151,228]},{value:.75,color:[134,185,227]},{value:.88,color:[177,214,227]},{value:1,color:[230,241,241]}]}),FREESURFACE_BLUE:new h({stops:[{value:0,color:[30,4,110]},{value:.13,color:[47,14,176]},{value:.25,color:[41,45,236]},{value:.38,color:[25,99,212]},{value:.5,color:[68,131,200]},{value:.63,color:[114,156,197]},{value:.75,color:[157,181,203]},{value:.88,color:[200,208,216]},{value:1,color:[241,237,236]}]}),FREESURFACE_RED:new h({stops:[{value:0,color:[60,9,18]},{value:.13,color:[100,17,27]},{value:.25,color:[142,20,29]},{value:.38,color:[177,43,27]},{value:.5,color:[192,87,63]},{value:.63,color:[205,125,105]},{value:.75,color:[216,162,148]},{value:.88,color:[227,199,193]},{value:1,color:[241,237,236]}]}),OXYGEN:new h({stops:[{value:0,color:[64,5,5]},{value:.13,color:[106,6,15]},{value:.25,color:[144,26,7]},{value:.38,color:[168,64,3]},{value:.5,color:[188,100,4]},{value:.63,color:[206,136,11]},{value:.75,color:[220,174,25]},{value:.88,color:[231,215,44]},{value:1,color:[248,254,105]}]}),PAR:new h({stops:[{value:0,color:[51,20,24]},{value:.13,color:[90,32,35]},{value:.25,color:[129,44,34]},{value:.38,color:[159,68,25]},{value:.5,color:[182,99,19]},{value:.63,color:[199,134,22]},{value:.75,color:[212,171,35]},{value:.88,color:[221,210,54]},{value:1,color:[225,253,75]}]}),PHASE:new h({stops:[{value:0,color:[145,105,18]},{value:.13,color:[184,71,38]},{value:.25,color:[186,58,115]},{value:.38,color:[160,71,185]},{value:.5,color:[110,97,218]},{value:.63,color:[50,123,164]},{value:.75,color:[31,131,110]},{value:.88,color:[77,129,34]},{value:1,color:[145,105,18]}]}),SALINITY:new h({stops:[{value:0,color:[42,24,108]},{value:.13,color:[33,50,162]},{value:.25,color:[15,90,145]},{value:.38,color:[40,118,137]},{value:.5,color:[59,146,135]},{value:.63,color:[79,175,126]},{value:.75,color:[120,203,104]},{value:.88,color:[193,221,100]},{value:1,color:[253,239,154]}]}),TEMPERATURE:new h({stops:[{value:0,color:[4,35,51]},{value:.13,color:[23,51,122]},{value:.25,color:[85,59,157]},{value:.38,color:[129,79,143]},{value:.5,color:[175,95,130]},{value:.63,color:[222,112,101]},{value:.75,color:[249,146,66]},{value:.88,color:[249,196,65]},{value:1,color:[232,250,91]}]}),TURBIDITY:new h({stops:[{value:0,color:[34,31,27]},{value:.13,color:[65,50,41]},{value:.25,color:[98,69,52]},{value:.38,color:[131,89,57]},{value:.5,color:[161,112,59]},{value:.63,color:[185,140,66]},{value:.75,color:[202,174,88]},{value:.88,color:[216,209,126]},{value:1,color:[233,246,171]}]}),VELOCITY_BLUE:new h({stops:[{value:0,color:[17,32,64]},{value:.13,color:[35,52,116]},{value:.25,color:[29,81,156]},{value:.38,color:[31,113,162]},{value:.5,color:[50,144,169]},{value:.63,color:[87,173,176]},{value:.75,color:[149,196,189]},{value:.88,color:[203,221,211]},{value:1,color:[254,251,230]}]}),VELOCITY_GREEN:new h({stops:[{value:0,color:[23,35,19]},{value:.13,color:[24,64,38]},{value:.25,color:[11,95,45]},{value:.38,color:[39,123,35]},{value:.5,color:[95,146,12]},{value:.63,color:[152,165,18]},{value:.75,color:[201,186,69]},{value:.88,color:[233,216,137]},{value:1,color:[255,253,205]}]}),CUBEHELIX:new h({stops:[{value:0,color:[0,0,0]},{value:.07,color:[22,5,59]},{value:.13,color:[60,4,105]},{value:.2,color:[109,1,135]},{value:.27,color:[161,0,147]},{value:.33,color:[210,2,142]},{value:.4,color:[251,11,123]},{value:.47,color:[255,29,97]},{value:.53,color:[255,54,69]},{value:.6,color:[255,85,46]},{value:.67,color:[255,120,34]},{value:.73,color:[255,157,37]},{value:.8,color:[241,191,57]},{value:.87,color:[224,220,93]},{value:.93,color:[218,241,142]},{value:1,color:[227,253,198]}]}),CIVIDIS:new h({stops:[{value:0,color:[0,32,77,255]},{value:.125,color:[5,54,110,255]},{value:.25,color:[65,77,108,255]},{value:.375,color:[97,100,111,255]},{value:.5,color:[125,124,121,255]},{value:.625,color:[156,149,120,255]},{value:.75,color:[190,175,111,255]},{value:.875,color:[225,204,94,255]},{value:1,color:[255,235,70,255]}]}),TURBO:new h({stops:[{value:0,color:[48,18,59,255]},{value:.125,color:[70,107,227,255]},{value:.25,color:[40,187,236,255]},{value:.375,color:[49,242,153,255]},{value:.5,color:[162,252,60,255]},{value:.625,color:[237,208,58,255]},{value:.75,color:[251,128,34,255]},{value:.875,color:[210,49,5,255]},{value:1,color:[122,4,3,255]}]}),ROCKET:new h({stops:[{value:0,color:[250,235,221,0]},{value:.133,color:[250,235,221,255]},{value:.266,color:[246,170,130,255]},{value:.4,color:[240,96,67,255]},{value:.533,color:[203,27,79,255]},{value:.666,color:[132,30,90,255]},{value:.8,color:[63,27,68,255]},{value:1,color:[3,5,26,255]}]}),MAKO:new h({stops:[{value:0,color:[11,4,5,255]},{value:.125,color:[43,28,53,255]},{value:.25,color:[62,53,107,255]},{value:.375,color:[59,86,152,255]},{value:.5,color:[53,123,162,255]},{value:.625,color:[53,158,170,255]},{value:.75,color:[73,193,173,255]},{value:.875,color:[150,221,181,255]},{value:1,color:[222,245,229,255]}]})},at=[["#1D5B79","#468B97","#EF6262","#F3AA60"],["#614BC3","#33BBC5","#85E6C5","#C8FFE0"],["#461959","#7A316F","#CD6688","#AED8CC"],["#0079FF","#00DFA2","#F6FA70","#FF0060"],["#39B5E0","#A31ACB","#FF78F0","#F5EA5A"],["#37E2D5","#590696","#C70A80","#FBCB0A"],["#FFD36E","#FFF56D","#99FFCD","#9FB4FF"],["#00EAD3","#FFF5B7","#FF449F","#005F99"],["#10A19D","#540375","#FF7000","#FFBF00"]];function Ae(){return at[~~(Math.random()*at.length)][~~(Math.random()*4)]}function te(){return`maptiler_source_${Ne()}`}function oe(){return`maptiler_layer_${Ne()}`}function nt(o,e){if(e<=o[0].zoom)return o[0].value;if(e>=o[o.length-1].zoom)return o[o.length-1].value;for(let t=0;t<o.length-1;t+=1)if(e>=o[t].zoom&&e<o[t+1].zoom){const r=o[t+1].zoom-o[t].zoom,a=(e-o[t].zoom)/r;return a*o[t+1].value+(1-a)*o[t].value}return 0}function V(o){return["interpolate",["linear"],["zoom"],...o.flatMap(e=>[e.zoom,e.value])]}function b(o){return["interpolate",["linear"],["zoom"],...o.flatMap(e=>[e.zoom,e.value])]}function Ro(o,e){if(typeof e=="number"&&typeof o=="number")return 2*e+o;if(typeof e=="number"&&Array.isArray(o))return["interpolate",["linear"],["zoom"],...o.flatMap(t=>[t.zoom,2*e+t.value])];if(typeof o=="number"&&Array.isArray(e))return["interpolate",["linear"],["zoom"],...e.flatMap(t=>[t.zoom,2*t.value+o])];if(Array.isArray(o)&&Array.isArray(e)){const t=Array.from(new Set([...o.map(r=>r.zoom),...e.map(r=>r.zoom)])).sort((r,a)=>r<a?-1:1);return["interpolate",["linear"],["zoom"],...t.flatMap(r=>[r,2*nt(e,r)+nt(o,r)])]}return 0}function xo(o,e){return["interpolate",["linear"],["get",e],...o.flatMap(t=>[t.propertyValue,t.value])]}function it(o){const e=o.trimStart(),t=`${e}${" ".repeat(o.length-e.length)}`,r=Array.from(t);if(!r.every(n=>n===" "||n==="_"))throw new Error("A dash pattern must be composed only of whitespace and underscore characters.");if(!(r.some(n=>n==="_")&&r.some(n=>n===" ")))throw new Error("A dash pattern must contain at least one underscore and one whitespace character");const a=[1];for(let n=1;n<r.length;n+=1){const i=r[n-1],l=r[n];i===l?a[a.length-1]+=1:a.push(1)}return a}function lt(o,e){return["interpolate",["linear"],["get",e],...o.flatMap(t=>[t.value,t.color])]}function st(o,e,t=!0){return t?["interpolate",["linear"],["zoom"],0,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.value,r.pointRadius*.025])],2,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.value,r.pointRadius*.05])],4,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.value,r.pointRadius*.1])],8,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.value,r.pointRadius*.25])],16,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.value,r.pointRadius])]]:["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.value,r.pointRadius])]}function No(o,e,t=!0){return t?["interpolate",["linear"],["zoom"],0,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.propertyValue,r.value*.025])],2,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.propertyValue,r.value*.05])],4,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.propertyValue,r.value*.1])],8,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.propertyValue,r.value*.25])],16,["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.propertyValue,r.value])]]:["interpolate",["linear"],["get",e],...o.flatMap(r=>[r.propertyValue,r.value])]}function ct(o,e){return o.every(t=>t.color[3]===o[0].color[3])?o[0].color[3]?o[0].color[3]/255:1:["interpolate",["linear"],["get",e],...o.getRawColorStops().flatMap(t=>{const r=t.value,a=t.color;return[r,a.length===4?a[3]/255:1]})]}function _o(o,e=10){return["interpolate",["linear"],["heatmap-density"],...Array.from({length:e+1},(t,r)=>{const a=r/e;return[a,o.getColorHex(a)]}).flat()]}async function Mo(o,e,t={}){if(!e.sourceId&&!e.data)throw new Error("Creating a polyline layer requires an existing .sourceId or a valid .data property");let r=e.data;if(typeof r=="string"){if(q(r))r=`https://api.maptiler.com/data/${e.data}/features.json?key=${R.apiKey}`;else if(r.split(".").pop()?.toLowerCase().trim()==="gpx"){const a=await(await fetch(r,t)).text();r=ge(a)}else if(r.split(".").pop()?.toLowerCase().trim()==="kml"){const a=await(await fetch(r,t)).text();r=ye(a)}else{const a=Yt(r)??rt(r);a&&(r=a)}if(!r)throw new Error("Polyline data was provided as string but is incompatible with valid formats.")}return Po(o,{...e,data:r})}function Po(o,e){if(e.layerId&&o.getLayer(e.layerId))throw new Error(`A layer already exists with the layer id: ${e.layerId}`);const t=e.sourceId??te(),r=e.layerId??oe(),a={polylineLayerId:r,polylineOutlineLayerId:"",polylineSourceId:t};e.data&&!o.getSource(t)&&o.addSource(t,{type:"geojson",data:e.data});const n=e.lineWidth??3,i=e.lineColor??Ae(),l=e.lineOpacity??1,u=e.lineBlur??0,s=e.lineGapWidth??0;let c=e.lineDashArray??null;const p=e.outlineWidth??1,d=e.outlineColor??"#FFFFFF",y=e.outlineOpacity??1,v=e.outlineBlur??0;if(typeof c=="string"&&(c=it(c)),e.outline===!0){const g=`${r}_outline`;a.polylineOutlineLayerId=g,o.addLayer({id:g,type:"line",source:t,layout:{"line-join":e.lineJoin??"round","line-cap":e.lineCap??"round"},minzoom:e.minzoom??0,maxzoom:e.maxzoom??23,paint:{"line-opacity":typeof y=="number"?y:b(y),"line-color":typeof d=="string"?d:V(d),"line-width":Ro(n,p),"line-blur":typeof v=="number"?v:b(v)}},e.beforeId)}return o.addLayer({id:r,type:"line",source:t,layout:{"line-join":e.lineJoin??"round","line-cap":e.lineCap??"round"},minzoom:e.minzoom??0,maxzoom:e.maxzoom??23,paint:{"line-opacity":typeof l=="number"?l:b(l),"line-color":typeof i=="string"?i:V(i),"line-width":typeof n=="number"?n:b(n),"line-blur":typeof u=="number"?u:b(u),"line-gap-width":typeof s=="number"?s:b(s),...c&&{"line-dasharray":c}}},e.beforeId),a}function Oo(o,e){if(e.layerId&&o.getLayer(e.layerId))throw new Error(`A layer already exists with the layer id: ${e.layerId}`);const t=e.sourceId??te(),r=e.layerId??oe(),a={polygonLayerId:r,polygonOutlineLayerId:e.outline?`${r}_outline`:"",polygonSourceId:t};if(e.data&&!o.getSource(t)){let g=e.data;typeof g=="string"&&q(g)&&(g=`https://api.maptiler.com/data/${g}/features.json?key=${R.apiKey}`),o.addSource(t,{type:"geojson",data:g})}let n=e.outlineDashArray??null;const i=e.outlineWidth??1,l=e.outlineColor??"#FFFFFF",u=e.outlineOpacity??1,s=e.outlineBlur??0,c=e.fillColor??Ae(),p=e.fillOpacity??1,d=e.outlinePosition??"center",y=e.pattern??null;typeof n=="string"&&(n=it(n));const v=(g=null)=>{if(o.addLayer({id:r,type:"fill",source:t,minzoom:e.minzoom??0,maxzoom:e.maxzoom??23,paint:{"fill-color":typeof c=="string"?c:V(c),"fill-opacity":typeof p=="number"?p:b(p),...g&&{"fill-pattern":g}}},e.beforeId),e.outline===!0){let w;d==="inside"?typeof i=="number"?w=.5*i:w=b(i.map(({zoom:N,value:L})=>({zoom:N,value:.5*L}))):d==="outside"?typeof i=="number"?w=-.5*i:w=b(i.map(N=>({zoom:N.zoom,value:-.5*N.value}))):w=0,o.addLayer({id:a.polygonOutlineLayerId,type:"line",source:t,layout:{"line-join":e.outlineJoin??"round","line-cap":e.outlineCap??"butt"},minzoom:e.minzoom??0,maxzoom:e.maxzoom??23,paint:{"line-opacity":typeof u=="number"?u:b(u),"line-color":typeof l=="string"?l:V(l),"line-width":typeof i=="number"?i:b(i),"line-blur":typeof s=="number"?s:b(s),"line-offset":w,...n&&{"line-dasharray":n}}},e.beforeId)}};return y?o.hasImage(y)?v(y):o.loadImage(y).then(g=>{o.addImage(y,g.data),v(y)}).catch(g=>(console.error("Could not load the pattern image.",g.message),v())):v(),a}function ko(o,e){if(e.layerId&&o.getLayer(e.layerId))throw new Error(`A layer already exists with the layer id: ${e.layerId}`);const t=e.minPointRadius??10,r=e.maxPointRadius??50,a=e.cluster??!1,n=20,i=Array.isArray(e.pointColor)?e.pointColor:Le.TURBO.scale(10,e.cluster?1e4:1e3).resample("ease-out-square"),l=i.getBounds(),u=e.sourceId??te(),s=e.layerId??oe(),c=e.showLabel??a,p=e.alignOnViewport??!0,d=e.outline??!1,y=e.outlineOpacity??1,v=e.outlineWidth??1,g=e.outlineColor??"#FFFFFF";let w;const N=e.zoomCompensation??!0,L=e.minzoom??0,I=e.maxzoom??23;typeof e.pointOpacity=="number"?w=e.pointOpacity:Array.isArray(e.pointOpacity)?w=b(e.pointOpacity):e.cluster?w=ct(i,"point_count"):e.property?w=ct(i,e.property):w=b([{zoom:L,value:0},{zoom:L+.25,value:1},{zoom:I-.25,value:1},{zoom:I,value:0}]);const E={pointLayerId:s,clusterLayerId:"",labelLayerId:"",pointSourceId:u};if(e.data&&!o.getSource(u)){let T=e.data;typeof T=="string"&&q(T)&&(T=`https://api.maptiler.com/data/${T}/features.json?key=${R.apiKey}`),o.addSource(u,{type:"geojson",data:T,cluster:a})}if(a){E.clusterLayerId=`${s}_cluster`;const T=Array.from({length:n},(z,H)=>{const K=l.min+H*(l.max-l.min)/(n-1);return{value:K,pointRadius:t+(r-t)*(H/(n-1))**.5,color:i.getColorHex(K)}});o.addLayer({id:E.clusterLayerId,type:"circle",source:u,filter:["has","point_count"],paint:{"circle-color":typeof e.pointColor=="string"?e.pointColor:lt(T,"point_count"),"circle-radius":typeof e.pointRadius=="number"?e.pointRadius:Array.isArray(e.pointRadius)?b(e.pointRadius):st(T,"point_count",!1),"circle-pitch-alignment":p?"viewport":"map","circle-pitch-scale":"map","circle-opacity":w,...d&&{"circle-stroke-opacity":typeof y=="number"?y:b(y),"circle-stroke-width":typeof v=="number"?v:b(v),"circle-stroke-color":typeof g=="string"?g:V(g)}},minzoom:L,maxzoom:I},e.beforeId),o.addLayer({id:E.pointLayerId,type:"circle",source:u,filter:["!",["has","point_count"]],paint:{"circle-pitch-alignment":p?"viewport":"map","circle-pitch-scale":"map","circle-color":typeof e.pointColor=="string"?e.pointColor:i.getColorHex(i.getBounds().min),"circle-radius":typeof e.pointRadius=="number"?e.pointRadius:Array.isArray(e.pointRadius)?b(e.pointRadius):T[0].pointRadius*.75,"circle-opacity":w,...d&&{"circle-stroke-opacity":typeof y=="number"?y:b(y),"circle-stroke-width":typeof v=="number"?v:b(v),"circle-stroke-color":typeof g=="string"?g:V(g)}},minzoom:L,maxzoom:I},e.beforeId)}else{let T=typeof e.pointColor=="string"?e.pointColor:Array.isArray(e.pointColor)?e.pointColor.getColorHex(e.pointColor.getBounds().min):Ae(),z=typeof e.pointRadius=="number"?N?b([{zoom:0,value:e.pointRadius*.025},{zoom:2,value:e.pointRadius*.05},{zoom:4,value:e.pointRadius*.1},{zoom:8,value:e.pointRadius*.25},{zoom:16,value:e.pointRadius*1}]):e.pointRadius:Array.isArray(e.pointRadius)?b(e.pointRadius):N?b([{zoom:0,value:t*.05},{zoom:2,value:t*.1},{zoom:4,value:t*.2},{zoom:8,value:t*.5},{zoom:16,value:t*1}]):t;if(e.property&&Array.isArray(e.pointColor)){const H=Array.from({length:n},(K,Z)=>{const Y=l.min+Z*(l.max-l.min)/(n-1);return{value:Y,pointRadius:typeof e.pointRadius=="number"?e.pointRadius:t+(r-t)*(Z/(n-1))**.5,color:typeof e.pointColor=="string"?e.pointColor:i.getColorHex(Y)}});T=lt(H,e.property),z=st(H,e.property,N)}o.addLayer({id:E.pointLayerId,type:"circle",source:u,layout:{"circle-sort-key":e.property?["/",1,["get",e.property]]:0},paint:{"circle-pitch-alignment":p?"viewport":"map","circle-pitch-scale":"map","circle-color":T,"circle-opacity":w,"circle-radius":z,...d&&{"circle-stroke-opacity":typeof y=="number"?y:b(y),"circle-stroke-width":typeof v=="number"?v:b(v),"circle-stroke-color":typeof g=="string"?g:V(g)}},minzoom:L,maxzoom:I},e.beforeId)}if(c!==!1&&(e.cluster||e.property)){E.labelLayerId=`${s}_label`;const T=e.labelColor??"#fff",z=e.labelSize??12;o.addLayer({id:E.labelLayerId,type:"symbol",source:u,filter:["has",e.cluster?"point_count":e.property],layout:{"text-field":e.cluster?"{point_count_abbreviated}":`{${e.property}}`,"text-font":["Noto Sans Regular"],"text-size":z,"text-pitch-alignment":p?"viewport":"map","symbol-sort-key":["/",1,["get",e.cluster?"point_count":e.property]]},paint:{"text-color":T,"text-opacity":w},minzoom:L,maxzoom:I},e.beforeId)}return E}function Fo(o,e){if(e.layerId&&o.getLayer(e.layerId))throw new Error(`A layer already exists with the layer id: ${e.layerId}`);const t=e.sourceId??te(),r=e.layerId??oe(),a=e.minzoom??0,n=e.maxzoom??23,i=e.zoomCompensation??!0,l=e.opacity??[{zoom:a,value:0},{zoom:a+.25,value:1},{zoom:n-.25,value:1},{zoom:n,value:0}];let u=Array.isArray(e.colorRamp)?e.colorRamp:Le.TURBO.transparentStart();const s=u.getBounds();(s.min!==0||s.max!==1)&&(u=u.scale(0,1)),u.hasTransparentStart()||(u=u.transparentStart());const c=e.intensity??[{zoom:0,value:.01},{zoom:4,value:.2},{zoom:16,value:1}],p=e.property??null,d=e.weight??1;let y=1;p?typeof d=="number"?(y=d,typeof e.weight=="number"&&console.warn("The option `.property` is ignored when `.propertyValueWeights` is not of type `PropertyValueWeights`")):Array.isArray(d)?y=xo(d,p):console.warn("The option `.property` is ignored when `.propertyValueWeights` is not of type `PropertyValueWeights`"):typeof d=="number"?y=d:Array.isArray(d)&&console.warn("The options `.propertyValueWeights` can only be used when `.property` is provided.");const v=[{zoom:0,value:50*.025},{zoom:2,value:50*.05},{zoom:4,value:50*.1},{zoom:8,value:50*.25},{zoom:16,value:50}],g=e.radius??(i?v:10);let w=1;typeof g=="number"?w=g:Array.isArray(g)&&"zoom"in g[0]?w=b(g):p&&Array.isArray(g)&&"propertyValue"in g[0]?w=No(g,p,i):!p&&Array.isArray(g)&&"propertyValue"in g[0]?(w=b(v),console.warn("The option `.radius` can only be property-driven if the option `.property` is provided.")):w=b(v);const N={heatmapLayerId:r,heatmapSourceId:t};if(e.data&&!o.getSource(t)){let L=e.data;typeof L=="string"&&q(L)&&(L=`https://api.maptiler.com/data/${L}/features.json?key=${R.apiKey}`),o.addSource(t,{type:"geojson",data:L})}return o.addLayer({id:r,type:"heatmap",source:t,minzoom:a,maxzoom:n,paint:{"heatmap-weight":y,"heatmap-intensity":typeof c=="number"?c:b(c),"heatmap-color":_o(u),"heatmap-radius":w,"heatmap-opacity":typeof l=="number"?l:b(l)}}),N}const zo={addPolyline:Mo,addPolygon:Oo,addPoint:ko,addHeatmap:Fo};Kt();function Bo(){return Bt.version}export{Wo as AJAXError,so as AttributionControl,Ko as AttributionControlMLGL,uo as BoxZoomHandler,Zo as BoxZoomHandlerMLGL,to as CanvasSource,Yo as CanvasSourceMLGL,h as ColorRamp,Le as ColorRampCollection,ho as CooperativeGesturesHandler,qo as CooperativeGesturesHandlerMLGL,Jo as DoubleClickZoomHandler,Xo as DragPanHandler,Qo as DragRotateHandler,er as EdgeInsets,tr as Evented,ke as FullscreenControl,or as FullscreenControlMLGL,oo as GeoJSONSource,rr as GeoJSONSourceMLGL,Me as GeolocateControl,ar as GeolocateControlMLGL,We as GeolocationType,nr as Hash,ro as ImageSource,ir as ImageSourceMLGL,mo as KeyboardHandler,lr as KeyboardHandlerMLGL,A as Language,Yr as LanguageGeocoding,sr as LngLat,cr as LngLatBounds,Pe as LogoControl,ur as LogoControlMLGL,Ke as Map,pr as MapMLGL,fo as MapMouseEvent,hr as MapMouseEventMLGL,qr as MapStyle,Jr as MapStyleVariant,vo as MapTouchEvent,mr as MapTouchEventMLGL,yo as MapWheelEvent,dr as MapWheelEventMLGL,He as MaptilerGeolocateControl,ue as MaptilerLogoControl,Be as MaptilerNavigationControl,ze as MaptilerTerrainControl,Xt as Marker,gr as MarkerMLGL,yr as MercatorCoordinate,_e as NavigationControl,vr as NavigationControlMLGL,fr as Point,Qt as Popup,Lr as PopupMLGL,no as RasterDEMTileSource,Ar as RasterDEMTileSourceMLGL,ao as RasterTileSource,wr as RasterTileSourceMLGL,Xr as ReferenceMapStyle,Oe as ScaleControl,Cr as ScaleControlMLGL,po as ScrollZoomHandler,Sr as ScrollZoomHandlerMLGL,be as SdkConfig,Qr as ServiceError,eo as Style,br as StyleMLGL,co as TerrainControl,Tr as TerrainControlMLGL,go as TwoFingersTouchPitchHandler,Ir as TwoFingersTouchPitchHandlerMLGL,Er as TwoFingersTouchRotateHandler,Rr as TwoFingersTouchZoomHandler,xr as TwoFingersTouchZoomRotateHandler,io as VectorTileSource,Nr as VectorTileSourceMLGL,lo as VideoSource,_r as VideoSourceMLGL,Mr as addProtocol,Pr as addSourceType,ea as bufferToPixelDataBrowser,ta as circumferenceAtLatitude,Or as clearPrewarmedResources,R as config,kr as configMLGL,oa as coordinates,ra as data,aa as elevation,na as expandMapStyle,ia as geocoding,la as geolocation,sa as getAutoLanguageGeocoding,ne as getBrowserLanguage,ca as getBufferToPixelDataParser,Fr as getMapLibreVersion,zr as getMaxParallelImageRequests,Br as getRTLTextPluginStatus,ua as getTileCache,Bo as getVersion,Ur as getWorkerCount,Gr as getWorkerUrl,ge as gpx,rt as gpxOrKml,me as hasChildNodeWithName,zo as helpers,Hr as importScriptInWorkers,ae as isLanguageSupported,ye as kml,pa as mapStylePresetList,ha as math,ma as misc,Dr as prewarm,$r as removeProtocol,jr as setMaxParallelImageRequests,Vr as setRTLTextPlugin,Wr as setWorkerCount,Kr as setWorkerUrl,da as staticMaps,X as str2xml,ga as styleToStyle,de as xml2str};
|
package/rollup.config.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import os from "os";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import dts from "rollup-plugin-dts";
|
|
4
|
-
import esbuild from "rollup-plugin-esbuild";
|
|
5
|
-
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
6
|
-
import globals from "rollup-plugin-node-globals";
|
|
7
|
-
import commonjs from "@rollup/plugin-commonjs";
|
|
8
|
-
import copy from 'rollup-plugin-copy-merge'
|
|
9
|
-
import json from '@rollup/plugin-json';
|
|
10
|
-
import execute from "rollup-plugin-shell";
|
|
11
|
-
|
|
12
|
-
const outputName = "maptiler-sdk";
|
|
13
|
-
const externals = ["maplibre-gl", "@maptiler/client", "@mapbox/point-geometry", "uuid", "@mapbox/unitbezier", "events", "js-base64", "geojson-validation"];
|
|
14
|
-
|
|
15
|
-
const cssMaplibreFilepath = "node_modules/maplibre-gl/dist/maplibre-gl.css";
|
|
16
|
-
const cssTemplateFilepath = "src/style/style_template.css";
|
|
17
|
-
const cssIntermatdiateFilepath = path.join(os.tmpdir(), `${outputName}-style.css`);
|
|
18
|
-
const cssDistribution = `dist/${outputName}.css`;
|
|
19
|
-
|
|
20
|
-
const replaceCssPath = execute({ commands: [`node scripts/replace-path-with-content.js ${cssTemplateFilepath} ${cssIntermatdiateFilepath}`], hook: "buildStart" })
|
|
21
|
-
|
|
22
|
-
const copyCssPlugin = copy({
|
|
23
|
-
targets: [
|
|
24
|
-
{
|
|
25
|
-
src: [cssMaplibreFilepath, cssIntermatdiateFilepath],
|
|
26
|
-
file: cssDistribution,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const bundles = [
|
|
33
|
-
// ES module, not minified + sourcemap
|
|
34
|
-
{
|
|
35
|
-
plugins: [
|
|
36
|
-
replaceCssPath,
|
|
37
|
-
copyCssPlugin,
|
|
38
|
-
json(),
|
|
39
|
-
esbuild()
|
|
40
|
-
],
|
|
41
|
-
output: [
|
|
42
|
-
{
|
|
43
|
-
file: `dist/${outputName}.mjs`,
|
|
44
|
-
format: "es",
|
|
45
|
-
sourcemap: true,
|
|
46
|
-
},
|
|
47
|
-
],
|
|
48
|
-
input: "src/index.ts",
|
|
49
|
-
watch: {
|
|
50
|
-
include: "src/**",
|
|
51
|
-
},
|
|
52
|
-
external: externals,
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
// UMD module, not minified
|
|
56
|
-
{
|
|
57
|
-
plugins: [
|
|
58
|
-
replaceCssPath,
|
|
59
|
-
copyCssPlugin,
|
|
60
|
-
nodeResolve({
|
|
61
|
-
preferBuiltins: false,
|
|
62
|
-
}), // for the standalone UMD, we want to resolve so that the bundle contains all the dep.
|
|
63
|
-
commonjs({ include: "node_modules/**" }),
|
|
64
|
-
globals(),
|
|
65
|
-
json(),
|
|
66
|
-
esbuild(),
|
|
67
|
-
// copyUmdBundle,
|
|
68
|
-
],
|
|
69
|
-
output: [
|
|
70
|
-
{
|
|
71
|
-
name: "maptilersdk",
|
|
72
|
-
file: `dist/${outputName}.umd.js`,
|
|
73
|
-
format: "umd",
|
|
74
|
-
sourcemap: true,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
input: "src/index.ts",
|
|
78
|
-
watch: {
|
|
79
|
-
include: "src/**",
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
// types
|
|
84
|
-
{
|
|
85
|
-
plugins: [dts()],
|
|
86
|
-
output: {
|
|
87
|
-
file: `dist/${outputName}.d.ts`,
|
|
88
|
-
format: "es",
|
|
89
|
-
},
|
|
90
|
-
input: "src/index.ts",
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
if (process.env.NODE_ENV === "production") {
|
|
95
|
-
bundles.push(
|
|
96
|
-
// ES module, minified
|
|
97
|
-
{
|
|
98
|
-
plugins: [
|
|
99
|
-
replaceCssPath,
|
|
100
|
-
copyCssPlugin,
|
|
101
|
-
json(),
|
|
102
|
-
esbuild({
|
|
103
|
-
sourceMap: false,
|
|
104
|
-
minify: true,
|
|
105
|
-
}),
|
|
106
|
-
],
|
|
107
|
-
output: [
|
|
108
|
-
{
|
|
109
|
-
file: `dist/${outputName}.min.mjs`,
|
|
110
|
-
format: "es",
|
|
111
|
-
},
|
|
112
|
-
],
|
|
113
|
-
input: "src/index.ts",
|
|
114
|
-
external: externals,
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
plugins: [
|
|
118
|
-
replaceCssPath,
|
|
119
|
-
copyCssPlugin,
|
|
120
|
-
nodeResolve({
|
|
121
|
-
preferBuiltins: false,
|
|
122
|
-
}), // for the standalone UMD, we want to resolve so that the bundle contains all the dep.
|
|
123
|
-
commonjs({ include: "node_modules/**" }),
|
|
124
|
-
globals(),
|
|
125
|
-
json(),
|
|
126
|
-
esbuild({
|
|
127
|
-
sourceMap: false,
|
|
128
|
-
minify: true,
|
|
129
|
-
}),
|
|
130
|
-
],
|
|
131
|
-
output: [
|
|
132
|
-
{
|
|
133
|
-
name: "maptilersdk",
|
|
134
|
-
file: `dist/${outputName}.umd.min.js`,
|
|
135
|
-
format: "umd",
|
|
136
|
-
sourcemap: false,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
input: "src/index.ts",
|
|
140
|
-
watch: {
|
|
141
|
-
include: "src/**",
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export default bundles;
|