@trycourier/courier-ui-inbox 1.0.0-beta

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.
@@ -0,0 +1,3410 @@
1
+ var Lo = Object.defineProperty;
2
+ var To = (g, i, e) => i in g ? Lo(g, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : g[i] = e;
3
+ var a = (g, i, e) => To(g, typeof i != "symbol" ? i + "" : i, e);
4
+ import { Courier as C } from "@trycourier/courier-js";
5
+ var Bo = Object.defineProperty, Ao = (g, i, e) => i in g ? Bo(g, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : g[i] = e, L = (g, i, e) => Ao(g, typeof i != "symbol" ? i + "" : i, e);
6
+ const r = {
7
+ black: {
8
+ 500: "#171717",
9
+ 50010: "#1717171A",
10
+ 50020: "#17171733"
11
+ },
12
+ gray: {
13
+ 200: "#F5F5F5",
14
+ 400: "#3A3A3A",
15
+ 500: "#E5E5E5",
16
+ 600: "#737373"
17
+ },
18
+ white: {
19
+ 500: "#FFFFFF",
20
+ 50010: "#FFFFFF1A",
21
+ 50020: "#FFFFFF33"
22
+ },
23
+ blue: {
24
+ 400: "#60A5FA",
25
+ 500: "#2563EB"
26
+ }
27
+ }, G = {
28
+ light: {
29
+ colors: {
30
+ primary: r.black[500],
31
+ secondary: r.white[500],
32
+ border: r.gray[500],
33
+ link: r.blue[500],
34
+ icon: r.black[500]
35
+ },
36
+ button: {
37
+ cornerRadius: "4px"
38
+ }
39
+ },
40
+ dark: {
41
+ colors: {
42
+ primary: r.white[500],
43
+ secondary: r.black[500],
44
+ border: r.gray[400],
45
+ link: r.blue[400],
46
+ icon: r.white[500]
47
+ },
48
+ button: {
49
+ cornerRadius: "4px"
50
+ }
51
+ }
52
+ }, go = () => typeof window > "u" ? "light" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light", mo = (g) => {
53
+ if (typeof window > "u")
54
+ return () => {
55
+ };
56
+ const i = window.matchMedia("(prefers-color-scheme: dark)"), e = (t) => {
57
+ g(t.matches ? "dark" : "light");
58
+ };
59
+ return i.addEventListener("change", e), () => {
60
+ i.removeEventListener("change", e);
61
+ };
62
+ };
63
+ class bo extends HTMLElement {
64
+ constructor() {
65
+ super(), L(this, "_currentSystemTheme"), L(this, "_systemThemeCleanup"), this._currentSystemTheme = go(), this._systemThemeCleanup = mo((i) => {
66
+ this._currentSystemTheme = i, this.onSystemThemeChange(i);
67
+ });
68
+ }
69
+ get currentSystemTheme() {
70
+ return this._currentSystemTheme;
71
+ }
72
+ disconnectedCallback() {
73
+ this._systemThemeCleanup && this._systemThemeCleanup();
74
+ }
75
+ onSystemThemeChange(i) {
76
+ }
77
+ }
78
+ const Te = {
79
+ borderRadius: "4px",
80
+ fontSize: "14px"
81
+ }, ee = {
82
+ primary: (g) => ({
83
+ ...Te,
84
+ backgroundColor: G[g].colors.primary,
85
+ textColor: G[g].colors.secondary,
86
+ fontWeight: "500",
87
+ shadow: "none"
88
+ }),
89
+ secondary: (g) => ({
90
+ ...Te,
91
+ backgroundColor: G[g].colors.secondary,
92
+ textColor: G[g].colors.primary,
93
+ fontWeight: "500",
94
+ border: `1px solid ${G[g].colors.border}`,
95
+ shadow: g === "light" ? "0px 1px 2px 0px rgba(0, 0, 0, 0.06)" : "0px 1px 2px 0px rgba(255, 255, 255, 0.1)"
96
+ }),
97
+ tertiary: (g) => ({
98
+ ...Te,
99
+ backgroundColor: G[g].colors.border,
100
+ textColor: G[g].colors.primary,
101
+ fontWeight: "500",
102
+ border: "none",
103
+ shadow: "none"
104
+ })
105
+ };
106
+ class Ie extends bo {
107
+ constructor(i) {
108
+ super(), L(this, "_button"), L(this, "_style");
109
+ const e = this.attachShadow({ mode: "open" });
110
+ this._button = document.createElement("button"), this._button.setAttribute("part", "button"), this._style = document.createElement("style"), this._style.textContent = this.getStyles(i), e.appendChild(this._style), e.appendChild(this._button), this.updateButton(i), this._button.addEventListener("click", (t) => {
111
+ t.preventDefault(), t.stopPropagation(), i.onClick && i.onClick();
112
+ });
113
+ }
114
+ getStyles(i) {
115
+ const e = () => ee.secondary(this.currentSystemTheme).textColor, t = () => ee.secondary(this.currentSystemTheme).backgroundColor, s = () => ee.secondary(this.currentSystemTheme).border, o = () => ee.secondary(this.currentSystemTheme).shadow, n = () => ee.secondary(this.currentSystemTheme).borderRadius, h = () => ee.secondary(this.currentSystemTheme).fontSize, d = () => ee.secondary(this.currentSystemTheme).fontWeight;
116
+ return `
117
+ :host {
118
+ display: inline-block;
119
+ }
120
+
121
+ button {
122
+ border: none;
123
+ border-radius: ${i.borderRadius ?? n()};
124
+ font-weight: ${i.fontWeight ?? d()};
125
+ font-family: ${i.fontFamily ?? "inherit"};
126
+ font-size: ${i.fontSize ?? h()};
127
+ padding: 6px 10px;
128
+ cursor: pointer;
129
+ width: 100%;
130
+ height: 100%;
131
+ background-color: ${i.backgroundColor ?? t()};
132
+ color: ${i.textColor ?? e()};
133
+ border: ${i.border ?? s()};
134
+ box-shadow: ${i.shadow ?? o()};
135
+ touch-action: manipulation;
136
+ }
137
+
138
+ button:hover {
139
+ ${i.hoverBackgroundColor ? `background-color: ${i.hoverBackgroundColor};` : "filter: brightness(0.9);"}
140
+ }
141
+
142
+ button:active {
143
+ ${i.activeBackgroundColor ? `background-color: ${i.activeBackgroundColor};` : "filter: brightness(0.8);"}
144
+ }
145
+
146
+ button:disabled {
147
+ opacity: 0.5;
148
+ cursor: not-allowed;
149
+ }
150
+ `;
151
+ }
152
+ updateButton(i) {
153
+ i.text && (this._button.textContent = i.text), this._style.textContent = this.getStyles(i);
154
+ }
155
+ }
156
+ customElements.get("courier-button") || customElements.define("courier-button", Ie);
157
+ const f = {
158
+ inbox: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
159
+ <path d="M5.5 14.5V17C5.5 17.2812 5.71875 17.5 6 17.5H18C18.25 17.5 18.5 17.2812 18.5 17V14.5H15.9375L15.2812 15.8125C15.0938 16.25 14.6562 16.5 14.1875 16.5H9.78125C9.3125 16.5 8.875 16.25 8.6875 15.8125L8.03125 14.5H5.5ZM18.1875 13L16.6562 6.90625C16.5938 6.65625 16.4062 6.5 16.1875 6.5H7.8125C7.5625 6.5 7.375 6.65625 7.3125 6.90625L5.78125 13H8.1875C8.65625 13 9.09375 13.2812 9.3125 13.7188L9.9375 15H14.0312L14.6875 13.7188C14.875 13.2812 15.3125 13 15.7812 13H18.1875ZM4 14.25C4 14.0938 4 13.9375 4.03125 13.7812L5.84375 6.53125C6.09375 5.625 6.875 5 7.8125 5H16.1875C17.0938 5 17.9062 5.625 18.125 6.53125L19.9375 13.7812C19.9688 13.9375 20 14.0938 20 14.25V17C20 18.125 19.0938 19 18 19H6C4.875 19 4 18.125 4 17V14.25Z" fill="currentColor"/>
160
+ </svg>`,
161
+ archive: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
162
+ <path d="M5.5 6.5V8H18.5V6.5H5.5ZM5 5H19C19.5312 5 20 5.46875 20 6V8.5C20 9.0625 19.5312 9.5 19 9.5H5C4.4375 9.5 4 9.0625 4 8.5V6C4 5.46875 4.4375 5 5 5ZM9 11.75C9 11.3438 9.3125 11 9.75 11H14.25C14.6562 11 15 11.3438 15 11.75C15 12.1875 14.6562 12.5 14.25 12.5H9.75C9.3125 12.5 9 12.1875 9 11.75ZM5 17V10.5H6.5V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V10.5H19V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17Z" fill="currentColor"/>
163
+ </svg>`,
164
+ check: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
165
+ <path d="M18.793 7.33203C19.0742 7.64453 19.0742 8.11328 18.793 8.39453L10.543 16.6445C10.2305 16.957 9.76172 16.957 9.48047 16.6445L5.23047 12.3945C4.91797 12.1133 4.91797 11.6445 5.23047 11.3633C5.51172 11.0508 5.98047 11.0508 6.26172 11.3633L9.98047 15.082L17.7305 7.33203C18.0117 7.05078 18.4805 7.05078 18.7617 7.33203H18.793Z" fill="currentColor"/>
166
+ </svg>`,
167
+ filter: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
168
+ <path d="M5 7C5 6.59375 5.3125 6.25 5.75 6.25H18.25C18.6562 6.25 19 6.59375 19 7C19 7.4375 18.6562 7.75 18.25 7.75H5.75C5.3125 7.75 5 7.4375 5 7ZM7 12C7 11.5938 7.3125 11.25 7.75 11.25H16.25C16.6562 11.25 17 11.5938 17 12C17 12.4375 16.6562 12.75 16.25 12.75H7.75C7.3125 12.75 7 12.4375 7 12ZM14 17C14 17.4375 13.6562 17.75 13.25 17.75H10.75C10.3125 17.75 10 17.4375 10 17C10 16.5938 10.3125 16.25 10.75 16.25H13.25C13.6562 16.25 14 16.5938 14 17Z" fill="currentColor"/>
169
+ </svg>`,
170
+ overflow: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
171
+ <path d="M18.5117 11.9883C18.5117 12.5508 18.1992 13.0195 17.7617 13.3008C17.293 13.582 16.6992 13.582 16.2617 13.3008C15.793 13.0195 15.5117 12.5508 15.5117 11.9883C15.5117 11.457 15.793 10.9883 16.2617 10.707C16.6992 10.4258 17.293 10.4258 17.7617 10.707C18.1992 10.9883 18.5117 11.457 18.5117 11.9883ZM13.5117 11.9883C13.5117 12.5508 13.1992 13.0195 12.7617 13.3008C12.293 13.582 11.6992 13.582 11.2617 13.3008C10.793 13.0195 10.5117 12.5508 10.5117 11.9883C10.5117 11.457 10.793 10.9883 11.2617 10.707C11.6992 10.4258 12.293 10.4258 12.7617 10.707C13.1992 10.9883 13.5117 11.457 13.5117 11.9883ZM7.01172 13.4883C6.44922 13.4883 5.98047 13.207 5.69922 12.7383C5.41797 12.3008 5.41797 11.707 5.69922 11.2383C5.98047 10.8008 6.44922 10.4883 7.01172 10.4883C7.54297 10.4883 8.01172 10.8008 8.29297 11.2383C8.57422 11.707 8.57422 12.3008 8.29297 12.7383C8.01172 13.207 7.54297 13.4883 7.01172 13.4883Z" fill="currentColor"/>
172
+ </svg>`,
173
+ read: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
174
+ <path d="M7 6.5C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5H7ZM5 7C5 5.90625 5.875 5 7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7ZM15.5312 10.5312L11.5312 14.5312C11.2188 14.8438 10.75 14.8438 10.4688 14.5312L8.46875 12.5312C8.15625 12.25 8.15625 11.7812 8.46875 11.5C8.75 11.1875 9.21875 11.1875 9.53125 11.5L11 12.9688L14.4688 9.46875C14.75 9.1875 15.2188 9.1875 15.5 9.46875C15.8125 9.78125 15.8125 10.25 15.5 10.5312H15.5312Z" fill="currentColor"/>
175
+ </svg>`,
176
+ archiveRead: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
177
+ <path d="M7.5 6.5V15.25H16.5V6.5H7.5ZM6 15.25V6.5C6 5.6875 6.65625 5 7.5 5H16.5C17.3125 5 18 5.6875 18 6.5V15.25C18.4062 15.25 18.75 15.5938 18.75 16C18.75 16.4375 18.4062 16.75 18 16.75H6C5.5625 16.75 5.25 16.4375 5.25 16C5.25 15.5938 5.5625 15.25 6 15.25ZM5 13V14.5H4.5V17.5H19.5V14.5H19V13H19.5C20.3125 13 21 13.6875 21 14.5V17.5C21 18.3438 20.3125 19 19.5 19H4.5C3.65625 19 3 18.3438 3 17.5V14.5C3 13.6875 3.65625 13 4.5 13H5ZM15.0312 9.625L11.6875 12.9688C11.5312 13.0938 11.3438 13.1875 11.1562 13.1875C10.9375 13.1875 10.75 13.0938 10.625 12.9688L8.96875 11.2812C8.65625 11 8.65625 10.5312 8.96875 10.25C9.25 9.9375 9.71875 9.9375 10 10.25L11.1562 11.375L13.9688 8.5625C14.25 8.28125 14.7188 8.28125 15 8.5625C15.3125 8.875 15.3125 9.34375 15 9.625H15.0312Z" fill="currentColor"/>
178
+ </svg>`,
179
+ unread: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
180
+ <path d="M17 6.5H7C6.71875 6.5 6.5 6.75 6.5 7V17C6.5 17.2812 6.71875 17.5 7 17.5H17C17.25 17.5 17.5 17.2812 17.5 17V7C17.5 6.75 17.25 6.5 17 6.5ZM7 5H17C18.0938 5 19 5.90625 19 7V17C19 18.125 18.0938 19 17 19H7C5.875 19 5 18.125 5 17V7C5 5.90625 5.875 5 7 5Z" fill="currentColor"/>
181
+ </svg>`,
182
+ unarchive: `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
183
+ <path d="M5.5 11C5.0625 11 4.75 10.6875 4.75 10.25V5.75C4.75 5.34375 5.0625 5 5.5 5C5.90625 5 6.25 5.34375 6.25 5.75V8.28125L6.875 7.53125C8.15625 6 10.0625 5 12.25 5C16.0938 5 19.25 8.15625 19.25 12C19.25 15.875 16.0938 19 12.25 19C10.6562 19 9.21875 18.5 8.03125 17.625C7.71875 17.375 7.625 16.9062 7.875 16.5625C8.125 16.2188 8.59375 16.1562 8.9375 16.4062C9.84375 17.0938 11 17.5 12.25 17.5C15.2812 17.5 17.75 15.0625 17.75 12C17.75 8.96875 15.2812 6.5 12.25 6.5C10.5312 6.5 9.03125 7.28125 8 8.5L7.15625 9.5H10C10.4062 9.5 10.75 9.84375 10.75 10.25C10.75 10.6875 10.4062 11 10 11H5.5Z" fill="currentColor"/>
184
+ </svg>`
185
+ };
186
+ class ie extends HTMLElement {
187
+ constructor(i, e) {
188
+ super(), L(this, "_color"), L(this, "_svg"), L(this, "_iconContainer"), L(this, "_style"), this._color = i ?? r.black[500], this._svg = e;
189
+ const t = this.attachShadow({ mode: "open" });
190
+ this._iconContainer = document.createElement("div"), t.appendChild(this._iconContainer), this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._color), t.appendChild(this._style), this.refresh();
191
+ }
192
+ getStyles(i) {
193
+ return `
194
+ :host {
195
+ display: inline-block;
196
+ line-height: 0;
197
+ display: flex;
198
+ align-items: center;
199
+ justify-content: center;
200
+ }
201
+
202
+ svg {
203
+ width: 24px;
204
+ height: 24px;
205
+ color: ${i};
206
+ }
207
+ `;
208
+ }
209
+ refresh() {
210
+ this._svg && (this._iconContainer.innerHTML = this._svg), this._color && (this._style.textContent = this.getStyles(this._color));
211
+ }
212
+ updateColor(i) {
213
+ this._color = i, this.refresh();
214
+ }
215
+ updateSVG(i) {
216
+ this._svg = i, this.refresh();
217
+ }
218
+ }
219
+ customElements.get("courier-icon") || customElements.define("courier-icon", ie);
220
+ class Pe extends HTMLElement {
221
+ constructor() {
222
+ super(), L(this, "link");
223
+ const i = this.attachShadow({ mode: "open" });
224
+ this.link = document.createElement("a"), this.link.setAttribute("part", "link");
225
+ const e = document.createElement("style");
226
+ e.textContent = `
227
+ :host {
228
+ display: inline-block;
229
+ }
230
+
231
+ a {
232
+ text-decoration: none;
233
+ border-radius: 4px;
234
+ cursor: pointer;
235
+ font-weight: 500;
236
+ transition: all 0.2s ease;
237
+ font-family: var(--courier-link-font-family, inherit);
238
+ font-size: var(--courier-link-font-size, inherit);
239
+ }
240
+
241
+ /* Variants */
242
+ a[data-variant="primary"][data-mode="light"] {
243
+ color: var(--courier-link-color, ${G.light.colors.link});
244
+ }
245
+
246
+ a[data-variant="primary"][data-mode="light"]:hover {
247
+ opacity: 0.8;
248
+ }
249
+
250
+ a[data-variant="primary"][data-mode="light"]:active {
251
+ opacity: 0.6;
252
+ }
253
+
254
+ a[data-variant="primary"][data-mode="dark"] {
255
+ color: var(--courier-link-color, ${G.dark.colors.link});
256
+ }
257
+
258
+ a[data-variant="primary"][data-mode="dark"]:hover {
259
+ opacity: 0.8;
260
+ }
261
+
262
+ a[data-variant="primary"][data-mode="dark"]:active {
263
+ opacity: 0.6;
264
+ }
265
+
266
+ a[data-underline="true"] {
267
+ text-decoration: underline;
268
+ }
269
+
270
+ a:disabled {
271
+ opacity: 0.6;
272
+ cursor: not-allowed;
273
+ pointer-events: none;
274
+ }
275
+ `, i.appendChild(e), i.appendChild(this.link), this.updateVariant(), this.updateUnderline(), this.updateMode();
276
+ }
277
+ connectedCallback() {
278
+ const i = document.createElement("slot");
279
+ this.link.appendChild(i), this.updateHref();
280
+ }
281
+ attributeChangedCallback(i, e, t) {
282
+ if (e !== t)
283
+ switch (i) {
284
+ case "href":
285
+ this.updateHref();
286
+ break;
287
+ case "variant":
288
+ case "mode":
289
+ this.updateVariant();
290
+ break;
291
+ case "disabled":
292
+ this.link.style.pointerEvents = this.hasAttribute("disabled") ? "none" : "auto", this.link.style.opacity = this.hasAttribute("disabled") ? "0.6" : "1";
293
+ break;
294
+ case "color":
295
+ this.updateColor();
296
+ break;
297
+ case "underline":
298
+ this.updateUnderline();
299
+ break;
300
+ case "target":
301
+ this.updateTarget();
302
+ break;
303
+ case "font-family":
304
+ this.updateFontFamily();
305
+ break;
306
+ case "font-size":
307
+ this.updateFontSize();
308
+ break;
309
+ }
310
+ }
311
+ updateHref() {
312
+ const i = this.getAttribute("href");
313
+ i && (this.link.href = i);
314
+ }
315
+ updateVariant() {
316
+ const i = this.getAttribute("variant") || "primary", e = this.getAttribute("mode") || "light";
317
+ this.link.setAttribute("data-variant", i), this.link.setAttribute("data-mode", e);
318
+ }
319
+ updateColor() {
320
+ const i = this.getAttribute("color");
321
+ i ? this.link.style.setProperty("--courier-link-color", i) : this.link.style.removeProperty("--courier-link-color");
322
+ }
323
+ updateUnderline() {
324
+ const i = this.getAttribute("underline") === "true";
325
+ this.link.setAttribute("data-underline", i.toString());
326
+ }
327
+ updateMode() {
328
+ const i = this.getAttribute("mode") || "light";
329
+ this.link.setAttribute("data-mode", i);
330
+ }
331
+ updateTarget() {
332
+ const i = this.getAttribute("target");
333
+ i && (this.link.target = i);
334
+ }
335
+ updateFontFamily() {
336
+ const i = this.getAttribute("font-family");
337
+ i ? this.link.style.setProperty("--courier-link-font-family", i) : this.link.style.removeProperty("--courier-link-font-family");
338
+ }
339
+ updateFontSize() {
340
+ const i = this.getAttribute("font-size");
341
+ i ? this.link.style.setProperty("--courier-link-font-size", i) : this.link.style.removeProperty("--courier-link-font-size");
342
+ }
343
+ }
344
+ L(Pe, "observedAttributes", [
345
+ "href",
346
+ "variant",
347
+ "disabled",
348
+ "color",
349
+ "underline",
350
+ "mode",
351
+ "target",
352
+ "font-family",
353
+ "font-size"
354
+ ]);
355
+ customElements.get("courier-link") || customElements.define("courier-link", Pe);
356
+ class Le extends bo {
357
+ constructor() {
358
+ super(), L(this, "shadow"), this.shadow = this.attachShadow({ mode: "open" });
359
+ }
360
+ // Build the element with a factory function
361
+ build(i) {
362
+ if (i === null) {
363
+ this.shadow.replaceChildren();
364
+ return;
365
+ }
366
+ const e = i ?? this.defaultElement();
367
+ this.shadow.replaceChildren(e);
368
+ }
369
+ // Default element to be used if no factory is provided
370
+ defaultElement() {
371
+ const i = document.createElement("div");
372
+ return i.textContent = "Default Element Factory", i.style.cssText = `
373
+ background-color: red;
374
+ text-align: center;
375
+ padding: 12px;
376
+ `, i;
377
+ }
378
+ }
379
+ class Me extends Le {
380
+ constructor(i) {
381
+ super(), L(this, "_props"), L(this, "_title"), L(this, "_button"), L(this, "_style"), L(this, "_buttonClickCallback", null), this._props = i;
382
+ }
383
+ defaultElement() {
384
+ var i, e;
385
+ const t = document.createElement("div");
386
+ return this._title = document.createElement("h2"), (i = this._props.title) != null && i.text && (this._title.textContent = this._props.title.text), this._button = new Ie(this._props.button ?? ee.secondary(this.currentSystemTheme)), this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._props), t.className = "container", t.appendChild(this._style), t.appendChild(this._title), t.appendChild(this._button), this.shadow.appendChild(t), (e = this._button) == null || e.addEventListener("click", () => {
387
+ this._buttonClickCallback && this._buttonClickCallback();
388
+ }), t;
389
+ }
390
+ onSystemThemeChange(i) {
391
+ this.updateStyles(this._props);
392
+ }
393
+ getStyles(i) {
394
+ var e, t, s, o;
395
+ return `
396
+ :host {
397
+ display: flex;
398
+ align-items: center;
399
+ justify-content: center;
400
+ height: 100%;
401
+ width: 100%;
402
+ }
403
+
404
+ .container {
405
+ display: flex;
406
+ flex-direction: column;
407
+ align-items: center;
408
+ justify-content: center;
409
+ gap: 16px;
410
+ text-align: center;
411
+ padding: 24px;
412
+ }
413
+
414
+ .container h2 {
415
+ margin: 0;
416
+ color: ${((e = i.title) == null ? void 0 : e.textColor) ?? "red"};
417
+ font-size: ${((t = i.title) == null ? void 0 : t.fontSize) ?? "16px"};
418
+ font-weight: ${((s = i.title) == null ? void 0 : s.fontWeight) ?? "500"};
419
+ font-family: ${((o = i.title) == null ? void 0 : o.fontFamily) ?? "inherit"};
420
+ }
421
+ `;
422
+ }
423
+ updateStyles(i) {
424
+ this._props = i, this._style && (this._style.textContent = this.getStyles(i)), this._button && this._button.updateButton(i.button);
425
+ }
426
+ setButtonClickCallback(i) {
427
+ this._buttonClickCallback = i;
428
+ }
429
+ }
430
+ customElements.get("courier-info-state") || customElements.define("courier-info-state", Me);
431
+ class Se extends HTMLElement {
432
+ constructor(i, e, t, s, o, n, h, d) {
433
+ super(), L(this, "_backgroundColor"), L(this, "_hoverBackgroundColor"), L(this, "_activeBackgroundColor"), L(this, "_borderRadius"), L(this, "_height"), L(this, "_width"), L(this, "_style"), L(this, "_button"), L(this, "_icon"), this._borderRadius = n, this._backgroundColor = t, this._hoverBackgroundColor = s, this._activeBackgroundColor = o, this._height = h, this._width = d;
434
+ const c = this.attachShadow({ mode: "open" });
435
+ this._button = document.createElement("button"), this._button.setAttribute("part", "button"), this._icon = new ie(e, i), this._style = document.createElement("style"), this.refresh(), c.appendChild(this._style), this._button.appendChild(this._icon), c.appendChild(this._button);
436
+ }
437
+ refresh() {
438
+ this._style.textContent = this.getStyles();
439
+ }
440
+ getStyles() {
441
+ return `
442
+ :host {
443
+ display: inline-block;
444
+ border-radius: ${this._borderRadius ?? "50%"};
445
+ }
446
+
447
+ button {
448
+ border: none;
449
+ border-radius: ${this._borderRadius ?? "50%"};
450
+ cursor: pointer;
451
+ width: ${this._width ?? "36px"};
452
+ height: ${this._height ?? "36px"};
453
+ display: flex;
454
+ align-items: center;
455
+ justify-content: center;
456
+ background: ${this._backgroundColor ?? "transparent"};
457
+ transition: background-color 0.2s ease;
458
+ touch-action: manipulation;
459
+ }
460
+
461
+ button:hover {
462
+ background-color: ${this._hoverBackgroundColor ?? "red"};
463
+ }
464
+
465
+ button:active {
466
+ background-color: ${this._activeBackgroundColor ?? "red"};
467
+ }
468
+
469
+ button:disabled {
470
+ opacity: 0.6;
471
+ cursor: not-allowed;
472
+ }
473
+
474
+ [part="icon"] {
475
+ display: flex;
476
+ align-items: center;
477
+ justify-content: center;
478
+ width: 24px;
479
+ height: 24px;
480
+ }
481
+ `;
482
+ }
483
+ updateIconColor(i) {
484
+ this._icon.updateColor(i);
485
+ }
486
+ updateIconSVG(i) {
487
+ this._icon.updateSVG(i);
488
+ }
489
+ updateBackgroundColor(i) {
490
+ this._backgroundColor = i, this.refresh();
491
+ }
492
+ updateHoverBackgroundColor(i) {
493
+ this._hoverBackgroundColor = i, this.refresh();
494
+ }
495
+ updateActiveBackgroundColor(i) {
496
+ this._activeBackgroundColor = i, this.refresh();
497
+ }
498
+ }
499
+ customElements.get("courier-icon-button") || customElements.define("courier-icon-button", Se);
500
+ const Po = [
501
+ { name: "courier-button", class: Ie },
502
+ { name: "courier-icon", class: ie },
503
+ { name: "courier-link", class: Pe },
504
+ { name: "courier-info-state", class: Me },
505
+ { name: "courier-icon-button", class: Se }
506
+ ];
507
+ Po.forEach(({ name: g, class: i }) => {
508
+ customElements.get(g) || customElements.define(g, i);
509
+ });
510
+ const te = class te {
511
+ constructor() {
512
+ a(this, "_inboxDataSet");
513
+ a(this, "_archiveDataSet");
514
+ a(this, "_dataStoreListeners", []);
515
+ a(this, "_unreadCount");
516
+ a(this, "isPaginatingInbox", !1);
517
+ a(this, "isPaginatingArchive", !1);
518
+ }
519
+ static get shared() {
520
+ return te.instance || (te.instance = new te()), te.instance;
521
+ }
522
+ get unreadCount() {
523
+ return this._unreadCount ?? 0;
524
+ }
525
+ get inboxDataSet() {
526
+ return this._inboxDataSet ?? { messages: [], canPaginate: !1, paginationCursor: null };
527
+ }
528
+ get archiveDataSet() {
529
+ return this._archiveDataSet ?? { messages: [], canPaginate: !1, paginationCursor: null };
530
+ }
531
+ addDataStoreListener(i) {
532
+ this._dataStoreListeners.push(i);
533
+ }
534
+ removeDataStoreListener(i) {
535
+ this._dataStoreListeners = this._dataStoreListeners.filter((e) => e !== i);
536
+ }
537
+ async fetchDataSet(i) {
538
+ var t, s, o, n, h, d, c, u, m, p;
539
+ if (i.canUseCache)
540
+ switch (i.feedType) {
541
+ case "inbox":
542
+ if (this._inboxDataSet)
543
+ return this._inboxDataSet;
544
+ break;
545
+ case "archive":
546
+ if (this._archiveDataSet)
547
+ return this._archiveDataSet;
548
+ break;
549
+ }
550
+ const e = i.feedType === "inbox" ? await ((t = C.shared.client) == null ? void 0 : t.inbox.getMessages()) : await ((s = C.shared.client) == null ? void 0 : s.inbox.getArchivedMessages());
551
+ return {
552
+ messages: ((n = (o = e == null ? void 0 : e.data) == null ? void 0 : o.messages) == null ? void 0 : n.nodes) ?? [],
553
+ canPaginate: ((c = (d = (h = e == null ? void 0 : e.data) == null ? void 0 : h.messages) == null ? void 0 : d.pageInfo) == null ? void 0 : c.hasNextPage) ?? !1,
554
+ paginationCursor: ((p = (m = (u = e == null ? void 0 : e.data) == null ? void 0 : u.messages) == null ? void 0 : m.pageInfo) == null ? void 0 : p.startCursor) ?? null
555
+ };
556
+ }
557
+ async fetchUnreadCount(i) {
558
+ var t;
559
+ return i.canUseCache && this._unreadCount !== void 0 ? this._unreadCount : await ((t = C.shared.client) == null ? void 0 : t.inbox.getUnreadMessageCount()) ?? 0;
560
+ }
561
+ async load(i) {
562
+ var e, t, s;
563
+ try {
564
+ if (!((e = C.shared.client) != null && e.options.userId))
565
+ throw new Error("User is not signed in");
566
+ const o = i ?? { feedType: "inbox", canUseCache: !0 }, [n, h] = await Promise.all([
567
+ this.fetchDataSet(o),
568
+ this.fetchUnreadCount(o)
569
+ ]);
570
+ switch (o.feedType) {
571
+ case "inbox":
572
+ this._inboxDataSet = n;
573
+ break;
574
+ case "archive":
575
+ this._archiveDataSet = n;
576
+ break;
577
+ }
578
+ this._unreadCount = h, this._dataStoreListeners.forEach((d) => {
579
+ var c, u, m, p;
580
+ (u = (c = d.events).onDataSetChange) == null || u.call(c, n, o.feedType), (p = (m = d.events).onUnreadCountChange) == null || p.call(m, this._unreadCount ?? 0);
581
+ }), await this.connectSocket();
582
+ } catch (o) {
583
+ (s = (t = C.shared.client) == null ? void 0 : t.options.logger) == null || s.error("Error loading inbox:", o), this._dataStoreListeners.forEach((n) => {
584
+ var h, d;
585
+ (d = (h = n.events).onError) == null || d.call(h, o);
586
+ });
587
+ }
588
+ }
589
+ async connectSocket() {
590
+ var e, t, s, o, n, h, d, c, u, m, p, x;
591
+ const i = (e = C.shared.client) == null ? void 0 : e.inbox.socket;
592
+ try {
593
+ if (!i) {
594
+ (s = (t = C.shared.client) == null ? void 0 : t.options.logger) == null || s.info("CourierInbox socket not available");
595
+ return;
596
+ }
597
+ if ((h = (o = C.shared.client) == null ? void 0 : o.options.logger) == null || h.info("CourierInbox socket connectionId:", (n = C.shared.client) == null ? void 0 : n.options.connectionId), i.isConnected) {
598
+ (c = (d = C.shared.client) == null ? void 0 : d.options.logger) == null || c.info("CourierInbox socket already connected. Socket will not attempt reconnection.");
599
+ return;
600
+ }
601
+ i.receivedMessage = (_) => {
602
+ this.addMessage(_, 0, "inbox");
603
+ }, i.receivedMessageEvent = (_) => {
604
+ let b;
605
+ switch (_.messageId && (b = this.getMessage({ messageId: _.messageId })), _.event) {
606
+ case "mark-all-read":
607
+ this.readAllMessages();
608
+ break;
609
+ case "read":
610
+ b && this.readMessage(b, !1);
611
+ break;
612
+ case "unread":
613
+ b && this.unreadMessage(b, !1);
614
+ break;
615
+ case "opened":
616
+ b && this.openMessage(b, !1);
617
+ break;
618
+ case "archive":
619
+ b && this.archiveMessage(b, !1);
620
+ break;
621
+ case "click":
622
+ b && this.clickMessage(b, !1);
623
+ break;
624
+ case "unopened":
625
+ case "unarchive":
626
+ break;
627
+ }
628
+ }, await i.connect(), await i.sendSubscribe(), i.keepAlive(), (m = (u = C.shared.client) == null ? void 0 : u.options.logger) == null || m.info("CourierInbox socket connected");
629
+ } catch (_) {
630
+ (x = (p = C.shared.client) == null ? void 0 : p.options.logger) == null || x.error("Failed to connect socket:", _);
631
+ }
632
+ }
633
+ getMessage(i) {
634
+ var e, t;
635
+ return ((e = this._inboxDataSet) == null ? void 0 : e.messages.find((s) => s.messageId === i.messageId)) ?? ((t = this._archiveDataSet) == null ? void 0 : t.messages.find((s) => s.messageId === i.messageId));
636
+ }
637
+ async fetchNextPageOfMessages(i) {
638
+ var e, t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T, $, D;
639
+ switch (i.feedType) {
640
+ case "inbox":
641
+ if (this.isPaginatingInbox)
642
+ return null;
643
+ if ((e = this._inboxDataSet) != null && e.canPaginate && this._inboxDataSet.paginationCursor)
644
+ try {
645
+ this.isPaginatingInbox = !0;
646
+ const y = await ((t = C.shared.client) == null ? void 0 : t.inbox.getMessages({
647
+ paginationLimit: C.shared.paginationLimit,
648
+ startCursor: this._inboxDataSet.paginationCursor
649
+ })), B = {
650
+ messages: ((o = (s = y == null ? void 0 : y.data) == null ? void 0 : s.messages) == null ? void 0 : o.nodes) ?? [],
651
+ canPaginate: ((d = (h = (n = y == null ? void 0 : y.data) == null ? void 0 : n.messages) == null ? void 0 : h.pageInfo) == null ? void 0 : d.hasNextPage) ?? !1,
652
+ paginationCursor: ((m = (u = (c = y == null ? void 0 : y.data) == null ? void 0 : c.messages) == null ? void 0 : u.pageInfo) == null ? void 0 : m.startCursor) ?? null
653
+ };
654
+ return this.addPage(B, "inbox"), B;
655
+ } catch (y) {
656
+ return (x = (p = C.shared.client) == null ? void 0 : p.options.logger) == null || x.error("Error fetching next page of inbox messages:", y), null;
657
+ } finally {
658
+ this.isPaginatingInbox = !1;
659
+ }
660
+ break;
661
+ case "archive":
662
+ if (this.isPaginatingArchive)
663
+ return null;
664
+ if ((_ = this._archiveDataSet) != null && _.canPaginate && this._archiveDataSet.paginationCursor)
665
+ try {
666
+ this.isPaginatingArchive = !0;
667
+ const y = await ((b = C.shared.client) == null ? void 0 : b.inbox.getArchivedMessages({
668
+ paginationLimit: C.shared.paginationLimit,
669
+ startCursor: this._archiveDataSet.paginationCursor
670
+ })), B = {
671
+ messages: ((k = (v = y == null ? void 0 : y.data) == null ? void 0 : v.messages) == null ? void 0 : k.nodes) ?? [],
672
+ canPaginate: ((E = (S = (w = y == null ? void 0 : y.data) == null ? void 0 : w.messages) == null ? void 0 : S.pageInfo) == null ? void 0 : E.hasNextPage) ?? !1,
673
+ paginationCursor: ((T = (I = (M = y == null ? void 0 : y.data) == null ? void 0 : M.messages) == null ? void 0 : I.pageInfo) == null ? void 0 : T.startCursor) ?? null
674
+ };
675
+ return this.addPage(B, "archive"), B;
676
+ } catch (y) {
677
+ return (D = ($ = C.shared.client) == null ? void 0 : $.options.logger) == null || D.error("Error fetching next page of archived messages:", y), null;
678
+ } finally {
679
+ this.isPaginatingArchive = !1;
680
+ }
681
+ break;
682
+ }
683
+ return null;
684
+ }
685
+ applyLocalMessageChange(i, e) {
686
+ for (const [t, s] of Object.entries(e))
687
+ s !== void 0 && this.updateMessage(i, s, t);
688
+ }
689
+ async readMessage(i, e = !0) {
690
+ var o, n, h, d;
691
+ if (!C.shared.client)
692
+ return;
693
+ const t = i;
694
+ if (t.read)
695
+ return;
696
+ const s = {
697
+ inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((c) => c.messageId === i.messageId),
698
+ archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((c) => c.messageId === i.messageId)
699
+ };
700
+ try {
701
+ i.read = (/* @__PURE__ */ new Date()).toISOString(), this.applyLocalMessageChange(i, s), e && await C.shared.client.inbox.read({ messageId: i.messageId });
702
+ } catch (c) {
703
+ this.applyLocalMessageChange(t, s), (d = (h = C.shared.client) == null ? void 0 : h.options.logger) == null || d.error("Error reading message:", c);
704
+ }
705
+ }
706
+ async unreadMessage(i, e = !0) {
707
+ var o, n, h, d;
708
+ if (!C.shared.client)
709
+ return;
710
+ const t = i;
711
+ if (!t.read)
712
+ return;
713
+ const s = {
714
+ inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((c) => c.messageId === i.messageId),
715
+ archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((c) => c.messageId === i.messageId)
716
+ };
717
+ try {
718
+ i.read = void 0, this.applyLocalMessageChange(i, s), e && await C.shared.client.inbox.unread({ messageId: i.messageId });
719
+ } catch (c) {
720
+ this.applyLocalMessageChange(t, s), (d = (h = C.shared.client) == null ? void 0 : h.options.logger) == null || d.error("Error unreading message:", c);
721
+ }
722
+ }
723
+ async openMessage(i, e = !0) {
724
+ var o, n, h, d;
725
+ if (!C.shared.client)
726
+ return;
727
+ const t = i, s = {
728
+ inbox: (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((c) => c.messageId === i.messageId),
729
+ archive: (n = this._archiveDataSet) == null ? void 0 : n.messages.findIndex((c) => c.messageId === i.messageId)
730
+ };
731
+ if (!(!s.inbox && !s.archive) && !t.opened)
732
+ try {
733
+ i.opened = (/* @__PURE__ */ new Date()).toISOString(), this.applyLocalMessageChange(i, s), e && await C.shared.client.inbox.open({ messageId: i.messageId });
734
+ } catch (c) {
735
+ this.applyLocalMessageChange(t, s), (d = (h = C.shared.client) == null ? void 0 : h.options.logger) == null || d.error("Error opening message:", c);
736
+ }
737
+ }
738
+ async clickMessage(i, e = !0) {
739
+ var t, s, o, n;
740
+ if (C.shared.client)
741
+ try {
742
+ (t = i.trackingIds) != null && t.clickTrackingId && e && await C.shared.client.inbox.click({
743
+ messageId: i.messageId,
744
+ trackingId: (s = i.trackingIds) == null ? void 0 : s.clickTrackingId
745
+ });
746
+ } catch (h) {
747
+ (n = (o = C.shared.client) == null ? void 0 : o.options.logger) == null || n.error("Error clicking message:", h);
748
+ }
749
+ }
750
+ async archiveMessage(i, e = !0) {
751
+ var o, n;
752
+ if (!C.shared.client)
753
+ return;
754
+ const t = i, s = (o = this._inboxDataSet) == null ? void 0 : o.messages.findIndex((h) => h.messageId === i.messageId);
755
+ if (s !== void 0)
756
+ try {
757
+ if (this.removeMessage(i, s, "inbox"), (n = this._archiveDataSet) != null && n.messages) {
758
+ const h = this.findInsertIndex(i, this._archiveDataSet.messages);
759
+ i.archived = (/* @__PURE__ */ new Date()).toISOString(), this.addMessage(i, h, "archive");
760
+ }
761
+ e && await C.shared.client.inbox.archive({ messageId: i.messageId });
762
+ } catch {
763
+ this.addMessage(t, s, "inbox"), i.archived = void 0, this.removeMessage(i, s, "archive");
764
+ }
765
+ }
766
+ async readAllMessages(i = !0) {
767
+ var o, n, h, d;
768
+ if (!C.shared.client)
769
+ return;
770
+ const e = this._inboxDataSet, t = this._archiveDataSet, s = this._unreadCount;
771
+ try {
772
+ (o = this._inboxDataSet) == null || o.messages.forEach((c) => {
773
+ c.read || (c.read = (/* @__PURE__ */ new Date()).toISOString());
774
+ }), (n = this._archiveDataSet) == null || n.messages.forEach((c) => {
775
+ c.read || (c.read = (/* @__PURE__ */ new Date()).toISOString());
776
+ }), this._unreadCount = 0, this._dataStoreListeners.forEach((c) => {
777
+ var u, m, p, x, _, b;
778
+ this._inboxDataSet && ((m = (u = c.events).onDataSetChange) == null || m.call(u, this._inboxDataSet, "inbox")), this._archiveDataSet && ((x = (p = c.events).onDataSetChange) == null || x.call(p, this._archiveDataSet, "archive")), (b = (_ = c.events).onUnreadCountChange) == null || b.call(_, this._unreadCount);
779
+ }), i && await C.shared.client.inbox.readAll();
780
+ } catch (c) {
781
+ (d = (h = C.shared.client) == null ? void 0 : h.options.logger) == null || d.error("Error reading all messages:", c), this._inboxDataSet && e && (this._inboxDataSet.messages = e.messages), this._archiveDataSet && t && (this._archiveDataSet.messages = t.messages), this._unreadCount = s, this._dataStoreListeners.forEach((u) => {
782
+ var m, p, x, _, b, v;
783
+ this._inboxDataSet && ((p = (m = u.events).onDataSetChange) == null || p.call(m, this._inboxDataSet, "inbox")), this._archiveDataSet && ((_ = (x = u.events).onDataSetChange) == null || _.call(x, this._archiveDataSet, "archive")), (v = (b = u.events).onUnreadCountChange) == null || v.call(b, this._unreadCount);
784
+ });
785
+ }
786
+ }
787
+ findInsertIndex(i, e) {
788
+ const t = [...e];
789
+ t.push(i), t.sort((o, n) => {
790
+ const h = new Date(o.created ?? Date.now()).getTime();
791
+ return new Date(n.created ?? Date.now()).getTime() - h;
792
+ });
793
+ const s = t.findIndex((o) => o.messageId === i.messageId);
794
+ return Math.max(s - 1, 0);
795
+ }
796
+ addPage(i, e) {
797
+ switch (e) {
798
+ case "inbox":
799
+ this._inboxDataSet && (this._inboxDataSet.canPaginate = i.canPaginate, this._inboxDataSet.paginationCursor = i.paginationCursor, this._inboxDataSet.messages = [...this._inboxDataSet.messages, ...i.messages]);
800
+ break;
801
+ case "archive":
802
+ this._archiveDataSet && (this._archiveDataSet.canPaginate = i.canPaginate, this._archiveDataSet.paginationCursor = i.paginationCursor, this._archiveDataSet.messages = [...this._archiveDataSet.messages, ...i.messages]);
803
+ break;
804
+ }
805
+ this._dataStoreListeners.forEach(
806
+ (t) => {
807
+ var s, o;
808
+ return (o = (s = t.events).onPageAdded) == null ? void 0 : o.call(s, i, e);
809
+ }
810
+ );
811
+ }
812
+ addMessage(i, e, t) {
813
+ var s, o;
814
+ switch (t) {
815
+ case "inbox":
816
+ !i.read && this._unreadCount !== void 0 && (this._unreadCount = this._unreadCount + 1), (s = this._inboxDataSet) == null || s.messages.splice(e, 0, i);
817
+ break;
818
+ case "archive":
819
+ (o = this._archiveDataSet) == null || o.messages.splice(e, 0, i);
820
+ break;
821
+ }
822
+ this._dataStoreListeners.forEach((n) => {
823
+ var h, d, c, u;
824
+ (d = (h = n.events).onMessageAdd) == null || d.call(h, i, e, t), (u = (c = n.events).onUnreadCountChange) == null || u.call(c, this._unreadCount ?? 0);
825
+ });
826
+ }
827
+ removeMessage(i, e, t) {
828
+ var s, o;
829
+ switch (t) {
830
+ case "inbox":
831
+ !i.read && this._unreadCount !== void 0 && (this._unreadCount = this._unreadCount - 1), (s = this._inboxDataSet) == null || s.messages.splice(e, 1);
832
+ break;
833
+ case "archive":
834
+ (o = this._archiveDataSet) == null || o.messages.splice(e, 1);
835
+ break;
836
+ }
837
+ this._dataStoreListeners.forEach((n) => {
838
+ var h, d, c, u;
839
+ (d = (h = n.events).onMessageRemove) == null || d.call(h, i, e, t), (u = (c = n.events).onUnreadCountChange) == null || u.call(c, this._unreadCount ?? 0);
840
+ });
841
+ }
842
+ updateMessage(i, e, t) {
843
+ switch (t) {
844
+ case "inbox":
845
+ this._unreadCount !== void 0 && !i.archived && (i.read && (this._unreadCount = Math.max(0, this._unreadCount - 1)), i.read || (this._unreadCount = this._unreadCount + 1)), this._inboxDataSet && (this._inboxDataSet.messages[e] = i);
846
+ break;
847
+ case "archive":
848
+ this._archiveDataSet && (this._archiveDataSet.messages[e] = i);
849
+ break;
850
+ }
851
+ this._dataStoreListeners.forEach((s) => {
852
+ var o, n, h, d;
853
+ (n = (o = s.events).onMessageUpdate) == null || n.call(o, i, e, t), (d = (h = s.events).onUnreadCountChange) == null || d.call(h, this._unreadCount ?? 0);
854
+ });
855
+ }
856
+ };
857
+ a(te, "instance");
858
+ let A = te;
859
+ function zo(g) {
860
+ return A.shared.readMessage(g);
861
+ }
862
+ function Oo(g) {
863
+ return A.shared.unreadMessage(g);
864
+ }
865
+ function No(g) {
866
+ return A.shared.clickMessage(g);
867
+ }
868
+ function Uo(g) {
869
+ return A.shared.archiveMessage(g);
870
+ }
871
+ function Vo(g) {
872
+ return A.shared.openMessage(g);
873
+ }
874
+ function $o(g) {
875
+ if (!g.created) return "Now";
876
+ const i = /* @__PURE__ */ new Date(), e = new Date(g.created), t = Math.floor((i.getTime() - e.getTime()) / 1e3);
877
+ return t < 60 ? `${t}s` : t < 3600 ? `${Math.floor(t / 60)}m` : t < 86400 ? `${Math.floor(t / 3600)}h` : t < 604800 ? `${Math.floor(t / 86400)}d` : t < 31536e3 ? `${Math.floor(t / 604800)}w` : `${Math.floor(t / 31536e3)}y`;
878
+ }
879
+ class _o extends HTMLElement {
880
+ constructor(e) {
881
+ super();
882
+ // State
883
+ a(this, "_theme");
884
+ a(this, "_options", []);
885
+ // Components
886
+ a(this, "_style");
887
+ this._theme = e;
888
+ const t = this.attachShadow({ mode: "open" });
889
+ this._style = document.createElement("style"), this._style.textContent = this.getStyles(), t.appendChild(this._style);
890
+ const s = document.createElement("ul");
891
+ s.className = "menu", t.appendChild(s);
892
+ }
893
+ getStyles() {
894
+ var t, s, o;
895
+ const e = (o = (s = (t = this._theme.inbox) == null ? void 0 : t.list) == null ? void 0 : s.item) == null ? void 0 : o.menu;
896
+ return `
897
+ :host {
898
+ display: block;
899
+ position: absolute;
900
+ background: ${(e == null ? void 0 : e.backgroundColor) ?? "red"};
901
+ border: ${(e == null ? void 0 : e.border) ?? "1px solid red"};
902
+ border-radius: ${(e == null ? void 0 : e.borderRadius) ?? "0px"};
903
+ box-shadow: ${(e == null ? void 0 : e.shadow) ?? "0 2px 8px red"};
904
+ user-select: none;
905
+ opacity: 0;
906
+ pointer-events: none;
907
+ transition: opacity 0.15s;
908
+ overflow: hidden;
909
+ }
910
+
911
+ :host(.visible) {
912
+ opacity: 1;
913
+ pointer-events: auto;
914
+ }
915
+
916
+ ul.menu {
917
+ list-style: none;
918
+ margin: 0;
919
+ padding: 0;
920
+ display: flex;
921
+ flex-direction: row;
922
+ }
923
+
924
+ li.menu-item {
925
+ display: flex;
926
+ align-items: center;
927
+ justify-content: center;
928
+ cursor: pointer;
929
+ border-bottom: none;
930
+ background: transparent;
931
+ }
932
+ `;
933
+ }
934
+ setOptions(e) {
935
+ this._options = e, this.renderMenu();
936
+ }
937
+ renderMenu() {
938
+ var o, n, h, d;
939
+ const e = (o = this.shadowRoot) == null ? void 0 : o.querySelector("ul.menu");
940
+ if (!e) return;
941
+ e.innerHTML = "";
942
+ const t = (d = (h = (n = this._theme.inbox) == null ? void 0 : n.list) == null ? void 0 : h.item) == null ? void 0 : d.menu, s = (c) => {
943
+ c.stopPropagation(), c.preventDefault();
944
+ };
945
+ this._options.forEach((c) => {
946
+ var p, x, _;
947
+ const u = new Se(c.icon.svg, c.icon.color, t == null ? void 0 : t.backgroundColor, (p = t == null ? void 0 : t.item) == null ? void 0 : p.hoverBackgroundColor, (x = t == null ? void 0 : t.item) == null ? void 0 : x.activeBackgroundColor, (_ = t == null ? void 0 : t.item) == null ? void 0 : _.borderRadius), m = (b) => {
948
+ s(b), c.onClick();
949
+ };
950
+ u.addEventListener("click", m), u.addEventListener("touchstart", s), u.addEventListener("touchend", m), u.addEventListener("touchmove", s), u.addEventListener("mousedown", s), u.addEventListener("mouseup", s), e.appendChild(u);
951
+ });
952
+ }
953
+ show() {
954
+ this.classList.add("visible");
955
+ }
956
+ hide() {
957
+ this.classList.remove("visible");
958
+ }
959
+ }
960
+ customElements.get("courier-list-item-menu") || customElements.define("courier-list-item-menu", _o);
961
+ class xo extends HTMLElement {
962
+ constructor(e) {
963
+ super();
964
+ // State
965
+ a(this, "_theme");
966
+ a(this, "_message", null);
967
+ a(this, "_feedType", "inbox");
968
+ a(this, "_isMobile", !1);
969
+ // Elements
970
+ a(this, "_titleElement");
971
+ a(this, "_subtitleElement");
972
+ a(this, "_timeElement");
973
+ a(this, "_style");
974
+ a(this, "_menu");
975
+ a(this, "_unreadIndicator");
976
+ a(this, "_actionsContainer");
977
+ // Touch gestures
978
+ a(this, "_longPressTimeout", null);
979
+ a(this, "_isLongPress", !1);
980
+ // Callbacks
981
+ a(this, "onItemClick", null);
982
+ a(this, "onItemLongPress", null);
983
+ a(this, "onItemActionClick", null);
984
+ this._theme = e, this._isMobile = "ontouchstart" in window;
985
+ const t = this.attachShadow({ mode: "open" }), s = document.createElement("div");
986
+ s.className = "content-container", this._titleElement = document.createElement("p"), this._titleElement.setAttribute("part", "title"), this._subtitleElement = document.createElement("p"), this._subtitleElement.setAttribute("part", "subtitle"), this._actionsContainer = document.createElement("div"), this._actionsContainer.className = "actions-container", s.appendChild(this._titleElement), s.appendChild(this._subtitleElement), s.appendChild(this._actionsContainer), this._timeElement = document.createElement("p"), this._timeElement.setAttribute("part", "time"), this._unreadIndicator = document.createElement("div"), this._unreadIndicator.className = "unread-indicator", this._style = document.createElement("style"), this._refreshStyles(), this._menu = new _o(this._theme), this._menu.setOptions(this._getMenuOptions()), t.append(this._style, this._unreadIndicator, s, this._timeElement, this._menu);
987
+ const o = (n) => {
988
+ n.stopPropagation(), n.preventDefault();
989
+ };
990
+ this._menu.addEventListener("mousedown", o), this._menu.addEventListener("pointerdown", o), this._menu.addEventListener("click", o), this.addEventListener("click", (n) => {
991
+ this._menu.contains(n.target) || n.composedPath().includes(this._menu) || this._message && this.onItemClick && !(n.target instanceof ie) && !this._isLongPress && this.onItemClick(this._message);
992
+ }), this._setupHoverBehavior(), this._setupLongPressBehavior();
993
+ }
994
+ _setupHoverBehavior() {
995
+ this._isMobile || (this.addEventListener("mouseenter", () => {
996
+ this._isLongPress = !1, this._showMenu();
997
+ }), this.addEventListener("mouseleave", () => this._hideMenu()));
998
+ }
999
+ _setupLongPressBehavior() {
1000
+ var s, o, n;
1001
+ const e = (n = (o = (s = this._theme.inbox) == null ? void 0 : s.list) == null ? void 0 : o.item) == null ? void 0 : n.menu;
1002
+ if (!(e != null && e.enabled))
1003
+ return;
1004
+ const t = e.longPress;
1005
+ this.addEventListener(
1006
+ "touchstart",
1007
+ () => {
1008
+ this._longPressTimeout = window.setTimeout(() => {
1009
+ this._isLongPress = !0, this._showMenu(), this._message && this.onItemLongPress && (this.onItemLongPress(this._message), navigator.vibrate && navigator.vibrate((t == null ? void 0 : t.vibrationDuration) ?? 50)), setTimeout(() => {
1010
+ this._hideMenu(), this._isLongPress = !1;
1011
+ }, (t == null ? void 0 : t.displayDuration) ?? 2e3);
1012
+ }, 650);
1013
+ },
1014
+ { passive: !0 }
1015
+ ), this.addEventListener("touchend", () => {
1016
+ this._longPressTimeout && (window.clearTimeout(this._longPressTimeout), this._longPressTimeout = null);
1017
+ });
1018
+ }
1019
+ setOnLongPress(e) {
1020
+ this.onItemLongPress = e;
1021
+ }
1022
+ // Helpers
1023
+ _getMenuOptions() {
1024
+ var s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I;
1025
+ const e = (h = (n = (o = (s = this._theme.inbox) == null ? void 0 : s.list) == null ? void 0 : o.item) == null ? void 0 : n.menu) == null ? void 0 : h.item;
1026
+ let t = [];
1027
+ return (d = this._message) != null && d.archived || t.push({
1028
+ id: (c = this._message) != null && c.read ? "unread" : "read",
1029
+ icon: {
1030
+ svg: (u = this._message) != null && u.read ? (m = e == null ? void 0 : e.unread) == null ? void 0 : m.svg : (p = e == null ? void 0 : e.read) == null ? void 0 : p.svg,
1031
+ color: (x = this._message) != null && x.read ? (_ = e == null ? void 0 : e.unread) == null ? void 0 : _.color : ((b = e == null ? void 0 : e.read) == null ? void 0 : b.color) ?? "red"
1032
+ },
1033
+ onClick: () => {
1034
+ this._message && (this._message.read ? A.shared.unreadMessage(this._message) : A.shared.readMessage(this._message));
1035
+ }
1036
+ }), t.push({
1037
+ id: (v = this._message) != null && v.archived ? "unarchive" : "archive",
1038
+ icon: {
1039
+ svg: (k = this._message) != null && k.archived ? (w = e == null ? void 0 : e.unarchive) == null ? void 0 : w.svg : (S = e == null ? void 0 : e.archive) == null ? void 0 : S.svg,
1040
+ color: (E = this._message) != null && E.archived ? (M = e == null ? void 0 : e.unarchive) == null ? void 0 : M.color : ((I = e == null ? void 0 : e.archive) == null ? void 0 : I.color) ?? "red"
1041
+ },
1042
+ onClick: () => {
1043
+ this._message && (this._message.archived ? alert("unarchive") : A.shared.archiveMessage(this._message));
1044
+ }
1045
+ }), t;
1046
+ }
1047
+ // Menu visibility helpers
1048
+ _showMenu() {
1049
+ var t, s, o;
1050
+ const e = (o = (s = (t = this._theme.inbox) == null ? void 0 : t.list) == null ? void 0 : s.item) == null ? void 0 : o.menu;
1051
+ e && e.enabled && (this._menu.setOptions(this._getMenuOptions()), this._menu.style.display = "block", this._menu.show(), this._timeElement.style.opacity = "0");
1052
+ }
1053
+ _hideMenu() {
1054
+ var t, s, o;
1055
+ const e = (o = (s = (t = this._theme.inbox) == null ? void 0 : t.list) == null ? void 0 : s.item) == null ? void 0 : o.menu;
1056
+ e && e.enabled && (this._menu.hide(), this._menu.style.display = "none", this._timeElement.style.opacity = "1");
1057
+ }
1058
+ _getStyles() {
1059
+ var t, s, o, n, h, d, c, u, m, p, x;
1060
+ const e = (s = (t = this._theme.inbox) == null ? void 0 : t.list) == null ? void 0 : s.item;
1061
+ return `
1062
+ :host {
1063
+ display: flex;
1064
+ flex-direction: row;
1065
+ align-items: flex-start;
1066
+ justify-content: space-between;
1067
+ border-bottom: ${(e == null ? void 0 : e.divider) ?? "1px solid red"};
1068
+ font-family: inherit;
1069
+ cursor: pointer;
1070
+ transition: background-color 0.2s ease;
1071
+ margin: 0;
1072
+ width: 100%;
1073
+ box-sizing: border-box;
1074
+ padding: 12px 20px;
1075
+ position: relative;
1076
+ background-color: ${(e == null ? void 0 : e.backgroundColor) ?? "transparent"};
1077
+ user-select: none;
1078
+ -webkit-user-select: none;
1079
+ -moz-user-select: none;
1080
+ -ms-user-select: none;
1081
+ touch-action: manipulation;
1082
+ }
1083
+
1084
+ /* ───────────────────────── Base hover / active ────────────────── */
1085
+ @media (hover: hover) {
1086
+ :host(:hover) {
1087
+ background-color: ${(e == null ? void 0 : e.hoverBackgroundColor) ?? "red"};
1088
+ }
1089
+ }
1090
+ :host(:active) {
1091
+ background-color: ${(e == null ? void 0 : e.activeBackgroundColor) ?? "red"};
1092
+ }
1093
+
1094
+ /* ───────────────────────── Menu hover / active ────────────────── */
1095
+ @media (hover: hover) {
1096
+ :host(:hover):has(courier-list-item-menu:hover, courier-list-item-menu *:hover, courier-button:hover, courier-button *:hover) {
1097
+ background-color: ${(e == null ? void 0 : e.backgroundColor) ?? "transparent"};
1098
+ }
1099
+ }
1100
+ :host(:active):has(courier-list-item-menu:active, courier-list-item-menu *:active, courier-button:active, courier-button *:active) {
1101
+ background-color: ${(e == null ? void 0 : e.backgroundColor) ?? "transparent"};
1102
+ }
1103
+
1104
+ :host(:last-child) {
1105
+ border-bottom: none;
1106
+ }
1107
+
1108
+ .unread-indicator {
1109
+ position: absolute;
1110
+ top: 28px;
1111
+ left: 6px;
1112
+ width: 8px;
1113
+ height: 8px;
1114
+ border-radius: 50%;
1115
+ background-color: ${(e == null ? void 0 : e.unreadIndicatorColor) ?? "red"};
1116
+ display: none;
1117
+ }
1118
+
1119
+ :host(.unread) .unread-indicator {
1120
+ display: block;
1121
+ }
1122
+
1123
+ .content-container {
1124
+ flex: 1;
1125
+ display: flex;
1126
+ flex-direction: column;
1127
+ margin-right: 12px;
1128
+ }
1129
+
1130
+ p {
1131
+ margin: 0;
1132
+ overflow-wrap: break-word;
1133
+ word-break: break-word;
1134
+ hyphens: auto;
1135
+ line-height: 1.4;
1136
+ user-select: none;
1137
+ -webkit-user-select: none;
1138
+ -moz-user-select: none;
1139
+ -ms-user-select: none;
1140
+ text-align: left;
1141
+ }
1142
+
1143
+ p[part='title'] {
1144
+ font-family: ${((o = e == null ? void 0 : e.title) == null ? void 0 : o.family) ?? "inherit"};
1145
+ font-size: ${((n = e == null ? void 0 : e.title) == null ? void 0 : n.size) ?? "14px"};
1146
+ color: ${((h = e == null ? void 0 : e.title) == null ? void 0 : h.color) ?? "red"};
1147
+ margin-bottom: 4px;
1148
+ }
1149
+
1150
+ p[part='subtitle'] {
1151
+ font-family: ${((d = e == null ? void 0 : e.subtitle) == null ? void 0 : d.family) ?? "inherit"};
1152
+ font-size: ${((c = e == null ? void 0 : e.subtitle) == null ? void 0 : c.size) ?? "14px"};
1153
+ color: ${((u = e == null ? void 0 : e.subtitle) == null ? void 0 : u.color) ?? "red"};
1154
+ }
1155
+
1156
+ p[part='time'] {
1157
+ font-family: ${((m = e == null ? void 0 : e.time) == null ? void 0 : m.family) ?? "inherit"};
1158
+ font-size: ${((p = e == null ? void 0 : e.time) == null ? void 0 : p.size) ?? "14px"};
1159
+ color: ${((x = e == null ? void 0 : e.time) == null ? void 0 : x.color) ?? "red"};
1160
+ text-align: right;
1161
+ white-space: nowrap;
1162
+ }
1163
+
1164
+ courier-list-item-menu {
1165
+ z-index: 1;
1166
+ position: absolute;
1167
+ top: 8px;
1168
+ right: 8px;
1169
+ display: none; /* becomes block while visible */
1170
+ }
1171
+
1172
+ .actions-container {
1173
+ display: flex;
1174
+ margin-top: 10px;
1175
+ flex-wrap: wrap;
1176
+ flex-direction: row;
1177
+ align-items: center;
1178
+ gap: 8px;
1179
+ display: none;
1180
+ }
1181
+
1182
+ `;
1183
+ }
1184
+ _refreshStyles() {
1185
+ this._style.textContent = this._getStyles();
1186
+ }
1187
+ // Lifecycle hooks
1188
+ connectedCallback() {
1189
+ var s, o;
1190
+ const e = this.getAttribute("message"), t = this.getAttribute("feed-type");
1191
+ if (t && (this._feedType = t), e)
1192
+ try {
1193
+ this._message = JSON.parse(e), this._updateContent();
1194
+ } catch (n) {
1195
+ (o = (s = C.shared.client) == null ? void 0 : s.options.logger) == null || o.error("CourierListItem – failed to parse message:", n);
1196
+ }
1197
+ }
1198
+ // Public API
1199
+ setMessage(e, t) {
1200
+ this._message = e, this._feedType = t, this._updateContent();
1201
+ }
1202
+ setOnItemClick(e) {
1203
+ this.onItemClick = e;
1204
+ }
1205
+ setOnItemActionClick(e) {
1206
+ this.onItemActionClick = e;
1207
+ }
1208
+ setOnItemLongPress(e) {
1209
+ this.onItemLongPress = e;
1210
+ }
1211
+ // Content rendering
1212
+ _updateContent() {
1213
+ var s, o, n, h, d, c;
1214
+ if (!this._message) {
1215
+ this._titleElement.textContent = "", this._subtitleElement.textContent = "";
1216
+ return;
1217
+ }
1218
+ this.classList.toggle("unread", !this._message.read && this._feedType !== "archive"), this._titleElement.textContent = this._message.title || "Untitled Message", this._subtitleElement.textContent = this._message.preview || this._message.body || "", this._timeElement.textContent = $o(this._message), this._menu.setOptions(this._getMenuOptions());
1219
+ const e = ((s = this._message) == null ? void 0 : s.actions) && this._message.actions.length > 0;
1220
+ this._actionsContainer.style.display = e ? "flex" : "none";
1221
+ const t = (h = (n = (o = this._theme.inbox) == null ? void 0 : o.list) == null ? void 0 : n.item) == null ? void 0 : h.actions;
1222
+ (c = (d = this._message) == null ? void 0 : d.actions) == null || c.forEach((u) => {
1223
+ var p, x, _, b;
1224
+ const m = new Ie({
1225
+ text: u.content,
1226
+ variant: "secondary",
1227
+ backgroundColor: t == null ? void 0 : t.backgroundColor,
1228
+ hoverBackgroundColor: t == null ? void 0 : t.hoverBackgroundColor,
1229
+ activeBackgroundColor: t == null ? void 0 : t.activeBackgroundColor,
1230
+ border: t == null ? void 0 : t.border,
1231
+ borderRadius: t == null ? void 0 : t.borderRadius,
1232
+ shadow: t == null ? void 0 : t.shadow,
1233
+ fontFamily: (p = t == null ? void 0 : t.font) == null ? void 0 : p.family,
1234
+ fontSize: (x = t == null ? void 0 : t.font) == null ? void 0 : x.size,
1235
+ fontWeight: (_ = t == null ? void 0 : t.font) == null ? void 0 : _.weight,
1236
+ textColor: (b = t == null ? void 0 : t.font) == null ? void 0 : b.color,
1237
+ onClick: () => {
1238
+ this._message && this.onItemActionClick && this.onItemActionClick(this._message, u);
1239
+ }
1240
+ });
1241
+ this._actionsContainer.appendChild(m);
1242
+ });
1243
+ }
1244
+ }
1245
+ customElements.get("courier-list-item") || customElements.define("courier-list-item", xo);
1246
+ class fo extends HTMLElement {
1247
+ constructor(e, t) {
1248
+ super();
1249
+ // Shadow root
1250
+ a(this, "_shadow");
1251
+ this._shadow = this.attachShadow({ mode: "open" });
1252
+ const s = document.createElement("style");
1253
+ s.textContent = this.getStyles(t), this._shadow.appendChild(s);
1254
+ const o = new Ee(e, 35), n = new Ee(e, 100), h = new Ee(e, 82);
1255
+ this._shadow.appendChild(o), this._shadow.appendChild(n), this._shadow.appendChild(h);
1256
+ }
1257
+ getStyles(e) {
1258
+ return `
1259
+ :host {
1260
+ display: flex;
1261
+ flex-direction: column;
1262
+ gap: 12px;
1263
+ padding: 12px;
1264
+ width: 100%;
1265
+ box-sizing: border-box;
1266
+ opacity: ${e};
1267
+ }
1268
+ `;
1269
+ }
1270
+ }
1271
+ customElements.get("courier-inbox-skeleton-list-item") || customElements.define("courier-inbox-skeleton-list-item", fo);
1272
+ class Ee extends HTMLElement {
1273
+ constructor(e, t) {
1274
+ super();
1275
+ a(this, "_shadow");
1276
+ this._shadow = this.attachShadow({ mode: "open" });
1277
+ const s = document.createElement("style");
1278
+ s.textContent = this.getStyles(e, t), this._shadow.appendChild(s);
1279
+ const o = document.createElement("div");
1280
+ o.className = "skeleton-item", this._shadow.appendChild(o);
1281
+ }
1282
+ getStyles(e, t) {
1283
+ var m, p, x, _, b, v, k, w, S, E, M, I;
1284
+ const s = ((x = (p = (m = e.inbox) == null ? void 0 : m.loading) == null ? void 0 : p.animation) == null ? void 0 : x.barColor) ?? "#000", o = s.length === 4 ? `#${s[1]}${s[1]}${s[2]}${s[2]}${s[3]}${s[3]}` : s, n = parseInt(o.slice(1, 3), 16), h = parseInt(o.slice(3, 5), 16), d = parseInt(o.slice(5, 7), 16), c = `rgba(${n}, ${h}, ${d}, 0.8)`, u = `rgba(${n}, ${h}, ${d}, 0.4)`;
1285
+ return `
1286
+ :host {
1287
+ display: flex;
1288
+ height: 100%;
1289
+ width: ${t}%;
1290
+ align-items: flex-start;
1291
+ justify-content: flex-start;
1292
+ }
1293
+
1294
+ .skeleton-item {
1295
+ height: ${((v = (b = (_ = e.inbox) == null ? void 0 : _.loading) == null ? void 0 : b.animation) == null ? void 0 : v.barHeight) ?? "14px"};
1296
+ width: 100%;
1297
+ background: linear-gradient(
1298
+ 90deg,
1299
+ ${c} 25%,
1300
+ ${u} 50%,
1301
+ ${c} 75%
1302
+ );
1303
+ background-size: 200% 100%;
1304
+ animation: shimmer ${((S = (w = (k = e.inbox) == null ? void 0 : k.loading) == null ? void 0 : w.animation) == null ? void 0 : S.duration) ?? "2s"} ease-in-out infinite;
1305
+ border-radius: ${((I = (M = (E = e.inbox) == null ? void 0 : E.loading) == null ? void 0 : M.animation) == null ? void 0 : I.barBorderRadius) ?? "14px"};
1306
+ }
1307
+
1308
+ @keyframes shimmer {
1309
+ 0% {
1310
+ background-position: 200% 0;
1311
+ }
1312
+ 100% {
1313
+ background-position: -200% 0;
1314
+ }
1315
+ }
1316
+ `;
1317
+ }
1318
+ }
1319
+ customElements.get("courier-skeleton-animated-row") || customElements.define("courier-skeleton-animated-row", Ee);
1320
+ class $e extends Le {
1321
+ constructor(e) {
1322
+ super();
1323
+ a(this, "_theme");
1324
+ this._theme = e;
1325
+ }
1326
+ defaultElement() {
1327
+ const e = document.createElement("div");
1328
+ e.className = "list";
1329
+ const t = document.createElement("style");
1330
+ t.textContent = this.getStyles(), e.appendChild(t);
1331
+ for (let s = 0; s < 3; s++) {
1332
+ const o = new fo(this._theme, 1 / (s + 1));
1333
+ e.appendChild(o);
1334
+ }
1335
+ return this.shadow.appendChild(e), e;
1336
+ }
1337
+ getStyles() {
1338
+ var e, t;
1339
+ return `
1340
+ :host {
1341
+ display: flex;
1342
+ height: 100%;
1343
+ width: 100%;
1344
+ align-items: flex-start;
1345
+ justify-content: flex-start;
1346
+ overflow: hidden;
1347
+ }
1348
+
1349
+ .list {
1350
+ display: flex;
1351
+ flex-direction: column;
1352
+ gap: 8px;
1353
+ width: 100%;
1354
+ overflow: hidden;
1355
+ }
1356
+
1357
+ .list > * {
1358
+ border-bottom: ${((t = (e = this._theme.inbox) == null ? void 0 : e.loading) == null ? void 0 : t.divider) ?? "1px solid red"};
1359
+ }
1360
+
1361
+ .list > *:last-child {
1362
+ border-bottom: none;
1363
+ }
1364
+ `;
1365
+ }
1366
+ }
1367
+ customElements.get("courier-inbox-skeleton-list") || customElements.define("courier-inbox-skeleton-list", $e);
1368
+ class Co extends HTMLElement {
1369
+ constructor(e) {
1370
+ super();
1371
+ // Components
1372
+ a(this, "skeletonLoadingList");
1373
+ a(this, "observer");
1374
+ a(this, "customItem");
1375
+ // Handlers
1376
+ a(this, "onPaginationTrigger");
1377
+ this.onPaginationTrigger = e.onPaginationTrigger, this.customItem = e.customItem;
1378
+ const t = this.attachShadow({ mode: "open" }), s = document.createElement("style");
1379
+ if (s.textContent = this.getStyles(), t.appendChild(s), this.customItem)
1380
+ t.appendChild(this.customItem);
1381
+ else {
1382
+ const o = document.createElement("div");
1383
+ o.className = "skeleton-container", this.skeletonLoadingList = new $e(e.theme), this.skeletonLoadingList.build(void 0), o.appendChild(this.skeletonLoadingList), t.appendChild(o);
1384
+ }
1385
+ this.observer = new IntersectionObserver((o) => {
1386
+ o.forEach((n) => {
1387
+ n.isIntersecting && this.onPaginationTrigger();
1388
+ });
1389
+ }), this.observer.observe(this);
1390
+ }
1391
+ getStyles() {
1392
+ return `
1393
+ :host {
1394
+ padding: 0;
1395
+ margin: 0;
1396
+ box-sizing: border-box;
1397
+ }
1398
+
1399
+ .skeleton-container {
1400
+ height: 150%;
1401
+ }
1402
+ `;
1403
+ }
1404
+ disconnectedCallback() {
1405
+ this.observer.disconnect();
1406
+ }
1407
+ }
1408
+ customElements.get("courier-inbox-pagination-list-item") || customElements.define("courier-inbox-pagination-list-item", Co);
1409
+ class vo extends HTMLElement {
1410
+ constructor(e) {
1411
+ super();
1412
+ // Theme
1413
+ a(this, "_themeSubscription");
1414
+ // State
1415
+ a(this, "_messages", []);
1416
+ a(this, "_feedType", "inbox");
1417
+ a(this, "_isLoading", !0);
1418
+ a(this, "_error", null);
1419
+ a(this, "_canPaginate", !1);
1420
+ // Callbacks
1421
+ a(this, "_onMessageClick", null);
1422
+ a(this, "_onMessageActionClick", null);
1423
+ a(this, "_onMessageLongPress", null);
1424
+ a(this, "_onRefresh");
1425
+ // Factories
1426
+ a(this, "_onPaginationTrigger");
1427
+ a(this, "_listItemFactory");
1428
+ a(this, "_paginationItemFactory");
1429
+ a(this, "_loadingStateFactory");
1430
+ a(this, "_emptyStateFactory");
1431
+ a(this, "_errorStateFactory");
1432
+ this._themeSubscription = e.themeManager.subscribe((o) => {
1433
+ this.refreshTheme();
1434
+ }), this._onRefresh = e.onRefresh, this._onPaginationTrigger = e.onPaginationTrigger, this._onMessageClick = e.onMessageClick, this._onMessageActionClick = e.onMessageActionClick, this._onMessageLongPress = e.onMessageLongPress;
1435
+ const t = this.attachShadow({ mode: "open" }), s = document.createElement("style");
1436
+ s.textContent = this.getStyles(), t.appendChild(s);
1437
+ }
1438
+ // Getters
1439
+ get messages() {
1440
+ return this._messages;
1441
+ }
1442
+ getStyles() {
1443
+ var t;
1444
+ const e = (t = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : t.list;
1445
+ return `
1446
+ :host {
1447
+ flex: 1;
1448
+ width: 100%;
1449
+ background-color: ${(e == null ? void 0 : e.backgroundColor) ?? r.white[500]};
1450
+ }
1451
+
1452
+ ul {
1453
+ list-style: none;
1454
+ padding: 0;
1455
+ margin: 0;
1456
+ height: 100%;
1457
+ }
1458
+ `;
1459
+ }
1460
+ reset() {
1461
+ var t, s;
1462
+ for (; (t = this.shadowRoot) != null && t.firstChild; )
1463
+ this.shadowRoot.removeChild(this.shadowRoot.firstChild);
1464
+ const e = document.createElement("style");
1465
+ e.textContent = this.getStyles(), (s = this.shadowRoot) == null || s.appendChild(e);
1466
+ }
1467
+ setDataSet(e) {
1468
+ this._messages = [...e.messages], this._canPaginate = !!e.canPaginate, this._error = null, this._isLoading = !1, this.render();
1469
+ }
1470
+ addPage(e) {
1471
+ this._messages = [...this._messages, ...e.messages], this._canPaginate = !!e.canPaginate, this._error = null, this._isLoading = !1, this.render();
1472
+ }
1473
+ addMessage(e, t = 0) {
1474
+ this._messages.splice(t, 0, e), this.render();
1475
+ }
1476
+ removeMessage(e = 0) {
1477
+ this._messages.splice(e, 1), this.render();
1478
+ }
1479
+ updateMessage(e, t = 0) {
1480
+ this._messages[t] = e, this.render();
1481
+ }
1482
+ setFeedType(e) {
1483
+ this._feedType = e, this._error = null, this._isLoading = !0, this.render();
1484
+ }
1485
+ setLoading(e) {
1486
+ this._error = null, this._isLoading = e, this.render();
1487
+ }
1488
+ setError(e) {
1489
+ this._error = e, this._isLoading = !1, this._messages = [], this.render();
1490
+ }
1491
+ setErrorNoClient() {
1492
+ this.setError(new Error("No user signed in"));
1493
+ }
1494
+ handleRetry() {
1495
+ this._onRefresh();
1496
+ }
1497
+ handleRefresh() {
1498
+ this._onRefresh();
1499
+ }
1500
+ render() {
1501
+ var s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T, $, D, y, B, F, H, R, z, O, N, U, V, Z, J, q, X, Y, j, se, oe, ne, re, ae, he, ce, le, de, ue, pe, ge, me, be, _e, xe, fe, Ce, ve, ye;
1502
+ this.reset();
1503
+ const e = this._themeSubscription.manager.getTheme();
1504
+ if (this._error) {
1505
+ const l = (s = e.inbox) == null ? void 0 : s.error, P = new Me({
1506
+ title: {
1507
+ text: ((o = l == null ? void 0 : l.title) == null ? void 0 : o.text) ?? this._error.message,
1508
+ textColor: (h = (n = l == null ? void 0 : l.title) == null ? void 0 : n.font) == null ? void 0 : h.color,
1509
+ fontFamily: (c = (d = l == null ? void 0 : l.title) == null ? void 0 : d.font) == null ? void 0 : c.family,
1510
+ fontSize: (m = (u = l == null ? void 0 : l.title) == null ? void 0 : u.font) == null ? void 0 : m.size,
1511
+ fontWeight: (x = (p = l == null ? void 0 : l.title) == null ? void 0 : p.font) == null ? void 0 : x.weight
1512
+ },
1513
+ button: {
1514
+ text: (_ = l == null ? void 0 : l.button) == null ? void 0 : _.text,
1515
+ backgroundColor: (b = l == null ? void 0 : l.button) == null ? void 0 : b.backgroundColor,
1516
+ hoverBackgroundColor: (v = l == null ? void 0 : l.button) == null ? void 0 : v.hoverBackgroundColor,
1517
+ activeBackgroundColor: (k = l == null ? void 0 : l.button) == null ? void 0 : k.activeBackgroundColor,
1518
+ textColor: (S = (w = l == null ? void 0 : l.button) == null ? void 0 : w.font) == null ? void 0 : S.color,
1519
+ fontFamily: (M = (E = l == null ? void 0 : l.button) == null ? void 0 : E.font) == null ? void 0 : M.family,
1520
+ fontSize: (T = (I = l == null ? void 0 : l.button) == null ? void 0 : I.font) == null ? void 0 : T.size,
1521
+ fontWeight: (D = ($ = l == null ? void 0 : l.button) == null ? void 0 : $.font) == null ? void 0 : D.weight,
1522
+ shadow: (y = l == null ? void 0 : l.button) == null ? void 0 : y.shadow,
1523
+ border: (B = l == null ? void 0 : l.button) == null ? void 0 : B.border,
1524
+ borderRadius: (F = l == null ? void 0 : l.button) == null ? void 0 : F.borderRadius
1525
+ }
1526
+ });
1527
+ P.build((H = this._errorStateFactory) == null ? void 0 : H.call(this, { feedType: this._feedType, error: this._error })), P.setButtonClickCallback(() => this.handleRetry()), (R = this.shadowRoot) == null || R.appendChild(P);
1528
+ return;
1529
+ }
1530
+ if (this._isLoading) {
1531
+ const l = new $e(e);
1532
+ l.build((z = this._loadingStateFactory) == null ? void 0 : z.call(this, { feedType: this._feedType })), (O = this.shadowRoot) == null || O.appendChild(l);
1533
+ return;
1534
+ }
1535
+ if (this._messages.length === 0) {
1536
+ const l = (N = e.inbox) == null ? void 0 : N.empty, P = new Me({
1537
+ title: {
1538
+ text: ((U = l == null ? void 0 : l.title) == null ? void 0 : U.text) ?? `No ${this._feedType} messages yet`,
1539
+ textColor: (Z = (V = l == null ? void 0 : l.title) == null ? void 0 : V.font) == null ? void 0 : Z.color,
1540
+ fontFamily: (q = (J = l == null ? void 0 : l.title) == null ? void 0 : J.font) == null ? void 0 : q.family,
1541
+ fontSize: (Y = (X = l == null ? void 0 : l.title) == null ? void 0 : X.font) == null ? void 0 : Y.size,
1542
+ fontWeight: (se = (j = l == null ? void 0 : l.title) == null ? void 0 : j.font) == null ? void 0 : se.weight
1543
+ },
1544
+ button: {
1545
+ text: (oe = l == null ? void 0 : l.button) == null ? void 0 : oe.text,
1546
+ backgroundColor: (ne = l == null ? void 0 : l.button) == null ? void 0 : ne.backgroundColor,
1547
+ hoverBackgroundColor: (re = l == null ? void 0 : l.button) == null ? void 0 : re.hoverBackgroundColor,
1548
+ activeBackgroundColor: (ae = l == null ? void 0 : l.button) == null ? void 0 : ae.activeBackgroundColor,
1549
+ textColor: (ce = (he = l == null ? void 0 : l.button) == null ? void 0 : he.font) == null ? void 0 : ce.color,
1550
+ fontFamily: (de = (le = l == null ? void 0 : l.button) == null ? void 0 : le.font) == null ? void 0 : de.family,
1551
+ fontSize: (pe = (ue = l == null ? void 0 : l.button) == null ? void 0 : ue.font) == null ? void 0 : pe.size,
1552
+ fontWeight: (me = (ge = l == null ? void 0 : l.button) == null ? void 0 : ge.font) == null ? void 0 : me.weight,
1553
+ shadow: (be = l == null ? void 0 : l.button) == null ? void 0 : be.shadow,
1554
+ border: (_e = l == null ? void 0 : l.button) == null ? void 0 : _e.border,
1555
+ borderRadius: (xe = l == null ? void 0 : l.button) == null ? void 0 : xe.borderRadius
1556
+ }
1557
+ });
1558
+ P.build((fe = this._emptyStateFactory) == null ? void 0 : fe.call(this, { feedType: this._feedType })), P.setButtonClickCallback(() => this.handleRefresh()), (Ce = this.shadowRoot) == null || Ce.appendChild(P);
1559
+ return;
1560
+ }
1561
+ const t = document.createElement("ul");
1562
+ if ((ve = this.shadowRoot) == null || ve.appendChild(t), this._messages.forEach((l, P) => {
1563
+ if (this._listItemFactory) {
1564
+ t.appendChild(this._listItemFactory({ message: l, index: P }));
1565
+ return;
1566
+ }
1567
+ const K = new xo(e);
1568
+ K.setMessage(l, this._feedType), K.setOnItemClick((Q) => {
1569
+ var W;
1570
+ return (W = this._onMessageClick) == null ? void 0 : W.call(this, Q, P);
1571
+ }), K.setOnItemActionClick((Q, W) => {
1572
+ var ke;
1573
+ return (ke = this._onMessageActionClick) == null ? void 0 : ke.call(this, Q, W, P);
1574
+ }), K.setOnItemLongPress((Q) => {
1575
+ var W;
1576
+ return (W = this._onMessageLongPress) == null ? void 0 : W.call(this, Q, P);
1577
+ }), t.appendChild(K);
1578
+ }), this._canPaginate) {
1579
+ const l = new Co({
1580
+ theme: e,
1581
+ customItem: (ye = this._paginationItemFactory) == null ? void 0 : ye.call(this, { feedType: this._feedType }),
1582
+ onPaginationTrigger: () => {
1583
+ var P;
1584
+ return (P = this._onPaginationTrigger) == null ? void 0 : P.call(this, this._feedType);
1585
+ }
1586
+ });
1587
+ t.appendChild(l);
1588
+ }
1589
+ }
1590
+ // Factories
1591
+ setLoadingStateFactory(e) {
1592
+ this._loadingStateFactory = e, this.render();
1593
+ }
1594
+ setEmptyStateFactory(e) {
1595
+ this._emptyStateFactory = e, this.render();
1596
+ }
1597
+ setErrorStateFactory(e) {
1598
+ this._errorStateFactory = e, this.render();
1599
+ }
1600
+ setListItemFactory(e) {
1601
+ this._listItemFactory = e, this.render();
1602
+ }
1603
+ setPaginationItemFactory(e) {
1604
+ this._paginationItemFactory = e, this.render();
1605
+ }
1606
+ refreshTheme() {
1607
+ this.render();
1608
+ }
1609
+ // Disconnect the theme subscription
1610
+ disconnectedCallback() {
1611
+ this._themeSubscription.unsubscribe();
1612
+ }
1613
+ }
1614
+ customElements.get("courier-inbox-list") || customElements.define("courier-inbox-list", vo);
1615
+ class yo extends HTMLElement {
1616
+ constructor(e) {
1617
+ super();
1618
+ // State
1619
+ a(this, "_option");
1620
+ a(this, "_isSelected");
1621
+ // Components
1622
+ a(this, "_content");
1623
+ a(this, "_itemIcon");
1624
+ a(this, "_title");
1625
+ a(this, "_selectionIcon");
1626
+ a(this, "_style");
1627
+ // Theme
1628
+ a(this, "_themeManager");
1629
+ this._option = e.option, this._isSelected = e.isSelected, this._themeManager = e.themeManager;
1630
+ const t = this.attachShadow({ mode: "open" });
1631
+ this._style = document.createElement("style"), this._content = document.createElement("div"), this._content.className = "menu-item", this._itemIcon = new ie(this._option.icon.svg ?? f.inbox), this._itemIcon.setAttribute("size", "16"), this._title = document.createElement("p"), this._title.textContent = this._option.text;
1632
+ const s = document.createElement("div");
1633
+ s.className = "spacer", this._selectionIcon = new ie(f.check), this._content.appendChild(this._itemIcon), this._content.appendChild(this._title), this._content.appendChild(s), e.selectable && this._content.appendChild(this._selectionIcon), t.appendChild(this._style), t.appendChild(this._content), this._selectionIcon.style.display = this._isSelected ? "block" : "none", this.refreshTheme();
1634
+ }
1635
+ getStyles() {
1636
+ var t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T, $, D, y, B, F, H, R, z, O, N, U, V, Z;
1637
+ const e = this._themeManager.getTheme();
1638
+ return `
1639
+ :host {
1640
+ display: flex;
1641
+ flex-direction: row;
1642
+ padding: 6px 12px;
1643
+ cursor: pointer;
1644
+ }
1645
+
1646
+ :host(:hover) {
1647
+ background-color: ${((h = (n = (o = (s = (t = e.inbox) == null ? void 0 : t.header) == null ? void 0 : s.menus) == null ? void 0 : o.popup) == null ? void 0 : n.list) == null ? void 0 : h.hoverBackgroundColor) ?? "red"};
1648
+ }
1649
+
1650
+ :host(:active) {
1651
+ background-color: ${((p = (m = (u = (c = (d = e.inbox) == null ? void 0 : d.header) == null ? void 0 : c.menus) == null ? void 0 : u.popup) == null ? void 0 : m.list) == null ? void 0 : p.activeBackgroundColor) ?? "red"};
1652
+ }
1653
+
1654
+ .menu-item {
1655
+ display: flex;
1656
+ align-items: center;
1657
+ width: 100%;
1658
+ gap: 12px;
1659
+ }
1660
+
1661
+ .spacer {
1662
+ flex: 1;
1663
+ }
1664
+
1665
+ p {
1666
+ margin: 0;
1667
+ font-family: ${((w = (k = (v = (b = (_ = (x = e.inbox) == null ? void 0 : x.header) == null ? void 0 : _.menus) == null ? void 0 : b.popup) == null ? void 0 : v.list) == null ? void 0 : k.font) == null ? void 0 : w.family) ?? "inherit"};
1668
+ font-weight: ${(($ = (T = (I = (M = (E = (S = e.inbox) == null ? void 0 : S.header) == null ? void 0 : E.menus) == null ? void 0 : M.popup) == null ? void 0 : I.list) == null ? void 0 : T.font) == null ? void 0 : $.weight) ?? "inherit"};
1669
+ font-size: ${((R = (H = (F = (B = (y = (D = e.inbox) == null ? void 0 : D.header) == null ? void 0 : y.menus) == null ? void 0 : B.popup) == null ? void 0 : F.list) == null ? void 0 : H.font) == null ? void 0 : R.size) ?? "14px"};
1670
+ color: ${((Z = (V = (U = (N = (O = (z = e.inbox) == null ? void 0 : z.header) == null ? void 0 : O.menus) == null ? void 0 : N.popup) == null ? void 0 : U.list) == null ? void 0 : V.font) == null ? void 0 : Z.color) ?? "red"};
1671
+ white-space: nowrap;
1672
+ }
1673
+
1674
+ .check-icon {
1675
+ display: none;
1676
+ }
1677
+ `;
1678
+ }
1679
+ refreshTheme() {
1680
+ var e, t, s, o;
1681
+ this._style.textContent = this.getStyles(), this._selectionIcon.updateColor(((e = this._option.selectionIcon) == null ? void 0 : e.color) ?? "red"), this._selectionIcon.updateSVG(((t = this._option.selectionIcon) == null ? void 0 : t.svg) ?? f.check), this._title.textContent = this._option.text ?? "Missing Text", this._itemIcon.updateColor(((s = this._option.icon) == null ? void 0 : s.color) ?? "red"), this._itemIcon.updateSVG(((o = this._option.icon) == null ? void 0 : o.svg) ?? f.inbox);
1682
+ }
1683
+ }
1684
+ customElements.get("courier-inbox-filter-menu-item") || customElements.define("courier-inbox-filter-menu-item", yo);
1685
+ class Be extends HTMLElement {
1686
+ constructor(e, t, s, o, n) {
1687
+ super();
1688
+ // Theme
1689
+ a(this, "_themeSubscription");
1690
+ // State
1691
+ a(this, "_type");
1692
+ a(this, "_selectedIndex", 0);
1693
+ a(this, "_options");
1694
+ a(this, "_selectable");
1695
+ a(this, "_onMenuOpen");
1696
+ // Components
1697
+ a(this, "_menuButton");
1698
+ a(this, "_menu");
1699
+ a(this, "_style");
1700
+ this._type = t, this._selectable = s, this._options = o, this._selectedIndex = 0, this._onMenuOpen = n;
1701
+ const h = this.attachShadow({ mode: "open" });
1702
+ this._menuButton = new Se(t === "filters" ? f.filter : f.overflow), this._menu = document.createElement("div"), this._menu.className = `menu ${t}`, this._style = document.createElement("style"), h.appendChild(this._style), h.appendChild(this._menuButton), h.appendChild(this._menu), this._menuButton.addEventListener("click", this.toggleMenu.bind(this)), document.addEventListener("click", this.handleOutsideClick.bind(this)), this._themeSubscription = e.subscribe((d) => {
1703
+ this.refreshTheme();
1704
+ }), this.refreshTheme();
1705
+ }
1706
+ getStyles() {
1707
+ var t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T;
1708
+ const e = this._themeSubscription.manager.getTheme();
1709
+ return `
1710
+ :host {
1711
+ position: relative;
1712
+ display: inline-block;
1713
+ }
1714
+
1715
+ .menu {
1716
+ display: none;
1717
+ position: absolute;
1718
+ top: 42px;
1719
+ right: -6px;
1720
+ border-radius: ${((n = (o = (s = (t = e.inbox) == null ? void 0 : t.header) == null ? void 0 : s.menus) == null ? void 0 : o.popup) == null ? void 0 : n.borderRadius) ?? "6px"};
1721
+ border: ${((u = (c = (d = (h = e.inbox) == null ? void 0 : h.header) == null ? void 0 : d.menus) == null ? void 0 : c.popup) == null ? void 0 : u.border) ?? "1px solid red"};
1722
+ background: ${((_ = (x = (p = (m = e.inbox) == null ? void 0 : m.header) == null ? void 0 : p.menus) == null ? void 0 : x.popup) == null ? void 0 : _.backgroundColor) ?? "red"};
1723
+ box-shadow: ${((w = (k = (v = (b = e.inbox) == null ? void 0 : b.header) == null ? void 0 : v.menus) == null ? void 0 : k.popup) == null ? void 0 : w.shadow) ?? "0 4px 12px 0 red"};
1724
+ z-index: 1000;
1725
+ min-width: 200px;
1726
+ overflow: hidden;
1727
+ padding: 4px 0;
1728
+ }
1729
+
1730
+ courier-inbox-filter-menu-item {
1731
+ border-bottom: ${((T = (I = (M = (E = (S = e.inbox) == null ? void 0 : S.header) == null ? void 0 : E.menus) == null ? void 0 : M.popup) == null ? void 0 : I.list) == null ? void 0 : T.divider) ?? "none"};
1732
+ }
1733
+
1734
+ courier-inbox-filter-menu-item:last-child {
1735
+ border-bottom: none;
1736
+ }
1737
+ `;
1738
+ }
1739
+ refreshTheme() {
1740
+ var h, d, c, u, m, p;
1741
+ this._style.textContent = this.getStyles();
1742
+ const t = (d = (h = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : h.header) == null ? void 0 : d.menus, s = this._type === "filters", o = s ? (c = t == null ? void 0 : t.filters) == null ? void 0 : c.button : (u = t == null ? void 0 : t.actions) == null ? void 0 : u.button, n = s ? f.filter : f.overflow;
1743
+ this._menuButton.updateIconSVG(((m = o == null ? void 0 : o.icon) == null ? void 0 : m.svg) ?? n), this._menuButton.updateIconColor(((p = o == null ? void 0 : o.icon) == null ? void 0 : p.color) ?? "red"), this._menuButton.updateBackgroundColor((o == null ? void 0 : o.backgroundColor) ?? "transparent"), this._menuButton.updateHoverBackgroundColor((o == null ? void 0 : o.hoverBackgroundColor) ?? "red"), this._menuButton.updateActiveBackgroundColor((o == null ? void 0 : o.activeBackgroundColor) ?? "red"), this.refreshMenuItems();
1744
+ }
1745
+ setOptions(e) {
1746
+ this._options = e, this.refreshMenuItems();
1747
+ }
1748
+ refreshMenuItems() {
1749
+ this._menu.innerHTML = "", this._options.forEach((e, t) => {
1750
+ const s = new yo({
1751
+ option: e,
1752
+ selectable: this._selectable,
1753
+ isSelected: this._selectedIndex === t,
1754
+ themeManager: this._themeSubscription.manager
1755
+ });
1756
+ s.addEventListener("click", () => {
1757
+ this._selectedIndex = t, e.onClick(e), this.refreshMenuItems(), this.closeMenu();
1758
+ }), this._menu.appendChild(s);
1759
+ });
1760
+ }
1761
+ toggleMenu(e) {
1762
+ e.stopPropagation();
1763
+ const t = this._menu.style.display !== "block";
1764
+ this._menu.style.display = t ? "block" : "none", t && this._onMenuOpen();
1765
+ }
1766
+ handleOutsideClick(e) {
1767
+ this.contains(e.target) || this.closeMenu();
1768
+ }
1769
+ closeMenu() {
1770
+ this._menu.style.display = "none";
1771
+ }
1772
+ selectOption(e) {
1773
+ this._selectedIndex = this._options.findIndex((t) => t.id === e.id), this.refreshMenuItems();
1774
+ }
1775
+ disconnectedCallback() {
1776
+ this._themeSubscription.unsubscribe();
1777
+ }
1778
+ }
1779
+ customElements.get("courier-inbox-option-menu") || customElements.define("courier-inbox-option-menu", Be);
1780
+ class De extends HTMLElement {
1781
+ constructor(e) {
1782
+ super();
1783
+ // Theme
1784
+ a(this, "_themeSubscription");
1785
+ // State
1786
+ a(this, "_location");
1787
+ a(this, "_count", 0);
1788
+ // Elements
1789
+ a(this, "_badge");
1790
+ a(this, "_style");
1791
+ this._location = e.location, this._themeSubscription = e.themeBus.subscribe((s) => {
1792
+ this.refreshTheme(this._location);
1793
+ });
1794
+ const t = this.attachShadow({ mode: "open" });
1795
+ this._badge = document.createElement("span"), this._badge.className = "unread-badge", this._style = document.createElement("style"), this._style.textContent = this.getStyles(this._location), t.appendChild(this._style), t.appendChild(this._badge);
1796
+ }
1797
+ getStyles(e) {
1798
+ var c, u, m, p, x, _, b;
1799
+ const t = this._themeSubscription.manager.getTheme(), s = e === "button" ? (u = (c = t.popup) == null ? void 0 : c.button) == null ? void 0 : u.unreadIndicator : (x = (p = (m = t.inbox) == null ? void 0 : m.header) == null ? void 0 : p.filters) == null ? void 0 : x.unreadIndicator, o = s == null ? void 0 : s.backgroundColor, n = s == null ? void 0 : s.borderRadius, h = (_ = s == null ? void 0 : s.font) == null ? void 0 : _.color, d = (b = s == null ? void 0 : s.font) == null ? void 0 : b.size;
1800
+ return `
1801
+ :host {
1802
+ display: inline-block;
1803
+ }
1804
+
1805
+ .unread-badge {
1806
+ background-color: ${o};
1807
+ color: ${h};
1808
+ border-radius: ${n};
1809
+ padding: 4px 8px;
1810
+ font-size: ${d};
1811
+ text-align: center;
1812
+ display: none;
1813
+ pointer-events: none;
1814
+ }
1815
+ `;
1816
+ }
1817
+ setCount(e) {
1818
+ this._count = e, this.updateBadge();
1819
+ }
1820
+ refreshTheme(e) {
1821
+ this._location = e, this.updateBadge();
1822
+ }
1823
+ updateBadge() {
1824
+ this._style.textContent = this.getStyles(this._location), this._count > 0 ? (this._badge.textContent = this._count.toString(), this._badge.style.display = "block") : this._badge.style.display = "none";
1825
+ }
1826
+ disconnectedCallback() {
1827
+ this._themeSubscription.unsubscribe();
1828
+ }
1829
+ }
1830
+ customElements.get("courier-unread-count-badge") || customElements.define("courier-unread-count-badge", De);
1831
+ class ko extends HTMLElement {
1832
+ constructor(e, t) {
1833
+ super();
1834
+ // Theme
1835
+ a(this, "_themeSubscription");
1836
+ // State
1837
+ a(this, "_option");
1838
+ a(this, "_feedType");
1839
+ // Components
1840
+ a(this, "_titleElement");
1841
+ a(this, "_iconElement");
1842
+ a(this, "_unreadBadge");
1843
+ a(this, "_container");
1844
+ a(this, "_style");
1845
+ this._option = t;
1846
+ const s = this.attachShadow({ mode: "open" });
1847
+ this._style = document.createElement("style"), this._container = document.createElement("div"), this._container.className = "title-section", this._iconElement = new ie(void 0, this._option.icon.svg), this._titleElement = document.createElement("h2"), this._unreadBadge = new De({
1848
+ themeBus: e,
1849
+ location: "header"
1850
+ }), this._container.appendChild(this._iconElement), this._container.appendChild(this._titleElement), this._container.appendChild(this._unreadBadge), s.appendChild(this._style), s.appendChild(this._container), this._themeSubscription = e.subscribe((o) => {
1851
+ this.refreshTheme(this._feedType ?? "inbox");
1852
+ }), this.refreshTheme(this._feedType ?? "inbox");
1853
+ }
1854
+ getStyles() {
1855
+ var t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w;
1856
+ const e = this._themeSubscription.manager.getTheme();
1857
+ return `
1858
+ .title-section {
1859
+ display: flex;
1860
+ align-items: center;
1861
+ gap: 8px;
1862
+ position: relative;
1863
+ }
1864
+
1865
+ courier-icon {
1866
+ display: flex;
1867
+ align-items: center;
1868
+ }
1869
+
1870
+ h2 {
1871
+ margin: 0;
1872
+ font-family: ${((n = (o = (s = (t = e.inbox) == null ? void 0 : t.header) == null ? void 0 : s.filters) == null ? void 0 : o.font) == null ? void 0 : n.family) ?? "inherit"};
1873
+ font-size: ${((u = (c = (d = (h = e.inbox) == null ? void 0 : h.header) == null ? void 0 : d.filters) == null ? void 0 : c.font) == null ? void 0 : u.size) ?? "18px"};
1874
+ font-weight: ${((_ = (x = (p = (m = e.inbox) == null ? void 0 : m.header) == null ? void 0 : p.filters) == null ? void 0 : x.font) == null ? void 0 : _.weight) ?? "500"};
1875
+ color: ${((w = (k = (v = (b = e.inbox) == null ? void 0 : b.header) == null ? void 0 : v.filters) == null ? void 0 : k.font) == null ? void 0 : w.color) ?? "red"};
1876
+ }
1877
+
1878
+ courier-unread-count-badge {
1879
+ margin-left: 4px;
1880
+ }
1881
+ `;
1882
+ }
1883
+ refreshTheme(e) {
1884
+ this._feedType = e, this._style.textContent = this.getStyles(), this._unreadBadge.refreshTheme("header"), this.updateFilter();
1885
+ }
1886
+ updateSelectedOption(e, t, s) {
1887
+ this._option = e, this._feedType = t, this._unreadBadge.setCount(s), this.updateFilter();
1888
+ }
1889
+ updateFilter() {
1890
+ var t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T, $, D, y, B, F, H, R;
1891
+ const e = this._themeSubscription.manager.getTheme();
1892
+ switch (this._feedType) {
1893
+ case "inbox":
1894
+ this._titleElement.textContent = ((n = (o = (s = (t = e.inbox) == null ? void 0 : t.header) == null ? void 0 : s.filters) == null ? void 0 : o.inbox) == null ? void 0 : n.text) ?? "Inbox", this._iconElement.updateSVG(((m = (u = (c = (d = (h = e.inbox) == null ? void 0 : h.header) == null ? void 0 : d.filters) == null ? void 0 : c.inbox) == null ? void 0 : u.icon) == null ? void 0 : m.svg) ?? f.inbox), this._iconElement.updateColor(((v = (b = (_ = (x = (p = e.inbox) == null ? void 0 : p.header) == null ? void 0 : x.filters) == null ? void 0 : _.inbox) == null ? void 0 : b.icon) == null ? void 0 : v.color) ?? "red");
1895
+ break;
1896
+ case "archive":
1897
+ this._titleElement.textContent = ((E = (S = (w = (k = e.inbox) == null ? void 0 : k.header) == null ? void 0 : w.filters) == null ? void 0 : S.archive) == null ? void 0 : E.text) ?? "Archive", this._iconElement.updateSVG(((D = ($ = (T = (I = (M = e.inbox) == null ? void 0 : M.header) == null ? void 0 : I.filters) == null ? void 0 : T.archive) == null ? void 0 : $.icon) == null ? void 0 : D.svg) ?? f.archive), this._iconElement.updateColor(((R = (H = (F = (B = (y = e.inbox) == null ? void 0 : y.header) == null ? void 0 : B.filters) == null ? void 0 : F.archive) == null ? void 0 : H.icon) == null ? void 0 : R.color) ?? "red");
1898
+ break;
1899
+ }
1900
+ }
1901
+ // Disconnect the theme subscription
1902
+ disconnectedCallback() {
1903
+ this._themeSubscription.unsubscribe();
1904
+ }
1905
+ }
1906
+ customElements.get("courier-inbox-header-title") || customElements.define("courier-inbox-header-title", ko);
1907
+ class wo extends Le {
1908
+ constructor(e) {
1909
+ super();
1910
+ // Theme
1911
+ a(this, "_themeSubscription");
1912
+ // State
1913
+ a(this, "_feedType", "inbox");
1914
+ a(this, "_unreadCount", 0);
1915
+ // Components
1916
+ a(this, "_titleSection");
1917
+ a(this, "_filterMenu");
1918
+ a(this, "_actionMenu");
1919
+ a(this, "_style");
1920
+ // Callbacks
1921
+ a(this, "_onFeedTypeChange");
1922
+ this._themeSubscription = e.themeManager.subscribe((t) => {
1923
+ this.refreshTheme();
1924
+ }), this._onFeedTypeChange = e.onFeedTypeChange;
1925
+ }
1926
+ // Menu options
1927
+ getFilterOptions() {
1928
+ var s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T, $, D, y, B, F, H, R, z, O, N, U, V, Z, J, q, X, Y;
1929
+ const e = this._themeSubscription.manager.getTheme(), t = (n = (o = (s = e.inbox) == null ? void 0 : s.header) == null ? void 0 : o.menus) == null ? void 0 : n.filters;
1930
+ return [
1931
+ {
1932
+ id: "inbox",
1933
+ text: ((h = t == null ? void 0 : t.inbox) == null ? void 0 : h.text) ?? "Inbox",
1934
+ icon: {
1935
+ color: ((c = (d = t == null ? void 0 : t.inbox) == null ? void 0 : d.icon) == null ? void 0 : c.color) ?? "red",
1936
+ svg: ((m = (u = t == null ? void 0 : t.inbox) == null ? void 0 : u.icon) == null ? void 0 : m.svg) ?? f.inbox
1937
+ },
1938
+ selectionIcon: {
1939
+ color: ((k = (v = (b = (_ = (x = (p = e.inbox) == null ? void 0 : p.header) == null ? void 0 : x.menus) == null ? void 0 : _.popup) == null ? void 0 : b.list) == null ? void 0 : v.selectionIcon) == null ? void 0 : k.color) ?? "red",
1940
+ svg: ((T = (I = (M = (E = (S = (w = e.inbox) == null ? void 0 : w.header) == null ? void 0 : S.menus) == null ? void 0 : E.popup) == null ? void 0 : M.list) == null ? void 0 : I.selectionIcon) == null ? void 0 : T.svg) ?? f.check
1941
+ },
1942
+ onClick: (j) => {
1943
+ this.handleOptionMenuItemClick("inbox", j);
1944
+ }
1945
+ },
1946
+ {
1947
+ id: "archive",
1948
+ text: (($ = t == null ? void 0 : t.archive) == null ? void 0 : $.text) ?? "Archive",
1949
+ icon: {
1950
+ color: ((y = (D = t == null ? void 0 : t.archive) == null ? void 0 : D.icon) == null ? void 0 : y.color) ?? "red",
1951
+ svg: ((F = (B = t == null ? void 0 : t.archive) == null ? void 0 : B.icon) == null ? void 0 : F.svg) ?? f.archive
1952
+ },
1953
+ selectionIcon: {
1954
+ color: ((U = (N = (O = (z = (R = (H = e.inbox) == null ? void 0 : H.header) == null ? void 0 : R.menus) == null ? void 0 : z.popup) == null ? void 0 : O.list) == null ? void 0 : N.selectionIcon) == null ? void 0 : U.color) ?? "red",
1955
+ svg: ((Y = (X = (q = (J = (Z = (V = e.inbox) == null ? void 0 : V.header) == null ? void 0 : Z.menus) == null ? void 0 : J.popup) == null ? void 0 : q.list) == null ? void 0 : X.selectionIcon) == null ? void 0 : Y.svg) ?? f.check
1956
+ },
1957
+ onClick: (j) => {
1958
+ this.handleOptionMenuItemClick("archive", j);
1959
+ }
1960
+ }
1961
+ ];
1962
+ }
1963
+ getActionOptions() {
1964
+ var s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M;
1965
+ const t = (n = (o = (s = this._themeSubscription.manager.getTheme().inbox) == null ? void 0 : s.header) == null ? void 0 : o.menus) == null ? void 0 : n.actions;
1966
+ return [
1967
+ {
1968
+ id: "markAllRead",
1969
+ text: ((h = t == null ? void 0 : t.markAllRead) == null ? void 0 : h.text) ?? "Mark All as Read",
1970
+ icon: {
1971
+ color: ((c = (d = t == null ? void 0 : t.markAllRead) == null ? void 0 : d.icon) == null ? void 0 : c.color) ?? "red",
1972
+ svg: ((m = (u = t == null ? void 0 : t.markAllRead) == null ? void 0 : u.icon) == null ? void 0 : m.svg) ?? f.inbox
1973
+ },
1974
+ selectionIcon: null,
1975
+ onClick: (I) => {
1976
+ A.shared.readAllMessages();
1977
+ }
1978
+ },
1979
+ {
1980
+ id: "archiveAll",
1981
+ text: ((p = t == null ? void 0 : t.archiveAll) == null ? void 0 : p.text) ?? "Archive All",
1982
+ icon: {
1983
+ color: ((_ = (x = t == null ? void 0 : t.archiveAll) == null ? void 0 : x.icon) == null ? void 0 : _.color) ?? "red",
1984
+ svg: ((v = (b = t == null ? void 0 : t.archiveAll) == null ? void 0 : b.icon) == null ? void 0 : v.svg) ?? f.archive
1985
+ },
1986
+ selectionIcon: null,
1987
+ onClick: (I) => {
1988
+ var T;
1989
+ alert(JSON.stringify((T = C.shared.client) == null ? void 0 : T.options));
1990
+ }
1991
+ },
1992
+ {
1993
+ id: "archiveRead",
1994
+ text: ((k = t == null ? void 0 : t.archiveRead) == null ? void 0 : k.text) ?? "Archive Read",
1995
+ icon: {
1996
+ color: ((S = (w = t == null ? void 0 : t.archiveRead) == null ? void 0 : w.icon) == null ? void 0 : S.color) ?? "red",
1997
+ svg: ((M = (E = t == null ? void 0 : t.archiveRead) == null ? void 0 : E.icon) == null ? void 0 : M.svg) ?? f.archive
1998
+ },
1999
+ selectionIcon: null,
2000
+ onClick: (I) => {
2001
+ alert("TODO: Archive read messages");
2002
+ }
2003
+ }
2004
+ ];
2005
+ }
2006
+ static get observedAttributes() {
2007
+ return ["icon", "title", "feed-type"];
2008
+ }
2009
+ refreshTheme() {
2010
+ var s, o, n, h, d, c, u;
2011
+ const e = this._themeSubscription.manager.getTheme(), t = (s = this.shadow) == null ? void 0 : s.querySelector(".courier-inbox-header");
2012
+ t && (t.style.backgroundColor = ((n = (o = e.inbox) == null ? void 0 : o.header) == null ? void 0 : n.backgroundColor) ?? r.white[500], t.style.boxShadow = ((d = (h = e.inbox) == null ? void 0 : h.header) == null ? void 0 : d.shadow) ?? `0px 1px 0px 0px ${r.gray[500]}`), (c = this._filterMenu) == null || c.setOptions(this.getFilterOptions()), (u = this._actionMenu) == null || u.setOptions(this.getActionOptions());
2013
+ }
2014
+ handleOptionMenuItemClick(e, t) {
2015
+ this._feedType = e, this._titleSection && this._titleSection.updateSelectedOption(t, this._feedType, this._feedType === "inbox" ? this._unreadCount : 0), this._onFeedTypeChange(e);
2016
+ }
2017
+ render(e) {
2018
+ this._feedType = e.feedType, this._unreadCount = e.unreadCount, this.refreshTitleSection();
2019
+ }
2020
+ refreshTitleSection() {
2021
+ var t, s;
2022
+ const e = this.getFilterOptions().find((o) => ["inbox", "archive"].includes(o.id) && o.id === this._feedType);
2023
+ e && ((t = this._titleSection) == null || t.updateSelectedOption(e, this._feedType, this._feedType === "inbox" ? this._unreadCount : 0), (s = this._filterMenu) == null || s.selectOption(e));
2024
+ }
2025
+ build(e) {
2026
+ var t;
2027
+ super.build(e), this._style = document.createElement("style"), this._style.textContent = this.getStyles(), (t = this.shadow) == null || t.appendChild(this._style), this.refreshTheme();
2028
+ }
2029
+ defaultElement() {
2030
+ const e = this.getFilterOptions();
2031
+ this._titleSection = new ko(this._themeSubscription.manager, e[0]), this._filterMenu = new Be(this._themeSubscription.manager, "filters", !0, e, () => {
2032
+ var n;
2033
+ (n = this._actionMenu) == null || n.closeMenu();
2034
+ }), this._actionMenu = new Be(this._themeSubscription.manager, "actions", !1, this.getActionOptions(), () => {
2035
+ var n;
2036
+ (n = this._filterMenu) == null || n.closeMenu();
2037
+ }), this._filterMenu.selectOption(e[0]);
2038
+ const t = document.createElement("div");
2039
+ t.className = "spacer";
2040
+ const s = document.createElement("div");
2041
+ s.className = "actions", s.appendChild(this._filterMenu), s.appendChild(this._actionMenu);
2042
+ const o = document.createElement("div");
2043
+ return o.className = "courier-inbox-header", o.appendChild(this._titleSection), o.appendChild(t), o.appendChild(s), o;
2044
+ }
2045
+ getStyles() {
2046
+ return `
2047
+ :host {
2048
+ z-index: 100;
2049
+ }
2050
+
2051
+ .courier-inbox-header {
2052
+ display: flex;
2053
+ align-items: center;
2054
+ justify-content: space-between;
2055
+ padding: 10px 10px 10px 16px;
2056
+ background-color: ${r.white[500]};
2057
+ box-shadow: 0px 1px 0px 0px ${r.gray[500]};
2058
+ }
2059
+
2060
+ .header-content {
2061
+ display: flex;
2062
+ align-items: center;
2063
+ flex: 1;
2064
+ }
2065
+
2066
+ .spacer {
2067
+ flex: 1;
2068
+ }
2069
+
2070
+ .actions {
2071
+ display: flex;
2072
+ align-items: center;
2073
+ gap: 4px;
2074
+ }
2075
+ `;
2076
+ }
2077
+ // Disconnect the theme subscription
2078
+ disconnectedCallback() {
2079
+ this._themeSubscription.unsubscribe();
2080
+ }
2081
+ }
2082
+ customElements.get("courier-inbox-header") || customElements.define("courier-inbox-header", wo);
2083
+ class So {
2084
+ constructor(i) {
2085
+ a(this, "events");
2086
+ this.events = i;
2087
+ }
2088
+ remove() {
2089
+ A.shared.removeDataStoreListener(this);
2090
+ }
2091
+ }
2092
+ const we = {
2093
+ popup: {
2094
+ button: {
2095
+ icon: {
2096
+ color: r.black[500],
2097
+ svg: f.inbox
2098
+ },
2099
+ backgroundColor: "transparent",
2100
+ hoverBackgroundColor: r.black[50010],
2101
+ activeBackgroundColor: r.black[50020],
2102
+ unreadIndicator: {
2103
+ font: {
2104
+ color: r.white[500],
2105
+ size: "14px",
2106
+ family: void 0,
2107
+ weight: void 0
2108
+ },
2109
+ backgroundColor: r.blue[500],
2110
+ borderRadius: "12px"
2111
+ }
2112
+ },
2113
+ window: {
2114
+ backgroundColor: r.white[500],
2115
+ borderRadius: "8px",
2116
+ border: `1px solid ${r.gray[500]}`,
2117
+ shadow: `0px 8px 16px -4px ${r.gray[500]}`
2118
+ }
2119
+ },
2120
+ inbox: {
2121
+ header: {
2122
+ backgroundColor: r.white[500],
2123
+ shadow: `0px 1px 0px 0px ${r.gray[500]}`,
2124
+ filters: {
2125
+ font: {
2126
+ color: r.black[500],
2127
+ family: void 0,
2128
+ size: "18px"
2129
+ },
2130
+ inbox: {
2131
+ icon: {
2132
+ color: r.black[500],
2133
+ svg: f.inbox
2134
+ },
2135
+ text: "Inbox"
2136
+ },
2137
+ archive: {
2138
+ icon: {
2139
+ color: r.black[500],
2140
+ svg: f.archive
2141
+ },
2142
+ text: "Archive"
2143
+ },
2144
+ unreadIndicator: {
2145
+ font: {
2146
+ color: r.white[500],
2147
+ family: void 0,
2148
+ size: "14px"
2149
+ },
2150
+ backgroundColor: r.blue[500],
2151
+ borderRadius: "12px"
2152
+ }
2153
+ },
2154
+ menus: {
2155
+ popup: {
2156
+ backgroundColor: r.white[500],
2157
+ border: `1px solid ${r.gray[500]}`,
2158
+ borderRadius: "4px",
2159
+ shadow: `0px 4px 8px -2px ${r.gray[500]}`,
2160
+ list: {
2161
+ hoverBackgroundColor: r.gray[200],
2162
+ activeBackgroundColor: r.gray[500],
2163
+ divider: "none",
2164
+ font: {
2165
+ color: r.black[500],
2166
+ family: void 0,
2167
+ size: "14px"
2168
+ },
2169
+ selectionIcon: {
2170
+ color: r.black[500],
2171
+ svg: f.check
2172
+ }
2173
+ }
2174
+ },
2175
+ filters: {
2176
+ button: {
2177
+ icon: {
2178
+ color: r.black[500],
2179
+ svg: f.filter
2180
+ },
2181
+ backgroundColor: "transparent",
2182
+ hoverBackgroundColor: r.black[50010],
2183
+ activeBackgroundColor: r.black[50020]
2184
+ },
2185
+ inbox: {
2186
+ icon: {
2187
+ color: r.black[500],
2188
+ svg: f.inbox
2189
+ },
2190
+ text: "Inbox"
2191
+ },
2192
+ archive: {
2193
+ icon: {
2194
+ color: r.black[500],
2195
+ svg: f.archive
2196
+ },
2197
+ text: "Archive"
2198
+ }
2199
+ },
2200
+ actions: {
2201
+ button: {
2202
+ icon: {
2203
+ color: r.black[500],
2204
+ svg: f.overflow
2205
+ },
2206
+ backgroundColor: "transparent",
2207
+ hoverBackgroundColor: r.black[50010],
2208
+ activeBackgroundColor: r.black[50020]
2209
+ },
2210
+ markAllRead: {
2211
+ icon: {
2212
+ color: r.black[500],
2213
+ svg: f.read
2214
+ },
2215
+ text: "Mark All as Read"
2216
+ },
2217
+ archiveAll: {
2218
+ icon: {
2219
+ color: r.black[500],
2220
+ svg: f.archive
2221
+ },
2222
+ text: "Archive All"
2223
+ },
2224
+ archiveRead: {
2225
+ icon: {
2226
+ color: r.black[500],
2227
+ svg: f.archiveRead
2228
+ },
2229
+ text: "Archive Read"
2230
+ }
2231
+ }
2232
+ }
2233
+ },
2234
+ list: {
2235
+ backgroundColor: r.white[500],
2236
+ item: {
2237
+ backgroundColor: "transparent",
2238
+ unreadIndicatorColor: r.blue[500],
2239
+ hoverBackgroundColor: r.gray[200],
2240
+ activeBackgroundColor: r.gray[500],
2241
+ actions: {
2242
+ backgroundColor: "transparent",
2243
+ hoverBackgroundColor: r.gray[200],
2244
+ activeBackgroundColor: r.gray[500],
2245
+ border: `1px solid ${r.gray[500]}`,
2246
+ borderRadius: "4px",
2247
+ shadow: "0px 1px 2px 0px rgba(0, 0, 0, 0.06)",
2248
+ font: {
2249
+ color: r.black[500],
2250
+ family: void 0,
2251
+ size: "14px"
2252
+ }
2253
+ },
2254
+ title: {
2255
+ color: r.black[500],
2256
+ family: void 0,
2257
+ size: "14px"
2258
+ },
2259
+ subtitle: {
2260
+ color: r.gray[600],
2261
+ family: void 0,
2262
+ size: "14px"
2263
+ },
2264
+ time: {
2265
+ color: r.gray[600],
2266
+ family: void 0,
2267
+ size: "14px"
2268
+ },
2269
+ divider: `1px solid ${r.gray[200]}`,
2270
+ menu: {
2271
+ enabled: !0,
2272
+ backgroundColor: r.white[500],
2273
+ border: `1px solid ${r.gray[500]}`,
2274
+ borderRadius: "4px",
2275
+ shadow: `0px 2px 4px -2px ${r.gray[500]}`,
2276
+ longPress: {
2277
+ displayDuration: 4e3,
2278
+ vibrationDuration: 50
2279
+ },
2280
+ item: {
2281
+ hoverBackgroundColor: r.gray[200],
2282
+ activeBackgroundColor: r.gray[500],
2283
+ borderRadius: "0px",
2284
+ read: {
2285
+ color: r.black[500],
2286
+ svg: f.read
2287
+ },
2288
+ unread: {
2289
+ color: r.black[500],
2290
+ svg: f.unread
2291
+ },
2292
+ archive: {
2293
+ color: r.black[500],
2294
+ svg: f.archive
2295
+ },
2296
+ unarchive: {
2297
+ color: r.black[500],
2298
+ svg: f.unarchive
2299
+ }
2300
+ }
2301
+ }
2302
+ }
2303
+ },
2304
+ loading: {
2305
+ animation: {
2306
+ barColor: r.gray[500],
2307
+ barHeight: "14px",
2308
+ barBorderRadius: "14px",
2309
+ duration: "2s"
2310
+ },
2311
+ divider: `1px solid ${r.gray[200]}`
2312
+ },
2313
+ empty: {
2314
+ title: {
2315
+ font: {
2316
+ size: "16px",
2317
+ weight: "500",
2318
+ color: r.black[500]
2319
+ }
2320
+ },
2321
+ button: {
2322
+ text: "Refresh"
2323
+ }
2324
+ },
2325
+ error: {
2326
+ title: {
2327
+ font: {
2328
+ size: "16px",
2329
+ weight: "500",
2330
+ color: r.black[500]
2331
+ }
2332
+ },
2333
+ button: {
2334
+ text: "Retry"
2335
+ }
2336
+ }
2337
+ }
2338
+ }, Ae = {
2339
+ popup: {
2340
+ button: {
2341
+ icon: {
2342
+ color: r.white[500],
2343
+ svg: f.inbox
2344
+ },
2345
+ backgroundColor: "transparent",
2346
+ hoverBackgroundColor: r.white[50010],
2347
+ activeBackgroundColor: r.white[50020],
2348
+ unreadIndicator: {
2349
+ font: {
2350
+ color: r.white[500],
2351
+ size: "14px",
2352
+ family: void 0,
2353
+ weight: void 0
2354
+ },
2355
+ backgroundColor: r.blue[500],
2356
+ borderRadius: "12px"
2357
+ }
2358
+ },
2359
+ window: {
2360
+ backgroundColor: r.black[500],
2361
+ borderRadius: "8px",
2362
+ border: `1px solid ${r.gray[400]}`,
2363
+ shadow: `0px 4px 8px -2px ${r.white[50020]}`
2364
+ }
2365
+ },
2366
+ inbox: {
2367
+ header: {
2368
+ backgroundColor: r.black[500],
2369
+ shadow: `0px 1px 0px 0px ${r.gray[400]}`,
2370
+ filters: {
2371
+ font: {
2372
+ color: r.white[500],
2373
+ family: void 0,
2374
+ size: "18px"
2375
+ },
2376
+ inbox: {
2377
+ icon: {
2378
+ color: r.white[500],
2379
+ svg: f.inbox
2380
+ },
2381
+ text: "Inbox"
2382
+ },
2383
+ archive: {
2384
+ icon: {
2385
+ color: r.white[500],
2386
+ svg: f.archive
2387
+ },
2388
+ text: "Archive"
2389
+ },
2390
+ unreadIndicator: {
2391
+ font: {
2392
+ color: r.white[500],
2393
+ family: void 0,
2394
+ size: "14px"
2395
+ },
2396
+ backgroundColor: r.blue[500],
2397
+ borderRadius: "12px"
2398
+ }
2399
+ },
2400
+ menus: {
2401
+ popup: {
2402
+ backgroundColor: r.black[500],
2403
+ border: `1px solid ${r.gray[400]}`,
2404
+ borderRadius: "4px",
2405
+ shadow: `0px 4px 8px -2px ${r.white[50020]}`,
2406
+ list: {
2407
+ hoverBackgroundColor: r.white[50010],
2408
+ activeBackgroundColor: r.white[50020],
2409
+ divider: "none",
2410
+ font: {
2411
+ color: r.white[500],
2412
+ family: void 0,
2413
+ size: "14px"
2414
+ },
2415
+ selectionIcon: {
2416
+ color: r.white[500],
2417
+ svg: f.check
2418
+ }
2419
+ }
2420
+ },
2421
+ filters: {
2422
+ button: {
2423
+ icon: {
2424
+ color: r.white[500],
2425
+ svg: f.filter
2426
+ },
2427
+ backgroundColor: "transparent",
2428
+ hoverBackgroundColor: r.white[50010],
2429
+ activeBackgroundColor: r.white[50020]
2430
+ },
2431
+ inbox: {
2432
+ icon: {
2433
+ color: r.white[500],
2434
+ svg: f.inbox
2435
+ },
2436
+ text: "Inbox"
2437
+ },
2438
+ archive: {
2439
+ icon: {
2440
+ color: r.white[500],
2441
+ svg: f.archive
2442
+ },
2443
+ text: "Archive"
2444
+ }
2445
+ },
2446
+ actions: {
2447
+ button: {
2448
+ icon: {
2449
+ color: r.white[500],
2450
+ svg: f.overflow
2451
+ },
2452
+ backgroundColor: "transparent",
2453
+ hoverBackgroundColor: r.white[50010],
2454
+ activeBackgroundColor: r.white[50020]
2455
+ },
2456
+ markAllRead: {
2457
+ icon: {
2458
+ color: r.white[500],
2459
+ svg: f.read
2460
+ },
2461
+ text: "Mark All as Read"
2462
+ },
2463
+ archiveAll: {
2464
+ icon: {
2465
+ color: r.white[500],
2466
+ svg: f.archive
2467
+ },
2468
+ text: "Archive All"
2469
+ },
2470
+ archiveRead: {
2471
+ icon: {
2472
+ color: r.white[500],
2473
+ svg: f.archiveRead
2474
+ },
2475
+ text: "Archive Read"
2476
+ }
2477
+ }
2478
+ }
2479
+ },
2480
+ list: {
2481
+ backgroundColor: r.black[500],
2482
+ item: {
2483
+ backgroundColor: "transparent",
2484
+ unreadIndicatorColor: r.blue[500],
2485
+ hoverBackgroundColor: r.white[50010],
2486
+ activeBackgroundColor: r.white[50020],
2487
+ actions: {
2488
+ backgroundColor: "transparent",
2489
+ hoverBackgroundColor: r.white[50010],
2490
+ activeBackgroundColor: r.white[50020],
2491
+ border: `1px solid ${r.gray[400]}`,
2492
+ borderRadius: "4px",
2493
+ shadow: `0px 1px 2px 0px ${r.white[50010]}`,
2494
+ font: {
2495
+ color: r.white[500],
2496
+ family: void 0,
2497
+ size: "14px"
2498
+ }
2499
+ },
2500
+ title: {
2501
+ color: r.white[500],
2502
+ family: void 0,
2503
+ size: "14px"
2504
+ },
2505
+ subtitle: {
2506
+ color: r.gray[500],
2507
+ family: void 0,
2508
+ size: "14px"
2509
+ },
2510
+ time: {
2511
+ color: r.gray[500],
2512
+ family: void 0,
2513
+ size: "12px"
2514
+ },
2515
+ divider: `1px solid ${r.gray[400]}`,
2516
+ menu: {
2517
+ enabled: !0,
2518
+ backgroundColor: r.black[500],
2519
+ border: `1px solid ${r.gray[400]}`,
2520
+ borderRadius: "4px",
2521
+ shadow: `0px 2px 4px -2px ${r.white[50020]}`,
2522
+ longPress: {
2523
+ displayDuration: 4e3,
2524
+ vibrationDuration: 50
2525
+ },
2526
+ item: {
2527
+ hoverBackgroundColor: r.white[50010],
2528
+ activeBackgroundColor: r.white[50020],
2529
+ borderRadius: "0px",
2530
+ read: {
2531
+ color: r.white[500],
2532
+ svg: f.read
2533
+ },
2534
+ unread: {
2535
+ color: r.white[500],
2536
+ svg: f.unread
2537
+ },
2538
+ archive: {
2539
+ color: r.white[500],
2540
+ svg: f.archive
2541
+ },
2542
+ unarchive: {
2543
+ color: r.white[500],
2544
+ svg: f.unarchive
2545
+ }
2546
+ }
2547
+ }
2548
+ }
2549
+ },
2550
+ loading: {
2551
+ animation: {
2552
+ barColor: r.white[500],
2553
+ barHeight: "14px",
2554
+ barBorderRadius: "14px",
2555
+ duration: "2s"
2556
+ },
2557
+ divider: `1px solid ${r.gray[400]}`
2558
+ },
2559
+ empty: {
2560
+ title: {
2561
+ font: {
2562
+ size: "16px",
2563
+ weight: "500",
2564
+ color: r.white[500]
2565
+ }
2566
+ },
2567
+ button: {
2568
+ text: "Refresh"
2569
+ }
2570
+ },
2571
+ error: {
2572
+ title: {
2573
+ font: {
2574
+ size: "16px",
2575
+ weight: "500",
2576
+ color: r.white[500]
2577
+ }
2578
+ },
2579
+ button: {
2580
+ text: "Retry"
2581
+ }
2582
+ }
2583
+ }
2584
+ }, Do = (g, i) => {
2585
+ var t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E, M, I, T, $, D, y, B, F, H, R, z, O, N, U, V, Z, J, q, X, Y, j, se, oe, ne, re, ae, he, ce, le, de, ue, pe, ge, me, be, _e, xe, fe, Ce, ve, ye, l, P, K, Q, W, ke, Fe, He, Re, ze, Oe, Ne, Ue, Ve, Ze, We, je, Ge, Je, qe, Xe, Ye, Ke, Qe, et, tt, it, st, ot, nt, rt, at, ht, ct, lt, dt, ut, pt, gt, mt, bt, _t, xt, ft, Ct, vt, yt, kt, wt, St, Et, Mt, It, Lt, Tt, Bt, At, Pt, $t, Dt, Ft, Ht, Rt, zt, Ot, Nt, Ut, Vt, Zt, Wt, jt, Gt, Jt, qt, Xt, Yt, Kt, Qt, ei, ti, ii, si, oi, ni, ri, ai, hi, ci, li, di, ui, pi, gi, mi, bi, _i, xi, fi, Ci, vi, yi, ki, wi, Si, Ei, Mi, Ii, Li, Ti, Bi, Ai, Pi, $i, Di, Fi, Hi, Ri, zi, Oi, Ni, Ui, Vi, Zi, Wi, ji, Gi, Ji, qi, Xi, Yi, Ki, Qi, es, ts, is, ss, os, ns, rs, as, hs, cs, ls, ds, us, ps, gs, ms, bs, _s, xs, fs, Cs, vs, ys, ks, ws, Ss, Es, Ms, Is, Ls, Ts, Bs, As, Ps, $s, Ds, Fs, Hs, Rs, zs, Os, Ns, Us, Vs, Zs, Ws, js, Gs, Js, qs, Xs, Ys, Ks, Qs, eo, to, io, so, oo, no, ro, ao, ho, co, lo, uo, po;
2586
+ const e = g === "light" ? we : Ae;
2587
+ return {
2588
+ popup: {
2589
+ button: {
2590
+ ...(t = e.popup) == null ? void 0 : t.button,
2591
+ ...(s = i.popup) == null ? void 0 : s.button,
2592
+ icon: {
2593
+ ...(n = (o = e.popup) == null ? void 0 : o.button) == null ? void 0 : n.icon,
2594
+ ...(d = (h = i.popup) == null ? void 0 : h.button) == null ? void 0 : d.icon
2595
+ },
2596
+ unreadIndicator: {
2597
+ ...(u = (c = e.popup) == null ? void 0 : c.button) == null ? void 0 : u.unreadIndicator,
2598
+ ...(p = (m = i.popup) == null ? void 0 : m.button) == null ? void 0 : p.unreadIndicator
2599
+ }
2600
+ },
2601
+ window: {
2602
+ ...(x = e.popup) == null ? void 0 : x.window,
2603
+ ...(_ = i.popup) == null ? void 0 : _.window
2604
+ }
2605
+ },
2606
+ inbox: {
2607
+ header: {
2608
+ ...(b = e.inbox) == null ? void 0 : b.header,
2609
+ ...(v = i.inbox) == null ? void 0 : v.header,
2610
+ filters: {
2611
+ ...(w = (k = e.inbox) == null ? void 0 : k.header) == null ? void 0 : w.filters,
2612
+ ...(E = (S = i.inbox) == null ? void 0 : S.header) == null ? void 0 : E.filters,
2613
+ inbox: {
2614
+ ...(T = (I = (M = e.inbox) == null ? void 0 : M.header) == null ? void 0 : I.filters) == null ? void 0 : T.inbox,
2615
+ ...(y = (D = ($ = i.inbox) == null ? void 0 : $.header) == null ? void 0 : D.filters) == null ? void 0 : y.inbox,
2616
+ icon: {
2617
+ ...(R = (H = (F = (B = e.inbox) == null ? void 0 : B.header) == null ? void 0 : F.filters) == null ? void 0 : H.inbox) == null ? void 0 : R.icon,
2618
+ ...(U = (N = (O = (z = i.inbox) == null ? void 0 : z.header) == null ? void 0 : O.filters) == null ? void 0 : N.inbox) == null ? void 0 : U.icon
2619
+ }
2620
+ },
2621
+ archive: {
2622
+ ...(J = (Z = (V = e.inbox) == null ? void 0 : V.header) == null ? void 0 : Z.filters) == null ? void 0 : J.archive,
2623
+ ...(Y = (X = (q = i.inbox) == null ? void 0 : q.header) == null ? void 0 : X.filters) == null ? void 0 : Y.archive,
2624
+ icon: {
2625
+ ...(ne = (oe = (se = (j = e.inbox) == null ? void 0 : j.header) == null ? void 0 : se.filters) == null ? void 0 : oe.archive) == null ? void 0 : ne.icon,
2626
+ ...(ce = (he = (ae = (re = i.inbox) == null ? void 0 : re.header) == null ? void 0 : ae.filters) == null ? void 0 : he.archive) == null ? void 0 : ce.icon
2627
+ }
2628
+ },
2629
+ unreadIndicator: {
2630
+ ...(ue = (de = (le = e.inbox) == null ? void 0 : le.header) == null ? void 0 : de.filters) == null ? void 0 : ue.unreadIndicator,
2631
+ ...(me = (ge = (pe = i.inbox) == null ? void 0 : pe.header) == null ? void 0 : ge.filters) == null ? void 0 : me.unreadIndicator
2632
+ }
2633
+ },
2634
+ menus: {
2635
+ ...(_e = (be = e.inbox) == null ? void 0 : be.header) == null ? void 0 : _e.menus,
2636
+ ...(fe = (xe = i.inbox) == null ? void 0 : xe.header) == null ? void 0 : fe.menus,
2637
+ popup: {
2638
+ ...(ye = (ve = (Ce = e.inbox) == null ? void 0 : Ce.header) == null ? void 0 : ve.menus) == null ? void 0 : ye.popup,
2639
+ ...(K = (P = (l = i.inbox) == null ? void 0 : l.header) == null ? void 0 : P.menus) == null ? void 0 : K.popup,
2640
+ list: {
2641
+ ...(Fe = (ke = (W = (Q = e.inbox) == null ? void 0 : Q.header) == null ? void 0 : W.menus) == null ? void 0 : ke.popup) == null ? void 0 : Fe.list,
2642
+ ...(Oe = (ze = (Re = (He = i.inbox) == null ? void 0 : He.header) == null ? void 0 : Re.menus) == null ? void 0 : ze.popup) == null ? void 0 : Oe.list,
2643
+ font: {
2644
+ ...(We = (Ze = (Ve = (Ue = (Ne = e.inbox) == null ? void 0 : Ne.header) == null ? void 0 : Ue.menus) == null ? void 0 : Ve.popup) == null ? void 0 : Ze.list) == null ? void 0 : We.font,
2645
+ ...(Xe = (qe = (Je = (Ge = (je = i.inbox) == null ? void 0 : je.header) == null ? void 0 : Ge.menus) == null ? void 0 : Je.popup) == null ? void 0 : qe.list) == null ? void 0 : Xe.font
2646
+ },
2647
+ selectionIcon: {
2648
+ ...(tt = (et = (Qe = (Ke = (Ye = e.inbox) == null ? void 0 : Ye.header) == null ? void 0 : Ke.menus) == null ? void 0 : Qe.popup) == null ? void 0 : et.list) == null ? void 0 : tt.selectionIcon,
2649
+ ...(rt = (nt = (ot = (st = (it = i.inbox) == null ? void 0 : it.header) == null ? void 0 : st.menus) == null ? void 0 : ot.popup) == null ? void 0 : nt.list) == null ? void 0 : rt.selectionIcon
2650
+ }
2651
+ }
2652
+ },
2653
+ filters: {
2654
+ ...(ct = (ht = (at = e.inbox) == null ? void 0 : at.header) == null ? void 0 : ht.menus) == null ? void 0 : ct.filters,
2655
+ ...(ut = (dt = (lt = i.inbox) == null ? void 0 : lt.header) == null ? void 0 : dt.menus) == null ? void 0 : ut.filters,
2656
+ inbox: {
2657
+ ...(bt = (mt = (gt = (pt = e.inbox) == null ? void 0 : pt.header) == null ? void 0 : gt.menus) == null ? void 0 : mt.filters) == null ? void 0 : bt.inbox,
2658
+ ...(Ct = (ft = (xt = (_t = i.inbox) == null ? void 0 : _t.header) == null ? void 0 : xt.menus) == null ? void 0 : ft.filters) == null ? void 0 : Ct.inbox,
2659
+ icon: {
2660
+ ...(St = (wt = (kt = (yt = (vt = e.inbox) == null ? void 0 : vt.header) == null ? void 0 : yt.menus) == null ? void 0 : kt.filters) == null ? void 0 : wt.inbox) == null ? void 0 : St.icon,
2661
+ ...(Tt = (Lt = (It = (Mt = (Et = i.inbox) == null ? void 0 : Et.header) == null ? void 0 : Mt.menus) == null ? void 0 : It.filters) == null ? void 0 : Lt.inbox) == null ? void 0 : Tt.icon
2662
+ }
2663
+ },
2664
+ archive: {
2665
+ ...($t = (Pt = (At = (Bt = e.inbox) == null ? void 0 : Bt.header) == null ? void 0 : At.menus) == null ? void 0 : Pt.filters) == null ? void 0 : $t.archive,
2666
+ ...(Rt = (Ht = (Ft = (Dt = i.inbox) == null ? void 0 : Dt.header) == null ? void 0 : Ft.menus) == null ? void 0 : Ht.filters) == null ? void 0 : Rt.archive,
2667
+ icon: {
2668
+ ...(Vt = (Ut = (Nt = (Ot = (zt = e.inbox) == null ? void 0 : zt.header) == null ? void 0 : Ot.menus) == null ? void 0 : Nt.filters) == null ? void 0 : Ut.archive) == null ? void 0 : Vt.icon,
2669
+ ...(Jt = (Gt = (jt = (Wt = (Zt = i.inbox) == null ? void 0 : Zt.header) == null ? void 0 : Wt.menus) == null ? void 0 : jt.filters) == null ? void 0 : Gt.archive) == null ? void 0 : Jt.icon
2670
+ }
2671
+ }
2672
+ },
2673
+ actions: {
2674
+ ...(Yt = (Xt = (qt = e.inbox) == null ? void 0 : qt.header) == null ? void 0 : Xt.menus) == null ? void 0 : Yt.actions,
2675
+ ...(ei = (Qt = (Kt = i.inbox) == null ? void 0 : Kt.header) == null ? void 0 : Qt.menus) == null ? void 0 : ei.actions,
2676
+ markAllRead: {
2677
+ ...(oi = (si = (ii = (ti = e.inbox) == null ? void 0 : ti.header) == null ? void 0 : ii.menus) == null ? void 0 : si.actions) == null ? void 0 : oi.markAllRead,
2678
+ ...(hi = (ai = (ri = (ni = i.inbox) == null ? void 0 : ni.header) == null ? void 0 : ri.menus) == null ? void 0 : ai.actions) == null ? void 0 : hi.markAllRead,
2679
+ icon: {
2680
+ ...(pi = (ui = (di = (li = (ci = e.inbox) == null ? void 0 : ci.header) == null ? void 0 : li.menus) == null ? void 0 : di.actions) == null ? void 0 : ui.markAllRead) == null ? void 0 : pi.icon,
2681
+ ...(xi = (_i = (bi = (mi = (gi = i.inbox) == null ? void 0 : gi.header) == null ? void 0 : mi.menus) == null ? void 0 : bi.actions) == null ? void 0 : _i.markAllRead) == null ? void 0 : xi.icon
2682
+ }
2683
+ },
2684
+ archiveAll: {
2685
+ ...(yi = (vi = (Ci = (fi = e.inbox) == null ? void 0 : fi.header) == null ? void 0 : Ci.menus) == null ? void 0 : vi.actions) == null ? void 0 : yi.archiveAll,
2686
+ ...(Ei = (Si = (wi = (ki = i.inbox) == null ? void 0 : ki.header) == null ? void 0 : wi.menus) == null ? void 0 : Si.actions) == null ? void 0 : Ei.archiveAll,
2687
+ icon: {
2688
+ ...(Bi = (Ti = (Li = (Ii = (Mi = e.inbox) == null ? void 0 : Mi.header) == null ? void 0 : Ii.menus) == null ? void 0 : Li.actions) == null ? void 0 : Ti.archiveAll) == null ? void 0 : Bi.icon,
2689
+ ...(Fi = (Di = ($i = (Pi = (Ai = i.inbox) == null ? void 0 : Ai.header) == null ? void 0 : Pi.menus) == null ? void 0 : $i.actions) == null ? void 0 : Di.archiveAll) == null ? void 0 : Fi.icon
2690
+ }
2691
+ },
2692
+ archiveRead: {
2693
+ ...(Oi = (zi = (Ri = (Hi = e.inbox) == null ? void 0 : Hi.header) == null ? void 0 : Ri.menus) == null ? void 0 : zi.actions) == null ? void 0 : Oi.archiveRead,
2694
+ ...(Zi = (Vi = (Ui = (Ni = i.inbox) == null ? void 0 : Ni.header) == null ? void 0 : Ui.menus) == null ? void 0 : Vi.actions) == null ? void 0 : Zi.archiveRead,
2695
+ icon: {
2696
+ ...(qi = (Ji = (Gi = (ji = (Wi = e.inbox) == null ? void 0 : Wi.header) == null ? void 0 : ji.menus) == null ? void 0 : Gi.actions) == null ? void 0 : Ji.archiveRead) == null ? void 0 : qi.icon,
2697
+ ...(es = (Qi = (Ki = (Yi = (Xi = i.inbox) == null ? void 0 : Xi.header) == null ? void 0 : Yi.menus) == null ? void 0 : Ki.actions) == null ? void 0 : Qi.archiveRead) == null ? void 0 : es.icon
2698
+ }
2699
+ }
2700
+ }
2701
+ }
2702
+ },
2703
+ list: {
2704
+ ...(ts = e.inbox) == null ? void 0 : ts.list,
2705
+ ...(is = i.inbox) == null ? void 0 : is.list,
2706
+ item: {
2707
+ ...(os = (ss = e.inbox) == null ? void 0 : ss.list) == null ? void 0 : os.item,
2708
+ ...(rs = (ns = i.inbox) == null ? void 0 : ns.list) == null ? void 0 : rs.item,
2709
+ menu: {
2710
+ ...(cs = (hs = (as = e.inbox) == null ? void 0 : as.list) == null ? void 0 : hs.item) == null ? void 0 : cs.menu,
2711
+ ...(us = (ds = (ls = i.inbox) == null ? void 0 : ls.list) == null ? void 0 : ds.item) == null ? void 0 : us.menu,
2712
+ item: {
2713
+ ...(bs = (ms = (gs = (ps = e.inbox) == null ? void 0 : ps.list) == null ? void 0 : gs.item) == null ? void 0 : ms.menu) == null ? void 0 : bs.item,
2714
+ ...(Cs = (fs = (xs = (_s = i.inbox) == null ? void 0 : _s.list) == null ? void 0 : xs.item) == null ? void 0 : fs.menu) == null ? void 0 : Cs.item,
2715
+ read: {
2716
+ ...(Ss = (ws = (ks = (ys = (vs = e.inbox) == null ? void 0 : vs.list) == null ? void 0 : ys.item) == null ? void 0 : ks.menu) == null ? void 0 : ws.item) == null ? void 0 : Ss.read,
2717
+ ...(Ts = (Ls = (Is = (Ms = (Es = i.inbox) == null ? void 0 : Es.list) == null ? void 0 : Ms.item) == null ? void 0 : Is.menu) == null ? void 0 : Ls.item) == null ? void 0 : Ts.read
2718
+ },
2719
+ unread: {
2720
+ ...(Ds = ($s = (Ps = (As = (Bs = e.inbox) == null ? void 0 : Bs.list) == null ? void 0 : As.item) == null ? void 0 : Ps.menu) == null ? void 0 : $s.item) == null ? void 0 : Ds.unread,
2721
+ ...(Os = (zs = (Rs = (Hs = (Fs = i.inbox) == null ? void 0 : Fs.list) == null ? void 0 : Hs.item) == null ? void 0 : Rs.menu) == null ? void 0 : zs.item) == null ? void 0 : Os.unread
2722
+ },
2723
+ archive: {
2724
+ ...(Ws = (Zs = (Vs = (Us = (Ns = e.inbox) == null ? void 0 : Ns.list) == null ? void 0 : Us.item) == null ? void 0 : Vs.menu) == null ? void 0 : Zs.item) == null ? void 0 : Ws.archive,
2725
+ ...(Xs = (qs = (Js = (Gs = (js = i.inbox) == null ? void 0 : js.list) == null ? void 0 : Gs.item) == null ? void 0 : Js.menu) == null ? void 0 : qs.item) == null ? void 0 : Xs.archive
2726
+ },
2727
+ unarchive: {
2728
+ ...(to = (eo = (Qs = (Ks = (Ys = e.inbox) == null ? void 0 : Ys.list) == null ? void 0 : Ks.item) == null ? void 0 : Qs.menu) == null ? void 0 : eo.item) == null ? void 0 : to.unarchive,
2729
+ ...(ro = (no = (oo = (so = (io = i.inbox) == null ? void 0 : io.list) == null ? void 0 : so.item) == null ? void 0 : oo.menu) == null ? void 0 : no.item) == null ? void 0 : ro.unarchive
2730
+ }
2731
+ }
2732
+ }
2733
+ }
2734
+ },
2735
+ loading: {
2736
+ ...(ao = e.inbox) == null ? void 0 : ao.loading,
2737
+ ...(ho = i.inbox) == null ? void 0 : ho.loading
2738
+ },
2739
+ empty: {
2740
+ ...(co = e.inbox) == null ? void 0 : co.empty,
2741
+ ...(lo = i.inbox) == null ? void 0 : lo.empty
2742
+ },
2743
+ error: {
2744
+ ...(uo = e.inbox) == null ? void 0 : uo.error,
2745
+ ...(po = i.inbox) == null ? void 0 : po.error
2746
+ }
2747
+ }
2748
+ };
2749
+ };
2750
+ class Eo {
2751
+ constructor(i) {
2752
+ // Event IDs
2753
+ a(this, "THEME_CHANGE_EVENT", "courier_inbox_theme_change");
2754
+ // State
2755
+ a(this, "_theme");
2756
+ a(this, "_lightTheme", we);
2757
+ a(this, "_darkTheme", Ae);
2758
+ a(this, "_target");
2759
+ a(this, "_subscriptions", []);
2760
+ // System theme
2761
+ a(this, "_userMode");
2762
+ a(this, "_systemMode");
2763
+ a(this, "_systemThemeCleanup");
2764
+ this._theme = i, this._target = new EventTarget(), this._userMode = "system", this._systemMode = go(), this.setLightTheme(we), this.setDarkTheme(Ae), this._systemThemeCleanup = mo((e) => {
2765
+ this._systemMode = e, this.updateTheme();
2766
+ });
2767
+ }
2768
+ setLightTheme(i) {
2769
+ this._lightTheme = i, this._systemMode === "light" && this.updateTheme();
2770
+ }
2771
+ setDarkTheme(i) {
2772
+ this._darkTheme = i, this._systemMode === "dark" && this.updateTheme();
2773
+ }
2774
+ /**
2775
+ * Get the current system theme
2776
+ */
2777
+ get currentSystemTheme() {
2778
+ return this._systemMode;
2779
+ }
2780
+ /**
2781
+ * Get the current theme
2782
+ */
2783
+ getTheme() {
2784
+ return this._theme;
2785
+ }
2786
+ /**
2787
+ * Update the theme
2788
+ */
2789
+ updateTheme() {
2790
+ const i = this._userMode === "system" ? this._systemMode : this._userMode, e = i === "light" ? this._lightTheme : this._darkTheme, t = Do(i, e);
2791
+ this.setTheme(t);
2792
+ }
2793
+ /**
2794
+ * Set the theme and notify all listeners
2795
+ */
2796
+ setTheme(i) {
2797
+ i !== this._theme && (this._theme = i, this._target.dispatchEvent(new CustomEvent(this.THEME_CHANGE_EVENT, {
2798
+ detail: { theme: i }
2799
+ })));
2800
+ }
2801
+ /**
2802
+ * Set the mode and notify all listeners
2803
+ */
2804
+ setMode(i) {
2805
+ this._userMode = i, this.updateTheme();
2806
+ }
2807
+ /**
2808
+ * Subscribe to theme changes
2809
+ * @param {Function} callback - Function to run when the theme changes
2810
+ * @returns {CourierInboxThemeSubscription} - Object with remove method to stop listening
2811
+ */
2812
+ subscribe(i) {
2813
+ const e = new AbortController();
2814
+ this._target.addEventListener(this.THEME_CHANGE_EVENT, (s) => {
2815
+ i(s.detail.theme);
2816
+ }, { signal: e.signal });
2817
+ const t = {
2818
+ manager: this,
2819
+ unsubscribe: () => {
2820
+ e.abort();
2821
+ const s = this._subscriptions.indexOf(t);
2822
+ s > -1 && this._subscriptions.splice(s, 1);
2823
+ }
2824
+ };
2825
+ return this._subscriptions.push(t), t;
2826
+ }
2827
+ /**
2828
+ * Clean up event listeners
2829
+ */
2830
+ cleanup() {
2831
+ this._systemThemeCleanup && this._systemThemeCleanup(), this._subscriptions.forEach((i) => i.unsubscribe()), this._subscriptions = [];
2832
+ }
2833
+ }
2834
+ class Mo extends HTMLElement {
2835
+ constructor(e) {
2836
+ var t;
2837
+ super();
2838
+ // State
2839
+ a(this, "_currentFeed", "inbox");
2840
+ // Theming
2841
+ a(this, "_themeManager");
2842
+ // Components
2843
+ a(this, "_shadow");
2844
+ a(this, "_list");
2845
+ a(this, "_datastoreListener");
2846
+ a(this, "_authListener");
2847
+ a(this, "_style");
2848
+ // Header
2849
+ a(this, "_header");
2850
+ a(this, "_headerFactory");
2851
+ // List
2852
+ a(this, "_onMessageClick");
2853
+ a(this, "_onMessageActionClick");
2854
+ a(this, "_onMessageLongPress");
2855
+ // Default props
2856
+ a(this, "_defaultProps", {
2857
+ title: "Inbox",
2858
+ icon: f.inbox,
2859
+ feedType: this._currentFeed,
2860
+ height: "768px"
2861
+ });
2862
+ this._shadow = this.attachShadow({ mode: "open" }), this._themeManager = e ?? new Eo(we), this._header = new wo({
2863
+ themeManager: this._themeManager,
2864
+ onFeedTypeChange: (s) => {
2865
+ this.setFeedType(s);
2866
+ }
2867
+ }), this._header.build(void 0), this._shadow.appendChild(this._header), this._list = new vo({
2868
+ themeManager: this._themeManager,
2869
+ onRefresh: () => {
2870
+ this.refresh();
2871
+ },
2872
+ onPaginationTrigger: async (s) => {
2873
+ var o, n;
2874
+ try {
2875
+ await A.shared.fetchNextPageOfMessages({
2876
+ feedType: s
2877
+ });
2878
+ } catch (h) {
2879
+ (n = (o = C.shared.client) == null ? void 0 : o.options.logger) == null || n.error("Failed to fetch next page of messages:", h);
2880
+ }
2881
+ },
2882
+ onMessageClick: (s, o) => {
2883
+ var n;
2884
+ A.shared.clickMessage(s), this.dispatchEvent(new CustomEvent("message-click", {
2885
+ detail: { message: s, index: o },
2886
+ bubbles: !0,
2887
+ composed: !0
2888
+ })), (n = this._onMessageClick) == null || n.call(this, { message: s, index: o });
2889
+ },
2890
+ onMessageActionClick: (s, o, n) => {
2891
+ var h;
2892
+ this.dispatchEvent(new CustomEvent("message-action-click", {
2893
+ detail: { message: s, action: o, index: n },
2894
+ bubbles: !0,
2895
+ composed: !0
2896
+ })), (h = this._onMessageActionClick) == null || h.call(this, { message: s, action: o, index: n });
2897
+ },
2898
+ onMessageLongPress: (s, o) => {
2899
+ var n;
2900
+ this.dispatchEvent(new CustomEvent("message-long-press", {
2901
+ detail: { message: s, index: o },
2902
+ bubbles: !0,
2903
+ composed: !0
2904
+ })), (n = this._onMessageLongPress) == null || n.call(this, { message: s, index: o });
2905
+ }
2906
+ }), this._style = document.createElement("style"), this.refreshTheme(), this._shadow.appendChild(this._style), this._shadow.appendChild(this._list), this._datastoreListener = new So({
2907
+ onError: (s) => {
2908
+ this._list.setError(s);
2909
+ },
2910
+ onDataSetChange: (s, o) => {
2911
+ this._currentFeed === o && (this._list.setDataSet(s), this.updateHeader());
2912
+ },
2913
+ onPageAdded: (s, o) => {
2914
+ this._currentFeed === o && (this._list.addPage(s), this.updateHeader());
2915
+ },
2916
+ onMessageAdd: (s, o, n) => {
2917
+ this._currentFeed === n && (this._list.addMessage(s, o), this.updateHeader());
2918
+ },
2919
+ onMessageRemove: (s, o, n) => {
2920
+ this._currentFeed === n && (this._list.removeMessage(o), this.updateHeader());
2921
+ },
2922
+ onMessageUpdate: (s, o, n) => {
2923
+ this._currentFeed === n && (this._list.updateMessage(s, o), this.updateHeader());
2924
+ },
2925
+ onUnreadCountChange: (s) => {
2926
+ this.updateHeader();
2927
+ }
2928
+ }), A.shared.addDataStoreListener(this._datastoreListener), this._themeManager.subscribe((s) => {
2929
+ this.refreshTheme();
2930
+ }), this._authListener = C.shared.addAuthenticationListener((s) => {
2931
+ this.refresh();
2932
+ }), (t = C.shared.client) != null && t.options.userId && this.refresh();
2933
+ }
2934
+ get theme() {
2935
+ return this._themeManager.getTheme();
2936
+ }
2937
+ setLightTheme(e) {
2938
+ this._themeManager.setLightTheme(e);
2939
+ }
2940
+ setDarkTheme(e) {
2941
+ this._themeManager.setDarkTheme(e);
2942
+ }
2943
+ static get observedAttributes() {
2944
+ return ["height", "light-theme", "dark-theme", "mode", "message-click", "message-action-click", "message-long-press"];
2945
+ }
2946
+ refreshTheme() {
2947
+ this._style.textContent = this.getStyles();
2948
+ }
2949
+ getStyles() {
2950
+ return `
2951
+ :host {
2952
+ display: flex;
2953
+ flex-direction: column;
2954
+ width: 100%;
2955
+ height: ${this._defaultProps.height};
2956
+ }
2957
+
2958
+ courier-inbox-header {
2959
+ flex-shrink: 0;
2960
+ }
2961
+
2962
+ courier-inbox-list {
2963
+ flex: 1;
2964
+ overflow-y: auto;
2965
+ overflow-x: hidden;
2966
+ }
2967
+ `;
2968
+ }
2969
+ setHeader(e) {
2970
+ this._headerFactory = e, this.updateHeader();
2971
+ }
2972
+ removeHeader() {
2973
+ this._headerFactory = null, this.updateHeader();
2974
+ }
2975
+ setLoadingState(e) {
2976
+ this._list.setLoadingStateFactory(e);
2977
+ }
2978
+ setEmptyState(e) {
2979
+ this._list.setEmptyStateFactory(e);
2980
+ }
2981
+ setErrorState(e) {
2982
+ this._list.setErrorStateFactory(e);
2983
+ }
2984
+ setListItem(e) {
2985
+ this._list.setListItemFactory(e);
2986
+ }
2987
+ setPaginationItem(e) {
2988
+ this._list.setPaginationItemFactory(e);
2989
+ }
2990
+ onMessageClick(e) {
2991
+ this._onMessageClick = e;
2992
+ }
2993
+ onMessageActionClick(e) {
2994
+ this._onMessageActionClick = e;
2995
+ }
2996
+ onMessageLongPress(e) {
2997
+ this._onMessageLongPress = e;
2998
+ }
2999
+ setFeedType(e) {
3000
+ this._currentFeed = e, this._list.setFeedType(e), this.updateHeader(), this.load({
3001
+ feedType: this._currentFeed,
3002
+ canUseCache: !0
3003
+ });
3004
+ }
3005
+ updateHeader() {
3006
+ const e = {
3007
+ feedType: this._currentFeed,
3008
+ unreadCount: A.shared.unreadCount,
3009
+ messageCount: this._list.messages.length
3010
+ };
3011
+ switch (this._headerFactory) {
3012
+ case void 0:
3013
+ this._header.render(e);
3014
+ break;
3015
+ case null:
3016
+ this._header.build(null);
3017
+ break;
3018
+ default:
3019
+ const t = this._headerFactory(e);
3020
+ this._header.build(t);
3021
+ break;
3022
+ }
3023
+ }
3024
+ async load(e) {
3025
+ await A.shared.load(e);
3026
+ }
3027
+ refresh() {
3028
+ this.load({
3029
+ feedType: this._currentFeed,
3030
+ canUseCache: !1
3031
+ });
3032
+ }
3033
+ connectedCallback() {
3034
+ this.refresh();
3035
+ }
3036
+ disconnectedCallback() {
3037
+ var e, t;
3038
+ this._themeManager.cleanup(), (e = this._datastoreListener) == null || e.remove(), (t = this._authListener) == null || t.remove();
3039
+ }
3040
+ attributeChangedCallback(e, t, s) {
3041
+ var o, n, h, d, c, u;
3042
+ if (t !== s)
3043
+ switch (e) {
3044
+ case "height":
3045
+ const m = s || this._defaultProps.height;
3046
+ this.style.height = m;
3047
+ break;
3048
+ case "message-click":
3049
+ if (s)
3050
+ try {
3051
+ this._onMessageClick = new Function("props", s);
3052
+ } catch (p) {
3053
+ (n = (o = C.shared.client) == null ? void 0 : o.options.logger) == null || n.error("Failed to parse message-click handler:", p);
3054
+ }
3055
+ else
3056
+ this._onMessageClick = void 0;
3057
+ break;
3058
+ case "message-action-click":
3059
+ if (s)
3060
+ try {
3061
+ this._onMessageActionClick = new Function("props", s);
3062
+ } catch (p) {
3063
+ (d = (h = C.shared.client) == null ? void 0 : h.options.logger) == null || d.error("Failed to parse message-action-click handler:", p);
3064
+ }
3065
+ else
3066
+ this._onMessageActionClick = void 0;
3067
+ break;
3068
+ case "message-long-press":
3069
+ if (s)
3070
+ try {
3071
+ this._onMessageLongPress = new Function("props", s);
3072
+ } catch (p) {
3073
+ (u = (c = C.shared.client) == null ? void 0 : c.options.logger) == null || u.error("Failed to parse message-long-press handler:", p);
3074
+ }
3075
+ else
3076
+ this._onMessageLongPress = void 0;
3077
+ break;
3078
+ case "light-theme":
3079
+ s && this.setLightTheme(JSON.parse(s));
3080
+ break;
3081
+ case "dark-theme":
3082
+ s && this.setDarkTheme(JSON.parse(s));
3083
+ break;
3084
+ case "mode":
3085
+ this._themeManager.setMode(s);
3086
+ break;
3087
+ }
3088
+ }
3089
+ }
3090
+ customElements.get("courier-inbox") || customElements.define("courier-inbox", Mo);
3091
+ class Io extends Le {
3092
+ constructor(e) {
3093
+ super();
3094
+ // Theme
3095
+ a(this, "_themeSubscription");
3096
+ // Components
3097
+ a(this, "_container");
3098
+ a(this, "_triggerButton");
3099
+ a(this, "_unreadCountBadge");
3100
+ this._themeSubscription = e.subscribe((t) => {
3101
+ this.updateTheme();
3102
+ });
3103
+ }
3104
+ defaultElement() {
3105
+ this._container = document.createElement("div"), this._container.className = "menu-button-container", this._triggerButton = new Se(f.inbox), this._unreadCountBadge = new De({
3106
+ themeBus: this._themeSubscription.manager,
3107
+ location: "button"
3108
+ }), this._unreadCountBadge.id = "unread-badge";
3109
+ const e = document.createElement("style");
3110
+ return e.textContent = this.getStyles(), this._container.appendChild(e), this._container.appendChild(this._triggerButton), this._container.appendChild(this._unreadCountBadge), this.shadow.appendChild(this._container), this.updateTheme(), this._container;
3111
+ }
3112
+ getStyles() {
3113
+ return `
3114
+ .menu-button-container {
3115
+ position: relative;
3116
+ display: inline-block;
3117
+ }
3118
+
3119
+ #unread-badge {
3120
+ position: absolute;
3121
+ top: -8px;
3122
+ left: 50%;
3123
+ pointer-events: none;
3124
+ }
3125
+ `;
3126
+ }
3127
+ onUnreadCountChange(e) {
3128
+ var t;
3129
+ (t = this._unreadCountBadge) == null || t.setCount(e), this.updateTheme();
3130
+ }
3131
+ updateTheme() {
3132
+ var t, s, o, n, h, d, c, u, m, p, x, _, b, v, k, w, S, E;
3133
+ const e = this._themeSubscription.manager.getTheme();
3134
+ (n = this._triggerButton) == null || n.updateIconColor(((o = (s = (t = e == null ? void 0 : e.popup) == null ? void 0 : t.button) == null ? void 0 : s.icon) == null ? void 0 : o.color) ?? r.black[500]), (u = this._triggerButton) == null || u.updateIconSVG(((c = (d = (h = e == null ? void 0 : e.popup) == null ? void 0 : h.button) == null ? void 0 : d.icon) == null ? void 0 : c.svg) ?? f.inbox), (x = this._triggerButton) == null || x.updateBackgroundColor(((p = (m = e == null ? void 0 : e.popup) == null ? void 0 : m.button) == null ? void 0 : p.backgroundColor) ?? "transparent"), (v = this._triggerButton) == null || v.updateHoverBackgroundColor(((b = (_ = e == null ? void 0 : e.popup) == null ? void 0 : _.button) == null ? void 0 : b.hoverBackgroundColor) ?? r.black[50010]), (S = this._triggerButton) == null || S.updateActiveBackgroundColor(((w = (k = e == null ? void 0 : e.popup) == null ? void 0 : k.button) == null ? void 0 : w.activeBackgroundColor) ?? r.black[50020]), (E = this._unreadCountBadge) == null || E.refreshTheme("button");
3135
+ }
3136
+ disconnectedCallback() {
3137
+ this._themeSubscription.unsubscribe();
3138
+ }
3139
+ }
3140
+ customElements.get("courier-inbox-menu-button") || customElements.define("courier-inbox-menu-button", Io);
3141
+ class Fo extends HTMLElement {
3142
+ constructor() {
3143
+ super();
3144
+ // State
3145
+ a(this, "_width", "440px");
3146
+ a(this, "_height", "440px");
3147
+ a(this, "_popupAlignment", "top-right");
3148
+ a(this, "_top", "40px");
3149
+ a(this, "_right", "0");
3150
+ a(this, "_bottom", "40px");
3151
+ a(this, "_left", "0");
3152
+ // Theming
3153
+ a(this, "_themeManager", new Eo(we));
3154
+ // Components
3155
+ a(this, "_triggerButton");
3156
+ a(this, "_popup");
3157
+ a(this, "_inbox");
3158
+ a(this, "_style");
3159
+ // Listeners
3160
+ a(this, "_datastoreListener");
3161
+ // Factories
3162
+ a(this, "_popupMenuButtonFactory");
3163
+ const e = this.attachShadow({ mode: "open" });
3164
+ this._triggerButton = new Io(this._themeManager), this._triggerButton.build(void 0), this._popup = document.createElement("div"), this._popup.className = "popup", this._inbox = new Mo(this._themeManager), this._inbox.setAttribute("height", "100%"), this._style = document.createElement("style"), this.refreshTheme(), e.appendChild(this._style), e.appendChild(this._triggerButton), e.appendChild(this._popup), this._popup.appendChild(this._inbox), this._triggerButton.addEventListener("click", this.togglePopup.bind(this)), document.addEventListener("click", this.handleOutsideClick.bind(this)), this.updatePopupPosition(), this._datastoreListener = new So(this), A.shared.addDataStoreListener(this._datastoreListener), this._themeManager.subscribe((t) => {
3165
+ this.refreshTheme();
3166
+ });
3167
+ }
3168
+ get theme() {
3169
+ return this._themeManager.getTheme();
3170
+ }
3171
+ setLightTheme(e) {
3172
+ this._themeManager.setLightTheme(e);
3173
+ }
3174
+ setDarkTheme(e) {
3175
+ this._themeManager.setDarkTheme(e);
3176
+ }
3177
+ static get observedAttributes() {
3178
+ return ["popup-alignment", "message-click", "message-action-click", "message-long-press", "popup-width", "popup-height", "top", "right", "bottom", "left", "light-theme", "dark-theme", "mode"];
3179
+ }
3180
+ refreshTheme() {
3181
+ this._style.textContent = this.getStyles();
3182
+ }
3183
+ getStyles() {
3184
+ var e, t, s, o, n, h, d, c;
3185
+ return `
3186
+ :host {
3187
+ display: inline-block;
3188
+ position: relative;
3189
+ }
3190
+
3191
+ .menu-button-container {
3192
+ position: relative;
3193
+ display: inline-block;
3194
+ }
3195
+
3196
+ .popup {
3197
+ display: none;
3198
+ position: absolute;
3199
+ background: ${((t = (e = this.theme.popup) == null ? void 0 : e.window) == null ? void 0 : t.backgroundColor) ?? "red"};
3200
+ border-radius: ${((o = (s = this.theme.popup) == null ? void 0 : s.window) == null ? void 0 : o.borderRadius) ?? "8px"};
3201
+ border: ${((h = (n = this.theme.popup) == null ? void 0 : n.window) == null ? void 0 : h.border) ?? "1px solid red"};
3202
+ box-shadow: ${((c = (d = this.theme.popup) == null ? void 0 : d.window) == null ? void 0 : c.shadow) ?? "0px 8px 16px -4px red"};
3203
+ z-index: 1000;
3204
+ width: ${this._width};
3205
+ height: ${this._height};
3206
+ overflow: hidden;
3207
+ transform: translateZ(0);
3208
+ will-change: transform;
3209
+ }
3210
+
3211
+ #unread-badge {
3212
+ position: absolute;
3213
+ top: -8px;
3214
+ left: 50%;
3215
+ pointer-events: none;
3216
+ }
3217
+
3218
+ courier-inbox {
3219
+ height: 100%;
3220
+ }
3221
+ `;
3222
+ }
3223
+ attributeChangedCallback(e, t, s) {
3224
+ switch (e) {
3225
+ case "popup-alignment":
3226
+ this.isValidPosition(s) && (this._popupAlignment = s, this.updatePopupPosition());
3227
+ break;
3228
+ case "popup-width":
3229
+ this._width = s, this.setSize(s, this._height);
3230
+ break;
3231
+ case "popup-height":
3232
+ this._height = s, this.setSize(this._width, s);
3233
+ break;
3234
+ case "top":
3235
+ this._top = s, this.updatePopupPosition();
3236
+ break;
3237
+ case "right":
3238
+ this._right = s, this.updatePopupPosition();
3239
+ break;
3240
+ case "bottom":
3241
+ this._bottom = s, this.updatePopupPosition();
3242
+ break;
3243
+ case "left":
3244
+ this._left = s, this.updatePopupPosition();
3245
+ break;
3246
+ case "light-theme":
3247
+ s && this.setLightTheme(JSON.parse(s));
3248
+ break;
3249
+ case "dark-theme":
3250
+ s && this.setDarkTheme(JSON.parse(s));
3251
+ break;
3252
+ case "mode":
3253
+ this._themeManager.setMode(s);
3254
+ break;
3255
+ }
3256
+ }
3257
+ onUnreadCountChange(e) {
3258
+ this.render();
3259
+ }
3260
+ onMessageClick(e) {
3261
+ this._inbox.onMessageClick(e);
3262
+ }
3263
+ onMessageActionClick(e) {
3264
+ this._inbox.onMessageActionClick(e);
3265
+ }
3266
+ onMessageLongPress(e) {
3267
+ this._inbox.onMessageLongPress(e);
3268
+ }
3269
+ isValidPosition(e) {
3270
+ return [
3271
+ "top-right",
3272
+ "top-left",
3273
+ "top-center",
3274
+ "bottom-right",
3275
+ "bottom-left",
3276
+ "bottom-center",
3277
+ "center-right",
3278
+ "center-left",
3279
+ "center-center"
3280
+ ].includes(e);
3281
+ }
3282
+ updatePopupPosition() {
3283
+ switch (this._popup.style.top = "", this._popup.style.bottom = "", this._popup.style.left = "", this._popup.style.right = "", this._popup.style.margin = "", this._popup.style.transform = "", this._popupAlignment) {
3284
+ case "top-right":
3285
+ this._popup.style.top = this._top, this._popup.style.right = this._right;
3286
+ break;
3287
+ case "top-left":
3288
+ this._popup.style.top = this._top, this._popup.style.left = this._left;
3289
+ break;
3290
+ case "top-center":
3291
+ this._popup.style.top = this._top, this._popup.style.left = "50%", this._popup.style.transform = "translateX(-50%)";
3292
+ break;
3293
+ case "bottom-right":
3294
+ this._popup.style.bottom = this._bottom, this._popup.style.right = this._right;
3295
+ break;
3296
+ case "bottom-left":
3297
+ this._popup.style.bottom = this._bottom, this._popup.style.left = this._left;
3298
+ break;
3299
+ case "bottom-center":
3300
+ this._popup.style.bottom = this._bottom, this._popup.style.left = "50%", this._popup.style.transform = "translateX(-50%)";
3301
+ break;
3302
+ case "center-right":
3303
+ this._popup.style.top = "50%", this._popup.style.right = this._right, this._popup.style.transform = "translateY(-50%)";
3304
+ break;
3305
+ case "center-left":
3306
+ this._popup.style.top = "50%", this._popup.style.left = this._left, this._popup.style.transform = "translateY(-50%)";
3307
+ break;
3308
+ case "center-center":
3309
+ this._popup.style.top = "50%", this._popup.style.left = "50%", this._popup.style.transform = "translate(-50%, -50%)";
3310
+ break;
3311
+ }
3312
+ }
3313
+ togglePopup(e) {
3314
+ e.stopPropagation(), this._popup.style.display === "block" ? this._popup.style.display = "none" : this._popup.style.display = "block";
3315
+ }
3316
+ handleOutsideClick(e) {
3317
+ this.contains(e.target) || (this._popup.style.display = "none");
3318
+ }
3319
+ setContent(e) {
3320
+ this._inbox.innerHTML = "", this._inbox.appendChild(e);
3321
+ }
3322
+ setSize(e, t) {
3323
+ this._width = e, this._height = t, this._popup.style.width = e, this._popup.style.height = t;
3324
+ }
3325
+ setPosition(e) {
3326
+ var t, s;
3327
+ this.isValidPosition(e) ? (this._popupAlignment = e, this.updatePopupPosition()) : (s = (t = C.shared.client) == null ? void 0 : t.options.logger) == null || s.error(`Invalid position: ${e}`);
3328
+ }
3329
+ setFeedType(e) {
3330
+ this._inbox.setFeedType(e);
3331
+ }
3332
+ // Factory methods
3333
+ setPopupHeader(e) {
3334
+ this._inbox.setHeader(e);
3335
+ }
3336
+ removePopupHeader() {
3337
+ this._inbox.removeHeader();
3338
+ }
3339
+ setPopupLoadingState(e) {
3340
+ this._inbox.setLoadingState(e);
3341
+ }
3342
+ setPopupEmptyState(e) {
3343
+ this._inbox.setEmptyState(e);
3344
+ }
3345
+ setPopupErrorState(e) {
3346
+ this._inbox.setErrorState(e);
3347
+ }
3348
+ setPopupListItem(e) {
3349
+ this._inbox.setListItem(e);
3350
+ }
3351
+ setPopupPaginationItem(e) {
3352
+ this._inbox.setPaginationItem(e);
3353
+ }
3354
+ setPopupMenuButton(e) {
3355
+ this._popupMenuButtonFactory = e, this.render();
3356
+ }
3357
+ render() {
3358
+ const e = A.shared.unreadCount;
3359
+ switch (this._popupMenuButtonFactory) {
3360
+ case void 0:
3361
+ case null:
3362
+ this._triggerButton.build(void 0), this._triggerButton.onUnreadCountChange(e);
3363
+ break;
3364
+ default:
3365
+ const t = this._popupMenuButtonFactory({ unreadCount: e });
3366
+ this._triggerButton.build(t);
3367
+ break;
3368
+ }
3369
+ }
3370
+ disconnectedCallback() {
3371
+ var e;
3372
+ (e = this._datastoreListener) == null || e.remove(), this._themeManager.cleanup();
3373
+ }
3374
+ }
3375
+ customElements.get("courier-inbox-menu") || customElements.define("courier-inbox-menu", Fo);
3376
+ class Zo {
3377
+ onDataSetChange(i, e) {
3378
+ }
3379
+ onPageAdded(i, e) {
3380
+ }
3381
+ onUnreadCountChange(i) {
3382
+ }
3383
+ onMessageAdd(i, e, t) {
3384
+ }
3385
+ onMessageRemove(i, e, t) {
3386
+ }
3387
+ onMessageUpdate(i, e, t) {
3388
+ }
3389
+ onError(i) {
3390
+ }
3391
+ }
3392
+ export {
3393
+ Mo as CourierInbox,
3394
+ So as CourierInboxDataStoreListener,
3395
+ A as CourierInboxDatastore,
3396
+ Zo as CourierInboxDatastoreEvents,
3397
+ wo as CourierInboxHeader,
3398
+ Fo as CourierInboxMenu,
3399
+ Eo as CourierInboxThemeManager,
3400
+ xo as CourierListItem,
3401
+ Uo as archiveMessage,
3402
+ No as clickMessage,
3403
+ Ae as defaultDarkTheme,
3404
+ we as defaultLightTheme,
3405
+ $o as getMessageTime,
3406
+ zo as markAsRead,
3407
+ Oo as markAsUnread,
3408
+ Do as mergeTheme,
3409
+ Vo as openMessage
3410
+ };