@sbb-esta/lyne-elements-experimental 2.5.1 → 2.7.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/core/datetime/date-helper.js +191 -0
- package/core/datetime.d.ts +3 -0
- package/core/datetime.d.ts.map +1 -1
- package/core/datetime.js +3 -189
- package/core/timetable/access-leg-helper.js +94 -0
- package/core/timetable/timetable-helper.js +13 -0
- package/core/timetable/timetable-properties.js +1 -0
- package/core/timetable.d.ts +3 -0
- package/core/timetable.d.ts.map +1 -1
- package/core/timetable.js +6 -102
- package/custom-elements.json +602 -433
- package/development/core/datetime/date-helper.js +285 -0
- package/development/core/datetime.d.ts +3 -0
- package/development/core/datetime.d.ts.map +1 -1
- package/development/core/datetime.js +2 -281
- package/development/core/timetable/access-leg-helper.js +128 -0
- package/development/core/timetable/timetable-helper.js +21 -0
- package/development/core/timetable/timetable-properties.js +2 -0
- package/development/core/timetable.d.ts +3 -0
- package/development/core/timetable.d.ts.map +1 -1
- package/development/core/timetable.js +3 -139
- package/development/{differenceInMinutes-Cmyza6nm.js → differenceInMinutes-CHSyWiQs.js} +2 -2
- package/development/{format-BU7bjY-L.js → format-D0-yhzi4.js} +3 -3
- package/development/{isValid-DO_pHwcW.js → isValid-Bo4R7iA7.js} +2 -2
- package/development/journey-summary/journey-summary.js +297 -0
- package/development/journey-summary.d.ts +3 -0
- package/development/journey-summary.d.ts.map +1 -1
- package/development/journey-summary.js +2 -294
- package/development/pearl-chain/pearl-chain.js +649 -0
- package/development/pearl-chain-time/pearl-chain-time.js +315 -0
- package/development/pearl-chain-time.d.ts +3 -0
- package/development/pearl-chain-time.d.ts.map +1 -1
- package/development/pearl-chain-time.js +2 -312
- package/development/pearl-chain-vertical/pearl-chain-vertical.js +45 -0
- package/development/pearl-chain-vertical-item/pearl-chain-vertical-item.js +395 -0
- package/development/pearl-chain-vertical-item.d.ts +3 -0
- package/development/pearl-chain-vertical-item.d.ts.map +1 -1
- package/development/pearl-chain-vertical-item.js +2 -392
- package/development/pearl-chain-vertical.d.ts +3 -0
- package/development/pearl-chain-vertical.d.ts.map +1 -1
- package/development/pearl-chain-vertical.js +2 -42
- package/development/pearl-chain.d.ts +3 -0
- package/development/pearl-chain.d.ts.map +1 -1
- package/development/pearl-chain.js +2 -646
- package/development/timetable-duration/timetable-duration.js +119 -0
- package/development/timetable-duration.d.ts +3 -0
- package/development/timetable-duration.d.ts.map +1 -1
- package/development/timetable-duration.js +2 -116
- package/development/timetable-row/timetable-row.d.ts +1 -0
- package/development/timetable-row/timetable-row.d.ts.map +1 -1
- package/development/timetable-row/timetable-row.js +820 -0
- package/development/timetable-row.d.ts +3 -0
- package/development/timetable-row.d.ts.map +1 -1
- package/development/timetable-row.js +2 -788
- package/development/{toDate-B6IBgPYH.js → toDate-D_Vjps95.js} +5 -5
- package/{differenceInMinutes-BI2zjbtS.js → differenceInMinutes-BMqUZdhj.js} +1 -1
- package/{format-CUYwLzoN.js → format-Dg8rkk7h.js} +2 -2
- package/index.d.ts +7 -7
- package/index.js +7 -7
- package/{isValid-mroh13Xp.js → isValid-DJ69OMZJ.js} +6 -6
- package/journey-summary/journey-summary.js +190 -0
- package/journey-summary.d.ts +3 -0
- package/journey-summary.d.ts.map +1 -1
- package/journey-summary.js +2 -188
- package/package.json +3 -3
- package/pearl-chain/pearl-chain.js +177 -0
- package/pearl-chain-time/pearl-chain-time.js +153 -0
- package/pearl-chain-time.d.ts +3 -0
- package/pearl-chain-time.d.ts.map +1 -1
- package/pearl-chain-time.js +2 -151
- package/pearl-chain-vertical/pearl-chain-vertical.js +23 -0
- package/pearl-chain-vertical-item/pearl-chain-vertical-item.js +71 -0
- package/pearl-chain-vertical-item.d.ts +3 -0
- package/pearl-chain-vertical-item.d.ts.map +1 -1
- package/pearl-chain-vertical-item.js +2 -69
- package/pearl-chain-vertical.d.ts +3 -0
- package/pearl-chain-vertical.d.ts.map +1 -1
- package/pearl-chain-vertical.js +2 -21
- package/pearl-chain.d.ts +3 -0
- package/pearl-chain.d.ts.map +1 -1
- package/pearl-chain.js +2 -175
- package/timetable-duration/timetable-duration.js +55 -0
- package/timetable-duration.d.ts +3 -0
- package/timetable-duration.d.ts.map +1 -1
- package/timetable-duration.js +2 -53
- package/timetable-row/timetable-row.d.ts +1 -0
- package/timetable-row/timetable-row.d.ts.map +1 -1
- package/timetable-row/timetable-row.js +462 -0
- package/timetable-row.d.ts +3 -0
- package/timetable-row.d.ts.map +1 -1
- package/timetable-row.js +9 -439
- package/{toDate-DQg4ZFnf.js → toDate-BCXKL_wM.js} +4 -4
- package/development/pearl-chain/pearl-chain.sample-data.d.ts +0 -140
- package/development/pearl-chain/pearl-chain.sample-data.d.ts.map +0 -1
- package/development/timetable-duration/timetable-duration.sample-data.d.ts +0 -6
- package/development/timetable-duration/timetable-duration.sample-data.d.ts.map +0 -1
- package/development/timetable-row/timetable-row.sample-data.d.ts +0 -24
- package/development/timetable-row/timetable-row.sample-data.d.ts.map +0 -1
- package/pearl-chain/pearl-chain.sample-data.d.ts +0 -140
- package/pearl-chain/pearl-chain.sample-data.d.ts.map +0 -1
- package/timetable-duration/timetable-duration.sample-data.d.ts +0 -6
- package/timetable-duration/timetable-duration.sample-data.d.ts.map +0 -1
- package/timetable-row/timetable-row.sample-data.d.ts +0 -24
- package/timetable-row/timetable-row.sample-data.d.ts.map +0 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { i18nDurationDay as h, i18nDurationHour as T, i18nDurationMinute as p } from "@sbb-esta/lyne-elements/core/i18n.js";
|
|
2
|
+
import { t as d, c as N, b as m, m as w } from "../../toDate-BCXKL_wM.js";
|
|
3
|
+
import { n as I, d as y, i as U } from "../../isValid-DJ69OMZJ.js";
|
|
4
|
+
import { g as C, a as Y, d as F } from "../../differenceInMinutes-BMqUZdhj.js";
|
|
5
|
+
function x(t, e, n) {
|
|
6
|
+
const r = d(t, n == null ? void 0 : n.in);
|
|
7
|
+
return isNaN(e) ? N(t, NaN) : (e && r.setDate(r.getDate() + e), r);
|
|
8
|
+
}
|
|
9
|
+
function z(t, e, n) {
|
|
10
|
+
return N(t, +d(t) + e);
|
|
11
|
+
}
|
|
12
|
+
function H(t, e, n) {
|
|
13
|
+
return z(t, e * m);
|
|
14
|
+
}
|
|
15
|
+
function S(t, e, n) {
|
|
16
|
+
const [r, i] = I(
|
|
17
|
+
n == null ? void 0 : n.in,
|
|
18
|
+
t,
|
|
19
|
+
e
|
|
20
|
+
), s = M(r, i), u = Math.abs(
|
|
21
|
+
y(r, i)
|
|
22
|
+
);
|
|
23
|
+
r.setDate(r.getDate() - s * u);
|
|
24
|
+
const a = +(M(r, i) === -s), c = s * (u - a);
|
|
25
|
+
return c === 0 ? 0 : c;
|
|
26
|
+
}
|
|
27
|
+
function M(t, e) {
|
|
28
|
+
const n = t.getFullYear() - e.getFullYear() || t.getMonth() - e.getMonth() || t.getDate() - e.getDate() || t.getHours() - e.getHours() || t.getMinutes() - e.getMinutes() || t.getSeconds() - e.getSeconds() || t.getMilliseconds() - e.getMilliseconds();
|
|
29
|
+
return n < 0 ? -1 : n > 0 ? 1 : n;
|
|
30
|
+
}
|
|
31
|
+
function Z(t, e, n) {
|
|
32
|
+
const [r, i] = I(
|
|
33
|
+
n == null ? void 0 : n.in,
|
|
34
|
+
t,
|
|
35
|
+
e
|
|
36
|
+
), s = (+r - +i) / m;
|
|
37
|
+
return C(n == null ? void 0 : n.roundingMethod)(s);
|
|
38
|
+
}
|
|
39
|
+
function v(t, e, n) {
|
|
40
|
+
return x(t, -e, n);
|
|
41
|
+
}
|
|
42
|
+
function O(t, e) {
|
|
43
|
+
const n = () => N(e == null ? void 0 : e.in, NaN), i = k(t);
|
|
44
|
+
let s;
|
|
45
|
+
if (i.date) {
|
|
46
|
+
const o = W(i.date, 2);
|
|
47
|
+
s = j(o.restDateString, o.year);
|
|
48
|
+
}
|
|
49
|
+
if (!s || isNaN(+s)) return n();
|
|
50
|
+
const u = +s;
|
|
51
|
+
let a = 0, c;
|
|
52
|
+
if (i.time && (a = A(i.time), isNaN(a)))
|
|
53
|
+
return n();
|
|
54
|
+
if (i.timezone) {
|
|
55
|
+
if (c = E(i.timezone), isNaN(c)) return n();
|
|
56
|
+
} else {
|
|
57
|
+
const o = new Date(u + a), D = d(0, e == null ? void 0 : e.in);
|
|
58
|
+
return D.setFullYear(
|
|
59
|
+
o.getUTCFullYear(),
|
|
60
|
+
o.getUTCMonth(),
|
|
61
|
+
o.getUTCDate()
|
|
62
|
+
), D.setHours(
|
|
63
|
+
o.getUTCHours(),
|
|
64
|
+
o.getUTCMinutes(),
|
|
65
|
+
o.getUTCSeconds(),
|
|
66
|
+
o.getUTCMilliseconds()
|
|
67
|
+
), D;
|
|
68
|
+
}
|
|
69
|
+
return d(u + a + c, e == null ? void 0 : e.in);
|
|
70
|
+
}
|
|
71
|
+
const l = {
|
|
72
|
+
dateTimeDelimiter: /[T ]/,
|
|
73
|
+
timeZoneDelimiter: /[Z ]/i,
|
|
74
|
+
timezone: /([Z+-].*)$/
|
|
75
|
+
}, _ = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, b = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, R = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
76
|
+
function k(t) {
|
|
77
|
+
const e = {}, n = t.split(l.dateTimeDelimiter);
|
|
78
|
+
let r;
|
|
79
|
+
if (n.length > 2)
|
|
80
|
+
return e;
|
|
81
|
+
if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], l.timeZoneDelimiter.test(e.date) && (e.date = t.split(l.timeZoneDelimiter)[0], r = t.substr(
|
|
82
|
+
e.date.length,
|
|
83
|
+
t.length
|
|
84
|
+
))), r) {
|
|
85
|
+
const i = l.timezone.exec(r);
|
|
86
|
+
i ? (e.time = r.replace(i[1], ""), e.timezone = i[1]) : e.time = r;
|
|
87
|
+
}
|
|
88
|
+
return e;
|
|
89
|
+
}
|
|
90
|
+
function W(t, e) {
|
|
91
|
+
const n = new RegExp(
|
|
92
|
+
"^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
|
|
93
|
+
), r = t.match(n);
|
|
94
|
+
if (!r) return { year: NaN, restDateString: "" };
|
|
95
|
+
const i = r[1] ? parseInt(r[1]) : null, s = r[2] ? parseInt(r[2]) : null;
|
|
96
|
+
return {
|
|
97
|
+
year: s === null ? i : s * 100,
|
|
98
|
+
restDateString: t.slice((r[1] || r[2]).length)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function j(t, e) {
|
|
102
|
+
if (e === null) return /* @__PURE__ */ new Date(NaN);
|
|
103
|
+
const n = t.match(_);
|
|
104
|
+
if (!n) return /* @__PURE__ */ new Date(NaN);
|
|
105
|
+
const r = !!n[4], i = f(n[1]), s = f(n[2]) - 1, u = f(n[3]), a = f(n[4]), c = f(n[5]) - 1;
|
|
106
|
+
if (r)
|
|
107
|
+
return G(e, a, c) ? J(e, a, c) : /* @__PURE__ */ new Date(NaN);
|
|
108
|
+
{
|
|
109
|
+
const o = /* @__PURE__ */ new Date(0);
|
|
110
|
+
return !q(e, s, u) || !B(e, i) ? /* @__PURE__ */ new Date(NaN) : (o.setUTCFullYear(e, s, Math.max(i, u)), o);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function f(t) {
|
|
114
|
+
return t ? parseInt(t) : 1;
|
|
115
|
+
}
|
|
116
|
+
function A(t) {
|
|
117
|
+
const e = t.match(b);
|
|
118
|
+
if (!e) return NaN;
|
|
119
|
+
const n = g(e[1]), r = g(e[2]), i = g(e[3]);
|
|
120
|
+
return K(n, r, i) ? n * m + r * w + i * 1e3 : NaN;
|
|
121
|
+
}
|
|
122
|
+
function g(t) {
|
|
123
|
+
return t && parseFloat(t.replace(",", ".")) || 0;
|
|
124
|
+
}
|
|
125
|
+
function E(t) {
|
|
126
|
+
if (t === "Z") return 0;
|
|
127
|
+
const e = t.match(R);
|
|
128
|
+
if (!e) return 0;
|
|
129
|
+
const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), i = e[3] && parseInt(e[3]) || 0;
|
|
130
|
+
return P(r, i) ? n * (r * m + i * w) : NaN;
|
|
131
|
+
}
|
|
132
|
+
function J(t, e, n) {
|
|
133
|
+
const r = /* @__PURE__ */ new Date(0);
|
|
134
|
+
r.setUTCFullYear(t, 0, 4);
|
|
135
|
+
const i = r.getUTCDay() || 7, s = (e - 1) * 7 + n + 1 - i;
|
|
136
|
+
return r.setUTCDate(r.getUTCDate() + s), r;
|
|
137
|
+
}
|
|
138
|
+
const V = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
139
|
+
function $(t) {
|
|
140
|
+
return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
|
|
141
|
+
}
|
|
142
|
+
function q(t, e, n) {
|
|
143
|
+
return e >= 0 && e <= 11 && n >= 1 && n <= (V[e] || ($(t) ? 29 : 28));
|
|
144
|
+
}
|
|
145
|
+
function B(t, e) {
|
|
146
|
+
return e >= 1 && e <= ($(t) ? 366 : 365);
|
|
147
|
+
}
|
|
148
|
+
function G(t, e, n) {
|
|
149
|
+
return e >= 1 && e <= 53 && n >= 0 && n <= 6;
|
|
150
|
+
}
|
|
151
|
+
function K(t, e, n) {
|
|
152
|
+
return t === 24 ? e === 0 && n === 0 : n >= 0 && n < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
|
|
153
|
+
}
|
|
154
|
+
function P(t, e) {
|
|
155
|
+
return e >= 0 && e <= 59;
|
|
156
|
+
}
|
|
157
|
+
function Q(t, e, n) {
|
|
158
|
+
return H(t, -e);
|
|
159
|
+
}
|
|
160
|
+
function ne(t) {
|
|
161
|
+
if (!t)
|
|
162
|
+
return;
|
|
163
|
+
const e = O(t);
|
|
164
|
+
if (U(e)) {
|
|
165
|
+
if (t.includes("Z"))
|
|
166
|
+
return new Date(t.replace("Z", ""));
|
|
167
|
+
if (t.includes("T")) {
|
|
168
|
+
const n = t.split("T");
|
|
169
|
+
if (n[1] && (n[1].includes("+") || n[1].includes("-")))
|
|
170
|
+
return /* @__PURE__ */ new Date(`${n[0]}T${n[1].split(/[+-]/)[0]}`);
|
|
171
|
+
}
|
|
172
|
+
return new Date(t);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
const re = (t, e) => {
|
|
176
|
+
const n = [], r = [];
|
|
177
|
+
let s = Y(0, t);
|
|
178
|
+
const u = S(s, 0);
|
|
179
|
+
u > 0 && (n.push(`${u} d`), e && r.push(`${u} ${u > 1 ? h.multiple.long[e] : h.single.long[e]}`), s = v(s, u));
|
|
180
|
+
const a = Z(s, 0);
|
|
181
|
+
a > 0 && (n.push(`${a} h`), e && r.push(`${a} ${a > 1 ? T.multiple.long[e] : T.single.long[e]}`), s = Q(s, a));
|
|
182
|
+
const c = F(s, 0);
|
|
183
|
+
return c > 0 && (n.push(`${c} min`), e && r.push(`${c} ${c > 1 ? p.multiple.long[e] : p.single.long[e]}`)), {
|
|
184
|
+
short: n.join(" "),
|
|
185
|
+
long: r.join(" ")
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
export {
|
|
189
|
+
re as durationToTime,
|
|
190
|
+
ne as removeTimezoneFromISOTimeString
|
|
191
|
+
};
|
package/core/datetime.d.ts
CHANGED
package/core/datetime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../src/elements-experimental/core/datetime.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"datetime.d.ts","sourceRoot":"","sources":["../../../src/elements-experimental/core/datetime.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,2BAA2B,CAAC"}
|
package/core/datetime.js
CHANGED
|
@@ -1,191 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as d, c as N, a as m, b as w } from "../toDate-DQg4ZFnf.js";
|
|
3
|
-
import { n as I, d as y, i as U } from "../isValid-mroh13Xp.js";
|
|
4
|
-
import { g as C, a as Y, d as F } from "../differenceInMinutes-BI2zjbtS.js";
|
|
5
|
-
function x(t, e, n) {
|
|
6
|
-
const r = d(t, n == null ? void 0 : n.in);
|
|
7
|
-
return isNaN(e) ? N(t, NaN) : (e && r.setDate(r.getDate() + e), r);
|
|
8
|
-
}
|
|
9
|
-
function z(t, e, n) {
|
|
10
|
-
return N(t, +d(t) + e);
|
|
11
|
-
}
|
|
12
|
-
function H(t, e, n) {
|
|
13
|
-
return z(t, e * m);
|
|
14
|
-
}
|
|
15
|
-
function S(t, e, n) {
|
|
16
|
-
const [r, i] = I(
|
|
17
|
-
n == null ? void 0 : n.in,
|
|
18
|
-
t,
|
|
19
|
-
e
|
|
20
|
-
), s = M(r, i), u = Math.abs(
|
|
21
|
-
y(r, i)
|
|
22
|
-
);
|
|
23
|
-
r.setDate(r.getDate() - s * u);
|
|
24
|
-
const a = +(M(r, i) === -s), c = s * (u - a);
|
|
25
|
-
return c === 0 ? 0 : c;
|
|
26
|
-
}
|
|
27
|
-
function M(t, e) {
|
|
28
|
-
const n = t.getFullYear() - e.getFullYear() || t.getMonth() - e.getMonth() || t.getDate() - e.getDate() || t.getHours() - e.getHours() || t.getMinutes() - e.getMinutes() || t.getSeconds() - e.getSeconds() || t.getMilliseconds() - e.getMilliseconds();
|
|
29
|
-
return n < 0 ? -1 : n > 0 ? 1 : n;
|
|
30
|
-
}
|
|
31
|
-
function Z(t, e, n) {
|
|
32
|
-
const [r, i] = I(
|
|
33
|
-
n == null ? void 0 : n.in,
|
|
34
|
-
t,
|
|
35
|
-
e
|
|
36
|
-
), s = (+r - +i) / m;
|
|
37
|
-
return C(n == null ? void 0 : n.roundingMethod)(s);
|
|
38
|
-
}
|
|
39
|
-
function v(t, e, n) {
|
|
40
|
-
return x(t, -e, n);
|
|
41
|
-
}
|
|
42
|
-
function O(t, e) {
|
|
43
|
-
const n = () => N(e == null ? void 0 : e.in, NaN), i = k(t);
|
|
44
|
-
let s;
|
|
45
|
-
if (i.date) {
|
|
46
|
-
const o = W(i.date, 2);
|
|
47
|
-
s = j(o.restDateString, o.year);
|
|
48
|
-
}
|
|
49
|
-
if (!s || isNaN(+s)) return n();
|
|
50
|
-
const u = +s;
|
|
51
|
-
let a = 0, c;
|
|
52
|
-
if (i.time && (a = A(i.time), isNaN(a)))
|
|
53
|
-
return n();
|
|
54
|
-
if (i.timezone) {
|
|
55
|
-
if (c = E(i.timezone), isNaN(c)) return n();
|
|
56
|
-
} else {
|
|
57
|
-
const o = new Date(u + a), D = d(0, e == null ? void 0 : e.in);
|
|
58
|
-
return D.setFullYear(
|
|
59
|
-
o.getUTCFullYear(),
|
|
60
|
-
o.getUTCMonth(),
|
|
61
|
-
o.getUTCDate()
|
|
62
|
-
), D.setHours(
|
|
63
|
-
o.getUTCHours(),
|
|
64
|
-
o.getUTCMinutes(),
|
|
65
|
-
o.getUTCSeconds(),
|
|
66
|
-
o.getUTCMilliseconds()
|
|
67
|
-
), D;
|
|
68
|
-
}
|
|
69
|
-
return d(u + a + c, e == null ? void 0 : e.in);
|
|
70
|
-
}
|
|
71
|
-
const l = {
|
|
72
|
-
dateTimeDelimiter: /[T ]/,
|
|
73
|
-
timeZoneDelimiter: /[Z ]/i,
|
|
74
|
-
timezone: /([Z+-].*)$/
|
|
75
|
-
}, _ = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, b = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, R = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
76
|
-
function k(t) {
|
|
77
|
-
const e = {}, n = t.split(l.dateTimeDelimiter);
|
|
78
|
-
let r;
|
|
79
|
-
if (n.length > 2)
|
|
80
|
-
return e;
|
|
81
|
-
if (/:/.test(n[0]) ? r = n[0] : (e.date = n[0], r = n[1], l.timeZoneDelimiter.test(e.date) && (e.date = t.split(l.timeZoneDelimiter)[0], r = t.substr(
|
|
82
|
-
e.date.length,
|
|
83
|
-
t.length
|
|
84
|
-
))), r) {
|
|
85
|
-
const i = l.timezone.exec(r);
|
|
86
|
-
i ? (e.time = r.replace(i[1], ""), e.timezone = i[1]) : e.time = r;
|
|
87
|
-
}
|
|
88
|
-
return e;
|
|
89
|
-
}
|
|
90
|
-
function W(t, e) {
|
|
91
|
-
const n = new RegExp(
|
|
92
|
-
"^(?:(\\d{4}|[+-]\\d{" + (4 + e) + "})|(\\d{2}|[+-]\\d{" + (2 + e) + "})$)"
|
|
93
|
-
), r = t.match(n);
|
|
94
|
-
if (!r) return { year: NaN, restDateString: "" };
|
|
95
|
-
const i = r[1] ? parseInt(r[1]) : null, s = r[2] ? parseInt(r[2]) : null;
|
|
96
|
-
return {
|
|
97
|
-
year: s === null ? i : s * 100,
|
|
98
|
-
restDateString: t.slice((r[1] || r[2]).length)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function j(t, e) {
|
|
102
|
-
if (e === null) return /* @__PURE__ */ new Date(NaN);
|
|
103
|
-
const n = t.match(_);
|
|
104
|
-
if (!n) return /* @__PURE__ */ new Date(NaN);
|
|
105
|
-
const r = !!n[4], i = f(n[1]), s = f(n[2]) - 1, u = f(n[3]), a = f(n[4]), c = f(n[5]) - 1;
|
|
106
|
-
if (r)
|
|
107
|
-
return G(e, a, c) ? J(e, a, c) : /* @__PURE__ */ new Date(NaN);
|
|
108
|
-
{
|
|
109
|
-
const o = /* @__PURE__ */ new Date(0);
|
|
110
|
-
return !q(e, s, u) || !B(e, i) ? /* @__PURE__ */ new Date(NaN) : (o.setUTCFullYear(e, s, Math.max(i, u)), o);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function f(t) {
|
|
114
|
-
return t ? parseInt(t) : 1;
|
|
115
|
-
}
|
|
116
|
-
function A(t) {
|
|
117
|
-
const e = t.match(b);
|
|
118
|
-
if (!e) return NaN;
|
|
119
|
-
const n = g(e[1]), r = g(e[2]), i = g(e[3]);
|
|
120
|
-
return K(n, r, i) ? n * m + r * w + i * 1e3 : NaN;
|
|
121
|
-
}
|
|
122
|
-
function g(t) {
|
|
123
|
-
return t && parseFloat(t.replace(",", ".")) || 0;
|
|
124
|
-
}
|
|
125
|
-
function E(t) {
|
|
126
|
-
if (t === "Z") return 0;
|
|
127
|
-
const e = t.match(R);
|
|
128
|
-
if (!e) return 0;
|
|
129
|
-
const n = e[1] === "+" ? -1 : 1, r = parseInt(e[2]), i = e[3] && parseInt(e[3]) || 0;
|
|
130
|
-
return P(r, i) ? n * (r * m + i * w) : NaN;
|
|
131
|
-
}
|
|
132
|
-
function J(t, e, n) {
|
|
133
|
-
const r = /* @__PURE__ */ new Date(0);
|
|
134
|
-
r.setUTCFullYear(t, 0, 4);
|
|
135
|
-
const i = r.getUTCDay() || 7, s = (e - 1) * 7 + n + 1 - i;
|
|
136
|
-
return r.setUTCDate(r.getUTCDate() + s), r;
|
|
137
|
-
}
|
|
138
|
-
const V = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
139
|
-
function $(t) {
|
|
140
|
-
return t % 400 === 0 || t % 4 === 0 && t % 100 !== 0;
|
|
141
|
-
}
|
|
142
|
-
function q(t, e, n) {
|
|
143
|
-
return e >= 0 && e <= 11 && n >= 1 && n <= (V[e] || ($(t) ? 29 : 28));
|
|
144
|
-
}
|
|
145
|
-
function B(t, e) {
|
|
146
|
-
return e >= 1 && e <= ($(t) ? 366 : 365);
|
|
147
|
-
}
|
|
148
|
-
function G(t, e, n) {
|
|
149
|
-
return e >= 1 && e <= 53 && n >= 0 && n <= 6;
|
|
150
|
-
}
|
|
151
|
-
function K(t, e, n) {
|
|
152
|
-
return t === 24 ? e === 0 && n === 0 : n >= 0 && n < 60 && e >= 0 && e < 60 && t >= 0 && t < 25;
|
|
153
|
-
}
|
|
154
|
-
function P(t, e) {
|
|
155
|
-
return e >= 0 && e <= 59;
|
|
156
|
-
}
|
|
157
|
-
function Q(t, e, n) {
|
|
158
|
-
return H(t, -e);
|
|
159
|
-
}
|
|
160
|
-
function ne(t) {
|
|
161
|
-
if (!t)
|
|
162
|
-
return;
|
|
163
|
-
const e = O(t);
|
|
164
|
-
if (U(e)) {
|
|
165
|
-
if (t.includes("Z"))
|
|
166
|
-
return new Date(t.replace("Z", ""));
|
|
167
|
-
if (t.includes("T")) {
|
|
168
|
-
const n = t.split("T");
|
|
169
|
-
if (n[1] && (n[1].includes("+") || n[1].includes("-")))
|
|
170
|
-
return /* @__PURE__ */ new Date(`${n[0]}T${n[1].split(/[+-]/)[0]}`);
|
|
171
|
-
}
|
|
172
|
-
return new Date(t);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
const re = (t, e) => {
|
|
176
|
-
const n = [], r = [];
|
|
177
|
-
let s = Y(0, t);
|
|
178
|
-
const u = S(s, 0);
|
|
179
|
-
u > 0 && (n.push(`${u} d`), e && r.push(`${u} ${u > 1 ? h.multiple.long[e] : h.single.long[e]}`), s = v(s, u));
|
|
180
|
-
const a = Z(s, 0);
|
|
181
|
-
a > 0 && (n.push(`${a} h`), e && r.push(`${a} ${a > 1 ? T.multiple.long[e] : T.single.long[e]}`), s = Q(s, a));
|
|
182
|
-
const c = F(s, 0);
|
|
183
|
-
return c > 0 && (n.push(`${c} min`), e && r.push(`${c} ${c > 1 ? p.multiple.long[e] : p.single.long[e]}`)), {
|
|
184
|
-
short: n.join(" "),
|
|
185
|
-
long: r.join(" ")
|
|
186
|
-
};
|
|
187
|
-
};
|
|
1
|
+
import { durationToTime as m, removeTimezoneFromISOTimeString as r } from "./datetime/date-helper.js";
|
|
188
2
|
export {
|
|
189
|
-
|
|
190
|
-
|
|
3
|
+
m as durationToTime,
|
|
4
|
+
r as removeTimezoneFromISOTimeString
|
|
191
5
|
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { i18nWalkingDistanceDeparture as _, i18nWalkingDistanceArrival as A } from "@sbb-esta/lyne-elements/core/i18n.js";
|
|
2
|
+
import { nothing as b, html as f } from "lit";
|
|
3
|
+
import { isRideLeg as h, isConnectionLeg as w, extractTimeAndStringFromNoticeText as C } from "./timetable-helper.js";
|
|
4
|
+
import "@sbb-esta/lyne-elements/icon.js";
|
|
5
|
+
function T(t, a) {
|
|
6
|
+
var e, r;
|
|
7
|
+
const n = w(t) ? t : null, i = n ? (e = n == null ? void 0 : n.notices) == null ? void 0 : e.filter((c) => a.includes(c.name))[0] : null;
|
|
8
|
+
return i ? {
|
|
9
|
+
duration: (n == null ? void 0 : n.duration) || 0,
|
|
10
|
+
text: ((r = i == null ? void 0 : i.text) == null ? void 0 : r.template) || "",
|
|
11
|
+
icon: "walk-small"
|
|
12
|
+
} : null;
|
|
13
|
+
}
|
|
14
|
+
function R(t, a, n, i) {
|
|
15
|
+
var c, l, s;
|
|
16
|
+
const e = h(t) ? (l = (c = t == null ? void 0 : t.serviceJourney) == null ? void 0 : c.notices) == null ? void 0 : l.filter((u) => ["CI"].includes(u.name))[0] : null, r = e && C(e);
|
|
17
|
+
return e ? {
|
|
18
|
+
duration: ((r == null ? void 0 : r.duration) || 0) + (a || 0),
|
|
19
|
+
text: n ? _[i] : (r == null ? void 0 : r.text) || "",
|
|
20
|
+
icon: n ? "wheelchair-small" : `sa-${(s = e == null ? void 0 : e.name) == null ? void 0 : s.toLowerCase()}`
|
|
21
|
+
} : null;
|
|
22
|
+
}
|
|
23
|
+
function E(t, a, n, i) {
|
|
24
|
+
var c, l, s;
|
|
25
|
+
const e = h(t) ? (l = (c = t == null ? void 0 : t.serviceJourney) == null ? void 0 : c.notices) == null ? void 0 : l.filter((u) => ["CO"].includes(u.name))[0] : null, r = e && C(e);
|
|
26
|
+
return e ? {
|
|
27
|
+
duration: ((r == null ? void 0 : r.duration) || 0) + (a || 0),
|
|
28
|
+
text: n ? A[i] : (r == null ? void 0 : r.text) || "",
|
|
29
|
+
icon: n ? "wheelchair-small" : `sa-${(s = e == null ? void 0 : e.name) == null ? void 0 : s.toLowerCase()}`
|
|
30
|
+
} : null;
|
|
31
|
+
}
|
|
32
|
+
function v(t, a, n, i, e) {
|
|
33
|
+
return f`
|
|
34
|
+
<span class="sbb-pearl-chain__time-transfer sbb-pearl-chain__time-transfer--${a}-${e}">
|
|
35
|
+
<sbb-icon name=${a}></sbb-icon>
|
|
36
|
+
<time datetime=${t + "M"}>
|
|
37
|
+
<span class="sbb-screen-reader-only">
|
|
38
|
+
${!i && e ? e === "departure" ? _[n] : A[n] : b}
|
|
39
|
+
${i ? f`<span>${i}</span>` : b}
|
|
40
|
+
</span>
|
|
41
|
+
${t}
|
|
42
|
+
<span class="sbb-pearl-chain__time-walktime-prime-symbol" aria-hidden="true">'</span>
|
|
43
|
+
<span class="sbb-screen-reader-only">min</span>
|
|
44
|
+
</time>
|
|
45
|
+
</span>
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
function p(t, a, n, i) {
|
|
49
|
+
return f`
|
|
50
|
+
<span class="sbb-pearl-chain__time-walktime sbb-pearl-chain__time-walktime--${i}-${n}">
|
|
51
|
+
<sbb-icon name=${i}></sbb-icon>
|
|
52
|
+
<time datetime=${t + "M"}>
|
|
53
|
+
<span class="sbb-screen-reader-only">${a}</span>
|
|
54
|
+
${t}
|
|
55
|
+
<span class="sbb-pearl-chain__time-walktime-prime-symbol" aria-hidden="true">'</span>
|
|
56
|
+
</time>
|
|
57
|
+
</span>
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
function O(t, a, n, i, e) {
|
|
61
|
+
const r = t && t.filter((k) => h(k) || w(k))[0], c = ["YM", "YB", "Y", "YT"], l = T(r, c), s = R(r, a, e, i), u = a ? {
|
|
62
|
+
text: _[i],
|
|
63
|
+
duration: a,
|
|
64
|
+
icon: e ? "wheelchair-small" : "walk-small"
|
|
65
|
+
} : null, D = () => l || (u && !s && !l ? u : s || null);
|
|
66
|
+
function L() {
|
|
67
|
+
return f`
|
|
68
|
+
${l ? p(l.duration, l.text, "left", l.icon) : b}
|
|
69
|
+
${u && !s && !l ? p(u.duration, u.text, "left", u.icon) : b}
|
|
70
|
+
${s ? e ? p(s.duration, s.text, "left", s.icon) : v(s.duration, s.icon, i, s.text, "departure") : b}
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
const x = t && t[t.length - 1], $ = (w(x) || h(x)) && x, m = $ && T($, c), o = $ && E($, n, e, i), d = n ? {
|
|
74
|
+
text: A[i],
|
|
75
|
+
duration: n,
|
|
76
|
+
icon: e ? "wheelchair-small" : "walk-small"
|
|
77
|
+
} : null, Y = () => m || (d && !o && !m ? d : o || null);
|
|
78
|
+
function M() {
|
|
79
|
+
return f`
|
|
80
|
+
${m ? p(m.duration, m.text, "right", m.icon) : b}
|
|
81
|
+
${d && !o && !m ? p(d.duration, d.text, "right", d.icon) : b}
|
|
82
|
+
${o ? e ? p(o.duration, o.text, "right", o.icon) : v(o.duration, o.icon, i, o.text, "arrival") : b}
|
|
83
|
+
`;
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
renderDepartureTimeAttribute: L,
|
|
87
|
+
renderArrivalTimeAttribute: M,
|
|
88
|
+
departureTimeAttribute: D(),
|
|
89
|
+
arrivalTimeAttribute: Y()
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
O as getDepartureArrivalTimeAttribute
|
|
94
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const n = (t) => (t == null ? void 0 : t.__typename) === "PTRideLeg", u = (t) => (t == null ? void 0 : t.__typename) === "PTConnectionLeg", L = (t) => {
|
|
2
|
+
var e, s, x, a, m, p;
|
|
3
|
+
const d = ((e = t == null ? void 0 : t.text) == null ? void 0 : e.template) && t.text.template.indexOf("(") + 1, r = (a = (s = t == null ? void 0 : t.text) == null ? void 0 : s.template) == null ? void 0 : a.substring(d || 0, (x = t == null ? void 0 : t.text) == null ? void 0 : x.template.indexOf(")"));
|
|
4
|
+
return {
|
|
5
|
+
duration: r && +r.substring(0, r.length - 1) || 0,
|
|
6
|
+
text: ((p = (m = t == null ? void 0 : t.text) == null ? void 0 : m.template) == null ? void 0 : p.split("(")[0]) || ""
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
L as extractTimeAndStringFromNoticeText,
|
|
11
|
+
u as isConnectionLeg,
|
|
12
|
+
n as isRideLeg
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/core/timetable.d.ts
CHANGED
package/core/timetable.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timetable.d.ts","sourceRoot":"","sources":["../../../src/elements-experimental/core/timetable.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"timetable.d.ts","sourceRoot":"","sources":["../../../src/elements-experimental/core/timetable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,qCAAqC,CAAC"}
|
package/core/timetable.js
CHANGED
|
@@ -1,104 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "@sbb-esta/lyne-elements/icon.js";
|
|
4
|
-
const $ = (t) => (t == null ? void 0 : t.__typename) === "PTRideLeg", _ = (t) => (t == null ? void 0 : t.__typename) === "PTConnectionLeg", v = (t) => {
|
|
5
|
-
var r, e, i, u, a, s;
|
|
6
|
-
const l = ((r = t == null ? void 0 : t.text) == null ? void 0 : r.template) && t.text.template.indexOf("(") + 1, n = (u = (e = t == null ? void 0 : t.text) == null ? void 0 : e.template) == null ? void 0 : u.substring(l || 0, (i = t == null ? void 0 : t.text) == null ? void 0 : i.template.indexOf(")"));
|
|
7
|
-
return {
|
|
8
|
-
duration: n && +n.substring(0, n.length - 1) || 0,
|
|
9
|
-
text: ((s = (a = t == null ? void 0 : t.text) == null ? void 0 : a.template) == null ? void 0 : s.split("(")[0]) || ""
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
function k(t, l) {
|
|
13
|
-
var e, i;
|
|
14
|
-
const n = _(t) ? t : null, r = n ? (e = n == null ? void 0 : n.notices) == null ? void 0 : e.filter((u) => l.includes(u.name))[0] : null;
|
|
15
|
-
return r ? {
|
|
16
|
-
duration: (n == null ? void 0 : n.duration) || 0,
|
|
17
|
-
text: ((i = r == null ? void 0 : r.text) == null ? void 0 : i.template) || "",
|
|
18
|
-
icon: "walk-small"
|
|
19
|
-
} : null;
|
|
20
|
-
}
|
|
21
|
-
function M(t, l, n, r) {
|
|
22
|
-
var u, a, s;
|
|
23
|
-
const e = $(t) ? (a = (u = t == null ? void 0 : t.serviceJourney) == null ? void 0 : u.notices) == null ? void 0 : a.filter((m) => ["CI"].includes(m.name))[0] : null, i = e && v(e);
|
|
24
|
-
return e ? {
|
|
25
|
-
duration: ((i == null ? void 0 : i.duration) || 0) + (l || 0),
|
|
26
|
-
text: n ? w[r] : (i == null ? void 0 : i.text) || "",
|
|
27
|
-
icon: n ? "wheelchair-small" : `sa-${(s = e == null ? void 0 : e.name) == null ? void 0 : s.toLowerCase()}`
|
|
28
|
-
} : null;
|
|
29
|
-
}
|
|
30
|
-
function O(t, l, n, r) {
|
|
31
|
-
var u, a, s;
|
|
32
|
-
const e = $(t) ? (a = (u = t == null ? void 0 : t.serviceJourney) == null ? void 0 : u.notices) == null ? void 0 : a.filter((m) => ["CO"].includes(m.name))[0] : null, i = e && v(e);
|
|
33
|
-
return e ? {
|
|
34
|
-
duration: ((i == null ? void 0 : i.duration) || 0) + (l || 0),
|
|
35
|
-
text: n ? T[r] : (i == null ? void 0 : i.text) || "",
|
|
36
|
-
icon: n ? "wheelchair-small" : `sa-${(s = e == null ? void 0 : e.name) == null ? void 0 : s.toLowerCase()}`
|
|
37
|
-
} : null;
|
|
38
|
-
}
|
|
39
|
-
function C(t, l, n, r, e) {
|
|
40
|
-
return f`
|
|
41
|
-
<span class="sbb-pearl-chain__time-transfer sbb-pearl-chain__time-transfer--${l}-${e}">
|
|
42
|
-
<sbb-icon name=${l}></sbb-icon>
|
|
43
|
-
<time datetime=${t + "M"}>
|
|
44
|
-
<span class="sbb-screen-reader-only">
|
|
45
|
-
${!r && e ? e === "departure" ? w[n] : T[n] : b}
|
|
46
|
-
${r ? f`<span>${r}</span>` : b}
|
|
47
|
-
</span>
|
|
48
|
-
${t}
|
|
49
|
-
<span class="sbb-pearl-chain__time-walktime-prime-symbol" aria-hidden="true">'</span>
|
|
50
|
-
<span class="sbb-screen-reader-only">min</span>
|
|
51
|
-
</time>
|
|
52
|
-
</span>
|
|
53
|
-
`;
|
|
54
|
-
}
|
|
55
|
-
function p(t, l, n, r) {
|
|
56
|
-
return f`
|
|
57
|
-
<span class="sbb-pearl-chain__time-walktime sbb-pearl-chain__time-walktime--${r}-${n}">
|
|
58
|
-
<sbb-icon name=${r}></sbb-icon>
|
|
59
|
-
<time datetime=${t + "M"}>
|
|
60
|
-
<span class="sbb-screen-reader-only">${l}</span>
|
|
61
|
-
${t}
|
|
62
|
-
<span class="sbb-pearl-chain__time-walktime-prime-symbol" aria-hidden="true">'</span>
|
|
63
|
-
</time>
|
|
64
|
-
</span>
|
|
65
|
-
`;
|
|
66
|
-
}
|
|
67
|
-
function I(t, l, n, r, e) {
|
|
68
|
-
const i = t && t.filter((A) => $(A) || _(A))[0], u = ["YM", "YB", "Y", "YT"], a = k(i, u), s = M(i, l, e, r), m = l ? {
|
|
69
|
-
text: w[r],
|
|
70
|
-
duration: l,
|
|
71
|
-
icon: e ? "wheelchair-small" : "walk-small"
|
|
72
|
-
} : null, D = () => a || (m && !s && !a ? m : s || null);
|
|
73
|
-
function L() {
|
|
74
|
-
return f`
|
|
75
|
-
${a ? p(a.duration, a.text, "left", a.icon) : b}
|
|
76
|
-
${m && !s && !a ? p(m.duration, m.text, "left", m.icon) : b}
|
|
77
|
-
${s ? e ? p(s.duration, s.text, "left", s.icon) : C(s.duration, s.icon, r, s.text, "departure") : b}
|
|
78
|
-
`;
|
|
79
|
-
}
|
|
80
|
-
const h = t && t[t.length - 1], x = (_(h) || $(h)) && h, c = x && k(x, u), o = x && O(x, n, e, r), d = n ? {
|
|
81
|
-
text: T[r],
|
|
82
|
-
duration: n,
|
|
83
|
-
icon: e ? "wheelchair-small" : "walk-small"
|
|
84
|
-
} : null, R = () => c || (d && !o && !c ? d : o || null);
|
|
85
|
-
function Y() {
|
|
86
|
-
return f`
|
|
87
|
-
${c ? p(c.duration, c.text, "right", c.icon) : b}
|
|
88
|
-
${d && !o && !c ? p(d.duration, d.text, "right", d.icon) : b}
|
|
89
|
-
${o ? e ? p(o.duration, o.text, "right", o.icon) : C(o.duration, o.icon, r, o.text, "arrival") : b}
|
|
90
|
-
`;
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
renderDepartureTimeAttribute: L,
|
|
94
|
-
renderArrivalTimeAttribute: Y,
|
|
95
|
-
departureTimeAttribute: D(),
|
|
96
|
-
arrivalTimeAttribute: R()
|
|
97
|
-
};
|
|
98
|
-
}
|
|
1
|
+
import { getDepartureArrivalTimeAttribute as r } from "./timetable/access-leg-helper.js";
|
|
2
|
+
import { extractTimeAndStringFromNoticeText as o, isConnectionLeg as m, isRideLeg as n } from "./timetable/timetable-helper.js";
|
|
99
3
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
4
|
+
o as extractTimeAndStringFromNoticeText,
|
|
5
|
+
r as getDepartureArrivalTimeAttribute,
|
|
6
|
+
m as isConnectionLeg,
|
|
7
|
+
n as isRideLeg
|
|
104
8
|
};
|