snice 2.1.4 → 2.2.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/dist/components/accordion/snice-accordion-item.d.ts +25 -0
- package/dist/components/accordion/snice-accordion-item.js +255 -0
- package/dist/components/accordion/snice-accordion-item.js.map +1 -0
- package/dist/components/accordion/snice-accordion.d.ts +28 -0
- package/dist/components/accordion/snice-accordion.js +206 -0
- package/dist/components/accordion/snice-accordion.js.map +1 -0
- package/dist/components/accordion/snice-accordion.types.d.ts +29 -0
- package/dist/components/alert/snice-alert.d.ts +26 -0
- package/dist/components/alert/snice-alert.js +180 -0
- package/dist/components/alert/snice-alert.js.map +1 -0
- package/{components/alert/snice-alert.types.ts → dist/components/alert/snice-alert.types.d.ts} +8 -9
- package/dist/components/avatar/snice-avatar.d.ts +24 -0
- package/dist/components/avatar/snice-avatar.js +180 -0
- package/dist/components/avatar/snice-avatar.js.map +1 -0
- package/dist/components/avatar/snice-avatar.types.d.ts +12 -0
- package/dist/components/badge/snice-badge.d.ts +25 -0
- package/dist/components/badge/snice-badge.js +169 -0
- package/dist/components/badge/snice-badge.js.map +1 -0
- package/{components/badge/snice-badge.types.ts → dist/components/badge/snice-badge.types.d.ts} +11 -12
- package/dist/components/breadcrumbs/snice-breadcrumbs.d.ts +27 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +214 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.types.d.ts +23 -0
- package/dist/components/breadcrumbs/snice-crumb.d.ts +9 -0
- package/dist/components/breadcrumbs/snice-crumb.js +63 -0
- package/dist/components/breadcrumbs/snice-crumb.js.map +1 -0
- package/dist/components/button/snice-button.d.ts +32 -0
- package/dist/components/button/snice-button.js +232 -0
- package/dist/components/button/snice-button.js.map +1 -0
- package/dist/components/button/snice-button.types.d.ts +23 -0
- package/dist/components/card/snice-card.d.ts +19 -0
- package/dist/components/card/snice-card.js +136 -0
- package/dist/components/card/snice-card.js.map +1 -0
- package/{components/card/snice-card.types.ts → dist/components/card/snice-card.types.d.ts} +6 -7
- package/dist/components/checkbox/snice-checkbox.d.ts +34 -0
- package/dist/components/checkbox/snice-checkbox.js +286 -0
- package/dist/components/checkbox/snice-checkbox.js.map +1 -0
- package/dist/components/checkbox/snice-checkbox.types.d.ts +20 -0
- package/dist/components/chip/snice-chip.d.ts +28 -0
- package/dist/components/chip/snice-chip.js +199 -0
- package/dist/components/chip/snice-chip.js.map +1 -0
- package/dist/components/chip/snice-chip.types.d.ts +14 -0
- package/dist/components/date-picker/snice-date-picker.d.ts +82 -0
- package/dist/components/date-picker/snice-date-picker.js +847 -0
- package/dist/components/date-picker/snice-date-picker.js.map +1 -0
- package/dist/components/date-picker/snice-date-picker.types.d.ts +71 -0
- package/dist/components/divider/snice-divider.d.ts +17 -0
- package/dist/components/divider/snice-divider.js +122 -0
- package/dist/components/divider/snice-divider.js.map +1 -0
- package/{components/divider/snice-divider.types.ts → dist/components/divider/snice-divider.types.d.ts} +9 -10
- package/dist/components/drawer/snice-drawer.d.ts +37 -0
- package/dist/components/drawer/snice-drawer.js +337 -0
- package/dist/components/drawer/snice-drawer.js.map +1 -0
- package/dist/components/drawer/snice-drawer.types.d.ts +16 -0
- package/dist/components/input/snice-input.d.ts +65 -0
- package/dist/components/input/snice-input.js +567 -0
- package/dist/components/input/snice-input.js.map +1 -0
- package/dist/components/input/snice-input.types.d.ts +53 -0
- package/dist/components/layout/snice-layout-blog.d.ts +4 -0
- package/dist/components/layout/snice-layout-blog.js +67 -0
- package/dist/components/layout/snice-layout-blog.js.map +1 -0
- package/dist/components/layout/snice-layout-card.d.ts +6 -0
- package/dist/components/layout/snice-layout-card.js +64 -0
- package/dist/components/layout/snice-layout-card.js.map +1 -0
- package/dist/components/layout/snice-layout-centered.d.ts +5 -0
- package/dist/components/layout/snice-layout-centered.js +48 -0
- package/dist/components/layout/snice-layout-centered.js.map +1 -0
- package/dist/components/layout/snice-layout-dashboard.d.ts +4 -0
- package/dist/components/layout/snice-layout-dashboard.js +64 -0
- package/dist/components/layout/snice-layout-dashboard.js.map +1 -0
- package/dist/components/layout/snice-layout-fullscreen.d.ts +5 -0
- package/dist/components/layout/snice-layout-fullscreen.js +60 -0
- package/dist/components/layout/snice-layout-fullscreen.js.map +1 -0
- package/dist/components/layout/snice-layout-landing.d.ts +4 -0
- package/dist/components/layout/snice-layout-landing.js +66 -0
- package/dist/components/layout/snice-layout-landing.js.map +1 -0
- package/dist/components/layout/snice-layout-minimal.d.ts +4 -0
- package/dist/components/layout/snice-layout-minimal.js +38 -0
- package/dist/components/layout/snice-layout-minimal.js.map +1 -0
- package/dist/components/layout/snice-layout-sidebar.d.ts +5 -0
- package/dist/components/layout/snice-layout-sidebar.js +74 -0
- package/dist/components/layout/snice-layout-sidebar.js.map +1 -0
- package/dist/components/layout/snice-layout-split.d.ts +6 -0
- package/dist/components/layout/snice-layout-split.js +58 -0
- package/dist/components/layout/snice-layout-split.js.map +1 -0
- package/dist/components/layout/snice-layout.d.ts +4 -0
- package/dist/components/layout/snice-layout.js +54 -0
- package/dist/components/layout/snice-layout.js.map +1 -0
- package/{components/layout/snice-layout.types.ts → dist/components/layout/snice-layout.types.d.ts} +1 -3
- package/dist/components/login/snice-login.d.ts +44 -0
- package/dist/components/login/snice-login.js +382 -0
- package/dist/components/login/snice-login.js.map +1 -0
- package/dist/components/login/snice-login.types.d.ts +26 -0
- package/dist/components/modal/snice-modal.d.ts +32 -0
- package/dist/components/modal/snice-modal.js +280 -0
- package/dist/components/modal/snice-modal.js.map +1 -0
- package/dist/components/modal/snice-modal.types.d.ts +18 -0
- package/dist/components/pagination/snice-pagination.d.ts +26 -0
- package/dist/components/pagination/snice-pagination.js +373 -0
- package/dist/components/pagination/snice-pagination.js.map +1 -0
- package/dist/components/pagination/snice-pagination.types.d.ts +18 -0
- package/dist/components/progress/snice-progress.d.ts +35 -0
- package/dist/components/progress/snice-progress.js +305 -0
- package/dist/components/progress/snice-progress.js.map +1 -0
- package/dist/components/progress/snice-progress.types.d.ts +18 -0
- package/dist/components/radio/snice-radio.d.ts +33 -0
- package/dist/components/radio/snice-radio.js +279 -0
- package/dist/components/radio/snice-radio.js.map +1 -0
- package/dist/components/radio/snice-radio.types.d.ts +19 -0
- package/dist/components/select/snice-option.d.ts +17 -0
- package/dist/components/select/snice-option.js +88 -0
- package/dist/components/select/snice-option.js.map +1 -0
- package/{components/select/snice-option.types.ts → dist/components/select/snice-option.types.d.ts} +8 -8
- package/dist/components/select/snice-select.d.ts +89 -0
- package/dist/components/select/snice-select.js +864 -0
- package/dist/components/select/snice-select.js.map +1 -0
- package/dist/components/select/snice-select.types.d.ts +49 -0
- package/dist/components/skeleton/snice-skeleton.d.ts +16 -0
- package/dist/components/skeleton/snice-skeleton.js +166 -0
- package/dist/components/skeleton/snice-skeleton.js.map +1 -0
- package/{components/skeleton/snice-skeleton.types.ts → dist/components/skeleton/snice-skeleton.types.d.ts} +7 -8
- package/dist/components/snice-cell-C8aBfN72.js +4 -0
- package/dist/components/snice-cell-C8aBfN72.js.map +1 -0
- package/dist/components/switch/snice-switch.d.ts +38 -0
- package/dist/components/switch/snice-switch.js +305 -0
- package/dist/components/switch/snice-switch.js.map +1 -0
- package/dist/components/switch/snice-switch.types.d.ts +21 -0
- package/dist/components/symbols.d.ts +1 -0
- package/dist/components/symbols.js +22 -0
- package/dist/components/symbols.js.map +1 -0
- package/dist/components/table/snice-cell-boolean.d.ts +21 -0
- package/dist/components/table/snice-cell-boolean.js +164 -0
- package/dist/components/table/snice-cell-boolean.js.map +1 -0
- package/dist/components/table/snice-cell-date.d.ts +24 -0
- package/dist/components/table/snice-cell-date.js +253 -0
- package/dist/components/table/snice-cell-date.js.map +1 -0
- package/dist/components/table/snice-cell-duration.d.ts +16 -0
- package/dist/components/table/snice-cell-duration.js +130 -0
- package/dist/components/table/snice-cell-duration.js.map +1 -0
- package/dist/components/table/snice-cell-filesize.d.ts +16 -0
- package/dist/components/table/snice-cell-filesize.js +126 -0
- package/dist/components/table/snice-cell-filesize.js.map +1 -0
- package/dist/components/table/snice-cell-number.d.ts +23 -0
- package/dist/components/table/snice-cell-number.js +215 -0
- package/dist/components/table/snice-cell-number.js.map +1 -0
- package/dist/components/table/snice-cell-progress.d.ts +17 -0
- package/dist/components/table/snice-cell-progress.js +121 -0
- package/dist/components/table/snice-cell-progress.js.map +1 -0
- package/dist/components/table/snice-cell-rating.d.ts +17 -0
- package/dist/components/table/snice-cell-rating.js +120 -0
- package/dist/components/table/snice-cell-rating.js.map +1 -0
- package/dist/components/table/snice-cell-sparkline.d.ts +29 -0
- package/dist/components/table/snice-cell-sparkline.js +306 -0
- package/dist/components/table/snice-cell-sparkline.js.map +1 -0
- package/dist/components/table/snice-cell-text.d.ts +19 -0
- package/dist/components/table/snice-cell-text.js +161 -0
- package/dist/components/table/snice-cell-text.js.map +1 -0
- package/dist/components/table/snice-cell.d.ts +32 -0
- package/dist/components/table/snice-cell.js +458 -0
- package/dist/components/table/snice-cell.js.map +1 -0
- package/dist/components/table/snice-column.d.ts +62 -0
- package/dist/components/table/snice-column.js +506 -0
- package/dist/components/table/snice-column.js.map +1 -0
- package/dist/components/table/snice-header.d.ts +33 -0
- package/dist/components/table/snice-header.js +289 -0
- package/dist/components/table/snice-header.js.map +1 -0
- package/dist/components/table/snice-progress.d.ts +10 -0
- package/dist/components/table/snice-progress.js +105 -0
- package/dist/components/table/snice-progress.js.map +1 -0
- package/dist/components/table/snice-rating.d.ts +9 -0
- package/dist/components/table/snice-rating.js +81 -0
- package/dist/components/table/snice-rating.js.map +1 -0
- package/dist/components/table/snice-row.d.ts +43 -0
- package/dist/components/table/snice-row.js +353 -0
- package/dist/components/table/snice-row.js.map +1 -0
- package/dist/components/table/snice-table.d.ts +69 -0
- package/dist/components/table/snice-table.js +792 -0
- package/dist/components/table/snice-table.js.map +1 -0
- package/dist/components/table/snice-table.types.d.ts +137 -0
- package/dist/components/tabs/snice-tab-panel.d.ts +12 -0
- package/dist/components/tabs/snice-tab-panel.js +87 -0
- package/dist/components/tabs/snice-tab-panel.js.map +1 -0
- package/dist/components/tabs/snice-tab.d.ts +13 -0
- package/dist/components/tabs/snice-tab.js +98 -0
- package/dist/components/tabs/snice-tab.js.map +1 -0
- package/dist/components/tabs/snice-tabs.d.ts +34 -0
- package/dist/components/tabs/snice-tabs.js +375 -0
- package/dist/components/tabs/snice-tabs.js.map +1 -0
- package/dist/components/tabs/snice-tabs.types.d.ts +23 -0
- package/dist/components/toast/snice-toast-container.d.ts +25 -0
- package/dist/components/toast/snice-toast-container.js +252 -0
- package/dist/components/toast/snice-toast-container.js.map +1 -0
- package/dist/components/toast/snice-toast.d.ts +23 -0
- package/dist/components/toast/snice-toast.js +321 -0
- package/dist/components/toast/snice-toast.js.map +1 -0
- package/dist/components/toast/snice-toast.types.d.ts +30 -0
- package/dist/components/tooltip/snice-tooltip.d.ts +50 -0
- package/dist/components/tooltip/snice-tooltip.js +644 -0
- package/dist/components/tooltip/snice-tooltip.js.map +1 -0
- package/dist/components/tooltip/snice-tooltip.types.d.ts +18 -0
- package/dist/components/transitions.d.ts +11 -0
- package/dist/components/transitions.js +72 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/index.cjs +16 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.cjs.min.map +1 -1
- package/dist/index.esm.js +16 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +3 -3
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +16 -20
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +3 -3
- package/dist/index.iife.min.js.map +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.esm.js +1 -1
- package/package.json +10 -6
- package/components/accordion/demo.html +0 -403
- package/components/accordion/snice-accordion-item.css +0 -85
- package/components/accordion/snice-accordion-item.ts +0 -226
- package/components/accordion/snice-accordion.css +0 -31
- package/components/accordion/snice-accordion.ts +0 -182
- package/components/accordion/snice-accordion.types.ts +0 -32
- package/components/alert/demo.html +0 -445
- package/components/alert/snice-alert.css +0 -195
- package/components/alert/snice-alert.ts +0 -141
- package/components/avatar/demo.html +0 -598
- package/components/avatar/snice-avatar.css +0 -131
- package/components/avatar/snice-avatar.ts +0 -136
- package/components/avatar/snice-avatar.types.ts +0 -13
- package/components/badge/demo.html +0 -523
- package/components/badge/snice-badge.css +0 -161
- package/components/badge/snice-badge.ts +0 -117
- package/components/breadcrumbs/demo.html +0 -404
- package/components/breadcrumbs/snice-breadcrumbs.css +0 -133
- package/components/breadcrumbs/snice-breadcrumbs.ts +0 -191
- package/components/breadcrumbs/snice-breadcrumbs.types.ts +0 -26
- package/components/breadcrumbs/snice-crumb.ts +0 -26
- package/components/button/demo.html +0 -42
- package/components/button/snice-button.css +0 -230
- package/components/button/snice-button.ts +0 -169
- package/components/button/snice-button.types.ts +0 -25
- package/components/card/demo.html +0 -525
- package/components/card/snice-card.css +0 -140
- package/components/card/snice-card.ts +0 -102
- package/components/checkbox/demo.html +0 -253
- package/components/checkbox/snice-checkbox.css +0 -164
- package/components/checkbox/snice-checkbox.ts +0 -223
- package/components/checkbox/snice-checkbox.types.ts +0 -22
- package/components/chip/demo.html +0 -383
- package/components/chip/snice-chip.css +0 -195
- package/components/chip/snice-chip.ts +0 -139
- package/components/chip/snice-chip.types.ts +0 -15
- package/components/date-picker/README.md +0 -233
- package/components/date-picker/demo.html +0 -191
- package/components/date-picker/snice-date-picker.css +0 -330
- package/components/date-picker/snice-date-picker.ts +0 -777
- package/components/date-picker/snice-date-picker.types.ts +0 -83
- package/components/divider/demo.html +0 -233
- package/components/divider/snice-divider.css +0 -155
- package/components/divider/snice-divider.ts +0 -69
- package/components/drawer/demo.html +0 -328
- package/components/drawer/snice-drawer.css +0 -476
- package/components/drawer/snice-drawer.ts +0 -287
- package/components/drawer/snice-drawer.types.ts +0 -17
- package/components/global.d.ts +0 -14
- package/components/input/demo.html +0 -303
- package/components/input/snice-input.css +0 -257
- package/components/input/snice-input.ts +0 -442
- package/components/input/snice-input.types.ts +0 -59
- package/components/input/test.html +0 -77
- package/components/layout/README.md +0 -260
- package/components/layout/demo.html +0 -538
- package/components/layout/snice-layout-blog.css +0 -129
- package/components/layout/snice-layout-blog.ts +0 -48
- package/components/layout/snice-layout-card.css +0 -104
- package/components/layout/snice-layout-card.ts +0 -35
- package/components/layout/snice-layout-centered.css +0 -51
- package/components/layout/snice-layout-centered.ts +0 -22
- package/components/layout/snice-layout-dashboard.css +0 -98
- package/components/layout/snice-layout-dashboard.ts +0 -45
- package/components/layout/snice-layout-fullscreen.css +0 -72
- package/components/layout/snice-layout-fullscreen.ts +0 -34
- package/components/layout/snice-layout-landing.css +0 -92
- package/components/layout/snice-layout-landing.ts +0 -47
- package/components/layout/snice-layout-minimal.css +0 -16
- package/components/layout/snice-layout-minimal.ts +0 -19
- package/components/layout/snice-layout-sidebar.css +0 -117
- package/components/layout/snice-layout-sidebar.ts +0 -48
- package/components/layout/snice-layout-split.css +0 -103
- package/components/layout/snice-layout-split.ts +0 -29
- package/components/layout/snice-layout.css +0 -72
- package/components/layout/snice-layout.ts +0 -35
- package/components/login/demo-auth-controller.ts +0 -185
- package/components/login/demo.html +0 -470
- package/components/login/snice-login.css +0 -204
- package/components/login/snice-login.ts +0 -326
- package/components/login/snice-login.types.ts +0 -29
- package/components/modal/demo.html +0 -291
- package/components/modal/snice-modal.css +0 -203
- package/components/modal/snice-modal.ts +0 -233
- package/components/modal/snice-modal.types.ts +0 -21
- package/components/pagination/demo.html +0 -395
- package/components/pagination/snice-pagination.ts +0 -333
- package/components/pagination/snice-pagination.types.ts +0 -21
- package/components/progress/demo.html +0 -510
- package/components/progress/snice-progress.css +0 -267
- package/components/progress/snice-progress.ts +0 -247
- package/components/progress/snice-progress.types.ts +0 -19
- package/components/radio/demo.html +0 -287
- package/components/radio/snice-radio.css +0 -171
- package/components/radio/snice-radio.ts +0 -218
- package/components/radio/snice-radio.types.ts +0 -21
- package/components/select/demo.html +0 -511
- package/components/select/snice-option.ts +0 -52
- package/components/select/snice-select.css +0 -392
- package/components/select/snice-select.ts +0 -796
- package/components/select/snice-select.types.ts +0 -55
- package/components/skeleton/demo.html +0 -514
- package/components/skeleton/snice-skeleton.css +0 -109
- package/components/skeleton/snice-skeleton.ts +0 -126
- package/components/switch/demo.html +0 -284
- package/components/switch/snice-switch.css +0 -221
- package/components/switch/snice-switch.ts +0 -229
- package/components/switch/snice-switch.types.ts +0 -23
- package/components/symbols.ts +0 -23
- package/components/table/demo-table-controller.ts +0 -100
- package/components/table/demo.html +0 -480
- package/components/table/snice-cell-boolean.ts +0 -112
- package/components/table/snice-cell-date.ts +0 -210
- package/components/table/snice-cell-duration.ts +0 -91
- package/components/table/snice-cell-filesize.ts +0 -90
- package/components/table/snice-cell-number.ts +0 -165
- package/components/table/snice-cell-progress.ts +0 -83
- package/components/table/snice-cell-rating.ts +0 -82
- package/components/table/snice-cell-sparkline.ts +0 -253
- package/components/table/snice-cell-text.ts +0 -125
- package/components/table/snice-cell.css +0 -296
- package/components/table/snice-cell.ts +0 -473
- package/components/table/snice-column.ts +0 -353
- package/components/table/snice-header.css +0 -243
- package/components/table/snice-header.ts +0 -261
- package/components/table/snice-progress.ts +0 -66
- package/components/table/snice-rating.ts +0 -45
- package/components/table/snice-row.css +0 -255
- package/components/table/snice-row.ts +0 -331
- package/components/table/snice-table.css +0 -241
- package/components/table/snice-table.ts +0 -737
- package/components/table/snice-table.types.ts +0 -158
- package/components/tabs/demo.html +0 -487
- package/components/tabs/snice-tab-panel.css +0 -264
- package/components/tabs/snice-tab-panel.ts +0 -47
- package/components/tabs/snice-tab.css +0 -96
- package/components/tabs/snice-tab.ts +0 -65
- package/components/tabs/snice-tabs.css +0 -189
- package/components/tabs/snice-tabs.ts +0 -332
- package/components/tabs/snice-tabs.types.ts +0 -28
- package/components/theme/theme.css +0 -234
- package/components/toast/demo.html +0 -329
- package/components/toast/snice-toast-container.ts +0 -256
- package/components/toast/snice-toast.css +0 -213
- package/components/toast/snice-toast.ts +0 -276
- package/components/toast/snice-toast.types.ts +0 -35
- package/components/tooltip/demo.html +0 -350
- package/components/tooltip/snice-tooltip-portal.css +0 -79
- package/components/tooltip/snice-tooltip.css +0 -117
- package/components/tooltip/snice-tooltip.ts +0 -612
- package/components/tooltip/snice-tooltip.types.ts +0 -32
- package/components/transitions.ts +0 -94
- package/components/tsconfig.json +0 -18
package/dist/index.esm.min.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* snice v2.1.
|
|
2
|
+
* snice v2.1.5
|
|
3
3
|
* Imperative TypeScript framework for building vanilla web components with decorators, routing, and controllers. No virtual DOM, no build complexity.
|
|
4
4
|
* (c) 2024
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
7
|
-
const t=(globalThis.snice||(globalThis.snice={controllerRegistry:new Map,controllerIdCounter:0,symbols:new Map}),globalThis.snice);function e(e){return t.symbols.has(e)||t.symbols.set(e,Symbol(e)),t.symbols.get(e)}const n=e("is-controller-class"),o=e("is-controller-instance"),r=e("is-element-class"),s=e("channel-handlers"),i=e("ready-promise"),a=e("ready-resolve"),c=e("controller"),l=e("on-handlers"),u=e("controller-key"),h=e("controller-name"),d=e("controller-id"),p=e("controller-operations"),f=e("native-controller"),m=e("cleanup"),y=e("properties"),g=e("property-values"),b=e("properties-initialized"),w=e("property-watchers"),v=e("explicitly-set-properties"),E=e("router-context");e("current-page-marker");const S=e("context-request-handler"),T=e("page-transition"),A=e("created-at"),O=e("ready-handlers"),N=e("dispose-handlers"),P=e("observers"),L=e("parts"),I=e("part-timers"),C=e("dispatch-timers");function x(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;n.prototype[l]||(n.prototype[l]=[]);const i=Array.isArray(t)?t:[t];for(const t of i)n.prototype[l].push({eventName:t,selector:o,methodName:s,method:e,options:r})})}}function k(t,e){const n=t.constructor.prototype[l];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=t[o.method.name],r=n?n.bind(t):o.method.bind(t),s=o.options||{},[i,a]=o.eventName.split(":"),c=t=>!a||"keydown"!==i&&"keyup"!==i&&"keypress"!==i?t:e=>{const n=e,o=t=>"Space"===t?" ":t;if(a.startsWith("~")){const r=o(a.slice(1));return void(n.key===r&&t(e))}if(a.includes("+")){const r=a.split("+"),s=o(r[r.length-1]),i=r.slice(0,-1);if(n.key!==s)return;const c=new Set(i.map(t=>t.toLowerCase())),l=c.has("ctrl"),u=c.has("shift"),h=c.has("alt"),d=c.has("meta")||c.has("cmd");n.ctrlKey===l&&n.shiftKey===u&&n.altKey===h&&n.metaKey===d&&t(e)}else{const r=o(a);n.key!==r||n.ctrlKey||n.shiftKey||n.altKey||n.metaKey||t(e)}},l=(t=>{if(s.debounce){let e;return function(...n){clearTimeout(e),e=setTimeout(()=>t.apply(this,n),s.debounce)}}if(s.throttle){let e,n=0;return function(...o){const r=Date.now(),i=s.throttle-(r-n);i<=0?(clearTimeout(e),n=r,t.apply(this,o)):e||(e=setTimeout(()=>{n=Date.now(),e=null,t.apply(this,o)},i))}}return t})(r),u=c(t=>{try{return s.preventDefault&&t.preventDefault(),s.stopPropagation&&t.stopPropagation(),l(t)}catch(t){console.error(`Error in event handler ${o.methodName}:`,t)}});if(o.selector){const n=e.shadowRoot||e,r=t=>{const e=t.target;let n=!1;if(e.matches&&e.matches(o.selector))n=!0;else if(e.closest){e.closest(o.selector)&&(n=!0)}n&&(s.preventDefault&&t.preventDefault(),s.stopPropagation&&(t.stopPropagation(),t.stopImmediatePropagation()),u(t))},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};n.addEventListener(i,r,a),t[m].events.push(()=>{n.removeEventListener(i,r,a)})}else{const n={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};e.addEventListener(i,u,n),t[m].events.push(()=>{e.removeEventListener(i,u,n)})}}}}function R(t){if(t[m]?.events){for(const e of t[m].events)e();t[m].events=[]}}function $(t,e){return function(n,o){return function(...r){this[C]||(this[C]=new Map);const s=`${t}_${o.name}`;this[C].has(s)||this[C].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[C].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===e?.dispatchOnUndefined)return;const o=new CustomEvent(t,{bubbles:!0,composed:!0,...e,detail:n});this.dispatchEvent(o)},l=t=>{if(e?.debounce)clearTimeout(i.debounceTimeout),i.debounceTimeout=setTimeout(()=>c(t),e.debounce);else if(e?.throttle){const n=Date.now(),o=e.throttle-(n-i.throttleLastCall);o<=0?(clearTimeout(i.throttleTimeout),i.throttleLastCall=n,c(t)):i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null,c(t)},o))}else c(t)};return a instanceof Promise?a.then(t=>(l(t),t)):(l(a),a)}}}const q=new Map,D=new WeakMap;function M(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;n.prototype[P]||(n.prototype[P]=[]);const i=Array.isArray(t)?t:[t];for(const t of i){const[i,...a]=t.split(":");n.prototype[P].push({type:i,target:a.join(":"),selector:o,methodName:s,method:e,options:r})}})}}function j(t,e){const n=t.constructor.prototype[P];if(n&&Array.isArray(n)&&0!==n.length){t[m]?t[m].observers||(t[m].observers=[]):t[m]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(t),r=o.options?.throttle?B(n,o.options.throttle):n;switch(o.type){case"intersection":z(t,e,o,r);break;case"resize":F(t,e,o,r);break;case"media":U(t,e,o,r);break;case"mutation":H(t,e,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function z(t,e,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null},s=JSON.stringify(r),i=t=>{for(const e of t)try{!1===o(e)&&a&&a.unobserve(e.target)}catch(t){console.error(`Error in intersection observer ${n.methodName}:`,t)}};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");let a=D.get({instance:t,options:s});a||(a=new IntersectionObserver(i,r),D.set({instance:t,options:s},a));const c=n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e];c.forEach(t=>a.observe(t)),t[m].observers.push(()=>{c.forEach(t=>a.unobserve(t)),0===a.takeRecords().length&&a.disconnect()})}function F(t,e,n,o){const r=n.options?.box||"content-box";if("undefined"==typeof ResizeObserver)return void console.warn("ResizeObserver is not available in this environment");const s=new ResizeObserver(t=>{for(const e of t)try{o(e)}catch(t){console.error(`Error in resize observer ${n.methodName}:`,t)}});(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e]).forEach(t=>{s.observe(t,{box:r})}),t[m].observers.push(()=>{s.disconnect()})}function U(t,e,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=q.get(r);if(!s)try{s=window.matchMedia(r),q.set(r,s)}catch(t){return void console.error(`Invalid media query: ${r}`,t)}const i=t=>{try{o(t.matches)}catch(t){console.error(`Error in media query observer ${n.methodName}:`,t)}};i(s);const a=t=>i(t);s.addEventListener?(s.addEventListener("change",a),t[m].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),t[m].observers.push(()=>{s.removeListener(a)}))}function H(t,e,n,r){const s=n.target.split(":"),i=s[0]||"childList",a=s[1],c={};switch(i){case"childList":c.childList=!0;break;case"attributes":c.attributes=!0,a&&(c.attributeFilter=[a]);break;default:return void console.warn(`Unknown mutation type: ${i}`)}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=new MutationObserver(t=>{try{if(n.options?.maxDepth&&n.options.subtree){const o=n.options.maxDepth,s=t.filter(t=>{let n=0,r=t.target;const s=e.shadowRoot||e;for(;r&&r!==s&&n<o;)r=r.parentNode,n++;return n<o});s.length>0&&r(s)}else r(t)}catch(t){console.error(`Error in mutation observer ${n.methodName}:`,t)}}),u=!0===t[o];(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):u&&e.shadowRoot?[e.shadowRoot]:[e]).forEach(t=>{l.observe(t,c)}),t[m].observers.push(()=>{l.disconnect()})}function B(t,e){let n=0,o=null;return function(...r){const s=Date.now(),i=e-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,t.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,t.apply(this,r)},i))}}function G(t){if(t[m]?.observers){for(const e of t[m].observers)e();t[m].observers=[]}}function K(t,e){return function(n,r){let s,i,a=0;return async function(...r){const c=async()=>{const s=e?.timeout??12e4,i=e?.discoveryTimeout??50,a=n.apply(this,r),{value:c,done:l}=await a.next();if(l)return c;let u,h;const d=new Promise((t,e)=>{u=t,h=e});let p,f,m;const y=new Promise((e,n)=>{p=e,f=n,m=setTimeout(()=>{n(new Error(`Request "${t}" timed out after ${i}ms - no handler found`))},i)}),g=new CustomEvent(`@request/${t}`,{bubbles:void 0===e?.bubbles||e.bubbles,cancelable:e?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{clearTimeout(m),p()},reject:f},data:{resolve:u,reject:h}}});(!0===this[o]&&this.element?this.element:this).dispatchEvent(g);try{await y;const e=setTimeout(()=>{h(new Error(`Request "${t}" timed out after ${s}ms`))},s),n=await d;clearTimeout(e);const{value:o}=await a.next(n);return o}catch(t){try{await a.throw(t)}catch(t){throw t}}};if(e?.debounce)return new Promise((t,n)=>{clearTimeout(s),s=setTimeout(async()=>{try{const e=await c();t(e)}catch(t){n(t)}},e.debounce)});if(e?.throttle){const t=Date.now(),n=e.throttle-(t-a);return n<=0?(clearTimeout(i),a=t,c()):i?Promise.resolve():new Promise((t,e)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const e=await c();t(e)}catch(t){e(t)}},n)})}return c()}}}function W(t,e){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;o.prototype[s]||(o.prototype[s]=[]),o.prototype[s].push({channelName:t,methodName:r,method:n,options:e})})}}function Q(t,e){const n=t.constructor.prototype[s];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=o.method.bind(t),r=`@request/${o.channelName}`;let s,i,a=0;const c=(t=>o.options?.debounce?(...e)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{const o=await t(...e);n(o)}catch(t){r(t)}},o.options.debounce)}):o.options?.throttle?(...e)=>{const n=Date.now(),r=o.options.throttle-(n-a);return r<=0?(clearTimeout(i),a=n,t(...e)):i?Promise.resolve(void 0):new Promise((n,o)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const o=await t(...e);n(o)}catch(t){o(t)}},r)})}:t)(n),l=t=>{const{data:e,discovery:n,payload:r}=t.detail;t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),n.resolve(),Promise.resolve(c(r)).then(t=>{e.resolve(t)}).catch(t=>{e.reject(t),console.error(`Error in response handler ${o.methodName}:`,t)})};e.addEventListener(r,l),t[m].channels.push(()=>{e.removeEventListener(r,l)})}}}function _(t){if(t[m]?.channels){for(const e of t[m].channels)e();t[m].channels=[]}}class J{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(t,e){this.cleanupFns.set(t,e)}unregister(t){this.cleanupFns.delete(t)}async cleanup(){await Promise.all(this.pendingOperations);for(const t of this.cleanupFns.values())try{await t()}catch(t){console.error("Error during cleanup:",t)}this.cleanupFns.clear()}async runOperation(t){const e=t(),n=e.then(()=>{},()=>{});this.pendingOperations.add(n);try{const t=await e;return this.pendingOperations.delete(n),t}catch(t){throw this.pendingOperations.delete(n),t}}}function V(e){return function(o,r){return t.controllerRegistry.set(e,o),o.prototype[n]=!0,o}}async function X(e,n){const r=e[u],s=e[h],i=e[f];if(void 0!==i&&i!==n)return;if(s===n&&r)return;r&&await Y(e);const a=t.controllerRegistry.get(n);if(!a)throw new Error(`Controller "${n}" not found in registry`);const c=new a;t.controllerIdCounter+=1;const l=t.controllerIdCounter,m=new J;c[o]=!0,c[d]=l,c.element=e;const y=e[E];void 0!==y&&(c[E]=y),e[u]=c,e[h]=n,e[p]=m,await e.ready,await m.runOperation(async()=>{await c.attach(e)}),k(c,e),j(c,e),Q(c,e),e.dispatchEvent(new CustomEvent("@snice/controller-attached",{detail:{name:n,controller:c}}))}async function Y(t){const e=t[u],n=t[h],o=t[p];e&&(o?await o.runOperation(async()=>{await e.detach(t)}):await e.detach(t),e.element=null,R(e),G(e),_(e),o&&await o.cleanup(),delete e[E],delete t[u],delete t[h],delete t[p],t.dispatchEvent(new CustomEvent("@snice/controller-detached",{detail:{name:n,controller:e}})))}function Z(t){return t[u]}function tt(){if(globalThis.sniceNativeControllersInitialized)return;function t(t){if(!(t instanceof HTMLElement))return;if(t.tagName.includes("-"))return;if(t[r])return;const e=t.getAttribute("controller"),n=t[f];e&&e!==n?(t[f]=e,t.ready||(t.ready=Promise.resolve()),n&&Y(t).catch(t=>{console.error("Failed to detach old controller from native element:",t)}),X(t,e).catch(t=>{console.error(`Failed to attach controller "${e}" to native element:`,t)})):!e&&n&&(delete t[f],delete t[h],Y(t).catch(t=>{console.error("Failed to detach controller from native element:",t)}))}globalThis.sniceNativeControllersInitialized=!0;const e=new MutationObserver(e=>{for(const n of e)"attributes"===n.type&&"controller"===n.attributeName?t(n.target):"childList"===n.type&&n.addedNodes.forEach(e=>{e instanceof HTMLElement&&(t(e),e.querySelectorAll('[controller]:not([class*="-"])').forEach(t))})});"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}):(document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})),globalThis.sniceNativeControllerObserver=e}function et(){const t=globalThis.sniceNativeControllerObserver;t&&(t.disconnect(),delete globalThis.sniceNativeControllerObserver,delete globalThis.sniceNativeControllersInitialized)}function nt(t){t.prototype[r]=!0;const e=t.prototype.connectedCallback,n=t.prototype.disconnectedCallback,o=t.prototype.attributeChangedCallback,s=t.observedAttributes||[];s.includes("controller")||s.push("controller");const l=t[y];if(l)for(const[t,e]of l){const n="string"==typeof e.attribute?e.attribute:t.toLowerCase();s.includes(n)||s.push(n)}Object.defineProperty(t,"observedAttributes",{get:()=>s,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get(){return this[i]||(this[i]=new Promise(t=>{this[a]=t})),this[i]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controller",{get(){return this[c]},set(t){const e=this[c];this[c]=t,t!==e&&t?X(this,t).catch(e=>{console.error(`Failed to attach controller "${t}":`,e)}):!t&&e&&Y(this).catch(t=>{console.error("Failed to detach controller:",t)})},enumerable:!0,configurable:!0}),t.prototype.connectedCallback=async function(){this[i]||(this[i]=new Promise(t=>{this[a]=t}));try{const n=t[y];if(n)for(const[t,e]of n)if(this.hasAttribute(t)){const n=this.getAttribute(t);switch(this[v]||(this[v]=new Set),this[v].add(t),e.type){case Boolean:this[t]=null!==n&&"false"!==n;break;case Number:this[t]=Number(n);break;case String:this[t]=n;break;case Date:this[t]=n?new Date(n):null;break;case BigInt:n&&n.endsWith("n")?this[t]=BigInt(n.slice(0,-1)):this[t]=n?BigInt(n):null;break;case ct:this[t]=ct.parse(n);break;default:this[t]=n}}if(this[b]=!0,n)for(const[t,e]of n){const n=this[v]&&this[v].has(t),o=t in this[g];if(e.reflect&&o&&(n||void 0!==this[g][t])){const n=this[g][t],o="string"==typeof e.attribute?e.attribute:t.toLowerCase();if(null!=n&&!1!==n&&(e.type!==ct||!Array.isArray(n)||0!==n.length)){let t;t=n instanceof Date?n.toISOString():"bigint"==typeof n?n.toString()+"n":e.type===ct&&Array.isArray(n)?ct.serialize(n):String(n),this.setAttribute(o,t)}}}R(this),this.shadowRoot||this.attachShadow({mode:"open"});let o="";if(this.html)try{const t=this.html(),e=t instanceof Promise?await t:t;void 0!==e&&(o+=e)}catch(t){console.error(`Error in html() method for ${this.tagName}:`,t)}if(this.css)try{const t=this.css(),e=t instanceof Promise?await t:t;if(e){o+=`<style data-component-css>${Array.isArray(e)?e.join("\n"):e}</style>`}}catch(t){console.error(`Error in css() method for ${this.tagName}:`,t)}o&&(this.shadowRoot.innerHTML=o);const r=t[L];if(r&&this.shadowRoot)for(const[t,e]of r)try{const n=this.shadowRoot.querySelector(`[part="${t}"]`);if(n){const t=e.method.call(this),o=t instanceof Promise?await t:t;void 0!==o&&(n.innerHTML=o)}}catch(e){console.error(`Error rendering @part('${t}') in ${this.tagName}:`,e)}e&&e.call(this);const s=this.getAttribute("controller");s&&(this.controller=s),k(this,this),Q(this,this);try{j(this,this)}catch(t){console.error(`Error setting up observers for ${this.tagName}:`,t)}const i=t[O];if(i)for(const t of i)try{await t.method.call(this)}catch(e){console.error(`Error in @ready handler ${t.methodName}:`,e)}}finally{this[a]&&(this[a](),this[a]=null)}},t.prototype.disconnectedCallback=async function(){const e=t[N];if(e)for(const t of e)try{await t.method.call(this)}catch(e){console.error(`Error in @dispose handler ${t.methodName}:`,e)}n&&n.call(this),this[c]&&Y(this).catch(t=>{console.error("Failed to detach controller:",t)}),R(this),_(this),G(this)},t.prototype.attributeChangedCallback=function(e,n,r){if(o?.call(this,e,n,r),"controller"===e)this.controller=r;else{const n=t[y];if(n)for(const[o,s]of n){if(("string"==typeof s.attribute?s.attribute:o.toLowerCase())===e){const e=this[g]?.[o];let n;if(n=s.type===Boolean?null!==r&&"false"!==r:s.type===Number?Number(r):s.type===Date?r?new Date(r):null:s.type===BigInt?r&&r.endsWith("n")?BigInt(r.slice(0,-1)):r?BigInt(r):null:s.type===ct?ct.parse(r):"number"==typeof e&&null!==r?Number(r):r,e!==n){this[v]||(this[v]=new Set),this[v].add(o),this[g]||(this[g]={}),this[g][o]=n;const r=t[w];if(r){if(r.has(o)){const t=r.get(o);for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(r.has("*")){const t=r.get("*");for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}}break}}}}}function ot(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}return nt(e),customElements.define(t,e),e}}function rt(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}return nt(e),customElements.define(t,e),e}}function st(t){return function(e,n){const o=n.name;return n.metadata||(n.metadata={}),n.metadata[y]||(n.metadata[y]=new Map),n.metadata[y].set(o,t||{}),t?.reflect&&t?.type===Array&&console.warn(`⚠️ Property '${o}' uses reflect:true with Array type.`),t?.reflect&&t?.type===Object&&console.warn(`⚠️ Property '${o}' uses reflect:true with Object type.`),n.addInitializer(function(){}),function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,o)){const e={get(){return this[g]||(this[g]={}),this[g][o]},set(e){this[g]||(this[g]={}),this[v]||(this[v]=new Set);const n=this[g][o];if(n===e)return;const r=void 0===n&&!this[b];if((void 0!==n||r&&null!=e)&&this[v].add(o),this[g][o]=e,t?.reflect&&this.setAttribute&&this[b]&&this[v].has(o)){const n="string"==typeof t.attribute?t.attribute:o.toLowerCase();if(null==e||!1===e||t?.type===ct&&Array.isArray(e)&&0===e.length)this.removeAttribute(n);else{let o;o=e instanceof Date?e.toISOString():"bigint"==typeof e?e.toString()+"n":t?.type===ct&&Array.isArray(e)?ct.serialize(e):String(e),this.setAttribute(n,o)}}const s=this.constructor[w];if(s){if(s.has(o)){const t=s.get(o);for(const r of t)try{r.method.call(this,n,e,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(s.has("*")){const t=s.get("*");for(const r of t)try{r.method.call(this,n,e,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}this.requestUpdate&&this.requestUpdate(o,n)},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,o,e)}return this[g]||(this[g]={}),this[g][o]=e,e}}}function it(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e,a=r.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[o]&&this.element?this.element:this;let n=null;return i&&e.shadowRoot&&(n=e.shadowRoot.querySelector(t)),!n&&s&&(n=e.querySelector(t)),n||null},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,a,e)}return e}}}function at(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e,a=r.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[o]&&this.element?this.element:this,n=[];if(i&&e.shadowRoot){const o=e.shadowRoot.querySelectorAll(t);n.push(...o)}if(s){const o=e.querySelectorAll(t);n.push(...o)}return n},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,a,e)}return e}}}class ct{static{this.SEPARATOR=","}static serialize(t){return Array.isArray(t)?t.map(t=>{if("string"==typeof t){if(t.includes(ct.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${ct.SEPARATOR}" (U+FF0C)`);return t}if("number"==typeof t||"boolean"==typeof t)return String(t);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof t)}).join(ct.SEPARATOR):""}static parse(t){return null==t||""===t?[]:t.split(ct.SEPARATOR).map(t=>{if(/^-?\d+\.?\d*$/.test(t)){const e=Number(t);if(!isNaN(e))return e}return"true"===t||"false"!==t&&t})}}function lt(...t){return function(e,n){const o=n.name;n.addInitializer(function(){const n=this.constructor;n[w]||(n[w]=new Map);for(const r of t)n[w].has(r)||n[w].set(r,[]),n[w].get(r).push({methodName:o,method:e})})}}function ut(){return function(t,e){const n=e.name;return function(t){if(!Object.hasOwnProperty.call(this.constructor.prototype,n)){const t={get(){if(void 0!==this[E])return this[E];const t={target:this},e=new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t});let n=!0===this[o]&&this.element?this.element:this;if(n&&n.dispatchEvent){if(n.getRootNode&&n.getRootNode()instanceof ShadowRoot){const t=n.getRootNode();n=t.host}return n.dispatchEvent(e),void 0!==t.context?(this[E]=t.context,t.context):void 0}},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,n,t)}return t}}}function ht(){return function(t,e){const n=e.name;e.addInitializer(function(){const e=this.constructor;e[O]||(e[O]=[]),e[O].push({methodName:n,method:t})})}}function dt(){return function(t,e){const n=e.name;e.addInitializer(function(){const e=this.constructor;e[N]||(e[N]=[]),e[N].push({methodName:n,method:t})})}}function pt(t,e={}){return function(n,o){const r=o.name;return o.addInitializer(function(){const e=this.constructor;e[L]||(e[L]=new Map),e[L].set(t,{methodName:r,method:n})}),function(...o){this[I]||(this[I]=new Map),this[I].has(t)||this[I].set(t,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[I].get(t),s=(...e)=>{const o=n.apply(this,e),r=e=>{const n=void 0!==e,o=this.shadowRoot?.querySelector(`[part="${t}"]`);n&&o&&(o.innerHTML=e)};return o instanceof Promise?o.then(t=>(r(t),t)):(r(o),o)},i=void 0!==e.debounce&&e.debounce>0,a=void 0!==e.throttle&&e.throttle>0;switch(!0){case i:return clearTimeout(r.debounceTimer),void(r.debounceTimer=setTimeout(()=>s(...o),e.debounce));case a:{const t=e.throttle,n=Date.now();if(0===r.lastThrottleCall||n-r.lastThrottleCall>=t)return r.lastThrottleCall=n,s(...o);if(!!!r.throttleTimer){const e=t-(n-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),s(...o)},e)}return}default:return s(...o)}}}}
|
|
7
|
+
const t=(globalThis.snice||(globalThis.snice={controllerRegistry:new Map,controllerIdCounter:0,symbols:new Map}),globalThis.snice);function e(e){return t.symbols.has(e)||t.symbols.set(e,Symbol(e)),t.symbols.get(e)}const n=e("is-controller-class"),o=e("is-controller-instance"),r=e("is-element-class"),s=e("channel-handlers"),i=e("ready-promise"),a=e("ready-resolve"),c=e("controller"),l=e("on-handlers"),u=e("controller-key"),h=e("controller-name"),d=e("controller-id"),p=e("controller-operations"),f=e("native-controller"),m=e("cleanup"),y=e("properties"),g=e("property-values"),b=e("properties-initialized"),w=e("property-watchers"),v=e("explicitly-set-properties"),E=e("router-context");e("current-page-marker");const S=e("context-request-handler"),T=e("page-transition"),O=e("created-at"),A=e("ready-handlers"),N=e("dispose-handlers"),P=e("observers"),L=e("parts"),I=e("part-timers"),C=e("dispatch-timers");function x(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;n.prototype[l]||(n.prototype[l]=[]);const i=Array.isArray(t)?t:[t];for(const t of i)n.prototype[l].push({eventName:t,selector:o,methodName:s,method:e,options:r})})}}function k(t,e){const n=t.constructor.prototype[l];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=t[o.method.name],r=n?n.bind(t):o.method.bind(t),s=o.options||{},[i,a]=o.eventName.split(":"),c=t=>!a||"keydown"!==i&&"keyup"!==i&&"keypress"!==i?t:e=>{const n=e,o=t=>"Space"===t?" ":t;if(a.startsWith("~")){const r=o(a.slice(1));return void(n.key===r&&t(e))}if(a.includes("+")){const r=a.split("+"),s=o(r[r.length-1]),i=r.slice(0,-1);if(n.key!==s)return;const c=new Set(i.map(t=>t.toLowerCase())),l=c.has("ctrl"),u=c.has("shift"),h=c.has("alt"),d=c.has("meta")||c.has("cmd");n.ctrlKey===l&&n.shiftKey===u&&n.altKey===h&&n.metaKey===d&&t(e)}else{const r=o(a);n.key!==r||n.ctrlKey||n.shiftKey||n.altKey||n.metaKey||t(e)}},l=(t=>{if(s.debounce){let e;return function(...n){clearTimeout(e),e=setTimeout(()=>t.apply(this,n),s.debounce)}}if(s.throttle){let e,n=0;return function(...o){const r=Date.now(),i=s.throttle-(r-n);i<=0?(clearTimeout(e),n=r,t.apply(this,o)):e||(e=setTimeout(()=>{n=Date.now(),e=null,t.apply(this,o)},i))}}return t})(r),u=c(t=>{try{return s.preventDefault&&t.preventDefault(),s.stopPropagation&&t.stopPropagation(),l(t)}catch(t){console.error(`Error in event handler ${o.methodName}:`,t)}});if(o.selector){const n=e.shadowRoot||e,r=t=>{const e=t.target;let n=!1;if(e.matches&&e.matches(o.selector))n=!0;else if(e.closest){e.closest(o.selector)&&(n=!0)}n&&(s.preventDefault&&t.preventDefault(),s.stopPropagation&&(t.stopPropagation(),t.stopImmediatePropagation()),u(t))},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};n.addEventListener(i,r,a),t[m].events.push(()=>{n.removeEventListener(i,r,a)})}else{const n={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};e.addEventListener(i,u,n),t[m].events.push(()=>{e.removeEventListener(i,u,n)})}}}}function R(t){if(t[m]?.events){for(const e of t[m].events)e();t[m].events=[]}}function $(t,e){return function(n,o){return function(...r){this[C]||(this[C]=new Map);const s=`${t}_${o.name}`;this[C].has(s)||this[C].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[C].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===e?.dispatchOnUndefined)return;const o=new CustomEvent(t,{bubbles:!0,composed:!0,...e,detail:n});this.dispatchEvent(o)},l=t=>{if(e?.debounce)clearTimeout(i.debounceTimeout),i.debounceTimeout=setTimeout(()=>c(t),e.debounce);else if(e?.throttle){const n=Date.now(),o=e.throttle-(n-i.throttleLastCall);o<=0?(clearTimeout(i.throttleTimeout),i.throttleLastCall=n,c(t)):i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null,c(t)},o))}else c(t)};return a instanceof Promise?a.then(t=>(l(t),t)):(l(a),a)}}}const q=new Map,D=new WeakMap;function M(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;n.prototype[P]||(n.prototype[P]=[]);const i=Array.isArray(t)?t:[t];for(const t of i){const[i,...a]=t.split(":");n.prototype[P].push({type:i,target:a.join(":"),selector:o,methodName:s,method:e,options:r})}})}}function j(t,e){const n=t.constructor.prototype[P];if(n&&Array.isArray(n)&&0!==n.length){t[m]?t[m].observers||(t[m].observers=[]):t[m]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(t),r=o.options?.throttle?B(n,o.options.throttle):n;switch(o.type){case"intersection":z(t,e,o,r);break;case"resize":F(t,e,o,r);break;case"media":U(t,e,o,r);break;case"mutation":H(t,e,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function z(t,e,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null},s=JSON.stringify(r),i=t=>{for(const e of t)try{!1===o(e)&&a&&a.unobserve(e.target)}catch(t){console.error(`Error in intersection observer ${n.methodName}:`,t)}};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");let a=D.get({instance:t,options:s});a||(a=new IntersectionObserver(i,r),D.set({instance:t,options:s},a));const c=n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e];c.forEach(t=>a.observe(t)),t[m].observers.push(()=>{c.forEach(t=>a.unobserve(t)),0===a.takeRecords().length&&a.disconnect()})}function F(t,e,n,o){const r=n.options?.box||"content-box";if("undefined"==typeof ResizeObserver)return void console.warn("ResizeObserver is not available in this environment");const s=new ResizeObserver(t=>{for(const e of t)try{o(e)}catch(t){console.error(`Error in resize observer ${n.methodName}:`,t)}});(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e]).forEach(t=>{s.observe(t,{box:r})}),t[m].observers.push(()=>{s.disconnect()})}function U(t,e,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=q.get(r);if(!s)try{s=window.matchMedia(r),q.set(r,s)}catch(t){return void console.error(`Invalid media query: ${r}`,t)}const i=t=>{try{o(t.matches)}catch(t){console.error(`Error in media query observer ${n.methodName}:`,t)}};i(s);const a=t=>i(t);s.addEventListener?(s.addEventListener("change",a),t[m].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),t[m].observers.push(()=>{s.removeListener(a)}))}function H(t,e,n,r){const s=n.target.split(":"),i=s[0]||"childList",a=s[1],c={};switch(i){case"childList":c.childList=!0;break;case"attributes":c.attributes=!0,a&&(c.attributeFilter=[a]);break;default:return void console.warn(`Unknown mutation type: ${i}`)}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=new MutationObserver(t=>{try{if(n.options?.maxDepth&&n.options.subtree){const o=n.options.maxDepth,s=t.filter(t=>{let n=0,r=t.target;const s=e.shadowRoot||e;for(;r&&r!==s&&n<o;)r=r.parentNode,n++;return n<o});s.length>0&&r(s)}else r(t)}catch(t){console.error(`Error in mutation observer ${n.methodName}:`,t)}}),u=!0===t[o];(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):u&&e.shadowRoot?[e.shadowRoot]:[e]).forEach(t=>{l.observe(t,c)}),t[m].observers.push(()=>{l.disconnect()})}function B(t,e){let n=0,o=null;return function(...r){const s=Date.now(),i=e-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,t.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,t.apply(this,r)},i))}}function G(t){if(t[m]?.observers){for(const e of t[m].observers)e();t[m].observers=[]}}function K(t,e){return function(n,r){let s,i,a=0;return async function(...r){const c=async()=>{const s=e?.timeout??12e4,i=e?.discoveryTimeout??50,a=n.apply(this,r),{value:c,done:l}=await a.next();if(l)return c;let u,h;const d=new Promise((t,e)=>{u=t,h=e});let p,f,m;const y=new Promise((e,n)=>{p=e,f=n,m=setTimeout(()=>{n(new Error(`Request "${t}" timed out after ${i}ms - no handler found`))},i)}),g=new CustomEvent(`@request/${t}`,{bubbles:void 0===e?.bubbles||e.bubbles,cancelable:e?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{clearTimeout(m),p()},reject:f},data:{resolve:u,reject:h}}});(!0===this[o]&&this.element?this.element:this).dispatchEvent(g);try{await y;const e=setTimeout(()=>{h(new Error(`Request "${t}" timed out after ${s}ms`))},s),n=await d;clearTimeout(e);const{value:o}=await a.next(n);return o}catch(t){try{await a.throw(t)}catch(t){throw t}}};if(e?.debounce)return new Promise((t,n)=>{clearTimeout(s),s=setTimeout(async()=>{try{const e=await c();t(e)}catch(t){n(t)}},e.debounce)});if(e?.throttle){const t=Date.now(),n=e.throttle-(t-a);return n<=0?(clearTimeout(i),a=t,c()):i?Promise.resolve():new Promise((t,e)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const e=await c();t(e)}catch(t){e(t)}},n)})}return c()}}}function W(t,e){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;o.prototype[s]||(o.prototype[s]=[]),o.prototype[s].push({channelName:t,methodName:r,method:n,options:e})})}}function Q(t,e){const n=t.constructor.prototype[s];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=o.method.bind(t),r=`@request/${o.channelName}`;let s,i,a=0;const c=(t=>o.options?.debounce?(...e)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{const o=await t(...e);n(o)}catch(t){r(t)}},o.options.debounce)}):o.options?.throttle?(...e)=>{const n=Date.now(),r=o.options.throttle-(n-a);return r<=0?(clearTimeout(i),a=n,t(...e)):i?Promise.resolve(void 0):new Promise((n,o)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const o=await t(...e);n(o)}catch(t){o(t)}},r)})}:t)(n),l=t=>{const{data:e,discovery:n,payload:r}=t.detail;t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),n.resolve(),Promise.resolve(c(r)).then(t=>{e.resolve(t)}).catch(t=>{e.reject(t),console.error(`Error in response handler ${o.methodName}:`,t)})};e.addEventListener(r,l),t[m].channels.push(()=>{e.removeEventListener(r,l)})}}}function _(t){if(t[m]?.channels){for(const e of t[m].channels)e();t[m].channels=[]}}class J{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(t,e){this.cleanupFns.set(t,e)}unregister(t){this.cleanupFns.delete(t)}async cleanup(){await Promise.all(this.pendingOperations);for(const t of this.cleanupFns.values())try{await t()}catch(t){console.error("Error during cleanup:",t)}this.cleanupFns.clear()}async runOperation(t){const e=t(),n=e.then(()=>{},()=>{});this.pendingOperations.add(n);try{const t=await e;return this.pendingOperations.delete(n),t}catch(t){throw this.pendingOperations.delete(n),t}}}function V(e){return function(o,r){return t.controllerRegistry.set(e,o),o.prototype[n]=!0,o}}async function X(e,n){const r=e[u],s=e[h],i=e[f];if(void 0!==i&&i!==n)return;if(s===n&&r)return;r&&await Y(e);const a=t.controllerRegistry.get(n);if(!a)throw new Error(`Controller "${n}" not found in registry`);const c=new a;t.controllerIdCounter+=1;const l=t.controllerIdCounter,m=new J;c[o]=!0,c[d]=l,c.element=e;const y=e[E];void 0!==y&&(c[E]=y),e[u]=c,e[h]=n,e[p]=m,await e.ready,await m.runOperation(async()=>{await c.attach(e)}),k(c,e),j(c,e),Q(c,e),e.dispatchEvent(new CustomEvent("@snice/controller-attached",{detail:{name:n,controller:c}}))}async function Y(t){const e=t[u],n=t[h],o=t[p];e&&(o?await o.runOperation(async()=>{await e.detach(t)}):await e.detach(t),e.element=null,R(e),G(e),_(e),o&&await o.cleanup(),delete e[E],delete t[u],delete t[h],delete t[p],t.dispatchEvent(new CustomEvent("@snice/controller-detached",{detail:{name:n,controller:e}})))}function Z(t){return t[u]}function tt(){if(globalThis.sniceNativeControllersInitialized)return;function t(t){if(!(t instanceof HTMLElement))return;if(t.tagName.includes("-"))return;if(t[r])return;const e=t.getAttribute("controller"),n=t[f];e&&e!==n?(t[f]=e,t.ready||(t.ready=Promise.resolve()),n&&Y(t).catch(t=>{console.error("Failed to detach old controller from native element:",t)}),X(t,e).catch(t=>{console.error(`Failed to attach controller "${e}" to native element:`,t)})):!e&&n&&(delete t[f],delete t[h],Y(t).catch(t=>{console.error("Failed to detach controller from native element:",t)}))}globalThis.sniceNativeControllersInitialized=!0;const e=new MutationObserver(e=>{for(const n of e)"attributes"===n.type&&"controller"===n.attributeName?t(n.target):"childList"===n.type&&n.addedNodes.forEach(e=>{e instanceof HTMLElement&&(t(e),e.querySelectorAll('[controller]:not([class*="-"])').forEach(t))})});"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}):(document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})),globalThis.sniceNativeControllerObserver=e}function et(){const t=globalThis.sniceNativeControllerObserver;t&&(t.disconnect(),delete globalThis.sniceNativeControllerObserver,delete globalThis.sniceNativeControllersInitialized)}function nt(t){t.prototype[r]=!0;const e=t.prototype.connectedCallback,n=t.prototype.disconnectedCallback,o=t.prototype.attributeChangedCallback,s=t.observedAttributes||[];s.includes("controller")||s.push("controller");const l=t[y];if(l)for(const[t,e]of l){const n="string"==typeof e.attribute?e.attribute:t.toLowerCase();s.includes(n)||s.push(n)}Object.defineProperty(t,"observedAttributes",{get:()=>s,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get(){return this[i]||(this[i]=new Promise(t=>{this[a]=t})),this[i]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controller",{get(){return this[c]},set(t){const e=this[c];this[c]=t,t!==e&&t?X(this,t).catch(e=>{console.error(`Failed to attach controller "${t}":`,e)}):!t&&e&&Y(this).catch(t=>{console.error("Failed to detach controller:",t)})},enumerable:!0,configurable:!0}),t.prototype.connectedCallback=async function(){this[i]||(this[i]=new Promise(t=>{this[a]=t}));try{const n=t[y];if(n)for(const[t,e]of n)if(this.hasAttribute(t)){const n=this.getAttribute(t);switch(this[v]||(this[v]=new Set),this[v].add(t),e.type){case Boolean:this[t]=null!==n&&"false"!==n;break;case Number:this[t]=Number(n);break;case String:this[t]=n;break;case Date:this[t]=n?new Date(n):null;break;case BigInt:n&&n.endsWith("n")?this[t]=BigInt(n.slice(0,-1)):this[t]=n?BigInt(n):null;break;case ct:this[t]=ct.parse(n);break;default:this[t]=n}}if(this[b]=!0,n)for(const[t,e]of n){const n=this[v]&&this[v].has(t),o=t in this[g];if(e.reflect&&o&&(n||void 0!==this[g][t])){const n=this[g][t],o="string"==typeof e.attribute?e.attribute:t.toLowerCase();if(null!=n&&!1!==n&&(e.type!==ct||!Array.isArray(n)||0!==n.length)){let t;t=n instanceof Date?n.toISOString():"bigint"==typeof n?n.toString()+"n":e.type===ct&&Array.isArray(n)?ct.serialize(n):String(n),this.setAttribute(o,t)}}}R(this),this.shadowRoot||this.attachShadow({mode:"open"});let o="";if(this.html)try{const t=this.html(),e=t instanceof Promise?await t:t;void 0!==e&&(o+=e)}catch(t){console.error(`Error in html() method for ${this.tagName}:`,t)}if(this.css)try{const t=this.css(),e=t instanceof Promise?await t:t;if(e){o+=`<style data-component-css>${Array.isArray(e)?e.join("\n"):e}</style>`}}catch(t){console.error(`Error in css() method for ${this.tagName}:`,t)}o&&(this.shadowRoot.innerHTML=o);const r=t[L];if(r&&this.shadowRoot)for(const[t,e]of r)try{const n=this.shadowRoot.querySelector(`[part="${t}"]`);if(n){const t=e.method.call(this),o=t instanceof Promise?await t:t;void 0!==o&&(n.innerHTML=o)}}catch(e){console.error(`Error rendering @part('${t}') in ${this.tagName}:`,e)}k(this,this),Q(this,this);try{j(this,this)}catch(t){console.error(`Error setting up observers for ${this.tagName}:`,t)}e&&e.call(this)}finally{this[a]&&(this[a](),this[a]=null)}const n=t[A];if(n)for(const t of n)try{await t.method.call(this)}catch(e){console.error(`Error in @ready handler ${t.methodName}:`,e)}},t.prototype.disconnectedCallback=async function(){const e=t[N];if(e)for(const t of e)try{await t.method.call(this)}catch(e){console.error(`Error in @dispose handler ${t.methodName}:`,e)}n&&n.call(this),this[c]&&Y(this).catch(t=>{console.error("Failed to detach controller:",t)}),R(this),_(this),G(this)},t.prototype.attributeChangedCallback=function(e,n,r){if(o?.call(this,e,n,r),"controller"===e)this.controller=r;else{const n=t[y];if(n)for(const[o,s]of n){if(("string"==typeof s.attribute?s.attribute:o.toLowerCase())===e){const e=this[g]?.[o];let n;if(n=s.type===Boolean?null!==r&&"false"!==r:s.type===Number?Number(r):s.type===Date?r?new Date(r):null:s.type===BigInt?r&&r.endsWith("n")?BigInt(r.slice(0,-1)):r?BigInt(r):null:s.type===ct?ct.parse(r):"number"==typeof e&&null!==r?Number(r):r,e!==n){this[v]||(this[v]=new Set),this[v].add(o),this[g]||(this[g]={}),this[g][o]=n;const r=t[w];if(r){if(r.has(o)){const t=r.get(o);for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(r.has("*")){const t=r.get("*");for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}}break}}}}}function ot(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}return nt(e),customElements.define(t,e),e}}function rt(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}return nt(e),customElements.define(t,e),e}}function st(t){return function(e,n){const o=n.name;return n.metadata||(n.metadata={}),n.metadata[y]||(n.metadata[y]=new Map),n.metadata[y].set(o,t||{}),t?.reflect&&t?.type===Array&&console.warn(`⚠️ Property '${o}' uses reflect:true with Array type.`),t?.reflect&&t?.type===Object&&console.warn(`⚠️ Property '${o}' uses reflect:true with Object type.`),n.addInitializer(function(){}),function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,o)){const e={get(){return this[g]||(this[g]={}),this[g][o]},set(e){this[g]||(this[g]={}),this[v]||(this[v]=new Set);const n=this[g][o];if(n===e)return;const r=void 0===n&&!this[b];if((void 0!==n||r&&null!=e)&&this[v].add(o),this[g][o]=e,t?.reflect&&this.setAttribute&&this[b]&&this[v].has(o)){const n="string"==typeof t.attribute?t.attribute:o.toLowerCase();if(null==e||!1===e||t?.type===ct&&Array.isArray(e)&&0===e.length)this.removeAttribute(n);else{let o;o=e instanceof Date?e.toISOString():"bigint"==typeof e?e.toString()+"n":t?.type===ct&&Array.isArray(e)?ct.serialize(e):String(e),this.setAttribute(n,o)}}const s=this.constructor[w];if(s){if(s.has(o)){const t=s.get(o);for(const r of t)try{r.method.call(this,n,e,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(s.has("*")){const t=s.get("*");for(const r of t)try{r.method.call(this,n,e,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}this.requestUpdate&&this.requestUpdate(o,n)},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,o,e)}return this[g]||(this[g]={}),this[g][o]=e,e}}}function it(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e,a=r.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[o]&&this.element?this.element:this;let n=null;return i&&e.shadowRoot&&(n=e.shadowRoot.querySelector(t)),!n&&s&&(n=e.querySelector(t)),n||null},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,a,e)}return e}}}function at(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e,a=r.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[o]&&this.element?this.element:this,n=[];if(i&&e.shadowRoot){const o=e.shadowRoot.querySelectorAll(t);n.push(...o)}if(s){const o=e.querySelectorAll(t);n.push(...o)}return n},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,a,e)}return e}}}class ct{static{this.SEPARATOR=","}static serialize(t){return Array.isArray(t)?t.map(t=>{if("string"==typeof t){if(t.includes(ct.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${ct.SEPARATOR}" (U+FF0C)`);return t}if("number"==typeof t||"boolean"==typeof t)return String(t);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof t)}).join(ct.SEPARATOR):""}static parse(t){return null==t||""===t?[]:t.split(ct.SEPARATOR).map(t=>{if(/^-?\d+\.?\d*$/.test(t)){const e=Number(t);if(!isNaN(e))return e}return"true"===t||"false"!==t&&t})}}function lt(...t){return function(e,n){const o=n.name;n.addInitializer(function(){const n=this.constructor;n[w]||(n[w]=new Map);for(const r of t)n[w].has(r)||n[w].set(r,[]),n[w].get(r).push({methodName:o,method:e})})}}function ut(){return function(t,e){const n=e.name;return function(t){if(!Object.hasOwnProperty.call(this.constructor.prototype,n)){const t={get(){if(void 0!==this[E])return this[E];const t={target:this},e=new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t});let n=!0===this[o]&&this.element?this.element:this;if(n&&n.dispatchEvent){if(n.getRootNode&&n.getRootNode()instanceof ShadowRoot){const t=n.getRootNode();n=t.host}return n.dispatchEvent(e),void 0!==t.context?(this[E]=t.context,t.context):void 0}},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,n,t)}return t}}}function ht(){return function(t,e){const n=e.name;e.addInitializer(function(){const e=this.constructor;e[A]||(e[A]=[]),e[A].push({methodName:n,method:t})})}}function dt(){return function(t,e){const n=e.name;e.addInitializer(function(){const e=this.constructor;e[N]||(e[N]=[]),e[N].push({methodName:n,method:t})})}}function pt(t,e={}){return function(n,o){const r=o.name;return o.addInitializer(function(){const e=this.constructor;e[L]||(e[L]=new Map),e[L].set(t,{methodName:r,method:n})}),function(...o){this[I]||(this[I]=new Map),this[I].has(t)||this[I].set(t,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[I].get(t),s=(...e)=>{const o=n.apply(this,e),r=e=>{const n=void 0!==e,o=this.shadowRoot?.querySelector(`[part="${t}"]`);n&&o&&(o.innerHTML=e)};return o instanceof Promise?o.then(t=>(r(t),t)):(r(o),o)},i=void 0!==e.debounce&&e.debounce>0,a=void 0!==e.throttle&&e.throttle>0;switch(!0){case i:return clearTimeout(r.debounceTimer),void(r.debounceTimer=setTimeout(()=>s(...o),e.debounce));case a:{const t=e.throttle,n=Date.now();if(0===r.lastThrottleCall||n-r.lastThrottleCall>=t)return r.lastThrottleCall=n,s(...o);if(!!!r.throttleTimer){const e=t-(n-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),s(...o)},e)}return}default:return s(...o)}}}}
|
|
8
8
|
/*!
|
|
9
9
|
* pica-route v1.1.2
|
|
10
10
|
* A pure URL pattern matching library compatible with route-parser API
|
|
11
11
|
* (c) 2024
|
|
12
12
|
* Released under the MIT License.
|
|
13
|
-
*/class ft{constructor(t){this.parsed=this.parsePattern(t)}get spec(){return this.parsed.template}parsePattern(t){let e=t,n="",o=!1;const r=t.indexOf("?");return-1!==r&&(e=t.slice(0,r),n=t.slice(r+1),e.endsWith("(")&&n.endsWith(")")&&(o=!0,e=e.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(e),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:t}}parseSegments(t){const e=[];let n=0;for(;n<t.length;){switch(t[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(t,n);e.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(t,n+1);e.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(t,n+1);e.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:u}=this.parseLiteral(t,n);l&&e.push({type:"literal",value:l}),n=u}}return e}parseOptionalGroup(t,e){let n=1,o=e+1;for(;o<t.length&&n>0;)"("===t[o]&&n++,")"===t[o]&&n--,o++;const r=t.slice(e+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(t,e){let n=e;for(;n<t.length&&/[\w-]/.test(t[n]);)n++;return{name:t.slice(e,n),endIndex:n}}parseLiteral(t,e){let n=e;for(;n<t.length&&!"(:*(".includes(t[n]);)n++;return{value:t.slice(e,n),endIndex:n}}parseQuerySegments(t){let e=t;e.startsWith("(")&&e.endsWith(")")&&(e=e.slice(1,-1));const n=[];let o=0;for(;o<e.length;)if(":"===e[o]){const{name:t,endIndex:r}=this.parseIdentifier(e,o+1);n.push({type:"param",name:t}),o=r}else{const{value:t,endIndex:r}=this.parseQueryLiteral(e,o);t&&n.push({type:"literal",value:t}),o=r}return n}parseQueryLiteral(t,e){let n=e;for(;n<t.length&&":"!==t[n];)n++;return{value:t.slice(e,n),endIndex:n}}getAllParamNames(){const t=new Set,e=n=>{for(const o of n)switch(o.type){case"param":case"splat":t.add(o.name);break;case"optional":e(o.segments)}};return e(this.parsed.pathSegments),e(this.parsed.querySegments),Array.from(t)}canMatchRemainingSegments(t,e,n){let o=e;for(const e of n)if("literal"===e.type){const n=t.indexOf(e.value,o);if(-1===n)return!1;o=n+e.value.length}return!0}match(t){const[e,n]=t.split("?"),o=this.matchPath(e,this.parsed.pathSegments);if(!1===o)return!1;const r=this.matchQuery(n||"",this.parsed.querySegments);if(!1===r)return!1;const s=this.getAllParamNames(),i={};for(const t of s)i[t]=void 0;return Object.assign(i,o,r),i}matchPath(t,e){const n={};let o=0;for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1),a=this.matchSegment(t,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<t.length)&&n}matchSegment(t,e,n,o=[]){switch(n.type){case"literal":return t.slice(e,e+n.value.length)===n.value&&{params:{},nextIndex:e+n.value.length};case"param":{let r=e;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=s.value,o=t.indexOf(n,e);if(-1===o)return!1;r=o}else for(;r<t.length&&!a.includes(t[r]);)r++;if(r===e)return!1;try{i=decodeURIComponent(t.slice(e,r))}catch(n){i=t.slice(e,r)}return!(r<t.length&&"?"===t[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=t.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=t.indexOf(".",e);-1!==n&&(r=n)}else{const n=t.lastIndexOf(s.value);-1!==n&&n>=e&&(r=n)}break;case"param":let n=-1;for(let o=t.length-1;o>=e;o--)if("/"===t[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=t.length-1;n>e;n--)if("/"===t[n]){o=n+1;break}if(-1!==o)r=o;else{const n=t.slice(e).split("/").filter(t=>t);r=n.length>1?e+n.slice(0,-1).join("/").length+1:e}break;case"optional":const i=t=>{for(const e of t){if("literal"===e.type)return e.value;if("optional"===e.type){const t=i(e.segments);if(t)return t}}return null},a=i(s.segments);if(a){const n=t.lastIndexOf(a);-1!==n&&n>=e&&(r=n)}}const i=t.indexOf("?",e);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(t.slice(e,r))}catch(n){a=t.slice(e,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=e,s={},i=!0;for(let e=0;e<n.segments.length;e++){const o=n.segments[e],a=n.segments.slice(e+1),c=this.matchSegment(t,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}if(i){if(this.canMatchRemainingSegments(t,r,o))return{params:s,nextIndex:r}}return{params:{},nextIndex:e}}default:return!1}}findNextLiteral(t){for(const e of t){if("literal"===e.type)return e;if("optional"===e.type){const t=this.findNextLiteral(e.segments);if(t)return t}}return null}matchQuery(t,e){if(0===e.length)return{};const n={};let o=0;for(const r of e)switch(r.type){case"literal":if(t.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let e,s=o;for(;s<t.length&&"&"!==t[s];)s++;if(s===o)return!1;try{e=decodeURIComponent(t.slice(o,s))}catch(n){e=t.slice(o,s)}n[r.name]=e,o=s;break}}return n}reverse(t={}){const e=this.reverseSegments(this.parsed.pathSegments,t);if(!1===e)return!1;let n=e;if(this.parsed.querySegments.length>0){const e=this.reverseSegments(this.parsed.querySegments,t);if(!this.parsed.queryOptional&&!1===e)return!1;e&&""!==e&&(n+="?"+e)}return n}reverseSegments(t,e,n=!1){let o="";for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in e))return!1;o+=String(e[s.name]);break;case"optional":if(this.hasAllParams(s.segments,e,n)||this.hasLaterOptionalGroupNeedingParams(i,e,s.segments)){const t=this.reverseSegments(s.segments,e,!0);if(!1===t)return!1;o+=t}}}return o}hasLaterOptionalGroupNeedingParams(t,e,n){for(const o of t)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,e))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(t){for(const e of t)if("param"===e.type||"splat"===e.type)return!1;return!0}hasAllParams(t,e,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of t)switch(n.type){case"param":case"splat":i=!1,n.name in e&&void 0!==e[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of t)if("optional"===n.type){this.hasAllParams(n.segments,e,a)&&(r=!0)}return!(!o||s)||(!(!r||s)||!(!i||!n))}hasOnlyOptionalMissingParams(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(!(n.name in e))return!1}return!0}hasAnyParamInSegments(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(n.name in e)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,e))return!0}return!1}}function mt(t){const e={};return t.split(";").forEach(t=>{const[n,o]=t.split(":").map(t=>t.trim());n&&o&&(e[n]=o)}),e}var yt;function gt(t){const e=[];let n,o,r,s=!1,i=null,a=null;const c=t.context||{};function l(t){if(!i||!a)return null;const e=t.querySelectorAll(i);for(const t of e){if(t[A]===a)return t}return null}function u(t,i,a,c,l){e.push({route:new ft(t),tag:i,transition:a,guards:c,layout:l}),s=!1,"/404"===t&&(n=i),"/403"===t&&(o=i),"/"===t&&(r=i)}function h(){switch(t.type){case"hash":return window.location.hash.slice(1);case"pushstate":return window.location.pathname}}async function d(t){let e;const n=!!o;if(n&&(e=document.createElement(o),e[E]=c),!n){const t=document.createElement("div");t.className="default-403",t.innerHTML="<h1>403</h1><p>Unauthorized</p>",e=t}t.innerHTML="",t.appendChild(e),i=null,a=null}async function p(t,e,n){if(!!!t)return!0;const o=Array.isArray(t)?t:[t];for(const t of o){if(!await t(c,e))return await d(n),!1}return!0}function f(e){if(!1===e)return null;if(!!e)return e;return!!t.layout?t.layout:null}function m(t){if(!(t!==i))return{element:null,needsNewLayout:!1};i=t;if(!!t){const e=Date.now();a=e;const n=document.createElement(t);return n[E]=c,n[A]=e,{element:n,needsNewLayout:!0}}return a=null,{element:null,needsNewLayout:!0}}async function g(t,e,n,o,r){const s=o||l(t);if(!s)return;const i=s.querySelector('[slot="page"]');if(!(!n||!i))return e.setAttribute("slot","page"),await v(s,i,e,n),void(r&&(t.innerHTML="",t.appendChild(s)));s.querySelectorAll('[slot="page"]').forEach(t=>t.remove()),e.setAttribute("slot","page"),s.appendChild(e),r&&(t.innerHTML="",t.appendChild(s))}async function b(t,e,n){const o=t.children[0];!n||!o?(t.innerHTML="",t.appendChild(e)):await v(t,o,e,n)}async function w(o){const s=document.querySelector(t.target);if(!s)throw new Error(`Target element not found: ${t.target}`);window.scrollTo(0,0);if((""===o.trim()||"/"===o)&&!!r){const n=e.find(t=>t.route.match("/"));if(!await p(n?.guards,{},s))return;const{element:o,transition:i,layout:a}=function(){const t=document.createElement(r);t[E]=c;const n=customElements.get(r),o=n?.[T],s=e.find(t=>t.route.match("/"));return{element:t,transition:o,layout:s?.layout}}(),u=f(a),{element:h,needsNewLayout:d}=m(u),y=i||t.transition;return null!==h||null!==l(s)?void await g(s,o,y,h,d):void await b(s,o,y)}const i=await async function(t,n){for(const o of e){const e=o.route.match(t);if(!1===e)continue;if(!await p(o.guards,e,n))return{result:yt.GUARDS_FAILED};const r=document.createElement(o.tag);r[E]=c;const s=e;return Object.keys(s).forEach(t=>r.setAttribute(t,s[t])),{result:yt.SUCCESS,element:r,transition:o.transition,layout:o.layout}}return{result:yt.NOT_FOUND}}(o,s);if(i.result===yt.GUARDS_FAILED)return;if(i.result===yt.SUCCESS){const{element:e,transition:n,layout:o}=i,r=f(o),{element:a,needsNewLayout:c}=m(r),u=n||t.transition;return null!==a||null!==l(s)?void await g(s,e,u,a,c):void await b(s,e,u)}const{element:a,transition:u,layout:h}=function(){if(n){const t=document.createElement(n);t[E]=c;const e=customElements.get(n),o=e?.[T];return{element:t,transition:o,layout:void 0}}const t=document.createElement("div");return t.className="default-404",t.innerHTML="<h1>404</h1><p>Page not found</p>",{element:t,transition:void 0,layout:void 0}}(),d=f(h),{element:y,needsNewLayout:w}=m(d),v=u||t.transition;null!==y||null!==l(s)?await g(s,a,v,y,w):await b(s,a,v)}async function v(t,e,n,o){return async function(t,e,n,o={}){const r=o.outDuration||300,s=o.inDuration||300,i=o.mode||"sequential",a=o.out?mt(o.out):{opacity:"0"},c={opacity:"0"},l=o.in?mt(o.in):{opacity:"1"},u=t.style,h=u.position,d=t.tagName.includes("-")&&t.shadowRoot;d||(u.position="relative");const p=e.hasAttribute("slot")||n.hasAttribute("slot");p?(e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.transition=`opacity ${r}ms ease-in-out`,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.transition=`opacity ${s}ms ease-in-out`):(e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.transition=`all ${r}ms ease-in-out`,n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%"),Object.assign(n.style,c),n.style.transition=`all ${s}ms ease-in-out`,t.appendChild(n),n.offsetHeight,"simultaneous"===i?(Object.assign(e.style,a),Object.assign(n.style,l),await new Promise(t=>setTimeout(t,Math.max(r,s)))):(Object.assign(e.style,a),await new Promise(t=>setTimeout(t,r)),Object.assign(n.style,l),await new Promise(t=>setTimeout(t,s))),e.remove(),p?(n.style.position="",n.style.width="",n.style.height="",n.style.transition=""):(n.style.position="",n.style.top="",n.style.left="",n.style.width="",n.style.transition=""),Object.keys({...c,...l}).forEach(t=>{n.style[t]=""}),d||(u.position=h)}(t,e,n,o)}return{page:function(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}nt(e),e[T]=t.transition;const o=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){o?.call(this);const t=t=>{void 0!==this[E]&&(t.detail.context=this[E],t.stopPropagation())};this.addEventListener("@context/request",t),this[S]=t};const r=e.prototype.disconnectedCallback;return e.prototype.disconnectedCallback=function(){r?.call(this);const t=this[S];t&&(this.removeEventListener("@context/request",t),delete this[S]),delete this[E]},customElements.define(t.tag,e),t.routes.forEach(e=>u(e,t.tag,t.transition,t.guards,t.layout)),e}},initialize:function(){if(!!!document.querySelector(t.target))throw new Error(`Target element not found: ${t.target}`);!s&&(e.sort((t,e)=>e.route.spec.length-t.route.spec.length),s=!0),function(){const e="hash"===t.type,n="pushstate"===t.type;e&&window.addEventListener("hashchange",()=>{document.querySelector(t.target)&&w(h())}),n&&window.addEventListener("popstate",()=>{document.querySelector(t.target)&&w(h())})}(),w(h())},navigate:w,register:u,context:c}}!function(t){t.SUCCESS="success",t.GUARDS_FAILED="guards-failed",t.NOT_FOUND="not-found"}(yt||(yt={}));export{o as IS_CONTROLLER_INSTANCE,gt as Router,ct as SimpleArray,nt as applyElementFunctionality,X as attachController,et as cleanupNativeElementControllers,ut as context,V as controller,Y as detachController,$ as dispatch,dt as dispose,ot as element,Z as getController,e as getSymbol,rt as layout,M as observe,x as on,pt as part,st as property,it as query,at as queryAll,ht as ready,K as request,W as respond,tt as useNativeElementControllers,lt as watch};
|
|
13
|
+
*/class ft{constructor(t){this.parsed=this.parsePattern(t)}get spec(){return this.parsed.template}parsePattern(t){let e=t,n="",o=!1;const r=t.indexOf("?");return-1!==r&&(e=t.slice(0,r),n=t.slice(r+1),e.endsWith("(")&&n.endsWith(")")&&(o=!0,e=e.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(e),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:t}}parseSegments(t){const e=[];let n=0;for(;n<t.length;){switch(t[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(t,n);e.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(t,n+1);e.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(t,n+1);e.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:u}=this.parseLiteral(t,n);l&&e.push({type:"literal",value:l}),n=u}}return e}parseOptionalGroup(t,e){let n=1,o=e+1;for(;o<t.length&&n>0;)"("===t[o]&&n++,")"===t[o]&&n--,o++;const r=t.slice(e+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(t,e){let n=e;for(;n<t.length&&/[\w-]/.test(t[n]);)n++;return{name:t.slice(e,n),endIndex:n}}parseLiteral(t,e){let n=e;for(;n<t.length&&!"(:*(".includes(t[n]);)n++;return{value:t.slice(e,n),endIndex:n}}parseQuerySegments(t){let e=t;e.startsWith("(")&&e.endsWith(")")&&(e=e.slice(1,-1));const n=[];let o=0;for(;o<e.length;)if(":"===e[o]){const{name:t,endIndex:r}=this.parseIdentifier(e,o+1);n.push({type:"param",name:t}),o=r}else{const{value:t,endIndex:r}=this.parseQueryLiteral(e,o);t&&n.push({type:"literal",value:t}),o=r}return n}parseQueryLiteral(t,e){let n=e;for(;n<t.length&&":"!==t[n];)n++;return{value:t.slice(e,n),endIndex:n}}getAllParamNames(){const t=new Set,e=n=>{for(const o of n)switch(o.type){case"param":case"splat":t.add(o.name);break;case"optional":e(o.segments)}};return e(this.parsed.pathSegments),e(this.parsed.querySegments),Array.from(t)}canMatchRemainingSegments(t,e,n){let o=e;for(const e of n)if("literal"===e.type){const n=t.indexOf(e.value,o);if(-1===n)return!1;o=n+e.value.length}return!0}match(t){const[e,n]=t.split("?"),o=this.matchPath(e,this.parsed.pathSegments);if(!1===o)return!1;const r=this.matchQuery(n||"",this.parsed.querySegments);if(!1===r)return!1;const s=this.getAllParamNames(),i={};for(const t of s)i[t]=void 0;return Object.assign(i,o,r),i}matchPath(t,e){const n={};let o=0;for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1),a=this.matchSegment(t,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<t.length)&&n}matchSegment(t,e,n,o=[]){switch(n.type){case"literal":return t.slice(e,e+n.value.length)===n.value&&{params:{},nextIndex:e+n.value.length};case"param":{let r=e;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=s.value,o=t.indexOf(n,e);if(-1===o)return!1;r=o}else for(;r<t.length&&!a.includes(t[r]);)r++;if(r===e)return!1;try{i=decodeURIComponent(t.slice(e,r))}catch(n){i=t.slice(e,r)}return!(r<t.length&&"?"===t[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=t.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=t.indexOf(".",e);-1!==n&&(r=n)}else{const n=t.lastIndexOf(s.value);-1!==n&&n>=e&&(r=n)}break;case"param":let n=-1;for(let o=t.length-1;o>=e;o--)if("/"===t[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=t.length-1;n>e;n--)if("/"===t[n]){o=n+1;break}if(-1!==o)r=o;else{const n=t.slice(e).split("/").filter(t=>t);r=n.length>1?e+n.slice(0,-1).join("/").length+1:e}break;case"optional":const i=t=>{for(const e of t){if("literal"===e.type)return e.value;if("optional"===e.type){const t=i(e.segments);if(t)return t}}return null},a=i(s.segments);if(a){const n=t.lastIndexOf(a);-1!==n&&n>=e&&(r=n)}}const i=t.indexOf("?",e);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(t.slice(e,r))}catch(n){a=t.slice(e,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=e,s={},i=!0;for(let e=0;e<n.segments.length;e++){const o=n.segments[e],a=n.segments.slice(e+1),c=this.matchSegment(t,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}if(i){if(this.canMatchRemainingSegments(t,r,o))return{params:s,nextIndex:r}}return{params:{},nextIndex:e}}default:return!1}}findNextLiteral(t){for(const e of t){if("literal"===e.type)return e;if("optional"===e.type){const t=this.findNextLiteral(e.segments);if(t)return t}}return null}matchQuery(t,e){if(0===e.length)return{};const n={};let o=0;for(const r of e)switch(r.type){case"literal":if(t.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let e,s=o;for(;s<t.length&&"&"!==t[s];)s++;if(s===o)return!1;try{e=decodeURIComponent(t.slice(o,s))}catch(n){e=t.slice(o,s)}n[r.name]=e,o=s;break}}return n}reverse(t={}){const e=this.reverseSegments(this.parsed.pathSegments,t);if(!1===e)return!1;let n=e;if(this.parsed.querySegments.length>0){const e=this.reverseSegments(this.parsed.querySegments,t);if(!this.parsed.queryOptional&&!1===e)return!1;e&&""!==e&&(n+="?"+e)}return n}reverseSegments(t,e,n=!1){let o="";for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in e))return!1;o+=String(e[s.name]);break;case"optional":if(this.hasAllParams(s.segments,e,n)||this.hasLaterOptionalGroupNeedingParams(i,e,s.segments)){const t=this.reverseSegments(s.segments,e,!0);if(!1===t)return!1;o+=t}}}return o}hasLaterOptionalGroupNeedingParams(t,e,n){for(const o of t)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,e))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(t){for(const e of t)if("param"===e.type||"splat"===e.type)return!1;return!0}hasAllParams(t,e,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of t)switch(n.type){case"param":case"splat":i=!1,n.name in e&&void 0!==e[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of t)if("optional"===n.type){this.hasAllParams(n.segments,e,a)&&(r=!0)}return!(!o||s)||(!(!r||s)||!(!i||!n))}hasOnlyOptionalMissingParams(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(!(n.name in e))return!1}return!0}hasAnyParamInSegments(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(n.name in e)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,e))return!0}return!1}}function mt(t){const e={};return t.split(";").forEach(t=>{const[n,o]=t.split(":").map(t=>t.trim());n&&o&&(e[n]=o)}),e}var yt;function gt(t){const e=[];let n,o,r,s=!1,i=null,a=null;const c=t.context||{};function l(t){if(!i||!a)return null;const e=t.querySelectorAll(i);for(const t of e){if(t[O]===a)return t}return null}function u(t,i,a,c,l){e.push({route:new ft(t),tag:i,transition:a,guards:c,layout:l}),s=!1,"/404"===t&&(n=i),"/403"===t&&(o=i),"/"===t&&(r=i)}function h(){switch(t.type){case"hash":return window.location.hash.slice(1);case"pushstate":return window.location.pathname}}async function d(t){let e;const n=!!o;if(n&&(e=document.createElement(o),e[E]=c),!n){const t=document.createElement("div");t.className="default-403",t.innerHTML="<h1>403</h1><p>Unauthorized</p>",e=t}t.innerHTML="",t.appendChild(e),i=null,a=null}async function p(t,e,n){if(!!!t)return!0;const o=Array.isArray(t)?t:[t];for(const t of o){if(!await t(c,e))return await d(n),!1}return!0}function f(e){if(!1===e)return null;if(!!e)return e;return!!t.layout?t.layout:null}function m(t){if(!(t!==i))return{element:null,needsNewLayout:!1};i=t;if(!!t){const e=Date.now();a=e;const n=document.createElement(t);return n[E]=c,n[O]=e,{element:n,needsNewLayout:!0}}return a=null,{element:null,needsNewLayout:!0}}async function g(t,e,n,o,r){const s=o||l(t);if(!s)return;const i=s.querySelector('[slot="page"]');if(!(!n||!i))return e.setAttribute("slot","page"),await v(s,i,e,n),void(r&&(t.innerHTML="",t.appendChild(s)));s.querySelectorAll('[slot="page"]').forEach(t=>t.remove()),e.setAttribute("slot","page"),s.appendChild(e),r&&(t.innerHTML="",t.appendChild(s))}async function b(t,e,n){const o=t.children[0];!n||!o?(t.innerHTML="",t.appendChild(e)):await v(t,o,e,n)}async function w(o){const s=document.querySelector(t.target);if(!s)throw new Error(`Target element not found: ${t.target}`);window.scrollTo(0,0);if((""===o.trim()||"/"===o)&&!!r){const n=e.find(t=>t.route.match("/"));if(!await p(n?.guards,{},s))return;const{element:o,transition:i,layout:a}=function(){const t=document.createElement(r);t[E]=c;const n=customElements.get(r),o=n?.[T],s=e.find(t=>t.route.match("/"));return{element:t,transition:o,layout:s?.layout}}(),u=f(a),{element:h,needsNewLayout:d}=m(u),y=i||t.transition;return null!==h||null!==l(s)?void await g(s,o,y,h,d):void await b(s,o,y)}const i=await async function(t,n){for(const o of e){const e=o.route.match(t);if(!1===e)continue;if(!await p(o.guards,e,n))return{result:yt.GUARDS_FAILED};const r=document.createElement(o.tag);r[E]=c;const s=e;return Object.keys(s).forEach(t=>r.setAttribute(t,s[t])),{result:yt.SUCCESS,element:r,transition:o.transition,layout:o.layout}}return{result:yt.NOT_FOUND}}(o,s);if(i.result===yt.GUARDS_FAILED)return;if(i.result===yt.SUCCESS){const{element:e,transition:n,layout:o}=i,r=f(o),{element:a,needsNewLayout:c}=m(r),u=n||t.transition;return null!==a||null!==l(s)?void await g(s,e,u,a,c):void await b(s,e,u)}const{element:a,transition:u,layout:h}=function(){if(n){const t=document.createElement(n);t[E]=c;const e=customElements.get(n),o=e?.[T];return{element:t,transition:o,layout:void 0}}const t=document.createElement("div");return t.className="default-404",t.innerHTML="<h1>404</h1><p>Page not found</p>",{element:t,transition:void 0,layout:void 0}}(),d=f(h),{element:y,needsNewLayout:w}=m(d),v=u||t.transition;null!==y||null!==l(s)?await g(s,a,v,y,w):await b(s,a,v)}async function v(t,e,n,o){return async function(t,e,n,o={}){const r=o.outDuration||300,s=o.inDuration||300,i=o.mode||"sequential",a=o.out?mt(o.out):{opacity:"0"},c={opacity:"0"},l=o.in?mt(o.in):{opacity:"1"},u=t.style,h=u.position,d=t.tagName.includes("-")&&t.shadowRoot;d||(u.position="relative");const p=e.hasAttribute("slot")||n.hasAttribute("slot");p?(e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.transition=`opacity ${r}ms ease-in-out`,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.transition=`opacity ${s}ms ease-in-out`):(e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.transition=`all ${r}ms ease-in-out`,n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%"),Object.assign(n.style,c),n.style.transition=`all ${s}ms ease-in-out`,t.appendChild(n),n.offsetHeight,"simultaneous"===i?(Object.assign(e.style,a),Object.assign(n.style,l),await new Promise(t=>setTimeout(t,Math.max(r,s)))):(Object.assign(e.style,a),await new Promise(t=>setTimeout(t,r)),Object.assign(n.style,l),await new Promise(t=>setTimeout(t,s))),e.remove(),p?(n.style.position="",n.style.width="",n.style.height="",n.style.transition=""):(n.style.position="",n.style.top="",n.style.left="",n.style.width="",n.style.transition=""),Object.keys({...c,...l}).forEach(t=>{n.style[t]=""}),d||(u.position=h)}(t,e,n,o)}return{page:function(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}nt(e),e[T]=t.transition;const o=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){o?.call(this);const t=t=>{void 0!==this[E]&&(t.detail.context=this[E],t.stopPropagation())};this.addEventListener("@context/request",t),this[S]=t};const r=e.prototype.disconnectedCallback;return e.prototype.disconnectedCallback=function(){r?.call(this);const t=this[S];t&&(this.removeEventListener("@context/request",t),delete this[S]),delete this[E]},customElements.define(t.tag,e),t.routes.forEach(e=>u(e,t.tag,t.transition,t.guards,t.layout)),e}},initialize:function(){if(!!!document.querySelector(t.target))throw new Error(`Target element not found: ${t.target}`);!s&&(e.sort((t,e)=>e.route.spec.length-t.route.spec.length),s=!0),function(){const e="hash"===t.type,n="pushstate"===t.type;e&&window.addEventListener("hashchange",()=>{document.querySelector(t.target)&&w(h())}),n&&window.addEventListener("popstate",()=>{document.querySelector(t.target)&&w(h())})}(),w(h())},navigate:w,register:u,context:c}}!function(t){t.SUCCESS="success",t.GUARDS_FAILED="guards-failed",t.NOT_FOUND="not-found"}(yt||(yt={}));export{o as IS_CONTROLLER_INSTANCE,gt as Router,ct as SimpleArray,nt as applyElementFunctionality,X as attachController,et as cleanupNativeElementControllers,ut as context,V as controller,Y as detachController,$ as dispatch,dt as dispose,ot as element,Z as getController,e as getSymbol,rt as layout,M as observe,x as on,pt as part,st as property,it as query,at as queryAll,ht as ready,K as request,W as respond,tt as useNativeElementControllers,lt as watch};
|
|
14
14
|
//# sourceMappingURL=index.esm.min.js.map
|