@meetelise/chat 1.72.0 → 1.74.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.
@@ -35,12 +35,16 @@ import mapValues from "lodash/mapValues";
35
35
  import classnames from "classnames";
36
36
  import parseISO from "date-fns/parseISO";
37
37
  import compareAsc from "date-fns/compareAsc";
38
+ import isValid from "date-fns/isValid";
38
39
  import { InputStyles } from "../actions/InputStyles";
39
40
  import { classMap } from "lit/directives/class-map.js";
40
41
  import {
41
42
  FeatureFlagsShowDropdown,
42
43
  fetchTrackedRolloutCoastalCustomTourTypes,
43
44
  } from "../../fetchFeatureFlag";
45
+ import fetchFloorplanOptions, {
46
+ FloorplanOption,
47
+ } from "../../fetchFloorplanOptions";
44
48
  import {
45
49
  appendParamsToUrl,
46
50
  getUrlQueryParameters,
@@ -227,6 +231,12 @@ export class TourScheduler extends LitElement {
227
231
  private promptForReschedule = false;
228
232
  @state()
229
233
  private canceledReschedule = false;
234
+ /** The existing tour's community, from the "already has a tour" 409. */
235
+ @state()
236
+ private existingTourBuildingName?: string;
237
+ /** The existing tour's readable time, in its own UTC offset, from the same 409. */
238
+ @state()
239
+ private existingTourStartTime?: string;
230
240
  @state()
231
241
  isBrokerReferral = false;
232
242
  @state()
@@ -284,6 +294,8 @@ export class TourScheduler extends LitElement {
284
294
  selectedLeadSource!: MESelect;
285
295
  @query("me-select#layout")
286
296
  selectedLayoutEl?: MESelect;
297
+ @query("me-select#floorplan")
298
+ selectedFloorplanEl?: MESelect;
287
299
  @query("me-select#unit")
288
300
  selectedUnitEl?: MESelect;
289
301
 
@@ -295,6 +307,11 @@ export class TourScheduler extends LitElement {
295
307
  leadSourceInputValue = "";
296
308
  @state()
297
309
  selectedLayoutValue = "";
310
+ /** Filled when the building is on the WEBCHAT_FLOORPLAN_PREFERENCE switch; the floor plan dropdown then replaces the bedroom one. */
311
+ @state()
312
+ floorplanOptions: FloorplanOption[] = [];
313
+ @state()
314
+ selectedFloorplanName = "";
298
315
  @state()
299
316
  selectedUnitValue = "";
300
317
  @state()
@@ -583,6 +600,7 @@ export class TourScheduler extends LitElement {
583
600
  const useCoastalCustomTourTypes = fetchTrackedRolloutCoastalCustomTourTypes(
584
601
  this.buildingSlug
585
602
  );
603
+ const floorplanOptions = fetchFloorplanOptions(this.buildingSlug);
586
604
  this.tourTypeOrder = tourTypeOrderFor(
587
605
  await getRawAvailabilities(this.buildingId).then(
588
606
  (availabilities) => availabilities.rankOrderedSupportedTourTypes ?? [],
@@ -590,6 +608,7 @@ export class TourScheduler extends LitElement {
590
608
  )
591
609
  );
592
610
  this.useCoastalCustomTourTypes = await useCoastalCustomTourTypes;
611
+ this.floorplanOptions = await floorplanOptions;
593
612
  await Promise.all([
594
613
  this._setAvailabilities().then(async () => {
595
614
  try {
@@ -635,6 +654,8 @@ export class TourScheduler extends LitElement {
635
654
  this.mobilePageIndex = 0;
636
655
  this.units = [];
637
656
  this.selectedLayoutValue = "";
657
+ this.floorplanOptions = [];
658
+ this.selectedFloorplanName = "";
638
659
  this.selectedUnitValue = "";
639
660
 
640
661
  this.buildingId = building.building_id;
@@ -818,7 +839,9 @@ export class TourScheduler extends LitElement {
818
839
  );
819
840
  },
820
841
  layout: (): boolean =>
821
- !this.bedroomPreferenceRequired || !!this.selectedLayoutValue,
842
+ !this.bedroomPreferenceRequired ||
843
+ !!this.selectedLayoutValue ||
844
+ !!this.selectedFloorplanName,
822
845
  broker: (): boolean => {
823
846
  const broker = this.brokerReferral();
824
847
  // The broker's phone is optional, but one that's been typed has to be valid.
@@ -941,6 +964,9 @@ export class TourScheduler extends LitElement {
941
964
  query_params: Object.fromEntries(queryParams.entries()),
942
965
  conversation_tracking_id: this.leadSourceClient?.chatId,
943
966
  layouts: selectedLayout ? [selectedLayout] : undefined,
967
+ floorplans: this.selectedFloorplanName
968
+ ? [this.selectedFloorplanName]
969
+ : undefined,
944
970
  unit_numbers: selectedUnit ? [selectedUnit] : undefined,
945
971
  lead_sources_with_timestamps: (
946
972
  this.leadSourceMultitouchClient?.getSafeLeadSourceTouchpointsWithDefault(
@@ -1007,6 +1033,13 @@ export class TourScheduler extends LitElement {
1007
1033
  !this.promptForReschedule &&
1008
1034
  message === "User already has a tour scheduled for this building"
1009
1035
  ) {
1036
+ const headers = typedError.response.headers;
1037
+ this.existingTourBuildingName = decodedHeader(
1038
+ headers["existing-tour-building-name"]
1039
+ );
1040
+ this.existingTourStartTime = readableTimeAtOwnOffset(
1041
+ headers["existing-tour-start-time"]
1042
+ );
1010
1043
  this.promptForReschedule = true;
1011
1044
  this.isSubmitting = false;
1012
1045
  this.tourIsBooked = false;
@@ -1544,6 +1577,29 @@ export class TourScheduler extends LitElement {
1544
1577
  );
1545
1578
  }
1546
1579
 
1580
+ /** Sets the canonical layout ("studio", "1br", ...) picked from the bedroom or floor plan dropdown. */
1581
+ private selectLayout = (v: string): void => {
1582
+ this.selectedLayoutValue = v;
1583
+ // Clear unit selection if it no longer matches the new layout.
1584
+ if (v && this.selectedUnitValue) {
1585
+ const unit = this.units.find(
1586
+ (u) => u.unitNumber === this.selectedUnitValue
1587
+ );
1588
+ if (unit && layoutValueToCanonical(unit.numberOfBedrooms * 10) !== v) {
1589
+ this.selectedUnitValue = "";
1590
+ if (this.selectedUnitEl) {
1591
+ this.selectedUnitEl.value = undefined;
1592
+ }
1593
+ }
1594
+ }
1595
+ if (v) {
1596
+ pushGtmEvent("tourLayoutSelected", {
1597
+ layout: v,
1598
+ buildingId: this.buildingId,
1599
+ });
1600
+ }
1601
+ };
1602
+
1547
1603
  userInfoAndLayoutMenu(): TemplateResult {
1548
1604
  const isReferral = this.brokerIntakeEnabled && this.isBrokerReferral;
1549
1605
  return html`<h2 class="journey-header">Your Information</h2>
@@ -1626,7 +1682,30 @@ export class TourScheduler extends LitElement {
1626
1682
  ${this.brokerIntakeEnabled && !isReferral
1627
1683
  ? this.renderBrokerToggle()
1628
1684
  : ""}
1629
- ${this.layoutOptions.length > 0
1685
+ ${this.floorplanOptions.length > 0
1686
+ ? html` <me-select
1687
+ id="floorplan"
1688
+ placeholder=${this.bedroomPreferenceRequired
1689
+ ? "Floor plan preference"
1690
+ : "Floor plan preference (optional)"}
1691
+ .value=${this.selectedFloorplanName}
1692
+ .options="${this.floorplanOptions.map((o) => ({
1693
+ label: o.name,
1694
+ value: o.name,
1695
+ }))}"
1696
+ @change=${() => {
1697
+ const name = this.selectedFloorplanEl?.value || "";
1698
+ const bedrooms = this.floorplanOptions.find(
1699
+ (o) => o.name === name
1700
+ )?.bedrooms;
1701
+ this.selectedFloorplanName = name;
1702
+ this.selectLayout(
1703
+ bedrooms == null ? "" : layoutValueToCanonical(bedrooms * 10)
1704
+ );
1705
+ }}
1706
+ >
1707
+ </me-select>`
1708
+ : this.layoutOptions.length > 0
1630
1709
  ? html` <me-select
1631
1710
  id="layout"
1632
1711
  placeholder=${this.bedroomPreferenceRequired
@@ -1636,31 +1715,8 @@ export class TourScheduler extends LitElement {
1636
1715
  label: o.label,
1637
1716
  value: layoutValueToCanonical(o.value),
1638
1717
  }))}"
1639
- @change=${() => {
1640
- const v = this.selectedLayoutEl?.value || "";
1641
- this.selectedLayoutValue = v;
1642
- // Clear unit selection if it no longer matches the new layout.
1643
- if (v && this.selectedUnitValue) {
1644
- const unit = this.units.find(
1645
- (u) => u.unitNumber === this.selectedUnitValue
1646
- );
1647
- if (
1648
- unit &&
1649
- layoutValueToCanonical(unit.numberOfBedrooms * 10) !== v
1650
- ) {
1651
- this.selectedUnitValue = "";
1652
- if (this.selectedUnitEl) {
1653
- this.selectedUnitEl.value = undefined;
1654
- }
1655
- }
1656
- }
1657
- if (v) {
1658
- pushGtmEvent("tourLayoutSelected", {
1659
- layout: v,
1660
- buildingId: this.buildingId,
1661
- });
1662
- }
1663
- }}
1718
+ @change=${() =>
1719
+ this.selectLayout(this.selectedLayoutEl?.value || "")}
1664
1720
  >
1665
1721
  </me-select>`
1666
1722
  : ""}
@@ -1710,11 +1766,9 @@ export class TourScheduler extends LitElement {
1710
1766
  confirmationMessage(): TemplateResult {
1711
1767
  if (!this.selectedDate || !this.selectedTime || this.tourType === null)
1712
1768
  return html``;
1713
- // format example: "November 9th, 2022 at 11:00pm"
1714
- const readableDateAndTime = formatInTimeZone(
1715
- parseISO(`${this.selectedTime.datetime}${this.selectedTime.offset}`),
1716
- this.calendarTimeZone,
1717
- "MMM d 'at' h:mmaaa"
1769
+ const readableDateAndTime = readableTourTime(
1770
+ `${this.selectedTime.datetime}${this.selectedTime.offset}`,
1771
+ this.calendarTimeZone
1718
1772
  );
1719
1773
 
1720
1774
  if (this.canceledReschedule) {
@@ -1776,6 +1830,16 @@ export class TourScheduler extends LitElement {
1776
1830
  `;
1777
1831
  }
1778
1832
 
1833
+ /** Names the existing tour's community and time when the 409 sent both. */
1834
+ rescheduleExplanation(): TemplateResult {
1835
+ if (this.existingTourBuildingName && this.existingTourStartTime) {
1836
+ return html`You already have a tour scheduled at one of our communities,
1837
+ ${this.existingTourBuildingName}, on ${this.existingTourStartTime}. Would
1838
+ you like to reschedule?`;
1839
+ }
1840
+ return html`You already have a tour scheduled. Would you like to reschedule?`;
1841
+ }
1842
+
1779
1843
  /** The broker isn't the one touring: the client gets the confirmation email. */
1780
1844
  private referralConfirmation(readableDateAndTime: string): TemplateResult {
1781
1845
  if (this.tourType === null) return html``;
@@ -1964,8 +2028,7 @@ export class TourScheduler extends LitElement {
1964
2028
  <div>
1965
2029
  <h2 class="journey-header">Reschedule Tour</h2>
1966
2030
  <div class="explanation">
1967
- You already have a tour scheduled. Would you like to
1968
- reschedule?
2031
+ ${this.rescheduleExplanation()}
1969
2032
  </div>
1970
2033
  </div>
1971
2034
  </div>
@@ -2107,8 +2170,7 @@ export class TourScheduler extends LitElement {
2107
2170
  <div>
2108
2171
  <h2 class="journey-header">Reschedule Tour</h2>
2109
2172
  <div class="explanation">
2110
- You already have a tour scheduled. Would you like to
2111
- reschedule?
2173
+ ${this.rescheduleExplanation()}
2112
2174
  </div>
2113
2175
  </div>
2114
2176
  </div>
@@ -2226,6 +2288,37 @@ const tourTypeForSubmission = {
2226
2288
  [TourType.Virtual]: "live-virtual-tour",
2227
2289
  };
2228
2290
 
2291
+ // format example: "Nov 9 at 11:00pm"
2292
+ function readableTourTime(isoDateTime: string, timeZone: string): string {
2293
+ return formatInTimeZone(
2294
+ parseISO(isoDateTime),
2295
+ timeZone,
2296
+ "MMM d 'at' h:mmaaa"
2297
+ );
2298
+ }
2299
+
2300
+ /**
2301
+ * An ISO 8601 time such as "2026-11-16T15:15:00-05:00", read in its own UTC
2302
+ * offset rather than the viewer's time zone. Undefined when absent or unreadable.
2303
+ */
2304
+ function readableTimeAtOwnOffset(
2305
+ value: string | undefined
2306
+ ): string | undefined {
2307
+ const offset = value?.match(/(Z|[+-]\d{2}:\d{2})$/)?.[1];
2308
+ if (!value || !offset || !isValid(parseISO(value))) return undefined;
2309
+ return readableTourTime(value, offset);
2310
+ }
2311
+
2312
+ /** A percent-encoded UTF-8 header value, or undefined when absent or malformed. */
2313
+ function decodedHeader(value: string | undefined): string | undefined {
2314
+ if (!value) return undefined;
2315
+ try {
2316
+ return decodeURIComponent(value) || undefined;
2317
+ } catch {
2318
+ return undefined;
2319
+ }
2320
+ }
2321
+
2229
2322
  // LayoutOption.value is bedrooms * 10; EliseAI classifier expects `studio` / `Nbr`.
2230
2323
  function layoutValueToCanonical(value: number): string {
2231
2324
  const bedrooms = Math.round(value / 10);
@@ -225,7 +225,7 @@ export class CommunityPicker extends LitElement {
225
225
  type="date"
226
226
  .value=${f.moveIn ?? ""}
227
227
  @change=${(e: Event) => {
228
- this.openFilter = null;
228
+ void this.closeCommittedFilter("moveIn");
229
229
  this.setFilters({
230
230
  moveIn: (e.target as HTMLInputElement).value || null,
231
231
  });
@@ -244,7 +244,7 @@ export class CommunityPicker extends LitElement {
244
244
  .value=${f.maxBudget === null ? "" : String(f.maxBudget)}
245
245
  @change=${(e: Event) => {
246
246
  const value = parseInt((e.target as HTMLInputElement).value, 10);
247
- this.openFilter = null;
247
+ void this.closeCommittedFilter("budget");
248
248
  this.setFilters({
249
249
  maxBudget: Number.isFinite(value) && value > 0 ? value : null,
250
250
  });
@@ -253,6 +253,23 @@ export class CommunityPicker extends LitElement {
253
253
  </div>`;
254
254
  }
255
255
 
256
+ /**
257
+ * A move-in date or budget, once set, closes its panel and so removes the
258
+ * input that had focus. Focus goes back to the chip, as on Escape, rather
259
+ * than out of the dialog, unless the prospect already moved it elsewhere.
260
+ */
261
+ private async closeCommittedFilter(id: FilterId): Promise<void> {
262
+ this.openFilter = null;
263
+ await this.updateComplete;
264
+ // A Tab that set it moves focus on after this event; let it land first.
265
+ await new Promise((resolve) => setTimeout(resolve));
266
+ if (!document.activeElement || document.activeElement === document.body) {
267
+ this.shadowRoot
268
+ ?.querySelector<HTMLElement>(`[aria-controls="filter-${id}"]`)
269
+ ?.focus();
270
+ }
271
+ }
272
+
256
273
  private renderFilters(): TemplateResult {
257
274
  const open = this.openFilter;
258
275
  return html`<div class="picker-toolbar" role="group" aria-label="Filters">
@@ -7,6 +7,7 @@ import "../me-select";
7
7
  import type { MESelect } from "../me-select";
8
8
  import { tourSchedulerStyles } from "../Scheduler/tourSchedulerStyles";
9
9
  import { InputStyles } from "../actions/InputStyles";
10
+ import floorPlanSelectorStyles from "../FeeCalculator/components/floor-plan-selector/floor-plan-selector-styles";
10
11
  import type { LayoutOption } from "../../fetchBuildingWebchatView";
11
12
  import { isValidEmail } from "../../utils";
12
13
 
@@ -17,8 +18,8 @@ export interface ContactValues {
17
18
  phone: string;
18
19
  phoneE164: string | null;
19
20
  phoneCountry: string | null;
20
- /** The building's layout option value picked, or null. */
21
- layout: number | null;
21
+ /** The building's layout option values picked, in the options' order. */
22
+ layouts: number[];
22
23
  moveIn: string;
23
24
  notes: string;
24
25
  /** Picked in "How did you hear about us?", when that is shown. */
@@ -32,7 +33,7 @@ export const EMPTY_CONTACT: ContactValues = {
32
33
  phone: "",
33
34
  phoneE164: null,
34
35
  phoneCountry: null,
35
- layout: null,
36
+ layouts: [],
36
37
  moveIn: "",
37
38
  notes: "",
38
39
  leadSource: null,
@@ -40,7 +41,7 @@ export const EMPTY_CONTACT: ContactValues = {
40
41
 
41
42
  /**
42
43
  * Today's scheduler's rules: a first or last name, a valid email and phone,
43
- * and a bedroom preference only where the building requires one.
44
+ * and at least one bedroom preference only where the building requires one.
44
45
  */
45
46
  export const contactIsValid = (
46
47
  values: ContactValues,
@@ -49,7 +50,7 @@ export const contactIsValid = (
49
50
  (!!values.firstName.trim() || !!values.lastName.trim()) &&
50
51
  isValidEmail(values.email.trim()) &&
51
52
  !!values.phoneE164 &&
52
- (!bedroomsRequired || values.layout !== null);
53
+ (!bedroomsRequired || values.layouts.length > 0);
53
54
 
54
55
  /**
55
56
  * The prospect's details, in today's scheduler's "Your Information" column
@@ -104,6 +105,44 @@ export class ContactForm extends LitElement {
104
105
  });
105
106
  }
106
107
 
108
+ /**
109
+ * The bedroom preferences as the filters' chips: each tap picks or clears
110
+ * one, as the Bedrooms filter does.
111
+ */
112
+ private renderLayouts(): TemplateResult {
113
+ const picked = this.values.layouts;
114
+ return html`<div class="inputContainer">
115
+ <span class="section-label" id="layout-label">
116
+ Bedroom preferences${this.bedroomsRequired ? "" : " (optional)"}
117
+ </span>
118
+ <div
119
+ id="layout"
120
+ class="floor-plan-selector-badges"
121
+ role="group"
122
+ aria-labelledby="layout-label"
123
+ >
124
+ ${this.layoutOptions.map((o) => {
125
+ const selected = picked.includes(o.value);
126
+ return html`<button
127
+ type="button"
128
+ class=${classMap({ "floor-plan-badge": true, selected })}
129
+ aria-pressed=${String(selected)}
130
+ @click=${() =>
131
+ this.setValues({
132
+ layouts: this.layoutOptions
133
+ .map((option) => option.value)
134
+ .filter((value) =>
135
+ value === o.value ? !selected : picked.includes(value)
136
+ ),
137
+ })}
138
+ >
139
+ ${o.label}
140
+ </button>`;
141
+ })}
142
+ </div>
143
+ </div>`;
144
+ }
145
+
107
146
  render(): TemplateResult {
108
147
  const v = this.values;
109
148
  const emailInvalid = !!v.email && !isValidEmail(v.email.trim());
@@ -174,23 +213,7 @@ export class ContactForm extends LitElement {
174
213
  ? html`<p class="error-message">Invalid phone number</p>`
175
214
  : ""}
176
215
  </div>
177
- ${this.layoutOptions.length > 0
178
- ? html`<me-select
179
- id="layout"
180
- placeholder=${this.bedroomsRequired
181
- ? "Bedroom preference"
182
- : "Bedroom preference (optional)"}
183
- value=${v.layout === null ? "" : String(v.layout)}
184
- .options=${this.layoutOptions.map((o) => ({
185
- label: o.label,
186
- value: String(o.value),
187
- }))}
188
- @change=${(e: Event) => {
189
- const value = (e.target as MESelect).value;
190
- this.setValues({ layout: value ? Number(value) : null });
191
- }}
192
- ></me-select>`
193
- : ""}
216
+ ${this.layoutOptions.length > 0 ? this.renderLayouts() : ""}
194
217
  <div class="inputContainer">
195
218
  <label class="section-label" for="move-in">
196
219
  Move-in date (optional)
@@ -243,6 +266,7 @@ export class ContactForm extends LitElement {
243
266
  static styles = [
244
267
  tourSchedulerStyles,
245
268
  InputStyles,
269
+ floorPlanSelectorStyles,
246
270
  css`
247
271
  :host {
248
272
  display: contents;
@@ -254,6 +278,14 @@ export class ContactForm extends LitElement {
254
278
  gap: 4px;
255
279
  }
256
280
 
281
+ /* The filters' chips, wrapping in the column rather than scrolling. */
282
+ #layout {
283
+ flex-wrap: wrap;
284
+ margin: 0;
285
+ max-width: none;
286
+ overflow: visible;
287
+ }
288
+
257
289
  textarea {
258
290
  resize: vertical;
259
291
  width: 100%;
@@ -4,7 +4,9 @@ import { customElement, property } from "lit/decorators.js";
4
4
  /**
5
5
  * A trigger and the small panel it opens, for the v2 scheduler's secondary
6
6
  * choices. The panel floats under the trigger with `me-select`'s list surface
7
- * and closes, as that list does, on a click outside it, or on Escape. With
7
+ * and closes, as that list does, on a click outside it, or on Escape, and
8
+ * when focus moves out of it, so a later Escape closes the scheduler only
9
+ * once no panel is open. With
8
10
  * `inline` (phones) it opens in place instead, after its siblings in the
9
11
  * parent's flex row, as the filter row always did there.
10
12
  *
@@ -24,11 +26,13 @@ export class SchedulerPopover extends LitElement {
24
26
  super.connectedCallback();
25
27
  document.addEventListener("click", this.onDocumentClick);
26
28
  this.addEventListener("keydown", this.onKeydown);
29
+ this.addEventListener("focusout", this.onFocusout);
27
30
  }
28
31
 
29
32
  disconnectedCallback(): void {
30
33
  document.removeEventListener("click", this.onDocumentClick);
31
34
  this.removeEventListener("keydown", this.onKeydown);
35
+ this.removeEventListener("focusout", this.onFocusout);
32
36
  super.disconnectedCallback();
33
37
  }
34
38
 
@@ -43,6 +47,18 @@ export class SchedulerPopover extends LitElement {
43
47
  }
44
48
  };
45
49
 
50
+ /**
51
+ * Tabbing on to another control. Not when focus goes nowhere (a click on
52
+ * the panel's own text), nor inline, where closing would move what is
53
+ * being tapped.
54
+ */
55
+ private onFocusout = (e: FocusEvent): void => {
56
+ const to = e.relatedTarget;
57
+ if (this.open && !this.inline && to instanceof Node && !this.contains(to)) {
58
+ this.requestClose();
59
+ }
60
+ };
61
+
46
62
  private onKeydown = (e: KeyboardEvent): void => {
47
63
  if (!this.open || e.key !== "Escape" || e.isComposing) return;
48
64
  // The scheduler closes on Escape; here it only closes the panel.
@@ -81,6 +81,11 @@ const EMPTY_FILTERS: CommunityFilters = {
81
81
  maxBudget: null,
82
82
  };
83
83
 
84
+ /** The bedroom counts of layouts, once each. */
85
+ const bedroomsOf = (layouts: number[]): number[] => [
86
+ ...new Set(layouts.map(layoutToBedrooms)),
87
+ ];
88
+
84
89
  /** The building config value each tour type is offered under. */
85
90
  const TOUR_TYPE_OPTION_VALUE: Record<TourTypeId, string> = {
86
91
  "escorted-tour": "WITH_AGENT",
@@ -657,8 +662,7 @@ export class TourSchedulerV2 extends LitElement {
657
662
  last_name: values.lastName.trim(),
658
663
  email: values.email.trim(),
659
664
  phone_e164: values.phoneE164 ?? "",
660
- bedrooms:
661
- values.layout === null ? [] : [layoutToBedrooms(values.layout)],
665
+ bedrooms: bedroomsOf(values.layouts),
662
666
  move_in: values.moveIn || null,
663
667
  notes: values.notes.trim(),
664
668
  },
@@ -970,22 +974,20 @@ export class TourSchedulerV2 extends LitElement {
970
974
  : this.layoutOptions;
971
975
  }
972
976
 
973
- /**
974
- * The form's bedroom preference, from the shared bedrooms: the one offered
975
- * option they name, or none when they name no offered option or several.
976
- */
977
- private get preferredLayout(): number | null {
978
- const named = this.bedroomOptions.filter((option) =>
979
- this.preferences.bedrooms.includes(layoutToBedrooms(option.value))
980
- );
981
- return named.length === 1 ? named[0].value : null;
977
+ /** The form's bedroom preferences: every offered option the shared bedrooms name. */
978
+ private get preferredLayouts(): number[] {
979
+ return this.bedroomOptions
980
+ .map((option) => option.value)
981
+ .filter((value) =>
982
+ this.preferences.bedrooms.includes(layoutToBedrooms(value))
983
+ );
982
984
  }
983
985
 
984
986
  /** The form's values, with bedrooms and move-in from the shared preferences. */
985
987
  private get formValues(): ContactValues {
986
988
  return {
987
989
  ...this.contact,
988
- layout: this.preferredLayout,
990
+ layouts: this.preferredLayouts,
989
991
  moveIn: this.preferences.moveIn ?? "",
990
992
  };
991
993
  }
@@ -995,11 +997,23 @@ export class TourSchedulerV2 extends LitElement {
995
997
  // Every edit sends the whole form: only a field the prospect changed replaces
996
998
  // the shared value, so typing a name keeps bedrooms the form can't show.
997
999
  const shown = this.formValues;
998
- if (values.layout !== shown.layout) {
1000
+ // A chip picks or clears its bedroom count, so bedrooms the form doesn't
1001
+ // offer stay picked, and layouts sharing a count go on and off together.
1002
+ const cleared = bedroomsOf(
1003
+ shown.layouts.filter((layout) => !values.layouts.includes(layout))
1004
+ );
1005
+ const picked = bedroomsOf(
1006
+ values.layouts.filter((layout) => !shown.layouts.includes(layout))
1007
+ );
1008
+ if (cleared.length > 0 || picked.length > 0) {
999
1009
  this.preferences = {
1000
1010
  ...this.preferences,
1001
- bedrooms:
1002
- values.layout === null ? [] : [layoutToBedrooms(values.layout)],
1011
+ bedrooms: [
1012
+ ...new Set([
1013
+ ...this.preferences.bedrooms.filter((b) => !cleared.includes(b)),
1014
+ ...picked,
1015
+ ]),
1016
+ ].sort((a, b) => a - b),
1003
1017
  };
1004
1018
  }
1005
1019
  if (values.moveIn !== shown.moveIn) {
@@ -162,9 +162,7 @@ export class MESelect extends LitElement {
162
162
  overflow-y: scroll;
163
163
  position: absolute;
164
164
  min-height: 40px;
165
- min-width: 144px;
166
- max-width: 400px;
167
- width: max-content;
165
+ width: 100%;
168
166
  background-color: white;
169
167
  z-index: 20;
170
168
  margin-top: 4px;