@eifi1/ui-kit 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -41
- package/dist/admin/role-select.d.ts +3 -2
- package/dist/admin/role-select.js +2 -0
- package/dist/admin/role-select.js.map +1 -1
- package/dist/billing/billing-banner.d.ts +5 -2
- package/dist/billing/billing-banner.js.map +1 -1
- package/dist/billing/plan-limit-notice.d.ts +5 -2
- package/dist/billing/plan-limit-notice.js.map +1 -1
- package/dist/chart.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -5
- package/dist/components/amount-input.js +2 -2
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/autocomplete.d.ts +2 -2
- package/dist/components/autocomplete.js +2 -1
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/button-look.d.ts +1 -1
- package/dist/components/button-look.js +9 -4
- package/dist/components/button-look.js.map +1 -1
- package/dist/components/calculator.d.ts +1 -4
- package/dist/components/calculator.js +1 -3
- package/dist/components/calculator.js.map +1 -1
- package/dist/components/chart-zoom.d.ts +0 -37
- package/dist/components/chart-zoom.js +1 -28
- package/dist/components/chart-zoom.js.map +1 -1
- package/dist/components/checkbox-group.d.ts +5 -2
- package/dist/components/checkbox-group.js +15 -4
- package/dist/components/checkbox-group.js.map +1 -1
- package/dist/components/chip-input.d.ts +0 -4
- package/dist/components/chip-input.js +1 -5
- package/dist/components/chip-input.js.map +1 -1
- package/dist/components/column-mapper.d.ts +5 -3
- package/dist/components/column-mapper.js +2 -0
- package/dist/components/column-mapper.js.map +1 -1
- package/dist/components/combobox.d.ts +3 -3
- package/dist/components/combobox.js +2 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/copy-button.d.ts +5 -1
- package/dist/components/copy-button.js.map +1 -1
- package/dist/components/country-select.d.ts +3 -3
- package/dist/components/country-select.js +3 -0
- package/dist/components/country-select.js.map +1 -1
- package/dist/components/currency-option-list.d.ts +3 -8
- package/dist/components/currency-option-list.js +1 -29
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.d.ts +3 -2
- package/dist/components/currency-select.js +10 -1
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +3 -3
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +1 -1
- package/dist/components/data-table-filter-popover.js +1 -1
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-labels.d.ts +1 -42
- package/dist/components/data-table-labels.js +2 -31
- package/dist/components/data-table-labels.js.map +1 -1
- package/dist/components/data-table-shared.d.ts +17 -1
- package/dist/components/data-table-shared.js +22 -0
- package/dist/components/data-table-shared.js.map +1 -1
- package/dist/components/data-table.d.ts +12 -2
- package/dist/components/data-table.js +18 -14
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-field.d.ts +2 -1
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.js +3 -0
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.js +3 -0
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/dropdown.d.ts +18 -15
- package/dist/components/dropdown.js +11 -3
- package/dist/components/dropdown.js.map +1 -1
- package/dist/components/entity-combobox.d.ts +3 -3
- package/dist/components/entity-combobox.js +2 -1
- package/dist/components/entity-combobox.js.map +1 -1
- package/dist/components/field-base.d.ts +0 -5
- package/dist/components/field-base.js +0 -5
- package/dist/components/field-base.js.map +1 -1
- package/dist/components/field-parts.d.ts +69 -22
- package/dist/components/field-parts.js +33 -19
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/field-strip.d.ts +9 -23
- package/dist/components/field-strip.js +26 -23
- package/dist/components/field-strip.js.map +1 -1
- package/dist/components/field-sync.d.ts +0 -4
- package/dist/components/field-sync.js +0 -4
- package/dist/components/field-sync.js.map +1 -1
- package/dist/components/field.d.ts +7 -6
- package/dist/components/field.js +24 -15
- package/dist/components/field.js.map +1 -1
- package/dist/components/full-bleed-dialog.js +2 -2
- package/dist/components/full-bleed-dialog.js.map +1 -1
- package/dist/components/help-popover.d.ts +9 -7
- package/dist/components/help-popover.js.map +1 -1
- package/dist/components/hover-menu.d.ts +6 -13
- package/dist/components/hover-menu.js +3 -3
- package/dist/components/hover-menu.js.map +1 -1
- package/dist/components/icon-picker.d.ts +3 -2
- package/dist/components/icon-picker.js +3 -0
- package/dist/components/icon-picker.js.map +1 -1
- package/dist/components/inline-entity-combobox.d.ts +3 -3
- package/dist/components/inline-entity-combobox.js +2 -1
- package/dist/components/inline-entity-combobox.js.map +1 -1
- package/dist/components/input.d.ts +2 -2
- package/dist/components/input.js +2 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/modal.d.ts +9 -1
- package/dist/components/modal.js +7 -4
- package/dist/components/modal.js.map +1 -1
- package/dist/components/month-picker.d.ts +2 -1
- package/dist/components/month-picker.js +8 -1
- package/dist/components/month-picker.js.map +1 -1
- package/dist/components/multi-entity-combobox.d.ts +2 -2
- package/dist/components/multi-entity-combobox.js +2 -1
- package/dist/components/multi-entity-combobox.js.map +1 -1
- package/dist/components/multi-select.d.ts +7 -18
- package/dist/components/multi-select.js +8 -10
- package/dist/components/multi-select.js.map +1 -1
- package/dist/components/number-input.d.ts +2 -5
- package/dist/components/number-input.js +2 -4
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/numeric-field.d.ts +5 -2
- package/dist/components/numeric-field.js +4 -1
- package/dist/components/numeric-field.js.map +1 -1
- package/dist/components/one-time-code-input.d.ts +2 -1
- package/dist/components/one-time-code-input.js +2 -1
- package/dist/components/one-time-code-input.js.map +1 -1
- package/dist/components/phone-input.d.ts +1 -1
- package/dist/components/phone-input.js +4 -0
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/popover.js +3 -3
- package/dist/components/popover.js.map +1 -1
- package/dist/components/select.d.ts +4 -3
- package/dist/components/select.js +2 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/server-wake.d.ts +0 -6
- package/dist/components/server-wake.js.map +1 -1
- package/dist/components/settings-fields.d.ts +4 -2
- package/dist/components/settings-fields.js.map +1 -1
- package/dist/components/slider.d.ts +3 -2
- package/dist/components/slider.js +7 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stat-tile.d.ts +8 -2
- package/dist/components/stat-tile.js +2 -11
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/swatch-picker.d.ts +3 -2
- package/dist/components/swatch-picker.js +3 -0
- package/dist/components/swatch-picker.js.map +1 -1
- package/dist/components/swipeable-row.d.ts +2 -17
- package/dist/components/swipeable-row.js +11 -16
- package/dist/components/swipeable-row.js.map +1 -1
- package/dist/components/text-link.js +3 -1
- package/dist/components/text-link.js.map +1 -1
- package/dist/components/textarea.d.ts +2 -1
- package/dist/components/textarea.js +9 -3
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/toggle-group.d.ts +2 -2
- package/dist/components/toggle-group.js +7 -3
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/tooltip.d.ts +9 -1
- package/dist/components/tooltip.js +20 -5
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/translation-review.d.ts +10 -2
- package/dist/components/translation-review.js +11 -3
- package/dist/components/translation-review.js.map +1 -1
- package/dist/components/use-table-state.d.ts +31 -3
- package/dist/components/use-table-state.js +53 -8
- package/dist/components/use-table-state.js.map +1 -1
- package/dist/components/user-avatar.d.ts +2 -2
- package/dist/components/user-avatar.js.map +1 -1
- package/dist/components/wizard-stepper.d.ts +1 -4
- package/dist/components/wizard-stepper.js +2 -3
- package/dist/components/wizard-stepper.js.map +1 -1
- package/dist/currencies.d.ts +23 -0
- package/dist/currencies.js +38 -0
- package/dist/currencies.js.map +1 -0
- package/dist/demo/demo-banner.d.ts +7 -2
- package/dist/demo/demo-banner.js.map +1 -1
- package/dist/eslint/index.d.ts +83 -0
- package/dist/eslint/index.js +69 -0
- package/dist/eslint/index.js.map +1 -0
- package/dist/eslint/role-utilities.d.ts +48 -0
- package/dist/eslint/role-utilities.generated.d.ts +2 -0
- package/dist/eslint/role-utilities.generated.js +143 -0
- package/dist/eslint/role-utilities.generated.js.map +1 -0
- package/dist/eslint/role-utilities.js +43 -0
- package/dist/eslint/role-utilities.js.map +1 -0
- package/dist/feedback/feedback-menu.d.ts +2 -2
- package/dist/feedback/feedback-menu.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +3 -8
- package/dist/feedback/feedback-thread.js +0 -2
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/hooks/use-dismiss.d.ts +16 -3
- package/dist/hooks/use-dismiss.js +14 -2
- package/dist/hooks/use-dismiss.js.map +1 -1
- package/dist/i18n/defaults.js +5 -1
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +97 -1
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +29 -4
- package/dist/i18n/kit-labels.js +21 -1
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +104 -3
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +95 -1
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +99 -3
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +95 -1
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +99 -3
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +95 -1
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +13 -0
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js +3 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/device-settings.d.ts +72 -0
- package/dist/lib/device-settings.js +64 -0
- package/dist/lib/device-settings.js.map +1 -0
- package/dist/lib/plain-text.d.ts +11 -0
- package/dist/lib/plain-text.js +16 -0
- package/dist/lib/plain-text.js.map +1 -0
- package/dist/lib/refs.d.ts +13 -0
- package/dist/lib/refs.js +15 -0
- package/dist/lib/refs.js.map +1 -0
- package/dist/lib/safe-storage.d.ts +6 -0
- package/dist/lib/safe-storage.js +11 -0
- package/dist/lib/safe-storage.js.map +1 -1
- package/dist/notifications/notification-parts.d.ts +39 -0
- package/dist/notifications/notification-parts.js +47 -0
- package/dist/notifications/notification-parts.js.map +1 -0
- package/dist/notifications/notification-types-setting.d.ts +62 -0
- package/dist/notifications/notification-types-setting.js +192 -0
- package/dist/notifications/notification-types-setting.js.map +1 -0
- package/dist/notifications/notification-types.d.ts +75 -0
- package/dist/notifications/notification-types.js +2 -0
- package/dist/notifications/notification-types.js.map +1 -0
- package/dist/notifications/notifications-labels.d.ts +131 -0
- package/dist/notifications/notifications-labels.js +83 -0
- package/dist/notifications/notifications-labels.js.map +1 -0
- package/dist/notifications/push-device-setting.d.ts +37 -0
- package/dist/notifications/push-device-setting.js +164 -0
- package/dist/notifications/push-device-setting.js.map +1 -0
- package/dist/notifications/push-devices-setting.d.ts +44 -0
- package/dist/notifications/push-devices-setting.js +203 -0
- package/dist/notifications/push-devices-setting.js.map +1 -0
- package/dist/notifications/quiet-hours-setting.d.ts +47 -0
- package/dist/notifications/quiet-hours-setting.js +131 -0
- package/dist/notifications/quiet-hours-setting.js.map +1 -0
- package/dist/notifications/time-zone-select.d.ts +50 -0
- package/dist/notifications/time-zone-select.js +76 -0
- package/dist/notifications/time-zone-select.js.map +1 -0
- package/dist/notifications/unsubscribe-panel.d.ts +53 -0
- package/dist/notifications/unsubscribe-panel.js +139 -0
- package/dist/notifications/unsubscribe-panel.js.map +1 -0
- package/dist/notifications/use-push-device.d.ts +122 -0
- package/dist/notifications/use-push-device.js +230 -0
- package/dist/notifications/use-push-device.js.map +1 -0
- package/dist/rhf/fields.d.ts +36 -29
- package/dist/rhf/fields.js +51 -22
- package/dist/rhf/fields.js.map +1 -1
- package/dist/rhf/form-core.d.ts +5 -4
- package/dist/rhf/form-core.js.map +1 -1
- package/dist/rhf/form.d.ts +7 -36
- package/dist/rhf/form.js +1 -16
- package/dist/rhf/form.js.map +1 -1
- package/dist/rhf/line-items.d.ts +1 -1
- package/dist/rhf/line-items.js.map +1 -1
- package/dist/rhf/use-rhf-wizard-step.js.map +1 -1
- package/dist/rhf.js.map +1 -1
- package/dist/settings/device-reset-setting-labels.d.ts +3 -0
- package/dist/settings/device-reset-setting-labels.js +15 -0
- package/dist/settings/device-reset-setting-labels.js.map +1 -0
- package/dist/settings/device-reset-setting.d.ts +58 -0
- package/dist/settings/device-reset-setting.js +51 -0
- package/dist/settings/device-reset-setting.js.map +1 -0
- package/dist/shell/app-shell.js +5 -0
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/option-switcher-menu.d.ts +5 -17
- package/dist/shell/option-switcher-menu.js +1 -3
- package/dist/shell/option-switcher-menu.js.map +1 -1
- package/dist/shell/role-switcher.d.ts +1 -4
- package/dist/shell/role-switcher.js +2 -3
- package/dist/shell/role-switcher.js.map +1 -1
- package/dist/shell/topbar-action-menu.d.ts +7 -19
- package/dist/shell/topbar-action-menu.js +1 -3
- package/dist/shell/topbar-action-menu.js.map +1 -1
- package/dist/shell/topbar-controls.d.ts +3 -12
- package/dist/shell/topbar-controls.js +6 -9
- package/dist/shell/topbar-controls.js.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/viewport.d.ts +25 -2
- package/dist/testing/viewport.js +61 -10
- package/dist/testing/viewport.js.map +1 -1
- package/dist/theme/contrast-tokens.d.ts +42 -4
- package/dist/theme/contrast-tokens.js +56 -9
- package/dist/theme/contrast-tokens.js.map +1 -1
- package/dist/theme/contrast.d.ts +4 -2
- package/dist/theme/contrast.js +13 -0
- package/dist/theme/contrast.js.map +1 -1
- package/dist/theme/palette-derive.d.ts +15 -1
- package/dist/theme/palette-derive.js +37 -8
- package/dist/theme/palette-derive.js.map +1 -1
- package/dist/theme/palette-presets.d.ts +2 -8
- package/dist/theme/palette-presets.js +5 -284
- package/dist/theme/palette-presets.js.map +1 -1
- package/dist/theme/palette-store.js +6 -0
- package/dist/theme/palette-store.js.map +1 -1
- package/dist/theme/text-size.js +6 -0
- package/dist/theme/text-size.js.map +1 -1
- package/dist/theme/theme-store.js +6 -0
- package/dist/theme/theme-store.js.map +1 -1
- package/dist/wizard/types.d.ts +0 -5
- package/dist/wizard/types.js +1 -5
- package/dist/wizard/types.js.map +1 -1
- package/package.json +9 -1
- package/src/admin/role-select.tsx +4 -1
- package/src/billing/billing-banner.tsx +5 -2
- package/src/billing/plan-limit-notice.tsx +5 -2
- package/src/chart.ts +5 -3
- package/src/components/amount-input.tsx +4 -7
- package/src/components/autocomplete.tsx +5 -2
- package/src/components/button-look.ts +15 -5
- package/src/components/calculator.tsx +2 -7
- package/src/components/chart-zoom.tsx +4 -47
- package/src/components/checkbox-group.tsx +22 -4
- package/src/components/chip-input.tsx +0 -7
- package/src/components/column-mapper.tsx +6 -2
- package/src/components/combobox.tsx +6 -3
- package/src/components/copy-button.tsx +5 -1
- package/src/components/country-select.tsx +6 -1
- package/src/components/currency-option-list.tsx +8 -42
- package/src/components/currency-select.tsx +12 -3
- package/src/components/danger-confirm.tsx +3 -3
- package/src/components/data-table-filter-popover.tsx +2 -1
- package/src/components/data-table-labels.ts +2 -84
- package/src/components/data-table-shared.tsx +55 -2
- package/src/components/data-table.tsx +29 -17
- package/src/components/date-field.tsx +2 -2
- package/src/components/date-picker.tsx +3 -0
- package/src/components/date-range-picker.tsx +3 -0
- package/src/components/dialog-frame.tsx +3 -1
- package/src/components/dropdown.tsx +42 -18
- package/src/components/entity-combobox.tsx +6 -3
- package/src/components/field-base.tsx +0 -11
- package/src/components/field-parts.tsx +112 -38
- package/src/components/field-strip.tsx +12 -27
- package/src/components/field-sync.tsx +0 -7
- package/src/components/field.tsx +32 -19
- package/src/components/full-bleed-dialog.tsx +4 -3
- package/src/components/help-popover.tsx +9 -7
- package/src/components/hover-menu.tsx +12 -16
- package/src/components/icon-picker.tsx +8 -3
- package/src/components/inline-entity-combobox.tsx +6 -3
- package/src/components/input.tsx +4 -2
- package/src/components/modal.tsx +20 -4
- package/src/components/month-picker.tsx +10 -3
- package/src/components/multi-entity-combobox.tsx +5 -2
- package/src/components/multi-select.tsx +19 -31
- package/src/components/number-input.tsx +5 -10
- package/src/components/numeric-field.ts +10 -2
- package/src/components/one-time-code-input.tsx +5 -3
- package/src/components/phone-input.tsx +4 -0
- package/src/components/popover.tsx +8 -4
- package/src/components/select.tsx +6 -3
- package/src/components/series-chart.tsx +1 -1
- package/src/components/server-wake.tsx +0 -6
- package/src/components/settings-fields.tsx +4 -2
- package/src/components/slider.tsx +10 -3
- package/src/components/stat-tile.tsx +11 -20
- package/src/components/swatch-picker.tsx +9 -4
- package/src/components/swipeable-row.tsx +15 -37
- package/src/components/text-link.tsx +3 -1
- package/src/components/textarea.tsx +11 -4
- package/src/components/toggle-group.tsx +21 -5
- package/src/components/tooltip.tsx +37 -6
- package/src/components/translation-review.tsx +25 -7
- package/src/components/use-table-state.ts +91 -10
- package/src/components/user-avatar.tsx +2 -2
- package/src/components/wizard-stepper.tsx +2 -6
- package/src/currencies.ts +70 -0
- package/src/demo/demo-banner.tsx +7 -2
- package/src/eslint/index.ts +161 -0
- package/src/eslint/role-utilities.generated.ts +146 -0
- package/src/eslint/role-utilities.ts +99 -0
- package/src/feedback/feedback-menu.tsx +2 -2
- package/src/feedback/feedback-thread.tsx +3 -8
- package/src/hooks/use-dismiss.ts +39 -4
- package/src/i18n/defaults.ts +4 -0
- package/src/i18n/german.ts +113 -0
- package/src/i18n/kit-labels.tsx +66 -6
- package/src/i18n/locales/en.ts +6 -0
- package/src/i18n/locales/es.ts +106 -0
- package/src/i18n/locales/fr.ts +109 -2
- package/src/i18n/locales/hu.ts +104 -0
- package/src/i18n/locales/it.ts +108 -2
- package/src/i18n/locales/zh.ts +96 -0
- package/src/i18n/review.ts +13 -0
- package/src/i18n/shared-labels.ts +2 -0
- package/src/index.ts +53 -1
- package/src/lib/device-settings.ts +146 -0
- package/src/lib/plain-text.ts +22 -0
- package/src/lib/refs.ts +22 -0
- package/src/lib/safe-storage.ts +16 -0
- package/src/notifications/notification-parts.tsx +83 -0
- package/src/notifications/notification-types-setting.tsx +309 -0
- package/src/notifications/notification-types.ts +80 -0
- package/src/notifications/notifications-labels.ts +238 -0
- package/src/notifications/push-device-setting.tsx +224 -0
- package/src/notifications/push-devices-setting.tsx +306 -0
- package/src/notifications/quiet-hours-setting.tsx +185 -0
- package/src/notifications/time-zone-select.tsx +126 -0
- package/src/notifications/unsubscribe-panel.tsx +203 -0
- package/src/notifications/use-push-device.ts +392 -0
- package/src/rhf/fields.tsx +87 -39
- package/src/rhf/form-core.tsx +5 -4
- package/src/rhf/form.tsx +7 -43
- package/src/rhf/line-items.tsx +1 -1
- package/src/rhf/use-rhf-wizard-step.ts +4 -4
- package/src/rhf.ts +3 -2
- package/src/settings/device-reset-setting-labels.ts +20 -0
- package/src/settings/device-reset-setting.tsx +119 -0
- package/src/shell/app-shell.tsx +8 -0
- package/src/shell/option-switcher-menu.tsx +5 -22
- package/src/shell/role-switcher.tsx +2 -6
- package/src/shell/topbar-action-menu.tsx +7 -24
- package/src/shell/topbar-controls.tsx +6 -18
- package/src/testing/index.ts +3 -1
- package/src/testing/viewport.ts +125 -19
- package/src/theme/contrast-tokens.ts +106 -12
- package/src/theme/contrast.ts +30 -4
- package/src/theme/palette-derive.ts +68 -7
- package/src/theme/palette-presets.ts +16 -299
- package/src/theme/palette-store.ts +12 -0
- package/src/theme/text-size.ts +8 -0
- package/src/theme/theme-store.ts +10 -0
- package/src/wizard/types.ts +0 -8
- package/tokens.css +38 -4
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const DEFAULT_NOTIFICATIONS_LABELS = {
|
|
3
|
+
typesTitle: "Notify me about",
|
|
4
|
+
typesDescription: "Choose what you hear about, and how.",
|
|
5
|
+
byEmail: "By e-mail",
|
|
6
|
+
emailUnverified: "Confirm your address to receive these.",
|
|
7
|
+
digestCadence: "Frequency",
|
|
8
|
+
digestWeekly: "Weekly",
|
|
9
|
+
digestMonthly: "Monthly",
|
|
10
|
+
typesLoading: "Loading notification settings\u2026",
|
|
11
|
+
typesEmpty: "There are no notifications for this account.",
|
|
12
|
+
quietTitle: "Quiet hours",
|
|
13
|
+
quietDescription: (inbox) => inbox ? "No push notifications during this window. They still reach your inbox." : "No push notifications during this window.",
|
|
14
|
+
quietFrom: "From",
|
|
15
|
+
quietUntil: "Until",
|
|
16
|
+
quietIncomplete: "Set both a start and an end time. Quiet hours take effect once both are set.",
|
|
17
|
+
timeZone: "Time zone",
|
|
18
|
+
deviceZone: (zone) => `This device is in ${zone}.`,
|
|
19
|
+
useDeviceZone: "Use it",
|
|
20
|
+
regions: {
|
|
21
|
+
Africa: "Africa",
|
|
22
|
+
America: "Americas",
|
|
23
|
+
Antarctica: "Antarctica",
|
|
24
|
+
Arctic: "Arctic",
|
|
25
|
+
Asia: "Asia",
|
|
26
|
+
Atlantic: "Atlantic",
|
|
27
|
+
Australia: "Australia",
|
|
28
|
+
Europe: "Europe",
|
|
29
|
+
Indian: "Indian Ocean",
|
|
30
|
+
Pacific: "Pacific"
|
|
31
|
+
},
|
|
32
|
+
pushTitle: "Push notifications",
|
|
33
|
+
pushDescription: "Notifications on this device, also while the app is closed.",
|
|
34
|
+
unsupported: "This browser doesn\u2019t support push notifications.",
|
|
35
|
+
iosInstall: (app) => `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,
|
|
36
|
+
notConfigured: "Push notifications aren\u2019t set up on this server.",
|
|
37
|
+
blocked: "Notifications are blocked in this browser\u2019s settings.",
|
|
38
|
+
on: "Notifications are on for this device.",
|
|
39
|
+
off: "Notifications are off for this device.",
|
|
40
|
+
otherAccount: "This browser gets notifications for another account. Turn them on here to get them for the account you\u2019re signed in with.",
|
|
41
|
+
enable: "Turn on notifications",
|
|
42
|
+
disable: "Turn off",
|
|
43
|
+
sendTest: "Send a test",
|
|
44
|
+
enableFailed: "Couldn\u2019t turn on notifications.",
|
|
45
|
+
noServiceWorker: "Couldn\u2019t reach the app\u2019s service worker. Reload the page and try again.",
|
|
46
|
+
pushTimeout: "The browser\u2019s push service didn\u2019t answer. Check your connection and try again.",
|
|
47
|
+
testSent: (count) => count === 1 ? "Test sent to 1 device" : `Test sent to ${count} devices`,
|
|
48
|
+
testNone: "No device accepted the test. Turn notifications on for this device first.",
|
|
49
|
+
testFailed: "Couldn\u2019t send a test notification.",
|
|
50
|
+
explainerTitle: "Turn on notifications?",
|
|
51
|
+
explainerBody: (app) => `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,
|
|
52
|
+
explainerHint: "Your browser asks for permission next.",
|
|
53
|
+
explainerContinue: "Continue",
|
|
54
|
+
devicesTitle: "Notification devices",
|
|
55
|
+
devicesDescription: "Every device that gets push notifications for your account. Remove any you no longer use.",
|
|
56
|
+
devicesLoading: "Loading devices\u2026",
|
|
57
|
+
devicesEmpty: "No device gets notifications yet.",
|
|
58
|
+
unknownDevice: "Unknown device",
|
|
59
|
+
thisDevice: "This device",
|
|
60
|
+
added: (date) => `Added ${date}`,
|
|
61
|
+
lastDelivery: (date) => `Last delivery ${date}`,
|
|
62
|
+
noDelivery: "No delivery yet",
|
|
63
|
+
failures: (count) => count === 1 ? "1 failed delivery in a row" : `${count} failed deliveries in a row`,
|
|
64
|
+
remove: "Remove",
|
|
65
|
+
removeItem: (device) => `Remove ${device}`,
|
|
66
|
+
removePrompt: "Stop sending notifications to this device?",
|
|
67
|
+
unsubscribeTitle: "E-mail notifications",
|
|
68
|
+
unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,
|
|
69
|
+
unsubscribeGeneric: "You get notification e-mails.",
|
|
70
|
+
stopThese: "Stop these e-mails",
|
|
71
|
+
stopAll: (app) => `Stop all notification e-mails from ${app}`,
|
|
72
|
+
stoppedThese: "Done. You won\u2019t get these e-mails any more.",
|
|
73
|
+
stoppedAll: (app) => `Done. You won\u2019t get notification e-mails from ${app} any more.`,
|
|
74
|
+
accountMail: "E-mails about your account still come.",
|
|
75
|
+
turnBackOn: "You can turn them back on at any time in Settings.",
|
|
76
|
+
openSettings: "Open Settings",
|
|
77
|
+
invalidLink: "This link doesn\u2019t work any more. You can turn e-mails off in Settings instead.",
|
|
78
|
+
failed: "That didn\u2019t work. Please try again."
|
|
79
|
+
};
|
|
80
|
+
export {
|
|
81
|
+
DEFAULT_NOTIFICATIONS_LABELS
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=notifications-labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/notifications-labels.ts"],"sourcesContent":["// The words of the notification cards (docs/notifications-harmonization.md §4.2), in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, so `en` loads as one chunk like the other languages\n// (0.34, KS U8). The cards read it through `useKitLabels(\"notifications\", …)`.\n\n/** The ten IANA regions `Intl` lists zones under — keksdose's `tz_region_*` — in the\n * kit's words. A region a runtime adds later keeps its IANA name. */\nexport interface NotificationRegionLabels {\n Africa: string;\n America: string;\n Antarctica: string;\n Arctic: string;\n Asia: string;\n Atlantic: string;\n Australia: string;\n Europe: string;\n Indian: string;\n Pacific: string;\n}\n\n/**\n * Every string the notification parts render — the `notifications` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`: the types card,\n * quiet hours and the zone picker, this device's push, the device list, and the\n * unsubscribe page. Cancel is `common.cancel`.\n */\nexport interface NotificationsLabels {\n /* ── The types card ─────────────────────────────────────────────────── */\n /** The types card's title. */\n typesTitle: string;\n /** The line under it. */\n typesDescription: string;\n /** The e-mail switch under a type that offers mail. */\n byEmail: string;\n /** Under every e-mail switch while the account's address is unverified (decision 16):\n * no notification mail goes to an unverified address. */\n emailUnverified: string;\n /** The digest's cadence select. */\n digestCadence: string;\n digestWeekly: string;\n digestMonthly: string;\n /** While the settings load. */\n typesLoading: string;\n /** The server answered no types for this account. */\n typesEmpty: string;\n\n /* ── Quiet hours ────────────────────────────────────────────────────── */\n quietTitle: string;\n /** The line under the title; `inbox`: the app keeps an inbox, which a held push still\n * reaches. */\n quietDescription: (inbox: boolean) => string;\n /** The start time's label. */\n quietFrom: string;\n /** The end time's label. */\n quietUntil: string;\n /** One time set, the other not: quiet hours fail open until both are. */\n quietIncomplete: string;\n /** The zone picker's label. */\n timeZone: string;\n /** Given the device's zone, as the picker names it, when it differs from the one the\n * server applies. */\n deviceZone: (zone: string) => string;\n /** The button that takes the device's zone. */\n useDeviceZone: string;\n /** The zone picker's region headings. */\n regions: NotificationRegionLabels;\n\n /* ── This device ────────────────────────────────────────────────────── */\n pushTitle: string;\n pushDescription: string;\n /** The browser has no push. */\n unsupported: string;\n /** iOS outside the installed app, given the app's name. */\n iosInstall: (app: string) => string;\n /** The server has no VAPID keys. */\n notConfigured: string;\n /** The browser's permission is denied. */\n blocked: string;\n /** This device gets notifications for the signed-in account. */\n on: string;\n off: string;\n /** This browser's subscription belongs to another account. */\n otherAccount: string;\n enable: string;\n disable: string;\n sendTest: string;\n /** Turning on did not finish (the permission prompt dismissed, a refusal). */\n enableFailed: string;\n /** No service worker, or one that is not ready in 10 s. */\n noServiceWorker: string;\n /** The browser's push service did not answer in 15 s. */\n pushTimeout: string;\n /** Given how many devices the push service accepted the test for (≥ 1). */\n testSent: (count: number) => string;\n /** The test reached no device. */\n testNone: string;\n testFailed: string;\n /** The explainer before the browser's one permission prompt. */\n explainerTitle: string;\n explainerBody: (app: string) => string;\n explainerHint: string;\n explainerContinue: string;\n\n /* ── The device list ────────────────────────────────────────────────── */\n devicesTitle: string;\n devicesDescription: string;\n devicesLoading: string;\n devicesEmpty: string;\n /** A device whose user agent says nothing the kit recognises. */\n unknownDevice: string;\n /** The chip on this browser's row. */\n thisDevice: string;\n /** Given the registration date, formatted. */\n added: (date: string) => string;\n /** Given the last accepted delivery, formatted. */\n lastDelivery: (date: string) => string;\n noDelivery: string;\n /** Given the failed deliveries in a row (≥ 1). */\n failures: (count: number) => string;\n /** A row's button, visible text — and the confirm's answer. */\n remove: string;\n /** The same button's accessible name, given the device: it starts with `remove`. */\n removeItem: (device: string) => string;\n /** The question the row asks before it removes. */\n removePrompt: string;\n\n /* ── The unsubscribe page ───────────────────────────────────────────── */\n unsubscribeTitle: string;\n /** Given the type's name in the app's words. */\n unsubscribeAbout: (type: string) => string;\n /** No type name to give. */\n unsubscribeGeneric: string;\n stopThese: string;\n stopAll: (app: string) => string;\n stoppedThese: string;\n stoppedAll: (app: string) => string;\n /** Account mail is not a notification, and keeps coming. */\n accountMail: string;\n turnBackOn: string;\n openSettings: string;\n /** A token the server refused, or one that does not parse. */\n invalidLink: string;\n\n /* ── Every card ─────────────────────────────────────────────────────── */\n /** A request failed, and the app had no words of its own. */\n failed: string;\n}\n\nexport const DEFAULT_NOTIFICATIONS_LABELS: NotificationsLabels = {\n typesTitle: \"Notify me about\",\n typesDescription: \"Choose what you hear about, and how.\",\n byEmail: \"By e-mail\",\n emailUnverified: \"Confirm your address to receive these.\",\n digestCadence: \"Frequency\",\n digestWeekly: \"Weekly\",\n digestMonthly: \"Monthly\",\n typesLoading: \"Loading notification settings…\",\n typesEmpty: \"There are no notifications for this account.\",\n\n quietTitle: \"Quiet hours\",\n quietDescription: (inbox) =>\n inbox\n ? \"No push notifications during this window. They still reach your inbox.\"\n : \"No push notifications during this window.\",\n quietFrom: \"From\",\n quietUntil: \"Until\",\n quietIncomplete: \"Set both a start and an end time. Quiet hours take effect once both are set.\",\n timeZone: \"Time zone\",\n deviceZone: (zone) => `This device is in ${zone}.`,\n useDeviceZone: \"Use it\",\n regions: {\n Africa: \"Africa\",\n America: \"Americas\",\n Antarctica: \"Antarctica\",\n Arctic: \"Arctic\",\n Asia: \"Asia\",\n Atlantic: \"Atlantic\",\n Australia: \"Australia\",\n Europe: \"Europe\",\n Indian: \"Indian Ocean\",\n Pacific: \"Pacific\",\n },\n\n pushTitle: \"Push notifications\",\n pushDescription: \"Notifications on this device, also while the app is closed.\",\n unsupported: \"This browser doesn’t support push notifications.\",\n iosInstall: (app) =>\n `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,\n notConfigured: \"Push notifications aren’t set up on this server.\",\n blocked: \"Notifications are blocked in this browser’s settings.\",\n on: \"Notifications are on for this device.\",\n off: \"Notifications are off for this device.\",\n otherAccount:\n \"This browser gets notifications for another account. Turn them on here to get them for the account you’re signed in with.\",\n enable: \"Turn on notifications\",\n disable: \"Turn off\",\n sendTest: \"Send a test\",\n enableFailed: \"Couldn’t turn on notifications.\",\n noServiceWorker: \"Couldn’t reach the app’s service worker. Reload the page and try again.\",\n pushTimeout: \"The browser’s push service didn’t answer. Check your connection and try again.\",\n testSent: (count) => (count === 1 ? \"Test sent to 1 device\" : `Test sent to ${count} devices`),\n testNone: \"No device accepted the test. Turn notifications on for this device first.\",\n testFailed: \"Couldn’t send a test notification.\",\n explainerTitle: \"Turn on notifications?\",\n explainerBody: (app) =>\n `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,\n explainerHint: \"Your browser asks for permission next.\",\n explainerContinue: \"Continue\",\n\n devicesTitle: \"Notification devices\",\n devicesDescription: \"Every device that gets push notifications for your account. Remove any you no longer use.\",\n devicesLoading: \"Loading devices…\",\n devicesEmpty: \"No device gets notifications yet.\",\n unknownDevice: \"Unknown device\",\n thisDevice: \"This device\",\n added: (date) => `Added ${date}`,\n lastDelivery: (date) => `Last delivery ${date}`,\n noDelivery: \"No delivery yet\",\n failures: (count) =>\n count === 1 ? \"1 failed delivery in a row\" : `${count} failed deliveries in a row`,\n remove: \"Remove\",\n removeItem: (device) => `Remove ${device}`,\n removePrompt: \"Stop sending notifications to this device?\",\n\n unsubscribeTitle: \"E-mail notifications\",\n unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,\n unsubscribeGeneric: \"You get notification e-mails.\",\n stopThese: \"Stop these e-mails\",\n stopAll: (app) => `Stop all notification e-mails from ${app}`,\n stoppedThese: \"Done. You won’t get these e-mails any more.\",\n stoppedAll: (app) => `Done. You won’t get notification e-mails from ${app} any more.`,\n accountMail: \"E-mails about your account still come.\",\n turnBackOn: \"You can turn them back on at any time in Settings.\",\n openSettings: \"Open Settings\",\n invalidLink: \"This link doesn’t work any more. You can turn e-mails off in Settings instead.\",\n\n failed: \"That didn’t work. Please try again.\",\n};\n"],"mappings":";AAoJO,MAAM,+BAAoD;AAAA,EAC/D,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EAEZ,YAAY;AAAA,EACZ,kBAAkB,CAAC,UACjB,QACI,2EACA;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,YAAY,CAAC,SAAS,qBAAqB,IAAI;AAAA,EAC/C,eAAe;AAAA,EACf,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,YAAY,CAAC,QACX,0BAA0B,GAAG;AAAA,EAC/B,eAAe;AAAA,EACf,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,cACE;AAAA,EACF,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,UAAU,CAAC,UAAW,UAAU,IAAI,0BAA0B,gBAAgB,KAAK;AAAA,EACnF,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe,CAAC,QACd,GAAG,GAAG;AAAA,EACR,eAAe;AAAA,EACf,mBAAmB;AAAA,EAEnB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,OAAO,CAAC,SAAS,SAAS,IAAI;AAAA,EAC9B,cAAc,CAAC,SAAS,iBAAiB,IAAI;AAAA,EAC7C,YAAY;AAAA,EACZ,UAAU,CAAC,UACT,UAAU,IAAI,+BAA+B,GAAG,KAAK;AAAA,EACvD,QAAQ;AAAA,EACR,YAAY,CAAC,WAAW,UAAU,MAAM;AAAA,EACxC,cAAc;AAAA,EAEd,kBAAkB;AAAA,EAClB,kBAAkB,CAAC,SAAS,0BAA0B,IAAI;AAAA,EAC1D,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,SAAS,CAAC,QAAQ,sCAAsC,GAAG;AAAA,EAC3D,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ,sDAAiD,GAAG;AAAA,EACzE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEb,QAAQ;AACV;","names":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
import { type LabelOverride } from "../i18n/kit-labels.js";
|
|
3
|
+
import type { NotificationsLabels } from "./notifications-labels.js";
|
|
4
|
+
import type { PushDevice } from "./use-push-device.js";
|
|
5
|
+
/** Which action failed — {@link PushDeviceSettingProps.describeError}'s second argument. */
|
|
6
|
+
export type PushDeviceAction = "enable" | "disable" | "test";
|
|
7
|
+
export interface PushDeviceSettingProps extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
8
|
+
/** This browser's push, from {@link usePushDevice}. */
|
|
9
|
+
push: PushDevice;
|
|
10
|
+
/** The app's name, for the iOS line and the explainer. */
|
|
11
|
+
appName: string;
|
|
12
|
+
/** The app's own words for a failure, or `undefined` for the kit's. The kit already
|
|
13
|
+
* has words for a missing service worker and an unanswered push service. */
|
|
14
|
+
describeError?: (error: unknown, action: PushDeviceAction) => ReactNode | undefined;
|
|
15
|
+
labels?: LabelOverride<NotificationsLabels>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Push on THIS device (docs/notifications-harmonization.md §2.2, §2.7, §4.2): keksdose's
|
|
19
|
+
* push block, as a card of its own. Registering the device is the switch — push has no
|
|
20
|
+
* account switch. One state at a time, in keksdose's order
|
|
21
|
+
* (`notifications-card.tsx:333-402`):
|
|
22
|
+
*
|
|
23
|
+
* 1. the browser has no push;
|
|
24
|
+
* 2. iOS outside the installed app (iOS delivers only to the installed app);
|
|
25
|
+
* 3. push is not set up on the server (no VAPID keys);
|
|
26
|
+
* 4. notifications blocked in the browser;
|
|
27
|
+
* 5. on or off — with "another account" when this browser's subscription is someone
|
|
28
|
+
* else's — and "Turn on notifications", or "Send a test" and "Turn off".
|
|
29
|
+
*
|
|
30
|
+
* **The explainer comes before the browser's one prompt**: turning on while the
|
|
31
|
+
* permission is still `"default"` opens a dialog first (what the notifications are for,
|
|
32
|
+
* that the browser asks next); with it granted, it goes straight on. A test that reached
|
|
33
|
+
* no device says so (`testNone`) — a 404/410 removes the row on the server while this
|
|
34
|
+
* browser still holds its subscription. Outcomes are a line under the buttons; nothing
|
|
35
|
+
* toasts.
|
|
36
|
+
*/
|
|
37
|
+
export declare function PushDeviceSetting({ push, appName, describeError, labels: labelsProp, className, ...rest }: PushDeviceSettingProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
5
|
+
import { DEFAULT_COMMON_LABELS } from "../i18n/shared-labels.js";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { AlertBanner } from "../components/alert-banner.js";
|
|
8
|
+
import { Button } from "../components/button.js";
|
|
9
|
+
import { Card } from "../components/card.js";
|
|
10
|
+
import { DialogFrame } from "../components/dialog-frame.js";
|
|
11
|
+
import { COMMIT_EXCEPT_BILLING } from "../components/write-lock.js";
|
|
12
|
+
import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes.js";
|
|
13
|
+
import { SettingsCardTitle } from "../settings/settings-heading.js";
|
|
14
|
+
import { useMounted } from "../account/account-parts.js";
|
|
15
|
+
import { describeFailure, FailureLine, useNotificationsLabels } from "./notification-parts.js";
|
|
16
|
+
import { PushDeviceError } from "./use-push-device.js";
|
|
17
|
+
function PushDeviceSetting({
|
|
18
|
+
push,
|
|
19
|
+
appName,
|
|
20
|
+
describeError,
|
|
21
|
+
labels: labelsProp,
|
|
22
|
+
className,
|
|
23
|
+
...rest
|
|
24
|
+
}) {
|
|
25
|
+
const labels = useNotificationsLabels(labelsProp);
|
|
26
|
+
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
27
|
+
const [explainer, setExplainer] = useState(false);
|
|
28
|
+
const [running, setRunning] = useState(null);
|
|
29
|
+
const [outcome, setOutcome] = useState(null);
|
|
30
|
+
const mounted = useMounted();
|
|
31
|
+
const failureOf = (error, action, fallback) => {
|
|
32
|
+
if (error instanceof PushDeviceError) {
|
|
33
|
+
return error.code === "no_service_worker" ? labels.noServiceWorker : labels.pushTimeout;
|
|
34
|
+
}
|
|
35
|
+
return describeFailure(describeError?.(error, action), fallback);
|
|
36
|
+
};
|
|
37
|
+
const run = (action, call, done, fallback) => {
|
|
38
|
+
if (running) return;
|
|
39
|
+
setRunning(action);
|
|
40
|
+
setOutcome(null);
|
|
41
|
+
call().then(
|
|
42
|
+
(value) => {
|
|
43
|
+
if (!mounted.current) return;
|
|
44
|
+
setRunning(null);
|
|
45
|
+
setOutcome(done(value));
|
|
46
|
+
},
|
|
47
|
+
(error) => {
|
|
48
|
+
if (!mounted.current) return;
|
|
49
|
+
setRunning(null);
|
|
50
|
+
setOutcome({ tone: "danger", text: failureOf(error, action, fallback) });
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
const enable = () => run(
|
|
55
|
+
"enable",
|
|
56
|
+
() => push.enable(),
|
|
57
|
+
(ok) => ok ? null : { tone: "danger", text: labels.enableFailed },
|
|
58
|
+
labels.enableFailed
|
|
59
|
+
);
|
|
60
|
+
const disable = () => run("disable", () => push.disable(), () => null, labels.failed);
|
|
61
|
+
const test = () => run(
|
|
62
|
+
"test",
|
|
63
|
+
() => push.sendTest(),
|
|
64
|
+
({ sent }) => sent > 0 ? { tone: "status", text: labels.testSent(sent) } : { tone: "warning", text: labels.testNone },
|
|
65
|
+
labels.testFailed
|
|
66
|
+
);
|
|
67
|
+
const turnOn = () => {
|
|
68
|
+
if (push.permission === "granted") enable();
|
|
69
|
+
else setExplainer(true);
|
|
70
|
+
};
|
|
71
|
+
let state;
|
|
72
|
+
if (!push.supported) {
|
|
73
|
+
state = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.unsupported });
|
|
74
|
+
} else if (push.ios && !push.installed) {
|
|
75
|
+
state = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.iosInstall(appName) });
|
|
76
|
+
} else if (push.configured === false) {
|
|
77
|
+
state = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.notConfigured });
|
|
78
|
+
} else if (push.permission === "denied") {
|
|
79
|
+
state = /* @__PURE__ */ jsx("p", { className: "text-xs text-warning", children: labels.blocked });
|
|
80
|
+
} else {
|
|
81
|
+
const busy = push.busy || running !== null;
|
|
82
|
+
state = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, "data-push-state": push.subscribed ? "on" : "off", children: push.subscribed ? labels.on : labels.off }),
|
|
84
|
+
push.foreignSubscription && /* @__PURE__ */ jsx("p", { className: "text-xs text-warning", children: labels.otherAccount }),
|
|
85
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: push.subscribed ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
86
|
+
/* @__PURE__ */ jsx(
|
|
87
|
+
Button,
|
|
88
|
+
{
|
|
89
|
+
type: "button",
|
|
90
|
+
size: "sm",
|
|
91
|
+
variant: "secondary",
|
|
92
|
+
commit: COMMIT_EXCEPT_BILLING,
|
|
93
|
+
pending: running === "test",
|
|
94
|
+
disabled: busy && running !== "test",
|
|
95
|
+
onClick: test,
|
|
96
|
+
children: labels.sendTest
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ jsx(
|
|
100
|
+
Button,
|
|
101
|
+
{
|
|
102
|
+
type: "button",
|
|
103
|
+
size: "sm",
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
commit: COMMIT_EXCEPT_BILLING,
|
|
106
|
+
pending: running === "disable",
|
|
107
|
+
disabled: busy && running !== "disable",
|
|
108
|
+
onClick: disable,
|
|
109
|
+
children: labels.disable
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }) : /* @__PURE__ */ jsx(
|
|
113
|
+
Button,
|
|
114
|
+
{
|
|
115
|
+
type: "button",
|
|
116
|
+
size: "sm",
|
|
117
|
+
commit: COMMIT_EXCEPT_BILLING,
|
|
118
|
+
pending: running === "enable",
|
|
119
|
+
disabled: busy && running !== "enable",
|
|
120
|
+
onClick: turnOn,
|
|
121
|
+
children: labels.enable
|
|
122
|
+
}
|
|
123
|
+
) }),
|
|
124
|
+
outcome?.tone === "status" && /* @__PURE__ */ jsx("p", { role: "status", className: CARD_DESCRIPTION_CLASS, children: outcome.text }),
|
|
125
|
+
outcome?.tone === "warning" && /* @__PURE__ */ jsx(AlertBanner, { tone: "warning", size: "sm", role: "status", children: outcome.text }),
|
|
126
|
+
outcome?.tone === "danger" && /* @__PURE__ */ jsx(FailureLine, { children: outcome.text })
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
|
|
130
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
131
|
+
/* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.pushTitle }),
|
|
132
|
+
/* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.pushDescription })
|
|
133
|
+
] }),
|
|
134
|
+
state,
|
|
135
|
+
/* @__PURE__ */ jsx(
|
|
136
|
+
DialogFrame,
|
|
137
|
+
{
|
|
138
|
+
open: explainer,
|
|
139
|
+
onClose: () => setExplainer(false),
|
|
140
|
+
title: labels.explainerTitle,
|
|
141
|
+
description: labels.explainerBody(appName),
|
|
142
|
+
actions: (close) => /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
143
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", onClick: close, children: common.cancel }),
|
|
144
|
+
/* @__PURE__ */ jsx(
|
|
145
|
+
Button,
|
|
146
|
+
{
|
|
147
|
+
type: "button",
|
|
148
|
+
onClick: () => {
|
|
149
|
+
setExplainer(false);
|
|
150
|
+
enable();
|
|
151
|
+
},
|
|
152
|
+
children: labels.explainerContinue
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
] }),
|
|
156
|
+
children: /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.explainerHint })
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] });
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
PushDeviceSetting
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=push-device-setting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/push-device-setting.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ComponentPropsWithRef, ReactNode } from \"react\";\n\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { AlertBanner } from \"../components/alert-banner\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { DialogFrame } from \"../components/dialog-frame\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport { PushDeviceError } from \"./use-push-device\";\nimport type { PushDevice } from \"./use-push-device\";\n\n/** Which action failed — {@link PushDeviceSettingProps.describeError}'s second argument. */\nexport type PushDeviceAction = \"enable\" | \"disable\" | \"test\";\n\nexport interface PushDeviceSettingProps extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** This browser's push, from {@link usePushDevice}. */\n push: PushDevice;\n /** The app's name, for the iOS line and the explainer. */\n appName: string;\n /** The app's own words for a failure, or `undefined` for the kit's. The kit already\n * has words for a missing service worker and an unanswered push service. */\n describeError?: (error: unknown, action: PushDeviceAction) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** What the line under the buttons says. */\ntype Outcome = { tone: \"status\" | \"warning\" | \"danger\"; text: ReactNode } | null;\n\n/**\n * Push on THIS device (docs/notifications-harmonization.md §2.2, §2.7, §4.2): keksdose's\n * push block, as a card of its own. Registering the device is the switch — push has no\n * account switch. One state at a time, in keksdose's order\n * (`notifications-card.tsx:333-402`):\n *\n * 1. the browser has no push;\n * 2. iOS outside the installed app (iOS delivers only to the installed app);\n * 3. push is not set up on the server (no VAPID keys);\n * 4. notifications blocked in the browser;\n * 5. on or off — with \"another account\" when this browser's subscription is someone\n * else's — and \"Turn on notifications\", or \"Send a test\" and \"Turn off\".\n *\n * **The explainer comes before the browser's one prompt**: turning on while the\n * permission is still `\"default\"` opens a dialog first (what the notifications are for,\n * that the browser asks next); with it granted, it goes straight on. A test that reached\n * no device says so (`testNone`) — a 404/410 removes the row on the server while this\n * browser still holds its subscription. Outcomes are a line under the buttons; nothing\n * toasts.\n */\nexport function PushDeviceSetting({\n push,\n appName,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDeviceSettingProps) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const [explainer, setExplainer] = useState(false);\n const [running, setRunning] = useState<PushDeviceAction | null>(null);\n const [outcome, setOutcome] = useState<Outcome>(null);\n const mounted = useMounted();\n\n const failureOf = (error: unknown, action: PushDeviceAction, fallback: string): ReactNode => {\n if (error instanceof PushDeviceError) {\n return error.code === \"no_service_worker\" ? labels.noServiceWorker : labels.pushTimeout;\n }\n return describeFailure(describeError?.(error, action), fallback);\n };\n\n const run = <T,>(action: PushDeviceAction, call: () => Promise<T>, done: (value: T) => Outcome, fallback: string) => {\n if (running) return;\n setRunning(action);\n setOutcome(null);\n call().then(\n (value) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome(done(value));\n },\n (error: unknown) => {\n if (!mounted.current) return;\n setRunning(null);\n setOutcome({ tone: \"danger\", text: failureOf(error, action, fallback) });\n },\n );\n };\n\n const enable = () =>\n run(\n \"enable\",\n () => push.enable(),\n (ok): Outcome => (ok ? null : { tone: \"danger\", text: labels.enableFailed }),\n labels.enableFailed,\n );\n const disable = () => run(\"disable\", () => push.disable(), () => null, labels.failed);\n const test = () =>\n run(\n \"test\",\n () => push.sendTest(),\n ({ sent }): Outcome =>\n sent > 0 ? { tone: \"status\", text: labels.testSent(sent) } : { tone: \"warning\", text: labels.testNone },\n labels.testFailed,\n );\n\n const turnOn = () => {\n if (push.permission === \"granted\") enable();\n else setExplainer(true);\n };\n\n let state: ReactNode;\n if (!push.supported) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.unsupported}</p>;\n } else if (push.ios && !push.installed) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.iosInstall(appName)}</p>;\n } else if (push.configured === false) {\n state = <p className={CARD_DESCRIPTION_CLASS}>{labels.notConfigured}</p>;\n } else if (push.permission === \"denied\") {\n state = <p className=\"text-xs text-warning\">{labels.blocked}</p>;\n } else {\n const busy = push.busy || running !== null;\n state = (\n <>\n <p className={CARD_DESCRIPTION_CLASS} data-push-state={push.subscribed ? \"on\" : \"off\"}>\n {push.subscribed ? labels.on : labels.off}\n </p>\n {push.foreignSubscription && <p className=\"text-xs text-warning\">{labels.otherAccount}</p>}\n <div className=\"flex flex-wrap gap-2\">\n {push.subscribed ? (\n <>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"secondary\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"test\"}\n disabled={busy && running !== \"test\"}\n onClick={test}\n >\n {labels.sendTest}\n </Button>\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"disable\"}\n disabled={busy && running !== \"disable\"}\n onClick={disable}\n >\n {labels.disable}\n </Button>\n </>\n ) : (\n <Button\n type=\"button\"\n size=\"sm\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={running === \"enable\"}\n disabled={busy && running !== \"enable\"}\n onClick={turnOn}\n >\n {labels.enable}\n </Button>\n )}\n </div>\n {outcome?.tone === \"status\" && (\n <p role=\"status\" className={CARD_DESCRIPTION_CLASS}>\n {outcome.text}\n </p>\n )}\n {outcome?.tone === \"warning\" && (\n <AlertBanner tone=\"warning\" size=\"sm\" role=\"status\">\n {outcome.text}\n </AlertBanner>\n )}\n {outcome?.tone === \"danger\" && <FailureLine>{outcome.text}</FailureLine>}\n </>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.pushTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.pushDescription}</div>\n </div>\n {state}\n <DialogFrame\n open={explainer}\n onClose={() => setExplainer(false)}\n title={labels.explainerTitle}\n description={labels.explainerBody(appName)}\n actions={(close) => (\n <div className=\"flex justify-end gap-2\">\n <Button type=\"button\" variant=\"ghost\" onClick={close}>\n {common.cancel}\n </Button>\n <Button\n type=\"button\"\n onClick={() => {\n setExplainer(false);\n // Only now the browser's one permission prompt.\n enable();\n }}\n >\n {labels.explainerContinue}\n </Button>\n </div>\n )}\n >\n <p className={CARD_DESCRIPTION_CLASS}>{labels.explainerHint}</p>\n </DialogFrame>\n </Card>\n );\n}\n"],"mappings":";AAwHY,SAiBA,UAjBA,KAiBA,YAjBA;AAxHZ,SAAS,gBAAgB;AAGzB,SAAS,oBAAwC;AACjD,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB,aAAa,8BAA8B;AAErE,SAAS,uBAAuB;AAwCzB,SAAS,kBAAkB;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA,GAAG;AACL,GAA2B;AACzB,QAAM,SAAS,uBAAuB,UAAU;AAChD,QAAM,SAAS,aAAa,UAAU,qBAAqB;AAC3D,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAkC,IAAI;AACpE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAkB,IAAI;AACpD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AAAA,UAC9B,SAAS;AAAA,UAER,iBAAO;AAAA;AAAA,MACV,GAEJ;AAAA,MACC,SAAS,SAAS,YACjB,oBAAC,OAAE,MAAK,UAAS,WAAW,wBACzB,kBAAQ,MACX;AAAA,MAED,SAAS,SAAS,aACjB,oBAAC,eAAY,MAAK,WAAU,MAAK,MAAK,MAAK,UACxC,kBAAQ,MACX;AAAA,MAED,SAAS,SAAS,YAAY,oBAAC,eAAa,kBAAQ,MAAK;AAAA,OAC5D;AAAA,EAEJ;AAEA,SACE,qBAAC,QAAM,GAAG,MAAM,WAAW,GAAG,iBAAiB,SAAS,GACtD;AAAA,yBAAC,SACC;AAAA,0BAAC,qBAAmB,iBAAO,WAAU;AAAA,MACrC,oBAAC,SAAI,WAAW,wBAAyB,iBAAO,iBAAgB;AAAA,OAClE;AAAA,IACC;AAAA,IACD;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,SAAS,MAAM,aAAa,KAAK;AAAA,QACjC,OAAO,OAAO;AAAA,QACd,aAAa,OAAO,cAAc,OAAO;AAAA,QACzC,SAAS,CAAC,UACR,qBAAC,SAAI,WAAU,0BACb;AAAA,8BAAC,UAAO,MAAK,UAAS,SAAQ,SAAQ,SAAS,OAC5C,iBAAO,QACV;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,SAAS,MAAM;AACb,6BAAa,KAAK;AAElB,uBAAO;AAAA,cACT;AAAA,cAEC,iBAAO;AAAA;AAAA,UACV;AAAA,WACF;AAAA,QAGF,8BAAC,OAAE,WAAW,wBAAyB,iBAAO,eAAc;AAAA;AAAA,IAC9D;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
2
|
+
import { type LabelOverride } from "../i18n/kit-labels.js";
|
|
3
|
+
import type { NotificationsLabels } from "./notifications-labels.js";
|
|
4
|
+
import type { PushDeviceItem } from "./notification-types.js";
|
|
5
|
+
/**
|
|
6
|
+
* A name for a stored user agent: "Chrome · Android", "Firefox · Windows" (keksdose
|
|
7
|
+
* `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back
|
|
8
|
+
* as it is, cut at 60 characters so a token soup cannot blow up the row; `null` for none.
|
|
9
|
+
* The order matters — Edge and Opera say "Chrome" too, and Chrome says "Safari".
|
|
10
|
+
*/
|
|
11
|
+
export declare function describeUserAgent(ua: string | null): string | null;
|
|
12
|
+
export interface PushDevicesSettingProps<Id extends string | number = string> extends Omit<ComponentPropsWithRef<"div">, "children"> {
|
|
13
|
+
/** `GET /notifications/devices`, oldest first; `undefined` while the first load runs. */
|
|
14
|
+
devices: readonly PushDeviceItem<Id>[] | undefined;
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
/** This browser's endpoint (`usePushDevice().currentEndpoint`): its row says "This
|
|
17
|
+
* device", and removing it also unsubscribes the browser. */
|
|
18
|
+
currentEndpoint?: string | null;
|
|
19
|
+
/** `DELETE /notifications/devices/{id}`. Asked first; refresh `devices` once it
|
|
20
|
+
* resolves. */
|
|
21
|
+
onRemove: (id: Id) => Promise<unknown> | void;
|
|
22
|
+
/** The dates' text. Default: the provider's locale, medium date. */
|
|
23
|
+
formatDate?: (date: Date) => string;
|
|
24
|
+
/** Overrides the provider's locale for the default format. */
|
|
25
|
+
locale?: string;
|
|
26
|
+
/** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */
|
|
27
|
+
describeError?: (error: unknown) => ReactNode | undefined;
|
|
28
|
+
labels?: LabelOverride<NotificationsLabels>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Every device that gets push for the account (docs/notifications-harmonization.md §3.5,
|
|
32
|
+
* §4.2) — keksdose's devices card: the browser and system read from the stored user
|
|
33
|
+
* agent, "This device" on this browser's row, when it was added and last delivered to,
|
|
34
|
+
* the failures in a row in the warning tone, and "Remove".
|
|
35
|
+
*
|
|
36
|
+
* **Remove asks first, in the row**, as `PasskeysSetting` does: the card must work in an
|
|
37
|
+
* app without a `ConfirmProvider`, and the question belongs beside the device it names.
|
|
38
|
+
* Focus moves to Cancel. **Removing this device** also unsubscribes the browser and fires
|
|
39
|
+
* `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card
|
|
40
|
+
* stops saying "on".
|
|
41
|
+
*
|
|
42
|
+
* Under a write lock Remove is a `commit` control exempt from billing.
|
|
43
|
+
*/
|
|
44
|
+
export declare function PushDevicesSetting<Id extends string | number = string>({ devices, loading, currentEndpoint, onRemove, formatDate: formatDateProp, locale: localeProp, describeError, labels: labelsProp, className, ...rest }: PushDevicesSettingProps<Id>): import("react").JSX.Element;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { MonitorSmartphone } from "lucide-react";
|
|
5
|
+
import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
|
|
6
|
+
import { DEFAULT_COMMON_LABELS } from "../i18n/shared-labels.js";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
import { formatDate } from "../lib/format.js";
|
|
9
|
+
import { Button } from "../components/button.js";
|
|
10
|
+
import { Card } from "../components/card.js";
|
|
11
|
+
import { Chip } from "../components/chip.js";
|
|
12
|
+
import { Skeleton } from "../components/skeleton.js";
|
|
13
|
+
import { COMMIT_EXCEPT_BILLING } from "../components/write-lock.js";
|
|
14
|
+
import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes.js";
|
|
15
|
+
import { SettingsCardTitle } from "../settings/settings-heading.js";
|
|
16
|
+
import { settle, useMounted } from "../account/account-parts.js";
|
|
17
|
+
import { describeFailure, FailureLine, useNotificationsLabels } from "./notification-parts.js";
|
|
18
|
+
import { notifyPushSubscriptionChanged } from "./use-push-device.js";
|
|
19
|
+
function describeUserAgent(ua) {
|
|
20
|
+
if (!ua) return null;
|
|
21
|
+
const browser = /edg(?:e|a|ios)?\//i.test(ua) ? "Edge" : /opr\/|opera/i.test(ua) ? "Opera" : /firefox|fxios/i.test(ua) ? "Firefox" : /chrome|crios/i.test(ua) ? "Chrome" : /safari/i.test(ua) ? "Safari" : null;
|
|
22
|
+
const os = /windows/i.test(ua) ? "Windows" : /android/i.test(ua) ? "Android" : /iphone|ipad|ipod/i.test(ua) ? "iOS" : /mac os x|macintosh/i.test(ua) ? "macOS" : /linux/i.test(ua) ? "Linux" : null;
|
|
23
|
+
if (!browser && !os) return ua.length > 60 ? `${ua.slice(0, 60)}\u2026` : ua;
|
|
24
|
+
return [browser, os].filter(Boolean).join(" \xB7 ");
|
|
25
|
+
}
|
|
26
|
+
async function unsubscribeThisBrowser() {
|
|
27
|
+
try {
|
|
28
|
+
const registration = await navigator.serviceWorker?.getRegistration();
|
|
29
|
+
const subscription = await registration?.pushManager.getSubscription();
|
|
30
|
+
await subscription?.unsubscribe();
|
|
31
|
+
} catch {
|
|
32
|
+
}
|
|
33
|
+
notifyPushSubscriptionChanged();
|
|
34
|
+
}
|
|
35
|
+
function PushDevicesSetting({
|
|
36
|
+
devices,
|
|
37
|
+
loading,
|
|
38
|
+
currentEndpoint,
|
|
39
|
+
onRemove,
|
|
40
|
+
formatDate: formatDateProp,
|
|
41
|
+
locale: localeProp,
|
|
42
|
+
describeError,
|
|
43
|
+
labels: labelsProp,
|
|
44
|
+
className,
|
|
45
|
+
...rest
|
|
46
|
+
}) {
|
|
47
|
+
const labels = useNotificationsLabels(labelsProp);
|
|
48
|
+
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
49
|
+
const locale = useKitLocale(localeProp);
|
|
50
|
+
const [asking, setAsking] = useState(null);
|
|
51
|
+
const [busyId, setBusyId] = useState(null);
|
|
52
|
+
const [failure, setFailure] = useState(null);
|
|
53
|
+
const mounted = useMounted();
|
|
54
|
+
const dateText = (iso) => {
|
|
55
|
+
const date = new Date(iso);
|
|
56
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
57
|
+
return formatDateProp ? formatDateProp(date) : formatDate(date, "medium", { locale });
|
|
58
|
+
};
|
|
59
|
+
const remove = (device) => {
|
|
60
|
+
if (busyId !== null) return;
|
|
61
|
+
setBusyId(device.id);
|
|
62
|
+
setFailure(null);
|
|
63
|
+
const isThis = Boolean(currentEndpoint) && device.endpoint === currentEndpoint;
|
|
64
|
+
settle(() => onRemove(device.id)).then(async () => {
|
|
65
|
+
if (isThis) await unsubscribeThisBrowser();
|
|
66
|
+
if (!mounted.current) return;
|
|
67
|
+
setBusyId(null);
|
|
68
|
+
setAsking(null);
|
|
69
|
+
}).catch((error) => {
|
|
70
|
+
if (!mounted.current) return;
|
|
71
|
+
setBusyId(null);
|
|
72
|
+
setFailure(describeFailure(describeError?.(error), labels.failed));
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
let body;
|
|
76
|
+
if (loading || devices === void 0) {
|
|
77
|
+
body = /* @__PURE__ */ jsx(Skeleton, { lines: 2, label: labels.devicesLoading });
|
|
78
|
+
} else if (devices.length === 0) {
|
|
79
|
+
body = /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.devicesEmpty });
|
|
80
|
+
} else {
|
|
81
|
+
body = /* @__PURE__ */ jsx("ul", { "aria-label": labels.devicesTitle, className: "divide-y divide-subtle", children: devices.map((device) => /* @__PURE__ */ jsx(
|
|
82
|
+
DeviceRow,
|
|
83
|
+
{
|
|
84
|
+
device,
|
|
85
|
+
name: describeUserAgent(device.user_agent) ?? labels.unknownDevice,
|
|
86
|
+
current: Boolean(currentEndpoint) && device.endpoint === currentEndpoint,
|
|
87
|
+
added: dateText(device.created_at),
|
|
88
|
+
lastDelivery: device.last_success_at ? dateText(device.last_success_at) : null,
|
|
89
|
+
asking: asking === device.id,
|
|
90
|
+
busy: busyId === device.id,
|
|
91
|
+
blocked: busyId !== null && busyId !== device.id,
|
|
92
|
+
onAsk: () => setAsking(device.id),
|
|
93
|
+
onCancel: () => setAsking(null),
|
|
94
|
+
onConfirm: () => remove(device),
|
|
95
|
+
labels,
|
|
96
|
+
cancelLabel: common.cancel
|
|
97
|
+
},
|
|
98
|
+
device.id
|
|
99
|
+
)) });
|
|
100
|
+
}
|
|
101
|
+
return /* @__PURE__ */ jsxs(Card, { ...rest, className: cn("p-4 space-y-3", className), children: [
|
|
102
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
103
|
+
/* @__PURE__ */ jsx(SettingsCardTitle, { children: labels.devicesTitle }),
|
|
104
|
+
/* @__PURE__ */ jsx("div", { className: CARD_DESCRIPTION_CLASS, children: labels.devicesDescription })
|
|
105
|
+
] }),
|
|
106
|
+
body,
|
|
107
|
+
/* @__PURE__ */ jsx(FailureLine, { children: failure })
|
|
108
|
+
] });
|
|
109
|
+
}
|
|
110
|
+
function DeviceRow({
|
|
111
|
+
device,
|
|
112
|
+
name,
|
|
113
|
+
current,
|
|
114
|
+
added,
|
|
115
|
+
lastDelivery,
|
|
116
|
+
asking,
|
|
117
|
+
busy,
|
|
118
|
+
blocked,
|
|
119
|
+
onAsk,
|
|
120
|
+
onCancel,
|
|
121
|
+
onConfirm,
|
|
122
|
+
labels,
|
|
123
|
+
cancelLabel
|
|
124
|
+
}) {
|
|
125
|
+
const cancelRef = useRef(null);
|
|
126
|
+
const removeRef = useRef(null);
|
|
127
|
+
const [returning, setReturning] = useState(false);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (asking) cancelRef.current?.focus();
|
|
130
|
+
else if (returning) removeRef.current?.focus();
|
|
131
|
+
}, [asking, returning]);
|
|
132
|
+
const leave = () => {
|
|
133
|
+
setReturning(true);
|
|
134
|
+
onCancel();
|
|
135
|
+
};
|
|
136
|
+
const escapeLeaves = (event) => {
|
|
137
|
+
if (event.key === "Escape") {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
leave();
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const row = { "data-push-device-id": String(device.id), "data-current": current || void 0 };
|
|
144
|
+
if (asking) {
|
|
145
|
+
return /* @__PURE__ */ jsxs("li", { ...row, className: "space-y-2 py-2", children: [
|
|
146
|
+
/* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm", children: labels.removePrompt }),
|
|
147
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
148
|
+
/* @__PURE__ */ jsx(
|
|
149
|
+
Button,
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
size: "sm",
|
|
153
|
+
variant: "danger",
|
|
154
|
+
commit: COMMIT_EXCEPT_BILLING,
|
|
155
|
+
pending: busy,
|
|
156
|
+
"aria-label": labels.removeItem(name),
|
|
157
|
+
onClick: onConfirm,
|
|
158
|
+
onKeyDown: escapeLeaves,
|
|
159
|
+
children: labels.remove
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ jsx(Button, { ref: cancelRef, type: "button", size: "sm", variant: "ghost", onClick: leave, onKeyDown: escapeLeaves, children: cancelLabel })
|
|
163
|
+
] })
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
return /* @__PURE__ */ jsxs("li", { ...row, className: "flex items-center gap-3 py-2", children: [
|
|
167
|
+
/* @__PURE__ */ jsx(MonitorSmartphone, { "aria-hidden": true, className: "size-4 shrink-0 text-muted" }),
|
|
168
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
169
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
170
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-sm font-medium", children: name }),
|
|
171
|
+
current && /* @__PURE__ */ jsx(Chip, { size: "sm", tone: "brand", children: labels.thisDevice })
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ jsxs("div", { className: CARD_DESCRIPTION_CLASS, children: [
|
|
174
|
+
labels.added(added),
|
|
175
|
+
" \xB7 ",
|
|
176
|
+
lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery
|
|
177
|
+
] }),
|
|
178
|
+
device.failure_count > 0 && /* @__PURE__ */ jsx("div", { className: "text-xs text-warning", children: labels.failures(device.failure_count) })
|
|
179
|
+
] }),
|
|
180
|
+
/* @__PURE__ */ jsx(
|
|
181
|
+
Button,
|
|
182
|
+
{
|
|
183
|
+
ref: removeRef,
|
|
184
|
+
type: "button",
|
|
185
|
+
size: "sm",
|
|
186
|
+
variant: "ghost",
|
|
187
|
+
commit: COMMIT_EXCEPT_BILLING,
|
|
188
|
+
disabled: blocked,
|
|
189
|
+
"aria-label": labels.removeItem(name),
|
|
190
|
+
onClick: () => {
|
|
191
|
+
setReturning(false);
|
|
192
|
+
onAsk();
|
|
193
|
+
},
|
|
194
|
+
children: labels.remove
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
] });
|
|
198
|
+
}
|
|
199
|
+
export {
|
|
200
|
+
PushDevicesSetting,
|
|
201
|
+
describeUserAgent
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=push-devices-setting.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/notifications/push-devices-setting.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate } from \"../lib/format\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { Chip } from \"../components/chip\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type { PushDeviceItem } from \"./notification-types\";\nimport { notifyPushSubscriptionChanged } from \"./use-push-device\";\n\n/**\n * A name for a stored user agent: \"Chrome · Android\", \"Firefox · Windows\" (keksdose\n * `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back\n * as it is, cut at 60 characters so a token soup cannot blow up the row; `null` for none.\n * The order matters — Edge and Opera say \"Chrome\" too, and Chrome says \"Safari\".\n */\nexport function describeUserAgent(ua: string | null): string | null {\n if (!ua) return null;\n const browser = /edg(?:e|a|ios)?\\//i.test(ua)\n ? \"Edge\"\n : /opr\\/|opera/i.test(ua)\n ? \"Opera\"\n : /firefox|fxios/i.test(ua)\n ? \"Firefox\"\n : /chrome|crios/i.test(ua)\n ? \"Chrome\"\n : /safari/i.test(ua)\n ? \"Safari\"\n : null;\n const os = /windows/i.test(ua)\n ? \"Windows\"\n : /android/i.test(ua)\n ? \"Android\"\n : /iphone|ipad|ipod/i.test(ua)\n ? \"iOS\"\n : /mac os x|macintosh/i.test(ua)\n ? \"macOS\"\n : /linux/i.test(ua)\n ? \"Linux\"\n : null;\n if (!browser && !os) return ua.length > 60 ? `${ua.slice(0, 60)}…` : ua;\n return [browser, os].filter(Boolean).join(\" · \");\n}\n\nexport interface PushDevicesSettingProps<Id extends string | number = string>\n extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** `GET /notifications/devices`, oldest first; `undefined` while the first load runs. */\n devices: readonly PushDeviceItem<Id>[] | undefined;\n loading?: boolean;\n /** This browser's endpoint (`usePushDevice().currentEndpoint`): its row says \"This\n * device\", and removing it also unsubscribes the browser. */\n currentEndpoint?: string | null;\n /** `DELETE /notifications/devices/{id}`. Asked first; refresh `devices` once it\n * resolves. */\n onRemove: (id: Id) => Promise<unknown> | void;\n /** The dates' text. Default: the provider's locale, medium date. */\n formatDate?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n /** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** Tear down this browser's subscription after its server row went: otherwise the\n * browser still holds one, and the push card would say \"on\" for a device nothing can\n * reach. Best effort — the row is already gone. */\nasync function unsubscribeThisBrowser(): Promise<void> {\n try {\n const registration = await navigator.serviceWorker?.getRegistration();\n const subscription = await registration?.pushManager.getSubscription();\n await subscription?.unsubscribe();\n } catch {\n /* the server row is gone either way */\n }\n notifyPushSubscriptionChanged();\n}\n\n/**\n * Every device that gets push for the account (docs/notifications-harmonization.md §3.5,\n * §4.2) — keksdose's devices card: the browser and system read from the stored user\n * agent, \"This device\" on this browser's row, when it was added and last delivered to,\n * the failures in a row in the warning tone, and \"Remove\".\n *\n * **Remove asks first, in the row**, as `PasskeysSetting` does: the card must work in an\n * app without a `ConfirmProvider`, and the question belongs beside the device it names.\n * Focus moves to Cancel. **Removing this device** also unsubscribes the browser and fires\n * `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card\n * stops saying \"on\".\n *\n * Under a write lock Remove is a `commit` control exempt from billing.\n */\nexport function PushDevicesSetting<Id extends string | number = string>({\n devices,\n loading,\n currentEndpoint,\n onRemove,\n formatDate: formatDateProp,\n locale: localeProp,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDevicesSettingProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const locale = useKitLocale(localeProp);\n const [asking, setAsking] = useState<Id | null>(null);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const dateText = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n return formatDateProp ? formatDateProp(date) : formatDate(date, \"medium\", { locale });\n };\n\n const remove = (device: PushDeviceItem<Id>) => {\n if (busyId !== null) return;\n setBusyId(device.id);\n setFailure(null);\n const isThis = Boolean(currentEndpoint) && device.endpoint === currentEndpoint;\n settle(() => onRemove(device.id))\n .then(async () => {\n if (isThis) await unsubscribeThisBrowser();\n if (!mounted.current) return;\n setBusyId(null);\n setAsking(null);\n })\n .catch((error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n });\n };\n\n let body: ReactNode;\n if (loading || devices === undefined) {\n body = <Skeleton lines={2} label={labels.devicesLoading} />;\n } else if (devices.length === 0) {\n body = <p className={CARD_DESCRIPTION_CLASS}>{labels.devicesEmpty}</p>;\n } else {\n body = (\n <ul aria-label={labels.devicesTitle} className=\"divide-y divide-subtle\">\n {devices.map((device) => (\n <DeviceRow\n key={device.id}\n device={device}\n name={describeUserAgent(device.user_agent) ?? labels.unknownDevice}\n current={Boolean(currentEndpoint) && device.endpoint === currentEndpoint}\n added={dateText(device.created_at)}\n lastDelivery={device.last_success_at ? dateText(device.last_success_at) : null}\n asking={asking === device.id}\n busy={busyId === device.id}\n blocked={busyId !== null && busyId !== device.id}\n onAsk={() => setAsking(device.id)}\n onCancel={() => setAsking(null)}\n onConfirm={() => remove(device)}\n labels={labels}\n cancelLabel={common.cancel}\n />\n ))}\n </ul>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.devicesTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.devicesDescription}</div>\n </div>\n {body}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n\nfunction DeviceRow<Id extends string | number>({\n device,\n name,\n current,\n added,\n lastDelivery,\n asking,\n busy,\n blocked,\n onAsk,\n onCancel,\n onConfirm,\n labels,\n cancelLabel,\n}: {\n device: PushDeviceItem<Id>;\n name: string;\n current: boolean;\n added: string;\n lastDelivery: string | null;\n asking: boolean;\n busy: boolean;\n blocked: boolean;\n onAsk: () => void;\n onCancel: () => void;\n onConfirm: () => void;\n labels: NotificationsLabels;\n cancelLabel: string;\n}) {\n const cancelRef = useRef<HTMLButtonElement>(null);\n const removeRef = useRef<HTMLButtonElement>(null);\n // Which way the confirm closed: back to Remove, so focus does not fall to <body>.\n const [returning, setReturning] = useState(false);\n useEffect(() => {\n if (asking) cancelRef.current?.focus();\n else if (returning) removeRef.current?.focus();\n }, [asking, returning]);\n\n const leave = () => {\n setReturning(true);\n onCancel();\n };\n const escapeLeaves = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n leave();\n }\n };\n\n const row = { \"data-push-device-id\": String(device.id), \"data-current\": current || undefined };\n\n if (asking) {\n return (\n <li {...row} className=\"space-y-2 py-2\">\n <p role=\"alert\" className=\"text-sm\">\n {labels.removePrompt}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={busy}\n aria-label={labels.removeItem(name)}\n onClick={onConfirm}\n onKeyDown={escapeLeaves}\n >\n {labels.remove}\n </Button>\n <Button ref={cancelRef} type=\"button\" size=\"sm\" variant=\"ghost\" onClick={leave} onKeyDown={escapeLeaves}>\n {cancelLabel}\n </Button>\n </div>\n </li>\n );\n }\n\n return (\n <li {...row} className=\"flex items-center gap-3 py-2\">\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-muted\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{name}</span>\n {current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.thisDevice}\n </Chip>\n )}\n </div>\n <div className={CARD_DESCRIPTION_CLASS}>\n {labels.added(added)}\n {\" · \"}\n {lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery}\n </div>\n {device.failure_count > 0 && <div className=\"text-xs text-warning\">{labels.failures(device.failure_count)}</div>}\n </div>\n <Button\n ref={removeRef}\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n disabled={blocked}\n aria-label={labels.removeItem(name)}\n onClick={() => {\n setReturning(false);\n onAsk();\n }}\n >\n {labels.remove}\n </Button>\n </li>\n );\n}\n"],"mappings":";AAsJW,cA8BL,YA9BK;AAtJX,SAAS,WAAW,QAAQ,gBAAgB;AAE5C,SAAS,yBAAyB;AAElC,SAAS,cAAc,oBAAwC;AAC/D,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,aAAa,8BAA8B;AAGrE,SAAS,qCAAqC;AAQvC,SAAS,kBAAkB,IAAkC;AAClE,MAAI,CAAC,GAAI,QAAO;AAChB,QAAM,UAAU,qBAAqB,KAAK,EAAE,IACxC,SACA,eAAe,KAAK,EAAE,IACpB,UACA,iBAAiB,KAAK,EAAE,IACtB,YACA,gBAAgB,KAAK,EAAE,IACrB,WACA,UAAU,KAAK,EAAE,IACf,WACA;AACZ,QAAM,KAAK,WAAW,KAAK,EAAE,IACzB,YACA,WAAW,KAAK,EAAE,IAChB,YACA,oBAAoB,KAAK,EAAE,IACzB,QACA,sBAAsB,KAAK,EAAE,IAC3B,UACA,SAAS,KAAK,EAAE,IACd,UACA;AACZ,MAAI,CAAC,WAAW,CAAC,GAAI,QAAO,GAAG,SAAS,KAAK,GAAG,GAAG,MAAM,GAAG,EAAE,CAAC,WAAM;AACrE,SAAO,CAAC,SAAS,EAAE,EAAE,OAAO,OAAO,EAAE,K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