snice 7.1.0 → 7.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/adapters/react/SniceProvider.js +1 -1
- package/adapters/react/SniceRouter.js +1 -1
- package/adapters/react/matchRoute.js +1 -1
- package/adapters/react/useRequestHandler.js +1 -1
- package/dist/cdn/accordion/snice-accordion.js +1 -1
- package/dist/cdn/action-bar/snice-action-bar.js +1 -1
- package/dist/cdn/activity-feed/snice-activity-feed.js +1 -1
- package/dist/cdn/alert/snice-alert.js +1 -1
- package/dist/cdn/app-tiles/snice-app-tiles.js +1 -1
- package/dist/cdn/approval-flow/snice-approval-flow.js +1 -1
- package/dist/cdn/audio-recorder/snice-audio-recorder.js +1 -1
- package/dist/cdn/availability/snice-availability.js +1 -1
- package/dist/cdn/avatar/snice-avatar.js +1 -1
- package/dist/cdn/avatar-group/snice-avatar-group.js +1 -1
- package/dist/cdn/badge/snice-badge.js +1 -1
- package/dist/cdn/banner/snice-banner.js +1 -1
- package/dist/cdn/binpack/snice-binpack.js +1 -1
- package/dist/cdn/book/snice-book.js +1 -1
- package/dist/cdn/booking/snice-booking.js +1 -1
- package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +1 -1
- package/dist/cdn/button/snice-button.js +1 -1
- package/dist/cdn/calendar/snice-calendar.js +1 -1
- package/dist/cdn/camera/snice-camera.js +1 -1
- package/dist/cdn/camera-annotate/snice-camera-annotate.js +1 -1
- package/dist/cdn/candlestick/snice-candlestick.js +1 -1
- package/dist/cdn/card/snice-card.js +1 -1
- package/dist/cdn/carousel/snice-carousel.js +1 -1
- package/dist/cdn/cart/snice-cart.js +1 -1
- package/dist/cdn/chart/snice-chart.js +1 -1
- package/dist/cdn/chat/snice-chat.js +1 -1
- package/dist/cdn/checkbox/snice-checkbox.js +1 -1
- package/dist/cdn/chip/snice-chip.js +1 -1
- package/dist/cdn/code-block/snice-code-block.js +1 -1
- package/dist/cdn/color-display/snice-color-display.js +1 -1
- package/dist/cdn/color-picker/snice-color-picker.js +1 -1
- package/dist/cdn/command-palette/snice-command-palette.js +1 -1
- package/dist/cdn/comments/snice-comments.js +1 -1
- package/dist/cdn/countdown/snice-countdown.js +1 -1
- package/dist/cdn/cropper/snice-cropper.js +1 -1
- package/dist/cdn/data-card/snice-data-card.js +1 -1
- package/dist/cdn/date-picker/snice-date-picker.js +1 -1
- package/dist/cdn/date-range-picker/snice-date-range-picker.js +1 -1
- package/dist/cdn/date-time-picker/snice-date-time-picker.js +1 -1
- package/dist/cdn/diff/snice-diff.js +1 -1
- package/dist/cdn/divider/snice-divider.js +1 -1
- package/dist/cdn/doc/snice-doc.js +1 -1
- package/dist/cdn/draw/snice-draw.js +1 -1
- package/dist/cdn/drawer/snice-drawer.js +1 -1
- package/dist/cdn/empty-state/snice-empty-state.js +1 -1
- package/dist/cdn/estimate/snice-estimate.js +1 -1
- package/dist/cdn/file-gallery/snice-file-gallery.js +1 -1
- package/dist/cdn/file-upload/snice-file-upload.js +1 -1
- package/dist/cdn/flip-card/snice-flip-card.js +1 -1
- package/dist/cdn/flow/snice-flow.js +1 -1
- package/dist/cdn/form-layout/snice-form-layout.js +1 -1
- package/dist/cdn/funnel/snice-funnel.js +1 -1
- package/dist/cdn/gantt/snice-gantt.js +1 -1
- package/dist/cdn/gauge/snice-gauge.js +1 -1
- package/dist/cdn/grid/snice-grid.js +1 -1
- package/dist/cdn/heatmap/snice-heatmap.js +1 -1
- package/dist/cdn/image/snice-image.js +1 -1
- package/dist/cdn/input/snice-input.js +1 -1
- package/dist/cdn/invoice/snice-invoice.js +1 -1
- package/dist/cdn/kanban/snice-kanban.js +1 -1
- package/dist/cdn/key-value/snice-key-value.js +1 -1
- package/dist/cdn/kpi/snice-kpi.js +1 -1
- package/dist/cdn/layout/snice-layout.js +1 -1
- package/dist/cdn/leaderboard/snice-leaderboard.js +1 -1
- package/dist/cdn/link/snice-link.js +1 -1
- package/dist/cdn/link-preview/snice-link-preview.js +1 -1
- package/dist/cdn/list/snice-list.js +1 -1
- package/dist/cdn/location/snice-location.js +1 -1
- package/dist/cdn/login/snice-login.js +1 -1
- package/dist/cdn/map/snice-map.js +1 -1
- package/dist/cdn/markdown/snice-markdown.js +1 -1
- package/dist/cdn/masonry/snice-masonry.js +1 -1
- package/dist/cdn/menu/snice-menu.js +1 -1
- package/dist/cdn/message-strip/snice-message-strip.js +1 -1
- package/dist/cdn/modal/snice-modal.js +1 -1
- package/dist/cdn/music-player/snice-music-player.js +1 -1
- package/dist/cdn/nav/snice-nav.js +1 -1
- package/dist/cdn/network-graph/snice-network-graph.js +1 -1
- package/dist/cdn/notification-center/snice-notification-center.js +1 -1
- package/dist/cdn/order-tracker/snice-order-tracker.js +1 -1
- package/dist/cdn/org-chart/snice-org-chart.js +1 -1
- package/dist/cdn/pagination/snice-pagination.js +1 -1
- package/dist/cdn/paint/snice-paint.js +1 -1
- package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +1 -1
- package/dist/cdn/permission-matrix/snice-permission-matrix.js +1 -1
- package/dist/cdn/podcast-player/snice-podcast-player.js +1 -1
- package/dist/cdn/popover/snice-popover.js +1 -1
- package/dist/cdn/pricing-table/snice-pricing-table.js +1 -1
- package/dist/cdn/product-card/snice-product-card.js +1 -1
- package/dist/cdn/progress/snice-progress.js +1 -1
- package/dist/cdn/progress-ring/snice-progress-ring.js +1 -1
- package/dist/cdn/qr-code/snice-qr-code.js +1 -1
- package/dist/cdn/qr-reader/snice-qr-reader.js +1 -1
- package/dist/cdn/radio/snice-radio.js +1 -1
- package/dist/cdn/range-slider/snice-range-slider.js +1 -1
- package/dist/cdn/rating/snice-rating.js +1 -1
- package/dist/cdn/receipt/snice-receipt.js +1 -1
- package/dist/cdn/recipe/snice-recipe.js +1 -1
- package/dist/cdn/runtime/README.md +2 -2
- package/dist/cdn/runtime/snice-runtime.esm.js +114 -15
- package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.js +114 -15
- package/dist/cdn/runtime/snice-runtime.js.map +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js +1 -1
- package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
- package/dist/cdn/sankey/snice-sankey.js +1 -1
- package/dist/cdn/segmented-control/snice-segmented-control.js +1 -1
- package/dist/cdn/select/snice-select.js +1 -1
- package/dist/cdn/skeleton/snice-skeleton.js +1 -1
- package/dist/cdn/slider/snice-slider.js +1 -1
- package/dist/cdn/sortable/snice-sortable.js +1 -1
- package/dist/cdn/sparkline/snice-sparkline.js +1 -1
- package/dist/cdn/spinner/snice-spinner.js +1 -1
- package/dist/cdn/split-button/snice-split-button.js +1 -1
- package/dist/cdn/split-pane/snice-split-pane.js +1 -1
- package/dist/cdn/spotlight/snice-spotlight.js +1 -1
- package/dist/cdn/stat-group/snice-stat-group.js +1 -1
- package/dist/cdn/step-input/snice-step-input.js +1 -1
- package/dist/cdn/stepper/snice-stepper.js +1 -1
- package/dist/cdn/switch/snice-switch.js +1 -1
- package/dist/cdn/table/snice-table.esm.js +1 -1
- package/dist/cdn/table/snice-table.js +1 -1
- package/dist/cdn/tabs/snice-tabs.js +1 -1
- package/dist/cdn/tag/snice-tag.js +1 -1
- package/dist/cdn/tag-input/snice-tag-input.js +1 -1
- package/dist/cdn/terminal/snice-terminal.js +1 -1
- package/dist/cdn/testimonial/snice-testimonial.js +1 -1
- package/dist/cdn/textarea/snice-textarea.js +1 -1
- package/dist/cdn/time-picker/snice-time-picker.js +1 -1
- package/dist/cdn/time-range-picker/snice-time-range-picker.js +1 -1
- package/dist/cdn/timeline/snice-timeline.js +1 -1
- package/dist/cdn/timer/snice-timer.js +1 -1
- package/dist/cdn/toast/snice-toast.js +1 -1
- package/dist/cdn/tooltip/snice-tooltip.js +1 -1
- package/dist/cdn/tree/snice-tree.js +1 -1
- package/dist/cdn/treemap/snice-treemap.js +1 -1
- package/dist/cdn/user-card/snice-user-card.js +1 -1
- package/dist/cdn/video-player/snice-video-player.js +1 -1
- package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +1 -1
- package/dist/cdn/waterfall/snice-waterfall.js +1 -1
- package/dist/cdn/weather/snice-weather.js +1 -1
- package/dist/cdn/work-order/snice-work-order.js +1 -1
- package/dist/controller.d.ts +5 -0
- package/dist/index.cjs +111 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.esm.js +111 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +111 -12
- package/dist/index.iife.js.map +1 -1
- package/dist/parts.d.ts +2 -2
- package/dist/react/SniceProvider.js +1 -1
- package/dist/react/SniceRouter.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/matchRoute.js +1 -1
- package/dist/react/useRequestHandler.js +1 -1
- package/dist/symbols.cjs +9 -1
- package/dist/symbols.cjs.map +1 -1
- package/dist/symbols.d.ts +2 -0
- package/dist/symbols.esm.js +8 -2
- package/dist/symbols.esm.js.map +1 -1
- package/dist/transitions.cjs +1 -1
- package/dist/transitions.esm.js +1 -1
- package/docs/ai/architecture.md +1 -1
- package/docs/ai/bindings.md +1 -1
- package/docs/ai/controllers.md +1 -1
- package/docs/ai/decorators.md +1 -1
- package/docs/ai/patterns.md +4 -3
- package/docs/bindings.md +1 -1
- package/docs/controllers.md +8 -2
- 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"),h=n("ready-promise"),u=n("ready-resolve"),d=n("rendered-promise"),f=n("rendered-resolve"),m=n("pending-reconnect-render"),p=n("render-depth"),y=n("render-root"),g=n("element-options"),v=n("controller"),b=n("initialized"),w=n("controller-key"),E=n("controller-name"),N=n("controller-id"),S=n("controller-operations"),T=n("native-controller"),A=n("direct-controller"),_=n("pending-controller-binding"),C=n("cleanup"),x=n("properties"),O=n("property-values"),k=n("property-defaults"),$=n("property-wrappers"),L=n("pre-init-property-values"),P=n("pre-upgrade-property-bindings"),j=n("properties-initialized"),M=n("property-watchers"),R=n("explicitly-set-properties"),I=n("router-context"),D=n("page-transition"),V=n("created-at"),q=n("ready-handlers"),B=n("dispose-handlers"),F=n("reconnect-handlers"),W=n("moved-handlers"),z=n("adopted-handlers"),U=n("observers"),H=n("setting-from-property"),K=n("moved-timers"),G=n("adopted-timers"),Q=n("dispatch-timers"),J=n("render-method"),X=n("render-options"),Y=n("render-instance"),Z=n("render-timers"),ee=n("render-callbacks"),te=n("styles-method"),ne=n("styles-applied"),oe=n("parent-styles-methods"),re=n("snice-element-base"),se=n("context-handler"),ie=n("navigation-context-instance"),ae=n("registered-elements"),ce=n("is-updating"),le=n("context-register"),he=n("context-unregister"),ue=n("context-notify-element"),de=n("context-timer"),fe=n("context-called"),me=n("context-update"),pe=n("context-methods"),ye=n("watch-methods"),ge=n("observe-methods"),ve=n("on-methods"),be=n("respond-methods"),we=n("ready-methods"),Ee=n("dispose-methods"),Ne=n("reconnect-methods"),Se=n("moved-methods"),Te=n("adopted-methods"),Ae=n("controller-abort"),_e=n("controller-attached"),Ce=n("property-definers");class xe{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes(xe.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${xe.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(xe.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split(xe.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var Oe,ke,$e;e.TransitionMode=void 0,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(e.TransitionMode||(e.TransitionMode={}));const Le=Symbol.for("snice:registered-elements-set");let Pe=0;class je{constructor(e={},t=[],n="",o={},r){if(this[Oe]=new WeakMap,this[ke]=new Set,this[$e]=!1,this.id=Pe++,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)}}[(Oe=ae,ke=Le,$e=ce,le)](e,t){const n=this[ae];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[Le].add(e)}[he](e,t){const n=this[ae];if(void 0!==t){const o=n.get(e);if(!o)return;if(o.delete(t),o.size>0)return}n.delete(e),this[Le].delete(e)}[me](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[ce])return;this[ce]=!0;const e=this[Le],t=this[ae];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[ce]=!1}[ue](e){const t=this[ae].get(e);if(t)for(const n of t)"function"==typeof e[n]&&e[n](this)}}function Me(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 Re(e,t,n,o){const r=t.type||Me(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 xe:return xe.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 Ie(e,t){return e!==t&&(e==e||t==t)}function De(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 Ve(e,t){return e[t]||(e[t]=new Set),e[t]}function qe(e,t){return e[t]||(e[t]={}),e[t]}function Be(e,t,n,o,r){const s=t[M];if(!s)return;const i=[n],a=t[x]?.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 Fe(e,t){let n=null;return function(...o){null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o),n=null},t)}}function We(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 ze(e,t){if(null==t)return e;if("global"===t)return"undefined"!=typeof document?document:null;if("function"==typeof t)try{return t.call(e)||null}catch{return null}return"string"==typeof t?e.closest?.(t)||null:t&&"function"==typeof t.addEventListener?t:null}function Ue(e,t,n){if(null==e||!1===e||t?.type===xe&&Array.isArray(e)&&0===e.length)return null;if(t.converter?.toAttribute)return t.converter.toAttribute(e,t.type);switch(t.type||Me(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 xe:return Array.isArray(e)?xe.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 He=new WeakSet,Ke=new Map;function Ge(e,t){const n=e.constructor[U];if(n&&Array.isArray(n)&&0!==n.length){e[C]?e[C].observers||(e[C].observers=[]):e[C]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?We(n,o.options.throttle):n;switch(o.type){case"intersection":Qe(e,t,o,r);break;case"resize":Je(e,t,o,r);break;case"media":Xe(e,0,o,r);break;case"mutation":Ye(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function Qe(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[C].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function Je(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[C].observers.push(()=>{s.disconnect()})}function Xe(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=Ke.get(r);if(!s)try{s=window.matchMedia(r),Ke.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[C].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[C].observers.push(()=>{s.removeListener(a)}))}function Ye(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),h=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)}}),u=!0===e[r];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):u&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{h.observe(e,c)}),e[C].observers.push(()=>{h.disconnect()})}function Ze(e){if(e[C]?.observers){for(const t of e[C].observers)t();e[C].observers=[]}}const et="@context/request",tt=new WeakMap;function nt(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=function(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}(e);if(t){const e={};if(t.dispatchEvent(new CustomEvent(et,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[I]?n[I]:!0===n[r]&&void 0!==n.element?.[I]?n.element[I]:void 0}function ot(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[s]}function rt(e){if(!ot(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 st(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=nt(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[r]?"controller":ot(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(!ot(o))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=rt(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 it(e){return ot(e)?function(e){return rt(e).target}(e):!0===e?.[r]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}function at(e,t){const n=e.constructor[c];if(n){e[C]||(e[C]={events:[],channels:[]});for(const o of n){const n=o.method.bind(e),r=`@request/${o.channelName}`;let s,i,a=0;const c=[];let l=null;const h=(e=>o.options?.debounce?(...t)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{n(await e(...t))}catch(e){r(e)}},o.options.debounce)}):o.options?.throttle?(...t)=>{const n=Date.now(),r=o.options.throttle-(n-a);if(r<=0){clearTimeout(i),i=null,a=n;const o=c.splice(0);l=null;const r=e(...t);return o.length&&Promise.resolve(r).then(e=>{for(const t of o)t.resolve(e)},e=>{for(const t of o)t.reject(e)}),r}return l=t,new Promise((n,o)=>{c.push({resolve:n,reject:o}),i||(i=setTimeout(async()=>{a=Date.now(),i=null;const n=c.splice(0),o=l??t;l=null;try{const t=await e(...o);for(const e of n)e.resolve(t)}catch(e){for(const t of n)t.reject(e)}},r))})}:e)(n),u=e=>{const{data:t,discovery:n,payload:r}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),Promise.resolve(h(r)).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${o.methodName}:`,e)})};let d=t;if(void 0!==o.options?.daemon)try{d=st(e,o.options.daemon)}catch(e){console.warn(`[snice/@respond] ${e.message} Responder "${o.channelName}" skipped.`);continue}d.addEventListener(r,u),e[C].channels.push(()=>{d.removeEventListener(r,u)})}}}function ct(e){if(e[C]?.channels){for(const t of e[C].channels)t();e[C].channels=[]}}const lt=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function ht(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();lt.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 ut(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=dt(e)}return o}function dt(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 ft(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 mt=n("on-handlers");function pt(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const yt=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function gt(e,t){const n=e.constructor[mt];if(n&&Array.isArray(n)&&0!==n.length){e[C]?e[C].events?e[C].events.length>0&&vt(e):e[C].events=[]:e[C]={events:[],channels:[],observers:[]};for(const o of n){const n=e[o.methodName];let r=n?n.bind(e):o.method.bind(e);const s=o.options||{},i=["keydown","keyup","keypress"].includes(o.eventName.split(".")[0].split(":")[0]),a=i?o.eventName.indexOf("."):-1,c=i?o.eventName.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c),h=l>0?o.eventName.substring(0,l):o.eventName,u=l>0?o.eventName.substring(l+1):null;l<=0&&ht(o.eventName),s.debounce&&s.debounce>0?r=Fe(r,s.debounce):s.throttle&&s.throttle>0&&(r=pt(r,s.throttle));let d=null;u&&["keydown","keyup","keypress"].includes(h)&&(d=ut(u));const f=(e=>d?t=>{ft(t,d)&&e(t)}:e)(r),m=void 0!==s.scope,p=void 0!==s.daemon;if(m&&p){console.warn(`[snice/@on] "${o.eventName}" cannot use both scope and daemon — listener skipped.`);continue}if((p||ot(e))&&o.selector){console.warn(`[snice/@on] "${o.eventName}" cannot delegate "${o.selector}" on a daemon target — listener skipped.`);continue}const y=m||p;let g=null;if(p)try{g=st(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(m&&(g=ze(t,s.scope),!g)){console.warn(`[snice/@on] scope did not resolve for "${o.eventName}" on ${o.methodName} — listener skipped.`);continue}if(o.selector){const n=y?g:t.shadowRoot||t,r=e=>{const t=e.target;if(t.matches&&t.matches(o.selector)&&t||t.closest&&t.closest(o.selector)){s.preventDefault&&e.preventDefault(),s.stopPropagation&&(e.stopPropagation(),e.stopImmediatePropagation());try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},i=yt.has(h),a={capture:void 0!==s.capture?s.capture:i,once:s.once||!1,passive:s.passive||!1};n.addEventListener(h,r,a),e[C].events.push({target:n,eventName:h,handler:r,options:a})}else{const n=y?null:t.shadowRoot,r=Symbol(),i=e=>{if(!e[r]){e[r]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&e.stopPropagation();try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};if(y){g.addEventListener(h,i,a),e[C].events.push({target:g,eventName:h,handler:i,options:a});continue}n&&(n.addEventListener(h,i,a),e[C].events.push({target:n,eventName:h,handler:i,options:a})),t.addEventListener(h,i,a),e[C].events.push({target:t,eventName:h,handler:i,options:a})}}}}function vt(e){if(e[C]?.events){for(const{target:t,eventName:n,handler:o,options:r}of e[C].events)t.removeEventListener(n,o,r);e[C].events=[]}}class bt{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(e,t){this.cleanupFns.set(e,t)}unregister(e){this.cleanupFns.delete(e)}async cleanup(){await Promise.all(this.pendingOperations);for(const e of this.cleanupFns.values())try{await e()}catch(e){console.error("Error during cleanup:",e)}this.cleanupFns.clear()}async runOperation(e){const t=e(),n=t.then(()=>{},()=>{});this.pendingOperations.add(n);try{const e=await t;return this.pendingOperations.delete(n),e}catch(e){throw this.pendingOperations.delete(n),e}}}function wt(e,n){if(t.controllerRegistry.has(n))return void queueMicrotask(()=>{const t=e[T];(void 0===t?e[v]:t)===n&&Nt(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 Et(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}async function Nt(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 "${Et(n)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=Et(n),a=e[w],c=e[T];if("string"==typeof n&&void 0!==c&&c!==n)return;if(e[E]===n&&a)return;let l;if(a&&await St(e),"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,e[A]=!0,delete e[T];const h=new l;t.controllerIdCounter+=1;const u=t.controllerIdCounter,d=new bt;h[r]=!0,h[N]=u,h.element=e;const f=e[I];void 0!==f&&(h[I]=f),e[w]=h,e[E]=n,e[S]=d;const m=new AbortController;e[Ae]=m;try{await Promise.race([e.ready,new Promise((e,t)=>{const n=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",t(e)};if(m.signal.aborted)return n();m.signal.addEventListener("abort",n,{once:!0});const o=setTimeout(()=>t(new Error(`attachController("${i}"): element did not become ready within 30000ms (did you forget to appendChild it?)`)),3e4);m.signal.addEventListener("abort",()=>clearTimeout(o),{once:!0})})])}catch(t){throw e[w]===h&&(delete e[w],delete e[E],delete e[S],"string"!=typeof n&&delete e[A]),t}finally{e[Ae]===m&&delete e[Ae]}h[_e]=!0,await d.runOperation(async()=>{await h.attach(e)}),Ge(h,e),at(h,e),gt(h,e),e.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:h}}))}async function St(e){const t=e[Ae];t&&t.abort();const n=e[w],o=e[E],r=e[S];n&&(delete e[w],delete e[E],delete e[S],"function"==typeof o&&delete e[A],n[_e]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),n.element=null,Ze(n),ct(n),vt(n),r&&await r.cleanup(),delete n[I],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:Et(o),controller:n}}))))}function Tt(){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[A])return;const t=e.getAttribute("controller"),n=e[T];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[T],delete e[E],void St(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[T]=t,e.ready||(e.ready=Promise.resolve()),n&&St(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),Nt(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):wt(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 At=n("context-handlers");function _t(e){const t=e.constructor[At];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[se];if(n){e[ie]=n;for(const o of t){const{methodName:t,method:r,options:s}=o,i=`__wrapped_${t}`;e[i]=function(n){const o=e[fe]||(e[fe]=new Set);if(s.once&&o.has(t))return;const a=()=>{if(r.call(e,n),s.once){o.add(t);const n=e[ie];n&&"function"==typeof n[he]&&n[he](e,i)}},c=e[de]||(e[de]={}),l=t;if(s.debounce)return clearTimeout(c[l]?.timeout),void(c[l]={timeout:setTimeout(a,s.debounce)});if(s.throttle){const e=Date.now();return void(e-(c[l]?.lastCall||0)>=s.throttle&&(c[l]={lastCall:e},a()))}a()},"function"==typeof n[le]&&n[le](e,i)}}}const Ct=Symbol.for("snice:html-result"),xt=Symbol.for("snice:css-result"),Ot=new WeakMap;function kt(e){return e&&e._$litType$===Ct}function $t(e){return e&&e._$litType$===xt}const Lt=Symbol.for("snice:nothing"),Pt=Symbol.for("snice:unsafe-html");function jt(e){return e&&e._$litType$===Pt}const Mt=Symbol.for("snice:repeat-result"),Rt=new WeakSet;function It(e){return e[y]||e.shadowRoot||null}function Dt(e){const t=It(e);if(t)return t;const n=e.constructor[g];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[y]=o,Rt.add(e),o}function Vt(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&Rt.has(n))return n;n=n.parentNode}return null}const qt=`snice$${Math.random().toFixed(9).slice(2)}$`,Bt="?"+qt,Ft=`\x3c!--${Bt}--\x3e`,Wt=new RegExp(qt.replace(/\$/g,"\\$"),"g"),zt=new WeakMap,Ut=Symbol("not-committed");function Ht(e,t){const n=e.localName;if(!n?.includes("-"))return;const o=e.ownerDocument?.defaultView?.customElements??globalThis.customElements;if(o?.get(n))return;const r=e;r[P]||(r[P]=new Set),r[P].add(t)}const Kt=Symbol.for("snice:no-change"),Gt=Symbol.for("snice:live"),Qt=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Jt=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class Xt{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(qt))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(qt))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(qt))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(qt))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(qt)&&(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(qt)){o.push(i);const t=n[r]||i.name,s=a.split(qt),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===Bt){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(qt)){const t=e.data.split(Wt);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(qt)){const n=e.parentNode,o=t.split(Wt),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 Yt(e){const{strings:t}=e,n=zt.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(qt);else if(i)r.push(l),o.push(qt);else if(s){const e=n.trimEnd();if(e.endsWith("=")){let t=e.length-2;for(;t>=0&&/[\w\-\.@\?\/:\+~|]/.test(e[t]);)t--;l=e.substring(t+1,e.length-1).trim(),r.push(l),o.push(qt)}else{if(!n.match(/<(if|else-if|case|when)\s*$/))throw new Error("snice: expressions directly in opening tags are not supported; use an explicit attribute, property, event, class, style, or named spread binding.");l="value",r.push("value"),o.push(`value="${qt}"`)}}else r.push(""),o.push(Ft)}}const h=o.join(""),u=document.createElement("template");if(e.svg){u.innerHTML=`<svg>${h}</svg>`;const e=u.content.firstElementChild;for(;e.firstChild;)u.content.insertBefore(e.firstChild,e);u.content.removeChild(e)}else u.innerHTML=h;const d=new Xt(e,u,r);return zt.set(t,d),d}function Zt(e){if(!kt(e))return;const t=Yt(e);return-1===t.keyIndex?void 0:e.values[t.keyIndex]}class en{constructor(e){this.parts=[],this.fragment=null,this.conditionalParts=[],this.regularParts=[],this.template=Yt(e),this.strings=e.strings}isSameTemplate(e){return this.strings===e}renderFragment(){if(!this.fragment){this.fragment=this.template.element.content.cloneNode(!0);const e=document.createTreeWalker(this.template.element.content,NodeFilter.SHOW_ALL),t=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ALL),n=new Map;let o=e.currentNode,r=t.currentNode;for(;o&&r;)n.set(o,r),o=e.nextNode(),r=t.nextNode();const s=new Set;for(const e of this.template.parts)"conditional-when"===e.type&&s.add(n.get(e.element));for(let e=0;e<this.template.parts.length;e++){const t=this.template.parts[e];let o;switch(t.type){case"node":const e=n.get(t.startNode),r=n.get(t.endNode);o=new nn(e,r);break;case"attribute":const i=n.get(t.element);o=new on(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new ln(a,t.name);break;case"boolean-attribute":const c=n.get(t.element);o=new un(c,t.name);break;case"event":const l=n.get(t.element);o=new dn(l,t.name);break;case"class":const h=n.get(t.element);o=new sn(h,t.name);break;case"style":const u=n.get(t.element);o=new an(u,t.name);break;case"spread":const d=n.get(t.element);o=new cn(d,t.name);break;case"controller":const f=n.get(t.element);o=new hn(f);break;case"conditional-if":const m=n.get(t.element);o=new mn(m);break;case"conditional-else-if":const p=n.get(t.element);o=new yn(p);break;case"conditional-case":const y=n.get(t.element);o=new gn(y,s);break;case"conditional-when":const g=n.get(t.element);o=new bn(g);break;case"comment":const v=n.get(t.startNode);o=new rn(v,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof mn||o instanceof yn||o instanceof gn||o instanceof bn?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 yn||e instanceof bn?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof mn||n instanceof gn)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof on&&void 0!==t.strings||t instanceof rn?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 tn{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 nn extends tn{constructor(e,t){super(),this.type="node",this._committedValue=Ut,this._itemKeys=null,this._asyncSource=null,this._asyncVersion=0,this._asyncIterator=null,this._asyncRunning=!1,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1,this._committingAsyncValue=!1,this.startNode=e,this.endNode=t}commit(e){if(e!==Kt)if((e=>!!e&&"function"==typeof e.then)(e)||Jt(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==Lt&&null!=e&&""!==e)Qt(e)?e!==this._committedValue&&this._commitText(e):kt(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===Mt}(e)?0===e.values.length?this.commit(e.empty??Lt):this._commitIterable(e.values,e.keys):jt(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!==Lt){const e=this._clear();if(this._committedValue=Lt,e)throw e}this._committedValue=Lt}}_commitText(e){if(this._committedValue!==Ut&&this._committedValue!==Lt&&Qt(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 en){const n=zt.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new en(e),o=n.renderFragment();try{n.update(e.values)}catch(e){throw n.clear(),e}const r=this._committedValue,s=this._itemKeys,i=this.endNode.ownerDocument.createDocumentFragment();let a=this.startNode.nextSibling;for(;a&&a!==this.endNode;){const e=a.nextSibling;i.appendChild(a),a=e}this._insertBefore(o),this._committedValue=n,this._itemKeys=null;try{this.isConnected&&n.reconnected()}catch(e){try{n.clear()}catch(e){console.error("snice: failed to clean up a rejected nested template:",e)}let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const e=t.nextSibling;t.remove(),t=e}throw this._insertBefore(i),this._committedValue=r,this._itemKeys=s,e}this._disposeCommitted(r)}_commitIterable(e,t){const n=Array.isArray(e)?e:Array.from(e),o=t?Array.from(t):n.map(Zt);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 nn||(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 nn(e,n),c.push(t)}else t=c[l];t.commit(e),l++}if(l<c.length){for(let e=l;e<c.length;e++){const t=c[e];try{t.destroy()}catch(e){s??=e}t.startNode.remove(),t.endNode.remove()}c.length=l}if(this._itemKeys=i?o:null,s)throw s}_reconcileKeyed(e,t,n,o){const r=this.endNode.parentNode;let s;const i=new Map;for(let e=0;e<n.length;e++)i.has(o[e])||i.set(o[e],n[e]);const a=new Set,c=new Array(e.length).fill(null);for(let n=0;n<e.length;n++){const e=i.get(t[n]);e&&!a.has(e)&&(a.add(e),c[n]=e)}for(const e of n)if(!a.has(e)){try{e.destroy()}catch(e){s??=e}e.startNode.remove(),e.endNode.remove()}let l=this.startNode.nextSibling;for(let t=0;t<c.length;t++){let n=c[t];if(n)if(n.startNode===l)l=n.endNode.nextSibling;else{const e=document.createDocumentFragment();let t=n.startNode;const o=n.endNode.nextSibling;for(;t&&t!==o;){const n=t.nextSibling;e.appendChild(t),t=n}r.insertBefore(e,l)}else{const e=document.createComment(""),o=document.createComment("");r.insertBefore(e,l),r.insertBefore(o,l),n=new nn(e,o),c[t]=n}n.commit(e[t])}return this._committedValue=c,s}_commitNode(e){if(this._committedValue!==e){const t=this._clear();if(this._insertBefore(e),this._committedValue=e,t)throw t}}_commitUnsafeHTML(e){const t=this._committedValue;if(jt(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=Lt,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(Jt(t)){try{this._asyncIterator=t[Symbol.asyncIterator]()}catch(e){return this._asyncRunning=!1,this._asyncCompleted=!0,void console.error("snice: async iterable template value failed:",e)}(async()=>{try{for(;this._asyncIterator;){const e=await this._asyncIterator.next();if(e.done||n!==this._asyncVersion)break;this._commitAsyncValue(e.value)}}catch(e){n===this._asyncVersion&&console.error("snice: async iterable template value failed:",e)}finally{n===this._asyncVersion&&(this._asyncIterator=null,this._asyncRunning=!1,this._asyncCompleted=!0)}})()}else Promise.resolve(t).then(e=>{if(n===this._asyncVersion){this._asyncRunning=!1,this._asyncCompleted=!0;try{this._commitAsyncValue(e)}catch(e){console.error("snice: promise template value failed:",e)}}},e=>{n===this._asyncVersion&&(this._asyncRunning=!1,this._asyncCompleted=!0,console.error("snice: promise template value failed:",e))})}_commitAsyncValue(e){this._committingAsyncValue=!0;try{this.commit(e)}finally{this._committingAsyncValue=!1}}_cancelAsync(e){this._asyncVersion++;const t=this._asyncIterator;if(this._asyncIterator=null,this._asyncRunning=!1,e&&(this._asyncSource=null,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1),t?.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}_insertBefore(e){this.endNode.parentNode?.insertBefore(e,this.endNode)}_clear(){const e=this.startNode.parentNode,t=this._committedValue;let n;try{this._disposeCommitted(t)}catch(e){n=e}if(!e)return this._committedValue=Lt,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=Lt,n}_disposeCommitted(e){let t;if(e instanceof en)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof nn)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 en)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof nn)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 en)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof nn)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class on extends tn{constructor(e,t,n){super(),this.type="attribute",this._committedValue=Ut,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(Ut),this.strings=n):this._committedValue=Ut}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===Kt)return;if(o=!Qt(e)||e!==this._committedValue&&e!==Kt,!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===Kt&&(i=s[e],i===Ut&&(i="")),o=o||!Qt(i)||i!==s[e],i===Lt?n=Lt:n!==Lt&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===Lt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class rn extends tn{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(Ut)}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===Kt&&(s=this._committedValues[e],s===Ut&&(s="")),o=o||!Qt(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===Lt?"":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 sn extends tn{constructor(e,t){super(),this.type="class",this.committed=Ut,this.element=e,this.name=t}commit(e){if(e===Kt)return;const t=e!==Lt&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=Ut}}class an extends tn{constructor(e,t){super(),this.type="style",this.committed=Ut,this.element=e,this.name=t}commit(e){if(e===Kt||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===Lt||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=Ut}}class cn extends tn{constructor(e,t){super(),this.type="spread",this.committed={},this.listeners=new Map,this.consumedOnce=new Map,this.element=e,this.name=t}commit(e){if(e===Kt)return;if(e!==Lt&&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)||(Ht(this.element,t),this.element[t]=void 0);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(Ht(this.element,t),this.element[t]=n===Lt?void 0:n)}commitAttributes(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||this.element.removeAttribute(t);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(n===Lt||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!==Lt&&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===Lt||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 Vt(this.element)||this.element}clear(){if("events"===this.name){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear(),this.consumedOnce.clear()}else if("props"!==this.name&&"properties"!==this.name)for(const e of Object.keys(this.committed))this.element.removeAttribute(e);this.committed={}}disconnected(e=!1){"events"!==this.name||e||this.detachListeners()}reconnected(){"events"===this.name&&0===this.listeners.size&&this.commitEvents(this.committed)}detachListeners(){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear()}}class ln extends tn{constructor(e,t){super(),this.type="property",this._committedValue=Ut,this.element=e,this.name=t}commit(e){if(e!==Kt){if(function(e){return e&&e._$liveMarker$===Gt}(e)){if((e=e.value)===Kt)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,Ht(this.element,this.name),this.element[this.name]=e===Lt?void 0:e}}clear(){this._committedValue=Ut}}class hn extends tn{constructor(e){super(),this.type="controller",this._committedValue=Ut,this.element=e}commit(e){if(e===Kt)return;const t=null==e||!1===e||""===e||e===Lt?null:e,n=this._committedValue===Ut,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[_]?delete r[_]:r[a]?r.controller=null:this._detach()),"function"==typeof t?(this.element.hasAttribute("controller")&&this.element.removeAttribute("controller"),this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[a]&&(r[_]=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[_]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){Nt(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){St(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[_]&&(t[a]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[_]&&delete e[_];const t=this._committedValue;this._committedValue=Ut,"function"==typeof t&&(e[a]||this._detach())}}class un extends tn{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=Ut,this.element=e,this.name=t}commit(e){if(e===Kt)return;const t=!!e&&e!==Lt;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=Ut}}class dn extends tn{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=ut(t)}else this.eventName=n,ht(n)}commit(e){if(e===Kt)return;e===Lt&&(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&&!ft(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=Vt(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 fn=Symbol("not-set");class mn extends tn{constructor(e){super(),this.type="node",this.conditions=[fn],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]=fn,pn.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!==Kt&&(this.conditions[0]=e)}setAlternative(e,t){t!==Kt&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==fn&&this.conditions[t]!==Lt&&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 pn=new WeakMap;class yn extends tn{constructor(e){super(),this.type="node";const t=pn.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 gn extends tn{constructor(e,t){super(),this.type="node",this.value=fn,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?fn: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:fn})-1}}n.removeChild(e)}commit(e){e!==Kt&&(this.value=e)}setExpected(e,t){t!==Kt&&(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 bn extends tn{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}}let wn=!1;function En(e){e[f]||(e[d]=new Promise(t=>{e[f]=t}))}function Nn(e){const t=e[f];t&&(e[f]=null,t())}const Sn=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?Cn(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?Cn(t,t[X]||{}):t[m]=!0}remove(e){this.pending.delete(e)}};function Tn(e){return Object.prototype.hasOwnProperty.call(e,Y)}function An(e){const t=e[ee];if(!t||0===t.length)return;const n=[...t];e[ee]=[],n.forEach(e=>e())}const _n=50;function Cn(e,t,n){const o=arguments.length>=3,r=e[J];if(!r)return void Nn(e);if(t.once&&Tn(e))return void Nn(e);const s=e[p]??0;if(s>=_n){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${_n}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void Nn(e)}e[p]=s+1;try{const s=o?n:r.call(e),i=Dt(e);if(!1===t.differential){if("string"!=typeof s)return void console.warn("Render method with differential: false must return a string");const t=document.createElement("template");t.innerHTML=s;const n=e[Y];n?.clear();const o=Array.from(i.childNodes).filter(e=>!(e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")));for(const e of o)e.remove();return i.appendChild(t.content),e[Y]=null,void An(e)}if(!kt(s))return void console.warn("Render method must return html`` template result");let a=e[Y];if(a&&a.isSameTemplate(s.strings))return a.update(s.values),void An(e);const c=new en(s),l=c.renderFragment();try{c.update(s.values)}catch(e){throw c.clear(),e}const h=document.createDocumentFragment();for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||h.appendChild(e);i.appendChild(l);try{e.isConnected&&c.reconnected()}catch(e){try{c.clear()}catch(e){console.error("snice: failed to clean up a rejected render tree:",e)}for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||e.remove();throw i.appendChild(h),e}let u;e[Y]=c;try{a?.clear()}catch(e){u=e}if(An(e),u)throw u}catch(e){if(wn)throw e;console.error("Error rendering element:",e)}finally{e[p]=s,Nn(e)}}function xn(e,t=!1){const n=e[X]||{};if(n.once&&Tn(e))e.isConnected&&On(e);else if(En(e),t)Cn(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[Z]||(e[Z]={}),clearTimeout(e[Z].debounce),void(e[Z].debounce=setTimeout(()=>{e[Z].debounce=null,Sn.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[Z]||(e[Z]={lastThrottle:0});const t=e[Z],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void Sn.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),Sn.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}Sn.schedule(e,n)}}function On(e){const t=e[Y];t?.reconnected()}function kn(e){const t=e[Q];if(t)for(const e of t.values())e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.throttleTimeout&&clearTimeout(e.throttleTimeout),e.debounceTimeout=null,e.throttleTimeout=null,e.throttleLastCall=0,e.latestDetail=void 0}const $n=n("debounce-timers"),Ln=n("throttle-timers"),Pn=n("once-called"),jn=n("memoize-cache");function Mn(e){if(e[$n]){for(const t in e[$n])e[$n][t]?.timeout&&clearTimeout(e[$n][t].timeout);e[$n]={}}}function Rn(e){if(e[Ln]){for(const t in e[Ln])e[Ln][t]?.timeout&&clearTimeout(e[Ln][t].timeout);e[Ln]={}}}function In(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 Dn(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");const s=e[x];if(s)for(const[e,t]of s){if(!1===t.attribute)continue;const n=De(t,e);r.includes(n)||r.push(n)}Object.defineProperty(e,"observedAttributes",{get:()=>r,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get(){return this[h]||(this[h]=new Promise(e=>{this[u]=e})),this[h]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[f]?this[d]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[v]},set(e){const t=this[v];if(this[v]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void Nt(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):wt(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&St(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[h]||(this[h]=new Promise(e=>{this[u]=e})),this[b]){try{On(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}gt(this,this),at(this,this),_t(this);try{Ge(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[F];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 void(this[J]&&this[m]&&(this[m]=!1,xn(this)))}this[j]=!0;const n=e[x];if(n)for(const[e,t]of n){if(!1===t.attribute)continue;const n=De(t,e);if(!this.hasAttribute(n))continue;const o=this.getAttribute(n);Ve(this,R).add(e),t.type===Boolean&&""===o&&this.setAttribute(n,"true"),this[e]=Re(o,t)}if(this[L]){for(const[e,t]of Array.from(this[L].entries())){const o=n?.get(e),r=De(o||{},e);this[L].delete(e),this.hasAttribute(r)||(this[e]=t)}delete this[L]}if(void 0!==this[_]){const e=this[_];if(delete this[_],!this[v]){this[v]=e;const t=e?.name||"(anonymous controller class)";Nt(this,e).catch(e=>{"ControllerAttachAborted"!==e?.name?console.error(`Failed to attach controller "${t}":`,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}if(this.hasAttribute("controller")&&!this[v]){const e=this.getAttribute("controller");e&&(this.controller=e)}!function(e){const t=e[te],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)$t(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[ne]){e[ne]=!0;try{const o=[...n],r=e[oe];if(r)for(const t of r){const n=t.call(e);$t(n)&&o.push(n)}if(t){const n=t.call(e);if(!$t(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=Dt(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),gt(this,this),at(this,this),_t(this),this[b]=!0,function(e,t){if(He.has(t))return;He.add(t);const n=t[M];if(!n||0===n.size)return;const o=t[x],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[M],o=t[x];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[q];if(await new Promise(e=>queueMicrotask(e)),this.isConnected){this[J]&&xn(this,!0);try{Ge(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName}:`,e)}if(await new Promise(e=>queueMicrotask(e)),this.isConnected){if(o)for(const e of o)try{await e.method.call(this)}catch(t){console.error(`Error in @ready handler ${e.methodName}:`,t)}this[u]&&(this[u](),this[u]=null)}else this[u]&&(this[u](),this[u]=null)}else this[u]&&(this[u](),this[u]=null)},e.prototype.disconnectedCallback=async function(){try{!function(e){const t=e[Y];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[B];if(t)for(const e of t)try{await e.method.call(this)}catch(t){console.error(`Error in @dispose handler ${e.methodName}:`,t)}n&&n.call(this),this[v]&&St(this).catch(e=>{console.error("Failed to detach controller:",e)}),vt(this),ct(this),function(e){const t=e.constructor[At];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[de];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[de]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[ie];o&&"function"==typeof o[he]&&o[he](e),delete e[ie],delete e[fe]}(this),Ze(this),Mn(this),Rn(this),function(e){const t=e[Z];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[m]=!0),kn(this),Un(this,K),Un(this,G)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t)return void(this.controller=r);const s=e[x];if(s)for(const[n,o]of s){if(De(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[H]?.has(t.toLowerCase()))break;const s=this[O]?.[n],i=this[k]?.[n];let a=null===r?o.type!==Boolean&&i:Re(r,o,s,i);const c=this[$]?.[n];if(c&&(a=c(a)),!(o?.hasChanged?o.hasChanged(a,s):Ie(a,s)))break;Ve(this,R).add(n),qe(this,O)[n]=a,this[b]&&Be(this,e,n,s,a),this[J]&&this[b]&&xn(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[W];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[z];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function Vn(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[x]){e[x]||(e[x]=new Map);for(const[n,o]of t[x])e[x].has(n)||e[x].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[x]){t[x]||(t[x]=new Map);for(const[e,o]of n.metadata[x])t[x].set(e,o)}else if(qn.length>0){t[x]||(t[x]=new Map);const e=qn.pop();for(const[n,o]of e)t[x].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[g]||{}},s=o||{};if("light"===s.renderRoot&&"string"==typeof s.shadow||"shadow"===s.renderRoot&&!1===s.shadow)throw new TypeError("snice: @element renderRoot and shadow options select conflicting render roots.");const i={...r,...s};return Object.prototype.hasOwnProperty.call(s,"shadow")?i.renderRoot=!1===s.shadow?"light":"shadow":Object.prototype.hasOwnProperty.call(s,"renderRoot")&&("light"===s.renderRoot?i.shadow=!1:!1===i.shadow&&(i.shadow="open")),t[g]=i,!0===t.prototype[re]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,J)&&"function"==typeof t.prototype.render&&(t.prototype[J]=t.prototype.render,t.prototype[X]=t.renderOptions||{}),Dn(t),customElements.get(e)?(globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),t)}const qn=[],Bn=new WeakMap;function Fn(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[x]||(n.metadata[x]=new Map),n.metadata[x].set(o,e||{})):(0===qn.length&&qn.push(new Map),qn[qn.length-1].set(o,e||{})),function(t){const n=this[P],r=!0===n?.delete(o);0===n?.size&&delete this[P];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=Bn.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);Bn.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[x]||(c[x]=new Map);const l={...e};l.type||void 0===t||(l.type=Me(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[x].set(o,l),qe(this,k)[o]=t;const h=()=>{if(!this[j])return;const e=this[O]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=De(l,o),r=Ue(e,l,t),s=n.toLowerCase();Ve(this,H).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[H].delete(s)}}this[b]&&(Be(this,this.constructor,o,e,e),this[J]&&xn(this))},u=e=>{if(!l.deep)return e;let t;return t=function(e,t){if(!e||"object"!=typeof e)return e;const n=new WeakMap,o=new WeakMap,r=e=>e&&"object"==typeof e&&o.get(e)||e,s=e=>{if(!e||"object"!=typeof e)return e;if(n.has(e))return n.get(e);if(e instanceof Map){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=In(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=In(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=In(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[O]?.[o]===t&&h()}),t};qe(this,$)[o]=u;const d=this.constructor.prototype;let f=d[Ce];f&&Object.prototype.hasOwnProperty.call(d,Ce)||(f=new Map(f),d[Ce]=f);const m=f.get(o);m&&m===e||(f.set(o,e),Object.defineProperty(this.constructor.prototype,o,{get(){return this[L]?.has(o)?this[L].get(o):this[O]&&o in this[O]?this[O][o]:t},set(e){const t=this[o];if(!(l.hasChanged?l.hasChanged(e,t):Ie(e,t)))return;const n=(this[$]?.[o]||(e=>e))(e);if(!this[j])return this[L]||(this[L]=new Map),void this[L].set(o,n);if(qe(this,O)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=De(l,o),t=Ue(n,l,this[k]?.[o]);Ve(this,R).add(o);const r=e.toLowerCase();Ve(this,H).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[H].delete(r)}}this[b]&&(Be(this,this.constructor,o,t,n),this[J]&&xn(this))},configurable:!0,enumerable:!0}));const p=u(t);return qe(this,O)[o]=p,qe(this,k)[o]=p,i?a:p}}}function Wn(e){return!0===e[r]&&e.element?e.element:e}function zn(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 Un(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 Hn(e,t,n){return function(o={}){return function(r,s){zn(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 Kn=Hn(W,K,Se),Gn=Hn(z,G,Te);class Qn extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[g];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return xn(this),this.rendered}renderNow(){return En(this),Cn(this,{...this[X]||{},once:!1}),this.rendered}}Object.defineProperty(Qn.prototype,re,{value:!0});class Jn{constructor(e){this.parsed=this.parsePattern(e)}get spec(){return this.parsed.template}parsePattern(e){let t=e,n="",o=!1;const r=e.indexOf("?");return-1!==r&&(t=e.slice(0,r),n=e.slice(r+1),t.endsWith("(")&&n.endsWith(")")&&(o=!0,t=t.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(t),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:e}}parseSegments(e){const t=[];let n=0;for(;n<e.length;)switch(e[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(e,n);t.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(e,n+1);t.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(e,n+1);t.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:h}=this.parseLiteral(e,n);l&&t.push({type:"literal",value:l}),n=h}return t}parseOptionalGroup(e,t){let n=1,o=t+1;for(;o<e.length&&n>0;)"("===e[o]&&n++,")"===e[o]&&n--,o++;const r=e.slice(t+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(e,t){let n=t;for(;n<e.length&&/[\w-]/.test(e[n]);)n++;return{name:e.slice(t,n),endIndex:n}}parseLiteral(e,t){let n=t;for(;n<e.length&&!"(:*(".includes(e[n]);)n++;return{value:e.slice(t,n),endIndex:n}}parseQuerySegments(e){let t=e;t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1));const n=[];let o=0;for(;o<t.length;)if(":"===t[o]){const{name:e,endIndex:r}=this.parseIdentifier(t,o+1);n.push({type:"param",name:e}),o=r}else{const{value:e,endIndex:r}=this.parseQueryLiteral(t,o);e&&n.push({type:"literal",value:e}),o=r}return n}parseQueryLiteral(e,t){let n=t;for(;n<e.length&&":"!==e[n];)n++;return{value:e.slice(t,n),endIndex:n}}getAllParamNames(){const e=new Set,t=n=>{for(const o of n)switch(o.type){case"param":case"splat":e.add(o.name);break;case"optional":t(o.segments)}};return t(this.parsed.pathSegments),t(this.parsed.querySegments),Array.from(e)}canMatchRemainingSegments(e,t,n){let o=t;for(const t of n)if("literal"===t.type){const n=e.indexOf(t.value,o);if(-1===n)return!1;o=n+t.value.length}return!0}match(e){const[t,n]=e.split("?"),o=this.matchPath(t,this.parsed.pathSegments);if(!1===o)return!1;const r=this.matchQuery(n||"",this.parsed.querySegments);if(!1===r)return!1;const s=this.getAllParamNames(),i={};for(const e of s)i[e]=void 0;return Object.assign(i,o,r),i}matchPath(e,t){const n={};let o=0;for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1),a=this.matchSegment(e,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<e.length)&&n}matchSegment(e,t,n,o=[]){switch(n.type){case"literal":return e.slice(t,t+n.value.length)===n.value&&{params:{},nextIndex:t+n.value.length};case"param":{let r=t;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=e.indexOf(s.value,t);if(-1===n)return!1;r=n}else for(;r<e.length&&!a.includes(e[r]);)r++;if(r===t)return!1;try{i=decodeURIComponent(e.slice(t,r))}catch(n){i=e.slice(t,r)}return!(r<e.length&&"?"===e[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=e.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=e.indexOf(".",t);-1!==n&&(r=n)}else{const n=e.lastIndexOf(s.value);-1!==n&&n>=t&&(r=n)}break;case"param":let n=-1;for(let o=e.length-1;o>=t;o--)if("/"===e[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=e.length-1;n>t;n--)if("/"===e[n]){o=n+1;break}if(-1!==o)r=o;else{const n=e.slice(t).split("/").filter(e=>e);r=n.length>1?t+n.slice(0,-1).join("/").length+1:t}break;case"optional":const i=e=>{for(const t of e){if("literal"===t.type)return t.value;if("optional"===t.type){const e=i(t.segments);if(e)return e}}return null},a=i(s.segments);if(a){const n=e.lastIndexOf(a);-1!==n&&n>=t&&(r=n)}}const i=e.indexOf("?",t);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(e.slice(t,r))}catch(n){a=e.slice(t,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=t,s={},i=!0;for(let t=0;t<n.segments.length;t++){const o=n.segments[t],a=n.segments.slice(t+1),c=this.matchSegment(e,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}return i&&this.canMatchRemainingSegments(e,r,o)?{params:s,nextIndex:r}:{params:{},nextIndex:t}}default:return!1}}findNextLiteral(e){for(const t of e){if("literal"===t.type)return t;if("optional"===t.type){const e=this.findNextLiteral(t.segments);if(e)return e}}return null}matchQuery(e,t){if(0===t.length)return{};const n={};let o=0;for(const r of t)switch(r.type){case"literal":if(e.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let t,s=o;for(;s<e.length&&"&"!==e[s];)s++;if(s===o)return!1;try{t=decodeURIComponent(e.slice(o,s))}catch(n){t=e.slice(o,s)}n[r.name]=t,o=s;break}}return n}reverse(e={}){const t=this.reverseSegments(this.parsed.pathSegments,e);if(!1===t)return!1;let n=t;if(this.parsed.querySegments.length>0){const t=this.reverseSegments(this.parsed.querySegments,e);if(!this.parsed.queryOptional&&!1===t)return!1;t&&""!==t&&(n+="?"+t)}return n}reverseSegments(e,t,n=!1){let o="";for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in t))return!1;o+=String(t[s.name]);break;case"optional":if(this.hasAllParams(s.segments,t,n)||this.hasLaterOptionalGroupNeedingParams(i,t,s.segments)){const e=this.reverseSegments(s.segments,t,!0);if(!1===e)return!1;o+=e}}}return o}hasLaterOptionalGroupNeedingParams(e,t,n){for(const o of e)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,t))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(e){for(const t of e)if("param"===t.type||"splat"===t.type)return!1;return!0}hasAllParams(e,t,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of e)switch(n.type){case"param":case"splat":i=!1,n.name in t&&void 0!==t[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of e)"optional"===n.type&&this.hasAllParams(n.segments,t,a)&&(r=!0);return!(!o||s)||!(!r||s)||!(!i||!n)}hasOnlyOptionalMissingParams(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(!(n.name in t))return!1}return!0}hasAnyParamInSegments(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(n.name in t)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,t))return!0}return!1}}function Xn(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 Yn(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 Zn(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 eo(e){if(!ot(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=rt(e);if(0===t.bindings){t.active=!0;try{gt(e,t.target),at(e,t.target)}catch(n){throw ct(e),vt(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&&(ct(e),vt(e),kn(e),t.active=!1,t.target=new EventTarget))}}function to(e,t){const n=function(e,t){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(tt.has(e))throw new Error("This root already provides an application context. Release it before providing another.");const n=e=>{const n=e;n.detail&&void 0===n.detail.context&&(n.detail.context=t,n.preventDefault(),n.stopPropagation())};e.addEventListener(et,n),tt.set(e,{listener:n});let o=!1;return()=>{if(o)return;o=!0;const t=tt.get(e);t?.listener===n&&(e.removeEventListener(et,n),tt.delete(e))}}(e,t);let o;try{o=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(eo(r)))}}catch(e){for(const e of n.reverse())e();throw e}return()=>{for(const e of n.reverse())e()}}(t)}catch(e){throw n(),e}let r=!1;return()=>{r||(r=!0,n(),o?.())}}const no=new WeakMap;var oo;!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(oo||(oo={}));let ro=!1;async function so(e,t=500){if(customElements.get(e))return;let n=null;ro||(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 so(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}let ao=0,co=null;const lo=Symbol.for("snice:body-scroll-lock");var ho;return globalThis[lo]={clear(){ao=0,co=null}},"undefined"!=typeof document&&Tt(),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"}(ho||(ho={})),e.Context=je,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){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=!1,l=[],h=null,u=null;const d=t.context||{};let f=null,m=null;const p=new je(d,[],"",{},t.fetcher);function y(e){if(f===e&&m&&no.get(e)===m)return;m?.(),no.get(e)?.();const t=to(e,d);let n=!1;const o=()=>{n||(n=!0,t(),no.get(e)===o&&no.delete(e))};m=o,f=e,no.set(e,o)}function g(e){if(!h||!u)return null;const t=e.querySelectorAll(h);for(const e of t)if(e[V]===u)return e;return null}function v(e,t,n,o,l,h){switch(r.push({route:new Jn(e),tag:t,transition:n,guards:o,layout:l,placard:h}),c=!1,e){case"/404":s=t;break;case"/403":i=t;break;case"/":a=t}}function b(){const e=new Set;l=r.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(d):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function w(e,t,n){p[me](d,l,t,n)}function E(){switch(t.type){case"hash":return n.location.hash.slice(1);case"pushstate":return`${n.location.pathname}${n.location.search}`}}function N(e){let t;if(i)t=o.createElement(i),t[I]=d;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,u=null}async function S(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(d,t))return r&&r()||N(n),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function T(e,n,r,s,i,a,c){const f=!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();u=t;const n=o.createElement(e);return n[I]=d,n[V]=t,{element:n,needsNewLayout:!0}}return u=null,{element:null,needsNewLayout:!0}}(f),v=r||t.transition;if(null!==p||null!==g(e)){if(await async function(e,t,n,o,r,s,i,a){const c=o||g(e);if(!c)return;!function(e,t,n){"function"==typeof e.update&&e.update(d,l,t,n)}(c,s,i);const h=c.querySelector('[slot="page"]');if(n&&h){if(t.setAttribute("slot","page"),await C(c,h,t,n),a&&a())return;r&&(e.innerHTML="",e.appendChild(c))}else a&&a()||(c.querySelectorAll('[slot="page"]').forEach(e=>e.remove()),t.setAttribute("slot","page"),c.appendChild(t),r&&(e.innerHTML="",e.appendChild(c)))}(e,n,v,p,y,i,a,c),c&&c())return;w(0,i,a)}else await async function(e,t,n,o){const r=e.children[0];n&&r?await C(e,r,t,n):o&&o()||(e.innerHTML="",e.appendChild(t))}(e,n,v,c),c&&c()||w(0,i,a)}let A=0;async function _(e){const i=o.querySelector(t.target);if(!i)throw new Error(`Target element not found: ${t.target}`);y(i);const c=++A,l=()=>c!==A;if(b(),n.scrollTo(0,0),(""===e?.trim()||"/"===e)&&a){const t=r.find(e=>e.route.match("/"));if(!await S(t?.guards,{},i,l))return;if(l())return;const{element:s,transition:c,layout:h}=function(){const e=o.createElement(a);e[I]=d;const t=n.customElements.get(a),s=t?.[D],i=r.find(e=>e.route.match("/"));return{element:e,transition:s,layout:i?.layout}}();return void await T(i,s,c,h,e,{},l)}if(!e)return;const h=await async function(e,t,n){for(const s of r){const r=s.route.match(e);if(!1===r)continue;if(!await S(s.guards,r,t,n))return{result:oo.GUARDS_FAILED};const i=o.createElement(s.tag);i[I]=d,i[se]=p;const a=r;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:oo.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:oo.NOT_FOUND}}(e,i,l);if(l())return;if(h.result===oo.GUARDS_FAILED)return;if(h.result===oo.SUCCESS){const{element:t,transition:n,layout:o,routeParams:r={}}=h;return void await T(i,t,n,o,e,r,l)}const{element:u,transition:f,layout:m}=function(){if(s){const e=o.createElement(s);e[I]=d;const t=n.customElements.get(s),r=t?.[D];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 T(i,u,f,m,e,{},l)}async function C(t,n,o,r,s=A){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?Yn(r.out):{opacity:"0"},h={opacity:"0"},u=r.in?Yn(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]))},v=n.hasAttribute("slot")||o.hasAttribute("slot");switch(Zn(n,v,i,"all"),Zn(o,v,a,"all"),Object.assign(o.style,h),t.appendChild(o),c){case e.TransitionMode.SIMULTANEOUS:Object.assign(n.style,l),Object.assign(o.style,u),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,u),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,v),Object.keys({...h,...u}).forEach(e=>{o.style[e]=""}),g()}(t,n,o,r,()=>s!==A)}return{page:function(e){return function(t,o){if(o?.metadata&&o.metadata[x]){t[x]||(t[x]=new Map);for(const[e,n]of o.metadata[x])t[x].set(e,n)}Dn(t),t[D]=e.transition;const r=t.prototype.connectedCallback;t.prototype.connectedCallback=function(){this[se]=p,r?.call(this)};const s=t.prototype.disconnectedCallback;return t.prototype.disconnectedCallback=function(){s?.call(this),delete this[I],delete this[se]},n.customElements.get(e.tag)||n.customElements.define(e.tag,t),e.routes.forEach(t=>v(t,e.tag,e.transition,e.guards,e.layout,e.placard)),t}},initialize:function(){const e=o.querySelector(t.target);if(!e)throw new Error(`Target element not found: ${t.target}`);y(e),!c&&(r.sort((e,t)=>Xn(t.route.spec)-Xn(e.route.spec)),c=!0),b(),function(){const e=()=>{const e=o.querySelector(t.target);if(e&&(f!==e||!m||no.get(e)===m))return f!==e&&tt.has(e)?(m?.(),m=null,void(f=null)):void _(E())};switch(t.type){case"hash":n.addEventListener("hashchange",e);break;case"pushstate":n.addEventListener("popstate",e)}}(),_(E())},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=xe,e.SniceElement=Qn,e.adopted=Gn,e.applyElementFunctionality=Dn,e.attachController=Nt,e.classMap=function(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t},e.clearDebounceTimers=Mn,e.clearMemoizeCache=function(e,t){e[jn]&&(t?delete e[jn][t]:e[jn]={})},e.clearThrottleTimers=Rn,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,pe)||(n[pe]=new Set),!n[pe].has(t)){if(n[pe].add(t),!Object.prototype.hasOwnProperty.call(n,At)){const e=n[At];n[At]=e?[...e]:[]}n[At].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[I])return this[I];const e=nt(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;const i=t.pendingControllerAttachments.get(e);return i&&(t.pendingControllerAttachments.delete(e),queueMicrotask(()=>{for(const t of i){const n=t[T];(void 0===n?t[v]:n)===e&&Nt(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?Ot.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+=($t(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:xt,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&&Ot.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[$n]||(this[$n]={});const a=this[$n],c=i;a[c]&&clearTimeout(a[c].timeout);const l=Date.now(),h=!a[c],u=h?l:a[c].startTime,d=void 0!==r&&l-u>=r;if(n&&h){const e=t.apply(this,s);return a[c]={timeout:null,startTime:u,lastArgs:s},e}const f=setTimeout(()=>{(o||d)&&t.apply(this,a[c].lastArgs),delete a[c]},d?0:e);a[c]={timeout:f,startTime:u,lastArgs:s}}}},e.detachController=St,e.dispatch=function(e,t){return function(n,o){return function(...r){this[Q]||(this[Q]=new Map);const s=`${e}_${o.name}`;this[Q].has(s)||this[Q].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[Q].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===t?.dispatchOnUndefined)return;const o=new CustomEvent(e,{bubbles:t?.bubbles??!0,cancelable:t?.cancelable??!1,composed:t?.composed??!0,detail:n});if(void 0!==t?.scope&&void 0!==t?.daemon)throw new TypeError(`@dispatch('${e}') cannot use both scope and daemon.`);if(void 0!==t?.daemon)return void st(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=ze(this,t.scope);return n?void n.dispatchEvent(o):void console.warn(`[snice/@dispatch] scope did not resolve for "${e}" — event not dispatched.`)}const r=it(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},l=e=>{if(t?.debounce)return clearTimeout(i.debounceTimeout),void(i.debounceTimeout=setTimeout(()=>c(e),t.debounce));if(!t?.throttle)return void c(e);const n=Date.now(),o=t.throttle-(n-i.throttleLastCall);if(o<=0)return clearTimeout(i.throttleTimeout),i.throttleLastCall=n,void c(e);i.latestDetail=e,i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null;const e=i.latestDetail;i.latestDetail=void 0,c(e)},o))};return a instanceof Promise?a.then(e=>(l(e),e)):(l(a),a)}}},e.dispose=function(){return function(e,t){zn(B,Ee,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 Vn(e,n,o,t)}},e.escapeAttr=function(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},e.escapeHtml=function(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},e.getBodyScrollLockCount=function(){return ao},e.getContext=nt,e.getController=function(e){return e[w]},e.getSymbol=n,e.html=function(e,...t){return{_$litType$:Ct,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 Vn(e,t,n)}},e.live=function(e){return{_$liveMarker$:Gt,value:e}},e.lockBodyScroll=function(){0===ao&&(co=document.body.style.overflow,document.body.style.overflow="hidden"),ao++},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[jn]||(this[jn]={}),this[jn][s]||(this[jn][s]=new Map);const i=this[jn][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=Kn,e.noChange=Kt,e.nothing=Lt,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,ge)||(n[ge]=new Set),n[ge].has(t))return;if(n[ge].add(t),!Object.prototype.hasOwnProperty.call(n,U)){const e=n[U];n[U]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[U].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),function(t,n){const s=n.name;return n.addInitializer(function(){const n=this.constructor,i=Array.isArray(e)?e:[e],a=`${s}::${i.join(",")}::${o??""}::daemon:${r.daemon??""}`;if(Object.prototype.hasOwnProperty.call(n,ve)||(n[ve]=new Set),!n[ve].has(a)){if(n[ve].add(a),!Object.prototype.hasOwnProperty.call(n,mt)){const e=n[mt];n[mt]=e?[...e]:[]}for(const e of i)n[mt].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[Pn]||(this[Pn]={}),this[Pn][s]||(this[Pn][s]={called:!0,result:o.apply(this,r)}),this[Pn][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=Fn,e.provideContext=to,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=Wn(this);let n=null;const o=t instanceof HTMLElement?It(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=Wn(this),n=new Set,o=t instanceof HTMLElement?It(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){zn(q,we,e,t)}},e.reconnect=function(){return function(e,t){zn(F,Ne,e,t)}},e.render=function(e={}){return function(t,n){return n.addInitializer(function(){this[J]=t,this[X]=e}),function(...n){const o=t.apply(this,n);return Cn(this,{...this[X]||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$:Mt,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?st(this,t.daemon):it(this);if(!i)throw new TypeError(`@request('${e}') requires an element, attached controller, or provided @daemon instance.`);const a=n.apply(this,o),{value:c,done:l}=await a.next();if(l)return c;let h,u;const d=new Promise((e,t)=>{h=e,u=t});let f,m,p,y=!1;const g=new Promise((t,n)=>{f=t,m=n,p=setTimeout(()=>{n(new Error(`Request "${e}" found no @respond('${e}') handler within ${s}ms — attach a responding controller/element, or pass { optional: true } to resolve undefined when unhandled.`))},s)}),v=new CustomEvent(`@request/${e}`,{bubbles:void 0===t?.bubbles||t.bubbles,cancelable:t?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{y=!0,clearTimeout(p),f()},reject:m},data:{resolve:h,reject:u}}});i.dispatchEvent(v);try{await g;const t=setTimeout(()=>{u(new Error(`Request "${e}" timed out after ${r}ms`))},r),n=await d;clearTimeout(t);const{value:o}=await a.next(n);return o}catch(e){if(t?.optional&&!y){const{value:e}=await a.next(void 0);return e}const{value:n}=await a.throw(e);return n}};if(t?.debounce)return new Promise((e,n)=>{clearTimeout(r),r=setTimeout(async()=>{try{e(await c())}catch(e){n(e)}},t.debounce)});if(!t?.throttle)return c();const l=Date.now(),h=t.throttle-(l-i);if(h<=0){clearTimeout(s),s=null,i=l;const e=a.splice(0),t=c();return e.length&&t.then(t=>{for(const n of e)n.resolve(t)},t=>{for(const n of e)n.reject(t)}),t}return new Promise(s?(e,t)=>{a.push({resolve:e,reject:t})}:(e,t)=>{a.push({resolve:e,reject:t}),s=setTimeout(async()=>{i=Date.now(),s=null;const e=a.splice(0);try{const t=await c();for(const n of e)n.resolve(t)}catch(t){for(const n of e)n.reject(t)}},h)})}}},e.resetOnce=function(e,t){e[Pn]&&(t?delete e[Pn][t]:e[Pn]={})},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,be)||(o[be]=new Set),!o[be].has(n)){if(o[be].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){ro=e},e.setStrictRenderErrors=function(e){wn=e},e.state=function(e={}){return Fn({...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[te]&&!this[oe]?this[oe]=[this[te]]:this[te]&&this[oe]&&this[oe].push(this[te]),this[te]=e}),e}},e.svg=function(e,...t){return{_$litType$:Ct,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[Ln]||(this[Ln]={});const i=this[Ln],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[ee]||(e[ee]=[]),e[ee].push(t)}),yield},e.unlockBodyScroll=function(){0!==ao&&(ao--,0===ao&&(document.body.style.overflow=co??"",co=null))},e.unsafeHTML=function(e){return{_$litType$:Pt,html:e}},e.useNativeElementControllers=Tt,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=so,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,ye)||(n[ye]=new Map);let s=n[ye].get(e);if(s||(s=new Set,n[ye].set(e,s)),!Object.prototype.hasOwnProperty.call(n,M)){const e=n[M],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[M]=t}for(const i of t)s.has(i)||(s.add(i),n[M].has(i)||n[M].set(i,[]),n[M].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"),h=n("ready-promise"),u=n("ready-resolve"),d=n("rendered-promise"),f=n("rendered-resolve"),m=n("pending-reconnect-render"),p=n("render-depth"),y=n("render-root"),g=n("element-options"),v=n("controller"),b=n("initialized"),w=n("controller-key"),E=n("controller-name"),N=n("controller-id"),S=n("controller-operations"),T=n("native-controller"),A=n("controller-registry-name"),_=n("direct-controller"),C=n("controller-attribute-sync"),x=n("pending-controller-binding"),O=n("cleanup"),k=n("properties"),$=n("property-values"),L=n("property-defaults"),P=n("property-wrappers"),j=n("pre-init-property-values"),M=n("pre-upgrade-property-bindings"),R=n("properties-initialized"),I=n("property-watchers"),D=n("explicitly-set-properties"),V=n("router-context"),q=n("page-transition"),B=n("created-at"),F=n("ready-handlers"),W=n("dispose-handlers"),z=n("reconnect-handlers"),U=n("moved-handlers"),H=n("adopted-handlers"),K=n("observers"),G=n("setting-from-property"),Q=n("moved-timers"),J=n("adopted-timers"),X=n("dispatch-timers"),Y=n("render-method"),Z=n("render-options"),ee=n("render-instance"),te=n("render-timers"),ne=n("render-callbacks"),oe=n("styles-method"),re=n("styles-applied"),se=n("parent-styles-methods"),ie=n("snice-element-base"),ae=n("context-handler"),ce=n("navigation-context-instance"),le=n("registered-elements"),he=n("is-updating"),ue=n("context-register"),de=n("context-unregister"),fe=n("context-notify-element"),me=n("context-timer"),pe=n("context-called"),ye=n("context-update"),ge=n("context-methods"),ve=n("watch-methods"),be=n("observe-methods"),we=n("on-methods"),Ee=n("respond-methods"),Ne=n("ready-methods"),Se=n("dispose-methods"),Te=n("reconnect-methods"),Ae=n("moved-methods"),_e=n("adopted-methods"),Ce=n("controller-abort"),xe=n("controller-attached"),Oe=n("property-definers");class ke{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes(ke.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${ke.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(ke.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split(ke.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var $e,Le,Pe;e.TransitionMode=void 0,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(e.TransitionMode||(e.TransitionMode={}));const je=Symbol.for("snice:registered-elements-set");let Me=0;class Re{constructor(e={},t=[],n="",o={},r){if(this[$e]=new WeakMap,this[Le]=new Set,this[Pe]=!1,this.id=Me++,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)}}[($e=le,Le=je,Pe=he,ue)](e,t){const n=this[le];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[je].add(e)}[de](e,t){const n=this[le];if(void 0!==t){const o=n.get(e);if(!o)return;if(o.delete(t),o.size>0)return}n.delete(e),this[je].delete(e)}[ye](e,t,n,o){this.application=e,this.navigation.placards=t,this.navigation.route=n,this.navigation.params=o,this.notify()}update(){this.notify()}notify(){if(this[he])return;this[he]=!0;const e=this[je],t=this[le];for(const n of e){const e=t.get(n);if(e)for(const t of e)if("function"==typeof n[t])try{n[t](this)}catch(e){console.error(`Error calling @context method ${t}:`,e)}}this[he]=!1}[fe](e){const t=this[le].get(e);if(t)for(const n of t)"function"==typeof e[n]&&e[n](this)}}function Ie(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 De(e,t,n,o){const r=t.type||Ie(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 ke:return ke.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 Ve(e,t){return e!==t&&(e==e||t==t)}function qe(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 Be(e,t){return e[t]||(e[t]=new Set),e[t]}function Fe(e,t){return e[t]||(e[t]={}),e[t]}function We(e,t,n,o,r){const s=t[I];if(!s)return;const i=[n],a=t[k]?.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 ze(e,t){let n=null;return function(...o){null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o),n=null},t)}}function Ue(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 He(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 Ke(e,t,n){if(null==e||!1===e||t?.type===ke&&Array.isArray(e)&&0===e.length)return null;if(t.converter?.toAttribute)return t.converter.toAttribute(e,t.type);switch(t.type||Ie(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 ke:return Array.isArray(e)?ke.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 Ge=new WeakSet,Qe=new Map;function Je(e,t){const n=e.constructor[K];if(n&&Array.isArray(n)&&0!==n.length){e[O]?e[O].observers||(e[O].observers=[]):e[O]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?Ue(n,o.options.throttle):n;switch(o.type){case"intersection":Xe(e,t,o,r);break;case"resize":Ye(e,t,o,r);break;case"media":Ze(e,0,o,r);break;case"mutation":et(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function Xe(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[O].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function Ye(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[O].observers.push(()=>{s.disconnect()})}function Ze(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=Qe.get(r);if(!s)try{s=window.matchMedia(r),Qe.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[O].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[O].observers.push(()=>{s.removeListener(a)}))}function et(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),h=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)}}),u=!0===e[r];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):u&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{h.observe(e,c)}),e[O].observers.push(()=>{h.disconnect()})}function tt(e){if(e[O]?.observers){for(const t of e[O].observers)t();e[O].observers=[]}}const nt="@context/request",ot=new WeakMap;function rt(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=function(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}(e);if(t){const e={};if(t.dispatchEvent(new CustomEvent(nt,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[V]?n[V]:!0===n[r]&&void 0!==n.element?.[V]?n.element[V]:void 0}function st(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[s]}function it(e){if(!st(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 at(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=rt(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[r]?"controller":st(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(!st(o))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=it(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 ct(e){return st(e)?function(e){return it(e).target}(e):!0===e?.[r]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}function lt(e,t){const n=e.constructor[c];if(n){e[O]||(e[O]={events:[],channels:[]});for(const o of n){const n=o.method.bind(e),r=`@request/${o.channelName}`;let s,i,a=0;const c=[];let l=null;const h=(e=>o.options?.debounce?(...t)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{n(await e(...t))}catch(e){r(e)}},o.options.debounce)}):o.options?.throttle?(...t)=>{const n=Date.now(),r=o.options.throttle-(n-a);if(r<=0){clearTimeout(i),i=null,a=n;const o=c.splice(0);l=null;const r=e(...t);return o.length&&Promise.resolve(r).then(e=>{for(const t of o)t.resolve(e)},e=>{for(const t of o)t.reject(e)}),r}return l=t,new Promise((n,o)=>{c.push({resolve:n,reject:o}),i||(i=setTimeout(async()=>{a=Date.now(),i=null;const n=c.splice(0),o=l??t;l=null;try{const t=await e(...o);for(const e of n)e.resolve(t)}catch(e){for(const t of n)t.reject(e)}},r))})}:e)(n),u=e=>{const{data:t,discovery:n,payload:r}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),Promise.resolve(h(r)).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${o.methodName}:`,e)})};let d=t;if(void 0!==o.options?.daemon)try{d=at(e,o.options.daemon)}catch(e){console.warn(`[snice/@respond] ${e.message} Responder "${o.channelName}" skipped.`);continue}d.addEventListener(r,u),e[O].channels.push(()=>{d.removeEventListener(r,u)})}}}function ht(e){if(e[O]?.channels){for(const t of e[O].channels)t();e[O].channels=[]}}const ut=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function dt(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();ut.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 ft(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=mt(e)}return o}function mt(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 pt(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 yt=n("on-handlers");function gt(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const vt=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function bt(e,t){const n=e.constructor[yt];if(n&&Array.isArray(n)&&0!==n.length){e[O]?e[O].events?e[O].events.length>0&&wt(e):e[O].events=[]:e[O]={events:[],channels:[],observers:[]};for(const o of n){const n=e[o.methodName];let r=n?n.bind(e):o.method.bind(e);const s=o.options||{},i=["keydown","keyup","keypress"].includes(o.eventName.split(".")[0].split(":")[0]),a=i?o.eventName.indexOf("."):-1,c=i?o.eventName.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c),h=l>0?o.eventName.substring(0,l):o.eventName,u=l>0?o.eventName.substring(l+1):null;l<=0&&dt(o.eventName),s.debounce&&s.debounce>0?r=ze(r,s.debounce):s.throttle&&s.throttle>0&&(r=gt(r,s.throttle));let d=null;u&&["keydown","keyup","keypress"].includes(h)&&(d=ft(u));const f=(e=>d?t=>{pt(t,d)&&e(t)}:e)(r),m=void 0!==s.scope,p=void 0!==s.daemon;if(m&&p){console.warn(`[snice/@on] "${o.eventName}" cannot use both scope and daemon — listener skipped.`);continue}if((p||st(e))&&o.selector){console.warn(`[snice/@on] "${o.eventName}" cannot delegate "${o.selector}" on a daemon target — listener skipped.`);continue}const y=m||p;let g=null;if(p)try{g=at(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(m&&(g=He(t,s.scope),!g)){console.warn(`[snice/@on] scope did not resolve for "${o.eventName}" on ${o.methodName} — listener skipped.`);continue}if(o.selector){const n=y?g:t.shadowRoot||t,r=e=>{const t=e.target;if(t.matches&&t.matches(o.selector)&&t||t.closest&&t.closest(o.selector)){s.preventDefault&&e.preventDefault(),s.stopPropagation&&(e.stopPropagation(),e.stopImmediatePropagation());try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},i=vt.has(h),a={capture:void 0!==s.capture?s.capture:i,once:s.once||!1,passive:s.passive||!1};n.addEventListener(h,r,a),e[O].events.push({target:n,eventName:h,handler:r,options:a})}else{const n=y?null:t.shadowRoot,r=Symbol(),i=e=>{if(!e[r]){e[r]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&e.stopPropagation();try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};if(y){g.addEventListener(h,i,a),e[O].events.push({target:g,eventName:h,handler:i,options:a});continue}n&&(n.addEventListener(h,i,a),e[O].events.push({target:n,eventName:h,handler:i,options:a})),t.addEventListener(h,i,a),e[O].events.push({target:t,eventName:h,handler:i,options:a})}}}}function wt(e){if(e[O]?.events){for(const{target:t,eventName:n,handler:o,options:r}of e[O].events)t.removeEventListener(n,o,r);e[O].events=[]}}class Et{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 Nt(e,n){if(t.controllerRegistry.has(n))return void queueMicrotask(()=>{const t=e[T];(void 0===t?e[v]:t)===n&&_t(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 St(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}function Tt(e,t){if(null===t){if(!e.hasAttribute("controller"))return}else if(e.getAttribute("controller")===t)return;e[C]=!0;try{null===t?e.removeAttribute("controller"):e.setAttribute("controller",t)}finally{delete e[C]}}function At(e){if(!e[_])return!1;const t=e[E];return"function"==typeof t&&(Tt(e,function(e){const t=Object.prototype.hasOwnProperty.call(e,A)?e[A]:void 0;return"string"==typeof t?t:St(e)}(t)),!0)}async function _t(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 "${St(n)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=St(n),a=e[w],c=e[T];if("string"==typeof n&&void 0!==c&&c!==n)return;if(e[E]===n&&a)return void("string"!=typeof n&&At(e));if(a&&(await Ct(e),e[w]&&e[E]===n))return void("string"!=typeof n&&At(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 h=new l;"string"!=typeof n&&(e[_]=!0,delete e[T]),t.controllerIdCounter+=1;const u=t.controllerIdCounter,d=new Et;h[r]=!0,h[N]=u,h.element=e;const f=e[V];void 0!==f&&(h[V]=f),e[w]=h,e[E]=n,e[S]=d,"string"!=typeof n&&At(e);const m=new AbortController;e[Ce]=m;try{await Promise.race([e.ready,new Promise((e,t)=>{const n=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",t(e)};if(m.signal.aborted)return n();m.signal.addEventListener("abort",n,{once:!0});const o=setTimeout(()=>t(new Error(`attachController("${i}"): element did not become ready within 30000ms (did you forget to appendChild it?)`)),3e4);m.signal.addEventListener("abort",()=>clearTimeout(o),{once:!0})})])}catch(t){throw e[w]===h&&("string"!=typeof n&&Tt(e,null),delete e[w],delete e[E],delete e[S],"string"!=typeof n&&delete e[_]),t}finally{e[Ce]===m&&delete e[Ce]}h[xe]=!0,await d.runOperation(async()=>{await h.attach(e)}),Je(h,e),lt(h,e),bt(h,e),e.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:h}}))}async function Ct(e){const t=e[Ce];t&&t.abort();const n=e[w],o=e[E],r=e[S];n&&("function"==typeof o&&Tt(e,null),delete e[w],delete e[E],delete e[S],"function"==typeof o&&delete e[_],n[xe]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),n.element=null,tt(n),ht(n),wt(n),r&&await r.cleanup(),delete n[V],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:St(o),controller:n}}))))}function xt(){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[_])return void At(e);const t=e.getAttribute("controller"),n=e[T];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[T],delete e[E],void Ct(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[T]=t,e.ready||(e.ready=Promise.resolve()),n&&Ct(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),_t(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):Nt(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 Ot=n("context-handlers");function kt(e){const t=e.constructor[Ot];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[ae];if(n){e[ce]=n;for(const o of t){const{methodName:t,method:r,options:s}=o,i=`__wrapped_${t}`;e[i]=function(n){const o=e[pe]||(e[pe]=new Set);if(s.once&&o.has(t))return;const a=()=>{if(r.call(e,n),s.once){o.add(t);const n=e[ce];n&&"function"==typeof n[de]&&n[de](e,i)}},c=e[me]||(e[me]={}),l=t;if(s.debounce)return clearTimeout(c[l]?.timeout),void(c[l]={timeout:setTimeout(a,s.debounce)});if(s.throttle){const e=Date.now();return void(e-(c[l]?.lastCall||0)>=s.throttle&&(c[l]={lastCall:e},a()))}a()},"function"==typeof n[ue]&&n[ue](e,i)}}}const $t=Symbol.for("snice:html-result"),Lt=Symbol.for("snice:css-result"),Pt=new WeakMap;function jt(e){return e&&e._$litType$===$t}function Mt(e){return e&&e._$litType$===Lt}const Rt=Symbol.for("snice:nothing"),It=Symbol.for("snice:unsafe-html");function Dt(e){return e&&e._$litType$===It}const Vt=Symbol.for("snice:repeat-result"),qt=new WeakSet;function Bt(e){return e[y]||e.shadowRoot||null}function Ft(e){const t=Bt(e);if(t)return t;const n=e.constructor[g];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[y]=o,qt.add(e),o}function Wt(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&qt.has(n))return n;n=n.parentNode}return null}const zt=`snice$${Math.random().toFixed(9).slice(2)}$`,Ut="?"+zt,Ht=`\x3c!--${Ut}--\x3e`,Kt=new RegExp(zt.replace(/\$/g,"\\$"),"g"),Gt=new WeakMap,Qt=Symbol("not-committed");function Jt(e,t){const n=e.localName;if(!n?.includes("-"))return;const o=e.ownerDocument?.defaultView?.customElements??globalThis.customElements;if(o?.get(n))return;const r=e;r[M]||(r[M]=new Set),r[M].add(t)}const Xt=Symbol.for("snice:no-change"),Yt=Symbol.for("snice:live"),Zt=e=>null===e||"object"!=typeof e&&"function"!=typeof e,en=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class tn{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(zt))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(zt))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(zt))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(zt))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(zt)&&(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(zt)){o.push(i);const t=n[r]||i.name,s=a.split(zt),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===Ut){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(zt)){const t=e.data.split(Kt);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(zt)){const n=e.parentNode,o=t.split(Kt),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 nn(e){const{strings:t}=e,n=Gt.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(zt);else if(i)r.push(l),o.push(zt);else if(s){const e=n.trimEnd();if(e.endsWith("=")){let t=e.length-2;for(;t>=0&&/[\w\-\.@\?\/:\+~|]/.test(e[t]);)t--;l=e.substring(t+1,e.length-1).trim(),r.push(l),o.push(zt)}else{if(!n.match(/<(if|else-if|case|when)\s*$/))throw new Error("snice: expressions directly in opening tags are not supported; use an explicit attribute, property, event, class, style, or named spread binding.");l="value",r.push("value"),o.push(`value="${zt}"`)}}else r.push(""),o.push(Ht)}}const h=o.join(""),u=document.createElement("template");if(e.svg){u.innerHTML=`<svg>${h}</svg>`;const e=u.content.firstElementChild;for(;e.firstChild;)u.content.insertBefore(e.firstChild,e);u.content.removeChild(e)}else u.innerHTML=h;const d=new tn(e,u,r);return Gt.set(t,d),d}function on(e){if(!jt(e))return;const t=nn(e);return-1===t.keyIndex?void 0:e.values[t.keyIndex]}class rn{constructor(e){this.parts=[],this.fragment=null,this.conditionalParts=[],this.regularParts=[],this.template=nn(e),this.strings=e.strings}isSameTemplate(e){return this.strings===e}renderFragment(){if(!this.fragment){this.fragment=this.template.element.content.cloneNode(!0);const e=document.createTreeWalker(this.template.element.content,NodeFilter.SHOW_ALL),t=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ALL),n=new Map;let o=e.currentNode,r=t.currentNode;for(;o&&r;)n.set(o,r),o=e.nextNode(),r=t.nextNode();const s=new Set;for(const e of this.template.parts)"conditional-when"===e.type&&s.add(n.get(e.element));for(let e=0;e<this.template.parts.length;e++){const t=this.template.parts[e];let o;switch(t.type){case"node":const e=n.get(t.startNode),r=n.get(t.endNode);o=new an(e,r);break;case"attribute":const i=n.get(t.element);o=new cn(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new fn(a,t.name);break;case"boolean-attribute":const c=n.get(t.element);o=new pn(c,t.name);break;case"event":const l=n.get(t.element);o=new yn(l,t.name);break;case"class":const h=n.get(t.element);o=new hn(h,t.name);break;case"style":const u=n.get(t.element);o=new un(u,t.name);break;case"spread":const d=n.get(t.element);o=new dn(d,t.name);break;case"controller":const f=n.get(t.element);o=new mn(f);break;case"conditional-if":const m=n.get(t.element);o=new vn(m);break;case"conditional-else-if":const p=n.get(t.element);o=new wn(p);break;case"conditional-case":const y=n.get(t.element);o=new En(y,s);break;case"conditional-when":const g=n.get(t.element);o=new Sn(g);break;case"comment":const v=n.get(t.startNode);o=new ln(v,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof vn||o instanceof wn||o instanceof En||o instanceof Sn?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 wn||e instanceof Sn?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof vn||n instanceof En)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof cn&&void 0!==t.strings||t instanceof ln?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 an extends sn{constructor(e,t){super(),this.type="node",this._committedValue=Qt,this._itemKeys=null,this._asyncSource=null,this._asyncVersion=0,this._asyncIterator=null,this._asyncRunning=!1,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1,this._committingAsyncValue=!1,this.startNode=e,this.endNode=t}commit(e){if(e!==Xt)if((e=>!!e&&"function"==typeof e.then)(e)||en(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==Rt&&null!=e&&""!==e)Zt(e)?e!==this._committedValue&&this._commitText(e):jt(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===Vt}(e)?0===e.values.length?this.commit(e.empty??Rt):this._commitIterable(e.values,e.keys):Dt(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!==Rt){const e=this._clear();if(this._committedValue=Rt,e)throw e}this._committedValue=Rt}}_commitText(e){if(this._committedValue!==Qt&&this._committedValue!==Rt&&Zt(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 rn){const n=Gt.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new rn(e),o=n.renderFragment();try{n.update(e.values)}catch(e){throw n.clear(),e}const r=this._committedValue,s=this._itemKeys,i=this.endNode.ownerDocument.createDocumentFragment();let a=this.startNode.nextSibling;for(;a&&a!==this.endNode;){const e=a.nextSibling;i.appendChild(a),a=e}this._insertBefore(o),this._committedValue=n,this._itemKeys=null;try{this.isConnected&&n.reconnected()}catch(e){try{n.clear()}catch(e){console.error("snice: failed to clean up a rejected nested template:",e)}let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const e=t.nextSibling;t.remove(),t=e}throw this._insertBefore(i),this._committedValue=r,this._itemKeys=s,e}this._disposeCommitted(r)}_commitIterable(e,t){const n=Array.isArray(e)?e:Array.from(e),o=t?Array.from(t):n.map(on);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 an||(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 an(e,n),c.push(t)}else t=c[l];t.commit(e),l++}if(l<c.length){for(let e=l;e<c.length;e++){const t=c[e];try{t.destroy()}catch(e){s??=e}t.startNode.remove(),t.endNode.remove()}c.length=l}if(this._itemKeys=i?o:null,s)throw s}_reconcileKeyed(e,t,n,o){const r=this.endNode.parentNode;let s;const i=new Map;for(let e=0;e<n.length;e++)i.has(o[e])||i.set(o[e],n[e]);const a=new Set,c=new Array(e.length).fill(null);for(let n=0;n<e.length;n++){const e=i.get(t[n]);e&&!a.has(e)&&(a.add(e),c[n]=e)}for(const e of n)if(!a.has(e)){try{e.destroy()}catch(e){s??=e}e.startNode.remove(),e.endNode.remove()}let l=this.startNode.nextSibling;for(let t=0;t<c.length;t++){let n=c[t];if(n)if(n.startNode===l)l=n.endNode.nextSibling;else{const e=document.createDocumentFragment();let t=n.startNode;const o=n.endNode.nextSibling;for(;t&&t!==o;){const n=t.nextSibling;e.appendChild(t),t=n}r.insertBefore(e,l)}else{const e=document.createComment(""),o=document.createComment("");r.insertBefore(e,l),r.insertBefore(o,l),n=new an(e,o),c[t]=n}n.commit(e[t])}return this._committedValue=c,s}_commitNode(e){if(this._committedValue!==e){const t=this._clear();if(this._insertBefore(e),this._committedValue=e,t)throw t}}_commitUnsafeHTML(e){const t=this._committedValue;if(Dt(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=Rt,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:",e)}(async()=>{try{for(;this._asyncIterator;){const e=await this._asyncIterator.next();if(e.done||n!==this._asyncVersion)break;this._commitAsyncValue(e.value)}}catch(e){n===this._asyncVersion&&console.error("snice: async iterable template value failed:",e)}finally{n===this._asyncVersion&&(this._asyncIterator=null,this._asyncRunning=!1,this._asyncCompleted=!0)}})()}else Promise.resolve(t).then(e=>{if(n===this._asyncVersion){this._asyncRunning=!1,this._asyncCompleted=!0;try{this._commitAsyncValue(e)}catch(e){console.error("snice: promise template value failed:",e)}}},e=>{n===this._asyncVersion&&(this._asyncRunning=!1,this._asyncCompleted=!0,console.error("snice: promise template value failed:",e))})}_commitAsyncValue(e){this._committingAsyncValue=!0;try{this.commit(e)}finally{this._committingAsyncValue=!1}}_cancelAsync(e){this._asyncVersion++;const t=this._asyncIterator;if(this._asyncIterator=null,this._asyncRunning=!1,e&&(this._asyncSource=null,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1),t?.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}_insertBefore(e){this.endNode.parentNode?.insertBefore(e,this.endNode)}_clear(){const e=this.startNode.parentNode,t=this._committedValue;let n;try{this._disposeCommitted(t)}catch(e){n=e}if(!e)return this._committedValue=Rt,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=Rt,n}_disposeCommitted(e){let t;if(e instanceof rn)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof an)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 rn)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof an)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 rn)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof an)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class cn extends sn{constructor(e,t,n){super(),this.type="attribute",this._committedValue=Qt,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(Qt),this.strings=n):this._committedValue=Qt}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===Xt)return;if(o=!Zt(e)||e!==this._committedValue&&e!==Xt,!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===Xt&&(i=s[e],i===Qt&&(i="")),o=o||!Zt(i)||i!==s[e],i===Rt?n=Rt:n!==Rt&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===Rt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class ln 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(Qt)}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===Xt&&(s=this._committedValues[e],s===Qt&&(s="")),o=o||!Zt(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===Rt?"":s??"")+this.strings[e+1]}if(o){if(r.includes("--")||r.endsWith("-"))throw new Error('snice: comment expressions cannot produce "--" or end with "-".');this.node.data=r}}clear(){}}class hn extends sn{constructor(e,t){super(),this.type="class",this.committed=Qt,this.element=e,this.name=t}commit(e){if(e===Xt)return;const t=e!==Rt&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=Qt}}class un extends sn{constructor(e,t){super(),this.type="style",this.committed=Qt,this.element=e,this.name=t}commit(e){if(e===Xt||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===Rt||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=Qt}}class dn extends sn{constructor(e,t){super(),this.type="spread",this.committed={},this.listeners=new Map,this.consumedOnce=new Map,this.element=e,this.name=t}commit(e){if(e===Xt)return;if(e!==Rt&&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)||(Jt(this.element,t),this.element[t]=void 0);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(Jt(this.element,t),this.element[t]=n===Rt?void 0:n)}commitAttributes(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||this.element.removeAttribute(t);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(n===Rt||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!==Rt&&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===Rt||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 Wt(this.element)||this.element}clear(){if("events"===this.name){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear(),this.consumedOnce.clear()}else if("props"!==this.name&&"properties"!==this.name)for(const e of Object.keys(this.committed))this.element.removeAttribute(e);this.committed={}}disconnected(e=!1){"events"!==this.name||e||this.detachListeners()}reconnected(){"events"===this.name&&0===this.listeners.size&&this.commitEvents(this.committed)}detachListeners(){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear()}}class fn extends sn{constructor(e,t){super(),this.type="property",this._committedValue=Qt,this.element=e,this.name=t}commit(e){if(e!==Xt){if(function(e){return e&&e._$liveMarker$===Yt}(e)){if((e=e.value)===Xt)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,Jt(this.element,this.name),this.element[this.name]=e===Rt?void 0:e}}clear(){this._committedValue=Qt}}class mn extends sn{constructor(e){super(),this.type="controller",this._committedValue=Qt,this.element=e}commit(e){if(e===Xt)return;const t=null==e||!1===e||""===e||e===Rt?null:e,n=this._committedValue===Qt,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[x]?delete r[x]:r[a]?r.controller=null:this._detach()),"function"==typeof t?this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[a]&&(r[x]=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[x]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){_t(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){Ct(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[x]&&(t[a]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[x]&&delete e[x];const t=this._committedValue;this._committedValue=Qt,"function"==typeof t&&(e[a]||this._detach())}}class pn extends sn{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=Qt,this.element=e,this.name=t}commit(e){if(e===Xt)return;const t=!!e&&e!==Rt;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=Qt}}class yn 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=ft(t)}else this.eventName=n,dt(n)}commit(e){if(e===Xt)return;e===Rt&&(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&&!pt(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=Wt(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 gn=Symbol("not-set");class vn extends sn{constructor(e){super(),this.type="node",this.conditions=[gn],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]=gn,bn.set(n,{coordinator:this,index:i})}else{if(-1!==this.defaultBranch)throw new Error("snice: <if> may contain only one <else> branch.");this.defaultBranch=i}n.remove();continue}o?t.nodeType!==Node.TEXT_NODE||t.textContent?.trim()?r.appendChild(t):t.remove():n.appendChild(t)}t.removeChild(e)}commit(e){e!==Xt&&(this.conditions[0]=e)}setAlternative(e,t){t!==Xt&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==gn&&this.conditions[t]!==Rt&&Boolean(this.conditions[t])){e=t;break}-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e],this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch];let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const bn=new WeakMap;class wn extends sn{constructor(e){super(),this.type="node";const t=bn.get(e);if(!t)throw new Error("snice: <else-if> must be a direct child of <if>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setAlternative(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}class En extends sn{constructor(e,t){super(),this.type="node",this.value=gn,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?gn:n.getAttribute("value")??""})-1;o&&Nn.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:gn})-1}}n.removeChild(e)}commit(e){e!==Xt&&(this.value=e)}setExpected(e,t){t!==Xt&&(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 Nn=new WeakMap;class Sn extends sn{constructor(e){super(),this.type="node";const t=Nn.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}}let Tn=!1;function An(e){e[f]||(e[d]=new Promise(t=>{e[f]=t}))}function _n(e){const t=e[f];t&&(e[f]=null,t())}const Cn=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?$n(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?$n(t,t[Z]||{}):t[m]=!0}remove(e){this.pending.delete(e)}};function xn(e){return Object.prototype.hasOwnProperty.call(e,ee)}function On(e){const t=e[ne];if(!t||0===t.length)return;const n=[...t];e[ne]=[],n.forEach(e=>e())}const kn=50;function $n(e,t,n){const o=arguments.length>=3,r=e[Y];if(!r)return void _n(e);if(t.once&&xn(e))return void _n(e);const s=e[p]??0;if(s>=kn){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${kn}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void _n(e)}e[p]=s+1;try{const s=o?n:r.call(e),i=Ft(e);if(!1===t.differential){if("string"!=typeof s)return void console.warn("Render method with differential: false must return a string");const t=document.createElement("template");t.innerHTML=s;const n=e[ee];n?.clear();const o=Array.from(i.childNodes).filter(e=>!(e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")));for(const e of o)e.remove();return i.appendChild(t.content),e[ee]=null,void On(e)}if(!jt(s))return void console.warn("Render method must return html`` template result");let a=e[ee];if(a&&a.isSameTemplate(s.strings))return a.update(s.values),void On(e);const c=new rn(s),l=c.renderFragment();try{c.update(s.values)}catch(e){throw c.clear(),e}const h=document.createDocumentFragment();for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||h.appendChild(e);i.appendChild(l);try{e.isConnected&&c.reconnected()}catch(e){try{c.clear()}catch(e){console.error("snice: failed to clean up a rejected render tree:",e)}for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||e.remove();throw i.appendChild(h),e}let u;e[ee]=c;try{a?.clear()}catch(e){u=e}if(On(e),u)throw u}catch(e){if(Tn)throw e;console.error("Error rendering element:",e)}finally{e[p]=s,_n(e)}}function Ln(e,t=!1){const n=e[Z]||{};if(n.once&&xn(e))e.isConnected&&Pn(e);else if(An(e),t)$n(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[te]||(e[te]={}),clearTimeout(e[te].debounce),void(e[te].debounce=setTimeout(()=>{e[te].debounce=null,Cn.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[te]||(e[te]={lastThrottle:0});const t=e[te],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void Cn.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),Cn.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}Cn.schedule(e,n)}}function Pn(e){const t=e[ee];t?.reconnected()}function jn(e){const t=e[X];if(t)for(const e of t.values())e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.throttleTimeout&&clearTimeout(e.throttleTimeout),e.debounceTimeout=null,e.throttleTimeout=null,e.throttleLastCall=0,e.latestDetail=void 0}const Mn=n("debounce-timers"),Rn=n("throttle-timers"),In=n("once-called"),Dn=n("memoize-cache");function Vn(e){if(e[Mn]){for(const t in e[Mn])e[Mn][t]?.timeout&&clearTimeout(e[Mn][t].timeout);e[Mn]={}}}function qn(e){if(e[Rn]){for(const t in e[Rn])e[Rn][t]?.timeout&&clearTimeout(e[Rn][t].timeout);e[Rn]={}}}function Bn(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 Fn(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");const s=e[k];if(s)for(const[e,t]of s){if(!1===t.attribute)continue;const n=qe(t,e);r.includes(n)||r.push(n)}Object.defineProperty(e,"observedAttributes",{get:()=>r,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get(){return this[h]||(this[h]=new Promise(e=>{this[u]=e})),this[h]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[f]?this[d]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[v]},set(e){const t=this[v];if(this[v]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void _t(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):Nt(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&Ct(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[h]||(this[h]=new Promise(e=>{this[u]=e})),this[b]){try{Pn(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}bt(this,this),lt(this,this),kt(this);try{Je(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[z];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 void(this[Y]&&this[m]&&(this[m]=!1,Ln(this)))}this[R]=!0;const n=e[k];if(n)for(const[e,t]of n){if(!1===t.attribute)continue;const n=qe(t,e);if(!this.hasAttribute(n))continue;const o=this.getAttribute(n);Be(this,D).add(e),t.type===Boolean&&""===o&&this.setAttribute(n,"true"),this[e]=De(o,t)}if(this[j]){for(const[e,t]of Array.from(this[j].entries())){const o=n?.get(e),r=qe(o||{},e);this[j].delete(e),this.hasAttribute(r)||(this[e]=t)}delete this[j]}if(void 0!==this[x]){const e=this[x];if(delete this[x],!this[v]){this[v]=e;const t=e?.name||"(anonymous controller class)";_t(this,e).catch(e=>{"ControllerAttachAborted"!==e?.name?console.error(`Failed to attach controller "${t}":`,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}if(this.hasAttribute("controller")&&!this[v]){const e=this.getAttribute("controller");e&&(this.controller=e)}!function(e){const t=e[oe],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)Mt(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[re]){e[re]=!0;try{const o=[...n],r=e[se];if(r)for(const t of r){const n=t.call(e);Mt(n)&&o.push(n)}if(t){const n=t.call(e);if(!Mt(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=Ft(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),bt(this,this),lt(this,this),kt(this),this[b]=!0,function(e,t){if(Ge.has(t))return;Ge.add(t);const n=t[I];if(!n||0===n.size)return;const o=t[k],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[I],o=t[k];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[F];if(await new Promise(e=>queueMicrotask(e)),this.isConnected){this[Y]&&Ln(this,!0);try{Je(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName}:`,e)}if(await new Promise(e=>queueMicrotask(e)),this.isConnected){if(o)for(const e of o)try{await e.method.call(this)}catch(t){console.error(`Error in @ready handler ${e.methodName}:`,t)}this[u]&&(this[u](),this[u]=null)}else this[u]&&(this[u](),this[u]=null)}else this[u]&&(this[u](),this[u]=null)},e.prototype.disconnectedCallback=async function(){try{!function(e){const t=e[ee];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[W];if(t)for(const e of t)try{await e.method.call(this)}catch(t){console.error(`Error in @dispose handler ${e.methodName}:`,t)}n&&n.call(this),this[v]&&Ct(this).catch(e=>{console.error("Failed to detach controller:",e)}),wt(this),ht(this),function(e){const t=e.constructor[Ot];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[me];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[me]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[ce];o&&"function"==typeof o[de]&&o[de](e),delete e[ce],delete e[pe]}(this),tt(this),Vn(this),qn(this),function(e){const t=e[te];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[m]=!0),jn(this),Qn(this,Q),Qn(this,J)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t){if(this[C])return;return this[_]?void At(this):void(this.controller=r)}const s=e[k];if(s)for(const[n,o]of s){if(qe(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[G]?.has(t.toLowerCase()))break;const s=this[$]?.[n],i=this[L]?.[n];let a=null===r?o.type!==Boolean&&i:De(r,o,s,i);const c=this[P]?.[n];if(c&&(a=c(a)),!(o?.hasChanged?o.hasChanged(a,s):Ve(a,s)))break;Be(this,D).add(n),Fe(this,$)[n]=a,this[b]&&We(this,e,n,s,a),this[Y]&&this[b]&&Ln(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[U];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[H];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function Wn(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[k]){e[k]||(e[k]=new Map);for(const[n,o]of t[k])e[k].has(n)||e[k].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[k]){t[k]||(t[k]=new Map);for(const[e,o]of n.metadata[k])t[k].set(e,o)}else if(zn.length>0){t[k]||(t[k]=new Map);const e=zn.pop();for(const[n,o]of e)t[k].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[g]||{}},s=o||{};if("light"===s.renderRoot&&"string"==typeof s.shadow||"shadow"===s.renderRoot&&!1===s.shadow)throw new TypeError("snice: @element renderRoot and shadow options select conflicting render roots.");const i={...r,...s};return Object.prototype.hasOwnProperty.call(s,"shadow")?i.renderRoot=!1===s.shadow?"light":"shadow":Object.prototype.hasOwnProperty.call(s,"renderRoot")&&("light"===s.renderRoot?i.shadow=!1:!1===i.shadow&&(i.shadow="open")),t[g]=i,!0===t.prototype[ie]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,Y)&&"function"==typeof t.prototype.render&&(t.prototype[Y]=t.prototype.render,t.prototype[Z]=t.renderOptions||{}),Fn(t),customElements.get(e)?(globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),t)}const zn=[],Un=new WeakMap;function Hn(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[k]||(n.metadata[k]=new Map),n.metadata[k].set(o,e||{})):(0===zn.length&&zn.push(new Map),zn[zn.length-1].set(o,e||{})),function(t){const n=this[M],r=!0===n?.delete(o);0===n?.size&&delete this[M];const s=Object.prototype.hasOwnProperty.call(this,o),i=s&&(r||!function(e,t,n){const o=e?.ownerDocument;if(!o?.createElement)return!1;let r=Un.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);Un.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[k]||(c[k]=new Map);const l={...e};l.type||void 0===t||(l.type=Ie(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[k].set(o,l),Fe(this,L)[o]=t;const h=()=>{if(!this[R])return;const e=this[$]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=qe(l,o),r=Ke(e,l,t),s=n.toLowerCase();Be(this,G).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[G].delete(s)}}this[b]&&(We(this,this.constructor,o,e,e),this[Y]&&Ln(this))},u=e=>{if(!l.deep)return e;let t;return t=function(e,t){if(!e||"object"!=typeof e)return e;const n=new WeakMap,o=new WeakMap,r=e=>e&&"object"==typeof e&&o.get(e)||e,s=e=>{if(!e||"object"!=typeof e)return e;if(n.has(e))return n.get(e);if(e instanceof Map){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=Bn(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=Bn(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=Bn(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[$]?.[o]===t&&h()}),t};Fe(this,P)[o]=u;const d=this.constructor.prototype;let f=d[Oe];f&&Object.prototype.hasOwnProperty.call(d,Oe)||(f=new Map(f),d[Oe]=f);const m=f.get(o);m&&m===e||(f.set(o,e),Object.defineProperty(this.constructor.prototype,o,{get(){return this[j]?.has(o)?this[j].get(o):this[$]&&o in this[$]?this[$][o]:t},set(e){const t=this[o];if(!(l.hasChanged?l.hasChanged(e,t):Ve(e,t)))return;const n=(this[P]?.[o]||(e=>e))(e);if(!this[R])return this[j]||(this[j]=new Map),void this[j].set(o,n);if(Fe(this,$)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=qe(l,o),t=Ke(n,l,this[L]?.[o]);Be(this,D).add(o);const r=e.toLowerCase();Be(this,G).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[G].delete(r)}}this[b]&&(We(this,this.constructor,o,t,n),this[Y]&&Ln(this))},configurable:!0,enumerable:!0}));const p=u(t);return Fe(this,$)[o]=p,Fe(this,L)[o]=p,i?a:p}}}function Kn(e){return!0===e[r]&&e.element?e.element:e}function Gn(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 Qn(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 Jn(e,t,n){return function(o={}){return function(r,s){Gn(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 Xn=Jn(U,Q,Ae),Yn=Jn(H,J,_e);class Zn extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[g];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return Ln(this),this.rendered}renderNow(){return An(this),$n(this,{...this[Z]||{},once:!1}),this.rendered}}Object.defineProperty(Zn.prototype,ie,{value:!0});class eo{constructor(e){this.parsed=this.parsePattern(e)}get spec(){return this.parsed.template}parsePattern(e){let t=e,n="",o=!1;const r=e.indexOf("?");return-1!==r&&(t=e.slice(0,r),n=e.slice(r+1),t.endsWith("(")&&n.endsWith(")")&&(o=!0,t=t.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(t),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:e}}parseSegments(e){const t=[];let n=0;for(;n<e.length;)switch(e[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(e,n);t.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(e,n+1);t.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(e,n+1);t.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:h}=this.parseLiteral(e,n);l&&t.push({type:"literal",value:l}),n=h}return t}parseOptionalGroup(e,t){let n=1,o=t+1;for(;o<e.length&&n>0;)"("===e[o]&&n++,")"===e[o]&&n--,o++;const r=e.slice(t+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(e,t){let n=t;for(;n<e.length&&/[\w-]/.test(e[n]);)n++;return{name:e.slice(t,n),endIndex:n}}parseLiteral(e,t){let n=t;for(;n<e.length&&!"(:*(".includes(e[n]);)n++;return{value:e.slice(t,n),endIndex:n}}parseQuerySegments(e){let t=e;t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1));const n=[];let o=0;for(;o<t.length;)if(":"===t[o]){const{name:e,endIndex:r}=this.parseIdentifier(t,o+1);n.push({type:"param",name:e}),o=r}else{const{value:e,endIndex:r}=this.parseQueryLiteral(t,o);e&&n.push({type:"literal",value:e}),o=r}return n}parseQueryLiteral(e,t){let n=t;for(;n<e.length&&":"!==e[n];)n++;return{value:e.slice(t,n),endIndex:n}}getAllParamNames(){const e=new Set,t=n=>{for(const o of n)switch(o.type){case"param":case"splat":e.add(o.name);break;case"optional":t(o.segments)}};return t(this.parsed.pathSegments),t(this.parsed.querySegments),Array.from(e)}canMatchRemainingSegments(e,t,n){let o=t;for(const t of n)if("literal"===t.type){const n=e.indexOf(t.value,o);if(-1===n)return!1;o=n+t.value.length}return!0}match(e){const[t,n]=e.split("?"),o=this.matchPath(t,this.parsed.pathSegments);if(!1===o)return!1;const r=this.matchQuery(n||"",this.parsed.querySegments);if(!1===r)return!1;const s=this.getAllParamNames(),i={};for(const e of s)i[e]=void 0;return Object.assign(i,o,r),i}matchPath(e,t){const n={};let o=0;for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1),a=this.matchSegment(e,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<e.length)&&n}matchSegment(e,t,n,o=[]){switch(n.type){case"literal":return e.slice(t,t+n.value.length)===n.value&&{params:{},nextIndex:t+n.value.length};case"param":{let r=t;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=e.indexOf(s.value,t);if(-1===n)return!1;r=n}else for(;r<e.length&&!a.includes(e[r]);)r++;if(r===t)return!1;try{i=decodeURIComponent(e.slice(t,r))}catch(n){i=e.slice(t,r)}return!(r<e.length&&"?"===e[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=e.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=e.indexOf(".",t);-1!==n&&(r=n)}else{const n=e.lastIndexOf(s.value);-1!==n&&n>=t&&(r=n)}break;case"param":let n=-1;for(let o=e.length-1;o>=t;o--)if("/"===e[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=e.length-1;n>t;n--)if("/"===e[n]){o=n+1;break}if(-1!==o)r=o;else{const n=e.slice(t).split("/").filter(e=>e);r=n.length>1?t+n.slice(0,-1).join("/").length+1:t}break;case"optional":const i=e=>{for(const t of e){if("literal"===t.type)return t.value;if("optional"===t.type){const e=i(t.segments);if(e)return e}}return null},a=i(s.segments);if(a){const n=e.lastIndexOf(a);-1!==n&&n>=t&&(r=n)}}const i=e.indexOf("?",t);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(e.slice(t,r))}catch(n){a=e.slice(t,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=t,s={},i=!0;for(let t=0;t<n.segments.length;t++){const o=n.segments[t],a=n.segments.slice(t+1),c=this.matchSegment(e,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}return i&&this.canMatchRemainingSegments(e,r,o)?{params:s,nextIndex:r}:{params:{},nextIndex:t}}default:return!1}}findNextLiteral(e){for(const t of e){if("literal"===t.type)return t;if("optional"===t.type){const e=this.findNextLiteral(t.segments);if(e)return e}}return null}matchQuery(e,t){if(0===t.length)return{};const n={};let o=0;for(const r of t)switch(r.type){case"literal":if(e.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let t,s=o;for(;s<e.length&&"&"!==e[s];)s++;if(s===o)return!1;try{t=decodeURIComponent(e.slice(o,s))}catch(n){t=e.slice(o,s)}n[r.name]=t,o=s;break}}return n}reverse(e={}){const t=this.reverseSegments(this.parsed.pathSegments,e);if(!1===t)return!1;let n=t;if(this.parsed.querySegments.length>0){const t=this.reverseSegments(this.parsed.querySegments,e);if(!this.parsed.queryOptional&&!1===t)return!1;t&&""!==t&&(n+="?"+t)}return n}reverseSegments(e,t,n=!1){let o="";for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in t))return!1;o+=String(t[s.name]);break;case"optional":if(this.hasAllParams(s.segments,t,n)||this.hasLaterOptionalGroupNeedingParams(i,t,s.segments)){const e=this.reverseSegments(s.segments,t,!0);if(!1===e)return!1;o+=e}}}return o}hasLaterOptionalGroupNeedingParams(e,t,n){for(const o of e)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,t))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(e){for(const t of e)if("param"===t.type||"splat"===t.type)return!1;return!0}hasAllParams(e,t,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of e)switch(n.type){case"param":case"splat":i=!1,n.name in t&&void 0!==t[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of e)"optional"===n.type&&this.hasAllParams(n.segments,t,a)&&(r=!0);return!(!o||s)||!(!r||s)||!(!i||!n)}hasOnlyOptionalMissingParams(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(!(n.name in t))return!1}return!0}hasAnyParamInSegments(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(n.name in t)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,t))return!0}return!1}}function to(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 no(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 oo(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 ro(e){if(!st(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=it(e);if(0===t.bindings){t.active=!0;try{bt(e,t.target),lt(e,t.target)}catch(n){throw ht(e),wt(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&&(ht(e),wt(e),jn(e),t.active=!1,t.target=new EventTarget))}}function so(e,t){const n=function(e,t){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(ot.has(e))throw new Error("This root already provides an application context. Release it before providing another.");const n=e=>{const n=e;n.detail&&void 0===n.detail.context&&(n.detail.context=t,n.preventDefault(),n.stopPropagation())};e.addEventListener(nt,n),ot.set(e,{listener:n});let o=!1;return()=>{if(o)return;o=!0;const t=ot.get(e);t?.listener===n&&(e.removeEventListener(nt,n),ot.delete(e))}}(e,t);let o;try{o=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(ro(r)))}}catch(e){for(const e of n.reverse())e();throw e}return()=>{for(const e of n.reverse())e()}}(t)}catch(e){throw n(),e}let r=!1;return()=>{r||(r=!0,n(),o?.())}}const io=new WeakMap;var ao;!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(ao||(ao={}));let co=!1;async function lo(e,t=500){if(customElements.get(e))return;let n=null;co||(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 ho(e,t=500){const n=e.tagName.toLowerCase();await lo(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}let uo=0,fo=null;const mo=Symbol.for("snice:body-scroll-lock");var po;return globalThis[mo]={clear(){uo=0,fo=null}},"undefined"!=typeof document&&xt(),globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(po||(po={})),e.Context=Re,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){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=!1,l=[],h=null,u=null;const d=t.context||{};let f=null,m=null;const p=new Re(d,[],"",{},t.fetcher);function y(e){if(f===e&&m&&io.get(e)===m)return;m?.(),io.get(e)?.();const t=so(e,d);let n=!1;const o=()=>{n||(n=!0,t(),io.get(e)===o&&io.delete(e))};m=o,f=e,io.set(e,o)}function g(e){if(!h||!u)return null;const t=e.querySelectorAll(h);for(const e of t)if(e[B]===u)return e;return null}function v(e,t,n,o,l,h){switch(r.push({route:new eo(e),tag:t,transition:n,guards:o,layout:l,placard:h}),c=!1,e){case"/404":s=t;break;case"/403":i=t;break;case"/":a=t}}function b(){const e=new Set;l=r.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(d):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function w(e,t,n){p[ye](d,l,t,n)}function E(){switch(t.type){case"hash":return n.location.hash.slice(1);case"pushstate":return`${n.location.pathname}${n.location.search}`}}function N(e){let t;if(i)t=o.createElement(i),t[V]=d;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,u=null}async function S(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(d,t))return r&&r()||N(n),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function T(e,n,r,s,i,a,c){const f=!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();u=t;const n=o.createElement(e);return n[V]=d,n[B]=t,{element:n,needsNewLayout:!0}}return u=null,{element:null,needsNewLayout:!0}}(f),v=r||t.transition;if(null!==p||null!==g(e)){if(await async function(e,t,n,o,r,s,i,a){const c=o||g(e);if(!c)return;!function(e,t,n){"function"==typeof e.update&&e.update(d,l,t,n)}(c,s,i);const h=c.querySelector('[slot="page"]');if(n&&h){if(t.setAttribute("slot","page"),await C(c,h,t,n),a&&a())return;r&&(e.innerHTML="",e.appendChild(c))}else a&&a()||(c.querySelectorAll('[slot="page"]').forEach(e=>e.remove()),t.setAttribute("slot","page"),c.appendChild(t),r&&(e.innerHTML="",e.appendChild(c)))}(e,n,v,p,y,i,a,c),c&&c())return;w(0,i,a)}else await async function(e,t,n,o){const r=e.children[0];n&&r?await C(e,r,t,n):o&&o()||(e.innerHTML="",e.appendChild(t))}(e,n,v,c),c&&c()||w(0,i,a)}let A=0;async function _(e){const i=o.querySelector(t.target);if(!i)throw new Error(`Target element not found: ${t.target}`);y(i);const c=++A,l=()=>c!==A;if(b(),n.scrollTo(0,0),(""===e?.trim()||"/"===e)&&a){const t=r.find(e=>e.route.match("/"));if(!await S(t?.guards,{},i,l))return;if(l())return;const{element:s,transition:c,layout:h}=function(){const e=o.createElement(a);e[V]=d;const t=n.customElements.get(a),s=t?.[q],i=r.find(e=>e.route.match("/"));return{element:e,transition:s,layout:i?.layout}}();return void await T(i,s,c,h,e,{},l)}if(!e)return;const h=await async function(e,t,n){for(const s of r){const r=s.route.match(e);if(!1===r)continue;if(!await S(s.guards,r,t,n))return{result:ao.GUARDS_FAILED};const i=o.createElement(s.tag);i[V]=d,i[ae]=p;const a=r;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:ao.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:ao.NOT_FOUND}}(e,i,l);if(l())return;if(h.result===ao.GUARDS_FAILED)return;if(h.result===ao.SUCCESS){const{element:t,transition:n,layout:o,routeParams:r={}}=h;return void await T(i,t,n,o,e,r,l)}const{element:u,transition:f,layout:m}=function(){if(s){const e=o.createElement(s);e[V]=d;const t=n.customElements.get(s),r=t?.[q];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 T(i,u,f,m,e,{},l)}async function C(t,n,o,r,s=A){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?no(r.out):{opacity:"0"},h={opacity:"0"},u=r.in?no(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]))},v=n.hasAttribute("slot")||o.hasAttribute("slot");switch(oo(n,v,i,"all"),oo(o,v,a,"all"),Object.assign(o.style,h),t.appendChild(o),c){case e.TransitionMode.SIMULTANEOUS:Object.assign(n.style,l),Object.assign(o.style,u),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,u),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,v),Object.keys({...h,...u}).forEach(e=>{o.style[e]=""}),g()}(t,n,o,r,()=>s!==A)}return{page:function(e){return function(t,o){if(o?.metadata&&o.metadata[k]){t[k]||(t[k]=new Map);for(const[e,n]of o.metadata[k])t[k].set(e,n)}Fn(t),t[q]=e.transition;const r=t.prototype.connectedCallback;t.prototype.connectedCallback=function(){this[ae]=p,r?.call(this)};const s=t.prototype.disconnectedCallback;return t.prototype.disconnectedCallback=function(){s?.call(this),delete this[V],delete this[ae]},n.customElements.get(e.tag)||n.customElements.define(e.tag,t),e.routes.forEach(t=>v(t,e.tag,e.transition,e.guards,e.layout,e.placard)),t}},initialize:function(){const e=o.querySelector(t.target);if(!e)throw new Error(`Target element not found: ${t.target}`);y(e),!c&&(r.sort((e,t)=>to(t.route.spec)-to(e.route.spec)),c=!0),b(),function(){const e=()=>{const e=o.querySelector(t.target);if(e&&(f!==e||!m||io.get(e)===m))return f!==e&&ot.has(e)?(m?.(),m=null,void(f=null)):void _(E())};switch(t.type){case"hash":n.addEventListener("hashchange",e);break;case"pushstate":n.addEventListener("popstate",e)}}(),_(E())},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=ke,e.SniceElement=Zn,e.adopted=Yn,e.applyElementFunctionality=Fn,e.attachController=_t,e.classMap=function(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t},e.clearDebounceTimers=Vn,e.clearMemoizeCache=function(e,t){e[Dn]&&(t?delete e[Dn][t]:e[Dn]={})},e.clearThrottleTimers=qn,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,ge)||(n[ge]=new Set),!n[ge].has(t)){if(n[ge].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[V])return this[V];const e=rt(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,A,{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[T];(void 0===n?t[v]:n)===e&&_t(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?Pt.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+=(Mt(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:Lt,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&&Pt.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[Mn]||(this[Mn]={});const a=this[Mn],c=i;a[c]&&clearTimeout(a[c].timeout);const l=Date.now(),h=!a[c],u=h?l:a[c].startTime,d=void 0!==r&&l-u>=r;if(n&&h){const e=t.apply(this,s);return a[c]={timeout:null,startTime:u,lastArgs:s},e}const f=setTimeout(()=>{(o||d)&&t.apply(this,a[c].lastArgs),delete a[c]},d?0:e);a[c]={timeout:f,startTime:u,lastArgs:s}}}},e.detachController=Ct,e.dispatch=function(e,t){return function(n,o){return function(...r){this[X]||(this[X]=new Map);const s=`${e}_${o.name}`;this[X].has(s)||this[X].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[X].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===t?.dispatchOnUndefined)return;const o=new CustomEvent(e,{bubbles:t?.bubbles??!0,cancelable:t?.cancelable??!1,composed:t?.composed??!0,detail:n});if(void 0!==t?.scope&&void 0!==t?.daemon)throw new TypeError(`@dispatch('${e}') cannot use both scope and daemon.`);if(void 0!==t?.daemon)return void at(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=He(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=ct(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},l=e=>{if(t?.debounce)return clearTimeout(i.debounceTimeout),void(i.debounceTimeout=setTimeout(()=>c(e),t.debounce));if(!t?.throttle)return void c(e);const n=Date.now(),o=t.throttle-(n-i.throttleLastCall);if(o<=0)return clearTimeout(i.throttleTimeout),i.throttleLastCall=n,void c(e);i.latestDetail=e,i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null;const e=i.latestDetail;i.latestDetail=void 0,c(e)},o))};return a instanceof Promise?a.then(e=>(l(e),e)):(l(a),a)}}},e.dispose=function(){return function(e,t){Gn(W,Se,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 Wn(e,n,o,t)}},e.escapeAttr=function(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},e.escapeHtml=function(e){return String(e??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")},e.getBodyScrollLockCount=function(){return uo},e.getContext=rt,e.getController=function(e){return e[w]},e.getSymbol=n,e.html=function(e,...t){return{_$litType$:$t,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 Wn(e,t,n)}},e.live=function(e){return{_$liveMarker$:Yt,value:e}},e.lockBodyScroll=function(){0===uo&&(fo=document.body.style.overflow,document.body.style.overflow="hidden"),uo++},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[Dn]||(this[Dn]={}),this[Dn][s]||(this[Dn][s]=new Map);const i=this[Dn][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=Xn,e.noChange=Xt,e.nothing=Rt,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,be)||(n[be]=new Set),n[be].has(t))return;if(n[be].add(t),!Object.prototype.hasOwnProperty.call(n,K)){const e=n[K];n[K]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[K].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),function(t,n){const s=n.name;return n.addInitializer(function(){const n=this.constructor,i=Array.isArray(e)?e:[e],a=`${s}::${i.join(",")}::${o??""}::daemon:${r.daemon??""}`;if(Object.prototype.hasOwnProperty.call(n,we)||(n[we]=new Set),!n[we].has(a)){if(n[we].add(a),!Object.prototype.hasOwnProperty.call(n,yt)){const e=n[yt];n[yt]=e?[...e]:[]}for(const e of i)n[yt].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[In]||(this[In]={}),this[In][s]||(this[In][s]={called:!0,result:o.apply(this,r)}),this[In][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=Hn,e.provideContext=so,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=Kn(this);let n=null;const o=t instanceof HTMLElement?Bt(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=Kn(this),n=new Set,o=t instanceof HTMLElement?Bt(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){Gn(F,Ne,e,t)}},e.reconnect=function(){return function(e,t){Gn(z,Te,e,t)}},e.render=function(e={}){return function(t,n){return n.addInitializer(function(){this[Y]=t,this[Z]=e}),function(...n){const o=t.apply(this,n);return $n(this,{...this[Z]||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$:Vt,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?at(this,t.daemon):ct(this);if(!i)throw new TypeError(`@request('${e}') requires an element, attached controller, or provided @daemon instance.`);const a=n.apply(this,o),{value:c,done:l}=await a.next();if(l)return c;let h,u;const d=new Promise((e,t)=>{h=e,u=t});let f,m,p,y=!1;const g=new Promise((t,n)=>{f=t,m=n,p=setTimeout(()=>{n(new Error(`Request "${e}" found no @respond('${e}') handler within ${s}ms — attach a responding controller/element, or pass { optional: true } to resolve undefined when unhandled.`))},s)}),v=new CustomEvent(`@request/${e}`,{bubbles:void 0===t?.bubbles||t.bubbles,cancelable:t?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{y=!0,clearTimeout(p),f()},reject:m},data:{resolve:h,reject:u}}});i.dispatchEvent(v);try{await g;const t=setTimeout(()=>{u(new Error(`Request "${e}" timed out after ${r}ms`))},r),n=await d;clearTimeout(t);const{value:o}=await a.next(n);return o}catch(e){if(t?.optional&&!y){const{value:e}=await a.next(void 0);return e}const{value:n}=await a.throw(e);return n}};if(t?.debounce)return new Promise((e,n)=>{clearTimeout(r),r=setTimeout(async()=>{try{e(await c())}catch(e){n(e)}},t.debounce)});if(!t?.throttle)return c();const l=Date.now(),h=t.throttle-(l-i);if(h<=0){clearTimeout(s),s=null,i=l;const e=a.splice(0),t=c();return e.length&&t.then(t=>{for(const n of e)n.resolve(t)},t=>{for(const n of e)n.reject(t)}),t}return new Promise(s?(e,t)=>{a.push({resolve:e,reject:t})}:(e,t)=>{a.push({resolve:e,reject:t}),s=setTimeout(async()=>{i=Date.now(),s=null;const e=a.splice(0);try{const t=await c();for(const n of e)n.resolve(t)}catch(t){for(const n of e)n.reject(t)}},h)})}}},e.resetOnce=function(e,t){e[In]&&(t?delete e[In][t]:e[In]={})},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,Ee)||(o[Ee]=new Set),!o[Ee].has(n)){if(o[Ee].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){co=e},e.setStrictRenderErrors=function(e){Tn=e},e.state=function(e={}){return Hn({...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[oe]&&!this[se]?this[se]=[this[oe]]:this[oe]&&this[se]&&this[se].push(this[oe]),this[oe]=e}),e}},e.svg=function(e,...t){return{_$litType$:$t,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[Rn]||(this[Rn]={});const i=this[Rn],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[ne]||(e[ne]=[]),e[ne].push(t)}),yield},e.unlockBodyScroll=function(){0!==uo&&(uo--,0===uo&&(document.body.style.overflow=fo??"",fo=null))},e.unsafeHTML=function(e){return{_$litType$:It,html:e}},e.useNativeElementControllers=xt,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=>ho(e,t)))},e.waitForElementDefined=lo,e.waitForElementReady=ho,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,ve)||(n[ve]=new Map);let s=n[ve].get(e);if(s||(s=new Set,n[ve].set(e,s)),!Object.prototype.hasOwnProperty.call(n,I)){const e=n[I],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[I]=t}for(const i of t)s.has(i)||(s.add(i),n[I].has(i)||n[I].set(i,[]),n[I].get(i).push({methodName:r,method:e,immediate:o}))})}},e}({});
|
|
2
2
|
//# sourceMappingURL=snice-runtime.min.js.map
|