@maptiler/geocoding-control 3.0.0-rc.2 → 3.0.0-rc.4

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.
@@ -0,0 +1,1283 @@
1
+ import { css as M, LitElement as S, svg as A, html as m, unsafeCSS as he, nothing as ee } from "lit";
2
+ import { customElement as F, property as d, state as b, query as qe } from "lit/decorators.js";
3
+ import { convert as Ze } from "geo-coordinates-parser";
4
+ import { classMap as V } from "lit/directives/class-map.js";
5
+ import { repeat as Ne } from "lit/directives/repeat.js";
6
+ import "@turf/clone";
7
+ import { styleMap as Qe } from "lit/directives/style-map.js";
8
+ import { Feature as $ } from "ol";
9
+ import { Control as Ke } from "ol/control";
10
+ import { Point as X, Polygon as be, MultiPolygon as we, GeometryCollection as Ye, LineString as ke, MultiLineString as _e } from "ol/geom";
11
+ import He from "ol/layer/Vector";
12
+ import { transformExtent as Je, getUserProjection as Xe, fromLonLat as et, toLonLat as tt } from "ol/proj";
13
+ import it from "ol/source/Vector";
14
+ import $e from "@turf/bbox";
15
+ import st from "@turf/difference";
16
+ import rt from "@turf/flatten";
17
+ import { featureCollection as Le, polygon as ot } from "@turf/helpers";
18
+ import at from "@turf/union";
19
+ import Ie from "ol/style/Fill";
20
+ import nt from "ol/style/Icon";
21
+ import Me from "ol/style/Stroke";
22
+ import lt from "ol/style/Style";
23
+ import ct from "ol/style/Text";
24
+ var ht = Object.getOwnPropertyDescriptor, dt = (t, e, i, o) => {
25
+ for (var r = o > 1 ? void 0 : o ? ht(e, i) : e, s = t.length - 1, a; s >= 0; s--)
26
+ (a = t[s]) && (r = a(r) || r);
27
+ return r;
28
+ };
29
+ let te = class extends S {
30
+ render() {
31
+ return A`
32
+ <svg viewBox="0 0 14 14" width="13" height="13">
33
+ <path
34
+ d="M13.12.706a.982.982 0 0 0-1.391 0L6.907 5.517 2.087.696a.982.982 0 1 0-1.391 1.39l4.821 4.821L.696 11.73a.982.982 0 1 0 1.39 1.39l4.821-4.821 4.822 4.821a.982.982 0 1 0 1.39-1.39L8.298 6.908l4.821-4.822a.988.988 0 0 0 0-1.38Z"
35
+ />
36
+ </svg>
37
+ `;
38
+ }
39
+ };
40
+ te.styles = M`
41
+ svg {
42
+ display: block;
43
+ fill: var(--color-icon-button);
44
+ }
45
+ `;
46
+ te = dt([
47
+ F("maptiler-geocode-clear-icon")
48
+ ], te);
49
+ var pt = Object.getOwnPropertyDescriptor, ut = (t, e, i, o) => {
50
+ for (var r = o > 1 ? void 0 : o ? pt(e, i) : e, s = t.length - 1, a; s >= 0; s--)
51
+ (a = t[s]) && (r = a(r) || r);
52
+ return r;
53
+ };
54
+ let ie = class extends S {
55
+ render() {
56
+ return A`
57
+ <svg viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg">
58
+ <path
59
+ d="M15 0C6.705 0 0 6.705 0 15C0 23.295 6.705 30 15 30C23.295 30 30 23.295 30 15C30 6.705 23.295 0 15 0ZM22.5 20.385L20.385 22.5L15 17.115L9.615 22.5L7.5 20.385L12.885 15L7.5 9.615L9.615 7.5L15 12.885L20.385 7.5L22.5 9.615L17.115 15L22.5 20.385Z"
60
+ />
61
+ </svg>
62
+ `;
63
+ }
64
+ };
65
+ ie.styles = M`
66
+ svg {
67
+ display: block;
68
+ fill: #e15042;
69
+ }
70
+ `;
71
+ ie = ut([
72
+ F("maptiler-geocode-fail-icon")
73
+ ], ie);
74
+ var ft = Object.getOwnPropertyDescriptor, mt = (t, e, i, o) => {
75
+ for (var r = o > 1 ? void 0 : o ? ft(e, i) : e, s = t.length - 1, a; s >= 0; s--)
76
+ (a = t[s]) && (r = a(r) || r);
77
+ return r;
78
+ };
79
+ let se = class extends S {
80
+ render() {
81
+ return m`
82
+ <div>
83
+ <svg viewBox="0 0 18 18" width="24" height="24" class="loading-icon">
84
+ <path fill="#333" d="M4.4 4.4l.8.8c2.1-2.1 5.5-2.1 7.6 0l.8-.8c-2.5-2.5-6.7-2.5-9.2 0z" />
85
+ <path opacity=".1" d="M12.8 12.9c-2.1 2.1-5.5 2.1-7.6 0-2.1-2.1-2.1-5.5 0-7.7l-.8-.8c-2.5 2.5-2.5 6.7 0 9.2s6.6 2.5 9.2 0 2.5-6.6 0-9.2l-.8.8c2.2 2.1 2.2 5.6 0 7.7z" />
86
+ </svg>
87
+ </div>
88
+ `;
89
+ }
90
+ };
91
+ se.styles = M`
92
+ div {
93
+ position: absolute;
94
+ left: 50%;
95
+ top: 50%;
96
+ transform: translate(-50%, -50%);
97
+ pointer-events: none;
98
+
99
+ display: flex;
100
+ align-items: center;
101
+ }
102
+
103
+ .loading-icon {
104
+ animation: rotate 0.8s infinite cubic-bezier(0.45, 0.05, 0.55, 0.95);
105
+ }
106
+
107
+ @keyframes rotate {
108
+ from {
109
+ -webkit-transform: rotate(0);
110
+ transform: rotate(0);
111
+ }
112
+ to {
113
+ -webkit-transform: rotate(360deg);
114
+ transform: rotate(360deg);
115
+ }
116
+ }
117
+ `;
118
+ se = mt([
119
+ F("maptiler-geocode-loading-icon")
120
+ ], se);
121
+ var gt = Object.getOwnPropertyDescriptor, yt = (t, e, i, o) => {
122
+ for (var r = o > 1 ? void 0 : o ? gt(e, i) : e, s = t.length - 1, a; s >= 0; s--)
123
+ (a = t[s]) && (r = a(r) || r);
124
+ return r;
125
+ };
126
+ let re = class extends S {
127
+ render() {
128
+ return A`
129
+ <svg viewBox="0 0 60.006 21.412" width="14" height="20">
130
+ <path
131
+ d="M30.003-26.765C13.46-26.765 0-14.158 0 1.337c0 23.286 24.535 42.952 28.39 46.04.24.192.402.316.471.376.323.282.732.424 1.142.424.41 0 .82-.142 1.142-.424.068-.06.231-.183.471-.376 3.856-3.09 28.39-22.754 28.39-46.04 0-15.495-13.46-28.102-30.003-28.102Zm1.757 12.469c4.38 0 7.858 1.052 10.431 3.158 2.595 2.105 3.89 4.913 3.89 8.422 0 2.34-.53 4.362-1.593 6.063-1.063 1.702-3.086 3.616-6.063 5.742-2.042 1.51-3.337 2.659-3.89 3.446-.532.787-.8 1.82-.8 3.096v1.914h-8.449V15.18c0-2.041.434-3.815 1.306-5.325.872-1.51 2.467-3.118 4.785-4.82 2.233-1.594 3.7-2.89 4.402-3.889a5.582 5.582 0 0 0 1.087-3.35c0-1.382-.51-2.435-1.531-3.158-1.02-.723-2.45-1.087-4.28-1.087-3.19 0-6.826 1.047-10.91 3.131l-3.472-6.986c4.742-2.659 9.77-3.992 15.087-3.992Zm-1.88 37.324c1.765 0 3.124.472 4.08 1.408.98.936 1.47 2.276 1.47 4.02 0 1.68-.49 3.007-1.47 3.985-.977.957-2.336 1.435-4.08 1.435-1.787 0-3.171-.465-4.15-1.4-.978-.958-1.47-2.298-1.47-4.02 0-1.787.48-3.14 1.436-4.054.957-.915 2.355-1.374 4.184-1.374Z"
132
+ />
133
+ </svg>
134
+ `;
135
+ }
136
+ };
137
+ re.styles = M`
138
+ svg {
139
+ display: block;
140
+ fill: var(--color-icon-button);
141
+ }
142
+ `;
143
+ re = yt([
144
+ F("maptiler-geocode-reverse-geocoding-icon")
145
+ ], re);
146
+ var vt = Object.getOwnPropertyDescriptor, xt = (t, e, i, o) => {
147
+ for (var r = o > 1 ? void 0 : o ? vt(e, i) : e, s = t.length - 1, a; s >= 0; s--)
148
+ (a = t[s]) && (r = a(r) || r);
149
+ return r;
150
+ };
151
+ let oe = class extends S {
152
+ render() {
153
+ return A`
154
+ <svg
155
+ xmlns="http://www.w3.org/2000/svg"
156
+ width="13"
157
+ height="13"
158
+ viewBox="0 0 13 13"
159
+ >
160
+ <circle cx="4.789" cy="4.787" r="3.85" />
161
+ <path d="M12.063 12.063 7.635 7.635" />
162
+ </svg>
163
+ `;
164
+ }
165
+ };
166
+ oe.styles = M`
167
+ circle {
168
+ stroke-width: 1.875;
169
+ fill: none;
170
+ }
171
+
172
+ path {
173
+ stroke-width: 1.875;
174
+ stroke-linecap: round;
175
+ }
176
+
177
+ svg {
178
+ display: block;
179
+ stroke: var(--color-icon-button);
180
+ }
181
+ `;
182
+ oe = xt([
183
+ F("maptiler-geocode-search-icon")
184
+ ], oe);
185
+ function bt(t, e, i) {
186
+ const o = e[1], r = e[0], s = o - r;
187
+ return t === o && i ? t : ((t - r) % s + s) % s + r;
188
+ }
189
+ function Z(t) {
190
+ const e = [...t];
191
+ return e[2] < e[0] && (Math.abs((e[0] + e[2] + 360) / 2) > Math.abs((e[0] - 360 + e[2]) / 2) ? e[0] -= 360 : e[2] += 360), e;
192
+ }
193
+ let G;
194
+ async function wt(t, e, i) {
195
+ for (const o of e ?? [])
196
+ if (!(t && (o.minZoom != null && o.minZoom > t[0] || o.maxZoom != null && o.maxZoom < t[0]))) {
197
+ if (o.type === "fixed")
198
+ return o.coordinates.join(",");
199
+ if (o.type === "client-geolocation")
200
+ if (G && o.cachedLocationExpiry && G.time + o.cachedLocationExpiry > Date.now()) {
201
+ if (G.coords)
202
+ return G.coords;
203
+ } else {
204
+ let r;
205
+ try {
206
+ return r = await new Promise((s, a) => {
207
+ i.signal.addEventListener("abort", () => {
208
+ a(Error("aborted"));
209
+ }), navigator.geolocation.getCurrentPosition(
210
+ (f) => {
211
+ s([f.coords.longitude, f.coords.latitude].map((L) => L.toFixed(6)).join(","));
212
+ },
213
+ (f) => {
214
+ a(f);
215
+ },
216
+ o
217
+ );
218
+ }), r;
219
+ } catch {
220
+ } finally {
221
+ o.cachedLocationExpiry && (G = {
222
+ time: Date.now(),
223
+ coords: r
224
+ });
225
+ }
226
+ if (i.signal.aborted)
227
+ return;
228
+ }
229
+ if (o.type === "server-geolocation")
230
+ return "ip";
231
+ if (t && o.type === "map-center")
232
+ return t[1].toFixed(6) + "," + t[2].toFixed(6);
233
+ }
234
+ }
235
+ const kt = ".sprite-icon{align-self:center;justify-self:center;opacity:.75;background-repeat:no-repeat}li{text-align:left;cursor:default;display:grid;grid-template-columns:40px 1fr;color:var(--color-text);padding:8px 0;font-size:14px;line-height:18px;min-width:fit-content;outline:0}li:first-child{padding-top:10px}li:last-child{padding-bottom:10px}li.picked{background-color:#e7edff}li.picked .secondary{color:#96a4c7;padding-left:4px}li.picked .line2{color:#96a4c7}li.selected{background-color:#f3f6ff;animation:backAndForth 5s linear infinite}li.selected .primary{color:#2b8bfb}li.selected .secondary{color:#a2adc7;padding-left:4px}li.selected .line2{color:#a2adc7}li>img{align-self:center;justify-self:center;opacity:.75}.texts{padding:0 17px 0 0}.texts>*{white-space:nowrap;display:block;min-width:fit-content}.primary{font-weight:600}.secondary{color:#aeb6c7;padding-left:4px}.line2{color:#aeb6c7}@keyframes backAndForth{0%{transform:translate(0)}10%{transform:translate(0)}45%{transform:translate(calc(-100% + 270px))}55%{transform:translate(calc(-100% + 270px))}90%{transform:translate(0)}to{transform:translate(0)}}";
236
+ var _t = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, Se = (t) => {
237
+ throw TypeError(t);
238
+ }, _ = (t, e, i, o) => {
239
+ for (var r = o > 1 ? void 0 : o ? $t(e, i) : e, s = t.length - 1, a; s >= 0; s--)
240
+ (a = t[s]) && (r = (o ? a(e, i, r) : a(r)) || r);
241
+ return o && r && _t(e, i, r), r;
242
+ }, Fe = (t, e, i) => e.has(t) || Se("Cannot " + i), u = (t, e, i) => (Fe(t, e, "read from private field"), i ? i.call(t) : e.get(t)), Lt = (t, e, i) => e.has(t) ? Se("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), U = (t, e, i) => (Fe(t, e, "access private method"), i), p, N, z, g, Oe, Ce, de, ae;
243
+ const Te = typeof devicePixelRatio > "u" || devicePixelRatio > 1.25, Pe = Te ? "@2x" : "", P = Te ? 2 : 1;
244
+ let C, Ee, w = class extends S {
245
+ constructor() {
246
+ super(...arguments), Lt(this, p), this.itemStyle = "default", this.showPlaceType = "if-needed", this.missingIconsCache = /* @__PURE__ */ new Set(), this.iconsBaseUrl = "", this.index = 0;
247
+ }
248
+ willUpdate(t) {
249
+ t.has("feature") && u(this, p, N) && (this.index = u(this, p, N).length, U(this, p, de).call(this));
250
+ }
251
+ render() {
252
+ return m`
253
+ <li
254
+ tabindex="-1"
255
+ role="option"
256
+ aria-selected=${this.itemStyle === "selected"}
257
+ aria-checked=${this.itemStyle === "picked"}
258
+ class=${this.itemStyle}
259
+ @click=${() => this.dispatchEvent(new CustomEvent("select"))}
260
+ >
261
+ ${C && this.spriteIcon ? m`
262
+ <div
263
+ class="sprite-icon"
264
+ style=${Qe({
265
+ width: `${this.spriteIcon.width / P}px`,
266
+ height: `${this.spriteIcon.height / P}px`,
267
+ backgroundImage: `url(${this.iconsBaseUrl}sprite${Pe}.png)`,
268
+ backgroundPosition: `-${this.spriteIcon.x / P}px -${this.spriteIcon.y / P}px`,
269
+ backgroundSize: `${C.width / P}px ${C.height / P}px`
270
+ })}
271
+ title=${u(this, p, g)}
272
+ />
273
+ ` : this.imageUrl ? m` <img src=${this.imageUrl} alt=${this.category} title=${u(this, p, g)} @error=${U(this, p, Ce)} />` : this.feature?.address ? m` <img src=${this.iconsBaseUrl + "housenumber.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> ` : this.feature?.id.startsWith("road.") ? m` <img src=${this.iconsBaseUrl + "road.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> ` : this.feature?.id.startsWith("address.") ? m` <img src=${this.iconsBaseUrl + "street.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> ` : this.feature?.id.startsWith("postal_code.") ? m` <img src=${this.iconsBaseUrl + "postal_code.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> ` : this.feature?.id.startsWith("poi.") ? m` <img src=${this.iconsBaseUrl + "poi.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> ` : u(this, p, z) ? m` <img src=${this.iconsBaseUrl + "reverse.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> ` : m` <img src=${this.iconsBaseUrl + "area.svg"} alt=${u(this, p, g)} title=${u(this, p, g)} /> `}
274
+
275
+ <span class="texts">
276
+ <span>
277
+ <span class="primary"> ${u(this, p, z) ? this.feature?.place_name : this.feature?.place_name.replace(/,.*/, "")} </span>
278
+
279
+ ${this.showPlaceType === "always" || this.showPlaceType !== "never" && !this.feature?.address && !this.feature?.id.startsWith("road.") && !this.feature?.id.startsWith("address.") && !this.feature?.id.startsWith("postal_code.") && (!this.feature?.id.startsWith("poi.") || !this.imageUrl) && !u(this, p, z) ? m` <span class="secondary"> ${u(this, p, g)} </span> ` : ee}
280
+ </span>
281
+
282
+ <span class="line2"> ${u(this, p, z) ? this.feature?.text : this.feature?.place_name.replace(/[^,]*,?s*/, "")} </span>
283
+ </span>
284
+ </li>
285
+ `;
286
+ }
287
+ };
288
+ p = /* @__PURE__ */ new WeakSet();
289
+ N = function() {
290
+ return this.feature?.properties?.categories;
291
+ };
292
+ z = function() {
293
+ return this.feature?.place_type[0] === "reverse";
294
+ };
295
+ g = function() {
296
+ return this.feature?.properties?.categories?.join(", ") ?? this.feature?.place_type_name?.[0] ?? this.feature?.place_type[0];
297
+ };
298
+ Oe = function() {
299
+ Ee ??= fetch(`${this.iconsBaseUrl}sprite${Pe}.json`).then((t) => t.json()).then((t) => {
300
+ C = t;
301
+ }).catch(() => {
302
+ C = null;
303
+ });
304
+ };
305
+ Ce = function() {
306
+ this.imageUrl && this.missingIconsCache.add(this.imageUrl), U(this, p, de).call(this);
307
+ };
308
+ de = function() {
309
+ C !== void 0 ? U(this, p, ae).call(this) : (U(this, p, Oe).call(this), Ee?.then(() => {
310
+ U(this, p, ae).call(this);
311
+ }));
312
+ };
313
+ ae = function() {
314
+ do {
315
+ if (this.index--, this.category = u(this, p, N)?.[this.index], this.spriteIcon = this.category ? C?.icons[this.category] : void 0, this.spriteIcon)
316
+ break;
317
+ this.imageUrl = this.category ? this.iconsBaseUrl + this.category.replace(/ /g, "_") + ".svg" : void 0;
318
+ } while (this.index > -1 && (!this.imageUrl || this.missingIconsCache.has(this.imageUrl)));
319
+ };
320
+ w.styles = M`
321
+ ${he(kt)}
322
+ `;
323
+ _([
324
+ d({ type: Object })
325
+ ], w.prototype, "feature", 2);
326
+ _([
327
+ d({ type: String })
328
+ ], w.prototype, "itemStyle", 2);
329
+ _([
330
+ d({ type: String })
331
+ ], w.prototype, "showPlaceType", 2);
332
+ _([
333
+ d({ attribute: !1 })
334
+ ], w.prototype, "missingIconsCache", 2);
335
+ _([
336
+ d({ type: String })
337
+ ], w.prototype, "iconsBaseUrl", 2);
338
+ _([
339
+ b()
340
+ ], w.prototype, "category", 2);
341
+ _([
342
+ b()
343
+ ], w.prototype, "imageUrl", 2);
344
+ _([
345
+ b()
346
+ ], w.prototype, "spriteIcon", 2);
347
+ _([
348
+ b()
349
+ ], w.prototype, "index", 2);
350
+ w = _([
351
+ F("maptiler-geocoder-feature-item")
352
+ ], w);
353
+ const It = "form{font-family:Open Sans,Ubuntu,Helvetica Neue,Arial,Helvetica,sans-serif;position:relative;background-color:#fff;z-index:10;border-radius:4px;margin:0;transition:max-width .25s;box-shadow:0 2px 5px #33335926;--color-text: #444952;--color-icon-button: #444952;pointer-events:all}form,form *,form *:after,form *:before{box-sizing:border-box}form.can-collapse{max-width:29px}form.can-collapse input::placeholder{transition:opacity .25s;opacity:0}form{width:270px;max-width:270px}form:focus-within,form:hover{width:270px;max-width:270px}form input::placeholder,form:focus-within input::placeholder,form:hover input::placeholder{opacity:1}input{font:inherit;font-size:14px;flex-grow:1;min-height:29px;background-color:transparent;color:#444952;white-space:nowrap;overflow:hidden;border:0;margin:0;padding:0}input:focus{color:#444952;outline:0;outline:none;box-shadow:none}ul,div.error,div.no-results{background-color:#fff;border-radius:4px;left:0;list-style:none;margin:0;padding:0;position:absolute;width:100%;top:calc(100% + 6px);overflow:hidden}ul{font-size:14px;line-height:16px;box-shadow:0 5px 10px #33335926}div.error,div.no-results{font:inherit;line-height:18px;font-size:12px;display:flex;gap:16px}div.error{padding:16px;font-weight:600;color:#e25041;background-color:#fbeae8}div.error div{flex-grow:1}div.error maptiler-geocode-fail-icon{flex-shrink:0;width:20px;height:20px}div.error button{flex-shrink:0}div.error button maptiler-geocode-clear-icon{--color-icon-button: #e25041}div.error button:hover maptiler-geocode-clear-icon,div.error button:active maptiler-geocode-clear-icon{--color-icon-button: inherit}div.no-results{padding:14px 24px 14px 16px;font-weight:400;color:#6b7c93;box-shadow:0 5px 10px #33335926}div.no-results maptiler-geocode-fail-icon{margin-top:4px;flex-shrink:0;width:20px;height:20px}ul.options.open-on-top{top:auto;bottom:calc(100% + 6px)}button{padding:0;margin:0;border:0;background-color:transparent;height:auto;width:auto}button:hover{background-color:transparent}button:hover,button:active{--color-icon-button: #2b8bfb}.input-group{display:flex;align-items:stretch;gap:7px;padding-inline:8px;border-radius:4px;overflow:hidden}.input-group:focus-within{outline:#2b8bfb solid 2px}.search-button{flex-shrink:0}.clear-button-container{display:flex;display:none;position:relative;align-items:stretch}.clear-button-container.displayable{display:flex;flex-shrink:0}:host(.maptiler-geocoder):not(:empty){box-shadow:none}:host(.maptiler-geocoder) .input-group{border:white solid 2px}:host(.maptiler-geocoder) .input-group:focus-within{border:#2b8bfb solid 2px;outline:0;outline:none}:host(.maptiler-geocoder) form.can-collapse{max-width:33px}:host(.maptiler-geocoder) form,:host(.maptiler-geocoder) form:focus-within,:host(.maptiler-geocoder) form:hover{width:270px;max-width:270px}:host(.leaflet-geocoder) .input-group{border:white solid 1px}:host(.leaflet-geocoder) form.can-collapse{max-width:30px}";
354
+ var Mt = Object.defineProperty, St = Object.getOwnPropertyDescriptor, Ue = (t) => {
355
+ throw TypeError(t);
356
+ }, c = (t, e, i, o) => {
357
+ for (var r = o > 1 ? void 0 : o ? St(e, i) : e, s = t.length - 1, a; s >= 0; s--)
358
+ (a = t[s]) && (r = (o ? a(e, i, r) : a(r)) || r);
359
+ return o && r && Mt(e, i, r), r;
360
+ }, pe = (t, e, i) => e.has(t) || Ue("Cannot " + i), x = (t, e, i) => (pe(t, e, "read from private field"), i ? i.call(t) : e.get(t)), E = (t, e, i) => e.has(t) ? Ue("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), W = (t, e, i, o) => (pe(t, e, "write to private field"), e.set(t, i), i), h = (t, e, i) => (pe(t, e, "access private method"), i), Q, q, j, ne, R, n, K, Be, Ge, ue, v, fe, Y, me, ge, I, ye, H, ze, le, je, Re, Ae, De, Ve;
361
+ let l = class extends S {
362
+ constructor() {
363
+ super(...arguments), E(this, n), this.clearListOnPick = !1, this.clearOnBlur = !1, this.collapsed = !1, this.excludeTypes = !1, this.exhaustiveReverseGeocoding = !1, this.fetchFullGeometryOnPick = !1, this.keepListOpen = !1, this.openListOnTop = !1, this.reverseActive = !1, this.searchValue = "", this.selectedItemIndex = -1, this.cachedFeatures = [], this.lastSearchUrl = "", this.focused = !1, this.focusedDelayed = !1, E(this, Q, !1), E(this, q, !1), E(this, j), E(this, ne, /* @__PURE__ */ new Set()), E(this, R);
364
+ }
365
+ firstUpdated() {
366
+ W(this, Q, !0);
367
+ }
368
+ /**
369
+ * Set the options of this instance.
370
+ *
371
+ * @param options options to set
372
+ */
373
+ setOptions(t) {
374
+ const e = { ...t };
375
+ for (const i of Object.keys(e))
376
+ Ft.includes(i) || delete e[i];
377
+ Object.assign(this, e);
378
+ }
379
+ /**
380
+ * Set the content of search input box.
381
+ *
382
+ * @param value text to set
383
+ */
384
+ setQuery(t) {
385
+ h(this, n, ge).call(this, t), h(this, n, me).call(this);
386
+ }
387
+ /**
388
+ * Set the content of search input box and immediately submit it.
389
+ *
390
+ * @param value text to set and submit
391
+ */
392
+ submitQuery(t) {
393
+ h(this, n, ye).call(this, t);
394
+ }
395
+ /**
396
+ * Clear search result list.
397
+ */
398
+ clearList() {
399
+ h(this, n, I).call(this), this.picked = void 0, this.selectedItemIndex = -1;
400
+ }
401
+ /**
402
+ * Focus the search input box.
403
+ *
404
+ * @param options [FocusOptions](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus#options)
405
+ */
406
+ focus(t) {
407
+ this.input.focus(t);
408
+ }
409
+ /**
410
+ * Blur the search input box.
411
+ */
412
+ blur() {
413
+ this.input.blur();
414
+ }
415
+ addEventListener(t, e, i) {
416
+ super.addEventListener(t, e, i);
417
+ }
418
+ removeEventListener(t, e, i) {
419
+ super.removeEventListener(t, e, i);
420
+ }
421
+ /** @internal */
422
+ handleMapChange(t) {
423
+ W(this, R, t);
424
+ }
425
+ /** @internal */
426
+ handleMapClick(t) {
427
+ this.reverseActive && h(this, n, ze).call(this, t);
428
+ }
429
+ willUpdate(t) {
430
+ t.has("error") && this.error && console.error("[MapTilerGeocodingControl] Error:", this.error), t.has("enableReverse") && (this.reverseActive = this.enableReverse === "always"), ["picked"].some((e) => t.has(e)) && this.picked && (this.clearListOnPick && h(this, n, I).call(this), this.selectedItemIndex = -1), ["searchValue", "minLength"].some((e) => t.has(e)) && x(this, n, ue) && (h(this, n, I).call(this), this.error = void 0), ["focused"].some((e) => t.has(e)) && setTimeout(() => {
431
+ this.focusedDelayed = this.focused, this.clearOnBlur && !this.focused && (this.searchValue = "");
432
+ }, 100), ["selectFirst", "listFeatures", "selectedItemIndex", "picked"].some((e) => t.has(e)) && this.selectFirst !== !1 && this.listFeatures?.length && this.selectedItemIndex == -1 && !this.picked && (this.selectedItemIndex = 0), ["listFeatures", "selectedItemIndex"].some((e) => t.has(e)) && h(this, n, v).call(this, "select", { feature: x(this, n, K) }), ["picked"].some((e) => t.has(e)) && this.picked && this.picked.id !== t.get("picked")?.id && (this.fetchFullGeometryOnPick && !this.picked.address && this.picked.geometry.type === "Point" && this.picked.place_type[0] !== "reverse" ? h(this, n, H).call(this, this.picked.id, { byId: !0 }) : Promise.resolve()).then(
433
+ () => {
434
+ h(this, n, v).call(this, "pick", { feature: this.picked });
435
+ },
436
+ (e) => {
437
+ e && typeof e == "object" && "name" in e && e.name === "AbortError" || (this.error = e, h(this, n, v).call(this, "pick", { feature: this.picked }));
438
+ }
439
+ ), ["listFeatures", "focusedDelayed"].some((e) => t.has(e)) && (x(this, n, Be) ? (h(this, n, v).call(this, "featuresshow"), W(this, q, !0)) : x(this, q) && h(this, n, v).call(this, "featureshide")), ["reverseActive"].some((e) => t.has(e)) && h(this, n, v).call(this, "reversetoggle", { reverse: this.reverseActive });
440
+ }
441
+ render() {
442
+ return m`
443
+ <form @submit=${h(this, n, fe)} class=${V({ "can-collapse": this.collapsed && this.searchValue === "" })}>
444
+ <div class="input-group">
445
+ <button
446
+ class="search-button"
447
+ type="button"
448
+ @click=${() => {
449
+ this.input.focus();
450
+ }}
451
+ >
452
+ <maptiler-geocode-search-icon></maptiler-geocode-search-icon>
453
+ </button>
454
+
455
+ <input
456
+ .value=${this.searchValue}
457
+ @focus=${() => this.focused = !0}
458
+ @blur=${() => this.focused = !1}
459
+ @click=${() => this.focused = !0}
460
+ @keydown=${h(this, n, le)}
461
+ @input=${h(this, n, je)}
462
+ @change=${() => this.picked = void 0}
463
+ placeholder=${this.placeholder ?? "Search"}
464
+ aria-label=${this.placeholder ?? "Search"}
465
+ />
466
+
467
+ <div class="clear-button-container ${V({ displayable: this.searchValue !== "" })}">
468
+ ${x(this, n, Ge) ? m`<maptiler-geocode-loading-icon></maptiler-geocode-loading-icon>` : m`
469
+ <button type="button" @click=${h(this, n, Ve)} title=${this.clearButtonTitle ?? "clear"}>
470
+ <maptiler-geocode-clear-icon></maptiler-geocode-clear-icon>
471
+ </button>
472
+ `}
473
+ </div>
474
+
475
+ ${this.enableReverse === "button" ? m`
476
+ <button
477
+ type="button"
478
+ class=${V({ active: this.reverseActive })}
479
+ title=${this.reverseButtonTitle ?? "toggle reverse geocoding"}
480
+ @click=${() => this.reverseActive = !this.reverseActive}
481
+ >
482
+ <maptiler-geocode-reverse-geocoding-icon></maptiler-geocode-reverse-geocoding-icon>
483
+ </button>
484
+ ` : ee}
485
+
486
+ <!-- <slot /> -->
487
+ </div>
488
+
489
+ ${this.error ? m`
490
+ <div class="error">
491
+ <maptiler-geocode-fail-icon></maptiler-geocode-fail-icon>
492
+
493
+ <div>${this.errorMessage ?? "Something went wrong…"}</div>
494
+
495
+ <button @click=${() => this.error = void 0}>
496
+ <maptiler-geocode-clear-icon></maptiler-geocode-clear-icon>
497
+ </button>
498
+ </div>
499
+ ` : !this.focusedDelayed && !this.keepListOpen || this.listFeatures === void 0 ? ee : this.listFeatures.length === 0 ? m`
500
+ <div class="no-results">
501
+ <maptiler-geocode-fail-icon></maptiler-geocode-fail-icon>
502
+
503
+ <div>
504
+ ${this.noResultsMessage ?? "Oops! Looks like you're trying to predict something that's not quite right. We can't seem to find what you're looking for. Maybe try double-checking your spelling or try a different search term. Keep on typing - we'll do our best to get you where you need to go!"}
505
+ </div>
506
+ </div>
507
+ ` : m`
508
+ <ul class="options ${V({ "open-on-top": this.openListOnTop })}" @mouseleave=${h(this, n, De)} @keydown=${h(this, n, le)} role="listbox">
509
+ ${Ne(
510
+ this.listFeatures,
511
+ (t) => t.id + (t.address ? "," + t.address : ""),
512
+ (t, e) => m`
513
+ <maptiler-geocoder-feature-item
514
+ .feature=${t}
515
+ .showPlaceType=${this.showPlaceType ?? "if-needed"}
516
+ itemStyle=${this.selectedItemIndex === e ? "selected" : this.picked?.id === t.id ? "picked" : "default"}
517
+ @mouseenter=${() => {
518
+ h(this, n, Ae).call(this, e);
519
+ }}
520
+ @select=${() => {
521
+ h(this, n, Re).call(this, t);
522
+ }}
523
+ .missingIconsCache=${x(this, ne)}
524
+ .iconsBaseUrl=${this.iconsBaseUrl ?? "https://cdn.maptiler.com/maptiler-geocoding-control/v3.0.0-rc.4/icons/"}
525
+ >
526
+ ${t.place_name}
527
+ </maptiler-geocoder-feature-item>
528
+ `
529
+ )}
530
+ </ul>
531
+ `}
532
+ </form>
533
+ `;
534
+ }
535
+ };
536
+ Q = /* @__PURE__ */ new WeakMap();
537
+ q = /* @__PURE__ */ new WeakMap();
538
+ j = /* @__PURE__ */ new WeakMap();
539
+ ne = /* @__PURE__ */ new WeakMap();
540
+ R = /* @__PURE__ */ new WeakMap();
541
+ n = /* @__PURE__ */ new WeakSet();
542
+ K = function() {
543
+ return this.listFeatures?.[this.selectedItemIndex];
544
+ };
545
+ Be = function() {
546
+ return !!this.listFeatures?.length && (this.focusedDelayed || this.keepListOpen);
547
+ };
548
+ Ge = function() {
549
+ return this.abortController !== void 0;
550
+ };
551
+ ue = function() {
552
+ return this.searchValue.length < (this.minLength ?? 2);
553
+ };
554
+ v = function(t, ...[e]) {
555
+ x(this, Q) && this.dispatchEvent(
556
+ new CustomEvent(t, {
557
+ bubbles: !0,
558
+ composed: !0,
559
+ detail: e
560
+ })
561
+ );
562
+ };
563
+ fe = function(t) {
564
+ t?.preventDefault(), this.focused = !1, clearTimeout(x(this, j)), this.selectedItemIndex > -1 && this.listFeatures ? (this.picked = this.listFeatures[this.selectedItemIndex], this.searchValue = this.picked.place_type[0] === "reverse" ? this.picked.place_name : this.picked.place_name.replace(/,.*/, ""), this.error = void 0, this.selectedItemIndex = -1) : this.searchValue && h(this, n, H).call(this, this.searchValue, { exact: !0 }).then(() => {
565
+ this.picked = void 0;
566
+ }).catch((e) => this.error = e);
567
+ };
568
+ Y = function(t) {
569
+ try {
570
+ return Ze(t, 6);
571
+ } catch {
572
+ return !1;
573
+ }
574
+ };
575
+ me = function() {
576
+ setTimeout(() => {
577
+ this.input.focus(), this.focused = !0, this.input.select();
578
+ });
579
+ };
580
+ ge = function(t) {
581
+ if (this.searchValue = t, h(this, n, v).call(this, "querychange", { query: this.searchValue, reverseCoords: h(this, n, Y).call(this, t) }), this.error = void 0, this.picked = void 0, this.showResultsWhileTyping !== !1) {
582
+ if (clearTimeout(x(this, j)), x(this, n, ue))
583
+ return;
584
+ const e = this.searchValue;
585
+ W(this, j, window.setTimeout(() => {
586
+ h(this, n, H).call(this, e).catch((i) => this.error = i);
587
+ }, this.debounceSearch ?? 200));
588
+ } else
589
+ h(this, n, I).call(this);
590
+ };
591
+ I = function() {
592
+ this.listFeatures !== void 0 && (this.listFeatures = void 0, h(this, n, v).call(this, "featuresclear"));
593
+ };
594
+ ye = function(t) {
595
+ this.searchValue = t, h(this, n, v).call(this, "querychange", { query: this.searchValue, reverseCoords: h(this, n, Y).call(this, t) }), this.selectedItemIndex = -1, h(this, n, fe).call(this);
596
+ };
597
+ H = async function(t, { byId: e = !1, exact: i = !1 } = {}) {
598
+ this.error = void 0, this.abortController?.abort();
599
+ const o = new AbortController();
600
+ this.abortController = o;
601
+ try {
602
+ const r = this.apiUrl ?? "https://api.maptiler.com/geocoding", s = h(this, n, Y).call(this, t), a = new URL(r + "/" + encodeURIComponent(s ? `${s.decimalLongitude},${s.decimalLatitude}` : t) + ".json"), f = a.searchParams;
603
+ this.language !== void 0 && f.set("language", Array.isArray(this.language) ? this.language.join(",") : this.language ?? "");
604
+ const [L] = x(this, R) ?? [void 0];
605
+ let k = (!s || this.reverseGeocodingTypes === void 0 ? this.types : this.reverseGeocodingTypes)?.map(
606
+ (y) => typeof y == "string" ? y : L === void 0 || (y[0] ?? 0) <= L && L < (y[1] ?? 1 / 0) ? y[2] : void 0
607
+ ).filter((y) => y !== void 0);
608
+ k && (k = [...new Set(k)], f.set("types", k.join(",")));
609
+ const T = !s || this.reverseGeocodingExcludeTypes === void 0 ? this.excludeTypes : this.reverseGeocodingExcludeTypes;
610
+ if (T && f.set("excludeTypes", String(T)), this.bbox && f.set("bbox", this.bbox.map((y) => y.toFixed(6)).join(",")), this.country && f.set("country", Array.isArray(this.country) ? this.country.join(",") : this.country), this.worldview && f.set("worldview", this.worldview), !e && !s) {
611
+ const y = this.proximity ?? [{ type: "server-geolocation" }], xe = await wt(x(this, R), y, o);
612
+ xe && f.set("proximity", xe), (i || this.showResultsWhileTyping === !1) && f.set("autocomplete", "false"), f.set("fuzzyMatch", String(this.fuzzyMatch !== !1));
613
+ }
614
+ const ve = this.limit ?? 5, J = this.reverseGeocodingLimit ?? ve;
615
+ J > 1 && k?.length !== 1 && console.warn("[MapTilerGeocodingControl] Warning: For reverse geocoding when limit > 1 then types must contain single value."), s ? (J === 1 || this.exhaustiveReverseGeocoding || k?.length === 1) && f.set("limit", String(J)) : f.set("limit", String(ve)), this.apiKey && f.set("key", this.apiKey), this.adjustUrl?.(a);
616
+ const We = a.searchParams.get("types") === "" && a.searchParams.get("excludeTypes") !== "true", D = a.toString();
617
+ if (D === this.lastSearchUrl) {
618
+ e ? (this.clearListOnPick && h(this, n, I).call(this), this.picked = this.cachedFeatures[0]) : (this.listFeatures = this.cachedFeatures, h(this, n, v).call(this, "featureslisted", { features: this.listFeatures }), this.listFeatures[this.selectedItemIndex]?.id !== x(this, n, K)?.id && (this.selectedItemIndex = -1));
619
+ return;
620
+ }
621
+ h(this, n, v).call(this, "request", { urlObj: a }), this.lastSearchUrl = D;
622
+ let B;
623
+ if (We)
624
+ B = { type: "FeatureCollection", features: [] };
625
+ else {
626
+ const y = await fetch(D, {
627
+ signal: o.signal,
628
+ ...this.fetchParameters
629
+ });
630
+ if (!y.ok)
631
+ throw new Error(await y.text());
632
+ B = await y.json();
633
+ }
634
+ h(this, n, v).call(this, "response", { url: D, featureCollection: B }), e ? (this.clearListOnPick && h(this, n, I).call(this), this.picked = B.features[0], this.cachedFeatures = [this.picked]) : (this.listFeatures = B.features.filter(this.filter ?? (() => !0)), s && this.listFeatures.unshift({
635
+ type: "Feature",
636
+ properties: {},
637
+ /* eslint-disable @typescript-eslint/restrict-template-expressions */
638
+ id: `reverse_${s.decimalLongitude}_${s.decimalLatitude}`,
639
+ text: `${s.decimalLatitude}, ${s.decimalLongitude}`,
640
+ place_name: s.toCoordinateFormat("DMS"),
641
+ /* eslint-enable @typescript-eslint/restrict-template-expressions */
642
+ place_type: ["reverse"],
643
+ place_type_name: ["reverse"],
644
+ center: [s.decimalLongitude, s.decimalLatitude],
645
+ bbox: [s.decimalLongitude, s.decimalLatitude, s.decimalLongitude, s.decimalLatitude],
646
+ geometry: {
647
+ type: "Point",
648
+ coordinates: [s.decimalLongitude, s.decimalLatitude]
649
+ }
650
+ }), h(this, n, v).call(this, "featureslisted", { features: this.listFeatures }), this.cachedFeatures = this.listFeatures, this.listFeatures[this.selectedItemIndex]?.id !== x(this, n, K)?.id && (this.selectedItemIndex = -1), s && this.input.focus());
651
+ } catch (r) {
652
+ if (r && typeof r == "object" && "name" in r && r.name === "AbortError")
653
+ return;
654
+ throw r;
655
+ } finally {
656
+ o === this.abortController && (this.abortController = void 0);
657
+ }
658
+ };
659
+ ze = function(t) {
660
+ this.reverseActive = this.enableReverse === "always", h(this, n, I).call(this), this.picked = void 0, h(this, n, ye).call(this, `${t[1].toFixed(6)}, ${bt(t[0], [-180, 180], !0).toFixed(6)}`), h(this, n, me).call(this);
661
+ };
662
+ le = function(t) {
663
+ if (!this.listFeatures)
664
+ return;
665
+ const e = t.key === "ArrowDown" ? 1 : t.key === "ArrowUp" ? -1 : 0;
666
+ e && (this.input.focus(), this.focused = !0, t.preventDefault(), this.picked && this.selectedItemIndex === -1 && (this.selectedItemIndex = this.listFeatures.findIndex((i) => i.id === this.picked?.id)), this.selectedItemIndex === (this.picked || this.selectFirst !== !1 ? 0 : -1) && e === -1 && (this.selectedItemIndex = this.listFeatures.length), this.selectedItemIndex += e, this.selectedItemIndex >= this.listFeatures.length && (this.selectedItemIndex = -1), this.selectedItemIndex < 0 && (this.picked || this.selectFirst !== !1) && (this.selectedItemIndex = 0));
667
+ };
668
+ je = function(t) {
669
+ h(this, n, ge).call(this, t.target.value);
670
+ };
671
+ Re = function(t) {
672
+ (!this.picked || this.picked.id !== t.id) && (this.picked = t, this.searchValue = t.place_name);
673
+ };
674
+ Ae = function(t) {
675
+ this.selectedItemIndex = t;
676
+ };
677
+ De = function() {
678
+ (!this.selectFirst || this.picked) && (this.selectedItemIndex = -1);
679
+ };
680
+ Ve = function() {
681
+ this.searchValue = "", h(this, n, v).call(this, "queryclear"), this.picked = void 0, this.input.focus();
682
+ };
683
+ l.styles = M`
684
+ ${he(It)}
685
+ `;
686
+ c([
687
+ d({ attribute: !1 })
688
+ ], l.prototype, "adjustUrl", 2);
689
+ c([
690
+ d({ type: String })
691
+ ], l.prototype, "apiKey", 2);
692
+ c([
693
+ d({ type: String })
694
+ ], l.prototype, "apiUrl", 2);
695
+ c([
696
+ d({ type: Array })
697
+ ], l.prototype, "bbox", 2);
698
+ c([
699
+ d({ type: String })
700
+ ], l.prototype, "clearButtonTitle", 2);
701
+ c([
702
+ d({ type: Boolean })
703
+ ], l.prototype, "clearListOnPick", 2);
704
+ c([
705
+ d({ type: Boolean })
706
+ ], l.prototype, "clearOnBlur", 2);
707
+ c([
708
+ d({ type: Boolean })
709
+ ], l.prototype, "collapsed", 2);
710
+ c([
711
+ d({ attribute: !1 })
712
+ ], l.prototype, "country", 2);
713
+ c([
714
+ d({ type: Number })
715
+ ], l.prototype, "debounceSearch", 2);
716
+ c([
717
+ d({ type: String })
718
+ ], l.prototype, "enableReverse", 2);
719
+ c([
720
+ d({ type: String })
721
+ ], l.prototype, "errorMessage", 2);
722
+ c([
723
+ d({ type: Boolean })
724
+ ], l.prototype, "excludeTypes", 2);
725
+ c([
726
+ d({ type: Boolean })
727
+ ], l.prototype, "exhaustiveReverseGeocoding", 2);
728
+ c([
729
+ d({ type: Boolean })
730
+ ], l.prototype, "fetchFullGeometryOnPick", 2);
731
+ c([
732
+ d({ type: Object })
733
+ ], l.prototype, "fetchParameters", 2);
734
+ c([
735
+ d({ attribute: !1 })
736
+ ], l.prototype, "filter", 2);
737
+ c([
738
+ d({ type: Object })
739
+ ], l.prototype, "fuzzyMatch", 2);
740
+ c([
741
+ d({ type: String })
742
+ ], l.prototype, "iconsBaseUrl", 2);
743
+ c([
744
+ d({ type: Boolean })
745
+ ], l.prototype, "keepListOpen", 2);
746
+ c([
747
+ d({ attribute: !1 })
748
+ ], l.prototype, "language", 2);
749
+ c([
750
+ d({ type: Number })
751
+ ], l.prototype, "limit", 2);
752
+ c([
753
+ d({ type: Number })
754
+ ], l.prototype, "minLength", 2);
755
+ c([
756
+ d({ type: String })
757
+ ], l.prototype, "noResultsMessage", 2);
758
+ c([
759
+ d({ type: Boolean })
760
+ ], l.prototype, "openListOnTop", 2);
761
+ c([
762
+ d({ type: String })
763
+ ], l.prototype, "placeholder", 2);
764
+ c([
765
+ d({ type: Array })
766
+ ], l.prototype, "proximity", 2);
767
+ c([
768
+ d({ type: Boolean })
769
+ ], l.prototype, "reverseActive", 2);
770
+ c([
771
+ d({ type: String })
772
+ ], l.prototype, "reverseButtonTitle", 2);
773
+ c([
774
+ d({ type: Object })
775
+ ], l.prototype, "reverseGeocodingExcludeTypes", 2);
776
+ c([
777
+ d({ type: Number })
778
+ ], l.prototype, "reverseGeocodingLimit", 2);
779
+ c([
780
+ d({ type: Array })
781
+ ], l.prototype, "reverseGeocodingTypes", 2);
782
+ c([
783
+ d({ type: Object })
784
+ ], l.prototype, "selectFirst", 2);
785
+ c([
786
+ d({ type: String })
787
+ ], l.prototype, "showPlaceType", 2);
788
+ c([
789
+ d({ type: Object })
790
+ ], l.prototype, "showResultsWhileTyping", 2);
791
+ c([
792
+ d({ type: Array })
793
+ ], l.prototype, "types", 2);
794
+ c([
795
+ d({ type: String })
796
+ ], l.prototype, "worldview", 2);
797
+ c([
798
+ qe("input")
799
+ ], l.prototype, "input", 2);
800
+ c([
801
+ b()
802
+ ], l.prototype, "searchValue", 2);
803
+ c([
804
+ b()
805
+ ], l.prototype, "listFeatures", 2);
806
+ c([
807
+ b()
808
+ ], l.prototype, "selectedItemIndex", 2);
809
+ c([
810
+ b()
811
+ ], l.prototype, "picked", 2);
812
+ c([
813
+ b()
814
+ ], l.prototype, "cachedFeatures", 2);
815
+ c([
816
+ b()
817
+ ], l.prototype, "lastSearchUrl", 2);
818
+ c([
819
+ b()
820
+ ], l.prototype, "error", 2);
821
+ c([
822
+ b()
823
+ ], l.prototype, "abortController", 2);
824
+ c([
825
+ b()
826
+ ], l.prototype, "focused", 2);
827
+ c([
828
+ b()
829
+ ], l.prototype, "focusedDelayed", 2);
830
+ l = c([
831
+ F("maptiler-geocoder")
832
+ ], l);
833
+ const Ft = [
834
+ "adjustUrl",
835
+ "apiKey",
836
+ "apiUrl",
837
+ "bbox",
838
+ "clearButtonTitle",
839
+ "clearListOnPick",
840
+ "clearOnBlur",
841
+ "collapsed",
842
+ "country",
843
+ "debounceSearch",
844
+ "enableReverse",
845
+ "errorMessage",
846
+ "excludeTypes",
847
+ "reverseGeocodingExcludeTypes",
848
+ "exhaustiveReverseGeocoding",
849
+ "fetchParameters",
850
+ "fetchFullGeometryOnPick",
851
+ "filter",
852
+ "fuzzyMatch",
853
+ "iconsBaseUrl",
854
+ "keepListOpen",
855
+ "language",
856
+ "limit",
857
+ "reverseGeocodingLimit",
858
+ "minLength",
859
+ "noResultsMessage",
860
+ "openListOnTop",
861
+ "placeholder",
862
+ "proximity",
863
+ "reverseActive",
864
+ "reverseButtonTitle",
865
+ "selectFirst",
866
+ "showPlaceType",
867
+ "showResultsWhileTyping",
868
+ "types",
869
+ "reverseGeocodingTypes",
870
+ "worldview"
871
+ ], Ot = "svg{display:block;fill:var(--maptiler-geocode-marker-fill, #3170fe);stroke:var(--maptiler-geocode-marker-stroke, #3170fe);height:30px}:host(.marker-selected){z-index:2}:host(.marker-selected) svg path{fill:var(--maptiler-geocode-marker-selected-fill, #98b7ff);stroke:var(--maptiler-geocode-marker-selected-stroke, #3170fe)}:host(.marker-reverse) svg path{fill:var(--maptiler-geocode-marker-reverse-fill, silver);stroke:var(--maptiler-geocode-marker-reverse-stroke, gray)}:host(.marker-interactive){cursor:pointer!important}:host(.marker-fuzzy) svg path{fill:var(--maptiler-geocode-marker-fuzzy-fill, silver);stroke:var(--maptiler-geocode-marker-fuzzy-stroke, gray)}:host(.marker-fuzzy.marker-selected) svg path{fill:var(--maptiler-geocode-marker-selected-fuzzy-fill, #ddd);stroke:var(--maptiler-geocode-marker-selected-fuzzy-stroke, silver)}";
872
+ var Ct = Object.getOwnPropertyDescriptor, Tt = (t, e, i, o) => {
873
+ for (var r = o > 1 ? void 0 : o ? Ct(e, i) : e, s = t.length - 1, a; s >= 0; s--)
874
+ (a = t[s]) && (r = a(r) || r);
875
+ return r;
876
+ };
877
+ let ce = class extends S {
878
+ render() {
879
+ return A`
880
+ <svg
881
+ viewBox="0 0 70 85"
882
+ fill="none"
883
+ class:in-map={displayIn !== "list"}
884
+ >
885
+ <path
886
+ stroke-width="4"
887
+ d="M 5,33.103579 C 5,17.607779 18.457,5 35,5 C 51.543,5 65,17.607779 65,33.103579 C 65,56.388679 40.4668,76.048179 36.6112,79.137779 C 36.3714,79.329879 36.2116,79.457979 36.1427,79.518879 C 35.8203,79.800879 35.4102,79.942779 35,79.942779 C 34.5899,79.942779 34.1797,79.800879 33.8575,79.518879 C 33.7886,79.457979 33.6289,79.330079 33.3893,79.138079 C 29.5346,76.049279 5,56.389379 5,33.103579 Z M 35.0001,49.386379 C 43.1917,49.386379 49.8323,42.646079 49.8323,34.331379 C 49.8323,26.016779 43.1917,19.276479 35.0001,19.276479 C 26.8085,19.276479 20.1679,26.016779 20.1679,34.331379 C 20.1679,42.646079 26.8085,49.386379 35.0001,49.386379 Z"
888
+ />
889
+ </svg>
890
+ `;
891
+ }
892
+ };
893
+ ce.styles = M`
894
+ ${he(Ot)}
895
+ `;
896
+ ce = Tt([
897
+ F("maptiler-geocode-marker")
898
+ ], ce);
899
+ function Pt(t) {
900
+ const e = st(
901
+ Le([
902
+ ot([
903
+ [
904
+ [180, 90],
905
+ [-180, 90],
906
+ [-180, -90],
907
+ [180, -90],
908
+ [180, 90]
909
+ ]
910
+ ]),
911
+ t
912
+ ])
913
+ );
914
+ if (!e)
915
+ return;
916
+ e.properties = { isMask: !0 };
917
+ const i = Z($e(t)), o = (i[2] - i[0]) / 360 / 1e3, r = i[0] < -180, s = i[2] > 180, a = rt(t);
918
+ if (a.features.length > 1 && (r || s))
919
+ for (const f of a.features) {
920
+ const L = Z($e(f));
921
+ if (s && L[0] < -180 + o)
922
+ for (const k of f.geometry.coordinates)
923
+ for (const T of k)
924
+ T[0] += 360 - o;
925
+ if (r && L[2] > 180 - o)
926
+ for (const k of f.geometry.coordinates)
927
+ for (const T of k)
928
+ T[0] -= 360 - o;
929
+ }
930
+ return Le([a.features.length < 2 ? t : at(a) ?? t, e]);
931
+ }
932
+ const Et = {
933
+ continental_marine: 4,
934
+ country: 4,
935
+ major_landform: 8,
936
+ region: 5,
937
+ subregion: 6,
938
+ county: 7,
939
+ joint_municipality: 8,
940
+ joint_submunicipality: 9,
941
+ municipality: 10,
942
+ municipal_district: 11,
943
+ locality: 12,
944
+ neighbourhood: 13,
945
+ place: 14,
946
+ postal_code: 14,
947
+ road: 16,
948
+ poi: 17,
949
+ address: 18,
950
+ "poi.peak": 15,
951
+ "poi.shop": 18,
952
+ "poi.cafe": 18,
953
+ "poi.restaurant": 18,
954
+ "poi.aerodrome": 13
955
+ // TODO add many more
956
+ }, Ut = (t) => (e) => {
957
+ const i = t.iconsBaseUrl ?? "https://cdn.maptiler.com/maptiler-geocoding-control/v3.0.0-rc.4/icons/", o = e.getProperties(), r = e.getGeometry()?.getType(), s = o.isMask ? 0 : r === "LineString" || r === "MultiLineString" ? 3 : 2;
958
+ return new lt({
959
+ stroke: o.isMask ? void 0 : new Me({
960
+ color: "#3170fe",
961
+ lineDash: [s, s],
962
+ width: s,
963
+ lineCap: "butt"
964
+ }),
965
+ fill: o.isMask ? new Ie({
966
+ color: "#00000020"
967
+ }) : void 0,
968
+ image: new nt({
969
+ src: `${i}marker_${o.isReverse ? "reverse" : o.isSelected ? "selected" : "unselected"}.svg`,
970
+ anchor: [0.5, 1]
971
+ }),
972
+ zIndex: o.isSelected ? 2 : o.isReverse ? 0 : 1,
973
+ text: (o.isSelected || o.isMouseOver) && o.tooltip ? new ct({
974
+ backgroundFill: new Ie({ color: "white" }),
975
+ text: o.tooltip,
976
+ offsetY: -40,
977
+ backgroundStroke: new Me({
978
+ color: "white",
979
+ lineJoin: "round",
980
+ width: 3
981
+ }),
982
+ padding: [2, 0, 0, 2]
983
+ }) : void 0
984
+ });
985
+ }, O = "EPSG:4326";
986
+ class oi extends Ke {
987
+ #t;
988
+ #e;
989
+ #r;
990
+ constructor(e = {}) {
991
+ const i = document.createElement("div");
992
+ super({
993
+ element: i,
994
+ ...e
995
+ }), this.#t = e, this.#r = document.createElement("maptiler-geocoder"), this.#r.classList.add("openlayers-geocoder"), this.#b(), i.classList.add("openlayers-ctrl-geocoder"), i.style.zIndex = "3", i.appendChild(this.#r);
996
+ }
997
+ /** @internal Not to be called directly */
998
+ setMap(e) {
999
+ super.setMap(e), this.#e && this.#e !== e && (this.#I(), this.#P(), this.#e = void 0), e && (this.#e = e, this.#L(), this.#T());
1000
+ }
1001
+ getOptions() {
1002
+ return { ...this.#t };
1003
+ }
1004
+ setOptions(e) {
1005
+ Object.assign(this.#t, e), this.#b();
1006
+ }
1007
+ setQuery(e) {
1008
+ this.#r.setQuery(e);
1009
+ }
1010
+ submitQuery(e) {
1011
+ this.#r.submitQuery(e);
1012
+ }
1013
+ clearMap() {
1014
+ this.#a = [], this.#u(void 0, void 0);
1015
+ }
1016
+ clearList() {
1017
+ this.#r.clearList();
1018
+ }
1019
+ setReverseMode(e) {
1020
+ this.setOptions({ reverseActive: e });
1021
+ }
1022
+ focus(e) {
1023
+ this.#r.focus(e);
1024
+ }
1025
+ blur() {
1026
+ this.#r.blur();
1027
+ }
1028
+ /** Markers currently displayed on the map */
1029
+ #c = /* @__PURE__ */ new Map();
1030
+ /** Marker representing the selected feature */
1031
+ #h;
1032
+ /** Marker representing the picked feature */
1033
+ #o;
1034
+ /** Features currently marked on the map */
1035
+ #a;
1036
+ /** Remember last feature that the map flew to as to not do it again */
1037
+ #g;
1038
+ /** Layer used for showing results */
1039
+ #l;
1040
+ /** Source connected to layer used for showing results */
1041
+ #s;
1042
+ /** Last marker the mouse was over, used to detech mouseover and mouseleave events on markers */
1043
+ #d;
1044
+ /** Flag whether to show reverse geocoding cursor */
1045
+ #y = !1;
1046
+ #v = {
1047
+ reversetoggle: (e) => {
1048
+ this.#y = e.detail.reverse, this.#i("reversetoggle", e.detail);
1049
+ },
1050
+ querychange: (e) => {
1051
+ const i = e.detail.reverseCoords;
1052
+ this.#_(i ? [i.decimalLongitude, i.decimalLatitude] : void 0), this.#i("querychange", e.detail);
1053
+ },
1054
+ queryclear: () => {
1055
+ this.#_(void 0), this.#i("queryclear");
1056
+ },
1057
+ request: (e) => {
1058
+ this.#i("request", e.detail);
1059
+ },
1060
+ response: (e) => {
1061
+ this.#i("response", e.detail);
1062
+ },
1063
+ select: (e) => {
1064
+ const i = e.detail.feature;
1065
+ i && this.#m && this.#t.flyToSelected && this.#w(i.center, this.#p(i)), this.#a && i && this.#C(i), this.#i("select", e.detail);
1066
+ },
1067
+ pick: (e) => {
1068
+ const i = e.detail.feature;
1069
+ i && i.id !== this.#g && this.#m && (this.#M(i), this.#u(this.#a, i)), this.#g = i?.id, this.#i("pick", e.detail);
1070
+ },
1071
+ featuresshow: () => {
1072
+ this.#i("featuresshow");
1073
+ },
1074
+ featureshide: () => {
1075
+ this.#i("featureshide");
1076
+ },
1077
+ featureslisted: (e) => {
1078
+ const i = e.detail.features;
1079
+ this.#a = i, this.#u(this.#a, void 0), this.#S(i), this.#i("featureslisted", e.detail);
1080
+ },
1081
+ featuresclear: () => {
1082
+ this.#a = void 0, this.#u(void 0, void 0), this.#i("featuresclear");
1083
+ },
1084
+ focusin: () => {
1085
+ this.#i("focusin");
1086
+ },
1087
+ focusout: () => {
1088
+ this.#i("focusout");
1089
+ }
1090
+ };
1091
+ #x = {
1092
+ postrender: () => {
1093
+ const e = this.#e?.getView().getZoom(), i = this.#e?.getView().getCenter();
1094
+ this.#r.handleMapChange(e && i ? [e, ...this.#$(i)] : void 0);
1095
+ },
1096
+ click: (e) => {
1097
+ this.#r.handleMapClick(this.#$(e.coordinate)), this.#e?.forEachFeatureAtPixel(e.pixel, (i) => {
1098
+ const o = i.getId(), r = this.#a?.find((s) => s.id === o);
1099
+ if (!(!o || !r))
1100
+ return e.stopPropagation(), this.#i("markerclick", { feature: r, marker: i }), !0;
1101
+ });
1102
+ },
1103
+ pointermove: (e) => {
1104
+ if (!this.#e) return;
1105
+ const i = this.#e.forEachFeatureAtPixel(e.pixel, (r) => r.getId() ? r : void 0);
1106
+ this.#e.getTargetElement().style.cursor = i ? "pointer" : this.#y ? "crosshair" : "";
1107
+ const o = i?.getId();
1108
+ if (this.#d !== o) {
1109
+ if (this.#d) {
1110
+ const r = this.#a?.find((a) => a.id === this.#d), s = this.#c.get(r);
1111
+ s?.set("isMouseOver", !1), r && s && this.#i("markermouseleave", { feature: r, marker: s });
1112
+ }
1113
+ if (i) {
1114
+ const r = this.#a?.find((s) => s.id === o);
1115
+ this.#i("markermouseenter", { feature: r, marker: i }), i.set("isMouseOver", !0);
1116
+ }
1117
+ this.#d = o;
1118
+ }
1119
+ }
1120
+ };
1121
+ #b() {
1122
+ this.#r.setOptions(this.#t), this.#r.fetchFullGeometryOnPick = this.#t.pickedResultStyle !== "marker-only";
1123
+ }
1124
+ #L() {
1125
+ if (this.#e) {
1126
+ for (const [e, i] of Object.entries(this.#v))
1127
+ this.#r.addEventListener(e, i);
1128
+ for (const [e, i] of Object.entries(this.#x))
1129
+ this.#e.on([e], i);
1130
+ }
1131
+ }
1132
+ #I() {
1133
+ if (this.#e) {
1134
+ for (const [e, i] of Object.entries(this.#v))
1135
+ this.#r.removeEventListener(e, i);
1136
+ for (const [e, i] of Object.entries(this.#x))
1137
+ this.#e.un([e], i);
1138
+ }
1139
+ }
1140
+ #i(e, i) {
1141
+ this.dispatchEvent({ type: e, ...i ?? {} });
1142
+ }
1143
+ #M(e) {
1144
+ e.bbox[0] === e.bbox[2] && e.bbox[1] === e.bbox[3] ? this.#w(e.center, this.#p(e)) : this.#k(Z(e.bbox), 50, this.#p(e));
1145
+ }
1146
+ #S(e) {
1147
+ if (!e || e.length === 0 || !this.#m) return;
1148
+ const i = e.every((s) => s.matching_text), o = e.reduce(
1149
+ (s, a) => i || !a.matching_text ? [Math.min(s[0], a.bbox[0]), Math.min(s[1], a.bbox[1]), Math.max(s[2], a.bbox[2]), Math.max(s[3], a.bbox[3])] : s,
1150
+ [180, 90, -180, -90]
1151
+ ), r = e.map((s) => this.#p(s)).filter((s) => s !== void 0).reduce((s, a) => s === void 0 ? a : Math.max(s, a), void 0);
1152
+ this.#k(Z(o), 50, r);
1153
+ }
1154
+ #p(e) {
1155
+ if (e.bbox[0] !== e.bbox[2] || e.bbox[1] !== e.bbox[3])
1156
+ return;
1157
+ const i = e.id.replace(/\..*/, ""), o = this.#t.zoom ?? Et;
1158
+ return (Array.isArray(e.properties?.categories) ? e.properties.categories.reduce((r, s) => {
1159
+ const a = o[i + "." + s];
1160
+ return r === void 0 ? a : a === void 0 ? r : Math.max(r, a);
1161
+ }, void 0) : void 0) ?? o[i];
1162
+ }
1163
+ get #m() {
1164
+ return !!this.#t.flyTo || this.#t.flyTo === void 0;
1165
+ }
1166
+ get #F() {
1167
+ return typeof this.#t.flyTo == "boolean" ? {} : this.#t.flyTo;
1168
+ }
1169
+ get #O() {
1170
+ return typeof this.#t.flyTo == "boolean" ? {} : this.#t.flyTo;
1171
+ }
1172
+ #w(e, i) {
1173
+ this.#e?.getView().animate({
1174
+ center: this.#f(e),
1175
+ ...i ? { zoom: i } : {},
1176
+ duration: 2e3,
1177
+ ...this.#F
1178
+ });
1179
+ }
1180
+ #k(e, i, o) {
1181
+ this.#e?.getView().fit(Je(e, O, this.#n()), {
1182
+ padding: [i, i, i, i],
1183
+ ...o ? { maxZoom: o } : {},
1184
+ duration: 2e3,
1185
+ ...this.#O
1186
+ });
1187
+ }
1188
+ #_(e) {
1189
+ if (this.#t.marker === !1 || !this.#e || !this.#s)
1190
+ return;
1191
+ if (!e) {
1192
+ this.#o && (this.#s.removeFeature(this.#o), this.#o.dispose(), this.#o = void 0);
1193
+ return;
1194
+ }
1195
+ const i = this.#f(e);
1196
+ if (!this.#o) {
1197
+ this.#o = new $(new X(i)), this.#o.set("isReverse", !0), this.#s.addFeature(this.#o);
1198
+ return;
1199
+ }
1200
+ this.#o.getGeometry().setCoordinates(i);
1201
+ }
1202
+ #u(e, i) {
1203
+ if (!this.#e || !this.#s)
1204
+ return;
1205
+ this.#s.removeFeatures([...this.#c.values()]), this.#c = /* @__PURE__ */ new Map();
1206
+ const o = () => {
1207
+ if (!i || !this.#e || this.#t.marker === !1) return;
1208
+ const r = new $(new X(this.#f(i.center)));
1209
+ r.setId(i.id), this.#c.set(i, r), this.#s?.addFeature(r);
1210
+ };
1211
+ if (i?.geometry.type === "GeometryCollection") {
1212
+ const r = i.geometry.geometries.map((s) => s.type === "Polygon" ? new be(s.coordinates) : s.type === "MultiPolygon" ? new we(s.coordinates) : null).filter((s) => !!s);
1213
+ if (r.length > 0)
1214
+ this.#s.addFeature(new $(new Ye(r).transform(O, this.#n())));
1215
+ else
1216
+ for (const s of i.geometry.geometries)
1217
+ s.type === "LineString" ? this.#s.addFeature(new $(new ke(s.coordinates).transform(O, this.#n()))) : s.type === "MultiLineString" && this.#s.addFeature(new $(new _e(s.coordinates).transform(O, this.#n())));
1218
+ } else if (i?.geometry.type.endsWith("Polygon")) {
1219
+ const r = Pt(i);
1220
+ if (r)
1221
+ for (const s of r.features) {
1222
+ const a = s.geometry.type === "Polygon" ? new be(s.geometry.coordinates) : new we(s.geometry.coordinates);
1223
+ this.#s.addFeature(
1224
+ new $({
1225
+ isMask: !!s.properties?.isMask,
1226
+ geometry: a.transform(O, this.#n())
1227
+ })
1228
+ );
1229
+ }
1230
+ this.#t.pickedResultStyle === "full-geometry-including-polygon-center-marker" && o();
1231
+ } else i?.geometry.type === "LineString" ? this.#s.addFeature(new $(new ke(i.geometry.coordinates).transform(O, this.#n()))) : i?.geometry.type === "MultiLineString" ? this.#s.addFeature(new $(new _e(i.geometry.coordinates).transform(O, this.#n()))) : i?.geometry.type.endsWith("Point") && o();
1232
+ if (this.#t.showResultMarkers !== !1)
1233
+ for (const r of e ?? []) {
1234
+ if (r.id === i?.id || r.place_type.includes("reverse"))
1235
+ continue;
1236
+ const s = new $(new X(this.#f(r.center)));
1237
+ s.setId(r.id), s.setProperties({
1238
+ fuzzy: !!r.matching_text,
1239
+ tooltip: r.place_type[0] === "reverse" ? r.place_name : r.place_name.replace(/,.*/, "")
1240
+ }), this.#s.addFeature(s), this.#c.set(r, s);
1241
+ }
1242
+ }
1243
+ #C(e) {
1244
+ this.#h?.set("isSelected", !1), this.#h = void 0, this.#t.markerOnSelected !== !1 && (this.#h = this.#c.get(e), this.#h?.setProperties({ isSelected: !0 }));
1245
+ }
1246
+ #T() {
1247
+ this.#e && (this.#s = new it({}), this.#l = new He({
1248
+ updateWhileAnimating: !0
1249
+ }), this.#l.setSource(this.#s), this.#l.setStyle(this.#E()), this.#e.addLayer(this.#l));
1250
+ }
1251
+ #P() {
1252
+ !this.#e || !this.#l || (this.#e.removeLayer(this.#l), this.#l = void 0);
1253
+ }
1254
+ #n() {
1255
+ return Xe() ?? this.#e?.getView().getProjection();
1256
+ }
1257
+ #f(e) {
1258
+ return et(e, this.#n());
1259
+ }
1260
+ #$(e) {
1261
+ return tt(e, this.#n());
1262
+ }
1263
+ #E() {
1264
+ const { fullGeometryStyle: e } = this.#t;
1265
+ if (e === !0 || e === void 0) return Ut(this.#t);
1266
+ if (!(e === !1 || e === null))
1267
+ return e;
1268
+ }
1269
+ }
1270
+ export {
1271
+ Ut as DEFAULT_GEOMETRY_STYLE,
1272
+ oi as GeocodingControl,
1273
+ te as MaptilerGeocodeClearIconElement,
1274
+ ie as MaptilerGeocodeFailIconElement,
1275
+ se as MaptilerGeocodeLoadingIconElement,
1276
+ ce as MaptilerGeocodeMarkerElement,
1277
+ re as MaptilerGeocodeReverseGeocodingIconElement,
1278
+ oe as MaptilerGeocodeSearchIconElement,
1279
+ l as MaptilerGeocoderElement,
1280
+ oi as OpenLayersGeocodingControl,
1281
+ Et as ZOOM_DEFAULTS
1282
+ };
1283
+ //# sourceMappingURL=openlayers.public.js.map