snice 4.10.0 → 4.12.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.
Files changed (269) hide show
  1. package/adapters/react/carousel.d.ts +1 -0
  2. package/adapters/react/carousel.d.ts.map +1 -1
  3. package/adapters/react/carousel.js +1 -1
  4. package/adapters/react/carousel.js.map +1 -1
  5. package/adapters/react/carousel.tsx +2 -1
  6. package/bin/templates/CLAUDE.md +169 -113
  7. package/bin/templates/pwa/README.md +72 -94
  8. package/bin/templates/pwa/src/components/app-header.ts +218 -0
  9. package/bin/templates/pwa/src/components/notification-badge.ts +68 -0
  10. package/bin/templates/pwa/src/components/search-bar.ts +99 -0
  11. package/bin/templates/pwa/src/controllers/notification-controller.ts +42 -0
  12. package/bin/templates/pwa/src/guards/auth.ts +1 -1
  13. package/bin/templates/pwa/src/main.ts +19 -0
  14. package/bin/templates/pwa/src/pages/dashboard.ts +124 -23
  15. package/bin/templates/pwa/src/pages/data.ts +329 -0
  16. package/bin/templates/pwa/src/pages/notifications.ts +112 -30
  17. package/bin/templates/pwa/src/pages/profile.ts +86 -52
  18. package/bin/templates/pwa/src/pages/settings.ts +291 -0
  19. package/bin/templates/pwa/src/styles/global.css +12 -3
  20. package/dist/cdn/accordion/snice-accordion.js +1 -1
  21. package/dist/cdn/accordion/snice-accordion.min.js +1 -1
  22. package/dist/cdn/alert/snice-alert.js +1 -1
  23. package/dist/cdn/alert/snice-alert.min.js +1 -1
  24. package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
  25. package/dist/cdn/app-tiles/snice-app-tiles.min.js +1 -1
  26. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  27. package/dist/cdn/audio-recorder/snice-audio-recorder.min.js +1 -1
  28. package/dist/cdn/avatar/snice-avatar.js +1 -1
  29. package/dist/cdn/avatar/snice-avatar.min.js +1 -1
  30. package/dist/cdn/badge/snice-badge.js +1 -1
  31. package/dist/cdn/badge/snice-badge.min.js +1 -1
  32. package/dist/cdn/banner/snice-banner.js +1 -1
  33. package/dist/cdn/banner/snice-banner.min.js +1 -1
  34. package/dist/cdn/book/snice-book.js +1 -1
  35. package/dist/cdn/book/snice-book.min.js +1 -1
  36. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  37. package/dist/cdn/breadcrumbs/snice-breadcrumbs.min.js +1 -1
  38. package/dist/cdn/button/snice-button.js +1 -1
  39. package/dist/cdn/button/snice-button.min.js +1 -1
  40. package/dist/cdn/calendar/snice-calendar.js +1 -1
  41. package/dist/cdn/calendar/snice-calendar.min.js +1 -1
  42. package/dist/cdn/camera/README.md +1 -1
  43. package/dist/cdn/camera/snice-camera.js +1 -1
  44. package/dist/cdn/camera/snice-camera.min.js +1 -1
  45. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  46. package/dist/cdn/camera-annotate/snice-camera-annotate.min.js +1 -1
  47. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  48. package/dist/cdn/candlestick/snice-candlestick.min.js +1 -1
  49. package/dist/cdn/card/snice-card.js +1 -1
  50. package/dist/cdn/card/snice-card.min.js +1 -1
  51. package/dist/cdn/carousel/README.md +2 -2
  52. package/dist/cdn/carousel/snice-carousel.js +9 -3
  53. package/dist/cdn/carousel/snice-carousel.js.map +1 -1
  54. package/dist/cdn/carousel/snice-carousel.min.js +3 -3
  55. package/dist/cdn/carousel/snice-carousel.min.js.map +1 -1
  56. package/dist/cdn/chart/snice-chart.js +1 -1
  57. package/dist/cdn/chart/snice-chart.min.js +1 -1
  58. package/dist/cdn/chat/snice-chat.js +1 -1
  59. package/dist/cdn/chat/snice-chat.min.js +1 -1
  60. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  61. package/dist/cdn/checkbox/snice-checkbox.min.js +1 -1
  62. package/dist/cdn/chip/snice-chip.js +1 -1
  63. package/dist/cdn/chip/snice-chip.min.js +1 -1
  64. package/dist/cdn/code-block/snice-code-block.js +1 -1
  65. package/dist/cdn/code-block/snice-code-block.min.js +1 -1
  66. package/dist/cdn/color-display/snice-color-display.js +1 -1
  67. package/dist/cdn/color-display/snice-color-display.min.js +1 -1
  68. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  69. package/dist/cdn/color-picker/snice-color-picker.min.js +1 -1
  70. package/dist/cdn/command-palette/snice-command-palette.js +1 -1
  71. package/dist/cdn/command-palette/snice-command-palette.min.js +1 -1
  72. package/dist/cdn/comments/snice-comments.js +1 -1
  73. package/dist/cdn/comments/snice-comments.min.js +1 -1
  74. package/dist/cdn/countdown/snice-countdown.js +1 -1
  75. package/dist/cdn/countdown/snice-countdown.min.js +1 -1
  76. package/dist/cdn/cropper/snice-cropper.js +1 -1
  77. package/dist/cdn/cropper/snice-cropper.min.js +1 -1
  78. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  79. package/dist/cdn/date-picker/snice-date-picker.min.js +1 -1
  80. package/dist/cdn/diff/snice-diff.js +1 -1
  81. package/dist/cdn/diff/snice-diff.min.js +1 -1
  82. package/dist/cdn/divider/snice-divider.js +1 -1
  83. package/dist/cdn/divider/snice-divider.min.js +1 -1
  84. package/dist/cdn/doc/snice-doc.js +1 -1
  85. package/dist/cdn/doc/snice-doc.min.js +1 -1
  86. package/dist/cdn/draw/snice-draw.js +1 -1
  87. package/dist/cdn/draw/snice-draw.min.js +1 -1
  88. package/dist/cdn/drawer/snice-drawer.js +1 -1
  89. package/dist/cdn/drawer/snice-drawer.min.js +1 -1
  90. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  91. package/dist/cdn/empty-state/snice-empty-state.min.js +1 -1
  92. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  93. package/dist/cdn/file-gallery/snice-file-gallery.min.js +1 -1
  94. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  95. package/dist/cdn/file-upload/snice-file-upload.min.js +1 -1
  96. package/dist/cdn/flip-card/snice-flip-card.js +1 -1
  97. package/dist/cdn/flip-card/snice-flip-card.min.js +1 -1
  98. package/dist/cdn/flow/snice-flow.js +1 -1
  99. package/dist/cdn/flow/snice-flow.min.js +1 -1
  100. package/dist/cdn/funnel/snice-funnel.js +1 -1
  101. package/dist/cdn/funnel/snice-funnel.min.js +1 -1
  102. package/dist/cdn/gantt/README.md +1 -1
  103. package/dist/cdn/gantt/snice-gantt.js +1 -1
  104. package/dist/cdn/gantt/snice-gantt.min.js +1 -1
  105. package/dist/cdn/gauge/snice-gauge.js +1 -1
  106. package/dist/cdn/gauge/snice-gauge.min.js +1 -1
  107. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  108. package/dist/cdn/heatmap/snice-heatmap.min.js +1 -1
  109. package/dist/cdn/image/snice-image.js +1 -1
  110. package/dist/cdn/image/snice-image.min.js +1 -1
  111. package/dist/cdn/input/snice-input.js +1 -1
  112. package/dist/cdn/input/snice-input.min.js +1 -1
  113. package/dist/cdn/kanban/snice-kanban.js +1 -1
  114. package/dist/cdn/kanban/snice-kanban.min.js +1 -1
  115. package/dist/cdn/kpi/snice-kpi.js +1 -1
  116. package/dist/cdn/kpi/snice-kpi.min.js +1 -1
  117. package/dist/cdn/layout/snice-layout.js +1 -1
  118. package/dist/cdn/layout/snice-layout.min.js +1 -1
  119. package/dist/cdn/link/snice-link.js +1 -1
  120. package/dist/cdn/link/snice-link.min.js +1 -1
  121. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  122. package/dist/cdn/link-preview/snice-link-preview.min.js +1 -1
  123. package/dist/cdn/list/snice-list.js +1 -1
  124. package/dist/cdn/list/snice-list.min.js +1 -1
  125. package/dist/cdn/location/snice-location.js +1 -1
  126. package/dist/cdn/location/snice-location.min.js +1 -1
  127. package/dist/cdn/login/snice-login.js +1 -1
  128. package/dist/cdn/login/snice-login.min.js +1 -1
  129. package/dist/cdn/map/snice-map.js +1 -1
  130. package/dist/cdn/map/snice-map.min.js +1 -1
  131. package/dist/cdn/markdown/README.md +1 -1
  132. package/dist/cdn/markdown/snice-markdown.js +2 -2
  133. package/dist/cdn/markdown/snice-markdown.js.map +1 -1
  134. package/dist/cdn/markdown/snice-markdown.min.js +2 -2
  135. package/dist/cdn/markdown/snice-markdown.min.js.map +1 -1
  136. package/dist/cdn/masonry/snice-masonry.js +1 -1
  137. package/dist/cdn/masonry/snice-masonry.min.js +1 -1
  138. package/dist/cdn/menu/snice-menu.js +1 -1
  139. package/dist/cdn/menu/snice-menu.min.js +1 -1
  140. package/dist/cdn/modal/snice-modal.js +1 -1
  141. package/dist/cdn/modal/snice-modal.min.js +1 -1
  142. package/dist/cdn/music-player/snice-music-player.js +1 -1
  143. package/dist/cdn/music-player/snice-music-player.min.js +1 -1
  144. package/dist/cdn/nav/snice-nav.js +1 -1
  145. package/dist/cdn/nav/snice-nav.min.js +1 -1
  146. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  147. package/dist/cdn/network-graph/snice-network-graph.min.js +1 -1
  148. package/dist/cdn/notification-center/snice-notification-center.js +1 -1
  149. package/dist/cdn/notification-center/snice-notification-center.min.js +1 -1
  150. package/dist/cdn/org-chart/snice-org-chart.js +1 -1
  151. package/dist/cdn/org-chart/snice-org-chart.min.js +1 -1
  152. package/dist/cdn/pagination/snice-pagination.js +1 -1
  153. package/dist/cdn/pagination/snice-pagination.min.js +1 -1
  154. package/dist/cdn/paint/snice-paint.js +1 -1
  155. package/dist/cdn/paint/snice-paint.min.js +1 -1
  156. package/dist/cdn/pdf-viewer/README.md +2 -2
  157. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +72 -78
  158. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js.map +1 -1
  159. package/dist/cdn/pdf-viewer/snice-pdf-viewer.min.js +3 -3
  160. package/dist/cdn/pdf-viewer/snice-pdf-viewer.min.js.map +1 -1
  161. package/dist/cdn/podcast-player/README.md +1 -1
  162. package/dist/cdn/podcast-player/snice-podcast-player.js +2 -2
  163. package/dist/cdn/podcast-player/snice-podcast-player.js.map +1 -1
  164. package/dist/cdn/podcast-player/snice-podcast-player.min.js +2 -2
  165. package/dist/cdn/podcast-player/snice-podcast-player.min.js.map +1 -1
  166. package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
  167. package/dist/cdn/pricing-table/snice-pricing-table.min.js +1 -1
  168. package/dist/cdn/progress/snice-progress.js +1 -1
  169. package/dist/cdn/progress/snice-progress.min.js +1 -1
  170. package/dist/cdn/qr-code/snice-qr-code.js +1 -1
  171. package/dist/cdn/qr-code/snice-qr-code.min.js +1 -1
  172. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  173. package/dist/cdn/qr-reader/snice-qr-reader.min.js +1 -1
  174. package/dist/cdn/radio/snice-radio.js +1 -1
  175. package/dist/cdn/radio/snice-radio.min.js +1 -1
  176. package/dist/cdn/rating/snice-rating.js +1 -1
  177. package/dist/cdn/rating/snice-rating.min.js +1 -1
  178. package/dist/cdn/recipe/snice-recipe.js +1 -1
  179. package/dist/cdn/recipe/snice-recipe.min.js +1 -1
  180. package/dist/cdn/runtime/README.md +1 -1
  181. package/dist/cdn/runtime/snice-runtime.esm.js +10 -3
  182. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  183. package/dist/cdn/runtime/snice-runtime.esm.min.js +4 -4
  184. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  185. package/dist/cdn/runtime/snice-runtime.js +10 -3
  186. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  187. package/dist/cdn/runtime/snice-runtime.min.js +4 -4
  188. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  189. package/dist/cdn/sankey/snice-sankey.js +1 -1
  190. package/dist/cdn/sankey/snice-sankey.min.js +1 -1
  191. package/dist/cdn/select/snice-select.js +1 -1
  192. package/dist/cdn/select/snice-select.min.js +1 -1
  193. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  194. package/dist/cdn/skeleton/snice-skeleton.min.js +1 -1
  195. package/dist/cdn/slider/snice-slider.js +1 -1
  196. package/dist/cdn/slider/snice-slider.min.js +1 -1
  197. package/dist/cdn/sortable/snice-sortable.js +1 -1
  198. package/dist/cdn/sortable/snice-sortable.min.js +1 -1
  199. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  200. package/dist/cdn/sparkline/snice-sparkline.min.js +1 -1
  201. package/dist/cdn/spinner/snice-spinner.js +1 -1
  202. package/dist/cdn/spinner/snice-spinner.min.js +1 -1
  203. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  204. package/dist/cdn/split-pane/snice-split-pane.min.js +1 -1
  205. package/dist/cdn/spotlight/snice-spotlight.js +1 -1
  206. package/dist/cdn/spotlight/snice-spotlight.min.js +1 -1
  207. package/dist/cdn/spreadsheet/snice-spreadsheet.js +1 -1
  208. package/dist/cdn/spreadsheet/snice-spreadsheet.min.js +1 -1
  209. package/dist/cdn/stepper/snice-stepper.js +1 -1
  210. package/dist/cdn/stepper/snice-stepper.min.js +1 -1
  211. package/dist/cdn/switch/snice-switch.js +1 -1
  212. package/dist/cdn/switch/snice-switch.min.js +1 -1
  213. package/dist/cdn/table/snice-table.js +1 -1
  214. package/dist/cdn/table/snice-table.min.js +1 -1
  215. package/dist/cdn/tabs/snice-tabs.js +1 -1
  216. package/dist/cdn/tabs/snice-tabs.min.js +1 -1
  217. package/dist/cdn/tag-input/snice-tag-input.js +1 -1
  218. package/dist/cdn/tag-input/snice-tag-input.min.js +1 -1
  219. package/dist/cdn/terminal/snice-terminal.js +1 -1
  220. package/dist/cdn/terminal/snice-terminal.min.js +1 -1
  221. package/dist/cdn/testimonial/snice-testimonial.js +1 -1
  222. package/dist/cdn/testimonial/snice-testimonial.min.js +1 -1
  223. package/dist/cdn/textarea/snice-textarea.js +1 -1
  224. package/dist/cdn/textarea/snice-textarea.min.js +1 -1
  225. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  226. package/dist/cdn/time-range-picker/snice-time-range-picker.min.js +1 -1
  227. package/dist/cdn/timeline/snice-timeline.js +1 -1
  228. package/dist/cdn/timeline/snice-timeline.min.js +1 -1
  229. package/dist/cdn/timer/snice-timer.js +1 -1
  230. package/dist/cdn/timer/snice-timer.min.js +1 -1
  231. package/dist/cdn/toast/snice-toast.js +1 -1
  232. package/dist/cdn/toast/snice-toast.min.js +1 -1
  233. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  234. package/dist/cdn/tooltip/snice-tooltip.min.js +1 -1
  235. package/dist/cdn/tree/snice-tree.js +1 -1
  236. package/dist/cdn/tree/snice-tree.min.js +1 -1
  237. package/dist/cdn/treemap/snice-treemap.js +1 -1
  238. package/dist/cdn/treemap/snice-treemap.min.js +1 -1
  239. package/dist/cdn/video-player/snice-video-player.js +1 -1
  240. package/dist/cdn/video-player/snice-video-player.min.js +1 -1
  241. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  242. package/dist/cdn/virtual-scroller/snice-virtual-scroller.min.js +1 -1
  243. package/dist/cdn/waterfall/snice-waterfall.js +1 -1
  244. package/dist/cdn/waterfall/snice-waterfall.min.js +1 -1
  245. package/dist/cdn/weather/snice-weather.js +1 -1
  246. package/dist/cdn/weather/snice-weather.min.js +1 -1
  247. package/dist/components/carousel/snice-carousel.js +8 -2
  248. package/dist/components/carousel/snice-carousel.js.map +1 -1
  249. package/dist/components/code-block/grammars/html.json +48 -0
  250. package/dist/components/markdown/snice-markdown.js +1 -1
  251. package/dist/components/markdown/snice-markdown.js.map +1 -1
  252. package/dist/components/pdf-viewer/snice-pdf-viewer.d.ts +9 -8
  253. package/dist/components/pdf-viewer/snice-pdf-viewer.js +71 -77
  254. package/dist/components/pdf-viewer/snice-pdf-viewer.js.map +1 -1
  255. package/dist/components/podcast-player/snice-podcast-player.js +1 -1
  256. package/dist/components/podcast-player/snice-podcast-player.js.map +1 -1
  257. package/dist/index.cjs +8 -1
  258. package/dist/index.cjs.map +1 -1
  259. package/dist/index.esm.js +8 -1
  260. package/dist/index.esm.js.map +1 -1
  261. package/dist/index.iife.js +8 -1
  262. package/dist/index.iife.js.map +1 -1
  263. package/dist/symbols.cjs +1 -1
  264. package/dist/symbols.esm.js +1 -1
  265. package/dist/transitions.cjs +1 -1
  266. package/dist/transitions.esm.js +1 -1
  267. package/docs/ai/patterns.md +1 -1
  268. package/docs/routing.md +2 -2
  269. package/package.json +4 -2
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * snice v4.9.0
2
+ * snice v4.11.0
3
3
  * Imperative TypeScript framework for building vanilla web components with decorators, differential rendering, routing, and controllers. No virtual DOM, no build complexity.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
6
6
  */
7
7
  var Snice=function(t){"use strict";
8
8
  /*!
9
- * snice v4.9.0
9
+ * snice v4.11.0
10
10
  * Imperative TypeScript framework for building vanilla web components with decorators, differential rendering, routing, and controllers. No virtual DOM, no build complexity.
11
11
  * (c) 2024
12
12
  * Released under the MIT License.
@@ -19,10 +19,10 @@ var Snice=function(t){"use strict";
19
19
  */
20
20
  class ae{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:l}=this.parseIdentifier(t,n+1);e.push({type:"splat",name:a}),n=l;break;default:const{value:c,endIndex:u}=this.parseLiteral(t,n);c&&e.push({type:"literal",value:c}),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),l=this.matchSegment(t,r,o,a);if(!1===l){i=!1;break}Object.assign(s,l.params),r=l.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 le(t){const e={};return t.split(";").forEach(t=>{const[n,o]=t.split(":").map(t=>t.trim());n&&o&&(e[n]=o)}),e}var ce;!function(t){t.SUCCESS="success",t.GUARDS_FAILED="guards-failed",t.NOT_FOUND="not-found"}(ce||(ce={}));let ue=!1;async function he(t,e=500){if(customElements.get(t))return;let n=null;ue||(n=setTimeout(()=>{console.warn(`Custom element <${t}> is taking longer than ${e}ms to register. This may indicate a missing import or circular dependency. Set DISABLE_ELEMENT_READY_WARNINGS=true to disable this warning.`)},e));try{await customElements.whenDefined(t)}finally{n&&clearTimeout(n)}}async function de(t,e=500){const n=t.tagName.toLowerCase();await he(n,e),"ready"in t&&"function"==typeof t.ready?.then&&await t.ready}const me=n("debounce-timers"),fe=n("throttle-timers"),pe=n("once-called"),ye=n("memoize-cache");
21
21
  /*!
22
- * snice v4.9.0
22
+ * snice v4.11.0
23
23
  * Imperative TypeScript framework for building vanilla web components with decorators, differential rendering, routing, and controllers. No virtual DOM, no build complexity.
24
24
  * (c) 2024
25
25
  * Released under the MIT License.
26
26
  */
27
- globalThis.snice||(globalThis.snice={controllerRegistry:new Map,controllerIdCounter:0,symbols:new Map});const ge=globalThis.snice;function be(t){return ge.symbols.has(t)||ge.symbols.set(t,Symbol.for(`snice:${t}`)),ge.symbols.get(t)}return be("is-controller-class"),be("is-controller-instance"),be("is-element-class"),be("channel-handlers"),be("ready-promise"),be("ready-resolve"),be("rendered-promise"),be("rendered-resolve"),be("controller"),be("initialized"),be("on-handlers"),be("controller-key"),be("controller-name"),be("controller-id"),be("controller-operations"),be("native-controller"),be("cleanup"),be("properties"),be("property-values"),be("pre-init-property-values"),be("properties-initialized"),be("property-watchers"),be("explicitly-set-properties"),be("router-context"),be("current-page-marker"),be("context-request-handler"),be("page-transition"),be("created-at"),be("ready-handlers"),be("dispose-handlers"),be("moved-handlers"),be("adopted-handlers"),be("observers"),be("parts"),be("part-timers"),be("moved-timers"),be("adopted-timers"),be("dispatch-timers"),be("render-method"),be("render-options"),be("render-instance"),be("render-scheduled"),be("render-timers"),be("render-callbacks"),be("styles-method"),be("styles-applied"),be("context-handler"),be("context-method-name"),be("navigation-context-instance"),be("registered-elements"),be("is-updating"),be("context-register"),be("context-unregister"),be("context-notify-element"),be("context-options"),be("context-timer"),be("context-called"),be("context-update"),t.Context=Zt,t.ContextAwareFetcher=class{constructor(){this.requestMiddlewares=[],this.responseMiddlewares=[]}use(t,e){"request"===t?this.requestMiddlewares.push(e):this.responseMiddlewares.push(e)}create(t){const e=this.requestMiddlewares,n=this.responseMiddlewares;return async function(t,o){const r=new Request(t,o);let s=0;const i=async()=>{if(s<e.length){return e[s++].call(this,r,i)}const t=await fetch(r);let o=0;const a=async()=>{if(o<n.length){return n[o++].call(this,t,a)}return t};return a()};return i()}.bind(t)}},t.IS_CONTROLLER_INSTANCE=r,t.Router=function(t){const e=[];let n,o,r,s=!1,i=[],a=null,l=null;const c=t.context||{},u=new Zt(c,[],"",{},t.fetcher);function h(t){if(!a||!l)return null;const e=t.querySelectorAll(a);for(const t of e){if(t[A]===l)return t}return null}function d(t,i,a,l,c,u){e.push({route:new ae(t),tag:i,transition:a,guards:l,layout:c,placard:u}),s=!1,"/404"===t&&(n=i),"/403"===t&&(o=i),"/"===t&&(r=i)}function m(){i=e.filter(t=>t.placard).map(t=>{const e=t.placard;return"function"==typeof e?e(c):e})}function f(t,e,n){u[X](c,i,e,n)}function p(){switch(t.type){case"hash":return window.location.hash.slice(1);case"pushstate":return window.location.pathname}}function y(t){let e;const n=!!o;if(n&&(e=document.createElement(o),e[N]=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),a=null,l=null}function b(t,e,n){if(!!!t)return!0;const o=Array.isArray(t)?t:[t];for(const t of o){if(!t(c,e))return y(n),!1}return!0}function w(e){if(!1===e)return null;if(!!e)return e;return!!t.layout?t.layout:null}function v(t){if(!(t!==a))return{element:null,needsNewLayout:!1};a=t;if(!!t){const e=Date.now();l=e;const n=document.createElement(t);return n[N]=c,n[A]=e,{element:n,needsNewLayout:!0}}return l=null,{element:null,needsNewLayout:!0}}async function T(t,e,n,o,r,s,a){const l=o||h(t);if(!l)return;!function(t,e,n){"function"==typeof t.update&&t.update(c,i,e,n)}(l,s,a);const u=l.querySelector('[slot="page"]');if(!(!n||!u))return e.setAttribute("slot","page"),await x(l,u,e,n),void(r&&(t.innerHTML="",t.appendChild(l)));l.querySelectorAll('[slot="page"]').forEach(t=>t.remove()),e.setAttribute("slot","page"),l.appendChild(e),r&&(t.innerHTML="",t.appendChild(l))}async function S(t,e,n){const o=t.children[0];!n||!o?(t.innerHTML="",t.appendChild(e)):await x(t,o,e,n)}async function _(o){const s=document.querySelector(t.target);if(!s)throw new Error(`Target element not found: ${t.target}`);m(),window.scrollTo(0,0);if((""===o?.trim()||"/"===o)&&!!r){const n=e.find(t=>t.route.match("/"));if(!b(n?.guards,{},s))return;const{element:i,transition:a,layout:l}=function(){const t=document.createElement(r);t[N]=c;const n=customElements.get(r),o=n?.[E],s=e.find(t=>t.route.match("/"));return{element:t,transition:o,layout:s?.layout}}(),u=w(l),{element:d,needsNewLayout:m}=v(u),p=a||t.transition;return null!==d||null!==h(s)?(await T(s,i,p,d,m,o,{}),void f(0,o,{})):(await S(s,i,p),void f(0,o,{}))}if(!o)return;const i=function(t,n){for(const o of e){const e=o.route.match(t);if(!1===e)continue;if(!b(o.guards,e,n))return{result:ce.GUARDS_FAILED};const r=document.createElement(o.tag);r[N]=c,r[j]=u;const s=e;return Object.keys(s).forEach(t=>r.setAttribute(t,s[t])),{result:ce.SUCCESS,element:r,transition:o.transition,layout:o.layout,routeParams:s}}return{result:ce.NOT_FOUND}}(o,s);if(i.result===ce.GUARDS_FAILED)return;if(i.result===ce.SUCCESS){const{element:e,transition:n,layout:r,routeParams:a={}}=i,l=w(r),{element:c,needsNewLayout:u}=v(l),d=n||t.transition;return null!==c||null!==h(s)?(await T(s,e,d,c,u,o,a),void f(0,o,a)):(await S(s,e,d),void f(0,o,a))}const{element:a,transition:l,layout:d}=function(){if(n){const t=document.createElement(n);t[N]=c;const e=customElements.get(n),o=e?.[E];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}}(),p=w(d),{element:y,needsNewLayout:g}=v(p),A=l||t.transition;if(null!==y||null!==h(s))return await T(s,a,A,y,g,o,{}),void f(0,o,{});await S(s,a,A),f(0,o,{})}async function x(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?le(o.out):{opacity:"0"},l={opacity:"0"},c=o.in?le(o.in):{opacity:"1"},u=t.style,h=u.position,d=t.tagName.includes("-")&&t.shadowRoot;d||(u.position="relative");const m=e.hasAttribute("slot")||n.hasAttribute("slot");m?(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,l),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,c),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,c),await new Promise(t=>setTimeout(t,s))),e.remove(),m?(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({...l,...c}).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[g]){e[g]||(e[g]=new Map);for(const[t,o]of n.metadata[g])e[g].set(t,o)}ie(e),e[E]=t.transition;const o=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){this[j]=u,o?.call(this)};const r=e.prototype.disconnectedCallback;return e.prototype.disconnectedCallback=function(){r?.call(this),delete this[N],delete this[j]},customElements.get(t.tag)?console.warn(`[snice] Page "${t.tag}" is already registered. Skipping duplicate registration.`):customElements.define(t.tag,e),t.routes.forEach(e=>d(e,t.tag,t.transition,t.guards,t.layout,t.placard)),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),m(),function(){const e="hash"===t.type,n="pushstate"===t.type;e&&window.addEventListener("hashchange",()=>{document.querySelector(t.target)&&_(p())}),n&&window.addEventListener("popstate",()=>{document.querySelector(t.target)&&_(p())})}(),_(p())},navigate:_,register:d}},t.SimpleArray=Gt,t.adopted=function(t={}){return function(e,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;n[O]||(n[O]=[]),n[O].push({methodName:o,method:e,options:t})}),function(...n){this[$]||(this[$]=new Map),this[$].has(o)||this[$].set(o,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[$].get(o),s=(...t)=>e.apply(this,t),i=void 0!==t.debounce&&t.debounce>0,a=void 0!==t.throttle&&t.throttle>0;switch(!0){case i:return clearTimeout(r.debounceTimer),void(r.debounceTimer=setTimeout(()=>s(...n),t.debounce));case a:{const e=t.throttle,o=Date.now();if(0===r.lastThrottleCall||o-r.lastThrottleCall>=e)return r.lastThrottleCall=o,s(...n);if(!!!r.throttleTimer){const t=e-(o-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),s(...n)},t)}return}default:return s(...n)}}}},t.applyElementFunctionality=ie,t.clearDebounceTimers=function(t){if(t[me]){for(const e in t[me])t[me][e]?.timeout&&clearTimeout(t[me][e].timeout);t[me]={}}},t.clearMemoizeCache=function(t,e){t[ye]&&(e?delete t[ye][e]:t[ye]={})},t.clearThrottleTimers=function(t){if(t[fe]){for(const e in t[fe])t[fe][e]?.timeout&&clearTimeout(t[fe][e].timeout);t[fe]={}}},t.context=function(t={}){return function(e,n){const o=n.name,r=`__context_init_${o}`;return n.addInitializer(function(){const n=this.constructor;n[r]||(n[r]=!0,n[Ht]||(n[Ht]=[]),n[Ht].push({methodName:o,method:e,options:t}))}),e}},t.contextProperty=function(){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[N])return this[N];const t={target:this},e=new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t});let n=!0===this[r]&&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[N]=t.context,t.context):void 0}},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,n,t)}return t}}},t.controller=function(t){return function(e,n){const r=globalThis.snice?.controllerRegistry;if(!r)throw new Error("Snice global registry not initialized");return r.set(t,e),e.prototype[o]=!0,e}},t.css=function(t,...e){let n=t[0];for(let o=0;o<e.length;o++)n+=String(e[o])+t[o+1];const o={_$litType$:ut,cssText:n};if("undefined"!=typeof CSSStyleSheet&&"adoptedStyleSheets"in Document.prototype)try{const t=new CSSStyleSheet;t.replaceSync(n),o.styleSheet=t}catch(t){}return o},t.debounce=function(t=300,e={}){const{leading:n=!1,trailing:o=!0,maxWait:r}=e;return function(e,s){const i=s.name;return function(...s){this[me]||(this[me]={});const a=this[me],l=i;a[l]&&clearTimeout(a[l].timeout);const c=Date.now(),u=!a[l],h=u?c:a[l].startTime,d=void 0!==r&&c-h>=r;if(n&&u){const t=e.apply(this,s);return a[l]={timeout:null,startTime:h,lastArgs:s},t}const m=setTimeout(()=>{(o||d)&&e.apply(this,a[l].lastArgs),delete a[l]},d?0:t);a[l]={timeout:m,startTime:h,lastArgs:s}}}},t.dispatch=function(t,e){return function(n,o){return function(...r){this[M]||(this[M]=new Map);const s=`${t}_${o.name}`;this[M].has(s)||this[M].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[M].get(s),a=n.apply(this,r),l=n=>{if(void 0===n&&!1===e?.dispatchOnUndefined)return;const o=new CustomEvent(t,{bubbles:!0,composed:!0,...e,detail:n});this.dispatchEvent(o)},c=t=>{if(e?.debounce)clearTimeout(i.debounceTimeout),i.debounceTimeout=setTimeout(()=>l(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,l(t)):i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null,l(t)},o))}else l(t)};return a instanceof Promise?a.then(t=>(c(t),t)):(c(a),a)}}},t.dispose=function(){return function(t,e){const n=e.name,o=`__dispose_init_${n}`;e.addInitializer(function(){const e=this.constructor;e[o]||(e[o]=!0,e[x]||(e[x]=[]),e[x].push({methodName:n,method:t}))})}},t.element=function(t,e){return function(n,o){if(o.metadata&&o.metadata[g]){n[g]||(n[g]=new Map);for(const[t,e]of o.metadata[g])n[g].set(t,e)}return!0===e?.formAssociated&&(n.formAssociated=!0),ie(n),customElements.get(t)?(console.warn(`[snice] Element "${t}" is already registered. Skipping duplicate registration.`),n):(customElements.define(t,n),n)}},t.getSymbol=n,t.html=function(t,...e){return{_$litType$:ct,strings:t,values:e}},t.layout=function(t){return function(e,n){if(n.metadata&&n.metadata[g]){e[g]||(e[g]=new Map);for(const[t,o]of n.metadata[g])e[g].set(t,o)}return ie(e),customElements.get(t)?(console.warn(`[snice] Layout "${t}" is already registered. Skipping duplicate registration.`),e):(customElements.define(t,e),e)}},t.memoize=function(t={}){const{keyGenerator:e=(...t)=>JSON.stringify(t),maxSize:n=100,ttl:o}=t;return function(t,r){const s=r.name;return function(...r){this[ye]||(this[ye]={}),this[ye][s]||(this[ye][s]=new Map);const i=this[ye][s],a=e(...r);if(i.has(a)){const t=i.get(a);if(void 0===o)return t.value;if(!(Date.now()-t.timestamp>o))return t.value;i.delete(a)}const l=t.apply(this,r);if(i.set(a,{value:l,timestamp:Date.now()}),i.size>n){const t=i.keys().next().value;i.delete(t)}return l}}},t.moved=function(t={}){return function(e,n){const o=n.name,r=`__moved_init_${o}`;return n.addInitializer(function(){const n=this.constructor;n[r]||(n[r]=!0,n[C]||(n[C]=[]),n[C].push({methodName:o,method:e,options:t}))}),function(...n){this[L]||(this[L]=new Map),this[L].has(o)||this[L].set(o,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[L].get(o),s=(...t)=>e.apply(this,t),i=void 0!==t.debounce&&t.debounce>0,a=void 0!==t.throttle&&t.throttle>0;switch(!0){case i:return clearTimeout(r.debounceTimer),void(r.debounceTimer=setTimeout(()=>s(...n),t.debounce));case a:{const e=t.throttle,o=Date.now();if(0===r.lastThrottleCall||o-r.lastThrottleCall>=e)return r.lastThrottleCall=o,s(...n);if(!!!r.throttleTimer){const t=e-(o-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),s(...n)},t)}return}default:return s(...n)}}}},t.noChange=vt,t.nothing=dt,t.observe=function(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,i=`__observe_init_${s}`;n.addInitializer(function(){const n=this.constructor;if(n[i])return;n[i]=!0,n[k]||(n[k]=[]);const a=Array.isArray(t)?t:[t];for(const t of a){const[i,...a]=t.split(":"),l=a.join(":");n[k].push({type:i,target:l,selector:o,methodName:s,method:e,options:r})}})}},t.on=function(t,e,n){let o=null,r={};return"string"==typeof e?(o=e,r=n||{}):null===e&&n?r=n:e&&"object"==typeof e&&(r=e),function(e,n){const s=n.name,i=`__on_init_${s}_${o||""}_${JSON.stringify(t)}`;return n.addInitializer(function(){const n=this.constructor;if(n[i])return;n[i]=!0,n[It]||(n[It]=[]);const a=Array.isArray(t)?t:[t];for(const t of a)n[It].push({eventName:t,selector:o,methodName:s,method:e,options:r})}),e}},t.once=function(t=!0){let e,n=!1;return function(o,r){const s=r.name;return function(...r){return t?(this[pe]||(this[pe]={}),this[pe][s]||(this[pe][s]={called:!0,result:o.apply(this,r)}),this[pe][s].result):(n||(n=!0,e=o.apply(this,r)),e)}}},t.property=function(t){return function(e,n){const o=n.name;return n.metadata||(n.metadata={}),n.metadata[g]||(n.metadata[g]=new Map),n.metadata[g].set(o,t||{}),function(e){const n=this.constructor;n[g]||(n[g]=new Map);const r={...t};if(r.type||void 0===e||(r.type=te(e)),n[g].set(o,r),!Object.hasOwnProperty.call(this.constructor.prototype,o)){const t={get(){const t="string"==typeof r?.attribute?r?.attribute:o.toLowerCase(),n=this.getAttribute?.(t);if(null!==n)return ee(n,r||{},void 0,e);return((r?.type||te(e))!==Boolean||!this[S]?.has(o))&&(this[w]?.has(o)?this[w].get(o):e)},set(t){const n=this[o];if(n===t)return;if(!this[v])return this[w]||(this[w]=new Map),void this[w].set(o,t);const s="string"==typeof r.attribute?r.attribute:o.toLowerCase(),i=function(t,e,n){if(null==t||!1===t||e?.type===Gt&&Array.isArray(t)&&0===t.length)return null;if(e.converter?.toAttribute)return e.converter.toAttribute(t,e.type);switch(e.type||te(n)){case Boolean:return"true";case Date:return t instanceof Date?t.toISOString():String(t);case BigInt:return"bigint"==typeof t?t.toString()+"n":String(t);case Gt:return Array.isArray(t)?Gt.serialize(t):String(t);case Array:return Array.isArray(t)?JSON.stringify(t):String(t);case Object:return"object"==typeof t&&null!==t?JSON.stringify(t):String(t);default:return String(t)}}(t,r,e);this[S]||(this[S]=new Set),this[S].add(o),this._settingFromProperty||(this._settingFromProperty=new Set),this._settingFromProperty.add(s.toLowerCase()),null===i?this.removeAttribute?.(s):this.setAttribute?.(s,i),setTimeout(()=>{this._settingFromProperty?.delete(s.toLowerCase())},0);const a=this.constructor[T];if(a){if(a.has(o)){const e=a.get(o);for(const r of e)try{r.method.call(this,n,t,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(a.has("*")){const e=a.get("*");for(const r of e)try{r.method.call(this,n,t,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}this[P]&&this[u]&&re(this)},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,o,t)}return this[b]||(this[b]={}),this[b][o]=e,e}}},t.query=function(t,e={}){return function(n,o){const{light:s=!1,shadow:i=!0}=e,a=o.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[r]&&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}}},t.queryAll=function(t,e={}){return function(n,o){const{light:s=!1,shadow:i=!0}=e,a=o.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[r]&&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}}},t.ready=function(){return function(t,e){const n=e.name,o=`__ready_init_${n}`;e.addInitializer(function(){const e=this.constructor;e[o]||(e[o]=!0,e[_]||(e[_]=[]),e[_].push({methodName:n,method:t}))})}},t.render=function(t={}){return function(e,n){return n.name,n.addInitializer(function(){this[P]=e,this[R]=t}),function(...t){const n=e.apply(this,t);return oe(this,{},n),n}}},t.request=function(t,e){return function(n,o){let s,i,a=0;return async function(...o){const l=async()=>{const s=e?.timeout??12e4,i=e?.discoveryTimeout??50,a=n.apply(this,o),{value:l,done:c}=await a.next();if(c)return l;let u,h;const d=new Promise((t,e)=>{u=t,h=e});let m,f,p;const y=new Promise((e,n)=>{m=e,f=n,p=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:l,discovery:{resolve:()=>{clearTimeout(p),m()},reject:f},data:{resolve:u,reject:h}}});(!0===this[r]&&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 l();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,l()):i?Promise.resolve():new Promise((t,e)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const e=await l();t(e)}catch(t){e(t)}},n)})}return l()}}},t.resetOnce=function(t,e){t[pe]&&(e?delete t[pe][e]:t[pe]={})},t.respond=function(t,e){return function(n,o){const r=o.name,s=`__respond_init_${t}_${r}`;o.addInitializer(function(){const o=this.constructor;o[s]||(o[s]=!0,o[i]||(o[i]=[]),o[i].push({channelName:t,methodName:r,method:n,options:e}))})}},t.setDisableElementReadyWarnings=function(t){ue=t},t.styles=function(){return function(t,e){return e.addInitializer(function(){this[V]=t}),t}},t.throttle=function(t=300,e={}){const{leading:n=!0,trailing:o=!0}=e;return function(e,r){const s=r.name;return function(...r){this[fe]||(this[fe]={});const i=this[fe],a=s,l=Date.now();if(i[a]){const n=l-i[a].lastInvoke;if(i[a].lastArgs=r,i[a].timeout&&clearTimeout(i[a].timeout),n>=t)e.apply(this,r),i[a].lastInvoke=l;else if(o){const o=t-n;i[a].timeout=setTimeout(()=>{e.apply(this,i[a].lastArgs),i[a].lastInvoke=Date.now(),i[a].timeout=null},o)}}else n&&e.apply(this,r),i[a]={lastInvoke:l,timeout:null,lastArgs:r},o&&!n&&(i[a].timeout=setTimeout(()=>{e.apply(this,i[a].lastArgs),delete i[a]},t))}}},t.trackRenders=async function*(t){for(;;)await new Promise(e=>{t[q]||(t[q]=[]),t[q].push(e)}),yield},t.unsafeHTML=function(t){return{_$litType$:mt,html:t}},t.useNativeElementControllers=function(){if(globalThis.sniceNativeControllersInitialized)return;function t(t){if(!(t instanceof HTMLElement))return;if(t.tagName.includes("-"))return;if(t[s])return;const e=t.getAttribute("controller"),n=t[p];e&&e!==n?(t[p]=e,t.ready||(t.ready=Promise.resolve()),n&&Wt(t).catch(t=>{console.error("Failed to detach old controller from native element:",t)}),Bt(t,e).catch(t=>{console.error(`Failed to attach controller "${e}" to native element:`,t)})):!e&&n&&(delete t[p],delete t[d],Wt(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},t.waitForAllCustomElements=async function(t,e=500){const n=[];if(t instanceof Element&&(t.tagName.includes("-")&&n.push(t),t.shadowRoot)){t.shadowRoot.querySelectorAll("*").forEach(t=>{t.tagName.includes("-")&&n.push(t)})}if(t instanceof DocumentFragment){t.querySelectorAll("*").forEach(t=>{t.tagName.includes("-")&&n.push(t)})}await Promise.all(n.map(t=>de(t,e)))},t.waitForElementDefined=he,t.waitForElementReady=de,t.watch=function(...t){return function(e,n){const o=n.name,r=`__watch_init_${o}`;n.addInitializer(function(){const n=this.constructor;if(!n[r]){n[r]=!0,n[T]||(n[T]=new Map);for(const r of t)n[T].has(r)||n[T].set(r,[]),n[T].get(r).push({methodName:o,method:e})}})}},t}({});
27
+ globalThis.snice||(globalThis.snice={controllerRegistry:new Map,controllerIdCounter:0,symbols:new Map});const ge=globalThis.snice;function be(t){return ge.symbols.has(t)||ge.symbols.set(t,Symbol.for(`snice:${t}`)),ge.symbols.get(t)}return be("is-controller-class"),be("is-controller-instance"),be("is-element-class"),be("channel-handlers"),be("ready-promise"),be("ready-resolve"),be("rendered-promise"),be("rendered-resolve"),be("controller"),be("initialized"),be("on-handlers"),be("controller-key"),be("controller-name"),be("controller-id"),be("controller-operations"),be("native-controller"),be("cleanup"),be("properties"),be("property-values"),be("pre-init-property-values"),be("properties-initialized"),be("property-watchers"),be("explicitly-set-properties"),be("router-context"),be("current-page-marker"),be("context-request-handler"),be("page-transition"),be("created-at"),be("ready-handlers"),be("dispose-handlers"),be("moved-handlers"),be("adopted-handlers"),be("observers"),be("parts"),be("part-timers"),be("moved-timers"),be("adopted-timers"),be("dispatch-timers"),be("render-method"),be("render-options"),be("render-instance"),be("render-scheduled"),be("render-timers"),be("render-callbacks"),be("styles-method"),be("styles-applied"),be("context-handler"),be("context-method-name"),be("navigation-context-instance"),be("registered-elements"),be("is-updating"),be("context-register"),be("context-unregister"),be("context-notify-element"),be("context-options"),be("context-timer"),be("context-called"),be("context-update"),t.Context=Zt,t.ContextAwareFetcher=class{constructor(){this.requestMiddlewares=[],this.responseMiddlewares=[]}use(t,e){"request"===t?this.requestMiddlewares.push(e):this.responseMiddlewares.push(e)}create(t){const e=this.requestMiddlewares,n=this.responseMiddlewares;return async function(t,o){const r=new Request(t,o);let s=0;const i=async()=>{if(s<e.length){return e[s++].call(this,r,i)}const t=await fetch(r);let o=0;const a=async()=>{if(o<n.length){return n[o++].call(this,t,a)}return t};return a()};return i()}.bind(t)}},t.IS_CONTROLLER_INSTANCE=r,t.Router=function(t){const e=[];let n,o,r,s=!1,i=[],a=null,l=null;const c=t.context||{},u=new Zt(c,[],"",{},t.fetcher);function h(t){if(!a||!l)return null;const e=t.querySelectorAll(a);for(const t of e){if(t[A]===l)return t}return null}function d(t,i,a,l,c,u){e.push({route:new ae(t),tag:i,transition:a,guards:l,layout:c,placard:u}),s=!1,"/404"===t&&(n=i),"/403"===t&&(o=i),"/"===t&&(r=i)}function m(){const t=new Set;i=e.filter(t=>t.placard).map(t=>{const e=t.placard;return"function"==typeof e?e(c):e}).filter(e=>!t.has(e.name)&&(t.add(e.name),!0))}function f(t,e,n){u[X](c,i,e,n)}function p(){switch(t.type){case"hash":return window.location.hash.slice(1);case"pushstate":return window.location.pathname}}function y(t){let e;const n=!!o;if(n&&(e=document.createElement(o),e[N]=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),a=null,l=null}function b(t,e,n){if(!!!t)return!0;const o=Array.isArray(t)?t:[t];for(const t of o){if(!t(c,e))return y(n),!1}return!0}function w(e){if(!1===e)return null;if(!!e)return e;return!!t.layout?t.layout:null}function v(t){if(!(t!==a))return{element:null,needsNewLayout:!1};a=t;if(!!t){const e=Date.now();l=e;const n=document.createElement(t);return n[N]=c,n[A]=e,{element:n,needsNewLayout:!0}}return l=null,{element:null,needsNewLayout:!0}}async function T(t,e,n,o,r,s,a){const l=o||h(t);if(!l)return;!function(t,e,n){"function"==typeof t.update&&t.update(c,i,e,n)}(l,s,a);const u=l.querySelector('[slot="page"]');if(!(!n||!u))return e.setAttribute("slot","page"),await x(l,u,e,n),void(r&&(t.innerHTML="",t.appendChild(l)));l.querySelectorAll('[slot="page"]').forEach(t=>t.remove()),e.setAttribute("slot","page"),l.appendChild(e),r&&(t.innerHTML="",t.appendChild(l))}async function S(t,e,n){const o=t.children[0];!n||!o?(t.innerHTML="",t.appendChild(e)):await x(t,o,e,n)}async function _(o){const s=document.querySelector(t.target);if(!s)throw new Error(`Target element not found: ${t.target}`);m(),window.scrollTo(0,0);if((""===o?.trim()||"/"===o)&&!!r){const n=e.find(t=>t.route.match("/"));if(!b(n?.guards,{},s))return;const{element:i,transition:a,layout:l}=function(){const t=document.createElement(r);t[N]=c;const n=customElements.get(r),o=n?.[E],s=e.find(t=>t.route.match("/"));return{element:t,transition:o,layout:s?.layout}}(),u=w(l),{element:d,needsNewLayout:m}=v(u),p=a||t.transition;return null!==d||null!==h(s)?(await T(s,i,p,d,m,o,{}),void f(0,o,{})):(await S(s,i,p),void f(0,o,{}))}if(!o)return;const i=function(t,n){for(const o of e){const e=o.route.match(t);if(!1===e)continue;if(!b(o.guards,e,n))return{result:ce.GUARDS_FAILED};const r=document.createElement(o.tag);r[N]=c,r[j]=u;const s=e;return Object.keys(s).forEach(t=>r.setAttribute(t,s[t])),{result:ce.SUCCESS,element:r,transition:o.transition,layout:o.layout,routeParams:s}}return{result:ce.NOT_FOUND}}(o,s);if(i.result===ce.GUARDS_FAILED)return;if(i.result===ce.SUCCESS){const{element:e,transition:n,layout:r,routeParams:a={}}=i,l=w(r),{element:c,needsNewLayout:u}=v(l),d=n||t.transition;return null!==c||null!==h(s)?(await T(s,e,d,c,u,o,a),void f(0,o,a)):(await S(s,e,d),void f(0,o,a))}const{element:a,transition:l,layout:d}=function(){if(n){const t=document.createElement(n);t[N]=c;const e=customElements.get(n),o=e?.[E];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}}(),p=w(d),{element:y,needsNewLayout:g}=v(p),A=l||t.transition;if(null!==y||null!==h(s))return await T(s,a,A,y,g,o,{}),void f(0,o,{});await S(s,a,A),f(0,o,{})}async function x(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?le(o.out):{opacity:"0"},l={opacity:"0"},c=o.in?le(o.in):{opacity:"1"},u=t.style,h=u.position,d=t.tagName.includes("-")&&t.shadowRoot;d||(u.position="relative");const m=e.hasAttribute("slot")||n.hasAttribute("slot");m?(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,l),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,c),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,c),await new Promise(t=>setTimeout(t,s))),e.remove(),m?(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({...l,...c}).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[g]){e[g]||(e[g]=new Map);for(const[t,o]of n.metadata[g])e[g].set(t,o)}ie(e),e[E]=t.transition;const o=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){this[j]=u,o?.call(this)};const r=e.prototype.disconnectedCallback;return e.prototype.disconnectedCallback=function(){r?.call(this),delete this[N],delete this[j]},customElements.get(t.tag)?console.warn(`[snice] Page "${t.tag}" is already registered. Skipping duplicate registration.`):customElements.define(t.tag,e),t.routes.forEach(e=>d(e,t.tag,t.transition,t.guards,t.layout,t.placard)),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),m(),function(){const e="hash"===t.type,n="pushstate"===t.type;e&&window.addEventListener("hashchange",()=>{document.querySelector(t.target)&&_(p())}),n&&window.addEventListener("popstate",()=>{document.querySelector(t.target)&&_(p())})}(),_(p())},navigate:_,register:d}},t.SimpleArray=Gt,t.adopted=function(t={}){return function(e,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;n[O]||(n[O]=[]),n[O].push({methodName:o,method:e,options:t})}),function(...n){this[$]||(this[$]=new Map),this[$].has(o)||this[$].set(o,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[$].get(o),s=(...t)=>e.apply(this,t),i=void 0!==t.debounce&&t.debounce>0,a=void 0!==t.throttle&&t.throttle>0;switch(!0){case i:return clearTimeout(r.debounceTimer),void(r.debounceTimer=setTimeout(()=>s(...n),t.debounce));case a:{const e=t.throttle,o=Date.now();if(0===r.lastThrottleCall||o-r.lastThrottleCall>=e)return r.lastThrottleCall=o,s(...n);if(!!!r.throttleTimer){const t=e-(o-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),s(...n)},t)}return}default:return s(...n)}}}},t.applyElementFunctionality=ie,t.clearDebounceTimers=function(t){if(t[me]){for(const e in t[me])t[me][e]?.timeout&&clearTimeout(t[me][e].timeout);t[me]={}}},t.clearMemoizeCache=function(t,e){t[ye]&&(e?delete t[ye][e]:t[ye]={})},t.clearThrottleTimers=function(t){if(t[fe]){for(const e in t[fe])t[fe][e]?.timeout&&clearTimeout(t[fe][e].timeout);t[fe]={}}},t.context=function(t={}){return function(e,n){const o=n.name,r=`__context_init_${o}`;return n.addInitializer(function(){const n=this.constructor;n[r]||(n[r]=!0,n[Ht]||(n[Ht]=[]),n[Ht].push({methodName:o,method:e,options:t}))}),e}},t.contextProperty=function(){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[N])return this[N];const t={target:this},e=new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t});let n=!0===this[r]&&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[N]=t.context,t.context):void 0}},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,n,t)}return t}}},t.controller=function(t){return function(e,n){const r=globalThis.snice?.controllerRegistry;if(!r)throw new Error("Snice global registry not initialized");return r.set(t,e),e.prototype[o]=!0,e}},t.css=function(t,...e){let n=t[0];for(let o=0;o<e.length;o++)n+=String(e[o])+t[o+1];const o={_$litType$:ut,cssText:n};if("undefined"!=typeof CSSStyleSheet&&"adoptedStyleSheets"in Document.prototype)try{const t=new CSSStyleSheet;t.replaceSync(n),o.styleSheet=t}catch(t){}return o},t.debounce=function(t=300,e={}){const{leading:n=!1,trailing:o=!0,maxWait:r}=e;return function(e,s){const i=s.name;return function(...s){this[me]||(this[me]={});const a=this[me],l=i;a[l]&&clearTimeout(a[l].timeout);const c=Date.now(),u=!a[l],h=u?c:a[l].startTime,d=void 0!==r&&c-h>=r;if(n&&u){const t=e.apply(this,s);return a[l]={timeout:null,startTime:h,lastArgs:s},t}const m=setTimeout(()=>{(o||d)&&e.apply(this,a[l].lastArgs),delete a[l]},d?0:t);a[l]={timeout:m,startTime:h,lastArgs:s}}}},t.dispatch=function(t,e){return function(n,o){return function(...r){this[M]||(this[M]=new Map);const s=`${t}_${o.name}`;this[M].has(s)||this[M].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[M].get(s),a=n.apply(this,r),l=n=>{if(void 0===n&&!1===e?.dispatchOnUndefined)return;const o=new CustomEvent(t,{bubbles:!0,composed:!0,...e,detail:n});this.dispatchEvent(o)},c=t=>{if(e?.debounce)clearTimeout(i.debounceTimeout),i.debounceTimeout=setTimeout(()=>l(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,l(t)):i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null,l(t)},o))}else l(t)};return a instanceof Promise?a.then(t=>(c(t),t)):(c(a),a)}}},t.dispose=function(){return function(t,e){const n=e.name,o=`__dispose_init_${n}`;e.addInitializer(function(){const e=this.constructor;e[o]||(e[o]=!0,e[x]||(e[x]=[]),e[x].push({methodName:n,method:t}))})}},t.element=function(t,e){return function(n,o){if(o.metadata&&o.metadata[g]){n[g]||(n[g]=new Map);for(const[t,e]of o.metadata[g])n[g].set(t,e)}return!0===e?.formAssociated&&(n.formAssociated=!0),ie(n),customElements.get(t)?(console.warn(`[snice] Element "${t}" is already registered. Skipping duplicate registration.`),n):(customElements.define(t,n),n)}},t.getSymbol=n,t.html=function(t,...e){return{_$litType$:ct,strings:t,values:e}},t.layout=function(t){return function(e,n){if(n.metadata&&n.metadata[g]){e[g]||(e[g]=new Map);for(const[t,o]of n.metadata[g])e[g].set(t,o)}return ie(e),customElements.get(t)?(console.warn(`[snice] Layout "${t}" is already registered. Skipping duplicate registration.`),e):(customElements.define(t,e),e)}},t.memoize=function(t={}){const{keyGenerator:e=(...t)=>JSON.stringify(t),maxSize:n=100,ttl:o}=t;return function(t,r){const s=r.name;return function(...r){this[ye]||(this[ye]={}),this[ye][s]||(this[ye][s]=new Map);const i=this[ye][s],a=e(...r);if(i.has(a)){const t=i.get(a);if(void 0===o)return t.value;if(!(Date.now()-t.timestamp>o))return t.value;i.delete(a)}const l=t.apply(this,r);if(i.set(a,{value:l,timestamp:Date.now()}),i.size>n){const t=i.keys().next().value;i.delete(t)}return l}}},t.moved=function(t={}){return function(e,n){const o=n.name,r=`__moved_init_${o}`;return n.addInitializer(function(){const n=this.constructor;n[r]||(n[r]=!0,n[C]||(n[C]=[]),n[C].push({methodName:o,method:e,options:t}))}),function(...n){this[L]||(this[L]=new Map),this[L].has(o)||this[L].set(o,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[L].get(o),s=(...t)=>e.apply(this,t),i=void 0!==t.debounce&&t.debounce>0,a=void 0!==t.throttle&&t.throttle>0;switch(!0){case i:return clearTimeout(r.debounceTimer),void(r.debounceTimer=setTimeout(()=>s(...n),t.debounce));case a:{const e=t.throttle,o=Date.now();if(0===r.lastThrottleCall||o-r.lastThrottleCall>=e)return r.lastThrottleCall=o,s(...n);if(!!!r.throttleTimer){const t=e-(o-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),s(...n)},t)}return}default:return s(...n)}}}},t.noChange=vt,t.nothing=dt,t.observe=function(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,i=`__observe_init_${s}`;n.addInitializer(function(){const n=this.constructor;if(n[i])return;n[i]=!0,n[k]||(n[k]=[]);const a=Array.isArray(t)?t:[t];for(const t of a){const[i,...a]=t.split(":"),l=a.join(":");n[k].push({type:i,target:l,selector:o,methodName:s,method:e,options:r})}})}},t.on=function(t,e,n){let o=null,r={};return"string"==typeof e?(o=e,r=n||{}):null===e&&n?r=n:e&&"object"==typeof e&&(r=e),function(e,n){const s=n.name,i=`__on_init_${s}_${o||""}_${JSON.stringify(t)}`;return n.addInitializer(function(){const n=this.constructor;if(n[i])return;n[i]=!0,n[It]||(n[It]=[]);const a=Array.isArray(t)?t:[t];for(const t of a)n[It].push({eventName:t,selector:o,methodName:s,method:e,options:r})}),e}},t.once=function(t=!0){let e,n=!1;return function(o,r){const s=r.name;return function(...r){return t?(this[pe]||(this[pe]={}),this[pe][s]||(this[pe][s]={called:!0,result:o.apply(this,r)}),this[pe][s].result):(n||(n=!0,e=o.apply(this,r)),e)}}},t.property=function(t){return function(e,n){const o=n.name;return n.metadata||(n.metadata={}),n.metadata[g]||(n.metadata[g]=new Map),n.metadata[g].set(o,t||{}),function(e){const n=this.constructor;n[g]||(n[g]=new Map);const r={...t};if(r.type||void 0===e||(r.type=te(e)),n[g].set(o,r),!Object.hasOwnProperty.call(this.constructor.prototype,o)){const t={get(){const t="string"==typeof r?.attribute?r?.attribute:o.toLowerCase(),n=this.getAttribute?.(t);if(null!==n)return ee(n,r||{},void 0,e);return((r?.type||te(e))!==Boolean||!this[S]?.has(o))&&(this[w]?.has(o)?this[w].get(o):e)},set(t){const n=this[o];if(n===t)return;if(!this[v])return this[w]||(this[w]=new Map),void this[w].set(o,t);const s="string"==typeof r.attribute?r.attribute:o.toLowerCase(),i=function(t,e,n){if(null==t||!1===t||e?.type===Gt&&Array.isArray(t)&&0===t.length)return null;if(e.converter?.toAttribute)return e.converter.toAttribute(t,e.type);switch(e.type||te(n)){case Boolean:return"true";case Date:return t instanceof Date?t.toISOString():String(t);case BigInt:return"bigint"==typeof t?t.toString()+"n":String(t);case Gt:return Array.isArray(t)?Gt.serialize(t):String(t);case Array:return Array.isArray(t)?JSON.stringify(t):String(t);case Object:return"object"==typeof t&&null!==t?JSON.stringify(t):String(t);default:return String(t)}}(t,r,e);this[S]||(this[S]=new Set),this[S].add(o),this._settingFromProperty||(this._settingFromProperty=new Set),this._settingFromProperty.add(s.toLowerCase()),null===i?this.removeAttribute?.(s):this.setAttribute?.(s,i),setTimeout(()=>{this._settingFromProperty?.delete(s.toLowerCase())},0);const a=this.constructor[T];if(a){if(a.has(o)){const e=a.get(o);for(const r of e)try{r.method.call(this,n,t,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(a.has("*")){const e=a.get("*");for(const r of e)try{r.method.call(this,n,t,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}this[P]&&this[u]&&re(this)},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,o,t)}return this[b]||(this[b]={}),this[b][o]=e,e}}},t.query=function(t,e={}){return function(n,o){const{light:s=!1,shadow:i=!0}=e,a=o.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[r]&&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}}},t.queryAll=function(t,e={}){return function(n,o){const{light:s=!1,shadow:i=!0}=e,a=o.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[r]&&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}}},t.ready=function(){return function(t,e){const n=e.name,o=`__ready_init_${n}`;e.addInitializer(function(){const e=this.constructor;e[o]||(e[o]=!0,e[_]||(e[_]=[]),e[_].push({methodName:n,method:t}))})}},t.render=function(t={}){return function(e,n){return n.name,n.addInitializer(function(){this[P]=e,this[R]=t}),function(...t){const n=e.apply(this,t);return oe(this,{},n),n}}},t.request=function(t,e){return function(n,o){let s,i,a=0;return async function(...o){const l=async()=>{const s=e?.timeout??12e4,i=e?.discoveryTimeout??50,a=n.apply(this,o),{value:l,done:c}=await a.next();if(c)return l;let u,h;const d=new Promise((t,e)=>{u=t,h=e});let m,f,p;const y=new Promise((e,n)=>{m=e,f=n,p=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:l,discovery:{resolve:()=>{clearTimeout(p),m()},reject:f},data:{resolve:u,reject:h}}});(!0===this[r]&&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 l();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,l()):i?Promise.resolve():new Promise((t,e)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const e=await l();t(e)}catch(t){e(t)}},n)})}return l()}}},t.resetOnce=function(t,e){t[pe]&&(e?delete t[pe][e]:t[pe]={})},t.respond=function(t,e){return function(n,o){const r=o.name,s=`__respond_init_${t}_${r}`;o.addInitializer(function(){const o=this.constructor;o[s]||(o[s]=!0,o[i]||(o[i]=[]),o[i].push({channelName:t,methodName:r,method:n,options:e}))})}},t.setDisableElementReadyWarnings=function(t){ue=t},t.styles=function(){return function(t,e){return e.addInitializer(function(){this[V]=t}),t}},t.throttle=function(t=300,e={}){const{leading:n=!0,trailing:o=!0}=e;return function(e,r){const s=r.name;return function(...r){this[fe]||(this[fe]={});const i=this[fe],a=s,l=Date.now();if(i[a]){const n=l-i[a].lastInvoke;if(i[a].lastArgs=r,i[a].timeout&&clearTimeout(i[a].timeout),n>=t)e.apply(this,r),i[a].lastInvoke=l;else if(o){const o=t-n;i[a].timeout=setTimeout(()=>{e.apply(this,i[a].lastArgs),i[a].lastInvoke=Date.now(),i[a].timeout=null},o)}}else n&&e.apply(this,r),i[a]={lastInvoke:l,timeout:null,lastArgs:r},o&&!n&&(i[a].timeout=setTimeout(()=>{e.apply(this,i[a].lastArgs),delete i[a]},t))}}},t.trackRenders=async function*(t){for(;;)await new Promise(e=>{t[q]||(t[q]=[]),t[q].push(e)}),yield},t.unsafeHTML=function(t){return{_$litType$:mt,html:t}},t.useNativeElementControllers=function(){if(globalThis.sniceNativeControllersInitialized)return;function t(t){if(!(t instanceof HTMLElement))return;if(t.tagName.includes("-"))return;if(t[s])return;const e=t.getAttribute("controller"),n=t[p];e&&e!==n?(t[p]=e,t.ready||(t.ready=Promise.resolve()),n&&Wt(t).catch(t=>{console.error("Failed to detach old controller from native element:",t)}),Bt(t,e).catch(t=>{console.error(`Failed to attach controller "${e}" to native element:`,t)})):!e&&n&&(delete t[p],delete t[d],Wt(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},t.waitForAllCustomElements=async function(t,e=500){const n=[];if(t instanceof Element&&(t.tagName.includes("-")&&n.push(t),t.shadowRoot)){t.shadowRoot.querySelectorAll("*").forEach(t=>{t.tagName.includes("-")&&n.push(t)})}if(t instanceof DocumentFragment){t.querySelectorAll("*").forEach(t=>{t.tagName.includes("-")&&n.push(t)})}await Promise.all(n.map(t=>de(t,e)))},t.waitForElementDefined=he,t.waitForElementReady=de,t.watch=function(...t){return function(e,n){const o=n.name,r=`__watch_init_${o}`;n.addInitializer(function(){const n=this.constructor;if(!n[r]){n[r]=!0,n[T]||(n[T]=new Map);for(const r of t)n[T].has(r)||n[T].set(r,[]),n[T].get(r).push({methodName:o,method:e})}})}},t}({});
28
28
  //# sourceMappingURL=snice-runtime.min.js.map