snice 7.7.0 → 7.8.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 (216) hide show
  1. package/adapters/react/SniceProvider.js +1 -1
  2. package/adapters/react/SniceRouter.js +1 -1
  3. package/adapters/react/calendar.d.ts +1 -0
  4. package/adapters/react/calendar.d.ts.map +1 -1
  5. package/adapters/react/calendar.js +1 -1
  6. package/adapters/react/calendar.js.map +1 -1
  7. package/adapters/react/calendar.tsx +2 -1
  8. package/adapters/react/matchRoute.js +1 -1
  9. package/adapters/react/useRequestHandler.js +1 -1
  10. package/bin/analyzer-contracts.js +8 -2
  11. package/custom-elements.json +5 -1
  12. package/dist/cdn/accordion/snice-accordion.js +1 -1
  13. package/dist/cdn/action-bar/snice-action-bar.js +1 -1
  14. package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
  15. package/dist/cdn/alert/snice-alert.js +1 -1
  16. package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
  17. package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
  18. package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
  19. package/dist/cdn/availability/snice-availability.js +1 -1
  20. package/dist/cdn/avatar/snice-avatar.js +1 -1
  21. package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
  22. package/dist/cdn/badge/snice-badge.js +1 -1
  23. package/dist/cdn/banner/snice-banner.js +1 -1
  24. package/dist/cdn/binpack/snice-binpack.js +1 -1
  25. package/dist/cdn/book/snice-book.js +1 -1
  26. package/dist/cdn/booking/snice-booking.js +1 -1
  27. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
  28. package/dist/cdn/button/snice-button.js +1 -1
  29. package/dist/cdn/calendar/README.md +2 -2
  30. package/dist/cdn/calendar/snice-calendar.js +26 -2
  31. package/dist/cdn/calendar/snice-calendar.js.map +1 -1
  32. package/dist/cdn/calendar/snice-calendar.min.js +2 -2
  33. package/dist/cdn/calendar/snice-calendar.min.js.map +1 -1
  34. package/dist/cdn/camera/snice-camera.js +1 -1
  35. package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
  36. package/dist/cdn/candlestick/snice-candlestick.js +1 -1
  37. package/dist/cdn/card/snice-card.js +1 -1
  38. package/dist/cdn/carousel/snice-carousel.js +1 -1
  39. package/dist/cdn/cart/snice-cart.js +1 -1
  40. package/dist/cdn/chart/snice-chart.js +1 -1
  41. package/dist/cdn/chat/snice-chat.js +1 -1
  42. package/dist/cdn/checkbox/snice-checkbox.js +1 -1
  43. package/dist/cdn/chip/snice-chip.js +1 -1
  44. package/dist/cdn/code-block/snice-code-block.js +1 -1
  45. package/dist/cdn/color-display/snice-color-display.js +1 -1
  46. package/dist/cdn/color-picker/snice-color-picker.js +1 -1
  47. package/dist/cdn/command-palette/snice-command-palette.js +1 -1
  48. package/dist/cdn/comments/snice-comments.js +1 -1
  49. package/dist/cdn/countdown/snice-countdown.js +1 -1
  50. package/dist/cdn/cropper/snice-cropper.js +1 -1
  51. package/dist/cdn/data-card/snice-data-card.js +1 -1
  52. package/dist/cdn/date-picker/snice-date-picker.js +1 -1
  53. package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
  54. package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
  55. package/dist/cdn/diff/snice-diff.js +1 -1
  56. package/dist/cdn/divider/snice-divider.js +1 -1
  57. package/dist/cdn/doc/snice-doc.js +1 -1
  58. package/dist/cdn/draw/snice-draw.js +1 -1
  59. package/dist/cdn/drawer/snice-drawer.js +1 -1
  60. package/dist/cdn/empty-state/snice-empty-state.js +1 -1
  61. package/dist/cdn/estimate/snice-estimate.js +1 -1
  62. package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
  63. package/dist/cdn/file-upload/snice-file-upload.js +1 -1
  64. package/dist/cdn/flip-card/snice-flip-card.js +1 -1
  65. package/dist/cdn/flow/snice-flow.js +1 -1
  66. package/dist/cdn/form-layout/snice-form-layout.js +1 -1
  67. package/dist/cdn/funnel/snice-funnel.js +1 -1
  68. package/dist/cdn/gantt/snice-gantt.js +1 -1
  69. package/dist/cdn/gauge/snice-gauge.js +1 -1
  70. package/dist/cdn/grid/snice-grid.js +1 -1
  71. package/dist/cdn/heatmap/snice-heatmap.js +1 -1
  72. package/dist/cdn/image/snice-image.js +1 -1
  73. package/dist/cdn/input/snice-input.js +1 -1
  74. package/dist/cdn/invoice/snice-invoice.js +1 -1
  75. package/dist/cdn/kanban/snice-kanban.js +1 -1
  76. package/dist/cdn/key-value/snice-key-value.js +1 -1
  77. package/dist/cdn/kpi/snice-kpi.js +1 -1
  78. package/dist/cdn/layout/snice-layout.js +1 -1
  79. package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
  80. package/dist/cdn/link/snice-link.js +1 -1
  81. package/dist/cdn/link-preview/snice-link-preview.js +1 -1
  82. package/dist/cdn/list/snice-list.js +1 -1
  83. package/dist/cdn/location/snice-location.js +1 -1
  84. package/dist/cdn/login/snice-login.js +1 -1
  85. package/dist/cdn/map/snice-map.js +1 -1
  86. package/dist/cdn/markdown/snice-markdown.js +1 -1
  87. package/dist/cdn/masonry/snice-masonry.js +1 -1
  88. package/dist/cdn/menu/snice-menu.js +1 -1
  89. package/dist/cdn/message-strip/snice-message-strip.js +1 -1
  90. package/dist/cdn/modal/snice-modal.js +1 -1
  91. package/dist/cdn/music-player/snice-music-player.js +1 -1
  92. package/dist/cdn/nav/snice-nav.js +1 -1
  93. package/dist/cdn/network-graph/snice-network-graph.js +1 -1
  94. package/dist/cdn/notification-center/snice-notification-center.js +1 -1
  95. package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
  96. package/dist/cdn/org-chart/snice-org-chart.js +1 -1
  97. package/dist/cdn/pagination/snice-pagination.js +1 -1
  98. package/dist/cdn/paint/snice-paint.js +1 -1
  99. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
  100. package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
  101. package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
  102. package/dist/cdn/popover/snice-popover.js +1 -1
  103. package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
  104. package/dist/cdn/product-card/snice-product-card.js +1 -1
  105. package/dist/cdn/progress/snice-progress.js +1 -1
  106. package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
  107. package/dist/cdn/qr-code/snice-qr-code.js +1 -1
  108. package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
  109. package/dist/cdn/radio/snice-radio.js +1 -1
  110. package/dist/cdn/range-slider/snice-range-slider.js +1 -1
  111. package/dist/cdn/rating/snice-rating.js +1 -1
  112. package/dist/cdn/receipt/snice-receipt.js +1 -1
  113. package/dist/cdn/recipe/snice-recipe.js +1 -1
  114. package/dist/cdn/runtime/README.md +2 -2
  115. package/dist/cdn/runtime/snice-runtime.esm.js +130 -31
  116. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  117. package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
  118. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  119. package/dist/cdn/runtime/snice-runtime.js +130 -31
  120. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  121. package/dist/cdn/runtime/snice-runtime.min.js +1 -1
  122. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  123. package/dist/cdn/sankey/snice-sankey.js +1 -1
  124. package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
  125. package/dist/cdn/select/snice-select.js +1 -1
  126. package/dist/cdn/skeleton/snice-skeleton.js +1 -1
  127. package/dist/cdn/slider/snice-slider.js +1 -1
  128. package/dist/cdn/sortable/snice-sortable.js +1 -1
  129. package/dist/cdn/sparkline/snice-sparkline.js +1 -1
  130. package/dist/cdn/spinner/snice-spinner.js +1 -1
  131. package/dist/cdn/split-button/snice-split-button.js +1 -1
  132. package/dist/cdn/split-pane/snice-split-pane.js +1 -1
  133. package/dist/cdn/spotlight/snice-spotlight.js +1 -1
  134. package/dist/cdn/stat-group/snice-stat-group.js +1 -1
  135. package/dist/cdn/step-input/snice-step-input.js +1 -1
  136. package/dist/cdn/stepper/snice-stepper.js +1 -1
  137. package/dist/cdn/switch/snice-switch.js +1 -1
  138. package/dist/cdn/table/README.md +2 -2
  139. package/dist/cdn/table/snice-table.esm.js +157 -33
  140. package/dist/cdn/table/snice-table.esm.js.map +1 -1
  141. package/dist/cdn/table/snice-table.esm.min.js +4 -4
  142. package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
  143. package/dist/cdn/table/snice-table.js +157 -33
  144. package/dist/cdn/table/snice-table.js.map +1 -1
  145. package/dist/cdn/table/snice-table.min.js +33 -33
  146. package/dist/cdn/table/snice-table.min.js.map +1 -1
  147. package/dist/cdn/tabs/snice-tabs.js +1 -1
  148. package/dist/cdn/tag/snice-tag.js +1 -1
  149. package/dist/cdn/tag-input/README.md +2 -2
  150. package/dist/cdn/tag-input/snice-tag-input.js +10 -16
  151. package/dist/cdn/tag-input/snice-tag-input.js.map +1 -1
  152. package/dist/cdn/tag-input/snice-tag-input.min.js +2 -2
  153. package/dist/cdn/tag-input/snice-tag-input.min.js.map +1 -1
  154. package/dist/cdn/terminal/snice-terminal.js +1 -1
  155. package/dist/cdn/testimonial/snice-testimonial.js +1 -1
  156. package/dist/cdn/textarea/snice-textarea.js +1 -1
  157. package/dist/cdn/time-picker/snice-time-picker.js +1 -1
  158. package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
  159. package/dist/cdn/timeline/snice-timeline.js +1 -1
  160. package/dist/cdn/timer/snice-timer.js +1 -1
  161. package/dist/cdn/toast/snice-toast.js +1 -1
  162. package/dist/cdn/tooltip/snice-tooltip.js +1 -1
  163. package/dist/cdn/tree/snice-tree.js +1 -1
  164. package/dist/cdn/treemap/snice-treemap.js +1 -1
  165. package/dist/cdn/user-card/snice-user-card.js +1 -1
  166. package/dist/cdn/video-player/snice-video-player.js +1 -1
  167. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
  168. package/dist/cdn/waterfall/snice-waterfall.js +1 -1
  169. package/dist/cdn/weather/snice-weather.js +1 -1
  170. package/dist/cdn/work-order/snice-work-order.js +1 -1
  171. package/dist/components/calendar/snice-calendar.d.ts +2 -0
  172. package/dist/components/calendar/snice-calendar.js +25 -1
  173. package/dist/components/calendar/snice-calendar.js.map +1 -1
  174. package/dist/components/table/snice-row.d.ts +6 -0
  175. package/dist/components/table/snice-row.js +11 -3
  176. package/dist/components/table/snice-row.js.map +1 -1
  177. package/dist/components/table/snice-table.d.ts +31 -3
  178. package/dist/components/table/snice-table.js +89 -16
  179. package/dist/components/table/snice-table.js.map +1 -1
  180. package/dist/components/table/table-cell-presentation.d.ts +11 -0
  181. package/dist/components/table/table-cell-presentation.js +25 -8
  182. package/dist/components/table/table-cell-presentation.js.map +1 -1
  183. package/dist/components/table/table-export.d.ts +6 -0
  184. package/dist/components/table/table-export.js +11 -2
  185. package/dist/components/table/table-export.js.map +1 -1
  186. package/dist/components/table/table-master-detail.d.ts +11 -2
  187. package/dist/components/table/table-master-detail.js +20 -3
  188. package/dist/components/table/table-master-detail.js.map +1 -1
  189. package/dist/components/tag-input/snice-tag-input.d.ts +2 -2
  190. package/dist/components/tag-input/snice-tag-input.js +9 -15
  191. package/dist/components/tag-input/snice-tag-input.js.map +1 -1
  192. package/dist/index.cjs +127 -28
  193. package/dist/index.cjs.map +1 -1
  194. package/dist/index.esm.js +127 -28
  195. package/dist/index.esm.js.map +1 -1
  196. package/dist/index.iife.js +127 -28
  197. package/dist/index.iife.js.map +1 -1
  198. package/dist/react/SniceProvider.js +1 -1
  199. package/dist/react/SniceRouter.js +1 -1
  200. package/dist/react/index.js +1 -1
  201. package/dist/react/matchRoute.js +1 -1
  202. package/dist/react/useRequestHandler.js +1 -1
  203. package/dist/request-response.d.ts +24 -1
  204. package/dist/symbols.cjs +1 -1
  205. package/dist/symbols.esm.js +1 -1
  206. package/dist/testing-dom.cjs +1 -1
  207. package/dist/testing-dom.esm.js +1 -1
  208. package/dist/transitions.cjs +1 -1
  209. package/dist/transitions.esm.js +1 -1
  210. package/docs/ai/components/calendar.md +8 -0
  211. package/docs/ai/components/tag-input.md +4 -0
  212. package/docs/ai/controllers.md +22 -6
  213. package/docs/components/calendar.md +24 -0
  214. package/docs/components/tag-input.md +6 -1
  215. package/docs/controllers.md +57 -6
  216. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- var Snice=function(e){"use strict";globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map;const t=globalThis.snice;function n(e){return Symbol.for(`snice:${e}`)}const o=n("is-controller-class"),r=n("is-controller-instance"),s=n("is-daemon-class"),i=n("is-daemon-instance"),a=n("is-element-class"),c=n("channel-handlers"),l=n("daemon-state"),u=n("ready-promise"),h=n("ready-resolve"),d=n("ready-reject"),f=n("ready-handlers-running"),m=n("rendered-promise"),p=n("rendered-resolve"),y=n("pending-reconnect-render"),g=n("render-depth"),b=n("render-root"),v=n("element-options"),w=n("controller"),E=n("initialized"),N=n("controller-key"),S=n("controller-name"),T=n("controller-id"),A=n("controller-operations"),C=n("native-controller"),_=n("controller-registry-name"),O=n("direct-controller"),x=n("controller-attribute-sync"),k=n("pending-controller-binding"),$=n("cleanup"),L=n("properties"),P=n("property-values"),R=n("property-defaults"),j=n("property-wrappers"),M=n("pre-init-property-values"),I=n("pre-upgrade-property-bindings"),D=n("properties-initialized"),V=n("property-watchers"),q=n("explicitly-set-properties"),B=n("router-context"),F=n("page-transition"),W=n("created-at"),z=n("ready-handlers"),U=n("dispose-handlers"),H=n("reconnect-handlers"),K=n("moved-handlers"),G=n("adopted-handlers"),Q=n("observers"),J=n("setting-from-property"),X=n("moved-timers"),Y=n("adopted-timers"),Z=n("dispatch-timers"),ee=n("render-method"),te=n("render-options"),ne=n("render-instance"),oe=n("render-timers"),re=n("render-callbacks"),se=n("styles-method"),ie=n("styles-applied"),ae=n("parent-styles-methods"),ce=n("snice-element-base"),le=n("context-handler"),ue=n("navigation-context-instance"),he=n("registered-elements"),de=n("is-updating"),fe=n("context-register"),me=n("context-unregister"),pe=n("context-notify-element"),ye=n("context-timer"),ge=n("context-called"),be=n("context-update"),ve=n("context-methods"),we=n("watch-methods"),Ee=n("observe-methods"),Ne=n("on-methods"),Se=n("respond-methods"),Te=n("ready-methods"),Ae=n("dispose-methods"),Ce=n("reconnect-methods"),_e=n("moved-methods"),Oe=n("adopted-methods"),xe=n("controller-abort"),ke=n("controller-attached"),$e=n("property-definers");class Le{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes(Le.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${Le.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(Le.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split(Le.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var Pe,Re,je;e.TransitionMode=void 0,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(e.TransitionMode||(e.TransitionMode={}));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[Re]=new Set,this[je]=!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,Re=Me,je=de,fe)](e,t){const n=this[he];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[Me].add(e)}[me](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[Me].delete(e)}[be](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[de])return;this[de]=!0;const e=this[Me],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[de]=!1}[pe](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 Le:return Le.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,t){return e[t]||(e[t]=new Set),e[t]}function ze(e,t){return e[t]||(e[t]={}),e[t]}function Ue(e,t,n,o,r){const s=t[V];if(!s)return;const i=[n],a=t[L]?.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 He(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 Ke(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 Ge(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 Qe(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 Je(e,t,n){if(null==e||!1===e||t?.type===Le&&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 Le:return Array.isArray(e)?Le.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 Xe=new WeakSet,Ye=new Map;function Ze(e,t){const n=e.constructor[Q];if(n&&Array.isArray(n)&&0!==n.length){e[$]?e[$].observers||(e[$].observers=[]):e[$]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?Ke(n,o.options.throttle):n;switch(o.type){case"intersection":et(e,t,o,r);break;case"resize":tt(e,t,o,r);break;case"media":nt(e,0,o,r);break;case"mutation":ot(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function et(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[$].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function tt(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[$].observers.push(()=>{s.disconnect()})}function nt(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=Ye.get(r);if(!s)try{s=window.matchMedia(r),Ye.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[$].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[$].observers.push(()=>{s.removeListener(a)}))}function ot(e,t,n,o){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 o(e);const r=n.options.maxDepth,s=t.shadowRoot||t,i=e.filter(e=>{let t=0,n=e.target;for(;n&&n!==s&&t<r;)n=n.parentNode,t++;return t<r});i.length>0&&o(i)}catch(e){console.error(`Error in mutation observer ${n.methodName}:`,e)}}),h=!0===e[r];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):h&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{u.observe(e,c)}),e[$].observers.push(()=>{u.disconnect()})}function rt(e){if(e[$]?.observers){for(const t of e[$].observers)t();e[$].observers=[]}}const st="@context/request",it=new WeakMap;function at(e){return!e||"object"!=typeof e&&"function"!=typeof e?null:!0===e[r]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:"function"==typeof e.dispatchEvent?e:null}function ct(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=at(e);if(t){const e={kind:"application"};if(t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[B]?n[B]:!0===n[r]&&void 0!==n.element?.[B]?n.element[B]:void 0}function lt(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[s]}function ut(e){if(!lt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");let t=e[l];if(!t){t={target:new EventTarget,bindings:0,active:!1};try{Object.defineProperty(e,l,{value:t,configurable:!0}),Object.defineProperty(e,i,{value:!0,configurable:!0})}catch{throw new TypeError("@daemon instances must remain extensible until they are provided to an app context.")}}return t}function ht(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=ct(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[r]?"controller":lt(t)?"@daemon instance":"element"}(e)} cannot resolve daemon "${t}" because no app context is provided.`);const o=n.daemons?.[t];if(!o)throw new Error(`[snice] app context does not provide daemon "${t}".`);if(!lt(o))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=ut(o);if(!s.active)throw new Error(`[snice] daemon "${t}" is not active because its app context has not been provided.`);return s.target}function dt(e){return lt(e)?function(e){return ut(e).target}(e):!0===e?.[r]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}function ft(e,t){const n=e.constructor[c];if(n){e[$]||(e[$]={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=ht(e,o.options.daemon)}catch(e){console.warn(`[snice/@respond] ${e.message} Responder "${o.channelName}" skipped.`);continue}d.addEventListener(r,h),e[$].channels.push(()=>{d.removeEventListener(r,h)})}}}function mt(e){if(e[$]?.channels){for(const t of e[$].channels)t();e[$].channels=[]}}const pt=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function yt(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();pt.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 gt(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=bt(e)}return o}function bt(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 vt(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 wt=n("on-handlers");function Et(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const Nt=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function St(e,t){const n=e.constructor[wt];if(n&&Array.isArray(n)&&0!==n.length){e[$]||(e[$]={events:[],eventCancels:[],channels:[],observers:[]}),e[$].events||(e[$].events=[]),e[$].eventCancels||(e[$].eventCancels=[]),(e[$].events.length>0||e[$].eventCancels.length>0)&&Tt(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=Ge(e,s.debounce,"@on","debounce"),a=i&&i>0?void 0:Ge(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&&yt(o.eventName),i&&i>0){const t=He(r,i);e[$].eventCancels.push(()=>t.cancel()),r=t}else a&&a>0&&(r=Et(r,a));let m=null;f&&["keydown","keyup","keypress"].includes(d)&&(m=gt(f));const p=(e=>m?t=>!!vt(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||lt(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=ht(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(y&&(E=Qe(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=Nt.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[$].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[$].events.push({target:t,eventName:d,handler:l,options:i})};if(b){u(E);continue}n&&u(n),w&&u(t)}}}}function Tt(e){if(e[$]?.events){for(const t of e[$].eventCancels??[])t();e[$].eventCancels=[];for(const{target:t,eventName:n,handler:o,options:r}of e[$].events)t.removeEventListener(n,o,r);e[$].events=[]}}const At=n("dispatch-generation");function Ct(e,t){return(e[At]??0)===t}function _t(e){e[At]=(e[At]??0)+1;const t=e[Z];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 Ot=n("context-handlers");function xt(e,t=!1){const n=e.constructor[Ot];if(!n||!Array.isArray(n)||0===n.length)return;const o=e[le]??function(e){const t=at(e);if(!t)return;const n={kind:"navigation"};return t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.navigation}(e);if(!o)return;e[ue]=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[ge]||(e[ge]=new Set);if(i.once&&o.has(n))return;const c=()=>{if(s.call(e,t),i.once){o.add(n);const t=e[ue];t&&"function"==typeof t[me]&&t[me](e,a)}},l=e[ye]||(e[ye]={}),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[fe]&&o[fe](e,a)}return t&&"function"==typeof o[pe]?new Promise(n=>{const s=()=>{try{r||e[ue]!==o||o[pe](e)}finally{n()}};"task"===t?setTimeout(s,0):queueMicrotask(s)}):void 0}function kt(e){const t=e.constructor[Ot];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[ye];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[ye]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[ue];o&&"function"==typeof o[me]&&o[me](e),delete e[ue],delete e[ge]}class $t{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 Lt(e,n){if(t.controllerRegistry.has(n))return void queueMicrotask(()=>{const t=e[C];(void 0===t?e[w]:t)===n&&Mt(e,n).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${n}":`,e)})});let o=t.pendingControllerAttachments.get(n);o||(o=new Set,t.pendingControllerAttachments.set(n,o)),o.add(e),queueMicrotask(()=>{t.pendingControllerAttachments.get(n)?.has(e)&&console.error(`Failed to attach controller "${n}":`,new Error(`Controller "${n}" not found in registry`))})}function Pt(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}function Rt(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 jt(e){if(!e[O])return!1;const t=e[S];return"function"==typeof t&&(Rt(e,function(e){const t=Object.prototype.hasOwnProperty.call(e,_)?e[_]:void 0;return"string"==typeof t?t:Pt(e)}(t)),!0)}async function Mt(e,n){if("string"!=typeof n){if("function"!=typeof n)throw new Error(`attachController: expected a controller name or a controller class, got ${typeof n}. Controller instances are not supported — pass the class itself.`);if("function"!=typeof(s=n)||!0!==s.prototype?.[o])throw new Error(`Controller class "${Pt(n)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=Pt(n),a=e[N],c=e[C];if("string"==typeof n&&void 0!==c&&c!==n)return;if(e[S]===n&&a)return void("string"!=typeof n&&jt(e));if(a&&(await It(e),e[N]&&e[S]===n))return void("string"!=typeof n&&jt(e));let l;if("string"==typeof n){const e=globalThis.snice?.controllerRegistry;if(!e)throw new Error("Snice global registry not initialized");if(l=e.get(n),!l)throw new Error(`Controller "${n}" not found in registry`)}else l=n;const u=new l;"string"!=typeof n&&(e[O]=!0,delete e[C]),t.controllerIdCounter+=1;const h=t.controllerIdCounter,d=new $t;u[r]=!0,u[T]=h,u.element=e;const m=e[B];if(void 0!==m&&(u[B]=m),e[N]=u,e[S]=n,e[A]=d,"string"!=typeof n&&jt(e),!e[f]){const t=new AbortController;e[xe]=t;const o=3e4;try{await Promise.race([e.ready,new Promise((e,n)=>{const r=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",n(e)};if(t.signal.aborted)return r();t.signal.addEventListener("abort",r,{once:!0});const s=setTimeout(()=>n(new Error(`attachController("${i}"): element did not become ready within ${o}ms (did you forget to appendChild it?)`)),o);t.signal.addEventListener("abort",()=>clearTimeout(s),{once:!0})})])}catch(t){throw e[N]===u&&("string"!=typeof n&&Rt(e,null),delete e[N],delete e[S],delete e[A],"string"!=typeof n&&delete e[O]),t}finally{e[xe]===t&&delete e[xe]}}u[ke]=!0,await d.runOperation(async()=>{await u.attach(e)}),await xt(u,"microtask"),Ze(u,e),ft(u,e),St(u,e),e.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:u}}))}async function It(e){const t=e[xe];t&&t.abort();const n=e[N],o=e[S],r=e[A];n&&(_t(n),"function"==typeof o&&Rt(e,null),delete e[N],delete e[S],delete e[A],"function"==typeof o&&delete e[O],n[ke]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),_t(n),n.element=null,rt(n),mt(n),Tt(n),kt(n),r&&await r.cleanup(),delete n[B],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:Pt(o),controller:n}}))))}function Dt(){if(globalThis.sniceNativeControllersInitialized)return;function e(e){if(!(e instanceof HTMLElement))return;if(!e.tagName||e.tagName.includes("-"))return;if(e[a])return;if(e[O])return void jt(e);const t=e.getAttribute("controller"),n=e[C];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[C],delete e[S],void It(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[C]=t,e.ready||(e.ready=Promise.resolve()),n&&It(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),Mt(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):Lt(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 Vt=Symbol.for("snice:html-result"),qt=Symbol.for("snice:css-result"),Bt=new WeakMap;function Ft(e){return e&&e._$litType$===Vt}function Wt(e){return e&&e._$litType$===qt}const zt=Symbol.for("snice:nothing"),Ut=Symbol.for("snice:unsafe-html");function Ht(e){return e&&e._$litType$===Ut}const Kt=Symbol.for("snice:repeat-result"),Gt=new WeakSet;function Qt(e){return e[b]||e.shadowRoot||null}function Jt(e){const t=Qt(e);if(t)return t;const n=e.constructor[v];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[b]=o,Gt.add(e),o}function Xt(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&Gt.has(n))return n;n=n.parentNode}return null}const Yt=/^[a-z][a-z0-9._-]{0,127}$/,Zt=/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/,en=Symbol("ambiguous-render-host-identity"),tn=new WeakMap;function nn(e,t){try{if("function"!=typeof e||!Yt.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=Zt.test(s)?s:"",a=Object.freeze({label:i?`<${t}> (${i})`:`<${t}>`}),c=[tn.get(e),tn.get(o)].filter(e=>void 0!==e),l=c.some(e=>e===en||e.label!==a.label)?en:c[0]??a;tn.set(e,l),tn.set(o,l)}catch{}}class on extends Error{#e;constructor(e,t,n){super(t,{cause:n}),this.#e=e.marker}belongsTo(e){return this.#e===e.marker}}function rn(e,t){if(t instanceof on&&t.belongsTo(e))return t;const n=t instanceof Error?t.message:String(t),o=new on(e,`snice: render failed for ${e.label}: ${n}`,t);return t instanceof Error&&(o.name=t.name),o}const sn=`snice$${Math.random().toFixed(9).slice(2)}$`,an="?"+sn,cn=`\x3c!--${an}--\x3e`,ln=new RegExp(sn.replace(/\$/g,"\\$"),"g"),un=new WeakMap,hn=Symbol("not-committed"),dn=new WeakMap;function fn(e,t){return Object.prototype.isPrototypeOf.call(t.prototype,e)}function mn(e,t){const n=e.localName,o=n&&t?.get(n);if(!o||!fn(e,o))return;const r=e,s=r[I];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[I]}}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(fn(e,r))return!1;const n=r[L];if(!n?.has(t))return!1}const s=e;return s[I]||(s[I]=new Set),s[I].add(t),function(e,t){if(!t?.whenDefined||dn.get(e)===t)return;dn.set(e,t);const n=new WeakRef(e);t.whenDefined(e.localName).then(()=>{const e=n.deref();e&&mn(e,t)})}(e,n),!0}(e,t,o)?e[t]=n:Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n})}const yn=Symbol.for("snice:no-change"),gn=Symbol.for("snice:live"),bn=e=>null===e||"object"!=typeof e&&"function"!=typeof e,vn=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class wn{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(sn))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(sn))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(sn))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(sn))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(sn)&&(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(sn)){o.push(i);const t=n[r]||i.name,s=a.split(sn),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===an){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(sn)){const t=e.data.split(ln);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(sn)){const n=e.parentNode,o=t.split(ln),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 En(e){const{strings:t}=e,n=un.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(sn);else if(i)r.push(l),o.push(sn);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(sn)}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="${sn}"`)}}else r.push(""),o.push(cn)}}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 wn(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 un.set(t,d),d}class Nn{#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=En(e)}catch(e){throw t?rn(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 Tn(e,r,this.#t,this.#n);break;case"attribute":const i=n.get(t.element);o=new An(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new kn(a,t.name,this.#n);break;case"boolean-attribute":const c=n.get(t.element);o=new Ln(c,t.name);break;case"event":const l=n.get(t.element);o=new Pn(l,t.name);break;case"class":const u=n.get(t.element);o=new _n(u,t.name);break;case"style":const h=n.get(t.element);o=new On(h,t.name);break;case"spread":const d=n.get(t.element);o=new xn(d,t.name,this.#n);break;case"controller":const f=n.get(t.element);o=new $n(f);break;case"conditional-if":const m=n.get(t.element);o=new jn(m);break;case"conditional-else-if":const p=n.get(t.element);o=new In(p);break;case"conditional-case":const y=n.get(t.element);o=new Dn(y,s);break;case"conditional-when":const g=n.get(t.element);o=new qn(g);break;case"comment":const b=n.get(t.startNode);o=new Cn(b,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof jn||o instanceof In||o instanceof Dn||o instanceof qn?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 In||e instanceof qn?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof jn||n instanceof Dn)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof An&&void 0!==t.strings||t instanceof Cn?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 Sn{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 Tn extends Sn{#t;#n;constructor(e,t,n=null,o=null){super(),this.type="node",this._committedValue=hn,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?rn(this.#t,e):e}commit(e){if(e!==yn)if((e=>!!e&&"function"==typeof e.then)(e)||vn(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==zt&&null!=e&&""!==e)bn(e)?e!==this._committedValue&&this._commitText(e):Ft(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===Kt}(e)?0===e.values.length?this.commit(e.empty??zt):this._commitIterable(e.values,e.keys):Ht(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!==zt){const e=this._clear();if(this._committedValue=zt,e)throw e}this._committedValue=zt}}_commitText(e){if(this._committedValue!==hn&&this._committedValue!==zt&&bn(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 Nn){const n=un.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new Nn(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(!Ft(e))return;let n;try{n=En(e)}catch(e){throw t?rn(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 Tn||(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 Tn(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 Tn(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(Ht(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=zt,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(vn(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=zt,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=zt,n}_disposeCommitted(e){let t;if(e instanceof Nn)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof Tn)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 Nn)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof Tn)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 Nn)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof Tn)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class An extends Sn{constructor(e,t,n){super(),this.type="attribute",this._committedValue=hn,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(hn),this.strings=n):this._committedValue=hn}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===yn)return;if(o=!bn(e)||e!==this._committedValue&&e!==yn,!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===yn&&(i=s[e],i===hn&&(i="")),o=o||!bn(i)||i!==s[e],i===zt?n=zt:n!==zt&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===zt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class Cn extends Sn{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(hn)}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===yn&&(s=this._committedValues[e],s===hn&&(s="")),o=o||!bn(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===zt?"":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 _n extends Sn{constructor(e,t){super(),this.type="class",this.committed=hn,this.element=e,this.name=t}commit(e){if(e===yn)return;const t=e!==zt&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=hn}}class On extends Sn{constructor(e,t){super(),this.type="style",this.committed=hn,this.element=e,this.name=t}commit(e){if(e===yn||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===zt||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=hn}}class xn extends Sn{#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===yn)return;if(e!==zt&&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===zt?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===zt||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!==zt&&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===zt||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 Xt(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||mn(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 kn extends Sn{#n;constructor(e,t,n=null){super(),this.type="property",this._committedValue=hn,this.element=e,this.name=t,this.#n=n}commit(e){if(e!==yn){if(function(e){return e&&e._$liveMarker$===gn}(e)){if((e=e.value)===yn)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===zt?void 0:e,this.#n)}}reconnected(){mn(this.element,this.#n)}clear(){this._committedValue=hn}}class $n extends Sn{constructor(e){super(),this.type="controller",this._committedValue=hn,this.element=e}commit(e){if(e===yn)return;const t=null==e||!1===e||""===e||e===zt?null:e,n=this._committedValue===hn,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[k]?delete r[k]:r[a]?r.controller=null:this._detach()),"function"==typeof t?this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[a]&&(r[k]=t):"string"==typeof t?this.element.setAttribute("controller",t):"string"==typeof o&&this.element.removeAttribute("controller")}_apply(e){const t=this.element;t[a]?t.controller!==e?t.controller=e:this._attach(e):this.element.localName.includes("-")?t[k]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){Mt(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){It(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[k]&&(t[a]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[k]&&delete e[k];const t=this._committedValue;this._committedValue=hn,"function"==typeof t&&(e[a]||this._detach())}}class Ln extends Sn{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=hn,this.element=e,this.name=t}commit(e){if(e===yn)return;const t=!!e&&e!==zt;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=hn}}class Pn extends Sn{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=gt(t)}else this.eventName=n,yt(n)}commit(e){if(e===yn)return;e===zt&&(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&&!vt(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=Xt(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 Rn=Symbol("not-set");class jn extends Sn{constructor(e){super(),this.type="node",this.conditions=[Rn],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]=Rn,Mn.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!==yn&&(this.conditions[0]=e)}setAlternative(e,t){t!==yn&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==Rn&&this.conditions[t]!==zt&&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 Mn=new WeakMap;class In extends Sn{constructor(e){super(),this.type="node";const t=Mn.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 Dn extends Sn{constructor(e,t){super(),this.type="node",this.value=Rn,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?Rn:n.getAttribute("value")??""})-1;o&&Vn.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:Rn})-1}}n.removeChild(e)}commit(e){e!==yn&&(this.value=e)}setExpected(e,t){t!==yn&&(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 Vn=new WeakMap;class qn extends Sn{constructor(e){super(),this.type="node";const t=Vn.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 Bn=new WeakSet,Fn=new WeakSet,Wn=["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 zn(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 Un(e){return e?Array.from(e.querySelectorAll("[autofocus]")).filter(e=>!Fn.has(e)):[]}function Hn(e){return e?Array.from(e.querySelectorAll(Wn)):[]}function Kn(e){if(Bn.has(e)||!function(e){return!(!e.hasAttribute("autofocus")||Fn.has(e))||Un(Qt(e)).length>0}(e))return;Bn.add(e);const t=()=>{const t=e.ownerDocument.defaultView,n=()=>{Bn.delete(e),function(e){if(!e.isConnected)return;const t=Qt(e),n=[];if(e.hasAttribute("autofocus")&&!Fn.has(e)&&n.push(e),n.push(...Un(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)Fn.add(e);else for(const o of n){if(Fn.add(o),zn(o))return;if(o===e)for(const e of Hn(t))if(zn(e))return}}(e)};t?.requestAnimationFrame?t.requestAnimationFrame(n):queueMicrotask(n)};Promise.resolve(e.ready).then(t,t)}let Gn=!1;function Qn(e){e[p]||(e[m]=new Promise(t=>{e[p]=t}))}function Jn(e){const t=e[p];t&&(e[p]=null,t())}const Xn=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?to(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?to(t,t[te]||{}):t[y]=!0}remove(e){this.pending.delete(e)}};function Yn(e){return Object.prototype.hasOwnProperty.call(e,ne)}function Zn(e){const t=e[re];if(!t||0===t.length)return;const n=[...t];e[re]=[],n.forEach(e=>e())}const eo=50;function to(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=tn.get(t),s=tn.get(o);return r!==en&&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[ee];if(!i)return void Jn(e);if(t.once&&Yn(e))return void Jn(e);const a=e[g]??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 Jn(e)}e[g]=a+1;try{const a=s?n:i.call(e),c=Jt(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[ne];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[ne]=null,Zn(e),void Kn(e)}if(!Ft(a))return void console.warn("Render method must return html`` template result");let l=e[ne];if(l&&l.isSameTemplate(a.strings))return r=l.getRenderHostIdentity()??o,l.update(a.values),Zn(e),void Kn(e);const u=c instanceof ShadowRoot?c.customElementRegistry??c.ownerDocument.defaultView?.customElements??null:c.ownerDocument.defaultView?.customElements??null,h=new Nn(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[ne]=h;try{l?.clear()}catch(e){m=e}if(Zn(e),Kn(e),m)throw m}catch(e){const t=rn(r,e);if(Gn)throw t;console.error("Error rendering element:",t)}finally{e[g]=a,Jn(e)}}function no(e,t=!1){const n=e[te]||{};if(n.once&&Yn(e))e.isConnected&&oo(e);else if(Qn(e),t)to(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[oe]||(e[oe]={}),clearTimeout(e[oe].debounce),void(e[oe].debounce=setTimeout(()=>{e[oe].debounce=null,Xn.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[oe]||(e[oe]={lastThrottle:0});const t=e[oe],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void Xn.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),Xn.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}Xn.schedule(e,n)}}function oo(e){const t=e[ne];t?.reconnected()}const ro=n("debounce-timers"),so=n("throttle-timers"),io=n("once-called"),ao=n("memoize-cache");function co(e){if(e[ro]){for(const t in e[ro])e[ro][t]?.timeout&&clearTimeout(e[ro][t].timeout);e[ro]={}}}function lo(e){if(e[so]){for(const t in e[so])e[so][t]?.timeout&&clearTimeout(e[so][t].timeout);e[so]={}}}function uo(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 ho(e){e.prototype[a]=!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[L];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[u]||(this[u]=new Promise((e,t)=>{this[h]=e,this[d]=t}),this[u].catch(()=>{})),this[u]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[p]?this[m]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[w]},set(e){const t=this[w];if(this[w]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void Mt(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):Lt(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&It(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[u]||(this[u]=new Promise((e,t)=>{this[h]=e,this[d]=t}),this[u].catch(()=>{})),this[E]){try{oo(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}St(this,this),ft(this,this),xt(this,"task");try{Ze(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[H];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[ee]&&this[y]&&(this[y]=!1,no(this)),void Kn(this)}this[D]=!0;const n=e[L];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);We(this,q).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[k]){const e=this[k];if(delete this[k],!this[w]){this[w]=e;const t=e?.name||"(anonymous controller class)";Mt(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[w]){const e=this.getAttribute("controller");e&&(this.controller=e)}if(function(e){const t=e[se],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)Wt(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[ie]){e[ie]=!0;try{const o=[...n],r=e[ae];if(r)for(const t of r){const n=t.call(e);Wt(n)&&o.push(n)}if(t){const n=t.call(e);if(!Wt(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=Jt(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[ee])try{Jt(this)}catch{}St(this,this),ft(this,this),xt(this,"task"),this[E]=!0,function(e,t){if(Xe.has(t))return;Xe.add(t);const n=t[V];if(!n||0===n.size)return;const o=t[L],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[V],o=t[L];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[z];if(await new Promise(e=>queueMicrotask(e)),!this.isConnected)return void(this[h]&&(this[h](),this[h]=null,this[d]=null));this[ee]&&no(this,!0);try{Ze(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[d]=null));let r,s=!1;if(o){this[f]=!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[f]}}s&&this[d]?(this[d](r),this[h]=null,this[d]=null):this[h]&&(this[h](),this[h]=null,this[d]=null),Kn(this)},e.prototype.disconnectedCallback=async function(){_t(this);try{!function(e){const t=e[ne];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[U];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[w]&&It(this).catch(e=>{console.error("Failed to detach controller:",e)}),Tt(this),mt(this),kt(this),rt(this),co(this),lo(this),function(e){const t=e[oe];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[y]=!0),vo(this,X),vo(this,Y)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t){if(s=r,s?.includes(sn))return;if(this[x])return;return this[O]?void jt(this):void(this.controller=r)}var s;"autofocus"===t&&(null===r?Fn.delete(this):this[E]&&Kn(this));const i=e[L];if(i)for(const[n,o]of i){if(Fe(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[J]?.has(t.toLowerCase()))break;const s=this[P]?.[n],i=this[R]?.[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;We(this,q).add(n),ze(this,P)[n]=a,this[E]&&Ue(this,e,n,s,a),this[ee]&&this[E]&&no(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[K];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[G];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function fo(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[L]){e[L]||(e[L]=new Map);for(const[n,o]of t[L])e[L].has(n)||e[L].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[L]){t[L]||(t[L]=new Map);for(const[e,o]of n.metadata[L])t[L].set(e,o)}else if(mo.length>0){t[L]||(t[L]=new Map);const e=mo.pop();for(const[n,o]of e)t[L].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[v]||{}},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[v]=i,!0===t.prototype[ce]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,ee)&&"function"==typeof t.prototype.render&&(t.prototype[ee]=t.prototype.render,t.prototype[te]=t.renderOptions||{}),ho(t);const a=customElements.get(e);return a?(a===t&&nn(t,e),globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),nn(t,e),t)}const mo=[],po=new WeakMap;function yo(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[L]||(n.metadata[L]=new Map),n.metadata[L].set(o,e||{})):(0===mo.length&&mo.push(new Map),mo[mo.length-1].set(o,e||{})),function(t){const n=this[I],r=!0===n?.delete(o);0===n?.size&&delete this[I];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[L]||(c[L]=new Map);const l={...e};l.type||void 0===t||(l.type=Ve(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[L].set(o,l),ze(this,R)[o]=t;const u=()=>{if(!this[D])return;const e=this[P]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=Fe(l,o),r=Je(e,l,t),s=n.toLowerCase();We(this,J).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[J].delete(s)}}this[E]&&(Ue(this,this.constructor,o,e,e),this[ee]&&no(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=uo(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=uo(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=uo(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[P]?.[o]===t&&u()}),t};ze(this,j)[o]=h;const d=this.constructor.prototype;let f=d[$e];f&&Object.prototype.hasOwnProperty.call(d,$e)||(f=new Map(f),d[$e]=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[P]&&o in this[P]?this[P][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[D])return this[M]||(this[M]=new Map),void this[M].set(o,n);if(ze(this,P)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=Fe(l,o),t=Je(n,l,this[R]?.[o]);We(this,q).add(o);const r=e.toLowerCase();We(this,J).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[J].delete(r)}}this[E]&&(Ue(this,this.constructor,o,t,n),this[ee]&&no(this))},configurable:!0,enumerable:!0}));const p=h(t);return ze(this,P)[o]=p,ze(this,R)[o]=p,i?a:p}}}function go(e){return!0===e[r]&&e.element?e.element: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 vo(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 wo(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 Eo=wo(K,X,_e),No=wo(G,Y,Oe);class So extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[v];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return no(this),this.rendered}renderNow(){return Qn(this),to(this,{...this[te]||{},once:!1}),this.rendered}}Object.defineProperty(So.prototype,ce,{value:!0});class To{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 Ao(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 Co(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 _o(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 Oo(e){if(!lt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=ut(e);if(0===t.bindings){t.active=!0;try{St(e,t.target),ft(e,t.target)}catch(n){throw mt(e),Tt(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&&(mt(e),Tt(e),_t(e),t.active=!1,t.target=new EventTarget))}}function xo(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(it.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(st,r),it.set(e,{listener:r});let s=!1;return()=>{if(s)return;s=!0;const t=it.get(e);t?.listener===r&&(e.removeEventListener(st,r),it.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(Oo(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?.())}}const ko=/=:[\w-]+\)?$/;function $o(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 Lo(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)||$o(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("=")&&ko.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 Po=new WeakMap;var Ro;!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(Ro||(Ro={}));let jo=!1;async function Mo(e,t=500){if(customElements.get(e))return;let n=null;jo||(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 Io(e,t=500){const n=e.tagName.toLowerCase();await Mo(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}let Do=0,Vo=null;const qo=Symbol.for("snice:body-scroll-lock");var Bo;return globalThis[qo]={clear(){Do=0,Vo=null}},"undefined"!=typeof document&&Dt(),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"}(Bo||(Bo={})),e.Context=De,e.ContextAwareFetcher=class{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)}},e.IS_CONTROLLER_INSTANCE=r,e.Router=function(t){const n=t.window??window,o=t.document??document,r=[];let s,i,a,c=0,l=!1,u=[],h=null,d=null;const f=t.context||{};let m=null,p=null;const y=new De(f,[],"",{},t.fetcher);function g(e){if(m===e&&p&&Po.get(e)===p)return;p?.(),Po.get(e)?.();const t=xo(e,(n=y).application,{fetch:n.fetch},n);var n;let o=!1;const r=()=>{o||(o=!0,t(),Po.get(e)===r&&Po.delete(e))};p=r,m=e,Po.set(e,r)}function b(e){if(!h||!d)return null;const t=e.querySelectorAll(h);for(const e of t)if(e[W]===d)return e;return null}function v(e,t,n,o,u,h,d=0){if(!Number.isFinite(d))throw new TypeError(`Route order for "${e}" must be a finite number.`);switch(r.push({route:new To(e),tag:t,transition:n,guards:o,layout:u,placard:h,order:d,registrationOrder:c++}),l=!1,e){case"/404":s=t;break;case"/403":i=t;break;case"/":a=t}}function w(){const e=new Set;u=r.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(f):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function E(e,t,n){y[be](f,u,t,n)}function N(){switch(t.type){case"hash":return n.location.hash.slice(1);case"pushstate":return`${n.location.pathname}${n.location.search}`}}function S(e){let t;if(i)t=o.createElement(i),t[B]=f;else{const e=o.createElement("div");e.className="default-403",e.innerHTML="<h1>403</h1><p>Unauthorized</p>",t=e}e.innerHTML="",e.appendChild(t),h=null,d=null}async function T(e,t,n,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=o.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}(),n.appendChild(i))},50);try{for(const e of s)if(!await e(f,t))return r&&r()||S(n),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function A(e,n,r,s,i,a,c){const l=!1===(m=s)?null:m||(t.layout?t.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();d=t;const n=o.createElement(e);return n[B]=f,n[W]=t,{element:n,needsNewLayout:!0}}return d=null,{element:null,needsNewLayout:!0}}(l),g=r||t.transition;if(null!==p||null!==b(e)){if(await async function(e,t,n,o,r,s,i,a){const c=o||b(e);if(!c)return;!function(e,t,n){"function"==typeof e.update&&e.update(f,u,t,n)}(c,s,i);const l=c.querySelector('[slot="page"]');if(n&&l){if(t.setAttribute("slot","page"),await O(c,l,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)))}(e,n,g,p,y,i,a,c),c&&c())return;E(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))}(e,n,g,c),c&&c()||E(0,i,a)}let C=0;async function _(e){const i=o.querySelector(t.target);if(!i)throw new Error(`Target element not found: ${t.target}`);g(i);const c=++C,l=()=>c!==C;if(w(),n.scrollTo(0,0),(""===e?.trim()||"/"===e)&&a){const t=r.find(e=>e.route.match("/"));if(!await T(t?.guards,{},i,l))return;if(l())return;const{element:s,transition:c,layout:u}=function(){const e=o.createElement(a);e[B]=f;const t=n.customElements.get(a),s=t?.[F],i=r.find(e=>e.route.match("/"));return{element:e,transition:s,layout:i?.layout}}();return void await A(i,s,c,u,e,{},l)}if(!e)return;const u=await async function(e,t,n){for(const s of r){const r=Lo(s.route,e);if(!1===r)continue;if(!await T(s.guards,r,t,n))return{result:Ro.GUARDS_FAILED};const i=o.createElement(s.tag);i[B]=f,i[le]=y;const a=r;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:Ro.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:Ro.NOT_FOUND}}(e,i,l);if(l())return;if(u.result===Ro.GUARDS_FAILED)return;if(u.result===Ro.SUCCESS){const{element:t,transition:n,layout:o,routeParams:r={}}=u;return void await A(i,t,n,o,e,r,l)}const{element:h,transition:d,layout:m}=function(){if(s){const e=o.createElement(s);e[B]=f;const t=n.customElements.get(s),r=t?.[F];return{element:e,transition:r,layout:void 0}}const e=o.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 A(i,h,d,m,e,{},l)}async function O(t,n,o,r,s=C){return async function(t,n,o,r={},s=()=>!1){const i=r.outDuration??300,a=r.inDuration??300,c=r.mode||"sequential",l=r.out?Co(r.out):{opacity:"0"},u={opacity:"0"},h=r.in?Co(r.in):{opacity:"1"},d=t.style,f=t.tagName.includes("-")&&t.shadowRoot,m=Symbol.for("snice:transition-original-position"),p=Symbol.for("snice:transition-count"),y=t;f||(m in y||(y[m]=d.position,y[p]=0),y[p]++,d.position="relative");const g=()=>{f||(y[p]--,y[p]<=0&&(d.position=y[m],delete y[m],delete y[p]))},b=n.hasAttribute("slot")||o.hasAttribute("slot");switch(_o(n,b,i,"all"),_o(o,b,a,"all"),Object.assign(o.style,u),t.appendChild(o),c){case e.TransitionMode.SIMULTANEOUS:Object.assign(n.style,l),Object.assign(o.style,h),await new Promise(e=>setTimeout(e,Math.max(i,a)));break;case e.TransitionMode.SEQUENTIAL:if(Object.assign(n.style,l),await new Promise(e=>setTimeout(e,i)),s())return o.parentNode===t&&o.remove(),void g();Object.assign(o.style,h),await new Promise(e=>setTimeout(e,a))}if(s())return o.parentNode===t&&o.remove(),void g();n.remove(),function(e,t){e.style.position="",e.style.width="",e.style.transition="",t?e.style.height="":(e.style.top="",e.style.left="")}(o,b),Object.keys({...u,...h}).forEach(e=>{o.style[e]=""}),g()}(t,n,o,r,()=>s!==C)}return{page:function(e){return function(t,o){if(o?.metadata&&o.metadata[L]){t[L]||(t[L]=new Map);for(const[e,n]of o.metadata[L])t[L].set(e,n)}ho(t),t[F]=e.transition;const r=t.prototype.connectedCallback;t.prototype.connectedCallback=function(){void 0!==this[B]&&(this[le]=y),r?.call(this)};const s=t.prototype.disconnectedCallback;t.prototype.disconnectedCallback=function(){s?.call(this),delete this[B],delete this[le]};const i=n.customElements.get(e.tag);return i?i===t&&nn(t,e.tag):(n.customElements.define(e.tag,t),nn(t,e.tag)),e.routes.forEach(t=>{v("string"==typeof t?t:t.path,e.tag,e.transition,e.guards,e.layout,e.placard,"string"==typeof t?void 0:t.order)}),t}},initialize:function(){const e=o.querySelector(t.target);if(!e)throw new Error(`Target element not found: ${t.target}`);g(e),!l&&(r.sort((e,t)=>Ao(t.route.spec)-Ao(e.route.spec)||e.order-t.order||e.registrationOrder-t.registrationOrder),l=!0),w(),function(){const e=()=>{const e=o.querySelector(t.target);if(e&&(m!==e||!p||Po.get(e)===p))return m!==e&&it.has(e)?(p?.(),p=null,void(m=null)):void _(N())};switch(t.type){case"hash":n.addEventListener("hashchange",e);break;case"pushstate":n.addEventListener("popstate",e)}}(),_(N())},navigate:async function(e){const o=function(e){const t=e.trim().replace(/^#/,"");return t?t.startsWith("/")?t:`/${t}`:"/"}(e);!function(e){switch(t.type){case"hash":{const t=`#${e}`;n.location.hash!==t&&n.history.pushState(null,"",t);break}case"pushstate":`${n.location.pathname}${n.location.search}`!==e&&n.history.pushState(null,"",e)}}(o),await _(o)},register:v}},e.SimpleArray=Le,e.SniceElement=So,e.adopted=No,e.applyElementFunctionality=ho,e.attachController=Mt,e.classMap=function(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t},e.clearDebounceTimers=co,e.clearMemoizeCache=function(e,t){e[ao]&&(t?delete e[ao][t]:e[ao]={})},e.clearThrottleTimers=lo,e.context=function(e={}){return function(t,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,ve)||(n[ve]=new Set),!n[ve].has(t)){if(n[ve].add(t),!Object.prototype.hasOwnProperty.call(n,Ot)){const e=n[Ot];n[Ot]=e?[...e]:[]}n[Ot].push({methodName:o,method:t,options:e})}}),t}},e.contextProperty=function(){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[B])return this[B];const e=ct(this);return void 0!==e?e:void 0},set(){},configurable:!0,enumerable:!0}),e}}},e.controller=function(e){return function(n,r){const s=globalThis.snice?.controllerRegistry;if(!s)throw new Error("Snice global registry not initialized");s.set(e,n),n.prototype[o]=!0,Object.defineProperty(n,_,{value:e,configurable:!0});const i=t.pendingControllerAttachments.get(e);return i&&(t.pendingControllerAttachments.delete(e),queueMicrotask(()=>{for(const t of i){const n=t[C];(void 0===n?t[w]:n)===e&&Mt(t,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e}":`,t)})}})),n}},e.createRequestHandler=function(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}},e.css=function(e,...t){const n=0===t.length?Bt.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+=(Wt(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:qt,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&&Bt.set(e,r),r},e.daemon=function(e,t){Object.defineProperty(e.prototype,s,{value:!0,configurable:!0})},e.debounce=function(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[ro]||(this[ro]={});const a=this[ro],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}}}},e.detachController=It,e.dispatch=function(e,t){return function(n,o){const r=Symbol(`@dispatch:${e}`);return function(...o){const s=this[At]??0;this[Z]||(this[Z]=new Map),this[Z].has(r)||this[Z].set(r,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null,invocation:0});const i=this[Z].get(r),a=Ge(this,t?.debounce,"@dispatch","debounce"),c=a&&a>0?void 0:Ge(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 ht(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=Qe(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=dt(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},d=e=>{if(!Ct(this,s))return;if(a&&a>0)return void(i.debounceTimeout=setTimeout(()=>{i.debounceTimeout=null,Ct(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,Ct(this,s)&&i.invocation===l&&h(e)},n)};return u instanceof Promise?u.then(e=>{const t=(a??0)>0||(c??0)>0;return!Ct(this,s)||t&&i.invocation!==l||d(e),e}):(d(u),u)}}},e.dispose=function(){return function(e,t){bo(U,Ae,e,t)}},e.element=function(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 fo(e,n,o,t)}},e.escapeAttr=function(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")},e.escapeHtml=function(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},e.getBodyScrollLockCount=function(){return Do},e.getContext=ct,e.getContextFetch=function(e){const t=at(e);if(!t)return;const n={kind:"fetch"};return t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.fetch},e.getController=function(e){return e[N]},e.getSymbol=n,e.html=function(e,...t){return{_$litType$:Vt,strings:e,values:t}},e.isSafeUrl=function(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}},e.layout=function(e){return function(t,n){return fo(e,t,n)}},e.live=function(e){return{_$liveMarker$:gn,value:e}},e.lockBodyScroll=function(){0===Do&&(Vo=document.body.style.overflow,document.body.style.overflow="hidden"),Do++},e.memoize=function(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[ao]||(this[ao]={}),this[ao][s]||(this[ao][s]=new Map);const i=this[ao][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}}},e.moved=Eo,e.noChange=yn,e.nothing=zt,e.observe=function(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,Ee)||(n[Ee]=new Set),n[Ee].has(t))return;if(n[Ee].add(t),!Object.prototype.hasOwnProperty.call(n,Q)){const e=n[Q];n[Q]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[Q].push({type:i,target:c,selector:o,methodName:s,method:t,options:r})}})}},e.on=function(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,Ne)||(n[Ne]=new Set),!n[Ne].has(a)){if(n[Ne].add(a),!Object.prototype.hasOwnProperty.call(n,wt)){const e=n[wt];n[wt]=e?[...e]:[]}for(const e of i)n[wt].push({eventName:e,selector:o,methodName:s,method:t,options:r})}}),t}},e.once=function(e=!0){let t,n=!1;return function(o,r){const s=r.name;return function(...r){return e?(this[io]||(this[io]={}),this[io][s]||(this[io][s]={called:!0,result:o.apply(this,r)}),this[io][s].result):(n||(n=!0,t=o.apply(this,r)),t)}}},e.parseDuration=function(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}},e.property=yo,e.provideContext=function(e,t,n={}){return xo(e,t,n)},e.query=function(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?Qt(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}}},e.queryAll=function(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?Qt(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}}},e.ready=function(){return function(e,t){bo(z,Te,e,t)}},e.reconnect=function(){return function(e,t){bo(H,Ce,e,t)}},e.render=function(e={}){return function(t,n){return n.addInitializer(function(){this[ee]=t,this[te]=e}),function(...n){const o=t.apply(this,n);return to(this,{...this[te]||e,once:!1},o),o}}},e.repeat=function(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$:Kt,items:n,keys:o,values:n.map(t.render),empty:0===n.length?"function"==typeof t.empty?t.empty():t.empty:void 0}},e.request=function(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?ht(this,t.daemon):dt(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)})}}},e.resetOnce=function(e,t){e[io]&&(t?delete e[io][t]:e[io]={})},e.respond=function(e,t){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,Se)||(o[Se]=new Set),!o[Se].has(n)){if(o[Se].add(n),!Object.prototype.hasOwnProperty.call(o,c)){const e=o[c];o[c]=e?[...e]:[]}o[c].push({channelName:e,methodName:r,method:n,options:t})}})}},e.setDisableElementReadyWarnings=function(e){jo=e},e.setStrictRenderErrors=function(e){Gn=e},e.state=function(e={}){return yo({...e,attribute:!1,reflect:!1})},e.styleMap=function(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("; ")},e.styles=function(){return function(e,t){return t.addInitializer(function(){this[se]&&!this[ae]?this[ae]=[this[se]]:this[se]&&this[ae]&&this[ae].push(this[se]),this[se]=e}),e}},e.svg=function(e,...t){return{_$litType$:Vt,strings:e,values:t,svg:!0}},e.throttle=function(e=300,t={}){const{leading:n=!0,trailing:o=!0}=t;return function(t,r){const s=r.name;return function(...r){this[so]||(this[so]={});const i=this[so],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))}}},e.trackRenders=async function*(e){for(;;)await new Promise(t=>{e[re]||(e[re]=[]),e[re].push(t)}),yield},e.unlockBodyScroll=function(){0!==Do&&(Do--,0===Do&&(document.body.style.overflow=Vo??"",Vo=null))},e.unsafeHTML=function(e){return{_$litType$:Ut,html:e}},e.useNativeElementControllers=Dt,e.waitForAllCustomElements=async function(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=>Io(e,t)))},e.waitForElementDefined=Mo,e.waitForElementReady=Io,e.watch=function(...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,we)||(n[we]=new Map);let s=n[we].get(e);if(s||(s=new Set,n[we].set(e,s)),!Object.prototype.hasOwnProperty.call(n,V)){const e=n[V],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[V]=t}for(const i of t)s.has(i)||(s.add(i),n[V].has(i)||n[V].set(i,[]),n[V].get(i).push({methodName:r,method:e,immediate:o}))})}},e}({});
1
+ var Snice=function(e){"use strict";globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map;const t=globalThis.snice;function n(e){return Symbol.for(`snice:${e}`)}const o=n("is-controller-class"),r=n("is-controller-instance"),s=n("is-daemon-class"),i=n("is-daemon-instance"),a=n("is-element-class"),c=n("channel-handlers"),l=n("daemon-state"),u=n("ready-promise"),h=n("ready-resolve"),d=n("ready-reject"),f=n("ready-handlers-running"),m=n("rendered-promise"),p=n("rendered-resolve"),y=n("pending-reconnect-render"),g=n("render-depth"),b=n("render-root"),v=n("element-options"),w=n("controller"),E=n("initialized"),N=n("controller-key"),S=n("controller-name"),T=n("controller-id"),A=n("controller-operations"),C=n("native-controller"),_=n("controller-registry-name"),O=n("direct-controller"),x=n("controller-attribute-sync"),k=n("pending-controller-binding"),$=n("cleanup"),L=n("properties"),P=n("property-values"),R=n("property-defaults"),j=n("property-wrappers"),M=n("pre-init-property-values"),I=n("pre-upgrade-property-bindings"),D=n("properties-initialized"),V=n("property-watchers"),q=n("explicitly-set-properties"),B=n("router-context"),F=n("page-transition"),W=n("created-at"),z=n("ready-handlers"),U=n("dispose-handlers"),H=n("reconnect-handlers"),K=n("moved-handlers"),G=n("adopted-handlers"),Q=n("observers"),J=n("setting-from-property"),X=n("moved-timers"),Y=n("adopted-timers"),Z=n("dispatch-timers"),ee=n("render-method"),te=n("render-options"),ne=n("render-instance"),oe=n("render-timers"),re=n("render-callbacks"),se=n("styles-method"),ie=n("styles-applied"),ae=n("parent-styles-methods"),ce=n("snice-element-base"),le=n("context-handler"),ue=n("navigation-context-instance"),he=n("registered-elements"),de=n("is-updating"),fe=n("context-register"),me=n("context-unregister"),pe=n("context-notify-element"),ye=n("context-timer"),ge=n("context-called"),be=n("context-update"),ve=n("context-methods"),we=n("watch-methods"),Ee=n("observe-methods"),Ne=n("on-methods"),Se=n("respond-methods"),Te=n("ready-methods"),Ae=n("dispose-methods"),Ce=n("reconnect-methods"),_e=n("moved-methods"),Oe=n("adopted-methods"),xe=n("controller-abort"),ke=n("controller-attached"),$e=n("property-definers");class Le{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes(Le.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${Le.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(Le.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split(Le.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var Pe,Re,je;e.TransitionMode=void 0,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(e.TransitionMode||(e.TransitionMode={}));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[Re]=new Set,this[je]=!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,Re=Me,je=de,fe)](e,t){const n=this[he];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[Me].add(e)}[me](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[Me].delete(e)}[be](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[de])return;this[de]=!0;const e=this[Me],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[de]=!1}[pe](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 Le:return Le.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,t){return e[t]||(e[t]=new Set),e[t]}function ze(e,t){return e[t]||(e[t]={}),e[t]}function Ue(e,t,n,o,r){const s=t[V];if(!s)return;const i=[n],a=t[L]?.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 He(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 Ke(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 Ge(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 Qe(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 Je(e,t,n){if(null==e||!1===e||t?.type===Le&&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 Le:return Array.isArray(e)?Le.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 Xe=new WeakSet,Ye=new Map;function Ze(e,t){const n=e.constructor[Q];if(n&&Array.isArray(n)&&0!==n.length){e[$]?e[$].observers||(e[$].observers=[]):e[$]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?Ke(n,o.options.throttle):n;switch(o.type){case"intersection":et(e,t,o,r);break;case"resize":tt(e,t,o,r);break;case"media":nt(e,0,o,r);break;case"mutation":ot(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function et(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[$].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function tt(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[$].observers.push(()=>{s.disconnect()})}function nt(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=Ye.get(r);if(!s)try{s=window.matchMedia(r),Ye.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[$].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[$].observers.push(()=>{s.removeListener(a)}))}function ot(e,t,n,o){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 o(e);const r=n.options.maxDepth,s=t.shadowRoot||t,i=e.filter(e=>{let t=0,n=e.target;for(;n&&n!==s&&t<r;)n=n.parentNode,t++;return t<r});i.length>0&&o(i)}catch(e){console.error(`Error in mutation observer ${n.methodName}:`,e)}}),h=!0===e[r];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):h&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{u.observe(e,c)}),e[$].observers.push(()=>{u.disconnect()})}function rt(e){if(e[$]?.observers){for(const t of e[$].observers)t();e[$].observers=[]}}const st="@context/request",it=new WeakMap;function at(e){return!e||"object"!=typeof e&&"function"!=typeof e?null:!0===e[r]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:"function"==typeof e.dispatchEvent?e:null}function ct(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=at(e);if(t){const e={kind:"application"};if(t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[B]?n[B]:!0===n[r]&&void 0!==n.element?.[B]?n.element[B]:void 0}function lt(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[s]}function ut(e){if(!lt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");let t=e[l];if(!t){t={target:new EventTarget,bindings:0,active:!1};try{Object.defineProperty(e,l,{value:t,configurable:!0}),Object.defineProperty(e,i,{value:!0,configurable:!0})}catch{throw new TypeError("@daemon instances must remain extensible until they are provided to an app context.")}}return t}function ht(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=ct(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[r]?"controller":lt(t)?"@daemon instance":"element"}(e)} cannot resolve daemon "${t}" because no app context is provided.`);const o=n.daemons?.[t];if(!o)throw new Error(`[snice] app context does not provide daemon "${t}".`);if(!lt(o))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=ut(o);if(!s.active)throw new Error(`[snice] daemon "${t}" is not active because its app context has not been provided.`);return s.target}function dt(e){return lt(e)?function(e){return ut(e).target}(e):!0===e?.[r]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}const ft=new WeakMap;function mt(e,t,n){const o=e.constructor[c];if(!o)return;const r=n?.claim;let s=ft.get(e);s||(s=new Set,ft.set(e,s)),e[$]||(e[$]={events:[],channels:[]});for(const i of o){if(s.has(i))continue;const o=i.method.bind(e),a=`@request/${i.channelName}`;let c,l,u=0;const h=[];let d=null;const f=(e=>i.options?.debounce?(...t)=>new Promise((n,o)=>{clearTimeout(c),c=setTimeout(async()=>{try{n(await e(...t))}catch(e){o(e)}},i.options.debounce)}):i.options?.throttle?(...t)=>{const n=Date.now(),o=i.options.throttle-(n-u);if(o<=0){clearTimeout(l),l=null,u=n;const o=h.splice(0);d=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 d=t,new Promise((n,r)=>{h.push({resolve:n,reject:r}),l||(l=setTimeout(async()=>{u=Date.now(),l=null;const n=h.splice(0),o=d??t;d=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)}},o))})}:e)(o),m=e=>{const{data:t,discovery:n,payload:o}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),(r?Promise.resolve(r()).then(()=>f(o)):Promise.resolve(f(o))).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${i.methodName}:`,e)})};let p=t;if(void 0!==i.options?.daemon)try{p=ht(e,i.options.daemon)}catch(e){if(n?.deferUnresolvableDaemons)continue;console.warn(`[snice/@respond] ${e.message} Responder "${i.channelName}" skipped.`),s.add(i);continue}s.add(i),p.addEventListener(a,m),e[$].channels.push(()=>{p.removeEventListener(a,m)})}}function pt(e){if(ft.delete(e),e[$]?.channels){for(const t of e[$].channels)t();e[$].channels=[]}}const yt=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function gt(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();yt.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 bt(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=vt(e)}return o}function vt(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 wt(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 Et=n("on-handlers");let Nt=0;function St(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const Tt=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function At(e,t){const n=e.constructor[Et];if(n&&Array.isArray(n)&&0!==n.length){e[$]||(e[$]={events:[],eventCancels:[],channels:[],observers:[]}),e[$].events||(e[$].events=[]),e[$].eventCancels||(e[$].eventCancels=[]),(e[$].events.length>0||e[$].eventCancels.length>0)&&Ct(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=Ge(e,s.debounce,"@on","debounce"),a=i&&i>0?void 0:Ge(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&&gt(o.eventName),i&&i>0){const t=He(r,i);e[$].eventCancels.push(()=>t.cancel()),r=t}else a&&a>0&&(r=St(r,a));let m=null;f&&["keydown","keyup","keypress"].includes(d)&&(m=bt(f));const p=(e=>m?t=>!!wt(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||lt(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=ht(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(y&&(E=Qe(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=Tt.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[$].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[$].events.push({target:t,eventName:d,handler:l,options:i})};if(b){u(E);continue}n&&u(n),w&&u(t)}}}}function Ct(e){if(e[$]?.events){for(const t of e[$].eventCancels??[])t();e[$].eventCancels=[];for(const{target:t,eventName:n,handler:o,options:r}of e[$].events)t.removeEventListener(n,o,r);e[$].events=[]}}const _t=n("dispatch-generation");function Ot(e,t){return(e[_t]??0)===t}function xt(e){e[_t]=(e[_t]??0)+1;const t=e[Z];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 kt=n("context-handlers");function $t(e,t=!1){const n=e.constructor[kt];if(!n||!Array.isArray(n)||0===n.length)return;const o=e[le]??function(e){const t=at(e);if(!t)return;const n={kind:"navigation"};return t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.navigation}(e);if(!o)return;e[ue]=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[ge]||(e[ge]=new Set);if(i.once&&o.has(n))return;const c=()=>{if(s.call(e,t),i.once){o.add(n);const t=e[ue];t&&"function"==typeof t[me]&&t[me](e,a)}},l=e[ye]||(e[ye]={}),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[fe]&&o[fe](e,a)}return t&&"function"==typeof o[pe]?new Promise(n=>{const s=()=>{try{r||e[ue]!==o||o[pe](e)}finally{n()}};"task"===t?setTimeout(s,0):queueMicrotask(s)}):void 0}function Lt(e){const t=e.constructor[kt];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[ye];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[ye]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[ue];o&&"function"==typeof o[me]&&o[me](e),delete e[ue],delete e[ge]}class Pt{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 Rt(e,n){if(t.controllerRegistry.has(n))return void queueMicrotask(()=>{const t=e[C];(void 0===t?e[w]:t)===n&&Dt(e,n).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${n}":`,e)})});let o=t.pendingControllerAttachments.get(n);o||(o=new Set,t.pendingControllerAttachments.set(n,o)),o.add(e),queueMicrotask(()=>{t.pendingControllerAttachments.get(n)?.has(e)&&console.error(`Failed to attach controller "${n}":`,new Error(`Controller "${n}" not found in registry`))})}function jt(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}function Mt(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 It(e){if(!e[O])return!1;const t=e[S];return"function"==typeof t&&(Mt(e,function(e){const t=Object.prototype.hasOwnProperty.call(e,_)?e[_]:void 0;return"string"==typeof t?t:jt(e)}(t)),!0)}async function Dt(e,n){if("string"!=typeof n){if("function"!=typeof n)throw new Error(`attachController: expected a controller name or a controller class, got ${typeof n}. Controller instances are not supported — pass the class itself.`);if("function"!=typeof(s=n)||!0!==s.prototype?.[o])throw new Error(`Controller class "${jt(n)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=jt(n),a=e[N],c=e[C];if("string"==typeof n&&void 0!==c&&c!==n)return;if(e[S]===n&&a)return void("string"!=typeof n&&It(e));if(a&&(await Vt(e),e[N]&&e[S]===n))return void("string"!=typeof n&&It(e));let l;if("string"==typeof n){const e=globalThis.snice?.controllerRegistry;if(!e)throw new Error("Snice global registry not initialized");if(l=e.get(n),!l)throw new Error(`Controller "${n}" not found in registry`)}else l=n;const u=new l;"string"!=typeof n&&(e[O]=!0,delete e[C]),t.controllerIdCounter+=1;const h=t.controllerIdCounter,d=new Pt;u[r]=!0,u[T]=h,u.element=e;const m=e[B];void 0!==m&&(u[B]=m),e[N]=u,e[S]=n,e[A]=d,"string"!=typeof n&&It(e);let p,y,g,b=!1;const v=new Promise((e,t)=>{y=e,g=t});if(v.catch(()=>{}),mt(u,e,{deferUnresolvableDaemons:!0,claim:()=>(b=!0,p?.(),v)}),!e[f]){const t=new AbortController;e[xe]=t;const o=3e4;try{await Promise.race([e.ready,new Promise(e=>{if(b)return e();p=e}),new Promise((e,n)=>{const r=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",n(e)};if(t.signal.aborted)return r();t.signal.addEventListener("abort",r,{once:!0});const s=setTimeout(()=>n(new Error(`attachController("${i}"): element did not become ready within ${o}ms (did you forget to appendChild it?)`)),o);t.signal.addEventListener("abort",()=>clearTimeout(s),{once:!0})})])}catch(t){throw pt(u),g(t),e[N]===u&&("string"!=typeof n&&Mt(e,null),delete e[N],delete e[S],delete e[A],"string"!=typeof n&&delete e[O]),t}finally{e[xe]===t&&delete e[xe]}}u[ke]=!0;try{await d.runOperation(async()=>{await u.attach(e)}),await $t(u,"microtask"),Ze(u,e),mt(u,e),At(u,e)}catch(e){throw g(e),e}y(),e.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:u}}))}async function Vt(e){const t=e[xe];t&&t.abort();const n=e[N],o=e[S],r=e[A];n&&(xt(n),"function"==typeof o&&Mt(e,null),delete e[N],delete e[S],delete e[A],"function"==typeof o&&delete e[O],n[ke]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),xt(n),n.element=null,rt(n),pt(n),Ct(n),Lt(n),r&&await r.cleanup(),delete n[B],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:jt(o),controller:n}}))))}function qt(){if(globalThis.sniceNativeControllersInitialized)return;function e(e){if(!(e instanceof HTMLElement))return;if(!e.tagName||e.tagName.includes("-"))return;if(e[a])return;if(e[O])return void It(e);const t=e.getAttribute("controller"),n=e[C];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[C],delete e[S],void Vt(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[C]=t,e.ready||(e.ready=Promise.resolve()),n&&Vt(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),Dt(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):Rt(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 Bt=Symbol.for("snice:html-result"),Ft=Symbol.for("snice:css-result"),Wt=new WeakMap;function zt(e){return e&&e._$litType$===Bt}function Ut(e){return e&&e._$litType$===Ft}const Ht=Symbol.for("snice:nothing"),Kt=Symbol.for("snice:unsafe-html");function Gt(e){return e&&e._$litType$===Kt}const Qt=Symbol.for("snice:repeat-result"),Jt=new WeakSet;function Xt(e){return e[b]||e.shadowRoot||null}function Yt(e){const t=Xt(e);if(t)return t;const n=e.constructor[v];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[b]=o,Jt.add(e),o}function Zt(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&Jt.has(n))return n;n=n.parentNode}return null}const en=/^[a-z][a-z0-9._-]{0,127}$/,tn=/^[A-Za-z_$][A-Za-z0-9_$]{0,127}$/,nn=Symbol("ambiguous-render-host-identity"),on=new WeakMap;function rn(e,t){try{if("function"!=typeof e||!en.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=tn.test(s)?s:"",a=Object.freeze({label:i?`<${t}> (${i})`:`<${t}>`}),c=[on.get(e),on.get(o)].filter(e=>void 0!==e),l=c.some(e=>e===nn||e.label!==a.label)?nn:c[0]??a;on.set(e,l),on.set(o,l)}catch{}}class sn 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 sn&&t.belongsTo(e))return t;const n=t instanceof Error?t.message:String(t),o=new sn(e,`snice: render failed for ${e.label}: ${n}`,t);return t instanceof Error&&(o.name=t.name),o}const cn=`snice$${Math.random().toFixed(9).slice(2)}$`,ln="?"+cn,un=`\x3c!--${ln}--\x3e`,hn=new RegExp(cn.replace(/\$/g,"\\$"),"g"),dn=new WeakMap,fn=Symbol("not-committed"),mn=new WeakMap;function pn(e,t){return Object.prototype.isPrototypeOf.call(t.prototype,e)}function yn(e,t){const n=e.localName,o=n&&t?.get(n);if(!o||!pn(e,o))return;const r=e,s=r[I];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[I]}}function gn(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(pn(e,r))return!1;const n=r[L];if(!n?.has(t))return!1}const s=e;return s[I]||(s[I]=new Set),s[I].add(t),function(e,t){if(!t?.whenDefined||mn.get(e)===t)return;mn.set(e,t);const n=new WeakRef(e);t.whenDefined(e.localName).then(()=>{const e=n.deref();e&&yn(e,t)})}(e,n),!0}(e,t,o)?e[t]=n:Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n})}const bn=Symbol.for("snice:no-change"),vn=Symbol.for("snice:live"),wn=e=>null===e||"object"!=typeof e&&"function"!=typeof e,En=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class Nn{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(cn))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(cn))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(cn))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(cn))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(cn)&&(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(cn)){o.push(i);const t=n[r]||i.name,s=a.split(cn),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===ln){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(cn)){const t=e.data.split(hn);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(cn)){const n=e.parentNode,o=t.split(hn),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 Sn(e){const{strings:t}=e,n=dn.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(cn);else if(i)r.push(l),o.push(cn);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(cn)}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="${cn}"`)}}else r.push(""),o.push(un)}}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 Nn(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 dn.set(t,d),d}class Tn{#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=Sn(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 Cn(e,r,this.#t,this.#n);break;case"attribute":const i=n.get(t.element);o=new _n(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new Ln(a,t.name,this.#n);break;case"boolean-attribute":const c=n.get(t.element);o=new Rn(c,t.name);break;case"event":const l=n.get(t.element);o=new jn(l,t.name);break;case"class":const u=n.get(t.element);o=new xn(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 $n(d,t.name,this.#n);break;case"controller":const f=n.get(t.element);o=new Pn(f);break;case"conditional-if":const m=n.get(t.element);o=new In(m);break;case"conditional-else-if":const p=n.get(t.element);o=new Vn(p);break;case"conditional-case":const y=n.get(t.element);o=new qn(y,s);break;case"conditional-when":const g=n.get(t.element);o=new Fn(g);break;case"comment":const b=n.get(t.startNode);o=new On(b,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof In||o instanceof Vn||o instanceof qn||o instanceof Fn?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 Vn||e instanceof Fn?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof In||n instanceof qn)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof _n&&void 0!==t.strings||t instanceof On?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 An{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 Cn extends An{#t;#n;constructor(e,t,n=null,o=null){super(),this.type="node",this._committedValue=fn,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!==bn)if((e=>!!e&&"function"==typeof e.then)(e)||En(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==Ht&&null!=e&&""!==e)wn(e)?e!==this._committedValue&&this._commitText(e):zt(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===Qt}(e)?0===e.values.length?this.commit(e.empty??Ht):this._commitIterable(e.values,e.keys):Gt(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!==Ht){const e=this._clear();if(this._committedValue=Ht,e)throw e}this._committedValue=Ht}}_commitText(e){if(this._committedValue!==fn&&this._committedValue!==Ht&&wn(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 Tn){const n=dn.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new Tn(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(!zt(e))return;let n;try{n=Sn(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 Cn||(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 Cn(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 Cn(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(Gt(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=Ht,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(En(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=Ht,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=Ht,n}_disposeCommitted(e){let t;if(e instanceof Tn)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof Cn)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 Tn)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof Cn)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 Tn)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof Cn)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class _n extends An{constructor(e,t,n){super(),this.type="attribute",this._committedValue=fn,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(fn),this.strings=n):this._committedValue=fn}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===bn)return;if(o=!wn(e)||e!==this._committedValue&&e!==bn,!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===bn&&(i=s[e],i===fn&&(i="")),o=o||!wn(i)||i!==s[e],i===Ht?n=Ht:n!==Ht&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===Ht?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class On extends An{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(fn)}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===bn&&(s=this._committedValues[e],s===fn&&(s="")),o=o||!wn(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===Ht?"":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 xn extends An{constructor(e,t){super(),this.type="class",this.committed=fn,this.element=e,this.name=t}commit(e){if(e===bn)return;const t=e!==Ht&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=fn}}class kn extends An{constructor(e,t){super(),this.type="style",this.committed=fn,this.element=e,this.name=t}commit(e){if(e===bn||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===Ht||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=fn}}class $n extends An{#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===bn)return;if(e!==Ht&&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)||gn(this.element,t,void 0,this.#n);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||gn(this.element,t,n===Ht?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===Ht||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!==Ht&&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===Ht||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 Zt(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||yn(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 Ln extends An{#n;constructor(e,t,n=null){super(),this.type="property",this._committedValue=fn,this.element=e,this.name=t,this.#n=n}commit(e){if(e!==bn){if(function(e){return e&&e._$liveMarker$===vn}(e)){if((e=e.value)===bn)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,gn(this.element,this.name,e===Ht?void 0:e,this.#n)}}reconnected(){yn(this.element,this.#n)}clear(){this._committedValue=fn}}class Pn extends An{constructor(e){super(),this.type="controller",this._committedValue=fn,this.element=e}commit(e){if(e===bn)return;const t=null==e||!1===e||""===e||e===Ht?null:e,n=this._committedValue===fn,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[k]?delete r[k]:r[a]?r.controller=null:this._detach()),"function"==typeof t?this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[a]&&(r[k]=t):"string"==typeof t?this.element.setAttribute("controller",t):"string"==typeof o&&this.element.removeAttribute("controller")}_apply(e){const t=this.element;t[a]?t.controller!==e?t.controller=e:this._attach(e):this.element.localName.includes("-")?t[k]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){Dt(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){Vt(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[k]&&(t[a]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[k]&&delete e[k];const t=this._committedValue;this._committedValue=fn,"function"==typeof t&&(e[a]||this._detach())}}class Rn extends An{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=fn,this.element=e,this.name=t}commit(e){if(e===bn)return;const t=!!e&&e!==Ht;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=fn}}class jn extends An{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=bt(t)}else this.eventName=n,gt(n)}commit(e){if(e===bn)return;e===Ht&&(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&&!wt(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=Zt(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 Mn=Symbol("not-set");class In extends An{constructor(e){super(),this.type="node",this.conditions=[Mn],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]=Mn,Dn.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!==bn&&(this.conditions[0]=e)}setAlternative(e,t){t!==bn&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==Mn&&this.conditions[t]!==Ht&&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 Dn=new WeakMap;class Vn extends An{constructor(e){super(),this.type="node";const t=Dn.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 qn extends An{constructor(e,t){super(),this.type="node",this.value=Mn,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?Mn:n.getAttribute("value")??""})-1;o&&Bn.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:Mn})-1}}n.removeChild(e)}commit(e){e!==bn&&(this.value=e)}setExpected(e,t){t!==bn&&(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 Bn=new WeakMap;class Fn extends An{constructor(e){super(),this.type="node";const t=Bn.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 Wn=new WeakSet,zn=new WeakSet,Un=["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 Hn(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 Kn(e){return e?Array.from(e.querySelectorAll("[autofocus]")).filter(e=>!zn.has(e)):[]}function Gn(e){return e?Array.from(e.querySelectorAll(Un)):[]}function Qn(e){if(Wn.has(e)||!function(e){return!(!e.hasAttribute("autofocus")||zn.has(e))||Kn(Xt(e)).length>0}(e))return;Wn.add(e);const t=()=>{const t=e.ownerDocument.defaultView,n=()=>{Wn.delete(e),function(e){if(!e.isConnected)return;const t=Xt(e),n=[];if(e.hasAttribute("autofocus")&&!zn.has(e)&&n.push(e),n.push(...Kn(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)zn.add(e);else for(const o of n){if(zn.add(o),Hn(o))return;if(o===e)for(const e of Gn(t))if(Hn(e))return}}(e)};t?.requestAnimationFrame?t.requestAnimationFrame(n):queueMicrotask(n)};Promise.resolve(e.ready).then(t,t)}let Jn=!1;function Xn(e){e[p]||(e[m]=new Promise(t=>{e[p]=t}))}function Yn(e){const t=e[p];t&&(e[p]=null,t())}const Zn=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?oo(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?oo(t,t[te]||{}):t[y]=!0}remove(e){this.pending.delete(e)}};function eo(e){return Object.prototype.hasOwnProperty.call(e,ne)}function to(e){const t=e[re];if(!t||0===t.length)return;const n=[...t];e[re]=[],n.forEach(e=>e())}const no=50;function oo(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=on.get(t),s=on.get(o);return r!==nn&&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[ee];if(!i)return void Yn(e);if(t.once&&eo(e))return void Yn(e);const a=e[g]??0;if(a>=no){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${no}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void Yn(e)}e[g]=a+1;try{const a=s?n:i.call(e),c=Yt(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[ne];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[ne]=null,to(e),void Qn(e)}if(!zt(a))return void console.warn("Render method must return html`` template result");let l=e[ne];if(l&&l.isSameTemplate(a.strings))return r=l.getRenderHostIdentity()??o,l.update(a.values),to(e),void Qn(e);const u=c instanceof ShadowRoot?c.customElementRegistry??c.ownerDocument.defaultView?.customElements??null:c.ownerDocument.defaultView?.customElements??null,h=new Tn(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[ne]=h;try{l?.clear()}catch(e){m=e}if(to(e),Qn(e),m)throw m}catch(e){const t=an(r,e);if(Jn)throw t;console.error("Error rendering element:",t)}finally{e[g]=a,Yn(e)}}function ro(e,t=!1){const n=e[te]||{};if(n.once&&eo(e))e.isConnected&&so(e);else if(Xn(e),t)oo(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[oe]||(e[oe]={}),clearTimeout(e[oe].debounce),void(e[oe].debounce=setTimeout(()=>{e[oe].debounce=null,Zn.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[oe]||(e[oe]={lastThrottle:0});const t=e[oe],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void Zn.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),Zn.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}Zn.schedule(e,n)}}function so(e){const t=e[ne];t?.reconnected()}const io=n("debounce-timers"),ao=n("throttle-timers"),co=n("once-called"),lo=n("memoize-cache");function uo(e){if(e[io]){for(const t in e[io])e[io][t]?.timeout&&clearTimeout(e[io][t].timeout);e[io]={}}}function ho(e){if(e[ao]){for(const t in e[ao])e[ao][t]?.timeout&&clearTimeout(e[ao][t].timeout);e[ao]={}}}function fo(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 mo(e){e.prototype[a]=!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[L];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[u]||(this[u]=new Promise((e,t)=>{this[h]=e,this[d]=t}),this[u].catch(()=>{})),this[u]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[p]?this[m]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[w]},set(e){const t=this[w];if(this[w]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void Dt(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):Rt(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&Vt(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[u]||(this[u]=new Promise((e,t)=>{this[h]=e,this[d]=t}),this[u].catch(()=>{})),this[E]){try{so(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}At(this,this),mt(this,this),$t(this,"task");try{Ze(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[H];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[ee]&&this[y]&&(this[y]=!1,ro(this)),void Qn(this)}this[D]=!0;const n=e[L];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);We(this,q).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[k]){const e=this[k];if(delete this[k],!this[w]){this[w]=e;const t=e?.name||"(anonymous controller class)";Dt(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[w]){const e=this.getAttribute("controller");e&&(this.controller=e)}if(function(e){const t=e[se],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)Ut(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[ie]){e[ie]=!0;try{const o=[...n],r=e[ae];if(r)for(const t of r){const n=t.call(e);Ut(n)&&o.push(n)}if(t){const n=t.call(e);if(!Ut(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=Yt(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[ee])try{Yt(this)}catch{}At(this,this),mt(this,this),$t(this,"task"),this[E]=!0,function(e,t){if(Xe.has(t))return;Xe.add(t);const n=t[V];if(!n||0===n.size)return;const o=t[L],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[V],o=t[L];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[z];if(await new Promise(e=>queueMicrotask(e)),!this.isConnected)return void(this[h]&&(this[h](),this[h]=null,this[d]=null));this[ee]&&ro(this,!0);try{Ze(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[d]=null));let r,s=!1;if(o){this[f]=!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[f]}}s&&this[d]?(this[d](r),this[h]=null,this[d]=null):this[h]&&(this[h](),this[h]=null,this[d]=null),Qn(this)},e.prototype.disconnectedCallback=async function(){xt(this);try{!function(e){const t=e[ne];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[U];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[w]&&Vt(this).catch(e=>{console.error("Failed to detach controller:",e)}),Ct(this),pt(this),Lt(this),rt(this),uo(this),ho(this),function(e){const t=e[oe];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[y]=!0),Eo(this,X),Eo(this,Y)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t){if(s=r,s?.includes(cn))return;if(this[x])return;return this[O]?void It(this):void(this.controller=r)}var s;"autofocus"===t&&(null===r?zn.delete(this):this[E]&&Qn(this));const i=e[L];if(i)for(const[n,o]of i){if(Fe(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[J]?.has(t.toLowerCase()))break;const s=this[P]?.[n],i=this[R]?.[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;We(this,q).add(n),ze(this,P)[n]=a,this[E]&&Ue(this,e,n,s,a),this[ee]&&this[E]&&ro(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[K];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[G];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function po(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[L]){e[L]||(e[L]=new Map);for(const[n,o]of t[L])e[L].has(n)||e[L].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[L]){t[L]||(t[L]=new Map);for(const[e,o]of n.metadata[L])t[L].set(e,o)}else if(yo.length>0){t[L]||(t[L]=new Map);const e=yo.pop();for(const[n,o]of e)t[L].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[v]||{}},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[v]=i,!0===t.prototype[ce]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,ee)&&"function"==typeof t.prototype.render&&(t.prototype[ee]=t.prototype.render,t.prototype[te]=t.renderOptions||{}),mo(t);const a=customElements.get(e);return a?(a===t&&rn(t,e),globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),rn(t,e),t)}const yo=[],go=new WeakMap;function bo(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[L]||(n.metadata[L]=new Map),n.metadata[L].set(o,e||{})):(0===yo.length&&yo.push(new Map),yo[yo.length-1].set(o,e||{})),function(t){const n=this[I],r=!0===n?.delete(o);0===n?.size&&delete this[I];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=go.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);go.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[L]||(c[L]=new Map);const l={...e};l.type||void 0===t||(l.type=Ve(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[L].set(o,l),ze(this,R)[o]=t;const u=()=>{if(!this[D])return;const e=this[P]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=Fe(l,o),r=Je(e,l,t),s=n.toLowerCase();We(this,J).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[J].delete(s)}}this[E]&&(Ue(this,this.constructor,o,e,e),this[ee]&&ro(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=fo(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=fo(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=fo(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[P]?.[o]===t&&u()}),t};ze(this,j)[o]=h;const d=this.constructor.prototype;let f=d[$e];f&&Object.prototype.hasOwnProperty.call(d,$e)||(f=new Map(f),d[$e]=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[P]&&o in this[P]?this[P][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[D])return this[M]||(this[M]=new Map),void this[M].set(o,n);if(ze(this,P)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=Fe(l,o),t=Je(n,l,this[R]?.[o]);We(this,q).add(o);const r=e.toLowerCase();We(this,J).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[J].delete(r)}}this[E]&&(Ue(this,this.constructor,o,t,n),this[ee]&&ro(this))},configurable:!0,enumerable:!0}));const p=h(t);return ze(this,P)[o]=p,ze(this,R)[o]=p,i?a:p}}}function vo(e){return!0===e[r]&&e.element?e.element:e}function wo(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 Eo(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 No(e,t,n){return function(o={}){return function(r,s){wo(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 So=No(K,X,_e),To=No(G,Y,Oe);class Ao extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[v];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return ro(this),this.rendered}renderNow(){return Xn(this),oo(this,{...this[te]||{},once:!1}),this.rendered}}Object.defineProperty(Ao.prototype,ce,{value:!0});class Co{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 _o(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 Oo(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 xo(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 ko(e){if(!lt(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=ut(e);if(0===t.bindings){t.active=!0;try{At(e,t.target),mt(e,t.target)}catch(n){throw pt(e),Ct(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&&(pt(e),Ct(e),xt(e),t.active=!1,t.target=new EventTarget))}}function $o(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(it.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(st,r),it.set(e,{listener:r});let s=!1;return()=>{if(s)return;s=!0;const t=it.get(e);t?.listener===r&&(e.removeEventListener(st,r),it.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(ko(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?.())}}const Lo=/=:[\w-]+\)?$/;function Po(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 Ro(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)||Po(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("=")&&Lo.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 jo=new WeakMap;var Mo;!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(Mo||(Mo={}));let Io=!1;async function Do(e,t=500){if(customElements.get(e))return;let n=null;Io||(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 Vo(e,t=500){const n=e.tagName.toLowerCase();await Do(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}let qo=0,Bo=null;const Fo=Symbol.for("snice:body-scroll-lock");var Wo;return globalThis[Fo]={clear(){qo=0,Bo=null}},"undefined"!=typeof document&&qt(),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"}(Wo||(Wo={})),e.Context=De,e.ContextAwareFetcher=class{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)}},e.IS_CONTROLLER_INSTANCE=r,e.Router=function(t){const n=t.window??window,o=t.document??document,r=[];let s,i,a,c=0,l=!1,u=[],h=null,d=null;const f=t.context||{};let m=null,p=null;const y=new De(f,[],"",{},t.fetcher);function g(e){if(m===e&&p&&jo.get(e)===p)return;p?.(),jo.get(e)?.();const t=$o(e,(n=y).application,{fetch:n.fetch},n);var n;let o=!1;const r=()=>{o||(o=!0,t(),jo.get(e)===r&&jo.delete(e))};p=r,m=e,jo.set(e,r)}function b(e){if(!h||!d)return null;const t=e.querySelectorAll(h);for(const e of t)if(e[W]===d)return e;return null}function v(e,t,n,o,u,h,d=0){if(!Number.isFinite(d))throw new TypeError(`Route order for "${e}" must be a finite number.`);switch(r.push({route:new Co(e),tag:t,transition:n,guards:o,layout:u,placard:h,order:d,registrationOrder:c++}),l=!1,e){case"/404":s=t;break;case"/403":i=t;break;case"/":a=t}}function w(){const e=new Set;u=r.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(f):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function E(e,t,n){y[be](f,u,t,n)}function N(){switch(t.type){case"hash":return n.location.hash.slice(1);case"pushstate":return`${n.location.pathname}${n.location.search}`}}function S(e){let t;if(i)t=o.createElement(i),t[B]=f;else{const e=o.createElement("div");e.className="default-403",e.innerHTML="<h1>403</h1><p>Unauthorized</p>",t=e}e.innerHTML="",e.appendChild(t),h=null,d=null}async function T(e,t,n,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=o.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}(),n.appendChild(i))},50);try{for(const e of s)if(!await e(f,t))return r&&r()||S(n),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function A(e,n,r,s,i,a,c){const l=!1===(m=s)?null:m||(t.layout?t.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();d=t;const n=o.createElement(e);return n[B]=f,n[W]=t,{element:n,needsNewLayout:!0}}return d=null,{element:null,needsNewLayout:!0}}(l),g=r||t.transition;if(null!==p||null!==b(e)){if(await async function(e,t,n,o,r,s,i,a){const c=o||b(e);if(!c)return;!function(e,t,n){"function"==typeof e.update&&e.update(f,u,t,n)}(c,s,i);const l=c.querySelector('[slot="page"]');if(n&&l){if(t.setAttribute("slot","page"),await O(c,l,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)))}(e,n,g,p,y,i,a,c),c&&c())return;E(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))}(e,n,g,c),c&&c()||E(0,i,a)}let C=0;async function _(e){const i=o.querySelector(t.target);if(!i)throw new Error(`Target element not found: ${t.target}`);g(i);const c=++C,l=()=>c!==C;if(w(),n.scrollTo(0,0),(""===e?.trim()||"/"===e)&&a){const t=r.find(e=>e.route.match("/"));if(!await T(t?.guards,{},i,l))return;if(l())return;const{element:s,transition:c,layout:u}=function(){const e=o.createElement(a);e[B]=f;const t=n.customElements.get(a),s=t?.[F],i=r.find(e=>e.route.match("/"));return{element:e,transition:s,layout:i?.layout}}();return void await A(i,s,c,u,e,{},l)}if(!e)return;const u=await async function(e,t,n){for(const s of r){const r=Ro(s.route,e);if(!1===r)continue;if(!await T(s.guards,r,t,n))return{result:Mo.GUARDS_FAILED};const i=o.createElement(s.tag);i[B]=f,i[le]=y;const a=r;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:Mo.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:Mo.NOT_FOUND}}(e,i,l);if(l())return;if(u.result===Mo.GUARDS_FAILED)return;if(u.result===Mo.SUCCESS){const{element:t,transition:n,layout:o,routeParams:r={}}=u;return void await A(i,t,n,o,e,r,l)}const{element:h,transition:d,layout:m}=function(){if(s){const e=o.createElement(s);e[B]=f;const t=n.customElements.get(s),r=t?.[F];return{element:e,transition:r,layout:void 0}}const e=o.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 A(i,h,d,m,e,{},l)}async function O(t,n,o,r,s=C){return async function(t,n,o,r={},s=()=>!1){const i=r.outDuration??300,a=r.inDuration??300,c=r.mode||"sequential",l=r.out?Oo(r.out):{opacity:"0"},u={opacity:"0"},h=r.in?Oo(r.in):{opacity:"1"},d=t.style,f=t.tagName.includes("-")&&t.shadowRoot,m=Symbol.for("snice:transition-original-position"),p=Symbol.for("snice:transition-count"),y=t;f||(m in y||(y[m]=d.position,y[p]=0),y[p]++,d.position="relative");const g=()=>{f||(y[p]--,y[p]<=0&&(d.position=y[m],delete y[m],delete y[p]))},b=n.hasAttribute("slot")||o.hasAttribute("slot");switch(xo(n,b,i,"all"),xo(o,b,a,"all"),Object.assign(o.style,u),t.appendChild(o),c){case e.TransitionMode.SIMULTANEOUS:Object.assign(n.style,l),Object.assign(o.style,h),await new Promise(e=>setTimeout(e,Math.max(i,a)));break;case e.TransitionMode.SEQUENTIAL:if(Object.assign(n.style,l),await new Promise(e=>setTimeout(e,i)),s())return o.parentNode===t&&o.remove(),void g();Object.assign(o.style,h),await new Promise(e=>setTimeout(e,a))}if(s())return o.parentNode===t&&o.remove(),void g();n.remove(),function(e,t){e.style.position="",e.style.width="",e.style.transition="",t?e.style.height="":(e.style.top="",e.style.left="")}(o,b),Object.keys({...u,...h}).forEach(e=>{o.style[e]=""}),g()}(t,n,o,r,()=>s!==C)}return{page:function(e){return function(t,o){if(o?.metadata&&o.metadata[L]){t[L]||(t[L]=new Map);for(const[e,n]of o.metadata[L])t[L].set(e,n)}mo(t),t[F]=e.transition;const r=t.prototype.connectedCallback;t.prototype.connectedCallback=function(){void 0!==this[B]&&(this[le]=y),r?.call(this)};const s=t.prototype.disconnectedCallback;t.prototype.disconnectedCallback=function(){s?.call(this),delete this[B],delete this[le]};const i=n.customElements.get(e.tag);return i?i===t&&rn(t,e.tag):(n.customElements.define(e.tag,t),rn(t,e.tag)),e.routes.forEach(t=>{v("string"==typeof t?t:t.path,e.tag,e.transition,e.guards,e.layout,e.placard,"string"==typeof t?void 0:t.order)}),t}},initialize:function(){const e=o.querySelector(t.target);if(!e)throw new Error(`Target element not found: ${t.target}`);g(e),!l&&(r.sort((e,t)=>_o(t.route.spec)-_o(e.route.spec)||e.order-t.order||e.registrationOrder-t.registrationOrder),l=!0),w(),function(){const e=()=>{const e=o.querySelector(t.target);if(e&&(m!==e||!p||jo.get(e)===p))return m!==e&&it.has(e)?(p?.(),p=null,void(m=null)):void _(N())};switch(t.type){case"hash":n.addEventListener("hashchange",e);break;case"pushstate":n.addEventListener("popstate",e)}}(),_(N())},navigate:async function(e){const o=function(e){const t=e.trim().replace(/^#/,"");return t?t.startsWith("/")?t:`/${t}`:"/"}(e);!function(e){switch(t.type){case"hash":{const t=`#${e}`;n.location.hash!==t&&n.history.pushState(null,"",t);break}case"pushstate":`${n.location.pathname}${n.location.search}`!==e&&n.history.pushState(null,"",e)}}(o),await _(o)},register:v}},e.SimpleArray=Le,e.SniceElement=Ao,e.adopted=To,e.applyElementFunctionality=mo,e.attachController=Dt,e.classMap=function(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t},e.clearDebounceTimers=uo,e.clearMemoizeCache=function(e,t){e[lo]&&(t?delete e[lo][t]:e[lo]={})},e.clearThrottleTimers=ho,e.context=function(e={}){return function(t,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,ve)||(n[ve]=new Set),!n[ve].has(t)){if(n[ve].add(t),!Object.prototype.hasOwnProperty.call(n,kt)){const e=n[kt];n[kt]=e?[...e]:[]}n[kt].push({methodName:o,method:t,options:e})}}),t}},e.contextProperty=function(){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[B])return this[B];const e=ct(this);return void 0!==e?e:void 0},set(){},configurable:!0,enumerable:!0}),e}}},e.controller=function(e){return function(n,r){const s=globalThis.snice?.controllerRegistry;if(!s)throw new Error("Snice global registry not initialized");s.set(e,n),n.prototype[o]=!0,Object.defineProperty(n,_,{value:e,configurable:!0});const i=t.pendingControllerAttachments.get(e);return i&&(t.pendingControllerAttachments.delete(e),queueMicrotask(()=>{for(const t of i){const n=t[C];(void 0===n?t[w]:n)===e&&Dt(t,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e}":`,t)})}})),n}},e.createRequestHandler=function(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}},e.css=function(e,...t){const n=0===t.length?Wt.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+=(Ut(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:Ft,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&&Wt.set(e,r),r},e.daemon=function(e,t){Object.defineProperty(e.prototype,s,{value:!0,configurable:!0})},e.debounce=function(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[io]||(this[io]={});const a=this[io],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}}}},e.detachController=Vt,e.dispatch=function(e,t){return function(n,o){const r=Symbol(`@dispatch:${e}`);return function(...o){const s=this[_t]??0;this[Z]||(this[Z]=new Map),this[Z].has(r)||this[Z].set(r,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null,invocation:0});const i=this[Z].get(r),a=Ge(this,t?.debounce,"@dispatch","debounce"),c=a&&a>0?void 0:Ge(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 ht(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=Qe(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=dt(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},d=e=>{if(!Ot(this,s))return;if(a&&a>0)return void(i.debounceTimeout=setTimeout(()=>{i.debounceTimeout=null,Ot(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,Ot(this,s)&&i.invocation===l&&h(e)},n)};return u instanceof Promise?u.then(e=>{const t=(a??0)>0||(c??0)>0;return!Ot(this,s)||t&&i.invocation!==l||d(e),e}):(d(u),u)}}},e.dispose=function(){return function(e,t){wo(U,Ae,e,t)}},e.element=function(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 po(e,n,o,t)}},e.escapeAttr=function(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")},e.escapeHtml=function(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},e.getBodyScrollLockCount=function(){return qo},e.getContext=ct,e.getContextFetch=function(e){const t=at(e);if(!t)return;const n={kind:"fetch"};return t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:n})),n.fetch},e.getController=function(e){return e[N]},e.getSymbol=n,e.html=function(e,...t){return{_$litType$:Bt,strings:e,values:t}},e.isSafeUrl=function(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}},e.layout=function(e){return function(t,n){return po(e,t,n)}},e.live=function(e){return{_$liveMarker$:vn,value:e}},e.lockBodyScroll=function(){0===qo&&(Bo=document.body.style.overflow,document.body.style.overflow="hidden"),qo++},e.memoize=function(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[lo]||(this[lo]={}),this[lo][s]||(this[lo][s]=new Map);const i=this[lo][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}}},e.moved=So,e.noChange=bn,e.nothing=Ht,e.observe=function(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,Ee)||(n[Ee]=new Set),n[Ee].has(t))return;if(n[Ee].add(t),!Object.prototype.hasOwnProperty.call(n,Q)){const e=n[Q];n[Q]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[Q].push({type:i,target:c,selector:o,methodName:s,method:t,options:r})}})}},e.on=function(e,t,n){let o=null,r={};"string"==typeof t?(o=t,r=n||{}):t&&"object"==typeof t?r=t:null===t&&n&&(r=n),!o&&r.target&&(o=r.target);const s=Array.isArray(e)?e:[e],i="site:"+ ++Nt;let a="",c=!1;for(const e of Object.keys(r).sort()){const t=r[e];void 0!==t&&(null===t||"object"!=typeof t&&"function"!=typeof t?a+=`${e}=${String(t)};`:c=!0)}const l=`${s.join(",")}::${o??""}::${a}${c?`::${i}`:""}`;return function(e,t){const n=t.name,i=`${n}::${l}`;return t.addInitializer(function(){const t=this.constructor;if(Object.prototype.hasOwnProperty.call(t,Ne)||(t[Ne]=new Set),!t[Ne].has(i)){if(t[Ne].add(i),!Object.prototype.hasOwnProperty.call(t,Et)){const e=t[Et];t[Et]=e?[...e]:[]}for(const i of s)t[Et].push({eventName:i,selector:o,methodName:n,method:e,options:r})}}),e}},e.once=function(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)}}},e.parseDuration=function(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}},e.property=bo,e.provideContext=function(e,t,n={}){return $o(e,t,n)},e.query=function(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=vo(this);let n=null;const o=t instanceof HTMLElement?Xt(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}}},e.queryAll=function(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=vo(this),n=new Set,o=t instanceof HTMLElement?Xt(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}}},e.ready=function(){return function(e,t){wo(z,Te,e,t)}},e.reconnect=function(){return function(e,t){wo(H,Ce,e,t)}},e.render=function(e={}){return function(t,n){return n.addInitializer(function(){this[ee]=t,this[te]=e}),function(...n){const o=t.apply(this,n);return oo(this,{...this[te]||e,once:!1},o),o}}},e.repeat=function(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$:Qt,items:n,keys:o,values:n.map(t.render),empty:0===n.length?"function"==typeof t.empty?t.empty():t.empty:void 0}},e.request=function(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?ht(this,t.daemon):dt(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)})}}},e.resetOnce=function(e,t){e[co]&&(t?delete e[co][t]:e[co]={})},e.respond=function(e,t){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,Se)||(o[Se]=new Set),!o[Se].has(n)){if(o[Se].add(n),!Object.prototype.hasOwnProperty.call(o,c)){const e=o[c];o[c]=e?[...e]:[]}o[c].push({channelName:e,methodName:r,method:n,options:t})}})}},e.setDisableElementReadyWarnings=function(e){Io=e},e.setStrictRenderErrors=function(e){Jn=e},e.state=function(e={}){return bo({...e,attribute:!1,reflect:!1})},e.styleMap=function(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("; ")},e.styles=function(){return function(e,t){return t.addInitializer(function(){this[se]&&!this[ae]?this[ae]=[this[se]]:this[se]&&this[ae]&&this[ae].push(this[se]),this[se]=e}),e}},e.svg=function(e,...t){return{_$litType$:Bt,strings:e,values:t,svg:!0}},e.throttle=function(e=300,t={}){const{leading:n=!0,trailing:o=!0}=t;return function(t,r){const s=r.name;return function(...r){this[ao]||(this[ao]={});const i=this[ao],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))}}},e.trackRenders=async function*(e){for(;;)await new Promise(t=>{e[re]||(e[re]=[]),e[re].push(t)}),yield},e.unlockBodyScroll=function(){0!==qo&&(qo--,0===qo&&(document.body.style.overflow=Bo??"",Bo=null))},e.unsafeHTML=function(e){return{_$litType$:Kt,html:e}},e.useNativeElementControllers=qt,e.waitForAllCustomElements=async function(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=>Vo(e,t)))},e.waitForElementDefined=Do,e.waitForElementReady=Vo,e.watch=function(...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,we)||(n[we]=new Map);let s=n[we].get(e);if(s||(s=new Set,n[we].set(e,s)),!Object.prototype.hasOwnProperty.call(n,V)){const e=n[V],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[V]=t}for(const i of t)s.has(i)||(s.add(i),n[V].has(i)||n[V].set(i,[]),n[V].get(i).push({methodName:r,method:e,immediate:o}))})}},e}({});
2
2
  //# sourceMappingURL=snice-runtime.min.js.map