@garagem-ai/site-sdk 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +329 -31
- package/dist/index.d.mts +305 -44
- package/dist/index.d.ts +305 -44
- package/dist/index.js +1282 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1233 -34
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +29 -2
- package/dist/react.d.ts +29 -2
- package/dist/react.js +639 -26
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +638 -26
- package/dist/react.mjs.map +1 -1
- package/dist/{types-photo-search-OeONNDxl.d.mts → types-photo-search-D88oevZv.d.mts} +400 -1
- package/dist/{types-photo-search-OeONNDxl.d.ts → types-photo-search-D88oevZv.d.ts} +400 -1
- package/package.json +1 -1
- package/src/client.ts +23 -0
- package/src/fetchers-photos.ts +98 -0
- package/src/fetchers.ts +96 -30
- package/src/index.ts +120 -2
- package/src/internal/sdk-http.ts +122 -0
- package/src/leads.ts +34 -3
- package/src/listing-photos.ts +312 -0
- package/src/map-search.ts +487 -0
- package/src/maps.ts +743 -0
- package/src/react/index.ts +2 -0
- package/src/react/types.ts +5 -0
- package/src/react/use-map-search.ts +101 -0
- package/src/react/use-public-search.ts +23 -5
- package/src/resolve-site-id.ts +3 -0
- package/src/studio-contract.ts +120 -0
- package/src/types-maps.ts +275 -0
- package/src/types-photos.ts +46 -0
- package/src/types.ts +23 -0
package/dist/index.js
CHANGED
|
@@ -21,15 +21,24 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
AMENITY_FALLBACK_LABELS: () => AMENITY_FALLBACK_LABELS,
|
|
24
|
+
DEFAULT_MAPS_BASE_URL: () => DEFAULT_MAPS_BASE_URL,
|
|
24
25
|
DEFAULT_PHONE_COUNTRY_CODE: () => DEFAULT_PHONE_COUNTRY_CODE,
|
|
25
26
|
FORBIDDEN_SEARCH_QUERY_KEYS: () => FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
26
27
|
GaragemSdkError: () => GaragemSdkError,
|
|
27
28
|
LISTING_AMENITY_TITLES: () => LISTING_AMENITY_TITLES,
|
|
28
29
|
LISTING_DESCRIPTION_CLAMP: () => LISTING_DESCRIPTION_CLAMP,
|
|
29
30
|
LeadSubmitError: () => LeadSubmitError,
|
|
31
|
+
MAPS_MAX_IMAGE_EDGE: () => MAPS_MAX_IMAGE_EDGE,
|
|
32
|
+
MAPS_SITE_HEADER: () => MAPS_SITE_HEADER,
|
|
33
|
+
MAP_POLYGON_MAX_VERTICES: () => MAP_POLYGON_MAX_VERTICES,
|
|
34
|
+
MAP_SEARCH_DEFAULT_PAGE_SIZE: () => MAP_SEARCH_DEFAULT_PAGE_SIZE,
|
|
35
|
+
MAP_SEARCH_MAX_PAGE_SIZE: () => MAP_SEARCH_MAX_PAGE_SIZE,
|
|
36
|
+
MAP_VIEWPORT_DEBOUNCE_MS: () => MAP_VIEWPORT_DEBOUNCE_MS,
|
|
30
37
|
MATCHED_PHOTO_COVER_MAX_DISTANCE: () => MATCHED_PHOTO_COVER_MAX_DISTANCE,
|
|
31
38
|
MAX_NATIONAL_PHONE_DIGITS: () => MAX_NATIONAL_PHONE_DIGITS,
|
|
32
39
|
PHONE_COUNTRIES: () => PHONE_COUNTRIES,
|
|
40
|
+
PHOTO_GROUP_OTHER_KEY: () => PHOTO_GROUP_OTHER_KEY,
|
|
41
|
+
PHOTO_GROUP_OTHER_LABEL: () => PHOTO_GROUP_OTHER_LABEL,
|
|
33
42
|
PHOTO_SEARCH_MIN_QUERY_LENGTH: () => PHOTO_SEARCH_MIN_QUERY_LENGTH,
|
|
34
43
|
SEARCH_EMPTY_COPY: () => SEARCH_EMPTY_COPY,
|
|
35
44
|
SEARCH_SORT_RELEVANCE: () => SEARCH_SORT_RELEVANCE,
|
|
@@ -41,17 +50,28 @@ __export(src_exports, {
|
|
|
41
50
|
VISIT_TIME_ZONE: () => VISIT_TIME_ZONE,
|
|
42
51
|
applyMatchedPhotoCover: () => applyMatchedPhotoCover,
|
|
43
52
|
applyPathFilter: () => applyPathFilter,
|
|
53
|
+
boundaryCitySlug: () => boundaryCitySlug,
|
|
54
|
+
boundaryLayerId: () => boundaryLayerId,
|
|
55
|
+
boundaryLayerUrl: () => boundaryLayerUrl,
|
|
44
56
|
buildQueryListingsParams: () => buildQueryListingsParams,
|
|
45
57
|
canonicalizeSearchHref: () => canonicalizeSearchHref,
|
|
58
|
+
capMapPage: () => capMapPage,
|
|
59
|
+
capMapPageSize: () => capMapPageSize,
|
|
46
60
|
clearStagedPathFilters: () => clearStagedPathFilters,
|
|
61
|
+
clearTravelTimeCache: () => clearTravelTimeCache,
|
|
62
|
+
clusterPins: () => clusterPins,
|
|
63
|
+
coarsenCoordinates: () => coarsenCoordinates,
|
|
47
64
|
coerceNpmVersion: () => coerceNpmVersion,
|
|
48
65
|
collapseDuplicatedBrazilianMobileNine: () => collapseDuplicatedBrazilianMobileNine,
|
|
49
66
|
compareSemver: () => compareSemver,
|
|
50
67
|
composeSearchPublicHref: () => composeSearchPublicHref2,
|
|
51
68
|
composeSearchPublicPath: () => composeSearchPublicPath2,
|
|
69
|
+
coordinateDecimals: () => coordinateDecimals,
|
|
52
70
|
countFacetChoices: () => countFacetChoices,
|
|
53
71
|
countOptionLabel: () => countOptionLabel,
|
|
72
|
+
createClient: () => createClient,
|
|
54
73
|
createGaragemClient: () => createGaragemClient,
|
|
74
|
+
createTravelTimeCache: () => createTravelTimeCache,
|
|
55
75
|
defaultPhoneCountry: () => defaultPhoneCountry,
|
|
56
76
|
displayPathLocation: () => displayPathLocation,
|
|
57
77
|
expandVisitSchedule: () => expandVisitSchedule,
|
|
@@ -61,6 +81,7 @@ __export(src_exports, {
|
|
|
61
81
|
formatGroupedInteger: () => formatGroupedInteger,
|
|
62
82
|
formatListingPrice: () => formatListingPrice,
|
|
63
83
|
formatPhoneNational: () => formatPhoneNational,
|
|
84
|
+
getBoundaryLayer: () => getBoundaryLayer,
|
|
64
85
|
getCmsCollection: () => getCmsCollection,
|
|
65
86
|
getCmsCollections: () => getCmsCollections,
|
|
66
87
|
getCmsEntries: () => getCmsEntries,
|
|
@@ -71,6 +92,7 @@ __export(src_exports, {
|
|
|
71
92
|
getListings: () => getListings,
|
|
72
93
|
getNeighborhoodSummary: () => getNeighborhoodSummary,
|
|
73
94
|
getSearchUi: () => getSearchUi,
|
|
95
|
+
getSimilarByPhoto: () => getSimilarByPhoto,
|
|
74
96
|
getSimilarListings: () => getSimilarListings,
|
|
75
97
|
getSite: () => getSite,
|
|
76
98
|
hasShowcaseLeadsPostUrl: () => hasShowcaseLeadsPostUrl,
|
|
@@ -78,6 +100,8 @@ __export(src_exports, {
|
|
|
78
100
|
hrefForPathFilters: () => hrefForPathFilters,
|
|
79
101
|
hrefWithExplicitPage: () => hrefWithExplicitPage,
|
|
80
102
|
isListingDetailPath: () => isListingDetailPath,
|
|
103
|
+
isMapBounds: () => isMapBounds,
|
|
104
|
+
isMapPolygon: () => isMapPolygon,
|
|
81
105
|
isPhotoSearchOnPin: () => isPhotoSearchOnPin,
|
|
82
106
|
isStudioPreviewHost: () => isStudioPreviewHost,
|
|
83
107
|
isValidPhone: () => isValidPhone,
|
|
@@ -86,6 +110,7 @@ __export(src_exports, {
|
|
|
86
110
|
listingAmenityGroups: () => listingAmenityGroups,
|
|
87
111
|
listingBreadcrumb: () => listingBreadcrumb,
|
|
88
112
|
listingBusinessLabel: () => listingBusinessLabel,
|
|
113
|
+
listingCoordinates: () => listingCoordinates,
|
|
89
114
|
listingDescriptionPreview: () => listingDescriptionPreview,
|
|
90
115
|
listingDetailFieldsModel: () => listingDetailFieldsModel,
|
|
91
116
|
listingDetailModel: () => listingDetailModel,
|
|
@@ -95,12 +120,25 @@ __export(src_exports, {
|
|
|
95
120
|
listingLookupKey: () => listingLookupKey,
|
|
96
121
|
listingMapsHref: () => listingMapsHref,
|
|
97
122
|
listingMediaOverlays: () => listingMediaOverlays,
|
|
123
|
+
listingPhotoGroups: () => listingPhotoGroups,
|
|
98
124
|
listingPublicPath: () => listingPublicPath,
|
|
125
|
+
listingStaticMapUrl: () => listingStaticMapUrl,
|
|
126
|
+
listingStreetViewAvailable: () => listingStreetViewAvailable,
|
|
127
|
+
listingStreetViewMetadataUrl: () => listingStreetViewMetadataUrl,
|
|
128
|
+
listingStreetViewUrl: () => listingStreetViewUrl,
|
|
99
129
|
listingValues: () => listingValues,
|
|
130
|
+
listingVisualHighlights: () => listingVisualHighlights,
|
|
131
|
+
mapClusterCellDegrees: () => mapClusterCellDegrees,
|
|
132
|
+
mapSearchPins: () => mapSearchPins,
|
|
133
|
+
mapsExportsPublished: () => mapsExportsPublished,
|
|
100
134
|
marketExportsAvailableAt: () => marketExportsAvailableAt,
|
|
101
135
|
marketPositionLabel: () => marketPositionLabel,
|
|
136
|
+
maxZoomForCoordinates: () => maxZoomForCoordinates,
|
|
102
137
|
mergeAppliedSearchQueryIntoSearch: () => mergeAppliedSearchQueryIntoSearch2,
|
|
103
138
|
nationalPhoneDigits: () => nationalPhoneDigits,
|
|
139
|
+
neighborhoodBoundaryLayer: () => neighborhoodBoundaryLayer,
|
|
140
|
+
neighborhoodBoundaryUrl: () => neighborhoodBoundaryUrl,
|
|
141
|
+
normalizeMapsBaseUrl: () => normalizeMapsBaseUrl,
|
|
104
142
|
normalizeVisitDate: () => normalizeVisitDate,
|
|
105
143
|
normalizeVisitTime: () => normalizeVisitTime,
|
|
106
144
|
paginationPages: () => paginationPages,
|
|
@@ -114,6 +152,7 @@ __export(src_exports, {
|
|
|
114
152
|
pathFiltersToQueryFilters: () => pathFiltersToQueryFilters,
|
|
115
153
|
pathLocationToFilterInput: () => pathLocationToFilterInput,
|
|
116
154
|
phoneCountrySearchValue: () => phoneCountrySearchValue,
|
|
155
|
+
photoRoomLabel: () => photoRoomLabel,
|
|
117
156
|
photoSearchUrl: () => photoSearchUrl,
|
|
118
157
|
priceBandLabel: () => priceBandLabel,
|
|
119
158
|
publicSearchHref: () => publicSearchHref,
|
|
@@ -125,10 +164,13 @@ __export(src_exports, {
|
|
|
125
164
|
requestPriceEstimate: () => requestPriceEstimate,
|
|
126
165
|
resolveMatchedCoverPhoto: () => resolveMatchedCoverPhoto,
|
|
127
166
|
resolvePublicSiteId: () => resolvePublicSiteId,
|
|
167
|
+
resolveTravelDestination: () => resolveTravelDestination,
|
|
128
168
|
searchChromeModel: () => searchChromeModel,
|
|
129
169
|
searchHrefUsesLegacyFilterQuery: () => searchHrefUsesLegacyFilterQuery,
|
|
130
170
|
searchListingPhotos: () => searchListingPhotos,
|
|
131
171
|
searchListings: () => searchListings,
|
|
172
|
+
searchListingsInBounds: () => searchListingsInBounds,
|
|
173
|
+
searchListingsInPolygon: () => searchListingsInPolygon,
|
|
132
174
|
searchResultsHeading: () => searchResultsHeading,
|
|
133
175
|
searchSortOptions: () => searchSortOptions,
|
|
134
176
|
serializeAppliedSearchQuery: () => serializeAppliedSearchQuery2,
|
|
@@ -141,8 +183,12 @@ __export(src_exports, {
|
|
|
141
183
|
studioLeadInstruction: () => studioLeadInstruction,
|
|
142
184
|
studioListingCardInstruction: () => studioListingCardInstruction,
|
|
143
185
|
studioListingDetailInstruction: () => studioListingDetailInstruction,
|
|
186
|
+
studioMapsInstruction: () => studioMapsInstruction,
|
|
144
187
|
studioMarketInstruction: () => studioMarketInstruction,
|
|
188
|
+
studioPhotoInstruction: () => studioPhotoInstruction,
|
|
189
|
+
studioPhotoInstructionFor: () => studioPhotoInstructionFor,
|
|
145
190
|
studioPhotoSearchInstruction: () => studioPhotoSearchInstruction,
|
|
191
|
+
studioPublishableKeyInstruction: () => studioPublishableKeyInstruction,
|
|
146
192
|
studioSdkPinInstruction: () => studioSdkPinInstruction,
|
|
147
193
|
studioSearchInstruction: () => studioSearchInstruction,
|
|
148
194
|
studioSearchLandmarkInstruction: () => studioSearchLandmarkInstruction,
|
|
@@ -152,6 +198,9 @@ __export(src_exports, {
|
|
|
152
198
|
toE164: () => toE164,
|
|
153
199
|
toListingCardModel: () => toListingCardModel,
|
|
154
200
|
toolbarFilterIds: () => toolbarFilterIds,
|
|
201
|
+
travelTimeCacheKey: () => travelTimeCacheKey,
|
|
202
|
+
travelTimeFromListing: () => travelTimeFromListing,
|
|
203
|
+
travelTimesFromListing: () => travelTimesFromListing,
|
|
155
204
|
truncateNationalPhoneDigits: () => truncateNationalPhoneDigits,
|
|
156
205
|
unavailableReactImports: () => unavailableReactImports,
|
|
157
206
|
visibleSearchFilters: () => visibleSearchFilters
|
|
@@ -172,6 +221,90 @@ function listingPublicPath(listing) {
|
|
|
172
221
|
return `/imoveis/id-${identity}`;
|
|
173
222
|
}
|
|
174
223
|
|
|
224
|
+
// src/internal/sdk-http.ts
|
|
225
|
+
var PUBLISHABLE_KEY_HEADER = "X-Garagem-Publishable-Key";
|
|
226
|
+
function publishableKeyHeaders(publishableKey) {
|
|
227
|
+
const key = publishableKey?.trim();
|
|
228
|
+
if (!key) return {};
|
|
229
|
+
return { [PUBLISHABLE_KEY_HEADER]: key };
|
|
230
|
+
}
|
|
231
|
+
function withPublishableKeyHeader(init, publishableKey) {
|
|
232
|
+
const extra = publishableKeyHeaders(publishableKey);
|
|
233
|
+
if (Object.keys(extra).length === 0) return init;
|
|
234
|
+
const current = init.headers;
|
|
235
|
+
const base = plainHeaders(current);
|
|
236
|
+
return { ...init, headers: { ...base, ...extra } };
|
|
237
|
+
}
|
|
238
|
+
function plainHeaders(headers) {
|
|
239
|
+
const out = {};
|
|
240
|
+
if (!headers) return out;
|
|
241
|
+
if (typeof Headers !== "undefined" && headers instanceof Headers) {
|
|
242
|
+
headers.forEach((value, name) => {
|
|
243
|
+
out[name] = value;
|
|
244
|
+
});
|
|
245
|
+
return out;
|
|
246
|
+
}
|
|
247
|
+
if (Array.isArray(headers)) {
|
|
248
|
+
for (const pair of headers) {
|
|
249
|
+
out[String(pair[0])] = String(pair[1]);
|
|
250
|
+
}
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
for (const [name, value] of Object.entries(
|
|
254
|
+
headers
|
|
255
|
+
)) {
|
|
256
|
+
if (typeof value === "string") out[name] = value;
|
|
257
|
+
}
|
|
258
|
+
return out;
|
|
259
|
+
}
|
|
260
|
+
function finiteNonNegative(value) {
|
|
261
|
+
if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
|
|
262
|
+
return value;
|
|
263
|
+
}
|
|
264
|
+
if (typeof value === "string" && value.trim()) {
|
|
265
|
+
const parsed = Number(value);
|
|
266
|
+
if (Number.isFinite(parsed) && parsed >= 0) return parsed;
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
function parseSdkErrorBody(text) {
|
|
271
|
+
const raw = text ? text.slice(0, 200) : "";
|
|
272
|
+
if (!text) {
|
|
273
|
+
return { reason: null, retryAfterSeconds: null, summary: "" };
|
|
274
|
+
}
|
|
275
|
+
try {
|
|
276
|
+
const body = JSON.parse(text);
|
|
277
|
+
if (!body || typeof body !== "object") {
|
|
278
|
+
return { reason: null, retryAfterSeconds: null, summary: raw };
|
|
279
|
+
}
|
|
280
|
+
const record = body;
|
|
281
|
+
const reason = typeof record.reason === "string" && record.reason ? record.reason : null;
|
|
282
|
+
const retryAfterSeconds = finiteNonNegative(
|
|
283
|
+
record.retryAfterSeconds ?? record.retryAfter
|
|
284
|
+
);
|
|
285
|
+
const errorText = typeof record.error === "string" && record.error ? record.error : raw;
|
|
286
|
+
return {
|
|
287
|
+
reason,
|
|
288
|
+
retryAfterSeconds,
|
|
289
|
+
summary: errorText.slice(0, 200)
|
|
290
|
+
};
|
|
291
|
+
} catch {
|
|
292
|
+
return { reason: null, retryAfterSeconds: null, summary: raw };
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function retryAfterFromResponse(response, bodySeconds, nowMs = Date.now()) {
|
|
296
|
+
const header = response.headers.get("Retry-After")?.trim();
|
|
297
|
+
if (header) {
|
|
298
|
+
const delta = finiteNonNegative(header);
|
|
299
|
+
if (delta != null) return delta;
|
|
300
|
+
const at = Date.parse(header);
|
|
301
|
+
if (Number.isFinite(at)) {
|
|
302
|
+
return Math.max(0, Math.ceil((at - nowMs) / 1e3));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return bodySeconds;
|
|
306
|
+
}
|
|
307
|
+
|
|
175
308
|
// src/internal/url.ts
|
|
176
309
|
var DEFAULT_BASE_URL = "https://app.garagem.ai";
|
|
177
310
|
var DEFAULT_RESOLVE_BASE_URL = "https://cdn.fndn.ai/site";
|
|
@@ -206,27 +339,50 @@ function buildListingFiltersQuery(filters) {
|
|
|
206
339
|
}
|
|
207
340
|
|
|
208
341
|
// src/fetchers.ts
|
|
209
|
-
async function callJson(url, init, fetchImpl) {
|
|
210
|
-
const response = await fetchImpl(
|
|
342
|
+
async function callJson(url, init, fetchImpl, publishableKey) {
|
|
343
|
+
const response = await fetchImpl(
|
|
344
|
+
url,
|
|
345
|
+
withPublishableKeyHeader(init, publishableKey)
|
|
346
|
+
);
|
|
211
347
|
if (!response.ok) {
|
|
212
|
-
|
|
213
|
-
throw new GaragemSdkError(
|
|
214
|
-
`Garagem SDK: request failed (${response.status} ${response.statusText}) for ${url}${text ? ` \u2014 ${text.slice(0, 200)}` : ""}`,
|
|
215
|
-
{ status: response.status, url }
|
|
216
|
-
);
|
|
348
|
+
throw await readGaragemSdkError(response, url);
|
|
217
349
|
}
|
|
218
350
|
return await response.json();
|
|
219
351
|
}
|
|
220
352
|
var GaragemSdkError = class extends Error {
|
|
221
353
|
status;
|
|
222
354
|
url;
|
|
355
|
+
/** Machine reason from the JSON body (`invalid_publishable_key`, `rate_limited`, …). */
|
|
356
|
+
reason;
|
|
357
|
+
/**
|
|
358
|
+
* Seconds to wait before retrying. Set on HTTP 429 from `Retry-After`
|
|
359
|
+
* or the body's `retryAfterSeconds`. `null` when the response has neither.
|
|
360
|
+
*/
|
|
361
|
+
retryAfter;
|
|
223
362
|
constructor(message, info) {
|
|
224
363
|
super(message);
|
|
225
364
|
this.name = "GaragemSdkError";
|
|
226
365
|
this.status = info.status;
|
|
227
366
|
this.url = info.url;
|
|
367
|
+
this.reason = info.reason ?? null;
|
|
368
|
+
this.retryAfter = info.retryAfter ?? null;
|
|
228
369
|
}
|
|
229
370
|
};
|
|
371
|
+
async function readGaragemSdkError(response, url) {
|
|
372
|
+
const text = await response.text().catch(() => "");
|
|
373
|
+
const parsed = parseSdkErrorBody(text);
|
|
374
|
+
const retryAfter = response.status === 429 ? retryAfterFromResponse(response, parsed.retryAfterSeconds) : parsed.retryAfterSeconds;
|
|
375
|
+
const detail = parsed.summary;
|
|
376
|
+
return new GaragemSdkError(
|
|
377
|
+
`Garagem SDK: request failed (${response.status} ${response.statusText}) for ${url}${detail ? ` \u2014 ${detail}` : ""}`,
|
|
378
|
+
{
|
|
379
|
+
status: response.status,
|
|
380
|
+
url,
|
|
381
|
+
reason: parsed.reason,
|
|
382
|
+
retryAfter
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
}
|
|
230
386
|
async function getListings(options) {
|
|
231
387
|
const { filters, baseUrl, fetch: fetchImpl, next } = options;
|
|
232
388
|
const siteId = await coerceSiteId(options.siteId);
|
|
@@ -237,7 +393,8 @@ async function getListings(options) {
|
|
|
237
393
|
const data = await callJson(
|
|
238
394
|
url,
|
|
239
395
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
240
|
-
fetchImpl ?? fetch
|
|
396
|
+
fetchImpl ?? fetch,
|
|
397
|
+
options.publishableKey
|
|
241
398
|
);
|
|
242
399
|
return {
|
|
243
400
|
listings: data.listings ?? [],
|
|
@@ -258,7 +415,8 @@ async function getListing(options) {
|
|
|
258
415
|
return callJson(
|
|
259
416
|
url,
|
|
260
417
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
261
|
-
fetchImpl ?? fetch
|
|
418
|
+
fetchImpl ?? fetch,
|
|
419
|
+
options.publishableKey
|
|
262
420
|
);
|
|
263
421
|
}
|
|
264
422
|
async function getSite(options) {
|
|
@@ -280,17 +438,20 @@ async function getSite(options) {
|
|
|
280
438
|
if (domain) params.set("domain", domain);
|
|
281
439
|
const url = `${base}/api/sites/resolve?${params.toString()}`;
|
|
282
440
|
const f = fetchImpl ?? fetch;
|
|
283
|
-
const response = await f(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
441
|
+
const response = await f(
|
|
442
|
+
url,
|
|
443
|
+
withPublishableKeyHeader(
|
|
444
|
+
{
|
|
445
|
+
method: "GET",
|
|
446
|
+
headers: { Accept: "application/json" },
|
|
447
|
+
next
|
|
448
|
+
},
|
|
449
|
+
options.publishableKey
|
|
450
|
+
)
|
|
451
|
+
);
|
|
288
452
|
if (response.status === 404) return null;
|
|
289
453
|
if (!response.ok) {
|
|
290
|
-
throw
|
|
291
|
-
`Garagem SDK: getSite failed (${response.status}) for ${url}`,
|
|
292
|
-
{ status: response.status, url }
|
|
293
|
-
);
|
|
454
|
+
throw await readGaragemSdkError(response, url);
|
|
294
455
|
}
|
|
295
456
|
const data = await response.json();
|
|
296
457
|
return {
|
|
@@ -318,7 +479,8 @@ async function searchListings(options) {
|
|
|
318
479
|
body: JSON.stringify(params),
|
|
319
480
|
next
|
|
320
481
|
},
|
|
321
|
-
fetchImpl ?? fetch
|
|
482
|
+
fetchImpl ?? fetch,
|
|
483
|
+
options.publishableKey
|
|
322
484
|
);
|
|
323
485
|
}
|
|
324
486
|
async function getSearchUi(options) {
|
|
@@ -329,11 +491,12 @@ async function getSearchUi(options) {
|
|
|
329
491
|
return callJson(
|
|
330
492
|
url,
|
|
331
493
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
332
|
-
fetchImpl ?? fetch
|
|
494
|
+
fetchImpl ?? fetch,
|
|
495
|
+
options.publishableKey
|
|
333
496
|
);
|
|
334
497
|
}
|
|
335
498
|
async function queryListings(options) {
|
|
336
|
-
const { params, baseUrl, fetch: fetchImpl, next } = options;
|
|
499
|
+
const { params, baseUrl, fetch: fetchImpl, next, signal } = options;
|
|
337
500
|
const siteId = await coerceSiteId(options.siteId);
|
|
338
501
|
const base = normalizeBaseUrl(baseUrl);
|
|
339
502
|
const url = `${base}/api/sites/${encodeURIComponent(siteId)}/search/listings`;
|
|
@@ -346,9 +509,11 @@ async function queryListings(options) {
|
|
|
346
509
|
"Content-Type": "application/json"
|
|
347
510
|
},
|
|
348
511
|
body: JSON.stringify(params ?? {}),
|
|
349
|
-
next
|
|
512
|
+
next,
|
|
513
|
+
signal
|
|
350
514
|
},
|
|
351
|
-
fetchImpl ?? fetch
|
|
515
|
+
fetchImpl ?? fetch,
|
|
516
|
+
options.publishableKey
|
|
352
517
|
);
|
|
353
518
|
}
|
|
354
519
|
async function getSimilarListings(options) {
|
|
@@ -376,7 +541,8 @@ async function getSimilarListings(options) {
|
|
|
376
541
|
const data = await callJson(
|
|
377
542
|
url,
|
|
378
543
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
379
|
-
fetchImpl ?? fetch
|
|
544
|
+
fetchImpl ?? fetch,
|
|
545
|
+
options.publishableKey
|
|
380
546
|
);
|
|
381
547
|
return {
|
|
382
548
|
listings: data.listings ?? [],
|
|
@@ -391,7 +557,8 @@ async function getCmsCollections(options) {
|
|
|
391
557
|
const data = await callJson(
|
|
392
558
|
url,
|
|
393
559
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
394
|
-
fetchImpl ?? fetch
|
|
560
|
+
fetchImpl ?? fetch,
|
|
561
|
+
options.publishableKey
|
|
395
562
|
);
|
|
396
563
|
return data.collections ?? [];
|
|
397
564
|
}
|
|
@@ -408,7 +575,8 @@ async function getCmsCollection(options) {
|
|
|
408
575
|
const data = await callJson(
|
|
409
576
|
url,
|
|
410
577
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
411
|
-
fetchImpl ?? fetch
|
|
578
|
+
fetchImpl ?? fetch,
|
|
579
|
+
options.publishableKey
|
|
412
580
|
);
|
|
413
581
|
if (data && typeof data === "object" && "collection" in data && data.collection) {
|
|
414
582
|
return data.collection;
|
|
@@ -443,7 +611,8 @@ async function getCmsEntries(options) {
|
|
|
443
611
|
const data = await callJson(
|
|
444
612
|
url,
|
|
445
613
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
446
|
-
fetchImpl ?? fetch
|
|
614
|
+
fetchImpl ?? fetch,
|
|
615
|
+
options.publishableKey
|
|
447
616
|
);
|
|
448
617
|
return {
|
|
449
618
|
entries: data.entries ?? [],
|
|
@@ -468,7 +637,8 @@ async function getCmsEntry(options) {
|
|
|
468
637
|
const data = await callJson(
|
|
469
638
|
url,
|
|
470
639
|
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
471
|
-
fetchImpl ?? fetch
|
|
640
|
+
fetchImpl ?? fetch,
|
|
641
|
+
options.publishableKey
|
|
472
642
|
);
|
|
473
643
|
if (data && typeof data === "object" && "entry" in data && data.entry) {
|
|
474
644
|
return data.entry;
|
|
@@ -999,7 +1169,8 @@ async function resolvePublicSiteId(options) {
|
|
|
999
1169
|
const site = await getSite({
|
|
1000
1170
|
domain: host,
|
|
1001
1171
|
baseUrl: options.baseUrl,
|
|
1002
|
-
fetch: options.fetch
|
|
1172
|
+
fetch: options.fetch,
|
|
1173
|
+
publishableKey: options.publishableKey
|
|
1003
1174
|
});
|
|
1004
1175
|
if (site?.id) return site.id;
|
|
1005
1176
|
throw new GaragemSdkError(
|
|
@@ -1028,7 +1199,8 @@ async function resolveLeadSiteId(input) {
|
|
|
1028
1199
|
return resolvePublicSiteId({
|
|
1029
1200
|
host,
|
|
1030
1201
|
baseUrl: input.baseUrl,
|
|
1031
|
-
fetch: input.fetch
|
|
1202
|
+
fetch: input.fetch,
|
|
1203
|
+
publishableKey: input.publishableKey
|
|
1032
1204
|
});
|
|
1033
1205
|
}
|
|
1034
1206
|
}
|
|
@@ -1036,6 +1208,8 @@ var LeadSubmitError = class extends Error {
|
|
|
1036
1208
|
code;
|
|
1037
1209
|
status;
|
|
1038
1210
|
retryAfterSeconds;
|
|
1211
|
+
/** Seconds to wait. Same value as `retryAfterSeconds`; `null` when unset. */
|
|
1212
|
+
retryAfter;
|
|
1039
1213
|
constructor(message, info) {
|
|
1040
1214
|
super(message);
|
|
1041
1215
|
this.name = "LeadSubmitError";
|
|
@@ -1044,6 +1218,7 @@ var LeadSubmitError = class extends Error {
|
|
|
1044
1218
|
if (info.retryAfterSeconds != null) {
|
|
1045
1219
|
this.retryAfterSeconds = info.retryAfterSeconds;
|
|
1046
1220
|
}
|
|
1221
|
+
this.retryAfter = info.retryAfterSeconds ?? null;
|
|
1047
1222
|
}
|
|
1048
1223
|
};
|
|
1049
1224
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
@@ -1085,7 +1260,8 @@ async function getLeadUi(options) {
|
|
|
1085
1260
|
headers: { Accept: "application/json" },
|
|
1086
1261
|
next: options.next
|
|
1087
1262
|
},
|
|
1088
|
-
options.fetch ?? fetch
|
|
1263
|
+
options.fetch ?? fetch,
|
|
1264
|
+
options.publishableKey
|
|
1089
1265
|
);
|
|
1090
1266
|
}
|
|
1091
1267
|
function assertListingId(listingId) {
|
|
@@ -1158,7 +1334,8 @@ async function postSiteLead(input) {
|
|
|
1158
1334
|
method: "POST",
|
|
1159
1335
|
headers: {
|
|
1160
1336
|
Accept: "application/json",
|
|
1161
|
-
"Content-Type": "application/json"
|
|
1337
|
+
"Content-Type": "application/json",
|
|
1338
|
+
...publishableKeyHeaders(input.publishableKey)
|
|
1162
1339
|
},
|
|
1163
1340
|
body: JSON.stringify(input.body)
|
|
1164
1341
|
});
|
|
@@ -1173,12 +1350,23 @@ async function postSiteLead(input) {
|
|
|
1173
1350
|
const id = typeof data.id === "string" && data.id ? data.id : "";
|
|
1174
1351
|
return { ok: true, status: 202, id };
|
|
1175
1352
|
}
|
|
1176
|
-
|
|
1353
|
+
if (response.status === 401) {
|
|
1354
|
+
throw new LeadSubmitError("Garagem SDK: invalid publishable key.", {
|
|
1355
|
+
code: "unauthorized",
|
|
1356
|
+
status: 401
|
|
1357
|
+
});
|
|
1358
|
+
}
|
|
1177
1359
|
if (response.status === 429) {
|
|
1360
|
+
const text = await response.text().catch(() => "");
|
|
1361
|
+
const parsed = parseSdkErrorBody(text);
|
|
1362
|
+
const retryAfter = retryAfterFromResponse(
|
|
1363
|
+
response,
|
|
1364
|
+
parsed.retryAfterSeconds
|
|
1365
|
+
);
|
|
1178
1366
|
throw new LeadSubmitError("Garagem SDK: too many lead submissions.", {
|
|
1179
1367
|
code: "rate_limited",
|
|
1180
1368
|
status: 429,
|
|
1181
|
-
retryAfterSeconds:
|
|
1369
|
+
...retryAfter != null ? { retryAfterSeconds: retryAfter } : {}
|
|
1182
1370
|
});
|
|
1183
1371
|
}
|
|
1184
1372
|
if (response.status === 404) {
|
|
@@ -1222,6 +1410,7 @@ async function submitVisitLead(input) {
|
|
|
1222
1410
|
siteId: input.siteId,
|
|
1223
1411
|
baseUrl: input.baseUrl,
|
|
1224
1412
|
fetch: input.fetch,
|
|
1413
|
+
publishableKey: input.publishableKey,
|
|
1225
1414
|
body: {
|
|
1226
1415
|
source: "site-sdk",
|
|
1227
1416
|
leadType: "visit",
|
|
@@ -1240,6 +1429,7 @@ async function submitContactLead(input) {
|
|
|
1240
1429
|
siteId: input.siteId,
|
|
1241
1430
|
baseUrl: input.baseUrl,
|
|
1242
1431
|
fetch: input.fetch,
|
|
1432
|
+
publishableKey: input.publishableKey,
|
|
1243
1433
|
body: {
|
|
1244
1434
|
source: "site-sdk",
|
|
1245
1435
|
leadType: "contact",
|
|
@@ -2829,6 +3019,29 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2829
3019
|
*/
|
|
2830
3020
|
unpublishedPhoneExports: [],
|
|
2831
3021
|
amenityExports: ["listingAmenityGroups"],
|
|
3022
|
+
/**
|
|
3023
|
+
* Prompt-safe photo helpers on `minNpmVersion`. Empty until the release
|
|
3024
|
+
* that carries `getSimilarByPhoto` / `listingPhotoGroups` /
|
|
3025
|
+
* `listingVisualHighlights` is on npm; then bump the pin, move the names
|
|
3026
|
+
* here from `unpublishedPhotoExports`, and `studioPhotoInstruction()`
|
|
3027
|
+
* starts teaching the gallery-by-room, highlight chips, and
|
|
3028
|
+
* "imóveis com fotos parecidas" blocks. The caption-based `media[].alt` /
|
|
3029
|
+
* `media[].caption` fields are API data (not tarball exports) and are
|
|
3030
|
+
* documented regardless of the pin.
|
|
3031
|
+
*/
|
|
3032
|
+
photoExports: [],
|
|
3033
|
+
/**
|
|
3034
|
+
* Photo helpers in the repo but not on `minNpmVersion`. Prompts,
|
|
3035
|
+
* completeness, and repair text must not mention these until the pin
|
|
3036
|
+
* bumps — v0 installs the pin and the ESM loader throws on missing named
|
|
3037
|
+
* exports.
|
|
3038
|
+
*/
|
|
3039
|
+
unpublishedPhotoExports: [
|
|
3040
|
+
"getSimilarByPhoto",
|
|
3041
|
+
"listingPhotoGroups",
|
|
3042
|
+
"listingVisualHighlights",
|
|
3043
|
+
"photoRoomLabel"
|
|
3044
|
+
],
|
|
2832
3045
|
/**
|
|
2833
3046
|
* Names already on the pinned npm tarball (`minNpmVersion`) — safe for
|
|
2834
3047
|
* Studio prompts and completeness. Includes `visibleSearchFilters` +
|
|
@@ -2853,6 +3066,27 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2853
3066
|
"searchChromeModel",
|
|
2854
3067
|
"rangeDraftFromPath"
|
|
2855
3068
|
],
|
|
3069
|
+
/**
|
|
3070
|
+
* maps.fndn.ai helpers (static map, street view, boundaries, travel
|
|
3071
|
+
* time) plus friendly map search. They ship in `mapsSince`;
|
|
3072
|
+
* `studioMapsInstruction()` is empty and these names are codegen
|
|
3073
|
+
* violations until `minNpmVersion` reaches that release — bump the pin
|
|
3074
|
+
* after the tarball is on npm and the listing guidance turns on by
|
|
3075
|
+
* itself. `useMapSearch` is a `/react` hook named in that same
|
|
3076
|
+
* instruction; it stays off `reactExports` until the pin moves.
|
|
3077
|
+
*/
|
|
3078
|
+
mapsSince: "0.7.0",
|
|
3079
|
+
mapsExports: [
|
|
3080
|
+
"listingStaticMapUrl",
|
|
3081
|
+
"listingStreetViewUrl",
|
|
3082
|
+
"listingStreetViewAvailable",
|
|
3083
|
+
"neighborhoodBoundaryLayer",
|
|
3084
|
+
"boundaryLayerUrl",
|
|
3085
|
+
"travelTimeFromListing",
|
|
3086
|
+
"searchListingsInBounds",
|
|
3087
|
+
"searchListingsInPolygon",
|
|
3088
|
+
"clusterPins"
|
|
3089
|
+
],
|
|
2856
3090
|
/**
|
|
2857
3091
|
* Market-data helpers (neighborhood price summary, listing market
|
|
2858
3092
|
* position, visitor price estimate, pt-BR labels). They ship in
|
|
@@ -2972,6 +3206,9 @@ function unavailableReactImports(source, pin) {
|
|
|
2972
3206
|
}
|
|
2973
3207
|
return missing;
|
|
2974
3208
|
}
|
|
3209
|
+
function studioPublishableKeyInstruction() {
|
|
3210
|
+
return `Public site API key (optional, backwards compatible). \`publishableKey\` (\`pk_live_\u2026\`) is not a secret. Create or rotate it in Garagem at Configura\xE7\xF5es \u2192 Sites \u2192 the site \u2192 API p\xFAblica (route \`/configuracoes/sites/[siteId]\`, section API p\xFAblica (SDK)). Pass it to \`createGaragemClient({ siteId, baseUrl: GARAGEM_API_BASE, publishableKey })\` or on each call: \`getListings\`, \`getListing\`, \`getSite\`, \`getSearchUi\`, \`queryListings\`, \`searchListings\`, the CMS helpers, \`getLeadUi\`, \`submitVisitLead\`, \`submitContactLead\`, and \`usePublicSearch\`. The SDK sends header \`X-Garagem-Publishable-Key\` (a Bearer token that starts with \`pk_live_\` is also accepted). Omitting the key still succeeds. Once a site has a key, anonymous traffic uses the stricter per-IP budget (listings/search 30/min, detail 60/min, config 30/min). A site with no key uses the looser anonymous budget (120 / 300 / 120). With the key, budgets are listings/search 600/min, detail 1200/min, config 300/min. Window is 60 seconds. Success and 429 responses carry \`RateLimit-Limit\`, \`RateLimit-Remaining\`, \`RateLimit-Reset\`, and \`RateLimit-Policy\`. HTTP 401 throws \`GaragemSdkError\` with \`status\` 401 and \`reason\` \`invalid_publishable_key\` (wrong key). HTTP 403 has \`reason\` \`origin_not_allowed\` when the site's origin allowlist rejects the browser Origin or Referer. HTTP 429 has \`reason\` \`rate_limited\` and \`retryAfter\` seconds (same value as the \`Retry-After\` header). \`LeadSubmitError\` uses \`code\` \`rate_limited\` or \`unauthorized\`, and \`retryAfter\` / \`retryAfterSeconds\` on 429. A public constant next to \`GARAGEM_API_BASE\` is the right place for the key. Do not invent a second header name.`;
|
|
3211
|
+
}
|
|
2975
3212
|
function studioSdkPinInstruction() {
|
|
2976
3213
|
const version = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
2977
3214
|
const names = [...reactExportsAvailableAt(version)].join(", ");
|
|
@@ -2990,6 +3227,31 @@ function studioListingDetailInstruction() {
|
|
|
2990
3227
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
2991
3228
|
return `Listing detail: import ${names} from \`${STUDIO_SDK_PACKAGE}\`. Render \`listingDetailModel\` leaves: \`model.facts[].label\` / \`.text\`, \`model.values[].label\` / \`.text\`, \`model.location.label\` / \`model.location.mapsHref\`, breadcrumb \`.href\` (search prefixes of \`listing.path\`). The pre\xE7o / sob consulta entry is the primary value; condom\xEDnio and IPTU are secondary and omitted when missing. \`model.description\` is the complete string \u2014 do not slice. A collapsed disclosure uses a container (max-height or overflow), not a cut of the string. Never interpolate \`model.location\`, \`model.facts\`, \`model.values\`, \`model.breadcrumb\`, or \`model.mediaOverlays\` as a React child. Video/tour: \`model.mediaOverlays\` as hash links (\`#video\` / \`#tour\`); player src is \`embedSrc\`; fullscreen overlay closes with browser back; omit when that overlay is absent. Do not key the page on \`location.hash\`. Similar listings: \`getSimilarListings({ siteId, listingId, baseUrl })\` plus the site listing-card module; hide the section when empty. Do not invent a local recommendation loop.`;
|
|
2992
3229
|
}
|
|
3230
|
+
function studioPhotoInstructionFor(published) {
|
|
3231
|
+
const has = (name) => published.includes(name);
|
|
3232
|
+
const parts = [
|
|
3233
|
+
`Gallery photo text: \`item.alt\` on \`listing.media\` is the photo caption when the platform analyzed it (else "<title> - Foto N") \u2014 always pass it as the img alt. \`item.caption\` is optional: show it as the slide / overlay caption when present and omit the element when absent. Never invent captions or room names in generated source.`
|
|
3234
|
+
];
|
|
3235
|
+
if (has("listingPhotoGroups")) {
|
|
3236
|
+
parts.push(
|
|
3237
|
+
`Gallery by room: \`const groups = listingPhotoGroups(listing)\` from \`${STUDIO_SDK_PACKAGE}\` returns \`{ key, label, photos }[]\` (pt-BR labels such as "Sala", "Quartos", "Cozinha"; "Outras fotos" last). Use it only inside the fullscreen photo overlay (room tabs or section headings over the thumbnail strip) \u2014 the page carousel stays one flat section. Render \`group.label\` and \`group.photos.length\`; when \`groups.length <= 1\` render the flat strip without headings. Never read \`item.roomType\` / \`item.sceneType\` directly to build sections and never hardcode room names.`
|
|
3238
|
+
);
|
|
3239
|
+
}
|
|
3240
|
+
if (has("listingVisualHighlights")) {
|
|
3241
|
+
parts.push(
|
|
3242
|
+
`Visual highlights: \`const highlights = listingVisualHighlights(listing, { limit: 6 })\` returns deduped strings ("piso de madeira", "vista livre"). Render them as small chips (site tokens, \`--radius\`) under the gallery or beside the facts, one chip per string, and omit the block when the array is empty. Do not merge them with \`listingAmenityGroups\` and do not read \`item.features\` directly.`
|
|
3243
|
+
);
|
|
3244
|
+
}
|
|
3245
|
+
if (has("getSimilarByPhoto")) {
|
|
3246
|
+
parts.push(
|
|
3247
|
+
`Im\xF3veis com fotos parecidas: on the server page, pick the first image item of \`listing.media\` and \`await getSimilarByPhoto(siteId, listing.id, photo.id, { limit: 6, baseUrl: GARAGEM_API_BASE })\` from \`${STUDIO_SDK_PACKAGE}\` (positional ids; \`listing.id\` is the UUID, never the path). The result is \`{ available, items }\`: when \`available === false\` (tenant without image search, or \`photo.id\` is not a media UUID such as the \`image-N\` / \`external-N\` gallery keys \u2014 that returns locally and does not throw) render nothing \u2014 no heading, no empty state; when \`items.length === 0\` also render nothing. Otherwise a section titled "Im\xF3veis com fotos parecidas" with the site listing-card module (\`toListingCardModel(item.listing)\`), using \`item.matchedPhoto.src\` / \`item.matchedPhoto.alt\` as that card's photo. Keep \`getSimilarListings\` as the default similar carousel; this section is additional, below it. Wrap the call in try/catch and treat an error like \`available: false\`.`
|
|
3248
|
+
);
|
|
3249
|
+
}
|
|
3250
|
+
return parts.join(" ");
|
|
3251
|
+
}
|
|
3252
|
+
function studioPhotoInstruction() {
|
|
3253
|
+
return studioPhotoInstructionFor(STUDIO_SDK_CONTRACT.photoExports);
|
|
3254
|
+
}
|
|
2993
3255
|
function studioAmenityInstruction() {
|
|
2994
3256
|
return `Listing amenities: Portuguese labels from \`listingAmenityGroups(listing, dictionary)\` (pass the dictionary from \`getSearchUi()\` so section titles follow Campos). Each group is \`{ title, labels: string[] }\` \u2014 render \`group.title\` and \`group.labels.map((label) => \u2026)\` and hide a group when \`group.labels.length === 0\`. Do not hardcode section titles. Never print amenity ids, never invent a local label map, and never title a section "Comodidades da unidade".`;
|
|
2995
3257
|
}
|
|
@@ -2998,6 +3260,14 @@ function studioSearchInstruction() {
|
|
|
2998
3260
|
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
2999
3261
|
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}. Prefetch \`getSearchUi\` + \`queryListings\` on the server page. \`const search = usePublicSearch({ siteId, baseUrl: GARAGEM_API_BASE, search: searchFromServer, initial })\` where \`searchFromServer\` is \`new URLSearchParams(await searchParams).toString()\` \u2014 never shorthand \`{ search }\` beside \`const search =\` (temporal dead zone). Do not wrap this UI in \`<Suspense>\` and do not add a route \`loading\` file \u2014 heading and cards are ordinary elements in the document, visible with JavaScript off. Compose the page UI in the app \u2014 do not paste a canonical search TSX. Required chrome (design is free; omit none): query (\`qDraft\` / \`setQDraft\` / form \`preventDefault\` + \`submitQuery\`), heading (count span FIRST then h1 from \`searchResultsHeading(search.pathFilters, search.schema?.dictionary, search.locationNames)\` \u2014 never \`searchResultsHeading({})\`), toolbar (\`toolbarFilterIds\` + \`applyFilter\`; range \u201CAtualizar\u201D on that toolbar item only) vs sheet (\`visibleSearchFilters\` extras, \`stageFilter\`, one footer \`applyStaged\`), sort (\`searchSortOptions\` + \`setSort\`; first option id is \`""\` / \u201CMais relevantes\u201D \u2014 map **only** that empty id to Select sentinel \`"relevancia"\` (\`opt.id || "relevancia"\`), never \`SelectItem value=""\` and never give \u201CMais recentes\u201D (\`id: "recentes"\`, \`?ordenar=recentes\`) that sentinel; on change \`setSort(id === "relevancia" ? "" : id)\` so recentes stays recentes. Closed trigger shows the option \`.label\`, never \`{search.applied.sort}\`), grid (\`listings.map\` + the site listing-card module; listing-card-skeleton only for a slot whose content is still unknown, never as a Suspense fallback; do not \`throw\` in that chrome), pagination (\`paginationPages\` + \`hrefWithExplicitPage\`). Never interpolate \`schema\`, \`pathFilters\`, or a filter object as a React child. \`queryListings\` key is \`params\`. The URL is the document. Count text is \`{search.total}\` only. Heading is one row; font size lives on the container and the span and h1 use \`font-size: inherit\`. Sort trigger shows the option label (\u201CMais relevantes\u201D when \`ordenar\` is absent), chevron at the end, same height as the toolbar controls. Toolbar ranges open a Popover form (not DropdownMenu \u2014 Menu typeahead swallows digit keys) whose submit calls \`applyFilter\`; the popup clips and the two inputs stay inside (\`min-w-0\`, no \`w-64\`). Reset min/max drafts when the popover opens and when the applied path range changes. The sheet omits toolbar ids (price, bedrooms) so Pre\xE7o is never a heading without inputs. Sheet DialogContent uses \`h-[min(640px,85dvh)]\` (not max-h alone) so the body ScrollArea can move. Tipo de im\xF3vel, caracter\xEDsticas and comodidades each use a nested ScrollArea with \`h-56 overflow-hidden\` (viewport \`h-full\`). Area is two inputs in schema order with no \u201CAplicar\u201D; the footer stages then applyStaged. Never read \`staged[filter.id]\` \u2014 path keys are \`bedrooms\` / \`listingType\` / \`bathrooms\`. Bedrooms Select reads \`pathFilters.bedrooms\` so \`/imoveis/4-quartos\` checks \`"4"\` and shows the same trigger dot as price. Bathrooms and parking pressed state uses \`pathFilterHasOption\`. Limpar keeps location plus toolbar price and bedrooms via \`clearStagedPathFilters\` and \`toolbarFilterIds\`; do not call \`clearStaged\` for that button. It enables only when staged has a path filter other than location and those kept toolbar ids. Each multi-select \`stageFilter\` value is one option id, never a concatenated slug; \`checked\` uses \`pathFilterHasOption\`. Listing type does not pass the clicked id: no path value shows every checkbox checked, unchecking one stages the other option's id, and the last box stays checked. Price inputs use formatGroupedInteger. The closed price and bedrooms triggers keep the filter label plus a dot when set \u2014 never the literal range. Empty price calls applyFilter(id, undefined); never send 0 or 1000000000. Area is a plain integer (not that mask). The results button stageFilter property_area_total with both drafts, then applyStaged. Never send 0 or 100000. Count buttons pass the option id (\`"2"\`), never the label \`"2+"\`. Property type, features, and amenities render in pt-BR label order. Do not set \`[data-slot="search-sort"] { flex-direction: column }\` in a \`<style>\` tag; that selector is row so the chevron sits beside the label. Empty copy: ${JSON.stringify(SEARCH_EMPTY_COPY)}`;
|
|
3000
3262
|
}
|
|
3263
|
+
function mapsExportsPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3264
|
+
return compareSemver(pin, STUDIO_SDK_CONTRACT.mapsSince) >= 0;
|
|
3265
|
+
}
|
|
3266
|
+
function studioMapsInstruction(options = {}) {
|
|
3267
|
+
if (!mapsExportsPublished(options.pin)) return "";
|
|
3268
|
+
const names = STUDIO_SDK_CONTRACT.mapsExports.join(", ");
|
|
3269
|
+
return `Maps on listing detail: from \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`listing.location.coordinates\` is already masked by the site's privacy settings (\u2248100 m by default) \u2014 pass the listing object as-is; never un-mask, never re-geocode the street address to get a sharper point, never add decimals (\`maxDecimals\` can only coarsen). Always pass \`siteId\` (the resolved site id / publishable key) so maps.fndn.ai meters the site. Static map: \`const mapSrc = listingStaticMapUrl(listing, { width: 640, height: 320, zoom: 15, style: "roadmap", siteId })\` then \`{mapSrc ? <img src={mapSrc} alt={model.location.label} /> : null}\` \u2014 \`null\` means no coordinates, so omit the block (never a placeholder image). Zoom is capped by the coordinate precision (16 on the default mask); do not work around it. Street View: on the server page \`const sv = await listingStreetViewAvailable(listing, { siteId })\` (metadata is free), and only when \`sv.available\` render \`<img src={listingStreetViewUrl(listing, { width: 640, height: 400, siteId })} alt="Street View" />\` \u2014 the image is billed per load. Neighbourhood outline on an interactive map: load Maps JS ONLY through \`<script src="https://maps.fndn.ai/sdk.js?callback=initMap" async defer />\` (never a Google key in the app, never \`NEXT_PUBLIC_GOOGLE_MAPS_API_KEY\`); in \`initMap\` do \`const outline = await neighborhoodBoundaryLayer(listing.location.city, listing.location.neighborhood, { siteId })\` and \`if (outline.feature) map.data.addGeoJson(outline.feature)\`; with MapLibre the vector source url is \`boundaryLayerUrl(listing.location.city)\`. Travel time (\u201Cquanto tempo at\xE9\u2026\u201D): \`const trip = await travelTimeFromListing(listing, destination, { mode: "driving", siteId })\` gives \`{ minutes, distanceKm }\` or \`null\` (hide the row). Every uncached call is a billed Google Directions request: call it on demand \u2014 a destination the visitor typed, or at most one fixed landmark per listing page \u2014 never per listing card, never inside a search loop, keep the SDK cache on (default 15 min LRU, \`cache: null\` only in tests), and do not re-run it on every render. Map search (search page: search as the map moves, or draw an area): searchListingsInBounds(siteId, { bounds: { north, south, east, west }, zoom, q, sort, location, filters, page, pageSize, publishableKey }) and searchListingsInPolygon(siteId, { polygon: [[lat, lng], ...], q, sort, location, filters, page, pageSize, publishableKey }). Polygon points are [lat, lng], not GeoJSON. The server builds the allowlisted coordinates geo filter from those numbers; do not send a raw filter string from the browser. Pins are { id, lat, lng, price, coverImage } copied from the listings the API returned \u2014 masked pins, plot them as returned, never geocode the street to sharpen one. clusterPins(pins, zoom) is the headless grid: one pin keeps its coordinates, a group centroid is rounded back to the coarsest pin. The React hook useMapSearch (on the /react entry, next to usePublicSearch) debounces viewport changes by 400ms, cancels the stale request, caps pageSize at 100, and returns those pins plus cards from toListingCardModel. Pass the same q, sort, location, filters, and publishableKey as the list (queryListings / usePublicSearch). Dropping them pins listings outside the active query or spends the anonymous listings budget. Cost: every viewport change is a search call \u2014 keep the debounce, do not raise the page size, and do not call travel time or Street View inside that loop.`;
|
|
3270
|
+
}
|
|
3001
3271
|
function marketExportsAvailableAt(pin) {
|
|
3002
3272
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.marketExportsSince) >= 0;
|
|
3003
3273
|
}
|
|
@@ -3048,6 +3318,18 @@ function studioCodegenContractViolations(text) {
|
|
|
3048
3318
|
violations.push(name);
|
|
3049
3319
|
}
|
|
3050
3320
|
}
|
|
3321
|
+
if (!mapsExportsPublished()) {
|
|
3322
|
+
for (const name of STUDIO_SDK_CONTRACT.mapsExports) {
|
|
3323
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
3324
|
+
violations.push(name);
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhotoExports) {
|
|
3329
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
3330
|
+
violations.push(name);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3051
3333
|
if (!isPhotoSearchOnPin()) {
|
|
3052
3334
|
for (const name of STUDIO_SDK_CONTRACT.photoSearchExports) {
|
|
3053
3335
|
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
@@ -3097,6 +3379,9 @@ function createGaragemClient(options = {}) {
|
|
|
3097
3379
|
const out = { ...opts };
|
|
3098
3380
|
if (options.baseUrl !== void 0) out.baseUrl = options.baseUrl;
|
|
3099
3381
|
if (options.fetch !== void 0) out.fetch = options.fetch;
|
|
3382
|
+
if (options.publishableKey !== void 0 && out.publishableKey === void 0) {
|
|
3383
|
+
out.publishableKey = options.publishableKey;
|
|
3384
|
+
}
|
|
3100
3385
|
return out;
|
|
3101
3386
|
};
|
|
3102
3387
|
return {
|
|
@@ -3125,6 +3410,9 @@ function createGaragemClient(options = {}) {
|
|
|
3125
3410
|
if (domain !== void 0) opts.domain = domain;
|
|
3126
3411
|
if (options.baseUrl !== void 0) opts.baseUrl = options.baseUrl;
|
|
3127
3412
|
if (options.fetch !== void 0) opts.fetch = options.fetch;
|
|
3413
|
+
if (options.publishableKey !== void 0) {
|
|
3414
|
+
opts.publishableKey = options.publishableKey;
|
|
3415
|
+
}
|
|
3128
3416
|
const merged = mergeNext(next);
|
|
3129
3417
|
if (merged !== void 0) opts.next = merged;
|
|
3130
3418
|
return getSite(opts);
|
|
@@ -3233,6 +3521,917 @@ function createGaragemClient(options = {}) {
|
|
|
3233
3521
|
}
|
|
3234
3522
|
};
|
|
3235
3523
|
}
|
|
3524
|
+
var createClient = createGaragemClient;
|
|
3525
|
+
|
|
3526
|
+
// src/maps.ts
|
|
3527
|
+
var DEFAULT_MAPS_BASE_URL = "https://maps.fndn.ai";
|
|
3528
|
+
var MAPS_SITE_HEADER = "X-Garagem-Site";
|
|
3529
|
+
var MAPS_MAX_IMAGE_EDGE = 640;
|
|
3530
|
+
var TRAVEL_MODES = /* @__PURE__ */ new Set([
|
|
3531
|
+
"driving",
|
|
3532
|
+
"walking",
|
|
3533
|
+
"bicycling",
|
|
3534
|
+
"transit"
|
|
3535
|
+
]);
|
|
3536
|
+
function finite(value) {
|
|
3537
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
3538
|
+
}
|
|
3539
|
+
function listingCoordinates(listing) {
|
|
3540
|
+
const raw = listing?.location?.coordinates;
|
|
3541
|
+
const lat = finite(raw?.lat);
|
|
3542
|
+
const lng = finite(raw?.lng);
|
|
3543
|
+
if (lat == null || lng == null) return null;
|
|
3544
|
+
if (lat === 0 && lng === 0) return null;
|
|
3545
|
+
if (Math.abs(lat) > 90 || Math.abs(lng) > 180) return null;
|
|
3546
|
+
return { lat, lng };
|
|
3547
|
+
}
|
|
3548
|
+
function coordinateDecimals(value) {
|
|
3549
|
+
if (!Number.isFinite(value)) return 0;
|
|
3550
|
+
const text = Math.abs(value).toString();
|
|
3551
|
+
if (text.includes("e")) {
|
|
3552
|
+
const fixed = Math.abs(value).toFixed(12).replace(/0+$/, "");
|
|
3553
|
+
const dot2 = fixed.indexOf(".");
|
|
3554
|
+
return dot2 === -1 ? 0 : fixed.length - dot2 - 1;
|
|
3555
|
+
}
|
|
3556
|
+
const dot = text.indexOf(".");
|
|
3557
|
+
return dot === -1 ? 0 : text.length - dot - 1;
|
|
3558
|
+
}
|
|
3559
|
+
function roundTo(value, decimals) {
|
|
3560
|
+
const factor = 10 ** decimals;
|
|
3561
|
+
return Math.round(value * factor) / factor;
|
|
3562
|
+
}
|
|
3563
|
+
function coarsenCoordinates(coordinates, maxDecimals) {
|
|
3564
|
+
if (maxDecimals == null || !Number.isFinite(maxDecimals)) return coordinates;
|
|
3565
|
+
const limit = Math.max(0, Math.floor(maxDecimals));
|
|
3566
|
+
return {
|
|
3567
|
+
lat: coordinateDecimals(coordinates.lat) > limit ? roundTo(coordinates.lat, limit) : coordinates.lat,
|
|
3568
|
+
lng: coordinateDecimals(coordinates.lng) > limit ? roundTo(coordinates.lng, limit) : coordinates.lng
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
function maxZoomForCoordinates(coordinates) {
|
|
3572
|
+
const decimals = Math.min(
|
|
3573
|
+
coordinateDecimals(coordinates.lat),
|
|
3574
|
+
coordinateDecimals(coordinates.lng)
|
|
3575
|
+
);
|
|
3576
|
+
if (decimals >= 4) return 21;
|
|
3577
|
+
if (decimals === 3) return 16;
|
|
3578
|
+
if (decimals === 2) return 13;
|
|
3579
|
+
return 11;
|
|
3580
|
+
}
|
|
3581
|
+
function clampInt(value, fallback, min, max) {
|
|
3582
|
+
if (value == null || !Number.isFinite(value)) return fallback;
|
|
3583
|
+
return Math.min(max, Math.max(min, Math.round(value)));
|
|
3584
|
+
}
|
|
3585
|
+
function normalizeMapsBaseUrl(baseUrl) {
|
|
3586
|
+
const raw = (baseUrl ?? "").trim();
|
|
3587
|
+
if (!raw) return DEFAULT_MAPS_BASE_URL;
|
|
3588
|
+
return raw.replace(/\/+$/, "") || DEFAULT_MAPS_BASE_URL;
|
|
3589
|
+
}
|
|
3590
|
+
function siteTag(options) {
|
|
3591
|
+
const value = options?.siteId?.trim();
|
|
3592
|
+
return value ? value : null;
|
|
3593
|
+
}
|
|
3594
|
+
function mapsUrl(path, params, options) {
|
|
3595
|
+
const url = new URL(path, `${normalizeMapsBaseUrl(options?.mapsBaseUrl)}/`);
|
|
3596
|
+
for (const [key, value] of Object.entries(params)) {
|
|
3597
|
+
if (value === void 0 || value === "") continue;
|
|
3598
|
+
url.searchParams.set(key, String(value));
|
|
3599
|
+
}
|
|
3600
|
+
const site = siteTag(options);
|
|
3601
|
+
if (site) url.searchParams.set("site", site);
|
|
3602
|
+
return url.toString();
|
|
3603
|
+
}
|
|
3604
|
+
function resolveFetch(options) {
|
|
3605
|
+
const custom = options?.fetch;
|
|
3606
|
+
if (custom) return custom;
|
|
3607
|
+
const global = globalThis.fetch;
|
|
3608
|
+
if (!global) {
|
|
3609
|
+
throw new TypeError(
|
|
3610
|
+
"Garagem SDK: no fetch available. Pass `fetch` in the options."
|
|
3611
|
+
);
|
|
3612
|
+
}
|
|
3613
|
+
return global;
|
|
3614
|
+
}
|
|
3615
|
+
async function mapsFetchJson(url, options, init) {
|
|
3616
|
+
const headers = new Headers(init?.headers);
|
|
3617
|
+
headers.set("accept", "application/json");
|
|
3618
|
+
const site = siteTag(options);
|
|
3619
|
+
if (site) headers.set(MAPS_SITE_HEADER, site);
|
|
3620
|
+
try {
|
|
3621
|
+
const response = await resolveFetch(options)(url, { ...init, headers });
|
|
3622
|
+
if (!response.ok) return null;
|
|
3623
|
+
return await response.json();
|
|
3624
|
+
} catch {
|
|
3625
|
+
return null;
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
function listingStaticMapUrl(listing, options = {}) {
|
|
3629
|
+
const raw = listingCoordinates(listing);
|
|
3630
|
+
if (!raw) return null;
|
|
3631
|
+
const coordinates = coarsenCoordinates(raw, options.maxDecimals);
|
|
3632
|
+
const zoomCeiling = maxZoomForCoordinates(coordinates);
|
|
3633
|
+
const zoom = Math.min(zoomCeiling, clampInt(options.zoom, 15, 1, 21));
|
|
3634
|
+
const markerColor = options.markerColor ?? "red";
|
|
3635
|
+
return mapsUrl(
|
|
3636
|
+
"/v1/static-map",
|
|
3637
|
+
{
|
|
3638
|
+
lat: coordinates.lat,
|
|
3639
|
+
lng: coordinates.lng,
|
|
3640
|
+
zoom,
|
|
3641
|
+
width: clampInt(options.width, 600, 1, MAPS_MAX_IMAGE_EDGE),
|
|
3642
|
+
height: clampInt(options.height, 300, 1, MAPS_MAX_IMAGE_EDGE),
|
|
3643
|
+
scale: options.scale === 1 ? 1 : 2,
|
|
3644
|
+
maptype: options.style,
|
|
3645
|
+
markerColor: markerColor !== "red" ? markerColor : void 0,
|
|
3646
|
+
hidePoi: options.hidePoi ? "1" : void 0
|
|
3647
|
+
},
|
|
3648
|
+
options
|
|
3649
|
+
);
|
|
3650
|
+
}
|
|
3651
|
+
function listingStreetViewUrl(listing, options = {}) {
|
|
3652
|
+
const raw = listingCoordinates(listing);
|
|
3653
|
+
if (!raw) return null;
|
|
3654
|
+
const coordinates = coarsenCoordinates(raw, options.maxDecimals);
|
|
3655
|
+
const width = clampInt(options.width, 640, 1, MAPS_MAX_IMAGE_EDGE);
|
|
3656
|
+
const height = clampInt(options.height, 640, 1, MAPS_MAX_IMAGE_EDGE);
|
|
3657
|
+
return mapsUrl(
|
|
3658
|
+
"/v1/street-view",
|
|
3659
|
+
{
|
|
3660
|
+
lat: coordinates.lat,
|
|
3661
|
+
lng: coordinates.lng,
|
|
3662
|
+
size: `${width}x${height}`,
|
|
3663
|
+
fov: clampInt(options.fov, 90, 10, 120),
|
|
3664
|
+
heading: clampInt(options.heading, 0, 0, 360),
|
|
3665
|
+
pitch: clampInt(options.pitch, 10, -90, 90)
|
|
3666
|
+
},
|
|
3667
|
+
options
|
|
3668
|
+
);
|
|
3669
|
+
}
|
|
3670
|
+
function listingStreetViewMetadataUrl(listing, options = {}) {
|
|
3671
|
+
const raw = listingCoordinates(listing);
|
|
3672
|
+
if (!raw) return null;
|
|
3673
|
+
const coordinates = coarsenCoordinates(raw, options.maxDecimals);
|
|
3674
|
+
return mapsUrl(
|
|
3675
|
+
"/v1/street-view/metadata",
|
|
3676
|
+
{ lat: coordinates.lat, lng: coordinates.lng },
|
|
3677
|
+
options
|
|
3678
|
+
);
|
|
3679
|
+
}
|
|
3680
|
+
async function listingStreetViewAvailable(listing, options = {}) {
|
|
3681
|
+
const url = listingStreetViewMetadataUrl(listing, options);
|
|
3682
|
+
if (!url) {
|
|
3683
|
+
return { available: false, status: "NO_COORDINATES", url: "" };
|
|
3684
|
+
}
|
|
3685
|
+
const data = await mapsFetchJson(url, options);
|
|
3686
|
+
const status = typeof data?.status === "string" ? data.status : "ERROR";
|
|
3687
|
+
const result = {
|
|
3688
|
+
available: status === "OK",
|
|
3689
|
+
status,
|
|
3690
|
+
url
|
|
3691
|
+
};
|
|
3692
|
+
if (typeof data?.pano_id === "string") result.panoId = data.pano_id;
|
|
3693
|
+
if (typeof data?.date === "string") result.date = data.date;
|
|
3694
|
+
return result;
|
|
3695
|
+
}
|
|
3696
|
+
function boundaryCitySlug(city) {
|
|
3697
|
+
return city.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
3698
|
+
}
|
|
3699
|
+
function boundaryLayerId(city) {
|
|
3700
|
+
const slug = boundaryCitySlug(city);
|
|
3701
|
+
return slug.endsWith("_boundaries") ? slug : `${slug}_boundaries`;
|
|
3702
|
+
}
|
|
3703
|
+
function boundaryLayerUrl(city, options = {}) {
|
|
3704
|
+
const base = normalizeMapsBaseUrl(options.mapsBaseUrl);
|
|
3705
|
+
const id = boundaryLayerId(city);
|
|
3706
|
+
const slug = id.replace(/_boundaries$/, "");
|
|
3707
|
+
switch (options.kind ?? "tilejson") {
|
|
3708
|
+
case "layer":
|
|
3709
|
+
return `${base}/v1/layers/${id}`;
|
|
3710
|
+
case "tiles":
|
|
3711
|
+
return `${base}/martin/${id}/{z}/{x}/{y}`;
|
|
3712
|
+
case "geojson":
|
|
3713
|
+
return `${base}/api/boundaries/${slug}`;
|
|
3714
|
+
default:
|
|
3715
|
+
return `${base}/martin/${id}`;
|
|
3716
|
+
}
|
|
3717
|
+
}
|
|
3718
|
+
function neighborhoodBoundaryUrl(city, neighborhood, options = {}) {
|
|
3719
|
+
const base = normalizeMapsBaseUrl(options.mapsBaseUrl);
|
|
3720
|
+
const slug = boundaryLayerId(city).replace(/_boundaries$/, "");
|
|
3721
|
+
const url = new URL(
|
|
3722
|
+
`${base}/api/boundaries/${slug}/${encodeURIComponent(neighborhood.trim())}`
|
|
3723
|
+
);
|
|
3724
|
+
if (options.source && options.source !== "listaaberta") {
|
|
3725
|
+
url.searchParams.set("source", options.source);
|
|
3726
|
+
}
|
|
3727
|
+
return url.toString();
|
|
3728
|
+
}
|
|
3729
|
+
function asNumber(value, fallback) {
|
|
3730
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
3731
|
+
}
|
|
3732
|
+
async function getBoundaryLayer(city, options = {}) {
|
|
3733
|
+
const data = await mapsFetchJson(
|
|
3734
|
+
boundaryLayerUrl(city, { ...options, kind: "layer" }),
|
|
3735
|
+
options
|
|
3736
|
+
);
|
|
3737
|
+
const layer = data?.layer;
|
|
3738
|
+
if (!data?.ok || !layer || typeof layer.id !== "string") return null;
|
|
3739
|
+
const rawSourceLayers = Array.isArray(layer.source_layers) ? layer.source_layers : [];
|
|
3740
|
+
return {
|
|
3741
|
+
id: layer.id,
|
|
3742
|
+
name: typeof layer.name === "string" ? layer.name : layer.id,
|
|
3743
|
+
description: typeof layer.description === "string" ? layer.description : "",
|
|
3744
|
+
city: typeof layer.city === "string" ? layer.city : void 0,
|
|
3745
|
+
tiles: typeof layer.tiles === "string" ? layer.tiles : "",
|
|
3746
|
+
tilejson: typeof layer.tilejson === "string" ? layer.tilejson : "",
|
|
3747
|
+
geojson: typeof layer.geojson === "string" ? layer.geojson : void 0,
|
|
3748
|
+
sourceLayers: rawSourceLayers.filter(
|
|
3749
|
+
(entry) => !!entry && typeof entry === "object"
|
|
3750
|
+
).map((entry) => ({
|
|
3751
|
+
id: String(entry.id ?? ""),
|
|
3752
|
+
label: String(entry.label ?? entry.id ?? ""),
|
|
3753
|
+
minzoom: typeof entry.minzoom === "number" ? entry.minzoom : void 0,
|
|
3754
|
+
maxzoom: typeof entry.maxzoom === "number" ? entry.maxzoom : void 0
|
|
3755
|
+
})),
|
|
3756
|
+
minzoom: asNumber(layer.minzoom, 0),
|
|
3757
|
+
maxzoom: asNumber(layer.maxzoom, 14),
|
|
3758
|
+
attribution: typeof layer.attribution === "string" ? layer.attribution : void 0,
|
|
3759
|
+
available: layer.available !== false
|
|
3760
|
+
};
|
|
3761
|
+
}
|
|
3762
|
+
function isFeature(value) {
|
|
3763
|
+
return !!value && typeof value === "object" && value.type === "Feature";
|
|
3764
|
+
}
|
|
3765
|
+
async function neighborhoodBoundaryLayer(city, neighborhood, options = {}) {
|
|
3766
|
+
const url = neighborhoodBoundaryUrl(city, neighborhood, options);
|
|
3767
|
+
const slug = boundaryLayerId(city).replace(/_boundaries$/, "");
|
|
3768
|
+
const result = {
|
|
3769
|
+
city: slug,
|
|
3770
|
+
neighborhood: neighborhood.trim(),
|
|
3771
|
+
feature: null,
|
|
3772
|
+
candidates: [],
|
|
3773
|
+
url,
|
|
3774
|
+
tiles: boundaryLayerUrl(city, { ...options, kind: "tiles" })
|
|
3775
|
+
};
|
|
3776
|
+
if (!result.neighborhood) return result;
|
|
3777
|
+
const data = await mapsFetchJson(
|
|
3778
|
+
url,
|
|
3779
|
+
options
|
|
3780
|
+
);
|
|
3781
|
+
if (!data) return result;
|
|
3782
|
+
if (isFeature(data)) {
|
|
3783
|
+
result.feature = data;
|
|
3784
|
+
result.candidates = [data];
|
|
3785
|
+
return result;
|
|
3786
|
+
}
|
|
3787
|
+
const features = Array.isArray(data.features) ? data.features.filter(isFeature) : [];
|
|
3788
|
+
result.candidates = features;
|
|
3789
|
+
const wanted = result.neighborhood.toLocaleLowerCase("pt-BR");
|
|
3790
|
+
result.feature = features.find(
|
|
3791
|
+
(feature) => typeof feature.properties?.name === "string" && feature.properties.name.toLocaleLowerCase("pt-BR") === wanted
|
|
3792
|
+
) ?? (features.length === 1 ? features[0] : null);
|
|
3793
|
+
return result;
|
|
3794
|
+
}
|
|
3795
|
+
function createTravelTimeCache(options = {}) {
|
|
3796
|
+
const maxEntries = Math.max(1, Math.floor(options.maxEntries ?? 200));
|
|
3797
|
+
const ttlMs = Math.max(0, options.ttlMs ?? 15 * 60 * 1e3);
|
|
3798
|
+
const entries = /* @__PURE__ */ new Map();
|
|
3799
|
+
return {
|
|
3800
|
+
get(key) {
|
|
3801
|
+
const hit = entries.get(key);
|
|
3802
|
+
if (!hit) return void 0;
|
|
3803
|
+
if (hit.expiresAt <= Date.now()) {
|
|
3804
|
+
entries.delete(key);
|
|
3805
|
+
return void 0;
|
|
3806
|
+
}
|
|
3807
|
+
entries.delete(key);
|
|
3808
|
+
entries.set(key, hit);
|
|
3809
|
+
return hit.value;
|
|
3810
|
+
},
|
|
3811
|
+
set(key, value) {
|
|
3812
|
+
entries.delete(key);
|
|
3813
|
+
entries.set(key, { value, expiresAt: Date.now() + ttlMs });
|
|
3814
|
+
while (entries.size > maxEntries) {
|
|
3815
|
+
const oldest = entries.keys().next().value;
|
|
3816
|
+
if (oldest === void 0) break;
|
|
3817
|
+
entries.delete(oldest);
|
|
3818
|
+
}
|
|
3819
|
+
},
|
|
3820
|
+
clear() {
|
|
3821
|
+
entries.clear();
|
|
3822
|
+
},
|
|
3823
|
+
get size() {
|
|
3824
|
+
return entries.size;
|
|
3825
|
+
}
|
|
3826
|
+
};
|
|
3827
|
+
}
|
|
3828
|
+
var defaultTravelTimeCache = createTravelTimeCache();
|
|
3829
|
+
function clearTravelTimeCache() {
|
|
3830
|
+
defaultTravelTimeCache.clear();
|
|
3831
|
+
}
|
|
3832
|
+
function travelTimeCacheKey(origin, destination, mode) {
|
|
3833
|
+
return `${origin.lat},${origin.lng}|${destination.lat},${destination.lng}|${mode}`;
|
|
3834
|
+
}
|
|
3835
|
+
function travelTimeQueryCacheKey(origin, query, mode) {
|
|
3836
|
+
return `${origin.lat},${origin.lng}|q:${query}|${mode}`;
|
|
3837
|
+
}
|
|
3838
|
+
function trimmedDestinationQuery(destination) {
|
|
3839
|
+
if (typeof destination !== "string") return null;
|
|
3840
|
+
const query = destination.trim();
|
|
3841
|
+
return query ? query : null;
|
|
3842
|
+
}
|
|
3843
|
+
function recallTravelTime(cache, key) {
|
|
3844
|
+
if (!cache) return null;
|
|
3845
|
+
const hit = cache.get(key);
|
|
3846
|
+
return hit ? { ...hit, cached: true } : null;
|
|
3847
|
+
}
|
|
3848
|
+
function rememberTravelTime(cache, keys, value) {
|
|
3849
|
+
if (!cache) return;
|
|
3850
|
+
for (const key of keys) cache.set(key, value);
|
|
3851
|
+
}
|
|
3852
|
+
function normalizeMode(mode) {
|
|
3853
|
+
return mode && TRAVEL_MODES.has(mode) ? mode : "driving";
|
|
3854
|
+
}
|
|
3855
|
+
async function resolveTravelDestination(destination, options = {}) {
|
|
3856
|
+
if (typeof destination !== "string") {
|
|
3857
|
+
const lat2 = finite(destination?.lat);
|
|
3858
|
+
const lng2 = finite(destination?.lng);
|
|
3859
|
+
return lat2 == null || lng2 == null ? null : { lat: lat2, lng: lng2 };
|
|
3860
|
+
}
|
|
3861
|
+
const query = destination.trim();
|
|
3862
|
+
if (!query) return null;
|
|
3863
|
+
const data = await mapsFetchJson(
|
|
3864
|
+
mapsUrl("/v1/geocode", { q: query }, options),
|
|
3865
|
+
options
|
|
3866
|
+
);
|
|
3867
|
+
const lat = finite(data?.latitude);
|
|
3868
|
+
const lng = finite(data?.longitude);
|
|
3869
|
+
if (!data?.ok || lat == null || lng == null) return null;
|
|
3870
|
+
return { lat, lng };
|
|
3871
|
+
}
|
|
3872
|
+
function minutesFromSeconds(seconds) {
|
|
3873
|
+
return Math.max(1, Math.round(seconds / 60));
|
|
3874
|
+
}
|
|
3875
|
+
async function travelTimeFromListing(listing, destination, options = {}) {
|
|
3876
|
+
const raw = listingCoordinates(listing);
|
|
3877
|
+
if (!raw) return null;
|
|
3878
|
+
const origin = coarsenCoordinates(raw, options.maxDecimals);
|
|
3879
|
+
const mode = normalizeMode(options.mode);
|
|
3880
|
+
const cache = options.cache === void 0 ? defaultTravelTimeCache : options.cache;
|
|
3881
|
+
const query = trimmedDestinationQuery(destination);
|
|
3882
|
+
if (typeof destination === "string" && !query) return null;
|
|
3883
|
+
if (query) {
|
|
3884
|
+
const queryHit = recallTravelTime(
|
|
3885
|
+
cache,
|
|
3886
|
+
travelTimeQueryCacheKey(origin, query, mode)
|
|
3887
|
+
);
|
|
3888
|
+
if (queryHit) return queryHit;
|
|
3889
|
+
}
|
|
3890
|
+
const target = await resolveTravelDestination(query ?? destination, options);
|
|
3891
|
+
if (!target) return null;
|
|
3892
|
+
const coordKey = travelTimeCacheKey(origin, target, mode);
|
|
3893
|
+
const stored = cache?.get(coordKey);
|
|
3894
|
+
if (stored) {
|
|
3895
|
+
if (query) {
|
|
3896
|
+
rememberTravelTime(
|
|
3897
|
+
cache,
|
|
3898
|
+
[travelTimeQueryCacheKey(origin, query, mode)],
|
|
3899
|
+
stored
|
|
3900
|
+
);
|
|
3901
|
+
}
|
|
3902
|
+
return { ...stored, cached: true };
|
|
3903
|
+
}
|
|
3904
|
+
const data = await mapsFetchJson(
|
|
3905
|
+
mapsUrl(
|
|
3906
|
+
"/v1/directions",
|
|
3907
|
+
{
|
|
3908
|
+
origin: `${origin.lat},${origin.lng}`,
|
|
3909
|
+
destination: `${target.lat},${target.lng}`,
|
|
3910
|
+
mode
|
|
3911
|
+
},
|
|
3912
|
+
options
|
|
3913
|
+
),
|
|
3914
|
+
options
|
|
3915
|
+
);
|
|
3916
|
+
const seconds = finite(data?.route?.totalTravelTime);
|
|
3917
|
+
const meters = finite(data?.route?.totalDistance);
|
|
3918
|
+
if (!data?.ok || seconds == null || meters == null) return null;
|
|
3919
|
+
const result = {
|
|
3920
|
+
minutes: minutesFromSeconds(seconds),
|
|
3921
|
+
seconds,
|
|
3922
|
+
distanceMeters: meters,
|
|
3923
|
+
distanceKm: Math.round(meters / 100) / 10,
|
|
3924
|
+
mode,
|
|
3925
|
+
origin,
|
|
3926
|
+
destination: target,
|
|
3927
|
+
cached: false
|
|
3928
|
+
};
|
|
3929
|
+
const keys = query ? [coordKey, travelTimeQueryCacheKey(origin, query, mode)] : [coordKey];
|
|
3930
|
+
rememberTravelTime(cache, keys, result);
|
|
3931
|
+
return result;
|
|
3932
|
+
}
|
|
3933
|
+
async function travelTimesFromListing(listing, destinations, options = {}) {
|
|
3934
|
+
const raw = listingCoordinates(listing);
|
|
3935
|
+
if (!raw) return null;
|
|
3936
|
+
const origin = coarsenCoordinates(raw, options.maxDecimals);
|
|
3937
|
+
const targets = destinations.map((destination) => {
|
|
3938
|
+
const lat = finite(destination?.lat);
|
|
3939
|
+
const lng = finite(destination?.lng);
|
|
3940
|
+
return lat == null || lng == null ? null : { lat, lng };
|
|
3941
|
+
}).filter((item) => item !== null);
|
|
3942
|
+
if (targets.length === 0) return [];
|
|
3943
|
+
const data = await mapsFetchJson(
|
|
3944
|
+
mapsUrl("/v1/route-matrix", {}, options),
|
|
3945
|
+
options,
|
|
3946
|
+
{
|
|
3947
|
+
method: "POST",
|
|
3948
|
+
headers: { "content-type": "application/json" },
|
|
3949
|
+
body: JSON.stringify({ origin, destinations: targets })
|
|
3950
|
+
}
|
|
3951
|
+
);
|
|
3952
|
+
if (!data?.ok || !Array.isArray(data.durations)) return null;
|
|
3953
|
+
return targets.map((destination, index) => {
|
|
3954
|
+
const seconds = finite(
|
|
3955
|
+
data.durations && data.durations[index]
|
|
3956
|
+
);
|
|
3957
|
+
if (seconds == null) return null;
|
|
3958
|
+
return { minutes: minutesFromSeconds(seconds), seconds, destination };
|
|
3959
|
+
});
|
|
3960
|
+
}
|
|
3961
|
+
|
|
3962
|
+
// src/map-search.ts
|
|
3963
|
+
var MAP_SEARCH_MAX_PAGE_SIZE = 100;
|
|
3964
|
+
var MAP_SEARCH_DEFAULT_PAGE_SIZE = 100;
|
|
3965
|
+
var MAP_SEARCH_MAX_PAGE = 1e4;
|
|
3966
|
+
var MAP_VIEWPORT_DEBOUNCE_MS = 400;
|
|
3967
|
+
var MAP_POLYGON_MAX_VERTICES = 64;
|
|
3968
|
+
function capMapPageSize(value) {
|
|
3969
|
+
if (value == null || !Number.isFinite(value) || value <= 0) {
|
|
3970
|
+
return MAP_SEARCH_DEFAULT_PAGE_SIZE;
|
|
3971
|
+
}
|
|
3972
|
+
return Math.min(MAP_SEARCH_MAX_PAGE_SIZE, Math.floor(value));
|
|
3973
|
+
}
|
|
3974
|
+
function capMapPage(value) {
|
|
3975
|
+
if (value == null || !Number.isFinite(value) || value <= 1) return 1;
|
|
3976
|
+
return Math.min(MAP_SEARCH_MAX_PAGE, Math.floor(value));
|
|
3977
|
+
}
|
|
3978
|
+
function finitePair(lat, lng) {
|
|
3979
|
+
if (typeof lat !== "number" || typeof lng !== "number") return null;
|
|
3980
|
+
if (!Number.isFinite(lat) || !Number.isFinite(lng)) return null;
|
|
3981
|
+
if (lat < -90 || lat > 90 || lng < -180 || lng > 180) return null;
|
|
3982
|
+
return [lat, lng];
|
|
3983
|
+
}
|
|
3984
|
+
function isMapBounds(bounds) {
|
|
3985
|
+
if (!bounds) return false;
|
|
3986
|
+
const north = finitePair(bounds.north, bounds.east);
|
|
3987
|
+
const south = finitePair(bounds.south, bounds.west);
|
|
3988
|
+
if (!north || !south) return false;
|
|
3989
|
+
return bounds.north > bounds.south && bounds.east > bounds.west;
|
|
3990
|
+
}
|
|
3991
|
+
function isMapPolygon(polygon) {
|
|
3992
|
+
if (!Array.isArray(polygon)) return false;
|
|
3993
|
+
if (polygon.length < 3 || polygon.length > MAP_POLYGON_MAX_VERTICES + 1) {
|
|
3994
|
+
return false;
|
|
3995
|
+
}
|
|
3996
|
+
let unique = 0;
|
|
3997
|
+
let prev = null;
|
|
3998
|
+
for (const point of polygon) {
|
|
3999
|
+
if (!Array.isArray(point)) return false;
|
|
4000
|
+
const pair = finitePair(point[0], point[1]);
|
|
4001
|
+
if (!pair) return false;
|
|
4002
|
+
if (prev && prev[0] === pair[0] && prev[1] === pair[1]) continue;
|
|
4003
|
+
prev = pair;
|
|
4004
|
+
unique += 1;
|
|
4005
|
+
}
|
|
4006
|
+
if (unique >= 2 && polygon.length >= 2) {
|
|
4007
|
+
const first = finitePair(polygon[0]?.[0], polygon[0]?.[1]);
|
|
4008
|
+
const last = finitePair(
|
|
4009
|
+
polygon[polygon.length - 1]?.[0],
|
|
4010
|
+
polygon[polygon.length - 1]?.[1]
|
|
4011
|
+
);
|
|
4012
|
+
if (first && last && first[0] === last[0] && first[1] === last[1] && unique > 1) {
|
|
4013
|
+
unique -= 1;
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
return unique >= 3 && unique <= MAP_POLYGON_MAX_VERTICES;
|
|
4017
|
+
}
|
|
4018
|
+
function mapSearchPins(listings) {
|
|
4019
|
+
const pins = [];
|
|
4020
|
+
for (const listing of listings) {
|
|
4021
|
+
const coords = listingCoordinates(listing);
|
|
4022
|
+
if (!coords || !listing.id) continue;
|
|
4023
|
+
const src = listing.coverImage?.src;
|
|
4024
|
+
pins.push({
|
|
4025
|
+
id: listing.id,
|
|
4026
|
+
lat: coords.lat,
|
|
4027
|
+
lng: coords.lng,
|
|
4028
|
+
price: listing.price ?? null,
|
|
4029
|
+
coverImage: src ? src : null
|
|
4030
|
+
});
|
|
4031
|
+
}
|
|
4032
|
+
return pins;
|
|
4033
|
+
}
|
|
4034
|
+
function listingsResult(listings, meta, requestedPageSize) {
|
|
4035
|
+
return {
|
|
4036
|
+
pins: mapSearchPins(listings),
|
|
4037
|
+
cards: listings.map((listing) => toListingCardModel(listing)),
|
|
4038
|
+
listings,
|
|
4039
|
+
page: meta.page ?? 1,
|
|
4040
|
+
pageSize: meta.limit ?? requestedPageSize,
|
|
4041
|
+
total: meta.total ?? listings.length,
|
|
4042
|
+
totalPages: meta.totalPages ?? 0
|
|
4043
|
+
};
|
|
4044
|
+
}
|
|
4045
|
+
function searchParams(area, options) {
|
|
4046
|
+
const params = {
|
|
4047
|
+
page: capMapPage(options.page),
|
|
4048
|
+
limit: capMapPageSize(options.pageSize)
|
|
4049
|
+
};
|
|
4050
|
+
if (options.q !== void 0) params.q = options.q;
|
|
4051
|
+
if (options.sort !== void 0) params.sort = options.sort;
|
|
4052
|
+
if (options.location !== void 0) params.location = options.location;
|
|
4053
|
+
if (options.filters) params.filters = options.filters;
|
|
4054
|
+
if (area.polygon) params.polygon = area.polygon;
|
|
4055
|
+
else if (area.bounds) params.bounds = area.bounds;
|
|
4056
|
+
return params;
|
|
4057
|
+
}
|
|
4058
|
+
async function runMapSearch(siteId, area, options) {
|
|
4059
|
+
const pageSize = capMapPageSize(options.pageSize);
|
|
4060
|
+
const result = await queryListings({
|
|
4061
|
+
siteId,
|
|
4062
|
+
params: searchParams(area, options),
|
|
4063
|
+
baseUrl: options.baseUrl,
|
|
4064
|
+
fetch: options.fetch,
|
|
4065
|
+
signal: options.signal,
|
|
4066
|
+
publishableKey: options.publishableKey,
|
|
4067
|
+
next: options.next
|
|
4068
|
+
});
|
|
4069
|
+
return listingsResult(result.listings ?? [], result, pageSize);
|
|
4070
|
+
}
|
|
4071
|
+
async function searchListingsInBounds(siteId, options) {
|
|
4072
|
+
if (!isMapBounds(options.bounds)) {
|
|
4073
|
+
throw new TypeError(
|
|
4074
|
+
"searchListingsInBounds: bounds must be a finite rectangle with north > south and east > west (no antimeridian)."
|
|
4075
|
+
);
|
|
4076
|
+
}
|
|
4077
|
+
return runMapSearch(siteId, { bounds: options.bounds }, options);
|
|
4078
|
+
}
|
|
4079
|
+
async function searchListingsInPolygon(siteId, options) {
|
|
4080
|
+
if (!isMapPolygon(options.polygon)) {
|
|
4081
|
+
throw new TypeError(
|
|
4082
|
+
`searchListingsInPolygon: polygon must be 3\u2013${MAP_POLYGON_MAX_VERTICES} finite [lat, lng] points.`
|
|
4083
|
+
);
|
|
4084
|
+
}
|
|
4085
|
+
return runMapSearch(siteId, { polygon: options.polygon }, options);
|
|
4086
|
+
}
|
|
4087
|
+
function clampZoom(zoom) {
|
|
4088
|
+
if (!Number.isFinite(zoom)) return 0;
|
|
4089
|
+
return Math.min(22, Math.max(0, zoom));
|
|
4090
|
+
}
|
|
4091
|
+
function mapClusterCellDegrees(zoom) {
|
|
4092
|
+
return 360 / 2 ** clampZoom(zoom) / 4;
|
|
4093
|
+
}
|
|
4094
|
+
function usablePin(pin) {
|
|
4095
|
+
return finitePair(pin.lat, pin.lng) !== null && !(pin.lat === 0 && pin.lng === 0);
|
|
4096
|
+
}
|
|
4097
|
+
function groupPrecision(group) {
|
|
4098
|
+
let min = 12;
|
|
4099
|
+
for (const pin of group) {
|
|
4100
|
+
min = Math.min(
|
|
4101
|
+
min,
|
|
4102
|
+
coordinateDecimals(pin.lat),
|
|
4103
|
+
coordinateDecimals(pin.lng)
|
|
4104
|
+
);
|
|
4105
|
+
}
|
|
4106
|
+
return min;
|
|
4107
|
+
}
|
|
4108
|
+
function multiCluster(key, group) {
|
|
4109
|
+
const lat = group.reduce((sum, pin) => sum + pin.lat, 0) / group.length;
|
|
4110
|
+
const lng = group.reduce((sum, pin) => sum + pin.lng, 0) / group.length;
|
|
4111
|
+
const center = coarsenCoordinates({ lat, lng }, groupPrecision(group));
|
|
4112
|
+
return {
|
|
4113
|
+
id: key,
|
|
4114
|
+
lat: center.lat,
|
|
4115
|
+
lng: center.lng,
|
|
4116
|
+
count: group.length,
|
|
4117
|
+
pinIds: group.map((pin) => pin.id),
|
|
4118
|
+
pin: null
|
|
4119
|
+
};
|
|
4120
|
+
}
|
|
4121
|
+
function singleCluster(pin) {
|
|
4122
|
+
return {
|
|
4123
|
+
id: pin.id,
|
|
4124
|
+
lat: pin.lat,
|
|
4125
|
+
lng: pin.lng,
|
|
4126
|
+
count: 1,
|
|
4127
|
+
pinIds: [pin.id],
|
|
4128
|
+
pin
|
|
4129
|
+
};
|
|
4130
|
+
}
|
|
4131
|
+
function clusterPins(pins, zoom) {
|
|
4132
|
+
if (pins.length === 0) return [];
|
|
4133
|
+
const cell = mapClusterCellDegrees(zoom);
|
|
4134
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4135
|
+
for (const pin of pins) {
|
|
4136
|
+
if (!usablePin(pin)) continue;
|
|
4137
|
+
const key = `${Math.floor(pin.lat / cell)}:${Math.floor(pin.lng / cell)}`;
|
|
4138
|
+
const list = groups.get(key);
|
|
4139
|
+
if (list) list.push(pin);
|
|
4140
|
+
else groups.set(key, [pin]);
|
|
4141
|
+
}
|
|
4142
|
+
const clusters = [];
|
|
4143
|
+
for (const [key, group] of groups) {
|
|
4144
|
+
const only = group[0];
|
|
4145
|
+
clusters.push(
|
|
4146
|
+
group.length === 1 && only ? singleCluster(only) : multiCluster(key, group)
|
|
4147
|
+
);
|
|
4148
|
+
}
|
|
4149
|
+
clusters.sort((a, b) => a.id.localeCompare(b.id));
|
|
4150
|
+
return clusters;
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
// src/fetchers-photos.ts
|
|
4154
|
+
var MEDIA_UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
4155
|
+
var HIDDEN_SIMILAR_PHOTOS = {
|
|
4156
|
+
available: false,
|
|
4157
|
+
items: []
|
|
4158
|
+
};
|
|
4159
|
+
async function getSimilarByPhoto(siteId, listingId, mediaId, options = {}) {
|
|
4160
|
+
const { baseUrl, fetch: fetchImpl, next, limit } = options;
|
|
4161
|
+
const resolvedSiteId = await coerceSiteId(siteId);
|
|
4162
|
+
const lookupId = listingLookupKey(listingId ?? "");
|
|
4163
|
+
if (!lookupId || lookupId === "undefined" || lookupId === "null") {
|
|
4164
|
+
throw new TypeError("getSimilarByPhoto: `listingId` is required");
|
|
4165
|
+
}
|
|
4166
|
+
const photoId = typeof mediaId === "string" ? mediaId.trim() : "";
|
|
4167
|
+
if (!photoId) {
|
|
4168
|
+
throw new TypeError("getSimilarByPhoto: `mediaId` is required");
|
|
4169
|
+
}
|
|
4170
|
+
if (!MEDIA_UUID_RE.test(photoId)) {
|
|
4171
|
+
return HIDDEN_SIMILAR_PHOTOS;
|
|
4172
|
+
}
|
|
4173
|
+
const base = normalizeBaseUrl(baseUrl);
|
|
4174
|
+
const params = new URLSearchParams({ mediaId: photoId });
|
|
4175
|
+
if (typeof limit === "number" && Number.isFinite(limit) && limit > 0) {
|
|
4176
|
+
params.set("limit", String(Math.floor(limit)));
|
|
4177
|
+
}
|
|
4178
|
+
const url = `${base}/api/sites/${encodeURIComponent(resolvedSiteId)}/listings/${encodeURIComponent(
|
|
4179
|
+
lookupId
|
|
4180
|
+
)}/similar-photos?${params.toString()}`;
|
|
4181
|
+
const data = await callJson(
|
|
4182
|
+
url,
|
|
4183
|
+
{ method: "GET", headers: { Accept: "application/json" }, next },
|
|
4184
|
+
fetchImpl ?? fetch
|
|
4185
|
+
);
|
|
4186
|
+
return {
|
|
4187
|
+
available: data.available !== false,
|
|
4188
|
+
items: Array.isArray(data.items) ? data.items : []
|
|
4189
|
+
};
|
|
4190
|
+
}
|
|
4191
|
+
|
|
4192
|
+
// src/listing-photos.ts
|
|
4193
|
+
var PHOTO_GROUP_OTHER_KEY = "outros";
|
|
4194
|
+
var PHOTO_GROUP_OTHER_LABEL = "Outras fotos";
|
|
4195
|
+
function normalizeRoomLabel(value) {
|
|
4196
|
+
return value.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
4197
|
+
}
|
|
4198
|
+
var ROOM_GROUPS = [
|
|
4199
|
+
{
|
|
4200
|
+
key: "fachada",
|
|
4201
|
+
label: "Fachada",
|
|
4202
|
+
members: [
|
|
4203
|
+
"fachada",
|
|
4204
|
+
"exterior",
|
|
4205
|
+
"frente",
|
|
4206
|
+
"facade",
|
|
4207
|
+
"fachada do predio",
|
|
4208
|
+
"predio",
|
|
4209
|
+
"building exterior",
|
|
4210
|
+
"area externa do predio"
|
|
4211
|
+
]
|
|
4212
|
+
},
|
|
4213
|
+
{
|
|
4214
|
+
key: "sala",
|
|
4215
|
+
label: "Sala",
|
|
4216
|
+
members: [
|
|
4217
|
+
"sala",
|
|
4218
|
+
"sala de estar",
|
|
4219
|
+
"living",
|
|
4220
|
+
"estar",
|
|
4221
|
+
"sala de tv",
|
|
4222
|
+
"living room",
|
|
4223
|
+
"sala de estar e jantar",
|
|
4224
|
+
"sala integrada"
|
|
4225
|
+
]
|
|
4226
|
+
},
|
|
4227
|
+
{
|
|
4228
|
+
key: "sala de jantar",
|
|
4229
|
+
label: "Sala de jantar",
|
|
4230
|
+
members: ["sala de jantar", "jantar", "dining room", "copa jantar"]
|
|
4231
|
+
},
|
|
4232
|
+
{
|
|
4233
|
+
key: "cozinha",
|
|
4234
|
+
label: "Cozinha",
|
|
4235
|
+
members: [
|
|
4236
|
+
"cozinha",
|
|
4237
|
+
"copa",
|
|
4238
|
+
"copa cozinha",
|
|
4239
|
+
"cozinha americana",
|
|
4240
|
+
"kitchen"
|
|
4241
|
+
]
|
|
4242
|
+
},
|
|
4243
|
+
{
|
|
4244
|
+
key: "quarto",
|
|
4245
|
+
label: "Quartos",
|
|
4246
|
+
members: [
|
|
4247
|
+
"quarto",
|
|
4248
|
+
"dormitorio",
|
|
4249
|
+
"suite",
|
|
4250
|
+
"suite master",
|
|
4251
|
+
"quarto de casal",
|
|
4252
|
+
"quarto de solteiro",
|
|
4253
|
+
"quarto infantil",
|
|
4254
|
+
"bedroom",
|
|
4255
|
+
"master bedroom"
|
|
4256
|
+
]
|
|
4257
|
+
},
|
|
4258
|
+
{
|
|
4259
|
+
key: "banheiro",
|
|
4260
|
+
label: "Banheiros",
|
|
4261
|
+
members: [
|
|
4262
|
+
"banheiro",
|
|
4263
|
+
"lavabo",
|
|
4264
|
+
"wc",
|
|
4265
|
+
"toalete",
|
|
4266
|
+
"bathroom",
|
|
4267
|
+
"banheiro social",
|
|
4268
|
+
"banheiro da suite"
|
|
4269
|
+
]
|
|
4270
|
+
},
|
|
4271
|
+
{
|
|
4272
|
+
key: "varanda",
|
|
4273
|
+
label: "Varanda",
|
|
4274
|
+
members: ["varanda", "sacada", "terraco", "balcony", "terrace"]
|
|
4275
|
+
},
|
|
4276
|
+
{
|
|
4277
|
+
key: "area gourmet",
|
|
4278
|
+
label: "\xC1rea gourmet",
|
|
4279
|
+
members: [
|
|
4280
|
+
"area gourmet",
|
|
4281
|
+
"varanda gourmet",
|
|
4282
|
+
"espaco gourmet",
|
|
4283
|
+
"churrasqueira",
|
|
4284
|
+
"gourmet",
|
|
4285
|
+
"terraco gourmet"
|
|
4286
|
+
]
|
|
4287
|
+
},
|
|
4288
|
+
{
|
|
4289
|
+
key: "closet",
|
|
4290
|
+
label: "Closet",
|
|
4291
|
+
members: ["closet", "closet da suite", "walk in closet"]
|
|
4292
|
+
},
|
|
4293
|
+
{
|
|
4294
|
+
key: "escritorio",
|
|
4295
|
+
label: "Escrit\xF3rio",
|
|
4296
|
+
members: ["escritorio", "home office", "office"]
|
|
4297
|
+
},
|
|
4298
|
+
{
|
|
4299
|
+
key: "area de servico",
|
|
4300
|
+
label: "\xC1rea de servi\xE7o",
|
|
4301
|
+
members: ["area de servico", "lavanderia", "laundry", "servico"]
|
|
4302
|
+
},
|
|
4303
|
+
{ key: "despensa", label: "Despensa", members: ["despensa", "pantry"] },
|
|
4304
|
+
{
|
|
4305
|
+
key: "corredor",
|
|
4306
|
+
label: "Corredor",
|
|
4307
|
+
members: ["corredor", "circulacao", "hallway"]
|
|
4308
|
+
},
|
|
4309
|
+
{
|
|
4310
|
+
key: "hall",
|
|
4311
|
+
label: "Hall",
|
|
4312
|
+
members: [
|
|
4313
|
+
"hall",
|
|
4314
|
+
"hall de entrada",
|
|
4315
|
+
"entrada",
|
|
4316
|
+
"recepcao",
|
|
4317
|
+
"lobby",
|
|
4318
|
+
"portaria"
|
|
4319
|
+
]
|
|
4320
|
+
},
|
|
4321
|
+
{
|
|
4322
|
+
key: "garagem",
|
|
4323
|
+
label: "Garagem",
|
|
4324
|
+
members: [
|
|
4325
|
+
"garagem",
|
|
4326
|
+
"vaga",
|
|
4327
|
+
"vagas",
|
|
4328
|
+
"estacionamento",
|
|
4329
|
+
"garage",
|
|
4330
|
+
"vaga de garagem"
|
|
4331
|
+
]
|
|
4332
|
+
},
|
|
4333
|
+
{
|
|
4334
|
+
key: "piscina",
|
|
4335
|
+
label: "Piscina",
|
|
4336
|
+
members: ["piscina", "pool", "piscina do condominio"]
|
|
4337
|
+
},
|
|
4338
|
+
{
|
|
4339
|
+
key: "academia",
|
|
4340
|
+
label: "Academia",
|
|
4341
|
+
members: ["academia", "fitness", "gym", "espaco fitness"]
|
|
4342
|
+
},
|
|
4343
|
+
{
|
|
4344
|
+
key: "salao de festas",
|
|
4345
|
+
label: "Sal\xE3o de festas",
|
|
4346
|
+
members: ["salao de festas", "festas", "salao", "party room"]
|
|
4347
|
+
},
|
|
4348
|
+
{
|
|
4349
|
+
key: "playground",
|
|
4350
|
+
label: "Playground",
|
|
4351
|
+
members: ["playground", "brinquedoteca", "espaco kids"]
|
|
4352
|
+
},
|
|
4353
|
+
{
|
|
4354
|
+
key: "jardim",
|
|
4355
|
+
label: "Jardim",
|
|
4356
|
+
members: ["jardim", "quintal", "area externa", "garden", "backyard"]
|
|
4357
|
+
},
|
|
4358
|
+
{
|
|
4359
|
+
key: "vista",
|
|
4360
|
+
label: "Vista",
|
|
4361
|
+
members: ["vista", "view", "vista da varanda"]
|
|
4362
|
+
},
|
|
4363
|
+
{
|
|
4364
|
+
key: "planta",
|
|
4365
|
+
label: "Planta",
|
|
4366
|
+
members: ["planta", "planta baixa", "floorplan", "floor plan"]
|
|
4367
|
+
}
|
|
4368
|
+
];
|
|
4369
|
+
var GROUP_BY_MEMBER = /* @__PURE__ */ new Map();
|
|
4370
|
+
for (const group of ROOM_GROUPS) {
|
|
4371
|
+
for (const member of group.members) {
|
|
4372
|
+
GROUP_BY_MEMBER.set(member, { key: group.key, label: group.label });
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
var NON_ROOM_LABELS = /* @__PURE__ */ new Set(["", "outro", "outros", "other", "unknown"]);
|
|
4376
|
+
function capitalize(value) {
|
|
4377
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
4378
|
+
}
|
|
4379
|
+
function photoRoomLabel(roomType) {
|
|
4380
|
+
const raw = (roomType ?? "").trim();
|
|
4381
|
+
const normalized = normalizeRoomLabel(raw);
|
|
4382
|
+
if (NON_ROOM_LABELS.has(normalized)) {
|
|
4383
|
+
return { key: PHOTO_GROUP_OTHER_KEY, label: PHOTO_GROUP_OTHER_LABEL };
|
|
4384
|
+
}
|
|
4385
|
+
const known = GROUP_BY_MEMBER.get(normalized);
|
|
4386
|
+
if (known) return known;
|
|
4387
|
+
return { key: normalized, label: capitalize(raw) };
|
|
4388
|
+
}
|
|
4389
|
+
function isPhoto(item) {
|
|
4390
|
+
return (item.type || "image") === "image" && typeof item.src === "string";
|
|
4391
|
+
}
|
|
4392
|
+
function listingPhotoGroups(listing) {
|
|
4393
|
+
const groups = /* @__PURE__ */ new Map();
|
|
4394
|
+
const photos = [...listing.media ?? []].filter(isPhoto).sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
4395
|
+
for (const photo of photos) {
|
|
4396
|
+
const { key, label } = photoRoomLabel(photo.roomType);
|
|
4397
|
+
const group = groups.get(key);
|
|
4398
|
+
if (group) {
|
|
4399
|
+
group.photos.push(photo);
|
|
4400
|
+
} else {
|
|
4401
|
+
groups.set(key, { key, label, photos: [photo] });
|
|
4402
|
+
}
|
|
4403
|
+
}
|
|
4404
|
+
const ordered = [...groups.values()];
|
|
4405
|
+
const otherIndex = ordered.findIndex((g) => g.key === PHOTO_GROUP_OTHER_KEY);
|
|
4406
|
+
if (otherIndex >= 0 && otherIndex !== ordered.length - 1) {
|
|
4407
|
+
const [other] = ordered.splice(otherIndex, 1);
|
|
4408
|
+
ordered.push(other);
|
|
4409
|
+
}
|
|
4410
|
+
return ordered;
|
|
4411
|
+
}
|
|
4412
|
+
function listingVisualHighlights(listing, options) {
|
|
4413
|
+
const limit = Math.max(0, Math.floor(options?.limit ?? 8));
|
|
4414
|
+
if (limit === 0) return [];
|
|
4415
|
+
const counts = /* @__PURE__ */ new Map();
|
|
4416
|
+
let seen = 0;
|
|
4417
|
+
for (const item of listing.media ?? []) {
|
|
4418
|
+
if (!isPhoto(item) || !Array.isArray(item.features)) continue;
|
|
4419
|
+
for (const feature of item.features) {
|
|
4420
|
+
if (typeof feature !== "string") continue;
|
|
4421
|
+
const text = feature.trim();
|
|
4422
|
+
if (!text) continue;
|
|
4423
|
+
const key = normalizeRoomLabel(text);
|
|
4424
|
+
if (!key) continue;
|
|
4425
|
+
const entry = counts.get(key);
|
|
4426
|
+
if (entry) {
|
|
4427
|
+
entry.count += 1;
|
|
4428
|
+
} else {
|
|
4429
|
+
counts.set(key, { text, count: 1, seen: seen++ });
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
return [...counts.values()].sort((a, b) => b.count - a.count || a.seen - b.seen).slice(0, limit).map((entry) => entry.text);
|
|
4434
|
+
}
|
|
3236
4435
|
|
|
3237
4436
|
// src/fetchers-market.ts
|
|
3238
4437
|
var RATE_LIMITED_MESSAGE = "Muitas consultas em pouco tempo. Tente novamente em instantes.";
|
|
@@ -3471,15 +4670,24 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3471
4670
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3472
4671
|
0 && (module.exports = {
|
|
3473
4672
|
AMENITY_FALLBACK_LABELS,
|
|
4673
|
+
DEFAULT_MAPS_BASE_URL,
|
|
3474
4674
|
DEFAULT_PHONE_COUNTRY_CODE,
|
|
3475
4675
|
FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
3476
4676
|
GaragemSdkError,
|
|
3477
4677
|
LISTING_AMENITY_TITLES,
|
|
3478
4678
|
LISTING_DESCRIPTION_CLAMP,
|
|
3479
4679
|
LeadSubmitError,
|
|
4680
|
+
MAPS_MAX_IMAGE_EDGE,
|
|
4681
|
+
MAPS_SITE_HEADER,
|
|
4682
|
+
MAP_POLYGON_MAX_VERTICES,
|
|
4683
|
+
MAP_SEARCH_DEFAULT_PAGE_SIZE,
|
|
4684
|
+
MAP_SEARCH_MAX_PAGE_SIZE,
|
|
4685
|
+
MAP_VIEWPORT_DEBOUNCE_MS,
|
|
3480
4686
|
MATCHED_PHOTO_COVER_MAX_DISTANCE,
|
|
3481
4687
|
MAX_NATIONAL_PHONE_DIGITS,
|
|
3482
4688
|
PHONE_COUNTRIES,
|
|
4689
|
+
PHOTO_GROUP_OTHER_KEY,
|
|
4690
|
+
PHOTO_GROUP_OTHER_LABEL,
|
|
3483
4691
|
PHOTO_SEARCH_MIN_QUERY_LENGTH,
|
|
3484
4692
|
SEARCH_EMPTY_COPY,
|
|
3485
4693
|
SEARCH_SORT_RELEVANCE,
|
|
@@ -3491,17 +4699,28 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3491
4699
|
VISIT_TIME_ZONE,
|
|
3492
4700
|
applyMatchedPhotoCover,
|
|
3493
4701
|
applyPathFilter,
|
|
4702
|
+
boundaryCitySlug,
|
|
4703
|
+
boundaryLayerId,
|
|
4704
|
+
boundaryLayerUrl,
|
|
3494
4705
|
buildQueryListingsParams,
|
|
3495
4706
|
canonicalizeSearchHref,
|
|
4707
|
+
capMapPage,
|
|
4708
|
+
capMapPageSize,
|
|
3496
4709
|
clearStagedPathFilters,
|
|
4710
|
+
clearTravelTimeCache,
|
|
4711
|
+
clusterPins,
|
|
4712
|
+
coarsenCoordinates,
|
|
3497
4713
|
coerceNpmVersion,
|
|
3498
4714
|
collapseDuplicatedBrazilianMobileNine,
|
|
3499
4715
|
compareSemver,
|
|
3500
4716
|
composeSearchPublicHref,
|
|
3501
4717
|
composeSearchPublicPath,
|
|
4718
|
+
coordinateDecimals,
|
|
3502
4719
|
countFacetChoices,
|
|
3503
4720
|
countOptionLabel,
|
|
4721
|
+
createClient,
|
|
3504
4722
|
createGaragemClient,
|
|
4723
|
+
createTravelTimeCache,
|
|
3505
4724
|
defaultPhoneCountry,
|
|
3506
4725
|
displayPathLocation,
|
|
3507
4726
|
expandVisitSchedule,
|
|
@@ -3511,6 +4730,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3511
4730
|
formatGroupedInteger,
|
|
3512
4731
|
formatListingPrice,
|
|
3513
4732
|
formatPhoneNational,
|
|
4733
|
+
getBoundaryLayer,
|
|
3514
4734
|
getCmsCollection,
|
|
3515
4735
|
getCmsCollections,
|
|
3516
4736
|
getCmsEntries,
|
|
@@ -3521,6 +4741,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3521
4741
|
getListings,
|
|
3522
4742
|
getNeighborhoodSummary,
|
|
3523
4743
|
getSearchUi,
|
|
4744
|
+
getSimilarByPhoto,
|
|
3524
4745
|
getSimilarListings,
|
|
3525
4746
|
getSite,
|
|
3526
4747
|
hasShowcaseLeadsPostUrl,
|
|
@@ -3528,6 +4749,8 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3528
4749
|
hrefForPathFilters,
|
|
3529
4750
|
hrefWithExplicitPage,
|
|
3530
4751
|
isListingDetailPath,
|
|
4752
|
+
isMapBounds,
|
|
4753
|
+
isMapPolygon,
|
|
3531
4754
|
isPhotoSearchOnPin,
|
|
3532
4755
|
isStudioPreviewHost,
|
|
3533
4756
|
isValidPhone,
|
|
@@ -3536,6 +4759,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3536
4759
|
listingAmenityGroups,
|
|
3537
4760
|
listingBreadcrumb,
|
|
3538
4761
|
listingBusinessLabel,
|
|
4762
|
+
listingCoordinates,
|
|
3539
4763
|
listingDescriptionPreview,
|
|
3540
4764
|
listingDetailFieldsModel,
|
|
3541
4765
|
listingDetailModel,
|
|
@@ -3545,12 +4769,25 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3545
4769
|
listingLookupKey,
|
|
3546
4770
|
listingMapsHref,
|
|
3547
4771
|
listingMediaOverlays,
|
|
4772
|
+
listingPhotoGroups,
|
|
3548
4773
|
listingPublicPath,
|
|
4774
|
+
listingStaticMapUrl,
|
|
4775
|
+
listingStreetViewAvailable,
|
|
4776
|
+
listingStreetViewMetadataUrl,
|
|
4777
|
+
listingStreetViewUrl,
|
|
3549
4778
|
listingValues,
|
|
4779
|
+
listingVisualHighlights,
|
|
4780
|
+
mapClusterCellDegrees,
|
|
4781
|
+
mapSearchPins,
|
|
4782
|
+
mapsExportsPublished,
|
|
3550
4783
|
marketExportsAvailableAt,
|
|
3551
4784
|
marketPositionLabel,
|
|
4785
|
+
maxZoomForCoordinates,
|
|
3552
4786
|
mergeAppliedSearchQueryIntoSearch,
|
|
3553
4787
|
nationalPhoneDigits,
|
|
4788
|
+
neighborhoodBoundaryLayer,
|
|
4789
|
+
neighborhoodBoundaryUrl,
|
|
4790
|
+
normalizeMapsBaseUrl,
|
|
3554
4791
|
normalizeVisitDate,
|
|
3555
4792
|
normalizeVisitTime,
|
|
3556
4793
|
paginationPages,
|
|
@@ -3564,6 +4801,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3564
4801
|
pathFiltersToQueryFilters,
|
|
3565
4802
|
pathLocationToFilterInput,
|
|
3566
4803
|
phoneCountrySearchValue,
|
|
4804
|
+
photoRoomLabel,
|
|
3567
4805
|
photoSearchUrl,
|
|
3568
4806
|
priceBandLabel,
|
|
3569
4807
|
publicSearchHref,
|
|
@@ -3575,10 +4813,13 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3575
4813
|
requestPriceEstimate,
|
|
3576
4814
|
resolveMatchedCoverPhoto,
|
|
3577
4815
|
resolvePublicSiteId,
|
|
4816
|
+
resolveTravelDestination,
|
|
3578
4817
|
searchChromeModel,
|
|
3579
4818
|
searchHrefUsesLegacyFilterQuery,
|
|
3580
4819
|
searchListingPhotos,
|
|
3581
4820
|
searchListings,
|
|
4821
|
+
searchListingsInBounds,
|
|
4822
|
+
searchListingsInPolygon,
|
|
3582
4823
|
searchResultsHeading,
|
|
3583
4824
|
searchSortOptions,
|
|
3584
4825
|
serializeAppliedSearchQuery,
|
|
@@ -3591,8 +4832,12 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3591
4832
|
studioLeadInstruction,
|
|
3592
4833
|
studioListingCardInstruction,
|
|
3593
4834
|
studioListingDetailInstruction,
|
|
4835
|
+
studioMapsInstruction,
|
|
3594
4836
|
studioMarketInstruction,
|
|
4837
|
+
studioPhotoInstruction,
|
|
4838
|
+
studioPhotoInstructionFor,
|
|
3595
4839
|
studioPhotoSearchInstruction,
|
|
4840
|
+
studioPublishableKeyInstruction,
|
|
3596
4841
|
studioSdkPinInstruction,
|
|
3597
4842
|
studioSearchInstruction,
|
|
3598
4843
|
studioSearchLandmarkInstruction,
|
|
@@ -3602,6 +4847,9 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
3602
4847
|
toE164,
|
|
3603
4848
|
toListingCardModel,
|
|
3604
4849
|
toolbarFilterIds,
|
|
4850
|
+
travelTimeCacheKey,
|
|
4851
|
+
travelTimeFromListing,
|
|
4852
|
+
travelTimesFromListing,
|
|
3605
4853
|
truncateNationalPhoneDigits,
|
|
3606
4854
|
unavailableReactImports,
|
|
3607
4855
|
visibleSearchFilters
|