@sbb-esta/lyne-elements-dev 5.0.0-next.3-dev.1780381732 → 5.0.0-next.3-dev.1780406485

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.
Files changed (45) hide show
  1. package/calendar/_calendar.global.scss +25 -26
  2. package/calendar/calendar/calendar.component.js +1 -1
  3. package/calendar/calendar-day/calendar-day.component.js +1 -1
  4. package/calendar/calendar-month/calendar-month.component.js +1 -1
  5. package/calendar/calendar-year/calendar-year.component.js +1 -1
  6. package/calendar/common/calendar-cell-base-element.js +1 -1
  7. package/calendar-cell-base-element-DHCKK3bU.js +23 -0
  8. package/{calendar-day.component-Caf2w9lS.js → calendar-day.component-DrMWf6-w.js} +2 -2
  9. package/calendar.component-BM4L9oyb.js +987 -0
  10. package/calendar.js +3 -3
  11. package/calendar.pure.js +3 -3
  12. package/core/i18n/i18n.js +4 -4
  13. package/core/styles/_theme.scss +1 -0
  14. package/custom-elements.json +401 -233
  15. package/datepicker/datepicker/datepicker.component.js +45 -27
  16. package/development/calendar/calendar/calendar.component.d.ts +27 -42
  17. package/development/calendar/calendar/calendar.component.d.ts.map +1 -1
  18. package/development/calendar/calendar/calendar.component.js +1 -1
  19. package/development/calendar/calendar-day/calendar-day.component.js +1 -1
  20. package/development/calendar/calendar-month/calendar-month.component.js +2 -2
  21. package/development/calendar/calendar-year/calendar-year.component.js +2 -2
  22. package/development/calendar/common/calendar-cell-base-element.js +1 -1
  23. package/development/calendar-cell-base-element-D9XadTz1.js +38 -0
  24. package/development/calendar-day.component-Zky9Z-Fq.js +139 -0
  25. package/development/calendar.component-C_Yc2PNV.js +1367 -0
  26. package/development/calendar.js +3 -3
  27. package/development/calendar.pure.js +3 -3
  28. package/development/core/decorators/id-reference.d.ts.map +1 -1
  29. package/development/core/decorators/id-reference.js +1 -1
  30. package/development/core/i18n/i18n.js +5 -5
  31. package/development/datepicker/datepicker/datepicker.component.d.ts +2 -0
  32. package/development/datepicker/datepicker/datepicker.component.d.ts.map +1 -1
  33. package/development/datepicker/datepicker/datepicker.component.js +37 -11
  34. package/lean-off-brand-theme.css +14 -22
  35. package/lean-safety-theme.css +14 -22
  36. package/lean-theme.css +14 -22
  37. package/off-brand-theme.css +14 -22
  38. package/package.json +2 -2
  39. package/safety-theme.css +14 -22
  40. package/standard-theme.css +14 -22
  41. package/calendar-cell-base-element-Dq7Ap5n-.js +0 -23
  42. package/calendar.component-DKKptbyy.js +0 -1082
  43. package/development/calendar-cell-base-element-D_CTwDn9.js +0 -38
  44. package/development/calendar-day.component-Bux4ezpg.js +0 -139
  45. package/development/calendar.component-NvMN01yi.js +0 -1478
@@ -0,0 +1,987 @@
1
+ import { __esDecorate as e, __runInitializers as t } from "tslib";
2
+ import { html as n, isServer as r, nothing as i, unsafeCSS as a } from "lit";
3
+ import { property as o, state as s } from "lit/decorators.js";
4
+ import { MONDAY as c, SbbElement as l, SbbFormAssociatedMixin as ee, SbbLanguageController as te, THURSDAY as ne, TUESDAY as re, WEDNESDAY as ie, buttonResetStyles as ae, defaultDateAdapter as oe, forceType as u, handleDistinctChange as se, i18nCalendarDateSelection as d, i18nCalendarWeekNumber as f, i18nNextMonth as ce, i18nNextYear as le, i18nNextYearRange as ue, i18nPreviousMonth as de, i18nPreviousYear as fe, i18nPreviousYearRange as pe, i18nYearMonthSelection as me, isArrowKeyOrPageKeysPressed as he, plainDate as p, readConfig as ge, screenReaderOnlyStyles as _e } from "./core.js";
5
+ import { SbbSecondaryButtonElement as ve } from "./button.pure.js";
6
+ import { SbbIconElement as ye } from "./icon.pure.js";
7
+ import { SbbCalendarDayElement as be } from "./calendar/calendar-day/calendar-day.component.js";
8
+ import { SbbCalendarMonthElement as xe } from "./calendar/calendar-month/calendar-month.component.js";
9
+ import { SbbCalendarWeekdayElement as Se } from "./calendar/calendar-weekday/calendar-weekday.component.js";
10
+ import { SbbCalendarWeeknumberElement as Ce } from "./calendar/calendar-weeknumber/calendar-weeknumber.component.js";
11
+ import { SbbCalendarYearElement as we } from "./calendar/calendar-year/calendar-year.component.js";
12
+ //#region src/elements/calendar/calendar/calendar.scss?inline
13
+ var Te = ":host{display:block;width:max-content;max-width:100%;line-height:var(--sbb-typo-line-height-text)}:host(:is(:state(enhanced),[state--enhanced])){--sbb-calendar-cell-padding-block-end: var(--sbb-spacing-fixed-3x)}.sbb-calendar__wrapper{width:100%;display:flex;flex-wrap:wrap;gap:var(--sbb-calendar-tables-gap);position:relative}:is(.sbb-calendar__year-view,.sbb-calendar__month-view){position:absolute;inset-block-start:0;inset-inline-start:0}:host(:not(:is(:state(view-day),[state--view-day]))) .sbb-calendar__day-view{visibility:hidden}.sbb-calendar__table-header{display:flex;align-items:center;gap:var(--sbb-calendar-control-gap);height:var(--sbb-size-element-xs);margin-block-end:var(--sbb-spacing-fixed-4x)}.sbb-calendar__table-header span{flex:1 1 auto;padding-inline-start:var(--sbb-spacing-fixed-3x);color:var(--sbb-calendar-control-view-change-color)}.sbb-calendar__control{-webkit-tap-highlight-color:transparent}.sbb-calendar__table{width:100%;border-collapse:collapse;height:max-content;flex:0 0}.sbb-calendar__table :is(thead,tbody){text-align:center}.sbb-calendar__table-header-cell,.sbb-calendar__table-header-cell-vertical{width:var(--sbb-calendar-cell-size);min-width:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-header-color);padding:0;font-size:var(--sbb-text-font-size-xs);font-weight:400;letter-spacing:var(--sbb-typo-letter-spacing-text)}:host(:not([multiple])) .sbb-calendar__table-header-cell,:host(:not([multiple])) .sbb-calendar__table-header-cell-vertical{height:var(--sbb-calendar-cell-size)}.sbb-calendar__table-header-cell-vertical{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}.sbb-calendar__table-data{position:relative;padding:0;text-align:center}.sbb-calendar__day-cell{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}:host(:not(:is(:state(enhanced),[state--enhanced]))) sbb-calendar-day{--sbb-calendar-day-justify-content: center;--sbb-calendar-day-height: var(--sbb-calendar-day-size);--sbb-calendar-day-extra-display: none;--sbb-calendar-day-value-height: unset}", m = 7, h = 4, g = 4, Ee = 12, _ = 24, v = class extends Event {
14
+ get range() {
15
+ return this._range;
16
+ }
17
+ constructor(e) {
18
+ super("monthchange", {
19
+ bubbles: !0,
20
+ composed: !0
21
+ }), this._range = Object.freeze(e || []);
22
+ }
23
+ }, y = class extends Event {
24
+ get dateSelected() {
25
+ return this._dateSelected;
26
+ }
27
+ constructor(e) {
28
+ super("dateselected", {
29
+ bubbles: !0,
30
+ composed: !0
31
+ }), this._dateSelected = Object.freeze(e);
32
+ }
33
+ }, b = (() => {
34
+ let b = ee(l), x = [], S, C = [], w = [], T, De = [], E = [], D, O = [], k = [], A, j = [], M = [], N, P = [], F = [], I, L, R = [], z = [], B, V = [], H = [], U, W = [], G = [], K, q = [], J = [], Y, X = [], Z = [], Q, Oe = [], ke = [], Ae, je = [], $ = [];
35
+ return class extends b {
36
+ static {
37
+ let t = typeof Symbol == "function" && Symbol.metadata ? Object.create(b[Symbol.metadata] ?? null) : void 0;
38
+ S = [u(), o({ type: Number })], T = [o()], D = [p(), o()], A = [p(), o()], N = [
39
+ u(),
40
+ se((e, t) => e._onMultipleChanged(t)),
41
+ o({ type: Boolean })
42
+ ], I = [o()], L = [s()], B = [o({ attribute: "date-filter" })], U = [o({ reflect: !0 })], K = [u(), o({
43
+ attribute: "week-numbers",
44
+ type: Boolean
45
+ })], Y = [s()], Q = [s()], Ae = [s()], e(this, null, S, {
46
+ kind: "accessor",
47
+ name: "amount",
48
+ static: !1,
49
+ private: !1,
50
+ access: {
51
+ has: (e) => "amount" in e,
52
+ get: (e) => e.amount,
53
+ set: (e, t) => {
54
+ e.amount = t;
55
+ }
56
+ },
57
+ metadata: t
58
+ }, C, w), e(this, null, T, {
59
+ kind: "accessor",
60
+ name: "view",
61
+ static: !1,
62
+ private: !1,
63
+ access: {
64
+ has: (e) => "view" in e,
65
+ get: (e) => e.view,
66
+ set: (e, t) => {
67
+ e.view = t;
68
+ }
69
+ },
70
+ metadata: t
71
+ }, De, E), e(this, null, D, {
72
+ kind: "accessor",
73
+ name: "min",
74
+ static: !1,
75
+ private: !1,
76
+ access: {
77
+ has: (e) => "min" in e,
78
+ get: (e) => e.min,
79
+ set: (e, t) => {
80
+ e.min = t;
81
+ }
82
+ },
83
+ metadata: t
84
+ }, O, k), e(this, null, A, {
85
+ kind: "accessor",
86
+ name: "max",
87
+ static: !1,
88
+ private: !1,
89
+ access: {
90
+ has: (e) => "max" in e,
91
+ get: (e) => e.max,
92
+ set: (e, t) => {
93
+ e.max = t;
94
+ }
95
+ },
96
+ metadata: t
97
+ }, j, M), e(this, null, N, {
98
+ kind: "accessor",
99
+ name: "multiple",
100
+ static: !1,
101
+ private: !1,
102
+ access: {
103
+ has: (e) => "multiple" in e,
104
+ get: (e) => e.multiple,
105
+ set: (e, t) => {
106
+ e.multiple = t;
107
+ }
108
+ },
109
+ metadata: t
110
+ }, P, F), e(this, null, I, {
111
+ kind: "setter",
112
+ name: "value",
113
+ static: !1,
114
+ private: !1,
115
+ access: {
116
+ has: (e) => "value" in e,
117
+ set: (e, t) => {
118
+ e.value = t;
119
+ }
120
+ },
121
+ metadata: t
122
+ }, null, x), e(this, null, L, {
123
+ kind: "accessor",
124
+ name: "_value",
125
+ static: !1,
126
+ private: !1,
127
+ access: {
128
+ has: (e) => "_value" in e,
129
+ get: (e) => e._value,
130
+ set: (e, t) => {
131
+ e._value = t;
132
+ }
133
+ },
134
+ metadata: t
135
+ }, R, z), e(this, null, B, {
136
+ kind: "accessor",
137
+ name: "dateFilter",
138
+ static: !1,
139
+ private: !1,
140
+ access: {
141
+ has: (e) => "dateFilter" in e,
142
+ get: (e) => e.dateFilter,
143
+ set: (e, t) => {
144
+ e.dateFilter = t;
145
+ }
146
+ },
147
+ metadata: t
148
+ }, V, H), e(this, null, U, {
149
+ kind: "accessor",
150
+ name: "orientation",
151
+ static: !1,
152
+ private: !1,
153
+ access: {
154
+ has: (e) => "orientation" in e,
155
+ get: (e) => e.orientation,
156
+ set: (e, t) => {
157
+ e.orientation = t;
158
+ }
159
+ },
160
+ metadata: t
161
+ }, W, G), e(this, null, K, {
162
+ kind: "accessor",
163
+ name: "weekNumbers",
164
+ static: !1,
165
+ private: !1,
166
+ access: {
167
+ has: (e) => "weekNumbers" in e,
168
+ get: (e) => e.weekNumbers,
169
+ set: (e, t) => {
170
+ e.weekNumbers = t;
171
+ }
172
+ },
173
+ metadata: t
174
+ }, q, J), e(this, null, Y, {
175
+ kind: "accessor",
176
+ name: "_activeDate",
177
+ static: !1,
178
+ private: !1,
179
+ access: {
180
+ has: (e) => "_activeDate" in e,
181
+ get: (e) => e._activeDate,
182
+ set: (e, t) => {
183
+ e._activeDate = t;
184
+ }
185
+ },
186
+ metadata: t
187
+ }, X, Z), e(this, null, Q, {
188
+ kind: "accessor",
189
+ name: "_calendarView",
190
+ static: !1,
191
+ private: !1,
192
+ access: {
193
+ has: (e) => "_calendarView" in e,
194
+ get: (e) => e._calendarView,
195
+ set: (e, t) => {
196
+ e._calendarView = t;
197
+ }
198
+ },
199
+ metadata: t
200
+ }, Oe, ke), e(this, null, Ae, {
201
+ kind: "accessor",
202
+ name: "_initialized",
203
+ static: !1,
204
+ private: !1,
205
+ access: {
206
+ has: (e) => "_initialized" in e,
207
+ get: (e) => e._initialized,
208
+ set: (e, t) => {
209
+ e._initialized = t;
210
+ }
211
+ },
212
+ metadata: t
213
+ }, je, $), t && Object.defineProperty(this, Symbol.metadata, {
214
+ enumerable: !0,
215
+ configurable: !0,
216
+ writable: !0,
217
+ value: t
218
+ });
219
+ }
220
+ static {
221
+ this.elementName = "sbb-calendar";
222
+ }
223
+ static {
224
+ this.elementDependencies = [
225
+ be,
226
+ xe,
227
+ Se,
228
+ Ce,
229
+ we,
230
+ ye,
231
+ ve
232
+ ];
233
+ }
234
+ static {
235
+ this.styles = [
236
+ ae,
237
+ _e,
238
+ a(Te)
239
+ ];
240
+ }
241
+ static {
242
+ this.events = {
243
+ dateselected: "dateselected",
244
+ monthchange: "monthchange"
245
+ };
246
+ }
247
+ #e;
248
+ get amount() {
249
+ return this.#e;
250
+ }
251
+ set amount(e) {
252
+ this.#e = e;
253
+ }
254
+ #t;
255
+ get view() {
256
+ return this.#t;
257
+ }
258
+ set view(e) {
259
+ this.#t = e;
260
+ }
261
+ #n;
262
+ get min() {
263
+ return this.#n;
264
+ }
265
+ set min(e) {
266
+ this.#n = e;
267
+ }
268
+ #r;
269
+ get max() {
270
+ return this.#r;
271
+ }
272
+ set max(e) {
273
+ this.#r = e;
274
+ }
275
+ #i;
276
+ get multiple() {
277
+ return this.#i;
278
+ }
279
+ set multiple(e) {
280
+ this.#i = e;
281
+ }
282
+ set value(e) {
283
+ if (Array.isArray(e)) this._value = e.map((e) => this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e))).filter((e) => e !== null).filter((e) => !this._isDayInRange(this._dateAdapter.toIso8601(e)) || this._dateFilter(e)).sort(this._sortDate);
284
+ else {
285
+ let t = this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));
286
+ t && (!this._isDayInRange(this._dateAdapter.toIso8601(t)) || this._dateFilter(t)) ? this._value = t : this._value = null;
287
+ }
288
+ }
289
+ get value() {
290
+ return this._value;
291
+ }
292
+ #a;
293
+ get _value() {
294
+ return this.#a;
295
+ }
296
+ set _value(e) {
297
+ this.#a = e;
298
+ }
299
+ #o;
300
+ get dateFilter() {
301
+ return this.#o;
302
+ }
303
+ set dateFilter(e) {
304
+ this.#o = e;
305
+ }
306
+ #s;
307
+ get orientation() {
308
+ return this.#s;
309
+ }
310
+ set orientation(e) {
311
+ this.#s = e;
312
+ }
313
+ #c;
314
+ get weekNumbers() {
315
+ return this.#c;
316
+ }
317
+ set weekNumbers(e) {
318
+ this.#c = e;
319
+ }
320
+ #l;
321
+ get _activeDate() {
322
+ return this.#l;
323
+ }
324
+ set _activeDate(e) {
325
+ this.#l = e;
326
+ }
327
+ #u;
328
+ get _calendarView() {
329
+ return this.#u;
330
+ }
331
+ set _calendarView(e) {
332
+ this.#u = e;
333
+ }
334
+ get _cells() {
335
+ return Array.from((this._calendarView === "day" ? Array.from(this.shadowRoot.querySelectorAll("slot")).flatMap((e) => e.assignedElements({ flatten: !0 })) : this.shadowRoot?.querySelectorAll(`sbb-calendar-${this._calendarView}`)) ?? []);
336
+ }
337
+ #d;
338
+ get _initialized() {
339
+ return this.#d;
340
+ }
341
+ set _initialized(e) {
342
+ this.#d = e;
343
+ }
344
+ constructor() {
345
+ super(), this.#e = (t(this, x), t(this, C, 1)), this.#t = (t(this, w), t(this, De, "day")), this.#n = (t(this, E), t(this, O, null)), this.#r = (t(this, k), t(this, j, null)), this.#i = (t(this, M), t(this, P, !1)), this.#a = (t(this, F), t(this, R, null)), this.#o = (t(this, z), t(this, V, null)), this.#s = (t(this, H), t(this, W, "horizontal")), this.#c = (t(this, G), t(this, q, !1)), this._dateAdapter = (t(this, J), ge().datetime?.dateAdapter ?? oe), this.#l = t(this, X, this._dateAdapter.today()), this.#u = (t(this, Z), t(this, Oe, "day")), this._weekdays = t(this, ke), this._weeks = [], this._firstVisibleDay = "", this._lastVisibleDay = "", this._monthNames = this._dateAdapter.getMonthNames("long"), this._enhancedVariant = !1, this._resetFocus = !1, this._containingFocus = !1, this._lastSelection = null, this.#d = t(this, je, !1), this._language = (t(this, $), new te(this).withHandler(() => {
346
+ this._monthNames = this._dateAdapter.getMonthNames("long"), this._createMonthRows();
347
+ })), this._sortDate = (e, t) => this._dateAdapter.compareDate(e, t), this._onSlotChange = () => {
348
+ this._enhancedVariant = Array.from(this.children).some((e) => e.localName === "sbb-calendar-day"), this.toggleState("enhanced", this._enhancedVariant), this._setTabIndex();
349
+ }, this._createMonthRows(), this._setWeekdays(), this.addEventListener("focusin", () => this._containingFocus = !0), this.addEventListener("focusout", () => this._containingFocus = !1);
350
+ let e = (e) => e.target.closest("sbb-calendar-day") ?? e.composedPath().find((e) => e.localName === "sbb-calendar-day") ?? null;
351
+ this.addEventListener("click", (t) => {
352
+ let n = e(t);
353
+ n && this._selectDate(n.value, t);
354
+ }), this.addEventListener("keydown", (t) => {
355
+ let n = e(t);
356
+ n && this._handleKeyboardEvent(t, n);
357
+ }), this.addEventListener("blur", () => this._lastSelection = null);
358
+ }
359
+ _dateFilter(e) {
360
+ return this.dateFilter?.(e) ?? !0;
361
+ }
362
+ resetPosition() {
363
+ this._resetCalendarView(), this._init();
364
+ }
365
+ connectedCallback() {
366
+ super.connectedCallback(), this.resetPosition(), this.shadowRoot?.addEventListener("slotchange", this._onSlotChange, { capture: !0 });
367
+ }
368
+ disconnectedCallback() {
369
+ super.disconnectedCallback(), this.shadowRoot?.removeEventListener("slotchange", this._onSlotChange, { capture: !0 });
370
+ }
371
+ formResetCallback() {}
372
+ formStateRestoreCallback(e, t) {
373
+ if (t === "autocomplete" || e == null) return;
374
+ let n = (e) => this._dateAdapter.getValidDateOrNull(this._dateAdapter.deserialize(e));
375
+ if (typeof e == "string") this.value = n(e);
376
+ else if (e instanceof FormData) {
377
+ if (this.multiple) {
378
+ this._readFormData(e).then((e) => this.value = e.map(n).filter((e) => e != null));
379
+ return;
380
+ }
381
+ let t = e.get(this.name);
382
+ t instanceof Blob ? t.text().then((e) => this.value = n(JSON.parse(e))) : this.value = n(t);
383
+ }
384
+ }
385
+ async _readFormData(e) {
386
+ return Promise.all(e.getAll(this.name).map(async (e) => e instanceof Blob ? JSON.parse(await e.text()) : e));
387
+ }
388
+ focus() {
389
+ this._resetFocus = !0, this._focusCell();
390
+ }
391
+ willUpdate(e) {
392
+ super.willUpdate(e), this._initialized && ((e.has("amount") || e.has("orientation")) && this.resetPosition(), e.has("view") && (this._setChosenYear(), this._chosenMonth = void 0, this._calendarView = this.view));
393
+ }
394
+ requestUpdate(e, t, n) {
395
+ super.requestUpdate(e, t, n), e === "_calendarView" && (this.internals.states.delete(`view-${t}`), this.internals.states.add(`view-${this._calendarView}`), this._containingFocus && (this._resetFocus = !0));
396
+ }
397
+ updated(e) {
398
+ super.updated(e), this._setTabIndex(), this._focusCell();
399
+ }
400
+ _onMultipleChanged(e) {
401
+ e && !Array.isArray(this._value) && (this._value = this._value ? [this._value] : []), !e && Array.isArray(this._value) && (this._value = this._value.length ? this._value[0] : null);
402
+ }
403
+ _init(e) {
404
+ if (r) return;
405
+ if (this.hydrationRequired) {
406
+ this.hydrationComplete.then(() => this._init());
407
+ return;
408
+ }
409
+ e && this._assignActiveDate(e);
410
+ let t = this.amount < 1 ? 1 : this.amount;
411
+ this._weeks = Array.from({ length: t }, (e, t) => this._createWeekRows(this._dateAdapter.addCalendarMonths(this._activeDate, t)));
412
+ let n = this._weeks[0][0][0].dateValue;
413
+ this._firstVisibleDay = this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(n), this._dateAdapter.getMonth(n), 1));
414
+ let i = this._weeks[t - 1][0][0].dateValue;
415
+ this._lastVisibleDay = this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(i), this._dateAdapter.getMonth(i), this._dateAdapter.getNumDaysInMonth(i))), this._years = this._createYearRows(), this._weekNumbers = this._weeks.map((e) => e.flat().sort((e, t) => e.value.localeCompare(t.value)).map((e) => e.weekValue).filter((e, t, n) => n.indexOf(e) === t)), this._initialized = !0;
416
+ }
417
+ _focusCell() {
418
+ this._resetFocus &&= (this._getFirstFocusable()?.focus(), !1);
419
+ }
420
+ _setWeekdays() {
421
+ let e = this._dateAdapter.getDayOfWeekNames("narrow"), t = this._dateAdapter.getDayOfWeekNames("long").map((t, n) => ({
422
+ long: t,
423
+ narrow: e[n]
424
+ })), n = this._dateAdapter.getFirstDayOfWeek();
425
+ this._weekdays = t.slice(n).concat(t.slice(0, n));
426
+ }
427
+ _createWeekRows(e) {
428
+ let t = this._dateAdapter.getNumDaysInMonth(e), n = this._dateAdapter.getFirstWeekOffset(e);
429
+ return this.orientation === "horizontal" ? this._createWeekRowsHorizontal(e, t, n) : this._createWeekRowsVertical(e, t, n);
430
+ }
431
+ _createWeekRowsHorizontal(e, t, n) {
432
+ let r = [[]];
433
+ for (let i = 0, a = n; i < t; i++, a++) {
434
+ a === m && (r.push([]), a = 0);
435
+ let t = this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), i + 1);
436
+ r[r.length - 1].push(this._mapDateToDay(t));
437
+ }
438
+ return r;
439
+ }
440
+ _createWeekRowsVertical(e, t, n) {
441
+ let r = Array.from({ length: m }, () => []);
442
+ for (let i = 0, a = n; i < t; i++, a++) {
443
+ a === m && (a = 0);
444
+ let t = this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), i + 1);
445
+ r[a].push(this._mapDateToDay(t));
446
+ }
447
+ return r;
448
+ }
449
+ _mapDateToDay(e) {
450
+ return {
451
+ value: this._dateAdapter.toIso8601(e),
452
+ dateValue: e,
453
+ dayValue: String(this._dateAdapter.getDate(e)),
454
+ monthValue: String(this._dateAdapter.getMonth(e)),
455
+ yearValue: String(this._dateAdapter.getYear(e)),
456
+ weekValue: this._getWeek(e),
457
+ weekDayValue: this._dateAdapter.getDayOfWeek(e)
458
+ };
459
+ }
460
+ _getWeek(e) {
461
+ let t = this._dateAdapter.createDate(this._dateAdapter.getYear(e), 1, 1), n = this._dateAdapter.getDayOfWeek(t), r = +!![
462
+ c,
463
+ re,
464
+ ie,
465
+ ne
466
+ ].includes(n), i = this._dateAdapter.addCalendarDays(t, this._dateAdapter.getFirstWeekOffset(t) * -1);
467
+ for (; this._dateAdapter.compareDate(i, e) <= 0;) {
468
+ let n = this._dateAdapter.addCalendarDays(i, 6);
469
+ if (this._dateAdapter.compareDate(e, n) <= 0) return r > 0 ? r : this._getWeek(this._dateAdapter.addCalendarDays(t, -1));
470
+ i = this._dateAdapter.addCalendarDays(i, m), r++;
471
+ }
472
+ throw Error("The provided date is invalid");
473
+ }
474
+ _mapValueToISODate(e) {
475
+ return typeof e == "string" ? e : this._dateAdapter.toIso8601(e);
476
+ }
477
+ _createMonthRows() {
478
+ let e = Array(12).fill(null).map((e, t) => ({
479
+ value: String(t + 1).padStart(2, "0"),
480
+ monthValue: t + 1
481
+ })), t = 12 / h, n = [];
482
+ for (let r = 0; r < t; r++) n.push(e.slice(h * r, h * (r + 1)));
483
+ this._months = n;
484
+ }
485
+ _createYearRows() {
486
+ let e = this._getStartValueYearView(), t = Array(_).fill(0).map((t, n) => e + n), n = _ / g, r = [];
487
+ for (let e = 0; e < n; e++) r.push(t.slice(g * e, g * (e + 1)));
488
+ return r;
489
+ }
490
+ _getStartValueYearView() {
491
+ let e = 0;
492
+ this.max ? e = this._dateAdapter.getYear(this.max) - _ + 1 : this.min && (e = this._dateAdapter.getYear(this.min));
493
+ let t = this._dateAdapter.getYear(this._activeDate);
494
+ return t - ((t - e) % _ + _) % _;
495
+ }
496
+ _isDayInRange(e) {
497
+ if (!this.min && !this.max) return !0;
498
+ let t = this._dateAdapter.deserialize(e);
499
+ return this._dateAdapter.sameDate(t, this._dateAdapter.clampDate(t, this.min, this.max));
500
+ }
501
+ _selectDate(e, t) {
502
+ if (this._chosenMonth = void 0, this._setChosenYear(), this.multiple) {
503
+ window.getSelection()?.removeAllRanges();
504
+ let n = this._value ? Array.isArray(this._value) ? this._value : [this._value] : [], r = n.map((e) => this._dateAdapter.toIso8601(e));
505
+ if (t.shiftKey && this._lastSelection && r.includes(this._dateAdapter.toIso8601(this._lastSelection)) && !r.includes(this._dateAdapter.toIso8601(e))) {
506
+ let t = this._dateAdapter.compareDate(this._lastSelection, e) < 0 ? 1 : -1, i = [], a = this._lastSelection;
507
+ for (; !this._dateAdapter.sameDate(a, e);) {
508
+ a = this._dateAdapter.addCalendarDays(a, t);
509
+ let e = this._dateAdapter.toIso8601(a);
510
+ r.includes(e) || i.push(e);
511
+ }
512
+ n = this._mergeDates(i, r);
513
+ } else n = n.some((t) => this._dateAdapter.sameDate(t, e)) ? n.filter((t) => !this._dateAdapter.sameDate(t, e)) : [...n, e].sort(this._sortDate);
514
+ this._lastSelection = e, this._value = n, this._emitDateSelectedEvent(this._value.map((e) => this._dateAdapter.deserialize(e)));
515
+ } else (!this._value || this._dateAdapter.compareDate(this._value, e) !== 0) && (this._value = e, this._emitDateSelectedEvent(this._dateAdapter.deserialize(e)));
516
+ }
517
+ _selectMultipleDates(e) {
518
+ this._value = this._mergeDates(e.map((e) => e.value)), this._emitDateSelectedEvent(this._value.map((e) => this._dateAdapter.deserialize(e)));
519
+ }
520
+ _mergeDates(e, t) {
521
+ t ??= this._value.map((e) => this._dateAdapter.toIso8601(e));
522
+ let n = this._cells.filter((e) => !e.disabled).map((e) => this._mapValueToISODate(e.value)), r = e.filter((e) => n.includes(e));
523
+ return t = r.every((e) => t.includes(e)) ? t.filter((e) => !r.includes(e)) : [...t, ...r].filter((e, t, n) => n.indexOf(e) === t), t.map((e) => this._dateAdapter.deserialize(e)).sort(this._sortDate);
524
+ }
525
+ _emitDateSelectedEvent(e) {
526
+ this.dispatchEvent(new y(e)), this.dispatchEvent(new InputEvent("input", {
527
+ bubbles: !0,
528
+ composed: !0
529
+ })), this.dispatchEvent(new Event("change", { bubbles: !0 }));
530
+ }
531
+ _emitMonthChange() {
532
+ let e = this._weeks.flat(2).sort((e, t) => e.value.localeCompare(t.value));
533
+ this.dispatchEvent(new v(e));
534
+ }
535
+ _setChosenYear() {
536
+ if (this.view === "month") {
537
+ let e;
538
+ e = this.multiple ? this.value.at(-1) : this.value, this._chosenYear = this._dateAdapter.getYear(e ?? this._dateAdapter.today());
539
+ } else this._chosenYear = void 0;
540
+ }
541
+ _assignActiveDate(e) {
542
+ this._activeDate = this._dateAdapter.clampDate(e, this.min, this.max);
543
+ }
544
+ _goToDifferentMonth(e) {
545
+ this._init(this._dateAdapter.addCalendarMonths(this._activeDate, e)), this._emitMonthChange();
546
+ }
547
+ _goToDifferentYear(e) {
548
+ this._chosenYear += e, this._activeDate = this._dateAdapter.createDate(this._chosenYear, this._dateAdapter.getMonth(this._activeDate), this._dateAdapter.getDate(this._activeDate)), this._init();
549
+ }
550
+ _goToDifferentYearRange(e) {
551
+ this._init(this._dateAdapter.addCalendarYears(this._activeDate, e));
552
+ }
553
+ _prevDisabled(e) {
554
+ return this.min ? this._dateAdapter.compareDate(e, this.min) < 0 : !1;
555
+ }
556
+ _nextDisabled(e) {
557
+ return this.max ? this._dateAdapter.compareDate(e, this.max) > 0 : !1;
558
+ }
559
+ _previousMonthDisabled() {
560
+ let e = this._dateAdapter.addCalendarDays(this._activeDate, this._dateAdapter.getDate(this._activeDate) * -1);
561
+ return this._prevDisabled(e);
562
+ }
563
+ _nextMonthDisabled() {
564
+ let e = this._dateAdapter.addCalendarMonths(this._activeDate, this.amount < 1 ? 1 : this.amount);
565
+ return e = this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), 1), this._nextDisabled(e);
566
+ }
567
+ _previousYearDisabled() {
568
+ let e = this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate) - 1, 12, 31);
569
+ return this._prevDisabled(e);
570
+ }
571
+ _nextYearDisabled() {
572
+ let e = this._dateAdapter.createDate(this._dateAdapter.getYear(this._activeDate) + (this.amount < 1 ? 1 : this.amount), 1, 1);
573
+ return this._nextDisabled(e);
574
+ }
575
+ _previousYearRangeDisabled() {
576
+ let e = this._dateAdapter.createDate(this._years[0][0] - 1, 12, 31);
577
+ return this._prevDisabled(e);
578
+ }
579
+ _nextYearRangeDisabled() {
580
+ let e = this._years.flat(2).at(-1), t = this._dateAdapter.createDate(e + 1, 1, 1);
581
+ return this._nextDisabled(t);
582
+ }
583
+ _handleTableBlur(e) {
584
+ e?.localName !== "sbb-calendar-day" && this._setTabIndex();
585
+ }
586
+ _setTabIndex() {
587
+ Array.from(this._cells.filter((e) => e.tabIndex === 0) ?? []).forEach((e) => e.tabIndex = -1);
588
+ let e = this._getFirstFocusable();
589
+ e && (e.tabIndex = 0);
590
+ }
591
+ _getFirstFocusable() {
592
+ if (this._calendarView === "day") {
593
+ let e = this._cells.find((e) => e.matches(":is(:state(selected),[state--selected])")) ?? this._cells.find((e) => e.matches(":is(:state(current),[state--current])"));
594
+ return e && !e.disabled ? e : this._getFirstFocusableDay();
595
+ } else {
596
+ let e = this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(selected),[state--selected])`) ?? this.shadowRoot?.querySelector(`sbb-calendar-${this._calendarView}:is(:state(current),[state--current])`);
597
+ return e && !e.disabled ? e : this.shadowRoot.querySelector(`sbb-calendar-${this._calendarView}:not([disabled])`);
598
+ }
599
+ }
600
+ _getFirstFocusableDay() {
601
+ let e = this._cells, t = e.filter((e) => !e.disabled);
602
+ if (!t || t.length === 0) return null;
603
+ {
604
+ let n = t.map((e) => this._dateAdapter.toIso8601(e.value)).sort()[0];
605
+ return e.find((e) => e.matches(`[slot="${n}"]`)) ?? null;
606
+ }
607
+ }
608
+ _handleKeyboardEvent(e, t) {
609
+ he(e) && e.preventDefault();
610
+ let n = t ?? e.target, r = this._cells, i = r.indexOf(n), a;
611
+ a = t ? this._navigateByKeyboardDayView(e, i, r, this._mapDateToDay(t.value)) : this._navigateByKeyboard(e, i, r);
612
+ let o = (this._enhancedVariant ? document : this.shadowRoot).activeElement;
613
+ a !== o && (a.tabIndex = 0, a.focus(), r.includes(o) && (o.tabIndex = -1));
614
+ }
615
+ _navigateByKeyboardDayView(e, t, n, r) {
616
+ let i = this.orientation === "horizontal" ? {
617
+ leftRight: 1,
618
+ upDown: m
619
+ } : {
620
+ leftRight: m,
621
+ upDown: 1
622
+ };
623
+ switch (e.key) {
624
+ case "ArrowUp": return this._findDayArrows(n, t, r.dateValue, -i.upDown);
625
+ case "ArrowDown": return this._findDayArrows(n, t, r.dateValue, i.upDown);
626
+ case "ArrowLeft": return this._findDayArrows(n, t, r.dateValue, -i.leftRight);
627
+ case "ArrowRight": return this._findDayArrows(n, t, r.dateValue, i.leftRight);
628
+ case "PageUp": if (this.orientation === "horizontal") {
629
+ let e = (+r.dayValue % m || m) - +r.dayValue;
630
+ return this._findDayPageUpDown(n, t, r, e, i.upDown);
631
+ } else {
632
+ let e = this._dateAdapter.getFirstWeekOffset(r.dateValue), a = (Math.ceil((+r.dayValue + e) / m) - 1) * m - e + 1 - r.dayValue;
633
+ return this._findDayPageUpDown(n, t, r, a, i.upDown);
634
+ }
635
+ case "PageDown": if (this.orientation === "horizontal") {
636
+ let e = +r.monthValue + 1 > 12 ? 1 : +r.monthValue + 1, a = +r.monthValue + 1 > 12 ? +r.yearValue + 1 : +r.yearValue, o = this._dateAdapter.createDate(a, e, 1), s = this._dateAdapter.getDate(this._dateAdapter.addCalendarDays(o, -1)), c = Math.trunc((s - +r.dayValue) / m) * m;
637
+ return this._findDayPageUpDown(n, t, r, c, -i.upDown);
638
+ } else {
639
+ let e = this._dateAdapter.getFirstWeekOffset(r.dateValue), a = Math.ceil((+r.dayValue + e) / m) * m - e - +r.dayValue;
640
+ return this._findDayPageUpDown(n, t, r, a, -i.upDown);
641
+ }
642
+ case "Home": return this._findDayFirst(n, t, r, 1);
643
+ case "End": {
644
+ let e = +r.monthValue + 1 > 12 ? 1 : +r.monthValue + 1, i = +r.monthValue + 1 > 12 ? +r.yearValue + 1 : +r.yearValue, a = this._dateAdapter.createDate(i, e, 1);
645
+ return this._findDayLast(n, t, a);
646
+ }
647
+ default: return n[t];
648
+ }
649
+ }
650
+ _isDayOutOfView(e) {
651
+ return e < this._firstVisibleDay || e > this._lastVisibleDay;
652
+ }
653
+ _findDayArrows(e, t, n, r) {
654
+ let i = this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n, r));
655
+ if (this._isDayOutOfView(i)) return e[t];
656
+ let a = e.find((e) => this._mapValueToISODate(e.value) === i);
657
+ return !a || a.disabled ? this._findDayArrows(e, t, this._dateAdapter.deserialize(i), r) : a;
658
+ }
659
+ _findDayPageUpDown(e, t, n, r, i) {
660
+ let a = this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n.dateValue, r));
661
+ if (this._isDayOutOfView(a)) return e[t];
662
+ let o = e.find((e) => this._mapValueToISODate(e.value) === a);
663
+ return !o || o.disabled ? this._findDayPageUpDown(e, t, n, r + i, i) : o;
664
+ }
665
+ _findDayFirst(e, t, n, r) {
666
+ let i = this._dateAdapter.toIso8601(this._dateAdapter.createDate(+n.yearValue, +n.monthValue, r));
667
+ if (this._isDayOutOfView(i)) return e[t];
668
+ let a = e.find((e) => this._mapValueToISODate(e.value) === i);
669
+ return !a || a.disabled ? this._findDayFirst(e, t, n, r + 1) : a;
670
+ }
671
+ _findDayLast(e, t, n) {
672
+ let r = this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(n, -1));
673
+ if (this._isDayOutOfView(r)) return e[t];
674
+ let i = e.find((e) => this._mapValueToISODate(e.value) === r);
675
+ return !i || i.disabled ? this._findDayLast(e, t, this._dateAdapter.deserialize(r)) : i;
676
+ }
677
+ _navigateByKeyboard(e, t, n) {
678
+ let { elementIndexForWideMode: r, offsetForWideMode: i, lastElementIndexForWideMode: a, verticalOffset: o } = this._calculateParametersForKeyboardNavigation(t, this._calendarView === "year");
679
+ switch (e.key) {
680
+ case "ArrowUp": return this._findNext(n, t, -o);
681
+ case "ArrowDown": return this._findNext(n, t, o);
682
+ case "ArrowLeft": return this._findNext(n, t, -1);
683
+ case "ArrowRight": return this._findNext(n, t, 1);
684
+ case "Home": return this._findFirst(n, i);
685
+ case "PageUp": return this._findFirstOnColumn(n, r, i, o);
686
+ case "PageDown": return this._findLastOnColumn(n, t, a, o);
687
+ case "End": return this._findLast(n, a - 1);
688
+ default: return n[t];
689
+ }
690
+ }
691
+ _calculateParametersForKeyboardNavigation(e, t) {
692
+ let n = t ? _ : Ee, r = Math.trunc(e / n) * n, i = r === 0 ? e : e - n;
693
+ return {
694
+ verticalOffset: t ? g : h,
695
+ elementIndexForWideMode: i,
696
+ offsetForWideMode: e - i,
697
+ lastElementIndexForWideMode: r === 0 ? n : n * 2
698
+ };
699
+ }
700
+ _findNext(e, t, n) {
701
+ let r = t + n;
702
+ for (; r < e.length && e[r]?.disabled;) r += n;
703
+ return e[r] ?? e[t];
704
+ }
705
+ _findFirst(e, t) {
706
+ return e[t].disabled ? this._findNext(e, t, 1) : e[t];
707
+ }
708
+ _findLast(e, t) {
709
+ return e[t].disabled ? this._findNext(e, t, -1) : e[t];
710
+ }
711
+ _findFirstOnColumn(e, t, n, r) {
712
+ let i = t % r + n;
713
+ return e[i].disabled ? this._findNext(e, i, r) : e[i];
714
+ }
715
+ _findLastOnColumn(e, t, n, r) {
716
+ let i = t + Math.trunc((n - t - 1) / r) * r;
717
+ return e[i].disabled ? this._findNext(e, i, -r) : e[i];
718
+ }
719
+ _resetCalendarViewAndEmitMonthChange() {
720
+ this._resetCalendarView(), this._emitMonthChange();
721
+ }
722
+ _resetCalendarView() {
723
+ this._containingFocus && (this._resetFocus = !0), this._activeDate = (this.multiple ? this._value.at(-1) : this._value) ?? this._dateAdapter.today(), this._setChosenYear(), this._chosenMonth = void 0, this._init(), this._calendarView = this.view;
724
+ }
725
+ _createDayTable(e, t, r) {
726
+ let a = e[0][0].dateValue, o = `${this._monthNames[this._dateAdapter.getMonth(a) - 1]} ${this._dateAdapter.getYear(a)}`, s = e.flat(), c = e.flat();
727
+ return n`
728
+ <div class="sbb-calendar__table-wrapper sbb-calendar__day-view">
729
+ <div class="sbb-calendar__table-header">
730
+ <span>${o}</span> ${r ? this._createDayTableControls(o) : i}
731
+ </div>
732
+ <table
733
+ class="sbb-calendar__table"
734
+ @focusout=${(e) => this._handleTableBlur(e.relatedTarget)}
735
+ >
736
+ <thead>
737
+ <tr>
738
+ ${this.weekNumbers ? n`<th class="sbb-calendar__table-header-cell"></th>` : i}
739
+ ${this._weekdays.map((e, t) => n`
740
+ <th class="sbb-calendar__table-header-cell">
741
+ ${this.multiple ? n`
742
+ <sbb-calendar-weekday
743
+ .value=${e}
744
+ @click=${() => {
745
+ let e = c.filter((e) => e.weekDayValue === (t + 1) % 7);
746
+ this._selectMultipleDates(e);
747
+ }}
748
+ ></sbb-calendar-weekday>
749
+ ` : n`
750
+ <span class="sbb-screen-reader-only">${e.long}</span>
751
+ <span aria-hidden="true">${e.narrow}</span>
752
+ `}
753
+ </th>
754
+ `)}
755
+ </tr>
756
+ </thead>
757
+ <tbody>
758
+ ${e.map((e, r) => {
759
+ let a = m - e.length;
760
+ return r === 0 && a ? n`
761
+ <tr>
762
+ ${this.weekNumbers ? n`
763
+ <td class="sbb-calendar__table-header-cell-vertical">
764
+ ${this.multiple ? n`
765
+ <sbb-calendar-weeknumber
766
+ .value=${t[0]}
767
+ @click=${() => {
768
+ let e = s.filter((e) => e.weekValue === t[0]);
769
+ this._selectMultipleDates(e);
770
+ }}
771
+ ></sbb-calendar-weeknumber>
772
+ ` : n`
773
+ <span class="sbb-screen-reader-only"
774
+ >${`${f[this._language.current]} ${t[0]}`}</span
775
+ >
776
+ <span aria-hidden="true">${t[0]}</span>
777
+ `}
778
+ </td>
779
+ ` : i}
780
+ ${[...Array(a).keys()].map(() => n`<td class="sbb-calendar__table-data"></td>`)}
781
+ ${this._createDayCells(e)}
782
+ </tr>
783
+ ` : n`
784
+ <tr>
785
+ ${this.weekNumbers ? n`
786
+ <td class="sbb-calendar__table-header-cell-vertical">
787
+ ${this.multiple ? n`
788
+ <sbb-calendar-weeknumber
789
+ .value=${t[r]}
790
+ @click=${() => {
791
+ let e = s.filter((e) => e.weekValue === t[r]);
792
+ this._selectMultipleDates(e);
793
+ }}
794
+ ></sbb-calendar-weeknumber>
795
+ ` : n`
796
+ <span class="sbb-screen-reader-only"
797
+ >${`${f[this._language.current]} ${t[r]}`}</span
798
+ >
799
+ <span aria-hidden="true">${t[r]}</span>
800
+ `}
801
+ </td>
802
+ ` : i}
803
+ ${this._createDayCells(e)}
804
+ </tr>
805
+ `;
806
+ })}
807
+ </tbody>
808
+ </table>
809
+ </div>
810
+ `;
811
+ }
812
+ _createDayTableVertical(e, t, r) {
813
+ let a = e[0][0].dateValue, o = `${this._monthNames[this._dateAdapter.getMonth(a) - 1]} ${this._dateAdapter.getYear(a)}`, s = e[0][0].dateValue, c = this._dateAdapter.getFirstWeekOffset(s ?? this._activeDate), l = e.flat();
814
+ return n`
815
+ <div class="sbb-calendar__table-wrapper sbb-calendar__day-view">
816
+ <div class="sbb-calendar__table-header">
817
+ <span>${o}</span> ${r ? this._createDayTableControls(o) : i}
818
+ </div>
819
+ <table
820
+ class="sbb-calendar__table"
821
+ @focusout=${(e) => this._handleTableBlur(e.relatedTarget)}
822
+ >
823
+ ${this.weekNumbers ? n`
824
+ <thead>
825
+ <tr>
826
+ <th class="sbb-calendar__table-data"></th>
827
+ ${t.map((e) => n`
828
+ <th class="sbb-calendar__table-header-cell">
829
+ ${this.multiple ? n`
830
+ <sbb-calendar-weeknumber
831
+ .value=${e}
832
+ @click=${() => {
833
+ let t = l.filter((t) => t.weekValue === e);
834
+ this._selectMultipleDates(t);
835
+ }}
836
+ ></sbb-calendar-weeknumber>
837
+ ` : n`
838
+ <span class="sbb-screen-reader-only"
839
+ >${`${f[this._language.current]} ${e}`}</span
840
+ >
841
+ <span aria-hidden="true">${e}</span>
842
+ `}
843
+ </th>
844
+ `)}
845
+ </tr>
846
+ </thead>
847
+ ` : i}
848
+ <tbody>
849
+ ${e.map((e, t) => {
850
+ let r = this._weekdays[t];
851
+ return n`
852
+ <tr>
853
+ <td class="sbb-calendar__table-header-cell-vertical">
854
+ ${this.multiple ? n`
855
+ <sbb-calendar-weekday
856
+ .value=${r}
857
+ @click=${() => this._selectMultipleDates(e)}
858
+ >
859
+ ${r.narrow}
860
+ </sbb-calendar-weekday>
861
+ ` : n`
862
+ <span class="sbb-screen-reader-only">${r.long}</span>
863
+ <span aria-hidden="true">${r.narrow}</span>
864
+ `}
865
+ </td>
866
+ ${t < c ? n`<td class="sbb-calendar__table-data"></td>` : i}
867
+ ${this._createDayCells(e)}
868
+ </tr>
869
+ `;
870
+ })}
871
+ </tbody>
872
+ </table>
873
+ </div>
874
+ `;
875
+ }
876
+ _createDayTableControls(e) {
877
+ return [
878
+ this._getArrow("left", () => this._goToDifferentMonth(-1), de[this._language.current], this._previousMonthDisabled()),
879
+ this._getArrow("right", () => this._goToDifferentMonth(1), ce[this._language.current], this._nextMonthDisabled()),
880
+ this._getArrow("up", () => {
881
+ this._resetFocus = !0, this._calendarView = "year";
882
+ }, `${me[this._language.current]} ${e}`)
883
+ ];
884
+ }
885
+ _createDayCells(e) {
886
+ return e.map((e) => n`
887
+ <td class="sbb-calendar__table-data sbb-calendar__day-cell">
888
+ <slot name=${e.value}>
889
+ <sbb-calendar-day slot=${e.value}></sbb-calendar-day>
890
+ </slot>
891
+ </td>
892
+ `);
893
+ }
894
+ _renderMonthView() {
895
+ return n`
896
+ <div class="sbb-calendar__table-wrapper sbb-calendar__month-view">
897
+ <div class="sbb-calendar__table-header">
898
+ <span>${this._chosenYear}</span>
899
+ ${this._getArrow("left", () => this._goToDifferentYear(-1), fe[this._language.current], this._previousYearDisabled())}
900
+ ${this._getArrow("right", () => this._goToDifferentYear(1), le[this._language.current], this._nextYearDisabled())}
901
+ ${this._getArrow("down", () => this._resetCalendarViewAndEmitMonthChange(), d[this._language.current])}
902
+ <span class="sbb-screen-reader-only" role="status">${this._chosenYear}</span>
903
+ </div>
904
+ <table class="sbb-calendar__table">
905
+ <tbody>
906
+ ${this._months.map((e) => n`
907
+ <tr>
908
+ ${e.map((e) => n`
909
+ <td class="sbb-calendar__table-data">
910
+ <sbb-calendar-month
911
+ .value="${this._chosenYear}-${e.value}"
912
+ @click=${() => this._onMonthSelection(e.monthValue, this._chosenYear)}
913
+ @keydown=${(e) => this._handleKeyboardEvent(e)}
914
+ >
915
+ </sbb-calendar-month>
916
+ </td>
917
+ `)}
918
+ </tr>
919
+ `)}
920
+ </tbody>
921
+ </table>
922
+ </div>
923
+ `;
924
+ }
925
+ _onMonthSelection(e, t) {
926
+ this._chosenMonth = e, this._calendarView = "day", this._init(this._dateAdapter.createDate(t, this._chosenMonth, this._dateAdapter.getDate(this._activeDate))), this._emitMonthChange();
927
+ }
928
+ _renderYearView() {
929
+ let e = this._years.flat(2)[0], t = this._years.at(-1).flat(), r = `${e} - ${t[t.length - 1]}`;
930
+ return n`
931
+ <div class="sbb-calendar__table-wrapper sbb-calendar__year-view">
932
+ <div class="sbb-calendar__table-header">
933
+ <span>${r}</span>
934
+ ${this._getArrow("left", () => this._goToDifferentYearRange(-24), pe(_)[this._language.current], this._previousYearRangeDisabled())}
935
+ ${this._getArrow("right", () => this._goToDifferentYearRange(_), ue(_)[this._language.current], this._nextYearRangeDisabled())}
936
+ ${this._getArrow("down", () => this._resetCalendarViewAndEmitMonthChange(), d[this._language.current])}
937
+ <span class="sbb-screen-reader-only" role="status">${r}</span>
938
+ </div>
939
+ <table class="sbb-calendar__table">
940
+ <tbody>
941
+ ${this._years.map((e) => n` <tr>
942
+ ${e.map((e) => n`
943
+ <td class="sbb-calendar__table-data">
944
+ <sbb-calendar-year
945
+ .value=${String(e)}
946
+ @keydown=${(e) => this._handleKeyboardEvent(e)}
947
+ @click=${() => this._onYearSelection(e)}
948
+ >
949
+ </sbb-calendar-year>
950
+ </td>
951
+ `)}
952
+ </tr>`)}
953
+ </tbody>
954
+ </table>
955
+ </div>
956
+ `;
957
+ }
958
+ _onYearSelection(e) {
959
+ this._chosenYear = e, this._calendarView = "month", this._assignActiveDate(this._dateAdapter.createDate(this._chosenYear, this._dateAdapter.getMonth(this._activeDate), this._dateAdapter.getDate(this._activeDate)));
960
+ }
961
+ _getArrow(e, t, r, i = !1) {
962
+ return n`<sbb-secondary-button
963
+ class="sbb-calendar__control"
964
+ size="s"
965
+ icon-name="chevron-small-${e}-small"
966
+ aria-label=${r}
967
+ @click=${t}
968
+ ?disabled=${i}
969
+ ></sbb-secondary-button>`;
970
+ }
971
+ _getView() {
972
+ switch (this._calendarView) {
973
+ case "year": return this._renderYearView();
974
+ case "month": return this._renderMonthView();
975
+ default: return i;
976
+ }
977
+ }
978
+ render() {
979
+ return r || this.hydrationRequired ? n`${i}` : n`<div class="sbb-calendar__wrapper">
980
+ ${this.orientation === "horizontal" ? this._weeks.map((e, t) => this._createDayTable(e, this._weekNumbers[t], t === 0)) : this._weeks.map((e, t) => this._createDayTableVertical(e, this._weekNumbers[t], t === 0))}
981
+ ${this._getView()}
982
+ </div>`;
983
+ }
984
+ };
985
+ })();
986
+ //#endregion
987
+ export { y as n, v as r, b as t };