@biodiv-platform/naksha-maplibre-layers 5.0.9 → 5.0.10
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.cjs +1 -2301
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -2285
- package/locales/en.json +1 -0
- package/locales/fr.json +1 -0
- package/locales/hi.json +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,2285 +1 @@
|
|
|
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
|
-
};
|
|
1
|
+
import{TranslationProvider as oa}from"@biodiv-platform/naksha-commons";import na from"react";import{MapProvider as aa}from"react-map-gl/maplibre";import{setup as sa}from"twind";var At={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",published:"Published",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 Bt={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",published:"Publi\xE9",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Ot={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",published:"\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 Gt={en:At,fr:Bt,hi:Ot};import{defaultViewState as Yn}from"@biodiv-platform/naksha-commons";import ht,{useEffect as eo,useMemo as Kn,useState as jn}from"react";import Jn,{FullscreenControl as Xn,NavigationControl as Qn}from"react-map-gl/maplibre";import{config as ea}from"maplibre-gl";import{tw as ta}from"twind";import{defaultMapStyles as mo,useDebounce as fo}from"@biodiv-platform/naksha-commons";import yo,{createContext as go,useCallback as C,useContext as ho,useEffect as ke,useMemo as de,useRef as bo,useState as T}from"react";import{useMap as Lo}from"react-map-gl/maplibre";import uo from"colorbrewer";import H from"redaxios";import Ft from"boundingbox";import{GeoHash as Ue}from"geohash";import{MapStyles as so,defaultViewState as io}from"@biodiv-platform/naksha-commons";var Dt={defaultViewState:io,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:so.MAP_STREETS,layers:[],selectedLayers:[]},zt="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",qe={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},Ht={...qe,WebkitLineClamp:2},E="ogc_fid",J={ACTIVE:"Active",PENDING:"Pending"},N={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Se=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],Ve="0123456789bcdefghjkmnpqrstuvwxyz",lo=(e,r,t)=>{t=t||16/2**(1-e.length&1)/4**r;let n=e.slice(0,-1),o=~~(Ve.indexOf(e.slice(-1))/t);return[n+Ve[t*o],n+Ve[t*(o+1)-1]]},co=function(e,r){var t=new Map,n=new Map;let o=[];for(let[a,s]of Object.entries(e)){let[l,c]=lo(a,r);n.set(l,c),t.has(l)||t.set(l,0),t.set(l,t.get(l)+s)}return t.forEach((a,s)=>{let l=Ue.decodeGeoHash(s),c=Ue.decodeGeoHash(n.get(s)),u=new Ft({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:c.latitude[1],maxlon:c.longitude[1]}).toGeoJSON();o.push({...u,properties:{count:a,[E]:s}})}),o},po=e=>{let r=[];for(let[t,n]of Object.entries(e)){let o=Ue.decodeGeoHash(t),a=new Ft({minlat:o.latitude[0],minlon:o.longitude[0],maxlat:o.latitude[1],maxlon:o.longitude[1]}).toGeoJSON();r.push({...a,properties:{count:n,[E]:t}})}return r},$t=(e,r)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:r===-1?po(e):co(e,r)}),Wt=(e,r)=>{let t=Object.values(e).sort((a,s)=>a-s),n=Math.floor(t.length/r),o=new Array(r-1).fill(0).map((a,s)=>t[n*(s+1)]);return o.push(t[t.length-1]),o};var qt=async(e,r,t,n)=>Promise.all((e||[]).map(async o=>{let a=n?.includes(o.name),s=o.layerType?.toLowerCase()==="raster",l={...o,id:o.name,thumbnail:r+o.thumbnail,source:{type:s?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${o.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:a};if(a&&!s){let c=await Ze(l,0,r,t);return{...l,data:c}}return l})),Ze=async(e,r,t,n)=>{let o=e.data||{styles:[]},a=o.layerName,s=o.styles?[...o.styles]:[],l=o.summaryColumn,c=o.titleColumn,u=o.propertyMap;if(s.length===0){let{success:m,data:f}=await Vt(e.id,t);m&&f&&(a=f.layerName,s=(f.styles||[]).map(v=>({...v})),l=f.summaryColumn,c=f.titleColumn,u=Object.fromEntries((f.styles||[]).map(v=>[v.styleName,v.styleTitle])))}if(s[r]&&!s[r]?.colors){let m=await Ut(e.id,n?.workspace,s[r].styleName,t);s[r]={...s[r],colors:m}}return{...o,layerName:a,styles:s,summaryColumn:l,titleColumn:c,propertyMap:u,styleIndex:r}};var Zt=async(e,r,t,n)=>{try{let o=await H.get(`${r}/layer/all`,{headers:{Authorization:e}});return await qt(o.data,r,t,n)}catch(o){return console.error(o),[]}},Vt=async(e,r)=>{try{let{data:t}=await H.get(`${r}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}},Yt=async(e,r,t)=>{let n={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 H.get(`${e}/${r}/wms`,{params:{...t,...n}})).data}}catch(o){return console.error(o),{success:!1,data:[]}}},Kt=async(e,r,t,n)=>{try{return await H.put(`${r}/layer/${n?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}},jt=async(e,r,t)=>{try{return await H.delete(`${r}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Ut=async(e,r,t,n)=>{try{return(await H.get(`${n}/geoserver/workspaces/${r}/styles/${e}_${t}.mbstyle`)).data?.layers?.[0]}catch(o){return console.error(o),{}}},Jt=async(e,r,t,n=6,o="YlOrRd")=>{try{let[a,s,l]=Se(t),{_ne:c,_sw:u}=r,m={top:c.lat,left:u.lng,bottom:u.lat,right:c.lng,geoAggegationPrecision:a},f=await e(m),v=$t(f,s),R=Wt(f,n).map((O,Z)=>[O,uo[o][n][Z]]);return{success:!0,geojson:v,paint:{"fill-color":{property:"count",default:"yellow",stops:R},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:R,squareSize:l}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},Xt=async(e,r,t,n)=>{try{await H.post(`${e}/layer/download`,{layerName:t,layerTitle:n,attributeList:[],filterArray:[]},{headers:{Authorization:r}})}catch(o){console.error(o)}};import{jsx as vo}from"react/jsx-runtime";var Qt=go({}),er=({mp:e,children:r})=>{let[t,n]=T(e),{mapl:o}=Lo();ke(()=>{n(d=>({...d,...e}))},[e]);let[a,s]=T(""),l=fo(a,500),c=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:mo,[u,m]=T(c[t?.mapStyle||0]?.style),[f,v]=T(c[t?.mapStyle||0]?.maxZoom),[S,R]=T(N.TOP),[B,O]=T({}),[Z,he]=T(!0),[k,$e]=T(),[w,M]=T(e.layers||[]),[L,G]=T(t.selectedLayers||[]);ke(()=>{t.selectedLayers&&t.selectedLayers.join(",")!==L.join(",")&&G(t.selectedLayers)},[t.selectedLayers]);let[Y,be]=T(),[Le,Lt]=T(),vt=de(()=>{let d={};for(let y of Le||[])d[y.sourceLayer]=[...d[y.sourceLayer]||[],y?.properties?.[E]];return Object.keys(d).length?d:void 0},[Le]),se=yo.useMemo(()=>{let d=w.filter(g=>L.includes(g.id)),y=new Array(L.length);for(let g of d){let h=L.findIndex(I=>g.id===I);h>-1&&(y[h]=g)}return y},[w,L]),K=C(d=>w.findIndex(y=>y.id===d),[w]),ve=C((d,y)=>{M(g=>g.map(h=>h.id===d?{...h,...y}:h))},[]),xe=C(async(d,y,g)=>{let h=w[d];if(!h)return;let I=await Ze(h,y,t.nakshaApiEndpoint,t.geoserver);ve(h.id,{data:I}),g&&o?.fitBounds(h.bbox,{padding:40,duration:1e3})},[w,t.nakshaApiEndpoint,t.geoserver,ve,o]),xt=C(async(d,y)=>{let g=K(d);xe(g,y,!1)},[K,xe]),wt=C(async d=>{if(!(!L.length||!o))try{let y=L[0],g=o.queryRenderedFeatures(d.point,{layers:[y]});if(g.length){let h=g[0]?.id||g[0]?.properties?.[E];if(h===Y?.id)return;let I=w[K(y)];if(!I)return;let ie=I?.data?.summaryColumn?.map(we=>[I.data?.propertyMap?.[we]||we,g[0].properties?.[we]]);be({id:h,title:I.title,data:ie||[],coordinates:d.lngLat})}else be(h=>h!==void 0?void 0:h)}catch{}},[L,o,Y?.id,w,K]),St=C(async({layerId:d,add:y,styleIndex:g=0,focus:h=!0})=>{if(!y){G(le=>le.filter(ce=>d!==ce));return}let I=K(d),ie=w[I];ie?.source.type==="grid"?(G(le=>[d,...le.filter(ce=>ce!==d)]),h&&ie?.bbox&&setTimeout(()=>{o?.fitBounds(ie.bbox,{padding:40,duration:1e3})},100)):(await xe(I,g,h),G(le=>[d,...le.filter(ce=>ce!==d)]))},[K,w,o,xe]),kt=C(async()=>G([]),[]),It=C((d,y)=>{n(g=>({...g,[d]:y}))},[]),Ct=C((d,y)=>{let g=y===J.PENDING;Kt(t.nakshaEndpointToken,t.nakshaApiEndpoint,d,g),ve(d,{layerStatus:g?J.ACTIVE:J.PENDING})},[t.nakshaEndpointToken,t.nakshaApiEndpoint,ve]),Pt=C(async(d,y)=>{confirm(y)&&(jt(t.nakshaEndpointToken,t.nakshaApiEndpoint,d),M(g=>g.filter(h=>h.id!==d)))},[t.nakshaEndpointToken,t.nakshaApiEndpoint]),Tt=C(d=>{let y=w.find(g=>g.id===d);y?.bbox&&o?.fitBounds(y.bbox,{padding:40,duration:1e3})},[w,o]),We=C(()=>k?[k.lng,k.lat,k.lng+.1,k.lat+.1]:[0,0,0,0],[k]),j=C(d=>{if(!(!k||!o))try{let y=o.project([k.lng,k.lat]),g=o.queryRenderedFeatures(y,{layers:S===N.TOP?[L[0]]:L});if((d||S)===N.ALL){let h=se.filter(I=>I.layerType=="RASTER").map(I=>({sourceLayer:I.id,layerType:"raster",bbox:We()}));g=[...g,...h]}Lt(se?.[0]?.layerType==="RASTER"&&S!==N.ALL?L.length&&g?.length?g:[{sourceLayer:L[0],layerType:"raster",bbox:We()}]:g)}catch(y){console.error(y)}},[k,o,S,L,se,We]),Rt=C(d=>{R(d),d===N.TOP&&j(d)},[j]),Mt=bo(!0);ke(()=>{if(Mt.current){Mt.current=!1;return}t.onSelectedLayersChange&&t.onSelectedLayersChange(L)},[L]),ke(()=>{let d=setTimeout(j,300);return()=>clearTimeout(d)},[k,S,L,j]);let Et=de(()=>({mapStyle:u,featuresAtLatLng:j,setMapStyle:m,maxZoom:f,setMaxZoom:v,mapStyles:c,all:w,setAll:M,selectedIds:L,handleSelectStyle:Rt,setSelectedIds:G,selectedLayers:se,clearAll:kt,toggle:St,updateStyle:xt,selectedFeatures:Le,selectedFeaturesId:vt,setSelectedFeatures:Lt,togglePublish:Ct,delete:Pt,selectionStyle:S,setSelectionStyle:R,zoomToExtent:Tt,gridLegends:B,setGridLegends:O}),[u,j,f,c,w,L,Rt,se,kt,St,xt,Le,vt,Ct,Pt,S,Tt,B]),Nt=de(()=>({term:l,setTerm:s,clickedLngLat:k,setClickedLngLat:$e}),[l,k]),_t=de(()=>({onHover:wt,features:Y}),[wt,Y]),ro=de(()=>({mp:t,updateMP:It,layer:Et,query:Nt,isInfoBarOpen:Z,setIsInfoBarOpen:he,hover:_t}),[t,It,Et,Nt,Z,_t]);return vo(Qt.Provider,{value:ro,children:r})};function p(){return ho(Qt)}import wo from"react";import{tw as Ce}from"twind";import{tw as xo}from"twind";import{jsx as i,jsxs as X}from"react/jsx-runtime";var tr=()=>i("svg",{fill:"none",className:xo`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"})}),pe=()=>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"})]}),Ie=()=>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"})]}),rr=()=>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 Ye(){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 or(){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 nr(){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 ar(){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 sr(){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 ir(){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 lr(){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 cr(){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 dr(){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 pr(){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 ur(){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 mr(){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"})})}function fr(){return X("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[i("polyline",{points:"3 6 5 6 21 6"}),i("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),i("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),i("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}import{jsx as Q}from"react/jsx-runtime";var D=wo.forwardRef((e,r)=>Q("button",{ref:r,type:"button",className:Ce`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 Pe=e=>Q("button",{className:Ce`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}),yr=e=>Q("button",{className:Ce`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:Q(pe,{})}),gr=e=>Q("button",{className:Ce`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:Q(Ie,{})});import{tw as ee}from"twind";import{jsx as _,jsxs as Lr}from"react/jsx-runtime";var te=e=>Lr("div",{children:[e.label&&_("label",{className:ee`text-gray-700`,htmlFor:e.name,children:e.label}),_("select",{id:e.name,name:e.name,className:ee`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})]}),hr=e=>Lr("div",{className:"relative",children:[_("span",{className:ee`absolute inset-y-0 left-0 flex items-center pl-3`,children:_(tr,{})}),_("input",{type:"search",className:ee`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})]}),br=e=>e.isLoading?_("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:ee`inline text-gray-200 animate-spin dark:text-gray-600`,children:_("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:_("g",{fill:"#212121",fillRule:"nonzero",children:_("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"})})})}):_("input",{type:"checkbox",className:ee`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 vr,usePanelState as So,useTabState as ko}from"@bumaga/tabs";import Io from"clsx";import{tw as Te}from"twind";import{jsx as Ke,jsxs as Co}from"react/jsx-runtime";var Re=({children:e,icon:r})=>{let{onClick:t,isActive:n}=ko(),o=Io(["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":n,"text-gray-700 border-gray-300 hover:border-gray-400":!n}]);return Co("button",{className:Te(o),onClick:t,children:[r,Ke("span",{className:Te`ml-2 text-base`,children:e})]})},Me=({children:e})=>So()?Ke("div",{className:Te`w-full flex flex-grow-1 overflow-auto`,children:e}):null,xr=({children:e})=>Ke("div",{className:Te`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{tw as re}from"twind";import{jsx as Ee,jsxs as wr}from"react/jsx-runtime";var Sr=({checked:e=!1,onChange:r,disabled:t=!1,label:n,title:o,id:a})=>wr("label",{htmlFor:a,title:o,className:re`inline-flex items-center gap-2 cursor-pointer select-none ${t?"opacity-50 cursor-not-allowed":""}`,children:[n&&Ee("span",{className:re`text-sm text-gray-600 font-normal`,children:n}),wr("span",{className:re`relative inline-flex items-center`,children:[Ee("input",{id:a,type:"checkbox",role:"switch","aria-checked":e,checked:e,disabled:t,onChange:s=>r?.(s.target.checked),className:re`sr-only`}),Ee("div",{className:re`w-8 h-4 rounded-full transition-colors duration-200 ease-in-out ${e?"bg-blue-600":"bg-gray-300"}`}),Ee("div",{className:re`absolute left-0.5 top-0.5 bg-white w-3 h-3 rounded-full shadow-sm transition-transform duration-200 ease-in-out ${e?"transform translate-x-4":""}`})]})]});import{useT as Mo}from"@biodiv-platform/naksha-commons";import{tw as _e}from"twind";import{useT as Po}from"@biodiv-platform/naksha-commons";import{jsx as kr}from"react/jsx-runtime";function ue({hideLabel:e}){let{layer:{selectionStyle:r,handleSelectStyle:t}}=p(),{t:n}=Po(),o=a=>{t(a.target.value)};return kr(te,{name:"layer_selection",label:e?null:n("layer_selection"),defaultValue:r,onChange:o,children:Object.values(N).map(a=>kr("option",{value:a,children:n(a)},a))})}import To from"clsx";import{useEffect as Ro,useState as Ir}from"react";import{tw as Ne}from"twind";import{jsx as me,jsxs as je}from"react/jsx-runtime";function Je({data:e}){let[r,t]=Ir(!0),[n,o]=Ir({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=p(),c=async()=>{let u,m=a.selectedLayers.find(f=>f.id===(e.sourceLayer||e.source));if(m.layerType.toLowerCase()==="raster"){let{data:f}=await Yt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${m.id}`,layers:`${s.geoserver?.workspace}:${m.id}`});u=f?.features[0]?Object.entries(f.features[0]?.properties).map(([v,S])=>[S||"-"]):[]}else u=Object.entries(m?.data?.propertyMap||{}).map(([f,v])=>[v,e?.properties?.[f]||"-"]);o({title:m.title,properties:u})};return Ro(()=>{c()},[l]),je("div",{className:Ne`bg-gray-100 rounded-lg`,children:[je("button",{className:Ne(To(["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":r,"rounded-lg":!r}])),onClick:()=>t(!r),children:[n.title," ",r?me(mr,{}):me(ur,{})]}),r&&me("div",{className:Ne`px-4 py-3 flex flex-col gap-3`,children:n.properties.map(([u,m],f)=>je("div",{children:[me("div",{className:Ne`text-gray-600`,children:u}),me("div",{children:m})]},u+m+f))})]})}import{jsx as oe,jsxs as Xe}from"react/jsx-runtime";function Qe({onClose:e}){let{layer:{selectedFeatures:r,selectedLayers:t,selectionStyle:n}}=p(),{t:o}=Mo();return Xe("div",{className:_e`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:[Xe("div",{className:"flex w-full",children:[Xe("div",{className:_e`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[oe(pr,{})," ",o("infobar")]}),oe(Pe,{onClick:e})]}),oe("div",{className:_e`bg-gray-100 p-4 flex-shrink-0 rt`,children:oe(ue,{hideLabel:!0})}),oe("div",{className:_e`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:r.flat(1)?.map(a=>oe(Je,{data:a},t?.[0]?.source.type==="raster"||n===N.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[E]))})]})}import{jsx as Cr}from"react/jsx-runtime";function et(){let{layer:e,isInfoBarOpen:r,setIsInfoBarOpen:t}=p();if(!e.selectedFeatures?.length)return null;let n=()=>t(!r);return r?Cr(Qe,{onClose:n}):Cr(gr,{onClick:n})}import $r,{useEffect as Wr,useRef as kn,useState as In}from"react";import{useMap as Cn}from"react-map-gl/maplibre";import{useT as Sn}from"@biodiv-platform/naksha-commons";import{tw as Fr}from"twind";import{tw as an}from"twind";import Qo,{useMemo as en}from"react";import{useVirtual as tn}from"react-virtual";import{AutoSizer as rn}from"react-virtualized-auto-sizer";import{tw as Nr}from"twind";import{useT as Ko}from"@biodiv-platform/naksha-commons";import{useMemo as jo,useState as Er}from"react";import{RWebShare as Jo}from"react-web-share";import{tw as A}from"twind";import{Fragment as Pr,jsx as Ae}from"react/jsx-runtime";var Tr=({text:e="",highlight:r=""})=>{if(!r.trim())return Ae(Pr,{children:e});let t=new RegExp(`(${r})`,"gi"),n=e.split(t);return Ae(Pr,{children:n.filter(o=>o).map((o,a)=>t.test(o)?Ae("mark",{children:o},a):Ae("span",{children:o},a))})};import{tw as Oo}from"twind";import{useT as Eo}from"@biodiv-platform/naksha-commons";import{useState as No}from"react";import{tw as _o}from"twind";import{jsx as Ao,jsxs as Bo}from"react/jsx-runtime";function fe({children:e}){let[r,t]=No(!1),{t:n}=Eo();return Bo("div",{children:[r&&e,Ao("button",{onClick:()=>t(!r),className:_o`text-blue-600 focus:outline-none focus:outline focus:ring`,children:n(r?"less":"legend")})]})}import{jsx as Be,jsxs as Oe}from"react/jsx-runtime";function tt({item:e}){let{layer:r}=p(),t=r.gridLegends[e.id];return t?Be(fe,{children:Oe("ul",{style:{margin:0,padding:0},children:[t?.stops.map(([n,o],a,s)=>{let l=(s[a-1]||[0])[0];return l===n?Be("div",{},o):Oe("li",{className:Oo`flex gap-2 items-center mb-1`,children:[Be("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Be("circle",{cx:"12",fill:o,cy:"12",r:"12",stroke:"none"})}),Oe("div",{children:[l," - ",n]})]},o)}),Oe("li",{children:["1 Square = ",t?.squareSize," x ",t?.squareSize," km"]})]})}):null}import{LICENSES as Go,useT as Do}from"@biodiv-platform/naksha-commons";import{useState as zo}from"react";import{Popover as Ho}from"react-tiny-popover";import{tw as F}from"twind";import{jsx as b,jsxs as rt}from"react/jsx-runtime";var ne=({icon:e,name:r,title:t,link:n,children:o})=>{let a=b("span",{className:F`flex-1`,children:o||"-"});return rt("div",{className:F`flex items-center gap-3 text-sm text-gray-600 break-all`,title:r&&t&&`${r}: ${t}`,children:[b("div",{className:F`flex-shrink-0`,children:e}),n?b("a",{className:F`text-blue-700 focus:outline-none focus:ring flex-1`,target:"_blank",rel:"noopener",href:n,children:a}):a]})};function Fo({item:e,containerStyle:r}){let{t}=Do(),{layer:n,mp:o}=p(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return rt("div",{className:F`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:r,children:[o.managePublishing&&e.layerStatus&&b(ne,{icon:b(ar,{}),name:t("visiblity"),title:e.layerStatus,children:rt("div",{className:F`flex items-center gap-3`,children:[b("span",{children:e.layerStatus}),b(Sr,{label:t("published"),checked:e.layerStatus?.toLowerCase()===J.ACTIVE.toLowerCase(),onChange:()=>n.togglePublish(e.id,e?.layerStatus)}),b("button",{type:"button",title:t("delete"),className:F`text-red-500 hover:text-red-700 focus:outline-none cursor-pointer flex items-center p-0.5 rounded hover:bg-red-50 transition-colors`,onClick:()=>n.delete(e.id,t("are_you_sure")),children:b(fr,{})})]})}),b(ne,{icon:b(Ye,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),b(ne,{icon:b(Ye,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),b(ne,{icon:b(sr,{}),name:t("created_on"),title:s,children:s}),b(ne,{icon:b(or,{}),name:t("tags"),title:l,children:l}),b(ne,{name:t("license"),title:a,link:a&&Go[a],icon:b(nr,{}),children:a})]})}var Rr=({item:e})=>{let[r,t]=zo(!1),n=()=>t(!r);return b(Ho,{isOpen:r,padding:10,positions:["right"],containerStyle:{zIndex:"99"},onClickOutside:n,content:b(Fo,{item:e}),children:b(D,{onClick:n,children:b(Ie,{}),title:"Information"})})};import{tw as Zo}from"twind";import{useMemo as $o,useState as Wo}from"react";import{useT as qo}from"@biodiv-platform/naksha-commons";import{tw as Vo}from"twind";import{jsx as $,jsxs as Uo}from"react/jsx-runtime";function Mr({item:e}){let[r,t]=Wo(!0),{mp:n}=p(),{t:o}=qo(),a=$o(()=>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,c])=>Uo("li",{className:Vo`flex gap-2 items-center mb-1`,children:[$("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:$("circle",{cx:"12",fill:c,cy:"12",r:"12",stroke:"none"})}),$("div",{children:l})]},c));return $("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():r?$("li",{children:$("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${n?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):$("div",{children:o("raster_style_not_found")})})}import{jsx as Ge,jsxs as Yo}from"react/jsx-runtime";function ot({item:e}){if(!e.data?.styles)return null;let{layer:r}=p(),t=n=>{r.updateStyle(e.id,Number(n.target.value))};return Yo("div",{className:Zo`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&Ge(te,{onChange:t,children:e.data?.styles.map((n,o)=>Ge("option",{value:o,children:n.styleTitle},o))}),Ge(fe,{children:Ge(Mr,{item:e})})]})}import{jsx as x,jsxs as W}from"react/jsx-runtime";function Xo({dragHandleProps:e}){return x("div",{className:A`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:x(dr,{})})}function ye({item:e,extended:r,dragHandleProps:t}){let{t:n}=Ko(),{layer:o,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:c}=p(),[u,m]=Er(o.selectedIds.includes(e.id)),[f,v]=Er(!1),S=jo(()=>s.canLayerShare?{url:typeof window<"u"?`${window.location.href.split("?")[0]}?layers=${e.id}`:"",title:e.title}:void 0,[s.canLayerShare,e.id,e.title]),R=async()=>{v(!0),c(!0),o.setSelectedFeatures([]),l(null),await o.toggle({layerId:e.id,add:!u}),m(!u),v(!1)},B=async()=>{await Xt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},O=()=>o.zoomToExtent(e.id);return W("div",{className:A`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[W("div",{className:A`flex gap-3`,children:[W("div",{className:A`flex-shrink-0`,children:[x(br,{name:e.id,checked:u,onChange:R,isLoading:f}),r&&x(Xo,{dragHandleProps:t})]}),x("img",{className:A`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||zt}),W("div",{children:[x("div",{title:e.title,className:A`mb-1 leading-tight`,style:qe,children:x(Tr,{text:e.title,highlight:a.term})}),x("p",{title:e.description,className:A`text-gray-600 text-sm`,style:Ht,children:e.description})]})]}),W("div",{className:A`flex justify-between`,children:[W(D,{onClick:B,disabled:!e.isDownloadable,children:[x(ir,{})," ",n("download")]}),W("div",{className:A`flex gap-3`,children:[S&&x(Jo,{data:S,children:x(D,{title:"Share",children:x(cr,{})})}),r&&x(D,{onClick:O,title:"Zoom To Extent",children:x(lr,{})}),x(Rr,{item:e})]})]}),r&&x(ot,{item:e}),r&&e.source.type==="grid"&&x(tt,{item:e})]})}import{jsx as q}from"react/jsx-runtime";function _r(){let{layer:e,query:r}=p(),t=en(()=>r.term?e.all.filter(a=>a.title.toLowerCase().includes(r.term.toLowerCase())):e.all,[e.all,r.term]),n=Qo.useRef(null),o=tn({size:t.length,parentRef:n});return q("div",{className:Nr`flex-grow-1 relative`,children:q(rn,{renderProp:a=>q("div",{ref:n,className:"List",style:{height:a.height,overflow:"auto"},children:q("div",{style:{height:o.totalSize,width:"100%",position:"relative"},children:o.virtualItems.map(s=>q("div",{ref:s.measureRef,className:Nr`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:q("div",{style:{height:146},children:q(ye,{item:t[s.index]})})},s.index))})})})})}import{useT as on}from"@biodiv-platform/naksha-commons";import{tw as nn}from"twind";import{jsx as Ar}from"react/jsx-runtime";function nt(){let{t:e}=on(),{query:r}=p(),t=n=>r.setTerm(n.target.value);return Ar("div",{className:nn`flex-shrink-0 border-b-2 p-4`,children:Ar(hr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as Br,jsxs as sn}from"react/jsx-runtime";function at(){return sn("div",{className:an`flex flex-col w-full`,children:[Br(nt,{}),Br(_r,{})]})}function ln(e,r,t){let n=r<0?e.length+r:r;if(n>=0&&n<e.length){let o=t<0?e.length+t:t,[a]=e.splice(r,1);e.splice(o,0,a)}}function Or(e,r,t){return e=[...e],ln(e,r,t),e}import{closestCenter as cn,DndContext as dn,PointerSensor as pn,useSensor as un,useSensors as mn}from"@dnd-kit/core";import{SortableContext as fn,useSortable as yn,verticalListSortingStrategy as gn}from"@dnd-kit/sortable";import{CSS as hn}from"@dnd-kit/utilities";import{jsx as ae}from"react/jsx-runtime";function bn({item:e,extended:r}){let{attributes:t,listeners:n,setNodeRef:o,transform:a,transition:s,isDragging:l}=yn({id:e.id}),c={transform:hn.Transform.toString(a),transition:s,opacity:l?.5:1};return ae("div",{ref:o,style:c,children:ae(ye,{item:e,extended:r,dragHandleProps:{...t,...n}})})}var Gr=({layerList:e,onSortEnd:r})=>{let t=mn(un(pn,{activationConstraint:{distance:4}}));return ae(dn,{sensors:t,collisionDetection:cn,onDragEnd:o=>{let{active:a,over:s}=o;if(s&&a.id!==s.id){let l=e.findIndex(u=>u.id===a.id),c=e.findIndex(u=>u.id===s.id);l!==-1&&c!==-1&&r({oldIndex:l,newIndex:c})}},children:ae(fn,{items:e.map(o=>o.id),strategy:gn,children:ae("div",{children:e.map(o=>ae(bn,{item:o,extended:!0},o.id))})})})};import{useT as Ln}from"@biodiv-platform/naksha-commons";import{tw as Dr}from"twind";import{jsx as Hr,jsxs as zr}from"react/jsx-runtime";function st(){let{layer:e}=p(),{t:r}=Ln(),t=({oldIndex:n,newIndex:o})=>{e.setSelectedIds(Or(e.selectedIds,n,o))};return zr("div",{className:Dr`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&Hr("div",{className:Dr`p-3 pb-0`,children:zr(D,{onClick:()=>e.clearAll(),children:["\u2715 ",r("clear")]})}),Hr(Gr,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as vn}from"@biodiv-platform/naksha-commons";import{tw as xn}from"twind";import{jsx as it,jsxs as wn}from"react/jsx-runtime";function lt(){let{layer:e}=p(),{t:r}=vn(),t=n=>{e.setMapStyle(n.target.value),e.setMaxZoom(e.mapStyles.find(o=>o.style===n.target.value)?.maxZoom)};return wn("div",{className:xn`w-full p-4 flex flex-col gap-4`,children:[it(te,{name:"base_style",label:r("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(n=>it("option",{value:n.style,children:n.text},n.key))}),it(ue,{})]})}import{jsx as P,jsxs as ct}from"react/jsx-runtime";function dt({onClose:e}){let{t:r}=Sn();return ct("div",{className:Fr`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:[P(Pe,{onClick:e}),P("div",{className:Fr`flex flex-col h-full`,children:ct(vr,{children:[ct(xr,{children:[P(Re,{icon:P(pe,{}),children:r("layers")}),P(Re,{icon:P(pe,{}),children:r("selected")}),P(Re,{icon:P(rr,{}),children:r("settings")})]}),P(Me,{children:P(at,{})}),P(Me,{children:P(st,{})}),P(Me,{children:P(lt,{})})]})})]})}import{jsx as qr}from"react/jsx-runtime";function pt(){let{mp:e,layer:r}=p(),[t,n]=In(e.showToC),{mapl:o}=Cn(),a=kn(!1),s=$r.useCallback(()=>n(c=>!c),[]),l=$r.useCallback(async()=>{let c=await Zt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...c];if(r.setAll(u),r.selectedIds.length){let m=u.find(f=>f.id===r.selectedIds[0]);m?.bbox&&o?.fitBounds(m.bbox,{padding:40,duration:1e3})}},[e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers,e.layers,r.setAll,r.selectedIds,o]);return Wr(()=>{e.loadToC&&!a.current&&(a.current=!0,l())},[e.loadToC]),Wr(()=>{if(o&&r.selectedIds.length&&r.all?.length){let c=r.all.find(u=>u.id===r.selectedIds[0]);c?.bbox&&o.fitBounds(c.bbox,{padding:40,duration:1e3})}},[o]),t?qr(dt,{onClose:s}):qr(yr,{onClick:s})}import{config as z}from"maplibre-gl";var Vr="https://unpkg.com/maplibre-gl@6.16.0/dist/maplibre-gl-worker.mjs";typeof window<"u"&&!z.WORKER_URL&&(z.WORKER_URL="/maplibre-gl-worker.mjs");var De=null;async function Ur(e){return e?(z.WORKER_URL=e,e):z.WORKER_URL&&z.WORKER_URL!=="/maplibre-gl-worker.mjs"?z.WORKER_URL:typeof window>"u"?"":De||(De=(async()=>{try{let r=await fetch("/maplibre-gl-worker.mjs",{method:"HEAD"}),t=r.headers.get("content-type")||"";if(r.ok&&!t.includes("text/html"))return z.WORKER_URL="/maplibre-gl-worker.mjs","/maplibre-gl-worker.mjs"}catch{}return z.WORKER_URL=Vr,Vr})(),De)}import{useMap as zn}from"react-map-gl/maplibre";import Pn from"@turf/bbox";import{useEffect as ut,useRef as Tn,useState as Rn}from"react";import{Layer as Mn,Source as En,useMap as Nn}from"react-map-gl/maplibre";import{jsx as Zr}from"react/jsx-runtime";function mt({data:e,beforeId:r}){let{layer:t}=p(),{mapl:n}=Nn(),[o,a]=Rn({geojson:{},paint:{}}),s=Tn(""),l=t.selectedIds.includes(e.id),c=t.selectedIds[0]===e.id,u=async(m=!1)=>{if(!n)return;let f=n.getBounds(),v=n.getZoom();if(!f)return;let[S]=Se(v),{_ne:R,_sw:B}=f,O=`${R.lat.toFixed(4)},${B.lng.toFixed(4)},${B.lat.toFixed(4)},${R.lng.toFixed(4)},${S}`;if(O===s.current)return;s.current=O;let{success:Z,geojson:he,paint:k,stops:$e,squareSize:w}=await Jt(e.source.fetcher,f,v);if(Z){if(a({geojson:he,paint:k}),m&&c&&e.zoomToFit)try{let M=Pn(he);if(M.every(Number.isFinite)){let[L,G,Y,be]=M;n.fitBounds([[L,G],[Y,be]],{padding:40,animate:!0})}}catch(M){console.warn("Failed to compute bbox",M)}t.setGridLegends(M=>({...M,[e.id]:{stops:$e,squareSize:w}}))}};return ut(()=>{l&&c?u(!0):l&&u(!1)},[l,c]),ut(()=>{if(!l||!n)return;let m=()=>u(!1);return n.on("moveend",m),()=>{n.off("moveend",m)}},[l,n]),ut(()=>()=>{t.setGridLegends(m=>{let f={...m};return delete f[e.id],f})},[e.id]),Zr(En,{id:e.id,type:"geojson",data:o.geojson,children:Zr(Mn,{beforeId:r,id:e.id,type:"fill",paint:o.paint})})}import{useMemo as _n}from"react";import{Layer as Yr,Source as An}from"react-map-gl/maplibre";import{jsx as Kr,jsxs as On}from"react/jsx-runtime";var Bn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function ze({layer:e,beforeId:r}){let{layer:t}=p(),n=_n(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,t.selectedFeatures]),o=t.selectedFeaturesId?.[e.id];return On(An,{...e.source,children:[n&&Kr(Yr,{beforeId:r,...n}),o&&n&&Kr(Yr,{...n,beforeId:r,id:`hl_${e.id}`,filter:["in",E,...o],type:n.type==="fill"?"line":n.type,paint:Bn[n.type]})]})}import{Layer as Gn,Source as Dn}from"react-map-gl/maplibre";import{jsx as jr}from"react/jsx-runtime";function ft({data:e,beforeId:r}){let{mp:t}=p();return jr(Dn,{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:jr(Gn,{id:e.id,beforeId:r,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as He}from"react/jsx-runtime";function Jr({layer:e,beforeId:r}){let{mapl:t}=zn();if(!t)return null;switch(e.source.type){case"vector":return He(ze,{beforeId:r,layer:e});case"grid":return He(mt,{beforeId:r,data:e});case"raster":return He(ft,{beforeId:r,data:e});default:return He(ze,{beforeId:r,layer:e})}}import{useMemo as Hn}from"react";import{Marker as Fn}from"react-map-gl/maplibre";import{Fragment as qn,jsx as yt}from"react/jsx-runtime";var $n=Fn,Wn=()=>{let{mp:e}=p(),r=Hn(()=>e.markers,[e.markers]);return yt(qn,{children:r?.map(({latitude:t,longitude:n,colorHex:o,anchor:a="bottom",iconUrl:s},l)=>yt($n,{latitude:t,longitude:n,anchor:a,subpixelPositioning:!0,children:yt("img",{style:{cursor:"pointer",display:"block",width:"25px",height:"41px"},width:25,height:41,alt:"Marker",src:s||"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},l))})},Xr=Wn;import Vn from"clsx";import{Popup as Un}from"react-map-gl/maplibre";import{tw as ge}from"twind";import{jsx as V,jsxs as Qr}from"react/jsx-runtime";var Zn=Un;function gt({coordinates:e}){let{hover:r}=p(),t=e||r.features?.coordinates;return t?.lat&&r.features?V(Zn,{latitude:t.lat,longitude:t.lng,closeButton:!1,children:Qr("table",{className:ge`table-auto border`,children:[V("thead",{children:V("tr",{children:V("th",{className:ge`bg-gray-200 py-1 px-2`,colSpan:2,children:r.features.title})})}),V("tbody",{children:r.features.data.map(([n,o],a)=>Qr("tr",{className:ge(Vn({"bg-gray-50":a%2===0,"border-gray-100 border-t":1})),children:[V("td",{className:ge`py-1 px-2`,children:n}),V("td",{className:ge`py-1 px-2 border-l border-gray-100`,children:o})]},n+o))})]})}):null}import{jsx as U,jsxs as to}from"react/jsx-runtime";var ra=Qn;function bt(){let{mp:e,layer:r,hover:t,query:n}=p(),[o,a]=jn(e.workerUrl||(typeof window<"u"?ea.WORKER_URL||"/maplibre-gl-worker.mjs":void 0));eo(()=>{Ur(e.workerUrl).then(a)},[e.workerUrl]);let s=Kn(()=>e.defaultViewState||Yn,[e.defaultViewState]),l=ht.useCallback(m=>n.setClickedLngLat(m.lngLat),[n]),c=ht.useRef(null),u=ht.useCallback(m=>{c.current||(c.current=requestAnimationFrame(()=>{c.current=null,t.onHover(m)}))},[t]);return eo(()=>()=>{c.current&&cancelAnimationFrame(c.current)},[]),to("div",{className:ta`h-full w-full relative bg-gray-100`,children:[e.loadToC&&U(pt,{}),r.selectedFeatures?.length>0&&U(et,{}),to(Jn,{id:"mapl",workerUrl:o,cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:r.mapStyle,maxZoom:r.maxZoom,onClick:l,onMouseMove:u,children:[U(ra,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&U(Xn,{position:"bottom-right"}),U(Xr,{}),r.selectedLayers.map((m,f)=>{let v=f>0?r.selectedIds[f-1]:void 0;return U(Jr,{layer:m,beforeId:v},m.id)}),U(gt,{},"popup")]})]})}import{jsx as Fe}from"react/jsx-runtime";sa({preflight:!1});var Vc=e=>{let r=na.useMemo(()=>({...Dt,...e}),[e]);return Fe(aa,{children:Fe(oa,{localeStrings:Gt,lang:r.lang,children:Fe(er,{mp:r,children:Fe(bt,{})})})})};export{Vc as NakshaMaplibreLayers};
|