@mapfirst.ai/react 0.0.15 → 0.0.16
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/README.md +231 -298
- package/dist/index.d.mts +96 -295
- package/dist/index.d.ts +96 -295
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/EXAMPLES.md +0 -740
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
1
|
import * as _mapfirst_ai_core from '@mapfirst.ai/core';
|
|
3
|
-
import { PropertyType, PriceLevel, MapFirstCore, BaseMapFirstOptions, MapState, Property, MapLibreNamespace, GoogleMapsNamespace, MapboxNamespace
|
|
2
|
+
import { PropertyType, PriceLevel, MapFirstCore, BaseMapFirstOptions, MapState, Property, MapLibreNamespace, GoogleMapsNamespace, MapboxNamespace } from '@mapfirst.ai/core';
|
|
4
3
|
export { ApiFiltersResponse, convertToApiFilters, processApiFilters } from '@mapfirst.ai/core';
|
|
5
4
|
import * as React$1 from 'react';
|
|
6
5
|
import React__default, { FunctionComponent, CSSProperties, ReactNode } from 'react';
|
|
@@ -93,7 +92,6 @@ declare const Chip: React__default.FC<ChipProps>;
|
|
|
93
92
|
|
|
94
93
|
interface FilterChipsProps {
|
|
95
94
|
filters: Filter[];
|
|
96
|
-
isPortrait: boolean;
|
|
97
95
|
currency: string;
|
|
98
96
|
minRatingSuffix: string;
|
|
99
97
|
clearAllLabel: string;
|
|
@@ -146,12 +144,6 @@ declare const useFilterScroll: (dependency: number) => {
|
|
|
146
144
|
scrollByDir: (dir: "prev" | "next") => void;
|
|
147
145
|
};
|
|
148
146
|
|
|
149
|
-
/**
|
|
150
|
-
* Hook to detect if the viewport is in portrait orientation.
|
|
151
|
-
* Updates on window resize.
|
|
152
|
-
*/
|
|
153
|
-
declare const useIsPortrait: () => boolean;
|
|
154
|
-
|
|
155
147
|
type Locale = "en" | "es" | "de" | "fr" | "it" | "pt";
|
|
156
148
|
type TranslationFunction = (key: string, params?: Record<string, any>) => string;
|
|
157
149
|
type FormatCurrencyFunction = (value: number, currency?: string) => string;
|
|
@@ -201,14 +193,24 @@ type SmartFilter = {
|
|
|
201
193
|
priceLevels?: any[];
|
|
202
194
|
};
|
|
203
195
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* Returns the instance and reactive state that updates when SDK state changes.
|
|
196
|
+
* Comprehensive hook for MapFirst SDK with all functionality in one place.
|
|
197
|
+
* Creates a MapFirstCore instance with reactive state and provides all necessary methods.
|
|
207
198
|
*
|
|
208
199
|
* @example
|
|
209
200
|
* ```tsx
|
|
210
|
-
* //
|
|
211
|
-
* const {
|
|
201
|
+
* // Initialize with location data
|
|
202
|
+
* const {
|
|
203
|
+
* instance,
|
|
204
|
+
* state,
|
|
205
|
+
* setPrimaryType,
|
|
206
|
+
* setSelectedMarker,
|
|
207
|
+
* propertiesSearch,
|
|
208
|
+
* smartFilterSearch,
|
|
209
|
+
* boundsSearch,
|
|
210
|
+
* attachMapLibre,
|
|
211
|
+
* attachGoogle,
|
|
212
|
+
* attachMapbox
|
|
213
|
+
* } = useMapFirst({
|
|
212
214
|
* initialLocationData: {
|
|
213
215
|
* city: "New York",
|
|
214
216
|
* country: "United States",
|
|
@@ -217,298 +219,97 @@ type SmartFilter = {
|
|
|
217
219
|
* });
|
|
218
220
|
*
|
|
219
221
|
* // Access reactive state
|
|
220
|
-
* console.log(state
|
|
221
|
-
* console.log(state
|
|
222
|
+
* console.log(state?.properties);
|
|
223
|
+
* console.log(state?.isSearching);
|
|
224
|
+
* console.log(state?.selectedPropertyId);
|
|
222
225
|
*
|
|
223
|
-
* //
|
|
226
|
+
* // Attach map when ready
|
|
224
227
|
* useEffect(() => {
|
|
225
|
-
* if (mapLibreInstance
|
|
226
|
-
*
|
|
227
|
-
* platform: "maplibre",
|
|
228
|
-
* maplibregl: maplibregl,
|
|
228
|
+
* if (mapLibreInstance) {
|
|
229
|
+
* attachMapLibre(mapLibreInstance, maplibregl, {
|
|
229
230
|
* onMarkerClick: (marker) => console.log(marker)
|
|
230
231
|
* });
|
|
231
232
|
* }
|
|
232
|
-
* }, [mapLibreInstance
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
declare function useMapFirstCore(options: BaseMapFirstOptions): {
|
|
236
|
-
mapFirst: MapFirstCore | null;
|
|
237
|
-
state: MapState | null;
|
|
238
|
-
};
|
|
239
|
-
/**
|
|
240
|
-
* Hook to access reactive properties from MapFirst SDK.
|
|
241
|
-
* Returns the current properties array that updates when properties change.
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```tsx
|
|
245
|
-
* const { mapFirst } = useMapFirstCore({ ... });
|
|
246
|
-
* const properties = useMapFirstProperties(mapFirst);
|
|
247
|
-
*
|
|
248
|
-
* return <div>Found {properties.length} properties</div>;
|
|
249
|
-
* ```
|
|
250
|
-
*/
|
|
251
|
-
declare function useMapFirstProperties(mapFirst: MapFirstCore | null): Property[];
|
|
252
|
-
/**
|
|
253
|
-
* Hook to access the selected property ID from MapFirst SDK.
|
|
254
|
-
* Returns the currently selected property ID that updates when selection changes.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```tsx
|
|
258
|
-
* const { mapFirst } = useMapFirstCore({ ... });
|
|
259
|
-
* const selectedId = useMapFirstSelectedProperty(mapFirst);
|
|
260
|
-
*
|
|
261
|
-
* return <div>Selected: {selectedId || 'None'}</div>;
|
|
262
|
-
* ```
|
|
263
|
-
*/
|
|
264
|
-
declare function useMapFirstSelectedProperty(mapFirst: MapFirstCore | null): number | null;
|
|
265
|
-
/**
|
|
266
|
-
* Hook to access and control the primary property type.
|
|
267
|
-
* Returns the current primary type and a setter function.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```tsx
|
|
271
|
-
* const { mapFirst } = useMapFirstCore({ ... });
|
|
272
|
-
* const [primaryType, setPrimaryType] = usePrimaryType(mapFirst);
|
|
273
|
-
*
|
|
274
|
-
* return (
|
|
275
|
-
* <select value={primaryType} onChange={(e) => setPrimaryType(e.target.value as PropertyType)}>
|
|
276
|
-
* <option value="Accommodation">Hotels</option>
|
|
277
|
-
* <option value="Restaurant">Restaurants</option>
|
|
278
|
-
* <option value="Attraction">Attractions</option>
|
|
279
|
-
* </select>
|
|
280
|
-
* );
|
|
281
|
-
* ```
|
|
282
|
-
*/
|
|
283
|
-
declare function usePrimaryType(mapFirst: MapFirstCore | null): [PropertyType, (type: PropertyType) => void];
|
|
284
|
-
/**
|
|
285
|
-
* Hook to access and control the selected marker.
|
|
286
|
-
* Returns the current selected marker ID and a setter function.
|
|
287
|
-
* Note: This hook requires the MapFirstCore instance. For simpler usage with reactive updates,
|
|
288
|
-
* use state.selectedPropertyId from useMapFirstCore instead.
|
|
289
|
-
*
|
|
290
|
-
* @example
|
|
291
|
-
* ```tsx
|
|
292
|
-
* const { mapFirst } = useMapFirstCore({ ... });
|
|
293
|
-
* const [selectedMarker, setSelectedMarker] = useSelectedMarker(mapFirst);
|
|
294
|
-
*
|
|
295
|
-
* return (
|
|
296
|
-
* <div>
|
|
297
|
-
* <p>Selected: {selectedMarker || 'None'}</p>
|
|
298
|
-
* <button onClick={() => setSelectedMarker(null)}>Clear Selection</button>
|
|
299
|
-
* </div>
|
|
300
|
-
* );
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
declare function useSelectedMarker(mapFirst: MapFirstCore | null): [number | null, (id: number | null) => void];
|
|
304
|
-
/**
|
|
305
|
-
* Hook for MapLibre GL JS integration.
|
|
306
|
-
* Automatically attaches the map when both the SDK instance and map are available.
|
|
307
|
-
*
|
|
308
|
-
* @example
|
|
309
|
-
* ```tsx
|
|
310
|
-
* const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: "Paris", country: "France" } });
|
|
311
|
-
* const mapRef = useRef<maplibregl.Map | null>(null);
|
|
312
|
-
*
|
|
313
|
-
* useMapLibreAttachment({
|
|
314
|
-
* mapFirst,
|
|
315
|
-
* map: mapRef.current,
|
|
316
|
-
* maplibregl: maplibregl,
|
|
317
|
-
* onMarkerClick: (marker) => console.log(marker)
|
|
318
|
-
* });
|
|
319
|
-
*
|
|
320
|
-
* // Access reactive state
|
|
321
|
-
* console.log(state?.properties);
|
|
322
|
-
* ```
|
|
323
|
-
*/
|
|
324
|
-
declare function useMapLibreAttachment({ mapFirst, map, maplibregl, onMarkerClick, }: {
|
|
325
|
-
mapFirst: MapFirstCore | null;
|
|
326
|
-
map: any | null;
|
|
327
|
-
maplibregl: MapLibreNamespace;
|
|
328
|
-
onMarkerClick?: (marker: Property) => void;
|
|
329
|
-
}): void;
|
|
330
|
-
/**
|
|
331
|
-
* Hook for Google Maps integration.
|
|
332
|
-
* Automatically attaches the map when both the SDK instance and map are available.
|
|
333
|
-
*
|
|
334
|
-
* @example
|
|
335
|
-
* ```tsx
|
|
336
|
-
* const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: "Tokyo", country: "Japan" } });
|
|
337
|
-
* const mapRef = useRef<google.maps.Map | null>(null);
|
|
233
|
+
* }, [mapLibreInstance]);
|
|
338
234
|
*
|
|
339
|
-
*
|
|
340
|
-
*
|
|
341
|
-
*
|
|
342
|
-
* google: window.google,
|
|
343
|
-
* onMarkerClick: (marker) => console.log(marker)
|
|
235
|
+
* // Use search methods
|
|
236
|
+
* await propertiesSearch.search({
|
|
237
|
+
* body: { city: "Paris", country: "France" }
|
|
344
238
|
* });
|
|
345
239
|
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
declare function useGoogleMapsAttachment({ mapFirst, map, google, onMarkerClick, }: {
|
|
351
|
-
mapFirst: MapFirstCore | null;
|
|
352
|
-
map: any | null;
|
|
353
|
-
google: GoogleMapsNamespace;
|
|
354
|
-
onMarkerClick?: (marker: Property) => void;
|
|
355
|
-
}): void;
|
|
356
|
-
/**
|
|
357
|
-
* Hook for Mapbox GL JS integration.
|
|
358
|
-
* Automatically attaches the map when both the SDK instance and map are available.
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
* ```tsx
|
|
362
|
-
* const { mapFirst, state } = useMapFirstCore({ initialLocationData: { city: "London", country: "United Kingdom" } });
|
|
363
|
-
* const mapRef = useRef<mapboxgl.Map | null>(null);
|
|
364
|
-
*
|
|
365
|
-
* useMapboxAttachment({
|
|
366
|
-
* mapFirst,
|
|
367
|
-
* map: mapRef.current,
|
|
368
|
-
* mapboxgl: mapboxgl,
|
|
369
|
-
* onMarkerClick: (marker) => console.log(marker)
|
|
240
|
+
* await smartFilterSearch.search({
|
|
241
|
+
* query: "hotels near beach with pool"
|
|
370
242
|
* });
|
|
371
243
|
*
|
|
372
|
-
*
|
|
373
|
-
* console.log(state?.filters);
|
|
374
|
-
* ```
|
|
375
|
-
*/
|
|
376
|
-
declare function useMapboxAttachment({ mapFirst, map, mapboxgl, onMarkerClick, }: {
|
|
377
|
-
mapFirst: MapFirstCore | null;
|
|
378
|
-
map: any | null;
|
|
379
|
-
mapboxgl: MapboxNamespace;
|
|
380
|
-
onMarkerClick?: (marker: Property) => void;
|
|
381
|
-
}): void;
|
|
382
|
-
/**
|
|
383
|
-
* Legacy hook that creates the MapFirstCore instance with a map immediately.
|
|
384
|
-
* Use useMapFirstCore + useMap*Attachment hooks for better control.
|
|
385
|
-
*
|
|
386
|
-
* @deprecated Use useMapFirstCore and platform-specific attachment hooks instead
|
|
387
|
-
*/
|
|
388
|
-
declare function useMapFirst(options: MapFirstOptions | null): React__default.RefObject<MapFirstCore | null>;
|
|
389
|
-
/**
|
|
390
|
-
* Hook to run properties search with the MapFirst SDK.
|
|
391
|
-
* Returns a function to trigger the search and loading state.
|
|
392
|
-
*
|
|
393
|
-
* @example
|
|
394
|
-
* ```tsx
|
|
395
|
-
* const { mapFirst } = useMapFirstCore({ ... });
|
|
396
|
-
* const { search, isLoading, error } = usePropertiesSearch(mapFirst);
|
|
397
|
-
*
|
|
398
|
-
* const handleSearch = async () => {
|
|
399
|
-
* await search({
|
|
400
|
-
* body: {
|
|
401
|
-
* city: "Paris",
|
|
402
|
-
* country: "France",
|
|
403
|
-
* filters: {
|
|
404
|
-
* checkIn: new Date(),
|
|
405
|
-
* checkOut: new Date(Date.now() + 86400000),
|
|
406
|
-
* numAdults: 2,
|
|
407
|
-
* numRooms: 1
|
|
408
|
-
* }
|
|
409
|
-
* }
|
|
410
|
-
* });
|
|
411
|
-
* };
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
declare function usePropertiesSearch(mapFirst: MapFirstCore | null): {
|
|
415
|
-
search: (options: {
|
|
416
|
-
body: InitialRequestBody;
|
|
417
|
-
beforeApplyProperties?: (data: any) => {
|
|
418
|
-
price?: any;
|
|
419
|
-
limit?: number;
|
|
420
|
-
};
|
|
421
|
-
smartFiltersClearable?: boolean;
|
|
422
|
-
}) => Promise<{
|
|
423
|
-
location_id?: number;
|
|
424
|
-
filters: _mapfirst_ai_core.FilterSchema;
|
|
425
|
-
properties: Property[];
|
|
426
|
-
isComplete: boolean | undefined;
|
|
427
|
-
pollingLink: string | undefined;
|
|
428
|
-
durationSeconds: number;
|
|
429
|
-
} | null>;
|
|
430
|
-
isLoading: boolean;
|
|
431
|
-
error: Error | null;
|
|
432
|
-
};
|
|
433
|
-
/**
|
|
434
|
-
* Hook to run smart filter search with the MapFirst SDK.
|
|
435
|
-
* Returns a function to trigger the search and loading state.
|
|
436
|
-
*
|
|
437
|
-
* @example
|
|
438
|
-
* ```tsx
|
|
439
|
-
* const { mapFirst } = useMapFirstCore({ ... });
|
|
440
|
-
* const { search, isLoading, error } = useSmartFilterSearch(mapFirst);
|
|
441
|
-
*
|
|
442
|
-
* const handleSearch = async () => {
|
|
443
|
-
* await search({
|
|
444
|
-
* query: "hotels near beach with pool"
|
|
445
|
-
* });
|
|
446
|
-
* };
|
|
447
|
-
*
|
|
448
|
-
* // Or with filters
|
|
449
|
-
* const handleFilterSearch = async () => {
|
|
450
|
-
* await search({
|
|
451
|
-
* filters: [
|
|
452
|
-
* { id: "pool", label: "Pool", type: "amenity", value: "pool" },
|
|
453
|
-
* { id: "4star", label: "4 Star", type: "starRating", value: "4", numericValue: 4 }
|
|
454
|
-
* ]
|
|
455
|
-
* });
|
|
456
|
-
* };
|
|
457
|
-
* ```
|
|
458
|
-
*/
|
|
459
|
-
declare function useSmartFilterSearch(mapFirst: MapFirstCore | null): {
|
|
460
|
-
search: (options: {
|
|
461
|
-
query?: string;
|
|
462
|
-
filters?: SmartFilter[];
|
|
463
|
-
onProcessFilters?: (filters: any, location_id?: number) => {
|
|
464
|
-
smartFilters?: SmartFilter[];
|
|
465
|
-
price?: any;
|
|
466
|
-
limit?: number;
|
|
467
|
-
language?: string;
|
|
468
|
-
};
|
|
469
|
-
}) => Promise<{
|
|
470
|
-
location_id?: number;
|
|
471
|
-
filters: _mapfirst_ai_core.FilterSchema;
|
|
472
|
-
properties: Property[];
|
|
473
|
-
isComplete: boolean | undefined;
|
|
474
|
-
pollingLink: string | undefined;
|
|
475
|
-
durationSeconds: number;
|
|
476
|
-
} | null>;
|
|
477
|
-
isLoading: boolean;
|
|
478
|
-
error: Error | null;
|
|
479
|
-
};
|
|
480
|
-
/**
|
|
481
|
-
* Hook to perform a bounds search when the user moves the map
|
|
482
|
-
*
|
|
483
|
-
* @example
|
|
484
|
-
* ```tsx
|
|
485
|
-
* const { mapFirst, state } = useMapFirstCore({ ... });
|
|
486
|
-
* const { performBoundsSearch, isSearching } = useMapFirstBoundsSearch(mapFirst);
|
|
487
|
-
*
|
|
488
|
-
* // When user clicks "Search this area" button
|
|
489
|
-
* <button onClick={performBoundsSearch} disabled={!state.pendingBounds || isSearching}>
|
|
490
|
-
* Search this area
|
|
491
|
-
* </button>
|
|
244
|
+
* await boundsSearch.perform();
|
|
492
245
|
* ```
|
|
493
246
|
*/
|
|
494
|
-
declare function
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
247
|
+
declare function useMapFirst(options: BaseMapFirstOptions): {
|
|
248
|
+
instance: MapFirstCore | null;
|
|
249
|
+
state: MapState | null;
|
|
250
|
+
setPrimaryType: (type: PropertyType) => void;
|
|
251
|
+
setSelectedMarker: (id: number | null) => void;
|
|
252
|
+
propertiesSearch: {
|
|
253
|
+
search: (options: {
|
|
254
|
+
body: InitialRequestBody;
|
|
255
|
+
beforeApplyProperties?: (data: any) => {
|
|
256
|
+
price?: any;
|
|
257
|
+
limit?: number;
|
|
258
|
+
};
|
|
259
|
+
smartFiltersClearable?: boolean;
|
|
260
|
+
}) => Promise<{
|
|
261
|
+
location_id?: number;
|
|
262
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
263
|
+
properties: Property[];
|
|
264
|
+
isComplete: boolean | undefined;
|
|
265
|
+
pollingLink: string | undefined;
|
|
266
|
+
durationSeconds: number;
|
|
267
|
+
} | null>;
|
|
268
|
+
isLoading: boolean;
|
|
269
|
+
error: Error | null;
|
|
270
|
+
};
|
|
271
|
+
smartFilterSearch: {
|
|
272
|
+
search: (options: {
|
|
273
|
+
query?: string;
|
|
274
|
+
filters?: SmartFilter[];
|
|
275
|
+
onProcessFilters?: (filters: any, location_id?: number) => {
|
|
276
|
+
smartFilters?: SmartFilter[];
|
|
277
|
+
price?: any;
|
|
278
|
+
limit?: number;
|
|
279
|
+
language?: string;
|
|
280
|
+
};
|
|
281
|
+
}) => Promise<{
|
|
282
|
+
location_id?: number;
|
|
283
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
284
|
+
properties: Property[];
|
|
285
|
+
isComplete: boolean | undefined;
|
|
286
|
+
pollingLink: string | undefined;
|
|
287
|
+
durationSeconds: number;
|
|
288
|
+
} | null>;
|
|
289
|
+
isLoading: boolean;
|
|
290
|
+
error: Error | null;
|
|
291
|
+
};
|
|
292
|
+
boundsSearch: {
|
|
293
|
+
perform: () => Promise<{
|
|
294
|
+
location_id?: number;
|
|
295
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
296
|
+
properties: Property[];
|
|
297
|
+
isComplete: boolean | undefined;
|
|
298
|
+
pollingLink: string | undefined;
|
|
299
|
+
durationSeconds: number;
|
|
300
|
+
} | null>;
|
|
301
|
+
isSearching: boolean;
|
|
302
|
+
error: Error | null;
|
|
303
|
+
};
|
|
304
|
+
attachMapLibre: (map: any, maplibregl: MapLibreNamespace, options?: {
|
|
305
|
+
onMarkerClick?: (marker: Property) => void;
|
|
306
|
+
}) => void;
|
|
307
|
+
attachGoogle: (map: any, google: GoogleMapsNamespace, options?: {
|
|
308
|
+
onMarkerClick?: (marker: Property) => void;
|
|
309
|
+
}) => void;
|
|
310
|
+
attachMapbox: (map: any, mapboxgl: MapboxNamespace, options?: {
|
|
311
|
+
onMarkerClick?: (marker: Property) => void;
|
|
312
|
+
}) => void;
|
|
505
313
|
};
|
|
506
|
-
/**
|
|
507
|
-
* Helper component that simply renders the markers it receives so non-React environments
|
|
508
|
-
* can verify data flows before wiring the SDK into a map.
|
|
509
|
-
*/
|
|
510
|
-
declare function MarkerDebugList({ markers }: {
|
|
511
|
-
markers: Property[];
|
|
512
|
-
}): react_jsx_runtime.JSX.Element;
|
|
513
314
|
|
|
514
|
-
export { Chip, type ChipProps, CloseIcon, EditIcon, type Filter, FilterChips, type FilterChipsProps, type IconProps, type Locale,
|
|
315
|
+
export { Chip, type ChipProps, CloseIcon, EditIcon, type Filter, FilterChips, type FilterChipsProps, type IconProps, type Locale, MinRatingFilterChip, NextIcon, PriceRangeFilterChip, type PriceRangeValue, RestaurantPriceLevelChip, type RestaurantPriceLevelChipProps, SearchIcon, SmartFilter$1 as SmartFilter, type SmartFilterProps, StarIcon, TransformedQueryChip, type TransformedQueryChipProps, createMinRatingFilterLabel, createPriceRangeFilterLabel, formatRatingValue, renderStars, useFilterScroll, useMapFirst, useTranslation };
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var Ee=Object.create;var J=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var He=(e,t)=>{for(var o in t)J(e,o,{get:t[o],enumerable:!0})},xe=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ie(t))!Be.call(e,s)&&s!==o&&J(e,s,{get:()=>t[s],enumerable:!(i=Me(t,s))||i.enumerable});return e};var fe=(e,t,o)=>(o=e!=null?Ee(Te(e)):{},xe(t||!e||!e.__esModule?J(o,"default",{value:e,enumerable:!0}):o,e)),Ne=e=>xe(J({},"__esModule",{value:!0}),e);var xt={};He(xt,{Chip:()=>te,CloseIcon:()=>ge,EditIcon:()=>G,FilterChips:()=>ce,MarkerDebugList:()=>St,MinRatingFilterChip:()=>Y,NextIcon:()=>ee,PriceRangeFilterChip:()=>oe,RestaurantPriceLevelChip:()=>ie,SearchIcon:()=>$,SmartFilter:()=>Le,StarIcon:()=>ye,TransformedQueryChip:()=>se,convertToApiFilters:()=>de.convertToApiFilters,createMinRatingFilterLabel:()=>_e,createPriceRangeFilterLabel:()=>Ve,formatRatingValue:()=>re,processApiFilters:()=>de.processApiFilters,renderStars:()=>ve,useFilterScroll:()=>ae,useGoogleMapsAttachment:()=>mt,useIsPortrait:()=>ue,useMapFirst:()=>gt,useMapFirstBoundsSearch:()=>bt,useMapFirstCore:()=>at,useMapFirstProperties:()=>lt,useMapFirstSelectedProperty:()=>ct,useMapLibreAttachment:()=>dt,useMapboxAttachment:()=>ft,usePrimaryType:()=>pt,usePropertiesSearch:()=>yt,useSelectedMarker:()=>ut,useSmartFilterSearch:()=>ht,useTranslation:()=>E});module.exports=Ne(xt);var m=fe(require("react")),Se=require("@mapfirst.ai/core"),de=require("@mapfirst.ai/core");var q=require("react");var le=fe(require("react"));var Ce=fe(require("react"));var w=require("react/jsx-runtime"),$=({className:e,style:t})=>(0,w.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,w.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,w.jsx)("path",{d:"m21 21-4.35-4.35"})]}),ge=({className:e,style:t})=>(0,w.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,w.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,w.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),G=({className:e,style:t})=>(0,w.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,w.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,w.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),ee=({className:e,style:t})=>(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,w.jsx)("polyline",{points:"9 18 15 12 9 6"})}),ye=({className:e,style:t,fill:o="none"})=>(0,w.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:o,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,w.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});var he=require("react/jsx-runtime"),De={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},Ae={width:"17px",height:"17px"},H=({onClick:e,style:t})=>{let[o,i]=Ce.default.useState(!1);return(0,he.jsx)("button",{style:{...De,backgroundColor:o?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),"aria-label":"Remove filter",children:(0,he.jsx)(ge,{style:Ae})})};var _=require("react/jsx-runtime"),ze={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},te=({label:e,icon:t,remove:o,style:i})=>(0,_.jsxs)("div",{style:{...ze,...i},children:[t&&(0,_.jsx)("span",{style:{display:"flex",alignItems:"center"},children:t}),(0,_.jsx)("span",{style:{whiteSpace:"nowrap"},children:e}),(0,_.jsx)(H,{onClick:o})]});var Pe=require("react");var U=require("react"),Oe={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},We=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),E=(e,t)=>{let[o,i]=(0,U.useState)("en"),s=(0,U.useCallback)((u,p)=>{let n={...Oe,...e}[u]||u;return p&&Object.keys(p).forEach(a=>{n=n.replace(new RegExp(`{{${a}}}`,"g"),String(p[a]))}),n},[e]),d=(0,U.useCallback)((u,p)=>t?t(u,p):We(u,p),[t]);return{t:s,locale:o,setLocale:i,formatCurrency:d}};var W=require("react/jsx-runtime"),ve=e=>{let t=[],o=Math.floor(e),i=e%1!==0,s={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},d={...s,backgroundColor:"#03852e"},u={...s,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let r=0;r<o;r+=1)t.push((0,W.jsx)("span",{style:d},`full-${r}`));i&&t.push((0,W.jsx)("span",{style:u},"half"));let p=Math.max(0,5-Math.ceil(e));for(let r=0;r<p;r+=1)t.push((0,W.jsx)("span",{style:s},`empty-${r}`));return t},_e=(e,t)=>(0,W.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,W.jsx)("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:ve(e)})," ",t]}),re=e=>e.toFixed(1),Ve=(e,t,o,i)=>`${i(e,o)} - ${i(t!=null?t:0,o)}`;var L=require("react/jsx-runtime"),qe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},Qe={display:"flex",gap:"1px",userSelect:"none"},be={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},ne={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},Y=({rating:e,onChange:t,onRemove:o,star:i=!1})=>{let[s,d]=(0,Pe.useState)(null),{t:u}=E(),p=s!=null?s:e,r=g=>i&&g?g.toString():u("smartFilter.minRating.label",{value:re(g)}),n=u("smartFilter.minRating.remove"),a=g=>u("smartFilter.minRating.setTo",{rating:re(g)}),c=g=>{let b=g+1;return p>=b?"full":p>=b-.5?"half":"empty"},f=g=>{d(null),g!==e&&t(g)},v=g=>{var y;let b=g.relatedTarget;(!b||!((y=g.currentTarget.closest("[data-min-rating-chip]"))!=null&&y.contains(b)))&&d(null)};return(0,L.jsxs)("div",{style:qe,"data-min-rating-chip":!0,children:[(0,L.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>d(null),children:[(0,L.jsx)("div",{style:Qe,children:Array.from({length:5}).map((g,b)=>{let y=c(b),h=b+1,P=h-.5;if(i)return(0,L.jsxs)("div",{style:{position:"relative",width:"16px",height:"16px"},children:[(0,L.jsx)(ye,{fill:p>=h?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),(0,L.jsx)("button",{type:"button",style:{...ne,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>d(P),onFocus:()=>d(P),onBlur:v,onClick:()=>f(P),"aria-label":a(P),title:r(P)}),(0,L.jsx)("button",{type:"button",style:{...ne,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>d(h),onFocus:()=>d(h),onBlur:v,onClick:()=>f(h),"aria-label":a(h),title:r(h)})]},b);let R=y==="full"?{...be,backgroundColor:"#03852e"}:be,O={...be,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return(0,L.jsxs)("div",{style:{position:"relative",width:"12px",height:"12px"},children:[(0,L.jsx)("span",{style:y==="half"?O:R}),(0,L.jsx)("button",{type:"button",style:{...ne,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>d(P),onFocus:()=>d(P),onBlur:v,onClick:()=>f(P),"aria-label":a(P),title:r(P)}),(0,L.jsx)("button",{type:"button",style:{...ne,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>d(h),onFocus:()=>d(h),onBlur:v,onClick:()=>f(h),"aria-label":a(h),title:r(h)})]},b)})}),(0,L.jsx)("span",{style:{whiteSpace:"nowrap"},children:r(p)})]}),(0,L.jsx)(H,{onClick:o})]})};var V=require("react");var F=require("react/jsx-runtime"),Ke={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},$e={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},Ge={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},ke=({boundary:e,label:t,value:o,placeholder:i,currency:s,isOptional:d=!1,showRemoveButton:u=!1,removeLabel:p,editLabel:r,showAddWhenEmpty:n=!1,onCommit:a,onRemove:c})=>{let[f,v]=(0,V.useState)(o!==void 0?String(o):""),[g,b]=(0,V.useState)(!1),[y,h]=(0,V.useState)(!1),P=o!==void 0;(0,V.useEffect)(()=>{v(o!==void 0?String(o):""),b(!1)},[o]);let R=()=>{v(o!==void 0?String(o):"")},O=()=>{if(f.trim()===""){if(d){a(void 0),v("");return}R();return}let l=Number(f);if(!Number.isFinite(l)){R();return}let M=Math.max(0,l);if(M===o){R();return}a(M)};return(0,F.jsxs)("div",{style:Ke,children:[(0,F.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),g?(0,F.jsx)("input",{value:f,onChange:l=>{let M=l.target.value.replace(/[^\d]/g,"");v(M)},onBlur:()=>{O(),b(!1)},onKeyDown:l=>{if(l.key==="Enter"){l.preventDefault(),l.currentTarget.blur(),b(!1);return}if(l.key==="Escape"){l.preventDefault(),R(),l.currentTarget.blur(),b(!1);return}l.key.length===1&&/[0-9]/.test(l.key)||l.key==="Backspace"||l.key==="Delete"||l.key==="Tab"||l.key==="ArrowLeft"||l.key==="ArrowRight"||l.key==="Home"||l.key==="End"||l.preventDefault()},placeholder:i,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:$e,autoFocus:!0}):P?(0,F.jsxs)("span",{style:{fontSize:"16px"},children:[s,o]}):n?(0,F.jsx)("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>b(!0),"aria-label":r,children:"+"}):(0,F.jsx)("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!n||n&&g)&&(0,F.jsx)("span",{style:{color:"#737373",fontSize:"12px"},children:s}),!g&&(!n||P)&&(0,F.jsx)("button",{type:"button",style:{...Ge,backgroundColor:y?"#e5e5e5":"transparent"},"aria-label":r,title:r,onClick:()=>b(!0),onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:(0,F.jsx)(G,{})}),u&&(0,F.jsx)(H,{onClick:c})]})},oe=({priceRange:e,currency:t,onChange:o,onRemove:i})=>{let{t:s}=E(),d="Min",u="Max",p=s("smartFilter.priceRange.remove"),r=s("smartFilter.priceRange.edit"),n=(a,c)=>{let f={min:e.min,max:e.max};a==="min"?(f.min=c,c!==void 0&&e.max!==void 0&&c>e.max&&(f.max=c)):(f.max=c,c!==void 0&&e.min!==void 0&&c<e.min&&(f.min=c)),(f.min!==e.min||f.max!==e.max)&&o(f)};return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(ke,{boundary:"min",label:d,value:e.min,currency:t,editLabel:r,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:a=>n("min",a),onRemove:i}),(0,F.jsx)(ke,{boundary:"max",label:u,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:p,editLabel:r,showAddWhenEmpty:!0,onCommit:a=>n("max",a),onRemove:i})]})};var T=require("react/jsx-runtime"),Ue={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},Fe=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],ie=({values:e,onChange:t,onRemove:o})=>{let{t:i}=E(),s=i("smartFilter.restaurantPriceLevel.label"),d=i("smartFilter.restaurantPriceLevel.remove"),u=i("smartFilter.restaurantPriceLevel.none"),p=r=>{let{value:n,checked:a}=r.target,c=n,f=new Set(e);a?f.add(c):f.delete(c);let v=Fe.filter(g=>f.has(g.value)).map(g=>g.value);t(v)};return(0,T.jsxs)("div",{style:Ue,children:[(0,T.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,T.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:s}),(0,T.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[Fe.map(r=>{let n=i(`smartFilter.restaurantPriceLevel.options.${r.key}`),a=`price-level-${r.key}`;return(0,T.jsxs)("label",{htmlFor:a,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[(0,T.jsx)("input",{id:a,type:"checkbox",value:r.value,checked:e.includes(r.value),onChange:p,style:{accentColor:"#03852e",cursor:"pointer"}}),(0,T.jsx)("span",{children:n})]},r.value)}),e.length===0&&(0,T.jsx)("span",{style:{fontSize:"12px",color:"#737373"},children:u})]})]}),(0,T.jsx)(H,{onClick:o})]})};var z=require("react");var D=require("react/jsx-runtime"),Ye={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},Ze={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},je={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},se=({value:e,onChange:t,onRemove:o})=>{let i=(0,z.useRef)(null),[s,d]=(0,z.useState)(e),[u,p]=(0,z.useState)(!1),[r,n]=(0,z.useState)(!1),{t:a}=E(),c=a("smartFilter.transformedQuery.remove"),f=a("smartFilter.transformedQuery.edit");(0,z.useEffect)(()=>{d(e),p(!1)},[e]);let v=()=>{let y=s.trim();if(!y.length){d(e);return}y!==e&&t(y)};return(0,D.jsxs)("div",{style:Ye,children:[(0,D.jsx)($,{style:{width:"16px",height:"16px",color:"#03852e"}}),u?(0,D.jsx)("input",{ref:i,value:s,onChange:y=>{d(y.target.value)},onBlur:()=>{v(),p(!1)},onKeyDown:y=>{if(y.key==="Enter"){y.preventDefault(),y.currentTarget.blur();return}if(y.key==="Escape"){y.preventDefault(),d(e),y.currentTarget.blur();return}},"aria-label":f,style:Ze,autoFocus:!0}):(0,D.jsx)("span",{style:{fontSize:"16px"},children:e}),!u&&(0,D.jsx)("button",{type:"button",style:{...je,backgroundColor:r?"#e5e5e5":"transparent"},"aria-label":f,title:f,onClick:()=>p(!0),onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:(0,D.jsx)(G,{})}),(0,D.jsx)(H,{onClick:o})]})};var N=require("react"),ae=e=>{let t=(0,N.useRef)(null),[o,i]=(0,N.useState)(!0),[s,d]=(0,N.useState)(!0),u=(0,N.useCallback)(()=>{let r=t.current;if(!r){i(!0),d(!0);return}let{scrollLeft:n,scrollWidth:a,clientWidth:c}=r;i(n<=0),d(n+c>=a-1)},[]);(0,N.useEffect)(()=>{let r=t.current;if(u(),!r)return;let n=()=>u();return r.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",u),()=>{r.removeEventListener("scroll",n),window.removeEventListener("resize",u)}},[e,u]);let p=(0,N.useCallback)(r=>{let n=t.current;if(!n)return;let a=n.clientWidth*.7;n.scrollBy({left:r==="next"?a:-a,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:o,atEnd:s,scrollByDir:p}};var C=require("react/jsx-runtime"),Xe={position:"relative",width:"100%"},Je={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},Re={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},we={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},ce=({filters:e,isPortrait:t,currency:o,minRatingSuffix:i,clearAllLabel:s,previousFiltersLabel:d,nextFiltersLabel:u,formatCurrency:p,onFilterChange:r,onResetFilters:n,onClearAll:a})=>{let{scrollerRef:c,atStart:f,atEnd:v,scrollByDir:g}=ae(e.length),{t:b}=E(),[y,h]=le.default.useState(null),[P,R]=le.default.useState(!1),[O,K]=le.default.useState(!1),Z={...Je,padding:t?"8px 16px":"8px"};return(0,C.jsxs)("div",{style:Xe,children:[(0,C.jsxs)("div",{ref:c,style:{...Z,WebkitOverflowScrolling:"touch"},children:[(0,C.jsx)("style",{children:`
|
|
1
|
+
"use strict";var Ee=Object.create;var J=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Ne=(e,t)=>{for(var i in t)J(e,i,{get:t[i],enumerable:!0})},Se=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ie(t))!Be.call(e,a)&&a!==i&&J(e,a,{get:()=>t[a],enumerable:!(r=Me(t,a))||r.enumerable});return e};var ue=(e,t,i)=>(i=e!=null?Ee(Te(e)):{},Se(t||!e||!e.__esModule?J(i,"default",{value:e,enumerable:!0}):i,e)),He=e=>Se(J({},"__esModule",{value:!0}),e);var lt={};Ne(lt,{Chip:()=>te,CloseIcon:()=>me,EditIcon:()=>Z,FilterChips:()=>le,MinRatingFilterChip:()=>X,NextIcon:()=>ee,PriceRangeFilterChip:()=>oe,RestaurantPriceLevelChip:()=>ie,SearchIcon:()=>de,SmartFilter:()=>Le,StarIcon:()=>ge,TransformedQueryChip:()=>ae,convertToApiFilters:()=>ce.convertToApiFilters,createMinRatingFilterLabel:()=>_e,createPriceRangeFilterLabel:()=>We,formatRatingValue:()=>re,processApiFilters:()=>ce.processApiFilters,renderStars:()=>xe,useFilterScroll:()=>se,useMapFirst:()=>st,useTranslation:()=>D});module.exports=He(lt);var L=ue(require("react")),we=require("@mapfirst.ai/core"),ce=require("@mapfirst.ai/core");var Y=require("react");var he=ue(require("react"));var Ce=ue(require("react"));var N=require("react/jsx-runtime"),de=({className:e,style:t})=>(0,N.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,N.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,N.jsx)("path",{d:"m21 21-4.35-4.35"})]}),me=({className:e,style:t})=>(0,N.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,N.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,N.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),Z=({className:e,style:t})=>(0,N.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:[(0,N.jsx)("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),(0,N.jsx)("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),ee=({className:e,style:t})=>(0,N.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,N.jsx)("polyline",{points:"9 18 15 12 9 6"})}),ge=({className:e,style:t,fill:i="none"})=>(0,N.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:i,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,style:{width:"1em",height:"1em",...t},children:(0,N.jsx)("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})});var ye=require("react/jsx-runtime"),De={position:"absolute",top:"-8px",right:"-8px",padding:"2px",borderRadius:"50%",backgroundColor:"white",border:"1px solid #03852e",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},Ae={width:"17px",height:"17px"},V=({onClick:e,style:t})=>{let[i,r]=Ce.default.useState(!1);return(0,ye.jsx)("button",{style:{...De,backgroundColor:i?"#e5e5e5":"white",...t},onClick:e,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),"aria-label":"Remove filter",children:(0,ye.jsx)(me,{style:Ae})})};var G=require("react/jsx-runtime"),ze={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},te=({label:e,icon:t,remove:i,style:r})=>(0,G.jsxs)("div",{style:{...ze,...r},children:[t&&(0,G.jsx)("span",{style:{display:"flex",alignItems:"center"},children:t}),(0,G.jsx)("span",{style:{whiteSpace:"nowrap"},children:e}),(0,G.jsx)(V,{onClick:i})]});var ve=require("react");var j=require("react"),Oe={"smartFilter.typingPrompt":"Search for hotels, restaurants, or attractions...","smartFilter.nav.previous":"Previous filters","smartFilter.nav.next":"Next filters","smartFilter.toast.locationRequired":"Please select a location first","smartFilter.clearAll":"Clear all","smartFilter.minRating.suffix":"+","smartFilter.minRating.label":"{{value}}+","smartFilter.minRating.remove":"Remove rating filter","smartFilter.minRating.setTo":"Set rating to {{rating}}","smartFilter.priceRange.label":"Price Range","smartFilter.priceRange.remove":"Remove price filter","smartFilter.priceRange.edit":"Edit price","smartFilter.transformedQuery.remove":"Remove search query","smartFilter.transformedQuery.edit":"Edit search query","smartFilter.restaurantPriceLevel.label":"Price Level","smartFilter.restaurantPriceLevel.remove":"Remove price level filter","smartFilter.restaurantPriceLevel.none":"Any","smartFilter.restaurantPriceLevel.options.cheapEats":"Cheap Eats","smartFilter.restaurantPriceLevel.options.midRange":"Mid Range","smartFilter.restaurantPriceLevel.options.fineDining":"Fine Dining"},Ve=(e,t="USD")=>new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:0,maximumFractionDigits:0}).format(e),D=(e,t)=>{let[i,r]=(0,j.useState)("en"),a=(0,j.useCallback)((f,c)=>{let d={...Oe,...e}[f]||f;return c&&Object.keys(c).forEach(u=>{d=d.replace(new RegExp(`{{${u}}}`,"g"),String(c[u]))}),d},[e]),m=(0,j.useCallback)((f,c)=>t?t(f,c):Ve(f,c),[t]);return{t:a,locale:i,setLocale:r,formatCurrency:m}};var $=require("react/jsx-runtime"),xe=e=>{let t=[],i=Math.floor(e),r=e%1!==0,a={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},m={...a,backgroundColor:"#03852e"},f={...a,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};for(let s=0;s<i;s+=1)t.push((0,$.jsx)("span",{style:m},`full-${s}`));r&&t.push((0,$.jsx)("span",{style:f},"half"));let c=Math.max(0,5-Math.ceil(e));for(let s=0;s<c;s+=1)t.push((0,$.jsx)("span",{style:a},`empty-${s}`));return t},_e=(e,t)=>(0,$.jsxs)("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[(0,$.jsx)("span",{style:{display:"flex",gap:"1px",userSelect:"none"},children:xe(e)})," ",t]}),re=e=>e.toFixed(1),We=(e,t,i,r)=>`${r(e,i)} - ${r(t!=null?t:0,i)}`;var H=require("react/jsx-runtime"),qe={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",flexShrink:0,height:"34px"},Qe={display:"flex",gap:"1px",userSelect:"none"},fe={display:"block",width:"12px",height:"12px",borderRadius:"50%",border:"1px solid #03852e",pointerEvents:"none"},ne={position:"absolute",top:0,height:"100%",cursor:"pointer",backgroundColor:"transparent",border:"none",padding:0},X=({rating:e,onChange:t,onRemove:i,star:r=!1})=>{let[a,m]=(0,ve.useState)(null),{t:f}=D(),c=a!=null?a:e,s=C=>r&&C?C.toString():f("smartFilter.minRating.label",{value:re(C)}),d=f("smartFilter.minRating.remove"),u=C=>f("smartFilter.minRating.setTo",{rating:re(C)}),P=C=>{let x=C+1;return c>=x?"full":c>=x-.5?"half":"empty"},h=C=>{m(null),C!==e&&t(C)},w=C=>{var v;let x=C.relatedTarget;(!x||!((v=C.currentTarget.closest("[data-min-rating-chip]"))!=null&&v.contains(x)))&&m(null)};return(0,H.jsxs)("div",{style:qe,"data-min-rating-chip":!0,children:[(0,H.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"4px"},onMouseLeave:()=>m(null),children:[(0,H.jsx)("div",{style:Qe,children:Array.from({length:5}).map((C,x)=>{let v=P(x),R=x+1,n=R-.5;if(r)return(0,H.jsxs)("div",{style:{position:"relative",width:"16px",height:"16px"},children:[(0,H.jsx)(ge,{fill:c>=R?"#03852e":"none",style:{width:"16px",height:"16px",pointerEvents:"none"}}),(0,H.jsx)("button",{type:"button",style:{...ne,left:0,width:"50%",borderRadius:"50% 0 0 50%"},onMouseEnter:()=>m(n),onFocus:()=>m(n),onBlur:w,onClick:()=>h(n),"aria-label":u(n),title:s(n)}),(0,H.jsx)("button",{type:"button",style:{...ne,left:"50%",width:"50%",borderRadius:"0 50% 50% 0"},onMouseEnter:()=>m(R),onFocus:()=>m(R),onBlur:w,onClick:()=>h(R),"aria-label":u(R),title:s(R)})]},x);let B=v==="full"?{...fe,backgroundColor:"#03852e"}:fe,A={...fe,background:"linear-gradient(90deg, #03852e 50%, transparent 50%)"};return(0,H.jsxs)("div",{style:{position:"relative",width:"12px",height:"12px"},children:[(0,H.jsx)("span",{style:v==="half"?A:B}),(0,H.jsx)("button",{type:"button",style:{...ne,left:0,width:"50%",borderRadius:"50% 0 0 50%",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(n),onFocus:()=>m(n),onBlur:w,onClick:()=>h(n),"aria-label":u(n),title:s(n)}),(0,H.jsx)("button",{type:"button",style:{...ne,left:"50%",width:"50%",borderRadius:"0 50% 50% 0",outline:"2px solid transparent",outlineOffset:"1px"},onMouseEnter:()=>m(R),onFocus:()=>m(R),onBlur:w,onClick:()=>h(R),"aria-label":u(R),title:s(R)})]},x)})}),(0,H.jsx)("span",{style:{whiteSpace:"nowrap"},children:s(c)})]}),(0,H.jsx)(V,{onClick:i})]})};var U=require("react");var I=require("react/jsx-runtime"),Ke={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,height:"34px"},$e={outline:"none",fontSize:"16px",backgroundColor:"transparent",borderRadius:"2px",padding:"2px 8px",width:"64px",textAlign:"center",border:"none"},Ge={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",border:"none",backgroundColor:"transparent",color:"#737373",display:"flex",alignItems:"center",justifyContent:"center"},ke=({boundary:e,label:t,value:i,placeholder:r,currency:a,isOptional:m=!1,showRemoveButton:f=!1,removeLabel:c,editLabel:s,showAddWhenEmpty:d=!1,onCommit:u,onRemove:P})=>{let[h,w]=(0,U.useState)(i!==void 0?String(i):""),[C,x]=(0,U.useState)(!1),[v,R]=(0,U.useState)(!1),n=i!==void 0;(0,U.useEffect)(()=>{w(i!==void 0?String(i):""),x(!1)},[i]);let B=()=>{w(i!==void 0?String(i):"")},A=()=>{if(h.trim()===""){if(m){u(void 0),w("");return}B();return}let l=Number(h);if(!Number.isFinite(l)){B();return}let k=Math.max(0,l);if(k===i){B();return}u(k)};return(0,I.jsxs)("div",{style:Ke,children:[(0,I.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:t}),C?(0,I.jsx)("input",{value:h,onChange:l=>{let k=l.target.value.replace(/[^\d]/g,"");w(k)},onBlur:()=>{A(),x(!1)},onKeyDown:l=>{if(l.key==="Enter"){l.preventDefault(),l.currentTarget.blur(),x(!1);return}if(l.key==="Escape"){l.preventDefault(),B(),l.currentTarget.blur(),x(!1);return}l.key.length===1&&/[0-9]/.test(l.key)||l.key==="Backspace"||l.key==="Delete"||l.key==="Tab"||l.key==="ArrowLeft"||l.key==="ArrowRight"||l.key==="Home"||l.key==="End"||l.preventDefault()},placeholder:r,inputMode:"numeric",pattern:"[0-9]*","aria-label":t,style:$e,autoFocus:!0}):n?(0,I.jsxs)("span",{style:{fontSize:"16px"},children:[a,i]}):d?(0,I.jsx)("button",{type:"button",style:{fontSize:"16px",color:"#737373",cursor:"pointer",border:"none",backgroundColor:"transparent",padding:0},onClick:()=>x(!0),"aria-label":s,children:"+"}):(0,I.jsx)("span",{style:{fontSize:"16px",color:"#737373"},children:"-"}),(!d||d&&C)&&(0,I.jsx)("span",{style:{color:"#737373",fontSize:"12px"},children:a}),!C&&(!d||n)&&(0,I.jsx)("button",{type:"button",style:{...Ge,backgroundColor:v?"#e5e5e5":"transparent"},"aria-label":s,title:s,onClick:()=>x(!0),onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),children:(0,I.jsx)(Z,{})}),f&&(0,I.jsx)(V,{onClick:P})]})},oe=({priceRange:e,currency:t,onChange:i,onRemove:r})=>{let{t:a}=D(),m="Min",f="Max",c=a("smartFilter.priceRange.remove"),s=a("smartFilter.priceRange.edit"),d=(u,P)=>{let h={min:e.min,max:e.max};u==="min"?(h.min=P,P!==void 0&&e.max!==void 0&&P>e.max&&(h.max=P)):(h.max=P,P!==void 0&&e.min!==void 0&&P<e.min&&(h.min=P)),(h.min!==e.min||h.max!==e.max)&&i(h)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(ke,{boundary:"min",label:m,value:e.min,currency:t,editLabel:s,showRemoveButton:e.min!==void 0&&e.min!==0,onCommit:u=>d("min",u),onRemove:r}),(0,I.jsx)(ke,{boundary:"max",label:f,value:e.max,currency:t,isOptional:!0,showRemoveButton:e.max!==void 0,removeLabel:c,editLabel:s,showAddWhenEmpty:!0,onCommit:u=>d("max",u),onRemove:r})]})};var z=require("react/jsx-runtime"),Ue={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"16px",flexShrink:0,height:"34px"},Fe=[{value:"Cheap Eats",key:"cheapEats"},{value:"Mid Range",key:"midRange"},{value:"Fine Dining",key:"fineDining"}],ie=({values:e,onChange:t,onRemove:i})=>{let{t:r}=D(),a=r("smartFilter.restaurantPriceLevel.label"),m=r("smartFilter.restaurantPriceLevel.remove"),f=r("smartFilter.restaurantPriceLevel.none"),c=s=>{let{value:d,checked:u}=s.target,P=d,h=new Set(e);u?h.add(P):h.delete(P);let w=Fe.filter(C=>h.has(C.value)).map(C=>C.value);t(w)};return(0,z.jsxs)("div",{style:Ue,children:[(0,z.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap"},children:[(0,z.jsx)("span",{style:{fontSize:"10px",textTransform:"uppercase",fontWeight:600,letterSpacing:"0.05em"},children:a}),(0,z.jsxs)("div",{style:{display:"flex",gap:"12px"},children:[Fe.map(s=>{let d=r(`smartFilter.restaurantPriceLevel.options.${s.key}`),u=`price-level-${s.key}`;return(0,z.jsxs)("label",{htmlFor:u,style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",cursor:"pointer"},children:[(0,z.jsx)("input",{id:u,type:"checkbox",value:s.value,checked:e.includes(s.value),onChange:c,style:{accentColor:"#03852e",cursor:"pointer"}}),(0,z.jsx)("span",{children:d})]},s.value)}),e.length===0&&(0,z.jsx)("span",{style:{fontSize:"12px",color:"#737373"},children:f})]})]}),(0,z.jsx)(V,{onClick:i})]})};var Q=require("react");var W=require("react/jsx-runtime"),Ye={position:"relative",backgroundColor:"white",color:"black",fontSize:"14px",borderRadius:"9999px",padding:"0 16px",paddingRight:"20px",border:"1px solid #03852e",display:"flex",alignItems:"center",gap:"8px",flexShrink:0,userSelect:"none",height:"34px"},Ze={backgroundColor:"#ececec",borderRadius:"2px",padding:"2px 8px",outline:"none",fontSize:"16px",minWidth:"8ch",border:"none"},je={padding:"4px",borderRadius:"50%",cursor:"pointer",transition:"background-color 0.2s",color:"#737373",border:"none",backgroundColor:"transparent",display:"flex",alignItems:"center",justifyContent:"center"},ae=({value:e,onChange:t,onRemove:i})=>{let r=(0,Q.useRef)(null),[a,m]=(0,Q.useState)(e),[f,c]=(0,Q.useState)(!1),[s,d]=(0,Q.useState)(!1),{t:u}=D(),P=u("smartFilter.transformedQuery.remove"),h=u("smartFilter.transformedQuery.edit");(0,Q.useEffect)(()=>{m(e),c(!1)},[e]);let w=()=>{let v=a.trim();if(!v.length){m(e);return}v!==e&&t(v)};return(0,W.jsxs)("div",{style:Ye,children:[(0,W.jsx)(de,{style:{width:"16px",height:"16px",color:"#03852e"}}),f?(0,W.jsx)("input",{ref:r,value:a,onChange:v=>{m(v.target.value)},onBlur:()=>{w(),c(!1)},onKeyDown:v=>{if(v.key==="Enter"){v.preventDefault(),v.currentTarget.blur();return}if(v.key==="Escape"){v.preventDefault(),m(e),v.currentTarget.blur();return}},"aria-label":h,style:Ze,autoFocus:!0}):(0,W.jsx)("span",{style:{fontSize:"16px"},children:e}),!f&&(0,W.jsx)("button",{type:"button",style:{...je,backgroundColor:s?"#e5e5e5":"transparent"},"aria-label":h,title:h,onClick:()=>c(!0),onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),children:(0,W.jsx)(Z,{})}),(0,W.jsx)(V,{onClick:i})]})};var _=require("react"),se=e=>{let t=(0,_.useRef)(null),[i,r]=(0,_.useState)(!0),[a,m]=(0,_.useState)(!0),f=(0,_.useCallback)(()=>{let s=t.current;if(!s){r(!0),m(!0);return}let{scrollLeft:d,scrollWidth:u,clientWidth:P}=s;r(d<=0),m(d+P>=u-1)},[]);(0,_.useEffect)(()=>{let s=t.current;if(f(),!s)return;let d=()=>f();return s.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",f),()=>{s.removeEventListener("scroll",d),window.removeEventListener("resize",f)}},[e,f]);let c=(0,_.useCallback)(s=>{let d=t.current;if(!d)return;let u=d.clientWidth*.7;d.scrollBy({left:s==="next"?u:-u,behavior:"smooth"})},[]);return{scrollerRef:t,atStart:i,atEnd:a,scrollByDir:c}};var M=require("react/jsx-runtime"),Xe={position:"relative",width:"100%"},Je={display:"flex",gap:"8px",overflowX:"auto",alignItems:"center",width:"100%",scrollbarWidth:"none",msOverflowStyle:"none"},Pe={pointerEvents:"none",position:"absolute",top:0,bottom:0,width:"40px"},Re={position:"absolute",top:"50%",transform:"translateY(-50%)",backgroundColor:"white",color:"#003c30",border:"1px solid #003c30",padding:"4px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",cursor:"pointer"},le=({filters:e,currency:t,minRatingSuffix:i,clearAllLabel:r,previousFiltersLabel:a,nextFiltersLabel:m,formatCurrency:f,onFilterChange:c,onResetFilters:s,onClearAll:d})=>{let{scrollerRef:u,atStart:P,atEnd:h,scrollByDir:w}=se(e.length),[C,x]=he.default.useState(null),[v,R]=he.default.useState(!1);return(0,M.jsxs)("div",{style:Xe,children:[(0,M.jsxs)("div",{ref:u,style:{...Je,padding:"8px",WebkitOverflowScrolling:"touch"},children:[(0,M.jsx)("style",{children:`
|
|
2
2
|
div::-webkit-scrollbar {
|
|
3
3
|
display: none;
|
|
4
4
|
}
|
|
5
|
-
`}),
|
|
5
|
+
`}),e.map(n=>{var A,K,q;let B=()=>(0,M.jsx)(te,{label:n.label,icon:n.icon,remove:()=>{c(e.filter(l=>l.id!==n.id))}},n.id);if(n.type==="minRating"){let l=(A=n.numericValue)!=null?A:Number(n.value);return Number.isFinite(l)?(0,M.jsx)(X,{rating:l,onChange:k=>{let E=e.map(T=>T.id===n.id?{...T,numericValue:k,value:String(k)}:T);c(E)},onRemove:()=>void c(e.filter(k=>k.id!==n.id))},n.id):B()}if(n.type==="starRating"){let l=(K=n.numericValue)!=null?K:Number(n.value);return Number.isFinite(l)?(0,M.jsx)(X,{star:!0,rating:l,onChange:k=>{let E=e.map(T=>T.id===n.id?{...T,numericValue:k,value:String(k)}:T);c(E)},onRemove:()=>void c(e.filter(k=>k.id!==n.id))},n.id):B()}return n.type==="priceRange"&&n.priceRange?(0,M.jsx)(oe,{priceRange:n.priceRange,currency:t,onChange:l=>{let k=e.map(E=>E.id===n.id?{...E,priceRange:l}:E);c(k)},onRemove:()=>void c(e.filter(l=>l.id!==n.id))},n.id):n.type==="transformed_query"?(0,M.jsx)(ae,{value:n.value,onChange:l=>{let k=e.map(E=>E.id===n.id?{...E,value:l}:E);c(k)},onRemove:()=>void c(e.filter(l=>l.id!==n.id))},n.id):n.type==="selected_restaurant_price_levels"?(0,M.jsx)(ie,{values:(q=n.priceLevels)!=null?q:[],onChange:l=>{let k=e.map(E=>E.id===n.id?{...E,priceLevels:l}:E);c(k)},onRemove:()=>void c(e.filter(l=>l.id!==n.id))},n.id):B()}),(0,M.jsx)("button",{style:{flexShrink:0,padding:"4px 16px",borderRadius:"9999px",cursor:"pointer",fontSize:"14px",userSelect:"none",backgroundColor:v?"#eee":"white",color:"black",border:"1px solid #03852e"},onClick:d,onMouseEnter:()=>R(!0),onMouseLeave:()=>R(!1),children:r})]}),!P&&(0,M.jsx)("div",{"aria-hidden":"true",style:{...Pe,left:0,background:"linear-gradient(to right, white, transparent)"}}),!h&&(0,M.jsx)("div",{"aria-hidden":"true",style:{...Pe,right:0,background:"linear-gradient(to left, white, transparent)"}}),!P&&(0,M.jsx)("button",{type:"button","aria-label":a,style:{...Re,left:"4px",transform:"translateY(-50%) rotate(180deg)",backgroundColor:C==="prev"?"#e5e5e5":"white"},onClick:()=>w("prev"),onMouseEnter:()=>x("prev"),onMouseLeave:()=>x(null),children:(0,M.jsx)(ee,{style:{width:"20px",height:"20px"}})}),!h&&(0,M.jsx)("button",{type:"button","aria-label":m,style:{...Re,right:"4px",backgroundColor:C==="next"?"#e5e5e5":"white"},onClick:()=>w("next"),onMouseEnter:()=>x("next"),onMouseLeave:()=>x(null),children:(0,M.jsx)(ee,{style:{width:"20px",height:"20px"}})})]})};var O=require("react/jsx-runtime"),et={position:"relative",display:"flex",flexDirection:"column",gap:"8px",width:"100%"},tt={position:"relative",display:"flex",alignItems:"center",gap:"8px",width:"100%"},rt={position:"relative",display:"flex",alignItems:"center",flex:1,backgroundColor:"white",borderRadius:"24px",border:"1px solid #e5e5e5",padding:"0 16px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},nt={flex:1,border:"none",outline:"none",fontSize:"16px",backgroundColor:"transparent",color:"#000",padding:"10px"},ot={position:"absolute",right:"16px",top:"50%",transform:"translateY(-50%)"},it={width:"20px",height:"20px",border:"2px solid #e5e5e5",borderTop:"2px solid #03852e",borderRadius:"50%",animation:"spin 1s linear infinite"},at={position:"absolute",padding:"10px",color:"#737373",pointerEvents:"none",fontSize:"16px"},Le=({mapFirst:e,filters:t,value:i,isSearching:r=!1,placeholder:a,onSearch:m,onFilterChange:f,onValueChange:c,showTypingPrompt:s=!0,customTranslations:d,currency:u="USD",style:P,inputStyle:h,containerStyle:w})=>{let[C,x]=(0,Y.useState)(""),v=i!==void 0?i:C,R=c||x,{t:n,formatCurrency:B}=D(d),A=n("smartFilter.minRating.suffix"),K=a||n("smartFilter.typingPrompt"),q=n("smartFilter.nav.previous"),l=n("smartFilter.nav.next"),k=n("smartFilter.clearAll"),E=async b=>{b.preventDefault();let y=v.trim();if(!(!y||r))try{await m(y)}catch(p){console.error("Search error:",p)}},T=(0,Y.useCallback)(async(b,y)=>{if(!r)try{await f(b)}catch(p){console.error("Filter change error:",p)}},[r,f]),pe=(0,Y.useCallback)(()=>{T([])},[T]),F=(0,Y.useCallback)(()=>{T([],!0),R("")},[T,R]);return(0,O.jsxs)("div",{style:{...et,...w},children:[(0,O.jsx)("style",{children:`
|
|
6
6
|
@keyframes spin {
|
|
7
7
|
0% { transform: rotate(0deg); }
|
|
8
8
|
100% { transform: rotate(360deg); }
|
|
9
9
|
}
|
|
10
|
-
`}),(0,
|
|
10
|
+
`}),t.length===0&&(0,O.jsx)("form",{onSubmit:E,style:{...tt,...P},children:(0,O.jsxs)("div",{style:rt,children:[(0,O.jsx)("input",{type:"text",value:v,onChange:b=>R(b.target.value),disabled:r,style:{...nt,...h},autoComplete:"off","aria-label":"Smart search"}),s&&v.length===0&&!r&&(0,O.jsx)("span",{style:at,children:K}),r&&(0,O.jsx)("div",{style:ot,children:(0,O.jsx)("div",{style:it})})]})}),t.length>0&&(0,O.jsx)(le,{filters:t,currency:u,minRatingSuffix:A,clearAllLabel:k,previousFiltersLabel:q,nextFiltersLabel:l,formatCurrency:B,onFilterChange:T,onResetFilters:pe,onClearAll:F})]})};function st(e){let t=L.default.useRef(null),[i,r]=L.default.useState(null),a=L.default.useRef(e);L.default.useEffect(()=>{a.current=e}),L.default.useEffect(()=>{let F=a.current,b={adapter:null,...F,callbacks:{...F.callbacks,onPropertiesChange:p=>{var o,g;r(S=>S?{...S,properties:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onPropertiesChange)==null||g.call(o,p)},onSelectedPropertyChange:p=>{var o,g;r(S=>S?{...S,selectedPropertyId:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onSelectedPropertyChange)==null||g.call(o,p)},onPrimaryTypeChange:p=>{var o,g;r(S=>S?{...S,primary:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onPrimaryTypeChange)==null||g.call(o,p)},onFiltersChange:p=>{var o,g;r(S=>S?{...S,filters:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onFiltersChange)==null||g.call(o,p)},onBoundsChange:p=>{var o,g;r(S=>S?{...S,bounds:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onBoundsChange)==null||g.call(o,p)},onPendingBoundsChange:p=>{var o,g;r(S=>S?{...S,pendingBounds:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onPendingBoundsChange)==null||g.call(o,p)},onCenterChange:(p,o)=>{var g,S;r(be=>be?{...be,center:p,zoom:o}:null),(S=(g=a.current.callbacks)==null?void 0:g.onCenterChange)==null||S.call(g,p,o)},onZoomChange:p=>{var o,g;r(S=>S?{...S,zoom:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onZoomChange)==null||g.call(o,p)},onActiveLocationChange:p=>{var o,g;r(S=>S?{...S,activeLocation:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onActiveLocationChange)==null||g.call(o,p)},onLoadingStateChange:p=>{var o,g;r(S=>S?{...S,initialLoading:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onLoadingStateChange)==null||g.call(o,p)},onSearchingStateChange:p=>{var o,g;r(S=>S?{...S,isSearching:p}:null),(g=(o=a.current.callbacks)==null?void 0:o.onSearchingStateChange)==null||g.call(o,p)}}},y=new we.MapFirstCore(b);return t.current=y,r(y.getState()),()=>{y.destroy(),t.current=null,r(null)}},[]);let m=L.default.useCallback(F=>{t.current&&t.current.setPrimaryType(F)},[]),f=L.default.useCallback(F=>{t.current&&t.current.setSelectedMarker(F)},[]),[c,s]=L.default.useState(!1),[d,u]=L.default.useState(null),P=L.default.useMemo(()=>({search:async F=>{if(!t.current){let b=new Error("MapFirst instance not available");throw u(b),b}s(!0),u(null);try{return await t.current.runPropertiesSearch({...F,onError:y=>{let p=y instanceof Error?y:new Error(String(y));u(p)}})}catch(b){let y=b instanceof Error?b:new Error(String(b));throw u(y),y}finally{s(!1)}},isLoading:c,error:d}),[c,d]),[h,w]=L.default.useState(!1),[C,x]=L.default.useState(null),v=L.default.useMemo(()=>({search:async F=>{if(!t.current){let b=new Error("MapFirst instance not available");throw x(b),b}w(!0),x(null);try{return await t.current.runSmartFilterSearch({...F,onError:y=>{let p=y instanceof Error?y:new Error(String(y));x(p)}})}catch(b){let y=b instanceof Error?b:new Error(String(b));throw x(y),y}finally{w(!1)}},isLoading:h,error:C}),[h,C]),[R,n]=L.default.useState(!1),[B,A]=L.default.useState(null),K=L.default.useMemo(()=>({perform:async()=>{if(!t.current)return null;n(!0),A(null);try{return await t.current.performBoundsSearch()}catch(F){let b=F instanceof Error?F:new Error(String(F));throw A(b),b}finally{n(!1)}},isSearching:R,error:B}),[R,B]),q=L.default.useRef(!1),l=L.default.useCallback((F,b,y)=>{t.current&&F&&!q.current&&(t.current.attachMap(F,{platform:"maplibre",maplibregl:b,onMarkerClick:y==null?void 0:y.onMarkerClick}),q.current=!0)},[]),k=L.default.useRef(!1),E=L.default.useCallback((F,b,y)=>{t.current&&F&&!k.current&&(t.current.attachMap(F,{platform:"google",google:b,onMarkerClick:y==null?void 0:y.onMarkerClick}),k.current=!0)},[]),T=L.default.useRef(!1),pe=L.default.useCallback((F,b,y)=>{t.current&&F&&!T.current&&(t.current.attachMap(F,{platform:"mapbox",mapboxgl:b,onMarkerClick:y==null?void 0:y.onMarkerClick}),T.current=!0)},[]);return{instance:t.current,state:i,setPrimaryType:m,setSelectedMarker:f,propertiesSearch:P,smartFilterSearch:v,boundsSearch:K,attachMapLibre:l,attachGoogle:E,attachMapbox:pe}}0&&(module.exports={Chip,CloseIcon,EditIcon,FilterChips,MinRatingFilterChip,NextIcon,PriceRangeFilterChip,RestaurantPriceLevelChip,SearchIcon,SmartFilter,StarIcon,TransformedQueryChip,convertToApiFilters,createMinRatingFilterLabel,createPriceRangeFilterLabel,formatRatingValue,processApiFilters,renderStars,useFilterScroll,useMapFirst,useTranslation});
|
|
11
11
|
//# sourceMappingURL=index.js.map
|