@alfadocs/ui-kit-debug 1.92.0 → 1.93.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.
@@ -0,0 +1,726 @@
1
+ import { jsx as l, jsxs as S } from "react/jsx-runtime";
2
+ import { forwardRef as he, useMemo as E, useRef as k, useId as ge, useState as Y, useEffect as L, useCallback as T, useImperativeHandle as fe } from "react";
3
+ import { c as x } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as A } from "react-i18next";
5
+ import { M as be, A as ye, a as we, b as ve, P as ke, c as Me, u as ze, d as ne, e as K } from "./maps-core-gate-DkNqGkm3.js";
6
+ import { B as Ve } from "./button-DohK_Ak_.js";
7
+ import { S as Le } from "./skeleton-tTWJpvAq.js";
8
+ import { V as Ce } from "./visually-hidden-BHxEUGyT.js";
9
+ import { E as Ie } from "./error-boundary-tAn_GuCu.js";
10
+ import { u as Ee } from "./registry-DvAUVLHh.js";
11
+ import { l as Te } from "./length-token-DwMnGEYT.js";
12
+ import { M as Se } from "./map-pin-BaY37-Km.js";
13
+ import { E as xe } from "./external-link-CY6zAXXU.js";
14
+ const Pe = {
15
+ id: "map-view",
16
+ // pan → scroll (viewport move); set_zoom → set_value; select_marker → pick
17
+ // (NON-persisting marker focus, no value state slot).
18
+ capabilities: ["scroll", "set_value", "pick"],
19
+ // Every action routes through the imperative bridge, which only exists
20
+ // once the map has loaded: consent granted (the default is
21
+ // `consentGranted={false}`) and Google Maps finished loading. Until then
22
+ // all three actions are silent no-ops. `consentGranted` says whether the
23
+ // gate is passed, and a null `center` after it means the map is still
24
+ // loading. `center` / `zoom` are read off the live
25
+ // map because Google clamps zoom and animates pans, so requested is not
26
+ // applied; `selectedMarkerId` is the only confirmation the host accepted
27
+ // a `select_marker` proposal.
28
+ //
29
+ // A9: marker ids only (`MapMarker.id` is a stable opaque id). Never
30
+ // `MapMarker.label`, never the `address` prop (consumer-supplied free
31
+ // text, PII in any patient-address deployment), never `apiKey`.
32
+ state: {
33
+ consentGranted: {
34
+ type: "boolean",
35
+ descriptionKey: "ui.agent.mapView.state.consentGranted",
36
+ description: "True when the GDPR consent gate has been passed. Read this FIRST: while it is false every action is a silent no-op against a placeholder, and nothing else in the surface says so. When it is true but `center` is still null, Google Maps is loading; wait for `center` before acting.",
37
+ read: (e) => e.isConsentGranted()
38
+ },
39
+ markerCount: {
40
+ type: "number",
41
+ descriptionKey: "ui.agent.mapView.state.markerCount",
42
+ description: "Number of markers the consumer passed. Zero means there is nothing for `select_marker` to select. A count only — no ids, labels or positions.",
43
+ read: (e) => e.getMarkerCount()
44
+ },
45
+ selectedMarkerId: {
46
+ type: "string | null",
47
+ descriptionKey: "ui.agent.mapView.state.selectedMarkerId",
48
+ description: "Id of the marker the host currently holds as selected, or null. Selection is fully controlled by the consumer, so `select_marker` only proposes — this slot is the only way to see whether the proposal was accepted.",
49
+ read: (e) => e.getSelectedMarkerId()
50
+ },
51
+ center: {
52
+ type: "{ lat: number; lng: number } | null",
53
+ descriptionKey: "ui.agent.mapView.state.center",
54
+ description: "Live map centre in lat/lng, or null until the map has loaded (consent not granted, or Google Maps still loading). The read-back for `pan_to`, and the sign that the map is ready.",
55
+ read: (e) => e.getCenter()
56
+ },
57
+ zoom: {
58
+ type: "number | null",
59
+ descriptionKey: "ui.agent.mapView.state.zoom",
60
+ description: "Live zoom level, or null until the map has loaded. Google clamps zoom to the map type's range, so this is not necessarily the value last passed to `set_zoom`.",
61
+ read: (e) => e.getZoom()
62
+ }
63
+ },
64
+ actions: {
65
+ pan_to: {
66
+ // Ephemeral viewport move, no data loss → read.
67
+ safety: "read",
68
+ argsType: "{ position: { lat: number; lng: number } }",
69
+ argsSchema: {
70
+ type: "object",
71
+ properties: {
72
+ position: {
73
+ type: "object",
74
+ properties: {
75
+ lat: { type: "number", description: "Latitude in degrees." },
76
+ lng: { type: "number", description: "Longitude in degrees." }
77
+ },
78
+ required: ["lat", "lng"]
79
+ }
80
+ },
81
+ required: ["position"]
82
+ },
83
+ idempotent: !0,
84
+ descriptionKey: "ui.agent.mapView.actions.panTo",
85
+ description: "Pan the map to a new centre without changing zoom. Read the `center` slot back to confirm — Google animates the pan, so the applied centre settles after the call.",
86
+ errors: [
87
+ "Silent no-op until the map has loaded: while `consentGranted` is false (only the consent placeholder shows) or while `center` is still null (Google Maps is loading)."
88
+ ],
89
+ invoke: (e, n) => {
90
+ e.panTo(n.position);
91
+ }
92
+ },
93
+ set_zoom: {
94
+ // Ephemeral viewport zoom, no data loss → read.
95
+ safety: "read",
96
+ argsType: "{ zoom: number }",
97
+ argsSchema: {
98
+ type: "object",
99
+ properties: {
100
+ zoom: {
101
+ type: "number",
102
+ description: "Zoom level, typical range 1–20."
103
+ }
104
+ },
105
+ required: ["zoom"]
106
+ },
107
+ idempotent: !0,
108
+ descriptionKey: "ui.agent.mapView.actions.setZoom",
109
+ description: "Set the map zoom level (typical range 1–20). Read the `zoom` slot back — Google clamps the request to the map type’s supported range, so requested and applied can differ.",
110
+ errors: [
111
+ "Silent no-op until the map has loaded: while `consentGranted` is false (only the consent placeholder shows) or while `center` is still null (Google Maps is loading).",
112
+ "Requested zoom is clamped to the map type's range; `zoom` reports what was actually applied."
113
+ ],
114
+ invoke: (e, n) => {
115
+ e.setZoom(n.zoom);
116
+ }
117
+ },
118
+ select_marker: {
119
+ // Ephemeral marker focus, no data loss → read.
120
+ safety: "read",
121
+ argsType: "{ id: string | null }",
122
+ argsSchema: {
123
+ type: "object",
124
+ properties: {
125
+ id: {
126
+ type: ["string", "null"],
127
+ description: "Marker id to select, or null to clear the selection."
128
+ }
129
+ },
130
+ required: ["id"]
131
+ },
132
+ idempotent: !0,
133
+ descriptionKey: "ui.agent.mapView.actions.selectMarker",
134
+ description: "Propose a marker selection by id, or pass null to clear it. Fires the host's `onMarkerClick`; selection is controlled by the host, so read the `selectedMarkerId` slot back to see whether it accepted.",
135
+ errors: [
136
+ "Silent no-op until the map has loaded: while `consentGranted` is false (only the consent placeholder shows) or while `center` is still null (Google Maps is loading).",
137
+ "The host owns `selectedMarkerId` and may ignore the proposal; `selectedMarkerId` is unchanged when it does."
138
+ ],
139
+ invoke: (e, n) => {
140
+ e.selectMarker(n.id);
141
+ }
142
+ }
143
+ },
144
+ domHooks: {
145
+ root: {
146
+ attr: "data-component",
147
+ value: "map-view",
148
+ description: "Marks the element as a kit MapView."
149
+ },
150
+ instanceId: {
151
+ attr: "data-component-id",
152
+ sourceProp: "id",
153
+ description: "Sourced from the id prop."
154
+ }
155
+ }
156
+ }, Ge = x(
157
+ ["ds:relative ds:overflow-hidden ds:block", "ds:bg-[var(--muted)]"].join(" "),
158
+ {
159
+ variants: {
160
+ size: {
161
+ sm: "ds:[--map-block-size:14rem]",
162
+ md: "ds:[--map-block-size:20rem]",
163
+ lg: "ds:[--map-block-size:28rem]",
164
+ // `fill` defers sizing to the parent. The outer takes
165
+ // `block-size: 100%` so the inner (also 100%) has something
166
+ // to inherit from. Use inside a viewport-locked column —
167
+ // `<PracticeResults variant="map-first">` wires this through
168
+ // automatically; standalone consumers must give the parent
169
+ // a constrained block-size or the map collapses to 0.
170
+ fill: "ds:[block-size:100%]"
171
+ },
172
+ surface: {
173
+ bordered: "ds:rounded-[var(--radius-md)] ds:border ds:border-[color:var(--border)]",
174
+ elevated: "ds:rounded-[var(--radius-md)] ds:shadow-[var(--shadow-card)] ds:[:where(&)]:border-[length:var(--surface-border-width,var(--border-width-sm))] ds:border-[color:var(--card-border)]",
175
+ bare: "ds:rounded-none ds:border-0"
176
+ }
177
+ },
178
+ defaultVariants: { size: "md", surface: "bordered" }
179
+ }
180
+ ), Ne = x("ds:block ds:inline-size-full", {
181
+ variants: {
182
+ size: {
183
+ sm: "ds:[block-size:var(--map-block-size)]",
184
+ md: "ds:[block-size:var(--map-block-size)]",
185
+ lg: "ds:[block-size:var(--map-block-size)]",
186
+ fill: "ds:[block-size:100%]"
187
+ }
188
+ },
189
+ defaultVariants: { size: "md" }
190
+ }), Re = x(
191
+ [
192
+ "ds:absolute ds:inset-0",
193
+ "ds:flex ds:flex-col ds:items-center ds:justify-center",
194
+ "ds:gap-[var(--spacing-sm)]",
195
+ "ds:p-[var(--spacing-md)]",
196
+ "ds:bg-[var(--muted)] ds:text-[var(--foreground)]",
197
+ "ds:text-center"
198
+ ].join(" ")
199
+ ), Ze = x("type-heading-3 ds:m-0"), Q = x(
200
+ "type-body-sm ds:text-[var(--muted-foreground)] ds:[max-inline-size:28rem] ds:m-0"
201
+ );
202
+ function _e({
203
+ onHandleReady: e,
204
+ onMarkerSelect: n,
205
+ onCameraMove: o
206
+ }) {
207
+ const i = K();
208
+ return L(() => {
209
+ if (i)
210
+ return e({
211
+ panTo: (r) => {
212
+ o(), i.panTo(r);
213
+ },
214
+ setZoom: (r) => {
215
+ o(), i.setZoom(r);
216
+ },
217
+ jumpTo: (r, a) => {
218
+ o(), i.moveCamera({ center: r, zoom: a });
219
+ },
220
+ selectMarker: (r) => n(r),
221
+ // Read straight off the live map: Google clamps `setZoom` to the
222
+ // map type's range and animates `panTo`, so requested and applied
223
+ // are not the same value.
224
+ getCenter: () => {
225
+ var r;
226
+ return ((r = i.getCenter()) == null ? void 0 : r.toJSON()) ?? null;
227
+ },
228
+ getZoom: () => i.getZoom() ?? null
229
+ }), () => e(null);
230
+ }, [i, e, n, o]), null;
231
+ }
232
+ function je({
233
+ onBoundsChange: e,
234
+ userInteraction: n
235
+ }) {
236
+ const o = K(), i = k(e);
237
+ return i.current = e, L(() => {
238
+ if (!o) return;
239
+ const r = o.getDiv();
240
+ let a = null;
241
+ const d = () => {
242
+ n.current = {
243
+ pendingInput: !1,
244
+ moved: !1,
245
+ programmatic: !1
246
+ };
247
+ };
248
+ d();
249
+ let b;
250
+ const p = /* @__PURE__ */ new Set(), f = (t) => {
251
+ if (t instanceof PointerEvent && t.pointerType === "touch" && (t.type === "pointerdown" && p.add(t.pointerId), t.type === "pointerup" || t.type === "pointercancel")) {
252
+ p.delete(t.pointerId);
253
+ return;
254
+ }
255
+ if (t instanceof PointerEvent && t.type === "pointermove" && t.buttons === 0 && t.pointerType !== "touch" || t instanceof KeyboardEvent && ![
256
+ "ArrowUp",
257
+ "ArrowDown",
258
+ "ArrowLeft",
259
+ "ArrowRight",
260
+ "+",
261
+ "=",
262
+ "-",
263
+ "_",
264
+ "Enter",
265
+ " ",
266
+ "PageUp",
267
+ "PageDown"
268
+ ].includes(t.key))
269
+ return;
270
+ const h = document.fullscreenElement, w = !!(h && (h.contains(r) || r.contains(h)));
271
+ let m = t.type === "dblclick";
272
+ t instanceof PointerEvent && t.type === "pointermove" && (m = t.pointerType !== "touch" || p.size >= 2 || w), t.type === "touchmove" && (m = t.touches.length >= 2 || w), t instanceof KeyboardEvent && (m = t.key !== "Enter" && t.key !== " "), t instanceof WheelEvent && (m = t.ctrlKey || t.metaKey || w), t.type === "click" && (m = t.target instanceof Element && t.target.closest('button, [role="button"]') != null), m && (n.current.programmatic = !1), n.current.pendingInput = !0, clearTimeout(b), b = setTimeout(() => {
273
+ n.current.pendingInput = !1;
274
+ }, 250);
275
+ }, c = () => {
276
+ n.current.pendingInput && !n.current.programmatic && (n.current.moved = !0);
277
+ }, y = () => {
278
+ var P, G;
279
+ const t = (P = o.getBounds()) == null ? void 0 : P.toJSON(), h = (G = o.getCenter()) == null ? void 0 : G.toJSON(), w = o.getZoom(), m = n.current.moved;
280
+ if (d(), clearTimeout(b), !t || !h || w == null) return;
281
+ const M = !a || Object.keys(t).some(
282
+ (N) => t[N] !== a.bounds[N]
283
+ ), I = a != null && (w !== a.zoom || h.lat !== a.center.lat || h.lng !== a.center.lng);
284
+ a = { bounds: t, center: h, zoom: w }, M && i.current(t, { userInteraction: m && I });
285
+ }, u = [
286
+ "pointerdown",
287
+ "pointermove",
288
+ "pointerup",
289
+ "pointercancel",
290
+ "touchstart",
291
+ "touchmove",
292
+ "click",
293
+ "dblclick",
294
+ "wheel",
295
+ "keydown"
296
+ ];
297
+ u.forEach(
298
+ (t) => r.addEventListener(t, f, { capture: !0, passive: !0 })
299
+ );
300
+ const v = [
301
+ o.addListener("dragstart", () => {
302
+ n.current.programmatic = !1, n.current.moved = !0;
303
+ }),
304
+ o.addListener("center_changed", c),
305
+ o.addListener("zoom_changed", c),
306
+ o.addListener("idle", y)
307
+ ];
308
+ return y(), () => {
309
+ v.forEach((t) => t.remove()), u.forEach(
310
+ (t) => r.removeEventListener(t, f, !0)
311
+ ), clearTimeout(b), d();
312
+ };
313
+ }, [o, n]), null;
314
+ }
315
+ const Oe = 256, Ae = (e) => e * Math.PI / 180;
316
+ function ee(e) {
317
+ const n = Math.min(Math.max(Math.sin(Ae(e)), -0.9999), 0.9999);
318
+ return Math.log((1 + n) / (1 - n)) / 2;
319
+ }
320
+ const Ke = (e) => Math.atan(Math.sinh(e)) * 180 / Math.PI;
321
+ function $e(e) {
322
+ let n = -90, o = 90, i = -180, r = 180;
323
+ for (const { lat: a, lng: d } of e)
324
+ n = Math.max(n, a), o = Math.min(o, a), i = Math.max(i, d), r = Math.min(r, d);
325
+ return { north: n, south: o, east: i, west: r };
326
+ }
327
+ function qe(e, n, o, i, r) {
328
+ const { north: a, south: d, east: b, west: p } = $e(e);
329
+ if (a === d && b === p)
330
+ return { center: { lat: a, lng: b }, zoom: r };
331
+ const f = ee(a), c = ee(d), y = {
332
+ lat: Ke((f + c) / 2),
333
+ lng: (b + p) / 2
334
+ }, u = (t, h) => h > 0 ? Math.log2(Math.max(t, 1) / Oe / h) : r, v = Math.min(
335
+ u(n - 2 * i, (b - p) / 360),
336
+ u(o - 2 * i, (f - c) / (2 * Math.PI)),
337
+ r
338
+ );
339
+ return { center: y, zoom: Math.max(0, Math.floor(v)) };
340
+ }
341
+ const re = ({ id: e, lat: n, lng: o }) => e != null ? `id:${e}` : `at:${n},${o}`;
342
+ function De({
343
+ points: e,
344
+ fitKey: n,
345
+ maxZoom: o,
346
+ onCameraMove: i
347
+ }) {
348
+ const r = K(), a = k(null), d = k(!1), b = k(null);
349
+ return L(() => {
350
+ if (!r) return;
351
+ const p = () => {
352
+ var t;
353
+ const c = b.current, y = (t = r.getCenter()) == null ? void 0 : t.toJSON(), u = r.getZoom();
354
+ c != null && u === c.zoom && y != null && Math.abs(y.lat - c.center.lat) < 1e-6 && Math.abs(y.lng - c.center.lng) < 1e-6 || (d.current = !0);
355
+ }, f = [
356
+ r.addListener("dragstart", () => {
357
+ d.current = !0;
358
+ }),
359
+ r.addListener("center_changed", p),
360
+ r.addListener("zoom_changed", p)
361
+ ];
362
+ return () => f.forEach((c) => c.remove());
363
+ }, [r]), L(() => {
364
+ var w;
365
+ if (!r) return;
366
+ const p = ((w = a.current) == null ? void 0 : w.map) === r ? a.current : null;
367
+ if ((p == null ? void 0 : p.key) === n) return;
368
+ const f = new Set(e.map(re)), c = (m, M) => {
369
+ b.current = { center: m, zoom: M }, i(), r.moveCamera({ center: m, zoom: M }), d.current = !1;
370
+ };
371
+ if (e.length === 0) {
372
+ a.current = { map: r, key: n, points: f };
373
+ return;
374
+ }
375
+ if (p != null && p.points.size > 0 && [...p.points].every((m) => f.has(m)) && d.current) {
376
+ a.current = { map: r, key: n, points: f };
377
+ return;
378
+ }
379
+ const u = r.getDiv();
380
+ if (!(u instanceof Element)) return;
381
+ const v = () => {
382
+ a.current = { map: r, key: n, points: f };
383
+ const m = Math.min(
384
+ Te("--spacing-2xl", u, 48),
385
+ u.clientWidth / 4,
386
+ u.clientHeight / 4
387
+ ), { center: M, zoom: I } = qe(
388
+ e,
389
+ u.clientWidth,
390
+ u.clientHeight,
391
+ m,
392
+ o
393
+ );
394
+ c(M, I);
395
+ }, t = () => u.clientWidth > 0 && u.clientHeight > 0;
396
+ if (t() || typeof ResizeObserver > "u") {
397
+ v();
398
+ return;
399
+ }
400
+ const h = new ResizeObserver(() => {
401
+ t() && (h.disconnect(), v());
402
+ });
403
+ return h.observe(u), () => h.disconnect();
404
+ }, [r, n, e, o, i]), null;
405
+ }
406
+ const oe = (e) => {
407
+ var n, o;
408
+ return typeof ((o = (n = globalThis.google) == null ? void 0 : n.maps) == null ? void 0 : o[e]) == "function";
409
+ };
410
+ function se() {
411
+ const { t: e } = A("ui");
412
+ return /* @__PURE__ */ S(
413
+ "div",
414
+ {
415
+ role: "status",
416
+ "data-testid": "map-view-loading",
417
+ className: "ds:[inline-size:100%] ds:[block-size:100%]",
418
+ children: [
419
+ /* @__PURE__ */ l(Le, { variant: "rectangular", width: "100%", height: "100%" }),
420
+ /* @__PURE__ */ l(Ce, { children: e("common.loading") })
421
+ ]
422
+ }
423
+ );
424
+ }
425
+ function He({ children: e }) {
426
+ const n = ze();
427
+ return ne("maps") || !n || oe("Map") ? e : /* @__PURE__ */ l(se, {});
428
+ }
429
+ function Be({ children: e }) {
430
+ return ne("marker") || oe("Marker") ? e : null;
431
+ }
432
+ function te({
433
+ address: e,
434
+ description: n,
435
+ onLoadMap: o,
436
+ openInGoogleMapsHref: i,
437
+ consentCta: r
438
+ }) {
439
+ const { t: a } = A("ui");
440
+ return /* @__PURE__ */ S("div", { className: Re(), "data-testid": "map-view-consent", children: [
441
+ /* @__PURE__ */ l(
442
+ Se,
443
+ {
444
+ "aria-hidden": "true",
445
+ className: "ds:size-6 ds:text-[var(--muted-foreground)]"
446
+ }
447
+ ),
448
+ /* @__PURE__ */ l("p", { className: Ze(), children: a("mapView.consentTitle") }),
449
+ e ? /* @__PURE__ */ l(
450
+ "p",
451
+ {
452
+ className: Q(),
453
+ "data-testid": "map-view-address",
454
+ children: e
455
+ }
456
+ ) : null,
457
+ /* @__PURE__ */ l("p", { className: Q(), children: n }),
458
+ /* @__PURE__ */ S("div", { className: "ds:flex ds:gap-[var(--spacing-sm)] ds:flex-wrap ds:items-center ds:justify-center", children: [
459
+ r ?? /* @__PURE__ */ l(
460
+ Ve,
461
+ {
462
+ type: "button",
463
+ intent: "primary",
464
+ size: "sm",
465
+ onClick: o,
466
+ "data-testid": "map-view-load-cta",
467
+ children: a("mapView.consentCta")
468
+ }
469
+ ),
470
+ /* @__PURE__ */ S(
471
+ "a",
472
+ {
473
+ href: i,
474
+ target: "_blank",
475
+ rel: "noopener noreferrer",
476
+ className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-2xs)] ds:text-[var(--primary-readable)] ds:underline ds:underline-offset-2",
477
+ children: [
478
+ a("mapView.openInGoogleMaps"),
479
+ /* @__PURE__ */ l(xe, { "aria-hidden": "true", className: "ds:size-3" })
480
+ ]
481
+ }
482
+ )
483
+ ] })
484
+ ] });
485
+ }
486
+ const Fe = he(
487
+ ({
488
+ id: e,
489
+ apiKey: n,
490
+ center: o,
491
+ zoom: i = 15,
492
+ markers: r,
493
+ selectedMarkerId: a,
494
+ onMarkerClick: d,
495
+ onBoundsChange: b,
496
+ consentGranted: p = !1,
497
+ onConsentRequest: f,
498
+ address: c,
499
+ consentDescription: y,
500
+ consentCta: u,
501
+ mapId: v,
502
+ size: t,
503
+ surface: h,
504
+ ariaLabel: w,
505
+ fitToPoints: m,
506
+ fitKey: M,
507
+ fitMaxZoom: I = 15,
508
+ className: P,
509
+ ...G
510
+ }, N) => {
511
+ const { t: R, i18n: ae } = A("ui"), Z = E(() => m ?? [], [m]), ie = E(
512
+ () => M ?? Z.map((s) => `${re(s)}@${s.lat},${s.lng}`).sort().join("|"),
513
+ [M, Z]
514
+ ), V = Z.length > 0, $ = k(V), q = ge(), le = E(
515
+ () => `map-${q.replace(/[^a-zA-Z0-9-_]/g, "")}`,
516
+ [q]
517
+ ), [D, ce] = Y(!1);
518
+ L(() => {
519
+ if (typeof window > "u") return;
520
+ const s = window.matchMedia("(prefers-reduced-motion: reduce)"), g = () => ce(s.matches);
521
+ return g(), s.addEventListener("change", g), () => s.removeEventListener("change", g);
522
+ }, []);
523
+ const H = E(() => `https://www.google.com/maps/search/?api=1&query=${c ? encodeURIComponent(c) : `${o.lat},${o.lng}`}`, [c, o.lat, o.lng]), z = k(null), B = k({
524
+ pendingInput: !1,
525
+ moved: !1,
526
+ programmatic: !1
527
+ }), _ = T(() => {
528
+ B.current = {
529
+ pendingInput: !1,
530
+ moved: !1,
531
+ programmatic: !0
532
+ };
533
+ }, []), j = T(
534
+ (s) => {
535
+ _(), d == null || d(s);
536
+ },
537
+ [_, d]
538
+ ), de = T((s) => {
539
+ z.current = s;
540
+ }, []), F = k(!1), W = k(null), J = k(0), O = T(
541
+ () => ({
542
+ panTo: (s) => {
543
+ var g;
544
+ return (g = z.current) == null ? void 0 : g.panTo(s);
545
+ },
546
+ setZoom: (s) => {
547
+ var g;
548
+ return (g = z.current) == null ? void 0 : g.setZoom(s);
549
+ },
550
+ selectMarker: (s) => {
551
+ var g;
552
+ return (g = z.current) == null ? void 0 : g.selectMarker(s);
553
+ },
554
+ // Without `isConsentGranted` an agent has no way to learn that
555
+ // its pan / zoom / select was swallowed by the GDPR gate rather
556
+ // than applied: under the default (`consentGranted={false}`) the
557
+ // whole Maps subtree is unmounted and every action optional-chains
558
+ // into nothing.
559
+ isConsentGranted: () => F.current,
560
+ getCenter: () => {
561
+ var s;
562
+ return ((s = z.current) == null ? void 0 : s.getCenter()) ?? null;
563
+ },
564
+ getZoom: () => {
565
+ var s;
566
+ return ((s = z.current) == null ? void 0 : s.getZoom()) ?? null;
567
+ },
568
+ getSelectedMarkerId: () => W.current,
569
+ getMarkerCount: () => J.current
570
+ }),
571
+ []
572
+ );
573
+ fe(N, O, [O]);
574
+ const pe = E(
575
+ () => O(),
576
+ [O]
577
+ );
578
+ Ee(Pe, pe, e), L(() => {
579
+ var g, C;
580
+ const s = $.current && !V;
581
+ if ($.current = V, !V) {
582
+ if (s) {
583
+ (g = z.current) == null || g.jumpTo(o, i);
584
+ return;
585
+ }
586
+ D || (C = z.current) == null || C.panTo(o);
587
+ }
588
+ }, [o.lat, o.lng, D, V]), L(() => {
589
+ var s;
590
+ V || (s = z.current) == null || s.setZoom(i);
591
+ }, [i, V]);
592
+ const [ue, U] = Y(!1), X = p || ue;
593
+ F.current = X, W.current = a ?? null, J.current = (r ?? []).length;
594
+ const me = T(() => {
595
+ if (f) {
596
+ f(), U(!0);
597
+ return;
598
+ }
599
+ U(!0);
600
+ }, [f]);
601
+ return /* @__PURE__ */ l(
602
+ "div",
603
+ {
604
+ className: Ge({ size: t, surface: h, className: P }),
605
+ "data-component": "map-view",
606
+ "data-component-id": e ?? le,
607
+ role: "region",
608
+ "aria-label": w ?? R("mapView.label"),
609
+ ...G,
610
+ children: /* @__PURE__ */ l("div", { className: Ne({ size: t }), children: X ? (
611
+ // A provider failure shows the consent placeholder (its "Open in
612
+ // Google Maps" link needs no script) with "Load map" as the
613
+ // retry, instead of unmounting the host's React tree. The gate
614
+ // starts the provider only once Google's `core` and `maps`
615
+ // libraries have arrived.
616
+ /* @__PURE__ */ l(
617
+ Ie,
618
+ {
619
+ fallback: ({ reset: s }) => /* @__PURE__ */ l(
620
+ te,
621
+ {
622
+ address: c,
623
+ description: y ?? R("mapView.consentDescription"),
624
+ onLoadMap: s,
625
+ consentCta: void 0,
626
+ openInGoogleMapsHref: H
627
+ }
628
+ ),
629
+ children: /* @__PURE__ */ l(be, { libraries: ["maps"], pending: /* @__PURE__ */ l(se, {}), children: /* @__PURE__ */ l(
630
+ ye,
631
+ {
632
+ apiKey: n,
633
+ language: ae.language,
634
+ children: /* @__PURE__ */ l(He, { children: /* @__PURE__ */ S(
635
+ we,
636
+ {
637
+ defaultCenter: o,
638
+ defaultZoom: i,
639
+ mapId: v,
640
+ gestureHandling: "cooperative",
641
+ disableDefaultUI: !1,
642
+ onClick: () => j(null),
643
+ className: "ds:[inline-size:100%] ds:[block-size:100%]",
644
+ children: [
645
+ /* @__PURE__ */ l(
646
+ _e,
647
+ {
648
+ onHandleReady: de,
649
+ onMarkerSelect: j,
650
+ onCameraMove: _
651
+ }
652
+ ),
653
+ b ? /* @__PURE__ */ l(
654
+ je,
655
+ {
656
+ onBoundsChange: b,
657
+ userInteraction: B
658
+ }
659
+ ) : null,
660
+ m ? /* @__PURE__ */ l(
661
+ De,
662
+ {
663
+ points: Z,
664
+ fitKey: ie,
665
+ maxZoom: I,
666
+ onCameraMove: _
667
+ }
668
+ ) : null,
669
+ /* @__PURE__ */ l(Be, { children: (r ?? []).map((s) => {
670
+ const g = a != null && a === s.id, C = R("mapView.markerLabel", {
671
+ label: s.label ?? s.id
672
+ });
673
+ return v ? /* @__PURE__ */ l(
674
+ ve,
675
+ {
676
+ position: s.position,
677
+ title: C,
678
+ "aria-label": C,
679
+ "data-selected": g ? "true" : "false",
680
+ onClick: () => j(s.id),
681
+ children: /* @__PURE__ */ l(
682
+ ke,
683
+ {
684
+ background: "var(--primary)",
685
+ borderColor: "var(--primary)",
686
+ glyphColor: "var(--primary-foreground)"
687
+ }
688
+ )
689
+ },
690
+ s.id
691
+ ) : /* @__PURE__ */ l(
692
+ Me,
693
+ {
694
+ position: s.position,
695
+ title: C,
696
+ onClick: () => j(s.id)
697
+ },
698
+ s.id
699
+ );
700
+ }) })
701
+ ]
702
+ }
703
+ ) })
704
+ }
705
+ ) })
706
+ }
707
+ )
708
+ ) : /* @__PURE__ */ l(
709
+ te,
710
+ {
711
+ address: c,
712
+ description: y ?? R("mapView.consentDescription"),
713
+ onLoadMap: me,
714
+ consentCta: u,
715
+ openInGoogleMapsHref: H
716
+ }
717
+ ) })
718
+ }
719
+ );
720
+ }
721
+ );
722
+ Fe.displayName = "MapView";
723
+ export {
724
+ Fe as M
725
+ };
726
+ //# sourceMappingURL=map-view--c9bJDRw.js.map