snice 7.5.0 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/adapters/react/SniceProvider.js +1 -1
  2. package/adapters/react/SniceRouter.js +1 -1
  3. package/adapters/react/avatar.d.ts +1 -0
  4. package/adapters/react/avatar.d.ts.map +1 -1
  5. package/adapters/react/avatar.js +1 -1
  6. package/adapters/react/avatar.js.map +1 -1
  7. package/adapters/react/avatar.tsx +2 -1
  8. package/adapters/react/calendar.d.ts +4 -0
  9. package/adapters/react/calendar.d.ts.map +1 -1
  10. package/adapters/react/calendar.js +1 -1
  11. package/adapters/react/calendar.js.map +1 -1
  12. package/adapters/react/calendar.tsx +5 -1
  13. package/adapters/react/matchRoute.js +68 -2
  14. package/adapters/react/matchRoute.js.map +1 -1
  15. package/adapters/react/route-match.d.ts +7 -0
  16. package/adapters/react/useRequestHandler.js +1 -1
  17. package/bin/analyzer-contracts.js +60 -2
  18. package/bin/project-analyzer.js +1262 -118
  19. package/bin/snice.js +95 -5
  20. package/custom-elements.json +112 -0
  21. package/dist/cdn/accordion/snice-accordion.js +1 -1
  22. package/dist/cdn/action-bar/snice-action-bar.js +1 -1
  23. package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
  24. package/dist/cdn/alert/snice-alert.js +1 -1
  25. package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
  26. package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
  27. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  28. package/dist/cdn/availability/snice-availability.js +1 -1
  29. package/dist/cdn/avatar/README.md +1 -1
  30. package/dist/cdn/avatar/snice-avatar.js +9 -3
  31. package/dist/cdn/avatar/snice-avatar.js.map +1 -1
  32. package/dist/cdn/avatar/snice-avatar.min.js +2 -2
  33. package/dist/cdn/avatar/snice-avatar.min.js.map +1 -1
  34. package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
  35. package/dist/cdn/badge/snice-badge.js +1 -1
  36. package/dist/cdn/banner/snice-banner.js +1 -1
  37. package/dist/cdn/binpack/snice-binpack.js +1 -1
  38. package/dist/cdn/book/snice-book.js +1 -1
  39. package/dist/cdn/booking/snice-booking.js +1 -1
  40. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  41. package/dist/cdn/button/snice-button.js +2 -2
  42. package/dist/cdn/button/snice-button.js.map +1 -1
  43. package/dist/cdn/button/snice-button.min.js +1 -1
  44. package/dist/cdn/button/snice-button.min.js.map +1 -1
  45. package/dist/cdn/calendar/README.md +2 -2
  46. package/dist/cdn/calendar/snice-calendar.js +562 -40
  47. package/dist/cdn/calendar/snice-calendar.js.map +1 -1
  48. package/dist/cdn/calendar/snice-calendar.min.js +28 -1
  49. package/dist/cdn/calendar/snice-calendar.min.js.map +1 -1
  50. package/dist/cdn/camera/snice-camera.js +1 -1
  51. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  52. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  53. package/dist/cdn/card/snice-card.js +1 -1
  54. package/dist/cdn/carousel/snice-carousel.js +1 -1
  55. package/dist/cdn/cart/snice-cart.js +1 -1
  56. package/dist/cdn/chart/snice-chart.js +1 -1
  57. package/dist/cdn/chat/snice-chat.js +1 -1
  58. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  59. package/dist/cdn/chip/snice-chip.js +1 -1
  60. package/dist/cdn/code-block/snice-code-block.js +1 -1
  61. package/dist/cdn/color-display/snice-color-display.js +1 -1
  62. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  63. package/dist/cdn/command-palette/snice-command-palette.js +1 -1
  64. package/dist/cdn/comments/snice-comments.js +1 -1
  65. package/dist/cdn/countdown/snice-countdown.js +1 -1
  66. package/dist/cdn/cropper/snice-cropper.js +1 -1
  67. package/dist/cdn/data-card/snice-data-card.js +1 -1
  68. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  69. package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
  70. package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
  71. package/dist/cdn/diff/snice-diff.js +1 -1
  72. package/dist/cdn/divider/snice-divider.js +1 -1
  73. package/dist/cdn/doc/snice-doc.js +1 -1
  74. package/dist/cdn/draw/snice-draw.js +1 -1
  75. package/dist/cdn/drawer/snice-drawer.js +1 -1
  76. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  77. package/dist/cdn/estimate/snice-estimate.js +1 -1
  78. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  79. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  80. package/dist/cdn/flip-card/snice-flip-card.js +1 -1
  81. package/dist/cdn/flow/snice-flow.js +1 -1
  82. package/dist/cdn/form-layout/snice-form-layout.js +1 -1
  83. package/dist/cdn/funnel/snice-funnel.js +1 -1
  84. package/dist/cdn/gantt/snice-gantt.js +1 -1
  85. package/dist/cdn/gauge/snice-gauge.js +1 -1
  86. package/dist/cdn/grid/snice-grid.js +1 -1
  87. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  88. package/dist/cdn/image/snice-image.js +1 -1
  89. package/dist/cdn/input/snice-input.js +1 -1
  90. package/dist/cdn/invoice/snice-invoice.js +1 -1
  91. package/dist/cdn/kanban/snice-kanban.js +1 -1
  92. package/dist/cdn/key-value/snice-key-value.js +1 -1
  93. package/dist/cdn/kpi/snice-kpi.js +1 -1
  94. package/dist/cdn/layout/snice-layout.js +1 -1
  95. package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
  96. package/dist/cdn/link/snice-link.js +1 -1
  97. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  98. package/dist/cdn/list/snice-list.js +1 -1
  99. package/dist/cdn/location/snice-location.js +1 -1
  100. package/dist/cdn/login/README.md +1 -1
  101. package/dist/cdn/login/snice-login.js +2 -2
  102. package/dist/cdn/login/snice-login.js.map +1 -1
  103. package/dist/cdn/login/snice-login.min.js +1 -1
  104. package/dist/cdn/login/snice-login.min.js.map +1 -1
  105. package/dist/cdn/map/snice-map.js +1 -1
  106. package/dist/cdn/markdown/snice-markdown.js +1 -1
  107. package/dist/cdn/masonry/snice-masonry.js +1 -1
  108. package/dist/cdn/menu/snice-menu.js +1 -1
  109. package/dist/cdn/message-strip/snice-message-strip.js +1 -1
  110. package/dist/cdn/modal/snice-modal.js +1 -1
  111. package/dist/cdn/music-player/snice-music-player.js +1 -1
  112. package/dist/cdn/nav/snice-nav.js +1 -1
  113. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  114. package/dist/cdn/notification-center/snice-notification-center.js +1 -1
  115. package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
  116. package/dist/cdn/org-chart/snice-org-chart.js +1 -1
  117. package/dist/cdn/pagination/snice-pagination.js +1 -1
  118. package/dist/cdn/paint/snice-paint.js +1 -1
  119. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
  120. package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
  121. package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
  122. package/dist/cdn/popover/snice-popover.js +1 -1
  123. package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
  124. package/dist/cdn/product-card/snice-product-card.js +1 -1
  125. package/dist/cdn/progress/snice-progress.js +1 -1
  126. package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
  127. package/dist/cdn/qr-code/snice-qr-code.js +1 -1
  128. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  129. package/dist/cdn/radio/snice-radio.js +1 -1
  130. package/dist/cdn/range-slider/snice-range-slider.js +1 -1
  131. package/dist/cdn/rating/snice-rating.js +1 -1
  132. package/dist/cdn/receipt/snice-receipt.js +1 -1
  133. package/dist/cdn/recipe/snice-recipe.js +1 -1
  134. package/dist/cdn/runtime/README.md +2 -2
  135. package/dist/cdn/runtime/snice-runtime.esm.js +706 -267
  136. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  137. package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
  138. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  139. package/dist/cdn/runtime/snice-runtime.js +706 -267
  140. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  141. package/dist/cdn/runtime/snice-runtime.min.js +1 -1
  142. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  143. package/dist/cdn/sankey/snice-sankey.js +1 -1
  144. package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
  145. package/dist/cdn/select/snice-select.js +3 -1
  146. package/dist/cdn/select/snice-select.js.map +1 -1
  147. package/dist/cdn/select/snice-select.min.js +2 -2
  148. package/dist/cdn/select/snice-select.min.js.map +1 -1
  149. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  150. package/dist/cdn/slider/snice-slider.js +1 -1
  151. package/dist/cdn/sortable/snice-sortable.js +1 -1
  152. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  153. package/dist/cdn/spinner/snice-spinner.js +1 -1
  154. package/dist/cdn/split-button/snice-split-button.js +1 -1
  155. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  156. package/dist/cdn/spotlight/snice-spotlight.js +1 -1
  157. package/dist/cdn/stat-group/snice-stat-group.js +1 -1
  158. package/dist/cdn/step-input/snice-step-input.js +1 -1
  159. package/dist/cdn/stepper/snice-stepper.js +1 -1
  160. package/dist/cdn/switch/README.md +1 -1
  161. package/dist/cdn/switch/snice-switch.js +8 -4
  162. package/dist/cdn/switch/snice-switch.js.map +1 -1
  163. package/dist/cdn/switch/snice-switch.min.js +8 -4
  164. package/dist/cdn/switch/snice-switch.min.js.map +1 -1
  165. package/dist/cdn/table/README.md +2 -2
  166. package/dist/cdn/table/snice-table.esm.js +77 -5
  167. package/dist/cdn/table/snice-table.esm.js.map +1 -1
  168. package/dist/cdn/table/snice-table.esm.min.js +68 -47
  169. package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
  170. package/dist/cdn/table/snice-table.js +76 -4
  171. package/dist/cdn/table/snice-table.js.map +1 -1
  172. package/dist/cdn/table/snice-table.min.js +53 -32
  173. package/dist/cdn/table/snice-table.min.js.map +1 -1
  174. package/dist/cdn/tabs/snice-tabs.js +1 -1
  175. package/dist/cdn/tag/snice-tag.js +1 -1
  176. package/dist/cdn/tag-input/snice-tag-input.js +1 -1
  177. package/dist/cdn/terminal/snice-terminal.js +1 -1
  178. package/dist/cdn/testimonial/snice-testimonial.js +1 -1
  179. package/dist/cdn/textarea/snice-textarea.js +1 -1
  180. package/dist/cdn/time-picker/snice-time-picker.js +1 -1
  181. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  182. package/dist/cdn/timeline/snice-timeline.js +1 -1
  183. package/dist/cdn/timer/snice-timer.js +1 -1
  184. package/dist/cdn/toast/snice-toast.js +1 -1
  185. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  186. package/dist/cdn/tree/snice-tree.js +1 -1
  187. package/dist/cdn/treemap/snice-treemap.js +1 -1
  188. package/dist/cdn/user-card/snice-user-card.js +1 -1
  189. package/dist/cdn/video-player/snice-video-player.js +1 -1
  190. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  191. package/dist/cdn/waterfall/snice-waterfall.js +1 -1
  192. package/dist/cdn/weather/snice-weather.js +1 -1
  193. package/dist/cdn/work-order/snice-work-order.js +1 -1
  194. package/dist/components/avatar/snice-avatar.d.ts +1 -0
  195. package/dist/components/avatar/snice-avatar.js +8 -2
  196. package/dist/components/avatar/snice-avatar.js.map +1 -1
  197. package/dist/components/avatar/snice-avatar.types.d.ts +2 -0
  198. package/dist/components/button/snice-button.js +1 -1
  199. package/dist/components/button/snice-button.js.map +1 -1
  200. package/dist/components/calendar/snice-calendar.d.ts +38 -1
  201. package/dist/components/calendar/snice-calendar.js +390 -40
  202. package/dist/components/calendar/snice-calendar.js.map +1 -1
  203. package/dist/components/calendar/snice-calendar.types.d.ts +63 -0
  204. package/dist/components/select/snice-select.js +2 -0
  205. package/dist/components/select/snice-select.js.map +1 -1
  206. package/dist/components/switch/snice-switch.js +7 -3
  207. package/dist/components/switch/snice-switch.js.map +1 -1
  208. package/dist/components/table/snice-table.d.ts +9 -0
  209. package/dist/components/table/snice-table.js +72 -2
  210. package/dist/components/table/snice-table.js.map +1 -1
  211. package/dist/components/table/table-keyboard.js +1 -1
  212. package/dist/components/table/table-keyboard.js.map +1 -1
  213. package/dist/index.cjs +703 -264
  214. package/dist/index.cjs.map +1 -1
  215. package/dist/index.d.ts +3 -1
  216. package/dist/index.esm.js +703 -264
  217. package/dist/index.esm.js.map +1 -1
  218. package/dist/index.iife.js +703 -264
  219. package/dist/index.iife.js.map +1 -1
  220. package/dist/parts.d.ts +14 -4
  221. package/dist/react/SniceProvider.js +1 -1
  222. package/dist/react/SniceRouter.js +1 -1
  223. package/dist/react/index.js +1 -1
  224. package/dist/react/matchRoute.js +68 -2
  225. package/dist/react/matchRoute.js.map +1 -1
  226. package/dist/react/route-match.d.ts +7 -0
  227. package/dist/react/useRequestHandler.js +1 -1
  228. package/dist/render-errors.d.ts +9 -0
  229. package/dist/route-match.d.ts +7 -0
  230. package/dist/symbols.cjs +1 -1
  231. package/dist/symbols.esm.js +1 -1
  232. package/dist/template-marker.d.ts +5 -0
  233. package/dist/testing-dom.cjs +1 -1
  234. package/dist/testing-dom.esm.js +1 -1
  235. package/dist/testing.d.ts +3 -0
  236. package/dist/transitions.cjs +1 -1
  237. package/dist/transitions.esm.js +1 -1
  238. package/dist/types/dispatch-options.d.ts +5 -4
  239. package/dist/types/event-timing.d.ts +7 -0
  240. package/dist/types/index.d.ts +1 -0
  241. package/dist/types/on-options.d.ts +21 -6
  242. package/dist/utils.d.ts +3 -0
  243. package/docs/ai/DEVELOPMENT.md +1 -1
  244. package/docs/ai/api.md +7 -2
  245. package/docs/ai/cli.md +14 -0
  246. package/docs/ai/components/avatar.md +1 -0
  247. package/docs/ai/components/calendar.md +24 -1
  248. package/docs/ai/components/switch.md +3 -0
  249. package/docs/ai/components/table.md +1 -1
  250. package/docs/ai/decorators.md +3 -2
  251. package/docs/ai/events.md +45 -8
  252. package/docs/ai/rendering.md +7 -0
  253. package/docs/ai/routing.md +6 -1
  254. package/docs/ai/testing.md +17 -0
  255. package/docs/cli.md +19 -0
  256. package/docs/components/avatar.md +1 -0
  257. package/docs/components/calendar.md +112 -2
  258. package/docs/components/switch.md +7 -1
  259. package/docs/components/table.md +2 -1
  260. package/docs/events.md +90 -10
  261. package/docs/rendering.md +10 -0
  262. package/docs/routing.md +22 -1
  263. package/docs/testing.md +19 -0
  264. package/package.json +2 -2
  265. package/vscode.html-custom-data.json +28 -0
@@ -1,2 +1,2 @@
1
- globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map;const e=globalThis.snice;function t(e){return Symbol.for(`snice:${e}`)}const n=t("is-controller-class"),o=t("is-controller-instance"),r=t("is-daemon-class"),s=t("is-daemon-instance"),i=t("is-element-class"),a=t("channel-handlers"),c=t("daemon-state"),l=t("ready-promise"),h=t("ready-resolve"),u=t("ready-reject"),d=t("ready-handlers-running"),f=t("rendered-promise"),m=t("rendered-resolve"),p=t("pending-reconnect-render"),y=t("render-depth"),g=t("render-root"),b=t("element-options"),v=t("controller"),w=t("initialized"),E=t("controller-key"),N=t("controller-name"),A=t("controller-id"),S=t("controller-operations"),T=t("native-controller"),_=t("controller-registry-name"),x=t("direct-controller"),C=t("controller-attribute-sync"),O=t("pending-controller-binding"),k=t("cleanup"),$=t("properties"),L=t("property-values"),P=t("property-defaults"),j=t("property-wrappers"),M=t("pre-init-property-values"),R=t("pre-upgrade-property-bindings"),I=t("properties-initialized"),D=t("property-watchers"),V=t("explicitly-set-properties"),q=t("router-context"),B=t("page-transition"),F=t("created-at"),W=t("ready-handlers"),z=t("dispose-handlers"),U=t("reconnect-handlers"),H=t("moved-handlers"),K=t("adopted-handlers"),G=t("observers"),Q=t("setting-from-property"),J=t("moved-timers"),X=t("adopted-timers"),Y=t("dispatch-timers"),Z=t("render-method"),ee=t("render-options"),te=t("render-instance"),ne=t("render-timers"),oe=t("render-callbacks"),re=t("styles-method"),se=t("styles-applied"),ie=t("parent-styles-methods"),ae=t("snice-element-base"),ce=t("context-handler"),le=t("navigation-context-instance"),he=t("registered-elements"),ue=t("is-updating"),de=t("context-register"),fe=t("context-unregister"),me=t("context-notify-element"),pe=t("context-timer"),ye=t("context-called"),ge=t("context-update"),be=t("context-methods"),ve=t("watch-methods"),we=t("observe-methods"),Ee=t("on-methods"),Ne=t("respond-methods"),Ae=t("ready-methods"),Se=t("dispose-methods"),Te=t("reconnect-methods"),_e=t("moved-methods"),xe=t("adopted-methods"),Ce=t("controller-abort"),Oe=t("controller-attached"),ke=t("property-definers");class $e{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes($e.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${$e.SEPARATOR}" (U+FF0C)`);return e}if("number"==typeof e||"boolean"==typeof e)return String(e);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof e)}).join($e.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split($e.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var Le,Pe,je,Me;!function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(Le||(Le={}));const Re=Symbol.for("snice:registered-elements-set");let Ie=0;class De{constructor(e={},t=[],n="",o={},r){if(this[Pe]=new WeakMap,this[je]=new Set,this[Me]=!1,this.id=Ie++,this.application=e,this.navigation={placards:t,route:n,params:o},r&&"function"==typeof r.create)this.fetch=r.create(this);else{if("function"!=typeof fetch)throw new Error("No fetch implementation available");this.fetch=fetch.bind(this)}}[(Pe=he,je=Re,Me=ue,de)](e,t){const n=this[he];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[Re].add(e)}[fe](e,t){const n=this[he];if(void 0!==t){const o=n.get(e);if(!o)return;if(o.delete(t),o.size>0)return}n.delete(e),this[Re].delete(e)}[ge](e,t,n,o){this.application=e,this.navigation.placards=t,this.navigation.route=n,this.navigation.params=o,this.notify()}update(){this.notify()}notify(){if(this[ue])return;this[ue]=!0;const e=this[Re],t=this[he];for(const n of e){const e=t.get(n);if(e)for(const t of e)if("function"==typeof n[t])try{n[t](this)}catch(e){console.error(`Error calling @context method ${t}:`,e)}}this[ue]=!1}[me](e){const t=this[he].get(e);if(t)for(const n of t)if("function"==typeof e[n])try{e[n](this)}catch(e){console.error(`Error calling @context method ${n}:`,e)}}}function Ve(e){if(null!=e)return"string"==typeof e?String:"number"==typeof e?Number:"boolean"==typeof e?Boolean:e instanceof Date?Date:"bigint"==typeof e?BigInt:Array.isArray(e)?Array:void 0}function qe(e,t,n,o){const r=t.type||Ve(o);if(t.converter?.fromAttribute)return t.converter.fromAttribute(e,r);switch(r){case Boolean:return null!==e&&"false"!==e;case Number:return null!==e?Number(e):null;case String:return e;case Date:return e?new Date(e):null;case BigInt:return e&&e.endsWith("n")?BigInt(e.slice(0,-1)):e?BigInt(e):null;case $e:return $e.parse(e);case Array:try{return e?JSON.parse(e):[]}catch{return[]}case Object:try{return e?JSON.parse(e):{}}catch{return{}}default:return"number"==typeof n&&null!==e?Number(e):e}}function Be(e,t){return e!==t&&(e==e||t==t)}function Fe(e,t){return"string"==typeof e.attribute?e.attribute.toLowerCase():!0===e.attribute||"kebab"===e.attributeNaming?t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase():t.toLowerCase()}function We(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ze(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ue(e,t={}){let n;try{n=String(e??"")}catch{return!1}if(!n||/[\u0000-\u001f\u007f]/.test(n))return!1;const o=n.trim();if(!o)return!1;const r=t.allowed??["http:","https:","mailto:","tel:"];try{const e=new URL(o,"http://__snice-relative.invalid/"),t=/^[a-z][a-z\d+.-]*:/i.test(o),n=/^[\\/]{2}/.test(o);return!t&&!n||r.some(t=>"string"==typeof t&&t.toLowerCase()===e.protocol)}catch{return!1}}function He(e){const t=String(e).trim(),n=parseFloat(t);let o;return o=isNaN(n)?0:/ms$/i.test(t)?n:/s$/i.test(t)?1e3*n:/m$/i.test(t)?6e4*n:/h$/i.test(t)?36e5*n:n,{milliseconds:()=>o,seconds:()=>o/1e3,minutes:()=>o/6e4}}function Ke(e,t){return e[t]||(e[t]=new Set),e[t]}function Ge(e,t){return e[t]||(e[t]={}),e[t]}function Qe(e,t,n,o,r){const s=t[D];if(!s)return;const i=[n],a=t[$]?.get(n),c=a&&"string"==typeof a.attribute?a.attribute:null;c&&c!==n&&i.push(c);for(const t of i)if(s.has(t))for(const i of s.get(t))try{i.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('${t}') method ${i.methodName}:`,e)}if(s.has("*"))for(const t of s.get("*"))try{t.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('*') method ${t.methodName}:`,e)}}function Je(e,t){let n=null;const o=function(...o){null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o),n=null},t)};return o.cancel=()=>{null!==n&&clearTimeout(n),n=null},o}function Xe(e,t){let n=0,o=null;return function(...r){const s=Date.now(),i=t-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,e.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,e.apply(this,r)},i))}}function Ye(e,t){if(null==t)return e;if("global"===t)return"undefined"!=typeof document?document:null;if("function"==typeof t)try{return t.call(e)||null}catch{return null}return"string"==typeof t?e.closest?.(t)||null:t&&"function"==typeof t.addEventListener?t:null}function Ze(e,t,n){if(null==e||!1===e||t?.type===$e&&Array.isArray(e)&&0===e.length)return null;if(t.converter?.toAttribute)return t.converter.toAttribute(e,t.type);switch(t.type||Ve(n)){case Boolean:return"true";case Date:return e instanceof Date?e.toISOString():String(e);case BigInt:return"bigint"==typeof e?e.toString()+"n":String(e);case $e:return Array.isArray(e)?$e.serialize(e):String(e);case Array:return Array.isArray(e)?JSON.stringify(e):String(e);case Object:return"object"==typeof e&&null!==e?JSON.stringify(e):String(e);default:return String(e)}}const et=new WeakSet,tt=new Map;function nt(e,t,n){let o,r;return"string"==typeof t?(o=t,r=n):(o=void 0,r=t),function(t,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,we)||(n[we]=new Set),n[we].has(t))return;if(n[we].add(t),!Object.prototype.hasOwnProperty.call(n,G)){const e=n[G];n[G]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[G].push({type:i,target:c,selector:o,methodName:s,method:t,options:r})}})}}function ot(e,t){const n=e.constructor[G];if(n&&Array.isArray(n)&&0!==n.length){e[k]?e[k].observers||(e[k].observers=[]):e[k]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?Xe(n,o.options.throttle):n;switch(o.type){case"intersection":rt(e,t,o,r);break;case"resize":st(e,t,o,r);break;case"media":it(e,0,o,r);break;case"mutation":at(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function rt(e,t,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");const s=new IntersectionObserver(e=>{for(const t of e)try{!1===o(t)&&s&&s.unobserve(t.target)}catch(e){console.error(`Error in intersection observer ${n.methodName}:`,e)}},r),i=n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t];i.forEach(e=>s.observe(e)),e[k].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function st(e,t,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(e=>{for(const t of e)try{o(t)}catch(e){console.error(`Error in resize observer ${n.methodName}:`,e)}});(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t]).forEach(e=>{s.observe(e,{box:r})}),e[k].observers.push(()=>{s.disconnect()})}function it(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=tt.get(r);if(!s)try{s=window.matchMedia(r),tt.set(r,s)}catch(e){return void console.error(`Invalid media query: ${r}`,e)}const i=e=>{try{o(e.matches)}catch(e){console.error(`Error in media query observer ${n.methodName}:`,e)}};i(s);const a=e=>i(e);s.addEventListener?(s.addEventListener("change",a),e[k].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[k].observers.push(()=>{s.removeListener(a)}))}function at(e,t,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(/^[.#[]/.test(i)?console.warn(`@observe: "mutation:${i}" — "${i}" looks like a selector. Selectors are the second argument — did you mean @observe('mutation:childList', '${i}')?`):console.warn(`Unknown mutation type: ${i} (expected childList or attributes)`))}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=!(!n.options?.maxDepth||!n.options.subtree),h=new MutationObserver(e=>{try{if(!l)return void r(e);const o=n.options.maxDepth,s=t.shadowRoot||t,i=e.filter(e=>{let t=0,n=e.target;for(;n&&n!==s&&t<o;)n=n.parentNode,t++;return t<o});i.length>0&&r(i)}catch(e){console.error(`Error in mutation observer ${n.methodName}:`,e)}}),u=!0===e[o];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):u&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{h.observe(e,c)}),e[k].observers.push(()=>{h.disconnect()})}function ct(e){if(e[k]?.observers){for(const t of e[k].observers)t();e[k].observers=[]}}const lt="@context/request",ht=new WeakMap;function ut(e){return!e||"object"!=typeof e&&"function"!=typeof e?null:!0===e[o]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:"function"==typeof e.dispatchEvent?e:null}function dt(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=ut(e);if(t){const e={kind:"application"};if(t.dispatchEvent(new CustomEvent(lt,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[q]?n[q]:!0===n[o]&&void 0!==n.element?.[q]?n.element[q]:void 0}function ft(e){const t=ut(e);if(!t)return;const n={kind:"fetch"};return t.dispatchEvent(new CustomEvent(lt,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.fetch}function mt(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[r]}function pt(e){if(!mt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");let t=e[c];if(!t){t={target:new EventTarget,bindings:0,active:!1};try{Object.defineProperty(e,c,{value:t,configurable:!0}),Object.defineProperty(e,s,{value:!0,configurable:!0})}catch{throw new TypeError("@daemon instances must remain extensible until they are provided to an app context.")}}return t}function yt(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=dt(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[o]?"controller":mt(t)?"@daemon instance":"element"}(e)} cannot resolve daemon "${t}" because no app context is provided.`);const r=n.daemons?.[t];if(!r)throw new Error(`[snice] app context does not provide daemon "${t}".`);if(!mt(r))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=pt(r);if(!s.active)throw new Error(`[snice] daemon "${t}" is not active because its app context has not been provided.`);return s.target}function gt(e){return mt(e)?function(e){return pt(e).target}(e):!0===e?.[o]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}function bt(e,t){return function(n,o){let r,s,i=0;const a=[];return async function(...o){const c=async()=>{const r=t?.timeout??12e4,s=t?.discoveryTimeout??50,i=void 0!==t?.daemon?yt(this,t.daemon):gt(this);if(!i)throw new TypeError(`@request('${e}') requires an element, attached controller, or provided @daemon instance.`);const a=n.apply(this,o),{value:c,done:l}=await a.next();if(l)return c;let h,u;const d=new Promise((e,t)=>{h=e,u=t});let f,m,p,y=!1;const g=new Promise((t,n)=>{f=t,m=n,p=setTimeout(()=>{n(new Error(`Request "${e}" found no @respond('${e}') handler within ${s}ms — attach a responding controller/element, or pass { optional: true } to resolve undefined when unhandled.`))},s)}),b=new CustomEvent(`@request/${e}`,{bubbles:void 0===t?.bubbles||t.bubbles,cancelable:t?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{y=!0,clearTimeout(p),f()},reject:m},data:{resolve:h,reject:u}}});i.dispatchEvent(b);try{await g;const t=setTimeout(()=>{u(new Error(`Request "${e}" timed out after ${r}ms`))},r),n=await d;clearTimeout(t);const{value:o}=await a.next(n);return o}catch(e){if(t?.optional&&!y){const{value:e}=await a.next(void 0);return e}const{value:n}=await a.throw(e);return n}};if(t?.debounce)return new Promise((e,n)=>{clearTimeout(r),r=setTimeout(async()=>{try{e(await c())}catch(e){n(e)}},t.debounce)});if(!t?.throttle)return c();const l=Date.now(),h=t.throttle-(l-i);if(h<=0){clearTimeout(s),s=null,i=l;const e=a.splice(0),t=c();return e.length&&t.then(t=>{for(const n of e)n.resolve(t)},t=>{for(const n of e)n.reject(t)}),t}return new Promise(s?(e,t)=>{a.push({resolve:e,reject:t})}:(e,t)=>{a.push({resolve:e,reject:t}),s=setTimeout(async()=>{i=Date.now(),s=null;const e=a.splice(0);try{const t=await c();for(const n of e)n.resolve(t)}catch(t){for(const n of e)n.reject(t)}},h)})}}}function vt(e,t){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,Ne)||(o[Ne]=new Set),!o[Ne].has(n)){if(o[Ne].add(n),!Object.prototype.hasOwnProperty.call(o,a)){const e=o[a];o[a]=e?[...e]:[]}o[a].push({channelName:e,methodName:r,method:n,options:t})}})}}function wt(e,t){const n=e.constructor[a];if(n){e[k]||(e[k]={events:[],channels:[]});for(const o of n){const n=o.method.bind(e),r=`@request/${o.channelName}`;let s,i,a=0;const c=[];let l=null;const h=(e=>o.options?.debounce?(...t)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{n(await e(...t))}catch(e){r(e)}},o.options.debounce)}):o.options?.throttle?(...t)=>{const n=Date.now(),r=o.options.throttle-(n-a);if(r<=0){clearTimeout(i),i=null,a=n;const o=c.splice(0);l=null;const r=e(...t);return o.length&&Promise.resolve(r).then(e=>{for(const t of o)t.resolve(e)},e=>{for(const t of o)t.reject(e)}),r}return l=t,new Promise((n,o)=>{c.push({resolve:n,reject:o}),i||(i=setTimeout(async()=>{a=Date.now(),i=null;const n=c.splice(0),o=l??t;l=null;try{const t=await e(...o);for(const e of n)e.resolve(t)}catch(e){for(const t of n)t.reject(e)}},r))})}:e)(n),u=e=>{const{data:t,discovery:n,payload:r}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),Promise.resolve(h(r)).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${o.methodName}:`,e)})};let d=t;if(void 0!==o.options?.daemon)try{d=yt(e,o.options.daemon)}catch(e){console.warn(`[snice/@respond] ${e.message} Responder "${o.channelName}" skipped.`);continue}d.addEventListener(r,u),e[k].channels.push(()=>{d.removeEventListener(r,u)})}}}function Et(e){if(e[k]?.channels){for(const t of e[k].channels)t();e[k].channels=[]}}const Nt=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function At(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();Nt.has(n)&&console.warn(`snice: "@${e}" is not a valid modifier — once/preventDefault/stopPropagation/capture are @on() options, not template modifiers. This registers a listener for event "${e}", which never fires.`)}function St(e){const t=e.startsWith("~");t&&(e=e.substring(1));const n=e.split("+"),o={key:"",anyModifiers:t};for(const e of n){const t=e.toLowerCase();"ctrl"===t||"control"===t?o.ctrl=!0:"alt"===t?o.alt=!0:"shift"===t?o.shift=!0:"meta"===t||"cmd"===t||"command"===t?o.meta=!0:o.key=Tt(e)}return o}function Tt(e){return{esc:"Escape",escape:"Escape",enter:"Enter",return:"Enter",space:" ",spacebar:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",delete:"Delete",del:"Delete",backspace:"Backspace",tab:"Tab",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"}[e.toLowerCase()]||e}function _t(e,t){return e.key===t.key&&(!!t.anyModifiers||(t.ctrl?e.ctrlKey:!e.ctrlKey)&&(t.alt?e.altKey:!e.altKey)&&(t.shift?e.shiftKey:!e.shiftKey)&&(t.meta?e.metaKey:!e.metaKey))}const xt=t("on-handlers");function Ct(e,t,n){let o=null,r={};return"string"==typeof t?(o=t,r=n||{}):t&&"object"==typeof t?r=t:null===t&&n&&(r=n),function(t,n){const s=n.name;return n.addInitializer(function(){const n=this.constructor,i=Array.isArray(e)?e:[e],a=`${s}::${i.join(",")}::${o??""}::daemon:${r.daemon??""}`;if(Object.prototype.hasOwnProperty.call(n,Ee)||(n[Ee]=new Set),!n[Ee].has(a)){if(n[Ee].add(a),!Object.prototype.hasOwnProperty.call(n,xt)){const e=n[xt];n[xt]=e?[...e]:[]}for(const e of i)n[xt].push({eventName:e,selector:o,methodName:s,method:t,options:r})}}),t}}function Ot(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const kt=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function $t(e,t){const n=e.constructor[xt];if(n&&Array.isArray(n)&&0!==n.length){e[k]||(e[k]={events:[],eventCancels:[],channels:[],observers:[]}),e[k].events||(e[k].events=[]),e[k].eventCancels||(e[k].eventCancels=[]),(e[k].events.length>0||e[k].eventCancels.length>0)&&Lt(e);for(const o of n){const n=e[o.methodName];let r=n?n.bind(e):o.method.bind(e);const s=o.options||{},i=["keydown","keyup","keypress"].includes(o.eventName.split(".")[0].split(":")[0]),a=i?o.eventName.indexOf("."):-1,c=i?o.eventName.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c),h=l>0?o.eventName.substring(0,l):o.eventName,u=l>0?o.eventName.substring(l+1):null;if(l<=0&&At(o.eventName),s.debounce&&s.debounce>0){const t=Je(r,s.debounce);e[k].eventCancels.push(()=>t.cancel()),r=t}else s.throttle&&s.throttle>0&&(r=Ot(r,s.throttle));let d=null;u&&["keydown","keyup","keypress"].includes(h)&&(d=St(u));const f=(e=>d?t=>{_t(t,d)&&e(t)}:e)(r),m=void 0!==s.scope,p=void 0!==s.daemon;if(m&&p){console.warn(`[snice/@on] "${o.eventName}" cannot use both scope and daemon — listener skipped.`);continue}if((p||mt(e))&&o.selector){console.warn(`[snice/@on] "${o.eventName}" cannot delegate "${o.selector}" on a daemon target — listener skipped.`);continue}const y=m||p;let g=null;if(p)try{g=yt(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(m&&(g=Ye(t,s.scope),!g)){console.warn(`[snice/@on] scope did not resolve for "${o.eventName}" on ${o.methodName} — listener skipped.`);continue}if(o.selector){const n=y?g:t.shadowRoot||t,r=e=>{const t=e.target;if(t.matches&&t.matches(o.selector)&&t||t.closest&&t.closest(o.selector)){s.preventDefault&&e.preventDefault(),s.stopPropagation&&(e.stopPropagation(),e.stopImmediatePropagation());try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},i=kt.has(h),a={capture:void 0!==s.capture?s.capture:i,once:s.once||!1,passive:s.passive||!1};n.addEventListener(h,r,a),e[k].events.push({target:n,eventName:h,handler:r,options:a})}else{const n=y?null:t.shadowRoot,r=Symbol(),i=e=>{if(!e[r]){e[r]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&e.stopPropagation();try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};if(y){g.addEventListener(h,i,a),e[k].events.push({target:g,eventName:h,handler:i,options:a});continue}n&&(n.addEventListener(h,i,a),e[k].events.push({target:n,eventName:h,handler:i,options:a})),t.addEventListener(h,i,a),e[k].events.push({target:t,eventName:h,handler:i,options:a})}}}}function Lt(e){if(e[k]?.events){for(const t of e[k].eventCancels??[])t();e[k].eventCancels=[];for(const{target:t,eventName:n,handler:o,options:r}of e[k].events)t.removeEventListener(n,o,r);e[k].events=[]}}const Pt=t("context-handlers");function jt(e={}){return function(t,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,be)||(n[be]=new Set),!n[be].has(t)){if(n[be].add(t),!Object.prototype.hasOwnProperty.call(n,Pt)){const e=n[Pt];n[Pt]=e?[...e]:[]}n[Pt].push({methodName:o,method:t,options:e})}}),t}}function Mt(e,t=!1){const n=e.constructor[Pt];if(!n||!Array.isArray(n)||0===n.length)return;const o=e[ce]??function(e){const t=ut(e);if(!t)return;const n={kind:"navigation"};return t.dispatchEvent(new CustomEvent(lt,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.navigation}(e);if(!o)return;e[le]=o;let r=!1;for(const t of n){const{methodName:n,method:s,options:i}=t,a=`__wrapped_${n}`;e[a]=function(t){r=!0;const o=e[ye]||(e[ye]=new Set);if(i.once&&o.has(n))return;const c=()=>{if(s.call(e,t),i.once){o.add(n);const t=e[le];t&&"function"==typeof t[fe]&&t[fe](e,a)}},l=e[pe]||(e[pe]={}),h=n;if(i.debounce)return clearTimeout(l[h]?.timeout),void(l[h]={timeout:setTimeout(c,i.debounce)});if(i.throttle){const e=Date.now();return void(e-(l[h]?.lastCall||0)>=i.throttle&&(l[h]={lastCall:e},c()))}c()},"function"==typeof o[de]&&o[de](e,a)}return t&&"function"==typeof o[me]?new Promise(n=>{const s=()=>{try{r||e[le]!==o||o[me](e)}finally{n()}};"task"===t?setTimeout(s,0):queueMicrotask(s)}):void 0}function Rt(e){const t=e.constructor[Pt];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[pe];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[pe]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[le];o&&"function"==typeof o[fe]&&o[fe](e),delete e[le],delete e[ye]}class It{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(e,t){this.cleanupFns.set(e,t)}unregister(e){this.cleanupFns.delete(e)}async cleanup(){await Promise.all(this.pendingOperations);for(const e of this.cleanupFns.values())try{await e()}catch(e){console.error("Error during cleanup:",e)}this.cleanupFns.clear()}async runOperation(e){const t=e(),n=t.then(()=>{},()=>{});this.pendingOperations.add(n);try{const e=await t;return this.pendingOperations.delete(n),e}catch(e){throw this.pendingOperations.delete(n),e}}}function Dt(t){return function(o,r){const s=globalThis.snice?.controllerRegistry;if(!s)throw new Error("Snice global registry not initialized");s.set(t,o),o.prototype[n]=!0,Object.defineProperty(o,_,{value:t,configurable:!0});const i=e.pendingControllerAttachments.get(t);return i&&(e.pendingControllerAttachments.delete(t),queueMicrotask(()=>{for(const e of i){const n=e[T];(void 0===n?e[v]:n)===t&&Wt(e,t).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${t}":`,e)})}})),o}}function Vt(t,n){if(e.controllerRegistry.has(n))return void queueMicrotask(()=>{const e=t[T];(void 0===e?t[v]:e)===n&&Wt(t,n).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${n}":`,e)})});let o=e.pendingControllerAttachments.get(n);o||(o=new Set,e.pendingControllerAttachments.set(n,o)),o.add(t),queueMicrotask(()=>{e.pendingControllerAttachments.get(n)?.has(t)&&console.error(`Failed to attach controller "${n}":`,new Error(`Controller "${n}" not found in registry`))})}function qt(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}function Bt(e,t){if(null===t){if(!e.hasAttribute("controller"))return}else if(e.getAttribute("controller")===t)return;e[C]=!0;try{null===t?e.removeAttribute("controller"):e.setAttribute("controller",t)}finally{delete e[C]}}function Ft(e){if(!e[x])return!1;const t=e[N];return"function"==typeof t&&(Bt(e,function(e){const t=Object.prototype.hasOwnProperty.call(e,_)?e[_]:void 0;return"string"==typeof t?t:qt(e)}(t)),!0)}async function Wt(t,r){if("string"!=typeof r){if("function"!=typeof r)throw new Error(`attachController: expected a controller name or a controller class, got ${typeof r}. Controller instances are not supported — pass the class itself.`);if("function"!=typeof(s=r)||!0!==s.prototype?.[n])throw new Error(`Controller class "${qt(r)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=qt(r),a=t[E],c=t[T];if("string"==typeof r&&void 0!==c&&c!==r)return;if(t[N]===r&&a)return void("string"!=typeof r&&Ft(t));if(a&&(await zt(t),t[E]&&t[N]===r))return void("string"!=typeof r&&Ft(t));let l;if("string"==typeof r){const e=globalThis.snice?.controllerRegistry;if(!e)throw new Error("Snice global registry not initialized");if(l=e.get(r),!l)throw new Error(`Controller "${r}" not found in registry`)}else l=r;const h=new l;"string"!=typeof r&&(t[x]=!0,delete t[T]),e.controllerIdCounter+=1;const u=e.controllerIdCounter,f=new It;h[o]=!0,h[A]=u,h.element=t;const m=t[q];if(void 0!==m&&(h[q]=m),t[E]=h,t[N]=r,t[S]=f,"string"!=typeof r&&Ft(t),!t[d]){const e=new AbortController;t[Ce]=e;const n=3e4;try{await Promise.race([t.ready,new Promise((t,o)=>{const r=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",o(e)};if(e.signal.aborted)return r();e.signal.addEventListener("abort",r,{once:!0});const s=setTimeout(()=>o(new Error(`attachController("${i}"): element did not become ready within ${n}ms (did you forget to appendChild it?)`)),n);e.signal.addEventListener("abort",()=>clearTimeout(s),{once:!0})})])}catch(e){throw t[E]===h&&("string"!=typeof r&&Bt(t,null),delete t[E],delete t[N],delete t[S],"string"!=typeof r&&delete t[x]),e}finally{t[Ce]===e&&delete t[Ce]}}h[Oe]=!0,await f.runOperation(async()=>{await h.attach(t)}),await Mt(h,"microtask"),ot(h,t),wt(h,t),$t(h,t),t.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:h}}))}async function zt(e){const t=e[Ce];t&&t.abort();const n=e[E],o=e[N],r=e[S];n&&("function"==typeof o&&Bt(e,null),delete e[E],delete e[N],delete e[S],"function"==typeof o&&delete e[x],n[Oe]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),n.element=null,ct(n),Et(n),Lt(n),Rt(n),r&&await r.cleanup(),delete n[q],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:qt(o),controller:n}}))))}function Ut(e){return e[E]}function Ht(){if(globalThis.sniceNativeControllersInitialized)return;function e(e){if(!(e instanceof HTMLElement))return;if(!e.tagName||e.tagName.includes("-"))return;if(e[i])return;if(e[x])return void Ft(e);const t=e.getAttribute("controller"),n=e[T];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[T],delete e[N],void zt(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[T]=t,e.ready||(e.ready=Promise.resolve()),n&&zt(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),Wt(e,t).catch(n=>{"ControllerAttachAborted"!==n?.name?n?.message!==`Controller "${t}" not found in registry`?console.error(`Failed to attach controller "${t}" to native element:`,n):Vt(e,t):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}globalThis.sniceNativeControllersInitialized=!0;const t=new MutationObserver(t=>{for(const n of t)"attributes"===n.type&&"controller"===n.attributeName?e(n.target):"childList"===n.type&&n.addedNodes.forEach(t=>{t instanceof HTMLElement&&(e(t),t.querySelectorAll("[controller]").forEach(e))})});function n(){document.querySelectorAll("[controller]").forEach(e),t.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n(),globalThis.sniceNativeControllerObserver=t}const Kt=Symbol.for("snice:html-result"),Gt=Symbol.for("snice:css-result"),Qt=new WeakMap;function Jt(e,...t){return{_$litType$:Kt,strings:e,values:t}}function Xt(e,...t){return{_$litType$:Kt,strings:e,values:t,svg:!0}}function Yt(e,...t){const n=0===t.length?Qt.get(e):void 0;if(n)return n;let o=e[0];for(let n=0;n<t.length;n++){const r=t[n];o+=(en(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:Gt,cssText:o};if("undefined"!=typeof CSSStyleSheet&&"undefined"!=typeof Document&&"adoptedStyleSheets"in Document.prototype)try{const e=new CSSStyleSheet;e.replaceSync(o),r.styleSheet=e}catch(e){}return 0===t.length&&Qt.set(e,r),r}function Zt(e){return e&&e._$litType$===Kt}function en(e){return e&&e._$litType$===Gt}const tn=Symbol.for("snice:nothing"),nn=Symbol.for("snice:unsafe-html");function on(e){return{_$litType$:nn,html:e}}function rn(e){return e&&e._$litType$===nn}const sn=Symbol.for("snice:repeat-result");function an(e,t){if(!t||"function"!=typeof t.key||"function"!=typeof t.render)throw new TypeError("snice: repeat() requires { key, render }.");const n=null==e?[]:Array.from(e),o=n.map(t.key),r=new Set;for(const e of o){if(r.has(e))throw new Error(`snice: repeat() received duplicate key ${String(e)}.`);r.add(e)}return{_$repeat$:sn,items:n,keys:o,values:n.map(t.render),empty:0===n.length?"function"==typeof t.empty?t.empty():t.empty:void 0}}const cn=new WeakSet;function ln(e){return e[g]||e.shadowRoot||null}function hn(e){const t=ln(e);if(t)return t;const n=e.constructor[b];let o;if(o="light"===n?.renderRoot||!1===n?.shadow?e:"function"==typeof e.createRenderRoot?e.createRenderRoot():e.attachShadow({mode:"string"==typeof n?.shadow?n.shadow:"open",delegatesFocus:n?.delegatesFocus}),o!==e&&!(o instanceof ShadowRoot))throw new TypeError("snice: createRenderRoot() must return the host element or a ShadowRoot.");return e[g]=o,cn.add(e),o}function un(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&cn.has(n))return n;n=n.parentNode}return null}const dn=`snice$${Math.random().toFixed(9).slice(2)}$`,fn="?"+dn,mn=`\x3c!--${fn}--\x3e`,pn=new RegExp(dn.replace(/\$/g,"\\$"),"g"),yn=new WeakMap,gn=Symbol("not-committed");function bn(e,t,n){!function(e,t){const n=e.localName;if(!n?.includes("-"))return!1;const o=e.ownerDocument?.defaultView?.customElements??globalThis.customElements;if(o?.get(n))return!1;const r=e;return r[R]||(r[R]=new Set),r[R].add(t),!0}(e,t)?e[t]=n:Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n})}const vn=Symbol.for("snice:no-change"),wn=Symbol.for("snice:live");function En(e){return{_$liveMarker$:wn,value:e}}const Nn=e=>null===e||"object"!=typeof e&&"function"!=typeof e,An=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class Sn{constructor(e,t,n){this.parts=[],this.keyIndex=-1,this.element=t;const o=document.createTreeWalker(t.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let r=0;const s=[];let i;for(;null!==(i=o.nextNode());)if(i.nodeType===Node.ELEMENT_NODE){const e=i,t=e.tagName.toLowerCase(),o=e.parentElement?.tagName.toLowerCase();if(("else"===t||"else-if"===t)&&"if"!==o)throw new Error(`snice: <${t}> must be a direct child of <if>.`);if(("when"===t||"default"===t)&&"case"!==o)throw new Error(`snice: <${t}> must be a direct child of <case>.`);if("if"===t){const t=e.getAttribute("value");if(!t||!t.includes(dn))throw new Error("snice: <if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-if",index:r++,element:e});continue}if("case"===t){const t=e.getAttribute("value");if(!t||!t.includes(dn))throw new Error("snice: <case> requires a value expression.");for(const t of Array.from(e.childNodes))if(t.nodeType===Node.ELEMENT_NODE){const e=t.tagName.toLowerCase();if("when"!==e&&"default"!==e)throw new Error("snice: <case> may contain only direct <when> and <default> branches.")}else if(t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()||t.nodeType===Node.COMMENT_NODE&&t.data.includes(dn))throw new Error("snice: content inside <case> must be nested in a <when> or <default> branch.");e.removeAttribute("value"),this.parts.push({type:"conditional-case",index:r++,element:e});continue}if("else-if"===t){const t=e.getAttribute("value");if(!t||!t.includes(dn))throw new Error("snice: <else-if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-else-if",index:r++,element:e});continue}if("when"===t){const t=e.getAttribute("value");t&&t.includes(dn)&&(e.removeAttribute("value"),this.parts.push({type:"conditional-when",index:r++,element:e}));continue}if(e.hasAttributes()){const t=e.attributes,o=[];for(let s=0;s<t.length;s++){const i=t[s],a=i.value;if(a.includes(dn)){o.push(i);const t=n[r]||i.name,s=a.split(dn),c=s.length-1;if(/^@@?|^[.?]/.test(t)||t.startsWith("...")||t.startsWith("class:")||t.startsWith("style:")){const e=s.some(e=>""!==e);(c>1||e)&&console.warn(`snice: binding "${t}" takes a single expression; static text and extra interpolations are ignored. Use a plain attribute for string interpolation.`)}if(t.startsWith("...")){const n=t.slice(3).toLowerCase();if(!["props","properties","attrs","attributes","events"].includes(n))throw new Error(`snice: unknown spread binding "${t}". Use ...props, ...attrs, or ...events.`);this.parts.push({type:"spread",index:r,name:n,element:e}),r+=c}else if(t.startsWith("class:")){if(!t.slice(6))throw new Error("snice: class: binding requires a class name.");this.parts.push({type:"class",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("style:")){if(!t.slice(6))throw new Error("snice: style: binding requires a CSS property name.");this.parts.push({type:"style",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("@@")){if(!t.slice(2).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("@")){if(!t.slice(1).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith(".")){if(!t.slice(1))throw new Error("snice: property binding requires a property name.");this.parts.push({type:"property",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("?")){if(!t.slice(1))throw new Error("snice: boolean binding requires an attribute name.");this.parts.push({type:"boolean-attribute",index:r,name:t.slice(1),element:e}),r+=c}else"controller"===i.name&&2===s.length&&""===s[0]&&""===s[1]?(this.parts.push({type:"controller",index:r,element:e}),r+=c):(this.parts.push({type:"attribute",index:r,name:i.name,element:e,attrStrings:s}),r+=c)}}for(const t of o)e.removeAttribute(t.name)}}else if(i.nodeType===Node.COMMENT_NODE){const e=i;if(e.data===fn){const t=e.parentNode,n=document.createComment("");t.insertBefore(n,e.nextSibling),this.parts.push({type:"node",index:r++,startNode:e,endNode:n})}else if(e.data.includes(dn)){const t=e.data.split(pn);this.parts.push({type:"comment",index:r,startNode:e,attrStrings:t}),r+=t.length-1}}else if(i.nodeType===Node.TEXT_NODE){const e=i,t=e.data;if(t.includes(dn)){const n=e.parentNode,o=t.split(pn),i=o.length-1;for(let t=0;t<i;t++){n.insertBefore(document.createTextNode(o[t]),e);const s=document.createComment(""),i=document.createComment("");n.insertBefore(s,e),n.insertBefore(i,e),this.parts.push({type:"node",index:r++,startNode:s,endNode:i})}""!==o[i]?e.data=o[i]:s.push(e)}}for(const e of s)e.parentNode?.removeChild(e);for(const e of this.parts)if("attribute"===e.type&&"key"===e.name){this.keyIndex=e.index;break}}}function Tn(e){const{strings:t}=e,n=yn.get(t);if(n)return n;const o=[],r=[];let s=!1,i=!1,a=!1,c="",l="";for(let e=0;e<t.length;e++){const n=t[e];if(o.push(n),e<t.length-1){for(let e=0;e<n.length;e++){const t=n[e];if(a)"-"===t&&n.startsWith("--\x3e",e)&&(a=!1,e+=2);else if(s){if(i)t===c&&(i=!1,c="");else if(">"===t)s=!1;else if('"'===t||"'"===t)i=!0,c=t;else if("="===t){let t=e-1;for(;t>=0&&/[\w\-\.@\?/:\+~|]/.test(n[t]);)t--;l=n.substring(t+1,e).trim()}}else"<"===t&&(n.startsWith("\x3c!--",e)?(a=!0,e+=3):/[A-Za-z!/?]/.test(n[e+1]||"")&&(s=!0))}if(a)r.push(""),o.push(dn);else if(i)r.push(l),o.push(dn);else if(s){const s=n.trimEnd();if(s.endsWith("=")){let e=s.length-2;for(;e>=0&&/[\w\-\.@\?\/:\+~|]/.test(s[e]);)e--;l=s.substring(e+1,s.length-1).trim(),r.push(l),o.push(dn)}else{if(!n.match(/<(if|else-if|case|when)\s*$/)){const o=(n.slice(-40)+"${…}"+(t[e+1]??"").slice(0,40)).replace(/\s+/g," ").trim();throw new Error(`snice: expressions directly in opening tags are not supported; use an explicit attribute, property, event, class, style, or named spread binding. Near "${o}".`)}l="value",r.push("value"),o.push(`value="${dn}"`)}}else r.push(""),o.push(mn)}}const h=o.join(""),u=document.createElement("template");if(e.svg){u.innerHTML=`<svg>${h}</svg>`;const e=u.content.firstElementChild;for(;e.firstChild;)u.content.insertBefore(e.firstChild,e);u.content.removeChild(e)}else u.innerHTML=h;let d;try{d=new Sn(e,u,r)}catch(e){throw function(e,t){if(e instanceof Error&&/\bNear "[\s\S]*"\.$/.test(e.message))return e;const n=e instanceof Error?e.message:String(e),o=Array.from(t).join("${…}").replace(/\s+/g," ").trim(),r=/<([a-z][a-z0-9-]*)>/i.exec(n)?.[1],s=/binding "([^"]+)"/i.exec(n)?.[1],i=r?`<${r}`:s??"",a=i?o.indexOf(i):-1,c=a>=0?a:0,l=Math.max(0,c-40),h=Math.min(o.length,c+80),u=h<o.length?"…":"";return new Error(`${n} Near "${l>0?"…":""}${o.slice(l,h)}${u}".`,{cause:e})}(e,t)}return yn.set(t,d),d}function _n(e){if(!Zt(e))return;const t=Tn(e);return-1===t.keyIndex?void 0:e.values[t.keyIndex]}class xn{constructor(e){this.parts=[],this.fragment=null,this.conditionalParts=[],this.regularParts=[],this.template=Tn(e),this.strings=e.strings}isSameTemplate(e){return this.strings===e}renderFragment(){if(!this.fragment){this.fragment=this.template.element.content.cloneNode(!0);const e=document.createTreeWalker(this.template.element.content,NodeFilter.SHOW_ALL),t=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ALL),n=new Map;let o=e.currentNode,r=t.currentNode;for(;o&&r;)n.set(o,r),o=e.nextNode(),r=t.nextNode();const s=new Set;for(const e of this.template.parts)"conditional-when"===e.type&&s.add(n.get(e.element));for(let e=0;e<this.template.parts.length;e++){const t=this.template.parts[e];let o;switch(t.type){case"node":const e=n.get(t.startNode),r=n.get(t.endNode);o=new On(e,r);break;case"attribute":const i=n.get(t.element);o=new kn(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new Mn(a,t.name);break;case"boolean-attribute":const c=n.get(t.element);o=new In(c,t.name);break;case"event":const l=n.get(t.element);o=new Dn(l,t.name);break;case"class":const h=n.get(t.element);o=new Ln(h,t.name);break;case"style":const u=n.get(t.element);o=new Pn(u,t.name);break;case"spread":const d=n.get(t.element);o=new jn(d,t.name);break;case"controller":const f=n.get(t.element);o=new Rn(f);break;case"conditional-if":const m=n.get(t.element);o=new qn(m);break;case"conditional-else-if":const p=n.get(t.element);o=new Fn(p);break;case"conditional-case":const y=n.get(t.element);o=new Wn(y,s);break;case"conditional-when":const g=n.get(t.element);o=new Un(g);break;case"comment":const b=n.get(t.startNode);o=new $n(b,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof qn||o instanceof Fn||o instanceof Wn||o instanceof Un?this.conditionalParts.push({part:o,index:t.index}):this.regularParts.push({part:o,index:t.index})}}return this.fragment}render(e){const t=this.renderFragment();return this.update(e),t}update(e){for(const{part:t,index:n}of this.conditionalParts)t.commit(e[n]);const t=new Set;for(const{part:e}of this.conditionalParts){const n=e instanceof Fn||e instanceof Un?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof qn||n instanceof Wn)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof kn&&void 0!==t.strings||t instanceof $n?t.commit(e,n):t.commit(e[n]);let n;for(const e of this.parts)try{e.isConnected?e.reconnected():e.disconnected()}catch(e){n??=e}if(n)throw n}clear(){let e;for(const t of this.parts)try{t.destroy()}catch(t){e??=t}if(e)throw e}disconnected(e=!1){let t;for(const n of this.parts)try{n.disconnected(e)}catch(e){t??=e}if(t)throw t}reconnected(){let e;for(const t of this.parts)try{t.reconnected()}catch(t){e??=t}if(e)throw e}}class Cn{get isConnected(){return this.element?.isConnected??!1}disconnected(e=!1){}reconnected(){}destroy(){let e;try{this.clear()}catch(t){e=t}if(e)throw e}}class On extends Cn{constructor(e,t){super(),this.type="node",this._committedValue=gn,this._itemKeys=null,this._asyncSource=null,this._asyncVersion=0,this._asyncIterator=null,this._asyncRunning=!1,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1,this._committingAsyncValue=!1,this.startNode=e,this.endNode=t}commit(e){if(e!==vn)if((e=>!!e&&"function"==typeof e.then)(e)||An(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==tn&&null!=e&&""!==e)Nn(e)?e!==this._committedValue&&this._commitText(e):Zt(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===sn}(e)?0===e.values.length?this.commit(e.empty??tn):this._commitIterable(e.values,e.keys):rn(e)?this._commitUnsafeHTML(e):void 0===e.nodeType?(e=>Array.isArray(e)||"function"==typeof e?.[Symbol.iterator])(e)?this._commitIterable(e):this._commitText(e):this._commitNode(e);else{if(this._committedValue!==tn){const e=this._clear();if(this._committedValue=tn,e)throw e}this._committedValue=tn}}_commitText(e){if(this._committedValue!==gn&&this._committedValue!==tn&&Nn(this._committedValue)&&!Array.isArray(this._committedValue)){const t=this.startNode.nextSibling;if(t&&t.nodeType===Node.TEXT_NODE)return t.data=String(e),void(this._committedValue=e)}const t=this._clear();if(this._insertBefore(document.createTextNode(String(e))),this._committedValue=e,t)throw t}_commitTemplateResult(e){const t=this._committedValue;if(t instanceof xn){const n=yn.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new xn(e),o=n.renderFragment();try{n.update(e.values)}catch(e){throw n.clear(),e}const r=this._committedValue,s=this._itemKeys,i=this.endNode.ownerDocument.createDocumentFragment();let a=this.startNode.nextSibling;for(;a&&a!==this.endNode;){const e=a.nextSibling;i.appendChild(a),a=e}this._insertBefore(o),this._committedValue=n,this._itemKeys=null;try{this.isConnected&&n.reconnected()}catch(e){try{n.clear()}catch(e){console.error("snice: failed to clean up a rejected nested template:",e)}let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const e=t.nextSibling;t.remove(),t=e}throw this._insertBefore(i),this._committedValue=r,this._itemKeys=s,e}this._disposeCommitted(r)}_commitIterable(e,t){const n=Array.isArray(e)?e:Array.from(e),o=t?Array.from(t):n.map(_n);if(o.length!==n.length)throw new Error("snice: keyed iterable produced a different number of keys and values.");const r=o.filter(e=>void 0!==e);if(r.length>0&&r.length!==o.length&&console.warn("snice: a list mixes keyed and unkeyed items. Identity falls back to position; use repeat(items, { key, render }) for deterministic updates."),r.length>0&&new Set(r).size!==r.length)throw new Error("snice: a keyed list contains duplicate keys.");let s;Array.isArray(this._committedValue)&&this._committedValue[0]instanceof On||(s=this._clear(),this._committedValue=[],this._itemKeys=null);const i=n.length>0&&o.every(e=>void 0!==e),a=this._itemKeys;if(i&&a&&this._committedValue.length>0&&(a.length!==o.length||!o.every((e,t)=>e===a[t]))){if(s??=this._reconcileKeyed(n,o,this._committedValue,a),this._itemKeys=o,s)throw s;return}const c=this._committedValue;let l=0;for(const e of n){let t;if(l>=c.length){const e=document.createComment(""),n=document.createComment("");this._insertBefore(e),this._insertBefore(n),t=new On(e,n),c.push(t)}else t=c[l];t.commit(e),l++}if(l<c.length){for(let e=l;e<c.length;e++){const t=c[e];try{t.destroy()}catch(e){s??=e}t.startNode.remove(),t.endNode.remove()}c.length=l}if(this._itemKeys=i?o:null,s)throw s}_reconcileKeyed(e,t,n,o){const r=this.endNode.parentNode;let s;const i=new Map;for(let e=0;e<n.length;e++)i.has(o[e])||i.set(o[e],n[e]);const a=new Set,c=new Array(e.length).fill(null);for(let n=0;n<e.length;n++){const e=i.get(t[n]);e&&!a.has(e)&&(a.add(e),c[n]=e)}for(const e of n)if(!a.has(e)){try{e.destroy()}catch(e){s??=e}e.startNode.remove(),e.endNode.remove()}let l=this.startNode.nextSibling;for(let t=0;t<c.length;t++){let n=c[t];if(n)if(n.startNode===l)l=n.endNode.nextSibling;else{const e=document.createDocumentFragment();let t=n.startNode;const o=n.endNode.nextSibling;for(;t&&t!==o;){const n=t.nextSibling;e.appendChild(t),t=n}r.insertBefore(e,l)}else{const e=document.createComment(""),o=document.createComment("");r.insertBefore(e,l),r.insertBefore(o,l),n=new On(e,o),c[t]=n}n.commit(e[t])}return this._committedValue=c,s}_commitNode(e){if(this._committedValue!==e){const t=this._clear();if(this._insertBefore(e),this._committedValue=e,t)throw t}}_commitUnsafeHTML(e){const t=this._committedValue;if(rn(t)&&t.html===e.html)return;const n=this._clear(),o=document.createElement("template");if(o.innerHTML=e.html,this._insertBefore(o.content),this._committedValue=e,n)throw n}_commitAsync(e){if(e===this._asyncSource)return;this._cancelAsync(!1),this._asyncSource=e,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1;const t=this._clear();if(this._committedValue=tn,this._startAsyncSource(),t)throw t}_startAsyncSource(e=!1){const t=this._asyncSource;if(!t||this._asyncRunning||this._asyncCompleted||!e&&!this.isConnected)return;this._asyncRunning=!0,this._asyncStarted=!0,this._asyncPaused=!1;const n=++this._asyncVersion;if(An(t)){try{this._asyncIterator=t[Symbol.asyncIterator]()}catch(e){return this._asyncRunning=!1,this._asyncCompleted=!0,void console.error("snice: async iterable template value failed:",e)}(async()=>{try{for(;this._asyncIterator;){const e=await this._asyncIterator.next();if(e.done||n!==this._asyncVersion)break;this._commitAsyncValue(e.value)}}catch(e){n===this._asyncVersion&&console.error("snice: async iterable template value failed:",e)}finally{n===this._asyncVersion&&(this._asyncIterator=null,this._asyncRunning=!1,this._asyncCompleted=!0)}})()}else Promise.resolve(t).then(e=>{if(n===this._asyncVersion){this._asyncRunning=!1,this._asyncCompleted=!0;try{this._commitAsyncValue(e)}catch(e){console.error("snice: promise template value failed:",e)}}},e=>{n===this._asyncVersion&&(this._asyncRunning=!1,this._asyncCompleted=!0,console.error("snice: promise template value failed:",e))})}_commitAsyncValue(e){this._committingAsyncValue=!0;try{this.commit(e)}finally{this._committingAsyncValue=!1}}_cancelAsync(e){this._asyncVersion++;const t=this._asyncIterator;if(this._asyncIterator=null,this._asyncRunning=!1,e&&(this._asyncSource=null,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1),t?.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}_insertBefore(e){this.endNode.parentNode?.insertBefore(e,this.endNode)}_clear(){const e=this.startNode.parentNode,t=this._committedValue;let n;try{this._disposeCommitted(t)}catch(e){n=e}if(!e)return this._committedValue=tn,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=tn,n}_disposeCommitted(e){let t;if(e instanceof xn)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof On)try{n.destroy()}catch(e){t??=e}if(t)throw t}clear(){this._cancelAsync(!0);const e=this._clear();if(e)throw e}get isConnected(){return this.startNode.isConnected}disconnected(e=!1){let t;if(this._committedValue instanceof xn)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof On)try{n.disconnected(e)}catch(e){t??=e}if(this._asyncSource&&this._asyncRunning&&(this._cancelAsync(!1),this._asyncPaused=!0),t)throw t}reconnected(){let e;if(this._committedValue instanceof xn)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof On)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class kn extends Cn{constructor(e,t,n){super(),this.type="attribute",this._committedValue=gn,this.lastValues=null,this.lastValueIndex=0,this.element=e,this.name=t,n&&(n.length>2||""!==n[0]||""!==n[1])?(this._committedValue=new Array(n.length-1).fill(gn),this.strings=n):this._committedValue=gn}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===vn)return;if(o=!Nn(e)||e!==this._committedValue&&e!==vn,!o)return;this._committedValue=e,n=e}else{const r=e;this.lastValues=[...r],this.lastValueIndex=t;const s=this._committedValue;n=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let i=r[t+e];i===vn&&(i=s[e],i===gn&&(i="")),o=o||!Nn(i)||i!==s[e],i===tn?n=tn:n!==tn&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===tn?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class $n extends Cn{constructor(e,t){super(),this.type="node",this.lastValues=null,this.lastValueIndex=0,this.node=e,this.strings=t,this._committedValues=new Array(t.length-1).fill(gn)}commit(e,t=0){const n=e;this.lastValues=[...n],this.lastValueIndex=t;let o=!1,r=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let s=n[t+e];s===vn&&(s=this._committedValues[e],s===gn&&(s="")),o=o||!Nn(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===tn?"":s??"")+this.strings[e+1]}if(o){if(r.includes("--")||r.endsWith("-"))throw new Error('snice: comment expressions cannot produce "--" or end with "-".');this.node.data=r}}clear(){}}class Ln extends Cn{constructor(e,t){super(),this.type="class",this.committed=gn,this.element=e,this.name=t}commit(e){if(e===vn)return;const t=e!==tn&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=gn}}class Pn extends Cn{constructor(e,t){super(),this.type="style",this.committed=gn,this.element=e,this.name=t}commit(e){if(e===vn||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===tn||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=gn}}class jn extends Cn{constructor(e,t){super(),this.type="spread",this.committed={},this.listeners=new Map,this.consumedOnce=new Map,this.element=e,this.name=t}commit(e){if(e===vn)return;if(e!==tn&&null!=e||(e={}),"object"!=typeof e||Array.isArray(e))throw new TypeError(`snice: ...${this.name} expects an object.`);const t=e;"events"===this.name?this.commitEvents(t):"props"===this.name||"properties"===this.name?this.commitProperties(t):this.commitAttributes(t),this.committed={...t}}commitProperties(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||bn(this.element,t,void 0);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||bn(this.element,t,n===tn?void 0:n)}commitAttributes(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||this.element.removeAttribute(t);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(n===tn||null==n||!1===n?this.element.removeAttribute(t):this.element.setAttribute(t,!0===n?"":String(n)))}commitEvents(e){!function(e,t){const n=new Set;for(const[o,r]of Object.entries(e)){const e=o.startsWith("@")?o.slice(1):o;if(!e)throw new TypeError(`snice: ${t} contains an empty event name.`);if(n.has(e))throw new TypeError(`snice: ${t} contains duplicate event name "${e}".`);if(n.add(e),r!==tn&&null!=r&&!1!==r&&"function"!=typeof r&&(!r||"object"!=typeof r||"function"!=typeof r.handleEvent))throw new TypeError(`snice: ${t} event "${e}" expects a function, EventListenerObject, or null.`)}}(e,`...${this.name}`);for(const[t,n]of this.consumedOnce){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n)||this.consumedOnce.delete(t)}for(const[t,n]of this.listeners){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n.value)||(this.element.removeEventListener(t,n.listener,n.options),this.listeners.delete(t))}for(const[t,n]of Object.entries(e)){const e=this.eventName(t);if(this.listeners.has(e))continue;const o=!!n&&"object"==typeof n&&"function"==typeof n.handleEvent;if(n===tn||null==n||!1===n)continue;if(this.consumedOnce.has(e)&&Object.is(this.consumedOnce.get(e),n))continue;this.consumedOnce.delete(e);const r=o?n:void 0,s=t=>{r?.once&&this.consumedOnce.set(e,n),o?n.handleEvent(t):n.call(this.resolveHost(),t)};this.element.addEventListener(e,s,r),this.listeners.set(e,{value:n,listener:s,options:r})}}eventName(e){return e.startsWith("@")?e.slice(1):e}resolveHost(){return un(this.element)||this.element}clear(){if("events"===this.name){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear(),this.consumedOnce.clear()}else if("props"!==this.name&&"properties"!==this.name)for(const e of Object.keys(this.committed))this.element.removeAttribute(e);this.committed={}}disconnected(e=!1){"events"!==this.name||e||this.detachListeners()}reconnected(){"events"===this.name&&0===this.listeners.size&&this.commitEvents(this.committed)}detachListeners(){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear()}}class Mn extends Cn{constructor(e,t){super(),this.type="property",this._committedValue=gn,this.element=e,this.name=t}commit(e){if(e!==vn){if(function(e){return e&&e._$liveMarker$===wn}(e)){if((e=e.value)===vn)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,bn(this.element,this.name,e===tn?void 0:e)}}clear(){this._committedValue=gn}}class Rn extends Cn{constructor(e){super(),this.type="controller",this._committedValue=gn,this.element=e}commit(e){if(e===vn)return;const t=null==e||!1===e||""===e||e===tn?null:e,n=this._committedValue===gn,o=n?null:this._committedValue;if(!n&&t===o)return;this._committedValue=t;const r=this.element;"function"==typeof o&&"function"!=typeof t&&(void 0!==r[O]?delete r[O]:r[i]?r.controller=null:this._detach()),"function"==typeof t?this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[i]&&(r[O]=t):"string"==typeof t?this.element.setAttribute("controller",t):"string"==typeof o&&this.element.removeAttribute("controller")}_apply(e){const t=this.element;t[i]?t.controller!==e?t.controller=e:this._attach(e):this.element.localName.includes("-")?t[O]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){Wt(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){zt(this.element).catch(e=>{console.error("Failed to detach controller:",e)})}disconnected(e=!1){if("function"!=typeof this._committedValue)return;const t=this.element;void 0===t[O]&&(t[i]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[O]&&delete e[O];const t=this._committedValue;this._committedValue=gn,"function"==typeof t&&(e[i]||this._detach())}}class In extends Cn{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=gn,this.element=e,this.name=t}commit(e){if(e===vn)return;const t=!!e&&e!==tn;t!==this._committedValue&&(this._committedValue=t,t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name))}clear(){this.element.removeAttribute(this.name),this._committedValue=gn}}class Dn extends Cn{constructor(e,t){super(),this.type="event",this.listener=null,this.listenerOptions=void 0,this.value=void 0,this.keyFilter=null,this.host=null,this.modifiers=new Set,this.once=!1,this.onceConsumed=!1,this.element=e;const[n,...o]=t.split("|"),r={preventdefault:"prevent",stoppropagation:"stop",stopimmediatepropagation:"immediate"},s=new Set(["prevent","stop","immediate","once","capture","passive","self"]);for(const e of o){const n=r[e.toLowerCase()]||e.toLowerCase();if(!s.has(n))throw new Error(`snice: unknown event modifier "${e}" in @${t}. Supported modifiers: prevent, stop, immediate, once, capture, passive, self.`);this.modifiers.add(n)}if(this.modifiers.has("passive")&&this.modifiers.has("prevent"))throw new Error(`snice: @${t} cannot combine passive and prevent.`);const i=["keydown","keyup","keypress"].includes(n.split(".")[0].split(":")[0]),a=i?n.indexOf("."):-1,c=i?n.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c);if(l>0){const e=n.substring(0,l),t=n.substring(l+1);this.eventName=e,this.keyFilter=St(t)}else this.eventName=n,At(n)}commit(e){if(e===vn)return;e===tn&&(e=null);const t=!!e&&"object"==typeof e&&"function"==typeof e.handleEvent;if(null!=e&&!1!==e&&"function"!=typeof e&&!t)throw new TypeError(`snice: @${this.eventName} expects a function, EventListenerObject, or null.`);if(t&&this.modifiers.has("prevent")&&e.passive)throw new Error(`snice: @${this.eventName} cannot combine a passive listener object with prevent.`);if(e!==this.value||null==e){if(this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0),null==e||!1===e)return this.value=e,void(this.onceConsumed=!1);this.onceConsumed=!1;try{this.attachListener(e,t),this.value=e}catch(e){throw this.value=void 0,e}}}attachListener(e,t){const n=this.keyFilter,o=r=>{this.modifiers.has("self")&&r.target!==this.element||n&&!_t(r,n)||(this.once&&(this.onceConsumed=!0,this.element.removeEventListener(this.eventName,o,s),this.listener=null,this.listenerOptions=void 0),this.modifiers.has("prevent")&&r.preventDefault(),this.modifiers.has("immediate")?r.stopImmediatePropagation():this.modifiers.has("stop")&&r.stopPropagation(),t?e.handleEvent(r):(this.host||(this.host=un(this.element)),e.call(this.host||this.element,r)))},r=t?e:{};this.once=this.modifiers.has("once")||!!r.once;const s={capture:this.modifiers.has("capture")||r.capture,passive:this.modifiers.has("passive")||r.passive,signal:r.signal};this.element.addEventListener(this.eventName,o,s),this.listener=o,this.listenerOptions=s}clear(){this.detachListener(),this.value=void 0,this.host=null,this.onceConsumed=!1}detachListener(){this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0)}disconnected(e=!1){e||this.detachListener(),this.host=null}reconnected(){this.listener||this.onceConsumed||null==this.value||!1===this.value||this.attachListener(this.value,"object"==typeof this.value)}}const Vn=Symbol("not-set");class qn extends Cn{constructor(e){super(),this.type="node",this.conditions=[Vn],this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const t=e.parentNode;this.startNode=document.createComment("if"),this.endNode=document.createComment("/if"),t.insertBefore(this.startNode,e),t.insertBefore(this.endNode,e.nextSibling);const n=document.createDocumentFragment();this.branches.push(n);let o=!1,r=n;for(const t of Array.from(e.childNodes)){const e=t.nodeType===Node.ELEMENT_NODE?t.tagName.toLowerCase():"";if("else-if"===e||"else"===e){o=!0;const n=t,s=document.createDocumentFragment();for(;n.firstChild;)s.appendChild(n.firstChild);const i=this.branches.push(s)-1;if(r=s,"else-if"===e){if(-1!==this.defaultBranch)throw new Error("snice: <else> must be the final branch inside <if>.");this.conditions[i]=Vn,Bn.set(n,{coordinator:this,index:i})}else{if(-1!==this.defaultBranch)throw new Error("snice: <if> may contain only one <else> branch.");this.defaultBranch=i}n.remove();continue}o?t.nodeType!==Node.TEXT_NODE||t.textContent?.trim()?r.appendChild(t):t.remove():n.appendChild(t)}t.removeChild(e)}commit(e){e!==vn&&(this.conditions[0]=e)}setAlternative(e,t){t!==vn&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==Vn&&this.conditions[t]!==tn&&Boolean(this.conditions[t])){e=t;break}-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e],this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch];let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const Bn=new WeakMap;class Fn extends Cn{constructor(e){super(),this.type="node";const t=Bn.get(e);if(!t)throw new Error("snice: <else-if> must be a direct child of <if>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setAlternative(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}class Wn extends Cn{constructor(e,t){super(),this.type="node",this.value=Vn,this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const n=e.parentNode;this.startNode=document.createComment("case"),this.endNode=document.createComment("/case"),n.insertBefore(this.startNode,e),n.insertBefore(this.endNode,e.nextSibling);for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();if("when"===e){const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);const o=t.has(n),r=this.branches.push({fragment:e,dynamic:o,expected:o?Vn:n.getAttribute("value")??""})-1;o&&zn.set(n,{coordinator:this,index:r})}else if("default"===e){if(-1!==this.defaultBranch)throw new Error("snice: <case> may contain only one <default> branch.");const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);this.defaultBranch=this.branches.push({fragment:e,dynamic:!1,expected:Vn})-1}}n.removeChild(e)}commit(e){e!==vn&&(this.value=e)}setExpected(e,t){t!==vn&&(this.branches[e].expected=t)}flush(){let e=this.branches.findIndex((e,t)=>t!==this.defaultBranch&&(e.dynamic?Object.is(this.value,e.expected):String(this.value)===e.expected));-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].fragment.hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e].fragment,this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch].fragment;let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const zn=new WeakMap;class Un extends Cn{constructor(e){super(),this.type="node";const t=zn.get(e);if(!t)throw new Error("snice: dynamic <when> must be a direct child of <case>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setExpected(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}const Hn=new WeakSet,Kn=new WeakSet,Gn=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","object","embed","summary","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function Qn(e){try{e.focus()}catch{return!1}return function(e){const t=e.getRootNode().activeElement;return t===e||Boolean(t&&e.contains(t))}(e)}function Jn(e){return e?Array.from(e.querySelectorAll("[autofocus]")).filter(e=>!Kn.has(e)):[]}function Xn(e){return e?Array.from(e.querySelectorAll(Gn)):[]}function Yn(e){if(Hn.has(e)||!function(e){return!(!e.hasAttribute("autofocus")||Kn.has(e))||Jn(ln(e)).length>0}(e))return;Hn.add(e);const t=()=>{const t=e.ownerDocument.defaultView,n=()=>{Hn.delete(e),function(e){if(!e.isConnected)return;const t=ln(e),n=[];if(e.hasAttribute("autofocus")&&!Kn.has(e)&&n.push(e),n.push(...Jn(t)),0!==n.length)if(function(e){const t=e.activeElement;return Boolean(t&&t!==e.body&&t!==e.documentElement)}(e.ownerDocument))for(const e of n)Kn.add(e);else for(const o of n){if(Kn.add(o),Qn(o))return;if(o===e)for(const e of Xn(t))if(Qn(e))return}}(e)};t?.requestAnimationFrame?t.requestAnimationFrame(n):queueMicrotask(n)};Promise.resolve(e.ready).then(t,t)}let Zn=!1;function eo(e){Zn=e}function to(e){e[m]||(e[f]=new Promise(t=>{e[m]=t}))}function no(e){const t=e[m];t&&(e[m]=null,t())}const oo=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?ao(e,t):(this.pending.add(e),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush())))}flush(){const e=Array.from(this.pending);this.pending.clear(),this.scheduled=!1;for(const t of e)t.isConnected?ao(t,t[ee]||{}):t[p]=!0}remove(e){this.pending.delete(e)}};function ro(e){return Object.prototype.hasOwnProperty.call(e,te)}function so(e){const t=e[oe];if(!t||0===t.length)return;const n=[...t];e[oe]=[],n.forEach(e=>e())}const io=50;function ao(e,t,n){const o=arguments.length>=3,r=e[Z];if(!r)return void no(e);if(t.once&&ro(e))return void no(e);const s=e[y]??0;if(s>=io){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${io}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void no(e)}e[y]=s+1;try{const s=o?n:r.call(e),i=hn(e);if(!1===t.differential){if("string"!=typeof s)return void console.warn("Render method with differential: false must return a string");const t=document.createElement("template");t.innerHTML=s;const n=e[te];n?.clear();const o=Array.from(i.childNodes).filter(e=>!(e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")));for(const e of o)e.remove();return i.appendChild(t.content),e[te]=null,so(e),void Yn(e)}if(!Zt(s))return void console.warn("Render method must return html`` template result");let a=e[te];if(a&&a.isSameTemplate(s.strings))return a.update(s.values),so(e),void Yn(e);const c=new xn(s),l=c.renderFragment();try{c.update(s.values)}catch(e){throw c.clear(),e}const h=document.createDocumentFragment();for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||h.appendChild(e);i.appendChild(l);try{e.isConnected&&c.reconnected()}catch(e){try{c.clear()}catch(e){console.error("snice: failed to clean up a rejected render tree:",e)}for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||e.remove();throw i.appendChild(h),e}let u;e[te]=c;try{a?.clear()}catch(e){u=e}if(so(e),Yn(e),u)throw u}catch(t){const n=function(e,t){const n=e.tagName?.toLowerCase()||"element",o=t instanceof Error?t.message:String(t),r=new Error(`snice: render failed for <${n}>: ${o}`,{cause:t});return t instanceof Error&&(r.name=t.name),r}(e,t);if(Zn)throw n;console.error("Error rendering element:",n)}finally{e[y]=s,no(e)}}function co(e,t=!1){const n=e[ee]||{};if(n.once&&ro(e))e.isConnected&&lo(e);else if(to(e),t)ao(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[ne]||(e[ne]={}),clearTimeout(e[ne].debounce),void(e[ne].debounce=setTimeout(()=>{e[ne].debounce=null,oo.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[ne]||(e[ne]={lastThrottle:0});const t=e[ne],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void oo.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),oo.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}oo.schedule(e,n)}}function lo(e){const t=e[te];t?.reconnected()}function ho(e={}){return function(t,n){return n.addInitializer(function(){this[Z]=t,this[ee]=e}),function(...n){const o=t.apply(this,n);return ao(this,{...this[ee]||e,once:!1},o),o}}}function uo(){return function(e,t){return t.addInitializer(function(){this[re]&&!this[ie]?this[ie]=[this[re]]:this[re]&&this[ie]&&this[ie].push(this[re]),this[re]=e}),e}}function fo(e,t){return function(n,o){return function(...r){this[Y]||(this[Y]=new Map);const s=`${e}_${o.name}`;this[Y].has(s)||this[Y].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[Y].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===t?.dispatchOnUndefined)return;const o=new CustomEvent(e,{bubbles:t?.bubbles??!0,cancelable:t?.cancelable??!1,composed:t?.composed??!0,detail:n});if(void 0!==t?.scope&&void 0!==t?.daemon)throw new TypeError(`@dispatch('${e}') cannot use both scope and daemon.`);if(void 0!==t?.daemon)return void yt(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=Ye(this,t.scope);return n?void n.dispatchEvent(o):void console.warn(`[snice/@dispatch] scope did not resolve for "${e}" — event not dispatched.`)}const r=gt(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},l=e=>{if(t?.debounce)return clearTimeout(i.debounceTimeout),void(i.debounceTimeout=setTimeout(()=>c(e),t.debounce));if(!t?.throttle)return void c(e);const n=Date.now(),o=t.throttle-(n-i.throttleLastCall);if(o<=0)return clearTimeout(i.throttleTimeout),i.throttleLastCall=n,void c(e);i.latestDetail=e,i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null;const e=i.latestDetail;i.latestDetail=void 0,c(e)},o))};return a instanceof Promise?a.then(e=>(l(e),e)):(l(a),a)}}}function mo(e){const t=e[Y];if(t)for(const e of t.values())e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.throttleTimeout&&clearTimeout(e.throttleTimeout),e.debounceTimeout=null,e.throttleTimeout=null,e.throttleLastCall=0,e.latestDetail=void 0}const po=t("debounce-timers"),yo=t("throttle-timers"),go=t("once-called"),bo=t("memoize-cache");function vo(e=300,t={}){const{leading:n=!1,trailing:o=!0,maxWait:r}=t;return function(t,s){const i=s.name;return function(...s){this[po]||(this[po]={});const a=this[po],c=i;a[c]&&clearTimeout(a[c].timeout);const l=Date.now(),h=!a[c],u=h?l:a[c].startTime,d=void 0!==r&&l-u>=r;if(n&&h){const e=t.apply(this,s);return a[c]={timeout:null,startTime:u,lastArgs:s},e}const f=setTimeout(()=>{(o||d)&&t.apply(this,a[c].lastArgs),delete a[c]},d?0:e);a[c]={timeout:f,startTime:u,lastArgs:s}}}}function wo(e=300,t={}){const{leading:n=!0,trailing:o=!0}=t;return function(t,r){const s=r.name;return function(...r){this[yo]||(this[yo]={});const i=this[yo],a=s,c=Date.now();if(!i[a])return n&&t.apply(this,r),i[a]={lastInvoke:c,timeout:null,lastArgs:r},void(o&&!n&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),delete i[a]},e)));const l=c-i[a].lastInvoke;if(i[a].lastArgs=r,i[a].timeout&&clearTimeout(i[a].timeout),l>=e)return t.apply(this,r),void(i[a].lastInvoke=c);o&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),i[a].lastInvoke=Date.now(),i[a].timeout=null},e-l))}}}function Eo(e=!0){let t,n=!1;return function(o,r){const s=r.name;return function(...r){return e?(this[go]||(this[go]={}),this[go][s]||(this[go][s]={called:!0,result:o.apply(this,r)}),this[go][s].result):(n||(n=!0,t=o.apply(this,r)),t)}}}function No(e={}){const{keyGenerator:t=(...e)=>JSON.stringify(e),maxSize:n=100,ttl:o}=e;return function(e,r){const s=r.name;return function(...r){this[bo]||(this[bo]={}),this[bo][s]||(this[bo][s]=new Map);const i=this[bo][s],a=t(...r);if(i.has(a)){const e=i.get(a);if(!(void 0!==o&&Date.now()-e.timestamp>o))return e.value;i.delete(a)}const c=e.apply(this,r);if(i.set(a,{value:c,timestamp:Date.now()}),i.size>n){const e=i.keys().next().value;i.delete(e)}return c}}}function Ao(e){if(e[po]){for(const t in e[po])e[po][t]?.timeout&&clearTimeout(e[po][t].timeout);e[po]={}}}function So(e){if(e[yo]){for(const t in e[yo])e[yo][t]?.timeout&&clearTimeout(e[yo][t].timeout);e[yo]={}}}function To(e,t){e[bo]&&(t?delete e[bo][t]:e[bo]={})}function _o(e,t){e[go]&&(t?delete e[go][t]:e[go]={})}function xo(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.configurable?{locked:!1,value:void 0}:"value"in n&&!1===n.writable?{locked:!0,value:n.value}:"value"in n||void 0!==n.get?{locked:!1,value:void 0}:{locked:!0,value:void 0}}function Co(e){e.prototype[i]=!0;const t=e.prototype.connectedCallback,n=e.prototype.disconnectedCallback,o=e.prototype.attributeChangedCallback,r=e.observedAttributes||[];r.includes("controller")||r.push("controller"),r.includes("autofocus")||r.push("autofocus");const s=e[$];if(s)for(const[e,t]of s){if(!1===t.attribute)continue;const n=Fe(t,e);r.includes(n)||r.push(n)}Object.defineProperty(e,"observedAttributes",{get:()=>r,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get(){return this[l]||(this[l]=new Promise((e,t)=>{this[h]=e,this[u]=t}),this[l].catch(()=>{})),this[l]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[m]?this[f]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[v]},set(e){const t=this[v];if(this[v]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void Wt(this,e).catch(n=>{"ControllerAttachAborted"!==n?.name?"string"!=typeof e||n?.message!==`Controller "${e}" not found in registry`?console.error(`Failed to attach controller "${t}":`,n):Vt(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&zt(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[l]||(this[l]=new Promise((e,t)=>{this[h]=e,this[u]=t}),this[l].catch(()=>{})),this[w]){try{lo(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}$t(this,this),wt(this,this),Mt(this,"task");try{ot(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[U];if(n)for(const e of n)try{const t=e.method.call(this);t&&"function"==typeof t.then&&t.catch(t=>{console.error(`Error in @reconnect handler ${e.methodName}:`,t)})}catch(t){console.error(`Error in @reconnect handler ${e.methodName}:`,t)}return this[Z]&&this[p]&&(this[p]=!1,co(this)),void Yn(this)}this[I]=!0;const n=e[$];if(n)for(const[e,t]of n){if(!1===t.attribute)continue;const n=Fe(t,e);if(!this.hasAttribute(n))continue;const o=this.getAttribute(n);Ke(this,V).add(e),t.type===Boolean&&""===o&&this.setAttribute(n,"true"),this[e]=qe(o,t)}if(this[M]){for(const[e,t]of Array.from(this[M].entries())){const o=n?.get(e),r=Fe(o||{},e);this[M].delete(e),this.hasAttribute(r)||(this[e]=t)}delete this[M]}if(void 0!==this[O]){const e=this[O];if(delete this[O],!this[v]){this[v]=e;const t=e?.name||"(anonymous controller class)";Wt(this,e).catch(e=>{"ControllerAttachAborted"!==e?.name?console.error(`Failed to attach controller "${t}":`,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}if(this.hasAttribute("controller")&&!this[v]){const e=this.getAttribute("controller");e&&(this.controller=e)}if(function(e){const t=e[re],n=[],o=[];let r=e.constructor;for(;r&&r!==HTMLElement&&r!==Function.prototype;)o.unshift(r),r=Object.getPrototypeOf(r);for(const e of o){if(!Object.prototype.hasOwnProperty.call(e,"styles"))continue;const t=e.styles,o=Array.isArray(t)?t:[t];for(const e of o)en(e)?n.push(e):console.warn("Static styles must be a css`` result or an array of css`` results")}if((t||0!==n.length)&&!e[se]){e[se]=!0;try{const o=[...n],r=e[ie];if(r)for(const t of r){const n=t.call(e);en(n)&&o.push(n)}if(t){const n=t.call(e);if(!en(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=hn(e),i=Array.from(s.childNodes).filter(e=>e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style"));if(i.length===o.length&&i.every((e,t)=>e.textContent===o[t].cssText))return;for(const e of i)e.remove();if(s instanceof ShadowRoot&&o.every(e=>!!e.styleSheet)&&"adoptedStyleSheets"in s)try{return void(s.adoptedStyleSheets=o.map(e=>e.styleSheet))}catch{}for(const e of o){const t=document.createElement("style");t.setAttribute("data-snice-style",""),t.textContent=e.cssText,s.appendChild(t)}}catch(e){console.error("Error applying styles:",e)}}}(this),this[Z])try{hn(this)}catch{}$t(this,this),wt(this,this),Mt(this,"task"),this[w]=!0,function(e,t){if(et.has(t))return;et.add(t);const n=t[D];if(!n||0===n.size)return;const o=t[$],r=new Set(["*"]);if(o)for(const[e,t]of o)r.add(e),"string"==typeof t?.attribute&&r.add(t.attribute);for(const t of n.keys()){if(r.has(t))continue;const n=e.tagName?e.tagName.toLowerCase():"element",s=o?[...o.keys()].join(", "):"(none)";console.warn(`@watch('${t}') on <${n}> matches no @property — it will never fire. Known properties: ${s}.`)}}(this,e),function(e,t){const n=t[D],o=t[$];if(n&&o)for(const[t,r]of o){const o=[t],s=r&&"string"==typeof r.attribute?r.attribute:null;s&&s!==t&&o.push(s),o.push("*");for(const r of o)if(n.has(r))for(const o of n.get(r))if(o.immediate)try{o.method.call(e,void 0,e[t],t)}catch(e){console.error(`Error in @watch('${r}') method ${o.methodName}:`,e)}}}(this,e),t&&t.call(this);const o=e[W];if(await new Promise(e=>queueMicrotask(e)),!this.isConnected)return void(this[h]&&(this[h](),this[h]=null,this[u]=null));this[Z]&&co(this,!0);try{ot(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName}:`,e)}if(await new Promise(e=>queueMicrotask(e)),!this.isConnected)return void(this[h]&&(this[h](),this[h]=null,this[u]=null));let r,s=!1;if(o){this[d]=!0;try{for(const e of o)try{await e.method.call(this)}catch(t){console.error(`Error in @ready handler ${e.methodName}:`,t),s||(s=!0,r=t)}}finally{delete this[d]}}s&&this[u]?(this[u](r),this[h]=null,this[u]=null):this[h]&&(this[h](),this[h]=null,this[u]=null),Yn(this)},e.prototype.disconnectedCallback=async function(){try{!function(e){const t=e[te];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[z];if(t)for(const e of t)try{await e.method.call(this)}catch(t){console.error(`Error in @dispose handler ${e.methodName}:`,t)}n&&n.call(this),this[v]&&zt(this).catch(e=>{console.error("Failed to detach controller:",e)}),Lt(this),Et(this),Rt(this),ct(this),Ao(this),So(this),function(e){const t=e[ne];if(!t)return!1;let n=!1;return t.debounce&&(clearTimeout(t.debounce),t.debounce=null,n=!0),t.throttleTimer&&(clearTimeout(t.throttleTimer),t.throttleTimer=null,n=!0),n}(this)&&(this[p]=!0),mo(this),Uo(this,J),Uo(this,X)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t){if(this[C])return;return this[x]?void Ft(this):void(this.controller=r)}"autofocus"===t&&(null===r?Kn.delete(this):this[w]&&Yn(this));const s=e[$];if(s)for(const[n,o]of s){if(Fe(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[Q]?.has(t.toLowerCase()))break;const s=this[L]?.[n],i=this[P]?.[n];let a=null===r?o.type!==Boolean&&i:qe(r,o,s,i);const c=this[j]?.[n];if(c&&(a=c(a)),!(o?.hasChanged?o.hasChanged(a,s):Be(a,s)))break;Ke(this,V).add(n),Ge(this,L)[n]=a,this[w]&&Qe(this,e,n,s,a),this[Z]&&this[w]&&co(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[H];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @moved handler ${e.methodName}:`,t)}},e.prototype.adoptedCallback=async function(){const t=e[K];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function Oo(e,t,n,o){if(function(e){let t=Object.getPrototypeOf(e);const n=[];for(;t&&t!==HTMLElement&&t!==Function.prototype;)n.push(t),t=Object.getPrototypeOf(t);n.reverse();for(const t of n){if(t[$]){e[$]||(e[$]=new Map);for(const[n,o]of t[$])e[$].has(n)||e[$].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[$]){t[$]||(t[$]=new Map);for(const[e,o]of n.metadata[$])t[$].set(e,o)}else if(Lo.length>0){t[$]||(t[$]=new Map);const e=Lo.pop();for(const[n,o]of e)t[$].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[b]||{}},s=o||{};if("light"===s.renderRoot&&"string"==typeof s.shadow||"shadow"===s.renderRoot&&!1===s.shadow)throw new TypeError("snice: @element renderRoot and shadow options select conflicting render roots.");const i={...r,...s};return Object.prototype.hasOwnProperty.call(s,"shadow")?i.renderRoot=!1===s.shadow?"light":"shadow":Object.prototype.hasOwnProperty.call(s,"renderRoot")&&("light"===s.renderRoot?i.shadow=!1:!1===i.shadow&&(i.shadow="open")),t[b]=i,!0===t.prototype[ae]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,Z)&&"function"==typeof t.prototype.render&&(t.prototype[Z]=t.prototype.render,t.prototype[ee]=t.renderOptions||{}),Co(t),customElements.get(e)?(globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),t)}function ko(e,t){if(void 0!==t?.renderRoot&&"shadow"!==t.renderRoot&&"light"!==t.renderRoot)throw new TypeError('snice: @element renderRoot must be "shadow" or "light".');if(void 0!==t?.shadow&&!1!==t.shadow&&"open"!==t.shadow&&"closed"!==t.shadow)throw new TypeError('snice: @element shadow must be "open", "closed", or false.');return function(n,o){return Oo(e,n,o,t)}}function $o(e){return function(t,n){return Oo(e,t,n)}}const Lo=[],Po=new WeakMap;function jo(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[$]||(n.metadata[$]=new Map),n.metadata[$].set(o,e||{})):(0===Lo.length&&Lo.push(new Map),Lo[Lo.length-1].set(o,e||{})),function(t){const n=this[R],r=!0===n?.delete(o);0===n?.size&&delete this[R];const s=Object.prototype.hasOwnProperty.call(this,o),i=s&&(r||!function(e,t,n){const o=e?.ownerDocument;if(!o?.createElement)return!1;let r=Po.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);Po.set(o,r)}return r.has(t)&&Object.is(r.get(t),n)}(this,o,this[o])),a=i?this[o]:t;s&&delete this[o];const c=this.constructor;c[$]||(c[$]=new Map);const l={...e};l.type||void 0===t||(l.type=Ve(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[$].set(o,l),Ge(this,P)[o]=t;const h=()=>{if(!this[I])return;const e=this[L]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=Fe(l,o),r=Ze(e,l,t),s=n.toLowerCase();Ke(this,Q).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[Q].delete(s)}}this[w]&&(Qe(this,this.constructor,o,e,e),this[Z]&&co(this))},u=e=>{if(!l.deep)return e;let t;return t=function(e,t){if(!e||"object"!=typeof e)return e;const n=new WeakMap,o=new WeakMap,r=e=>e&&"object"==typeof e&&o.get(e)||e,s=e=>{if(!e||"object"!=typeof e)return e;if(n.has(e))return n.get(e);if(e instanceof Map){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=xo(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("set"===n)c=(n,o)=>{n=r(n),o=r(o);const s=e.has(n),a=e.get(n);return e.set(n,o),s&&Object.is(a,o)||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("get"===n)c=t=>s(e.get(r(t)));else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach((e,o)=>t.call(n,s(e),s(o),i));else if("values"===n)c=function*(){for(const t of e.values())yield s(t)};else if("keys"===n)c=function*(){for(const t of e.keys())yield s(t)};else if("entries"===n||n===Symbol.iterator)c=function*(){for(const[t,n]of e.entries())yield[s(t),s(n)]};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(e instanceof Set){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=xo(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("add"===n)c=n=>{n=r(n);const o=e.has(n);return e.add(n),o||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach(e=>{const o=s(e);t.call(n,o,o,i)});else if("values"===n||"keys"===n||n===Symbol.iterator)c=function*(){for(const t of e.values())yield s(t)};else if("entries"===n)c=function*(){for(const t of e.values()){const e=s(t);yield[e,e]}};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(!Array.isArray(e)&&!function(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;const i=new Proxy(e,{get(e,t,n){const o=xo(e,t);return o.locked?o.value:s(Reflect.get(e,t,n))},set(e,n,o,s){const i=Reflect.get(e,n,s);o=r(o);const a=Reflect.set(e,n,o);return a&&!Object.is(i,o)&&t(),a},deleteProperty(e,n){const o=Object.prototype.hasOwnProperty.call(e,n),r=Reflect.deleteProperty(e,n);return r&&o&&t(),r},defineProperty(e,n,o){const s=Reflect.getOwnPropertyDescriptor(e,n),i="value"in o?{...o,value:r(o.value)}:o,a=Reflect.defineProperty(e,n,i),c=a?Reflect.getOwnPropertyDescriptor(e,n):s;return a&&!function(e,t){if(!e||!t)return e===t;const n="value"in e||"writable"in e;return n===("value"in t||"writable"in t)&&e.configurable===t.configurable&&e.enumerable===t.enumerable&&(!n||e.writable===t.writable&&Object.is(e.value,t.value))&&(n||e.get===t.get&&e.set===t.set)}(s,c)&&t(),a}});return n.set(e,i),o.set(i,e),i};return s(e)}(e,()=>{this[L]?.[o]===t&&h()}),t};Ge(this,j)[o]=u;const d=this.constructor.prototype;let f=d[ke];f&&Object.prototype.hasOwnProperty.call(d,ke)||(f=new Map(f),d[ke]=f);const m=f.get(o);m&&m===e||(f.set(o,e),Object.defineProperty(this.constructor.prototype,o,{get(){return this[M]?.has(o)?this[M].get(o):this[L]&&o in this[L]?this[L][o]:t},set(e){const t=this[o];if(!(l.hasChanged?l.hasChanged(e,t):Be(e,t)))return;const n=(this[j]?.[o]||(e=>e))(e);if(!this[I])return this[M]||(this[M]=new Map),void this[M].set(o,n);if(Ge(this,L)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=Fe(l,o),t=Ze(n,l,this[P]?.[o]);Ke(this,V).add(o);const r=e.toLowerCase();Ke(this,Q).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[Q].delete(r)}}this[w]&&(Qe(this,this.constructor,o,t,n),this[Z]&&co(this))},configurable:!0,enumerable:!0}));const p=u(t);return Ge(this,L)[o]=p,Ge(this,P)[o]=p,i?a:p}}}function Mo(e={}){return jo({...e,attribute:!1,reflect:!1})}function Ro(e){return!0===e[o]&&e.element?e.element:e}function Io(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=Ro(this);let n=null;const o=t instanceof HTMLElement?ln(t):null;return s&&o?n=o.querySelector(e):s&&t.shadowRoot&&(n=t.shadowRoot.querySelector(e)),!n&&r&&(n=t.querySelector(e)),n||null},set(){},configurable:!0,enumerable:!0}),t}}}function Do(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=Ro(this),n=new Set,o=t instanceof HTMLElement?ln(t):null;if(s&&o)for(const t of o.querySelectorAll(e))n.add(t);else if(s&&t.shadowRoot)for(const o of t.shadowRoot.querySelectorAll(e))n.add(o);if(r)for(const o of t.querySelectorAll(e))n.add(o);return[...n]},set(){},configurable:!0,enumerable:!0}),t}}}function Vo(...e){const t=e.filter(e=>"string"==typeof e),n=e.find(e=>"object"==typeof e&&null!==e),o=!1!==n?.immediate;return function(e,n){const r=n.name;n.addInitializer(function(){const n=this.constructor;Object.prototype.hasOwnProperty.call(n,ve)||(n[ve]=new Map);let s=n[ve].get(e);if(s||(s=new Set,n[ve].set(e,s)),!Object.prototype.hasOwnProperty.call(n,D)){const e=n[D],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[D]=t}for(const i of t)s.has(i)||(s.add(i),n[D].has(i)||n[D].set(i,[]),n[D].get(i).push({methodName:r,method:e,immediate:o}))})}}function qo(){return function(e,t){const n=t.name;return function(e){return Object.hasOwn(this.constructor.prototype,n)||Object.defineProperty(this.constructor.prototype,n,{get(){if(void 0!==this[q])return this[q];const e=dt(this);return void 0!==e?e:void 0},set(){},configurable:!0,enumerable:!0}),e}}}function Bo(e,t,n,o,r){const s=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,t)||(o[t]=new Set),!o[t].has(n)){if(o[t].add(n),!Object.prototype.hasOwnProperty.call(o,e)){const t=o[e];o[e]=t?[...t]:[]}o[e].push({methodName:s,method:n,...r})}})}function Fo(){return function(e,t){Bo(W,Ae,e,t)}}function Wo(){return function(e,t){Bo(z,Se,e,t)}}function zo(){return function(e,t){Bo(U,Te,e,t)}}function Uo(e,t){const n=e[t];if(n)for(const e of n.values())e.debounceTimer&&clearTimeout(e.debounceTimer),e.throttleTimer&&clearTimeout(e.throttleTimer),e.debounceTimer=null,e.throttleTimer=null,e.lastThrottleCall=0}function Ho(e,t,n){return function(o={}){return function(r,s){Bo(e,n,r,s,{options:o});const i=s.name;return function(...e){this[t]||(this[t]=new Map),this[t].has(i)||this[t].set(i,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const n=this[t].get(i),s=(...e)=>r.apply(this,e),a=(...e)=>{try{const t=r.apply(this,e);t&&"function"==typeof t.then&&t.catch(e=>console.error(`Error in deferred lifecycle handler ${i}:`,e))}catch(e){console.error(`Error in deferred lifecycle handler ${i}:`,e)}};if(o.debounce>0)return clearTimeout(n.debounceTimer),void(n.debounceTimer=setTimeout(()=>a(...e),o.debounce));if(o.throttle>0){const t=Date.now();return 0===n.lastThrottleCall||t-n.lastThrottleCall>=o.throttle?(n.lastThrottleCall=t,s(...e)):void(n.throttleTimer||(n.throttleTimer=setTimeout(()=>{n.throttleTimer=null,n.lastThrottleCall=Date.now(),a(...e)},o.throttle-(t-n.lastThrottleCall))))}return s(...e)}}}}const Ko=Ho(H,J,_e),Go=Ho(K,X,xe);class Qo extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[b];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return co(this),this.rendered}renderNow(){return function(e){to(e),ao(e,{...e[ee]||{},once:!1})}(this),this.rendered}}Object.defineProperty(Qo.prototype,ae,{value:!0});class Jo{constructor(e){this.parsed=this.parsePattern(e)}get spec(){return this.parsed.template}parsePattern(e){let t=e,n="",o=!1;const r=e.indexOf("?");return-1!==r&&(t=e.slice(0,r),n=e.slice(r+1),t.endsWith("(")&&n.endsWith(")")&&(o=!0,t=t.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(t),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:e}}parseSegments(e){const t=[];let n=0;for(;n<e.length;)switch(e[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(e,n);t.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(e,n+1);t.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(e,n+1);t.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:h}=this.parseLiteral(e,n);l&&t.push({type:"literal",value:l}),n=h}return t}parseOptionalGroup(e,t){let n=1,o=t+1;for(;o<e.length&&n>0;)"("===e[o]&&n++,")"===e[o]&&n--,o++;const r=e.slice(t+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(e,t){let n=t;for(;n<e.length&&/[\w-]/.test(e[n]);)n++;return{name:e.slice(t,n),endIndex:n}}parseLiteral(e,t){let n=t;for(;n<e.length&&!"(:*(".includes(e[n]);)n++;return{value:e.slice(t,n),endIndex:n}}parseQuerySegments(e){let t=e;t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1));const n=[];let o=0;for(;o<t.length;)if(":"===t[o]){const{name:e,endIndex:r}=this.parseIdentifier(t,o+1);n.push({type:"param",name:e}),o=r}else{const{value:e,endIndex:r}=this.parseQueryLiteral(t,o);e&&n.push({type:"literal",value:e}),o=r}return n}parseQueryLiteral(e,t){let n=t;for(;n<e.length&&":"!==e[n];)n++;return{value:e.slice(t,n),endIndex:n}}getAllParamNames(){const e=new Set,t=n=>{for(const o of n)switch(o.type){case"param":case"splat":e.add(o.name);break;case"optional":t(o.segments)}};return t(this.parsed.pathSegments),t(this.parsed.querySegments),Array.from(e)}canMatchRemainingSegments(e,t,n){let o=t;for(const t of n)if("literal"===t.type){const n=e.indexOf(t.value,o);if(-1===n)return!1;o=n+t.value.length}return!0}match(e){const[t,n]=e.split("?"),o=this.matchPath(t,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 e of s)i[e]=void 0;return Object.assign(i,o,r),i}matchPath(e,t){const n={};let o=0;for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1),a=this.matchSegment(e,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<e.length)&&n}matchSegment(e,t,n,o=[]){switch(n.type){case"literal":return e.slice(t,t+n.value.length)===n.value&&{params:{},nextIndex:t+n.value.length};case"param":{let r=t;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=e.indexOf(s.value,t);if(-1===n)return!1;r=n}else for(;r<e.length&&!a.includes(e[r]);)r++;if(r===t)return!1;try{i=decodeURIComponent(e.slice(t,r))}catch(n){i=e.slice(t,r)}return!(r<e.length&&"?"===e[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=e.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=e.indexOf(".",t);-1!==n&&(r=n)}else{const n=e.lastIndexOf(s.value);-1!==n&&n>=t&&(r=n)}break;case"param":let n=-1;for(let o=e.length-1;o>=t;o--)if("/"===e[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=e.length-1;n>t;n--)if("/"===e[n]){o=n+1;break}if(-1!==o)r=o;else{const n=e.slice(t).split("/").filter(e=>e);r=n.length>1?t+n.slice(0,-1).join("/").length+1:t}break;case"optional":const i=e=>{for(const t of e){if("literal"===t.type)return t.value;if("optional"===t.type){const e=i(t.segments);if(e)return e}}return null},a=i(s.segments);if(a){const n=e.lastIndexOf(a);-1!==n&&n>=t&&(r=n)}}const i=e.indexOf("?",t);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(e.slice(t,r))}catch(n){a=e.slice(t,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=t,s={},i=!0;for(let t=0;t<n.segments.length;t++){const o=n.segments[t],a=n.segments.slice(t+1),c=this.matchSegment(e,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}return i&&this.canMatchRemainingSegments(e,r,o)?{params:s,nextIndex:r}:{params:{},nextIndex:t}}default:return!1}}findNextLiteral(e){for(const t of e){if("literal"===t.type)return t;if("optional"===t.type){const e=this.findNextLiteral(t.segments);if(e)return e}}return null}matchQuery(e,t){if(0===t.length)return{};const n={};let o=0;for(const r of t)switch(r.type){case"literal":if(e.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let t,s=o;for(;s<e.length&&"&"!==e[s];)s++;if(s===o)return!1;try{t=decodeURIComponent(e.slice(o,s))}catch(n){t=e.slice(o,s)}n[r.name]=t,o=s;break}}return n}reverse(e={}){const t=this.reverseSegments(this.parsed.pathSegments,e);if(!1===t)return!1;let n=t;if(this.parsed.querySegments.length>0){const t=this.reverseSegments(this.parsed.querySegments,e);if(!this.parsed.queryOptional&&!1===t)return!1;t&&""!==t&&(n+="?"+t)}return n}reverseSegments(e,t,n=!1){let o="";for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in t))return!1;o+=String(t[s.name]);break;case"optional":if(this.hasAllParams(s.segments,t,n)||this.hasLaterOptionalGroupNeedingParams(i,t,s.segments)){const e=this.reverseSegments(s.segments,t,!0);if(!1===e)return!1;o+=e}}}return o}hasLaterOptionalGroupNeedingParams(e,t,n){for(const o of e)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,t))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(e){for(const t of e)if("param"===t.type||"splat"===t.type)return!1;return!0}hasAllParams(e,t,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of e)switch(n.type){case"param":case"splat":i=!1,n.name in t&&void 0!==t[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of e)"optional"===n.type&&this.hasAllParams(n.segments,t,a)&&(r=!0);return!(!o||s)||!(!r||s)||!(!i||!n)}hasOnlyOptionalMissingParams(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(!(n.name in t))return!1}return!0}hasAnyParamInSegments(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(n.name in t)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,t))return!0}return!1}}function Xo(e){const t=e.split("/").filter(Boolean);let n=t.length;for(const e of t)e.startsWith("*")?n+=-2:e.startsWith(":")?n+=3:n+=10;return n}function Yo(e){const t={};return e.split(";").forEach(e=>{const n=e.indexOf(":");if(-1===n)return;const o=e.slice(0,n).trim(),r=e.slice(n+1).trim();o&&r&&(t[o]=r)}),t}function Zo(e,t,n,o){if(e.style.position="absolute",e.style.width="100%",t)return e.style.height="100%",void(e.style.transition=`opacity ${n}ms ease-in-out`);e.style.top="0",e.style.left="0",e.style.transition=`${o} ${n}ms ease-in-out`}function er(e,t){Object.defineProperty(e.prototype,r,{value:!0,configurable:!0})}function tr(e){if(!mt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=pt(e);if(0===t.bindings){t.active=!0;try{$t(e,t.target),wt(e,t.target)}catch(n){throw Et(e),Lt(e),t.active=!1,n}}t.bindings+=1;let n=!1;return()=>{n||(n=!0,t.bindings=Math.max(0,t.bindings-1),0===t.bindings&&(Et(e),Lt(e),mo(e),t.active=!1,t.target=new EventTarget))}}function nr(e,t,n,o){const r=function(e,t,n,o){if(!e||"function"!=typeof e.addEventListener||"function"!=typeof e.removeEventListener)throw new TypeError("provideContext() requires an EventTarget root.");if(!t||"object"!=typeof t)throw new TypeError("provideContext() requires an application context object.");if(ht.has(e))throw new Error("This root already provides an application context. Release it before providing another.");const r=e=>{const r=e;if(r.detail){if("application"===r.detail.kind){if(void 0!==r.detail.context)return;r.detail.context=t}else if("fetch"===r.detail.kind){if(!n||void 0!==r.detail.fetch)return;r.detail.fetch=n}else{if("navigation"!==r.detail.kind)return;if(!o||void 0!==r.detail.navigation)return;r.detail.navigation=o}r.preventDefault(),r.stopPropagation()}};e.addEventListener(lt,r),ht.set(e,{listener:r});let s=!1;return()=>{if(s)return;s=!0;const t=ht.get(e);t?.listener===r&&(e.removeEventListener(lt,r),ht.delete(e))}}(e,t,n.fetch,o);let s;try{s=function(e){const t=e.daemons;if(void 0===t)return()=>{};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("AppContext.daemons must be a readonly record of named @daemon instances.");const n=[],o=new Set;try{for(const[e,r]of Object.entries(t)){if(!e.trim())throw new TypeError("AppContext.daemons keys must be non-empty strings.");if(!r||"object"!=typeof r)throw new TypeError(`AppContext.daemons["${e}"] must be an instance of an @daemon class.`);o.has(r)||(o.add(r),n.push(tr(r)))}}catch(e){for(const e of n.reverse())e();throw e}return()=>{for(const e of n.reverse())e()}}(t)}catch(e){throw r(),e}let i=!1;return()=>{i||(i=!0,r(),s?.())}}function or(e,t,n={}){return nr(e,t,n)}const rr=new WeakMap;var sr;function ir(e){const t=e.window??window,n=e.document??document,o=[];let r,s,i,a=0,c=!1,l=[],h=null,u=null;const d=e.context||{};let f=null,m=null;const p=new De(d,[],"",{},e.fetcher);function y(e){if(f===e&&m&&rr.get(e)===m)return;m?.(),rr.get(e)?.();const t=nr(e,(n=p).application,{fetch:n.fetch},n);var n;let o=!1;const r=()=>{o||(o=!0,t(),rr.get(e)===r&&rr.delete(e))};m=r,f=e,rr.set(e,r)}function g(e){if(!h||!u)return null;const t=e.querySelectorAll(h);for(const e of t)if(e[F]===u)return e;return null}function b(e,t,n,l,h,u,d=0){if(!Number.isFinite(d))throw new TypeError(`Route order for "${e}" must be a finite number.`);switch(o.push({route:new Jo(e),tag:t,transition:n,guards:l,layout:h,placard:u,order:d,registrationOrder:a++}),c=!1,e){case"/404":r=t;break;case"/403":s=t;break;case"/":i=t}}function v(){const e=new Set;l=o.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(d):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function w(e,t,n){p[ge](d,l,t,n)}function E(){switch(e.type){case"hash":return t.location.hash.slice(1);case"pushstate":return`${t.location.pathname}${t.location.search}`}}function N(e){let t;if(s)t=n.createElement(s),t[q]=d;else{const e=n.createElement("div");e.className="default-403",e.innerHTML="<h1>403</h1><p>Unauthorized</p>",t=e}e.innerHTML="",e.appendChild(t),h=null,u=null}async function A(e,t,o,r){if(!e)return!0;const s=Array.isArray(e)?e:[e];let i=null,a=null;a=setTimeout(()=>{r&&r()||(i=function(){const e=n.createElement("div");return e.setAttribute("data-snice-loading",""),e.innerHTML='\n <style>@keyframes snice-spin{to{transform:rotate(360deg)}}</style>\n <div style="display:flex;align-items:center;justify-content:center;height:100%;min-height:200px">\n <div style="width:32px;height:32px;border:3px solid rgba(128,128,128,0.3);border-top-color:rgba(128,128,128,0.8);border-radius:50%;animation:snice-spin 0.6s linear infinite"></div>\n </div>',e}(),o.appendChild(i))},50);try{for(const e of s)if(!await e(d,t))return r&&r()||N(o),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function S(t,o,r,s,i,a,c){const f=!1===(m=s)?null:m||(e.layout?e.layout:null);var m;const{element:p,needsNewLayout:y}=function(e){if(e===h)return{element:null,needsNewLayout:!1};if(h=e,e){const t=Date.now();u=t;const o=n.createElement(e);return o[q]=d,o[F]=t,{element:o,needsNewLayout:!0}}return u=null,{element:null,needsNewLayout:!0}}(f),b=r||e.transition;if(null!==p||null!==g(t)){if(await async function(e,t,n,o,r,s,i,a){const c=o||g(e);if(!c)return;!function(e,t,n){"function"==typeof e.update&&e.update(d,l,t,n)}(c,s,i);const h=c.querySelector('[slot="page"]');if(n&&h){if(t.setAttribute("slot","page"),await x(c,h,t,n),a&&a())return;r&&(e.innerHTML="",e.appendChild(c))}else a&&a()||(c.querySelectorAll('[slot="page"]').forEach(e=>e.remove()),t.setAttribute("slot","page"),c.appendChild(t),r&&(e.innerHTML="",e.appendChild(c)))}(t,o,b,p,y,i,a,c),c&&c())return;w(0,i,a)}else await async function(e,t,n,o){const r=e.children[0];n&&r?await x(e,r,t,n):o&&o()||(e.innerHTML="",e.appendChild(t))}(t,o,b,c),c&&c()||w(0,i,a)}let T=0;async function _(s){const a=n.querySelector(e.target);if(!a)throw new Error(`Target element not found: ${e.target}`);y(a);const c=++T,l=()=>c!==T;if(v(),t.scrollTo(0,0),(""===s?.trim()||"/"===s)&&i){const e=o.find(e=>e.route.match("/"));if(!await A(e?.guards,{},a,l))return;if(l())return;const{element:r,transition:c,layout:h}=function(){const e=n.createElement(i);e[q]=d;const r=t.customElements.get(i),s=r?.[B],a=o.find(e=>e.route.match("/"));return{element:e,transition:s,layout:a?.layout}}();return void await S(a,r,c,h,s,{},l)}if(!s)return;const h=await async function(e,t,r){for(const s of o){const o=s.route.match(e);if(!1===o)continue;if(!await A(s.guards,o,t,r))return{result:sr.GUARDS_FAILED};const i=n.createElement(s.tag);i[q]=d,i[ce]=p;const a=o;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:sr.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:sr.NOT_FOUND}}(s,a,l);if(l())return;if(h.result===sr.GUARDS_FAILED)return;if(h.result===sr.SUCCESS){const{element:e,transition:t,layout:n,routeParams:o={}}=h;return void await S(a,e,t,n,s,o,l)}const{element:u,transition:f,layout:m}=function(){if(r){const e=n.createElement(r);e[q]=d;const o=t.customElements.get(r),s=o?.[B];return{element:e,transition:s,layout:void 0}}const e=n.createElement("div");return e.className="default-404",e.innerHTML="<h1>404</h1><p>Page not found</p>",{element:e,transition:void 0,layout:void 0}}();await S(a,u,f,m,s,{},l)}async function x(e,t,n,o,r=T){return async function(e,t,n,o={},r=()=>!1){const s=o.outDuration??300,i=o.inDuration??300,a=o.mode||"sequential",c=o.out?Yo(o.out):{opacity:"0"},l={opacity:"0"},h=o.in?Yo(o.in):{opacity:"1"},u=e.style,d=e.tagName.includes("-")&&e.shadowRoot,f=Symbol.for("snice:transition-original-position"),m=Symbol.for("snice:transition-count"),p=e;d||(f in p||(p[f]=u.position,p[m]=0),p[m]++,u.position="relative");const y=()=>{d||(p[m]--,p[m]<=0&&(u.position=p[f],delete p[f],delete p[m]))},g=t.hasAttribute("slot")||n.hasAttribute("slot");switch(Zo(t,g,s,"all"),Zo(n,g,i,"all"),Object.assign(n.style,l),e.appendChild(n),a){case Le.SIMULTANEOUS:Object.assign(t.style,c),Object.assign(n.style,h),await new Promise(e=>setTimeout(e,Math.max(s,i)));break;case Le.SEQUENTIAL:if(Object.assign(t.style,c),await new Promise(e=>setTimeout(e,s)),r())return n.parentNode===e&&n.remove(),void y();Object.assign(n.style,h),await new Promise(e=>setTimeout(e,i))}if(r())return n.parentNode===e&&n.remove(),void y();t.remove(),function(e,t){e.style.position="",e.style.width="",e.style.transition="",t?e.style.height="":(e.style.top="",e.style.left="")}(n,g),Object.keys({...l,...h}).forEach(e=>{n.style[e]=""}),y()}(e,t,n,o,()=>r!==T)}return{page:function(e){return function(n,o){if(o?.metadata&&o.metadata[$]){n[$]||(n[$]=new Map);for(const[e,t]of o.metadata[$])n[$].set(e,t)}Co(n),n[B]=e.transition;const r=n.prototype.connectedCallback;n.prototype.connectedCallback=function(){void 0!==this[q]&&(this[ce]=p),r?.call(this)};const s=n.prototype.disconnectedCallback;return n.prototype.disconnectedCallback=function(){s?.call(this),delete this[q],delete this[ce]},t.customElements.get(e.tag)||t.customElements.define(e.tag,n),e.routes.forEach(t=>{b("string"==typeof t?t:t.path,e.tag,e.transition,e.guards,e.layout,e.placard,"string"==typeof t?void 0:t.order)}),n}},initialize:function(){const r=n.querySelector(e.target);if(!r)throw new Error(`Target element not found: ${e.target}`);y(r),!c&&(o.sort((e,t)=>Xo(t.route.spec)-Xo(e.route.spec)||e.order-t.order||e.registrationOrder-t.registrationOrder),c=!0),v(),function(){const o=()=>{const t=n.querySelector(e.target);if(t&&(f!==t||!m||rr.get(t)===m))return f!==t&&ht.has(t)?(m?.(),m=null,void(f=null)):void _(E())};switch(e.type){case"hash":t.addEventListener("hashchange",o);break;case"pushstate":t.addEventListener("popstate",o)}}(),_(E())},navigate:async function(n){const o=function(e){const t=e.trim().replace(/^#/,"");return t?t.startsWith("/")?t:`/${t}`:"/"}(n);!function(n){switch(e.type){case"hash":{const e=`#${n}`;t.location.hash!==e&&t.history.pushState(null,"",e);break}case"pushstate":`${t.location.pathname}${t.location.search}`!==n&&t.history.pushState(null,"",n)}}(o),await _(o)},register:b}}function ar(e,t,n){const o=[];for(const[r,s]of Object.entries(t)){const t=`@request/${r}`,i=e=>{const t=e,{discovery:o,data:i,payload:a}=t.detail;n?.passive||(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()),o.resolve(),Promise.resolve().then(()=>s(a)).then(e=>i.resolve(e)).catch(e=>{i.reject(e),console.error(`createRequestHandler: error in "${r}" handler:`,e)})};e.addEventListener(t,i),o.push(()=>e.removeEventListener(t,i))}return()=>{for(const e of o)e();o.length=0}}function cr(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t}function lr(e){const t=[];for(const n of Object.keys(e)){const o=e[n];if(null==o||!1===o)continue;const r=n.startsWith("--")?n:n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());t.push(`${r}: ${o}`)}return t.join("; ")}!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(sr||(sr={}));let hr=!1;function ur(e){hr=e}async function dr(e,t=500){if(customElements.get(e))return;let n=null;hr||(n=setTimeout(()=>{console.warn(`Custom element <${e}> is taking longer than ${t}ms to register. This may indicate a missing import or circular dependency. Set DISABLE_ELEMENT_READY_WARNINGS=true to disable this warning.`)},t));try{await customElements.whenDefined(e)}finally{n&&clearTimeout(n)}}async function fr(e,t=500){const n=e.tagName.toLowerCase();await dr(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}async function mr(e,t=500){const n=[];e instanceof Element&&(e.tagName.includes("-")&&n.push(e),e.shadowRoot)&&e.shadowRoot.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),e instanceof DocumentFragment&&e.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),await Promise.all(n.map(e=>fr(e,t)))}async function*pr(e){for(;;)await new Promise(t=>{e[oe]||(e[oe]=[]),e[oe].push(t)}),yield}let yr=0,gr=null;const br=Symbol.for("snice:body-scroll-lock");function vr(){0===yr&&(gr=document.body.style.overflow,document.body.style.overflow="hidden"),yr++}function wr(){0!==yr&&(yr--,0===yr&&(document.body.style.overflow=gr??"",gr=null))}function Er(){return yr}globalThis[br]={clear(){yr=0,gr=null}};class Nr{constructor(){this.requestMiddlewares=[],this.responseMiddlewares=[]}use(e,t){"request"!==e?this.responseMiddlewares.push(t):this.requestMiddlewares.push(t)}create(e){const t=this.requestMiddlewares,n=this.responseMiddlewares;return async function(e,o){if("string"==typeof e&&"undefined"!=typeof location&&location.href)try{new URL(e)}catch{e=new URL(e,location.href).href}const r=new Request(e,o);let s=0;const i=async()=>{if(s<t.length)return t[s++].call(this,r,i);const e=await fetch(r);let o=0;const a=async()=>o<n.length?n[o++].call(this,e,a):e;return a()};return i()}.bind(e)}}var Ar;"undefined"!=typeof document&&Ht(),globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(Ar||(Ar={}));export{De as Context,Nr as ContextAwareFetcher,o as IS_CONTROLLER_INSTANCE,ir as Router,$e as SimpleArray,Qo as SniceElement,Le as TransitionMode,Go as adopted,Co as applyElementFunctionality,Wt as attachController,cr as classMap,Ao as clearDebounceTimers,To as clearMemoizeCache,So as clearThrottleTimers,jt as context,qo as contextProperty,Dt as controller,ar as createRequestHandler,Yt as css,er as daemon,vo as debounce,zt as detachController,fo as dispatch,Wo as dispose,ko as element,ze as escapeAttr,We as escapeHtml,Er as getBodyScrollLockCount,dt as getContext,ft as getContextFetch,Ut as getController,t as getSymbol,Jt as html,Ue as isSafeUrl,$o as layout,En as live,vr as lockBodyScroll,No as memoize,Ko as moved,vn as noChange,tn as nothing,nt as observe,Ct as on,Eo as once,He as parseDuration,jo as property,or as provideContext,Io as query,Do as queryAll,Fo as ready,zo as reconnect,ho as render,an as repeat,bt as request,_o as resetOnce,vt as respond,ur as setDisableElementReadyWarnings,eo as setStrictRenderErrors,Mo as state,lr as styleMap,uo as styles,Xt as svg,wo as throttle,pr as trackRenders,wr as unlockBodyScroll,on as unsafeHTML,Ht as useNativeElementControllers,mr as waitForAllCustomElements,dr as waitForElementDefined,fr as waitForElementReady,Vo as watch};
1
+ globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map;const e=globalThis.snice;function t(e){return Symbol.for(`snice:${e}`)}const n=t("is-controller-class"),o=t("is-controller-instance"),r=t("is-daemon-class"),s=t("is-daemon-instance"),i=t("is-element-class"),a=t("channel-handlers"),c=t("daemon-state"),l=t("ready-promise"),u=t("ready-resolve"),h=t("ready-reject"),d=t("ready-handlers-running"),f=t("rendered-promise"),m=t("rendered-resolve"),p=t("pending-reconnect-render"),y=t("render-depth"),g=t("render-root"),b=t("element-options"),v=t("controller"),w=t("initialized"),E=t("controller-key"),N=t("controller-name"),A=t("controller-id"),T=t("controller-operations"),S=t("native-controller"),_=t("controller-registry-name"),O=t("direct-controller"),x=t("controller-attribute-sync"),C=t("pending-controller-binding"),k=t("cleanup"),$=t("properties"),L=t("property-values"),P=t("property-defaults"),j=t("property-wrappers"),R=t("pre-init-property-values"),M=t("pre-upgrade-property-bindings"),I=t("properties-initialized"),D=t("property-watchers"),V=t("explicitly-set-properties"),q=t("router-context"),B=t("page-transition"),F=t("created-at"),W=t("ready-handlers"),z=t("dispose-handlers"),U=t("reconnect-handlers"),H=t("moved-handlers"),K=t("adopted-handlers"),G=t("observers"),Q=t("setting-from-property"),J=t("moved-timers"),X=t("adopted-timers"),Y=t("dispatch-timers"),Z=t("render-method"),ee=t("render-options"),te=t("render-instance"),ne=t("render-timers"),oe=t("render-callbacks"),re=t("styles-method"),se=t("styles-applied"),ie=t("parent-styles-methods"),ae=t("snice-element-base"),ce=t("context-handler"),le=t("navigation-context-instance"),ue=t("registered-elements"),he=t("is-updating"),de=t("context-register"),fe=t("context-unregister"),me=t("context-notify-element"),pe=t("context-timer"),ye=t("context-called"),ge=t("context-update"),be=t("context-methods"),ve=t("watch-methods"),we=t("observe-methods"),Ee=t("on-methods"),Ne=t("respond-methods"),Ae=t("ready-methods"),Te=t("dispose-methods"),Se=t("reconnect-methods"),_e=t("moved-methods"),Oe=t("adopted-methods"),xe=t("controller-abort"),Ce=t("controller-attached"),ke=t("property-definers");class $e{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes($e.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${$e.SEPARATOR}" (U+FF0C)`);return e}if("number"==typeof e||"boolean"==typeof e)return String(e);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof e)}).join($e.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split($e.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var Le,Pe,je,Re;!function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(Le||(Le={}));const Me=Symbol.for("snice:registered-elements-set");let Ie=0;class De{constructor(e={},t=[],n="",o={},r){if(this[Pe]=new WeakMap,this[je]=new Set,this[Re]=!1,this.id=Ie++,this.application=e,this.navigation={placards:t,route:n,params:o},r&&"function"==typeof r.create)this.fetch=r.create(this);else{if("function"!=typeof fetch)throw new Error("No fetch implementation available");this.fetch=fetch.bind(this)}}[(Pe=ue,je=Me,Re=he,de)](e,t){const n=this[ue];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[Me].add(e)}[fe](e,t){const n=this[ue];if(void 0!==t){const o=n.get(e);if(!o)return;if(o.delete(t),o.size>0)return}n.delete(e),this[Me].delete(e)}[ge](e,t,n,o){this.application=e,this.navigation.placards=t,this.navigation.route=n,this.navigation.params=o,this.notify()}update(){this.notify()}notify(){if(this[he])return;this[he]=!0;const e=this[Me],t=this[ue];for(const n of e){const e=t.get(n);if(e)for(const t of e)if("function"==typeof n[t])try{n[t](this)}catch(e){console.error(`Error calling @context method ${t}:`,e)}}this[he]=!1}[me](e){const t=this[ue].get(e);if(t)for(const n of t)if("function"==typeof e[n])try{e[n](this)}catch(e){console.error(`Error calling @context method ${n}:`,e)}}}function Ve(e){if(null!=e)return"string"==typeof e?String:"number"==typeof e?Number:"boolean"==typeof e?Boolean:e instanceof Date?Date:"bigint"==typeof e?BigInt:Array.isArray(e)?Array:void 0}function qe(e,t,n,o){const r=t.type||Ve(o);if(t.converter?.fromAttribute)return t.converter.fromAttribute(e,r);switch(r){case Boolean:return null!==e&&"false"!==e;case Number:return null!==e?Number(e):null;case String:return e;case Date:return e?new Date(e):null;case BigInt:return e&&e.endsWith("n")?BigInt(e.slice(0,-1)):e?BigInt(e):null;case $e:return $e.parse(e);case Array:try{return e?JSON.parse(e):[]}catch{return[]}case Object:try{return e?JSON.parse(e):{}}catch{return{}}default:return"number"==typeof n&&null!==e?Number(e):e}}function Be(e,t){return e!==t&&(e==e||t==t)}function Fe(e,t){return"string"==typeof e.attribute?e.attribute.toLowerCase():!0===e.attribute||"kebab"===e.attributeNaming?t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase():t.toLowerCase()}function We(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ze(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Ue(e,t={}){let n;try{n=String(e??"")}catch{return!1}if(!n||/[\u0000-\u001f\u007f]/.test(n))return!1;const o=n.trim();if(!o)return!1;const r=t.allowed??["http:","https:","mailto:","tel:"];try{const e=new URL(o,"http://__snice-relative.invalid/"),t=/^[a-z][a-z\d+.-]*:/i.test(o),n=/^[\\/]{2}/.test(o);return!t&&!n||r.some(t=>"string"==typeof t&&t.toLowerCase()===e.protocol)}catch{return!1}}function He(e){const t=String(e).trim(),n=parseFloat(t);let o;return o=isNaN(n)?0:/ms$/i.test(t)?n:/s$/i.test(t)?1e3*n:/m$/i.test(t)?6e4*n:/h$/i.test(t)?36e5*n:n,{milliseconds:()=>o,seconds:()=>o/1e3,minutes:()=>o/6e4}}function Ke(e,t){return e[t]||(e[t]=new Set),e[t]}function Ge(e,t){return e[t]||(e[t]={}),e[t]}function Qe(e,t,n,o,r){const s=t[D];if(!s)return;const i=[n],a=t[$]?.get(n),c=a&&"string"==typeof a.attribute?a.attribute:null;c&&c!==n&&i.push(c);for(const t of i)if(s.has(t))for(const i of s.get(t))try{i.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('${t}') method ${i.methodName}:`,e)}if(s.has("*"))for(const t of s.get("*"))try{t.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('*') method ${t.methodName}:`,e)}}function Je(e,t){let n=null;const o=function(...o){null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o),n=null},t)};return o.cancel=()=>{null!==n&&clearTimeout(n),n=null},o}function Xe(e,t){let n=0,o=null;return function(...r){const s=Date.now(),i=t-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,e.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,e.apply(this,r)},i))}}function Ye(e,t,n,o){if(void 0===t)return;const r="function"==typeof t?t.call(e):t;if("number"!=typeof r||!Number.isFinite(r)||r<0)throw new TypeError(`${n} ${o} must resolve to a finite, non-negative number of milliseconds.`);return r}function Ze(e,t){if(null==t)return e;if("global"===t)return"undefined"!=typeof document?document:null;if("function"==typeof t)try{return t.call(e)||null}catch{return null}return"string"==typeof t?e.closest?.(t)||null:t&&"function"==typeof t.addEventListener?t:null}function et(e,t,n){if(null==e||!1===e||t?.type===$e&&Array.isArray(e)&&0===e.length)return null;if(t.converter?.toAttribute)return t.converter.toAttribute(e,t.type);switch(t.type||Ve(n)){case Boolean:return"true";case Date:return e instanceof Date?e.toISOString():String(e);case BigInt:return"bigint"==typeof e?e.toString()+"n":String(e);case $e:return Array.isArray(e)?$e.serialize(e):String(e);case Array:return Array.isArray(e)?JSON.stringify(e):String(e);case Object:return"object"==typeof e&&null!==e?JSON.stringify(e):String(e);default:return String(e)}}const tt=new WeakSet,nt=new Map;function ot(e,t,n){let o,r;return"string"==typeof t?(o=t,r=n):(o=void 0,r=t),function(t,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,we)||(n[we]=new Set),n[we].has(t))return;if(n[we].add(t),!Object.prototype.hasOwnProperty.call(n,G)){const e=n[G];n[G]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[G].push({type:i,target:c,selector:o,methodName:s,method:t,options:r})}})}}function rt(e,t){const n=e.constructor[G];if(n&&Array.isArray(n)&&0!==n.length){e[k]?e[k].observers||(e[k].observers=[]):e[k]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?Xe(n,o.options.throttle):n;switch(o.type){case"intersection":st(e,t,o,r);break;case"resize":it(e,t,o,r);break;case"media":at(e,0,o,r);break;case"mutation":ct(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function st(e,t,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");const s=new IntersectionObserver(e=>{for(const t of e)try{!1===o(t)&&s&&s.unobserve(t.target)}catch(e){console.error(`Error in intersection observer ${n.methodName}:`,e)}},r),i=n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t];i.forEach(e=>s.observe(e)),e[k].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function it(e,t,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(e=>{for(const t of e)try{o(t)}catch(e){console.error(`Error in resize observer ${n.methodName}:`,e)}});(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t]).forEach(e=>{s.observe(e,{box:r})}),e[k].observers.push(()=>{s.disconnect()})}function at(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=nt.get(r);if(!s)try{s=window.matchMedia(r),nt.set(r,s)}catch(e){return void console.error(`Invalid media query: ${r}`,e)}const i=e=>{try{o(e.matches)}catch(e){console.error(`Error in media query observer ${n.methodName}:`,e)}};i(s);const a=e=>i(e);s.addEventListener?(s.addEventListener("change",a),e[k].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[k].observers.push(()=>{s.removeListener(a)}))}function ct(e,t,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(/^[.#[]/.test(i)?console.warn(`@observe: "mutation:${i}" — "${i}" looks like a selector. Selectors are the second argument — did you mean @observe('mutation:childList', '${i}')?`):console.warn(`Unknown mutation type: ${i} (expected childList or attributes)`))}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=!(!n.options?.maxDepth||!n.options.subtree),u=new MutationObserver(e=>{try{if(!l)return void r(e);const o=n.options.maxDepth,s=t.shadowRoot||t,i=e.filter(e=>{let t=0,n=e.target;for(;n&&n!==s&&t<o;)n=n.parentNode,t++;return t<o});i.length>0&&r(i)}catch(e){console.error(`Error in mutation observer ${n.methodName}:`,e)}}),h=!0===e[o];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):h&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{u.observe(e,c)}),e[k].observers.push(()=>{u.disconnect()})}function lt(e){if(e[k]?.observers){for(const t of e[k].observers)t();e[k].observers=[]}}const ut="@context/request",ht=new WeakMap;function dt(e){return!e||"object"!=typeof e&&"function"!=typeof e?null:!0===e[o]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:"function"==typeof e.dispatchEvent?e:null}function ft(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=dt(e);if(t){const e={kind:"application"};if(t.dispatchEvent(new CustomEvent(ut,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[q]?n[q]:!0===n[o]&&void 0!==n.element?.[q]?n.element[q]:void 0}function mt(e){const t=dt(e);if(!t)return;const n={kind:"fetch"};return t.dispatchEvent(new CustomEvent(ut,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.fetch}function pt(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[r]}function yt(e){if(!pt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");let t=e[c];if(!t){t={target:new EventTarget,bindings:0,active:!1};try{Object.defineProperty(e,c,{value:t,configurable:!0}),Object.defineProperty(e,s,{value:!0,configurable:!0})}catch{throw new TypeError("@daemon instances must remain extensible until they are provided to an app context.")}}return t}function gt(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=ft(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[o]?"controller":pt(t)?"@daemon instance":"element"}(e)} cannot resolve daemon "${t}" because no app context is provided.`);const r=n.daemons?.[t];if(!r)throw new Error(`[snice] app context does not provide daemon "${t}".`);if(!pt(r))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=yt(r);if(!s.active)throw new Error(`[snice] daemon "${t}" is not active because its app context has not been provided.`);return s.target}function bt(e){return pt(e)?function(e){return yt(e).target}(e):!0===e?.[o]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}function vt(e,t){return function(n,o){let r,s,i=0;const a=[];return async function(...o){const c=async()=>{const r=t?.timeout??12e4,s=t?.discoveryTimeout??50,i=void 0!==t?.daemon?gt(this,t.daemon):bt(this);if(!i)throw new TypeError(`@request('${e}') requires an element, attached controller, or provided @daemon instance.`);const a=n.apply(this,o),{value:c,done:l}=await a.next();if(l)return c;let u,h;const d=new Promise((e,t)=>{u=e,h=t});let f,m,p,y=!1;const g=new Promise((t,n)=>{f=t,m=n,p=setTimeout(()=>{n(new Error(`Request "${e}" found no @respond('${e}') handler within ${s}ms — attach a responding controller/element, or pass { optional: true } to resolve undefined when unhandled.`))},s)}),b=new CustomEvent(`@request/${e}`,{bubbles:void 0===t?.bubbles||t.bubbles,cancelable:t?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{y=!0,clearTimeout(p),f()},reject:m},data:{resolve:u,reject:h}}});i.dispatchEvent(b);try{await g;const t=setTimeout(()=>{h(new Error(`Request "${e}" timed out after ${r}ms`))},r),n=await d;clearTimeout(t);const{value:o}=await a.next(n);return o}catch(e){if(t?.optional&&!y){const{value:e}=await a.next(void 0);return e}const{value:n}=await a.throw(e);return n}};if(t?.debounce)return new Promise((e,n)=>{clearTimeout(r),r=setTimeout(async()=>{try{e(await c())}catch(e){n(e)}},t.debounce)});if(!t?.throttle)return c();const l=Date.now(),u=t.throttle-(l-i);if(u<=0){clearTimeout(s),s=null,i=l;const e=a.splice(0),t=c();return e.length&&t.then(t=>{for(const n of e)n.resolve(t)},t=>{for(const n of e)n.reject(t)}),t}return new Promise(s?(e,t)=>{a.push({resolve:e,reject:t})}:(e,t)=>{a.push({resolve:e,reject:t}),s=setTimeout(async()=>{i=Date.now(),s=null;const e=a.splice(0);try{const t=await c();for(const n of e)n.resolve(t)}catch(t){for(const n of e)n.reject(t)}},u)})}}}function wt(e,t){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,Ne)||(o[Ne]=new Set),!o[Ne].has(n)){if(o[Ne].add(n),!Object.prototype.hasOwnProperty.call(o,a)){const e=o[a];o[a]=e?[...e]:[]}o[a].push({channelName:e,methodName:r,method:n,options:t})}})}}function Et(e,t){const n=e.constructor[a];if(n){e[k]||(e[k]={events:[],channels:[]});for(const o of n){const n=o.method.bind(e),r=`@request/${o.channelName}`;let s,i,a=0;const c=[];let l=null;const u=(e=>o.options?.debounce?(...t)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{n(await e(...t))}catch(e){r(e)}},o.options.debounce)}):o.options?.throttle?(...t)=>{const n=Date.now(),r=o.options.throttle-(n-a);if(r<=0){clearTimeout(i),i=null,a=n;const o=c.splice(0);l=null;const r=e(...t);return o.length&&Promise.resolve(r).then(e=>{for(const t of o)t.resolve(e)},e=>{for(const t of o)t.reject(e)}),r}return l=t,new Promise((n,o)=>{c.push({resolve:n,reject:o}),i||(i=setTimeout(async()=>{a=Date.now(),i=null;const n=c.splice(0),o=l??t;l=null;try{const t=await e(...o);for(const e of n)e.resolve(t)}catch(e){for(const t of n)t.reject(e)}},r))})}:e)(n),h=e=>{const{data:t,discovery:n,payload:r}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),Promise.resolve(u(r)).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${o.methodName}:`,e)})};let d=t;if(void 0!==o.options?.daemon)try{d=gt(e,o.options.daemon)}catch(e){console.warn(`[snice/@respond] ${e.message} Responder "${o.channelName}" skipped.`);continue}d.addEventListener(r,h),e[k].channels.push(()=>{d.removeEventListener(r,h)})}}}function Nt(e){if(e[k]?.channels){for(const t of e[k].channels)t();e[k].channels=[]}}const At=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function Tt(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();At.has(n)&&console.warn(`snice: "@${e}" is not a valid modifier — once/preventDefault/stopPropagation/capture are @on() options, not template modifiers. This registers a listener for event "${e}", which never fires.`)}function St(e){const t=e.startsWith("~");t&&(e=e.substring(1));const n=e.split("+"),o={key:"",anyModifiers:t};for(const e of n){const t=e.toLowerCase();"ctrl"===t||"control"===t?o.ctrl=!0:"alt"===t?o.alt=!0:"shift"===t?o.shift=!0:"meta"===t||"cmd"===t||"command"===t?o.meta=!0:o.key=_t(e)}return o}function _t(e){return{esc:"Escape",escape:"Escape",enter:"Enter",return:"Enter",space:" ",spacebar:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",delete:"Delete",del:"Delete",backspace:"Backspace",tab:"Tab",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"}[e.toLowerCase()]||e}function Ot(e,t){return e.key===t.key&&(!!t.anyModifiers||(t.ctrl?e.ctrlKey:!e.ctrlKey)&&(t.alt?e.altKey:!e.altKey)&&(t.shift?e.shiftKey:!e.shiftKey)&&(t.meta?e.metaKey:!e.metaKey))}const xt=t("on-handlers");function Ct(e,t,n){let o=null,r={};return"string"==typeof t?(o=t,r=n||{}):t&&"object"==typeof t?r=t:null===t&&n&&(r=n),!o&&r.target&&(o=r.target),function(t,n){const s=n.name;return n.addInitializer(function(){const n=this.constructor,i=Array.isArray(e)?e:[e],a=`${s}::${i.join(",")}::${o??""}::daemon:${r.daemon??""}::light:${r.light??""}::shadow:${r.shadow??""}`;if(Object.prototype.hasOwnProperty.call(n,Ee)||(n[Ee]=new Set),!n[Ee].has(a)){if(n[Ee].add(a),!Object.prototype.hasOwnProperty.call(n,xt)){const e=n[xt];n[xt]=e?[...e]:[]}for(const e of i)n[xt].push({eventName:e,selector:o,methodName:s,method:t,options:r})}}),t}}function kt(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const $t=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function Lt(e,t){const n=e.constructor[xt];if(n&&Array.isArray(n)&&0!==n.length){e[k]||(e[k]={events:[],eventCancels:[],channels:[],observers:[]}),e[k].events||(e[k].events=[]),e[k].eventCancels||(e[k].eventCancels=[]),(e[k].events.length>0||e[k].eventCancels.length>0)&&Pt(e);for(const o of n){const n=e[o.methodName];let r=n?n.bind(e):o.method.bind(e);const s=o.options||{},i=Ye(e,s.debounce,"@on","debounce"),a=i&&i>0?void 0:Ye(e,s.throttle,"@on","throttle"),c=["keydown","keyup","keypress"].includes(o.eventName.split(".")[0].split(":")[0]),l=c?o.eventName.indexOf("."):-1,u=c?o.eventName.indexOf(":"):-1,h=l>0&&u>0?Math.min(l,u):Math.max(l,u),d=h>0?o.eventName.substring(0,h):o.eventName,f=h>0?o.eventName.substring(h+1):null;if(h<=0&&Tt(o.eventName),i&&i>0){const t=Je(r,i);e[k].eventCancels.push(()=>t.cancel()),r=t}else a&&a>0&&(r=kt(r,a));let m=null;f&&["keydown","keyup","keypress"].includes(d)&&(m=St(f));const p=(e=>m?t=>!!Ot(t,m)&&(e(t),!0):t=>(e(t),!0))(r),y=void 0!==s.scope,g=void 0!==s.daemon;if(y&&g){console.warn(`[snice/@on] "${o.eventName}" cannot use both scope and daemon — listener skipped.`);continue}if((g||pt(e))&&o.selector){console.warn(`[snice/@on] "${o.eventName}" cannot delegate "${o.selector}" on a daemon target — listener skipped.`);continue}const b=y||g,v=!1!==s.shadow,w=!1!==s.light;if(!b||void 0===s.light&&void 0===s.shadow||console.warn(`[snice/@on] light/shadow are ignored for "${o.eventName}" — an explicit scope/daemon owns the listener target.`),!b&&!v&&!w){console.warn(`[snice/@on] "${o.eventName}" disables both light and shadow — listener skipped.`);continue}let E=null;if(g)try{E=gt(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(y&&(E=Ze(t,s.scope),!E)){console.warn(`[snice/@on] scope did not resolve for "${o.eventName}" on ${o.methodName} — listener skipped.`);continue}if(o.selector){const n=t.shadowRoot,r=b?[E]:[...v&&n?[n]:[],...w?[t]:[]];if(0===r.length){console.warn(`[snice/@on] "${o.eventName}" cannot delegate "${o.selector}" — no shadow root and light disabled; listener skipped.`);continue}const i=Symbol(),a=$t.has(d),c={capture:void 0!==s.capture?s.capture:a,once:!1,passive:s.passive||!1},l=[],u=()=>{for(const e of l)e.target.removeEventListener(d,e.handler,c)};for(const t of r){const n=t instanceof ShadowRoot?t:t.getRootNode?.()??document,r=e=>{if("function"!=typeof e.composedPath){const t=e.target;return t.matches&&t.matches(o.selector)&&t||t.closest&&t.closest(o.selector)||null}for(const r of e.composedPath()){const e=r;if(e===t)break;if(1===e.nodeType&&e.getRootNode()===n&&e.matches(o.selector))return e}return null},a=e=>{if(e[i])return;if(!r(e))return;e[i]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&(e.stopPropagation(),e.stopImmediatePropagation());let t=!1;try{t=p(e)}catch(e){t=!0,console.error(`Error in event handler ${o.methodName}:`,e)}t&&s.once&&u()};t.addEventListener(d,a,c),l.push({target:t,handler:a}),e[k].events.push({target:t,eventName:d,handler:a,options:c})}}else{const n=b||!v?null:t.shadowRoot;if(!b&&!n&&!w){console.warn(`[snice/@on] "${o.eventName}" requests shadow only but the element has no shadow root — listener skipped.`);continue}const r=Symbol(),i={capture:s.capture||!1,once:!1,passive:s.passive||!1},a=[],c=()=>{for(const e of a)e.target.removeEventListener(d,e.handler,i)},l=e=>{if(e[r])return;e[r]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&e.stopPropagation();let t=!1;try{t=p(e)}catch(e){t=!0,console.error(`Error in event handler ${o.methodName}:`,e)}t&&s.once&&c()},u=t=>{t.addEventListener(d,l,i),a.push({target:t,handler:l}),e[k].events.push({target:t,eventName:d,handler:l,options:i})};if(b){u(E);continue}n&&u(n),w&&u(t)}}}}function Pt(e){if(e[k]?.events){for(const t of e[k].eventCancels??[])t();e[k].eventCancels=[];for(const{target:t,eventName:n,handler:o,options:r}of e[k].events)t.removeEventListener(n,o,r);e[k].events=[]}}const jt=t("dispatch-generation");function Rt(e,t){return(e[jt]??0)===t}function Mt(e,t){return function(n,o){const r=Symbol(`@dispatch:${e}`);return function(...o){const s=this[jt]??0;this[Y]||(this[Y]=new Map),this[Y].has(r)||this[Y].set(r,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null,invocation:0});const i=this[Y].get(r),a=Ye(this,t?.debounce,"@dispatch","debounce"),c=a&&a>0?void 0:Ye(this,t?.throttle,"@dispatch","throttle"),l=++i.invocation;i.debounceTimeout&&clearTimeout(i.debounceTimeout),i.debounceTimeout=null,i.throttleTimeout&&clearTimeout(i.throttleTimeout),i.throttleTimeout=null,i.latestDetail=void 0,(a&&a>0||!c||c<=0)&&(i.throttleLastCall=0);const u=n.apply(this,o),h=n=>{if(void 0===n&&!1===t?.dispatchOnUndefined)return;const o=new CustomEvent(e,{bubbles:t?.bubbles??!0,cancelable:t?.cancelable??!1,composed:t?.composed??!0,detail:n});if(void 0!==t?.scope&&void 0!==t?.daemon)throw new TypeError(`@dispatch('${e}') cannot use both scope and daemon.`);if(void 0!==t?.daemon)return void gt(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=Ze(this,t.scope);return n?void n.dispatchEvent(o):void console.warn(`[snice/@dispatch] scope did not resolve for "${e}" — event not dispatched.`)}const r=bt(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},d=e=>{if(!Rt(this,s))return;if(a&&a>0)return void(i.debounceTimeout=setTimeout(()=>{i.debounceTimeout=null,Rt(this,s)&&i.invocation===l&&h(e)},a));if(!c||c<=0)return void h(e);const t=Date.now(),n=c-(t-i.throttleLastCall);if(n<=0)return clearTimeout(i.throttleTimeout),i.throttleLastCall=t,void h(e);i.latestDetail=e,i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null;const e=i.latestDetail;i.latestDetail=void 0,Rt(this,s)&&i.invocation===l&&h(e)},n)};return u instanceof Promise?u.then(e=>{const t=(a??0)>0||(c??0)>0;return!Rt(this,s)||t&&i.invocation!==l||d(e),e}):(d(u),u)}}}function It(e){e[jt]=(e[jt]??0)+1;const t=e[Y];if(t)for(const e of t.values())e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.throttleTimeout&&clearTimeout(e.throttleTimeout),e.debounceTimeout=null,e.throttleTimeout=null,e.throttleLastCall=0,e.latestDetail=void 0,e.invocation=(e.invocation??0)+1}const Dt=t("context-handlers");function Vt(e={}){return function(t,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,be)||(n[be]=new Set),!n[be].has(t)){if(n[be].add(t),!Object.prototype.hasOwnProperty.call(n,Dt)){const e=n[Dt];n[Dt]=e?[...e]:[]}n[Dt].push({methodName:o,method:t,options:e})}}),t}}function qt(e,t=!1){const n=e.constructor[Dt];if(!n||!Array.isArray(n)||0===n.length)return;const o=e[ce]??function(e){const t=dt(e);if(!t)return;const n={kind:"navigation"};return t.dispatchEvent(new CustomEvent(ut,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.navigation}(e);if(!o)return;e[le]=o;let r=!1;for(const t of n){const{methodName:n,method:s,options:i}=t,a=`__wrapped_${n}`;e[a]=function(t){r=!0;const o=e[ye]||(e[ye]=new Set);if(i.once&&o.has(n))return;const c=()=>{if(s.call(e,t),i.once){o.add(n);const t=e[le];t&&"function"==typeof t[fe]&&t[fe](e,a)}},l=e[pe]||(e[pe]={}),u=n;if(i.debounce)return clearTimeout(l[u]?.timeout),void(l[u]={timeout:setTimeout(c,i.debounce)});if(i.throttle){const e=Date.now();return void(e-(l[u]?.lastCall||0)>=i.throttle&&(l[u]={lastCall:e},c()))}c()},"function"==typeof o[de]&&o[de](e,a)}return t&&"function"==typeof o[me]?new Promise(n=>{const s=()=>{try{r||e[le]!==o||o[me](e)}finally{n()}};"task"===t?setTimeout(s,0):queueMicrotask(s)}):void 0}function Bt(e){const t=e.constructor[Dt];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[pe];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[pe]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[le];o&&"function"==typeof o[fe]&&o[fe](e),delete e[le],delete e[ye]}class Ft{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(e,t){this.cleanupFns.set(e,t)}unregister(e){this.cleanupFns.delete(e)}async cleanup(){await Promise.all(this.pendingOperations);for(const e of this.cleanupFns.values())try{await e()}catch(e){console.error("Error during cleanup:",e)}this.cleanupFns.clear()}async runOperation(e){const t=e(),n=t.then(()=>{},()=>{});this.pendingOperations.add(n);try{const e=await t;return this.pendingOperations.delete(n),e}catch(e){throw this.pendingOperations.delete(n),e}}}function Wt(t){return function(o,r){const s=globalThis.snice?.controllerRegistry;if(!s)throw new Error("Snice global registry not initialized");s.set(t,o),o.prototype[n]=!0,Object.defineProperty(o,_,{value:t,configurable:!0});const i=e.pendingControllerAttachments.get(t);return i&&(e.pendingControllerAttachments.delete(t),queueMicrotask(()=>{for(const e of i){const n=e[S];(void 0===n?e[v]:n)===t&&Gt(e,t).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${t}":`,e)})}})),o}}function zt(t,n){if(e.controllerRegistry.has(n))return void queueMicrotask(()=>{const e=t[S];(void 0===e?t[v]:e)===n&&Gt(t,n).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${n}":`,e)})});let o=e.pendingControllerAttachments.get(n);o||(o=new Set,e.pendingControllerAttachments.set(n,o)),o.add(t),queueMicrotask(()=>{e.pendingControllerAttachments.get(n)?.has(t)&&console.error(`Failed to attach controller "${n}":`,new Error(`Controller "${n}" not found in registry`))})}function Ut(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}function Ht(e,t){if(null===t){if(!e.hasAttribute("controller"))return}else if(e.getAttribute("controller")===t)return;e[x]=!0;try{null===t?e.removeAttribute("controller"):e.setAttribute("controller",t)}finally{delete e[x]}}function Kt(e){if(!e[O])return!1;const t=e[N];return"function"==typeof t&&(Ht(e,function(e){const t=Object.prototype.hasOwnProperty.call(e,_)?e[_]:void 0;return"string"==typeof t?t:Ut(e)}(t)),!0)}async function Gt(t,r){if("string"!=typeof r){if("function"!=typeof r)throw new Error(`attachController: expected a controller name or a controller class, got ${typeof r}. Controller instances are not supported — pass the class itself.`);if("function"!=typeof(s=r)||!0!==s.prototype?.[n])throw new Error(`Controller class "${Ut(r)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=Ut(r),a=t[E],c=t[S];if("string"==typeof r&&void 0!==c&&c!==r)return;if(t[N]===r&&a)return void("string"!=typeof r&&Kt(t));if(a&&(await Qt(t),t[E]&&t[N]===r))return void("string"!=typeof r&&Kt(t));let l;if("string"==typeof r){const e=globalThis.snice?.controllerRegistry;if(!e)throw new Error("Snice global registry not initialized");if(l=e.get(r),!l)throw new Error(`Controller "${r}" not found in registry`)}else l=r;const u=new l;"string"!=typeof r&&(t[O]=!0,delete t[S]),e.controllerIdCounter+=1;const h=e.controllerIdCounter,f=new Ft;u[o]=!0,u[A]=h,u.element=t;const m=t[q];if(void 0!==m&&(u[q]=m),t[E]=u,t[N]=r,t[T]=f,"string"!=typeof r&&Kt(t),!t[d]){const e=new AbortController;t[xe]=e;const n=3e4;try{await Promise.race([t.ready,new Promise((t,o)=>{const r=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",o(e)};if(e.signal.aborted)return r();e.signal.addEventListener("abort",r,{once:!0});const s=setTimeout(()=>o(new Error(`attachController("${i}"): element did not become ready within ${n}ms (did you forget to appendChild it?)`)),n);e.signal.addEventListener("abort",()=>clearTimeout(s),{once:!0})})])}catch(e){throw t[E]===u&&("string"!=typeof r&&Ht(t,null),delete t[E],delete t[N],delete t[T],"string"!=typeof r&&delete t[O]),e}finally{t[xe]===e&&delete t[xe]}}u[Ce]=!0,await f.runOperation(async()=>{await u.attach(t)}),await qt(u,"microtask"),rt(u,t),Et(u,t),Lt(u,t),t.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:u}}))}async function Qt(e){const t=e[xe];t&&t.abort();const n=e[E],o=e[N],r=e[T];n&&(It(n),"function"==typeof o&&Ht(e,null),delete e[E],delete e[N],delete e[T],"function"==typeof o&&delete e[O],n[Ce]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),It(n),n.element=null,lt(n),Nt(n),Pt(n),Bt(n),r&&await r.cleanup(),delete n[q],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:Ut(o),controller:n}}))))}function Jt(e){return e[E]}function Xt(){if(globalThis.sniceNativeControllersInitialized)return;function e(e){if(!(e instanceof HTMLElement))return;if(!e.tagName||e.tagName.includes("-"))return;if(e[i])return;if(e[O])return void Kt(e);const t=e.getAttribute("controller"),n=e[S];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[S],delete e[N],void Qt(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[S]=t,e.ready||(e.ready=Promise.resolve()),n&&Qt(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),Gt(e,t).catch(n=>{"ControllerAttachAborted"!==n?.name?n?.message!==`Controller "${t}" not found in registry`?console.error(`Failed to attach controller "${t}" to native element:`,n):zt(e,t):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}globalThis.sniceNativeControllersInitialized=!0;const t=new MutationObserver(t=>{for(const n of t)"attributes"===n.type&&"controller"===n.attributeName?e(n.target):"childList"===n.type&&n.addedNodes.forEach(t=>{t instanceof HTMLElement&&(e(t),t.querySelectorAll("[controller]").forEach(e))})});function n(){document.querySelectorAll("[controller]").forEach(e),t.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n(),globalThis.sniceNativeControllerObserver=t}const Yt=Symbol.for("snice:html-result"),Zt=Symbol.for("snice:css-result"),en=new WeakMap;function tn(e,...t){return{_$litType$:Yt,strings:e,values:t}}function nn(e,...t){return{_$litType$:Yt,strings:e,values:t,svg:!0}}function on(e,...t){const n=0===t.length?en.get(e):void 0;if(n)return n;let o=e[0];for(let n=0;n<t.length;n++){const r=t[n];o+=(sn(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:Zt,cssText:o};if("undefined"!=typeof CSSStyleSheet&&"undefined"!=typeof Document&&"adoptedStyleSheets"in Document.prototype)try{const e=new CSSStyleSheet;e.replaceSync(o),r.styleSheet=e}catch(e){}return 0===t.length&&en.set(e,r),r}function rn(e){return e&&e._$litType$===Yt}function sn(e){return e&&e._$litType$===Zt}const an=Symbol.for("snice:nothing"),cn=Symbol.for("snice:unsafe-html");function ln(e){return{_$litType$:cn,html:e}}function un(e){return e&&e._$litType$===cn}const hn=Symbol.for("snice:repeat-result");function dn(e,t){if(!t||"function"!=typeof t.key||"function"!=typeof t.render)throw new TypeError("snice: repeat() requires { key, render }.");const n=null==e?[]:Array.from(e),o=n.map(t.key),r=new Set;for(const e of o){if(r.has(e))throw new Error(`snice: repeat() received duplicate key ${String(e)}.`);r.add(e)}return{_$repeat$:hn,items:n,keys:o,values:n.map(t.render),empty:0===n.length?"function"==typeof t.empty?t.empty():t.empty:void 0}}const fn=new WeakSet;function mn(e){return e[g]||e.shadowRoot||null}function pn(e){const t=mn(e);if(t)return t;const n=e.constructor[b];let o;if(o="light"===n?.renderRoot||!1===n?.shadow?e:"function"==typeof e.createRenderRoot?e.createRenderRoot():e.attachShadow({mode:"string"==typeof n?.shadow?n.shadow:"open",delegatesFocus:n?.delegatesFocus}),o!==e&&!(o instanceof ShadowRoot))throw new TypeError("snice: createRenderRoot() must return the host element or a ShadowRoot.");return e[g]=o,fn.add(e),o}function yn(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&fn.has(n))return n;n=n.parentNode}return null}const gn=/^[a-z][a-z0-9._-]{0,127}$/,bn=/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/,vn=Symbol("ambiguous-render-host-identity"),wn=new WeakMap;function En(e,t){try{if("function"!=typeof e||!gn.test(t))return;const n=Object.getOwnPropertyDescriptor(e,"prototype"),o=n&&"value"in n?n.value:void 0;if("object"!=typeof o&&"function"!=typeof o||null===o)return;const r=Object.getOwnPropertyDescriptor(e,"name"),s=r&&"value"in r&&"string"==typeof r.value?r.value:"",i=bn.test(s)?s:"",a=Object.freeze({label:i?`<${t}> (${i})`:`<${t}>`}),c=[wn.get(e),wn.get(o)].filter(e=>void 0!==e),l=c.some(e=>e===vn||e.label!==a.label),u=l?vn:c[0]??a;wn.set(e,u),wn.set(o,u)}catch{}}class Nn extends Error{#e;constructor(e,t,n){super(t,{cause:n}),this.#e=e.marker}belongsTo(e){return this.#e===e.marker}}function An(e,t){if(t instanceof Nn&&t.belongsTo(e))return t;const n=t instanceof Error?t.message:String(t),o=new Nn(e,`snice: render failed for ${e.label}: ${n}`,t);return t instanceof Error&&(o.name=t.name),o}const Tn=`snice$${Math.random().toFixed(9).slice(2)}$`,Sn="?"+Tn,_n=`\x3c!--${Sn}--\x3e`,On=new RegExp(Tn.replace(/\$/g,"\\$"),"g"),xn=new WeakMap,Cn=Symbol("not-committed"),kn=new WeakMap;function $n(e,t){return Object.prototype.isPrototypeOf.call(t.prototype,e)}function Ln(e,t){const n=e.localName,o=n&&t?.get(n);if(!o||!$n(e,o))return;const r=e,s=r[M];if(s?.size){for(const e of Array.from(s)){if(Object.prototype.hasOwnProperty.call(r,e)){const t=r[e];delete r[e],r[e]=t}s.delete(e)}delete r[M]}}function Pn(e,t,n,o){!function(e,t,n){const o=e.localName;if(!o?.includes("-"))return!1;const r=n?.get(o);if(r){if($n(e,r))return!1;const n=r[$];if(!n?.has(t))return!1}const s=e;return s[M]||(s[M]=new Set),s[M].add(t),function(e,t){if(!t?.whenDefined||kn.get(e)===t)return;kn.set(e,t);const n=new WeakRef(e);t.whenDefined(e.localName).then(()=>{const e=n.deref();e&&Ln(e,t)})}(e,n),!0}(e,t,o)?e[t]=n:Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n})}const jn=Symbol.for("snice:no-change"),Rn=Symbol.for("snice:live");function Mn(e){return{_$liveMarker$:Rn,value:e}}const In=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Dn=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class Vn{constructor(e,t,n){this.parts=[],this.keyIndex=-1,this.element=t;const o=document.createTreeWalker(t.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let r=0;const s=[];let i;for(;null!==(i=o.nextNode());)if(i.nodeType===Node.ELEMENT_NODE){const e=i,t=e.tagName.toLowerCase(),o=e.parentElement?.tagName.toLowerCase();if(("else"===t||"else-if"===t)&&"if"!==o)throw new Error(`snice: <${t}> must be a direct child of <if>.`);if(("when"===t||"default"===t)&&"case"!==o)throw new Error(`snice: <${t}> must be a direct child of <case>.`);if("if"===t){const t=e.getAttribute("value");if(!t||!t.includes(Tn))throw new Error("snice: <if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-if",index:r++,element:e});continue}if("case"===t){const t=e.getAttribute("value");if(!t||!t.includes(Tn))throw new Error("snice: <case> requires a value expression.");for(const t of Array.from(e.childNodes))if(t.nodeType===Node.ELEMENT_NODE){const e=t.tagName.toLowerCase();if("when"!==e&&"default"!==e)throw new Error("snice: <case> may contain only direct <when> and <default> branches.")}else if(t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()||t.nodeType===Node.COMMENT_NODE&&t.data.includes(Tn))throw new Error("snice: content inside <case> must be nested in a <when> or <default> branch.");e.removeAttribute("value"),this.parts.push({type:"conditional-case",index:r++,element:e});continue}if("else-if"===t){const t=e.getAttribute("value");if(!t||!t.includes(Tn))throw new Error("snice: <else-if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-else-if",index:r++,element:e});continue}if("when"===t){const t=e.getAttribute("value");t&&t.includes(Tn)&&(e.removeAttribute("value"),this.parts.push({type:"conditional-when",index:r++,element:e}));continue}if(e.hasAttributes()){const t=e.attributes,o=[];for(let s=0;s<t.length;s++){const i=t[s],a=i.value;if(a.includes(Tn)){o.push(i);const t=n[r]||i.name,s=a.split(Tn),c=s.length-1;if(/^@@?|^[.?]/.test(t)||t.startsWith("...")||t.startsWith("class:")||t.startsWith("style:")){const e=s.some(e=>""!==e);(c>1||e)&&console.warn(`snice: binding "${t}" takes a single expression; static text and extra interpolations are ignored. Use a plain attribute for string interpolation.`)}if(t.startsWith("...")){const n=t.slice(3).toLowerCase();if(!["props","properties","attrs","attributes","events"].includes(n))throw new Error(`snice: unknown spread binding "${t}". Use ...props, ...attrs, or ...events.`);this.parts.push({type:"spread",index:r,name:n,element:e}),r+=c}else if(t.startsWith("class:")){if(!t.slice(6))throw new Error("snice: class: binding requires a class name.");this.parts.push({type:"class",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("style:")){if(!t.slice(6))throw new Error("snice: style: binding requires a CSS property name.");this.parts.push({type:"style",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("@@")){if(!t.slice(2).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("@")){if(!t.slice(1).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith(".")){if(!t.slice(1))throw new Error("snice: property binding requires a property name.");this.parts.push({type:"property",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("?")){if(!t.slice(1))throw new Error("snice: boolean binding requires an attribute name.");this.parts.push({type:"boolean-attribute",index:r,name:t.slice(1),element:e}),r+=c}else"controller"===i.name&&2===s.length&&""===s[0]&&""===s[1]?(this.parts.push({type:"controller",index:r,element:e}),r+=c):(this.parts.push({type:"attribute",index:r,name:i.name,element:e,attrStrings:s}),r+=c)}}for(const t of o)e.removeAttribute(t.name)}}else if(i.nodeType===Node.COMMENT_NODE){const e=i;if(e.data===Sn){const t=e.parentNode,n=document.createComment("");t.insertBefore(n,e.nextSibling),this.parts.push({type:"node",index:r++,startNode:e,endNode:n})}else if(e.data.includes(Tn)){const t=e.data.split(On);this.parts.push({type:"comment",index:r,startNode:e,attrStrings:t}),r+=t.length-1}}else if(i.nodeType===Node.TEXT_NODE){const e=i,t=e.data;if(t.includes(Tn)){const n=e.parentNode,o=t.split(On),i=o.length-1;for(let t=0;t<i;t++){n.insertBefore(document.createTextNode(o[t]),e);const s=document.createComment(""),i=document.createComment("");n.insertBefore(s,e),n.insertBefore(i,e),this.parts.push({type:"node",index:r++,startNode:s,endNode:i})}""!==o[i]?e.data=o[i]:s.push(e)}}for(const e of s)e.parentNode?.removeChild(e);for(const e of this.parts)if("attribute"===e.type&&"key"===e.name){this.keyIndex=e.index;break}}}function qn(e){const{strings:t}=e,n=xn.get(t);if(n)return n;const o=[],r=[];let s=!1,i=!1,a=!1,c="",l="";for(let e=0;e<t.length;e++){const n=t[e];if(o.push(n),e<t.length-1){for(let e=0;e<n.length;e++){const t=n[e];if(a)"-"===t&&n.startsWith("--\x3e",e)&&(a=!1,e+=2);else if(s){if(i)t===c&&(i=!1,c="");else if(">"===t)s=!1;else if('"'===t||"'"===t)i=!0,c=t;else if("="===t){let t=e-1;for(;t>=0&&/[\w\-\.@\?/:\+~|]/.test(n[t]);)t--;l=n.substring(t+1,e).trim()}}else"<"===t&&(n.startsWith("\x3c!--",e)?(a=!0,e+=3):/[A-Za-z!/?]/.test(n[e+1]||"")&&(s=!0))}if(a)r.push(""),o.push(Tn);else if(i)r.push(l),o.push(Tn);else if(s){const s=n.trimEnd();if(s.endsWith("=")){let e=s.length-2;for(;e>=0&&/[\w\-\.@\?\/:\+~|]/.test(s[e]);)e--;l=s.substring(e+1,s.length-1).trim(),r.push(l),o.push(Tn)}else{if(!n.match(/<(if|else-if|case|when)\s*$/)){const o=(n.slice(-40)+"${…}"+(t[e+1]??"").slice(0,40)).replace(/\s+/g," ").trim();throw new Error(`snice: expressions directly in opening tags are not supported; use an explicit attribute, property, event, class, style, or named spread binding. Near "${o}".`)}l="value",r.push("value"),o.push(`value="${Tn}"`)}}else r.push(""),o.push(_n)}}const u=o.join(""),h=document.createElement("template");if(e.svg){h.innerHTML=`<svg>${u}</svg>`;const e=h.content.firstElementChild;for(;e.firstChild;)h.content.insertBefore(e.firstChild,e);h.content.removeChild(e)}else h.innerHTML=u;let d;try{d=new Vn(e,h,r)}catch(e){throw function(e,t){if(e instanceof Error&&/\bNear "[\s\S]*"\.$/.test(e.message))return e;const n=e instanceof Error?e.message:String(e),o=Array.from(t).join("${…}").replace(/\s+/g," ").trim(),r=/<([a-z][a-z0-9-]*)>/i.exec(n)?.[1],s=/binding "([^"]+)"/i.exec(n)?.[1],i=r?`<${r}`:s??"",a=i?o.indexOf(i):-1,c=a>=0?a:0,l=Math.max(0,c-40),u=Math.min(o.length,c+80),h=u<o.length?"…":"";return new Error(`${n} Near "${l>0?"…":""}${o.slice(l,u)}${h}".`,{cause:e})}(e,t)}return xn.set(t,d),d}class Bn{#t;#n;constructor(e,t=null,n=document.defaultView?.customElements??globalThis.customElements??null){this.parts=[],this.fragment=null,this.conditionalParts=[],this.regularParts=[],this.#t=t,this.#n=n;try{this.template=qn(e)}catch(e){throw t?An(t,e):e}this.strings=e.strings}isSameTemplate(e){return this.strings===e}getRenderHostIdentity(){return this.#t}renderFragment(){if(!this.fragment){this.fragment=this.template.element.content.cloneNode(!0);const e=document.createTreeWalker(this.template.element.content,NodeFilter.SHOW_ALL),t=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ALL),n=new Map;let o=e.currentNode,r=t.currentNode;for(;o&&r;)n.set(o,r),o=e.nextNode(),r=t.nextNode();const s=new Set;for(const e of this.template.parts)"conditional-when"===e.type&&s.add(n.get(e.element));for(let e=0;e<this.template.parts.length;e++){const t=this.template.parts[e];let o;switch(t.type){case"node":const e=n.get(t.startNode),r=n.get(t.endNode);o=new Wn(e,r,this.#t,this.#n);break;case"attribute":const i=n.get(t.element);o=new zn(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new Qn(a,t.name,this.#n);break;case"boolean-attribute":const c=n.get(t.element);o=new Xn(c,t.name);break;case"event":const l=n.get(t.element);o=new Yn(l,t.name);break;case"class":const u=n.get(t.element);o=new Hn(u,t.name);break;case"style":const h=n.get(t.element);o=new Kn(h,t.name);break;case"spread":const d=n.get(t.element);o=new Gn(d,t.name,this.#n);break;case"controller":const f=n.get(t.element);o=new Jn(f);break;case"conditional-if":const m=n.get(t.element);o=new eo(m);break;case"conditional-else-if":const p=n.get(t.element);o=new no(p);break;case"conditional-case":const y=n.get(t.element);o=new oo(y,s);break;case"conditional-when":const g=n.get(t.element);o=new so(g);break;case"comment":const b=n.get(t.startNode);o=new Un(b,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof eo||o instanceof no||o instanceof oo||o instanceof so?this.conditionalParts.push({part:o,index:t.index}):this.regularParts.push({part:o,index:t.index})}}return this.fragment}render(e){const t=this.renderFragment();return this.update(e),t}update(e){for(const{part:t,index:n}of this.conditionalParts)t.commit(e[n]);const t=new Set;for(const{part:e}of this.conditionalParts){const n=e instanceof no||e instanceof so?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof eo||n instanceof oo)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof zn&&void 0!==t.strings||t instanceof Un?t.commit(e,n):t.commit(e[n]);let n;for(const e of this.parts)try{e.isConnected?e.reconnected():e.disconnected()}catch(e){n??=e}if(n)throw n}clear(){let e;for(const t of this.parts)try{t.destroy()}catch(t){e??=t}if(e)throw e}disconnected(e=!1){let t;for(const n of this.parts)try{n.disconnected(e)}catch(e){t??=e}if(t)throw t}reconnected(){let e;for(const t of this.parts)try{t.reconnected()}catch(t){e??=t}if(e)throw e}}class Fn{get isConnected(){return this.element?.isConnected??!1}disconnected(e=!1){}reconnected(){}destroy(){let e;try{this.clear()}catch(t){e=t}if(e)throw e}}class Wn extends Fn{#t;#n;constructor(e,t,n=null,o=null){super(),this.type="node",this._committedValue=Cn,this._itemKeys=null,this._asyncSource=null,this._asyncVersion=0,this._asyncIterator=null,this._asyncRunning=!1,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1,this._committingAsyncValue=!1,this.startNode=e,this.endNode=t,this.#t=n,this.#n=o}_withRenderContext(e){return this.#t?An(this.#t,e):e}commit(e){if(e!==jn)if((e=>!!e&&"function"==typeof e.then)(e)||Dn(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==an&&null!=e&&""!==e)In(e)?e!==this._committedValue&&this._commitText(e):rn(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===hn}(e)?0===e.values.length?this.commit(e.empty??an):this._commitIterable(e.values,e.keys):un(e)?this._commitUnsafeHTML(e):void 0===e.nodeType?(e=>Array.isArray(e)||"function"==typeof e?.[Symbol.iterator])(e)?this._commitIterable(e):this._commitText(e):this._commitNode(e);else{if(this._committedValue!==an){const e=this._clear();if(this._committedValue=an,e)throw e}this._committedValue=an}}_commitText(e){if(this._committedValue!==Cn&&this._committedValue!==an&&In(this._committedValue)&&!Array.isArray(this._committedValue)){const t=this.startNode.nextSibling;if(t&&t.nodeType===Node.TEXT_NODE)return t.data=String(e),void(this._committedValue=e)}const t=this._clear();if(this._insertBefore(document.createTextNode(String(e))),this._committedValue=e,t)throw t}_commitTemplateResult(e){const t=this._committedValue;if(t instanceof Bn){const n=xn.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new Bn(e,this.#t,this.#n),o=n.renderFragment();try{n.update(e.values)}catch(e){throw n.clear(),e}const r=this._committedValue,s=this._itemKeys,i=this.endNode.ownerDocument.createDocumentFragment();let a=this.startNode.nextSibling;for(;a&&a!==this.endNode;){const e=a.nextSibling;i.appendChild(a),a=e}this._insertBefore(o),this._committedValue=n,this._itemKeys=null;try{this.isConnected&&n.reconnected()}catch(e){try{n.clear()}catch(e){console.error("snice: failed to clean up a rejected nested template:",e)}let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const e=t.nextSibling;t.remove(),t=e}throw this._insertBefore(i),this._committedValue=r,this._itemKeys=s,e}this._disposeCommitted(r)}_commitIterable(e,t){const n=Array.isArray(e)?e:Array.from(e),o=t?Array.from(t):n.map(e=>function(e,t){if(!rn(e))return;let n;try{n=qn(e)}catch(e){throw t?An(t,e):e}return-1===n.keyIndex?void 0:e.values[n.keyIndex]}(e,this.#t));if(o.length!==n.length)throw new Error("snice: keyed iterable produced a different number of keys and values.");const r=o.filter(e=>void 0!==e);if(r.length>0&&r.length!==o.length&&console.warn("snice: a list mixes keyed and unkeyed items. Identity falls back to position; use repeat(items, { key, render }) for deterministic updates."),r.length>0&&new Set(r).size!==r.length)throw new Error("snice: a keyed list contains duplicate keys.");let s;Array.isArray(this._committedValue)&&this._committedValue[0]instanceof Wn||(s=this._clear(),this._committedValue=[],this._itemKeys=null);const i=n.length>0&&o.every(e=>void 0!==e),a=this._itemKeys;if(i&&a&&this._committedValue.length>0&&(a.length!==o.length||!o.every((e,t)=>e===a[t]))){if(s??=this._reconcileKeyed(n,o,this._committedValue,a),this._itemKeys=o,s)throw s;return}const c=this._committedValue;let l=0;for(const e of n){let t;if(l>=c.length){const e=document.createComment(""),n=document.createComment("");this._insertBefore(e),this._insertBefore(n),t=new Wn(e,n,this.#t,this.#n),c.push(t)}else t=c[l];t.commit(e),l++}if(l<c.length){for(let e=l;e<c.length;e++){const t=c[e];try{t.destroy()}catch(e){s??=e}t.startNode.remove(),t.endNode.remove()}c.length=l}if(this._itemKeys=i?o:null,s)throw s}_reconcileKeyed(e,t,n,o){const r=this.endNode.parentNode;let s;const i=new Map;for(let e=0;e<n.length;e++)i.has(o[e])||i.set(o[e],n[e]);const a=new Set,c=new Array(e.length).fill(null);for(let n=0;n<e.length;n++){const e=i.get(t[n]);e&&!a.has(e)&&(a.add(e),c[n]=e)}for(const e of n)if(!a.has(e)){try{e.destroy()}catch(e){s??=e}e.startNode.remove(),e.endNode.remove()}let l=this.startNode.nextSibling;for(let t=0;t<c.length;t++){let n=c[t];if(n)if(n.startNode===l)l=n.endNode.nextSibling;else{const e=document.createDocumentFragment();let t=n.startNode;const o=n.endNode.nextSibling;for(;t&&t!==o;){const n=t.nextSibling;e.appendChild(t),t=n}r.insertBefore(e,l)}else{const e=document.createComment(""),o=document.createComment("");r.insertBefore(e,l),r.insertBefore(o,l),n=new Wn(e,o,this.#t,this.#n),c[t]=n}n.commit(e[t])}return this._committedValue=c,s}_commitNode(e){if(this._committedValue!==e){const t=this._clear();if(this._insertBefore(e),this._committedValue=e,t)throw t}}_commitUnsafeHTML(e){const t=this._committedValue;if(un(t)&&t.html===e.html)return;const n=this._clear(),o=document.createElement("template");if(o.innerHTML=e.html,this._insertBefore(o.content),this._committedValue=e,n)throw n}_commitAsync(e){if(e===this._asyncSource)return;this._cancelAsync(!1),this._asyncSource=e,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1;const t=this._clear();if(this._committedValue=an,this._startAsyncSource(),t)throw t}_startAsyncSource(e=!1){const t=this._asyncSource;if(!t||this._asyncRunning||this._asyncCompleted||!e&&!this.isConnected)return;this._asyncRunning=!0,this._asyncStarted=!0,this._asyncPaused=!1;const n=++this._asyncVersion;if(Dn(t)){try{this._asyncIterator=t[Symbol.asyncIterator]()}catch(e){return this._asyncRunning=!1,this._asyncCompleted=!0,void console.error("snice: async iterable template value failed:",this._withRenderContext(e))}(async()=>{try{for(;this._asyncIterator;){const e=await this._asyncIterator.next();if(e.done||n!==this._asyncVersion)break;this._commitAsyncValue(e.value)}}catch(e){n===this._asyncVersion&&console.error("snice: async iterable template value failed:",this._withRenderContext(e))}finally{n===this._asyncVersion&&(this._asyncIterator=null,this._asyncRunning=!1,this._asyncCompleted=!0)}})()}else Promise.resolve(t).then(e=>{if(n===this._asyncVersion){this._asyncRunning=!1,this._asyncCompleted=!0;try{this._commitAsyncValue(e)}catch(e){console.error("snice: promise template value failed:",this._withRenderContext(e))}}},e=>{n===this._asyncVersion&&(this._asyncRunning=!1,this._asyncCompleted=!0,console.error("snice: promise template value failed:",this._withRenderContext(e)))})}_commitAsyncValue(e){this._committingAsyncValue=!0;try{this.commit(e)}finally{this._committingAsyncValue=!1}}_cancelAsync(e){this._asyncVersion++;const t=this._asyncIterator;if(this._asyncIterator=null,this._asyncRunning=!1,e&&(this._asyncSource=null,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1),t?.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}_insertBefore(e){this.endNode.parentNode?.insertBefore(e,this.endNode)}_clear(){const e=this.startNode.parentNode,t=this._committedValue;let n;try{this._disposeCommitted(t)}catch(e){n=e}if(!e)return this._committedValue=an,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=an,n}_disposeCommitted(e){let t;if(e instanceof Bn)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof Wn)try{n.destroy()}catch(e){t??=e}if(t)throw t}clear(){this._cancelAsync(!0);const e=this._clear();if(e)throw e}get isConnected(){return this.startNode.isConnected}disconnected(e=!1){let t;if(this._committedValue instanceof Bn)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof Wn)try{n.disconnected(e)}catch(e){t??=e}if(this._asyncSource&&this._asyncRunning&&(this._cancelAsync(!1),this._asyncPaused=!0),t)throw t}reconnected(){let e;if(this._committedValue instanceof Bn)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof Wn)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class zn extends Fn{constructor(e,t,n){super(),this.type="attribute",this._committedValue=Cn,this.lastValues=null,this.lastValueIndex=0,this.element=e,this.name=t,n&&(n.length>2||""!==n[0]||""!==n[1])?(this._committedValue=new Array(n.length-1).fill(Cn),this.strings=n):this._committedValue=Cn}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===jn)return;if(o=!In(e)||e!==this._committedValue&&e!==jn,!o)return;this._committedValue=e,n=e}else{const r=e;this.lastValues=[...r],this.lastValueIndex=t;const s=this._committedValue;n=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let i=r[t+e];i===jn&&(i=s[e],i===Cn&&(i="")),o=o||!In(i)||i!==s[e],i===an?n=an:n!==an&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===an?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class Un extends Fn{constructor(e,t){super(),this.type="node",this.lastValues=null,this.lastValueIndex=0,this.node=e,this.strings=t,this._committedValues=new Array(t.length-1).fill(Cn)}commit(e,t=0){const n=e;this.lastValues=[...n],this.lastValueIndex=t;let o=!1,r=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let s=n[t+e];s===jn&&(s=this._committedValues[e],s===Cn&&(s="")),o=o||!In(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===an?"":s??"")+this.strings[e+1]}if(o){if(r.includes("--")||r.endsWith("-"))throw new Error('snice: comment expressions cannot produce "--" or end with "-".');this.node.data=r}}clear(){}}class Hn extends Fn{constructor(e,t){super(),this.type="class",this.committed=Cn,this.element=e,this.name=t}commit(e){if(e===jn)return;const t=e!==an&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=Cn}}class Kn extends Fn{constructor(e,t){super(),this.type="style",this.committed=Cn,this.element=e,this.name=t}commit(e){if(e===jn||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===an||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=Cn}}class Gn extends Fn{#n;constructor(e,t,n=null){super(),this.type="spread",this.committed={},this.listeners=new Map,this.consumedOnce=new Map,this.element=e,this.name=t,this.#n=n}commit(e){if(e===jn)return;if(e!==an&&null!=e||(e={}),"object"!=typeof e||Array.isArray(e))throw new TypeError(`snice: ...${this.name} expects an object.`);const t=e;"events"===this.name?this.commitEvents(t):"props"===this.name||"properties"===this.name?this.commitProperties(t):this.commitAttributes(t),this.committed={...t}}commitProperties(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||Pn(this.element,t,void 0,this.#n);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||Pn(this.element,t,n===an?void 0:n,this.#n)}commitAttributes(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||this.element.removeAttribute(t);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(n===an||null==n||!1===n?this.element.removeAttribute(t):this.element.setAttribute(t,!0===n?"":String(n)))}commitEvents(e){!function(e,t){const n=new Set;for(const[o,r]of Object.entries(e)){const e=o.startsWith("@")?o.slice(1):o;if(!e)throw new TypeError(`snice: ${t} contains an empty event name.`);if(n.has(e))throw new TypeError(`snice: ${t} contains duplicate event name "${e}".`);if(n.add(e),r!==an&&null!=r&&!1!==r&&"function"!=typeof r&&(!r||"object"!=typeof r||"function"!=typeof r.handleEvent))throw new TypeError(`snice: ${t} event "${e}" expects a function, EventListenerObject, or null.`)}}(e,`...${this.name}`);for(const[t,n]of this.consumedOnce){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n)||this.consumedOnce.delete(t)}for(const[t,n]of this.listeners){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n.value)||(this.element.removeEventListener(t,n.listener,n.options),this.listeners.delete(t))}for(const[t,n]of Object.entries(e)){const e=this.eventName(t);if(this.listeners.has(e))continue;const o=!!n&&"object"==typeof n&&"function"==typeof n.handleEvent;if(n===an||null==n||!1===n)continue;if(this.consumedOnce.has(e)&&Object.is(this.consumedOnce.get(e),n))continue;this.consumedOnce.delete(e);const r=o?n:void 0,s=t=>{r?.once&&this.consumedOnce.set(e,n),o?n.handleEvent(t):n.call(this.resolveHost(),t)};this.element.addEventListener(e,s,r),this.listeners.set(e,{value:n,listener:s,options:r})}}eventName(e){return e.startsWith("@")?e.slice(1):e}resolveHost(){return yn(this.element)||this.element}clear(){if("events"===this.name){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear(),this.consumedOnce.clear()}else if("props"!==this.name&&"properties"!==this.name)for(const e of Object.keys(this.committed))this.element.removeAttribute(e);this.committed={}}disconnected(e=!1){"events"!==this.name||e||this.detachListeners()}reconnected(){"props"!==this.name&&"properties"!==this.name||Ln(this.element,this.#n),"events"===this.name&&0===this.listeners.size&&this.commitEvents(this.committed)}detachListeners(){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear()}}class Qn extends Fn{#n;constructor(e,t,n=null){super(),this.type="property",this._committedValue=Cn,this.element=e,this.name=t,this.#n=n}commit(e){if(e!==jn){if(function(e){return e&&e._$liveMarker$===Rn}(e)){if((e=e.value)===jn)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,Pn(this.element,this.name,e===an?void 0:e,this.#n)}}reconnected(){Ln(this.element,this.#n)}clear(){this._committedValue=Cn}}class Jn extends Fn{constructor(e){super(),this.type="controller",this._committedValue=Cn,this.element=e}commit(e){if(e===jn)return;const t=null==e||!1===e||""===e||e===an?null:e,n=this._committedValue===Cn,o=n?null:this._committedValue;if(!n&&t===o)return;this._committedValue=t;const r=this.element;"function"==typeof o&&"function"!=typeof t&&(void 0!==r[C]?delete r[C]:r[i]?r.controller=null:this._detach()),"function"==typeof t?this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[i]&&(r[C]=t):"string"==typeof t?this.element.setAttribute("controller",t):"string"==typeof o&&this.element.removeAttribute("controller")}_apply(e){const t=this.element;t[i]?t.controller!==e?t.controller=e:this._attach(e):this.element.localName.includes("-")?t[C]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){Gt(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){Qt(this.element).catch(e=>{console.error("Failed to detach controller:",e)})}disconnected(e=!1){if("function"!=typeof this._committedValue)return;const t=this.element;void 0===t[C]&&(t[i]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[C]&&delete e[C];const t=this._committedValue;this._committedValue=Cn,"function"==typeof t&&(e[i]||this._detach())}}class Xn extends Fn{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=Cn,this.element=e,this.name=t}commit(e){if(e===jn)return;const t=!!e&&e!==an;t!==this._committedValue&&(this._committedValue=t,t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name))}clear(){this.element.removeAttribute(this.name),this._committedValue=Cn}}class Yn extends Fn{constructor(e,t){super(),this.type="event",this.listener=null,this.listenerOptions=void 0,this.value=void 0,this.keyFilter=null,this.host=null,this.modifiers=new Set,this.once=!1,this.onceConsumed=!1,this.element=e;const[n,...o]=t.split("|"),r={preventdefault:"prevent",stoppropagation:"stop",stopimmediatepropagation:"immediate"},s=new Set(["prevent","stop","immediate","once","capture","passive","self"]);for(const e of o){const n=r[e.toLowerCase()]||e.toLowerCase();if(!s.has(n))throw new Error(`snice: unknown event modifier "${e}" in @${t}. Supported modifiers: prevent, stop, immediate, once, capture, passive, self.`);this.modifiers.add(n)}if(this.modifiers.has("passive")&&this.modifiers.has("prevent"))throw new Error(`snice: @${t} cannot combine passive and prevent.`);const i=["keydown","keyup","keypress"].includes(n.split(".")[0].split(":")[0]),a=i?n.indexOf("."):-1,c=i?n.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c);if(l>0){const e=n.substring(0,l),t=n.substring(l+1);this.eventName=e,this.keyFilter=St(t)}else this.eventName=n,Tt(n)}commit(e){if(e===jn)return;e===an&&(e=null);const t=!!e&&"object"==typeof e&&"function"==typeof e.handleEvent;if(null!=e&&!1!==e&&"function"!=typeof e&&!t)throw new TypeError(`snice: @${this.eventName} expects a function, EventListenerObject, or null.`);if(t&&this.modifiers.has("prevent")&&e.passive)throw new Error(`snice: @${this.eventName} cannot combine a passive listener object with prevent.`);if(e!==this.value||null==e){if(this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0),null==e||!1===e)return this.value=e,void(this.onceConsumed=!1);this.onceConsumed=!1;try{this.attachListener(e,t),this.value=e}catch(e){throw this.value=void 0,e}}}attachListener(e,t){const n=this.keyFilter,o=r=>{this.modifiers.has("self")&&r.target!==this.element||n&&!Ot(r,n)||(this.once&&(this.onceConsumed=!0,this.element.removeEventListener(this.eventName,o,s),this.listener=null,this.listenerOptions=void 0),this.modifiers.has("prevent")&&r.preventDefault(),this.modifiers.has("immediate")?r.stopImmediatePropagation():this.modifiers.has("stop")&&r.stopPropagation(),t?e.handleEvent(r):(this.host||(this.host=yn(this.element)),e.call(this.host||this.element,r)))},r=t?e:{};this.once=this.modifiers.has("once")||!!r.once;const s={capture:this.modifiers.has("capture")||r.capture,passive:this.modifiers.has("passive")||r.passive,signal:r.signal};this.element.addEventListener(this.eventName,o,s),this.listener=o,this.listenerOptions=s}clear(){this.detachListener(),this.value=void 0,this.host=null,this.onceConsumed=!1}detachListener(){this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0)}disconnected(e=!1){e||this.detachListener(),this.host=null}reconnected(){this.listener||this.onceConsumed||null==this.value||!1===this.value||this.attachListener(this.value,"object"==typeof this.value)}}const Zn=Symbol("not-set");class eo extends Fn{constructor(e){super(),this.type="node",this.conditions=[Zn],this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const t=e.parentNode;this.startNode=document.createComment("if"),this.endNode=document.createComment("/if"),t.insertBefore(this.startNode,e),t.insertBefore(this.endNode,e.nextSibling);const n=document.createDocumentFragment();this.branches.push(n);let o=!1,r=n;for(const t of Array.from(e.childNodes)){const e=t.nodeType===Node.ELEMENT_NODE?t.tagName.toLowerCase():"";if("else-if"===e||"else"===e){o=!0;const n=t,s=document.createDocumentFragment();for(;n.firstChild;)s.appendChild(n.firstChild);const i=this.branches.push(s)-1;if(r=s,"else-if"===e){if(-1!==this.defaultBranch)throw new Error("snice: <else> must be the final branch inside <if>.");this.conditions[i]=Zn,to.set(n,{coordinator:this,index:i})}else{if(-1!==this.defaultBranch)throw new Error("snice: <if> may contain only one <else> branch.");this.defaultBranch=i}n.remove();continue}o?t.nodeType!==Node.TEXT_NODE||t.textContent?.trim()?r.appendChild(t):t.remove():n.appendChild(t)}t.removeChild(e)}commit(e){e!==jn&&(this.conditions[0]=e)}setAlternative(e,t){t!==jn&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==Zn&&this.conditions[t]!==an&&Boolean(this.conditions[t])){e=t;break}-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e],this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch];let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const to=new WeakMap;class no extends Fn{constructor(e){super(),this.type="node";const t=to.get(e);if(!t)throw new Error("snice: <else-if> must be a direct child of <if>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setAlternative(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}class oo extends Fn{constructor(e,t){super(),this.type="node",this.value=Zn,this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const n=e.parentNode;this.startNode=document.createComment("case"),this.endNode=document.createComment("/case"),n.insertBefore(this.startNode,e),n.insertBefore(this.endNode,e.nextSibling);for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();if("when"===e){const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);const o=t.has(n),r=this.branches.push({fragment:e,dynamic:o,expected:o?Zn:n.getAttribute("value")??""})-1;o&&ro.set(n,{coordinator:this,index:r})}else if("default"===e){if(-1!==this.defaultBranch)throw new Error("snice: <case> may contain only one <default> branch.");const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);this.defaultBranch=this.branches.push({fragment:e,dynamic:!1,expected:Zn})-1}}n.removeChild(e)}commit(e){e!==jn&&(this.value=e)}setExpected(e,t){t!==jn&&(this.branches[e].expected=t)}flush(){let e=this.branches.findIndex((e,t)=>t!==this.defaultBranch&&(e.dynamic?Object.is(this.value,e.expected):String(this.value)===e.expected));-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].fragment.hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e].fragment,this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch].fragment;let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const ro=new WeakMap;class so extends Fn{constructor(e){super(),this.type="node";const t=ro.get(e);if(!t)throw new Error("snice: dynamic <when> must be a direct child of <case>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setExpected(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}const io=new WeakSet,ao=new WeakSet,co=["a[href]","area[href]","button:not([disabled])",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])","iframe","object","embed","summary","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])','[tabindex]:not([tabindex="-1"])'].join(",");function lo(e){try{e.focus()}catch{return!1}return function(e){const t=e.getRootNode().activeElement;return t===e||Boolean(t&&e.contains(t))}(e)}function uo(e){return e?Array.from(e.querySelectorAll("[autofocus]")).filter(e=>!ao.has(e)):[]}function ho(e){return e?Array.from(e.querySelectorAll(co)):[]}function fo(e){if(io.has(e)||!function(e){return!(!e.hasAttribute("autofocus")||ao.has(e))||uo(mn(e)).length>0}(e))return;io.add(e);const t=()=>{const t=e.ownerDocument.defaultView,n=()=>{io.delete(e),function(e){if(!e.isConnected)return;const t=mn(e),n=[];if(e.hasAttribute("autofocus")&&!ao.has(e)&&n.push(e),n.push(...uo(t)),0!==n.length)if(function(e){const t=e.activeElement;return Boolean(t&&t!==e.body&&t!==e.documentElement)}(e.ownerDocument))for(const e of n)ao.add(e);else for(const o of n){if(ao.add(o),lo(o))return;if(o===e)for(const e of ho(t))if(lo(e))return}}(e)};t?.requestAnimationFrame?t.requestAnimationFrame(n):queueMicrotask(n)};Promise.resolve(e.ready).then(t,t)}let mo=!1;function po(e){mo=e}function yo(e){e[m]||(e[f]=new Promise(t=>{e[m]=t}))}function go(e){const t=e[m];t&&(e[m]=null,t())}const bo=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?No(e,t):(this.pending.add(e),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush())))}flush(){const e=Array.from(this.pending);this.pending.clear(),this.scheduled=!1;for(const t of e)t.isConnected?No(t,t[ee]||{}):t[p]=!0}remove(e){this.pending.delete(e)}};function vo(e){return Object.prototype.hasOwnProperty.call(e,te)}function wo(e){const t=e[oe];if(!t||0===t.length)return;const n=[...t];e[oe]=[],n.forEach(e=>e())}const Eo=50;function No(e,t,n){const o=function(e){let t="<element>";try{const n=function(e){const t=Object.getPrototypeOf(e);if(!t)return;const n=Object.getOwnPropertyDescriptor(t,"constructor"),o=n&&"value"in n?n.value:void 0;if("function"!=typeof o)return;const r=wn.get(t),s=wn.get(o);return r!==vn&&r===s?r:void 0}(e);n&&(t=n.label)}catch{}return Object.freeze({label:t,marker:Symbol("render-host-identity")})}(e);let r=o;const s=arguments.length>=3,i=e[Z];if(!i)return void go(e);if(t.once&&vo(e))return void go(e);const a=e[y]??0;if(a>=Eo){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${Eo}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void go(e)}e[y]=a+1;try{const a=s?n:i.call(e),c=pn(e);if(!1===t.differential){if("string"!=typeof a)return void console.warn("Render method with differential: false must return a string");const t=document.createElement("template");t.innerHTML=a;const n=e[te];n?.clear();const o=Array.from(c.childNodes).filter(e=>!(e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")));for(const e of o)e.remove();return c.appendChild(t.content),e[te]=null,wo(e),void fo(e)}if(!rn(a))return void console.warn("Render method must return html`` template result");let l=e[te];if(l&&l.isSameTemplate(a.strings))return r=l.getRenderHostIdentity()??o,l.update(a.values),wo(e),void fo(e);const u=c instanceof ShadowRoot?c.customElementRegistry??c.ownerDocument.defaultView?.customElements??null:c.ownerDocument.defaultView?.customElements??null,h=new Bn(a,o,u),d=h.renderFragment();try{h.update(a.values)}catch(e){throw h.clear(),e}const f=document.createDocumentFragment();for(const e of Array.from(c.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||f.appendChild(e);c.appendChild(d);try{e.isConnected&&h.reconnected()}catch(e){try{h.clear()}catch(e){console.error("snice: failed to clean up a rejected render tree:",e)}for(const e of Array.from(c.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||e.remove();throw c.appendChild(f),e}let m;e[te]=h;try{l?.clear()}catch(e){m=e}if(wo(e),fo(e),m)throw m}catch(e){const t=An(r,e);if(mo)throw t;console.error("Error rendering element:",t)}finally{e[y]=a,go(e)}}function Ao(e,t=!1){const n=e[ee]||{};if(n.once&&vo(e))e.isConnected&&To(e);else if(yo(e),t)No(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[ne]||(e[ne]={}),clearTimeout(e[ne].debounce),void(e[ne].debounce=setTimeout(()=>{e[ne].debounce=null,bo.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[ne]||(e[ne]={lastThrottle:0});const t=e[ne],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void bo.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),bo.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}bo.schedule(e,n)}}function To(e){const t=e[te];t?.reconnected()}function So(e={}){return function(t,n){return n.addInitializer(function(){this[Z]=t,this[ee]=e}),function(...n){const o=t.apply(this,n);return No(this,{...this[ee]||e,once:!1},o),o}}}function _o(){return function(e,t){return t.addInitializer(function(){this[re]&&!this[ie]?this[ie]=[this[re]]:this[re]&&this[ie]&&this[ie].push(this[re]),this[re]=e}),e}}const Oo=t("debounce-timers"),xo=t("throttle-timers"),Co=t("once-called"),ko=t("memoize-cache");function $o(e=300,t={}){const{leading:n=!1,trailing:o=!0,maxWait:r}=t;return function(t,s){const i=s.name;return function(...s){this[Oo]||(this[Oo]={});const a=this[Oo],c=i;a[c]&&clearTimeout(a[c].timeout);const l=Date.now(),u=!a[c],h=u?l:a[c].startTime,d=void 0!==r&&l-h>=r;if(n&&u){const e=t.apply(this,s);return a[c]={timeout:null,startTime:h,lastArgs:s},e}const f=setTimeout(()=>{(o||d)&&t.apply(this,a[c].lastArgs),delete a[c]},d?0:e);a[c]={timeout:f,startTime:h,lastArgs:s}}}}function Lo(e=300,t={}){const{leading:n=!0,trailing:o=!0}=t;return function(t,r){const s=r.name;return function(...r){this[xo]||(this[xo]={});const i=this[xo],a=s,c=Date.now();if(!i[a])return n&&t.apply(this,r),i[a]={lastInvoke:c,timeout:null,lastArgs:r},void(o&&!n&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),delete i[a]},e)));const l=c-i[a].lastInvoke;if(i[a].lastArgs=r,i[a].timeout&&clearTimeout(i[a].timeout),l>=e)return t.apply(this,r),void(i[a].lastInvoke=c);o&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),i[a].lastInvoke=Date.now(),i[a].timeout=null},e-l))}}}function Po(e=!0){let t,n=!1;return function(o,r){const s=r.name;return function(...r){return e?(this[Co]||(this[Co]={}),this[Co][s]||(this[Co][s]={called:!0,result:o.apply(this,r)}),this[Co][s].result):(n||(n=!0,t=o.apply(this,r)),t)}}}function jo(e={}){const{keyGenerator:t=(...e)=>JSON.stringify(e),maxSize:n=100,ttl:o}=e;return function(e,r){const s=r.name;return function(...r){this[ko]||(this[ko]={}),this[ko][s]||(this[ko][s]=new Map);const i=this[ko][s],a=t(...r);if(i.has(a)){const e=i.get(a);if(!(void 0!==o&&Date.now()-e.timestamp>o))return e.value;i.delete(a)}const c=e.apply(this,r);if(i.set(a,{value:c,timestamp:Date.now()}),i.size>n){const e=i.keys().next().value;i.delete(e)}return c}}}function Ro(e){if(e[Oo]){for(const t in e[Oo])e[Oo][t]?.timeout&&clearTimeout(e[Oo][t].timeout);e[Oo]={}}}function Mo(e){if(e[xo]){for(const t in e[xo])e[xo][t]?.timeout&&clearTimeout(e[xo][t].timeout);e[xo]={}}}function Io(e,t){e[ko]&&(t?delete e[ko][t]:e[ko]={})}function Do(e,t){e[Co]&&(t?delete e[Co][t]:e[Co]={})}function Vo(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.configurable?{locked:!1,value:void 0}:"value"in n&&!1===n.writable?{locked:!0,value:n.value}:"value"in n||void 0!==n.get?{locked:!1,value:void 0}:{locked:!0,value:void 0}}function qo(e){e.prototype[i]=!0;const t=e.prototype.connectedCallback,n=e.prototype.disconnectedCallback,o=e.prototype.attributeChangedCallback,r=e.observedAttributes||[];r.includes("controller")||r.push("controller"),r.includes("autofocus")||r.push("autofocus");const s=e[$];if(s)for(const[e,t]of s){if(!1===t.attribute)continue;const n=Fe(t,e);r.includes(n)||r.push(n)}Object.defineProperty(e,"observedAttributes",{get:()=>r,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get(){return this[l]||(this[l]=new Promise((e,t)=>{this[u]=e,this[h]=t}),this[l].catch(()=>{})),this[l]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[m]?this[f]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[v]},set(e){const t=this[v];if(this[v]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void Gt(this,e).catch(n=>{"ControllerAttachAborted"!==n?.name?"string"!=typeof e||n?.message!==`Controller "${e}" not found in registry`?console.error(`Failed to attach controller "${t}":`,n):zt(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&Qt(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[l]||(this[l]=new Promise((e,t)=>{this[u]=e,this[h]=t}),this[l].catch(()=>{})),this[w]){try{To(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}Lt(this,this),Et(this,this),qt(this,"task");try{rt(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[U];if(n)for(const e of n)try{const t=e.method.call(this);t&&"function"==typeof t.then&&t.catch(t=>{console.error(`Error in @reconnect handler ${e.methodName}:`,t)})}catch(t){console.error(`Error in @reconnect handler ${e.methodName}:`,t)}return this[Z]&&this[p]&&(this[p]=!1,Ao(this)),void fo(this)}this[I]=!0;const n=e[$];if(n)for(const[e,t]of n){if(!1===t.attribute)continue;const n=Fe(t,e);if(!this.hasAttribute(n))continue;const o=this.getAttribute(n);Ke(this,V).add(e),t.type===Boolean&&""===o&&this.setAttribute(n,"true"),this[e]=qe(o,t)}if(this[R]){for(const[e,t]of Array.from(this[R].entries())){const o=n?.get(e),r=Fe(o||{},e);this[R].delete(e),this.hasAttribute(r)||(this[e]=t)}delete this[R]}if(void 0!==this[C]){const e=this[C];if(delete this[C],!this[v]){this[v]=e;const t=e?.name||"(anonymous controller class)";Gt(this,e).catch(e=>{"ControllerAttachAborted"!==e?.name?console.error(`Failed to attach controller "${t}":`,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}if(this.hasAttribute("controller")&&!this[v]){const e=this.getAttribute("controller");e&&(this.controller=e)}if(function(e){const t=e[re],n=[],o=[];let r=e.constructor;for(;r&&r!==HTMLElement&&r!==Function.prototype;)o.unshift(r),r=Object.getPrototypeOf(r);for(const e of o){if(!Object.prototype.hasOwnProperty.call(e,"styles"))continue;const t=e.styles,o=Array.isArray(t)?t:[t];for(const e of o)sn(e)?n.push(e):console.warn("Static styles must be a css`` result or an array of css`` results")}if((t||0!==n.length)&&!e[se]){e[se]=!0;try{const o=[...n],r=e[ie];if(r)for(const t of r){const n=t.call(e);sn(n)&&o.push(n)}if(t){const n=t.call(e);if(!sn(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=pn(e),i=Array.from(s.childNodes).filter(e=>e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style"));if(i.length===o.length&&i.every((e,t)=>e.textContent===o[t].cssText))return;for(const e of i)e.remove();if(s instanceof ShadowRoot&&o.every(e=>!!e.styleSheet)&&"adoptedStyleSheets"in s)try{return void(s.adoptedStyleSheets=o.map(e=>e.styleSheet))}catch{}for(const e of o){const t=document.createElement("style");t.setAttribute("data-snice-style",""),t.textContent=e.cssText,s.appendChild(t)}}catch(e){console.error("Error applying styles:",e)}}}(this),this[Z])try{pn(this)}catch{}Lt(this,this),Et(this,this),qt(this,"task"),this[w]=!0,function(e,t){if(tt.has(t))return;tt.add(t);const n=t[D];if(!n||0===n.size)return;const o=t[$],r=new Set(["*"]);if(o)for(const[e,t]of o)r.add(e),"string"==typeof t?.attribute&&r.add(t.attribute);for(const t of n.keys()){if(r.has(t))continue;const n=e.tagName?e.tagName.toLowerCase():"element",s=o?[...o.keys()].join(", "):"(none)";console.warn(`@watch('${t}') on <${n}> matches no @property — it will never fire. Known properties: ${s}.`)}}(this,e),function(e,t){const n=t[D],o=t[$];if(n&&o)for(const[t,r]of o){const o=[t],s=r&&"string"==typeof r.attribute?r.attribute:null;s&&s!==t&&o.push(s),o.push("*");for(const r of o)if(n.has(r))for(const o of n.get(r))if(o.immediate)try{o.method.call(e,void 0,e[t],t)}catch(e){console.error(`Error in @watch('${r}') method ${o.methodName}:`,e)}}}(this,e),t&&t.call(this);const o=e[W];if(await new Promise(e=>queueMicrotask(e)),!this.isConnected)return void(this[u]&&(this[u](),this[u]=null,this[h]=null));this[Z]&&Ao(this,!0);try{rt(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName}:`,e)}if(await new Promise(e=>queueMicrotask(e)),!this.isConnected)return void(this[u]&&(this[u](),this[u]=null,this[h]=null));let r,s=!1;if(o){this[d]=!0;try{for(const e of o)try{await e.method.call(this)}catch(t){console.error(`Error in @ready handler ${e.methodName}:`,t),s||(s=!0,r=t)}}finally{delete this[d]}}s&&this[h]?(this[h](r),this[u]=null,this[h]=null):this[u]&&(this[u](),this[u]=null,this[h]=null),fo(this)},e.prototype.disconnectedCallback=async function(){It(this);try{!function(e){const t=e[te];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[z];if(t)for(const e of t)try{await e.method.call(this)}catch(t){console.error(`Error in @dispose handler ${e.methodName}:`,t)}n&&n.call(this),this[v]&&Qt(this).catch(e=>{console.error("Failed to detach controller:",e)}),Pt(this),Nt(this),Bt(this),lt(this),Ro(this),Mo(this),function(e){const t=e[ne];if(!t)return!1;let n=!1;return t.debounce&&(clearTimeout(t.debounce),t.debounce=null,n=!0),t.throttleTimer&&(clearTimeout(t.throttleTimer),t.throttleTimer=null,n=!0),n}(this)&&(this[p]=!0),or(this,J),or(this,X)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t){if(s=r,s?.includes(Tn))return;if(this[x])return;return this[O]?void Kt(this):void(this.controller=r)}var s;"autofocus"===t&&(null===r?ao.delete(this):this[w]&&fo(this));const i=e[$];if(i)for(const[n,o]of i){if(Fe(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[Q]?.has(t.toLowerCase()))break;const s=this[L]?.[n],i=this[P]?.[n];let a=null===r?o.type!==Boolean&&i:qe(r,o,s,i);const c=this[j]?.[n];if(c&&(a=c(a)),!(o?.hasChanged?o.hasChanged(a,s):Be(a,s)))break;Ke(this,V).add(n),Ge(this,L)[n]=a,this[w]&&Qe(this,e,n,s,a),this[Z]&&this[w]&&Ao(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[H];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @moved handler ${e.methodName}:`,t)}},e.prototype.adoptedCallback=async function(){const t=e[K];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function Bo(e,t,n,o){if(function(e){let t=Object.getPrototypeOf(e);const n=[];for(;t&&t!==HTMLElement&&t!==Function.prototype;)n.push(t),t=Object.getPrototypeOf(t);n.reverse();for(const t of n){if(t[$]){e[$]||(e[$]=new Map);for(const[n,o]of t[$])e[$].has(n)||e[$].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[$]){t[$]||(t[$]=new Map);for(const[e,o]of n.metadata[$])t[$].set(e,o)}else if(zo.length>0){t[$]||(t[$]=new Map);const e=zo.pop();for(const[n,o]of e)t[$].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[b]||{}},s=o||{};if("light"===s.renderRoot&&"string"==typeof s.shadow||"shadow"===s.renderRoot&&!1===s.shadow)throw new TypeError("snice: @element renderRoot and shadow options select conflicting render roots.");const i={...r,...s};Object.prototype.hasOwnProperty.call(s,"shadow")?i.renderRoot=!1===s.shadow?"light":"shadow":Object.prototype.hasOwnProperty.call(s,"renderRoot")&&("light"===s.renderRoot?i.shadow=!1:!1===i.shadow&&(i.shadow="open")),t[b]=i,!0===t.prototype[ae]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,Z)&&"function"==typeof t.prototype.render&&(t.prototype[Z]=t.prototype.render,t.prototype[ee]=t.renderOptions||{}),qo(t);const a=customElements.get(e);return a?(a===t&&En(t,e),globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),En(t,e),t)}function Fo(e,t){if(void 0!==t?.renderRoot&&"shadow"!==t.renderRoot&&"light"!==t.renderRoot)throw new TypeError('snice: @element renderRoot must be "shadow" or "light".');if(void 0!==t?.shadow&&!1!==t.shadow&&"open"!==t.shadow&&"closed"!==t.shadow)throw new TypeError('snice: @element shadow must be "open", "closed", or false.');return function(n,o){return Bo(e,n,o,t)}}function Wo(e){return function(t,n){return Bo(e,t,n)}}const zo=[],Uo=new WeakMap;function Ho(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[$]||(n.metadata[$]=new Map),n.metadata[$].set(o,e||{})):(0===zo.length&&zo.push(new Map),zo[zo.length-1].set(o,e||{})),function(t){const n=this[M],r=!0===n?.delete(o);0===n?.size&&delete this[M];const s=Object.prototype.hasOwnProperty.call(this,o),i=s&&(r||!function(e,t,n){const o=e?.ownerDocument;if(!o?.createElement)return!1;let r=Uo.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);Uo.set(o,r)}return r.has(t)&&Object.is(r.get(t),n)}(this,o,this[o])),a=i?this[o]:t;s&&delete this[o];const c=this.constructor;c[$]||(c[$]=new Map);const l={...e};l.type||void 0===t||(l.type=Ve(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[$].set(o,l),Ge(this,P)[o]=t;const u=()=>{if(!this[I])return;const e=this[L]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=Fe(l,o),r=et(e,l,t),s=n.toLowerCase();Ke(this,Q).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[Q].delete(s)}}this[w]&&(Qe(this,this.constructor,o,e,e),this[Z]&&Ao(this))},h=e=>{if(!l.deep)return e;let t;return t=function(e,t){if(!e||"object"!=typeof e)return e;const n=new WeakMap,o=new WeakMap,r=e=>e&&"object"==typeof e&&o.get(e)||e,s=e=>{if(!e||"object"!=typeof e)return e;if(n.has(e))return n.get(e);if(e instanceof Map){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=Vo(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("set"===n)c=(n,o)=>{n=r(n),o=r(o);const s=e.has(n),a=e.get(n);return e.set(n,o),s&&Object.is(a,o)||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("get"===n)c=t=>s(e.get(r(t)));else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach((e,o)=>t.call(n,s(e),s(o),i));else if("values"===n)c=function*(){for(const t of e.values())yield s(t)};else if("keys"===n)c=function*(){for(const t of e.keys())yield s(t)};else if("entries"===n||n===Symbol.iterator)c=function*(){for(const[t,n]of e.entries())yield[s(t),s(n)]};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(e instanceof Set){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=Vo(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("add"===n)c=n=>{n=r(n);const o=e.has(n);return e.add(n),o||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach(e=>{const o=s(e);t.call(n,o,o,i)});else if("values"===n||"keys"===n||n===Symbol.iterator)c=function*(){for(const t of e.values())yield s(t)};else if("entries"===n)c=function*(){for(const t of e.values()){const e=s(t);yield[e,e]}};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(!Array.isArray(e)&&!function(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;const i=new Proxy(e,{get(e,t,n){const o=Vo(e,t);return o.locked?o.value:s(Reflect.get(e,t,n))},set(e,n,o,s){const i=Reflect.get(e,n,s);o=r(o);const a=Reflect.set(e,n,o);return a&&!Object.is(i,o)&&t(),a},deleteProperty(e,n){const o=Object.prototype.hasOwnProperty.call(e,n),r=Reflect.deleteProperty(e,n);return r&&o&&t(),r},defineProperty(e,n,o){const s=Reflect.getOwnPropertyDescriptor(e,n),i="value"in o?{...o,value:r(o.value)}:o,a=Reflect.defineProperty(e,n,i),c=a?Reflect.getOwnPropertyDescriptor(e,n):s;return a&&!function(e,t){if(!e||!t)return e===t;const n="value"in e||"writable"in e;return n===("value"in t||"writable"in t)&&e.configurable===t.configurable&&e.enumerable===t.enumerable&&(!n||e.writable===t.writable&&Object.is(e.value,t.value))&&(n||e.get===t.get&&e.set===t.set)}(s,c)&&t(),a}});return n.set(e,i),o.set(i,e),i};return s(e)}(e,()=>{this[L]?.[o]===t&&u()}),t};Ge(this,j)[o]=h;const d=this.constructor.prototype;let f=d[ke];f&&Object.prototype.hasOwnProperty.call(d,ke)||(f=new Map(f),d[ke]=f);const m=f.get(o);m&&m===e||(f.set(o,e),Object.defineProperty(this.constructor.prototype,o,{get(){return this[R]?.has(o)?this[R].get(o):this[L]&&o in this[L]?this[L][o]:t},set(e){const t=this[o];if(!(l.hasChanged?l.hasChanged(e,t):Be(e,t)))return;const n=(this[j]?.[o]||(e=>e))(e);if(!this[I])return this[R]||(this[R]=new Map),void this[R].set(o,n);if(Ge(this,L)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=Fe(l,o),t=et(n,l,this[P]?.[o]);Ke(this,V).add(o);const r=e.toLowerCase();Ke(this,Q).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[Q].delete(r)}}this[w]&&(Qe(this,this.constructor,o,t,n),this[Z]&&Ao(this))},configurable:!0,enumerable:!0}));const p=h(t);return Ge(this,L)[o]=p,Ge(this,P)[o]=p,i?a:p}}}function Ko(e={}){return Ho({...e,attribute:!1,reflect:!1})}function Go(e){return!0===e[o]&&e.element?e.element:e}function Qo(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=Go(this);let n=null;const o=t instanceof HTMLElement?mn(t):null;return s&&o?n=o.querySelector(e):s&&t.shadowRoot&&(n=t.shadowRoot.querySelector(e)),!n&&r&&(n=t.querySelector(e)),n||null},set(){},configurable:!0,enumerable:!0}),t}}}function Jo(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=Go(this),n=new Set,o=t instanceof HTMLElement?mn(t):null;if(s&&o)for(const t of o.querySelectorAll(e))n.add(t);else if(s&&t.shadowRoot)for(const o of t.shadowRoot.querySelectorAll(e))n.add(o);if(r)for(const o of t.querySelectorAll(e))n.add(o);return[...n]},set(){},configurable:!0,enumerable:!0}),t}}}function Xo(...e){const t=e.filter(e=>"string"==typeof e),n=e.find(e=>"object"==typeof e&&null!==e),o=!1!==n?.immediate;return function(e,n){const r=n.name;n.addInitializer(function(){const n=this.constructor;Object.prototype.hasOwnProperty.call(n,ve)||(n[ve]=new Map);let s=n[ve].get(e);if(s||(s=new Set,n[ve].set(e,s)),!Object.prototype.hasOwnProperty.call(n,D)){const e=n[D],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[D]=t}for(const i of t)s.has(i)||(s.add(i),n[D].has(i)||n[D].set(i,[]),n[D].get(i).push({methodName:r,method:e,immediate:o}))})}}function Yo(){return function(e,t){const n=t.name;return function(e){return Object.hasOwn(this.constructor.prototype,n)||Object.defineProperty(this.constructor.prototype,n,{get(){if(void 0!==this[q])return this[q];const e=ft(this);return void 0!==e?e:void 0},set(){},configurable:!0,enumerable:!0}),e}}}function Zo(e,t,n,o,r){const s=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,t)||(o[t]=new Set),!o[t].has(n)){if(o[t].add(n),!Object.prototype.hasOwnProperty.call(o,e)){const t=o[e];o[e]=t?[...t]:[]}o[e].push({methodName:s,method:n,...r})}})}function er(){return function(e,t){Zo(W,Ae,e,t)}}function tr(){return function(e,t){Zo(z,Te,e,t)}}function nr(){return function(e,t){Zo(U,Se,e,t)}}function or(e,t){const n=e[t];if(n)for(const e of n.values())e.debounceTimer&&clearTimeout(e.debounceTimer),e.throttleTimer&&clearTimeout(e.throttleTimer),e.debounceTimer=null,e.throttleTimer=null,e.lastThrottleCall=0}function rr(e,t,n){return function(o={}){return function(r,s){Zo(e,n,r,s,{options:o});const i=s.name;return function(...e){this[t]||(this[t]=new Map),this[t].has(i)||this[t].set(i,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const n=this[t].get(i),s=(...e)=>r.apply(this,e),a=(...e)=>{try{const t=r.apply(this,e);t&&"function"==typeof t.then&&t.catch(e=>console.error(`Error in deferred lifecycle handler ${i}:`,e))}catch(e){console.error(`Error in deferred lifecycle handler ${i}:`,e)}};if(o.debounce>0)return clearTimeout(n.debounceTimer),void(n.debounceTimer=setTimeout(()=>a(...e),o.debounce));if(o.throttle>0){const t=Date.now();return 0===n.lastThrottleCall||t-n.lastThrottleCall>=o.throttle?(n.lastThrottleCall=t,s(...e)):void(n.throttleTimer||(n.throttleTimer=setTimeout(()=>{n.throttleTimer=null,n.lastThrottleCall=Date.now(),a(...e)},o.throttle-(t-n.lastThrottleCall))))}return s(...e)}}}}const sr=rr(H,J,_e),ir=rr(K,X,Oe);class ar extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[b];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return Ao(this),this.rendered}renderNow(){return function(e){yo(e),No(e,{...e[ee]||{},once:!1})}(this),this.rendered}}Object.defineProperty(ar.prototype,ae,{value:!0});class cr{constructor(e){this.parsed=this.parsePattern(e)}get spec(){return this.parsed.template}parsePattern(e){let t=e,n="",o=!1;const r=e.indexOf("?");return-1!==r&&(t=e.slice(0,r),n=e.slice(r+1),t.endsWith("(")&&n.endsWith(")")&&(o=!0,t=t.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(t),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:e}}parseSegments(e){const t=[];let n=0;for(;n<e.length;)switch(e[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(e,n);t.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(e,n+1);t.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(e,n+1);t.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:u}=this.parseLiteral(e,n);l&&t.push({type:"literal",value:l}),n=u}return t}parseOptionalGroup(e,t){let n=1,o=t+1;for(;o<e.length&&n>0;)"("===e[o]&&n++,")"===e[o]&&n--,o++;const r=e.slice(t+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(e,t){let n=t;for(;n<e.length&&/[\w-]/.test(e[n]);)n++;return{name:e.slice(t,n),endIndex:n}}parseLiteral(e,t){let n=t;for(;n<e.length&&!"(:*(".includes(e[n]);)n++;return{value:e.slice(t,n),endIndex:n}}parseQuerySegments(e){let t=e;t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1));const n=[];let o=0;for(;o<t.length;)if(":"===t[o]){const{name:e,endIndex:r}=this.parseIdentifier(t,o+1);n.push({type:"param",name:e}),o=r}else{const{value:e,endIndex:r}=this.parseQueryLiteral(t,o);e&&n.push({type:"literal",value:e}),o=r}return n}parseQueryLiteral(e,t){let n=t;for(;n<e.length&&":"!==e[n];)n++;return{value:e.slice(t,n),endIndex:n}}getAllParamNames(){const e=new Set,t=n=>{for(const o of n)switch(o.type){case"param":case"splat":e.add(o.name);break;case"optional":t(o.segments)}};return t(this.parsed.pathSegments),t(this.parsed.querySegments),Array.from(e)}canMatchRemainingSegments(e,t,n){let o=t;for(const t of n)if("literal"===t.type){const n=e.indexOf(t.value,o);if(-1===n)return!1;o=n+t.value.length}return!0}match(e){const[t,n]=e.split("?"),o=this.matchPath(t,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 e of s)i[e]=void 0;return Object.assign(i,o,r),i}matchPath(e,t){const n={};let o=0;for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1),a=this.matchSegment(e,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<e.length)&&n}matchSegment(e,t,n,o=[]){switch(n.type){case"literal":return e.slice(t,t+n.value.length)===n.value&&{params:{},nextIndex:t+n.value.length};case"param":{let r=t;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=e.indexOf(s.value,t);if(-1===n)return!1;r=n}else for(;r<e.length&&!a.includes(e[r]);)r++;if(r===t)return!1;try{i=decodeURIComponent(e.slice(t,r))}catch(n){i=e.slice(t,r)}return!(r<e.length&&"?"===e[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=e.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=e.indexOf(".",t);-1!==n&&(r=n)}else{const n=e.lastIndexOf(s.value);-1!==n&&n>=t&&(r=n)}break;case"param":let n=-1;for(let o=e.length-1;o>=t;o--)if("/"===e[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=e.length-1;n>t;n--)if("/"===e[n]){o=n+1;break}if(-1!==o)r=o;else{const n=e.slice(t).split("/").filter(e=>e);r=n.length>1?t+n.slice(0,-1).join("/").length+1:t}break;case"optional":const i=e=>{for(const t of e){if("literal"===t.type)return t.value;if("optional"===t.type){const e=i(t.segments);if(e)return e}}return null},a=i(s.segments);if(a){const n=e.lastIndexOf(a);-1!==n&&n>=t&&(r=n)}}const i=e.indexOf("?",t);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(e.slice(t,r))}catch(n){a=e.slice(t,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=t,s={},i=!0;for(let t=0;t<n.segments.length;t++){const o=n.segments[t],a=n.segments.slice(t+1),c=this.matchSegment(e,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}return i&&this.canMatchRemainingSegments(e,r,o)?{params:s,nextIndex:r}:{params:{},nextIndex:t}}default:return!1}}findNextLiteral(e){for(const t of e){if("literal"===t.type)return t;if("optional"===t.type){const e=this.findNextLiteral(t.segments);if(e)return e}}return null}matchQuery(e,t){if(0===t.length)return{};const n={};let o=0;for(const r of t)switch(r.type){case"literal":if(e.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let t,s=o;for(;s<e.length&&"&"!==e[s];)s++;if(s===o)return!1;try{t=decodeURIComponent(e.slice(o,s))}catch(n){t=e.slice(o,s)}n[r.name]=t,o=s;break}}return n}reverse(e={}){const t=this.reverseSegments(this.parsed.pathSegments,e);if(!1===t)return!1;let n=t;if(this.parsed.querySegments.length>0){const t=this.reverseSegments(this.parsed.querySegments,e);if(!this.parsed.queryOptional&&!1===t)return!1;t&&""!==t&&(n+="?"+t)}return n}reverseSegments(e,t,n=!1){let o="";for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in t))return!1;o+=String(t[s.name]);break;case"optional":if(this.hasAllParams(s.segments,t,n)||this.hasLaterOptionalGroupNeedingParams(i,t,s.segments)){const e=this.reverseSegments(s.segments,t,!0);if(!1===e)return!1;o+=e}}}return o}hasLaterOptionalGroupNeedingParams(e,t,n){for(const o of e)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,t))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(e){for(const t of e)if("param"===t.type||"splat"===t.type)return!1;return!0}hasAllParams(e,t,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of e)switch(n.type){case"param":case"splat":i=!1,n.name in t&&void 0!==t[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of e)"optional"===n.type&&this.hasAllParams(n.segments,t,a)&&(r=!0);return!(!o||s)||!(!r||s)||!(!i||!n)}hasOnlyOptionalMissingParams(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(!(n.name in t))return!1}return!0}hasAnyParamInSegments(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(n.name in t)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,t))return!0}return!1}}function lr(e){const t=e.split("/").filter(Boolean);let n=t.length;for(const e of t)e.startsWith("*")?n+=-2:e.startsWith(":")?n+=3:n+=10;return n}function ur(e){const t={};return e.split(";").forEach(e=>{const n=e.indexOf(":");if(-1===n)return;const o=e.slice(0,n).trim(),r=e.slice(n+1).trim();o&&r&&(t[o]=r)}),t}function hr(e,t,n,o){if(e.style.position="absolute",e.style.width="100%",t)return e.style.height="100%",void(e.style.transition=`opacity ${n}ms ease-in-out`);e.style.top="0",e.style.left="0",e.style.transition=`${o} ${n}ms ease-in-out`}function dr(e,t){Object.defineProperty(e.prototype,r,{value:!0,configurable:!0})}function fr(e){if(!pt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=yt(e);if(0===t.bindings){t.active=!0;try{Lt(e,t.target),Et(e,t.target)}catch(n){throw Nt(e),Pt(e),t.active=!1,n}}t.bindings+=1;let n=!1;return()=>{n||(n=!0,t.bindings=Math.max(0,t.bindings-1),0===t.bindings&&(Nt(e),Pt(e),It(e),t.active=!1,t.target=new EventTarget))}}function mr(e,t,n,o){const r=function(e,t,n,o){if(!e||"function"!=typeof e.addEventListener||"function"!=typeof e.removeEventListener)throw new TypeError("provideContext() requires an EventTarget root.");if(!t||"object"!=typeof t)throw new TypeError("provideContext() requires an application context object.");if(ht.has(e))throw new Error("This root already provides an application context. Release it before providing another.");const r=e=>{const r=e;if(r.detail){if("application"===r.detail.kind){if(void 0!==r.detail.context)return;r.detail.context=t}else if("fetch"===r.detail.kind){if(!n||void 0!==r.detail.fetch)return;r.detail.fetch=n}else{if("navigation"!==r.detail.kind)return;if(!o||void 0!==r.detail.navigation)return;r.detail.navigation=o}r.preventDefault(),r.stopPropagation()}};e.addEventListener(ut,r),ht.set(e,{listener:r});let s=!1;return()=>{if(s)return;s=!0;const t=ht.get(e);t?.listener===r&&(e.removeEventListener(ut,r),ht.delete(e))}}(e,t,n.fetch,o);let s;try{s=function(e){const t=e.daemons;if(void 0===t)return()=>{};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("AppContext.daemons must be a readonly record of named @daemon instances.");const n=[],o=new Set;try{for(const[e,r]of Object.entries(t)){if(!e.trim())throw new TypeError("AppContext.daemons keys must be non-empty strings.");if(!r||"object"!=typeof r)throw new TypeError(`AppContext.daemons["${e}"] must be an instance of an @daemon class.`);o.has(r)||(o.add(r),n.push(fr(r)))}}catch(e){for(const e of n.reverse())e();throw e}return()=>{for(const e of n.reverse())e()}}(t)}catch(e){throw r(),e}let i=!1;return()=>{i||(i=!0,r(),s?.())}}function pr(e,t,n={}){return mr(e,t,n)}const yr=/=:[\w-]+\)?$/;function gr(e,t){if(e.includes(t))return!0;const n=e.indexOf("?");return-1!==n&&e.slice(n+1).split("&").some(e=>{try{return decodeURIComponent(e).includes(t)}catch{return!1}})}function br(e,t){const n=e.match(t);if(!1!==n)return n;const o=function(e,t){let n="__snice_empty_query_value__";for(;e.spec.includes(n)||gr(t,n);)n+="_";return n}(e,t),r=function(e,t,n){const o=t.indexOf("?"),r=e.spec.indexOf("?");if(-1===o||-1===r)return null;const s=t.slice(o+1).split("&"),i=e.spec.slice(r+1).split("&");let a=!1;const c=s.map((e,t)=>e.endsWith("=")&&yr.test(i[t]??"")?(a=!0,`${e}${n}`):e);return a?`${t.slice(0,o+1)}${c.join("&")}`:null}(e,t,o);if(null===r)return!1;const s=e.match(r);if(!1===s)return!1;for(const e of Object.keys(s))s[e]===o&&(s[e]="");return s}const vr=new WeakMap;var wr;function Er(e){const t=e.window??window,n=e.document??document,o=[];let r,s,i,a=0,c=!1,l=[],u=null,h=null;const d=e.context||{};let f=null,m=null;const p=new De(d,[],"",{},e.fetcher);function y(e){if(f===e&&m&&vr.get(e)===m)return;m?.(),vr.get(e)?.();const t=mr(e,(n=p).application,{fetch:n.fetch},n);var n;let o=!1;const r=()=>{o||(o=!0,t(),vr.get(e)===r&&vr.delete(e))};m=r,f=e,vr.set(e,r)}function g(e){if(!u||!h)return null;const t=e.querySelectorAll(u);for(const e of t)if(e[F]===h)return e;return null}function b(e,t,n,l,u,h,d=0){if(!Number.isFinite(d))throw new TypeError(`Route order for "${e}" must be a finite number.`);switch(o.push({route:new cr(e),tag:t,transition:n,guards:l,layout:u,placard:h,order:d,registrationOrder:a++}),c=!1,e){case"/404":r=t;break;case"/403":s=t;break;case"/":i=t}}function v(){const e=new Set;l=o.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(d):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function w(e,t,n){p[ge](d,l,t,n)}function E(){switch(e.type){case"hash":return t.location.hash.slice(1);case"pushstate":return`${t.location.pathname}${t.location.search}`}}function N(e){let t;if(s)t=n.createElement(s),t[q]=d;else{const e=n.createElement("div");e.className="default-403",e.innerHTML="<h1>403</h1><p>Unauthorized</p>",t=e}e.innerHTML="",e.appendChild(t),u=null,h=null}async function A(e,t,o,r){if(!e)return!0;const s=Array.isArray(e)?e:[e];let i=null,a=null;a=setTimeout(()=>{r&&r()||(i=function(){const e=n.createElement("div");return e.setAttribute("data-snice-loading",""),e.innerHTML='\n <style>@keyframes snice-spin{to{transform:rotate(360deg)}}</style>\n <div style="display:flex;align-items:center;justify-content:center;height:100%;min-height:200px">\n <div style="width:32px;height:32px;border:3px solid rgba(128,128,128,0.3);border-top-color:rgba(128,128,128,0.8);border-radius:50%;animation:snice-spin 0.6s linear infinite"></div>\n </div>',e}(),o.appendChild(i))},50);try{for(const e of s)if(!await e(d,t))return r&&r()||N(o),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function T(t,o,r,s,i,a,c){const f=!1===(m=s)?null:m||(e.layout?e.layout:null);var m;const{element:p,needsNewLayout:y}=function(e){if(e===u)return{element:null,needsNewLayout:!1};if(u=e,e){const t=Date.now();h=t;const o=n.createElement(e);return o[q]=d,o[F]=t,{element:o,needsNewLayout:!0}}return h=null,{element:null,needsNewLayout:!0}}(f),b=r||e.transition;if(null!==p||null!==g(t)){if(await async function(e,t,n,o,r,s,i,a){const c=o||g(e);if(!c)return;!function(e,t,n){"function"==typeof e.update&&e.update(d,l,t,n)}(c,s,i);const u=c.querySelector('[slot="page"]');if(n&&u){if(t.setAttribute("slot","page"),await O(c,u,t,n),a&&a())return;r&&(e.innerHTML="",e.appendChild(c))}else a&&a()||(c.querySelectorAll('[slot="page"]').forEach(e=>e.remove()),t.setAttribute("slot","page"),c.appendChild(t),r&&(e.innerHTML="",e.appendChild(c)))}(t,o,b,p,y,i,a,c),c&&c())return;w(0,i,a)}else await async function(e,t,n,o){const r=e.children[0];n&&r?await O(e,r,t,n):o&&o()||(e.innerHTML="",e.appendChild(t))}(t,o,b,c),c&&c()||w(0,i,a)}let S=0;async function _(s){const a=n.querySelector(e.target);if(!a)throw new Error(`Target element not found: ${e.target}`);y(a);const c=++S,l=()=>c!==S;if(v(),t.scrollTo(0,0),(""===s?.trim()||"/"===s)&&i){const e=o.find(e=>e.route.match("/"));if(!await A(e?.guards,{},a,l))return;if(l())return;const{element:r,transition:c,layout:u}=function(){const e=n.createElement(i);e[q]=d;const r=t.customElements.get(i),s=r?.[B],a=o.find(e=>e.route.match("/"));return{element:e,transition:s,layout:a?.layout}}();return void await T(a,r,c,u,s,{},l)}if(!s)return;const u=await async function(e,t,r){for(const s of o){const o=br(s.route,e);if(!1===o)continue;if(!await A(s.guards,o,t,r))return{result:wr.GUARDS_FAILED};const i=n.createElement(s.tag);i[q]=d,i[ce]=p;const a=o;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:wr.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:wr.NOT_FOUND}}(s,a,l);if(l())return;if(u.result===wr.GUARDS_FAILED)return;if(u.result===wr.SUCCESS){const{element:e,transition:t,layout:n,routeParams:o={}}=u;return void await T(a,e,t,n,s,o,l)}const{element:h,transition:f,layout:m}=function(){if(r){const e=n.createElement(r);e[q]=d;const o=t.customElements.get(r),s=o?.[B];return{element:e,transition:s,layout:void 0}}const e=n.createElement("div");return e.className="default-404",e.innerHTML="<h1>404</h1><p>Page not found</p>",{element:e,transition:void 0,layout:void 0}}();await T(a,h,f,m,s,{},l)}async function O(e,t,n,o,r=S){return async function(e,t,n,o={},r=()=>!1){const s=o.outDuration??300,i=o.inDuration??300,a=o.mode||"sequential",c=o.out?ur(o.out):{opacity:"0"},l={opacity:"0"},u=o.in?ur(o.in):{opacity:"1"},h=e.style,d=e.tagName.includes("-")&&e.shadowRoot,f=Symbol.for("snice:transition-original-position"),m=Symbol.for("snice:transition-count"),p=e;d||(f in p||(p[f]=h.position,p[m]=0),p[m]++,h.position="relative");const y=()=>{d||(p[m]--,p[m]<=0&&(h.position=p[f],delete p[f],delete p[m]))},g=t.hasAttribute("slot")||n.hasAttribute("slot");switch(hr(t,g,s,"all"),hr(n,g,i,"all"),Object.assign(n.style,l),e.appendChild(n),a){case Le.SIMULTANEOUS:Object.assign(t.style,c),Object.assign(n.style,u),await new Promise(e=>setTimeout(e,Math.max(s,i)));break;case Le.SEQUENTIAL:if(Object.assign(t.style,c),await new Promise(e=>setTimeout(e,s)),r())return n.parentNode===e&&n.remove(),void y();Object.assign(n.style,u),await new Promise(e=>setTimeout(e,i))}if(r())return n.parentNode===e&&n.remove(),void y();t.remove(),function(e,t){e.style.position="",e.style.width="",e.style.transition="",t?e.style.height="":(e.style.top="",e.style.left="")}(n,g),Object.keys({...l,...u}).forEach(e=>{n.style[e]=""}),y()}(e,t,n,o,()=>r!==S)}return{page:function(e){return function(n,o){if(o?.metadata&&o.metadata[$]){n[$]||(n[$]=new Map);for(const[e,t]of o.metadata[$])n[$].set(e,t)}qo(n),n[B]=e.transition;const r=n.prototype.connectedCallback;n.prototype.connectedCallback=function(){void 0!==this[q]&&(this[ce]=p),r?.call(this)};const s=n.prototype.disconnectedCallback;n.prototype.disconnectedCallback=function(){s?.call(this),delete this[q],delete this[ce]};const i=t.customElements.get(e.tag);return i?i===n&&En(n,e.tag):(t.customElements.define(e.tag,n),En(n,e.tag)),e.routes.forEach(t=>{b("string"==typeof t?t:t.path,e.tag,e.transition,e.guards,e.layout,e.placard,"string"==typeof t?void 0:t.order)}),n}},initialize:function(){const r=n.querySelector(e.target);if(!r)throw new Error(`Target element not found: ${e.target}`);y(r),!c&&(o.sort((e,t)=>lr(t.route.spec)-lr(e.route.spec)||e.order-t.order||e.registrationOrder-t.registrationOrder),c=!0),v(),function(){const o=()=>{const t=n.querySelector(e.target);if(t&&(f!==t||!m||vr.get(t)===m))return f!==t&&ht.has(t)?(m?.(),m=null,void(f=null)):void _(E())};switch(e.type){case"hash":t.addEventListener("hashchange",o);break;case"pushstate":t.addEventListener("popstate",o)}}(),_(E())},navigate:async function(n){const o=function(e){const t=e.trim().replace(/^#/,"");return t?t.startsWith("/")?t:`/${t}`:"/"}(n);!function(n){switch(e.type){case"hash":{const e=`#${n}`;t.location.hash!==e&&t.history.pushState(null,"",e);break}case"pushstate":`${t.location.pathname}${t.location.search}`!==n&&t.history.pushState(null,"",n)}}(o),await _(o)},register:b}}function Nr(e,t,n){const o=[];for(const[r,s]of Object.entries(t)){const t=`@request/${r}`,i=e=>{const t=e,{discovery:o,data:i,payload:a}=t.detail;n?.passive||(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()),o.resolve(),Promise.resolve().then(()=>s(a)).then(e=>i.resolve(e)).catch(e=>{i.reject(e),console.error(`createRequestHandler: error in "${r}" handler:`,e)})};e.addEventListener(t,i),o.push(()=>e.removeEventListener(t,i))}return()=>{for(const e of o)e();o.length=0}}function Ar(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t}function Tr(e){const t=[];for(const n of Object.keys(e)){const o=e[n];if(null==o||!1===o)continue;const r=n.startsWith("--")?n:n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());t.push(`${r}: ${o}`)}return t.join("; ")}!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(wr||(wr={}));let Sr=!1;function _r(e){Sr=e}async function Or(e,t=500){if(customElements.get(e))return;let n=null;Sr||(n=setTimeout(()=>{console.warn(`Custom element <${e}> is taking longer than ${t}ms to register. This may indicate a missing import or circular dependency. Set DISABLE_ELEMENT_READY_WARNINGS=true to disable this warning.`)},t));try{await customElements.whenDefined(e)}finally{n&&clearTimeout(n)}}async function xr(e,t=500){const n=e.tagName.toLowerCase();await Or(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}async function Cr(e,t=500){const n=[];e instanceof Element&&(e.tagName.includes("-")&&n.push(e),e.shadowRoot)&&e.shadowRoot.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),e instanceof DocumentFragment&&e.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),await Promise.all(n.map(e=>xr(e,t)))}async function*kr(e){for(;;)await new Promise(t=>{e[oe]||(e[oe]=[]),e[oe].push(t)}),yield}let $r=0,Lr=null;const Pr=Symbol.for("snice:body-scroll-lock");function jr(){0===$r&&(Lr=document.body.style.overflow,document.body.style.overflow="hidden"),$r++}function Rr(){0!==$r&&($r--,0===$r&&(document.body.style.overflow=Lr??"",Lr=null))}function Mr(){return $r}globalThis[Pr]={clear(){$r=0,Lr=null}};class Ir{constructor(){this.requestMiddlewares=[],this.responseMiddlewares=[]}use(e,t){"request"!==e?this.responseMiddlewares.push(t):this.requestMiddlewares.push(t)}create(e){const t=this.requestMiddlewares,n=this.responseMiddlewares;return async function(e,o){if("string"==typeof e&&"undefined"!=typeof location&&location.href)try{new URL(e)}catch{e=new URL(e,location.href).href}const r=new Request(e,o);let s=0;const i=async()=>{if(s<t.length)return t[s++].call(this,r,i);const e=await fetch(r);let o=0;const a=async()=>o<n.length?n[o++].call(this,e,a):e;return a()};return i()}.bind(e)}}var Dr;"undefined"!=typeof document&&Xt(),globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(Dr||(Dr={}));export{De as Context,Ir as ContextAwareFetcher,o as IS_CONTROLLER_INSTANCE,Er as Router,$e as SimpleArray,ar as SniceElement,Le as TransitionMode,ir as adopted,qo as applyElementFunctionality,Gt as attachController,Ar as classMap,Ro as clearDebounceTimers,Io as clearMemoizeCache,Mo as clearThrottleTimers,Vt as context,Yo as contextProperty,Wt as controller,Nr as createRequestHandler,on as css,dr as daemon,$o as debounce,Qt as detachController,Mt as dispatch,tr as dispose,Fo as element,ze as escapeAttr,We as escapeHtml,Mr as getBodyScrollLockCount,ft as getContext,mt as getContextFetch,Jt as getController,t as getSymbol,tn as html,Ue as isSafeUrl,Wo as layout,Mn as live,jr as lockBodyScroll,jo as memoize,sr as moved,jn as noChange,an as nothing,ot as observe,Ct as on,Po as once,He as parseDuration,Ho as property,pr as provideContext,Qo as query,Jo as queryAll,er as ready,nr as reconnect,So as render,dn as repeat,vt as request,Do as resetOnce,wt as respond,_r as setDisableElementReadyWarnings,po as setStrictRenderErrors,Ko as state,Tr as styleMap,_o as styles,nn as svg,Lo as throttle,kr as trackRenders,Rr as unlockBodyScroll,ln as unsafeHTML,Xt as useNativeElementControllers,Cr as waitForAllCustomElements,Or as waitForElementDefined,xr as waitForElementReady,Xo as watch};
2
2
  //# sourceMappingURL=snice-runtime.esm.min.js.map