sygnal 5.3.6 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +53 -38
  2. package/dist/astro/client.cjs.js +18 -8106
  3. package/dist/astro/client.cjs.js.map +1 -0
  4. package/dist/astro/client.mjs +17 -8105
  5. package/dist/astro/client.mjs.map +1 -0
  6. package/dist/astro/index.cjs.js +768 -9
  7. package/dist/astro/index.cjs.js.map +1 -0
  8. package/dist/astro/index.mjs +768 -9
  9. package/dist/astro/index.mjs.map +1 -0
  10. package/dist/astro/server.cjs.js +4 -1
  11. package/dist/astro/server.cjs.js.map +1 -0
  12. package/dist/astro/server.mjs +4 -1
  13. package/dist/astro/server.mjs.map +1 -0
  14. package/dist/diagnostics.cjs.js +1297 -0
  15. package/dist/diagnostics.cjs.js.map +1 -0
  16. package/dist/diagnostics.esm.js +1267 -0
  17. package/dist/diagnostics.esm.js.map +1 -0
  18. package/dist/index.cjs.js +2981 -1386
  19. package/dist/index.cjs.js.map +1 -0
  20. package/dist/index.d.ts +848 -111
  21. package/dist/index.esm.js +2997 -1411
  22. package/dist/index.esm.js.map +1 -0
  23. package/dist/jsx-dev-runtime.cjs.js +15 -9
  24. package/dist/jsx-dev-runtime.cjs.js.map +1 -0
  25. package/dist/jsx-dev-runtime.esm.js +15 -9
  26. package/dist/jsx-dev-runtime.esm.js.map +1 -0
  27. package/dist/jsx-runtime.cjs.js +15 -9
  28. package/dist/jsx-runtime.cjs.js.map +1 -0
  29. package/dist/jsx-runtime.esm.js +15 -9
  30. package/dist/jsx-runtime.esm.js.map +1 -0
  31. package/dist/jsx.cjs.js +15 -9
  32. package/dist/jsx.cjs.js.map +1 -0
  33. package/dist/jsx.esm.js +15 -9
  34. package/dist/jsx.esm.js.map +1 -0
  35. package/dist/sygnal.min.js +2 -1
  36. package/dist/sygnal.min.js.map +1 -0
  37. package/dist/vike/+config.cjs.js +1 -0
  38. package/dist/vike/+config.cjs.js.map +1 -0
  39. package/dist/vike/+config.js +1 -0
  40. package/dist/vike/+config.js.map +1 -0
  41. package/dist/vike/ClientOnly.cjs.js +1 -0
  42. package/dist/vike/ClientOnly.cjs.js.map +1 -0
  43. package/dist/vike/ClientOnly.mjs +1 -0
  44. package/dist/vike/ClientOnly.mjs.map +1 -0
  45. package/dist/vike/onRenderClient.cjs.js +1 -0
  46. package/dist/vike/onRenderClient.cjs.js.map +1 -0
  47. package/dist/vike/onRenderClient.mjs +1 -0
  48. package/dist/vike/onRenderClient.mjs.map +1 -0
  49. package/dist/vike/onRenderHtml.cjs.js +1 -0
  50. package/dist/vike/onRenderHtml.cjs.js.map +1 -0
  51. package/dist/vike/onRenderHtml.mjs +1 -0
  52. package/dist/vike/onRenderHtml.mjs.map +1 -0
  53. package/dist/vite/plugin.cjs.js +680 -47
  54. package/dist/vite/plugin.cjs.js.map +1 -0
  55. package/dist/vite/plugin.mjs +680 -47
  56. package/dist/vite/plugin.mjs.map +1 -0
  57. package/llms.txt +250 -0
  58. package/package.json +15 -6
  59. package/src/astro/client.ts +13 -2
  60. package/src/astro/index.d.ts +24 -1
  61. package/src/astro/index.ts +40 -9
  62. package/src/astro/server.ts +3 -1
  63. package/src/collection.ts +5 -2
  64. package/src/component.ts +375 -330
  65. package/src/cycle/dom/MainDOMSource.ts +4 -0
  66. package/src/cycle/dom/classNameModule.ts +74 -0
  67. package/src/cycle/dom/controlledInputModule.ts +33 -0
  68. package/src/cycle/dom/enrichEventStream.ts +9 -3
  69. package/src/cycle/dom/makeDOMDriver.ts +1 -2
  70. package/src/cycle/dom/mockDOMSource.ts +62 -8
  71. package/src/cycle/dom/modules.ts +5 -1
  72. package/src/cycle/state/Collection.ts +13 -3
  73. package/src/cycle/state/StateSource.ts +1 -1
  74. package/src/cycle/state/pickCombine.ts +35 -1
  75. package/src/cycle/state/withState.ts +1 -1
  76. package/src/extra/devtools.ts +8 -0
  77. package/src/extra/diagnostics/checks/collections.ts +67 -0
  78. package/src/extra/diagnostics/checks/dom.ts +241 -0
  79. package/src/extra/diagnostics/checks/events.ts +68 -0
  80. package/src/extra/diagnostics/checks/index.ts +109 -0
  81. package/src/extra/diagnostics/checks/inspect.ts +319 -0
  82. package/src/extra/diagnostics/checks/props.ts +51 -0
  83. package/src/extra/diagnostics/checks/public.d.ts +211 -0
  84. package/src/extra/diagnostics/checks/rxjsHints.ts +88 -0
  85. package/src/extra/diagnostics/checks/shared.ts +119 -0
  86. package/src/extra/diagnostics/checks/state.ts +55 -0
  87. package/src/extra/diagnostics/checks/strict.ts +112 -0
  88. package/src/extra/diagnostics/checks/wiring.ts +65 -0
  89. package/src/extra/diagnostics/codes.ts +232 -0
  90. package/src/extra/diagnostics/index.ts +328 -0
  91. package/src/extra/diagnostics/legacy.ts +59 -0
  92. package/src/extra/driverFactories.ts +106 -58
  93. package/src/extra/eventDriver.ts +4 -0
  94. package/src/extra/flatten.ts +75 -0
  95. package/src/extra/reducers.ts +12 -5
  96. package/src/extra/run.ts +11 -0
  97. package/src/extra/testing.ts +890 -180
  98. package/src/extra/xstreamExtras.ts +269 -0
  99. package/src/index.d.ts +428 -17
  100. package/src/index.ts +7 -6
  101. package/src/pragma/index.ts +14 -9
  102. package/src/switchable.ts +10 -8
  103. package/src/vike/types.ts +21 -4
  104. package/src/vite/plugin.d.ts +95 -2
  105. package/src/vite/plugin.ts +730 -55
  106. package/dist/astro/astro/client.d.ts +0 -5
  107. package/dist/astro/astro/index.d.ts +0 -16
  108. package/dist/astro/astro/server.d.ts +0 -12
  109. package/dist/astro/client.d.ts +0 -5
  110. package/dist/astro/client.esm.js +0 -4665
  111. package/dist/astro/collection.d.ts +0 -12
  112. package/dist/astro/component.d.ts +0 -22
  113. package/dist/astro/cycle/dom/BodyDOMSource.d.ts +0 -10
  114. package/dist/astro/cycle/dom/DOMSource.d.ts +0 -11
  115. package/dist/astro/cycle/dom/DocumentDOMSource.d.ts +0 -12
  116. package/dist/astro/cycle/dom/ElementFinder.d.ts +0 -8
  117. package/dist/astro/cycle/dom/EventDelegator.d.ts +0 -34
  118. package/dist/astro/cycle/dom/IsolateModule.d.ts +0 -23
  119. package/dist/astro/cycle/dom/MainDOMSource.d.ts +0 -32
  120. package/dist/astro/cycle/dom/PriorityQueue.d.ts +0 -7
  121. package/dist/astro/cycle/dom/ScopeChecker.d.ts +0 -9
  122. package/dist/astro/cycle/dom/SymbolTree.d.ts +0 -9
  123. package/dist/astro/cycle/dom/VNodeWrapper.d.ts +0 -8
  124. package/dist/astro/cycle/dom/enrichEventStream.d.ts +0 -24
  125. package/dist/astro/cycle/dom/fromEvent.d.ts +0 -6
  126. package/dist/astro/cycle/dom/index.d.ts +0 -8
  127. package/dist/astro/cycle/dom/isolate.d.ts +0 -9
  128. package/dist/astro/cycle/dom/makeDOMDriver.d.ts +0 -11
  129. package/dist/astro/cycle/dom/mockDOMSource.d.ts +0 -17
  130. package/dist/astro/cycle/dom/modules.d.ts +0 -5
  131. package/dist/astro/cycle/dom/snabbdom.d.ts +0 -22
  132. package/dist/astro/cycle/dom/styleModule.d.ts +0 -13
  133. package/dist/astro/cycle/dom/thunk.d.ts +0 -11
  134. package/dist/astro/cycle/dom/utils.d.ts +0 -8
  135. package/dist/astro/cycle/isolate/index.d.ts +0 -42
  136. package/dist/astro/cycle/run/adapt.d.ts +0 -6
  137. package/dist/astro/cycle/run/index.d.ts +0 -36
  138. package/dist/astro/cycle/run/internals.d.ts +0 -8
  139. package/dist/astro/cycle/run/types.d.ts +0 -49
  140. package/dist/astro/cycle/state/Collection.d.ts +0 -29
  141. package/dist/astro/cycle/state/StateSource.d.ts +0 -20
  142. package/dist/astro/cycle/state/index.d.ts +0 -5
  143. package/dist/astro/cycle/state/pickCombine.d.ts +0 -3
  144. package/dist/astro/cycle/state/pickMerge.d.ts +0 -3
  145. package/dist/astro/cycle/state/types.d.ts +0 -18
  146. package/dist/astro/cycle/state/withState.d.ts +0 -17
  147. package/dist/astro/extra/classes.d.ts +0 -7
  148. package/dist/astro/extra/devtools.d.ts +0 -78
  149. package/dist/astro/extra/dragDriver.d.ts +0 -20
  150. package/dist/astro/extra/driverFactories.d.ts +0 -12
  151. package/dist/astro/extra/eventDriver.d.ts +0 -9
  152. package/dist/astro/extra/exactState.d.ts +0 -1
  153. package/dist/astro/extra/hmr.d.ts +0 -17
  154. package/dist/astro/extra/logDriver.d.ts +0 -2
  155. package/dist/astro/extra/processDrag.d.ts +0 -19
  156. package/dist/astro/extra/processForm.d.ts +0 -15
  157. package/dist/astro/extra/run.d.ts +0 -13
  158. package/dist/astro/extra/xstreamCompat.d.ts +0 -5
  159. package/dist/astro/index.d.ts +0 -19
  160. package/dist/astro/index.esm.js +0 -27
  161. package/dist/astro/jsx-dev-runtime.d.ts +0 -1
  162. package/dist/astro/jsx-runtime.d.ts +0 -4
  163. package/dist/astro/jsx.d.ts +0 -2
  164. package/dist/astro/pragma/fn.d.ts +0 -7
  165. package/dist/astro/pragma/index.d.ts +0 -7
  166. package/dist/astro/pragma/is.d.ts +0 -10
  167. package/dist/astro/server.d.ts +0 -12
  168. package/dist/astro/server.esm.js +0 -25
  169. package/dist/astro/switchable.d.ts +0 -7
  170. package/dist/collection.d.ts +0 -12
  171. package/dist/component.d.ts +0 -22
  172. package/dist/cycle/dom/BodyDOMSource.d.ts +0 -10
  173. package/dist/cycle/dom/DOMSource.d.ts +0 -11
  174. package/dist/cycle/dom/DocumentDOMSource.d.ts +0 -12
  175. package/dist/cycle/dom/ElementFinder.d.ts +0 -8
  176. package/dist/cycle/dom/EventDelegator.d.ts +0 -34
  177. package/dist/cycle/dom/IsolateModule.d.ts +0 -23
  178. package/dist/cycle/dom/MainDOMSource.d.ts +0 -32
  179. package/dist/cycle/dom/PriorityQueue.d.ts +0 -7
  180. package/dist/cycle/dom/ScopeChecker.d.ts +0 -9
  181. package/dist/cycle/dom/SymbolTree.d.ts +0 -9
  182. package/dist/cycle/dom/VNodeWrapper.d.ts +0 -8
  183. package/dist/cycle/dom/enrichEventStream.d.ts +0 -24
  184. package/dist/cycle/dom/fromEvent.d.ts +0 -6
  185. package/dist/cycle/dom/index.d.ts +0 -8
  186. package/dist/cycle/dom/isolate.d.ts +0 -9
  187. package/dist/cycle/dom/makeDOMDriver.d.ts +0 -11
  188. package/dist/cycle/dom/mockDOMSource.d.ts +0 -17
  189. package/dist/cycle/dom/modules.d.ts +0 -5
  190. package/dist/cycle/dom/snabbdom.d.ts +0 -22
  191. package/dist/cycle/dom/styleModule.d.ts +0 -13
  192. package/dist/cycle/dom/thunk.d.ts +0 -11
  193. package/dist/cycle/dom/utils.d.ts +0 -8
  194. package/dist/cycle/isolate/index.d.ts +0 -42
  195. package/dist/cycle/run/adapt.d.ts +0 -6
  196. package/dist/cycle/run/index.d.ts +0 -36
  197. package/dist/cycle/run/internals.d.ts +0 -8
  198. package/dist/cycle/run/types.d.ts +0 -49
  199. package/dist/cycle/state/Collection.d.ts +0 -29
  200. package/dist/cycle/state/StateSource.d.ts +0 -20
  201. package/dist/cycle/state/index.d.ts +0 -5
  202. package/dist/cycle/state/pickCombine.d.ts +0 -3
  203. package/dist/cycle/state/pickMerge.d.ts +0 -3
  204. package/dist/cycle/state/types.d.ts +0 -18
  205. package/dist/cycle/state/withState.d.ts +0 -17
  206. package/dist/extra/classes.d.ts +0 -7
  207. package/dist/extra/devtools.d.ts +0 -78
  208. package/dist/extra/dragDriver.d.ts +0 -20
  209. package/dist/extra/driverFactories.d.ts +0 -12
  210. package/dist/extra/eventDriver.d.ts +0 -9
  211. package/dist/extra/exactState.d.ts +0 -1
  212. package/dist/extra/hmr.d.ts +0 -17
  213. package/dist/extra/logDriver.d.ts +0 -2
  214. package/dist/extra/processDrag.d.ts +0 -19
  215. package/dist/extra/processForm.d.ts +0 -15
  216. package/dist/extra/run.d.ts +0 -13
  217. package/dist/extra/xstreamCompat.d.ts +0 -5
  218. package/dist/jsx-dev-runtime.d.ts +0 -1
  219. package/dist/jsx-dev-runtime.js +0 -224
  220. package/dist/jsx-runtime.d.ts +0 -4
  221. package/dist/jsx-runtime.js +0 -224
  222. package/dist/jsx.d.ts +0 -2
  223. package/dist/pragma/fn.d.ts +0 -7
  224. package/dist/pragma/index.d.ts +0 -7
  225. package/dist/pragma/is.d.ts +0 -10
  226. package/dist/switchable.d.ts +0 -7
@@ -1 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Sygnal={})}(this,(function(t){"use strict";function e(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r={},i={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){var e,n=t.Symbol;if("function"==typeof n)if(n.observable)e=n.observable;else{e=n.for("https://github.com/benlesh/symbol-observable");try{n.observable=e}catch(t){}}else e="@@observable";return e}}(i);var s,a,c=i,l=Object.prototype.toString,u=function(t){var e=l.call(t),n="[object Arguments]"===e;return n||(n="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===l.call(t.callee)),n};var d=Array.prototype.slice,p=u,h=Object.keys,f=h?function(t){return h(t)}:function(){if(a)return s;var t;if(a=1,!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=u,r=Object.prototype.propertyIsEnumerable,i=!r.call({toString:null},"toString"),c=r.call((function(){}),"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=function(t){var e=t.constructor;return e&&e.prototype===t},p={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!p["$"+t]&&e.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{d(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();t=function(t){var r=null!==t&&"object"==typeof t,s="[object Function]"===n.call(t),a=o(t),u=r&&"[object String]"===n.call(t),p=[];if(!r&&!s&&!a)throw new TypeError("Object.keys called on a non-object");var f=c&&s;if(u&&t.length>0&&!e.call(t,0))for(var m=0;m<t.length;++m)p.push(String(m));if(a&&t.length>0)for(var y=0;y<t.length;++y)p.push(String(y));else for(var _ in t)f&&"prototype"===_||!e.call(t,_)||p.push(String(_));if(i)for(var v=function(t){if("undefined"==typeof window||!h)return d(t);try{return d(t)}catch(t){return!1}}(t),g=0;g<l.length;++g)v&&"constructor"===l[g]||!e.call(t,l[g])||p.push(l[g]);return p}}return s=t}(),m=Object.keys;f.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return p(t)?m(d.call(t)):m(t)})}else Object.keys=f;return Object.keys||f};var y,_=f,v="undefined"!=typeof Symbol&&Symbol,g=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),n=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var r=Object.getOwnPropertyDescriptor(t,e);if(42!==r.value||!0!==r.enumerable)return!1}return!0},b={foo:{}},w=Object,S=Array.prototype.slice,E=Object.prototype.toString,A=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==E.call(e))throw new TypeError("Function.prototype.bind called on incompatible "+e);for(var n,o=S.call(arguments,1),r=Math.max(0,e.length-o.length),i=[],s=0;s<r;s++)i.push("$"+s);if(n=Function("binder","return function ("+i.join(",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof n){var r=e.apply(this,o.concat(S.call(arguments)));return Object(r)===r?r:this}return e.apply(t,o.concat(S.call(arguments)))})),e.prototype){var a=function(){};a.prototype=e.prototype,n.prototype=new a,a.prototype=null}return n},O=Function.prototype.bind||A,N=O.call(Function.call,Object.prototype.hasOwnProperty),C=SyntaxError,T=Function,$=TypeError,x=function(t){try{return T('"use strict"; return ('+t+").constructor;")()}catch(t){}},k=Object.getOwnPropertyDescriptor;if(k)try{k({},"")}catch(t){k=null}var L=function(){throw new $},D=k?function(){try{return L}catch(t){try{return k(arguments,"callee").get}catch(t){return L}}}():L,j="function"==typeof v&&"function"==typeof Symbol&&"symbol"==typeof v("foo")&&"symbol"==typeof Symbol("bar")&&g(),I={__proto__:b}.foo===b.foo&&!({__proto__:null}instanceof w),M=Object.getPrototypeOf||(I?function(t){return t.__proto__}:null),P={},R="undefined"!=typeof Uint8Array&&M?M(Uint8Array):y,F={"%AggregateError%":"undefined"==typeof AggregateError?y:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?y:ArrayBuffer,"%ArrayIteratorPrototype%":j&&M?M([][Symbol.iterator]()):y,"%AsyncFromSyncIteratorPrototype%":y,"%AsyncFunction%":P,"%AsyncGenerator%":P,"%AsyncGeneratorFunction%":P,"%AsyncIteratorPrototype%":P,"%Atomics%":"undefined"==typeof Atomics?y:Atomics,"%BigInt%":"undefined"==typeof BigInt?y:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?y:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?y:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?y:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?y:FinalizationRegistry,"%Function%":T,"%GeneratorFunction%":P,"%Int8Array%":"undefined"==typeof Int8Array?y:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?y:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":j&&M?M(M([][Symbol.iterator]())):y,"%JSON%":"object"==typeof JSON?JSON:y,"%Map%":"undefined"==typeof Map?y:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&j&&M?M((new Map)[Symbol.iterator]()):y,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?y:Promise,"%Proxy%":"undefined"==typeof Proxy?y:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?y:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?y:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&j&&M?M((new Set)[Symbol.iterator]()):y,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":j&&M?M(""[Symbol.iterator]()):y,"%Symbol%":j?Symbol:y,"%SyntaxError%":C,"%ThrowTypeError%":D,"%TypedArray%":R,"%TypeError%":$,"%Uint8Array%":"undefined"==typeof Uint8Array?y:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?y:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?y:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?y:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?y:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?y:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?y:WeakSet};if(M)try{null.error}catch(t){var G=M(M(t));F["%Error.prototype%"]=G}var B=function t(e){var n;if("%AsyncFunction%"===e)n=x("async function () {}");else if("%GeneratorFunction%"===e)n=x("function* () {}");else if("%AsyncGeneratorFunction%"===e)n=x("async function* () {}");else if("%AsyncGenerator%"===e){var o=t("%AsyncGeneratorFunction%");o&&(n=o.prototype)}else if("%AsyncIteratorPrototype%"===e){var r=t("%AsyncGenerator%");r&&M&&(n=M(r.prototype))}return F[e]=n,n},U={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},V=O,H=N,W=V.call(Function.call,Array.prototype.concat),Y=V.call(Function.apply,Array.prototype.splice),z=V.call(Function.call,String.prototype.replace),q=V.call(Function.call,String.prototype.slice),J=V.call(Function.call,RegExp.prototype.exec),Z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,X=/\\(\\)?/g,K=function(t,e){var n,o=t;if(H(U,o)&&(o="%"+(n=U[o])[0]+"%"),H(F,o)){var r=F[o];if(r===P&&(r=B(o)),void 0===r&&!e)throw new $("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:n,name:o,value:r}}throw new C("intrinsic "+t+" does not exist!")},Q=function(t,e){if("string"!=typeof t||0===t.length)throw new $("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new $('"allowMissing" argument must be a boolean');if(null===J(/^%?[^%]*%?$/,t))throw new C("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(t){var e=q(t,0,1),n=q(t,-1);if("%"===e&&"%"!==n)throw new C("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==e)throw new C("invalid intrinsic syntax, expected opening `%`");var o=[];return z(t,Z,(function(t,e,n,r){o[o.length]=n?z(r,X,"$1"):e||t})),o}(t),o=n.length>0?n[0]:"",r=K("%"+o+"%",e),i=r.name,s=r.value,a=!1,c=r.alias;c&&(o=c[0],Y(n,W([0,1],c)));for(var l=1,u=!0;l<n.length;l+=1){var d=n[l],p=q(d,0,1),h=q(d,-1);if(('"'===p||"'"===p||"`"===p||'"'===h||"'"===h||"`"===h)&&p!==h)throw new C("property names with quotes must have matching quotes");if("constructor"!==d&&u||(a=!0),H(F,i="%"+(o+="."+d)+"%"))s=F[i];else if(null!=s){if(!(d in s)){if(!e)throw new $("base intrinsic for "+t+" exists, but the property is not available.");return}if(k&&l+1>=n.length){var f=k(s,d);s=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:s[d]}else u=H(s,d),s=s[d];u&&!a&&(F[i]=s)}}return s},tt=Q("%Object.defineProperty%",!0),et=function(){if(tt)try{return tt({},"a",{value:1}),!0}catch(t){return!1}return!1};et.hasArrayLengthDefineBug=function(){if(!et())return null;try{return 1!==tt([],"length",{value:1}).length}catch(t){return!0}};var nt=et,ot=_,rt="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),it=Object.prototype.toString,st=Array.prototype.concat,at=Object.defineProperty,ct=nt(),lt=at&&ct,ut=function(t,e,n,o){if(e in t)if(!0===o){if(t[e]===n)return}else if("function"!=typeof(r=o)||"[object Function]"!==it.call(r)||!o())return;var r;lt?at(t,e,{configurable:!0,enumerable:!1,value:n,writable:!0}):t[e]=n},dt=function(t,e){var n=arguments.length>2?arguments[2]:{},o=ot(e);rt&&(o=st.call(o,Object.getOwnPropertySymbols(e)));for(var r=0;r<o.length;r+=1)ut(t,o[r],e[o[r]],n[o[r]])};dt.supportsDescriptors=!!lt;var pt=n,ht=function(){return"object"==typeof n&&n&&n.Math===Math&&n.Array===Array?n:pt},ft=dt,mt=ht,yt=dt,_t=n,vt=ht,gt=function(){var t=mt();if(ft.supportsDescriptors){var e=Object.getOwnPropertyDescriptor(t,"globalThis");e&&(!e.configurable||!e.enumerable&&e.writable&&globalThis===t)||Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else"object"==typeof globalThis&&globalThis===t||(t.globalThis=t);return t},bt=vt(),wt=function(){return bt};yt(wt,{getPolyfill:vt,implementation:_t,shim:gt});var St,Et=wt,At=n&&n.__extends||(St=function(t,e){return St=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},St(t,e)},function(t,e){function n(){this.constructor=t}St(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(r,"__esModule",{value:!0});var Ot=r.NO_IL=r.NO=r.MemoryStream=re=r.Stream=void 0,Nt=c.default(Et.getPolyfill()),Ct={},Tt=r.NO=Ct;function $t(){}function xt(t){for(var e=t.length,n=Array(e),o=0;o<e;++o)n[o]=t[o];return n}function kt(t,e,n){try{return t.f(e)}catch(t){return n._e(t),Ct}}var Lt={_n:$t,_e:$t,_c:$t};function Dt(t){t._start=function(t){t.next=t._n,t.error=t._e,t.complete=t._c,this.start(t)},t._stop=t.stop}Ot=r.NO_IL=Lt;var jt=function(){function t(t,e){this._stream=t,this._listener=e}return t.prototype.unsubscribe=function(){this._stream._remove(this._listener)},t}(),It=function(){function t(t){this._listener=t}return t.prototype.next=function(t){this._listener._n(t)},t.prototype.error=function(t){this._listener._e(t)},t.prototype.complete=function(){this._listener._c()},t}(),Mt=function(){function t(t){this.type="fromObservable",this.ins=t,this.active=!1}return t.prototype._start=function(t){this.out=t,this.active=!0,this._sub=this.ins.subscribe(new It(t)),this.active||this._sub.unsubscribe()},t.prototype._stop=function(){this._sub&&this._sub.unsubscribe(),this.active=!1},t}(),Pt=function(){function t(t){this.type="merge",this.insArr=t,this.out=Ct,this.ac=0}return t.prototype._start=function(t){this.out=t;var e=this.insArr,n=e.length;this.ac=n;for(var o=0;o<n;o++)e[o]._add(this)},t.prototype._stop=function(){for(var t=this.insArr,e=t.length,n=0;n<e;n++)t[n]._remove(this);this.out=Ct},t.prototype._n=function(t){var e=this.out;e!==Ct&&e._n(t)},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){if(--this.ac<=0){var t=this.out;if(t===Ct)return;t._c()}},t}(),Rt=function(){function t(t,e,n){this.i=t,this.out=e,this.p=n,n.ils.push(this)}return t.prototype._n=function(t){var e=this.p,n=this.out;if(n!==Ct&&e.up(t,this.i)){var o=xt(e.vals);n._n(o)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.p;t.out!==Ct&&0==--t.Nc&&t.out._c()},t}(),Ft=function(){function t(t){this.type="combine",this.insArr=t,this.out=Ct,this.ils=[],this.Nc=this.Nn=0,this.vals=[]}return t.prototype.up=function(t,e){var n=this.vals[e],o=this.Nn?n===Ct?--this.Nn:this.Nn:0;return this.vals[e]=t,0===o},t.prototype._start=function(t){this.out=t;var e=this.insArr,n=this.Nc=this.Nn=e.length,o=this.vals=new Array(n);if(0===n)t._n([]),t._c();else for(var r=0;r<n;r++)o[r]=Ct,e[r]._add(new Rt(r,t,this))},t.prototype._stop=function(){for(var t=this.insArr,e=t.length,n=this.ils,o=0;o<e;o++)t[o]._remove(n[o]);this.out=Ct,this.ils=[],this.vals=[]},t}(),Gt=function(){function t(t){this.type="fromArray",this.a=t}return t.prototype._start=function(t){for(var e=this.a,n=0,o=e.length;n<o;n++)t._n(e[n]);t._c()},t.prototype._stop=function(){},t}(),Bt=function(){function t(t){this.type="fromPromise",this.on=!1,this.p=t}return t.prototype._start=function(t){var e=this;this.on=!0,this.p.then((function(n){e.on&&(t._n(n),t._c())}),(function(e){t._e(e)})).then($t,(function(t){setTimeout((function(){throw t}))}))},t.prototype._stop=function(){this.on=!1},t}(),Ut=function(){function t(t){this.type="periodic",this.period=t,this.intervalID=-1,this.i=0}return t.prototype._start=function(t){var e=this;this.intervalID=setInterval((function(){t._n(e.i++)}),this.period)},t.prototype._stop=function(){-1!==this.intervalID&&clearInterval(this.intervalID),this.intervalID=-1,this.i=0},t}(),Vt=function(){function t(t,e){this.type="debug",this.ins=t,this.out=Ct,this.s=$t,this.l="","string"==typeof e?this.l=e:"function"==typeof e&&(this.s=e)}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=this.s,o=this.l;if(n!==$t)try{n(t)}catch(t){e._e(t)}else o?console.log(o+":",t):console.log(t);e._n(t)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Ht=function(){function t(t,e){this.type="drop",this.ins=e,this.out=Ct,this.max=t,this.dropped=0}return t.prototype._start=function(t){this.out=t,this.dropped=0,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;e!==Ct&&this.dropped++>=this.max&&e._n(t)},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Wt=function(){function t(t,e){this.out=t,this.op=e}return t.prototype._n=function(){this.op.end()},t.prototype._e=function(t){this.out._e(t)},t.prototype._c=function(){this.op.end()},t}(),Yt=function(){function t(t,e){this.type="endWhen",this.ins=e,this.out=Ct,this.o=t,this.oil=Lt}return t.prototype._start=function(t){this.out=t,this.o._add(this.oil=new Wt(t,this)),this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.o._remove(this.oil),this.out=Ct,this.oil=Lt},t.prototype.end=function(){var t=this.out;t!==Ct&&t._c()},t.prototype._n=function(t){var e=this.out;e!==Ct&&e._n(t)},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){this.end()},t}(),zt=function(){function t(t,e){this.type="filter",this.ins=e,this.out=Ct,this.f=t}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=kt(this,t,e);n!==Ct&&n&&e._n(t)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),qt=function(){function t(t,e){this.out=t,this.op=e}return t.prototype._n=function(t){this.out._n(t)},t.prototype._e=function(t){this.out._e(t)},t.prototype._c=function(){this.op.inner=Ct,this.op.less()},t}(),Jt=function(){function t(t){this.type="flatten",this.ins=t,this.out=Ct,this.open=!0,this.inner=Ct,this.il=Lt}return t.prototype._start=function(t){this.out=t,this.open=!0,this.inner=Ct,this.il=Lt,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.inner!==Ct&&this.inner._remove(this.il),this.out=Ct,this.open=!0,this.inner=Ct,this.il=Lt},t.prototype.less=function(){var t=this.out;t!==Ct&&(this.open||this.inner!==Ct||t._c())},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=this.inner,o=this.il;n!==Ct&&o!==Lt&&n._remove(o),(this.inner=t)._add(this.il=new qt(e,this))}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){this.open=!1,this.less()},t}(),Zt=function(){function t(t,e,n){var o=this;this.type="fold",this.ins=n,this.out=Ct,this.f=function(e){return t(o.acc,e)},this.acc=this.seed=e}return t.prototype._start=function(t){this.out=t,this.acc=this.seed,t._n(this.acc),this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct,this.acc=this.seed},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=kt(this,t,e);n!==Ct&&e._n(this.acc=n)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Xt=function(){function t(t){this.type="last",this.ins=t,this.out=Ct,this.has=!1,this.val=Ct}return t.prototype._start=function(t){this.out=t,this.has=!1,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct,this.val=Ct},t.prototype._n=function(t){this.has=!0,this.val=t},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&(this.has?(t._n(this.val),t._c()):t._e(new Error("last() failed because input stream completed")))},t}(),Kt=function(){function t(t,e){this.type="map",this.ins=e,this.out=Ct,this.f=t}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=kt(this,t,e);n!==Ct&&e._n(n)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Qt=function(){function t(t){this.type="remember",this.ins=t,this.out=Ct}return t.prototype._start=function(t){this.out=t,this.ins._add(t)},t.prototype._stop=function(){this.ins._remove(this.out),this.out=Ct},t}(),te=function(){function t(t,e){this.type="replaceError",this.ins=e,this.out=Ct,this.f=t}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;e!==Ct&&e._n(t)},t.prototype._e=function(t){var e=this.out;if(e!==Ct)try{this.ins._remove(this),(this.ins=this.f(t))._add(this)}catch(t){e._e(t)}},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),ee=function(){function t(t,e){this.type="startWith",this.ins=t,this.out=Ct,this.val=e}return t.prototype._start=function(t){this.out=t,this.out._n(this.val),this.ins._add(t)},t.prototype._stop=function(){this.ins._remove(this.out),this.out=Ct},t}(),ne=function(){function t(t,e){this.type="take",this.ins=e,this.out=Ct,this.max=t,this.taken=0}return t.prototype._start=function(t){this.out=t,this.taken=0,this.max<=0?t._c():this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=++this.taken;n<this.max?e._n(t):n===this.max&&(e._n(t),e._c())}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),oe=function(){function t(t){this._prod=t||Ct,this._ils=[],this._stopID=Ct,this._dl=Ct,this._d=!1,this._target=null,this._err=Ct}return t.prototype._n=function(t){var e=this._ils,n=e.length;if(this._d&&this._dl._n(t),1==n)e[0]._n(t);else{if(0==n)return;for(var o=xt(e),r=0;r<n;r++)o[r]._n(t)}},t.prototype._e=function(t){if(this._err===Ct){this._err=t;var e=this._ils,n=e.length;if(this._x(),this._d&&this._dl._e(t),1==n)e[0]._e(t);else{if(0==n)return;for(var o=xt(e),r=0;r<n;r++)o[r]._e(t)}if(!this._d&&0==n)throw this._err}},t.prototype._c=function(){var t=this._ils,e=t.length;if(this._x(),this._d&&this._dl._c(),1==e)t[0]._c();else{if(0==e)return;for(var n=xt(t),o=0;o<e;o++)n[o]._c()}},t.prototype._x=function(){0!==this._ils.length&&(this._prod!==Ct&&this._prod._stop(),this._err=Ct,this._ils=[])},t.prototype._stopNow=function(){this._prod._stop(),this._err=Ct,this._stopID=Ct},t.prototype._add=function(t){var e=this._target;if(e)return e._add(t);var n=this._ils;if(n.push(t),!(n.length>1))if(this._stopID!==Ct)clearTimeout(this._stopID),this._stopID=Ct;else{var o=this._prod;o!==Ct&&o._start(this)}},t.prototype._remove=function(t){var e=this,n=this._target;if(n)return n._remove(t);var o=this._ils,r=o.indexOf(t);r>-1&&(o.splice(r,1),this._prod!==Ct&&o.length<=0?(this._err=Ct,this._stopID=setTimeout((function(){return e._stopNow()}))):1===o.length&&this._pruneCycles())},t.prototype._pruneCycles=function(){this._hasNoSinks(this,[])&&this._remove(this._ils[0])},t.prototype._hasNoSinks=function(t,e){if(-1!==e.indexOf(t))return!0;if(t.out===this)return!0;if(t.out&&t.out!==Ct)return this._hasNoSinks(t.out,e.concat(t));if(t._ils){for(var n=0,o=t._ils.length;n<o;n++)if(!this._hasNoSinks(t._ils[n],e.concat(t)))return!1;return!0}return!1},t.prototype.ctor=function(){return this instanceof ie?ie:t},t.prototype.addListener=function(t){t._n=t.next||$t,t._e=t.error||$t,t._c=t.complete||$t,this._add(t)},t.prototype.removeListener=function(t){this._remove(t)},t.prototype.subscribe=function(t){return this.addListener(t),new jt(this,t)},t.prototype[Nt]=function(){return this},t.create=function(e){if(e){if("function"!=typeof e.start||"function"!=typeof e.stop)throw new Error("producer requires both start and stop functions");Dt(e)}return new t(e)},t.createWithMemory=function(t){return t&&Dt(t),new ie(t)},t.never=function(){return new t({_start:$t,_stop:$t})},t.empty=function(){return new t({_start:function(t){t._c()},_stop:$t})},t.throw=function(e){return new t({_start:function(t){t._e(e)},_stop:$t})},t.from=function(e){if("function"==typeof e[Nt])return t.fromObservable(e);if("function"==typeof e.then)return t.fromPromise(e);if(Array.isArray(e))return t.fromArray(e);throw new TypeError("Type of input to from() must be an Array, Promise, or Observable")},t.of=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.fromArray(e)},t.fromArray=function(e){return new t(new Gt(e))},t.fromPromise=function(e){return new t(new Bt(e))},t.fromObservable=function(e){if(void 0!==e.endWhen)return e;var n="function"==typeof e[Nt]?e[Nt]():e;return new t(new Mt(n))},t.periodic=function(e){return new t(new Ut(e))},t.prototype._map=function(t){return new(this.ctor())(new Kt(t,this))},t.prototype.map=function(t){return this._map(t)},t.prototype.mapTo=function(t){var e=this.map((function(){return t}));return e._prod.type="mapTo",e},t.prototype.filter=function(e){var n,o,r=this._prod;return new t(r instanceof zt?new zt((n=r.f,o=e,function(t){return n(t)&&o(t)}),r.ins):new zt(e,this))},t.prototype.take=function(t){return new(this.ctor())(new ne(t,this))},t.prototype.drop=function(e){return new t(new Ht(e,this))},t.prototype.last=function(){return new t(new Xt(this))},t.prototype.startWith=function(t){return new ie(new ee(this,t))},t.prototype.endWhen=function(t){return new(this.ctor())(new Yt(t,this))},t.prototype.fold=function(t,e){return new ie(new Zt(t,e,this))},t.prototype.replaceError=function(t){return new(this.ctor())(new te(t,this))},t.prototype.flatten=function(){return new t(new Jt(this))},t.prototype.compose=function(t){return t(this)},t.prototype.remember=function(){return new ie(new Qt(this))},t.prototype.debug=function(t){return new(this.ctor())(new Vt(this,t))},t.prototype.imitate=function(t){if(t instanceof ie)throw new Error("A MemoryStream was given to imitate(), but it only supports a Stream. Read more about this restriction here: https://github.com/staltz/xstream#faq");this._target=t;for(var e=this._ils,n=e.length,o=0;o<n;o++)t._add(e[o]);this._ils=[]},t.prototype.shamefullySendNext=function(t){this._n(t)},t.prototype.shamefullySendError=function(t){this._e(t)},t.prototype.shamefullySendComplete=function(){this._c()},t.prototype.setDebugListener=function(t){t?(this._d=!0,t._n=t.next||$t,t._e=t.error||$t,t._c=t.complete||$t,this._dl=t):(this._d=!1,this._dl=Ct)},t.merge=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new t(new Pt(e))},t.combine=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new t(new Ft(e))},t}(),re=r.Stream=oe,ie=function(t){function e(e){var n=t.call(this,e)||this;return n._has=!1,n}return At(e,t),e.prototype._n=function(e){this._v=e,this._has=!0,t.prototype._n.call(this,e)},e.prototype._add=function(t){var e=this._target;if(e)return e._add(t);var n=this._ils;if(n.push(t),n.length>1)this._has&&t._n(this._v);else if(this._stopID!==Ct)this._has&&t._n(this._v),clearTimeout(this._stopID),this._stopID=Ct;else if(this._has)t._n(this._v);else{var o=this._prod;o!==Ct&&o._start(this)}},e.prototype._stopNow=function(){this._has=!1,t.prototype._stopNow.call(this)},e.prototype._x=function(){this._has=!1,t.prototype._x.call(this)},e.prototype.map=function(t){return this._map(t)},e.prototype.mapTo=function(e){return t.prototype.mapTo.call(this,e)},e.prototype.take=function(e){return t.prototype.take.call(this,e)},e.prototype.endWhen=function(e){return t.prototype.endWhen.call(this,e)},e.prototype.replaceError=function(e){return t.prototype.replaceError.call(this,e)},e.prototype.remember=function(){return this},e.prototype.debug=function(e){return t.prototype.debug.call(this,e)},e}(oe),se=r.MemoryStream=ie,ae=oe,ce=r.default=ae,le=e({__proto__:null,get MemoryStream(){return se},get NO(){return Tt},get NO_IL(){return Ot},get Stream(){return re},default:ce},[r]);function ue(t){return function(){let t;return t="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,t.Cyclejs=t.Cyclejs||{},t=t.Cyclejs,t.adaptStream=t.adaptStream||(t=>t),t}().adaptStream(t)}let de=0;function pe(){return"cycle"+ ++de}function he(t,e=pe()){!function(t,e){if("function"!=typeof t)throw new Error("First argument given to isolate() must be a 'dataflowComponent' function");if(null===e)throw new Error("Second argument given to isolate() must not be null")}(t,e);const n="object"==typeof e?pe():"",o="string"==typeof e||"object"==typeof e?e:e.toString();return function(e,...r){const i=function(t,e,n){const o={};return Object.keys(t).forEach((t=>{if("string"==typeof e)return void(o[t]=e);const r=e[t];if(void 0!==r)return void(o[t]=r);const i=e["*"];o[t]=void 0===i?n:i})),o}(e,o,n),s=function(t,e){const n={};for(const o in t){const r=t[o];Object.prototype.hasOwnProperty.call(t,o)&&r&&null!==e[o]&&"function"==typeof r.isolateSource?n[o]=r.isolateSource(r,e[o]):Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n}(e,i),a=function(t,e,n){const o={};for(const r in e){const i=t[r],s=e[r];Object.prototype.hasOwnProperty.call(e,r)&&i&&null!==n[r]&&"function"==typeof i.isolateSink?o[r]=ue(i.isolateSink(ce.fromObservable(s),n[r])):Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r])}return o}(e,t(s,...r),i);return a}}he.reset=()=>de=0;var fe={};Object.defineProperty(fe,"__esModule",{value:!0});var me=fe.DropRepeatsOperator=void 0,ye=r,_e={},ve=function(){function t(t,e){this.ins=t,this.type="dropRepeats",this.out=null,this.v=_e,this.isEq=e||function(t,e){return t===e}}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=null,this.v=_e},t.prototype._n=function(t){var e=this.out;if(e){var n=this.v;n!==_e&&this.isEq(t,n)||(this.v=t,e._n(t))}},t.prototype._e=function(t){var e=this.out;e&&e._e(t)},t.prototype._c=function(){var t=this.out;t&&t._c()},t}();me=fe.DropRepeatsOperator=ve;var ge=fe.default=function(t){return void 0===t&&(t=void 0),function(e){return new ye.Stream(new ve(e,t))}},be=e({__proto__:null,get DropRepeatsOperator(){return me},default:ge},[fe]);function we(t){return"string"==typeof t||"number"==typeof t?function(e){return null==e?void 0:e[t]}:t.get}function Se(t){return"string"==typeof t||"number"==typeof t?function(e,n){return Array.isArray(e)?function(t,e,n){if(n===t[e])return t;const o=parseInt(e);return void 0===n?t.filter(((t,e)=>e!==o)):t.map(((t,e)=>e===o?n:t))}(e,t,n):void 0===e?{[t]:n}:{...e,[t]:n}}:t.set}function Ee(t,e){return t.select(e)}function Ae(t,e){const n=we(e),o=Se(e);return t.map((t=>function(e){const r=n(e),i=t(r);return r===i?e:o(e,i)}))}class Oe{constructor(t,e){this.isolateSource=Ee,this.isolateSink=Ae,this._stream=t.filter((t=>void 0!==t)).compose(ge()).remember(),this._name=e,this.stream=ue(this._stream),this._stream._isCycleSource=e}select(t){const e=we(t);return new Oe(this._stream.map(e),this._name)}}class Ne{constructor(t,e,n){this.ins=n,this.out=t,this.p=e}_n(t){this.p;const e=this.out;null!==e&&e._n(t)}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){}}class Ce{constructor(t,e){this.type="pickMerge",this.ins=e,this.out=null,this.sel=t,this.ils=new Map,this.inst=null}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this);const t=this.ils;t.forEach(((e,n)=>{e.ins._remove(e),e.ins=null,e.out=null,t.delete(n)})),t.clear(),this.out=null,this.ils=new Map,this.inst=null}_n(t){this.inst=t;const e=t.arr,n=this.ils,o=this.out,r=this.sel,i=e.length;for(let t=0;t<i;++t){const i=e[t],s=i._key,a=ce.fromObservable(i[r]||ce.never());n.has(s)||(n.set(s,new Ne(o,this,a)),a._add(n.get(s)))}n.forEach(((e,o)=>{t.dict.has(o)&&t.dict.get(o)||(e.ins._remove(e),e.ins=null,e.out=null,n.delete(o))}))}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){const t=this.out;null!==t&&t._c()}}class Te{constructor(t,e,n,o){this.key=t,this.out=e,this.p=n,this.val=Tt,this.ins=o}_n(t){this.p;const e=this.out;this.val=t,null!==e&&this.p.up()}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){}}class $e{constructor(t,e){this.type="combine",this.ins=e,this.sel=t,this.out=null,this.ils=new Map,this.inst=null}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this);const t=this.ils;t.forEach((t=>{t.ins._remove(t),t.ins=null,t.out=null,t.val=null})),t.clear(),this.out=null,this.ils=new Map,this.inst=null}up(){const t=this.inst.arr,e=t.length,n=this.ils,o=Array(e);for(let r=0;r<e;++r){const e=t[r]._key;if(!n.has(e))return;const i=n.get(e).val;if(i===Tt)return;o[r]=i}this.out._n(o)}_n(t){this.inst=t;const e=t.arr,n=this.ils,o=this.out,r=this.sel,i=t.dict,s=e.length;let a=!1;if(n.forEach(((t,e)=>{i.has(e)||(t.ins._remove(t),t.ins=null,t.out=null,t.val=null,n.delete(e),a=!0)})),0!==s){for(let t=0;t<s;++t){const i=e[t],s=i._key;if(!i[r])throw new Error("pickCombine found an undefined child sink stream");const a=ce.fromObservable(i[r]);n.has(s)||(n.set(s,new Te(s,o,this,a)),a._add(n.get(s)))}a&&this.up()}else o._n([])}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){const t=this.out;null!==t&&t._c()}}class xe{constructor(t){this._instances$=t}pickMerge(t){return ue(this._instances$.compose(function(t){return function(e){return new re(new Ce(t,e))}}(t)))}pickCombine(t){return ue(this._instances$.compose(function(t){return function(e){return new re(new $e(t,e))}}(t)))}}function ke(t){return{"*":null}}function Le(t,e){return{get(n){if(void 0!==n)for(let o=0,r=n.length;o<r;++o)if(`${t(n[o],o)}`===e)return n[o]},set:(n,o)=>void 0===n?[o]:void 0===o?n.filter(((n,o)=>`${t(n,o)}`!==e)):n.map(((n,r)=>`${t(n,r)}`===e?o:n))}}const De={get:t=>t,set:(t,e)=>e};var je={};Object.defineProperty(je,"__esModule",{value:!0});var Ie=r,Me=function(){function t(t){this.streams=t,this.type="concat",this.out=null,this.i=0}return t.prototype._start=function(t){this.out=t,this.streams[this.i]._add(this)},t.prototype._stop=function(){var t=this.streams;this.i<t.length&&t[this.i]._remove(this),this.i=0,this.out=null},t.prototype._n=function(t){var e=this.out;e&&e._n(t)},t.prototype._e=function(t){var e=this.out;e&&e._e(t)},t.prototype._c=function(){var t=this.out;if(t){var e=this.streams;e[this.i]._remove(this),++this.i<e.length?e[this.i]._add(this):t._c()}},t}();var Pe=je.default=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Ie.Stream(new Me(t))},Re=e({__proto__:null,default:Pe},[je]);function Fe(t,e="state"){return function(n){const o=ce.create(),r=o.fold(((t,e)=>e(t)),void 0).drop(1),i=n;i[e]=new Oe(r,e);const s=t(i);if(s[e]){Pe(ce.fromObservable(s[e]),ce.never()).subscribe({next:t=>queueMicrotask((()=>o._n(t))),error:t=>queueMicrotask((()=>o._e(t))),complete:()=>queueMicrotask((()=>o._c()))})}return s}}function Ge(t,e,n,o,r){return{sel:t,data:e,children:n,text:o,elm:r,key:void 0===e?void 0:e.key}}const Be=Array.isArray;function Ue(t){return"string"==typeof t||"number"==typeof t||t instanceof String||t instanceof Number}function Ve(t,e,n){if(t.ns="http://www.w3.org/2000/svg","foreignObject"!==n&&void 0!==e)for(let t=0;t<e.length;++t){const n=e[t];if("string"==typeof n)continue;const o=n.data;void 0!==o&&Ve(o,n.children,n.sel)}}function He(t,e,n){let o,r,i,s={};if(void 0!==n?(null!==e&&(s=e),Be(n)?o=n:Ue(n)?r=n.toString():n&&n.sel&&(o=[n])):null!=e&&(Be(e)?o=e:Ue(e)?r=e.toString():e&&e.sel?o=[e]:s=e),void 0!==o)for(i=0;i<o.length;++i)Ue(o[i])&&(o[i]=Ge(void 0,void 0,void 0,o[i],void 0));return!t.startsWith("svg")||3!==t.length&&"."!==t[3]&&"#"!==t[3]||Ve(s,o,t),Ge(t,s,o,r,void 0)}function We(t){if(Ye(t)){for(;t&&Ye(t);){t=ze(t).parent}return null!=t?t:null}return t.parentNode}function Ye(t){return 11===t.nodeType}function ze(t,e){var n,o,r;const i=t;return null!==(n=i.parent)&&void 0!==n||(i.parent=null!=e?e:null),null!==(o=i.firstChildNode)&&void 0!==o||(i.firstChildNode=t.firstChild),null!==(r=i.lastChildNode)&&void 0!==r||(i.lastChildNode=t.lastChild),i}const qe={createElement:function(t,e){return document.createElement(t,e)},createElementNS:function(t,e,n){return document.createElementNS(t,e,n)},createTextNode:function(t){return document.createTextNode(t)},createDocumentFragment:function(){return ze(document.createDocumentFragment())},createComment:function(t){return document.createComment(t)},insertBefore:function(t,e,n){if(Ye(t)){let e=t;for(;e&&Ye(e);){e=ze(e).parent}t=null!=e?e:t}Ye(e)&&(e=ze(e,t)),n&&Ye(n)&&(n=ze(n).firstChildNode),t.insertBefore(e,n)},removeChild:function(t,e){t.removeChild(e)},appendChild:function(t,e){Ye(e)&&(e=ze(e,t)),t.appendChild(e)},parentNode:We,nextSibling:function(t){var e;if(Ye(t)){const n=ze(t),o=We(n);if(o&&n.lastChildNode){const t=Array.from(o.childNodes),r=t.indexOf(n.lastChildNode);return null!==(e=t[r+1])&&void 0!==e?e:null}return null}return t.nextSibling},tagName:function(t){return t.tagName},setTextContent:function(t,e){t.textContent=e},getTextContent:function(t){return t.textContent},isElement:function(t){return 1===t.nodeType},isText:function(t){return 3===t.nodeType},isComment:function(t){return 8===t.nodeType},isDocumentFragment:Ye},Je=Ge("",{},[],void 0,void 0);function Ze(t,e){var n,o;const r=t.key===e.key,i=(null===(n=t.data)||void 0===n?void 0:n.is)===(null===(o=e.data)||void 0===o?void 0:o.is),s=t.sel===e.sel,a=!(!t.sel&&t.sel===e.sel)||typeof t.text==typeof e.text;return s&&r&&i&&a}function Xe(){throw new Error("The document fragment is not supported on this platform.")}function Ke(t,e,n){var o;const r={};for(let i=e;i<=n;++i){const e=null===(o=t[i])||void 0===o?void 0:o.key;void 0!==e&&(r[e]=i)}return r}const Qe=["create","update","remove","destroy","pre","post"];function tn(t,e,n){const o={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},r=void 0!==e?e:qe;for(const e of Qe)for(const n of t){const t=n[e];void 0!==t&&o[e].push(t)}function i(t,e){return function(){if(0==--e){const e=r.parentNode(t);null!==e&&r.removeChild(e,t)}}}function s(t,e){var i,a,c,l,u;let d;const p=t.data,h=null==p?void 0:p.hook;null===(i=null==h?void 0:h.init)||void 0===i||i.call(h,t);const f=t.children,m=t.sel;if("!"===m)null!==(a=t.text)&&void 0!==a||(t.text=""),t.elm=r.createComment(t.text);else if(""===m)t.elm=r.createTextNode(t.text);else if(void 0!==m){const n=m.indexOf("#"),i=m.indexOf(".",n),a=n>0?n:m.length,l=i>0?i:m.length,u=-1!==n||-1!==i?m.slice(0,Math.min(a,l)):m,y=null==p?void 0:p.ns,_=void 0===y?r.createElement(u,p):r.createElementNS(y,u,p);for(t.elm=_,a<l&&_.setAttribute("id",m.slice(a+1,l)),i>0&&_.setAttribute("class",m.slice(l+1).replace(/\./g," ")),d=0;d<o.create.length;++d)o.create[d](Je,t);if(!Ue(t.text)||Be(f)&&0!==f.length||r.appendChild(_,r.createTextNode(t.text)),Be(f))for(d=0;d<f.length;++d){const t=f[d];null!=t&&r.appendChild(_,s(t,e))}void 0!==h&&(null===(c=h.create)||void 0===c||c.call(h,Je,t),void 0!==h.insert&&e.push(t))}else if((null===(l=null==n?void 0:n.experimental)||void 0===l?void 0:l.fragments)&&t.children){for(t.elm=(null!==(u=r.createDocumentFragment)&&void 0!==u?u:Xe)(),d=0;d<o.create.length;++d)o.create[d](Je,t);for(d=0;d<t.children.length;++d){const n=t.children[d];null!=n&&r.appendChild(t.elm,s(n,e))}}else t.elm=r.createTextNode(t.text);return t.elm}function a(t,e,n,o,i,a){for(;o<=i;++o){const i=n[o];null!=i&&r.insertBefore(t,s(i,a),e)}}function c(t){var e,n;const r=t.data;if(void 0!==r){null===(n=null===(e=null==r?void 0:r.hook)||void 0===e?void 0:e.destroy)||void 0===n||n.call(e,t);for(let e=0;e<o.destroy.length;++e)o.destroy[e](t);if(void 0!==t.children)for(let e=0;e<t.children.length;++e){const n=t.children[e];null!=n&&"string"!=typeof n&&c(n)}}}function l(t,e,n,s){for(var a,u;n<=s;++n){let s;const d=e[n];if(null!=d)if(void 0!==d.sel){c(d),s=o.remove.length+1;const t=i(d.elm,s);for(let e=0;e<o.remove.length;++e)o.remove[e](d,t);const e=null===(u=null===(a=null==d?void 0:d.data)||void 0===a?void 0:a.hook)||void 0===u?void 0:u.remove;void 0!==e?e(d,t):t()}else d.children?(c(d),l(t,d.children,0,d.children.length-1)):r.removeChild(t,d.elm)}}function u(t,e,n){var i,c,d,p,h,f,m,y;const _=null===(i=e.data)||void 0===i?void 0:i.hook;null===(c=null==_?void 0:_.prepatch)||void 0===c||c.call(_,t,e);const v=e.elm=t.elm;if(t===e)return;if(void 0!==e.data||void 0!==e.text&&e.text!==t.text){null!==(d=e.data)&&void 0!==d||(e.data={}),null!==(p=t.data)&&void 0!==p||(t.data={});for(let n=0;n<o.update.length;++n)o.update[n](t,e);null===(m=null===(f=null===(h=e.data)||void 0===h?void 0:h.hook)||void 0===f?void 0:f.update)||void 0===m||m.call(f,t,e)}const g=t.children,b=e.children;void 0===e.text?void 0!==g&&void 0!==b?g!==b&&function(t,e,n,o){let i,c,d,p,h=0,f=0,m=e.length-1,y=e[0],_=e[m],v=n.length-1,g=n[0],b=n[v];for(;h<=m&&f<=v;)null==y?y=e[++h]:null==_?_=e[--m]:null==g?g=n[++f]:null==b?b=n[--v]:Ze(y,g)?(u(y,g,o),y=e[++h],g=n[++f]):Ze(_,b)?(u(_,b,o),_=e[--m],b=n[--v]):Ze(y,b)?(u(y,b,o),r.insertBefore(t,y.elm,r.nextSibling(_.elm)),y=e[++h],b=n[--v]):Ze(_,g)?(u(_,g,o),r.insertBefore(t,_.elm,y.elm),_=e[--m],g=n[++f]):(void 0===i&&(i=Ke(e,h,m)),c=i[g.key],void 0===c?(r.insertBefore(t,s(g,o),y.elm),g=n[++f]):void 0===i[b.key]?(r.insertBefore(t,s(b,o),r.nextSibling(_.elm)),b=n[--v]):(d=e[c],d.sel!==g.sel?r.insertBefore(t,s(g,o),y.elm):(u(d,g,o),e[c]=void 0,r.insertBefore(t,d.elm,y.elm)),g=n[++f]));f<=v&&(p=null==n[v+1]?null:n[v+1].elm,a(t,p,n,f,v,o)),h<=m&&l(t,e,h,m)}(v,g,b,n):void 0!==b?(void 0!==t.text&&r.setTextContent(v,""),a(v,null,b,0,b.length-1,n)):void 0!==g?l(v,g,0,g.length-1):void 0!==t.text&&r.setTextContent(v,""):t.text!==e.text&&(void 0!==g&&l(v,g,0,g.length-1),r.setTextContent(v,e.text)),null===(y=null==_?void 0:_.postpatch)||void 0===y||y.call(_,t,e)}return function(t,e){let n,i,a;const c=[];for(n=0;n<o.pre.length;++n)o.pre[n]();for(!function(t,e){return t.isElement(e)}(r,t)?function(t,e){return t.isDocumentFragment(e)}(r,t)&&(t=Ge(void 0,{},[],void 0,t)):t=function(t){const e=t.id?"#"+t.id:"",n=t.getAttribute("class"),o=n?"."+n.split(" ").join("."):"";return Ge(r.tagName(t).toLowerCase()+e+o,{},[],void 0,t)}(t),Ze(t,e)?u(t,e,c):(i=t.elm,a=r.parentNode(i),s(e,c),null!==a&&(r.insertBefore(a,e.elm,r.nextSibling(i)),l(a,[t],0,0))),n=0;n<c.length;++n)c[n].data.hook.insert(c[n]);for(n=0;n<o.post.length;++n)o.post[n]();return e}}function en(t,e){var n;const o=void 0!==e?e:qe;let r;if(o.isElement(t)){const r=t.id?"#"+t.id:"",s=null===(n=t.getAttribute("class"))||void 0===n?void 0:n.match(/[^\t\r\n\f ]+/g),a=s?"."+s.join("."):"",c=o.tagName(t).toLowerCase()+r+a,l={},u={},d={},p=[];let h,f,m;const y=t.attributes,_=t.childNodes;for(f=0,m=y.length;f<m;f++)h=y[f].nodeName,h.startsWith("data-")?u[(i=h,i.slice(5).replace(/-([a-z])/g,((t,e)=>e.toUpperCase())))]=y[f].nodeValue||"":"id"!==h&&"class"!==h&&(l[h]=y[f].nodeValue);for(f=0,m=_.length;f<m;f++)p.push(en(_[f],e));return Object.keys(l).length>0&&(d.attrs=l),Object.keys(u).length>0&&(d.dataset=u),!c.startsWith("svg")||3!==c.length&&"."!==c[3]&&"#"!==c[3]||Ve(d,p,c),Ge(c,d,p,void 0,t)}return o.isText(t)?(r=o.getTextContent(t),Ge(void 0,void 0,void 0,r,t)):o.isComment(t)?(r=o.getTextContent(t),Ge("!",{},[],r,t)):Ge("",{},[],void 0,t);var i}function nn(t,e){let n,o;const r=e.elm;let i=t.data.class,s=e.data.class;if((i||s)&&i!==s){for(o in i=i||{},s=s||{},i)i[o]&&!Object.prototype.hasOwnProperty.call(s,o)&&r.classList.remove(o);for(o in s)n=s[o],n!==i[o]&&r.classList[n?"add":"remove"](o)}}const on={create:nn,update:nn};function rn(t,e){let n,o,r;const i=e.elm;let s=t.data.props,a=e.data.props;if((s||a)&&s!==a)for(n in s=s||{},a=a||{},a)o=a[n],r=s[n],r===o||"value"===n&&i[n]===o||(i[n]=o)}const sn={create:rn,update:rn};function an(t,e){let n;const o=e.elm;let r=t.data.attrs,i=e.data.attrs;if((r||i)&&r!==i){for(n in r=r||{},i=i||{},i){const t=i[n];r[n]!==t&&(!0===t?o.setAttribute(n,""):!1===t?o.removeAttribute(n):120!==n.charCodeAt(0)?o.setAttribute(n,t):58===n.charCodeAt(3)?o.setAttributeNS("http://www.w3.org/XML/1998/namespace",n,t):58===n.charCodeAt(5)?109===n.charCodeAt(1)?o.setAttributeNS("http://www.w3.org/2000/xmlns/",n,t):o.setAttributeNS("http://www.w3.org/1999/xlink",n,t):o.setAttribute(n,t))}for(n in r)n in i||o.removeAttribute(n)}}const cn={create:an,update:an},ln=/[A-Z]/g;function un(t,e){const n=e.elm;let o,r=t.data.dataset,i=e.data.dataset;if(!r&&!i)return;if(r===i)return;r=r||{},i=i||{};const s=n.dataset;for(o in r)o in i||(s?o in s&&delete s[o]:n.removeAttribute("data-"+o.replace(ln,"-$&").toLowerCase()));for(o in i)r[o]!==i[o]&&(s?s[o]=i[o]:n.setAttribute("data-"+o.replace(ln,"-$&").toLowerCase(),i[o]))}const dn={create:un,update:un};function pn(t,e){e.elm=t.elm,t.data.fn=e.data.fn,t.data.args=e.data.args,t.data.isolate=e.data.isolate,e.data=t.data,e.children=t.children,e.text=t.text,e.elm=t.elm}function hn(t){const e=t.data;pn(e.fn.apply(void 0,e.args),t)}function fn(t,e){const n=t.data,o=e.data;let r;const i=n.args,s=o.args;for(n.fn===o.fn&&i.length===s.length||pn(o.fn.apply(void 0,s),e),r=0;r<s.length;++r)if(i[r]!==s[r])return void pn(o.fn.apply(void 0,s),e);pn(t,e)}function mn(t,e,n=!1,o=!1,r=!1){let i=null;return re.create({start:function(s){i=o?function(t){_n(t,o),s.next(t)}:function(t){s.next(t)},t.addEventListener(e,i,{capture:n,passive:r})},stop:function(){t.removeEventListener(e,i,n),i=null}})}function yn(t,e){const n=Object.keys(t),o=n.length;for(let r=0;r<o;r++){const o=n[r];if("object"==typeof t[o]&&null!==t[o]&&"object"==typeof e[o]&&null!==e[o]){if(!yn(t[o],e[o]))return!1}else if(t[o]!==e[o])return!1}return!0}function _n(t,e){if(e)if("boolean"==typeof e)t.preventDefault();else if("function"==typeof e)e(t)&&t.preventDefault();else{if("object"!=typeof e)throw new Error("preventDefault has to be either a boolean, predicate function or object");yn(e,t)&&t.preventDefault()}}function vn(t){return t.value=function(e){return vn(t.map((t=>{const n=t?.target?.value;return e?e(n):n})))},t.checked=function(e){return vn(t.map((t=>{const n=!!t?.target?.checked;return e?e(n):n})))},t.data=function(e,n){return vn(t.map((t=>{const o=t?.target instanceof Element?t.target.closest(`[data-${e}]`)||t.target:t?.target,r=o?.dataset?.[e];return n?n(r):r})))},t.target=function(e){return vn(t.map((t=>{const n=t?.target;return e?e(n):n})))},t.key=function(e){return vn(t.map((t=>{const n=t?.key;return e?e(n):n})))},t}class gn{constructor(t,e){this._name=t,this._selector=e||null}select(t){return new gn(this._name,t)}elements(){if(this._selector){const t=ue(ce.of(Array.from(document.querySelectorAll(this._selector))));return t._isCycleSource=this._name,t}const t=ue(ce.of([document]));return t._isCycleSource=this._name,t}element(){if(this._selector){const t=ue(ce.of(document.querySelector(this._selector)));return t._isCycleSource=this._name,t}const t=ue(ce.of(document));return t._isCycleSource=this._name,t}events(t,e={},n){let o;if(o=mn(document,t,e.useCapture,e.preventDefault),this._selector){const t=this._selector;o=o.filter((e=>{const n=e.target;return n instanceof Element&&(n.matches(t)||null!==n.closest(t))}))}const r=vn(ue(o));return r._isCycleSource=this._name,r}}class bn{constructor(t){this._name=t}select(t){return this}elements(){const t=ue(ce.of([document.body]));return t._isCycleSource=this._name,t}element(){const t=ue(ce.of(document.body));return t._isCycleSource=this._name,t}events(t,e={},n){let o;o=mn(document.body,t,e.useCapture,e.preventDefault);const r=ue(o);return r._isCycleSource=this._name,r}}function wn(t){if("string"!=typeof t&&(e=t,!("object"==typeof HTMLElement?e instanceof HTMLElement||e instanceof DocumentFragment:e&&"object"==typeof e&&null!==e&&(1===e.nodeType||11===e.nodeType)&&"string"==typeof e.nodeName)))throw new Error("Given container is not a DOM element neither a selector string.");var e}function Sn(t){let e="";for(let n=t.length-1;n>=0&&"selector"===t[n].type;n--)e=t[n].scope+" "+e;return e.trim()}function En(t,e){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n].type!==e[n].type||t[n].scope!==e[n].scope)return!1;return!0}class An{constructor(t,e){this.namespace=t,this.isolateModule=e,this._namespace=t.filter((t=>"selector"!==t.type))}isDirectlyInScope(t){const e=this.isolateModule.getNamespace(t);if(!e)return!1;if(this._namespace.length>e.length||!En(this._namespace,e.slice(0,this._namespace.length)))return!1;for(let t=this._namespace.length;t<e.length;t++)if("total"===e[t].type)return!1;return!0}}class On{constructor(t,e){this.namespace=t,this.isolateModule=e}call(){const t=this.namespace,e=Sn(t),n=new An(t,this.isolateModule),o=this.isolateModule.getElement(t.filter((t=>"selector"!==t.type)));return void 0===o?[]:""===e?[o]:(r=o.querySelectorAll(e),Array.prototype.slice.call(r)).filter(n.isDirectlyInScope,n).concat(o.matches(e)?[o]:[]);var r}}function Nn(t){return{type:(e=t,e.length>1&&("."===e[0]||"#"===e[0])?"sibling":"total"),scope:t};var e}class Cn{constructor(t,e,n=[],o,r,i){var s;this._rootElement$=t,this._sanitation$=e,this._namespace=n,this._isolateModule=o,this._eventDelegator=r,this._name=i,this.isolateSource=(t,e)=>new Cn(t._rootElement$,t._sanitation$,t._namespace.concat(Nn(e)),t._isolateModule,t._eventDelegator,t._name),this.isolateSink=(s=this._namespace,(t,e)=>":root"===e?t:t.map((t=>{if(!t)return t;const n=Nn(e),o={...t,data:{...t.data,isolate:t.data&&Array.isArray(t.data.isolate)?t.data.isolate:s.concat([n])}};return{...o,key:void 0!==o.key?o.key:JSON.stringify(o.data.isolate)}})))}_elements(){if(0===this._namespace.length)return this._rootElement$.map((t=>[t]));{const t=new On(this._namespace,this._isolateModule);return this._rootElement$.map((()=>t.call()))}}elements(){const t=ue(this._elements().remember());return t._isCycleSource=this._name,t}element(){const t=ue(this._elements().filter((t=>t.length>0)).map((t=>t[0])).remember());return t._isCycleSource=this._name,t}get namespace(){return this._namespace}select(t){if("string"!=typeof t)throw new Error("DOM driver's select() expects the argument to be a string as a CSS selector");if("document"===t)return new gn(this._name);if("body"===t)return new bn(this._name);const e=":root"===t?[]:this._namespace.concat({type:"selector",scope:t.trim()});return new Cn(this._rootElement$,this._sanitation$,e,this._isolateModule,this._eventDelegator,this._name)}events(t,e={},n){if("string"!=typeof t)throw new Error("DOM driver's events() expects argument to be a string representing the event type to listen for.");const o=vn(ue(this._eventDelegator.addEventListener(t,this._namespace,e,n)));return o._isCycleSource=this._name,o}dispose(){this._sanitation$.shamefullySendNext(null)}}var Tn={},$n=n&&n.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var o=Array(t),r=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,r++)o[r]=i[s];return o};Object.defineProperty(Tn,"__esModule",{value:!0}),Tn.SampleCombineOperator=Tn.SampleCombineListener=void 0;var xn=r,kn={},Ln=function(){function t(t,e){this.i=t,this.p=e,e.ils[t]=this}return t.prototype._n=function(t){var e=this.p;e.out!==kn&&e.up(t,this.i)},t.prototype._e=function(t){this.p._e(t)},t.prototype._c=function(){this.p.down(this.i,this)},t}();Tn.SampleCombineListener=Ln;var Dn,jn=function(){function t(t,e){this.type="sampleCombine",this.ins=t,this.others=e,this.out=kn,this.ils=[],this.Nn=0,this.vals=[]}return t.prototype._start=function(t){this.out=t;for(var e=this.others,n=this.Nn=e.length,o=this.vals=new Array(n),r=0;r<n;r++)o[r]=kn,e[r]._add(new Ln(r,this));this.ins._add(this)},t.prototype._stop=function(){var t=this.others,e=t.length,n=this.ils;this.ins._remove(this);for(var o=0;o<e;o++)t[o]._remove(n[o]);this.out=kn,this.vals=[],this.ils=[]},t.prototype._n=function(t){var e=this.out;e!==kn&&(this.Nn>0||e._n($n([t],this.vals)))},t.prototype._e=function(t){var e=this.out;e!==kn&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==kn&&t._c()},t.prototype.up=function(t,e){var n=this.vals[e];this.Nn>0&&n===kn&&this.Nn--,this.vals[e]=t},t.prototype.down=function(t,e){this.others[t]._remove(e)},t}();Tn.SampleCombineOperator=jn,Dn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(e){return new xn.Stream(new jn(e,t))}};var In=Tn.default=Dn;function Mn(t){if(!t.sel)return{tagName:"",id:"",className:""};const e=t.sel,n=e.indexOf("#"),o=e.indexOf(".",n),r=n>0?n:e.length,i=o>0?o:e.length;return{tagName:-1!==n||-1!==o?e.slice(0,Math.min(r,i)):e,id:r<i?e.slice(r+1,i):void 0,className:o>0?e.slice(i+1).replace(/\./g," "):void 0}}class Pn{constructor(t){this.rootElement=t}call(t){if(11===this.rootElement.nodeType)return this.wrapDocFrag(null===t?[]:[t]);if(null===t)return this.wrap([]);const{tagName:e,id:n}=Mn(t),o=function(t){let{className:e=""}=Mn(t);if(!t.data)return e;const{class:n,props:o}=t.data;n&&(e+=` ${Object.keys(n).filter((t=>n[t])).join(" ")}`);return o&&o.className&&(e+=` ${o.className}`),e&&e.trim()}(t),r=(t.data||{}).props||{},{id:i=n}=r;return"string"==typeof i&&i.toUpperCase()===this.rootElement.id.toUpperCase()&&e.toUpperCase()===this.rootElement.tagName.toUpperCase()&&o.toUpperCase()===this.rootElement.className.toUpperCase()?t:this.wrap([t])}wrapDocFrag(t){return Ge("",{isolate:[]},t,void 0,this.rootElement)}wrap(t){const{tagName:e,id:n,className:o}=this.rootElement,r=n?`#${n}`:"",i=o?`.${o.split(" ").join(".")}`:"",s=He(`${e.toLowerCase()}${r}${i}`,{},t);return s.data=s.data||{},s.data.isolate=s.data.isolate||[],s}}const Rn="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||setTimeout,Fn=t=>{Rn((()=>{Rn(t)}))};let Gn=!1;function Bn(t,e,n){Fn((()=>{t[e]=n}))}function Un(t,e){let n,o;const r=e.elm;let i=t.data.style,s=e.data.style;if(!i&&!s)return;if(i===s)return;i=i||{},s=s||{};const a="delayed"in i;for(o in i)o in s||("-"===o[0]&&"-"===o[1]?r.style.removeProperty(o):r.style[o]="");for(o in s)if(n=s[o],"delayed"===o&&s.delayed)for(const t in s.delayed)n=s.delayed[t],a&&n===i.delayed[t]||Bn(r.style,t,n);else"remove"!==o&&n!==i[o]&&("-"===o[0]&&"-"===o[1]?r.style.setProperty(o,n):r.style[o]=n)}const Vn={pre:function(){Gn=!1},create:Un,update:Un,destroy:function(t){let e,n;const o=t.elm,r=t.data.style;if(r&&(e=r.destroy))for(n in e)o.style[n]=e[n]},remove:function(t,e){const n=t.data.style;if(!n||!n.remove)return void e();let o;Gn||(t.elm.offsetLeft,Gn=!0);const r=t.elm;let i=0;const s=n.remove;let a=0;const c=[];for(o in s)c.push(o),r.style[o]=s[o];const l=getComputedStyle(r)["transition-property"].split(", ");for(;i<l.length;++i)-1!==c.indexOf(l[i])&&a++;r.addEventListener("transitionend",(t=>{t.target===r&&--a,0===a&&e()}))}};let Hn=[];const Wn={create:function(t,e){const n=e.elm;n&&"SELECT"===n.tagName&&void 0!==e.data?.props?.value&&Hn.push({elm:n,value:e.data.props.value})},post:function(){for(let t=0;t<Hn.length;t++){const{elm:e,value:n}=Hn[t];e.value=n}Hn=[]}},Yn=[Vn,on,sn,cn,dn,Wn];class zn{constructor(t){this.mapper=t,this.tree=[void 0,{}]}set(t,e,n){let o=this.tree;const r=void 0!==n?n:t.length;for(let e=0;e<r;e++){const n=this.mapper(t[e]);let r=o[1][n];r||(r=[void 0,{}],o[1][n]=r),o=r}o[0]=e}getDefault(t,e,n){return this.get(t,e,n)}get(t,e,n){let o=this.tree;const r=void 0!==n?n:t.length;for(let n=0;n<r;n++){const r=this.mapper(t[n]);let i=o[1][r];if(!i){if(!e)return;i=[void 0,{}],o[1][r]=i}o=i}return e&&!o[0]&&(o[0]=e()),o[0]}delete(t){let e=this.tree;for(let n=0;n<t.length-1;n++){const o=e[1][this.mapper(t[n])];if(!o)return;e=o}delete e[1][this.mapper(t[t.length-1])]}}class qn{constructor(){this.namespaceTree=new zn((t=>t.scope)),this.namespaceByElement=new Map,this.vnodesBeingRemoved=[]}setEventDelegator(t){this.eventDelegator=t}insertElement(t,e){this.namespaceByElement.set(e,t),this.namespaceTree.set(t,e)}removeElement(t){this.namespaceByElement.delete(t);const e=this.getNamespace(t);e&&this.namespaceTree.delete(e)}getElement(t,e){return this.namespaceTree.get(t,void 0,e)}getRootElement(t){if(this.namespaceByElement.has(t))return t;let e=t;for(;!this.namespaceByElement.has(e);){if(e=e.parentNode,!e)return;if("HTML"===e.tagName)throw new Error("No root element found, this should not happen at all")}return e}getNamespace(t){const e=this.getRootElement(t);if(e)return this.namespaceByElement.get(e)}createModule(){const t=this;return{create(e,n){const{elm:o,data:r={}}=n,i=r.isolate;Array.isArray(i)&&t.insertElement(i,o)},update(e,n){const{elm:o,data:r={}}=e,{elm:i,data:s={}}=n,a=r.isolate,c=s.isolate;En(a,c)||Array.isArray(a)&&t.removeElement(o),Array.isArray(c)&&t.insertElement(c,i)},destroy(e){t.vnodesBeingRemoved.push(e)},remove(e,n){t.vnodesBeingRemoved.push(e),n()},post(){const e=t.vnodesBeingRemoved;for(let n=e.length-1;n>=0;n--){const o=e[n],r=void 0!==o.data?o.data.isolation:void 0;void 0!==r&&t.removeElement(r),t.eventDelegator.removeElement(o.elm,r)}t.vnodesBeingRemoved=[]}}}}class Jn{constructor(){this.arr=[],this.prios=[]}add(t,e){for(let n=0;n<this.arr.length;n++)if(this.prios[n]<e)return this.arr.splice(n,0,t),void this.prios.splice(n,0,e);this.arr.push(t),this.prios.push(e)}forEach(t){for(let e=0;e<this.arr.length;e++)t(this.arr[e],e,this.arr)}delete(t){for(let e=0;e<this.arr.length;e++)if(this.arr[e]===t)return this.arr.splice(e,1),void this.prios.splice(e,1)}}const Zn=["blur","focus","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture","canplay","canplaythrough","durationchange","emptied","ended","loadeddata","loadedmetadata","pause","play","playing","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","load","unload","invalid","reset","submit","formdata","toggle","animationstart","animationend","animationiteration","transitionrun","transitionstart","transitionend","scroll","scrollend"];class Xn{constructor(t,e){this.rootElement$=t,this.isolateModule=e,this.virtualListeners=new zn((t=>t.scope)),this.nonBubblingListenersToAdd=new Set,this.virtualNonBubblingListener=[],this.isolateModule.setEventDelegator(this),this.domListeners=new Map,this.domListenersToAdd=new Map,this.nonBubblingListeners=new Map,t.addListener({next:t=>{this.origin!==t&&(this.origin=t,this.resetEventListeners(),this.domListenersToAdd.forEach(((t,e)=>this.setupDOMListener(e,t))),this.domListenersToAdd.clear()),this.nonBubblingListenersToAdd.forEach((t=>{this.setupNonBubblingListener(t)}))}})}addEventListener(t,e,n,o){const r=ce.never();let i;const s=new An(e,this.isolateModule);if(void 0===o?-1===Zn.indexOf(t):o)return this.domListeners.has(t)||this.setupDOMListener(t,!!n.passive),i=this.insertListener(r,s,t,n),r;{const o=[];this.nonBubblingListenersToAdd.forEach((t=>o.push(t)));let a,c=0;const l=o.length,u=n=>{const[o,r,i,s]=n;return t===r&&En(i.namespace,e)};for(;!a&&c<l;){const t=o[c];a=u(t)?t:a,c++}let d,p=a;if(p){const[t]=p;d=t}else{const o=new On(e,this.isolateModule);i=this.insertListener(r,s,t,n),p=[r,t,o,i],d=r,this.nonBubblingListenersToAdd.add(p),this.setupNonBubblingListener(p)}const h=this;let f=null;return ce.create({start:t=>{f=d.subscribe(t)},stop:()=>{const[t,e,n,o]=p;n.call().forEach((function(t){const n=t.subs;n&&n[e]&&(n[e].unsubscribe(),delete n[e])})),h.nonBubblingListenersToAdd.delete(p),f.unsubscribe()}})}}removeElement(t,e){void 0!==e&&this.virtualListeners.delete(e);const n=[];this.nonBubblingListeners.forEach(((e,o)=>{if(e.has(t)){n.push([o,t]);const e=t.subs;e&&Object.keys(e).forEach((t=>{e[t].unsubscribe()}))}}));for(let t=0;t<n.length;t++){const e=this.nonBubblingListeners.get(n[t][0]);e&&(e.delete(n[t][1]),0===e.size?this.nonBubblingListeners.delete(n[t][0]):this.nonBubblingListeners.set(n[t][0],e))}}insertListener(t,e,n,o){const r=[],i=e._namespace;let s=i.length;do{r.push(this.getVirtualListeners(n,i,!0,s)),s--}while(s>=0&&"total"!==i[s].type);const a={...o,scopeChecker:e,subject:t,bubbles:!!o.bubbles,useCapture:!!o.useCapture,passive:!!o.passive};for(let t=0;t<r.length;t++)r[t].add(a,i.length);return a}getVirtualListeners(t,e,n=!1,o){let r=void 0!==o?o:e.length;if(!n)for(let t=r-1;t>=0;t--){if("total"===e[t].type){r=t+1;break}r=t}const i=this.virtualListeners.getDefault(e,(()=>new Map),r);return i.has(t)||i.set(t,new Jn),i.get(t)}setupDOMListener(t,e){if(this.origin){const n=mn(this.origin,t,!1,!1,e).subscribe({next:n=>this.onEvent(t,n,e),error:()=>{},complete:()=>{}});this.domListeners.set(t,{sub:n,passive:e})}else this.domListenersToAdd.set(t,e)}setupNonBubblingListener(t){const[e,n,o,r]=t;if(!this.origin)return;const i=o.call();if(i.length){const t=this;i.forEach((e=>{const o=e.subs;if(!o||!o[n]){const i=mn(e,n,!1,!1,r.passive).subscribe({next:e=>t.onEvent(n,e,!!r.passive,!1),error:()=>{},complete:()=>{}});t.nonBubblingListeners.has(n)||t.nonBubblingListeners.set(n,new Map);const s=t.nonBubblingListeners.get(n);if(!s)return;s.set(e,{sub:i,destination:r}),e.subs={...o,[n]:i}}}))}}resetEventListeners(){const t=this.domListeners.entries();let e=t.next();for(;!e.done;){const[n,{sub:o,passive:r}]=e.value;o.unsubscribe(),this.setupDOMListener(n,r),e=t.next()}}putNonBubblingListener(t,e,n,o){const r=this.nonBubblingListeners.get(t);if(!r)return;const i=r.get(e);i&&i.destination.passive===o&&i.destination.useCapture===n&&(this.virtualNonBubblingListener[0]=i.destination)}onEvent(t,e,n,o=!0){const r=this.patchEvent(e),i=this.isolateModule.getRootElement(e.target);if(o){const o=this.isolateModule.getNamespace(e.target);if(!o)return;const s=this.getVirtualListeners(t,o);this.bubble(t,e.target,i,r,s,o,o.length-1,!0,n),this.bubble(t,e.target,i,r,s,o,o.length-1,!1,n)}else this.putNonBubblingListener(t,e.target,!0,n),this.doBubbleStep(t,e.target,i,r,this.virtualNonBubblingListener,!0,n),this.putNonBubblingListener(t,e.target,!1,n),this.doBubbleStep(t,e.target,i,r,this.virtualNonBubblingListener,!1,n),e.stopPropagation()}bubble(t,e,n,o,r,i,s,a,c){a||o.propagationHasBeenStopped||this.doBubbleStep(t,e,n,o,r,a,c);let l=n,u=s;if(e===n){if(!(s>=0&&"sibling"===i[s].type))return;l=this.isolateModule.getElement(i,s),u--}e.parentNode&&l&&this.bubble(t,e.parentNode,l,o,r,i,u,a,c),a&&!o.propagationHasBeenStopped&&this.doBubbleStep(t,e,n,o,r,a,c)}doBubbleStep(t,e,n,o,r,i,s){n&&(this.mutateEventCurrentTarget(o,e),r.forEach((t=>{if(t.passive===s&&t.useCapture===i){const r=Sn(t.scopeChecker.namespace);!o.propagationHasBeenStopped&&t.scopeChecker.isDirectlyInScope(e)&&(""!==r&&e.matches(r)||""===r&&e===n)&&(_n(o,t.preventDefault),t.subject.shamefullySendNext(o))}})))}patchEvent(t){const e=t;e.propagationHasBeenStopped=!1;const n=e.stopPropagation;return e.stopPropagation=function(){n.call(this),this.propagationHasBeenStopped=!0},e}mutateEventCurrentTarget(t,e){try{Object.defineProperty(t,"currentTarget",{value:e,configurable:!0})}catch(t){}t.ownerTarget=e}}function Kn(t){return ce.merge(t,ce.never())}function Qn(t){return t.elm}function to(t){(console.error||console.log)(t)}function eo(t,e={}){wn(t);const n=e.modules||Yn;!function(t){if(!Array.isArray(t))throw new Error("Optional modules option must be an array for snabbdom modules")}(n);const o=new qn,r=e&&e.snabbdomOptions||void 0,i=tn([o.createModule()].concat(n),void 0,r),s=ce.create({start(t){"loading"===document.readyState?document.addEventListener("readystatechange",(()=>{const e=document.readyState;"interactive"!==e&&"complete"!==e||(t.next(null),t.complete())})):(t.next(null),t.complete())},stop(){}});let a,c;const l=ce.create({start(t){c=new MutationObserver((()=>t.next(null)))},stop(){c.disconnect()}});return function(n,r="DOM"){!function(t){if(!t||"function"!=typeof t.addListener||"function"!=typeof t.fold)throw new Error("The DOM driver function expects as input a Stream of virtual DOM elements")}(n);const u=ce.create(),d=s.map((()=>{const e=function(t){const e="string"==typeof t?document.querySelector(t):t;if("string"==typeof t&&null===e)throw new Error(`Cannot render into unknown element \`${t}\``);return e}(t)||document.body;return a=new Pn(e),e})),p=n.remember();p.addListener({}),l.addListener({});const h=d.map((t=>ce.merge(p.endWhen(u),u).map((t=>a.call(t))).startWith(function(t){return t.data=t.data||{},t.data.isolate=[],t}(en(t))).fold(i,en(t)).drop(1).map(Qn).startWith(t).map((t=>(c.observe(t,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),t))).compose(Kn))).flatten(),f=Pe(s,l).endWhen(u).compose(In(h)).map((t=>t[1])).remember();f.addListener({error:e.reportSnabbdomError||to});const m=new Xn(f,o);return new Cn(f,u,[],o,m,r)}}const no="___";class oo{constructor(t){this._mockConfig=t,t.elements?this._elements=t.elements:this._elements=ue(ce.empty())}elements(){const t=this._elements;return t._isCycleSource="MockedDOM",t}element(){const t=ue(this.elements().filter((t=>t.length>0)).map((t=>t[0])).remember());return t._isCycleSource="MockedDOM",t}events(t,e,n){const o=ue(this._mockConfig[t]||ce.empty());return o._isCycleSource="MockedDOM",o}select(t){const e=this._mockConfig[t]||{};return new oo(e)}isolateSource(t,e){return t.select("."+no+e)}isolateSink(t,e){return ue(ce.fromObservable(t).map((t=>(t.sel&&-1!==t.sel.indexOf(no+e)||(t.sel+=`.${no}${e}`),t))))}}function ro(t){return new oo(t)}let io=0;function so(t,e,n={}){if("function"!=typeof t)throw new Error("collection: first argument (component) must be a function");const{combineList:o=["DOM"],globalList:r=["EVENTS"],stateSourceName:i="STATE",domSourceName:s="DOM",container:a="div",containerClass:c}=n;return n=>{const l="sygnal-collection-"+io++,u={item:t,itemKey:(t,e)=>void 0!==t.id?t.id:e,itemScope:t=>t,channel:i,collectSinks:t=>Object.entries(n).reduce(((e,[n])=>{if(o.includes(n)){const o=t.pickCombine(n);n===s&&a?e[s]=o.map((t=>({sel:a,data:c?{props:{className:c}}:{},children:t,key:l,text:void 0,elm:void 0}))):e[n]=o}else e[n]=t.pickMerge(n);return e}),{})},d={[i]:e};return r.forEach((t=>d[t]=null)),o.forEach((t=>d[t]=null)),function(t,e,n){return he(function(t){return function(e){const n=t.channel||"state",o=t.itemKey,r=t.itemScope||ke,i=ce.fromObservable(e[n].stream).fold(((i,s)=>{const a=i.dict;if(Array.isArray(s)){const i=Array(s.length),c=new Set;for(let l=0,u=s.length;l<u;++l){const u=`${o?o(s[l],l):l}`;if(c.add(u),a.has(u))i[l]=a.get(u);else{const c=o?Le(o,u):`${l}`,d=r(u),p="string"==typeof d?{"*":d,[n]:c}:{...d,[n]:c},h=he(t.itemFactory?t.itemFactory(s[l],l):t.item,p)(e);a.set(u,h),i[l]=h}i[l]._key=u}return a.forEach(((t,e)=>{c.has(e)||(t&&"function"==typeof t.__dispose&&t.__dispose(),a.delete(e))})),c.clear(),{dict:a,arr:i}}{a.forEach((t=>{t&&"function"==typeof t.__dispose&&t.__dispose()})),a.clear();const i=`${o?o(s,0):"this"}`,c=De,l=r(i),u="string"==typeof l?{"*":l,[n]:c}:{...l,[n]:c},d=he(t.itemFactory?t.itemFactory(s,0):t.item,u)(e);return a.set(i,d),{dict:a,arr:[d]}}}),{dict:new Map,arr:[]});return t.collectSinks(new xe(i))}}(t),e)(n)}(u,d,n)}}const ao=t=>{const{children:e,...n}=t;return He("collection",{props:n},e)};function co(t){return t&&t.default&&t.default.default&&"function"==typeof t.default.default?t.default.default:t&&t.default?t.default:t}ao.label="collection",ao.preventInstantiation=!0;const lo=function(t){const e=co(t);return e&&e.default&&"function"==typeof e.default.create?e.default:e}(le),uo=re||ce&&ce.Stream||lo&&lo.Stream,po=co(be);function ho(t,e,n,o={}){const{switched:r=["DOM"],stateSourceName:i="STATE"}=o,s=typeof e;if(!e)throw new Error("Missing 'name$' parameter for switchable()");if(!("string"===s||"function"===s||e instanceof uo))throw new Error("Invalid 'name$' parameter for switchable(): expects Stream, String, or Function");if(e instanceof uo){const o=e.compose(po()).startWith(n).remember();return e=>fo(t,e,o,r)}{const o="function"===s&&e||(t=>t[e]);return e=>{const s=e&&("string"==typeof i&&e[i]||e.STATE||e.state).stream;if(!(s instanceof uo))throw new Error(`Could not find the state source: ${i}`);const a=s.map(o).filter((t=>"string"==typeof t)).compose(po()).startWith(n).remember();return fo(t,e,a,r,i)}}}function fo(t,e,n,o=["DOM"],r="STATE"){"string"==typeof o&&(o=[o]);const i=Object.entries(t).map((([t,o])=>{if(e[r]){const i=e[r].stream,s=lo.combine(n,i).filter((([e])=>e==t)).map((([,t])=>t)).remember(),a=new e[r].constructor(s,e[r]._name);return[t,o({...e,state:a})]}return[t,o(e)]}));return Object.keys(e).reduce(((t,e)=>{if(o.includes(e))t[e]=n.map((t=>{const n=i.find((([e])=>e===t));return n&&n[1][e]||lo.never()})).flatten().remember().startWith(void 0);else{const n=i.filter((([,t])=>void 0!==t[e])).map((([,t])=>t[e]));t[e]=lo.merge(...n)}return t}),{})}const mo=t=>{const{children:e,...n}=t;return He("switchable",{props:n},e)};function yo(t){return{select:e=>t._stream.filter((t=>t.type===e)).map((t=>t.data))}}mo.label="switchable",mo.preventInstantiation=!0;var _o={};Object.defineProperty(_o,"__esModule",{value:!0});var vo=r,go=function(){function t(t,e){this.dt=t,this.ins=e,this.type="delay",this.out=null}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=null},t.prototype._n=function(t){var e=this.out;if(e)var n=setInterval((function(){e._n(t),clearInterval(n)}),this.dt)},t.prototype._e=function(t){var e=this.out;if(e)var n=setInterval((function(){e._e(t),clearInterval(n)}),this.dt)},t.prototype._c=function(){var t=this.out;if(t)var e=setInterval((function(){t._c(),clearInterval(e)}),this.dt)},t}();var bo=_o.default=function(t){return function(e){return new vo.Stream(new go(t,e))}},wo=e({__proto__:null,default:bo},[_o]),So={};Object.defineProperty(So,"__esModule",{value:!0});var Eo=r,Ao=function(){function t(t,e){this.dt=t,this.ins=e,this.type="debounce",this.out=null,this.id=null,this.t=Eo.NO}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=null,this.clearInterval()},t.prototype.clearInterval=function(){var t=this.id;null!==t&&clearInterval(t),this.id=null},t.prototype._n=function(t){var e=this,n=this.out;n&&(this.clearInterval(),this.t=t,this.id=setInterval((function(){e.clearInterval(),n._n(t),e.t=Eo.NO}),this.dt))},t.prototype._e=function(t){var e=this.out;e&&(this.clearInterval(),e._e(t))},t.prototype._c=function(){var t=this.out;t&&(this.clearInterval(),this.t!=Eo.NO&&t._n(this.t),this.t=Eo.NO,t._c())},t}();var Oo=So.default=function(t){return function(e){return new Eo.Stream(new Ao(t,e))}},No=e({__proto__:null,default:Oo},[So]);const Co=co(wo),To=co(Re),$o=co(No),xo=co(be),ko="undefined"!=typeof window&&window||"undefined"!=typeof process&&process.env||{},Lo="BOOTSTRAP",Do="INITIALIZE",jo="DISPOSE",Io="PARENT",Mo="READY",Po="EFFECT";let Ro=0;const Fo=Symbol.for("sygnal.ABORT");function Go(t){return t===Fo||"symbol"==typeof t&&"sygnal.ABORT"===t.description}function Bo(t,e){if("function"==typeof e)return{fn:e,deps:null};if(Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&"function"==typeof e[1])return{fn:e[1],deps:e[0]};throw new Error(`Invalid calculated field '${t}': expected a function or [depsArray, function]`)}function Uo(t){const{name:e,sources:n,isolateOpts:o,stateSourceName:r="STATE"}=t;if(n&&!ir(n))throw new Error(`[${e}] Sources must be a Cycle.js sources object`);let i;i="string"==typeof o?{[r]:o}:!0===o?{}:o;const s=void 0===n;let a;if(ir(i)){const e=e=>{const n={...t,sources:e},o=new Vo(n);return o.sinks.__dispose=()=>o.dispose(),o.sinks};a=s?he(e,i):he(e,i)(n)}else if(s)a=e=>{const n=new Vo({...t,sources:e});return n.sinks.__dispose=()=>n.dispose(),n.sinks};else{const e=new Vo(t);e.sinks.__dispose=()=>e.dispose(),a=e.sinks}return a.componentName=e,a.isSygnalComponent=!0,a}class Vo{constructor({name:t="NO NAME",sources:e,intent:n,model:o,hmrActions:r,context:i,response:s,view:a,peers:c={},components:l={},initialState:u,calculated:d,storeCalculatedInState:p=!0,DOMSourceName:h="DOM",stateSourceName:f="STATE",requestSourceName:m="HTTP",isolatedState:y=!1,onError:_,debug:v=!1}){if(!e||!ir(e))throw new Error(`[${t}] Missing or invalid sources`);if(this._componentNumber=Ro++,this.name=t,this.sources=e,this.intent=n,this.model=o,this.hmrActions=r,this.context=i,this.response=s,this.view=a,this.peers=c,this.components=l,this.initialState=u,this.calculated=d,this.storeCalculatedInState=p,this.DOMSourceName=h,this.stateSourceName=f,this.requestSourceName=m,this.sourceNames=Object.keys(e),this.onError=_,this.isolatedState=y,this._debug=v,this.calculated&&this.initialState&&ir(this.calculated)&&ir(this.initialState))for(const e of Object.keys(this.calculated))e in this.initialState&&console.warn(`[${t}] Calculated field '${e}' shadows a key in initialState. The initialState value will be overwritten on every state update.`);if(this.calculated&&ir(this.calculated)){const e=Object.entries(this.calculated);this._calculatedNormalized={};for(const[t,n]of e)this._calculatedNormalized[t]=Bo(t,n);this._calculatedFieldNames=new Set(Object.keys(this._calculatedNormalized));for(const[e,{deps:n}]of Object.entries(this._calculatedNormalized))if(null!==n)for(const o of n)this._calculatedFieldNames.has(o)||!this.initialState||o in this.initialState||console.warn(`[${t}] Calculated field '${e}' declares dependency '${o}' which is not in initialState or calculated fields`);const n={};for(const[t,{deps:e}]of Object.entries(this._calculatedNormalized))n[t]=null===e?[]:e.filter((t=>this._calculatedFieldNames.has(t)));const o={},r={};for(const t of this._calculatedFieldNames)o[t]=0,r[t]=[];for(const[t,e]of Object.entries(n)){o[t]=e.length;for(const n of e)r[n].push(t)}const i=[];for(const[t,e]of Object.entries(o))0===e&&i.push(t);const s=[];for(;i.length>0;){const t=i.shift();s.push(t);for(const e of r[t])o[e]--,0===o[e]&&i.push(e)}if(s.length!==this._calculatedFieldNames.size){const t=[...this._calculatedFieldNames].filter((t=>!s.includes(t))),e=new Set,o=[],r=i=>{if(e.has(i))return o.push(i),!0;e.add(i),o.push(i);for(const e of n[i])if(t.includes(e)&&r(e))return!0;return o.pop(),e.delete(i),!1};r(t[0]);const i=o[o.length-1],a=o.slice(o.indexOf(i));throw new Error(`Circular calculated dependency: ${a.join(" → ")}`)}this._calculatedOrder=s.map((t=>[t,this._calculatedNormalized[t]])),this._calculatedFieldCache={};for(const[t,{deps:e}]of this._calculatedOrder)null!==e&&(this._calculatedFieldCache[t]={lastDepValues:void 0,lastResult:void 0})}else this._calculatedOrder=null,this._calculatedNormalized=null,this._calculatedFieldNames=null,this._calculatedFieldCache=null;this.isSubComponent=this.sourceNames.includes("props$");const g=e[f]&&e[f].stream;this.currentSlots={},g&&(this.currentState=u||{},this.sources[f]=new Oe(g.map((t=>(this.currentState=t,"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onStateChanged(this._componentNumber,this.name,t),t))),f));const b=e.props$;b&&(this.sources.props$=b.map((t=>{const{sygnalFactory:e,sygnalOptions:n,...o}=t;return this.currentProps=o,"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onPropsChanged(this._componentNumber,this.name,o),t})));const w=e.children$;var S;if(w&&(this.sources.children$=w.map((t=>{if(Array.isArray(t)){const{slots:e,defaultChildren:n}=lr(t);this.currentSlots=e,this.currentChildren=n}else this.currentSlots={},this.currentChildren=t;return t}))),this.sources[h]&&(this.sources[h]=(S=this.sources[h],new Proxy(S,{get:(t,e,n)=>"symbol"==typeof e||e in t?Reflect.get(t,e,n):n=>t.select(n).events(e)}))),this.isSubComponent||void 0!==this.intent||void 0!==this.model||(this.initialState=u||!0,this.intent=t=>({__NOOP_ACTION__:lo.never()}),this.model={__NOOP_ACTION__:t=>t}),this._subscriptions=[],this._activeSubComponents=new Map,this._childReadyState={},this._readyChangedListener=null,this._readyChanged$=lo.create({start:t=>{this._readyChangedListener=t},stop:()=>{}}),this._disposeListener=null,this._dispose$=lo.create({start:t=>{this._disposeListener=t},stop:()=>{}}),this.sources.dispose$=this._dispose$,this.addCalculated=this.createMemoizedAddCalculated(),this.log=function(t){return function(e,n=!1){const o="function"==typeof e?e:t=>e;if(!n)return e=>e.debug((e=>{if(this.debug){const n=`[${t}] ${o(e)}`;console.log(n),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onDebugLog(this._componentNumber,n)}}));if(this.debug){const n=`[${t}] ${o(e)}`;console.log(n),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onDebugLog(this._componentNumber,n)}}}(`${this._componentNumber} | ${t}`),this.initChildSources$(),this.initIntent$(),this.initHmrActions(),this.initAction$(),this.initState(),this.initContext(),this.initModel$(),this.initPeers$(),this.initSubComponentSink$(),this.initSubComponentsRendered$(),this.initVdom$(),this.initSinks(),this.sinks.__index=this._componentNumber,this.log("Instantiated",!0),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__){window.__SYGNAL_DEVTOOLS__.onComponentCreated(this._componentNumber,t,this);const n=e?.__parentComponentNumber;"number"==typeof n&&window.__SYGNAL_DEVTOOLS__.onSubComponentRegistered(n,this._componentNumber)}}dispose(){"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onComponentDisposed(this._componentNumber,this.name);if(this.model&&(this.model[jo]||Object.keys(this.model).some((t=>t.includes("|")&&t.split("|")[0].trim()===jo)))&&this.action$&&"function"==typeof this.action$.shamefullySendNext)try{this.action$.shamefullySendNext({type:jo})}catch(t){}if(this._disposeListener){try{this._disposeListener.next(!0),this._disposeListener.complete()}catch(t){}this._disposeListener=null}setTimeout((()=>{if(this.action$&&"function"==typeof this.action$.shamefullySendComplete)try{this.action$.shamefullySendComplete()}catch(t){}if(this.vdom$&&"function"==typeof this.vdom$.shamefullySendComplete)try{this.vdom$.shamefullySendComplete()}catch(t){}for(const t of this._subscriptions)if(t&&"function"==typeof t.unsubscribe)try{t.unsubscribe()}catch(t){}this._subscriptions=[],this._activeSubComponents.forEach((t=>{t?.sink$?.__dispose&&t.sink$.__dispose()})),this._activeSubComponents.clear()}),0)}get debug(){return this._debug||"true"===ko.SYGNAL_DEBUG||!0===ko.SYGNAL_DEBUG}initIntent$(){if(this.intent){if("function"!=typeof this.intent)throw new Error(`[${this.name}] Intent must be a function`);if(this.intent$=this.intent(this.sources),!(this.intent$ instanceof uo||ir(this.intent$)))throw new Error(`[${this.name}] Intent must return either an action$ stream or map of event streams`)}}initHmrActions(){if(void 0!==this.hmrActions){if("string"==typeof this.hmrActions&&(this.hmrActions=[this.hmrActions]),!Array.isArray(this.hmrActions))throw new Error(`[${this.name}] hmrActions must be the name of an action or an array of names of actions to run when a component is hot-reloaded`);if(this.hmrActions.some((t=>"string"!=typeof t)))throw new Error(`[${this.name}] hmrActions must be the name of an action or an array of names of actions to run when a component is hot-reloaded`);this.hmrAction$=lo.fromArray(this.hmrActions.map((t=>({type:t}))))}else this.hmrAction$=lo.of().filter((t=>!1))}initAction$(){const t=this.sources&&this.sources[this.requestSourceName]||null;if(!this.intent$)return void(this.action$=lo.never());let e;if(this.intent$ instanceof uo)e=this.intent$;else{for(const t of Object.keys(this.intent$))if(t.includes("|"))throw new Error(`[${this.name}] Intent action name '${t}' contains '|', which is reserved for the model shorthand syntax (e.g., 'ACTION | DRIVER'). Rename this action.`);const t=Object.entries(this.intent$).map((([t,e])=>e.map((e=>({type:t,data:e})))));e=lo.merge(lo.never(),...t)}const n=e instanceof uo?e:e.apply&&e(this.sources)||lo.never(),o=lo.of({type:Lo}).compose(Co(10)),r="undefined"!=typeof window&&!0===window.__SYGNAL_HMR_UPDATING,i=r?this.hmrAction$:lo.of().filter((t=>!1)),s=this.model[Lo]&&!r?To(o,n):To(lo.of().compose(Co(1)).filter((t=>!1)),i,n);let a;a=!r&&t&&"function"==typeof t.select?t.select("initial").flatten():lo.never();const c=a.map((t=>({type:"HYDRATE",data:t})));this.action$=lo.merge(s,c).compose(this.log((({type:t})=>`<${t}> Action triggered`))).map((t=>("undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onActionDispatched(this._componentNumber,this.name,t.type,t.data),t)))}initState(){void 0!==this.model&&(void 0===this.model[Do]?this.model[Do]={[this.stateSourceName]:(t,e)=>({...this.addCalculated(e)})}:ir(this.model[Do])&&Object.keys(this.model[Do]).forEach((t=>{t!==this.stateSourceName&&(console.warn(`${Do} can only be used with the ${this.stateSourceName} source... disregarding ${t}`),delete this.model[Do][t])})))}initContext(){if(!this.context&&!this.sources.__parentContext$)return void(this.context$=lo.of({}));const t=this.sources[this.stateSourceName]?.stream.startWith({}).compose(xo(or))||lo.never(),e=this.sources.__parentContext$?.startWith({}).compose(xo(or))||lo.of({});this.context&&!ir(this.context)&&console.error(`[${this.name}] Context must be an object mapping names to values of functions: ignoring provided ${typeof this.context}`),this.context$=lo.combine(t,e).map((([t,e])=>{const n=ir(e)?e:{},o=ir(this.context)?this.context:{},r=this.currentState,i={...n,...Object.entries(o).reduce(((t,e)=>{const[n,o]=e;let i;const s=typeof o;if("string"===s)i=r[o];else if("boolean"===s)i=r[n];else{if("function"!==s)return console.error(`[${this.name}] Invalid context entry '${n}': must be the name of a state property or a function returning a value to use`),t;i=o(r)}return t[n]=i,t}),{})};return this.currentContext=i,"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onContextChanged(this._componentNumber,this.name,i),i})).compose(xo(or)).startWith({}),this._subscriptions.push(this.context$.subscribe({next:t=>t,error:t=>console.error(`[${this.name}] Error in context stream:`,t)}))}initModel$(){if(void 0===this.model)return void(this.model$=this.sourceNames.reduce(((t,e)=>(t[e]=lo.never(),t)),{}));const t=ko?.__SYGNAL_HMR_STATE,e=void 0!==t?t:this.initialState,n={type:Do,data:e};this.isSubComponent&&this.initialState&&!this.isolatedState&&console.warn(`[${this.name}] Initial state provided to sub-component. This will overwrite any state provided by the parent component.`);const o=void 0!==e&&(!0!==ko?.__SYGNAL_HMR_UPDATING||void 0!==t)?To(lo.of(n),this.action$).compose(Co(0)):this.action$,r=()=>this.makeOnAction(o,!0,this.action$),i=()=>this.makeOnAction(this.action$,!1,this.action$),s=Object.entries(this.model),a={},c=new Set;s.forEach((t=>{let[e,n]=t;if(e.includes("|")){const t=e.split("|").map((t=>t.trim()));if(2!==t.length||!t[0]||!t[1])throw new Error(`[${this.name}] Invalid shorthand model entry '${e}'. Expected 'ACTION | DRIVER' format.`);e=t[0],n={[t[1]]:n}}if("function"==typeof n&&(n={[this.stateSourceName]:n}),!ir(n))throw new Error(`[${this.name}] Entry for each action must be an object: ${e}`);Object.entries(n).forEach((t=>{const[n,o]=t,s=`${e}::${n}`;if(c.has(s)&&console.warn(`[${this.name}] Duplicate model entry for action '${e}' on sink '${n}'. Only the last definition will take effect.`),c.add(s),n===Po){const t=this.makeEffectHandler(this.action$,e,o);return void(Array.isArray(a[n])?a[n].push(t):a[n]=[t])}const l=n===this.stateSourceName,u=n===Io,d=l?r():i(),p=(u?d(e,o).map((t=>({name:this.name,component:this.view,value:t}))):d(e,o)).compose(this.log((t=>{if(l)return`<${e}> State reducer added`;if(u)return`<${e}> Data sent to parent component: ${JSON.stringify(t.value).replaceAll('"',"")}`;{const o=t&&(t.type||t.command||t.name||t.key||Array.isArray(t)&&"Array"||t);return`<${e}> Data sent to [${n}]: ${JSON.stringify(o).replaceAll('"',"")}`}})));Array.isArray(a[n])?a[n].push(p):a[n]=[p]}))}));const l=Object.entries(a).reduce(((t,e)=>{const[n,o]=e;return t[n]=lo.merge(lo.never(),...o),t}),{});this.model$=l}initPeers$(){const t=this.sourceNames.reduce(((t,e)=>(e==this.DOMSourceName?t[e]={}:t[e]=[],t)),{});this.peers$=Object.entries(this.peers).reduce(((t,[e,n])=>{const o=n(this.sources);return this.sourceNames.forEach((n=>{n==this.DOMSourceName?t[n][e]=o[n]:t[n].push(o[n])})),t}),t)}initChildSources$(){let t;const e=lo.create({start:e=>{t=e.next.bind(e)},stop:t=>{}}).map((t=>lo.merge(...t))).flatten();this.sources.CHILD={select:t=>{const n=e;return("function"==typeof t?n.filter((e=>e.component===t)):t?n.filter((e=>e.name===t)):n).map((t=>t.value))}},this.newChildSources=e=>{"function"==typeof t&&t(e)}}initSubComponentSink$(){const t=lo.create({start:t=>{this.newSubComponentSinks=t.next.bind(t)},stop:t=>{}});this._subscriptions.push(t.subscribe({next:t=>t,error:t=>console.error(`[${this.name}] Error in sub-component sink stream:`,t)})),this.subComponentSink$=t.filter((t=>Object.keys(t).length>0))}initSubComponentsRendered$(){const t=lo.create({start:t=>{this.triggerSubComponentsRendered=t.next.bind(t)},stop:t=>{}});this.subComponentsRendered$=t.startWith(null)}initVdom$(){if("function"!=typeof this.view)return void(this.vdom$=lo.of(null));const t=this.collectRenderParameters();this.vdom$=t.map((t=>{const{props:e,state:n,children:o,slots:r,context:i,...s}=t,{sygnalFactory:a,sygnalOptions:c,...l}=e||{};try{return this.view({...l,state:n,children:o,slots:r||{},context:i,peers:s},n,i,s)}catch(t){const e=t instanceof Error?t:new Error(String(t));if(console.error(`[${this.name}] Error in view:`,e),"function"==typeof this.onError)try{return this.onError(e,{componentName:this.name})}catch(t){console.error(`[${this.name}] Error in onError handler:`,t)}return{sel:"div",data:{attrs:{"data-sygnal-error":this.name}},children:[]}}})).compose(this.log("View rendered")).map((t=>t||{sel:"div",data:{},children:[]})).map((t=>Qo(t,this))).map(Zo).map(Xo).map(Ko).compose(this.instantiateSubComponents.bind(this)).filter((t=>void 0!==t)).compose(this.renderVdom.bind(this))}initSinks(){if(this.sinks=this.sourceNames.reduce(((t,e)=>{if(e==this.DOMSourceName)return t;const n=this.subComponentSink$&&e!==Io?this.subComponentSink$.map((t=>t[e])).filter((t=>!!t)).flatten():lo.never();if(e===this.stateSourceName?t[e]=lo.merge(this.model$[e]||lo.never(),n,this.sources[this.stateSourceName].stream.filter((t=>!1)),...this.peers$[e]||[]):t[e]=lo.merge(this.model$[e]||lo.never(),n,...this.peers$[e]||[]),"EVENTS"===e&&t[e]){const n=this._componentNumber,o=this.name;t[e]=t[e].map((t=>({...t,__emitterId:n,__emitterName:o})))}return t}),{}),this.sinks[this.DOMSourceName]=this.vdom$,this.sinks[Io]=this.model$[Io]||lo.never(),this.model$[Po]){const t=this.model$[Po].subscribe({next:()=>{},error:t=>console.error(`[${this.name}] Uncaught error in EFFECT stream:`,t)});this._subscriptions.push(t),delete this.sinks[Po]}this.model&&ir(this.model)&&Object.values(this.model).some((t=>!(!ir(t)||!(Mo in t))))?(this.sinks[Mo]=this.model$[Mo],this.sinks[Mo].__explicitReady=!0):this.sinks[Mo]=lo.of(!0)}makeOnAction(t,e=!0,n){return n=n||t,(o,r)=>{const i=t.filter((({type:t})=>t==o));let s;if("function"==typeof r)s=i.map((t=>{const i=(t,e,r=10)=>{if("number"!=typeof r)throw new Error(`[${this.name}] Invalid delay value provided to next() function in model action '${o}'. Must be a number in ms.`);setTimeout((()=>{n.shamefullySendNext({type:t,data:e})}),r),this.log(`<${o}> Triggered a next() action: <${t}> ${r}ms delay`,!0)},s={...this.currentProps,children:this.currentChildren,slots:this.currentSlots||{},context:this.currentContext};let a=t.data;if(e)return t=>{const e=this.isSubComponent?this.currentState:t;try{const t=this.addCalculated(e);s.state=t;const n=r(t,a,i,s);return Go(n)?e:this.cleanupCalculated(n)}catch(t){return console.error(`[${this.name}] Error in model reducer '${o}':`,t),e}};try{const t=this.addCalculated(this.currentState);s.state=t;const e=r(t,a,i,s),n=typeof e;if(ir(e)||["string","number","boolean","function"].includes(n))return e;if("undefined"===n)return console.warn(`[${this.name}] 'undefined' value sent to ${o}`),e;throw new Error(`[${this.name}] Invalid reducer type for action '${o}': ${n}`)}catch(t){return console.error(`[${this.name}] Error in model reducer '${o}':`,t),Fo}})).filter((t=>!Go(t)));else if(void 0===r||!0===r)s=i.map((({data:t})=>t));else{const t=r;s=i.mapTo(t)}return s}}makeEffectHandler(t,e,n){return t.filter((({type:t})=>t==e)).map((o=>{if("function"==typeof n){const r=(n,o,r=10)=>{if("number"!=typeof r)throw new Error(`[${this.name}] Invalid delay value provided to next() function in EFFECT handler '${e}'. Must be a number in ms.`);setTimeout((()=>{t.shamefullySendNext({type:n,data:o})}),r),this.log(`<${e}> EFFECT triggered a next() action: <${n}> ${r}ms delay`,!0)};try{const t=this.addCalculated(this.currentState),i={...this.currentProps,children:this.currentChildren,slots:this.currentSlots||{},context:this.currentContext,state:t};void 0!==n(t,o.data,r,i)&&console.warn(`[${this.name}] EFFECT handler '${e}' returned a value. EFFECT handlers are for side effects only — return values are ignored.`)}catch(t){console.error(`[${this.name}] Error in EFFECT handler '${e}':`,t)}}return null})).filter((t=>!1))}createMemoizedAddCalculated(){let t,e;return function(n){if(!this.calculated||!ir(n)||Array.isArray(n))return n;if(n===t)return e;if(!ir(this.calculated))throw new Error(`[${this.name}] 'calculated' parameter must be an object mapping calculated state field names to functions`);const o=this.getCalculatedValues(n);if(!o)return t=n,e=n,n;const r={...n,...o};return t=n,e=r,r}}getCalculatedValues(t){if(!this._calculatedOrder||0===this._calculatedOrder.length)return;const e={...t},n={};for(const[t,{fn:o,deps:r}]of this._calculatedOrder)if(null!==r&&this._calculatedFieldCache){const i=this._calculatedFieldCache[t],s=r.map((t=>e[t]));if(void 0!==i.lastDepValues){let o=!0;for(let t=0;t<s.length;t++)if(s[t]!==i.lastDepValues[t]){o=!1;break}if(o){n[t]=i.lastResult,e[t]=i.lastResult;continue}}try{const r=o(e);i.lastDepValues=s,i.lastResult=r,n[t]=r,e[t]=r}catch(e){console.warn(`Calculated field '${t}' threw an error during calculation: ${e instanceof Error?e.message:e}`)}}else try{const r=o(e);n[t]=r,e[t]=r}catch(e){console.warn(`Calculated field '${t}' threw an error during calculation: ${e instanceof Error?e.message:e}`)}return n}cleanupCalculated(t){if(!t||!ir(t)||Array.isArray(t))return t;const e={...this.storeCalculatedInState?this.addCalculated(t):t};if(!this.calculated||this.storeCalculatedInState)return e;return Object.keys(this.calculated).forEach((t=>{this.initialState&&void 0!==this.initialState[t]?e[t]=this.initialState[t]:delete e[t]})),e}collectRenderParameters(){const t=this.sources[this.stateSourceName],e={...this.peers$[this.DOMSourceName]},n=t&&t.isolateSource(t,{get:t=>this.addCalculated(t)}),o=n&&n.stream||lo.never();if(e.state=o.compose(xo(or)),this.sources.props$&&(e.props=this.sources.props$.compose(xo(nr))),this.sources.children$){const t=this.sources.children$.map((t=>{if(!Array.isArray(t))return{children:t,slots:{}};const{slots:e,defaultChildren:n}=lr(t);return{children:n,slots:e}}));e.children=t.map((t=>t.children)).compose(xo(or)),e.slots=t.map((t=>t.slots)).compose(xo(or))}this.context$&&(e.context=this.context$.compose(xo(or)));const r=[],i=[];Object.entries(e).forEach((([t,e])=>{r.push(t),i.push(e)}));return lo.combine(...i).compose($o(1)).map((t=>r.reduce(((e,n,o)=>(e[n]=t[o],"state"===n&&(e[this.stateSourceName]=t[o],e.calculated=t[o]&&this.getCalculatedValues(t[o])||{}),e)),{})))}instantiateSubComponents(t){return t.fold(((t,e)=>{const n=Ho(e,Object.keys(this.components)),o=Object.entries(n),r={"::ROOT::":e};if(0===o.length)return this._activeSubComponents.forEach((t=>{t?.sink$?.__dispose&&t.sink$.__dispose()})),this._activeSubComponents.clear(),r;const i={},s=[];let a=0;const c=o.reduce(((e,[n,o])=>{const r=o.data,c=r.props||{},l=o.children||[],u=r.isCollection||!1,d=r.isSwitchable||!1,p=t=>{Object.entries(t).forEach((([t,e])=>{i[t]||(i[t]=[]),t===Io?s.push(e):t!==this.DOMSourceName&&t!==Mo&&i[t].push(e)}))};if(t[n]){const o=t[n];return e[n]=o,o.props$.shamefullySendNext(c),o.children$.shamefullySendNext(l),p(o.sink$),e}const h=lo.create().startWith(c),f=lo.create().startWith(l);let m,y;m=u?this.instantiateCollection.bind(this):d?this.instantiateSwitchable.bind(this):this.instantiateCustomComponent.bind(this),a++;try{y=m(o,h,f)}catch(t){const e=t instanceof Error?t:new Error(String(t));console.error(`[${this.name}] Error instantiating sub-component:`,e);let n={sel:"div",data:{attrs:{"data-sygnal-error":this.name}},children:[]};if("function"==typeof this.onError)try{n=this.onError(e,{componentName:this.name})||n}catch(t){console.error(`[${this.name}] Error in onError handler:`,t)}y={[this.DOMSourceName]:lo.of(n)}}return y[this.DOMSourceName]=y[this.DOMSourceName]?this.makeCoordinatedSubComponentDomSink(y[this.DOMSourceName]):lo.never(),e[n]={sink$:y,props$:h,children$:f},this._activeSubComponents.set(n,e[n]),p(y),e}),r),l=Object.entries(i).reduce(((t,[e,n])=>(0===n.length||(t[e]=1===n.length?n[0]:lo.merge(...n)),t)),{}),u=new Set(Object.keys(c));return this._activeSubComponents.forEach(((t,e)=>{u.has(e)||(t?.sink$?.__dispose&&t.sink$.__dispose(),this._activeSubComponents.delete(e),delete this._childReadyState[e])})),this.newSubComponentSinks(l),this.newChildSources(s),a>0&&this.log(`New sub components instantiated: ${a}`,!0),c}),{})}makeCoordinatedSubComponentDomSink(t){const e=t.remember();return this.sources[this.stateSourceName].stream.compose(xo(or)).map((t=>e)).flatten().debug((t=>this.triggerSubComponentsRendered())).remember()}instantiateCollection(t,e,n){const o=t.data.props||{};const r={filter:"function"==typeof o.filter?o.filter:void 0,sort:cr(o.sort)},i=lo.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState),e.startWith(o)).compose($o(1)).map((([t,e])=>(e.filter!==r.filter&&(r.filter="function"==typeof e.filter?e.filter:void 0),e.sort!==r.sort&&(r.sort=cr(e.sort)),ir(t)?this.addCalculated(t):t))),s=new Oe(i,this.stateSourceName),a=o.from,c=o.of,l=o.idfield||"id";let u,d;if("function"==typeof c)if(c.isSygnalComponent)d=c;else{const t=c.componentName||c.label||c.name||"FUNCTION_COMPONENT",e=c,{model:n,intent:o,hmrActions:r,context:i,peers:s,components:a,initialState:l,calculated:u,storeCalculatedInState:p,DOMSourceName:h,stateSourceName:f,onError:m,debug:y}=c;d=Uo({name:t,view:e,model:n,intent:o,hmrActions:r,context:i,peers:s,components:a,initialState:l,calculated:u,storeCalculatedInState:p,DOMSourceName:h,stateSourceName:f,onError:m,debug:y})}else{if(!this.components[c])throw new Error(`[${this.name}] Invalid 'of' property in collection: ${c}`);d=this.components[c]}const p={get:t=>{if(!Array.isArray(t[a]))return[];const e=t[a],n="function"==typeof r.filter?e.filter(r.filter):e;return("function"==typeof r.sort?n.sort(r.sort):n).map(((t,e)=>ir(t)?{...t,[l]:t[l]||e}:{value:t,[l]:e}))},set:(t,e)=>{if(this.calculated&&a in this.calculated)return console.warn(`Collection sub-component of ${this.name} attempted to update state on a calculated field '${a}': Update ignored`),t;const n=[];for(const o of t[a].map(((t,e)=>ir(t)?{...t,[l]:t[l]||e}:{__primitive:!0,value:t,[l]:e})))if("function"!=typeof r.filter||r.filter(o)){const t=e.find((t=>t[l]===o[l]));void 0!==t&&n.push(o.__primitive?t.value:t)}else n.push(o.__primitive?o.value:o);return{...t,[a]:n}}};void 0===a?u={get:t=>!(t instanceof Array)&&t.value&&t.value instanceof Array?t.value:t,set:(t,e)=>e}:"string"==typeof a?ir(this.currentState)?this.currentState&&a in this.currentState||this.calculated&&a in this.calculated?(Array.isArray(this.currentState[a])||console.warn(`[${this.name}] State property '${a}' in collection component is not an array: No components will be instantiated in the collection.`),u=p):(console.error(`Collection component in ${this.name} is attempting to use non-existent state property '${a}': To fix this error, specify a valid array property on the state. Attempting to use parent component state.`),u=void 0):(Array.isArray(this.currentState[a])||console.warn(`[${this.name}] State property '${a}' in collection component is not an array: No components will be instantiated in the collection.`),u=p):ir(a)?"function"!=typeof a.get?(console.error(`Collection component in ${this.name} has an invalid 'from' field: Expecting 'undefined', a string indicating an array property in the state, or an object with 'get' and 'set' functions for retrieving and setting child state from the current state. Attempting to use parent component state.`),u=void 0):u={get:t=>{const e=a.get(t);return Array.isArray(e)?e:(console.warn(`State getter function in collection component of ${this.name} did not return an array: No components will be instantiated in the collection. Returned value:`,e),[])},set:a.set}:(console.error(`Collection component in ${this.name} has an invalid 'from' field: Expecting 'undefined', a string indicating an array property in the state, or an object with 'get' and 'set' functions for retrieving and setting child state from the current state. Attempting to use parent component state.`),u=void 0);const h=["of","from","filter","sort","idfield","className"],f=e.map((t=>{if(!t||"object"!=typeof t)return{};const e={};for(const n in t)h.includes(n)||(e[n]=t[n]);return e})),m={...this.sources,[this.stateSourceName]:s,props$:f,children$:n,__parentContext$:this.context$,PARENT:null,__parentComponentNumber:this._componentNumber},y=so(d,u,{container:null})(m);if(!ir(y))throw new Error(`[${this.name}] Invalid sinks returned from component factory of collection element`);if("undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected){const t="function"==typeof c?c.componentName||c.label||c.name||"anonymous":String(c);window.__SYGNAL_DEVTOOLS__.onCollectionMounted(this._componentNumber,this.name,t,"string"==typeof a?a:null)}return y}instantiateSwitchable(t,e,n){const o=t.data.props||{},r=this.sources[this.stateSourceName].stream.startWith(this.currentState).map((t=>ir(t)?this.addCalculated(t):t)),i=new Oe(r,this.stateSourceName),s=o.state;let a;const c={get:t=>t,set:(t,e)=>e};void 0===s?a=c:"string"==typeof s?a={get:t=>t[s],set:(t,e)=>this.calculated&&s in this.calculated?(console.warn(`Switchable sub-component of ${this.name} attempted to update state on a calculated field '${s}': Update ignored`),t):!ir(e)||Array.isArray(e)?{...t,[s]:e}:{...t,[s]:e}}:ir(s)?"function"!=typeof s.get?(console.error(`Switchable component in ${this.name} has an invalid 'state' field: Expecting 'undefined', a string indicating an array property in the state, or an object with 'get' and 'set' functions for retrieving and setting sub-component state from the current state. Attempting to use parent component state.`),a=c):a={get:s.get,set:s.set}:(console.error(`Invalid state provided to switchable sub-component of ${this.name}: Expecting string, object, or undefined, but found ${typeof s}. Attempting to use parent component state.`),a=c);const l=o.of;Object.keys(l).forEach((t=>{const e=l[t];if(!e.isSygnalComponent){const n=e.componentName||e.label||e.name||"FUNCTION_COMPONENT",o=e,{model:r,intent:i,hmrActions:s,context:a,peers:c,components:u,initialState:d,calculated:p,storeCalculatedInState:h,DOMSourceName:f,stateSourceName:m,onError:y,debug:_}=e,v={name:n,view:o,model:r,intent:i,hmrActions:s,context:a,peers:c,components:u,initialState:d,calculated:p,storeCalculatedInState:h,DOMSourceName:f,stateSourceName:m,onError:y,debug:_};l[t]=Uo(v)}}));const u={...this.sources,[this.stateSourceName]:i,props$:e,children$:n,__parentContext$:this.context$,__parentComponentNumber:this._componentNumber},d=he(ho(l,e.map((t=>t.current)),""),{[this.stateSourceName]:a})(u);if(!ir(d))throw new Error(`[${this.name}] Invalid sinks returned from component factory of switchable element`);return d}instantiateCustomComponent(t,e,n){const o=t.sel,r=t.data.props||{},i=this.sources[this.stateSourceName].stream.startWith(this.currentState).map((t=>ir(t)?this.addCalculated(t):t)),s=new Oe(i,this.stateSourceName),a=r.state;"function"!=typeof r.sygnalFactory&&ir(r.sygnalOptions)&&(r.sygnalFactory=Uo(r.sygnalOptions));const c="sygnal-factory"===o?r.sygnalFactory:this.components[o]||r.sygnalFactory;if(!c){if("sygnal-factory"===o)throw new Error("Component not found on element with Capitalized selector and nameless function: JSX transpilation replaces selectors starting with upper case letters with functions in-scope with the same name, Sygnal cannot see the name of the resulting component.");throw new Error(`Component not found: ${o}`)}const l=r.sygnalOptions?.initialState,u=r.sygnalOptions?.isolatedState;if(l&&!u){const t=r.sygnalOptions?.name||o;throw new Error(`[${t}] Sub-component has .initialState but no .isolatedState = true. This will overwrite parent state. If this is intentional, add .isolatedState = true to the component.`)}let d;const p=u?l:void 0,h={get:t=>{const e=t[a];return void 0===e&&p?p:e},set:(t,e)=>this.calculated&&a in this.calculated?(console.warn(`Sub-component of ${this.name} attempted to update state on a calculated field '${a}': Update ignored`),t):{...t,[a]:e}},f={get:t=>t,set:(t,e)=>e};void 0===a?d=f:"string"==typeof a?d=h:ir(a)?"function"!=typeof a.get?(console.error(`Sub-component in ${this.name} has an invalid 'state' field: Expecting 'undefined', a string indicating an array property in the state, or an object with 'get' and 'set' functions for retrieving and setting sub-component state from the current state. Attempting to use parent component state.`),d=f):d={get:a.get,set:a.set}:(console.error(`Invalid state provided to sub-component of ${this.name}: Expecting string, object, or undefined, but found ${typeof a}. Attempting to use parent component state.`),d=f);const m={...this.sources,[this.stateSourceName]:s,props$:e,children$:n,__parentContext$:this.context$,__parentComponentNumber:this._componentNumber};for(const t of Object.keys(r)){const e=r[t];if(e&&e.__sygnalCommand){e._targetComponentName=o,m.commands$=yo(e);break}}const y=he(c,{[this.stateSourceName]:d})(m);if(!ir(y)){throw new Error(`Invalid sinks returned from component factory: ${"sygnal-factory"===o?"custom element":o}`)}return y}renderVdom(t){return lo.combine(this.subComponentsRendered$,t,this._readyChanged$.startWith(null)).compose($o(1)).map((([t,e])=>{const n=Object.keys(this.components),o=e["::ROOT::"],r=Object.entries(e).filter((([t])=>"::ROOT::"!==t));if(0===r.length)return lo.of(qo(o));const i=[],s=r.map((([t,e])=>(i.push(t),e.sink$[this.DOMSourceName].startWith(void 0))));if(0===s.length)return lo.of(o);for(const[t,e]of r){if(void 0!==this._childReadyState[t])continue;const n=e.sink$[Mo];if(n){const e=n.__explicitReady;this._childReadyState[t]=!e,n.addListener({next:e=>{const n=this._childReadyState[t];this._childReadyState[t]=!!e,n!==!!e&&(this._readyChangedListener&&setTimeout((()=>{this._readyChangedListener?.next(null)}),0),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onReadyChanged(this._componentNumber,this.name,t,!!e))},error:()=>{},complete:()=>{}})}else this._childReadyState[t]=!0}return lo.combine(...s).compose($o(1)).map((t=>{const e=t.reduce(((t,e,n)=>(t[i[n]]=e,t)),{});return qo(Wo(er(o),e,n,"r",void 0,this._childReadyState))}))})).flatten().filter((t=>!!t)).remember()}}function Ho(t,e,n="r",o){var r;if(!t)return{};if(t.data?.componentsProcessed)return{};"r"===n&&(t.data.componentsProcessed=!0);const i=t.sel,s=i&&"collection"===i.toLowerCase(),a=i&&"switchable"===i.toLowerCase(),c=i&&["collection","switchable","sygnal-factory",...e].includes(i)||"function"==typeof t.data?.props?.sygnalFactory||ir(t.data?.props?.sygnalOptions),l=t.data&&t.data.props||{};t.data&&t.data.attrs;const u=t.children||[];let d={},p=o;if(c){if(p=Yo(t,n,o),s){if(!l.of)throw new Error("Collection element missing required 'component' property");if("string"!=typeof l.of&&"function"!=typeof l.of)throw new Error(`Invalid 'component' property of collection element: found ${typeof l.of} requires string or component factory function`);if("function"!=typeof l.of&&!e.includes(l.of))throw new Error(`Specified component for collection not found: ${l.of}`);void 0===l.from||"string"==typeof l.from||Array.isArray(l.from)||"function"==typeof l.from.get||console.warn(`No valid array found for collection ${"string"==typeof l.of?l.of:"function component"}: no collection components will be created`,l.from),t.data.isCollection=!0,(r=t.data).props||(r.props={})}else if(a){if(!l.of)throw new Error("Switchable element missing required 'of' property");if(!ir(l.of))throw new Error(`Invalid 'of' property of switchable element: found ${typeof l.of} requires object mapping names to component factories`);if(!Object.values(l.of).every((t=>"function"==typeof t)))throw new Error("One or more components provided to switchable element is not a valid component factory");if(!l.current||"string"!=typeof l.current&&"function"!=typeof l.current)throw new Error(`Missing or invalid 'current' property for switchable element: found '${typeof l.current}' requires string or function`);if(!Object.keys(l.of).includes(l.current))throw new Error(`Component '${l.current}' not found in switchable element`);t.data.isSwitchable=!0}void 0===l.key&&(t.data.props.key=p),d[p]=t}return u.length>0&&u.map(((t,o)=>Ho(t,e,`${n}.${o}`,p))).forEach((t=>{Object.entries(t).forEach((([t,e])=>d[t]=e))})),d}function Wo(t,e,n,o="r",r,i){if(!t)return;if(t.data?.componentsInjected)return t;"r"===o&&t.data&&(t.data.componentsInjected=!0);const s=t.sel||"NO SELECTOR",a=["collection","switchable","sygnal-factory",...n].includes(s)||"function"==typeof t.data?.props?.sygnalFactory||ir(t.data?.props?.sygnalOptions),c=t?.data?.isCollection;t.data&&t.data.props;const l=t.children||[];let u=r;if(a){u=Yo(t,o,r);let n=e[u];return i&&u&&n&&"object"==typeof n&&n.sel&&(n.data=n.data||{},n.data.attrs=n.data.attrs||{},n.data.attrs["data-sygnal-ready"]=!1!==i[u]?"true":"false"),c?(t.sel="div",t.children=Array.isArray(n)?n:[n],t):n}return l.length>0?(t.children=l.map(((t,r)=>Wo(t,e,n,`${o}.${r}`,u,i))).flat(),t):t}function Yo(t,e,n){const o=t.sel,r="string"==typeof o?o:"functionComponent",i=t.data?.props||{};return`${n?`${n}|`:""}${r}::${i.id&&JSON.stringify(i.id).replaceAll('"',"")||e}`}function zo(t){if(!t||!t.sel)return!1;if("false"===t.data?.attrs?.["data-sygnal-ready"])return!0;if("loading"===t.data?.attrs?.["data-sygnal-lazy"])return!0;if("suspense"===t.sel)return!1;if(Array.isArray(t.children))for(const e of t.children)if(zo(e))return!0;return!1}function qo(t){if(!t||!t.sel)return t;if("suspense"===t.sel){const e=(t.data?.props||{}).fallback,n=t.children||[];return n.some(zo)&&e?"string"==typeof e?{sel:"div",data:{attrs:{"data-sygnal-suspense":"pending"}},children:[{text:e}],text:void 0,elm:void 0,key:void 0}:{sel:"div",data:{attrs:{"data-sygnal-suspense":"pending"}},children:[e],text:void 0,elm:void 0,key:void 0}:1===n.length?qo(n[0]):{sel:"div",data:{attrs:{"data-sygnal-suspense":"resolved"}},children:n.map((t=>qo(t))),text:void 0,elm:void 0,key:void 0}}return t.children&&t.children.length>0&&(t.children=t.children.map((t=>qo(t)))),t}const Jo=tn(Yn);function Zo(t){if(!t||!t.sel)return t;if("portal"===t.sel){const e=t.data?.props?.target;return function(t,e){const n=e||[];return{sel:"div",data:{style:{display:"none"},attrs:{"data-sygnal-portal":t},portalChildren:n,hook:{insert:e=>{const o=document.querySelector(t);if(!o)return void console.warn(`[Portal] Target "${t}" not found in DOM`);const r=document.createElement("div");o.appendChild(r),e.data._portalVnode=Jo(r,{sel:"div",data:{},children:n,text:void 0,elm:void 0,key:void 0}),e.data._portalContainer=o},postpatch:(t,e)=>{const n=t.data?._portalVnode,o=t.data?._portalContainer;if(!n||!o)return;const r=e.data?.portalChildren||[];e.data._portalVnode=Jo(n,{sel:"div",data:{},children:r,text:void 0,elm:void 0,key:void 0}),e.data._portalContainer=o},destroy:t=>{const e=t.data?._portalVnode;e&&e.elm&&e.elm.parentNode&&e.elm.parentNode.removeChild(e.elm)}}},children:[],text:void 0,elm:void 0,key:void 0}}(e,t.children||[])}return t.children&&t.children.length>0&&(t.children=t.children.map(Zo)),t}function Xo(t){if(!t||!t.sel)return t;if("transition"===t.sel){const e=t.data?.props||{},n=e.name||"v",o=e.duration,r=(t.children||[])[0];return r&&r.sel?function(t,e,n){const o=t.data?.hook?.insert,r=t.data?.hook?.remove;return t.data=t.data||{},t.data.hook=t.data.hook||{},t.data.hook.insert=t=>{o&&o(t);const r=t.elm;r&&r.classList&&(r.classList.add(`${e}-enter-from`,`${e}-enter-active`),requestAnimationFrame((()=>{requestAnimationFrame((()=>{r.classList.remove(`${e}-enter-from`),r.classList.add(`${e}-enter-to`),tr(r,n,(()=>{r.classList.remove(`${e}-enter-active`,`${e}-enter-to`)}))}))})))},t.data.hook.remove=(t,o)=>{r&&r(t,(()=>{}));const i=t.elm;i&&i.classList?(i.classList.add(`${e}-leave-from`,`${e}-leave-active`),requestAnimationFrame((()=>{requestAnimationFrame((()=>{i.classList.remove(`${e}-leave-from`),i.classList.add(`${e}-leave-to`),tr(i,n,(()=>{i.classList.remove(`${e}-leave-active`,`${e}-leave-to`),o()}))}))}))):o()},t}(Xo(r),n,o):r||t}return t.children&&t.children.length>0&&(t.children=t.children.map(Xo)),t}function Ko(t){if(!t||!t.sel)return t;if("clientonly"===t.sel){const e=t.children||[];return 0===e.length?{sel:"div",data:{},children:[]}:1===e.length?Ko(e[0]):{sel:"div",data:{},children:e.map(Ko),text:void 0,elm:void 0,key:void 0}}return t.children&&t.children.length>0&&(t.children=t.children.map(Ko)),t}function Qo(t,e){if(!t||!t.sel)return t;const n=t.data?.props?.sygnalOptions?.view;if(n&&n.__sygnalLazy)if(n.__sygnalLazyLoaded()){const e=n.__sygnalLazyLoadedComponent;if(e){const n=t.data?.props||{},o=e.componentName||e.label||e.name||"LazyLoaded",{model:r,intent:i,hmrActions:s,context:a,peers:c,components:l,initialState:u,isolatedState:d,calculated:p,storeCalculatedInState:h,DOMSourceName:f,stateSourceName:m,onError:y,debug:_}=e,v={name:o,view:e,model:r,intent:i,hmrActions:s,context:a,peers:c,components:l,initialState:u,isolatedState:d,calculated:p,storeCalculatedInState:h,DOMSourceName:f,stateSourceName:m,onError:y,debug:_},g={...n};return delete g.sygnalOptions,{sel:o,data:{props:{...g,sygnalOptions:v}},children:t.children||[],text:void 0,elm:void 0,key:void 0}}}else!n.__sygnalLazyReRenderScheduled&&n.__sygnalLazyPromise&&e&&(n.__sygnalLazyReRenderScheduled=!0,n.__sygnalLazyPromise.then((()=>{setTimeout((()=>{const t=e.sources?.[e.stateSourceName];if(t&&t.stream){const n={...e.currentState,__sygnalLazyTick:Date.now()};t.stream.shamefullySendNext(n)}}),0)})));return t.children&&t.children.length>0&&(t.children=t.children.map((t=>Qo(t,e)))),t}function tr(t,e,n){if("number"==typeof e)setTimeout(n,e);else{const e=()=>{t.removeEventListener("transitionend",e),n()};t.addEventListener("transitionend",e)}}function er(t){return void 0===t?t:{...t,children:Array.isArray(t.children)?t.children.map(er):void 0,data:t.data&&{...t.data,componentsInjected:!1}}}function nr(t,e){return or(rr(t),rr(e))}function or(t,e,n=5,o=0){if(o>n)return!1;if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!or(t[r],e[r],n,o+1))return!1;return!0}const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;for(const s of r){if(!i.includes(s))return!1;if(!or(t[s],e[s],n,o+1))return!1}return!0}function rr(t){if(!ir(t))return t;const{state:e,of:n,from:o,filter:r,...i}=t;return i}function ir(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function sr(t,e,n=!0){const o=n?1:-1;switch(!0){case t>e:return 1*o;case t<e:return-1*o;default:return 0}}function ar(t){const e=Object.entries(t);if(e.length>1)return void console.error("Sort objects can only have one key:",t);const n=e[0],[o,r]=n;if(!["string","number"].includes(typeof r))return void console.error("Sort object properties must be a string or number:",t);let i=!0;if("string"==typeof r){if(!["asc","desc"].includes(r.toLowerCase()))return void console.error("Sort object string values must be asc or desc:",t);i="desc"!==r.toLowerCase()}if("number"==typeof r){if(1!==r&&-1!==r)return void console.error("Sort object number values must be 1 or -1:",t);i=1===r}return(t,e)=>sr(t[o],e[o],i)}function cr(t){if(!t)return;const e=typeof t;if("function"===e)return t;if("string"===e){if("asc"===t.toLowerCase()||"desc"===t.toLowerCase()){const e="desc"!==t.toLowerCase();return(t,n)=>sr(t,n,e)}const e=t;return(t,n)=>sr(t[e],n[e],!0)}if(Array.isArray(t)){const e=t.map((t=>"function"==typeof t?t:"string"!=typeof t||["asc","desc"].includes(t.toLowerCase())?ir(t)?ar(t):void 0:(e,n)=>sr(e[t],n[t],!0)));return(t,n)=>e.filter((t=>"function"==typeof t)).reduce(((e,o)=>0!==e?e:o(t,n)),0)}return ir(t)?ar(t):void console.error("Invalid sort option (ignoring):",t)}function lr(t){const e={},n=[];for(const o of t)if(o&&"slot"===o.sel){const t=o.data?.props?.name||"default";e[t]||(e[t]=[]);const n=Array.isArray(o.children)?o.children:o.children?[o.children]:[];e[t].push(...n)}else n.push(o);return n.length>0&&(e.default||(e.default=[]),e.default.push(...n)),{slots:e,defaultChildren:e.default||[]}}const ur=t=>{const{children:e,...n}=t;return He("portal",{props:n},e)};ur.label="portal",ur.preventInstantiation=!0;const dr=t=>{const{children:e,...n}=t;return He("transition",{props:n},e)};dr.label="transition",dr.preventInstantiation=!0;const pr=t=>{const{children:e,...n}=t;return He("suspense",{props:n},e)};pr.label="suspense",pr.preventInstantiation=!0;const hr=t=>{const{children:e,...n}=t;return He("slot",{props:n},e)};function fr(t){return t.data=function(e,n){return fr(t.map((t=>{const o=t?.dataset?.[e]??t?.dropZone?.dataset?.[e]??t?.element?.dataset?.[e];return n?n(o):o})))},t.element=function(e){return fr(t.map((t=>{const n=t?.element??t?.dropZone??null;return e?e(n):n})))},t}function mr(t){return 0===Object.keys(t).length}function yr(t,e){if("function"!=typeof t)throw new Error("First argument given to Cycle must be the 'main' function.");if("object"!=typeof e||null===e)throw new Error("Second argument given to Cycle must be an object with driver functions as properties.");if(mr(e))throw new Error("Second argument given to Cycle must be an object with at least one driver function declared as a property.");const n=function(t){if("object"!=typeof t||null===t)throw new Error("Argument given to setupReusable must be an object with driver functions as properties.");if(mr(t))throw new Error("Argument given to setupReusable must be an object with at least one driver function declared as a property.");const e=function(t){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=ce.create());return e}(t),n=function(t,e){const n={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o](e[o],o),n[o]&&"object"==typeof n[o]&&(n[o]._isCycleSource=o));return n}(t,e),o=function(t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&"function"==typeof t[e].shamefullySendNext&&(t[e]=ue(t[e]));return t}(n);function r(t){return function(t,e){const n=Object.keys(t).filter((t=>!!e[t]));let o={};const r={};n.forEach((t=>{o[t]={_n:[],_e:[]},r[t]={next:e=>o[t]._n.push(e),error:e=>o[t]._e.push(e),complete:()=>{}}}));const i=n.map((e=>ce.fromObservable(t[e]).subscribe(r[e])));return n.forEach((t=>{const n=e[t],i=t=>{queueMicrotask((()=>n._n(t)))},s=t=>{queueMicrotask((()=>{(console.error||console.log)(t),n._e(t)}))};o[t]._n.forEach(i),o[t]._e.forEach(s),r[t].next=i,r[t].error=s,r[t]._n=i,r[t]._e=s})),o=null,function(){i.forEach((t=>t.unsubscribe()))}}(t,e)}function i(){!function(t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&t[e].dispose&&t[e].dispose()}(o),function(t){Object.keys(t).forEach((e=>t[e]._c()))}(e)}return{sources:o,run:r,dispose:i}}(e),o=t(n.sources);return"undefined"!=typeof window&&(window.Cyclejs=window.Cyclejs||{},window.Cyclejs.sinks=o),{sinks:o,sources:n.sources,run:function(){const t=n.run(o);return function(){t(),n.dispose()}}}}function _r(t){const e=new EventTarget;return t.subscribe({next:t=>{e.dispatchEvent(new CustomEvent("data",{detail:t})),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onBusEvent(t)},error:t=>console.error("[EVENTS driver] Error in sink stream:",t)}),{select:t=>{const n=!t,o=Array.isArray(t)?t:[t];let r;return ue(ce.create({start:t=>{r=({detail:e})=>{const r=e&&e.data||null;(n||o.includes(e.type))&&t.next(r)},e.addEventListener("data",r)},stop:()=>{r&&e.removeEventListener("data",r)}}))}}}function vr(t){t.addListener({next:t=>{console.log(t)},error:t=>{console.error("[LOG driver] Error in sink stream:",t)}})}hr.label="slot",hr.preventInstantiation=!0;class gr{constructor(){this._connected=!1,this._components=new Map,this._stateHistory=[],this._maxHistory=200}get connected(){return this._connected&&"undefined"!=typeof window}init(){"undefined"!=typeof window&&(window.__SYGNAL_DEVTOOLS__=this,window.addEventListener("message",(t=>{t.source===window&&"__SYGNAL_DEVTOOLS_EXTENSION__"===t.data?.source&&this._handleExtensionMessage(t.data)})))}_handleExtensionMessage(t){switch(t.type){case"CONNECT":this._connected=!0,t.payload?.maxHistory&&(this._maxHistory=t.payload.maxHistory),this._sendFullTree();break;case"DISCONNECT":this._connected=!1;break;case"SET_DEBUG":this._setDebug(t.payload);break;case"TIME_TRAVEL":this._timeTravel(t.payload);break;case"SNAPSHOT":this._takeSnapshot();break;case"RESTORE_SNAPSHOT":this._restoreSnapshot(t.payload);break;case"GET_STATE":this._sendComponentState(t.payload.componentId)}}onComponentCreated(t,e,n){const o={id:t,name:e,isSubComponent:n.isSubComponent,hasModel:!!n.model,hasIntent:!!n.intent,hasContext:!!n.context,hasCalculated:!!n.calculated,components:Object.keys(n.components||{}),parentId:null,children:[],debug:n._debug,createdAt:Date.now(),mviGraph:this._extractMviGraph(n),_instanceRef:new WeakRef(n)};this._components.set(t,o),this.connected&&this._post("COMPONENT_CREATED",this._serializeMeta(o))}onStateChanged(t,e,n){if(!this.connected)return;const o={componentId:t,componentName:e,timestamp:Date.now(),state:this._safeClone(n)};this._stateHistory.push(o),this._stateHistory.length>this._maxHistory&&this._stateHistory.shift(),this._post("STATE_CHANGED",{componentId:t,componentName:e,state:o.state})}onActionDispatched(t,e,n,o){this.connected&&this._post("ACTION_DISPATCHED",{componentId:t,componentName:e,actionType:n,data:this._safeClone(o),timestamp:Date.now()})}onSubComponentRegistered(t,e){const n=this._components.get(t),o=this._components.get(e);n&&o&&(o.parentId=t,n.children.includes(e)||n.children.push(e)),this.connected&&this._post("TREE_UPDATED",{parentId:t,childId:e})}onContextChanged(t,e,n){this.connected&&this._post("CONTEXT_CHANGED",{componentId:t,componentName:e,context:this._safeClone(n),contextTrace:this._buildContextTrace(t,n)})}onPropsChanged(t,e,n){this.connected&&this._post("PROPS_CHANGED",{componentId:t,componentName:e,props:this._safeClone(n)})}onBusEvent(t){this.connected&&this._post("BUS_EVENT",{type:t.type,data:this._safeClone(t.data),componentId:t.__emitterId??null,componentName:t.__emitterName??null,timestamp:Date.now()})}onCommandSent(t,e,n,o){this.connected&&this._post("COMMAND_SENT",{type:t,data:this._safeClone(e),targetComponentName:o??null,timestamp:Date.now()})}onReadyChanged(t,e,n,o){this.connected&&this._post("READY_CHANGED",{parentId:t,parentName:e,childKey:n,ready:o,timestamp:Date.now()})}onCollectionMounted(t,e,n,o){const r=this._components.get(t);r&&(r.collection={itemComponent:n,stateField:o}),this.connected&&this._post("COLLECTION_MOUNTED",{parentId:t,parentName:e,itemComponent:n,stateField:o})}onComponentDisposed(t,e){const n=this._components.get(t);n&&(n.disposed=!0,n.disposedAt=Date.now()),this.connected&&this._post("COMPONENT_DISPOSED",{componentId:t,componentName:e,timestamp:Date.now()})}onDebugLog(t,e){this.connected&&this._post("DEBUG_LOG",{componentId:t,message:e,timestamp:Date.now()})}_setDebug({componentId:t,enabled:e}){if(null==t)return"undefined"!=typeof window&&(window.SYGNAL_DEBUG=!!e&&"true"),void this._post("DEBUG_TOGGLED",{global:!0,enabled:e});const n=this._components.get(t);if(n&&n._instanceRef){const o=n._instanceRef.deref();o&&(o._debug=e,n.debug=e,this._post("DEBUG_TOGGLED",{componentId:t,enabled:e}))}}_timeTravel({componentId:t,componentName:e,state:n}){if(null==t||!n)return void console.warn("[Sygnal DevTools] _timeTravel: missing componentId or state",{componentId:t,hasState:!!n});if("undefined"==typeof window)return;const o=this._safeClone(n),r=this._components.get(t);if(r){const n=r._instanceRef?.deref();if(n){const r=n.stateSourceName||"STATE",i=n.sinks?.[r];if(i?.shamefullySendNext)return i.shamefullySendNext((()=>({...o}))),void this._post("TIME_TRAVEL_APPLIED",{componentId:t,componentName:e,state:o});console.warn(`[Sygnal DevTools] _timeTravel: component #${t} (${e}) has no STATE sink with shamefullySendNext. sinkName=${r}, hasSinks=${!!n.sinks}, sinkKeys=${n.sinks?Object.keys(n.sinks).join(","):"none"}`)}else console.warn(`[Sygnal DevTools] _timeTravel: WeakRef for component #${t} (${e}) has been GC'd`)}else console.warn(`[Sygnal DevTools] _timeTravel: no meta for componentId ${t}`);const i=window.__SYGNAL_DEVTOOLS_APP__;i?.sinks?.STATE?.shamefullySendNext?(i.sinks.STATE.shamefullySendNext((()=>({...o}))),this._post("TIME_TRAVEL_APPLIED",{componentId:t,componentName:e,state:o})):console.warn("[Sygnal DevTools] _timeTravel: no fallback root STATE sink available")}_takeSnapshot(){const t=[];for(const[e,n]of this._components){if(n.disposed)continue;const o=n._instanceRef?.deref();null!=o?.currentState&&t.push({componentId:e,componentName:n.name,state:this._safeClone(o.currentState)})}this._post("SNAPSHOT_TAKEN",{entries:t,timestamp:Date.now()})}_restoreSnapshot(t){if(t?.entries)for(const e of t.entries)this._timeTravel(e)}_sendComponentState(t){const e=this._components.get(t);if(e&&e._instanceRef){const n=e._instanceRef.deref();n&&this._post("COMPONENT_STATE",{componentId:t,state:this._safeClone(n.currentState),context:this._safeClone(n.currentContext),contextTrace:this._buildContextTrace(t,n.currentContext),props:this._safeClone(n.currentProps)})}}_buildContextTrace(t,e){if(!e||"object"!=typeof e)return[];const n=[],o=Object.keys(e);for(const e of o){let o=t,r=!1;for(;null!=o;){const t=this._components.get(o);if(!t)break;if(t.mviGraph?.contextProvides?.includes(e)){n.push({field:e,providerId:t.id,providerName:t.name}),r=!0;break}o=t.parentId}r||n.push({field:e,providerId:-1,providerName:"unknown"})}return n}_sendFullTree(){const t=[];for(const[,e]of this._components){const n=e._instanceRef?.deref();t.push({...this._serializeMeta(e),state:n?this._safeClone(n.currentState):null,context:n?this._safeClone(n.currentContext):null})}this._post("FULL_TREE",{components:t,history:this._stateHistory})}_post(t,e){"undefined"!=typeof window&&window.postMessage({source:"__SYGNAL_DEVTOOLS_PAGE__",type:t,payload:e},"*")}_safeClone(t){if(null==t)return t;try{return JSON.parse(JSON.stringify(t))}catch(t){return"[unserializable]"}}_extractMviGraph(t){if(!t.model)return null;try{const e=t.sourceNames?[...t.sourceNames]:[],n=[],o=t.model;for(const e of Object.keys(o)){let r=e,i=o[e];if(e.includes("|")){const t=e.split("|").map((t=>t.trim()));if(2===t.length&&t[0]&&t[1]){r=t[0],n.push({name:r,sinks:[t[1]]});continue}}"function"!=typeof i?i&&"object"==typeof i&&n.push({name:r,sinks:Object.keys(i)}):n.push({name:r,sinks:[t.stateSourceName||"STATE"]})}return{sources:e,actions:n,contextProvides:t.context&&"object"==typeof t.context?Object.keys(t.context):[]}}catch(t){return null}}_serializeMeta(t){const{_instanceRef:e,...n}=t;return n}}let br=null;function wr(){return br||(br=new gr),br}function Sr(t){if(!t)return null;const e=t.default||t;return"function"!=typeof e?null:t.default?t:{default:e}}function Er(t){return/^[a-zA-Z0-9-_]+$/.test(t)}function Ar(t){if("string"!=typeof t)throw new Error("Class name must be a string");return t.trim().split(" ").reduce(((t,e)=>{if(0===e.trim().length)return t;if(!Er(e))throw new Error(`${e} is not a valid CSS class name`);return t.push(e),t}),[])}const Or=t=>(t=>"string"==typeof t)(t)||(t=>"number"==typeof t)(t),Nr={svg:1,g:1,defs:1,symbol:1,use:1,circle:1,ellipse:1,line:1,path:1,polygon:1,polyline:1,rect:1,text:1,tspan:1,textPath:1,linearGradient:1,radialGradient:1,stop:1,pattern:1,clipPath:1,mask:1,marker:1,filter:1,feBlend:1,feColorMatrix:1,feComponentTransfer:1,feComposite:1,feConvolveMatrix:1,feDiffuseLighting:1,feDisplacementMap:1,feDropShadow:1,feFlood:1,feGaussianBlur:1,feImage:1,feMerge:1,feMergeNode:1,feMorphology:1,feOffset:1,fePointLight:1,feSpecularLighting:1,feSpotLight:1,feTile:1,feTurbulence:1,feFuncR:1,feFuncG:1,feFuncB:1,feFuncA:1,desc:1,metadata:1,foreignObject:1,switch:1,animate:1,animateMotion:1,animateTransform:1,set:1,mpath:1};var Cr=Object.prototype.hasOwnProperty,Tr=Object.prototype.toString,$r=Object.defineProperty,xr=Object.getOwnPropertyDescriptor,kr=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===Tr.call(t)},Lr=function(t){if(!t||"[object Object]"!==Tr.call(t))return!1;var e,n=Cr.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&Cr.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!o)return!1;for(e in t);return void 0===e||Cr.call(t,e)},Dr=function(t,e){$r&&"__proto__"===e.name?$r(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},jr=function(t,e){if("__proto__"===e){if(!Cr.call(t,e))return;if(xr)return xr(t,e).value}return t[e]},Ir=function t(){var e,n,o,r,i,s,a=arguments[0],c=1,l=arguments.length,u=!1;for("boolean"==typeof a&&(u=a,a=arguments[1]||{},c=2),(null==a||"object"!=typeof a&&"function"!=typeof a)&&(a={});c<l;++c)if(null!=(e=arguments[c]))for(n in e)o=jr(a,n),a!==(r=jr(e,n))&&(u&&r&&(Lr(r)||(i=kr(r)))?(i?(i=!1,s=o&&kr(o)?o:[]):s=o&&Lr(o)?o:{},Dr(a,{name:n,newValue:t(u,s,r)})):void 0!==r&&Dr(a,{name:n,newValue:r}));return a},Mr=o(Ir);const Pr=(...t)=>Mr(!1,...t),Rr=(t,e,n)=>{let o=n;for(let n=0;n<t.length;n++){const i=t[n];r=i,o=Array.isArray(r)?Rr(i,e,o):e(o,i)}var r;return o},Fr=(t,e)=>Object.keys(t).map((n=>e(n,t[n]))).reduce(((t,e)=>((...t)=>Mr(!0,...t))(t,e)),{}),Gr=(t,e)=>Fr(e,((e,n)=>e!==t?{[e]:n}:{})),Br=t=>Or(t)?{text:t,sel:void 0,data:void 0,children:void 0,elm:void 0,key:void 0}:void 0,Ur=t=>{if(!t||void 0===t.sel)return t;const e=t.data||{},n=e.props||{},o=Gr("className",n),r=void 0!==n.className?{class:n.className}:{},i=Pr({},o,r,e.attrs||{});return Pr(t,{data:Gr("props",Pr({},e,{ns:"http://www.w3.org/2000/svg",attrs:i}))},{children:Array.isArray(t.children)&&"foreignObject"!==t.sel?t.children.map((t=>Ur(t))):t.children})},Vr=t=>t.sel in Nr?Ur(t):t,Hr={for:"attrs",role:"attrs",tabindex:"attrs","aria-*":"attrs",key:null},Wr=(t,e)=>{const{ref:n,...o}=t,r=(t=>{if(!t.props)return t;const{autoFocus:e,autoSelect:n,...o}=t.props;if(!e&&!n)return t;t.props=o,t._autoFocus=!!e,t._autoSelect=!!n;const r=t=>{t&&"function"==typeof t.focus&&requestAnimationFrame((()=>{t.focus(),n&&"function"==typeof t.select&&t.select()}))},i=t.hook?.insert,s=t.hook?.postpatch;return t.hook={...t.hook,insert:t=>{i&&i(t),(e||n)&&r(t.elm)},postpatch:(t,e)=>{s&&s(t,e);const n=t.data?._autoFocus,o=e.data?._autoFocus;!n&&o&&r(e.elm)}},t})(((t,e)=>Fr(t,((t,n)=>{const o={[t]:n};if(Hr[t]&&void 0!==e[Hr[t]])return{[Hr[t]]:o};if(null===Hr[t])return{};const r=Object.keys(Hr);for(let n=0;n<r.length;n++){const i=r[n];if("*"===i.charAt(i.length-1)&&0===t.indexOf(i.slice(0,-1))&&void 0!==e[Hr[i]])return{[Hr[i]]:o}}return void 0!==e[t]?{[e[t]?e[t]:t]:n}:void 0!==e.props?{props:o}:o})))(((t,e)=>Fr(t,((t,n)=>{const o=t.indexOf("-");if(o>-1&&void 0!==e[t.slice(0,o)]){const e={[t.slice(o+1)]:n};return{[t.slice(0,o)]:e}}return{[t]:n}})))(o,e),e));return((t,e)=>{if(!e)return t;const n=t=>{"function"==typeof e?e(t):e&&"object"==typeof e&&"current"in e&&(e.current=t)},o=t.hook?.insert,r=t.hook?.destroy,i=t.hook?.postpatch;return t.hook={...t.hook,insert:t=>{o&&o(t),n(t.elm)},postpatch:(t,e)=>{i&&i(t,e),n(e.elm)},destroy:t=>{r&&r(t),n(null)}},t})(r,n)},Yr=t=>t.length>1||!Or(t[0])?void 0:t[0].toString(),zr=t=>Rr(t,((t,e)=>{const n=(t=>"object"==typeof t&&null!==t)(o=e)&&"sel"in o&&"data"in o&&"children"in o&&"text"in o?e:Br(e);var o;return t.push(n),t}),[]),qr=(t=>(e,n,...o)=>{if(void 0===e&&(e="UNDEFINED",console.error("JSX Error: Capitalized HTML element without corresponding factory function. Components with names where the first letter is capital MUST be defined or included at the parent component's file scope.")),"function"==typeof e){if(e.__sygnalFragment||"Fragment"===e.name)return e(n||{},o);if(n||(n={}),e.isSygnalComponent){const t=e;e=e.componentName||e.label||e.name||"sygnal-factory",n.sygnalFactory=t}else{const r=e.componentName||e.label||e.name||"FUNCTION_COMPONENT",i=e,{model:s,intent:a,hmrActions:c,context:l,peers:u,components:d,initialState:p,isolatedState:h,calculated:f,storeCalculatedInState:m,DOMSourceName:y,stateSourceName:_,onError:v,debug:g,preventInstantiation:b}=e;if(b){const e=Yr(o),i=n?Wr(n,t):{};return Vr({sel:r,data:i,children:void 0!==e?Br(e):zr(o),text:e,elm:void 0,key:n?n.key:void 0})}const w={name:r,view:i,model:s,intent:a,hmrActions:c,context:l,peers:u,components:d,initialState:p,isolatedState:h,calculated:f,storeCalculatedInState:m,DOMSourceName:y,stateSourceName:_,onError:v,debug:g};n.sygnalOptions=w,e=r}}const r=Yr(o);return Vr({sel:e,data:n?Wr(n,t):{},children:void 0!==r?Br(r):zr(o),text:r,elm:void 0,key:n?n.key:void 0})})({attrs:"",props:"",class:"",data:"dataset",style:"",hook:"",on:""});const Jr=lo;function Zr(t,e){const n=(t,n)=>e.dispatchEvent(new CustomEvent("data",{detail:{type:t,data:n}}));t.addEventListener("statechange",(()=>{"installed"===t.state&&n("installed",!0),"activated"===t.state&&n("activated",!0)})),"installed"===t.state&&n("waiting",t),"activated"===t.state&&n("activated",!0)}let Xr;const Kr=Jr.create({start(t){if("undefined"==typeof window)return void t.next(!0);t.next(navigator.onLine);const e=()=>t.next(!0),n=()=>t.next(!1);window.addEventListener("online",e),window.addEventListener("offline",n),Xr=()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}},stop(){Xr?.(),Xr=void 0}});const Qr=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ti={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function ei(t){return String(t).replace(/[&<>"']/g,(t=>ti[t]))}function ni(t){return t.replace(/^(Webkit|Moz|Ms|O)/,(t=>"-"+t.toLowerCase())).replace(/([A-Z])/g,"-$1").toLowerCase()}function oi(t,e,n){if(!t)return t;if("string"==typeof t||null!=t.text)return t;const o=t.sel;if(!o&&t.children&&Array.isArray(t.children))return t.children=t.children.map((t=>oi(t,e,n))).filter((t=>null!=t)),t;if("portal"===o){const o=t.children||[];return 0===o.length?null:1===o.length?oi(o[0],e,n):{sel:"div",data:{attrs:{"data-sygnal-portal":""}},children:o.map((t=>oi(t,e,n))),text:void 0,elm:void 0,key:void 0}}if("transition"===o){const o=(t.children||[])[0];return o?oi(o,e,n):null}if("suspense"===o){const o=t.children||[];return 0===o.length?null:1===o.length?oi(o[0],e,n):{sel:"div",data:{attrs:{"data-sygnal-suspense":"resolved"}},children:o.map((t=>oi(t,e,n))),text:void 0,elm:void 0,key:void 0}}if("clientonly"===o){const o=(t.data?.props||{}).fallback;return o?oi(o,e,n):{sel:"div",data:{attrs:{"data-sygnal-clientonly":""}},children:[],text:void 0,elm:void 0,key:void 0}}if("slot"===o){const o=t.children||[];return 0===o.length?null:1===o.length?oi(o[0],e,n):{sel:"div",data:{},children:o.map((t=>oi(t,e,n))),text:void 0,elm:void 0,key:void 0}}const r=t.data?.props||{};return r.sygnalOptions||"function"==typeof r.sygnalFactory?function(t,e,n){const o=t.data?.props||{},{sygnalOptions:r,sygnalFactory:i,...s}=o;let a;if(r)a=r.view,!a.initialState&&r.initialState&&(a=Object.assign(a,{initialState:r.initialState,model:r.model,intent:r.intent,context:r.context,onError:r.onError,calculated:r.calculated}));else if(i&&i.componentName)return{sel:"div",data:{attrs:{"data-sygnal-ssr":t.sel||"component"}},children:t.children||[],text:void 0,elm:void 0,key:void 0};if(!a||"function"!=typeof a)return{sel:"div",data:{attrs:{"data-sygnal-ssr":t.sel||"component"}},children:t.children||[],text:void 0,elm:void 0,key:void 0};let c=a.initialState;const l=s.state;"string"==typeof l&&null!=n&&null!=n[l]?c=n[l]:null!=l&&"string"!=typeof l&&(c=l);const u={...e},d=a.context||{};for(const t of Object.keys(d)){const e=d[t];if("function"==typeof e&&null!=c)try{u[t]=e(c)}catch(t){}}const p={},h=[],f=t.children||[];for(const t of f)if(t&&"slot"===t.sel){const e=t.data?.props?.name||"default";p[e]||(p[e]=[]);const n=t.children||[];p[e].push(...n)}else h.push(t);h.length>0&&(p.default||(p.default=[]),p.default.push(...h));let m;try{m=a({...s,state:c,children:p.default||f,slots:p,context:u,peers:{}},c,u,{})}catch(t){if("function"==typeof a.onError){const e=a.componentName||a.name||"Component";try{m=a.onError(t,{componentName:e})}catch(t){m={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}}else m={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}m||(m={sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0});return oi(m,u,c)}(t,e,n):"collection"===o?function(t,e,n){const o=t.data?.props||{},{of:r,from:i,className:s}=o;if(!r||!i||!n)return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};const a=n[i];if(!Array.isArray(a))return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};const c=a.map(((t,n)=>{const o={...e},i=r.context||{};for(const e of Object.keys(i)){const n=i[e];if("function"==typeof n)try{o[e]=n(t)}catch(t){}}let s;try{s=r({state:t,children:[],slots:{},context:o,peers:{}},t,o,{})}catch(t){if("function"==typeof r.onError)try{s=r.onError(t,{componentName:r.name||"CollectionItem"})}catch(t){s={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}else s={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}return oi(s,o,t)})).filter((t=>null!=t)),l={};s&&(l.props={className:s});return{sel:"div",data:l,children:c,text:void 0,elm:void 0,key:void 0}}(t,e,n):"switchable"===o?function(t,e,n){const o=t.data?.props||{},{components:r,active:i,initial:s}=o;if(!r)return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};let a;"string"==typeof i&&(r[i]?a=i:n&&"string"==typeof n[i]&&(a=n[i]));!a&&s&&(a=s);a||(a=Object.keys(r)[0]);const c=r[a];if(!c||"function"!=typeof c)return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};return function(t,e,n){const o=void 0!==e?e:t.initialState,r=t.context||{},i={...n};for(const t of Object.keys(r)){const e=r[t];if("function"==typeof e&&null!=o)try{i[t]=e(o)}catch(t){}}let s;try{s=t({state:o,children:[],slots:{},context:i,peers:{}},o,i,{})}catch(e){if("function"==typeof t.onError)try{s=t.onError(e,{componentName:t.name||"Component"})}catch(t){s={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}else s={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}s||(s={sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0});return oi(s,i,o)}(c,n,e)}(t,e,n):(t.children&&(Array.isArray(t.children)?t.children.length>0&&(t.children=t.children.map((t=>oi(t,e,n))).filter((t=>null!=t))):t.children&&"object"==typeof t.children&&(t.children=oi(t.children,e,n))),t)}function ri(t){if(null==t)return"";if("string"==typeof t)return ei(t);if(null!=t.text&&!t.sel)return ei(String(t.text));const e=t.sel;if(!e)return null!=t.text?ei(String(t.text)):t.children&&Array.isArray(t.children)?t.children.map((t=>ri(t))).join(""):"";const{tag:n,id:o,selectorClasses:r}=function(t){let e=t,n=null;const o=[],r=t.indexOf("#");if(-1!==r){const i=t.slice(r+1),s=i.indexOf(".");if(-1!==s){n=i.slice(0,s),e=t.slice(0,r);const a=i.slice(s+1);a&&o.push(...a.split("."))}else n=i,e=t.slice(0,r)}else{const n=t.indexOf(".");if(-1!==n){e=t.slice(0,n);const r=t.slice(n+1);r&&o.push(...r.split("."))}}e||(e="div");return{tag:e,id:n,selectorClasses:o}}(e),i=function(t,e,n){const o=[],r=[...n];if(t.props)for(const[e,n]of Object.entries(t.props))"className"===e?"string"==typeof n&&n&&r.push(n):"htmlFor"===e?o.push(["for",n]):"innerHTML"===e||"textContent"===e||"sygnalOptions"===e||"sygnalFactory"===e||("boolean"==typeof n?n&&o.push([e,!0]):null!=n&&o.push([e,n]));if(t.attrs)for(const[e,n]of Object.entries(t.attrs))"class"===e?"string"==typeof n&&n&&r.push(n):"boolean"==typeof n?n&&o.push([e,!0]):null!=n&&o.push([e,n]);if(t.class)for(const[e,n]of Object.entries(t.class))n&&r.push(e);if(t.dataset)for(const[e,n]of Object.entries(t.dataset))null!=n&&o.push([`data-${ni(e)}`,n]);e&&o.unshift(["id",e]);if(r.length>0){const t=[...new Set(r)];o.unshift(["class",t.join(" ")])}if(t.style&&"object"==typeof t.style){const e=function(t){const e=[];for(const n of Object.keys(t)){const o=t[n];if(null==o||""===o)continue;if("delayed"===n||"remove"===n||"destroy"===n)continue;const r=ni(n);e.push(`${r}: ${o}`)}return e.join("; ")}(t.style);e&&o.push(["style",e])}return o}(t.data||{},o,r);let s=`<${n}`;for(const[t,e]of i)!0===e?s+=` ${t}`:!1!==e&&null!=e&&(s+=` ${t}="${ei(String(e))}"`);if(s+=">",Qr.has(n))return s;if(null!=t.data?.props?.innerHTML)return s+=String(t.data.props.innerHTML),s+=`</${n}>`,s;if(null!=t.text)s+=ei(String(t.text));else if(t.children){const e=Array.isArray(t.children)?t.children:[t.children];for(const t of e)s+=ri(t)}return s+=`</${n}>`,s}var ii={};Object.defineProperty(ii,"__esModule",{value:!0});var si=r,ai=function(){function t(t,e){this.dt=t,this.ins=e,this.type="throttle",this.out=null,this.id=null}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=null,this.id=null},t.prototype.clearInterval=function(){var t=this.id;null!==t&&clearInterval(t),this.id=null},t.prototype._n=function(t){var e=this,n=this.out;n&&(this.id||(n._n(t),this.id=setInterval((function(){e.clearInterval()}),this.dt)))},t.prototype._e=function(t){var e=this.out;e&&(this.clearInterval(),e._e(t))},t.prototype._c=function(){var t=this.out;t&&(this.clearInterval(),t._c())},t}();var ci=ii.default=function(t){return function(e){return new si.Stream(new ai(t,e))}};t.ABORT=Fo,t.Collection=ao,t.MainDOMSource=Cn,t.MockedDOMSource=oo,t.Portal=ur,t.Slot=hr,t.Suspense=pr,t.Switchable=mo,t.Transition=dr,t.classes=function(...t){return t.reduce(((t,e)=>{var n,o;return"string"!=typeof e||t.includes(e)?Array.isArray(e)?t.push(...(o=e,o.map(Ar).flat())):"object"==typeof e&&t.push(...(n=e,Object.entries(n).filter((([t,e])=>"function"==typeof e?e():!!e)).map((([t,e])=>{const n=t.trim();if(!Er(n))throw new Error(`${n} is not a valid CSS class name`);return n})))):t.push(...Ar(e)),t}),[]).join(" ")},t.collection=so,t.component=Uo,t.createCommand=function(){const t={next:()=>{}},e={send:(n,o)=>{t.next({type:n,data:o}),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onCommandSent(n,o,e._targetComponentId,e._targetComponentName)},_stream:lo.create({start(e){t.next=t=>e.next(t)},stop(){t.next=()=>{}}}),__sygnalCommand:!0};return e},t.createElement=qr,t.createInstallPrompt=function(){let t=null;const e=new EventTarget;return"undefined"!=typeof window&&(window.addEventListener("beforeinstallprompt",(n=>{n.preventDefault(),t=n,e.dispatchEvent(new CustomEvent("data",{detail:{type:"beforeinstallprompt",data:!0}}))})),window.addEventListener("appinstalled",(()=>{t=null,e.dispatchEvent(new CustomEvent("data",{detail:{type:"appinstalled",data:!0}}))}))),{select(t){let n;return ue(Jr.create({start:o=>{n=({detail:e})=>{e.type===t&&o.next(e.data)},e.addEventListener("data",n)},stop:()=>{n&&e.removeEventListener("data",n)}}))},prompt:()=>t?.prompt()}},t.createRef=function(){return{current:null}},t.createRef$=function(){const t={next:()=>{}},e=lo.createWithMemory({start(e){t.next=t=>e.next(t)},stop(){t.next=()=>{}}});return new Proxy({current:null,stream:e},{set:(e,n,o)=>"current"===n?(e.current=o,t.next(o),!0):(e[n]=o,!0)})},t.debounce=Oo,t.delay=bo,t.driverFromAsync=function(t,e={}){const{selector:n="category",args:o="value",return:r="value",pre:i=(t=>t),post:s=(t=>t)}=e,a=t.name||"[anonymous function]",c=typeof o;if(!("string"===c||"function"===c||Array.isArray(o)&&o.every((t=>"string"==typeof t))))throw new Error(`The 'args' option for driverFromAsync(${a}) must be a string, array of strings, or a function. Received ${c}`);if("string"!=typeof n)throw new Error(`The 'selector' option for driverFromAsync(${a}) must be a string. Received ${typeof n}`);return e=>{let c=null;const l=ce.create({start:t=>{c=t.next.bind(t)},stop:()=>{}});return e.addListener({next:e=>{const l=i(e);let u=[];if("object"==typeof l&&null!==l){if("function"==typeof o){const t=o(l);u=Array.isArray(t)?t:[t]}"string"==typeof o&&(u=[l[o]]),Array.isArray(o)&&(u=o.map((t=>l[t])))}const d=`Error in driver created using driverFromAsync(${a})`;t(...u).then((t=>{const o=t=>{let o;if(void 0===r)o=t,"object"==typeof o&&null!==o?o[n]=e[n]:console.warn(`The 'return' option for driverFromAsync(${a}) was not set, but the promise returned an non-object. The result will be returned as-is, but the '${n}' property will not be set, so will not be filtered by the 'select' method of the driver.`);else{if("string"!=typeof r)throw new Error(`The 'return' option for driverFromAsync(${a}) must be a string. Received ${typeof r}`);o={[r]:t,[n]:e[n]}}return o};if("function"==typeof t.then)t.then((t=>{const n=s(t,e);"function"==typeof n.then?n.then((t=>{c(o(t))})).catch((t=>console.error(`${d}: ${t}`))):c(o(n))})).catch((t=>console.error(`${d}: ${t}`)));else{const n=s(t,e);"function"==typeof n.then?n.then((t=>{c(o(t))})).catch((t=>console.error(`${d}: ${t}`))):c(o(n))}})).catch((t=>console.error(`${d}: ${t}`)))},error:t=>{console.error(`Error received from sink stream in driver created using driverFromAsync(${a}):`,t)},complete:()=>{console.warn(`Unexpected completion of sink stream to driver created using driverFromAsync(${a})`)}}),{select:t=>void 0===t?l:"function"==typeof t?l.filter(t):l.filter((e=>e?.[n]===t))}}},t.dropRepeats=ge,t.emit=function(t,e){return{EVENTS:"function"==typeof e?(n,o,r,i)=>({type:t,data:e(n,o,r,i)}):()=>({type:t,data:e})}},t.enableHMR=function(t,e,n,o){if(!t||"function"!=typeof t.hmr)return t;if(!e||"function"!=typeof e.accept)return t;let r=!1;const i=e=>{Promise.resolve((async e=>{if(r)return;r=!0;const o=Array.isArray(e)?e.find(Boolean):e;try{let e=Sr(o);if(e||"function"!=typeof n||(e=Sr(await n())),e){const n=t?.sources?.STATE?.stream?._v;t.hmr(e,n)}}finally{r=!1}})(e)).catch((()=>{}))};return void 0!==o&&e.accept(o,i),e.accept(i),"function"==typeof e.dispose&&"function"==typeof t.dispose&&e.dispose((()=>t.dispose())),t},t.exactState=function(){return t=>t},t.getDevTools=wr,t.h=He,t.lazy=function(t){let e=null,n=null;function o(t){return n?{sel:"div",data:{attrs:{"data-sygnal-error":"lazy"}},children:[],text:void 0,elm:void 0,key:void 0}:e?e(t):{sel:"div",data:{attrs:{"data-sygnal-lazy":"loading"}},children:[],text:void 0,elm:void 0,key:void 0}}const r=t().then((t=>{e=t.default||t,o.__sygnalLazyLoadedComponent=e;const n=["model","intent","hmrActions","context","peers","components","initialState","calculated","storeCalculatedInState","DOMSourceName","stateSourceName","onError","debug","componentName"];for(const t of n)void 0!==e[t]&&void 0===o[t]&&(o[t]=e[t])})).catch((t=>{n=t,console.error("[lazy] Failed to load component:",t)}));return o.__sygnalLazy=!0,o.__sygnalLazyLoaded=()=>null!==e,o.__sygnalLazyLoadedComponent=null,o.__sygnalLazyPromise=r,o.__sygnalLazyReRenderScheduled=!1,o},t.makeDOMDriver=eo,t.makeDragDriver=function(){return function(t){const e=new Map,n=new EventTarget,o=[];let r=null;const i=t=>{if(!t?.category)return;const n=e.get(t.category)??{};e.set(t.category,{...n,...t})};t.subscribe({next(t){(t?.configs??(Array.isArray(t)?t:[t])).forEach(i)},error(){},complete(){}});const s=(t,e)=>n.dispatchEvent(new CustomEvent(t,{detail:e})),a=(t,e)=>{document.addEventListener(t,e),o.push([t,e])};a("dragstart",(t=>{const n=t;for(const[t,o]of e){if(!o.draggable)continue;const e=n.target.closest(o.draggable);if(e){if(r=t,n.dataTransfer.effectAllowed="move",o.dragImage){const t=e.closest(o.dragImage);if(t){const e=t.getBoundingClientRect();n.dataTransfer.setDragImage(t,n.clientX-e.left,n.clientY-e.top)}}return void s(`${t}:dragstart`,{element:e,dataset:{...e.dataset}})}}})),a("dragend",(()=>{r&&(s(`${r}:dragend`,null),r=null)})),a("dragover",(t=>{const n=t;for(const[,t]of e)if(t.dropZone&&(!r||!t.accepts||t.accepts===r)&&n.target.closest(t.dropZone))return void n.preventDefault()})),a("drop",(t=>{const n=t;for(const[t,o]of e){if(!o.dropZone)continue;if(r&&o.accepts&&o.accepts!==r)continue;const i=n.target.closest(o.dropZone);if(!i)continue;n.preventDefault();let a=null;const c=r?e.get(r):null;return c?.draggable&&(a=n.target.closest(c.draggable)??null),void s(`${t}:drop`,{dropZone:i,insertBefore:a})}}));const c={select:t=>({events(e){const o=`${t}:${e}`;let r;return fr(ce.create({start(t){r=({detail:e})=>t.next(e),n.addEventListener(o,r)},stop(){r&&n.removeEventListener(o,r)}}))}}),dragstart:t=>c.select(t).events("dragstart"),dragend:t=>c.select(t).events("dragend"),drop:t=>c.select(t).events("drop"),dragover:t=>c.select(t).events("dragover"),dispose(){o.forEach((([t,e])=>document.removeEventListener(t,e)))}};return c}},t.makeServiceWorkerDriver=function(t,e={}){return function(n){const o=new EventTarget;return"undefined"!=typeof navigator&&"serviceWorker"in navigator&&(navigator.serviceWorker.register(t,{scope:e.scope}).then((t=>{const e=(t,e)=>o.dispatchEvent(new CustomEvent("data",{detail:{type:t,data:e}}));t.installing&&Zr(t.installing,o),t.waiting&&e("waiting",t.waiting),t.active&&e("activated",!0),t.addEventListener("updatefound",(()=>{t.installing&&Zr(t.installing,o)})),navigator.serviceWorker.addEventListener("controllerchange",(()=>{e("controlling",!0)})),navigator.serviceWorker.addEventListener("message",(t=>{e("message",t.data)}))})).catch((t=>{o.dispatchEvent(new CustomEvent("data",{detail:{type:"error",data:t}}))})),n.addListener({next:t=>{"skipWaiting"===t.action?navigator.serviceWorker.ready.then((t=>{t.waiting&&t.waiting.postMessage({type:"SKIP_WAITING"})})):"postMessage"===t.action?navigator.serviceWorker.ready.then((e=>{e.active&&e.active.postMessage(t.data)})):"unregister"===t.action&&navigator.serviceWorker.ready.then((t=>t.unregister()))},error:t=>console.error("[SW driver] Error in sink stream:",t)})),{select(t){let e;return ue(Jr.create({start:n=>{e=({detail:e})=>{t&&e.type!==t||n.next(e.data)},o.addEventListener("data",e)},stop:()=>{e&&o.removeEventListener("data",e)}}))}}}},t.mockDOMSource=ro,t.onlineStatus$=Kr,t.portal=ur,t.processDrag=function({draggable:t,dropZone:e}={},n={}){if(t&&"function"!=typeof t.events)throw new Error("processDrag: draggable must have an .events() method (e.g. DOM.select(...))");if(e&&"function"!=typeof e.events)throw new Error("processDrag: dropZone must have an .events() method (e.g. DOM.select(...))");const{effectAllowed:o="move"}=n;return{dragStart$:t?t.events("dragstart").map((t=>(t.dataTransfer.effectAllowed=o,t))):ce.never(),dragEnd$:t?t.events("dragend").mapTo(null):ce.never(),dragOver$:e?e.events("dragover").map((t=>(t.preventDefault(),null))):ce.never(),drop$:e?e.events("drop").map((t=>(t.preventDefault(),t))):ce.never()}},t.processForm=function(t,e={}){if(!t||"function"!=typeof t.events)throw new Error("processForm: first argument must have an .events() method (e.g. DOM.select(...))");let{events:n=["input","submit"],preventDefault:o=!0}=e;"string"==typeof n&&(n=[n]);const r=n.map((e=>t.events(e)));return ce.merge(...r).map((t=>{o&&t.preventDefault();const e="submit"===t.type?t.srcElement:t.currentTarget,n=new FormData(e),r={event:t,eventType:t.type},i=e.querySelector("input[type=submit]:focus");if(i){const{name:t,value:e}=i;r[t||"submit"]=e}for(const[t,e]of n.entries())r[t]=e;return r}))},t.renderComponent=function(t,e={}){const{initialState:n,mockConfig:o={},drivers:r={}}=e,i=t.name||t.componentName||"TestComponent",s=t,{intent:a,model:c,context:l,calculated:u,storeCalculatedInState:d,onError:p}=t,h=void 0!==n?n:t.initialState,f={next:()=>{}},m=lo.create({start(t){f.next=e=>t.next(e)},stop(){f.next=()=>{}}}),y={...c||{},__TEST_ACTION__:{STATE:(t,e)=>{if(!e||!e.type)return t;const{type:n,data:o}=e;let r=c?.[n];if(!r)for(const t of Object.keys(c||{}))if(t.includes("|")){const e=t.split("|").map((t=>t.trim()));if(e[0]===n){r={[e[1]]:c[t]};break}}if(!r)return t;if("function"==typeof r){const e=r(t,o);return"symbol"==typeof e?t:void 0!==e?e:t}if("object"==typeof r){const e=r.STATE||r[_];if("function"==typeof e){const n=e(t,o);return"symbol"==typeof n?t:void 0!==n?n:t}const n=r.EFFECT;if("function"==typeof n){n(t,o,((t,e)=>{setTimeout((()=>f.next({type:t,data:e})),10)}),{})}}return t}}},_="STATE",v=Fe(Uo({name:i,view:s,intent:a?t=>({...a(t),__TEST_ACTION__:m}):t=>({__TEST_ACTION__:m}),model:y,context:l,initialState:h,calculated:u,storeCalculatedInState:d,onError:p}),_),g={DOM:()=>ro(o),EVENTS:_r,LOG:vr,...r},{sources:b,sinks:w,run:S}=yr(v,g),E=S(),A=[];let O=null;const N=b.STATE&&b.STATE.stream?b.STATE.stream:lo.never();return O={next:t=>A.push(t),error:()=>{},complete:()=>{}},N.addListener(O),{state$:N,dom$:w.DOM||lo.never(),events$:b.EVENTS||{select:()=>lo.never()},sinks:w,sources:b,simulateAction:(t,e)=>{f.next({type:t,data:e})},waitForState:(t,e=2e3)=>new Promise(((n,o)=>{for(const e of A)try{if(t(e))return n(e)}catch(t){}const r=setTimeout((()=>{try{N.removeListener(i)}catch(t){}o(new Error(`waitForState timed out after ${e}ms`))}),e),i={next:e=>{try{t(e)&&(clearTimeout(r),N.removeListener(i),n(e))}catch(t){}},error:t=>{clearTimeout(r),o(t)},complete:()=>{clearTimeout(r),o(new Error("waitForState: state stream completed without matching"))}};N.addListener(i)})),states:A,dispose:()=>{if(O){try{N.removeListener(O)}catch(t){}O=null}if("function"==typeof w.__dispose)try{w.__dispose()}catch(t){}E()}}},t.renderToString=function(t,e={}){const{state:n,props:o={},context:r={},hydrateState:i}=e,s=void 0!==n?n:t.initialState,a=t.context||{},c={...r};for(const t of Object.keys(a)){const e=a[t];if("function"==typeof e&&null!=s)try{c[t]=e(s)}catch(t){}}let l;try{l=t({...o,state:s,children:o.children||[],slots:o.slots||{},context:c,peers:{}},s,c,{})}catch(e){if("function"==typeof t.onError){const n=t.componentName||t.name||"Component";try{l=t.onError(e,{componentName:n})}catch(t){l={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}}else l={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}l||(l={sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0}),l=oi(l,c,s);let u=ri(l);if(i&&null!=s){const t="string"==typeof i?i:"__SYGNAL_STATE__";ei(JSON.stringify(s)),u+=`<script>window.${t}=${JSON.stringify(s)}<\/script>`}return u},t.run=function t(e,n={},o={}){if("undefined"!=typeof window){wr().init()}const{mountPoint:r="#root",fragments:i=!0,useDefaultDrivers:s=!0}=o;if(!e.isSygnalComponent){const t=e.name||e.componentName||e.label||"FUNCTIONAL_COMPONENT",n=e,{model:o,intent:r,hmrActions:i,context:s,peers:a,components:c,initialState:l,calculated:u,storeCalculatedInState:d,DOMSourceName:p,stateSourceName:h,onError:f,debug:m}=e;e=Uo({name:t,view:n,model:o,intent:r,hmrActions:i,context:s,peers:a,components:c,initialState:l,calculated:u,storeCalculatedInState:d,DOMSourceName:p,stateSourceName:h,onError:f,debug:m})}"undefined"!=typeof window&&!0===window.__SYGNAL_HMR_UPDATING&&void 0!==window.__SYGNAL_HMR_PERSISTED_STATE&&(e.initialState=window.__SYGNAL_HMR_PERSISTED_STATE);const a=Fe(e,"STATE"),c={...s?{EVENTS:_r,DOM:eo(r,{snabbdomOptions:{experimental:{fragments:i}}}),LOG:vr}:{},...n},{sources:l,sinks:u,run:d}=yr(a,c),p=d();let h=null;"undefined"!=typeof window&&l?.STATE?.stream&&"function"==typeof l.STATE.stream.addListener&&(h={next:t=>{window.__SYGNAL_HMR_PERSISTED_STATE=t},error:()=>{},complete:()=>{}},l.STATE.stream.addListener(h));const f={sources:l,sinks:u,dispose:()=>{if(h&&l?.STATE?.stream&&"function"==typeof l.STATE.stream.removeListener&&(l.STATE.stream.removeListener(h),h=null),"function"==typeof u.__dispose)try{u.__dispose()}catch(t){}p()}};"undefined"!=typeof window&&(window.__SYGNAL_DEVTOOLS_APP__=f);const m=(r,i)=>{const s="undefined"!=typeof window?window.__SYGNAL_HMR_PERSISTED_STATE:void 0,a=void 0!==s?s:e.initialState,c=void 0===i?a:i;"undefined"!=typeof window&&(window.__SYGNAL_HMR_UPDATING=!0,window.__SYGNAL_HMR_STATE=c,window.__SYGNAL_HMR_PERSISTED_STATE=c),f.dispose();const l=r.default||r;l.initialState=c;const u=t(l,n,o);if(f.sources=u.sources,f.sinks=u.sinks,f.dispose=u.dispose,void 0!==c&&u?.sinks?.STATE&&"function"==typeof u.sinks.STATE.shamefullySendNext){const t=()=>u.sinks.STATE.shamefullySendNext((()=>({...c})));setTimeout(t,0),setTimeout(t,20)}"undefined"!=typeof window&&u?.sources?.STATE?.stream&&"function"==typeof u.sources.STATE.stream.setDebugListener?u.sources.STATE.stream.setDebugListener({next:()=>{u.sources.STATE.stream.setDebugListener(null),window.__SYGNAL_HMR_STATE=void 0,setTimeout((()=>{window.__SYGNAL_HMR_UPDATING=!1}),100)}}):"undefined"!=typeof window&&(window.__SYGNAL_HMR_STATE=void 0,window.__SYGNAL_HMR_UPDATING=!1)},y=t=>t?Array.isArray(t)?y(t.find(Boolean)):t.default&&"function"==typeof t.default?t:"function"==typeof t?{default:t}:null:null;return f.hmr=(t,n)=>{const o=y(t)||{default:e};if(void 0!==n)return"undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=n),void m(o,n);const r="undefined"!=typeof window?window.__SYGNAL_HMR_PERSISTED_STATE:void 0;if(void 0!==r)return"undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=r),void m(o,r);const i=f?.sources?.STATE?.stream?._v;if(void 0!==i)return"undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=i),void m(o,i);f?.sinks?.STATE&&"function"==typeof f.sinks.STATE.shamefullySendNext?f.sinks.STATE.shamefullySendNext((t=>("undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=t),m(o,t),Fo))):m(o)},f},t.sampleCombine=In,t.set=function(t){return"function"==typeof t?(e,n,o,r)=>({...e,...t(e,n,o,r)}):e=>({...e,...t})},t.switchable=ho,t.throttle=ci,t.thunk=function(t,e,n,o){return void 0===o&&(o=n,n=e,e=void 0),He(t,{key:e,hook:{init:hn,prepatch:fn},fn:n,args:o})},t.toggle=function(t){return e=>({...e,[t]:!e[t]})},t.xs=lo}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Sygnal={})}(this,(function(t){"use strict";function e(t,e){return e.forEach((function(e){e&&"string"!=typeof e&&!Array.isArray(e)&&Object.keys(e).forEach((function(n){if("default"!==n&&!(n in t)){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}}))})),Object.freeze(t)}var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var r={},s={};!function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(t){var e,n=t.Symbol;if("function"==typeof n)if(n.observable)e=n.observable;else{e=n.for("https://github.com/benlesh/symbol-observable");try{n.observable=e}catch(t){}}else e="@@observable";return e}}(s);var i,a,c=s,l=Object.prototype.toString,u=function(t){var e=l.call(t),n="[object Arguments]"===e;return n||(n="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===l.call(t.callee)),n};var d=Array.prototype.slice,h=u,p=Object.keys,f=p?function(t){return p(t)}:function(){if(a)return i;var t;if(a=1,!Object.keys){var e=Object.prototype.hasOwnProperty,n=Object.prototype.toString,o=u,r=Object.prototype.propertyIsEnumerable,s=!r.call({toString:null},"toString"),c=r.call((function(){}),"prototype"),l=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=function(t){var e=t.constructor;return e&&e.prototype===t},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&e.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{d(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();t=function(t){var r=null!==t&&"object"==typeof t,i="[object Function]"===n.call(t),a=o(t),u=r&&"[object String]"===n.call(t),h=[];if(!r&&!i&&!a)throw new TypeError("Object.keys called on a non-object");var f=c&&i;if(u&&t.length>0&&!e.call(t,0))for(var m=0;m<t.length;++m)h.push(String(m));if(a&&t.length>0)for(var y=0;y<t.length;++y)h.push(String(y));else for(var _ in t)f&&"prototype"===_||!e.call(t,_)||h.push(String(_));if(s)for(var v=function(t){if("undefined"==typeof window||!p)return d(t);try{return d(t)}catch(t){return!1}}(t),g=0;g<l.length;++g)v&&"constructor"===l[g]||!e.call(t,l[g])||h.push(l[g]);return h}}return i=t}(),m=Object.keys;f.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return h(t)?m(d.call(t)):m(t)})}else Object.keys=f;return Object.keys||f};var y,_=f,v="undefined"!=typeof Symbol&&Symbol,g=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),n=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(n))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var r=Object.getOwnPropertyDescriptor(t,e);if(42!==r.value||!0!==r.enumerable)return!1}return!0},S={foo:{}},b=Object,w=Array.prototype.slice,A=Object.prototype.toString,E=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==A.call(e))throw new TypeError("Function.prototype.bind called on incompatible "+e);for(var n,o=w.call(arguments,1),r=Math.max(0,e.length-o.length),s=[],i=0;i<r;i++)s.push("$"+i);if(n=Function("binder","return function ("+s.join(",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof n){var r=e.apply(this,o.concat(w.call(arguments)));return Object(r)===r?r:this}return e.apply(t,o.concat(w.call(arguments)))})),e.prototype){var a=function(){};a.prototype=e.prototype,n.prototype=new a,a.prototype=null}return n},N=Function.prototype.bind||E,O=N.call(Function.call,Object.prototype.hasOwnProperty),C=SyntaxError,T=Function,k=TypeError,$=function(t){try{return T('"use strict"; return ('+t+").constructor;")()}catch(t){}},x=Object.getOwnPropertyDescriptor;if(x)try{x({},"")}catch(t){x=null}var L=function(){throw new k},D=x?function(){try{return L}catch(t){try{return x(arguments,"callee").get}catch(t){return L}}}():L,G="function"==typeof v&&"function"==typeof Symbol&&"symbol"==typeof v("foo")&&"symbol"==typeof Symbol("bar")&&g(),j={__proto__:S}.foo===S.foo&&!({__proto__:null}instanceof b),I=Object.getPrototypeOf||(j?function(t){return t.__proto__}:null),M={},P="undefined"!=typeof Uint8Array&&I?I(Uint8Array):y,Y={"%AggregateError%":"undefined"==typeof AggregateError?y:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?y:ArrayBuffer,"%ArrayIteratorPrototype%":G&&I?I([][Symbol.iterator]()):y,"%AsyncFromSyncIteratorPrototype%":y,"%AsyncFunction%":M,"%AsyncGenerator%":M,"%AsyncGeneratorFunction%":M,"%AsyncIteratorPrototype%":M,"%Atomics%":"undefined"==typeof Atomics?y:Atomics,"%BigInt%":"undefined"==typeof BigInt?y:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?y:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?y:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?y:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?y:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?y:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?y:FinalizationRegistry,"%Function%":T,"%GeneratorFunction%":M,"%Int8Array%":"undefined"==typeof Int8Array?y:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?y:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?y:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":G&&I?I(I([][Symbol.iterator]())):y,"%JSON%":"object"==typeof JSON?JSON:y,"%Map%":"undefined"==typeof Map?y:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&G&&I?I((new Map)[Symbol.iterator]()):y,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?y:Promise,"%Proxy%":"undefined"==typeof Proxy?y:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?y:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?y:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&G&&I?I((new Set)[Symbol.iterator]()):y,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?y:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":G&&I?I(""[Symbol.iterator]()):y,"%Symbol%":G?Symbol:y,"%SyntaxError%":C,"%ThrowTypeError%":D,"%TypedArray%":P,"%TypeError%":k,"%Uint8Array%":"undefined"==typeof Uint8Array?y:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?y:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?y:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?y:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?y:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?y:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?y:WeakSet};if(I)try{null.error}catch(t){var R=I(I(t));Y["%Error.prototype%"]=R}var F=function t(e){var n;if("%AsyncFunction%"===e)n=$("async function () {}");else if("%GeneratorFunction%"===e)n=$("function* () {}");else if("%AsyncGeneratorFunction%"===e)n=$("async function* () {}");else if("%AsyncGenerator%"===e){var o=t("%AsyncGeneratorFunction%");o&&(n=o.prototype)}else if("%AsyncIteratorPrototype%"===e){var r=t("%AsyncGenerator%");r&&I&&(n=I(r.prototype))}return Y[e]=n,n},B={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},U=N,V=O,W=U.call(Function.call,Array.prototype.concat),H=U.call(Function.apply,Array.prototype.splice),z=U.call(Function.call,String.prototype.replace),q=U.call(Function.call,String.prototype.slice),J=U.call(Function.call,RegExp.prototype.exec),Z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,X=/\\(\\)?/g,K=function(t,e){var n,o=t;if(V(B,o)&&(o="%"+(n=B[o])[0]+"%"),V(Y,o)){var r=Y[o];if(r===M&&(r=F(o)),void 0===r&&!e)throw new k("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:n,name:o,value:r}}throw new C("intrinsic "+t+" does not exist!")},Q=function(t,e){if("string"!=typeof t||0===t.length)throw new k("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new k('"allowMissing" argument must be a boolean');if(null===J(/^%?[^%]*%?$/,t))throw new C("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=function(t){var e=q(t,0,1),n=q(t,-1);if("%"===e&&"%"!==n)throw new C("invalid intrinsic syntax, expected closing `%`");if("%"===n&&"%"!==e)throw new C("invalid intrinsic syntax, expected opening `%`");var o=[];return z(t,Z,(function(t,e,n,r){o[o.length]=n?z(r,X,"$1"):e||t})),o}(t),o=n.length>0?n[0]:"",r=K("%"+o+"%",e),s=r.name,i=r.value,a=!1,c=r.alias;c&&(o=c[0],H(n,W([0,1],c)));for(var l=1,u=!0;l<n.length;l+=1){var d=n[l],h=q(d,0,1),p=q(d,-1);if(('"'===h||"'"===h||"`"===h||'"'===p||"'"===p||"`"===p)&&h!==p)throw new C("property names with quotes must have matching quotes");if("constructor"!==d&&u||(a=!0),V(Y,s="%"+(o+="."+d)+"%"))i=Y[s];else if(null!=i){if(!(d in i)){if(!e)throw new k("base intrinsic for "+t+" exists, but the property is not available.");return}if(x&&l+1>=n.length){var f=x(i,d);i=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:i[d]}else u=V(i,d),i=i[d];u&&!a&&(Y[s]=i)}}return i},tt=Q("%Object.defineProperty%",!0),et=function(){if(tt)try{return tt({},"a",{value:1}),!0}catch(t){return!1}return!1};et.hasArrayLengthDefineBug=function(){if(!et())return null;try{return 1!==tt([],"length",{value:1}).length}catch(t){return!0}};var nt=et,ot=_,rt="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),st=Object.prototype.toString,it=Array.prototype.concat,at=Object.defineProperty,ct=nt(),lt=at&&ct,ut=function(t,e,n,o){if(e in t)if(!0===o){if(t[e]===n)return}else if("function"!=typeof(r=o)||"[object Function]"!==st.call(r)||!o())return;var r;lt?at(t,e,{configurable:!0,enumerable:!1,value:n,writable:!0}):t[e]=n},dt=function(t,e){var n=arguments.length>2?arguments[2]:{},o=ot(e);rt&&(o=it.call(o,Object.getOwnPropertySymbols(e)));for(var r=0;r<o.length;r+=1)ut(t,o[r],e[o[r]],n[o[r]])};dt.supportsDescriptors=!!lt;var ht=n,pt=function(){return"object"==typeof n&&n&&n.Math===Math&&n.Array===Array?n:ht},ft=dt,mt=pt,yt=dt,_t=n,vt=pt,gt=function(){var t=mt();if(ft.supportsDescriptors){var e=Object.getOwnPropertyDescriptor(t,"globalThis");e&&(!e.configurable||!e.enumerable&&e.writable&&globalThis===t)||Object.defineProperty(t,"globalThis",{configurable:!0,enumerable:!1,value:t,writable:!0})}else"object"==typeof globalThis&&globalThis===t||(t.globalThis=t);return t},St=vt(),bt=function(){return St};yt(bt,{getPolyfill:vt,implementation:_t,shim:gt});var wt,At=bt,Et=n&&n.__extends||(wt=function(t,e){return wt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},wt(t,e)},function(t,e){function n(){this.constructor=t}wt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(r,"__esModule",{value:!0});var Nt=r.NO_IL=r.NO=r.MemoryStream=re=r.Stream=void 0,Ot=c.default(At.getPolyfill()),Ct={},Tt=r.NO=Ct;function kt(){}function $t(t){for(var e=t.length,n=Array(e),o=0;o<e;++o)n[o]=t[o];return n}function xt(t,e,n){try{return t.f(e)}catch(t){return n._e(t),Ct}}var Lt={_n:kt,_e:kt,_c:kt};function Dt(t){t._start=function(t){t.next=t._n,t.error=t._e,t.complete=t._c,this.start(t)},t._stop=t.stop}Nt=r.NO_IL=Lt;var Gt=function(){function t(t,e){this._stream=t,this._listener=e}return t.prototype.unsubscribe=function(){this._stream._remove(this._listener)},t}(),jt=function(){function t(t){this._listener=t}return t.prototype.next=function(t){this._listener._n(t)},t.prototype.error=function(t){this._listener._e(t)},t.prototype.complete=function(){this._listener._c()},t}(),It=function(){function t(t){this.type="fromObservable",this.ins=t,this.active=!1}return t.prototype._start=function(t){this.out=t,this.active=!0,this._sub=this.ins.subscribe(new jt(t)),this.active||this._sub.unsubscribe()},t.prototype._stop=function(){this._sub&&this._sub.unsubscribe(),this.active=!1},t}(),Mt=function(){function t(t){this.type="merge",this.insArr=t,this.out=Ct,this.ac=0}return t.prototype._start=function(t){this.out=t;var e=this.insArr,n=e.length;this.ac=n;for(var o=0;o<n;o++)e[o]._add(this)},t.prototype._stop=function(){for(var t=this.insArr,e=t.length,n=0;n<e;n++)t[n]._remove(this);this.out=Ct},t.prototype._n=function(t){var e=this.out;e!==Ct&&e._n(t)},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){if(--this.ac<=0){var t=this.out;if(t===Ct)return;t._c()}},t}(),Pt=function(){function t(t,e,n){this.i=t,this.out=e,this.p=n,n.ils.push(this)}return t.prototype._n=function(t){var e=this.p,n=this.out;if(n!==Ct&&e.up(t,this.i)){var o=$t(e.vals);n._n(o)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.p;t.out!==Ct&&0==--t.Nc&&t.out._c()},t}(),Yt=function(){function t(t){this.type="combine",this.insArr=t,this.out=Ct,this.ils=[],this.Nc=this.Nn=0,this.vals=[]}return t.prototype.up=function(t,e){var n=this.vals[e],o=this.Nn?n===Ct?--this.Nn:this.Nn:0;return this.vals[e]=t,0===o},t.prototype._start=function(t){this.out=t;var e=this.insArr,n=this.Nc=this.Nn=e.length,o=this.vals=new Array(n);if(0===n)t._n([]),t._c();else for(var r=0;r<n;r++)o[r]=Ct,e[r]._add(new Pt(r,t,this))},t.prototype._stop=function(){for(var t=this.insArr,e=t.length,n=this.ils,o=0;o<e;o++)t[o]._remove(n[o]);this.out=Ct,this.ils=[],this.vals=[]},t}(),Rt=function(){function t(t){this.type="fromArray",this.a=t}return t.prototype._start=function(t){for(var e=this.a,n=0,o=e.length;n<o;n++)t._n(e[n]);t._c()},t.prototype._stop=function(){},t}(),Ft=function(){function t(t){this.type="fromPromise",this.on=!1,this.p=t}return t.prototype._start=function(t){var e=this;this.on=!0,this.p.then((function(n){e.on&&(t._n(n),t._c())}),(function(e){t._e(e)})).then(kt,(function(t){setTimeout((function(){throw t}))}))},t.prototype._stop=function(){this.on=!1},t}(),Bt=function(){function t(t){this.type="periodic",this.period=t,this.intervalID=-1,this.i=0}return t.prototype._start=function(t){var e=this;this.intervalID=setInterval((function(){t._n(e.i++)}),this.period)},t.prototype._stop=function(){-1!==this.intervalID&&clearInterval(this.intervalID),this.intervalID=-1,this.i=0},t}(),Ut=function(){function t(t,e){this.type="debug",this.ins=t,this.out=Ct,this.s=kt,this.l="","string"==typeof e?this.l=e:"function"==typeof e&&(this.s=e)}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=this.s,o=this.l;if(n!==kt)try{n(t)}catch(t){e._e(t)}else o?console.log(o+":",t):console.log(t);e._n(t)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Vt=function(){function t(t,e){this.type="drop",this.ins=e,this.out=Ct,this.max=t,this.dropped=0}return t.prototype._start=function(t){this.out=t,this.dropped=0,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;e!==Ct&&this.dropped++>=this.max&&e._n(t)},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Wt=function(){function t(t,e){this.out=t,this.op=e}return t.prototype._n=function(){this.op.end()},t.prototype._e=function(t){this.out._e(t)},t.prototype._c=function(){this.op.end()},t}(),Ht=function(){function t(t,e){this.type="endWhen",this.ins=e,this.out=Ct,this.o=t,this.oil=Lt}return t.prototype._start=function(t){this.out=t,this.o._add(this.oil=new Wt(t,this)),this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.o._remove(this.oil),this.out=Ct,this.oil=Lt},t.prototype.end=function(){var t=this.out;t!==Ct&&t._c()},t.prototype._n=function(t){var e=this.out;e!==Ct&&e._n(t)},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){this.end()},t}(),zt=function(){function t(t,e){this.type="filter",this.ins=e,this.out=Ct,this.f=t}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=xt(this,t,e);n!==Ct&&n&&e._n(t)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),qt=function(){function t(t,e){this.out=t,this.op=e}return t.prototype._n=function(t){this.out._n(t)},t.prototype._e=function(t){this.out._e(t)},t.prototype._c=function(){this.op.inner=Ct,this.op.less()},t}(),Jt=function(){function t(t){this.type="flatten",this.ins=t,this.out=Ct,this.open=!0,this.inner=Ct,this.il=Lt}return t.prototype._start=function(t){this.out=t,this.open=!0,this.inner=Ct,this.il=Lt,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.inner!==Ct&&this.inner._remove(this.il),this.out=Ct,this.open=!0,this.inner=Ct,this.il=Lt},t.prototype.less=function(){var t=this.out;t!==Ct&&(this.open||this.inner!==Ct||t._c())},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=this.inner,o=this.il;n!==Ct&&o!==Lt&&n._remove(o),(this.inner=t)._add(this.il=new qt(e,this))}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){this.open=!1,this.less()},t}(),Zt=function(){function t(t,e,n){var o=this;this.type="fold",this.ins=n,this.out=Ct,this.f=function(e){return t(o.acc,e)},this.acc=this.seed=e}return t.prototype._start=function(t){this.out=t,this.acc=this.seed,t._n(this.acc),this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct,this.acc=this.seed},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=xt(this,t,e);n!==Ct&&e._n(this.acc=n)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Xt=function(){function t(t){this.type="last",this.ins=t,this.out=Ct,this.has=!1,this.val=Ct}return t.prototype._start=function(t){this.out=t,this.has=!1,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct,this.val=Ct},t.prototype._n=function(t){this.has=!0,this.val=t},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&(this.has?(t._n(this.val),t._c()):t._e(new Error("last() failed because input stream completed")))},t}(),Kt=function(){function t(t,e){this.type="map",this.ins=e,this.out=Ct,this.f=t}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=xt(this,t,e);n!==Ct&&e._n(n)}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),Qt=function(){function t(t){this.type="remember",this.ins=t,this.out=Ct}return t.prototype._start=function(t){this.out=t,this.ins._add(t)},t.prototype._stop=function(){this.ins._remove(this.out),this.out=Ct},t}(),te=function(){function t(t,e){this.type="replaceError",this.ins=e,this.out=Ct,this.f=t}return t.prototype._start=function(t){this.out=t,this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;e!==Ct&&e._n(t)},t.prototype._e=function(t){var e=this.out;if(e!==Ct)try{this.ins._remove(this),(this.ins=this.f(t))._add(this)}catch(t){e._e(t)}},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),ee=function(){function t(t,e){this.type="startWith",this.ins=t,this.out=Ct,this.val=e}return t.prototype._start=function(t){this.out=t,this.out._n(this.val),this.ins._add(t)},t.prototype._stop=function(){this.ins._remove(this.out),this.out=Ct},t}(),ne=function(){function t(t,e){this.type="take",this.ins=e,this.out=Ct,this.max=t,this.taken=0}return t.prototype._start=function(t){this.out=t,this.taken=0,this.max<=0?t._c():this.ins._add(this)},t.prototype._stop=function(){this.ins._remove(this),this.out=Ct},t.prototype._n=function(t){var e=this.out;if(e!==Ct){var n=++this.taken;n<this.max?e._n(t):n===this.max&&(e._n(t),e._c())}},t.prototype._e=function(t){var e=this.out;e!==Ct&&e._e(t)},t.prototype._c=function(){var t=this.out;t!==Ct&&t._c()},t}(),oe=function(){function t(t){this._prod=t||Ct,this._ils=[],this._stopID=Ct,this._dl=Ct,this._d=!1,this._target=null,this._err=Ct}return t.prototype._n=function(t){var e=this._ils,n=e.length;if(this._d&&this._dl._n(t),1==n)e[0]._n(t);else{if(0==n)return;for(var o=$t(e),r=0;r<n;r++)o[r]._n(t)}},t.prototype._e=function(t){if(this._err===Ct){this._err=t;var e=this._ils,n=e.length;if(this._x(),this._d&&this._dl._e(t),1==n)e[0]._e(t);else{if(0==n)return;for(var o=$t(e),r=0;r<n;r++)o[r]._e(t)}if(!this._d&&0==n)throw this._err}},t.prototype._c=function(){var t=this._ils,e=t.length;if(this._x(),this._d&&this._dl._c(),1==e)t[0]._c();else{if(0==e)return;for(var n=$t(t),o=0;o<e;o++)n[o]._c()}},t.prototype._x=function(){0!==this._ils.length&&(this._prod!==Ct&&this._prod._stop(),this._err=Ct,this._ils=[])},t.prototype._stopNow=function(){this._prod._stop(),this._err=Ct,this._stopID=Ct},t.prototype._add=function(t){var e=this._target;if(e)return e._add(t);var n=this._ils;if(n.push(t),!(n.length>1))if(this._stopID!==Ct)clearTimeout(this._stopID),this._stopID=Ct;else{var o=this._prod;o!==Ct&&o._start(this)}},t.prototype._remove=function(t){var e=this,n=this._target;if(n)return n._remove(t);var o=this._ils,r=o.indexOf(t);r>-1&&(o.splice(r,1),this._prod!==Ct&&o.length<=0?(this._err=Ct,this._stopID=setTimeout((function(){return e._stopNow()}))):1===o.length&&this._pruneCycles())},t.prototype._pruneCycles=function(){this._hasNoSinks(this,[])&&this._remove(this._ils[0])},t.prototype._hasNoSinks=function(t,e){if(-1!==e.indexOf(t))return!0;if(t.out===this)return!0;if(t.out&&t.out!==Ct)return this._hasNoSinks(t.out,e.concat(t));if(t._ils){for(var n=0,o=t._ils.length;n<o;n++)if(!this._hasNoSinks(t._ils[n],e.concat(t)))return!1;return!0}return!1},t.prototype.ctor=function(){return this instanceof se?se:t},t.prototype.addListener=function(t){t._n=t.next||kt,t._e=t.error||kt,t._c=t.complete||kt,this._add(t)},t.prototype.removeListener=function(t){this._remove(t)},t.prototype.subscribe=function(t){return this.addListener(t),new Gt(this,t)},t.prototype[Ot]=function(){return this},t.create=function(e){if(e){if("function"!=typeof e.start||"function"!=typeof e.stop)throw new Error("producer requires both start and stop functions");Dt(e)}return new t(e)},t.createWithMemory=function(t){return t&&Dt(t),new se(t)},t.never=function(){return new t({_start:kt,_stop:kt})},t.empty=function(){return new t({_start:function(t){t._c()},_stop:kt})},t.throw=function(e){return new t({_start:function(t){t._e(e)},_stop:kt})},t.from=function(e){if("function"==typeof e[Ot])return t.fromObservable(e);if("function"==typeof e.then)return t.fromPromise(e);if(Array.isArray(e))return t.fromArray(e);throw new TypeError("Type of input to from() must be an Array, Promise, or Observable")},t.of=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.fromArray(e)},t.fromArray=function(e){return new t(new Rt(e))},t.fromPromise=function(e){return new t(new Ft(e))},t.fromObservable=function(e){if(void 0!==e.endWhen)return e;var n="function"==typeof e[Ot]?e[Ot]():e;return new t(new It(n))},t.periodic=function(e){return new t(new Bt(e))},t.prototype._map=function(t){return new(this.ctor())(new Kt(t,this))},t.prototype.map=function(t){return this._map(t)},t.prototype.mapTo=function(t){var e=this.map((function(){return t}));return e._prod.type="mapTo",e},t.prototype.filter=function(e){var n,o,r=this._prod;return new t(r instanceof zt?new zt((n=r.f,o=e,function(t){return n(t)&&o(t)}),r.ins):new zt(e,this))},t.prototype.take=function(t){return new(this.ctor())(new ne(t,this))},t.prototype.drop=function(e){return new t(new Vt(e,this))},t.prototype.last=function(){return new t(new Xt(this))},t.prototype.startWith=function(t){return new se(new ee(this,t))},t.prototype.endWhen=function(t){return new(this.ctor())(new Ht(t,this))},t.prototype.fold=function(t,e){return new se(new Zt(t,e,this))},t.prototype.replaceError=function(t){return new(this.ctor())(new te(t,this))},t.prototype.flatten=function(){return new t(new Jt(this))},t.prototype.compose=function(t){return t(this)},t.prototype.remember=function(){return new se(new Qt(this))},t.prototype.debug=function(t){return new(this.ctor())(new Ut(this,t))},t.prototype.imitate=function(t){if(t instanceof se)throw new Error("A MemoryStream was given to imitate(), but it only supports a Stream. Read more about this restriction here: https://github.com/staltz/xstream#faq");this._target=t;for(var e=this._ils,n=e.length,o=0;o<n;o++)t._add(e[o]);this._ils=[]},t.prototype.shamefullySendNext=function(t){this._n(t)},t.prototype.shamefullySendError=function(t){this._e(t)},t.prototype.shamefullySendComplete=function(){this._c()},t.prototype.setDebugListener=function(t){t?(this._d=!0,t._n=t.next||kt,t._e=t.error||kt,t._c=t.complete||kt,this._dl=t):(this._d=!1,this._dl=Ct)},t.merge=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new t(new Mt(e))},t.combine=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return new t(new Yt(e))},t}(),re=r.Stream=oe,se=function(t){function e(e){var n=t.call(this,e)||this;return n._has=!1,n}return Et(e,t),e.prototype._n=function(e){this._v=e,this._has=!0,t.prototype._n.call(this,e)},e.prototype._add=function(t){var e=this._target;if(e)return e._add(t);var n=this._ils;if(n.push(t),n.length>1)this._has&&t._n(this._v);else if(this._stopID!==Ct)this._has&&t._n(this._v),clearTimeout(this._stopID),this._stopID=Ct;else if(this._has)t._n(this._v);else{var o=this._prod;o!==Ct&&o._start(this)}},e.prototype._stopNow=function(){this._has=!1,t.prototype._stopNow.call(this)},e.prototype._x=function(){this._has=!1,t.prototype._x.call(this)},e.prototype.map=function(t){return this._map(t)},e.prototype.mapTo=function(e){return t.prototype.mapTo.call(this,e)},e.prototype.take=function(e){return t.prototype.take.call(this,e)},e.prototype.endWhen=function(e){return t.prototype.endWhen.call(this,e)},e.prototype.replaceError=function(e){return t.prototype.replaceError.call(this,e)},e.prototype.remember=function(){return this},e.prototype.debug=function(e){return t.prototype.debug.call(this,e)},e}(oe),ie=r.MemoryStream=se,ae=oe,ce=r.default=ae,le=e({__proto__:null,get MemoryStream(){return ie},get NO(){return Tt},get NO_IL(){return Nt},get Stream(){return re},default:ce},[r]);function ue(t){return function(){let t;return t="undefined"!=typeof window?window:"undefined"!=typeof global?global:this,t.Cyclejs=t.Cyclejs||{},t=t.Cyclejs,t.adaptStream=t.adaptStream||(t=>t),t}().adaptStream(t)}let de=0;function he(){return"cycle"+ ++de}function pe(t,e=he()){!function(t,e){if("function"!=typeof t)throw new Error("First argument given to isolate() must be a 'dataflowComponent' function");if(null===e)throw new Error("Second argument given to isolate() must not be null")}(t,e);const n="object"==typeof e?he():"",o="string"==typeof e||"object"==typeof e?e:e.toString();return function(e,...r){const s=function(t,e,n){const o={};return Object.keys(t).forEach((t=>{if("string"==typeof e)return void(o[t]=e);const r=e[t];if(void 0!==r)return void(o[t]=r);const s=e["*"];o[t]=void 0===s?n:s})),o}(e,o,n),i=function(t,e){const n={};for(const o in t){const r=t[o];Object.prototype.hasOwnProperty.call(t,o)&&r&&null!==e[o]&&"function"==typeof r.isolateSource?n[o]=r.isolateSource(r,e[o]):Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o])}return n}(e,s),a=function(t,e,n){const o={};for(const r in e){const s=t[r],i=e[r];Object.prototype.hasOwnProperty.call(e,r)&&s&&null!==n[r]&&"function"==typeof s.isolateSink?o[r]=ue(s.isolateSink(ce.fromObservable(i),n[r])):Object.prototype.hasOwnProperty.call(e,r)&&(o[r]=e[r])}return o}(e,t(i,...r),s);return a}}pe.reset=()=>de=0;class fe{constructor(t){this.streams=t,this.type="concat",this.out=null,this.i=0}_start(t){this.out=t,this.streams[this.i]._add(this)}_stop(){const t=this.streams;this.i<t.length&&t[this.i]._remove(this),this.i=0,this.out=null}_n(t){const e=this.out;e&&e._n(t)}_e(t){const e=this.out;e&&e._e(t)}_c(){const t=this.out;if(!t)return;const e=this.streams;e[this.i]._remove(this),++this.i<e.length?e[this.i]._add(this):t._c()}}function me(...t){return new re(new fe(t))}const ye={};class _e{constructor(t,e){this.dt=t,this.ins=e,this.type="debounce",this.out=null,this.id=null,this.t=ye}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this),this.out=null,this.clearInterval()}clearInterval(){const t=this.id;null!==t&&clearInterval(t),this.id=null}_n(t){const e=this.out;e&&(this.clearInterval(),this.t=t,this.id=setInterval((()=>{this.clearInterval(),e._n(t),this.t=ye}),this.dt))}_e(t){const e=this.out;e&&(this.clearInterval(),e._e(t))}_c(){const t=this.out;t&&(this.clearInterval(),this.t!=ye&&t._n(this.t),this.t=ye,t._c())}}function ve(t){return function(e){return new re(new _e(t,e))}}class ge{constructor(t,e){this.dt=t,this.ins=e,this.type="throttle",this.out=null,this.id=null}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this),this.out=null,this.id=null}clearInterval(){const t=this.id;null!==t&&clearInterval(t),this.id=null}_n(t){const e=this.out;e&&(this.id||(e._n(t),this.id=setInterval((()=>{this.clearInterval()}),this.dt)))}_e(t){const e=this.out;e&&(this.clearInterval(),e._e(t))}_c(){const t=this.out;t&&(this.clearInterval(),t._c())}}class Se{constructor(t,e){this.dt=t,this.ins=e,this.type="delay",this.out=null}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this),this.out=null}_n(t){const e=this.out;if(!e)return;const n=setInterval((()=>{e._n(t),clearInterval(n)}),this.dt)}_e(t){const e=this.out;if(!e)return;const n=setInterval((()=>{e._e(t),clearInterval(n)}),this.dt)}_c(){const t=this.out;if(!t)return;const e=setInterval((()=>{t._c(),clearInterval(e)}),this.dt)}}function be(t){return function(e){return new re(new Se(t,e))}}const we={};class Ae{constructor(t,e){this.ins=t,this.type="dropRepeats",this.out=null,this.v=we,this.isEq=e||((t,e)=>t===e)}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this),this.out=null,this.v=we}_n(t){const e=this.out;if(!e)return;const n=this.v;n!==we&&this.isEq(t,n)||(this.v=t,e._n(t))}_e(t){const e=this.out;e&&e._e(t)}_c(){const t=this.out;t&&t._c()}}function Ee(t){return function(e){return new re(new Ae(e,t))}}const Ne={};class Oe{constructor(t,e){this.i=t,this.p=e,e.ils[t]=this}_n(t){const e=this.p;e.out!==Ne&&e.up(t,this.i)}_e(t){this.p._e(t)}_c(){this.p.down(this.i,this)}}class Ce{constructor(t,e){this.ins=t,this.others=e,this.type="sampleCombine",this.out=Ne,this.ils=[],this.Nn=0,this.vals=[]}_start(t){this.out=t;const e=this.others,n=this.Nn=e.length,o=this.vals=new Array(n);for(let t=0;t<n;t++)o[t]=Ne,e[t]._add(new Oe(t,this));this.ins._add(this)}_stop(){const t=this.others,e=t.length,n=this.ils;this.ins._remove(this);for(let o=0;o<e;o++)t[o]._remove(n[o]);this.out=Ne,this.vals=[],this.ils=[]}_n(t){const e=this.out;e!==Ne&&(this.Nn>0||e._n([t,...this.vals]))}_e(t){const e=this.out;e!==Ne&&e._e(t)}_c(){const t=this.out;t!==Ne&&t._c()}up(t,e){const n=this.vals[e];this.Nn>0&&n===Ne&&this.Nn--,this.vals[e]=t}down(t,e){this.others[t]._remove(e)}}function Te(...t){return function(e){return new re(new Ce(e,t))}}function ke(t){return"string"==typeof t||"number"==typeof t?function(e){return null==e?void 0:e[t]}:t.get}function $e(t){return"string"==typeof t||"number"==typeof t?function(e,n){return Array.isArray(e)?function(t,e,n){if(n===t[e])return t;const o=parseInt(e);return void 0===n?t.filter(((t,e)=>e!==o)):t.map(((t,e)=>e===o?n:t))}(e,t,n):void 0===e?{[t]:n}:{...e,[t]:n}}:t.set}function xe(t,e){return t.select(e)}function Le(t,e){const n=ke(e),o=$e(e);return t.map((t=>function(e){const r=n(e),s=t(r);return r===s?e:o(e,s)}))}class De{constructor(t,e){this.isolateSource=xe,this.isolateSink=Le,this._stream=t.filter((t=>void 0!==t)).compose(Ee()).remember(),this._name=e,this.stream=ue(this._stream),this._stream._isCycleSource=e}select(t){const e=ke(t);return new De(this._stream.map(e),this._name)}}class Ge{constructor(t,e,n){this.ins=n,this.out=t,this.p=e}_n(t){this.p;const e=this.out;null!==e&&e._n(t)}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){}}class je{constructor(t,e){this.type="pickMerge",this.ins=e,this.out=null,this.sel=t,this.ils=new Map,this.inst=null}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this);const t=this.ils;t.forEach(((e,n)=>{e.ins._remove(e),e.ins=null,e.out=null,t.delete(n)})),t.clear(),this.out=null,this.ils=new Map,this.inst=null}_n(t){this.inst=t;const e=t.arr,n=this.ils,o=this.out,r=this.sel,s=e.length;for(let t=0;t<s;++t){const s=e[t],i=s._key,a=ce.fromObservable(s[r]||ce.never());n.has(i)||(n.set(i,new Ge(o,this,a)),a._add(n.get(i)))}n.forEach(((e,o)=>{t.dict.has(o)&&t.dict.get(o)||(e.ins._remove(e),e.ins=null,e.out=null,n.delete(o))}))}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){const t=this.out;null!==t&&t._c()}}class Ie{constructor(t,e,n,o){this.key=t,this.out=e,this.p=n,this.val=Tt,this.ins=o}_n(t){this.p;const e=this.out;this.val=t,null!==e&&this.p.up()}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){}}class Me{constructor(t,e){this.type="combine",this.ins=e,this.sel=t,this.out=null,this.ils=new Map,this.inst=null,this.keys=[]}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this);const t=this.ils;t.forEach((t=>{t.ins._remove(t),t.ins=null,t.out=null,t.val=null})),t.clear(),this.out=null,this.ils=new Map,this.inst=null,this.keys=[]}up(){const t=this.inst.arr,e=t.length,n=this.ils,o=Array(e);for(let r=0;r<e;++r){const e=t[r]._key;if(!n.has(e))return;const s=n.get(e).val;if(s===Tt)return;o[r]=s}this.out._n(o)}_n(t){this.inst=t;const e=t.arr,n=this.ils,o=this.out,r=this.sel,s=t.dict,i=e.length;let a=!1;if(n.forEach(((t,e)=>{s.has(e)||(t.ins._remove(t),t.ins=null,t.out=null,t.val=null,n.delete(e),a=!0)})),0===i)return this.keys=[],void o._n([]);const c=Array(i);for(let t=0;t<i;++t){const s=e[t],i=s._key;if(c[t]=i,!s[r])throw new Error("pickCombine found an undefined child sink stream");const a=ce.fromObservable(s[r]);n.has(i)||(n.set(i,new Ie(i,o,this,a)),a._add(n.get(i)))}const l=function(t,e,n){const o=t.length;if(o===e.length){let n=!0;for(let r=0;r<o&&n;++r)n=t[r]===e[r];if(n)return!1}let r=0;const s=new Set(t);for(let i=0;i<e.length;++i){const a=e[i];if(s.has(a)){for(;r<o&&!n.has(t[r]);)++r;if(t[r]!==a)return!0;++r}}return!1}(this.keys,c,s);this.keys=c,(a||l)&&this.up()}_e(t){const e=this.out;null!==e&&e._e(t)}_c(){const t=this.out;null!==t&&t._c()}}class Pe{constructor(t){this._instances$=t}pickMerge(t){return ue(this._instances$.compose(function(t){return function(e){return new re(new je(t,e))}}(t)))}pickCombine(t){return ue(this._instances$.compose(function(t){return function(e){return new re(new Me(t,e))}}(t)))}}function Ye(t){return{"*":null}}function Re(t,e){return{get(n){if(void 0!==n)for(let o=0,r=n.length;o<r;++o)if(`${t(n[o],o)}`===e)return n[o]},set:(n,o)=>void 0===n?[o]:void 0===o?n.filter(((n,o)=>`${t(n,o)}`!==e)):n.map(((n,r)=>`${t(n,r)}`===e?o:n))}}const Fe={get:t=>t,set:(t,e)=>e};function Be(t,e="state"){return function(n){const o=ce.create(),r=o.fold(((t,e)=>e(t)),void 0).drop(1),s=n;s[e]=new De(r,e);const i=t(s);if(i[e]){me(ce.fromObservable(i[e]),ce.never()).subscribe({next:t=>queueMicrotask((()=>o._n(t))),error:t=>queueMicrotask((()=>o._e(t))),complete:()=>queueMicrotask((()=>o._c()))})}return i}}function Ue(t,e,n,o,r){return{sel:t,data:e,children:n,text:o,elm:r,key:void 0===e?void 0:e.key}}const Ve=Array.isArray;function We(t){return"string"==typeof t||"number"==typeof t||t instanceof String||t instanceof Number}function He(t,e,n){if(t.ns="http://www.w3.org/2000/svg","foreignObject"!==n&&void 0!==e)for(let t=0;t<e.length;++t){const n=e[t];if("string"==typeof n)continue;const o=n.data;void 0!==o&&He(o,n.children,n.sel)}}function ze(t,e,n){let o,r,s,i={};if(void 0!==n?(null!==e&&(i=e),Ve(n)?o=n:We(n)?r=n.toString():n&&n.sel&&(o=[n])):null!=e&&(Ve(e)?o=e:We(e)?r=e.toString():e&&e.sel?o=[e]:i=e),void 0!==o)for(s=0;s<o.length;++s)We(o[s])&&(o[s]=Ue(void 0,void 0,void 0,o[s],void 0));return!t.startsWith("svg")||3!==t.length&&"."!==t[3]&&"#"!==t[3]||He(i,o,t),Ue(t,i,o,r,void 0)}function qe(t){if(Je(t)){for(;t&&Je(t);){t=Ze(t).parent}return null!=t?t:null}return t.parentNode}function Je(t){return 11===t.nodeType}function Ze(t,e){var n,o,r;const s=t;return null!==(n=s.parent)&&void 0!==n||(s.parent=null!=e?e:null),null!==(o=s.firstChildNode)&&void 0!==o||(s.firstChildNode=t.firstChild),null!==(r=s.lastChildNode)&&void 0!==r||(s.lastChildNode=t.lastChild),s}const Xe={createElement:function(t,e){return document.createElement(t,e)},createElementNS:function(t,e,n){return document.createElementNS(t,e,n)},createTextNode:function(t){return document.createTextNode(t)},createDocumentFragment:function(){return Ze(document.createDocumentFragment())},createComment:function(t){return document.createComment(t)},insertBefore:function(t,e,n){if(Je(t)){let e=t;for(;e&&Je(e);){e=Ze(e).parent}t=null!=e?e:t}Je(e)&&(e=Ze(e,t)),n&&Je(n)&&(n=Ze(n).firstChildNode),t.insertBefore(e,n)},removeChild:function(t,e){t.removeChild(e)},appendChild:function(t,e){Je(e)&&(e=Ze(e,t)),t.appendChild(e)},parentNode:qe,nextSibling:function(t){var e;if(Je(t)){const n=Ze(t),o=qe(n);if(o&&n.lastChildNode){const t=Array.from(o.childNodes),r=t.indexOf(n.lastChildNode);return null!==(e=t[r+1])&&void 0!==e?e:null}return null}return t.nextSibling},tagName:function(t){return t.tagName},setTextContent:function(t,e){t.textContent=e},getTextContent:function(t){return t.textContent},isElement:function(t){return 1===t.nodeType},isText:function(t){return 3===t.nodeType},isComment:function(t){return 8===t.nodeType},isDocumentFragment:Je},Ke=Ue("",{},[],void 0,void 0);function Qe(t,e){var n,o;const r=t.key===e.key,s=(null===(n=t.data)||void 0===n?void 0:n.is)===(null===(o=e.data)||void 0===o?void 0:o.is),i=t.sel===e.sel,a=!(!t.sel&&t.sel===e.sel)||typeof t.text==typeof e.text;return i&&r&&s&&a}function tn(){throw new Error("The document fragment is not supported on this platform.")}function en(t,e,n){var o;const r={};for(let s=e;s<=n;++s){const e=null===(o=t[s])||void 0===o?void 0:o.key;void 0!==e&&(r[e]=s)}return r}const nn=["create","update","remove","destroy","pre","post"];function on(t,e,n){const o={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},r=void 0!==e?e:Xe;for(const e of nn)for(const n of t){const t=n[e];void 0!==t&&o[e].push(t)}function s(t,e){return function(){if(0==--e){const e=r.parentNode(t);null!==e&&r.removeChild(e,t)}}}function i(t,e){var s,a,c,l,u;let d;const h=t.data,p=null==h?void 0:h.hook;null===(s=null==p?void 0:p.init)||void 0===s||s.call(p,t);const f=t.children,m=t.sel;if("!"===m)null!==(a=t.text)&&void 0!==a||(t.text=""),t.elm=r.createComment(t.text);else if(""===m)t.elm=r.createTextNode(t.text);else if(void 0!==m){const n=m.indexOf("#"),s=m.indexOf(".",n),a=n>0?n:m.length,l=s>0?s:m.length,u=-1!==n||-1!==s?m.slice(0,Math.min(a,l)):m,y=null==h?void 0:h.ns,_=void 0===y?r.createElement(u,h):r.createElementNS(y,u,h);for(t.elm=_,a<l&&_.setAttribute("id",m.slice(a+1,l)),s>0&&_.setAttribute("class",m.slice(l+1).replace(/\./g," ")),d=0;d<o.create.length;++d)o.create[d](Ke,t);if(!We(t.text)||Ve(f)&&0!==f.length||r.appendChild(_,r.createTextNode(t.text)),Ve(f))for(d=0;d<f.length;++d){const t=f[d];null!=t&&r.appendChild(_,i(t,e))}void 0!==p&&(null===(c=p.create)||void 0===c||c.call(p,Ke,t),void 0!==p.insert&&e.push(t))}else if((null===(l=null==n?void 0:n.experimental)||void 0===l?void 0:l.fragments)&&t.children){for(t.elm=(null!==(u=r.createDocumentFragment)&&void 0!==u?u:tn)(),d=0;d<o.create.length;++d)o.create[d](Ke,t);for(d=0;d<t.children.length;++d){const n=t.children[d];null!=n&&r.appendChild(t.elm,i(n,e))}}else t.elm=r.createTextNode(t.text);return t.elm}function a(t,e,n,o,s,a){for(;o<=s;++o){const s=n[o];null!=s&&r.insertBefore(t,i(s,a),e)}}function c(t){var e,n;const r=t.data;if(void 0!==r){null===(n=null===(e=null==r?void 0:r.hook)||void 0===e?void 0:e.destroy)||void 0===n||n.call(e,t);for(let e=0;e<o.destroy.length;++e)o.destroy[e](t);if(void 0!==t.children)for(let e=0;e<t.children.length;++e){const n=t.children[e];null!=n&&"string"!=typeof n&&c(n)}}}function l(t,e,n,i){for(var a,u;n<=i;++n){let i;const d=e[n];if(null!=d)if(void 0!==d.sel){c(d),i=o.remove.length+1;const t=s(d.elm,i);for(let e=0;e<o.remove.length;++e)o.remove[e](d,t);const e=null===(u=null===(a=null==d?void 0:d.data)||void 0===a?void 0:a.hook)||void 0===u?void 0:u.remove;void 0!==e?e(d,t):t()}else d.children?(c(d),l(t,d.children,0,d.children.length-1)):r.removeChild(t,d.elm)}}function u(t,e,n){var s,c,d,h,p,f,m,y;const _=null===(s=e.data)||void 0===s?void 0:s.hook;null===(c=null==_?void 0:_.prepatch)||void 0===c||c.call(_,t,e);const v=e.elm=t.elm;if(t===e)return;if(void 0!==e.data||void 0!==e.text&&e.text!==t.text){null!==(d=e.data)&&void 0!==d||(e.data={}),null!==(h=t.data)&&void 0!==h||(t.data={});for(let n=0;n<o.update.length;++n)o.update[n](t,e);null===(m=null===(f=null===(p=e.data)||void 0===p?void 0:p.hook)||void 0===f?void 0:f.update)||void 0===m||m.call(f,t,e)}const g=t.children,S=e.children;void 0===e.text?void 0!==g&&void 0!==S?g!==S&&function(t,e,n,o){let s,c,d,h,p=0,f=0,m=e.length-1,y=e[0],_=e[m],v=n.length-1,g=n[0],S=n[v];for(;p<=m&&f<=v;)null==y?y=e[++p]:null==_?_=e[--m]:null==g?g=n[++f]:null==S?S=n[--v]:Qe(y,g)?(u(y,g,o),y=e[++p],g=n[++f]):Qe(_,S)?(u(_,S,o),_=e[--m],S=n[--v]):Qe(y,S)?(u(y,S,o),r.insertBefore(t,y.elm,r.nextSibling(_.elm)),y=e[++p],S=n[--v]):Qe(_,g)?(u(_,g,o),r.insertBefore(t,_.elm,y.elm),_=e[--m],g=n[++f]):(void 0===s&&(s=en(e,p,m)),c=s[g.key],void 0===c?(r.insertBefore(t,i(g,o),y.elm),g=n[++f]):void 0===s[S.key]?(r.insertBefore(t,i(S,o),r.nextSibling(_.elm)),S=n[--v]):(d=e[c],d.sel!==g.sel?r.insertBefore(t,i(g,o),y.elm):(u(d,g,o),e[c]=void 0,r.insertBefore(t,d.elm,y.elm)),g=n[++f]));f<=v&&(h=null==n[v+1]?null:n[v+1].elm,a(t,h,n,f,v,o)),p<=m&&l(t,e,p,m)}(v,g,S,n):void 0!==S?(void 0!==t.text&&r.setTextContent(v,""),a(v,null,S,0,S.length-1,n)):void 0!==g?l(v,g,0,g.length-1):void 0!==t.text&&r.setTextContent(v,""):t.text!==e.text&&(void 0!==g&&l(v,g,0,g.length-1),r.setTextContent(v,e.text)),null===(y=null==_?void 0:_.postpatch)||void 0===y||y.call(_,t,e)}return function(t,e){let n,s,a;const c=[];for(n=0;n<o.pre.length;++n)o.pre[n]();for(!function(t,e){return t.isElement(e)}(r,t)?function(t,e){return t.isDocumentFragment(e)}(r,t)&&(t=Ue(void 0,{},[],void 0,t)):t=function(t){const e=t.id?"#"+t.id:"",n=t.getAttribute("class"),o=n?"."+n.split(" ").join("."):"";return Ue(r.tagName(t).toLowerCase()+e+o,{},[],void 0,t)}(t),Qe(t,e)?u(t,e,c):(s=t.elm,a=r.parentNode(s),i(e,c),null!==a&&(r.insertBefore(a,e.elm,r.nextSibling(s)),l(a,[t],0,0))),n=0;n<c.length;++n)c[n].data.hook.insert(c[n]);for(n=0;n<o.post.length;++n)o.post[n]();return e}}function rn(t,e){var n;const o=void 0!==e?e:Xe;let r;if(o.isElement(t)){const r=t.id?"#"+t.id:"",i=null===(n=t.getAttribute("class"))||void 0===n?void 0:n.match(/[^\t\r\n\f ]+/g),a=i?"."+i.join("."):"",c=o.tagName(t).toLowerCase()+r+a,l={},u={},d={},h=[];let p,f,m;const y=t.attributes,_=t.childNodes;for(f=0,m=y.length;f<m;f++)p=y[f].nodeName,p.startsWith("data-")?u[(s=p,s.slice(5).replace(/-([a-z])/g,((t,e)=>e.toUpperCase())))]=y[f].nodeValue||"":"id"!==p&&"class"!==p&&(l[p]=y[f].nodeValue);for(f=0,m=_.length;f<m;f++)h.push(rn(_[f],e));return Object.keys(l).length>0&&(d.attrs=l),Object.keys(u).length>0&&(d.dataset=u),!c.startsWith("svg")||3!==c.length&&"."!==c[3]&&"#"!==c[3]||He(d,h,c),Ue(c,d,h,void 0,t)}return o.isText(t)?(r=o.getTextContent(t),Ue(void 0,void 0,void 0,r,t)):o.isComment(t)?(r=o.getTextContent(t),Ue("!",{},[],r,t)):Ue("",{},[],void 0,t);var s}function sn(t,e){let n,o;const r=e.elm;let s=t.data.class,i=e.data.class;if((s||i)&&s!==i){for(o in s=s||{},i=i||{},s)s[o]&&!Object.prototype.hasOwnProperty.call(i,o)&&r.classList.remove(o);for(o in i)n=i[o],n!==s[o]&&r.classList[n?"add":"remove"](o)}}const an={create:sn,update:sn};function cn(t,e){let n,o,r;const s=e.elm;let i=t.data.props,a=e.data.props;if((i||a)&&i!==a)for(n in i=i||{},a=a||{},a)o=a[n],r=i[n],r===o||"value"===n&&s[n]===o||(s[n]=o)}const ln={create:cn,update:cn};function un(t,e){let n;const o=e.elm;let r=t.data.attrs,s=e.data.attrs;if((r||s)&&r!==s){for(n in r=r||{},s=s||{},s){const t=s[n];r[n]!==t&&(!0===t?o.setAttribute(n,""):!1===t?o.removeAttribute(n):120!==n.charCodeAt(0)?o.setAttribute(n,t):58===n.charCodeAt(3)?o.setAttributeNS("http://www.w3.org/XML/1998/namespace",n,t):58===n.charCodeAt(5)?109===n.charCodeAt(1)?o.setAttributeNS("http://www.w3.org/2000/xmlns/",n,t):o.setAttributeNS("http://www.w3.org/1999/xlink",n,t):o.setAttribute(n,t))}for(n in r)n in s||o.removeAttribute(n)}}const dn={create:un,update:un},hn=/[A-Z]/g;function pn(t,e){const n=e.elm;let o,r=t.data.dataset,s=e.data.dataset;if(!r&&!s)return;if(r===s)return;r=r||{},s=s||{};const i=n.dataset;for(o in r)o in s||(i?o in i&&delete i[o]:n.removeAttribute("data-"+o.replace(hn,"-$&").toLowerCase()));for(o in s)r[o]!==s[o]&&(i?i[o]=s[o]:n.setAttribute("data-"+o.replace(hn,"-$&").toLowerCase(),s[o]))}const fn={create:pn,update:pn};function mn(t,e){e.elm=t.elm,t.data.fn=e.data.fn,t.data.args=e.data.args,t.data.isolate=e.data.isolate,e.data=t.data,e.children=t.children,e.text=t.text,e.elm=t.elm}function yn(t){const e=t.data;mn(e.fn.apply(void 0,e.args),t)}function _n(t,e){const n=t.data,o=e.data;let r;const s=n.args,i=o.args;for(n.fn===o.fn&&s.length===i.length||mn(o.fn.apply(void 0,i),e),r=0;r<i.length;++r)if(s[r]!==i[r])return void mn(o.fn.apply(void 0,i),e);mn(t,e)}function vn(t,e,n=!1,o=!1,r=!1){let s=null;return re.create({start:function(i){s=o?function(t){Sn(t,o),i.next(t)}:function(t){i.next(t)},t.addEventListener(e,s,{capture:n,passive:r})},stop:function(){t.removeEventListener(e,s,n),s=null}})}function gn(t,e){const n=Object.keys(t),o=n.length;for(let r=0;r<o;r++){const o=n[r];if("object"==typeof t[o]&&null!==t[o]&&"object"==typeof e[o]&&null!==e[o]){if(!gn(t[o],e[o]))return!1}else if(t[o]!==e[o])return!1}return!0}function Sn(t,e){if(e)if("boolean"==typeof e)t.preventDefault();else if("function"==typeof e)e(t)&&t.preventDefault();else{if("object"!=typeof e)throw new Error("preventDefault has to be either a boolean, predicate function or object");gn(e,t)&&t.preventDefault()}}function bn(t){return t.value=function(e){return bn(t.map((t=>{const n=t?.target?.value;return e?e(n):n})))},t.checked=function(e){return bn(t.map((t=>{const n=!!t?.target?.checked;return e?e(n):n})))},t.data=function(e,n){const o=String(e).replace(/-([a-z])/g,((t,e)=>e.toUpperCase())),r=`[data-${o.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}]`;return bn(t.map((t=>{const e=t?.target,s="function"==typeof e?.closest&&e.closest(r)||e,i=s?.dataset?.[o];return n?n(i):i})))},t.target=function(e){return bn(t.map((t=>{const n=t?.target;return e?e(n):n})))},t.key=function(e){return bn(t.map((t=>{const n=t?.key;return e?e(n):n})))},t}class wn{constructor(t,e){this._name=t,this._selector=e||null}select(t){return new wn(this._name,t)}elements(){if(this._selector){const t=ue(ce.of(Array.from(document.querySelectorAll(this._selector))));return t._isCycleSource=this._name,t}const t=ue(ce.of([document]));return t._isCycleSource=this._name,t}element(){if(this._selector){const t=ue(ce.of(document.querySelector(this._selector)));return t._isCycleSource=this._name,t}const t=ue(ce.of(document));return t._isCycleSource=this._name,t}events(t,e={},n){let o;if(o=vn(document,t,e.useCapture,e.preventDefault),this._selector){const t=this._selector;o=o.filter((e=>{const n=e.target;return n instanceof Element&&(n.matches(t)||null!==n.closest(t))}))}const r=bn(ue(o));return r._isCycleSource=this._name,r}}class An{constructor(t){this._name=t}select(t){return this}elements(){const t=ue(ce.of([document.body]));return t._isCycleSource=this._name,t}element(){const t=ue(ce.of(document.body));return t._isCycleSource=this._name,t}events(t,e={},n){let o;o=vn(document.body,t,e.useCapture,e.preventDefault);const r=ue(o);return r._isCycleSource=this._name,r}}function En(t){return t.length>1&&("."===t[0]||"#"===t[0])}function Nn(t){if("string"!=typeof t&&(e=t,!("object"==typeof HTMLElement?e instanceof HTMLElement||e instanceof DocumentFragment:e&&"object"==typeof e&&null!==e&&(1===e.nodeType||11===e.nodeType)&&"string"==typeof e.nodeName)))throw new Error("Given container is not a DOM element neither a selector string.");var e}function On(t){let e="";for(let n=t.length-1;n>=0&&"selector"===t[n].type;n--)e=t[n].scope+" "+e;return e.trim()}function Cn(t,e){if(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n].type!==e[n].type||t[n].scope!==e[n].scope)return!1;return!0}class Tn{constructor(t,e){this.namespace=t,this.isolateModule=e,this._namespace=t.filter((t=>"selector"!==t.type))}isDirectlyInScope(t){const e=this.isolateModule.getNamespace(t);if(!e)return!1;if(this._namespace.length>e.length||!Cn(this._namespace,e.slice(0,this._namespace.length)))return!1;for(let t=this._namespace.length;t<e.length;t++)if("total"===e[t].type)return!1;return!0}}class kn{constructor(t,e){this.namespace=t,this.isolateModule=e}call(){const t=this.namespace,e=On(t),n=new Tn(t,this.isolateModule),o=this.isolateModule.getElement(t.filter((t=>"selector"!==t.type)));return void 0===o?[]:""===e?[o]:(r=o.querySelectorAll(e),Array.prototype.slice.call(r)).filter(n.isDirectlyInScope,n).concat(o.matches(e)?[o]:[]);var r}}function $n(t){return{type:En(t)?"sibling":"total",scope:t}}const xn="https://sygnal.js.org",Ln={SYG101:"warn",SYG102:"info",SYG103:"info",SYG104:"warn",SYG105:"info",SYG106:"warn",SYG110:"warn",SYG111:"warn",SYG201:"warn",SYG202:"warn",SYG301:"error",SYG401:"warn",SYG900:"warn",SYG206:"error",SYG207:"warn",SYG208:"warn",SYG209:"error",SYG210:"warn",SYG211:"error",SYG212:"error",SYG213:"warn",SYG214:"error",SYG215:"error",SYG216:"error",SYG217:"warn",SYG218:"error",SYG219:"warn",SYG220:"warn",SYG402:"error",SYG403:"error",SYG404:"error",SYG405:"warn",SYG406:"error",SYG407:"error",SYG408:"error",SYG409:"warn",SYG410:"error",SYG411:"error",SYG412:"error",SYG413:"error",SYG414:"error",SYG415:"error",SYG416:"error",SYG417:"warn",SYG418:"error",SYG419:"error",SYG420:"error",SYG601:"error",SYG602:"error",SYG603:"error",SYG604:"error",SYG605:"error",SYG606:"error",SYG607:"error",SYG901:"error",SYG902:"error",SYG903:"error"};function Dn(t){return`${xn}/reference/errors#${t.toLowerCase()}`}class Gn extends Error{constructor(t){super(t.text),this.diagnostic=t}}let jn,In="off",Mn=!1,Pn=new Set,Yn=[],Rn=[],Fn=[];function Bn(){return In=jn||(!0===globalThis.__SYGNAL_DEV__?"warn":"off"),Mn="off"!==In,In}function Un(t={}){"mode"in t&&(jn=t.mode),t.ignore&&(Pn=new Set(t.ignore)),Bn()}function Vn(){return In}const Wn=t=>(t&&"object"==typeof t?t.name:t)||void 0,Hn=t=>/[.!?]$/.test(t)?t:t+".";function zn(t,e){const n=Wn(e.component);return`[Sygnal ${t}] ${n?n+": ":""}${Hn(e.message)}`+(e.fix?" "+Hn(e.fix):"")+" "+Dn(t)}function qn(t,e){if(!Mn||Pn.has(t))return;const n=e.severity||Ln[t]||"warn",o={code:t,severity:n,component:Wn(e.component),message:e.message,fix:e.fix,data:e.data,docsUrl:Dn(t),get text(){return zn(t,this)},timestamp:Date.now()};if(Yn.push(o)>500&&Yn.shift(),Rn.forEach((t=>{try{t(o)}catch(t){}})),"info"!==n){if("error"===In)throw new Gn(o);"warn"===In&&console[n](o.text)}return o}function Jn(){return Yn.slice()}function Zn(t){return Rn=[...Rn,t],()=>{Rn=Rn.filter((e=>e!==t))}}function Xn(t){return Fn=[...Fn,t],()=>{Fn=Fn.filter((e=>e!==t))}}let Kn=t=>{const e=()=>{throw t};"function"==typeof queueMicrotask?queueMicrotask(e):setTimeout(e)};const Qn=t=>(e,...n)=>{if(Mn)for(const o of Fn)try{o[t]?.(e,...n)}catch(n){try{if(n instanceof Gn)throw n;qn("SYG900",{component:e,message:`Diagnostics check '${o.id}' threw in ${t}: ${n?.message}`,data:{check:o.id,hook:t,error:n}})}catch(t){Kn(t)}}},to=Qn("onIntent"),eo=Qn("onModel"),no=Qn("onRender"),oo=Qn("onReducer"),ro=Qn("onDispose"),so=Qn("onSelector"),io=Qn("onBusEmit"),ao=Qn("onBusSelect");globalThis.__SYGNAL_DIAGNOSTICS__={registerCheck:Xn,report:qn},Bn();class co{constructor(t,e,n=[],o,r,s){var i;this._rootElement$=t,this._sanitation$=e,this._namespace=n,this._isolateModule=o,this._eventDelegator=r,this._name=s,this.isolateSource=(t,e)=>new co(t._rootElement$,t._sanitation$,t._namespace.concat($n(e)),t._isolateModule,t._eventDelegator,t._name),this.isolateSink=(i=this._namespace,(t,e)=>":root"===e?t:t.map((t=>{if(!t)return t;const n=$n(e),o={...t,data:{...t.data,isolate:t.data&&Array.isArray(t.data.isolate)?t.data.isolate:i.concat([n])}};return{...o,key:void 0!==o.key?o.key:JSON.stringify(o.data.isolate)}})))}_elements(){if(0===this._namespace.length)return this._rootElement$.map((t=>[t]));{const t=new kn(this._namespace,this._isolateModule);return this._rootElement$.map((()=>t.call()))}}elements(){const t=ue(this._elements().remember());return t._isCycleSource=this._name,t}element(){const t=ue(this._elements().filter((t=>t.length>0)).map((t=>t[0])).remember());return t._isCycleSource=this._name,t}get namespace(){return this._namespace}select(t){if("string"!=typeof t)throw new Error("DOM driver's select() expects the argument to be a string as a CSS selector");if("document"===t)return new wn(this._name);if("body"===t)return new An(this._name);":root"!==t&&so(this,t.trim());const e=":root"===t?[]:this._namespace.concat({type:"selector",scope:t.trim()});return new co(this._rootElement$,this._sanitation$,e,this._isolateModule,this._eventDelegator,this._name)}events(t,e={},n){if("string"!=typeof t)throw new Error("DOM driver's events() expects argument to be a string representing the event type to listen for.");const o=bn(ue(this._eventDelegator.addEventListener(t,this._namespace,e,n)));return o._isCycleSource=this._name,o}dispose(){this._sanitation$.shamefullySendNext(null)}}function lo(t){if(!t.sel)return{tagName:"",id:"",className:""};const e=t.sel,n=e.indexOf("#"),o=e.indexOf(".",n),r=n>0?n:e.length,s=o>0?o:e.length;return{tagName:-1!==n||-1!==o?e.slice(0,Math.min(r,s)):e,id:r<s?e.slice(r+1,s):void 0,className:o>0?e.slice(s+1).replace(/\./g," "):void 0}}class uo{constructor(t){this.rootElement=t}call(t){if(11===this.rootElement.nodeType)return this.wrapDocFrag(null===t?[]:[t]);if(null===t)return this.wrap([]);const{tagName:e,id:n}=lo(t),o=function(t){let{className:e=""}=lo(t);if(!t.data)return e;const{class:n,props:o}=t.data;n&&(e+=` ${Object.keys(n).filter((t=>n[t])).join(" ")}`);return o&&o.className&&(e+=` ${o.className}`),e&&e.trim()}(t),r=(t.data||{}).props||{},{id:s=n}=r;return"string"==typeof s&&s.toUpperCase()===this.rootElement.id.toUpperCase()&&e.toUpperCase()===this.rootElement.tagName.toUpperCase()&&o.toUpperCase()===this.rootElement.className.toUpperCase()?t:this.wrap([t])}wrapDocFrag(t){return Ue("",{isolate:[]},t,void 0,this.rootElement)}wrap(t){const{tagName:e,id:n,className:o}=this.rootElement,r=n?`#${n}`:"",s=o?`.${o.split(" ").join(".")}`:"",i=ze(`${e.toLowerCase()}${r}${s}`,{},t);return i.data=i.data||{},i.data.isolate=i.data.isolate||[],i}}const ho="undefined"!=typeof window&&"function"==typeof window.requestAnimationFrame&&window.requestAnimationFrame.bind(window)||setTimeout,po=t=>{ho((()=>{ho(t)}))};let fo=!1;function mo(t,e,n){po((()=>{t[e]=n}))}function yo(t,e){let n,o;const r=e.elm;let s=t.data.style,i=e.data.style;if(!s&&!i)return;if(s===i)return;s=s||{},i=i||{};const a="delayed"in s;for(o in s)o in i||("-"===o[0]&&"-"===o[1]?r.style.removeProperty(o):r.style[o]="");for(o in i)if(n=i[o],"delayed"===o&&i.delayed)for(const t in i.delayed)n=i.delayed[t],a&&n===s.delayed[t]||mo(r.style,t,n);else"remove"!==o&&n!==s[o]&&("-"===o[0]&&"-"===o[1]?r.style.setProperty(o,n):r.style[o]=n)}const _o={pre:function(){fo=!1},create:yo,update:yo,destroy:function(t){let e,n;const o=t.elm,r=t.data.style;if(r&&(e=r.destroy))for(n in e)o.style[n]=e[n]},remove:function(t,e){const n=t.data.style;if(!n||!n.remove)return void e();let o;fo||(t.elm.offsetLeft,fo=!0);const r=t.elm;let s=0;const i=n.remove;let a=0;const c=[];for(o in i)c.push(o),r.style[o]=i[o];const l=getComputedStyle(r)["transition-property"].split(", ");for(;s<l.length;++s)-1!==c.indexOf(l[s])&&a++;r.addEventListener("transitionend",(t=>{t.target===r&&--a,0===a&&e()}))}};let vo=[];const go={create:function(t,e){const n=e.elm;n&&"SELECT"===n.tagName&&void 0!==e.data?.props?.value&&vo.push({elm:n,value:e.data.props.value})},post:function(){for(let t=0;t<vo.length;t++){const{elm:e,value:n}=vo[t];e.value=n}vo=[]}};const So={update:function(t,e){const n=e.data?.props,o=e.elm;if(!n||!o||!/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)||"file"==o.type)return;const r=t.data?.props||{},{value:s,checked:i}=n;s===r.value&&null!=s&&o.value!==String(s)&&(o.value=String(s)),i===r.checked&&null!=i&&o.checked!==!!i&&(o.checked=!!i)}};function bo(t){const e=[],n=t.data?.class;if(n&&"object"==typeof n)for(const t in n)n[t]&&e.push(t);return e}function wo(t){const e=t.sel||"",n=e.indexOf("#"),o=e.indexOf(".",n);return(o>0?e.slice(o+1).split("."):[]).concat(bo(t))}function Ao(t,e){for(const n of e)n&&t.classList.add(n)}const Eo=t=>null!=t&&!1!==t;function No(t,e){const n=e.elm;if(!n||!n.classList)return;const o=e.data?.props,r=t.data?.props,s=!!o&&"className"in o,i=s?o.className:void 0;if(Eo(i))return void(r&&r.className===i||Ao(n,bo(e)));if(s)return void(r&&r.className===i||(n.className=wo(e).join(" "),""===n.className&&n.removeAttribute("class")));const a=r?r.className:void 0;if(!Eo(a))return;const c=wo(e);for(const t of(t=>"string"==typeof t?t.split(/\s+/).filter(Boolean):[])(a))-1===c.indexOf(t)&&n.classList.remove(t);Ao(n,c),""===n.getAttribute("class")&&n.removeAttribute("class")}const Oo={create:(t,e)=>No(t,e),update:No},Co=[_o,an,ln,Oo,dn,fn,go,So];class To{constructor(t){this.mapper=t,this.tree=[void 0,{}]}set(t,e,n){let o=this.tree;const r=void 0!==n?n:t.length;for(let e=0;e<r;e++){const n=this.mapper(t[e]);let r=o[1][n];r||(r=[void 0,{}],o[1][n]=r),o=r}o[0]=e}getDefault(t,e,n){return this.get(t,e,n)}get(t,e,n){let o=this.tree;const r=void 0!==n?n:t.length;for(let n=0;n<r;n++){const r=this.mapper(t[n]);let s=o[1][r];if(!s){if(!e)return;s=[void 0,{}],o[1][r]=s}o=s}return e&&!o[0]&&(o[0]=e()),o[0]}delete(t){let e=this.tree;for(let n=0;n<t.length-1;n++){const o=e[1][this.mapper(t[n])];if(!o)return;e=o}delete e[1][this.mapper(t[t.length-1])]}}class ko{constructor(){this.namespaceTree=new To((t=>t.scope)),this.namespaceByElement=new Map,this.vnodesBeingRemoved=[]}setEventDelegator(t){this.eventDelegator=t}insertElement(t,e){this.namespaceByElement.set(e,t),this.namespaceTree.set(t,e)}removeElement(t){this.namespaceByElement.delete(t);const e=this.getNamespace(t);e&&this.namespaceTree.delete(e)}getElement(t,e){return this.namespaceTree.get(t,void 0,e)}getRootElement(t){if(this.namespaceByElement.has(t))return t;let e=t;for(;!this.namespaceByElement.has(e);){if(e=e.parentNode,!e)return;if("HTML"===e.tagName)throw new Error("No root element found, this should not happen at all")}return e}getNamespace(t){const e=this.getRootElement(t);if(e)return this.namespaceByElement.get(e)}createModule(){const t=this;return{create(e,n){const{elm:o,data:r={}}=n,s=r.isolate;Array.isArray(s)&&t.insertElement(s,o)},update(e,n){const{elm:o,data:r={}}=e,{elm:s,data:i={}}=n,a=r.isolate,c=i.isolate;Cn(a,c)||Array.isArray(a)&&t.removeElement(o),Array.isArray(c)&&t.insertElement(c,s)},destroy(e){t.vnodesBeingRemoved.push(e)},remove(e,n){t.vnodesBeingRemoved.push(e),n()},post(){const e=t.vnodesBeingRemoved;for(let n=e.length-1;n>=0;n--){const o=e[n],r=void 0!==o.data?o.data.isolation:void 0;void 0!==r&&t.removeElement(r),t.eventDelegator.removeElement(o.elm,r)}t.vnodesBeingRemoved=[]}}}}class $o{constructor(){this.arr=[],this.prios=[]}add(t,e){for(let n=0;n<this.arr.length;n++)if(this.prios[n]<e)return this.arr.splice(n,0,t),void this.prios.splice(n,0,e);this.arr.push(t),this.prios.push(e)}forEach(t){for(let e=0;e<this.arr.length;e++)t(this.arr[e],e,this.arr)}delete(t){for(let e=0;e<this.arr.length;e++)if(this.arr[e]===t)return this.arr.splice(e,1),void this.prios.splice(e,1)}}const xo=["blur","focus","mouseenter","mouseleave","pointerenter","pointerleave","gotpointercapture","lostpointercapture","canplay","canplaythrough","durationchange","emptied","ended","loadeddata","loadedmetadata","pause","play","playing","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","load","unload","invalid","reset","submit","formdata","toggle","animationstart","animationend","animationiteration","transitionrun","transitionstart","transitionend","scroll","scrollend"];class Lo{constructor(t,e){this.rootElement$=t,this.isolateModule=e,this.virtualListeners=new To((t=>t.scope)),this.nonBubblingListenersToAdd=new Set,this.virtualNonBubblingListener=[],this.isolateModule.setEventDelegator(this),this.domListeners=new Map,this.domListenersToAdd=new Map,this.nonBubblingListeners=new Map,t.addListener({next:t=>{this.origin!==t&&(this.origin=t,this.resetEventListeners(),this.domListenersToAdd.forEach(((t,e)=>this.setupDOMListener(e,t))),this.domListenersToAdd.clear()),this.nonBubblingListenersToAdd.forEach((t=>{this.setupNonBubblingListener(t)}))}})}addEventListener(t,e,n,o){const r=ce.never();let s;const i=new Tn(e,this.isolateModule);if(void 0===o?-1===xo.indexOf(t):o)return this.domListeners.has(t)||this.setupDOMListener(t,!!n.passive),s=this.insertListener(r,i,t,n),r;{const o=[];this.nonBubblingListenersToAdd.forEach((t=>o.push(t)));let a,c=0;const l=o.length,u=n=>{const[o,r,s,i]=n;return t===r&&Cn(s.namespace,e)};for(;!a&&c<l;){const t=o[c];a=u(t)?t:a,c++}let d,h=a;if(h){const[t]=h;d=t}else{const o=new kn(e,this.isolateModule);s=this.insertListener(r,i,t,n),h=[r,t,o,s],d=r,this.nonBubblingListenersToAdd.add(h),this.setupNonBubblingListener(h)}const p=this;let f=null;return ce.create({start:t=>{f=d.subscribe(t)},stop:()=>{const[t,e,n,o]=h;n.call().forEach((function(t){const n=t.subs;n&&n[e]&&(n[e].unsubscribe(),delete n[e])})),p.nonBubblingListenersToAdd.delete(h),f.unsubscribe()}})}}removeElement(t,e){void 0!==e&&this.virtualListeners.delete(e);const n=[];this.nonBubblingListeners.forEach(((e,o)=>{if(e.has(t)){n.push([o,t]);const e=t.subs;e&&Object.keys(e).forEach((t=>{e[t].unsubscribe()}))}}));for(let t=0;t<n.length;t++){const e=this.nonBubblingListeners.get(n[t][0]);e&&(e.delete(n[t][1]),0===e.size?this.nonBubblingListeners.delete(n[t][0]):this.nonBubblingListeners.set(n[t][0],e))}}insertListener(t,e,n,o){const r=[],s=e._namespace;let i=s.length;do{r.push(this.getVirtualListeners(n,s,!0,i)),i--}while(i>=0&&"total"!==s[i].type);const a={...o,scopeChecker:e,subject:t,bubbles:!!o.bubbles,useCapture:!!o.useCapture,passive:!!o.passive};for(let t=0;t<r.length;t++)r[t].add(a,s.length);return a}getVirtualListeners(t,e,n=!1,o){let r=void 0!==o?o:e.length;if(!n)for(let t=r-1;t>=0;t--){if("total"===e[t].type){r=t+1;break}r=t}const s=this.virtualListeners.getDefault(e,(()=>new Map),r);return s.has(t)||s.set(t,new $o),s.get(t)}setupDOMListener(t,e){if(this.origin){const n=vn(this.origin,t,!1,!1,e).subscribe({next:n=>this.onEvent(t,n,e),error:()=>{},complete:()=>{}});this.domListeners.set(t,{sub:n,passive:e})}else this.domListenersToAdd.set(t,e)}setupNonBubblingListener(t){const[e,n,o,r]=t;if(!this.origin)return;const s=o.call();if(s.length){const t=this;s.forEach((e=>{const o=e.subs;if(!o||!o[n]){const s=vn(e,n,!1,!1,r.passive).subscribe({next:e=>t.onEvent(n,e,!!r.passive,!1),error:()=>{},complete:()=>{}});t.nonBubblingListeners.has(n)||t.nonBubblingListeners.set(n,new Map);const i=t.nonBubblingListeners.get(n);if(!i)return;i.set(e,{sub:s,destination:r}),e.subs={...o,[n]:s}}}))}}resetEventListeners(){const t=this.domListeners.entries();let e=t.next();for(;!e.done;){const[n,{sub:o,passive:r}]=e.value;o.unsubscribe(),this.setupDOMListener(n,r),e=t.next()}}putNonBubblingListener(t,e,n,o){const r=this.nonBubblingListeners.get(t);if(!r)return;const s=r.get(e);s&&s.destination.passive===o&&s.destination.useCapture===n&&(this.virtualNonBubblingListener[0]=s.destination)}onEvent(t,e,n,o=!0){const r=this.patchEvent(e),s=this.isolateModule.getRootElement(e.target);if(o){const o=this.isolateModule.getNamespace(e.target);if(!o)return;const i=this.getVirtualListeners(t,o);this.bubble(t,e.target,s,r,i,o,o.length-1,!0,n),this.bubble(t,e.target,s,r,i,o,o.length-1,!1,n)}else this.putNonBubblingListener(t,e.target,!0,n),this.doBubbleStep(t,e.target,s,r,this.virtualNonBubblingListener,!0,n),this.putNonBubblingListener(t,e.target,!1,n),this.doBubbleStep(t,e.target,s,r,this.virtualNonBubblingListener,!1,n),e.stopPropagation()}bubble(t,e,n,o,r,s,i,a,c){a||o.propagationHasBeenStopped||this.doBubbleStep(t,e,n,o,r,a,c);let l=n,u=i;if(e===n){if(!(i>=0&&"sibling"===s[i].type))return;l=this.isolateModule.getElement(s,i),u--}e.parentNode&&l&&this.bubble(t,e.parentNode,l,o,r,s,u,a,c),a&&!o.propagationHasBeenStopped&&this.doBubbleStep(t,e,n,o,r,a,c)}doBubbleStep(t,e,n,o,r,s,i){n&&(this.mutateEventCurrentTarget(o,e),r.forEach((t=>{if(t.passive===i&&t.useCapture===s){const r=On(t.scopeChecker.namespace);!o.propagationHasBeenStopped&&t.scopeChecker.isDirectlyInScope(e)&&(""!==r&&e.matches(r)||""===r&&e===n)&&(Sn(o,t.preventDefault),t.subject.shamefullySendNext(o))}})))}patchEvent(t){const e=t;e.propagationHasBeenStopped=!1;const n=e.stopPropagation;return e.stopPropagation=function(){n.call(this),this.propagationHasBeenStopped=!0},e}mutateEventCurrentTarget(t,e){try{Object.defineProperty(t,"currentTarget",{value:e,configurable:!0})}catch(t){}t.ownerTarget=e}}function Do(t){return ce.merge(t,ce.never())}function Go(t){return t.elm}function jo(t){(console.error||console.log)(t)}function Io(t,e={}){Nn(t);const n=e.modules||Co;!function(t){if(!Array.isArray(t))throw new Error("Optional modules option must be an array for snabbdom modules")}(n);const o=new ko,r=e&&e.snabbdomOptions||void 0,s=on([o.createModule()].concat(n),void 0,r),i=ce.create({start(t){"loading"===document.readyState?document.addEventListener("readystatechange",(()=>{const e=document.readyState;"interactive"!==e&&"complete"!==e||(t.next(null),t.complete())})):(t.next(null),t.complete())},stop(){}});let a,c;const l=ce.create({start(t){c=new MutationObserver((()=>t.next(null)))},stop(){c.disconnect()}});return function(n,r="DOM"){!function(t){if(!t||"function"!=typeof t.addListener||"function"!=typeof t.fold)throw new Error("The DOM driver function expects as input a Stream of virtual DOM elements")}(n);const u=ce.create(),d=i.map((()=>{const e=function(t){const e="string"==typeof t?document.querySelector(t):t;if("string"==typeof t&&null===e)throw new Error(`Cannot render into unknown element \`${t}\``);return e}(t)||document.body;return a=new uo(e),e})),h=n.remember();h.addListener({}),l.addListener({});const p=d.map((t=>ce.merge(h.endWhen(u),u).map((t=>a.call(t))).startWith(function(t){return t.data=t.data||{},t.data.isolate=[],t}(rn(t))).fold(s,rn(t)).drop(1).map(Go).startWith(t).map((t=>(c.observe(t,{childList:!0,attributes:!0,characterData:!0,subtree:!0,attributeOldValue:!0,characterDataOldValue:!0}),t))).compose(Do))).flatten(),f=me(i,l).endWhen(u).compose(Te(p)).map((t=>t[1])).remember();f.addListener({error:e.reportSnabbdomError||jo});const m=new Lo(f,o);return new co(f,u,[],o,m,r)}}const Mo="___";class Po{constructor(t,e,n=[],o){this._mockConfig=t,this._hub=e,this._path=n,this._onEvents=o,t.elements?this._elements=t.elements:this._elements=ue(ce.empty())}elements(){const t=this._elements;return t._isCycleSource="MockedDOM",t}element(){const t=ue(this.elements().filter((t=>t.length>0)).map((t=>t[0])).remember());return t._isCycleSource="MockedDOM",t}events(t,e,n){const o=this._mockConfig[t],{_hub:r,_path:s,_onEvents:i}=this;let a;if(i&&i(s,t),r){const e=r.filter((e=>e.type===t&&e.match(s))).map((t=>t.event));let n;a=i?ce.create({start:o=>{e.addListener(n={next:t=>o.next(t),error:t=>o.error(t),complete:()=>o.complete()}),i(s,t,!0)},stop:()=>{e.removeListener(n),i(s,t,!1)}}):e}const c=bn(ue(a?ce.merge(o?ce.fromObservable(o):ce.empty(),a):o||ce.empty()));return c._isCycleSource="MockedDOM",c}select(t){const e=this._mockConfig[t]||{};return new Po(e,this._hub,this._path.concat(t),this._onEvents)}isolateSource(t,e){return t.select("."+Mo+e)}isolateSink(t,e){return ue(ce.fromObservable(t).map((t=>t?(t.sel&&-1!==t.sel.indexOf(Mo+e)||(t.sel+=`.${Mo}${e}`),t):t)))}}function Yo(t,e,n){return new Po(t,e,[],n)}const Ro=t=>(e,n,o,r,...s)=>{const i={component:n,message:o,fix:r,severity:t,data:s[0]},a=Vn();if("off"!==a)try{const n=qn(e,i);n&&"collect"===a&&"error"===t?console.error(n.text,...s):n&&"warn"===a&&s.length&&console[t](...s)}catch(t){setTimeout((()=>{throw t}))}else console[t](zn(e,i),...s)},Fo=Ro("warn"),Bo=Ro("error");function Uo(t,e,n,o){const r=new Error(zn(t,{component:e,message:n,fix:o}));throw r.code=t,r}let Vo=0;function Wo(t,e,n={}){"function"!=typeof t&&Uo("SYG411","collection","first argument (component) must be a function","Pass a component function");const{combineList:o=["DOM"],globalList:r=["EVENTS"],stateSourceName:s="STATE",domSourceName:i="DOM",container:a="div",containerClass:c}=n;return n=>{const l="sygnal-collection-"+Vo++,u={item:t,itemKey:(t,e)=>void 0!==t.id?t.id:e,itemScope:t=>`${l}-${t}`,channel:s,collectSinks:t=>Object.entries(n).reduce(((e,[n])=>{if(o.includes(n)){const o=t.pickCombine(n);n===i&&a?e[i]=o.map((t=>({sel:a,data:c?{props:{className:c}}:{},children:t,key:l,text:void 0,elm:void 0}))):e[n]=o}else e[n]=t.pickMerge(n);return e}),{})},d={[s]:e};return r.forEach((t=>d[t]=null)),o.forEach((t=>d[t]=null)),function(t,e,n){return pe(function(t){return function(e){const n=t.channel||"state",o=t.itemKey,r=t.itemScope||Ye,s=ce.fromObservable(e[n].stream),i=new Map;let a=!1;const c=s.fold(((s,c)=>{if(a)return s;if(Array.isArray(c)){const s=Array(c.length),a=new Set;for(let l=0,u=c.length;l<u;++l){const u=`${o?o(c[l],l):l}`;if(a.add(u),i.has(u))s[l]=i.get(u);else{const a=o?Re(o,u):`${l}`,d=r(u),h="string"==typeof d?{"*":d,[n]:a}:{...d,[n]:a},p=pe(t.itemFactory?t.itemFactory(c[l],l):t.item,h)(e);i.set(u,p),s[l]=p}s[l]._key=u}return i.forEach(((t,e)=>{a.has(e)||(t&&"function"==typeof t.__dispose&&t.__dispose(),i.delete(e))})),a.clear(),{dict:i,arr:s}}{i.forEach((t=>{t&&"function"==typeof t.__dispose&&t.__dispose()})),i.clear();const s=`${o?o(c,0):"this"}`,a=Fe,l=r(s),u="string"==typeof l?{"*":l,[n]:a}:{...l,[n]:a},d=pe(t.itemFactory?t.itemFactory(c,0):t.item,u)(e);return i.set(s,d),{dict:i,arr:[d]}}}),{dict:i,arr:[]}),l=t.collectSinks(new Pe(c));return l.__dispose=()=>{a=!0,i.forEach((t=>t.__dispose?.())),i.clear()},l}}(t),e)(n)}(u,d,n)}}const Ho=t=>{const{children:e,...n}=t;return ze("collection",{props:n},e)};Ho.label="collection",Ho.preventInstantiation=!0;const zo=function(t){const e=function(t){return t&&t.default&&t.default.default&&"function"==typeof t.default.default?t.default.default:t&&t.default?t.default:t}(t);return e&&e.default&&"function"==typeof e.default.create?e.default:e}(le),qo=re||ce&&ce.Stream||zo&&zo.Stream,Jo="Pass a stream, a state key string, or a state => name function";function Zo(t,e,n,o={}){const{switched:r=["DOM"],stateSourceName:s="STATE"}=o,i=typeof e;if(e||Uo("SYG419","switchable","Missing 'name$' parameter",Jo),"string"===i||"function"===i||e instanceof qo||Uo("SYG419","switchable",`Invalid 'name$' parameter: got ${i}`,Jo),e instanceof qo){const o=e.compose(Ee()).startWith(n).remember();return e=>Xo(t,e,o,r)}{const o="function"===i&&e||(t=>t[e]);return e=>{const i=e&&("string"==typeof s&&e[s]||e.STATE||e.state).stream;i instanceof qo||Uo("SYG607","switchable",`State source '${s}' not found`,"Pass the state source in sources, or set stateSourceName");const a=i.map(o).filter((t=>"string"==typeof t)).compose(Ee()).startWith(n).remember();return Xo(t,e,a,r,s)}}}function Xo(t,e,n,o=["DOM"],r="STATE"){"string"==typeof o&&(o=[o]);const s=Object.entries(t).map((([t,o])=>{if(e[r]){const s=e[r].stream,i=zo.combine(n,s).filter((([e])=>e==t)).map((([,t])=>t)).remember(),a=new e[r].constructor(i,e[r]._name);return[t,o({...e,state:a})]}return[t,o(e)]})),i=Object.keys(e).reduce(((t,e)=>{if(o.includes(e))t[e]=n.map((t=>{const n=s.find((([e])=>e===t));return n&&n[1][e]||zo.never()})).flatten().remember().startWith(void 0);else{const n=s.filter((([,t])=>void 0!==t[e])).map((([,t])=>t[e]));t[e]=zo.merge(...n)}return t}),{});return i.__dispose=()=>s.forEach((([,t])=>t.__dispose?.())),i}const Ko=t=>{const{children:e,...n}=t;return ze("switchable",{props:n},e)};function Qo(t){return{select:e=>t._stream.filter((t=>t.type===e)).map((t=>t.data))}}Ko.label="switchable",Ko.preventInstantiation=!0;const tr="undefined"!=typeof window&&window||"undefined"!=typeof process&&process.env||{},er="BOOTSTRAP",nr="INITIALIZE",or="DISPOSE",rr="PARENT",sr="READY",ir="EFFECT",ar="See the attached error",cr=Symbol("sygnal.stateSnapshot");let lr=0,ur=0;const dr=Symbol.for("sygnal.ABORT");function hr(t){return t===dr||"symbol"==typeof t&&"sygnal.ABORT"===t.description}function pr(t,e){return"function"==typeof e?{fn:e,deps:null}:Array.isArray(e)&&2===e.length&&Array.isArray(e[0])&&"function"==typeof e[1]?{fn:e[1],deps:e[0]}:void Uo("SYG206",void 0,`Invalid calculated field '${t}'`,"Use fn or [deps, fn]")}function fr(t){const{name:e,sources:n,isolateOpts:o,stateSourceName:r="STATE"}=t;let s;n&&!Tr(n)&&Uo("SYG601",e,"Invalid sources","Pass sources from run()"),s="string"==typeof o?{[r]:o}:!0===o?{}:o;const i=void 0===n;let a;if(Tr(s)){const e=e=>{const n={...t,sources:e},o=new mr(n);return o.sinks.__dispose=()=>o.dispose(),o.sinks};a=i?pe(e,s):pe(e,s)(n)}else if(i)a=e=>{const n=new mr({...t,sources:e});return n.sinks.__dispose=()=>n.dispose(),n.sinks};else{const e=new mr(t);e.sinks.__dispose=()=>e.dispose(),a=e.sinks}return a.componentName=e,a.isSygnalComponent=!0,a}class mr{constructor({name:t="NO NAME",sources:e,intent:n,model:o,hmrActions:r,context:s,response:i,view:a,peers:c={},components:l={},initialState:u,calculated:d,storeCalculatedInState:h=!0,DOMSourceName:p="DOM",stateSourceName:f="STATE",requestSourceName:m="HTTP",isolatedState:y=!1,onError:_,debug:v=!1}){if(e&&Tr(e)||Uo("SYG601",t,"Missing or invalid sources","Pass sources from run()"),this._componentNumber=lr++,this.name=t,this.sources=e,this.intent=n,this.model=o,this.hmrActions=r,this.context=s,this.response=i,this.view=a,this.peers=c,this.components=l,this.initialState=u,this.calculated=d,this.storeCalculatedInState=h,this.DOMSourceName=p,this.stateSourceName=f,this.requestSourceName=m,this.sourceNames=Object.keys(e),this.onError=_,this.isolatedState=y,this._debug=v,this.calculated&&this.initialState&&Tr(this.calculated)&&Tr(this.initialState))for(const e of Object.keys(this.calculated))e in this.initialState&&Fo("SYG207",t,`Calculated field '${e}' overwrites the initialState key of the same name`,"Rename one of them");if(this.calculated&&Tr(this.calculated)){const e=Object.entries(this.calculated);this._calculatedNormalized={};for(const[t,n]of e)this._calculatedNormalized[t]=pr(t,n);this._calculatedFieldNames=new Set(Object.keys(this._calculatedNormalized));for(const[e,{deps:n}]of Object.entries(this._calculatedNormalized))if(null!==n)for(const o of n)this._calculatedFieldNames.has(o)||!this.initialState||o in this.initialState||Fo("SYG208",t,`Calculated field '${e}' depends on unknown key '${o}'`,"Add it to initialState");const n={};for(const[t,{deps:e}]of Object.entries(this._calculatedNormalized))n[t]=null===e?[]:e.filter((t=>this._calculatedFieldNames.has(t)));const o={},r={};for(const t of this._calculatedFieldNames)o[t]=0,r[t]=[];for(const[t,e]of Object.entries(n)){o[t]=e.length;for(const n of e)r[n].push(t)}const s=[];for(const[t,e]of Object.entries(o))0===e&&s.push(t);const i=[];for(;s.length>0;){const t=s.shift();i.push(t);for(const e of r[t])o[e]--,0===o[e]&&s.push(e)}if(i.length!==this._calculatedFieldNames.size){const e=[...this._calculatedFieldNames].filter((t=>!i.includes(t))),o=new Set,r=[],s=t=>{if(o.has(t))return r.push(t),!0;o.add(t),r.push(t);for(const o of n[t])if(e.includes(o)&&s(o))return!0;return r.pop(),o.delete(t),!1};s(e[0]);const a=r[r.length-1];Uo("SYG209",t,`Circular calculated dependency: ${r.slice(r.indexOf(a)).join(" → ")}`,"Break the cycle")}this._calculatedOrder=i.map((t=>[t,this._calculatedNormalized[t]])),this._calculatedFieldCache={};for(const[t,{deps:e}]of this._calculatedOrder)null!==e&&(this._calculatedFieldCache[t]={lastDepValues:void 0,lastResult:void 0})}else this._calculatedOrder=null,this._calculatedNormalized=null,this._calculatedFieldNames=null,this._calculatedFieldCache=null;this.isSubComponent=this.sourceNames.includes("props$");const g=e[f]&&e[f].stream;this.currentSlots={},g&&(this.currentState=u||{},this.sources[f]=new De(g.map((t=>(this.currentState=t,"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onStateChanged(this._componentNumber,this.name,t),t))),f));const S=e.props$;S&&(this.sources.props$=S.map((t=>{const{sygnalFactory:e,sygnalOptions:n,...o}=t;return this.currentProps=o,"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onPropsChanged(this._componentNumber,this.name,o),t})));const b=e.children$;var w;if(b&&(this._processedChildren$=b.map((t=>{if(Array.isArray(t)){const{slots:e,defaultChildren:n}=function(t){const e={},n=[];for(const o of t)if(o&&"slot"===o.sel){const t=o.data?.props?.name||"default";e[t]||(e[t]=[]);const n=Array.isArray(o.children)?o.children:o.children?[o.children]:[];e[t].push(...n)}else n.push(o);n.length>0&&(e.default||(e.default=[]),e.default.push(...n));return{slots:e,defaultChildren:e.default||[]}}(t);return this.currentSlots=e,this.currentChildren=n,{children:n,slots:e}}return this.currentSlots={},this.currentChildren=t,{children:t,slots:{}}})),this.sources.children$=this._processedChildren$.map((t=>t.children))),this.sources[p]&&(this.sources[p]=(w=this.sources[p],new Proxy(w,{get:(t,e,n)=>"symbol"==typeof e||e in t?Reflect.get(t,e,n):n=>t.select(n).events(e)}))),this.isSubComponent||void 0!==this.intent||void 0!==this.model||(this.initialState=u||!0,this.intent=t=>({__NOOP_ACTION__:zo.never()}),this.model={__NOOP_ACTION__:t=>t}),this._subscriptions=[],this._activeSubComponents=new Map,this._childReadyState={},this._readyChangedListener=null,this._readyChanged$=zo.create({start:t=>{this._readyChangedListener=t},stop:()=>{}}),this._disposeListener=null,this._dispose$=zo.create({start:t=>{this._disposeListener=t},stop:()=>{}}),this.sources.dispose$=this._dispose$,this.addCalculated=this.createMemoizedAddCalculated(),this.log=function(t){return function(e,n=!1){const o="function"==typeof e?e:t=>e;if(!n)return e=>e.debug((e=>{if(this.debug){const n=`[${t}] ${o(e)}`;console.log(n),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onDebugLog(this._componentNumber,n)}}));if(this.debug){const n=`[${t}] ${o(e)}`;console.log(n),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onDebugLog(this._componentNumber,n)}}}(`${this._componentNumber} | ${t}`),this.initChildSources$(),this.initIntent$(),this.initHmrActions(),this.initAction$(),this.initState(),this.initContext(),this.initModel$(),this.initPeers$(),this.initSubComponentSink$(),this.initSubComponentsRendered$(),this.initVdom$(),this.initSinks(),this.sinks.__index=this._componentNumber,this.log("Instantiated",!0),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__){window.__SYGNAL_DEVTOOLS__.onComponentCreated(this._componentNumber,t,this);const n=e?.__parentComponentNumber;"number"==typeof n&&window.__SYGNAL_DEVTOOLS__.onSubComponentRegistered(n,this._componentNumber)}}dispose(){if(this._disposed)return;this._disposed=!0,ro(this),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onComponentDisposed(this._componentNumber,this.name);if(this.model&&(this.model[or]||Object.keys(this.model).some((t=>t.includes("|")&&t.split("|")[0].trim()===or)))&&this.action$&&"function"==typeof this.action$.shamefullySendNext)try{this.action$.shamefullySendNext({type:or})}catch(t){}if(this._disposeListener){try{this._disposeListener.next(!0),this._disposeListener.complete()}catch(t){}this._disposeListener=null}this._activeSubComponents.forEach((t=>t?.sink$?.__dispose?.())),this._activeSubComponents.clear(),setTimeout((()=>{if(this.action$&&"function"==typeof this.action$.shamefullySendComplete)try{this.action$.shamefullySendComplete()}catch(t){}if(this.vdom$&&"function"==typeof this.vdom$.shamefullySendComplete)try{this.vdom$.shamefullySendComplete()}catch(t){}for(const t of this._subscriptions)if(t&&"function"==typeof t.unsubscribe)try{t.unsubscribe()}catch(t){}this._subscriptions=[]}),0)}get debug(){return this._debug||"true"===tr.SYGNAL_DEBUG||!0===tr.SYGNAL_DEBUG}initIntent$(){this.intent?("function"!=typeof this.intent&&Uo("SYG602",this,"intent must be a function","Use intent = sources => ({ ACTION: stream$ })"),this.intent$=this.intent(this.sources),this.intent$ instanceof qo||Tr(this.intent$)||Uo("SYG603",this,"intent must return a stream or an object of streams","Return { ACTION: stream$ }"),to(this,this.intent$ instanceof qo?[]:Object.keys(this.intent$),void 0)):to(this,[],void 0)}initHmrActions(){void 0!==this.hmrActions?("string"==typeof this.hmrActions&&(this.hmrActions=[this.hmrActions]),Array.isArray(this.hmrActions)&&!this.hmrActions.some((t=>"string"!=typeof t))||Uo("SYG604",this,"hmrActions must be an action name or an array of action names","Use hmrActions = ['ACTION']"),this.hmrAction$=zo.fromArray(this.hmrActions.map((t=>({type:t}))))):this.hmrAction$=zo.of().filter((t=>!1))}initAction$(){const t=this.sources&&this.sources[this.requestSourceName]||null;if(!this.intent$)return void(this.action$=zo.never());let e;if(this.intent$ instanceof qo)e=this.intent$;else{for(const t of Object.keys(this.intent$))t.includes("|")&&Uo("SYG605",this,`Intent action '${t}' contains '|', which is reserved for model shorthand`,"Rename the action");const t=Object.entries(this.intent$).map((([t,e])=>e.map((e=>({type:t,data:e})))));e=t.length>0?zo.merge(...t):zo.never()}const n=e instanceof qo?e:e.apply&&e(this.sources)||zo.never(),o=zo.of({type:er}).compose(be(10)),r="undefined"!=typeof window&&!0===window.__SYGNAL_HMR_UPDATING,s=r?this.hmrAction$:zo.of().filter((t=>!1)),i=this.model[er]&&!r?me(o,n):me(zo.of().compose(be(1)).filter((t=>!1)),s,n);let a;a=!r&&t&&"function"==typeof t.select?t.select("initial").flatten():zo.never();const c=a.map((t=>({type:"HYDRATE",data:t})));this.action$=zo.merge(i,c).compose(this.log((({type:t})=>`<${t}> Action triggered`))).map((t=>("undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onActionDispatched(this._componentNumber,this.name,t.type,t.data),t)))}initState(){void 0!==this.model&&(void 0===this.model[nr]?this.model[nr]={[this.stateSourceName]:(t,e)=>({...this.addCalculated(e)})}:Tr(this.model[nr])&&Object.keys(this.model[nr]).forEach((t=>{t!==this.stateSourceName&&(Fo("SYG210",this,`${nr} only supports the ${this.stateSourceName} sink; ignoring '${t}'`,"Use another action"),delete this.model[nr][t])})))}initContext(){if(!this.context&&!this.sources.__parentContext$)return void(this.context$=zo.of({}));const t=this.sources[this.stateSourceName]?.stream.startWith({}).compose(Ee(Or))||zo.never(),e=this.sources.__parentContext$?.startWith({}).compose(Ee(Or))||zo.of({});this.context&&!Tr(this.context)&&Bo("SYG402",this,`context must be an object, got ${typeof this.context}; ignoring it`,"Use context = { name: state => value }"),this.context$=zo.combine(t,e).map((([t,e])=>{const n=Tr(e)?e:{},o=Tr(this.context)?this.context:{},r=this.currentState,s={...n,...Object.entries(o).reduce(((t,e)=>{const[n,o]=e;let s;const i=typeof o;if("string"===i)s=r[o];else if("boolean"===i)s=r[n];else{if("function"!==i)return Bo("SYG403",this,`Invalid context entry '${n}'; skipping it`,"Use a state key or state => value"),t;s=o(r)}return t[n]=s,t}),{})};return this.currentContext=s,"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onContextChanged(this._componentNumber,this.name,s),s})).compose(Ee(Or)).startWith({}),this._subscriptions.push(this.context$.subscribe({next:t=>t,error:t=>Bo("SYG404",this,"Context stream errored; context stops updating","Check the context functions",t)}))}initModel$(){if(void 0===this.model)return this.model$=this.sourceNames.reduce(((t,e)=>(t[e]=zo.never(),t)),{}),void eo(this,{});const t=tr?.__SYGNAL_HMR_STATE,e=void 0!==t?t:this.initialState,n={type:nr,data:e};this.isSubComponent&&this.initialState&&!this.isolatedState&&Fo("SYG405",this,"Sub-component initialState replaces the state its parent passes in","Remove initialState, or set isolatedState = true");const o=void 0!==e&&(!0!==tr?.__SYGNAL_HMR_UPDATING||void 0!==t)?zo.merge(zo.of(n).compose(be(0)),this.action$):this.action$;let r=null;const s=o.map((t=>{const e=r,n=()=>e.next({...t,[cr]:this.currentState});return e&&(ur?queueMicrotask(n):n()),t}));let i;const a=zo.create({start:t=>{r=t,i=s.subscribe({})},stop:()=>{r=null,i?.unsubscribe()}}),c=()=>this.makeOnAction(s,!0,this.action$),l=()=>this.makeOnAction(a,!1,this.action$),u=Object.entries(this.model),d={},h=new Set,p={};u.forEach((t=>{let[e,n]=t;if(e.includes("|")){const t=e.split("|").map((t=>t.trim()));2===t.length&&t[0]&&t[1]||Uo("SYG211",this,`Invalid shorthand model entry '${e}'`,"Use 'ACTION | SINK'"),e=t[0],n={[t[1]]:n}}"function"==typeof n&&(n={[this.stateSourceName]:n}),Tr(n)||Uo("SYG212",this,`Model entry '${e}' must be a function or an object`,"Use { STATE: reducer }");Object.entries(n).forEach((t=>{const[n,o]=t,r=`${e}::${n}`;if(h.has(r)&&Fo("SYG213",this,`Duplicate model entry for action '${e}' on sink '${n}'; both run`,"Remove the duplicate"),h.add(r),(p[e]||(p[e]=[])).push(n),n===ir){const t=this.makeEffectHandler(a,e,o,this.action$);return void(Array.isArray(d[n])?d[n].push(t):d[n]=[t])}const s=n===this.stateSourceName,i=n===rr,u=s?c():l(),f=(i?u(e,o).map((t=>({name:this.name,component:this.view,value:t}))):u(e,o)).compose(this.log((t=>{if(s)return`<${e}> State reducer added`;if(i)return`<${e}> Data sent to parent component: ${JSON.stringify(t.value).replaceAll('"',"")}`;{const o=t&&(t.type||t.command||t.name||t.key||Array.isArray(t)&&"Array"||t);return`<${e}> Data sent to [${n}]: ${JSON.stringify(o).replaceAll('"',"")}`}})));Array.isArray(d[n])?d[n].push(f):d[n]=[f]}))}));const f=Object.entries(d).reduce(((t,e)=>{const[n,o]=e;return t[n]=1===o.length?o[0]:zo.merge(...o),t}),{});this.model$=f,eo(this,p)}initPeers$(){const t=this.sourceNames.reduce(((t,e)=>(e==this.DOMSourceName?t[e]={}:t[e]=[],t)),{});this.peers$=Object.entries(this.peers).reduce(((t,[e,n])=>{const o=n(this.sources);return this.sourceNames.forEach((n=>{n==this.DOMSourceName?t[n][e]=o[n]:t[n].push(o[n])})),t}),t)}initChildSources$(){let t;const e=zo.create({start:e=>{t=e.next.bind(e)},stop:t=>{}}).map((t=>zo.merge(...t))).flatten();this.sources.CHILD={select:t=>{const n=e;return("function"==typeof t?n.filter((e=>e.component===t)):t?n.filter((e=>e.name===t)):n).map((t=>t.value))}},this.newChildSources=e=>{"function"==typeof t&&t(e)}}initSubComponentSink$(){const t=zo.create({start:t=>{this.newSubComponentSinks=t.next.bind(t)},stop:t=>{}});this._subscriptions.push(t.subscribe({next:t=>t,error:t=>Bo("SYG901",this,"Sub-component sink stream errored",ar,t)})),this.subComponentSink$=t.filter((t=>Object.keys(t).length>0))}initSubComponentsRendered$(){const t=zo.create({start:t=>{this.triggerSubComponentsRendered=t.next.bind(t)},stop:t=>{}});this.subComponentsRendered$=t.startWith(null)}initVdom$(){if("function"!=typeof this.view)return void(this.vdom$=zo.of(null));const t=this.collectRenderParameters();this.vdom$=t.map((t=>{const{props:e,state:n,children:o,slots:r,context:s,...i}=t,{sygnalFactory:a,sygnalOptions:c,...l}=e||{};try{return this.view({...l,state:n,children:o,slots:r||{},context:s,peers:i},n,s,i)}catch(t){const e=t instanceof Error?t:new Error(String(t));if("function"==typeof this.onError)try{const t=this.onError(e,{componentName:this.name});return Fo("SYG406",this,"View threw; rendered the onError fallback",void 0,e),t}catch(t){Bo("SYG406",this,"View threw; rendering the error fallback",void 0,e),Bo("SYG407",this,"onError threw; rendering an empty error <div>","Make onError return a vnode",t)}else Bo("SYG406",this,"View threw; rendering the error fallback","Add .onError for a custom fallback",e);return{sel:"div",data:{attrs:{"data-sygnal-error":this.name}},children:[]}}})).compose(this.log("View rendered")).map((t=>t||{sel:"div",data:{},children:[]})).map((t=>wr(t,this))).compose(this.instantiateSubComponents.bind(this)).filter((t=>void 0!==t)).compose(this.renderVdom.bind(this))}initSinks(){const t=this.model$.EVENTS;if(t&&(this.model$.EVENTS=t.map((t=>Object.defineProperties({...t},{__emitterId:{value:this._componentNumber,configurable:!0},__emitterName:{value:this.name,configurable:!0}})))),this.sinks=this.sourceNames.reduce(((t,e)=>{if(e==this.DOMSourceName)return t;const n=this.subComponentSink$&&e!==rr?this.subComponentSink$.map((t=>t[e])).filter((t=>!!t)).flatten():zo.never();return e===this.stateSourceName?t[e]=zo.merge(this.model$[e]||zo.never(),n,this.sources[this.stateSourceName].stream.filter((t=>!1)),...this.peers$[e]||[]):t[e]=zo.merge(this.model$[e]||zo.never(),n,...this.peers$[e]||[]),t}),{}),this.sinks[this.DOMSourceName]=this.vdom$,this.sinks[rr]=this.model$[rr]||zo.never(),this.model$[ir]){const t=this.model$[ir].subscribe({next:()=>{},error:t=>Bo("SYG902",this,"EFFECT stream errored; effects stop running",ar,t)});this._subscriptions.push(t),delete this.sinks[ir]}this.model&&Tr(this.model)&&Object.values(this.model).some((t=>!(!Tr(t)||!(sr in t))))?(this.sinks[sr]=this.model$[sr],this.sinks[sr].__explicitReady=!0):this.sinks[sr]=zo.of(!0)}makeOnAction(t,e=!0,n){return n=n||t,(o,r)=>{const s=t.filter((({type:t})=>t==o));let i;if("function"==typeof r)i=s.map((t=>{const s=(t,e,r=10)=>{"number"!=typeof r&&Uo("SYG215",this,`next() delay in '${o}' must be a number`,"Use next('ACTION', data, ms)"),setTimeout((()=>{n.shamefullySendNext({type:t,data:e})}),r),this.log(`<${o}> Triggered a next() action: <${t}> ${r}ms delay`,!0)},i={...this.currentProps,children:this.currentChildren,slots:this.currentSlots||{},context:this.currentContext};let a=t.data;if(e){ur++||setTimeout((()=>{ur=0}));let t=!1;return e=>{!t&&ur&&(t=!0,ur--);const n=void 0!==e,c=this.isSubComponent&&!n?this.currentState:e;try{const t=this.addCalculated(c);i.state=t;const e=r(t,a,s,i);if(hr(e))return c;oo(this,o,c,e,this.stateSourceName);const l=this.cleanupCalculated(e);return n&&(this.currentState=l),l}catch(t){return Bo("SYG216",this,`Reducer for '${o}' threw; state unchanged`,ar,t),c}}}try{const e=this.addCalculated(cr in t?t[cr]:this.currentState);i.state=e;const n=r(e,a,s,i);if(hr(n))return n;const c=typeof n;if(Tr(n)||["string","number","boolean","function"].includes(c))return n;if("undefined"===c)return Fo("SYG217",this,`Reducer for '${o}' sent undefined to the driver`,"Return a value, or ABORT to send nothing"),n;Uo("SYG218",this,`Reducer for '${o}' returned a ${c}`,"Return a value, or ABORT to send nothing")}catch(t){return Bo("SYG216",this,`Reducer for '${o}' threw; nothing sent`,ar,t),dr}})).filter((t=>!hr(t)));else if(void 0===r||!0===r)i=s.map((({data:t})=>t));else{const t=r;i=s.mapTo(t)}return i}}makeEffectHandler(t,e,n,o=t){return t.filter((({type:t})=>t==e)).map((t=>{if("function"==typeof n){const r=(t,n,r=10)=>{"number"!=typeof r&&Uo("SYG215",this,`next() delay in '${e}' must be a number`,"Use next('ACTION', data, ms)"),setTimeout((()=>{o.shamefullySendNext({type:t,data:n})}),r),this.log(`<${e}> EFFECT triggered a next() action: <${t}> ${r}ms delay`,!0)};try{const o=this.addCalculated(cr in t?t[cr]:this.currentState),s={...this.currentProps,children:this.currentChildren,slots:this.currentSlots||{},context:this.currentContext,state:o},i=n(o,t.data,r,s);void 0===i||hr(i)||Fo("SYG219",this,`EFFECT handler '${e}' returned a value, which is ignored`,"Use a STATE or driver sink")}catch(t){Bo("SYG214",this,`EFFECT handler '${e}' threw`,ar,t)}}return null})).filter((t=>!1))}createMemoizedAddCalculated(){let t,e;return function(n){if(!this.calculated||!Tr(n)||Array.isArray(n))return n;if(n===t)return e;Tr(this.calculated)||Uo("SYG606",this,"calculated must be an object","Use calculated = { field: state => value }");const o=this.getCalculatedValues(n);if(!o)return t=n,e=n,n;const r={...n,...o};return t=n,e=r,r}}getCalculatedValues(t){if(!this._calculatedOrder||0===this._calculatedOrder.length)return;const e={...t},n={};for(const[t,{fn:o,deps:r}]of this._calculatedOrder)if(null!==r&&this._calculatedFieldCache){const s=this._calculatedFieldCache[t],i=r.map((t=>e[t]));if(void 0!==s.lastDepValues){let o=!0;for(let t=0;t<i.length;t++)if(i[t]!==s.lastDepValues[t]){o=!1;break}if(o){n[t]=s.lastResult,e[t]=s.lastResult;continue}}try{const r=o(e);s.lastDepValues=i,s.lastResult=r,n[t]=r,e[t]=r}catch(e){Fo("SYG220",this,`Calculated field '${t}' threw (${e instanceof Error?e.message:e}); skipped this update`,"Guard against missing data")}}else try{const r=o(e);n[t]=r,e[t]=r}catch(e){Fo("SYG220",this,`Calculated field '${t}' threw (${e instanceof Error?e.message:e}); skipped this update`,"Guard against missing data")}return n}cleanupCalculated(t){if(!t||!Tr(t)||Array.isArray(t))return t;const e={...this.storeCalculatedInState?this.addCalculated(t):t};if(!this.calculated||this.storeCalculatedInState)return e;return Object.keys(this.calculated).forEach((t=>{this.initialState&&void 0!==this.initialState[t]?e[t]=this.initialState[t]:delete e[t]})),e}collectRenderParameters(){const t=this.sources[this.stateSourceName],e={...this.peers$[this.DOMSourceName]},n=t&&t.isolateSource(t,{get:t=>this.addCalculated(t)}),o=n&&n.stream||zo.never();e.state=o.compose(Ee(Or)),this.sources.props$&&(e.props=this.sources.props$.compose(Ee(Nr))),this._processedChildren$&&(e.children=this._processedChildren$.map((t=>t.children)).compose(Ee(Or)),e.slots=this._processedChildren$.map((t=>t.slots)).compose(Ee(Or))),this.context$&&(e.context=this.context$.compose(Ee(Or)));const r=[],s=[];Object.entries(e).forEach((([t,e])=>{r.push(t),s.push(e)}));const i=zo.combine(...s).compose(ve(1)).map((t=>{const e=r.reduce(((e,n,o)=>(e[n]=t[o],"state"===n&&(e[this.stateSourceName]=t[o],e.calculated=t[o]&&this.getCalculatedValues(t[o])||{}),e)),{});return e}));return i}instantiateSubComponents(t){const e=new Set(["collection","switchable","sygnal-factory",...Object.keys(this.components)]);return t.fold(((t,n)=>{const o=yr(n,e),r=Object.entries(o),s={"::ROOT::":n};if(0===r.length)return this._activeSubComponents.forEach((t=>{t?.sink$?.__dispose&&t.sink$.__dispose()})),this._activeSubComponents.clear(),s;const i={},a=[];let c=0;const l=r.reduce(((e,[n,o])=>{const r=o.data,s=r.props||{},l=o.children||(null!=o.text?[{text:o.text}]:[]),u=r.isCollection||!1,d=r.isSwitchable||!1,h=t=>{Object.entries(t).forEach((([t,e])=>{i[t]||(i[t]=[]),t===rr?a.push(e):t!==this.DOMSourceName&&t!==sr&&i[t].push(e)}))};if(t[n]){const o=t[n];return e[n]=o,o.props$.shamefullySendNext(s),o.children$.shamefullySendNext(l),h(o.sink$),e}const p=zo.create().startWith(s),f=zo.create().startWith(l);let m,y;m=u?this.instantiateCollection.bind(this):d?this.instantiateSwitchable.bind(this):this.instantiateCustomComponent.bind(this),c++;try{y=m(o,p,f)}catch(t){const e=t instanceof Error?t:new Error(String(t));Bo("SYG408",this,"Sub-component threw; rendering the error fallback",ar,e);let n={sel:"div",data:{attrs:{"data-sygnal-error":this.name}},children:[]};if("function"==typeof this.onError)try{n=this.onError(e,{componentName:this.name})||n}catch(t){Bo("SYG407",this,"onError threw; rendering an empty error <div>","Make onError return a vnode",t)}y={[this.DOMSourceName]:zo.of(n)}}return y[this.DOMSourceName]=y[this.DOMSourceName]?this.makeCoordinatedSubComponentDomSink(y[this.DOMSourceName]):zo.never(),e[n]={sink$:y,props$:p,children$:f},this._activeSubComponents.set(n,e[n]),h(y),e}),s),u=Object.entries(i).reduce(((t,[e,n])=>(0===n.length||(t[e]=1===n.length?n[0]:zo.merge(...n)),t)),{}),d=new Set(Object.keys(l));return this._activeSubComponents.forEach(((t,e)=>{d.has(e)||(t?.sink$?.__dispose&&t.sink$.__dispose(),this._activeSubComponents.delete(e),delete this._childReadyState[e])})),this.newSubComponentSinks(u),this.newChildSources(a),c>0&&this.log(`New sub components instantiated: ${c}`,!0),l}),{})}makeCoordinatedSubComponentDomSink(t){return t.debug((t=>this.triggerSubComponentsRendered())).remember()}withCalculated(t){return this.calculated?{get:e=>t.get(Tr(e)?this.addCalculated(e):e),set:t.set}:t}createSubComponentLense(t,e,n){const o={get:t=>t,set:(t,e)=>e};return void 0===t?o:"string"==typeof t?{get:e=>{const o=e[t];return void 0===o&&n?n:o},set:(n,o)=>this.calculated&&t in this.calculated?(Fo("SYG409",this,`${e} tried to update calculated field '${t}'; ignored`,"Bind it to a non-calculated field"),n):{...n,[t]:o}}:Tr(t)?"function"!=typeof t.get?(Bo("SYG410",this,`${e} 'state' prop has no get(); it gets the parent's whole state`,"Use a state key string or { get, set }"),o):{get:t.get,set:t.set}:(Bo("SYG410",this,`${e} 'state' prop is a ${typeof t}; it gets the parent's whole state`,"Use a state key string or { get, set }"),o)}instantiateCollection(t,e,n){const o=t.data.props||{};const r={filter:"function"==typeof o.filter?o.filter:void 0,sort:Lr(o.sort)},s=zo.combine(this.sources[this.stateSourceName].stream.startWith(this.currentState),e.startWith(o)).compose(ve(1)).map((([t,e])=>(e.filter!==r.filter&&(r.filter="function"==typeof e.filter?e.filter:void 0),e.sort!==r.sort&&(r.sort=Lr(e.sort)),t))),i=new De(s,this.stateSourceName),a=o.from,c=o.of,l=o.idfield||"id";let u,d;if("function"==typeof c)if(c.isSygnalComponent)d=c;else{const t=c.componentName||c.label||c.name||"FUNCTION_COMPONENT",e=c,{model:n,intent:o,hmrActions:r,context:s,peers:i,components:a,initialState:l,calculated:u,storeCalculatedInState:h,DOMSourceName:p,stateSourceName:f,onError:m,debug:y}=c;d=fr({name:t,view:e,model:n,intent:o,hmrActions:r,context:s,peers:i,components:a,initialState:l,calculated:u,storeCalculatedInState:h,DOMSourceName:p,stateSourceName:f,onError:m,debug:y})}else this.components[c]?d=this.components[c]:Uo("SYG411",this,`Collection 'of' is not a component: ${c}`,"Use of={ItemComponent}");const h={get:t=>{if(!Array.isArray(t[a]))return[];const e=t[a],n="function"==typeof r.filter?e.filter(r.filter):e,o=("function"==typeof r.sort?n.sort(r.sort):n).map(((t,e)=>Tr(t)?{...t,[l]:t[l]||e}:{value:t,[l]:e}));return o},set:(t,e)=>{if(this.calculated&&a in this.calculated)return Fo("SYG409",this,`Collection tried to update calculated field '${a}'; ignored`,"Bind it to a non-calculated field"),t;const n=[];for(const o of t[a].map(((t,e)=>Tr(t)?{...t,[l]:t[l]||e}:{__primitive:!0,value:t,[l]:e})))if("function"!=typeof r.filter||r.filter(o)){const t=e.find((t=>t[l]===o[l]));void 0!==t&&n.push(o.__primitive?t.value:t)}else n.push(o.__primitive?o.value:o);return{...t,[a]:n}}};if(void 0===a)u={get:t=>!(t instanceof Array)&&t.value&&t.value instanceof Array?t.value:t,set:(t,e)=>e};else if("string"==typeof a)if(Tr(this.currentState))if(this.currentState&&a in this.currentState||this.calculated&&a in this.calculated)Array.isArray(this.currentState[a])||Fo("SYG401",this,`Collection 'from' field '${a}' is not an array; it renders nothing`,"Set it to an array in initialState"),u=h;else{const t=Object.keys(this.currentState).filter((t=>Array.isArray(this.currentState[t])));Bo("SYG401",this,`Collection from="${a}" is not in state${t.length?` (array fields: '${t.join("', '")}')`:""}; it renders nothing`,"Set it to an array in initialState"),u=void 0}else Array.isArray(this.currentState[a])||Fo("SYG401",this,`Collection 'from' field '${a}' is not an array; it renders nothing`,"Set it to an array in initialState"),u=h;else Tr(a)?"function"!=typeof a.get?(Bo("SYG412",this,"Collection 'from' prop is invalid; it renders nothing","Use a state key string or { get, set }",a),u=void 0):u={get:t=>{const e=a.get(t);return Array.isArray(e)?e:(Fo("SYG401",this,"Collection 'from' getter returned a non-array; it renders nothing","Return an array from get()",e),[])},set:a.set}:(Bo("SYG412",this,"Collection 'from' prop is invalid; it renders nothing","Use a state key string or { get, set }",a),u=void 0);u&&(u=this.withCalculated(u));const p=["of","from","filter","sort","idfield","className"],f=e.map((t=>{if(!t||"object"!=typeof t)return{};const e={};for(const n in t)p.includes(n)||(e[n]=t[n]);return e})),m={...this.sources,[this.stateSourceName]:i,props$:f,children$:n,__parentContext$:this.context$,PARENT:null,__parentComponentNumber:this._componentNumber},y=Wo(d,u,{container:null})(m);if(Tr(y)||Uo("SYG903",this,"Collection factory returned invalid sinks","Return a sinks object"),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected){const t="function"==typeof c?c.componentName||c.label||c.name||"anonymous":String(c);window.__SYGNAL_DEVTOOLS__.onCollectionMounted(this._componentNumber,this.name,t,"string"==typeof a?a:null)}return y}instantiateSwitchable(t,e,n){const o=t.data.props||{},r=this.sources[this.stateSourceName].stream.startWith(this.currentState).map((t=>Tr(t)?this.addCalculated(t):t)),s=new De(r,this.stateSourceName),i=o.state,a=this.withCalculated(this.createSubComponentLense(i,"Switchable sub-component")),c=o.of;Object.keys(c).forEach((t=>{const e=c[t];if(!e.isSygnalComponent){const n=e.componentName||e.label||e.name||"FUNCTION_COMPONENT",o=e,{model:r,intent:s,hmrActions:i,context:a,peers:l,components:u,initialState:d,calculated:h,storeCalculatedInState:p,DOMSourceName:f,stateSourceName:m,onError:y,debug:_}=e,v={name:n,view:o,model:r,intent:s,hmrActions:i,context:a,peers:l,components:u,initialState:d,calculated:h,storeCalculatedInState:p,DOMSourceName:f,stateSourceName:m,onError:y,debug:_};c[t]=fr(v)}}));const l={...this.sources,[this.stateSourceName]:s,props$:e,children$:n,__parentContext$:this.context$,__parentComponentNumber:this._componentNumber},u=pe(Zo(c,e.map((t=>t.current)),""),{[this.stateSourceName]:a})(l);return Tr(u)||Uo("SYG903",this,"Switchable factory returned invalid sinks","Return a sinks object"),u}instantiateCustomComponent(t,e,n){const o=t.sel,r=t.data.props||{},s=this.sources[this.stateSourceName].stream.startWith(this.currentState).map((t=>Tr(t)?this.addCalculated(t):t));let i=new De(s,this.stateSourceName);const a=r.state;"function"!=typeof r.sygnalFactory&&Tr(r.sygnalOptions)&&(r.sygnalFactory=fr(r.sygnalOptions));const c="sygnal-factory"===o?r.sygnalFactory:this.components[o]||r.sygnalFactory;c||("sygnal-factory"===o&&Uo("SYG413",this,"Unnamed component has no factory","Name the function, or set Comp.componentName"),Uo("SYG414",this,`Component '${o}' not found`,"Import it, or add it to .components"));const l=r.sygnalOptions?.initialState,u=r.sygnalOptions?.isolatedState;if(l&&!u){Uo("SYG405",r.sygnalOptions?.name||o,"Sub-component initialState replaces the state its parent passes in","Remove initialState, or set isolatedState = true")}const d=u?l:void 0;let h,p,f=this.createSubComponentLense(a,"Sub-component",d);u&&void 0===a&&(p=zo.create(),i=new De(zo.merge(s.filter((()=>void 0===h)),p),this.stateSourceName));const m={...this.sources,[this.stateSourceName]:i,props$:e,children$:n,__parentContext$:this.context$,__parentComponentNumber:this._componentNumber};f=p?null:this.withCalculated(f);for(const t of Object.keys(r)){const e=r[t];if(e&&e.__sygnalCommand){e._targetComponentName=o,m.commands$=Qo(e);break}}const y=pe(c,{[this.stateSourceName]:f})(m);if(!Tr(y)){Uo("SYG903",this,`Factory for ${"sygnal-factory"===o?"custom element":o} returned invalid sinks`,"Return a sinks object")}return p&&y[this.stateSourceName]&&(y[this.stateSourceName]=y[this.stateSourceName].map((t=>p.shamefullySendNext(h=t(void 0===h?this.addCalculated(this.currentState):h)))).filter((()=>!1))),y}renderVdom(t){const e=new Set(["collection","switchable","sygnal-factory",...Object.keys(this.components)]);return zo.combine(this.subComponentsRendered$,t,this._readyChanged$.startWith(null)).compose(ve(1)).map((([t,n])=>{const o=n["::ROOT::"],r=Object.entries(n).filter((([t])=>"::ROOT::"!==t));if(0===r.length)return zo.of(Sr(o));const s=[],i=r.map((([t,e])=>(s.push(t),e.sink$[this.DOMSourceName].startWith(void 0))));if(0===i.length)return zo.of(o);for(const[t,e]of r){if(void 0!==this._childReadyState[t])continue;const n=e.sink$[sr];if(n){const e=n.__explicitReady;this._childReadyState[t]=!e,n.addListener({next:e=>{const n=this._childReadyState[t];this._childReadyState[t]=!!e,n!==!!e&&(this._readyChangedListener&&setTimeout((()=>{this._readyChangedListener?.next(null)}),0),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onReadyChanged(this._componentNumber,this.name,t,!!e))},error:()=>{},complete:()=>{}})}else this._childReadyState[t]=!0}return zo.combine(...i).filter((t=>t.every((t=>void 0!==t)))).map((t=>{const n=t.reduce(((t,e,n)=>(t[s[n]]=e,t)),{});return Sr(_r(o,n,e,"r",void 0,this._childReadyState))}))})).flatten().filter((t=>!!t)).map((t=>(no(this,t),t))).remember()}}function yr(t,e,n="r",o,r){var s,i;if(!t)return r||{};if(t.data?.componentsProcessed)return r||{};"r"===n&&(t.data.componentsProcessed=!0),r||(r={});const a=t.sel,c=a&&"collection"===a.toLowerCase(),l=a&&"switchable"===a.toLowerCase(),u=a&&e.has(a)||"function"==typeof t.data?.props?.sygnalFactory||Tr(t.data?.props?.sygnalOptions),d=t.data&&t.data.props||{},h=t.children||[];let p=o;if(u){if(p=vr(t,n,o),c)d.of||Uo("SYG411",void 0,"Collection is missing 'of'","Use of={ItemComponent}"),"string"!=typeof d.of&&"function"!=typeof d.of&&Uo("SYG411",void 0,"Collection 'of' is a "+typeof d.of,"Use of={ItemComponent}"),"function"==typeof d.of||e.has(d.of)||Uo("SYG411",void 0,`Collection 'of' component not found: ${d.of}`,"Use of={ItemComponent}"),t.data.isCollection=!0,(s=t.data).props||(s.props={});else if(l){d.of||Uo("SYG415",void 0,"Switchable is missing 'of'","Use of={{ name: Component }}"),Tr(d.of)||Uo("SYG415",void 0,"Switchable 'of' is a "+typeof d.of,"Use of={{ name: Component }}");Object.values(d.of).every((t=>"function"==typeof t))||Uo("SYG415",void 0,"Switchable 'of' has a value that is not a component","Use of={{ name: Component }}"),(!d.current||"string"!=typeof d.current&&"function"!=typeof d.current)&&Uo("SYG416",void 0,"Switchable 'current' is missing or a "+typeof d.current,"Set current to a key of 'of'");Object.keys(d.of).includes(d.current)||Uo("SYG416",void 0,`Switchable 'current' '${d.current}' is not a key of 'of'`,"Set current to a key of 'of'"),t.data.isSwitchable=!0}void 0===d.key&&(((i=t.data).props||(i.props={})).key=p),r[p]=t}for(let t=0;t<h.length;t++)yr(h[t],e,`${n}.${t}`,p,r);return r}function _r(t,e,n,o="r",r,s){if(!t)return;const i=t.sel||"NO SELECTOR",a=n.has(i)||"function"==typeof t.data?.props?.sygnalFactory||Tr(t.data?.props?.sygnalOptions),c=t?.data?.isCollection,l=t.children||[];let u=r;if(a){u=vr(t,o,r);let n=e[u];return s&&u&&!1===s[u]&&n&&"object"==typeof n&&n.sel&&(n={...n,data:{...n.data||{},attrs:{...n.data?.attrs||{},"data-sygnal-ready":"false"}}}),c?{...t,sel:"div",children:Array.isArray(n)?n:[n]}:n}if(l.length>0){const r=l.map(((t,r)=>_r(t,e,n,`${o}.${r}`,u,s))).flat();return{...t,children:r}}return t}function vr(t,e,n){const o=t.sel,r="string"==typeof o?o:"functionComponent",s=t.data?.props||{};return`${n?`${n}|`:""}${r}::${s.id&&JSON.stringify(s.id).replaceAll('"',"")||e}`}function gr(t){if(!t||!t.sel)return!1;if("false"===t.data?.attrs?.["data-sygnal-ready"])return!0;if("loading"===t.data?.attrs?.["data-sygnal-lazy"])return!0;if("suspense"===t.sel)return!1;if(Array.isArray(t.children))for(const e of t.children)if(gr(e))return!0;return!1}function Sr(t){if(!t||!t.sel)return t;if("suspense"===t.sel){const e=(t.data?.props||{}).fallback,n=t.children||[];return n.some(gr)&&e?"string"==typeof e?{sel:"div",data:{attrs:{"data-sygnal-suspense":"pending"}},children:[{text:e}],text:void 0,elm:void 0,key:void 0}:{sel:"div",data:{attrs:{"data-sygnal-suspense":"pending"}},children:[e],text:void 0,elm:void 0,key:void 0}:1===n.length?Sr(n[0]):{sel:"div",data:{attrs:{"data-sygnal-suspense":"resolved"}},children:n.map((t=>Sr(t))),text:void 0,elm:void 0,key:void 0}}if(t.children&&t.children.length>0){const e=t.children.map((t=>Sr(t)));return{...t,children:e}}return t}const br=on(Co);function wr(t,e){if(!t||!t.sel)return t;const n=t.data?.props?.sygnalOptions?.view;if(n&&n.__sygnalLazy)if(n.__sygnalLazyLoaded()){const e=n.__sygnalLazyLoadedComponent;if(e){const n=t.data?.props||{},o=e.componentName||e.label||e.name||"LazyLoaded",{model:r,intent:s,hmrActions:i,context:a,peers:c,components:l,initialState:u,isolatedState:d,calculated:h,storeCalculatedInState:p,DOMSourceName:f,stateSourceName:m,onError:y,debug:_}=e,v={name:o,view:e,model:r,intent:s,hmrActions:i,context:a,peers:c,components:l,initialState:u,isolatedState:d,calculated:h,storeCalculatedInState:p,DOMSourceName:f,stateSourceName:m,onError:y,debug:_},g={...n};return delete g.sygnalOptions,{sel:o,data:{props:{...g,sygnalOptions:v}},children:t.children||[],text:void 0,elm:void 0,key:void 0}}}else!n.__sygnalLazyReRenderScheduled&&n.__sygnalLazyPromise&&e&&(n.__sygnalLazyReRenderScheduled=!0,n.__sygnalLazyPromise.then((()=>{setTimeout((()=>{const t=e.sources?.[e.stateSourceName];if(t&&t.stream){const n={...e.currentState,__sygnalLazyTick:Date.now()};t.stream.shamefullySendNext(n)}}),0)})));if("portal"===t.sel){const e=t.data?.props?.target;return function(t,e){const n=e||[];return{sel:"div",data:{style:{display:"none"},attrs:{"data-sygnal-portal":t},portalChildren:n,hook:{insert:e=>{if(document.querySelector(t))return void Er(e,t,n);let o=0;const r=()=>{e.data._portalVnode||(document.querySelector(t)?Er(e,t,n):++o<10?setTimeout(r,5):Fo("SYG417","Portal",`Target '${t}' not found; content not rendered`,"Render the target first"))};setTimeout(r,5)},postpatch:(e,n)=>{const o=e.data?._portalVnode,r=e.data?._portalContainer,s=n.data?.portalChildren||[];o&&r?(n.data._portalVnode=br(o,{sel:"div",data:{},children:s,text:void 0,elm:void 0,key:void 0}),n.data._portalContainer=r):n.data._portalVnode||Er(n,t,s)},destroy:t=>{const e=t.data?._portalVnode;e&&e.elm&&e.elm.parentNode&&e.elm.parentNode.removeChild(e.elm)}}},children:[],text:void 0,elm:void 0,key:void 0}}(e,t.children||[])}if("transition"===t.sel){const n=t.data?.props||{},o=n.name||"v",r=n.duration,s=(t.children||[])[0];return s&&s.sel?function(t,e,n){const o=t.data?.hook?.insert,r=t.data?.hook?.remove;return t.data=t.data||{},t.data.hook=t.data.hook||{},t.data.hook.insert=t=>{o&&o(t);const r=t.elm;r&&r.classList&&(r.classList.add(`${e}-enter-from`,`${e}-enter-active`),requestAnimationFrame((()=>{requestAnimationFrame((()=>{r.classList.remove(`${e}-enter-from`),r.classList.add(`${e}-enter-to`),Ar(r,n,(()=>{r.classList.remove(`${e}-enter-active`,`${e}-enter-to`)}))}))})))},t.data.hook.remove=(t,o)=>{r&&r(t,(()=>{}));const s=t.elm;s&&s.classList?(s.classList.add(`${e}-leave-from`,`${e}-leave-active`),requestAnimationFrame((()=>{requestAnimationFrame((()=>{s.classList.remove(`${e}-leave-from`),s.classList.add(`${e}-leave-to`),Ar(s,n,(()=>{s.classList.remove(`${e}-leave-active`,`${e}-leave-to`),o()}))}))}))):o()},t}(wr(s,e),o,r):s||t}if("clientonly"===t.sel){const n=t.children||[];return 0===n.length?{sel:"div",data:{},children:[]}:1===n.length?wr(n[0],e):{sel:"div",data:{},children:n.map((t=>wr(t,e))),text:void 0,elm:void 0,key:void 0}}return t.children&&t.children.length>0&&(t.children=t.children.map((t=>wr(t,e)))),t}function Ar(t,e,n){if("number"==typeof e)setTimeout(n,e);else{const e=()=>{t.removeEventListener("transitionend",e),n()};t.addEventListener("transitionend",e)}}function Er(t,e,n){const o=document.querySelector(e);if(!o)return void Fo("SYG417","Portal",`Target '${e}' not found; content not rendered`,"Render the target first");const r=document.createElement("div");o.appendChild(r),t.data._portalVnode=br(r,{sel:"div",data:{},children:n,text:void 0,elm:void 0,key:void 0}),t.data._portalContainer=o}function Nr(t,e){return Or(Cr(t),Cr(e))}function Or(t,e,n=5,o=0){if(o>n)return!1;if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(!Or(t[r],e[r],n,o+1))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(const s of r){if(!(s in e))return!1;if(!Or(t[s],e[s],n,o+1))return!1}return!0}function Cr(t){if(!Tr(t))return t;const{state:e,of:n,from:o,filter:r,...s}=t;return s}function Tr(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}const kr="Use a field name, { field: 'asc'|'desc'|1|-1 }, or a function";function $r(t,e,n=!0){const o=n?1:-1;switch(!0){case t>e:return 1*o;case t<e:return-1*o;default:return 0}}function xr(t){const e=Object.entries(t);if(e.length>1)return void Bo("SYG418","Collection","sort object must have one key; ignored",kr,t);const n=e[0],[o,r]=n;if(!["string","number"].includes(typeof r))return void Bo("SYG418","Collection","sort direction must be a string or number; ignored",kr,t);let s=!0;if("string"==typeof r){if(!["asc","desc"].includes(r.toLowerCase()))return void Bo("SYG418","Collection","sort direction must be 'asc' or 'desc'; ignored",kr,t);s="desc"!==r.toLowerCase()}if("number"==typeof r){if(1!==r&&-1!==r)return void Bo("SYG418","Collection","sort direction must be 1 or -1; ignored",kr,t);s=1===r}return(t,e)=>$r(t[o],e[o],s)}function Lr(t){if(!t)return;const e=typeof t;if("function"===e)return t;if("string"===e){if("asc"===t.toLowerCase()||"desc"===t.toLowerCase()){const e="desc"!==t.toLowerCase();return(t,n)=>$r(t,n,e)}const e=t;return(t,n)=>$r(t[e],n[e],!0)}if(Array.isArray(t)){const e=t.map((t=>"function"==typeof t?t:"string"!=typeof t||["asc","desc"].includes(t.toLowerCase())?Tr(t)?xr(t):void 0:(e,n)=>$r(e[t],n[t],!0)));return(t,n)=>e.filter((t=>"function"==typeof t)).reduce(((e,o)=>0!==e?e:o(t,n)),0)}return Tr(t)?xr(t):void Bo("SYG418","Collection","Invalid sort prop; ignored",kr,t)}const Dr=t=>{const{children:e,...n}=t;return ze("portal",{props:n},e)};Dr.label="portal",Dr.preventInstantiation=!0;const Gr=t=>{const{children:e,...n}=t;return ze("transition",{props:n},e)};Gr.label="transition",Gr.preventInstantiation=!0;const jr=t=>{const{children:e,...n}=t;return ze("suspense",{props:n},e)};jr.label="suspense",jr.preventInstantiation=!0;const Ir=t=>{const{children:e,...n}=t;return ze("slot",{props:n},e)};function Mr(t){return t.data=function(e,n){return Mr(t.map((t=>{const o=t?.dataset?.[e]??t?.dropZone?.dataset?.[e]??t?.element?.dataset?.[e];return n?n(o):o})))},t.element=function(e){return Mr(t.map((t=>{const n=t?.element??t?.dropZone??null;return e?e(n):n})))},t}function Pr(t){return 0===Object.keys(t).length}function Yr(t,e){if("function"!=typeof t)throw new Error("First argument given to Cycle must be the 'main' function.");if("object"!=typeof e||null===e)throw new Error("Second argument given to Cycle must be an object with driver functions as properties.");if(Pr(e))throw new Error("Second argument given to Cycle must be an object with at least one driver function declared as a property.");const n=function(t){if("object"!=typeof t||null===t)throw new Error("Argument given to setupReusable must be an object with driver functions as properties.");if(Pr(t))throw new Error("Argument given to setupReusable must be an object with at least one driver function declared as a property.");const e=function(t){const e={};for(const n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=ce.create());return e}(t),n=function(t,e){const n={};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(n[o]=t[o](e[o],o),n[o]&&"object"==typeof n[o]&&(n[o]._isCycleSource=o));return n}(t,e),o=function(t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&"function"==typeof t[e].shamefullySendNext&&(t[e]=ue(t[e]));return t}(n);function r(t){return function(t,e){const n=Object.keys(t).filter((t=>!!e[t]));let o={};const r={};n.forEach((t=>{o[t]={_n:[],_e:[]},r[t]={next:e=>o[t]._n.push(e),error:e=>o[t]._e.push(e),complete:()=>{}}}));const s=n.map((e=>ce.fromObservable(t[e]).subscribe(r[e])));return n.forEach((t=>{const n=e[t],s=t=>{queueMicrotask((()=>n._n(t)))},i=t=>{queueMicrotask((()=>{(console.error||console.log)(t),n._e(t)}))};o[t]._n.forEach(s),o[t]._e.forEach(i),r[t].next=s,r[t].error=i,r[t]._n=s,r[t]._e=i})),o=null,function(){s.forEach((t=>t.unsubscribe()))}}(t,e)}function s(){!function(t){for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&t[e]&&t[e].dispose&&t[e].dispose()}(o),function(t){Object.keys(t).forEach((e=>t[e]._c()))}(e)}return{sources:o,run:r,dispose:s}}(e),o=t(n.sources);return"undefined"!=typeof window&&(window.Cyclejs=window.Cyclejs||{},window.Cyclejs.sinks=o),{sinks:o,sources:n.sources,run:function(){const t=n.run(o);return function(){t(),n.dispose()}}}}function Rr(t){const e=new EventTarget;return t.subscribe({next:t=>{io(t&&t.type,t?.__emitterName),e.dispatchEvent(new CustomEvent("data",{detail:t})),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onBusEvent(t)},error:t=>console.error("[EVENTS driver] Error in sink stream:",t)}),{select:t=>{ao(t);const n=!t,o=Array.isArray(t)?t:[t];let r;const s=ce.create({start:t=>{r=({detail:e})=>{const r=e&&e.data||null;(n||o.includes(e.type))&&t.next(r)},e.addEventListener("data",r)},stop:()=>{r&&e.removeEventListener("data",r)}});return ue(s)}}}function Fr(t){t.addListener({next:t=>{console.log(t)},error:t=>{console.error("[LOG driver] Error in sink stream:",t)}})}Ir.label="slot",Ir.preventInstantiation=!0;class Br{constructor(){this._connected=!1,this._components=new Map,this._stateHistory=[],this._maxHistory=200}getDiagnostics(){return Jn()}get connected(){return this._connected&&"undefined"!=typeof window}init(){"undefined"!=typeof window&&(window.__SYGNAL_DEVTOOLS__=this,window.addEventListener("message",(t=>{t.source===window&&"__SYGNAL_DEVTOOLS_EXTENSION__"===t.data?.source&&this._handleExtensionMessage(t.data)})))}_handleExtensionMessage(t){switch(t.type){case"CONNECT":this._connected=!0,t.payload?.maxHistory&&(this._maxHistory=t.payload.maxHistory),this._sendFullTree();break;case"DISCONNECT":this._connected=!1;break;case"SET_DEBUG":this._setDebug(t.payload);break;case"TIME_TRAVEL":this._timeTravel(t.payload);break;case"SNAPSHOT":this._takeSnapshot();break;case"RESTORE_SNAPSHOT":this._restoreSnapshot(t.payload);break;case"GET_STATE":this._sendComponentState(t.payload.componentId)}}onComponentCreated(t,e,n){const o={id:t,name:e,isSubComponent:n.isSubComponent,hasModel:!!n.model,hasIntent:!!n.intent,hasContext:!!n.context,hasCalculated:!!n.calculated,components:Object.keys(n.components||{}),parentId:null,children:[],debug:n._debug,createdAt:Date.now(),mviGraph:this._extractMviGraph(n),_instanceRef:new WeakRef(n)};this._components.set(t,o),this.connected&&this._post("COMPONENT_CREATED",this._serializeMeta(o))}onStateChanged(t,e,n){if(!this.connected)return;const o={componentId:t,componentName:e,timestamp:Date.now(),state:this._safeClone(n)};this._stateHistory.push(o),this._stateHistory.length>this._maxHistory&&this._stateHistory.shift(),this._post("STATE_CHANGED",{componentId:t,componentName:e,state:o.state})}onActionDispatched(t,e,n,o){this.connected&&this._post("ACTION_DISPATCHED",{componentId:t,componentName:e,actionType:n,data:this._safeClone(o),timestamp:Date.now()})}onSubComponentRegistered(t,e){const n=this._components.get(t),o=this._components.get(e);n&&o&&(o.parentId=t,n.children.includes(e)||n.children.push(e)),this.connected&&this._post("TREE_UPDATED",{parentId:t,childId:e})}onContextChanged(t,e,n){this.connected&&this._post("CONTEXT_CHANGED",{componentId:t,componentName:e,context:this._safeClone(n),contextTrace:this._buildContextTrace(t,n)})}onPropsChanged(t,e,n){this.connected&&this._post("PROPS_CHANGED",{componentId:t,componentName:e,props:this._safeClone(n)})}onBusEvent(t){this.connected&&this._post("BUS_EVENT",{type:t.type,data:this._safeClone(t.data),componentId:t.__emitterId??null,componentName:t.__emitterName??null,timestamp:Date.now()})}onCommandSent(t,e,n,o){this.connected&&this._post("COMMAND_SENT",{type:t,data:this._safeClone(e),targetComponentName:o??null,timestamp:Date.now()})}onReadyChanged(t,e,n,o){this.connected&&this._post("READY_CHANGED",{parentId:t,parentName:e,childKey:n,ready:o,timestamp:Date.now()})}onCollectionMounted(t,e,n,o){const r=this._components.get(t);r&&(r.collection={itemComponent:n,stateField:o}),this.connected&&this._post("COLLECTION_MOUNTED",{parentId:t,parentName:e,itemComponent:n,stateField:o})}onComponentDisposed(t,e){const n=this._components.get(t);n&&(n.disposed=!0,n.disposedAt=Date.now()),this.connected&&this._post("COMPONENT_DISPOSED",{componentId:t,componentName:e,timestamp:Date.now()})}onDebugLog(t,e){this.connected&&this._post("DEBUG_LOG",{componentId:t,message:e,timestamp:Date.now()})}_setDebug({componentId:t,enabled:e}){if(null==t)return"undefined"!=typeof window&&(window.SYGNAL_DEBUG=!!e&&"true"),void this._post("DEBUG_TOGGLED",{global:!0,enabled:e});const n=this._components.get(t);if(n&&n._instanceRef){const o=n._instanceRef.deref();o&&(o._debug=e,n.debug=e,this._post("DEBUG_TOGGLED",{componentId:t,enabled:e}))}}_timeTravel({componentId:t,componentName:e,state:n}){if(null==t||!n)return void console.warn("[Sygnal DevTools] _timeTravel: missing componentId or state",{componentId:t,hasState:!!n});if("undefined"==typeof window)return;const o=this._safeClone(n),r=this._components.get(t);if(r){const n=r._instanceRef?.deref();if(n){const r=n.stateSourceName||"STATE",s=n.sinks?.[r];if(s?.shamefullySendNext)return s.shamefullySendNext((()=>({...o}))),void this._post("TIME_TRAVEL_APPLIED",{componentId:t,componentName:e,state:o});console.warn(`[Sygnal DevTools] _timeTravel: component #${t} (${e}) has no STATE sink with shamefullySendNext. sinkName=${r}, hasSinks=${!!n.sinks}, sinkKeys=${n.sinks?Object.keys(n.sinks).join(","):"none"}`)}else console.warn(`[Sygnal DevTools] _timeTravel: WeakRef for component #${t} (${e}) has been GC'd`)}else console.warn(`[Sygnal DevTools] _timeTravel: no meta for componentId ${t}`);const s=window.__SYGNAL_DEVTOOLS_APP__;s?.sinks?.STATE?.shamefullySendNext?(s.sinks.STATE.shamefullySendNext((()=>({...o}))),this._post("TIME_TRAVEL_APPLIED",{componentId:t,componentName:e,state:o})):console.warn("[Sygnal DevTools] _timeTravel: no fallback root STATE sink available")}_takeSnapshot(){const t=[];for(const[e,n]of this._components){if(n.disposed)continue;const o=n._instanceRef?.deref();null!=o?.currentState&&t.push({componentId:e,componentName:n.name,state:this._safeClone(o.currentState)})}this._post("SNAPSHOT_TAKEN",{entries:t,timestamp:Date.now()})}_restoreSnapshot(t){if(t?.entries)for(const e of t.entries)this._timeTravel(e)}_sendComponentState(t){const e=this._components.get(t);if(e&&e._instanceRef){const n=e._instanceRef.deref();n&&this._post("COMPONENT_STATE",{componentId:t,state:this._safeClone(n.currentState),context:this._safeClone(n.currentContext),contextTrace:this._buildContextTrace(t,n.currentContext),props:this._safeClone(n.currentProps)})}}_buildContextTrace(t,e){if(!e||"object"!=typeof e)return[];const n=[],o=Object.keys(e);for(const e of o){let o=t,r=!1;for(;null!=o;){const t=this._components.get(o);if(!t)break;if(t.mviGraph?.contextProvides?.includes(e)){n.push({field:e,providerId:t.id,providerName:t.name}),r=!0;break}o=t.parentId}r||n.push({field:e,providerId:-1,providerName:"unknown"})}return n}_sendFullTree(){const t=[];for(const[,e]of this._components){const n=e._instanceRef?.deref();t.push({...this._serializeMeta(e),state:n?this._safeClone(n.currentState):null,context:n?this._safeClone(n.currentContext):null})}this._post("FULL_TREE",{components:t,history:this._stateHistory})}_post(t,e){"undefined"!=typeof window&&window.postMessage({source:"__SYGNAL_DEVTOOLS_PAGE__",type:t,payload:e},"*")}_safeClone(t){if(null==t)return t;try{return JSON.parse(JSON.stringify(t))}catch(t){return"[unserializable]"}}_extractMviGraph(t){if(!t.model)return null;try{const e=t.sourceNames?[...t.sourceNames]:[],n=[],o=t.model;for(const e of Object.keys(o)){let r=e,s=o[e];if(e.includes("|")){const t=e.split("|").map((t=>t.trim()));if(2===t.length&&t[0]&&t[1]){r=t[0],n.push({name:r,sinks:[t[1]]});continue}}"function"!=typeof s?s&&"object"==typeof s&&n.push({name:r,sinks:Object.keys(s)}):n.push({name:r,sinks:[t.stateSourceName||"STATE"]})}return{sources:e,actions:n,contextProvides:t.context&&"object"==typeof t.context?Object.keys(t.context):[]}}catch(t){return null}}_serializeMeta(t){const{_instanceRef:e,...n}=t;return n}}let Ur=null;function Vr(){return Ur||(Ur=new Br),Ur}function Wr(t){if(!t)return null;const e=t.default||t;return"function"!=typeof e?null:t.default?t:{default:e}}function Hr(t){return/^[a-zA-Z0-9-_]+$/.test(t)}function zr(t){if("string"!=typeof t)throw new Error("Class name must be a string");return t.trim().split(" ").reduce(((t,e)=>{if(0===e.trim().length)return t;if(!Hr(e))throw new Error(`${e} is not a valid CSS class name`);return t.push(e),t}),[])}const qr=t=>(t=>"string"==typeof t)(t)||(t=>"number"==typeof t)(t),Jr={svg:1,g:1,defs:1,symbol:1,use:1,circle:1,ellipse:1,line:1,path:1,polygon:1,polyline:1,rect:1,text:1,tspan:1,textPath:1,linearGradient:1,radialGradient:1,stop:1,pattern:1,clipPath:1,mask:1,marker:1,filter:1,feBlend:1,feColorMatrix:1,feComponentTransfer:1,feComposite:1,feConvolveMatrix:1,feDiffuseLighting:1,feDisplacementMap:1,feDropShadow:1,feFlood:1,feGaussianBlur:1,feImage:1,feMerge:1,feMergeNode:1,feMorphology:1,feOffset:1,fePointLight:1,feSpecularLighting:1,feSpotLight:1,feTile:1,feTurbulence:1,feFuncR:1,feFuncG:1,feFuncB:1,feFuncA:1,desc:1,metadata:1,foreignObject:1,switch:1,animate:1,animateMotion:1,animateTransform:1,set:1,mpath:1};var Zr=Object.prototype.hasOwnProperty,Xr=Object.prototype.toString,Kr=Object.defineProperty,Qr=Object.getOwnPropertyDescriptor,ts=function(t){return"function"==typeof Array.isArray?Array.isArray(t):"[object Array]"===Xr.call(t)},es=function(t){if(!t||"[object Object]"!==Xr.call(t))return!1;var e,n=Zr.call(t,"constructor"),o=t.constructor&&t.constructor.prototype&&Zr.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!o)return!1;for(e in t);return void 0===e||Zr.call(t,e)},ns=function(t,e){Kr&&"__proto__"===e.name?Kr(t,e.name,{enumerable:!0,configurable:!0,value:e.newValue,writable:!0}):t[e.name]=e.newValue},os=function(t,e){if("__proto__"===e){if(!Zr.call(t,e))return;if(Qr)return Qr(t,e).value}return t[e]},rs=function t(){var e,n,o,r,s,i,a=arguments[0],c=1,l=arguments.length,u=!1;for("boolean"==typeof a&&(u=a,a=arguments[1]||{},c=2),(null==a||"object"!=typeof a&&"function"!=typeof a)&&(a={});c<l;++c)if(null!=(e=arguments[c]))for(n in e)o=os(a,n),a!==(r=os(e,n))&&(u&&r&&(es(r)||(s=ts(r)))?(s?(s=!1,i=o&&ts(o)?o:[]):i=o&&es(o)?o:{},ns(a,{name:n,newValue:t(u,i,r)})):void 0!==r&&ns(a,{name:n,newValue:r}));return a},ss=o(rs);const is=(...t)=>ss(!1,...t),as=(t,e,n)=>{let o=n;for(let n=0;n<t.length;n++){const s=t[n];r=s,o=Array.isArray(r)?as(s,e,o):e(o,s)}var r;return o},cs=(t,e)=>Object.keys(t).map((n=>e(n,t[n]))).reduce(((t,e)=>((...t)=>ss(!0,...t))(t,e)),{}),ls=(t,e)=>cs(e,((e,n)=>e!==t?{[e]:n}:{})),us=t=>{if(!t||void 0===t.sel)return t;const e=t.data||{},n=e.props||{},o=ls("className",n),r=void 0!==n.className?{class:n.className}:{},s=is({},o,r,e.attrs||{});return is(t,{data:ls("props",is({},e,{ns:"http://www.w3.org/2000/svg",attrs:s}))},{children:Array.isArray(t.children)&&"foreignObject"!==t.sel?t.children.map((t=>us(t))):t.children})},ds=t=>t.sel in Jr?us(t):t,hs={for:"attrs",role:"attrs",tabindex:"attrs","aria-*":"attrs",key:null},ps=(t,e)=>{const{ref:n,...o}=t,r=(t=>{if(!t.props)return t;const{autoFocus:e,autoSelect:n,...o}=t.props;if(!e&&!n)return t;t.props=o,t._autoFocus=!!e,t._autoSelect=!!n;const r=t=>{t&&"function"==typeof t.focus&&requestAnimationFrame((()=>{t.focus(),n&&"function"==typeof t.select&&t.select()}))},s=t.hook?.insert,i=t.hook?.postpatch;return t.hook={...t.hook,insert:t=>{s&&s(t),(e||n)&&r(t.elm)},postpatch:(t,e)=>{i&&i(t,e);const n=t.data?._autoFocus,o=e.data?._autoFocus;!n&&o&&r(e.elm)}},t})(((t,e)=>cs(t,((t,n)=>{const o={[t]:n};if(hs[t]&&void 0!==e[hs[t]])return{[hs[t]]:o};if(null===hs[t])return{};const r=Object.keys(hs);for(let n=0;n<r.length;n++){const s=r[n];if("*"===s.charAt(s.length-1)&&0===t.indexOf(s.slice(0,-1))&&void 0!==e[hs[s]])return{[hs[s]]:o}}return void 0!==e[t]?{[e[t]?e[t]:t]:n}:void 0!==e.props?{props:o}:o})))(((t,e)=>cs(t,((t,n)=>{const o=t.indexOf("-");if(o>-1&&void 0!==e[t.slice(0,o)]){const e={[t.slice(o+1)]:n};return{[t.slice(0,o)]:e}}return{[t]:n}})))(o,e),e));return((t,e)=>{if(!e)return t;const n=t=>{"function"==typeof e?e(t):e&&"object"==typeof e&&"current"in e&&(e.current=t)},o=t.hook?.insert,r=t.hook?.destroy,s=t.hook?.postpatch;return t.hook={...t.hook,insert:t=>{o&&o(t),n(t.elm)},postpatch:(t,e)=>{s&&s(t,e),n(e.elm)},destroy:t=>{r&&r(t),n(null)}},t})(r,n)},fs=t=>t.length>1||!qr(t[0])?void 0:t[0].toString(),ms=t=>as(t,((t,e)=>{const n=(t=>"object"==typeof t&&null!==t)(r=e)&&"sel"in r&&"data"in r&&"children"in r&&"text"in r?e:qr(o=e)?{text:o,sel:void 0,data:void 0,children:void 0,elm:void 0,key:void 0}:void 0;var o,r;return t.push(n),t}),[]),ys=(t=>(e,n,...o)=>{void 0===e&&(e="UNDEFINED",console.error("[Sygnal SYG420] JSX: A JSX tag is undefined, so <UNDEFINED> is rendered instead. Import or define the component in this file. https://sygnal.js.org/reference/errors#syg420"));const r="function"==typeof e;if(r){if(e.__sygnalFragment||"Fragment"===e.name)return e(n||{},o);if(n||(n={}),e.isSygnalComponent){const t=e;e=e.componentName||e.label||e.name||"sygnal-factory",n.sygnalFactory=t}else{const r=e.componentName||e.label||e.name||"FUNCTION_COMPONENT",s=e,{model:i,intent:a,hmrActions:c,context:l,peers:u,components:d,initialState:h,isolatedState:p,calculated:f,storeCalculatedInState:m,DOMSourceName:y,stateSourceName:_,onError:v,debug:g,preventInstantiation:S}=e;if(S)return ds({sel:r,data:n?ps(n,t):{},children:ms(o),text:void 0,elm:void 0,key:n?n.key:void 0});const b={name:r,view:s,model:i,intent:a,hmrActions:c,context:l,peers:u,components:d,initialState:h,isolatedState:p,calculated:f,storeCalculatedInState:m,DOMSourceName:y,stateSourceName:_,onError:v,debug:g};n.sygnalOptions=b,e=r}}const s=r?void 0:fs(o);return ds({sel:e,data:n?ps(n,t):{},children:void 0!==s?void 0:ms(o),text:s,elm:void 0,key:n?n.key:void 0})})({attrs:"",props:"",class:"",data:"dataset",style:"",hook:"",on:""});const _s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),vs={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function gs(t){return String(t).replace(/[&<>"']/g,(t=>vs[t]))}function Ss(t){return t.replace(/^(Webkit|Moz|Ms|O)/,(t=>"-"+t.toLowerCase())).replace(/([A-Z])/g,"-$1").toLowerCase()}function bs(t,e={}){const{state:n,props:o={},context:r={},hydrateState:s}=e,i=void 0!==n?n:t.initialState,a=t.context||{},c={...r};for(const t of Object.keys(a)){const e=a[t];if("function"==typeof e&&null!=i)try{c[t]=e(i)}catch(t){}}let l;try{l=t({...o,state:i,children:o.children||[],slots:o.slots||{},context:c,peers:{}},i,c,{})}catch(e){if("function"==typeof t.onError){const n=t.componentName||t.name||"Component";try{l=t.onError(e,{componentName:n})}catch(t){l={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}}else l={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}l||(l={sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0}),l=ws(l,c,i);let u=As(l);if(s&&null!=i){const t="string"==typeof s?s:"__SYGNAL_STATE__";gs(JSON.stringify(i)),u+=`<script>window.${t}=${JSON.stringify(i)}<\/script>`}return u}function ws(t,e,n){if(!t)return t;if("string"==typeof t||null!=t.text)return t;const o=t.sel;if(!o&&t.children&&Array.isArray(t.children))return t.children=t.children.map((t=>ws(t,e,n))).filter((t=>null!=t)),t;if("portal"===o){const o=t.children||[];return 0===o.length?null:1===o.length?ws(o[0],e,n):{sel:"div",data:{attrs:{"data-sygnal-portal":""}},children:o.map((t=>ws(t,e,n))),text:void 0,elm:void 0,key:void 0}}if("transition"===o){const o=(t.children||[])[0];return o?ws(o,e,n):null}if("suspense"===o){const o=t.children||[];return 0===o.length?null:1===o.length?ws(o[0],e,n):{sel:"div",data:{attrs:{"data-sygnal-suspense":"resolved"}},children:o.map((t=>ws(t,e,n))),text:void 0,elm:void 0,key:void 0}}if("clientonly"===o){const o=(t.data?.props||{}).fallback;return o?ws(o,e,n):{sel:"div",data:{attrs:{"data-sygnal-clientonly":""}},children:[],text:void 0,elm:void 0,key:void 0}}if("slot"===o){const o=t.children||[];return 0===o.length?null:1===o.length?ws(o[0],e,n):{sel:"div",data:{},children:o.map((t=>ws(t,e,n))),text:void 0,elm:void 0,key:void 0}}const r=t.data?.props||{};return r.sygnalOptions||"function"==typeof r.sygnalFactory?function(t,e,n){const o=t.data?.props||{},{sygnalOptions:r,sygnalFactory:s,...i}=o;let a;if(r)a=r.view,!a.initialState&&r.initialState&&(a=Object.assign(a,{initialState:r.initialState,model:r.model,intent:r.intent,context:r.context,onError:r.onError,calculated:r.calculated}));else if(s&&s.componentName)return{sel:"div",data:{attrs:{"data-sygnal-ssr":t.sel||"component"}},children:t.children||[],text:void 0,elm:void 0,key:void 0};if(!a||"function"!=typeof a)return{sel:"div",data:{attrs:{"data-sygnal-ssr":t.sel||"component"}},children:t.children||[],text:void 0,elm:void 0,key:void 0};let c=a.initialState;const l=i.state;"string"==typeof l&&null!=n&&null!=n[l]?c=n[l]:null!=l&&"string"!=typeof l&&(c=l);const u={...e},d=a.context||{};for(const t of Object.keys(d)){const e=d[t];if("function"==typeof e&&null!=c)try{u[t]=e(c)}catch(t){}}const h={},p=[],f=t.children||[];for(const t of f)if(t&&"slot"===t.sel){const e=t.data?.props?.name||"default";h[e]||(h[e]=[]);const n=t.children||[];h[e].push(...n)}else p.push(t);p.length>0&&(h.default||(h.default=[]),h.default.push(...p));let m;try{m=a({...i,state:c,children:h.default||f,slots:h,context:u,peers:{}},c,u,{})}catch(t){if("function"==typeof a.onError){const e=a.componentName||a.name||"Component";try{m=a.onError(t,{componentName:e})}catch(t){m={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}}else m={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}m||(m={sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0});return ws(m,u,c)}(t,e,n):"collection"===o?function(t,e,n){const o=t.data?.props||{},{of:r,from:s,className:i}=o;if(!r||!s||!n)return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};const a=n[s];if(!Array.isArray(a))return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};const c=a.map(((t,n)=>{const o={...e},s=r.context||{};for(const e of Object.keys(s)){const n=s[e];if("function"==typeof n)try{o[e]=n(t)}catch(t){}}let i;try{i=r({state:t,children:[],slots:{},context:o,peers:{}},t,o,{})}catch(t){if("function"==typeof r.onError)try{i=r.onError(t,{componentName:r.name||"CollectionItem"})}catch(t){i={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}else i={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}return ws(i,o,t)})).filter((t=>null!=t)),l={};i&&(l.props={className:i});return{sel:"div",data:l,children:c,text:void 0,elm:void 0,key:void 0}}(t,e,n):"switchable"===o?function(t,e,n){const o=t.data?.props||{},{components:r,active:s,initial:i}=o;if(!r)return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};let a;"string"==typeof s&&(r[s]?a=s:n&&"string"==typeof n[s]&&(a=n[s]));!a&&i&&(a=i);a||(a=Object.keys(r)[0]);const c=r[a];if(!c||"function"!=typeof c)return{sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0};return function(t,e,n){const o=void 0!==e?e:t.initialState,r=t.context||{},s={...n};for(const t of Object.keys(r)){const e=r[t];if("function"==typeof e&&null!=o)try{s[t]=e(o)}catch(t){}}let i;try{i=t({state:o,children:[],slots:{},context:s,peers:{}},o,s,{})}catch(e){if("function"==typeof t.onError)try{i=t.onError(e,{componentName:t.name||"Component"})}catch(t){i={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}else i={sel:"div",data:{attrs:{"data-sygnal-error":""}},children:[],text:void 0,elm:void 0,key:void 0}}i||(i={sel:"div",data:{},children:[],text:void 0,elm:void 0,key:void 0});return ws(i,s,o)}(c,n,e)}(t,e,n):(t.children&&(Array.isArray(t.children)?t.children.length>0&&(t.children=t.children.map((t=>ws(t,e,n))).filter((t=>null!=t))):t.children&&"object"==typeof t.children&&(t.children=ws(t.children,e,n))),t)}function As(t){if(null==t)return"";if("string"==typeof t)return gs(t);if(null!=t.text&&!t.sel)return gs(String(t.text));const e=t.sel;if(!e)return null!=t.text?gs(String(t.text)):t.children&&Array.isArray(t.children)?t.children.map((t=>As(t))).join(""):"";const{tag:n,id:o,selectorClasses:r}=function(t){let e=t,n=null;const o=[],r=t.indexOf("#");if(-1!==r){const s=t.slice(r+1),i=s.indexOf(".");if(-1!==i){n=s.slice(0,i),e=t.slice(0,r);const a=s.slice(i+1);a&&o.push(...a.split("."))}else n=s,e=t.slice(0,r)}else{const n=t.indexOf(".");if(-1!==n){e=t.slice(0,n);const r=t.slice(n+1);r&&o.push(...r.split("."))}}e||(e="div");return{tag:e,id:n,selectorClasses:o}}(e),s=function(t,e,n){const o=[],r=[...n];if(t.props)for(const[e,n]of Object.entries(t.props))"className"===e?"string"==typeof n&&n&&r.push(n):"htmlFor"===e?o.push(["for",n]):"innerHTML"===e||"textContent"===e||"sygnalOptions"===e||"sygnalFactory"===e||("boolean"==typeof n?n&&o.push([e,!0]):null!=n&&o.push([e,n]));if(t.attrs)for(const[e,n]of Object.entries(t.attrs))"class"===e?"string"==typeof n&&n&&r.push(n):"boolean"==typeof n?n&&o.push([e,!0]):null!=n&&o.push([e,n]);if(t.class)for(const[e,n]of Object.entries(t.class))n&&r.push(e);if(t.dataset)for(const[e,n]of Object.entries(t.dataset))null!=n&&o.push([`data-${Ss(e)}`,n]);e&&o.unshift(["id",e]);if(r.length>0){const t=[...new Set(r)];o.unshift(["class",t.join(" ")])}if(t.style&&"object"==typeof t.style){const e=function(t){const e=[];for(const n of Object.keys(t)){const o=t[n];if(null==o||""===o)continue;if("delayed"===n||"remove"===n||"destroy"===n)continue;const r=Ss(n);e.push(`${r}: ${o}`)}return e.join("; ")}(t.style);e&&o.push(["style",e])}return o}(t.data||{},o,r);let i=`<${n}`;for(const[t,e]of s)!0===e?i+=` ${t}`:!1!==e&&null!=e&&(i+=` ${t}="${gs(String(e))}"`);if(i+=">",_s.has(n))return i;if(null!=t.data?.props?.innerHTML)return i+=String(t.data.props.innerHTML),i+=`</${n}>`,i;if(null!=t.text)i+=gs(String(t.text));else if(t.children){const e=Array.isArray(t.children)?t.children:[t.children];for(const t of e)i+=As(t)}return i+=`</${n}>`,i}const Es=t=>t.startsWith(".___"),Ns=t=>Os(t.filter((t=>!Es(t))).join(" ")),Os=t=>t.trim().replace(/\s*>\s*/g," > ").replace(/\s+/g," "),Cs=/^(document|body)(\s+|$)/,Ts=t=>{const e={};for(const n in t)null!=t[n]&&(e[n]=String(t[n]));return e},ks="tag, *, .class, #id, [attr], [attr=\"v\"] (also ^= $= *= ~=), :first-child, :last-child, :only-child, :nth-child(an+b|odd|even), :nth-last-child(), :first-of-type, :last-of-type, :only-of-type, :nth-of-type(), :nth-last-of-type(), :not(...), the descendant (' ') and child ('>') combinators, ',' lists",$s=/^(?:[\w-]|\\.)+/,xs=t=>t.replace(/\\(.)/g,"$1"),Ls=new Map;function Ds(t){let e=Ls.get(t);if(!e){try{e=function(t){let e=0;const n=e=>{const n=new Error(`[Sygnal] Unsupported selector syntax in '${t}': ${e}. Supported: ${ks}. Or give the element an attribute and select it, e.g. [data-id="3"]`);throw n.unsupported=!0,n},o=()=>{const n=t.slice(e).match(/^\s*/)[0].length;return e+=n,n>0},r=o=>{const r=t.slice(e).match($s);return r?(e+=r[0].length,xs(r[0])):n(`expected ${o} at '${t.slice(e)||"end"}'`)},s=t=>{const e=t.trim().toLowerCase().replace(/\s+/g,"");if("odd"==e)return[2,1];if("even"==e)return[2,0];if(/^[+-]?\d+$/.test(e))return[0,+e];const o=e.match(/^([+-]?\d*)n([+-]\d+)?$/);return o?[""==o[1]||"+"==o[1]?1:"-"==o[1]?-1:+o[1],o[2]?+o[2]:0]:n(`'${t}' is not an+b`)},i=()=>{const o={cls:[],attrs:[],ps:[]},i=e;for("*"==t[e]?e++:$s.test(t.slice(e))&&(o.tag=r("tag").toLowerCase());;){const i=t[e];if("."==i)e++,o.cls.push(r("a class name"));else if("#"==i)e++,o.id=r("an id");else if("["==i){const r=t.slice(e).match(/^\[\s*((?:[\w-]|\\.)+)\s*(?:([~^$*|]?=)\s*(?:"([^"]*)"|'([^']*)'|((?:[\w-]|\\.)+))\s*)?\]/);if(!r)return n(`attribute selector '${t.slice(e)}'`);"|="==r[2]&&n("the '|=' attribute operator"),e+=r[0].length,o.attrs.push([xs(r[1]),r[2]||"",r[2]?r[3]??r[4]??xs(r[5]):void 0])}else{if(":"!=i)break;{":"==t[e+1]&&n("pseudo-elements"),e++;const i=r("a pseudo-class").toLowerCase();let a;if("("==t[e]){let o=0,r=e;for(;r<t.length;r++)if("("==t[r])o++;else if(")"==t[r]&&! --o)break;r>=t.length&&n(`unclosed ':${i}('`),a=t.slice(e+1,r),e=r+1}const c={k:i,a:0,b:1},l=i.match(/^(?:(first|last|only)|nth(-last)?)-(child|of-type)$/);l&&void 0===a==!!l[1]?(c.type="of-type"==l[3],"only"==l[1]?c.k="only":l[1]?c.last="last"==l[1]:(/\bof\b/.test(a)&&n(`':${i}(... of S)'`),[c.a,c.b]=s(a),c.last=!!l[2])):"not"==i&&void 0!==a?(c.not=Ds(a),c.not.some((t=>t.parts.length>1))&&n("combinators inside ':not()'")):n(`':${i}${void 0===a?"":"("+a+")"}'`),o.ps.push(c)}}}return e==i&&n(`unexpected '${t[e]||"end of selector"}'`),o},a=[];if(o(),e>=t.length)return a;for(;;){const r={parts:[i()],combs:[]};for(;;){const s=o(),a=t[e];if(e>=t.length||","==a)break;"+"!=a&&"~"!=a||n(`the '${a}' combinator`),">"==a?(e++,o(),r.combs.push(">")):s?r.combs.push(" "):n(`unexpected '${a}'`),r.parts.push(i())}if(a.push(r),e>=t.length)return a;e++,o()}}(t)}catch(t){e=t}Ls.set(t,e)}if(e instanceof Error)throw e;return e}const Gs=t=>{try{return Ds(t)}catch(t){return}};function js(t){const e=[];for(const n of[].concat(t.children||[]))n&&"object"==typeof n&&(n.sel?"!"!=n.sel&&e.push(n):n.children&&e.push(...js(n)));return e}const Is=new WeakMap;const Ms=t=>t.sel.split(/[.#]/)[0].toLowerCase();function Ps(t,e){const n=(t,o,r)=>{if(r<0||!function(t,e){const n=t.data||{},o=n.props||{},r=n.attrs||{},[s,...i]=t.sel.split("."),[a,c]=s.split("#");if(e.tag&&a.toLowerCase()!=e.tag)return!1;const l=c||o.id||r.id;if(void 0!==e.id&&l!=e.id)return!1;if(e.cls.length){const t=i.concat(`${o.className||""} ${r.class||""}`.split(" "),Object.keys(n.class||{}).filter((t=>n.class[t])));if(!e.cls.every((e=>t.includes(e))))return!1}for(const[t,s,i]of e.attrs){const e="id"==t?l:t in r?r[t]:t in o?o[t]:t.startsWith("data-")?Ts(n.dataset)[t.slice(5).replace(/-(\w)/g,((t,e)=>e.toUpperCase()))]:void 0;if(null==e||!1===e)return!1;const a=String(e);if(s&&!("="==s?a==i:i&&("^="==s?a.startsWith(i):"$="==s?a.endsWith(i):"*="==s?a.includes(i):a.split(/\s+/).includes(i))))return!1}for(const n of e.ps){if(n.not){if(Ps(n.not,[t]))return!1;continue}let e=(Is.get(t)||{sibs:[t]}).sibs;if(n.type&&(e=e.filter((e=>Ms(e)==Ms(t)))),"only"==n.k){if(1!=e.length)return!1;continue}const o=e.indexOf(t),r=n.last?e.length-o:o+1;if(0==n.a?r!=n.b:(r-n.b)/n.a<0||(r-n.b)%n.a!=0)return!1}return!0}(e[r],t.parts[o]))return!1;if(0==o)return!0;if(">"==t.combs[o-1]){const s=Is.get(e[r]);return r>0&&(!s||e[r-1]===s.p)&&n(t,o-1,r-1)}for(let e=r-1;e>=0;e--)if(n(t,o-1,e))return!0;return!1};return t.some((t=>n(t,t.parts.length-1,e.length-1)))}function Ys(t,e,n=[]){if(!t||"object"!=typeof t)return;const o=t.sel?n.concat(t):n;if(t.sel&&Ps(e,o))return o;for(const n of[].concat(t.children||[],t.data?.portalChildren||[])){const t=Ys(n,e,o);if(t)return t}}let Rs=0;let Fs,Bs;function Us(t,e){return"function"==typeof e?(n,o,r,s)=>({type:t,data:e(n,o,r,s)}):()=>({type:t,data:e})}const Vs=zo;function Ws(t,e){const n=(t,n)=>e.dispatchEvent(new CustomEvent("data",{detail:{type:t,data:n}}));t.addEventListener("statechange",(()=>{"installed"===t.state&&n("installed",!0),"activated"===t.state&&n("activated",!0)})),"installed"===t.state&&n("waiting",t),"activated"===t.state&&n("activated",!0)}let Hs;const zs=Vs.create({start(t){if("undefined"==typeof window)return void t.next(!0);t.next(navigator.onLine);const e=()=>t.next(!0),n=()=>t.next(!1);window.addEventListener("online",e),window.addEventListener("offline",n),Hs=()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}},stop(){Hs?.(),Hs=void 0}});class qs{constructor(t,e){this.out=t,this.op=e}_n(t){this.out._n(t)}_e(t){this.out._e(t)}_c(){this.op.less()}}class Js{constructor(t){this.ins=t,this.type="flattenConcurrently",this.active=1,this.out=null}_start(t){this.out=t,this.ins._add(this)}_stop(){this.ins._remove(this),this.active=1,this.out=null}less(){0==--this.active&&this.out&&this.out._c()}_n(t){this.out&&(this.active++,t._add(new qs(this.out,this)))}_e(t){this.out&&this.out._e(t)}_c(){this.less()}}class Zs{constructor(t){this.ins=t,this.type="flattenSequentially",this.out=null,this.open=!0,this.active=null,this.activeIL=null,this.seq=[]}_start(t){this.out=t,this.open=!0,this.active=null,this.activeIL=new qs(t,this),this.seq=[],this.ins._add(this)}_stop(){this.ins._remove(this),this.active&&this.activeIL&&this.active._remove(this.activeIL),this.open=!0,this.active=null,this.activeIL=null,this.seq=[],this.out=null}less(){this.active=null,this.seq.length>0&&this._n(this.seq.shift()),this.open||this.active||this.out._c()}_n(t){this.out&&(this.active?this.seq.push(t):(this.active=t,t._add(this.activeIL)))}_e(t){this.out&&this.out._e(t)}_c(){this.out&&(this.open=!1,this.active||0!==this.seq.length||this.out._c())}}t.ABORT=dr,t.Collection=Ho,t.MainDOMSource=co,t.MockedDOMSource=Po,t.Portal=Dr,t.Slot=Ir,t.Suspense=jr,t.Switchable=Ko,t.Transition=Gr,t.classes=function(...t){return t.reduce(((t,e)=>{var n,o;return"string"!=typeof e||t.includes(e)?Array.isArray(e)?t.push(...(o=e,o.map(zr).flat())):"object"==typeof e&&t.push(...(n=e,Object.entries(n).filter((([t,e])=>"function"==typeof e?e():!!e)).map((([t,e])=>{const n=t.trim();if(!Hr(n))throw new Error(`${n} is not a valid CSS class name`);return n})))):t.push(...zr(e)),t}),[]).join(" ")},t.clearDiagnostics=function(){Yn=[]},t.collection=Wo,t.component=fr,t.concat=me,t.createCommand=function(){const t={next:()=>{}},e={send:(n,o)=>{t.next({type:n,data:o}),"undefined"!=typeof window&&window.__SYGNAL_DEVTOOLS__?.connected&&window.__SYGNAL_DEVTOOLS__.onCommandSent(n,o,e._targetComponentId,e._targetComponentName)},_stream:zo.create({start(e){t.next=t=>e.next(t)},stop(){t.next=()=>{}}}),__sygnalCommand:!0};return e},t.createElement=ys,t.createInstallPrompt=function(){let t=null;const e=new EventTarget;return"undefined"!=typeof window&&(window.addEventListener("beforeinstallprompt",(n=>{n.preventDefault(),t=n,e.dispatchEvent(new CustomEvent("data",{detail:{type:"beforeinstallprompt",data:!0}}))})),window.addEventListener("appinstalled",(()=>{t=null,e.dispatchEvent(new CustomEvent("data",{detail:{type:"appinstalled",data:!0}}))}))),{select(t){let n;return ue(Vs.create({start:o=>{n=({detail:e})=>{e.type===t&&o.next(e.data)},e.addEventListener("data",n)},stop:()=>{n&&e.removeEventListener("data",n)}}))},prompt:()=>t?.prompt()}},t.createRef=function(){return{current:null}},t.createRef$=function(){const t={next:()=>{}},e=zo.createWithMemory({start(e){t.next=t=>e.next(t)},stop(){t.next=()=>{}}});return new Proxy({current:null,stream:e},{set:(e,n,o)=>"current"===n?(e.current=o,t.next(o),!0):(e[n]=o,!0)})},t.debounce=ve,t.delay=be,t.driverFromAsync=function(t,e={}){const{selector:n="category",args:o="value",return:r="value",pre:s=(t=>t),post:i=(t=>t)}=e,a=t.name||"[anonymous function]",c=typeof o;if(!("string"===c||"function"===c||Array.isArray(o)&&o.every((t=>"string"==typeof t))))throw new Error(`The 'args' option for driverFromAsync(${a}) must be a string, array of strings, or a function. Received ${c}`);if("string"!=typeof n)throw new Error(`The 'selector' option for driverFromAsync(${a}) must be a string. Received ${typeof n}`);return e=>{let c=null;const l=ce.create({start:t=>{c=t.next.bind(t)},stop:()=>{}}),u=new Set,d=(t,e)=>void 0===t||("function"==typeof t?t(e):e?.[n]===t);let h=!1;return e.addListener({next:e=>{const l=s(e);let h=[];if("object"==typeof l&&null!==l){if("function"==typeof o){const t=o(l);h=Array.isArray(t)?t:[t]}"string"==typeof o&&(h=[l[o]]),Array.isArray(o)&&(h=o.map((t=>l[t])))}const p=`Error in driver created using driverFromAsync(${a})`;t(...h).then((t=>{return null!=(n=t)&&"function"==typeof n.then?t.then((t=>i(t,e))):i(t,e);var n})).then((t=>{let o;if(void 0===r)o=t,"object"==typeof o&&null!==o?o[n]=e[n]:console.warn(`The 'return' option for driverFromAsync(${a}) was not set, but the promise returned an non-object. The result will be returned as-is, but the '${n}' property will not be set, so will not be filtered by the 'select' method of the driver.`);else{if("string"!=typeof r)throw new Error(`The 'return' option for driverFromAsync(${a}) must be a string. Received ${typeof r}`);o={[r]:t,[n]:e[n]}}return o})).then((t=>{try{c(t)}catch(t){console.error(`${p}: ${t}`)}}),(t=>{const o={error:t,[n]:e?.[n],request:e};let r=!1;u.forEach((t=>{let e=!1;try{e=d(t.selector,o)}catch(t){}e&&(r=!0,t.listener.next(o))})),r||console.error(`${p}: ${t}`)}))},error:t=>{console.error(`Error received from sink stream in driver created using driverFromAsync(${a}):`,t)},complete:()=>{h||console.warn(`Unexpected completion of sink stream to driver created using driverFromAsync(${a})`)}}),{dispose:()=>{h=!0},select:t=>((t,e)=>void 0===e?t:t.filter((t=>d(e,t))))(l,t),errors:t=>{let e;return ce.create({start:n=>{u.add(e={listener:n,selector:t})},stop:()=>{u.delete(e)}})}}}},t.dropRepeats=Ee,t.emit=function(t,e){return{EVENTS:Us(t,e)}},t.enableHMR=function(t,e,n,o){if(!t||"function"!=typeof t.hmr)return t;if(!e||"function"!=typeof e.accept)return t;let r=!1;const s=e=>{Promise.resolve((async e=>{if(r)return;r=!0;const o=Array.isArray(e)?e.find(Boolean):e;try{let e=Wr(o);if(e||"function"!=typeof n||(e=Wr(await n())),e){const n=t?.sources?.STATE?.stream?._v;t.hmr(e,n)}}finally{r=!1}})(e)).catch((()=>{}))};return void 0!==o&&e.accept(o,s),e.accept(s),"function"==typeof e.dispose&&"function"==typeof t.dispose&&e.dispose((()=>t.dispose())),t},t.event=Us,t.exactState=function(){return t=>t},t.flattenConcurrently=function(t){return new re(new Js(t))},t.flattenSequentially=function(t){return new re(new Zs(t))},t.getDevTools=Vr,t.getDiagnostics=Jn,t.h=ze,t.lazy=function(t){let e=null,n=null;function o(t){return n?{sel:"div",data:{attrs:{"data-sygnal-error":"lazy"}},children:[],text:void 0,elm:void 0,key:void 0}:e?e(t):{sel:"div",data:{attrs:{"data-sygnal-lazy":"loading"}},children:[],text:void 0,elm:void 0,key:void 0}}const r=t().then((t=>{e=t.default||t,o.__sygnalLazyLoadedComponent=e;const n=["model","intent","hmrActions","context","peers","components","initialState","calculated","storeCalculatedInState","DOMSourceName","stateSourceName","onError","debug","componentName"];for(const t of n)void 0!==e[t]&&void 0===o[t]&&(o[t]=e[t])})).catch((t=>{n=t,console.error("[lazy] Failed to load component:",t)}));return o.__sygnalLazy=!0,o.__sygnalLazyLoaded=()=>null!==e,o.__sygnalLazyLoadedComponent=null,o.__sygnalLazyPromise=r,o.__sygnalLazyReRenderScheduled=!1,o},t.makeDOMDriver=Io,t.makeDragDriver=function(){return function(t){const e=new Map,n=new EventTarget,o=[];let r=null;const s=t=>{if(!t?.category)return;const n=e.get(t.category)??{};e.set(t.category,{...n,...t})};t.subscribe({next(t){(t?.configs??(Array.isArray(t)?t:[t])).forEach(s)},error(){},complete(){}});const i=(t,e)=>n.dispatchEvent(new CustomEvent(t,{detail:e})),a=(t,e)=>{document.addEventListener(t,e),o.push([t,e])};a("dragstart",(t=>{const n=t;for(const[t,o]of e){if(!o.draggable)continue;const e=n.target.closest(o.draggable);if(e){if(r=t,n.dataTransfer.effectAllowed="move",o.dragImage){const t=e.closest(o.dragImage);if(t){const e=t.getBoundingClientRect();n.dataTransfer.setDragImage(t,n.clientX-e.left,n.clientY-e.top)}}return void i(`${t}:dragstart`,{element:e,dataset:{...e.dataset}})}}})),a("dragend",(()=>{r&&(i(`${r}:dragend`,null),r=null)})),a("dragover",(t=>{const n=t;for(const[,t]of e)if(t.dropZone&&(!r||!t.accepts||t.accepts===r)&&n.target.closest(t.dropZone))return void n.preventDefault()})),a("drop",(t=>{const n=t;for(const[t,o]of e){if(!o.dropZone)continue;if(r&&o.accepts&&o.accepts!==r)continue;const s=n.target.closest(o.dropZone);if(!s)continue;n.preventDefault();let a=null;const c=r?e.get(r):null;return c?.draggable&&(a=n.target.closest(c.draggable)??null),void i(`${t}:drop`,{dropZone:s,insertBefore:a})}}));const c={select:t=>({events(e){const o=`${t}:${e}`;let r;return Mr(ce.create({start(t){r=({detail:e})=>t.next(e),n.addEventListener(o,r)},stop(){r&&n.removeEventListener(o,r)}}))}}),dragstart:t=>c.select(t).events("dragstart"),dragend:t=>c.select(t).events("dragend"),drop:t=>c.select(t).events("drop"),dragover:t=>c.select(t).events("dragover"),dispose(){o.forEach((([t,e])=>document.removeEventListener(t,e)))}};return c}},t.makeServiceWorkerDriver=function(t,e={}){return function(n){const o=new EventTarget;return"undefined"!=typeof navigator&&"serviceWorker"in navigator&&(navigator.serviceWorker.register(t,{scope:e.scope}).then((t=>{const e=(t,e)=>o.dispatchEvent(new CustomEvent("data",{detail:{type:t,data:e}}));t.installing&&Ws(t.installing,o),t.waiting&&e("waiting",t.waiting),t.active&&e("activated",!0),t.addEventListener("updatefound",(()=>{t.installing&&Ws(t.installing,o)})),navigator.serviceWorker.addEventListener("controllerchange",(()=>{e("controlling",!0)})),navigator.serviceWorker.addEventListener("message",(t=>{e("message",t.data)}))})).catch((t=>{o.dispatchEvent(new CustomEvent("data",{detail:{type:"error",data:t}}))})),n.addListener({next:t=>{"skipWaiting"===t.action?navigator.serviceWorker.ready.then((t=>{t.waiting&&t.waiting.postMessage({type:"SKIP_WAITING"})})):"postMessage"===t.action?navigator.serviceWorker.ready.then((e=>{e.active&&e.active.postMessage(t.data)})):"unregister"===t.action&&navigator.serviceWorker.ready.then((t=>t.unregister()))},error:t=>console.error("[SW driver] Error in sink stream:",t)})),{select(t){let e;return ue(Vs.create({start:n=>{e=({detail:e})=>{t&&e.type!==t||n.next(e.data)},o.addEventListener("data",e)},stop:()=>{e&&o.removeEventListener("data",e)}}))}}}},t.mockDOMSource=Yo,t.onDiagnostic=Zn,t.onlineStatus$=zs,t.portal=Dr,t.processDrag=function({draggable:t,dropZone:e}={},n={}){if(t&&"function"!=typeof t.events)throw new Error("processDrag: draggable must have an .events() method (e.g. DOM.select(...))");if(e&&"function"!=typeof e.events)throw new Error("processDrag: dropZone must have an .events() method (e.g. DOM.select(...))");const{effectAllowed:o="move"}=n;return{dragStart$:t?t.events("dragstart").map((t=>(t.dataTransfer.effectAllowed=o,t))):ce.never(),dragEnd$:t?t.events("dragend").mapTo(null):ce.never(),dragOver$:e?e.events("dragover").map((t=>(t.preventDefault(),null))):ce.never(),drop$:e?e.events("drop").map((t=>(t.preventDefault(),t))):ce.never()}},t.processForm=function(t,e={}){if(!t||"function"!=typeof t.events)throw new Error("processForm: first argument must have an .events() method (e.g. DOM.select(...))");let{events:n=["input","submit"],preventDefault:o=!0}=e;"string"==typeof n&&(n=[n]);const r=n.map((e=>t.events(e)));return ce.merge(...r).map((t=>{o&&t.preventDefault();const e="submit"===t.type?t.srcElement:t.currentTarget,n=new FormData(e),r={event:t,eventType:t.type},s=e.querySelector("input[type=submit]:focus");if(s){const{name:t,value:e}=s;r[t||"submit"]=e}for(const[t,e]of n.entries())r[t]=e;return r}))},t.renderComponent=function(t,e={}){const{initialState:n,mockConfig:o={},drivers:r={},diagnostics:s,strict:i}=e,{intent:a,model:c={}}=t,l=Vn(),u=globalThis.__SYGNAL_DIAGNOSTICS__;Rs++||(Fs={mode:jn,ignore:[...Pn]},Bs=u.strict,u.resetOnce?.()),Un({mode:s||("off"==l?"collect":l)}),void 0!==i&&(u.strict=i);const d=[],h=Zn((t=>d.push(t))),p=t.name||t.componentName||"TestComponent",f=new Map,m=new Map;let y=!1;const _=new Map([["",p]]),v=new Map,g={},S=new Set,b=t=>{const e=t&&t.sources&&t.sources[t.DOMSourceName||"DOM"];return e&&e._hub===j.$&&(e._path||[]).filter(Es).pop()};let w=0,A=Date.now();const E=()=>{w++,A=Date.now()},N=Xn({id:"renderComponent",onRender:E,onReducer:E,onIntent(t){E();const e=b(t);e&&_.set(e,t.name),t.sources[t.DOMSourceName||"DOM"]?._hub==j.$&&v.set(e||"",t._componentNumber)},onDispose(t){const e=b(t);e&&(_.delete(e),v.delete(e),f.forEach(((t,n)=>{t.filter(Es).pop()==e&&f.delete(n)})))}}),O=(t,e,n,o,r)=>{try{qn(t,{component:e,message:n,fix:o,data:r})}catch(t){setTimeout((()=>{throw t}))}};let C,T=!1;const k=(t,e,n)=>{let o,r=!1,s=!n;const i=Gs(Array.isArray(t)?t.join(" "):t);if(!i||!i.length)return{own:r,child:o,hit:!1};const a=(t,e)=>Ps(i,e),c=(t,i,l,u,d)=>{if(!t||!t.sel||r)return;const h=(t.sel.match(/\.___[^.#]+/)||[])[0]||l,p=i.concat([[t,h]]);(u=u||h==e)&&(h==e?a(0,p.filter((t=>t[1]==e)).map((t=>t[0])))&&(r=!0):(d=d||h,a(0,p.map((t=>t[0])))&&(o=o||d,t===n&&(s=!0))));for(const n of[].concat(t.children||[]))c(n,p,h,u,h==e?void 0:d)};return c(dt,[],void 0,!e,void 0),{own:r,child:o,hit:s}},$=t=>{dt&&Mn&&(t||dt!==C||T)&&(t||(C=dt,T=!1),f.forEach((e=>{const n=Ns(e),o=e.filter(Es).pop(),r=_.get(o||"")||"Component",s=r+"\0"+n;if(!n||Cs.test(n)||S.has(s))return;const{own:i,child:a,hit:c}=k(n,o,t);if(i)return S.add(s);if(!a||!c)return;S.add(s);const l=_.get(a)||"a child component";O("SYG104",r,`DOM.select('${n}') in ${r} matches elements inside ${l} (isolated), so ${r} never receives their events`,`Handle the event in ${l} and send it up with PARENT (read it here with CHILD.select(${l})), or use EVENTS`,{selector:n,child:l})})))},x=()=>{N(),h(),--Rs||(Un(Fs),u.strict=Bs)},L=()=>{},D=()=>{const t={emit:L,$:null};return t.$=zo.create({start:e=>{t.emit=t=>e.next(t)},stop:()=>{t.emit=L}}),t},G=D(),j=D(),I=Object.keys(c).map((t=>t.split("|")[0].trim())).filter((t=>"INITIALIZE"!=t)),M=t=>G.$.filter((e=>e.type==t)).map((t=>t.data)),{context:P,calculated:Y,storeCalculatedInState:R,onError:F,hmrActions:B,components:U}=t,V=void 0!==n?n:t.initialState,W=!a&&!Object.keys(c).length&&void 0===V,H=fr({name:t.name||t.componentName||"TestComponent",view:t,intent:W?void 0:t=>{const e=a?a(t):{};if(e&&"function"==typeof e.addListener)return zo.merge(e,G.$);const n={...e},o=I.filter((t=>!(t in n)));for(const t of new Set([...Object.keys(n),...o]))n[t]=n[t]?zo.merge(n[t],M(t)):M(t);return Object.defineProperty(n,"__sygnalTestActions",{value:o}),n},model:W?void 0:c,hmrActions:B,components:U,context:P,calculated:Y,storeCalculatedInState:R,onError:F,initialState:V}),z={DOM:()=>Yo(o,j.$,((t,e,n)=>{const o=t.join("\0");if(void 0===n)f.has(o)||(f.set(o,t),T=!0),(g[o]=g[o]||[]).push(e);else{const t=o+"\0"+e;m.set(t,(m.get(t)||0)+(n?1:-1)),n&&at(0)}})),EVENTS:Rr,LOG:Fr,...r};for(const t in c){const e=c[t],[,n]=t.split("|");for(const t of n?[n.trim()]:e&&"object"==typeof e?Object.keys(e):[])z[t]||/^(STATE|EFFECT|PARENT|READY)$/.test(t)||(z[t]=()=>({select:()=>zo.never()}))}let q,J,Z;try{const t=Yr(Be(H,"STATE"),z);({sources:q,sinks:J}=t),Z=t.run()}catch(t){throw x(),t}const X=[],K=(t,e)=>{const n={next:e,error:L,complete:L};t.addListener(n),X.push([t,n])},Q=[],tt=q.STATE?.stream||zo.never();K(tt,(t=>{Q.push(t),E()}));const et={},nt=t=>et[t]=et[t]||[];for(const t in J)"DOM"!=t&&"STATE"!=t&&"function"==typeof J[t]?.addListener&&K(J[t],(e=>nt(t).push("EVENTS"==t?{type:e.type,data:e.data}:"PARENT"==t?e.value:e)));const ot=[];let rt,st=!1;const it=()=>{if(st&&!y)for(;ot.length;){const t=ot[0];if(t.until=t.until||Date.now()+300,!t.go(Date.now()>=t.until))return at(5);ot.shift(),E()}},at=t=>{!rt&&ot.length&&(rt=setTimeout((()=>{rt=0,it()}),t))};let ct;const lt=new Promise((t=>{ct=()=>{st=!0,it(),t()}})),ut=(t,e)=>{ot.push({go:t,missing:e}),it()};let dt,ht,pt=0;const ft=()=>ht||(ht=setTimeout((()=>ct()),12));J.DOM&&K(J.DOM,(t=>{dt=t,function(t){if(!t||"object"!=typeof t)return;const e=t=>{for(const n of[js(t),js({children:t.data?.portalChildren||[]})])for(const o of n)Is.set(o,{p:t,sibs:n}),e(o)},n=t.sel?[t]:js(t);for(const t of n)Is.set(t,{p:void 0,sibs:n}),e(t)}(t),pt=Q.length,E(),$(),ft(),it()}));const mt=setTimeout(ft,J.DOM?30:0),yt=t=>new Promise((e=>setTimeout(e,t))),_t=async(t,e,n,o=(()=>!1))=>{const r=Date.now();let s=-1;for(;!y;){const i=Date.now()-A;if(Date.now()-r>n)return!1;if((!J.DOM||pt>=t||Date.now()-r>100)&&i>=e&&!o()){if(s===w)return!0;s=w,await yt(3)}else s=-1,await yt(Math.max(1,e-i))}return!0};let vt;const gt=new Set,St=()=>{const t=vt;return vt=void 0,t},bt=()=>{const t=St();if(t)throw t},wt=(t,e,n)=>{const o=Nt();return new Error(`[Sygnal] simulateEvent('${t}', '${e}'): the selector matched nothing in the rendered output`+(n?" (waited 300ms for it to render)":"")+'. Check t.html() to see what rendered, or give the element an attribute and select it, e.g. [data-id="3"]'+` (pass { allowMissing: true } to drop the event instead).\nRendered: ${o.length>600?o.slice(0,600)+"…":o||"(nothing)"}`)},At=(t,e,n,o)=>new Promise(((r,s)=>{const i=St();if(i)return s(i);const a=t=>{var e;clearTimeout(h),tt.removeListener(d),(e=t+1,_t(e,10,250)).then((()=>{gt.delete(l),r(Q[t])}))},c=t=>{try{return e(Q[t])}catch(t){return!1}},l=t=>{clearTimeout(h),tt.removeListener(d),gt.delete(l),s(t)};gt.add(l);const u=Q.length,d={next:()=>{Q.length>u&&c(Q.length-1)&&a(Q.length-1)},error:t=>l(t),complete:()=>l(new Error(`${o}: state stream completed without matching`))},h=setTimeout((()=>l(new Error(`${o} timed out after ${n}ms`))),n);for(let e=t;e<Q.length;e++)if(c(e))return a(e);tt.addListener(d)})),Et=t=>{if(!t||"object"!=typeof t||!t.sel)return t;let e=t.data;if(e?.isCollection){const{className:t,id:n}=e.props||{};e={...e,props:{className:t,id:n}}}return{...t,data:e,children:t.children&&t.children.map(Et)}},Nt=()=>dt?bs((()=>Et(dt))).replace(/ class="([^"]*)"/g,((t,e)=>(e=e.split(" ").filter((t=>!t.startsWith("___"))).join(" "))?` class="${e}"`:"")):"";return{state$:tt,dom$:J.DOM||zo.never(),events$:q.EVENTS||{select:()=>zo.never()},sinks:J,sources:q,simulateAction:(t,e)=>{bt(),ut((()=>(G.emit({type:t,data:e}),!0)))},simulateEvent:(t,e,n={})=>{bt();const{allowMissing:o,...r}=n,s=Os(String(t)),i=!s||Cs.test(s),a=i?[]:Ds(s);if(!i&&!o&&st&&!ot.length&&dt&&pt>=Q.length&&Date.now()-A>=20&&!Ys(dt,a))throw wt(t,e,!1);ut((c=>{const l=i?void 0:Ys(dt,a),u=l?.[l.length-1];if(!i&&!u)return!!c&&(o?(O("SYG103",p,`simulateEvent('${t}', '${e}') matched no rendered element within 300ms, so the event was dropped`,"Check the selector against the view's className/id, or wait until the element is rendered (await t.next(...) or t.settle())",{selector:t,type:e}),!0):((t=>{if(!gt.size)return void(vt=vt||t);const e=[...gt];gt.clear(),e.forEach((e=>e(t)))})(wt(t,e,!0)),!0));const d=t=>{let e=Ns(t);if(!l)return e==s;let n=l;if(Cs.test(e))e=e.replace(Cs,"");else{const e=t.filter(Es).pop();let o;n=l.filter((t=>{const n=t.sel.match(/\.___[^.#]+/);return n&&(o=n[0]),o==e}))}if(!e)return!0;const o=Gs(e);return!!o&&n.some(((t,e)=>Ps(o,n.slice(0,e+1))))};if(!c)for(const[t,n]of f)if((g[t]||[]).includes(e)&&!m.get(t+"\0"+e)&&d(n))return!1;u&&$(u);const h=u?.data||{},y=h.props||{},{target:_={},value:v,checked:S,dataset:b,data:w,...A}=r,E=y.value??h.attrs?.value,N={tagName:u?.sel.split(/[.#]/)[0].toUpperCase(),value:null==E?E:String(E),checked:y.checked??h.attrs?.checked,..."value"in n&&{value:v},..."checked"in n&&{checked:S},..._};if(N.dataset=Ts({...h.dataset,...b,...w,..._.dataset}),l&&!("closest"in _)){const t=t=>{const n=l[t];return{tagName:n.sel.split(/[.#]/)[0].toUpperCase(),dataset:Ts(n.data?.dataset),closest:e(t)}},e=e=>n=>{const o=Ds(String(n));for(let n=e;n>=0;n--)if(Ps(o,l.slice(0,n+1)))return n==l.length-1?N:t(n);return null};N.closest=e(l.length-1)}const C={type:e,target:N,currentTarget:N,ownerTarget:N,dataTransfer:{},preventDefault:L,stopPropagation:L,...A};return j.emit({type:e,event:C,match:d}),!0}),i||o?void 0:()=>Ys(dt,a)?void 0:wt(t,e,!1))},ready:()=>lt,waitForState:(t,e=2e3)=>At(0,t,e,"waitForState"),next:(t=(()=>!0),e=2e3)=>At(Q.length,t,e,"next"),settle:(t=2e3)=>new Promise(((e,n)=>{const o=St();if(o)return n(o);const r=t=>{gt.delete(r),t?n(t):e()};gt.add(r),(async()=>{if(await Promise.race([lt,yt(t)]),!await _t(Q.length,20,t,(()=>!st||ot.length>0)))throw new Error(`settle timed out after ${t}ms: ${ot.length?`${ot.length} simulated input(s) still pending`:"the component kept rendering"}`)})().then((()=>r()),r)})),states:Q,sinkValues:nt,emitted:nt("EVENTS"),diagnostics:d,expectNoDiagnostics:()=>{bt();const t=d.filter((t=>"info"!=t.severity));if(t.length)throw new Error(`Expected no diagnostics, got ${t.length}:\n`+t.map((t=>t.text)).join("\n"))},html:Nt,dispose:()=>{if(y)return;y=!0,clearTimeout(ht),clearTimeout(mt),clearTimeout(rt);const t=ot[0];t&&t.until&&t.missing&&!vt&&(vt=t.missing()),ot.length=0,X.forEach((([t,e])=>{try{t.removeListener(e)}catch(t){}}));try{J.__dispose?.()}catch(t){}Z(),x(),gt.clear(),bt()},inspect:()=>{if(!u.inspect)throw Error("[Sygnal] t.inspect() needs import 'sygnal/diagnostics'");return u.inspect({ids:[...v.values()],diagnostics:d,mock:{listeners:f,evTypes:g,owners:_,scopeIds:v,probe:k,vtree:dt}})}}},t.renderToString=bs,t.run=function t(e,n={},o={}){if("undefined"!=typeof window){Vr().init()}const{diagnostics:r}=o,s="string"==typeof r?{mode:r}:r||{};Un({mode:s.mode,ignore:s.ignore||[]});const{mountPoint:i="#root",fragments:a=!0,useDefaultDrivers:c=!0}=o;if(!e.isSygnalComponent){const t=e.name||e.componentName||e.label||"FUNCTIONAL_COMPONENT",n=e,{model:o,intent:r,hmrActions:s,context:i,peers:a,components:c,initialState:l,calculated:u,storeCalculatedInState:d,DOMSourceName:h,stateSourceName:p,onError:f,debug:m}=e;e=fr({name:t,view:n,model:o,intent:r,hmrActions:s,context:i,peers:a,components:c,initialState:l,calculated:u,storeCalculatedInState:d,DOMSourceName:h,stateSourceName:p,onError:f,debug:m})}"undefined"!=typeof window&&!0===window.__SYGNAL_HMR_UPDATING&&void 0!==window.__SYGNAL_HMR_PERSISTED_STATE&&(e.initialState=window.__SYGNAL_HMR_PERSISTED_STATE);const l=Be(e,"STATE"),u={...c?{EVENTS:Rr,DOM:Io(i,{snabbdomOptions:{experimental:{fragments:a}}}),LOG:Fr}:{},...n},{sources:d,sinks:h,run:p}=Yr(l,u),f=p();let m=null;"undefined"!=typeof window&&d?.STATE?.stream&&"function"==typeof d.STATE.stream.addListener&&(m={next:t=>{window.__SYGNAL_HMR_PERSISTED_STATE=t},error:()=>{},complete:()=>{}},d.STATE.stream.addListener(m));const y={sources:d,sinks:h,dispose:()=>{if(m&&d?.STATE?.stream&&"function"==typeof d.STATE.stream.removeListener&&(d.STATE.stream.removeListener(m),m=null),"function"==typeof h.__dispose)try{h.__dispose()}catch(t){}f()}};"undefined"!=typeof window&&(window.__SYGNAL_DEVTOOLS_APP__=y);const _=(r,s)=>{const i="undefined"!=typeof window?window.__SYGNAL_HMR_PERSISTED_STATE:void 0,a=void 0!==i?i:e.initialState,c=void 0===s?a:s;"undefined"!=typeof window&&(window.__SYGNAL_HMR_UPDATING=!0,window.__SYGNAL_HMR_STATE=c,window.__SYGNAL_HMR_PERSISTED_STATE=c),y.dispose();const l=r.default||r;l.initialState=c;const u=t(l,n,o);if(y.sources=u.sources,y.sinks=u.sinks,y.dispose=u.dispose,void 0!==c&&u?.sinks?.STATE&&"function"==typeof u.sinks.STATE.shamefullySendNext){const t=()=>u.sinks.STATE.shamefullySendNext((()=>({...c})));setTimeout(t,0),setTimeout(t,20)}"undefined"!=typeof window&&u?.sources?.STATE?.stream&&"function"==typeof u.sources.STATE.stream.setDebugListener?u.sources.STATE.stream.setDebugListener({next:()=>{u.sources.STATE.stream.setDebugListener(null),window.__SYGNAL_HMR_STATE=void 0,setTimeout((()=>{window.__SYGNAL_HMR_UPDATING=!1}),100)}}):"undefined"!=typeof window&&(window.__SYGNAL_HMR_STATE=void 0,window.__SYGNAL_HMR_UPDATING=!1)},v=t=>t?Array.isArray(t)?v(t.find(Boolean)):t.default&&"function"==typeof t.default?t:"function"==typeof t?{default:t}:null:null;return y.hmr=(t,n)=>{const o=v(t)||{default:e};if(void 0!==n)return"undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=n),void _(o,n);const r="undefined"!=typeof window?window.__SYGNAL_HMR_PERSISTED_STATE:void 0;if(void 0!==r)return"undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=r),void _(o,r);const s=y?.sources?.STATE?.stream?._v;if(void 0!==s)return"undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=s),void _(o,s);y?.sinks?.STATE&&"function"==typeof y.sinks.STATE.shamefullySendNext?y.sinks.STATE.shamefullySendNext((t=>("undefined"!=typeof window&&(window.__SYGNAL_HMR_LAST_CAPTURED_STATE=t),_(o,t),dr))):_(o)},y},t.sampleCombine=Te,t.set=function(t){return"function"==typeof t?(e,n,o,r)=>({...e,...t(e,n,o,r)}):e=>({...e,...t})},t.switchable=Zo,t.throttle=function(t){return function(e){return new re(new ge(t,e))}},t.thunk=function(t,e,n,o){return void 0===o&&(o=n,n=e,e=void 0),ze(t,{key:e,hook:{init:yn,prepatch:_n},fn:n,args:o})},t.toggle=function(t){return e=>({...e,[t]:!e[t]})},t.xs=zo}));
2
+ //# sourceMappingURL=sygnal.min.js.map