New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

maplibre-react-components

Package Overview
Dependencies
Maintainers
0
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

maplibre-react-components - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

88

index.d.ts
import * as react from 'react';
import { ReactNode, CSSProperties, MutableRefObject } from 'react';
import * as maplibre_gl from 'maplibre-gl';
import { ReactNode, CSSProperties, Dispatch, SetStateAction, MutableRefObject } from 'react';
import { TerrainSpecification, LayerSpecification, CustomLayerInterface, MapLayerMouseEvent, MapLayerTouchEvent, Source, SourceSpecification, PaddingOptions, StyleSpecification, StyleSwapOptions, Map, MapWheelEvent, MapLibreEvent, MapLibreZoomEvent, MapContextEvent, MapDataEvent, MapStyleDataEvent, MapSourceDataEvent, MapStyleImageMissingEvent, MapTerrainEvent, MapOptions, TransformStyleFunction, Marker, MarkerOptions, Popup, PopupOptions, LngLat, ControlPosition, AttributionControlOptions, IControl, FullscreenControlOptions, GeolocateControlOptions, LogoControlOptions, NavigationControlOptions, ScaleControlOptions, LngLatLike, PointLike, Offset } from 'maplibre-gl';

@@ -177,3 +176,3 @@ import * as react_jsx_runtime from 'react/jsx-runtime';

};
declare const markerReactiveOptionNames: readonly ["className", "offset", "draggable", "clickTolerance", "rotation", "rotationAlignment", "pitchAlignment", "opacity", "opacityWhenCovered"];
declare const markerReactiveOptionNames: readonly ["className", "offset", "draggable", "clickTolerance", "rotation", "rotationAlignment", "pitchAlignment", "opacity", "opacityWhenCovered", "subpixelPositioning"];
type MarkerReactiveOptionName = (typeof markerReactiveOptionNames)[number];

@@ -266,3 +265,3 @@ type MarkerReactiveOptions = {

};
declare const gradientMarkerReactiveOptionNames: readonly ["className", "clickTolerance", "color", "draggable", "icon", "interactive", "opacity", "opacityWhenCovered", "pitchAlignment", "rotation", "rotationAlignment", "scale", "shape", "text"];
declare const gradientMarkerReactiveOptionNames: readonly ["className", "clickTolerance", "rotation", "rotationAlignment", "pitchAlignment", "opacity", "opacityWhenCovered", "subpixelPositioning", "color", "draggable", "icon", "interactive", "scale", "shape", "text"];
type GradientMarkerReactiveOptionName = (typeof gradientMarkerReactiveOptionNames)[number];

@@ -295,2 +294,21 @@ type GradientMarkerReactiveOptions = {

type MountedState = [boolean, Dispatch<SetStateAction<boolean>>];
declare class MapManagers {
private _maps;
private _listeners;
add(id: string, mapManager: MapManager): void;
remove(id: string): void;
get(id: string | null): MapManager | null;
addListener(id: string, mountedState: MountedState): void;
removeListener(id: string, [, callback]: MountedState): void;
}
declare const RMapContext: react.Context<MutableRefObject<MapManagers> | null>;
interface RMapContextProviderProps {
children: ReactNode;
}
declare const RMapContextProvider: ({ children }: RMapContextProviderProps) => react_jsx_runtime.JSX.Element;
declare const CurrentMapIdContext: react.Context<string | null>;
interface MapLibreReactLogoProps {

@@ -333,30 +351,5 @@ height?: number;

declare function useMap(): maplibre_gl.Map;
declare function useMap(): Map;
declare function useMap(id: string): Map | null;
type RControlHookOptions<T extends string = ControlPosition> = {
position: T;
className?: string;
};
type RControlHookReturn = {
container: HTMLDivElement;
};
declare function useRControl<T extends string = ControlPosition>({ position, className, }: RControlHookOptions<T>): RControlHookReturn;
type ControlHookOptions = {
position: ControlPosition;
factory: (map: Map) => IControl;
onRemove?: (map: Map) => void;
};
type ControlHookReturn = IControl;
declare function useControl({ position, factory, onRemove, }: ControlHookOptions): ControlHookReturn;
type useMapAndCanvasRefsReturn = {
mapRef: MutableRefObject<Map>;
canvasRef: MutableRefObject<HTMLElement>;
setMapAndCanvasRef: (map: Map) => void;
};
declare const useMapAndCanvasRefs: () => useMapAndCanvasRefsReturn;
declare const useCanvasRef: () => react.MutableRefObject<HTMLElement>;
declare function filterMapProps(options: MapProps): readonly [MapReactiveOptions, MapCallbacks, MapHandlerOptions];

@@ -399,8 +392,33 @@ declare function transformPropsToOptions(props: {

declare const emptyStyle: StyleSpecification;
declare function uniqueId(): string;
type MapLibreContext = {
mapManager?: MapManager;
declare function useMapManager(): MapManager;
declare function useMapManager(id: string): MapManager | null;
type RControlHookOptions<T extends string = ControlPosition> = {
position: T;
className?: string;
};
declare const mapLibreContext: react.Context<MapLibreContext>;
type RControlHookReturn = {
container: HTMLDivElement;
};
declare function useRControl<T extends string = ControlPosition>({ position, className, }: RControlHookOptions<T>): RControlHookReturn;
export { ContextMenuEventAdapter, type Event, GradientMarker, type MapLibreContext, MapLibreReactLogo, MapManager, type MaplibreContextmenuEventDetail, MrcLogoControl, RAttributionControl, RFullscreenControl, RGeolocateControl, RGradientMarker, RLayer, RLogoControl, RMap, RMarker, RNavigationControl, RPopup, RScaleControl, RSource, RTerrain, RTerrainControl, areCoordsClose, areLngLatClose, arePointsEqual, deepEqual, emptyStyle, filterMapProps, gradientMarkerPopupOffset, lngLatClassToObj, mapLibreContext, markerPopupOffset, prepareEventDep, transformPropsToOptions, updateClassNames, updateListeners, useCanvasRef, useControl, useMap, useMapAndCanvasRefs, useRControl };
type ControlHookOptions = {
position: ControlPosition;
factory: (map: Map) => IControl;
onRemove?: (map: Map) => void;
};
type ControlHookReturn = IControl;
declare function useControl({ position, factory, onRemove, }: ControlHookOptions): ControlHookReturn;
type useMapAndCanvasRefsReturn = {
mapRef: MutableRefObject<Map>;
canvasRef: MutableRefObject<HTMLElement>;
setMapAndCanvasRef: (map: Map) => void;
};
declare const useMapAndCanvasRefs: () => useMapAndCanvasRefsReturn;
declare const useCanvasRef: () => react.MutableRefObject<HTMLElement>;
export { ContextMenuEventAdapter, CurrentMapIdContext, type Event, GradientMarker, MapLibreReactLogo, MapManager, type MaplibreContextmenuEventDetail, MrcLogoControl, RAttributionControl, RFullscreenControl, RGeolocateControl, RGradientMarker, RLayer, RLogoControl, RMap, RMapContext, RMapContextProvider, RMarker, RNavigationControl, RPopup, RScaleControl, RSource, RTerrain, RTerrainControl, areCoordsClose, areLngLatClose, arePointsEqual, deepEqual, emptyStyle, filterMapProps, gradientMarkerPopupOffset, lngLatClassToObj, markerPopupOffset, prepareEventDep, transformPropsToOptions, uniqueId, updateClassNames, updateListeners, useCanvasRef, useControl, useMap, useMapAndCanvasRefs, useMapManager, useRControl };

@@ -1,1 +0,1 @@

"use client";var Ze=Object.create;var se=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Fe=Object.prototype.hasOwnProperty;var $e=(t,e)=>()=>(t&&(e=t(t=0)),e);var Be=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Ue=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of je(e))!Fe.call(t,r)&&r!==o&&se(t,r,{get:()=>e[r],enumerable:!(n=ze(e,r))||n.enumerable});return t};var qe=(t,e,o)=>(o=t!=null?Ze(Ve(t)):{},Ue(e||!t||!t.__esModule?se(o,"default",{value:t,enumerable:!0}):o,t));var a=$e(()=>{"use strict"});var Pe=Be((Tr,Se)=>{"use strict";a();Se.exports=j;function j(t,e){this.x=t,this.y=e}j.prototype={clone:function(){return new j(this.x,this.y)},add:function(t){return this.clone()._add(t)},sub:function(t){return this.clone()._sub(t)},multByPoint:function(t){return this.clone()._multByPoint(t)},divByPoint:function(t){return this.clone()._divByPoint(t)},mult:function(t){return this.clone()._mult(t)},div:function(t){return this.clone()._div(t)},rotate:function(t){return this.clone()._rotate(t)},rotateAround:function(t,e){return this.clone()._rotateAround(t,e)},matMult:function(t){return this.clone()._matMult(t)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,o=t.y-this.y;return e*e+o*o},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult:function(t){var e=t[0]*this.x+t[1]*this.y,o=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=o,this},_add:function(t){return this.x+=t.x,this.y+=t.y,this},_sub:function(t){return this.x-=t.x,this.y-=t.y,this},_mult:function(t){return this.x*=t,this.y*=t,this},_div:function(t){return this.x/=t,this.y/=t,this},_multByPoint:function(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint:function(t){return this.x/=t.x,this.y/=t.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var t=this.y;return this.y=this.x,this.x=-t,this},_rotate:function(t){var e=Math.cos(t),o=Math.sin(t),n=e*this.x-o*this.y,r=o*this.x+e*this.y;return this.x=n,this.y=r,this},_rotateAround:function(t,e){var o=Math.cos(t),n=Math.sin(t),r=e.x+o*(this.x-e.x)-n*(this.y-e.y),i=e.y+n*(this.x-e.x)+o*(this.y-e.y);return this.x=r,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}};j.convert=function(t){return t instanceof j?t:Array.isArray(t)?new j(t[0],t[1]):t}});a();a();a();a();import{forwardRef as Xe,useImperativeHandle as et,useMemo as tt,useRef as Q,useState as ot}from"react";a();import{Map as Je}from"maplibre-gl";a();import{LngLat as ce}from"maplibre-gl";function le(t){let e={},o={},n={};for(let r in t)if(r.startsWith("on"))e[r]=t[r];else if(Y.includes(r))o[r]=t[r];else if(K.includes(r))n[r]=t[r];else if(!r.startsWith("initial")&&r!=="container"&&r!=="style")throw Error(`unknown map option key ${r}`);return[n,e,o]}function _(t){let e={},o={};for(let n in t)if(n.startsWith("on"))e[n]=t[n];else{let r=n.startsWith("initial")?n[7].toLowerCase()+n.substring(8):n;if(o[r])throw new Error(`duplicate key ${r}`);o[r]=t[n]}return[o,e]}function w(t,e){return Object.keys(t).filter(n=>t[n]in e).sort()}function Z(t,e){if(t===e)return!0;if(!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!Z(t[o],e[o]))return!1;return!0}else if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),n=Object.keys(e);if(o.length!==n.length)return!1;for(let r of o)if(!Object.prototype.hasOwnProperty.call(e,r)||!Z(t[r],e[r]))return!1;return!0}return!1}function qo(t,e){return!t&&!e?!0:!t||!e?!1:Math.round(t.lng*1e5)===Math.round(e.lng*1e5)&&Math.round(t.lat*1e5)===Math.round(e.lat*1e5)}function Jo(t,e){if(!t&&!e)return!0;if(!t||!e)return!1;let o=ce.convert(t),n=ce.convert(e);return Math.round(o.lng*1e5)===Math.round(n.lng*1e5)&&Math.round(o.lat*1e5)===Math.round(n.lat*1e5)}function Ko(t){return{lng:t.lng,lat:t.lat}}function pe(t,e){let o=Array.isArray(t)?t[0]:t?t.x:0,n=Array.isArray(t)?t[1]:t?t.y:0,r=Array.isArray(e)?e[0]:e?e.x:0,i=Array.isArray(e)?e[1]:e?e.y:0;return o===r&&n===i}function z(t,e,o){e.forEach(n=>{n!==""&&o.indexOf(n)===-1&&t.classList.remove(n)}),o.forEach(n=>{n!==""&&(e.indexOf(n)===-1||!t.classList.contains(n))&&t.classList.add(n)})}function ue(t,e,o,n){t.forEach(r=>{r!==""&&e.indexOf(r)===-1&&n(r)}),e.forEach(r=>{r!==""&&t.indexOf(r)===-1&&o(r)})}var $=41-5.8/2,b=13.5,W=Math.abs(b)/Math.SQRT2,Yo={top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-$],"bottom-left":[W,($-b+W)*-1],"bottom-right":[-W,($-b+W)*-1],left:[b,($-b)*-1],right:[-b,($-b)*-1]},B=50,Qo={top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-B],"bottom-left":[W,(B-b+W)*-1],"bottom-right":[-W,(B-b+W)*-1],left:[b,(B-b)*-1],right:[-b,(B-b)*-1]},Xo={version:8,name:"Empty",sources:{},layers:[]};var me={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mouseout:"onMouseOut",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",click:"onClick",dblclick:"onDblClick",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchcancel:"onTouchCancel",touchmove:"onTouchMove",movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd",wheel:"onWheel",resize:"onResize",remove:"onRemove",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",webglcontextlost:"onWebglContextLost",webglcontextrestored:"onWebglContextRestored",load:"onLoad",render:"onRender",idle:"onIdle",error:"onError",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",dataloading:"onDataLoading",styledataloading:"onStyleDataLoading",sourcedataloading:"onSourceDataLoading",tiledataloading:"onTileDataLoading",styleimagemissing:"onStyleImageMissing",dataabort:"onDataAbort",sourcedataabort:"onSourceDataAbort",terrain:"onTerrain"},K=["maxBounds","minZoom","maxZoom","minPitch","maxPitch","renderWorldCopies","pixelRatio"];var Y=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch","cooperativeGestures"],fe="https://demotiles.maplibre.org/style.json",U=class{reactiveOptions={};handlerOptions={};eventNames=[];callbacks;_map;padding;mapStyle;controlledSources={};controlledLayers={};controlledTerrain=null;constructor({mapStyle:e=fe,padding:o},n,r){this.mapStyle=e,this.padding=o;let[i,s]=_(n);this.callbacks=s;let l={...i,container:r,style:e},d=new Je(l);d.style.on("error",this._onStyleError),o&&d.setPadding(o),this._map=d,this._updateCallbacks(s)}setProps({mapStyle:e=fe,styleDiffing:o=!0,styleTransformStyle:n,padding:r},i){let[s,l,d]=le(i);this._updateCallbacks(l),this._updateStyle(e,{diff:o,transformStyle:n}),this._updateReactiveOptions(s,{padding:r}),this._updateHandlers(d)}getControlledTerrain(){return this.controlledTerrain}setControlledTerrain(e){this.controlledTerrain=e}getControlledLayer(e){return this.controlledLayers[e]??null}setControlledLayer(e,o){o?this.controlledLayers[e]=o:delete this.controlledLayers[e]}getControlledSource(e){return this.controlledSources[e]??null}setControlledSource(e,o){o?this.controlledSources[e]=o:delete this.controlledSources[e]}_updateStyle(e,o){let n=this.mapStyle;e!==n&&(this.mapStyle=e,this._map.setStyle(e,{diff:o.diff,transformStyle:(r,i)=>{let s=r?Object.fromEntries(Object.entries(r?.sources).filter(([f])=>f in this.controlledSources)):{},l=r?r.layers.filter(f=>f.id in this.controlledLayers):[],d={...i,sources:{...i.sources,...s},layers:[...i.layers,...l],terrain:this.controlledTerrain?r?.terrain:i.terrain};return o.transformStyle?o.transformStyle(r,d):d}}))}_updateReactiveOptions(e,{padding:o}){let n=this.reactiveOptions;this.reactiveOptions=e;for(let r of K)if(r in e&&!Z(n[r],e[r])){let i=`set${r[0].toUpperCase()}${r.substring(1)}`;this._map[i](e[r])}o&&!Z(this.padding,o)&&this._map.setPadding(o),this.padding=o}_updateCallbacks(e={}){this.callbacks=e;let o=w(me,e);this.eventNames.join("-")!==o.join("-")&&(ue(this.eventNames,o,n=>this._map.on(n,this._onMapEvent),n=>this._map.off(n,this._onMapEvent)),this.eventNames=o)}_updateHandlers(e){let o=this.handlerOptions;this.handlerOptions=e;for(let n of Y){let r=e[n]??!0,i=o[n]??!0;Z(r,i)||(r?this._map[n].enable(r):this._map[n].disable())}}_onStyleError=e=>{e.error.name!=="AbortError"&&console.error(e.error)};_onMapEvent=e=>{let o=e.type,n=me[o];this.callbacks[n]?this.callbacks[n]?.(e):console.info("not managed RMap event",o,e)};get map(){return this._map}destroy(){this._updateCallbacks(),this._map.remove()}};a();import{createContext as Ke}from"react";var T=Ke({mapManager:void 0});a();import{useEffect as Ye,useLayoutEffect as Qe}from"react";var q=typeof window<"u"?Qe:Ye;import{jsx as X}from"react/jsx-runtime";var nt={height:"100%"},de=Xe(function({children:e,style:o,id:n,className:r,onMounted:i,mapStyle:s,styleDiffing:l,styleTransformStyle:d,padding:f,...v},c){let p=Q(null),y=Q({mapManager:void 0}),M=Q(!0),[,L]=ot(0);q(()=>{y.current.mapManager?M.current?y.current.mapManager.setProps({mapStyle:s,padding:f,styleDiffing:l,styleTransformStyle:d},v):M.current=!0:(y.current.mapManager=new U({mapStyle:s,styleDiffing:l,padding:f},v,p.current),i&&i(y.current.mapManager.map),L(g=>g+1),M.current=!1)}),q(()=>()=>{y.current.mapManager&&(y.current.mapManager.destroy(),y.current.mapManager=void 0)},[]),et(c,()=>y.current.mapManager?.map||null,[]),q(()=>{if(!r)return;let g=p.current;return r.split(" ").map(E=>g.classList.add(E)),()=>void r.split(" ").map(E=>g.classList.remove(E))},[r]);let C=tt(()=>({position:"relative",width:"100%",height:"100%",...o}),[o]);return X("div",{ref:p,id:n,style:C,children:y.current.mapManager&&X(T.Provider,{value:y.current,children:X("div",{className:"maplibregl-children",style:nt,children:e})})})});a();a();import{Marker as at}from"maplibre-gl";import{forwardRef as it,memo as st,useEffect as ve,useImperativeHandle as ct,useMemo as lt,useRef as ye}from"react";import{createPortal as pt}from"react-dom";a();import{useContext as rt}from"react";function R(){let t=rt(T);if(!t.mapManager)throw new Error("use useMap in components inside <RMap />");return t.mapManager.map}var Me={dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",click:"onClick"};var he=st(it(function(e,o){let{longitude:n,latitude:r,children:i,...s}=e,l=R(),[d,f]=_(s),v=ye(d),c=ye();c.current=f;let p=lt(()=>{let S={...d,element:i?document.createElement("div"):void 0},A=new at(S);return A.setLngLat([n,r]),A},[]),y=w(Me,f).join("-");ve(()=>{function S(P){let F=P.type,N=Me[F];c.current?.[N]?c.current[N]?.(P):console.info("not managed RMarker event",F,P)}let A=y.split("-");return A.forEach(P=>{P==="click"?p.getElement().addEventListener("click",S):p.on(P,S)}),()=>{A.forEach(P=>{P==="click"?p.getElement().removeEventListener("click",S):p.off(P,S)})}},[y,p]),ve(()=>(p.addTo(l),()=>void p.remove()),[]);let{className:M,offset:L,draggable:C,clickTolerance:g=0,rotation:E,rotationAlignment:k,pitchAlignment:O,opacity:h,opacityWhenCovered:D}=d;return ct(o,()=>p,[p]),v.current.className!==M&&z(p._element,v.current.className?.split(" ")||[],M?.split(" ")||[]),(p.getLngLat().lng!==n||p.getLngLat().lat!==r)&&p.setLngLat([n,r]),L&&!pe(p.getOffset(),L)&&p.setOffset(L),p.isDraggable()!==C&&p.setDraggable(C),p._clickTolerance!==g&&(p._clickTolerance=g),p.getRotation()!==E&&p.setRotation(E),p.getRotationAlignment()!==k&&p.setRotationAlignment(k),p.getPitchAlignment()!==O&&p.setPitchAlignment(O),(p._opacity!==h||p._opacityWhenCovered!==D)&&p.setOpacity(h,D),v.current=d,i?pt(i,p.getElement()):null}));a();a();import{Popup as ut}from"maplibre-gl";import{forwardRef as mt,memo as ft,useEffect as ge,useImperativeHandle as dt,useMemo as vt,useRef as ee}from"react";import{createPortal as yt}from"react-dom";var te={map_click:"onMapClick",map_move:"onMapMove"};var Ee=ft(mt(function(e,o){let{longitude:n,latitude:r,children:i,...s}=e,l=R(),[d,f]=_(s),v=ee(null),c=ee(d),p=ee();p.current=f;let y=vt(()=>document.createElement("div"),[]);v.current||(v.current=new ut({...d,closeButton:!1,closeOnClick:!1,closeOnMove:!1}),n!==void 0&&r!==void 0&&v.current.setLngLat([n,r]));let M=w(te,f).join("-");ge(()=>{function E(h){let D=h.type,S=te[D]||te[`map_${D}`];p.current?.[S]?p.current[S]?.(h):console.info("not managed RPopup event",D,h)}if(M==="")return;let k=M.split("-"),O=v.current;return k.forEach(h=>{h.startsWith("map_")?l.on(h.substring(4),E):O.on(h,E)}),()=>{k.forEach(h=>{h.startsWith("map_")?l.off(h.substring(4),E):O.off(h,E)})}},[M,l]),ge(()=>(v.current.setDOMContent(y).addTo(l),()=>void v.current.remove()),[y,l]);let{offset:L,maxWidth:C="240px",className:g}=d;return dt(o,()=>v.current,[v]),v.current.isOpen()&&(n!==void 0&&r!==void 0&&(v.current.getLngLat().lng!==n||v.current.getLngLat().lat!==r)&&v.current.setLngLat([n,r]),L&&!Z(v.current.options.offset,L)&&v.current.setOffset(L),c.current.className!==g&&z(y,c.current.className?.split(" ")||[],g?.split(" ")||[]),v.current.getMaxWidth()!==C&&v.current.setMaxWidth(C)),c.current=d,yt(i,y)}));a();a();import{forwardRef as Mt,memo as ht,useCallback as gt,useContext as Et,useEffect as Ce,useImperativeHandle as Ct,useRef as ke,useState as kt}from"react";a();var Le={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mouseout:"onMouseOut",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",click:"onClick",dblclick:"onDblClick",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchcancel:"onTouchCancel",touchmove:"onTouchMove"};function Lt(t,e,o){if(t.style?._loaded&&(e.type==="background"||e.type==="custom"||e.source&&t.getSource(e.source)))return t.addLayer(e,o&&t.getLayer(o)?o:void 0),t.getLayer(e.id)}function Rt(t,{beforeId:e,...o},{beforeId:n,...r}){if(r.type==="custom"||o.type==="custom")return;n!==e&&t.moveLayer(o.id,e),o.type!=="background"&&o.type!=="custom"&&r.filter!==o.filter&&t.setFilter(o.id,o.filter);let i=r,s=o;if(i.layout!==s.layout){if(s.layout)for(let l of Object.keys(s.layout))s.layout[l]!==i.layout?.[l]&&t.setLayoutProperty(o.id,l,s.layout[l]);for(let l in i.layout)Object.prototype.hasOwnProperty.call(s.layout,l)||t.setLayoutProperty(o.id,l,void 0)}if(i.paint!==s.paint){if(s.paint)for(let l of Object.keys(s.paint))s.paint[l]!==i.paint?.[l]&&t.setPaintProperty(o.id,l,s.paint[l]);for(let l in i.paint)Object.prototype.hasOwnProperty.call(s.paint,l)||t.setPaintProperty(o.id,l,void 0)}(i.minzoom!==s.minzoom||i.maxzoom!==s.maxzoom)&&s.minzoom&&s.maxzoom&&t.setLayerZoomRange(o.id,s.minzoom,s.maxzoom)}var Re=ht(Mt(function(e,o){let{beforeId:n,...r}=e,[i,s]=_(r),l=i.id,d=Et(T);if(!d.mapManager)throw new Error("use <RLayer /> component inside <RMap />");let f=d.mapManager.map,v=ke(l);if(l!==v.current)throw new Error(`RLayer id should not change. "${l}" "${v.current}". If you defined id as const string add a "key" prop to your RLayer component`);let c=d.mapManager.getControlledLayer(l)??e,[,p]=kt(0),y=gt(()=>p(g=>g+1),[]);if(e.type!==c.type)throw new Error(`RLayer type should not change. "${e.type}" "${c.type}"`);let M=ke();M.current=s,Ce(()=>(f.on("styledata",y),f.style._loaded&&y(),()=>{f.off("styledata",y),f.style&&f.style._loaded&&f.getLayer(l)&&f.removeLayer(l),d.mapManager?.setControlledLayer(l,null)}),[f,l,d,y]);let L=w(Le,s).join("-");Ce(()=>{function g(k){let O=k.type,h=Le[O];M.current?.[h]?M.current[h]?.(k):console.info("not managed RLayer event",O,k)}let E=L.split("-");return E.forEach(k=>{f.on(k,l,g)}),()=>{E.forEach(k=>{f.off(k,l,g)})}},[L,l,f]);let C=f.style?._loaded&&f.getLayer(l);return C?Rt(f,e,c):(C=Lt(f,i,n),C&&f.off("styledata",y)),Ct(o,()=>C||null,[C]),d.mapManager.setControlledLayer(l,e),null}));a();a();import{forwardRef as xt,useEffect as bt,useRef as St,useState as Pt,useImperativeHandle as Ot,useContext as Tt,memo as Nt,useCallback as _t}from"react";function wt(t,e,o){if(t.style?._loaded)return t.addSource(e,o),t.getSource(e)}function It(t,e,o){switch(e.type){case"image":{let n=o,r=e;n.url!==r.url&&t.updateImage({url:r.url,coordinates:r.coordinates}),n.coordinates!==r.coordinates&&t.setCoordinates(r.coordinates);break}case"video":{let n=o,r=e;n.coordinates!==r.coordinates&&t.setCoordinates(r.coordinates);break}case"geojson":{let n=o,r=e;n.data!==r.data&&t.setData(r.data),(n.cluster!==r.cluster||n.clusterMaxZoom!==r.clusterMaxZoom||n.clusterRadius!==r.clusterRadius)&&t.setClusterOptions({cluster:r.cluster,clusterMaxZoom:r.clusterMaxZoom,clusterRadius:r.clusterRadius});break}case"raster":case"raster-dem":case"vector":{let n=o,r=e;n.tiles!==r.tiles&&r.tiles&&t.setTiles(r.tiles),n.url!==r.url&&r.url&&t.setUrl(r.url);break}}}var xe=Nt(xt(function(e,o){let{id:n,...r}=e,i=Tt(T);if(!i.mapManager)throw new Error("use <RSource /> component inside <RMap />");let s=i.mapManager.map,l=St(n);if(n!==l.current)throw new Error(`RSource id should not change. "${n}" "${l.current}". If you defined id as const string add a "key" prop to your RSource component`);let{id:d,...f}=i.mapManager.getControlledSource(n)??e;if(r.type!==f.type)throw new Error(`RSource type should not change. "${r.type}" "${f.type}"`);let[,v]=Pt(0),c=_t(()=>void setTimeout(()=>v(y=>y+1),0),[]);bt(()=>(s.on("styledata",c),s.style._loaded&&c(),()=>{if(s.off("styledata",c),s.style&&s.getSource(n)){let y=s.getStyle()?.layers;if(y)for(let M of y)M.type!=="background"&&M.type!=="custom"&&M.source===n&&s.removeLayer(M.id);s.removeSource(n)}i.mapManager?.setControlledSource(n,null)}),[s,n,i,c]);let p=s.style?._loaded&&s.getSource(n);return p?It(p,r,f):(p=wt(s,n,r),p&&s.off("styledata",c)),Ot(o,()=>p||null,[p]),i.mapManager.setControlledSource(n,e),null}));a();a();import{useCallback as Dt,useContext as Gt,useEffect as Ht,useState as At}from"react";var be=t=>{let e=t,o=Gt(T);if(!o.mapManager)throw new Error("use <RTerrain /> component inside <RMap />");let n=o.mapManager.map,r=o.mapManager.getControlledTerrain()??t,[,i]=At(0),s=Dt(()=>i(d=>d+1),[]);return Ht(()=>(n.on("styledata",s),n.style._loaded&&s(),()=>{n.off("styledata",s),n.style?._loaded&&n.getTerrain()&&n.setTerrain(null),o.mapManager?.setControlledTerrain(null)}),[n,o,s]),n.style?._loaded&&(n.getSource(e.source)?n.getTerrain():!1)?(r.exaggeration!==e.exaggeration||r.source!==e.source)&&n.setTerrain(e):n.style?._loaded&&n.getSource(e.source)&&(n.setTerrain(e),n.off("styledata",s)),o.mapManager.setControlledTerrain(t),null};a();a();import{Marker as J}from"maplibre-gl";a();var Oe=qe(Pe(),1),I=class t{static docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style;static userSelect;static selectProp=t.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]);static transformProp=t.testProp(["transform","WebkitTransform"]);static testProp(e){if(!t.docStyle)return e[0];for(let o=0;o<e.length;o++)if(e[o]in t.docStyle)return e[o];return e[0]}static create(e,o,n){let r=window.document.createElement(e);return o!==void 0&&(r.className=o),n&&n.appendChild(r),r}static createNS(e,o){return window.document.createElementNS(e,o)}static disableDrag(){t.docStyle&&t.selectProp&&(t.userSelect=t.docStyle[t.selectProp],t.docStyle[t.selectProp]="none")}static enableDrag(){t.docStyle&&t.selectProp&&(t.docStyle[t.selectProp]=t.userSelect)}static setTransform(e,o){e.style[t.transformProp]=o}static addEventListener(e,o,n,r={}){"passive"in r?e.addEventListener(o,n,r):e.addEventListener(o,n,r.capture)}static removeEventListener(e,o,n,r={}){"passive"in r?e.removeEventListener(o,n,r):e.removeEventListener(o,n,r.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",t.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",t.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",t.suppressClickInternal,!0)},0)}static getScale(e){let o=e.getBoundingClientRect();return{x:o.width/e.offsetWidth||1,y:o.height/e.offsetHeight||1,boundingClientRect:o}}static getPoint(e,o,n){let r=o.boundingClientRect;return new Oe.default((n.clientX-r.left)/o.x-e.clientLeft,(n.clientY-r.top)/o.y-e.clientTop)}static mousePos(e,o){let n=t.getScale(e);return t.getPoint(e,n,o)}static touchPos(e,o){let n=[],r=t.getScale(e);for(let i=0;i<o.length;i++)n.push(t.getPoint(e,r,o[i]));return n}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}};var Te="#ffe64b",Ne=50,V=class extends J{_interactive;_shape;_icon;_height=Ne;_text;_circleElement=null;_iconElement=null;_textElement=null;_markerElement;constructor(e){e??={},e.element=I.create("div","maplibregl-gradient-marker"),e.className&&e.element.classList.add(e.className),super(e),this._draggable&&this._element.classList.add("draggable"),this._interactive=e&&e.interactive===!1?!1:"pending",this._shape=(e&&e.shape)??"pin",this._color=(e&&e.color)??Te,this._icon=e&&e.icon,this._text=e&&e.text,this._defaultMarker=!0,this._element.setAttribute("aria-label","Map marker"),this._element.setAttribute("tabindex","0"),this.setScale(this._scale),this.setColor(this._color),this._markerElement=I.create("div","marker"),this.setShape(this._shape),this._text?this.setText(this._text):this._icon&&this.setIcon(this._icon);let o=I.create("div","target");this._element.appendChild(this._markerElement),this._element.appendChild(o)}_onActive=()=>{this._map.getContainer().addEventListener("mouseup",this._onInactive,{once:!0}),this._map.getContainer().addEventListener("touchend",this._onInactive,{once:!0}),this._element.classList.add("active")};_onInactive=()=>{this._element.classList.remove("active")};addTo(e){return J.prototype.addTo.apply(this,[e]),this._interactive==="pending"&&this.setInteractive(!0),this}setInteractive(e=!0){this._interactive!==e&&(this._interactive=e,e?this._element.dataset.interactive="":delete this._element.dataset.interactive,e?(this._element.addEventListener("mousedown",this._onActive),this._element.addEventListener("touchstart",this._onActive)):(this._element.removeEventListener("mousedown",this._onInactive),this._element.removeEventListener("touchstart",this._onInactive)))}getInteractive(){return this._interactive}remove(){return this._map&&this.setInteractive(!1),J.prototype.remove.apply(this),this}setIcon(e){return this.resetIconText(),this._icon=e,e?(this._circleElement=I.create("div","circle",this._markerElement),typeof e=="string"?(this._iconElement=I.create("i",e,this._markerElement),this._iconElement.className=e||""):typeof e=="function"?(this._iconElement=e(),this._markerElement?.append(this._iconElement)):(this._iconElement=e,this._markerElement?.append(e)),this):this}getIcon(){return this._icon}resetIconText(){this._circleElement?.remove(),this._iconElement?.remove(),this._textElement?.remove(),this._circleElement=null,this._iconElement=null,this._textElement=null}setText(e){return this.resetIconText(),this._text=e,e?(this._circleElement=I.create("div","circle",this._markerElement),this._textElement=I.create("div","text",this._markerElement),this._textElement.innerText=e,this):this}getText(){return this._text}setColor(e){return this._color=e||Te,this._element.style.setProperty("--marker-color",this._color),this}getColor(){return this._color}setScale(e=1,o=Ne){return this._scale=e,this._height=o*this._scale,this._element.style.setProperty("--marker-scale",e.toString()),this}getScale(){return this._scale}setShape(e){return this._shape=e||"pin",this._anchor=this._shape==="pin"?"bottom":"center",this._element.dataset.shape=this._shape,this._update(),this}getShape(){return this._shape}setDraggable(e){return J.prototype.setDraggable.apply(this,[e]),this._element.classList.toggle("draggable",e),this}};a();import{forwardRef as Wt,memo as Zt,useEffect as _e,useImperativeHandle as zt,useMemo as jt,useRef as we}from"react";var Ie={dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",click:"onClick"};var De=Zt(Wt(function(e,o){let{longitude:n,latitude:r,...i}=e,s=R(),[l,d]=_(i),f=we(l),v=we();v.current=d;let c=jt(()=>{let N=new V({...l,anchor:"bottom"});return N.setLngLat([n,r]),N},[]),p=w(Ie,d).join("-");_e(()=>{function N(G){let ae=G.type,ie=Ie[ae];v.current?.[ie]?v.current[ie]?.(G):console.info("not managed RGradientMarker event",ae,G)}let re=p.split("-");return re.forEach(G=>{G==="click"?c.getElement().addEventListener("click",N):c.on(G,N)}),()=>{re.forEach(G=>{G==="click"?c.getElement().removeEventListener("click",N):c.off(G,N)})}},[p,c]),_e(()=>(c.addTo(s),()=>void c.remove()),[]);let{scale:y,color:M,text:L,icon:C,interactive:g,className:E,draggable:k,clickTolerance:O=0,rotation:h,rotationAlignment:D,pitchAlignment:S,shape:A,opacity:P,opacityWhenCovered:F}=l;return zt(o,()=>c,[c]),f.current.className!==E&&z(c._element,f.current.className?.split(" ")||[],E?.split(" ")||[]),c.getInteractive()!==g&&c.setInteractive(g),c.getShape()!==A&&c.setShape(A),(c.getLngLat().lng!==n||c.getLngLat().lat!==r)&&c.setLngLat([n,r]),c.isDraggable()!==k&&c.setDraggable(k),c._clickTolerance!==O&&(c._clickTolerance=O),c.getRotation()!==h&&c.setRotation(h),c.getRotationAlignment()!==D&&c.setRotationAlignment(D),c.getPitchAlignment()!==S&&c.setPitchAlignment(S),(c._opacity!==P||c._opacityWhenCovered!==F)&&c.setOpacity(P,F),c.getColor()!==M&&c.setColor(M),c.getScale()!==y&&c.setScale(y),c.getText()!==L&&c.setText(L),c.getIcon()!==C&&c.setIcon(C),f.current=l,null}));a();import{useEffect as Vt}from"react";function Ft({customEventName:t="contextmenu-maplibre",enabled:e=!0}){let o=R();return Vt(()=>{if(!e)return;let n=window.matchMedia("(pointer: coarse)").matches?"click":"contextmenu";function r(i){setTimeout(()=>{if(i.defaultPrevented)return;let{originalEvent:s,point:l,lngLat:d}=i;o.getCanvasContainer().dispatchEvent(new CustomEvent(t,{detail:{originalEvent:s,point:l,lngLat:d,emulated:n!=="contextmenu"}}))})}return o.on(n,r),()=>{o.off(n,r)}},[o,e,t]),null}a();a();import{memo as Bt,useState as Ut}from"react";a();import{useEffect as $t,useRef as Ge}from"react";function oe({position:t,className:e="maplibregl-ctrl maplibregl-ctrl-group"}){let o=R(),n=Ge(),r=Ge({className:e});if(!n.current){let i=document.createElement("div");i.className=e,n.current=i}return $t(()=>{let i=n.current;if(i&&!i.parentElement){let s=o._controlPositions[t];if(!s)throw new Error(`Unable to add control, position ${t} doesn't exists`);t.indexOf("bottom")!==-1?s.insertBefore(i,s.firstChild):s.appendChild(i)}return()=>{n.current&&n.current.remove()}},[o,t]),r.current.className!==e&&z(n.current,r.current.className?.split(" ")||[],e?.split(" ")||[]),r.current={className:e},{container:n.current}}import{createPortal as qt}from"react-dom";import{jsx as H,jsxs as ne}from"react/jsx-runtime";function He({height:t=27}){let[e,o]=Ut("25s");return ne("svg",{width:t*21/27,height:t,viewBox:"-10.5 -10.5 21 27",fill:"none",version:"1.1",id:"svg3",xmlns:"http://www.w3.org/2000/svg",onMouseEnter:()=>o("2s"),onMouseLeave:()=>o("25s"),children:[H("path",{fill:"#82b4fe",fillRule:"evenodd",d:"m 0.04378077,-7.0160133 c -3.95934197,-0.025693 -7.19979577,2.9709105 -7.22395607,6.67957072 -0.021351,3.28396108 1.6024867,4.88716988 3.3609363,6.62322508 1.2259466,1.2102943 2.5172339,2.4851233 3.36206037,4.4390285 0.056993,0.04631 0.095121,0.07722 0.1114948,0.09183 a 0.41450831,0.41450831 0 0 0 0.2727553,0.103225 0.41515047,0.41515047 0 0 0 0.2741963,-0.09961 c 0.00438,-0.0039 0.012527,-0.0074 0.022479,-0.01165 0.027304,-0.01171 0.068791,-0.02955 0.090222,-0.0789 C 1.1559887,8.7954149 2.4656545,7.5377628 3.7164045,6.3367792 5.4974902,4.626493 7.158975,3.0309869 7.1802478,-0.24301718 7.2043965,-3.9517594 4.0032063,-6.9901745 0.04378537,-7.016023 Z m -0.06903,10.6235008 C 1.9352357,3.6202595 3.5351559,2.0173639 3.5480768,0.02733852 3.5610008,-1.9626869 1.9821136,-3.5862858 0.02154667,-3.5990486 -1.9390213,-3.6118206 -3.5388592,-2.0089214 -3.5518634,-0.01889648 -3.5647874,1.9711289 -1.9858982,3.5947246 -0.02533123,3.6074875 Z"}),H("path",{fill:"currentColor",d:"m -2.4911489,12.068709 c -0.3270955,-0.0022 -0.5946317,0.359604 -0.5975214,0.807906 l -0.014767,2.269118 c -0.00295,0.448302 0.2598305,0.813445 0.587006,0.815611 l 5.0075702,0.03259 c 0.3270965,0.0022 0.5946306,-0.359606 0.5975218,-0.807909 l 0.014775,-2.269117 c 0.00304,-0.44838 -0.259831,-0.813523 -0.5870064,-0.815609 z"}),ne("g",{children:[H("circle",{cx:"0",cy:"0",r:"2",fill:"currentColor",id:"circle1"}),ne("g",{stroke:"currentColor",strokeWidth:"1",fill:"none",id:"g3",children:[H("ellipse",{rx:"10",ry:"4.5",id:"ellipse1",cx:"0",cy:"0"}),H("ellipse",{rx:"10",ry:"4.5",transform:"rotate(60)",id:"ellipse2",cx:"0",cy:"0"}),H("ellipse",{rx:"10",ry:"4.5",transform:"rotate(120)",id:"ellipse3",cx:"0",cy:"0"})]}),H("animateTransform",{attributeName:"transform",type:"rotate",dur:e,values:"0 0 0;360 0 0;",repeatCount:"indefinite"})]})]})}var Jt=Bt(function({position:e="bottom-left"}){let{container:o}=oe({position:e,className:"maplibregl-ctrl maplibregl-ctrl-mrc-logo"});return qt(H("a",{target:"_blank",rel:"noopener nofollow",href:"https://maplibre-react-components.pentatrion.com","aria-label":"MapLibre React components logo",children:H(He,{height:30})}),o)});a();import{AttributionControl as eo}from"maplibre-gl";import{memo as to,forwardRef as oo,useImperativeHandle as no}from"react";a();import{useEffect as Qt,useMemo as Xt}from"react";a();import{useCallback as Kt,useRef as Yt}from"react";function Ae(t){let e=Yt(()=>{throw new Error("Cannot call an event handler while rendering.")});return e.current=t,Kt((...o)=>e.current?.(...o),[e])}function x({position:t="top-right",factory:e,onRemove:o}){let n=R(),r=Xt(()=>e(n),[n]),i=Ae(o||null);return Qt(()=>(console.log("mount"),n.hasControl(r)||n.addControl(r,t),()=>{console.log("unmount"),i&&i(n),n.hasControl(r)&&n.removeControl(r)}),[n,r,i,t]),r}var ro=to(oo(function({position:e="bottom-right",...o},n){let r=x({position:e,factory:()=>new eo(o)});return no(n,()=>r),null}));a();import{FullscreenControl as ao}from"maplibre-gl";import{memo as io,forwardRef as so,useImperativeHandle as co}from"react";var lo=io(so(function({position:e="top-right",...o},n){let r=x({position:e,factory:()=>new ao(o)});return co(n,()=>r),null}));a();import{GeolocateControl as po}from"maplibre-gl";import{memo as uo,forwardRef as mo,useImperativeHandle as fo}from"react";var vo=uo(mo(function({position:e="top-right",...o},n){let r=x({position:e,factory:()=>new po(o)});return fo(n,()=>r),null}));a();import{LogoControl as yo}from"maplibre-gl";import{memo as Mo,forwardRef as ho,useImperativeHandle as go}from"react";var Eo=Mo(ho(function({position:e="bottom-left",...o},n){let r=x({position:e,factory:()=>new yo(o)});return go(n,()=>r),null}));a();import{forwardRef as Co,memo as ko,useImperativeHandle as Lo}from"react";import{NavigationControl as Ro}from"maplibre-gl";var xo=ko(Co(function({position:e="top-right",...o},n){let r=x({position:e,factory:()=>new Ro(o)});return Lo(n,()=>r),null}));a();import{ScaleControl as bo}from"maplibre-gl";import{memo as So,forwardRef as Po,useImperativeHandle as Oo}from"react";var To=So(Po(function({position:e="bottom-left",...o},n){let r=x({position:e,factory:()=>new bo(o)});return Oo(n,()=>r),null}));a();import{TerrainControl as No}from"maplibre-gl";import{memo as _o,forwardRef as wo,useImperativeHandle as Io}from"react";var Do=_o(wo(function({position:e="top-right",...o},n){let r=x({position:e,factory:()=>new No(o)});return Io(n,()=>r),null}));a();a();import{useCallback as Go,useRef as We}from"react";var Ho=()=>{let t=We(null),e=We(null),o=Go(n=>{t.current=n,e.current=n?.getCanvasContainer()},[]);return{mapRef:t,canvasRef:e,setMapAndCanvasRef:o}};a();import{useRef as Ao}from"react";var Wo=()=>{let t=R();return Ao(t.getCanvasContainer())};export{Ft as ContextMenuEventAdapter,V as GradientMarker,He as MapLibreReactLogo,U as MapManager,Jt as MrcLogoControl,ro as RAttributionControl,lo as RFullscreenControl,vo as RGeolocateControl,De as RGradientMarker,Re as RLayer,Eo as RLogoControl,de as RMap,he as RMarker,xo as RNavigationControl,Ee as RPopup,To as RScaleControl,xe as RSource,be as RTerrain,Do as RTerrainControl,Jo as areCoordsClose,qo as areLngLatClose,pe as arePointsEqual,Z as deepEqual,Xo as emptyStyle,le as filterMapProps,Qo as gradientMarkerPopupOffset,Ko as lngLatClassToObj,T as mapLibreContext,Yo as markerPopupOffset,w as prepareEventDep,_ as transformPropsToOptions,z as updateClassNames,ue as updateListeners,Wo as useCanvasRef,x as useControl,R as useMap,Ho as useMapAndCanvasRefs,oe as useRControl};
"use client";import{forwardRef as Ke,useContext as Ye,useImperativeHandle as Qe,useMemo as Xe,useRef as X,useState as et}from"react";import{Map as Ze}from"maplibre-gl";import{LngLat as pe}from"maplibre-gl";function ue(t){let e={},o={},r={};for(let n in t)if(n.startsWith("on"))e[n]=t[n];else if(oe.includes(n))o[n]=t[n];else if(te.includes(n))r[n]=t[n];else if(!n.startsWith("initial")&&n!=="container"&&n!=="style")throw Error(`unknown map option key ${n}`);return[r,e,o]}function _(t){let e={},o={};for(let r in t)if(r.startsWith("on"))e[r]=t[r];else{let n=r.startsWith("initial")?r[7].toLowerCase()+r.substring(8):r;if(o[n])throw new Error(`duplicate key ${n}`);o[n]=t[r]}return[o,e]}function N(t,e){return Object.keys(t).filter(r=>t[r]in e).sort()}function z(t,e){if(t===e)return!0;if(!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!z(t[o],e[o]))return!1;return!0}else if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let o=Object.keys(t),r=Object.keys(e);if(o.length!==r.length)return!1;for(let n of o)if(!Object.prototype.hasOwnProperty.call(e,n)||!z(t[n],e[n]))return!1;return!0}return!1}function zo(t,e){return!t&&!e?!0:!t||!e?!1:Math.round(t.lng*1e5)===Math.round(e.lng*1e5)&&Math.round(t.lat*1e5)===Math.round(e.lat*1e5)}function Zo(t,e){if(!t&&!e)return!0;if(!t||!e)return!1;let o=pe.convert(t),r=pe.convert(e);return Math.round(o.lng*1e5)===Math.round(r.lng*1e5)&&Math.round(o.lat*1e5)===Math.round(r.lat*1e5)}function Vo(t){return{lng:t.lng,lat:t.lat}}function me(t,e){let o=Array.isArray(t)?t[0]:t?t.x:0,r=Array.isArray(t)?t[1]:t?t.y:0,n=Array.isArray(e)?e[0]:e?e.x:0,a=Array.isArray(e)?e[1]:e?e.y:0;return o===n&&r===a}function Z(t,e,o){e.forEach(r=>{r!==""&&o.indexOf(r)===-1&&t.classList.remove(r)}),o.forEach(r=>{r!==""&&(e.indexOf(r)===-1||!t.classList.contains(r))&&t.classList.add(r)})}function de(t,e,o,r){t.forEach(n=>{n!==""&&e.indexOf(n)===-1&&r(n)}),e.forEach(n=>{n!==""&&t.indexOf(n)===-1&&o(n)})}var q=41-5.8/2,S=13.5,j=Math.abs(S)/Math.SQRT2,$o={top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-q],"bottom-left":[j,(q-S+j)*-1],"bottom-right":[-j,(q-S+j)*-1],left:[S,(q-S)*-1],right:[-S,(q-S)*-1]},U=50,Fo={top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-U],"bottom-left":[j,(U-S+j)*-1],"bottom-right":[-j,(U-S+j)*-1],left:[S,(U-S)*-1],right:[-S,(U-S)*-1]},Bo={version:8,name:"Empty",sources:{},layers:[]};function fe(){let t="abcdefghijklmnopqrstuvwxyz0123456789",e="";for(let o=0;o<8;o++){let r=Math.floor(Math.random()*t.length);e+=t[r]}return e}var ve={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mouseout:"onMouseOut",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",click:"onClick",dblclick:"onDblClick",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchcancel:"onTouchCancel",touchmove:"onTouchMove",movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd",wheel:"onWheel",resize:"onResize",remove:"onRemove",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",webglcontextlost:"onWebglContextLost",webglcontextrestored:"onWebglContextRestored",load:"onLoad",render:"onRender",idle:"onIdle",error:"onError",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",dataloading:"onDataLoading",styledataloading:"onStyleDataLoading",sourcedataloading:"onSourceDataLoading",tiledataloading:"onTileDataLoading",styleimagemissing:"onStyleImageMissing",dataabort:"onDataAbort",sourcedataabort:"onSourceDataAbort",terrain:"onTerrain"},te=["maxBounds","minZoom","maxZoom","minPitch","maxPitch","renderWorldCopies","pixelRatio"];var oe=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch","cooperativeGestures"],Me="https://demotiles.maplibre.org/style.json",J=class{reactiveOptions={};handlerOptions={};eventNames=[];callbacks;_map;padding;mapStyle;controlledSources={};controlledLayers={};controlledTerrain=null;constructor({mapStyle:e=Me,padding:o},r,n){this.mapStyle=e,this.padding=o;let[a,i]=_(r);this.callbacks=i;let l={...a,container:n,style:e},d=new Ze(l);d.style.on("error",this._onStyleError),o&&d.setPadding(o),this._map=d,this._updateCallbacks(i)}setProps({mapStyle:e=Me,styleDiffing:o=!0,styleTransformStyle:r,padding:n},a){let[i,l,d]=ue(a);this._updateCallbacks(l),this._updateStyle(e,{diff:o,transformStyle:r}),this._updateReactiveOptions(i,{padding:n}),this._updateHandlers(d)}getControlledTerrain(){return this.controlledTerrain}setControlledTerrain(e){this.controlledTerrain=e}getControlledLayer(e){return this.controlledLayers[e]??null}setControlledLayer(e,o){o?this.controlledLayers[e]=o:delete this.controlledLayers[e]}getControlledSource(e){return this.controlledSources[e]??null}setControlledSource(e,o){o?this.controlledSources[e]=o:delete this.controlledSources[e]}_updateStyle(e,o){let r=this.mapStyle;e!==r&&(this.mapStyle=e,this._map.setStyle(e,{diff:o.diff,transformStyle:(n,a)=>{let i=n?Object.fromEntries(Object.entries(n?.sources).filter(([m])=>m in this.controlledSources)):{},l=n?n.layers.filter(m=>m.id in this.controlledLayers):[],d={...a,sources:{...a.sources,...i},layers:[...a.layers,...l],terrain:this.controlledTerrain?n?.terrain:a.terrain};return o.transformStyle?o.transformStyle(n,d):d}}))}_updateReactiveOptions(e,{padding:o}){let r=this.reactiveOptions;this.reactiveOptions=e;for(let n of te)if(n in e&&!z(r[n],e[n])){let a=`set${n[0].toUpperCase()}${n.substring(1)}`;this._map[a](e[n])}o&&!z(this.padding,o)&&this._map.setPadding(o),this.padding=o}_updateCallbacks(e={}){this.callbacks=e;let o=N(ve,e);this.eventNames.join("-")!==o.join("-")&&(de(this.eventNames,o,r=>this._map.on(r,this._onMapEvent),r=>this._map.off(r,this._onMapEvent)),this.eventNames=o)}_updateHandlers(e){let o=this.handlerOptions;this.handlerOptions=e;for(let r of oe){let n=e[r]??!0,a=o[r]??!0;z(n,a)||(n?this._map[r].enable(n):this._map[r].disable())}}_onStyleError=e=>{e.error.name!=="AbortError"&&console.error(e.error)};_onMapEvent=e=>{let o=e.type,r=ve[o];this.callbacks[r]?this.callbacks[r]?.(e):console.info("not managed RMap event",o,e)};get map(){return this._map}destroy(){this._updateCallbacks(),this._map.remove()}};import{useEffect as Ve,useLayoutEffect as $e}from"react";var Q=typeof window<"u"?$e:Ve;import{createContext as Fe,useRef as Be}from"react";var $=class{_maps={};_listeners={};add(e,o){this._maps[e]=o,this._listeners[e]?.forEach(([r,n])=>{r||n(!0)})}remove(e){delete this._maps[e],this._listeners[e]?.forEach(([o,r])=>{o&&r(!1)})}get(e){return e?this._maps[e]??null:null}addListener(e,o){this._listeners[e]?this._listeners[e].push(o):this._listeners[e]=[o];let r=!!this._maps[e];o[0]!==r&&o[1](r)}removeListener(e,[,o]){this._listeners[e]=this._listeners[e].filter(([,r])=>r!==o)}};import{jsx as Ue}from"react/jsx-runtime";var V=Fe(null),qe=({children:t})=>{let e=Be(null);return e.current||(e.current=new $),Ue(V.Provider,{value:e,children:t})};import{createContext as Je}from"react";var K=Je(null);import{jsx as Y}from"react/jsx-runtime";var ye={height:"100%"},he=Ke(function({children:e,style:o,id:r,className:n,onMounted:a,mapStyle:i,styleDiffing:l,styleTransformStyle:d,padding:m,...f},s){let c=X(null),M=X(!0),h=X(r??fe());if(r&&r!==h.current)throw new Error(`RMap id should not change. "${r}" "${h.current}". If you defined id as const string add a "key" prop to your RMap component`);let y=h.current,E=Ye(V),C=X();!E&&!C.current&&(C.current=new $);let g=E?E.current:C.current,[,k]=et(0);Q(()=>{let v=g.get(y);if(v)M.current?v.setProps({mapStyle:i,padding:m,styleDiffing:l,styleTransformStyle:d},f):M.current=!0;else{let R=new J({mapStyle:i,styleDiffing:l,padding:m},f,c.current);g.add(y,R),a&&a(R.map),k(O=>O+1),M.current=!1}}),Q(()=>()=>{let v=g.get(y);v&&(v.destroy(),g.remove(y))},[]),Qe(s,()=>g.get(y)?.map||null,[y,g]),Q(()=>{if(!n)return;let v=c.current;return n.split(" ").map(R=>v.classList.add(R)),()=>void n.split(" ").map(R=>v.classList.remove(R))},[n]);let b=Xe(()=>({position:"relative",width:"100%",height:"100%",...o}),[o]);return Y("div",{ref:c,id:y,style:b,children:g.get(y)&&Y(K.Provider,{value:y,children:E?Y("div",{className:"maplibregl-children",style:ye,children:e}):Y(V.Provider,{value:C,children:Y("div",{className:"maplibregl-children",style:ye,children:e})})})})});import{Marker as rt}from"maplibre-gl";import{forwardRef as nt,memo as at,useEffect as Ee,useImperativeHandle as it,useMemo as st,useRef as Ce}from"react";import{createPortal as lt}from"react-dom";import{useContext as ge,useEffect as tt,useState as ot}from"react";function A(t){let e=ge(V),o=ge(K),r=t??o,n=e?.current.get(r)??null,a=ot(n!==null);if(!e?.current)throw new Error("use useMapManager in components inside <RMap /> or inside <RMapContextProvider />");if(!r)throw new Error("provide an id to useMap or use inside <RMap />");return tt(()=>{let i=e.current;if(!i)throw new Error("mapManagers can't disappear");return i.addListener(r,a),()=>{i.removeListener(r,a)}},[r,e,a,n]),n}function x(t){return A(t)?.map??null}var ke={dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",click:"onClick"};var Re=at(nt(function(e,o){let{longitude:r,latitude:n,children:a,...i}=e,l=x(),[d,m]=_(i),f=Ce(d),s=Ce();s.current=m;let c=st(()=>{let D={...d,element:a?document.createElement("div"):void 0},W=new rt(D);return W.setLngLat([r,n]),W},[]),M=N(ke,m).join("-");Ee(()=>{function D(P){let B=P.type,T=ke[B];s.current?.[T]?s.current[T]?.(P):console.info("not managed RMarker event",B,P)}let W=M.split("-");return W.forEach(P=>{P==="click"?c.getElement().addEventListener("click",D):c.on(P,D)}),()=>{W.forEach(P=>{P==="click"?c.getElement().removeEventListener("click",D):c.off(P,D)})}},[M,c]),Ee(()=>(c.addTo(l),()=>void c.remove()),[]);let{className:h,offset:y,draggable:E,clickTolerance:C=0,rotation:g,rotationAlignment:k,subpixelPositioning:b=!1,pitchAlignment:v,opacity:R,opacityWhenCovered:O}=d;return it(o,()=>c,[c]),f.current.className!==h&&Z(c._element,f.current.className?.split(" ")||[],h?.split(" ")||[]),(c.getLngLat().lng!==r||c.getLngLat().lat!==n)&&c.setLngLat([r,n]),y&&!me(c.getOffset(),y)&&c.setOffset(y),c.isDraggable()!==E&&c.setDraggable(E),c._clickTolerance!==C&&(c._clickTolerance=C),c.getRotation()!==g&&c.setRotation(g),c.getRotationAlignment()!==k&&c.setRotationAlignment(k),c.getPitchAlignment()!==v&&c.setPitchAlignment(v),(c._opacity!==R||c._opacityWhenCovered!==O)&&c.setOpacity(R,O),c.setSubpixelPositioning&&c._subpixelPositioning!==b&&c.setSubpixelPositioning(b),f.current=d,a?lt(a,c.getElement()):null}));import{Popup as ct}from"maplibre-gl";import{forwardRef as pt,memo as ut,useEffect as xe,useImperativeHandle as mt,useMemo as dt,useRef as re}from"react";import{createPortal as ft}from"react-dom";var ne={map_click:"onMapClick",map_move:"onMapMove"};var Le=ut(pt(function(e,o){let{longitude:r,latitude:n,children:a,...i}=e,l=x(),[d,m]=_(i),f=re(null),s=re(d),c=re();c.current=m;let M=dt(()=>document.createElement("div"),[]);f.current||(f.current=new ct({...d,closeButton:!1,closeOnClick:!1,closeOnMove:!1}),r!==void 0&&n!==void 0&&f.current.setLngLat([r,n]));let h=N(ne,m).join("-");xe(()=>{function g(v){let R=v.type,O=ne[R]||ne[`map_${R}`];c.current?.[O]?c.current[O]?.(v):console.info("not managed RPopup event",R,v)}if(h==="")return;let k=h.split("-"),b=f.current;return k.forEach(v=>{v.startsWith("map_")?l.on(v.substring(4),g):b.on(v,g)}),()=>{k.forEach(v=>{v.startsWith("map_")?l.off(v.substring(4),g):b.off(v,g)})}},[h,l]),xe(()=>(f.current.setDOMContent(M).addTo(l),()=>void f.current.remove()),[M,l]);let{offset:y,maxWidth:E="240px",className:C}=d;return mt(o,()=>f.current,[f]),f.current.isOpen()&&(r!==void 0&&n!==void 0&&(f.current.getLngLat().lng!==r||f.current.getLngLat().lat!==n)&&f.current.setLngLat([r,n]),y&&!z(f.current.options.offset,y)&&f.current.setOffset(y),s.current.className!==C&&Z(M,s.current.className?.split(" ")||[],C?.split(" ")||[]),f.current.getMaxWidth()!==E&&f.current.setMaxWidth(E)),s.current=d,ft(a,M)}));import{forwardRef as vt,memo as Mt,useCallback as yt,useEffect as be,useImperativeHandle as ht,useRef as Se,useState as gt}from"react";var Pe={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mouseout:"onMouseOut",mousemove:"onMouseMove",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",click:"onClick",dblclick:"onDblClick",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchcancel:"onTouchCancel",touchmove:"onTouchMove"};function Et(t,e,o){if(t.style?._loaded&&(e.type==="background"||e.type==="custom"||e.source&&t.getSource(e.source)))return t.addLayer(e,o&&t.getLayer(o)?o:void 0),t.getLayer(e.id)}function Ct(t,{beforeId:e,...o},{beforeId:r,...n}){if(n.type==="custom"||o.type==="custom")return;r!==e&&t.moveLayer(o.id,e),o.type!=="background"&&o.type!=="custom"&&n.filter!==o.filter&&t.setFilter(o.id,o.filter);let a=n,i=o;if(a.layout!==i.layout){if(i.layout)for(let l of Object.keys(i.layout))i.layout[l]!==a.layout?.[l]&&t.setLayoutProperty(o.id,l,i.layout[l]);for(let l in a.layout)Object.prototype.hasOwnProperty.call(i.layout,l)||t.setLayoutProperty(o.id,l,void 0)}if(a.paint!==i.paint){if(i.paint)for(let l of Object.keys(i.paint))i.paint[l]!==a.paint?.[l]&&t.setPaintProperty(o.id,l,i.paint[l]);for(let l in a.paint)Object.prototype.hasOwnProperty.call(i.paint,l)||t.setPaintProperty(o.id,l,void 0)}(a.minzoom!==i.minzoom||a.maxzoom!==i.maxzoom)&&i.minzoom&&i.maxzoom&&t.setLayerZoomRange(o.id,i.minzoom,i.maxzoom)}var Oe=Mt(vt(function(e,o){let{beforeId:r,...n}=e,[a,i]=_(n),l=a.id,d=A();if(!d)throw new Error("use <RLayer /> component inside <RMap />");let m=d.map,f=Se(l);if(l!==f.current)throw new Error(`RLayer id should not change. "${l}" "${f.current}". If you defined id as const string add a "key" prop to your RLayer component`);let s=d.getControlledLayer(l)??e,[,c]=gt(0),M=yt(()=>c(C=>C+1),[]);if(e.type!==s.type)throw new Error(`RLayer type should not change. "${e.type}" "${s.type}"`);let h=Se();h.current=i,be(()=>(m.on("styledata",M),m.style._loaded&&M(),()=>{m.off("styledata",M),m.style&&m.style._loaded&&m.getLayer(l)&&m.removeLayer(l),d?.setControlledLayer(l,null)}),[m,l,d,M]);let y=N(Pe,i).join("-");be(()=>{function C(k){let b=k.type,v=Pe[b];h.current?.[v]?h.current[v]?.(k):console.info("not managed RLayer event",b,k)}let g=y.split("-");return g.forEach(k=>{m.on(k,l,C)}),()=>{g.forEach(k=>{m.off(k,l,C)})}},[y,l,m]);let E=m.style?._loaded&&m.getLayer(l);return E?Ct(m,e,s):(E=Et(m,a,r),E&&m.off("styledata",M)),ht(o,()=>E||null,[E]),d.setControlledLayer(l,e),null}));import{forwardRef as kt,useEffect as Rt,useRef as xt,useState as Lt,useImperativeHandle as bt,memo as St,useCallback as Pt}from"react";function Ot(t,e,o){if(t.style?._loaded)return t.addSource(e,o),t.getSource(e)}function Tt(t,e,o){switch(e.type){case"image":{let r=o,n=e;r.url!==n.url&&t.updateImage({url:n.url,coordinates:n.coordinates}),r.coordinates!==n.coordinates&&t.setCoordinates(n.coordinates);break}case"video":{let r=o,n=e;r.coordinates!==n.coordinates&&t.setCoordinates(n.coordinates);break}case"geojson":{let r=o,n=e;r.data!==n.data&&t.setData(n.data),(r.cluster!==n.cluster||r.clusterMaxZoom!==n.clusterMaxZoom||r.clusterRadius!==n.clusterRadius)&&t.setClusterOptions({cluster:n.cluster,clusterMaxZoom:n.clusterMaxZoom,clusterRadius:n.clusterRadius});break}case"raster":case"raster-dem":case"vector":{let r=o,n=e;r.tiles!==n.tiles&&n.tiles&&t.setTiles(n.tiles),r.url!==n.url&&n.url&&t.setUrl(n.url);break}}}var Te=St(kt(function(e,o){let{id:r,...n}=e,a=A(),i=a.map,l=xt(r);if(r!==l.current)throw new Error(`RSource id should not change. "${r}" "${l.current}". If you defined id as const string add a "key" prop to your RSource component`);let{id:d,...m}=a.getControlledSource(r)??e;if(n.type!==m.type)throw new Error(`RSource type should not change. "${n.type}" "${m.type}"`);let[,f]=Lt(0),s=Pt(()=>void setTimeout(()=>f(M=>M+1),0),[]);Rt(()=>(i.on("styledata",s),i.style._loaded&&s(),()=>{if(i.off("styledata",s),i.style&&i.getSource(r)){let M=i.getStyle()?.layers;if(M)for(let h of M)h.type!=="background"&&h.type!=="custom"&&h.source===r&&i.removeLayer(h.id);i.removeSource(r)}a?.setControlledSource(r,null)}),[i,r,a,s]);let c=i.style?._loaded&&i.getSource(r);return c?Tt(c,n,m):(c=Ot(i,r,n),c&&i.off("styledata",s)),bt(o,()=>c||null,[c]),a.setControlledSource(r,e),null}));import{useCallback as _t,useEffect as Nt,useState as wt}from"react";var _e=t=>{let e=t,o=A(),r=o.map,n=o.getControlledTerrain()??t,[,a]=wt(0),i=_t(()=>a(d=>d+1),[]);return Nt(()=>(r.on("styledata",i),r.style._loaded&&i(),()=>{r.off("styledata",i),r.style?._loaded&&r.getTerrain()&&r.setTerrain(null),o?.setControlledTerrain(null)}),[r,o,i]),r.style?._loaded&&(r.getSource(e.source)?r.getTerrain():!1)?(n.exaggeration!==e.exaggeration||n.source!==e.source)&&r.setTerrain(e):r.style?._loaded&&r.getSource(e.source)&&(r.setTerrain(e),r.off("styledata",i)),o.setControlledTerrain(t),null};import{Marker as ee}from"maplibre-gl";function w(t,e){this.x=t,this.y=e}w.prototype={clone(){return new w(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){let e=t.x-this.x,o=t.y-this.y;return e*e+o*o},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){let e=t[0]*this.x+t[1]*this.y,o=t[2]*this.x+t[3]*this.y;return this.x=e,this.y=o,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let e=Math.cos(t),o=Math.sin(t),r=e*this.x-o*this.y,n=o*this.x+e*this.y;return this.x=r,this.y=n,this},_rotateAround(t,e){let o=Math.cos(t),r=Math.sin(t),n=e.x+o*(this.x-e.x)-r*(this.y-e.y),a=e.y+r*(this.x-e.x)+o*(this.y-e.y);return this.x=n,this.y=a,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:w};w.convert=function(t){if(t instanceof w)return t;if(Array.isArray(t))return new w(+t[0],+t[1]);if(t.x!==void 0&&t.y!==void 0)return new w(+t.x,+t.y);throw new Error("Expected [x, y] or {x, y} point format")};var I=class t{static docStyle=typeof window<"u"&&window.document&&window.document.documentElement.style;static userSelect;static selectProp=t.testProp(["userSelect","MozUserSelect","WebkitUserSelect","msUserSelect"]);static transformProp=t.testProp(["transform","WebkitTransform"]);static testProp(e){if(!t.docStyle)return e[0];for(let o=0;o<e.length;o++)if(e[o]in t.docStyle)return e[o];return e[0]}static create(e,o,r){let n=window.document.createElement(e);return o!==void 0&&(n.className=o),r&&r.appendChild(n),n}static createNS(e,o){return window.document.createElementNS(e,o)}static disableDrag(){t.docStyle&&t.selectProp&&(t.userSelect=t.docStyle[t.selectProp],t.docStyle[t.selectProp]="none")}static enableDrag(){t.docStyle&&t.selectProp&&(t.docStyle[t.selectProp]=t.userSelect)}static setTransform(e,o){e.style[t.transformProp]=o}static addEventListener(e,o,r,n={}){"passive"in n?e.addEventListener(o,r,n):e.addEventListener(o,r,n.capture)}static removeEventListener(e,o,r,n={}){"passive"in n?e.removeEventListener(o,r,n):e.removeEventListener(o,r,n.capture)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",t.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",t.suppressClickInternal,!0),window.setTimeout(()=>{window.removeEventListener("click",t.suppressClickInternal,!0)},0)}static getScale(e){let o=e.getBoundingClientRect();return{x:o.width/e.offsetWidth||1,y:o.height/e.offsetHeight||1,boundingClientRect:o}}static getPoint(e,o,r){let n=o.boundingClientRect;return new w((r.clientX-n.left)/o.x-e.clientLeft,(r.clientY-n.top)/o.y-e.clientTop)}static mousePos(e,o){let r=t.getScale(e);return t.getPoint(e,r,o)}static touchPos(e,o){let r=[],n=t.getScale(e);for(let a=0;a<o.length;a++)r.push(t.getPoint(e,n,o[a]));return r}static mouseButton(e){return e.button}static remove(e){e.parentNode&&e.parentNode.removeChild(e)}};var Ne="#ffe64b",we=50,F=class extends ee{_interactive;_shape;_icon;_height=we;_text;_circleElement=null;_iconElement=null;_textElement=null;_markerElement;constructor(e){e??={},e.element=I.create("div","maplibregl-gradient-marker"),e.className&&e.element.classList.add(e.className),super(e),this._draggable&&this._element.classList.add("draggable"),this._interactive=e&&e.interactive===!1?!1:"pending",this._shape=(e&&e.shape)??"pin",this._color=(e&&e.color)??Ne,this._icon=e&&e.icon,this._text=e&&e.text,this._defaultMarker=!0,this._element.setAttribute("aria-label","Map marker"),this._element.setAttribute("tabindex","0"),this.setScale(this._scale),this.setColor(this._color),this._markerElement=I.create("div","marker"),this.setShape(this._shape),this._text?this.setText(this._text):this._icon&&this.setIcon(this._icon);let o=I.create("div","target");this._element.appendChild(this._markerElement),this._element.appendChild(o)}_onActive=()=>{this._map.getContainer().addEventListener("mouseup",this._onInactive,{once:!0}),this._map.getContainer().addEventListener("touchend",this._onInactive,{once:!0}),this._element.classList.add("active")};_onInactive=()=>{this._element.classList.remove("active")};addTo(e){return ee.prototype.addTo.apply(this,[e]),this._interactive==="pending"&&this.setInteractive(!0),this}setInteractive(e=!0){this._interactive!==e&&(this._interactive=e,e?this._element.dataset.interactive="":delete this._element.dataset.interactive,e?(this._element.addEventListener("mousedown",this._onActive),this._element.addEventListener("touchstart",this._onActive)):(this._element.removeEventListener("mousedown",this._onInactive),this._element.removeEventListener("touchstart",this._onInactive)))}getInteractive(){return this._interactive}remove(){return this._map&&this.setInteractive(!1),ee.prototype.remove.apply(this),this}setIcon(e){return this.resetIconText(),this._icon=e,e?(this._circleElement=I.create("div","circle",this._markerElement),typeof e=="string"?(this._iconElement=I.create("i",e,this._markerElement),this._iconElement.className=e||""):typeof e=="function"?(this._iconElement=e(),this._markerElement?.append(this._iconElement)):(this._iconElement=e,this._markerElement?.append(e)),this):this}getIcon(){return this._icon}resetIconText(){this._circleElement?.remove(),this._iconElement?.remove(),this._textElement?.remove(),this._circleElement=null,this._iconElement=null,this._textElement=null}setText(e){return this.resetIconText(),this._text=e,e?(this._circleElement=I.create("div","circle",this._markerElement),this._textElement=I.create("div","text",this._markerElement),this._textElement.innerText=e,this):this}getText(){return this._text}setColor(e){return this._color=e||Ne,this._element.style.setProperty("--marker-color",this._color),this}getColor(){return this._color}setScale(e=1,o=we){return this._scale=e,this._height=o*this._scale,this._element.style.setProperty("--marker-scale",e.toString()),this}getScale(){return this._scale}setShape(e){return this._shape=e||"pin",this._anchor=this._shape==="pin"?"bottom":"center",this._element.dataset.shape=this._shape,this._update(),this}getShape(){return this._shape}setDraggable(e){return ee.prototype.setDraggable.apply(this,[e]),this._element.classList.toggle("draggable",e),this}};import{forwardRef as It,memo as Dt,useEffect as Ie,useImperativeHandle as Gt,useMemo as At,useRef as De}from"react";var Ge={dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",click:"onClick"};var Ae=Dt(It(function(e,o){let{longitude:r,latitude:n,...a}=e,i=x(),[l,d]=_(a),m=De(l),f=De();f.current=d;let s=At(()=>{let T=new F({...l,anchor:"bottom"});return T.setLngLat([r,n]),T},[]),c=N(Ge,d).join("-");Ie(()=>{function T(G){let le=G.type,ce=Ge[le];f.current?.[ce]?f.current[ce]?.(G):console.info("not managed RGradientMarker event",le,G)}let se=c.split("-");return se.forEach(G=>{G==="click"?s.getElement().addEventListener("click",T):s.on(G,T)}),()=>{se.forEach(G=>{G==="click"?s.getElement().removeEventListener("click",T):s.off(G,T)})}},[c,s]),Ie(()=>(s.addTo(i),()=>void s.remove()),[]);let{scale:M,color:h,text:y,icon:E,interactive:C,className:g,draggable:k,clickTolerance:b=0,rotation:v,rotationAlignment:R,subpixelPositioning:O=!1,pitchAlignment:D,shape:W,opacity:P,opacityWhenCovered:B}=l;return Gt(o,()=>s,[s]),m.current.className!==g&&Z(s._element,m.current.className?.split(" ")||[],g?.split(" ")||[]),s.getInteractive()!==C&&s.setInteractive(C),s.getShape()!==W&&s.setShape(W),(s.getLngLat().lng!==r||s.getLngLat().lat!==n)&&s.setLngLat([r,n]),s.isDraggable()!==k&&s.setDraggable(k),s._clickTolerance!==b&&(s._clickTolerance=b),s.getRotation()!==v&&s.setRotation(v),s.getRotationAlignment()!==R&&s.setRotationAlignment(R),s.getPitchAlignment()!==D&&s.setPitchAlignment(D),(s._opacity!==P||s._opacityWhenCovered!==B)&&s.setOpacity(P,B),s.setSubpixelPositioning&&s._subpixelPositioning!==O&&s.setSubpixelPositioning(O),s.getColor()!==h&&s.setColor(h),s.getScale()!==M&&s.setScale(M),s.getText()!==y&&s.setText(y),s.getIcon()!==E&&s.setIcon(E),m.current=l,null}));import{useEffect as Ht}from"react";function Wt({customEventName:t="contextmenu-maplibre",enabled:e=!0}){let o=x();return Ht(()=>{if(!e)return;let r=window.matchMedia("(pointer: coarse)").matches?"click":"contextmenu";function n(a){setTimeout(()=>{if(a.defaultPrevented)return;let{originalEvent:i,point:l,lngLat:d}=a;o.getCanvasContainer().dispatchEvent(new CustomEvent(t,{detail:{originalEvent:i,point:l,lngLat:d,emulated:r!=="contextmenu"}}))})}return o.on(r,n),()=>{o.off(r,n)}},[o,e,t]),null}import{memo as zt,useState as Zt}from"react";import{useEffect as jt,useRef as He}from"react";function ae({position:t,className:e="maplibregl-ctrl maplibregl-ctrl-group"}){let o=x(),r=He(),n=He({className:e});if(!r.current){let a=document.createElement("div");a.className=e,r.current=a}return jt(()=>{let a=r.current;if(a&&!a.parentElement){let i=o._controlPositions[t];if(!i)throw new Error(`Unable to add control, position ${t} doesn't exists`);t.indexOf("bottom")!==-1?i.insertBefore(a,i.firstChild):i.appendChild(a)}return()=>{r.current&&r.current.remove()}},[o,t]),n.current.className!==e&&Z(r.current,n.current.className?.split(" ")||[],e?.split(" ")||[]),n.current={className:e},{container:r.current}}import{createPortal as Vt}from"react-dom";import{jsx as H,jsxs as ie}from"react/jsx-runtime";function We({height:t=27}){let[e,o]=Zt("25s");return ie("svg",{width:t*21/27,height:t,viewBox:"-10.5 -10.5 21 27",fill:"none",version:"1.1",id:"svg3",xmlns:"http://www.w3.org/2000/svg",onMouseEnter:()=>o("2s"),onMouseLeave:()=>o("25s"),children:[H("path",{fill:"#82b4fe",fillRule:"evenodd",d:"m 0.04378077,-7.0160133 c -3.95934197,-0.025693 -7.19979577,2.9709105 -7.22395607,6.67957072 -0.021351,3.28396108 1.6024867,4.88716988 3.3609363,6.62322508 1.2259466,1.2102943 2.5172339,2.4851233 3.36206037,4.4390285 0.056993,0.04631 0.095121,0.07722 0.1114948,0.09183 a 0.41450831,0.41450831 0 0 0 0.2727553,0.103225 0.41515047,0.41515047 0 0 0 0.2741963,-0.09961 c 0.00438,-0.0039 0.012527,-0.0074 0.022479,-0.01165 0.027304,-0.01171 0.068791,-0.02955 0.090222,-0.0789 C 1.1559887,8.7954149 2.4656545,7.5377628 3.7164045,6.3367792 5.4974902,4.626493 7.158975,3.0309869 7.1802478,-0.24301718 7.2043965,-3.9517594 4.0032063,-6.9901745 0.04378537,-7.016023 Z m -0.06903,10.6235008 C 1.9352357,3.6202595 3.5351559,2.0173639 3.5480768,0.02733852 3.5610008,-1.9626869 1.9821136,-3.5862858 0.02154667,-3.5990486 -1.9390213,-3.6118206 -3.5388592,-2.0089214 -3.5518634,-0.01889648 -3.5647874,1.9711289 -1.9858982,3.5947246 -0.02533123,3.6074875 Z"}),H("path",{fill:"currentColor",d:"m -2.4911489,12.068709 c -0.3270955,-0.0022 -0.5946317,0.359604 -0.5975214,0.807906 l -0.014767,2.269118 c -0.00295,0.448302 0.2598305,0.813445 0.587006,0.815611 l 5.0075702,0.03259 c 0.3270965,0.0022 0.5946306,-0.359606 0.5975218,-0.807909 l 0.014775,-2.269117 c 0.00304,-0.44838 -0.259831,-0.813523 -0.5870064,-0.815609 z"}),ie("g",{children:[H("circle",{cx:"0",cy:"0",r:"2",fill:"currentColor",id:"circle1"}),ie("g",{stroke:"currentColor",strokeWidth:"1",fill:"none",id:"g3",children:[H("ellipse",{rx:"10",ry:"4.5",id:"ellipse1",cx:"0",cy:"0"}),H("ellipse",{rx:"10",ry:"4.5",transform:"rotate(60)",id:"ellipse2",cx:"0",cy:"0"}),H("ellipse",{rx:"10",ry:"4.5",transform:"rotate(120)",id:"ellipse3",cx:"0",cy:"0"})]}),H("animateTransform",{attributeName:"transform",type:"rotate",dur:e,values:"0 0 0;360 0 0;",repeatCount:"indefinite"})]})]})}var $t=zt(function({position:e="bottom-left"}){let{container:o}=ae({position:e,className:"maplibregl-ctrl maplibregl-ctrl-mrc-logo"});return Vt(H("a",{target:"_blank",rel:"noopener nofollow",href:"https://maplibre-react-components.pentatrion.com","aria-label":"MapLibre React components logo",children:H(We,{height:30})}),o)});import{AttributionControl as Jt}from"maplibre-gl";import{memo as Kt,forwardRef as Yt,useImperativeHandle as Qt}from"react";import{useEffect as qt,useMemo as Ut}from"react";import{useCallback as Ft,useRef as Bt}from"react";function je(t){let e=Bt(()=>{throw new Error("Cannot call an event handler while rendering.")});return e.current=t,Ft((...o)=>e.current?.(...o),[e])}function L({position:t="top-right",factory:e,onRemove:o}){let r=x(),n=Ut(()=>e(r),[r]),a=je(o||null);return qt(()=>(r.hasControl(n)||r.addControl(n,t),()=>{a&&a(r),r.hasControl(n)&&r.removeControl(n)}),[r,n,a,t]),n}var Xt=Kt(Yt(function({position:e="bottom-right",...o},r){let n=L({position:e,factory:()=>new Jt(o)});return Qt(r,()=>n),null}));import{FullscreenControl as eo}from"maplibre-gl";import{memo as to,forwardRef as oo,useImperativeHandle as ro}from"react";var no=to(oo(function({position:e="top-right",...o},r){let n=L({position:e,factory:()=>new eo(o)});return ro(r,()=>n),null}));import{GeolocateControl as ao}from"maplibre-gl";import{memo as io,forwardRef as so,useImperativeHandle as lo}from"react";var co=io(so(function({position:e="top-right",...o},r){let n=L({position:e,factory:()=>new ao(o)});return lo(r,()=>n),null}));import{LogoControl as po}from"maplibre-gl";import{memo as uo,forwardRef as mo,useImperativeHandle as fo}from"react";var vo=uo(mo(function({position:e="bottom-left",...o},r){let n=L({position:e,factory:()=>new po(o)});return fo(r,()=>n),null}));import{forwardRef as Mo,memo as yo,useImperativeHandle as ho}from"react";import{NavigationControl as go}from"maplibre-gl";var Eo=yo(Mo(function({position:e="top-right",...o},r){let n=L({position:e,factory:()=>new go(o)});return ho(r,()=>n),null}));import{ScaleControl as Co}from"maplibre-gl";import{memo as ko,forwardRef as Ro,useImperativeHandle as xo}from"react";var Lo=ko(Ro(function({position:e="bottom-left",...o},r){let n=L({position:e,factory:()=>new Co(o)});return xo(r,()=>n),null}));import{TerrainControl as bo}from"maplibre-gl";import{memo as So,forwardRef as Po,useImperativeHandle as Oo}from"react";var To=So(Po(function({position:e="top-right",...o},r){let n=L({position:e,factory:()=>new bo(o)});return Oo(r,()=>n),null}));import{useCallback as _o,useRef as ze}from"react";var No=()=>{let t=ze(null),e=ze(null),o=_o(r=>{t.current=r,e.current=r?.getCanvasContainer()},[]);return{mapRef:t,canvasRef:e,setMapAndCanvasRef:o}};import{useRef as wo}from"react";var Io=()=>{let t=x();return wo(t.getCanvasContainer())};export{Wt as ContextMenuEventAdapter,K as CurrentMapIdContext,F as GradientMarker,We as MapLibreReactLogo,J as MapManager,$t as MrcLogoControl,Xt as RAttributionControl,no as RFullscreenControl,co as RGeolocateControl,Ae as RGradientMarker,Oe as RLayer,vo as RLogoControl,he as RMap,V as RMapContext,qe as RMapContextProvider,Re as RMarker,Eo as RNavigationControl,Le as RPopup,Lo as RScaleControl,Te as RSource,_e as RTerrain,To as RTerrainControl,Zo as areCoordsClose,zo as areLngLatClose,me as arePointsEqual,z as deepEqual,Bo as emptyStyle,ue as filterMapProps,Fo as gradientMarkerPopupOffset,Vo as lngLatClassToObj,$o as markerPopupOffset,N as prepareEventDep,_ as transformPropsToOptions,fe as uniqueId,Z as updateClassNames,de as updateListeners,Io as useCanvasRef,L as useControl,x as useMap,No as useMapAndCanvasRefs,A as useMapManager,ae as useRControl};
{
"name": "maplibre-react-components",
"version": "0.1.6",
"version": "0.1.7",
"description": "React components for MapLibre GL JS",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc