solid-map-gl 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { Component, JSX, ParentComponent, VoidComponent } from 'solid-js';
2
- import { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent, LngLatLike, LngLatBounds, PaddingOptions, MapboxOptions, StyleSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, FogSpecification, NavigationControlOptions, ScaleControlOptions, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, MarkerOptions, PopupOptions, StyleImageInterface, Map as Map$1, LightSpecification } from 'mapbox-gl';
2
+ import { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent, LngLatLike, LngLatBoundsLike, PaddingOptions, MapboxOptions, StyleSpecification, SourceSpecification, CustomLayerInterface, FilterSpecification, FogSpecification, NavigationControlOptions, ScaleControlOptions, AttributionControlOptions, FullscreenControlOptions, GeolocateControlOptions, MarkerOptions, PopupOptions, StyleImageInterface, Map as Map$1, LightSpecification } from 'mapbox-gl';
3
3
 
4
4
  /** Any object shaped enough like `mapboxgl.Map`/`maplibregl.Map` for the functions in this module —
5
5
  * kept loose (not the real `mapboxgl.Map` type) so this file has no hard dependency on either
@@ -32,7 +32,11 @@ type SettleOptions = {
32
32
  declare function settleAfterIdle(map: SettleableMap, options?: SettleOptions): Promise<void>;
33
33
  /** Waits for the map's next 'idle' event, then `settleAfterIdle`. The convenience entry point for
34
34
  * off-screen/headless capture: call your own `jumpTo`/`fitBounds`/`setData` first, then `await` this
35
- * before reading the canvas. */
35
+ * before reading the canvas. Calls `triggerRepaint()` itself before waiting — 'idle' only fires on
36
+ * the *transition into* idle, so a map that's already idle with nothing queued (e.g. capturing
37
+ * whatever's on screen with no preceding camera/data change) would otherwise never fire another one
38
+ * and this would hang forever. Redundant, and harmless, if the map isn't idle yet: mapbox-gl/
39
+ * maplibre-gl coalesce repeated `triggerRepaint()` calls into whatever frame is already pending. */
36
40
  declare function waitForIdleAndSettle(map: SettleableMap, options?: SettleOptions): Promise<void>;
37
41
  /** Zeros `raster-fade-duration` on every layer that supports it, so newly-loaded raster tiles
38
42
  * appear at full opacity immediately instead of cross-fading in over mapbox-gl's default 300ms —
@@ -184,7 +188,7 @@ type Viewport = {
184
188
  y: number;
185
189
  };
186
190
  center?: LngLatLike;
187
- bounds?: LngLatBounds;
191
+ bounds?: LngLatBoundsLike;
188
192
  zoom?: number;
189
193
  pitch?: number;
190
194
  bearing?: number;
@@ -204,10 +208,11 @@ type Props$b = {
204
208
  };
205
209
  /** Current Map View */
206
210
  viewport?: Viewport;
207
- /** Mapbox Options
211
+ /** Mapbox Options. `container` is always set internally (see setupMap below) and is omitted
212
+ * from this type since a consumer-supplied value would just be silently overridden.
208
213
  * @see https://docs.mapbox.com/mapbox-gl-js/api/map/#map-parameters
209
214
  */
210
- options?: MapboxOptions;
215
+ options?: Omit<MapboxOptions, "container">;
211
216
  /** Mapbox Standard / Standard Satellite style configuration — Mapbox-only, no-op on MapLibre.
212
217
  * @see https://docs.mapbox.com/mapbox-gl-js/guides/styles/#configure-a-style
213
218
  */
@@ -293,12 +298,12 @@ type Props$b = {
293
298
  * Default `true`. */
294
299
  disableRasterFade?: boolean;
295
300
  };
296
- /** Called once, after the map loads, with a capturer for grabbing the canvas as an image — only
297
- * meaningful together with `offscreen`. Change `viewport`/`<Source>`'s `data` the normal
298
- * declarative way, then call `capturer.captureWhenSettled()`, which waits for the map to fully
299
- * settle (see `onTilesLoaded`, reusing this same `tilesLoadedTimeout`/`tilesLoadedFadeMargin`)
300
- * before reading the canvas. The result (a data URL) can be handed to any PDF/document library —
301
- * this doesn't depend on or assume one. */
301
+ /** Called once, after the map loads, with a capturer for grabbing the canvas as an image — works
302
+ * on any map, `offscreen` or not. Change `viewport`/`<Source>`'s `data` the normal declarative
303
+ * way, then call `capturer.captureWhenSettled()`, which waits for the map to fully settle (see
304
+ * `onTilesLoaded`, reusing this same `tilesLoadedTimeout`/`tilesLoadedFadeMargin`) before reading
305
+ * the canvas. The result (a data URL) can be handed to any PDF/document library — this doesn't
306
+ * depend on or assume one. */
302
307
  onCapturerReady?: (capturer: MapCapturer) => void;
303
308
  /** Called if map initialization fails — e.g. `mapLib.supported()` reports the environment can't
304
309
  * run Mapbox/MapLibre GL JS (any WebGL-less context, including Vitest/jsdom), or the underlying
@@ -381,27 +386,20 @@ declare const Source: Component<Props$a>;
381
386
 
382
387
  type FlatLayerStyle = Record<string, any>;
383
388
  type PulseConfig = {
384
- /** The paint property to animate, e.g. `"icon-halo-width"`, `"icon-opacity"`, or a
385
- * `*-color` property (e.g. `"icon-halo-color"`) to fade/shift a color instead of a number.
386
- * Default `"icon-halo-width"` — override for anything other than a symbol layer's halo
387
- * (e.g. `"circle-radius"`/`"circle-opacity"` on a circle layer). */
388
- property?: string;
389
- /** Start value — a number for a plain paint property, or any CSS color string (hex, named,
390
- * rgb/rgba, a Tailwind name, ...) when animating a `*-color` property. Default `0`. */
391
- from?: number | string;
392
- /** Default `4` — see `PULSE_DEFAULTS`'s comment for why this stays under mapbox's fixed
393
- * `icon-halo-width <~ 6 * icon-size` ceiling before the halo fills the whole icon. */
394
- to?: number | string;
395
- /** Full cycle length, in ms. Default `1500`. */
389
+ /** The paint property to animate — a number (e.g. `"circle-radius"`, `"icon-halo-width"`) or a
390
+ * `*-color` property (e.g. `"circle-color"`, `"icon-halo-color"`) to fade/shift a color. No
391
+ * default: which property makes sense depends entirely on the layer type, so this is required. */
392
+ property: string;
393
+ /** Value at the start of each ping — a number, or any CSS color string (hex, named, rgb/rgba, a
394
+ * Tailwind name, oklch(), ...) when animating a `*-color` property. */
395
+ from: number | string;
396
+ /** Value the ping ramps out to before holding and resetting. */
397
+ to: number | string;
398
+ /** Full cycle length, in ms: ramp-out, then hold at `to`, then reset. Default `1500`. */
396
399
  duration?: number;
397
- /** - `"out"` (default): a one-directional ease-out ramp from `from` to `to`, holding at `to`
398
- * for the last quarter of the cycle before resetting — Tailwind's `animate-ping` shape
399
- * (e.g. a ring that grows outward and fades, then disappears until the next cycle). The
400
- * most common "pulsing dot" look.
401
- * - `"in"`: the mirror of `"out"` — ramps from `to` down to `from`, holding at `from`.
402
- * - `"in-out"`: smooth back-and-forth between `from` and `to`, forever (sine-eased) — e.g. a
403
- * halo that grows and shrinks continuously, with no reset. */
404
- waveform?: "in-out" | "out" | "in";
400
+ /** Fraction of `duration` spent held at `to` before the next reset (the remainder is the ramp).
401
+ * Default `0.25`, matching Tailwind's `animate-ping` timing. */
402
+ holdFraction?: number;
405
403
  };
406
404
  type Props$9 = {
407
405
  id?: string;
@@ -427,15 +425,21 @@ type Props$9 = {
427
425
  state: Record<string, any>;
428
426
  };
429
427
  /** An object that specifies the state of a feature in the layer. The object consists of an ID (either a number or a string) and an object containing the state. */
430
- /** Continuously animates one paint property via `setPaintProperty` every animation frame —
431
- * e.g. a growing/fading `icon-halo-width`/`icon-halo-color` for a "pulsing dot" marker. Every
432
- * field defaults (see `PulseConfig`), so `pulse` alone or `pulse={{}}` already pulses a
433
- * symbol layer's halo — override only what you need to customize. Pass an array to drive
434
- * several properties at once (one shared `requestAnimationFrame` loop), e.g. `icon-halo-width`
435
- * and `icon-opacity` together for a combined ping. Driven by real paint properties (not a
436
- * swapped-out image), so it composes with any other paint value, including data-driven
437
- * expressions on other properties of the same layer. */
438
- pulse?: boolean | PulseConfig | PulseConfig[];
428
+ /** A periodic "ping": each cycle resets to `from`, hands the ramp to `to` off to Mapbox's own
429
+ * paint-property transition, then holds at `to` until the next cycle — e.g. a growing/fading
430
+ * `circle-radius`/`circle-color` for a "pulsing dot" marker. Pass an array to drive several
431
+ * properties off one shared cycle (one `setInterval` per entry, all started together), e.g.
432
+ * `circle-radius` and `circle-color` together for a ring that grows *and* fades. Driven by real
433
+ * paint properties (not a swapped-out image), so it composes with any other paint value,
434
+ * including data-driven expressions on other properties of the same layer.
435
+ *
436
+ * Only touches the property twice per cycle (reset + ramp-start) — the ramp itself is animated
437
+ * by Mapbox, not a per-frame `setPaintProperty` loop — so between the ramp finishing and the
438
+ * next cycle's reset, the map genuinely goes idle instead of staying marked dirty forever. That
439
+ * matters beyond just performance: `@mapbox/mapbox-gl-draw`'s own mount logic and this
440
+ * library's `captureWhenSettled()`/`waitUntilSettled()` both depend on the map actually
441
+ * reaching `'idle'`/`loaded()` — a continuously-dirty map silently starves both. */
442
+ pulse?: PulseConfig | PulseConfig[];
439
443
  children?: any;
440
444
  } & layerEventTypes;
441
445
  declare const Layer: Component<Props$9>;
@@ -3,8 +3,8 @@ export { b as MapProvider, a as useMapContext } from '../chunk/BTR7SKE6.js';
3
3
  import { template, isServer, use, insert, memo, createComponent, effect, setAttribute, className, classList, style } from 'solid-js/web';
4
4
  import { createContext, createSignal, onMount, createEffect, on, onCleanup, useContext, createUniqueId, createMemo, splitProps, untrack } from 'solid-js';
5
5
 
6
- var ye=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],ve=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],Me=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"];var S="mapbox://styles/mapbox",A="https://raw.githubusercontent.com/",L="https://raw.githubusercontent.com/GIShub4/map-styles/main/",J="https://assets.vector.hereapi.com/styles/",be={mb:{standard:`${S}/standard`,light:`${S}/light-v11`,dark:`${S}/dark-v11`,street:`${S}/streets-v12`,outdoor:`${S}/outdoors-v12`,sat:`${S}/satellite-v9`,sat_street:`${S}/satellite-streets-v12`,nav_base:`${S}/navigation-guidance-day-v4`,nav_base_night:`${S}/navigation-guidance-night-v4`,nav:`${S}/navigation-day-v1`,nav_night:`${S}/navigation-night-v1`,basic:`${S}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${S}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${S}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${S}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${S}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${S}/cj44mfrt20f082snokim4ungi`,mineral:`${S}/cjtep62gq54l21frr1whf27ak`,moonlight:`${S}/cj3kbeqzo00022smj7akz3o1e`,frank:`${S}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${S}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${S}-map-design/ck4014y110wt61ctt07egsel6`,stand:`${S}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${S}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${S}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${S}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${A}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${A}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${A}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${A}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${A}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${A}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${A}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${A}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${J}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${J}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${J}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${L}esri:blueprint.json`,charted_territory:`${L}esri:charted-territory.json`,colored_pencil:`${L}esri:colored-pencil.json`,community:`${L}esri:community.json`,mid_century:`${L}esri:mid-century.json`,modern_antique:`${L}esri:modern-antique.json`,nat_geo:`${L}esri:national-geographic.json`,newspaper:`${L}esri:newspaper.json`,open_street_map:`${L}esri:open-street-map.json`,light_gray_canvas:`${L}esri:light-gray-canvas.json`,dark_gray_canvas:`${L}esri:dark-gray-canvas.json`,human_geo_light:`${L}esri:human-geography-light.json`,human_geo_dark:`${L}esri:human-geography-dark.json`,world_navigation:`${L}esri:world-navigation.json`,world_street:`${L}esri:world-street.json`,world_street_night:`${L}esri:world-street-night.json`,world_terrain:`${L}esri:world-terrain.json`,world_terrain_hybrid:`${L}esri:world-terrain-hybrid.json`,world_topographic:`${L}esri:world-topographic.json`,chromium:`${L}esri:chromium.json`,dreamcatcher:`${L}esri:dreamcatcher.json`,seahaven:`${L}esri:seahaven.json`,sangria:`${L}esri:sangria.json`,mercurial:`${L}esri:mercurial.json`,imagery:`${L}esri:imagery.json`,imagery_hybrid:`${L}esri:imagery-hybrid.json`,firefly:`${L}esri:firefly.json`,firefly_hybrid:`${L}esri:firefly-hybrid.json`,oceans:`${L}esri:oceans.json`}},ee="https://{s}.basemaps.cartocdn.com/rastertiles/",N="https://stamen-tiles-{s}.a.ssl.fastly.net/",T="https://{s}.tile.thunderforest.com/",te={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>'},carto:{voyager:`${ee}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${ee}light_all/{z}/{x}/{y}{r}.png`,dark:`${ee}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">&copy; Carto</a>'},stamen:{toner:`${N}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${N}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${N}watercolor/{z}/{x}/{y}.png`,terrain:`${N}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">&copy; Stamen Design</a>'},tf:{cycle:`${T}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${T}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${T}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${T}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${T}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${T}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${T}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${T}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${T}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${T}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">&copy; Thunderforest</a>'}};var z=()=>new Promise(e=>requestAnimationFrame(()=>e())),Qe=e=>{try{return !!e.style?.hasTransitions?.()}catch{return false}};function Ke(e,t){return new Promise(n=>{let o=Date.now()+t,r=()=>{if(e.areTilesLoaded()){n(true);return}if(Date.now()>=o){n(false);return}setTimeout(r,100);};r();})}async function q(e,t={}){let{timeout:n=1e4,fadeMargin:o=400}=t;if(await Ke(e,n),e.triggerRepaint(),await z(),await z(),o>0){let r=Date.now()+Math.max(o,2e3);for(;Qe(e)&&Date.now()<r;)e.triggerRepaint(),await z();await new Promise(i=>setTimeout(i,o)),e.triggerRepaint(),await z(),await z();}}function G(e,t={}){return new Promise(n=>{e.once("idle",()=>{q(e,t).then(n);});})}function ne(e){for(let t of e.getStyle()?.layers??[])try{e.setPaintProperty(t.id,"raster-fade-duration",0);}catch{}}function xe(e,t){return {map:e,waitUntilSettled:()=>G(e,t),capture:(n="image/jpeg",o=.92)=>e.getCanvas().toDataURL(n,o),captureWhenSettled:async(n="image/jpeg",o=.92)=>(await G(e,t),e.getCanvas().toDataURL(n,o))}}var st=template("<div>"),lt=template("<style>.overlay{position:relative;width:100%;height:100%;pointer-events:none}:where(.overlay>*){pointer-events:auto}"),ct=template("<div class=overlay>"),pt=e=>{let t,n,o,r,i,a=false,s=0,[c,l]=createSignal(null),[h,m]=createSignal(0),[b$1,d]=createSignal(!isServer&&(window.matchMedia("(prefers-color-scheme: dark)").matches||document.body.classList.contains("dark"))),f=false,v=false,y=(u,g)=>(e.debug||e.debugEvents)&&console.debug("%c[MapGL]","color: #0ea5e9",u,g||""),M=(u,g)=>{let p=b$1()&&g?g:u;return (typeof p=="string"||p instanceof String)&&p?.split(":").reduce((x,E)=>x&&x[E],be)?.replace("{apikey}",e.apikey||import.meta.env?.VITE_VECTOR_API_KEY)||p};onMount(async()=>{try{await C();}catch(u){console.error("[MapGL] Failed to initialize map:",u),e.onError?.(u);}});let C=async()=>{if(i=e.mapLib||await import('mapbox-gl'),i.Map||(i=window.maplibregl||window.mapboxgl),typeof i.supported=="function"&&!i.supported())throw new Error("Mapbox GL not supported");if(a=typeof i.Map?.prototype?.setConfigProperty!="function",y(`Map (v${i.version}) loading...`),t=new i.Map({accessToken:e.options?.accessToken||import.meta.env?.VITE_MAPBOX_ACCESS_TOKEN,interactive:e.options?.interactive||!!e.onViewportChange,...e.options,...e.viewport,projection:e.options?.projection,container:n,style:M(e.options?.style,e.darkStyle),fitBoundsOptions:{padding:e.viewport?.padding},...e.offscreen?{preserveDrawingBuffer:true}:{}}),t.debug=e.debug,t.debugEvents=e.debugEvents,t.sourceIdList=[],t.layerIdList=[],t.isMapLibre=a,ye.forEach(u=>{let g=e[u];if(g){let p=u.slice(2).toLowerCase();typeof g=="function"?t.on(p,x=>{setTimeout(()=>{p==="click"&&x.clickOnLayer||(g(x),e.debugEvents&&y(`Map '${p}' event:`,x));},0);}):Object.keys(g).forEach(x=>{t.on(p,x,E=>{setTimeout(()=>{p==="click"&&E.clickOnLayer||(g[x](E),e.debugEvents&&y(`Map '${p}' event on '${x}':`,E));},0);});});}}),e.onTilesLoaded){let u=e.tilesLoadedTimeout??1e4,g=e.tilesLoadedFadeMargin??400;t.on("idle",()=>{let p=++s;q(t,{timeout:u,fadeMargin:g}).then(()=>{p===s&&(y("Tiles settled"),e.onTilesLoaded());});});}t.once("load",()=>{l(t),y("Map loaded"),e.offscreen&&(e.offscreen.disableRasterFade!==false&&ne(t),e.onCapturerReady?.(xe(t,{timeout:e.tilesLoadedTimeout??1e4,fadeMargin:e.tilesLoadedFadeMargin??400}))),["mousedown","touchstart","wheel"].forEach(g=>t.on(g,p=>!p.rotate&&e.onUserInteraction?.(true))),["moveend","mouseup","touchend"].forEach(g=>t.on(g,p=>!p.rotate&&e.onUserInteraction?.(false)));let u=!isServer&&window.matchMedia("(prefers-color-scheme: dark)");u?.addEventListener("change",()=>{d(u.matches),m(g=>g+1),y("Set dark theme to:",u.matches?.toString());}),r=new MutationObserver(()=>{let g=document.documentElement.classList.contains("dark")||document.body.classList.contains("dark");d(g),m(p=>p+1),y("Set theme to:",g);}),r.observe(document.documentElement,{attributes:true}),r.observe(document.body,{attributes:true}),e.disableResize||(o=new ResizeObserver(()=>{setTimeout(()=>{t?.resize();},0),y("Map resized");}),o.observe(n)),t.on("move",g=>{let p={...e.viewport,id:e.id,point:{x:g.originalEvent?.x,y:g.originalEvent?.y},center:e.viewport?.center?.lat?t.getCenter():[t.getCenter().lng,t.getCenter().lat],zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),inTransit:true,bounds:null};!g.viewport&&e.onViewportChange&&(v=true,e.onViewportChange(p));}),t.on("moveend",g=>{if(f||g.rotate||!e.onViewportChange)return;let p={...e.viewport,inTransit:false};v=true,e.onViewportChange(p);});});};createEffect(on(()=>e.viewport,u=>{if(!t||e.id!==u?.id)return;if(v){v=false;return}let g={...u,...u.bounds?t.cameraForBounds(u.bounds,{bearing:u?.bearing,pitch:u?.pitch,padding:u?.padding}):null};f=true,t.stop(),f=false,t[e.transitionType||"flyTo"](g),y(`Update Viewport (${e.transitionType||"flyTo"}):`,g);},{defer:true})),createEffect(()=>{let u=c();if(typeof u?.setConfigProperty!="function"){u&&e.config&&Object.keys(e.config).length&&y("Config prop is set but this map library has no setConfigProperty (Mapbox Standard Style only) \u2014 skipping");return}for(let g in e.config){if(!g||g==="id")continue;let p=e.config?.id||"basemap",x=e.config[g];u.setConfigProperty(p,g,x),y(`Set Config (${p}:${g}) to:`,x);}}),createEffect(()=>{let u=e.options?.projection;!t||!u||(t.setProjection(u),y("Set Projection to:",u));}),createEffect(()=>{let u=e.cursorStyle;!t||!u||(t.getCanvas().style.cursor=u,y("Set Cursor to:",u));});let P=(u,g)=>(g.forEach(p=>{let x=u.findIndex(E=>p.metadata.smg.beforeType?E.type===p.metadata.smg.beforeType:E.id===p.metadata.smg.beforeId);u=x===-1?[...u,p]:[...u.slice(0,x),p,...u.slice(x)];}),u);return createEffect(u=>{let g=M(e.options?.style,e.darkStyle);if(t?.isStyleLoaded()&&u!==g){let p=t.getStyle(),x=p.layers.filter(_=>t.layerIdList.includes(_.id)),E=Object.keys(p.sources).filter(_=>t.sourceIdList.includes(_)).reduce((_,he)=>({..._,[he]:p.sources[he]}),{}),Q=e.shouldDiffStyle?e.shouldDiffStyle(u,g):true;t.setStyle(g,Q?void 0:{diff:false}),t.once("styledata",()=>{if(!x)return;let _=t.getStyle();t.setStyle({..._,sources:{..._.sources,...E},layers:P(_.layers,x),fog:p.fog,terrain:p.terrain,light:p.light}),y("Set Mapstyle to:",g);});}return g},e.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach(u=>{createEffect(()=>{let g=e[u];!t||!g||(t[u]=g,y(`Set ${u} to:`,g));});}),onCleanup(()=>{o?.disconnect(),r?.disconnect(),s++,t?.remove(),y("Map removed");}),(()=>{var u=st(),g=n;return typeof g=="function"?use(g,u):n=u,insert(u,(()=>{var p=memo(()=>!!c());return ()=>p()&&createComponent(b,{get map(){return c()},mapLib:i,isMapLibre:a,get constants(){return e.constants},get themeVersion(){return h()},get children(){return [lt(),(()=>{var x=ct();return insert(x,()=>e.children),x})()]}})})()),effect(p=>{var x=e.id,E=e?.class,Q=e?.classList,_=e.offscreen?{position:"fixed",left:"-99999px",top:"-99999px",width:`${e.offscreen.width}px`,height:`${e.offscreen.height}px`,...e.style}:{width:"100%",height:"100%",...e.style};return x!==p.e&&setAttribute(u,"id",p.e=x),E!==p.t&&className(u,p.t=E),p.a=classList(u,Q,p.a),p.o=style(u,_,p.o),p},{e:void 0,t:void 0,a:void 0,o:void 0}),u})()};var Ce=createContext(),V=()=>useContext(Ce),Mt=e=>{let[t]=a();e.id??=createUniqueId();let n=(i,a)=>{t.map.debug&&console.debug("%c[MapGL]","color: #ec4899",i,a||"");},o=()=>e.source,r=i=>{let a=i?.split(":").reduce((c,l)=>c&&c[l],te),s=a?{...o(),url:"",tiles:[a.replace("{apikey}",o().apikey||import.meta.env?.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:te[i.split(":")[0]]._copy}:o();return s.tiles&&(s.tiles=["a","b","c"].map(c=>s.tiles[0].replace("{s}",c))),s};switch(t.map.addSource(e.id,r(o().url)),t.map.sourceIdList.push(e.id),n("Add Source:",e.id),o().type){case "geojson":createEffect(()=>{let i=o().data;t.map.getSource(e.id).setData(i||{}),n("Update GeoJSON Data:",e.id);});break;case "image":createEffect(()=>{let i=o().url,a=o().coordinates;t.map.getSource(e.id).updateImage(i,a),n("Update Image Data:",e.id);});break;case "vector":createEffect(()=>{let i=o().url,a=o().tiles,s=t.map.getSource(e.id);i?s.setUrl(i):s.setTiles(a),n("Update Vector Data:",e.id);});break;case "raster":createEffect(()=>{let i=r(o().url),a=t.map.getSource(e.id);i.url?a.setUrl(i.url):a.setTiles(i.tiles),n("Update Raster Data:",e.id);});break}return onCleanup(()=>{t.map?.getStyle().layers.forEach(i=>i.source===e.id&&t.map.removeLayer(i.id)),t.map?.getSource(e.id)&&t.map?.removeSource(e.id),n("Remove Source:",e.id);}),createComponent(Ce.Provider,{get value(){return e.id},get children(){return e.children}})};var Se=["id","type","filter","source","source-layer","minzoom","metadata","maxzoom","paint","layout"],Pe=["visibility","line-join","line-cap","line-miter-limit","line-round-limit","line-sort-key","circle-sort-key","symbol-avoid-edges","symbol-placement","symbol-sort-key","symbol-spacing","symbol-z-order","icon-allow-overlap","icon-anchor","icon-ignore-placement","icon-image","icon-keep-upright","icon-offset","icon-optional","icon-padding","icon-pitch-alignment","icon-rotate","icon-rotation-alignment","icon-size","icon-text-fit","icon-text-fit-padding","text-allow-overlap","text-anchor","text-field","text-font","text-ignore-placement","text-justify","text-keep-upright","text-letter-spacing","text-line-height","text-max-angle","text-max-width","text-offset","text-optional","text-padding","text-pitch-alignment","text-radial-offset","text-rotate","text-rotation-alignment","text-size","text-transform","text-variable-anchor","text-writing-mode"];var O,ae=e=>(O??=document.body.appendChild(document.createElement("div")),O.style.cssText="position:absolute;visibility:hidden;pointer-events:none",O.style.color="",O.style.color=e,O.style.color?getComputedStyle(O).color:void 0),bt=/^[a-z]+-\d{2,3}$/,xt=/^(rgb|rgba|hsl|hsla)\(/i,wt=/^[a-z-]+\(/i,U,Lt=/^bg-[a-z]+-\d{2,3}(?:\s+dark:bg-[a-z]+-\d{2,3})?$/,Ct=e=>{U??=document.body.appendChild(document.createElement("div")),U.style.cssText="position:absolute;visibility:hidden;pointer-events:none",U.className=e;let t=getComputedStyle(U).backgroundColor;return U.className="",t&&t!=="rgba(0, 0, 0, 0)"?t:e},ie=e=>{if(Lt.test(e))return Ct(e);if(bt.test(e)){let t=getComputedStyle(document.documentElement).getPropertyValue(`--color-${e}`).trim();return t&&ae(t)||e}return wt.test(e)&&!xt.test(e)&&ae(e)||e},se=e=>{let n=(ae(ie(e))??e).match(/rgba?\(([^)]+)\)/i);if(!n)return [0,0,0,1];let[o,r,i,a=1]=n[1].split(",").map(Number);return [o,r,i,a]};var Et={property:"icon-halo-width",from:0,to:4,duration:1500,waveform:"out"},kt=.75,_t=e=>1-(1-e)*(1-e),It=(e,t,n)=>{let o=e%t/t;if(n==="in-out")return (1-Math.cos(o*Math.PI*2))/2;let r=Math.min(o/kt,1);return _t(r)},Tt=(e,t,n)=>{let o=Math.round(e[0]+(t[0]-e[0])*n),r=Math.round(e[1]+(t[1]-e[1])*n),i=Math.round(e[2]+(t[2]-e[2])*n),a=e[3]+(t[3]-e[3])*n;return `rgba(${o}, ${r}, ${i}, ${a})`},ke=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce((o,r)=>{let i=e[r];return i!==t[r]&&o.push([r,i]),o},[]),le=(e,t)=>(e.startsWith(t)||e.startsWith("icon")||e.startsWith("text")?"":t+"-")+e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),$t=["slot","filter","visible","beforeId","beforeType"],_e=(e,t)=>e.endsWith("color")?Array.isArray(t)?t.map(n=>_e(e,n)):typeof t=="string"?ie(t):t:t,At=/^@(.+)$/,Y=(e,t,n,o)=>{if(Array.isArray(t))return t.map(a=>Y(e,a,n,o));if(typeof t!="string")return t;let r=t.match(At);if(!r)return t;let i=n[r[1]];return i===void 0?(o(`Unknown constant "@${r[1]}" referenced by "${e}" \u2014 leaving unresolved`),t):i},ce=(e,t={},n=()=>{})=>{if(!e)return;let o={},r={},i={},a=(s,c)=>_e(s,Y(s,c,t,n));return Object.entries(e).forEach(([s,c])=>{if(Se.includes(s))i[s]=c;else {$t.includes(s)&&n(`"${s}" is a <Layer> prop, not a style property \u2014 belongs outside "style", not inside it. Treating it as a paint/layout property instead.`);let l=le(s,e.type);Pe.includes(l)?o[l]=Y(l,c,t,n):r[l]=a(l,c);}}),e.paint&&Object.entries(e.paint).forEach(([s,c])=>{let l=le(s,e.type);r[l]=a(l,c);}),e.layout&&Object.entries(e.layout).forEach(([s,c])=>{let l=le(s,e.type);o[l]=Y(l,c,t,n);}),{...i,paint:r,layout:o}},Ft=e=>{let[t]=a(),n=e.sourceId||e.style?.source||V(),o=e.id||e.customLayer?.id||createUniqueId(),r=(a,s)=>{(t.map.debug||t.map.debugEvents)&&console.debug("%c[MapGL]","color: #10b981",a,s||"");},i=createMemo(()=>e.beforeType?t.map.getStyle().layers.find(a=>a.type===e.beforeType)?.id:e.beforeId);return t.map.addLayer(e.customLayer||{...ce(e.style,t.constants,r),id:o,source:n,...t.isMapLibre?{}:{slot:e.slot||""},metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},i()),t.map.layerIdList.push(o),e.customLayer&&t.map.fire("load"),r("Add Layer:",o),ve.forEach(a=>{if(e[a]){let s=a.slice(2).toLowerCase();t.map.on(s,o,c=>{s==="click"&&(c.clickOnLayer=true),e[a](c),t.map.debugEvents&&r(`Layer '${s}' event on '${o}':`,c);});}}),createEffect(a=>{t.themeVersion;let s=ce(e.style,t.constants,r);if(s!==a)return s.layout!==a?.layout&&ke(s.layout,a?.layout).forEach(([c,l])=>t.map.setLayoutProperty(o,c,l,{validate:false})),s.paint!==a?.paint&&ke(s.paint,a?.paint).forEach(([c,l])=>t.map.setPaintProperty(o,c,l,{validate:false})),(s.minzoom!==a?.minzoom||s.maxzoom!==a?.maxzoom)&&t.map.setLayerZoomRange(o,s.minzoom,s.maxzoom),s.filter!==a?.filter&&t.map.setFilter(o,s.filter,{validate:false}),r("Update Layer Style:",o),s},ce(e.style,t.constants,r)),createEffect(a=>{if(e.visible!==a)return t.map.setLayoutProperty(o,"visibility",e.visible?"visible":"none",{validate:false}),r(`Update Visibility (${o}):`,e.visible.toString()),e.visible},e.visible),createEffect(a=>i()===a?a:(t.map.moveLayer(o,i()),r(`Update Layer Z-Index (${o}):`,i()),i()),i()),createEffect(a=>e.filter===a||a===void 0&&!e.filter?a:(t.map.setFilter(o,e.filter??null),r(`Update Filter (${o}):`,e.filter),e.filter),void 0),createEffect(async()=>{!e.featureState||e.featureState.id===null||(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:n,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:n,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state));}),createEffect(()=>{if(!e.pulse)return;let s=(e.pulse===true?[{}]:Array.isArray(e.pulse)?e.pulse:[e.pulse]).map(m=>{let{property:b,from:d,to:f,duration:v,waveform:y}={...Et,...m},M=typeof d=="string"||typeof f=="string",[C,P]=y==="in"?[f,d]:[d,f];return {property:b,duration:v,waveform:y,isColor:M,fromNum:M?0:C,toNum:M?0:P,fromRgba:M?se(C):null,toRgba:M?se(P):null}});s.forEach(m=>{t.map.setPaintProperty(o,`${m.property}-transition`,{duration:0,delay:0},{validate:false});});let c=performance.now(),l,h=m=>{let b=m-c;s.forEach(d=>{let f=It(b,d.duration,d.waveform),v=d.isColor?Tt(d.fromRgba,d.toRgba,f):d.fromNum+(d.toNum-d.fromNum)*f;t.map.setPaintProperty(o,d.property,v,{validate:false});}),l=window.requestAnimationFrame(h);};l=window.requestAnimationFrame(h),r(`Start Pulse (${o}):`,e.pulse),onCleanup(()=>window.cancelAnimationFrame(l));}),onCleanup(()=>t.map?.getLayer(o)&&t.map?.removeLayer(o)),e.children};var Ie=createContext(),Nt=()=>useContext(Ie),qt=e=>{let[t]=a(),[n,o]=createSignal(null);return onMount(async()=>{e.id=e.id||createUniqueId();let r=t.mapLib.MercatorCoordinate.fromLngLat([e.origin[0]||0,e.origin[1]||0],e.origin[2]||0),i=r.meterInMercatorCoordinateUnits(),{x:a,y:s,z:c}=r,l=null,h=null,m=null;e.babylon?(h=await import('@babylonjs/core'),l=h.Matrix.Compose(new h.Vector3(i,i,i),h.Quaternion.FromEulerAngles(Math.PI/2,0,0),new h.Vector3(a,s,c))):(m=await import('three'),l={translateX:a,translateY:s,translateZ:c,rotateX:Math.PI/2,rotateY:0,rotateZ:0,scale:i}),t.map.addLayer({id:e.id,type:"custom",renderingMode:"3d",onAdd(b,d){if(e.babylon){let f=new h.Engine(d,true,{useHighPrecisionMatrix:true},true);this.scene=new h.Scene(f),this.scene.autoClear=false,this.scene.preventDefaultOnPointerDown=false,this.scene.preventDefaultOnPointerUp=false;let v=new h.UniversalCamera("Camera",h.Vector3.Zero());v.mode=h.Camera.ORTHOGRAPHIC_CAMERA,v.inertia=0,this.scene.ambientColor=new h.Color3(1,1,1),e.defaultLight&&new h.HemisphericLight("Light",new h.Vector3(100,10,0),this.scene);}else this.camera=new m.Camera,this.scene=new m.Scene,e.defaultLight&&(this.light=new m.DirectionalLight(16777215),this.light.position.set(100,0,0).normalize(),this.scene.add(this.light)),this.renderer=new m.WebGLRenderer({canvas:b.getCanvas(),context:d,antialias:true}),this.renderer.autoClear=false;this.map=b,e.onAdd&&e.onAdd(this.scene,this.map,d),o(this.scene);},render(b,d){if(e.babylon){this.scene.activeCamera.freezeProjectionMatrix(l.multiply(h.Matrix.FromArray(d)));this.map.getPitch()*(Math.PI/180);this.map.getBearing()*(Math.PI/180);this.scene.render(false);}else {let f=new m.Matrix4().makeRotationAxis(new m.Vector3(1,0,0),l.rotateX),v=new m.Matrix4().makeRotationAxis(new m.Vector3(0,1,0),l.rotateY),y=new m.Matrix4().makeRotationAxis(new m.Vector3(0,0,1),l.rotateZ),M=new m.Matrix4().fromArray(d),C=new m.Matrix4().makeTranslation(l.translateX,l.translateY,l.translateZ).scale(new m.Vector3(l.scale,-l.scale,l.scale)).multiply(f).multiply(v).multiply(y);this.camera.projectionMatrix=M.multiply(C),this.renderer.resetState(),this.renderer.render(this.scene,this.camera);}e.onRender&&e.onRender(b,d),t.map.triggerRepaint();}},e.beforeId);}),onCleanup(()=>{t.map.getLayer(e.id)&&t.map.removeLayer(e.id);}),createComponent(Ie.Provider,{value:n,get children(){return memo(()=>!!n())()&&e.children}})};var Yt=e=>{let[t]=a();return createEffect(()=>{t.isMapLibre?t.map.setSky?.(e.style||{}):t.map.setFog(e.style||{});}),onCleanup(()=>{t.isMapLibre?t.map.getSky?.()&&t.map.setSky(null):t.map.getFog()&&t.map.setFog(null);}),null};var Qt=e=>{let[t]=a(),n=V();return !n&&!e?.source&&(n=createUniqueId(),t.map.addSource(n,{type:"raster-dem",url:t.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.isMapLibre?256:512,maxzoom:t.isMapLibre?void 0:14}),t.map.sourceIdList.push(n)),createEffect(()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e?.source||n});}),onCleanup(()=>t.map?.setTerrain(null)),null};var X=(e,t)=>{let[n]=a();createEffect(()=>{let o=e(),r=t?.();o&&(n.map.hasControl(o)&&n.map.removeControl(o),n.map.addControl(o,r));}),onCleanup(()=>{let o=e();o&&n.map.hasControl(o)&&n.map.removeControl(o);});};var rn=e=>{let[t]=a(),[n,o]=splitProps(e,["position"]),[r,i]=createSignal(null),a$1=new Map([["navigation",t.mapLib.NavigationControl],["scale",t.mapLib.ScaleControl],["attribution",t.mapLib.AttributionControl],["geolocate",t.mapLib.GeolocateControl],["fullscreen",t.mapLib.FullscreenControl],["logo",t.mapLib.LogoControl],["terrain",t.mapLib.TerrainControl]]);return createEffect(()=>{untrack(()=>r()&&t.map.hasControl(r())&&t.map.removeControl(r())),i(o.custom||new(a$1.get(o.type||"navigation"))(o.options));}),X(r,()=>n.position),null};var ln=e=>{if(!e.lngLat)throw new Error("Marker - lngLat is required");let[t,n,o]=splitProps(e,["lngLat","children","showPopup","draggable"],["popup","onOpen","onClose"]),[r]=a(),i=null,a$1=null,s=t.lngLat;return createEffect(()=>{r.map&&(a$1?.remove(),a$1=new r.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...n.popup}).on("open",()=>n.onOpen?.()).on("close",()=>n.onClose?.()),createEffect(()=>{t.children!==void 0&&(typeof t.children=="string"?a$1?.setHTML(t.children):a$1?.setDOMContent(t.children),i?.setPopup(a$1));}),createEffect(()=>t.showPopup!==a$1?.isOpen()&&i?.togglePopup()));}),createEffect(()=>{r.map&&(i?.remove(),i=new r.mapLib.Marker(o.options).on("dragstart",()=>o.onDragStart?.()).on("dragend",()=>o.onDragEnd?.()).on("drag",()=>o.onDrag?.(i?.getLngLat().toArray())).setPopup(a$1).setLngLat(s).addTo(r.map),createEffect(()=>t.showPopup!==a$1?.isOpen()&&i?.togglePopup()));}),createEffect(()=>i?.setLngLat(t.lngLat)),createEffect(()=>i?.setDraggable(t.draggable)),onCleanup(()=>i?.remove()),null};var un=e=>{if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");let[t,n]=splitProps(e,["lngLat","children","trackPointer"]),[o]=a(),r;return createEffect(()=>{o.map&&(r?.remove(),r=new o.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...n.options}).on("open",()=>n.onOpen?.()).on("close",()=>n.onClose?.()).addTo(o.map),createEffect(()=>t.trackPointer?r.trackPointer():r.setLngLat(t.lngLat)),createEffect(()=>typeof t.children=="string"?r.setHTML(t.children):r.setDOMContent(t.children)));}),onCleanup(()=>r?.remove()),null};var ue=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-Math.pow(e/255,.45454545454545453);ue[e]=t*Math.abs(t);}ue[255]=-1e20;function Te(e,t,n,o,r,i,a){i[0]=0,a[0]=-1e20,a[1]=1e20,r[0]=e[t];for(let s=1,c=0,l=0;s<o;s++){r[s]=e[t+s*n];let h=s*s;do{let m=i[c];l=(r[s]-r[m]+h-m*m)/(s-m)/2;}while(l<=a[c]&&--c>-1);c++,i[c]=s,a[c]=l,a[c+1]=1e20;}for(let s=0,c=0;s<o;s++){for(;a[c+1]<s;)c++;let l=i[c],h=s-l;e[t+s*n]=r[l]+h*h;}}function $e(e,t,n,o,r,i){for(let a=0;a<t;a++)Te(e,a,t,n,o,r,i);for(let a=0;a<n;a++)Te(e,a*t,1,t,o,r,i);}var me=({radius:e=8}={})=>Math.ceil(e);function W(e,{radius:t=8,cutoff:n=.25}={}){let{width:o,height:r}=e,i=o*r,a=new Float64Array(i).fill(1e20),s=new Float64Array(i),c=Math.max(o,r),l=new Float64Array(c),h=new Uint16Array(c),m=new Float64Array(c+1),b=e.data;for(let y=0,M=3;y<i;y++,M+=4){let C=b[M];if(C===0)continue;let P=ue[C];a[y]=Math.max(0,P),s[y]=Math.max(0,-P);}$e(a,o,r,l,h,m),$e(s,o,r,l,h,m);let d=255/t,f=255*(1-n),v=new Uint8ClampedArray(i*4);for(let y=0,M=0;y<i;y++,M+=4){let C=Math.sqrt(a[y])-Math.sqrt(s[y]),P=Math.max(0,Math.min(255,Math.round(f-d*C)));v[M]=v[M+1]=v[M+2]=255,v[M+3]=P;}return {width:o,height:r,data:v}}var pe={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:true},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:true},grid:{size:20,path:"M10 0V20M0 10H20"},brick:{size:40,path:"M0 0H40M0 20H40M0 40H40M0 0V20M20 0V20M40 0V20M10 20V40M30 20V40"},wave:{size:20,path:"M0 5Q5 0 10 5T20 5M0 15Q5 10 10 15T20 15"}},Ae=Object.keys(pe),k=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke-linecap="round" stroke-linejoin="round">
6
+ var fe=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],he=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],ye=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"];var C="mapbox://styles/mapbox",A="https://raw.githubusercontent.com/",L="https://raw.githubusercontent.com/GIShub4/map-styles/main/",ee="https://assets.vector.hereapi.com/styles/",ve={mb:{standard:`${C}/standard`,light:`${C}/light-v11`,dark:`${C}/dark-v11`,street:`${C}/streets-v12`,outdoor:`${C}/outdoors-v12`,sat:`${C}/satellite-v9`,sat_street:`${C}/satellite-streets-v12`,nav_base:`${C}/navigation-guidance-day-v4`,nav_base_night:`${C}/navigation-guidance-night-v4`,nav:`${C}/navigation-day-v1`,nav_night:`${C}/navigation-night-v1`,basic:`${C}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${C}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${C}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${C}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${C}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${C}/cj44mfrt20f082snokim4ungi`,mineral:`${C}/cjtep62gq54l21frr1whf27ak`,moonlight:`${C}/cj3kbeqzo00022smj7akz3o1e`,frank:`${C}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${C}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${C}-map-design/ck4014y110wt61ctt07egsel6`,stand:`${C}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${C}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${C}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${C}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${A}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${A}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${A}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${A}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${A}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${A}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${A}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${A}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${ee}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${ee}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${ee}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${L}esri:blueprint.json`,charted_territory:`${L}esri:charted-territory.json`,colored_pencil:`${L}esri:colored-pencil.json`,community:`${L}esri:community.json`,mid_century:`${L}esri:mid-century.json`,modern_antique:`${L}esri:modern-antique.json`,nat_geo:`${L}esri:national-geographic.json`,newspaper:`${L}esri:newspaper.json`,open_street_map:`${L}esri:open-street-map.json`,light_gray_canvas:`${L}esri:light-gray-canvas.json`,dark_gray_canvas:`${L}esri:dark-gray-canvas.json`,human_geo_light:`${L}esri:human-geography-light.json`,human_geo_dark:`${L}esri:human-geography-dark.json`,world_navigation:`${L}esri:world-navigation.json`,world_street:`${L}esri:world-street.json`,world_street_night:`${L}esri:world-street-night.json`,world_terrain:`${L}esri:world-terrain.json`,world_terrain_hybrid:`${L}esri:world-terrain-hybrid.json`,world_topographic:`${L}esri:world-topographic.json`,chromium:`${L}esri:chromium.json`,dreamcatcher:`${L}esri:dreamcatcher.json`,seahaven:`${L}esri:seahaven.json`,sangria:`${L}esri:sangria.json`,mercurial:`${L}esri:mercurial.json`,imagery:`${L}esri:imagery.json`,imagery_hybrid:`${L}esri:imagery-hybrid.json`,firefly:`${L}esri:firefly.json`,firefly_hybrid:`${L}esri:firefly-hybrid.json`,oceans:`${L}esri:oceans.json`}},te="https://{s}.basemaps.cartocdn.com/rastertiles/",N="https://stamen-tiles-{s}.a.ssl.fastly.net/",T="https://{s}.tile.thunderforest.com/",ne={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>'},carto:{voyager:`${te}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${te}light_all/{z}/{x}/{y}{r}.png`,dark:`${te}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">&copy; Carto</a>'},stamen:{toner:`${N}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${N}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${N}watercolor/{z}/{x}/{y}.png`,terrain:`${N}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">&copy; Stamen Design</a>'},tf:{cycle:`${T}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${T}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${T}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${T}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${T}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${T}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${T}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${T}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${T}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${T}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">&copy; Thunderforest</a>'}};var z=()=>new Promise(e=>requestAnimationFrame(()=>e())),He=e=>{try{return !!e.style?.hasTransitions?.()}catch{return false}};function Qe(e,t){return new Promise(n=>{let o=Date.now()+t,r=()=>{if(e.areTilesLoaded()){n(true);return}if(Date.now()>=o){n(false);return}setTimeout(r,100);};r();})}async function q(e,t={}){let{timeout:n=1e4,fadeMargin:o=400}=t;if(await Qe(e,n),e.triggerRepaint(),await z(),await z(),o>0){let r=Date.now()+Math.max(o,2e3);for(;He(e)&&Date.now()<r;)e.triggerRepaint(),await z();await new Promise(i=>setTimeout(i,o)),e.triggerRepaint(),await z(),await z();}}function G(e,t={}){return new Promise(n=>{e.once("idle",()=>{q(e,t).then(n);}),e.triggerRepaint();})}function oe(e){for(let t of e.getStyle()?.layers??[])try{e.setPaintProperty(t.id,"raster-fade-duration",0);}catch{}}function Me(e,t){return {map:e,waitUntilSettled:()=>G(e,t),capture:(n="image/jpeg",o=.92)=>e.getCanvas().toDataURL(n,o),captureWhenSettled:async(n="image/jpeg",o=.92)=>(await G(e,t),e.getCanvas().toDataURL(n,o))}}var it=template("<div>"),st=template("<style>.overlay{position:relative;width:100%;height:100%;pointer-events:none}:where(.overlay>*){pointer-events:auto}"),lt=template("<div class=overlay>"),mt=e=>{let t,n,o,r,i,a=false,s=0,[c,l]=createSignal(null),[g,m]=createSignal(0),[M,f]=createSignal(!isServer&&(window.matchMedia("(prefers-color-scheme: dark)").matches||document.body.classList.contains("dark"))),h=false,v=false,y=(d,p)=>(e.debug||e.debugEvents)&&console.debug("%c[MapGL]","color: #0ea5e9",d,p||""),b$1=(d,p)=>{let u=M()&&p?p:d;return (typeof u=="string"||u instanceof String)&&u?.split(":").reduce((x,P)=>x&&x[P],ve)?.replace("{apikey}",e.apikey||import.meta.env?.VITE_VECTOR_API_KEY)||u};onMount(async()=>{try{await S();}catch(d){console.error("[MapGL] Failed to initialize map:",d),e.onError?.(d);}});let S=async()=>{if(i=e.mapLib||await import('mapbox-gl'),i.Map||(i=window.maplibregl||window.mapboxgl),typeof i.supported=="function"&&!i.supported())throw new Error("Mapbox GL not supported");if(a=typeof i.Map?.prototype?.setConfigProperty!="function",y(`Map (v${i.version}) loading...`),t=new i.Map({accessToken:e.options?.accessToken||import.meta.env?.VITE_MAPBOX_ACCESS_TOKEN,interactive:e.options?.interactive||!!e.onViewportChange,...e.options,...e.viewport,projection:e.options?.projection,container:n,style:b$1(e.options?.style,e.darkStyle),fitBoundsOptions:{padding:e.viewport?.padding},...e.offscreen?{preserveDrawingBuffer:true}:{}}),t.debug=e.debug,t.debugEvents=e.debugEvents,t.sourceIdList=[],t.layerIdList=[],t.isMapLibre=a,fe.forEach(d=>{let p=e[d];if(p){let u=d.slice(2).toLowerCase();typeof p=="function"?t.on(u,x=>{setTimeout(()=>{u==="click"&&x.clickOnLayer||(p(x),e.debugEvents&&y(`Map '${u}' event:`,x));},0);}):Object.keys(p).forEach(x=>{t.on(u,x,P=>{setTimeout(()=>{u==="click"&&P.clickOnLayer||(p[x](P),e.debugEvents&&y(`Map '${u}' event on '${x}':`,P));},0);});});}}),e.onTilesLoaded){let d=e.tilesLoadedTimeout??1e4,p=e.tilesLoadedFadeMargin??400;t.on("idle",()=>{let u=++s;q(t,{timeout:d,fadeMargin:p}).then(()=>{u===s&&(y("Tiles settled"),e.onTilesLoaded());});});}t.once("load",()=>{l(t),y("Map loaded"),e.offscreen&&e.offscreen.disableRasterFade!==false&&oe(t),e.onCapturerReady&&e.onCapturerReady(Me(t,{timeout:e.tilesLoadedTimeout??1e4,fadeMargin:e.tilesLoadedFadeMargin??400})),["mousedown","touchstart","wheel"].forEach(p=>t.on(p,u=>!u.rotate&&e.onUserInteraction?.(true))),["moveend","mouseup","touchend"].forEach(p=>t.on(p,u=>!u.rotate&&e.onUserInteraction?.(false)));let d=!isServer&&window.matchMedia("(prefers-color-scheme: dark)");d?.addEventListener("change",()=>{f(d.matches),m(p=>p+1),y("Set dark theme to:",d.matches?.toString());}),r=new MutationObserver(()=>{let p=document.documentElement.classList.contains("dark")||document.body.classList.contains("dark");f(p),m(u=>u+1),y("Set theme to:",p);}),r.observe(document.documentElement,{attributes:true}),r.observe(document.body,{attributes:true}),e.disableResize||(o=new ResizeObserver(()=>{setTimeout(()=>{t?.resize();},0),y("Map resized");}),o.observe(n)),t.on("move",p=>{let u={...e.viewport,id:e.id,point:{x:p.originalEvent?.x,y:p.originalEvent?.y},center:e.viewport?.center?.lat?t.getCenter():[t.getCenter().lng,t.getCenter().lat],zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),inTransit:true,bounds:null};!p.viewport&&e.onViewportChange&&(v=true,e.onViewportChange(u));}),t.on("moveend",p=>{if(h||p.rotate||!e.onViewportChange)return;let u={...e.viewport,inTransit:false};v=true,e.onViewportChange(u);});});};createEffect(on(()=>e.viewport,d=>{if(!t||e.id!==d?.id)return;if(v){v=false;return}let p={...d,...d.bounds?t.cameraForBounds(d.bounds,{bearing:d?.bearing,pitch:d?.pitch,padding:d?.padding}):null};h=true,t.stop(),h=false,t[e.transitionType||"flyTo"](p),y(`Update Viewport (${e.transitionType||"flyTo"}):`,p);},{defer:true})),createEffect(()=>{let d=c();if(typeof d?.setConfigProperty!="function"){d&&e.config&&Object.keys(e.config).length&&y("Config prop is set but this map library has no setConfigProperty (Mapbox Standard Style only) \u2014 skipping");return}for(let p in e.config){if(!p||p==="id")continue;let u=e.config?.id||"basemap",x=e.config[p];d.setConfigProperty(u,p,x),y(`Set Config (${u}:${p}) to:`,x);}}),createEffect(()=>{let d=e.options?.projection;!t||!d||(t.setProjection(d),y("Set Projection to:",d));}),createEffect(()=>{let d=e.cursorStyle;!t||!d||(t.getCanvas().style.cursor=d,y("Set Cursor to:",d));});let k=(d,p)=>(p.forEach(u=>{let x=d.findIndex(P=>u.metadata.smg.beforeType?P.type===u.metadata.smg.beforeType:P.id===u.metadata.smg.beforeId);d=x===-1?[...d,u]:[...d.slice(0,x),u,...d.slice(x)];}),d);return createEffect(d=>{let p=b$1(e.options?.style,e.darkStyle);if(t&&d!==p){let u=t.getStyle(),x=u.layers.filter(_=>t.layerIdList.includes(_.id)),P=Object.keys(u.sources).filter(_=>t.sourceIdList.includes(_)).reduce((_,ge)=>({..._,[ge]:u.sources[ge]}),{}),K=e.shouldDiffStyle?e.shouldDiffStyle(d,p):true;t.setStyle(p,K?void 0:{diff:false}),t.once("styledata",()=>{if(!x)return;let _=t.getStyle();t.setStyle({..._,sources:{..._.sources,...P},layers:k(_.layers,x),fog:u.fog,terrain:u.terrain,light:u.light}),y("Set Mapstyle to:",p);});}return p},e.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach(d=>{createEffect(()=>{let p=e[d];!t||!p||(t[d]=p,y(`Set ${d} to:`,p));});}),onCleanup(()=>{o?.disconnect(),r?.disconnect(),s++,t?.remove(),y("Map removed");}),(()=>{var d=it(),p=n;return typeof p=="function"?use(p,d):n=d,insert(d,(()=>{var u=memo(()=>!!c());return ()=>u()&&createComponent(b,{get map(){return c()},mapLib:i,isMapLibre:a,get constants(){return e.constants},get themeVersion(){return g()},get children(){return [st(),(()=>{var x=lt();return insert(x,()=>e.children),x})()]}})})()),effect(u=>{var x=e.id,P=e?.class,K=e?.classList,_=e.offscreen?{position:"fixed",left:"-99999px",top:"-99999px",width:`${e.offscreen.width}px`,height:`${e.offscreen.height}px`,...e.style}:{width:"100%",height:"100%",...e.style};return x!==u.e&&setAttribute(d,"id",u.e=x),P!==u.t&&className(d,u.t=P),u.a=classList(d,K,u.a),u.o=style(d,_,u.o),u},{e:void 0,t:void 0,a:void 0,o:void 0}),d})()};var we=createContext(),V=()=>useContext(we),vt=e=>{let[t]=a();e.id??=createUniqueId();let n=(i,a)=>{t.map.debug&&console.debug("%c[MapGL]","color: #ec4899",i,a||"");},o=()=>e.source,r=i=>{let a=i?.split(":").reduce((c,l)=>c&&c[l],ne),s=a?{...o(),url:"",tiles:[a.replace("{apikey}",o().apikey||import.meta.env?.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:ne[i.split(":")[0]]._copy}:o();return s.tiles&&(s.tiles=["a","b","c"].map(c=>s.tiles[0].replace("{s}",c))),s};switch(t.map.addSource(e.id,r(o().url)),t.map.sourceIdList.push(e.id),n("Add Source:",e.id),o().type){case "geojson":createEffect(()=>{let i=o().data,a=t.map.getSource(e.id);a&&(a.setData(i||{}),n("Update GeoJSON Data:",e.id));});break;case "image":createEffect(()=>{let i=o().url,a=o().coordinates,s=t.map.getSource(e.id);s&&(s.updateImage(i,a),n("Update Image Data:",e.id));});break;case "vector":createEffect(()=>{let i=o().url,a=o().tiles,s=t.map.getSource(e.id);s&&(i?s.setUrl(i):s.setTiles(a),n("Update Vector Data:",e.id));});break;case "raster":createEffect(()=>{let i=r(o().url),a=t.map.getSource(e.id);a&&(i.url?a.setUrl(i.url):a.setTiles(i.tiles),n("Update Raster Data:",e.id));});break}return onCleanup(()=>{t.map?.getStyle().layers.forEach(i=>i.source===e.id&&t.map.removeLayer(i.id)),t.map?.getSource(e.id)&&t.map?.removeSource(e.id),n("Remove Source:",e.id);}),createComponent(we.Provider,{get value(){return e.id},get children(){return e.children}})};var Le=["id","type","filter","source","source-layer","minzoom","metadata","maxzoom","paint","layout"],Ce=["visibility","line-join","line-cap","line-miter-limit","line-round-limit","line-sort-key","circle-sort-key","symbol-avoid-edges","symbol-placement","symbol-sort-key","symbol-spacing","symbol-z-order","icon-allow-overlap","icon-anchor","icon-ignore-placement","icon-image","icon-keep-upright","icon-offset","icon-optional","icon-padding","icon-pitch-alignment","icon-rotate","icon-rotation-alignment","icon-size","icon-text-fit","icon-text-fit-padding","text-allow-overlap","text-anchor","text-field","text-font","text-ignore-placement","text-justify","text-keep-upright","text-letter-spacing","text-line-height","text-max-angle","text-max-width","text-offset","text-optional","text-padding","text-pitch-alignment","text-radial-offset","text-rotate","text-rotation-alignment","text-size","text-transform","text-variable-anchor","text-writing-mode"];var O,Se=e=>(O??=document.body.appendChild(document.createElement("div")),O.style.cssText="position:absolute;visibility:hidden;pointer-events:none",O.style.color="",O.style.color=e,O.style.color?getComputedStyle(O).color:void 0),Mt=/^[a-z]+-\d{2,3}$/,bt=/^(rgb|rgba|hsl|hsla)\(/i,xt=/^[a-z-]+\(/i,U,wt=/^bg-[a-z]+-\d{2,3}(?:\s+dark:bg-[a-z]+-\d{2,3})?$/,Lt=e=>{U??=document.body.appendChild(document.createElement("div")),U.style.cssText="position:absolute;visibility:hidden;pointer-events:none",U.className=e;let t=getComputedStyle(U).backgroundColor;return U.className="",t&&t!=="rgba(0, 0, 0, 0)"?t:e},Pe=e=>{if(wt.test(e))return Lt(e);if(Mt.test(e)){let t=getComputedStyle(document.documentElement).getPropertyValue(`--color-${e}`).trim();return t&&Se(t)||e}return xt.test(e)&&!bt.test(e)&&Se(e)||e};var ke=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce((o,r)=>{let i=e[r];return i!==t[r]&&o.push([r,i]),o},[]),ie=(e,t)=>(e.startsWith(t)||e.startsWith("icon")||e.startsWith("text")?"":t+"-")+e.replace(/[A-Z]/g,n=>"-"+n.toLowerCase()),Pt=["slot","filter","visible","beforeId","beforeType"],X=(e,t)=>e.endsWith("color")?Array.isArray(t)?t.map(n=>X(e,n)):typeof t=="string"?Pe(t):t:t,Et=/^@(.+)$/,Y=(e,t,n,o)=>{if(Array.isArray(t))return t.map(a=>Y(e,a,n,o));if(typeof t!="string")return t;let r=t.match(Et);if(!r)return t;let i=n[r[1]];return i===void 0?(o(`Unknown constant "@${r[1]}" referenced by "${e}" \u2014 leaving unresolved`),t):i},se=(e,t={},n=()=>{})=>{if(!e)return;let o={},r={},i={},a=(s,c)=>X(s,Y(s,c,t,n));return Object.entries(e).forEach(([s,c])=>{if(Le.includes(s))i[s]=c;else {Pt.includes(s)&&n(`"${s}" is a <Layer> prop, not a style property \u2014 belongs outside "style", not inside it. Treating it as a paint/layout property instead.`);let l=ie(s,e.type);Ce.includes(l)?o[l]=Y(l,c,t,n):r[l]=a(l,c);}}),e.paint&&Object.entries(e.paint).forEach(([s,c])=>{let l=ie(s,e.type);r[l]=a(l,c);}),e.layout&&Object.entries(e.layout).forEach(([s,c])=>{let l=ie(s,e.type);o[l]=Y(l,c,t,n);}),{...i,paint:r,layout:o}},kt=e=>{let[t]=a(),n=e.sourceId||e.style?.source||V(),o=e.id||e.customLayer?.id||createUniqueId(),r=(a,s)=>{(t.map.debug||t.map.debugEvents)&&console.debug("%c[MapGL]","color: #10b981",a,s||"");},i=createMemo(()=>e.beforeType?t.map.getStyle().layers.find(a=>a.type===e.beforeType)?.id:e.beforeId);return t.map.addLayer(e.customLayer||{...se(e.style,t.constants,r),id:o,source:n,...t.isMapLibre?{}:{slot:e.slot||""},metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},i()),t.map.layerIdList.push(o),e.customLayer&&t.map.fire("load"),r("Add Layer:",o),he.forEach(a=>{if(e[a]){let s=a.slice(2).toLowerCase();t.map.on(s,o,c=>{s==="click"&&(c.clickOnLayer=true),e[a](c),t.map.debugEvents&&r(`Layer '${s}' event on '${o}':`,c);});}}),createEffect(a=>{t.themeVersion;let s=se(e.style,t.constants,r);if(s!==a)return s.layout!==a?.layout&&ke(s.layout,a?.layout).forEach(([c,l])=>t.map.setLayoutProperty(o,c,l,{validate:false})),s.paint!==a?.paint&&ke(s.paint,a?.paint).forEach(([c,l])=>t.map.setPaintProperty(o,c,l,{validate:false})),(s.minzoom!==a?.minzoom||s.maxzoom!==a?.maxzoom)&&t.map.setLayerZoomRange(o,s.minzoom,s.maxzoom),s.filter!==a?.filter&&t.map.setFilter(o,s.filter,{validate:false}),r("Update Layer Style:",o),s},se(e.style,t.constants,r)),createEffect(a=>{if(e.visible!==a)return t.map.setLayoutProperty(o,"visibility",e.visible?"visible":"none",{validate:false}),r(`Update Visibility (${o}):`,e.visible.toString()),e.visible},e.visible),createEffect(a=>i()===a?a:(t.map.moveLayer(o,i()),r(`Update Layer Z-Index (${o}):`,i()),i()),i()),createEffect(a=>e.filter===a||a===void 0&&!e.filter?a:(t.map.setFilter(o,e.filter??null),r(`Update Filter (${o}):`,e.filter),e.filter),void 0),createEffect(async()=>{!e.featureState||e.featureState.id===null||(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:n,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:n,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state));}),createEffect(()=>{if(!e.pulse)return;let s=(Array.isArray(e.pulse)?e.pulse:[e.pulse]).map(c=>{let{property:l,duration:g=1500,holdFraction:m=.25}=c,M=X(l,c.from),f=X(l,c.to),h=g*(1-m),v=()=>{t.map.setPaintProperty(o,`${l}-transition`,{duration:0,delay:0},{validate:false}),t.map.setPaintProperty(o,l,M,{validate:false}),requestAnimationFrame(()=>{t.map.setPaintProperty(o,`${l}-transition`,{duration:h,delay:0},{validate:false}),t.map.setPaintProperty(o,l,f,{validate:false});});};return v(),window.setInterval(v,g)});r(`Start Pulse (${o}):`,e.pulse),onCleanup(()=>s.forEach(c=>window.clearInterval(c)));}),onCleanup(()=>t.map?.getLayer(o)&&t.map?.removeLayer(o)),e.children};var _e=createContext(),Rt=()=>useContext(_e),zt=e=>{let[t]=a(),[n,o]=createSignal(null);return onMount(async()=>{e.id=e.id||createUniqueId();let r=t.mapLib.MercatorCoordinate.fromLngLat([e.origin[0]||0,e.origin[1]||0],e.origin[2]||0),i=r.meterInMercatorCoordinateUnits(),{x:a,y:s,z:c}=r,l=null,g=null,m=null;e.babylon?(g=await import('@babylonjs/core'),l=g.Matrix.Compose(new g.Vector3(i,i,i),g.Quaternion.FromEulerAngles(Math.PI/2,0,0),new g.Vector3(a,s,c))):(m=await import('three'),l={translateX:a,translateY:s,translateZ:c,rotateX:Math.PI/2,rotateY:0,rotateZ:0,scale:i}),t.map.addLayer({id:e.id,type:"custom",renderingMode:"3d",onAdd(M,f){if(e.babylon){let h=new g.Engine(f,true,{useHighPrecisionMatrix:true},true);this.scene=new g.Scene(h),this.scene.autoClear=false,this.scene.preventDefaultOnPointerDown=false,this.scene.preventDefaultOnPointerUp=false;let v=new g.UniversalCamera("Camera",g.Vector3.Zero());v.mode=g.Camera.ORTHOGRAPHIC_CAMERA,v.inertia=0,this.scene.ambientColor=new g.Color3(1,1,1),e.defaultLight&&new g.HemisphericLight("Light",new g.Vector3(100,10,0),this.scene);}else this.camera=new m.Camera,this.scene=new m.Scene,e.defaultLight&&(this.light=new m.DirectionalLight(16777215),this.light.position.set(100,0,0).normalize(),this.scene.add(this.light)),this.renderer=new m.WebGLRenderer({canvas:M.getCanvas(),context:f,antialias:true}),this.renderer.autoClear=false;this.map=M,e.onAdd&&e.onAdd(this.scene,this.map,f),o(this.scene);},render(M,f){if(e.babylon){this.scene.activeCamera.freezeProjectionMatrix(l.multiply(g.Matrix.FromArray(f)));this.map.getPitch()*(Math.PI/180);this.map.getBearing()*(Math.PI/180);this.scene.render(false);}else {let h=new m.Matrix4().makeRotationAxis(new m.Vector3(1,0,0),l.rotateX),v=new m.Matrix4().makeRotationAxis(new m.Vector3(0,1,0),l.rotateY),y=new m.Matrix4().makeRotationAxis(new m.Vector3(0,0,1),l.rotateZ),b=new m.Matrix4().fromArray(f),S=new m.Matrix4().makeTranslation(l.translateX,l.translateY,l.translateZ).scale(new m.Vector3(l.scale,-l.scale,l.scale)).multiply(h).multiply(v).multiply(y);this.camera.projectionMatrix=b.multiply(S),this.renderer.resetState(),this.renderer.render(this.scene,this.camera);}e.onRender&&e.onRender(M,f),t.map.triggerRepaint();}},e.beforeId);}),onCleanup(()=>{t.map.getLayer(e.id)&&t.map.removeLayer(e.id);}),createComponent(_e.Provider,{value:n,get children(){return memo(()=>!!n())()&&e.children}})};var jt=e=>{let[t]=a();return createEffect(()=>{t.isMapLibre?t.map.setSky?.(e.style||{}):t.map.setFog(e.style||{});}),onCleanup(()=>{t.isMapLibre?t.map.getSky?.()&&t.map.setSky(null):t.map.getFog()&&t.map.setFog(null);}),null};var Gt=e=>{let[t]=a(),n=V();return !n&&!e?.source&&(n=createUniqueId(),t.map.addSource(n,{type:"raster-dem",url:t.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.isMapLibre?256:512,maxzoom:t.isMapLibre?void 0:14}),t.map.sourceIdList.push(n)),createEffect(()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e?.source||n});}),onCleanup(()=>t.map?.setTerrain(null)),null};var W=(e,t)=>{let[n]=a();createEffect(()=>{let o=e(),r=t?.();o&&(n.map.hasControl(o)&&n.map.removeControl(o),n.map.addControl(o,r));}),onCleanup(()=>{let o=e();o&&n.map.hasControl(o)&&n.map.removeControl(o);});};var Kt=e=>{let[t]=a(),[n,o]=splitProps(e,["position"]),[r,i]=createSignal(null),a$1=new Map([["navigation",t.mapLib.NavigationControl],["scale",t.mapLib.ScaleControl],["attribution",t.mapLib.AttributionControl],["geolocate",t.mapLib.GeolocateControl],["fullscreen",t.mapLib.FullscreenControl],["logo",t.mapLib.LogoControl],["terrain",t.mapLib.TerrainControl]]);return createEffect(()=>{untrack(()=>r()&&t.map.hasControl(r())&&t.map.removeControl(r())),i(o.custom||new(a$1.get(o.type||"navigation"))(o.options));}),W(r,()=>n.position),null};var tn=e=>{if(!e.lngLat)throw new Error("Marker - lngLat is required");let[t,n,o]=splitProps(e,["lngLat","children","showPopup","draggable"],["popup","onOpen","onClose"]),[r]=a(),i=null,a$1=null,s=t.lngLat;return createEffect(()=>{r.map&&(a$1?.remove(),a$1=new r.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...n.popup}).on("open",()=>n.onOpen?.()).on("close",()=>n.onClose?.()),createEffect(()=>{t.children!==void 0&&(typeof t.children=="string"?a$1?.setHTML(t.children):a$1?.setDOMContent(t.children),i?.setPopup(a$1));}),createEffect(()=>t.showPopup!==a$1?.isOpen()&&i?.togglePopup()));}),createEffect(()=>{r.map&&(i?.remove(),i=new r.mapLib.Marker(o.options).on("dragstart",()=>o.onDragStart?.()).on("dragend",()=>o.onDragEnd?.()).on("drag",()=>o.onDrag?.(i?.getLngLat().toArray())).setPopup(a$1).setLngLat(s).addTo(r.map),createEffect(()=>t.showPopup!==a$1?.isOpen()&&i?.togglePopup()));}),createEffect(()=>i?.setLngLat(t.lngLat)),createEffect(()=>i?.setDraggable(t.draggable)),onCleanup(()=>i?.remove()),null};var rn=e=>{if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");let[t,n]=splitProps(e,["lngLat","children","trackPointer"]),[o]=a(),r;return createEffect(()=>{o.map&&(r?.remove(),r=new o.mapLib.Popup({closeOnClick:false,focusAfterOpen:false,...n.options}).on("open",()=>n.onOpen?.()).on("close",()=>n.onClose?.()).addTo(o.map),createEffect(()=>t.trackPointer?r.trackPointer():r.setLngLat(t.lngLat)),createEffect(()=>typeof t.children=="string"?r.setHTML(t.children):r.setDOMContent(t.children)));}),onCleanup(()=>r?.remove()),null};var ce=new Float64Array(256);for(let e=0;e<256;e++){let t=.5-Math.pow(e/255,.45454545454545453);ce[e]=t*Math.abs(t);}ce[255]=-1e20;function Ie(e,t,n,o,r,i,a){i[0]=0,a[0]=-1e20,a[1]=1e20,r[0]=e[t];for(let s=1,c=0,l=0;s<o;s++){r[s]=e[t+s*n];let g=s*s;do{let m=i[c];l=(r[s]-r[m]+g-m*m)/(s-m)/2;}while(l<=a[c]&&--c>-1);c++,i[c]=s,a[c]=l,a[c+1]=1e20;}for(let s=0,c=0;s<o;s++){for(;a[c+1]<s;)c++;let l=i[c],g=s-l;e[t+s*n]=r[l]+g*g;}}function Te(e,t,n,o,r,i){for(let a=0;a<t;a++)Ie(e,a,t,n,o,r,i);for(let a=0;a<n;a++)Ie(e,a*t,1,t,o,r,i);}var de=({radius:e=8}={})=>Math.ceil(e);function H(e,{radius:t=8,cutoff:n=.25}={}){let{width:o,height:r}=e,i=o*r,a=new Float64Array(i).fill(1e20),s=new Float64Array(i),c=Math.max(o,r),l=new Float64Array(c),g=new Uint16Array(c),m=new Float64Array(c+1),M=e.data;for(let y=0,b=3;y<i;y++,b+=4){let S=M[b];if(S===0)continue;let k=ce[S];a[y]=Math.max(0,k),s[y]=Math.max(0,-k);}Te(a,o,r,l,g,m),Te(s,o,r,l,g,m);let f=255/t,h=255*(1-n),v=new Uint8ClampedArray(i*4);for(let y=0,b=0;y<i;y++,b+=4){let S=Math.sqrt(a[y])-Math.sqrt(s[y]),k=Math.max(0,Math.min(255,Math.round(h-f*S)));v[b]=v[b+1]=v[b+2]=255,v[b+3]=k;}return {width:o,height:r,data:v}}var ue={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:true},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:true},grid:{size:20,path:"M10 0V20M0 10H20"},brick:{size:40,path:"M0 0H40M0 20H40M0 40H40M0 0V20M20 0V20M40 0V20M10 20V40M30 20V40"},wave:{size:20,path:"M0 5Q5 0 10 5T20 5M0 15Q5 10 10 15T20 15"}},$e=Object.keys(ue),E=e=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" stroke-linecap="round" stroke-linejoin="round">
7
7
  <path d="${e}" fill="#000" stroke="#000" stroke-width="3"/>
8
- </svg>`,ge={square:k("M3,3 L21,3 L21,21 L3,21 Z"),circle:k("M 12 4 A 1 1 0 0 0 12 20 A 1 1 0 0 0 12 4 Z"),triangle:k("M 12 2 L 22 19 H 2 Z"),diamond:k("M 12 1 L 19 12 L 12 23 L 5 12 Z"),pentagon:k("M12,3 L21,9 L17,19 L7,19 L3,9 Z"),hexagon:k("M12,3 L20,7.5 L20,16.5 L12,21 L4,16.5 L4,7.5 Z"),octagon:k("M 8 3 Q 12 3.3 16 3 Q 18.3 5.7 21 8 Q 20.7 12 21 16 Q 18.3 18.3 16 21 Q 12 20.7 8 21 Q 5.8 18.2 3 16 Q 3.3 12 3 8 Q 5.7 5.7 8 3 Z"),cross:k("M 10.5 3 h 3 v 7.5 h 7.5 v 3 h -7.5 v 7.5 h -3 v -7.5 h -7.5 v -3 h 7.5 Z"),x:k("M 18 4 L 20 6 L 14 12 L 20 18 L 18 20 L 12 14 L 6 20 L 4 18 L 10 12 L 4 6 L 6 4 L 12 10 Z"),star:k("M12,3 L14,9 L20.5,9 L15.5,13 L17.5,19.5 L12,15.5 L6.5,19.5 L8.5,13 L3.5,9 L10,9 Z"),heart:k("M 12 21 L 3 11 A 4.5 4.5 0 1 1 11 8 L 13 8 A 4.5 4.5 0 1 1 21 11 Z"),pin:k("M 12 21 L 7 11 A 6 6 0 0 1 12 2 A 6 6 0 0 1 17 11 Z"),drop:k("M 4 21 V 12 A 7.5 7.5 0 0 1 12 4 A 7.5 7.5 0 0 1 13 21 Z"),chevron:k("M 8 4 L 14 12 L 8 20 H 5 L 11 12 L 5 4 Z")},Fe=Object.keys(ge),De=e=>k(e);var hn=e=>{let[t]=a(),[n,o]=createSignal({width:0,height:0}),r=null,i=(l,h)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",l,h||"");},a$1=()=>{!r||!t.map||t.map.hasImage(e.id)||(t.map.addImage(e.id,r.data,r.ops),i("Re-Add Image:",e.id));};t.map.on("style.load",a$1),onCleanup(()=>{t.map?.off("style.load",a$1),t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),i("Remove Image:",e.id);}),createEffect(()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern&&!e.symbol)throw new Error("Image - Image, Pattern or Symbol is required");let l=Math.max(1,Math.round(window.devicePixelRatio||2)),h=e.pattern?{pixelRatio:l,...e.options}:e.sdf?{...e.options,sdf:true}:e.options,m=e.symbol&&(ge[e.symbol]||(e.symbol.trimStart().startsWith("<svg")?e.symbol:De(e.symbol)));s(e.source||m||c(e.pattern,l),(b,d)=>{let f=d?{...h,pixelRatio:d}:h,{width:v,height:y}=b;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,b,f),!e.pattern&&untrack(()=>v===n().width&&y===n().height)?(t.map.updateImage(e.id,b),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,b,f)),o({width:v,height:y}),r={data:b,ops:f},i("Add Image:",e.id);});});let s=(l,h)=>{let m=e.sdf?typeof e.sdf=="object"?e.sdf:{}:null;if(typeof l=="string"&&l?.trimStart().startsWith("<svg")&&(l=new DOMParser().parseFromString(l,"image/svg+xml").childNodes[0]),l instanceof SVGElement&&(e.options?.fill&&l.setAttribute("fill",e.options.fill),e.options?.stroke&&l.setAttribute("stroke",e.options.stroke),l=new XMLSerializer().serializeToString(l)),typeof l!="string")return h(l);t.map.loadImage(l,async(b,d)=>{if(b){typeof l=="string"&&l?.trimEnd().endsWith(".svg")&&(l=await(await fetch(l)).text(),l=new DOMParser().parseFromString(l,"image/svg+xml").childNodes[0],l.setAttribute("fill",e.options.fill),l.setAttribute("stroke",e.options.stroke),l.setAttribute("transform",e.options.transform),l=new XMLSerializer().serializeToString(l));let f=new Image;f.crossOrigin="Anonymous",f.onload=()=>{let v=Math.min(f.width,f.height),y=v>0?Math.max(1,50/v):1,M=e.options?.pixelRatio??Math.max(1,Math.round(window.devicePixelRatio||1)),C=y*M,P=m?me(m)*C:0,u=Math.round(f.width*C),g=Math.round(f.height*C),p=document.createElement("canvas");p.width=u+P*2,p.height=g+P*2;let x=p.getContext("2d");x.imageSmoothingEnabled=true,x.drawImage(f,P,P,u,g);let E=x.getImageData(0,0,p.width,p.height);return h(m?W(E,m):E,C)},f.onerror=v=>console.error(`[MapGL] Image "${e.id}" failed to load:`,v),f.src=l.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(l):l;}else {if(!m)return h(d);let{width:f,height:v}=d,y=me(m),M=document.createElement("canvas");M.width=f+y*2,M.height=v+y*2;let C=M.getContext("2d");C.imageSmoothingEnabled=true,"data"in d?C.putImageData(d,y,y):C.drawImage(d,y,y,f,v);let P=C.getImageData(0,0,M.width,M.height);return h(W(P,m))}});},c=(l,h=2)=>{let m=pe[l.type],b=m.size*h;return {width:b,height:b,data:new Uint8Array(b*b*4),onAdd:function(){let d=document.createElement("canvas");d.width=d.height=b,this.ctx=d.getContext("2d",{willReadFrequently:true}),this.ctx.scale(h,h);},render:function(){return this.ctx.fillStyle=l.background||"transparent",this.ctx.fillRect(0,0,m.size,m.size),this.ctx.strokeStyle=this.ctx.fillStyle=l.color||"black",this.ctx.lineWidth=l.lineWidth||1,this.ctx.stroke(new Path2D(m.path)),m.fill&&this.ctx.fill(new Path2D(m.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,true}}};return null};var Mn=(e,t,n)=>e.map((o,r)=>(1-n)*e[r]+n*t[r]),bn=(e,t,n)=>{let o=e.map((i,a)=>e[a]*t[a]).reduce((i,a)=>i+a),r=Math.acos(o);return e.map((i,a)=>Math.sin((1-n)*r)/Math.sin(r)*e[a]+Math.sin(n*r)/Math.sin(r)*t[a])},xn={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},wn=e=>{let[t]=a(),n=.1,o=false,[r,i]=createSignal(false);["mousedown","touchstart","wheel"].forEach(d=>t.map.on(d,f=>!f.rotate&&i(true))),["moveend","mouseup","touchend"].forEach(d=>t.map.on(d,f=>!f.rotate&&i(false)));let a$1=async([d,f,v],y)=>{let M=t.map.getFreeCameraOptions();M.position=t.mapLib.MercatorCoordinate.fromLngLat([d,f],v),M.lookAtPoint(y),t.map.setFreeCameraOptions(M);},s=()=>{e.translate&&window.requestAnimationFrame(s);let d=[e.translate.start,e.translate.end,e.translate.easing?xn[e.translate.easing](n):n],f=e.translate.type==="line"?Mn(...d):bn(...d);a$1(f,e.translate.target),!e.translate.loop&&(n>1||n<0)&&(o=!o),n=o?n-.001:n+.001;};createEffect(()=>{e.translate&&window.requestAnimationFrame(s);});let c={duration:1e3,easing:d=>d},l=()=>{if(r())return;let{secPerRev:d=120,maxSpinZoom:f=5,slowSpinZoom:v=3}=e.rotateGlobe,y=t.map.getZoom();if(y>f)return;let M=360/d;y>v&&(M*=(f-y)/(f-v));let C=t.map.getCenter();C.lng=e.reverse?C.lng+M:C.lng-M,t.map.easeTo({center:C,...c},{rotate:true});},h=()=>{if(!e.rotateViewport||r()){t.map.stop();return}let d=e.rotateViewport,f=d?.secPerRev||60,v=e.reverse?t.map.getBearing()+360/f:t.map.getBearing()-360/f,y=d?.pitch||60,M=d?.around;t.map.easeTo({bearing:v,pitch:y,around:M,...c},{rotate:true});},m=()=>e.rotateGlobe?l():h();t.map.on("moveend",m).on("dragend",m);let b;return createEffect(()=>{e.rotateGlobe!=null&&(e.rotateGlobe?(b=t.map.getCenter(),l()):e.resetWhenStopped?t.map.stop().easeTo({center:b}):t.map.stop());}),createEffect(()=>{e.rotateViewport!=null&&(e.rotateViewport?h():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop());}),onCleanup(()=>t.map.off("moveend",m).off("dragend",m)),e.children};var Sn=e=>{let[t]=a();return createEffect(()=>t.map.setLight(e.style||{})),onCleanup(()=>t.map?.setLight(null)),null};var j={};j.onSetup=function(e){var t={};return t.count=e.count||0,t};j.onClick=function(e,t){var n=this.newFeature({type:"Feature",properties:{count:e.count},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}});this.addFeature(n);};j.onKeyUp=function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")};j.toDisplayFeatures=function(e,t,n){n(t);};var Oe=j;var Pn=6371.0088,En=1.609344,Re=6378137;function I(e){return e*Math.PI/180}function ze(e){return e*180/Math.PI}function kn(e,t){let n=I(t[1]-e[1]),o=I(t[0]-e[0]),r=I(e[1]),i=I(t[1]),a=Math.sin(n/2)**2+Math.cos(r)*Math.cos(i)*Math.sin(o/2)**2;return Pn*2*Math.asin(Math.sqrt(a))}function Z(e,t="kilometers"){let n=0;for(let o=1;o<e.length;o++)n+=kn(e[o-1],e[o]);return t==="miles"?n/En:n}function Ve(e,t){let n=I(e[1]),o=I(e[0]),r=I(t[1]),i=I(t[0]-e[0]),a=Math.cos(r)*Math.cos(i),s=Math.cos(r)*Math.sin(i),c=Math.atan2(Math.sin(n)+Math.sin(r),Math.sqrt((Math.cos(n)+a)**2+s**2)),l=o+Math.atan2(s,Math.cos(n)+a);return [ze(l),ze(c)]}function _n(e){let t=e.length;if(t<=2)return 0;let n=0;for(let o=0;o<t;o++){let r,i,a;o===t-2?(r=t-2,i=t-1,a=0):o===t-1?(r=t-1,i=0,a=1):(r=o,i=o+1,a=o+2),n+=(I(e[a][0])-I(e[r][0]))*Math.sin(I(e[i][1]));}return n*Re*Re/2}function Ue(e){return e.reduce((t,n,o)=>{let r=Math.abs(_n(n));return o===0?t+r:t-r},0)}function je(e){let t=e[0],n=0,o=0;for(let[c,l]of t)n+=c,o+=l;n/=t.length,o/=t.length;let r=0,i=0,a=0;for(let c=0;c<t.length-1;c++){let l=t[c][0]-n,h=t[c][1]-o,m=t[c+1][0]-n,b=t[c+1][1]-o,d=l*b-m*h;r+=(l+m)*d,i+=(h+b)*d,a+=d;}if(a===0)return [n,o];let s=1/(3*a);return [n+r*s,o+i*s]}var Ze=e=>new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[0])+"\xB0 "+new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[1])+"\xB0",$=(e,t)=>{let n=Z(e,window.navigator.language==="en-US"?"miles":"kilometers");return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1?"foot":"mile"}).format(n<=1?n*5280:n):new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1?"meter":"kilometer"}).format(n<=1?n*1e3:n),...t},geometry:{type:"Point",coordinates:Ve(e[0],e[1])}}},H=(e,t)=>{let n=Ue(e);return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=10.764?"foot":"mile"}).format(n<=10.764?n*10.764:n*1.0000003861)+"\xB2":new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1e6?"meter":"kilometer"}).format(n<=1e6?n:n/1e6)+"\xB2",...t},geometry:{type:"Point",coordinates:je(e)}}};var Ne=e=>{let t=e.modes.draw_line_string;return {...t,onSetup:function(){let n=t.onSetup.call(this),o=this.newFeature({type:"Feature",properties:{type:"measure",value:"TTT"},geometry:{type:"Point",coordinates:[]}});return {...n,measure:o}},onMouseMove:function(n,o){if(t.onMouseMove.call(this,n,o),n.line.coordinates.length>=2){let r=$(n.line.coordinates);n.measure.properties.value=r.properties.value,n.measure.updateCoordinate("",r.geometry.coordinates[0],r.geometry.coordinates[1]);}},toDisplayFeatures:function(n,o,r){t.toDisplayFeatures.call(this,n,o,r),this.drawConfig.userProperties.showLength&&r(n.measure.toGeoJSON());}}};var qe=e=>{let t=e.modes.draw_point;return {...t,onSetup:function(){let n=t.onSetup.call(this);return n.point.properties={...n.point.properties,type:"measure",anchor:"bottom"},n},onMouseMove:function(n,{lngLat:o}){n.point.properties.value=Ze([o.lng,o.lat]),n.point.updateCoordinate("",o.lng,o.lat);},toDisplayFeatures:function(n,o,r){let i=o.properties.id===n.point.id;return o.properties.active=i?"":"false",r(o)}}};var Ge=e=>{let t=e.modes.draw_polygon;return {...t,toDisplayFeatures:function(n,o,r){let i=a=>{if(r(a),this.drawConfig.userProperties.showLength){let s=Array.isArray(a.geometry.coordinates[0][0])?a.geometry.coordinates[0]:a.geometry.coordinates;s.forEach((c,l)=>{!Array.isArray(c)||l==0||r($([s[l-1],c]));});}this.drawConfig.userProperties.showArea&&a.geometry.coordinates[0].length>=3&&r(H([a.geometry.coordinates[0]]));};t.toDisplayFeatures.call(this,n,o,i);}}};function In(e,t,n,o){return {type:"Feature",properties:{meta:"vertex",parent:e,coord_path:n,active:o?"true":"false"},geometry:{type:"Point",coordinates:t}}}function Tn(e,t,n,o=64){let r=[],i=t/(111.32*Math.cos(e[1]*Math.PI/180)),a=t/110.574;for(let s=0;s<o;s+=1){let c=s/o*(2*Math.PI),l=i*Math.cos(c),h=a*Math.sin(c);r.push([e[0]+l,e[1]+h]);}return r.push(r[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[r]},properties:{parent:n,active:"true"}}}var $n={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);}},An=e=>({...e.modes.draw_line_string,clickAnywhere:function(t,n){return t.currentVertexPosition===1?(t.line.addCoordinate(0,n.lngLat.lng,n.lngLat.lat),this.changeMode("simple_select",{featureIds:[t.line.id]})):(this.updateUIClasses({mouse:"add"}),t.line.updateCoordinate(t.currentVertexPosition,n.lngLat.lng,n.lngLat.lat),t.direction==="forward"?(t.currentVertexPosition+=1,t.line.updateCoordinate(t.currentVertexPosition,n.lngLat.lng,n.lngLat.lat)):t.line.addCoordinate(0,n.lngLat.lng,n.lngLat.lat),null)},onStop:function(t){if($n.enable(this),this.activateUIButton(),this.getFeature(t.line.id)!==void 0)if(t.line.removeCoordinate("0"),t.line.isValid()){let n=t.line.toGeoJSON(),o=(Z(n.geometry.coordinates)*1e3).toFixed(1),r=n.geometry.coordinates[0];this.deleteFeature([t.line.id],{silent:true});let i=this.newFeature({type:"Feature",properties:{radius:o},geometry:{type:"Point",coordinates:r}});this.addFeature(i),this.map.fire("draw.create",{features:[i.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[i.id]});}else this.deleteFeature([t.line.id],{silent:true}),this.changeMode("simple_select",{},{silent:true});},toDisplayFeatures:function(t,n,o){let r=n.properties.id===t.line.id;return n.properties.active=r?"true":"false",r?(n.geometry.coordinates.length<2||(n.properties.meta="feature",o(In(t.line.id,n.geometry.coordinates[t.direction==="forward"?n.geometry.coordinates.length-2:1],`${t.direction==="forward"?n.geometry.coordinates.length-2:1}`,false)),o(n),o($(n.geometry.coordinates,{parent:t.line.id})),o(Tn(n.geometry.coordinates[0],Z(n.geometry.coordinates),t.line.id))),null):o(n)}}),Be=An;var Fn=e=>({...e.modes.draw_line_string,onSetup:function(t){let n=e.modes.draw_line_string.onSetup.call(this,t),o=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(o),{...n,...t,rectangle:o}},onTap:function(t,n){t.startPoint&&this.onMouseMove(t,n),this.onClick(t,n);},onClick:function(t,n){t.startPoint&&t.startPoint[0]!==n.lngLat.lng&&t.startPoint[1]!==n.lngLat.lat?(this.updateUIClasses({mouse:"pointer"}),t.endPoint=[n.lngLat.lng,n.lngLat.lat],this.changeMode("simple_select",{featuresId:t.rectangle.id})):t.startPoint=[n.lngLat.lng,n.lngLat.lat];},onMouseMove:function(t,n){t.startPoint&&(t.rectangle.updateCoordinate("0.0",t.startPoint[0],t.startPoint[1]),t.rectangle.updateCoordinate("0.1",n.lngLat.lng,t.startPoint[1]),t.rectangle.updateCoordinate("0.2",n.lngLat.lng,n.lngLat.lat),t.rectangle.updateCoordinate("0.3",t.startPoint[0],n.lngLat.lat),t.rectangle.updateCoordinate("0.4",t.startPoint[0],t.startPoint[1]));},onKeyUp:function(t,n){if(n.keyCode===27)return this.changeMode("simple_select")},onStop:function(t){e.modes.draw_line_string.onStop.call(this,t),this.getFeature(t.rectangle.id)!==void 0&&(t.rectangle.removeCoordinate("0.4"),t.rectangle.isValid()?this.map.fire("draw.create",{features:[t.rectangle.toGeoJSON()]}):(this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(t,n,o){let r=n.properties.id===t.rectangle.id;if(n.properties.active=r?"true":"false",!r)return o(n);if(t.startPoint)return o(n),this.drawConfig.userProperties.showLength&&(o($([n.geometry.coordinates[0][0],n.geometry.coordinates[0][1]],{parent:t.rectangle.id,anchor:"bottom"})),o($([n.geometry.coordinates[0][1],n.geometry.coordinates[0][2]],{parent:t.rectangle.id,anchor:"left"}))),this.drawConfig.userProperties.showArea&&o(H(n.geometry.coordinates,{parent:t.rectangle.id})),null},onTrash:function(t){this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select");}}),Ye=Fn;var Xe={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable();},0);}},Dn={onSetup:function(e){let t=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),Xe.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:true}),{rectangle:t,currentVertexPosition:0}},onTap:function(e,t){this.onClick(e,t);},onClick:function(e,t){if(e.currentVertexPosition===2){let n=this.calculatepXY3(e,t,false);return n&&e.rectangle.updateCoordinate(`0.${e.currentVertexPosition+1}`,n[0],n[1]),this.updateUIClasses({mouse:"pointer"}),this.changeMode("simple_select",{featuresId:e.rectangle.id})}else e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat);},onMouseMove:function(e,t){if(e.rectangle.updateCoordinate("0."+e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition&&e.currentVertexPosition>0&&this.calculateOrientedAnglePolygon(e),e.currentVertexPosition===2){let n=this.calculatepXY3(e,t,true);n&&e.rectangle.updateCoordinate("0."+(e.currentVertexPosition+1),n[0],n[1]);}},deegrees2meters(e){let t=e[0]*2003750834e-2/180,n=Math.log(Math.tan((90+e[1])*Math.PI/360))/(Math.PI/180);return n=n*2003750834e-2/180,[t,n]},meters2degress(e){let t=e[0]*180/2003750834e-2,n=Math.atan(Math.exp(e[1]*Math.PI/2003750834e-2))*360/Math.PI-90;return [t,n]},calculateOrientedAnglePolygon:function(e){let t=e.rectangle.getCoordinate("0.0"),n=this.deegrees2meters(t),o=e.rectangle.getCoordinate("0.1"),r=this.deegrees2meters(o),a=-1*(Math.atan2(r[1]-n[1],r[0]-n[0])*180/Math.PI+90),s=a<0?a+360:a;e.angle=parseFloat(s.toFixed(2));},calculatepXY3:function(e,t,n){let o=e.rectangle.getCoordinate("0.0"),r=this.deegrees2meters(o),i=e.rectangle.getCoordinate("0.1"),a=this.deegrees2meters(i),s=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]),c=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]);if(r[0]===a[0])s=[c[0],a[1]];else if(r[1]===a[1])s=[a[0],c[1]];else {let f=-1/((a[1]-r[1])/(a[0]-r[0]));Math.abs(f)<1?s[1]=f*(c[0]-a[0])+a[1]:s[0]=a[0]+(s[1]-a[1])/f;}let l=[a[0]-r[0],a[1]-r[1]],h=[s[0]-l[0],s[1]-l[1]],m=this.meters2degress(s),b=this.meters2degress(h);return e.rectangle.updateCoordinate("0.2",m[0],m[1]),e.rectangle.updateCoordinate("0.3",b[0],b[1]),b},onKeyUp:function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")},onStop:function(e){Xe.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(e.rectangle.id)!==void 0&&(e.rectangle.removeCoordinate("0.4"),e.rectangle.isValid()?this.map.fire("draw.create",{features:[e.rectangle.toGeoJSON()]}):(this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(e,t,n){let o=t.properties.id===e.rectangle.id;if(t.properties.active=o?"true":"false",t.properties.angle=e.angle,t.angle=e.angle,!o)return n(t);let r=t.geometry.coordinates[0].length;if(r<3){let i=t.geometry.coordinates[0][0],a={type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:t.geometry.coordinates[0][0],type:"Point"}};i&&n(a);return}if(r>=3&&r<=4){let i=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(n({type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:i,type:"LineString"}}),r===3)return}return n(t)},onTrash:function(e){this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select");}},We=Dn;var He=[{id:"measure-label",type:"symbol",filter:["all",["==","$type","Point"],["==","user_type","measure"]],layout:{"text-field":["get","user_value"],"text-anchor":["get","user_anchor"],"text-offset":["match",["get","user_anchor"],"bottom",[0,-0.5],[0,0]],"text-size":12,"text-allow-overlap":true,"text-ignore-placement":true},paint:{"text-halo-color":"rgba(255,255,255,0.75)","text-halo-width":2,"text-halo-blur":1,"text-color":"#000"}}];var Rn=e=>{let[t]=a();t.isMapLibre&&e.lib.constants?.classes&&Object.assign(e.lib.constants.classes,{CANVAS:"maplibregl-canvas",CONTROL_BASE:"maplibregl-ctrl",CONTROL_PREFIX:"maplibregl-ctrl-",CONTROL_GROUP:"maplibregl-ctrl-group",ATTRIBUTION:"maplibregl-ctrl-attrib"});let n=new e.lib({styles:[...e.lib.lib.theme,...He],modes:{...e.lib.modes,draw_point:qe(e.lib),draw_line_string:Ne(e.lib),draw_polygon:Ge(e.lib),multi_point:Oe,radius:Be(e.lib),rectangle:Ye(e.lib),rectangle_assisted:We},userProperties:{showLength:e.showLength||false,showArea:e.showArea||false},...e.options});t.map.addControl(n,e.position||"top-right"),e.getInstance&&e.getInstance(n);let o={};return Me.forEach(r=>{if(e[r]){let i=`draw.${r.slice(2).toLowerCase()}`,a=s=>e[r](s);o[i]=a,t.map.on(i,a);}}),onCleanup(()=>{Object.keys(o).forEach(r=>t.map.off(r,o[r])),t.map?.removeControl(n);}),null};var Vn=e=>{let[t]=a(),n;return X(()=>(n||(n=new e.overlay(e.props||{})),n)),createEffect(()=>n?.setProps(e.props||{})),null};
8
+ </svg>`,me={square:E("M3,3 L21,3 L21,21 L3,21 Z"),circle:E("M 12 4 A 1 1 0 0 0 12 20 A 1 1 0 0 0 12 4 Z"),triangle:E("M 12 2 L 22 19 H 2 Z"),diamond:E("M 12 1 L 19 12 L 12 23 L 5 12 Z"),pentagon:E("M12,3 L21,9 L17,19 L7,19 L3,9 Z"),hexagon:E("M12,3 L20,7.5 L20,16.5 L12,21 L4,16.5 L4,7.5 Z"),octagon:E("M 8 3 Q 12 3.3 16 3 Q 18.3 5.7 21 8 Q 20.7 12 21 16 Q 18.3 18.3 16 21 Q 12 20.7 8 21 Q 5.8 18.2 3 16 Q 3.3 12 3 8 Q 5.7 5.7 8 3 Z"),cross:E("M 10.5 3 h 3 v 7.5 h 7.5 v 3 h -7.5 v 7.5 h -3 v -7.5 h -7.5 v -3 h 7.5 Z"),x:E("M 18 4 L 20 6 L 14 12 L 20 18 L 18 20 L 12 14 L 6 20 L 4 18 L 10 12 L 4 6 L 6 4 L 12 10 Z"),star:E("M12,3 L14,9 L20.5,9 L15.5,13 L17.5,19.5 L12,15.5 L6.5,19.5 L8.5,13 L3.5,9 L10,9 Z"),heart:E("M 12 21 L 3 11 A 4.5 4.5 0 1 1 11 8 L 13 8 A 4.5 4.5 0 1 1 21 11 Z"),pin:E("M 12 21 L 7 11 A 6 6 0 0 1 12 2 A 6 6 0 0 1 17 11 Z"),drop:E("M 4 21 V 12 A 7.5 7.5 0 0 1 12 4 A 7.5 7.5 0 0 1 13 21 Z"),chevron:E("M 8 4 L 14 12 L 8 20 H 5 L 11 12 L 5 4 Z")},Ae=Object.keys(me),De=e=>E(e);var dn=e=>{let[t]=a(),[n,o]=createSignal({width:0,height:0}),r=null,i=(l,g)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",l,g||"");},a$1=()=>{!r||!t.map||t.map.hasImage(e.id)||(t.map.addImage(e.id,r.data,r.ops),i("Re-Add Image:",e.id));};t.map.on("style.load",a$1),onCleanup(()=>{t.map?.off("style.load",a$1),t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),i("Remove Image:",e.id);}),createEffect(()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern&&!e.symbol)throw new Error("Image - Image, Pattern or Symbol is required");let l=Math.max(1,Math.round(window.devicePixelRatio||2)),g=e.pattern?{pixelRatio:l,...e.options}:e.sdf?{...e.options,sdf:true}:e.options,m=e.symbol&&(me[e.symbol]||(e.symbol.trimStart().startsWith("<svg")?e.symbol:De(e.symbol)));s(e.source||m||c(e.pattern,l),(M,f)=>{let h=f?{...g,pixelRatio:f}:g,{width:v,height:y}=M;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,M,h),!e.pattern&&untrack(()=>v===n().width&&y===n().height)?(t.map.updateImage(e.id,M),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,M,h)),o({width:v,height:y}),r={data:M,ops:h},i("Add Image:",e.id);});});let s=(l,g)=>{let m=e.sdf?typeof e.sdf=="object"?e.sdf:{}:null;if(typeof l=="string"&&l?.trimStart().startsWith("<svg")&&(l=new DOMParser().parseFromString(l,"image/svg+xml").childNodes[0]),l instanceof SVGElement&&(e.options?.fill&&l.setAttribute("fill",e.options.fill),e.options?.stroke&&l.setAttribute("stroke",e.options.stroke),l=new XMLSerializer().serializeToString(l)),typeof l!="string")return g(l);t.map.loadImage(l,async(M,f)=>{if(M){typeof l=="string"&&l?.trimEnd().endsWith(".svg")&&(l=await(await fetch(l)).text(),l=new DOMParser().parseFromString(l,"image/svg+xml").childNodes[0],l.setAttribute("fill",e.options.fill),l.setAttribute("stroke",e.options.stroke),l.setAttribute("transform",e.options.transform),l=new XMLSerializer().serializeToString(l));let h=new Image;h.crossOrigin="Anonymous",h.onload=()=>{let v=Math.min(h.width,h.height),y=v>0?Math.max(1,50/v):1,b=e.options?.pixelRatio??Math.max(1,Math.round(window.devicePixelRatio||1)),S=y*b,k=m?de(m)*S:0,d=Math.round(h.width*S),p=Math.round(h.height*S),u=document.createElement("canvas");u.width=d+k*2,u.height=p+k*2;let x=u.getContext("2d");x.imageSmoothingEnabled=true,x.drawImage(h,k,k,d,p);let P=x.getImageData(0,0,u.width,u.height);return g(m?H(P,m):P,S)},h.onerror=v=>console.error(`[MapGL] Image "${e.id}" failed to load:`,v),h.src=l.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+encodeURIComponent(l):l;}else {if(!m)return g(f);let{width:h,height:v}=f,y=de(m),b=document.createElement("canvas");b.width=h+y*2,b.height=v+y*2;let S=b.getContext("2d");S.imageSmoothingEnabled=true,"data"in f?S.putImageData(f,y,y):S.drawImage(f,y,y,h,v);let k=S.getImageData(0,0,b.width,b.height);return g(H(k,m))}});},c=(l,g=2)=>{let m=ue[l.type],M=m.size*g;return {width:M,height:M,data:new Uint8Array(M*M*4),onAdd:function(){let f=document.createElement("canvas");f.width=f.height=M,this.ctx=f.getContext("2d",{willReadFrequently:true}),this.ctx.scale(g,g);},render:function(){return this.ctx.fillStyle=l.background||"transparent",this.ctx.fillRect(0,0,m.size,m.size),this.ctx.strokeStyle=this.ctx.fillStyle=l.color||"black",this.ctx.lineWidth=l.lineWidth||1,this.ctx.stroke(new Path2D(m.path)),m.fill&&this.ctx.fill(new Path2D(m.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,true}}};return null};var pn=(e,t,n)=>e.map((o,r)=>(1-n)*e[r]+n*t[r]),gn=(e,t,n)=>{let o=e.map((i,a)=>e[a]*t[a]).reduce((i,a)=>i+a),r=Math.acos(o);return e.map((i,a)=>Math.sin((1-n)*r)/Math.sin(r)*e[a]+Math.sin(n*r)/Math.sin(r)*t[a])},fn={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},hn=e=>{let[t]=a(),n=.1,o=false,[r,i]=createSignal(false);["mousedown","touchstart","wheel"].forEach(f=>t.map.on(f,h=>!h.rotate&&i(true))),["moveend","mouseup","touchend"].forEach(f=>t.map.on(f,h=>!h.rotate&&i(false)));let a$1=async([f,h,v],y)=>{let b=t.map.getFreeCameraOptions();b.position=t.mapLib.MercatorCoordinate.fromLngLat([f,h],v),b.lookAtPoint(y),t.map.setFreeCameraOptions(b);},s=()=>{e.translate&&window.requestAnimationFrame(s);let f=[e.translate.start,e.translate.end,e.translate.easing?fn[e.translate.easing](n):n],h=e.translate.type==="line"?pn(...f):gn(...f);a$1(h,e.translate.target),!e.translate.loop&&(n>1||n<0)&&(o=!o),n=o?n-.001:n+.001;};createEffect(()=>{e.translate&&window.requestAnimationFrame(s);});let c={duration:1e3,easing:f=>f},l=()=>{if(r())return;let{secPerRev:f=120,maxSpinZoom:h=5,slowSpinZoom:v=3}=e.rotateGlobe,y=t.map.getZoom();if(y>h)return;let b=360/f;y>v&&(b*=(h-y)/(h-v));let S=t.map.getCenter();S.lng=e.reverse?S.lng+b:S.lng-b,t.map.easeTo({center:S,...c},{rotate:true});},g=()=>{if(!e.rotateViewport||r()){t.map.stop();return}let f=e.rotateViewport,h=f?.secPerRev||60,v=e.reverse?t.map.getBearing()+360/h:t.map.getBearing()-360/h,y=f?.pitch||60,b=f?.around;t.map.easeTo({bearing:v,pitch:y,around:b,...c},{rotate:true});},m=()=>e.rotateGlobe?l():g();t.map.on("moveend",m).on("dragend",m);let M;return createEffect(()=>{e.rotateGlobe!=null&&(e.rotateGlobe?(M=t.map.getCenter(),l()):e.resetWhenStopped?t.map.stop().easeTo({center:M}):t.map.stop());}),createEffect(()=>{e.rotateViewport!=null&&(e.rotateViewport?g():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop());}),onCleanup(()=>t.map.off("moveend",m).off("dragend",m)),e.children};var Mn=e=>{let[t]=a();return createEffect(()=>t.map.setLight(e.style||{})),onCleanup(()=>t.map?.setLight(null)),null};var j={};j.onSetup=function(e){var t={};return t.count=e.count||0,t};j.onClick=function(e,t){var n=this.newFeature({type:"Feature",properties:{count:e.count},geometry:{type:"Point",coordinates:[t.lngLat.lng,t.lngLat.lat]}});this.addFeature(n);};j.onKeyUp=function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")};j.toDisplayFeatures=function(e,t,n){n(t);};var Fe=j;var bn=6371.0088,xn=1.609344,Oe=6378137;function I(e){return e*Math.PI/180}function Re(e){return e*180/Math.PI}function wn(e,t){let n=I(t[1]-e[1]),o=I(t[0]-e[0]),r=I(e[1]),i=I(t[1]),a=Math.sin(n/2)**2+Math.cos(r)*Math.cos(i)*Math.sin(o/2)**2;return bn*2*Math.asin(Math.sqrt(a))}function Z(e,t="kilometers"){let n=0;for(let o=1;o<e.length;o++)n+=wn(e[o-1],e[o]);return t==="miles"?n/xn:n}function ze(e,t){let n=I(e[1]),o=I(e[0]),r=I(t[1]),i=I(t[0]-e[0]),a=Math.cos(r)*Math.cos(i),s=Math.cos(r)*Math.sin(i),c=Math.atan2(Math.sin(n)+Math.sin(r),Math.sqrt((Math.cos(n)+a)**2+s**2)),l=o+Math.atan2(s,Math.cos(n)+a);return [Re(l),Re(c)]}function Ln(e){let t=e.length;if(t<=2)return 0;let n=0;for(let o=0;o<t;o++){let r,i,a;o===t-2?(r=t-2,i=t-1,a=0):o===t-1?(r=t-1,i=0,a=1):(r=o,i=o+1,a=o+2),n+=(I(e[a][0])-I(e[r][0]))*Math.sin(I(e[i][1]));}return n*Oe*Oe/2}function Ve(e){return e.reduce((t,n,o)=>{let r=Math.abs(Ln(n));return o===0?t+r:t-r},0)}function Ue(e){let t=e[0],n=0,o=0;for(let[c,l]of t)n+=c,o+=l;n/=t.length,o/=t.length;let r=0,i=0,a=0;for(let c=0;c<t.length-1;c++){let l=t[c][0]-n,g=t[c][1]-o,m=t[c+1][0]-n,M=t[c+1][1]-o,f=l*M-m*g;r+=(l+m)*f,i+=(g+M)*f,a+=f;}if(a===0)return [n,o];let s=1/(3*a);return [n+r*s,o+i*s]}var je=e=>new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[0])+"\xB0 "+new Intl.NumberFormat(void 0,{maximumFractionDigits:5}).format(e[1])+"\xB0",$=(e,t)=>{let n=Z(e,window.navigator.language==="en-US"?"miles":"kilometers");return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1?"foot":"mile"}).format(n<=1?n*5280:n):new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1?"meter":"kilometer"}).format(n<=1?n*1e3:n),...t},geometry:{type:"Point",coordinates:ze(e[0],e[1])}}},Q=(e,t)=>{let n=Ve(e);return {type:"Feature",properties:{type:"measure",value:window.navigator.language==="en-US"?new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=10.764?"foot":"mile"}).format(n<=10.764?n*10.764:n*1.0000003861)+"\xB2":new Intl.NumberFormat(void 0,{style:"unit",maximumFractionDigits:2,unit:n<=1e6?"meter":"kilometer"}).format(n<=1e6?n:n/1e6)+"\xB2",...t},geometry:{type:"Point",coordinates:Ue(e)}}};var Ze=e=>{let t=e.modes.draw_line_string;return {...t,onSetup:function(){let n=t.onSetup.call(this),o=this.newFeature({type:"Feature",properties:{type:"measure",value:"TTT"},geometry:{type:"Point",coordinates:[]}});return {...n,measure:o}},onMouseMove:function(n,o){if(t.onMouseMove.call(this,n,o),n.line.coordinates.length>=2){let r=$(n.line.coordinates);n.measure.properties.value=r.properties.value,n.measure.updateCoordinate("",r.geometry.coordinates[0],r.geometry.coordinates[1]);}},toDisplayFeatures:function(n,o,r){t.toDisplayFeatures.call(this,n,o,r),this.drawConfig.userProperties.showLength&&r(n.measure.toGeoJSON());}}};var Ne=e=>{let t=e.modes.draw_point;return {...t,onSetup:function(){let n=t.onSetup.call(this);return n.point.properties={...n.point.properties,type:"measure",anchor:"bottom"},n},onMouseMove:function(n,{lngLat:o}){n.point.properties.value=je([o.lng,o.lat]),n.point.updateCoordinate("",o.lng,o.lat);},toDisplayFeatures:function(n,o,r){let i=o.properties.id===n.point.id;return o.properties.active=i?"":"false",r(o)}}};var qe=e=>{let t=e.modes.draw_polygon;return {...t,toDisplayFeatures:function(n,o,r){let i=a=>{if(r(a),this.drawConfig.userProperties.showLength){let s=Array.isArray(a.geometry.coordinates[0][0])?a.geometry.coordinates[0]:a.geometry.coordinates;s.forEach((c,l)=>{!Array.isArray(c)||l==0||r($([s[l-1],c]));});}this.drawConfig.userProperties.showArea&&a.geometry.coordinates[0].length>=3&&r(Q([a.geometry.coordinates[0]]));};t.toDisplayFeatures.call(this,n,o,i);}}};function Cn(e,t,n,o){return {type:"Feature",properties:{meta:"vertex",parent:e,coord_path:n,active:o?"true":"false"},geometry:{type:"Point",coordinates:t}}}function Sn(e,t,n,o=64){let r=[],i=t/(111.32*Math.cos(e[1]*Math.PI/180)),a=t/110.574;for(let s=0;s<o;s+=1){let c=s/o*(2*Math.PI),l=i*Math.cos(c),g=a*Math.sin(c);r.push([e[0]+l,e[1]+g]);}return r.push(r[0]),{type:"Feature",geometry:{type:"Polygon",coordinates:[r]},properties:{parent:n,active:"true"}}}var Pn={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);}},En=e=>({...e.modes.draw_line_string,clickAnywhere:function(t,n){return t.currentVertexPosition===1?(t.line.addCoordinate(0,n.lngLat.lng,n.lngLat.lat),this.changeMode("simple_select",{featureIds:[t.line.id]})):(this.updateUIClasses({mouse:"add"}),t.line.updateCoordinate(t.currentVertexPosition,n.lngLat.lng,n.lngLat.lat),t.direction==="forward"?(t.currentVertexPosition+=1,t.line.updateCoordinate(t.currentVertexPosition,n.lngLat.lng,n.lngLat.lat)):t.line.addCoordinate(0,n.lngLat.lng,n.lngLat.lat),null)},onStop:function(t){if(Pn.enable(this),this.activateUIButton(),this.getFeature(t.line.id)!==void 0)if(t.line.removeCoordinate("0"),t.line.isValid()){let n=t.line.toGeoJSON(),o=(Z(n.geometry.coordinates)*1e3).toFixed(1),r=n.geometry.coordinates[0];this.deleteFeature([t.line.id],{silent:true});let i=this.newFeature({type:"Feature",properties:{radius:o},geometry:{type:"Point",coordinates:r}});this.addFeature(i),this.map.fire("draw.create",{features:[i.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[i.id]});}else this.deleteFeature([t.line.id],{silent:true}),this.changeMode("simple_select",{},{silent:true});},toDisplayFeatures:function(t,n,o){let r=n.properties.id===t.line.id;return n.properties.active=r?"true":"false",r?(n.geometry.coordinates.length<2||(n.properties.meta="feature",o(Cn(t.line.id,n.geometry.coordinates[t.direction==="forward"?n.geometry.coordinates.length-2:1],`${t.direction==="forward"?n.geometry.coordinates.length-2:1}`,false)),o(n),o($(n.geometry.coordinates,{parent:t.line.id})),o(Sn(n.geometry.coordinates[0],Z(n.geometry.coordinates),t.line.id))),null):o(n)}}),Ge=En;var kn=e=>({...e.modes.draw_line_string,onSetup:function(t){let n=e.modes.draw_line_string.onSetup.call(this,t),o=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(o),{...n,...t,rectangle:o}},onTap:function(t,n){t.startPoint&&this.onMouseMove(t,n),this.onClick(t,n);},onClick:function(t,n){t.startPoint&&t.startPoint[0]!==n.lngLat.lng&&t.startPoint[1]!==n.lngLat.lat?(this.updateUIClasses({mouse:"pointer"}),t.endPoint=[n.lngLat.lng,n.lngLat.lat],this.changeMode("simple_select",{featuresId:t.rectangle.id})):t.startPoint=[n.lngLat.lng,n.lngLat.lat];},onMouseMove:function(t,n){t.startPoint&&(t.rectangle.updateCoordinate("0.0",t.startPoint[0],t.startPoint[1]),t.rectangle.updateCoordinate("0.1",n.lngLat.lng,t.startPoint[1]),t.rectangle.updateCoordinate("0.2",n.lngLat.lng,n.lngLat.lat),t.rectangle.updateCoordinate("0.3",t.startPoint[0],n.lngLat.lat),t.rectangle.updateCoordinate("0.4",t.startPoint[0],t.startPoint[1]));},onKeyUp:function(t,n){if(n.keyCode===27)return this.changeMode("simple_select")},onStop:function(t){e.modes.draw_line_string.onStop.call(this,t),this.getFeature(t.rectangle.id)!==void 0&&(t.rectangle.removeCoordinate("0.4"),t.rectangle.isValid()?this.map.fire("draw.create",{features:[t.rectangle.toGeoJSON()]}):(this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(t,n,o){let r=n.properties.id===t.rectangle.id;if(n.properties.active=r?"true":"false",!r)return o(n);if(t.startPoint)return o(n),this.drawConfig.userProperties.showLength&&(o($([n.geometry.coordinates[0][0],n.geometry.coordinates[0][1]],{parent:t.rectangle.id,anchor:"bottom"})),o($([n.geometry.coordinates[0][1],n.geometry.coordinates[0][2]],{parent:t.rectangle.id,anchor:"left"}))),this.drawConfig.userProperties.showArea&&o(Q(n.geometry.coordinates,{parent:t.rectangle.id})),null},onTrash:function(t){this.deleteFeature([t.rectangle.id],{silent:true}),this.changeMode("simple_select");}}),Be=kn;var Ye={enable:e=>{setTimeout(()=>{!e.map||!e.map.doubleClickZoom||!e._ctx||!e._ctx.store||!e._ctx.store.getInitialConfigValue||e._ctx.store.getInitialConfigValue("doubleClickZoom")&&e.map.doubleClickZoom.enable();},0);},disable(e){setTimeout(()=>{!e.map||!e.map.doubleClickZoom||e.map.doubleClickZoom.disable();},0);}},_n={onSetup:function(e){let t=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(t),this.clearSelectedFeatures(),Ye.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:true}),{rectangle:t,currentVertexPosition:0}},onTap:function(e,t){this.onClick(e,t);},onClick:function(e,t){if(e.currentVertexPosition===2){let n=this.calculatepXY3(e,t,false);return n&&e.rectangle.updateCoordinate(`0.${e.currentVertexPosition+1}`,n[0],n[1]),this.updateUIClasses({mouse:"pointer"}),this.changeMode("simple_select",{featuresId:e.rectangle.id})}else e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition++,e.rectangle.updateCoordinate(`0.${e.currentVertexPosition}`,t.lngLat.lng,t.lngLat.lat);},onMouseMove:function(e,t){if(e.rectangle.updateCoordinate("0."+e.currentVertexPosition,t.lngLat.lng,t.lngLat.lat),e.currentVertexPosition&&e.currentVertexPosition>0&&this.calculateOrientedAnglePolygon(e),e.currentVertexPosition===2){let n=this.calculatepXY3(e,t,true);n&&e.rectangle.updateCoordinate("0."+(e.currentVertexPosition+1),n[0],n[1]);}},deegrees2meters(e){let t=e[0]*2003750834e-2/180,n=Math.log(Math.tan((90+e[1])*Math.PI/360))/(Math.PI/180);return n=n*2003750834e-2/180,[t,n]},meters2degress(e){let t=e[0]*180/2003750834e-2,n=Math.atan(Math.exp(e[1]*Math.PI/2003750834e-2))*360/Math.PI-90;return [t,n]},calculateOrientedAnglePolygon:function(e){let t=e.rectangle.getCoordinate("0.0"),n=this.deegrees2meters(t),o=e.rectangle.getCoordinate("0.1"),r=this.deegrees2meters(o),a=-1*(Math.atan2(r[1]-n[1],r[0]-n[0])*180/Math.PI+90),s=a<0?a+360:a;e.angle=parseFloat(s.toFixed(2));},calculatepXY3:function(e,t,n){let o=e.rectangle.getCoordinate("0.0"),r=this.deegrees2meters(o),i=e.rectangle.getCoordinate("0.1"),a=this.deegrees2meters(i),s=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]),c=this.deegrees2meters([t.lngLat.lng,t.lngLat.lat]);if(r[0]===a[0])s=[c[0],a[1]];else if(r[1]===a[1])s=[a[0],c[1]];else {let h=-1/((a[1]-r[1])/(a[0]-r[0]));Math.abs(h)<1?s[1]=h*(c[0]-a[0])+a[1]:s[0]=a[0]+(s[1]-a[1])/h;}let l=[a[0]-r[0],a[1]-r[1]],g=[s[0]-l[0],s[1]-l[1]],m=this.meters2degress(s),M=this.meters2degress(g);return e.rectangle.updateCoordinate("0.2",m[0],m[1]),e.rectangle.updateCoordinate("0.3",M[0],M[1]),M},onKeyUp:function(e,t){if(t.keyCode===27)return this.changeMode("simple_select")},onStop:function(e){Ye.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(e.rectangle.id)!==void 0&&(e.rectangle.removeCoordinate("0.4"),e.rectangle.isValid()?this.map.fire("draw.create",{features:[e.rectangle.toGeoJSON()]}):(this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select",{},{silent:true})));},toDisplayFeatures:function(e,t,n){let o=t.properties.id===e.rectangle.id;if(t.properties.active=o?"true":"false",t.properties.angle=e.angle,t.angle=e.angle,!o)return n(t);let r=t.geometry.coordinates[0].length;if(r<3){let i=t.geometry.coordinates[0][0],a={type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:t.geometry.coordinates[0][0],type:"Point"}};i&&n(a);return}if(r>=3&&r<=4){let i=[[t.geometry.coordinates[0][0][0],t.geometry.coordinates[0][0][1]],[t.geometry.coordinates[0][1][0],t.geometry.coordinates[0][1][1]]];if(n({type:"Feature",properties:t.properties,angle:e.angle,geometry:{coordinates:i,type:"LineString"}}),r===3)return}return n(t)},onTrash:function(e){this.deleteFeature([e.rectangle.id],{silent:true}),this.changeMode("simple_select");}},Xe=_n;var We=[{id:"measure-label",type:"symbol",filter:["all",["==","$type","Point"],["==","user_type","measure"]],layout:{"text-field":["get","user_value"],"text-anchor":["get","user_anchor"],"text-offset":["match",["get","user_anchor"],"bottom",[0,-0.5],[0,0]],"text-size":12,"text-allow-overlap":true,"text-ignore-placement":true},paint:{"text-halo-color":"rgba(255,255,255,0.75)","text-halo-width":2,"text-halo-blur":1,"text-color":"#000"}}];var Tn=e=>{let[t]=a();t.isMapLibre&&e.lib.constants?.classes&&Object.assign(e.lib.constants.classes,{CANVAS:"maplibregl-canvas",CONTROL_BASE:"maplibregl-ctrl",CONTROL_PREFIX:"maplibregl-ctrl-",CONTROL_GROUP:"maplibregl-ctrl-group",ATTRIBUTION:"maplibregl-ctrl-attrib"});let n=new e.lib({styles:[...e.lib.lib.theme,...We],modes:{...e.lib.modes,draw_point:Ne(e.lib),draw_line_string:Ze(e.lib),draw_polygon:qe(e.lib),multi_point:Fe,radius:Ge(e.lib),rectangle:Be(e.lib),rectangle_assisted:Xe},userProperties:{showLength:e.showLength||false,showArea:e.showArea||false},...e.options});t.map.addControl(n,e.position||"top-right"),e.getInstance&&e.getInstance(n);let o={};return ye.forEach(r=>{if(e[r]){let i=`draw.${r.slice(2).toLowerCase()}`,a=s=>e[r](s);o[i]=a,t.map.on(i,a);}}),onCleanup(()=>{Object.keys(o).forEach(r=>t.map.off(r,o[r])),t.map?.removeControl(n);}),null};var An=e=>{let[t]=a(),n;return W(()=>(n||(n=new e.overlay(e.props||{})),n)),createEffect(()=>n?.setProps(e.props||{})),null};
9
9
 
10
- export { Yt as Atmosphere, wn as Camera, rn as Control, Vn as DeckOverlay, Rn as Draw, hn as Image, Ft as Layer, qt as Layer3D, Sn as Light, ln as Marker, un as Popup, Mt as Source, Qt as Terrain, pt as default, ne as disableRasterFade, Ae as patternList, q as settleAfterIdle, Fe as symbolList, W as toSDF, Nt as useScene, V as useSourceId, G as waitForIdleAndSettle };
10
+ export { jt as Atmosphere, hn as Camera, Kt as Control, An as DeckOverlay, Tn as Draw, dn as Image, kt as Layer, zt as Layer3D, Mn as Light, tn as Marker, rn as Popup, vt as Source, Gt as Terrain, mt as default, oe as disableRasterFade, $e as patternList, q as settleAfterIdle, Ae as symbolList, H as toSDF, Rt as useScene, V as useSourceId, G as waitForIdleAndSettle };
@@ -259,6 +259,7 @@ function waitForIdleAndSettle(map, options = {}) {
259
259
  map.once("idle", () => {
260
260
  settleAfterIdle(map, options).then(resolve);
261
261
  });
262
+ map.triggerRepaint();
262
263
  });
263
264
  }
264
265
  function disableRasterFade(map) {
@@ -383,9 +384,9 @@ var MapGL = (props) => {
383
384
  map.once("load", () => {
384
385
  setMapLoaded(map);
385
386
  debug("Map loaded");
386
- if (props.offscreen) {
387
- if (props.offscreen.disableRasterFade !== false) disableRasterFade(map);
388
- props.onCapturerReady?.(
387
+ if (props.offscreen && props.offscreen.disableRasterFade !== false) disableRasterFade(map);
388
+ if (props.onCapturerReady) {
389
+ props.onCapturerReady(
389
390
  createCapturer(map, {
390
391
  timeout: props.tilesLoadedTimeout ?? 1e4,
391
392
  fadeMargin: props.tilesLoadedFadeMargin ?? 400
@@ -541,7 +542,7 @@ var MapGL = (props) => {
541
542
  };
542
543
  createEffect((prev) => {
543
544
  const style = getStyle(props.options?.style, props.darkStyle);
544
- if (map?.isStyleLoaded() && prev !== style) {
545
+ if (map && prev !== style) {
545
546
  const oldStyle = map.getStyle();
546
547
  const oldLayers = oldStyle.layers.filter(
547
548
  (l) => map.layerIdList.includes(l.id)
@@ -656,7 +657,9 @@ var Source = (props) => {
656
657
  case "geojson":
657
658
  createEffect2(() => {
658
659
  const data = anySource().data;
659
- ctx.map.getSource(props.id).setData(data || {});
660
+ const source = ctx.map.getSource(props.id);
661
+ if (!source) return;
662
+ source.setData(data || {});
660
663
  debug("Update GeoJSON Data:", props.id);
661
664
  });
662
665
  break;
@@ -664,7 +667,9 @@ var Source = (props) => {
664
667
  createEffect2(() => {
665
668
  const url = anySource().url;
666
669
  const coords = anySource().coordinates;
667
- ctx.map.getSource(props.id).updateImage(url, coords);
670
+ const source = ctx.map.getSource(props.id);
671
+ if (!source) return;
672
+ source.updateImage(url, coords);
668
673
  debug("Update Image Data:", props.id);
669
674
  });
670
675
  break;
@@ -673,6 +678,7 @@ var Source = (props) => {
673
678
  const url = anySource().url;
674
679
  const tiles = anySource().tiles;
675
680
  const source = ctx.map.getSource(props.id);
681
+ if (!source) return;
676
682
  url ? source.setUrl(url) : source.setTiles(tiles);
677
683
  debug("Update Vector Data:", props.id);
678
684
  });
@@ -681,6 +687,7 @@ var Source = (props) => {
681
687
  createEffect2(() => {
682
688
  const src = lookup(anySource().url);
683
689
  const source = ctx.map.getSource(props.id);
690
+ if (!source) return;
684
691
  src.url ? source.setUrl(src.url) : source.setTiles(src.tiles);
685
692
  debug("Update Raster Data:", props.id);
686
693
  });
@@ -803,37 +810,8 @@ var resolveColor = (value) => {
803
810
  }
804
811
  return value;
805
812
  };
806
- var toRgbaComponents = (value) => {
807
- const rgb = toRgbString(resolveColor(value)) ?? value;
808
- const match = rgb.match(/rgba?\(([^)]+)\)/i);
809
- if (!match) return [0, 0, 0, 1];
810
- const [r, g, b, a = 1] = match[1].split(",").map(Number);
811
- return [r, g, b, a];
812
- };
813
813
 
814
814
  // src/components/Layer/index.tsx
815
- var PULSE_DEFAULTS = {
816
- property: "icon-halo-width",
817
- from: 0,
818
- to: 4,
819
- duration: 1500,
820
- waveform: "out"
821
- };
822
- var PULSE_RAMP_FRACTION = 0.75;
823
- var easeOutQuad = (t) => 1 - (1 - t) * (1 - t);
824
- var pulseShape = (elapsed, duration, waveform) => {
825
- const phase = elapsed % duration / duration;
826
- if (waveform === "in-out") return (1 - Math.cos(phase * Math.PI * 2)) / 2;
827
- const ramp = Math.min(phase / PULSE_RAMP_FRACTION, 1);
828
- return easeOutQuad(ramp);
829
- };
830
- var lerpColor = (from, to, t) => {
831
- const r = Math.round(from[0] + (to[0] - from[0]) * t);
832
- const g = Math.round(from[1] + (to[1] - from[1]) * t);
833
- const b = Math.round(from[2] + (to[2] - from[2]) * t);
834
- const a = from[3] + (to[3] - from[3]) * t;
835
- return `rgba(${r}, ${g}, ${b}, ${a})`;
836
- };
837
815
  var diff = (newProps = {}, prevProps = {}) => {
838
816
  const keys = /* @__PURE__ */ new Set([...Object.keys(newProps), ...Object.keys(prevProps)]);
839
817
  return [...keys].reduce((acc, key) => {
@@ -992,49 +970,25 @@ var Layer = (props) => {
992
970
  });
993
971
  createEffect3(() => {
994
972
  if (!props.pulse) return;
995
- const configs = props.pulse === true ? [{}] : Array.isArray(props.pulse) ? props.pulse : [props.pulse];
996
- const resolved = configs.map((config) => {
997
- const { property, from, to, duration, waveform } = {
998
- ...PULSE_DEFAULTS,
999
- ...config
1000
- };
1001
- const isColor = typeof from === "string" || typeof to === "string";
1002
- const [a, b] = waveform === "in" ? [to, from] : [from, to];
1003
- return {
1004
- property,
1005
- duration,
1006
- waveform,
1007
- isColor,
1008
- fromNum: isColor ? 0 : a,
1009
- toNum: isColor ? 0 : b,
1010
- fromRgba: isColor ? toRgbaComponents(a) : null,
1011
- toRgba: isColor ? toRgbaComponents(b) : null
973
+ const configs = Array.isArray(props.pulse) ? props.pulse : [props.pulse];
974
+ const timers = configs.map((config) => {
975
+ const { property, duration = 1500, holdFraction = 0.25 } = config;
976
+ const from = resolveColor2(property, config.from);
977
+ const to = resolveColor2(property, config.to);
978
+ const rampMs = duration * (1 - holdFraction);
979
+ const beat = () => {
980
+ ctx.map.setPaintProperty(layerId, `${property}-transition`, { duration: 0, delay: 0 }, { validate: false });
981
+ ctx.map.setPaintProperty(layerId, property, from, { validate: false });
982
+ requestAnimationFrame(() => {
983
+ ctx.map.setPaintProperty(layerId, `${property}-transition`, { duration: rampMs, delay: 0 }, { validate: false });
984
+ ctx.map.setPaintProperty(layerId, property, to, { validate: false });
985
+ });
1012
986
  };
987
+ beat();
988
+ return window.setInterval(beat, duration);
1013
989
  });
1014
- resolved.forEach((cfg) => {
1015
- ctx.map.setPaintProperty(
1016
- layerId,
1017
- `${cfg.property}-transition`,
1018
- { duration: 0, delay: 0 },
1019
- { validate: false }
1020
- );
1021
- });
1022
- const start = performance.now();
1023
- let frameId;
1024
- const loop = (now) => {
1025
- const elapsed = now - start;
1026
- resolved.forEach((cfg) => {
1027
- const t = pulseShape(elapsed, cfg.duration, cfg.waveform);
1028
- const value = cfg.isColor ? lerpColor(cfg.fromRgba, cfg.toRgba, t) : cfg.fromNum + (cfg.toNum - cfg.fromNum) * t;
1029
- ctx.map.setPaintProperty(layerId, cfg.property, value, {
1030
- validate: false
1031
- });
1032
- });
1033
- frameId = window.requestAnimationFrame(loop);
1034
- };
1035
- frameId = window.requestAnimationFrame(loop);
1036
990
  debug(`Start Pulse (${layerId}):`, props.pulse);
1037
- onCleanup3(() => window.cancelAnimationFrame(frameId));
991
+ onCleanup3(() => timers.forEach((timer) => window.clearInterval(timer)));
1038
992
  });
1039
993
  onCleanup3(() => ctx.map?.getLayer(layerId) && ctx.map?.removeLayer(layerId));
1040
994
  return props.children;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.1",
2
+ "version": "2.2.3",
3
3
  "name": "solid-map-gl",
4
4
  "description": "SolidJS Component Library for Mapbox GL JS & MapLibre GL JS",
5
5
  "info": "SolidJS Component Library for Mapbox GL JS & MapLibre GL JS. Mapbox GL JS and MapLibre GL JS are JavaScript libraries that render interactive maps from vector tiles and map styles using WebGL. This project is intended to be as close as possible to the Mapbox GL JS API.",
@@ -70,7 +70,7 @@
70
70
  "devDependencies": {
71
71
  "@solidjs/testing-library": "^0.8.10",
72
72
  "@testing-library/jest-dom": "^7.0.1",
73
- "@vitest/coverage-v8": "^5.0.0",
73
+ "@vitest/coverage-v8": "^5.0.1",
74
74
  "jsdom": "^30.0.1",
75
75
  "jsdom-worker": "^0.3.0",
76
76
  "mapbox-gl": "^3.30.0",
@@ -82,7 +82,7 @@
82
82
  "typescript": "^6.0.3",
83
83
  "vite": "^8.2.2",
84
84
  "vite-plugin-solid": "^2.11.10",
85
- "vitest": "^5.0.0"
85
+ "vitest": "^5.0.1"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@babylonjs/core": "^6.24.0",