@biodiv-platform/naksha-maplibre-layers 5.0.8 → 5.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1,2285 @@
1
- import{TranslationProvider as An}from"@biodiv-platform/naksha-commons";import Gn from"react";import{MapProvider as On}from"react-map-gl/maplibre";import{setup as Dn}from"twind";var ct={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var dt={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var pt={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var ut={en:ct,fr:dt,hi:pt};import{defaultViewState as Pn}from"@biodiv-platform/naksha-commons";import{useMemo as Tn,useState as Mn}from"react";import Nn,{FullscreenControl as En,NavigationControl as Rn}from"react-map-gl/maplibre";import{tw as _n}from"twind";import{defaultMapStyles as Yo,useDebounce as Uo}from"@biodiv-platform/naksha-commons";import jo,{createContext as Jo,useContext as Ko,useEffect as Mt,useMemo as Xo,useState as I}from"react";import{useMap as Qo}from"react-map-gl/maplibre";import Zo from"colorbrewer";import O from"redaxios";import gt from"boundingbox";import{GeoHash as Ne}from"geohash";import{MapStyles as Ho,defaultViewState as $o}from"@biodiv-platform/naksha-commons";var mt={defaultViewState:$o,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:Ho.MAP_STREETS,layers:[],selectedLayers:[]},ft="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",Te={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},yt={...Te,WebkitLineClamp:2},P="ogc_fid",se={ACTIVE:"Active",PENDING:"Pending"},T={TOP:"layer_selection_top",ALL:"layer_selection_all"};var ht=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],Me="0123456789bcdefghjkmnpqrstuvwxyz",qo=(e,o,t)=>{t=t||16/2**(1-e.length&1)/4**o;let r=e.slice(0,-1),n=~~(Me.indexOf(e.slice(-1))/t);return[r+Me[t*n],r+Me[t*(n+1)-1]]},Fo=function(e,o){var t=new Map,r=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[l,u]=qo(a,o);r.set(l,u),t.has(l)||t.set(l,0),t.set(l,t.get(l)+s)}return t.forEach((a,s)=>{let l=Ne.decodeGeoHash(s),u=Ne.decodeGeoHash(r.get(s)),d=new gt({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:u.latitude[1],maxlon:u.longitude[1]}).toGeoJSON();n.push({...d,properties:{count:a,[P]:s}})}),n},Vo=e=>{let o=[];for(let[t,r]of Object.entries(e)){let n=Ne.decodeGeoHash(t),a=new gt({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();o.push({...a,properties:{count:r,[P]:t}})}return o},bt=(e,o)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:o===-1?Vo(e):Fo(e,o)}),Lt=(e,o)=>{let t=Object.values(e).sort((a,s)=>a-s),r=Math.floor(t.length/o),n=new Array(o-1).fill(0).map((a,s)=>t[r*(s+1)]);return n.push(t[t.length-1]),n};import{produce as Wo}from"immer";var vt=async(e,o,t,r)=>{let n=[];for(let a of e){let s=r.includes(a.name),l={...a,id:a.name,thumbnail:o+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s};if(s){let u=await Ee(l,0,o,t);n.push({...l,data:u})}else n.push(l)}return n},Ee=async(e,o,t,r)=>Wo(e.data,async a=>{if(a.styles.length===0){let{success:s,data:l}=await xt(e.id,t);s&&(a.layerName=l.layerName,a.styles=l.styles,a.summaryColumn=l.summaryColumn,a.titleColumn=l.titleColumn,a.propertyMap=Object.fromEntries(l.styles.map(u=>[u.styleName,u.styleTitle])))}a.styles[o]&&!a.styles[o]?.colors&&(a.styles[o].colors=await St(e.id,r?.workspace,a.styles[o].styleName,t)),a.styleIndex=o});var wt=async(e,o,t,r)=>{try{let n=await O.get(`${o}/layer/all`,{headers:{Authorization:e}});return await vt(n.data,o,t,r)}catch(n){return console.error(n),[]}},xt=async(e,o)=>{try{let{data:t}=await O.get(`${o}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}},It=async(e,o,t)=>{let r={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await O.get(`${e}/${o}/wms`,{params:{...t,...r}})).data}}catch(n){return console.error(n),{success:!1,data:[]}}},kt=async(e,o,t,r)=>{try{return await O.put(`${o}/layer/${r?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Ct=async(e,o,t)=>{try{return await O.delete(`${o}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(r){return console.error(r),!1}},St=async(e,o,t,r)=>{try{return(await O.get(`${r}/geoserver/workspaces/${o}/styles/${e}_${t}.mbstyle`)).data?.layers?.[0]}catch(n){return console.error(n),{}}},Pt=async(e,o,t,r=6,n="YlOrRd")=>{try{let[a,s,l]=ht(t),{_ne:u,_sw:d}=o,y={top:u.lat,left:d.lng,bottom:d.lat,right:u.lng,geoAggegationPrecision:a},g=await e(y),k=bt(g,s),N=Lt(g,r).map((G,j)=>[G,Zo[n][r][j]]);return{success:!0,geojson:k,paint:{"fill-color":{property:"count",default:"yellow",stops:N},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:N,squareSize:l}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},Tt=async(e,o,t,r)=>{try{await O.post(`${e}/layer/download`,{layerName:t,layerTitle:r,attributeList:[],filterArray:[]},{headers:{Authorization:o}})}catch(n){console.error(n)}};import{jsx as er}from"react/jsx-runtime";var Nt=Jo({}),Et=({mp:e,children:o})=>{let[t,r]=I(e),{mapl:n}=Qo(),[a,s]=I(""),l=Uo(a,500),u=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:Yo,[d,y]=I(u[t?.mapStyle||0]?.style),[g,k]=I(u[t?.mapStyle||0]?.maxZoom),[w,N]=I(T.TOP),[B,G]=I({}),[j,Se]=I(!0),[E,Co]=I(),[C,we]=I(e.layers||[]),[x,J]=I(t.selectedLayers||[]),[ot,rt]=I(),[Ie,nt]=I(),Po=Xo(()=>{let p={};for(let m of Ie||[])p[m.sourceLayer]=[...p[m.sourceLayer]||[],m?.properties?.[P]];return Object.keys(p).length?p:void 0},[Ie]),ke=jo.useMemo(()=>{let p=C.filter(f=>x.includes(f.id)),m=new Array(x.length);for(let f of p){let b=x.findIndex(v=>f.id===v);b>-1&&(m[b]=f)}return m},[C,x]),ae=p=>C.findIndex(m=>m.id===p),at=(p,m)=>{we(f=>f.map(b=>b.id===p?{...b,...m}:b))},st=async(p,m,f)=>{let b=C[p],v=await Ee(b,m,t.nakshaApiEndpoint,t.geoserver);at(b.id,{data:v}),f&&n?.fitBounds(b.bbox,{padding:40,duration:1e3})},To=async(p,m)=>{let f=ae(p);st(f,m,!1)},Mo=async p=>{if(!(!x.length||!n))try{let m=x[0],f=n.queryRenderedFeatures(p.point,{layers:[m]});if(f.length){let b=f[0]?.id||f[0]?.properties?.[P];if(b===ot?.id)return;let v=C[ae(m)],it=v?.data?.summaryColumn.map(R=>[v.data?.propertyMap?.[R]||R,f[0].properties?.[R]]);rt({id:b,title:v.title,data:it})}else rt(void 0)}catch{}},No=async({layerId:p,add:m,styleIndex:f=0,focus:b=!0})=>{if(!m){J(x.filter(R=>p!==R));return}let v=ae(p);C[v]?.source.type==="grid"?(J(R=>[p,...R.filter(Pe=>Pe!==p)]),b&&C[v]?.bbox&&setTimeout(()=>{n?.fitBounds(C[v].bbox,{padding:40,duration:1e3})},100)):(await st(v,f,b),J(R=>[p,...R.filter(Pe=>Pe!==p)]))},Eo=async()=>J([]),Ro=(p,m)=>{r({...t,[p]:m})},_o=(p,m)=>{let f=m===se.PENDING;kt(t.nakshaEndpointToken,t.nakshaApiEndpoint,p,f),at(p,{layerStatus:f?se.ACTIVE:se.PENDING})},Bo=async(p,m)=>{confirm(m)&&(Ct(t.nakshaEndpointToken,t.nakshaApiEndpoint,p),we(C.filter(f=>f.id!==p)))},Ao=p=>{let m=ae(p),f=C[m];n?.fitBounds(f.bbox,{padding:40,duration:1e3})},lt=()=>[E.lng,E.lat,E.lng+.1,E.lat+.1],Go=p=>{N(p),p===T.TOP&&Ce(p)},Ce=p=>{if(E)try{let m=n?.project([E.lng,E.lat]),f=n?.queryRenderedFeatures(m,{layers:w===T.TOP?[x[0]]:x});if((p||w)===T.ALL){let b=ke.filter(v=>v.layerType=="RASTER").map(v=>({sourceLayer:v.id,layerType:"raster",bbox:lt()}));f=[...f,...b]}nt(ke?.[0].layerType==="RASTER"&&w!==T.ALL?x.length&&f?.length?f:[{sourceLayer:x[0],layerType:"raster",bbox:lt()}]:f)}catch(m){console.error(m)}};return Mt(()=>{t.onSelectedLayersChange&&t.onSelectedLayersChange(x)},[x]),Mt(()=>{setTimeout(Ce,300)},[E,w,x]),er(Nt.Provider,{value:{mp:t,updateMP:Ro,layer:{mapStyle:d,featuresAtLatLng:Ce,setMapStyle:y,maxZoom:g,setMaxZoom:k,mapStyles:u,all:C,setAll:we,selectedIds:x,handleSelectStyle:Go,setSelectedIds:J,selectedLayers:ke,clearAll:Eo,toggle:No,updateStyle:To,selectedFeatures:Ie,selectedFeaturesId:Po,setSelectedFeatures:nt,togglePublish:_o,delete:Bo,selectionStyle:w,setSelectionStyle:N,zoomToExtent:Ao,gridLegends:B,setGridLegends:G},query:{term:l,setTerm:s,clickedLngLat:E,setClickedLngLat:Co},isInfoBarOpen:j,setIsInfoBarOpen:Se,hover:{onHover:Mo,features:ot}},children:o})};function c(){return Ko(Nt)}import or from"react";import{tw as ie}from"twind";import{tw as tr}from"twind";import{jsx as i,jsxs as X}from"react/jsx-runtime";var Rt=()=>i("svg",{fill:"none",className:tr`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:i("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),K=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[i("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),i("path",{d:"M2 17L12 22 22 17"}),i("path",{d:"M2 12L12 17 22 12"})]}),le=()=>X("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),i("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),_t=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[i("path",{d:"M4 21L4 14"}),i("path",{d:"M4 10L4 3"}),i("path",{d:"M12 21L12 12"}),i("path",{d:"M12 8L12 3"}),i("path",{d:"M20 21L20 16"}),i("path",{d:"M20 12L20 3"}),i("path",{d:"M1 14L7 14"}),i("path",{d:"M9 8L15 8"}),i("path",{d:"M17 16L23 16"})]});function Re(){return i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function Bt(){return i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function At(){return i("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function Gt(){return i("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function Ot(){return i("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function Dt(){return i("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function zt(){return i("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:i("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function Ht(){return X("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[i("circle",{cx:"18",cy:"5",r:"3"}),i("circle",{cx:"6",cy:"12",r:"3"}),i("circle",{cx:"18",cy:"19",r:"3"}),i("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),i("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function $t(){return i("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:i("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function qt(){return X("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("circle",{cx:"12",cy:"12",r:"10"}),i("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),i("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),i("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),i("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function Ft(){return i("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:i("polyline",{points:"6 9 12 15 18 9"})})}function Vt(){return i("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:i("polyline",{points:"18 15 12 9 6 15"})})}import{jsx as F}from"react/jsx-runtime";var A=or.forwardRef((e,o)=>F("button",{ref:o,type:"button",className:ie`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var ce=e=>F("button",{className:ie`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),Wt=e=>F("button",{className:ie`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:F(K,{})}),Zt=e=>F("button",{className:ie`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:F(le,{})});import{tw as V}from"twind";import{jsx as M,jsxs as jt}from"react/jsx-runtime";var W=e=>jt("div",{children:[e.label&&M("label",{className:V`text-gray-700`,htmlFor:e.name,children:e.label}),M("select",{id:e.name,name:e.name,className:V`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),Yt=e=>jt("div",{className:"relative",children:[M("span",{className:V`absolute inset-y-0 left-0 flex items-center pl-3`,children:M(Rt,{})}),M("input",{type:"search",className:V`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),Ut=e=>e.isLoading?M("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:V`inline text-gray-200 animate-spin dark:text-gray-600`,children:M("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:M("g",{fill:"#212121",fillRule:"nonzero",children:M("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):M("input",{type:"checkbox",className:V`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});import{Tabs as Jt,usePanelState as rr,useTabState as nr}from"@bumaga/tabs";import ar from"clsx";import{tw as de}from"twind";import{jsx as _e,jsxs as sr}from"react/jsx-runtime";var pe=({children:e,icon:o})=>{let{onClick:t,isActive:r}=nr(),n=ar(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":r,"text-gray-700 border-gray-300 hover:border-gray-400":!r}]);return sr("button",{className:de(n),onClick:t,children:[o,_e("span",{className:de`ml-2 text-base`,children:e})]})},ue=({children:e})=>rr()?_e("div",{className:de`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Kt=({children:e})=>_e("div",{className:de`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{useT as dr}from"@biodiv-platform/naksha-commons";import{tw as fe}from"twind";import{useT as lr}from"@biodiv-platform/naksha-commons";import{jsx as Xt}from"react/jsx-runtime";function Q({hideLabel:e}){let{layer:{selectionStyle:o,handleSelectStyle:t}}=c(),{t:r}=lr(),n=a=>{t(a.target.value)};return Xt(W,{name:"layer_selection",label:e?null:r("layer_selection"),defaultValue:o,onChange:n,children:Object.values(T).map(a=>Xt("option",{value:a,children:r(a)},a))})}import ir from"clsx";import{useEffect as cr,useState as Qt}from"react";import{tw as me}from"twind";import{jsx as ee,jsxs as Be}from"react/jsx-runtime";function Ae({data:e}){let[o,t]=Qt(!0),[r,n]=Qt({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=c(),u=async()=>{let d,y=a.selectedLayers.find(g=>g.id===(e.sourceLayer||e.source));if(y.layerType.toLowerCase()==="raster"){let{data:g}=await It(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${y.id}`,layers:`${s.geoserver?.workspace}:${y.id}`});d=g?.features[0]?Object.entries(g.features[0]?.properties).map(([k,w])=>[w||"-"]):[]}else d=Object.entries(y?.data?.propertyMap||{}).map(([g,k])=>[k,e?.properties?.[g]]);n({title:y.title,properties:d})};return cr(()=>{u()},[l]),Be("div",{className:me`bg-gray-100 rounded-lg`,children:[Be("button",{className:me(ir(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":o,"rounded-lg":!o}])),onClick:()=>t(!o),children:[r.title," ",o?ee(Vt,{}):ee(Ft,{})]}),o&&ee("div",{className:me`px-4 py-3 flex flex-col gap-3`,children:r.properties.map(([d,y],g)=>Be("div",{children:[ee("div",{className:me`text-gray-600`,children:d}),ee("div",{children:y})]},d+y+g))})]})}import{jsx as Z,jsxs as Ge}from"react/jsx-runtime";function Oe({onClose:e}){let{layer:{selectedFeatures:o,selectedLayers:t,selectionStyle:r}}=c(),{t:n}=dr();return Ge("div",{className:fe`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[Ge("div",{className:"flex w-full",children:[Ge("div",{className:fe`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[Z(qt,{})," ",n("infobar")]}),Z(ce,{onClick:e})]}),Z("div",{className:fe`bg-gray-100 p-4 flex-shrink-0 rt`,children:Z(Q,{hideLabel:!0})}),Z("div",{className:fe`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:o.flat(1)?.map(a=>Z(Ae,{data:a},t?.[0]?.source.type==="raster"||r===T.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[P]))})]})}import{jsx as eo}from"react/jsx-runtime";function De(){let{layer:e,isInfoBarOpen:o,setIsInfoBarOpen:t}=c();if(!e.selectedFeatures?.length)return null;let r=()=>t(!o);return o?eo(Oe,{onClose:r}):eo(Zt,{onClick:r})}import{useEffect as rn,useState as nn}from"react";import{useMap as an}from"react-map-gl/maplibre";import{useT as on}from"@biodiv-platform/naksha-commons";import{tw as go}from"twind";import{tw as zr}from"twind";import _r,{useMemo as Br}from"react";import{useVirtual as Ar}from"react-virtual";import{AutoSizer as Gr}from"react-virtualized-auto-sizer";import{tw as so}from"twind";import{useT as Mr}from"@biodiv-platform/naksha-commons";import{useMemo as Nr,useState as ao}from"react";import{RWebShare as Er}from"react-web-share";import{tw as _}from"twind";import{Fragment as to,jsx as ye}from"react/jsx-runtime";var oo=({text:e="",highlight:o=""})=>{if(!o.trim())return ye(to,{children:e});let t=new RegExp(`(${o})`,"gi"),r=e.split(t);return ye(to,{children:r.filter(n=>n).map((n,a)=>t.test(n)?ye("mark",{children:n},a):ye("span",{children:n},a))})};import{tw as gr}from"twind";import{useT as pr}from"@biodiv-platform/naksha-commons";import{useState as ur}from"react";import{tw as mr}from"twind";import{jsx as fr,jsxs as yr}from"react/jsx-runtime";function te({children:e}){let[o,t]=ur(!1),{t:r}=pr();return yr("div",{children:[o&&e,fr("button",{onClick:()=>t(!o),className:mr`text-blue-600 focus:outline-none focus:outline focus:ring`,children:r(o?"less":"legend")})]})}import{jsx as ge,jsxs as he}from"react/jsx-runtime";function ze({item:e}){let{layer:o}=c(),t=o.gridLegends[e.id];return t?ge(te,{children:he("ul",{style:{margin:0,padding:0},children:[t?.stops.map(([r,n],a,s)=>{let l=(s[a-1]||[0])[0];return l===r?ge("div",{},n):he("li",{className:gr`flex gap-2 items-center mb-1`,children:[ge("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:ge("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),he("div",{children:[l," - ",r]})]},n)}),he("li",{children:["1 Square = ",t?.squareSize," x ",t?.squareSize," km"]})]})}):null}import{LICENSES as hr,useT as br}from"@biodiv-platform/naksha-commons";import{useState as Lr}from"react";import{Popover as vr}from"react-tiny-popover";import{tw as oe}from"twind";import{jsx as h,jsxs as He}from"react/jsx-runtime";var Y=({icon:e,name:o,title:t,link:r,children:n})=>{let a=h("span",{children:n||"-"});return He("div",{className:oe`flex gap-3 text-sm text-gray-600 break-all`,title:o&&t&&`${o}: ${t}`,children:[h("div",{children:e}),r?h("a",{className:oe`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:r,children:a}):a]})};function xr({item:e,containerStyle:o}){let{t}=br(),{layer:r,mp:n}=c(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return He("div",{className:oe`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:o,children:[n.managePublishing&&e.layerStatus&&He(Y,{icon:h(Gt,{}),name:t("visiblity"),title:e.layerStatus,children:[e.layerStatus,h("button",{className:oe`text-blue-600 focus:outline-none ml-4`,onClick:()=>r.togglePublish(e.id,e?.layerStatus),children:t("toggle")}),h("button",{className:oe`text-red-600 focus:outline-none ml-4`,onClick:()=>r.delete(e.id,t("are_you_sure")),children:t("delete")})]}),h(Y,{icon:h(Re,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),h(Y,{icon:h(Re,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),h(Y,{icon:h(Ot,{}),name:t("created_on"),title:s,children:s}),h(Y,{icon:h(Bt,{}),name:t("tags"),title:l,children:l}),h(Y,{name:t("license"),title:a,link:a&&hr[a],icon:h(At,{}),children:a})]})}var ro=({item:e})=>{let[o,t]=Lr(!1),r=()=>t(!o);return h(vr,{isOpen:o,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:r,content:h(xr,{item:e}),children:h(A,{onClick:r,children:h(le,{}),title:"Information"})})};import{tw as Pr}from"twind";import{useMemo as Sr,useState as wr}from"react";import{useT as Ir}from"@biodiv-platform/naksha-commons";import{tw as kr}from"twind";import{jsx as D,jsxs as Cr}from"react/jsx-runtime";function no({item:e}){let[o,t]=wr(!0),{mp:r}=c(),{t:n}=Ir(),a=Sr(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([l,u])=>Cr("li",{className:kr`flex gap-2 items-center mb-1`,children:[D("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:D("circle",{cx:"12",fill:u,cy:"12",r:"12",stroke:"none"})}),D("div",{children:l})]},u));return D("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():o?D("li",{children:D("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${r?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):D("div",{children:n("raster_style_not_found")})})}import{jsx as be,jsxs as Tr}from"react/jsx-runtime";function $e({item:e}){if(!e.data?.styles)return null;let{layer:o}=c(),t=r=>{o.updateStyle(e.id,Number(r.target.value))};return Tr("div",{className:Pr`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&be(W,{onChange:t,children:e.data?.styles.map((r,n)=>be("option",{value:n,children:r.styleTitle},n))}),be(te,{children:be(no,{item:e})})]})}import{jsx as L,jsxs as z}from"react/jsx-runtime";function Rr({dragHandleProps:e}){return L("div",{className:_`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:L($t,{})})}function re({item:e,extended:o,dragHandleProps:t}){let{t:r}=Mr(),{layer:n,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:u}=c(),[d,y]=ao(n.selectedIds.includes(e.id)),[g,k]=ao(!1),w=Nr(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),N=async()=>{k(!0),u(!0),n.setSelectedFeatures([]),l(null),await n.toggle({layerId:e.id,add:!d}),y(!d),k(!1)},B=async()=>{await Tt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},G=()=>n.zoomToExtent(e.id);return z("div",{className:_`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[z("div",{className:_`flex gap-3`,children:[z("div",{className:_`flex-shrink-0`,children:[L(Ut,{name:e.id,checked:d,onChange:N,isLoading:g}),o&&L(Rr,{dragHandleProps:t})]}),L("img",{className:_`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||ft}),z("div",{children:[L("div",{title:e.title,className:_`mb-1 leading-tight`,style:Te,children:L(oo,{text:e.title,highlight:a.term})}),L("p",{title:e.description,className:_`text-gray-600 text-sm`,style:yt,children:e.description})]})]}),z("div",{className:_`flex justify-between`,children:[z(A,{onClick:B,disabled:!e.isDownloadable,children:[L(Dt,{})," ",r("download")]}),z("div",{className:_`flex gap-3`,children:[w&&L(Er,{data:w,children:L(A,{title:"Share",children:L(Ht,{})})}),o&&L(A,{onClick:G,title:"Zoom To Extent",children:L(zt,{})}),L(ro,{item:e})]})]}),o&&L($e,{item:e}),o&&e.source.type==="grid"&&L(ze,{item:e})]})}import{jsx as H}from"react/jsx-runtime";function lo(){let{layer:e,query:o}=c(),t=Br(()=>o.term?e.all.filter(a=>a.title.toLowerCase().includes(o.term.toLowerCase())):e.all,[e.all,o.term]),r=_r.useRef(),n=Ar({size:t.length,parentRef:r});return H("div",{className:so`flex-grow-1 relative`,children:H(Gr,{disableWidth:!0,children:a=>H("div",{ref:r,className:"List",style:{height:a.height,overflow:"auto"},children:H("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>H("div",{ref:s.measureRef,className:so`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:H("div",{style:{height:146},children:H(re,{item:t[s.index]})})},s.index))})})})})}import{useT as Or}from"@biodiv-platform/naksha-commons";import{tw as Dr}from"twind";import{jsx as io}from"react/jsx-runtime";function qe(){let{t:e}=Or(),{query:o}=c(),t=r=>o.setTerm(r.target.value);return io("div",{className:Dr`flex-shrink-0 border-b-2 p-4`,children:io(Yt,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as co,jsxs as Hr}from"react/jsx-runtime";function Fe(){return Hr("div",{className:zr`flex flex-col w-full`,children:[co(qe,{}),co(lo,{})]})}function $r(e,o,t){let r=o<0?e.length+o:o;if(r>=0&&r<e.length){let n=t<0?e.length+t:t,[a]=e.splice(o,1);e.splice(n,0,a)}}function po(e,o,t){return e=[...e],$r(e,o,t),e}import{closestCenter as qr,DndContext as Fr,PointerSensor as Vr,useSensor as Wr,useSensors as Zr}from"@dnd-kit/core";import{SortableContext as Yr,useSortable as Ur,verticalListSortingStrategy as jr}from"@dnd-kit/sortable";import{CSS as Jr}from"@dnd-kit/utilities";import{jsx as U}from"react/jsx-runtime";function Kr({item:e,extended:o}){let{attributes:t,listeners:r,setNodeRef:n,transform:a,transition:s,isDragging:l}=Ur({id:e.id}),u={transform:Jr.Transform.toString(a),transition:s,opacity:l?.5:1};return U("div",{ref:n,style:u,children:U(re,{item:e,extended:o,dragHandleProps:{...t,...r}})})}var uo=({layerList:e,onSortEnd:o})=>{let t=Zr(Wr(Vr,{activationConstraint:{distance:4}}));return U(Fr,{sensors:t,collisionDetection:qr,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let l=e.findIndex(d=>d.id===a.id),u=e.findIndex(d=>d.id===s.id);l!==-1&&u!==-1&&o({oldIndex:l,newIndex:u})}},children:U(Yr,{items:e.map(n=>n.id),strategy:jr,children:U("div",{children:e.map(n=>U(Kr,{item:n,extended:!0},n.id))})})})};import{useT as Xr}from"@biodiv-platform/naksha-commons";import{tw as mo}from"twind";import{jsx as yo,jsxs as fo}from"react/jsx-runtime";function Ve(){let{layer:e}=c(),{t:o}=Xr(),t=({oldIndex:r,newIndex:n})=>{e.setSelectedIds(po(e.selectedIds,r,n))};return fo("div",{className:mo`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&yo("div",{className:mo`p-3 pb-0`,children:fo(A,{onClick:()=>e.clearAll(),children:["\u2715 ",o("clear")]})}),yo(uo,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as Qr}from"@biodiv-platform/naksha-commons";import{tw as en}from"twind";import{jsx as We,jsxs as tn}from"react/jsx-runtime";function Ze(){let{layer:e}=c(),{t:o}=Qr(),t=r=>{e.setMapStyle(r.target.value),e.setMaxZoom(e.mapStyles.find(n=>n.style===r.target.value)?.maxZoom)};return tn("div",{className:en`w-full p-4 flex flex-col gap-4`,children:[We(W,{name:"base_style",label:o("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(r=>We("option",{value:r.style,children:r.text},r.key))}),We(Q,{})]})}import{jsx as S,jsxs as Ye}from"react/jsx-runtime";function Ue({onClose:e}){let{t:o}=on();return Ye("div",{className:go`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[S(ce,{onClick:e}),S("div",{className:go`flex flex-col h-full`,children:Ye(Jt,{children:[Ye(Kt,{children:[S(pe,{icon:S(K,{}),children:o("layers")}),S(pe,{icon:S(K,{}),children:o("selected")}),S(pe,{icon:S(_t,{}),children:o("settings")})]}),S(ue,{children:S(Fe,{})}),S(ue,{children:S(Ve,{})}),S(ue,{children:S(Ze,{})})]})})]})}import{jsx as ho}from"react/jsx-runtime";function je(){let{mp:e,layer:o}=c(),[t,r]=nn(e.showToC),{mapl:n}=an(),a=()=>r(!t);async function s(){let l=await wt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...l];if(o.setAll(u),o.selectedIds.length){let d=u.find(y=>y.id===o.selectedIds[0]);d?.bbox&&n?.fitBounds(d.bbox,{padding:40,duration:1e3})}}return rn(()=>{n&&e.loadToC&&s()},[n]),t?ho(Ue,{onClose:a}):ho(Wt,{onClick:a})}import{useMap as bn}from"react-map-gl/maplibre";import sn from"@turf/bbox";import{useEffect as Je,useState as ln}from"react";import{Layer as cn,Source as dn,useMap as pn}from"react-map-gl/maplibre";import{jsx as bo}from"react/jsx-runtime";function Ke({data:e,beforeId:o}){let{layer:t}=c(),{mapl:r}=pn(),[n,a]=ln({geojson:{},paint:{}}),s=t.selectedIds.includes(e.id),l=t.selectedIds[0]===e.id,u=async(d=!1)=>{let{success:y,geojson:g,paint:k,stops:w,squareSize:N}=await Pt(e.source.fetcher,r?.getBounds(),r?.getZoom());if(y){if(a({geojson:g,paint:k}),d&&l&&e.zoomToFit)try{let[B,G,j,Se]=sn(g);r?.fitBounds([[B,G],[j,Se]],{padding:40,animate:!0})}catch(B){console.warn("Failed to compute bbox",B)}t.setGridLegends({[e.id]:{stops:w,squareSize:N}})}};return Je(()=>{s&&l?u(!0):s&&u(!1)},[s,l]),Je(()=>{if(!s||!r)return;let d=()=>u(!1);return r.on("idle",d),()=>{r.off("idle",d)}},[s,r]),Je(()=>()=>{t.setGridLegends(d=>{let y={...d};return delete y[e.id],y})},[e.id]),bo(dn,{id:e.id,type:"geojson",data:n.geojson,children:bo(cn,{beforeId:o,id:e.id,type:"fill",paint:n.paint})})}import{useMemo as un}from"react";import{Layer as Lo,Source as mn}from"react-map-gl/maplibre";import{jsx as vo,jsxs as yn}from"react/jsx-runtime";var fn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Le({layer:e,beforeId:o}){let{layer:t}=c(),r=un(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,t.selectedFeatures]),n=t.selectedFeaturesId?.[e.id];return yn(mn,{...e.source,children:[r&&vo(Lo,{beforeId:o,...r}),n&&r&&vo(Lo,{...r,beforeId:o,id:`hl_${e.id}`,filter:["in",P,...n],type:r.type==="fill"?"line":r.type,paint:fn[r.type]})]})}import{Layer as gn,Source as hn}from"react-map-gl/maplibre";import{jsx as xo}from"react/jsx-runtime";function Xe({data:e,beforeId:o}){let{mp:t}=c();return xo(hn,{id:e.id,type:"raster",tiles:[`${t?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:xo(gn,{id:e.id,beforeId:o,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as ve}from"react/jsx-runtime";function So({layer:e,beforeId:o}){let{mapl:t}=bn();if(!t)return null;switch(e.source.type){case"vector":return ve(Le,{beforeId:o,layer:e});case"grid":return ve(Ke,{beforeId:o,data:e});case"raster":return ve(Xe,{beforeId:o,data:e});default:return ve(Le,{beforeId:o,layer:e})}}import{useMemo as Ln}from"react";import{Marker as vn}from"react-map-gl/maplibre";import{Fragment as wn,jsx as Qe}from"react/jsx-runtime";var xn=vn,Sn=()=>{let{mp:e}=c(),o=Ln(()=>e.markers,[e.markers]);return Qe(wn,{children:o?.map(({latitude:t,longitude:r,colorHex:n},a)=>Qe(xn,{latitude:t,longitude:r,children:Qe("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},wo=Sn;import In from"clsx";import{Popup as kn}from"react-map-gl/maplibre";import{tw as ne}from"twind";import{jsx as $,jsxs as Io}from"react/jsx-runtime";var Cn=kn;function et({coordinates:e}){let{hover:o}=c();return e?.lat&&o.features?$(Cn,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:Io("table",{className:ne`table-auto border`,children:[$("thead",{children:$("tr",{children:$("th",{className:ne`bg-gray-200 py-1 px-2`,colSpan:2,children:o.features.title})})}),$("tbody",{children:o.features.data.map(([t,r],n)=>Io("tr",{className:ne(In({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[$("td",{className:ne`py-1 px-2`,children:t}),$("td",{className:ne`py-1 px-2 border-l border-gray-100`,children:r})]},t+r))})]})}):null}import{jsx as q,jsxs as ko}from"react/jsx-runtime";var Bn=Rn;function tt(){let{mp:e,layer:o,hover:t,query:r}=c(),[n,a]=Mn(),s=Tn(()=>e.defaultViewState||Pn,[e.defaultViewState]),l=d=>r.setClickedLngLat(d.lngLat),u=d=>{a(d.lngLat),t.onHover(d)};return ko("div",{className:_n`h-full w-full relative bg-gray-100`,children:[e.loadToC&&q(je,{}),o.selectedFeatures?.length>0&&q(De,{}),ko(Nn,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:o.mapStyle,maxZoom:o.maxZoom,onClick:l,onMouseMove:u,children:[q(Bn,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&q(En,{position:"bottom-right"}),q(wo,{}),o.selectedLayers.map((d,y)=>{let g=y>0?o.selectedIds[y-1]:void 0;return q(So,{layer:d,beforeId:g},d.id)}),q(et,{coordinates:n},"popup")]})]})}import{jsx as xe}from"react/jsx-runtime";Dn({preflight:!1});var gc=e=>{let o=Gn.useMemo(()=>({...mt,...e}),[e]);return xe(On,{children:xe(An,{localeStrings:ut,lang:o.lang,children:xe(Et,{mp:o,children:xe(tt,{})})})})};export{gc as NakshaMaplibreLayers};
1
+ // src/index.tsx
2
+ import { TranslationProvider } from "@biodiv-platform/naksha-commons";
3
+ import React14 from "react";
4
+ import { MapProvider } from "react-map-gl/maplibre";
5
+ import { setup } from "twind";
6
+
7
+ // locales/en.json
8
+ var en_default = {
9
+ are_you_sure: "Are you sure?",
10
+ base_style: "Base Style",
11
+ clear: "Clear Selection",
12
+ created_by: "Attribution",
13
+ created_on: "Created On",
14
+ delete: "Delete",
15
+ download: "Download",
16
+ find_layer_by_name: "Find layer by name",
17
+ infobar: "Attributes at Clicked Location",
18
+ information: "Information",
19
+ layer_selection: "Layer Selection",
20
+ layer_selection_all: "All Layers",
21
+ layer_selection_top: "Top Layer Only",
22
+ layers: "Layers",
23
+ legend: "Legend",
24
+ less: "Less",
25
+ license: "License",
26
+ list_layers: "List Layers",
27
+ pending: "Pending",
28
+ publish: "Publish",
29
+ raster_style_not_found: "Style not available for the given layer",
30
+ remove: "Remove",
31
+ selected: "Selected",
32
+ settings: "Settings",
33
+ square: "Square",
34
+ tags: "Tags",
35
+ toggle: "Toggle Publishing",
36
+ uploaded: "Uploaded",
37
+ uploader: "Uploader",
38
+ url: "URL",
39
+ visiblity: "Visiblity"
40
+ };
41
+
42
+ // locales/fr.json
43
+ var fr_default = {
44
+ are_you_sure: "\xCAtes-vous s\xFBr?",
45
+ base_style: "Style de base",
46
+ clear: "Effacer la s\xE9lection",
47
+ created_by: "Attribution",
48
+ created_on: "Cr\xE9\xE9 sur",
49
+ delete: "Effacer",
50
+ download: "T\xE9l\xE9charger",
51
+ find_layer_by_name: "Trouver la couche par nom",
52
+ infobar: "Attributs \xE0 l'emplacement cliqu\xE9",
53
+ information: "Informations",
54
+ layer_selection_all: "Toutes les couches",
55
+ layer_selection_top: "Couche sup\xE9rieure uniquement",
56
+ layer_selection: "S\xE9lection de calque",
57
+ layers: "Couches",
58
+ legend: "L\xE9gende",
59
+ less: "Moins",
60
+ license: "Licence",
61
+ list_layers: "Liste des couches",
62
+ pending: "En attente",
63
+ publish: "Publier",
64
+ remove: "Supprimer",
65
+ selected: "Choisie",
66
+ settings: "Param\xE8tres",
67
+ square: "Carr\xE9",
68
+ toggle: "Basculer la publication",
69
+ uploaded: "T\xE9l\xE9charg\xE9",
70
+ url: "url"
71
+ };
72
+
73
+ // locales/hi.json
74
+ var hi_default = {
75
+ are_you_sure: "\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",
76
+ base_style: "\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",
77
+ clear: "\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",
78
+ created_by: "\u0906\u0930\u094B\u092A\u0923",
79
+ created_on: "\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",
80
+ delete: "\u0939\u091F\u093E\u090F\u0902",
81
+ download: "\u0921\u093E\u0909\u0928\u0932\u094B\u0921",
82
+ find_layer_by_name: "\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",
83
+ infobar: "\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",
84
+ information: "\u091C\u093E\u0928\u0915\u093E\u0930\u0940",
85
+ layer_selection_all: "\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",
86
+ layer_selection_top: "\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",
87
+ layer_selection: "\u092A\u0930\u0924 \u091A\u092F\u0928",
88
+ layers: "\u092A\u0930\u0924\u0947\u0902",
89
+ legend: "\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",
90
+ less: "\u0915\u092E",
91
+ license: "\u0932\u093E\u0907\u0938\u0947\u0902\u0938",
92
+ list_layers: "\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",
93
+ pending: "\u0932\u0902\u092C\u093F\u0924",
94
+ publish: "\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",
95
+ remove: "\u0939\u091F\u093E\u0928\u093E",
96
+ selected: "\u091A\u092F\u0928\u093F\u0924",
97
+ settings: "\u0938\u092E\u093E\u092F\u094B\u091C\u0928",
98
+ square: "\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",
99
+ tags: "\u091F\u0948\u0917",
100
+ toggle: "\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",
101
+ uploaded: "\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",
102
+ url: "\u092F\u0942\u0906\u0930\u090F\u0932"
103
+ };
104
+
105
+ // locales/index.ts
106
+ var locales_default = { en: en_default, fr: fr_default, hi: hi_default };
107
+
108
+ // src/components/map/index.tsx
109
+ import { defaultViewState as defaultViewState2 } from "@biodiv-platform/naksha-commons";
110
+ import { useMemo as useMemo7, useState as useState10 } from "react";
111
+ import MapGL, {
112
+ FullscreenControl,
113
+ NavigationControl
114
+ } from "react-map-gl/maplibre";
115
+ import { tw as tw20 } from "twind";
116
+
117
+ // src/hooks/use-layers.tsx
118
+ import { defaultMapStyles, useDebounce } from "@biodiv-platform/naksha-commons";
119
+ import React, {
120
+ createContext,
121
+ useContext,
122
+ useEffect,
123
+ useMemo,
124
+ useState
125
+ } from "react";
126
+ import { useMap } from "react-map-gl/maplibre";
127
+
128
+ // src/services/naksha.ts
129
+ import cb from "colorbrewer";
130
+ import axios from "redaxios";
131
+
132
+ // src/utils/grid.ts
133
+ import BoundingBox from "boundingbox";
134
+ import { GeoHash } from "geohash";
135
+
136
+ // src/static/constants.tsx
137
+ import { MapStyles, defaultViewState } from "@biodiv-platform/naksha-commons";
138
+ var defaultNakshaProps = {
139
+ defaultViewState,
140
+ nakshaApiEndpoint: "/naksha-api/api",
141
+ geoserver: { endpoint: "/geoserver", workspace: "biodiv", store: "ibp" },
142
+ mapStyle: MapStyles.MAP_STREETS,
143
+ layers: [],
144
+ selectedLayers: []
145
+ };
146
+ var FALLBACK_THUMB = "data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E";
147
+ var overflowStyle = {
148
+ display: "-webkit-box",
149
+ WebkitLineClamp: 1,
150
+ WebkitBoxOrient: "vertical",
151
+ overflow: "hidden",
152
+ wordBreak: "break-word"
153
+ };
154
+ var overflowStyle2 = {
155
+ ...overflowStyle,
156
+ WebkitLineClamp: 2
157
+ };
158
+ var PROPERTY_ID = "ogc_fid";
159
+ var LAYER_STATUS = {
160
+ ACTIVE: "Active",
161
+ PENDING: "Pending"
162
+ };
163
+ var SELECTION_STYLE = {
164
+ TOP: "layer_selection_top",
165
+ ALL: "layer_selection_all"
166
+ };
167
+
168
+ // src/utils/grid.ts
169
+ var getZoomConfig = (zoom) => {
170
+ if (zoom < 6) return [4, 1, 39.2];
171
+ else if (zoom < 7) return [5, 0, 19.6];
172
+ else if (zoom < 8) return [5, 1, 9.8];
173
+ else if (zoom < 9) return [5, -1, 4.9];
174
+ else if (zoom < 10) return [6, 0, 2.45];
175
+ else if (zoom < 11) return [6, 1, 1.225];
176
+ else if (zoom < 12) return [7, 0, 0.612];
177
+ else if (zoom < 13) return [7, 1, 0.306];
178
+ else if (zoom < 14) return [7, -1, 0.153];
179
+ else if (zoom < 15) return [8, 0, 0.077];
180
+ return [8, 1, 0.039];
181
+ };
182
+ var BASE32 = "0123456789bcdefghjkmnpqrstuvwxyz";
183
+ var aggregateGeohashKey = (key, level, binSize) => {
184
+ binSize = binSize || 16 / 2 ** (1 - key.length & 1) / 4 ** level;
185
+ const keyExceptLast = key.slice(0, -1);
186
+ const binnedCharAt = ~~(BASE32.indexOf(key.slice(-1)) / binSize);
187
+ return [
188
+ keyExceptLast + BASE32[binSize * binnedCharAt],
189
+ keyExceptLast + BASE32[binSize * (binnedCharAt + 1) - 1]
190
+ ];
191
+ };
192
+ var processRectangles = function(data, level) {
193
+ var counts = /* @__PURE__ */ new Map();
194
+ var bins = /* @__PURE__ */ new Map();
195
+ const features = [];
196
+ for (const [hash, count] of Object.entries(data)) {
197
+ const [kStart, kEnd] = aggregateGeohashKey(hash, level);
198
+ bins.set(kStart, kEnd);
199
+ if (!counts.has(kStart)) {
200
+ counts.set(kStart, 0);
201
+ }
202
+ counts.set(kStart, counts.get(kStart) + count);
203
+ }
204
+ counts.forEach((count, hash) => {
205
+ const bboxStart = GeoHash.decodeGeoHash(hash);
206
+ const bboxEnd = GeoHash.decodeGeoHash(bins.get(hash));
207
+ const feature = new BoundingBox({
208
+ minlat: bboxStart.latitude[0],
209
+ minlon: bboxStart.longitude[0],
210
+ maxlat: bboxEnd.latitude[1],
211
+ maxlon: bboxEnd.longitude[1]
212
+ }).toGeoJSON();
213
+ features.push({ ...feature, properties: { count, [PROPERTY_ID]: hash } });
214
+ });
215
+ return features;
216
+ };
217
+ var processSquares = (data) => {
218
+ const features = [];
219
+ for (const [hash, count] of Object.entries(data)) {
220
+ const bbox2 = GeoHash.decodeGeoHash(hash);
221
+ const feature = new BoundingBox({
222
+ minlat: bbox2.latitude[0],
223
+ minlon: bbox2.longitude[0],
224
+ maxlat: bbox2.latitude[1],
225
+ maxlon: bbox2.longitude[1]
226
+ }).toGeoJSON();
227
+ features.push({ ...feature, properties: { count, [PROPERTY_ID]: hash } });
228
+ }
229
+ return features;
230
+ };
231
+ var geohashToJSON = (data, level) => ({
232
+ type: "FeatureCollection",
233
+ features: Object.keys(data).length === 0 ? [] : level === -1 ? processSquares(data) : processRectangles(data, level)
234
+ });
235
+ var getDataBins = (data, binCount) => {
236
+ const sortedData = Object.values(data).sort((a, b) => a - b);
237
+ const cutoff = Math.floor(sortedData.length / binCount);
238
+ const tBins = new Array(binCount - 1).fill(0).map((_, index) => sortedData[cutoff * (index + 1)]);
239
+ tBins.push(sortedData[sortedData.length - 1]);
240
+ return tBins;
241
+ };
242
+
243
+ // src/utils/naksha.ts
244
+ import { produce } from "immer";
245
+ var parseGeoserverLayersXml = async (layers, nakshaApiEndpoint, geoserver, selectedLayers) => {
246
+ const parsedLayers = [];
247
+ for (const l of layers) {
248
+ const isAdded = selectedLayers.includes(l.name);
249
+ const _l = {
250
+ ...l,
251
+ id: l.name,
252
+ thumbnail: nakshaApiEndpoint + l.thumbnail,
253
+ source: {
254
+ type: l.layerType.toLowerCase() === "raster" ? "raster" : "vector",
255
+ scheme: "tms",
256
+ tiles: [
257
+ `${geoserver.endpoint}/gwc/service/tms/1.0.0/${geoserver.workspace}:${l.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`
258
+ ]
259
+ },
260
+ data: { styles: [] },
261
+ isAdded
262
+ };
263
+ if (isAdded) {
264
+ const _ld = await getLayerStyle(_l, 0, nakshaApiEndpoint, geoserver);
265
+ parsedLayers.push({ ..._l, data: _ld });
266
+ } else {
267
+ parsedLayers.push(_l);
268
+ }
269
+ }
270
+ return parsedLayers;
271
+ };
272
+ var getLayerStyle = async (layer, styleIndex, nakshaApiEndpoint, geoserver) => {
273
+ const nextSl = produce(layer.data, async (_draft) => {
274
+ if (_draft.styles.length === 0) {
275
+ const { success, data } = await axGetGeoserverLayerStyleList(
276
+ layer.id,
277
+ nakshaApiEndpoint
278
+ );
279
+ if (success) {
280
+ _draft.layerName = data.layerName;
281
+ _draft.styles = data.styles;
282
+ _draft.summaryColumn = data.summaryColumn;
283
+ _draft.titleColumn = data.titleColumn;
284
+ _draft.propertyMap = Object.fromEntries(
285
+ data.styles.map((o) => [o.styleName, o.styleTitle])
286
+ );
287
+ }
288
+ }
289
+ if (_draft.styles[styleIndex] && !_draft.styles[styleIndex]?.colors) {
290
+ _draft.styles[styleIndex].colors = await axGetGeoserverLayerStyle(
291
+ layer.id,
292
+ geoserver?.workspace,
293
+ _draft.styles[styleIndex].styleName,
294
+ nakshaApiEndpoint
295
+ );
296
+ }
297
+ _draft.styleIndex = styleIndex;
298
+ });
299
+ return nextSl;
300
+ };
301
+
302
+ // src/services/naksha.ts
303
+ var axGetGeoserverLayers = async (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => {
304
+ try {
305
+ const res = await axios.get(`${nakshaApiEndpoint}/layer/all`, {
306
+ headers: { Authorization: nakshaEndpointToken }
307
+ });
308
+ const finalLayers = await parseGeoserverLayersXml(
309
+ res.data,
310
+ nakshaApiEndpoint,
311
+ geoserver,
312
+ selectedLayers
313
+ );
314
+ return finalLayers;
315
+ } catch (e) {
316
+ console.error(e);
317
+ return [];
318
+ }
319
+ };
320
+ var axGetGeoserverLayerStyleList = async (id, endpoint) => {
321
+ try {
322
+ const { data } = await axios.get(`${endpoint}/layer/onClick/${id}`);
323
+ return { success: true, data };
324
+ } catch (e) {
325
+ console.error(e);
326
+ return { success: false };
327
+ }
328
+ };
329
+ var axGexGetRasterInfoWithLonLat = async (endpoint, workspace, params) => {
330
+ const RasterInfoParams = {
331
+ service: "WMS",
332
+ version: "1.1.1",
333
+ request: "GetFeatureInfo",
334
+ info_format: "application/json",
335
+ width: 100,
336
+ height: 100,
337
+ x: 50,
338
+ y: 50,
339
+ srs: "EPSG:4326"
340
+ };
341
+ try {
342
+ const res = await axios.get(`${endpoint}/${workspace}/wms`, {
343
+ params: { ...params, ...RasterInfoParams }
344
+ });
345
+ return { success: true, data: res.data };
346
+ } catch (e) {
347
+ console.error(e);
348
+ return { success: false, data: [] };
349
+ }
350
+ };
351
+ var axToggleLayerPublishing = async (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => {
352
+ try {
353
+ await axios.put(
354
+ `${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`,
355
+ {},
356
+ { headers: { Authorization: nakshaEndpointToken } }
357
+ );
358
+ return true;
359
+ } catch (e) {
360
+ console.error(e);
361
+ return false;
362
+ }
363
+ };
364
+ var axDeleteLayer = async (nakshaEndpointToken, nakshaApiEndpoint, layerId) => {
365
+ try {
366
+ await axios.delete(`${nakshaApiEndpoint}/layer/${layerId}`, {
367
+ headers: { Authorization: nakshaEndpointToken }
368
+ });
369
+ return true;
370
+ } catch (e) {
371
+ console.error(e);
372
+ return false;
373
+ }
374
+ };
375
+ var axGetGeoserverLayerStyle = async (layername, workspace, styleName, endpoint) => {
376
+ try {
377
+ const res = await axios.get(
378
+ `${endpoint}/geoserver/workspaces/${workspace}/styles/${layername}_${styleName}.mbstyle`
379
+ );
380
+ return res.data?.layers?.[0];
381
+ } catch (e) {
382
+ console.error(e);
383
+ return {};
384
+ }
385
+ };
386
+ var getGridLayerData = async (fetcher, bounds, zoom, binCount = 6, colorScheme = "YlOrRd") => {
387
+ try {
388
+ const [geoAggegationPrecision, level, squareSize] = getZoomConfig(zoom);
389
+ const { _ne, _sw } = bounds;
390
+ const params = {
391
+ top: _ne.lat,
392
+ left: _sw.lng,
393
+ bottom: _sw.lat,
394
+ right: _ne.lng,
395
+ geoAggegationPrecision
396
+ };
397
+ const data = await fetcher(params);
398
+ const geojson = geohashToJSON(data, level);
399
+ const bins = getDataBins(data, binCount);
400
+ const stops = bins.map((bin, index) => [
401
+ bin,
402
+ cb[colorScheme][binCount][index]
403
+ ]);
404
+ const paint2 = {
405
+ "fill-color": {
406
+ property: "count",
407
+ default: "yellow",
408
+ stops
409
+ },
410
+ "fill-outline-color": "rgba(0,0,0,0.2)",
411
+ "fill-opacity": 0.7
412
+ };
413
+ return { success: true, geojson, paint: paint2, stops, squareSize };
414
+ } catch (e) {
415
+ console.error(e);
416
+ return { success: false, geojson: {}, paint: {}, stops: [], squareSize: 0 };
417
+ }
418
+ };
419
+ var axDownloadLayer = async (endpoint, token, layerName, layerTitle) => {
420
+ try {
421
+ await axios.post(
422
+ `${endpoint}/layer/download`,
423
+ { layerName, layerTitle, attributeList: [], filterArray: [] },
424
+ { headers: { Authorization: token } }
425
+ );
426
+ } catch (e) {
427
+ console.error(e);
428
+ }
429
+ };
430
+
431
+ // src/hooks/use-layers.tsx
432
+ import { jsx } from "react/jsx-runtime";
433
+ var LayersContext = createContext(
434
+ {}
435
+ );
436
+ var LayersProvider = ({ mp: _mp, children }) => {
437
+ const [mp, setMP] = useState(_mp);
438
+ const { mapl } = useMap();
439
+ const [queryTerm, setQueryTerm] = useState("");
440
+ const queryTermDebounced = useDebounce(queryTerm, 500);
441
+ const styles = mp.mapStyles && mp.mapStyles.length > 0 ? mp.mapStyles : defaultMapStyles;
442
+ const [mapStyle, setMapStyle] = useState(
443
+ styles[mp?.mapStyle || 0]?.style
444
+ );
445
+ const [maxZoom, setMaxZoom] = useState(
446
+ styles[mp?.mapStyle || 0]?.maxZoom
447
+ );
448
+ const [selectionStyle, setSelectionStyle] = useState(
449
+ SELECTION_STYLE.TOP
450
+ );
451
+ const [gridLegends, setGridLegends] = useState({});
452
+ const [isInfoBarOpen, setIsInfoBarOpen] = useState(true);
453
+ const [clickedLngLat, setClickedLngLat] = useState();
454
+ const [layers, setLayers] = useState(_mp.layers || []);
455
+ const [selectedLayerIds, setSelectedLayerIds] = useState(
456
+ mp.selectedLayers || []
457
+ );
458
+ const [hoverFeatures, setHoverFeatures] = useState();
459
+ const [selectedFeatures, setSelectedFeatures] = useState();
460
+ const selectedFeaturesId = useMemo(() => {
461
+ const meta = {};
462
+ for (const qr of selectedFeatures || []) {
463
+ meta[qr.sourceLayer] = [
464
+ ...meta[qr.sourceLayer] || [],
465
+ qr?.properties?.[PROPERTY_ID]
466
+ ];
467
+ }
468
+ return Object.keys(meta).length ? meta : void 0;
469
+ }, [selectedFeatures]);
470
+ const selectedLayers = React.useMemo(() => {
471
+ const unsortedLayers = layers.filter(
472
+ (_layer) => selectedLayerIds.includes(_layer.id)
473
+ );
474
+ const sortedLayers = new Array(selectedLayerIds.length);
475
+ for (const layerToSort of unsortedLayers) {
476
+ const idx = selectedLayerIds.findIndex((l) => layerToSort.id === l);
477
+ if (idx > -1) {
478
+ sortedLayers[idx] = layerToSort;
479
+ }
480
+ }
481
+ return sortedLayers;
482
+ }, [layers, selectedLayerIds]);
483
+ const getLayerIndexById = (layerId) => {
484
+ return layers.findIndex((layer) => layer.id === layerId);
485
+ };
486
+ const updateLayerById = (layerId, updatedLayer) => {
487
+ setLayers(
488
+ (_layers) => _layers.map((l) => l.id === layerId ? { ...l, ...updatedLayer } : l)
489
+ );
490
+ };
491
+ const toggleVectorLayer = async (layerIndex, styleIndex, focus) => {
492
+ const layer = layers[layerIndex];
493
+ const layerData = await getLayerStyle(
494
+ layer,
495
+ styleIndex,
496
+ mp.nakshaApiEndpoint,
497
+ mp.geoserver
498
+ );
499
+ updateLayerById(layer.id, { data: layerData });
500
+ focus && mapl?.fitBounds(layer.bbox, { padding: 40, duration: 1e3 });
501
+ };
502
+ const updateLayerStyle = async (layerId, styleIndex) => {
503
+ const layerIndex = getLayerIndexById(layerId);
504
+ toggleVectorLayer(layerIndex, styleIndex, false);
505
+ };
506
+ const onMapHover = async (e) => {
507
+ if (!selectedLayerIds.length || !mapl) return;
508
+ try {
509
+ const lastLayerId = selectedLayerIds[0];
510
+ const feats = mapl.queryRenderedFeatures(e.point, {
511
+ layers: [lastLayerId]
512
+ });
513
+ if (feats.length) {
514
+ const fId = feats[0]?.id || feats[0]?.properties?.[PROPERTY_ID];
515
+ if (fId === hoverFeatures?.id) return;
516
+ const layer = layers[getLayerIndexById(lastLayerId)];
517
+ const hoverProperties = layer?.data?.summaryColumn.map((sc) => [
518
+ layer.data?.propertyMap?.[sc] || sc,
519
+ feats[0].properties?.[sc]
520
+ ]);
521
+ setHoverFeatures({
522
+ id: fId,
523
+ title: layer.title,
524
+ data: hoverProperties
525
+ });
526
+ } else {
527
+ setHoverFeatures(void 0);
528
+ }
529
+ } catch (e2) {
530
+ }
531
+ };
532
+ const toggleLayer = async ({
533
+ layerId,
534
+ add,
535
+ styleIndex = 0,
536
+ focus = true
537
+ }) => {
538
+ if (!add) {
539
+ setSelectedLayerIds(
540
+ selectedLayerIds.filter((_lyrId) => layerId !== _lyrId)
541
+ );
542
+ return;
543
+ }
544
+ const layerIndex = getLayerIndexById(layerId);
545
+ const sourceType = layers[layerIndex]?.source.type;
546
+ if (sourceType === "grid") {
547
+ setSelectedLayerIds((_slIds) => [
548
+ layerId,
549
+ ..._slIds.filter((lid) => lid !== layerId)
550
+ ]);
551
+ if (focus && layers[layerIndex]?.bbox) {
552
+ setTimeout(() => {
553
+ mapl?.fitBounds(layers[layerIndex].bbox, {
554
+ padding: 40,
555
+ duration: 1e3
556
+ });
557
+ }, 100);
558
+ }
559
+ } else {
560
+ await toggleVectorLayer(layerIndex, styleIndex, focus);
561
+ setSelectedLayerIds((_slIds) => [
562
+ layerId,
563
+ ..._slIds.filter((lid) => lid !== layerId)
564
+ ]);
565
+ }
566
+ };
567
+ const clearAllLayers = async () => setSelectedLayerIds([]);
568
+ const updateMP = (key, value) => {
569
+ setMP({ ...mp, [key]: value });
570
+ };
571
+ const toggleLayerPublishing = (layerId, layerStatus) => {
572
+ const isActive = layerStatus === LAYER_STATUS.PENDING;
573
+ axToggleLayerPublishing(
574
+ mp.nakshaEndpointToken,
575
+ mp.nakshaApiEndpoint,
576
+ layerId,
577
+ isActive
578
+ );
579
+ updateLayerById(layerId, {
580
+ layerStatus: isActive ? LAYER_STATUS.ACTIVE : LAYER_STATUS.PENDING
581
+ });
582
+ };
583
+ const deleteLayer = async (layerId, message) => {
584
+ if (confirm(message)) {
585
+ axDeleteLayer(mp.nakshaEndpointToken, mp.nakshaApiEndpoint, layerId);
586
+ setLayers(layers.filter((l) => l.id !== layerId));
587
+ }
588
+ };
589
+ const zoomToExtent = (layerId) => {
590
+ const layerIndex = getLayerIndexById(layerId);
591
+ const layer = layers[layerIndex];
592
+ mapl?.fitBounds(layer.bbox, { padding: 40, duration: 1e3 });
593
+ };
594
+ const getBBoxFromLngLat = () => {
595
+ return [
596
+ clickedLngLat.lng,
597
+ clickedLngLat.lat,
598
+ clickedLngLat.lng + 0.1,
599
+ clickedLngLat.lat + 0.1
600
+ ];
601
+ };
602
+ const handleSelectStyle = (value) => {
603
+ setSelectionStyle(value);
604
+ if (value === SELECTION_STYLE.TOP) {
605
+ featuresAtLatLng(value);
606
+ }
607
+ };
608
+ const featuresAtLatLng = (value) => {
609
+ if (!clickedLngLat) return;
610
+ try {
611
+ const finalXY = mapl?.project([clickedLngLat.lng, clickedLngLat.lat]);
612
+ let queryFeat = mapl?.queryRenderedFeatures(finalXY, {
613
+ layers: selectionStyle === SELECTION_STYLE.TOP ? [selectedLayerIds[0]] : selectedLayerIds
614
+ });
615
+ if ((value || selectionStyle) === SELECTION_STYLE.ALL) {
616
+ const rasterLayerFeat = selectedLayers.filter((item) => item.layerType == "RASTER").map((item) => ({
617
+ sourceLayer: item.id,
618
+ layerType: "raster",
619
+ bbox: getBBoxFromLngLat()
620
+ }));
621
+ queryFeat = [...queryFeat, ...rasterLayerFeat];
622
+ }
623
+ setSelectedFeatures(
624
+ // if fist layer is raster and select all in not set
625
+ // send a raster based feature object
626
+ selectedLayers?.[0].layerType === "RASTER" && selectionStyle !== SELECTION_STYLE.ALL ? selectedLayerIds.length && queryFeat?.length ? queryFeat : [
627
+ {
628
+ sourceLayer: selectedLayerIds[0],
629
+ layerType: "raster",
630
+ bbox: getBBoxFromLngLat()
631
+ }
632
+ ] : queryFeat
633
+ );
634
+ } catch (e) {
635
+ console.error(e);
636
+ }
637
+ };
638
+ useEffect(() => {
639
+ if (mp.onSelectedLayersChange) {
640
+ mp.onSelectedLayersChange(selectedLayerIds);
641
+ }
642
+ }, [selectedLayerIds]);
643
+ useEffect(() => {
644
+ setTimeout(featuresAtLatLng, 300);
645
+ }, [clickedLngLat, selectionStyle, selectedLayerIds]);
646
+ return /* @__PURE__ */ jsx(
647
+ LayersContext.Provider,
648
+ {
649
+ value: {
650
+ mp,
651
+ updateMP,
652
+ layer: {
653
+ mapStyle,
654
+ featuresAtLatLng,
655
+ setMapStyle,
656
+ maxZoom,
657
+ setMaxZoom,
658
+ mapStyles: styles,
659
+ all: layers,
660
+ setAll: setLayers,
661
+ selectedIds: selectedLayerIds,
662
+ handleSelectStyle,
663
+ setSelectedIds: setSelectedLayerIds,
664
+ selectedLayers,
665
+ clearAll: clearAllLayers,
666
+ toggle: toggleLayer,
667
+ updateStyle: updateLayerStyle,
668
+ selectedFeatures,
669
+ selectedFeaturesId,
670
+ setSelectedFeatures,
671
+ togglePublish: toggleLayerPublishing,
672
+ delete: deleteLayer,
673
+ selectionStyle,
674
+ setSelectionStyle,
675
+ zoomToExtent,
676
+ gridLegends,
677
+ setGridLegends
678
+ },
679
+ query: {
680
+ term: queryTermDebounced,
681
+ setTerm: setQueryTerm,
682
+ clickedLngLat,
683
+ setClickedLngLat
684
+ },
685
+ isInfoBarOpen,
686
+ setIsInfoBarOpen,
687
+ hover: {
688
+ onHover: onMapHover,
689
+ features: hoverFeatures
690
+ }
691
+ },
692
+ children
693
+ }
694
+ );
695
+ };
696
+ function useLayers() {
697
+ return useContext(LayersContext);
698
+ }
699
+
700
+ // src/components/core/button.tsx
701
+ import React2 from "react";
702
+ import { tw as tw2 } from "twind";
703
+
704
+ // src/components/core/icons.tsx
705
+ import { tw } from "twind";
706
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
707
+ var SearchIcon = () => /* @__PURE__ */ jsx2(
708
+ "svg",
709
+ {
710
+ fill: "none",
711
+ className: tw`w-5 h-5 text-gray-400`,
712
+ width: "24",
713
+ height: "24",
714
+ viewBox: "0 0 24 24",
715
+ children: /* @__PURE__ */ jsx2(
716
+ "path",
717
+ {
718
+ stroke: "currentColor",
719
+ strokeLinecap: "round",
720
+ strokeLinejoin: "round",
721
+ strokeWidth: "2",
722
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
723
+ }
724
+ )
725
+ }
726
+ );
727
+ var LayersIcon = () => /* @__PURE__ */ jsxs(
728
+ "svg",
729
+ {
730
+ width: "18",
731
+ height: "18",
732
+ fill: "none",
733
+ stroke: "currentColor",
734
+ strokeLinecap: "round",
735
+ strokeLinejoin: "round",
736
+ strokeWidth: "2",
737
+ viewBox: "0 0 24 24",
738
+ children: [
739
+ /* @__PURE__ */ jsx2("path", { d: "M12 2L2 7 12 12 22 7 12 2z" }),
740
+ /* @__PURE__ */ jsx2("path", { d: "M2 17L12 22 22 17" }),
741
+ /* @__PURE__ */ jsx2("path", { d: "M2 12L12 17 22 12" })
742
+ ]
743
+ }
744
+ );
745
+ var InfoIcon = () => /* @__PURE__ */ jsxs(
746
+ "svg",
747
+ {
748
+ width: "16",
749
+ height: "16",
750
+ viewBox: "0 0 24 24",
751
+ fill: "none",
752
+ stroke: "currentColor",
753
+ strokeWidth: "2",
754
+ strokeLinecap: "round",
755
+ strokeLinejoin: "round",
756
+ children: [
757
+ /* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "10" }),
758
+ /* @__PURE__ */ jsx2("line", { x1: "12", y1: "16", x2: "12", y2: "12" }),
759
+ /* @__PURE__ */ jsx2("line", { x1: "12", y1: "8", x2: "12.01", y2: "8" })
760
+ ]
761
+ }
762
+ );
763
+ var SlidersIcon = () => /* @__PURE__ */ jsxs(
764
+ "svg",
765
+ {
766
+ width: "18",
767
+ height: "18",
768
+ fill: "none",
769
+ stroke: "currentColor",
770
+ strokeLinecap: "round",
771
+ strokeLinejoin: "round",
772
+ strokeWidth: "2",
773
+ viewBox: "0 0 24 24",
774
+ children: [
775
+ /* @__PURE__ */ jsx2("path", { d: "M4 21L4 14" }),
776
+ /* @__PURE__ */ jsx2("path", { d: "M4 10L4 3" }),
777
+ /* @__PURE__ */ jsx2("path", { d: "M12 21L12 12" }),
778
+ /* @__PURE__ */ jsx2("path", { d: "M12 8L12 3" }),
779
+ /* @__PURE__ */ jsx2("path", { d: "M20 21L20 16" }),
780
+ /* @__PURE__ */ jsx2("path", { d: "M20 12L20 3" }),
781
+ /* @__PURE__ */ jsx2("path", { d: "M1 14L7 14" }),
782
+ /* @__PURE__ */ jsx2("path", { d: "M9 8L15 8" }),
783
+ /* @__PURE__ */ jsx2("path", { d: "M17 16L23 16" })
784
+ ]
785
+ }
786
+ );
787
+ function AttributionIcon() {
788
+ return /* @__PURE__ */ jsx2(
789
+ "svg",
790
+ {
791
+ width: "14",
792
+ height: "14",
793
+ viewBox: "0 0 16 16",
794
+ style: { display: "inline-block" },
795
+ children: /* @__PURE__ */ jsx2(
796
+ "path",
797
+ {
798
+ fillRule: "evenodd",
799
+ fill: "currentColor",
800
+ d: "M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"
801
+ }
802
+ )
803
+ }
804
+ );
805
+ }
806
+ function TagIcon() {
807
+ return /* @__PURE__ */ jsx2(
808
+ "svg",
809
+ {
810
+ width: "14",
811
+ height: "14",
812
+ viewBox: "0 0 16 16",
813
+ style: { display: "inline-block" },
814
+ children: /* @__PURE__ */ jsx2(
815
+ "path",
816
+ {
817
+ fillRule: "evenodd",
818
+ fill: "currentColor",
819
+ d: "M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"
820
+ }
821
+ )
822
+ }
823
+ );
824
+ }
825
+ function LicenseIcon() {
826
+ return /* @__PURE__ */ jsx2(
827
+ "svg",
828
+ {
829
+ width: "14",
830
+ height: "14",
831
+ viewBox: "0 0 16 16",
832
+ style: { display: "inline-block" },
833
+ children: /* @__PURE__ */ jsx2(
834
+ "path",
835
+ {
836
+ fillRule: "evenodd",
837
+ fill: "currentColor",
838
+ d: "M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"
839
+ }
840
+ )
841
+ }
842
+ );
843
+ }
844
+ function EyeIcon() {
845
+ return /* @__PURE__ */ jsx2(
846
+ "svg",
847
+ {
848
+ viewBox: "0 0 16 16",
849
+ width: "14",
850
+ height: "14",
851
+ style: { display: "inline-block" },
852
+ children: /* @__PURE__ */ jsx2(
853
+ "path",
854
+ {
855
+ fillRule: "evenodd",
856
+ fill: "currentColor",
857
+ d: "M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"
858
+ }
859
+ )
860
+ }
861
+ );
862
+ }
863
+ function ClockIcon() {
864
+ return /* @__PURE__ */ jsx2(
865
+ "svg",
866
+ {
867
+ viewBox: "0 0 16 16",
868
+ width: "14",
869
+ height: "14",
870
+ style: { display: "inline-block" },
871
+ children: /* @__PURE__ */ jsx2(
872
+ "path",
873
+ {
874
+ fillRule: "evenodd",
875
+ fill: "currentColor",
876
+ d: "M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"
877
+ }
878
+ )
879
+ }
880
+ );
881
+ }
882
+ function DownloadIcon() {
883
+ return /* @__PURE__ */ jsx2(
884
+ "svg",
885
+ {
886
+ viewBox: "0 0 16 16",
887
+ width: "16",
888
+ height: "16",
889
+ style: { display: "inline-block" },
890
+ children: /* @__PURE__ */ jsx2(
891
+ "path",
892
+ {
893
+ fillRule: "evenodd",
894
+ fill: "currentColor",
895
+ d: "M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"
896
+ }
897
+ )
898
+ }
899
+ );
900
+ }
901
+ function ZoomExtentIcon() {
902
+ return /* @__PURE__ */ jsx2(
903
+ "svg",
904
+ {
905
+ viewBox: "0 0 24 24",
906
+ width: "16",
907
+ height: "16",
908
+ fill: "none",
909
+ stroke: "currentColor",
910
+ strokeWidth: "2",
911
+ strokeLinecap: "round",
912
+ strokeLinejoin: "round",
913
+ style: { display: "inline-block" },
914
+ children: /* @__PURE__ */ jsx2("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" })
915
+ }
916
+ );
917
+ }
918
+ function ShareIcon() {
919
+ return /* @__PURE__ */ jsxs(
920
+ "svg",
921
+ {
922
+ viewBox: "0 0 24 24",
923
+ width: "16",
924
+ height: "16",
925
+ fill: "none",
926
+ stroke: "currentColor",
927
+ strokeWidth: "2",
928
+ strokeLinecap: "round",
929
+ strokeLinejoin: "round",
930
+ style: { display: "inline-block" },
931
+ children: [
932
+ /* @__PURE__ */ jsx2("circle", { cx: "18", cy: "5", r: "3" }),
933
+ /* @__PURE__ */ jsx2("circle", { cx: "6", cy: "12", r: "3" }),
934
+ /* @__PURE__ */ jsx2("circle", { cx: "18", cy: "19", r: "3" }),
935
+ /* @__PURE__ */ jsx2("line", { x1: "8.59", y1: "13.51", x2: "15.42", y2: "17.49" }),
936
+ /* @__PURE__ */ jsx2("line", { x1: "15.41", y1: "6.51", x2: "8.59", y2: "10.49" })
937
+ ]
938
+ }
939
+ );
940
+ }
941
+ function GrabberIcon() {
942
+ return /* @__PURE__ */ jsx2(
943
+ "svg",
944
+ {
945
+ viewBox: "0 0 16 16",
946
+ width: "16",
947
+ height: "16",
948
+ style: { display: "inline-block" },
949
+ children: /* @__PURE__ */ jsx2(
950
+ "path",
951
+ {
952
+ fillRule: "evenodd",
953
+ d: "M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"
954
+ }
955
+ )
956
+ }
957
+ );
958
+ }
959
+ function CrossHairIcon() {
960
+ return /* @__PURE__ */ jsxs(
961
+ "svg",
962
+ {
963
+ style: { display: "inline-block" },
964
+ width: "18",
965
+ height: "18",
966
+ viewBox: "0 0 24 24",
967
+ fill: "none",
968
+ stroke: "currentColor",
969
+ strokeWidth: "2",
970
+ strokeLinecap: "round",
971
+ strokeLinejoin: "round",
972
+ children: [
973
+ /* @__PURE__ */ jsx2("circle", { cx: "12", cy: "12", r: "10" }),
974
+ /* @__PURE__ */ jsx2("line", { x1: "22", y1: "12", x2: "18", y2: "12" }),
975
+ /* @__PURE__ */ jsx2("line", { x1: "6", y1: "12", x2: "2", y2: "12" }),
976
+ /* @__PURE__ */ jsx2("line", { x1: "12", y1: "6", x2: "12", y2: "2" }),
977
+ /* @__PURE__ */ jsx2("line", { x1: "12", y1: "22", x2: "12", y2: "18" })
978
+ ]
979
+ }
980
+ );
981
+ }
982
+ function DownIcon() {
983
+ return /* @__PURE__ */ jsx2(
984
+ "svg",
985
+ {
986
+ width: "18",
987
+ height: "18",
988
+ viewBox: "0 0 24 24",
989
+ fill: "none",
990
+ stroke: "currentColor",
991
+ strokeWidth: "2",
992
+ strokeLinecap: "round",
993
+ strokeLinejoin: "round",
994
+ style: { display: "inline-block" },
995
+ children: /* @__PURE__ */ jsx2("polyline", { points: "6 9 12 15 18 9" })
996
+ }
997
+ );
998
+ }
999
+ function UpIcon() {
1000
+ return /* @__PURE__ */ jsx2(
1001
+ "svg",
1002
+ {
1003
+ width: "18",
1004
+ height: "18",
1005
+ viewBox: "0 0 24 24",
1006
+ fill: "none",
1007
+ stroke: "currentColor",
1008
+ strokeWidth: "2",
1009
+ strokeLinecap: "round",
1010
+ strokeLinejoin: "round",
1011
+ style: { display: "inline-block" },
1012
+ children: /* @__PURE__ */ jsx2("polyline", { points: "18 15 12 9 6 15" })
1013
+ }
1014
+ );
1015
+ }
1016
+
1017
+ // src/components/core/button.tsx
1018
+ import { jsx as jsx3 } from "react/jsx-runtime";
1019
+ var Button = React2.forwardRef((props, ref) => /* @__PURE__ */ jsx3(
1020
+ "button",
1021
+ {
1022
+ ref,
1023
+ type: "button",
1024
+ className: tw2`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,
1025
+ ...props
1026
+ }
1027
+ ));
1028
+ var CloseButton = (props) => /* @__PURE__ */ jsx3(
1029
+ "button",
1030
+ {
1031
+ className: tw2`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,
1032
+ children: "\u2715",
1033
+ ...props
1034
+ }
1035
+ );
1036
+ var LayersButton = (props) => /* @__PURE__ */ jsx3(
1037
+ "button",
1038
+ {
1039
+ className: tw2`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,
1040
+ ...props,
1041
+ children: /* @__PURE__ */ jsx3(LayersIcon, {})
1042
+ }
1043
+ );
1044
+ var InfobarButton = (props) => /* @__PURE__ */ jsx3(
1045
+ "button",
1046
+ {
1047
+ className: tw2`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,
1048
+ ...props,
1049
+ children: /* @__PURE__ */ jsx3(InfoIcon, {})
1050
+ }
1051
+ );
1052
+
1053
+ // src/components/core/input.tsx
1054
+ import { tw as tw3 } from "twind";
1055
+ import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
1056
+ var SelectInput = (props) => /* @__PURE__ */ jsxs2("div", { children: [
1057
+ props.label && /* @__PURE__ */ jsx4("label", { className: tw3`text-gray-700`, htmlFor: props.name, children: props.label }),
1058
+ /* @__PURE__ */ jsx4(
1059
+ "select",
1060
+ {
1061
+ id: props.name,
1062
+ name: props.name,
1063
+ className: tw3`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,
1064
+ style: {
1065
+ backgroundImage: `url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,
1066
+ backgroundPosition: "right 0.75rem center",
1067
+ backgroundSize: "16px 12px",
1068
+ backgroundRepeat: "no-repeat"
1069
+ },
1070
+ ...props
1071
+ }
1072
+ )
1073
+ ] });
1074
+ var SearchInput = (props) => /* @__PURE__ */ jsxs2("div", { className: "relative", children: [
1075
+ /* @__PURE__ */ jsx4("span", { className: tw3`absolute inset-y-0 left-0 flex items-center pl-3`, children: /* @__PURE__ */ jsx4(SearchIcon, {}) }),
1076
+ /* @__PURE__ */ jsx4(
1077
+ "input",
1078
+ {
1079
+ type: "search",
1080
+ className: tw3`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,
1081
+ ...props
1082
+ }
1083
+ )
1084
+ ] });
1085
+ var CheckboxInput = (props) => props.isLoading ? /* @__PURE__ */ jsx4(
1086
+ "svg",
1087
+ {
1088
+ width: "20px",
1089
+ height: "20px",
1090
+ viewBox: "0 0 20 20",
1091
+ version: "1.1",
1092
+ className: tw3`inline text-gray-200 animate-spin dark:text-gray-600`,
1093
+ children: /* @__PURE__ */ jsx4("g", { stroke: "none", strokeWidth: "1", fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ jsx4("g", { fill: "#212121", fillRule: "nonzero", children: /* @__PURE__ */ jsx4("path", { d: "M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z" }) }) })
1094
+ }
1095
+ ) : /* @__PURE__ */ jsx4(
1096
+ "input",
1097
+ {
1098
+ type: "checkbox",
1099
+ className: tw3`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,
1100
+ name: props.name,
1101
+ checked: props.checked,
1102
+ onChange: props.onChange
1103
+ }
1104
+ );
1105
+
1106
+ // src/components/core/tabs.tsx
1107
+ import { Tabs, usePanelState, useTabState } from "@bumaga/tabs";
1108
+ import clsx from "clsx";
1109
+ import { tw as tw4 } from "twind";
1110
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1111
+ var IconTab = ({ children, icon }) => {
1112
+ const { onClick, isActive } = useTabState();
1113
+ const classes = clsx([
1114
+ "flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",
1115
+ {
1116
+ "text-blue-600 border-blue-500": isActive,
1117
+ "text-gray-700 border-gray-300 hover:border-gray-400": !isActive
1118
+ }
1119
+ ]);
1120
+ return /* @__PURE__ */ jsxs3("button", { className: tw4(classes), onClick, children: [
1121
+ icon,
1122
+ /* @__PURE__ */ jsx5("span", { className: tw4`ml-2 text-base`, children })
1123
+ ] });
1124
+ };
1125
+ var Panel = ({ children }) => {
1126
+ const isActive = usePanelState();
1127
+ return isActive ? /* @__PURE__ */ jsx5("div", { className: tw4`w-full flex flex-grow-1 overflow-auto`, children }) : null;
1128
+ };
1129
+ var TabHeader = ({ children }) => /* @__PURE__ */ jsx5(
1130
+ "div",
1131
+ {
1132
+ className: tw4`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,
1133
+ children
1134
+ }
1135
+ );
1136
+
1137
+ // src/components/infobar/content.tsx
1138
+ import { useT as useT2 } from "@biodiv-platform/naksha-commons";
1139
+ import { tw as tw6 } from "twind";
1140
+
1141
+ // src/components/sidebar/settings/layer-selection.tsx
1142
+ import { useT } from "@biodiv-platform/naksha-commons";
1143
+ import { jsx as jsx6 } from "react/jsx-runtime";
1144
+ function LayerSelection({ hideLabel }) {
1145
+ const {
1146
+ layer: { selectionStyle, handleSelectStyle }
1147
+ } = useLayers();
1148
+ const { t } = useT();
1149
+ const handleOnSelectionStyleChange = (e) => {
1150
+ handleSelectStyle(e.target.value);
1151
+ };
1152
+ return /* @__PURE__ */ jsx6(
1153
+ SelectInput,
1154
+ {
1155
+ name: "layer_selection",
1156
+ label: hideLabel ? null : t("layer_selection"),
1157
+ defaultValue: selectionStyle,
1158
+ onChange: handleOnSelectionStyleChange,
1159
+ children: Object.values(SELECTION_STYLE).map((ss) => /* @__PURE__ */ jsx6("option", { value: ss, children: t(ss) }, ss))
1160
+ }
1161
+ );
1162
+ }
1163
+
1164
+ // src/components/infobar/infobar-panel.tsx
1165
+ import clsx2 from "clsx";
1166
+ import { useEffect as useEffect2, useState as useState2 } from "react";
1167
+ import { tw as tw5 } from "twind";
1168
+ import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
1169
+ function InfoBarPanel({ data: payload }) {
1170
+ const [isOpen, setIsOpen] = useState2(true);
1171
+ const [layerInfo, setLayerInfo] = useState2({
1172
+ title: payload.sourceLayer,
1173
+ properties: []
1174
+ });
1175
+ const {
1176
+ layer,
1177
+ mp,
1178
+ query: { clickedLngLat }
1179
+ } = useLayers();
1180
+ const getPropertyData = async () => {
1181
+ let properties;
1182
+ const currentLayer = layer.selectedLayers.find(
1183
+ (l) => l.id === (payload.sourceLayer || payload.source)
1184
+ );
1185
+ if (currentLayer.layerType.toLowerCase() === "raster") {
1186
+ const { data } = await axGexGetRasterInfoWithLonLat(
1187
+ mp.geoserver?.endpoint,
1188
+ mp.geoserver?.workspace,
1189
+ {
1190
+ bbox: payload.bbox.toString(),
1191
+ query_layers: `${mp.geoserver?.workspace}:${currentLayer.id}`,
1192
+ layers: `${mp.geoserver?.workspace}:${currentLayer.id}`
1193
+ }
1194
+ );
1195
+ properties = data?.features[0] ? Object.entries(data.features[0]?.properties).map(([v, k]) => [
1196
+ k || "-"
1197
+ ]) : [];
1198
+ } else {
1199
+ properties = Object.entries(currentLayer?.data?.propertyMap || {}).map(
1200
+ ([k, v]) => [v, payload?.properties?.[k]]
1201
+ );
1202
+ }
1203
+ setLayerInfo({ title: currentLayer.title, properties });
1204
+ };
1205
+ useEffect2(() => {
1206
+ getPropertyData();
1207
+ }, [clickedLngLat]);
1208
+ return /* @__PURE__ */ jsxs4("div", { className: tw5`bg-gray-100 rounded-lg`, children: [
1209
+ /* @__PURE__ */ jsxs4(
1210
+ "button",
1211
+ {
1212
+ className: tw5(
1213
+ clsx2([
1214
+ `px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring`,
1215
+ { "bg-gray-200 rounded-t-lg": isOpen, "rounded-lg": !isOpen }
1216
+ ])
1217
+ ),
1218
+ onClick: () => setIsOpen(!isOpen),
1219
+ children: [
1220
+ layerInfo.title,
1221
+ " ",
1222
+ isOpen ? /* @__PURE__ */ jsx7(UpIcon, {}) : /* @__PURE__ */ jsx7(DownIcon, {})
1223
+ ]
1224
+ }
1225
+ ),
1226
+ isOpen && /* @__PURE__ */ jsx7("div", { className: tw5`px-4 py-3 flex flex-col gap-3`, children: layerInfo.properties.map(([k, v], index) => /* @__PURE__ */ jsxs4("div", { children: [
1227
+ /* @__PURE__ */ jsx7("div", { className: tw5`text-gray-600`, children: k }),
1228
+ /* @__PURE__ */ jsx7("div", { children: v })
1229
+ ] }, k + v + index)) })
1230
+ ] });
1231
+ }
1232
+
1233
+ // src/components/infobar/content.tsx
1234
+ import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1235
+ function InfoBarContent({ onClose }) {
1236
+ const {
1237
+ layer: { selectedFeatures, selectedLayers, selectionStyle }
1238
+ } = useLayers();
1239
+ const { t } = useT2();
1240
+ return /* @__PURE__ */ jsxs5(
1241
+ "div",
1242
+ {
1243
+ className: tw6`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,
1244
+ children: [
1245
+ /* @__PURE__ */ jsxs5("div", { className: "flex w-full", children: [
1246
+ /* @__PURE__ */ jsxs5(
1247
+ "div",
1248
+ {
1249
+ className: tw6`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,
1250
+ children: [
1251
+ /* @__PURE__ */ jsx8(CrossHairIcon, {}),
1252
+ " ",
1253
+ t("infobar")
1254
+ ]
1255
+ }
1256
+ ),
1257
+ /* @__PURE__ */ jsx8(CloseButton, { onClick: onClose })
1258
+ ] }),
1259
+ /* @__PURE__ */ jsx8("div", { className: tw6`bg-gray-100 p-4 flex-shrink-0 rt`, children: /* @__PURE__ */ jsx8(LayerSelection, { hideLabel: true }) }),
1260
+ /* @__PURE__ */ jsx8("div", { className: tw6`flex flex-col flex-grow overflow-auto gap-3 p-4`, children: selectedFeatures.flat(1)?.map((data) => /* @__PURE__ */ jsx8(
1261
+ InfoBarPanel,
1262
+ {
1263
+ data
1264
+ },
1265
+ selectedLayers?.[0]?.source.type === "raster" || selectionStyle === SELECTION_STYLE.ALL ? data?.sourceLayer : data?.sourceLayer + data?.properties[PROPERTY_ID]
1266
+ )) })
1267
+ ]
1268
+ }
1269
+ );
1270
+ }
1271
+
1272
+ // src/components/infobar/index.tsx
1273
+ import { jsx as jsx9 } from "react/jsx-runtime";
1274
+ function InfoBar() {
1275
+ const { layer, isInfoBarOpen, setIsInfoBarOpen } = useLayers();
1276
+ if (!layer.selectedFeatures?.length) return null;
1277
+ const toggleOpen = () => setIsInfoBarOpen(!isInfoBarOpen);
1278
+ return isInfoBarOpen ? /* @__PURE__ */ jsx9(InfoBarContent, { onClose: toggleOpen }) : /* @__PURE__ */ jsx9(InfobarButton, { onClick: toggleOpen });
1279
+ }
1280
+
1281
+ // src/components/sidebar/index.tsx
1282
+ import { useEffect as useEffect3, useState as useState8 } from "react";
1283
+ import { useMap as useMap2 } from "react-map-gl/maplibre";
1284
+
1285
+ // src/components/sidebar/tabs.tsx
1286
+ import { useT as useT10 } from "@biodiv-platform/naksha-commons";
1287
+ import { tw as tw18 } from "twind";
1288
+
1289
+ // src/components/sidebar/layers/index.tsx
1290
+ import { tw as tw15 } from "twind";
1291
+
1292
+ // src/components/sidebar/layers/layer-list.tsx
1293
+ import React8, { useMemo as useMemo4 } from "react";
1294
+ import { useVirtual } from "react-virtual";
1295
+ import { AutoSizer } from "react-virtualized-auto-sizer";
1296
+ import { tw as tw13 } from "twind";
1297
+
1298
+ // src/components/sidebar/common/layer-item.tsx
1299
+ import { useT as useT6 } from "@biodiv-platform/naksha-commons";
1300
+ import { useMemo as useMemo3, useState as useState6 } from "react";
1301
+ import { RWebShare } from "react-web-share";
1302
+ import { tw as tw12 } from "twind";
1303
+
1304
+ // src/components/core/highlighter.tsx
1305
+ import { Fragment, jsx as jsx10 } from "react/jsx-runtime";
1306
+ var Highlighted = ({ text = "", highlight = "" }) => {
1307
+ if (!highlight.trim()) {
1308
+ return /* @__PURE__ */ jsx10(Fragment, { children: text });
1309
+ }
1310
+ const regex = new RegExp(`(${highlight})`, "gi");
1311
+ const parts = text.split(regex);
1312
+ return /* @__PURE__ */ jsx10(Fragment, { children: parts.filter((part) => part).map(
1313
+ (part, i) => regex.test(part) ? /* @__PURE__ */ jsx10("mark", { children: part }, i) : /* @__PURE__ */ jsx10("span", { children: part }, i)
1314
+ ) });
1315
+ };
1316
+
1317
+ // src/components/sidebar/common/grid-legend.tsx
1318
+ import { tw as tw8 } from "twind";
1319
+
1320
+ // src/components/sidebar/common/moreless.tsx
1321
+ import { useT as useT3 } from "@biodiv-platform/naksha-commons";
1322
+ import { useState as useState3 } from "react";
1323
+ import { tw as tw7 } from "twind";
1324
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
1325
+ function MoreLess({ children }) {
1326
+ const [showMore, setShowMore] = useState3(false);
1327
+ const { t } = useT3();
1328
+ return /* @__PURE__ */ jsxs6("div", { children: [
1329
+ showMore && children,
1330
+ /* @__PURE__ */ jsx11(
1331
+ "button",
1332
+ {
1333
+ onClick: () => setShowMore(!showMore),
1334
+ className: tw7`text-blue-600 focus:outline-none focus:outline focus:ring`,
1335
+ children: showMore ? t("less") : t("legend")
1336
+ }
1337
+ )
1338
+ ] });
1339
+ }
1340
+
1341
+ // src/components/sidebar/common/grid-legend.tsx
1342
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
1343
+ function GridLegend({ item }) {
1344
+ const { layer } = useLayers();
1345
+ const legendInfo = layer.gridLegends[item.id];
1346
+ if (!legendInfo) return null;
1347
+ return /* @__PURE__ */ jsx12(MoreLess, { children: /* @__PURE__ */ jsxs7("ul", { style: { margin: 0, padding: 0 }, children: [
1348
+ legendInfo?.stops.map(([stop, color], index, stopsArr) => {
1349
+ const prevStop = (stopsArr[index - 1] || [0])[0];
1350
+ if (prevStop === stop) return /* @__PURE__ */ jsx12("div", {}, color);
1351
+ return /* @__PURE__ */ jsxs7("li", { className: tw8`flex gap-2 items-center mb-1`, children: [
1352
+ /* @__PURE__ */ jsx12("svg", { viewBox: "0 0 24 24", height: "14", width: "14", focusable: "false", children: /* @__PURE__ */ jsx12(
1353
+ "circle",
1354
+ {
1355
+ cx: "12",
1356
+ fill: color,
1357
+ cy: "12",
1358
+ r: "12",
1359
+ stroke: "none"
1360
+ }
1361
+ ) }),
1362
+ /* @__PURE__ */ jsxs7("div", { children: [
1363
+ prevStop,
1364
+ " - ",
1365
+ stop
1366
+ ] })
1367
+ ] }, color);
1368
+ }),
1369
+ /* @__PURE__ */ jsxs7("li", { children: [
1370
+ "1 Square = ",
1371
+ legendInfo?.squareSize,
1372
+ " x ",
1373
+ legendInfo?.squareSize,
1374
+ " km"
1375
+ ] })
1376
+ ] }) });
1377
+ }
1378
+
1379
+ // src/components/sidebar/common/info-popover.tsx
1380
+ import { LICENSES, useT as useT4 } from "@biodiv-platform/naksha-commons";
1381
+ import { useState as useState4 } from "react";
1382
+ import { Popover } from "react-tiny-popover";
1383
+ import { tw as tw9 } from "twind";
1384
+ import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
1385
+ var LayerInfoLine = ({
1386
+ icon,
1387
+ name,
1388
+ title,
1389
+ link,
1390
+ children
1391
+ }) => {
1392
+ const content = /* @__PURE__ */ jsx13("span", { children: children || "-" });
1393
+ return /* @__PURE__ */ jsxs8(
1394
+ "div",
1395
+ {
1396
+ className: tw9`flex gap-3 text-sm text-gray-600 break-all`,
1397
+ title: name && title && `${name}: ${title}`,
1398
+ children: [
1399
+ /* @__PURE__ */ jsx13("div", { children: icon }),
1400
+ link ? /* @__PURE__ */ jsx13(
1401
+ "a",
1402
+ {
1403
+ className: tw9`text-blue-700 focus:outline-none focus:ring`,
1404
+ target: "_blank",
1405
+ rel: "noopener",
1406
+ href: link,
1407
+ children: content
1408
+ }
1409
+ ) : content
1410
+ ]
1411
+ }
1412
+ );
1413
+ };
1414
+ function InfoPopover({ item, containerStyle }) {
1415
+ const { t } = useT4();
1416
+ const { layer, mp } = useLayers();
1417
+ const license = item.license || "CC-BY";
1418
+ const createdOn = item?.createdDate && new Date(item.createdDate).toLocaleDateString();
1419
+ const tags = item.tags?.join(", ");
1420
+ return /* @__PURE__ */ jsxs8(
1421
+ "div",
1422
+ {
1423
+ className: tw9`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,
1424
+ style: containerStyle,
1425
+ children: [
1426
+ mp.managePublishing && item.layerStatus && /* @__PURE__ */ jsxs8(
1427
+ LayerInfoLine,
1428
+ {
1429
+ icon: /* @__PURE__ */ jsx13(EyeIcon, {}),
1430
+ name: t("visiblity"),
1431
+ title: item.layerStatus,
1432
+ children: [
1433
+ item.layerStatus,
1434
+ /* @__PURE__ */ jsx13(
1435
+ "button",
1436
+ {
1437
+ className: tw9`text-blue-600 focus:outline-none ml-4`,
1438
+ onClick: () => layer.togglePublish(item.id, item?.layerStatus),
1439
+ children: t("toggle")
1440
+ }
1441
+ ),
1442
+ /* @__PURE__ */ jsx13(
1443
+ "button",
1444
+ {
1445
+ className: tw9`text-red-600 focus:outline-none ml-4`,
1446
+ onClick: () => layer.delete(item.id, t("are_you_sure")),
1447
+ children: t("delete")
1448
+ }
1449
+ )
1450
+ ]
1451
+ }
1452
+ ),
1453
+ /* @__PURE__ */ jsx13(
1454
+ LayerInfoLine,
1455
+ {
1456
+ icon: /* @__PURE__ */ jsx13(AttributionIcon, {}),
1457
+ link: item.url,
1458
+ name: t("uploader"),
1459
+ title: item.createdBy,
1460
+ children: item.createdBy
1461
+ }
1462
+ ),
1463
+ /* @__PURE__ */ jsx13(
1464
+ LayerInfoLine,
1465
+ {
1466
+ icon: /* @__PURE__ */ jsx13(AttributionIcon, {}),
1467
+ link: item.url,
1468
+ name: t("created_by"),
1469
+ title: item.attribution,
1470
+ children: item.attribution
1471
+ }
1472
+ ),
1473
+ /* @__PURE__ */ jsx13(
1474
+ LayerInfoLine,
1475
+ {
1476
+ icon: /* @__PURE__ */ jsx13(ClockIcon, {}),
1477
+ name: t("created_on"),
1478
+ title: createdOn,
1479
+ children: createdOn
1480
+ }
1481
+ ),
1482
+ /* @__PURE__ */ jsx13(
1483
+ LayerInfoLine,
1484
+ {
1485
+ icon: /* @__PURE__ */ jsx13(TagIcon, {}),
1486
+ name: t("tags"),
1487
+ title: tags,
1488
+ children: tags
1489
+ }
1490
+ ),
1491
+ /* @__PURE__ */ jsx13(
1492
+ LayerInfoLine,
1493
+ {
1494
+ name: t("license"),
1495
+ title: license,
1496
+ link: license && LICENSES[license],
1497
+ icon: /* @__PURE__ */ jsx13(LicenseIcon, {}),
1498
+ children: license
1499
+ }
1500
+ )
1501
+ ]
1502
+ }
1503
+ );
1504
+ }
1505
+ var PopoverWrapper = ({ item }) => {
1506
+ const [isPopoverOpen, setIsPopoverOpen] = useState4(false);
1507
+ const togglePopover = () => setIsPopoverOpen(!isPopoverOpen);
1508
+ return /* @__PURE__ */ jsx13(
1509
+ Popover,
1510
+ {
1511
+ isOpen: isPopoverOpen,
1512
+ padding: 10,
1513
+ positions: ["right"],
1514
+ containerStyle: { zIndex: 99 },
1515
+ onClickOutside: togglePopover,
1516
+ content: /* @__PURE__ */ jsx13(InfoPopover, { item }),
1517
+ children: /* @__PURE__ */ jsx13(
1518
+ Button,
1519
+ {
1520
+ onClick: togglePopover,
1521
+ children: /* @__PURE__ */ jsx13(InfoIcon, {}),
1522
+ title: "Information"
1523
+ }
1524
+ )
1525
+ }
1526
+ );
1527
+ };
1528
+
1529
+ // src/components/sidebar/common/layer-item-style.tsx
1530
+ import { tw as tw11 } from "twind";
1531
+
1532
+ // src/components/sidebar/common/style-legend.tsx
1533
+ import { useMemo as useMemo2, useState as useState5 } from "react";
1534
+ import { useT as useT5 } from "@biodiv-platform/naksha-commons";
1535
+ import { tw as tw10 } from "twind";
1536
+ import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
1537
+ function StyleLegend({ item }) {
1538
+ const [showImage, setShowImage] = useState5(true);
1539
+ const { mp } = useLayers();
1540
+ const { t } = useT5();
1541
+ const legendStyles = useMemo2(
1542
+ () => item?.data?.styles?.[item.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops || item?.data?.styles?.[item.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops || [],
1543
+ [item]
1544
+ );
1545
+ const vectorLegend = () => {
1546
+ return legendStyles.map(([title, color]) => /* @__PURE__ */ jsxs9("li", { className: tw10`flex gap-2 items-center mb-1`, children: [
1547
+ /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 24 24", height: "14", width: "14", focusable: "false", children: /* @__PURE__ */ jsx14("circle", { cx: "12", fill: color, cy: "12", r: "12", stroke: "none" }) }),
1548
+ /* @__PURE__ */ jsx14("div", { children: title })
1549
+ ] }, color));
1550
+ };
1551
+ return /* @__PURE__ */ jsx14("ul", { style: { margin: 0, padding: 0 }, children: item.layerType !== "RASTER" ? vectorLegend() : showImage ? /* @__PURE__ */ jsx14("li", { children: /* @__PURE__ */ jsx14(
1552
+ "img",
1553
+ {
1554
+ style: { margin: "5px" },
1555
+ onError: () => setShowImage(false),
1556
+ src: `${mp?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${item.id}`
1557
+ }
1558
+ ) }) : /* @__PURE__ */ jsx14("div", { children: t("raster_style_not_found") }) });
1559
+ }
1560
+
1561
+ // src/components/sidebar/common/layer-item-style.tsx
1562
+ import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
1563
+ function LayerItemStyle({ item }) {
1564
+ if (!item.data?.styles) return null;
1565
+ const { layer } = useLayers();
1566
+ const onStyleChange = (e) => {
1567
+ layer.updateStyle(item.id, Number(e.target.value));
1568
+ };
1569
+ return /* @__PURE__ */ jsxs10("div", { className: tw11`flex flex-col gap-4 pt-2`, children: [
1570
+ item.layerType !== "RASTER" && /* @__PURE__ */ jsx15(SelectInput, { onChange: onStyleChange, children: item.data?.styles.map((opt, idx) => /* @__PURE__ */ jsx15("option", { value: idx, children: opt.styleTitle }, idx)) }),
1571
+ /* @__PURE__ */ jsx15(MoreLess, { children: /* @__PURE__ */ jsx15(StyleLegend, { item }) })
1572
+ ] });
1573
+ }
1574
+
1575
+ // src/components/sidebar/common/layer-item.tsx
1576
+ import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
1577
+ function DragHandle({
1578
+ dragHandleProps
1579
+ }) {
1580
+ return /* @__PURE__ */ jsx16(
1581
+ "div",
1582
+ {
1583
+ className: tw12`mt-1 w-6 text-center cursor-move`,
1584
+ style: { touchAction: "none" },
1585
+ ...dragHandleProps,
1586
+ children: /* @__PURE__ */ jsx16(GrabberIcon, {})
1587
+ }
1588
+ );
1589
+ }
1590
+ function LayerItem({
1591
+ item,
1592
+ extended,
1593
+ dragHandleProps
1594
+ }) {
1595
+ const { t } = useT6();
1596
+ const {
1597
+ layer,
1598
+ query,
1599
+ mp,
1600
+ query: { setClickedLngLat },
1601
+ setIsInfoBarOpen
1602
+ } = useLayers();
1603
+ const [isAdded, setIsAdded] = useState6(layer.selectedIds.includes(item.id));
1604
+ const [isLoading, setIsLoading] = useState6(false);
1605
+ const shareData = useMemo3(
1606
+ () => mp.canLayerShare ? {
1607
+ url: `${window.location.href.split("?")[0]}?layers=${item.id}`,
1608
+ title: item.title
1609
+ } : void 0,
1610
+ [item.id]
1611
+ );
1612
+ const onToggleLayer = async () => {
1613
+ setIsLoading(true);
1614
+ setIsInfoBarOpen(true);
1615
+ layer.setSelectedFeatures([]);
1616
+ setClickedLngLat(null);
1617
+ await layer.toggle({ layerId: item.id, add: !isAdded });
1618
+ setIsAdded(!isAdded);
1619
+ setIsLoading(false);
1620
+ };
1621
+ const onDownloadLayer = async () => {
1622
+ await axDownloadLayer(
1623
+ mp.nakshaApiEndpoint,
1624
+ mp.nakshaEndpointToken,
1625
+ item.id,
1626
+ item.title
1627
+ );
1628
+ mp?.onLayerDownload(item.id);
1629
+ };
1630
+ const handleOnZoom = () => layer.zoomToExtent(item.id);
1631
+ return /* @__PURE__ */ jsxs11(
1632
+ "div",
1633
+ {
1634
+ className: tw12`z-20 p-3 bg-white`,
1635
+ style: { borderTop: "1px solid #e5e7eb" },
1636
+ children: [
1637
+ /* @__PURE__ */ jsxs11("div", { className: tw12`flex gap-3`, children: [
1638
+ /* @__PURE__ */ jsxs11("div", { className: tw12`flex-shrink-0`, children: [
1639
+ /* @__PURE__ */ jsx16(
1640
+ CheckboxInput,
1641
+ {
1642
+ name: item.id,
1643
+ checked: isAdded,
1644
+ onChange: onToggleLayer,
1645
+ isLoading
1646
+ }
1647
+ ),
1648
+ extended && /* @__PURE__ */ jsx16(DragHandle, { dragHandleProps })
1649
+ ] }),
1650
+ /* @__PURE__ */ jsx16(
1651
+ "img",
1652
+ {
1653
+ className: tw12`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,
1654
+ src: item.thumbnail || FALLBACK_THUMB
1655
+ }
1656
+ ),
1657
+ /* @__PURE__ */ jsxs11("div", { children: [
1658
+ /* @__PURE__ */ jsx16(
1659
+ "div",
1660
+ {
1661
+ title: item.title,
1662
+ className: tw12`mb-1 leading-tight`,
1663
+ style: overflowStyle,
1664
+ children: /* @__PURE__ */ jsx16(Highlighted, { text: item.title, highlight: query.term })
1665
+ }
1666
+ ),
1667
+ /* @__PURE__ */ jsx16(
1668
+ "p",
1669
+ {
1670
+ title: item.description,
1671
+ className: tw12`text-gray-600 text-sm`,
1672
+ style: overflowStyle2,
1673
+ children: item.description
1674
+ }
1675
+ )
1676
+ ] })
1677
+ ] }),
1678
+ /* @__PURE__ */ jsxs11("div", { className: tw12`flex justify-between`, children: [
1679
+ /* @__PURE__ */ jsxs11(Button, { onClick: onDownloadLayer, disabled: !item.isDownloadable, children: [
1680
+ /* @__PURE__ */ jsx16(DownloadIcon, {}),
1681
+ " ",
1682
+ t("download")
1683
+ ] }),
1684
+ /* @__PURE__ */ jsxs11("div", { className: tw12`flex gap-3`, children: [
1685
+ shareData && /* @__PURE__ */ jsx16(RWebShare, { data: shareData, children: /* @__PURE__ */ jsx16(Button, { title: "Share", children: /* @__PURE__ */ jsx16(ShareIcon, {}) }) }),
1686
+ extended && /* @__PURE__ */ jsx16(
1687
+ Button,
1688
+ {
1689
+ onClick: handleOnZoom,
1690
+ title: "Zoom To Extent",
1691
+ children: /* @__PURE__ */ jsx16(ZoomExtentIcon, {})
1692
+ }
1693
+ ),
1694
+ /* @__PURE__ */ jsx16(PopoverWrapper, { item })
1695
+ ] })
1696
+ ] }),
1697
+ extended && /* @__PURE__ */ jsx16(LayerItemStyle, { item }),
1698
+ extended && item.source.type === "grid" && /* @__PURE__ */ jsx16(GridLegend, { item })
1699
+ ]
1700
+ }
1701
+ );
1702
+ }
1703
+
1704
+ // src/components/sidebar/layers/layer-list.tsx
1705
+ import { jsx as jsx17 } from "react/jsx-runtime";
1706
+ function LayerList() {
1707
+ const { layer, query } = useLayers();
1708
+ const filteredLayers = useMemo4(
1709
+ () => query.term ? layer.all.filter(
1710
+ (_l) => _l.title.toLowerCase().includes(query.term.toLowerCase())
1711
+ ) : layer.all,
1712
+ [layer.all, query.term]
1713
+ );
1714
+ const parentRef = React8.useRef();
1715
+ const rowVirtualizer = useVirtual({
1716
+ size: filteredLayers.length,
1717
+ parentRef
1718
+ });
1719
+ return /* @__PURE__ */ jsx17("div", { className: tw13`flex-grow-1 relative`, children: /* @__PURE__ */ jsx17(AutoSizer, { disableWidth: true, children: (p) => /* @__PURE__ */ jsx17(
1720
+ "div",
1721
+ {
1722
+ ref: parentRef,
1723
+ className: "List",
1724
+ style: { height: p.height, overflow: "auto" },
1725
+ children: /* @__PURE__ */ jsx17(
1726
+ "div",
1727
+ {
1728
+ style: {
1729
+ height: rowVirtualizer.totalSize,
1730
+ width: "100%",
1731
+ position: "relative"
1732
+ },
1733
+ children: rowVirtualizer.virtualItems.map((virtualRow) => /* @__PURE__ */ jsx17(
1734
+ "div",
1735
+ {
1736
+ ref: virtualRow.measureRef,
1737
+ className: tw13`absolute top-0 left-0 w-full`,
1738
+ style: { transform: `translateY(${virtualRow.start}px)` },
1739
+ children: /* @__PURE__ */ jsx17("div", { style: { height: 146 }, children: /* @__PURE__ */ jsx17(LayerItem, { item: filteredLayers[virtualRow.index] }) })
1740
+ },
1741
+ virtualRow.index
1742
+ ))
1743
+ }
1744
+ )
1745
+ }
1746
+ ) }) });
1747
+ }
1748
+
1749
+ // src/components/sidebar/layers/search.tsx
1750
+ import { useT as useT7 } from "@biodiv-platform/naksha-commons";
1751
+ import { tw as tw14 } from "twind";
1752
+ import { jsx as jsx18 } from "react/jsx-runtime";
1753
+ function LayerSearch() {
1754
+ const { t } = useT7();
1755
+ const { query } = useLayers();
1756
+ const handleOnSearchChange = (e) => query.setTerm(e.target.value);
1757
+ return /* @__PURE__ */ jsx18("div", { className: tw14`flex-shrink-0 border-b-2 p-4`, children: /* @__PURE__ */ jsx18(
1758
+ SearchInput,
1759
+ {
1760
+ name: "lyr_search",
1761
+ placeholder: t("find_layer_by_name"),
1762
+ onChange: handleOnSearchChange
1763
+ }
1764
+ ) });
1765
+ }
1766
+
1767
+ // src/components/sidebar/layers/index.tsx
1768
+ import { jsx as jsx19, jsxs as jsxs12 } from "react/jsx-runtime";
1769
+ function LayersTabPanel() {
1770
+ return /* @__PURE__ */ jsxs12("div", { className: tw15`flex flex-col w-full`, children: [
1771
+ /* @__PURE__ */ jsx19(LayerSearch, {}),
1772
+ /* @__PURE__ */ jsx19(LayerList, {})
1773
+ ] });
1774
+ }
1775
+
1776
+ // src/utils/array-move.ts
1777
+ function arrayMoveMutable(array, fromIndex, toIndex) {
1778
+ const startIndex = fromIndex < 0 ? array.length + fromIndex : fromIndex;
1779
+ if (startIndex >= 0 && startIndex < array.length) {
1780
+ const endIndex = toIndex < 0 ? array.length + toIndex : toIndex;
1781
+ const [item] = array.splice(fromIndex, 1);
1782
+ array.splice(endIndex, 0, item);
1783
+ }
1784
+ }
1785
+ function arrayMoveImmutable(array, fromIndex, toIndex) {
1786
+ array = [...array];
1787
+ arrayMoveMutable(array, fromIndex, toIndex);
1788
+ return array;
1789
+ }
1790
+
1791
+ // src/components/sidebar/selected/selected-item-list.tsx
1792
+ import {
1793
+ closestCenter,
1794
+ DndContext,
1795
+ PointerSensor,
1796
+ useSensor,
1797
+ useSensors
1798
+ } from "@dnd-kit/core";
1799
+ import {
1800
+ SortableContext,
1801
+ useSortable,
1802
+ verticalListSortingStrategy
1803
+ } from "@dnd-kit/sortable";
1804
+ import { CSS } from "@dnd-kit/utilities";
1805
+ import { jsx as jsx20 } from "react/jsx-runtime";
1806
+ function SortableSelectedItem({ item, extended }) {
1807
+ const {
1808
+ attributes,
1809
+ listeners,
1810
+ setNodeRef,
1811
+ transform,
1812
+ transition,
1813
+ isDragging
1814
+ } = useSortable({
1815
+ id: item.id
1816
+ });
1817
+ const style = {
1818
+ transform: CSS.Transform.toString(transform),
1819
+ transition,
1820
+ opacity: isDragging ? 0.5 : 1
1821
+ };
1822
+ return /* @__PURE__ */ jsx20("div", { ref: setNodeRef, style, children: /* @__PURE__ */ jsx20(
1823
+ LayerItem,
1824
+ {
1825
+ item,
1826
+ extended,
1827
+ dragHandleProps: { ...attributes, ...listeners }
1828
+ }
1829
+ ) });
1830
+ }
1831
+ var SelectedItemList = ({
1832
+ layerList,
1833
+ onSortEnd
1834
+ }) => {
1835
+ const sensors = useSensors(
1836
+ useSensor(PointerSensor, { activationConstraint: { distance: 4 } })
1837
+ );
1838
+ const handleDragEnd = (event) => {
1839
+ const { active, over } = event;
1840
+ if (over && active.id !== over.id) {
1841
+ const oldIndex = layerList.findIndex((item) => item.id === active.id);
1842
+ const newIndex = layerList.findIndex((item) => item.id === over.id);
1843
+ if (oldIndex !== -1 && newIndex !== -1) {
1844
+ onSortEnd({ oldIndex, newIndex });
1845
+ }
1846
+ }
1847
+ };
1848
+ return /* @__PURE__ */ jsx20(
1849
+ DndContext,
1850
+ {
1851
+ sensors,
1852
+ collisionDetection: closestCenter,
1853
+ onDragEnd: handleDragEnd,
1854
+ children: /* @__PURE__ */ jsx20(
1855
+ SortableContext,
1856
+ {
1857
+ items: layerList.map((item) => item.id),
1858
+ strategy: verticalListSortingStrategy,
1859
+ children: /* @__PURE__ */ jsx20("div", { children: layerList.map((item) => /* @__PURE__ */ jsx20(SortableSelectedItem, { item, extended: true }, item.id)) })
1860
+ }
1861
+ )
1862
+ }
1863
+ );
1864
+ };
1865
+
1866
+ // src/components/sidebar/selected/index.tsx
1867
+ import { useT as useT8 } from "@biodiv-platform/naksha-commons";
1868
+ import { tw as tw16 } from "twind";
1869
+ import { jsx as jsx21, jsxs as jsxs13 } from "react/jsx-runtime";
1870
+ function SelectedTabPanel() {
1871
+ const { layer } = useLayers();
1872
+ const { t } = useT8();
1873
+ const onSortEnd = ({ oldIndex, newIndex }) => {
1874
+ layer.setSelectedIds(
1875
+ arrayMoveImmutable(layer.selectedIds, oldIndex, newIndex)
1876
+ );
1877
+ };
1878
+ return /* @__PURE__ */ jsxs13("div", { className: tw16`flex flex-col gap-3 w-full`, children: [
1879
+ layer.selectedIds.length > 0 && /* @__PURE__ */ jsx21("div", { className: tw16`p-3 pb-0`, children: /* @__PURE__ */ jsxs13(Button, { onClick: () => layer.clearAll(), children: [
1880
+ "\u2715 ",
1881
+ t("clear")
1882
+ ] }) }),
1883
+ /* @__PURE__ */ jsx21(
1884
+ SelectedItemList,
1885
+ {
1886
+ layerList: layer.selectedLayers,
1887
+ useDragHandle: true,
1888
+ onSortEnd
1889
+ }
1890
+ )
1891
+ ] });
1892
+ }
1893
+
1894
+ // src/components/sidebar/settings/index.tsx
1895
+ import { useT as useT9 } from "@biodiv-platform/naksha-commons";
1896
+ import { tw as tw17 } from "twind";
1897
+ import { jsx as jsx22, jsxs as jsxs14 } from "react/jsx-runtime";
1898
+ function SettingsTabPanel() {
1899
+ const { layer } = useLayers();
1900
+ const { t } = useT9();
1901
+ const handleOnStyleChange = (e) => {
1902
+ layer.setMapStyle(e.target.value);
1903
+ layer.setMaxZoom(
1904
+ layer.mapStyles.find((ms) => ms.style === e.target.value)?.maxZoom
1905
+ );
1906
+ };
1907
+ return /* @__PURE__ */ jsxs14("div", { className: tw17`w-full p-4 flex flex-col gap-4`, children: [
1908
+ /* @__PURE__ */ jsx22(
1909
+ SelectInput,
1910
+ {
1911
+ name: "base_style",
1912
+ label: t("base_style"),
1913
+ defaultValue: layer.mapStyle,
1914
+ onChange: handleOnStyleChange,
1915
+ children: layer.mapStyles.map((ms) => /* @__PURE__ */ jsx22("option", { value: ms.style, children: ms.text }, ms.key))
1916
+ }
1917
+ ),
1918
+ /* @__PURE__ */ jsx22(LayerSelection, {})
1919
+ ] });
1920
+ }
1921
+
1922
+ // src/components/sidebar/tabs.tsx
1923
+ import { jsx as jsx23, jsxs as jsxs15 } from "react/jsx-runtime";
1924
+ function SidebarTabs({ onClose }) {
1925
+ const { t } = useT10();
1926
+ return /* @__PURE__ */ jsxs15(
1927
+ "div",
1928
+ {
1929
+ className: tw18`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,
1930
+ children: [
1931
+ /* @__PURE__ */ jsx23(CloseButton, { onClick: onClose }),
1932
+ /* @__PURE__ */ jsx23("div", { className: tw18`flex flex-col h-full`, children: /* @__PURE__ */ jsxs15(Tabs, { children: [
1933
+ /* @__PURE__ */ jsxs15(TabHeader, { children: [
1934
+ /* @__PURE__ */ jsx23(IconTab, { icon: /* @__PURE__ */ jsx23(LayersIcon, {}), children: t("layers") }),
1935
+ /* @__PURE__ */ jsx23(IconTab, { icon: /* @__PURE__ */ jsx23(LayersIcon, {}), children: t("selected") }),
1936
+ /* @__PURE__ */ jsx23(IconTab, { icon: /* @__PURE__ */ jsx23(SlidersIcon, {}), children: t("settings") })
1937
+ ] }),
1938
+ /* @__PURE__ */ jsx23(Panel, { children: /* @__PURE__ */ jsx23(LayersTabPanel, {}) }),
1939
+ /* @__PURE__ */ jsx23(Panel, { children: /* @__PURE__ */ jsx23(SelectedTabPanel, {}) }),
1940
+ /* @__PURE__ */ jsx23(Panel, { children: /* @__PURE__ */ jsx23(SettingsTabPanel, {}) })
1941
+ ] }) })
1942
+ ]
1943
+ }
1944
+ );
1945
+ }
1946
+
1947
+ // src/components/sidebar/index.tsx
1948
+ import { jsx as jsx24 } from "react/jsx-runtime";
1949
+ function Sidebar() {
1950
+ const { mp, layer } = useLayers();
1951
+ const [isOpen, setIsOpen] = useState8(mp.showToC);
1952
+ const { mapl } = useMap2();
1953
+ const toggleOpen = () => setIsOpen(!isOpen);
1954
+ async function loadToC() {
1955
+ const _layers = await axGetGeoserverLayers(
1956
+ mp.nakshaEndpointToken,
1957
+ mp.nakshaApiEndpoint,
1958
+ mp.geoserver,
1959
+ mp.selectedLayers
1960
+ );
1961
+ const _newLayers = [...mp.layers || [], ..._layers];
1962
+ layer.setAll(_newLayers);
1963
+ if (layer.selectedIds.length) {
1964
+ const _layer = _newLayers.find((l) => l.id === layer.selectedIds[0]);
1965
+ _layer?.bbox && mapl?.fitBounds(_layer.bbox, { padding: 40, duration: 1e3 });
1966
+ }
1967
+ }
1968
+ useEffect3(() => {
1969
+ if (mapl && mp.loadToC) {
1970
+ loadToC();
1971
+ }
1972
+ }, [mapl]);
1973
+ return isOpen ? /* @__PURE__ */ jsx24(SidebarTabs, { onClose: toggleOpen }) : /* @__PURE__ */ jsx24(LayersButton, { onClick: toggleOpen });
1974
+ }
1975
+
1976
+ // src/components/map/layers/index.tsx
1977
+ import { useMap as useMap4 } from "react-map-gl/maplibre";
1978
+
1979
+ // src/components/map/layers/grid/index.tsx
1980
+ import bbox from "@turf/bbox";
1981
+ import { useEffect as useEffect4, useState as useState9 } from "react";
1982
+ import { Layer, Source, useMap as useMap3 } from "react-map-gl/maplibre";
1983
+ import { jsx as jsx25 } from "react/jsx-runtime";
1984
+ function GridLayer({
1985
+ data,
1986
+ beforeId
1987
+ }) {
1988
+ const { layer } = useLayers();
1989
+ const { mapl } = useMap3();
1990
+ const [layerData, setLayerData] = useState9({ geojson: {}, paint: {} });
1991
+ const isSelected = layer.selectedIds.includes(data.id);
1992
+ const isLastSelected = layer.selectedIds[0] === data.id;
1993
+ const fetchGridData = async (shouldFitBounds = false) => {
1994
+ const { success, geojson, paint: paint2, stops, squareSize } = await getGridLayerData(
1995
+ data.source.fetcher,
1996
+ mapl?.getBounds(),
1997
+ mapl?.getZoom()
1998
+ );
1999
+ if (success) {
2000
+ setLayerData({ geojson, paint: paint2 });
2001
+ if (shouldFitBounds && isLastSelected && data.zoomToFit) {
2002
+ try {
2003
+ const [minLon, minLat, maxLon, maxLat] = bbox(geojson);
2004
+ mapl?.fitBounds(
2005
+ [
2006
+ [minLon, minLat],
2007
+ [maxLon, maxLat]
2008
+ ],
2009
+ { padding: 40, animate: true }
2010
+ );
2011
+ } catch (e) {
2012
+ console.warn("Failed to compute bbox", e);
2013
+ }
2014
+ }
2015
+ layer.setGridLegends({
2016
+ [data.id]: { stops, squareSize }
2017
+ });
2018
+ }
2019
+ };
2020
+ useEffect4(() => {
2021
+ if (isSelected && isLastSelected) {
2022
+ fetchGridData(true);
2023
+ } else if (isSelected) {
2024
+ fetchGridData(false);
2025
+ }
2026
+ }, [isSelected, isLastSelected]);
2027
+ useEffect4(() => {
2028
+ if (!isSelected || !mapl) return;
2029
+ const handleIdle = () => fetchGridData(false);
2030
+ mapl.on("idle", handleIdle);
2031
+ return () => {
2032
+ mapl.off("idle", handleIdle);
2033
+ };
2034
+ }, [isSelected, mapl]);
2035
+ useEffect4(() => {
2036
+ return () => {
2037
+ layer.setGridLegends((prev) => {
2038
+ const newLegends = { ...prev };
2039
+ delete newLegends[data.id];
2040
+ return newLegends;
2041
+ });
2042
+ };
2043
+ }, [data.id]);
2044
+ return /* @__PURE__ */ jsx25(Source, { id: data.id, type: "geojson", data: layerData.geojson, children: /* @__PURE__ */ jsx25(
2045
+ Layer,
2046
+ {
2047
+ beforeId,
2048
+ id: data.id,
2049
+ type: "fill",
2050
+ paint: layerData.paint
2051
+ }
2052
+ ) });
2053
+ }
2054
+
2055
+ // src/components/map/layers/vector/index.tsx
2056
+ import { useMemo as useMemo5 } from "react";
2057
+ import { Layer as Layer2, Source as Source2 } from "react-map-gl/maplibre";
2058
+ import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
2059
+ var paint = {
2060
+ fill: {
2061
+ "line-color": "red",
2062
+ "line-width": 2
2063
+ },
2064
+ circle: {
2065
+ "circle-stroke-color": "red",
2066
+ "circle-stroke-width": 2,
2067
+ "circle-opacity": 0
2068
+ }
2069
+ };
2070
+ function VectorLayer({ layer: data, beforeId }) {
2071
+ const { layer } = useLayers();
2072
+ const layerProps = useMemo5(
2073
+ () => data.data?.styles?.[data.data?.styleIndex]?.colors,
2074
+ [data, layer.selectedFeatures]
2075
+ );
2076
+ const highlightData = layer.selectedFeaturesId?.[data.id];
2077
+ return /* @__PURE__ */ jsxs16(Source2, { ...data.source, children: [
2078
+ layerProps && /* @__PURE__ */ jsx26(Layer2, { beforeId, ...layerProps }),
2079
+ highlightData && layerProps && /* @__PURE__ */ jsx26(
2080
+ Layer2,
2081
+ {
2082
+ ...layerProps,
2083
+ beforeId,
2084
+ id: `hl_${data.id}`,
2085
+ filter: ["in", PROPERTY_ID, ...highlightData],
2086
+ type: layerProps.type === "fill" ? "line" : layerProps.type,
2087
+ paint: paint[layerProps.type]
2088
+ }
2089
+ )
2090
+ ] });
2091
+ }
2092
+
2093
+ // src/components/map/layers/raster/index.tsx
2094
+ import { Layer as Layer3, Source as Source3 } from "react-map-gl/maplibre";
2095
+ import { jsx as jsx27 } from "react/jsx-runtime";
2096
+ function RasterLayer({
2097
+ data,
2098
+ beforeId
2099
+ }) {
2100
+ const { mp } = useLayers();
2101
+ return /* @__PURE__ */ jsx27(
2102
+ Source3,
2103
+ {
2104
+ id: data.id,
2105
+ type: "raster",
2106
+ tiles: [
2107
+ `${mp?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${data.id}`
2108
+ ],
2109
+ tileSize: 256,
2110
+ children: /* @__PURE__ */ jsx27(
2111
+ Layer3,
2112
+ {
2113
+ id: data.id,
2114
+ beforeId,
2115
+ type: "raster",
2116
+ source: "biodiv",
2117
+ layout: { visibility: "visible" },
2118
+ paint: {}
2119
+ }
2120
+ )
2121
+ }
2122
+ );
2123
+ }
2124
+
2125
+ // src/components/map/layers/index.tsx
2126
+ import { jsx as jsx28 } from "react/jsx-runtime";
2127
+ function MapLayer({
2128
+ layer,
2129
+ beforeId
2130
+ }) {
2131
+ const { mapl } = useMap4();
2132
+ if (!mapl) {
2133
+ return null;
2134
+ }
2135
+ switch (layer.source.type) {
2136
+ case "vector":
2137
+ return /* @__PURE__ */ jsx28(VectorLayer, { beforeId, layer });
2138
+ case "grid":
2139
+ return /* @__PURE__ */ jsx28(GridLayer, { beforeId, data: layer });
2140
+ case "raster":
2141
+ return /* @__PURE__ */ jsx28(RasterLayer, { beforeId, data: layer });
2142
+ default:
2143
+ return /* @__PURE__ */ jsx28(VectorLayer, { beforeId, layer });
2144
+ }
2145
+ }
2146
+
2147
+ // src/components/map/markers-list/index.tsx
2148
+ import { useMemo as useMemo6 } from "react";
2149
+ import { Marker } from "react-map-gl/maplibre";
2150
+ import { Fragment as Fragment2, jsx as jsx29 } from "react/jsx-runtime";
2151
+ var Marker1 = Marker;
2152
+ var MarkersList = () => {
2153
+ const { mp } = useLayers();
2154
+ const markersMemoized = useMemo6(() => mp.markers, [mp.markers]);
2155
+ return /* @__PURE__ */ jsx29(Fragment2, { children: markersMemoized?.map(
2156
+ ({ latitude, longitude, colorHex, anchor = "bottom", iconUrl }, index) => /* @__PURE__ */ jsx29(
2157
+ Marker1,
2158
+ {
2159
+ latitude,
2160
+ longitude,
2161
+ anchor,
2162
+ subpixelPositioning: true,
2163
+ children: /* @__PURE__ */ jsx29(
2164
+ "img",
2165
+ {
2166
+ style: {
2167
+ cursor: "pointer",
2168
+ display: "block",
2169
+ width: "25px",
2170
+ height: "41px"
2171
+ },
2172
+ width: 25,
2173
+ height: 41,
2174
+ alt: "Marker",
2175
+ src: iconUrl || "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"
2176
+ }
2177
+ )
2178
+ },
2179
+ index
2180
+ )
2181
+ ) });
2182
+ };
2183
+ var markers_list_default = MarkersList;
2184
+
2185
+ // src/components/map/popup/index.tsx
2186
+ import clsx3 from "clsx";
2187
+ import { Popup } from "react-map-gl/maplibre";
2188
+ import { tw as tw19 } from "twind";
2189
+ import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
2190
+ var Pop = Popup;
2191
+ function HoverPopup({ coordinates }) {
2192
+ const { hover } = useLayers();
2193
+ return coordinates?.lat && hover.features ? /* @__PURE__ */ jsx30(
2194
+ Pop,
2195
+ {
2196
+ latitude: coordinates.lat,
2197
+ longitude: coordinates.lng,
2198
+ closeButton: false,
2199
+ children: /* @__PURE__ */ jsxs17("table", { className: tw19`table-auto border`, children: [
2200
+ /* @__PURE__ */ jsx30("thead", { children: /* @__PURE__ */ jsx30("tr", { children: /* @__PURE__ */ jsx30("th", { className: tw19`bg-gray-200 py-1 px-2`, colSpan: 2, children: hover.features.title }) }) }),
2201
+ /* @__PURE__ */ jsx30("tbody", { children: hover.features.data.map(([k, v], idx) => /* @__PURE__ */ jsxs17(
2202
+ "tr",
2203
+ {
2204
+ className: tw19(
2205
+ clsx3({
2206
+ "bg-gray-50": idx % 2 === 0,
2207
+ "border-gray-100 border-t": 1
2208
+ })
2209
+ ),
2210
+ children: [
2211
+ /* @__PURE__ */ jsx30("td", { className: tw19`py-1 px-2`, children: k }),
2212
+ /* @__PURE__ */ jsx30("td", { className: tw19`py-1 px-2 border-l border-gray-100`, children: v })
2213
+ ]
2214
+ },
2215
+ k + v
2216
+ )) })
2217
+ ] })
2218
+ }
2219
+ ) : null;
2220
+ }
2221
+
2222
+ // src/components/map/index.tsx
2223
+ import { jsx as jsx31, jsxs as jsxs18 } from "react/jsx-runtime";
2224
+ var NavControl = NavigationControl;
2225
+ function Map2() {
2226
+ const { mp, layer, hover, query } = useLayers();
2227
+ const [coordinates, setCoordinates] = useState10();
2228
+ const viewState = useMemo7(
2229
+ () => mp.defaultViewState || defaultViewState2,
2230
+ [mp.defaultViewState]
2231
+ );
2232
+ const onMapClick = (e) => query.setClickedLngLat(e.lngLat);
2233
+ const handleOnMouseMove = (event) => {
2234
+ setCoordinates(event.lngLat);
2235
+ hover.onHover(event);
2236
+ };
2237
+ return /* @__PURE__ */ jsxs18("div", { className: tw20`h-full w-full relative bg-gray-100`, children: [
2238
+ mp.loadToC && /* @__PURE__ */ jsx31(Sidebar, {}),
2239
+ layer.selectedFeatures?.length > 0 && /* @__PURE__ */ jsx31(InfoBar, {}),
2240
+ /* @__PURE__ */ jsxs18(
2241
+ MapGL,
2242
+ {
2243
+ id: "mapl",
2244
+ cursor: "default",
2245
+ initialViewState: viewState,
2246
+ style: { width: "100%", height: "100%" },
2247
+ mapStyle: layer.mapStyle,
2248
+ maxZoom: layer.maxZoom,
2249
+ onClick: onMapClick,
2250
+ onMouseMove: handleOnMouseMove,
2251
+ children: [
2252
+ /* @__PURE__ */ jsx31(
2253
+ NavControl,
2254
+ {
2255
+ position: "bottom-right",
2256
+ showZoom: true,
2257
+ showCompass: true
2258
+ }
2259
+ ),
2260
+ mp.showFullscreenControl && /* @__PURE__ */ jsx31(FullscreenControl, { position: "bottom-right" }),
2261
+ /* @__PURE__ */ jsx31(markers_list_default, {}),
2262
+ layer.selectedLayers.map((_l, index) => {
2263
+ const beforeId = index > 0 ? layer.selectedIds[index - 1] : void 0;
2264
+ return /* @__PURE__ */ jsx31(MapLayer, { layer: _l, beforeId }, _l.id);
2265
+ }),
2266
+ /* @__PURE__ */ jsx31(HoverPopup, { coordinates }, "popup")
2267
+ ]
2268
+ }
2269
+ )
2270
+ ] });
2271
+ }
2272
+
2273
+ // src/index.tsx
2274
+ import { jsx as jsx32 } from "react/jsx-runtime";
2275
+ setup({ preflight: false });
2276
+ var NakshaMaplibreLayers = (props) => {
2277
+ const mp = React14.useMemo(
2278
+ () => ({ ...defaultNakshaProps, ...props }),
2279
+ [props]
2280
+ );
2281
+ return /* @__PURE__ */ jsx32(MapProvider, { children: /* @__PURE__ */ jsx32(TranslationProvider, { localeStrings: locales_default, lang: mp.lang, children: /* @__PURE__ */ jsx32(LayersProvider, { mp, children: /* @__PURE__ */ jsx32(Map2, {}) }) }) });
2282
+ };
2283
+ export {
2284
+ NakshaMaplibreLayers
2285
+ };