@biodiv-platform/naksha-maplibre-layers 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2368 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __pow = Math.pow;
13
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
14
+ var __spreadValues = (a, b) => {
15
+ for (var prop in b || (b = {}))
16
+ if (__hasOwnProp.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ if (__getOwnPropSymbols)
19
+ for (var prop of __getOwnPropSymbols(b)) {
20
+ if (__propIsEnum.call(b, prop))
21
+ __defNormalProp(a, prop, b[prop]);
22
+ }
23
+ return a;
24
+ };
25
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
26
+ var __export = (target, all) => {
27
+ for (var name in all)
28
+ __defProp(target, name, { get: all[name], enumerable: true });
29
+ };
30
+ var __copyProps = (to, from, except, desc) => {
31
+ if (from && typeof from === "object" || typeof from === "function") {
32
+ for (let key of __getOwnPropNames(from))
33
+ if (!__hasOwnProp.call(to, key) && key !== except)
34
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
35
+ }
36
+ return to;
37
+ };
38
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
39
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
40
+ mod
41
+ ));
42
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
43
+ var __async = (__this, __arguments, generator) => {
44
+ return new Promise((resolve, reject) => {
45
+ var fulfilled = (value) => {
46
+ try {
47
+ step(generator.next(value));
48
+ } catch (e) {
49
+ reject(e);
50
+ }
51
+ };
52
+ var rejected = (value) => {
53
+ try {
54
+ step(generator.throw(value));
55
+ } catch (e) {
56
+ reject(e);
57
+ }
58
+ };
59
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
60
+ step((generator = generator.apply(__this, __arguments)).next());
61
+ });
62
+ };
63
+
64
+ // src/index.tsx
65
+ var src_exports = {};
66
+ __export(src_exports, {
67
+ NakshaMaplibreLayers: () => NakshaMaplibreLayers
68
+ });
69
+ module.exports = __toCommonJS(src_exports);
70
+ var import_naksha_commons14 = require("@biodiv-platform/naksha-commons");
71
+ var import_react14 = __toESM(require("react"));
72
+ var import_maplibre10 = require("react-map-gl/maplibre");
73
+ var import_twind21 = require("twind");
74
+
75
+ // locales/en.json
76
+ var en_default = {
77
+ are_you_sure: "Are you sure?",
78
+ base_style: "Base Style",
79
+ clear: "Clear Selection",
80
+ created_by: "Attribution",
81
+ created_on: "Created On",
82
+ delete: "Delete",
83
+ download: "Download",
84
+ find_layer_by_name: "Find layer by name",
85
+ infobar: "Attributes at Clicked Location",
86
+ information: "Information",
87
+ layer_selection: "Layer Selection",
88
+ layer_selection_all: "All Layers",
89
+ layer_selection_top: "Top Layer Only",
90
+ layers: "Layers",
91
+ legend: "Legend",
92
+ less: "Less",
93
+ license: "License",
94
+ list_layers: "List Layers",
95
+ pending: "Pending",
96
+ publish: "Publish",
97
+ raster_style_not_found: "Style not available for the given layer",
98
+ remove: "Remove",
99
+ selected: "Selected",
100
+ settings: "Settings",
101
+ square: "Square",
102
+ tags: "Tags",
103
+ toggle: "Toggle Publishing",
104
+ uploaded: "Uploaded",
105
+ uploader: "Uploader",
106
+ url: "URL",
107
+ visiblity: "Visiblity"
108
+ };
109
+
110
+ // locales/fr.json
111
+ var fr_default = {
112
+ are_you_sure: "\xCAtes-vous s\xFBr?",
113
+ base_style: "Style de base",
114
+ clear: "Effacer la s\xE9lection",
115
+ created_by: "Attribution",
116
+ created_on: "Cr\xE9\xE9 sur",
117
+ delete: "Effacer",
118
+ download: "T\xE9l\xE9charger",
119
+ find_layer_by_name: "Trouver la couche par nom",
120
+ infobar: "Attributs \xE0 l'emplacement cliqu\xE9",
121
+ information: "Informations",
122
+ layer_selection_all: "Toutes les couches",
123
+ layer_selection_top: "Couche sup\xE9rieure uniquement",
124
+ layer_selection: "S\xE9lection de calque",
125
+ layers: "Couches",
126
+ legend: "L\xE9gende",
127
+ less: "Moins",
128
+ license: "Licence",
129
+ list_layers: "Liste des couches",
130
+ pending: "En attente",
131
+ publish: "Publier",
132
+ remove: "Supprimer",
133
+ selected: "Choisie",
134
+ settings: "Param\xE8tres",
135
+ square: "Carr\xE9",
136
+ toggle: "Basculer la publication",
137
+ uploaded: "T\xE9l\xE9charg\xE9",
138
+ url: "url"
139
+ };
140
+
141
+ // locales/hi.json
142
+ var hi_default = {
143
+ are_you_sure: "\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",
144
+ base_style: "\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",
145
+ clear: "\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",
146
+ created_by: "\u0906\u0930\u094B\u092A\u0923",
147
+ created_on: "\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",
148
+ delete: "\u0939\u091F\u093E\u090F\u0902",
149
+ download: "\u0921\u093E\u0909\u0928\u0932\u094B\u0921",
150
+ find_layer_by_name: "\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",
151
+ 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",
152
+ information: "\u091C\u093E\u0928\u0915\u093E\u0930\u0940",
153
+ layer_selection_all: "\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",
154
+ layer_selection_top: "\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",
155
+ layer_selection: "\u092A\u0930\u0924 \u091A\u092F\u0928",
156
+ layers: "\u092A\u0930\u0924\u0947\u0902",
157
+ legend: "\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",
158
+ less: "\u0915\u092E",
159
+ license: "\u0932\u093E\u0907\u0938\u0947\u0902\u0938",
160
+ list_layers: "\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",
161
+ pending: "\u0932\u0902\u092C\u093F\u0924",
162
+ publish: "\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",
163
+ remove: "\u0939\u091F\u093E\u0928\u093E",
164
+ selected: "\u091A\u092F\u0928\u093F\u0924",
165
+ settings: "\u0938\u092E\u093E\u092F\u094B\u091C\u0928",
166
+ square: "\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",
167
+ tags: "\u091F\u0948\u0917",
168
+ toggle: "\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",
169
+ uploaded: "\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",
170
+ url: "\u092F\u0942\u0906\u0930\u090F\u0932"
171
+ };
172
+
173
+ // locales/index.ts
174
+ var locales_default = { en: en_default, fr: fr_default, hi: hi_default };
175
+
176
+ // src/components/map/index.tsx
177
+ var import_naksha_commons13 = require("@biodiv-platform/naksha-commons");
178
+ var import_react13 = require("react");
179
+ var import_maplibre9 = __toESM(require("react-map-gl/maplibre"));
180
+ var import_twind20 = require("twind");
181
+
182
+ // src/hooks/use-layers.tsx
183
+ var import_naksha_commons2 = require("@biodiv-platform/naksha-commons");
184
+ var import_react = __toESM(require("react"));
185
+ var import_maplibre = require("react-map-gl/maplibre");
186
+
187
+ // src/services/naksha.ts
188
+ var import_colorbrewer = __toESM(require("colorbrewer"));
189
+ var import_redaxios = __toESM(require("redaxios"));
190
+
191
+ // src/utils/grid.ts
192
+ var import_boundingbox = __toESM(require("boundingbox"));
193
+ var import_geohash = require("geohash");
194
+
195
+ // src/static/constants.tsx
196
+ var import_naksha_commons = require("@biodiv-platform/naksha-commons");
197
+ var defaultNakshaProps = {
198
+ defaultViewState: import_naksha_commons.defaultViewState,
199
+ nakshaApiEndpoint: "/naksha-api/api",
200
+ geoserver: { endpoint: "/geoserver", workspace: "biodiv", store: "ibp" },
201
+ mapStyle: import_naksha_commons.MapStyles.MAP_STREETS,
202
+ layers: [],
203
+ selectedLayers: []
204
+ };
205
+ 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";
206
+ var overflowStyle = {
207
+ display: "-webkit-box",
208
+ WebkitLineClamp: 1,
209
+ WebkitBoxOrient: "vertical",
210
+ overflow: "hidden",
211
+ wordBreak: "break-word"
212
+ };
213
+ var overflowStyle2 = __spreadProps(__spreadValues({}, overflowStyle), {
214
+ WebkitLineClamp: 2
215
+ });
216
+ var PROPERTY_ID = "ogc_fid";
217
+ var LAYER_STATUS = {
218
+ ACTIVE: "Active",
219
+ PENDING: "Pending"
220
+ };
221
+ var SELECTION_STYLE = {
222
+ TOP: "layer_selection_top",
223
+ ALL: "layer_selection_all"
224
+ };
225
+
226
+ // src/utils/grid.ts
227
+ var getZoomConfig = (zoom) => {
228
+ if (zoom < 6)
229
+ return [4, 1, 39.2];
230
+ else if (zoom < 7)
231
+ return [5, 0, 19.6];
232
+ else if (zoom < 8)
233
+ return [5, 1, 9.8];
234
+ else if (zoom < 9)
235
+ return [5, -1, 4.9];
236
+ else if (zoom < 10)
237
+ return [6, 0, 2.45];
238
+ else if (zoom < 11)
239
+ return [6, 1, 1.225];
240
+ else if (zoom < 12)
241
+ return [7, 0, 0.612];
242
+ else if (zoom < 13)
243
+ return [7, 1, 0.306];
244
+ else if (zoom < 14)
245
+ return [7, -1, 0.153];
246
+ else if (zoom < 15)
247
+ return [8, 0, 0.077];
248
+ return [8, 1, 0.039];
249
+ };
250
+ var BASE32 = "0123456789bcdefghjkmnpqrstuvwxyz";
251
+ var aggregateGeohashKey = (key, level, binSize) => {
252
+ binSize = binSize || 16 / __pow(2, 1 - key.length & 1) / __pow(4, level);
253
+ const keyExceptLast = key.slice(0, -1);
254
+ const binnedCharAt = ~~(BASE32.indexOf(key.slice(-1)) / binSize);
255
+ return [
256
+ keyExceptLast + BASE32[binSize * binnedCharAt],
257
+ keyExceptLast + BASE32[binSize * (binnedCharAt + 1) - 1]
258
+ ];
259
+ };
260
+ var processRectangles = function(data, level) {
261
+ var counts = /* @__PURE__ */ new Map();
262
+ var bins = /* @__PURE__ */ new Map();
263
+ const features = [];
264
+ for (const [hash, count] of Object.entries(data)) {
265
+ const [kStart, kEnd] = aggregateGeohashKey(hash, level);
266
+ bins.set(kStart, kEnd);
267
+ if (!counts.has(kStart)) {
268
+ counts.set(kStart, 0);
269
+ }
270
+ counts.set(kStart, counts.get(kStart) + count);
271
+ }
272
+ counts.forEach((count, hash) => {
273
+ const bboxStart = import_geohash.GeoHash.decodeGeoHash(hash);
274
+ const bboxEnd = import_geohash.GeoHash.decodeGeoHash(bins.get(hash));
275
+ const feature = new import_boundingbox.default({
276
+ minlat: bboxStart.latitude[0],
277
+ minlon: bboxStart.longitude[0],
278
+ maxlat: bboxEnd.latitude[1],
279
+ maxlon: bboxEnd.longitude[1]
280
+ }).toGeoJSON();
281
+ features.push(__spreadProps(__spreadValues({}, feature), { properties: { count, [PROPERTY_ID]: hash } }));
282
+ });
283
+ return features;
284
+ };
285
+ var processSquares = (data) => {
286
+ const features = [];
287
+ for (const [hash, count] of Object.entries(data)) {
288
+ const bbox = import_geohash.GeoHash.decodeGeoHash(hash);
289
+ const feature = new import_boundingbox.default({
290
+ minlat: bbox.latitude[0],
291
+ minlon: bbox.longitude[0],
292
+ maxlat: bbox.latitude[1],
293
+ maxlon: bbox.longitude[1]
294
+ }).toGeoJSON();
295
+ features.push(__spreadProps(__spreadValues({}, feature), { properties: { count, [PROPERTY_ID]: hash } }));
296
+ }
297
+ return features;
298
+ };
299
+ var geohashToJSON = (data, level) => ({
300
+ type: "FeatureCollection",
301
+ features: Object.keys(data).length === 0 ? [] : level === -1 ? processSquares(data) : processRectangles(data, level)
302
+ });
303
+ var getDataBins = (data, binCount) => {
304
+ const sortedData = Object.values(data).sort((a, b) => a - b);
305
+ const cutoff = Math.floor(sortedData.length / binCount);
306
+ const tBins = new Array(binCount - 1).fill(0).map((_, index) => sortedData[cutoff * (index + 1)]);
307
+ tBins.push(sortedData[sortedData.length - 1]);
308
+ return tBins;
309
+ };
310
+
311
+ // src/utils/naksha.ts
312
+ var import_immer = __toESM(require("immer"));
313
+ var parseGeoserverLayersXml = (layers, nakshaApiEndpoint, geoserver, selectedLayers) => __async(void 0, null, function* () {
314
+ const parsedLayers = [];
315
+ for (const l of layers) {
316
+ const isAdded = selectedLayers.includes(l.name);
317
+ const _l = __spreadProps(__spreadValues({}, l), {
318
+ id: l.name,
319
+ thumbnail: nakshaApiEndpoint + l.thumbnail,
320
+ source: {
321
+ type: l.layerType.toLowerCase() === "raster" ? "raster" : "vector",
322
+ scheme: "tms",
323
+ tiles: [
324
+ `${geoserver.endpoint}/gwc/service/tms/1.0.0/${geoserver.workspace}:${l.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`
325
+ ]
326
+ },
327
+ data: { styles: [] },
328
+ isAdded
329
+ });
330
+ if (isAdded) {
331
+ const _ld = yield getLayerStyle(_l, 0, nakshaApiEndpoint, geoserver);
332
+ parsedLayers.push(__spreadProps(__spreadValues({}, _l), { data: _ld }));
333
+ } else {
334
+ parsedLayers.push(_l);
335
+ }
336
+ }
337
+ return parsedLayers;
338
+ });
339
+ var getLayerStyle = (layer, styleIndex, nakshaApiEndpoint, geoserver) => __async(void 0, null, function* () {
340
+ const nextSl = (0, import_immer.default)(layer.data, (_draft) => __async(void 0, null, function* () {
341
+ var _a;
342
+ if (_draft.styles.length === 0) {
343
+ const { success, data } = yield axGetGeoserverLayerStyleList(
344
+ layer.id,
345
+ nakshaApiEndpoint
346
+ );
347
+ if (success) {
348
+ _draft.layerName = data.layerName;
349
+ _draft.styles = data.styles;
350
+ _draft.summaryColumn = data.summaryColumn;
351
+ _draft.titleColumn = data.titleColumn;
352
+ _draft.propertyMap = Object.fromEntries(
353
+ data.styles.map((o) => [o.styleName, o.styleTitle])
354
+ );
355
+ }
356
+ }
357
+ if (_draft.styles[styleIndex] && !((_a = _draft.styles[styleIndex]) == null ? void 0 : _a.colors)) {
358
+ _draft.styles[styleIndex].colors = yield axGetGeoserverLayerStyle(
359
+ layer.id,
360
+ geoserver == null ? void 0 : geoserver.workspace,
361
+ _draft.styles[styleIndex].styleName,
362
+ nakshaApiEndpoint
363
+ );
364
+ }
365
+ _draft.styleIndex = styleIndex;
366
+ }));
367
+ return nextSl;
368
+ });
369
+
370
+ // src/services/naksha.ts
371
+ var axGetGeoserverLayers = (nakshaEndpointToken, nakshaApiEndpoint, geoserver, selectedLayers) => __async(void 0, null, function* () {
372
+ try {
373
+ const res = yield import_redaxios.default.get(`${nakshaApiEndpoint}/layer/all`, {
374
+ headers: { Authorization: nakshaEndpointToken }
375
+ });
376
+ const finalLayers = yield parseGeoserverLayersXml(
377
+ res.data,
378
+ nakshaApiEndpoint,
379
+ geoserver,
380
+ selectedLayers
381
+ );
382
+ return finalLayers;
383
+ } catch (e) {
384
+ console.error(e);
385
+ return [];
386
+ }
387
+ });
388
+ var axGetGeoserverLayerStyleList = (id, endpoint) => __async(void 0, null, function* () {
389
+ try {
390
+ const { data } = yield import_redaxios.default.get(`${endpoint}/layer/onClick/${id}`);
391
+ return { success: true, data };
392
+ } catch (e) {
393
+ console.error(e);
394
+ return { success: false };
395
+ }
396
+ });
397
+ var axGexGetRasterInfoWithLonLat = (endpoint, workspace, params) => __async(void 0, null, function* () {
398
+ const RasterInfoParams = {
399
+ service: "WMS",
400
+ version: "1.1.1",
401
+ request: "GetFeatureInfo",
402
+ info_format: "application/json",
403
+ width: 100,
404
+ height: 100,
405
+ x: 50,
406
+ y: 50,
407
+ srs: "EPSG:4326"
408
+ };
409
+ try {
410
+ const res = yield import_redaxios.default.get(`${endpoint}/${workspace}/wms`, {
411
+ params: __spreadValues(__spreadValues({}, params), RasterInfoParams)
412
+ });
413
+ return { success: true, data: res.data };
414
+ } catch (e) {
415
+ console.error(e);
416
+ return { success: false, data: [] };
417
+ }
418
+ });
419
+ var axToggleLayerPublishing = (nakshaEndpointToken, nakshaApiEndpoint, layerId, isActive) => __async(void 0, null, function* () {
420
+ try {
421
+ yield import_redaxios.default.put(
422
+ `${nakshaApiEndpoint}/layer/${isActive ? "active" : "pending"}/${layerId}`,
423
+ {},
424
+ { headers: { Authorization: nakshaEndpointToken } }
425
+ );
426
+ return true;
427
+ } catch (e) {
428
+ console.error(e);
429
+ return false;
430
+ }
431
+ });
432
+ var axDeleteLayer = (nakshaEndpointToken, nakshaApiEndpoint, layerId) => __async(void 0, null, function* () {
433
+ try {
434
+ yield import_redaxios.default.delete(`${nakshaApiEndpoint}/layer/${layerId}`, {
435
+ headers: { Authorization: nakshaEndpointToken }
436
+ });
437
+ return true;
438
+ } catch (e) {
439
+ console.error(e);
440
+ return false;
441
+ }
442
+ });
443
+ var axGetGeoserverLayerStyle = (layername, workspace, styleName, endpoint) => __async(void 0, null, function* () {
444
+ var _a, _b;
445
+ try {
446
+ const res = yield import_redaxios.default.get(
447
+ `${endpoint}/geoserver/workspaces/${workspace}/styles/${layername}_${styleName}.mbstyle`
448
+ );
449
+ return (_b = (_a = res.data) == null ? void 0 : _a.layers) == null ? void 0 : _b[0];
450
+ } catch (e) {
451
+ console.error(e);
452
+ return {};
453
+ }
454
+ });
455
+ var getGridLayerData = (fetcher, bounds, zoom, binCount = 6, colorScheme = "YlOrRd") => __async(void 0, null, function* () {
456
+ try {
457
+ const [geoAggegationPrecision, level, squareSize] = getZoomConfig(zoom);
458
+ const { _ne, _sw } = bounds;
459
+ const params = {
460
+ top: _ne.lat,
461
+ left: _sw.lng,
462
+ bottom: _sw.lat,
463
+ right: _ne.lng,
464
+ geoAggegationPrecision
465
+ };
466
+ const data = yield fetcher(params);
467
+ const geojson = geohashToJSON(data, level);
468
+ const bins = getDataBins(data, binCount);
469
+ const stops = bins.map((bin, index) => [
470
+ bin,
471
+ import_colorbrewer.default[colorScheme][binCount][index]
472
+ ]);
473
+ const paint2 = {
474
+ "fill-color": {
475
+ property: "count",
476
+ default: "yellow",
477
+ stops
478
+ },
479
+ "fill-outline-color": "rgba(0,0,0,0.2)",
480
+ "fill-opacity": 0.7
481
+ };
482
+ return { success: true, geojson, paint: paint2, stops, squareSize };
483
+ } catch (e) {
484
+ console.error(e);
485
+ return { success: false, geojson: {}, paint: {}, stops: [], squareSize: 0 };
486
+ }
487
+ });
488
+ var axDownloadLayer = (endpoint, token, layerName, layerTitle) => __async(void 0, null, function* () {
489
+ try {
490
+ yield import_redaxios.default.post(
491
+ `${endpoint}/layer/download`,
492
+ { layerName, layerTitle, attributeList: [], filterArray: [] },
493
+ { headers: { Authorization: token } }
494
+ );
495
+ } catch (e) {
496
+ console.error(e);
497
+ }
498
+ });
499
+
500
+ // src/hooks/use-layers.tsx
501
+ var import_jsx_runtime = require("react/jsx-runtime");
502
+ var LayersContext = (0, import_react.createContext)(
503
+ {}
504
+ );
505
+ var LayersProvider = ({ mp: _mp, children }) => {
506
+ const [mp, setMP] = (0, import_react.useState)(_mp);
507
+ const { mapl } = (0, import_maplibre.useMap)();
508
+ const [queryTerm, setQueryTerm] = (0, import_react.useState)("");
509
+ const queryTermDebounced = (0, import_naksha_commons2.useDebounce)(queryTerm, 500);
510
+ const [mapStyle, setMapStyle] = (0, import_react.useState)(
511
+ import_naksha_commons2.defaultMapStyles[(mp == null ? void 0 : mp.mapStyle) || 0].style
512
+ );
513
+ const [selectionStyle, setSelectionStyle] = (0, import_react.useState)(
514
+ SELECTION_STYLE.TOP
515
+ );
516
+ const [gridLegends, setGridLegends] = (0, import_react.useState)({});
517
+ const [isInfoBarOpen, setIsInfoBarOpen] = (0, import_react.useState)(true);
518
+ const [clickedLngLat, setClickedLngLat] = (0, import_react.useState)();
519
+ const [layers, setLayers] = (0, import_react.useState)(_mp.layers || []);
520
+ const [selectedLayerIds, setSelectedLayerIds] = (0, import_react.useState)(
521
+ mp.selectedLayers || []
522
+ );
523
+ const [hoverFeatures, setHoverFeatures] = (0, import_react.useState)();
524
+ const [selectedFeatures, setSelectedFeatures] = (0, import_react.useState)();
525
+ const selectedFeaturesId = (0, import_react.useMemo)(() => {
526
+ var _a;
527
+ const meta = {};
528
+ for (const qr of selectedFeatures || []) {
529
+ meta[qr.sourceLayer] = [
530
+ ...meta[qr.sourceLayer] || [],
531
+ (_a = qr == null ? void 0 : qr.properties) == null ? void 0 : _a[PROPERTY_ID]
532
+ ];
533
+ }
534
+ return Object.keys(meta).length ? meta : void 0;
535
+ }, [selectedFeatures]);
536
+ const selectedLayers = import_react.default.useMemo(() => {
537
+ const unsortedLayers = layers.filter(
538
+ (_layer) => selectedLayerIds.includes(_layer.id)
539
+ );
540
+ const sortedLayers = new Array(selectedLayerIds.length);
541
+ for (const layerToSort of unsortedLayers) {
542
+ const idx = selectedLayerIds.findIndex((l) => layerToSort.id === l);
543
+ if (idx > -1) {
544
+ sortedLayers[idx] = layerToSort;
545
+ }
546
+ }
547
+ return sortedLayers;
548
+ }, [layers, selectedLayerIds]);
549
+ const getLayerIndexById = (layerId) => {
550
+ return layers.findIndex((layer) => layer.id === layerId);
551
+ };
552
+ const updateLayerById = (layerId, updatedLayer) => {
553
+ setLayers(
554
+ (_layers) => _layers.map((l) => l.id === layerId ? __spreadValues(__spreadValues({}, l), updatedLayer) : l)
555
+ );
556
+ };
557
+ const toggleVectorLayer = (layerIndex, styleIndex, focus) => __async(void 0, null, function* () {
558
+ const layer = layers[layerIndex];
559
+ const layerData = yield getLayerStyle(
560
+ layer,
561
+ styleIndex,
562
+ mp.nakshaApiEndpoint,
563
+ mp.geoserver
564
+ );
565
+ updateLayerById(layer.id, { data: layerData });
566
+ focus && (mapl == null ? void 0 : mapl.fitBounds(layer.bbox, { padding: 40, duration: 1e3 }));
567
+ });
568
+ const updateLayerStyle = (layerId, styleIndex) => __async(void 0, null, function* () {
569
+ const layerIndex = getLayerIndexById(layerId);
570
+ toggleVectorLayer(layerIndex, styleIndex, false);
571
+ });
572
+ const onMapHover = (e) => __async(void 0, null, function* () {
573
+ var _a, _b, _c, _d;
574
+ if (!selectedLayerIds.length || !mapl)
575
+ return;
576
+ try {
577
+ const lastLayerId = selectedLayerIds[0];
578
+ const feats = mapl.queryRenderedFeatures(e.point, {
579
+ layers: [lastLayerId]
580
+ });
581
+ if (feats.length) {
582
+ const fId = ((_a = feats[0]) == null ? void 0 : _a.id) || ((_c = (_b = feats[0]) == null ? void 0 : _b.properties) == null ? void 0 : _c[PROPERTY_ID]);
583
+ if (fId === (hoverFeatures == null ? void 0 : hoverFeatures.id))
584
+ return;
585
+ const layer = layers[getLayerIndexById(lastLayerId)];
586
+ const hoverProperties = (_d = layer == null ? void 0 : layer.data) == null ? void 0 : _d.summaryColumn.map((sc) => {
587
+ var _a2, _b2, _c2;
588
+ return [
589
+ ((_b2 = (_a2 = layer.data) == null ? void 0 : _a2.propertyMap) == null ? void 0 : _b2[sc]) || sc,
590
+ (_c2 = feats[0].properties) == null ? void 0 : _c2[sc]
591
+ ];
592
+ });
593
+ setHoverFeatures({
594
+ id: fId,
595
+ title: layer.title,
596
+ data: hoverProperties
597
+ });
598
+ } else {
599
+ setHoverFeatures(void 0);
600
+ }
601
+ } catch (e2) {
602
+ }
603
+ });
604
+ const toggleLayer = (_0) => __async(void 0, [_0], function* ({
605
+ layerId,
606
+ add,
607
+ styleIndex = 0,
608
+ focus = true
609
+ }) {
610
+ var _a;
611
+ if (!add) {
612
+ setSelectedLayerIds(
613
+ selectedLayerIds.filter((_lyrId) => layerId !== _lyrId)
614
+ );
615
+ return;
616
+ }
617
+ const layerIndex = getLayerIndexById(layerId);
618
+ const sourceType = (_a = layers[layerIndex]) == null ? void 0 : _a.source.type;
619
+ yield toggleVectorLayer(layerIndex, styleIndex, focus);
620
+ setSelectedLayerIds((_slIds) => [
621
+ layerId,
622
+ ..._slIds.filter((lid) => lid !== layerId)
623
+ ]);
624
+ });
625
+ const clearAllLayers = () => __async(void 0, null, function* () {
626
+ return setSelectedLayerIds([]);
627
+ });
628
+ const updateMP = (key, value) => {
629
+ setMP(__spreadProps(__spreadValues({}, mp), { [key]: value }));
630
+ };
631
+ const toggleLayerPublishing = (layerId, layerStatus) => {
632
+ const isActive = layerStatus === LAYER_STATUS.PENDING;
633
+ axToggleLayerPublishing(
634
+ mp.nakshaEndpointToken,
635
+ mp.nakshaApiEndpoint,
636
+ layerId,
637
+ isActive
638
+ );
639
+ updateLayerById(layerId, {
640
+ layerStatus: isActive ? LAYER_STATUS.ACTIVE : LAYER_STATUS.PENDING
641
+ });
642
+ };
643
+ const deleteLayer = (layerId, message) => __async(void 0, null, function* () {
644
+ if (confirm(message)) {
645
+ axDeleteLayer(mp.nakshaEndpointToken, mp.nakshaApiEndpoint, layerId);
646
+ setLayers(layers.filter((l) => l.id !== layerId));
647
+ }
648
+ });
649
+ const zoomToExtent = (layerId) => {
650
+ const layerIndex = getLayerIndexById(layerId);
651
+ const layer = layers[layerIndex];
652
+ mapl == null ? void 0 : mapl.fitBounds(layer.bbox, { padding: 40, duration: 1e3 });
653
+ };
654
+ const getBBoxFromLngLat = () => {
655
+ return [
656
+ clickedLngLat.lng,
657
+ clickedLngLat.lat,
658
+ clickedLngLat.lng + 0.1,
659
+ clickedLngLat.lat + 0.1
660
+ ];
661
+ };
662
+ const handleSelectStyle = (value) => {
663
+ setSelectionStyle(value);
664
+ if (value === SELECTION_STYLE.TOP) {
665
+ featuresAtLatLng(value);
666
+ }
667
+ };
668
+ const featuresAtLatLng = (value) => {
669
+ if (!clickedLngLat)
670
+ return;
671
+ try {
672
+ const finalXY = mapl == null ? void 0 : mapl.project([clickedLngLat.lng, clickedLngLat.lat]);
673
+ let queryFeat = mapl == null ? void 0 : mapl.queryRenderedFeatures(finalXY, {
674
+ layers: selectionStyle === SELECTION_STYLE.TOP ? [selectedLayerIds[0]] : selectedLayerIds
675
+ });
676
+ if ((value || selectionStyle) === SELECTION_STYLE.ALL) {
677
+ const rasterLayerFeat = selectedLayers.filter((item) => item.layerType == "RASTER").map((item) => ({
678
+ sourceLayer: item.id,
679
+ layerType: "raster",
680
+ bbox: getBBoxFromLngLat()
681
+ }));
682
+ queryFeat = [...queryFeat, ...rasterLayerFeat];
683
+ }
684
+ setSelectedFeatures(
685
+ (selectedLayers == null ? void 0 : selectedLayers[0].layerType) === "RASTER" && selectionStyle !== SELECTION_STYLE.ALL ? selectedLayerIds.length && (queryFeat == null ? void 0 : queryFeat.length) ? queryFeat : [
686
+ {
687
+ sourceLayer: selectedLayerIds[0],
688
+ layerType: "raster",
689
+ bbox: getBBoxFromLngLat()
690
+ }
691
+ ] : queryFeat
692
+ );
693
+ } catch (e) {
694
+ console.error(e);
695
+ }
696
+ };
697
+ (0, import_react.useEffect)(() => {
698
+ if (mp.onSelectedLayersChange) {
699
+ mp.onSelectedLayersChange(selectedLayerIds);
700
+ }
701
+ }, [selectedLayerIds]);
702
+ (0, import_react.useEffect)(() => {
703
+ setTimeout(featuresAtLatLng, 300);
704
+ }, [clickedLngLat, selectionStyle, selectedLayerIds]);
705
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LayersContext.Provider, {
706
+ value: {
707
+ mp,
708
+ updateMP,
709
+ layer: {
710
+ mapStyle,
711
+ featuresAtLatLng,
712
+ setMapStyle,
713
+ all: layers,
714
+ setAll: setLayers,
715
+ selectedIds: selectedLayerIds,
716
+ handleSelectStyle,
717
+ setSelectedIds: setSelectedLayerIds,
718
+ selectedLayers,
719
+ clearAll: clearAllLayers,
720
+ toggle: toggleLayer,
721
+ updateStyle: updateLayerStyle,
722
+ selectedFeatures,
723
+ selectedFeaturesId,
724
+ setSelectedFeatures,
725
+ togglePublish: toggleLayerPublishing,
726
+ delete: deleteLayer,
727
+ selectionStyle,
728
+ setSelectionStyle,
729
+ zoomToExtent,
730
+ gridLegends,
731
+ setGridLegends
732
+ },
733
+ query: {
734
+ term: queryTermDebounced,
735
+ setTerm: setQueryTerm,
736
+ clickedLngLat,
737
+ setClickedLngLat
738
+ },
739
+ isInfoBarOpen,
740
+ setIsInfoBarOpen,
741
+ hover: {
742
+ onHover: onMapHover,
743
+ features: hoverFeatures
744
+ }
745
+ },
746
+ children
747
+ });
748
+ };
749
+ function useLayers() {
750
+ return (0, import_react.useContext)(LayersContext);
751
+ }
752
+
753
+ // src/components/core/button.tsx
754
+ var import_react2 = __toESM(require("react"));
755
+ var import_twind2 = require("twind");
756
+
757
+ // src/components/core/icons.tsx
758
+ var import_twind = require("twind");
759
+ var import_jsx_runtime2 = require("react/jsx-runtime");
760
+ var SearchIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
761
+ fill: "none",
762
+ className: import_twind.tw`w-5 h-5 text-gray-400`,
763
+ width: "24",
764
+ height: "24",
765
+ viewBox: "0 0 24 24",
766
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
767
+ stroke: "currentColor",
768
+ strokeLinecap: "round",
769
+ strokeLinejoin: "round",
770
+ strokeWidth: "2",
771
+ d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
772
+ })
773
+ });
774
+ var LayersIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", {
775
+ width: "18",
776
+ height: "18",
777
+ fill: "none",
778
+ stroke: "currentColor",
779
+ strokeLinecap: "round",
780
+ strokeLinejoin: "round",
781
+ strokeWidth: "2",
782
+ viewBox: "0 0 24 24",
783
+ children: [
784
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
785
+ d: "M12 2L2 7 12 12 22 7 12 2z"
786
+ }),
787
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
788
+ d: "M2 17L12 22 22 17"
789
+ }),
790
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
791
+ d: "M2 12L12 17 22 12"
792
+ })
793
+ ]
794
+ });
795
+ var InfoIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", {
796
+ width: "16",
797
+ height: "16",
798
+ viewBox: "0 0 24 24",
799
+ fill: "none",
800
+ stroke: "currentColor",
801
+ strokeWidth: "2",
802
+ strokeLinecap: "round",
803
+ strokeLinejoin: "round",
804
+ children: [
805
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", {
806
+ cx: "12",
807
+ cy: "12",
808
+ r: "10"
809
+ }),
810
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
811
+ x1: "12",
812
+ y1: "16",
813
+ x2: "12",
814
+ y2: "12"
815
+ }),
816
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
817
+ x1: "12",
818
+ y1: "8",
819
+ x2: "12.01",
820
+ y2: "8"
821
+ })
822
+ ]
823
+ });
824
+ var SlidersIcon = () => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", {
825
+ width: "18",
826
+ height: "18",
827
+ fill: "none",
828
+ stroke: "currentColor",
829
+ strokeLinecap: "round",
830
+ strokeLinejoin: "round",
831
+ strokeWidth: "2",
832
+ viewBox: "0 0 24 24",
833
+ children: [
834
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
835
+ d: "M4 21L4 14"
836
+ }),
837
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
838
+ d: "M4 10L4 3"
839
+ }),
840
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
841
+ d: "M12 21L12 12"
842
+ }),
843
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
844
+ d: "M12 8L12 3"
845
+ }),
846
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
847
+ d: "M20 21L20 16"
848
+ }),
849
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
850
+ d: "M20 12L20 3"
851
+ }),
852
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
853
+ d: "M1 14L7 14"
854
+ }),
855
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
856
+ d: "M9 8L15 8"
857
+ }),
858
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
859
+ d: "M17 16L23 16"
860
+ })
861
+ ]
862
+ });
863
+ function AttributionIcon() {
864
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
865
+ width: "14",
866
+ height: "14",
867
+ viewBox: "0 0 16 16",
868
+ style: { display: "inline-block" },
869
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
870
+ fillRule: "evenodd",
871
+ fill: "currentColor",
872
+ 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"
873
+ })
874
+ });
875
+ }
876
+ function TagIcon() {
877
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
878
+ width: "14",
879
+ height: "14",
880
+ viewBox: "0 0 16 16",
881
+ style: { display: "inline-block" },
882
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
883
+ fillRule: "evenodd",
884
+ fill: "currentColor",
885
+ 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"
886
+ })
887
+ });
888
+ }
889
+ function LicenseIcon() {
890
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
891
+ width: "14",
892
+ height: "14",
893
+ viewBox: "0 0 16 16",
894
+ style: { display: "inline-block" },
895
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
896
+ fillRule: "evenodd",
897
+ fill: "currentColor",
898
+ 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"
899
+ })
900
+ });
901
+ }
902
+ function EyeIcon() {
903
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
904
+ viewBox: "0 0 16 16",
905
+ width: "14",
906
+ height: "14",
907
+ style: { display: "inline-block" },
908
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
909
+ fillRule: "evenodd",
910
+ fill: "currentColor",
911
+ 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"
912
+ })
913
+ });
914
+ }
915
+ function ClockIcon() {
916
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
917
+ viewBox: "0 0 16 16",
918
+ width: "14",
919
+ height: "14",
920
+ style: { display: "inline-block" },
921
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
922
+ fillRule: "evenodd",
923
+ fill: "currentColor",
924
+ 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"
925
+ })
926
+ });
927
+ }
928
+ function DownloadIcon() {
929
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
930
+ viewBox: "0 0 16 16",
931
+ width: "16",
932
+ height: "16",
933
+ style: { display: "inline-block" },
934
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
935
+ fillRule: "evenodd",
936
+ fill: "currentColor",
937
+ 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"
938
+ })
939
+ });
940
+ }
941
+ function ZoomExtentIcon() {
942
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
943
+ viewBox: "0 0 24 24",
944
+ width: "16",
945
+ height: "16",
946
+ fill: "none",
947
+ stroke: "currentColor",
948
+ strokeWidth: "2",
949
+ strokeLinecap: "round",
950
+ strokeLinejoin: "round",
951
+ style: { display: "inline-block" },
952
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
953
+ 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"
954
+ })
955
+ });
956
+ }
957
+ function ShareIcon() {
958
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", {
959
+ viewBox: "0 0 24 24",
960
+ width: "16",
961
+ height: "16",
962
+ fill: "none",
963
+ stroke: "currentColor",
964
+ strokeWidth: "2",
965
+ strokeLinecap: "round",
966
+ strokeLinejoin: "round",
967
+ style: { display: "inline-block" },
968
+ children: [
969
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", {
970
+ cx: "18",
971
+ cy: "5",
972
+ r: "3"
973
+ }),
974
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", {
975
+ cx: "6",
976
+ cy: "12",
977
+ r: "3"
978
+ }),
979
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", {
980
+ cx: "18",
981
+ cy: "19",
982
+ r: "3"
983
+ }),
984
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
985
+ x1: "8.59",
986
+ y1: "13.51",
987
+ x2: "15.42",
988
+ y2: "17.49"
989
+ }),
990
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
991
+ x1: "15.41",
992
+ y1: "6.51",
993
+ x2: "8.59",
994
+ y2: "10.49"
995
+ })
996
+ ]
997
+ });
998
+ }
999
+ function GrabberIcon() {
1000
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
1001
+ viewBox: "0 0 16 16",
1002
+ width: "16",
1003
+ height: "16",
1004
+ style: { display: "inline-block" },
1005
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
1006
+ fillRule: "evenodd",
1007
+ 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"
1008
+ })
1009
+ });
1010
+ }
1011
+ function CrossHairIcon() {
1012
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", {
1013
+ style: { display: "inline-block" },
1014
+ width: "18",
1015
+ height: "18",
1016
+ viewBox: "0 0 24 24",
1017
+ fill: "none",
1018
+ stroke: "currentColor",
1019
+ strokeWidth: "2",
1020
+ strokeLinecap: "round",
1021
+ strokeLinejoin: "round",
1022
+ children: [
1023
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", {
1024
+ cx: "12",
1025
+ cy: "12",
1026
+ r: "10"
1027
+ }),
1028
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
1029
+ x1: "22",
1030
+ y1: "12",
1031
+ x2: "18",
1032
+ y2: "12"
1033
+ }),
1034
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
1035
+ x1: "6",
1036
+ y1: "12",
1037
+ x2: "2",
1038
+ y2: "12"
1039
+ }),
1040
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
1041
+ x1: "12",
1042
+ y1: "6",
1043
+ x2: "12",
1044
+ y2: "2"
1045
+ }),
1046
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", {
1047
+ x1: "12",
1048
+ y1: "22",
1049
+ x2: "12",
1050
+ y2: "18"
1051
+ })
1052
+ ]
1053
+ });
1054
+ }
1055
+ function DownIcon() {
1056
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
1057
+ width: "18",
1058
+ height: "18",
1059
+ viewBox: "0 0 24 24",
1060
+ fill: "none",
1061
+ stroke: "currentColor",
1062
+ strokeWidth: "2",
1063
+ strokeLinecap: "round",
1064
+ strokeLinejoin: "round",
1065
+ style: { display: "inline-block" },
1066
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", {
1067
+ points: "6 9 12 15 18 9"
1068
+ })
1069
+ });
1070
+ }
1071
+ function UpIcon() {
1072
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
1073
+ width: "18",
1074
+ height: "18",
1075
+ viewBox: "0 0 24 24",
1076
+ fill: "none",
1077
+ stroke: "currentColor",
1078
+ strokeWidth: "2",
1079
+ strokeLinecap: "round",
1080
+ strokeLinejoin: "round",
1081
+ style: { display: "inline-block" },
1082
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("polyline", {
1083
+ points: "18 15 12 9 6 15"
1084
+ })
1085
+ });
1086
+ }
1087
+
1088
+ // src/components/core/button.tsx
1089
+ var import_jsx_runtime3 = require("react/jsx-runtime");
1090
+ var Button = import_react2.default.forwardRef((props, ref) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", __spreadValues({
1091
+ ref,
1092
+ type: "button",
1093
+ className: import_twind2.tw`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`
1094
+ }, props)));
1095
+ var CloseButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", __spreadValues({
1096
+ className: import_twind2.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,
1097
+ children: "\u2715"
1098
+ }, props));
1099
+ var LayersButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", __spreadProps(__spreadValues({
1100
+ className: import_twind2.tw`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`
1101
+ }, props), {
1102
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LayersIcon, {})
1103
+ }));
1104
+ var InfobarButton = (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", __spreadProps(__spreadValues({
1105
+ className: import_twind2.tw`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`
1106
+ }, props), {
1107
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InfoIcon, {})
1108
+ }));
1109
+
1110
+ // src/components/core/input.tsx
1111
+ var import_twind3 = require("twind");
1112
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1113
+ var SelectInput = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", {
1114
+ children: [
1115
+ props.label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", {
1116
+ className: import_twind3.tw`text-gray-700`,
1117
+ htmlFor: props.name,
1118
+ children: props.label
1119
+ }),
1120
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("select", __spreadValues({
1121
+ id: props.name,
1122
+ name: props.name,
1123
+ className: import_twind3.tw`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`,
1124
+ style: {
1125
+ 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")`,
1126
+ backgroundPosition: "right 0.75rem center",
1127
+ backgroundSize: "16px 12px",
1128
+ backgroundRepeat: "no-repeat"
1129
+ }
1130
+ }, props))
1131
+ ]
1132
+ });
1133
+ var SearchInput = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", {
1134
+ className: "relative",
1135
+ children: [
1136
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", {
1137
+ className: import_twind3.tw`absolute inset-y-0 left-0 flex items-center pl-3`,
1138
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SearchIcon, {})
1139
+ }),
1140
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", __spreadValues({
1141
+ type: "search",
1142
+ className: import_twind3.tw`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`
1143
+ }, props))
1144
+ ]
1145
+ });
1146
+ var CheckboxInput = (props) => props.isLoading ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", {
1147
+ width: "20px",
1148
+ height: "20px",
1149
+ viewBox: "0 0 20 20",
1150
+ version: "1.1",
1151
+ className: import_twind3.tw`inline text-gray-200 animate-spin dark:text-gray-600`,
1152
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("g", {
1153
+ stroke: "none",
1154
+ strokeWidth: "1",
1155
+ fill: "none",
1156
+ fillRule: "evenodd",
1157
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("g", {
1158
+ fill: "#212121",
1159
+ fillRule: "nonzero",
1160
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", {
1161
+ 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"
1162
+ })
1163
+ })
1164
+ })
1165
+ }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", {
1166
+ type: "checkbox",
1167
+ className: import_twind3.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,
1168
+ name: props.name,
1169
+ checked: props.checked,
1170
+ onChange: props.onChange
1171
+ });
1172
+
1173
+ // src/components/core/tabs.tsx
1174
+ var import_tabs = require("@bumaga/tabs");
1175
+ var import_clsx = __toESM(require("clsx"));
1176
+ var import_twind4 = require("twind");
1177
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1178
+ var IconTab = ({ children, icon }) => {
1179
+ const { onClick, isActive } = (0, import_tabs.useTabState)();
1180
+ const classes = (0, import_clsx.default)([
1181
+ "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",
1182
+ {
1183
+ "text-blue-600 border-blue-500": isActive,
1184
+ "text-gray-700 border-gray-300 hover:border-gray-400": !isActive
1185
+ }
1186
+ ]);
1187
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("button", {
1188
+ className: (0, import_twind4.tw)(classes),
1189
+ onClick,
1190
+ children: [
1191
+ icon,
1192
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", {
1193
+ className: import_twind4.tw`ml-2 text-base`,
1194
+ children
1195
+ })
1196
+ ]
1197
+ });
1198
+ };
1199
+ var Panel = ({ children }) => {
1200
+ const isActive = (0, import_tabs.usePanelState)();
1201
+ return isActive ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
1202
+ className: import_twind4.tw`w-full flex flex-grow-1 overflow-auto`,
1203
+ children
1204
+ }) : null;
1205
+ };
1206
+ var TabHeader = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
1207
+ className: import_twind4.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,
1208
+ children
1209
+ });
1210
+
1211
+ // src/components/infobar/content.tsx
1212
+ var import_naksha_commons4 = require("@biodiv-platform/naksha-commons");
1213
+ var import_twind6 = require("twind");
1214
+
1215
+ // src/components/sidebar/settings/layer-selection.tsx
1216
+ var import_naksha_commons3 = require("@biodiv-platform/naksha-commons");
1217
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1218
+ function LayerSelection({ hideLabel }) {
1219
+ const {
1220
+ layer: { selectionStyle, handleSelectStyle }
1221
+ } = useLayers();
1222
+ const { t } = (0, import_naksha_commons3.useT)();
1223
+ const handleOnSelectionStyleChange = (e) => {
1224
+ handleSelectStyle(e.target.value);
1225
+ };
1226
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SelectInput, {
1227
+ name: "layer_selection",
1228
+ label: hideLabel ? null : t("layer_selection"),
1229
+ defaultValue: selectionStyle,
1230
+ onChange: handleOnSelectionStyleChange,
1231
+ children: Object.values(SELECTION_STYLE).map((ss) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", {
1232
+ value: ss,
1233
+ children: t(ss)
1234
+ }, ss))
1235
+ });
1236
+ }
1237
+
1238
+ // src/components/infobar/infobar-panel.tsx
1239
+ var import_clsx2 = __toESM(require("clsx"));
1240
+ var import_react3 = require("react");
1241
+ var import_twind5 = require("twind");
1242
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1243
+ function InfoBarPanel({ data: payload }) {
1244
+ const [isOpen, setIsOpen] = (0, import_react3.useState)(true);
1245
+ const [layerInfo, setLayerInfo] = (0, import_react3.useState)({
1246
+ title: payload.sourceLayer,
1247
+ properties: []
1248
+ });
1249
+ const { layer, mp, query: { clickedLngLat } } = useLayers();
1250
+ const getPropertyData = () => __async(this, null, function* () {
1251
+ var _a, _b, _c, _d, _e, _f;
1252
+ let properties;
1253
+ const currentLayer = layer.selectedLayers.find(
1254
+ (l) => l.id === (payload.sourceLayer || payload.source)
1255
+ );
1256
+ if (currentLayer.layerType.toLowerCase() === "raster") {
1257
+ const { data } = yield axGexGetRasterInfoWithLonLat(
1258
+ (_a = mp.geoserver) == null ? void 0 : _a.endpoint,
1259
+ (_b = mp.geoserver) == null ? void 0 : _b.workspace,
1260
+ {
1261
+ bbox: payload.bbox.toString(),
1262
+ query_layers: `${(_c = mp.geoserver) == null ? void 0 : _c.workspace}:${currentLayer.id}`,
1263
+ layers: `${(_d = mp.geoserver) == null ? void 0 : _d.workspace}:${currentLayer.id}`
1264
+ }
1265
+ );
1266
+ properties = (data == null ? void 0 : data.features[0]) ? Object.entries((_e = data.features[0]) == null ? void 0 : _e.properties).map(([v, k]) => [
1267
+ k || "-"
1268
+ ]) : [];
1269
+ } else {
1270
+ properties = Object.entries(((_f = currentLayer == null ? void 0 : currentLayer.data) == null ? void 0 : _f.propertyMap) || {}).map(
1271
+ ([k, v]) => {
1272
+ var _a2;
1273
+ return [v, (_a2 = payload == null ? void 0 : payload.properties) == null ? void 0 : _a2[k]];
1274
+ }
1275
+ );
1276
+ }
1277
+ setLayerInfo({ title: currentLayer.title, properties });
1278
+ });
1279
+ (0, import_react3.useEffect)(() => {
1280
+ getPropertyData();
1281
+ }, [clickedLngLat]);
1282
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
1283
+ className: import_twind5.tw`bg-gray-100 rounded-lg`,
1284
+ children: [
1285
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("button", {
1286
+ className: (0, import_twind5.tw)(
1287
+ (0, import_clsx2.default)([
1288
+ `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`,
1289
+ { "bg-gray-200 rounded-t-lg": isOpen, "rounded-lg": !isOpen }
1290
+ ])
1291
+ ),
1292
+ onClick: () => setIsOpen(!isOpen),
1293
+ children: [
1294
+ layerInfo.title,
1295
+ " ",
1296
+ isOpen ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(UpIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DownIcon, {})
1297
+ ]
1298
+ }),
1299
+ isOpen && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
1300
+ className: import_twind5.tw`px-4 py-3 flex flex-col gap-3`,
1301
+ children: layerInfo.properties.map(([k, v], index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", {
1302
+ children: [
1303
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
1304
+ className: import_twind5.tw`text-gray-600`,
1305
+ children: k
1306
+ }),
1307
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
1308
+ children: v
1309
+ })
1310
+ ]
1311
+ }, k + v + index))
1312
+ })
1313
+ ]
1314
+ });
1315
+ }
1316
+
1317
+ // src/components/infobar/content.tsx
1318
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1319
+ function InfoBarContent({ onClose }) {
1320
+ var _a;
1321
+ const {
1322
+ layer: { selectedFeatures, selectedLayers, selectionStyle }
1323
+ } = useLayers();
1324
+ const { t } = (0, import_naksha_commons4.useT)();
1325
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", {
1326
+ className: import_twind6.tw`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`,
1327
+ children: [
1328
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", {
1329
+ className: "flex w-full",
1330
+ children: [
1331
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", {
1332
+ className: import_twind6.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,
1333
+ children: [
1334
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CrossHairIcon, {}),
1335
+ " ",
1336
+ t("infobar")
1337
+ ]
1338
+ }),
1339
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseButton, {
1340
+ onClick: onClose
1341
+ })
1342
+ ]
1343
+ }),
1344
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
1345
+ className: import_twind6.tw`bg-gray-100 p-4 flex-shrink-0 rt`,
1346
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(LayerSelection, {
1347
+ hideLabel: true
1348
+ })
1349
+ }),
1350
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
1351
+ className: import_twind6.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,
1352
+ children: (_a = selectedFeatures.flat(1)) == null ? void 0 : _a.map((data) => {
1353
+ var _a2;
1354
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(InfoBarPanel, {
1355
+ data
1356
+ }, ((_a2 = selectedLayers == null ? void 0 : selectedLayers[0]) == null ? void 0 : _a2.source.type) === "raster" || selectionStyle === SELECTION_STYLE.ALL ? data == null ? void 0 : data.sourceLayer : (data == null ? void 0 : data.sourceLayer) + (data == null ? void 0 : data.properties[PROPERTY_ID]));
1357
+ })
1358
+ })
1359
+ ]
1360
+ });
1361
+ }
1362
+
1363
+ // src/components/infobar/index.tsx
1364
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1365
+ function InfoBar() {
1366
+ var _a;
1367
+ const { layer, isInfoBarOpen, setIsInfoBarOpen } = useLayers();
1368
+ if (!((_a = layer.selectedFeatures) == null ? void 0 : _a.length))
1369
+ return null;
1370
+ const toggleOpen = () => setIsInfoBarOpen(!isInfoBarOpen);
1371
+ return isInfoBarOpen ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfoBarContent, {
1372
+ onClose: toggleOpen
1373
+ }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(InfobarButton, {
1374
+ onClick: toggleOpen
1375
+ });
1376
+ }
1377
+
1378
+ // src/components/sidebar/index.tsx
1379
+ var import_react9 = require("react");
1380
+ var import_maplibre2 = require("react-map-gl/maplibre");
1381
+
1382
+ // src/components/sidebar/tabs.tsx
1383
+ var import_naksha_commons12 = require("@biodiv-platform/naksha-commons");
1384
+ var import_twind18 = require("twind");
1385
+
1386
+ // src/components/sidebar/layers/index.tsx
1387
+ var import_twind15 = require("twind");
1388
+
1389
+ // src/components/sidebar/layers/layer-list.tsx
1390
+ var import_react8 = __toESM(require("react"));
1391
+ var import_react_virtual = require("react-virtual");
1392
+ var import_react_virtualized_auto_sizer = __toESM(require("react-virtualized-auto-sizer"));
1393
+ var import_twind13 = require("twind");
1394
+
1395
+ // src/components/sidebar/common/layer-item.tsx
1396
+ var import_naksha_commons8 = require("@biodiv-platform/naksha-commons");
1397
+ var import_react7 = require("react");
1398
+ var import_react_sortable_hoc = require("react-sortable-hoc");
1399
+ var import_react_web_share = require("react-web-share");
1400
+ var import_twind12 = require("twind");
1401
+
1402
+ // src/components/core/highlighter.tsx
1403
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1404
+ var Highlighted = ({ text = "", highlight = "" }) => {
1405
+ if (!highlight.trim()) {
1406
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {
1407
+ children: text
1408
+ });
1409
+ }
1410
+ const regex = new RegExp(`(${highlight})`, "gi");
1411
+ const parts = text.split(regex);
1412
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {
1413
+ children: parts.filter((part) => part).map(
1414
+ (part, i) => regex.test(part) ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("mark", {
1415
+ children: part
1416
+ }, i) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", {
1417
+ children: part
1418
+ }, i)
1419
+ )
1420
+ });
1421
+ };
1422
+
1423
+ // src/components/sidebar/common/grid-legend.tsx
1424
+ var import_twind8 = require("twind");
1425
+
1426
+ // src/components/sidebar/common/moreless.tsx
1427
+ var import_naksha_commons5 = require("@biodiv-platform/naksha-commons");
1428
+ var import_react4 = require("react");
1429
+ var import_twind7 = require("twind");
1430
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1431
+ function MoreLess({ children }) {
1432
+ const [showMore, setShowMore] = (0, import_react4.useState)(false);
1433
+ const { t } = (0, import_naksha_commons5.useT)();
1434
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", {
1435
+ children: [
1436
+ showMore && children,
1437
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("button", {
1438
+ onClick: () => setShowMore(!showMore),
1439
+ className: import_twind7.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,
1440
+ children: showMore ? t("less") : t("legend")
1441
+ })
1442
+ ]
1443
+ });
1444
+ }
1445
+
1446
+ // src/components/sidebar/common/grid-legend.tsx
1447
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1448
+ function GridLegend({ item }) {
1449
+ const { layer } = useLayers();
1450
+ const legendInfo = layer.gridLegends[item.id];
1451
+ if (!legendInfo)
1452
+ return null;
1453
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MoreLess, {
1454
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("ul", {
1455
+ style: { margin: 0, padding: 0 },
1456
+ children: [
1457
+ legendInfo == null ? void 0 : legendInfo.stops.map(([stop, color], index, stopsArr) => {
1458
+ const prevStop = (stopsArr[index - 1] || [0])[0];
1459
+ if (prevStop === stop)
1460
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", {}, color);
1461
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", {
1462
+ className: import_twind8.tw`flex gap-2 items-center mb-1`,
1463
+ children: [
1464
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", {
1465
+ viewBox: "0 0 24 24",
1466
+ height: "14",
1467
+ width: "14",
1468
+ focusable: "false",
1469
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", {
1470
+ cx: "12",
1471
+ fill: color,
1472
+ cy: "12",
1473
+ r: "12",
1474
+ stroke: "none"
1475
+ })
1476
+ }),
1477
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", {
1478
+ children: [
1479
+ prevStop,
1480
+ " - ",
1481
+ stop
1482
+ ]
1483
+ })
1484
+ ]
1485
+ }, color);
1486
+ }),
1487
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", {
1488
+ children: [
1489
+ "1 Square = ",
1490
+ legendInfo == null ? void 0 : legendInfo.squareSize,
1491
+ " x ",
1492
+ legendInfo == null ? void 0 : legendInfo.squareSize,
1493
+ " km"
1494
+ ]
1495
+ })
1496
+ ]
1497
+ })
1498
+ });
1499
+ }
1500
+
1501
+ // src/components/sidebar/common/info-popover.tsx
1502
+ var import_naksha_commons6 = require("@biodiv-platform/naksha-commons");
1503
+ var import_react5 = require("react");
1504
+ var import_react_tiny_popover = require("react-tiny-popover");
1505
+ var import_twind9 = require("twind");
1506
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1507
+ var LayerInfoLine = ({
1508
+ icon,
1509
+ name,
1510
+ title,
1511
+ link,
1512
+ children
1513
+ }) => {
1514
+ const content = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", {
1515
+ children: children || "-"
1516
+ });
1517
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", {
1518
+ className: import_twind9.tw`flex gap-3 text-sm text-gray-600 break-all`,
1519
+ title: name && title && `${name}: ${title}`,
1520
+ children: [
1521
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", {
1522
+ children: icon
1523
+ }),
1524
+ link ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("a", {
1525
+ className: import_twind9.tw`text-blue-700 focus:outline-none focus:ring`,
1526
+ target: "_blank",
1527
+ rel: "noopener",
1528
+ href: link,
1529
+ children: content
1530
+ }) : content
1531
+ ]
1532
+ });
1533
+ };
1534
+ function InfoPopover({ item, containerStyle }) {
1535
+ var _a;
1536
+ const { t } = (0, import_naksha_commons6.useT)();
1537
+ const { layer, mp } = useLayers();
1538
+ const license = item.license || "CC-BY";
1539
+ const createdOn = (item == null ? void 0 : item.createdDate) && new Date(item.createdDate).toLocaleDateString();
1540
+ const tags = (_a = item.tags) == null ? void 0 : _a.join(", ");
1541
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", {
1542
+ className: import_twind9.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,
1543
+ style: containerStyle,
1544
+ children: [
1545
+ mp.managePublishing && item.layerStatus && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(LayerInfoLine, {
1546
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EyeIcon, {}),
1547
+ name: t("visiblity"),
1548
+ title: item.layerStatus,
1549
+ children: [
1550
+ item.layerStatus,
1551
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", {
1552
+ className: import_twind9.tw`text-blue-600 focus:outline-none ml-4`,
1553
+ onClick: () => layer.togglePublish(item.id, item == null ? void 0 : item.layerStatus),
1554
+ children: t("toggle")
1555
+ }),
1556
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("button", {
1557
+ className: import_twind9.tw`text-red-600 focus:outline-none ml-4`,
1558
+ onClick: () => layer.delete(item.id, t("are_you_sure")),
1559
+ children: t("delete")
1560
+ })
1561
+ ]
1562
+ }),
1563
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LayerInfoLine, {
1564
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AttributionIcon, {}),
1565
+ link: item.url,
1566
+ name: t("uploader"),
1567
+ title: item.createdBy,
1568
+ children: item.createdBy
1569
+ }),
1570
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LayerInfoLine, {
1571
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AttributionIcon, {}),
1572
+ link: item.url,
1573
+ name: t("created_by"),
1574
+ title: item.attribution,
1575
+ children: item.attribution
1576
+ }),
1577
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LayerInfoLine, {
1578
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ClockIcon, {}),
1579
+ name: t("created_on"),
1580
+ title: createdOn,
1581
+ children: createdOn
1582
+ }),
1583
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LayerInfoLine, {
1584
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TagIcon, {}),
1585
+ name: t("tags"),
1586
+ title: tags,
1587
+ children: tags
1588
+ }),
1589
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LayerInfoLine, {
1590
+ name: t("license"),
1591
+ title: license,
1592
+ link: license && import_naksha_commons6.LICENSES[license],
1593
+ icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(LicenseIcon, {}),
1594
+ children: license
1595
+ })
1596
+ ]
1597
+ });
1598
+ }
1599
+ var PopoverWrapper = ({ item }) => {
1600
+ const [isPopoverOpen, setIsPopoverOpen] = (0, import_react5.useState)(false);
1601
+ const togglePopover = () => setIsPopoverOpen(!isPopoverOpen);
1602
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_tiny_popover.Popover, {
1603
+ isOpen: isPopoverOpen,
1604
+ padding: 10,
1605
+ positions: ["right"],
1606
+ containerStyle: { zIndex: 99 },
1607
+ onClickOutside: togglePopover,
1608
+ content: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InfoPopover, {
1609
+ item
1610
+ }),
1611
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Button, {
1612
+ onClick: togglePopover,
1613
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InfoIcon, {}),
1614
+ title: "Information"
1615
+ })
1616
+ });
1617
+ };
1618
+
1619
+ // src/components/sidebar/common/layer-item-style.tsx
1620
+ var import_twind11 = require("twind");
1621
+
1622
+ // src/components/sidebar/common/style-legend.tsx
1623
+ var import_react6 = require("react");
1624
+ var import_naksha_commons7 = require("@biodiv-platform/naksha-commons");
1625
+ var import_twind10 = require("twind");
1626
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1627
+ function StyleLegend({ item }) {
1628
+ var _a;
1629
+ const [showImage, setShowImage] = (0, import_react6.useState)(true);
1630
+ const { mp } = useLayers();
1631
+ const { t } = (0, import_naksha_commons7.useT)();
1632
+ const legendStyles = (0, import_react6.useMemo)(
1633
+ () => {
1634
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1635
+ return ((_f = (_e = (_d = (_c = (_b = (_a2 = item == null ? void 0 : item.data) == null ? void 0 : _a2.styles) == null ? void 0 : _b[item.data.styleIndex]) == null ? void 0 : _c.colors) == null ? void 0 : _d.paint) == null ? void 0 : _e["fill-color"]) == null ? void 0 : _f.stops) || ((_l = (_k = (_j = (_i = (_h = (_g = item == null ? void 0 : item.data) == null ? void 0 : _g.styles) == null ? void 0 : _h[item.data.styleIndex]) == null ? void 0 : _i.colors) == null ? void 0 : _j.paint) == null ? void 0 : _k["circle-color"]) == null ? void 0 : _l.stops) || [];
1636
+ },
1637
+ [item]
1638
+ );
1639
+ const vectorLegend = () => {
1640
+ return legendStyles.map(([title, color]) => /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("li", {
1641
+ className: import_twind10.tw`flex gap-2 items-center mb-1`,
1642
+ children: [
1643
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", {
1644
+ viewBox: "0 0 24 24",
1645
+ height: "14",
1646
+ width: "14",
1647
+ focusable: "false",
1648
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("circle", {
1649
+ cx: "12",
1650
+ fill: color,
1651
+ cy: "12",
1652
+ r: "12",
1653
+ stroke: "none"
1654
+ })
1655
+ }),
1656
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {
1657
+ children: title
1658
+ })
1659
+ ]
1660
+ }, color));
1661
+ };
1662
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("ul", {
1663
+ style: { margin: 0, padding: 0 },
1664
+ children: item.layerType !== "RASTER" ? vectorLegend() : showImage ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("li", {
1665
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("img", {
1666
+ style: { margin: "5px" },
1667
+ onError: () => setShowImage(false),
1668
+ src: `${(_a = mp == null ? void 0 : mp.geoserver) == null ? void 0 : _a.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${item.id}`
1669
+ })
1670
+ }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("div", {
1671
+ children: t("raster_style_not_found")
1672
+ })
1673
+ });
1674
+ }
1675
+
1676
+ // src/components/sidebar/common/layer-item-style.tsx
1677
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1678
+ function LayerItemStyle({ item }) {
1679
+ var _a, _b;
1680
+ if (!((_a = item.data) == null ? void 0 : _a.styles))
1681
+ return null;
1682
+ const { layer } = useLayers();
1683
+ const onStyleChange = (e) => {
1684
+ layer.updateStyle(item.id, Number(e.target.value));
1685
+ };
1686
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", {
1687
+ className: import_twind11.tw`flex flex-col gap-4 pt-2`,
1688
+ children: [
1689
+ item.layerType !== "RASTER" && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SelectInput, {
1690
+ onChange: onStyleChange,
1691
+ children: (_b = item.data) == null ? void 0 : _b.styles.map((opt, idx) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", {
1692
+ value: idx,
1693
+ children: opt.styleTitle
1694
+ }, idx))
1695
+ }),
1696
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(MoreLess, {
1697
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(StyleLegend, {
1698
+ item
1699
+ })
1700
+ })
1701
+ ]
1702
+ });
1703
+ }
1704
+
1705
+ // src/components/sidebar/common/layer-item.tsx
1706
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1707
+ var DragHandle = (0, import_react_sortable_hoc.SortableHandle)(() => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", {
1708
+ className: import_twind12.tw`mt-1 w-6 text-center cursor-move`,
1709
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GrabberIcon, {})
1710
+ }));
1711
+ function LayerItem({ item, extended }) {
1712
+ const { t } = (0, import_naksha_commons8.useT)();
1713
+ const { layer, query, mp, query: { setClickedLngLat }, setIsInfoBarOpen } = useLayers();
1714
+ const [isAdded, setIsAdded] = (0, import_react7.useState)(layer.selectedIds.includes(item.id));
1715
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(false);
1716
+ const shareData = (0, import_react7.useMemo)(
1717
+ () => mp.canLayerShare ? {
1718
+ url: `${window.location.href.split("?")[0]}?layers=${item.id}`,
1719
+ title: item.title
1720
+ } : void 0,
1721
+ [item.id]
1722
+ );
1723
+ const onToggleLayer = () => __async(this, null, function* () {
1724
+ setIsLoading(true);
1725
+ setIsInfoBarOpen(true);
1726
+ layer.setSelectedFeatures([]);
1727
+ setClickedLngLat(null);
1728
+ yield layer.toggle({ layerId: item.id, add: !isAdded });
1729
+ setIsAdded(!isAdded);
1730
+ setIsLoading(false);
1731
+ });
1732
+ const onDownloadLayer = () => __async(this, null, function* () {
1733
+ yield axDownloadLayer(
1734
+ mp.nakshaApiEndpoint,
1735
+ mp.nakshaEndpointToken,
1736
+ item.id,
1737
+ item.title
1738
+ );
1739
+ mp == null ? void 0 : mp.onLayerDownload(item.id);
1740
+ });
1741
+ const handleOnZoom = () => layer.zoomToExtent(item.id);
1742
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", {
1743
+ className: import_twind12.tw`z-20 p-3 bg-white`,
1744
+ style: { borderTop: "1px solid #e5e7eb" },
1745
+ children: [
1746
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", {
1747
+ className: import_twind12.tw`flex gap-3`,
1748
+ children: [
1749
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", {
1750
+ className: import_twind12.tw`flex-shrink-0`,
1751
+ children: [
1752
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CheckboxInput, {
1753
+ name: item.id,
1754
+ checked: isAdded,
1755
+ onChange: onToggleLayer,
1756
+ isLoading
1757
+ }),
1758
+ extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DragHandle, {})
1759
+ ]
1760
+ }),
1761
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("img", {
1762
+ className: import_twind12.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,
1763
+ src: item.thumbnail || FALLBACK_THUMB
1764
+ }),
1765
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", {
1766
+ children: [
1767
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", {
1768
+ title: item.title,
1769
+ className: import_twind12.tw`mb-1 leading-tight`,
1770
+ style: overflowStyle,
1771
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Highlighted, {
1772
+ text: item.title,
1773
+ highlight: query.term
1774
+ })
1775
+ }),
1776
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", {
1777
+ title: item.description,
1778
+ className: import_twind12.tw`text-gray-600 text-sm`,
1779
+ style: overflowStyle2,
1780
+ children: item.description
1781
+ })
1782
+ ]
1783
+ })
1784
+ ]
1785
+ }),
1786
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", {
1787
+ className: import_twind12.tw`flex justify-between`,
1788
+ children: [
1789
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(Button, {
1790
+ onClick: onDownloadLayer,
1791
+ disabled: !item.isDownloadable,
1792
+ children: [
1793
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(DownloadIcon, {}),
1794
+ " ",
1795
+ t("download")
1796
+ ]
1797
+ }),
1798
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", {
1799
+ className: import_twind12.tw`flex gap-3`,
1800
+ children: [
1801
+ shareData && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_web_share.RWebShare, {
1802
+ data: shareData,
1803
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, {
1804
+ title: "Share",
1805
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ShareIcon, {})
1806
+ })
1807
+ }),
1808
+ extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Button, {
1809
+ onClick: handleOnZoom,
1810
+ title: "Zoom To Extent",
1811
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ZoomExtentIcon, {})
1812
+ }),
1813
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(PopoverWrapper, {
1814
+ item
1815
+ })
1816
+ ]
1817
+ })
1818
+ ]
1819
+ }),
1820
+ extended && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(LayerItemStyle, {
1821
+ item
1822
+ }),
1823
+ extended && item.source.type === "grid" && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(GridLegend, {
1824
+ item
1825
+ })
1826
+ ]
1827
+ });
1828
+ }
1829
+
1830
+ // src/components/sidebar/layers/layer-list.tsx
1831
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1832
+ function LayerList() {
1833
+ const { layer, query } = useLayers();
1834
+ const filteredLayers = (0, import_react8.useMemo)(
1835
+ () => query.term ? layer.all.filter(
1836
+ (_l) => _l.title.toLowerCase().includes(query.term.toLowerCase())
1837
+ ) : layer.all,
1838
+ [layer.all, query.term]
1839
+ );
1840
+ const parentRef = import_react8.default.useRef();
1841
+ const rowVirtualizer = (0, import_react_virtual.useVirtual)({
1842
+ size: filteredLayers.length,
1843
+ parentRef
1844
+ });
1845
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
1846
+ className: import_twind13.tw`flex-grow-1 relative`,
1847
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_virtualized_auto_sizer.default, {
1848
+ disableWidth: true,
1849
+ children: (p) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
1850
+ ref: parentRef,
1851
+ className: "List",
1852
+ style: { height: p.height, overflow: "auto" },
1853
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
1854
+ style: {
1855
+ height: rowVirtualizer.totalSize,
1856
+ width: "100%",
1857
+ position: "relative"
1858
+ },
1859
+ children: rowVirtualizer.virtualItems.map((virtualRow) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
1860
+ ref: virtualRow.measureRef,
1861
+ className: import_twind13.tw`absolute top-0 left-0 w-full`,
1862
+ style: { transform: `translateY(${virtualRow.start}px)` },
1863
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
1864
+ style: { height: 146 },
1865
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(LayerItem, {
1866
+ item: filteredLayers[virtualRow.index]
1867
+ })
1868
+ })
1869
+ }, virtualRow.index))
1870
+ })
1871
+ })
1872
+ })
1873
+ });
1874
+ }
1875
+
1876
+ // src/components/sidebar/layers/search.tsx
1877
+ var import_naksha_commons9 = require("@biodiv-platform/naksha-commons");
1878
+ var import_twind14 = require("twind");
1879
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1880
+ function LayerSearch() {
1881
+ const { t } = (0, import_naksha_commons9.useT)();
1882
+ const { query } = useLayers();
1883
+ const handleOnSearchChange = (e) => query.setTerm(e.target.value);
1884
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", {
1885
+ className: import_twind14.tw`flex-shrink-0 border-b-2 p-4`,
1886
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SearchInput, {
1887
+ name: "lyr_search",
1888
+ placeholder: t("find_layer_by_name"),
1889
+ onChange: handleOnSearchChange
1890
+ })
1891
+ });
1892
+ }
1893
+
1894
+ // src/components/sidebar/layers/index.tsx
1895
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1896
+ function LayersTabPanel() {
1897
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", {
1898
+ className: import_twind15.tw`flex flex-col w-full`,
1899
+ children: [
1900
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LayerSearch, {}),
1901
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LayerList, {})
1902
+ ]
1903
+ });
1904
+ }
1905
+
1906
+ // src/utils/array-move.ts
1907
+ function arrayMoveMutable(array, fromIndex, toIndex) {
1908
+ const startIndex = fromIndex < 0 ? array.length + fromIndex : fromIndex;
1909
+ if (startIndex >= 0 && startIndex < array.length) {
1910
+ const endIndex = toIndex < 0 ? array.length + toIndex : toIndex;
1911
+ const [item] = array.splice(fromIndex, 1);
1912
+ array.splice(endIndex, 0, item);
1913
+ }
1914
+ }
1915
+ function arrayMoveImmutable(array, fromIndex, toIndex) {
1916
+ array = [...array];
1917
+ arrayMoveMutable(array, fromIndex, toIndex);
1918
+ return array;
1919
+ }
1920
+
1921
+ // src/components/sidebar/selected/selected-item-list.tsx
1922
+ var import_react_sortable_hoc2 = require("react-sortable-hoc");
1923
+ var import_jsx_runtime20 = require("react/jsx-runtime");
1924
+ var SelectedItem = (0, import_react_sortable_hoc2.SortableElement)(({ item, extended }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(LayerItem, {
1925
+ item,
1926
+ extended
1927
+ }));
1928
+ var SelectedItemList = (0, import_react_sortable_hoc2.SortableContainer)(({ layerList }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", {
1929
+ children: layerList.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(SelectedItem, {
1930
+ index,
1931
+ item,
1932
+ extended: true
1933
+ }, item.id))
1934
+ }));
1935
+
1936
+ // src/components/sidebar/selected/index.tsx
1937
+ var import_naksha_commons10 = require("@biodiv-platform/naksha-commons");
1938
+ var import_twind16 = require("twind");
1939
+ var import_jsx_runtime21 = require("react/jsx-runtime");
1940
+ function SelectedTabPanel() {
1941
+ const { layer } = useLayers();
1942
+ const { t } = (0, import_naksha_commons10.useT)();
1943
+ const onSortEnd = ({ oldIndex, newIndex }) => {
1944
+ layer.setSelectedIds(
1945
+ arrayMoveImmutable(layer.selectedIds, oldIndex, newIndex)
1946
+ );
1947
+ };
1948
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", {
1949
+ className: import_twind16.tw`flex flex-col gap-3 w-full`,
1950
+ children: [
1951
+ layer.selectedIds.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", {
1952
+ className: import_twind16.tw`p-3 pb-0`,
1953
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(Button, {
1954
+ onClick: () => layer.clearAll(),
1955
+ children: [
1956
+ "\u2715 ",
1957
+ t("clear")
1958
+ ]
1959
+ })
1960
+ }),
1961
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(SelectedItemList, {
1962
+ layerList: layer.selectedLayers,
1963
+ useDragHandle: true,
1964
+ onSortEnd
1965
+ })
1966
+ ]
1967
+ });
1968
+ }
1969
+
1970
+ // src/components/sidebar/settings/index.tsx
1971
+ var import_naksha_commons11 = require("@biodiv-platform/naksha-commons");
1972
+ var import_twind17 = require("twind");
1973
+ var import_jsx_runtime22 = require("react/jsx-runtime");
1974
+ function SettingsTabPanel() {
1975
+ const { layer } = useLayers();
1976
+ const { t } = (0, import_naksha_commons11.useT)();
1977
+ const handleOnStyleChange = (e) => layer.setMapStyle(e.target.value);
1978
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", {
1979
+ className: import_twind17.tw`w-full p-4 flex flex-col gap-4`,
1980
+ children: [
1981
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(SelectInput, {
1982
+ name: "base_style",
1983
+ label: t("base_style"),
1984
+ defaultValue: layer.mapStyle,
1985
+ onChange: handleOnStyleChange,
1986
+ children: import_naksha_commons11.defaultMapStyles.map((ms) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("option", {
1987
+ value: ms.style,
1988
+ children: ms.text
1989
+ }, ms.key))
1990
+ }),
1991
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(LayerSelection, {})
1992
+ ]
1993
+ });
1994
+ }
1995
+
1996
+ // src/components/sidebar/tabs.tsx
1997
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1998
+ function SidebarTabs({ onClose }) {
1999
+ const { t } = (0, import_naksha_commons12.useT)();
2000
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", {
2001
+ className: import_twind18.tw`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`,
2002
+ children: [
2003
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(CloseButton, {
2004
+ onClick: onClose
2005
+ }),
2006
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", {
2007
+ className: import_twind18.tw`flex flex-col h-full`,
2008
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_tabs.Tabs, {
2009
+ children: [
2010
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(TabHeader, {
2011
+ children: [
2012
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconTab, {
2013
+ icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersIcon, {}),
2014
+ children: t("layers")
2015
+ }),
2016
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconTab, {
2017
+ icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersIcon, {}),
2018
+ children: t("selected")
2019
+ }),
2020
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(IconTab, {
2021
+ icon: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SlidersIcon, {}),
2022
+ children: t("settings")
2023
+ })
2024
+ ]
2025
+ }),
2026
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Panel, {
2027
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(LayersTabPanel, {})
2028
+ }),
2029
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Panel, {
2030
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SelectedTabPanel, {})
2031
+ }),
2032
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Panel, {
2033
+ children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SettingsTabPanel, {})
2034
+ })
2035
+ ]
2036
+ })
2037
+ })
2038
+ ]
2039
+ });
2040
+ }
2041
+
2042
+ // src/components/sidebar/index.tsx
2043
+ var import_jsx_runtime24 = require("react/jsx-runtime");
2044
+ function Sidebar() {
2045
+ const { mp, layer } = useLayers();
2046
+ const [isOpen, setIsOpen] = (0, import_react9.useState)(mp.showToC);
2047
+ const { mapl } = (0, import_maplibre2.useMap)();
2048
+ const toggleOpen = () => setIsOpen(!isOpen);
2049
+ function loadToC() {
2050
+ return __async(this, null, function* () {
2051
+ const _layers = yield axGetGeoserverLayers(
2052
+ mp.nakshaEndpointToken,
2053
+ mp.nakshaApiEndpoint,
2054
+ mp.geoserver,
2055
+ mp.selectedLayers
2056
+ );
2057
+ const _newLayers = [...mp.layers || [], ..._layers];
2058
+ layer.setAll(_newLayers);
2059
+ if (layer.selectedIds.length) {
2060
+ const _layer = _newLayers.find((l) => l.id === layer.selectedIds[0]);
2061
+ (_layer == null ? void 0 : _layer.bbox) && (mapl == null ? void 0 : mapl.fitBounds(_layer.bbox, { padding: 40, duration: 1e3 }));
2062
+ }
2063
+ });
2064
+ }
2065
+ (0, import_react9.useEffect)(() => {
2066
+ if (mapl && mp.loadToC) {
2067
+ loadToC();
2068
+ }
2069
+ }, [mapl]);
2070
+ return isOpen ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SidebarTabs, {
2071
+ onClose: toggleOpen
2072
+ }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(LayersButton, {
2073
+ onClick: toggleOpen
2074
+ });
2075
+ }
2076
+
2077
+ // src/components/map/layers/index.tsx
2078
+ var import_maplibre6 = require("react-map-gl/maplibre");
2079
+
2080
+ // src/components/map/layers/grid/index.tsx
2081
+ var import_react10 = require("react");
2082
+ var import_maplibre3 = require("react-map-gl/maplibre");
2083
+ var import_jsx_runtime25 = require("react/jsx-runtime");
2084
+ function GridLayer({
2085
+ data,
2086
+ beforeId
2087
+ }) {
2088
+ const { layer } = useLayers();
2089
+ const { mapl } = (0, import_maplibre3.useMap)();
2090
+ const [layerData, setLayerData] = (0, import_react10.useState)({ geojson: {}, paint: {} });
2091
+ const fetchGridData = () => __async(this, null, function* () {
2092
+ const { success, geojson, paint: paint2, stops, squareSize } = yield getGridLayerData(
2093
+ data.source.fetcher,
2094
+ mapl == null ? void 0 : mapl.getBounds(),
2095
+ mapl == null ? void 0 : mapl.getZoom()
2096
+ );
2097
+ if (success) {
2098
+ setLayerData({ geojson, paint: paint2 });
2099
+ layer.setGridLegends({
2100
+ [data.id]: { stops, squareSize }
2101
+ });
2102
+ }
2103
+ });
2104
+ (0, import_react10.useEffect)(() => {
2105
+ mapl == null ? void 0 : mapl.on("idle", fetchGridData);
2106
+ }, []);
2107
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_maplibre3.Source, {
2108
+ id: data.id,
2109
+ type: "geojson",
2110
+ data: layerData.geojson,
2111
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_maplibre3.Layer, {
2112
+ beforeId,
2113
+ id: data.id,
2114
+ type: "fill",
2115
+ paint: layerData.paint
2116
+ })
2117
+ });
2118
+ }
2119
+
2120
+ // src/components/map/layers/vector/index.tsx
2121
+ var import_react11 = require("react");
2122
+ var import_maplibre4 = require("react-map-gl/maplibre");
2123
+ var import_jsx_runtime26 = require("react/jsx-runtime");
2124
+ var paint = {
2125
+ fill: {
2126
+ "line-color": "red",
2127
+ "line-width": 2
2128
+ },
2129
+ circle: {
2130
+ "circle-stroke-color": "red",
2131
+ "circle-stroke-width": 2,
2132
+ "circle-opacity": 0
2133
+ }
2134
+ };
2135
+ function VectorLayer({ layer: data, beforeId }) {
2136
+ var _a;
2137
+ const { layer } = useLayers();
2138
+ const layerProps = (0, import_react11.useMemo)(
2139
+ () => {
2140
+ var _a2, _b, _c, _d;
2141
+ return (_d = (_c = (_a2 = data.data) == null ? void 0 : _a2.styles) == null ? void 0 : _c[(_b = data.data) == null ? void 0 : _b.styleIndex]) == null ? void 0 : _d.colors;
2142
+ },
2143
+ [data, layer.selectedFeatures]
2144
+ );
2145
+ const highlightData = (_a = layer.selectedFeaturesId) == null ? void 0 : _a[data.id];
2146
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_maplibre4.Source, __spreadProps(__spreadValues({}, data.source), {
2147
+ children: [
2148
+ layerProps && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_maplibre4.Layer, __spreadValues({
2149
+ beforeId
2150
+ }, layerProps)),
2151
+ highlightData && layerProps && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_maplibre4.Layer, __spreadProps(__spreadValues({}, layerProps), {
2152
+ beforeId,
2153
+ id: `hl_${data.id}`,
2154
+ filter: ["in", PROPERTY_ID, ...highlightData],
2155
+ type: layerProps.type === "fill" ? "line" : layerProps.type,
2156
+ paint: paint[layerProps.type]
2157
+ }))
2158
+ ]
2159
+ }));
2160
+ }
2161
+
2162
+ // src/components/map/layers/raster/index.tsx
2163
+ var import_maplibre5 = require("react-map-gl/maplibre");
2164
+ var import_jsx_runtime27 = require("react/jsx-runtime");
2165
+ function RasterLayer({
2166
+ data,
2167
+ beforeId
2168
+ }) {
2169
+ var _a;
2170
+ const { mp } = useLayers();
2171
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_maplibre5.Source, {
2172
+ id: data.id,
2173
+ type: "raster",
2174
+ tiles: [
2175
+ `${(_a = mp == null ? void 0 : mp.geoserver) == null ? void 0 : _a.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}`
2176
+ ],
2177
+ tileSize: 256,
2178
+ children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_maplibre5.Layer, {
2179
+ id: data.id,
2180
+ beforeId,
2181
+ type: "raster",
2182
+ source: "biodiv",
2183
+ layout: { visibility: "visible" },
2184
+ paint: {}
2185
+ })
2186
+ });
2187
+ }
2188
+
2189
+ // src/components/map/layers/index.tsx
2190
+ var import_jsx_runtime28 = require("react/jsx-runtime");
2191
+ function MapLayer({
2192
+ layer,
2193
+ beforeId
2194
+ }) {
2195
+ const { mapl } = (0, import_maplibre6.useMap)();
2196
+ if (!mapl) {
2197
+ return null;
2198
+ }
2199
+ switch (layer.source.type) {
2200
+ case "vector":
2201
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(VectorLayer, {
2202
+ beforeId,
2203
+ layer
2204
+ });
2205
+ case "grid":
2206
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(GridLayer, {
2207
+ beforeId,
2208
+ data: layer
2209
+ });
2210
+ case "raster":
2211
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(RasterLayer, {
2212
+ beforeId,
2213
+ data: layer
2214
+ });
2215
+ default:
2216
+ return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(VectorLayer, {
2217
+ beforeId,
2218
+ layer
2219
+ });
2220
+ }
2221
+ }
2222
+
2223
+ // src/components/map/markers-list/index.tsx
2224
+ var import_react12 = require("react");
2225
+ var import_maplibre7 = require("react-map-gl/maplibre");
2226
+ var import_jsx_runtime29 = require("react/jsx-runtime");
2227
+ var Marker1 = import_maplibre7.Marker;
2228
+ var MarkersList = () => {
2229
+ const { mp } = useLayers();
2230
+ const markersMemoized = (0, import_react12.useMemo)(() => mp.markers, [mp.markers]);
2231
+ return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_jsx_runtime29.Fragment, {
2232
+ children: markersMemoized == null ? void 0 : markersMemoized.map(({ latitude, longitude, colorHex }, index) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Marker1, {
2233
+ latitude,
2234
+ longitude,
2235
+ children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("img", {
2236
+ style: { cursor: "pointer" },
2237
+ alt: "Marker",
2238
+ src: "https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"
2239
+ })
2240
+ }, index))
2241
+ });
2242
+ };
2243
+ var markers_list_default = MarkersList;
2244
+
2245
+ // src/components/map/popup/index.tsx
2246
+ var import_clsx3 = __toESM(require("clsx"));
2247
+ var import_maplibre8 = require("react-map-gl/maplibre");
2248
+ var import_twind19 = require("twind");
2249
+ var import_jsx_runtime30 = require("react/jsx-runtime");
2250
+ var Pop = import_maplibre8.Popup;
2251
+ function HoverPopup({ coordinates }) {
2252
+ const { hover } = useLayers();
2253
+ return (coordinates == null ? void 0 : coordinates.lat) && hover.features ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Pop, {
2254
+ latitude: coordinates.lat,
2255
+ longitude: coordinates.lng,
2256
+ closeButton: false,
2257
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("table", {
2258
+ className: import_twind19.tw`table-auto border`,
2259
+ children: [
2260
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("thead", {
2261
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("tr", {
2262
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("th", {
2263
+ className: import_twind19.tw`bg-gray-200 py-1 px-2`,
2264
+ colSpan: 2,
2265
+ children: hover.features.title
2266
+ })
2267
+ })
2268
+ }),
2269
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("tbody", {
2270
+ children: hover.features.data.map(([k, v], idx) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("tr", {
2271
+ className: (0, import_twind19.tw)(
2272
+ (0, import_clsx3.default)({
2273
+ "bg-gray-50": idx % 2 === 0,
2274
+ "border-gray-100 border-t": 1
2275
+ })
2276
+ ),
2277
+ children: [
2278
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("td", {
2279
+ className: import_twind19.tw`py-1 px-2`,
2280
+ children: k
2281
+ }),
2282
+ /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("td", {
2283
+ className: import_twind19.tw`py-1 px-2 border-l border-gray-100`,
2284
+ children: v
2285
+ })
2286
+ ]
2287
+ }, k + v))
2288
+ })
2289
+ ]
2290
+ })
2291
+ }) : null;
2292
+ }
2293
+
2294
+ // src/components/map/index.tsx
2295
+ var import_jsx_runtime31 = require("react/jsx-runtime");
2296
+ var NavControl = import_maplibre9.NavigationControl;
2297
+ function Map2() {
2298
+ var _a;
2299
+ const { mp, layer, hover, query } = useLayers();
2300
+ const [coordinates, setCoordinates] = (0, import_react13.useState)();
2301
+ const viewState = (0, import_react13.useMemo)(
2302
+ () => mp.defaultViewState || import_naksha_commons13.defaultViewState,
2303
+ [mp.defaultViewState]
2304
+ );
2305
+ const onMapClick = (e) => query.setClickedLngLat(e.lngLat);
2306
+ const handleOnMouseMove = (event) => {
2307
+ setCoordinates(event.lngLat);
2308
+ hover.onHover(event);
2309
+ };
2310
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("div", {
2311
+ className: import_twind20.tw`h-full w-full relative bg-gray-100`,
2312
+ children: [
2313
+ mp.loadToC && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Sidebar, {}),
2314
+ ((_a = layer.selectedFeatures) == null ? void 0 : _a.length) > 0 && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(InfoBar, {}),
2315
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_maplibre9.default, {
2316
+ id: "mapl",
2317
+ cursor: "default",
2318
+ initialViewState: viewState,
2319
+ style: { width: "100%", height: "100%" },
2320
+ mapStyle: layer.mapStyle,
2321
+ onClick: onMapClick,
2322
+ onMouseMove: handleOnMouseMove,
2323
+ children: [
2324
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(NavControl, {
2325
+ position: "bottom-right",
2326
+ showZoom: true,
2327
+ showCompass: true
2328
+ }),
2329
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(markers_list_default, {}),
2330
+ layer.selectedLayers.map((_l, index) => {
2331
+ const beforeId = index > 0 ? layer.selectedIds[index - 1] : void 0;
2332
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(MapLayer, {
2333
+ layer: _l,
2334
+ beforeId
2335
+ }, _l.id);
2336
+ }),
2337
+ /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(HoverPopup, {
2338
+ coordinates
2339
+ }, "popup")
2340
+ ]
2341
+ })
2342
+ ]
2343
+ });
2344
+ }
2345
+
2346
+ // src/index.tsx
2347
+ var import_jsx_runtime32 = require("react/jsx-runtime");
2348
+ (0, import_twind21.setup)({ preflight: false });
2349
+ var NakshaMaplibreLayers = (props) => {
2350
+ const mp = import_react14.default.useMemo(
2351
+ () => __spreadValues(__spreadValues({}, defaultNakshaProps), props),
2352
+ [props]
2353
+ );
2354
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_maplibre10.MapProvider, {
2355
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_naksha_commons14.TranslationProvider, {
2356
+ localeStrings: locales_default,
2357
+ lang: mp.lang,
2358
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(LayersProvider, {
2359
+ mp,
2360
+ children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Map2, {})
2361
+ })
2362
+ })
2363
+ });
2364
+ };
2365
+ // Annotate the CommonJS export names for ESM import in node:
2366
+ 0 && (module.exports = {
2367
+ NakshaMaplibreLayers
2368
+ });