@biodiv-platform/naksha-maplibre-layers 5.0.7 → 5.0.9-beta.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/LICENSE +201 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.ts +0 -0
- package/dist/index.js +1 -1
- package/package.json +47 -35
- package/dist/esm/index.js +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Rr=Object.create;var Ne=Object.defineProperty;var _r=Object.getOwnPropertyDescriptor;var Br=Object.getOwnPropertyNames;var Ar=Object.getPrototypeOf,Gr=Object.prototype.hasOwnProperty;var Or=(e,t)=>{for(var o in t)Ne(e,o,{get:t[o],enumerable:!0})},At=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Br(t))!Gr.call(e,n)&&n!==o&&Ne(e,n,{get:()=>t[n],enumerable:!(r=_r(t,n))||r.enumerable});return e};var C=(e,t,o)=>(o=e!=null?Rr(Ar(e)):{},At(t||!e||!e.__esModule?Ne(o,"default",{value:e,enumerable:!0}):o,e)),Dr=e=>At(Ne({},"__esModule",{value:!0}),e);var tn={};Or(tn,{NakshaMaplibreLayers:()=>en});module.exports=Dr(tn);var hr=require("@biodiv-platform/naksha-commons"),br=C(require("react"),1),Lr=require("react-map-gl/maplibre"),vr=require("twind");var Gt={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var Ot={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Dt={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var zt={en:Gt,fr:Ot,hi:Dt};var yr=require("@biodiv-platform/naksha-commons"),Ze=require("react"),pe=C(require("react-map-gl/maplibre"),1),gr=require("twind");var Be=require("@biodiv-platform/naksha-commons"),g=C(require("react"),1),ro=require("react-map-gl/maplibre");var Jt=C(require("colorbrewer"),1),F=C(require("redaxios"),1);var tt=C(require("boundingbox"),1),_e=require("geohash");var Ee=require("@biodiv-platform/naksha-commons"),Ht={defaultViewState:Ee.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:Ee.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},$t="data:image/svg+xml,%3Csvg fill='none' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 72'%3E%3Cpath fill='%23fff' d='M0 0h72v72H0z'/%3E%3Cpath d='M35.981 48.293l-13.853-10.77-3.045 2.368L36 53.048l16.917-13.157-3.064-2.387-13.872 10.789zM36 43.519l13.834-10.77 3.083-2.388L36 17.204 19.083 30.36l3.064 2.387L36 43.518z' fill='%23A0AEC0'/%3E%3C/svg%3E",Qe={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},qt={...Qe,WebkitLineClamp:2},R="ogc_fid",Re={ACTIVE:"Active",PENDING:"Pending"},_={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Ft=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],et="0123456789bcdefghjkmnpqrstuvwxyz",qr=(e,t,o)=>{o=o||16/2**(1-e.length&1)/4**t;let r=e.slice(0,-1),n=~~(et.indexOf(e.slice(-1))/o);return[r+et[o*n],r+et[o*(n+1)-1]]},Fr=function(e,t){var o=new Map,r=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[l,u]=qr(a,t);r.set(l,u),o.has(l)||o.set(l,0),o.set(l,o.get(l)+s)}return o.forEach((a,s)=>{let l=_e.GeoHash.decodeGeoHash(s),u=_e.GeoHash.decodeGeoHash(r.get(s)),d=new tt.default({minlat:l.latitude[0],minlon:l.longitude[0],maxlat:u.latitude[1],maxlon:u.longitude[1]}).toGeoJSON();n.push({...d,properties:{count:a,[R]:s}})}),n},Vr=e=>{let t=[];for(let[o,r]of Object.entries(e)){let n=_e.GeoHash.decodeGeoHash(o),a=new tt.default({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();t.push({...a,properties:{count:r,[R]:o}})}return t},Vt=(e,t)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:t===-1?Vr(e):Fr(e,t)}),Wt=(e,t)=>{let o=Object.values(e).sort((a,s)=>a-s),r=Math.floor(o.length/t),n=new Array(t-1).fill(0).map((a,s)=>o[r*(s+1)]);return n.push(o[o.length-1]),n};var Zt=require("immer");var Yt=async(e,t,o,r)=>{let n=[];for(let a of e){let s=r.includes(a.name),l={...a,id:a.name,thumbnail:t+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${o.endpoint}/gwc/service/tms/1.0.0/${o.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s};if(s){let u=await ot(l,0,t,o);n.push({...l,data:u})}else n.push(l)}return n},ot=async(e,t,o,r)=>(0,Zt.produce)(e.data,async a=>{if(a.styles.length===0){let{success:s,data:l}=await Ut(e.id,o);s&&(a.layerName=l.layerName,a.styles=l.styles,a.summaryColumn=l.summaryColumn,a.titleColumn=l.titleColumn,a.propertyMap=Object.fromEntries(l.styles.map(u=>[u.styleName,u.styleTitle])))}a.styles[t]&&!a.styles[t]?.colors&&(a.styles[t].colors=await jt(e.id,r?.workspace,a.styles[t].styleName,o)),a.styleIndex=t});var Kt=async(e,t,o,r)=>{try{let n=await F.default.get(`${t}/layer/all`,{headers:{Authorization:e}});return await Yt(n.data,t,o,r)}catch(n){return console.error(n),[]}},Ut=async(e,t)=>{try{let{data:o}=await F.default.get(`${t}/layer/onClick/${e}`);return{success:!0,data:o}}catch(o){return console.error(o),{success:!1}}},Xt=async(e,t,o)=>{let r={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await F.default.get(`${e}/${t}/wms`,{params:{...o,...r}})).data}}catch(n){return console.error(n),{success:!1,data:[]}}},Qt=async(e,t,o,r)=>{try{return await F.default.put(`${t}/layer/${r?"active":"pending"}/${o}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},eo=async(e,t,o)=>{try{return await F.default.delete(`${t}/layer/${o}`,{headers:{Authorization:e}}),!0}catch(r){return console.error(r),!1}},jt=async(e,t,o,r)=>{try{return(await F.default.get(`${r}/geoserver/workspaces/${t}/styles/${e}_${o}.mbstyle`)).data?.layers?.[0]}catch(n){return console.error(n),{}}},to=async(e,t,o,r=6,n="YlOrRd")=>{try{let[a,s,l]=Ft(o),{_ne:u,_sw:d}=t,b={top:u.lat,left:d.lng,bottom:d.lat,right:u.lng,geoAggegationPrecision:a},L=await e(b),P=Vt(L,s),z=Wt(L,r).map((Y,ue)=>[Y,Jt.default[n][r][ue]]);return{success:!0,geojson:P,paint:{"fill-color":{property:"count",default:"yellow",stops:z},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:z,squareSize:l}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},oo=async(e,t,o,r)=>{try{await F.default.post(`${e}/layer/download`,{layerName:o,layerTitle:r,attributeList:[],filterArray:[]},{headers:{Authorization:t}})}catch(n){console.error(n)}};var so=require("react/jsx-runtime"),no=(0,g.createContext)({}),ao=({mp:e,children:t})=>{let[o,r]=(0,g.useState)(e),{mapl:n}=(0,ro.useMap)(),[a,s]=(0,g.useState)(""),l=(0,Be.useDebounce)(a,500),u=o.mapStyles&&o.mapStyles.length>0?o.mapStyles:Be.defaultMapStyles,[d,b]=(0,g.useState)(u[o?.mapStyle||0]?.style),[L,P]=(0,g.useState)(u[o?.mapStyle||0]?.maxZoom),[k,z]=(0,g.useState)(_.TOP),[q,Y]=(0,g.useState)({}),[ue,Ye]=(0,g.useState)(!0),[H,xr]=(0,g.useState)(),[T,Ue]=(0,g.useState)(e.layers||[]),[S,Q]=(0,g.useState)(o.selectedLayers||[]),[Tt,Mt]=(0,g.useState)(),[je,Nt]=(0,g.useState)(),Sr=(0,g.useMemo)(()=>{let p={};for(let m of je||[])p[m.sourceLayer]=[...p[m.sourceLayer]||[],m?.properties?.[R]];return Object.keys(p).length?p:void 0},[je]),Je=g.default.useMemo(()=>{let p=T.filter(f=>S.includes(f.id)),m=new Array(S.length);for(let f of p){let x=S.findIndex(w=>f.id===w);x>-1&&(m[x]=f)}return m},[T,S]),Te=p=>T.findIndex(m=>m.id===p),Et=(p,m)=>{Ue(f=>f.map(x=>x.id===p?{...x,...m}:x))},Rt=async(p,m,f)=>{let x=T[p],w=await ot(x,m,o.nakshaApiEndpoint,o.geoserver);Et(x.id,{data:w}),f&&n?.fitBounds(x.bbox,{padding:40,duration:1e3})},wr=async(p,m)=>{let f=Te(p);Rt(f,m,!1)},Ir=async p=>{if(!(!S.length||!n))try{let m=S[0],f=n.queryRenderedFeatures(p.point,{layers:[m]});if(f.length){let x=f[0]?.id||f[0]?.properties?.[R];if(x===Tt?.id)return;let w=T[Te(m)],Bt=w?.data?.summaryColumn.map($=>[w.data?.propertyMap?.[$]||$,f[0].properties?.[$]]);Mt({id:x,title:w.title,data:Bt})}else Mt(void 0)}catch{}},kr=async({layerId:p,add:m,styleIndex:f=0,focus:x=!0})=>{if(!m){Q(S.filter($=>p!==$));return}let w=Te(p);T[w]?.source.type==="grid"?(Q($=>[p,...$.filter(Xe=>Xe!==p)]),x&&T[w]?.bbox&&setTimeout(()=>{n?.fitBounds(T[w].bbox,{padding:40,duration:1e3})},100)):(await Rt(w,f,x),Q($=>[p,...$.filter(Xe=>Xe!==p)]))},Cr=async()=>Q([]),Pr=(p,m)=>{r({...o,[p]:m})},Tr=(p,m)=>{let f=m===Re.PENDING;Qt(o.nakshaEndpointToken,o.nakshaApiEndpoint,p,f),Et(p,{layerStatus:f?Re.ACTIVE:Re.PENDING})},Mr=async(p,m)=>{confirm(m)&&(eo(o.nakshaEndpointToken,o.nakshaApiEndpoint,p),Ue(T.filter(f=>f.id!==p)))},Nr=p=>{let m=Te(p),f=T[m];n?.fitBounds(f.bbox,{padding:40,duration:1e3})},_t=()=>[H.lng,H.lat,H.lng+.1,H.lat+.1],Er=p=>{z(p),p===_.TOP&&Ke(p)},Ke=p=>{if(H)try{let m=n?.project([H.lng,H.lat]),f=n?.queryRenderedFeatures(m,{layers:k===_.TOP?[S[0]]:S});if((p||k)===_.ALL){let x=Je.filter(w=>w.layerType=="RASTER").map(w=>({sourceLayer:w.id,layerType:"raster",bbox:_t()}));f=[...f,...x]}Nt(Je?.[0].layerType==="RASTER"&&k!==_.ALL?S.length&&f?.length?f:[{sourceLayer:S[0],layerType:"raster",bbox:_t()}]:f)}catch(m){console.error(m)}},Me=(e.selectedLayers||[]).join(",");return(0,g.useEffect)(()=>{Me!==S.join(",")&&Q(Me?Me.split(","):[])},[Me]),(0,g.useEffect)(()=>{o.onSelectedLayersChange&&o.onSelectedLayersChange(S)},[S]),(0,g.useEffect)(()=>{setTimeout(Ke,300)},[H,k,S]),(0,so.jsx)(no.Provider,{value:{mp:o,updateMP:Pr,layer:{mapStyle:d,featuresAtLatLng:Ke,setMapStyle:b,maxZoom:L,setMaxZoom:P,mapStyles:u,all:T,setAll:Ue,selectedIds:S,handleSelectStyle:Er,setSelectedIds:Q,selectedLayers:Je,clearAll:Cr,toggle:kr,updateStyle:wr,selectedFeatures:je,selectedFeaturesId:Sr,setSelectedFeatures:Nt,togglePublish:Tr,delete:Mr,selectionStyle:k,setSelectionStyle:z,zoomToExtent:Nr,gridLegends:q,setGridLegends:Y},query:{term:l,setTerm:s,clickedLngLat:H,setClickedLngLat:xr},isInfoBarOpen:ue,setIsInfoBarOpen:Ye,hover:{onHover:Ir,features:Tt}},children:t})};function c(){return(0,g.useContext)(no)}var So=C(require("react"),1),fe=require("twind");var io=require("twind"),i=require("react/jsx-runtime"),lo=()=>(0,i.jsx)("svg",{fill:"none",className:io.tw`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:(0,i.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),me=()=>(0,i.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,i.jsx)("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),(0,i.jsx)("path",{d:"M2 17L12 22 22 17"}),(0,i.jsx)("path",{d:"M2 12L12 17 22 12"})]}),Ae=()=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),co=()=>(0,i.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,i.jsx)("path",{d:"M4 21L4 14"}),(0,i.jsx)("path",{d:"M4 10L4 3"}),(0,i.jsx)("path",{d:"M12 21L12 12"}),(0,i.jsx)("path",{d:"M12 8L12 3"}),(0,i.jsx)("path",{d:"M20 21L20 16"}),(0,i.jsx)("path",{d:"M20 12L20 3"}),(0,i.jsx)("path",{d:"M1 14L7 14"}),(0,i.jsx)("path",{d:"M9 8L15 8"}),(0,i.jsx)("path",{d:"M17 16L23 16"})]});function rt(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function po(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function uo(){return(0,i.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function mo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function fo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function yo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function go(){return(0,i.jsx)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function ho(){return(0,i.jsxs)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[(0,i.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,i.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,i.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,i.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,i.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function bo(){return(0,i.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,i.jsx)("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function Lo(){return(0,i.jsxs)("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,i.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,i.jsx)("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),(0,i.jsx)("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),(0,i.jsx)("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),(0,i.jsx)("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function vo(){return(0,i.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function xo(){return(0,i.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,i.jsx)("polyline",{points:"18 15 12 9 6 15"})})}var U=require("react/jsx-runtime"),V=So.default.forwardRef((e,t)=>(0,U.jsx)("button",{ref:t,type:"button",className:fe.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`,...e}));var Ge=e=>(0,U.jsx)("button",{className:fe.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),wo=e=>(0,U.jsx)("button",{className:fe.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`,...e,children:(0,U.jsx)(me,{})}),Io=e=>(0,U.jsx)("button",{className:fe.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`,...e,children:(0,U.jsx)(Ae,{})});var j=require("twind");var I=require("react/jsx-runtime");var ee=e=>(0,I.jsxs)("div",{children:[e.label&&(0,I.jsx)("label",{className:j.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,I.jsx)("select",{id:e.name,name:e.name,className:j.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`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),ko=e=>(0,I.jsxs)("div",{className:"relative",children:[(0,I.jsx)("span",{className:j.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,I.jsx)(lo,{})}),(0,I.jsx)("input",{type:"search",className:j.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`,...e})]}),Co=e=>e.isLoading?(0,I.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:j.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,I.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,I.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,I.jsx)("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):(0,I.jsx)("input",{type:"checkbox",className:j.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});var J=require("@bumaga/tabs"),Po=C(require("clsx"),1),ye=require("twind"),te=require("react/jsx-runtime"),Oe=({children:e,icon:t})=>{let{onClick:o,isActive:r}=(0,J.useTabState)(),n=(0,Po.default)(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":r,"text-gray-700 border-gray-300 hover:border-gray-400":!r}]);return(0,te.jsxs)("button",{className:(0,ye.tw)(n),onClick:o,children:[t,(0,te.jsx)("span",{className:ye.tw`ml-2 text-base`,children:e})]})},De=({children:e})=>(0,J.usePanelState)()?(0,te.jsx)("div",{className:ye.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,To=({children:e})=>(0,te.jsx)("div",{className:ye.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var Eo=require("@biodiv-platform/naksha-commons"),Le=require("twind");var Mo=require("@biodiv-platform/naksha-commons");var nt=require("react/jsx-runtime");function ge({hideLabel:e}){let{layer:{selectionStyle:t,handleSelectStyle:o}}=c(),{t:r}=(0,Mo.useT)(),n=a=>{o(a.target.value)};return(0,nt.jsx)(ee,{name:"layer_selection",label:e?null:r("layer_selection"),defaultValue:t,onChange:n,children:Object.values(_).map(a=>(0,nt.jsx)("option",{value:a,children:r(a)},a))})}var No=C(require("clsx"),1),be=require("react"),he=require("twind");var B=require("react/jsx-runtime");function at({data:e}){let[t,o]=(0,be.useState)(!0),[r,n]=(0,be.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:l}}=c(),u=async()=>{let d,b=a.selectedLayers.find(L=>L.id===(e.sourceLayer||e.source));if(b.layerType.toLowerCase()==="raster"){let{data:L}=await Xt(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${b.id}`,layers:`${s.geoserver?.workspace}:${b.id}`});d=L?.features[0]?Object.entries(L.features[0]?.properties).map(([P,k])=>[k||"-"]):[]}else d=Object.entries(b?.data?.propertyMap||{}).map(([L,P])=>[P,e?.properties?.[L]]);n({title:b.title,properties:d})};return(0,be.useEffect)(()=>{u()},[l]),(0,B.jsxs)("div",{className:he.tw`bg-gray-100 rounded-lg`,children:[(0,B.jsxs)("button",{className:(0,he.tw)((0,No.default)(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":t,"rounded-lg":!t}])),onClick:()=>o(!t),children:[r.title," ",t?(0,B.jsx)(xo,{}):(0,B.jsx)(vo,{})]}),t&&(0,B.jsx)("div",{className:he.tw`px-4 py-3 flex flex-col gap-3`,children:r.properties.map(([d,b],L)=>(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{className:he.tw`text-gray-600`,children:d}),(0,B.jsx)("div",{children:b})]},d+b+L))})]})}var M=require("react/jsx-runtime");function st({onClose:e}){let{layer:{selectedFeatures:t,selectedLayers:o,selectionStyle:r}}=c(),{t:n}=(0,Eo.useT)();return(0,M.jsxs)("div",{className:Le.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`,children:[(0,M.jsxs)("div",{className:"flex w-full",children:[(0,M.jsxs)("div",{className:Le.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,M.jsx)(Lo,{})," ",n("infobar")]}),(0,M.jsx)(Ge,{onClick:e})]}),(0,M.jsx)("div",{className:Le.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,M.jsx)(ge,{hideLabel:!0})}),(0,M.jsx)("div",{className:Le.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:t.flat(1)?.map(a=>(0,M.jsx)(at,{data:a},o?.[0]?.source.type==="raster"||r===_.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[R]))})]})}var it=require("react/jsx-runtime");function lt(){let{layer:e,isInfoBarOpen:t,setIsInfoBarOpen:o}=c();if(!e.selectedFeatures?.length)return null;let r=()=>o(!t);return t?(0,it.jsx)(st,{onClose:r}):(0,it.jsx)(Io,{onClick:r})}var Fe=require("react"),ar=require("react-map-gl/maplibre");var nr=require("@biodiv-platform/naksha-commons"),bt=require("twind");var Ko=require("twind");var qe=C(require("react"),1),Zo=require("react-virtual"),Yo=require("react-virtualized-auto-sizer"),pt=require("twind");var Vo=require("@biodiv-platform/naksha-commons"),xe=require("react"),Wo=require("react-web-share"),O=require("twind");var W=require("react/jsx-runtime"),Ro=({text:e="",highlight:t=""})=>{if(!t.trim())return(0,W.jsx)(W.Fragment,{children:e});let o=new RegExp(`(${t})`,"gi"),r=e.split(o);return(0,W.jsx)(W.Fragment,{children:r.filter(n=>n).map((n,a)=>o.test(n)?(0,W.jsx)("mark",{children:n},a):(0,W.jsx)("span",{children:n},a))})};var Go=require("twind");var _o=require("@biodiv-platform/naksha-commons"),Bo=require("react"),Ao=require("twind"),ze=require("react/jsx-runtime");function ve({children:e}){let[t,o]=(0,Bo.useState)(!1),{t:r}=(0,_o.useT)();return(0,ze.jsxs)("div",{children:[t&&e,(0,ze.jsx)("button",{onClick:()=>o(!t),className:Ao.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:r(t?"less":"legend")})]})}var A=require("react/jsx-runtime");function ct({item:e}){let{layer:t}=c(),o=t.gridLegends[e.id];return o?(0,A.jsx)(ve,{children:(0,A.jsxs)("ul",{style:{margin:0,padding:0},children:[o?.stops.map(([r,n],a,s)=>{let l=(s[a-1]||[0])[0];return l===r?(0,A.jsx)("div",{},n):(0,A.jsxs)("li",{className:Go.tw`flex gap-2 items-center mb-1`,children:[(0,A.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,A.jsx)("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),(0,A.jsxs)("div",{children:[l," - ",r]})]},n)}),(0,A.jsxs)("li",{children:["1 Square = ",o?.squareSize," x ",o?.squareSize," km"]})]})}):null}var He=require("@biodiv-platform/naksha-commons"),Oo=require("react"),Do=require("react-tiny-popover"),re=require("twind");var h=require("react/jsx-runtime"),oe=({icon:e,name:t,title:o,link:r,children:n})=>{let a=(0,h.jsx)("span",{children:n||"-"});return(0,h.jsxs)("div",{className:re.tw`flex gap-3 text-sm text-gray-600 break-all`,title:t&&o&&`${t}: ${o}`,children:[(0,h.jsx)("div",{children:e}),r?(0,h.jsx)("a",{className:re.tw`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:r,children:a}):a]})};function Wr({item:e,containerStyle:t}){let{t:o}=(0,He.useT)(),{layer:r,mp:n}=c(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),l=e.tags?.join(", ");return(0,h.jsxs)("div",{className:re.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:t,children:[n.managePublishing&&e.layerStatus&&(0,h.jsxs)(oe,{icon:(0,h.jsx)(mo,{}),name:o("visiblity"),title:e.layerStatus,children:[e.layerStatus,(0,h.jsx)("button",{className:re.tw`text-blue-600 focus:outline-none ml-4`,onClick:()=>r.togglePublish(e.id,e?.layerStatus),children:o("toggle")}),(0,h.jsx)("button",{className:re.tw`text-red-600 focus:outline-none ml-4`,onClick:()=>r.delete(e.id,o("are_you_sure")),children:o("delete")})]}),(0,h.jsx)(oe,{icon:(0,h.jsx)(rt,{}),link:e.url,name:o("uploader"),title:e.createdBy,children:e.createdBy}),(0,h.jsx)(oe,{icon:(0,h.jsx)(rt,{}),link:e.url,name:o("created_by"),title:e.attribution,children:e.attribution}),(0,h.jsx)(oe,{icon:(0,h.jsx)(fo,{}),name:o("created_on"),title:s,children:s}),(0,h.jsx)(oe,{icon:(0,h.jsx)(po,{}),name:o("tags"),title:l,children:l}),(0,h.jsx)(oe,{name:o("license"),title:a,link:a&&He.LICENSES[a],icon:(0,h.jsx)(uo,{}),children:a})]})}var zo=({item:e})=>{let[t,o]=(0,Oo.useState)(!1),r=()=>o(!t);return(0,h.jsx)(Do.Popover,{isOpen:t,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:r,content:(0,h.jsx)(Wr,{item:e}),children:(0,h.jsx)(V,{onClick:r,children:(0,h.jsx)(Ae,{}),title:"Information"})})};var Fo=require("twind");var $e=require("react"),Ho=require("@biodiv-platform/naksha-commons"),$o=require("twind");var G=require("react/jsx-runtime");function qo({item:e}){let[t,o]=(0,$e.useState)(!0),{mp:r}=c(),{t:n}=(0,Ho.useT)(),a=(0,$e.useMemo)(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([l,u])=>(0,G.jsxs)("li",{className:$o.tw`flex gap-2 items-center mb-1`,children:[(0,G.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,G.jsx)("circle",{cx:"12",fill:u,cy:"12",r:"12",stroke:"none"})}),(0,G.jsx)("div",{children:l})]},u));return(0,G.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():t?(0,G.jsx)("li",{children:(0,G.jsx)("img",{style:{margin:"5px"},onError:()=>o(!1),src:`${r?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,G.jsx)("div",{children:n("raster_style_not_found")})})}var K=require("react/jsx-runtime");function dt({item:e}){if(!e.data?.styles)return null;let{layer:t}=c(),o=r=>{t.updateStyle(e.id,Number(r.target.value))};return(0,K.jsxs)("div",{className:Fo.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,K.jsx)(ee,{onChange:o,children:e.data?.styles.map((r,n)=>(0,K.jsx)("option",{value:n,children:r.styleTitle},n))}),(0,K.jsx)(ve,{children:(0,K.jsx)(qo,{item:e})})]})}var y=require("react/jsx-runtime");function Zr({dragHandleProps:e}){return(0,y.jsx)("div",{className:O.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:(0,y.jsx)(bo,{})})}function Se({item:e,extended:t,dragHandleProps:o}){let{t:r}=(0,Vo.useT)(),{layer:n,query:a,mp:s,query:{setClickedLngLat:l},setIsInfoBarOpen:u}=c(),[d,b]=(0,xe.useState)(n.selectedIds.includes(e.id)),[L,P]=(0,xe.useState)(!1),k=(0,xe.useMemo)(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),z=async()=>{P(!0),u(!0),n.setSelectedFeatures([]),l(null),await n.toggle({layerId:e.id,add:!d}),b(!d),P(!1)},q=async()=>{await oo(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},Y=()=>n.zoomToExtent(e.id);return(0,y.jsxs)("div",{className:O.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,y.jsxs)("div",{className:O.tw`flex gap-3`,children:[(0,y.jsxs)("div",{className:O.tw`flex-shrink-0`,children:[(0,y.jsx)(Co,{name:e.id,checked:d,onChange:z,isLoading:L}),t&&(0,y.jsx)(Zr,{dragHandleProps:o})]}),(0,y.jsx)("img",{className:O.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||$t}),(0,y.jsxs)("div",{children:[(0,y.jsx)("div",{title:e.title,className:O.tw`mb-1 leading-tight`,style:Qe,children:(0,y.jsx)(Ro,{text:e.title,highlight:a.term})}),(0,y.jsx)("p",{title:e.description,className:O.tw`text-gray-600 text-sm`,style:qt,children:e.description})]})]}),(0,y.jsxs)("div",{className:O.tw`flex justify-between`,children:[(0,y.jsxs)(V,{onClick:q,disabled:!e.isDownloadable,children:[(0,y.jsx)(yo,{})," ",r("download")]}),(0,y.jsxs)("div",{className:O.tw`flex gap-3`,children:[k&&(0,y.jsx)(Wo.RWebShare,{data:k,children:(0,y.jsx)(V,{title:"Share",children:(0,y.jsx)(ho,{})})}),t&&(0,y.jsx)(V,{onClick:Y,title:"Zoom To Extent",children:(0,y.jsx)(go,{})}),(0,y.jsx)(zo,{item:e})]})]}),t&&(0,y.jsx)(dt,{item:e}),t&&e.source.type==="grid"&&(0,y.jsx)(ct,{item:e})]})}var Z=require("react/jsx-runtime");function Uo(){let{layer:e,query:t}=c(),o=(0,qe.useMemo)(()=>t.term?e.all.filter(a=>a.title.toLowerCase().includes(t.term.toLowerCase())):e.all,[e.all,t.term]),r=qe.default.useRef(),n=(0,Zo.useVirtual)({size:o.length,parentRef:r});return(0,Z.jsx)("div",{className:pt.tw`flex-grow-1 relative`,children:(0,Z.jsx)(Yo.AutoSizer,{disableWidth:!0,children:a=>(0,Z.jsx)("div",{ref:r,className:"List",style:{height:a.height,overflow:"auto"},children:(0,Z.jsx)("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>(0,Z.jsx)("div",{ref:s.measureRef,className:pt.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,Z.jsx)("div",{style:{height:146},children:(0,Z.jsx)(Se,{item:o[s.index]})})},s.index))})})})})}var jo=require("@biodiv-platform/naksha-commons"),Jo=require("twind");var ut=require("react/jsx-runtime");function mt(){let{t:e}=(0,jo.useT)(),{query:t}=c(),o=r=>t.setTerm(r.target.value);return(0,ut.jsx)("div",{className:Jo.tw`flex-shrink-0 border-b-2 p-4`,children:(0,ut.jsx)(ko,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:o})})}var we=require("react/jsx-runtime");function ft(){return(0,we.jsxs)("div",{className:Ko.tw`flex flex-col w-full`,children:[(0,we.jsx)(mt,{}),(0,we.jsx)(Uo,{})]})}function Yr(e,t,o){let r=t<0?e.length+t:t;if(r>=0&&r<e.length){let n=o<0?e.length+o:o,[a]=e.splice(t,1);e.splice(n,0,a)}}function Xo(e,t,o){return e=[...e],Yr(e,t,o),e}var D=require("@dnd-kit/core"),ne=require("@dnd-kit/sortable"),Qo=require("@dnd-kit/utilities");var X=require("react/jsx-runtime");function Ur({item:e,extended:t}){let{attributes:o,listeners:r,setNodeRef:n,transform:a,transition:s,isDragging:l}=(0,ne.useSortable)({id:e.id}),u={transform:Qo.CSS.Transform.toString(a),transition:s,opacity:l?.5:1};return(0,X.jsx)("div",{ref:n,style:u,children:(0,X.jsx)(Se,{item:e,extended:t,dragHandleProps:{...o,...r}})})}var er=({layerList:e,onSortEnd:t})=>{let o=(0,D.useSensors)((0,D.useSensor)(D.PointerSensor,{activationConstraint:{distance:4}}));return(0,X.jsx)(D.DndContext,{sensors:o,collisionDetection:D.closestCenter,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let l=e.findIndex(d=>d.id===a.id),u=e.findIndex(d=>d.id===s.id);l!==-1&&u!==-1&&t({oldIndex:l,newIndex:u})}},children:(0,X.jsx)(ne.SortableContext,{items:e.map(n=>n.id),strategy:ne.verticalListSortingStrategy,children:(0,X.jsx)("div",{children:e.map(n=>(0,X.jsx)(Ur,{item:n,extended:!0},n.id))})})})};var tr=require("@biodiv-platform/naksha-commons"),yt=require("twind"),ae=require("react/jsx-runtime");function gt(){let{layer:e}=c(),{t}=(0,tr.useT)(),o=({oldIndex:r,newIndex:n})=>{e.setSelectedIds(Xo(e.selectedIds,r,n))};return(0,ae.jsxs)("div",{className:yt.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,ae.jsx)("div",{className:yt.tw`p-3 pb-0`,children:(0,ae.jsxs)(V,{onClick:()=>e.clearAll(),children:["\u2715 ",t("clear")]})}),(0,ae.jsx)(er,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:o})]})}var or=require("@biodiv-platform/naksha-commons"),rr=require("twind");var se=require("react/jsx-runtime");function ht(){let{layer:e}=c(),{t}=(0,or.useT)(),o=r=>{e.setMapStyle(r.target.value),e.setMaxZoom(e.mapStyles.find(n=>n.style===r.target.value)?.maxZoom)};return(0,se.jsxs)("div",{className:rr.tw`w-full p-4 flex flex-col gap-4`,children:[(0,se.jsx)(ee,{name:"base_style",label:t("base_style"),defaultValue:e.mapStyle,onChange:o,children:e.mapStyles.map(r=>(0,se.jsx)("option",{value:r.style,children:r.text},r.key))}),(0,se.jsx)(ge,{})]})}var v=require("react/jsx-runtime");function Lt({onClose:e}){let{t}=(0,nr.useT)();return(0,v.jsxs)("div",{className:bt.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`,children:[(0,v.jsx)(Ge,{onClick:e}),(0,v.jsx)("div",{className:bt.tw`flex flex-col h-full`,children:(0,v.jsxs)(J.Tabs,{children:[(0,v.jsxs)(To,{children:[(0,v.jsx)(Oe,{icon:(0,v.jsx)(me,{}),children:t("layers")}),(0,v.jsx)(Oe,{icon:(0,v.jsx)(me,{}),children:t("selected")}),(0,v.jsx)(Oe,{icon:(0,v.jsx)(co,{}),children:t("settings")})]}),(0,v.jsx)(De,{children:(0,v.jsx)(ft,{})}),(0,v.jsx)(De,{children:(0,v.jsx)(gt,{})}),(0,v.jsx)(De,{children:(0,v.jsx)(ht,{})})]})})]})}var vt=require("react/jsx-runtime");function xt(){let{mp:e,layer:t}=c(),[o,r]=(0,Fe.useState)(e.showToC),{mapl:n}=(0,ar.useMap)(),a=()=>r(!o);async function s(){let l=await Kt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...l];if(t.setAll(u),t.selectedIds.length){let d=u.find(b=>b.id===t.selectedIds[0]);d?.bbox&&n?.fitBounds(d.bbox,{padding:40,duration:1e3})}}return(0,Fe.useEffect)(()=>{n&&e.loadToC&&s()},[n]),o?(0,vt.jsx)(Lt,{onClose:a}):(0,vt.jsx)(wo,{onClick:a})}var lr=require("react-map-gl/maplibre");var sr=C(require("@turf/bbox"),1),ie=require("react"),le=require("react-map-gl/maplibre");var St=require("react/jsx-runtime");function wt({data:e,beforeId:t}){let{layer:o}=c(),{mapl:r}=(0,le.useMap)(),[n,a]=(0,ie.useState)({geojson:{},paint:{}}),s=o.selectedIds.includes(e.id),l=o.selectedIds[0]===e.id,u=async(d=!1)=>{let{success:b,geojson:L,paint:P,stops:k,squareSize:z}=await to(e.source.fetcher,r?.getBounds(),r?.getZoom());if(b){if(a({geojson:L,paint:P}),d&&l&&e.zoomToFit)try{let[q,Y,ue,Ye]=(0,sr.default)(L);r?.fitBounds([[q,Y],[ue,Ye]],{padding:40,animate:!0})}catch(q){console.warn("Failed to compute bbox",q)}o.setGridLegends({[e.id]:{stops:k,squareSize:z}})}};return(0,ie.useEffect)(()=>{s&&l?u(!0):s&&u(!1)},[s,l]),(0,ie.useEffect)(()=>{if(!s||!r)return;let d=()=>u(!1);return r.on("idle",d),()=>{r.off("idle",d)}},[s,r]),(0,ie.useEffect)(()=>()=>{o.setGridLegends(d=>{let b={...d};return delete b[e.id],b})},[e.id]),(0,St.jsx)(le.Source,{id:e.id,type:"geojson",data:n.geojson,children:(0,St.jsx)(le.Layer,{beforeId:t,id:e.id,type:"fill",paint:n.paint})})}var ir=require("react"),Ie=require("react-map-gl/maplibre");var ke=require("react/jsx-runtime"),jr={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Ve({layer:e,beforeId:t}){let{layer:o}=c(),r=(0,ir.useMemo)(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,o.selectedFeatures]),n=o.selectedFeaturesId?.[e.id];return(0,ke.jsxs)(Ie.Source,{...e.source,children:[r&&(0,ke.jsx)(Ie.Layer,{beforeId:t,...r}),n&&r&&(0,ke.jsx)(Ie.Layer,{...r,beforeId:t,id:`hl_${e.id}`,filter:["in",R,...n],type:r.type==="fill"?"line":r.type,paint:jr[r.type]})]})}var We=require("react-map-gl/maplibre");var It=require("react/jsx-runtime");function kt({data:e,beforeId:t}){let{mp:o}=c();return(0,It.jsx)(We.Source,{id:e.id,type:"raster",tiles:[`${o?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:(0,It.jsx)(We.Layer,{id:e.id,beforeId:t,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var Ce=require("react/jsx-runtime");function cr({layer:e,beforeId:t}){let{mapl:o}=(0,lr.useMap)();if(!o)return null;switch(e.source.type){case"vector":return(0,Ce.jsx)(Ve,{beforeId:t,layer:e});case"grid":return(0,Ce.jsx)(wt,{beforeId:t,data:e});case"raster":return(0,Ce.jsx)(kt,{beforeId:t,data:e});default:return(0,Ce.jsx)(Ve,{beforeId:t,layer:e})}}var dr=require("react"),pr=require("react-map-gl/maplibre");var ce=require("react/jsx-runtime"),Jr=pr.Marker,Kr=()=>{let{mp:e}=c(),t=(0,dr.useMemo)(()=>e.markers,[e.markers]);return(0,ce.jsx)(ce.Fragment,{children:t?.map(({latitude:o,longitude:r,colorHex:n},a)=>(0,ce.jsx)(Jr,{latitude:o,longitude:r,children:(0,ce.jsx)("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},ur=Kr;var mr=C(require("clsx"),1),fr=require("react-map-gl/maplibre"),de=require("twind");var N=require("react/jsx-runtime"),Xr=fr.Popup;function Ct({coordinates:e}){let{hover:t}=c();return e?.lat&&t.features?(0,N.jsx)(Xr,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:(0,N.jsxs)("table",{className:de.tw`table-auto border`,children:[(0,N.jsx)("thead",{children:(0,N.jsx)("tr",{children:(0,N.jsx)("th",{className:de.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:t.features.title})})}),(0,N.jsx)("tbody",{children:t.features.data.map(([o,r],n)=>(0,N.jsxs)("tr",{className:(0,de.tw)((0,mr.default)({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[(0,N.jsx)("td",{className:de.tw`py-1 px-2`,children:o}),(0,N.jsx)("td",{className:de.tw`py-1 px-2 border-l border-gray-100`,children:r})]},o+r))})]})}):null}var E=require("react/jsx-runtime"),Qr=pe.NavigationControl;function Pt(){let{mp:e,layer:t,hover:o,query:r}=c(),[n,a]=(0,Ze.useState)(),s=(0,Ze.useMemo)(()=>e.defaultViewState||yr.defaultViewState,[e.defaultViewState]),l=d=>r.setClickedLngLat(d.lngLat),u=d=>{a(d.lngLat),o.onHover(d)};return(0,E.jsxs)("div",{className:gr.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,E.jsx)(xt,{}),t.selectedFeatures?.length>0&&(0,E.jsx)(lt,{}),(0,E.jsxs)(pe.default,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:t.mapStyle,maxZoom:t.maxZoom,onClick:l,onMouseMove:u,children:[(0,E.jsx)(Qr,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,E.jsx)(pe.FullscreenControl,{position:"bottom-right"}),(0,E.jsx)(ur,{}),t.selectedLayers.map((d,b)=>{let L=b>0?t.selectedIds[b-1]:void 0;return(0,E.jsx)(cr,{layer:d,beforeId:L},d.id)}),(0,E.jsx)(Ct,{coordinates:n},"popup")]})]})}var Pe=require("react/jsx-runtime");(0,vr.setup)({preflight:!1});var en=e=>{let t=br.default.useMemo(()=>({...Ht,...e}),[e]);return(0,Pe.jsx)(Lr.MapProvider,{children:(0,Pe.jsx)(hr.TranslationProvider,{localeStrings:zt,lang:t.lang,children:(0,Pe.jsx)(ao,{mp:t,children:(0,Pe.jsx)(Pt,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ViewState } from 'react-map-gl/maplibre';
|
|
3
|
+
import { MapStyles } from '@biodiv-platform/naksha-commons';
|
|
4
|
+
|
|
5
|
+
type LayerType = "grid" | "vector" | "raster";
|
|
6
|
+
interface ExtendedMarkerProps {
|
|
7
|
+
latitude: number;
|
|
8
|
+
longitude: number;
|
|
9
|
+
colorHex: string;
|
|
10
|
+
}
|
|
11
|
+
interface NakshaMaplibreLayersProps {
|
|
12
|
+
defaultViewState?: Partial<ViewState>;
|
|
13
|
+
loadToC?: boolean;
|
|
14
|
+
showToC?: boolean;
|
|
15
|
+
showFullscreenControl?: boolean;
|
|
16
|
+
managePublishing?: boolean;
|
|
17
|
+
nakshaEndpointToken?: string;
|
|
18
|
+
nakshaApiEndpoint?: string;
|
|
19
|
+
bearerToken?: string;
|
|
20
|
+
geoserver?: {
|
|
21
|
+
endpoint: string;
|
|
22
|
+
store: string;
|
|
23
|
+
workspace: string;
|
|
24
|
+
onClick?: any;
|
|
25
|
+
};
|
|
26
|
+
selectedLayers?: string[];
|
|
27
|
+
onSelectedLayersChange?: any;
|
|
28
|
+
mapStyle?: MapStyles;
|
|
29
|
+
mapStyles?: Array<{
|
|
30
|
+
text: string;
|
|
31
|
+
key: string;
|
|
32
|
+
style: string;
|
|
33
|
+
maxZoom?: number;
|
|
34
|
+
}>;
|
|
35
|
+
layers?: GeoserverLayer[];
|
|
36
|
+
onLayerDownload?: any;
|
|
37
|
+
canLayerShare?: any;
|
|
38
|
+
lang?: any;
|
|
39
|
+
markers?: ExtendedMarkerProps[];
|
|
40
|
+
children?: any;
|
|
41
|
+
}
|
|
42
|
+
interface VectorStyleMeta {
|
|
43
|
+
styleName?: any;
|
|
44
|
+
styleTitle?: any;
|
|
45
|
+
colors?: any;
|
|
46
|
+
}
|
|
47
|
+
interface GeoserverLayer {
|
|
48
|
+
id: string;
|
|
49
|
+
index?: number;
|
|
50
|
+
title: string;
|
|
51
|
+
description?: string;
|
|
52
|
+
thumbnail?: string;
|
|
53
|
+
attribution?: string;
|
|
54
|
+
license?: string;
|
|
55
|
+
tags?: string[];
|
|
56
|
+
createdBy?: string;
|
|
57
|
+
layerStatus?: string;
|
|
58
|
+
author?: {
|
|
59
|
+
name: string;
|
|
60
|
+
};
|
|
61
|
+
url?: string;
|
|
62
|
+
createdDate?: string;
|
|
63
|
+
isDownloadable?: boolean;
|
|
64
|
+
bbox?: any[];
|
|
65
|
+
zoomToFit?: boolean;
|
|
66
|
+
isAdded?: boolean;
|
|
67
|
+
ats?: any;
|
|
68
|
+
source: {
|
|
69
|
+
type: LayerType;
|
|
70
|
+
scheme?: any;
|
|
71
|
+
tiles?: any;
|
|
72
|
+
endpoint?: any;
|
|
73
|
+
fetcher?: any;
|
|
74
|
+
};
|
|
75
|
+
onClick?: ({ bbox, feature, layerId }: {
|
|
76
|
+
bbox: any;
|
|
77
|
+
feature: any;
|
|
78
|
+
layerId: any;
|
|
79
|
+
}) => JSX.Element;
|
|
80
|
+
onHover?: ({ bbox, feature, layerId }: {
|
|
81
|
+
bbox: any;
|
|
82
|
+
feature: any;
|
|
83
|
+
layerId: any;
|
|
84
|
+
}) => JSX.Element;
|
|
85
|
+
data?: {
|
|
86
|
+
styles?: VectorStyleMeta[];
|
|
87
|
+
styleIndex?: any;
|
|
88
|
+
propertyMap?: any;
|
|
89
|
+
titleColumn?: any;
|
|
90
|
+
summaryColumn?: any;
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
declare const NakshaMaplibreLayers: (props: NakshaMaplibreLayersProps) => React.JSX.Element;
|
|
96
|
+
|
|
97
|
+
export { NakshaMaplibreLayers };
|
package/dist/index.d.ts
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Uo=Object.create;var Pe=Object.defineProperty,Ko=Object.defineProperties,Xo=Object.getOwnPropertyDescriptor,Qo=Object.getOwnPropertyDescriptors,jo=Object.getOwnPropertyNames,Kt=Object.getOwnPropertySymbols,en=Object.getPrototypeOf,Qt=Object.prototype.hasOwnProperty,tn=Object.prototype.propertyIsEnumerable;var lt=Math.pow,Xt=(e,r,t)=>r in e?Pe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,m=(e,r)=>{for(var t in r||(r={}))Qt.call(r,t)&&Xt(e,t,r[t]);if(Kt)for(var t of Kt(r))tn.call(r,t)&&Xt(e,t,r[t]);return e},T=(e,r)=>Ko(e,Qo(r));var rn=(e,r)=>{for(var t in r)Pe(e,t,{get:r[t],enumerable:!0})},jt=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of jo(r))!Qt.call(e,n)&&n!==t&&Pe(e,n,{get:()=>r[n],enumerable:!(o=Xo(r,n))||o.enumerable});return e};var O=(e,r,t)=>(t=e!=null?Uo(en(e)):{},jt(r||!e||!e.__esModule?Pe(t,"default",{value:e,enumerable:!0}):t,e)),on=e=>jt(Pe({},"__esModule",{value:!0}),e);var v=(e,r,t)=>new Promise((o,n)=>{var a=i=>{try{c(t.next(i))}catch(l){n(l)}},s=i=>{try{c(t.throw(i))}catch(l){n(l)}},c=i=>i.done?o(i.value):Promise.resolve(i.value).then(a,s);c((t=t.apply(e,r)).next())});var xn={};rn(xn,{NakshaMaplibreLayers:()=>Ln});module.exports=on(xn);var Go=require("@biodiv-platform/naksha-commons"),_o=O(require("react")),Oo=require("react-map-gl/maplibre"),Do=require("twind");var er={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var tr={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var rr={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var or={en:er,fr:tr,hi:rr};var Ao=require("@biodiv-platform/naksha-commons"),nt=require("react"),Le=O(require("react-map-gl/maplibre")),Bo=require("twind");var Ze=require("@biodiv-platform/naksha-commons"),S=O(require("react")),xr=require("react-map-gl/maplibre");var mr=O(require("colorbrewer")),Q=O(require("redaxios"));var ft=O(require("boundingbox")),We=require("geohash");var $e=require("@biodiv-platform/naksha-commons");var nr={defaultViewState:$e.defaultViewState,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:$e.MapStyles.MAP_STREETS,layers:[],selectedLayers:[]},ar="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",ct={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},sr=T(m({},ct),{WebkitLineClamp:2}),q="ogc_fid",Ve={ACTIVE:"Active",PENDING:"Pending"},$={TOP:"layer_selection_top",ALL:"layer_selection_all"};var ir=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],ut="0123456789bcdefghjkmnpqrstuvwxyz",ln=(e,r,t)=>{t=t||16/lt(2,1-e.length&1)/lt(4,r);let o=e.slice(0,-1),n=~~(ut.indexOf(e.slice(-1))/t);return[o+ut[t*n],o+ut[t*(n+1)-1]]},cn=function(e,r){var t=new Map,o=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[c,i]=ln(a,r);o.set(c,i),t.has(c)||t.set(c,0),t.set(c,t.get(c)+s)}return t.forEach((a,s)=>{let c=We.GeoHash.decodeGeoHash(s),i=We.GeoHash.decodeGeoHash(o.get(s)),l=new ft.default({minlat:c.latitude[0],minlon:c.longitude[0],maxlat:i.latitude[1],maxlon:i.longitude[1]}).toGeoJSON();n.push(T(m({},l),{properties:{count:a,[q]:s}}))}),n},un=e=>{let r=[];for(let[t,o]of Object.entries(e)){let n=We.GeoHash.decodeGeoHash(t),a=new ft.default({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();r.push(T(m({},a),{properties:{count:o,[q]:t}}))}return r},lr=(e,r)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:r===-1?un(e):cn(e,r)}),cr=(e,r)=>{let t=Object.values(e).sort((a,s)=>a-s),o=Math.floor(t.length/r),n=new Array(r-1).fill(0).map((a,s)=>t[o*(s+1)]);return n.push(t[t.length-1]),n};var ur=O(require("immer"));var fr=(e,r,t,o)=>v(void 0,null,function*(){let n=[];for(let a of e){let s=o.includes(a.name),c=T(m({},a),{id:a.name,thumbnail:r+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s});if(s){let i=yield dt(c,0,r,t);n.push(T(m({},c),{data:i}))}else n.push(c)}return n}),dt=(e,r,t,o)=>v(void 0,null,function*(){return(0,ur.default)(e.data,a=>v(void 0,null,function*(){var s;if(a.styles.length===0){let{success:c,data:i}=yield dr(e.id,t);c&&(a.layerName=i.layerName,a.styles=i.styles,a.summaryColumn=i.summaryColumn,a.titleColumn=i.titleColumn,a.propertyMap=Object.fromEntries(i.styles.map(l=>[l.styleName,l.styleTitle])))}a.styles[r]&&!((s=a.styles[r])!=null&&s.colors)&&(a.styles[r].colors=yield pr(e.id,o==null?void 0:o.workspace,a.styles[r].styleName,t)),a.styleIndex=r}))});var yr=(e,r,t,o)=>v(void 0,null,function*(){try{let n=yield Q.default.get(`${r}/layer/all`,{headers:{Authorization:e}});return yield fr(n.data,r,t,o)}catch(n){return console.error(n),[]}}),dr=(e,r)=>v(void 0,null,function*(){try{let{data:t}=yield Q.default.get(`${r}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}}),gr=(e,r,t)=>v(void 0,null,function*(){let o={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(yield Q.default.get(`${e}/${r}/wms`,{params:m(m({},t),o)})).data}}catch(n){return console.error(n),{success:!1,data:[]}}}),hr=(e,r,t,o)=>v(void 0,null,function*(){try{return yield Q.default.put(`${r}/layer/${o?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}}),vr=(e,r,t)=>v(void 0,null,function*(){try{return yield Q.default.delete(`${r}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}}),pr=(e,r,t,o)=>v(void 0,null,function*(){var n,a;try{return(a=(n=(yield Q.default.get(`${o}/geoserver/workspaces/${r}/styles/${e}_${t}.mbstyle`)).data)==null?void 0:n.layers)==null?void 0:a[0]}catch(s){return console.error(s),{}}}),br=(e,r,t,o=6,n="YlOrRd")=>v(void 0,null,function*(){try{let[a,s,c]=ir(t),{_ne:i,_sw:l}=r,p={top:i.lat,left:l.lng,bottom:l.lat,right:i.lng,geoAggegationPrecision:a},h=yield e(p),k=lr(h,s),M=cr(h,o).map((R,x)=>[R,mr.default[n][o][x]]);return{success:!0,geojson:k,paint:{"fill-color":{property:"count",default:"yellow",stops:M},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:M,squareSize:c}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}}),Lr=(e,r,t,o)=>v(void 0,null,function*(){try{yield Q.default.post(`${e}/layer/download`,{layerName:t,layerTitle:o,attributeList:[],filterArray:[]},{headers:{Authorization:r}})}catch(n){console.error(n)}});var kr=require("react/jsx-runtime"),wr=(0,S.createContext)({}),Sr=({mp:e,children:r})=>{var Wt,Zt;let[t,o]=(0,S.useState)(e),{mapl:n}=(0,xr.useMap)(),[a,s]=(0,S.useState)(""),c=(0,Ze.useDebounce)(a,500),i=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:Ze.defaultMapStyles,[l,p]=(0,S.useState)((Wt=i[(t==null?void 0:t.mapStyle)||0])==null?void 0:Wt.style),[h,k]=(0,S.useState)((Zt=i[(t==null?void 0:t.mapStyle)||0])==null?void 0:Zt.maxZoom),[P,M]=(0,S.useState)($.TOP),[N,R]=(0,S.useState)({}),[x,_]=(0,S.useState)(!0),[b,U]=(0,S.useState)(),[C,at]=(0,S.useState)(e.layers||[]),[A,xe]=(0,S.useState)(t.selectedLayers||[]),[Fe,Ht]=(0,S.useState)(),[st,Ft]=(0,S.useState)(),zo=(0,S.useMemo)(()=>{var g;let d={};for(let y of st||[])d[y.sourceLayer]=[...d[y.sourceLayer]||[],(g=y==null?void 0:y.properties)==null?void 0:g[q]];return Object.keys(d).length?d:void 0},[st]),we=S.default.useMemo(()=>{let d=C.filter(y=>A.includes(y.id)),g=new Array(A.length);for(let y of d){let E=A.findIndex(F=>y.id===F);E>-1&&(g[E]=y)}return g},[C,A]),qe=d=>C.findIndex(g=>g.id===d),qt=(d,g)=>{at(y=>y.map(E=>E.id===d?m(m({},E),g):E))},$t=(d,g,y)=>v(void 0,null,function*(){let E=C[d],F=yield dt(E,g,t.nakshaApiEndpoint,t.geoserver);qt(E.id,{data:F}),y&&(n==null||n.fitBounds(E.bbox,{padding:40,duration:1e3}))}),Ho=(d,g)=>v(void 0,null,function*(){let y=qe(d);$t(y,g,!1)}),Fo=d=>v(void 0,null,function*(){var g,y,E,F;if(!(!A.length||!n))try{let K=A[0],Se=n.queryRenderedFeatures(d.point,{layers:[K]});if(Se.length){let ke=((g=Se[0])==null?void 0:g.id)||((E=(y=Se[0])==null?void 0:y.properties)==null?void 0:E[q]);if(ke===(Fe==null?void 0:Fe.id))return;let X=C[qe(K)],re=(F=X==null?void 0:X.data)==null?void 0:F.summaryColumn.map(oe=>{var Yt,Jt,Ut;return[((Jt=(Yt=X.data)==null?void 0:Yt.propertyMap)==null?void 0:Jt[oe])||oe,(Ut=Se[0].properties)==null?void 0:Ut[oe]]});Ht({id:ke,title:X.title,data:re})}else Ht(void 0)}catch(K){}}),qo=F=>v(void 0,[F],function*({layerId:d,add:g,styleIndex:y=0,focus:E=!0}){var ke,X;if(!g){xe(A.filter(re=>d!==re));return}let K=qe(d);((ke=C[K])==null?void 0:ke.source.type)==="grid"?(xe(re=>[d,...re.filter(oe=>oe!==d)]),E&&((X=C[K])==null?void 0:X.bbox)&&setTimeout(()=>{n==null||n.fitBounds(C[K].bbox,{padding:40,duration:1e3})},100)):(yield $t(K,y,E),xe(re=>[d,...re.filter(oe=>oe!==d)]))}),$o=()=>v(void 0,null,function*(){return xe([])}),Vo=(d,g)=>{o(T(m({},t),{[d]:g}))},Wo=(d,g)=>{let y=g===Ve.PENDING;hr(t.nakshaEndpointToken,t.nakshaApiEndpoint,d,y),qt(d,{layerStatus:y?Ve.ACTIVE:Ve.PENDING})},Zo=(d,g)=>v(void 0,null,function*(){confirm(g)&&(vr(t.nakshaEndpointToken,t.nakshaApiEndpoint,d),at(C.filter(y=>y.id!==d)))}),Yo=d=>{let g=qe(d),y=C[g];n==null||n.fitBounds(y.bbox,{padding:40,duration:1e3})},Vt=()=>[b.lng,b.lat,b.lng+.1,b.lat+.1],Jo=d=>{M(d),d===$.TOP&&it(d)},it=d=>{if(!!b)try{let g=n==null?void 0:n.project([b.lng,b.lat]),y=n==null?void 0:n.queryRenderedFeatures(g,{layers:P===$.TOP?[A[0]]:A});if((d||P)===$.ALL){let E=we.filter(F=>F.layerType=="RASTER").map(F=>({sourceLayer:F.id,layerType:"raster",bbox:Vt()}));y=[...y,...E]}Ft((we==null?void 0:we[0].layerType)==="RASTER"&&P!==$.ALL?A.length&&(y==null?void 0:y.length)?y:[{sourceLayer:A[0],layerType:"raster",bbox:Vt()}]:y)}catch(g){console.error(g)}};return(0,S.useEffect)(()=>{t.onSelectedLayersChange&&t.onSelectedLayersChange(A)},[A]),(0,S.useEffect)(()=>{setTimeout(it,300)},[b,P,A]),(0,kr.jsx)(wr.Provider,{value:{mp:t,updateMP:Vo,layer:{mapStyle:l,featuresAtLatLng:it,setMapStyle:p,maxZoom:h,setMaxZoom:k,mapStyles:i,all:C,setAll:at,selectedIds:A,handleSelectStyle:Jo,setSelectedIds:xe,selectedLayers:we,clearAll:$o,toggle:qo,updateStyle:Ho,selectedFeatures:st,selectedFeaturesId:zo,setSelectedFeatures:Ft,togglePublish:Wo,delete:Zo,selectionStyle:P,setSelectionStyle:M,zoomToExtent:Yo,gridLegends:N,setGridLegends:R},query:{term:c,setTerm:s,clickedLngLat:b,setClickedLngLat:U},isInfoBarOpen:x,setIsInfoBarOpen:_,hover:{onHover:Fo,features:Fe}},children:r})};function f(){return(0,S.useContext)(wr)}var zr=O(require("react")),Ie=require("twind");var Pr=require("twind"),u=require("react/jsx-runtime"),Cr=()=>(0,u.jsx)("svg",{fill:"none",className:Pr.tw`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:(0,u.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),Ce=()=>(0,u.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,u.jsx)("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),(0,u.jsx)("path",{d:"M2 17L12 22 22 17"}),(0,u.jsx)("path",{d:"M2 12L12 17 22 12"})]}),Ye=()=>(0,u.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,u.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,u.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),Ir=()=>(0,u.jsxs)("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[(0,u.jsx)("path",{d:"M4 21L4 14"}),(0,u.jsx)("path",{d:"M4 10L4 3"}),(0,u.jsx)("path",{d:"M12 21L12 12"}),(0,u.jsx)("path",{d:"M12 8L12 3"}),(0,u.jsx)("path",{d:"M20 21L20 16"}),(0,u.jsx)("path",{d:"M20 12L20 3"}),(0,u.jsx)("path",{d:"M1 14L7 14"}),(0,u.jsx)("path",{d:"M9 8L15 8"}),(0,u.jsx)("path",{d:"M17 16L23 16"})]});function pt(){return(0,u.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function Mr(){return(0,u.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function Er(){return(0,u.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function Tr(){return(0,u.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function Nr(){return(0,u.jsx)("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function Rr(){return(0,u.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function Ar(){return(0,u.jsx)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,u.jsx)("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function Br(){return(0,u.jsxs)("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[(0,u.jsx)("circle",{cx:"18",cy:"5",r:"3"}),(0,u.jsx)("circle",{cx:"6",cy:"12",r:"3"}),(0,u.jsx)("circle",{cx:"18",cy:"19",r:"3"}),(0,u.jsx)("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),(0,u.jsx)("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function Gr(){return(0,u.jsx)("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:(0,u.jsx)("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function _r(){return(0,u.jsxs)("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,u.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,u.jsx)("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),(0,u.jsx)("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),(0,u.jsx)("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),(0,u.jsx)("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function Or(){return(0,u.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,u.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function Dr(){return(0,u.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:(0,u.jsx)("polyline",{points:"18 15 12 9 6 15"})})}var ne=require("react/jsx-runtime"),j=zr.default.forwardRef((e,r)=>(0,ne.jsx)("button",m({ref:r,type:"button",className:Ie.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`},e)));var Je=e=>(0,ne.jsx)("button",m({className:Ie.tw`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715"},e)),Hr=e=>(0,ne.jsx)("button",T(m({className:Ie.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`},e),{children:(0,ne.jsx)(Ce,{})})),Fr=e=>(0,ne.jsx)("button",T(m({className:Ie.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`},e),{children:(0,ne.jsx)(Ye,{})}));var ae=require("twind");var G=require("react/jsx-runtime");var ce=e=>(0,G.jsxs)("div",{children:[e.label&&(0,G.jsx)("label",{className:ae.tw`text-gray-700`,htmlFor:e.name,children:e.label}),(0,G.jsx)("select",m({id:e.name,name:e.name,className:ae.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`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"}},e))]}),qr=e=>(0,G.jsxs)("div",{className:"relative",children:[(0,G.jsx)("span",{className:ae.tw`absolute inset-y-0 left-0 flex items-center pl-3`,children:(0,G.jsx)(Cr,{})}),(0,G.jsx)("input",m({type:"search",className:ae.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`},e))]}),$r=e=>e.isLoading?(0,G.jsx)("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:ae.tw`inline text-gray-200 animate-spin dark:text-gray-600`,children:(0,G.jsx)("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:(0,G.jsx)("g",{fill:"#212121",fillRule:"nonzero",children:(0,G.jsx)("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):(0,G.jsx)("input",{type:"checkbox",className:ae.tw`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});var se=require("@bumaga/tabs"),Vr=O(require("clsx")),Me=require("twind"),ue=require("react/jsx-runtime"),Ue=({children:e,icon:r})=>{let{onClick:t,isActive:o}=(0,se.useTabState)(),n=(0,Vr.default)(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":o,"text-gray-700 border-gray-300 hover:border-gray-400":!o}]);return(0,ue.jsxs)("button",{className:(0,Me.tw)(n),onClick:t,children:[r,(0,ue.jsx)("span",{className:Me.tw`ml-2 text-base`,children:e})]})},Ke=({children:e})=>(0,se.usePanelState)()?(0,ue.jsx)("div",{className:Me.tw`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Wr=({children:e})=>(0,ue.jsx)("div",{className:Me.tw`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});var Jr=require("@biodiv-platform/naksha-commons"),Re=require("twind");var Zr=require("@biodiv-platform/naksha-commons");var mt=require("react/jsx-runtime");function Ee({hideLabel:e}){let{layer:{selectionStyle:r,handleSelectStyle:t}}=f(),{t:o}=(0,Zr.useT)(),n=a=>{t(a.target.value)};return(0,mt.jsx)(ce,{name:"layer_selection",label:e?null:o("layer_selection"),defaultValue:r,onChange:n,children:Object.values($).map(a=>(0,mt.jsx)("option",{value:a,children:o(a)},a))})}var Yr=O(require("clsx")),Ne=require("react"),Te=require("twind");var V=require("react/jsx-runtime");function yt({data:e}){let[r,t]=(0,Ne.useState)(!0),[o,n]=(0,Ne.useState)({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:c}}=f(),i=()=>v(this,null,function*(){var h,k,P,M,N,R;let l,p=a.selectedLayers.find(x=>x.id===(e.sourceLayer||e.source));if(p.layerType.toLowerCase()==="raster"){let{data:x}=yield gr((h=s.geoserver)==null?void 0:h.endpoint,(k=s.geoserver)==null?void 0:k.workspace,{bbox:e.bbox.toString(),query_layers:`${(P=s.geoserver)==null?void 0:P.workspace}:${p.id}`,layers:`${(M=s.geoserver)==null?void 0:M.workspace}:${p.id}`});l=x!=null&&x.features[0]?Object.entries((N=x.features[0])==null?void 0:N.properties).map(([_,b])=>[b||"-"]):[]}else l=Object.entries(((R=p==null?void 0:p.data)==null?void 0:R.propertyMap)||{}).map(([x,_])=>{var b;return[_,(b=e==null?void 0:e.properties)==null?void 0:b[x]]});n({title:p.title,properties:l})});return(0,Ne.useEffect)(()=>{i()},[c]),(0,V.jsxs)("div",{className:Te.tw`bg-gray-100 rounded-lg`,children:[(0,V.jsxs)("button",{className:(0,Te.tw)((0,Yr.default)(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":r,"rounded-lg":!r}])),onClick:()=>t(!r),children:[o.title," ",r?(0,V.jsx)(Dr,{}):(0,V.jsx)(Or,{})]}),r&&(0,V.jsx)("div",{className:Te.tw`px-4 py-3 flex flex-col gap-3`,children:o.properties.map(([l,p],h)=>(0,V.jsxs)("div",{children:[(0,V.jsx)("div",{className:Te.tw`text-gray-600`,children:l}),(0,V.jsx)("div",{children:p})]},l+p+h))})]})}var D=require("react/jsx-runtime");function gt({onClose:e}){var a;let{layer:{selectedFeatures:r,selectedLayers:t,selectionStyle:o}}=f(),{t:n}=(0,Jr.useT)();return(0,D.jsxs)("div",{className:Re.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`,children:[(0,D.jsxs)("div",{className:"flex w-full",children:[(0,D.jsxs)("div",{className:Re.tw`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[(0,D.jsx)(_r,{})," ",n("infobar")]}),(0,D.jsx)(Je,{onClick:e})]}),(0,D.jsx)("div",{className:Re.tw`bg-gray-100 p-4 flex-shrink-0 rt`,children:(0,D.jsx)(Ee,{hideLabel:!0})}),(0,D.jsx)("div",{className:Re.tw`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:(a=r.flat(1))==null?void 0:a.map(s=>{var c;return(0,D.jsx)(yt,{data:s},((c=t==null?void 0:t[0])==null?void 0:c.source.type)==="raster"||o===$.ALL?s==null?void 0:s.sourceLayer:(s==null?void 0:s.sourceLayer)+(s==null?void 0:s.properties[q]))})})]})}var ht=require("react/jsx-runtime");function vt(){var n;let{layer:e,isInfoBarOpen:r,setIsInfoBarOpen:t}=f();if(!((n=e.selectedFeatures)!=null&&n.length))return null;let o=()=>t(!r);return r?(0,ht.jsx)(gt,{onClose:o}):(0,ht.jsx)(Fr,{onClick:o})}var tt=require("react"),So=require("react-map-gl/maplibre");var wo=require("@biodiv-platform/naksha-commons"),Mt=require("twind");var yo=require("twind");var et=O(require("react")),co=require("react-virtual"),uo=O(require("react-virtualized-auto-sizer")),xt=require("twind");var io=require("@biodiv-platform/naksha-commons"),Be=require("react"),lo=require("react-web-share"),Y=require("twind");var ee=require("react/jsx-runtime"),Ur=({text:e="",highlight:r=""})=>{if(!r.trim())return(0,ee.jsx)(ee.Fragment,{children:e});let t=new RegExp(`(${r})`,"gi"),o=e.split(t);return(0,ee.jsx)(ee.Fragment,{children:o.filter(n=>n).map((n,a)=>t.test(n)?(0,ee.jsx)("mark",{children:n},a):(0,ee.jsx)("span",{children:n},a))})};var jr=require("twind");var Kr=require("@biodiv-platform/naksha-commons"),Xr=require("react"),Qr=require("twind"),Xe=require("react/jsx-runtime");function Ae({children:e}){let[r,t]=(0,Xr.useState)(!1),{t:o}=(0,Kr.useT)();return(0,Xe.jsxs)("div",{children:[r&&e,(0,Xe.jsx)("button",{onClick:()=>t(!r),className:Qr.tw`text-blue-600 focus:outline-none focus:outline focus:ring`,children:o(r?"less":"legend")})]})}var W=require("react/jsx-runtime");function bt({item:e}){let{layer:r}=f(),t=r.gridLegends[e.id];return t?(0,W.jsx)(Ae,{children:(0,W.jsxs)("ul",{style:{margin:0,padding:0},children:[t==null?void 0:t.stops.map(([o,n],a,s)=>{let c=(s[a-1]||[0])[0];return c===o?(0,W.jsx)("div",{},n):(0,W.jsxs)("li",{className:jr.tw`flex gap-2 items-center mb-1`,children:[(0,W.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,W.jsx)("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),(0,W.jsxs)("div",{children:[c," - ",o]})]},n)}),(0,W.jsxs)("li",{children:["1 Square = ",t==null?void 0:t.squareSize," x ",t==null?void 0:t.squareSize," km"]})]})}):null}var Qe=require("@biodiv-platform/naksha-commons"),eo=require("react"),to=require("react-tiny-popover"),de=require("twind");var w=require("react/jsx-runtime"),fe=({icon:e,name:r,title:t,link:o,children:n})=>{let a=(0,w.jsx)("span",{children:n||"-"});return(0,w.jsxs)("div",{className:de.tw`flex gap-3 text-sm text-gray-600 break-all`,title:r&&t&&`${r}: ${t}`,children:[(0,w.jsx)("div",{children:e}),o?(0,w.jsx)("a",{className:de.tw`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:o,children:a}):a]})};function fn({item:e,containerStyle:r}){var i;let{t}=(0,Qe.useT)(),{layer:o,mp:n}=f(),a=e.license||"CC-BY",s=(e==null?void 0:e.createdDate)&&new Date(e.createdDate).toLocaleDateString(),c=(i=e.tags)==null?void 0:i.join(", ");return(0,w.jsxs)("div",{className:de.tw`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:r,children:[n.managePublishing&&e.layerStatus&&(0,w.jsxs)(fe,{icon:(0,w.jsx)(Tr,{}),name:t("visiblity"),title:e.layerStatus,children:[e.layerStatus,(0,w.jsx)("button",{className:de.tw`text-blue-600 focus:outline-none ml-4`,onClick:()=>o.togglePublish(e.id,e==null?void 0:e.layerStatus),children:t("toggle")}),(0,w.jsx)("button",{className:de.tw`text-red-600 focus:outline-none ml-4`,onClick:()=>o.delete(e.id,t("are_you_sure")),children:t("delete")})]}),(0,w.jsx)(fe,{icon:(0,w.jsx)(pt,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),(0,w.jsx)(fe,{icon:(0,w.jsx)(pt,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),(0,w.jsx)(fe,{icon:(0,w.jsx)(Nr,{}),name:t("created_on"),title:s,children:s}),(0,w.jsx)(fe,{icon:(0,w.jsx)(Mr,{}),name:t("tags"),title:c,children:c}),(0,w.jsx)(fe,{name:t("license"),title:a,link:a&&Qe.LICENSES[a],icon:(0,w.jsx)(Er,{}),children:a})]})}var ro=({item:e})=>{let[r,t]=(0,eo.useState)(!1),o=()=>t(!r);return(0,w.jsx)(to.Popover,{isOpen:r,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:o,content:(0,w.jsx)(fn,{item:e}),children:(0,w.jsx)(j,{onClick:o,children:(0,w.jsx)(Ye,{}),title:"Information"})})};var so=require("twind");var je=require("react"),oo=require("@biodiv-platform/naksha-commons"),no=require("twind");var Z=require("react/jsx-runtime");function ao({item:e}){var c;let[r,t]=(0,je.useState)(!0),{mp:o}=f(),{t:n}=(0,oo.useT)(),a=(0,je.useMemo)(()=>{var i,l,p,h,k,P,M,N,R,x,_,b;return((P=(k=(h=(p=(l=(i=e==null?void 0:e.data)==null?void 0:i.styles)==null?void 0:l[e.data.styleIndex])==null?void 0:p.colors)==null?void 0:h.paint)==null?void 0:k["fill-color"])==null?void 0:P.stops)||((b=(_=(x=(R=(N=(M=e==null?void 0:e.data)==null?void 0:M.styles)==null?void 0:N[e.data.styleIndex])==null?void 0:R.colors)==null?void 0:x.paint)==null?void 0:_["circle-color"])==null?void 0:b.stops)||[]},[e]),s=()=>a.map(([i,l])=>(0,Z.jsxs)("li",{className:no.tw`flex gap-2 items-center mb-1`,children:[(0,Z.jsx)("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:(0,Z.jsx)("circle",{cx:"12",fill:l,cy:"12",r:"12",stroke:"none"})}),(0,Z.jsx)("div",{children:i})]},l));return(0,Z.jsx)("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():r?(0,Z.jsx)("li",{children:(0,Z.jsx)("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${(c=o==null?void 0:o.geoserver)==null?void 0:c.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):(0,Z.jsx)("div",{children:n("raster_style_not_found")})})}var ie=require("react/jsx-runtime");function Lt({item:e}){var o,n;if(!((o=e.data)!=null&&o.styles))return null;let{layer:r}=f(),t=a=>{r.updateStyle(e.id,Number(a.target.value))};return(0,ie.jsxs)("div",{className:so.tw`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&(0,ie.jsx)(ce,{onChange:t,children:(n=e.data)==null?void 0:n.styles.map((a,s)=>(0,ie.jsx)("option",{value:s,children:a.styleTitle},s))}),(0,ie.jsx)(Ae,{children:(0,ie.jsx)(ao,{item:e})})]})}var L=require("react/jsx-runtime");function dn({dragHandleProps:e}){return(0,L.jsx)("div",T(m({className:Y.tw`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"}},e),{children:(0,L.jsx)(Gr,{})}))}function Ge({item:e,extended:r,dragHandleProps:t}){let{t:o}=(0,io.useT)(),{layer:n,query:a,mp:s,query:{setClickedLngLat:c},setIsInfoBarOpen:i}=f(),[l,p]=(0,Be.useState)(n.selectedIds.includes(e.id)),[h,k]=(0,Be.useState)(!1),P=(0,Be.useMemo)(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),M=()=>v(this,null,function*(){k(!0),i(!0),n.setSelectedFeatures([]),c(null),yield n.toggle({layerId:e.id,add:!l}),p(!l),k(!1)}),N=()=>v(this,null,function*(){yield Lr(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s==null||s.onLayerDownload(e.id)}),R=()=>n.zoomToExtent(e.id);return(0,L.jsxs)("div",{className:Y.tw`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[(0,L.jsxs)("div",{className:Y.tw`flex gap-3`,children:[(0,L.jsxs)("div",{className:Y.tw`flex-shrink-0`,children:[(0,L.jsx)($r,{name:e.id,checked:l,onChange:M,isLoading:h}),r&&(0,L.jsx)(dn,{dragHandleProps:t})]}),(0,L.jsx)("img",{className:Y.tw`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||ar}),(0,L.jsxs)("div",{children:[(0,L.jsx)("div",{title:e.title,className:Y.tw`mb-1 leading-tight`,style:ct,children:(0,L.jsx)(Ur,{text:e.title,highlight:a.term})}),(0,L.jsx)("p",{title:e.description,className:Y.tw`text-gray-600 text-sm`,style:sr,children:e.description})]})]}),(0,L.jsxs)("div",{className:Y.tw`flex justify-between`,children:[(0,L.jsxs)(j,{onClick:N,disabled:!e.isDownloadable,children:[(0,L.jsx)(Rr,{})," ",o("download")]}),(0,L.jsxs)("div",{className:Y.tw`flex gap-3`,children:[P&&(0,L.jsx)(lo.RWebShare,{data:P,children:(0,L.jsx)(j,{title:"Share",children:(0,L.jsx)(Br,{})})}),r&&(0,L.jsx)(j,{onClick:R,title:"Zoom To Extent",children:(0,L.jsx)(Ar,{})}),(0,L.jsx)(ro,{item:e})]})]}),r&&(0,L.jsx)(Lt,{item:e}),r&&e.source.type==="grid"&&(0,L.jsx)(bt,{item:e})]})}var te=require("react/jsx-runtime");function fo(){let{layer:e,query:r}=f(),t=(0,et.useMemo)(()=>r.term?e.all.filter(a=>a.title.toLowerCase().includes(r.term.toLowerCase())):e.all,[e.all,r.term]),o=et.default.useRef(),n=(0,co.useVirtual)({size:t.length,parentRef:o});return(0,te.jsx)("div",{className:xt.tw`flex-grow-1 relative`,children:(0,te.jsx)(uo.default,{disableWidth:!0,children:a=>(0,te.jsx)("div",{ref:o,className:"List",style:{height:a.height,overflow:"auto"},children:(0,te.jsx)("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>(0,te.jsx)("div",{ref:s.measureRef,className:xt.tw`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:(0,te.jsx)("div",{style:{height:146},children:(0,te.jsx)(Ge,{item:t[s.index]})})},s.index))})})})})}var po=require("@biodiv-platform/naksha-commons"),mo=require("twind");var wt=require("react/jsx-runtime");function St(){let{t:e}=(0,po.useT)(),{query:r}=f(),t=o=>r.setTerm(o.target.value);return(0,wt.jsx)("div",{className:mo.tw`flex-shrink-0 border-b-2 p-4`,children:(0,wt.jsx)(qr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}var _e=require("react/jsx-runtime");function kt(){return(0,_e.jsxs)("div",{className:yo.tw`flex flex-col w-full`,children:[(0,_e.jsx)(St,{}),(0,_e.jsx)(fo,{})]})}function pn(e,r,t){let o=r<0?e.length+r:r;if(o>=0&&o<e.length){let n=t<0?e.length+t:t,[a]=e.splice(r,1);e.splice(n,0,a)}}function go(e,r,t){return e=[...e],pn(e,r,t),e}var J=require("@dnd-kit/core"),pe=require("@dnd-kit/sortable"),ho=require("@dnd-kit/utilities");var le=require("react/jsx-runtime");function mn({item:e,extended:r}){let{attributes:t,listeners:o,setNodeRef:n,transform:a,transition:s,isDragging:c}=(0,pe.useSortable)({id:e.id}),i={transform:ho.CSS.Transform.toString(a),transition:s,opacity:c?.5:1};return(0,le.jsx)("div",{ref:n,style:i,children:(0,le.jsx)(Ge,{item:e,extended:r,dragHandleProps:m(m({},t),o)})})}var vo=({layerList:e,onSortEnd:r})=>{let t=(0,J.useSensors)((0,J.useSensor)(J.PointerSensor,{activationConstraint:{distance:4}}));return(0,le.jsx)(J.DndContext,{sensors:t,collisionDetection:J.closestCenter,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let c=e.findIndex(l=>l.id===a.id),i=e.findIndex(l=>l.id===s.id);c!==-1&&i!==-1&&r({oldIndex:c,newIndex:i})}},children:(0,le.jsx)(pe.SortableContext,{items:e.map(n=>n.id),strategy:pe.verticalListSortingStrategy,children:(0,le.jsx)("div",{children:e.map(n=>(0,le.jsx)(mn,{item:n,extended:!0},n.id))})})})};var bo=require("@biodiv-platform/naksha-commons"),Pt=require("twind"),me=require("react/jsx-runtime");function Ct(){let{layer:e}=f(),{t:r}=(0,bo.useT)(),t=({oldIndex:o,newIndex:n})=>{e.setSelectedIds(go(e.selectedIds,o,n))};return(0,me.jsxs)("div",{className:Pt.tw`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&(0,me.jsx)("div",{className:Pt.tw`p-3 pb-0`,children:(0,me.jsxs)(j,{onClick:()=>e.clearAll(),children:["\u2715 ",r("clear")]})}),(0,me.jsx)(vo,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}var Lo=require("@biodiv-platform/naksha-commons"),xo=require("twind");var ye=require("react/jsx-runtime");function It(){let{layer:e}=f(),{t:r}=(0,Lo.useT)(),t=o=>{var n;e.setMapStyle(o.target.value),e.setMaxZoom((n=e.mapStyles.find(a=>a.style===o.target.value))==null?void 0:n.maxZoom)};return(0,ye.jsxs)("div",{className:xo.tw`w-full p-4 flex flex-col gap-4`,children:[(0,ye.jsx)(ce,{name:"base_style",label:r("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(o=>(0,ye.jsx)("option",{value:o.style,children:o.text},o.key))}),(0,ye.jsx)(Ee,{})]})}var I=require("react/jsx-runtime");function Et({onClose:e}){let{t:r}=(0,wo.useT)();return(0,I.jsxs)("div",{className:Mt.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`,children:[(0,I.jsx)(Je,{onClick:e}),(0,I.jsx)("div",{className:Mt.tw`flex flex-col h-full`,children:(0,I.jsxs)(se.Tabs,{children:[(0,I.jsxs)(Wr,{children:[(0,I.jsx)(Ue,{icon:(0,I.jsx)(Ce,{}),children:r("layers")}),(0,I.jsx)(Ue,{icon:(0,I.jsx)(Ce,{}),children:r("selected")}),(0,I.jsx)(Ue,{icon:(0,I.jsx)(Ir,{}),children:r("settings")})]}),(0,I.jsx)(Ke,{children:(0,I.jsx)(kt,{})}),(0,I.jsx)(Ke,{children:(0,I.jsx)(Ct,{})}),(0,I.jsx)(Ke,{children:(0,I.jsx)(It,{})})]})})]})}var Tt=require("react/jsx-runtime");function Nt(){let{mp:e,layer:r}=f(),[t,o]=(0,tt.useState)(e.showToC),{mapl:n}=(0,So.useMap)(),a=()=>o(!t);function s(){return v(this,null,function*(){let c=yield yr(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),i=[...e.layers||[],...c];if(r.setAll(i),r.selectedIds.length){let l=i.find(p=>p.id===r.selectedIds[0]);l!=null&&l.bbox&&(n==null||n.fitBounds(l.bbox,{padding:40,duration:1e3}))}})}return(0,tt.useEffect)(()=>{n&&e.loadToC&&s()},[n]),t?(0,Tt.jsx)(Et,{onClose:a}):(0,Tt.jsx)(Hr,{onClick:a})}var Co=require("react-map-gl/maplibre");var B=63710088e-1,Bs={centimeters:B*100,centimetres:B*100,degrees:B/111325,feet:B*3.28084,inches:B*39.37,kilometers:B/1e3,kilometres:B/1e3,meters:B,metres:B,miles:B/1609.344,millimeters:B*1e3,millimetres:B*1e3,nauticalmiles:B/1852,radians:1,yards:B*1.0936},Gs={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/B,yards:1.0936133};function Rt(e,r,t){if(e!==null)for(var o,n,a,s,c,i,l,p=0,h=0,k,P=e.type,M=P==="FeatureCollection",N=P==="Feature",R=M?e.features.length:1,x=0;x<R;x++){l=M?e.features[x].geometry:N?e.geometry:e,k=l?l.type==="GeometryCollection":!1,c=k?l.geometries.length:1;for(var _=0;_<c;_++){var b=0,U=0;if(s=k?l.geometries[_]:l,s!==null){i=s.coordinates;var C=s.type;switch(p=t&&(C==="Polygon"||C==="MultiPolygon")?1:0,C){case null:break;case"Point":if(r(i,h,x,b,U)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(o=0;o<i.length;o++){if(r(i[o],h,x,b,U)===!1)return!1;h++,C==="MultiPoint"&&b++}C==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(o=0;o<i.length;o++){for(n=0;n<i[o].length-p;n++){if(r(i[o][n],h,x,b,U)===!1)return!1;h++}C==="MultiLineString"&&b++,C==="Polygon"&&U++}C==="Polygon"&&b++;break;case"MultiPolygon":for(o=0;o<i.length;o++){for(U=0,n=0;n<i[o].length;n++){for(a=0;a<i[o][n].length-p;a++){if(r(i[o][n][a],h,x,b,U)===!1)return!1;h++}U++}b++}break;case"GeometryCollection":for(o=0;o<s.geometries.length;o++)if(Rt(s.geometries[o],r,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function At(e){var r=[1/0,1/0,-1/0,-1/0];return Rt(e,function(t){r[0]>t[0]&&(r[0]=t[0]),r[1]>t[1]&&(r[1]=t[1]),r[2]<t[0]&&(r[2]=t[0]),r[3]<t[1]&&(r[3]=t[1])}),r}At.default=At;var ko=At;var ge=require("react"),he=require("react-map-gl/maplibre");var Bt=require("react/jsx-runtime");function Gt({data:e,beforeId:r}){let{layer:t}=f(),{mapl:o}=(0,he.useMap)(),[n,a]=(0,ge.useState)({geojson:{},paint:{}}),s=t.selectedIds.includes(e.id),c=t.selectedIds[0]===e.id,i=(l=!1)=>v(this,null,function*(){let{success:p,geojson:h,paint:k,stops:P,squareSize:M}=yield br(e.source.fetcher,o==null?void 0:o.getBounds(),o==null?void 0:o.getZoom());if(p){if(a({geojson:h,paint:k}),l&&c&&e.zoomToFit)try{let[N,R,x,_]=ko(h);o==null||o.fitBounds([[N,R],[x,_]],{padding:40,animate:!0})}catch(N){console.warn("Failed to compute bbox",N)}t.setGridLegends({[e.id]:{stops:P,squareSize:M}})}});return(0,ge.useEffect)(()=>{s&&c?i(!0):s&&i(!1)},[s,c]),(0,ge.useEffect)(()=>{if(!s||!o)return;let l=()=>i(!1);return o.on("idle",l),()=>{o.off("idle",l)}},[s,o]),(0,ge.useEffect)(()=>()=>{t.setGridLegends(l=>{let p=m({},l);return delete p[e.id],p})},[e.id]),(0,Bt.jsx)(he.Source,{id:e.id,type:"geojson",data:n.geojson,children:(0,Bt.jsx)(he.Layer,{beforeId:r,id:e.id,type:"fill",paint:n.paint})})}var Po=require("react"),Oe=require("react-map-gl/maplibre");var De=require("react/jsx-runtime"),yn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function rt({layer:e,beforeId:r}){var a;let{layer:t}=f(),o=(0,Po.useMemo)(()=>{var s,c,i,l;return(l=(i=(s=e.data)==null?void 0:s.styles)==null?void 0:i[(c=e.data)==null?void 0:c.styleIndex])==null?void 0:l.colors},[e,t.selectedFeatures]),n=(a=t.selectedFeaturesId)==null?void 0:a[e.id];return(0,De.jsxs)(Oe.Source,T(m({},e.source),{children:[o&&(0,De.jsx)(Oe.Layer,m({beforeId:r},o)),n&&o&&(0,De.jsx)(Oe.Layer,T(m({},o),{beforeId:r,id:`hl_${e.id}`,filter:["in",q,...n],type:o.type==="fill"?"line":o.type,paint:yn[o.type]}))]}))}var ot=require("react-map-gl/maplibre");var _t=require("react/jsx-runtime");function Ot({data:e,beforeId:r}){var o;let{mp:t}=f();return(0,_t.jsx)(ot.Source,{id:e.id,type:"raster",tiles:[`${(o=t==null?void 0:t.geoserver)==null?void 0:o.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:(0,_t.jsx)(ot.Layer,{id:e.id,beforeId:r,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}var ze=require("react/jsx-runtime");function Io({layer:e,beforeId:r}){let{mapl:t}=(0,Co.useMap)();if(!t)return null;switch(e.source.type){case"vector":return(0,ze.jsx)(rt,{beforeId:r,layer:e});case"grid":return(0,ze.jsx)(Gt,{beforeId:r,data:e});case"raster":return(0,ze.jsx)(Ot,{beforeId:r,data:e});default:return(0,ze.jsx)(rt,{beforeId:r,layer:e})}}var Mo=require("react"),Eo=require("react-map-gl/maplibre");var ve=require("react/jsx-runtime"),gn=Eo.Marker,hn=()=>{let{mp:e}=f(),r=(0,Mo.useMemo)(()=>e.markers,[e.markers]);return(0,ve.jsx)(ve.Fragment,{children:r==null?void 0:r.map(({latitude:t,longitude:o,colorHex:n},a)=>(0,ve.jsx)(gn,{latitude:t,longitude:o,children:(0,ve.jsx)("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},To=hn;var No=O(require("clsx")),Ro=require("react-map-gl/maplibre"),be=require("twind");var z=require("react/jsx-runtime"),vn=Ro.Popup;function Dt({coordinates:e}){let{hover:r}=f();return(e==null?void 0:e.lat)&&r.features?(0,z.jsx)(vn,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:(0,z.jsxs)("table",{className:be.tw`table-auto border`,children:[(0,z.jsx)("thead",{children:(0,z.jsx)("tr",{children:(0,z.jsx)("th",{className:be.tw`bg-gray-200 py-1 px-2`,colSpan:2,children:r.features.title})})}),(0,z.jsx)("tbody",{children:r.features.data.map(([t,o],n)=>(0,z.jsxs)("tr",{className:(0,be.tw)((0,No.default)({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[(0,z.jsx)("td",{className:be.tw`py-1 px-2`,children:t}),(0,z.jsx)("td",{className:be.tw`py-1 px-2 border-l border-gray-100`,children:o})]},t+o))})]})}):null}var H=require("react/jsx-runtime"),bn=Le.NavigationControl;function zt(){var l;let{mp:e,layer:r,hover:t,query:o}=f(),[n,a]=(0,nt.useState)(),s=(0,nt.useMemo)(()=>e.defaultViewState||Ao.defaultViewState,[e.defaultViewState]),c=p=>o.setClickedLngLat(p.lngLat),i=p=>{a(p.lngLat),t.onHover(p)};return(0,H.jsxs)("div",{className:Bo.tw`h-full w-full relative bg-gray-100`,children:[e.loadToC&&(0,H.jsx)(Nt,{}),((l=r.selectedFeatures)==null?void 0:l.length)>0&&(0,H.jsx)(vt,{}),(0,H.jsxs)(Le.default,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:r.mapStyle,maxZoom:r.maxZoom,onClick:c,onMouseMove:i,children:[(0,H.jsx)(bn,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&(0,H.jsx)(Le.FullscreenControl,{position:"bottom-right"}),(0,H.jsx)(To,{}),r.selectedLayers.map((p,h)=>{let k=h>0?r.selectedIds[h-1]:void 0;return(0,H.jsx)(Io,{layer:p,beforeId:k},p.id)}),(0,H.jsx)(Dt,{coordinates:n},"popup")]})]})}var He=require("react/jsx-runtime");(0,Do.setup)({preflight:!1});var Ln=e=>{let r=_o.default.useMemo(()=>m(m({},nr),e),[e]);return(0,He.jsx)(Oo.MapProvider,{children:(0,He.jsx)(Go.TranslationProvider,{localeStrings:or,lang:r.lang,children:(0,He.jsx)(Sr,{mp:r,children:(0,He.jsx)(zt,{})})})})};0&&(module.exports={NakshaMaplibreLayers});
|
|
1
|
+
import{TranslationProvider as Gn}from"@biodiv-platform/naksha-commons";import On from"react";import{MapProvider as Dn}from"react-map-gl/maplibre";import{setup as zn}from"twind";var pt={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var ut={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var mt={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var ft={en:pt,fr:ut,hi:mt};import{defaultViewState as Tn}from"@biodiv-platform/naksha-commons";import{useMemo as Mn,useState as Nn}from"react";import En,{FullscreenControl as Rn,NavigationControl as _n}from"react-map-gl/maplibre";import{tw as Bn}from"twind";import{defaultMapStyles as Uo,useDebounce as jo}from"@biodiv-platform/naksha-commons";import Jo,{createContext as Ko,useContext as Xo,useEffect as _e,useMemo as Qo,useState as I}from"react";import{useMap as er}from"react-map-gl/maplibre";import Yo from"colorbrewer";import O from"redaxios";import bt from"boundingbox";import{GeoHash as Ee}from"geohash";import{MapStyles as $o,defaultViewState as qo}from"@biodiv-platform/naksha-commons";var yt={defaultViewState:qo,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:$o.MAP_STREETS,layers:[],selectedLayers:[]},gt="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",Me={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},ht={...Me,WebkitLineClamp:2},P="ogc_fid",ie={ACTIVE:"Active",PENDING:"Pending"},T={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Lt=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],Ne="0123456789bcdefghjkmnpqrstuvwxyz",Fo=(e,o,t)=>{t=t||16/2**(1-e.length&1)/4**o;let r=e.slice(0,-1),n=~~(Ne.indexOf(e.slice(-1))/t);return[r+Ne[t*n],r+Ne[t*(n+1)-1]]},Vo=function(e,o){var t=new Map,r=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[i,u]=Fo(a,o);r.set(i,u),t.has(i)||t.set(i,0),t.set(i,t.get(i)+s)}return t.forEach((a,s)=>{let i=Ee.decodeGeoHash(s),u=Ee.decodeGeoHash(r.get(s)),d=new bt({minlat:i.latitude[0],minlon:i.longitude[0],maxlat:u.latitude[1],maxlon:u.longitude[1]}).toGeoJSON();n.push({...d,properties:{count:a,[P]:s}})}),n},Wo=e=>{let o=[];for(let[t,r]of Object.entries(e)){let n=Ee.decodeGeoHash(t),a=new bt({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();o.push({...a,properties:{count:r,[P]:t}})}return o},vt=(e,o)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:o===-1?Wo(e):Vo(e,o)}),xt=(e,o)=>{let t=Object.values(e).sort((a,s)=>a-s),r=Math.floor(t.length/o),n=new Array(o-1).fill(0).map((a,s)=>t[r*(s+1)]);return n.push(t[t.length-1]),n};import{produce as Zo}from"immer";var St=async(e,o,t,r)=>{let n=[];for(let a of e){let s=r.includes(a.name),i={...a,id:a.name,thumbnail:o+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s};if(s){let u=await Re(i,0,o,t);n.push({...i,data:u})}else n.push(i)}return n},Re=async(e,o,t,r)=>Zo(e.data,async a=>{if(a.styles.length===0){let{success:s,data:i}=await wt(e.id,t);s&&(a.layerName=i.layerName,a.styles=i.styles,a.summaryColumn=i.summaryColumn,a.titleColumn=i.titleColumn,a.propertyMap=Object.fromEntries(i.styles.map(u=>[u.styleName,u.styleTitle])))}a.styles[o]&&!a.styles[o]?.colors&&(a.styles[o].colors=await It(e.id,r?.workspace,a.styles[o].styleName,t)),a.styleIndex=o});var kt=async(e,o,t,r)=>{try{let n=await O.get(`${o}/layer/all`,{headers:{Authorization:e}});return await St(n.data,o,t,r)}catch(n){return console.error(n),[]}},wt=async(e,o)=>{try{let{data:t}=await O.get(`${o}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}},Ct=async(e,o,t)=>{let r={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(await O.get(`${e}/${o}/wms`,{params:{...t,...r}})).data}}catch(n){return console.error(n),{success:!1,data:[]}}},Pt=async(e,o,t,r)=>{try{return await O.put(`${o}/layer/${r?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}},Tt=async(e,o,t)=>{try{return await O.delete(`${o}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(r){return console.error(r),!1}},It=async(e,o,t,r)=>{try{return(await O.get(`${r}/geoserver/workspaces/${o}/styles/${e}_${t}.mbstyle`)).data?.layers?.[0]}catch(n){return console.error(n),{}}},Mt=async(e,o,t,r=6,n="YlOrRd")=>{try{let[a,s,i]=Lt(t),{_ne:u,_sw:d}=o,y={top:u.lat,left:d.lng,bottom:d.lat,right:u.lng,geoAggegationPrecision:a},g=await e(y),k=vt(g,s),N=xt(g,r).map((G,J)=>[G,Yo[n][r][J]]);return{success:!0,geojson:k,paint:{"fill-color":{property:"count",default:"yellow",stops:N},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:N,squareSize:i}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}},Nt=async(e,o,t,r)=>{try{await O.post(`${e}/layer/download`,{layerName:t,layerTitle:r,attributeList:[],filterArray:[]},{headers:{Authorization:o}})}catch(n){console.error(n)}};import{jsx as tr}from"react/jsx-runtime";var Et=Ko({}),Rt=({mp:e,children:o})=>{let[t,r]=I(e),{mapl:n}=er(),[a,s]=I(""),i=jo(a,500),u=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:Uo,[d,y]=I(u[t?.mapStyle||0]?.style),[g,k]=I(u[t?.mapStyle||0]?.maxZoom),[w,N]=I(T.TOP),[B,G]=I({}),[J,we]=I(!0),[E,Po]=I(),[C,Ie]=I(e.layers||[]),[v,F]=I(t.selectedLayers||[]),[nt,at]=I(),[ke,st]=I(),To=Qo(()=>{let p={};for(let m of ke||[])p[m.sourceLayer]=[...p[m.sourceLayer]||[],m?.properties?.[P]];return Object.keys(p).length?p:void 0},[ke]),Ce=Jo.useMemo(()=>{let p=C.filter(f=>v.includes(f.id)),m=new Array(v.length);for(let f of p){let b=v.findIndex(x=>f.id===x);b>-1&&(m[b]=f)}return m},[C,v]),ae=p=>C.findIndex(m=>m.id===p),it=(p,m)=>{Ie(f=>f.map(b=>b.id===p?{...b,...m}:b))},lt=async(p,m,f)=>{let b=C[p],x=await Re(b,m,t.nakshaApiEndpoint,t.geoserver);it(b.id,{data:x}),f&&n?.fitBounds(b.bbox,{padding:40,duration:1e3})},Mo=async(p,m)=>{let f=ae(p);lt(f,m,!1)},No=async p=>{if(!(!v.length||!n))try{let m=v[0],f=n.queryRenderedFeatures(p.point,{layers:[m]});if(f.length){let b=f[0]?.id||f[0]?.properties?.[P];if(b===nt?.id)return;let x=C[ae(m)],dt=x?.data?.summaryColumn.map(R=>[x.data?.propertyMap?.[R]||R,f[0].properties?.[R]]);at({id:b,title:x.title,data:dt})}else at(void 0)}catch{}},Eo=async({layerId:p,add:m,styleIndex:f=0,focus:b=!0})=>{if(!m){F(v.filter(R=>p!==R));return}let x=ae(p);C[x]?.source.type==="grid"?(F(R=>[p,...R.filter(Te=>Te!==p)]),b&&C[x]?.bbox&&setTimeout(()=>{n?.fitBounds(C[x].bbox,{padding:40,duration:1e3})},100)):(await lt(x,f,b),F(R=>[p,...R.filter(Te=>Te!==p)]))},Ro=async()=>F([]),_o=(p,m)=>{r({...t,[p]:m})},Bo=(p,m)=>{let f=m===ie.PENDING;Pt(t.nakshaEndpointToken,t.nakshaApiEndpoint,p,f),it(p,{layerStatus:f?ie.ACTIVE:ie.PENDING})},Ao=async(p,m)=>{confirm(m)&&(Tt(t.nakshaEndpointToken,t.nakshaApiEndpoint,p),Ie(C.filter(f=>f.id!==p)))},Go=p=>{let m=ae(p),f=C[m];n?.fitBounds(f.bbox,{padding:40,duration:1e3})},ct=()=>[E.lng,E.lat,E.lng+.1,E.lat+.1],Oo=p=>{N(p),p===T.TOP&&Pe(p)},Pe=p=>{if(E)try{let m=n?.project([E.lng,E.lat]),f=n?.queryRenderedFeatures(m,{layers:w===T.TOP?[v[0]]:v});if((p||w)===T.ALL){let b=Ce.filter(x=>x.layerType=="RASTER").map(x=>({sourceLayer:x.id,layerType:"raster",bbox:ct()}));f=[...f,...b]}st(Ce?.[0].layerType==="RASTER"&&w!==T.ALL?v.length&&f?.length?f:[{sourceLayer:v[0],layerType:"raster",bbox:ct()}]:f)}catch(m){console.error(m)}},se=(e.selectedLayers||[]).join(",");return _e(()=>{se!==v.join(",")&&F(se?se.split(","):[])},[se]),_e(()=>{t.onSelectedLayersChange&&t.onSelectedLayersChange(v)},[v]),_e(()=>{setTimeout(Pe,300)},[E,w,v]),tr(Et.Provider,{value:{mp:t,updateMP:_o,layer:{mapStyle:d,featuresAtLatLng:Pe,setMapStyle:y,maxZoom:g,setMaxZoom:k,mapStyles:u,all:C,setAll:Ie,selectedIds:v,handleSelectStyle:Oo,setSelectedIds:F,selectedLayers:Ce,clearAll:Ro,toggle:Eo,updateStyle:Mo,selectedFeatures:ke,selectedFeaturesId:To,setSelectedFeatures:st,togglePublish:Bo,delete:Ao,selectionStyle:w,setSelectionStyle:N,zoomToExtent:Go,gridLegends:B,setGridLegends:G},query:{term:i,setTerm:s,clickedLngLat:E,setClickedLngLat:Po},isInfoBarOpen:J,setIsInfoBarOpen:we,hover:{onHover:No,features:nt}},children:o})};function c(){return Xo(Et)}import rr from"react";import{tw as ce}from"twind";import{tw as or}from"twind";import{jsx as l,jsxs as X}from"react/jsx-runtime";var _t=()=>l("svg",{fill:"none",className:or`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:l("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),K=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[l("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),l("path",{d:"M2 17L12 22 22 17"}),l("path",{d:"M2 12L12 17 22 12"})]}),le=()=>X("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l("circle",{cx:"12",cy:"12",r:"10"}),l("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),l("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),Bt=()=>X("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[l("path",{d:"M4 21L4 14"}),l("path",{d:"M4 10L4 3"}),l("path",{d:"M12 21L12 12"}),l("path",{d:"M12 8L12 3"}),l("path",{d:"M20 21L20 16"}),l("path",{d:"M20 12L20 3"}),l("path",{d:"M1 14L7 14"}),l("path",{d:"M9 8L15 8"}),l("path",{d:"M17 16L23 16"})]});function Be(){return l("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function At(){return l("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function Gt(){return l("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function Ot(){return l("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function Dt(){return l("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function zt(){return l("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function Ht(){return l("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:l("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function $t(){return X("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[l("circle",{cx:"18",cy:"5",r:"3"}),l("circle",{cx:"6",cy:"12",r:"3"}),l("circle",{cx:"18",cy:"19",r:"3"}),l("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),l("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function qt(){return l("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:l("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function Ft(){return X("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[l("circle",{cx:"12",cy:"12",r:"10"}),l("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),l("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),l("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),l("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function Vt(){return l("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:l("polyline",{points:"6 9 12 15 18 9"})})}function Wt(){return l("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:l("polyline",{points:"18 15 12 9 6 15"})})}import{jsx as V}from"react/jsx-runtime";var A=rr.forwardRef((e,o)=>V("button",{ref:o,type:"button",className:ce`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`,...e}));var de=e=>V("button",{className:ce`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715",...e}),Zt=e=>V("button",{className:ce`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:V(K,{})}),Yt=e=>V("button",{className:ce`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`,...e,children:V(le,{})});import{tw as W}from"twind";import{jsx as M,jsxs as Jt}from"react/jsx-runtime";var Z=e=>Jt("div",{children:[e.label&&M("label",{className:W`text-gray-700`,htmlFor:e.name,children:e.label}),M("select",{id:e.name,name:e.name,className:W`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"},...e})]}),Ut=e=>Jt("div",{className:"relative",children:[M("span",{className:W`absolute inset-y-0 left-0 flex items-center pl-3`,children:M(_t,{})}),M("input",{type:"search",className:W`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`,...e})]}),jt=e=>e.isLoading?M("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:W`inline text-gray-200 animate-spin dark:text-gray-600`,children:M("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:M("g",{fill:"#212121",fillRule:"nonzero",children:M("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):M("input",{type:"checkbox",className:W`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});import{Tabs as Kt,usePanelState as nr,useTabState as ar}from"@bumaga/tabs";import sr from"clsx";import{tw as pe}from"twind";import{jsx as Ae,jsxs as ir}from"react/jsx-runtime";var ue=({children:e,icon:o})=>{let{onClick:t,isActive:r}=ar(),n=sr(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":r,"text-gray-700 border-gray-300 hover:border-gray-400":!r}]);return ir("button",{className:pe(n),onClick:t,children:[o,Ae("span",{className:pe`ml-2 text-base`,children:e})]})},me=({children:e})=>nr()?Ae("div",{className:pe`w-full flex flex-grow-1 overflow-auto`,children:e}):null,Xt=({children:e})=>Ae("div",{className:pe`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{useT as pr}from"@biodiv-platform/naksha-commons";import{tw as ye}from"twind";import{useT as lr}from"@biodiv-platform/naksha-commons";import{jsx as Qt}from"react/jsx-runtime";function Q({hideLabel:e}){let{layer:{selectionStyle:o,handleSelectStyle:t}}=c(),{t:r}=lr(),n=a=>{t(a.target.value)};return Qt(Z,{name:"layer_selection",label:e?null:r("layer_selection"),defaultValue:o,onChange:n,children:Object.values(T).map(a=>Qt("option",{value:a,children:r(a)},a))})}import cr from"clsx";import{useEffect as dr,useState as eo}from"react";import{tw as fe}from"twind";import{jsx as ee,jsxs as Ge}from"react/jsx-runtime";function Oe({data:e}){let[o,t]=eo(!0),[r,n]=eo({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:i}}=c(),u=async()=>{let d,y=a.selectedLayers.find(g=>g.id===(e.sourceLayer||e.source));if(y.layerType.toLowerCase()==="raster"){let{data:g}=await Ct(s.geoserver?.endpoint,s.geoserver?.workspace,{bbox:e.bbox.toString(),query_layers:`${s.geoserver?.workspace}:${y.id}`,layers:`${s.geoserver?.workspace}:${y.id}`});d=g?.features[0]?Object.entries(g.features[0]?.properties).map(([k,w])=>[w||"-"]):[]}else d=Object.entries(y?.data?.propertyMap||{}).map(([g,k])=>[k,e?.properties?.[g]]);n({title:y.title,properties:d})};return dr(()=>{u()},[i]),Ge("div",{className:fe`bg-gray-100 rounded-lg`,children:[Ge("button",{className:fe(cr(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":o,"rounded-lg":!o}])),onClick:()=>t(!o),children:[r.title," ",o?ee(Wt,{}):ee(Vt,{})]}),o&&ee("div",{className:fe`px-4 py-3 flex flex-col gap-3`,children:r.properties.map(([d,y],g)=>Ge("div",{children:[ee("div",{className:fe`text-gray-600`,children:d}),ee("div",{children:y})]},d+y+g))})]})}import{jsx as Y,jsxs as De}from"react/jsx-runtime";function ze({onClose:e}){let{layer:{selectedFeatures:o,selectedLayers:t,selectionStyle:r}}=c(),{t:n}=pr();return De("div",{className:ye`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[De("div",{className:"flex w-full",children:[De("div",{className:ye`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[Y(Ft,{})," ",n("infobar")]}),Y(de,{onClick:e})]}),Y("div",{className:ye`bg-gray-100 p-4 flex-shrink-0 rt`,children:Y(Q,{hideLabel:!0})}),Y("div",{className:ye`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:o.flat(1)?.map(a=>Y(Oe,{data:a},t?.[0]?.source.type==="raster"||r===T.ALL?a?.sourceLayer:a?.sourceLayer+a?.properties[P]))})]})}import{jsx as to}from"react/jsx-runtime";function He(){let{layer:e,isInfoBarOpen:o,setIsInfoBarOpen:t}=c();if(!e.selectedFeatures?.length)return null;let r=()=>t(!o);return o?to(ze,{onClose:r}):to(Yt,{onClick:r})}import{useEffect as nn,useState as an}from"react";import{useMap as sn}from"react-map-gl/maplibre";import{useT as rn}from"@biodiv-platform/naksha-commons";import{tw as ho}from"twind";import{tw as Hr}from"twind";import Br,{useMemo as Ar}from"react";import{useVirtual as Gr}from"react-virtual";import{AutoSizer as Or}from"react-virtualized-auto-sizer";import{tw as io}from"twind";import{useT as Nr}from"@biodiv-platform/naksha-commons";import{useMemo as Er,useState as so}from"react";import{RWebShare as Rr}from"react-web-share";import{tw as _}from"twind";import{Fragment as oo,jsx as ge}from"react/jsx-runtime";var ro=({text:e="",highlight:o=""})=>{if(!o.trim())return ge(oo,{children:e});let t=new RegExp(`(${o})`,"gi"),r=e.split(t);return ge(oo,{children:r.filter(n=>n).map((n,a)=>t.test(n)?ge("mark",{children:n},a):ge("span",{children:n},a))})};import{tw as hr}from"twind";import{useT as ur}from"@biodiv-platform/naksha-commons";import{useState as mr}from"react";import{tw as fr}from"twind";import{jsx as yr,jsxs as gr}from"react/jsx-runtime";function te({children:e}){let[o,t]=mr(!1),{t:r}=ur();return gr("div",{children:[o&&e,yr("button",{onClick:()=>t(!o),className:fr`text-blue-600 focus:outline-none focus:outline focus:ring`,children:r(o?"less":"legend")})]})}import{jsx as he,jsxs as be}from"react/jsx-runtime";function $e({item:e}){let{layer:o}=c(),t=o.gridLegends[e.id];return t?he(te,{children:be("ul",{style:{margin:0,padding:0},children:[t?.stops.map(([r,n],a,s)=>{let i=(s[a-1]||[0])[0];return i===r?he("div",{},n):be("li",{className:hr`flex gap-2 items-center mb-1`,children:[he("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:he("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),be("div",{children:[i," - ",r]})]},n)}),be("li",{children:["1 Square = ",t?.squareSize," x ",t?.squareSize," km"]})]})}):null}import{LICENSES as br,useT as Lr}from"@biodiv-platform/naksha-commons";import{useState as vr}from"react";import{Popover as xr}from"react-tiny-popover";import{tw as oe}from"twind";import{jsx as h,jsxs as qe}from"react/jsx-runtime";var U=({icon:e,name:o,title:t,link:r,children:n})=>{let a=h("span",{children:n||"-"});return qe("div",{className:oe`flex gap-3 text-sm text-gray-600 break-all`,title:o&&t&&`${o}: ${t}`,children:[h("div",{children:e}),r?h("a",{className:oe`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:r,children:a}):a]})};function Sr({item:e,containerStyle:o}){let{t}=Lr(),{layer:r,mp:n}=c(),a=e.license||"CC-BY",s=e?.createdDate&&new Date(e.createdDate).toLocaleDateString(),i=e.tags?.join(", ");return qe("div",{className:oe`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:o,children:[n.managePublishing&&e.layerStatus&&qe(U,{icon:h(Ot,{}),name:t("visiblity"),title:e.layerStatus,children:[e.layerStatus,h("button",{className:oe`text-blue-600 focus:outline-none ml-4`,onClick:()=>r.togglePublish(e.id,e?.layerStatus),children:t("toggle")}),h("button",{className:oe`text-red-600 focus:outline-none ml-4`,onClick:()=>r.delete(e.id,t("are_you_sure")),children:t("delete")})]}),h(U,{icon:h(Be,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),h(U,{icon:h(Be,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),h(U,{icon:h(Dt,{}),name:t("created_on"),title:s,children:s}),h(U,{icon:h(At,{}),name:t("tags"),title:i,children:i}),h(U,{name:t("license"),title:a,link:a&&br[a],icon:h(Gt,{}),children:a})]})}var no=({item:e})=>{let[o,t]=vr(!1),r=()=>t(!o);return h(xr,{isOpen:o,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:r,content:h(Sr,{item:e}),children:h(A,{onClick:r,children:h(le,{}),title:"Information"})})};import{tw as Tr}from"twind";import{useMemo as wr,useState as Ir}from"react";import{useT as kr}from"@biodiv-platform/naksha-commons";import{tw as Cr}from"twind";import{jsx as D,jsxs as Pr}from"react/jsx-runtime";function ao({item:e}){let[o,t]=Ir(!0),{mp:r}=c(),{t:n}=kr(),a=wr(()=>e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["fill-color"]?.stops||e?.data?.styles?.[e.data.styleIndex]?.colors?.paint?.["circle-color"]?.stops||[],[e]),s=()=>a.map(([i,u])=>Pr("li",{className:Cr`flex gap-2 items-center mb-1`,children:[D("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:D("circle",{cx:"12",fill:u,cy:"12",r:"12",stroke:"none"})}),D("div",{children:i})]},u));return D("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():o?D("li",{children:D("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${r?.geoserver?.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):D("div",{children:n("raster_style_not_found")})})}import{jsx as Le,jsxs as Mr}from"react/jsx-runtime";function Fe({item:e}){if(!e.data?.styles)return null;let{layer:o}=c(),t=r=>{o.updateStyle(e.id,Number(r.target.value))};return Mr("div",{className:Tr`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&Le(Z,{onChange:t,children:e.data?.styles.map((r,n)=>Le("option",{value:n,children:r.styleTitle},n))}),Le(te,{children:Le(ao,{item:e})})]})}import{jsx as L,jsxs as z}from"react/jsx-runtime";function _r({dragHandleProps:e}){return L("div",{className:_`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"},...e,children:L(qt,{})})}function re({item:e,extended:o,dragHandleProps:t}){let{t:r}=Nr(),{layer:n,query:a,mp:s,query:{setClickedLngLat:i},setIsInfoBarOpen:u}=c(),[d,y]=so(n.selectedIds.includes(e.id)),[g,k]=so(!1),w=Er(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),N=async()=>{k(!0),u(!0),n.setSelectedFeatures([]),i(null),await n.toggle({layerId:e.id,add:!d}),y(!d),k(!1)},B=async()=>{await Nt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s?.onLayerDownload(e.id)},G=()=>n.zoomToExtent(e.id);return z("div",{className:_`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[z("div",{className:_`flex gap-3`,children:[z("div",{className:_`flex-shrink-0`,children:[L(jt,{name:e.id,checked:d,onChange:N,isLoading:g}),o&&L(_r,{dragHandleProps:t})]}),L("img",{className:_`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||gt}),z("div",{children:[L("div",{title:e.title,className:_`mb-1 leading-tight`,style:Me,children:L(ro,{text:e.title,highlight:a.term})}),L("p",{title:e.description,className:_`text-gray-600 text-sm`,style:ht,children:e.description})]})]}),z("div",{className:_`flex justify-between`,children:[z(A,{onClick:B,disabled:!e.isDownloadable,children:[L(zt,{})," ",r("download")]}),z("div",{className:_`flex gap-3`,children:[w&&L(Rr,{data:w,children:L(A,{title:"Share",children:L($t,{})})}),o&&L(A,{onClick:G,title:"Zoom To Extent",children:L(Ht,{})}),L(no,{item:e})]})]}),o&&L(Fe,{item:e}),o&&e.source.type==="grid"&&L($e,{item:e})]})}import{jsx as H}from"react/jsx-runtime";function lo(){let{layer:e,query:o}=c(),t=Ar(()=>o.term?e.all.filter(a=>a.title.toLowerCase().includes(o.term.toLowerCase())):e.all,[e.all,o.term]),r=Br.useRef(),n=Gr({size:t.length,parentRef:r});return H("div",{className:io`flex-grow-1 relative`,children:H(Or,{disableWidth:!0,children:a=>H("div",{ref:r,className:"List",style:{height:a.height,overflow:"auto"},children:H("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>H("div",{ref:s.measureRef,className:io`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:H("div",{style:{height:146},children:H(re,{item:t[s.index]})})},s.index))})})})})}import{useT as Dr}from"@biodiv-platform/naksha-commons";import{tw as zr}from"twind";import{jsx as co}from"react/jsx-runtime";function Ve(){let{t:e}=Dr(),{query:o}=c(),t=r=>o.setTerm(r.target.value);return co("div",{className:zr`flex-shrink-0 border-b-2 p-4`,children:co(Ut,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as po,jsxs as $r}from"react/jsx-runtime";function We(){return $r("div",{className:Hr`flex flex-col w-full`,children:[po(Ve,{}),po(lo,{})]})}function qr(e,o,t){let r=o<0?e.length+o:o;if(r>=0&&r<e.length){let n=t<0?e.length+t:t,[a]=e.splice(o,1);e.splice(n,0,a)}}function uo(e,o,t){return e=[...e],qr(e,o,t),e}import{closestCenter as Fr,DndContext as Vr,PointerSensor as Wr,useSensor as Zr,useSensors as Yr}from"@dnd-kit/core";import{SortableContext as Ur,useSortable as jr,verticalListSortingStrategy as Jr}from"@dnd-kit/sortable";import{CSS as Kr}from"@dnd-kit/utilities";import{jsx as j}from"react/jsx-runtime";function Xr({item:e,extended:o}){let{attributes:t,listeners:r,setNodeRef:n,transform:a,transition:s,isDragging:i}=jr({id:e.id}),u={transform:Kr.Transform.toString(a),transition:s,opacity:i?.5:1};return j("div",{ref:n,style:u,children:j(re,{item:e,extended:o,dragHandleProps:{...t,...r}})})}var mo=({layerList:e,onSortEnd:o})=>{let t=Yr(Zr(Wr,{activationConstraint:{distance:4}}));return j(Vr,{sensors:t,collisionDetection:Fr,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let i=e.findIndex(d=>d.id===a.id),u=e.findIndex(d=>d.id===s.id);i!==-1&&u!==-1&&o({oldIndex:i,newIndex:u})}},children:j(Ur,{items:e.map(n=>n.id),strategy:Jr,children:j("div",{children:e.map(n=>j(Xr,{item:n,extended:!0},n.id))})})})};import{useT as Qr}from"@biodiv-platform/naksha-commons";import{tw as fo}from"twind";import{jsx as go,jsxs as yo}from"react/jsx-runtime";function Ze(){let{layer:e}=c(),{t:o}=Qr(),t=({oldIndex:r,newIndex:n})=>{e.setSelectedIds(uo(e.selectedIds,r,n))};return yo("div",{className:fo`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&go("div",{className:fo`p-3 pb-0`,children:yo(A,{onClick:()=>e.clearAll(),children:["\u2715 ",o("clear")]})}),go(mo,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as en}from"@biodiv-platform/naksha-commons";import{tw as tn}from"twind";import{jsx as Ye,jsxs as on}from"react/jsx-runtime";function Ue(){let{layer:e}=c(),{t:o}=en(),t=r=>{e.setMapStyle(r.target.value),e.setMaxZoom(e.mapStyles.find(n=>n.style===r.target.value)?.maxZoom)};return on("div",{className:tn`w-full p-4 flex flex-col gap-4`,children:[Ye(Z,{name:"base_style",label:o("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(r=>Ye("option",{value:r.style,children:r.text},r.key))}),Ye(Q,{})]})}import{jsx as S,jsxs as je}from"react/jsx-runtime";function Je({onClose:e}){let{t:o}=rn();return je("div",{className:ho`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[S(de,{onClick:e}),S("div",{className:ho`flex flex-col h-full`,children:je(Kt,{children:[je(Xt,{children:[S(ue,{icon:S(K,{}),children:o("layers")}),S(ue,{icon:S(K,{}),children:o("selected")}),S(ue,{icon:S(Bt,{}),children:o("settings")})]}),S(me,{children:S(We,{})}),S(me,{children:S(Ze,{})}),S(me,{children:S(Ue,{})})]})})]})}import{jsx as bo}from"react/jsx-runtime";function Ke(){let{mp:e,layer:o}=c(),[t,r]=an(e.showToC),{mapl:n}=sn(),a=()=>r(!t);async function s(){let i=await kt(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),u=[...e.layers||[],...i];if(o.setAll(u),o.selectedIds.length){let d=u.find(y=>y.id===o.selectedIds[0]);d?.bbox&&n?.fitBounds(d.bbox,{padding:40,duration:1e3})}}return nn(()=>{n&&e.loadToC&&s()},[n]),t?bo(Je,{onClose:a}):bo(Zt,{onClick:a})}import{useMap as Ln}from"react-map-gl/maplibre";import ln from"@turf/bbox";import{useEffect as Xe,useState as cn}from"react";import{Layer as dn,Source as pn,useMap as un}from"react-map-gl/maplibre";import{jsx as Lo}from"react/jsx-runtime";function Qe({data:e,beforeId:o}){let{layer:t}=c(),{mapl:r}=un(),[n,a]=cn({geojson:{},paint:{}}),s=t.selectedIds.includes(e.id),i=t.selectedIds[0]===e.id,u=async(d=!1)=>{let{success:y,geojson:g,paint:k,stops:w,squareSize:N}=await Mt(e.source.fetcher,r?.getBounds(),r?.getZoom());if(y){if(a({geojson:g,paint:k}),d&&i&&e.zoomToFit)try{let[B,G,J,we]=ln(g);r?.fitBounds([[B,G],[J,we]],{padding:40,animate:!0})}catch(B){console.warn("Failed to compute bbox",B)}t.setGridLegends({[e.id]:{stops:w,squareSize:N}})}};return Xe(()=>{s&&i?u(!0):s&&u(!1)},[s,i]),Xe(()=>{if(!s||!r)return;let d=()=>u(!1);return r.on("idle",d),()=>{r.off("idle",d)}},[s,r]),Xe(()=>()=>{t.setGridLegends(d=>{let y={...d};return delete y[e.id],y})},[e.id]),Lo(pn,{id:e.id,type:"geojson",data:n.geojson,children:Lo(dn,{beforeId:o,id:e.id,type:"fill",paint:n.paint})})}import{useMemo as mn}from"react";import{Layer as vo,Source as fn}from"react-map-gl/maplibre";import{jsx as xo,jsxs as gn}from"react/jsx-runtime";var yn={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function ve({layer:e,beforeId:o}){let{layer:t}=c(),r=mn(()=>e.data?.styles?.[e.data?.styleIndex]?.colors,[e,t.selectedFeatures]),n=t.selectedFeaturesId?.[e.id];return gn(fn,{...e.source,children:[r&&xo(vo,{beforeId:o,...r}),n&&r&&xo(vo,{...r,beforeId:o,id:`hl_${e.id}`,filter:["in",P,...n],type:r.type==="fill"?"line":r.type,paint:yn[r.type]})]})}import{Layer as hn,Source as bn}from"react-map-gl/maplibre";import{jsx as So}from"react/jsx-runtime";function et({data:e,beforeId:o}){let{mp:t}=c();return So(bn,{id:e.id,type:"raster",tiles:[`${t?.geoserver?.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:So(hn,{id:e.id,beforeId:o,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as xe}from"react/jsx-runtime";function wo({layer:e,beforeId:o}){let{mapl:t}=Ln();if(!t)return null;switch(e.source.type){case"vector":return xe(ve,{beforeId:o,layer:e});case"grid":return xe(Qe,{beforeId:o,data:e});case"raster":return xe(et,{beforeId:o,data:e});default:return xe(ve,{beforeId:o,layer:e})}}import{useMemo as vn}from"react";import{Marker as xn}from"react-map-gl/maplibre";import{Fragment as In,jsx as tt}from"react/jsx-runtime";var Sn=xn,wn=()=>{let{mp:e}=c(),o=vn(()=>e.markers,[e.markers]);return tt(In,{children:o?.map(({latitude:t,longitude:r,colorHex:n},a)=>tt(Sn,{latitude:t,longitude:r,children:tt("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},Io=wn;import kn from"clsx";import{Popup as Cn}from"react-map-gl/maplibre";import{tw as ne}from"twind";import{jsx as $,jsxs as ko}from"react/jsx-runtime";var Pn=Cn;function ot({coordinates:e}){let{hover:o}=c();return e?.lat&&o.features?$(Pn,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:ko("table",{className:ne`table-auto border`,children:[$("thead",{children:$("tr",{children:$("th",{className:ne`bg-gray-200 py-1 px-2`,colSpan:2,children:o.features.title})})}),$("tbody",{children:o.features.data.map(([t,r],n)=>ko("tr",{className:ne(kn({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[$("td",{className:ne`py-1 px-2`,children:t}),$("td",{className:ne`py-1 px-2 border-l border-gray-100`,children:r})]},t+r))})]})}):null}import{jsx as q,jsxs as Co}from"react/jsx-runtime";var An=_n;function rt(){let{mp:e,layer:o,hover:t,query:r}=c(),[n,a]=Nn(),s=Mn(()=>e.defaultViewState||Tn,[e.defaultViewState]),i=d=>r.setClickedLngLat(d.lngLat),u=d=>{a(d.lngLat),t.onHover(d)};return Co("div",{className:Bn`h-full w-full relative bg-gray-100`,children:[e.loadToC&&q(Ke,{}),o.selectedFeatures?.length>0&&q(He,{}),Co(En,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:o.mapStyle,maxZoom:o.maxZoom,onClick:i,onMouseMove:u,children:[q(An,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&q(Rn,{position:"bottom-right"}),q(Io,{}),o.selectedLayers.map((d,y)=>{let g=y>0?o.selectedIds[y-1]:void 0;return q(wo,{layer:d,beforeId:g},d.id)}),q(ot,{coordinates:n},"popup")]})]})}import{jsx as Se}from"react/jsx-runtime";zn({preflight:!1});var hc=e=>{let o=On.useMemo(()=>({...yt,...e}),[e]);return Se(Dn,{children:Se(Gn,{localeStrings:ft,lang:o.lang,children:Se(Rt,{mp:o,children:Se(rt,{})})})})};export{hc as NakshaMaplibreLayers};
|
package/package.json
CHANGED
|
@@ -1,58 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@biodiv-platform/naksha-maplibre-layers",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.9-beta.0",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"author": "harshzalavadiya",
|
|
5
|
-
"main": "./dist/index.
|
|
6
|
-
"module": "./dist/
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
8
16
|
"sideEffects": false,
|
|
9
17
|
"license": "Apache-2.0",
|
|
10
|
-
"repository":
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "strandls/naksha-components-react"
|
|
21
|
+
},
|
|
11
22
|
"files": [
|
|
12
23
|
"dist/**",
|
|
13
24
|
"locales/**"
|
|
14
25
|
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"clean": "rm -rf node_modules dist .turbo",
|
|
17
|
-
"build": "tsup src/index.tsx --legacy-output --minify --format esm,cjs --dts --external react",
|
|
18
|
-
"dev": "tsup src/index.tsx --legacy-output --format esm,cjs --watch --dts --external react"
|
|
19
|
-
},
|
|
20
26
|
"peerDependencies": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
+
"@dnd-kit/core": ">=6.0.0",
|
|
28
|
+
"@dnd-kit/sortable": ">=8.0.0",
|
|
29
|
+
"@dnd-kit/utilities": ">=3.0.0",
|
|
30
|
+
"maplibre-gl": ">=4.0.0",
|
|
31
|
+
"react": ">=18.0.0",
|
|
32
|
+
"react-map-gl": ">=7.0.0"
|
|
27
33
|
},
|
|
28
34
|
"devDependencies": {
|
|
29
|
-
"@biodiv-platform/eslint-preset": "*",
|
|
30
|
-
"@biodiv-platform/tsconfig": "*",
|
|
31
|
-
"@types/react": "^18.0.13",
|
|
32
|
-
"@types/react-dom": "^18.0.5",
|
|
33
|
-
"react": ">=18",
|
|
34
|
-
"maplibre-gl": "^6.16.0",
|
|
35
|
-
"react-map-gl": "^8.0.4",
|
|
36
|
-
"tsup": "^6.1.2",
|
|
37
|
-
"typescript": "^4.7.3",
|
|
38
35
|
"@dnd-kit/core": "^6.3.1",
|
|
39
36
|
"@dnd-kit/sortable": "^10.0.0",
|
|
40
|
-
"@dnd-kit/utilities": "^3.2.2"
|
|
37
|
+
"@dnd-kit/utilities": "^3.2.2",
|
|
38
|
+
"@types/react": "^19.3.0",
|
|
39
|
+
"@types/react-dom": "^19.3.0",
|
|
40
|
+
"maplibre-gl": "^6.16.0",
|
|
41
|
+
"react": "^19.3.1",
|
|
42
|
+
"react-map-gl": "^8.1.3",
|
|
43
|
+
"tsup": "^9.0.0",
|
|
44
|
+
"typescript": "^5.8.3",
|
|
45
|
+
"@biodiv-platform/eslint-preset": "4.4.9",
|
|
46
|
+
"@biodiv-platform/tsconfig": "4.4.9"
|
|
41
47
|
},
|
|
42
48
|
"dependencies": {
|
|
43
49
|
"@bumaga/tabs": "^0.2.0",
|
|
44
|
-
"@
|
|
50
|
+
"@turf/bbox": "^7.4.0",
|
|
45
51
|
"boundingbox": "^1.4.0",
|
|
46
|
-
"clsx": "^
|
|
47
|
-
"colorbrewer": "1.
|
|
52
|
+
"clsx": "^2.1.1",
|
|
53
|
+
"colorbrewer": "^1.7.0",
|
|
48
54
|
"geohash": "^0.0.1",
|
|
49
55
|
"highlight-search-result": "^1.0.4",
|
|
50
|
-
"immer": "^
|
|
51
|
-
"react-tiny-popover": "^
|
|
56
|
+
"immer": "^11.2.9",
|
|
57
|
+
"react-tiny-popover": "^8.1.6",
|
|
52
58
|
"react-virtual": "^2.10.4",
|
|
53
|
-
"react-virtualized-auto-sizer": "^
|
|
54
|
-
"react-web-share": "^
|
|
55
|
-
"redaxios": "^0.5.
|
|
56
|
-
"twind": "^0.16.
|
|
59
|
+
"react-virtualized-auto-sizer": "^2.0.4",
|
|
60
|
+
"react-web-share": "^2.0.2",
|
|
61
|
+
"redaxios": "^0.5.1",
|
|
62
|
+
"twind": "^0.16.19",
|
|
63
|
+
"@biodiv-platform/naksha-commons": "5.0.0-beta.3"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"clean": "rm -rf node_modules dist .turbo",
|
|
67
|
+
"build": "tsup src/index.tsx --format esm,cjs --dts --minify --external react",
|
|
68
|
+
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react"
|
|
57
69
|
}
|
|
58
|
-
}
|
|
70
|
+
}
|
package/dist/esm/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var eo=Object.defineProperty,to=Object.defineProperties;var ro=Object.getOwnPropertyDescriptors;var Pt=Object.getOwnPropertySymbols;var oo=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var De=Math.pow,Ct=(e,r,t)=>r in e?eo(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,m=(e,r)=>{for(var t in r||(r={}))oo.call(r,t)&&Ct(e,t,r[t]);if(Pt)for(var t of Pt(r))no.call(r,t)&&Ct(e,t,r[t]);return e},I=(e,r)=>to(e,ro(r));var v=(e,r,t)=>new Promise((o,n)=>{var a=i=>{try{c(t.next(i))}catch(l){n(l)}},s=i=>{try{c(t.throw(i))}catch(l){n(l)}},c=i=>i.done?o(i.value):Promise.resolve(i.value).then(a,s);c((t=t.apply(e,r)).next())});import{TranslationProvider as oa}from"@biodiv-platform/naksha-commons";import na from"react";import{MapProvider as aa}from"react-map-gl/maplibre";import{setup as sa}from"twind";var It={are_you_sure:"Are you sure?",base_style:"Base Style",clear:"Clear Selection",created_by:"Attribution",created_on:"Created On",delete:"Delete",download:"Download",find_layer_by_name:"Find layer by name",infobar:"Attributes at Clicked Location",information:"Information",layer_selection:"Layer Selection",layer_selection_all:"All Layers",layer_selection_top:"Top Layer Only",layers:"Layers",legend:"Legend",less:"Less",license:"License",list_layers:"List Layers",pending:"Pending",publish:"Publish",raster_style_not_found:"Style not available for the given layer",remove:"Remove",selected:"Selected",settings:"Settings",square:"Square",tags:"Tags",toggle:"Toggle Publishing",uploaded:"Uploaded",uploader:"Uploader",url:"URL",visiblity:"Visiblity"};var Mt={are_you_sure:"\xCAtes-vous s\xFBr?",base_style:"Style de base",clear:"Effacer la s\xE9lection",created_by:"Attribution",created_on:"Cr\xE9\xE9 sur",delete:"Effacer",download:"T\xE9l\xE9charger",find_layer_by_name:"Trouver la couche par nom",infobar:"Attributs \xE0 l'emplacement cliqu\xE9",information:"Informations",layer_selection_all:"Toutes les couches",layer_selection_top:"Couche sup\xE9rieure uniquement",layer_selection:"S\xE9lection de calque",layers:"Couches",legend:"L\xE9gende",less:"Moins",license:"Licence",list_layers:"Liste des couches",pending:"En attente",publish:"Publier",remove:"Supprimer",selected:"Choisie",settings:"Param\xE8tres",square:"Carr\xE9",toggle:"Basculer la publication",uploaded:"T\xE9l\xE9charg\xE9",url:"url"};var Et={are_you_sure:"\u0915\u094D\u092F\u093E \u0906\u092A\u0915\u094B \u092F\u0915\u0940\u0928 \u0939\u0948?",base_style:"\u0906\u0927\u093E\u0930 \u0936\u0948\u0932\u0940",clear:"\u091A\u092F\u0928 \u0938\u093E\u092B\u093C \u0915\u0930\u0947\u0902",created_by:"\u0906\u0930\u094B\u092A\u0923",created_on:"\u092A\u0930 \u092C\u0928\u093E\u092F\u093E",delete:"\u0939\u091F\u093E\u090F\u0902",download:"\u0921\u093E\u0909\u0928\u0932\u094B\u0921",find_layer_by_name:"\u0928\u093E\u092E \u0938\u0947 \u092A\u0930\u0924 \u0916\u094B\u091C\u0947\u0902",infobar:"\u0915\u094D\u0932\u093F\u0915 \u0915\u093F\u090F \u0917\u090F \u0938\u094D\u0925\u093E\u0928 \u092A\u0930 \u0935\u093F\u0936\u0947\u0937\u0924\u093E\u090F\u0902",information:"\u091C\u093E\u0928\u0915\u093E\u0930\u0940",layer_selection_all:"\u0938\u092D\u0940 \u092A\u0930\u0924\u0947\u0902",layer_selection_top:"\u0915\u0947\u0935\u0932 \u0936\u0940\u0930\u094D\u0937 \u092A\u0930\u0924",layer_selection:"\u092A\u0930\u0924 \u091A\u092F\u0928",layers:"\u092A\u0930\u0924\u0947\u0902",legend:"\u0915\u093F\u0902\u0935\u0926\u0902\u0924\u0940",less:"\u0915\u092E",license:"\u0932\u093E\u0907\u0938\u0947\u0902\u0938",list_layers:"\u0938\u0942\u091A\u0940 \u092A\u0930\u0924\u0947\u0902",pending:"\u0932\u0902\u092C\u093F\u0924",publish:"\u092A\u094D\u0930\u0915\u093E\u0936\u093F\u0924",remove:"\u0939\u091F\u093E\u0928\u093E",selected:"\u091A\u092F\u0928\u093F\u0924",settings:"\u0938\u092E\u093E\u092F\u094B\u091C\u0928",square:"\u0938\u094D\u0915\u094D\u0935\u093E\u092F\u0930",tags:"\u091F\u0948\u0917",toggle:"\u092A\u094D\u0930\u0915\u093E\u0936\u0928 \u091F\u0949\u0917\u0932 \u0915\u0930\u0947\u0902",uploaded:"\u0905\u092A\u0932\u094B\u0921 \u0915\u093F\u092F\u093E \u0917\u092F\u093E",url:"\u092F\u0942\u0906\u0930\u090F\u0932"};var Tt={en:It,fr:Mt,hi:Et};import{defaultViewState as Un}from"@biodiv-platform/naksha-commons";import{useMemo as Kn,useState as Xn}from"react";import Qn,{FullscreenControl as jn,NavigationControl as ea}from"react-map-gl/maplibre";import{tw as ta}from"twind";import{defaultMapStyles as go,useDebounce as ho}from"@biodiv-platform/naksha-commons";import vo,{createContext as bo,useContext as Lo,useEffect as Yt,useMemo as xo,useState as G}from"react";import{useMap as wo}from"react-map-gl/maplibre";import yo from"colorbrewer";import Y from"redaxios";import Bt from"boundingbox";import{GeoHash as Fe}from"geohash";import{MapStyles as lo,defaultViewState as co}from"@biodiv-platform/naksha-commons";var Nt={defaultViewState:co,nakshaApiEndpoint:"/naksha-api/api",geoserver:{endpoint:"/geoserver",workspace:"biodiv",store:"ibp"},mapStyle:lo.MAP_STREETS,layers:[],selectedLayers:[]},Rt="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",ze={display:"-webkit-box",WebkitLineClamp:1,WebkitBoxOrient:"vertical",overflow:"hidden",wordBreak:"break-word"},At=I(m({},ze),{WebkitLineClamp:2}),O="ogc_fid",be={ACTIVE:"Active",PENDING:"Pending"},D={TOP:"layer_selection_top",ALL:"layer_selection_all"};var Gt=e=>e<6?[4,1,39.2]:e<7?[5,0,19.6]:e<8?[5,1,9.8]:e<9?[5,-1,4.9]:e<10?[6,0,2.45]:e<11?[6,1,1.225]:e<12?[7,0,.612]:e<13?[7,1,.306]:e<14?[7,-1,.153]:e<15?[8,0,.077]:[8,1,.039],He="0123456789bcdefghjkmnpqrstuvwxyz",uo=(e,r,t)=>{t=t||16/De(2,1-e.length&1)/De(4,r);let o=e.slice(0,-1),n=~~(He.indexOf(e.slice(-1))/t);return[o+He[t*n],o+He[t*(n+1)-1]]},fo=function(e,r){var t=new Map,o=new Map;let n=[];for(let[a,s]of Object.entries(e)){let[c,i]=uo(a,r);o.set(c,i),t.has(c)||t.set(c,0),t.set(c,t.get(c)+s)}return t.forEach((a,s)=>{let c=Fe.decodeGeoHash(s),i=Fe.decodeGeoHash(o.get(s)),l=new Bt({minlat:c.latitude[0],minlon:c.longitude[0],maxlat:i.latitude[1],maxlon:i.longitude[1]}).toGeoJSON();n.push(I(m({},l),{properties:{count:a,[O]:s}}))}),n},po=e=>{let r=[];for(let[t,o]of Object.entries(e)){let n=Fe.decodeGeoHash(t),a=new Bt({minlat:n.latitude[0],minlon:n.longitude[0],maxlat:n.latitude[1],maxlon:n.longitude[1]}).toGeoJSON();r.push(I(m({},a),{properties:{count:o,[O]:t}}))}return r},_t=(e,r)=>({type:"FeatureCollection",features:Object.keys(e).length===0?[]:r===-1?po(e):fo(e,r)}),Ot=(e,r)=>{let t=Object.values(e).sort((a,s)=>a-s),o=Math.floor(t.length/r),n=new Array(r-1).fill(0).map((a,s)=>t[o*(s+1)]);return n.push(t[t.length-1]),n};import mo from"immer";var Dt=(e,r,t,o)=>v(void 0,null,function*(){let n=[];for(let a of e){let s=o.includes(a.name),c=I(m({},a),{id:a.name,thumbnail:r+a.thumbnail,source:{type:a.layerType.toLowerCase()==="raster"?"raster":"vector",scheme:"tms",tiles:[`${t.endpoint}/gwc/service/tms/1.0.0/${t.workspace}:${a.name}@EPSG%3A900913@pbf/{z}/{x}/{y}.pbf`]},data:{styles:[]},isAdded:s});if(s){let i=yield qe(c,0,r,t);n.push(I(m({},c),{data:i}))}else n.push(c)}return n}),qe=(e,r,t,o)=>v(void 0,null,function*(){return mo(e.data,a=>v(void 0,null,function*(){var s;if(a.styles.length===0){let{success:c,data:i}=yield zt(e.id,t);c&&(a.layerName=i.layerName,a.styles=i.styles,a.summaryColumn=i.summaryColumn,a.titleColumn=i.titleColumn,a.propertyMap=Object.fromEntries(i.styles.map(l=>[l.styleName,l.styleTitle])))}a.styles[r]&&!((s=a.styles[r])!=null&&s.colors)&&(a.styles[r].colors=yield Ht(e.id,o==null?void 0:o.workspace,a.styles[r].styleName,t)),a.styleIndex=r}))});var Ft=(e,r,t,o)=>v(void 0,null,function*(){try{let n=yield Y.get(`${r}/layer/all`,{headers:{Authorization:e}});return yield Dt(n.data,r,t,o)}catch(n){return console.error(n),[]}}),zt=(e,r)=>v(void 0,null,function*(){try{let{data:t}=yield Y.get(`${r}/layer/onClick/${e}`);return{success:!0,data:t}}catch(t){return console.error(t),{success:!1}}}),qt=(e,r,t)=>v(void 0,null,function*(){let o={service:"WMS",version:"1.1.1",request:"GetFeatureInfo",info_format:"application/json",width:100,height:100,x:50,y:50,srs:"EPSG:4326"};try{return{success:!0,data:(yield Y.get(`${e}/${r}/wms`,{params:m(m({},t),o)})).data}}catch(n){return console.error(n),{success:!1,data:[]}}}),$t=(e,r,t,o)=>v(void 0,null,function*(){try{return yield Y.put(`${r}/layer/${o?"active":"pending"}/${t}`,{},{headers:{Authorization:e}}),!0}catch(n){return console.error(n),!1}}),Vt=(e,r,t)=>v(void 0,null,function*(){try{return yield Y.delete(`${r}/layer/${t}`,{headers:{Authorization:e}}),!0}catch(o){return console.error(o),!1}}),Ht=(e,r,t,o)=>v(void 0,null,function*(){var n,a;try{return(a=(n=(yield Y.get(`${o}/geoserver/workspaces/${r}/styles/${e}_${t}.mbstyle`)).data)==null?void 0:n.layers)==null?void 0:a[0]}catch(s){return console.error(s),{}}}),Wt=(e,r,t,o=6,n="YlOrRd")=>v(void 0,null,function*(){try{let[a,s,c]=Gt(t),{_ne:i,_sw:l}=r,p={top:i.lat,left:l.lng,bottom:l.lat,right:i.lng,geoAggegationPrecision:a},h=yield e(p),x=_t(h,s),P=Ot(h,o).map((T,L)=>[T,yo[n][o][L]]);return{success:!0,geojson:x,paint:{"fill-color":{property:"count",default:"yellow",stops:P},"fill-outline-color":"rgba(0,0,0,0.2)","fill-opacity":.7},stops:P,squareSize:c}}catch(a){return console.error(a),{success:!1,geojson:{},paint:{},stops:[],squareSize:0}}}),Zt=(e,r,t,o)=>v(void 0,null,function*(){try{yield Y.post(`${e}/layer/download`,{layerName:t,layerTitle:o,attributeList:[],filterArray:[]},{headers:{Authorization:r}})}catch(n){console.error(n)}});import{jsx as So}from"react/jsx-runtime";var Jt=bo({}),Ut=({mp:e,children:r})=>{var Lt,xt;let[t,o]=G(e),{mapl:n}=wo(),[a,s]=G(""),c=ho(a,500),i=t.mapStyles&&t.mapStyles.length>0?t.mapStyles:go,[l,p]=G((Lt=i[(t==null?void 0:t.mapStyle)||0])==null?void 0:Lt.style),[h,x]=G((xt=i[(t==null?void 0:t.mapStyle)||0])==null?void 0:xt.maxZoom),[w,P]=G(D.TOP),[E,T]=G({}),[L,B]=G(!0),[b,H]=G(),[S,Ge]=G(e.layers||[]),[N,ae]=G(t.selectedLayers||[]),[he,yt]=G(),[_e,gt]=G(),Vr=xo(()=>{var g;let d={};for(let y of _e||[])d[y.sourceLayer]=[...d[y.sourceLayer]||[],(g=y==null?void 0:y.properties)==null?void 0:g[O]];return Object.keys(d).length?d:void 0},[_e]),se=vo.useMemo(()=>{let d=S.filter(y=>N.includes(y.id)),g=new Array(N.length);for(let y of d){let C=N.findIndex(_=>y.id===_);C>-1&&(g[C]=y)}return g},[S,N]),ve=d=>S.findIndex(g=>g.id===d),ht=(d,g)=>{Ge(y=>y.map(C=>C.id===d?m(m({},C),g):C))},vt=(d,g,y)=>v(void 0,null,function*(){let C=S[d],_=yield qe(C,g,t.nakshaApiEndpoint,t.geoserver);ht(C.id,{data:_}),y&&(n==null||n.fitBounds(C.bbox,{padding:40,duration:1e3}))}),Wr=(d,g)=>v(void 0,null,function*(){let y=ve(d);vt(y,g,!1)}),Zr=d=>v(void 0,null,function*(){var g,y,C,_;if(!(!N.length||!n))try{let q=N[0],ie=n.queryRenderedFeatures(d.point,{layers:[q]});if(ie.length){let le=((g=ie[0])==null?void 0:g.id)||((C=(y=ie[0])==null?void 0:y.properties)==null?void 0:C[O]);if(le===(he==null?void 0:he.id))return;let $=S[ve(q)],W=(_=$==null?void 0:$.data)==null?void 0:_.summaryColumn.map(Z=>{var wt,St,kt;return[((St=(wt=$.data)==null?void 0:wt.propertyMap)==null?void 0:St[Z])||Z,(kt=ie[0].properties)==null?void 0:kt[Z]]});yt({id:le,title:$.title,data:W})}else yt(void 0)}catch(q){}}),Yr=_=>v(void 0,[_],function*({layerId:d,add:g,styleIndex:y=0,focus:C=!0}){var le,$;if(!g){ae(N.filter(W=>d!==W));return}let q=ve(d);((le=S[q])==null?void 0:le.source.type)==="grid"?(ae(W=>[d,...W.filter(Z=>Z!==d)]),C&&(($=S[q])==null?void 0:$.bbox)&&setTimeout(()=>{n==null||n.fitBounds(S[q].bbox,{padding:40,duration:1e3})},100)):(yield vt(q,y,C),ae(W=>[d,...W.filter(Z=>Z!==d)]))}),Jr=()=>v(void 0,null,function*(){return ae([])}),Ur=(d,g)=>{o(I(m({},t),{[d]:g}))},Kr=(d,g)=>{let y=g===be.PENDING;$t(t.nakshaEndpointToken,t.nakshaApiEndpoint,d,y),ht(d,{layerStatus:y?be.ACTIVE:be.PENDING})},Xr=(d,g)=>v(void 0,null,function*(){confirm(g)&&(Vt(t.nakshaEndpointToken,t.nakshaApiEndpoint,d),Ge(S.filter(y=>y.id!==d)))}),Qr=d=>{let g=ve(d),y=S[g];n==null||n.fitBounds(y.bbox,{padding:40,duration:1e3})},bt=()=>[b.lng,b.lat,b.lng+.1,b.lat+.1],jr=d=>{P(d),d===D.TOP&&Oe(d)},Oe=d=>{if(!!b)try{let g=n==null?void 0:n.project([b.lng,b.lat]),y=n==null?void 0:n.queryRenderedFeatures(g,{layers:w===D.TOP?[N[0]]:N});if((d||w)===D.ALL){let C=se.filter(_=>_.layerType=="RASTER").map(_=>({sourceLayer:_.id,layerType:"raster",bbox:bt()}));y=[...y,...C]}gt((se==null?void 0:se[0].layerType)==="RASTER"&&w!==D.ALL?N.length&&(y==null?void 0:y.length)?y:[{sourceLayer:N[0],layerType:"raster",bbox:bt()}]:y)}catch(g){console.error(g)}};return Yt(()=>{t.onSelectedLayersChange&&t.onSelectedLayersChange(N)},[N]),Yt(()=>{setTimeout(Oe,300)},[b,w,N]),So(Jt.Provider,{value:{mp:t,updateMP:Ur,layer:{mapStyle:l,featuresAtLatLng:Oe,setMapStyle:p,maxZoom:h,setMaxZoom:x,mapStyles:i,all:S,setAll:Ge,selectedIds:N,handleSelectStyle:jr,setSelectedIds:ae,selectedLayers:se,clearAll:Jr,toggle:Yr,updateStyle:Wr,selectedFeatures:_e,selectedFeaturesId:Vr,setSelectedFeatures:gt,togglePublish:Kr,delete:Xr,selectionStyle:w,setSelectionStyle:P,zoomToExtent:Qr,gridLegends:E,setGridLegends:T},query:{term:c,setTerm:s,clickedLngLat:b,setClickedLngLat:H},isInfoBarOpen:L,setIsInfoBarOpen:B,hover:{onHover:Zr,features:he}},children:r})};function f(){return Lo(Jt)}import Po from"react";import{tw as xe}from"twind";import{tw as ko}from"twind";import{jsx as u,jsxs as ue}from"react/jsx-runtime";var Kt=()=>u("svg",{fill:"none",className:ko`w-5 h-5 text-gray-400`,width:"24",height:"24",viewBox:"0 0 24 24",children:u("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ce=()=>ue("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[u("path",{d:"M12 2L2 7 12 12 22 7 12 2z"}),u("path",{d:"M2 17L12 22 22 17"}),u("path",{d:"M2 12L12 17 22 12"})]}),Le=()=>ue("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("circle",{cx:"12",cy:"12",r:"10"}),u("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),u("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),Xt=()=>ue("svg",{width:"18",height:"18",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",viewBox:"0 0 24 24",children:[u("path",{d:"M4 21L4 14"}),u("path",{d:"M4 10L4 3"}),u("path",{d:"M12 21L12 12"}),u("path",{d:"M12 8L12 3"}),u("path",{d:"M20 21L20 16"}),u("path",{d:"M20 12L20 3"}),u("path",{d:"M1 14L7 14"}),u("path",{d:"M9 8L15 8"}),u("path",{d:"M17 16L23 16"})]});function $e(){return u("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M5.5 3.5a2 2 0 100 4 2 2 0 000-4zM2 5.5a3.5 3.5 0 115.898 2.549 5.507 5.507 0 013.034 4.084.75.75 0 11-1.482.235 4.001 4.001 0 00-7.9 0 .75.75 0 01-1.482-.236A5.507 5.507 0 013.102 8.05 3.49 3.49 0 012 5.5zM11 4a.75.75 0 100 1.5 1.5 1.5 0 01.666 2.844.75.75 0 00-.416.672v.352a.75.75 0 00.574.73c1.2.289 2.162 1.2 2.522 2.372a.75.75 0 101.434-.44 5.01 5.01 0 00-2.56-3.012A3 3 0 0011 4z"})})}function Qt(){return u("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M2.5 7.775V2.75a.25.25 0 01.25-.25h5.025a.25.25 0 01.177.073l6.25 6.25a.25.25 0 010 .354l-5.025 5.025a.25.25 0 01-.354 0l-6.25-6.25a.25.25 0 01-.073-.177zm-1.5 0V2.75C1 1.784 1.784 1 2.75 1h5.025c.464 0 .91.184 1.238.513l6.25 6.25a1.75 1.75 0 010 2.474l-5.026 5.026a1.75 1.75 0 01-2.474 0l-6.25-6.25A1.75 1.75 0 011 7.775zM6 5a1 1 0 100 2 1 1 0 000-2z"})})}function jt(){return u("svg",{width:"14",height:"14",viewBox:"0 0 16 16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"})})}function er(){return u("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.679 7.932c.412-.621 1.242-1.75 2.366-2.717C5.175 4.242 6.527 3.5 8 3.5c1.473 0 2.824.742 3.955 1.715 1.124.967 1.954 2.096 2.366 2.717a.119.119 0 010 .136c-.412.621-1.242 1.75-2.366 2.717C10.825 11.758 9.473 12.5 8 12.5c-1.473 0-2.824-.742-3.955-1.715C2.92 9.818 2.09 8.69 1.679 8.068a.119.119 0 010-.136zM8 2c-1.981 0-3.67.992-4.933 2.078C1.797 5.169.88 6.423.43 7.1a1.619 1.619 0 000 1.798c.45.678 1.367 1.932 2.637 3.024C4.329 13.008 6.019 14 8 14c1.981 0 3.67-.992 4.933-2.078 1.27-1.091 2.187-2.345 2.637-3.023a1.619 1.619 0 000-1.798c-.45-.678-1.367-1.932-2.637-3.023C11.671 2.992 9.981 2 8 2zm0 8a2 2 0 100-4 2 2 0 000 4z"})})}function tr(){return u("svg",{viewBox:"0 0 16 16",width:"14",height:"14",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M1.5 8a6.5 6.5 0 1113 0 6.5 6.5 0 01-13 0zM8 0a8 8 0 100 16A8 8 0 008 0zm.5 4.75a.75.75 0 00-1.5 0v3.5a.75.75 0 00.471.696l2.5 1a.75.75 0 00.557-1.392L8.5 7.742V4.75z"})})}function rr(){return u("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",fill:"currentColor",d:"M7.47 10.78a.75.75 0 001.06 0l3.75-3.75a.75.75 0 00-1.06-1.06L8.75 8.44V1.75a.75.75 0 00-1.5 0v6.69L4.78 5.97a.75.75 0 00-1.06 1.06l3.75 3.75zM3.75 13a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5z"})})}function or(){return u("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:u("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}function nr(){return ue("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:[u("circle",{cx:"18",cy:"5",r:"3"}),u("circle",{cx:"6",cy:"12",r:"3"}),u("circle",{cx:"18",cy:"19",r:"3"}),u("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),u("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]})}function ar(){return u("svg",{viewBox:"0 0 16 16",width:"16",height:"16",style:{display:"inline-block"},children:u("path",{fillRule:"evenodd",d:"M10 13a1 1 0 100-2 1 1 0 000 2zm-4 0a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zm3 1a1 1 0 100-2 1 1 0 000 2zm1-5a1 1 0 11-2 0 1 1 0 012 0zM6 5a1 1 0 100-2 1 1 0 000 2z"})})}function sr(){return ue("svg",{style:{display:"inline-block"},width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[u("circle",{cx:"12",cy:"12",r:"10"}),u("line",{x1:"22",y1:"12",x2:"18",y2:"12"}),u("line",{x1:"6",y1:"12",x2:"2",y2:"12"}),u("line",{x1:"12",y1:"6",x2:"12",y2:"2"}),u("line",{x1:"12",y1:"22",x2:"12",y2:"18"})]})}function ir(){return u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:u("polyline",{points:"6 9 12 15 18 9"})})}function lr(){return u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"inline-block"},children:u("polyline",{points:"18 15 12 9 6 15"})})}import{jsx as j}from"react/jsx-runtime";var V=Po.forwardRef((e,r)=>j("button",m({ref:r,type:"button",className:xe`h-8 px-3 py-2 rounded-md focus:outline-none focus:ring cursor-pointer text-md flex align-middle items-center gap-2 bg-gray-100 hover:bg-gray-200 text-gray-700 disabled:cursor-not-allowed disabled:bg-gray-100! disabled:opacity-50`},e)));var we=e=>j("button",m({className:xe`absolute top-0 right-0 h-12 w-12 bg-red-100 cursor-pointer hover:bg-red-200 text-red-800 text-lg`,children:"\u2715"},e)),cr=e=>j("button",I(m({className:xe`absolute top-4 left-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`},e),{children:j(ce,{})})),ur=e=>j("button",I(m({className:xe`absolute top-4 right-4 rounded-lg z-10 h-10 w-10 bg-white cursor-pointer hover:bg-gray-100 text-gray-700 text-lg flex items-center justify-center`},e),{children:j(Le,{})}));import{tw as ee}from"twind";import{jsx as z,jsxs as pr}from"react/jsx-runtime";var te=e=>pr("div",{children:[e.label&&z("label",{className:ee`text-gray-700`,htmlFor:e.name,children:e.label}),z("select",m({id:e.name,name:e.name,className:ee`block w-full px-4 py-2 mt-2 text-gray-700 border bg-white border-gray-200 rounded-md focus:outline-none focus:ring appearance-none text-base`,style:{backgroundImage:`url("data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E")`,backgroundPosition:"right 0.75rem center",backgroundSize:"16px 12px",backgroundRepeat:"no-repeat"}},e))]}),fr=e=>pr("div",{className:"relative",children:[z("span",{className:ee`absolute inset-y-0 left-0 flex items-center pl-3`,children:z(Kt,{})}),z("input",m({type:"search",className:ee`w-full py-2 pl-10 pr-4 text-gray-700 bg-white border border-gray-300 text-base rounded-md focus:outline-none focus:ring`},e))]}),dr=e=>e.isLoading?z("svg",{width:"20px",height:"20px",viewBox:"0 0 20 20",version:"1.1",className:ee`inline text-gray-200 animate-spin dark:text-gray-600`,children:z("g",{stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:z("g",{fill:"#212121",fillRule:"nonzero",children:z("path",{d:"M10,3 C6.13401,3 3,6.13401 3,10 C3,10.2761 2.77614,10.5 2.5,10.5 C2.22386,10.5 2,10.2761 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 C18,14.4183 14.4183,18 10,18 C9.72386,18 9.5,17.7761 9.5,17.5 C9.5,17.2239 9.72386,17 10,17 C13.866,17 17,13.866 17,10 C17,6.13401 13.866,3 10,3 Z"})})})}):z("input",{type:"checkbox",className:ee`w-5 h-5 border-gray-100 focus:outline-none focus:ring focus:ring-blue-300 focus:ring-opacity-80`,name:e.name,checked:e.checked,onChange:e.onChange});import{Tabs as mr,usePanelState as Co,useTabState as Io}from"@bumaga/tabs";import Mo from"clsx";import{tw as Se}from"twind";import{jsx as Ve,jsxs as Eo}from"react/jsx-runtime";var ke=({children:e,icon:r})=>{let{onClick:t,isActive:o}=Io(),n=Mo(["flex items-center justify-center h-12 px-2 py-2 bg-transparent -mb-px border-b-2 -px-1 whitespace-nowrap focus:outline-none w-full cursor-pointer",{"text-blue-600 border-blue-500":o,"text-gray-700 border-gray-300 hover:border-gray-400":!o}]);return Eo("button",{className:Se(n),onClick:t,children:[r,Ve("span",{className:Se`ml-2 text-base`,children:e})]})},Pe=({children:e})=>Co()?Ve("div",{className:Se`w-full flex flex-grow-1 overflow-auto`,children:e}):null,yr=({children:e})=>Ve("div",{className:Se`flex flex-shrink-0 border-b border-gray-200 justify-around pr-12`,children:e});import{useT as Ao}from"@biodiv-platform/naksha-commons";import{tw as Ie}from"twind";import{useT as To}from"@biodiv-platform/naksha-commons";import{jsx as gr}from"react/jsx-runtime";function fe({hideLabel:e}){let{layer:{selectionStyle:r,handleSelectStyle:t}}=f(),{t:o}=To(),n=a=>{t(a.target.value)};return gr(te,{name:"layer_selection",label:e?null:o("layer_selection"),defaultValue:r,onChange:n,children:Object.values(D).map(a=>gr("option",{value:a,children:o(a)},a))})}import No from"clsx";import{useEffect as Ro,useState as hr}from"react";import{tw as Ce}from"twind";import{jsx as de,jsxs as We}from"react/jsx-runtime";function Ze({data:e}){let[r,t]=hr(!0),[o,n]=hr({title:e.sourceLayer,properties:[]}),{layer:a,mp:s,query:{clickedLngLat:c}}=f(),i=()=>v(this,null,function*(){var h,x,w,P,E,T;let l,p=a.selectedLayers.find(L=>L.id===(e.sourceLayer||e.source));if(p.layerType.toLowerCase()==="raster"){let{data:L}=yield qt((h=s.geoserver)==null?void 0:h.endpoint,(x=s.geoserver)==null?void 0:x.workspace,{bbox:e.bbox.toString(),query_layers:`${(w=s.geoserver)==null?void 0:w.workspace}:${p.id}`,layers:`${(P=s.geoserver)==null?void 0:P.workspace}:${p.id}`});l=L!=null&&L.features[0]?Object.entries((E=L.features[0])==null?void 0:E.properties).map(([B,b])=>[b||"-"]):[]}else l=Object.entries(((T=p==null?void 0:p.data)==null?void 0:T.propertyMap)||{}).map(([L,B])=>{var b;return[B,(b=e==null?void 0:e.properties)==null?void 0:b[L]]});n({title:p.title,properties:l})});return Ro(()=>{i()},[c]),We("div",{className:Ce`bg-gray-100 rounded-lg`,children:[We("button",{className:Ce(No(["px-4 h-10 flex items-center justify-between bg-gray-100 hover:bg-gray-200 transition-colors cursor-pointer w-full focus:outline-none focus:ring",{"bg-gray-200 rounded-t-lg":r,"rounded-lg":!r}])),onClick:()=>t(!r),children:[o.title," ",r?de(lr,{}):de(ir,{})]}),r&&de("div",{className:Ce`px-4 py-3 flex flex-col gap-3`,children:o.properties.map(([l,p],h)=>We("div",{children:[de("div",{className:Ce`text-gray-600`,children:l}),de("div",{children:p})]},l+p+h))})]})}import{jsx as re,jsxs as Ye}from"react/jsx-runtime";function Je({onClose:e}){var a;let{layer:{selectedFeatures:r,selectedLayers:t,selectionStyle:o}}=f(),{t:n}=Ao();return Ye("div",{className:Ie`absolute top-0 right-0 bottom-0 left-0 md:top-4 md:right-4 md:bottom-4 md:left-auto bg-white rounded-lg overflow-hidden shadow-md md:max-w-sm w-full z-20 flex flex-col`,children:[Ye("div",{className:"flex w-full",children:[Ye("div",{className:Ie`h-12 px-4 flex items-center gap-3 flex-grow bg-gray-200`,children:[re(sr,{})," ",n("infobar")]}),re(we,{onClick:e})]}),re("div",{className:Ie`bg-gray-100 p-4 flex-shrink-0 rt`,children:re(fe,{hideLabel:!0})}),re("div",{className:Ie`flex flex-col flex-grow overflow-auto gap-3 p-4`,children:(a=r.flat(1))==null?void 0:a.map(s=>{var c;return re(Ze,{data:s},((c=t==null?void 0:t[0])==null?void 0:c.source.type)==="raster"||o===D.ALL?s==null?void 0:s.sourceLayer:(s==null?void 0:s.sourceLayer)+(s==null?void 0:s.properties[O]))})})]})}import{jsx as vr}from"react/jsx-runtime";function Ue(){var n;let{layer:e,isInfoBarOpen:r,setIsInfoBarOpen:t}=f();if(!((n=e.selectedFeatures)!=null&&n.length))return null;let o=()=>t(!r);return r?vr(Je,{onClose:o}):vr(ur,{onClick:o})}import{useEffect as In,useState as Mn}from"react";import{useMap as En}from"react-map-gl/maplibre";import{useT as Cn}from"@biodiv-platform/naksha-commons";import{tw as Ar}from"twind";import{tw as cn}from"twind";import rn,{useMemo as on}from"react";import{useVirtual as nn}from"react-virtual";import an from"react-virtualized-auto-sizer";import{tw as kr}from"twind";import{useT as Qo}from"@biodiv-platform/naksha-commons";import{useMemo as jo,useState as Sr}from"react";import{RWebShare as en}from"react-web-share";import{tw as F}from"twind";import{Fragment as br,jsx as Me}from"react/jsx-runtime";var Lr=({text:e="",highlight:r=""})=>{if(!r.trim())return Me(br,{children:e});let t=new RegExp(`(${r})`,"gi"),o=e.split(t);return Me(br,{children:o.filter(n=>n).map((n,a)=>t.test(n)?Me("mark",{children:n},a):Me("span",{children:n},a))})};import{tw as zo}from"twind";import{useT as Bo}from"@biodiv-platform/naksha-commons";import{useState as Go}from"react";import{tw as _o}from"twind";import{jsx as Oo,jsxs as Do}from"react/jsx-runtime";function pe({children:e}){let[r,t]=Go(!1),{t:o}=Bo();return Do("div",{children:[r&&e,Oo("button",{onClick:()=>t(!r),className:_o`text-blue-600 focus:outline-none focus:outline focus:ring`,children:o(r?"less":"legend")})]})}import{jsx as Ee,jsxs as Te}from"react/jsx-runtime";function Ke({item:e}){let{layer:r}=f(),t=r.gridLegends[e.id];return t?Ee(pe,{children:Te("ul",{style:{margin:0,padding:0},children:[t==null?void 0:t.stops.map(([o,n],a,s)=>{let c=(s[a-1]||[0])[0];return c===o?Ee("div",{},n):Te("li",{className:zo`flex gap-2 items-center mb-1`,children:[Ee("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:Ee("circle",{cx:"12",fill:n,cy:"12",r:"12",stroke:"none"})}),Te("div",{children:[c," - ",o]})]},n)}),Te("li",{children:["1 Square = ",t==null?void 0:t.squareSize," x ",t==null?void 0:t.squareSize," km"]})]})}):null}import{LICENSES as Ho,useT as Fo}from"@biodiv-platform/naksha-commons";import{useState as qo}from"react";import{Popover as $o}from"react-tiny-popover";import{tw as me}from"twind";import{jsx as k,jsxs as Xe}from"react/jsx-runtime";var oe=({icon:e,name:r,title:t,link:o,children:n})=>{let a=k("span",{children:n||"-"});return Xe("div",{className:me`flex gap-3 text-sm text-gray-600 break-all`,title:r&&t&&`${r}: ${t}`,children:[k("div",{children:e}),o?k("a",{className:me`text-blue-700 focus:outline-none focus:ring`,target:"_blank",rel:"noopener",href:o,children:a}):a]})};function Vo({item:e,containerStyle:r}){var i;let{t}=Fo(),{layer:o,mp:n}=f(),a=e.license||"CC-BY",s=(e==null?void 0:e.createdDate)&&new Date(e.createdDate).toLocaleDateString(),c=(i=e.tags)==null?void 0:i.join(", ");return Xe("div",{className:me`flex flex-col gap-1 bg-white p-4 rounded-lg w-72 border border-gray-300 border-solid`,style:r,children:[n.managePublishing&&e.layerStatus&&Xe(oe,{icon:k(er,{}),name:t("visiblity"),title:e.layerStatus,children:[e.layerStatus,k("button",{className:me`text-blue-600 focus:outline-none ml-4`,onClick:()=>o.togglePublish(e.id,e==null?void 0:e.layerStatus),children:t("toggle")}),k("button",{className:me`text-red-600 focus:outline-none ml-4`,onClick:()=>o.delete(e.id,t("are_you_sure")),children:t("delete")})]}),k(oe,{icon:k($e,{}),link:e.url,name:t("uploader"),title:e.createdBy,children:e.createdBy}),k(oe,{icon:k($e,{}),link:e.url,name:t("created_by"),title:e.attribution,children:e.attribution}),k(oe,{icon:k(tr,{}),name:t("created_on"),title:s,children:s}),k(oe,{icon:k(Qt,{}),name:t("tags"),title:c,children:c}),k(oe,{name:t("license"),title:a,link:a&&Ho[a],icon:k(jt,{}),children:a})]})}var xr=({item:e})=>{let[r,t]=qo(!1),o=()=>t(!r);return k($o,{isOpen:r,padding:10,positions:["right"],containerStyle:{zIndex:99},onClickOutside:o,content:k(Vo,{item:e}),children:k(V,{onClick:o,children:k(Le,{}),title:"Information"})})};import{tw as Ko}from"twind";import{useMemo as Wo,useState as Zo}from"react";import{useT as Yo}from"@biodiv-platform/naksha-commons";import{tw as Jo}from"twind";import{jsx as J,jsxs as Uo}from"react/jsx-runtime";function wr({item:e}){var c;let[r,t]=Zo(!0),{mp:o}=f(),{t:n}=Yo(),a=Wo(()=>{var i,l,p,h,x,w,P,E,T,L,B,b;return((w=(x=(h=(p=(l=(i=e==null?void 0:e.data)==null?void 0:i.styles)==null?void 0:l[e.data.styleIndex])==null?void 0:p.colors)==null?void 0:h.paint)==null?void 0:x["fill-color"])==null?void 0:w.stops)||((b=(B=(L=(T=(E=(P=e==null?void 0:e.data)==null?void 0:P.styles)==null?void 0:E[e.data.styleIndex])==null?void 0:T.colors)==null?void 0:L.paint)==null?void 0:B["circle-color"])==null?void 0:b.stops)||[]},[e]),s=()=>a.map(([i,l])=>Uo("li",{className:Jo`flex gap-2 items-center mb-1`,children:[J("svg",{viewBox:"0 0 24 24",height:"14",width:"14",focusable:"false",children:J("circle",{cx:"12",fill:l,cy:"12",r:"12",stroke:"none"})}),J("div",{children:i})]},l));return J("ul",{style:{margin:0,padding:0},children:e.layerType!=="RASTER"?s():r?J("li",{children:J("img",{style:{margin:"5px"},onError:()=>t(!1),src:`${(c=o==null?void 0:o.geoserver)==null?void 0:c.endpoint}/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&WIDTH=20&HEIGHT=20&STRICT=false&layer=biodiv:${e.id}`})}):J("div",{children:n("raster_style_not_found")})})}import{jsx as Ne,jsxs as Xo}from"react/jsx-runtime";function Qe({item:e}){var o,n;if(!((o=e.data)!=null&&o.styles))return null;let{layer:r}=f(),t=a=>{r.updateStyle(e.id,Number(a.target.value))};return Xo("div",{className:Ko`flex flex-col gap-4 pt-2`,children:[e.layerType!=="RASTER"&&Ne(te,{onChange:t,children:(n=e.data)==null?void 0:n.styles.map((a,s)=>Ne("option",{value:s,children:a.styleTitle},s))}),Ne(pe,{children:Ne(wr,{item:e})})]})}import{jsx as M,jsxs as U}from"react/jsx-runtime";function tn({dragHandleProps:e}){return M("div",I(m({className:F`mt-1 w-6 text-center cursor-move`,style:{touchAction:"none"}},e),{children:M(ar,{})}))}function ye({item:e,extended:r,dragHandleProps:t}){let{t:o}=Qo(),{layer:n,query:a,mp:s,query:{setClickedLngLat:c},setIsInfoBarOpen:i}=f(),[l,p]=Sr(n.selectedIds.includes(e.id)),[h,x]=Sr(!1),w=jo(()=>s.canLayerShare?{url:`${window.location.href.split("?")[0]}?layers=${e.id}`,title:e.title}:void 0,[e.id]),P=()=>v(this,null,function*(){x(!0),i(!0),n.setSelectedFeatures([]),c(null),yield n.toggle({layerId:e.id,add:!l}),p(!l),x(!1)}),E=()=>v(this,null,function*(){yield Zt(s.nakshaApiEndpoint,s.nakshaEndpointToken,e.id,e.title),s==null||s.onLayerDownload(e.id)}),T=()=>n.zoomToExtent(e.id);return U("div",{className:F`z-20 p-3 bg-white`,style:{borderTop:"1px solid #e5e7eb"},children:[U("div",{className:F`flex gap-3`,children:[U("div",{className:F`flex-shrink-0`,children:[M(dr,{name:e.id,checked:l,onChange:P,isLoading:h}),r&&M(tn,{dragHandleProps:t})]}),M("img",{className:F`flex-shrink-0 overflow-hidden h-16 w-16 p-1 mb-2 object-cover border border-gray-200 rounded`,src:e.thumbnail||Rt}),U("div",{children:[M("div",{title:e.title,className:F`mb-1 leading-tight`,style:ze,children:M(Lr,{text:e.title,highlight:a.term})}),M("p",{title:e.description,className:F`text-gray-600 text-sm`,style:At,children:e.description})]})]}),U("div",{className:F`flex justify-between`,children:[U(V,{onClick:E,disabled:!e.isDownloadable,children:[M(rr,{})," ",o("download")]}),U("div",{className:F`flex gap-3`,children:[w&&M(en,{data:w,children:M(V,{title:"Share",children:M(nr,{})})}),r&&M(V,{onClick:T,title:"Zoom To Extent",children:M(or,{})}),M(xr,{item:e})]})]}),r&&M(Qe,{item:e}),r&&e.source.type==="grid"&&M(Ke,{item:e})]})}import{jsx as K}from"react/jsx-runtime";function Pr(){let{layer:e,query:r}=f(),t=on(()=>r.term?e.all.filter(a=>a.title.toLowerCase().includes(r.term.toLowerCase())):e.all,[e.all,r.term]),o=rn.useRef(),n=nn({size:t.length,parentRef:o});return K("div",{className:kr`flex-grow-1 relative`,children:K(an,{disableWidth:!0,children:a=>K("div",{ref:o,className:"List",style:{height:a.height,overflow:"auto"},children:K("div",{style:{height:n.totalSize,width:"100%",position:"relative"},children:n.virtualItems.map(s=>K("div",{ref:s.measureRef,className:kr`absolute top-0 left-0 w-full`,style:{transform:`translateY(${s.start}px)`},children:K("div",{style:{height:146},children:K(ye,{item:t[s.index]})})},s.index))})})})})}import{useT as sn}from"@biodiv-platform/naksha-commons";import{tw as ln}from"twind";import{jsx as Cr}from"react/jsx-runtime";function je(){let{t:e}=sn(),{query:r}=f(),t=o=>r.setTerm(o.target.value);return Cr("div",{className:ln`flex-shrink-0 border-b-2 p-4`,children:Cr(fr,{name:"lyr_search",placeholder:e("find_layer_by_name"),onChange:t})})}import{jsx as Ir,jsxs as un}from"react/jsx-runtime";function et(){return un("div",{className:cn`flex flex-col w-full`,children:[Ir(je,{}),Ir(Pr,{})]})}function fn(e,r,t){let o=r<0?e.length+r:r;if(o>=0&&o<e.length){let n=t<0?e.length+t:t,[a]=e.splice(r,1);e.splice(n,0,a)}}function Mr(e,r,t){return e=[...e],fn(e,r,t),e}import{closestCenter as dn,DndContext as pn,PointerSensor as mn,useSensor as yn,useSensors as gn}from"@dnd-kit/core";import{SortableContext as hn,useSortable as vn,verticalListSortingStrategy as bn}from"@dnd-kit/sortable";import{CSS as Ln}from"@dnd-kit/utilities";import{jsx as ne}from"react/jsx-runtime";function xn({item:e,extended:r}){let{attributes:t,listeners:o,setNodeRef:n,transform:a,transition:s,isDragging:c}=vn({id:e.id}),i={transform:Ln.Transform.toString(a),transition:s,opacity:c?.5:1};return ne("div",{ref:n,style:i,children:ne(ye,{item:e,extended:r,dragHandleProps:m(m({},t),o)})})}var Er=({layerList:e,onSortEnd:r})=>{let t=gn(yn(mn,{activationConstraint:{distance:4}}));return ne(pn,{sensors:t,collisionDetection:dn,onDragEnd:n=>{let{active:a,over:s}=n;if(s&&a.id!==s.id){let c=e.findIndex(l=>l.id===a.id),i=e.findIndex(l=>l.id===s.id);c!==-1&&i!==-1&&r({oldIndex:c,newIndex:i})}},children:ne(hn,{items:e.map(n=>n.id),strategy:bn,children:ne("div",{children:e.map(n=>ne(xn,{item:n,extended:!0},n.id))})})})};import{useT as wn}from"@biodiv-platform/naksha-commons";import{tw as Tr}from"twind";import{jsx as Rr,jsxs as Nr}from"react/jsx-runtime";function tt(){let{layer:e}=f(),{t:r}=wn(),t=({oldIndex:o,newIndex:n})=>{e.setSelectedIds(Mr(e.selectedIds,o,n))};return Nr("div",{className:Tr`flex flex-col gap-3 w-full`,children:[e.selectedIds.length>0&&Rr("div",{className:Tr`p-3 pb-0`,children:Nr(V,{onClick:()=>e.clearAll(),children:["\u2715 ",r("clear")]})}),Rr(Er,{layerList:e.selectedLayers,useDragHandle:!0,onSortEnd:t})]})}import{useT as Sn}from"@biodiv-platform/naksha-commons";import{tw as kn}from"twind";import{jsx as rt,jsxs as Pn}from"react/jsx-runtime";function ot(){let{layer:e}=f(),{t:r}=Sn(),t=o=>{var n;e.setMapStyle(o.target.value),e.setMaxZoom((n=e.mapStyles.find(a=>a.style===o.target.value))==null?void 0:n.maxZoom)};return Pn("div",{className:kn`w-full p-4 flex flex-col gap-4`,children:[rt(te,{name:"base_style",label:r("base_style"),defaultValue:e.mapStyle,onChange:t,children:e.mapStyles.map(o=>rt("option",{value:o.style,children:o.text},o.key))}),rt(fe,{})]})}import{jsx as A,jsxs as nt}from"react/jsx-runtime";function at({onClose:e}){let{t:r}=Cn();return nt("div",{className:Ar`absolute top-0 right-0 bottom-0 left-0 md:right-auto md:top-4 md:left-4 md:bottom-4 bg-white rounded-lg shadow-md md:max-w-sm w-full z-20 overflow-hidden`,children:[A(we,{onClick:e}),A("div",{className:Ar`flex flex-col h-full`,children:nt(mr,{children:[nt(yr,{children:[A(ke,{icon:A(ce,{}),children:r("layers")}),A(ke,{icon:A(ce,{}),children:r("selected")}),A(ke,{icon:A(Xt,{}),children:r("settings")})]}),A(Pe,{children:A(et,{})}),A(Pe,{children:A(tt,{})}),A(Pe,{children:A(ot,{})})]})})]})}import{jsx as Br}from"react/jsx-runtime";function st(){let{mp:e,layer:r}=f(),[t,o]=Mn(e.showToC),{mapl:n}=En(),a=()=>o(!t);function s(){return v(this,null,function*(){let c=yield Ft(e.nakshaEndpointToken,e.nakshaApiEndpoint,e.geoserver,e.selectedLayers),i=[...e.layers||[],...c];if(r.setAll(i),r.selectedIds.length){let l=i.find(p=>p.id===r.selectedIds[0]);l!=null&&l.bbox&&(n==null||n.fitBounds(l.bbox,{padding:40,duration:1e3}))}})}return In(()=>{n&&e.loadToC&&s()},[n]),t?Br(at,{onClose:a}):Br(cr,{onClick:a})}import{useMap as Hn}from"react-map-gl/maplibre";var R=63710088e-1,Wl={centimeters:R*100,centimetres:R*100,degrees:R/111325,feet:R*3.28084,inches:R*39.37,kilometers:R/1e3,kilometres:R/1e3,meters:R,metres:R,miles:R/1609.344,millimeters:R*1e3,millimetres:R*1e3,nauticalmiles:R/1852,radians:1,yards:R*1.0936},Zl={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/R,yards:1.0936133};function it(e,r,t){if(e!==null)for(var o,n,a,s,c,i,l,p=0,h=0,x,w=e.type,P=w==="FeatureCollection",E=w==="Feature",T=P?e.features.length:1,L=0;L<T;L++){l=P?e.features[L].geometry:E?e.geometry:e,x=l?l.type==="GeometryCollection":!1,c=x?l.geometries.length:1;for(var B=0;B<c;B++){var b=0,H=0;if(s=x?l.geometries[B]:l,s!==null){i=s.coordinates;var S=s.type;switch(p=t&&(S==="Polygon"||S==="MultiPolygon")?1:0,S){case null:break;case"Point":if(r(i,h,L,b,H)===!1)return!1;h++,b++;break;case"LineString":case"MultiPoint":for(o=0;o<i.length;o++){if(r(i[o],h,L,b,H)===!1)return!1;h++,S==="MultiPoint"&&b++}S==="LineString"&&b++;break;case"Polygon":case"MultiLineString":for(o=0;o<i.length;o++){for(n=0;n<i[o].length-p;n++){if(r(i[o][n],h,L,b,H)===!1)return!1;h++}S==="MultiLineString"&&b++,S==="Polygon"&&H++}S==="Polygon"&&b++;break;case"MultiPolygon":for(o=0;o<i.length;o++){for(H=0,n=0;n<i[o].length;n++){for(a=0;a<i[o][n].length-p;a++){if(r(i[o][n][a],h,L,b,H)===!1)return!1;h++}H++}b++}break;case"GeometryCollection":for(o=0;o<s.geometries.length;o++)if(it(s.geometries[o],r,t)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function lt(e){var r=[1/0,1/0,-1/0,-1/0];return it(e,function(t){r[0]>t[0]&&(r[0]=t[0]),r[1]>t[1]&&(r[1]=t[1]),r[2]<t[0]&&(r[2]=t[0]),r[3]<t[1]&&(r[3]=t[1])}),r}lt.default=lt;var Gr=lt;import{useEffect as ct,useState as Tn}from"react";import{Layer as Nn,Source as Rn,useMap as An}from"react-map-gl/maplibre";import{jsx as _r}from"react/jsx-runtime";function ut({data:e,beforeId:r}){let{layer:t}=f(),{mapl:o}=An(),[n,a]=Tn({geojson:{},paint:{}}),s=t.selectedIds.includes(e.id),c=t.selectedIds[0]===e.id,i=(l=!1)=>v(this,null,function*(){let{success:p,geojson:h,paint:x,stops:w,squareSize:P}=yield Wt(e.source.fetcher,o==null?void 0:o.getBounds(),o==null?void 0:o.getZoom());if(p){if(a({geojson:h,paint:x}),l&&c&&e.zoomToFit)try{let[E,T,L,B]=Gr(h);o==null||o.fitBounds([[E,T],[L,B]],{padding:40,animate:!0})}catch(E){console.warn("Failed to compute bbox",E)}t.setGridLegends({[e.id]:{stops:w,squareSize:P}})}});return ct(()=>{s&&c?i(!0):s&&i(!1)},[s,c]),ct(()=>{if(!s||!o)return;let l=()=>i(!1);return o.on("idle",l),()=>{o.off("idle",l)}},[s,o]),ct(()=>()=>{t.setGridLegends(l=>{let p=m({},l);return delete p[e.id],p})},[e.id]),_r(Rn,{id:e.id,type:"geojson",data:n.geojson,children:_r(Nn,{beforeId:r,id:e.id,type:"fill",paint:n.paint})})}import{useMemo as Bn}from"react";import{Layer as Or,Source as Gn}from"react-map-gl/maplibre";import{jsx as Dr,jsxs as On}from"react/jsx-runtime";var _n={fill:{"line-color":"red","line-width":2},circle:{"circle-stroke-color":"red","circle-stroke-width":2,"circle-opacity":0}};function Re({layer:e,beforeId:r}){var a;let{layer:t}=f(),o=Bn(()=>{var s,c,i,l;return(l=(i=(s=e.data)==null?void 0:s.styles)==null?void 0:i[(c=e.data)==null?void 0:c.styleIndex])==null?void 0:l.colors},[e,t.selectedFeatures]),n=(a=t.selectedFeaturesId)==null?void 0:a[e.id];return On(Gn,I(m({},e.source),{children:[o&&Dr(Or,m({beforeId:r},o)),n&&o&&Dr(Or,I(m({},o),{beforeId:r,id:`hl_${e.id}`,filter:["in",O,...n],type:o.type==="fill"?"line":o.type,paint:_n[o.type]}))]}))}import{Layer as Dn,Source as zn}from"react-map-gl/maplibre";import{jsx as zr}from"react/jsx-runtime";function ft({data:e,beforeId:r}){var o;let{mp:t}=f();return zr(zn,{id:e.id,type:"raster",tiles:[`${(o=t==null?void 0:t.geoserver)==null?void 0:o.endpoint}/wms?bbox={bbox-epsg-3857}&format=image/png&service=WMS&version=1.1.1&request=GetMap&srs=EPSG:3857&width=256&height=256&transparent=true&layers=biodiv:${e.id}`],tileSize:256,children:zr(Dn,{id:e.id,beforeId:r,type:"raster",source:"biodiv",layout:{visibility:"visible"},paint:{}})})}import{jsx as Ae}from"react/jsx-runtime";function Hr({layer:e,beforeId:r}){let{mapl:t}=Hn();if(!t)return null;switch(e.source.type){case"vector":return Ae(Re,{beforeId:r,layer:e});case"grid":return Ae(ut,{beforeId:r,data:e});case"raster":return Ae(ft,{beforeId:r,data:e});default:return Ae(Re,{beforeId:r,layer:e})}}import{useMemo as Fn}from"react";import{Marker as qn}from"react-map-gl/maplibre";import{Fragment as Wn,jsx as dt}from"react/jsx-runtime";var $n=qn,Vn=()=>{let{mp:e}=f(),r=Fn(()=>e.markers,[e.markers]);return dt(Wn,{children:r==null?void 0:r.map(({latitude:t,longitude:o,colorHex:n},a)=>dt($n,{latitude:t,longitude:o,children:dt("img",{style:{cursor:"pointer"},alt:"Marker",src:"https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png"})},a))})},Fr=Vn;import Zn from"clsx";import{Popup as Yn}from"react-map-gl/maplibre";import{tw as ge}from"twind";import{jsx as X,jsxs as qr}from"react/jsx-runtime";var Jn=Yn;function pt({coordinates:e}){let{hover:r}=f();return(e==null?void 0:e.lat)&&r.features?X(Jn,{latitude:e.lat,longitude:e.lng,closeButton:!1,children:qr("table",{className:ge`table-auto border`,children:[X("thead",{children:X("tr",{children:X("th",{className:ge`bg-gray-200 py-1 px-2`,colSpan:2,children:r.features.title})})}),X("tbody",{children:r.features.data.map(([t,o],n)=>qr("tr",{className:ge(Zn({"bg-gray-50":n%2===0,"border-gray-100 border-t":1})),children:[X("td",{className:ge`py-1 px-2`,children:t}),X("td",{className:ge`py-1 px-2 border-l border-gray-100`,children:o})]},t+o))})]})}):null}import{jsx as Q,jsxs as $r}from"react/jsx-runtime";var ra=ea;function mt(){var l;let{mp:e,layer:r,hover:t,query:o}=f(),[n,a]=Xn(),s=Kn(()=>e.defaultViewState||Un,[e.defaultViewState]),c=p=>o.setClickedLngLat(p.lngLat),i=p=>{a(p.lngLat),t.onHover(p)};return $r("div",{className:ta`h-full w-full relative bg-gray-100`,children:[e.loadToC&&Q(st,{}),((l=r.selectedFeatures)==null?void 0:l.length)>0&&Q(Ue,{}),$r(Qn,{id:"mapl",cursor:"default",initialViewState:s,style:{width:"100%",height:"100%"},mapStyle:r.mapStyle,maxZoom:r.maxZoom,onClick:c,onMouseMove:i,children:[Q(ra,{position:"bottom-right",showZoom:!0,showCompass:!0}),e.showFullscreenControl&&Q(jn,{position:"bottom-right"}),Q(Fr,{}),r.selectedLayers.map((p,h)=>{let x=h>0?r.selectedIds[h-1]:void 0;return Q(Hr,{layer:p,beforeId:x},p.id)}),Q(pt,{coordinates:n},"popup")]})]})}import{jsx as Be}from"react/jsx-runtime";sa({preflight:!1});var cu=e=>{let r=na.useMemo(()=>m(m({},Nt),e),[e]);return Be(aa,{children:Be(oa,{localeStrings:Tt,lang:r.lang,children:Be(Ut,{mp:r,children:Be(mt,{})})})})};export{cu as NakshaMaplibreLayers};
|