@garagem-ai/site-sdk 0.9.0 → 0.10.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/dist/index.d.mts +135 -13
- package/dist/index.d.ts +135 -13
- package/dist/index.js +436 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +423 -69
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +4 -4
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +4 -4
- package/dist/react.mjs.map +1 -1
- package/dist/{types-photo-search-D88oevZv.d.mts → types-photo-search-DIoV75SN.d.mts} +1 -1
- package/dist/{types-photo-search-D88oevZv.d.ts → types-photo-search-DIoV75SN.d.ts} +1 -1
- package/package.json +2 -2
- package/src/index.ts +24 -0
- package/src/leads.ts +47 -3
- package/src/map-search.ts +9 -5
- package/src/seller-lead.ts +428 -0
- package/src/studio-contract.ts +71 -11
package/dist/index.js
CHANGED
|
@@ -42,6 +42,10 @@ __export(src_exports, {
|
|
|
42
42
|
PHOTO_SEARCH_MIN_QUERY_LENGTH: () => PHOTO_SEARCH_MIN_QUERY_LENGTH,
|
|
43
43
|
SEARCH_EMPTY_COPY: () => SEARCH_EMPTY_COPY,
|
|
44
44
|
SEARCH_SORT_RELEVANCE: () => SEARCH_SORT_RELEVANCE,
|
|
45
|
+
SELLER_LEAD_PHOTO_MAX_BYTES: () => SELLER_LEAD_PHOTO_MAX_BYTES,
|
|
46
|
+
SELLER_LEAD_PHOTO_MAX_COUNT: () => SELLER_LEAD_PHOTO_MAX_COUNT,
|
|
47
|
+
SELLER_LEAD_PHOTO_TYPES: () => SELLER_LEAD_PHOTO_TYPES,
|
|
48
|
+
STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG: () => STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG,
|
|
45
49
|
STUDIO_DEFAULT_VISIT_SCHEDULE: () => STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
46
50
|
STUDIO_SDK_CONTRACT: () => STUDIO_SDK_CONTRACT,
|
|
47
51
|
STUDIO_SDK_PACKAGE: () => STUDIO_SDK_PACKAGE,
|
|
@@ -103,7 +107,10 @@ __export(src_exports, {
|
|
|
103
107
|
isMapBounds: () => isMapBounds,
|
|
104
108
|
isMapPolygon: () => isMapPolygon,
|
|
105
109
|
isPhotoSearchOnPin: () => isPhotoSearchOnPin,
|
|
110
|
+
isSellerLeadOnPin: () => isSellerLeadOnPin,
|
|
106
111
|
isStudioPreviewHost: () => isStudioPreviewHost,
|
|
112
|
+
isValidEmail: () => isValidEmail,
|
|
113
|
+
isValidName: () => isValidName,
|
|
107
114
|
isValidPhone: () => isValidPhone,
|
|
108
115
|
isVisitSlotAllowed: () => isVisitSlotAllowed,
|
|
109
116
|
labelAmenities: () => labelAmenities,
|
|
@@ -173,6 +180,8 @@ __export(src_exports, {
|
|
|
173
180
|
searchListingsInPolygon: () => searchListingsInPolygon,
|
|
174
181
|
searchResultsHeading: () => searchResultsHeading,
|
|
175
182
|
searchSortOptions: () => searchSortOptions,
|
|
183
|
+
sellerAddressErrors: () => sellerAddressErrors,
|
|
184
|
+
sellerPhotoSchedule: () => sellerPhotoSchedule,
|
|
176
185
|
serializeAppliedSearchQuery: () => serializeAppliedSearchQuery2,
|
|
177
186
|
slotsForDate: () => slotsForDate,
|
|
178
187
|
studioAmenityInstruction: () => studioAmenityInstruction,
|
|
@@ -183,6 +192,7 @@ __export(src_exports, {
|
|
|
183
192
|
studioLeadInstruction: () => studioLeadInstruction,
|
|
184
193
|
studioListingCardInstruction: () => studioListingCardInstruction,
|
|
185
194
|
studioListingDetailInstruction: () => studioListingDetailInstruction,
|
|
195
|
+
studioMapSearchInstruction: () => studioMapSearchInstruction,
|
|
186
196
|
studioMapsInstruction: () => studioMapsInstruction,
|
|
187
197
|
studioMarketInstruction: () => studioMarketInstruction,
|
|
188
198
|
studioPhotoInstruction: () => studioPhotoInstruction,
|
|
@@ -192,8 +202,10 @@ __export(src_exports, {
|
|
|
192
202
|
studioSdkPinInstruction: () => studioSdkPinInstruction,
|
|
193
203
|
studioSearchInstruction: () => studioSearchInstruction,
|
|
194
204
|
studioSearchLandmarkInstruction: () => studioSearchLandmarkInstruction,
|
|
205
|
+
studioSellerLeadSdkInstruction: () => studioSellerLeadSdkInstruction,
|
|
195
206
|
studioSiteWidthCss: () => studioSiteWidthCss,
|
|
196
207
|
submitContactLead: () => submitContactLead,
|
|
208
|
+
submitSellerLead: () => submitSellerLead,
|
|
197
209
|
submitVisitLead: () => submitVisitLead,
|
|
198
210
|
toE164: () => toE164,
|
|
199
211
|
toListingCardModel: () => toListingCardModel,
|
|
@@ -203,6 +215,7 @@ __export(src_exports, {
|
|
|
203
215
|
travelTimesFromListing: () => travelTimesFromListing,
|
|
204
216
|
truncateNationalPhoneDigits: () => truncateNationalPhoneDigits,
|
|
205
217
|
unavailableReactImports: () => unavailableReactImports,
|
|
218
|
+
uploadSellerLeadPhoto: () => uploadSellerLeadPhoto,
|
|
206
219
|
visibleSearchFilters: () => visibleSearchFilters
|
|
207
220
|
});
|
|
208
221
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -267,13 +280,13 @@ function finiteNonNegative(value) {
|
|
|
267
280
|
}
|
|
268
281
|
return null;
|
|
269
282
|
}
|
|
270
|
-
function parseSdkErrorBody(
|
|
271
|
-
const raw =
|
|
272
|
-
if (!
|
|
283
|
+
function parseSdkErrorBody(text2) {
|
|
284
|
+
const raw = text2 ? text2.slice(0, 200) : "";
|
|
285
|
+
if (!text2) {
|
|
273
286
|
return { reason: null, retryAfterSeconds: null, summary: "" };
|
|
274
287
|
}
|
|
275
288
|
try {
|
|
276
|
-
const body = JSON.parse(
|
|
289
|
+
const body = JSON.parse(text2);
|
|
277
290
|
if (!body || typeof body !== "object") {
|
|
278
291
|
return { reason: null, retryAfterSeconds: null, summary: raw };
|
|
279
292
|
}
|
|
@@ -369,8 +382,8 @@ var GaragemSdkError = class extends Error {
|
|
|
369
382
|
}
|
|
370
383
|
};
|
|
371
384
|
async function readGaragemSdkError(response, url) {
|
|
372
|
-
const
|
|
373
|
-
const parsed = parseSdkErrorBody(
|
|
385
|
+
const text2 = await response.text().catch(() => "");
|
|
386
|
+
const parsed = parseSdkErrorBody(text2);
|
|
374
387
|
const retryAfter = response.status === 429 ? retryAfterFromResponse(response, parsed.retryAfterSeconds) : parsed.retryAfterSeconds;
|
|
375
388
|
const detail = parsed.summary;
|
|
376
389
|
return new GaragemSdkError(
|
|
@@ -1223,7 +1236,15 @@ var LeadSubmitError = class extends Error {
|
|
|
1223
1236
|
};
|
|
1224
1237
|
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1225
1238
|
var EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1239
|
+
var NAME_RE = /^[^\d\s]{2,}.*$/;
|
|
1226
1240
|
var MESSAGE_MAX = 2e3;
|
|
1241
|
+
function isValidEmail(value) {
|
|
1242
|
+
return EMAIL_RE.test(value.trim());
|
|
1243
|
+
}
|
|
1244
|
+
function isValidName(value) {
|
|
1245
|
+
const name = value.trim();
|
|
1246
|
+
return name.length <= 200 && NAME_RE.test(name);
|
|
1247
|
+
}
|
|
1227
1248
|
var CONTACT_FIELDS = [
|
|
1228
1249
|
{ id: "name", required: true },
|
|
1229
1250
|
{ id: "email", required: false },
|
|
@@ -1323,6 +1344,27 @@ function normalizeSdkBusinessType(value) {
|
|
|
1323
1344
|
if (normalized === "sale" || normalized === "venda") return "sale";
|
|
1324
1345
|
return void 0;
|
|
1325
1346
|
}
|
|
1347
|
+
var ADDRESS_REJECTIONS = /* @__PURE__ */ new Set([
|
|
1348
|
+
"missing_postal_code",
|
|
1349
|
+
"ungeocoded_address"
|
|
1350
|
+
]);
|
|
1351
|
+
async function rejectedLeadError(response) {
|
|
1352
|
+
if (response.status !== 400 && response.status !== 409) return null;
|
|
1353
|
+
const parsed = parseSdkErrorBody(await response.text().catch(() => ""));
|
|
1354
|
+
if (response.status === 409 || parsed.reason === "duplicate_property") {
|
|
1355
|
+
return new LeadSubmitError(
|
|
1356
|
+
parsed.summary || "Garagem SDK: property already registered.",
|
|
1357
|
+
{ code: "duplicate_property", status: response.status }
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
if (parsed.reason && ADDRESS_REJECTIONS.has(parsed.reason)) {
|
|
1361
|
+
return new LeadSubmitError(`Garagem SDK: ${parsed.reason}.`, {
|
|
1362
|
+
code: "invalid_address",
|
|
1363
|
+
status: 400
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1326
1368
|
async function postSiteLead(input) {
|
|
1327
1369
|
const siteId = await resolveLeadSiteId(input);
|
|
1328
1370
|
const base = normalizeBaseUrl(input.baseUrl);
|
|
@@ -1357,8 +1399,8 @@ async function postSiteLead(input) {
|
|
|
1357
1399
|
});
|
|
1358
1400
|
}
|
|
1359
1401
|
if (response.status === 429) {
|
|
1360
|
-
const
|
|
1361
|
-
const parsed = parseSdkErrorBody(
|
|
1402
|
+
const text2 = await response.text().catch(() => "");
|
|
1403
|
+
const parsed = parseSdkErrorBody(text2);
|
|
1362
1404
|
const retryAfter = retryAfterFromResponse(
|
|
1363
1405
|
response,
|
|
1364
1406
|
parsed.retryAfterSeconds
|
|
@@ -1375,6 +1417,8 @@ async function postSiteLead(input) {
|
|
|
1375
1417
|
status: 404
|
|
1376
1418
|
});
|
|
1377
1419
|
}
|
|
1420
|
+
const rejected = await rejectedLeadError(response);
|
|
1421
|
+
if (rejected) throw rejected;
|
|
1378
1422
|
throw new LeadSubmitError(
|
|
1379
1423
|
`Garagem SDK: lead submit failed (${response.status}).`,
|
|
1380
1424
|
{ code: "http", status: response.status }
|
|
@@ -1441,6 +1485,278 @@ async function submitContactLead(input) {
|
|
|
1441
1485
|
});
|
|
1442
1486
|
}
|
|
1443
1487
|
|
|
1488
|
+
// src/seller-lead.ts
|
|
1489
|
+
function text(value) {
|
|
1490
|
+
return typeof value === "string" ? value.trim() : "";
|
|
1491
|
+
}
|
|
1492
|
+
function inRange(value, min, max) {
|
|
1493
|
+
return typeof value === "number" && Number.isFinite(value) && value >= min && value <= max;
|
|
1494
|
+
}
|
|
1495
|
+
function sellerAddressErrors(address) {
|
|
1496
|
+
const errors = {};
|
|
1497
|
+
if (!address || !text(address.fullAddress)) {
|
|
1498
|
+
errors.fullAddress = "Informe o endere\xE7o do im\xF3vel.";
|
|
1499
|
+
} else if (!inRange(address.latitude, -90, 90) || !inRange(address.longitude, -180, 180) || !text(address.street) || !text(address.city) || !text(address.neighborhood) || !/^[A-Za-z]{2}$/.test(text(address.state))) {
|
|
1500
|
+
errors.fullAddress = "Selecione o endere\xE7o em uma das sugest\xF5es.";
|
|
1501
|
+
}
|
|
1502
|
+
if (!address?.noNumber && !text(address?.number)) {
|
|
1503
|
+
errors.number = "Informe o n\xFAmero ou marque sem n\xFAmero.";
|
|
1504
|
+
}
|
|
1505
|
+
if (!address?.noBlocoTorre && !text(address?.blocoTorre)) {
|
|
1506
|
+
errors.blocoTorre = "Informe o bloco/torre ou marque que n\xE3o tem.";
|
|
1507
|
+
}
|
|
1508
|
+
if (!address?.noUnidade && !text(address?.unidade)) {
|
|
1509
|
+
errors.unidade = "Informe a unidade ou marque que n\xE3o tem.";
|
|
1510
|
+
}
|
|
1511
|
+
if (text(address?.postalCode).replace(/\D/g, "").length !== 8) {
|
|
1512
|
+
errors.postalCode = "Informe um CEP com 8 d\xEDgitos.";
|
|
1513
|
+
}
|
|
1514
|
+
return errors;
|
|
1515
|
+
}
|
|
1516
|
+
var SELLER_LEAD_PHOTO_MAX_BYTES = 10 * 1024 * 1024;
|
|
1517
|
+
var SELLER_LEAD_PHOTO_MAX_COUNT = 30;
|
|
1518
|
+
var SELLER_LEAD_PHOTO_TYPES = [
|
|
1519
|
+
"image/jpeg",
|
|
1520
|
+
"image/png",
|
|
1521
|
+
"image/webp"
|
|
1522
|
+
];
|
|
1523
|
+
async function uploadSellerLeadPhoto(input) {
|
|
1524
|
+
const { file } = input;
|
|
1525
|
+
if (!SELLER_LEAD_PHOTO_TYPES.includes(file.type)) {
|
|
1526
|
+
throw new LeadSubmitError("Garagem SDK: photo must be JPG, PNG or WEBP.", {
|
|
1527
|
+
code: "invalid_photo"
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
if (file.size <= 0) {
|
|
1531
|
+
throw new LeadSubmitError("Garagem SDK: photo is empty.", {
|
|
1532
|
+
code: "invalid_photo"
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
if (file.size > SELLER_LEAD_PHOTO_MAX_BYTES) {
|
|
1536
|
+
throw new LeadSubmitError("Garagem SDK: photo is larger than 10MB.", {
|
|
1537
|
+
code: "invalid_photo"
|
|
1538
|
+
});
|
|
1539
|
+
}
|
|
1540
|
+
const siteId = await resolveLeadSiteId(input);
|
|
1541
|
+
const url = `${normalizeBaseUrl(input.baseUrl)}/api/webhooks/sites/${encodeURIComponent(siteId)}/photos`;
|
|
1542
|
+
const form = new FormData();
|
|
1543
|
+
form.append("file", file);
|
|
1544
|
+
if (file.name) form.append("fileName", file.name);
|
|
1545
|
+
let response;
|
|
1546
|
+
try {
|
|
1547
|
+
response = await (input.fetch ?? fetch)(url, {
|
|
1548
|
+
method: "POST",
|
|
1549
|
+
body: form
|
|
1550
|
+
});
|
|
1551
|
+
} catch (error) {
|
|
1552
|
+
throw new LeadSubmitError(
|
|
1553
|
+
error instanceof Error ? error.message : "Garagem SDK: network error.",
|
|
1554
|
+
{ code: "network" }
|
|
1555
|
+
);
|
|
1556
|
+
}
|
|
1557
|
+
if (response.status === 404) {
|
|
1558
|
+
throw new LeadSubmitError("Garagem SDK: site not found.", {
|
|
1559
|
+
code: "not_found",
|
|
1560
|
+
status: 404
|
|
1561
|
+
});
|
|
1562
|
+
}
|
|
1563
|
+
const data = await response.json().catch(() => ({}));
|
|
1564
|
+
if (!response.ok || typeof data.url !== "string" || !data.url) {
|
|
1565
|
+
throw new LeadSubmitError(
|
|
1566
|
+
`Garagem SDK: photo upload failed (${response.status}).`,
|
|
1567
|
+
{
|
|
1568
|
+
code: response.status === 400 ? "invalid_photo" : "http",
|
|
1569
|
+
status: response.status
|
|
1570
|
+
}
|
|
1571
|
+
);
|
|
1572
|
+
}
|
|
1573
|
+
return data.url;
|
|
1574
|
+
}
|
|
1575
|
+
var STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG = {
|
|
1576
|
+
disabledDays: [0, 6],
|
|
1577
|
+
weekdayTimeSlots: [
|
|
1578
|
+
"09:00",
|
|
1579
|
+
"10:00",
|
|
1580
|
+
"11:00",
|
|
1581
|
+
"14:00",
|
|
1582
|
+
"15:00",
|
|
1583
|
+
"16:00",
|
|
1584
|
+
"17:00"
|
|
1585
|
+
],
|
|
1586
|
+
weekendTimeSlots: ["10:00", "11:00", "14:00", "15:00", "16:00"]
|
|
1587
|
+
};
|
|
1588
|
+
function sellerPhotoSchedule(config = STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG) {
|
|
1589
|
+
const weekdayTimeSlots = [...config.weekdayTimeSlots].sort();
|
|
1590
|
+
const weekendTimeSlots = [...config.weekendTimeSlots].sort();
|
|
1591
|
+
const hours = (slots) => slots.length > 0 ? { start: slots[0], end: slots[slots.length - 1] } : null;
|
|
1592
|
+
return {
|
|
1593
|
+
timeZone: VISIT_TIME_ZONE,
|
|
1594
|
+
saturday: !config.disabledDays.includes(6),
|
|
1595
|
+
sunday: !config.disabledDays.includes(0),
|
|
1596
|
+
weekday: hours(weekdayTimeSlots) ?? { start: "09:00", end: "09:00" },
|
|
1597
|
+
weekend: hours(weekendTimeSlots),
|
|
1598
|
+
minHoursAhead: 2,
|
|
1599
|
+
disabledDays: [...config.disabledDays],
|
|
1600
|
+
weekdayTimeSlots,
|
|
1601
|
+
weekendTimeSlots,
|
|
1602
|
+
timeSlots: Array.from(
|
|
1603
|
+
/* @__PURE__ */ new Set([...weekdayTimeSlots, ...weekendTimeSlots])
|
|
1604
|
+
).sort()
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
function contactError(message) {
|
|
1608
|
+
return new LeadSubmitError(`Garagem SDK: ${message}`, {
|
|
1609
|
+
code: "invalid_contact"
|
|
1610
|
+
});
|
|
1611
|
+
}
|
|
1612
|
+
function normalizeOwner(owner) {
|
|
1613
|
+
const name = text(owner?.name);
|
|
1614
|
+
const email = text(owner?.email);
|
|
1615
|
+
if (!isValidName(name)) throw contactError("owner name is invalid.");
|
|
1616
|
+
if (!isValidEmail(email)) throw contactError("owner email is invalid.");
|
|
1617
|
+
const phone = toE164(text(owner?.phone));
|
|
1618
|
+
if (!phone || !isValidPhone(phone) || phone.length > 40) {
|
|
1619
|
+
throw contactError("owner phone is invalid.");
|
|
1620
|
+
}
|
|
1621
|
+
return { name, email, phone };
|
|
1622
|
+
}
|
|
1623
|
+
function normalizeAddress(address) {
|
|
1624
|
+
const errors = sellerAddressErrors(address);
|
|
1625
|
+
const first = Object.values(errors)[0];
|
|
1626
|
+
if (first) {
|
|
1627
|
+
throw new LeadSubmitError(`Garagem SDK: ${first}`, {
|
|
1628
|
+
code: "invalid_address"
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
const optional = (value) => text(value) ? { value: text(value) } : null;
|
|
1632
|
+
const number = address.noNumber ? null : optional(address.number);
|
|
1633
|
+
const bloco = address.noBlocoTorre ? null : optional(address.blocoTorre);
|
|
1634
|
+
const unidade = address.noUnidade ? null : optional(address.unidade);
|
|
1635
|
+
return {
|
|
1636
|
+
fullAddress: text(address.fullAddress),
|
|
1637
|
+
street: text(address.street),
|
|
1638
|
+
...number ? { number: number.value } : {},
|
|
1639
|
+
neighborhood: text(address.neighborhood),
|
|
1640
|
+
city: text(address.city),
|
|
1641
|
+
state: text(address.state),
|
|
1642
|
+
postalCode: text(address.postalCode).replace(/\D/g, ""),
|
|
1643
|
+
country: text(address.country) || "BR",
|
|
1644
|
+
latitude: address.latitude,
|
|
1645
|
+
longitude: address.longitude,
|
|
1646
|
+
...bloco ? { blocoTorre: bloco.value } : {},
|
|
1647
|
+
...unidade ? { unidade: unidade.value } : {},
|
|
1648
|
+
noNumber: address.noNumber === true,
|
|
1649
|
+
noBlocoTorre: address.noBlocoTorre === true,
|
|
1650
|
+
noUnidade: address.noUnidade === true
|
|
1651
|
+
};
|
|
1652
|
+
}
|
|
1653
|
+
var COUNT_FIELDS = [
|
|
1654
|
+
"bedrooms",
|
|
1655
|
+
"bathrooms",
|
|
1656
|
+
"suites",
|
|
1657
|
+
"parkingSpaces"
|
|
1658
|
+
];
|
|
1659
|
+
var AMOUNT_FIELDS = [
|
|
1660
|
+
"saleValue",
|
|
1661
|
+
"rentValue",
|
|
1662
|
+
"condoFee",
|
|
1663
|
+
"totalArea"
|
|
1664
|
+
];
|
|
1665
|
+
function propertyError(message) {
|
|
1666
|
+
return new LeadSubmitError(`Garagem SDK: ${message}`, {
|
|
1667
|
+
code: "invalid_property"
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
function normalizeProperty(property) {
|
|
1671
|
+
if (!["sale", "rent", "both"].includes(property?.businessType)) {
|
|
1672
|
+
throw propertyError("businessType must be sale, rent or both.");
|
|
1673
|
+
}
|
|
1674
|
+
for (const field of COUNT_FIELDS) {
|
|
1675
|
+
const value = property[field];
|
|
1676
|
+
if (value != null && (!Number.isInteger(value) || value < 0 || value > 999)) {
|
|
1677
|
+
throw propertyError(`${field} must be a whole number.`);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
for (const field of AMOUNT_FIELDS) {
|
|
1681
|
+
const value = property[field];
|
|
1682
|
+
if (value != null && (!Number.isFinite(value) || value < 0 || value > 1e12)) {
|
|
1683
|
+
throw propertyError(`${field} must be a non-negative number.`);
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
const sale = property.businessType === "rent" ? void 0 : property.saleValue;
|
|
1687
|
+
const rent = property.businessType === "sale" ? void 0 : property.rentValue;
|
|
1688
|
+
const price = property.businessType === "rent" ? rent : sale;
|
|
1689
|
+
const counts = Object.fromEntries(
|
|
1690
|
+
COUNT_FIELDS.filter((field) => property[field] != null).map((field) => [
|
|
1691
|
+
field,
|
|
1692
|
+
property[field]
|
|
1693
|
+
])
|
|
1694
|
+
);
|
|
1695
|
+
return {
|
|
1696
|
+
businessType: property.businessType,
|
|
1697
|
+
...price != null ? { price } : {},
|
|
1698
|
+
...property.businessType === "both" && rent != null ? { rentPrice: rent } : {},
|
|
1699
|
+
...property.condoFee != null ? { condominiumFee: property.condoFee } : {},
|
|
1700
|
+
...property.totalArea != null ? { totalArea: property.totalArea } : {},
|
|
1701
|
+
...counts
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
function normalizePhotos(photos) {
|
|
1705
|
+
if (!photos?.length) return void 0;
|
|
1706
|
+
if (photos.length > SELLER_LEAD_PHOTO_MAX_COUNT) {
|
|
1707
|
+
throw new LeadSubmitError("Garagem SDK: too many photos (max 30).", {
|
|
1708
|
+
code: "invalid_photo"
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
return photos.map((url) => {
|
|
1712
|
+
const trimmed = url.trim();
|
|
1713
|
+
if (!trimmed.startsWith("https://")) {
|
|
1714
|
+
throw new LeadSubmitError("Garagem SDK: photo URL must be https.", {
|
|
1715
|
+
code: "invalid_photo"
|
|
1716
|
+
});
|
|
1717
|
+
}
|
|
1718
|
+
return trimmed;
|
|
1719
|
+
});
|
|
1720
|
+
}
|
|
1721
|
+
function normalizePhotoSession(input) {
|
|
1722
|
+
if (!input.photoSession) return void 0;
|
|
1723
|
+
const schedule = input.photoSchedule ?? sellerPhotoSchedule();
|
|
1724
|
+
const date = normalizeVisitDate(input.photoSession.date, schedule.timeZone);
|
|
1725
|
+
const time = normalizeVisitTime(input.photoSession.time);
|
|
1726
|
+
if (!date || !time || !isVisitSlotAllowed(schedule, date, time)) {
|
|
1727
|
+
throw new LeadSubmitError(
|
|
1728
|
+
"Garagem SDK: photo session slot is outside the schedule.",
|
|
1729
|
+
{ code: "invalid_slot" }
|
|
1730
|
+
);
|
|
1731
|
+
}
|
|
1732
|
+
return { date, time };
|
|
1733
|
+
}
|
|
1734
|
+
async function submitSellerLead(input) {
|
|
1735
|
+
const owner = normalizeOwner(input.owner);
|
|
1736
|
+
const address = normalizeAddress(input.address);
|
|
1737
|
+
const property = normalizeProperty(input.property);
|
|
1738
|
+
const photos = normalizePhotos(input.photos);
|
|
1739
|
+
const photoScheduling = normalizePhotoSession(input);
|
|
1740
|
+
return postSiteLead({
|
|
1741
|
+
siteId: input.siteId,
|
|
1742
|
+
baseUrl: input.baseUrl,
|
|
1743
|
+
fetch: input.fetch,
|
|
1744
|
+
publishableKey: input.publishableKey,
|
|
1745
|
+
body: {
|
|
1746
|
+
source: "site-sdk",
|
|
1747
|
+
leadType: "seller_lead",
|
|
1748
|
+
...owner,
|
|
1749
|
+
address,
|
|
1750
|
+
...property,
|
|
1751
|
+
...photos ? { photos } : {},
|
|
1752
|
+
...photoScheduling ? { photoScheduling } : {},
|
|
1753
|
+
...input.visitorId ? { visitorId: input.visitorId } : {},
|
|
1754
|
+
...input.brokerRef ? { brokerRef: input.brokerRef } : {},
|
|
1755
|
+
...input.referrer ? { referrer: input.referrer } : {}
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1444
1760
|
// src/amenity-labels.ts
|
|
1445
1761
|
var LISTING_AMENITY_TITLES = {
|
|
1446
1762
|
unit: "Comodidades",
|
|
@@ -1861,9 +2177,9 @@ var SORT_URL_TOKENS = [
|
|
|
1861
2177
|
];
|
|
1862
2178
|
|
|
1863
2179
|
// ../search-url/slugify.ts
|
|
1864
|
-
function slugifyForUrl(
|
|
1865
|
-
if (!
|
|
1866
|
-
const withDashes =
|
|
2180
|
+
function slugifyForUrl(text2) {
|
|
2181
|
+
if (!text2) return "";
|
|
2182
|
+
const withDashes = text2.replace(/([a-z])([A-Z])/g, "$1-$2");
|
|
1867
2183
|
return withDashes.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").trim();
|
|
1868
2184
|
}
|
|
1869
2185
|
|
|
@@ -2140,8 +2456,8 @@ function serializeAppliedSearchQuery(query) {
|
|
|
2140
2456
|
if (normalized.sort && isSortToken(normalized.sort)) {
|
|
2141
2457
|
params.set("ordenar", normalized.sort);
|
|
2142
2458
|
}
|
|
2143
|
-
const
|
|
2144
|
-
if (
|
|
2459
|
+
const text2 = normalized.query?.trim();
|
|
2460
|
+
if (text2) params.set("q", text2);
|
|
2145
2461
|
for (const value of (normalized.loc ?? []).slice(0, MAX_LOC_GROUPS)) {
|
|
2146
2462
|
const trimmed = value.trim();
|
|
2147
2463
|
if (trimmed) params.append("loc", trimmed);
|
|
@@ -2558,11 +2874,11 @@ function countFacetChoices(options) {
|
|
|
2558
2874
|
}
|
|
2559
2875
|
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
2560
2876
|
function pluralizePt(label) {
|
|
2561
|
-
const
|
|
2562
|
-
if (!
|
|
2563
|
-
if (/il$/i.test(
|
|
2564
|
-
if (/m$/i.test(
|
|
2565
|
-
return `${
|
|
2877
|
+
const text2 = label.trim();
|
|
2878
|
+
if (!text2 || /s$/i.test(text2)) return text2;
|
|
2879
|
+
if (/il$/i.test(text2)) return `${text2.slice(0, -1)}is`;
|
|
2880
|
+
if (/m$/i.test(text2)) return `${text2.slice(0, -1)}ns`;
|
|
2881
|
+
return `${text2}s`;
|
|
2566
2882
|
}
|
|
2567
2883
|
function headingLocationSuffix(location) {
|
|
2568
2884
|
if (!location) return "";
|
|
@@ -2855,16 +3171,16 @@ function listingBreadcrumb(listing) {
|
|
|
2855
3171
|
return crumbs;
|
|
2856
3172
|
}
|
|
2857
3173
|
function listingDescriptionPreview(description, expanded = false) {
|
|
2858
|
-
const
|
|
2859
|
-
if (!
|
|
2860
|
-
if (
|
|
2861
|
-
return { text, truncated: false, toggleLabel: null };
|
|
3174
|
+
const text2 = description?.trim() ?? "";
|
|
3175
|
+
if (!text2) return null;
|
|
3176
|
+
if (text2.length <= LISTING_DESCRIPTION_CLAMP) {
|
|
3177
|
+
return { text: text2, truncated: false, toggleLabel: null };
|
|
2862
3178
|
}
|
|
2863
3179
|
if (expanded) {
|
|
2864
|
-
return { text, truncated: true, toggleLabel: "Ler menos" };
|
|
3180
|
+
return { text: text2, truncated: true, toggleLabel: "Ler menos" };
|
|
2865
3181
|
}
|
|
2866
3182
|
return {
|
|
2867
|
-
text: `${
|
|
3183
|
+
text: `${text2.slice(0, LISTING_DESCRIPTION_CLAMP).trimEnd()}\u2026`,
|
|
2868
3184
|
truncated: true,
|
|
2869
3185
|
toggleLabel: "Ler mais"
|
|
2870
3186
|
};
|
|
@@ -2889,8 +3205,8 @@ function listingMediaOverlays(listing) {
|
|
|
2889
3205
|
return overlays;
|
|
2890
3206
|
}
|
|
2891
3207
|
function listingDetailModel(listing, options) {
|
|
2892
|
-
const
|
|
2893
|
-
const description =
|
|
3208
|
+
const text2 = listing.description?.trim() ?? "";
|
|
3209
|
+
const description = text2 || null;
|
|
2894
3210
|
const truncated = description != null && description.length > LISTING_DESCRIPTION_CLAMP;
|
|
2895
3211
|
const expanded = options?.descriptionExpanded === true;
|
|
2896
3212
|
return {
|
|
@@ -2915,8 +3231,8 @@ function visibleText(value) {
|
|
|
2915
3231
|
function visibleRows(rows) {
|
|
2916
3232
|
return rows.filter((row) => {
|
|
2917
3233
|
const label = visibleText(row.label);
|
|
2918
|
-
const
|
|
2919
|
-
return label != null &&
|
|
3234
|
+
const text2 = visibleText(row.text);
|
|
3235
|
+
return label != null && text2 != null;
|
|
2920
3236
|
});
|
|
2921
3237
|
}
|
|
2922
3238
|
function listingDetailFieldsModel(listing, dictionary) {
|
|
@@ -2940,11 +3256,13 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2940
3256
|
* this and move that release's names from `optionalReactExports` /
|
|
2941
3257
|
* `unpublishedSearchExports` / `unpublishedPhoneExports` into the
|
|
2942
3258
|
* prompt-safe lists. Do not bump here until that tarball is on npm.
|
|
2943
|
-
* Phone mask helpers shipped in 0.6.0.
|
|
3259
|
+
* Phone mask helpers shipped in 0.6.0. Map search
|
|
3260
|
+
* (`useMapSearch`, `searchListingsInBounds`) shipped in 0.9.0 — 0.7.0
|
|
3261
|
+
* does not export them. Search filter helpers
|
|
2944
3262
|
* (`visibleSearchFilters` / `toolbarFilterIds`) shipped in 0.4.12 and
|
|
2945
3263
|
* remain on this pin.
|
|
2946
3264
|
*/
|
|
2947
|
-
minNpmVersion: "0.
|
|
3265
|
+
minNpmVersion: "0.9.0",
|
|
2948
3266
|
/** Historical: older tarballs inject card CSS when those components mount. */
|
|
2949
3267
|
selfInjectSince: "0.4.2",
|
|
2950
3268
|
chromeStrategy: "app-owned",
|
|
@@ -2957,7 +3275,8 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2957
3275
|
* throws FatalRendererError.
|
|
2958
3276
|
*/
|
|
2959
3277
|
optionalReactExports: {
|
|
2960
|
-
usePublicPhotoSearch: "0.7.0"
|
|
3278
|
+
usePublicPhotoSearch: "0.7.0",
|
|
3279
|
+
useMapSearch: "0.9.0"
|
|
2961
3280
|
},
|
|
2962
3281
|
/**
|
|
2963
3282
|
* Former `/react` chrome (including card/skeleton inject). Completeness
|
|
@@ -3068,14 +3387,15 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
3068
3387
|
],
|
|
3069
3388
|
/**
|
|
3070
3389
|
* maps.fndn.ai helpers (static map, street view, boundaries, travel
|
|
3071
|
-
* time) plus friendly map search. They ship in `mapsSince
|
|
3072
|
-
* `studioMapsInstruction()`
|
|
3073
|
-
*
|
|
3074
|
-
*
|
|
3075
|
-
*
|
|
3076
|
-
*
|
|
3390
|
+
* time) plus friendly map search. They ship in npm 0.9.0 (`mapsSince`).
|
|
3391
|
+
* Listing-detail map guidance stays empty: `studioMapsInstruction()`
|
|
3392
|
+
* keeps the listing contract for a later task and Studio does not
|
|
3393
|
+
* inject it. Map search is `studioMapSearchInstruction()`, and only
|
|
3394
|
+
* the site that opted into list-and-map may include that text.
|
|
3395
|
+
* `useMapSearch` is a `/react` hook in `optionalReactExports`; the
|
|
3396
|
+
* pin sentence does not name it.
|
|
3077
3397
|
*/
|
|
3078
|
-
mapsSince: "0.
|
|
3398
|
+
mapsSince: "0.9.0",
|
|
3079
3399
|
mapsExports: [
|
|
3080
3400
|
"listingStaticMapUrl",
|
|
3081
3401
|
"listingStreetViewUrl",
|
|
@@ -3118,8 +3438,31 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
3118
3438
|
"searchListingPhotos",
|
|
3119
3439
|
"applyMatchedPhotoCover"
|
|
3120
3440
|
],
|
|
3121
|
-
photoSearchSince: "0.7.0"
|
|
3441
|
+
photoSearchSince: "0.7.0",
|
|
3442
|
+
/**
|
|
3443
|
+
* Seller lead (property registration on `/anunciar-imovel`). Prompt-safe
|
|
3444
|
+
* only once `minNpmVersion` reaches `sellerLeadSince`; below it
|
|
3445
|
+
* `studioSellerLeadSdkInstruction` prints nothing and
|
|
3446
|
+
* `studioCodegenContractViolations` flags the names.
|
|
3447
|
+
*/
|
|
3448
|
+
sellerLeadExports: [
|
|
3449
|
+
"submitSellerLead",
|
|
3450
|
+
"uploadSellerLeadPhoto",
|
|
3451
|
+
"sellerAddressErrors",
|
|
3452
|
+
"sellerPhotoSchedule",
|
|
3453
|
+
"isValidEmail",
|
|
3454
|
+
"isValidName"
|
|
3455
|
+
],
|
|
3456
|
+
sellerLeadSince: "0.10.0"
|
|
3122
3457
|
};
|
|
3458
|
+
function isSellerLeadOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3459
|
+
return compareSemver(pin, STUDIO_SDK_CONTRACT.sellerLeadSince) >= 0;
|
|
3460
|
+
}
|
|
3461
|
+
function studioSellerLeadSdkInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3462
|
+
if (!isSellerLeadOnPin(pin)) return "";
|
|
3463
|
+
const names = STUDIO_SDK_CONTRACT.sellerLeadExports.join(", ");
|
|
3464
|
+
return `Property registration (\`/anunciar-imovel\`, client component): import ${names}, isValidPhone, toE164 from \`${STUDIO_SDK_PACKAGE}\`. Address: load Maps JS only through \`<script src="https://maps.fndn.ai/sdk.js?callback=initPlaces" async defer />\` (Places is included; never a Google key, never \`maps.googleapis.com\`), then \`google.maps.places.Autocomplete\` with \`componentRestrictions: { country: "br" }\` and pt-BR. Picking a suggestion fills fullAddress, street, number, neighborhood, city, state (the 2-letter code), postalCode, latitude and longitude from the place; a typed address without a suggestion is not enough. The visitor confirms number or "Sem n\xFAmero", bloco/torre or "N\xE3o tem", unidade or "N\xE3o tem" (noNumber, noBlocoTorre, noUnidade). Block the next group while \`sellerAddressErrors(address)\` has keys and show each message on its field. Owner: name, email and phone are all required \u2014 \`isValidName\`, \`isValidEmail\`, the phone mask with \`isValidPhone(toE164(phone))\`. Photos: \`await uploadSellerLeadPhoto({ siteId, baseUrl: GARAGEM_API_BASE, file, publishableKey })\` per file (JPG/PNG/WEBP, 10MB, up to 30), keep the returned URLs. Photo session: \`const schedule = sellerPhotoSchedule(config)\` and \`slotsForDate(schedule, day)\` for the hours. Submit once with \`await submitSellerLead({ siteId, baseUrl: GARAGEM_API_BASE, publishableKey, owner: { name, email, phone }, address, property: { businessType, saleValue, rentValue, condoFee, totalArea, bedrooms, bathrooms, suites, parkingSpaces }, photos, photoSession: { date, time }, photoSchedule: schedule })\` (omit what the visitor did not fill). Errors are \`LeadSubmitError\`: \`duplicate_property\` \u2192 "Este im\xF3vel j\xE1 est\xE1 cadastrado. Nossa equipe entrar\xE1 em contato."; \`invalid_address\` \u2192 ask to pick the address again; anything else \u2192 a retry message. Disable the submit while pending and show a success state after it resolves. Never POST the leads webhook by hand.`;
|
|
3465
|
+
}
|
|
3123
3466
|
function isPhotoSearchOnPin(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
3124
3467
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.photoSearchSince) >= 0;
|
|
3125
3468
|
}
|
|
@@ -3154,8 +3497,8 @@ function studioSearchLandmarkInstruction() {
|
|
|
3154
3497
|
}
|
|
3155
3498
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
3156
3499
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
3157
|
-
function hasShowcaseLeadsPostUrl(
|
|
3158
|
-
return SHOWCASE_LEADS_POST_URL_RE.test(
|
|
3500
|
+
function hasShowcaseLeadsPostUrl(text2) {
|
|
3501
|
+
return SHOWCASE_LEADS_POST_URL_RE.test(text2);
|
|
3159
3502
|
}
|
|
3160
3503
|
function coerceNpmVersion(raw) {
|
|
3161
3504
|
if (typeof raw !== "string") return null;
|
|
@@ -3211,7 +3554,7 @@ function studioPublishableKeyInstruction() {
|
|
|
3211
3554
|
}
|
|
3212
3555
|
function studioSdkPinInstruction() {
|
|
3213
3556
|
const version = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
3214
|
-
const names =
|
|
3557
|
+
const names = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
3215
3558
|
return `In \`package.json\` set \`"@garagem-ai/site-sdk": "${version}"\` (exact). Import only these \`${STUDIO_SDK_PACKAGE}/react\` names: ${names}.`;
|
|
3216
3559
|
}
|
|
3217
3560
|
function studioLeadInstruction() {
|
|
@@ -3266,7 +3609,11 @@ function mapsExportsPublished(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
|
3266
3609
|
function studioMapsInstruction(options = {}) {
|
|
3267
3610
|
if (!mapsExportsPublished(options.pin)) return "";
|
|
3268
3611
|
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
|
|
3612
|
+
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.`;
|
|
3613
|
+
}
|
|
3614
|
+
function studioMapSearchInstruction(options = {}) {
|
|
3615
|
+
if (!mapsExportsPublished(options.pin)) return "";
|
|
3616
|
+
return `Map search on \`/imoveis\` (list and map of the same query). The list stays: keep \`usePublicSearch\` for the list, including its sort and pagination. The visitor switches on the same page. \`?modo=mapa\` is the map \u2014 read it on first paint. The list is the URL without \`modo\`; do not write \`modo=lista\` or \`modo=grade\`. Choosing the map sets \`modo=mapa\` and drops \`page\`. Choosing the list removes \`modo\`. On the map, hide sort and pagination. Do not add a map pager. The heading stays. Filters apply to both. Load Maps JS ONLY through \`<script src="https://maps.fndn.ai/sdk.js?callback=initMap" async defer />\` \u2014 never a Google key in the app, never \`NEXT_PUBLIC_GOOGLE_MAPS_API_KEY\`, never \`maps.googleapis.com\`, never \`@vis.gl/react-google-maps\`. From \`${STUDIO_SDK_PACKAGE}/react\` import useMapSearch; it fetches, debounces, and clusters. \`const map = useMapSearch({ siteId, baseUrl: GARAGEM_API_BASE, bounds, zoom, q, sort, location, filters, publishableKey })\` with the same q, sort, location, filters, and publishableKey as the list. Pass the map's current zoom on every zoom change, including after a cluster click. Changing zoom recomputes \`map.clusters\` and does not refetch; a bounds change refetches. Do not send filter_by, vector_query, or nl_query from the browser. Request page 1 and pageSize at most 100. Do not walk totalPages. Pins are the masked coordinates the API returned \u2014 plot them as returned, never geocode the street. Render \`map.clusters\` with \`google.maps.Marker\` (no map id needed), in two styles that never look alike. A cluster (\`count > 1\`) is a filled circle in the brand color with a white border and the white count as its label. A listing (\`count === 1\` with \`cluster.pin\`) is a white rounded-rectangle chip with a brand-color border, labelled with the short price in the brand color ("R$ 850 mil", "R$ 1,2 mi"; "Consulte" when the price is null or 0): \`icon: { path: "M-34,-12 h68 a6,6 0 0 1 6,6 v12 a6,6 0 0 1 -6,6 h-68 a6,6 0 0 1 -6,-6 v-12 a6,6 0 0 1 6,-6 z", fillColor: "#ffffff", fillOpacity: 1, strokeColor: brand, strokeWeight: 1.5, scale: 1, labelOrigin: new google.maps.Point(0, 0) }\`. Never draw a listing as a dot or a circle, and never without its price. Clicking a listing selects it and shows its card. Clicking a cluster opens its members: \`const members = map.pins.filter((pin) => cluster.pinIds.includes(pin.id))\`, then \`fitBounds\` a LatLngBounds of their coordinates with about 64px padding, so the listings land inside the new view and split into chips. Do not step the zoom around \`cluster.lat\`/\`cluster.lng\`: that point is approximate and the area around it can come back empty. When every member has the same coordinates, or the map is already at zoom 18, do not zoom: open a small list of those listings, each with its price and a link. Layout, top to bottom: query, heading, toolbar, then the view. On desktop the toolbar is one row: featured filters on the left, and the list/map toggle immediately beside the sort select on the right. On a narrow screen the filters stay in one horizontal scroll that does not wrap, and the toggle plus the sort sit together on the row below that scroll. On the map the sort is hidden, so the toggle keeps that place beside where the sort was. In map mode the map fills the remaining viewport height, with a minimum of about 240px. Keep the hook's 400ms viewport debounce. A drawn polygon is not required. Do not add a separate /mapa route, a regions page, or a map on the listing page. Do not call Street View or travel time inside the map search.`;
|
|
3270
3617
|
}
|
|
3271
3618
|
function marketExportsAvailableAt(pin) {
|
|
3272
3619
|
return compareSemver(pin, STUDIO_SDK_CONTRACT.marketExportsSince) >= 0;
|
|
@@ -3292,47 +3639,54 @@ function studioPhotoSearchInstruction(pin = STUDIO_SDK_CONTRACT.minNpmVersion) {
|
|
|
3292
3639
|
function studioChromeInstruction() {
|
|
3293
3640
|
return `Card, skeleton, and search chrome markup are app-owned. Never \`import "${STUDIO_SDK_CONTRACT.forbiddenImports[0]}"\` \u2014 v0 preview cannot load npm CSS. Do not mount an SDK stylesheet. Theme with site tokens and \`--radius\` in \`app/globals.css\`.`;
|
|
3294
3641
|
}
|
|
3295
|
-
function mentionsExportName(
|
|
3296
|
-
return new RegExp(`\\b${name}\\b`).test(
|
|
3642
|
+
function mentionsExportName(text2, name) {
|
|
3643
|
+
return new RegExp(`\\b${name}\\b`).test(text2);
|
|
3297
3644
|
}
|
|
3298
|
-
function studioCodegenContractViolations(
|
|
3645
|
+
function studioCodegenContractViolations(text2) {
|
|
3299
3646
|
const violations = [];
|
|
3300
3647
|
for (const [name, since] of Object.entries(
|
|
3301
3648
|
STUDIO_SDK_CONTRACT.optionalReactExports
|
|
3302
3649
|
)) {
|
|
3303
3650
|
if (compareSemver(STUDIO_SDK_CONTRACT.minNpmVersion, since) >= 0) continue;
|
|
3304
|
-
if (mentionsExportName(
|
|
3651
|
+
if (mentionsExportName(text2, name)) violations.push(name);
|
|
3305
3652
|
}
|
|
3306
3653
|
for (const name of STUDIO_SDK_CONTRACT.retiredReactExports) {
|
|
3307
|
-
if (mentionsExportName(
|
|
3654
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3308
3655
|
violations.push(name);
|
|
3309
3656
|
}
|
|
3310
3657
|
}
|
|
3311
3658
|
for (const name of STUDIO_SDK_CONTRACT.unpublishedSearchExports) {
|
|
3312
|
-
if (mentionsExportName(
|
|
3659
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3313
3660
|
violations.push(name);
|
|
3314
3661
|
}
|
|
3315
3662
|
}
|
|
3316
3663
|
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhoneExports) {
|
|
3317
|
-
if (mentionsExportName(
|
|
3664
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3318
3665
|
violations.push(name);
|
|
3319
3666
|
}
|
|
3320
3667
|
}
|
|
3321
3668
|
if (!mapsExportsPublished()) {
|
|
3322
3669
|
for (const name of STUDIO_SDK_CONTRACT.mapsExports) {
|
|
3323
|
-
if (mentionsExportName(
|
|
3670
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3324
3671
|
violations.push(name);
|
|
3325
3672
|
}
|
|
3326
3673
|
}
|
|
3327
3674
|
}
|
|
3328
3675
|
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhotoExports) {
|
|
3329
|
-
if (mentionsExportName(
|
|
3676
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3330
3677
|
violations.push(name);
|
|
3331
3678
|
}
|
|
3332
3679
|
}
|
|
3333
3680
|
if (!isPhotoSearchOnPin()) {
|
|
3334
3681
|
for (const name of STUDIO_SDK_CONTRACT.photoSearchExports) {
|
|
3335
|
-
if (mentionsExportName(
|
|
3682
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3683
|
+
violations.push(name);
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
}
|
|
3687
|
+
if (!isSellerLeadOnPin()) {
|
|
3688
|
+
for (const name of STUDIO_SDK_CONTRACT.sellerLeadExports) {
|
|
3689
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3336
3690
|
violations.push(name);
|
|
3337
3691
|
}
|
|
3338
3692
|
}
|
|
@@ -3340,21 +3694,21 @@ function studioCodegenContractViolations(text) {
|
|
|
3340
3694
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
3341
3695
|
if (!marketExportsAvailableAt(pin)) {
|
|
3342
3696
|
for (const name of STUDIO_SDK_CONTRACT.marketExports) {
|
|
3343
|
-
if (mentionsExportName(
|
|
3697
|
+
if (mentionsExportName(text2, name) && !violations.includes(name)) {
|
|
3344
3698
|
violations.push(name);
|
|
3345
3699
|
}
|
|
3346
3700
|
}
|
|
3347
3701
|
}
|
|
3348
3702
|
const available = reactExportsAvailableAt(pin);
|
|
3349
|
-
for (const name of parseReactSdkNamedImports(
|
|
3703
|
+
for (const name of parseReactSdkNamedImports(text2)) {
|
|
3350
3704
|
if (!available.has(name) && !violations.includes(name)) {
|
|
3351
3705
|
violations.push(name);
|
|
3352
3706
|
}
|
|
3353
3707
|
}
|
|
3354
|
-
if (hasShowcaseLeadsPostUrl(
|
|
3708
|
+
if (hasShowcaseLeadsPostUrl(text2)) {
|
|
3355
3709
|
violations.push("showcase-leads-url");
|
|
3356
3710
|
}
|
|
3357
|
-
if (/\btype\s*=\s*["']date["']/.test(
|
|
3711
|
+
if (/\btype\s*=\s*["']date["']/.test(text2)) {
|
|
3358
3712
|
violations.push("native-date-input");
|
|
3359
3713
|
}
|
|
3360
3714
|
return violations;
|
|
@@ -3547,14 +3901,14 @@ function listingCoordinates(listing) {
|
|
|
3547
3901
|
}
|
|
3548
3902
|
function coordinateDecimals(value) {
|
|
3549
3903
|
if (!Number.isFinite(value)) return 0;
|
|
3550
|
-
const
|
|
3551
|
-
if (
|
|
3904
|
+
const text2 = Math.abs(value).toString();
|
|
3905
|
+
if (text2.includes("e")) {
|
|
3552
3906
|
const fixed = Math.abs(value).toFixed(12).replace(/0+$/, "");
|
|
3553
3907
|
const dot2 = fixed.indexOf(".");
|
|
3554
3908
|
return dot2 === -1 ? 0 : fixed.length - dot2 - 1;
|
|
3555
3909
|
}
|
|
3556
|
-
const dot =
|
|
3557
|
-
return dot === -1 ? 0 :
|
|
3910
|
+
const dot = text2.indexOf(".");
|
|
3911
|
+
return dot === -1 ? 0 : text2.length - dot - 1;
|
|
3558
3912
|
}
|
|
3559
3913
|
function roundTo(value, decimals) {
|
|
3560
3914
|
const factor = 10 ** decimals;
|
|
@@ -4095,15 +4449,15 @@ function usablePin(pin) {
|
|
|
4095
4449
|
return finitePair(pin.lat, pin.lng) !== null && !(pin.lat === 0 && pin.lng === 0);
|
|
4096
4450
|
}
|
|
4097
4451
|
function groupPrecision(group) {
|
|
4098
|
-
let
|
|
4452
|
+
let max = 0;
|
|
4099
4453
|
for (const pin of group) {
|
|
4100
|
-
|
|
4101
|
-
|
|
4454
|
+
max = Math.max(
|
|
4455
|
+
max,
|
|
4102
4456
|
coordinateDecimals(pin.lat),
|
|
4103
4457
|
coordinateDecimals(pin.lng)
|
|
4104
4458
|
);
|
|
4105
4459
|
}
|
|
4106
|
-
return
|
|
4460
|
+
return max;
|
|
4107
4461
|
}
|
|
4108
4462
|
function multiCluster(key, group) {
|
|
4109
4463
|
const lat = group.reduce((sum, pin) => sum + pin.lat, 0) / group.length;
|
|
@@ -4418,15 +4772,15 @@ function listingVisualHighlights(listing, options) {
|
|
|
4418
4772
|
if (!isPhoto(item) || !Array.isArray(item.features)) continue;
|
|
4419
4773
|
for (const feature of item.features) {
|
|
4420
4774
|
if (typeof feature !== "string") continue;
|
|
4421
|
-
const
|
|
4422
|
-
if (!
|
|
4423
|
-
const key = normalizeRoomLabel(
|
|
4775
|
+
const text2 = feature.trim();
|
|
4776
|
+
if (!text2) continue;
|
|
4777
|
+
const key = normalizeRoomLabel(text2);
|
|
4424
4778
|
if (!key) continue;
|
|
4425
4779
|
const entry = counts.get(key);
|
|
4426
4780
|
if (entry) {
|
|
4427
4781
|
entry.count += 1;
|
|
4428
4782
|
} else {
|
|
4429
|
-
counts.set(key, { text, count: 1, seen: seen++ });
|
|
4783
|
+
counts.set(key, { text: text2, count: 1, seen: seen++ });
|
|
4430
4784
|
}
|
|
4431
4785
|
}
|
|
4432
4786
|
}
|
|
@@ -4691,6 +5045,10 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
4691
5045
|
PHOTO_SEARCH_MIN_QUERY_LENGTH,
|
|
4692
5046
|
SEARCH_EMPTY_COPY,
|
|
4693
5047
|
SEARCH_SORT_RELEVANCE,
|
|
5048
|
+
SELLER_LEAD_PHOTO_MAX_BYTES,
|
|
5049
|
+
SELLER_LEAD_PHOTO_MAX_COUNT,
|
|
5050
|
+
SELLER_LEAD_PHOTO_TYPES,
|
|
5051
|
+
STUDIO_DEFAULT_PHOTO_SCHEDULE_CONFIG,
|
|
4694
5052
|
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
4695
5053
|
STUDIO_SDK_CONTRACT,
|
|
4696
5054
|
STUDIO_SDK_PACKAGE,
|
|
@@ -4752,7 +5110,10 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
4752
5110
|
isMapBounds,
|
|
4753
5111
|
isMapPolygon,
|
|
4754
5112
|
isPhotoSearchOnPin,
|
|
5113
|
+
isSellerLeadOnPin,
|
|
4755
5114
|
isStudioPreviewHost,
|
|
5115
|
+
isValidEmail,
|
|
5116
|
+
isValidName,
|
|
4756
5117
|
isValidPhone,
|
|
4757
5118
|
isVisitSlotAllowed,
|
|
4758
5119
|
labelAmenities,
|
|
@@ -4822,6 +5183,8 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
4822
5183
|
searchListingsInPolygon,
|
|
4823
5184
|
searchResultsHeading,
|
|
4824
5185
|
searchSortOptions,
|
|
5186
|
+
sellerAddressErrors,
|
|
5187
|
+
sellerPhotoSchedule,
|
|
4825
5188
|
serializeAppliedSearchQuery,
|
|
4826
5189
|
slotsForDate,
|
|
4827
5190
|
studioAmenityInstruction,
|
|
@@ -4832,6 +5195,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
4832
5195
|
studioLeadInstruction,
|
|
4833
5196
|
studioListingCardInstruction,
|
|
4834
5197
|
studioListingDetailInstruction,
|
|
5198
|
+
studioMapSearchInstruction,
|
|
4835
5199
|
studioMapsInstruction,
|
|
4836
5200
|
studioMarketInstruction,
|
|
4837
5201
|
studioPhotoInstruction,
|
|
@@ -4841,8 +5205,10 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
4841
5205
|
studioSdkPinInstruction,
|
|
4842
5206
|
studioSearchInstruction,
|
|
4843
5207
|
studioSearchLandmarkInstruction,
|
|
5208
|
+
studioSellerLeadSdkInstruction,
|
|
4844
5209
|
studioSiteWidthCss,
|
|
4845
5210
|
submitContactLead,
|
|
5211
|
+
submitSellerLead,
|
|
4846
5212
|
submitVisitLead,
|
|
4847
5213
|
toE164,
|
|
4848
5214
|
toListingCardModel,
|
|
@@ -4852,6 +5218,7 @@ function applyMatchedPhotoCover(cards, photoResults, options = {}) {
|
|
|
4852
5218
|
travelTimesFromListing,
|
|
4853
5219
|
truncateNationalPhoneDigits,
|
|
4854
5220
|
unavailableReactImports,
|
|
5221
|
+
uploadSellerLeadPhoto,
|
|
4855
5222
|
visibleSearchFilters
|
|
4856
5223
|
});
|
|
4857
5224
|
//# sourceMappingURL=index.js.map
|