@garagem-ai/site-sdk 0.5.3 → 0.6.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 +98 -4
- package/dist/index.d.ts +98 -4
- package/dist/index.js +431 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +421 -12
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +18 -2
- package/dist/react.d.ts +18 -2
- package/dist/react.js +134 -31
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +135 -32
- package/dist/react.mjs.map +1 -1
- package/dist/{search-engine-CkbO77G8.d.mts → search-engine-CtnLzmwW.d.mts} +2 -0
- package/dist/{search-engine-CkbO77G8.d.ts → search-engine-CtnLzmwW.d.ts} +2 -0
- package/package.json +8 -5
- package/src/index.ts +19 -0
- package/src/leads.ts +45 -6
- package/src/listing-card-model.ts +4 -1
- package/src/listing-detail.ts +6 -1
- package/src/phone-countries.ts +97 -0
- package/src/phone.ts +431 -0
- package/src/react/index.ts +1 -0
- package/src/react/public-search-snapshot.ts +165 -0
- package/src/react/types.ts +17 -0
- package/src/react/use-public-search.ts +91 -32
- package/src/studio-contract.ts +31 -4
- package/src/types.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -21,11 +21,14 @@ 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_PHONE_COUNTRY_CODE: () => DEFAULT_PHONE_COUNTRY_CODE,
|
|
24
25
|
FORBIDDEN_SEARCH_QUERY_KEYS: () => FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
25
26
|
GaragemSdkError: () => GaragemSdkError,
|
|
26
27
|
LISTING_AMENITY_TITLES: () => LISTING_AMENITY_TITLES,
|
|
27
28
|
LISTING_DESCRIPTION_CLAMP: () => LISTING_DESCRIPTION_CLAMP,
|
|
28
29
|
LeadSubmitError: () => LeadSubmitError,
|
|
30
|
+
MAX_NATIONAL_PHONE_DIGITS: () => MAX_NATIONAL_PHONE_DIGITS,
|
|
31
|
+
PHONE_COUNTRIES: () => PHONE_COUNTRIES,
|
|
29
32
|
SEARCH_EMPTY_COPY: () => SEARCH_EMPTY_COPY,
|
|
30
33
|
SEARCH_SORT_RELEVANCE: () => SEARCH_SORT_RELEVANCE,
|
|
31
34
|
STUDIO_DEFAULT_VISIT_SCHEDULE: () => STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
@@ -39,18 +42,22 @@ __export(src_exports, {
|
|
|
39
42
|
canonicalizeSearchHref: () => canonicalizeSearchHref,
|
|
40
43
|
clearStagedPathFilters: () => clearStagedPathFilters,
|
|
41
44
|
coerceNpmVersion: () => coerceNpmVersion,
|
|
45
|
+
collapseDuplicatedBrazilianMobileNine: () => collapseDuplicatedBrazilianMobileNine,
|
|
42
46
|
compareSemver: () => compareSemver,
|
|
43
47
|
composeSearchPublicHref: () => composeSearchPublicHref2,
|
|
44
48
|
composeSearchPublicPath: () => composeSearchPublicPath2,
|
|
45
49
|
countFacetChoices: () => countFacetChoices,
|
|
46
50
|
countOptionLabel: () => countOptionLabel,
|
|
47
51
|
createGaragemClient: () => createGaragemClient,
|
|
52
|
+
defaultPhoneCountry: () => defaultPhoneCountry,
|
|
48
53
|
displayPathLocation: () => displayPathLocation,
|
|
49
54
|
expandVisitSchedule: () => expandVisitSchedule,
|
|
50
55
|
expandVisitTimeSlots: () => expandVisitTimeSlots,
|
|
56
|
+
findPhoneCountry: () => findPhoneCountry,
|
|
51
57
|
formatAreaM2: () => formatAreaM2,
|
|
52
58
|
formatGroupedInteger: () => formatGroupedInteger,
|
|
53
59
|
formatListingPrice: () => formatListingPrice,
|
|
60
|
+
formatPhoneNational: () => formatPhoneNational,
|
|
54
61
|
getCmsCollection: () => getCmsCollection,
|
|
55
62
|
getCmsCollections: () => getCmsCollections,
|
|
56
63
|
getCmsEntries: () => getCmsEntries,
|
|
@@ -67,6 +74,7 @@ __export(src_exports, {
|
|
|
67
74
|
hrefWithExplicitPage: () => hrefWithExplicitPage,
|
|
68
75
|
isListingDetailPath: () => isListingDetailPath,
|
|
69
76
|
isStudioPreviewHost: () => isStudioPreviewHost,
|
|
77
|
+
isValidPhone: () => isValidPhone,
|
|
70
78
|
isVisitSlotAllowed: () => isVisitSlotAllowed,
|
|
71
79
|
labelAmenities: () => labelAmenities,
|
|
72
80
|
listingAmenityGroups: () => listingAmenityGroups,
|
|
@@ -84,22 +92,26 @@ __export(src_exports, {
|
|
|
84
92
|
listingPublicPath: () => listingPublicPath,
|
|
85
93
|
listingValues: () => listingValues,
|
|
86
94
|
mergeAppliedSearchQueryIntoSearch: () => mergeAppliedSearchQueryIntoSearch2,
|
|
95
|
+
nationalPhoneDigits: () => nationalPhoneDigits,
|
|
87
96
|
normalizeVisitDate: () => normalizeVisitDate,
|
|
88
97
|
normalizeVisitTime: () => normalizeVisitTime,
|
|
89
98
|
paginationPages: () => paginationPages,
|
|
90
99
|
parseAppliedSearchQuery: () => parseAppliedSearchQuery2,
|
|
91
100
|
parseGroupedInteger: () => parseGroupedInteger,
|
|
101
|
+
parsePhoneInput: () => parsePhoneInput,
|
|
92
102
|
parseReactSdkNamedImports: () => parseReactSdkNamedImports,
|
|
93
103
|
parseSearchPublicPath: () => parseSearchPublicPath2,
|
|
94
104
|
pathFilterHasOption: () => pathFilterHasOption,
|
|
95
105
|
pathFilterValue: () => pathFilterValue,
|
|
96
106
|
pathFiltersToQueryFilters: () => pathFiltersToQueryFilters,
|
|
97
107
|
pathLocationToFilterInput: () => pathLocationToFilterInput,
|
|
108
|
+
phoneCountrySearchValue: () => phoneCountrySearchValue,
|
|
98
109
|
publicSearchHref: () => publicSearchHref,
|
|
99
110
|
queryListings: () => queryListings,
|
|
100
111
|
rangeDraftFromPath: () => rangeDraftFromPath,
|
|
101
112
|
readPublicSearch: () => readPublicSearch,
|
|
102
113
|
reduceAppliedSearchQuery: () => reduceAppliedSearchQuery2,
|
|
114
|
+
remaskPhoneForCountry: () => remaskPhoneForCountry,
|
|
103
115
|
resolvePublicSiteId: () => resolvePublicSiteId,
|
|
104
116
|
searchChromeModel: () => searchChromeModel,
|
|
105
117
|
searchHrefUsesLegacyFilterQuery: () => searchHrefUsesLegacyFilterQuery,
|
|
@@ -122,8 +134,10 @@ __export(src_exports, {
|
|
|
122
134
|
studioSiteWidthCss: () => studioSiteWidthCss,
|
|
123
135
|
submitContactLead: () => submitContactLead,
|
|
124
136
|
submitVisitLead: () => submitVisitLead,
|
|
137
|
+
toE164: () => toE164,
|
|
125
138
|
toListingCardModel: () => toListingCardModel,
|
|
126
139
|
toolbarFilterIds: () => toolbarFilterIds,
|
|
140
|
+
truncateNationalPhoneDigits: () => truncateNationalPhoneDigits,
|
|
127
141
|
unavailableReactImports: () => unavailableReactImports,
|
|
128
142
|
visibleSearchFilters: () => visibleSearchFilters
|
|
129
143
|
});
|
|
@@ -610,6 +624,349 @@ function isVisitSlotAllowed(schedule, visitDate, visitTime, now = /* @__PURE__ *
|
|
|
610
624
|
return slotsForDate(schedule, visitDate, now).includes(time);
|
|
611
625
|
}
|
|
612
626
|
|
|
627
|
+
// src/phone.ts
|
|
628
|
+
var import_libphonenumber_js = require("libphonenumber-js");
|
|
629
|
+
|
|
630
|
+
// src/phone-countries.ts
|
|
631
|
+
var DEFAULT_PHONE_COUNTRY_CODE = "BR";
|
|
632
|
+
var PHONE_COUNTRIES = [
|
|
633
|
+
{ code: "BR", name: "Brasil", dialCode: "55", flag: "\u{1F1E7}\u{1F1F7}" },
|
|
634
|
+
{ code: "US", name: "Estados Unidos", dialCode: "1", flag: "\u{1F1FA}\u{1F1F8}" },
|
|
635
|
+
{ code: "CA", name: "Canad\xE1", dialCode: "1", flag: "\u{1F1E8}\u{1F1E6}" },
|
|
636
|
+
{ code: "MX", name: "M\xE9xico", dialCode: "52", flag: "\u{1F1F2}\u{1F1FD}" },
|
|
637
|
+
{ code: "GT", name: "Guatemala", dialCode: "502", flag: "\u{1F1EC}\u{1F1F9}" },
|
|
638
|
+
{ code: "BZ", name: "Belize", dialCode: "501", flag: "\u{1F1E7}\u{1F1FF}" },
|
|
639
|
+
{ code: "SV", name: "El Salvador", dialCode: "503", flag: "\u{1F1F8}\u{1F1FB}" },
|
|
640
|
+
{ code: "HN", name: "Honduras", dialCode: "504", flag: "\u{1F1ED}\u{1F1F3}" },
|
|
641
|
+
{ code: "NI", name: "Nicar\xE1gua", dialCode: "505", flag: "\u{1F1F3}\u{1F1EE}" },
|
|
642
|
+
{ code: "CR", name: "Costa Rica", dialCode: "506", flag: "\u{1F1E8}\u{1F1F7}" },
|
|
643
|
+
{ code: "PA", name: "Panam\xE1", dialCode: "507", flag: "\u{1F1F5}\u{1F1E6}" },
|
|
644
|
+
{ code: "CU", name: "Cuba", dialCode: "53", flag: "\u{1F1E8}\u{1F1FA}" },
|
|
645
|
+
{ code: "DO", name: "Rep\xFAblica Dominicana", dialCode: "1", flag: "\u{1F1E9}\u{1F1F4}" },
|
|
646
|
+
{ code: "HT", name: "Haiti", dialCode: "509", flag: "\u{1F1ED}\u{1F1F9}" },
|
|
647
|
+
{ code: "AR", name: "Argentina", dialCode: "54", flag: "\u{1F1E6}\u{1F1F7}" },
|
|
648
|
+
{ code: "CL", name: "Chile", dialCode: "56", flag: "\u{1F1E8}\u{1F1F1}" },
|
|
649
|
+
{ code: "CO", name: "Col\xF4mbia", dialCode: "57", flag: "\u{1F1E8}\u{1F1F4}" },
|
|
650
|
+
{ code: "PE", name: "Peru", dialCode: "51", flag: "\u{1F1F5}\u{1F1EA}" },
|
|
651
|
+
{ code: "UY", name: "Uruguai", dialCode: "598", flag: "\u{1F1FA}\u{1F1FE}" },
|
|
652
|
+
{ code: "PY", name: "Paraguai", dialCode: "595", flag: "\u{1F1F5}\u{1F1FE}" },
|
|
653
|
+
{ code: "BO", name: "Bol\xEDvia", dialCode: "591", flag: "\u{1F1E7}\u{1F1F4}" },
|
|
654
|
+
{ code: "EC", name: "Equador", dialCode: "593", flag: "\u{1F1EA}\u{1F1E8}" },
|
|
655
|
+
{ code: "VE", name: "Venezuela", dialCode: "58", flag: "\u{1F1FB}\u{1F1EA}" },
|
|
656
|
+
{ code: "GY", name: "Guiana", dialCode: "592", flag: "\u{1F1EC}\u{1F1FE}" },
|
|
657
|
+
{ code: "SR", name: "Suriname", dialCode: "597", flag: "\u{1F1F8}\u{1F1F7}" },
|
|
658
|
+
{ code: "PT", name: "Portugal", dialCode: "351", flag: "\u{1F1F5}\u{1F1F9}" },
|
|
659
|
+
{ code: "ES", name: "Espanha", dialCode: "34", flag: "\u{1F1EA}\u{1F1F8}" },
|
|
660
|
+
{ code: "FR", name: "Fran\xE7a", dialCode: "33", flag: "\u{1F1EB}\u{1F1F7}" },
|
|
661
|
+
{ code: "UK", name: "Reino Unido", dialCode: "44", flag: "\u{1F1EC}\u{1F1E7}" },
|
|
662
|
+
{ code: "DE", name: "Alemanha", dialCode: "49", flag: "\u{1F1E9}\u{1F1EA}" },
|
|
663
|
+
{ code: "IT", name: "It\xE1lia", dialCode: "39", flag: "\u{1F1EE}\u{1F1F9}" },
|
|
664
|
+
{ code: "NL", name: "Holanda", dialCode: "31", flag: "\u{1F1F3}\u{1F1F1}" },
|
|
665
|
+
{ code: "BE", name: "B\xE9lgica", dialCode: "32", flag: "\u{1F1E7}\u{1F1EA}" },
|
|
666
|
+
{ code: "CH", name: "Su\xED\xE7a", dialCode: "41", flag: "\u{1F1E8}\u{1F1ED}" },
|
|
667
|
+
{ code: "AT", name: "\xC1ustria", dialCode: "43", flag: "\u{1F1E6}\u{1F1F9}" },
|
|
668
|
+
{ code: "SE", name: "Su\xE9cia", dialCode: "46", flag: "\u{1F1F8}\u{1F1EA}" },
|
|
669
|
+
{ code: "NO", name: "Noruega", dialCode: "47", flag: "\u{1F1F3}\u{1F1F4}" },
|
|
670
|
+
{ code: "DK", name: "Dinamarca", dialCode: "45", flag: "\u{1F1E9}\u{1F1F0}" },
|
|
671
|
+
{ code: "FI", name: "Finl\xE2ndia", dialCode: "358", flag: "\u{1F1EB}\u{1F1EE}" },
|
|
672
|
+
{ code: "IE", name: "Irlanda", dialCode: "353", flag: "\u{1F1EE}\u{1F1EA}" },
|
|
673
|
+
{ code: "AU", name: "Austr\xE1lia", dialCode: "61", flag: "\u{1F1E6}\u{1F1FA}" },
|
|
674
|
+
{ code: "NZ", name: "Nova Zel\xE2ndia", dialCode: "64", flag: "\u{1F1F3}\u{1F1FF}" },
|
|
675
|
+
{ code: "JP", name: "Jap\xE3o", dialCode: "81", flag: "\u{1F1EF}\u{1F1F5}" },
|
|
676
|
+
{ code: "KR", name: "Coreia do Sul", dialCode: "82", flag: "\u{1F1F0}\u{1F1F7}" },
|
|
677
|
+
{ code: "CN", name: "China", dialCode: "86", flag: "\u{1F1E8}\u{1F1F3}" },
|
|
678
|
+
{ code: "IN", name: "\xCDndia", dialCode: "91", flag: "\u{1F1EE}\u{1F1F3}" },
|
|
679
|
+
{ code: "RU", name: "R\xFAssia", dialCode: "7", flag: "\u{1F1F7}\u{1F1FA}" },
|
|
680
|
+
{ code: "UA", name: "Ucr\xE2nia", dialCode: "380", flag: "\u{1F1FA}\u{1F1E6}" },
|
|
681
|
+
{ code: "AE", name: "Emirados \xC1rabes", dialCode: "971", flag: "\u{1F1E6}\u{1F1EA}" },
|
|
682
|
+
{ code: "SA", name: "Ar\xE1bia Saudita", dialCode: "966", flag: "\u{1F1F8}\u{1F1E6}" },
|
|
683
|
+
{ code: "QA", name: "Catar", dialCode: "974", flag: "\u{1F1F6}\u{1F1E6}" },
|
|
684
|
+
{ code: "KW", name: "Kuwait", dialCode: "965", flag: "\u{1F1F0}\u{1F1FC}" },
|
|
685
|
+
{ code: "BH", name: "Bahrein", dialCode: "973", flag: "\u{1F1E7}\u{1F1ED}" },
|
|
686
|
+
{ code: "OM", name: "Om\xE3", dialCode: "968", flag: "\u{1F1F4}\u{1F1F2}" },
|
|
687
|
+
{ code: "JO", name: "Jord\xE2nia", dialCode: "962", flag: "\u{1F1EF}\u{1F1F4}" },
|
|
688
|
+
{ code: "LB", name: "L\xEDbano", dialCode: "961", flag: "\u{1F1F1}\u{1F1E7}" },
|
|
689
|
+
{ code: "IL", name: "Israel", dialCode: "972", flag: "\u{1F1EE}\u{1F1F1}" },
|
|
690
|
+
{ code: "TR", name: "Turquia", dialCode: "90", flag: "\u{1F1F9}\u{1F1F7}" },
|
|
691
|
+
{ code: "EG", name: "Egito", dialCode: "20", flag: "\u{1F1EA}\u{1F1EC}" },
|
|
692
|
+
{ code: "ZA", name: "\xC1frica do Sul", dialCode: "27", flag: "\u{1F1FF}\u{1F1E6}" },
|
|
693
|
+
{ code: "AO", name: "Angola", dialCode: "244", flag: "\u{1F1E6}\u{1F1F4}" },
|
|
694
|
+
{ code: "MZ", name: "Mo\xE7ambique", dialCode: "258", flag: "\u{1F1F2}\u{1F1FF}" },
|
|
695
|
+
{ code: "CV", name: "Cabo Verde", dialCode: "238", flag: "\u{1F1E8}\u{1F1FB}" }
|
|
696
|
+
];
|
|
697
|
+
function phoneCountrySearchValue(country) {
|
|
698
|
+
return `${country.name} ${country.code} ${country.dialCode} +${country.dialCode}`;
|
|
699
|
+
}
|
|
700
|
+
function findPhoneCountry(code) {
|
|
701
|
+
if (!code) return void 0;
|
|
702
|
+
const normalized = code.trim().toUpperCase();
|
|
703
|
+
return PHONE_COUNTRIES.find((country) => country.code === normalized);
|
|
704
|
+
}
|
|
705
|
+
function defaultPhoneCountry() {
|
|
706
|
+
return findPhoneCountry(DEFAULT_PHONE_COUNTRY_CODE) ?? PHONE_COUNTRIES[0];
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
// src/phone.ts
|
|
710
|
+
var MAX_NATIONAL_PHONE_DIGITS = 15;
|
|
711
|
+
var VALID_BR_DDDS = /* @__PURE__ */ new Set([
|
|
712
|
+
"11",
|
|
713
|
+
"12",
|
|
714
|
+
"13",
|
|
715
|
+
"14",
|
|
716
|
+
"15",
|
|
717
|
+
"16",
|
|
718
|
+
"17",
|
|
719
|
+
"18",
|
|
720
|
+
"19",
|
|
721
|
+
"21",
|
|
722
|
+
"22",
|
|
723
|
+
"24",
|
|
724
|
+
"27",
|
|
725
|
+
"28",
|
|
726
|
+
"31",
|
|
727
|
+
"32",
|
|
728
|
+
"33",
|
|
729
|
+
"34",
|
|
730
|
+
"35",
|
|
731
|
+
"37",
|
|
732
|
+
"38",
|
|
733
|
+
"41",
|
|
734
|
+
"42",
|
|
735
|
+
"43",
|
|
736
|
+
"44",
|
|
737
|
+
"45",
|
|
738
|
+
"46",
|
|
739
|
+
"47",
|
|
740
|
+
"48",
|
|
741
|
+
"49",
|
|
742
|
+
"51",
|
|
743
|
+
"53",
|
|
744
|
+
"54",
|
|
745
|
+
"55",
|
|
746
|
+
"61",
|
|
747
|
+
"62",
|
|
748
|
+
"63",
|
|
749
|
+
"64",
|
|
750
|
+
"65",
|
|
751
|
+
"66",
|
|
752
|
+
"67",
|
|
753
|
+
"68",
|
|
754
|
+
"69",
|
|
755
|
+
"71",
|
|
756
|
+
"73",
|
|
757
|
+
"74",
|
|
758
|
+
"75",
|
|
759
|
+
"77",
|
|
760
|
+
"79",
|
|
761
|
+
"81",
|
|
762
|
+
"82",
|
|
763
|
+
"83",
|
|
764
|
+
"84",
|
|
765
|
+
"85",
|
|
766
|
+
"86",
|
|
767
|
+
"87",
|
|
768
|
+
"88",
|
|
769
|
+
"89",
|
|
770
|
+
"91",
|
|
771
|
+
"92",
|
|
772
|
+
"93",
|
|
773
|
+
"94",
|
|
774
|
+
"95",
|
|
775
|
+
"96",
|
|
776
|
+
"97",
|
|
777
|
+
"98",
|
|
778
|
+
"99"
|
|
779
|
+
]);
|
|
780
|
+
var PHONE_INPUT_COUNTRY_CODES = new Set(
|
|
781
|
+
PHONE_COUNTRIES.map((country) => country.code)
|
|
782
|
+
);
|
|
783
|
+
var SORTED_PHONE_INPUT_DIAL_CODES = [
|
|
784
|
+
...new Set(PHONE_COUNTRIES.map((country) => country.dialCode))
|
|
785
|
+
].sort((a, b) => b.length - a.length);
|
|
786
|
+
function toLibCountryCode(code) {
|
|
787
|
+
if (code === "UK") return "GB";
|
|
788
|
+
return code;
|
|
789
|
+
}
|
|
790
|
+
function fromLibCountryCode(code) {
|
|
791
|
+
if (code === "GB") return "UK";
|
|
792
|
+
return code;
|
|
793
|
+
}
|
|
794
|
+
function nationalPhoneDigits(value) {
|
|
795
|
+
return String(value ?? "").replace(/\D/g, "");
|
|
796
|
+
}
|
|
797
|
+
function truncateNationalPhoneDigits(digits, max = MAX_NATIONAL_PHONE_DIGITS) {
|
|
798
|
+
return digits.slice(0, max);
|
|
799
|
+
}
|
|
800
|
+
function collapseDuplicatedBrazilianMobileNine(digits) {
|
|
801
|
+
if (digits.length === 14 && digits.startsWith("55")) {
|
|
802
|
+
const national = collapseDuplicatedBrazilianMobileNine(digits.slice(2));
|
|
803
|
+
return national === digits.slice(2) ? digits : `55${national}`;
|
|
804
|
+
}
|
|
805
|
+
if (digits.length !== 12) return digits;
|
|
806
|
+
const ddd = digits.slice(0, 2);
|
|
807
|
+
if (!VALID_BR_DDDS.has(ddd)) return digits;
|
|
808
|
+
if (digits.charAt(2) !== "9") return digits;
|
|
809
|
+
const rest = digits.slice(3);
|
|
810
|
+
if (rest.length !== 9 || rest.charAt(0) !== "9") return digits;
|
|
811
|
+
if (ddd === "55") {
|
|
812
|
+
const subscriberFirst = digits.charAt(4);
|
|
813
|
+
if (subscriberFirst >= "0" && subscriberFirst <= "5") {
|
|
814
|
+
return digits;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return `${ddd}${rest}`;
|
|
818
|
+
}
|
|
819
|
+
var BR_DIAL_CODE = "55";
|
|
820
|
+
function stripAccidentalDialCodePrefix(numbers, country) {
|
|
821
|
+
const dial = country.dialCode;
|
|
822
|
+
if (!numbers.startsWith(dial) || numbers.length <= dial.length) {
|
|
823
|
+
return numbers;
|
|
824
|
+
}
|
|
825
|
+
const withoutDial = numbers.slice(dial.length);
|
|
826
|
+
if (!withoutDial) return numbers;
|
|
827
|
+
try {
|
|
828
|
+
const parsed = (0, import_libphonenumber_js.parsePhoneNumber)(numbers, toLibCountryCode(country.code));
|
|
829
|
+
if (parsed.nationalNumber === numbers) {
|
|
830
|
+
return numbers;
|
|
831
|
+
}
|
|
832
|
+
if (parsed.countryCallingCode === dial && parsed.nationalNumber === withoutDial) {
|
|
833
|
+
return withoutDial;
|
|
834
|
+
}
|
|
835
|
+
} catch {
|
|
836
|
+
}
|
|
837
|
+
return numbers;
|
|
838
|
+
}
|
|
839
|
+
function prepareNationalDigits(value, country) {
|
|
840
|
+
const raw = nationalPhoneDigits(value);
|
|
841
|
+
const stripped = stripAccidentalDialCodePrefix(raw, country);
|
|
842
|
+
const digits = country.dialCode === BR_DIAL_CODE ? collapseDuplicatedBrazilianMobileNine(stripped) : stripped;
|
|
843
|
+
return truncateNationalPhoneDigits(digits);
|
|
844
|
+
}
|
|
845
|
+
function prepareInternationalDigits(value) {
|
|
846
|
+
const digits = nationalPhoneDigits(value);
|
|
847
|
+
const collapsed = collapseDuplicatedBrazilianMobileNine(digits);
|
|
848
|
+
if (collapsed === digits) return digits;
|
|
849
|
+
try {
|
|
850
|
+
const original = (0, import_libphonenumber_js.parsePhoneNumber)(`+${digits}`);
|
|
851
|
+
if (original.isValid() && original.countryCallingCode !== BR_DIAL_CODE) {
|
|
852
|
+
return digits;
|
|
853
|
+
}
|
|
854
|
+
} catch {
|
|
855
|
+
}
|
|
856
|
+
return collapsed;
|
|
857
|
+
}
|
|
858
|
+
function formatNationalDigits(digits, country) {
|
|
859
|
+
if (!digits) return "";
|
|
860
|
+
const libCode = toLibCountryCode(country.code);
|
|
861
|
+
const formatter = new import_libphonenumber_js.AsYouType(libCode);
|
|
862
|
+
formatter.input(`+${country.dialCode}${digits}`);
|
|
863
|
+
const national = formatter.getNumber()?.formatNational();
|
|
864
|
+
if (national && nationalPhoneDigits(national) === digits) return national;
|
|
865
|
+
const asTyped = new import_libphonenumber_js.AsYouType(libCode).input(digits);
|
|
866
|
+
if (nationalPhoneDigits(asTyped) === digits) return asTyped;
|
|
867
|
+
return digits;
|
|
868
|
+
}
|
|
869
|
+
function formatPhoneNational(value, countryCode = DEFAULT_PHONE_COUNTRY_CODE) {
|
|
870
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
871
|
+
return formatNationalDigits(prepareNationalDigits(value, country), country);
|
|
872
|
+
}
|
|
873
|
+
function parsePhoneInput(input) {
|
|
874
|
+
const cleaned = String(input ?? "").replace(/[\s\-().]/g, "");
|
|
875
|
+
if (!cleaned) {
|
|
876
|
+
return { ddi: null, national: "", countryCode: null };
|
|
877
|
+
}
|
|
878
|
+
const hasPlus = cleaned.startsWith("+");
|
|
879
|
+
if (hasPlus) {
|
|
880
|
+
try {
|
|
881
|
+
const parsed = (0, import_libphonenumber_js.parsePhoneNumber)(cleaned);
|
|
882
|
+
if (parsed.country) {
|
|
883
|
+
const ourCode = fromLibCountryCode(parsed.country);
|
|
884
|
+
if (PHONE_INPUT_COUNTRY_CODES.has(ourCode)) {
|
|
885
|
+
return {
|
|
886
|
+
ddi: parsed.countryCallingCode,
|
|
887
|
+
national: parsed.nationalNumber,
|
|
888
|
+
countryCode: ourCode
|
|
889
|
+
};
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
} catch {
|
|
893
|
+
}
|
|
894
|
+
const digits = cleaned.slice(1);
|
|
895
|
+
for (const ddi of SORTED_PHONE_INPUT_DIAL_CODES) {
|
|
896
|
+
if (digits.startsWith(ddi)) {
|
|
897
|
+
const national = digits.slice(ddi.length);
|
|
898
|
+
const match = PHONE_COUNTRIES.find((c) => c.dialCode === ddi);
|
|
899
|
+
return {
|
|
900
|
+
ddi,
|
|
901
|
+
national,
|
|
902
|
+
countryCode: match?.code ?? null
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
return {
|
|
907
|
+
ddi: null,
|
|
908
|
+
national: digits,
|
|
909
|
+
countryCode: null
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
return {
|
|
913
|
+
ddi: null,
|
|
914
|
+
national: cleaned.replace(/\D/g, ""),
|
|
915
|
+
countryCode: null
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
function preferValidE164(candidate) {
|
|
919
|
+
try {
|
|
920
|
+
const number = (0, import_libphonenumber_js.parsePhoneNumber)(candidate);
|
|
921
|
+
if (number.isValid()) return number.number;
|
|
922
|
+
} catch {
|
|
923
|
+
}
|
|
924
|
+
return candidate;
|
|
925
|
+
}
|
|
926
|
+
function toE164(value, countryCode = DEFAULT_PHONE_COUNTRY_CODE) {
|
|
927
|
+
const trimmed = String(value ?? "").trim();
|
|
928
|
+
if (!trimmed) return "";
|
|
929
|
+
const parsed = parsePhoneInput(trimmed);
|
|
930
|
+
if (parsed.ddi && parsed.national) {
|
|
931
|
+
const ddiCountry = parsed.countryCode && findPhoneCountry(parsed.countryCode) || PHONE_COUNTRIES.find((c) => c.dialCode === parsed.ddi) || defaultPhoneCountry();
|
|
932
|
+
return preferValidE164(
|
|
933
|
+
`+${parsed.ddi}${prepareNationalDigits(parsed.national, ddiCountry)}`
|
|
934
|
+
);
|
|
935
|
+
}
|
|
936
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
937
|
+
const national = prepareNationalDigits(parsed.national || trimmed, country);
|
|
938
|
+
if (!national) return "";
|
|
939
|
+
return preferValidE164(`+${country.dialCode}${national}`);
|
|
940
|
+
}
|
|
941
|
+
function isValidPhone(value, countryCode) {
|
|
942
|
+
const cleaned = String(value ?? "").trim();
|
|
943
|
+
if (!cleaned) return false;
|
|
944
|
+
if (cleaned.startsWith("+")) {
|
|
945
|
+
const digits2 = prepareInternationalDigits(cleaned);
|
|
946
|
+
return digits2 ? (0, import_libphonenumber_js.isValidPhoneNumber)(`+${digits2}`) : false;
|
|
947
|
+
}
|
|
948
|
+
const country = countryCode ? findPhoneCountry(countryCode) : defaultPhoneCountry();
|
|
949
|
+
if (!country) return false;
|
|
950
|
+
const digits = prepareNationalDigits(cleaned, country);
|
|
951
|
+
if (!digits) return false;
|
|
952
|
+
if (countryCode) {
|
|
953
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(digits, toLibCountryCode(countryCode));
|
|
954
|
+
}
|
|
955
|
+
if ((0, import_libphonenumber_js.isValidPhoneNumber)(`+${digits}`)) return true;
|
|
956
|
+
return (0, import_libphonenumber_js.isValidPhoneNumber)(digits, "BR");
|
|
957
|
+
}
|
|
958
|
+
function remaskPhoneForCountry(nationalOrDraft, countryCode) {
|
|
959
|
+
const country = findPhoneCountry(countryCode) ?? defaultPhoneCountry();
|
|
960
|
+
const digits = truncateNationalPhoneDigits(
|
|
961
|
+
nationalPhoneDigits(nationalOrDraft)
|
|
962
|
+
);
|
|
963
|
+
return {
|
|
964
|
+
display: formatNationalDigits(digits, country),
|
|
965
|
+
e164: digits ? `+${country.dialCode}${digits}` : "",
|
|
966
|
+
country
|
|
967
|
+
};
|
|
968
|
+
}
|
|
969
|
+
|
|
613
970
|
// src/resolve-site-id.ts
|
|
614
971
|
var PREVIEW_HOST_SUFFIXES = [".vusercontent.net"];
|
|
615
972
|
function isStudioPreviewHost(host) {
|
|
@@ -743,10 +1100,15 @@ function normalizeContact(input) {
|
|
|
743
1100
|
code: "invalid_contact"
|
|
744
1101
|
});
|
|
745
1102
|
}
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
1103
|
+
let normalizedPhone;
|
|
1104
|
+
if (phone) {
|
|
1105
|
+
const e164 = toE164(phone);
|
|
1106
|
+
if (!e164 || !isValidPhone(e164) || e164.length > 40) {
|
|
1107
|
+
throw new LeadSubmitError("Garagem SDK: phone is invalid.", {
|
|
1108
|
+
code: "invalid_contact"
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
normalizedPhone = e164;
|
|
750
1112
|
}
|
|
751
1113
|
const message = input.message?.trim() || void 0;
|
|
752
1114
|
if (message && message.length > MESSAGE_MAX) {
|
|
@@ -757,10 +1119,19 @@ function normalizeContact(input) {
|
|
|
757
1119
|
return {
|
|
758
1120
|
name,
|
|
759
1121
|
...email ? { email } : {},
|
|
760
|
-
...
|
|
1122
|
+
...normalizedPhone ? { phone: normalizedPhone } : {},
|
|
761
1123
|
...message ? { message } : {}
|
|
762
1124
|
};
|
|
763
1125
|
}
|
|
1126
|
+
function normalizeSdkBusinessType(value) {
|
|
1127
|
+
if (!value) return void 0;
|
|
1128
|
+
const normalized = value.trim().toLowerCase();
|
|
1129
|
+
if (normalized === "rent" || normalized === "rental" || normalized === "aluguel") {
|
|
1130
|
+
return "rent";
|
|
1131
|
+
}
|
|
1132
|
+
if (normalized === "sale" || normalized === "venda") return "sale";
|
|
1133
|
+
return void 0;
|
|
1134
|
+
}
|
|
764
1135
|
async function postSiteLead(input) {
|
|
765
1136
|
const siteId = await resolveLeadSiteId(input);
|
|
766
1137
|
const base = normalizeBaseUrl(input.baseUrl);
|
|
@@ -808,13 +1179,16 @@ async function postSiteLead(input) {
|
|
|
808
1179
|
}
|
|
809
1180
|
function leadPostContext(input) {
|
|
810
1181
|
assertListingId(input.listingId);
|
|
1182
|
+
const businessType = normalizeSdkBusinessType(input.businessType) ?? normalizeSdkBusinessType(input.listingType);
|
|
811
1183
|
return {
|
|
812
1184
|
listingId: input.listingId.trim(),
|
|
813
1185
|
contact: normalizeContact(input),
|
|
814
1186
|
extras: {
|
|
815
1187
|
...input.visitorId ? { visitorId: input.visitorId } : {},
|
|
816
1188
|
...input.brokerRef ? { brokerRef: input.brokerRef } : {},
|
|
817
|
-
...input.referrer ? { referrer: input.referrer } : {}
|
|
1189
|
+
...input.referrer ? { referrer: input.referrer } : {},
|
|
1190
|
+
...businessType ? { businessType } : {},
|
|
1191
|
+
...input.listingType ? { listingType: input.listingType } : {}
|
|
818
1192
|
}
|
|
819
1193
|
};
|
|
820
1194
|
}
|
|
@@ -1252,7 +1626,7 @@ function toListingCardModel(listing) {
|
|
|
1252
1626
|
businessLabel: listingBusinessLabel(listing.businessType),
|
|
1253
1627
|
priceVisibility: listing.priceVisibility,
|
|
1254
1628
|
price: listing.price,
|
|
1255
|
-
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price),
|
|
1629
|
+
priceLabel: isPrivate ? "Sob consulta" : formatListingPrice(listing.price, "pt-BR", listing.currency ?? "BRL"),
|
|
1256
1630
|
pricePeriod: listing.businessType === "rental" && !isPrivate && listing.price != null ? "/m\xEAs" : null,
|
|
1257
1631
|
locationLabel: listingLocationLabel(listing.location || {}),
|
|
1258
1632
|
propertyType: listing.property?.type ?? null,
|
|
@@ -2176,7 +2550,11 @@ function listingValues(listing) {
|
|
|
2176
2550
|
{
|
|
2177
2551
|
key: "price",
|
|
2178
2552
|
label: "Pre\xE7o",
|
|
2179
|
-
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(
|
|
2553
|
+
text: listing.priceVisibility === "private" ? "Sob consulta" : formatListingPrice(
|
|
2554
|
+
listing.price,
|
|
2555
|
+
"pt-BR",
|
|
2556
|
+
listing.currency ?? "BRL"
|
|
2557
|
+
)
|
|
2180
2558
|
}
|
|
2181
2559
|
];
|
|
2182
2560
|
const condoFee = positiveCount(listing.property?.condoFee);
|
|
@@ -2411,6 +2789,28 @@ var STUDIO_SDK_CONTRACT = {
|
|
|
2411
2789
|
"listingBusinessLabel",
|
|
2412
2790
|
"formatListingPrice"
|
|
2413
2791
|
],
|
|
2792
|
+
/**
|
|
2793
|
+
* Prompt-safe phone helpers on `minNpmVersion`. Empty until a published
|
|
2794
|
+
* tarball exports them and this pin bumps — then move names here from
|
|
2795
|
+
* `unpublishedPhoneExports`.
|
|
2796
|
+
*/
|
|
2797
|
+
phoneExports: [],
|
|
2798
|
+
/**
|
|
2799
|
+
* Headless phone mask helpers in git / newer tarballs but not on
|
|
2800
|
+
* `minNpmVersion` (0.4.12). Prompts, completeness, and repair text must
|
|
2801
|
+
* not mention these until the pin bumps — v0 installs the pin and the
|
|
2802
|
+
* ESM loader throws on missing named exports.
|
|
2803
|
+
*/
|
|
2804
|
+
unpublishedPhoneExports: [
|
|
2805
|
+
"PHONE_COUNTRIES",
|
|
2806
|
+
"formatPhoneNational",
|
|
2807
|
+
"toE164",
|
|
2808
|
+
"isValidPhone",
|
|
2809
|
+
"parsePhoneInput",
|
|
2810
|
+
"phoneCountrySearchValue",
|
|
2811
|
+
"findPhoneCountry",
|
|
2812
|
+
"remaskPhoneForCountry"
|
|
2813
|
+
],
|
|
2414
2814
|
amenityExports: ["listingAmenityGroups"],
|
|
2415
2815
|
/**
|
|
2416
2816
|
* Names already on the pinned npm tarball (`minNpmVersion` / 0.4.12) —
|
|
@@ -2464,7 +2864,7 @@ ${studioSiteWidthCss()}
|
|
|
2464
2864
|
Every page section is two layers: (1) surface \u2014 \`section\` / header / footer \`${STUDIO_SITE_LAYOUT.surfaceClassName}\`, background to the viewport edges, no max-width class and no horizontal padding; (2) wrapper \u2014 one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. Header and footer use that same inner wrapper. Components fill the wrapper (\`w-full\`). Never nest a second max-width container with extra horizontal padding. ${studioSearchLandmarkInstruction()} Do not use \`ml-auto\` on the content wrapper. To make the site narrower or wider, change ONLY \`--site-max-width\` in \`app/globals.css\` (allowed: ${scale}; default ${STUDIO_SITE_LAYOUT.maxWidthRem}). Do not edit wrapper class names or horizontal padding. Full-bleed image surfaces (home hero, listing gallery) stay flush with the header \u2014 do not add vertical padding there.`;
|
|
2465
2865
|
}
|
|
2466
2866
|
function studioSearchLandmarkInstruction() {
|
|
2467
|
-
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`.
|
|
2867
|
+
return `Search at \`/imoveis\` (hard rule). The page landmark is \`<main className="${STUDIO_SITE_LAYOUT.searchMainClassName}">\` with one child \`${STUDIO_SITE_LAYOUT.wrapperClassName}\`. The server page awaits the catalog and renders it with \`usePublicSearch\` from \`${STUDIO_SDK_PACKAGE}/react\` (\`search\` from the page searchParams, plus \`initial\`). Do not wrap that UI in \`<Suspense>\` and do not add a route \`loading\` file. A suspended page is streamed into a hidden node and stays invisible until JavaScript runs. Do not wrap the search UI in \`<section>\` or a second max-width. The page owns the SEO heading as \`<div data-slot="search-heading">\`: count \`<span data-slot="search-heading-count">\` FIRST, then \`<h1 data-slot="search-heading-title">\` \u2014 never put the count inside the H1 and never put the h1 first. \`pt-4 pb-12\` is the default on that search \`<main>\` \u2014 change those values if the design needs it. Flush search (glued to the header) is allowed only with \`${STUDIO_SITE_LAYOUT.searchFlushMarker}\` on that \`<main>\`. Never add that vertical padding to home heroes or listing galleries.`;
|
|
2468
2868
|
}
|
|
2469
2869
|
var REACT_SDK_NAMED_IMPORT_RE = /(?:^|[\n;])\s*import\s+(?!type\b)(?:type\s+)?\{([^}]+)\}\s+from\s+['"]@garagem-ai\/site-sdk\/react['"]/g;
|
|
2470
2870
|
var SHOWCASE_LEADS_POST_URL_RE = /\/api\/sites\/[^\s"']*\/leads(?!\/ui)/;
|
|
@@ -2527,11 +2927,11 @@ function studioSdkPinInstruction() {
|
|
|
2527
2927
|
}
|
|
2528
2928
|
function studioLeadInstruction() {
|
|
2529
2929
|
const names = STUDIO_SDK_CONTRACT.leadExports.join(", ");
|
|
2530
|
-
return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` \u2014 never concatenate a leads webhook URL and never POST the Showcase demo leads route.`;
|
|
2930
|
+
return `Listing-detail visit/contact leads: import ${names} from \`${STUDIO_SDK_PACKAGE}\` (the main package, not \`/react\`). Call \`submitVisitLead\` / \`submitContactLead\` \u2014 never concatenate a leads webhook URL and never POST the Showcase demo leads route. Phone fields use a national mask with a country picker and submit E.164 \u2014 do not invent a second mask and do not import \`@garagem/ui\` PhoneInput.`;
|
|
2531
2931
|
}
|
|
2532
2932
|
function studioListingCardInstruction() {
|
|
2533
2933
|
const names = STUDIO_SDK_CONTRACT.listingCardExports.join(", ");
|
|
2534
|
-
return `Listing card (site-wide). WRITE \`components/garagem/listing-card.tsx\` \u2014 one module for home, search results, and similar listings. Do not invent a second card. From \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`const model = toListingCardModel(listing)\`. href is \`model.href\` / \`listingPublicPath(listing)\` \u2014 never \`listing.id\` or \`property.id\`. Skip the card or omit the link when href is empty (no \`href=""\`, no \`href="#"\`). Must show title (\`model.title\`) and price (\`model.priceLabel\` \u2014 \u201CSob consulta\u201D when private; \`model.pricePeriod\` \u201C/m\xEAs\u201D when present, omit when null). Photo: \`model.coverSrc\` as img \`src\`, alt \`model.coverAlt\`; skip the img when cover is missing; an empty-photo block is allowed; never Unsplash, \`/placeholder.svg\`, or invented \`?query=\` images. Show when present, omit the line when missing: \`locationLabel\` (else \`propertyType\`), \`listingBusinessLabel\` / \`model.businessLabel\`, bedrooms, bathrooms, parkingSpaces, area via \`formatAreaM2\`. Never interpolate the listing object as a React child. Design is free (grid vs carousel vs mosaic; radius is site \`--radius\`). WRITE \`components/garagem/listing-card-skeleton.tsx\` for
|
|
2934
|
+
return `Listing card (site-wide). WRITE \`components/garagem/listing-card.tsx\` \u2014 one module for home, search results, and similar listings. Do not invent a second card. From \`${STUDIO_SDK_PACKAGE}\` import ${names}. \`const model = toListingCardModel(listing)\`. href is \`model.href\` / \`listingPublicPath(listing)\` \u2014 never \`listing.id\` or \`property.id\`. Skip the card or omit the link when href is empty (no \`href=""\`, no \`href="#"\`). Must show title (\`model.title\`) and price (\`model.priceLabel\` \u2014 \u201CSob consulta\u201D when private; \`model.pricePeriod\` \u201C/m\xEAs\u201D when present, omit when null). Photo: \`model.coverSrc\` as img \`src\`, alt \`model.coverAlt\`; skip the img when cover is missing; an empty-photo block is allowed; never Unsplash, \`/placeholder.svg\`, or invented \`?query=\` images. Show when present, omit the line when missing: \`locationLabel\` (else \`propertyType\`), \`listingBusinessLabel\` / \`model.businessLabel\`, bedrooms, bathrooms, parkingSpaces, area via \`formatAreaM2\`. Never interpolate the listing object as a React child. Design is free (grid vs carousel vs mosaic; radius is site \`--radius\`). WRITE \`components/garagem/listing-card-skeleton.tsx\` only for a slot whose content is still unknown \u2014 never as a \`<Suspense>\` fallback that replaces the catalog, and never the text \u201CCarregando im\xF3veis\u2026\u201D. Do not \`if (search.loading) return\` that skeleton inside the search client.`;
|
|
2535
2935
|
}
|
|
2536
2936
|
function studioListingDetailInstruction() {
|
|
2537
2937
|
const names = STUDIO_SDK_CONTRACT.listingDetailExports.join(", ");
|
|
@@ -2543,7 +2943,7 @@ function studioAmenityInstruction() {
|
|
|
2543
2943
|
function studioSearchInstruction() {
|
|
2544
2944
|
const reactNames = STUDIO_SDK_CONTRACT.reactExports.join(", ");
|
|
2545
2945
|
const libNames = STUDIO_SDK_CONTRACT.searchExports.join(", ");
|
|
2546
|
-
return `Search: import ${reactNames} from \`${STUDIO_SDK_PACKAGE}/react\`. From \`${STUDIO_SDK_PACKAGE}\` import ${libNames}.
|
|
2946
|
+
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)}`;
|
|
2547
2947
|
}
|
|
2548
2948
|
function studioChromeInstruction() {
|
|
2549
2949
|
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\`.`;
|
|
@@ -2566,6 +2966,11 @@ function studioCodegenContractViolations(text) {
|
|
|
2566
2966
|
violations.push(name);
|
|
2567
2967
|
}
|
|
2568
2968
|
}
|
|
2969
|
+
for (const name of STUDIO_SDK_CONTRACT.unpublishedPhoneExports) {
|
|
2970
|
+
if (mentionsExportName(text, name) && !violations.includes(name)) {
|
|
2971
|
+
violations.push(name);
|
|
2972
|
+
}
|
|
2973
|
+
}
|
|
2569
2974
|
const pin = STUDIO_SDK_CONTRACT.minNpmVersion;
|
|
2570
2975
|
const available = reactExportsAvailableAt(pin);
|
|
2571
2976
|
for (const name of parseReactSdkNamedImports(text)) {
|
|
@@ -2740,11 +3145,14 @@ function createGaragemClient(options = {}) {
|
|
|
2740
3145
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2741
3146
|
0 && (module.exports = {
|
|
2742
3147
|
AMENITY_FALLBACK_LABELS,
|
|
3148
|
+
DEFAULT_PHONE_COUNTRY_CODE,
|
|
2743
3149
|
FORBIDDEN_SEARCH_QUERY_KEYS,
|
|
2744
3150
|
GaragemSdkError,
|
|
2745
3151
|
LISTING_AMENITY_TITLES,
|
|
2746
3152
|
LISTING_DESCRIPTION_CLAMP,
|
|
2747
3153
|
LeadSubmitError,
|
|
3154
|
+
MAX_NATIONAL_PHONE_DIGITS,
|
|
3155
|
+
PHONE_COUNTRIES,
|
|
2748
3156
|
SEARCH_EMPTY_COPY,
|
|
2749
3157
|
SEARCH_SORT_RELEVANCE,
|
|
2750
3158
|
STUDIO_DEFAULT_VISIT_SCHEDULE,
|
|
@@ -2758,18 +3166,22 @@ function createGaragemClient(options = {}) {
|
|
|
2758
3166
|
canonicalizeSearchHref,
|
|
2759
3167
|
clearStagedPathFilters,
|
|
2760
3168
|
coerceNpmVersion,
|
|
3169
|
+
collapseDuplicatedBrazilianMobileNine,
|
|
2761
3170
|
compareSemver,
|
|
2762
3171
|
composeSearchPublicHref,
|
|
2763
3172
|
composeSearchPublicPath,
|
|
2764
3173
|
countFacetChoices,
|
|
2765
3174
|
countOptionLabel,
|
|
2766
3175
|
createGaragemClient,
|
|
3176
|
+
defaultPhoneCountry,
|
|
2767
3177
|
displayPathLocation,
|
|
2768
3178
|
expandVisitSchedule,
|
|
2769
3179
|
expandVisitTimeSlots,
|
|
3180
|
+
findPhoneCountry,
|
|
2770
3181
|
formatAreaM2,
|
|
2771
3182
|
formatGroupedInteger,
|
|
2772
3183
|
formatListingPrice,
|
|
3184
|
+
formatPhoneNational,
|
|
2773
3185
|
getCmsCollection,
|
|
2774
3186
|
getCmsCollections,
|
|
2775
3187
|
getCmsEntries,
|
|
@@ -2786,6 +3198,7 @@ function createGaragemClient(options = {}) {
|
|
|
2786
3198
|
hrefWithExplicitPage,
|
|
2787
3199
|
isListingDetailPath,
|
|
2788
3200
|
isStudioPreviewHost,
|
|
3201
|
+
isValidPhone,
|
|
2789
3202
|
isVisitSlotAllowed,
|
|
2790
3203
|
labelAmenities,
|
|
2791
3204
|
listingAmenityGroups,
|
|
@@ -2803,22 +3216,26 @@ function createGaragemClient(options = {}) {
|
|
|
2803
3216
|
listingPublicPath,
|
|
2804
3217
|
listingValues,
|
|
2805
3218
|
mergeAppliedSearchQueryIntoSearch,
|
|
3219
|
+
nationalPhoneDigits,
|
|
2806
3220
|
normalizeVisitDate,
|
|
2807
3221
|
normalizeVisitTime,
|
|
2808
3222
|
paginationPages,
|
|
2809
3223
|
parseAppliedSearchQuery,
|
|
2810
3224
|
parseGroupedInteger,
|
|
3225
|
+
parsePhoneInput,
|
|
2811
3226
|
parseReactSdkNamedImports,
|
|
2812
3227
|
parseSearchPublicPath,
|
|
2813
3228
|
pathFilterHasOption,
|
|
2814
3229
|
pathFilterValue,
|
|
2815
3230
|
pathFiltersToQueryFilters,
|
|
2816
3231
|
pathLocationToFilterInput,
|
|
3232
|
+
phoneCountrySearchValue,
|
|
2817
3233
|
publicSearchHref,
|
|
2818
3234
|
queryListings,
|
|
2819
3235
|
rangeDraftFromPath,
|
|
2820
3236
|
readPublicSearch,
|
|
2821
3237
|
reduceAppliedSearchQuery,
|
|
3238
|
+
remaskPhoneForCountry,
|
|
2822
3239
|
resolvePublicSiteId,
|
|
2823
3240
|
searchChromeModel,
|
|
2824
3241
|
searchHrefUsesLegacyFilterQuery,
|
|
@@ -2841,8 +3258,10 @@ function createGaragemClient(options = {}) {
|
|
|
2841
3258
|
studioSiteWidthCss,
|
|
2842
3259
|
submitContactLead,
|
|
2843
3260
|
submitVisitLead,
|
|
3261
|
+
toE164,
|
|
2844
3262
|
toListingCardModel,
|
|
2845
3263
|
toolbarFilterIds,
|
|
3264
|
+
truncateNationalPhoneDigits,
|
|
2846
3265
|
unavailableReactImports,
|
|
2847
3266
|
visibleSearchFilters
|
|
2848
3267
|
});
|