kimi-proxy 0.0.1 → 0.1.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 (79) hide show
  1. package/README.md +17 -8
  2. package/dist/adapters/anthropicAdapter.js +15 -10
  3. package/dist/adapters/anthropicAdapter.js.map +1 -1
  4. package/dist/config.d.ts +11 -3
  5. package/dist/config.js +2 -0
  6. package/dist/config.js.map +1 -1
  7. package/dist/core/clientAdapters.d.ts +18 -0
  8. package/dist/core/converters/anthropicToOpenAI.js +4 -0
  9. package/dist/core/converters/anthropicToOpenAI.js.map +1 -1
  10. package/dist/core/converters/openaiPassthrough.js +5 -1
  11. package/dist/core/converters/openaiPassthrough.js.map +1 -1
  12. package/dist/core/ensureToolCall.d.ts +3 -3
  13. package/dist/core/json.d.ts +3 -0
  14. package/dist/core/modelRegistry.d.ts +9 -1
  15. package/dist/core/modelRegistry.js +23 -7
  16. package/dist/core/modelRegistry.js.map +1 -1
  17. package/dist/core/pipeline.d.ts +30 -15
  18. package/dist/core/pipeline.js +9 -0
  19. package/dist/core/pipeline.js.map +1 -1
  20. package/dist/core/pipelineControl.d.ts +1 -1
  21. package/dist/core/providerAdapters.d.ts +4 -0
  22. package/dist/core/providers/anthropic.d.ts +16 -0
  23. package/dist/core/providers/openRouterProvider.js +1 -1
  24. package/dist/core/providers/openRouterProvider.js.map +1 -1
  25. package/dist/core/providers/openai.d.ts +2192 -0
  26. package/dist/core/providers/openrouter.d.ts +31 -0
  27. package/dist/core/providers/shared.d.ts +10 -0
  28. package/dist/core/providers/vertex.d.ts +45 -0
  29. package/dist/core/schemas.d.ts +2841 -0
  30. package/dist/core/transforms/request/EnsureToolCallRequestTransform.d.ts +1 -0
  31. package/dist/core/transforms/request/EnsureToolCallRequestTransform.js +43 -2
  32. package/dist/core/transforms/request/EnsureToolCallRequestTransform.js.map +1 -1
  33. package/dist/core/transforms/request/RestoreThoughtSignaturesTransform.d.ts +10 -0
  34. package/dist/core/transforms/request/RestoreThoughtSignaturesTransform.js +93 -0
  35. package/dist/core/transforms/request/RestoreThoughtSignaturesTransform.js.map +1 -0
  36. package/dist/core/transforms/response/CleanupExtraPropertiesResponseTransform.d.ts +7 -0
  37. package/dist/core/transforms/response/CleanupExtraPropertiesResponseTransform.js +30 -0
  38. package/dist/core/transforms/response/CleanupExtraPropertiesResponseTransform.js.map +1 -0
  39. package/dist/core/transforms/response/EnsureToolCallResponseTransform.d.ts +1 -0
  40. package/dist/core/transforms/response/EnsureToolCallResponseTransform.js +60 -3
  41. package/dist/core/transforms/response/EnsureToolCallResponseTransform.js.map +1 -1
  42. package/dist/core/transforms/response/ExtractThoughtSignaturesTransform.d.ts +10 -0
  43. package/dist/core/transforms/response/ExtractThoughtSignaturesTransform.js +80 -0
  44. package/dist/core/transforms/response/ExtractThoughtSignaturesTransform.js.map +1 -0
  45. package/dist/core/transforms/response/ValidateToolArgumentsTransform.d.ts +9 -0
  46. package/dist/core/transforms/response/ValidateToolArgumentsTransform.js +107 -0
  47. package/dist/core/transforms/response/ValidateToolArgumentsTransform.js.map +1 -0
  48. package/dist/core/transforms.d.ts +44 -0
  49. package/dist/core/types.d.ts +2765 -51
  50. package/dist/index.js +5926 -12
  51. package/dist/index.js.map +37 -1
  52. package/dist/livestore/runtime.d.ts +71 -0
  53. package/dist/persistence/hybridLogStore.d.ts +82 -0
  54. package/dist/persistence/migrateLogs.d.ts +1 -0
  55. package/dist/persistence/signatureCache.d.ts +18 -0
  56. package/dist/persistence/signatureCache.js +151 -0
  57. package/dist/persistence/signatureCache.js.map +1 -0
  58. package/dist/server.d.ts +1 -1
  59. package/dist/server.js +100 -16
  60. package/dist/server.js.map +1 -1
  61. package/dist/services/blobSearch/ripgrep.d.ts +17 -0
  62. package/dist/services/kimiFixer.d.ts +1 -1
  63. package/dist/services/kimiFixer.js +49 -26
  64. package/dist/services/kimiFixer.js.map +1 -1
  65. package/dist/services/logSearch.d.ts +15 -0
  66. package/dist/services/streaming.d.ts +4 -4
  67. package/dist/services/streaming.js +10 -6
  68. package/dist/services/streaming.js.map +1 -1
  69. package/dist/utils/envResolver.d.ts +1 -1
  70. package/dist/utils/httpCapture.d.ts +19 -0
  71. package/frontend/dist/assets/JSONViewer-516863bb.js +3 -0
  72. package/frontend/dist/assets/index-413f3c24.css +1 -0
  73. package/frontend/dist/assets/index-fd87815b.js +300 -0
  74. package/frontend/dist/assets/wa-sqlite-be172f22.wasm +0 -0
  75. package/frontend/dist/index.html +2 -2
  76. package/package.json +31 -16
  77. package/frontend/dist/assets/JSONViewer-97138fd7.js +0 -3
  78. package/frontend/dist/assets/index-0e7c091b.css +0 -1
  79. package/frontend/dist/assets/index-4b354ce2.js +0 -40
@@ -0,0 +1,300 @@
1
+ var iW=Object.defineProperty;var oW=(e,t,n)=>t in e?iW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var p=(e,t,n)=>(oW(e,typeof t!="symbol"?t+"":t,n),n),Hb=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)};var ge=(e,t,n)=>(Hb(e,t,"read from private field"),n?n.call(e):t.get(e)),Ft=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ec=(e,t,n,r)=>(Hb(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n);var Et=(e,t,n)=>(Hb(e,t,"access private method"),n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function aW(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var h3={exports:{}},uv={},p3={exports:{}},ct={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var gm=Symbol.for("react.element"),lW=Symbol.for("react.portal"),cW=Symbol.for("react.fragment"),uW=Symbol.for("react.strict_mode"),fW=Symbol.for("react.profiler"),dW=Symbol.for("react.provider"),hW=Symbol.for("react.context"),pW=Symbol.for("react.forward_ref"),gW=Symbol.for("react.suspense"),mW=Symbol.for("react.memo"),yW=Symbol.for("react.lazy"),eP=Symbol.iterator;function _W(e){return e===null||typeof e!="object"?null:(e=eP&&e[eP]||e["@@iterator"],typeof e=="function"?e:null)}var g3={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m3=Object.assign,y3={};function Wd(e,t,n){this.props=e,this.context=t,this.refs=y3,this.updater=n||g3}Wd.prototype.isReactComponent={};Wd.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Wd.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function _3(){}_3.prototype=Wd.prototype;function qx(e,t,n){this.props=e,this.context=t,this.refs=y3,this.updater=n||g3}var Mx=qx.prototype=new _3;Mx.constructor=qx;m3(Mx,Wd.prototype);Mx.isPureReactComponent=!0;var tP=Array.isArray,S3=Object.prototype.hasOwnProperty,Lx={current:null},v3={key:!0,ref:!0,__self:!0,__source:!0};function w3(e,t,n){var r,s={},i=null,o=null;if(t!=null)for(r in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)S3.call(t,r)&&!v3.hasOwnProperty(r)&&(s[r]=t[r]);var a=arguments.length-2;if(a===1)s.children=n;else if(1<a){for(var c=Array(a),f=0;f<a;f++)c[f]=arguments[f+2];s.children=c}if(e&&e.defaultProps)for(r in a=e.defaultProps,a)s[r]===void 0&&(s[r]=a[r]);return{$$typeof:gm,type:e,key:i,ref:o,props:s,_owner:Lx.current}}function SW(e,t){return{$$typeof:gm,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function zx(e){return typeof e=="object"&&e!==null&&e.$$typeof===gm}function vW(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var nP=/\/+/g;function Bb(e,t){return typeof e=="object"&&e!==null&&e.key!=null?vW(""+e.key):t.toString(36)}function m_(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case gm:case lW:o=!0}}if(o)return o=e,s=s(o),e=r===""?"."+Bb(o,0):r,tP(s)?(n="",e!=null&&(n=e.replace(nP,"$&/")+"/"),m_(s,t,n,"",function(f){return f})):s!=null&&(zx(s)&&(s=SW(s,n+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(nP,"$&/")+"/")+e)),t.push(s)),1;if(o=0,r=r===""?".":r+":",tP(e))for(var a=0;a<e.length;a++){i=e[a];var c=r+Bb(i,a);o+=m_(i,t,n,c,s)}else if(c=_W(e),typeof c=="function")for(e=c.call(e),a=0;!(i=e.next()).done;)i=i.value,c=r+Bb(i,a++),o+=m_(i,t,n,c,s);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Iy(e,t,n){if(e==null)return e;var r=[],s=0;return m_(e,r,"","",function(i){return t.call(n,i,s++)}),r}function wW(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Xr={current:null},y_={transition:null},bW={ReactCurrentDispatcher:Xr,ReactCurrentBatchConfig:y_,ReactCurrentOwner:Lx};function b3(){throw Error("act(...) is not supported in production builds of React.")}ct.Children={map:Iy,forEach:function(e,t,n){Iy(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Iy(e,function(){t++}),t},toArray:function(e){return Iy(e,function(t){return t})||[]},only:function(e){if(!zx(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};ct.Component=Wd;ct.Fragment=cW;ct.Profiler=fW;ct.PureComponent=qx;ct.StrictMode=uW;ct.Suspense=gW;ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=bW;ct.act=b3;ct.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=m3({},e.props),s=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=Lx.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(c in t)S3.call(t,c)&&!v3.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&a!==void 0?a[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){a=Array(c);for(var f=0;f<c;f++)a[f]=arguments[f+2];r.children=a}return{$$typeof:gm,type:e.type,key:s,ref:i,props:r,_owner:o}};ct.createContext=function(e){return e={$$typeof:hW,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:dW,_context:e},e.Consumer=e};ct.createElement=w3;ct.createFactory=function(e){var t=w3.bind(null,e);return t.type=e,t};ct.createRef=function(){return{current:null}};ct.forwardRef=function(e){return{$$typeof:pW,render:e}};ct.isValidElement=zx;ct.lazy=function(e){return{$$typeof:yW,_payload:{_status:-1,_result:e},_init:wW}};ct.memo=function(e,t){return{$$typeof:mW,type:e,compare:t===void 0?null:t}};ct.startTransition=function(e){var t=y_.transition;y_.transition={};try{e()}finally{y_.transition=t}};ct.unstable_act=b3;ct.useCallback=function(e,t){return Xr.current.useCallback(e,t)};ct.useContext=function(e){return Xr.current.useContext(e)};ct.useDebugValue=function(){};ct.useDeferredValue=function(e){return Xr.current.useDeferredValue(e)};ct.useEffect=function(e,t){return Xr.current.useEffect(e,t)};ct.useId=function(){return Xr.current.useId()};ct.useImperativeHandle=function(e,t,n){return Xr.current.useImperativeHandle(e,t,n)};ct.useInsertionEffect=function(e,t){return Xr.current.useInsertionEffect(e,t)};ct.useLayoutEffect=function(e,t){return Xr.current.useLayoutEffect(e,t)};ct.useMemo=function(e,t){return Xr.current.useMemo(e,t)};ct.useReducer=function(e,t,n){return Xr.current.useReducer(e,t,n)};ct.useRef=function(e){return Xr.current.useRef(e)};ct.useState=function(e){return Xr.current.useState(e)};ct.useSyncExternalStore=function(e,t,n){return Xr.current.useSyncExternalStore(e,t,n)};ct.useTransition=function(){return Xr.current.useTransition()};ct.version="18.3.1";p3.exports=ct;var ve=p3.exports;const pc=aW(ve);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var EW=ve,kW=Symbol.for("react.element"),CW=Symbol.for("react.fragment"),xW=Object.prototype.hasOwnProperty,RW=EW.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,$W={key:!0,ref:!0,__self:!0,__source:!0};function E3(e,t,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(r in t)xW.call(t,r)&&!$W.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:kW,type:e,key:i,ref:o,props:s,_owner:RW.current}}uv.Fragment=CW;uv.jsx=E3;uv.jsxs=E3;h3.exports=uv;var te=h3.exports,SE={},k3={exports:{}},Us={},C3={exports:{}},x3={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(e){function t(V,J){var ee=V.length;V.push(J);e:for(;0<ee;){var de=ee-1>>>1,Te=V[de];if(0<s(Te,J))V[de]=J,V[ee]=Te,ee=de;else break e}}function n(V){return V.length===0?null:V[0]}function r(V){if(V.length===0)return null;var J=V[0],ee=V.pop();if(ee!==J){V[0]=ee;e:for(var de=0,Te=V.length,dn=Te>>>1;de<dn;){var ln=2*(de+1)-1,ir=V[ln],Dn=ln+1,ns=V[Dn];if(0>s(ir,ee))Dn<Te&&0>s(ns,ir)?(V[de]=ns,V[Dn]=ee,de=Dn):(V[de]=ir,V[ln]=ee,de=ln);else if(Dn<Te&&0>s(ns,ee))V[de]=ns,V[Dn]=ee,de=Dn;else break e}}return J}function s(V,J){var ee=V.sortIndex-J.sortIndex;return ee!==0?ee:V.id-J.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();e.unstable_now=function(){return o.now()-a}}var c=[],f=[],d=1,g=null,_=3,b=!1,k=!1,I=!1,E=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(V){for(var J=n(f);J!==null;){if(J.callback===null)r(f);else if(J.startTime<=V)r(f),J.sortIndex=J.expirationTime,t(c,J);else break;J=n(f)}}function w(V){if(I=!1,v(V),!k)if(n(c)!==null)k=!0,L($);else{var J=n(f);J!==null&&G(w,J.startTime-V)}}function $(V,J){k=!1,I&&(I=!1,y(A),A=-1),b=!0;var ee=_;try{for(v(J),g=n(c);g!==null&&(!(g.expirationTime>J)||V&&!W());){var de=g.callback;if(typeof de=="function"){g.callback=null,_=g.priorityLevel;var Te=de(g.expirationTime<=J);J=e.unstable_now(),typeof Te=="function"?g.callback=Te:g===n(c)&&r(c),v(J)}else r(c);g=n(c)}if(g!==null)var dn=!0;else{var ln=n(f);ln!==null&&G(w,ln.startTime-J),dn=!1}return dn}finally{g=null,_=ee,b=!1}}var P=!1,O=null,A=-1,z=5,D=-1;function W(){return!(e.unstable_now()-D<z)}function le(){if(O!==null){var V=e.unstable_now();D=V;var J=!0;try{J=O(!0,V)}finally{J?M():(P=!1,O=null)}}else P=!1}var M;if(typeof m=="function")M=function(){m(le)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,Q=U.port2;U.port1.onmessage=le,M=function(){Q.postMessage(null)}}else M=function(){E(le,0)};function L(V){O=V,P||(P=!0,M())}function G(V,J){A=E(function(){V(e.unstable_now())},J)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(V){V.callback=null},e.unstable_continueExecution=function(){k||b||(k=!0,L($))},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return _},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(V){switch(_){case 1:case 2:case 3:var J=3;break;default:J=_}var ee=_;_=J;try{return V()}finally{_=ee}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(V,J){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var ee=_;_=V;try{return J()}finally{_=ee}},e.unstable_scheduleCallback=function(V,J,ee){var de=e.unstable_now();switch(typeof ee=="object"&&ee!==null?(ee=ee.delay,ee=typeof ee=="number"&&0<ee?de+ee:de):ee=de,V){case 1:var Te=-1;break;case 2:Te=250;break;case 5:Te=1073741823;break;case 4:Te=1e4;break;default:Te=5e3}return Te=ee+Te,V={id:d++,callback:J,priorityLevel:V,startTime:ee,expirationTime:Te,sortIndex:-1},ee>de?(V.sortIndex=ee,t(f,V),n(c)===null&&V===n(f)&&(I?(y(A),A=-1):I=!0,G(w,ee-de))):(V.sortIndex=Te,t(c,V),k||b||(k=!0,L($))),V},e.unstable_shouldYield=W,e.unstable_wrapCallback=function(V){var J=_;return function(){var ee=_;_=J;try{return V.apply(this,arguments)}finally{_=ee}}}})(x3);C3.exports=x3;var IW=C3.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var TW=ve,Ds=IW;function ae(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var R3=new Set,Gp={};function vu(e,t){sd(e,t),sd(e+"Capture",t)}function sd(e,t){for(Gp[e]=t,e=0;e<t.length;e++)R3.add(t[e])}var aa=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),vE=Object.prototype.hasOwnProperty,PW=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,rP={},sP={};function OW(e){return vE.call(sP,e)?!0:vE.call(rP,e)?!1:PW.test(e)?sP[e]=!0:(rP[e]=!0,!1)}function AW(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function FW(e,t,n,r){if(t===null||typeof t>"u"||AW(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Zr(e,t,n,r,s,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var Cr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Cr[e]=new Zr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Cr[t]=new Zr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Cr[e]=new Zr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Cr[e]=new Zr(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Cr[e]=new Zr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Cr[e]=new Zr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Cr[e]=new Zr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Cr[e]=new Zr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Cr[e]=new Zr(e,5,!1,e.toLowerCase(),null,!1,!1)});var jx=/[\-:]([a-z])/g;function Ux(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(jx,Ux);Cr[t]=new Zr(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(jx,Ux);Cr[t]=new Zr(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(jx,Ux);Cr[t]=new Zr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Cr[e]=new Zr(e,1,!1,e.toLowerCase(),null,!1,!1)});Cr.xlinkHref=new Zr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Cr[e]=new Zr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Hx(e,t,n,r){var s=Cr.hasOwnProperty(t)?Cr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(FW(t,n,s,r)&&(n=null),r||s===null?OW(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var Ea=TW.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ty=Symbol.for("react.element"),pf=Symbol.for("react.portal"),gf=Symbol.for("react.fragment"),Bx=Symbol.for("react.strict_mode"),wE=Symbol.for("react.profiler"),$3=Symbol.for("react.provider"),I3=Symbol.for("react.context"),Vx=Symbol.for("react.forward_ref"),bE=Symbol.for("react.suspense"),EE=Symbol.for("react.suspense_list"),Wx=Symbol.for("react.memo"),La=Symbol.for("react.lazy"),T3=Symbol.for("react.offscreen"),iP=Symbol.iterator;function Dh(e){return e===null||typeof e!="object"?null:(e=iP&&e[iP]||e["@@iterator"],typeof e=="function"?e:null)}var wn=Object.assign,Vb;function np(e){if(Vb===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Vb=t&&t[1]||""}return`
34
+ `+Vb+e}var Wb=!1;function Kb(e,t){if(!e||Wb)return"";Wb=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(f){var r=f}Reflect.construct(e,[],t)}else{try{t.call()}catch(f){r=f}e.call(t.prototype)}else{try{throw Error()}catch(f){r=f}e()}}catch(f){if(f&&r&&typeof f.stack=="string"){for(var s=f.stack.split(`
35
+ `),i=r.stack.split(`
36
+ `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var c=`
37
+ `+s[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=a);break}}}finally{Wb=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?np(e):""}function NW(e){switch(e.tag){case 5:return np(e.type);case 16:return np("Lazy");case 13:return np("Suspense");case 19:return np("SuspenseList");case 0:case 2:case 15:return e=Kb(e.type,!1),e;case 11:return e=Kb(e.type.render,!1),e;case 1:return e=Kb(e.type,!0),e;default:return""}}function kE(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case gf:return"Fragment";case pf:return"Portal";case wE:return"Profiler";case Bx:return"StrictMode";case bE:return"Suspense";case EE:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case I3:return(e.displayName||"Context")+".Consumer";case $3:return(e._context.displayName||"Context")+".Provider";case Vx:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Wx:return t=e.displayName||null,t!==null?t:kE(e.type)||"Memo";case La:t=e._payload,e=e._init;try{return kE(e(t))}catch{}}return null}function DW(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return kE(t);case 8:return t===Bx?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Sl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function P3(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function qW(e){var t=P3(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Py(e){e._valueTracker||(e._valueTracker=qW(e))}function O3(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=P3(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function eS(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function CE(e,t){var n=t.checked;return wn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function oP(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Sl(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function A3(e,t){t=t.checked,t!=null&&Hx(e,"checked",t,!1)}function xE(e,t){A3(e,t);var n=Sl(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?RE(e,t.type,n):t.hasOwnProperty("defaultValue")&&RE(e,t.type,Sl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function aP(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function RE(e,t,n){(t!=="number"||eS(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var rp=Array.isArray;function Ff(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s<n.length;s++)t["$"+n[s]]=!0;for(n=0;n<e.length;n++)s=t.hasOwnProperty("$"+e[n].value),e[n].selected!==s&&(e[n].selected=s),s&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Sl(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function $E(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(ae(91));return wn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function lP(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(ae(92));if(rp(n)){if(1<n.length)throw Error(ae(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Sl(n)}}function F3(e,t){var n=Sl(t.value),r=Sl(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function cP(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function N3(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function IE(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?N3(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Oy,D3=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,s){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,s)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Oy=Oy||document.createElement("div"),Oy.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Oy.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Qp(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Sp={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},MW=["Webkit","ms","Moz","O"];Object.keys(Sp).forEach(function(e){MW.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Sp[t]=Sp[e]})});function q3(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Sp.hasOwnProperty(e)&&Sp[e]?(""+t).trim():t+"px"}function M3(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=q3(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var LW=wn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function TE(e,t){if(t){if(LW[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(ae(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(ae(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(ae(61))}if(t.style!=null&&typeof t.style!="object")throw Error(ae(62))}}function PE(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var OE=null;function Kx(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var AE=null,Nf=null,Df=null;function uP(e){if(e=_m(e)){if(typeof AE!="function")throw Error(ae(280));var t=e.stateNode;t&&(t=gv(t),AE(e.stateNode,e.type,t))}}function L3(e){Nf?Df?Df.push(e):Df=[e]:Nf=e}function z3(){if(Nf){var e=Nf,t=Df;if(Df=Nf=null,uP(e),t)for(e=0;e<t.length;e++)uP(t[e])}}function j3(e,t){return e(t)}function U3(){}var Gb=!1;function H3(e,t,n){if(Gb)return e(t,n);Gb=!0;try{return j3(e,t,n)}finally{Gb=!1,(Nf!==null||Df!==null)&&(U3(),z3())}}function Jp(e,t){var n=e.stateNode;if(n===null)return null;var r=gv(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(ae(231,t,typeof n));return n}var FE=!1;if(aa)try{var qh={};Object.defineProperty(qh,"passive",{get:function(){FE=!0}}),window.addEventListener("test",qh,qh),window.removeEventListener("test",qh,qh)}catch{FE=!1}function zW(e,t,n,r,s,i,o,a,c){var f=Array.prototype.slice.call(arguments,3);try{t.apply(n,f)}catch(d){this.onError(d)}}var vp=!1,tS=null,nS=!1,NE=null,jW={onError:function(e){vp=!0,tS=e}};function UW(e,t,n,r,s,i,o,a,c){vp=!1,tS=null,zW.apply(jW,arguments)}function HW(e,t,n,r,s,i,o,a,c){if(UW.apply(this,arguments),vp){if(vp){var f=tS;vp=!1,tS=null}else throw Error(ae(198));nS||(nS=!0,NE=f)}}function wu(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function B3(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function fP(e){if(wu(e)!==e)throw Error(ae(188))}function BW(e){var t=e.alternate;if(!t){if(t=wu(e),t===null)throw Error(ae(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return fP(s),e;if(i===r)return fP(s),t;i=i.sibling}throw Error(ae(188))}if(n.return!==r.return)n=s,r=i;else{for(var o=!1,a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o){for(a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o)throw Error(ae(189))}}if(n.alternate!==r)throw Error(ae(190))}if(n.tag!==3)throw Error(ae(188));return n.stateNode.current===n?e:t}function V3(e){return e=BW(e),e!==null?W3(e):null}function W3(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=W3(e);if(t!==null)return t;e=e.sibling}return null}var K3=Ds.unstable_scheduleCallback,dP=Ds.unstable_cancelCallback,VW=Ds.unstable_shouldYield,WW=Ds.unstable_requestPaint,On=Ds.unstable_now,KW=Ds.unstable_getCurrentPriorityLevel,Gx=Ds.unstable_ImmediatePriority,G3=Ds.unstable_UserBlockingPriority,rS=Ds.unstable_NormalPriority,GW=Ds.unstable_LowPriority,Q3=Ds.unstable_IdlePriority,fv=null,ho=null;function QW(e){if(ho&&typeof ho.onCommitFiberRoot=="function")try{ho.onCommitFiberRoot(fv,e,void 0,(e.current.flags&128)===128)}catch{}}var Pi=Math.clz32?Math.clz32:XW,JW=Math.log,YW=Math.LN2;function XW(e){return e>>>=0,e===0?32:31-(JW(e)/YW|0)|0}var Ay=64,Fy=4194304;function sp(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function sS(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,o=n&268435455;if(o!==0){var a=o&~s;a!==0?r=sp(a):(i&=o,i!==0&&(r=sp(i)))}else o=n&~s,o!==0?r=sp(o):i!==0&&(r=sp(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Pi(t),s=1<<n,r|=e[n],t&=~s;return r}function ZW(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function e7(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-Pi(i),a=1<<o,c=s[o];c===-1?(!(a&n)||a&r)&&(s[o]=ZW(a,t)):c<=t&&(e.expiredLanes|=a),i&=~a}}function DE(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function J3(){var e=Ay;return Ay<<=1,!(Ay&4194240)&&(Ay=64),e}function Qb(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function mm(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Pi(t),e[t]=n}function t7(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var s=31-Pi(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function Qx(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Pi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var Nt=0;function Y3(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var X3,Jx,Z3,eD,tD,qE=!1,Ny=[],il=null,ol=null,al=null,Yp=new Map,Xp=new Map,Ha=[],n7="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function hP(e,t){switch(e){case"focusin":case"focusout":il=null;break;case"dragenter":case"dragleave":ol=null;break;case"mouseover":case"mouseout":al=null;break;case"pointerover":case"pointerout":Yp.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Xp.delete(t.pointerId)}}function Mh(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=_m(t),t!==null&&Jx(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function r7(e,t,n,r,s){switch(t){case"focusin":return il=Mh(il,e,t,n,r,s),!0;case"dragenter":return ol=Mh(ol,e,t,n,r,s),!0;case"mouseover":return al=Mh(al,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return Yp.set(i,Mh(Yp.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,Xp.set(i,Mh(Xp.get(i)||null,e,t,n,r,s)),!0}return!1}function nD(e){var t=gc(e.target);if(t!==null){var n=wu(t);if(n!==null){if(t=n.tag,t===13){if(t=B3(n),t!==null){e.blockedOn=t,tD(e.priority,function(){Z3(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function __(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=ME(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);OE=r,n.target.dispatchEvent(r),OE=null}else return t=_m(n),t!==null&&Jx(t),e.blockedOn=n,!1;t.shift()}return!0}function pP(e,t,n){__(e)&&n.delete(t)}function s7(){qE=!1,il!==null&&__(il)&&(il=null),ol!==null&&__(ol)&&(ol=null),al!==null&&__(al)&&(al=null),Yp.forEach(pP),Xp.forEach(pP)}function Lh(e,t){e.blockedOn===t&&(e.blockedOn=null,qE||(qE=!0,Ds.unstable_scheduleCallback(Ds.unstable_NormalPriority,s7)))}function Zp(e){function t(s){return Lh(s,e)}if(0<Ny.length){Lh(Ny[0],e);for(var n=1;n<Ny.length;n++){var r=Ny[n];r.blockedOn===e&&(r.blockedOn=null)}}for(il!==null&&Lh(il,e),ol!==null&&Lh(ol,e),al!==null&&Lh(al,e),Yp.forEach(t),Xp.forEach(t),n=0;n<Ha.length;n++)r=Ha[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Ha.length&&(n=Ha[0],n.blockedOn===null);)nD(n),n.blockedOn===null&&Ha.shift()}var qf=Ea.ReactCurrentBatchConfig,iS=!0;function i7(e,t,n,r){var s=Nt,i=qf.transition;qf.transition=null;try{Nt=1,Yx(e,t,n,r)}finally{Nt=s,qf.transition=i}}function o7(e,t,n,r){var s=Nt,i=qf.transition;qf.transition=null;try{Nt=4,Yx(e,t,n,r)}finally{Nt=s,qf.transition=i}}function Yx(e,t,n,r){if(iS){var s=ME(e,t,n,r);if(s===null)i1(e,t,r,oS,n),hP(e,r);else if(r7(s,e,t,n,r))r.stopPropagation();else if(hP(e,r),t&4&&-1<n7.indexOf(e)){for(;s!==null;){var i=_m(s);if(i!==null&&X3(i),i=ME(e,t,n,r),i===null&&i1(e,t,r,oS,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else i1(e,t,r,null,n)}}var oS=null;function ME(e,t,n,r){if(oS=null,e=Kx(r),e=gc(e),e!==null)if(t=wu(e),t===null)e=null;else if(n=t.tag,n===13){if(e=B3(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return oS=e,null}function rD(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(KW()){case Gx:return 1;case G3:return 4;case rS:case GW:return 16;case Q3:return 536870912;default:return 16}default:return 16}}var Qa=null,Xx=null,S_=null;function sD(){if(S_)return S_;var e,t=Xx,n=t.length,r,s="value"in Qa?Qa.value:Qa.textContent,i=s.length;for(e=0;e<n&&t[e]===s[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===s[i-r];r++);return S_=s.slice(e,1<r?1-r:void 0)}function v_(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Dy(){return!0}function gP(){return!1}function Hs(e){function t(n,r,s,i,o){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?Dy:gP,this.isPropagationStopped=gP,this}return wn(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Dy)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Dy)},persist:function(){},isPersistent:Dy}),t}var Kd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Zx=Hs(Kd),ym=wn({},Kd,{view:0,detail:0}),a7=Hs(ym),Jb,Yb,zh,dv=wn({},ym,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:eR,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==zh&&(zh&&e.type==="mousemove"?(Jb=e.screenX-zh.screenX,Yb=e.screenY-zh.screenY):Yb=Jb=0,zh=e),Jb)},movementY:function(e){return"movementY"in e?e.movementY:Yb}}),mP=Hs(dv),l7=wn({},dv,{dataTransfer:0}),c7=Hs(l7),u7=wn({},ym,{relatedTarget:0}),Xb=Hs(u7),f7=wn({},Kd,{animationName:0,elapsedTime:0,pseudoElement:0}),d7=Hs(f7),h7=wn({},Kd,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),p7=Hs(h7),g7=wn({},Kd,{data:0}),yP=Hs(g7),m7={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},y7={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},_7={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function S7(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=_7[e])?!!t[e]:!1}function eR(){return S7}var v7=wn({},ym,{key:function(e){if(e.key){var t=m7[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=v_(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?y7[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:eR,charCode:function(e){return e.type==="keypress"?v_(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?v_(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),w7=Hs(v7),b7=wn({},dv,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),_P=Hs(b7),E7=wn({},ym,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:eR}),k7=Hs(E7),C7=wn({},Kd,{propertyName:0,elapsedTime:0,pseudoElement:0}),x7=Hs(C7),R7=wn({},dv,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),$7=Hs(R7),I7=[9,13,27,32],tR=aa&&"CompositionEvent"in window,wp=null;aa&&"documentMode"in document&&(wp=document.documentMode);var T7=aa&&"TextEvent"in window&&!wp,iD=aa&&(!tR||wp&&8<wp&&11>=wp),SP=String.fromCharCode(32),vP=!1;function oD(e,t){switch(e){case"keyup":return I7.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function aD(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var mf=!1;function P7(e,t){switch(e){case"compositionend":return aD(t);case"keypress":return t.which!==32?null:(vP=!0,SP);case"textInput":return e=t.data,e===SP&&vP?null:e;default:return null}}function O7(e,t){if(mf)return e==="compositionend"||!tR&&oD(e,t)?(e=sD(),S_=Xx=Qa=null,mf=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return iD&&t.locale!=="ko"?null:t.data;default:return null}}var A7={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function wP(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!A7[e.type]:t==="textarea"}function lD(e,t,n,r){L3(r),t=aS(t,"onChange"),0<t.length&&(n=new Zx("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var bp=null,eg=null;function F7(e){SD(e,0)}function hv(e){var t=Sf(e);if(O3(t))return e}function N7(e,t){if(e==="change")return t}var cD=!1;if(aa){var Zb;if(aa){var e1="oninput"in document;if(!e1){var bP=document.createElement("div");bP.setAttribute("oninput","return;"),e1=typeof bP.oninput=="function"}Zb=e1}else Zb=!1;cD=Zb&&(!document.documentMode||9<document.documentMode)}function EP(){bp&&(bp.detachEvent("onpropertychange",uD),eg=bp=null)}function uD(e){if(e.propertyName==="value"&&hv(eg)){var t=[];lD(t,eg,e,Kx(e)),H3(F7,t)}}function D7(e,t,n){e==="focusin"?(EP(),bp=t,eg=n,bp.attachEvent("onpropertychange",uD)):e==="focusout"&&EP()}function q7(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return hv(eg)}function M7(e,t){if(e==="click")return hv(t)}function L7(e,t){if(e==="input"||e==="change")return hv(t)}function z7(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var qi=typeof Object.is=="function"?Object.is:z7;function tg(e,t){if(qi(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!vE.call(t,s)||!qi(e[s],t[s]))return!1}return!0}function kP(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function CP(e,t){var n=kP(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=kP(n)}}function fD(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?fD(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function dD(){for(var e=window,t=eS();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=eS(e.document)}return t}function nR(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function j7(e){var t=dD(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&fD(n.ownerDocument.documentElement,n)){if(r!==null&&nR(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=CP(n,i);var o=CP(n,r);s&&o&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var U7=aa&&"documentMode"in document&&11>=document.documentMode,yf=null,LE=null,Ep=null,zE=!1;function xP(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;zE||yf==null||yf!==eS(r)||(r=yf,"selectionStart"in r&&nR(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ep&&tg(Ep,r)||(Ep=r,r=aS(LE,"onSelect"),0<r.length&&(t=new Zx("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=yf)))}function qy(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var _f={animationend:qy("Animation","AnimationEnd"),animationiteration:qy("Animation","AnimationIteration"),animationstart:qy("Animation","AnimationStart"),transitionend:qy("Transition","TransitionEnd")},t1={},hD={};aa&&(hD=document.createElement("div").style,"AnimationEvent"in window||(delete _f.animationend.animation,delete _f.animationiteration.animation,delete _f.animationstart.animation),"TransitionEvent"in window||delete _f.transitionend.transition);function pv(e){if(t1[e])return t1[e];if(!_f[e])return e;var t=_f[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in hD)return t1[e]=t[n];return e}var pD=pv("animationend"),gD=pv("animationiteration"),mD=pv("animationstart"),yD=pv("transitionend"),_D=new Map,RP="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Ll(e,t){_D.set(e,t),vu(t,[e])}for(var n1=0;n1<RP.length;n1++){var r1=RP[n1],H7=r1.toLowerCase(),B7=r1[0].toUpperCase()+r1.slice(1);Ll(H7,"on"+B7)}Ll(pD,"onAnimationEnd");Ll(gD,"onAnimationIteration");Ll(mD,"onAnimationStart");Ll("dblclick","onDoubleClick");Ll("focusin","onFocus");Ll("focusout","onBlur");Ll(yD,"onTransitionEnd");sd("onMouseEnter",["mouseout","mouseover"]);sd("onMouseLeave",["mouseout","mouseover"]);sd("onPointerEnter",["pointerout","pointerover"]);sd("onPointerLeave",["pointerout","pointerover"]);vu("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));vu("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));vu("onBeforeInput",["compositionend","keypress","textInput","paste"]);vu("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));vu("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));vu("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ip="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),V7=new Set("cancel close invalid load scroll toggle".split(" ").concat(ip));function $P(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,HW(r,t,void 0,e),e.currentTarget=null}function SD(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],s=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var o=r.length-1;0<=o;o--){var a=r[o],c=a.instance,f=a.currentTarget;if(a=a.listener,c!==i&&s.isPropagationStopped())break e;$P(s,a,f),i=c}else for(o=0;o<r.length;o++){if(a=r[o],c=a.instance,f=a.currentTarget,a=a.listener,c!==i&&s.isPropagationStopped())break e;$P(s,a,f),i=c}}}if(nS)throw e=NE,nS=!1,NE=null,e}function Zt(e,t){var n=t[VE];n===void 0&&(n=t[VE]=new Set);var r=e+"__bubble";n.has(r)||(vD(t,e,2,!1),n.add(r))}function s1(e,t,n){var r=0;t&&(r|=4),vD(n,e,r,t)}var My="_reactListening"+Math.random().toString(36).slice(2);function ng(e){if(!e[My]){e[My]=!0,R3.forEach(function(n){n!=="selectionchange"&&(V7.has(n)||s1(n,!1,e),s1(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[My]||(t[My]=!0,s1("selectionchange",!1,t))}}function vD(e,t,n,r){switch(rD(t)){case 1:var s=i7;break;case 4:s=o7;break;default:s=Yx}n=s.bind(null,t,n,e),s=void 0,!FE||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(s=!0),r?s!==void 0?e.addEventListener(t,n,{capture:!0,passive:s}):e.addEventListener(t,n,!0):s!==void 0?e.addEventListener(t,n,{passive:s}):e.addEventListener(t,n,!1)}function i1(e,t,n,r,s){var i=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(o===4)for(o=r.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===s||c.nodeType===8&&c.parentNode===s))return;o=o.return}for(;a!==null;){if(o=gc(a),o===null)return;if(c=o.tag,c===5||c===6){r=i=o;continue e}a=a.parentNode}}r=r.return}H3(function(){var f=i,d=Kx(n),g=[];e:{var _=_D.get(e);if(_!==void 0){var b=Zx,k=e;switch(e){case"keypress":if(v_(n)===0)break e;case"keydown":case"keyup":b=w7;break;case"focusin":k="focus",b=Xb;break;case"focusout":k="blur",b=Xb;break;case"beforeblur":case"afterblur":b=Xb;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":b=mP;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":b=c7;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":b=k7;break;case pD:case gD:case mD:b=d7;break;case yD:b=x7;break;case"scroll":b=a7;break;case"wheel":b=$7;break;case"copy":case"cut":case"paste":b=p7;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":b=_P}var I=(t&4)!==0,E=!I&&e==="scroll",y=I?_!==null?_+"Capture":null:_;I=[];for(var m=f,v;m!==null;){v=m;var w=v.stateNode;if(v.tag===5&&w!==null&&(v=w,y!==null&&(w=Jp(m,y),w!=null&&I.push(rg(m,w,v)))),E)break;m=m.return}0<I.length&&(_=new b(_,k,null,n,d),g.push({event:_,listeners:I}))}}if(!(t&7)){e:{if(_=e==="mouseover"||e==="pointerover",b=e==="mouseout"||e==="pointerout",_&&n!==OE&&(k=n.relatedTarget||n.fromElement)&&(gc(k)||k[la]))break e;if((b||_)&&(_=d.window===d?d:(_=d.ownerDocument)?_.defaultView||_.parentWindow:window,b?(k=n.relatedTarget||n.toElement,b=f,k=k?gc(k):null,k!==null&&(E=wu(k),k!==E||k.tag!==5&&k.tag!==6)&&(k=null)):(b=null,k=f),b!==k)){if(I=mP,w="onMouseLeave",y="onMouseEnter",m="mouse",(e==="pointerout"||e==="pointerover")&&(I=_P,w="onPointerLeave",y="onPointerEnter",m="pointer"),E=b==null?_:Sf(b),v=k==null?_:Sf(k),_=new I(w,m+"leave",b,n,d),_.target=E,_.relatedTarget=v,w=null,gc(d)===f&&(I=new I(y,m+"enter",k,n,d),I.target=v,I.relatedTarget=E,w=I),E=w,b&&k)t:{for(I=b,y=k,m=0,v=I;v;v=Gu(v))m++;for(v=0,w=y;w;w=Gu(w))v++;for(;0<m-v;)I=Gu(I),m--;for(;0<v-m;)y=Gu(y),v--;for(;m--;){if(I===y||y!==null&&I===y.alternate)break t;I=Gu(I),y=Gu(y)}I=null}else I=null;b!==null&&IP(g,_,b,I,!1),k!==null&&E!==null&&IP(g,E,k,I,!0)}}e:{if(_=f?Sf(f):window,b=_.nodeName&&_.nodeName.toLowerCase(),b==="select"||b==="input"&&_.type==="file")var $=N7;else if(wP(_))if(cD)$=L7;else{$=q7;var P=D7}else(b=_.nodeName)&&b.toLowerCase()==="input"&&(_.type==="checkbox"||_.type==="radio")&&($=M7);if($&&($=$(e,f))){lD(g,$,n,d);break e}P&&P(e,_,f),e==="focusout"&&(P=_._wrapperState)&&P.controlled&&_.type==="number"&&RE(_,"number",_.value)}switch(P=f?Sf(f):window,e){case"focusin":(wP(P)||P.contentEditable==="true")&&(yf=P,LE=f,Ep=null);break;case"focusout":Ep=LE=yf=null;break;case"mousedown":zE=!0;break;case"contextmenu":case"mouseup":case"dragend":zE=!1,xP(g,n,d);break;case"selectionchange":if(U7)break;case"keydown":case"keyup":xP(g,n,d)}var O;if(tR)e:{switch(e){case"compositionstart":var A="onCompositionStart";break e;case"compositionend":A="onCompositionEnd";break e;case"compositionupdate":A="onCompositionUpdate";break e}A=void 0}else mf?oD(e,n)&&(A="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(A="onCompositionStart");A&&(iD&&n.locale!=="ko"&&(mf||A!=="onCompositionStart"?A==="onCompositionEnd"&&mf&&(O=sD()):(Qa=d,Xx="value"in Qa?Qa.value:Qa.textContent,mf=!0)),P=aS(f,A),0<P.length&&(A=new yP(A,e,null,n,d),g.push({event:A,listeners:P}),O?A.data=O:(O=aD(n),O!==null&&(A.data=O)))),(O=T7?P7(e,n):O7(e,n))&&(f=aS(f,"onBeforeInput"),0<f.length&&(d=new yP("onBeforeInput","beforeinput",null,n,d),g.push({event:d,listeners:f}),d.data=O))}SD(g,t)})}function rg(e,t,n){return{instance:e,listener:t,currentTarget:n}}function aS(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Jp(e,n),i!=null&&r.unshift(rg(e,i,s)),i=Jp(e,t),i!=null&&r.push(rg(e,i,s))),e=e.return}return r}function Gu(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function IP(e,t,n,r,s){for(var i=t._reactName,o=[];n!==null&&n!==r;){var a=n,c=a.alternate,f=a.stateNode;if(c!==null&&c===r)break;a.tag===5&&f!==null&&(a=f,s?(c=Jp(n,i),c!=null&&o.unshift(rg(n,c,a))):s||(c=Jp(n,i),c!=null&&o.push(rg(n,c,a)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var W7=/\r\n?/g,K7=/\u0000|\uFFFD/g;function TP(e){return(typeof e=="string"?e:""+e).replace(W7,`
38
+ `).replace(K7,"")}function Ly(e,t,n){if(t=TP(t),TP(e)!==t&&n)throw Error(ae(425))}function lS(){}var jE=null,UE=null;function HE(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var BE=typeof setTimeout=="function"?setTimeout:void 0,G7=typeof clearTimeout=="function"?clearTimeout:void 0,PP=typeof Promise=="function"?Promise:void 0,Q7=typeof queueMicrotask=="function"?queueMicrotask:typeof PP<"u"?function(e){return PP.resolve(null).then(e).catch(J7)}:BE;function J7(e){setTimeout(function(){throw e})}function o1(e,t){var n=t,r=0;do{var s=n.nextSibling;if(e.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){e.removeChild(s),Zp(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Zp(t)}function ll(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function OP(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var Gd=Math.random().toString(36).slice(2),ro="__reactFiber$"+Gd,sg="__reactProps$"+Gd,la="__reactContainer$"+Gd,VE="__reactEvents$"+Gd,Y7="__reactListeners$"+Gd,X7="__reactHandles$"+Gd;function gc(e){var t=e[ro];if(t)return t;for(var n=e.parentNode;n;){if(t=n[la]||n[ro]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=OP(e);e!==null;){if(n=e[ro])return n;e=OP(e)}return t}e=n,n=e.parentNode}return null}function _m(e){return e=e[ro]||e[la],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Sf(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(ae(33))}function gv(e){return e[sg]||null}var WE=[],vf=-1;function zl(e){return{current:e}}function rn(e){0>vf||(e.current=WE[vf],WE[vf]=null,vf--)}function Qt(e,t){vf++,WE[vf]=e.current,e.current=t}var vl={},Dr=zl(vl),cs=zl(!1),Uc=vl;function id(e,t){var n=e.type.contextTypes;if(!n)return vl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function us(e){return e=e.childContextTypes,e!=null}function cS(){rn(cs),rn(Dr)}function AP(e,t,n){if(Dr.current!==vl)throw Error(ae(168));Qt(Dr,t),Qt(cs,n)}function wD(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(ae(108,DW(e)||"Unknown",s));return wn({},n,r)}function uS(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||vl,Uc=Dr.current,Qt(Dr,e),Qt(cs,cs.current),!0}function FP(e,t,n){var r=e.stateNode;if(!r)throw Error(ae(169));n?(e=wD(e,t,Uc),r.__reactInternalMemoizedMergedChildContext=e,rn(cs),rn(Dr),Qt(Dr,e)):rn(cs),Qt(cs,n)}var Bo=null,mv=!1,a1=!1;function bD(e){Bo===null?Bo=[e]:Bo.push(e)}function Z7(e){mv=!0,bD(e)}function jl(){if(!a1&&Bo!==null){a1=!0;var e=0,t=Nt;try{var n=Bo;for(Nt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Bo=null,mv=!1}catch(s){throw Bo!==null&&(Bo=Bo.slice(e+1)),K3(Gx,jl),s}finally{Nt=t,a1=!1}}return null}var wf=[],bf=0,fS=null,dS=0,Zs=[],ei=0,Hc=null,Vo=1,Wo="";function ac(e,t){wf[bf++]=dS,wf[bf++]=fS,fS=e,dS=t}function ED(e,t,n){Zs[ei++]=Vo,Zs[ei++]=Wo,Zs[ei++]=Hc,Hc=e;var r=Vo;e=Wo;var s=32-Pi(r)-1;r&=~(1<<s),n+=1;var i=32-Pi(t)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,Vo=1<<32-Pi(t)+s|n<<s|r,Wo=i+e}else Vo=1<<i|n<<s|r,Wo=e}function rR(e){e.return!==null&&(ac(e,1),ED(e,1,0))}function sR(e){for(;e===fS;)fS=wf[--bf],wf[bf]=null,dS=wf[--bf],wf[bf]=null;for(;e===Hc;)Hc=Zs[--ei],Zs[ei]=null,Wo=Zs[--ei],Zs[ei]=null,Vo=Zs[--ei],Zs[ei]=null}var Os=null,Ts=null,cn=!1,xi=null;function kD(e,t){var n=ai(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function NP(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Os=e,Ts=ll(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Os=e,Ts=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=Hc!==null?{id:Vo,overflow:Wo}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=ai(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Os=e,Ts=null,!0):!1;default:return!1}}function KE(e){return(e.mode&1)!==0&&(e.flags&128)===0}function GE(e){if(cn){var t=Ts;if(t){var n=t;if(!NP(e,t)){if(KE(e))throw Error(ae(418));t=ll(n.nextSibling);var r=Os;t&&NP(e,t)?kD(r,n):(e.flags=e.flags&-4097|2,cn=!1,Os=e)}}else{if(KE(e))throw Error(ae(418));e.flags=e.flags&-4097|2,cn=!1,Os=e}}}function DP(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Os=e}function zy(e){if(e!==Os)return!1;if(!cn)return DP(e),cn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!HE(e.type,e.memoizedProps)),t&&(t=Ts)){if(KE(e))throw CD(),Error(ae(418));for(;t;)kD(e,t),t=ll(t.nextSibling)}if(DP(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(ae(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Ts=ll(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Ts=null}}else Ts=Os?ll(e.stateNode.nextSibling):null;return!0}function CD(){for(var e=Ts;e;)e=ll(e.nextSibling)}function od(){Ts=Os=null,cn=!1}function iR(e){xi===null?xi=[e]:xi.push(e)}var eK=Ea.ReactCurrentBatchConfig;function jh(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(ae(309));var r=n.stateNode}if(!r)throw Error(ae(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(ae(284));if(!n._owner)throw Error(ae(290,e))}return e}function jy(e,t){throw e=Object.prototype.toString.call(t),Error(ae(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function qP(e){var t=e._init;return t(e._payload)}function xD(e){function t(y,m){if(e){var v=y.deletions;v===null?(y.deletions=[m],y.flags|=16):v.push(m)}}function n(y,m){if(!e)return null;for(;m!==null;)t(y,m),m=m.sibling;return null}function r(y,m){for(y=new Map;m!==null;)m.key!==null?y.set(m.key,m):y.set(m.index,m),m=m.sibling;return y}function s(y,m){return y=dl(y,m),y.index=0,y.sibling=null,y}function i(y,m,v){return y.index=v,e?(v=y.alternate,v!==null?(v=v.index,v<m?(y.flags|=2,m):v):(y.flags|=2,m)):(y.flags|=1048576,m)}function o(y){return e&&y.alternate===null&&(y.flags|=2),y}function a(y,m,v,w){return m===null||m.tag!==6?(m=p1(v,y.mode,w),m.return=y,m):(m=s(m,v),m.return=y,m)}function c(y,m,v,w){var $=v.type;return $===gf?d(y,m,v.props.children,w,v.key):m!==null&&(m.elementType===$||typeof $=="object"&&$!==null&&$.$$typeof===La&&qP($)===m.type)?(w=s(m,v.props),w.ref=jh(y,m,v),w.return=y,w):(w=R_(v.type,v.key,v.props,null,y.mode,w),w.ref=jh(y,m,v),w.return=y,w)}function f(y,m,v,w){return m===null||m.tag!==4||m.stateNode.containerInfo!==v.containerInfo||m.stateNode.implementation!==v.implementation?(m=g1(v,y.mode,w),m.return=y,m):(m=s(m,v.children||[]),m.return=y,m)}function d(y,m,v,w,$){return m===null||m.tag!==7?(m=Oc(v,y.mode,w,$),m.return=y,m):(m=s(m,v),m.return=y,m)}function g(y,m,v){if(typeof m=="string"&&m!==""||typeof m=="number")return m=p1(""+m,y.mode,v),m.return=y,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case Ty:return v=R_(m.type,m.key,m.props,null,y.mode,v),v.ref=jh(y,null,m),v.return=y,v;case pf:return m=g1(m,y.mode,v),m.return=y,m;case La:var w=m._init;return g(y,w(m._payload),v)}if(rp(m)||Dh(m))return m=Oc(m,y.mode,v,null),m.return=y,m;jy(y,m)}return null}function _(y,m,v,w){var $=m!==null?m.key:null;if(typeof v=="string"&&v!==""||typeof v=="number")return $!==null?null:a(y,m,""+v,w);if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Ty:return v.key===$?c(y,m,v,w):null;case pf:return v.key===$?f(y,m,v,w):null;case La:return $=v._init,_(y,m,$(v._payload),w)}if(rp(v)||Dh(v))return $!==null?null:d(y,m,v,w,null);jy(y,v)}return null}function b(y,m,v,w,$){if(typeof w=="string"&&w!==""||typeof w=="number")return y=y.get(v)||null,a(m,y,""+w,$);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Ty:return y=y.get(w.key===null?v:w.key)||null,c(m,y,w,$);case pf:return y=y.get(w.key===null?v:w.key)||null,f(m,y,w,$);case La:var P=w._init;return b(y,m,v,P(w._payload),$)}if(rp(w)||Dh(w))return y=y.get(v)||null,d(m,y,w,$,null);jy(m,w)}return null}function k(y,m,v,w){for(var $=null,P=null,O=m,A=m=0,z=null;O!==null&&A<v.length;A++){O.index>A?(z=O,O=null):z=O.sibling;var D=_(y,O,v[A],w);if(D===null){O===null&&(O=z);break}e&&O&&D.alternate===null&&t(y,O),m=i(D,m,A),P===null?$=D:P.sibling=D,P=D,O=z}if(A===v.length)return n(y,O),cn&&ac(y,A),$;if(O===null){for(;A<v.length;A++)O=g(y,v[A],w),O!==null&&(m=i(O,m,A),P===null?$=O:P.sibling=O,P=O);return cn&&ac(y,A),$}for(O=r(y,O);A<v.length;A++)z=b(O,y,A,v[A],w),z!==null&&(e&&z.alternate!==null&&O.delete(z.key===null?A:z.key),m=i(z,m,A),P===null?$=z:P.sibling=z,P=z);return e&&O.forEach(function(W){return t(y,W)}),cn&&ac(y,A),$}function I(y,m,v,w){var $=Dh(v);if(typeof $!="function")throw Error(ae(150));if(v=$.call(v),v==null)throw Error(ae(151));for(var P=$=null,O=m,A=m=0,z=null,D=v.next();O!==null&&!D.done;A++,D=v.next()){O.index>A?(z=O,O=null):z=O.sibling;var W=_(y,O,D.value,w);if(W===null){O===null&&(O=z);break}e&&O&&W.alternate===null&&t(y,O),m=i(W,m,A),P===null?$=W:P.sibling=W,P=W,O=z}if(D.done)return n(y,O),cn&&ac(y,A),$;if(O===null){for(;!D.done;A++,D=v.next())D=g(y,D.value,w),D!==null&&(m=i(D,m,A),P===null?$=D:P.sibling=D,P=D);return cn&&ac(y,A),$}for(O=r(y,O);!D.done;A++,D=v.next())D=b(O,y,A,D.value,w),D!==null&&(e&&D.alternate!==null&&O.delete(D.key===null?A:D.key),m=i(D,m,A),P===null?$=D:P.sibling=D,P=D);return e&&O.forEach(function(le){return t(y,le)}),cn&&ac(y,A),$}function E(y,m,v,w){if(typeof v=="object"&&v!==null&&v.type===gf&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case Ty:e:{for(var $=v.key,P=m;P!==null;){if(P.key===$){if($=v.type,$===gf){if(P.tag===7){n(y,P.sibling),m=s(P,v.props.children),m.return=y,y=m;break e}}else if(P.elementType===$||typeof $=="object"&&$!==null&&$.$$typeof===La&&qP($)===P.type){n(y,P.sibling),m=s(P,v.props),m.ref=jh(y,P,v),m.return=y,y=m;break e}n(y,P);break}else t(y,P);P=P.sibling}v.type===gf?(m=Oc(v.props.children,y.mode,w,v.key),m.return=y,y=m):(w=R_(v.type,v.key,v.props,null,y.mode,w),w.ref=jh(y,m,v),w.return=y,y=w)}return o(y);case pf:e:{for(P=v.key;m!==null;){if(m.key===P)if(m.tag===4&&m.stateNode.containerInfo===v.containerInfo&&m.stateNode.implementation===v.implementation){n(y,m.sibling),m=s(m,v.children||[]),m.return=y,y=m;break e}else{n(y,m);break}else t(y,m);m=m.sibling}m=g1(v,y.mode,w),m.return=y,y=m}return o(y);case La:return P=v._init,E(y,m,P(v._payload),w)}if(rp(v))return k(y,m,v,w);if(Dh(v))return I(y,m,v,w);jy(y,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,m!==null&&m.tag===6?(n(y,m.sibling),m=s(m,v),m.return=y,y=m):(n(y,m),m=p1(v,y.mode,w),m.return=y,y=m),o(y)):n(y,m)}return E}var ad=xD(!0),RD=xD(!1),hS=zl(null),pS=null,Ef=null,oR=null;function aR(){oR=Ef=pS=null}function lR(e){var t=hS.current;rn(hS),e._currentValue=t}function QE(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Mf(e,t){pS=e,oR=Ef=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ls=!0),e.firstContext=null)}function pi(e){var t=e._currentValue;if(oR!==e)if(e={context:e,memoizedValue:t,next:null},Ef===null){if(pS===null)throw Error(ae(308));Ef=e,pS.dependencies={lanes:0,firstContext:e}}else Ef=Ef.next=e;return t}var mc=null;function cR(e){mc===null?mc=[e]:mc.push(e)}function $D(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,cR(t)):(n.next=s.next,s.next=n),t.interleaved=n,ca(e,r)}function ca(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var za=!1;function uR(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ID(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Yo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function cl(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,vt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,ca(e,n)}return s=r.interleaved,s===null?(t.next=t,cR(r)):(t.next=s.next,s.next=t),r.interleaved=t,ca(e,n)}function w_(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Qx(e,n)}}function MP(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function gS(e,t,n,r){var s=e.updateQueue;za=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var c=a,f=c.next;c.next=null,o===null?i=f:o.next=f,o=c;var d=e.alternate;d!==null&&(d=d.updateQueue,a=d.lastBaseUpdate,a!==o&&(a===null?d.firstBaseUpdate=f:a.next=f,d.lastBaseUpdate=c))}if(i!==null){var g=s.baseState;o=0,d=f=c=null,a=i;do{var _=a.lane,b=a.eventTime;if((r&_)===_){d!==null&&(d=d.next={eventTime:b,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var k=e,I=a;switch(_=t,b=n,I.tag){case 1:if(k=I.payload,typeof k=="function"){g=k.call(b,g,_);break e}g=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=I.payload,_=typeof k=="function"?k.call(b,g,_):k,_==null)break e;g=wn({},g,_);break e;case 2:za=!0}}a.callback!==null&&a.lane!==0&&(e.flags|=64,_=s.effects,_===null?s.effects=[a]:_.push(a))}else b={eventTime:b,lane:_,tag:a.tag,payload:a.payload,callback:a.callback,next:null},d===null?(f=d=b,c=g):d=d.next=b,o|=_;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;_=a,a=_.next,_.next=null,s.lastBaseUpdate=_,s.shared.pending=null}}while(1);if(d===null&&(c=g),s.baseState=c,s.firstBaseUpdate=f,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do o|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);Vc|=o,e.lanes=o,e.memoizedState=g}}function LP(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(ae(191,s));s.call(r)}}}var Sm={},po=zl(Sm),ig=zl(Sm),og=zl(Sm);function yc(e){if(e===Sm)throw Error(ae(174));return e}function fR(e,t){switch(Qt(og,t),Qt(ig,e),Qt(po,Sm),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:IE(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=IE(t,e)}rn(po),Qt(po,t)}function ld(){rn(po),rn(ig),rn(og)}function TD(e){yc(og.current);var t=yc(po.current),n=IE(t,e.type);t!==n&&(Qt(ig,e),Qt(po,n))}function dR(e){ig.current===e&&(rn(po),rn(ig))}var mn=zl(0);function mS(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var l1=[];function hR(){for(var e=0;e<l1.length;e++)l1[e]._workInProgressVersionPrimary=null;l1.length=0}var b_=Ea.ReactCurrentDispatcher,c1=Ea.ReactCurrentBatchConfig,Bc=0,vn=null,Qn=null,lr=null,yS=!1,kp=!1,ag=0,tK=0;function Ir(){throw Error(ae(321))}function pR(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!qi(e[n],t[n]))return!1;return!0}function gR(e,t,n,r,s,i){if(Bc=i,vn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,b_.current=e===null||e.memoizedState===null?iK:oK,e=n(r,s),kp){i=0;do{if(kp=!1,ag=0,25<=i)throw Error(ae(301));i+=1,lr=Qn=null,t.updateQueue=null,b_.current=aK,e=n(r,s)}while(kp)}if(b_.current=_S,t=Qn!==null&&Qn.next!==null,Bc=0,lr=Qn=vn=null,yS=!1,t)throw Error(ae(300));return e}function mR(){var e=ag!==0;return ag=0,e}function Xi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return lr===null?vn.memoizedState=lr=e:lr=lr.next=e,lr}function gi(){if(Qn===null){var e=vn.alternate;e=e!==null?e.memoizedState:null}else e=Qn.next;var t=lr===null?vn.memoizedState:lr.next;if(t!==null)lr=t,Qn=e;else{if(e===null)throw Error(ae(310));Qn=e,e={memoizedState:Qn.memoizedState,baseState:Qn.baseState,baseQueue:Qn.baseQueue,queue:Qn.queue,next:null},lr===null?vn.memoizedState=lr=e:lr=lr.next=e}return lr}function lg(e,t){return typeof t=="function"?t(e):t}function u1(e){var t=gi(),n=t.queue;if(n===null)throw Error(ae(311));n.lastRenderedReducer=e;var r=Qn,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var a=o=null,c=null,f=i;do{var d=f.lane;if((Bc&d)===d)c!==null&&(c=c.next={lane:0,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null}),r=f.hasEagerState?f.eagerState:e(r,f.action);else{var g={lane:d,action:f.action,hasEagerState:f.hasEagerState,eagerState:f.eagerState,next:null};c===null?(a=c=g,o=r):c=c.next=g,vn.lanes|=d,Vc|=d}f=f.next}while(f!==null&&f!==i);c===null?o=r:c.next=a,qi(r,t.memoizedState)||(ls=!0),t.memoizedState=r,t.baseState=o,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,vn.lanes|=i,Vc|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function f1(e){var t=gi(),n=t.queue;if(n===null)throw Error(ae(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=e(i,o.action),o=o.next;while(o!==s);qi(i,t.memoizedState)||(ls=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function PD(){}function OD(e,t){var n=vn,r=gi(),s=t(),i=!qi(r.memoizedState,s);if(i&&(r.memoizedState=s,ls=!0),r=r.queue,yR(ND.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||lr!==null&&lr.memoizedState.tag&1){if(n.flags|=2048,cg(9,FD.bind(null,n,r,s,t),void 0,null),hr===null)throw Error(ae(349));Bc&30||AD(n,t,s)}return s}function AD(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=vn.updateQueue,t===null?(t={lastEffect:null,stores:null},vn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function FD(e,t,n,r){t.value=n,t.getSnapshot=r,DD(t)&&qD(e)}function ND(e,t,n){return n(function(){DD(t)&&qD(e)})}function DD(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!qi(e,n)}catch{return!0}}function qD(e){var t=ca(e,1);t!==null&&Oi(t,e,1,-1)}function zP(e){var t=Xi();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:lg,lastRenderedState:e},t.queue=e,e=e.dispatch=sK.bind(null,vn,e),[t.memoizedState,e]}function cg(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=vn.updateQueue,t===null?(t={lastEffect:null,stores:null},vn.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function MD(){return gi().memoizedState}function E_(e,t,n,r){var s=Xi();vn.flags|=e,s.memoizedState=cg(1|t,n,void 0,r===void 0?null:r)}function yv(e,t,n,r){var s=gi();r=r===void 0?null:r;var i=void 0;if(Qn!==null){var o=Qn.memoizedState;if(i=o.destroy,r!==null&&pR(r,o.deps)){s.memoizedState=cg(t,n,i,r);return}}vn.flags|=e,s.memoizedState=cg(1|t,n,i,r)}function jP(e,t){return E_(8390656,8,e,t)}function yR(e,t){return yv(2048,8,e,t)}function LD(e,t){return yv(4,2,e,t)}function zD(e,t){return yv(4,4,e,t)}function jD(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function UD(e,t,n){return n=n!=null?n.concat([e]):null,yv(4,4,jD.bind(null,t,e),n)}function _R(){}function HD(e,t){var n=gi();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&pR(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function BD(e,t){var n=gi();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&pR(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function VD(e,t,n){return Bc&21?(qi(n,t)||(n=J3(),vn.lanes|=n,Vc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,ls=!0),e.memoizedState=n)}function nK(e,t){var n=Nt;Nt=n!==0&&4>n?n:4,e(!0);var r=c1.transition;c1.transition={};try{e(!1),t()}finally{Nt=n,c1.transition=r}}function WD(){return gi().memoizedState}function rK(e,t,n){var r=fl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},KD(e))GD(t,n);else if(n=$D(e,t,n,r),n!==null){var s=Wr();Oi(n,e,r,s),QD(n,t,r)}}function sK(e,t,n){var r=fl(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(KD(e))GD(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,a=i(o,n);if(s.hasEagerState=!0,s.eagerState=a,qi(a,o)){var c=t.interleaved;c===null?(s.next=s,cR(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=$D(e,t,s,r),n!==null&&(s=Wr(),Oi(n,e,r,s),QD(n,t,r))}}function KD(e){var t=e.alternate;return e===vn||t!==null&&t===vn}function GD(e,t){kp=yS=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function QD(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Qx(e,n)}}var _S={readContext:pi,useCallback:Ir,useContext:Ir,useEffect:Ir,useImperativeHandle:Ir,useInsertionEffect:Ir,useLayoutEffect:Ir,useMemo:Ir,useReducer:Ir,useRef:Ir,useState:Ir,useDebugValue:Ir,useDeferredValue:Ir,useTransition:Ir,useMutableSource:Ir,useSyncExternalStore:Ir,useId:Ir,unstable_isNewReconciler:!1},iK={readContext:pi,useCallback:function(e,t){return Xi().memoizedState=[e,t===void 0?null:t],e},useContext:pi,useEffect:jP,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,E_(4194308,4,jD.bind(null,t,e),n)},useLayoutEffect:function(e,t){return E_(4194308,4,e,t)},useInsertionEffect:function(e,t){return E_(4,2,e,t)},useMemo:function(e,t){var n=Xi();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Xi();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=rK.bind(null,vn,e),[r.memoizedState,e]},useRef:function(e){var t=Xi();return e={current:e},t.memoizedState=e},useState:zP,useDebugValue:_R,useDeferredValue:function(e){return Xi().memoizedState=e},useTransition:function(){var e=zP(!1),t=e[0];return e=nK.bind(null,e[1]),Xi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=vn,s=Xi();if(cn){if(n===void 0)throw Error(ae(407));n=n()}else{if(n=t(),hr===null)throw Error(ae(349));Bc&30||AD(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,jP(ND.bind(null,r,i,e),[e]),r.flags|=2048,cg(9,FD.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Xi(),t=hr.identifierPrefix;if(cn){var n=Wo,r=Vo;n=(r&~(1<<32-Pi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=ag++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=tK++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},oK={readContext:pi,useCallback:HD,useContext:pi,useEffect:yR,useImperativeHandle:UD,useInsertionEffect:LD,useLayoutEffect:zD,useMemo:BD,useReducer:u1,useRef:MD,useState:function(){return u1(lg)},useDebugValue:_R,useDeferredValue:function(e){var t=gi();return VD(t,Qn.memoizedState,e)},useTransition:function(){var e=u1(lg)[0],t=gi().memoizedState;return[e,t]},useMutableSource:PD,useSyncExternalStore:OD,useId:WD,unstable_isNewReconciler:!1},aK={readContext:pi,useCallback:HD,useContext:pi,useEffect:yR,useImperativeHandle:UD,useInsertionEffect:LD,useLayoutEffect:zD,useMemo:BD,useReducer:f1,useRef:MD,useState:function(){return f1(lg)},useDebugValue:_R,useDeferredValue:function(e){var t=gi();return Qn===null?t.memoizedState=e:VD(t,Qn.memoizedState,e)},useTransition:function(){var e=f1(lg)[0],t=gi().memoizedState;return[e,t]},useMutableSource:PD,useSyncExternalStore:OD,useId:WD,unstable_isNewReconciler:!1};function wi(e,t){if(e&&e.defaultProps){t=wn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function JE(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:wn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var _v={isMounted:function(e){return(e=e._reactInternals)?wu(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Wr(),s=fl(e),i=Yo(r,s);i.payload=t,n!=null&&(i.callback=n),t=cl(e,i,s),t!==null&&(Oi(t,e,s,r),w_(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Wr(),s=fl(e),i=Yo(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=cl(e,i,s),t!==null&&(Oi(t,e,s,r),w_(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Wr(),r=fl(e),s=Yo(n,r);s.tag=2,t!=null&&(s.callback=t),t=cl(e,s,r),t!==null&&(Oi(t,e,r,n),w_(t,e,r))}};function UP(e,t,n,r,s,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,o):t.prototype&&t.prototype.isPureReactComponent?!tg(n,r)||!tg(s,i):!0}function JD(e,t,n){var r=!1,s=vl,i=t.contextType;return typeof i=="object"&&i!==null?i=pi(i):(s=us(t)?Uc:Dr.current,r=t.contextTypes,i=(r=r!=null)?id(e,s):vl),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=_v,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function HP(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&_v.enqueueReplaceState(t,t.state,null)}function YE(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},uR(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=pi(i):(i=us(t)?Uc:Dr.current,s.context=id(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(JE(e,t,i,n),s.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(t=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),t!==s.state&&_v.enqueueReplaceState(s,s.state,null),gS(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function cd(e,t){try{var n="",r=t;do n+=NW(r),r=r.return;while(r);var s=n}catch(i){s=`
39
+ Error generating stack: `+i.message+`
40
+ `+i.stack}return{value:e,source:t,stack:s,digest:null}}function d1(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function XE(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var lK=typeof WeakMap=="function"?WeakMap:Map;function YD(e,t,n){n=Yo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){vS||(vS=!0,lk=r),XE(e,t)},n}function XD(e,t,n){n=Yo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var s=t.value;n.payload=function(){return r(s)},n.callback=function(){XE(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){XE(e,t),typeof r!="function"&&(ul===null?ul=new Set([this]):ul.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),n}function BP(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new lK;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=bK.bind(null,e,t,n),t.then(e,e))}function VP(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function WP(e,t,n,r,s){return e.mode&1?(e.flags|=65536,e.lanes=s,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Yo(-1,1),t.tag=2,cl(n,t,1))),n.lanes|=1),e)}var cK=Ea.ReactCurrentOwner,ls=!1;function zr(e,t,n,r){t.child=e===null?RD(t,null,n,r):ad(t,e.child,n,r)}function KP(e,t,n,r,s){n=n.render;var i=t.ref;return Mf(t,s),r=gR(e,t,n,r,i,s),n=mR(),e!==null&&!ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ua(e,t,s)):(cn&&n&&rR(t),t.flags|=1,zr(e,t,r,s),t.child)}function GP(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!xR(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,ZD(e,t,i,r,s)):(e=R_(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:tg,n(o,r)&&e.ref===t.ref)return ua(e,t,s)}return t.flags|=1,e=dl(i,r),e.ref=t.ref,e.return=t,t.child=e}function ZD(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(tg(i,r)&&e.ref===t.ref)if(ls=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(ls=!0);else return t.lanes=e.lanes,ua(e,t,s)}return ZE(e,t,n,r,s)}function eq(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qt(Cf,Rs),Rs|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Qt(Cf,Rs),Rs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,Qt(Cf,Rs),Rs|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,Qt(Cf,Rs),Rs|=r;return zr(e,t,s,n),t.child}function tq(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function ZE(e,t,n,r,s){var i=us(n)?Uc:Dr.current;return i=id(t,i),Mf(t,s),n=gR(e,t,n,r,i,s),r=mR(),e!==null&&!ls?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ua(e,t,s)):(cn&&r&&rR(t),t.flags|=1,zr(e,t,n,s),t.child)}function QP(e,t,n,r,s){if(us(n)){var i=!0;uS(t)}else i=!1;if(Mf(t,s),t.stateNode===null)k_(e,t),JD(t,n,r),YE(t,n,r,s),r=!0;else if(e===null){var o=t.stateNode,a=t.memoizedProps;o.props=a;var c=o.context,f=n.contextType;typeof f=="object"&&f!==null?f=pi(f):(f=us(n)?Uc:Dr.current,f=id(t,f));var d=n.getDerivedStateFromProps,g=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function";g||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||c!==f)&&HP(t,o,r,f),za=!1;var _=t.memoizedState;o.state=_,gS(t,r,o,s),c=t.memoizedState,a!==r||_!==c||cs.current||za?(typeof d=="function"&&(JE(t,n,d,r),c=t.memoizedState),(a=za||UP(t,n,a,r,_,c,f))?(g||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),o.props=r,o.state=c,o.context=f,r=a):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,ID(e,t),a=t.memoizedProps,f=t.type===t.elementType?a:wi(t.type,a),o.props=f,g=t.pendingProps,_=o.context,c=n.contextType,typeof c=="object"&&c!==null?c=pi(c):(c=us(n)?Uc:Dr.current,c=id(t,c));var b=n.getDerivedStateFromProps;(d=typeof b=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==g||_!==c)&&HP(t,o,r,c),za=!1,_=t.memoizedState,o.state=_,gS(t,r,o,s);var k=t.memoizedState;a!==g||_!==k||cs.current||za?(typeof b=="function"&&(JE(t,n,b,r),k=t.memoizedState),(f=za||UP(t,n,f,r,_,k,c)||!1)?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,k,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,k,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&_===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&_===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=k),o.props=r,o.state=k,o.context=c,r=f):(typeof o.componentDidUpdate!="function"||a===e.memoizedProps&&_===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===e.memoizedProps&&_===e.memoizedState||(t.flags|=1024),r=!1)}return ek(e,t,n,r,i,s)}function ek(e,t,n,r,s,i){tq(e,t);var o=(t.flags&128)!==0;if(!r&&!o)return s&&FP(t,n,!1),ua(e,t,i);r=t.stateNode,cK.current=t;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&o?(t.child=ad(t,e.child,null,i),t.child=ad(t,null,a,i)):zr(e,t,a,i),t.memoizedState=r.state,s&&FP(t,n,!0),t.child}function nq(e){var t=e.stateNode;t.pendingContext?AP(e,t.pendingContext,t.pendingContext!==t.context):t.context&&AP(e,t.context,!1),fR(e,t.containerInfo)}function JP(e,t,n,r,s){return od(),iR(s),t.flags|=256,zr(e,t,n,r),t.child}var tk={dehydrated:null,treeContext:null,retryLane:0};function nk(e){return{baseLanes:e,cachePool:null,transitions:null}}function rq(e,t,n){var r=t.pendingProps,s=mn.current,i=!1,o=(t.flags&128)!==0,a;if((a=o)||(a=e!==null&&e.memoizedState===null?!1:(s&2)!==0),a?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),Qt(mn,s&1),e===null)return GE(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=r.children,e=r.fallback,i?(r=t.mode,i=t.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=wv(o,r,0,null),e=Oc(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=nk(n),t.memoizedState=tk,e):SR(t,o));if(s=e.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return uK(e,t,o,r,a,s,n);if(i){i=r.fallback,o=t.mode,s=e.child,a=s.sibling;var c={mode:"hidden",children:r.children};return!(o&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=dl(s,c),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=dl(a,i):(i=Oc(i,o,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,o=e.child.memoizedState,o=o===null?nk(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~n,t.memoizedState=tk,r}return i=e.child,e=i.sibling,r=dl(i,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function SR(e,t){return t=wv({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Uy(e,t,n,r){return r!==null&&iR(r),ad(t,e.child,null,n),e=SR(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function uK(e,t,n,r,s,i,o){if(n)return t.flags&256?(t.flags&=-257,r=d1(Error(ae(422))),Uy(e,t,o,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=wv({mode:"visible",children:r.children},s,0,null),i=Oc(i,s,o,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&ad(t,e.child,null,o),t.child.memoizedState=nk(o),t.memoizedState=tk,i);if(!(t.mode&1))return Uy(e,t,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error(ae(419)),r=d1(i,r,void 0),Uy(e,t,o,r)}if(a=(o&e.childLanes)!==0,ls||a){if(r=hr,r!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,ca(e,s),Oi(r,e,s,-1))}return CR(),r=d1(Error(ae(421))),Uy(e,t,o,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=EK.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Ts=ll(s.nextSibling),Os=t,cn=!0,xi=null,e!==null&&(Zs[ei++]=Vo,Zs[ei++]=Wo,Zs[ei++]=Hc,Vo=e.id,Wo=e.overflow,Hc=t),t=SR(t,r.children),t.flags|=4096,t)}function YP(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),QE(e.return,t,n)}function h1(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function sq(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(zr(e,t,r.children,n),r=mn.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&YP(e,n,t);else if(e.tag===19)YP(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Qt(mn,r),!(t.mode&1))t.memoizedState=null;else switch(s){case"forwards":for(n=t.child,s=null;n!==null;)e=n.alternate,e!==null&&mS(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),h1(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&mS(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}h1(t,!0,n,null,i);break;case"together":h1(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function k_(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ua(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Vc|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(ae(153));if(t.child!==null){for(e=t.child,n=dl(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=dl(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function fK(e,t,n){switch(t.tag){case 3:nq(t),od();break;case 5:TD(t);break;case 1:us(t.type)&&uS(t);break;case 4:fR(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;Qt(hS,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Qt(mn,mn.current&1),t.flags|=128,null):n&t.child.childLanes?rq(e,t,n):(Qt(mn,mn.current&1),e=ua(e,t,n),e!==null?e.sibling:null);Qt(mn,mn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return sq(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),Qt(mn,mn.current),r)break;return null;case 22:case 23:return t.lanes=0,eq(e,t,n)}return ua(e,t,n)}var iq,rk,oq,aq;iq=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};rk=function(){};oq=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,yc(po.current);var i=null;switch(n){case"input":s=CE(e,s),r=CE(e,r),i=[];break;case"select":s=wn({},s,{value:void 0}),r=wn({},r,{value:void 0}),i=[];break;case"textarea":s=$E(e,s),r=$E(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=lS)}TE(n,r);var o;n=null;for(f in s)if(!r.hasOwnProperty(f)&&s.hasOwnProperty(f)&&s[f]!=null)if(f==="style"){var a=s[f];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(Gp.hasOwnProperty(f)?i||(i=[]):(i=i||[]).push(f,null));for(f in r){var c=r[f];if(a=s!=null?s[f]:void 0,r.hasOwnProperty(f)&&c!==a&&(c!=null||a!=null))if(f==="style")if(a){for(o in a)!a.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in c)c.hasOwnProperty(o)&&a[o]!==c[o]&&(n||(n={}),n[o]=c[o])}else n||(i||(i=[]),i.push(f,n)),n=c;else f==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,a=a?a.__html:void 0,c!=null&&a!==c&&(i=i||[]).push(f,c)):f==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(f,""+c):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(Gp.hasOwnProperty(f)?(c!=null&&f==="onScroll"&&Zt("scroll",e),i||a===c||(i=[])):(i=i||[]).push(f,c))}n&&(i=i||[]).push("style",n);var f=i;(t.updateQueue=f)&&(t.flags|=4)}};aq=function(e,t,n,r){n!==r&&(t.flags|=4)};function Uh(e,t){if(!cn)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Tr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=e,s=s.sibling;else for(s=e.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=e,s=s.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function dK(e,t,n){var r=t.pendingProps;switch(sR(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Tr(t),null;case 1:return us(t.type)&&cS(),Tr(t),null;case 3:return r=t.stateNode,ld(),rn(cs),rn(Dr),hR(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(zy(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,xi!==null&&(fk(xi),xi=null))),rk(e,t),Tr(t),null;case 5:dR(t);var s=yc(og.current);if(n=t.type,e!==null&&t.stateNode!=null)oq(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(ae(166));return Tr(t),null}if(e=yc(po.current),zy(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[ro]=t,r[sg]=i,e=(t.mode&1)!==0,n){case"dialog":Zt("cancel",r),Zt("close",r);break;case"iframe":case"object":case"embed":Zt("load",r);break;case"video":case"audio":for(s=0;s<ip.length;s++)Zt(ip[s],r);break;case"source":Zt("error",r);break;case"img":case"image":case"link":Zt("error",r),Zt("load",r);break;case"details":Zt("toggle",r);break;case"input":oP(r,i),Zt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},Zt("invalid",r);break;case"textarea":lP(r,i),Zt("invalid",r)}TE(n,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o];o==="children"?typeof a=="string"?r.textContent!==a&&(i.suppressHydrationWarning!==!0&&Ly(r.textContent,a,e),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&Ly(r.textContent,a,e),s=["children",""+a]):Gp.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&Zt("scroll",r)}switch(n){case"input":Py(r),aP(r,i,!0);break;case"textarea":Py(r),cP(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=lS)}r=s,t.updateQueue=r,r!==null&&(t.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=N3(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=o.createElement(n,{is:r.is}):(e=o.createElement(n),n==="select"&&(o=e,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):e=o.createElementNS(e,n),e[ro]=t,e[sg]=r,iq(e,t,!1,!1),t.stateNode=e;e:{switch(o=PE(n,r),n){case"dialog":Zt("cancel",e),Zt("close",e),s=r;break;case"iframe":case"object":case"embed":Zt("load",e),s=r;break;case"video":case"audio":for(s=0;s<ip.length;s++)Zt(ip[s],e);s=r;break;case"source":Zt("error",e),s=r;break;case"img":case"image":case"link":Zt("error",e),Zt("load",e),s=r;break;case"details":Zt("toggle",e),s=r;break;case"input":oP(e,r),s=CE(e,r),Zt("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=wn({},r,{value:void 0}),Zt("invalid",e);break;case"textarea":lP(e,r),s=$E(e,r),Zt("invalid",e);break;default:s=r}TE(n,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var c=a[i];i==="style"?M3(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&D3(e,c)):i==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Qp(e,c):typeof c=="number"&&Qp(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Gp.hasOwnProperty(i)?c!=null&&i==="onScroll"&&Zt("scroll",e):c!=null&&Hx(e,i,c,o))}switch(n){case"input":Py(e),aP(e,r,!1);break;case"textarea":Py(e),cP(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Sl(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?Ff(e,!!r.multiple,i,!1):r.defaultValue!=null&&Ff(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=lS)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Tr(t),null;case 6:if(e&&t.stateNode!=null)aq(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(ae(166));if(n=yc(og.current),yc(po.current),zy(t)){if(r=t.stateNode,n=t.memoizedProps,r[ro]=t,(i=r.nodeValue!==n)&&(e=Os,e!==null))switch(e.tag){case 3:Ly(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ly(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[ro]=t,t.stateNode=r}return Tr(t),null;case 13:if(rn(mn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(cn&&Ts!==null&&t.mode&1&&!(t.flags&128))CD(),od(),t.flags|=98560,i=!1;else if(i=zy(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(ae(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(ae(317));i[ro]=t}else od(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Tr(t),i=!1}else xi!==null&&(fk(xi),xi=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||mn.current&1?Xn===0&&(Xn=3):CR())),t.updateQueue!==null&&(t.flags|=4),Tr(t),null);case 4:return ld(),rk(e,t),e===null&&ng(t.stateNode.containerInfo),Tr(t),null;case 10:return lR(t.type._context),Tr(t),null;case 17:return us(t.type)&&cS(),Tr(t),null;case 19:if(rn(mn),i=t.memoizedState,i===null)return Tr(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)Uh(i,!1);else{if(Xn!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=mS(e),o!==null){for(t.flags|=128,Uh(i,!1),r=o.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Qt(mn,mn.current&1|2),t.child}e=e.sibling}i.tail!==null&&On()>ud&&(t.flags|=128,r=!0,Uh(i,!1),t.lanes=4194304)}else{if(!r)if(e=mS(o),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Uh(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!cn)return Tr(t),null}else 2*On()-i.renderingStartTime>ud&&n!==1073741824&&(t.flags|=128,r=!0,Uh(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(n=i.last,n!==null?n.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=On(),t.sibling=null,n=mn.current,Qt(mn,r?n&1|2:n&1),t):(Tr(t),null);case 22:case 23:return kR(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Rs&1073741824&&(Tr(t),t.subtreeFlags&6&&(t.flags|=8192)):Tr(t),null;case 24:return null;case 25:return null}throw Error(ae(156,t.tag))}function hK(e,t){switch(sR(t),t.tag){case 1:return us(t.type)&&cS(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ld(),rn(cs),rn(Dr),hR(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return dR(t),null;case 13:if(rn(mn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(ae(340));od()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return rn(mn),null;case 4:return ld(),null;case 10:return lR(t.type._context),null;case 22:case 23:return kR(),null;case 24:return null;default:return null}}var Hy=!1,Fr=!1,pK=typeof WeakSet=="function"?WeakSet:Set,ye=null;function kf(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Cn(e,t,r)}else n.current=null}function sk(e,t,n){try{n()}catch(r){Cn(e,t,r)}}var XP=!1;function gK(e,t){if(jE=iS,e=dD(),nR(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,a=-1,c=-1,f=0,d=0,g=e,_=null;t:for(;;){for(var b;g!==n||s!==0&&g.nodeType!==3||(a=o+s),g!==i||r!==0&&g.nodeType!==3||(c=o+r),g.nodeType===3&&(o+=g.nodeValue.length),(b=g.firstChild)!==null;)_=g,g=b;for(;;){if(g===e)break t;if(_===n&&++f===s&&(a=o),_===i&&++d===r&&(c=o),(b=g.nextSibling)!==null)break;g=_,_=g.parentNode}g=b}n=a===-1||c===-1?null:{start:a,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(UE={focusedElem:e,selectionRange:n},iS=!1,ye=t;ye!==null;)if(t=ye,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ye=e;else for(;ye!==null;){t=ye;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var I=k.memoizedProps,E=k.memoizedState,y=t.stateNode,m=y.getSnapshotBeforeUpdate(t.elementType===t.type?I:wi(t.type,I),E);y.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ae(163))}}catch(w){Cn(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,ye=e;break}ye=t.return}return k=XP,XP=!1,k}function Cp(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&sk(t,n,i)}s=s.next}while(s!==r)}}function Sv(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ik(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function lq(e){var t=e.alternate;t!==null&&(e.alternate=null,lq(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ro],delete t[sg],delete t[VE],delete t[Y7],delete t[X7])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function cq(e){return e.tag===5||e.tag===3||e.tag===4}function ZP(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||cq(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function ok(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=lS));else if(r!==4&&(e=e.child,e!==null))for(ok(e,t,n),e=e.sibling;e!==null;)ok(e,t,n),e=e.sibling}function ak(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ak(e,t,n),e=e.sibling;e!==null;)ak(e,t,n),e=e.sibling}var vr=null,Ci=!1;function Na(e,t,n){for(n=n.child;n!==null;)uq(e,t,n),n=n.sibling}function uq(e,t,n){if(ho&&typeof ho.onCommitFiberUnmount=="function")try{ho.onCommitFiberUnmount(fv,n)}catch{}switch(n.tag){case 5:Fr||kf(n,t);case 6:var r=vr,s=Ci;vr=null,Na(e,t,n),vr=r,Ci=s,vr!==null&&(Ci?(e=vr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):vr.removeChild(n.stateNode));break;case 18:vr!==null&&(Ci?(e=vr,n=n.stateNode,e.nodeType===8?o1(e.parentNode,n):e.nodeType===1&&o1(e,n),Zp(e)):o1(vr,n.stateNode));break;case 4:r=vr,s=Ci,vr=n.stateNode.containerInfo,Ci=!0,Na(e,t,n),vr=r,Ci=s;break;case 0:case 11:case 14:case 15:if(!Fr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&sk(n,t,o),s=s.next}while(s!==r)}Na(e,t,n);break;case 1:if(!Fr&&(kf(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Cn(n,t,a)}Na(e,t,n);break;case 21:Na(e,t,n);break;case 22:n.mode&1?(Fr=(r=Fr)||n.memoizedState!==null,Na(e,t,n),Fr=r):Na(e,t,n);break;default:Na(e,t,n)}}function eO(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pK),t.forEach(function(r){var s=kK.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Si(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,o=t,a=o;e:for(;a!==null;){switch(a.tag){case 5:vr=a.stateNode,Ci=!1;break e;case 3:vr=a.stateNode.containerInfo,Ci=!0;break e;case 4:vr=a.stateNode.containerInfo,Ci=!0;break e}a=a.return}if(vr===null)throw Error(ae(160));uq(i,o,s),vr=null,Ci=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(f){Cn(s,t,f)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)fq(t,e),t=t.sibling}function fq(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Si(t,e),Qi(e),r&4){try{Cp(3,e,e.return),Sv(3,e)}catch(I){Cn(e,e.return,I)}try{Cp(5,e,e.return)}catch(I){Cn(e,e.return,I)}}break;case 1:Si(t,e),Qi(e),r&512&&n!==null&&kf(n,n.return);break;case 5:if(Si(t,e),Qi(e),r&512&&n!==null&&kf(n,n.return),e.flags&32){var s=e.stateNode;try{Qp(s,"")}catch(I){Cn(e,e.return,I)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,o=n!==null?n.memoizedProps:i,a=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&A3(s,i),PE(a,o);var f=PE(a,i);for(o=0;o<c.length;o+=2){var d=c[o],g=c[o+1];d==="style"?M3(s,g):d==="dangerouslySetInnerHTML"?D3(s,g):d==="children"?Qp(s,g):Hx(s,d,g,f)}switch(a){case"input":xE(s,i);break;case"textarea":F3(s,i);break;case"select":var _=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var b=i.value;b!=null?Ff(s,!!i.multiple,b,!1):_!==!!i.multiple&&(i.defaultValue!=null?Ff(s,!!i.multiple,i.defaultValue,!0):Ff(s,!!i.multiple,i.multiple?[]:"",!1))}s[sg]=i}catch(I){Cn(e,e.return,I)}}break;case 6:if(Si(t,e),Qi(e),r&4){if(e.stateNode===null)throw Error(ae(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(I){Cn(e,e.return,I)}}break;case 3:if(Si(t,e),Qi(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Zp(t.containerInfo)}catch(I){Cn(e,e.return,I)}break;case 4:Si(t,e),Qi(e);break;case 13:Si(t,e),Qi(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(bR=On())),r&4&&eO(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Fr=(f=Fr)||d,Si(t,e),Fr=f):Si(t,e),Qi(e),r&8192){if(f=e.memoizedState!==null,(e.stateNode.isHidden=f)&&!d&&e.mode&1)for(ye=e,d=e.child;d!==null;){for(g=ye=d;ye!==null;){switch(_=ye,b=_.child,_.tag){case 0:case 11:case 14:case 15:Cp(4,_,_.return);break;case 1:kf(_,_.return);var k=_.stateNode;if(typeof k.componentWillUnmount=="function"){r=_,n=_.return;try{t=r,k.props=t.memoizedProps,k.state=t.memoizedState,k.componentWillUnmount()}catch(I){Cn(r,n,I)}}break;case 5:kf(_,_.return);break;case 22:if(_.memoizedState!==null){nO(g);continue}}b!==null?(b.return=_,ye=b):nO(g)}d=d.sibling}e:for(d=null,g=e;;){if(g.tag===5){if(d===null){d=g;try{s=g.stateNode,f?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=g.stateNode,c=g.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,a.style.display=q3("display",o))}catch(I){Cn(e,e.return,I)}}}else if(g.tag===6){if(d===null)try{g.stateNode.nodeValue=f?"":g.memoizedProps}catch(I){Cn(e,e.return,I)}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===e)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===e)break e;for(;g.sibling===null;){if(g.return===null||g.return===e)break e;d===g&&(d=null),g=g.return}d===g&&(d=null),g.sibling.return=g.return,g=g.sibling}}break;case 19:Si(t,e),Qi(e),r&4&&eO(e);break;case 21:break;default:Si(t,e),Qi(e)}}function Qi(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(cq(n)){var r=n;break e}n=n.return}throw Error(ae(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Qp(s,""),r.flags&=-33);var i=ZP(e);ak(e,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,a=ZP(e);ok(e,a,o);break;default:throw Error(ae(161))}}catch(c){Cn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function mK(e,t,n){ye=e,dq(e)}function dq(e,t,n){for(var r=(e.mode&1)!==0;ye!==null;){var s=ye,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||Hy;if(!o){var a=s.alternate,c=a!==null&&a.memoizedState!==null||Fr;a=Hy;var f=Fr;if(Hy=o,(Fr=c)&&!f)for(ye=s;ye!==null;)o=ye,c=o.child,o.tag===22&&o.memoizedState!==null?rO(s):c!==null?(c.return=o,ye=c):rO(s);for(;i!==null;)ye=i,dq(i),i=i.sibling;ye=s,Hy=a,Fr=f}tO(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,ye=i):tO(e)}}function tO(e){for(;ye!==null;){var t=ye;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Fr||Sv(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Fr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:wi(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&LP(t,i,r);break;case 3:var o=t.updateQueue;if(o!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}LP(t,o,n)}break;case 5:var a=t.stateNode;if(n===null&&t.flags&4){n=a;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var f=t.alternate;if(f!==null){var d=f.memoizedState;if(d!==null){var g=d.dehydrated;g!==null&&Zp(g)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ae(163))}Fr||t.flags&512&&ik(t)}catch(_){Cn(t,t.return,_)}}if(t===e){ye=null;break}if(n=t.sibling,n!==null){n.return=t.return,ye=n;break}ye=t.return}}function nO(e){for(;ye!==null;){var t=ye;if(t===e){ye=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ye=n;break}ye=t.return}}function rO(e){for(;ye!==null;){var t=ye;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Sv(4,t)}catch(c){Cn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){Cn(t,s,c)}}var i=t.return;try{ik(t)}catch(c){Cn(t,i,c)}break;case 5:var o=t.return;try{ik(t)}catch(c){Cn(t,o,c)}}}catch(c){Cn(t,t.return,c)}if(t===e){ye=null;break}var a=t.sibling;if(a!==null){a.return=t.return,ye=a;break}ye=t.return}}var yK=Math.ceil,SS=Ea.ReactCurrentDispatcher,vR=Ea.ReactCurrentOwner,ci=Ea.ReactCurrentBatchConfig,vt=0,hr=null,Mn=null,Er=0,Rs=0,Cf=zl(0),Xn=0,ug=null,Vc=0,vv=0,wR=0,xp=null,is=null,bR=0,ud=1/0,jo=null,vS=!1,lk=null,ul=null,By=!1,Ja=null,wS=0,Rp=0,ck=null,C_=-1,x_=0;function Wr(){return vt&6?On():C_!==-1?C_:C_=On()}function fl(e){return e.mode&1?vt&2&&Er!==0?Er&-Er:eK.transition!==null?(x_===0&&(x_=J3()),x_):(e=Nt,e!==0||(e=window.event,e=e===void 0?16:rD(e.type)),e):1}function Oi(e,t,n,r){if(50<Rp)throw Rp=0,ck=null,Error(ae(185));mm(e,n,r),(!(vt&2)||e!==hr)&&(e===hr&&(!(vt&2)&&(vv|=n),Xn===4&&Ba(e,Er)),fs(e,r),n===1&&vt===0&&!(t.mode&1)&&(ud=On()+500,mv&&jl()))}function fs(e,t){var n=e.callbackNode;e7(e,t);var r=sS(e,e===hr?Er:0);if(r===0)n!==null&&dP(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&dP(n),t===1)e.tag===0?Z7(sO.bind(null,e)):bD(sO.bind(null,e)),Q7(function(){!(vt&6)&&jl()}),n=null;else{switch(Y3(r)){case 1:n=Gx;break;case 4:n=G3;break;case 16:n=rS;break;case 536870912:n=Q3;break;default:n=rS}n=vq(n,hq.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function hq(e,t){if(C_=-1,x_=0,vt&6)throw Error(ae(327));var n=e.callbackNode;if(Lf()&&e.callbackNode!==n)return null;var r=sS(e,e===hr?Er:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=bS(e,r);else{t=r;var s=vt;vt|=2;var i=gq();(hr!==e||Er!==t)&&(jo=null,ud=On()+500,Pc(e,t));do try{vK();break}catch(a){pq(e,a)}while(1);aR(),SS.current=i,vt=s,Mn!==null?t=0:(hr=null,Er=0,t=Xn)}if(t!==0){if(t===2&&(s=DE(e),s!==0&&(r=s,t=uk(e,s))),t===1)throw n=ug,Pc(e,0),Ba(e,r),fs(e,On()),n;if(t===6)Ba(e,r);else{if(s=e.current.alternate,!(r&30)&&!_K(s)&&(t=bS(e,r),t===2&&(i=DE(e),i!==0&&(r=i,t=uk(e,i))),t===1))throw n=ug,Pc(e,0),Ba(e,r),fs(e,On()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(ae(345));case 2:lc(e,is,jo);break;case 3:if(Ba(e,r),(r&130023424)===r&&(t=bR+500-On(),10<t)){if(sS(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Wr(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=BE(lc.bind(null,e,is,jo),t);break}lc(e,is,jo);break;case 4:if(Ba(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var o=31-Pi(r);i=1<<o,o=t[o],o>s&&(s=o),r&=~i}if(r=s,r=On()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yK(r/1960))-r,10<r){e.timeoutHandle=BE(lc.bind(null,e,is,jo),r);break}lc(e,is,jo);break;case 5:lc(e,is,jo);break;default:throw Error(ae(329))}}}return fs(e,On()),e.callbackNode===n?hq.bind(null,e):null}function uk(e,t){var n=xp;return e.current.memoizedState.isDehydrated&&(Pc(e,t).flags|=256),e=bS(e,t),e!==2&&(t=is,is=n,t!==null&&fk(t)),e}function fk(e){is===null?is=e:is.push.apply(is,e)}function _K(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!qi(i(),s))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ba(e,t){for(t&=~wR,t&=~vv,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Pi(t),r=1<<n;e[n]=-1,t&=~r}}function sO(e){if(vt&6)throw Error(ae(327));Lf();var t=sS(e,0);if(!(t&1))return fs(e,On()),null;var n=bS(e,t);if(e.tag!==0&&n===2){var r=DE(e);r!==0&&(t=r,n=uk(e,r))}if(n===1)throw n=ug,Pc(e,0),Ba(e,t),fs(e,On()),n;if(n===6)throw Error(ae(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,lc(e,is,jo),fs(e,On()),null}function ER(e,t){var n=vt;vt|=1;try{return e(t)}finally{vt=n,vt===0&&(ud=On()+500,mv&&jl())}}function Wc(e){Ja!==null&&Ja.tag===0&&!(vt&6)&&Lf();var t=vt;vt|=1;var n=ci.transition,r=Nt;try{if(ci.transition=null,Nt=1,e)return e()}finally{Nt=r,ci.transition=n,vt=t,!(vt&6)&&jl()}}function kR(){Rs=Cf.current,rn(Cf)}function Pc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,G7(n)),Mn!==null)for(n=Mn.return;n!==null;){var r=n;switch(sR(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&cS();break;case 3:ld(),rn(cs),rn(Dr),hR();break;case 5:dR(r);break;case 4:ld();break;case 13:rn(mn);break;case 19:rn(mn);break;case 10:lR(r.type._context);break;case 22:case 23:kR()}n=n.return}if(hr=e,Mn=e=dl(e.current,null),Er=Rs=t,Xn=0,ug=null,wR=vv=Vc=0,is=xp=null,mc!==null){for(t=0;t<mc.length;t++)if(n=mc[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=s,r.next=o}n.pending=r}mc=null}return e}function pq(e,t){do{var n=Mn;try{if(aR(),b_.current=_S,yS){for(var r=vn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}yS=!1}if(Bc=0,lr=Qn=vn=null,kp=!1,ag=0,vR.current=null,n===null||n.return===null){Xn=1,ug=t,Mn=null;break}e:{var i=e,o=n.return,a=n,c=t;if(t=Er,a.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var f=c,d=a,g=d.tag;if(!(d.mode&1)&&(g===0||g===11||g===15)){var _=d.alternate;_?(d.updateQueue=_.updateQueue,d.memoizedState=_.memoizedState,d.lanes=_.lanes):(d.updateQueue=null,d.memoizedState=null)}var b=VP(o);if(b!==null){b.flags&=-257,WP(b,o,a,i,t),b.mode&1&&BP(i,f,t),t=b,c=f;var k=t.updateQueue;if(k===null){var I=new Set;I.add(c),t.updateQueue=I}else k.add(c);break e}else{if(!(t&1)){BP(i,f,t),CR();break e}c=Error(ae(426))}}else if(cn&&a.mode&1){var E=VP(o);if(E!==null){!(E.flags&65536)&&(E.flags|=256),WP(E,o,a,i,t),iR(cd(c,a));break e}}i=c=cd(c,a),Xn!==4&&(Xn=2),xp===null?xp=[i]:xp.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=YD(i,c,t);MP(i,y);break e;case 1:a=c;var m=i.type,v=i.stateNode;if(!(i.flags&128)&&(typeof m.getDerivedStateFromError=="function"||v!==null&&typeof v.componentDidCatch=="function"&&(ul===null||!ul.has(v)))){i.flags|=65536,t&=-t,i.lanes|=t;var w=XD(i,a,t);MP(i,w);break e}}i=i.return}while(i!==null)}yq(n)}catch($){t=$,Mn===n&&n!==null&&(Mn=n=n.return);continue}break}while(1)}function gq(){var e=SS.current;return SS.current=_S,e===null?_S:e}function CR(){(Xn===0||Xn===3||Xn===2)&&(Xn=4),hr===null||!(Vc&268435455)&&!(vv&268435455)||Ba(hr,Er)}function bS(e,t){var n=vt;vt|=2;var r=gq();(hr!==e||Er!==t)&&(jo=null,Pc(e,t));do try{SK();break}catch(s){pq(e,s)}while(1);if(aR(),vt=n,SS.current=r,Mn!==null)throw Error(ae(261));return hr=null,Er=0,Xn}function SK(){for(;Mn!==null;)mq(Mn)}function vK(){for(;Mn!==null&&!VW();)mq(Mn)}function mq(e){var t=Sq(e.alternate,e,Rs);e.memoizedProps=e.pendingProps,t===null?yq(e):Mn=t,vR.current=null}function yq(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=hK(n,t),n!==null){n.flags&=32767,Mn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Xn=6,Mn=null;return}}else if(n=dK(n,t,Rs),n!==null){Mn=n;return}if(t=t.sibling,t!==null){Mn=t;return}Mn=t=e}while(t!==null);Xn===0&&(Xn=5)}function lc(e,t,n){var r=Nt,s=ci.transition;try{ci.transition=null,Nt=1,wK(e,t,n,r)}finally{ci.transition=s,Nt=r}return null}function wK(e,t,n,r){do Lf();while(Ja!==null);if(vt&6)throw Error(ae(327));n=e.finishedWork;var s=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(ae(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(t7(e,i),e===hr&&(Mn=hr=null,Er=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||By||(By=!0,vq(rS,function(){return Lf(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=ci.transition,ci.transition=null;var o=Nt;Nt=1;var a=vt;vt|=4,vR.current=null,gK(e,n),fq(n,e),j7(UE),iS=!!jE,UE=jE=null,e.current=n,mK(n),WW(),vt=a,Nt=o,ci.transition=i}else e.current=n;if(By&&(By=!1,Ja=e,wS=s),i=e.pendingLanes,i===0&&(ul=null),QW(n.stateNode),fs(e,On()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)s=t[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(vS)throw vS=!1,e=lk,lk=null,e;return wS&1&&e.tag!==0&&Lf(),i=e.pendingLanes,i&1?e===ck?Rp++:(Rp=0,ck=e):Rp=0,jl(),null}function Lf(){if(Ja!==null){var e=Y3(wS),t=ci.transition,n=Nt;try{if(ci.transition=null,Nt=16>e?16:e,Ja===null)var r=!1;else{if(e=Ja,Ja=null,wS=0,vt&6)throw Error(ae(331));var s=vt;for(vt|=4,ye=e.current;ye!==null;){var i=ye,o=i.child;if(ye.flags&16){var a=i.deletions;if(a!==null){for(var c=0;c<a.length;c++){var f=a[c];for(ye=f;ye!==null;){var d=ye;switch(d.tag){case 0:case 11:case 15:Cp(8,d,i)}var g=d.child;if(g!==null)g.return=d,ye=g;else for(;ye!==null;){d=ye;var _=d.sibling,b=d.return;if(lq(d),d===f){ye=null;break}if(_!==null){_.return=b,ye=_;break}ye=b}}}var k=i.alternate;if(k!==null){var I=k.child;if(I!==null){k.child=null;do{var E=I.sibling;I.sibling=null,I=E}while(I!==null)}}ye=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,ye=o;else e:for(;ye!==null;){if(i=ye,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Cp(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,ye=y;break e}ye=i.return}}var m=e.current;for(ye=m;ye!==null;){o=ye;var v=o.child;if(o.subtreeFlags&2064&&v!==null)v.return=o,ye=v;else e:for(o=m;ye!==null;){if(a=ye,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:Sv(9,a)}}catch($){Cn(a,a.return,$)}if(a===o){ye=null;break e}var w=a.sibling;if(w!==null){w.return=a.return,ye=w;break e}ye=a.return}}if(vt=s,jl(),ho&&typeof ho.onPostCommitFiberRoot=="function")try{ho.onPostCommitFiberRoot(fv,e)}catch{}r=!0}return r}finally{Nt=n,ci.transition=t}}return!1}function iO(e,t,n){t=cd(n,t),t=YD(e,t,1),e=cl(e,t,1),t=Wr(),e!==null&&(mm(e,1,t),fs(e,t))}function Cn(e,t,n){if(e.tag===3)iO(e,e,n);else for(;t!==null;){if(t.tag===3){iO(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ul===null||!ul.has(r))){e=cd(n,e),e=XD(t,e,1),t=cl(t,e,1),e=Wr(),t!==null&&(mm(t,1,e),fs(t,e));break}}t=t.return}}function bK(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Wr(),e.pingedLanes|=e.suspendedLanes&n,hr===e&&(Er&n)===n&&(Xn===4||Xn===3&&(Er&130023424)===Er&&500>On()-bR?Pc(e,0):wR|=n),fs(e,t)}function _q(e,t){t===0&&(e.mode&1?(t=Fy,Fy<<=1,!(Fy&130023424)&&(Fy=4194304)):t=1);var n=Wr();e=ca(e,t),e!==null&&(mm(e,t,n),fs(e,n))}function EK(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),_q(e,n)}function kK(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(ae(314))}r!==null&&r.delete(t),_q(e,n)}var Sq;Sq=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||cs.current)ls=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ls=!1,fK(e,t,n);ls=!!(e.flags&131072)}else ls=!1,cn&&t.flags&1048576&&ED(t,dS,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;k_(e,t),e=t.pendingProps;var s=id(t,Dr.current);Mf(t,n),s=gR(null,t,r,e,s,n);var i=mR();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,us(r)?(i=!0,uS(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,uR(t),s.updater=_v,t.stateNode=s,s._reactInternals=t,YE(t,r,e,n),t=ek(null,t,r,!0,i,n)):(t.tag=0,cn&&i&&rR(t),zr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(k_(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=xK(r),e=wi(r,e),s){case 0:t=ZE(null,t,r,e,n);break e;case 1:t=QP(null,t,r,e,n);break e;case 11:t=KP(null,t,r,e,n);break e;case 14:t=GP(null,t,r,wi(r.type,e),n);break e}throw Error(ae(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:wi(r,s),ZE(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:wi(r,s),QP(e,t,r,s,n);case 3:e:{if(nq(t),e===null)throw Error(ae(387));r=t.pendingProps,i=t.memoizedState,s=i.element,ID(e,t),gS(t,r,null,n);var o=t.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=cd(Error(ae(423)),t),t=JP(e,t,r,n,s);break e}else if(r!==s){s=cd(Error(ae(424)),t),t=JP(e,t,r,n,s);break e}else for(Ts=ll(t.stateNode.containerInfo.firstChild),Os=t,cn=!0,xi=null,n=RD(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(od(),r===s){t=ua(e,t,n);break e}zr(e,t,r,n)}t=t.child}return t;case 5:return TD(t),e===null&&GE(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,o=s.children,HE(r,s)?o=null:i!==null&&HE(r,i)&&(t.flags|=32),tq(e,t),zr(e,t,o,n),t.child;case 6:return e===null&&GE(t),null;case 13:return rq(e,t,n);case 4:return fR(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=ad(t,null,r,n):zr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:wi(r,s),KP(e,t,r,s,n);case 7:return zr(e,t,t.pendingProps,n),t.child;case 8:return zr(e,t,t.pendingProps.children,n),t.child;case 12:return zr(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,o=s.value,Qt(hS,r._currentValue),r._currentValue=o,i!==null)if(qi(i.value,o)){if(i.children===s.children&&!cs.current){t=ua(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var c=a.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Yo(-1,n&-n),c.tag=2;var f=i.updateQueue;if(f!==null){f=f.shared;var d=f.pending;d===null?c.next=c:(c.next=d.next,d.next=c),f.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),QE(i.return,n,t),a.lanes|=n;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(ae(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),QE(o,n,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}zr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Mf(t,n),s=pi(s),r=r(s),t.flags|=1,zr(e,t,r,n),t.child;case 14:return r=t.type,s=wi(r,t.pendingProps),s=wi(r.type,s),GP(e,t,r,s,n);case 15:return ZD(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:wi(r,s),k_(e,t),t.tag=1,us(r)?(e=!0,uS(t)):e=!1,Mf(t,n),JD(t,r,s),YE(t,r,s,n),ek(null,t,r,!0,e,n);case 19:return sq(e,t,n);case 22:return eq(e,t,n)}throw Error(ae(156,t.tag))};function vq(e,t){return K3(e,t)}function CK(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ai(e,t,n,r){return new CK(e,t,n,r)}function xR(e){return e=e.prototype,!(!e||!e.isReactComponent)}function xK(e){if(typeof e=="function")return xR(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Vx)return 11;if(e===Wx)return 14}return 2}function dl(e,t){var n=e.alternate;return n===null?(n=ai(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function R_(e,t,n,r,s,i){var o=2;if(r=e,typeof e=="function")xR(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case gf:return Oc(n.children,s,i,t);case Bx:o=8,s|=8;break;case wE:return e=ai(12,n,t,s|2),e.elementType=wE,e.lanes=i,e;case bE:return e=ai(13,n,t,s),e.elementType=bE,e.lanes=i,e;case EE:return e=ai(19,n,t,s),e.elementType=EE,e.lanes=i,e;case T3:return wv(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case $3:o=10;break e;case I3:o=9;break e;case Vx:o=11;break e;case Wx:o=14;break e;case La:o=16,r=null;break e}throw Error(ae(130,e==null?e:typeof e,""))}return t=ai(o,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Oc(e,t,n,r){return e=ai(7,e,r,t),e.lanes=n,e}function wv(e,t,n,r){return e=ai(22,e,r,t),e.elementType=T3,e.lanes=n,e.stateNode={isHidden:!1},e}function p1(e,t,n){return e=ai(6,e,null,t),e.lanes=n,e}function g1(e,t,n){return t=ai(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function RK(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Qb(0),this.expirationTimes=Qb(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Qb(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function RR(e,t,n,r,s,i,o,a,c){return e=new RK(e,t,n,a,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ai(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},uR(i),e}function $K(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:pf,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function wq(e){if(!e)return vl;e=e._reactInternals;e:{if(wu(e)!==e||e.tag!==1)throw Error(ae(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(us(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(ae(171))}if(e.tag===1){var n=e.type;if(us(n))return wD(e,n,t)}return t}function bq(e,t,n,r,s,i,o,a,c){return e=RR(n,r,!0,e,s,i,o,a,c),e.context=wq(null),n=e.current,r=Wr(),s=fl(n),i=Yo(r,s),i.callback=t??null,cl(n,i,s),e.current.lanes=s,mm(e,s,r),fs(e,r),e}function bv(e,t,n,r){var s=t.current,i=Wr(),o=fl(s);return n=wq(n),t.context===null?t.context=n:t.pendingContext=n,t=Yo(i,o),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=cl(s,t,o),e!==null&&(Oi(e,s,o,i),w_(e,s,o)),o}function ES(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function oO(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function $R(e,t){oO(e,t),(e=e.alternate)&&oO(e,t)}function IK(){return null}var Eq=typeof reportError=="function"?reportError:function(e){console.error(e)};function IR(e){this._internalRoot=e}Ev.prototype.render=IR.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(ae(409));bv(e,t,null,null)};Ev.prototype.unmount=IR.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Wc(function(){bv(null,e,null,null)}),t[la]=null}};function Ev(e){this._internalRoot=e}Ev.prototype.unstable_scheduleHydration=function(e){if(e){var t=eD();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ha.length&&t!==0&&t<Ha[n].priority;n++);Ha.splice(n,0,e),n===0&&nD(e)}};function TR(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function kv(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function aO(){}function TK(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var f=ES(o);i.call(f)}}var o=bq(t,r,e,0,null,!1,!1,"",aO);return e._reactRootContainer=o,e[la]=o.current,ng(e.nodeType===8?e.parentNode:e),Wc(),o}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var f=ES(c);a.call(f)}}var c=RR(e,0,!1,null,null,!1,!1,"",aO);return e._reactRootContainer=c,e[la]=c.current,ng(e.nodeType===8?e.parentNode:e),Wc(function(){bv(t,c,n,r)}),c}function Cv(e,t,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var c=ES(o);a.call(c)}}bv(t,o,e,s)}else o=TK(n,t,e,s,r);return ES(o)}X3=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=sp(t.pendingLanes);n!==0&&(Qx(t,n|1),fs(t,On()),!(vt&6)&&(ud=On()+500,jl()))}break;case 13:Wc(function(){var r=ca(e,1);if(r!==null){var s=Wr();Oi(r,e,1,s)}}),$R(e,1)}};Jx=function(e){if(e.tag===13){var t=ca(e,134217728);if(t!==null){var n=Wr();Oi(t,e,134217728,n)}$R(e,134217728)}};Z3=function(e){if(e.tag===13){var t=fl(e),n=ca(e,t);if(n!==null){var r=Wr();Oi(n,e,t,r)}$R(e,t)}};eD=function(){return Nt};tD=function(e,t){var n=Nt;try{return Nt=e,t()}finally{Nt=n}};AE=function(e,t,n){switch(t){case"input":if(xE(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var s=gv(r);if(!s)throw Error(ae(90));O3(r),xE(r,s)}}}break;case"textarea":F3(e,n);break;case"select":t=n.value,t!=null&&Ff(e,!!n.multiple,t,!1)}};j3=ER;U3=Wc;var PK={usingClientEntryPoint:!1,Events:[_m,Sf,gv,L3,z3,ER]},Hh={findFiberByHostInstance:gc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},OK={bundleType:Hh.bundleType,version:Hh.version,rendererPackageName:Hh.rendererPackageName,rendererConfig:Hh.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Ea.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=V3(e),e===null?null:e.stateNode},findFiberByHostInstance:Hh.findFiberByHostInstance||IK,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Vy=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Vy.isDisabled&&Vy.supportsFiber)try{fv=Vy.inject(OK),ho=Vy}catch{}}Us.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=PK;Us.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!TR(t))throw Error(ae(200));return $K(e,t,null,n)};Us.createRoot=function(e,t){if(!TR(e))throw Error(ae(299));var n=!1,r="",s=Eq;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=RR(e,1,!1,null,null,n,!1,r,s),e[la]=t.current,ng(e.nodeType===8?e.parentNode:e),new IR(t)};Us.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(ae(188)):(e=Object.keys(e).join(","),Error(ae(268,e)));return e=V3(t),e=e===null?null:e.stateNode,e};Us.flushSync=function(e){return Wc(e)};Us.hydrate=function(e,t,n){if(!kv(t))throw Error(ae(200));return Cv(null,e,t,!0,n)};Us.hydrateRoot=function(e,t,n){if(!TR(e))throw Error(ae(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=Eq;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),t=bq(t,null,e,1,n??null,s,!1,i,o),e[la]=t.current,ng(e),r)for(e=0;e<r.length;e++)n=r[e],s=n._getVersion,s=s(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,s]:t.mutableSourceEagerHydrationData.push(n,s);return new Ev(t)};Us.render=function(e,t,n){if(!kv(t))throw Error(ae(200));return Cv(null,e,t,!1,n)};Us.unmountComponentAtNode=function(e){if(!kv(e))throw Error(ae(40));return e._reactRootContainer?(Wc(function(){Cv(null,null,e,!1,function(){e._reactRootContainer=null,e[la]=null})}),!0):!1};Us.unstable_batchedUpdates=ER;Us.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!kv(n))throw Error(ae(200));if(e==null||e._reactInternals===void 0)throw Error(ae(38));return Cv(e,t,n,!1,r)};Us.version="18.3.1-next-f1338f8080-20240426";function kq(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(kq)}catch(e){console.error(e)}}kq(),k3.exports=Us;var Cq=k3.exports,lO=Cq;SE.createRoot=lO.createRoot,SE.hydrateRoot=lO.hydrateRoot;const AK="modulepreload",FK=function(e){return"/"+e},cO={},NK=function(t,n,r){if(!n||n.length===0)return t();const s=document.getElementsByTagName("link");return Promise.all(n.map(i=>{if(i=FK(i),i in cO)return;cO[i]=!0;const o=i.endsWith(".css"),a=o?'[rel="stylesheet"]':"";if(!!r)for(let d=s.length-1;d>=0;d--){const g=s[d];if(g.href===i&&(!o||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${i}"]${a}`))return;const f=document.createElement("link");if(f.rel=o?"stylesheet":AK,o||(f.as="script",f.crossOrigin=""),f.href=i,document.head.appendChild(f),o)return new Promise((d,g)=>{f.addEventListener("load",d),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${i}`)))})})).then(()=>t()).catch(i=>{const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=i,window.dispatchEvent(o),!o.defaultPrevented)throw i})};/**
41
+ * table-core
42
+ *
43
+ * Copyright (c) TanStack
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE.md file in the root directory of this source tree.
47
+ *
48
+ * @license MIT
49
+ */function Ya(e,t){return typeof e=="function"?e(t):e}function qs(e,t){return n=>{t.setState(r=>({...r,[e]:Ya(n,r[e])}))}}function xv(e){return e instanceof Function}function DK(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function qK(e,t){const n=[],r=s=>{s.forEach(i=>{n.push(i);const o=t(i);o!=null&&o.length&&r(o)})};return r(e),n}function Ue(e,t,n){let r=[],s;return i=>{let o;n.key&&n.debug&&(o=Date.now());const a=e(i);if(!(a.length!==r.length||a.some((d,g)=>r[g]!==d)))return s;r=a;let f;if(n.key&&n.debug&&(f=Date.now()),s=t(...a),n==null||n.onChange==null||n.onChange(s),n.key&&n.debug&&n!=null&&n.debug()){const d=Math.round((Date.now()-o)*100)/100,g=Math.round((Date.now()-f)*100)/100,_=g/16,b=(k,I)=>{for(k=String(k);k.length<I;)k=" "+k;return k};console.info(`%c⏱ ${b(g,5)} /${b(d,5)} ms`,`
50
+ font-size: .6rem;
51
+ font-weight: bold;
52
+ color: hsl(${Math.max(0,Math.min(120-120*_,120))}deg 100% 31%);`,n==null?void 0:n.key)}return s}}function He(e,t,n,r){return{debug:()=>{var s;return(s=e==null?void 0:e.debugAll)!=null?s:e[t]},key:!1,onChange:r}}function MK(e,t,n,r){const s=()=>{var o;return(o=i.getValue())!=null?o:e.options.renderFallbackValue},i={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:s,getContext:Ue(()=>[e,n,t,i],(o,a,c,f)=>({table:o,column:a,row:c,cell:f,getValue:f.getValue,renderValue:f.renderValue}),He(e.options,"debugCells"))};return e._features.forEach(o=>{o.createCell==null||o.createCell(i,n,t,e)},{}),i}function LK(e,t,n,r){var s,i;const a={...e._getDefaultColumnDef(),...t},c=a.accessorKey;let f=(s=(i=a.id)!=null?i:c?typeof String.prototype.replaceAll=="function"?c.replaceAll(".","_"):c.replace(/\./g,"_"):void 0)!=null?s:typeof a.header=="string"?a.header:void 0,d;if(a.accessorFn?d=a.accessorFn:c&&(c.includes(".")?d=_=>{let b=_;for(const I of c.split(".")){var k;b=(k=b)==null?void 0:k[I]}return b}:d=_=>_[a.accessorKey]),!f)throw new Error;let g={id:`${String(f)}`,accessorFn:d,parent:r,depth:n,columnDef:a,columns:[],getFlatColumns:Ue(()=>[!0],()=>{var _;return[g,...(_=g.columns)==null?void 0:_.flatMap(b=>b.getFlatColumns())]},He(e.options,"debugColumns")),getLeafColumns:Ue(()=>[e._getOrderColumnsFn()],_=>{var b;if((b=g.columns)!=null&&b.length){let k=g.columns.flatMap(I=>I.getLeafColumns());return _(k)}return[g]},He(e.options,"debugColumns"))};for(const _ of e._features)_.createColumn==null||_.createColumn(g,e);return g}const Pr="debugHeaders";function uO(e,t,n){var r;let i={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const o=[],a=c=>{c.subHeaders&&c.subHeaders.length&&c.subHeaders.map(a),o.push(c)};return a(i),o},getContext:()=>({table:e,header:i,column:t})};return e._features.forEach(o=>{o.createHeader==null||o.createHeader(i,e)}),i}const zK={createTable:e=>{e.getHeaderGroups=Ue(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,s)=>{var i,o;const a=(i=r==null?void 0:r.map(g=>n.find(_=>_.id===g)).filter(Boolean))!=null?i:[],c=(o=s==null?void 0:s.map(g=>n.find(_=>_.id===g)).filter(Boolean))!=null?o:[],f=n.filter(g=>!(r!=null&&r.includes(g.id))&&!(s!=null&&s.includes(g.id)));return Wy(t,[...a,...f,...c],e)},He(e.options,Pr)),e.getCenterHeaderGroups=Ue(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,s)=>(n=n.filter(i=>!(r!=null&&r.includes(i.id))&&!(s!=null&&s.includes(i.id))),Wy(t,n,e,"center")),He(e.options,Pr)),e.getLeftHeaderGroups=Ue(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var s;const i=(s=r==null?void 0:r.map(o=>n.find(a=>a.id===o)).filter(Boolean))!=null?s:[];return Wy(t,i,e,"left")},He(e.options,Pr)),e.getRightHeaderGroups=Ue(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var s;const i=(s=r==null?void 0:r.map(o=>n.find(a=>a.id===o)).filter(Boolean))!=null?s:[];return Wy(t,i,e,"right")},He(e.options,Pr)),e.getFooterGroups=Ue(()=>[e.getHeaderGroups()],t=>[...t].reverse(),He(e.options,Pr)),e.getLeftFooterGroups=Ue(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),He(e.options,Pr)),e.getCenterFooterGroups=Ue(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),He(e.options,Pr)),e.getRightFooterGroups=Ue(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),He(e.options,Pr)),e.getFlatHeaders=Ue(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),He(e.options,Pr)),e.getLeftFlatHeaders=Ue(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),He(e.options,Pr)),e.getCenterFlatHeaders=Ue(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),He(e.options,Pr)),e.getRightFlatHeaders=Ue(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),He(e.options,Pr)),e.getCenterLeafHeaders=Ue(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),He(e.options,Pr)),e.getLeftLeafHeaders=Ue(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),He(e.options,Pr)),e.getRightLeafHeaders=Ue(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),He(e.options,Pr)),e.getLeafHeaders=Ue(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var s,i,o,a,c,f;return[...(s=(i=t[0])==null?void 0:i.headers)!=null?s:[],...(o=(a=n[0])==null?void 0:a.headers)!=null?o:[],...(c=(f=r[0])==null?void 0:f.headers)!=null?c:[]].map(d=>d.getLeafHeaders()).flat()},He(e.options,Pr))}};function Wy(e,t,n,r){var s,i;let o=0;const a=function(_,b){b===void 0&&(b=1),o=Math.max(o,b),_.filter(k=>k.getIsVisible()).forEach(k=>{var I;(I=k.columns)!=null&&I.length&&a(k.columns,b+1)},0)};a(e);let c=[];const f=(_,b)=>{const k={depth:b,id:[r,`${b}`].filter(Boolean).join("_"),headers:[]},I=[];_.forEach(E=>{const y=[...I].reverse()[0],m=E.column.depth===k.depth;let v,w=!1;if(m&&E.column.parent?v=E.column.parent:(v=E.column,w=!0),y&&(y==null?void 0:y.column)===v)y.subHeaders.push(E);else{const $=uO(n,v,{id:[r,b,v.id,E==null?void 0:E.id].filter(Boolean).join("_"),isPlaceholder:w,placeholderId:w?`${I.filter(P=>P.column===v).length}`:void 0,depth:b,index:I.length});$.subHeaders.push(E),I.push($)}k.headers.push(E),E.headerGroup=k}),c.push(k),b>0&&f(I,b-1)},d=t.map((_,b)=>uO(n,_,{depth:o,index:b}));f(d,o-1),c.reverse();const g=_=>_.filter(k=>k.column.getIsVisible()).map(k=>{let I=0,E=0,y=[0];k.subHeaders&&k.subHeaders.length?(y=[],g(k.subHeaders).forEach(v=>{let{colSpan:w,rowSpan:$}=v;I+=w,y.push($)})):I=1;const m=Math.min(...y);return E=E+m,k.colSpan=I,k.rowSpan=E,{colSpan:I,rowSpan:E}});return g((s=(i=c[0])==null?void 0:i.headers)!=null?s:[]),c}const jK=(e,t,n,r,s,i,o)=>{let a={id:t,index:r,original:n,depth:s,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:c=>{if(a._valuesCache.hasOwnProperty(c))return a._valuesCache[c];const f=e.getColumn(c);if(f!=null&&f.accessorFn)return a._valuesCache[c]=f.accessorFn(a.original,r),a._valuesCache[c]},getUniqueValues:c=>{if(a._uniqueValuesCache.hasOwnProperty(c))return a._uniqueValuesCache[c];const f=e.getColumn(c);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(a._uniqueValuesCache[c]=f.columnDef.getUniqueValues(a.original,r),a._uniqueValuesCache[c]):(a._uniqueValuesCache[c]=[a.getValue(c)],a._uniqueValuesCache[c])},renderValue:c=>{var f;return(f=a.getValue(c))!=null?f:e.options.renderFallbackValue},subRows:i??[],getLeafRows:()=>qK(a.subRows,c=>c.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId,!0):void 0,getParentRows:()=>{let c=[],f=a;for(;;){const d=f.getParentRow();if(!d)break;c.push(d),f=d}return c.reverse()},getAllCells:Ue(()=>[e.getAllLeafColumns()],c=>c.map(f=>MK(e,a,f,f.id)),He(e.options,"debugRows")),_getAllCellsByColumnId:Ue(()=>[a.getAllCells()],c=>c.reduce((f,d)=>(f[d.column.id]=d,f),{}),He(e.options,"debugRows"))};for(let c=0;c<e._features.length;c++){const f=e._features[c];f==null||f.createRow==null||f.createRow(a,e)}return a},UK={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},xq=(e,t,n)=>{var r,s;const i=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((s=e.getValue(t))==null||(s=s.toString())==null||(s=s.toLowerCase())==null)&&s.includes(i))};xq.autoRemove=e=>Ai(e);const Rq=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};Rq.autoRemove=e=>Ai(e);const $q=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===(n==null?void 0:n.toLowerCase())};$q.autoRemove=e=>Ai(e);const Iq=(e,t,n)=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)};Iq.autoRemove=e=>Ai(e);const Tq=(e,t,n)=>!n.some(r=>{var s;return!((s=e.getValue(t))!=null&&s.includes(r))});Tq.autoRemove=e=>Ai(e)||!(e!=null&&e.length);const Pq=(e,t,n)=>n.some(r=>{var s;return(s=e.getValue(t))==null?void 0:s.includes(r)});Pq.autoRemove=e=>Ai(e)||!(e!=null&&e.length);const Oq=(e,t,n)=>e.getValue(t)===n;Oq.autoRemove=e=>Ai(e);const Aq=(e,t,n)=>e.getValue(t)==n;Aq.autoRemove=e=>Ai(e);const PR=(e,t,n)=>{let[r,s]=n;const i=e.getValue(t);return i>=r&&i<=s};PR.resolveFilterValue=e=>{let[t,n]=e,r=typeof t!="number"?parseFloat(t):t,s=typeof n!="number"?parseFloat(n):n,i=t===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(s)?1/0:s;if(i>o){const a=i;i=o,o=a}return[i,o]};PR.autoRemove=e=>Ai(e)||Ai(e[0])&&Ai(e[1]);const Uo={includesString:xq,includesStringSensitive:Rq,equalsString:$q,arrIncludes:Iq,arrIncludesAll:Tq,arrIncludesSome:Pq,equals:Oq,weakEquals:Aq,inNumberRange:PR};function Ai(e){return e==null||e===""}const HK={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:qs("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{const n=t.getCoreRowModel().flatRows[0],r=n==null?void 0:n.getValue(e.id);return typeof r=="string"?Uo.includesString:typeof r=="number"?Uo.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?Uo.equals:Array.isArray(r)?Uo.arrIncludes:Uo.weakEquals},e.getFilterFn=()=>{var n,r;return xv(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(r=t.options.filterFns)==null?void 0:r[e.columnDef.filterFn])!=null?n:Uo[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,r,s;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((r=t.options.enableColumnFilters)!=null?r:!0)&&((s=t.options.enableFilters)!=null?s:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(r=>r.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,r;return(n=(r=t.getState().columnFilters)==null?void 0:r.findIndex(s=>s.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(r=>{const s=e.getFilterFn(),i=r==null?void 0:r.find(d=>d.id===e.id),o=Ya(n,i?i.value:void 0);if(fO(s,o,e)){var a;return(a=r==null?void 0:r.filter(d=>d.id!==e.id))!=null?a:[]}const c={id:e.id,value:o};if(i){var f;return(f=r==null?void 0:r.map(d=>d.id===e.id?c:d))!=null?f:[]}return r!=null&&r.length?[...r,c]:[c]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{const n=e.getAllLeafColumns(),r=s=>{var i;return(i=Ya(t,s))==null?void 0:i.filter(o=>{const a=n.find(c=>c.id===o.id);if(a){const c=a.getFilterFn();if(fO(c,o.value,a))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(r)},e.resetColumnFilters=t=>{var n,r;e.setColumnFilters(t?[]:(n=(r=e.initialState)==null?void 0:r.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function fO(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}const BK=(e,t,n)=>n.reduce((r,s)=>{const i=s.getValue(e);return r+(typeof i=="number"?i:0)},0),VK=(e,t,n)=>{let r;return n.forEach(s=>{const i=s.getValue(e);i!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}),r},WK=(e,t,n)=>{let r;return n.forEach(s=>{const i=s.getValue(e);i!=null&&(r<i||r===void 0&&i>=i)&&(r=i)}),r},KK=(e,t,n)=>{let r,s;return n.forEach(i=>{const o=i.getValue(e);o!=null&&(r===void 0?o>=o&&(r=s=o):(r>o&&(r=o),s<o&&(s=o)))}),[r,s]},GK=(e,t)=>{let n=0,r=0;if(t.forEach(s=>{let i=s.getValue(e);i!=null&&(i=+i)>=i&&(++n,r+=i)}),n)return r/n},QK=(e,t)=>{if(!t.length)return;const n=t.map(i=>i.getValue(e));if(!DK(n))return;if(n.length===1)return n[0];const r=Math.floor(n.length/2),s=n.sort((i,o)=>i-o);return n.length%2!==0?s[r]:(s[r-1]+s[r])/2},JK=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),YK=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,XK=(e,t)=>t.length,m1={sum:BK,min:VK,max:WK,extent:KK,mean:GK,median:QK,unique:JK,uniqueCount:YK,count:XK},ZK={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:qs("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(r=>r!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,r;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((r=t.options.enableGrouping)!=null?r:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{const n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{const n=t.getCoreRowModel().flatRows[0],r=n==null?void 0:n.getValue(e.id);if(typeof r=="number")return m1.sum;if(Object.prototype.toString.call(r)==="[object Date]")return m1.extent},e.getAggregationFn=()=>{var n,r;if(!e)throw new Error;return xv(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(r=t.options.aggregationFns)==null?void 0:r[e.columnDef.aggregationFn])!=null?n:m1[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,r;e.setGrouping(t?[]:(n=(r=e.initialState)==null?void 0:r.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];const r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var s;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((s=n.subRows)!=null&&s.length)}}};function e9(e,t,n){if(!(t!=null&&t.length)||!n)return e;const r=e.filter(i=>!t.includes(i.id));return n==="remove"?r:[...t.map(i=>e.find(o=>o.id===i)).filter(Boolean),...r]}const t9={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:qs("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=Ue(n=>[$p(t,n)],n=>n.findIndex(r=>r.id===e.id),He(t.options,"debugColumns")),e.getIsFirstColumn=n=>{var r;return((r=$p(t,n)[0])==null?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;const s=$p(t,n);return((r=s[s.length-1])==null?void 0:r.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=Ue(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,r)=>s=>{let i=[];if(!(t!=null&&t.length))i=s;else{const o=[...t],a=[...s];for(;a.length&&o.length;){const c=o.shift(),f=a.findIndex(d=>d.id===c);f>-1&&i.push(a.splice(f,1)[0])}i=[...i,...a]}return e9(i,n,r)},He(e.options,"debugTable"))}},y1=()=>({left:[],right:[]}),n9={getInitialState:e=>({columnPinning:y1(),...e}),getDefaultOptions:e=>({onColumnPinningChange:qs("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{const r=e.getLeafColumns().map(s=>s.id).filter(Boolean);t.setColumnPinning(s=>{var i,o;if(n==="right"){var a,c;return{left:((a=s==null?void 0:s.left)!=null?a:[]).filter(g=>!(r!=null&&r.includes(g))),right:[...((c=s==null?void 0:s.right)!=null?c:[]).filter(g=>!(r!=null&&r.includes(g))),...r]}}if(n==="left"){var f,d;return{left:[...((f=s==null?void 0:s.left)!=null?f:[]).filter(g=>!(r!=null&&r.includes(g))),...r],right:((d=s==null?void 0:s.right)!=null?d:[]).filter(g=>!(r!=null&&r.includes(g)))}}return{left:((i=s==null?void 0:s.left)!=null?i:[]).filter(g=>!(r!=null&&r.includes(g))),right:((o=s==null?void 0:s.right)!=null?o:[]).filter(g=>!(r!=null&&r.includes(g)))}})},e.getCanPin=()=>e.getLeafColumns().some(r=>{var s,i,o;return((s=r.columnDef.enablePinning)!=null?s:!0)&&((i=(o=t.options.enableColumnPinning)!=null?o:t.options.enablePinning)!=null?i:!0)}),e.getIsPinned=()=>{const n=e.getLeafColumns().map(a=>a.id),{left:r,right:s}=t.getState().columnPinning,i=n.some(a=>r==null?void 0:r.includes(a)),o=n.some(a=>s==null?void 0:s.includes(a));return i?"left":o?"right":!1},e.getPinnedIndex=()=>{var n,r;const s=e.getIsPinned();return s?(n=(r=t.getState().columnPinning)==null||(r=r[s])==null?void 0:r.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=Ue(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,r,s)=>{const i=[...r??[],...s??[]];return n.filter(o=>!i.includes(o.column.id))},He(t.options,"debugRows")),e.getLeftVisibleCells=Ue(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,r)=>(r??[]).map(i=>n.find(o=>o.column.id===i)).filter(Boolean).map(i=>({...i,position:"left"})),He(t.options,"debugRows")),e.getRightVisibleCells=Ue(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,r)=>(r??[]).map(i=>n.find(o=>o.column.id===i)).filter(Boolean).map(i=>({...i,position:"right"})),He(t.options,"debugRows"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,r;return e.setColumnPinning(t?y1():(n=(r=e.initialState)==null?void 0:r.columnPinning)!=null?n:y1())},e.getIsSomeColumnsPinned=t=>{var n;const r=e.getState().columnPinning;if(!t){var s,i;return!!((s=r.left)!=null&&s.length||(i=r.right)!=null&&i.length)}return!!((n=r[t])!=null&&n.length)},e.getLeftLeafColumns=Ue(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(s=>s.id===r)).filter(Boolean),He(e.options,"debugColumns")),e.getRightLeafColumns=Ue(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(s=>s.id===r)).filter(Boolean),He(e.options,"debugColumns")),e.getCenterLeafColumns=Ue(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r)=>{const s=[...n??[],...r??[]];return t.filter(i=>!s.includes(i.id))},He(e.options,"debugColumns"))}};function r9(e){return e||(typeof document<"u"?document:null)}const Ky={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},_1=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),s9={getDefaultColumnDef:()=>Ky,getInitialState:e=>({columnSizing:{},columnSizingInfo:_1(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:qs("columnSizing",e),onColumnSizingInfoChange:qs("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,r,s;const i=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:Ky.minSize,(r=i??e.columnDef.size)!=null?r:Ky.size),(s=e.columnDef.maxSize)!=null?s:Ky.maxSize)},e.getStart=Ue(n=>[n,$p(t,n),t.getState().columnSizing],(n,r)=>r.slice(0,e.getIndex(n)).reduce((s,i)=>s+i.getSize(),0),He(t.options,"debugColumns")),e.getAfter=Ue(n=>[n,$p(t,n),t.getState().columnSizing],(n,r)=>r.slice(e.getIndex(n)+1).reduce((s,i)=>s+i.getSize(),0),He(t.options,"debugColumns")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:r,...s}=n;return s})},e.getCanResize=()=>{var n,r;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((r=t.options.enableColumnResizing)!=null?r:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0;const r=s=>{if(s.subHeaders.length)s.subHeaders.forEach(r);else{var i;n+=(i=s.column.getSize())!=null?i:0}};return r(e),n},e.getStart=()=>{if(e.index>0){const n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{const r=t.getColumn(e.column.id),s=r==null?void 0:r.getCanResize();return i=>{if(!r||!s||(i.persist==null||i.persist(),S1(i)&&i.touches&&i.touches.length>1))return;const o=e.getSize(),a=e?e.getLeafHeaders().map(y=>[y.column.id,y.column.getSize()]):[[r.id,r.getSize()]],c=S1(i)?Math.round(i.touches[0].clientX):i.clientX,f={},d=(y,m)=>{typeof m=="number"&&(t.setColumnSizingInfo(v=>{var w,$;const P=t.options.columnResizeDirection==="rtl"?-1:1,O=(m-((w=v==null?void 0:v.startOffset)!=null?w:0))*P,A=Math.max(O/(($=v==null?void 0:v.startSize)!=null?$:0),-.999999);return v.columnSizingStart.forEach(z=>{let[D,W]=z;f[D]=Math.round(Math.max(W+W*A,0)*100)/100}),{...v,deltaOffset:O,deltaPercentage:A}}),(t.options.columnResizeMode==="onChange"||y==="end")&&t.setColumnSizing(v=>({...v,...f})))},g=y=>d("move",y),_=y=>{d("end",y),t.setColumnSizingInfo(m=>({...m,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},b=r9(n),k={moveHandler:y=>g(y.clientX),upHandler:y=>{b==null||b.removeEventListener("mousemove",k.moveHandler),b==null||b.removeEventListener("mouseup",k.upHandler),_(y.clientX)}},I={moveHandler:y=>(y.cancelable&&(y.preventDefault(),y.stopPropagation()),g(y.touches[0].clientX),!1),upHandler:y=>{var m;b==null||b.removeEventListener("touchmove",I.moveHandler),b==null||b.removeEventListener("touchend",I.upHandler),y.cancelable&&(y.preventDefault(),y.stopPropagation()),_((m=y.touches[0])==null?void 0:m.clientX)}},E=i9()?{passive:!1}:!1;S1(i)?(b==null||b.addEventListener("touchmove",I.moveHandler,E),b==null||b.addEventListener("touchend",I.upHandler,E)):(b==null||b.addEventListener("mousemove",k.moveHandler,E),b==null||b.addEventListener("mouseup",k.upHandler,E)),t.setColumnSizingInfo(y=>({...y,startOffset:c,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?_1():(n=e.initialState.columnSizingInfo)!=null?n:_1())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,s)=>r+s.getSize(),0))!=null?t:0}}};let Gy=null;function i9(){if(typeof Gy=="boolean")return Gy;let e=!1;try{const t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return Gy=e,Gy}function S1(e){return e.type==="touchstart"}const o9={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:qs("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(r=>({...r,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,r;const s=e.columns;return(n=s.length?s.some(i=>i.getIsVisible()):(r=t.getState().columnVisibility)==null?void 0:r[e.id])!=null?n:!0},e.getCanHide=()=>{var n,r;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((r=t.options.enableHiding)!=null?r:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=Ue(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),He(t.options,"debugRows")),e.getVisibleCells=Ue(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,r,s)=>[...n,...r,...s],He(t.options,"debugRows"))},createTable:e=>{const t=(n,r)=>Ue(()=>[r(),r().filter(s=>s.getIsVisible()).map(s=>s.id).join("_")],s=>s.filter(i=>i.getIsVisible==null?void 0:i.getIsVisible()),He(e.options,"debugColumns"));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var r;e.setColumnVisibility(n?{}:(r=e.initialState.columnVisibility)!=null?r:{})},e.toggleAllColumnsVisible=n=>{var r;n=(r=n)!=null?r:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((s,i)=>({...s,[i.id]:n||!(i.getCanHide!=null&&i.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var r;e.toggleAllColumnsVisible((r=n.target)==null?void 0:r.checked)}}};function $p(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}const a9={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},l9={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:qs("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;const r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r=="string"||typeof r=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,r,s,i;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableGlobalFilter)!=null?r:!0)&&((s=t.options.enableFilters)!=null?s:!0)&&((i=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?i:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>Uo.includesString,e.getGlobalFilterFn=()=>{var t,n;const{globalFilterFn:r}=e.options;return xv(r)?r:r==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[r])!=null?t:Uo[r]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},c9={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:qs("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var r,s;if(!t){e._queue(()=>{t=!0});return}if((r=(s=e.options.autoResetAll)!=null?s:e.options.autoResetExpanded)!=null?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=r=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(r),e.toggleAllRowsExpanded=r=>{r??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=r=>{var s,i;e.setExpanded(r?{}:(s=(i=e.initialState)==null?void 0:i.expanded)!=null?s:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(r=>r.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>r=>{r.persist==null||r.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{const r=e.getState().expanded;return r===!0||Object.values(r).some(Boolean)},e.getIsAllRowsExpanded=()=>{const r=e.getState().expanded;return typeof r=="boolean"?r===!0:!(!Object.keys(r).length||e.getRowModel().flatRows.some(s=>!s.getIsExpanded()))},e.getExpandedDepth=()=>{let r=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(i=>{const o=i.split(".");r=Math.max(r,o.length)}),r},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{var s;const i=r===!0?!0:!!(r!=null&&r[e.id]);let o={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{o[a]=!0}):o=r,n=(s=n)!=null?s:!i,!i&&n)return{...o,[e.id]:!0};if(i&&!n){const{[e.id]:a,...c}=o;return c}return r})},e.getIsExpanded=()=>{var n;const r=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:r===!0||r!=null&&r[e.id])},e.getCanExpand=()=>{var n,r,s;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((r=t.options.enableExpanding)!=null?r:!0)&&!!((s=e.subRows)!=null&&s.length)},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{const n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},dk=0,hk=10,v1=()=>({pageIndex:dk,pageSize:hk}),u9={getInitialState:e=>({...e,pagination:{...v1(),...e==null?void 0:e.pagination}}),getDefaultOptions:e=>({onPaginationChange:qs("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var r,s;if(!t){e._queue(()=>{t=!0});return}if((r=(s=e.options.autoResetAll)!=null?s:e.options.autoResetPageIndex)!=null?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=r=>{const s=i=>Ya(r,i);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(s)},e.resetPagination=r=>{var s;e.setPagination(r?v1():(s=e.initialState.pagination)!=null?s:v1())},e.setPageIndex=r=>{e.setPagination(s=>{let i=Ya(r,s.pageIndex);const o=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return i=Math.max(0,Math.min(i,o)),{...s,pageIndex:i}})},e.resetPageIndex=r=>{var s,i;e.setPageIndex(r?dk:(s=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageIndex)!=null?s:dk)},e.resetPageSize=r=>{var s,i;e.setPageSize(r?hk:(s=(i=e.initialState)==null||(i=i.pagination)==null?void 0:i.pageSize)!=null?s:hk)},e.setPageSize=r=>{e.setPagination(s=>{const i=Math.max(1,Ya(r,s.pageSize)),o=s.pageSize*s.pageIndex,a=Math.floor(o/i);return{...s,pageIndex:a,pageSize:i}})},e.setPageCount=r=>e.setPagination(s=>{var i;let o=Ya(r,(i=e.options.pageCount)!=null?i:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...s,pageCount:o}}),e.getPageOptions=Ue(()=>[e.getPageCount()],r=>{let s=[];return r&&r>0&&(s=[...new Array(r)].fill(null).map((i,o)=>o)),s},He(e.options,"debugTable")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{const{pageIndex:r}=e.getState().pagination,s=e.getPageCount();return s===-1?!0:s===0?!1:r<s-1},e.previousPage=()=>e.setPageIndex(r=>r-1),e.nextPage=()=>e.setPageIndex(r=>r+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var r;return(r=e.options.pageCount)!=null?r:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var r;return(r=e.options.rowCount)!=null?r:e.getPrePaginationRowModel().rows.length}}},w1=()=>({top:[],bottom:[]}),f9={getInitialState:e=>({rowPinning:w1(),...e}),getDefaultOptions:e=>({onRowPinningChange:qs("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,r,s)=>{const i=r?e.getLeafRows().map(c=>{let{id:f}=c;return f}):[],o=s?e.getParentRows().map(c=>{let{id:f}=c;return f}):[],a=new Set([...o,e.id,...i]);t.setRowPinning(c=>{var f,d;if(n==="bottom"){var g,_;return{top:((g=c==null?void 0:c.top)!=null?g:[]).filter(I=>!(a!=null&&a.has(I))),bottom:[...((_=c==null?void 0:c.bottom)!=null?_:[]).filter(I=>!(a!=null&&a.has(I))),...Array.from(a)]}}if(n==="top"){var b,k;return{top:[...((b=c==null?void 0:c.top)!=null?b:[]).filter(I=>!(a!=null&&a.has(I))),...Array.from(a)],bottom:((k=c==null?void 0:c.bottom)!=null?k:[]).filter(I=>!(a!=null&&a.has(I)))}}return{top:((f=c==null?void 0:c.top)!=null?f:[]).filter(I=>!(a!=null&&a.has(I))),bottom:((d=c==null?void 0:c.bottom)!=null?d:[]).filter(I=>!(a!=null&&a.has(I)))}})},e.getCanPin=()=>{var n;const{enableRowPinning:r,enablePinning:s}=t.options;return typeof r=="function"?r(e):(n=r??s)!=null?n:!0},e.getIsPinned=()=>{const n=[e.id],{top:r,bottom:s}=t.getState().rowPinning,i=n.some(a=>r==null?void 0:r.includes(a)),o=n.some(a=>s==null?void 0:s.includes(a));return i?"top":o?"bottom":!1},e.getPinnedIndex=()=>{var n,r;const s=e.getIsPinned();if(!s)return-1;const i=(n=s==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(o=>{let{id:a}=o;return a});return(r=i==null?void 0:i.indexOf(e.id))!=null?r:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,r;return e.setRowPinning(t?w1():(n=(r=e.initialState)==null?void 0:r.rowPinning)!=null?n:w1())},e.getIsSomeRowsPinned=t=>{var n;const r=e.getState().rowPinning;if(!t){var s,i;return!!((s=r.top)!=null&&s.length||(i=r.bottom)!=null&&i.length)}return!!((n=r[t])!=null&&n.length)},e._getPinnedRows=(t,n,r)=>{var s;return((s=e.options.keepPinnedRows)==null||s?(n??[]).map(o=>{const a=e.getRow(o,!0);return a.getIsAllParentsExpanded()?a:null}):(n??[]).map(o=>t.find(a=>a.id===o))).filter(Boolean).map(o=>({...o,position:r}))},e.getTopRows=Ue(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),He(e.options,"debugRows")),e.getBottomRows=Ue(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),He(e.options,"debugRows")),e.getCenterRows=Ue(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,r)=>{const s=new Set([...n??[],...r??[]]);return t.filter(i=>!s.has(i.id))},He(e.options,"debugRows"))}},d9={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:qs("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();const r={...n},s=e.getPreGroupedRowModel().flatRows;return t?s.forEach(i=>{i.getCanSelect()&&(r[i.id]=!0)}):s.forEach(i=>{delete r[i.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{const r=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),s={...n};return e.getRowModel().rows.forEach(i=>{pk(s,i.id,r,!0,e)}),s}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=Ue(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?b1(e,n):{rows:[],flatRows:[],rowsById:{}},He(e.options,"debugTable")),e.getFilteredSelectedRowModel=Ue(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?b1(e,n):{rows:[],flatRows:[],rowsById:{}},He(e.options,"debugTable")),e.getGroupedSelectedRowModel=Ue(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?b1(e,n):{rows:[],flatRows:[],rowsById:{}},He(e.options,"debugTable")),e.getIsAllRowsSelected=()=>{const t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState();let r=!!(t.length&&Object.keys(n).length);return r&&t.some(s=>s.getCanSelect()&&!n[s.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows.filter(s=>s.getCanSelect()),{rowSelection:n}=e.getState();let r=!!t.length;return r&&t.some(s=>!n[s.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{var t;const n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{const t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{const s=e.getIsSelected();t.setRowSelection(i=>{var o;if(n=typeof n<"u"?n:!s,e.getCanSelect()&&s===n)return i;const a={...i};return pk(a,e.id,n,(o=r==null?void 0:r.selectChildren)!=null?o:!0,t),a})},e.getIsSelected=()=>{const{rowSelection:n}=t.getState();return OR(e,n)},e.getIsSomeSelected=()=>{const{rowSelection:n}=t.getState();return gk(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=t.getState();return gk(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{const n=e.getCanSelect();return r=>{var s;n&&e.toggleSelected((s=r.target)==null?void 0:s.checked)}}}},pk=(e,t,n,r,s)=>{var i;const o=s.getRow(t,!0);n?(o.getCanMultiSelect()||Object.keys(e).forEach(a=>delete e[a]),o.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(i=o.subRows)!=null&&i.length&&o.getCanSelectSubRows()&&o.subRows.forEach(a=>pk(e,a.id,n,r,s))};function b1(e,t){const n=e.getState().rowSelection,r=[],s={},i=function(o,a){return o.map(c=>{var f;const d=OR(c,n);if(d&&(r.push(c),s[c.id]=c),(f=c.subRows)!=null&&f.length&&(c={...c,subRows:i(c.subRows)}),d)return c}).filter(Boolean)};return{rows:i(t.rows),flatRows:r,rowsById:s}}function OR(e,t){var n;return(n=t[e.id])!=null?n:!1}function gk(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let s=!0,i=!1;return e.subRows.forEach(o=>{if(!(i&&!s)&&(o.getCanSelect()&&(OR(o,t)?i=!0:s=!1),o.subRows&&o.subRows.length)){const a=gk(o,t);a==="all"?i=!0:(a==="some"&&(i=!0),s=!1)}}),s?"all":i?"some":!1}const mk=/([0-9]+)/gm,h9=(e,t,n)=>Fq(wl(e.getValue(n)).toLowerCase(),wl(t.getValue(n)).toLowerCase()),p9=(e,t,n)=>Fq(wl(e.getValue(n)),wl(t.getValue(n))),g9=(e,t,n)=>AR(wl(e.getValue(n)).toLowerCase(),wl(t.getValue(n)).toLowerCase()),m9=(e,t,n)=>AR(wl(e.getValue(n)),wl(t.getValue(n))),y9=(e,t,n)=>{const r=e.getValue(n),s=t.getValue(n);return r>s?1:r<s?-1:0},_9=(e,t,n)=>AR(e.getValue(n),t.getValue(n));function AR(e,t){return e===t?0:e>t?1:-1}function wl(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Fq(e,t){const n=e.split(mk).filter(Boolean),r=t.split(mk).filter(Boolean);for(;n.length&&r.length;){const s=n.shift(),i=r.shift(),o=parseInt(s,10),a=parseInt(i,10),c=[o,a].sort();if(isNaN(c[0])){if(s>i)return 1;if(i>s)return-1;continue}if(isNaN(c[1]))return isNaN(o)?-1:1;if(o>a)return 1;if(a>o)return-1}return n.length-r.length}const Bh={alphanumeric:h9,alphanumericCaseSensitive:p9,text:g9,textCaseSensitive:m9,datetime:y9,basic:_9},S9={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:qs("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{const n=t.getFilteredRowModel().flatRows.slice(10);let r=!1;for(const s of n){const i=s==null?void 0:s.getValue(e.id);if(Object.prototype.toString.call(i)==="[object Date]")return Bh.datetime;if(typeof i=="string"&&(r=!0,i.split(mk).length>1))return Bh.alphanumeric}return r?Bh.text:Bh.basic},e.getAutoSortDir=()=>{const n=t.getFilteredRowModel().flatRows[0];return typeof(n==null?void 0:n.getValue(e.id))=="string"?"asc":"desc"},e.getSortingFn=()=>{var n,r;if(!e)throw new Error;return xv(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(r=t.options.sortingFns)==null?void 0:r[e.columnDef.sortingFn])!=null?n:Bh[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{const s=e.getNextSortingOrder(),i=typeof n<"u"&&n!==null;t.setSorting(o=>{const a=o==null?void 0:o.find(b=>b.id===e.id),c=o==null?void 0:o.findIndex(b=>b.id===e.id);let f=[],d,g=i?n:s==="desc";if(o!=null&&o.length&&e.getCanMultiSort()&&r?a?d="toggle":d="add":o!=null&&o.length&&c!==o.length-1?d="replace":a?d="toggle":d="replace",d==="toggle"&&(i||s||(d="remove")),d==="add"){var _;f=[...o,{id:e.id,desc:g}],f.splice(0,f.length-((_=t.options.maxMultiSortColCount)!=null?_:Number.MAX_SAFE_INTEGER))}else d==="toggle"?f=o.map(b=>b.id===e.id?{...b,desc:g}:b):d==="remove"?f=o.filter(b=>b.id!==e.id):f=[{id:e.id,desc:g}];return f})},e.getFirstSortDir=()=>{var n,r;return((n=(r=e.columnDef.sortDescFirst)!=null?r:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var r,s;const i=e.getFirstSortDir(),o=e.getIsSorted();return o?o!==i&&((r=t.options.enableSortingRemoval)==null||r)&&(!(n&&(s=t.options.enableMultiRemove)!=null)||s)?!1:o==="desc"?"asc":"desc":i},e.getCanSort=()=>{var n,r;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((r=t.options.enableSorting)!=null?r:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,r;return(n=(r=e.columnDef.enableMultiSort)!=null?r:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;const r=(n=t.getState().sorting)==null?void 0:n.find(s=>s.id===e.id);return r?r.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,r;return(n=(r=t.getState().sorting)==null?void 0:r.findIndex(s=>s.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(r=>r.id!==e.id):[])},e.getToggleSortingHandler=()=>{const n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,r;e.setSorting(t?[]:(n=(r=e.initialState)==null?void 0:r.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},v9=[zK,o9,t9,n9,UK,HK,a9,l9,S9,ZK,c9,u9,f9,d9,s9];function w9(e){var t,n;const r=[...v9,...(t=e._features)!=null?t:[]];let s={_features:r};const i=s._features.reduce((_,b)=>Object.assign(_,b.getDefaultOptions==null?void 0:b.getDefaultOptions(s)),{}),o=_=>s.options.mergeOptions?s.options.mergeOptions(i,_):{...i,..._};let c={...{},...(n=e.initialState)!=null?n:{}};s._features.forEach(_=>{var b;c=(b=_.getInitialState==null?void 0:_.getInitialState(c))!=null?b:c});const f=[];let d=!1;const g={_features:r,options:{...i,...e},initialState:c,_queue:_=>{f.push(_),d||(d=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();d=!1}).catch(b=>setTimeout(()=>{throw b})))},reset:()=>{s.setState(s.initialState)},setOptions:_=>{const b=Ya(_,s.options);s.options=o(b)},getState:()=>s.options.state,setState:_=>{s.options.onStateChange==null||s.options.onStateChange(_)},_getRowId:(_,b,k)=>{var I;return(I=s.options.getRowId==null?void 0:s.options.getRowId(_,b,k))!=null?I:`${k?[k.id,b].join("."):b}`},getCoreRowModel:()=>(s._getCoreRowModel||(s._getCoreRowModel=s.options.getCoreRowModel(s)),s._getCoreRowModel()),getRowModel:()=>s.getPaginationRowModel(),getRow:(_,b)=>{let k=(b?s.getPrePaginationRowModel():s.getRowModel()).rowsById[_];if(!k&&(k=s.getCoreRowModel().rowsById[_],!k))throw new Error;return k},_getDefaultColumnDef:Ue(()=>[s.options.defaultColumn],_=>{var b;return _=(b=_)!=null?b:{},{header:k=>{const I=k.header.column.columnDef;return I.accessorKey?I.accessorKey:I.accessorFn?I.id:null},cell:k=>{var I,E;return(I=(E=k.renderValue())==null||E.toString==null?void 0:E.toString())!=null?I:null},...s._features.reduce((k,I)=>Object.assign(k,I.getDefaultColumnDef==null?void 0:I.getDefaultColumnDef()),{}),..._}},He(e,"debugColumns")),_getColumnDefs:()=>s.options.columns,getAllColumns:Ue(()=>[s._getColumnDefs()],_=>{const b=function(k,I,E){return E===void 0&&(E=0),k.map(y=>{const m=LK(s,y,E,I),v=y;return m.columns=v.columns?b(v.columns,m,E+1):[],m})};return b(_)},He(e,"debugColumns")),getAllFlatColumns:Ue(()=>[s.getAllColumns()],_=>_.flatMap(b=>b.getFlatColumns()),He(e,"debugColumns")),_getAllFlatColumnsById:Ue(()=>[s.getAllFlatColumns()],_=>_.reduce((b,k)=>(b[k.id]=k,b),{}),He(e,"debugColumns")),getAllLeafColumns:Ue(()=>[s.getAllColumns(),s._getOrderColumnsFn()],(_,b)=>{let k=_.flatMap(I=>I.getLeafColumns());return b(k)},He(e,"debugColumns")),getColumn:_=>s._getAllFlatColumnsById()[_]};Object.assign(s,g);for(let _=0;_<s._features.length;_++){const b=s._features[_];b==null||b.createTable==null||b.createTable(s)}return s}function b9(){return e=>Ue(()=>[e.options.data],t=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(s,i,o){i===void 0&&(i=0);const a=[];for(let f=0;f<s.length;f++){const d=jK(e,e._getRowId(s[f],f,o),s[f],f,i,void 0,o==null?void 0:o.id);if(n.flatRows.push(d),n.rowsById[d.id]=d,a.push(d),e.options.getSubRows){var c;d.originalSubRows=e.options.getSubRows(s[f],f),(c=d.originalSubRows)!=null&&c.length&&(d.subRows=r(d.originalSubRows,i+1,d))}}return a};return n.rows=r(t),n},He(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}/**
53
+ * react-table
54
+ *
55
+ * Copyright (c) TanStack
56
+ *
57
+ * This source code is licensed under the MIT license found in the
58
+ * LICENSE.md file in the root directory of this source tree.
59
+ *
60
+ * @license MIT
61
+ */function E9(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=ve.useState(()=>({current:w9(t)})),[r,s]=ve.useState(()=>n.current.initialState);return n.current.setOptions(i=>({...i,...e,state:{...r,...e.state},onStateChange:o=>{s(o),e.onStateChange==null||e.onStateChange(o)}})),n.current}function Qu(e,t,n){let r=n.initialDeps??[],s;function i(){var o,a,c,f;let d;n.key&&((o=n.debug)!=null&&o.call(n))&&(d=Date.now());const g=e();if(!(g.length!==r.length||g.some((k,I)=>r[I]!==k)))return s;r=g;let b;if(n.key&&((a=n.debug)!=null&&a.call(n))&&(b=Date.now()),s=t(...g),n.key&&((c=n.debug)!=null&&c.call(n))){const k=Math.round((Date.now()-d)*100)/100,I=Math.round((Date.now()-b)*100)/100,E=I/16,y=(m,v)=>{for(m=String(m);m.length<v;)m=" "+m;return m};console.info(`%c⏱ ${y(I,5)} /${y(k,5)} ms`,`
62
+ font-size: .6rem;
63
+ font-weight: bold;
64
+ color: hsl(${Math.max(0,Math.min(120-120*E,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(f=n==null?void 0:n.onChange)==null||f.call(n,s),s}return i.updateDeps=o=>{r=o},i}function dO(e,t){if(e===void 0)throw new Error(`Unexpected undefined${t?`: ${t}`:""}`);return e}const k9=(e,t)=>Math.abs(e-t)<1.01,C9=(e,t,n)=>{let r;return function(...s){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,s),n)}},hO=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},x9=e=>e,R9=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let s=t;s<=n;s++)r.push(s);return r},$9=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const s=o=>{const{width:a,height:c}=o;t({width:Math.round(a),height:Math.round(c)})};if(s(hO(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const a=()=>{const c=o[0];if(c!=null&&c.borderBoxSize){const f=c.borderBoxSize[0];if(f){s({width:f.inlineSize,height:f.blockSize});return}}s(hO(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},pO={passive:!0},gO=typeof window>"u"?!0:"onscrollend"in window,I9=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let s=0;const i=e.options.useScrollendEvent&&gO?()=>{}:C9(r,()=>{t(s,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:g,isRtl:_}=e.options;s=g?n.scrollLeft*(_&&-1||1):n.scrollTop,i(),t(s,d)},a=o(!0),c=o(!1);c(),n.addEventListener("scroll",a,pO);const f=e.options.useScrollendEvent&&gO;return f&&n.addEventListener("scrollend",c,pO),()=>{n.removeEventListener("scroll",a),f&&n.removeEventListener("scrollend",c)}},T9=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},P9=(e,{adjustments:t=0,behavior:n},r)=>{var s,i;const o=e+t;(i=(s=r.scrollElement)==null?void 0:s.scrollTo)==null||i.call(s,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class O9{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(s=>{s.forEach(i=>{const o=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var s;(s=r())==null||s.disconnect(),n=null},observe:s=>{var i;return(i=r())==null?void 0:i.observe(s,{box:"border-box"})},unobserve:s=>{var i;return(i=r())==null?void 0:i.unobserve(s)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,s])=>{typeof s>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:x9,rangeExtractor:R9,onChange:()=>{},measureElement:T9,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,s;(s=(r=this.options).onChange)==null||s.call(r,this,n)},this.maybeNotify=Qu(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=i,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const s=new Map,i=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(s.has(a.lane))continue;const c=i.get(a.lane);if(c==null||a.end>c.end?i.set(a.lane,a):a.end<c.end&&s.set(a.lane,!0),s.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=Qu(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,s,i,o)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:s,getItemKey:i,enabled:o}),{key:!1}),this.getMeasurements=Qu(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:s,getItemKey:i,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(d=>{this.itemSizeCache.set(d.key,d.size)}));const c=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const f=this.measurementsCache.slice(0,c);for(let d=c;d<n;d++){const g=i(d),_=this.options.lanes===1?f[d-1]:this.getFurthestMeasurement(f,d),b=_?_.end+this.options.gap:r+s,k=a.get(g),I=typeof k=="number"?k:this.options.estimateSize(d),E=b+I,y=_?_.lane:d%this.options.lanes;f[d]={index:d,start:b,size:I,end:E,key:g,lane:y}}return this.measurementsCache=f,f},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Qu(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,s,i)=>this.range=n.length>0&&r>0?A9({measurements:n,outerSize:r,scrollOffset:s,lanes:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Qu(()=>{let n=null,r=null;const s=this.calculateRange();return s&&(n=s.startIndex,r=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,s,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,s=n.getAttribute(r);return s?parseInt(s,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const s=this.indexFromElement(n),i=this.measurementsCache[s];if(!i)return;const o=i.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(s,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const s=this.measurementsCache[n];if(!s)return;const i=this.itemSizeCache.get(s.key)??s.size,o=r-i;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(s,o,this):s.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(s.index),this.itemSizeCache=new Map(this.itemSizeCache.set(s.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,s)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(s))});return}this._measureElement(n,void 0)},this.getVirtualItems=Qu(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const s=[];for(let i=0,o=n.length;i<o;i++){const a=n[i],c=r[a];s.push(c)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return dO(r[Nq(0,r.length-1,s=>dO(r[s]).start,n)])},this.getOffsetForAlignment=(n,r,s=0)=>{const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(s-i)/2:r==="end"&&(n-=i);const a=this.getTotalSize()+this.options.scrollMargin-i;return Math.max(Math.min(a,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const s=this.measurementsCache[n];if(!s)return;const i=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(s.end>=o+i-this.options.scrollPaddingEnd)r="end";else if(s.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const a=r==="end"?s.end+this.options.scrollPaddingEnd:s.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,r,s.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(n,{align:r="start",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:s})},this.scrollToIndex=(n,{align:r="auto",behavior:s}={})=>{s==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),n=Math.max(0,Math.min(n,this.options.count-1));let i=0;const o=10,a=f=>{if(!this.targetWindow)return;const d=this.getOffsetForIndex(n,f);if(!d){console.warn("Failed to get offset for index:",n);return}const[g,_]=d;this._scrollToOffset(g,{adjustments:void 0,behavior:s}),this.targetWindow.requestAnimationFrame(()=>{const b=this.getScrollOffset(),k=this.getOffsetForIndex(n,_);if(!k){console.warn("Failed to get offset for index:",n);return}k9(k[0],b)||c(_)})},c=f=>{this.targetWindow&&(i++,i<o?this.targetWindow.requestAnimationFrame(()=>a(f)):console.warn(`Failed to scroll to index ${n} after ${o} attempts.`))};a(r)},this.scrollBy=(n,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let s;if(r.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(a=>a===null);){const a=r[o];i[a.lane]===null&&(i[a.lane]=a.end),o--}s=Math.max(...i.filter(a=>a!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:s})=>{this.options.scrollToFn(n,{behavior:s,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(t)}}const Nq=(e,t,n,r)=>{for(;e<=t;){const s=(e+t)/2|0,i=n(s);if(i<r)e=s+1;else if(i>r)t=s-1;else return s}return e>0?e-1:0};function A9({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const s=e.length-1,i=c=>e[c].start;if(e.length<=r)return{startIndex:0,endIndex:s};let o=Nq(0,s,i,n),a=o;if(r===1)for(;a<s&&e[a].end<n+t;)a++;else if(r>1){const c=Array(r).fill(0);for(;a<s&&c.some(d=>d<n+t);){const d=e[a];c[d.lane]=d.end,a++}const f=Array(r).fill(n+t);for(;o>=0&&f.some(d=>d>=n);){const d=e[o];f[d.lane]=d.start,o--}o=Math.max(0,o-o%r),a=Math.min(s,a+(r-1-a%r))}return{startIndex:o,endIndex:a}}const mO=typeof document<"u"?ve.useLayoutEffect:ve.useEffect;function F9(e){const t=ve.useReducer(()=>({}),{})[1],n={...e,onChange:(s,i)=>{var o;i?Cq.flushSync(t):t(),(o=e.onChange)==null||o.call(e,s,i)}},[r]=ve.useState(()=>new O9(n));return r.setOptions(n),mO(()=>r._didMount(),[]),mO(()=>r._willUpdate()),r}function N9(e){return F9({observeElementRect:$9,observeElementOffset:I9,scrollToFn:P9,...e})}const yO=e=>{let t;const n=new Set,r=(f,d)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const _=t;t=d??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(b=>b(t,_))}},s=()=>t,a={setState:r,getState:s,getInitialState:()=>c,subscribe:f=>(n.add(f),()=>n.delete(f))},c=t=e(r,s,a);return a},D9=e=>e?yO(e):yO,q9=e=>e;function M9(e,t=q9){const n=pc.useSyncExternalStore(e.subscribe,pc.useCallback(()=>t(e.getState()),[e,t]),pc.useCallback(()=>t(e.getInitialState()),[e,t]));return pc.useDebugValue(n),n}const _O=e=>{const t=D9(e),n=r=>M9(t,r);return Object.assign(n,t),n},L9=e=>e?_O(e):_O;function z9(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const o=c=>c===null?null:JSON.parse(c,t==null?void 0:t.reviver),a=(i=n.getItem(s))!=null?i:null;return a instanceof Promise?a.then(o):o(a)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,t==null?void 0:t.replacer)),removeItem:s=>n.removeItem(s)}}const yk=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return yk(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return yk(r)(n)}}}},j9=(e,t)=>(n,r,s)=>{let i={storage:z9(()=>localStorage),partialize:I=>I,version:0,merge:(I,E)=>({...E,...I}),...t},o=!1;const a=new Set,c=new Set;let f=i.storage;if(!f)return e((...I)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...I)},r,s);const d=()=>{const I=i.partialize({...r()});return f.setItem(i.name,{state:I,version:i.version})},g=s.setState;s.setState=(I,E)=>(g(I,E),d());const _=e((...I)=>(n(...I),d()),r,s);s.getInitialState=()=>_;let b;const k=()=>{var I,E;if(!f)return;o=!1,a.forEach(m=>{var v;return m((v=r())!=null?v:_)});const y=((E=i.onRehydrateStorage)==null?void 0:E.call(i,(I=r())!=null?I:_))||void 0;return yk(f.getItem.bind(f))(i.name).then(m=>{if(m)if(typeof m.version=="number"&&m.version!==i.version){if(i.migrate){const v=i.migrate(m.state,m.version);return v instanceof Promise?v.then(w=>[!0,w]):[!0,v]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,m.state];return[!1,void 0]}).then(m=>{var v;const[w,$]=m;if(b=i.merge($,(v=r())!=null?v:_),n(b,!0),w)return d()}).then(()=>{y==null||y(b,void 0),b=r(),o=!0,c.forEach(m=>m(b))}).catch(m=>{y==null||y(void 0,m)})};return s.persist={setOptions:I=>{i={...i,...I},I.storage&&(f=I.storage)},clearStorage:()=>{f==null||f.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>o,onHydrate:I=>(a.add(I),()=>{a.delete(I)}),onFinishHydration:I=>(c.add(I),()=>{c.delete(I)})},i.skipHydration||k(),b||_},U9=j9,fg=L9()(U9((e,t)=>({theme:"system",setTheme:n=>{e({theme:n}),t().applyTheme(n)},resolvedTheme:"dark",initTheme:()=>{const{theme:n}=t();t().applyTheme(n)},applyTheme:n=>{if(typeof window>"u")return;const r=window.document.documentElement;r.classList.remove("light","dark");let s;n==="system"?s=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":s=n,r.classList.add(s),e({resolvedTheme:s})}}),{name:"theme-storage"}));typeof window<"u"&&(fg.getState().initTheme(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",()=>{const{theme:t,initTheme:n}=fg.getState();t==="system"&&n()}));/**
65
+ * @license lucide-react v0.561.0 - ISC
66
+ *
67
+ * This source code is licensed under the ISC license.
68
+ * See the LICENSE file in the root directory of this source tree.
69
+ */const H9=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),B9=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),SO=e=>{const t=B9(e);return t.charAt(0).toUpperCase()+t.slice(1)},Dq=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),V9=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};/**
70
+ * @license lucide-react v0.561.0 - ISC
71
+ *
72
+ * This source code is licensed under the ISC license.
73
+ * See the LICENSE file in the root directory of this source tree.
74
+ */var W9={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
75
+ * @license lucide-react v0.561.0 - ISC
76
+ *
77
+ * This source code is licensed under the ISC license.
78
+ * See the LICENSE file in the root directory of this source tree.
79
+ */const K9=ve.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...a},c)=>ve.createElement("svg",{ref:c,...W9,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Dq("lucide",s),...!i&&!V9(a)&&{"aria-hidden":"true"},...a},[...o.map(([f,d])=>ve.createElement(f,d)),...Array.isArray(i)?i:[i]]));/**
80
+ * @license lucide-react v0.561.0 - ISC
81
+ *
82
+ * This source code is licensed under the ISC license.
83
+ * See the LICENSE file in the root directory of this source tree.
84
+ */const mr=(e,t)=>{const n=ve.forwardRef(({className:r,...s},i)=>ve.createElement(K9,{ref:i,iconNode:t,className:Dq(`lucide-${H9(SO(e))}`,`lucide-${e}`,r),...s}));return n.displayName=SO(e),n};/**
85
+ * @license lucide-react v0.561.0 - ISC
86
+ *
87
+ * This source code is licensed under the ISC license.
88
+ * See the LICENSE file in the root directory of this source tree.
89
+ */const G9=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],Q9=mr("bot",G9);/**
90
+ * @license lucide-react v0.561.0 - ISC
91
+ *
92
+ * This source code is licensed under the ISC license.
93
+ * See the LICENSE file in the root directory of this source tree.
94
+ */const J9=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Y9=mr("calendar",J9);/**
95
+ * @license lucide-react v0.561.0 - ISC
96
+ *
97
+ * This source code is licensed under the ISC license.
98
+ * See the LICENSE file in the root directory of this source tree.
99
+ */const X9=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Z9=mr("circle-check-big",X9);/**
100
+ * @license lucide-react v0.561.0 - ISC
101
+ *
102
+ * This source code is licensed under the ISC license.
103
+ * See the LICENSE file in the root directory of this source tree.
104
+ */const eG=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],tG=mr("circle-x",eG);/**
105
+ * @license lucide-react v0.561.0 - ISC
106
+ *
107
+ * This source code is licensed under the ISC license.
108
+ * See the LICENSE file in the root directory of this source tree.
109
+ */const nG=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],rG=mr("clock",nG);/**
110
+ * @license lucide-react v0.561.0 - ISC
111
+ *
112
+ * This source code is licensed under the ISC license.
113
+ * See the LICENSE file in the root directory of this source tree.
114
+ */const sG=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],iG=mr("funnel",sG);/**
115
+ * @license lucide-react v0.561.0 - ISC
116
+ *
117
+ * This source code is licensed under the ISC license.
118
+ * See the LICENSE file in the root directory of this source tree.
119
+ */const oG=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],aG=mr("lightbulb",oG);/**
120
+ * @license lucide-react v0.561.0 - ISC
121
+ *
122
+ * This source code is licensed under the ISC license.
123
+ * See the LICENSE file in the root directory of this source tree.
124
+ */const lG=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],cG=mr("moon",lG);/**
125
+ * @license lucide-react v0.561.0 - ISC
126
+ *
127
+ * This source code is licensed under the ISC license.
128
+ * See the LICENSE file in the root directory of this source tree.
129
+ */const uG=[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]],fG=mr("pause",uG);/**
130
+ * @license lucide-react v0.561.0 - ISC
131
+ *
132
+ * This source code is licensed under the ISC license.
133
+ * See the LICENSE file in the root directory of this source tree.
134
+ */const dG=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],vO=mr("refresh-cw",dG);/**
135
+ * @license lucide-react v0.561.0 - ISC
136
+ *
137
+ * This source code is licensed under the ISC license.
138
+ * See the LICENSE file in the root directory of this source tree.
139
+ */const hG=[["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715",key:"xlf6rm"}],["path",{d:"M16 12a4 4 0 0 0-4-4",key:"6vsxu"}],["path",{d:"m19 5-1.256 1.256",key:"1yg6a6"}],["path",{d:"M20 12h2",key:"1q8mjw"}]],pG=mr("sun-moon",hG);/**
140
+ * @license lucide-react v0.561.0 - ISC
141
+ *
142
+ * This source code is licensed under the ISC license.
143
+ * See the LICENSE file in the root directory of this source tree.
144
+ */const gG=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],mG=mr("sun",gG);/**
145
+ * @license lucide-react v0.561.0 - ISC
146
+ *
147
+ * This source code is licensed under the ISC license.
148
+ * See the LICENSE file in the root directory of this source tree.
149
+ */const yG=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],_G=mr("tag",yG);/**
150
+ * @license lucide-react v0.561.0 - ISC
151
+ *
152
+ * This source code is licensed under the ISC license.
153
+ * See the LICENSE file in the root directory of this source tree.
154
+ */const SG=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],vG=mr("target",SG);/**
155
+ * @license lucide-react v0.561.0 - ISC
156
+ *
157
+ * This source code is licensed under the ISC license.
158
+ * See the LICENSE file in the root directory of this source tree.
159
+ */const wG=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],bG=mr("triangle-alert",wG);/**
160
+ * @license lucide-react v0.561.0 - ISC
161
+ *
162
+ * This source code is licensed under the ISC license.
163
+ * See the LICENSE file in the root directory of this source tree.
164
+ */const EG=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],kG=mr("upload",EG);/**
165
+ * @license lucide-react v0.561.0 - ISC
166
+ *
167
+ * This source code is licensed under the ISC license.
168
+ * See the LICENSE file in the root directory of this source tree.
169
+ */const CG=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],xG=mr("wrench",CG);/**
170
+ * @license lucide-react v0.561.0 - ISC
171
+ *
172
+ * This source code is licensed under the ISC license.
173
+ * See the LICENSE file in the root directory of this source tree.
174
+ */const RG=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],$G=mr("x",RG),IG=ve.forwardRef(({search:e,onSearchChange:t,selectedModel:n,onModelChange:r,selectedProvider:s,onProviderChange:i,selectedStatus:o,onStatusChange:a,models:c,providers:f},d)=>{const[g,_]=ve.useState(!1),[b,k]=ve.useState(!1),[I,E]=ve.useState([]),[y,m]=ve.useState(-1),v=ve.useRef(null),w=ve.useRef(null),$=ve.useRef(null),P=ve.useCallback(L=>{v.current=L,typeof d=="function"?d(L):d&&(d.current=L)},[d]),O=[{text:"status:200",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(Z9,{size:14,className:"icon-success"})," Successful requests only"," "]})},{text:"status:4xx OR status:5xx",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(tG,{size:14,className:"icon-error"})," Error responses"," "]})},{text:"method:POST",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(kG,{size:14})," POST requests only"," "]})},{text:"model:gpt-4",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(Q9,{size:14})," GPT-4 model requests"," "]})},{text:"provider:openai",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(xG,{size:14})," OpenAI provider only"," "]})},{text:"timestamp:>2024-01-01",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(Y9,{size:14})," Recent requests"," "]})},{text:"error OR failed OR exception",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(bG,{size:14,className:"icon-error"})," Error logs"," "]})},{text:"model:kimi-k2-thinking",type:"example",description:te.jsxs(te.Fragment,{children:[" ",te.jsx(vG,{size:14})," Kimi K2 Thinking model"," "]})}],A=[{text:"status:",type:"field",description:"Filter by status code"},{text:"method:",type:"field",description:"Filter by HTTP method"},{text:"model:",type:"field",description:"Filter by model name"},{text:"provider:",type:"field",description:"Filter by provider"},{text:"timestamp:",type:"field",description:"Filter by date/time"}],z=ve.useCallback(L=>{const G=L.toLowerCase(),V=[];return(!L||G.match(/^\w*:?$/))&&V.push(...A),V.push(...O),c.forEach(J=>{J.toLowerCase().includes(G)&&V.push({text:`model:${J}`,type:"field",description:`Filter by ${J} model`})}),f.forEach(J=>{J.toLowerCase().includes(G)&&V.push({text:`provider:${J}`,type:"field",description:`Filter by ${J} provider`})}),V.slice(0,8)},[c,f]);ve.useEffect(()=>{E(z(e)),m(-1)},[e,z]),ve.useEffect(()=>{if(!b)return;const L=G=>{var V,J;G.target instanceof Node&&((V=w.current)!=null&&V.contains(G.target)||(k(!1),m(-1),(J=v.current)==null||J.blur()))};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[b]);const D=L=>{var G;if(b)switch(L.key){case"ArrowDown":L.preventDefault(),m(V=>V<I.length-1?V+1:0);break;case"ArrowUp":L.preventDefault(),m(V=>V>0?V-1:I.length-1);break;case"Enter":if(L.preventDefault(),y>=0){const V=I[y];t(V.text),k(!1),m(-1)}break;case"Escape":k(!1),m(-1),(G=v.current)==null||G.blur();break}},W=L=>{var G;t(L.text),k(!1),m(-1),(G=v.current)==null||G.focus()},le=()=>{var L;t(""),(L=v.current)==null||L.focus()},M=()=>{let L=0;return n&&L++,s&&L++,o&&L++,L},U=()=>{t(""),r(""),i(""),a("")},Q=()=>navigator.platform.toUpperCase().indexOf("MAC")>=0?"⌘K":"Ctrl+K";return te.jsxs("div",{className:"search-filters",children:[te.jsxs("div",{className:"search-main",children:[te.jsxs("div",{ref:w,className:"search-input-wrapper",children:[te.jsxs("svg",{className:"search-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[te.jsx("circle",{cx:"11",cy:"11",r:"8"}),te.jsx("path",{d:"m21 21-4.35-4.35"})]}),te.jsx("input",{ref:P,type:"text",className:"search-input",placeholder:"Search logs... (try 'status:200' or 'model:gpt-4')",value:e,onChange:L=>{t(L.target.value),k(!0)},onKeyDown:D,onBlur:()=>{k(!1),m(-1)},onFocus:()=>{I.length>0&&k(!0)}}),e&&te.jsx("button",{className:"search-clear",onClick:le,title:"Clear search",children:te.jsx($G,{size:14})}),b&&te.jsx("div",{ref:$,className:"search-suggestions",onMouseDown:L=>L.preventDefault(),children:I.map((L,G)=>te.jsxs("div",{className:`suggestion-item ${G===y?"active":""}`,onClick:()=>W(L),children:[te.jsxs("div",{className:"suggestion-content",children:[te.jsx("span",{className:"suggestion-text",children:L.text}),L.description&&te.jsx("span",{className:"suggestion-description",children:L.description})]}),te.jsxs("div",{className:"suggestion-type",children:[L.type==="field"&&te.jsx(_G,{size:14}),L.type==="example"&&te.jsx(aG,{size:14}),L.type==="recent"&&te.jsx(rG,{size:14})]})]},G))})]}),te.jsxs("button",{className:`filters-toggle ${M()>0?"has-filters":""}`,onClick:()=>_(!g),"aria-expanded":g,children:[te.jsx(iG,{size:16}),"Filters",M()>0&&te.jsx("span",{className:"filter-count",children:M()})]}),te.jsx("div",{className:"search-shortcut",title:`Press ${Q()} to focus search`,children:Q()})]}),g&&te.jsxs("div",{className:"filters-panel",children:[te.jsxs("div",{className:"filter-group",children:[te.jsx("label",{children:"Model"}),te.jsxs("select",{value:n,onChange:L=>r(L.target.value),children:[te.jsx("option",{value:"",children:"All Models"}),c.map(L=>te.jsx("option",{value:L,children:L},L))]})]}),te.jsxs("div",{className:"filter-group",children:[te.jsx("label",{children:"Provider"}),te.jsxs("select",{value:s,onChange:L=>i(L.target.value),children:[te.jsx("option",{value:"",children:"All Providers"}),f.map(L=>te.jsx("option",{value:L,children:L},L))]})]}),te.jsxs("div",{className:"filter-group",children:[te.jsx("label",{children:"Status"}),te.jsxs("select",{value:o,onChange:L=>a(L.target.value),children:[te.jsx("option",{value:"",children:"All Status"}),te.jsx("option",{value:"success",children:"Success (2xx)"}),te.jsx("option",{value:"error",children:"Error (4xx, 5xx)"})]})]}),(n||s||o)&&te.jsx("button",{className:"clear-filters-btn",onClick:U,children:"Clear All"})]})]})}),TG=e=>typeof e=="function",x=function(e,t){if(typeof e=="function")return function(){return e(arguments)?t.apply(this,arguments):n=>t(n,...arguments)};switch(e){case 0:case 1:throw new RangeError(`Invalid arity ${e}`);case 2:return function(n,r){return arguments.length>=2?t(n,r):function(s){return t(s,n)}};case 3:return function(n,r,s){return arguments.length>=3?t(n,r,s):function(i){return t(i,n,r)}};case 4:return function(n,r,s,i){return arguments.length>=4?t(n,r,s,i):function(o){return t(o,n,r,s)}};case 5:return function(n,r,s,i,o){return arguments.length>=5?t(n,r,s,i,o):function(a){return t(a,n,r,s,i)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);const n=arguments;return function(r){return t(r,...n)}}}},Ce=e=>e,Rv=e=>()=>e,wO=Rv(!0),ds=Rv(!1),qq=Rv(void 0),fd=qq;function T(e,t,n,r,s,i,o,a,c){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return s(r(n(t(e))));case 6:return i(s(r(n(t(e)))));case 7:return o(i(s(r(n(t(e))))));case 8:return a(o(i(s(r(n(t(e)))))));case 9:return c(a(o(i(s(r(n(t(e))))))));default:{let f=arguments[0];for(let d=1;d<arguments.length;d++)f=arguments[d](f);return f}}}const vm=e=>(t,n)=>t===n||e(t,n),PG=(e,t)=>e===t,OG=()=>PG,AG=OG(),Mq=x(2,(e,t)=>vm((n,r)=>e(t(n),t(r)))),FG=Mq(AG,e=>e.getTime()),NG=e=>vm((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e(t[r],n[r]))return!1;return!0});let DG="3.15.5";const $v=()=>DG,Qy=`effect/GlobalValue/globalStoreId/${$v()}`;let Vh;const We=(e,t)=>(Vh||(globalThis[Qy]??(globalThis[Qy]=new Map),Vh=globalThis[Qy]),Vh.has(e)||Vh.set(e,t()),Vh.get(e)),qG=e=>e instanceof Set,Jr=e=>typeof e=="string",fa=e=>typeof e=="number",Kc=e=>typeof e=="boolean",Iv=e=>typeof e=="bigint",kS=e=>typeof e=="symbol",Qd=TG,MG=e=>e===void 0,LG=e=>!1,FR=e=>typeof e=="object"&&e!==null,xo=e=>FR(e)||Qd(e),_e=x(2,(e,t)=>xo(e)&&t in e),NR=x(2,(e,t)=>_e(e,"_tag")&&e._tag===t),Ju=e=>e==null,zG=e=>e!=null,jG=e=>e instanceof Uint8Array,Lq=e=>e instanceof Date,DR=e=>_e(e,Symbol.iterator),UG=e=>FR(e)&&!Array.isArray(e),zq=e=>_e(e,"then")&&Qd(e.then),Tv=e=>`BUG: ${e} - please report an issue at https://github.com/Effect-TS/effect/issues`;let jq=class Uq{constructor(t){p(this,"self");p(this,"called",!1);this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new Uq(this.self)}};const HG=335903614,BG=4150755663,VG=1481765933,WG=1284865837,KG=9007199254740992,GG=134217728;class QG{constructor(t,n,r,s){p(this,"_state");return Ju(n)&&Ju(t)?(n=Math.random()*4294967295>>>0,t=0):Ju(n)&&(n=t,t=0),Ju(s)&&Ju(r)?(s=this._state?this._state[3]:BG,r=this._state?this._state[2]:HG):Ju(s)&&(s=r,r=0),this._state=new Int32Array([0,0,r>>>0,((s||0)|1)>>>0]),this._next(),bO(this._state,this._state[0],this._state[1],t>>>0,n>>>0),this._next(),this}getState(){return[this._state[0],this._state[1],this._state[2],this._state[3]]}setState(t){this._state[0]=t[0],this._state[1]=t[1],this._state[2]=t[2],this._state[3]=t[3]|1}integer(t){return Math.round(this.number()*Number.MAX_SAFE_INTEGER)%t}number(){const t=(this._next()&67108863)*1,n=(this._next()&134217727)*1;return(t*GG+n)/KG}_next(){const t=this._state[0]>>>0,n=this._state[1]>>>0;JG(this._state,t,n,VG,WG),bO(this._state,this._state[0],this._state[1],this._state[2],this._state[3]);let r=t>>>18,s=(n>>>18|t<<14)>>>0;r=(r^t)>>>0,s=(s^n)>>>0;const i=(s>>>27|r<<5)>>>0,o=t>>>27,a=(-o>>>0&31)>>>0;return(i>>>o|i<<a)>>>0}}function JG(e,t,n,r,s){let i=(n>>>16)*(s&65535)>>>0,o=(n&65535)*(s>>>16)>>>0,a=(n&65535)*(s&65535)>>>0,c=(n>>>16)*(s>>>16)+((o>>>16)+(i>>>16))>>>0;o=o<<16>>>0,a=a+o>>>0,a>>>0<o>>>0&&(c=c+1>>>0),i=i<<16>>>0,a=a+i>>>0,a>>>0<i>>>0&&(c=c+1>>>0),c=c+Math.imul(n,r)>>>0,c=c+Math.imul(t,s)>>>0,e[0]=c,e[1]=a}function bO(e,t,n,r,s){let i=t+r>>>0;const o=n+s>>>0;o>>>0<n>>>0&&(i=i+1|0),e[0]=i,e[1]=o}const _k=Symbol.for("effect/Utils/YieldWrap");var lm;class Jd{constructor(t){Ft(this,lm,void 0);ec(this,lm,t)}[_k](){return ge(this,lm)}}lm=new WeakMap;function Hq(e){if(typeof e=="object"&&e!==null&&_k in e)return e[_k]();throw new Error(Tv("yieldWrapGet"))}const Gs=We("effect/Utils/isStructuralRegion",()=>({enabled:!1,tester:void 0})),Bq={effect_internal_function:e=>e()},YG={effect_internal_function:e=>{try{return e()}finally{}}};var u3;const XG=((u3=Bq.effect_internal_function(()=>new Error().stack))==null?void 0:u3.includes("effect_internal_function"))===!0,Bt=XG?Bq.effect_internal_function:YG.effect_internal_function,ZG=(function*(){}).constructor,eQ=e=>xo(e)&&e.constructor===ZG,E1=We(Symbol.for("effect/Hash/randomHashCache"),()=>new WeakMap),qe=Symbol.for("effect/Hash"),ce=e=>{if(Gs.enabled===!0)return 0;switch(typeof e){case"number":return qR(e);case"bigint":return tn(e.toString(10));case"boolean":return tn(String(e));case"symbol":return tn(String(e));case"string":return tn(e);case"undefined":return tn("undefined");case"function":case"object":return e===null?tn("null"):e instanceof Date?ce(e.toISOString()):e instanceof URL?ce(e.href):tQ(e)?e[qe]():Pv(e);default:throw new Error(`BUG: unhandled typeof ${typeof e} - please report an issue at https://github.com/Effect-TS/effect/issues`)}},Pv=e=>(E1.has(e)||E1.set(e,qR(Math.floor(Math.random()*Number.MAX_SAFE_INTEGER))),E1.get(e)),Oe=e=>t=>t*53^e,Ov=e=>e&3221225471|e>>>1&1073741824,tQ=e=>_e(e,qe),qR=e=>{if(e!==e||e===1/0)return 0;let t=e|0;for(t!==e&&(t^=e*4294967295);e>4294967295;)t^=e/=4294967295;return Ov(t)},tn=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return Ov(t)},nQ=(e,t)=>{let n=12289;for(let r=0;r<t.length;r++)n^=T(tn(t[r]),Oe(ce(e[t[r]])));return Ov(n)},Vq=e=>nQ(e,Object.keys(e)),wm=e=>{let t=6151;for(let n=0;n<e.length;n++)t=T(t,Oe(ce(e[n])));return Ov(t)},At=function(){if(arguments.length===1){const n=arguments[0];return function(r){return Object.defineProperty(n,qe,{value(){return r},enumerable:!1}),r}}const e=arguments[0],t=arguments[1];return Object.defineProperty(e,qe,{value(){return t},enumerable:!1}),t},Me=Symbol.for("effect/Equal");function Ne(){return arguments.length===1?e=>CS(e,arguments[0]):CS(arguments[0],arguments[1])}function CS(e,t){if(e===t)return!0;const n=typeof e;if(n!==typeof t)return!1;if(n==="object"||n==="function"){if(e!==null&&t!==null){if(dg(e)&&dg(t))return ce(e)===ce(t)&&e[Me](t)?!0:Gs.enabled&&Gs.tester?Gs.tester(e,t):!1;if(e instanceof Date&&t instanceof Date)return e.toISOString()===t.toISOString();if(e instanceof URL&&t instanceof URL)return e.href===t.href}if(Gs.enabled){if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,s)=>CS(r,t[s]));if(Object.getPrototypeOf(e)===Object.prototype&&Object.getPrototypeOf(e)===Object.prototype){const r=Object.keys(e),s=Object.keys(t);if(r.length===s.length){for(const i of r)if(!(i in t&&CS(e[i],t[i])))return Gs.tester?Gs.tester(e,t):!1;return!0}}return Gs.tester?Gs.tester(e,t):!1}}return Gs.enabled&&Gs.tester?Gs.tester(e,t):!1}const dg=e=>_e(e,Me),MR=()=>Ne,ft=Symbol.for("nodejs.util.inspect.custom"),sn=e=>{try{if(_e(e,"toJSON")&&Qd(e.toJSON)&&e.toJSON.length===0)return e.toJSON();if(Array.isArray(e))return e.map(sn)}catch{return{}}return Qc(e)},qt=e=>JSON.stringify(e,null,2),Av={toJSON(){return sn(this)},[ft](){return this.toJSON()},toString(){return qt(this.toJSON())}};let Wq=class{[ft](){return this.toJSON()}toString(){return qt(this.toJSON())}};const Gc=(e,t=2)=>{if(typeof e=="string")return e;try{return typeof e=="object"?Kq(e,t):String(e)}catch{return String(e)}},Kq=(e,t)=>{let n=[];const r=JSON.stringify(e,(s,i)=>typeof i=="object"&&i!==null?n.includes(i)?void 0:n.push(i)&&(Ac.fiberRefs!==void 0&&Gq(i)?i[Fv](Ac.fiberRefs):i):i,t);return n=void 0,r},Fv=Symbol.for("effect/Inspectable/Redactable"),Gq=e=>typeof e=="object"&&e!==null&&Fv in e,Ac=We("effect/Inspectable/redactableState",()=>({fiberRefs:void 0})),rQ=(e,t)=>{const n=Ac.fiberRefs;Ac.fiberRefs=e;try{return t()}finally{Ac.fiberRefs=n}},Qc=e=>Gq(e)&&Ac.fiberRefs!==void 0?e[Fv](Ac.fiberRefs):e,pe=(e,t)=>{switch(t.length){case 0:return e;case 1:return t[0](e);case 2:return t[1](t[0](e));case 3:return t[2](t[1](t[0](e)));case 4:return t[3](t[2](t[1](t[0](e))));case 5:return t[4](t[3](t[2](t[1](t[0](e)))));case 6:return t[5](t[4](t[3](t[2](t[1](t[0](e))))));case 7:return t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))));case 8:return t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e))))))));case 9:return t[8](t[7](t[6](t[5](t[4](t[3](t[2](t[1](t[0](e)))))))));default:{let n=e;for(let r=0,s=t.length;r<s;r++)n=t[r](n);return n}}},Ip="Async",bm="Commit",tr="Failure",$_="OnFailure",xS="OnSuccess",RS="OnSuccessAndFailure",nr="Success",Qq="Sync",sQ="Tag",Yd="UpdateRuntimeFlags",$S="While",Tp="Iterator",Jq="WithRuntime",I_="Yield",LR="RevertFlags",iQ=Symbol.for("effect/Effect"),Sk=Symbol.for("effect/Stream"),oQ=Symbol.for("effect/Sink"),aQ=Symbol.for("effect/Channel"),Jc={_R:e=>e,_E:e=>e,_A:e=>e,_V:$v()},lQ={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e},cQ={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},Em={[iQ]:Jc,[Sk]:Jc,[oQ]:lQ,[aQ]:cQ,[Me](e){return this===e},[qe](){return At(this,Pv(this))},[Symbol.iterator](){return new jq(new Jd(this))},pipe(){return pe(this,arguments)}},zR={[qe](){return At(this,Vq(this))},[Me](e){const t=Object.keys(this),n=Object.keys(e);if(t.length!==n.length)return!1;for(const r of t)if(!(r in e&&Ne(this[r],e[r])))return!1;return!0}},ka={...Em,_op:bm},uQ={...ka,...zR},fQ=function(){function e(){}return e.prototype=ka,e}(),Yq=Symbol.for("effect/Option"),Xq={...Em,[Yq]:{_A:e=>e},[ft](){return this.toJSON()},toString(){return qt(this.toJSON())}},dQ=Object.assign(Object.create(Xq),{_tag:"Some",_op:"Some",[Me](e){return jR(e)&&eM(e)&&Ne(this.value,e.value)},[qe](){return At(this,Oe(ce(this._tag))(ce(this.value)))},toJSON(){return{_id:"Option",_tag:this._tag,value:sn(this.value)}}}),hQ=ce("None"),pQ=Object.assign(Object.create(Xq),{_tag:"None",_op:"None",[Me](e){return jR(e)&&Zq(e)},[qe](){return hQ},toJSON(){return{_id:"Option",_tag:this._tag}}}),jR=e=>_e(e,Yq),Zq=e=>e._tag==="None",eM=e=>e._tag==="Some",UR=Object.create(pQ),IS=e=>{const t=Object.create(dQ);return t.value=e,t},tM=Symbol.for("effect/Either"),nM={...Em,[tM]:{_R:e=>e},[ft](){return this.toJSON()},toString(){return qt(this.toJSON())}},gQ=Object.assign(Object.create(nM),{_tag:"Right",_op:"Right",[Me](e){return HR(e)&&sM(e)&&Ne(this.right,e.right)},[qe](){return Oe(ce(this._tag))(ce(this.right))},toJSON(){return{_id:"Either",_tag:this._tag,right:sn(this.right)}}}),mQ=Object.assign(Object.create(nM),{_tag:"Left",_op:"Left",[Me](e){return HR(e)&&rM(e)&&Ne(this.left,e.left)},[qe](){return Oe(ce(this._tag))(ce(this.left))},toJSON(){return{_id:"Either",_tag:this._tag,left:sn(this.left)}}}),HR=e=>_e(e,tM),rM=e=>e._tag==="Left",sM=e=>e._tag==="Right",yQ=e=>{const t=Object.create(mQ);return t.left=e,t},_Q=e=>{const t=Object.create(gQ);return t.right=e,t},Pe=_Q,$e=yQ,SQ=e=>{if(Qd(e))try{return Pe(e())}catch(t){return $e(t)}else try{return Pe(e.try())}catch(t){return $e(e.catch(t))}},iM=HR,Gn=rM,ao=sM,vQ=x(2,(e,{onLeft:t,onRight:n})=>Gn(e)?$e(t(e.left)):Pe(n(e.right))),km=x(2,(e,t)=>Gn(e)?$e(t(e.left)):Pe(e.right)),wQ=x(2,(e,t)=>ao(e)?Pe(t(e.right)):$e(e.left)),Zn=x(2,(e,{onLeft:t,onRight:n})=>Gn(e)?t(e.left):n(e.right)),bQ=Zn({onLeft:Ce,onRight:Ce}),oM=x(2,(e,t)=>{if(ao(e))return e.right;throw t(e.left)}),EQ=oM(()=>new Error("getOrThrow called on a Left")),BR=e=>e.length>0,aM=e=>(t,n)=>t===n?0:e(t,n),kQ=aM((e,t)=>e<t?-1:1),lM=x(2,(e,t)=>aM((n,r)=>e(t(n),t(r)))),CQ=e=>x(2,(t,n)=>e(t,n)===1),re=()=>UR,oe=IS,xQ=jR,on=Zq,Wt=eM,bt=x(2,(e,{onNone:t,onSome:n})=>on(e)?t():n(e.value)),Yt=x(2,(e,t)=>on(e)?t():e.value),Xo=x(2,(e,t)=>on(e)?t():e),RQ=x(2,(e,t)=>on(e)?oe(t()):e),bu=e=>e==null?re():oe(e),ti=Yt(qq),cM=e=>(...t)=>{try{return oe(e(...t))}catch{return re()}},hl=x(2,(e,t)=>on(e)?re():oe(t(e.value))),Eu=x(2,(e,t)=>on(e)?re():t(e.value)),$Q=x(2,(e,t)=>on(e)?re():bu(t(e.value))),IQ=Eu(Ce),TQ=Eu,PQ=x(2,(e,t)=>TQ(e,n=>t(n)?IS(n):UR)),OQ=e=>vm((t,n)=>on(t)?on(n):on(n)?!1:e(t.value,n.value)),AQ=e=>x(2,(t,n)=>on(t)?!1:e(t.value,n)),FQ=MR(),NQ=AQ(FQ),DQ=x(2,(e,t)=>on(e)?!1:t(e.value)),EO=e=>(t,n)=>on(t)?n:on(n)?t:oe(e(t.value,n.value)),qQ=(...e)=>e,MQ=e=>{const n=e[Symbol.iterator]().next();return n.done?re():oe(n.value)},vk=e=>{const n=e[Symbol.iterator]().next();if(n.done)throw new Error("unsafeHead: empty iterable");return n.value},LQ=x(2,(e,t)=>{let n=0;for(const r of e){const s=t(r,n);if(Kc(s)){if(s)return oe(r)}else if(Wt(s))return s;n++}return re()}),zQ={[Symbol.iterator](){return jQ}},jQ={next(){return{done:!0,value:void 0}}},uM=()=>zQ,UQ=x(2,(e,t)=>({[Symbol.iterator](){const n=e[Symbol.iterator]();let r=0;return{next(){const s=n.next();return s.done?{done:!0,value:void 0}:{done:!1,value:t(s.value,r++)}}}}})),HQ=x(2,(e,t)=>({[Symbol.iterator](){const n=e[Symbol.iterator]();let r=0;return{next(){let s=n.next();for(;!s.done;){if(t(s.value,r++))return{done:!1,value:s.value};s=n.next()}return{done:!0,value:void 0}}}}})),BQ=x(2,(e,t)=>{const n={...e};for(const r of VQ(e))n[r]=t(e[r],r);return n}),VQ=e=>Object.keys(e),Nv=e=>new Array(e),WQ=x(2,(e,t)=>{const n=Math.max(1,Math.floor(e)),r=new Array(n);for(let s=0;s<n;s++)r[s]=t(s);return r}),gt=e=>Array.isArray(e)?e:Array.from(e),VR=e=>Array.isArray(e)?e:[e],KQ=x(2,(e,{onEmpty:t,onNonEmpty:n})=>Kt(e)?n(e):t()),GQ=x(2,(e,{onEmpty:t,onNonEmpty:n})=>Kt(e)?n(Kr(e),Yc(e)):t()),TS=x(2,(e,t)=>[t,...e]),QQ=x(2,(e,t)=>[...e,t]),Dv=x(2,(e,t)=>gt(e).concat(gt(t))),JQ=Array.isArray,YQ=e=>e.length===0,XQ=YQ,T_=BR,Kt=BR,fM=(e,t)=>e<0||e>=t.length,ZQ=(e,t)=>Math.floor(Math.min(Math.max(0,e),t.length)),eJ=x(2,(e,t)=>{const n=Math.floor(t);return fM(n,e)?re():oe(e[n])}),dM=x(2,(e,t)=>{const n=Math.floor(t);if(fM(n,e))throw new Error(`Index ${n} out of bounds`);return e[n]}),zf=eJ(0),Kr=dM(0),tJ=e=>Kt(e)?oe(hM(e)):re(),hM=e=>e[e.length-1],Yc=e=>e.slice(1),pM=(e,t)=>{let n=0;for(const r of e){if(!t(r,n))break;n++}return n},gM=x(2,(e,t)=>mM(e,pM(e,t))),nJ=x(2,(e,t)=>{const n=gt(e);return n.slice(ZQ(t,n),n.length)}),rJ=x(2,(e,t)=>gt(e).slice(pM(e,t))),sJ=LQ,kO=e=>Array.from(e).reverse(),hg=x(2,(e,t)=>{const n=Array.from(e);return n.sort(t),n}),CO=x(2,(e,t)=>iJ(e,t,qQ)),iJ=x(3,(e,t,n)=>{const r=gt(e),s=gt(t);if(Kt(r)&&Kt(s)){const i=[n(Kr(r),Kr(s))],o=Math.min(r.length,s.length);for(let a=1;a<o;a++)i[a]=n(r[a],s[a]);return i}return[]}),oJ=e=>{const t=gt(e);if(Kt(t)){const n=[t[0][0]],r=[t[0][1]];for(let s=1;s<t.length;s++)n[s]=t[s][0],r[s]=t[s][1];return[n,r]}return[[],[]]},aJ=MR(),lJ=x(2,(e,t)=>{const n=gt(e);if(Kt(n)){const[r,s]=t(n),i=[r];let o=s;for(;BR(o);){const[a,c]=t(o);i.push(a),o=c}return i}return[]}),mM=x(2,(e,t)=>{const n=Array.from(e),r=Math.floor(t);return Kt(n)?r>=1?yM(n,r):[[],n]:[n,[]]}),yM=x(2,(e,t)=>{const n=Math.max(1,Math.floor(t));return n>=e.length?[op(e),[]]:[TS(e.slice(1,n),Kr(e)),e.slice(n)]}),_M=x(2,(e,t)=>gM(e,(n,r)=>!t(n,r))),op=e=>e.slice(),cJ=x(2,(e,t)=>{const n=gt(e);return Kt(n)?lJ(n,yM(t)):[]}),uJ=x(3,(e,t,n)=>{const r=gt(e),s=gt(t);return Kt(r)?Kt(s)?wM(n)(Dv(r,s)):r:s}),P_=x(2,(e,t)=>uJ(e,t,aJ)),bl=()=>[],$s=e=>[e],Zo=x(2,(e,t)=>e.map(t)),PS=x(2,(e,t)=>{if(XQ(e))return[];const n=[];for(let r=0;r<e.length;r++){const s=t(e[r],r);for(let i=0;i<s.length;i++)n.push(s[i])}return n}),fJ=PS(Ce),SM=x(2,(e,t)=>{const n=gt(e),r=[];for(let s=0;s<n.length;s++){const i=t(n[s],s);Wt(i)&&r.push(i.value)}return r}),vM=x(2,(e,t)=>{const n=gt(e),r=[];for(let s=0;s<n.length;s++)t(n[s],s)&&r.push(n[s]);return r}),WR=x(3,(e,t,n)=>gt(e).reduce((r,s,i)=>n(r,s,i),t)),xO=(e,t)=>{const n=[];let r=e,s;for(;Wt(s=t(r));){const[i,o]=s.value;n.push(i),r=o}return n},Cm=NG,wM=x(2,(e,t)=>{const n=gt(e);if(Kt(n)){const r=[Kr(n)],s=Yc(n);for(const i of s)r.every(o=>!t(i,o))&&r.push(i);return r}return[]}),dJ=e=>wM(e,MR()),ku=x(2,(e,t)=>gt(e).join(t)),bM=(e,t)=>{switch(t._tag){case"StringKeyword":case"TemplateLiteral":return Object.keys(e);case"SymbolKeyword":return Object.getOwnPropertySymbols(e);case"Refinement":return bM(e,t.from)}},go=e=>Object.keys(e).concat(Object.getOwnPropertySymbols(e)),EM=e=>{let t=!1,n;return()=>(t||(n=e(),t=!0),n)},kM=e=>{try{return e.toISOString()}catch{return String(e)}},ui=(e,t=!0)=>{if(Array.isArray(e))return`[${e.map(n=>ui(n,t)).join(",")}]`;if(Lq(e))return kM(e);if(_e(e,"toString")&&Qd(e.toString)&&e.toString!==Object.prototype.toString)return e.toString();if(Jr(e))return JSON.stringify(e);if(fa(e)||e==null||Kc(e)||kS(e))return String(e);if(Iv(e))return String(e)+"n";if(DR(e))return`${e.constructor.name}(${ui(Array.from(e),t)})`;try{t&&JSON.stringify(e);const n=`{${go(e).map(s=>`${Jr(s)?JSON.stringify(s):String(s)}:${ui(e[s],!1)}`).join(",")}}`,r=e.constructor.name;return e.constructor!==Object.prototype.constructor?`${r}(${n})`:n}catch{return"<circular structure>"}},KR=e=>typeof e=="string"?JSON.stringify(e):String(e),CM=e=>Array.isArray(e),hJ=e=>!Array.isArray(e),RO=e=>`[${KR(e)}]`,xM=e=>CM(e)?e.map(RO).join(""):RO(e),Ca=(e,t,n,r)=>{let s=e;return n&&Kt(n)&&(s+=`
175
+ at path: ${xM(n)}`),t!==void 0&&(s+=`
176
+ details: ${t}`),r&&(s+=`
177
+ schema (${r._tag}): ${r}`),s},pJ=(e,t,n)=>Ca("Unsupported schema",e,t,n),RM=(e,t,n)=>Ca("Unsupported schema or overlapping types",`cannot extend ${e} with ${t}`,n),pg=e=>pJ(void 0,void 0,e),gJ=e=>Ca("Unsupported key schema",void 0,void 0,e),mJ=e=>Ca("Unsupported literal",`literal value: ${ui(e)}`),$O=e=>Ca("Duplicate index signature",`${e} index signature`),yJ=Ca("Unsupported index signature parameter","An index signature parameter type must be `string`, `symbol`, a template literal type or a refinement of the previous types"),_J=Ca("Invalid element","A required element cannot follow an optional element. ts(1257)"),IO=e=>Ca("Duplicate property signature transformation",`Duplicate key ${ui(e)}`),$M=e=>Ca("Duplicate property signature",`Duplicate key ${ui(e)}`),SJ=Symbol.for("effect/SchemaId/DateFromSelf"),vJ=Symbol.for("effect/SchemaId/GreaterThanOrEqualTo"),wJ=Symbol.for("effect/SchemaId/Int"),bJ=Symbol.for("effect/SchemaId/Between"),dd=kQ,OS=e=>e.replace(/[/\\^$*+?.()|[\]{}]/g,"\\$&"),IM=Symbol.for("effect/annotation/Brand"),EJ=Symbol.for("effect/annotation/SchemaId"),TM=Symbol.for("effect/annotation/Message"),GR=Symbol.for("effect/annotation/MissingMessage"),QR=Symbol.for("effect/annotation/Identifier"),Ro=Symbol.for("effect/annotation/Title"),jf=Symbol.for("effect/annotation/AutoTitle"),xm=Symbol.for("effect/annotation/Description"),PM=Symbol.for("effect/annotation/Examples"),OM=Symbol.for("effect/annotation/Default"),AM=Symbol.for("effect/annotation/JSONSchema"),FM=Symbol.for("effect/annotation/Arbitrary"),NM=Symbol.for("effect/annotation/Pretty"),DM=Symbol.for("effect/annotation/Equivalence"),kJ=Symbol.for("effect/annotation/Documentation"),qM=Symbol.for("effect/annotation/Concurrency"),MM=Symbol.for("effect/annotation/Batching"),LM=Symbol.for("effect/annotation/ParseIssueTitle"),zM=Symbol.for("effect/annotation/ParseOptions"),jM=Symbol.for("effect/annotation/DecodingFallback"),AS=Symbol.for("effect/annotation/Surrogate"),CJ=Symbol.for("effect/annotation/StableFilter"),es=x(2,(e,t)=>Object.prototype.hasOwnProperty.call(e.annotations,t)?oe(e.annotations[t]):re()),UM=es(IM),xJ=es(TM),RJ=es(GR),HM=es(Ro),BM=es(jf),qv=es(QR),VM=es(xm),$J=es(qM),IJ=es(MM),TJ=es(LM),PJ=es(zM),OJ=es(jM),Mv=es(AS),AJ=es(CJ),WM=e=>DQ(AJ(e),t=>t===!0),Lv=Symbol.for("effect/annotation/JSONIdentifier"),FJ=es(Lv),NJ=e=>Xo(FJ(e),()=>qv(e)),DJ=Symbol.for("effect/schema/ParseJson");class zv{constructor(t,n,r,s={}){p(this,"typeParameters");p(this,"decodeUnknown");p(this,"encodeUnknown");p(this,"annotations");p(this,"_tag","Declaration");this.typeParameters=t,this.decodeUnknown=n,this.encodeUnknown=r,this.annotations=s}toString(){return Yt(So(this),()=>"<declaration schema>")}toJSON(){return{_tag:this._tag,typeParameters:this.typeParameters.map(t=>t.toJSON()),annotations:Bn(this.annotations)}}}const $o=e=>t=>t._tag===e;let FS=class{constructor(t,n={}){p(this,"literal");p(this,"annotations");p(this,"_tag","Literal");this.literal=t,this.annotations=n}toString(){return Yt(So(this),()=>ui(this.literal))}toJSON(){return{_tag:this._tag,literal:Iv(this.literal)?String(this.literal):this.literal,annotations:Bn(this.annotations)}}};const Pp=$o("Literal"),qJ=new FS(null);class MJ{constructor(t,n={}){p(this,"symbol");p(this,"annotations");p(this,"_tag","UniqueSymbol");this.symbol=t,this.annotations=n}toString(){return Yt(So(this),()=>ui(this.symbol))}toJSON(){return{_tag:this._tag,symbol:String(this.symbol),annotations:Bn(this.annotations)}}}class LJ{constructor(t={}){p(this,"annotations");p(this,"_tag","UndefinedKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const hd=new LJ({[Ro]:"undefined"});class zJ{constructor(t={}){p(this,"annotations");p(this,"_tag","VoidKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const jJ=new zJ({[Ro]:"void"});class UJ{constructor(t={}){p(this,"annotations");p(this,"_tag","NeverKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const jv=new UJ({[Ro]:"never"}),HJ=$o("NeverKeyword");class BJ{constructor(t={}){p(this,"annotations");p(this,"_tag","UnknownKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const KM=new BJ({[Ro]:"unknown"});class VJ{constructor(t={}){p(this,"annotations");p(this,"_tag","AnyKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const GM=new VJ({[Ro]:"any"});class WJ{constructor(t={}){p(this,"annotations");p(this,"_tag","StringKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const wk=new WJ({[Ro]:"string",[xm]:"a string"}),bk=$o("StringKeyword");class KJ{constructor(t={}){p(this,"annotations");p(this,"_tag","NumberKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const Ek=new KJ({[Ro]:"number",[xm]:"a number"}),TO=$o("NumberKeyword");class GJ{constructor(t={}){p(this,"annotations");p(this,"_tag","BooleanKeyword");this.annotations=t}toString(){return Hl(this)}toJSON(){return{_tag:this._tag,annotations:Bn(this.annotations)}}}const kk=new GJ({[Ro]:"boolean",[xm]:"a boolean"}),PO=$o("BooleanKeyword"),QM=$o("SymbolKeyword");let Rm=class{constructor(t,n={}){p(this,"type");p(this,"annotations");this.type=t,this.annotations=n}toJSON(){return{type:this.type.toJSON(),annotations:Bn(this.annotations)}}toString(){return String(this.type)}};class Ul extends Rm{constructor(n,r,s={}){super(n,s);p(this,"isOptional");this.isOptional=r}toJSON(){return{type:this.type.toJSON(),isOptional:this.isOptional,annotations:Bn(this.annotations)}}toString(){return String(this.type)+(this.isOptional?"?":"")}}const Uv=e=>e.map(t=>t.type);class $m{constructor(t,n,r,s={}){p(this,"elements");p(this,"rest");p(this,"isReadonly");p(this,"annotations");p(this,"_tag","TupleType");this.elements=t,this.rest=n,this.isReadonly=r,this.annotations=s;let i=!1,o=!1;for(const a of t)if(a.isOptional)i=!0;else if(i){o=!0;break}if(o||i&&n.length>1)throw new Error(_J)}toString(){return Yt(So(this),()=>QJ(this))}toJSON(){return{_tag:this._tag,elements:this.elements.map(t=>t.toJSON()),rest:this.rest.map(t=>t.toJSON()),isReadonly:this.isReadonly,annotations:Bn(this.annotations)}}}const QJ=e=>{const t=e.elements.map(String).join(", ");return GQ(e.rest,{onEmpty:()=>`readonly [${t}]`,onNonEmpty:(n,r)=>{const s=String(n),i=s.includes(" | ")?`(${s})`:s;if(r.length>0){const o=r.map(String).join(", ");return e.elements.length>0?`readonly [${t}, ...${i}[], ${o}]`:`readonly [...${i}[], ${o}]`}else return e.elements.length>0?`readonly [${t}, ...${i}[]]`:`ReadonlyArray<${s}>`}})};class pn extends Ul{constructor(n,r,s,i,o){super(r,s,o);p(this,"name");p(this,"isReadonly");this.name=n,this.isReadonly=i}toString(){return(this.isReadonly?"readonly ":"")+String(this.name)+(this.isOptional?"?":"")+": "+this.type}toJSON(){return{name:String(this.name),type:this.type.toJSON(),isOptional:this.isOptional,isReadonly:this.isReadonly,annotations:Bn(this.annotations)}}}const JM=e=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return!0;case"Refinement":return JM(e.from)}return!1};class Xd{constructor(t,n,r){p(this,"type");p(this,"isReadonly");p(this,"parameter");if(this.type=n,this.isReadonly=r,JM(t))this.parameter=t;else throw new Error(yJ)}toString(){return(this.isReadonly?"readonly ":"")+`[x: ${this.parameter}]: ${this.type}`}toJSON(){return{parameter:this.parameter.toJSON(),type:this.type.toJSON(),isReadonly:this.isReadonly}}}class fi{constructor(t,n,r={}){p(this,"annotations");p(this,"_tag","TypeLiteral");p(this,"propertySignatures");p(this,"indexSignatures");this.annotations=r;const s={};for(let o=0;o<t.length;o++){const a=t[o].name;if(Object.prototype.hasOwnProperty.call(s,a))throw new Error($M(a));s[a]=null}const i={string:!1,symbol:!1};for(let o=0;o<n.length;o++){const a=DS(n[o].parameter);if(bk(a)){if(i.string)throw new Error($O("string"));i.string=!0}else if(QM(a)){if(i.symbol)throw new Error($O("symbol"));i.symbol=!0}}this.propertySignatures=t,this.indexSignatures=n}toString(){return Yt(So(this),()=>JJ(this))}toJSON(){return{_tag:this._tag,propertySignatures:this.propertySignatures.map(t=>t.toJSON()),indexSignatures:this.indexSignatures.map(t=>t.toJSON()),annotations:Bn(this.annotations)}}}const OO=e=>e.map(String).join("; "),JJ=e=>{if(e.propertySignatures.length>0){const t=e.propertySignatures.map(String).join("; ");return e.indexSignatures.length>0?`{ ${t}; ${OO(e.indexSignatures)} }`:`{ ${t} }`}else return e.indexSignatures.length>0?`{ ${OO(e.indexSignatures)} }`:"{}"},AO=$o("TypeLiteral"),YJ=hg(lM(dd,e=>{switch(e._tag){case"AnyKeyword":return 0;case"UnknownKeyword":return 1;case"ObjectKeyword":return 2;case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":return 3}return 4})),XJ={string:"StringKeyword",number:"NumberKeyword",boolean:"BooleanKeyword",bigint:"BigIntKeyword"},YM=e=>PS(e,t=>YR(t)?YM(t.types):[t]),ZJ=e=>{const t=YJ(e),n=[],r={},s=[];for(const i of t)switch(i._tag){case"NeverKeyword":break;case"AnyKeyword":return[GM];case"UnknownKeyword":return[KM];case"ObjectKeyword":case"UndefinedKeyword":case"VoidKeyword":case"StringKeyword":case"NumberKeyword":case"BooleanKeyword":case"BigIntKeyword":case"SymbolKeyword":{r[i._tag]||(r[i._tag]=i,n.push(i));break}case"Literal":{const o=typeof i.literal;switch(o){case"string":case"number":case"bigint":case"boolean":{const a=XJ[o];!r[a]&&!s.includes(i.literal)&&(s.push(i.literal),n.push(i));break}case"object":{s.includes(i.literal)||(s.push(i.literal),n.push(i));break}}break}case"UniqueSymbol":{!r.SymbolKeyword&&!s.includes(i.symbol)&&(s.push(i.symbol),n.push(i));break}case"TupleType":{r.ObjectKeyword||n.push(i);break}case"TypeLiteral":{i.propertySignatures.length===0&&i.indexSignatures.length===0?r["{}"]||(r["{}"]=i,n.push(i)):r.ObjectKeyword||n.push(i);break}default:n.push(i)}return n};var sl;let Jn=(sl=class{constructor(t,n={}){p(this,"types");p(this,"annotations");p(this,"_tag","Union");this.types=t,this.annotations=n}toString(){return Yt(So(this),()=>this.types.map(String).join(" | "))}toJSON(){return{_tag:this._tag,types:this.types.map(t=>t.toJSON()),annotations:Bn(this.annotations)}}},p(sl,"make",(t,n)=>JR(t)?new sl(t,n):t.length===1?t[0]:jv),p(sl,"unify",(t,n)=>sl.make(ZJ(YM(t)),n)),sl);const eY=(e,t)=>e.map(t),JR=e=>e.length>1,YR=$o("Union"),k1=We(Symbol.for("effect/Schema/AST/toJSONMemoMap"),()=>new WeakMap);class Xc{constructor(t,n={}){p(this,"f");p(this,"annotations");p(this,"_tag","Suspend");this.f=t,this.annotations=n,this.f=EM(t)}toString(){return So(this).pipe(Xo(()=>Eu(cM(this.f)(),t=>So(t))),Yt(()=>"<suspended schema>"))}toJSON(){const t=this.f();let n=k1.get(t);return n||(k1.set(t,{_tag:this._tag}),n={_tag:this._tag,ast:t.toJSON(),annotations:Bn(this.annotations)},k1.set(t,n),n)}}let Zd=class{constructor(t,n,r={}){p(this,"from");p(this,"filter");p(this,"annotations");p(this,"_tag","Refinement");this.from=t,this.filter=n,this.annotations=r}toString(){return qv(this).pipe(Yt(()=>bt(sL(this),{onNone:()=>`{ ${this.from} | filter }`,onSome:t=>Uf(this.from)?String(this.from)+" & "+t:t})))}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),annotations:Bn(this.annotations)}}};const Uf=$o("Refinement"),C1={};let li=class{constructor(t,n,r,s={}){p(this,"from");p(this,"to");p(this,"transformation");p(this,"annotations");p(this,"_tag","Transformation");this.from=t,this.to=n,this.transformation=r,this.annotations=s}toString(){return Yt(So(this),()=>`(${String(this.from)} <-> ${String(this.to)})`)}toJSON(){return{_tag:this._tag,from:this.from.toJSON(),to:this.to.toJSON(),annotations:Bn(this.annotations)}}};const tY=$o("Transformation");class XM{constructor(t,n){p(this,"decode");p(this,"encode");p(this,"_tag","FinalTransformation");this.decode=t,this.encode=n}}const nY=e=>t=>t._tag===e;class rY{constructor(){p(this,"_tag","ComposeTransformation")}}const XR=new rY;let sY=class{constructor(t,n,r,s){p(this,"from");p(this,"to");p(this,"decode");p(this,"encode");this.from=t,this.to=n,this.decode=r,this.encode=s}};const iY=e=>e.decode===Ce&&e.encode===Ce;class NS{constructor(t){p(this,"propertySignatureTransformations");p(this,"_tag","TypeLiteralTransformation");this.propertySignatureTransformations=t;const n={},r={};for(const s of t){const i=s.from;if(n[i])throw new Error(IO(i));n[i]=!0;const o=s.to;if(r[o])throw new Error(IO(o));r[o]=!0}}}const Ck=nY("TypeLiteralTransformation"),Zc=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={...e.annotations,...t},s=Mv(e);return Wt(s)&&(r[AS]=Zc(s.value,t)),n.annotations.value=r,Object.create(Object.getPrototypeOf(e),n)},oY="[\\s\\S]*",aY="[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?",ZM=(e,t)=>{switch(e._tag){case"Literal":return OS(String(e.literal));case"StringKeyword":return oY;case"NumberKeyword":return aY;case"TemplateLiteral":return eL(e,t,!1);case"Union":return e.types.map(n=>ZM(n,t)).join("|")}},lY=(e,t,n,r)=>{if(YR(e)){if(n&&!r)return`(?:${t})`}else if(!n||!r)return t;return`(${t})`},eL=(e,t,n)=>{let r="";if(e.head!==""){const s=OS(e.head);r+=t&&n?`(${s})`:s}for(const s of e.spans){const i=ZM(s.type,t);if(r+=lY(s.type,i,t,n),s.literal!==""){const o=OS(s.literal);r+=t&&n?`(${o})`:o}}return r},tL=e=>new RegExp(`^${eL(e,!1,!0)}$`),O_=e=>{switch(e._tag){case"TupleType":{let t=!1,n=[];for(const r of e.elements)r.isOptional&&(t=!0),n.push(r.type);return t&&n.push(hd),n=n.concat(Uv(e.rest)),Jn.make(n)}case"Refinement":return O_(e.from);case"Union":return Jn.make(e.types.map(O_));case"Suspend":return O_(e.f())}throw new Error(pg(e))},nL=(e,t)=>{const n=sJ(e.propertySignatures,r=>r.name===t);if(Wt(n))return n.value;if(Jr(t)){let r;for(const s of e.indexSignatures){const i=DS(s.parameter);switch(i._tag){case"TemplateLiteral":{if(tL(i).test(t))return new pn(t,s.type,!1,!0);break}case"StringKeyword":r===void 0&&(r=new pn(t,s.type,!1,!0))}}if(r)return r}else if(kS(t))for(const r of e.indexSignatures){const s=DS(r.parameter);if(QM(s))return new pn(t,r.type,!1,!0)}},xf=(e,t)=>{const n=Mv(e);if(Wt(n))return xf(n.value,t);switch(e._tag){case"TypeLiteral":{const r=nL(e,t);if(r)return r;break}case"Union":return new pn(t,Jn.make(e.types.map(r=>xf(r,t).type)),!1,!0);case"Suspend":return xf(e.f(),t);case"Refinement":return xf(e.from,t)}throw new Error(pg(e))},FO=(e,t)=>{const n=[],r=[],s=i=>{switch(i._tag){case"NeverKeyword":break;case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":case"Refinement":r.push(new Xd(i,t,!0));break;case"Literal":if(Jr(i.literal)||fa(i.literal))n.push(new pn(i.literal,t,!1,!0));else throw new Error(mJ(i.literal));break;case"Enums":{for(const[o,a]of i.enums)n.push(new pn(a,t,!1,!0));break}case"UniqueSymbol":n.push(new pn(i.symbol,t,!1,!0));break;case"Union":i.types.forEach(s);break;default:throw new Error(gJ(i))}};return s(e),{propertySignatures:n,indexSignatures:r}},Lo=(e,t)=>{const n=Mv(e);if(Wt(n))return Lo(n.value,t);switch(e._tag){case"TypeLiteral":{const r=[],s={};for(const i of e.propertySignatures)s[i.name]=null,t.includes(i.name)&&r.push(i);for(const i of t)if(!(i in s)){const o=nL(e,i);o&&r.push(o)}return new fi(r,[])}case"Union":return new fi(t.map(r=>xf(e,r)),[]);case"Suspend":return Lo(e.f(),t);case"Refinement":return Lo(e.from,t);case"Transformation":switch(e.transformation._tag){case"ComposeTransformation":return new li(Lo(e.from,t),Lo(e.to,t),XR);case"TypeLiteralTransformation":{const r=[],s=[];for(const i of t){const o=e.transformation.propertySignatureTransformations.find(a=>a.to===i);o?(r.push(o),s.push(o.from)):s.push(i)}return Kt(r)?new li(Lo(e.from,s),Lo(e.to,t),new NS(r)):Lo(e.from,s)}}}throw new Error(pg(e))},A_=e=>Jn.make([e,hd]),ap=(e,t)=>{const n=(t==null?void 0:t.exact)===!0;switch(e._tag){case"TupleType":return new $m(e.elements.map(r=>new Ul(n?r.type:A_(r.type),!0)),KQ(e.rest,{onEmpty:()=>e.rest,onNonEmpty:r=>[new Rm(Jn.make([...Uv(r),hd]))]}),e.isReadonly);case"TypeLiteral":return new fi(e.propertySignatures.map(r=>new pn(r.name,n?r.type:A_(r.type),!0,r.isReadonly,r.annotations)),e.indexSignatures.map(r=>new Xd(r.parameter,A_(r.type),r.isReadonly)));case"Union":return Jn.make(e.types.map(r=>ap(r,t)));case"Suspend":return new Xc(()=>ap(e.f(),t));case"Declaration":case"Refinement":throw new Error(pg(e));case"Transformation":{if(Ck(e.transformation)&&e.transformation.propertySignatureTransformations.every(iY))return new li(ap(e.from,t),ap(e.to,t),e.transformation);throw new Error(pg(e))}}return e},sf=e=>{switch(e._tag){case"TupleType":return e.isReadonly===!1?e:new $m(e.elements,e.rest,!1,e.annotations);case"TypeLiteral":{const t=Vr(e.propertySignatures,r=>r.isReadonly===!1?r:new pn(r.name,r.type,r.isOptional,!1,r.annotations)),n=Vr(e.indexSignatures,r=>r.isReadonly===!1?r:new Xd(r.parameter,r.type,!1));return t===e.propertySignatures&&n===e.indexSignatures?e:new fi(t,n,e.annotations)}case"Union":{const t=Vr(e.types,sf);return t===e.types?e:Jn.make(t,e.annotations)}case"Suspend":return new Xc(()=>sf(e.f()),e.annotations);case"Refinement":{const t=sf(e.from);return t===e.from?e:new Zd(t,e.filter,e.annotations)}case"Transformation":{const t=sf(e.from),n=sf(e.to);return t===e.from&&n===e.to?e:new li(t,n,e.transformation,e.annotations)}}return e},rL=e=>t=>{let n;for(const r of e)Object.prototype.hasOwnProperty.call(t.annotations,r)&&(n===void 0&&(n={}),n[r]=t.annotations[r]);return n},cY=e=>t=>{const n={...t.annotations};for(const r of e)delete n[r];return n},uY=rL([PM,OM,AM,FM,NM,DM]),gn=e=>{switch(e._tag){case"Declaration":{const t=Vr(e.typeParameters,gn);return t===e.typeParameters?e:new zv(t,e.decodeUnknown,e.encodeUnknown,e.annotations)}case"TupleType":{const t=Vr(e.elements,s=>{const i=gn(s.type);return i===s.type?s:new Ul(i,s.isOptional)}),n=Uv(e.rest),r=Vr(n,gn);return t===e.elements&&r===n?e:new $m(t,r.map(s=>new Rm(s)),e.isReadonly,e.annotations)}case"TypeLiteral":{const t=Vr(e.propertySignatures,r=>{const s=gn(r.type);return s===r.type?r:new pn(r.name,s,r.isOptional,r.isReadonly)}),n=Vr(e.indexSignatures,r=>{const s=gn(r.type);return s===r.type?r:new Xd(r.parameter,s,r.isReadonly)});return t===e.propertySignatures&&n===e.indexSignatures?e:new fi(t,n,e.annotations)}case"Union":{const t=Vr(e.types,gn);return t===e.types?e:Jn.make(t,e.annotations)}case"Suspend":return new Xc(()=>gn(e.f()),e.annotations);case"Refinement":{const t=gn(e.from);return t===e.from?e:new Zd(t,e.filter,e.annotations)}case"Transformation":{const t=uY(e);return gn(t!==void 0?Zc(e.to,t):e.to)}}return e},Yu=e=>bt(NJ(e),{onNone:()=>{},onSome:t=>({[Lv]:t})});function Vr(e,t){let n=!1;const r=Nv(e.length);for(let s=0;s<e.length;s++){const i=e[s],o=t(i);o!==i&&(n=!0),r[s]=o}return n?r:e}const xk=e=>{switch(e._tag){case"Transformation":return e.from;case"Refinement":return xk(e.from);case"Suspend":return xk(e.f())}},Ji=(e,t)=>{switch(e._tag){case"Declaration":{const n=Vr(e.typeParameters,r=>Ji(r,t));return n===e.typeParameters?e:new zv(n,e.decodeUnknown,e.encodeUnknown,e.annotations)}case"TupleType":{const n=Vr(e.elements,i=>{const o=Ji(i.type,t);return o===i.type?i:new Ul(o,i.isOptional)}),r=Uv(e.rest),s=Vr(r,i=>Ji(i,t));return n===e.elements&&s===r?e:new $m(n,s.map(i=>new Rm(i)),e.isReadonly,Yu(e))}case"TypeLiteral":{const n=Vr(e.propertySignatures,s=>{const i=Ji(s.type,t);return i===s.type?s:new pn(s.name,i,s.isOptional,s.isReadonly)}),r=Vr(e.indexSignatures,s=>{const i=Ji(s.type,t);return i===s.type?s:new Xd(s.parameter,i,s.isReadonly)});return n===e.propertySignatures&&r===e.indexSignatures?e:new fi(n,r,Yu(e))}case"Union":{const n=Vr(e.types,r=>Ji(r,t));return n===e.types?e:Jn.make(n,Yu(e))}case"Suspend":return new Xc(()=>Ji(e.f(),t),Yu(e));case"Refinement":{const n=Ji(e.from,t);if(t){if(n===e.from)return e;if(xk(e.from)===void 0&&WM(e))return new Zd(n,e.filter,e.annotations)}const r=Yu(e);return r?Zc(n,r):n}case"Transformation":{const n=Yu(e);return Ji(n?Zc(e.from,n):e.from,t)}}return e},Rk=e=>Ji(e,!1),Bn=e=>{const t={};for(const n of Object.getOwnPropertySymbols(e))t[String(n)]=e[n];return t},DS=e=>{switch(e._tag){case"StringKeyword":case"SymbolKeyword":case"TemplateLiteral":return e;case"Refinement":return DS(e.from)}},fY=(e,t)=>new li(e,t,XR),Hl=e=>Yt(So(e),()=>e._tag);function dY(e){return bt(UM(e),{onNone:()=>"",onSome:t=>t.map(n=>` & Brand<${ui(n)}>`).join("")})}const sL=e=>HM(e).pipe(Xo(()=>VM(e)),Xo(()=>BM(e)),hl(t=>t+dY(e))),So=e=>Xo(qv(e),()=>sL(e)),hY=(e,t,n)=>{switch(e._tag){case"UndefinedKeyword":return jv;case"Union":{const r=[];let s=!1;for(const i of e.types){const o=t(i);o?(s=!0,HJ(o)||r.push(o)):r.push(i)}if(s)return Jn.make(r);break}case"Suspend":return t(e.f());case"Transformation":return n(e)}},NO=Symbol.for("effect/Brand/Refined"),iL=()=>Object.assign(e=>e,{[NO]:NO,option:e=>oe(e),either:e=>Pe(e),is:e=>!0}),oL=Symbol.for("effect/Context/Tag"),qS=Symbol.for("effect/Context/Reference"),pY="effect/STM",gY=Symbol.for(pY),ZR={...Em,_op:"Tag",[gY]:Jc,[oL]:{_Service:e=>e,_Identifier:e=>e},toString(){return qt(this.toJSON())},toJSON(){return{_id:"Tag",key:this.key,stack:this.stack}},[ft](){return this.toJSON()},of(e){return e},context(e){return cL(this,e)}},mY={...ZR,[qS]:qS},yY=e=>{const t=Error.stackTraceLimit;Error.stackTraceLimit=2;const n=new Error;Error.stackTraceLimit=t;const r=Object.create(ZR);return Object.defineProperty(r,"stack",{get(){return n.stack}}),r.key=e,r},_Y=e=>()=>{const t=Error.stackTraceLimit;Error.stackTraceLimit=2;const n=new Error;Error.stackTraceLimit=t;function r(){}return Object.setPrototypeOf(r,ZR),r.key=e,Object.defineProperty(r,"stack",{get(){return n.stack}}),r},SY=()=>(e,t)=>{const n=Error.stackTraceLimit;Error.stackTraceLimit=2;const r=new Error;Error.stackTraceLimit=n;function s(){}return Object.setPrototypeOf(s,mY),s.key=e,s.defaultValue=t.defaultValue,Object.defineProperty(s,"stack",{get(){return r.stack}}),s},aL=Symbol.for("effect/Context"),vY={[aL]:{_Services:e=>e},[Me](e){if(lL(e)&&this.unsafeMap.size===e.unsafeMap.size){for(const t of this.unsafeMap.keys())if(!e.unsafeMap.has(t)||!Ne(this.unsafeMap.get(t),e.unsafeMap.get(t)))return!1;return!0}return!1},[qe](){return At(this,qR(this.unsafeMap.size))},pipe(){return pe(this,arguments)},toString(){return qt(this.toJSON())},toJSON(){return{_id:"Context",services:Array.from(this.unsafeMap).map(sn)}},[ft](){return this.toJSON()}},eu=e=>{const t=Object.create(vY);return t.unsafeMap=e,t},wY=e=>{const t=new Error(`Service not found${e.key?`: ${String(e.key)}`:""}`);if(e.stack){const n=e.stack.split(`
178
+ `);if(n.length>2){const r=n[2].match(/at (.*)/);r&&(t.message=t.message+` (defined at ${r[1]})`)}}if(t.stack){const n=t.stack.split(`
179
+ `);n.splice(1,3),t.stack=n.join(`
180
+ `)}return t},lL=e=>_e(e,aL),bY=e=>_e(e,oL),EY=e=>_e(e,qS),kY=eu(new Map),CY=()=>kY,cL=(e,t)=>eu(new Map([[e.key,t]])),xY=x(3,(e,t,n)=>{const r=new Map(e.unsafeMap);return r.set(t.key,n),eu(r)}),x1=We("effect/Context/defaultValueCache",()=>new Map),e$=e=>{if(x1.has(e.key))return x1.get(e.key);const t=e.defaultValue();return x1.set(e.key,t),t},RY=(e,t)=>e.unsafeMap.has(t.key)?e.unsafeMap.get(t.key):e$(t),uL=x(2,(e,t)=>{if(!e.unsafeMap.has(t.key)){if(qS in t)return e$(t);throw wY(t)}return e.unsafeMap.get(t.key)}),$Y=uL,IY=x(2,(e,t)=>e.unsafeMap.has(t.key)?IS(e.unsafeMap.get(t.key)):EY(t)?IS(e$(t)):UR),TY=x(2,(e,t)=>{const n=new Map(e.unsafeMap);for(const[r,s]of t.unsafeMap)n.set(r,s);return eu(n)}),PY=(...e)=>t=>{const n=new Map(t.unsafeMap);for(const r of e)n.delete(r.key);return eu(n)},Mr=yY,OY=lL,t$=bY,tu=CY,Hv=cL,$i=xY,hs=$Y,Bv=uL,Ms=IY,xa=TY,AY=PY,Vv=_Y,Im=SY,fL=Symbol.for("effect/Chunk");function FY(e,t,n,r,s){for(let i=t;i<Math.min(e.length,t+s);i++)n[r+i-t]=e[i];return n}const dL=[],NY=e=>vm((t,n)=>t.length===n.length&&di(t).every((r,s)=>e(r,mo(n,s)))),DY=NY(Ne),qY={[fL]:{_A:e=>e},toString(){return qt(this.toJSON())},toJSON(){return{_id:"Chunk",values:di(this).map(sn)}},[ft](){return this.toJSON()},[Me](e){return Fc(e)&&DY(this,e)},[qe](){return At(this,wm(di(this)))},[Symbol.iterator](){switch(this.backing._tag){case"IArray":return this.backing.array[Symbol.iterator]();case"IEmpty":return dL[Symbol.iterator]();default:return di(this)[Symbol.iterator]()}},pipe(){return pe(this,arguments)}},kn=e=>{const t=Object.create(qY);switch(t.backing=e,e._tag){case"IEmpty":{t.length=0,t.depth=0,t.left=t,t.right=t;break}case"IConcat":{t.length=e.left.length+e.right.length,t.depth=1+Math.max(e.left.depth,e.right.depth),t.left=e.left,t.right=e.right;break}case"IArray":{t.length=e.array.length,t.depth=0,t.left=Ri,t.right=Ri;break}case"ISingleton":{t.length=1,t.depth=0,t.left=Ri,t.right=Ri;break}case"ISlice":{t.length=e.length,t.depth=e.chunk.depth+1,t.left=Ri,t.right=Ri;break}}return t},Fc=e=>_e(e,fL),Ri=kn({_tag:"IEmpty"}),Ut=()=>Ri,R1=(...e)=>zY(e),Xt=e=>kn({_tag:"ISingleton",a:e}),da=e=>Fc(e)?e:xn(gt(e)),$k=(e,t,n)=>{switch(e.backing._tag){case"IArray":{FY(e.backing.array,0,t,n,e.length);break}case"IConcat":{$k(e.left,t,n),$k(e.right,t,n+e.left.length);break}case"ISingleton":{t[n]=e.backing.a;break}case"ISlice":{let r=0,s=n;for(;r<e.length;)t[s]=mo(e,r),r+=1,s+=1;break}}},MY=e=>{switch(e.backing._tag){case"IEmpty":return dL;case"IArray":return e.backing.array;default:{const t=new Array(e.length);return $k(e,t,0),e.backing={_tag:"IArray",array:t},e.left=Ri,e.right=Ri,e.depth=0,t}}},di=MY,LY=e=>{switch(e.backing._tag){case"IEmpty":case"ISingleton":return e;case"IArray":return kn({_tag:"IArray",array:kO(e.backing.array)});case"IConcat":return kn({_tag:"IConcat",left:ha(e.backing.right),right:ha(e.backing.left)});case"ISlice":return xn(kO(di(e)))}},ha=LY,hL=x(2,(e,t)=>t<0||t>=e.length?re():oe(mo(e,t))),xn=e=>e.length===0?Ut():e.length===1?Xt(e[0]):kn({_tag:"IArray",array:e}),zY=e=>xn(e),mo=x(2,(e,t)=>{switch(e.backing._tag){case"IEmpty":throw new Error("Index out of bounds");case"ISingleton":{if(t!==0)throw new Error("Index out of bounds");return e.backing.a}case"IArray":{if(t>=e.length||t<0)throw new Error("Index out of bounds");return e.backing.array[t]}case"IConcat":return t<e.left.length?mo(e.left,t):mo(e.right,t-e.left.length);case"ISlice":return mo(e.backing.chunk,t+e.backing.offset)}}),gg=x(2,(e,t)=>nn(e,Xt(t))),xr=x(2,(e,t)=>nn(Xt(t),e)),pd=x(2,(e,t)=>{if(t<=0)return Ri;if(t>=e.length)return e;switch(e.backing._tag){case"ISlice":return kn({_tag:"ISlice",chunk:e.backing.chunk,length:t,offset:e.backing.offset});case"IConcat":return t>e.left.length?kn({_tag:"IConcat",left:e.left,right:pd(e.right,t-e.left.length)}):pd(e.left,t);default:return kn({_tag:"ISlice",chunk:e,offset:0,length:t})}}),lo=x(2,(e,t)=>{if(t<=0)return e;if(t>=e.length)return Ri;switch(e.backing._tag){case"ISlice":return kn({_tag:"ISlice",chunk:e.backing.chunk,offset:e.backing.offset+t,length:e.backing.length-t});case"IConcat":return t>e.left.length?lo(e.right,t-e.left.length):kn({_tag:"IConcat",left:lo(e.left,t),right:e.right});default:return kn({_tag:"ISlice",chunk:e,offset:t,length:e.length-t})}}),nn=x(2,(e,t)=>{if(e.backing._tag==="IEmpty")return t;if(t.backing._tag==="IEmpty")return e;const n=t.depth-e.depth;if(Math.abs(n)<=1)return kn({_tag:"IConcat",left:e,right:t});if(n<-1)if(e.left.depth>=e.right.depth){const r=nn(e.right,t);return kn({_tag:"IConcat",left:e.left,right:r})}else{const r=nn(e.right.right,t);if(r.depth===e.depth-3){const s=kn({_tag:"IConcat",left:e.right.left,right:r});return kn({_tag:"IConcat",left:e.left,right:s})}else{const s=kn({_tag:"IConcat",left:e.left,right:e.right.left});return kn({_tag:"IConcat",left:s,right:r})}}else if(t.right.depth>=t.left.depth){const r=nn(e,t.left);return kn({_tag:"IConcat",left:r,right:t.right})}else{const r=nn(e,t.left.left);if(r.depth===t.depth-3){const s=kn({_tag:"IConcat",left:r,right:t.left.right});return kn({_tag:"IConcat",left:s,right:t.right})}else{const s=kn({_tag:"IConcat",left:t.left.right,right:t.right});return kn({_tag:"IConcat",left:r,right:s})}}}),pL=x(2,(e,t)=>xn(SM(e,t))),Wv=x(2,(e,t)=>xn(vM(e,t))),Tm=e=>e.length===0,vo=e=>e.length>0,Kv=hL(0),Gv=e=>mo(e,0),co=Gv,jY=e=>hL(e,e.length-1),Xu=e=>mo(e,e.length-1),Rf=x(2,(e,t)=>e.backing._tag==="ISingleton"?Xt(t(e.backing.a,0)):xn(T(di(e),Zo((n,r)=>t(n,r))))),gL=x(2,(e,t)=>[pd(e,t),lo(e,t)]),UY=x(2,(e,t)=>{let n=0;for(const r of di(e)){if(t(r))break;n++}return gL(e,n)}),Ko=e=>lo(e,1),HY=x(2,(e,t)=>lo(e,e.length-t)),BY=WR,Ik=Symbol.for("effect/Duration"),mL=BigInt(0),DO=BigInt(24),Jy=BigInt(60),Tk=BigInt(1e3),qO=BigInt(1e6),MO=BigInt(1e9),VY=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Ls=e=>{if(n$(e))return e;if(fa(e))return nu(e);if(Iv(e))return F_(e);if(Array.isArray(e)&&e.length===2&&e.every(fa))return e[0]===-1/0||e[1]===-1/0||Number.isNaN(e[0])||Number.isNaN(e[1])?yL:e[0]===1/0||e[1]===1/0?_L:F_(BigInt(Math.round(e[0]*1e9))+BigInt(Math.round(e[1])));if(Jr(e)){const t=VY.exec(e);if(t){const[n,r,s]=t,i=Number(r);switch(s){case"nano":case"nanos":return F_(BigInt(r));case"micro":case"micros":return QY(BigInt(r));case"milli":case"millis":return nu(i);case"second":case"seconds":return r$(i);case"minute":case"minutes":return SL(i);case"hour":case"hours":return JY(i);case"day":case"days":return YY(i);case"week":case"weeks":return XY(i)}}}throw new Error("Invalid DurationInput")},LO={_tag:"Millis",millis:0},WY={_tag:"Infinity"},KY={[Ik]:Ik,[qe](){return At(this,Vq(this.value))},[Me](e){return n$(e)&&iX(this,e)},toString(){return`Duration(${bL(this)})`},toJSON(){switch(this.value._tag){case"Millis":return{_id:"Duration",_tag:"Millis",millis:this.value.millis};case"Nanos":return{_id:"Duration",_tag:"Nanos",hrtime:eX(this)};case"Infinity":return{_id:"Duration",_tag:"Infinity"}}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},ms=e=>{const t=Object.create(KY);return fa(e)?isNaN(e)||e<=0?t.value=LO:Number.isFinite(e)?Number.isInteger(e)?t.value={_tag:"Millis",millis:e}:t.value={_tag:"Nanos",nanos:BigInt(Math.round(e*1e6))}:t.value=WY:e<=mL?t.value=LO:t.value={_tag:"Nanos",nanos:e},t},n$=e=>_e(e,Ik),GY=e=>{switch(e.value._tag){case"Millis":return e.value.millis===0;case"Nanos":return e.value.nanos===mL;case"Infinity":return!1}},yL=ms(0),_L=ms(1/0),F_=e=>ms(e),QY=e=>ms(e*Tk),nu=e=>ms(e),r$=e=>ms(e*1e3),SL=e=>ms(e*6e4),JY=e=>ms(e*36e5),YY=e=>ms(e*864e5),XY=e=>ms(e*6048e5),ru=e=>vL(e,{onMillis:t=>t,onNanos:t=>Number(t)/1e6}),ZY=e=>{const t=Ls(e);switch(t.value._tag){case"Infinity":throw new Error("Cannot convert infinite duration to nanos");case"Nanos":return t.value.nanos;case"Millis":return BigInt(Math.round(t.value.millis*1e6))}},eX=e=>{const t=Ls(e);switch(t.value._tag){case"Infinity":return[1/0,0];case"Nanos":return[Number(t.value.nanos/MO),Number(t.value.nanos%MO)];case"Millis":return[Math.floor(t.value.millis/1e3),Math.round(t.value.millis%1e3*1e6)]}},vL=x(2,(e,t)=>{const n=Ls(e);switch(n.value._tag){case"Nanos":return t.onNanos(n.value.nanos);case"Infinity":return t.onMillis(1/0);case"Millis":return t.onMillis(n.value.millis)}}),Qv=x(3,(e,t,n)=>{const r=Ls(e),s=Ls(t);if(r.value._tag==="Infinity"||s.value._tag==="Infinity")return n.onMillis(ru(r),ru(s));if(r.value._tag==="Nanos"||s.value._tag==="Nanos"){const i=r.value._tag==="Nanos"?r.value.nanos:BigInt(Math.round(r.value.millis*1e6)),o=s.value._tag==="Nanos"?s.value.nanos:BigInt(Math.round(s.value.millis*1e6));return n.onNanos(i,o)}return n.onMillis(r.value.millis,s.value.millis)}),wL=(e,t)=>Qv(e,t,{onMillis:(n,r)=>n===r,onNanos:(n,r)=>n===r}),tX=x(2,(e,t)=>vL(e,{onMillis:n=>ms(n*t),onNanos:n=>ms(n*BigInt(t))})),nX=x(2,(e,t)=>Qv(e,t,{onMillis:(n,r)=>ms(n+r),onNanos:(n,r)=>ms(n+r)})),rX=x(2,(e,t)=>Qv(e,t,{onMillis:(n,r)=>n<=r,onNanos:(n,r)=>n<=r})),sX=x(2,(e,t)=>Qv(e,t,{onMillis:(n,r)=>n>=r,onNanos:(n,r)=>n>=r})),iX=x(2,(e,t)=>wL(Ls(e),Ls(t))),oX=e=>{const t=Ls(e);if(t.value._tag==="Infinity")return{days:1/0,hours:1/0,minutes:1/0,seconds:1/0,millis:1/0,nanos:1/0};const n=ZY(t),r=n/qO,s=r/Tk,i=s/Jy,o=i/Jy,a=o/DO;return{days:Number(a),hours:Number(o%DO),minutes:Number(i%Jy),seconds:Number(s%Jy),millis:Number(r%Tk),nanos:Number(n%qO)}},bL=e=>{const t=Ls(e);if(t.value._tag==="Infinity")return"Infinity";if(GY(t))return"0";const n=oX(t),r=[];return n.days!==0&&r.push(`${n.days}d`),n.hours!==0&&r.push(`${n.hours}h`),n.minutes!==0&&r.push(`${n.minutes}m`),n.seconds!==0&&r.push(`${n.seconds}s`),n.millis!==0&&r.push(`${n.millis}ms`),n.nanos!==0&&r.push(`${n.nanos}ns`),r.join(" ")},su=5,s$=Math.pow(2,su),aX=s$-1,lX=s$/2,cX=s$/4;function uX(e){return e-=e>>1&1431655765,e=(e&858993459)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,e+=e>>16,e&127}function gd(e,t){return t>>>e&aX}function $f(e){return 1<<e}function EL(e,t){return uX(e&t-1)}const fX=(e,t)=>({value:e,previous:t});function Hf(e,t,n,r){let s=r;if(!e){const i=r.length;s=new Array(i);for(let o=0;o<i;++o)s[o]=r[o]}return s[t]=n,s}function kL(e,t,n){const r=n.length-1;let s=0,i=0,o=n;if(e)s=i=t;else for(o=new Array(r);s<t;)o[i++]=n[s++];for(++s;s<=r;)o[i++]=n[s++];return e&&(o.length=r),o}function dX(e,t,n,r){const s=r.length;if(e){let c=s;for(;c>=t;)r[c--]=r[c];return r[t]=n,r}let i=0,o=0;const a=new Array(s+1);for(;i<t;)a[o++]=r[i++];for(a[t]=n;i<s;)a[++o]=r[i++];return a}class El{constructor(){p(this,"_tag","EmptyNode")}modify(t,n,r,s,i,o){const a=r(re());return on(a)?new El:(++o.value,new Nc(t,s,i,a))}}function Ii(e){return NR(e,"EmptyNode")}function hX(e){return Ii(e)||e._tag==="LeafNode"||e._tag==="CollisionNode"}function Jv(e,t){return Ii(e)?!1:t===e.edit}class Nc{constructor(t,n,r,s){p(this,"edit");p(this,"hash");p(this,"key");p(this,"value");p(this,"_tag","LeafNode");this.edit=t,this.hash=n,this.key=r,this.value=s}modify(t,n,r,s,i,o){if(Ne(i,this.key)){const c=r(this.value);return c===this.value?this:on(c)?(--o.value,new El):Jv(this,t)?(this.value=c,this):new Nc(t,s,i,c)}const a=r(re());return on(a)?this:(++o.value,CL(t,n,this.hash,this,s,new Nc(t,s,i,a)))}}class i${constructor(t,n,r){p(this,"edit");p(this,"hash");p(this,"children");p(this,"_tag","CollisionNode");this.edit=t,this.hash=n,this.children=r}modify(t,n,r,s,i,o){if(s===this.hash){const c=Jv(this,t),f=this.updateCollisionList(c,t,this.hash,this.children,r,i,o);return f===this.children?this:f.length>1?new i$(t,this.hash,f):f[0]}const a=r(re());return on(a)?this:(++o.value,CL(t,n,this.hash,this,s,new Nc(t,s,i,a)))}updateCollisionList(t,n,r,s,i,o,a){const c=s.length;for(let d=0;d<c;++d){const g=s[d];if("key"in g&&Ne(o,g.key)){const _=g.value,b=i(_);return b===_?s:on(b)?(--a.value,kL(t,d,s)):Hf(t,d,new Nc(n,r,o,b),s)}}const f=i(re());return on(f)?s:(++a.value,Hf(t,c,new Nc(n,r,o,f),s))}}class md{constructor(t,n,r){p(this,"edit");p(this,"mask");p(this,"children");p(this,"_tag","IndexedNode");this.edit=t,this.mask=n,this.children=r}modify(t,n,r,s,i,o){const a=this.mask,c=this.children,f=gd(n,s),d=$f(f),g=EL(a,d),_=a&d,b=Jv(this,t);if(!_){const m=new El().modify(t,n+su,r,s,i,o);return m?c.length>=lX?gX(t,f,m,a,c):new md(t,a|d,dX(b,g,m,c)):this}const k=c[g],I=k.modify(t,n+su,r,s,i,o);if(k===I)return this;let E=a,y;if(Ii(I)){if(E&=~d,!E)return new El;if(c.length<=2&&hX(c[g^1]))return c[g^1];y=kL(b,g,c)}else y=Hf(b,g,I,c);return b?(this.mask=E,this.children=y,this):new md(t,E,y)}}class o${constructor(t,n,r){p(this,"edit");p(this,"size");p(this,"children");p(this,"_tag","ArrayNode");this.edit=t,this.size=n,this.children=r}modify(t,n,r,s,i,o){let a=this.size;const c=this.children,f=gd(n,s),d=c[f],g=(d||new El).modify(t,n+su,r,s,i,o);if(d===g)return this;const _=Jv(this,t);let b;if(Ii(d)&&!Ii(g))++a,b=Hf(_,f,g,c);else if(!Ii(d)&&Ii(g)){if(--a,a<=cX)return pX(t,a,f,c);b=Hf(_,f,new El,c)}else b=Hf(_,f,g,c);return _?(this.size=a,this.children=b,this):new o$(t,a,b)}}function pX(e,t,n,r){const s=new Array(t-1);let i=0,o=0;for(let a=0,c=r.length;a<c;++a)if(a!==n){const f=r[a];f&&!Ii(f)&&(s[i++]=f,o|=1<<a)}return new md(e,o,s)}function gX(e,t,n,r,s){const i=[];let o=r,a=0;for(let c=0;o;++c)o&1&&(i[c]=s[a++]),o>>>=1;return i[t]=n,new o$(e,a+1,i)}function mX(e,t,n,r,s,i){if(n===s)return new i$(e,n,[i,r]);const o=gd(t,n),a=gd(t,s);if(o===a)return c=>new md(e,$f(o)|$f(a),[c]);{const c=o<a?[r,i]:[i,r];return new md(e,$f(o)|$f(a),c)}}function CL(e,t,n,r,s,i){let o,a=t;for(;;){const c=mX(e,a,n,r,s,i);if(typeof c=="function")o=fX(c,o),a=a+su;else{let f=c;for(;o!=null;)f=o.value(f),o=o.previous;return f}}}const xL="effect/HashMap",Pk=Symbol.for(xL),yX={[Pk]:Pk,[Symbol.iterator](){return new Yv(this,(e,t)=>[e,t])},[qe](){let e=ce(xL);for(const t of this)e^=T(ce(t[0]),Oe(ce(t[1])));return At(this,e)},[Me](e){if(vX(e)){if(e._size!==this._size)return!1;for(const t of this){const n=T(e,l$(t[0],ce(t[0])));if(on(n))return!1;if(!Ne(t[1],n.value))return!1}return!0}return!1},toString(){return qt(this.toJSON())},toJSON(){return{_id:"HashMap",values:Array.from(this).map(sn)}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},a$=(e,t,n,r)=>{const s=Object.create(yX);return s._editable=e,s._edit=t,s._root=n,s._size=r,s};class Yv{constructor(t,n){p(this,"map");p(this,"f");p(this,"v");this.map=t,this.f=n,this.v=RL(this.map._root,this.f,void 0)}next(){if(on(this.v))return{done:!0,value:void 0};const t=this.v.value;return this.v=MS(t.cont),{done:!1,value:t.value}}[Symbol.iterator](){return new Yv(this.map,this.f)}}const MS=e=>e?$L(e[0],e[1],e[2],e[3],e[4]):re(),RL=(e,t,n=void 0)=>{switch(e._tag){case"LeafNode":return Wt(e.value)?oe({value:t(e.key,e.value.value),cont:n}):MS(n);case"CollisionNode":case"ArrayNode":case"IndexedNode":{const r=e.children;return $L(r.length,r,0,t,n)}default:return MS(n)}},$L=(e,t,n,r,s)=>{for(;n<e;){const i=t[n++];if(i&&!Ii(i))return RL(i,r,[e,t,n,r,s])}return MS(s)},_X=a$(!1,0,new El,0),Xv=()=>_X,SX=e=>{const t=TL(Xv());for(const n of e)mg(t,n[0],n[1]);return CX(t)},vX=e=>_e(e,Pk),wX=e=>e&&Ii(e._root),bX=x(2,(e,t)=>l$(e,t,ce(t))),l$=x(3,(e,t,n)=>{let r=e._root,s=0;for(;;)switch(r._tag){case"LeafNode":return Ne(t,r.key)?r.value:re();case"CollisionNode":{if(n===r.hash){const i=r.children;for(let o=0,a=i.length;o<a;++o){const c=i[o];if("key"in c&&Ne(t,c.key))return c.value}}return re()}case"IndexedNode":{const i=gd(s,n),o=$f(i);if(r.mask&o){r=r.children[EL(r.mask,o)],s+=su;break}return re()}case"ArrayNode":{if(r=r.children[gd(s,n)],r){s+=su;break}return re()}default:return re()}}),EX=x(2,(e,t)=>Wt(l$(e,t,ce(t)))),mg=x(3,(e,t,n)=>c$(e,t,()=>oe(n))),kX=x(3,(e,t,n)=>e._editable?(e._root=t,e._size=n,e):t===e._root?e:a$(e._editable,e._edit,t,n)),IL=e=>new Yv(e,t=>t),LS=e=>e._size,TL=e=>a$(!0,e._edit+1,e._root,e._size),CX=e=>(e._editable=!1,e),c$=x(3,(e,t,n)=>xX(e,t,ce(t),n)),xX=x(4,(e,t,n,r)=>{const s={value:e._size},i=e._root.modify(e._editable?e._edit:NaN,0,r,n,t,s);return T(e,kX(i,s.value))}),zO=x(2,(e,t)=>c$(e,t,re)),RX=x(2,(e,t)=>Zv(e,Xv(),(n,r,s)=>mg(n,s,t(r,s)))),PL=x(2,(e,t)=>Zv(e,void 0,(n,r,s)=>t(r,s))),Zv=x(3,(e,t,n)=>{const r=e._root;if(r._tag==="LeafNode")return Wt(r.value)?n(t,r.value.value,r.key):t;if(r._tag==="EmptyNode")return t;const s=[r.children];let i;for(;i=s.pop();)for(let o=0,a=i.length;o<a;){const c=i[o++];c&&!Ii(c)&&(c._tag==="LeafNode"?Wt(c.value)&&(t=n(t,c.value.value,c.key)):s.push(c.children))}return t}),OL="effect/HashSet",Ok=Symbol.for(OL),$X={[Ok]:Ok,[Symbol.iterator](){return IL(this._keyMap)},[qe](){return At(this,Oe(ce(this._keyMap))(ce(OL)))},[Me](e){return IX(e)?LS(this._keyMap)===LS(e._keyMap)&&Ne(this._keyMap,e._keyMap):!1},toString(){return qt(this.toJSON())},toJSON(){return{_id:"HashSet",values:Array.from(this).map(sn)}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},ew=e=>{const t=Object.create($X);return t._keyMap=e,t},IX=e=>_e(e,Ok),TX=ew(Xv()),tw=()=>TX,PX=e=>{const t=u$(tw());for(const n of e)yg(t,n);return f$(t)},OX=(...e)=>{const t=u$(tw());for(const n of e)yg(t,n);return f$(t)},AX=x(2,(e,t)=>EX(e._keyMap,t)),FX=e=>LS(e._keyMap),u$=e=>ew(TL(e._keyMap)),f$=e=>(e._keyMap._editable=!1,e),AL=x(2,(e,t)=>{const n=u$(e);return t(n),f$(n)}),yg=x(2,(e,t)=>e._keyMap._editable?(mg(t,!0)(e._keyMap),e):ew(mg(t,!0)(e._keyMap))),FL=x(2,(e,t)=>e._keyMap._editable?(zO(t)(e._keyMap),e):ew(zO(t)(e._keyMap))),NX=x(2,(e,t)=>AL(e,n=>{for(const r of t)FL(n,r)})),DX=x(2,(e,t)=>AL(tw(),n=>{qX(e,r=>yg(n,r));for(const r of t)yg(n,r)})),qX=x(2,(e,t)=>PL(e._keyMap,(n,r)=>t(r))),MX=x(3,(e,t,n)=>Zv(e._keyMap,t,(r,s,i)=>n(r,i))),iu=tw,LX=PX,nw=OX,rw=AX,d$=FX,Bf=yg,h$=FL,jO=NX,_g=DX,Sg=MX,UO=Symbol.for("effect/MutableRef"),zX={[UO]:UO,toString(){return qt(this.toJSON())},toJSON(){return{_id:"MutableRef",current:sn(this.current)}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},Cu=e=>{const t=Object.create(zX);return t.current=e,t},jX=x(3,(e,t,n)=>Ne(t,e.current)?(e.current=n,!0):!1),dt=e=>e.current,xu=x(2,(e,t)=>(e.current=t,e)),sw="effect/FiberId",ou=Symbol.for(sw),yd="None",Ak="Runtime",Fk="Composite",UX=tn(`${sw}-${yd}`);var $Ee;let HX=class{constructor(){p(this,$Ee,ou);p(this,"_tag",yd);p(this,"id",-1);p(this,"startTimeMillis",-1)}[($Ee=ou,qe)](){return UX}[Me](t){return g$(t)&&t._tag===yd}toString(){return qt(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag}}[ft](){return this.toJSON()}};var IEe;class p${constructor(t,n){p(this,"id");p(this,"startTimeMillis");p(this,IEe,ou);p(this,"_tag",Ak);this.id=t,this.startTimeMillis=n}[(IEe=ou,qe)](){return At(this,tn(`${sw}-${this._tag}-${this.id}-${this.startTimeMillis}`))}[Me](t){return g$(t)&&t._tag===Ak&&this.id===t.id&&this.startTimeMillis===t.startTimeMillis}toString(){return qt(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,id:this.id,startTimeMillis:this.startTimeMillis}}[ft](){return this.toJSON()}}var TEe;let NL=class{constructor(t,n){p(this,"left");p(this,"right");p(this,TEe,ou);p(this,"_tag",Fk);p(this,"_hash");this.left=t,this.right=n}[(TEe=ou,qe)](){return T(tn(`${sw}-${this._tag}`),Oe(ce(this.left)),Oe(ce(this.right)),At(this))}[Me](t){return g$(t)&&t._tag===Fk&&Ne(this.left,t.left)&&Ne(this.right,t.right)}toString(){return qt(this.toJSON())}toJSON(){return{_id:"FiberId",_tag:this._tag,left:sn(this.left),right:sn(this.right)}}[ft](){return this.toJSON()}};const DL=new HX,BX=(e,t)=>new p$(e,t),VX=(e,t)=>new NL(e,t),g$=e=>_e(e,ou),qL=x(2,(e,t)=>e._tag===yd?t:t._tag===yd?e:new NL(e,t)),WX=e=>T(e,Sg(DL,(t,n)=>qL(n)(t))),zS=e=>{switch(e._tag){case yd:return iu();case Ak:return nw(e.id);case Fk:return T(zS(e.left),_g(zS(e.right)))}},HO=We(Symbol.for("effect/Fiber/Id/_fiberCounter"),()=>Cu(0)),KX=(e,t)=>new p$(e,t),iw=e=>Array.from(zS(e)).map(n=>`#${n}`).join(","),GX=()=>{const e=dt(HO);return T(HO,xu(e+1)),new p$(e,Date.now())},Nr=DL,QX=BX,JX=VX,As=qL,YX=WX,ow=zS,m$=KX,XX=iw,ML=GX,aw=Xv,ZX=SX,eZ=wX,LL=bX,jS=mg,zL=IL,jL=LS,tZ=c$,nZ=RX,rZ=PL,UL=Zv,vg=Symbol.for("effect/List"),Nk=e=>gt(e),sZ=e=>Mq(Cm(e),Nk),iZ=sZ(Ne),oZ={[vg]:vg,_tag:"Cons",toString(){return qt(this.toJSON())},toJSON(){return{_id:"List",_tag:"Cons",values:Nk(this).map(sn)}},[ft](){return this.toJSON()},[Me](e){return BL(e)&&this._tag===e._tag&&iZ(this,e)},[qe](){return At(this,wm(Nk(this)))},[Symbol.iterator](){let e=!1,t=this;return{next(){if(e)return this.return();if(t._tag==="Nil")return e=!0,this.return();const n=t.head;return t=t.tail,{done:e,value:n}},return(n){return e||(e=!0),{done:!0,value:n}}}},pipe(){return pe(this,arguments)}},US=(e,t)=>{const n=Object.create(oZ);return n.head=e,n.tail=t,n},aZ=tn("Nil"),lZ={[vg]:vg,_tag:"Nil",toString(){return qt(this.toJSON())},toJSON(){return{_id:"List",_tag:"Nil"}},[ft](){return this.toJSON()},[qe](){return aZ},[Me](e){return BL(e)&&this._tag===e._tag},[Symbol.iterator](){return{next(){return{done:!0,value:void 0}}}},pipe(){return pe(this,arguments)}},HL=Object.create(lZ),BL=e=>_e(e,vg),ea=e=>e._tag==="Nil",y$=e=>e._tag==="Cons",cZ=()=>HL,au=(e,t)=>US(e,t),_d=cZ,_$=e=>US(e,HL),uZ=x(2,(e,t)=>dZ(t,e)),fZ=x(2,(e,t)=>au(t,e)),dZ=x(2,(e,t)=>{if(ea(e))return t;if(ea(t))return e;{const n=US(t.head,e);let r=n,s=t.tail;for(;!ea(s);){const i=US(s.head,e);r.tail=i,r=i,s=s.tail}return n}}),hZ=x(3,(e,t,n)=>{let r=t,s=e;for(;!ea(s);)r=n(r,s.head),s=s.tail;return r}),pZ=e=>{let t=_d(),n=e;for(;!ea(n);)t=fZ(t,n.head),n=n.tail;return t},Ru=function(){function e(t){t&&Object.assign(this,t)}return e.prototype=zR,e}(),gZ=Symbol.for("effect/DifferChunkPatch");function BO(e){return e}({...Ru.prototype,[gZ]:0});const mZ=Symbol.for("effect/DifferContextPatch");function VO(e){return e}const Pm={...Ru.prototype,[mZ]:{_Value:VO,_Patch:VO}},yZ=Object.assign(Object.create(Pm),{_tag:"Empty"}),_Z=Object.create(yZ),VL=()=>_Z,SZ=Object.assign(Object.create(Pm),{_tag:"AndThen"}),vZ=(e,t)=>{const n=Object.create(SZ);return n.first=e,n.second=t,n},wZ=Object.assign(Object.create(Pm),{_tag:"AddService"}),bZ=(e,t)=>{const n=Object.create(wZ);return n.key=e,n.service=t,n},EZ=Object.assign(Object.create(Pm),{_tag:"RemoveService"}),kZ=e=>{const t=Object.create(EZ);return t.key=e,t},CZ=Object.assign(Object.create(Pm),{_tag:"UpdateService"}),xZ=(e,t)=>{const n=Object.create(CZ);return n.key=e,n.update=t,n},RZ=(e,t)=>{const n=new Map(e.unsafeMap);let r=VL();for(const[s,i]of t.unsafeMap.entries())if(n.has(s)){const o=n.get(s);n.delete(s),Ne(o,i)||(r=N_(xZ(s,()=>i))(r))}else n.delete(s),r=N_(bZ(s,i))(r);for(const[s]of n.entries())r=N_(kZ(s))(r);return r},N_=x(2,(e,t)=>vZ(e,t)),$Z=x(2,(e,t)=>{if(e._tag==="Empty")return t;let n=!1,r=Xt(e);const s=new Map(t.unsafeMap);for(;vo(r);){const o=co(r),a=Ko(r);switch(o._tag){case"Empty":{r=a;break}case"AddService":{s.set(o.key,o.service),r=a;break}case"AndThen":{r=xr(xr(a,o.second),o.first);break}case"RemoveService":{s.delete(o.key),r=a;break}case"UpdateService":{s.set(o.key,o.update(s.get(o.key))),n=!0,r=a;break}}}if(!n)return eu(s);const i=new Map;for(const[o]of t.unsafeMap)s.has(o)&&(i.set(o,s.get(o)),s.delete(o));for(const[o,a]of s)i.set(o,a);return eu(i)}),IZ=Symbol.for("effect/DifferHashMapPatch");function $1(e){return e}({...Ru.prototype,[IZ]:0});const TZ=Symbol.for("effect/DifferHashSetPatch");function I1(e){return e}const lw={...Ru.prototype,[TZ]:{_Value:I1,_Key:I1,_Patch:I1}},PZ=Object.assign(Object.create(lw),{_tag:"Empty"}),OZ=Object.create(PZ),WL=()=>OZ,AZ=Object.assign(Object.create(lw),{_tag:"AndThen"}),FZ=(e,t)=>{const n=Object.create(AZ);return n.first=e,n.second=t,n},NZ=Object.assign(Object.create(lw),{_tag:"Add"}),DZ=e=>{const t=Object.create(NZ);return t.value=e,t},qZ=Object.assign(Object.create(lw),{_tag:"Remove"}),MZ=e=>{const t=Object.create(qZ);return t.value=e,t},LZ=(e,t)=>{const[n,r]=Sg([e,WL()],([s,i],o)=>rw(o)(s)?[h$(o)(s),i]:[s,Dk(DZ(o))(i)])(t);return Sg(r,(s,i)=>Dk(MZ(i))(s))(n)},Dk=x(2,(e,t)=>FZ(e,t)),zZ=x(2,(e,t)=>{if(e._tag==="Empty")return t;let n=t,r=Xt(e);for(;vo(r);){const s=co(r),i=Ko(r);switch(s._tag){case"Empty":{r=i;break}case"AndThen":{r=xr(s.first)(xr(s.second)(i));break}case"Add":{n=Bf(s.value)(n),r=i;break}case"Remove":n=h$(s.value)(n),r=i}}return n}),jZ=Symbol.for("effect/DifferOrPatch");function T1(e){return e}({...Ru.prototype,[jZ]:0});const UZ=Symbol.for("effect/DifferReadonlyArrayPatch");function WO(e){return e}const Om={...Ru.prototype,[UZ]:{_Value:WO,_Patch:WO}},HZ=Object.assign(Object.create(Om),{_tag:"Empty"}),BZ=Object.create(HZ),KL=()=>BZ,VZ=Object.assign(Object.create(Om),{_tag:"AndThen"}),WZ=(e,t)=>{const n=Object.create(VZ);return n.first=e,n.second=t,n},KZ=Object.assign(Object.create(Om),{_tag:"Append"}),GZ=e=>{const t=Object.create(KZ);return t.values=e,t},QZ=Object.assign(Object.create(Om),{_tag:"Slice"}),JZ=(e,t)=>{const n=Object.create(QZ);return n.from=e,n.until=t,n},YZ=Object.assign(Object.create(Om),{_tag:"Update"}),XZ=(e,t)=>{const n=Object.create(YZ);return n.index=e,n.patch=t,n},ZZ=e=>{let t=0,n=KL();for(;t<e.oldValue.length&&t<e.newValue.length;){const r=e.oldValue[t],s=e.newValue[t],i=e.differ.diff(r,s);Ne(i,e.differ.empty)||(n=D_(n,XZ(t,i))),t=t+1}return t<e.oldValue.length&&(n=D_(n,JZ(0,t))),t<e.newValue.length&&(n=D_(n,GZ(nJ(t)(e.newValue)))),n},D_=x(2,(e,t)=>WZ(e,t)),eee=x(3,(e,t,n)=>{if(e._tag==="Empty")return t;let r=t.slice(),s=$s(e);for(;T_(s);){const i=Kr(s),o=Yc(s);switch(i._tag){case"Empty":{s=o;break}case"AndThen":{o.unshift(i.first,i.second),s=o;break}case"Append":{for(const a of i.values)r.push(a);s=o;break}case"Slice":{r=r.slice(i.from,i.until),s=o;break}case"Update":{r[i.index]=n.patch(i.patch,r[i.index]),s=o;break}}}return r}),tee=Symbol.for("effect/Differ"),nee={[tee]:{_P:Ce,_V:Ce},pipe(){return pe(this,arguments)}},eh=e=>{const t=Object.create(nee);return t.empty=e.empty,t.diff=e.diff,t.combine=e.combine,t.patch=e.patch,t},ree=()=>eh({empty:VL(),combine:(e,t)=>N_(t)(e),diff:(e,t)=>RZ(e,t),patch:(e,t)=>$Z(t)(e)}),see=()=>eh({empty:WL(),combine:(e,t)=>Dk(t)(e),diff:(e,t)=>LZ(e,t),patch:(e,t)=>zZ(t)(e)}),iee=e=>eh({empty:KL(),combine:(t,n)=>D_(t,n),diff:(t,n)=>ZZ({oldValue:t,newValue:n,differ:e}),patch:(t,n)=>eee(t,n,e)}),GL=()=>oee((e,t)=>t),oee=e=>eh({empty:Ce,combine:(t,n)=>t===Ce?n:n===Ce?t:r=>n(t(r)),diff:(t,n)=>Ne(t,n)?Ce:Rv(n),patch:(t,n)=>e(n,t(n))}),wg=255,QL=8,qk=e=>e&wg,Mk=e=>e>>QL&wg,Am=(e,t)=>(e&wg)+((t&e&wg)<<QL),aee=Am(0,0),lee=e=>Am(e,e),cee=e=>Am(e,0),uee=x(2,(e,t)=>Am(qk(e)&~t,Mk(e))),fee=x(2,(e,t)=>e|t),dee=e=>~e>>>0&wg,hee=0,th=1,pee=2,JL=4,Lk=16,YL=32,gee=e=>cw(e,YL),mee=x(2,(e,t)=>e|t),ja=e=>XL(e)&&!_ee(e),XL=e=>cw(e,th),cw=x(2,(e,t)=>(e&t)!==0),ZL=(...e)=>e.reduce((t,n)=>t|n,0),yee=ZL(hee),KO=e=>cw(e,JL),_ee=e=>cw(e,Lk),pl=x(2,(e,t)=>Am(e^t,t)),Vf=x(2,(e,t)=>e&(dee(qk(t))|Mk(t))|qk(t)&Mk(t)),GO=eh({empty:aee,diff:(e,t)=>pl(e,t),combine:(e,t)=>fee(t)(e),patch:(e,t)=>Vf(t,e)}),See=lee,ez=cee,QO=uee,tz=(e,t)=>({_tag:"Par",left:e,right:t}),Yy=(e,t)=>({_tag:"Seq",left:e,right:t}),vee=e=>{let t=_$(e),n=_d();for(;;){const[r,s]=hZ(t,[nz(),_d()],([i,o],a)=>{const[c,f]=wee(a);return[xee(i,c),uZ(o,f)]});if(n=bee(n,r),ea(s))return pZ(n);t=s}throw new Error("BUG: BlockedRequests.flatten - please report an issue at https://github.com/Effect-TS/effect/issues")},wee=e=>{let t=e,n=nz(),r=_d(),s=_d();for(;;)switch(t._tag){case"Empty":{if(ea(r))return[n,s];t=r.head,r=r.tail;break}case"Par":{r=au(t.right,r),t=t.left;break}case"Seq":{const i=t.left,o=t.right;switch(i._tag){case"Empty":{t=o;break}case"Par":{const a=i.left,c=i.right;t=tz(Yy(a,o),Yy(c,o));break}case"Seq":{const a=i.left,c=i.right;t=Yy(a,Yy(c,o));break}case"Single":{t=i,s=au(o,s);break}}break}case"Single":{if(n=Cee(n,t),ea(r))return[n,s];t=r.head,r=r.tail;break}}throw new Error("BUG: BlockedRequests.step - please report an issue at https://github.com/Effect-TS/effect/issues")},bee=(e,t)=>{if(ea(e))return _$(P1(t));if(Ree(t))return e;const n=Aee(e.head),r=$ee(t);return n.length===1&&r.length===1&&Ne(n[0],r[0])?au(Oee(e.head,P1(t)),e.tail):au(P1(t),e)},Eee=Symbol.for("effect/RequestBlock/RequestBlockParallel"),kee={_R:e=>e};var PEe;class S${constructor(t){p(this,"map");p(this,PEe,kee);this.map=t}}PEe=Eee;const nz=()=>new S$(aw()),Cee=(e,t)=>new S$(tZ(e.map,t.dataSource,n=>RQ(hl(n,gg(t.blockedRequest)),()=>Xt(t.blockedRequest)))),xee=(e,t)=>new S$(UL(e.map,t.map,(n,r,s)=>jS(n,s,bt(LL(n,s),{onNone:()=>r,onSome:i=>nn(r,i)})))),Ree=e=>eZ(e.map),$ee=e=>Array.from(zL(e.map)),P1=e=>Pee(nZ(e.map,t=>Xt(t))),Iee=Symbol.for("effect/RequestBlock/RequestBlockSequential"),Tee={_R:e=>e};var OEe;class rz{constructor(t){p(this,"map");p(this,OEe,Tee);this.map=t}}OEe=Iee;const Pee=e=>new rz(e),Oee=(e,t)=>new rz(UL(t.map,e.map,(n,r,s)=>jS(n,s,bt(LL(n,s),{onNone:()=>Ut(),onSome:i=>nn(i,r)})))),Aee=e=>Array.from(zL(e.map)),Fee=e=>Array.from(e.map),nh="Die",lu="Empty",$u="Fail",rh="Interrupt",Sd="Parallel",vd="Sequential",sz="effect/Cause",iz=Symbol.for(sz),Nee={_E:e=>e},sh={[iz]:Nee,[qe](){return T(ce(sz),Oe(ce(Vee(this))),At(this))},[Me](e){return v$(e)&&Bee(this,e)},pipe(){return pe(this,arguments)},toJSON(){switch(this._tag){case"Empty":return{_id:"Cause",_tag:this._tag};case"Die":return{_id:"Cause",_tag:this._tag,defect:sn(this.defect)};case"Interrupt":return{_id:"Cause",_tag:this._tag,fiberId:this.fiberId.toJSON()};case"Fail":return{_id:"Cause",_tag:this._tag,failure:sn(this.error)};case"Sequential":case"Parallel":return{_id:"Cause",_tag:this._tag,left:sn(this.left),right:sn(this.right)}}},toString(){return Bl(this)},[ft](){return this.toJSON()}},pa=(()=>{const e=Object.create(sh);return e._tag=lu,e})(),cu=e=>{const t=Object.create(sh);return t._tag=$u,t.error=e,t},Gr=e=>{const t=Object.create(sh);return t._tag=nh,t.defect=e,t},ri=e=>{const t=Object.create(sh);return t._tag=rh,t.fiberId=e,t},ga=(e,t)=>{const n=Object.create(sh);return n._tag=Sd,n.left=e,n.right=t,n},zn=(e,t)=>{const n=Object.create(sh);return n._tag=vd,n.left=e,n.right=t,n},v$=e=>_e(e,iz),Dee=e=>e._tag===lu,qee=e=>e._tag===$u,w$=e=>e._tag===nh,b$=e=>e._tag===lu?!0:wd(e,!0,(t,n)=>{switch(n._tag){case lu:return oe(t);case nh:case $u:case rh:return oe(!1);default:return re()}}),E$=e=>Wt(zee(e)),uw=e=>hw(void 0,Kee)(e),Mee=e=>ha(wd(e,Ut(),(t,n)=>n._tag===$u?oe(T(t,xr(n.error))):re())),oz=e=>ha(wd(e,Ut(),(t,n)=>n._tag===nh?oe(T(t,xr(n.defect))):re())),k$=e=>wd(e,iu(),(t,n)=>n._tag===rh?oe(T(t,Bf(n.fiberId))):re()),az=e=>fw(e,t=>t._tag===$u?oe(t.error):re()),C$=e=>{const t=az(e);switch(t._tag){case"None":return Pe(e);case"Some":return $e(t.value)}},Lee=e=>dw(e,{onEmpty:oe(pa),onFail:hl(cu),onDie:t=>oe(Gr(t)),onInterrupt:t=>oe(ri(t)),onSequential:EO(zn),onParallel:EO(ga)}),zee=e=>fw(e,t=>t._tag===rh?oe(t.fiberId):re()),JO=e=>dw(e,{onEmpty:pa,onFail:()=>pa,onDie:Gr,onInterrupt:ri,onSequential:zn,onParallel:ga}),jee=e=>dw(e,{onEmpty:pa,onFail:Gr,onDie:Gr,onInterrupt:ri,onSequential:zn,onParallel:ga}),Uee=x(2,(e,t)=>Hee(e,n=>cu(t(n)))),Hee=x(2,(e,t)=>dw(e,{onEmpty:pa,onFail:n=>t(n),onDie:n=>Gr(n),onInterrupt:n=>ri(n),onSequential:(n,r)=>zn(n,r),onParallel:(n,r)=>ga(n,r)})),Bee=(e,t)=>{let n=Xt(e),r=Xt(t);for(;vo(n)&&vo(r);){const[s,i]=T(co(n),wd([iu(),Ut()],([c,f],d)=>{const[g,_]=zk(d);return oe([T(c,_g(g)),T(f,nn(_))])})),[o,a]=T(co(r),wd([iu(),Ut()],([c,f],d)=>{const[g,_]=zk(d);return oe([T(c,_g(g)),T(f,nn(_))])}));if(!Ne(s,o))return!1;n=i,r=a}return!0},Vee=e=>Wee(Xt(e),Ut()),Wee=(e,t)=>{for(;;){const[n,r]=T(e,WR([iu(),Ut()],([i,o],a)=>{const[c,f]=zk(a);return[T(i,_g(c)),T(o,nn(f))]})),s=d$(n)>0?T(t,xr(n)):t;if(Tm(r))return ha(s);e=r,t=s}throw new Error(Tv("Cause.flattenCauseLoop"))},fw=x(2,(e,t)=>{const n=[e];for(;n.length>0;){const r=n.pop(),s=t(r);switch(s._tag){case"None":{switch(r._tag){case vd:case Sd:{n.push(r.right),n.push(r.left);break}}break}case"Some":return s}}return re()}),zk=e=>{let t=e;const n=[];let r=iu(),s=Ut();for(;t!==void 0;)switch(t._tag){case lu:{if(n.length===0)return[r,s];t=n.pop();break}case $u:{if(r=Bf(r,R1(t._tag,t.error)),n.length===0)return[r,s];t=n.pop();break}case nh:{if(r=Bf(r,R1(t._tag,t.defect)),n.length===0)return[r,s];t=n.pop();break}case rh:{if(r=Bf(r,R1(t._tag,t.fiberId)),n.length===0)return[r,s];t=n.pop();break}case vd:{switch(t.left._tag){case lu:{t=t.right;break}case vd:{t=zn(t.left.left,zn(t.left.right,t.right));break}case Sd:{t=ga(zn(t.left.left,t.right),zn(t.left.right,t.right));break}default:{s=xr(s,t.right),t=t.left;break}}break}case Sd:{n.push(t.right),t=t.left;break}}throw new Error(Tv("Cause.evaluateCauseLoop"))},Kee={emptyCase:wO,failCase:ds,dieCase:ds,interruptCase:wO,sequentialCase:(e,t,n)=>t&&n,parallelCase:(e,t,n)=>t&&n},YO="SequentialCase",XO="ParallelCase",dw=x(2,(e,{onDie:t,onEmpty:n,onFail:r,onInterrupt:s,onParallel:i,onSequential:o})=>hw(e,void 0,{emptyCase:()=>n,failCase:(a,c)=>r(c),dieCase:(a,c)=>t(c),interruptCase:(a,c)=>s(c),sequentialCase:(a,c,f)=>o(c,f),parallelCase:(a,c,f)=>i(c,f)})),wd=x(3,(e,t,n)=>{let r=t,s=e;const i=[];for(;s!==void 0;){const o=n(r,s);switch(r=Wt(o)?o.value:r,s._tag){case vd:{i.push(s.right),s=s.left;break}case Sd:{i.push(s.right),s=s.left;break}default:{s=void 0;break}}s===void 0&&i.length>0&&(s=i.pop())}return r}),hw=x(3,(e,t,n)=>{const r=[e],s=[];for(;r.length>0;){const o=r.pop();switch(o._tag){case lu:{s.push(Pe(n.emptyCase(t)));break}case $u:{s.push(Pe(n.failCase(t,o.error)));break}case nh:{s.push(Pe(n.dieCase(t,o.defect)));break}case rh:{s.push(Pe(n.interruptCase(t,o.fiberId)));break}case vd:{r.push(o.right),r.push(o.left),s.push($e({_tag:YO}));break}case Sd:{r.push(o.right),r.push(o.left),s.push($e({_tag:XO}));break}}}const i=[];for(;s.length>0;){const o=s.pop();switch(o._tag){case"Left":{switch(o.left._tag){case YO:{const a=i.pop(),c=i.pop(),f=n.sequentialCase(t,a,c);i.push(f);break}case XO:{const a=i.pop(),c=i.pop(),f=n.parallelCase(t,a,c);i.push(f);break}}break}case"Right":{i.push(o.right);break}}}if(i.length===0)throw new Error("BUG: Cause.reduceWithContext - please report an issue at https://github.com/Effect-TS/effect/issues");return i.pop()}),Bl=(e,t)=>uw(e)?"All fibers interrupted without errors.":x$(e).map(function(n){return(t==null?void 0:t.renderErrorCause)!==!0||n.cause===void 0?n.stack:`${n.stack} {
181
+ ${lz(n.cause," ")}
182
+ }`}).join(`
183
+ `),lz=(e,t)=>{const n=e.stack.split(`
184
+ `);let r=`${t}[cause]: ${n[0]}`;for(let s=1,i=n.length;s<i;s++)r+=`
185
+ ${t}${n[s]}`;return e.cause&&(r+=` {
186
+ ${lz(e.cause,`${t} `)}
187
+ ${t}}`),r};class HS extends globalThis.Error{constructor(n){const r=typeof n=="object"&&n!==null,s=Error.stackTraceLimit;Error.stackTraceLimit=1;super(cz(n),r&&"cause"in n&&typeof n.cause<"u"?{cause:new HS(n.cause)}:void 0);p(this,"span");this.message===""&&(this.message="An error has occurred"),Error.stackTraceLimit=s,this.name=n instanceof Error?n.name:"Error",r&&(bd in n&&(this.span=n[bd]),Object.keys(n).forEach(i=>{i in this||(this[i]=n[i])})),this.stack=Qee(`${this.name}: ${this.message}`,n instanceof Error&&n.stack?n.stack:"",this.span)}}const cz=e=>{if(typeof e=="string")return e;if(typeof e=="object"&&e!==null&&e instanceof Error)return e.message;try{if(_e(e,"toString")&&Qd(e.toString)&&e.toString!==Object.prototype.toString&&e.toString!==globalThis.Array.prototype.toString)return e.toString()}catch{}return Kq(e)},Gee=/\((.*)\)/g,BS=We("effect/Tracer/spanToTrace",()=>new WeakMap),Qee=(e,t,n)=>{const r=[e],s=t.startsWith(e)?t.slice(e.length).split(`
188
+ `):t.split(`
189
+ `);for(let i=1;i<s.length;i++){if(s[i].includes(" at new BaseEffectError")||s[i].includes(" at new YieldableError")){i++;continue}if(s[i].includes("Generator.next")||s[i].includes("effect_internal_function"))break;r.push(s[i].replace(/at .*effect_instruction_i.*\((.*)\)/,"at $1").replace(/EffectPrimitive\.\w+/,"<anonymous>"))}if(n){let i=n,o=0;for(;i&&i._tag==="Span"&&o<10;){const a=BS.get(i);if(typeof a=="function"){const c=a();if(typeof c=="string"){const f=c.matchAll(Gee);let d=!1;for(const[,g]of f)d=!0,r.push(` at ${i.name} (${g})`);d||r.push(` at ${i.name} (${c.replace(/^at /,"")})`)}else r.push(` at ${i.name}`)}else r.push(` at ${i.name}`);i=ti(i.parent),o++}}return r.join(`
190
+ `)},bd=Symbol.for("effect/SpanAnnotation"),x$=e=>hw(e,void 0,{emptyCase:()=>[],dieCase:(t,n)=>[new HS(n)],failCase:(t,n)=>[new HS(n)],interruptCase:()=>[],parallelCase:(t,n,r)=>[...n,...r],sequentialCase:(t,n,r)=>[...n,...r]}),Fm="Pending",pw="Done",Jee="effect/Deferred",uz=Symbol.for(Jee),Yee={_E:e=>e,_A:e=>e},Xee=e=>({_tag:Fm,joiners:e}),fz=e=>({_tag:pw,effect:e});class ih{constructor(t){p(this,"self");p(this,"called",!1);this.self=t}next(t){return this.called?{value:t,done:!0}:(this.called=!0,{value:this.self,done:!1})}return(t){return{value:t,done:!0}}throw(t){throw t}[Symbol.iterator](){return new ih(this.self)}}const dz=(e,t)=>{const n=new Vn("Blocked");return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n},Zee=e=>{const t=new Vn("RunBlocked");return t.effect_instruction_i0=e,t},uu=Symbol.for("effect/Effect");class ete{constructor(t,n){p(this,"patch");p(this,"op");p(this,"_op",LR);this.patch=t,this.op=n}}var AEe;class Vn{constructor(t){p(this,"_op");p(this,"effect_instruction_i0");p(this,"effect_instruction_i1");p(this,"effect_instruction_i2");p(this,"trace");p(this,AEe,Jc);this._op=t}[(AEe=uu,Me)](t){return this===t}[qe](){return At(this,Pv(this))}pipe(){return pe(this,arguments)}toJSON(){return{_id:"Effect",_op:this._op,effect_instruction_i0:sn(this.effect_instruction_i0),effect_instruction_i1:sn(this.effect_instruction_i1),effect_instruction_i2:sn(this.effect_instruction_i2)}}toString(){return qt(this.toJSON())}[ft](){return this.toJSON()}[Symbol.iterator](){return new ih(new Jd(this))}}var FEe;class hz{constructor(t){p(this,"_op");p(this,"effect_instruction_i0");p(this,"effect_instruction_i1");p(this,"effect_instruction_i2");p(this,"trace");p(this,FEe,Jc);this._op=t,this._tag=t}[(FEe=uu,Me)](t){return vw(t)&&t._op==="Failure"&&Ne(this.effect_instruction_i0,t.effect_instruction_i0)}[qe](){return T(tn(this._tag),Oe(ce(this.effect_instruction_i0)),At(this))}get cause(){return this.effect_instruction_i0}pipe(){return pe(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,cause:this.cause.toJSON()}}toString(){return qt(this.toJSON())}[ft](){return this.toJSON()}[Symbol.iterator](){return new ih(new Jd(this))}}var NEe;class pz{constructor(t){p(this,"_op");p(this,"effect_instruction_i0");p(this,"effect_instruction_i1");p(this,"effect_instruction_i2");p(this,"trace");p(this,NEe,Jc);this._op=t,this._tag=t}[(NEe=uu,Me)](t){return vw(t)&&t._op==="Success"&&Ne(this.effect_instruction_i0,t.effect_instruction_i0)}[qe](){return T(tn(this._tag),Oe(ce(this.effect_instruction_i0)),At(this))}get value(){return this.effect_instruction_i0}pipe(){return pe(this,arguments)}toJSON(){return{_id:"Exit",_tag:this._op,value:sn(this.value)}}toString(){return qt(this.toJSON())}[ft](){return this.toJSON()}[Symbol.iterator](){return new ih(new Jd(this))}}const Bs=e=>_e(e,uu),et=e=>{const t=new Vn(Jq);return t.effect_instruction_i0=e,t},R$=x(3,(e,t,n)=>Yr(r=>Z(e,s=>Z(Fi(Ee(()=>r(t(s)))),i=>Ee(()=>n(s,i)).pipe(ys({onFailure:o=>{switch(i._tag){case tr:return fn(zn(i.effect_instruction_i0,o));case nr:return fn(o)}},onSuccess:()=>i})))))),Tn=x(2,(e,t)=>Z(e,()=>ie(t))),vs=e=>Tn(e,void 0),gz=function(){const e=new Vn(bm);switch(arguments.length){case 2:{e.effect_instruction_i0=arguments[0],e.commit=arguments[1];break}case 3:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.commit=arguments[2];break}case 4:{e.effect_instruction_i0=arguments[0],e.effect_instruction_i1=arguments[1],e.effect_instruction_i2=arguments[2],e.commit=arguments[3];break}default:throw new Error(Tv("you're not supposed to end up here"))}return e},bg=(e,t=Nr)=>{const n=new Vn(Ip);let r;return n.effect_instruction_i0=s=>{r=e(s)},n.effect_instruction_i1=t,Vl(n,s=>Bs(r)?r:Ve)},Xa=(e,t=Nr)=>Ee(()=>bg(e,t)),Mi=(e,t=Nr)=>gz(e,function(){let n,r;function s(c){n?n(c):r===void 0&&(r=c)}const i=new Vn(Ip);i.effect_instruction_i0=c=>{n=c,r&&c(r)},i.effect_instruction_i1=t;let o,a;return this.effect_instruction_i0.length!==1?(a=new AbortController,o=Bt(()=>this.effect_instruction_i0(s,a.signal))):o=Bt(()=>this.effect_instruction_i0(s)),o||a?Vl(i,c=>(a&&a.abort(),o??Ve)):i}),Nm=x(2,(e,t)=>{const n=new Vn($_);return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n}),Ed=x(2,(e,t)=>wo(e,{onFailure:t,onSuccess:ie})),tte=x(3,(e,t,n)=>Nm(e,r=>{const s=C$(r);switch(s._tag){case"Left":return t(s.left)?n(s.left):fn(r);case"Right":return fn(s.right)}})),ZO=Symbol.for("effect/OriginalAnnotation"),$$=(e,t)=>Wt(t)?new Proxy(e,{has(n,r){return r===bd||r===ZO||r in n},get(n,r){return r===bd?t.value:r===ZO?e:n[r]}}):e,Eg=e=>xo(e)&&!(bd in e)?et(t=>fn(Gr($$(e,B$(t))))):fn(Gr(e)),jk=e=>mz(()=>Gr(new Fte(e))),kd=e=>wo(e,{onFailure:t=>ie($e(t)),onSuccess:t=>ie(Pe(t))}),Fi=e=>yz(e,{onFailure:xt,onSuccess:St}),Gt=e=>xo(e)&&!(bd in e)?et(t=>fn(cu($$(e,B$(t))))):fn(cu(e)),Dm=e=>Z(se(e),Gt),fn=e=>{const t=new hz(tr);return t.effect_instruction_i0=e,t},mz=e=>Z(se(e),fn),qm=et(e=>ie(e.id())),Iu=e=>et(t=>e(t.id())),Z=x(2,(e,t)=>{const n=new Vn(xS);return n.effect_instruction_i0=e,n.effect_instruction_i1=t,n}),nte=x(2,(e,t)=>Z(e,n=>{const r=typeof t=="function"?t(n):t;return Bs(r)?r:zq(r)?bg(s=>{r.then(i=>s(ie(i)),i=>s(Gt(new Sw(i,"An unknown error occurred in Effect.andThen"))))}):ie(r)})),rte=e=>{const t=new Vn("OnStep");return t.effect_instruction_i0=e,t},oh=e=>Z(e,Ce),yz=x(2,(e,t)=>ys(e,{onFailure:n=>ie(t.onFailure(n)),onSuccess:n=>ie(t.onSuccess(n))})),ys=x(2,(e,t)=>{const n=new Vn(RS);return n.effect_instruction_i0=e,n.effect_instruction_i1=t.onFailure,n.effect_instruction_i2=t.onSuccess,n}),wo=x(2,(e,t)=>ys(e,{onFailure:n=>{if(oz(n).length>0)return fn(jee(n));const s=Mee(n);return s.length>0?t.onFailure(Gv(s)):fn(n)},onSuccess:t.onSuccess})),Go=x(2,(e,t)=>Ee(()=>{const n=gt(e),r=Nv(n.length);let s=0;return Tn(A$({while:()=>s<n.length,body:()=>t(n[s],s),step:i=>{r[s++]=i}}),r)})),fu=x(2,(e,t)=>Ee(()=>{const n=gt(e);let r=0;return A$({while:()=>r<n.length,body:()=>t(n[r],r),step:()=>{r++}})})),Pn=Z(qm,e=>I$(e)),I$=e=>fn(ri(e)),Cd=e=>{const t=new Vn(Yd);return t.effect_instruction_i0=See(th),t.effect_instruction_i1=()=>e,t},T$=x(2,(e,t)=>Yr(n=>Z(Fi(n(e)),r=>Tz(t,r)))),Fe=x(2,(e,t)=>Z(e,n=>se(()=>t(n)))),P$=x(2,(e,t)=>wo(e,{onFailure:n=>Dm(()=>t.onFailure(n)),onSuccess:n=>se(()=>t.onSuccess(n))})),gw=x(2,(e,t)=>ys(e,{onFailure:n=>{const r=C$(n);switch(r._tag){case"Left":return Dm(()=>t(r.left));case"Right":return fn(r.right)}},onSuccess:ie})),ste=x(2,(e,t)=>ma(e,n=>$z(n)?Ve:t(n.effect_instruction_i0))),ma=x(2,(e,t)=>Yr(n=>ys(n(e),{onFailure:r=>{const s=xt(r);return ys(t(s),{onFailure:i=>xt(zn(r,i)),onSuccess:()=>s})},onSuccess:r=>{const s=St(r);return kt(t(s),s)}}))),Vl=x(2,(e,t)=>ma(e,ww({onFailure:n=>uw(n)?vs(t(k$(n))):Ve,onSuccess:()=>Ve}))),O$=e=>ite(e,Ce),ite=x(2,(e,t)=>wo(e,{onFailure:n=>Eg(t(n)),onSuccess:ie})),ote=et((e,t)=>ie(t.runtimeFlags)),ie=e=>{const t=new pz(nr);return t.effect_instruction_i0=e,t},Ee=e=>{const t=new Vn(bm);return t.commit=e,t},se=e=>{const t=new Vn(Qq);return t.effect_instruction_i0=e,t},ya=x(e=>e.length===3||e.length===2&&!(xo(e[1])&&"onlyEffect"in e[1]),(e,t)=>Z(e,n=>{const r=typeof t=="function"?t(n):t;return Bs(r)?Tn(r,n):zq(r)?bg(s=>{r.then(i=>s(ie(n)),i=>s(Gt(new Sw(i,"An unknown error occurred in Effect.tap"))))}):ie(n)})),ate=e=>et(t=>{const n=t.getFiberRef(Hk),r=T(n,Yt(()=>t.scope()));return e(Tu(Hk,oe(r)))}),Ra=e=>{const t=new Vn(Yd);return t.effect_instruction_i0=ez(th),t.effect_instruction_i1=()=>e,t},Yr=e=>gz(e,function(){const t=new Vn(Yd);return t.effect_instruction_i0=ez(th),t.effect_instruction_i1=n=>XL(n)?Bt(()=>this.effect_instruction_i0(Cd)):Bt(()=>this.effect_instruction_i0(Ra)),t}),Ve=ie(void 0),_z=e=>{const t=new Vn(Yd);return t.effect_instruction_i0=e,t.effect_instruction_i1=void 0,t},Mm=x(2,(e,t)=>Z(t,n=>n?T(e,Fe(oe)):ie(re()))),A$=e=>{const t=new Vn($S);return t.effect_instruction_i0=e.while,t.effect_instruction_i1=e.body,t.effect_instruction_i2=e.step,t},VS=e=>Ee(()=>{const t=new Vn(Tp);return t.effect_instruction_i0=e(),t}),lte=function(){const e=arguments.length===1?arguments[0]:arguments[1].bind(arguments[0]);return VS(()=>e(T))},cte=(e,...t)=>Object.defineProperty(t.length===0?function(...n){return VS(()=>e.apply(this,n))}:function(...n){let r=VS(()=>e.apply(this,n));for(const s of t)r=s(r,...n);return r},"length",{value:e.length,configurable:!0}),ute=x(2,(e,t)=>{const n=new Vn(Yd);return n.effect_instruction_i0=t,n.effect_instruction_i1=()=>e,n}),Lm=e=>{const t=new Vn(I_);return typeof(e==null?void 0:e.priority)<"u"?xte(t,e.priority):t},mw=x(2,(e,t)=>Z(e,n=>Fe(t,r=>[n,r]))),gl=x(2,(e,t)=>Z(e,n=>Tn(t,n))),kt=x(2,(e,t)=>Z(e,()=>t)),Sz=x(3,(e,t,n)=>Z(e,r=>Fe(t,s=>n(r,s)))),q_=Xa(()=>{const e=setInterval(()=>{},2147483647);return se(()=>clearInterval(e))}),kg=e=>Z(qm,t=>T(e,Qo(t))),Qo=x(2,(e,t)=>Z(e.interruptAsFork(t),()=>e.await)),fte={_tag:"All",syslog:0,label:"ALL",ordinal:Number.MIN_SAFE_INTEGER,pipe(){return pe(this,arguments)}},dte={_tag:"Fatal",syslog:2,label:"FATAL",ordinal:5e4,pipe(){return pe(this,arguments)}},hte={_tag:"Error",syslog:3,label:"ERROR",ordinal:4e4,pipe(){return pe(this,arguments)}},pte={_tag:"Warning",syslog:4,label:"WARN",ordinal:3e4,pipe(){return pe(this,arguments)}},vz={_tag:"Info",syslog:6,label:"INFO",ordinal:2e4,pipe(){return pe(this,arguments)}},wz={_tag:"Debug",syslog:7,label:"DEBUG",ordinal:1e4,pipe(){return pe(this,arguments)}},gte={_tag:"Trace",syslog:7,label:"TRACE",ordinal:0,pipe(){return pe(this,arguments)}},mte={_tag:"None",syslog:7,label:"OFF",ordinal:Number.MAX_SAFE_INTEGER,pipe(){return pe(this,arguments)}},yte="effect/FiberRef",_te=Symbol.for(yte),Ste={_A:e=>e},yw=e=>et(t=>St(t.getFiberRef(e))),ah=x(2,(e,t)=>Z(yw(e),t)),WS=x(2,(e,t)=>vte(e,()=>[void 0,t])),vte=x(2,(e,t)=>et(n=>{const[r,s]=t(n.getFiberRef(e));return n.setFiberRef(e,s),ie(r)})),Tu=x(3,(e,t,n)=>R$(gl(yw(t),WS(t,n)),()=>e,r=>WS(t,r))),F$=x(3,(e,t,n)=>ah(t,r=>Tu(e,t,n(r)))),yr=(e,t)=>lh(e,{differ:GL(),fork:(t==null?void 0:t.fork)??Ce,join:t==null?void 0:t.join}),wte=e=>{const t=see();return lh(e,{differ:t,fork:t.empty})},bte=e=>{const t=iee(GL());return lh(e,{differ:t,fork:t.empty})},bz=e=>{const t=ree();return lh(e,{differ:t,fork:t.empty})},lh=(e,t)=>({...ka,[_te]:Ste,initial:e,commit(){return yw(this)},diff:(r,s)=>t.differ.diff(r,s),combine:(r,s)=>t.differ.combine(r,s),patch:r=>s=>t.differ.patch(r,s),fork:t.fork,join:t.join??((r,s)=>s)}),Ete=e=>lh(e,{differ:GO,fork:GO.empty}),Hi=We(Symbol.for("effect/FiberRef/currentContext"),()=>bz(tu())),Pu=We(Symbol.for("effect/FiberRef/currentSchedulingPriority"),()=>yr(0)),Ez=We(Symbol.for("effect/FiberRef/currentMaxOpsBeforeYield"),()=>yr(2048)),kz=We(Symbol.for("effect/FiberRef/currentLogAnnotation"),()=>yr(aw())),kte=We(Symbol.for("effect/FiberRef/currentLogLevel"),()=>yr(vz)),Cte=We(Symbol.for("effect/FiberRef/currentLogSpan"),()=>yr(_d())),xte=x(2,(e,t)=>Tu(e,Pu,t)),Rte=We(Symbol.for("effect/FiberRef/currentConcurrency"),()=>yr("unbounded")),$te=We(Symbol.for("effect/FiberRef/currentRequestBatching"),()=>yr(!0)),N$=We(Symbol.for("effect/FiberRef/currentUnhandledErrorLogLevel"),()=>yr(oe(wz))),Ite=x(2,(e,t)=>Tu(e,N$,t)),Uk=We(Symbol.for("effect/FiberRef/currentMetricLabels"),()=>bte(bl())),Hk=We(Symbol.for("effect/FiberRef/currentForkScopeOverride"),()=>yr(re(),{fork:()=>re(),join:(e,t)=>e})),Xy=We(Symbol.for("effect/FiberRef/currentInterruptedCause"),()=>yr(pa,{fork:()=>pa,join:(e,t)=>e})),Cz=We(Symbol.for("effect/FiberRef/currentTracerEnabled"),()=>yr(!0)),D$=We(Symbol.for("effect/FiberRef/currentTracerTiming"),()=>yr(!0)),Tte=We(Symbol.for("effect/FiberRef/currentTracerSpanAnnotations"),()=>yr(aw())),Pte=We(Symbol.for("effect/FiberRef/currentTracerSpanLinks"),()=>yr(Ut())),eA=Symbol.for("effect/Scope"),tA=Symbol.for("effect/CloseableScope"),xz=(e,t)=>e.addFinalizer(()=>vs(t)),Cg=(e,t)=>e.addFinalizer(t),Bk=(e,t)=>e.close(t),_w=(e,t)=>e.fork(t),Ote=e=>Ate(Ce)(e),Ate=x(2,(e,t)=>{const n=T(e,az,hl(t));switch(n._tag){case"None":return T(oz(e),Kv,bt({onNone:()=>{const r=gt(k$(e)).flatMap(s=>gt(ow(s)).map(i=>`#${i}`));return new Nte(r?`Interrupted by fibers: ${r.join(", ")}`:void 0)},onSome:Ce}));case"Some":return n.value}}),q$=function(){class e extends globalThis.Error{commit(){return Gt(this)}toJSON(){const n={...this};return this.message&&(n.message=this.message),this.cause&&(n.cause=this.cause),n}[ft](){return this.toString!==globalThis.Error.prototype.toString?this.stack?`${this.toString()}
191
+ ${this.stack.split(`
192
+ `).slice(1).join(`
193
+ `)}`:this.toString():"Bun"in globalThis?Bl(cu(this),{renderErrorCause:!0}):this}}return Object.assign(e.prototype,uQ),e}(),zm=(e,t)=>{class n extends q${constructor(){super(...arguments);p(this,"_tag",t)}}return Object.assign(n.prototype,e),n.prototype.name=t,n},nA=Symbol.for("effect/Cause/errors/RuntimeException"),Fte=zm({[nA]:nA},"RuntimeException"),Vk=Symbol.for("effect/Cause/errors/InterruptedException"),Nte=zm({[Vk]:Vk},"InterruptedException"),Dte=e=>_e(e,Vk),rA=Symbol.for("effect/Cause/errors/IllegalArgument"),qte=zm({[rA]:rA},"IllegalArgumentException"),sA=Symbol.for("effect/Cause/errors/NoSuchElement"),jm=zm({[sA]:sA},"NoSuchElementException"),iA=Symbol.for("effect/Cause/errors/Timeout"),Mte=zm({[iA]:iA},"TimeoutException"),Lte=e=>new Mte(`Operation timed out after '${bL(e)}'`),oA=Symbol.for("effect/Cause/errors/UnknownException"),Sw=function(){class e extends q${constructor(r,s){super(s??"An unknown error occurred",{cause:r});p(this,"_tag","UnknownException");p(this,"error");this.error=r}}return Object.assign(e.prototype,{[oA]:oA,name:"UnknownException"}),e}(),vw=e=>Bs(e)&&"_tag"in e&&(e._tag==="Success"||e._tag==="Failure"),Rz=e=>e._tag==="Failure",$z=e=>e._tag==="Success",zte=e=>{switch(e._tag){case tr:return E$(e.effect_instruction_i0);case nr:return!1}},M_=x(2,(e,t)=>{switch(e._tag){case tr:return xt(e.effect_instruction_i0);case nr:return St(t)}}),O1=e=>M_(e,void 0),Wf=(e,t)=>Bte(e,t!=null&&t.parallel?ga:zn),If=e=>xt(Gr(e)),xg=e=>xt(cu(e)),xt=e=>{const t=new hz(tr);return t.effect_instruction_i0=e,t},jte=x(2,(e,t)=>{switch(e._tag){case tr:return xt(e.effect_instruction_i0);case nr:return t(e.effect_instruction_i0)}}),Ute=e=>T(e,jte(Ce)),M$=e=>xt(ri(e)),L_=x(2,(e,t)=>{switch(e._tag){case tr:return xt(e.effect_instruction_i0);case nr:return St(t(e.effect_instruction_i0))}}),ww=x(2,(e,{onFailure:t,onSuccess:n})=>{switch(e._tag){case tr:return t(e.effect_instruction_i0);case nr:return n(e.effect_instruction_i0)}}),Wk=x(2,(e,{onFailure:t,onSuccess:n})=>{switch(e._tag){case tr:return t(e.effect_instruction_i0);case nr:return n(e.effect_instruction_i0)}}),St=e=>{const t=new pz(nr);return t.effect_instruction_i0=e,t},wr=St(void 0),Hte=x(2,(e,t)=>L$(e,t,{onSuccess:(n,r)=>[n,r],onFailure:zn})),Iz=x(2,(e,t)=>L$(e,t,{onSuccess:(n,r)=>r,onFailure:zn})),L$=x(3,(e,t,{onFailure:n,onSuccess:r})=>{switch(e._tag){case tr:switch(t._tag){case nr:return xt(e.effect_instruction_i0);case tr:return xt(n(e.effect_instruction_i0,t.effect_instruction_i0))}case nr:switch(t._tag){case nr:return St(r(e.effect_instruction_i0,t.effect_instruction_i0));case tr:return xt(t.effect_instruction_i0)}}}),Bte=(e,t)=>{const n=da(e);return vo(n)?T(Ko(n),WR(T(co(n),L_(Xt)),(r,s)=>T(r,L$(s,{onSuccess:(i,o)=>T(i,xr(o)),onFailure:t}))),L_(ha),L_(r=>di(r)),oe):re()},Um=e=>({...ka,[uz]:Yee,state:Cu(Xee([])),commit(){return Li(this)},blockingOn:e}),ch=()=>Z(qm,e=>Vte(e)),Vte=e=>se(()=>Um(e)),Li=e=>Xa(t=>{const n=dt(e.state);switch(n._tag){case pw:return t(n.effect);case Fm:return n.joiners.push(t),Jte(e,t)}},e.blockingOn),Wte=x(2,(e,t)=>T$(t,e)),uh=x(2,(e,t)=>se(()=>{const n=dt(e.state);switch(n._tag){case pw:return!1;case Fm:{xu(e.state,fz(t));for(let r=0,s=n.joiners.length;r<s;r++)n.joiners[r](t);return!0}}})),Tz=x(2,(e,t)=>uh(e,t)),Kte=x(2,(e,t)=>uh(e,Gt(t))),Pz=x(2,(e,t)=>uh(e,fn(t))),Gte=e=>Z(qm,t=>uh(e,I$(t))),z$=x(2,(e,t)=>uh(e,I$(t))),Qte=e=>se(()=>dt(e.state)._tag===pw),Hm=x(2,(e,t)=>uh(e,ie(t))),Bm=(e,t)=>{const n=dt(e.state);if(n._tag===Fm){xu(e.state,fz(t));for(let r=0,s=n.joiners.length;r<s;r++)n.joiners[r](t)}},Jte=(e,t)=>se(()=>{const n=dt(e.state);if(n._tag===Fm){const r=n.joiners.indexOf(t);r>=0&&n.joiners.splice(r,1)}}),Yte=et(e=>St(e.currentContext)),fh=()=>Yte,dh=e=>Z(fh(),e),j$=x(2,(e,t)=>Tu(Hi,t)(e)),U$=x(2,(e,t)=>F$(Hi,n=>xa(n,t))(e)),H$=x(2,(e,t)=>dh(n=>j$(e,t(n)))),B$=e=>{const t=e.currentSpan;return t!==void 0&&t._tag==="Span"?oe(t):re()},Xte={_tag:"Span",spanId:"noop",traceId:"noop",sampled:!1,status:{_tag:"Ended",startTime:BigInt(0),endTime:BigInt(0),exit:wr},attributes:new Map,links:[],kind:"internal",attribute(){},event(){},end(){},addLinks(){}},Zte=e=>Object.assign(Object.create(Xte),e),tc=uz,rt=ch,yn=Li,ene=Wte,Wl=Tz,V$=Kte,Kf=Pz,aA=Gte,Kk=Qte,jt=Hm,bw=Bm,tne=vw,hh=Rz,xd=$z,nne=zte,rne=Wf,KS=If,Vm=xg,jn=xt,sne=Ute,ine=M$,one=L_,Ti=ww,_n=St,_s=wr,lA=Hte,Rg=Iz,cA=Symbol.for("effect/MutableHashMap"),ane={[cA]:cA,[Symbol.iterator](){return new W$(this)},toString(){return qt(this.toJSON())},toJSON(){return{_id:"MutableHashMap",values:Array.from(this).map(sn)}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}};class W${constructor(t){p(this,"self");p(this,"referentialIterator");p(this,"bucketIterator");this.self=t,this.referentialIterator=t.referential[Symbol.iterator]()}next(){if(this.bucketIterator!==void 0)return this.bucketIterator.next();const t=this.referentialIterator.next();return t.done?(this.bucketIterator=new lne(this.self.buckets.values()),this.next()):t}[Symbol.iterator](){return new W$(this.self)}}class lne{constructor(t){p(this,"backing");p(this,"currentBucket");this.backing=t}next(){if(this.currentBucket===void 0){const n=this.backing.next();if(n.done)return n;this.currentBucket=n.value[Symbol.iterator]()}const t=this.currentBucket.next();return t.done?(this.currentBucket=void 0,this.next()):t}}const Oz=()=>{const e=Object.create(ane);return e.referential=new Map,e.buckets=new Map,e.bucketsSize=0,e},eo=x(2,(e,t)=>{if(dg(t)===!1)return e.referential.has(t)?oe(e.referential.get(t)):re();const n=t[qe](),r=e.buckets.get(n);return r===void 0?re():cne(e,r,t)}),cne=(e,t,n,r=!1)=>{for(let s=0,i=t.length;s<i;s++)if(n[Me](t[s][0])){const o=t[s][1];return r&&(t.splice(s,1),e.bucketsSize--),oe(o)}return re()},of=x(2,(e,t)=>Wt(eo(e,t))),af=x(3,(e,t,n)=>{if(dg(t)===!1)return e.referential.set(t,n),e;const r=t[qe](),s=e.buckets.get(r);return s===void 0?(e.buckets.set(r,[[t,n]]),e.bucketsSize++,e):(Az(e,s,t),s.push([t,n]),e.bucketsSize++,e)}),Az=(e,t,n)=>{for(let r=0,s=t.length;r<s;r++)if(n[Me](t[r][0])){t.splice(r,1),e.bucketsSize--;return}},une=x(2,(e,t)=>{if(dg(t)===!1)return e.referential.delete(t),e;const n=t[qe](),r=e.buckets.get(n);return r===void 0||(Az(e,r,t),r.length===0&&e.buckets.delete(n)),e}),uA=Symbol.for("effect/MutableList"),fne={[uA]:uA,[Symbol.iterator](){let e=!1,t=this.head;return{next(){if(e)return this.return();if(t==null)return e=!0,this.return();const n=t.value;return t=t.next,{done:e,value:n}},return(n){return e||(e=!0),{done:!0,value:n}}}},toString(){return qt(this.toJSON())},toJSON(){return{_id:"MutableList",values:Array.from(this).map(sn)}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},dne=e=>({value:e,removed:!1,prev:void 0,next:void 0}),hne=()=>{const e=Object.create(fne);return e.head=void 0,e.tail=void 0,e._length=0,e},Fz=e=>K$(e)===0,K$=e=>e._length,pne=x(2,(e,t)=>{const n=dne(t);return e.head===void 0&&(e.head=n),e.tail===void 0||(e.tail.next=n,n.prev=e.tail),e.tail=n,e._length+=1,e}),gne=e=>{const t=e.head;if(t!==void 0)return mne(e,t),t.value},mne=(e,t)=>{t.removed||(t.removed=!0,t.prev!==void 0&&t.next!==void 0?(t.prev.next=t.next,t.next.prev=t.prev):t.prev!==void 0?(e.tail=t.prev,t.prev.next=void 0):t.next!==void 0?(e.head=t.next,t.next.prev=void 0):(e.tail=void 0,e.head=void 0),e._length>0&&(e._length-=1))},fA=Symbol.for("effect/MutableQueue"),Rn=Symbol.for("effect/mutable/MutableQueue/Empty"),yne={[fA]:fA,[Symbol.iterator](){return Array.from(this.queue)[Symbol.iterator]()},toString(){return qt(this.toJSON())},toJSON(){return{_id:"MutableQueue",values:Array.from(this).map(sn)}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},Nz=e=>{const t=Object.create(yne);return t.queue=hne(),t.capacity=e,t},G$=e=>Nz(e),Ew=()=>Nz(void 0),Q$=e=>K$(e.queue),Dc=e=>Fz(e.queue),_ne=e=>e.capacity===void 0?1/0:e.capacity,Rd=x(2,(e,t)=>{const n=K$(e.queue);return e.capacity!==void 0&&n===e.capacity?!1:(pne(t)(e.queue),!0)}),J$=x(2,(e,t)=>{const n=t[Symbol.iterator]();let r,s=Ut(),i=!0;for(;i&&(r=n.next())&&!r.done;)i=Rd(r.value)(e);for(;r!=null&&!r.done;)s=xr(r.value)(s),r=n.next();return ha(s)}),ta=x(2,(e,t)=>Fz(e.queue)?t:gne(e.queue)),kw=x(2,(e,t)=>{let n=Ut(),r=0;for(;r<t;){const s=ta(Rn)(e);if(s===Rn)break;n=xr(s)(n),r+=1}return ha(n)}),Sne="effect/Clock",dA=Symbol.for(Sne),Ou=Mr("effect/Clock"),vne=2**31-1,hA={unsafeSchedule(e,t){const n=ru(t);if(n>vne)return ds;let r=!1;const s=setTimeout(()=>{r=!0,e()},n);return()=>(clearTimeout(s),!r)}},pA=function(){const e=BigInt(1e6);if(typeof performance>"u")return()=>BigInt(Date.now())*e;let t;return()=>(t===void 0&&(t=BigInt(Date.now())*e-BigInt(Math.round(performance.now()*1e6))),t+BigInt(Math.round(performance.now()*1e6)))}(),wne=function(){const e=typeof process=="object"&&"hrtime"in process&&typeof process.hrtime.bigint=="function"?process.hrtime:void 0;if(!e)return pA;const t=pA()-e.bigint();return()=>t+e.bigint()}();var DEe;class bne{constructor(){p(this,DEe,dA);p(this,"currentTimeMillis",se(()=>this.unsafeCurrentTimeMillis()));p(this,"currentTimeNanos",se(()=>this.unsafeCurrentTimeNanos()))}unsafeCurrentTimeMillis(){return Date.now()}unsafeCurrentTimeNanos(){return wne()}scheduler(){return ie(hA)}sleep(t){return Mi(n=>{const r=hA.unsafeSchedule(()=>n(Ve),t);return vs(se(r))})}}DEe=dA;const Ene=()=>new bne,Dz="And",qz="Or",Mz="InvalidData",Lz="MissingData",zz="SourceUnavailable",jz="Unsupported",kne="effect/ConfigError",gA=Symbol.for(kne),ph={_tag:"ConfigError",[gA]:gA},Uz=(e,t)=>{const n=Object.create(ph);return n._op=Dz,n.left=e,n.right=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`${this.left} and ${this.right}`}}),Object.defineProperty(n,"message",{enumerable:!1,get(){return this.toString()}}),n},Hz=(e,t)=>{const n=Object.create(ph);return n._op=qz,n.left=e,n.right=t,Object.defineProperty(n,"toString",{enumerable:!1,value(){return`${this.left} or ${this.right}`}}),Object.defineProperty(n,"message",{enumerable:!1,get(){return this.toString()}}),n},Cne=(e,t,n={pathDelim:"."})=>{const r=Object.create(ph);return r._op=Mz,r.path=e,r.message=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Invalid data at ${T(this.path,ku(n.pathDelim))}: "${this.message}")`}}),r},du=(e,t,n={pathDelim:"."})=>{const r=Object.create(ph);return r._op=Lz,r.path=e,r.message=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Missing data at ${T(this.path,ku(n.pathDelim))}: "${this.message}")`}}),r},xne=(e,t,n,r={pathDelim:"."})=>{const s=Object.create(ph);return s._op=zz,s.path=e,s.message=t,s.cause=n,Object.defineProperty(s,"toString",{enumerable:!1,value(){return`(Source unavailable at ${T(this.path,ku(r.pathDelim))}: "${this.message}")`}}),s},Rne=(e,t,n={pathDelim:"."})=>{const r=Object.create(ph);return r._op=jz,r.path=e,r.message=t,Object.defineProperty(r,"toString",{enumerable:!1,value(){return`(Unsupported operation at ${T(this.path,ku(n.pathDelim))}: "${this.message}")`}}),r},_c=x(2,(e,t)=>{switch(e._op){case Dz:return Uz(_c(e.left,t),_c(e.right,t));case qz:return Hz(_c(e.left,t),_c(e.right,t));case Mz:return Cne([...t,...e.path],e.message);case Lz:return du([...t,...e.path],e.message);case zz:return xne([...t,...e.path],e.message,e.cause);case jz:return Rne([...t,...e.path],e.message)}}),$ne={_tag:"Empty"},A1=x(2,(e,t)=>{let n=_$(t),r=e;for(;y$(n);){const s=n.head;switch(s._tag){case"Empty":{n=n.tail;break}case"AndThen":{n=au(s.first,au(s.second,n.tail));break}case"MapName":{r=Zo(r,s.f),n=n.tail;break}case"Nested":{r=TS(r,s.name),n=n.tail;break}case"Unnested":{if(T(zf(r),NQ(s.name)))r=Yc(r),n=n.tail;else return $e(du(r,`Expected ${s.name} to be in path in ConfigProvider#unnested`));break}}}return Pe(r)}),Ine="Constant",Tne="Fail",Pne="Fallback",One="Described",Ane="Lazy",Fne="MapOrFail",Nne="Nested",Dne="Primitive",qne="Sequence",Mne="HashMap",Lne="ZipWith",GS=(e,t)=>[...e,...t],zne="effect/ConfigProvider",mA=Symbol.for(zne),Bz=Mr("effect/ConfigProvider"),jne="effect/ConfigProviderFlat",yA=Symbol.for(jne),Une=e=>({[mA]:mA,pipe(){return pe(this,arguments)},...e}),Hne=e=>({[yA]:yA,patch:e.patch,load:(t,n,r=!0)=>e.load(t,n,r),enumerateChildren:e.enumerateChildren}),Bne=e=>Une({load:t=>Z(Qs(e,bl(),t,!1),n=>bt(zf(n),{onNone:()=>Gt(du(bl(),`Expected a single value having structure: ${t}`)),onSome:ie})),flattened:e}),Vne=e=>{const{pathDelim:t,seqDelim:n}=Object.assign({},{pathDelim:"_",seqDelim:","},e),r=c=>T(c,ku(t)),s=c=>c.split(t),i=()=>typeof process<"u"&&"env"in process&&typeof process.env=="object"?process.env:{};return Bne(Hne({load:(c,f,d=!0)=>{const g=r(c),_=i(),b=g in _?oe(_[g]):re();return T(b,gw(()=>du(c,`Expected ${g} to exist in the process context`)),Z(k=>Jne(k,c,f,n,d)))},enumerateChildren:c=>se(()=>{const f=i(),_=Object.keys(f).map(b=>s(b.toUpperCase())).filter(b=>{for(let k=0;k<c.length;k++){const I=T(c,dM(k)),E=b[k];if(E===void 0||I!==E)return!1}return!0}).flatMap(b=>b.slice(c.length,c.length+1));return LX(_)}),patch:$ne}))},Wne=(e,t,n,r)=>{const s=xO(n.length,c=>c>=r.length?re():oe([e(c),c+1])),i=xO(r.length,c=>c>=n.length?re():oe([t(c),c+1])),o=GS(n,s),a=GS(r,i);return[o,a]},Kne=(e,t)=>{let n=t;if(n._tag==="Nested"){const r=e.slice();for(;n._tag==="Nested";)r.push(n.name),n=n.config;return r}return e},Qs=(e,t,n,r)=>{const s=n;switch(s._tag){case Ine:return ie($s(s.value));case One:return Ee(()=>Qs(e,t,s.config,r));case Tne:return Gt(du(t,s.message));case Pne:return T(Ee(()=>Qs(e,t,s.first,r)),Ed(i=>s.condition(i)?T(Qs(e,t,s.second,r),Ed(o=>Gt(Hz(i,o)))):Gt(i)));case Ane:return Ee(()=>Qs(e,t,s.config(),r));case Fne:return Ee(()=>T(Qs(e,t,s.original,r),Z(Go(i=>T(s.mapOrFail(i),gw(_c(Kne(t,s.original))))))));case Nne:return Ee(()=>Qs(e,GS(t,$s(s.name)),s.config,r));case Dne:return T(A1(t,e.patch),Z(i=>T(e.load(i,s,r),Z(o=>{if(o.length===0){const a=T(tJ(i),Yt(()=>"<n/a>"));return Gt(du([],`Expected ${s.description} with name ${a}`))}return ie(o)}))));case qne:return T(A1(t,e.patch),Z(i=>T(e.enumerateChildren(i),Z(Xne),Z(o=>o.length===0?Ee(()=>Fe(Qs(e,t,s.config,!0),$s)):T(Go(o,a=>Qs(e,QQ(t,`[${a}]`),s.config,!0)),Fe(a=>{const c=fJ(a);return c.length===0?$s(bl()):$s(c)}))))));case Mne:return Ee(()=>T(A1(t,e.patch),Z(i=>T(e.enumerateChildren(i),Z(o=>T(o,Go(a=>Qs(e,GS(i,$s(a)),s.valueConfig,r)),Fe(a=>a.length===0?$s(aw()):T(Yne(a),Zo(c=>ZX(CO(gt(o),c)))))))))));case Lne:return Ee(()=>T(Qs(e,t,s.left,r),kd,Z(i=>T(Qs(e,t,s.right,r),kd,Z(o=>{if(Gn(i)&&Gn(o))return Gt(Uz(i.left,o.left));if(Gn(i)&&ao(o))return Gt(i.left);if(ao(i)&&Gn(o))return Gt(o.left);if(ao(i)&&ao(o)){const a=T(t,ku(".")),c=Gne(t,a),[f,d]=Wne(c,c,T(i.right,Zo(Pe)),T(o.right,Zo(Pe)));return T(f,CO(d),Go(([g,_])=>T(mw(g,_),Fe(([b,k])=>s.zip(b,k)))))}throw new Error("BUG: ConfigProvider.fromFlatLoop - please report an issue at https://github.com/Effect-TS/effect/issues")})))))}},Gne=(e,t)=>n=>$e(du(e,`The element at index ${n} in a sequence at path "${t}" was missing`)),Qne=(e,t)=>e.split(new RegExp(`\\s*${OS(t)}\\s*`)),Jne=(e,t,n,r,s)=>s?T(Qne(e,r),Go(i=>n.parse(i.trim())),gw(_c(t))):T(n.parse(e),P$({onFailure:_c(t),onSuccess:$s})),Yne=e=>Object.keys(e[0]).map(t=>e.map(n=>n[t])),Xne=e=>T(Go(e,ere),P$({onFailure:()=>bl(),onSuccess:hg(dd)}),kd,Fe(bQ)),Zne=/^(\[(\d+)\])$/,ere=e=>{const t=e.match(Zne);if(t!==null){const n=t[2];return T(n!==void 0&&n.length>0?oe(n):re(),Eu(tre))}return re()},tre=e=>{const t=Number.parseInt(e);return Number.isNaN(t)?re():oe(t)},_A=Symbol.for("effect/Console"),Cw=Mr("effect/Console"),nre={[_A]:_A,assert(e,...t){return se(()=>{console.assert(e,...t)})},clear:se(()=>{console.clear()}),count(e){return se(()=>{console.count(e)})},countReset(e){return se(()=>{console.countReset(e)})},debug(...e){return se(()=>{console.debug(...e)})},dir(e,t){return se(()=>{console.dir(e,t)})},dirxml(...e){return se(()=>{console.dirxml(...e)})},error(...e){return se(()=>{console.error(...e)})},group(e){return e!=null&&e.collapsed?se(()=>console.groupCollapsed(e==null?void 0:e.label)):se(()=>console.group(e==null?void 0:e.label))},groupEnd:se(()=>{console.groupEnd()}),info(...e){return se(()=>{console.info(...e)})},log(...e){return se(()=>{console.log(...e)})},table(e,t){return se(()=>{console.table(e,t)})},time(e){return se(()=>console.time(e))},timeEnd(e){return se(()=>console.timeEnd(e))},timeLog(e,...t){return se(()=>{console.timeLog(e,...t)})},trace(...e){return se(()=>{console.trace(...e)})},warn(...e){return se(()=>{console.warn(...e)})},unsafe:console},rre="effect/Random",SA=Symbol.for(rre),sre=Mr("effect/Random");var qEe;class ire{constructor(t){p(this,"seed");p(this,qEe,SA);p(this,"PRNG");this.seed=t,this.PRNG=new QG(t)}get next(){return se(()=>this.PRNG.number())}get nextBoolean(){return Fe(this.next,t=>t>.5)}get nextInt(){return se(()=>this.PRNG.integer(Number.MAX_SAFE_INTEGER))}nextRange(t,n){return Fe(this.next,r=>(n-t)*r+t)}nextIntBetween(t,n){return se(()=>this.PRNG.integer(n-t)+t)}shuffle(t){return ore(t,n=>this.nextIntBetween(0,n))}}qEe=SA;const ore=(e,t)=>Ee(()=>T(se(()=>Array.from(e)),Z(n=>{const r=[];for(let s=n.length;s>=2;s=s-1)r.push(s);return T(r,fu(s=>T(t(s),Fe(i=>are(n,s-1,i)))),Tn(da(n)))}))),are=(e,t,n)=>{const r=e[t];return e[t]=e[n],e[n]=r,e},lre=e=>new ire(ce(e)),vA=Symbol.for("effect/Tracer"),Vz=e=>({[vA]:vA,...e}),Wm=Mr("effect/Tracer"),kl=Mr("effect/ParentSpan"),wA=function(){const e="abcdef0123456789",t=e.length;return function(n){let r="";for(let s=0;s<n;s++)r+=e.charAt(Math.floor(Math.random()*t));return r}}();class cre{constructor(t,n,r,s,i,o){p(this,"name");p(this,"parent");p(this,"context");p(this,"startTime");p(this,"kind");p(this,"_tag","Span");p(this,"spanId");p(this,"traceId","native");p(this,"sampled",!0);p(this,"status");p(this,"attributes");p(this,"events",[]);p(this,"links");this.name=t,this.parent=n,this.context=r,this.startTime=i,this.kind=o,this.status={_tag:"Started",startTime:i},this.attributes=new Map,this.traceId=n._tag==="Some"?n.value.traceId:wA(32),this.spanId=wA(16),this.links=Array.from(s)}end(t,n){this.status={_tag:"Ended",endTime:t,exit:n,startTime:this.status.startTime}}attribute(t,n){this.attributes.set(t,n)}event(t,n,r){this.events.push([t,n,r??{}])}addLinks(t){this.links.push(...t)}}const ure=Vz({span:(e,t,n,r,s,i)=>new cre(e,t,n,r,s,i),context:e=>e()}),Gf=e=>{if((e==null?void 0:e.captureStackTrace)===!1)return e;if((e==null?void 0:e.captureStackTrace)!==void 0&&typeof e.captureStackTrace!="boolean")return e;const t=Error.stackTraceLimit;Error.stackTraceLimit=3;const n=new Error;Error.stackTraceLimit=t;let r=!1;return{...e,captureStackTrace:()=>{if(r!==!1)return r;if(n.stack!==void 0){const s=n.stack.split(`
194
+ `);if(s[3]!==void 0)return r=s[3].trim(),r}}}},QS=Im()("effect/Tracer/DisablePropagation",{defaultValue:ds}),fre=T(tu(),$i(Ou,Ene()),$i(Cw,nre),$i(sre,lre(Math.random())),$i(Bz,Vne()),$i(Wm,ure)),bo=We(Symbol.for("effect/DefaultServices/currentServices"),()=>bz(fre)),dre=e=>{const t=Ls(e);return X$(n=>n.sleep(t))},Y$=e=>et(t=>e(t.currentDefaultServices)),X$=e=>Y$(t=>e(t.unsafeMap.get(Ou.key))),hre=X$(e=>e.currentTimeMillis),pre=e=>Y$(t=>e(t.unsafeMap.get(Bz.key))),gre=e=>pre(t=>t.load(e)),mre=e=>Y$(t=>e(t.unsafeMap.get(Wm.key))),Wz=dre,yre=hre,_re=Ou;function Sre(e){return new Cl(e)}function vre(){return Sre(new Map)}const bA=Symbol.for("effect/FiberRefs");var MEe;class Cl{constructor(t){p(this,"locals");p(this,MEe,bA);this.locals=t}pipe(){return pe(this,arguments)}}MEe=bA;const wre=(e,t,n,r=!1)=>{const s=e;let i=t,o=n,a=r,c;for(;c===void 0;)if(Kt(i)&&Kt(o)){const f=Kr(i)[0],d=Yc(i),g=Kr(o)[0],_=Kr(o)[1],b=Yc(o);f.startTimeMillis<g.startTimeMillis?(o=b,a=!0):f.startTimeMillis>g.startTimeMillis?i=d:f.id<g.id?(o=b,a=!0):f.id>g.id?i=d:c=[_,a]}else c=[s.initial,!0];return c},bre=x(3,(e,t,n)=>{const r=new Map(e.locals);return n.locals.forEach((s,i)=>{const o=s[0][1];if(!s[0][0][Me](t)){if(!r.has(i)){if(Ne(o,i.initial))return;r.set(i,[[t,i.join(i.initial,o)]]);return}const a=r.get(i),[c,f]=wre(i,a,s);if(f){const d=i.diff(c,o),g=a[0][1],_=i.join(g,i.patch(d)(g));if(!Ne(g,_)){let b;const k=a[0][0];k[Me](t)?b=[[k,_],...a.slice(1)]:b=[[t,_],...a],r.set(i,b)}}}}),new Cl(r)}),Ere=x(2,(e,t)=>{const n=new Map;return Kz(e,n,t),new Cl(n)}),Kz=(e,t,n)=>{e.locals.forEach((r,s)=>{const i=r[0][1],o=s.patch(s.fork)(i);Ne(i,o)?t.set(s,r):t.set(s,[[n,o],...r])})},Gz=x(2,(e,t)=>{const n=new Map(e.locals);return n.delete(t),new Cl(n)}),Qz=x(2,(e,t)=>e.locals.has(t)?oe(Kr(e.locals.get(t))[1]):re()),$g=x(2,(e,t)=>T(Qz(e,t),Yt(()=>t.initial))),Gk=x(2,(e,{fiberId:t,fiberRef:n,value:r})=>{if(e.locals.size===0)return new Cl(new Map([[n,[[t,r]]]]));const s=new Map(e.locals);return Qk(s,t,n,r),new Cl(s)}),Qk=(e,t,n,r)=>{const s=e.get(n)??[];let i;if(Kt(s)){const[o,a]=Kr(s);if(o[Me](t)){if(Ne(a,r))return;i=[[t,r],...s.slice(1)]}else i=[[t,r],...s]}else i=[[t,r]];e.set(n,i)},kre=x(2,(e,{entries:t,forkAs:n})=>{if(e.locals.size===0)return new Cl(new Map(t));const r=new Map(e.locals);return n!==void 0&&Kz(e,r,n),t.forEach(([s,i])=>{i.length===1?Qk(r,i[0][0],s,i[0][1]):i.forEach(([o,a])=>{Qk(r,o,s,a)})}),new Cl(r)}),EA=Qz,xw=$g,Cre=kre,xre=vre,Rre=fte,$re=dte,Jz=hte,Yz=pte,Ire=vz,Z$=wz,Tre=gte,Pre=mte,Ore=T(dd,lM(e=>e.ordinal)),Are=CQ(Ore),Fre=e=>{switch(e){case"All":return Rre;case"Debug":return Z$;case"Error":return Jz;case"Fatal":return $re;case"Info":return Ire;case"Trace":return Tre;case"None":return Pre;case"Warning":return Yz}},Xz=e=>e.replace(/[\s="]/g,"_"),eI=e=>t=>`${Xz(t.label)}=${e-t.startTime}ms`,Nre=Em,Dre=ka,qre=fQ;let Io=class extends qre{};const xl=Symbol.for("effect/Readable"),tI=Symbol.for("effect/Ref"),nI={_A:e=>e};var LEe,zEe;class Mre extends Io{constructor(n){super();p(this,"ref");p(this,LEe,nI);p(this,zEe,xl);p(this,"get");this.ref=n,this.get=se(()=>dt(this.ref))}commit(){return this.get}modify(n){return se(()=>{const r=dt(this.ref),[s,i]=n(r);return r!==i&&xu(i)(this.ref),s})}}LEe=tI,zEe=xl;const Zz=e=>new Mre(Cu(e)),JS=e=>se(()=>Zz(e)),na=e=>e.get,Ig=x(2,(e,t)=>e.modify(()=>[void 0,t])),Lre=x(2,(e,t)=>e.modify(n=>[n,t])),e4=x(2,(e,t)=>e.modify(t)),Jk=x(2,(e,t)=>e.modify(n=>[void 0,t(n)])),zre=tI,Au=JS,Qf=na,jre=Lre,uc=e4,Tg=Ig,Ure=Jk,t4=kl,n4=Vz,Hre=mre,r4="Empty",s4="Add",i4="Remove",o4="Update",a4="AndThen",Bre={_tag:r4},rI=(e,t)=>{const n=new Map(e.locals);let r=Bre;for(const[s,i]of t.locals.entries()){const o=Kr(i)[1],a=n.get(s);if(a!==void 0){const c=Kr(a)[1];Ne(c,o)||(r=F1({_tag:o4,fiberRef:s,patch:s.diff(c,o)})(r))}else r=F1({_tag:s4,fiberRef:s,value:o})(r);n.delete(s)}for(const[s]of n.entries())r=F1({_tag:i4,fiberRef:s})(r);return r},F1=x(2,(e,t)=>({_tag:a4,first:e,second:t})),l4=x(3,(e,t,n)=>{let r=n,s=$s(e);for(;Kt(s);){const i=Kr(s),o=Yc(s);switch(i._tag){case r4:{s=o;break}case s4:{r=Gk(r,{fiberId:t,fiberRef:i.fiberRef,value:i.value}),s=o;break}case i4:{r=Gz(r,i.fiberRef),s=o;break}case o4:{const a=$g(r,i.fiberRef);r=Gk(r,{fiberId:t,fiberRef:i.fiberRef,value:i.fiberRef.patch(i.patch)(a)}),s=o;break}case a4:{s=TS(i.first)(TS(i.second)(o));break}}}return r}),c4="effect/MetricLabel",Yk=Symbol.for(c4);var jEe;class Vre{constructor(t,n){p(this,"key");p(this,"value");p(this,jEe,Yk);p(this,"_hash");this.key=t,this.value=n,this._hash=tn(c4+this.key+this.value)}[(jEe=Yk,qe)](){return this._hash}[Me](t){return Kre(t)&&this.key===t.key&&this.value===t.value}pipe(){return pe(this,arguments)}}const Wre=(e,t)=>new Vre(e,t),Kre=e=>_e(e,Yk),Gre=x(e=>Bs(e[0]),function(){const e=arguments;return F$(e[0],kz,typeof e[1]=="string"?jS(e[1],e[2]):t=>Object.entries(e[1]).reduce((n,[r,s])=>jS(n,r,s),t))}),Qre=e=>Fe(e,oe),u4=e=>{let t,n;return typeof e=="function"?t=e:(t=e.try,n=e.catch),Ee(()=>{try{return ie(Bt(t))}catch(r){return Gt(n?Bt(()=>n(r)):new Sw(r,"An unknown error occurred in Effect.try"))}})},Jre=x(2,(e,t)=>Nm(e,n=>{const r=fw(n,s=>w$(s)?oe(s):re());switch(r._tag){case"None":return fn(n);case"Some":return t(r.value.defect)}})),Yre=x(2,(e,t)=>ys(e,{onFailure:n=>{const r=t(n);switch(r._tag){case"None":return fn(n);case"Some":return r.value}},onSuccess:ie})),Xre=x(e=>Bs(e[0]),(e,...t)=>{const n=t[t.length-1];let r;return t.length===2?r=NR(t[0]):r=s=>{const i=_e(s,"_tag")?s._tag:void 0;if(!i)return!1;for(let o=0;o<t.length-1;o++)if(t[o]===i)return!0;return!1},tte(e,r,n)}),sI=x(2,(e,t)=>kt(Wz(t),e)),Zre=e=>m4(e,d4,rI),ese=e=>m4(e,mw(d4,ote),([t,n],[r,s])=>[rI(t,r),pl(n,s)]),f4=x(2,(e,t)=>wo(e,{onFailure:n=>ie(t.onFailure(n)),onSuccess:n=>ie(t.onSuccess(n))})),iI=e=>{const t=Z(Z(e,()=>Lm()),()=>t);return t},d4=et(e=>ie(e.getFiberRefs())),h4=e=>f4(e,{onFailure:fd,onSuccess:fd}),tse=e=>ys(e,{onFailure:t=>p4(t,"An error was silently ignored because it is not anticipated to be useful"),onSuccess:()=>Ve}),Rw=e=>(...t)=>{const n=bu(e);let r;for(let s=0,i=t.length;s<i;s++){const o=t[s];v$(o)&&(r!==void 0?r=zn(r,o):r=o,t=[...t.slice(0,s),...t.slice(s+1)],s--)}return r===void 0&&(r=pa),et(s=>(s.log(t,r,n),Ve))},nse=Rw(),p4=Rw(Z$),rse=Rw(Yz),sse=Rw(Jz),kA=x(2,(e,t)=>ys(e,{onFailure:n=>mz(()=>t(n)),onSuccess:ie})),ise=e=>T(ch(),Z(t=>T(ese(e),T$(t),ase,Fe(n=>kt(n,T(Li(t),Z(([r,s])=>Tn(mw(g4(r[0]),_z(r[1])),s)))))))),ose=e=>Fe(e,t=>!t),ase=e=>Fe(Au(!0),t=>vs(Mm(e,jre(t,!1)))),g4=e=>pse((t,n)=>T(e,l4(t,n))),lse=e=>e.length>=1?Mi((t,n)=>{try{e(n).then(r=>t(St(r)),r=>t(If(r)))}catch(r){t(If(r))}}):Mi(t=>{try{e().then(n=>t(St(n)),n=>t(If(n)))}catch(n){t(If(n))}}),Pg=x(3,(e,t,n)=>dh(r=>j$(e,$i(r,t,n)))),oI=Wz,Og=ie(re()),m4=x(3,(e,t,n)=>Z(t,r=>Z(e,s=>Fe(t,i=>[n(r,i),s])))),cse=x(2,(e,t)=>ys(e,{onFailure:n=>kt(t(n),fn(n)),onSuccess:ie})),use=Hre,fse=use(ie),dse=e=>{let t,n;typeof e=="function"?t=e:(t=e.try,n=e.catch);const r=s=>n?Dm(()=>n(s)):Gt(new Sw(s,"An unknown error occurred in Effect.tryPromise"));return t.length>=1?Mi((s,i)=>{try{t(i).then(o=>s(St(o)),o=>s(r(o)))}catch(o){s(r(o))}}):Mi(s=>{try{t().then(i=>s(St(i)),i=>s(r(i)))}catch(i){s(r(i))}})},hse=x(2,(e,t)=>Z(e,n=>u4({try:()=>t.try(n),catch:t.catch}))),pse=e=>et(t=>(t.setFiberRefs(e(t.id(),t.getFiberRefs())),Ve)),gse=x(2,(e,t)=>Ee(()=>t()?Fe(e,oe):ie(re()))),mse=e=>Fe(fh(),Ms(e)),yse=function(){const e=arguments;return h4(Z(y4,t=>se(()=>{if(typeof e[0]=="string")t.attribute(e[0],e[1]);else for(const n in e[0])t.attribute(n,e[0][n])})))},y4=Z(fh(),e=>{const t=e.unsafeMap.get(kl.key);return t!==void 0&&t._tag==="Span"?ie(t):Gt(new jm)}),_4=BigInt(0),S4=Eu(e=>hs(e.context,QS)?e._tag==="Span"?S4(e.parent):re():oe(e)),v4=(e,t,n)=>{const r=!e.getFiberRef(Cz)||n.context&&hs(n.context,QS),s=e.getFiberRef(Hi),i=n.parent?oe(n.parent):n.root?re():S4(Ms(s,kl));let o;if(r)o=Zte({name:t,parent:i,context:$i(n.context??tu(),QS,!0)});else{const a=e.getFiberRef(bo),c=hs(a,Wm),f=hs(a,_re),d=e.getFiberRef(D$),g=e.getFiberRefs(),_=EA(g,Tte),b=EA(g,Pte),k=b._tag==="Some"?n.links!==void 0?[...di(b.value),...n.links??[]]:di(b.value):n.links??bl();o=c.span(t,i,n.context??tu(),k,d?f.unsafeCurrentTimeNanos():_4,n.kind??"internal"),_._tag==="Some"&&rZ(_.value,(I,E)=>o.attribute(E,I)),n.attributes!==void 0&&Object.entries(n.attributes).forEach(([I,E])=>o.attribute(I,E))}return typeof n.captureStackTrace=="function"&&BS.set(o,n.captureStackTrace),o},w4=(e,t,n,r)=>se(()=>{e.status._tag!=="Ended"&&(Rz(t)&&BS.has(e)&&e.attribute("code.stacktrace",BS.get(e)()),e.end(r?n.unsafeCurrentTimeNanos():_4,t))}),Xk=(e,...t)=>{const n=Gf(t.length===1?void 0:t[0]),r=t[t.length-1];return et(s=>{const i=v4(s,e,n),o=s.getFiberRef(D$),a=hs(s.getFiberRef(bo),Ou);return ma(r(i),c=>w4(i,c,a,o))})},Zk=x(2,(e,t)=>Pg(e,kl,t)),_se=function(){const e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Gf(e?arguments[2]:arguments[1]);if(e){const r=arguments[0];return Xk(t,n,s=>Zk(r,s))}return r=>Xk(t,n,s=>Zk(r,s))},b4="Sequential",E4="Parallel",Sse="ParallelN",Km={_tag:b4},vse={_tag:E4},wse=e=>({_tag:Sse,parallelism:e}),bse=e=>e._tag===b4,Ese=e=>e._tag===E4,YS=Km,eC=vse,tC=wse,Ag=rI,Fg=l4,$w="effect/FiberStatus",hu=Symbol.for($w),XS="Done",CA="Running",xA="Suspended",kse=tn(`${$w}-${XS}`);var UEe;let Cse=class{constructor(){p(this,UEe,hu);p(this,"_tag",XS)}[(UEe=hu,qe)](){return kse}[Me](t){return aI(t)&&t._tag===XS}};var HEe;class xse{constructor(t){p(this,"runtimeFlags");p(this,HEe,hu);p(this,"_tag",CA);this.runtimeFlags=t}[(HEe=hu,qe)](){return T(ce($w),Oe(ce(this._tag)),Oe(ce(this.runtimeFlags)),At(this))}[Me](t){return aI(t)&&t._tag===CA&&this.runtimeFlags===t.runtimeFlags}}var BEe;class Rse{constructor(t,n){p(this,"runtimeFlags");p(this,"blockingOn");p(this,BEe,hu);p(this,"_tag",xA);this.runtimeFlags=t,this.blockingOn=n}[(BEe=hu,qe)](){return T(ce($w),Oe(ce(this._tag)),Oe(ce(this.runtimeFlags)),Oe(ce(this.blockingOn)),At(this))}[Me](t){return aI(t)&&t._tag===xA&&this.runtimeFlags===t.runtimeFlags&&Ne(this.blockingOn,t.blockingOn)}}const $se=new Cse,Ise=e=>new xse(e),Tse=(e,t)=>new Rse(e,t),aI=e=>_e(e,hu),Pse=e=>e._tag===XS,Ose=$se,k4=Ise,Ase=Tse,Fse=Pse,Nse=Symbol.for("effect/Micro"),ZS=Symbol.for("effect/Micro/MicroExit"),RA=Symbol.for("effect/Micro/MicroCause"),Dse={_E:Ce};var VEe;class C4 extends globalThis.Error{constructor(n,r,s){const i=`MicroCause.${n}`;let o,a,c;if(r instanceof globalThis.Error){o=`(${i}) ${r.name}`,a=r.message;const f=a.split(`
195
+ `).length;c=r.stack?`(${i}) ${r.stack.split(`
196
+ `).slice(0,f+3).join(`
197
+ `)}`:`${o}: ${a}`}else o=i,a=Gc(r,0),c=`${o}: ${a}`;s.length>0&&(c+=`
198
+ ${s.join(`
199
+ `)}`);super(a);p(this,"_tag");p(this,"traces");p(this,VEe);this._tag=n,this.traces=s,this[RA]=Dse,this.name=o,this.stack=c}pipe(){return pe(this,arguments)}toString(){return this.stack}[(VEe=RA,ft)](){return this.stack}}class qse extends C4{constructor(n,r=[]){super("Die",n,r);p(this,"defect");this.defect=n}}const Mse=(e,t=[])=>new qse(e,t);class Lse extends C4{constructor(t=[]){super("Interrupt","interrupted",t)}}const zse=(e=[])=>new Lse(e),jse=e=>e._tag==="Interrupt",$A=Symbol.for("effect/Micro/MicroFiber"),Use={_A:Ce,_E:Ce};var WEe;class Hse{constructor(t,n=!0){p(this,"context");p(this,"interruptible");p(this,WEe);p(this,"_stack",[]);p(this,"_observers",[]);p(this,"_exit");p(this,"_children");p(this,"currentOpCount",0);p(this,"_interrupted",!1);p(this,"_yielded");this.context=t,this.interruptible=n,this[$A]=Use}getRef(t){return RY(this.context,t)}addObserver(t){return this._exit?(t(this._exit),fd):(this._observers.push(t),()=>{const n=this._observers.indexOf(t);n>=0&&this._observers.splice(n,1)})}unsafeInterrupt(){this._exit||(this._interrupted=!0,this.interruptible&&this.evaluate(dI))}unsafePoll(){return this._exit}evaluate(t){if(this._exit)return;if(this._yielded!==void 0){const s=this._yielded;this._yielded=void 0,s()}const n=this.runLoop(t);if(n===Zy)return;const r=IA.interruptChildren&&IA.interruptChildren(this);if(r!==void 0)return this.evaluate(t0(r,()=>n));this._exit=n;for(let s=0;s<this._observers.length;s++)this._observers[s](n);this._observers.length=0}runLoop(t){let n=!1,r=t;this.currentOpCount=0;try{for(;;){if(this.currentOpCount++,!n&&this.getRef(hI).shouldYield(this)){n=!0;const s=r;r=t0(Gse,()=>s)}if(r=r[nC](this),r===Zy){const s=this._yielded;return ZS in s?(this._yielded=void 0,s):Zy}}}catch(s){return _e(r,nC)?rC(s):rC(`MicroFiber.runLoop: Not a valid effect: ${String(r)}`)}}getCont(t){for(;;){const n=this._stack.pop();if(!n)return;const r=n[e0]&&n[e0](this);if(r)return{[t]:r};if(n[t])return n}}yieldWith(t){return this._yielded=t,Zy}children(){return this._children??(this._children=new Set)}}WEe=$A;const IA=We("effect/Micro/fiberMiddleware",()=>({interruptChildren:void 0})),x4=Symbol.for("effect/Micro/identifier"),Yn=Symbol.for("effect/Micro/args"),nC=Symbol.for("effect/Micro/evaluate"),$d=Symbol.for("effect/Micro/successCont"),Jf=Symbol.for("effect/Micro/failureCont"),e0=Symbol.for("effect/Micro/ensureCont"),Zy=Symbol.for("effect/Micro/Yield"),Bse={_A:Ce,_E:Ce,_R:Ce},Vse={...Nre,_op:"Micro",[Nse]:Bse,pipe(){return pe(this,arguments)},[Symbol.iterator](){return new jq(new Jd(this))},toJSON(){return{_id:"Micro",op:this[x4],...Yn in this?{args:this[Yn]}:void 0}},toString(){return qt(this)},[ft](){return qt(this)}};function Wse(e){return rC("Micro.evaluate: Not implemented")}const Iw=e=>({...Vse,[x4]:e.op,[nC]:e.eval??Wse,[$d]:e.contA,[Jf]:e.contE,[e0]:e.ensure}),lI=e=>{const t=Iw(e);return function(){const n=Object.create(t);return n[Yn]=e.single===!1?arguments:arguments[0],n}},R4=e=>{const t={...Iw(e),[ZS]:ZS,_tag:e.op,get[e.prop](){return this[Yn]},toJSON(){return{_id:"MicroExit",_tag:e.op,[e.prop]:this[Yn]}},[Me](n){return Yse(n)&&n._tag===e.op&&Ne(this[Yn],n[Yn])},[qe](){return At(this,Oe(tn(e.op))(ce(this[Yn])))}};return function(n){const r=Object.create(t);return r[Yn]=n,r[$d]=void 0,r[Jf]=void 0,r[e0]=void 0,r}},cI=R4({op:"Success",prop:"value",eval(e){const t=e.getCont($d);return t?t[$d](this[Yn],e):e.yieldWith(this)}}),$4=R4({op:"Failure",prop:"cause",eval(e){let t=e.getCont(Jf);for(;jse(this[Yn])&&t&&e.interruptible;)t=e.getCont(Jf);return t?t[Jf](this[Yn],e):e.yieldWith(this)}}),Kse=lI({op:"Yield",eval(e){let t=!1;return e.getRef(hI).scheduleTask(()=>{t||e.evaluate(Xse)},this[Yn]??0),e.yieldWith(()=>{t=!0})}}),Gse=Kse(0),Qse=cI(void 0),uI=lI({op:"WithMicroFiber",eval(e){return this[Yn](e)}}),t0=x(2,(e,t)=>{const n=Object.create(Jse);return n[Yn]=e,n[$d]=t,n}),Jse=Iw({op:"OnSuccess",eval(e){return e._stack.push(this),this[Yn]}}),Yse=e=>_e(e,ZS),I4=cI,fI=$4,dI=fI(zse()),rC=e=>fI(Mse(e)),Xse=I4(void 0),Zse="setImmediate"in globalThis?globalThis.setImmediate:e=>setTimeout(e,0);class T4{constructor(){p(this,"tasks",[]);p(this,"running",!1);p(this,"afterScheduled",()=>{this.running=!1,this.runTasks()})}scheduleTask(t,n){this.tasks.push(t),this.running||(this.running=!0,Zse(this.afterScheduled))}runTasks(){const t=this.tasks;this.tasks=[];for(let n=0,r=t.length;n<r;n++)t[n]()}shouldYield(t){return t.currentOpCount>=t.getRef(nie)}flush(){for(;this.tasks.length>0;)this.runTasks()}}const eie=x(2,(e,t)=>uI(n=>{const r=n.context;return n.context=t(r),iie(e,()=>(n.context=r,Qse))})),tie=x(2,(e,t)=>eie(e,xa(t)));class nie extends Im()("effect/Micro/currentMaxOpsBeforeYield",{defaultValue:()=>2048}){}class hI extends Im()("effect/Micro/currentScheduler",{defaultValue:()=>new T4}){}const rie=x(2,(e,t)=>{const n=Object.create(sie);return n[Yn]=e,n[$d]=t.onSuccess,n[Jf]=t.onFailure,n}),sie=Iw({op:"OnSuccessAndFailure",eval(e){return e._stack.push(this),this[Yn]}}),iie=x(2,(e,t)=>aie(n=>rie(n(e),{onFailure:r=>t0(t(fI(r)),()=>$4(r)),onSuccess:r=>t0(t(I4(r)),()=>cI(r))}))),P4=lI({op:"SetInterruptible",ensure(e){if(e.interruptible=this[Yn],e._interrupted&&e.interruptible)return()=>dI}}),oie=e=>uI(t=>t.interruptible?e:(t.interruptible=!0,t._stack.push(P4(!1)),t._interrupted?dI:e)),aie=e=>uI(t=>t.interruptible?(t.interruptible=!1,t._stack.push(P4(!0)),e(oie)):e(Ce)),lie=(e,t)=>{const n=new Hse(hI.context((t==null?void 0:t.scheduler)??new T4));if(n.evaluate(e),t!=null&&t.signal)if(t.signal.aborted)n.unsafeInterrupt();else{const r=()=>n.unsafeInterrupt();t.signal.addEventListener("abort",r,{once:!0}),n.addObserver(()=>t.signal.removeEventListener("abort",r))}return n};class O4{constructor(){p(this,"buckets",[])}scheduleTask(t,n){const r=this.buckets.length;let s,i=0;for(;i<r&&this.buckets[i][0]<=n;i++)s=this.buckets[i];s&&s[0]===n?s[1].push(t):i===r?this.buckets.push([n,[t]]):this.buckets.splice(i,0,[n,[t]])}}class cie{constructor(t){p(this,"maxNextTickBeforeTimer");p(this,"running",!1);p(this,"tasks",new O4);this.maxNextTickBeforeTimer=t}starveInternal(t){const n=this.tasks.buckets;this.tasks.buckets=[];for(const[r,s]of n)for(let i=0;i<s.length;i++)s[i]();this.tasks.buckets.length===0?this.running=!1:this.starve(t)}starve(t=0){t>=this.maxNextTickBeforeTimer?setTimeout(()=>this.starveInternal(0),0):Promise.resolve(void 0).then(()=>this.starveInternal(t+1))}shouldYield(t){return t.currentOpCount>t.getFiberRef(Ez)?t.getFiberRef(Pu):!1}scheduleTask(t,n){this.tasks.scheduleTask(t,n),this.running||(this.running=!0,this.starve())}}const A4=We(Symbol.for("effect/Scheduler/defaultScheduler"),()=>new cie(2048));class F4{constructor(){p(this,"tasks",new O4);p(this,"deferred",!1)}scheduleTask(t,n){this.deferred?A4.scheduleTask(t,n):this.tasks.scheduleTask(t,n)}shouldYield(t){return t.currentOpCount>t.getFiberRef(Ez)?t.getFiberRef(Pu):!1}flush(){for(;this.tasks.buckets.length>0;){const t=this.tasks.buckets;this.tasks.buckets=[];for(const[n,r]of t)for(let s=0;s<r.length;s++)r[s]()}this.deferred=!0}}const Tw=We(Symbol.for("effect/FiberRef/currentScheduler"),()=>yr(A4)),N4=We(Symbol.for("effect/FiberRef/currentRequestMap"),()=>yr(new Map)),TA=(e,t,n,r)=>{switch(e){case void 0:return t();case"unbounded":return n();case"inherit":return ah(Rte,s=>s==="unbounded"?n():s>1?r(s):t());default:return e>1?r(e):t()}},pI="InterruptSignal",gI="Stateful",mI="Resume",yI="YieldNow",N1=e=>({_tag:pI,cause:e}),z_=e=>({_tag:gI,onFiber:e}),Zu=e=>({_tag:mI,effect:e}),uie=()=>({_tag:yI}),fie="effect/FiberScope",n0=Symbol.for(fie);var KEe;class die{constructor(){p(this,KEe,n0);p(this,"fiberId",Nr);p(this,"roots",new Set)}add(t,n){this.roots.add(n),n.addObserver(()=>{this.roots.delete(n)})}}KEe=n0;var GEe;class hie{constructor(t,n){p(this,"fiberId");p(this,"parent");p(this,GEe,n0);this.fiberId=t,this.parent=n}add(t,n){this.parent.tell(z_(r=>{r.addChild(n),n.addObserver(()=>{r.removeChild(n)})}))}}GEe=n0;const pie=e=>new hie(e.id(),e),Gm=We(Symbol.for("effect/FiberScope/Global"),()=>new die),gie="effect/Fiber",D4=Symbol.for(gie),q4={_E:e=>e,_A:e=>e},mie={[D4]:q4,pipe(){return pe(this,arguments)}},yie="effect/Fiber",_ie=Symbol.for(yie),M4=e=>e.await,Sie=e=>e.inheritAll,vie=x(2,(e,t)=>T(fu(e,L4(t)),kt(T(e,fu(M4))))),L4=x(2,(e,t)=>e.interruptAsFork(t)),pu=e=>gl(oh(e.await),e.inheritAll);({...ka,...mie});const Ma="effect/FiberCurrent",wie=()=>bu(globalThis[Ma]),bie="effect/Logger",Eie=Symbol.for(bie),kie={_Message:e=>e,_Output:e=>e},Qm=e=>({[Eie]:kie,log:e,pipe(){return pe(this,arguments)}}),Cie=/^[^\s"=]*$/,xie=(e,t)=>({annotations:n,cause:r,date:s,fiberId:i,logLevel:o,message:a,spans:c})=>{const f=k=>k.match(Cie)?k:e(k),d=(k,I)=>`${Xz(k)}=${f(I)}`,g=(k,I)=>" "+d(k,I);let _=d("timestamp",s.toISOString());_+=g("level",o.label),_+=g("fiber",iw(i));const b=VR(a);for(let k=0;k<b.length;k++)_+=g("message",Gc(b[k],t));Dee(r)||(_+=g("cause",Bl(r,{renderErrorCause:!0})));for(const k of c)_+=" "+eI(s.getTime())(k);for(const[k,I]of n)_+=g(k,Gc(I,t));return _},Rie=e=>`"${e.replace(/\\([\s\S])|(")/g,"\\$1$2")}"`,$ie=Qm(xie(Rie)),z4=e=>{switch(typeof e){case"bigint":case"function":case"symbol":return String(e);default:return sn(e)}},Iie=(e,...t)=>{let n="";for(let r=0;r<t.length;r++)n+=`\x1B[${t[r]}m`;return n+e+"\x1B[0m"},Tie=(e,...t)=>e,Ys={bold:"1",red:"31",green:"32",yellow:"33",blue:"34",cyan:"36",white:"37",gray:"90",black:"30",bgBrightRed:"101"},Pie={None:[],All:[],Trace:[Ys.gray],Debug:[Ys.blue],Info:[Ys.green],Warning:[Ys.yellow],Error:[Ys.red],Fatal:[Ys.bgBrightRed,Ys.black]},Oie={None:"",All:"",Trace:"color:gray",Debug:"color:blue",Info:"color:green",Warning:"color:orange",Error:"color:red",Fatal:"background-color:red;color:white"},Aie=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`,j4=typeof process=="object"&&process!==null&&typeof process.stdout=="object"&&process.stdout!==null,Fie=j4&&process.stdout.isTTY===!0,Nie=j4||"Deno"in globalThis,Die=e=>{const t=(e==null?void 0:e.mode)??"auto",r=(t==="auto"?Nie?"tty":"browser":t)==="browser",s=typeof(e==null?void 0:e.colors)=="boolean"?e.colors:Fie||r,i=(e==null?void 0:e.formatDate)??Aie;return r?Mie({colors:s,formatDate:i}):qie({colors:s,formatDate:i,stderr:(e==null?void 0:e.stderr)===!0})},qie=e=>{const t=typeof process=="object"&&"isBun"in process&&process.isBun===!0,n=e.colors?Iie:Tie;return Qm(({annotations:r,cause:s,context:i,date:o,fiberId:a,logLevel:c,message:f,spans:d})=>{const g=xw(i,bo),_=hs(g,Cw).unsafe,b=e.stderr===!0?_.error:_.log,k=VR(f);let I=n(`[${e.formatDate(o)}]`,Ys.white)+` ${n(c.label,...Pie[c._tag])} (${iw(a)})`;if(y$(d)){const y=o.getTime(),m=eI(y);for(const v of d)I+=" "+m(v)}I+=":";let E=0;if(k.length>0){const y=z4(k[0]);typeof y=="string"&&(I+=" "+n(y,Ys.bold,Ys.cyan),E++)}if(b(I),t||_.group(),b$(s)||b(Bl(s,{renderErrorCause:!0})),E<k.length)for(;E<k.length;E++)b(Qc(k[E]));if(jL(r)>0)for(const[y,m]of r)b(n(`${y}:`,Ys.bold,Ys.white),Qc(m));t||_.groupEnd()})},Mie=e=>{const t=e.colors?"%c":"";return Qm(({annotations:n,cause:r,context:s,date:i,fiberId:o,logLevel:a,message:c,spans:f})=>{const d=xw(s,bo),g=hs(d,Cw).unsafe,_=VR(c);let b=`${t}[${e.formatDate(i)}]`;const k=[];if(e.colors&&k.push("color:gray"),b+=` ${t}${a.label}${t} (${iw(o)})`,e.colors&&k.push(Oie[a._tag],""),y$(f)){const E=i.getTime(),y=eI(E);for(const m of f)b+=" "+y(m)}b+=":";let I=0;if(_.length>0){const E=z4(_[0]);typeof E=="string"&&(b+=` ${t}${E}`,e.colors&&k.push("color:deepskyblue"),I++)}if(g.groupCollapsed(b,...k),b$(r)||g.error(Bl(r,{renderErrorCause:!0})),I<_.length)for(;I<_.length;I++)g.log(Qc(_[I]));if(jL(n)>0)for(const[E,y]of n){const m=Qc(y);e.colors?g.log(`%c${E}:`,"color:gray",m):g.log(`${E}:`,m)}g.groupEnd()})},U4="effect/MetricBoundaries",sC=Symbol.for(U4);var QEe;class Lie{constructor(t){p(this,"values");p(this,QEe,sC);p(this,"_hash");this.values=t,this._hash=T(tn(U4),Oe(wm(this.values)))}[(QEe=sC,qe)](){return this._hash}[Me](t){return zie(t)&&Ne(this.values,t.values)}pipe(){return pe(this,arguments)}}const zie=e=>_e(e,sC),jie=e=>{const t=T(e,Dv(Xt(Number.POSITIVE_INFINITY)),dJ);return new Lie(t)},Uie=e=>T(WQ(e.count-1,t=>e.start*Math.pow(e.factor,t)),xn,jie),Hie="effect/MetricKeyType",H4=Symbol.for(Hie),B4="effect/MetricKeyType/Counter",iC=Symbol.for(B4),Bie="effect/MetricKeyType/Frequency",Vie=Symbol.for(Bie),Wie="effect/MetricKeyType/Gauge",Kie=Symbol.for(Wie),V4="effect/MetricKeyType/Histogram",oC=Symbol.for(V4),Gie="effect/MetricKeyType/Summary",Qie=Symbol.for(Gie),W4={_In:e=>e,_Out:e=>e};var JEe,YEe;class Jie{constructor(t,n){p(this,"incremental");p(this,"bigint");p(this,JEe,W4);p(this,YEe,iC);p(this,"_hash");this.incremental=t,this.bigint=n,this._hash=tn(B4)}[(JEe=H4,YEe=iC,qe)](){return this._hash}[Me](t){return K4(t)}pipe(){return pe(this,arguments)}}var XEe,ZEe;class Yie{constructor(t){p(this,"boundaries");p(this,XEe,W4);p(this,ZEe,oC);p(this,"_hash");this.boundaries=t,this._hash=T(tn(V4),Oe(ce(this.boundaries)))}[(XEe=H4,ZEe=oC,qe)](){return this._hash}[Me](t){return G4(t)&&Ne(this.boundaries,t.boundaries)}pipe(){return pe(this,arguments)}}const Xie=e=>new Jie((e==null?void 0:e.incremental)??!1,(e==null?void 0:e.bigint)??!1),Zie=e=>new Yie(e),K4=e=>_e(e,iC),eoe=e=>_e(e,Vie),toe=e=>_e(e,Kie),G4=e=>_e(e,oC),noe=e=>_e(e,Qie),roe="effect/MetricKey",Q4=Symbol.for(roe),soe={_Type:e=>e},ioe=Cm(Ne);var eke;class _I{constructor(t,n,r,s=[]){p(this,"name");p(this,"keyType");p(this,"description");p(this,"tags");p(this,eke,soe);p(this,"_hash");this.name=t,this.keyType=n,this.description=r,this.tags=s,this._hash=T(tn(this.name+this.description),Oe(ce(this.keyType)),Oe(wm(this.tags)))}[(eke=Q4,qe)](){return this._hash}[Me](t){return ooe(t)&&this.name===t.name&&Ne(this.keyType,t.keyType)&&Ne(this.description,t.description)&&ioe(this.tags,t.tags)}pipe(){return pe(this,arguments)}}const ooe=e=>_e(e,Q4),aoe=(e,t)=>new _I(e,Xie(t),bu(t==null?void 0:t.description)),loe=(e,t,n)=>new _I(e,Zie(t),bu(n)),coe=x(2,(e,t)=>t.length===0?e:new _I(e.name,e.keyType,e.description,P_(e.tags,t))),uoe="effect/MetricState",Jm=Symbol.for(uoe),J4="effect/MetricState/Counter",aC=Symbol.for(J4),Y4="effect/MetricState/Frequency",lC=Symbol.for(Y4),X4="effect/MetricState/Gauge",cC=Symbol.for(X4),Z4="effect/MetricState/Histogram",uC=Symbol.for(Z4),ej="effect/MetricState/Summary",fC=Symbol.for(ej),Ym={_A:e=>e};var tke,nke;class foe{constructor(t){p(this,"count");p(this,tke,Ym);p(this,nke,aC);this.count=t}[(tke=Jm,nke=aC,qe)](){return T(ce(J4),Oe(ce(this.count)),At(this))}[Me](t){return boe(t)&&this.count===t.count}pipe(){return pe(this,arguments)}}const doe=Cm(Ne);var rke,ske;class hoe{constructor(t){p(this,"occurrences");p(this,rke,Ym);p(this,ske,lC);p(this,"_hash");this.occurrences=t}[(rke=Jm,ske=lC,qe)](){return T(tn(Y4),Oe(wm(gt(this.occurrences.entries()))),At(this))}[Me](t){return Eoe(t)&&doe(gt(this.occurrences.entries()),gt(t.occurrences.entries()))}pipe(){return pe(this,arguments)}}var ike,oke;class poe{constructor(t){p(this,"value");p(this,ike,Ym);p(this,oke,cC);this.value=t}[(ike=Jm,oke=cC,qe)](){return T(ce(X4),Oe(ce(this.value)),At(this))}[Me](t){return koe(t)&&this.value===t.value}pipe(){return pe(this,arguments)}}var ake,lke;class goe{constructor(t,n,r,s,i){p(this,"buckets");p(this,"count");p(this,"min");p(this,"max");p(this,"sum");p(this,ake,Ym);p(this,lke,uC);this.buckets=t,this.count=n,this.min=r,this.max=s,this.sum=i}[(ake=Jm,lke=uC,qe)](){return T(ce(Z4),Oe(ce(this.buckets)),Oe(ce(this.count)),Oe(ce(this.min)),Oe(ce(this.max)),Oe(ce(this.sum)),At(this))}[Me](t){return Coe(t)&&Ne(this.buckets,t.buckets)&&this.count===t.count&&this.min===t.min&&this.max===t.max&&this.sum===t.sum}pipe(){return pe(this,arguments)}}var cke,uke;class moe{constructor(t,n,r,s,i,o){p(this,"error");p(this,"quantiles");p(this,"count");p(this,"min");p(this,"max");p(this,"sum");p(this,cke,Ym);p(this,uke,fC);this.error=t,this.quantiles=n,this.count=r,this.min=s,this.max=i,this.sum=o}[(cke=Jm,uke=fC,qe)](){return T(ce(ej),Oe(ce(this.error)),Oe(ce(this.quantiles)),Oe(ce(this.count)),Oe(ce(this.min)),Oe(ce(this.max)),Oe(ce(this.sum)),At(this))}[Me](t){return xoe(t)&&this.error===t.error&&Ne(this.quantiles,t.quantiles)&&this.count===t.count&&this.min===t.min&&this.max===t.max&&this.sum===t.sum}pipe(){return pe(this,arguments)}}const yoe=e=>new foe(e),_oe=e=>new hoe(e),Soe=e=>new poe(e),voe=e=>new goe(e.buckets,e.count,e.min,e.max,e.sum),woe=e=>new moe(e.error,e.quantiles,e.count,e.min,e.max,e.sum),boe=e=>_e(e,aC),Eoe=e=>_e(e,lC),koe=e=>_e(e,cC),Coe=e=>_e(e,uC),xoe=e=>_e(e,fC),Roe="effect/MetricHook",$oe=Symbol.for(Roe),Ioe={_In:e=>e,_Out:e=>e},Xm=e=>({[$oe]:Ioe,pipe(){return pe(this,arguments)},...e}),PA=BigInt(0),Toe=e=>{let t=e.keyType.bigint?PA:0;const n=e.keyType.incremental?e.keyType.bigint?s=>s>=PA:s=>s>=0:s=>!0,r=s=>{n(s)&&(t=t+s)};return Xm({get:()=>yoe(t),update:r,modify:r})},Poe=e=>{const t=new Map;for(const r of e.keyType.preregisteredWords)t.set(r,0);const n=r=>{const s=t.get(r)??0;t.set(r,s+1)};return Xm({get:()=>_oe(t),update:n,modify:n})},Ooe=(e,t)=>{let n=t;return Xm({get:()=>Soe(n),update:r=>{n=r},modify:r=>{n=n+r}})},Aoe=e=>{const t=e.keyType.boundaries.values,n=t.length,r=new Uint32Array(n+1),s=new Float32Array(n);let i=0,o=0,a=Number.MAX_VALUE,c=Number.MIN_VALUE;T(t,hg(dd),Zo((g,_)=>{s[_]=g}));const f=g=>{let _=0,b=n;for(;_!==b;){const k=Math.floor(_+(b-_)/2),I=s[k];g<=I?b=k:_=k,b===_+1&&(g<=s[_]?b=_:_=b)}r[_]=r[_]+1,i=i+1,o=o+g,g<a&&(a=g),g>c&&(c=g)},d=()=>{const g=Nv(n);let _=0;for(let b=0;b<n;b++){const k=s[b],I=r[b];_=_+I,g[b]=[k,_]}return g};return Xm({get:()=>voe({buckets:d(),count:i,min:a,max:c,sum:o}),update:f,modify:f})},Foe=e=>{const{error:t,maxAge:n,maxSize:r,quantiles:s}=e.keyType,i=T(s,hg(dd)),o=Nv(r);let a=0,c=0,f=0,d=0,g=0;const _=k=>{const I=[];let E=0;for(;E!==r-1;){const y=o[E];if(y!=null){const[m,v]=y,w=nu(k-m);sX(w,yL)&&rX(w,n)&&I.push(v)}E=E+1}return Noe(t,i,hg(I,dd))},b=(k,I)=>{if(r>0){a=a+1;const E=a%r;o[E]=[I,k]}d=c===0?k:Math.min(d,k),g=c===0?k:Math.max(g,k),c=c+1,f=f+k};return Xm({get:()=>woe({error:t,quantiles:_(Date.now()),count:c,min:d,max:g,sum:f}),update:([k,I])=>b(k,I),modify:([k,I])=>b(k,I)})},Noe=(e,t,n)=>{const r=n.length;if(!Kt(t))return bl();const s=t[0],i=t.slice(1),o=OA(e,r,re(),0,s,n),a=$s(o);return i.forEach(c=>{a.push(OA(e,r,o.value,o.consumed,c,o.rest))}),Zo(a,c=>[c.quantile,c.value])},OA=(e,t,n,r,s,i)=>{let o=e,a=t,c=n,f=r,d=s,g=i,_=e,b=t,k=n,I=r,E=s,y=i;for(;;){if(!Kt(g))return{quantile:d,value:re(),consumed:f,rest:[]};if(d===1)return{quantile:d,value:oe(hM(g)),consumed:f+g.length,rest:[]};const m=Kr(g),v=gM(g,A=>A===m),w=d*a,$=o/2*w,P=f+v[0].length,O=Math.abs(P-w);if(P<w-$){_=o,b=a,k=zf(g),I=P,E=d,y=v[1],o=_,a=b,c=k,f=I,d=E,g=y;continue}if(P>w+$){const A=on(c)?oe(m):c;return{quantile:d,value:A,consumed:f,rest:g}}switch(c._tag){case"None":{_=o,b=a,k=zf(g),I=P,E=d,y=v[1],o=_,a=b,c=k,f=I,d=E,g=y;continue}case"Some":{const A=Math.abs(w-c.value);if(O<A){_=o,b=a,k=zf(g),I=P,E=d,y=v[1],o=_,a=b,c=k,f=I,d=E,g=y;continue}return{quantile:d,value:oe(c.value),consumed:f,rest:g}}}}throw new Error("BUG: MetricHook.resolveQuantiles - please report an issue at https://github.com/Effect-TS/effect/issues")},Doe="effect/MetricPair",qoe=Symbol.for(Doe),Moe={_Type:e=>e},Loe=(e,t)=>({[qoe]:Moe,metricKey:e,metricState:t,pipe(){return pe(this,arguments)}}),zoe="effect/MetricRegistry",AA=Symbol.for(zoe);var fke;class joe{constructor(){p(this,fke,AA);p(this,"map",Oz())}snapshot(){const t=[];for(const[n,r]of this.map)t.push(Loe(n,r.get()));return t}get(t){const n=T(this.map,eo(t),ti);if(n==null){if(K4(t.keyType))return this.getCounter(t);if(toe(t.keyType))return this.getGauge(t);if(eoe(t.keyType))return this.getFrequency(t);if(G4(t.keyType))return this.getHistogram(t);if(noe(t.keyType))return this.getSummary(t);throw new Error("BUG: MetricRegistry.get - unknown MetricKeyType - please report an issue at https://github.com/Effect-TS/effect/issues")}else return n}getCounter(t){let n=T(this.map,eo(t),ti);if(n==null){const r=Toe(t);T(this.map,of(t))||T(this.map,af(t,r)),n=r}return n}getFrequency(t){let n=T(this.map,eo(t),ti);if(n==null){const r=Poe(t);T(this.map,of(t))||T(this.map,af(t,r)),n=r}return n}getGauge(t){let n=T(this.map,eo(t),ti);if(n==null){const r=Ooe(t,t.keyType.bigint?BigInt(0):0);T(this.map,of(t))||T(this.map,af(t,r)),n=r}return n}getHistogram(t){let n=T(this.map,eo(t),ti);if(n==null){const r=Aoe(t);T(this.map,of(t))||T(this.map,af(t,r)),n=r}return n}getSummary(t){let n=T(this.map,eo(t),ti);if(n==null){const r=Foe(t);T(this.map,of(t))||T(this.map,af(t,r)),n=r}return n}}fke=AA;const Uoe=()=>new joe,Hoe="effect/Metric",Boe=Symbol.for(Hoe),Voe={_Type:e=>e,_In:e=>e,_Out:e=>e},FA=We(Symbol.for("effect/Metric/globalMetricRegistry"),()=>Uoe()),tj=function(e,t,n,r){const s=Object.assign(i=>ya(i,o=>Qoe(s,o)),{[Boe]:Voe,keyType:e,unsafeUpdate:t,unsafeValue:n,unsafeModify:r,register(){return this.unsafeValue([]),this},pipe(){return pe(this,arguments)}});return s},Pw=(e,t)=>nj(aoe(e,t)),nj=e=>{let t;const n=new WeakMap,r=s=>{if(s.length===0)return t!==void 0||(t=FA.get(e)),t;let i=n.get(s);return i!==void 0||(i=FA.get(coe(e,s)),n.set(s,i)),i};return tj(e.keyType,(s,i)=>r(i).update(s),s=>r(s).get(),(s,i)=>r(i).modify(s))},Woe=(e,t,n)=>nj(loe(e,t,n)),Koe=x(3,(e,t,n)=>Goe(e,[Wre(t,n)])),Goe=x(2,(e,t)=>tj(e.keyType,(n,r)=>e.unsafeUpdate(n,P_(t,r)),n=>e.unsafeValue(P_(t,n)),(n,r)=>e.unsafeModify(n,P_(t,r)))),Qoe=x(2,(e,t)=>ah(Uk,n=>se(()=>e.unsafeUpdate(t,n)))),Joe="effect/Request",Yoe=Symbol.for(Joe),Xoe={_E:e=>e,_A:e=>e},Zoe={...zR,[Yoe]:Xoe},eae=function(){function e(t){t&&Object.assign(this,t)}return e.prototype=Zoe,e}(),tae=x(2,(e,t)=>ah(N4,n=>se(()=>{if(n.has(e)){const r=n.get(e);r.state.completed||(r.state.completed=!0,Bm(r.result,t))}}))),nae="effect/Supervisor",Ow=Symbol.for(nae),SI={_T:e=>e};var dke;const $2=class $2{constructor(t,n){p(this,"underlying");p(this,"value0");p(this,dke,SI);this.underlying=t,this.value0=n}get value(){return this.value0}onStart(t,n,r,s){this.underlying.onStart(t,n,r,s)}onEnd(t,n){this.underlying.onEnd(t,n)}onEffect(t,n){this.underlying.onEffect(t,n)}onSuspend(t){this.underlying.onSuspend(t)}onResume(t){this.underlying.onResume(t)}map(t){return new $2(this,T(this.value,Fe(t)))}zip(t){return new s0(this,t)}};dke=Ow;let r0=$2;var hke;const I2=class I2{constructor(t,n){p(this,"left");p(this,"right");p(this,"_tag","Zip");p(this,hke,SI);this.left=t,this.right=n}get value(){return mw(this.left.value,this.right.value)}onStart(t,n,r,s){this.left.onStart(t,n,r,s),this.right.onStart(t,n,r,s)}onEnd(t,n){this.left.onEnd(t,n),this.right.onEnd(t,n)}onEffect(t,n){this.left.onEffect(t,n),this.right.onEffect(t,n)}onSuspend(t){this.left.onSuspend(t),this.right.onSuspend(t)}onResume(t){this.left.onResume(t),this.right.onResume(t)}map(t){return new r0(this,T(this.value,Fe(t)))}zip(t){return new I2(this,t)}};hke=Ow;let s0=I2;const rj=e=>_e(e,Ow)&&NR(e,"Zip");var pke;class rae{constructor(t){p(this,"effect");p(this,pke,SI);this.effect=t}get value(){return this.effect}onStart(t,n,r,s){}onEnd(t,n){}onEffect(t,n){}onSuspend(t){}onResume(t){}map(t){return new r0(this,T(this.value,Fe(t)))}zip(t){return new s0(this,t)}onRun(t,n){return t()}}pke=Ow;const sae=e=>new rae(e),Aw=We("effect/Supervisor/none",()=>sae(Ve)),iae=eh,sj="Empty",ij="AddSupervisor",oj="RemoveSupervisor",aj="AndThen",Op={_tag:sj},j_=(e,t)=>({_tag:aj,first:e,second:t}),oae=(e,t)=>aae(t,Xt(e)),aae=(e,t)=>{let n=e,r=t;for(;vo(r);){const s=co(r);switch(s._tag){case sj:{r=Ko(r);break}case ij:{n=n.zip(s.supervisor),r=Ko(r);break}case oj:{n=dC(n,s.supervisor),r=Ko(r);break}case aj:{r=xr(s.first)(xr(s.second)(Ko(r)));break}}}return n},dC=(e,t)=>Ne(e,t)?Aw:rj(e)?dC(e.left,t).zip(dC(e.right,t)):e,i0=e=>Ne(e,Aw)?iu():rj(e)?T(i0(e.left),_g(i0(e.right))):nw(e),lae=(e,t)=>{if(Ne(e,t))return Op;const n=i0(e),r=i0(t),s=T(r,jO(n),Sg(Op,(o,a)=>j_(o,{_tag:ij,supervisor:a}))),i=T(n,jO(r),Sg(Op,(o,a)=>j_(o,{_tag:oj,supervisor:a})));return j_(s,i)},cae=iae({empty:Op,patch:oae,combine:j_,diff:lae}),uae=Pw("effect_fiber_started",{incremental:!0}),NA=Pw("effect_fiber_active"),fae=Pw("effect_fiber_successes",{incremental:!0}),dae=Pw("effect_fiber_failures",{incremental:!0}),hae=Koe(Woe("effect_fiber_lifetimes",Uie({start:.5,factor:2,count:35})),"time_unit","milliseconds"),Wh="Continue",pae="Done",DA="Yield",gae={_E:e=>e,_A:e=>e},e_=e=>{throw new Error(`BUG: FiberRuntime - ${Gc(e)} - please report an issue at https://github.com/Effect-TS/effect/issues`)},Fo=Symbol.for("effect/internal/fiberRuntime/YieldedOp"),No=We("effect/internal/fiberRuntime/yieldedOpChannel",()=>({currentOp:null})),Kh={[xS]:(e,t,n)=>Bt(()=>t.effect_instruction_i1(n)),OnStep:(e,t,n)=>St(St(n)),[RS]:(e,t,n)=>Bt(()=>t.effect_instruction_i2(n)),[LR]:(e,t,n)=>(e.patchRuntimeFlags(e.currentRuntimeFlags,t.patch),ja(e.currentRuntimeFlags)&&e.isInterrupted()?xt(e.getInterruptedCause()):St(n)),[$S]:(e,t,n)=>(Bt(()=>t.effect_instruction_i2(n)),Bt(()=>t.effect_instruction_i0())?(e.pushStack(t),Bt(()=>t.effect_instruction_i1())):Ve),[Tp]:(e,t,n)=>{const r=Bt(()=>t.effect_instruction_i0.next(n));return r.done?St(r.value):(e.pushStack(t),Hq(r.value))}},mae={[pI]:(e,t,n,r)=>(e.processNewInterruptSignal(r.cause),ja(t)?xt(r.cause):n),[mI]:(e,t,n,r)=>{throw new Error("It is illegal to have multiple concurrent run loops in a single fiber")},[gI]:(e,t,n,r)=>(r.onFiber(e,k4(t)),n),[yI]:(e,t,n,r)=>Z(Lm(),()=>n)},yae=e=>fu(vee(e),t=>ra(Fee(t),([n,r])=>{const s=new Map,i=[];for(const a of r){i.push(di(a));for(const c of a)s.set(c.request,c)}const o=i.flat();return Tu(Lae(n.runAll(i),o,()=>o.forEach(a=>{a.listeners.interrupted=!0})),N4,s)},!1,!1)),_ae=$v();var gke,mke;class lj extends Io{constructor(n,r,s){super();p(this,gke,q4);p(this,mke,gae);p(this,"_fiberRefs");p(this,"_fiberId");p(this,"_queue",new Array);p(this,"_children",null);p(this,"_observers",new Array);p(this,"_running",!1);p(this,"_stack",[]);p(this,"_asyncInterruptor",null);p(this,"_asyncBlockingOn",null);p(this,"_exitValue",null);p(this,"_steps",[]);p(this,"_isYielding",!1);p(this,"currentRuntimeFlags");p(this,"currentOpCount",0);p(this,"currentSupervisor");p(this,"currentScheduler");p(this,"currentTracer");p(this,"currentSpan");p(this,"currentContext");p(this,"currentDefaultServices");p(this,"run",()=>{this.drainQueueOnCurrentThread()});if(this.currentRuntimeFlags=s,this._fiberId=n,this._fiberRefs=r,KO(s)){const i=this.getFiberRef(Uk);uae.unsafeUpdate(1,i),NA.unsafeUpdate(1,i)}this.refreshRefCache()}commit(){return pu(this)}id(){return this._fiberId}resume(n){this.tell(Zu(n))}get status(){return this.ask((n,r)=>r)}get runtimeFlags(){return this.ask((n,r)=>Fse(r)?n.currentRuntimeFlags:r.runtimeFlags)}scope(){return pie(this)}get children(){return this.ask(n=>Array.from(n.getChildren()))}getChildren(){return this._children===null&&(this._children=new Set),this._children}getInterruptedCause(){return this.getFiberRef(Xy)}fiberRefs(){return this.ask(n=>n.getFiberRefs())}ask(n){return Ee(()=>{const r=Um(this._fiberId);return this.tell(z_((s,i)=>{Bm(r,se(()=>n(s,i)))})),Li(r)})}tell(n){this._queue.push(n),this._running||(this._running=!0,this.drainQueueLaterOnExecutor())}get await(){return Mi(n=>{const r=s=>n(ie(s));return this.tell(z_((s,i)=>{s._exitValue!==null?r(this._exitValue):s.addObserver(r)})),se(()=>this.tell(z_((s,i)=>{s.removeObserver(r)})))},this.id())}get inheritAll(){return et((n,r)=>{const s=n.id(),i=n.getFiberRefs(),o=r.runtimeFlags,a=this.getFiberRefs(),c=bre(i,s,a);n.setFiberRefs(c);const f=n.getFiberRef(zA),d=T(pl(o,f),QO(th),QO(Lk));return _z(d)})}get poll(){return se(()=>bu(this._exitValue))}unsafePoll(){return this._exitValue}interruptAsFork(n){return se(()=>this.tell(N1(ri(n))))}unsafeInterruptAsFork(n){this.tell(N1(ri(n)))}addObserver(n){this._exitValue!==null?n(this._exitValue):this._observers.push(n)}removeObserver(n){this._observers=this._observers.filter(r=>r!==n)}getFiberRefs(){return this.setFiberRef(zA,this.currentRuntimeFlags),this._fiberRefs}unsafeDeleteFiberRef(n){this._fiberRefs=Gz(this._fiberRefs,n)}getFiberRef(n){return this._fiberRefs.locals.has(n)?this._fiberRefs.locals.get(n)[0][1]:n.initial}setFiberRef(n,r){this._fiberRefs=Gk(this._fiberRefs,{fiberId:this._fiberId,fiberRef:n,value:r}),this.refreshRefCache()}refreshRefCache(){this.currentDefaultServices=this.getFiberRef(bo),this.currentTracer=this.currentDefaultServices.unsafeMap.get(Wm.key),this.currentSupervisor=this.getFiberRef(qae),this.currentScheduler=this.getFiberRef(Tw),this.currentContext=this.getFiberRef(Hi),this.currentSpan=this.currentContext.unsafeMap.get(kl.key)}setFiberRefs(n){this._fiberRefs=n,this.refreshRefCache()}addChild(n){this.getChildren().add(n)}removeChild(n){this.getChildren().delete(n)}transferChildren(n){const r=this._children;if(this._children=null,r!==null&&r.size>0)for(const s of r)s._exitValue===null&&n.add(this.currentRuntimeFlags,s)}drainQueueOnCurrentThread(){let n=!0;for(;n;){let r=Wh;const s=globalThis[Ma];globalThis[Ma]=this;try{for(;r===Wh;)r=this._queue.length===0?pae:this.evaluateMessageWhileSuspended(this._queue.splice(0,1)[0])}finally{this._running=!1,globalThis[Ma]=s}this._queue.length>0&&!this._running?(this._running=!0,r===DA?(this.drainQueueLaterOnExecutor(),n=!1):n=!0):n=!1}}drainQueueLaterOnExecutor(){this.currentScheduler.scheduleTask(this.run,this.getFiberRef(Pu))}drainQueueWhileRunning(n,r){let s=r;for(;this._queue.length>0;){const i=this._queue.splice(0,1)[0];s=mae[i._tag](this,n,s,i)}return s}isInterrupted(){return!b$(this.getFiberRef(Xy))}addInterruptedCause(n){const r=this.getFiberRef(Xy);this.setFiberRef(Xy,zn(r,n))}processNewInterruptSignal(n){this.addInterruptedCause(n),this.sendInterruptSignalToAllChildren()}sendInterruptSignalToAllChildren(){if(this._children===null||this._children.size===0)return!1;let n=!1;for(const r of this._children)r.tell(N1(ri(this.id()))),n=!0;return n}interruptAllChildren(){if(this.sendInterruptSignalToAllChildren()){const n=this._children.values();this._children=null;let r=!1;return A$({while:()=>!r,body:()=>{const i=n.next();return i.done?se(()=>{r=!0}):vs(i.value.await)},step:()=>{}})}return null}reportExitValue(n){if(KO(this.currentRuntimeFlags)){const r=this.getFiberRef(Uk),s=this.id().startTimeMillis,i=Date.now();switch(hae.unsafeUpdate(i-s,r),NA.unsafeUpdate(-1,r),n._tag){case nr:{fae.unsafeUpdate(1,r);break}case tr:{dae.unsafeUpdate(1,r);break}}}if(n._tag==="Failure"){const r=this.getFiberRef(N$);!uw(n.cause)&&r._tag==="Some"&&this.log("Fiber terminated with an unhandled error",n.cause,r)}}setExitValue(n){this._exitValue=n,this.reportExitValue(n);for(let r=this._observers.length-1;r>=0;r--)this._observers[r](n);this._observers=[]}getLoggers(){return this.getFiberRef(Fw)}log(n,r,s){const i=Wt(s)?s.value:this.getFiberRef(kte),o=this.getFiberRef(cj);if(Are(o,i))return;const a=this.getFiberRef(Cte),c=this.getFiberRef(kz),f=this.getLoggers(),d=this.getFiberRefs();if(d$(f)>0){const g=hs(this.getFiberRef(bo),Ou),_=new Date(g.unsafeCurrentTimeMillis());rQ(d,()=>{for(const b of f)b.log({fiberId:this.id(),logLevel:i,message:n,cause:r,context:d,spans:a,annotations:c,date:_})})}}evaluateMessageWhileSuspended(n){switch(n._tag){case yI:return DA;case pI:return this.processNewInterruptSignal(n.cause),this._asyncInterruptor!==null&&(this._asyncInterruptor(xt(n.cause)),this._asyncInterruptor=null),Wh;case mI:return this._asyncInterruptor=null,this._asyncBlockingOn=null,this.evaluateEffect(n.effect),Wh;case gI:return n.onFiber(this,this._exitValue!==null?Ose:Ase(this.currentRuntimeFlags,this._asyncBlockingOn)),Wh;default:return e_(n)}}evaluateEffect(n){this.currentSupervisor.onResume(this);try{let r=ja(this.currentRuntimeFlags)&&this.isInterrupted()?xt(this.getInterruptedCause()):n;for(;r!==null;){const s=r,i=this.runLoop(s);if(i===Fo){const o=No.currentOp;No.currentOp=null,o._op===I_?gee(this.currentRuntimeFlags)?(this.tell(uie()),this.tell(Zu(wr)),r=null):r=wr:o._op===Ip&&(r=null)}else{this.currentRuntimeFlags=T(this.currentRuntimeFlags,mee(Lk));const o=this.interruptAllChildren();o!==null?r=Z(o,()=>i):(this._queue.length===0?this.setExitValue(i):this.tell(Zu(i)),r=null)}}}finally{this.currentSupervisor.onSuspend(this)}}start(n){if(this._running)this.tell(Zu(n));else{this._running=!0;const r=globalThis[Ma];globalThis[Ma]=this;try{this.evaluateEffect(n)}finally{this._running=!1,globalThis[Ma]=r,this._queue.length>0&&this.drainQueueLaterOnExecutor()}}}startFork(n){this.tell(Zu(n))}patchRuntimeFlags(n,r){const s=Vf(n,r);return globalThis[Ma]=this,this.currentRuntimeFlags=s,s}initiateAsync(n,r){let s=!1;const i=o=>{s||(s=!0,this.tell(Zu(o)))};ja(n)&&(this._asyncInterruptor=i);try{r(i)}catch(o){i(fn(Gr(o)))}}pushStack(n){this._stack.push(n),n._op==="OnStep"&&this._steps.push({refs:this.getFiberRefs(),flags:this.currentRuntimeFlags})}popStack(){const n=this._stack.pop();if(n)return n._op==="OnStep"&&this._steps.pop(),n}getNextSuccessCont(){let n=this.popStack();for(;n;){if(n._op!==$_)return n;n=this.popStack()}}getNextFailCont(){let n=this.popStack();for(;n;){if(n._op!==xS&&n._op!==$S&&n._op!==Tp)return n;n=this.popStack()}}[(gke=D4,mke=_ie,sQ)](n){return se(()=>Bv(this.currentContext,n))}Left(n){return Gt(n.left)}None(n){return Gt(new jm)}Right(n){return St(n.right)}Some(n){return St(n.value)}Micro(n){return bg(r=>{let s=r;const i=lie(tie(n,this.currentContext));return i.addObserver(o=>{if(o._tag==="Success")return s(St(o.value));switch(o.cause._tag){case"Interrupt":return s(xt(ri(Nr)));case"Fail":return s(Gt(o.cause.error));case"Die":return s(Eg(o.cause.defect))}}),bg(o=>{s=a=>{o(Ve)},i.unsafeInterrupt()})})}[Qq](n){const r=Bt(()=>n.effect_instruction_i0()),s=this.getNextSuccessCont();return s!==void 0?(s._op in Kh||e_(s),Kh[s._op](this,s,r)):(No.currentOp=St(r),Fo)}[nr](n){const r=n,s=this.getNextSuccessCont();return s!==void 0?(s._op in Kh||e_(s),Kh[s._op](this,s,r.effect_instruction_i0)):(No.currentOp=r,Fo)}[tr](n){const r=n.effect_instruction_i0,s=this.getNextFailCont();if(s!==void 0)switch(s._op){case $_:case RS:return ja(this.currentRuntimeFlags)&&this.isInterrupted()?xt(JO(r)):Bt(()=>s.effect_instruction_i1(r));case"OnStep":return ja(this.currentRuntimeFlags)&&this.isInterrupted()?xt(JO(r)):St(xt(r));case LR:return this.patchRuntimeFlags(this.currentRuntimeFlags,s.patch),ja(this.currentRuntimeFlags)&&this.isInterrupted()?xt(zn(r,this.getInterruptedCause())):xt(r);default:e_(s)}else return No.currentOp=xt(r),Fo}[Jq](n){return Bt(()=>n.effect_instruction_i0(this,k4(this.currentRuntimeFlags)))}Blocked(n){const r=this.getFiberRefs(),s=this.currentRuntimeFlags;if(this._steps.length>0){const i=[],o=this._steps[this._steps.length-1];let a=this.popStack();for(;a&&a._op!=="OnStep";)i.push(a),a=this.popStack();this.setFiberRefs(o.refs),this.currentRuntimeFlags=o.flags;const c=Ag(o.refs,r),f=pl(o.flags,s);return St(dz(n.effect_instruction_i0,et(d=>{for(;i.length>0;)d.pushStack(i.pop());return d.setFiberRefs(Fg(d.id(),d.getFiberRefs())(c)),d.currentRuntimeFlags=Vf(f)(d.currentRuntimeFlags),n.effect_instruction_i1})))}return Yr(i=>Z(Td(Zee(n.effect_instruction_i0)),()=>i(n.effect_instruction_i1)))}RunBlocked(n){return yae(n.effect_instruction_i0)}[Yd](n){const r=n.effect_instruction_i0,s=this.currentRuntimeFlags,i=Vf(s,r);if(ja(i)&&this.isInterrupted())return xt(this.getInterruptedCause());if(this.patchRuntimeFlags(this.currentRuntimeFlags,r),n.effect_instruction_i1){const o=pl(i,s);return this.pushStack(new ete(o,n)),Bt(()=>n.effect_instruction_i1(s))}else return wr}[xS](n){return this.pushStack(n),n.effect_instruction_i0}OnStep(n){return this.pushStack(n),n.effect_instruction_i0}[$_](n){return this.pushStack(n),n.effect_instruction_i0}[RS](n){return this.pushStack(n),n.effect_instruction_i0}[Ip](n){return this._asyncBlockingOn=n.effect_instruction_i1,this.initiateAsync(this.currentRuntimeFlags,n.effect_instruction_i0),No.currentOp=n,Fo}[I_](n){return this._isYielding=!1,No.currentOp=n,Fo}[$S](n){const r=n.effect_instruction_i0,s=n.effect_instruction_i1;return r()?(this.pushStack(n),s()):wr}[Tp](n){return Kh[Tp](this,n,void 0)}[bm](n){return Bt(()=>n.commit())}runLoop(n){let r=n;for(this.currentOpCount=0;;){if(this.currentRuntimeFlags&pee&&this.currentSupervisor.onEffect(this,r),this._queue.length>0&&(r=this.drainQueueWhileRunning(this.currentRuntimeFlags,r)),!this._isYielding){this.currentOpCount+=1;const s=this.currentScheduler.shouldYield(this);if(s!==!1){this._isYielding=!0,this.currentOpCount=0;const i=r;r=Z(Lm({priority:s}),()=>i)}}try{if(r=this.currentTracer.context(()=>_ae!==r[uu]._V?jk(`Cannot execute an Effect versioned ${r[uu]._V} with a Runtime of version ${$v()}`):this[r._op](r),this),r===Fo){const s=No.currentOp;return s._op===I_||s._op===Ip?Fo:(No.currentOp=null,s._op===nr||s._op===tr?s:xt(Gr(s)))}}catch(s){r!==Fo&&!_e(r,"_op")||!(r._op in this)?r=jk(`Not a valid effect: ${Gc(r)}`):Dte(s)?r=xt(zn(Gr(s),ri(Nr))):r=Eg(s)}}}}const cj=We("effect/FiberRef/currentMinimumLogLevel",()=>yr(Fre("Info"))),Sae=e=>Qm(t=>{const n=xw(t.context,bo);hs(n,Cw).unsafe.log(e.log(t))}),uj=We(Symbol.for("effect/Logger/defaultLogger"),()=>Sae($ie)),fj=We(Symbol.for("effect/Logger/tracerLogger"),()=>Qm(({annotations:e,cause:t,context:n,fiberId:r,logLevel:s,message:i})=>{const o=Ms($g(n,Hi),kl);if(o._tag==="None"||o.value._tag==="ExternalSpan")return;const a=Bv($g(n,bo),Ou),c={};for(const[f,d]of e)c[f]=d;c["effect.fiberId"]=XX(r),c["effect.logLevel"]=s.label,t!==null&&t._tag!=="Empty"&&(c["effect.cause"]=Bl(t,{renderErrorCause:!0})),o.value.event(Gc(Array.isArray(i)?i[0]:i),a.unsafeCurrentTimeNanos(),c)})),Fw=We(Symbol.for("effect/FiberRef/currentLoggers"),()=>wte(nw(uj,fj))),vI=x(e=>Bs(e[0]),(e,t)=>Ra(ya(e,n=>dj(r=>t(n,r))))),dj=e=>et(t=>{const n=t.getFiberRefs(),r=t.currentRuntimeFlags;return Z(pj,s=>Cg(s,i=>et(o=>{const a=o.getFiberRefs(),c=o.currentRuntimeFlags,f=Ag(a,n),d=pl(c,r),g=Ag(n,a);return o.setFiberRefs(Fg(f,o.id(),n)),Pd(ute(e(i),d),se(()=>{o.setFiberRefs(Fg(g,o.id(),o.getFiberRefs()))}))})))}),vae=e=>{if(Array.isArray(e)||DR(e))return[e,re()];const t=Object.keys(e),n=t.length;return[t.map(r=>e[r]),oe(r=>{const s={};for(let i=0;i<n;i++)s[t[i]]=r[i];return s})]},wae=(e,t,n)=>{const r=[];for(const s of e)r.push(kd(s));return Z(Id(r,Ce,{concurrency:n==null?void 0:n.concurrency,batching:n==null?void 0:n.batching,concurrentFinalizers:n==null?void 0:n.concurrentFinalizers}),s=>{const i=re(),o=s.length,a=new Array(o),c=new Array(o);let f=!1;for(let d=0;d<o;d++){const g=s[d];g._tag==="Left"?(a[d]=oe(g.left),f=!0):(c[d]=g.right,a[d]=i)}return f?t._tag==="Some"?Gt(t.value(a)):Gt(a):n!=null&&n.discard?Ve:t._tag==="Some"?ie(t.value(c)):ie(c)})},bae=(e,t,n)=>{const r=[];for(const s of e)r.push(kd(s));return n!=null&&n.discard?Id(r,Ce,{concurrency:n==null?void 0:n.concurrency,batching:n==null?void 0:n.batching,discard:!0,concurrentFinalizers:n==null?void 0:n.concurrentFinalizers}):Fe(Id(r,Ce,{concurrency:n==null?void 0:n.concurrency,batching:n==null?void 0:n.batching,concurrentFinalizers:n==null?void 0:n.concurrentFinalizers}),s=>t._tag==="Some"?t.value(s):s)},Nw=(e,t)=>{const[n,r]=vae(e);return(t==null?void 0:t.mode)==="validate"?wae(n,r,t):(t==null?void 0:t.mode)==="either"?bae(n,r,t):(t==null?void 0:t.discard)!==!0&&r._tag==="Some"?Fe(Id(n,Ce,t),r.value):Id(n,Ce,t)},Eae=x(2,(e,t)=>Array.from({length:t},()=>e)),kae=x(e=>Bs(e[0]),(e,t,n)=>Nw(Eae(e,t),n)),Id=x(e=>DR(e[0]),(e,t,n)=>et(r=>{const s=(n==null?void 0:n.batching)===!0||(n==null?void 0:n.batching)==="inherit"&&r.getFiberRef($te);return n!=null&&n.discard?TA(n.concurrency,()=>ef(YS,n==null?void 0:n.concurrentFinalizers)(i=>s?ra(e,(o,a)=>i(t(o,a)),!0,!1,1):fu(e,(o,a)=>i(t(o,a)))),()=>ef(eC,n==null?void 0:n.concurrentFinalizers)(i=>ra(e,(o,a)=>i(t(o,a)),s,!1)),i=>ef(tC(i),n==null?void 0:n.concurrentFinalizers)(o=>ra(e,(a,c)=>o(t(a,c)),s,!1,i))):TA(n==null?void 0:n.concurrency,()=>ef(YS,n==null?void 0:n.concurrentFinalizers)(i=>s?hC(e,1,(o,a)=>i(t(o,a)),!0):Go(e,(o,a)=>i(t(o,a)))),()=>ef(eC,n==null?void 0:n.concurrentFinalizers)(i=>wI(e,(o,a)=>i(t(o,a)),s)),i=>ef(tC(i),n==null?void 0:n.concurrentFinalizers)(o=>hC(e,i,(a,c)=>o(t(a,c)),s)))})),wI=(e,t,n)=>Ee(()=>{const r=gt(e),s=new Array(r.length);return kt(ra(r,(o,a)=>Z(t(o,a),c=>se(()=>s[a]=c)),n,!1),ie(s))}),ra=(e,t,n,r,s)=>Yr(i=>ate(o=>et(a=>{let c=Array.from(e).reverse(),f=c.length;if(f===0)return Ve;let d=0,g=!1;const _=s?Math.min(c.length,s):c.length,b=new Set,k=new Array,I=()=>b.forEach(A=>{A.currentScheduler.scheduleTask(()=>{A.unsafeInterruptAsFork(a.id())},0)}),E=new Array,y=new Array,m=new Array,v=()=>{const A=k.filter(({exit:z})=>z._tag==="Failure").sort((z,D)=>z.index<D.index?-1:z.index===D.index?0:1).map(({exit:z})=>z);return A.length===0&&A.push(wr),A},w=(A,z=!1)=>{const D=Ra(o(A)),W=xae(D,a,a.currentRuntimeFlags,Gm);return a.currentScheduler.scheduleTask(()=>{z&&W.unsafeInterruptAsFork(a.id()),W.resume(D)},0),W},$=()=>{r||(f-=c.length,c=[]),g=!0,I()},P=n?rte:Fi,O=w(Mi(A=>{const z=(W,le)=>{W._op==="Blocked"?m.push(W):(k.push({index:le,exit:W}),W._op==="Failure"&&!g&&$())},D=()=>{if(c.length>0){const W=c.pop();let le=d++;const M=()=>{const G=c.pop();return le=d++,Z(Lm(),()=>Z(P(i(t(G,le))),U))},U=G=>c.length>0&&(z(G,le),c.length>0)?M():ie(G),Q=Z(P(i(t(W,le))),U),L=w(Q);E.push(L),b.add(L),g&&L.currentScheduler.scheduleTask(()=>{L.unsafeInterruptAsFork(a.id())},0),L.addObserver(G=>{let V;if(G._op==="Failure"?V=G:V=G.effect_instruction_i0,y.push(L),b.delete(L),z(V,le),k.length===f)A(ie(Yt(Wf(v(),{parallel:!0}),()=>wr)));else if(m.length+k.length===f){const J=v(),ee=m.map(de=>de.effect_instruction_i0).reduce(tz);A(ie(dz(ee,ra([Yt(Wf(J,{parallel:!0}),()=>wr),...m.map(de=>de.effect_instruction_i1)],de=>de,n,!0,s))))}else D()})}};for(let W=0;W<_;W++)D()}));return vs(ma(oh(i(pu(O))),ww({onFailure:A=>{$();const z=m.length+1,D=Math.min(typeof s=="number"?s:m.length,m.length),W=Array.from(m);return Mi(le=>{let M=0,U=0;const Q=(G,V)=>J=>{M++,M===z&&le(St(xt(A))),W.length>0&&V&&L()},L=()=>{w(W.pop(),!0).addObserver(Q(U,!0)),U++};O.addObserver(Q(U,!1)),U++;for(let G=0;G<D;G++)L()})},onSuccess:()=>Go(y,A=>A.inheritAll)})))}))),hC=(e,t,n,r)=>Ee(()=>{const s=gt(e),i=new Array(s.length);return kt(ra(s,(a,c)=>Fe(n(a,c),f=>i[c]=f),r,!1,t),ie(i))}),Cae=e=>et((t,n)=>ie(bI(e,t,n.runtimeFlags))),Td=e=>Rae(e,Gm),bI=(e,t,n,r=null)=>{const s=o0(e,t,n,r);return s.resume(e),s},xae=(e,t,n,r=null)=>o0(e,t,n,r),o0=(e,t,n,r=null)=>{const s=ML(),i=t.getFiberRefs(),o=Ere(i,s),a=new lj(s,o,n),c=$g(o,Hi),f=a.currentSupervisor;return f.onStart(c,e,oe(t),a),a.addObserver(g=>f.onEnd(g,a)),(r!==null?r:T(t.getFiberRef(Hk),Yt(()=>t.scope()))).add(n,a),a},Rae=(e,t)=>et((n,r)=>ie(bI(e,n,r.runtimeFlags,t))),qA=e=>dh(t=>bt(Ms(t,Bi),{onNone:()=>e,onSome:n=>{switch(n.strategy._tag){case"Parallel":return e;case"Sequential":case"ParallelN":return Z(_w(n,eC),r=>Fu(e,r))}}})),MA=e=>t=>dh(n=>bt(Ms(n,Bi),{onNone:()=>t,onSome:r=>r.strategy._tag==="ParallelN"&&r.strategy.parallelism===e?t:Z(_w(r,tC(e)),s=>Fu(t,s))})),ef=(e,t)=>n=>dh(r=>bt(Ms(r,Bi),{onNone:()=>n(Ce),onSome:s=>{if(t===!0){const i=e._tag==="Parallel"?qA:e._tag==="Sequential"?LA:MA(e.parallelism);switch(s.strategy._tag){case"Parallel":return i(n(qA));case"Sequential":return i(n(LA));case"ParallelN":return i(n(MA(s.strategy.parallelism)))}}else return n(Ce)}})),Dw=e=>Z(Bi,e),hj=e=>Z(gh(),t=>ma(e(t),n=>t.close(n))),$ae=e=>Z(gh(),t=>Fae(e,t)),LA=e=>dh(t=>bt(Ms(t,Bi),{onNone:()=>e,onSome:n=>{switch(n.strategy._tag){case"Sequential":return e;case"Parallel":case"ParallelN":return Z(_w(n,YS),r=>Fu(e,r))}}})),Iae=x(e=>Bs(e[1]),(e,t,n)=>Zm(e,t,(r,s)=>[r,s],n)),Tae=x(e=>Bs(e[1]),(e,t,n)=>(n==null?void 0:n.concurrent)!==!0&&((n==null?void 0:n.batching)===void 0||n.batching===!1)?gl(e,t):Zm(e,t,(r,s)=>r,n)),Pae=x(e=>Bs(e[1]),(e,t,n)=>(n==null?void 0:n.concurrent)!==!0&&((n==null?void 0:n.batching)===void 0||n.batching===!1)?kt(e,t):Zm(e,t,(r,s)=>s,n)),Zm=x(e=>Bs(e[1]),(e,t,n,r)=>Fe(Nw([e,t],{concurrency:r!=null&&r.concurrent?2:1,batching:r==null?void 0:r.batching,concurrentFinalizers:r==null?void 0:r.concurrentFinalizers}),([s,i])=>n(s,i))),Bi=Mr("effect/Scope"),pj=Bi,Oae=(e,t)=>{e.state._tag==="Open"&&e.state.finalizers.set({},t)},Aae={[eA]:eA,[tA]:tA,pipe(){return pe(this,arguments)},fork(e){return se(()=>{const t=gj(e);if(this.state._tag==="Closed")return t.state=this.state,t;const n={},r=s=>t.close(s);return this.state.finalizers.set(n,r),Oae(t,s=>se(()=>{this.state._tag==="Open"&&this.state.finalizers.delete(n)})),t})},close(e){return Ee(()=>{if(this.state._tag==="Closed")return Ve;const t=Array.from(this.state.finalizers.values()).reverse();return this.state={_tag:"Closed",exit:e},t.length===0?Ve:bse(this.strategy)?T(Go(t,n=>Fi(n(e))),Z(n=>T(Wf(n),hl(O1),Yt(()=>wr)))):Ese(this.strategy)?T(wI(t,n=>Fi(n(e)),!1),Z(n=>T(Wf(n,{parallel:!0}),hl(O1),Yt(()=>wr)))):T(hC(t,this.strategy.parallelism,n=>Fi(n(e)),!1),Z(n=>T(Wf(n,{parallel:!0}),hl(O1),Yt(()=>wr))))})},addFinalizer(e){return Ee(()=>this.state._tag==="Closed"?e(this.state.exit):(this.state.finalizers.set({},e),Ve))}},gj=(e=Km)=>{const t=Object.create(Aae);return t.strategy=e,t.state={_tag:"Open",finalizers:new Map},t},gh=(e=Km)=>se(()=>gj(e)),Fu=x(2,(e,t)=>H$(e,xa(Hv(Bi,t)))),Fae=x(2,(e,t)=>T(e,Fu(t),ma(n=>t.close(n)))),Nae=e=>lh(e,{differ:cae,fork:Op}),Dae=x(2,(e,t)=>vs(vI(Z(yw(e),n=>Tn(WS(e,t),n)),n=>WS(e,n)))),EI=x(2,(e,t)=>ah(e,n=>Dae(e,t(n)))),zA=Ete(yee),qae=Nae(Aw),mj=x(3,(e,t,n)=>_j(e,t,{onSelfWin:(r,s)=>Z(r.await,i=>{switch(i._tag){case nr:return Z(r.inheritAll,()=>n.onSelfDone(i,s));case tr:return n.onSelfDone(i,s)}}),onOtherWin:(r,s)=>Z(r.await,i=>{switch(i._tag){case nr:return Z(r.inheritAll,()=>n.onOtherDone(i,s));case tr:return n.onOtherDone(i,s)}})})),Mae=e=>Yr(t=>Iu(n=>Z(Td(t(e)),r=>T(t(pu(r)),Vl(()=>T(r,L4(n))))))),yj=x(2,(e,t)=>Iu(n=>mj(e,t,{onSelfDone:(r,s)=>Wk(r,{onFailure:i=>T(pu(s),kA(o=>ga(i,o))),onSuccess:i=>T(s,Qo(n),Tn(i))}),onOtherDone:(r,s)=>Wk(r,{onFailure:i=>T(pu(s),kA(o=>ga(o,i))),onSuccess:i=>T(s,Qo(n),Tn(i))})}))),_j=x(3,(e,t,n)=>et((r,s)=>{const i=s.runtimeFlags,o=Cu(!0),a=o0(e,r,i,n.selfScope),c=o0(t,r,i,n.otherScope);return Mi(f=>{a.addObserver(()=>jA(a,c,n.onSelfWin,o,f)),c.addObserver(()=>jA(c,a,n.onOtherWin,o,f)),a.startFork(e),c.startFork(t)},As(a.id(),c.id()))})),jA=(e,t,n,r,s)=>{jX(!0,!1)(r)&&s(n(e,t))},Pd=x(2,(e,t)=>Yr(n=>ys(n(e),{onFailure:r=>ys(t,{onFailure:s=>fn(zn(r,s)),onSuccess:()=>fn(r)}),onSuccess:r=>Tn(t,r)}))),Lae=(e,t,n)=>Iu(r=>Z(Z(Td(Cd(e)),s=>Mi(i=>{const o=t.map(f=>f.listeners.count),a=()=>{o.every(f=>f===0)&&t.every(f=>f.result.state.current._tag==="Pending"?!0:!!(f.result.state.current._tag==="Done"&&vw(f.result.state.current.effect)&&f.result.state.current.effect._tag==="Failure"&&E$(f.result.state.current.effect.cause)))&&(c.forEach(f=>f()),n==null||n(),i(kg(s)))};s.addObserver(f=>{c.forEach(d=>d()),i(f)});const c=t.map((f,d)=>{const g=_=>{o[d]=_,a()};return f.listeners.addObserver(g),()=>f.listeners.removeObserver(g)});return a(),se(()=>{c.forEach(f=>f())})})),()=>Ee(()=>{const s=t.flatMap(i=>i.state.completed?[]:[i]);return fu(s,i=>tae(i.request,M$(r)))}))),UA=(e,t)=>(t=Gf(t),Ra(et(n=>{const r=Bv(n.getFiberRef(Hi),Bi),s=v4(n,e,t),i=n.getFiberRef(D$),o=hs(n.getFiberRef(bo),Ou);return Tn(Cg(r,a=>w4(s,a,o,i)),s)}))),zae=e=>EI(bo,$i(Wm,e)),jae=function(){const e=typeof arguments[0]!="string",t=e?arguments[1]:arguments[0],n=Gf(e?arguments[2]:arguments[1]);if(e){const r=arguments[0];return Z(UA(t,Gf(n)),s=>Pg(r,kl,s))}return r=>Z(UA(t,Gf(n)),s=>Pg(r,kl,s))},Uae=pa,gu=cu,mu=Gr,qw=ri,Hae=ga,Bae=zn,Vae=v$,Sj=qee,Wae=w$,a0=E$,ml=uw,Kae=k$,Mw=C$,vj=Lee,kI=Uee,Gae=Ote,CI=hw,Qae=qte,Lw=jm,l0=Bl,Jae=x$,Yae="effect/ScheduleInterval",c0=Symbol.for(Yae),wj={[c0]:c0,startMillis:0,endMillis:0},xI=(e,t)=>e>t?wj:{[c0]:c0,startMillis:e,endMillis:t},Xae=x(2,(e,t)=>Zae(e,t)===e),Zae=x(2,(e,t)=>e.endMillis<=t.startMillis?e:t.endMillis<=e.startMillis?t:e.startMillis<t.startMillis?e:t.startMillis<e.startMillis?t:e.endMillis<=t.endMillis?e:t),ele=e=>e.startMillis>=e.endMillis,tle=x(2,(e,t)=>{const n=Math.max(e.startMillis,t.startMillis),r=Math.min(e.endMillis,t.endMillis);return xI(n,r)}),nle=e=>nu(e.endMillis-e.startMillis),rle=e=>xI(e,Number.POSITIVE_INFINITY),HA=xI,bj=wj,sle=Xae,ile=ele,ole=tle,ale=nle,lle=rle,cle="effect/ScheduleIntervals",BA=Symbol.for(cle),Ej=e=>({[BA]:BA,intervals:e}),ule=x(2,(e,t)=>fle(e.intervals,t.intervals,Ut())),fle=(e,t,n)=>{let r=e,s=t,i=n;for(;vo(r)&&vo(s);){const o=T(co(r),ole(co(s))),a=ile(o)?i:T(i,xr(o));T(co(r),sle(co(s)))?r=Ko(r):s=Ko(s),i=a}return Ej(ha(i))},pC=e=>T(e.intervals,Kv,Yt(()=>bj)).startMillis,dle=e=>T(e.intervals,Kv,Yt(()=>bj)).endMillis,hle=x(2,(e,t)=>pC(e)<pC(t)),ple=e=>vo(e.intervals),gle=Ej,mle=ule,gC=pC,mC=dle,yle=hle,_le=ple,RI="Continue",kj="Done",Sle=e=>({_tag:RI,intervals:e}),vle=e=>({_tag:RI,intervals:gle(Xt(e))}),wle={_tag:kj},ble=e=>e._tag===RI,Ele=e=>e._tag===kj,kle=Sle,Cj=vle,Ng=wle,VA=ble,Dg=Ele,Cle=Bi,Rl=xz,xle=Cg,Ln=Bk,ey=Fu,xj=_w,ty=gh,Rle=Ru,$I=function(){const e=Symbol.for("effect/Data/Error/plainArgs");return{BaseEffectError:class extends q${constructor(n){super(n==null?void 0:n.message,n!=null&&n.cause?{cause:n.cause}:void 0),n&&(Object.assign(this,n),Object.defineProperty(this,e,{value:n,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}.BaseEffectError}(),$le=e=>{const t={BaseEffectError:class extends $I{constructor(){super(...arguments);p(this,"_tag",e)}}};return t.BaseEffectError.prototype.name=e,t.BaseEffectError},Ile="effect/Schedule",Rj=Symbol.for(Ile),$j=e=>_e(e,Rj),Tle="effect/ScheduleDriver",Ple=Symbol.for(Tle),Ole={_Out:e=>e,_In:e=>e,_R:e=>e},Ale={_Out:e=>e,_In:e=>e,_R:e=>e};var yke;class Fle{constructor(t,n){p(this,"initial");p(this,"step");p(this,yke,Ole);this.initial=t,this.step=n}pipe(){return pe(this,arguments)}}yke=Rj;var _ke;class Nle{constructor(t,n){p(this,"schedule");p(this,"ref");p(this,_ke,Ale);this.schedule=t,this.ref=n}get state(){return Fe(na(this.ref),t=>t[1])}get last(){return Z(na(this.ref),([t,n])=>{switch(t._tag){case"None":return Dm(()=>new jm);case"Some":return ie(t.value)}})}get reset(){return Ig(this.ref,[re(),this.schedule.initial])}next(t){return T(Fe(na(this.ref),n=>n[1]),Z(n=>T(yre,Z(r=>T(Ee(()=>this.schedule.step(r,t,n)),Z(([s,i,o])=>{const a=Ig(this.ref,[oe(i),s]);if(Dg(o))return kt(a,Gt(re()));const c=gC(o.intervals)-r;return c<=0?Tn(a,i):T(a,kt(oI(nu(c))),Tn(i))}))))))}}_ke=Ple;const mh=(e,t)=>new Fle(e,t),Ij=x(2,(e,t)=>Dle(e,n=>se(()=>t(n)))),Dle=x(2,(e,t)=>Ule(e,(n,r)=>Fe(t(n),s=>nX(r,Ls(s))))),qle=x(2,(e,t)=>II(e,(n,r)=>se(()=>t(n,r)))),II=x(2,(e,t)=>mh(e.initial,(n,r,s)=>Z(e.step(n,r,s),([i,o,a])=>Dg(a)?ie([i,o,Ng]):Fe(t(r,o),c=>c?[i,o,a]:[i,o,Ng])))),Mle=e=>Ij(e,t=>t),Tj=e=>T(JS([re(),e.initial]),Fe(t=>new Nle(e,t))),Lle=(e,t=2)=>{const n=Ls(e);return Mle(Oj(ny,r=>tX(n,Math.pow(t,r))))},Pj=x(2,(e,t)=>zle(e,t,mle)),zle=x(3,(e,t,n)=>mh([e.initial,t.initial],(r,s,i)=>T(Sz(e.step(r,s,i[0]),t.step(r,s,i[1]),(o,a)=>[o,a]),Z(([[o,a,c],[f,d,g]])=>VA(c)&&VA(g)?yC(e,t,s,o,a,c.intervals,f,d,g.intervals,n):ie([[o,f],[a,d],Ng]))))),yC=(e,t,n,r,s,i,o,a,c,f)=>{const d=f(i,c);return _le(d)?ie([[r,o],[s,a],kle(d)]):T(i,yle(c))?Z(e.step(mC(i),n,r),([g,_,b])=>Dg(b)?ie([[g,o],[_,a],Ng]):yC(e,t,n,g,_,b.intervals,o,a,c,f)):Z(t.step(mC(c),n,o),([g,_,b])=>Dg(b)?ie([[r,g],[s,_],Ng]):yC(e,t,n,r,s,i,g,_,b.intervals,f))},Oj=x(2,(e,t)=>jle(e,n=>se(()=>t(n)))),jle=x(2,(e,t)=>mh(e.initial,(n,r,s)=>Z(e.step(n,r,s),([i,o,a])=>Fe(t(o),c=>[i,c,a])))),Ule=x(2,(e,t)=>mh(e.initial,(n,r,s)=>Z(e.step(n,r,s),([i,o,a])=>{if(Dg(a))return ie([i,o,a]);const c=a.intervals,f=ale(HA(n,gC(c)));return Fe(t(o,f),d=>{const g=Ls(d),_=gC(c),b=n+ru(g),k=b-_,I=Math.max(0,mC(c)+k),E=HA(b,I);return[i,o,Cj(E)]})}))),Hle=e=>mh(e.initial,(t,n,r)=>T(e.step(t,n,r),Fe(([s,i,o])=>[s,n,o]))),Aj=e=>Wle(ny,t=>t<e),Ble=e=>Ij(ny,()=>e),Vle=(e,t)=>mh(e,(n,r,s)=>se(()=>[t(s),s,Cj(lle(n))])),Fj=x(2,(e,t)=>II(e,(n,r)=>ose(t(n)))),Nj=x(2,(e,t)=>II(e,(n,r)=>t(n))),Wle=x(2,(e,t)=>qle(e,(n,r)=>t(r))),U_=Symbol.for("effect/Schedule/ScheduleDefect");var Ske;class Kle{constructor(t){p(this,"error");p(this,Ske);this.error=t,this[U_]=U_}}Ske=U_;const Gle=e=>_e(e,U_),u0=e=>Ed(e,t=>Eg(new Kle(t))),Dj=e=>Nm(e,t=>bt(fw(t,n=>w$(n)&&Gle(n.defect)?oe(n.defect):re()),{onNone:()=>fn(t),onSome:n=>Gt(n.error)})),WA=x(2,(e,t)=>Jle(e,t,(n,r)=>Gt(n))),Qle=x(2,(e,t)=>{if($j(t))return WA(e,t);const n=t.schedule??Hle(ny),r=t.while?Nj(n,o=>{const a=t.while(o);return typeof a=="boolean"?ie(a):u0(a)}):n,s=t.until?Fj(r,o=>{const a=t.until(o);return typeof a=="boolean"?ie(a):u0(a)}):r,i=t.times?Pj(s,Aj(t.times)).pipe(Oj(o=>o[0])):s;return Dj(WA(e,i))}),Jle=x(3,(e,t,n)=>Z(Tj(t),r=>wo(e,{onFailure:s=>n(s,re()),onSuccess:s=>qj(e,r,n,s)}))),qj=(e,t,n,r)=>wo(t.next(r),{onFailure:()=>O$(t.last),onSuccess:s=>wo(e,{onFailure:i=>n(i,oe(s)),onSuccess:i=>qj(e,t,n,i)})}),KA=x(2,(e,t)=>Xle(e,t,(n,r)=>Gt(n))),Yle=x(2,(e,t)=>{if($j(t))return KA(e,t);const n=t.schedule??ny,r=t.while?Nj(n,o=>{const a=t.while(o);return typeof a=="boolean"?ie(a):u0(a)}):n,s=t.until?Fj(r,o=>{const a=t.until(o);return typeof a=="boolean"?ie(a):u0(a)}):r,i=t.times?Pj(s,Aj(t.times)):s;return Dj(KA(e,i))}),Xle=x(3,(e,t,n)=>Z(Tj(t),r=>Mj(e,r,n))),Mj=(e,t,n)=>Ed(e,r=>wo(t.next(r),{onFailure:()=>T(t.last,O$,Z(s=>n(r,s))),onSuccess:()=>Mj(e,t,n)})),ny=Vle(0,e=>e+1);class Zle{constructor(t){p(this,"permits");p(this,"waiters",new Set);p(this,"taken",0);p(this,"take",t=>Xa(n=>{if(this.free<t){const r=()=>{this.free<t||(this.waiters.delete(r),this.taken+=t,n(ie(t)))};return this.waiters.add(r),se(()=>{this.waiters.delete(r)})}return this.taken+=t,n(ie(t))}));p(this,"updateTaken",t=>et(n=>(this.taken=t(this.taken),this.waiters.size>0&&n.getFiberRef(Tw).scheduleTask(()=>{const r=this.waiters.values();let s=r.next();for(;s.done===!1&&this.free>0;)s.value(),s=r.next()},n.getFiberRef(Pu)),ie(this.free))));p(this,"release",t=>this.updateTaken(n=>n-t));p(this,"releaseAll",this.updateTaken(t=>0));p(this,"withPermits",t=>n=>Yr(r=>Z(r(this.take(t)),s=>Pd(r(n),this.release(s)))));p(this,"withPermitsIfAvailable",t=>n=>Yr(r=>Ee(()=>this.free<t?Og:(this.taken+=t,Pd(r(Qre(n)),this.release(t))))));this.permits=t}get free(){return this.permits-this.taken}}const Ap=e=>new Zle(e),ece=e=>se(()=>Ap(e));class tce extends Io{constructor(n){super();p(this,"isOpen");p(this,"waiters",[]);p(this,"scheduled",!1);p(this,"flushWaiters",()=>{this.scheduled=!1;const n=this.waiters;this.waiters=[];for(let r=0;r<n.length;r++)n[r](wr)});p(this,"open",et(n=>this.isOpen?Ve:(this.isOpen=!0,this.unsafeSchedule(n))));p(this,"release",et(n=>this.isOpen?Ve:this.unsafeSchedule(n)));p(this,"await",Xa(n=>this.isOpen?n(Ve):(this.waiters.push(n),se(()=>{const r=this.waiters.indexOf(n);r!==-1&&this.waiters.splice(r,1)}))));p(this,"close",se(()=>{this.isOpen=!1}));p(this,"whenOpen",n=>kt(this.await,n));this.isOpen=n}commit(){return this.await}unsafeSchedule(n){return this.scheduled||this.waiters.length===0||(this.scheduled=!0,n.currentScheduler.scheduleTask(this.flushWaiters,n.getFiberRef(Pu))),Ve}unsafeOpen(){this.isOpen||(this.isOpen=!0,this.flushWaiters())}unsafeClose(){this.isOpen=!1}}const TI=e=>new tce(e??!1),nce=e=>se(()=>TI(e)),f0=x(2,(e,t)=>et((n,r)=>{const s=t,i=bI(e,n,r.runtimeFlags,Gm);if(s.state._tag==="Open"){const o=()=>Iu(c=>Ne(c,i.id())?Ve:vs(kg(i))),a={};s.state.finalizers.set(a,o),i.addObserver(()=>{s.state._tag!=="Closed"&&s.state.finalizers.delete(a)})}else i.unsafeInterruptAsFork(n.id());return ie(i)})),rce=e=>Dw(t=>f0(e,t)),sce=x(2,(e,t)=>T(Fi(e),yj(Fi(t)),n=>oh(n))),ice=x(2,(e,t)=>oce(e,{onTimeout:()=>Lte(t),duration:t})),oce=x(2,(e,{duration:t,onTimeout:n})=>oh(ace(e,{onTimeout:()=>Dm(n),onSuccess:ie,duration:t}))),ace=x(2,(e,{duration:t,onSuccess:n,onTimeout:r})=>Iu(s=>Yr(i=>_j(i(e),Cd(oI(t)),{onSelfWin:(o,a)=>Z(o.await,c=>c._tag==="Success"?Z(o.inheritAll,()=>Tn(Qo(a,s),n(c.value))):Z(Qo(a,s),()=>xt(c.cause))),onOtherWin:(o,a)=>Z(o.await,c=>c._tag==="Success"?Z(o.inheritAll,()=>Tn(Qo(a,s),r())):Z(Qo(a,s),()=>xt(c.cause))),otherScope:Gm})))),lce="effect/Ref/SynchronizedRef",Lj=Symbol.for(lce),zj={_A:e=>e};var vke,wke,bke;class cce extends Io{constructor(n,r){super();p(this,"ref");p(this,"withLock");p(this,vke,zj);p(this,wke,nI);p(this,bke,xl);p(this,"get");this.ref=n,this.withLock=r,this.get=na(this.ref)}commit(){return this.get}modify(n){return this.modifyEffect(r=>ie(n(r)))}modifyEffect(n){return this.withLock(T(Z(na(this.ref),n),Z(([r,s])=>Tn(Ig(this.ref,s),r))))}}vke=Lj,wke=tI,bke=xl;const uce=e=>se(()=>jj(e)),jj=e=>{const t=Zz(e),n=Ap(1);return new cce(t,n.withPermits(1))},_C=Symbol.for("effect/ManagedRuntime"),fce="Fold",dce="Fresh",hce="FromEffect",pce="Scoped",gce="Suspend",mce="Provide",Uj="ProvideMerge",yce="ZipWith",Hj=M4,_ce=wie,GA=Sie,Fs=kg,ry=Qo,Bj=vie,$l=pu,yh=e=>function(){if(arguments.length===1){const t=arguments[0];return(n,...r)=>e(t,n,...r)}return e.apply(this,arguments)},sy=yh((e,t,n)=>{const r=ML(),s=[[Hi,[[r,e.context]]]];n!=null&&n.scheduler&&s.push([Tw,[[r,n.scheduler]]]);let i=Cre(e.fiberRefs,{entries:s,forkAs:r});n!=null&&n.updateRefs&&(i=n.updateRefs(i,r));const o=new lj(r,i,e.runtimeFlags);let a=t;n!=null&&n.scope&&(a=Z(xj(n.scope,Km),f=>kt(xz(f,Iu(d=>Ne(d,o.id())?Ve:Qo(o,d))),ma(t,d=>Ln(f,d)))));const c=o.currentSupervisor;return c!==Aw&&(c.onStart(e.context,a,re(),o),o.addObserver(f=>c.onEnd(f,o))),Gm.add(e.runtimeFlags,o),(n==null?void 0:n.immediate)===!1?o.resume(a):o.start(a),o}),Vj=yh((e,t,n={})=>{const r=sy(e,t,n);return n.onExit&&r.addObserver(s=>{n.onExit(s)}),(s,i)=>Vj(e)(T(r,ry(s??Nr)),{...i,onExit:i!=null&&i.onExit?o=>i.onExit(sne(o)):void 0})}),Sce=yh((e,t)=>{const n=Ece(e)(t);if(n._tag==="Failure")throw Wj(n.effect_instruction_i0);return n.effect_instruction_i0});class vce extends Error{constructor(n){super(`Fiber #${n.id().id} cannot be resolved synchronously. This is caused by using runSync on an effect that performs async work`);p(this,"fiber");p(this,"_tag","AsyncFiberException");this.fiber=n,this.name=this._tag,this.stack=this.message}}const wce=e=>{const t=Error.stackTraceLimit;Error.stackTraceLimit=0;const n=new vce(e);return Error.stackTraceLimit=t,n},D1=Symbol.for("effect/Runtime/FiberFailure"),t_=Symbol.for("effect/Runtime/FiberFailure/Cause");var Eke,kke;class bce extends Error{constructor(n){const r=x$(n)[0];super((r==null?void 0:r.message)||"An error has occurred");p(this,Eke);p(this,kke);this[D1]=D1,this[t_]=n,this.name=r?`(FiberFailure) ${r.name}`:"FiberFailure",r!=null&&r.stack&&(this.stack=r.stack)}toJSON(){return{_id:"FiberFailure",cause:this[t_].toJSON()}}toString(){return"(FiberFailure) "+Bl(this[t_],{renderErrorCause:!0})}[(Eke=D1,kke=t_,ft)](){return this.toString()}}const Wj=e=>{const t=Error.stackTraceLimit;Error.stackTraceLimit=0;const n=new bce(e);return Error.stackTraceLimit=t,n},Kj=e=>{const t=e;switch(t._op){case"Failure":case"Success":return t;case"Left":return xg(t.left);case"Right":return St(t.right);case"Some":return St(t.value);case"None":return xg(jm())}},Ece=yh((e,t)=>{const n=Kj(t);if(n)return n;const r=new F4,s=sy(e)(t,{scheduler:r});r.flush();const i=s.unsafePoll();return i||If($$(wce(s),B$(s)))}),kce=yh((e,t,n)=>Cce(e,t,n).then(r=>{switch(r._tag){case nr:return r.effect_instruction_i0;case tr:throw Wj(r.effect_instruction_i0)}})),Cce=yh((e,t,n)=>new Promise(r=>{const s=Kj(t);s&&r(s);const i=sy(e)(t);i.addObserver(o=>{r(o)}),(n==null?void 0:n.signal)!==void 0&&(n.signal.aborted?i.unsafeInterruptAsFork(i.id()):n.signal.addEventListener("abort",()=>{i.unsafeInterruptAsFork(i.id())},{once:!0}))}));class Gj{constructor(t,n,r){p(this,"context");p(this,"runtimeFlags");p(this,"fiberRefs");this.context=t,this.runtimeFlags=n,this.fiberRefs=r}pipe(){return pe(this,arguments)}}const Qj=e=>new Gj(e.context,e.runtimeFlags,e.fiberRefs),xce=()=>et((e,t)=>ie(new Gj(e.getFiberRef(Hi),t.runtimeFlags,e.getFiberRefs()))),Rce=ZL(th,YL,JL),Od=Qj({context:tu(),runtimeFlags:Rce,fiberRefs:xre()}),$ce=x(2,(e,t)=>Qj({context:t(e.context),runtimeFlags:e.runtimeFlags,fiberRefs:e.fiberRefs})),Ice=Vj(Od),Tce=sy(Od),Pce=kce(Od),Oce=Sce(Od),Ace=x(2,(e,t)=>e.modifyEffect(t)),Fce="effect/Layer",Jj=Symbol.for(Fce),Nce={_RIn:e=>e,_E:e=>e,_ROut:e=>e},Il={[Jj]:Nce,pipe(){return pe(this,arguments)}},Dce="effect/Layer/MemoMap",q1=Symbol.for(Dce),qce=Im()("effect/Layer/CurrentMemoMap",{defaultValue:()=>jce()}),Mce=e=>_e(e,Jj),Lce=e=>e._op_layer===dce;var Cke;class Yj{constructor(t){p(this,"ref");p(this,Cke);this.ref=t,this[q1]=q1}getOrElseMemoize(t,n){return T(Ace(this.ref,r=>{const s=r.get(t);if(s!==void 0){const[i,o]=s,a=T(i,Z(([c,f])=>T(g4(c),Tn(f))),ma(ww({onFailure:()=>Ve,onSuccess:()=>Cg(n,o)})));return ie([a,r])}return T(JS(0),Z(i=>T(ch(),Z(o=>T(JS(()=>Ve),Fe(a=>{const c=Yr(d=>T(gh(),Z(g=>T(d(Z(Xj(t,g,!0),_=>Zre(_(this)))),Fi,Z(_=>{switch(_._tag){case tr:return T(Pz(o,_.effect_instruction_i0),kt(Bk(g,_)),kt(fn(_.effect_instruction_i0)));case nr:return T(Ig(a,b=>T(Bk(g,b),Mm(e4(i,k=>[k===1,k-1])),vs)),kt(Jk(i,b=>b+1)),kt(Cg(n,b=>T(se(()=>r.delete(t)),kt(na(a)),Z(k=>k(b))))),kt(Hm(o,_.effect_instruction_i0)),Tn(_.effect_instruction_i0[1]))}}))))),f=[T(Li(o),ma(Wk({onFailure:()=>Ve,onSuccess:()=>Jk(i,d=>d+1)}))),d=>T(na(a),Z(g=>g(d)))];return[c,Lce(t)?r:r.set(t,f)]}))))))}),oh)}}Cke=q1;const zce=Ee(()=>Fe(uce(new Map),e=>new Yj(e))),jce=()=>new Yj(jj(new Map)),Uce=e=>Dw(t=>PI(e,t)),PI=x(2,(e,t)=>Z(zce,n=>Hce(e,n,t))),Hce=x(3,(e,t,n)=>Z(Xj(e,n),r=>Pg(r(t),qce,t))),Xj=(e,t,n=!1)=>{const r=e;switch(r._op_layer){case"Locally":return se(()=>s=>r.f(s.getOrElseMemoize(r.self,t)));case"ExtendScope":return se(()=>s=>Dw(i=>s.getOrElseMemoize(r.layer,i)));case"Fold":return se(()=>s=>T(s.getOrElseMemoize(r.layer,t),ys({onFailure:i=>s.getOrElseMemoize(r.failureK(i),t),onSuccess:i=>s.getOrElseMemoize(r.successK(i),t)})));case"Fresh":return se(()=>s=>T(r.layer,PI(t)));case"FromEffect":return se(n?()=>s=>r.effect:()=>s=>s.getOrElseMemoize(e,t));case"Provide":return se(()=>s=>T(s.getOrElseMemoize(r.first,t),Z(i=>T(s.getOrElseMemoize(r.second,t),j$(i)))));case"Scoped":return se(n?()=>s=>Fu(r.effect,t):()=>s=>s.getOrElseMemoize(e,t));case"Suspend":return se(()=>s=>s.getOrElseMemoize(r.evaluate(),t));case"ProvideMerge":return se(()=>s=>T(s.getOrElseMemoize(r.first,t),Sz(s.getOrElseMemoize(r.second,t),r.zipK)));case"ZipWith":return se(()=>s=>T(s.getOrElseMemoize(r.first,t),Zm(s.getOrElseMemoize(r.second,t),r.zipK,{concurrent:!0})))}},Bce=()=>zw(fh()),Vce=e=>Zj(gu(e)),Zj=e=>zw(fn(e)),OI=x(2,(e,t)=>Kce(e,{onFailure:Vce,onSuccess:t})),eU=x(2,(e,t)=>{const n=t$(e),r=n?e:t;return zw(Fe(n?t:e,i=>Hv(r,i)))});function zw(e){const t=Object.create(Il);return t._op_layer=hce,t.effect=e,t}const Wce=x(2,(e,{onFailure:t,onSuccess:n})=>{const r=Object.create(Il);return r._op_layer=fce,r.layer=e,r.failureK=t,r.successK=n,r}),Kce=x(2,(e,{onFailure:t,onSuccess:n})=>Wce(e,{onFailure:r=>{const s=Mw(r);switch(s._tag){case"Left":return t(s.left);case"Right":return Zj(s.right)}},onSuccess:n})),tU=x(2,(e,t)=>Yce(e,t,(n,r)=>xa(n,r))),nU=(...e)=>{let t=e[0];for(let n=1;n<e.length;n++)t=tU(t,e[n]);return t},Gce=x(2,(e,t)=>{const n=t$(e),r=n?e:t;return rU(Fe(n?t:e,i=>Hv(r,i)))}),AI=e=>rU(T(e,Tn(tu()))),rU=e=>{const t=Object.create(Il);return t._op_layer=pce,t.effect=e,t},Qce=x(2,(e,t)=>{const n=t$(e);return zw(ie(Hv(n?e:t,n?t:e)))}),sU=e=>{const t=Object.create(Il);return t._op_layer=gce,t.evaluate=e,t};const iU=x(2,(e,t)=>sU(()=>{const n=Object.create(Il);return n._op_layer=mce,n.first=Object.create(Il,{_op_layer:{value:Uj,enumerable:!0},first:{value:Bce(),enumerable:!0},second:{value:Array.isArray(t)?nU(...t):t},zipK:{value:(r,s)=>T(r,xa(s))}}),n.second=e,n})),Jce=x(2,(e,t)=>{const n=Object.create(Il);return n._op_layer=Uj,n.first=t,n.second=iU(e,t),n.zipK=(r,s)=>T(r,xa(s)),n}),Yce=x(3,(e,t,n)=>sU(()=>{const r=Object.create(Il);return r._op_layer=yce,r.first=e,r.second=t,r.zipK=n,r})),Xce=e=>{const t=Mr("effect/Layer/unwrapEffect/Layer.Layer<R1, E1, A>");return OI(eU(t,e),n=>hs(n,t))},Zce=e=>{const t=Mr("effect/Layer/unwrapScoped/Layer.Layer<R1, E1, A>");return OI(Gce(t,e),n=>hs(n,t))},QA=x(2,(e,t)=>hj(n=>Z(PI(t,n),r=>U$(e,r)))),JA=x(2,(e,t)=>{const n=Ag(Od.fiberRefs,t.fiberRefs),r=pl(Od.runtimeFlags,t.runtimeFlags);return Yr(s=>et(i=>{const o=i.getFiberRef(Hi),a=i.getFiberRefs(),c=Fg(i.id(),a)(n),f=i.currentRuntimeFlags,d=Vf(r)(f),g=Ag(c,a),_=pl(d,f);return i.setFiberRefs(c),i.currentRuntimeFlags=d,Pd(U$(s(e),xa(o,t.context)),et(b=>(b.setFiberRefs(Fg(b.id(),b.getFiberRefs())(g)),b.currentRuntimeFlags=Vf(_)(b.currentRuntimeFlags),Ve)))}))}),eue=x(2,(e,t)=>Array.isArray(t)?QA(e,nU(...t)):Mce(t)?QA(e,t):OY(t)?U$(e,t):_C in t?Z(t.runtimeEffect,n=>JA(e,n)):JA(e,t)),tue=eae,YA=uu,$a=Bs,M1=ise,jw=Nw,er=Id,nue=Mi,_a=et,zs=Gt,ps=fn,Ad=Eg,rue=jk,X=lte,FI=q_,Fd=lse,Pt=ie,zt=Ee,Re=se,Le=Ve,sue=Lm,Uw=Ed,sa=Nm,iue=Jre,L1=Yre,_h=Xre,oue=h4,Hw=tse,NI=Yle,Kl=u4,aue=hse,Fp=dse,lue=Mae,to=Pn,Jt=Cd,oU=Vl,Sc=Ra,Tl=Yr,yo=Tn,Sa=vs,je=Fe,cue=P$,Gl=gw,Rt=vI,DI=R$,pr=dj,Tf=Pd,uue=ste,qI=pj,fue=Dw,SC=hj,Pl=$ae,MI=Iu,LI=Cae,zI=Td,gs=f0,Dt=rce,due=sI,Bw=oI,Vw=ice,hue=fh,pue=H$,Hn=eue,jI=Pg,gue=mse,cc=kd,$n=Fi,iy=T$,aU=gse,we=Z,d0=nte,Va=oh,z1=yj,lU=sce,UI=mj,kr=ya,Sh=cse,Nd=iI,XA=Qle,mue=F$,yue=f4,h0=yz,si=ys,_ue=wo,HI=nse,ni=p4,Ps=rse,Dd=sse,yl=Gre,Sue=Ite,os=O$,To=xce,Ww=ece,vue=TI,qg=nce,Po=Tce,wue=Ice,Kw=Pce,ur=Oce,p0=Iae,BI=Tae,Tt=Pae,qd=Zm,bue=fse,vC=yse,Gw=y4,Eue=Xk,Qe=_se,oy=jae,vc=Zk,ay=function(e,...t){const n=Error.stackTraceLimit;Error.stackTraceLimit=2;const r=new Error;if(Error.stackTraceLimit=n,typeof e!="string")return ZA(e.length,function(...o){const a=Error.stackTraceLimit;Error.stackTraceLimit=2;const c=new Error;return Error.stackTraceLimit=a,eF({self:this,body:e,args:o,pipeables:t,spanName:"<anonymous>",spanOptions:{context:QS.context(!0)},errorDef:r,errorCall:c})});const s=e,i=t[0];return(o,...a)=>ZA(o.length,{[s](...c){const f=Error.stackTraceLimit;Error.stackTraceLimit=2;const d=new Error;return Error.stackTraceLimit=f,eF({self:this,body:o,args:c,pipeables:a,spanName:s,spanOptions:i,errorDef:r,errorCall:d})}}[s])};function ZA(e,t){return Object.defineProperty(t,"length",{value:e,configurable:!0})}function eF(e){let t,n;if(eQ(e.body))t=VS(()=>e.body.apply(e.self,e.args));else try{t=e.body.apply(e.self,e.args)}catch(o){n=o,t=Ad(o)}if(e.pipeables.length>0)try{for(const o of e.pipeables)t=o(t,...e.args)}catch(o){t=n?ps(zn(Gr(n),Gr(o))):Ad(o)}let r=!1;const s=()=>{if(r!==!1)return r;if(e.errorCall.stack){const o=e.errorDef.stack.trim().split(`
200
+ `),a=e.errorCall.stack.trim().split(`
201
+ `);let c=o.slice(2).join(`
202
+ `).trim();c.includes("(")||(c=c.replace(/at (.*)/,"at ($1)"));let f=a.slice(2).join(`
203
+ `).trim();return f.includes("(")||(f=f.replace(/at (.*)/,"at ($1)")),r=`${c}
204
+ ${f}`,r}},i=e.spanOptions&&"captureStackTrace"in e.spanOptions?e.spanOptions:{captureStackTrace:s,...e.spanOptions};return Qe(t,e.spanName,i)}const kue=cte,VI=yr,Cue=ah,WI=Hi,xue=Pu,Rue=Fw,cU=Tw,$ue=Cz,Iue=x(2,(e,t)=>Tu(cj,t)(e)),Tue=e=>AI(EI(Fw,Bf(e))),Pue=e=>AI(EI(Fw,h$(e))),Oue=x(2,(e,t)=>OI(Pue(e),()=>Tue(t))),Aue=e=>AI(zae(e)),Fue=Uce,uU=eU,Nue=tU,vh=Qce;const Due=iU,que=Jce,fU=Xce,dU=Zce,hU=Aue,Mue="effect/QueueEnqueue",pU=Symbol.for(Mue),Lue="effect/QueueDequeue",KI=Symbol.for(Lue),zue="effect/QueueStrategy",GI=Symbol.for(zue),jue="effect/BackingQueue",Uue=Symbol.for(jue),QI={_A:e=>e},Hue={_A:e=>e},gU={_In:e=>e},JI={_Out:e=>e};var xke,Rke;class Bue extends Io{constructor(n,r,s,i,o){super();p(this,"queue");p(this,"takers");p(this,"shutdownHook");p(this,"shutdownFlag");p(this,"strategy");p(this,xke,gU);p(this,Rke,JI);this.queue=n,this.takers=r,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=o}pipe(){return pe(this,arguments)}commit(){return this.take}capacity(){return this.queue.capacity()}get size(){return Ee(()=>Ed(this.unsafeSize(),()=>Pn))}unsafeSize(){return dt(this.shutdownFlag)?re():oe(this.queue.length()-Q$(this.takers)+this.strategy.surplusSize())}get isEmpty(){return Fe(this.size,n=>n<=0)}get isFull(){return Fe(this.size,n=>n>=this.capacity())}get shutdown(){return Ra(et(n=>(T(this.shutdownFlag,xu(!0)),T(ra(Yf(this.takers),r=>z$(r,n.id()),!1,!1),kt(this.strategy.shutdown),Mm(Hm(this.shutdownHook,void 0)),vs))))}get isShutdown(){return se(()=>dt(this.shutdownFlag))}get awaitShutdown(){return Li(this.shutdownHook)}isActive(){return!dt(this.shutdownFlag)}unsafeOffer(n){if(dt(this.shutdownFlag))return!1;let r;if(this.queue.length()===0){const i=T(this.takers,ta(Rn));i!==Rn?(qc(i,n),r=!0):r=!1}else r=!1;if(r)return!0;const s=this.queue.offer(n);return wc(this.strategy,this.queue,this.takers),s}offer(n){return Ee(()=>{if(dt(this.shutdownFlag))return Pn;let r;if(this.queue.length()===0){const i=T(this.takers,ta(Rn));i!==Rn?(qc(i,n),r=!0):r=!1}else r=!1;if(r)return ie(!0);const s=this.queue.offer(n);return wc(this.strategy,this.queue,this.takers),s?ie(!0):this.strategy.handleSurplus([n],this.queue,this.takers,this.shutdownFlag)})}offerAll(n){return Ee(()=>{if(dt(this.shutdownFlag))return Pn;const r=gt(n),s=this.queue.length()===0?gt(cfe(this.takers,r.length)):bl,[i,o]=T(r,mM(s.length));for(let c=0;c<s.length;c++){const f=s[c],d=i[c];qc(f,d)}if(o.length===0)return ie(!0);const a=this.queue.offerAll(o);return wc(this.strategy,this.queue,this.takers),Tm(a)?ie(!0):this.strategy.handleSurplus(a,this.queue,this.takers,this.shutdownFlag)})}get take(){return et(n=>{if(dt(this.shutdownFlag))return Pn;const r=this.queue.poll(Rn);if(r!==Rn)return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),ie(r);{const s=Um(n.id());return T(Ee(()=>(T(this.takers,Rd(s)),wc(this.strategy,this.queue,this.takers),dt(this.shutdownFlag)?Pn:Li(s))),Vl(()=>se(()=>ufe(this.takers,s))))}})}get takeAll(){return Ee(()=>dt(this.shutdownFlag)?Pn:se(()=>{const n=this.queue.pollUpTo(Number.POSITIVE_INFINITY);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),da(n)}))}takeUpTo(n){return Ee(()=>dt(this.shutdownFlag)?Pn:se(()=>{const r=this.queue.pollUpTo(n);return this.strategy.unsafeOnQueueEmptySpace(this.queue,this.takers),da(r)}))}takeBetween(n,r){return Ee(()=>mU(this,n,r,Ut()))}}xke=pU,Rke=KI;const mU=(e,t,n,r)=>n<t?ie(r):T(nfe(e,n),Z(s=>{const i=t-s.length;return i===1?T(wC(e),Fe(o=>T(r,nn(s),gg(o)))):i>1?T(wC(e),Z(o=>mU(e,i-1,n-s.length-1,T(r,nn(s),gg(o))))):ie(T(r,nn(s)))})),Vue=e=>T(se(()=>G$(e)),Z(t=>Qw(Jw(t),sfe()))),Wue=e=>T(se(()=>G$(e)),Z(t=>Qw(Jw(t),yU()))),Kue=e=>T(se(()=>G$(e)),Z(t=>Qw(Jw(t),ife()))),YI=()=>T(se(()=>Ew()),Z(e=>Qw(Jw(e),yU()))),Gue=(e,t,n,r,s)=>new Bue(e,t,n,r,s),Qw=(e,t)=>T(ch(),Fe(n=>Gue(e,Ew(),n,Cu(!1),t)));var $ke;class Que{constructor(t){p(this,"mutable");p(this,$ke,Hue);this.mutable=t}poll(t){return ta(this.mutable,t)}pollUpTo(t){return kw(this.mutable,t)}offerAll(t){return J$(this.mutable,t)}offer(t){return Rd(this.mutable,t)}capacity(){return _ne(this.mutable)}length(){return Q$(this.mutable)}}$ke=Uue;const Jw=e=>new Que(e),Jue=e=>e.size,Yue=e=>e.isShutdown,Xue=e=>e.shutdown,Zue=x(2,(e,t)=>e.offer(t)),efe=x(2,(e,t)=>e.offerAll(t)),wC=e=>e.take,tfe=e=>e.takeAll,nfe=x(2,(e,t)=>e.takeUpTo(t)),rfe=x(3,(e,t,n)=>e.takeBetween(t,n)),sfe=()=>new ofe,yU=()=>new afe,ife=()=>new lfe;var Ike;class ofe{constructor(){p(this,Ike,QI);p(this,"putters",Ew())}surplusSize(){return Q$(this.putters)}onCompleteTakersWithEmptyQueue(t){for(;!Dc(this.putters)&&!Dc(t);){const n=ta(t,void 0),r=ta(this.putters,void 0);r[2]&&qc(r[1],!0),qc(n,r[0])}}get shutdown(){return T(qm,Z(t=>T(se(()=>Yf(this.putters)),Z(n=>ra(n,([r,s,i])=>i?T(z$(s,t),vs):Ve,!1,!1)))))}handleSurplus(t,n,r,s){return et(i=>{const o=Um(i.id());return T(Ee(()=>(this.unsafeOffer(t,o),this.unsafeOnQueueEmptySpace(n,r),wc(this,n,r),dt(s)?Pn:Li(o))),Vl(()=>se(()=>this.unsafeRemove(o))))})}unsafeOnQueueEmptySpace(t,n){let r=!0;for(;r&&(t.capacity()===Number.POSITIVE_INFINITY||t.length()<t.capacity());){const s=T(this.putters,ta(Rn));if(s===Rn)r=!1;else{const i=t.offer(s[0]);i&&s[2]?qc(s[1],!0):i||g0(this.putters,T(Yf(this.putters),xr(s))),wc(this,t,n)}}}unsafeOffer(t,n){const r=gt(t);for(let s=0;s<r.length;s++){const i=r[s];s===r.length-1?T(this.putters,Rd([i,n,!0])):T(this.putters,Rd([i,n,!1]))}}unsafeRemove(t){g0(this.putters,T(Yf(this.putters),Wv(([,n])=>n!==t)))}}Ike=GI;var Tke,f3;let afe=(f3=class{constructor(){p(this,Tke,QI)}surplusSize(){return 0}get shutdown(){return Ve}onCompleteTakersWithEmptyQueue(){}handleSurplus(t,n,r,s){return ie(!1)}unsafeOnQueueEmptySpace(t,n){}},Tke=GI,f3);var Pke;class lfe{constructor(){p(this,Pke,QI)}surplusSize(){return 0}get shutdown(){return Ve}onCompleteTakersWithEmptyQueue(){}handleSurplus(t,n,r,s){return se(()=>(this.unsafeOffer(n,t),wc(this,n,r),!0))}unsafeOnQueueEmptySpace(t,n){}unsafeOffer(t,n){const r=n[Symbol.iterator]();let s,i=!0;for(;!(s=r.next()).done&&i;){if(t.capacity()===0)return;t.poll(Rn),i=t.offer(s.value)}}}Pke=GI;const qc=(e,t)=>Bm(e,ie(t)),g0=(e,t)=>T(e,J$(t)),Yf=e=>T(e,kw(Number.POSITIVE_INFINITY)),cfe=(e,t)=>T(e,kw(t)),ufe=(e,t)=>{g0(e,T(Yf(e),Wv(n=>t!==n)))},wc=(e,t,n)=>{let r=!0;for(;r&&t.length()!==0;){const s=T(n,ta(Rn));if(s!==Rn){const i=t.poll(Rn);i!==Rn?(qc(s,i),e.unsafeOnQueueEmptySpace(t,n)):g0(n,T(Yf(n),xr(s))),r=!0}else r=!1}r&&t.length()===0&&!Dc(n)&&e.onCompleteTakersWithEmptyQueue(n)},no=Symbol.for("effect/PubSub/AbsentValue"),_U=(e,t)=>n=>{n.has(e)||n.set(e,new Set),n.get(e).add(t)},ffe=(e,t)=>n=>{if(!n.has(e))return;const r=n.get(e);r.delete(t),r.size===0&&n.delete(e)},dfe=e=>Ee(()=>{const t=mfe(e);return Efe(t,new Tfe)}),hfe=e=>e.shutdown,pfe=x(2,(e,t)=>e.publish(t)),gfe=e=>e.subscribe,mfe=e=>new Sfe(e!=null&&e.replay?new Afe(e.replay):void 0),yfe=(e,t,n)=>Fe(ch(),r=>_fe(e,t,e.subscribe(),Ew(),r,Cu(!1),n)),_fe=(e,t,n,r,s,i,o)=>new wfe(e,t,n,r,s,i,o,e.replayWindow());class Sfe{constructor(t){p(this,"replayBuffer");p(this,"publisherHead",{value:no,subscribers:0,next:null});p(this,"publisherTail",this.publisherHead);p(this,"publisherIndex",0);p(this,"subscribersIndex",0);p(this,"capacity",Number.MAX_SAFE_INTEGER);this.replayBuffer=t}replayWindow(){return this.replayBuffer?new Ffe(this.replayBuffer):Nfe}isEmpty(){return this.publisherHead===this.publisherTail}isFull(){return!1}size(){return this.publisherIndex-this.subscribersIndex}publish(t){const n=this.publisherTail.subscribers;return n!==0&&(this.publisherTail.next={value:t,subscribers:n,next:null},this.publisherTail=this.publisherTail.next,this.publisherIndex+=1),this.replayBuffer&&this.replayBuffer.offer(t),!0}publishAll(t){if(this.publisherTail.subscribers!==0)for(const n of t)this.publish(n);else this.replayBuffer&&this.replayBuffer.offerAll(t);return Ut()}slide(){this.publisherHead!==this.publisherTail&&(this.publisherHead=this.publisherHead.next,this.publisherHead.value=no,this.subscribersIndex+=1),this.replayBuffer&&this.replayBuffer.slide()}subscribe(){return this.publisherTail.subscribers+=1,new vfe(this,this.publisherTail,this.publisherIndex,!1)}}class vfe{constructor(t,n,r,s){p(this,"self");p(this,"subscriberHead");p(this,"subscriberIndex");p(this,"unsubscribed");this.self=t,this.subscriberHead=n,this.subscriberIndex=r,this.unsubscribed=s}isEmpty(){if(this.unsubscribed)return!0;let t=!0,n=!0;for(;n;)this.subscriberHead===this.self.publisherTail?n=!1:this.subscriberHead.next.value!==no?(t=!1,n=!1):(this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1);return t}size(){return this.unsubscribed?0:this.self.publisherIndex-Math.max(this.subscriberIndex,this.self.subscribersIndex)}poll(t){if(this.unsubscribed)return t;let n=!0,r=t;for(;n;)if(this.subscriberHead===this.self.publisherTail)n=!1;else{const s=this.subscriberHead.next.value;s!==no&&(r=s,this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=no,this.self.subscribersIndex+=1),n=!1),this.subscriberHead=this.subscriberHead.next,this.subscriberIndex+=1}return r}pollUpTo(t){const n=[],r=no;let s=0;for(;s!==t;){const i=this.poll(r);i===r?s=t:(n.push(i),s+=1)}return da(n)}unsubscribe(){if(!this.unsubscribed)for(this.unsubscribed=!0,this.self.publisherTail.subscribers-=1;this.subscriberHead!==this.self.publisherTail;)this.subscriberHead.next.value!==no&&(this.subscriberHead.subscribers-=1,this.subscriberHead.subscribers===0&&(this.self.publisherHead=this.self.publisherHead.next,this.self.publisherHead.value=no,this.self.subscribersIndex+=1)),this.subscriberHead=this.subscriberHead.next}}var Oke;class wfe extends Io{constructor(n,r,s,i,o,a,c,f){super();p(this,"pubsub");p(this,"subscribers");p(this,"subscription");p(this,"pollers");p(this,"shutdownHook");p(this,"shutdownFlag");p(this,"strategy");p(this,"replayWindow");p(this,Oke,JI);this.pubsub=n,this.subscribers=r,this.subscription=s,this.pollers=i,this.shutdownHook=o,this.shutdownFlag=a,this.strategy=c,this.replayWindow=f}commit(){return this.take}pipe(){return pe(this,arguments)}capacity(){return this.pubsub.capacity}isActive(){return!dt(this.shutdownFlag)}get size(){return Ee(()=>dt(this.shutdownFlag)?Pn:ie(this.subscription.size()+this.replayWindow.remaining))}unsafeSize(){return dt(this.shutdownFlag)?re():oe(this.subscription.size()+this.replayWindow.remaining)}get isFull(){return Ee(()=>dt(this.shutdownFlag)?Pn:ie(this.subscription.size()===this.capacity()))}get isEmpty(){return Fe(this.size,n=>n===0)}get shutdown(){return Ra(et(n=>(xu(this.shutdownFlag,!0),T(wI(XI(this.pollers),r=>z$(r,n.id()),!1),kt(se(()=>{this.subscribers.delete(this.subscription),this.subscription.unsubscribe(),this.strategy.unsafeOnPubSubEmptySpace(this.pubsub,this.subscribers)})),Mm(Hm(this.shutdownHook,void 0)),vs))))}get isShutdown(){return se(()=>dt(this.shutdownFlag))}get awaitShutdown(){return Li(this.shutdownHook)}get take(){return et(n=>{if(dt(this.shutdownFlag))return Pn;if(this.replayWindow.remaining>0){const s=this.replayWindow.take();return ie(s)}const r=Dc(this.pollers)?this.subscription.poll(Rn):Rn;if(r===Rn){const s=Um(n.id());return T(Ee(()=>(T(this.pollers,Rd(s)),T(this.subscribers,_U(this.subscription,this.pollers)),this.strategy.unsafeCompletePollers(this.pubsub,this.subscribers,this.subscription,this.pollers),dt(this.shutdownFlag)?Pn:Li(s))),Vl(()=>se(()=>Ife(this.pollers,s))))}else return this.strategy.unsafeOnPubSubEmptySpace(this.pubsub,this.subscribers),ie(r)})}get takeAll(){return Ee(()=>{if(dt(this.shutdownFlag))return Pn;const n=Dc(this.pollers)?xfe(this.subscription):Ut();return this.strategy.unsafeOnPubSubEmptySpace(this.pubsub,this.subscribers),this.replayWindow.remaining>0?ie(nn(this.replayWindow.takeAll(),n)):ie(n)})}takeUpTo(n){return Ee(()=>{if(dt(this.shutdownFlag))return Pn;let r;if(this.replayWindow.remaining>=n){const i=this.replayWindow.takeN(n);return ie(i)}else this.replayWindow.remaining>0&&(r=this.replayWindow.takeAll(),n=n-r.length);const s=Dc(this.pollers)?Rfe(this.subscription,n):Ut();return this.strategy.unsafeOnPubSubEmptySpace(this.pubsub,this.subscribers),ie(r?nn(r,s):s)})}takeBetween(n,r){return Ee(()=>SU(this,n,r,Ut()))}}Oke=KI;const SU=(e,t,n,r)=>n<t?ie(r):T(e.takeUpTo(n),Z(s=>{const i=t-s.length;return i===1?T(e.take,Fe(o=>T(r,nn(s),gg(o)))):i>1?T(e.take,Z(o=>SU(e,i-1,n-s.length-1,T(r,nn(s),gg(o))))):ie(T(r,nn(s)))}));var Ake,Fke;class bfe{constructor(t,n,r,s,i,o){p(this,"pubsub");p(this,"subscribers");p(this,"scope");p(this,"shutdownHook");p(this,"shutdownFlag");p(this,"strategy");p(this,Ake,gU);p(this,Fke,JI);this.pubsub=t,this.subscribers=n,this.scope=r,this.shutdownHook=s,this.shutdownFlag=i,this.strategy=o}capacity(){return this.pubsub.capacity}get size(){return Ee(()=>dt(this.shutdownFlag)?Pn:se(()=>this.pubsub.size()))}unsafeSize(){return dt(this.shutdownFlag)?re():oe(this.pubsub.size())}get isFull(){return Fe(this.size,t=>t===this.capacity())}get isEmpty(){return Fe(this.size,t=>t===0)}get awaitShutdown(){return Li(this.shutdownHook)}get isShutdown(){return se(()=>dt(this.shutdownFlag))}get shutdown(){return Ra(et(t=>(T(this.shutdownFlag,xu(!0)),T(this.scope.close(M$(t.id())),kt(this.strategy.shutdown),Mm(Hm(this.shutdownHook,void 0)),vs))))}publish(t){return Ee(()=>dt(this.shutdownFlag)?Pn:this.pubsub.publish(t)?(this.strategy.unsafeCompleteSubscribers(this.pubsub,this.subscribers),ie(!0)):this.strategy.handleSurplus(this.pubsub,this.subscribers,Xt(t),this.shutdownFlag))}isActive(){return!dt(this.shutdownFlag)}unsafeOffer(t){return dt(this.shutdownFlag)?!1:this.pubsub.publish(t)?(this.strategy.unsafeCompleteSubscribers(this.pubsub,this.subscribers),!0):!1}publishAll(t){return Ee(()=>{if(dt(this.shutdownFlag))return Pn;const n=$fe(this.pubsub,t);return this.strategy.unsafeCompleteSubscribers(this.pubsub,this.subscribers),Tm(n)?ie(!0):this.strategy.handleSurplus(this.pubsub,this.subscribers,n,this.shutdownFlag)})}get subscribe(){const t=ya(Nw([this.scope.fork(Km),yfe(this.pubsub,this.subscribers,this.strategy)]),n=>n[0].addFinalizer(()=>n[1].shutdown));return Fe(vI(t,(n,r)=>n[0].close(r)),n=>n[1])}offer(t){return this.publish(t)}offerAll(t){return this.publishAll(t)}pipe(){return pe(this,arguments)}}Ake=pU,Fke=KI;const Efe=(e,t)=>Z(gh(),n=>Fe(ch(),r=>kfe(e,new Map,n,r,Cu(!1),t))),kfe=(e,t,n,r,s,i)=>new bfe(e,t,n,r,s,i),Cfe=(e,t)=>{Bm(e,ie(t))},vU=(e,t)=>T(e,J$(t)),XI=e=>T(e,kw(Number.POSITIVE_INFINITY)),xfe=e=>e.pollUpTo(Number.POSITIVE_INFINITY),Rfe=(e,t)=>e.pollUpTo(t),$fe=(e,t)=>e.publishAll(t),Ife=(e,t)=>{vU(e,T(XI(e),Wv(n=>n!==t)))};class Tfe{get shutdown(){return Ve}handleSurplus(t,n,r,s){return ie(!1)}unsafeOnPubSubEmptySpace(t,n){}unsafeCompletePollers(t,n,r,s){return Pfe(this,t,n,r,s)}unsafeCompleteSubscribers(t,n){return Ofe(this,t,n)}}const Pfe=(e,t,n,r,s)=>{let i=!0;for(;i&&!r.isEmpty();){const o=T(s,ta(Rn));if(o===Rn)T(n,ffe(r,s)),Dc(s)?i=!1:T(n,_U(r,s));else{const a=r.poll(Rn);a===Rn?vU(s,T(XI(s),xr(o))):(Cfe(o,a),e.unsafeOnPubSubEmptySpace(t,n))}}},Ofe=(e,t,n)=>{for(const[r,s]of n)for(const i of s)e.unsafeCompletePollers(t,n,r,i)};class Afe{constructor(t){p(this,"capacity");p(this,"head",{value:no,next:null});p(this,"tail",this.head);p(this,"size",0);p(this,"index",0);this.capacity=t}slide(){this.index++}offer(t){this.tail.value=t,this.tail.next={value:no,next:null},this.tail=this.tail.next,this.size===this.capacity?this.head=this.head.next:this.size+=1}offerAll(t){for(const n of t)this.offer(n)}}class Ffe{constructor(t){p(this,"buffer");p(this,"head");p(this,"index");p(this,"remaining");this.buffer=t,this.index=t.index,this.remaining=t.size,this.head=t.head}fastForward(){for(;this.index<this.buffer.index;)this.head=this.head.next,this.index++}take(){if(this.remaining===0)return;this.index<this.buffer.index&&this.fastForward(),this.remaining--;const t=this.head.value;return this.head=this.head.next,t}takeN(t){if(this.remaining===0)return Ut();this.index<this.buffer.index&&this.fastForward();const n=Math.min(t,this.remaining),r=new Array(n);for(let s=0;s<n;s++){const i=this.head.value;this.head=this.head.next,r[s]=i}return this.remaining-=n,xn(r)}takeAll(){return this.takeN(this.remaining)}}const Nfe={remaining:0,take:()=>{},takeN:()=>Ut(),takeAll:()=>Ut()},wU=dfe,bC=hfe,ZI=pfe,tF=gfe,Yw=Vue,eT=Wue,tT=Kue,dr=YI,Dfe=Jue,qfe=Yue,In=Xue,$t=Zue,nT=efe,Ol=wC,Mfe=tfe,bU=rfe,EU="Continue",Lfe="Close",zfe="Yield",jfe="effect/ChannelChildExecutorDecision",nF=Symbol.for(jfe),Ufe={[nF]:nF},kU=e=>{const t=Object.create(Ufe);return t._tag=EU,t},H_="ContinuationK",Hfe="ContinuationFinalizer",CU=Symbol.for("effect/ChannelContinuation"),xU={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutDone:e=>e,_OutErr2:e=>e,_OutElem:e=>e,_OutDone2:e=>e};var Nke;class rT{constructor(t,n){p(this,"onSuccess");p(this,"onHalt");p(this,"_tag",H_);p(this,Nke,xU);this.onSuccess=t,this.onHalt=n}onExit(t){return hh(t)?this.onHalt(t.cause):this.onSuccess(t.value)}}Nke=CU;var Dke;class Bfe{constructor(t){p(this,"finalizer");p(this,"_tag",Hfe);p(this,Dke,xU);this.finalizer=t}}Dke=CU;const RU="PullAfterNext",Vfe="PullAfterAllEnqueued",Wfe="effect/ChannelUpstreamPullStrategy",Kfe=Symbol.for(Wfe),Gfe={_A:e=>e},Qfe={[Kfe]:Gfe},$U=e=>{const t=Object.create(Qfe);return t._tag=RU,t.emitSeparator=e,t},IU="BracketOut",TU="Bridge",sT="ConcatAll",PU="Emit",OU="Ensuring",AU="Fail",iT="Fold",FU="FromEffect",NU="PipeTo",Jfe="Provide",DU="Read",qU="Succeed",MU="SucceedNow",LU="Suspend",Yfe="effect/Channel",m0=Symbol.for(Yfe),Xfe={_Env:e=>e,_InErr:e=>e,_InElem:e=>e,_InDone:e=>e,_OutErr:e=>e,_OutElem:e=>e,_OutDone:e=>e},ts={[m0]:Xfe,pipe(){return pe(this,arguments)}},zU=e=>_e(e,m0)||$a(e),Zfe=x(2,(e,t)=>{const n=Object.create(ts);return n._tag=IU,n.acquire=()=>e,n.finalizer=t,n}),oT=x(2,(e,t)=>{const n=Object.create(ts);return n._tag=iT,n.channel=e,n.k=new rT(Nu,t),n}),jU=(e,t,n)=>{const r=Object.create(ts);return r._tag=sT,r.combineInners=t,r.combineAll=n,r.onPull=()=>$U(re()),r.onEmit=()=>kU,r.value=()=>e,r.k=Ce,r},ede=x(4,(e,t,n,r)=>{const s=Object.create(ts);return s._tag=sT,s.combineInners=n,s.combineAll=r,s.onPull=()=>$U(re()),s.onEmit=()=>kU,s.value=()=>e,s.k=t,s}),aT=x(2,(e,t)=>{const n=Object.create(ts);return n._tag=TU,n.input=t,n.channel=e,n}),lT=x(2,(e,t)=>{const n=Object.create(ts);return n._tag=OU,n.channel=e,n.finalizer=t,n}),wh=e=>an(gu(e)),an=e=>UU(()=>e),UU=e=>{const t=Object.create(ts);return t._tag=AU,t.error=e,t},Ze=x(2,(e,t)=>{const n=Object.create(ts);return n._tag=iT,n.channel=e,n.k=new rT(t,an),n}),en=e=>{const t=Object.create(ts);return t._tag=FU,t.effect=()=>e,t},rr=x(2,(e,t)=>{const n=Object.create(ts);return n._tag=NU,n.left=()=>e,n.right=()=>t,n}),ly=e=>Vs({onInput:e.onInput,onFailure:t=>Zn(Mw(t),{onLeft:e.onFailure,onRight:an}),onDone:e.onDone}),Vs=e=>{const t=Object.create(ts);return t._tag=DU,t.more=e.onInput,t.done=new rT(e.onDone,e.onFailure),t},Nu=e=>HU(()=>e),Eo=e=>{const t=Object.create(ts);return t._tag=MU,t.terminal=e,t},bh=e=>{const t=Object.create(ts);return t._tag=LU,t.channel=e,t},HU=e=>{const t=Object.create(ts);return t._tag=qU,t.evaluate=e,t},sr=Eo(void 0),pt=e=>{const t=Object.create(ts);return t._tag=PU,t.out=e,t},cy="Done",uy="Emit",Eh="FromEffect",fy="Read",tde=Symbol.for("effect/ChannelState"),nde={_E:e=>e,_R:e=>e},Xw={[tde]:nde},tf=()=>{const e=Object.create(Xw);return e._tag=cy,e},j1=()=>{const e=Object.create(Xw);return e._tag=uy,e},Gh=e=>{const t=Object.create(Xw);return t._tag=Eh,t.effect=e,t},U1=(e,t,n,r)=>{const s=Object.create(Xw);return s._tag=fy,s.upstream=e,s.onEffect=t,s.onEmit=n,s.onDone=r,s},y0=e=>e._tag===Eh,rde=e=>y0(e)?e.effect:Le,rF=e=>y0(e)?oue(e.effect):void 0,BU="PullFromChild",EC="PullFromUpstream",kC="DrainChildExecutors",VU="Emit";class n_{constructor(t,n,r){p(this,"childExecutor");p(this,"parentSubexecutor");p(this,"onEmit");p(this,"_tag",BU);this.childExecutor=t,this.parentSubexecutor=n,this.onEmit=r}close(t){const n=this.childExecutor.close(t),r=this.parentSubexecutor.close(t);return n!==void 0&&r!==void 0?qd($n(n),$n(r),(s,i)=>T(s,Rg(i))):n!==void 0?n:r!==void 0?r:void 0}enqueuePullFromChild(t){return this}}class fc{constructor(t,n,r,s,i,o,a,c){p(this,"upstreamExecutor");p(this,"createChild");p(this,"lastDone");p(this,"activeChildExecutors");p(this,"combineChildResults");p(this,"combineWithChildResult");p(this,"onPull");p(this,"onEmit");p(this,"_tag",EC);this.upstreamExecutor=t,this.createChild=n,this.lastDone=r,this.activeChildExecutors=s,this.combineChildResults=i,this.combineWithChildResult=o,this.onPull=a,this.onEmit=c}close(t){const n=this.upstreamExecutor.close(t),s=[...this.activeChildExecutors.map(i=>i!==void 0?i.childExecutor.close(t):void 0),n].reduce((i,o)=>i!==void 0&&o!==void 0?qd(i,$n(o),(a,c)=>Rg(a,c)):i!==void 0?i:o!==void 0?$n(o):void 0,void 0);return s}enqueuePullFromChild(t){return new fc(this.upstreamExecutor,this.createChild,this.lastDone,[...this.activeChildExecutors,t],this.combineChildResults,this.combineWithChildResult,this.onPull,this.onEmit)}}class Pf{constructor(t,n,r,s,i,o,a){p(this,"upstreamExecutor");p(this,"lastDone");p(this,"activeChildExecutors");p(this,"upstreamDone");p(this,"combineChildResults");p(this,"combineWithChildResult");p(this,"onPull");p(this,"_tag",kC);this.upstreamExecutor=t,this.lastDone=n,this.activeChildExecutors=r,this.upstreamDone=s,this.combineChildResults=i,this.combineWithChildResult=o,this.onPull=a}close(t){const n=this.upstreamExecutor.close(t),s=[...this.activeChildExecutors.map(i=>i!==void 0?i.childExecutor.close(t):void 0),n].reduce((i,o)=>i!==void 0&&o!==void 0?qd(i,$n(o),(a,c)=>Rg(a,c)):i!==void 0?i:o!==void 0?$n(o):void 0,void 0);return s}enqueuePullFromChild(t){return new Pf(this.upstreamExecutor,this.lastDone,[...this.activeChildExecutors,t],this.upstreamDone,this.combineChildResults,this.combineWithChildResult,this.onPull)}}class H1{constructor(t,n){p(this,"value");p(this,"next");p(this,"_tag",VU);this.value=t,this.next=n}close(t){const n=this.next.close(t);return n}enqueuePullFromChild(t){return this}}const sde="Pulled",ide="NoUpstream",ode="effect/ChannelUpstreamPullRequest",ade=Symbol.for(ode),lde={_A:e=>e},WU={[ade]:lde},sF=e=>{const t=Object.create(WU);return t._tag=sde,t.value=e,t},cde=e=>{const t=Object.create(WU);return t._tag=ide,t.activeDownstreamCount=e,t};class bc{constructor(t,n,r){p(this,"_activeSubexecutor");p(this,"_cancelled");p(this,"_closeLastSubstream");p(this,"_currentChannel");p(this,"_done");p(this,"_doneStack",[]);p(this,"_emitted");p(this,"_executeCloseLastSubstream");p(this,"_input");p(this,"_inProgressFinalizer");p(this,"_providedEnv");this._currentChannel=t,this._executeCloseLastSubstream=r,this._providedEnv=n}run(){let t;for(;t===void 0;)if(this._cancelled!==void 0)t=this.processCancellation();else if(this._activeSubexecutor!==void 0)t=this.runSubexecutor();else try{if(this._currentChannel===void 0)t=tf();else switch($a(this._currentChannel)&&(this._currentChannel=en(this._currentChannel)),this._currentChannel._tag){case IU:{t=this.runBracketOut(this._currentChannel);break}case TU:{const n=this._currentChannel.input;if(this._currentChannel=this._currentChannel.channel,this._input!==void 0){const r=this._input;this._input=void 0;const s=()=>we(n.awaitRead(),()=>zt(()=>{const i=r.run();switch(i._tag){case cy:return Ti(r.getDone(),{onFailure:o=>n.error(o),onSuccess:o=>n.done(o)});case uy:return we(n.emit(r.getEmit()),()=>s());case Eh:return si(i.effect,{onFailure:o=>n.error(o),onSuccess:()=>s()});case fy:return cT(i,()=>s(),o=>n.error(o))}}));t=Gh(we(zI(Jt(s())),i=>Re(()=>this.addFinalizer(o=>we(Fs(i),()=>zt(()=>{const a=this.restorePipe(o,r);return a!==void 0?a:Le}))))))}break}case sT:{const n=new bc(this._currentChannel.value(),this._providedEnv,s=>Re(()=>{const i=this._closeLastSubstream===void 0?Le:this._closeLastSubstream;this._closeLastSubstream=T(i,Tt(s))}));n._input=this._input;const r=this._currentChannel;this._activeSubexecutor=new fc(n,s=>r.k(s),void 0,[],(s,i)=>r.combineInners(s,i),(s,i)=>r.combineAll(s,i),s=>r.onPull(s),s=>r.onEmit(s)),this._closeLastSubstream=void 0,this._currentChannel=void 0;break}case PU:{this._emitted=this._currentChannel.out,this._currentChannel=this._activeSubexecutor!==void 0?void 0:sr,t=j1();break}case OU:{this.runEnsuring(this._currentChannel);break}case AU:{t=this.doneHalt(this._currentChannel.error());break}case iT:{this._doneStack.push(this._currentChannel.k),this._currentChannel=this._currentChannel.channel;break}case FU:{const n=this._providedEnv===void 0?this._currentChannel.effect():T(this._currentChannel.effect(),Hn(this._providedEnv));t=Gh(si(n,{onFailure:r=>{const s=this.doneHalt(r);return s!==void 0&&y0(s)?s.effect:Le},onSuccess:r=>{const s=this.doneSucceed(r);return s!==void 0&&y0(s)?s.effect:Le}}));break}case NU:{const n=this._input,r=new bc(this._currentChannel.left(),this._providedEnv,s=>this._executeCloseLastSubstream(s));r._input=n,this._input=r,this.addFinalizer(s=>{const i=this.restorePipe(s,n);return i!==void 0?i:Le}),this._currentChannel=this._currentChannel.right();break}case Jfe:{const n=this._providedEnv;this._providedEnv=this._currentChannel.context(),this._currentChannel=this._currentChannel.inner,this.addFinalizer(()=>Re(()=>{this._providedEnv=n}));break}case DU:{const n=this._currentChannel;t=U1(this._input,Ce,r=>{try{this._currentChannel=n.more(r)}catch(s){this._currentChannel=n.done.onExit(KS(s))}},r=>{const s=i=>n.done.onExit(i);this._currentChannel=s(r)});break}case qU:{t=this.doneSucceed(this._currentChannel.evaluate());break}case MU:{t=this.doneSucceed(this._currentChannel.terminal);break}case LU:{this._currentChannel=this._currentChannel.channel();break}}}catch(n){this._currentChannel=an(mu(n))}return t}getDone(){return this._done}getEmit(){return this._emitted}cancelWith(t){this._cancelled=t}clearInProgressFinalizer(){this._inProgressFinalizer=void 0}storeInProgressFinalizer(t){this._inProgressFinalizer=t}popAllFinalizers(t){const n=[];let r=this._doneStack.pop();for(;r;)r._tag==="ContinuationFinalizer"&&n.push(r.finalizer),r=this._doneStack.pop();const s=n.length===0?Le:V1(n,t);return this.storeInProgressFinalizer(s),s}popNextFinalizers(){const t=[];for(;this._doneStack.length!==0;){const n=this._doneStack[this._doneStack.length-1];if(n._tag===H_)return t;t.push(n),this._doneStack.pop()}return t}restorePipe(t,n){const r=this._input;return this._input=n,r!==void 0?r.close(t):Le}close(t){let n;const r=this._inProgressFinalizer;r!==void 0&&(n=T(r,Tf(Re(()=>this.clearInProgressFinalizer()))));let s;const i=this.popAllFinalizers(t);i!==void 0&&(s=T(i,Tf(Re(()=>this.clearInProgressFinalizer()))));const o=this._activeSubexecutor===void 0?void 0:this._activeSubexecutor.close(t);if(!(o===void 0&&n===void 0&&s===void 0))return T($n(B1(o)),p0($n(B1(n))),p0($n(B1(s))),je(([[a,c],f])=>T(a,Rg(c),Rg(f))),Sc,we(a=>zt(()=>a)))}doneSucceed(t){if(this._doneStack.length===0)return this._done=_n(t),this._currentChannel=void 0,tf();const n=this._doneStack[this._doneStack.length-1];if(n._tag===H_){this._doneStack.pop(),this._currentChannel=n.onSuccess(t);return}const r=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=r.reverse(),this._done=_n(t),this._currentChannel=void 0,tf();const s=V1(r.map(o=>o.finalizer),_n(t));this.storeInProgressFinalizer(s);const i=T(s,Tf(Re(()=>this.clearInProgressFinalizer())),Sc,we(()=>Re(()=>this.doneSucceed(t))));return Gh(i)}doneHalt(t){if(this._doneStack.length===0)return this._done=jn(t),this._currentChannel=void 0,tf();const n=this._doneStack[this._doneStack.length-1];if(n._tag===H_){this._doneStack.pop();try{this._currentChannel=n.onHalt(t)}catch(o){this._currentChannel=an(mu(o))}return}const r=this.popNextFinalizers();if(this._doneStack.length===0)return this._doneStack=r.reverse(),this._done=jn(t),this._currentChannel=void 0,tf();const s=V1(r.map(o=>o.finalizer),jn(t));this.storeInProgressFinalizer(s);const i=T(s,Tf(Re(()=>this.clearInProgressFinalizer())),Sc,we(()=>Re(()=>this.doneHalt(t))));return Gh(i)}processCancellation(){return this._currentChannel=void 0,this._done=this._cancelled,this._cancelled=void 0,tf()}runBracketOut(t){const n=Sc(si(this.provide(t.acquire()),{onFailure:r=>Re(()=>{this._currentChannel=an(r)}),onSuccess:r=>Re(()=>{this.addFinalizer(s=>this.provide(t.finalizer(r,s))),this._currentChannel=pt(r)})}));return Gh(n)}provide(t){return this._providedEnv===void 0?t:T(t,Hn(this._providedEnv))}runEnsuring(t){this.addFinalizer(t.finalizer),this._currentChannel=t.channel}addFinalizer(t){this._doneStack.push(new Bfe(t))}runSubexecutor(){const t=this._activeSubexecutor;switch(t._tag){case BU:return this.pullFromChild(t.childExecutor,t.parentSubexecutor,t.onEmit,t);case EC:return this.pullFromUpstream(t);case kC:return this.drainChildExecutors(t);case VU:return this._emitted=t.value,this._activeSubexecutor=t.next,j1()}}replaceSubexecutor(t){this._currentChannel=void 0,this._activeSubexecutor=t}finishWithExit(t){const n=Ti(t,{onFailure:r=>this.doneHalt(r),onSuccess:r=>this.doneSucceed(r)});return this._activeSubexecutor=void 0,n===void 0?Le:rde(n)}finishSubexecutorWithCloseEffect(t,...n){this.addFinalizer(()=>T(n,er(s=>T(Re(()=>s(t)),we(i=>i!==void 0?i:Le)),{discard:!0})));const r=T(t,Ti({onFailure:s=>this.doneHalt(s),onSuccess:s=>this.doneSucceed(s)}));return this._activeSubexecutor=void 0,r}applyUpstreamPullStrategy(t,n,r){switch(r._tag){case RU:{const s=!t||n.some(i=>i!==void 0);return[r.emitSeparator,s?[void 0,...n]:n]}case Vfe:{const s=!t||n.some(i=>i!==void 0);return[r.emitSeparator,s?[...n,void 0]:n]}}}pullFromChild(t,n,r,s){return U1(t,Ce,i=>{const o=r(i);switch(o._tag){case EU:break;case Lfe:{this.finishWithDoneValue(t,n,o.value);break}case zfe:{const a=n.enqueuePullFromChild(s);this.replaceSubexecutor(a);break}}this._activeSubexecutor=new H1(i,this._activeSubexecutor)},Ti({onFailure:i=>{const o=this.handleSubexecutorFailure(t,n,i);return o===void 0?void 0:rF(o)},onSuccess:i=>{this.finishWithDoneValue(t,n,i)}}))}finishWithDoneValue(t,n,r){const s=n;switch(s._tag){case EC:{const i=new fc(s.upstreamExecutor,s.createChild,s.lastDone!==void 0?s.combineChildResults(s.lastDone,r):r,s.activeChildExecutors,s.combineChildResults,s.combineWithChildResult,s.onPull,s.onEmit);this._closeLastSubstream=t.close(_n(r)),this.replaceSubexecutor(i);break}case kC:{const i=new Pf(s.upstreamExecutor,s.lastDone!==void 0?s.combineChildResults(s.lastDone,r):r,s.activeChildExecutors,s.upstreamDone,s.combineChildResults,s.combineWithChildResult,s.onPull);this._closeLastSubstream=t.close(_n(r)),this.replaceSubexecutor(i);break}}}handleSubexecutorFailure(t,n,r){return this.finishSubexecutorWithCloseEffect(jn(r),s=>n.close(s),s=>t.close(s))}pullFromUpstream(t){if(t.activeChildExecutors.length===0)return this.performPullFromUpstream(t);const n=t.activeChildExecutors[0],r=new fc(t.upstreamExecutor,t.createChild,t.lastDone,t.activeChildExecutors.slice(1),t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit);if(n===void 0)return this.performPullFromUpstream(r);this.replaceSubexecutor(new n_(n.childExecutor,r,n.onEmit))}performPullFromUpstream(t){return U1(t.upstreamExecutor,n=>{const r=this._closeLastSubstream===void 0?Le:this._closeLastSubstream;return this._closeLastSubstream=void 0,T(this._executeCloseLastSubstream(r),Tt(n))},n=>{if(this._closeLastSubstream!==void 0){const o=this._closeLastSubstream;return this._closeLastSubstream=void 0,T(this._executeCloseLastSubstream(o),je(()=>{const a=new bc(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);a._input=this._input;const[c,f]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(sF(n)));this._activeSubexecutor=new n_(a,new fc(t.upstreamExecutor,t.createChild,t.lastDone,f,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),Wt(c)&&(this._activeSubexecutor=new H1(c.value,this._activeSubexecutor))}))}const r=new bc(t.createChild(n),this._providedEnv,this._executeCloseLastSubstream);r._input=this._input;const[s,i]=this.applyUpstreamPullStrategy(!1,t.activeChildExecutors,t.onPull(sF(n)));this._activeSubexecutor=new n_(r,new fc(t.upstreamExecutor,t.createChild,t.lastDone,i,t.combineChildResults,t.combineWithChildResult,t.onPull,t.onEmit),t.onEmit),Wt(s)&&(this._activeSubexecutor=new H1(s.value,this._activeSubexecutor))},n=>{if(t.activeChildExecutors.some(i=>i!==void 0)){const i=new Pf(t.upstreamExecutor,t.lastDone,[void 0,...t.activeChildExecutors],t.upstreamExecutor.getDone(),t.combineChildResults,t.combineWithChildResult,t.onPull);if(this._closeLastSubstream!==void 0){const o=this._closeLastSubstream;return this._closeLastSubstream=void 0,T(this._executeCloseLastSubstream(o),je(()=>this.replaceSubexecutor(i)))}this.replaceSubexecutor(i);return}const r=this._closeLastSubstream,s=this.finishSubexecutorWithCloseEffect(T(n,one(i=>t.combineWithChildResult(t.lastDone,i))),()=>r,i=>t.upstreamExecutor.close(i));return s===void 0?void 0:rF(s)})}drainChildExecutors(t){if(t.activeChildExecutors.length===0){const i=this._closeLastSubstream;return i!==void 0&&this.addFinalizer(()=>Pt(i)),this.finishSubexecutorWithCloseEffect(t.upstreamDone,()=>i,o=>t.upstreamExecutor.close(o))}const n=t.activeChildExecutors[0],r=t.activeChildExecutors.slice(1);if(n===void 0){const[i,o]=this.applyUpstreamPullStrategy(!0,r,t.onPull(cde(r.reduce((a,c)=>c!==void 0?a+1:a,0))));return this.replaceSubexecutor(new Pf(t.upstreamExecutor,t.lastDone,o,t.upstreamDone,t.combineChildResults,t.combineWithChildResult,t.onPull)),Wt(i)?(this._emitted=i.value,j1()):void 0}const s=new Pf(t.upstreamExecutor,t.lastDone,r,t.upstreamDone,t.combineChildResults,t.combineWithChildResult,t.onPull);this.replaceSubexecutor(new n_(n.childExecutor,s,n.onEmit))}}const B1=e=>e!==void 0?e:Le,V1=(e,t)=>T(er(e,n=>$n(n(t))),je(n=>T(rne(n),Yt(()=>_s))),we(n=>zt(()=>n))),cT=(e,t,n)=>{const r=[e],s=()=>{const i=r.pop();if(i===void 0||i.upstream===void 0)return rue("Unexpected end of input for channel execution");const o=i.upstream.run();switch(o._tag){case uy:{const a=i.onEmit(i.upstream.getEmit());return r.length===0?a===void 0?zt(t):T(a,si({onFailure:n,onSuccess:t})):a===void 0?zt(()=>s()):T(a,si({onFailure:n,onSuccess:()=>s()}))}case cy:{const a=i.onDone(i.upstream.getDone());return r.length===0?a===void 0?zt(t):T(a,si({onFailure:n,onSuccess:t})):a===void 0?zt(()=>s()):T(a,si({onFailure:n,onSuccess:()=>s()}))}case Eh:return r.push(i),T(i.onEffect(o.effect),sa(a=>zt(()=>{const c=i.onDone(jn(a));return c===void 0?Le:c})),si({onFailure:n,onSuccess:()=>s()}));case fy:return r.push(i),r.push(o),zt(()=>s())}};return s()},uT=x(2,(e,t)=>{const n=(r,s,i)=>DI(Re(()=>new bc(e,void 0,Ce)),o=>zt(()=>B_(o.run(),o).pipe(iy(r),Tt(yn(r)),BI(yn(s)))),(o,a)=>{const c=o.close(a);return c===void 0?Le:Sh(c,f=>Rl(i,ps(f)))});return Tl(r=>jw([xj(t,YS),rt(),rt()]).pipe(we(([s,i,o])=>r(n(i,o,s)).pipe(gs(t),we(a=>t.addFinalizer(c=>{const f=hh(c)?Kae(c.cause):void 0;return Kk(i).pipe(we(d=>d?jt(o,void 0).pipe(Tt(Hj(a)),Tt(GA(a))):jt(o,void 0).pipe(Tt(f&&d$(f)>0?ry(a,YX(f)):Fs(a)),Tt(GA(a)))))}).pipe(Tt(r(yn(i)))))))))}),B_=(e,t)=>{const n=e;switch(n._tag){case Eh:return T(n.effect,we(()=>B_(t.run(),t)));case uy:return B_(t.run(),t);case cy:return zt(()=>t.getDone());case fy:return cT(n,()=>B_(t.run(),t),ps)}},KU="Done",ude="Await",fde="effect/ChannelMergeDecision",dde=Symbol.for(fde),GU={[dde]:{_R:e=>e,_E0:e=>e,_Z0:e=>e,_E:e=>e,_Z:e=>e}},hde=e=>{const t=Object.create(GU);return t._tag=KU,t.effect=e,t},CC=e=>{const t=Object.create(GU);return t._tag=ude,t.f=e,t},QU="BothRunning",JU="LeftDone",YU="RightDone",pde="effect/ChannelMergeState",iF=Symbol.for(pde),fT={[iF]:iF},W1=(e,t)=>{const n=Object.create(fT);return n._tag=QU,n.left=e,n.right=t,n},oF=e=>{const t=Object.create(fT);return t._tag=JU,t.f=e,t},aF=e=>{const t=Object.create(fT);return t._tag=YU,t.f=e,t},XU="BackPressure",ZU="BufferSliding",gde="effect/ChannelMergeStrategy",lF=Symbol.for(gde),e6={[lF]:lF},mde=e=>{const t=Object.create(e6);return t._tag=XU,t},yde=e=>{const t=Object.create(e6);return t._tag=ZU,t},_de=x(2,(e,{onBackPressure:t,onBufferSliding:n})=>{switch(e._tag){case XU:return t();case ZU:return n()}}),lf="Empty",lp="Emit",cp="Error",up="Done",t6=e=>({_tag:lf,notifyProducer:e}),K1=e=>({_tag:lp,notifyConsumers:e}),Sde=e=>({_tag:cp,cause:e}),vde=e=>({_tag:up,done:e});class wde{constructor(t){p(this,"ref");this.ref=t}awaitRead(){return Va(uc(this.ref,t=>t._tag===lf?[yn(t.notifyProducer),t]:[Le,t]))}get close(){return MI(t=>this.error(qw(t)))}done(t){return Va(uc(this.ref,n=>{switch(n._tag){case lf:return[yn(n.notifyProducer),n];case lp:return[er(n.notifyConsumers,r=>jt(r,$e(t)),{discard:!0}),vde(t)];case cp:return[to,n];case up:return[to,n]}}))}emit(t){return we(rt(),n=>Va(uc(this.ref,r=>{switch(r._tag){case lf:return[yn(r.notifyProducer),r];case lp:{const s=r.notifyConsumers[0],i=r.notifyConsumers.slice(1);if(s!==void 0)return[jt(s,Pe(t)),i.length===0?t6(n):K1(i)];throw new Error("Bug: Channel.SingleProducerAsyncInput.emit - Queue was empty! please report an issue at https://github.com/Effect-TS/effect/issues")}case cp:return[to,r];case up:return[to,r]}})))}error(t){return Va(uc(this.ref,n=>{switch(n._tag){case lf:return[yn(n.notifyProducer),n];case lp:return[er(n.notifyConsumers,r=>Kf(r,t),{discard:!0}),Sde(t)];case cp:return[to,n];case up:return[to,n]}}))}get take(){return this.takeWith(t=>jn(kI(t,$e)),t=>_n(t),t=>Vm(Pe(t)))}takeWith(t,n,r){return we(rt(),s=>Va(uc(this.ref,i=>{switch(i._tag){case lf:return[Tt(jt(i.notifyProducer,void 0),h0(yn(s),{onFailure:t,onSuccess:Zn({onLeft:r,onRight:n})})),K1([s])];case lp:return[h0(yn(s),{onFailure:t,onSuccess:Zn({onLeft:r,onRight:n})}),K1([...i.notifyConsumers,s])];case cp:return[Pt(t(i.cause)),i];case up:return[Pt(r(i.done)),i]}})))}}const dT=()=>T(rt(),we(e=>Au(t6(e))),je(e=>new wde(e))),bde=(e,t,n)=>Ze(en(Au(()=>Le)),r=>T(en(Sc(kr(e,s=>Tg(r,i=>n(s,i))))),Ze(t),lT(s=>we(Qf(r),i=>i(s))))),Ede=x(2,(e,t)=>hT(e,()=>t)),kde=x(2,(e,t)=>oT(e,n=>Zn(Mw(n),{onLeft:t,onRight:an}))),_0=x(2,(e,t)=>ede(e,t,()=>{},()=>{})),Zw=e=>{const t=Vs({onInput:()=>t,onFailure:an,onDone:Nu});return rr(e,t)},n6=x(2,(e,t)=>lT(e,()=>t)),Cde=e=>Ze(e,Ce),eb=e=>hi(e.takeWith(an,t=>Ze(pt(t),()=>eb(e)),Nu)),r6=()=>ly({onInput:e=>Ze(pt(e),()=>r6()),onFailure:wh,onDone:Eo}),hT=x(2,(e,t)=>Ze(e,n=>HU(()=>t(n)))),xde=x(2,(e,t)=>Rde(e,kI(t))),Rde=x(2,(e,t)=>oT(e,n=>an(t(n)))),tb=x(2,(e,t)=>{const n=ly({onInput:r=>Ze(pt(t(r)),()=>n),onFailure:wh,onDone:Eo});return rr(e,n)}),s6=x(2,(e,t)=>{const n=Vs({onInput:r=>T(en(t(r)),Ze(pt),Ze(()=>n)),onFailure:an,onDone:Eo});return rr(e,n)}),$de=x(3,(e,t,n)=>pT(r=>X(function*(){const s=yield*dT(),i=eb(s),o=yield*Yw(n);yield*Rl(r,In(o));const a=yield*rt(),c=n===Number.POSITIVE_INFINITY?g=>Ce:(yield*Ww(n)).withPermits;yield*(yield*i.pipe(rr(e),Mc(r))).pipe(si({onFailure:g=>$t(o,ps(g)),onSuccess:Zn({onLeft:g=>Tt(Jt(c(n)(Le)),Sa($t(o,Pt($e(g))))),onRight:g=>X(function*(){const _=yield*rt(),b=yield*rt();yield*$t(o,je(yn(_),Pe)),yield*jt(b,void 0).pipe(Tt(Tl(k=>$n(k(yn(a))).pipe(lU($n(k(t(g)))),we(Ce))).pipe(Sh(k=>Kf(a,k)),iy(_))),c(1),gs(r)),yield*yn(b)})})}),Nd,Jt,gs(r));const d=hi(h0(Va(Ol(o)),{onFailure:an,onSuccess:Zn({onLeft:Eo,onRight:g=>Ze(pt(g),()=>d)})}));return aT(d,s)}))),Ide=e=>t=>Tde(e)(t,fd),Tde=({bufferSize:e=16,concurrency:t,mergeStrategy:n=mde()})=>(r,s)=>pT(i=>X(function*(){const o=t==="unbounded"?Number.MAX_SAFE_INTEGER:t,a=yield*dT(),c=eb(a),f=yield*Yw(e);yield*Rl(i,In(f));const d=yield*dr();yield*Rl(i,In(d));const g=yield*Au(re()),_=yield*rt(),b=(yield*Ww(o)).withPermits,k=yield*Mc(rr(c,r),i);function I(y){return y.pipe(we(Zn({onLeft:m=>Pt(oe(m)),onRight:m=>yo($t(f,Pt(Pe(m))),re())})),XA({until:m=>Wt(m)}),we(m=>Ure(g,bt({onNone:()=>oe(m.value),onSome:v=>oe(s(v,m.value))}))),sa(m=>a0(m)?ps(m):$t(f,ps(m)).pipe(Tt(jt(_,void 0)),Sa)))}yield*k.pipe(si({onFailure:y=>$t(f,ps(y)).pipe(Tt(Pt(!1))),onSuccess:Zn({onLeft:y=>UI(Jt(yn(_)),Jt(b(o)(Le)),{onSelfDone:(m,v)=>yo(Fs(v),!1),onOtherDone:(m,v)=>Tt(Fs(v),Qf(g).pipe(we(bt({onNone:()=>$t(f,Pt($e(y))),onSome:w=>$t(f,Pt($e(s(w,y))))})),yo(!1)))}),onRight:y=>_de(n,{onBackPressure:()=>X(function*(){const m=yield*rt(),v=SC($=>Mc(rr(c,y),$).pipe(we(P=>z1($n(I(P)),$n(Jt(yn(_))))),we(Ce)));return yield*jt(m,void 0).pipe(Tt(v),b(1),gs(i)),yield*yn(m),!(yield*Kk(_))}),onBufferSliding:()=>X(function*(){const m=yield*rt(),v=yield*rt(),w=yield*Dfe(d);yield*Ol(d).pipe(we(O=>jt(O,void 0)),aU(()=>w>=o)),yield*$t(d,m);const $=SC(O=>Mc(rr(c,y),O).pipe(we(A=>$n(I(A)).pipe(z1($n(Jt(yn(_)))),z1($n(Jt(yn(m)))))),we(Ce)));return yield*jt(v,void 0).pipe(Tt($),b(1),gs(i)),yield*yn(v),!(yield*Kk(_))})})})}),XA({while:y=>y}),gs(i));const E=T(Ol(f),Va,h0({onFailure:an,onSuccess:Zn({onLeft:Eo,onRight:y=>Ze(pt(y),()=>E)})}),hi);return aT(E,a)})),i6=x(3,(e,t,n)=>Ide(n)(tb(e,t))),o6=x(2,(e,t)=>{function n(r){return X(function*(){const s=yield*dT(),i=eb(s),o=yield*Mc(rr(i,e),r),a=yield*Mc(rr(i,t.other),r);function c(d,g,_){return(b,k,I)=>{function E(y){const m=y;return m._tag===KU?Pt(en(Tt(Fs(g),m.effect))):je(Hj(g),Ti({onFailure:v=>en(m.f(jn(v))),onSuccess:Zn({onLeft:v=>en(m.f(_n(v))),onRight:v=>kh(pt(v),f(I(m.f)))})}))}return Ti(d,{onFailure:y=>E(b(jn(y))),onSuccess:Zn({onLeft:y=>E(b(_n(y))),onRight:y=>Pt(Ze(pt(y),()=>Ze(en(gs(Jt(_),r)),m=>f(k(m,g)))))})})}}function f(d){switch(d._tag){case QU:{const g=Jt($l(d.left)),_=Jt($l(d.right));return hi(UI(g,_,{onSelfDone:(b,k)=>Tt(Fs(k),c(b,d.right,o)(t.onSelfDone,W1,I=>oF(I))),onOtherDone:(b,k)=>Tt(Fs(k),c(b,d.left,a)(t.onOtherDone,(I,E)=>W1(E,I),I=>aF(I)))}))}case JU:return hi(je($n(a),Ti({onFailure:g=>en(d.f(jn(g))),onSuccess:Zn({onLeft:g=>en(d.f(_n(g))),onRight:g=>Ze(pt(g),()=>f(oF(d.f)))})})));case YU:return hi(je($n(o),Ti({onFailure:g=>en(d.f(jn(g))),onSuccess:Zn({onLeft:g=>en(d.f(_n(g))),onRight:g=>Ze(pt(g),()=>f(aF(d.f)))})})))}}return en(_a(d=>{const g=_a(k=>(k.transferChildren(d.scope()),Le)),_=Jt(o).pipe(Tf(g),gs(r)),b=Jt(a).pipe(Tf(g),gs(r));return qd(_,b,(k,I)=>W1(k,I))})).pipe(Ze(f),aT(s))})}return pT(n)}),Pde=x(2,(e,t)=>kde(e,n=>UU(()=>mu(t(n))))),a6=x(2,(e,t)=>bh(()=>{let n;const r=ly({onInput:i=>Ze(pt(i),()=>r),onFailure:i=>(n=Dde(i),an(mu(n))),onDone:Eo}),s=Vs({onInput:i=>T(pt(i),Ze(()=>s)),onFailure:i=>Wae(i)&&qde(i.defect)&&Ne(i.defect,n)?wh(i.defect.error):an(i),onDone:Eo});return rr(rr(rr(e,r),t),s)})),Ode=e=>SC(t=>uT(e,t)),Ade=e=>Ode(Zw(e)),l6=e=>fue(t=>uT(e,t)),c6=e=>hi(Tl(t=>je(ty(),n=>Zfe(Sh(t(ey(e,n)),r=>Ln(n,jn(r))),(r,s)=>Ln(n,s))))),u6=e=>nb(je(qI,t=>Ze(en(e(t)),pt))),Fde=e=>we(qI,t=>Mc(e,t)),Mc=x(2,(e,t)=>p0(Re(()=>new bc(e,void 0,Ce)),To()).pipe(kr(([n,r])=>xle(t,s=>{const i=n.close(s);return i!==void 0?Hn(i,r):Le})),Sc,je(([n])=>zt(()=>xC(n.run(),n))))),xC=(e,t)=>{const n=e;switch(n._tag){case cy:return Ti(t.getDone(),{onFailure:ps,onSuccess:r=>Pt($e(r))});case uy:return Pt(Pe(t.getEmit()));case Eh:return T(n.effect,we(()=>xC(t.run(),t)));case fy:return cT(n,()=>xC(t.run(),t),r=>ps(r))}},hi=e=>Cde(en(e)),nb=e=>jU(c6(e),(t,n)=>t,(t,n)=>t),pT=e=>jU(u6(e),(t,n)=>t,(t,n)=>t),rb=e=>f6(0,e.length,e),f6=(e,t,n)=>e===t?sr:T(pt(T(n,mo(e))),Ze(()=>f6(e+1,t,n))),Nde=x(e=>zU(e[1]),(e,t,n)=>n!=null&&n.concurrent?o6(e,{other:t,onSelfDone:r=>CC(s=>zt(()=>lA(r,s))),onOtherDone:r=>CC(s=>zt(()=>lA(s,r)))}):Ze(e,r=>hT(t,s=>[r,s]))),kh=x(e=>zU(e[1]),(e,t,n)=>n!=null&&n.concurrent?hT(Nde(e,t,{concurrent:!0}),r=>r[1]):Ze(e,()=>t)),RC=Symbol.for("effect/Channel/ChannelException"),Dde=e=>({_tag:"ChannelException",[RC]:RC,error:e}),qde=e=>_e(e,RC),$C=Symbol.for("effect/Sink"),Mde={_A:e=>e,_In:e=>e,_L:e=>e,_E:e=>e,_R:e=>e};var qke;class Ch{constructor(t){p(this,"channel");p(this,qke,Mde);this.channel=t}pipe(){return pe(this,arguments)}}qke=$C;const Lde=e=>new Ch(bh(()=>gT(e()))),zde=()=>new Ch(d6(Ut())),d6=e=>Vs({onInput:t=>d6(T(e,nn(t))),onFailure:an,onDone:()=>Nu(e)}),jde=new Ch(Zw(r6())),Ude=(e,t,n)=>Lde(()=>new Ch(h6(e,t,n))),h6=(e,t,n)=>t(e)?ly({onInput:r=>{const[s,i]=p6(e,r,t,n,0,r.length);return vo(i)?T(pt(i),Ede(s)):h6(s,t,n)},onFailure:wh,onDone:()=>Eo(e)}):Eo(e),p6=(e,t,n,r,s,i)=>{if(s===i)return[e,Ut()];const o=r(e,T(t,mo(s)));return n(o)?p6(o,t,n,r,s+1,i):[o,T(t,lo(s+1))]},Hde=e=>{const t=Vs({onInput:n=>T(en(e(n)),Ze(()=>t)),onFailure:an,onDone:()=>sr});return new Ch(t)},Bde=e=>new Ch(en(e)),Vde=()=>Ude(re(),on,(e,t)=>bt(e,{onNone:()=>oe(t),onSome:()=>e})),gT=e=>$a(e)?gT(Bde(e)):e.channel,Wde=hde,Kde=CC,sb=sy,Gde=$ce,Qde=Lle,Jde=Ble,Yde="Left",Xde="Right",Zde="Both",ehe="Either",the={_tag:Yde},nhe={_tag:Xde},g6={_tag:Zde},rhe={_tag:ehe},she=e=>{switch(e){case"left":return the;case"right":return nhe;case"both":return g6;case"either":return rhe;default:return e}},ihe=g6;class m6{constructor(t){p(this,"value");this.value=t}}const y6=(e,t)=>({ref:e,isNew:t,isChanged:!1,expected:e.versioned,newValue:e.versioned.value}),_6=e=>e.newValue,S6=(e,t)=>{e.isChanged=!0,e.newValue=t},ohe=e=>{e.ref.versioned=new m6(e.newValue)},ahe=e=>e.ref.versioned!==e.expected,lhe=e=>e.isChanged,S0="Invalid",mT="ReadWrite",che="ReadOnly",v6=e=>{for(const t of e)ohe(t[1])},w6=e=>{let t=che;for(const[,n]of e)if(t=ahe(n)?S0:lhe(n)?mT:t,t===S0)return t;return t},uhe=e=>{const t=new Map;for(const[,n]of e){for(const r of n.ref.todos)t.set(r[0],r[1]);n.ref.todos=new Map}return t},fhe=e=>{const t=Array.from(e.entries()).sort((n,r)=>n[0]-r[0]);for(const[n,r]of t)r()},dhe=(e,t,n)=>{let r=!1;for(const[,s]of t)s.ref.todos.has(e)||(s.ref.todos.set(e,n),r=!0);return r},b6="WithSTMRuntime",IC="OnFailure",cF="OnRetry",TC="OnSuccess",hhe="Provide",E6="Sync",k6="Succeed",C6="Retry",x6="Fail",R6="Die",$6="Interrupt",Xf="Fail",Zf="Die",ed="Interrupt",Lc="Succeed",xh="Retry",yT="Done",_T="Suspend",V_="Done",PC="Interrupted",v0="Running",ib="effect/STM/State",yu=Symbol.for(ib),ST=e=>_e(e,yu),I6=e=>e._tag===v0,phe=e=>e._tag===V_,r_=e=>({[yu]:yu,_tag:V_,exit:e,[qe](){return T(ce(ib),Oe(ce(V_)),Oe(ce(e)),At(this))},[Me](t){return ST(t)&&t._tag===V_&&Ne(e,t.exit)}}),ghe=T(ce(ib),Oe(ce(PC)),Oe(ce("interrupted"))),mhe={[yu]:yu,_tag:PC,[qe](){return ghe},[Me](e){return ST(e)&&e._tag===PC}},yhe=T(ce(ib),Oe(ce(v0)),Oe(ce("running"))),_he={[yu]:yu,_tag:v0,[qe](){return yhe},[Me](e){return ST(e)&&e._tag===v0}},s_=e=>{switch(e._tag){case Xf:return r_(Vm(e.error));case Zf:return r_(KS(e.defect));case ed:return r_(ine(e.fiberId));case Lc:return r_(_n(e.value));case xh:throw new Error("BUG: STM.STMState.fromTExit - please report an issue at https://github.com/Effect-TS/effect/issues")}},Rh="effect/TExit",$h=Symbol.for(Rh),dy={_A:e=>e,_E:e=>e},hy=e=>_e(e,$h),She=e=>e._tag===Lc,vhe=e=>e._tag===xh,whe=e=>({[$h]:dy,_tag:Xf,error:e,[qe](){return T(ce(Rh),Oe(ce(Xf)),Oe(ce(e)),At(this))},[Me](t){return hy(t)&&t._tag===Xf&&Ne(e,t.error)}}),bhe=e=>({[$h]:dy,_tag:Zf,defect:e,[qe](){return T(ce(Rh),Oe(ce(Zf)),Oe(ce(e)),At(this))},[Me](t){return hy(t)&&t._tag===Zf&&Ne(e,t.defect)}}),Ehe=e=>({[$h]:dy,_tag:ed,fiberId:e,[qe](){return T(ce(Rh),Oe(ce(ed)),Oe(ce(e)),At(this))},[Me](t){return hy(t)&&t._tag===ed&&Ne(e,t.fiberId)}}),uF=e=>({[$h]:dy,_tag:Lc,value:e,[qe](){return T(ce(Rh),Oe(ce(Lc)),Oe(ce(e)),At(this))},[Me](t){return hy(t)&&t._tag===Lc&&Ne(e,t.value)}}),khe=T(ce(Rh),Oe(ce(xh)),Oe(ce("retry"))),Che={[$h]:dy,_tag:xh,[qe](){return khe},[Me](e){return hy(e)&&vhe(e)}},xhe=e=>({_tag:yT,exit:e}),T6=e=>({_tag:_T,journal:e}),fF={ref:0},Rhe=()=>{const e=fF.ref+1;return fF.ref=e,e},$he="effect/STM",Ihe=Symbol.for($he),i_={_R:e=>e,_E:e=>e,_A:e=>e};var Mke,Lke,zke,jke;class Ia{constructor(t){p(this,"effect_instruction_i0");p(this,"_op",bm);p(this,"effect_instruction_i1");p(this,"effect_instruction_i2");p(this,Mke);p(this,Lke);p(this,zke);p(this,jke);this.effect_instruction_i0=t,this[YA]=Jc,this[Sk]=i_,this[$C]=i_,this[m0]=i_}get[(Mke=YA,Lke=Sk,zke=$C,jke=m0,Ihe)](){return i_}[Me](t){return this===t}[qe](){return At(this,Pv(this))}[Symbol.iterator](){return new ih(new Jd(this))}commit(){return The(this,fd,fd)}pipe(){return pe(this,arguments)}}const The=(e,t,n)=>et(r=>{const s=r.id(),i=r.getFiberRef(WI),o=r.getFiberRef(cU),a=r.getFiberRef(xue),c=Ohe(s,e,i,o,a);switch(c._tag){case yT:return t(c.exit),c.exit;case _T:{const f=Rhe(),d={value:_he},g=nue(_=>P6(s,e,f,d,i,o,a,_));return Tl(_=>T(_(g),sa(b=>{let k=d.value;return I6(k)&&(d.value=mhe),k=d.value,phe(k)?(t(k.exit),k.exit):(n(),ps(b))})))}}}),Phe=(e,t,n,r,s,i)=>{const o=new Map,a=new O6(t,o,e,r).run(),c=w6(o);if(c===mT)v6(o);else if(c===S0)throw new Error("BUG: STM.TryCommit.tryCommit - please report an issue at https://github.com/Effect-TS/effect/issues");switch(a._tag){case Lc:return n.value=s_(a),Za(_n(a.value),o,s,i);case Xf:{n.value=s_(a);const f=gu(a.error);return Za(jn(f),o,s,i)}case Zf:{n.value=s_(a);const f=mu(a.defect);return Za(jn(f),o,s,i)}case ed:{n.value=s_(a);const f=qw(e);return Za(jn(f),o,s,i)}case xh:return T6(o)}},Ohe=(e,t,n,r,s)=>{const i=new Map,o=new O6(t,i,e,n).run(),a=w6(i);if(a===mT&&She(o))v6(i);else if(a===S0)throw new Error("BUG: STM.TryCommit.tryCommitSync - please report an issue at https://github.com/Effect-TS/effect/issues");switch(o._tag){case Lc:return Za(_n(o.value),i,r,s);case Xf:{const c=gu(o.error);return Za(jn(c),i,r,s)}case Zf:{const c=mu(o.defect);return Za(jn(c),i,r,s)}case ed:{const c=qw(e);return Za(jn(c),i,r,s)}case xh:return T6(i)}},P6=(e,t,n,r,s,i,o,a)=>{if(I6(r.value)){const c=Phe(e,t,r,s,i,o);switch(c._tag){case yT:{Ahe(c.exit,a);break}case _T:{dhe(n,c.journal,()=>P6(e,t,n,r,s,i,o,a));break}}}},Za=(e,t,n,r)=>{const s=uhe(t);return s.size>0&&n.scheduleTask(()=>fhe(s),r),xhe(e)},Ahe=(e,t)=>{t(e)};class O6{constructor(t,n,r,s){p(this,"self");p(this,"journal");p(this,"fiberId");p(this,"contStack",[]);p(this,"env");this.self=t,this.journal=n,this.fiberId=r,this.env=s}getEnv(){return this.env}pushStack(t){this.contStack.push(t)}popStack(){return this.contStack.pop()}nextSuccess(){let t=this.popStack();for(;t!==void 0&&t.effect_instruction_i0!==TC;)t=this.popStack();return t}nextFailure(){let t=this.popStack();for(;t!==void 0&&t.effect_instruction_i0!==IC;)t=this.popStack();return t}nextRetry(){let t=this.popStack();for(;t!==void 0&&t.effect_instruction_i0!==cF;)t=this.popStack();return t}run(){let t=this.self,n;for(;n===void 0&&t!==void 0;)try{const r=t;if(r)switch(r._op){case"Tag":{t=ob((s,i,o)=>Bv(o,r));break}case"Left":{t=OC(r.left);break}case"None":{t=OC(new Lw);break}case"Right":{t=qn(r.right);break}case"Some":{t=qn(r.value);break}case"Commit":{switch(r.effect_instruction_i0){case R6:{n=bhe(Bt(()=>r.effect_instruction_i1()));break}case x6:{const s=this.nextFailure();s===void 0?n=whe(Bt(()=>r.effect_instruction_i1())):t=Bt(()=>s.effect_instruction_i2(Bt(()=>r.effect_instruction_i1())));break}case C6:{const s=this.nextRetry();s===void 0?n=Che:t=Bt(()=>s.effect_instruction_i2());break}case $6:{n=Ehe(this.fiberId);break}case b6:{t=Bt(()=>r.effect_instruction_i1(this));break}case TC:case IC:case cF:{this.pushStack(r),t=r.effect_instruction_i1;break}case hhe:{const s=this.env;this.env=Bt(()=>r.effect_instruction_i2(s)),t=T(r.effect_instruction_i1,qhe(vT(()=>this.env=s)));break}case k6:{const s=r.effect_instruction_i1,i=this.nextSuccess();i===void 0?n=uF(s):t=Bt(()=>i.effect_instruction_i2(s));break}case E6:{const s=Bt(()=>r.effect_instruction_i1()),i=this.nextSuccess();i===void 0?n=uF(s):t=Bt(()=>i.effect_instruction_i2(s));break}}break}}}catch(r){t=Nhe(r)}return n}}const Fhe=x(2,(e,t)=>{const n=new Ia(IC);return n.effect_instruction_i1=e,n.effect_instruction_i2=t,n}),Nhe=e=>Dhe(()=>e),Dhe=e=>{const t=new Ia(R6);return t.effect_instruction_i1=e,t},ob=e=>Yi(t=>qn(e(t.journal,t.fiberId,t.getEnv()))),qhe=x(2,(e,t)=>Lhe(e,{onFailure:n=>dF(t,OC(n)),onSuccess:n=>dF(t,qn(n))})),OC=e=>Mhe(()=>e),Mhe=e=>{const t=new Ia(x6);return t.effect_instruction_i1=e,t},Ih=x(2,(e,t)=>{const n=new Ia(TC);return n.effect_instruction_i1=e,n.effect_instruction_i2=t,n}),Lhe=x(2,(e,{onFailure:t,onSuccess:n})=>T(e,Mg(Pe),Fhe(r=>T(t(r),Mg($e))),Ih(r=>{switch(r._tag){case"Left":return qn(r.left);case"Right":return n(r.right)}}))),Yi=e=>{const t=new Ia(b6);return t.effect_instruction_i1=e,t},Da=e=>{const t=new Ia($6);return t.effect_instruction_i1=e,t},Mg=x(2,(e,t)=>T(e,Ih(n=>vT(()=>t(n))))),cf=new Ia(C6),qn=e=>{const t=new Ia(k6);return t.effect_instruction_i1=e,t},vT=e=>{const t=new Ia(E6);return t.effect_instruction_i1=e,t},dF=x(2,(e,t)=>T(e,Ih(()=>t))),hF="BackPressure",AC="Dropping",pF="Sliding",zhe=e=>Ih(e,Ce),jhe=(...e)=>Uhe(()=>{const n=(e.length===1?e[0]:e[1].bind(e[0]))(T),r=n.next(),s=i=>i.done?qn(i.value):Ih(Hq(i.value),o=>s(n.next(o)));return s(r)}),Uhe=e=>zhe(vT(e)),gF=qn(void 0),Hhe="effect/TRef",Bhe=Symbol.for(Hhe),Vhe={_A:e=>e};var Uke;class Whe{constructor(t){p(this,Uke,Vhe);p(this,"todos");p(this,"versioned");this.versioned=new m6(t),this.todos=new Map}modify(t){return ob(n=>{const r=wT(this,n),[s,i]=t(_6(r));return S6(r,i),s})}pipe(){return pe(this,arguments)}}Uke=Bhe;const A6=e=>ob(t=>{const n=new Whe(e);return t.set(n,y6(n,!0)),n}),Khe=e=>e.modify(t=>[t,t]),Ghe=x(2,(e,t)=>e.modify(()=>[void 0,t])),Qhe=x(2,(e,t)=>e.modify(n=>[void 0,t(n)])),wT=(e,t)=>{if(t.has(e))return t.get(e);const n=y6(e,!1);return t.set(e,n),n},Do=x(2,(e,t)=>_6(wT(e,t))),qo=x(3,(e,t,n)=>{const r=wT(e,n);S6(r,t)}),Jhe="effect/TQueue/TEnqueue",Yhe=Symbol.for(Jhe),Xhe="effect/TQueue/TDequeue",Zhe=Symbol.for(Xhe),epe={_tag:AC},tpe={_Out:e=>e},npe={_In:e=>e};var Hke,Bke;class rpe{constructor(t,n,r){p(this,"ref");p(this,"requestedCapacity");p(this,"strategy");p(this,Hke,tpe);p(this,Bke,npe);p(this,"size",Yi(t=>{const n=Do(this.ref,t.journal);return n===void 0?Da(t.fiberId):qn(n.length)}));p(this,"isFull",Mg(this.size,t=>t===this.requestedCapacity));p(this,"isEmpty",Mg(this.size,t=>t===0));p(this,"shutdown",Yi(t=>(qo(this.ref,void 0,t.journal),gF)));p(this,"isShutdown",ob(t=>Do(this.ref,t)===void 0));p(this,"awaitShutdown",Ih(this.isShutdown,t=>t?gF:cf));p(this,"peek",Yi(t=>{const n=Do(this.ref,t.journal);return n===void 0?Da(t.fiberId):n.length===0?cf:qn(n[0])}));p(this,"peekOption",Yi(t=>{const n=Do(this.ref,t.journal);return n===void 0?Da(t.fiberId):qn(bu(n[0]))}));p(this,"take",Yi(t=>{const n=Do(this.ref,t.journal);if(n===void 0)return Da(t.fiberId);if(n.length===0)return cf;const r=n.shift();return qo(this.ref,n,t.journal),qn(r)}));p(this,"takeAll",Yi(t=>{const n=Do(this.ref,t.journal);return n===void 0?Da(t.fiberId):(qo(this.ref,[],t.journal),qn(n))}));this.ref=t,this.requestedCapacity=n,this.strategy=r}capacity(){return this.requestedCapacity}offer(t){return Yi(n=>{const r=T(this.ref,Do(n.journal));if(r===void 0)return Da(n.fiberId);if(r.length<this.requestedCapacity)return r.push(t),qo(this.ref,r,n.journal),qn(!0);switch(this.strategy._tag){case hF:return cf;case AC:return qn(!1);case pF:return r.length===0||(r.shift(),r.push(t),qo(this.ref,r,n.journal)),qn(!0)}})}offerAll(t){return Yi(n=>{const r=Array.from(t),s=Do(this.ref,n.journal);if(s===void 0)return Da(n.fiberId);if(s.length+r.length<=this.requestedCapacity)return qo(this.ref,[...s,...r],n.journal),qn(!0);switch(this.strategy._tag){case hF:return cf;case AC:{const i=r.slice(0,this.requestedCapacity-s.length);return qo(this.ref,[...s,...i],n.journal),qn(!1)}case pF:{const i=r.slice(0,this.requestedCapacity-s.length),o=s.length+i.length-this.requestedCapacity,a=s.slice(o);return qo(this.ref,[...a,...i],n.journal),qn(!0)}}})}takeUpTo(t){return Yi(n=>{const r=Do(this.ref,n.journal);if(r===void 0)return Da(n.fiberId);const[s,i]=gL(xn(r),t);return qo(this.ref,Array.from(i),n.journal),qn(Array.from(s))})}}Hke=Zhe,Bke=Yhe;const spe=x(2,(e,t)=>e.offer(t)),ipe=e=>e.peek,ope=e=>e.take,ape=()=>lpe(Number.MAX_SAFE_INTEGER,epe),lpe=(e,t)=>Mg(A6([]),n=>new rpe(n,e,t)),cpe=spe,upe=ipe,fpe=ope,dpe=ape,hpe=(e,t)=>{let n=!1,r=[],s=!1;function i(c){if(n)return!1;if(c.length<=5e4)r.push.apply(r,c);else for(let f=0;f<c.length;f++)r.push(c[0]);return s||(s=!0,t.scheduleTask(o,0)),!0}function o(){s=!1,r.length>0&&(e.unsafeOffer(r),r=[])}function a(c){n||(n=!0,c._tag==="Success"&&r.push(c.value),o(),e.unsafeOffer(c._tag==="Success"?_s:c))}return{single(c){return n?!1:(r.push(c),s||(s=!0,t.scheduleTask(o,0)),!0)},array:i,chunk(c){return i(di(c))},done:a,end(){n||(n=!0,o(),e.unsafeOffer(_s))},halt(c){return a(jn(c))},fail(c){return a(Vm(c))},die(c){return a(KS(c))},dieMessage(c){return a(KS(new Error(c)))}}},ppe="effect/Take",gpe=Symbol.for(ppe),mpe={_A:e=>e,_E:e=>e};var Vke;class ab{constructor(t){p(this,"exit");p(this,Vke,mpe);this.exit=t}pipe(){return pe(this,arguments)}}Vke=gpe;const w0=e=>new ab(_n(e)),b0=new ab(Vm(re())),bT=e=>new ab(jn(T(e,kI(oe)))),F6=x(2,(e,{onEnd:t,onFailure:n,onSuccess:r})=>Ti(e.exit,{onFailure:s=>bt(vj(s),{onNone:t,onSome:n}),onSuccess:r})),ype=e=>new ab(_n(Xt(e))),_pe=()=>zs(re()),Spe=e=>Gl(ps(e),oe),vpe="effect/Stream",N6=Symbol.for(vpe),wpe={_R:e=>e,_E:e=>e,_A:e=>e};var Wke;class It{constructor(t){p(this,"channel");p(this,Wke,wpe);this.channel=t}pipe(){return pe(this,arguments)}}Wke=N6;const py=e=>_e(e,N6)||$a(e),ET=4096,bpe=e=>{if((e==null?void 0:e.bufferSize)==="unbounded"||(e==null?void 0:e.bufferSize)===void 0&&(e==null?void 0:e.strategy)===void 0)return dr();switch(e==null?void 0:e.strategy){case"sliding":return tT(e.bufferSize??16);default:return eT((e==null?void 0:e.bufferSize)??16)}},D6=(e,t)=>Rt(bpe(t),In).pipe(kr(n=>Cue(cU,r=>e(hpe(n,r)))),je(n=>{const r=Ze(Ol(n),s=>tne(s)?xd(s)?sr:an(s.cause):kh(pt(xn(s)),r));return r}),nb,j6),Epe=x(2,(e,t)=>{if(t.strategy==="dropping")return kpe(e,t.capacity);if(t.strategy==="sliding")return Cpe(e,t.capacity);const n=rge(e,t);return new It(nb(je(n,r=>{const s=T(en(Ol(r)),Ze(F6({onEnd:()=>sr,onFailure:an,onSuccess:i=>T(pt(i),Ze(()=>s))})));return s})))}),kpe=x(2,(e,t)=>{const n=Rt(eT(t),r=>In(r));return new It(q6(n,wt(e)))}),Cpe=x(2,(e,t)=>{const n=Rt(tT(t),r=>In(r));return new It(q6(n,wt(e)))}),q6=(e,t)=>{const n=(s,i)=>{const o=a=>T(Qf(i),kr(yn),Tt(rt()),we(c=>T($t(s,[a,c]),Tt(Tg(i,c)),Tt(yn(c)))),Sa,en);return Vs({onInput:a=>T(rt(),we(c=>T($t(s,[w0(a),c]),we(f=>T(Tg(i,c),aU(()=>f))))),Sa,en,Ze(()=>n(s,i))),onFailure:a=>o(bT(a)),onDone:()=>o(b0)})},r=s=>{const i=T(en(Ol(s)),Ze(([o,a])=>kh(en(jt(a,void 0)),F6(o,{onEnd:()=>sr,onFailure:an,onSuccess:c=>T(pt(c),Ze(()=>i))}))));return i};return nb(T(e,we(s=>T(rt(),kr(i=>jt(i,void 0)),we(i=>T(Au(i),we(o=>T(t,rr(n(s,o)),l6,Dt)),yo(r(s))))))))},xpe=x(2,(e,t)=>Rpe(e,n=>Zn(Mw(n),{onLeft:t,onRight:Ppe}))),Rpe=x(2,(e,t)=>new It(T(wt(e),oT(n=>wt(t(n)))))),M6=x(2,(e,t)=>new It(T(wt(e),kh(wt(t))))),$pe=e=>Du(Ad(e)),FC=x(2,(e,t)=>new It(T(wt(e),n6(t)))),Ipe=x(2,(e,t)=>new It(lT(wt(e),t))),Tpe=e=>kT(zs(oe(e))),Ppe=e=>Du(ps(e)),Ope=x(2,(e,t)=>B6(e,Wv(t))),Ape=x(2,(e,t)=>{const n=r=>{const s=r.next();return s.done?Vs({onInput:i=>n(i[Symbol.iterator]()),onFailure:an,onDone:Nu}):T(t(s.value),je(i=>i?T(pt(Xt(s.value)),Ze(()=>n(r))):n(r)),hi)};return new It(bh(()=>T(wt(e),rr(n(Ut()[Symbol.iterator]())))))}),Fpe=x(2,(e,t)=>B6(e,pL(t))),zc=x(e=>py(e[0]),(e,t,n)=>{const r=(n==null?void 0:n.bufferSize)??16;return n!=null&&n.switch?NC(n==null?void 0:n.concurrency,()=>mF(e,1,r,t),s=>mF(e,s,r,t)):NC(n==null?void 0:n.concurrency,()=>new It(_0(wt(e),s=>T(s,Rf(i=>wt(t(i))),BY(sr,(i,o)=>T(i,kh(o)))))),s=>new It(T(wt(e),_0(rb),i6(i=>wt(t(i)),n))))}),NC=(e,t,n)=>{switch(e){case void 0:return t();case"unbounded":return n(Number.MAX_SAFE_INTEGER);default:return e>1?n(e):t()}},mF=x(4,(e,t,n,r)=>new It(T(wt(e),_0(rb),i6(s=>wt(r(s)),{concurrency:t,mergeStrategy:yde(),bufferSize:n})))),lb=x(e=>py(e[0]),(e,t)=>zc(e,Ce,t)),L6=e=>{const t=Vs({onInput:n=>Ze(rb(n),()=>t),onFailure:an,onDone:()=>sr});return new It(T(wt(e),rr(t)))},Npe=e=>{const t=(r,s)=>{const[i,o]=T(r,UY(c=>!xd(c))),a=T(Kv(o),bt({onNone:()=>s,onSome:Ti({onFailure:c=>bt(vj(c),{onNone:()=>sr,onSome:an}),onSuccess:()=>sr})}));return T(pt(T(i,pL(c=>xd(c)?oe(c.value):re()))),Ze(()=>a))},n=Vs({onInput:r=>t(r,n),onFailure:r=>an(r),onDone:()=>sr});return new It(T(wt(e),rr(n)))},Dpe=e=>T(e,zg(da),L6),z6=e=>L6(Npe(T(e,zg(t=>t.exit)))),j6=e=>new It(e),wt=e=>{if("channel"in e)return e.channel;if($a(e))return wt(Du(e));throw new TypeError("Expected a Stream.")},DC=e=>new It(Tm(e)?sr:pt(e)),Du=e=>T(e,Gl(oe),kT),kT=e=>new It(hi(yue(e,{onFailure:bt({onNone:()=>sr,onSome:wh}),onSuccess:t=>pt(Xt(t))}))),U6=(e,t)=>{const n=(t==null?void 0:t.maxChunkSize)??ET;if(t!=null&&t.scoped){const s=je(tF(e),i=>Lg(i,{maxChunkSize:n,shutdown:!0}));return t.shutdown?je(s,FC(bC(e))):s}const r=zc(V6(tF(e)),s=>Lg(s,{maxChunkSize:n}));return t!=null&&t.shutdown?FC(r,bC(e)):r},qpe=e=>xT(()=>Fc(e)?DC(e):Mpe(e[Symbol.iterator]())),Mpe=(e,t=ET)=>T(Re(()=>{let n=[];const r=s=>T(Re(()=>{let i=s.next();if(t===1)return i.done?sr:T(pt(Xt(i.value)),Ze(()=>r(s)));n=[];let o=0;for(;i.done===!1&&(n.push(i.value),o=o+1,!(o>=t));)i=s.next();return o>0?T(pt(xn(n)),Ze(()=>r(s))):sr}),hi);return new It(r(e))}),lge),Lpe=e=>T(e,je(CT),ub),Lg=(e,t)=>T(bU(e,1,(t==null?void 0:t.maxChunkSize)??ET),sa(n=>T(qfe(e),we(r=>r&&a0(n)?_pe():Spe(n)))),CT,t!=null&&t.shutdown?FC(In(e)):Ce),zpe=(...e)=>{const t=e.length===1?e[0].evaluate:e[0],n=e.length===1?e[0].onError:e[1],r=e.length===1?e[0].releaseLockOnEnd===!0:!1;return ub(je(Rt(Re(()=>t().getReader()),s=>r?Re(()=>s.releaseLock()):Fd(()=>s.cancel())),s=>qC(we(Fp({try:()=>s.read(),catch:i=>oe(n(i))}),({done:i,value:o})=>i?zs(re()):Pt(o)))))},H6=(...e)=>qpe(e),zg=x(2,(e,t)=>new It(T(wt(e),tb(Rf(t))))),B6=x(2,(e,t)=>new It(T(wt(e),tb(t)))),jpe=x(2,(e,t)=>new It(T(wt(e),s6(t)))),E0=x(2,(e,t)=>{const n=r=>{const s=r.next();if(s.done)return Vs({onInput:i=>n(i[Symbol.iterator]()),onFailure:an,onDone:Nu});{const i=s.value;return hi(je(t(i),o=>Ze(pt(Xt(o)),()=>n(r))))}};return new It(T(wt(e),rr(bh(()=>n(Ut()[Symbol.iterator]())))))}),Upe=x(3,(e,t,n)=>new It(T(wt(e),_0(rb),$de(n,t),tb(Xt)))),Hpe=x(2,(e,t)=>new It(T(wt(e),xde(t)))),Bpe=x(2,(e,t)=>Vpe(e,t,{onSelf:$e,onOther:Pe})),Vpe=x(3,(e,t,n)=>{const r=n.haltStrategy?she(n.haltStrategy):ihe,s=i=>o=>i||!xd(o)?Wde(zt(()=>o)):Kde(a=>zt(()=>a));return new It(o6(wt(zg(e,n.onSelf)),{other:wt(zg(t,n.onOther)),onSelfDone:s(r._tag==="Either"||r._tag==="Left"),onOtherDone:s(r._tag==="Either"||r._tag==="Right")}))}),Wpe=Du(FI),Kpe=e=>T(e,Gpe(Ce)),Gpe=x(2,(e,t)=>new It(T(wt(e),Pde(t)))),CT=e=>age(e,t=>T(je(t,n=>oe([n,t])),Uw(bt({onNone:()=>Pt(re()),onSome:zs})))),qC=e=>CT(T(e,je(Xt))),cb=x(2,(e,t)=>wt(e).pipe(a6(gT(t)),Ade)),Qpe=e=>cb(e,zde()),Jpe=e=>cb(e,jde),Ype=x(2,(e,t)=>cb(e,Hde(t))),Xpe=e=>cb(e,Vde()),Zpe=x(2,(e,t)=>{const n=Vs({onInput:r=>Ze(pt(w0(r)),()=>n),onFailure:r=>pt(bT(r)),onDone:()=>pt(b0)});return T(rr(wt(e),n),s6(r=>$t(t,r)),Zw,l6,Sa)}),V6=e=>new It(n6(c6(T(e,je(Xt))),Le)),ege=e=>new It(u6(t=>e(t).pipe(je(Xt)))),xT=e=>new It(bh(()=>wt(e()))),tge=x(2,(e,t)=>{if(!Number.isInteger(t))return $pe(new Qae(`${t} must be an integer`));const n=r=>ly({onInput:s=>{const i=T(s,pd(Math.min(r,Number.POSITIVE_INFINITY))),o=Math.max(0,r-i.length);return o>0?T(pt(i),Ze(()=>n(o))):pt(i)},onFailure:wh,onDone:Nu});return new It(T(wt(e),a6(0<t?n(t):sr)))}),nge=x(2,(e,t)=>E0(e,n=>yo(t(n),n))),G1=e=>je(Fde(wt(e)),t=>T(t,Gl(oe),we(Zn({onLeft:()=>zs(re()),onRight:Pt})))),rge=x(e=>py(e[0]),(e,t)=>kr(Rt((t==null?void 0:t.strategy)==="unbounded"?dr():(t==null?void 0:t.strategy)==="dropping"?eT(t.capacity??2):(t==null?void 0:t.strategy)==="sliding"?tT(t.capacity??2):Yw((t==null?void 0:t.capacity)??2),n=>In(n)),n=>Dt(Zpe(e,n)))),sge=x(e=>py(e[0]),(e,t)=>je(To(),n=>ige(e,n,t))),ige=x(e=>py(e[0]),(e,t,n)=>{const r=sb(t);let s,i;const o=vue(!1);return new ReadableStream({start(a){i=r(Ype(e,c=>o.whenOpen(Re(()=>{o.unsafeClose();for(const f of c)a.enqueue(f);s(),s=void 0})))),i.addObserver(c=>{c._tag==="Failure"?a.error(Gae(c.cause)):a.close()})},pull(){return new Promise(a=>{s=a,ur(o.open)})},cancel(){if(i)return Kw(Sa(Fs(i)))}},n==null?void 0:n.strategy)}),oge=(e,t)=>{const n=r=>bt(t(r),{onNone:()=>sr,onSome:([s,i])=>Ze(pt(s),()=>n(i))});return new It(bh(()=>n(e)))},age=(e,t)=>xT(()=>{const n=r=>hi(je(t(r),bt({onNone:()=>sr,onSome:([s,i])=>Ze(pt(s),()=>n(i))})));return new It(n(e))}),lge=e=>lb(Du(e)),ub=e=>lb(V6(e)),cge=e=>lb(ege(t=>e(t))),uge=x(2,(e,t)=>T(e,fge(t,(n,r)=>[n,r]))),fge=x(3,(e,t,n)=>{const r=s=>T(s,we(i=>Tm(i)?r(s):Pt(i)));return T(G1(e),je(r),p0(T(G1(t),je(r))),we(([s,i])=>T(kT(UI(s,i,{onSelfDone:(o,a)=>T(zt(()=>o),qd($l(a),(c,f)=>[c,f,!0])),onOtherDone:(o,a)=>T(zt(()=>o),qd($l(a),(c,f)=>[f,c,!1]))})),zc(([o,a,c])=>T(Du(Au([Xu(o),Xu(a)])),zc(f=>T(DC(c?T(a,Rf(d=>n(Xu(o),d))):T(o,Rf(d=>n(d,Xu(a))))),M6(T(qC(s),Bpe(qC(i)),E0(Zn({onLeft:d=>T(uc(f,([g,_])=>[T(d,Rf(b=>n(b,_))),[Xu(d),_]])),onRight:d=>T(uc(f,([g,_])=>[T(d,Rf(b=>n(g,b))),[g,Xu(d)]]))})),zc(DC))))))),G1)),Lpe)}),dge=(e,t,n)=>D6(r=>Rt(Re(()=>e.addEventListener(t,r.single,n)),()=>Re(()=>e.removeEventListener(t,r.single,n))),{bufferSize:typeof n=="object"?n.bufferSize:void 0}),hge=bde,W6="effect/Redacted",W_=We("effect/Redacted/redactedRegistry",()=>new WeakMap),K6=Symbol.for(W6),pge={[K6]:{_A:e=>e},pipe(){return pe(this,arguments)},toString(){return"<redacted>"},toJSON(){return"<redacted>"},[ft](){return"<redacted>"},[qe](){return T(ce(W6),Oe(ce(W_.get(this))),At(this))},[Me](e){return gge(e)&&Ne(W_.get(this),W_.get(e))}},gge=e=>_e(e,K6),mge=e=>{const t=Object.create(pge);return W_.set(t,e),t},yge="effect/Config",_ge=Symbol.for(yge),Sge={_A:e=>e};({...ka,[_ge]:0});const yF=Symbol.for("effect/Encoding/errors/Decode"),Q1=(e,t)=>{const n={_tag:"DecodeException",[yF]:yF,input:e};return Jr(t)&&(n.message=t),n},vge=new TextEncoder,_F=e=>{const t=e.length;let n="",r;for(r=2;r<t;r+=3)n+=Mo[e[r-2]>>2],n+=Mo[(e[r-2]&3)<<4|e[r-1]>>4],n+=Mo[(e[r-1]&15)<<2|e[r]>>6],n+=Mo[e[r]&63];return r===t+1&&(n+=Mo[e[r-2]>>2],n+=Mo[(e[r-2]&3)<<4],n+="=="),r===t&&(n+=Mo[e[r-2]>>2],n+=Mo[(e[r-2]&3)<<4|e[r-1]>>4],n+=Mo[(e[r-1]&15)<<2],n+="="),n},wge=e=>{const t=bge(e),n=t.length;if(n%4!==0)return $e(Q1(t,`Length must be a multiple of 4, but is ${n}`));const r=t.indexOf("=");if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!=="="))return $e(Q1(t,"Found a '=' character, but it is not at the end"));try{const s=t.endsWith("==")?2:t.endsWith("=")?1:0,i=new Uint8Array(3*(n/4)-s);for(let o=0,a=0;o<n;o+=4,a+=3){const c=o_(t.charCodeAt(o))<<18|o_(t.charCodeAt(o+1))<<12|o_(t.charCodeAt(o+2))<<6|o_(t.charCodeAt(o+3));i[a]=c>>16,i[a+1]=c>>8&255,i[a+2]=c&255}return Pe(i)}catch(s){return $e(Q1(t,s instanceof Error?s.message:"Invalid input"))}},bge=e=>e.replace(/[\n\r]/g,"");function o_(e){if(e>=SF.length)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);const t=SF[e];if(t===255)throw new TypeError(`Invalid character ${String.fromCharCode(e)}`);return t}const Mo=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"],SF=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Ege=e=>_F(typeof e=="string"?vge.encode(e):e),kge=e=>wge(e),MC=Symbol.for("effect/FiberHandle"),Cge=e=>_e(e,MC),xge={[MC]:MC,toString(){return qt(this.toJSON())},toJSON(){return{_id:"FiberHandle",state:this.state}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},Rge=e=>{const t=Object.create(xge);return t.state={_tag:"Open",fiber:void 0},t.deferred=e,t},RT=()=>Rt(je(rt(),e=>Rge(e)),e=>_a(t=>{const n=e.state;return n._tag==="Closed"?Le:(e.state={_tag:"Closed"},n.fiber?iy(Sa(ry(n.fiber,As(t.id(),Np))),e.deferred):Wl(e.deferred,_s))})),G6=-1,Np=m$(G6,0),$ge=CI(void 0,{emptyCase:ds,failCase:ds,dieCase:ds,interruptCase:(e,t)=>rw(ow(t),G6),sequentialCase:(e,t,n)=>t||n,parallelCase:(e,t,n)=>t||n}),Ige=x(e=>Cge(e[0]),(e,t,n)=>{if(e.state._tag==="Closed"){t.unsafeInterruptAsFork(As((n==null?void 0:n.interruptAs)??Nr,Np));return}else if(e.state.fiber!==void 0){if((n==null?void 0:n.onlyIfMissing)===!0){t.unsafeInterruptAsFork(As((n==null?void 0:n.interruptAs)??Nr,Np));return}else if(e.state.fiber===t)return;e.state.fiber.unsafeInterruptAsFork(As((n==null?void 0:n.interruptAs)??Nr,Np)),e.state.fiber=void 0}e.state.fiber=t,t.addObserver(r=>{e.state._tag==="Open"&&t===e.state.fiber&&(e.state.fiber=void 0),hh(r)&&((n==null?void 0:n.propagateInterruption)===!0?!$ge(r.cause):!ml(r.cause))&&bw(e.deferred,r)})}),Q6=e=>Tl(t=>_a(n=>e.state._tag==="Closed"||e.state.fiber===void 0?Le:Tt(t(ry(e.state.fiber,As(n.id(),Np))),Re(()=>{e.state._tag==="Open"&&(e.state.fiber=void 0)})))),Tge=function(){let e;return()=>(e===void 0&&(e=Po(to)),e)}(),Md=function(){const e=arguments[0];if($a(arguments[1]))return vF(e,arguments[1],arguments[2]);const t=arguments[1];return n=>vF(e,n,t)},vF=(e,t,n)=>MI(r=>e.state._tag==="Closed"?to:e.state.fiber!==void 0&&(n==null?void 0:n.onlyIfMissing)===!0?Re(Tge):kr(zI(t),s=>Ige(e,s,{...n,interruptAs:r}))),LC=Symbol.for("effect/FiberMap"),Pge=e=>_e(e,LC),Oge={[LC]:LC,[Symbol.iterator](){return this.state._tag==="Closed"?uM():this.state.backing[Symbol.iterator]()},toString(){return qt(this.toJSON())},toJSON(){return{_id:"FiberMap",state:this.state}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},Age=(e,t)=>{const n=Object.create(Oge);return n.state={_tag:"Open",backing:e},n.deferred=t,n},Fge=()=>Rt(je(rt(),e=>Age(Oz(),e)),e=>_a(t=>{const n=e.state;return n._tag==="Closed"?Le:(e.state={_tag:"Closed"},Bj(UQ(n.backing,([,r])=>r),As(t.id(),Dp)).pipe(iy(e.deferred)))})),J6=-1,Dp=m$(J6,0),Nge=CI(void 0,{emptyCase:ds,failCase:ds,dieCase:ds,interruptCase:(e,t)=>rw(ow(t),J6),sequentialCase:(e,t,n)=>t||n,parallelCase:(e,t,n)=>t||n}),Dge=x(e=>Pge(e[0]),(e,t,n,r)=>{if(e.state._tag==="Closed"){n.unsafeInterruptAsFork(As((r==null?void 0:r.interruptAs)??Nr,Dp));return}const s=eo(e.state.backing,t);if(s._tag==="Some"){if((r==null?void 0:r.onlyIfMissing)===!0){n.unsafeInterruptAsFork(As((r==null?void 0:r.interruptAs)??Nr,Dp));return}else if(s.value===n)return;s.value.unsafeInterruptAsFork(As((r==null?void 0:r.interruptAs)??Nr,Dp))}af(e.state.backing,t,n),n.addObserver(i=>{if(e.state._tag==="Closed")return;const o=eo(e.state.backing,t);Wt(o)&&n===o.value&&une(e.state.backing,t),hh(i)&&((r==null?void 0:r.propagateInterruption)===!0?!Nge(i.cause):!ml(i.cause))&&bw(e.deferred,i)})}),qge=x(2,(e,t)=>e.state._tag==="Closed"?!1:of(e.state.backing,t)),J1=x(2,(e,t)=>_a(n=>{if(e.state._tag==="Closed")return Le;const r=eo(e.state.backing,t);return r._tag==="None"?Le:ry(r.value,As(n.id(),Dp))})),Mge=function(){let e;return()=>(e===void 0&&(e=Po(to)),e)}(),Y1=function(){const e=arguments[0];if($a(arguments[2]))return wF(e,arguments[1],arguments[2],arguments[3]);const t=arguments[1],n=arguments[2];return r=>wF(e,t,r,n)},wF=(e,t,n,r)=>MI(s=>e.state._tag==="Closed"?to:(r==null?void 0:r.onlyIfMissing)===!0&&qge(e,t)?Re(Mge):kr(zI(n),i=>Dge(e,t,i,{...r,interruptAs:s}))),zC=Symbol.for("effect/FiberSet"),Lge=e=>_e(e,zC),zge={[zC]:zC,[Symbol.iterator](){return this.state._tag==="Closed"?uM():this.state.backing[Symbol.iterator]()},toString(){return qt(this.toJSON())},toJSON(){return{_id:"FiberMap",state:this.state}},[ft](){return this.toJSON()},pipe(){return pe(this,arguments)}},jge=(e,t)=>{const n=Object.create(zge);return n.state={_tag:"Open",backing:e},n.deferred=t,n},Uge=()=>Rt(je(rt(),e=>jge(new Set,e)),e=>_a(t=>{const n=e.state;if(n._tag==="Closed")return Le;e.state={_tag:"Closed"};const r=n.backing;return Bj(r,As(t.id(),X6)).pipe(iy(e.deferred))})),Y6=-1,X6=m$(Y6,0),Hge=CI(void 0,{emptyCase:ds,failCase:ds,dieCase:ds,interruptCase:(e,t)=>rw(ow(t),Y6),sequentialCase:(e,t,n)=>t||n,parallelCase:(e,t,n)=>t||n}),Bge=x(e=>Lge(e[0]),(e,t,n)=>{if(e.state._tag==="Closed"){t.unsafeInterruptAsFork(As((n==null?void 0:n.interruptAs)??Nr,X6));return}else if(e.state.backing.has(t))return;e.state.backing.add(t),t.addObserver(r=>{e.state._tag!=="Closed"&&(e.state.backing.delete(t),hh(r)&&((n==null?void 0:n.propagateInterruption)===!0?!Hge(r.cause):!ml(r.cause))&&bw(e.deferred,r))})}),Vge=e=>yn(e.deferred),Wge="effect/GroupBy",Z6=Symbol.for(Wge),Kge={_R:e=>e,_E:e=>e,_K:e=>e,_V:e=>e},Gge=e=>_e(e,Z6),Qge=x(e=>Gge(e[0]),(e,t,n)=>zc(e.grouped,([r,s])=>t(r,z6(Lg(s,{shutdown:!0}))),{concurrency:"unbounded",bufferSize:(n==null?void 0:n.bufferSize)??16})),Jge=e=>({[Z6]:Kge,pipe(){return pe(this,arguments)},grouped:e}),Yge=x(e=>typeof e[0]!="function",(e,t,n)=>n!=null&&n.key?Qge(Xge(e,n.key,{bufferSize:n.bufferSize}),(r,s)=>E0(s,t)):NC(n==null?void 0:n.concurrency,()=>E0(e,t),r=>n!=null&&n.unordered?zc(e,s=>Du(t(s)),{concurrency:r}):Upe(e,r,t))),Xge=x(e=>typeof e[0]!="function",(e,t,n)=>{const r=(s,i)=>Vs({onInput:o=>Ze(en(er(Zge(o,t),([a,c])=>{const f=s.get(a);return f===void 0?T(Yw((n==null?void 0:n.bufferSize)??16),we(d=>T(Re(()=>{s.set(a,d)}),Tt($t(i,ype([a,d]))),Tt(T($t(d,w0(c)),L1(g=>ml(g)?oe(Le):re())))))):L1($t(f,w0(c)),d=>ml(d)?oe(Le):re())},{discard:!0})),()=>r(s,i)),onFailure:o=>en($t(i,bT(o))),onDone:()=>T(en(T(er(s.entries(),([o,a])=>T($t(a,b0),L1(c=>ml(c)?oe(Le):re())),{discard:!0}),Tt($t(i,b0)))))});return Jge(cge(s=>X(function*(){const i=new Map,o=yield*dr();return yield*Rl(s,In(o)),yield*wt(e).pipe(rr(r(i,o)),Zw,uT(s),gs(s),yo(z6(Lg(o,{shutdown:!0}))))})))}),Zge=x(2,(e,t)=>{const n=[],r=e[Symbol.iterator](),s=new Map;let i;for(;(i=r.next())&&!i.done;){const o=i.value,a=t(o);if(s.has(a))s.get(a).push(o);else{const c=[o];n.push([a,c]),s.set(a,c)}}return xn(n.map(o=>[o[0],xn(o[1])]))});class Sr{constructor(t,n,r){p(this,"path");p(this,"actual");p(this,"issue");p(this,"_tag","Pointer");this.path=t,this.actual=n,this.issue=r}}class bF{constructor(t,n){p(this,"actual");p(this,"message");p(this,"_tag","Unexpected");this.actual=t,this.message=n}}class Qh{constructor(t,n){p(this,"ast");p(this,"message");p(this,"_tag","Missing");p(this,"actual");this.ast=t,this.message=n}}class En{constructor(t,n,r,s){p(this,"ast");p(this,"actual");p(this,"issues");p(this,"output");p(this,"_tag","Composite");this.ast=t,this.actual=n,this.issues=r,this.output=s}}class X1{constructor(t,n,r,s){p(this,"ast");p(this,"actual");p(this,"kind");p(this,"issue");p(this,"_tag","Refinement");this.ast=t,this.actual=n,this.kind=r,this.issue=s}}class Z1{constructor(t,n,r,s){p(this,"ast");p(this,"actual");p(this,"kind");p(this,"issue");p(this,"_tag","Transformation");this.ast=t,this.actual=n,this.kind=r,this.issue=s}}class Fn{constructor(t,n,r){p(this,"ast");p(this,"actual");p(this,"message");p(this,"_tag","Type");this.ast=t,this.actual=n,this.message=r}}class EF{constructor(t,n,r){p(this,"ast");p(this,"actual");p(this,"message");p(this,"_tag","Forbidden");this.ast=t,this.actual=n,this.message=r}}const kF=Symbol.for("effect/Schema/ParseErrorTypeId");var Kke;class eme extends $le("ParseError"){constructor(){super(...arguments);p(this,Kke,kF)}get message(){return this.toString()}toString(){return Mp.formatIssueSync(this.issue)}toJSON(){return{_id:"ParseError",message:this.toString()}}[(Kke=kF,ft)](){return this.toJSON()}}const Th=e=>new eme({issue:e}),Ni=Pe,Al=$e,CF=SQ,Ur=iM,el=x(2,(e,t)=>Ur(e)?Zn(e,{onLeft:$e,onRight:t}):we(e,t)),Br=x(2,(e,t)=>Ur(e)?wQ(e,t):je(e,t)),qp=x(2,(e,t)=>Ur(e)?km(e,t):Gl(e,t)),tme=x(2,(e,t)=>Ur(e)?vQ(e,{onLeft:t.onFailure,onRight:t.onSuccess}):cue(e,t)),e8=x(2,(e,t)=>Ur(e)?Zn(e,{onLeft:t,onRight:Pe}):Uw(e,t)),fb=(e,t)=>t===void 0||fa(t)?e:e===void 0?t:{...e,...t},db=(e,t,n)=>{const r=or(e,t);return(s,i)=>r(s,fb(n,i))},$T=(e,t,n)=>{const r=db(e,t,n);return(s,i)=>oM(r(s,i),Th)},t8=(e,t,n)=>{const r=or(e,t);return(s,i)=>r(s,{...fb(n,i),isEffectAllowed:!0})},k0=(e,t)=>$T(e.ast,!0,t),nme=(e,t)=>db(e.ast,!0,t),Ph=(e,t)=>t8(e.ast,!0,t),IT=(e,t)=>$T(e.ast,!1,t),rme=(e,t)=>db(e.ast,!1,t),qu=(e,t)=>t8(e.ast,!1,t),Ld=k0,sme=Ph,hb=(e,t)=>$T(gn(e.ast),!0,t),ime=(e,t)=>db(gn(e.ast),!0,t),cr=(e,t)=>{const n=or(gn(e.ast),!0);return(r,s)=>ao(n(r,{exact:!0,...fb(t,s)}))},Jo=IT,ome=qu,ame=We(Symbol.for("effect/ParseResult/decodeMemoMap"),()=>new WeakMap),lme=We(Symbol.for("effect/ParseResult/encodeMemoMap"),()=>new WeakMap),or=(e,t)=>{const n=t?ame:lme,r=n.get(e);if(r)return r;const s=cme(e,t),i=PJ(e),o=Wt(i)?(f,d)=>s(f,fb(d,i.value)):s,a=OJ(e),c=t&&Wt(a)?(f,d)=>dp(e8(o(f,d),a.value),e,f,d):o;return n.set(e,c),c},eE=e=>ti($J(e)),tE=e=>ti(IJ(e)),cme=(e,t)=>{switch(e._tag){case"Refinement":if(t){const n=or(e.from,!0);return(r,s)=>{s=s??C1;const i=(s==null?void 0:s.errors)==="all",o=el(e8(n(r,s),a=>{const c=new X1(e,r,"From",a);return i&&WM(e)&&i8(a)?bt(e.filter(r,s,e),{onNone:()=>$e(c),onSome:f=>$e(new En(e,r,[c,new X1(e,r,"Predicate",f)]))}):$e(c)}),a=>bt(e.filter(a,s,e),{onNone:()=>Pe(a),onSome:c=>$e(new X1(e,r,"Predicate",c))}));return dp(o,e,r,s)}}else{const n=or(gn(e),!0),r=or(n8(e.from),!1);return(s,i)=>dp(el(n(s,i),o=>r(o,i)),e,s,i)}case"Transformation":{const n=dme(e.transformation,t),r=t?or(e.from,!0):or(e.to,!1),s=t?or(e.to,!0):or(e.from,!1);return(i,o)=>dp(el(qp(r(i,o),a=>new Z1(e,i,t?"Encoded":"Type",a)),a=>el(qp(n(a,o??C1,e,i),c=>new Z1(e,i,"Transformation",c)),c=>qp(s(c,o),f=>new Z1(e,i,t?"Type":"Encoded",f)))),e,i,o)}case"Declaration":{const n=t?e.decodeUnknown(...e.typeParameters):e.encodeUnknown(...e.typeParameters);return(r,s)=>dp(n(r,s??C1,e),e,r,s)}case"Literal":return Es(e,n=>n===e.literal);case"UniqueSymbol":return Es(e,n=>n===e.symbol);case"UndefinedKeyword":return Es(e,MG);case"NeverKeyword":return Es(e,LG);case"UnknownKeyword":case"AnyKeyword":case"VoidKeyword":return Pe;case"StringKeyword":return Es(e,Jr);case"NumberKeyword":return Es(e,fa);case"BooleanKeyword":return Es(e,Kc);case"BigIntKeyword":return Es(e,Iv);case"SymbolKeyword":return Es(e,kS);case"ObjectKeyword":return Es(e,xo);case"Enums":return Es(e,n=>e.enums.some(([r,s])=>s===n));case"TemplateLiteral":{const n=tL(e);return Es(e,r=>Jr(r)&&n.test(r))}case"TupleType":{const n=e.elements.map(f=>or(f.type,t)),r=e.rest.map(f=>or(f.type,t));let s=e.elements.filter(f=>!f.isOptional);e.rest.length>0&&(s=s.concat(e.rest.slice(1)));const i=s.length,o=e.elements.length>0?e.elements.map((f,d)=>d).join(" | "):"never",a=eE(e),c=tE(e);return(f,d)=>{if(!JQ(f))return $e(new Fn(e,f));const g=(d==null?void 0:d.errors)==="all",_=[];let b=0;const k=[],I=f.length;for(let v=I;v<=i-1;v++){const w=new Sr(v,f,new Qh(s[v-I]));if(g){_.push([b++,w]);continue}else return $e(new En(e,f,w,k))}if(e.rest.length===0)for(let v=e.elements.length;v<=I-1;v++){const w=new Sr(v,f,new bF(f[v],`is unexpected, expected: ${o}`));if(g){_.push([b++,w]);continue}else return $e(new En(e,f,w,k))}let E=0,y;for(;E<n.length;E++)if(I<E+1){if(e.elements[E].isOptional)continue}else{const v=n[E],w=v(f[E],d);if(Ur(w)){if(Gn(w)){const $=new Sr(E,f,w.left);if(g){_.push([b++,$]);continue}else return $e(new En(e,f,$,vi(k)))}k.push([b++,w.right])}else{const $=b++,P=E;y||(y=[]),y.push(({es:O,output:A})=>we(cc(w),z=>{if(Gn(z)){const D=new Sr(P,f,z.left);return g?(O.push([$,D]),Le):$e(new En(e,f,D,vi(A)))}return A.push([$,z.right]),Le}))}}if(Kt(r)){const[v,...w]=r;for(;E<I-w.length;E++){const $=v(f[E],d);if(Ur($))if(Gn($)){const P=new Sr(E,f,$.left);if(g){_.push([b++,P]);continue}else return $e(new En(e,f,P,vi(k)))}else k.push([b++,$.right]);else{const P=b++,O=E;y||(y=[]),y.push(({es:A,output:z})=>we(cc($),D=>{if(Gn(D)){const W=new Sr(O,f,D.left);return g?(A.push([P,W]),Le):$e(new En(e,f,W,vi(z)))}else return z.push([P,D.right]),Le}))}}for(let $=0;$<w.length;$++)if(E+=$,!(I<E+1)){const P=w[$](f[E],d);if(Ur(P)){if(Gn(P)){const O=new Sr(E,f,P.left);if(g){_.push([b++,O]);continue}else return $e(new En(e,f,O,vi(k)))}k.push([b++,P.right])}else{const O=b++,A=E;y||(y=[]),y.push(({es:z,output:D})=>we(cc(P),W=>{if(Gn(W)){const le=new Sr(A,f,W.left);return g?(z.push([O,le]),Le):$e(new En(e,f,le,vi(D)))}return D.push([O,W.right]),Le}))}}}const m=({es:v,output:w})=>T_(v)?$e(new En(e,f,vi(v),vi(w))):Pe(vi(w));if(y&&y.length>0){const v=y;return zt(()=>{const w={es:op(_),output:op(k)};return we(er(v,$=>$(w),{concurrency:a,batching:c,discard:!0}),()=>m(w))})}return m({output:k,es:_})}}case"TypeLiteral":{if(e.propertySignatures.length===0&&e.indexSignatures.length===0)return Es(e,zG);const n=[],r={},s=[];for(const d of e.propertySignatures)n.push([or(d.type,t),d]),r[d.name]=null,s.push(d.name);const i=e.indexSignatures.map(d=>[or(d.parameter,t),or(d.type,t),d.parameter]),o=Jn.make(e.indexSignatures.map(d=>d.parameter).concat(s.map(d=>kS(d)?new MJ(d):new FS(d)))),a=or(o,t),c=eE(e),f=tE(e);return(d,g)=>{if(!UG(d))return $e(new Fn(e,d));const _=(g==null?void 0:g.errors)==="all",b=[];let k=0;const I=(g==null?void 0:g.onExcessProperty)==="error",E=(g==null?void 0:g.onExcessProperty)==="preserve",y={};let m;if(I||E){m=go(d);for(const P of m){const O=a(P,g);if(Ur(O)&&Gn(O))if(I){const A=new Sr(P,d,new bF(d[P],`is unexpected, expected: ${String(o)}`));if(_){b.push([k++,A]);continue}else return $e(new En(e,d,A,y))}else y[P]=d[P]}}let v;const w=(g==null?void 0:g.exact)===!0;for(let P=0;P<n.length;P++){const O=n[P][1],A=O.name,z=Object.prototype.hasOwnProperty.call(d,A);if(!z){if(O.isOptional)continue;if(w){const le=new Sr(A,d,new Qh(O));if(_){b.push([k++,le]);continue}else return $e(new En(e,d,le,y))}}const D=n[P][0],W=D(d[A],g);if(Ur(W)){if(Gn(W)){const le=new Sr(A,d,z?W.left:new Qh(O));if(_){b.push([k++,le]);continue}else return $e(new En(e,d,le,y))}y[A]=W.right}else{const le=k++,M=A;v||(v=[]),v.push(({es:U,output:Q})=>we(cc(W),L=>{if(Gn(L)){const G=new Sr(M,d,z?L.left:new Qh(O));return _?(U.push([le,G]),Le):$e(new En(e,d,G,Q))}return Q[M]=L.right,Le}))}}for(let P=0;P<i.length;P++){const O=i[P],A=O[0],z=O[1],D=bM(d,O[2]);for(const W of D){const le=A(W,g);if(Ur(le)&&ao(le)){const M=z(d[W],g);if(Ur(M))if(Gn(M)){const U=new Sr(W,d,M.left);if(_){b.push([k++,U]);continue}else return $e(new En(e,d,U,y))}else Object.prototype.hasOwnProperty.call(r,W)||(y[W]=M.right);else{const U=k++,Q=W;v||(v=[]),v.push(({es:L,output:G})=>we(cc(M),V=>{if(Gn(V)){const J=new Sr(Q,d,V.left);return _?(L.push([U,J]),Le):$e(new En(e,d,J,G))}else return Object.prototype.hasOwnProperty.call(r,W)||(G[W]=V.right),Le}))}}}}const $=({es:P,output:O})=>{if(T_(P))return $e(new En(e,d,vi(P),O));if((g==null?void 0:g.propertyOrder)==="original"){const A=m||go(d);for(const D of s)A.indexOf(D)===-1&&A.push(D);const z={};for(const D of A)Object.prototype.hasOwnProperty.call(O,D)&&(z[D]=O[D]);return Pe(z)}return Pe(O)};if(v&&v.length>0){const P=v;return zt(()=>{const O={es:op(b),output:Object.assign({},y)};return we(er(P,A=>A(O),{concurrency:c,batching:f,discard:!0}),()=>$(O))})}return $({es:b,output:y})}}case"Union":{const n=ume(e.types,t),r=go(n.keys),s=r.length,i=e.types.length,o=new Map;for(let f=0;f<i;f++)o.set(e.types[f],or(e.types[f],t));const a=eE(e)??1,c=tE(e);return(f,d)=>{const g=[];let _=0,b=[];if(s>0)if(FR(f))for(let E=0;E<s;E++){const y=r[E],m=n.keys[y].buckets;if(Object.prototype.hasOwnProperty.call(f,y)){const v=String(f[y]);if(Object.prototype.hasOwnProperty.call(m,v))b=b.concat(m[v]);else{const{candidates:w,literals:$}=n.keys[y],P=Jn.make($),O=w.length===i?new fi([new pn(y,P,!1,!0)],[]):Jn.make(w);g.push([_++,new En(O,f,new Sr(y,f,new Fn(P,f[y])))])}}else{const{candidates:v,literals:w}=n.keys[y],$=new pn(y,Jn.make(w),!1,!0),P=v.length===i?new fi([$],[]):Jn.make(v);g.push([_++,new En(P,f,new Sr(y,f,new Qh($)))])}}else{const E=n.candidates.length===i?e:Jn.make(n.candidates);g.push([_++,new Fn(E,f)])}n.otherwise.length>0&&(b=b.concat(n.otherwise));let k;for(let E=0;E<b.length;E++){const y=b[E],m=o.get(y)(f,d);if(Ur(m)&&(!k||k.length===0)){if(ao(m))return m;g.push([_++,m.left])}else{const v=_++;k||(k=[]),k.push(w=>zt(()=>"finalResult"in w?Le:we(cc(m),$=>(ao($)?w.finalResult=$:w.es.push([v,$.left]),Le))))}}const I=E=>T_(E)?E.length===1&&E[0][1]._tag==="Type"?$e(E[0][1]):$e(new En(e,f,vi(E))):$e(new Fn(e,f));if(k&&k.length>0){const E=k;return zt(()=>{const y={es:op(g)};return we(er(E,m=>m(y),{concurrency:a,batching:c,discard:!0}),()=>"finalResult"in y?y.finalResult:I(y.es))})}return I(g)}}case"Suspend":{const n=EM(()=>or(Zc(e.f(),e.annotations),t));return(r,s)=>n()(r,s)}}},Es=(e,t)=>n=>t(n)?Pe(n):$e(new Fn(e,n)),fp=(e,t)=>{switch(e._tag){case"Declaration":{const n=Mv(e);if(Wt(n))return fp(n.value,t);break}case"TypeLiteral":{const n=[];for(let r=0;r<e.propertySignatures.length;r++){const s=e.propertySignatures[r],i=t?Rk(s.type):gn(s.type);Pp(i)&&!s.isOptional&&n.push([s.name,i])}return n}case"TupleType":{const n=[];for(let r=0;r<e.elements.length;r++){const s=e.elements[r],i=t?Rk(s.type):gn(s.type);Pp(i)&&!s.isOptional&&n.push([r,i])}return n}case"Refinement":return fp(e.from,t);case"Suspend":return fp(e.f(),t);case"Transformation":return fp(t?e.from:e.to,t)}return[]},ume=(e,t)=>{const n={},r=[],s=[];for(let i=0;i<e.length;i++){const o=e[i],a=fp(o,t);if(a.length>0){s.push(o);for(let c=0;c<a.length;c++){const[f,d]=a[c],g=String(d.literal);n[f]=n[f]||{buckets:{},literals:[],candidates:[]};const _=n[f].buckets;if(Object.prototype.hasOwnProperty.call(_,g)){if(c<a.length-1)continue;_[g].push(o),n[f].literals.push(d),n[f].candidates.push(o)}else{_[g]=[o],n[f].literals.push(d),n[f].candidates.push(o);break}}}else r.push(o)}return{keys:n,otherwise:r,candidates:s}},n8=e=>Uf(e)?n8(e.from):e,dp=(e,t,n,r)=>{if((r==null?void 0:r.isEffectAllowed)===!0||Ur(e))return e;const s=new F4,i=Po(e,{scheduler:s});s.flush();const o=i.unsafePoll();if(o){if(xd(o))return Pe(o.value);const a=o.cause;return Sj(a)?$e(a.error):$e(new EF(t,n,l0(a)))}return $e(new EF(t,n,"cannot be be resolved synchronously, this is caused by using runSync on an effect that performs async work"))},fme=([e],[t])=>e>t?1:e<t?-1:0;function vi(e){return e.sort(fme).map(t=>t[1])}const dme=(e,t)=>{switch(e._tag){case"FinalTransformation":return t?e.decode:e.encode;case"ComposeTransformation":return Pe;case"TypeLiteralTransformation":return n=>{let r=Pe(n);for(const s of e.propertySignatureTransformations){const[i,o]=t?[s.from,s.to]:[s.to,s.from],a=t?s.decode:s.encode;r=Br(r,f=>{const d=a(Object.prototype.hasOwnProperty.call(f,i)?oe(f[i]):re());return delete f[i],Wt(d)&&(f[o]=d.value),f})}return r}}},Lr=(e,t=[])=>({value:e,forest:t}),Mp={formatIssue:e=>Br(uf(e),hme),formatIssueSync:e=>{const t=Mp.formatIssue(e);return Ur(t)?EQ(t):ur(t)},formatError:e=>Mp.formatIssue(e.issue),formatErrorSync:e=>Mp.formatIssueSync(e.issue)},hme=e=>e.value+r8(`
205
+ `,e.forest),r8=(e,t)=>{let n="";const r=t.length;let s;for(let i=0;i<r;i++){s=t[i];const o=i===r-1;n+=e+(o?"└":"├")+"─ "+s.value,n+=r8(e+(r>1&&!o?"│ ":" "),s.forest)}return n},pme=e=>{switch(e){case"Encoded":return"Encoded side transformation failure";case"Transformation":return"Transformation process failure";case"Type":return"Type side transformation failure"}},gme=e=>{switch(e){case"From":return"From side refinement failure";case"Predicate":return"Predicate refinement failure"}},s8=e=>"ast"in e?oe(e.ast):re(),jC=Pe(void 0),mme=e=>s8(e).pipe(Eu(xJ),bt({onNone:()=>jC,onSome:t=>{const n=t(e);return Jr(n)?Pe({message:n,override:!1}):$a(n)?je(n,r=>({message:r,override:!1})):Jr(n.message)?Pe({message:n.message,override:n.override}):je(n.message,r=>({message:r,override:n.override}))}})),TT=e=>t=>t._tag===e,i8=TT("Composite"),xF=TT("Refinement"),RF=TT("Transformation"),Lp=e=>el(mme(e),t=>t!==void 0?!t.override&&(i8(e)||xF(e)&&e.kind==="From"||RF(e)&&e.kind!=="Transformation")?RF(e)||xF(e)?Lp(e.issue):jC:Pe(t.message):jC),o8=e=>s8(e).pipe(Eu(TJ),$Q(t=>t(e)),ti);function yme(e){return VM(e).pipe(Xo(()=>HM(e)),Xo(()=>BM(e)),Xo(()=>qv(e)),Yt(()=>`{ ${e.from} | filter }`))}function _me(e){return e.message!==void 0?e.message:`Expected ${Uf(e.ast)?yme(e.ast):String(e.ast)}, actual ${ui(e.actual)}`}const Sme=e=>Br(Lp(e),t=>t??o8(e)??_me(e)),a_=e=>o8(e)??String(e.ast),vme=e=>e.message??"is forbidden",wme=e=>e.message??"is unexpected",bme=e=>{const t=RJ(e.ast);if(Wt(t)){const n=t.value();return Jr(n)?Pe(n):n}return Pe(e.message??"is missing")},uf=e=>{switch(e._tag){case"Type":return Br(Sme(e),Lr);case"Forbidden":return Pe(Lr(a_(e),[Lr(vme(e))]));case"Unexpected":return Pe(Lr(wme(e)));case"Missing":return Br(bme(e),Lr);case"Transformation":return el(Lp(e),t=>t!==void 0?Pe(Lr(t)):Br(uf(e.issue),n=>Lr(a_(e),[Lr(pme(e.kind),[n])])));case"Refinement":return el(Lp(e),t=>t!==void 0?Pe(Lr(t)):Br(uf(e.issue),n=>Lr(a_(e),[Lr(gme(e.kind),[n])])));case"Pointer":return Br(uf(e.issue),t=>Lr(xM(e.path),[t]));case"Composite":return el(Lp(e),t=>{if(t!==void 0)return Pe(Lr(t));const n=a_(e);return CM(e.issues)?Br(er(e.issues,uf),r=>Lr(n,r)):Br(uf(e.issues),r=>Lr(n,[r]))})}},$F=Symbol.for("effect/Pool"),Eme={_E:e=>e,_A:e=>e},a8=e=>Yr(t=>Z(fh(),n=>{const r=hs(n,Bi),s=H$(e.acquire,c=>xa(n,c)),i=new xme(r,s,e.concurrency??1,e.min,e.max,e.strategy,Math.min(Math.max(e.targetUtilization??1,.1),1)),o=ya(Td(t(i.resize)),c=>r.addFinalizer(()=>kg(c))),a=ya(Td(t(e.strategy.run(i))),c=>r.addFinalizer(()=>kg(c)));return ie(i).pipe(gl(r.addFinalizer(()=>i.shutdown)),gl(o),gl(a))})),kme=e=>a8({...e,min:e.size,max:e.size,strategy:Rme()}),Cme=e=>Z(e.timeToLiveStrategy==="creation"?$me(e.timeToLive):Ime(e.timeToLive),t=>a8({...e,strategy:t}));var Gke;class xme extends Io{constructor(n,r,s,i,o,a,c){super();p(this,"scope");p(this,"acquire");p(this,"concurrency");p(this,"minSize");p(this,"maxSize");p(this,"strategy");p(this,"targetUtilization");p(this,Gke);p(this,"isShuttingDown",!1);p(this,"semaphore");p(this,"items",new Set);p(this,"available",new Set);p(this,"availableLatch",TI(!1));p(this,"invalidated",new Set);p(this,"waiters",0);p(this,"allocate",R$(gh(),n=>this.acquire.pipe(Fu(n),Fi,Z(r=>{const s={exit:r,finalizer:Nm(n.close(r),Tme),refCount:0,disableReclaim:!1};return this.items.add(s),this.available.add(s),Tn(r._tag==="Success"?this.strategy.onAcquire(s):kt(s.finalizer,this.strategy.onAcquire(s)),s)})),(n,r)=>r._tag==="Failure"?n.close(r):Ve));p(this,"resizeLoop",Ee(()=>{if(this.activeSize>=this.targetSize)return Ve;const n=this.targetSize-this.activeSize;return this.strategy.reclaim(this).pipe(Z(bt({onNone:()=>this.allocate,onSome:ie})),kae(n,{concurrency:n}),gl(this.availableLatch.open),Z(r=>r.some(s=>s.exit._tag==="Failure")?Ve:this.resizeLoop))}));p(this,"resizeSemaphore",Ap(1));p(this,"resize",this.resizeSemaphore.withPermits(1)(this.resizeLoop));p(this,"getPoolItem",Yr(n=>n(this.semaphore.take(1)).pipe(kt(Bi),Z(r=>Ee(()=>{if(this.waiters++,this.isShuttingDown)return Pn;if(this.targetSize>this.activeSize){const s=this;return Z(this.resizeSemaphore.withPermitsIfAvailable(1)(f0(Cd(this.resize),this.scope)),function i(){return s.isShuttingDown?Pn:s.available.size>0?ie(vk(s.available)):(s.availableLatch.unsafeClose(),Z(s.availableLatch.await,i))})}return ie(vk(this.available))}).pipe(Pd(se(()=>this.waiters--)),ya(s=>s.exit._tag==="Failure"?(this.items.delete(s),this.invalidated.delete(s),this.available.delete(s),this.semaphore.release(1)):(s.refCount++,this.available.delete(s),s.refCount<this.concurrency&&this.available.add(s),r.addFinalizer(()=>kt(Ee(()=>(s.refCount--,this.invalidated.has(s)?this.invalidatePoolItem(s):(this.available.add(s),wr))),this.semaphore.release(1))))),Vl(()=>this.semaphore.release(1)))))));p(this,"get",Z(Ee(()=>this.isShuttingDown?Pn:this.getPoolItem),n=>n.exit));this.scope=n,this.acquire=r,this.concurrency=s,this.minSize=i,this.maxSize=o,this.strategy=a,this.targetUtilization=c,this[$F]=Eme,this.semaphore=Ap(s*o)}get currentUsage(){let n=this.waiters;for(const r of this.items)n+=r.refCount;return n}get targetSize(){if(this.isShuttingDown)return 0;const n=this.currentUsage/this.targetUtilization,r=Math.ceil(n/this.concurrency);return Math.min(Math.max(this.minSize,r),this.maxSize)}get activeSize(){return this.items.size-this.invalidated.size}commit(){return this.get}invalidate(n){return Ee(()=>{if(this.isShuttingDown)return Ve;for(const r of this.items)if(r.exit._tag==="Success"&&r.exit.value===n)return r.disableReclaim=!0,Ra(this.invalidatePoolItem(r));return Ve})}invalidatePoolItem(n){return Ee(()=>{if(this.items.has(n)){if(n.refCount===0)return this.items.delete(n),this.available.delete(n),this.invalidated.delete(n),kt(n.finalizer,f0(Cd(this.resize),this.scope))}else return Ve;return this.invalidated.add(n),this.available.delete(n),Ve})}get shutdown(){return Ee(()=>{if(this.isShuttingDown)return Ve;this.isShuttingDown=!0;const n=this.items.size,r=Ap(n);return fu(this.items,s=>s.refCount>0?(s.finalizer=gl(s.finalizer,r.release(1)),this.invalidated.add(s),r.take(1)):(this.items.delete(s),this.available.delete(s),this.invalidated.delete(s),s.finalizer)).pipe(kt(this.semaphore.releaseAll),kt(this.availableLatch.open),kt(r.take(n)))})}pipe(){return pe(this,arguments)}}Gke=$F;const Rme=()=>({run:e=>Ve,onAcquire:e=>Ve,reclaim:e=>Og}),$me=e=>X$(t=>Fe(YI(),n=>{const r=ru(e),s=new WeakMap;return Ce({run:i=>{const o=a=>Ee(()=>{if(!i.items.has(a)||i.invalidated.has(a))return Ve;const c=t.unsafeCurrentTimeMillis(),f=s.get(a),d=r-(c-f);return d>0?sI(o(a),d):i.invalidatePoolItem(a)});return n.take.pipe(ya(o),iI)},onAcquire:i=>Ee(()=>(s.set(i,t.unsafeCurrentTimeMillis()),n.offer(i))),reclaim:i=>Og})})),Ime=e=>Fe(YI(),t=>Ce({run:n=>{const r=Ee(()=>n.activeSize-n.targetSize<=0?Ve:t.take.pipe(ya(i=>n.invalidatePoolItem(i)),kt(r)));return r.pipe(sI(e),iI)},onAcquire:n=>t.offer(n),reclaim(n){return Ee(()=>{if(n.invalidated.size===0)return Og;const r=MQ(HQ(n.invalidated,s=>!s.disableReclaim));return r._tag==="None"?Og:(n.invalidated.delete(r.value),r.value.refCount<n.concurrency&&n.available.add(r.value),Tn(t.offer(r.value),r))})}})),Tme=e=>et(t=>{const n=t.getFiberRef(N$);return n._tag==="Some"&&t.log("Unhandled error in pool finalizer",e,n),Ve}),Pme=Oue,Ome=Iue,Ame=uj,Fme=Die,Nme=fj,UC=Symbol.for("effect/Mailbox"),IF=Symbol.for("effect/Mailbox/ReadonlyMailbox"),dc=Ut(),TF=St(dc),l_=St(!1),c_=St(!0),PF=[dc,!0];var Qke,Jke;class Dme extends Io{constructor(n,r,s){super();p(this,"scheduler");p(this,"capacity");p(this,"strategy");p(this,Qke,UC);p(this,Jke,IF);p(this,"state",{_tag:"Open",takers:new Set,offers:new Set,awaiters:new Set});p(this,"messages",[]);p(this,"messagesChunk",Ut());p(this,"shutdown",se(()=>{if(this.state._tag==="Done")return!0;this.messages=[],this.messagesChunk=dc;const n=this.state.offers;if(this.finalize(this.state._tag==="Open"?wr:this.state.exit),n.size>0){for(const r of n)r._tag==="Single"?r.resume(l_):r.resume(St(xn(r.remaining.slice(r.offset))));n.clear()}return!0}));p(this,"end",this.done(wr));p(this,"clear",Ee(()=>{if(this.state._tag==="Done")return M_(this.state.exit,dc);const n=this.unsafeTakeAll();return this.releaseCapacity(),ie(n)}));p(this,"takeAll",Ee(()=>{if(this.state._tag==="Done")return M_(this.state.exit,PF);const n=this.unsafeTakeAll();return n.length===0?kt(this.awaitTake,this.takeAll):ie([n,this.releaseCapacity()])}));p(this,"take",Ee(()=>this.unsafeTake()??kt(this.awaitTake,this.take)));p(this,"await",Xa(n=>this.state._tag==="Done"?n(this.state.exit):(this.state.awaiters.add(n),se(()=>{this.state._tag!=="Done"&&this.state.awaiters.delete(n)}))));p(this,"size",se(()=>this.unsafeSize()));p(this,"awaitTake",Xa(n=>this.state._tag==="Done"?n(this.state.exit):(this.state.takers.add(n),se(()=>{this.state._tag!=="Done"&&this.state.takers.delete(n)}))));p(this,"scheduleRunning",!1);p(this,"releaseTaker",()=>{if(this.scheduleRunning=!1,this.state._tag==="Done")return;if(this.state.takers.size===0)return;const n=vk(this.state.takers);this.state.takers.delete(n),n(wr)});this.scheduler=n,this.capacity=r,this.strategy=s}offer(n){return Ee(()=>{if(this.state._tag!=="Open")return l_;if(this.messages.length+this.messagesChunk.length>=this.capacity)switch(this.strategy){case"dropping":return l_;case"suspend":return this.capacity<=0&&this.state.takers.size>0?(this.messages.push(n),this.releaseTaker(),c_):this.offerRemainingSingle(n);case"sliding":return this.unsafeTake(),this.messages.push(n),c_}return this.messages.push(n),this.scheduleReleaseTaker(),c_})}unsafeOffer(n){return this.state._tag!=="Open"?!1:this.messages.length+this.messagesChunk.length>=this.capacity?this.strategy==="sliding"?(this.unsafeTake(),this.messages.push(n),!0):this.capacity<=0&&this.state.takers.size>0?(this.messages.push(n),this.releaseTaker(),!0):!1:(this.messages.push(n),this.scheduleReleaseTaker(),!0)}offerAll(n){return Ee(()=>{if(this.state._tag!=="Open")return ie(da(n));const r=this.unsafeOfferAllArray(n);return r.length===0?TF:this.strategy==="dropping"?ie(xn(r)):this.offerRemainingArray(r)})}unsafeOfferAll(n){return xn(this.unsafeOfferAllArray(n))}unsafeOfferAllArray(n){if(this.state._tag!=="Open")return gt(n);if(this.capacity===Number.POSITIVE_INFINITY||this.strategy==="sliding")return this.messages.length>0&&(this.messagesChunk=nn(this.messagesChunk,xn(this.messages))),this.strategy==="sliding"?this.messagesChunk=this.messagesChunk.pipe(nn(da(n)),HY(this.capacity)):Fc(n)?this.messagesChunk=nn(this.messagesChunk,n):this.messages=gt(n),this.scheduleReleaseTaker(),[];const r=this.capacity<=0?this.state.takers.size:this.capacity-this.messages.length-this.messagesChunk.length;if(r===0)return gt(n);const s=[];let i=0;for(const o of n)i<r?this.messages.push(o):s.push(o),i++;return this.scheduleReleaseTaker(),s}fail(n){return this.done(xg(n))}failCause(n){return this.done(xt(n))}unsafeDone(n){return this.state._tag!=="Open"?!1:this.state.offers.size===0&&this.messages.length===0&&this.messagesChunk.length===0?(this.finalize(n),!0):(this.state={...this.state,_tag:"Closing",exit:n},!0)}done(n){return se(()=>this.unsafeDone(n))}takeN(n){return Ee(()=>{if(this.state._tag==="Done")return M_(this.state.exit,PF);if(n<=0)return ie([dc,!1]);n=Math.min(n,this.capacity);let r;if(n<=this.messagesChunk.length)r=pd(this.messagesChunk,n),this.messagesChunk=lo(this.messagesChunk,n);else if(n<=this.messages.length+this.messagesChunk.length)this.messagesChunk=nn(this.messagesChunk,xn(this.messages)),this.messages=[],r=pd(this.messagesChunk,n),this.messagesChunk=lo(this.messagesChunk,n);else return kt(this.awaitTake,this.takeN(n));return ie([r,this.releaseCapacity()])})}unsafeTake(){if(this.state._tag==="Done")return Iz(this.state.exit,xg(new Lw));let n;if(this.messagesChunk.length>0)n=Gv(this.messagesChunk),this.messagesChunk=lo(this.messagesChunk,1);else if(this.messages.length>0)n=this.messages[0],this.messagesChunk=lo(xn(this.messages),1),this.messages=[];else return this.capacity<=0&&this.state.offers.size>0?(this.capacity=1,this.releaseCapacity(),this.capacity=0,this.messages.length>0?St(this.messages.pop()):void 0):void 0;return this.releaseCapacity(),St(n)}unsafeSize(){const n=this.messages.length+this.messagesChunk.length;return this.state._tag==="Done"?re():oe(n)}commit(){return this.takeAll}pipe(){return pe(this,arguments)}toJSON(){return{_id:"effect/Mailbox",state:this.state._tag,size:this.unsafeSize().toJSON()}}toString(){return qt(this)}[(Qke=UC,Jke=IF,ft)](){return qt(this)}offerRemainingSingle(n){return Xa(r=>{if(this.state._tag!=="Open")return r(l_);const s={_tag:"Single",message:n,resume:r};return this.state.offers.add(s),se(()=>{this.state._tag==="Open"&&this.state.offers.delete(s)})})}offerRemainingArray(n){return Xa(r=>{if(this.state._tag!=="Open")return r(St(xn(n)));const s={_tag:"Array",remaining:n,offset:0,resume:r};return this.state.offers.add(s),se(()=>{this.state._tag==="Open"&&this.state.offers.delete(s)})})}releaseCapacity(){if(this.state._tag==="Done")return this.state.exit._tag==="Success";if(this.state.offers.size===0)return this.state._tag==="Closing"&&this.messages.length===0&&this.messagesChunk.length===0?(this.finalize(this.state.exit),this.state.exit._tag==="Success"):!1;let n=this.capacity-this.messages.length-this.messagesChunk.length;for(const r of this.state.offers){if(n===0)return!1;if(r._tag==="Single")this.messages.push(r.message),n--,r.resume(c_),this.state.offers.delete(r);else{for(;r.offset<r.remaining.length;r.offset++){if(n===0)return!1;this.messages.push(r.remaining[r.offset]),n--}r.resume(TF),this.state.offers.delete(r)}}return!1}scheduleReleaseTaker(){this.scheduleRunning||(this.scheduleRunning=!0,this.scheduler.scheduleTask(this.releaseTaker,0))}unsafeTakeAll(){if(this.messagesChunk.length>0){const n=this.messages.length>0?nn(this.messagesChunk,xn(this.messages)):this.messagesChunk;return this.messagesChunk=dc,this.messages=[],n}else if(this.messages.length>0){const n=xn(this.messages);return this.messages=[],n}else if(this.state._tag!=="Done"&&this.state.offers.size>0)return this.capacity=1,this.releaseCapacity(),this.capacity=0,Xt(this.messages.pop());return dc}finalize(n){if(this.state._tag==="Done")return;const r=this.state;this.state={_tag:"Done",exit:n};for(const s of r.takers)s(n);r.takers.clear();for(const s of r.awaiters)s(n);r.awaiters.clear()}}const qme=e=>et(t=>ie(new Dme(t.currentScheduler,typeof e=="number"?e:(e==null?void 0:e.capacity)??Number.POSITIVE_INFINITY,typeof e=="number"?"suspend":(e==null?void 0:e.strategy)??"suspend"))),Mme=e=>{const t=Ze(e.takeAll,([n,r])=>r?n.length===0?sr:pt(n):kh(pt(n),t));return t},Lme=UC,zme=e=>_e(e,Lme),jme=qme,Ume=Mme;({...Dre,[_C]:0});const Hme=Symbol.for("@effect/matcher/Matcher"),Bme={[Hme]:{_input:Ce,_filters:Ce,_result:Ce,_return:Ce},_tag:"ValueMatcher",add(e){return this.value._tag==="Right"?this:e._tag==="When"&&e.guard(this.provided)===!0?HC(this.provided,Pe(e.evaluate(this.provided))):e._tag==="Not"&&e.guard(this.provided)===!1?HC(this.provided,Pe(e.evaluate(this.provided))):this},pipe(){return pe(this,arguments)}};function HC(e,t){const n=Object.create(Bme);return n.provided=e,n.value=t,n}const l8=(e,t)=>({_tag:"When",guard:e,evaluate:t}),BC=e=>{if(typeof e=="function")return e;if(Array.isArray(e)){const t=e.map(BC),n=t.length;return r=>{if(!Array.isArray(r))return!1;for(let s=0;s<n;s++)if(t[s](r[s])===!1)return!1;return!0}}else if(e!==null&&typeof e=="object"){const t=Object.entries(e).map(([r,s])=>[r,BC(s)]),n=t.length;return r=>{if(typeof r!="object"||r===null)return!1;for(let s=0;s<n;s++){const[i,o]=t[s];if(!(i in r)||o(r[i])===!1)return!1}return!0}}return t=>t===e},Vme=e=>HC(e,$e(e)),Wme=(e,t)=>n=>n.add(l8(BC(e),t)),Kme=e=>(...t)=>{const n=t[t.length-1],r=t.slice(0,-1),s=r.length===1?i=>i[e]===r[0]:i=>r.includes(i[e]);return i=>i.add(l8(s,n))},Gme=Kme("_tag"),Qme=e=>{if(e._tag==="ValueMatcher")return e.value;const t=e.cases.length;if(t===1){const n=e.cases[0];return r=>n._tag==="When"&&n.guard(r)===!0||n._tag==="Not"&&n.guard(r)===!1?Pe(n.evaluate(r)):$e(r)}return n=>{for(let r=0;r<t;r++){const s=e.cases[r];if(s._tag==="When"&&s.guard(n)===!0)return Pe(s.evaluate(n));if(s._tag==="Not"&&s.guard(n)===!1)return Pe(s.evaluate(n))}return $e(n)}},OF="effect/Match/exhaustive: absurd",Jme=e=>{const t=Qme(e);if(iM(t)){if(t._tag==="Right")return t.right;throw new Error(OF)}return n=>{const r=t(n);if(r._tag==="Right")return r.right;throw new Error(OF)}},c8=Vme,nE=Wme,rE=Gme,u8=Jme,Yme=kme,Xme=Cme,AF=mge,Zme="effect/ScopedRef",eye=Symbol.for(Zme),tye={_A:e=>e};({...ka,[eye]:0});const f8=e=>Fe(na(e.ref),t=>t[1]),nye="effect/Resource",rye=Symbol.for(nye),sye={_E:e=>e,_A:e=>e};({...ka,[rye]:0});const iye=e=>Z(f8(e.scopedRef),Ce),d8=jhe,oye=cf,aye=x(e=>xo(e[0]),(e,...t)=>{const n={};for(const r of t)r in e&&(n[r]=e[r]);return n}),lye=x(e=>xo(e[0]),(e,...t)=>{const n={...e};for(const r of t)delete n[r];return n}),zd=Symbol.for("effect/Schema");function Ot(e){var t,n,r;return n=class{constructor(){p(this,t,VC)}static annotations(i){return Ot(Vi(this.ast,i))}static pipe(){return pe(this,arguments)}static toString(){return String(e)}},t=zd,r=zd,p(n,"ast",e),p(n,"Type"),p(n,"Encoded"),p(n,"Context"),p(n,r,VC),n}const VC={_A:e=>e,_I:e=>e,_R:e=>e},FF={schemaId:EJ,message:TM,missingMessage:GR,identifier:QR,title:Ro,description:xm,examples:PM,default:OM,documentation:kJ,jsonSchema:AM,arbitrary:FM,pretty:NM,equivalence:DM,concurrency:qM,batching:MM,parseIssueTitle:LM,parseOptions:zM,decodingFallback:jM},Ql=e=>{if(!e)return{};const t={...e};for(const n in FF)if(n in e){const r=FF[n];t[r]=e[n],delete t[n]}return t},Vi=(e,t)=>Zc(e,Ql(t));const Oh=e=>String(e.ast),pb=e=>Ot(Rk(e.ast)),zi=e=>Ot(gn(e.ast)),PT=(e,t)=>{const n=qu(e,t);return(r,s)=>qp(n(r,s),Th)},cye=(e,t)=>{const n=rme(e,t);return(r,s)=>km(n(r,s),Th)},OT=PT,uye=cye,jg=(e,t)=>{const n=Ph(e,t);return(r,s)=>qp(n(r,s),Th)},fye=(e,t)=>{const n=nme(e,t);return(r,s)=>km(n(r,s),Th)},hp=jg,gy=fye,dye=(e,t)=>{const n=ime(e,t);return(r,s)=>km(n(r,s),Th)},ji=e=>_e(e,zd)&&xo(e[zd]);function hye(e){return JR(e)?Jn.make(eY(e,t=>new FS(t))):new FS(e[0])}function h8(e,t=hye(e)){var n;return n=class extends Ot(t){static annotations(s){return h8(this.literals,Vi(this.ast,s))}},p(n,"literals",[...e]),n}function nt(...e){return Kt(e)?h8(e):gb}const pye=(e,t,n)=>AT(e,new zv(e.map(r=>r.ast),(...r)=>t.decode(...r.map(Ot)),(...r)=>t.encode(...r.map(Ot)),Ql(n))),gye=(e,t)=>{const n=()=>(s,i,o)=>e(s)?Ni(s):Al(new Fn(o,s)),r=n;return AT([],new zv([],n,r,Ql(t)))};function AT(e,t){var n;return n=class extends Ot(t){static annotations(s){return AT(this.typeParameters,Vi(this.ast,s))}},p(n,"typeParameters",[...e]),n}const Jl=function(){if(Array.isArray(arguments[0])){const n=arguments[0],r=arguments[1],s=arguments[2];return pye(n,r,s)}const e=arguments[0],t=arguments[1];return gye(e,t)},NF=Symbol.for("effect/SchemaId/Brand"),p8=(e,t)=>n=>MT(n,new Zd(n.ast,function(i,o,a){const c=e.either(i);return Gn(c)?oe(new Fn(a,i,c.left.map(f=>f.message).join(", "))):re()},Ql({schemaId:NF,[NF]:{constructor:e},...t})));class g8 extends Ot(hd){}class sE extends Ot(jJ){}class FT extends Ot(qJ){}class gb extends Ot(jv){}class WC extends Ot(KM){}class Nn extends Ot(GM){}class Y extends Ot(wk){}class it extends Ot(Ek){}class Fl extends Ot(kk){}const mye=e=>Jn.make(e.map(t=>t.ast));function m8(e,t=mye(e)){var n;return n=class extends Ot(t){static annotations(s){return m8(this.members,Vi(this.ast,s))}},p(n,"members",[...e]),n}function tt(...e){return JR(e)?m8(e):Kt(e)?e[0]:gb}const tl=e=>tt(e,FT),Ug=e=>tt(e,g8),yye=(e,t)=>new $m(e.map(n=>ji(n)?new Ul(n.ast,!1):n.ast),t.map(n=>ji(n)?new Rm(n.ast):n.ast),!0);function C0(e,t,n=yye(e,t)){var r;return r=class extends Ot(n){static annotations(i){return C0(this.elements,this.rest,Vi(this.ast,i))}},p(r,"elements",[...e]),p(r,"rest",[...t]),r}function y8(...e){return Array.isArray(e[0])?C0(e[0],e.slice(1)):C0(e,[])}function _8(e,t){var n;return n=class extends C0([],[e],t){static annotations(s){return _8(this.value,Vi(this.ast,s))}},p(n,"value",e),n}const Je=e=>_8(e),KC=e=>e?'"?:"':'":"';class mb extends Ul{constructor(n,r,s,i,o){super(n,r,i);p(this,"isReadonly");p(this,"defaultValue");p(this,"_tag","PropertySignatureDeclaration");this.isReadonly=s,this.defaultValue=o}toString(){const n=KC(this.isOptional),r=String(this.type);return`PropertySignature<${n}, ${r}, never, ${n}, ${r}>`}}class _ye extends Ul{constructor(n,r,s,i,o){super(n,r,i);p(this,"isReadonly");p(this,"fromKey");this.isReadonly=s,this.fromKey=o}}class x0 extends Ul{constructor(n,r,s,i,o){super(n,r,i);p(this,"isReadonly");p(this,"defaultValue");this.isReadonly=s,this.defaultValue=o}}const Sye=e=>e===void 0?"never":Jr(e)?JSON.stringify(e):String(e);class R0{constructor(t,n,r,s){p(this,"from");p(this,"to");p(this,"decode");p(this,"encode");p(this,"_tag","PropertySignatureTransformation");this.from=t,this.to=n,this.decode=r,this.encode=s}toString(){return`PropertySignature<${KC(this.to.isOptional)}, ${this.to.type}, ${Sye(this.from.fromKey)}, ${KC(this.from.isOptional)}, ${this.from.type}>`}}const S8=(e,t)=>{switch(e._tag){case"PropertySignatureDeclaration":return new mb(e.type,e.isOptional,e.isReadonly,{...e.annotations,...t},e.defaultValue);case"PropertySignatureTransformation":return new R0(e.from,new x0(e.to.type,e.to.isOptional,e.to.isReadonly,{...e.to.annotations,...t},e.to.defaultValue),e.decode,e.encode)}},v8=Symbol.for("effect/PropertySignature"),NT=e=>_e(e,v8);var Yke,Xke;const T2=class T2{constructor(t){p(this,"ast");p(this,Yke);p(this,Xke,null);p(this,"_TypeToken");p(this,"_Key");p(this,"_EncodedToken");p(this,"_HasDefault");this.ast=t}pipe(){return pe(this,arguments)}annotations(t){return new T2(S8(this.ast,Ql(t)))}toString(){return String(this.ast)}};Yke=zd,Xke=v8;let $0=T2;const I0=e=>new $0(e);class yb extends $0{constructor(n,r){super(n);p(this,"from");this.from=r}annotations(n){return new yb(S8(this.ast,Ql(n)),this.from)}}const w8=e=>new yb(new mb(e.ast,!1,!0,{},void 0),e),DT=x(2,(e,t)=>{const n=e.ast;switch(n._tag){case"PropertySignatureDeclaration":return I0(new mb(n.type,n.isOptional,n.isReadonly,n.annotations,t));case"PropertySignatureTransformation":return I0(new R0(n.from,new x0(n.to.type,n.to.isOptional,n.to.isReadonly,n.to.annotations,t),n.decode,n.encode))}}),DF=(e,t)=>bt(e,{onNone:()=>oe(t()),onSome:n=>oe(n===void 0?t():n)}),T0=e=>hY(e,T0,t=>{const n=T0(t.to);if(n)return new li(t.from,n,t.transformation)}),vye=x(2,(e,t)=>{const n=e.ast;switch(n._tag){case"PropertySignatureDeclaration":{const r=gn(n.type);return I0(new R0(new _ye(n.type,n.isOptional,n.isReadonly,n.annotations),new x0(T0(r)??r,!1,!0,{},n.defaultValue),s=>DF(s,t),Ce))}case"PropertySignatureTransformation":{const r=n.to.type;return I0(new R0(n.from,new x0(T0(r)??r,!1,n.to.isReadonly,n.to.annotations,n.to.defaultValue),s=>DF(n.decode(s),t),n.encode))}}}),b8=x(2,(e,t)=>e.pipe(vye(t.decoding),DT(t.constructor))),Qr=e=>{const t=e.ast===hd||e.ast===jv?hd:Ug(e).ast;return new yb(new mb(t,!0,!0,{},void 0),e)},wye=rL([GR]),bye=(e,t)=>{const n=go(e),r=[];if(n.length>0){const i=[],o=[],a=[];for(let c=0;c<n.length;c++){const f=n[c],d=e[f];if(NT(d)){const g=d.ast;switch(g._tag){case"PropertySignatureDeclaration":{const _=g.type,b=g.isOptional,k=g.annotations;i.push(new pn(f,_,b,!0,wye(g))),o.push(new pn(f,gn(_),b,!0,k)),r.push(new pn(f,_,b,!0,k));break}case"PropertySignatureTransformation":{const _=g.from.fromKey??f;i.push(new pn(_,g.from.type,g.from.isOptional,!0,g.from.annotations)),o.push(new pn(f,g.to.type,g.to.isOptional,!0,g.to.annotations)),a.push(new sY(_,f,g.decode,g.encode));break}}}else i.push(new pn(f,d.ast,!1,!0)),o.push(new pn(f,gn(d.ast),!1,!0)),r.push(new pn(f,d.ast,!1,!0))}if(Kt(a)){const c=[],f=[];for(const d of t){const{indexSignatures:g,propertySignatures:_}=FO(d.key.ast,d.value.ast);_.forEach(b=>{i.push(b),o.push(new pn(b.name,gn(b.type),b.isOptional,b.isReadonly,b.annotations))}),g.forEach(b=>{c.push(b),f.push(new Xd(b.parameter,gn(b.type),b.isReadonly))})}return new li(new fi(i,c,{[jf]:"Struct (Encoded side)"}),new fi(o,f,{[jf]:"Struct (Type side)"}),new NS(a))}}const s=[];for(const i of t){const{indexSignatures:o,propertySignatures:a}=FO(i.key.ast,i.value.ast);a.forEach(c=>r.push(c)),o.forEach(c=>s.push(c))}return new fi(r,s)},E8=(e,t)=>{const n=go(e);for(const r of n){const s=e[r];if(t[r]===void 0&&NT(s)){const i=s.ast,o=i._tag==="PropertySignatureDeclaration"?i.defaultValue:i.to.defaultValue;o!==void 0&&(t[r]=o())}}return t};function qT(e,t,n=bye(e,t)){var r;return r=class extends Ot(n){static annotations(i){return qT(this.fields,this.records,Vi(this.ast,i))}static pick(...i){return ke(aye(e,...i))}static omit(...i){return ke(lye(e,...i))}},p(r,"fields",{...e}),p(r,"records",[...t]),p(r,"make",(i,o)=>{const a=E8(e,{...i});return vb(o)?a:hb(r)(a)}),r}function ke(e,...t){return qT(e,t)}const Eye=e=>nt(e).pipe(w8,DT(()=>e)),Ye=(e,t)=>ke({_tag:Eye(e),...t});function k8(e,t,n){var r;return r=class extends qT({},[{key:e,value:t}],n){static annotations(i){return k8(e,t,Vi(this.ast,i))}},p(r,"key",e),p(r,"value",t),r}const my=e=>k8(e.key,e.value),P0=(...e)=>t=>Ot(Lo(t.ast,e)),jd=x(2,(e,t)=>{const n=xf(gn(e.ast),t),r=Ot(n.isOptional?A_(n.type):n.type);return Ws(e.pipe(P0(t)),r,{strict:!0,decode:i=>i[t],encode:i=>n.isOptional&&i===void 0?{}:{[t]:i}})});function MT(e,t){var n;return n=class extends Ot(t){static annotations(s){return MT(this.from,Vi(this.ast,s))}},p(n,"make",(s,i)=>vb(i)?s:hb(n)(s)),p(n,"from",e),n}const kye=(e,t)=>n=>{const r=bt(UM(n.ast),{onNone:()=>[e],onSome:i=>[...i,e]}),s=Zc(n.ast,Ql({[IM]:r,...t}));return MT(n,s)},Cye=e=>Ot(ap(e.ast)),C8=e=>Ot(sf(e.ast)),Jh=(e,t,n)=>{if(AO(e)&&AO(t)){const r=[...e.propertySignatures];for(const s of t.propertySignatures){const i=s.name,o=r.findIndex(a=>a.name===i);if(o===-1)r.push(s);else{const{isOptional:a,type:c}=r[o];r[o]=new pn(i,O0(c,s.type,n.concat(i)),a,!0)}}return new fi(r,e.indexSignatures.concat(t.indexSignatures))}throw new Error(RM(e,t,n))},xye=cY([QR]),Yh=(e,t)=>t.map(n=>new Zd(n,e.filter,xye(e))),O0=(e,t,n)=>Jn.make(zo([e],[t],n)),nc=e=>YR(e)?e.types:[e],zo=(e,t,n)=>PS(e,r=>PS(t,s=>{switch(s._tag){case"Literal":{if(Jr(s.literal)&&bk(r)||fa(s.literal)&&TO(r)||Kc(s.literal)&&PO(r))return[s];break}case"StringKeyword":{if(s===wk){if(bk(r)||Pp(r)&&Jr(r.literal))return[r];if(Uf(r))return Yh(r,zo(nc(r.from),[s],n))}else if(r===wk)return[s];break}case"NumberKeyword":{if(s===Ek){if(TO(r)||Pp(r)&&fa(r.literal))return[r];if(Uf(r))return Yh(r,zo(nc(r.from),[s],n))}else if(r===Ek)return[s];break}case"BooleanKeyword":{if(s===kk){if(PO(r)||Pp(r)&&Kc(r.literal))return[r];if(Uf(r))return Yh(r,zo(nc(r.from),[s],n))}else if(r===kk)return[s];break}case"Union":return zo(nc(r),s.types,n);case"Suspend":return[new Xc(()=>O0(r,s.f(),n))];case"Refinement":return Yh(s,zo(nc(r),nc(s.from),n));case"TypeLiteral":{switch(r._tag){case"Union":return zo(r.types,[s],n);case"Suspend":return[new Xc(()=>O0(r.f(),s,n))];case"Refinement":return Yh(r,zo(nc(r.from),[s],n));case"TypeLiteral":return[Jh(r,s,n)];case"Transformation":{const i=r.transformation,o=Jh(r.from,s,n),a=Jh(r.to,gn(s),n);switch(i._tag){case"TypeLiteralTransformation":return[new li(o,a,new NS(i.propertySignatureTransformations))];case"ComposeTransformation":return[new li(o,a,XR)];case"FinalTransformation":return[new li(o,a,new XM((c,f,d,g)=>Br(i.decode(c,f,d,g),_=>({...c,..._})),(c,f,d,g)=>Br(i.encode(c,f,d,g),_=>({...c,..._}))))]}}}break}case"Transformation":{if(tY(r)){if(Ck(s.transformation)&&Ck(r.transformation))return[new li(Jh(r.from,s.from,n),Jh(r.to,s.to,n),new NS(s.transformation.propertySignatureTransformations.concat(r.transformation.propertySignatureTransformations)))]}else return zo([s],[r],n);break}}throw new Error(RM(r,s,n))})),x8=x(2,(e,t)=>Ot(O0(e.ast,t.ast,[]))),Rye=x(e=>ji(e[1]),(e,t)=>LT(e,t,fY(e.ast,t.ast))),Hg=e=>Ot(new Xc(()=>e().ast)),R8=Symbol.for("effect/SchemaId/Refine");function $8(e,t,n){var r,s;return s=class extends Ot(n){static annotations(o){return $8(this.from,this.filter,Vi(this.ast,o))}},r=R8,p(s,r,e),p(s,"from",e),p(s,"filter",t),p(s,"make",(o,a)=>vb(a)?o:hb(s)(o)),s}const qF=(e,t,n)=>{if(Kc(e))return e?re():oe(new Fn(t,n));if(Jr(e))return oe(new Fn(t,n,e));if(e!==void 0){if("_tag"in e)return oe(e);const r=new Fn(t,n,e.message);return oe(Kt(e.path)?new Sr(e.path,n,r):r)}return re()},$ye=(e,t,n)=>{if(hJ(e))return qF(e,t,n);if(Kt(e)){const r=SM(e,s=>qF(s,t,n));if(Kt(r))return oe(r.length===1?r[0]:new En(t,n,r))}return re()};function _b(e,t){return n=>{function r(i,o,a){return $ye(e(i,o,a),a,i)}const s=new Zd(n.ast,r,Ql(t));return $8(n,r,s)}}function LT(e,t,n){var r;return r=class extends Ot(n){static annotations(i){return LT(this.from,this.to,Vi(this.ast,i))}},p(r,"from",e),p(r,"to",t),r}const Nl=x(e=>ji(e[0])&&ji(e[1]),(e,t,n)=>LT(e,t,new li(e.ast,t.ast,new XM(n.decode,n.encode)))),Ws=x(e=>ji(e[0])&&ji(e[1]),(e,t,n)=>Nl(e,t,{strict:!0,decode:(r,s,i,o)=>Ni(n.decode(r,o)),encode:(r,s,i,o)=>Ni(n.encode(r,o))})),Iye=x(2,(e,t)=>e.annotations(t)),MF=e=>e instanceof Error?e.message:String(e),Tye=e=>Nl(Y.annotations({description:"a string to be decoded into JSON"}),WC,{strict:!0,decode:(t,n,r)=>CF({try:()=>JSON.parse(t,e==null?void 0:e.reviver),catch:s=>new Fn(r,t,MF(s))}),encode:(t,n,r)=>CF({try:()=>JSON.stringify(t,e==null?void 0:e.replacer,e==null?void 0:e.space),catch:s=>new Fn(r,t,MF(s))})}).annotations({title:"parseJson",schemaId:DJ}),Bg=(e,t)=>ji(e)?Rye(Bg(t),e):Tye(e),Pye=vJ,Oye=(e,t)=>n=>n.pipe(_b(r=>r>=e,{schemaId:Pye,title:`greaterThanOrEqualTo(${e})`,description:e===0?"a non-negative number":`a number greater than or equal to ${e}`,jsonSchema:{minimum:e},...t})),Aye=wJ,Fye=e=>t=>t.pipe(_b(n=>Number.isSafeInteger(n),{schemaId:Aye,title:"int",description:"an integer",jsonSchema:{type:"integer"},...e})),Nye=bJ,Dye=(e,t,n)=>r=>r.pipe(_b(s=>s>=e&&s<=t,{schemaId:Nye,title:`between(${e}, ${t})`,description:`a number between ${e} and ${t}`,jsonSchema:{minimum:e,maximum:t},...n})),qye=e=>Oye(0,{title:"nonNegative",...e});class A0 extends it.pipe(Fye({identifier:"Int"})){}class Mye extends it.pipe(qye({identifier:"NonNegative"})){}const zT=(e,t,n,r)=>tme(e,{onFailure:s=>new En(n,r,s),onSuccess:t});class Lye extends Jl(n$,{identifier:"DurationFromSelf",pretty:()=>String,arbitrary:()=>t=>t.oneof(t.constant(_L),t.bigInt({min:0n}).map(n=>F_(n)),t.maxSafeNat().map(n=>nu(n))),equivalence:()=>wL}){}class zye extends Ws(Mye.annotations({description:"a non-negative number to be decoded into a Duration"}),Lye,{strict:!0,decode:t=>nu(t),encode:t=>ru(t)}).annotations({identifier:"DurationFromMillis"}){}class Sb extends Jl(jG,{identifier:"Uint8ArrayFromSelf",pretty:()=>t=>`new Uint8Array(${JSON.stringify(Array.from(t))})`,arbitrary:()=>t=>t.uint8Array(),equivalence:()=>Cm(Ne)}){}class jye extends it.pipe(Dye(0,255,{identifier:"Uint8",description:"a 8-bit unsigned integer"})){}class I8 extends Ws(Je(jye).annotations({description:"an array of 8-bit unsigned integers to be decoded into a Uint8Array"}),Sb,{strict:!0,decode:t=>Uint8Array.from(t),encode:t=>Array.from(t)}).annotations({identifier:"Uint8Array"}){}const Uye=(e,t,n)=>Nl(Y.annotations({description:"a string to be decoded into a Uint8Array"}),Sb,{strict:!0,decode:(r,s,i)=>km(t(r),o=>new Fn(i,r,o.message)),encode:r=>Ni(n(r))}).annotations({identifier:e}),Hye=Uye("Uint8ArrayFromBase64",kge,Ege),T8=e=>Ot(O_(e.ast));function Bye(e){return Ws(e,A8(T8(zi(e))),{strict:!1,decode:t=>zf(t),encode:t=>bt(t,{onNone:()=>[],onSome:$s})})}const pp=x(e=>ji(e[0]),(e,t)=>Nl(e,T8(zi(e)),{strict:!0,decode:(n,r,s)=>n.length>0?Ni(n[0]):t?Ni(t()):Al(new Fn(s,n,"Unable to retrieve the first element of an empty array")),encode:n=>Ni($s(n))})),LF=Symbol.for("effect/SchemaId/ValidDate"),Vye=e=>t=>t.pipe(_b(n=>!Number.isNaN(n.getTime()),{schemaId:LF,[LF]:{noInvalidDate:!0},title:"validDate",description:"a valid Date",...e})),zF=SJ;class P8 extends Jl(Lq,{identifier:"DateFromSelf",schemaId:zF,[zF]:{noInvalidDate:!1},description:"a potentially invalid Date instance",pretty:()=>t=>`new Date(${JSON.stringify(t)})`,arbitrary:()=>t=>t.date({noInvalidDate:!1}),equivalence:()=>FG}){}class Wye extends Ws(Y.annotations({description:"a string to be decoded into a Date"}),P8,{strict:!0,decode:t=>new Date(t),encode:t=>kM(t)}).annotations({identifier:"DateFromString"}){}class Kye extends Wye.pipe(Vye({identifier:"Date"})){}const Gye=ke({_tag:nt("None")}).annotations({description:"NoneEncoded"}),Qye=e=>ke({_tag:nt("Some"),value:e}).annotations({description:`SomeEncoded<${Oh(e)}>`}),Jye=e=>tt(Gye,Qye(e)).annotations({description:`OptionEncoded<${Oh(e)}>`}),O8=e=>e._tag==="None"?re():oe(e.value),Yye=(e,t)=>n=>n.oneof(t,n.record({_tag:n.constant("None")}),n.record({_tag:n.constant("Some"),value:e(n)})).map(O8),Xye=e=>bt({onNone:()=>"none()",onSome:t=>`some(${e(t)})`}),jF=e=>(t,n,r)=>xQ(t)?on(t)?Ni(re()):zT(e(t.value,n),oe,r,t):Al(new Fn(r,t)),A8=e=>Jl([e],{decode:t=>jF(Ph(t)),encode:t=>jF(qu(t))},{description:`Option<${Oh(e)}>`,pretty:Xye,arbitrary:Yye,equivalence:OQ}),Zye={_tag:"None"},e_e=e=>({_tag:"Some",value:e});function td(e){const t=e;return Ws(Jye(t),A8(zi(t)),{strict:!0,decode:r=>O8(r),encode:r=>bt(r,{onNone:()=>Zye,onSome:e_e})})}const t_e=(e,t)=>n=>{const r=n.array(e(n));return(t.depthIdentifier!==void 0?n.oneof(t,n.constant([]),r):r).map(s=>new Set(s))},n_e=e=>t=>`new Set([${Array.from(t.values()).map(n=>e(n)).join(", ")}])`,r_e=e=>{const t=Cm(e);return vm((n,r)=>t(Array.from(n.values()),Array.from(r.values())))},UF=e=>(t,n,r)=>qG(t)?zT(e(Array.from(t.values()),n),s=>new Set(s),r,t):Al(new Fn(r,t)),s_e=(e,t)=>Jl([e],{decode:n=>UF(Ph(Je(n))),encode:n=>UF(qu(Je(n)))},{description:t,pretty:n_e,arbitrary:t_e,equivalence:r_e}),i_e=e=>s_e(e,`ReadonlySet<${Oh(e)}>`);function jT(e){return Ws(Je(e),i_e(zi(e)),{strict:!0,decode:t=>new Set(t),encode:t=>Array.from(t)})}const o_e=e=>ji(e)||NT(e),F8=e=>go(e).every(t=>o_e(e[t])),UT=e=>"fields"in e?e.fields:UT(e[R8]),HT=e=>F8(e)?ke(e):ji(e)?e:ke(UT(e)),BT=e=>F8(e)?e:UT(e),Mu=e=>(t,n)=>nd({kind:"Class",identifier:e,schema:HT(t),fields:BT(t),Base:Rle,annotations:n}),N8=e=>DT(w8(nt(e)),()=>e),Oo=e=>(t,n,r)=>{class s extends $I{}s.prototype.name=t;const i=BT(n),o=HT(n),a={_tag:N8(t)},c=zp(a,i),f="message"in c;class d extends nd({kind:"TaggedError",identifier:e??t,schema:x8(o,ke(a)),fields:c,Base:s,annotations:r,disableToString:!0}){}return p(d,"_tag",t),f||Object.defineProperty(d.prototype,"message",{get(){return`{ ${go(i).map(g=>`${KR(g)}: ${ui(this[g])}`).join(", ")} }`},enumerable:!1,configurable:!0}),d},zp=(e,t)=>{const n={...e};for(const r of go(t)){if(r in e)throw new Error($M(r));n[r]=t[r]}return n};function vb(e){return Kc(e)?e:(e==null?void 0:e.disableValidation)??!1}const HF=We("effect/Schema/astCache",()=>new WeakMap),a_e=e=>e===void 0?[]:Array.isArray(e)?e:[e],nd=({Base:e,annotations:t,disableToString:n,fields:r,identifier:s,kind:i,schema:o})=>{var v,w;const a=Symbol.for(`effect/Schema/${i}/${s}`),[c,f,d]=a_e(t),g=zi(o),_=g.annotations({identifier:s,...c}),b=g.annotations({[jf]:`${s} (Type side)`,...c}),k=o.annotations({[jf]:`${s} (Constructor)`,...c}),I=o.annotations({[jf]:`${s} (Encoded side)`,...d}),E=o.annotations({[Lv]:s,...d,...c,...f}),y=$=>_e($,a)&&cr(b)($),m=(w=class extends e{constructor($={},P=!1){$={...$},i!=="Class"&&delete $._tag,$=E8(r,$),vb(P)||($=hb(k)($)),super($,!0)}static get ast(){let $=HF.get(this);if($)return $;const P=Jl([o],{decode:()=>(O,A,z)=>O instanceof this||y(O)?Ni(O):Al(new Fn(z,O)),encode:()=>(O,A)=>O instanceof this?Ni(O):Br(qu(b)(O,A),z=>new this(z,!0))},{identifier:s,pretty:O=>A=>`${s}(${O(A)})`,arbitrary:O=>A=>O(A).map(z=>new this(z)),equivalence:Ce,[AS]:_.ast,...c});return $=Ws(I,P,{strict:!0,decode:O=>new this(O,!0),encode:Ce}).annotations({[AS]:E.ast,...f}).ast,HF.set(this,$),$}static pipe(){return pe(this,arguments)}static annotations($){return Ot(this.ast).annotations($)}static toString(){return`(${String(I)} <-> ${s})`}static make(...$){return new this(...$)}static extend($){return(P,O)=>{const A=BT(P),z=HT(P),D=zp(r,A);return nd({kind:i,identifier:$,schema:x8(o,z),fields:D,Base:this,annotations:O})}}static transformOrFail($){return(P,O,A)=>{const z=zp(r,P);return nd({kind:i,identifier:$,schema:Nl(o,zi(ke(z)),O),fields:z,Base:this,annotations:A})}}static transformOrFailFrom($){return(P,O,A)=>{const z=zp(r,P);return nd({kind:i,identifier:$,schema:Nl(pb(o),ke(z),O),fields:z,Base:this,annotations:A})}}get[(v=zd,a)](){return a}},p(w,v,VC),p(w,"fields",{...r}),p(w,"identifier",s),w);return n!==!0&&Object.defineProperty(m.prototype,"toString",{value(){return`${s}({ ${go(r).map($=>`${KR($)}: ${ui(this[$])}`).join(", ")} })`},configurable:!0,writable:!0}),m},l_e=ke({_tag:nt("None")}).annotations({identifier:"FiberIdNoneEncoded"}),c_e=ke({_tag:nt("Runtime"),id:A0,startTimeMillis:A0}).annotations({identifier:"FiberIdRuntimeEncoded"}),u_e=ke({_tag:nt("Composite"),left:Hg(()=>GC),right:Hg(()=>GC)}).annotations({identifier:"FiberIdCompositeEncoded"}),GC=tt(l_e,c_e,u_e).annotations({identifier:"FiberIdEncoded"}),f_e=e=>e.letrec(t=>({None:e.record({_tag:e.constant("None")}),Runtime:e.record({_tag:e.constant("Runtime"),id:e.integer(),startTimeMillis:e.integer()}),Composite:e.record({_tag:e.constant("Composite"),left:t("FiberId"),right:t("FiberId")}),FiberId:e.oneof(t("None"),t("Runtime"),t("Composite"))})).FiberId.map(F0),QC=e=>{switch(e._tag){case"None":return"FiberId.none";case"Runtime":return`FiberId.runtime(${e.id}, ${e.startTimeMillis})`;case"Composite":return`FiberId.composite(${QC(e.right)}, ${QC(e.left)})`}},F0=e=>{switch(e._tag){case"None":return Nr;case"Runtime":return QX(e.id,e.startTimeMillis);case"Composite":return JX(F0(e.left),F0(e.right))}},d_e=e=>ke({_tag:nt("Die"),defect:e}),h_e=ke({_tag:nt("Empty")}),p_e=e=>ke({_tag:nt("Fail"),error:e}),g_e=ke({_tag:nt("Interrupt"),fiberId:GC});let m_e=0;const JC=(e,t)=>{const n=e,r=t,s=Hg(()=>i),i=tt(h_e,p_e(n),d_e(r),g_e,ke({_tag:nt("Sequential"),left:s,right:s}),ke({_tag:nt("Parallel"),left:s,right:s})).annotations({title:`CauseEncoded<${Oh(e)}>`,[Lv]:`CauseEncoded${m_e++}`});return i},y_e=(e,t)=>n=>n.letrec(r=>({Empty:n.record({_tag:n.constant("Empty")}),Fail:n.record({_tag:n.constant("Fail"),error:e(n)}),Die:n.record({_tag:n.constant("Die"),defect:t(n)}),Interrupt:n.record({_tag:n.constant("Interrupt"),fiberId:f_e(n)}),Sequential:n.record({_tag:n.constant("Sequential"),left:r("Cause"),right:r("Cause")}),Parallel:n.record({_tag:n.constant("Parallel"),left:r("Cause"),right:r("Cause")}),Cause:n.oneof(r("Empty"),r("Fail"),r("Die"),r("Interrupt"),r("Sequential"),r("Parallel"))})).Cause.map(Ec),__e=e=>t=>{const n=r=>{switch(r._tag){case"Empty":return"Cause.empty";case"Fail":return`Cause.fail(${e(r.error)})`;case"Die":return`Cause.die(${l0(r)})`;case"Interrupt":return`Cause.interrupt(${QC(r.fiberId)})`;case"Sequential":return`Cause.sequential(${n(r.left)}, ${n(r.right)})`;case"Parallel":return`Cause.parallel(${n(r.left)}, ${n(r.right)})`}};return n(t)},BF=e=>(t,n,r)=>Vae(t)?zT(e(Of(t),n),Ec,r,t):Al(new Fn(r,t)),S_e=({defect:e,error:t})=>Jl([t,e],{decode:(n,r)=>BF(Ph(JC(n,r))),encode:(n,r)=>BF(qu(JC(n,r)))},{title:`Cause<${t.ast}>`,pretty:__e,arbitrary:y_e});function Ec(e){switch(e._tag){case"Empty":return Uae;case"Fail":return gu(e.error);case"Die":return mu(e.defect);case"Interrupt":return qw(F0(e.fiberId));case"Sequential":return Bae(Ec(e.left),Ec(e.right));case"Parallel":return Hae(Ec(e.left),Ec(e.right))}}function Of(e){switch(e._tag){case"Empty":return{_tag:"Empty"};case"Fail":return{_tag:"Fail",error:e.error};case"Die":return{_tag:"Die",defect:e.defect};case"Interrupt":return{_tag:"Interrupt",fiberId:e.fiberId};case"Sequential":return{_tag:"Sequential",left:Of(e.left),right:Of(e.right)};case"Parallel":return{_tag:"Parallel",left:Of(e.left),right:Of(e.right)}}}const v_e=({defect:e,error:t})=>{const n=t,r=e;return Ws(JC(n,r),S_e({error:zi(n),defect:zi(r)}),{strict:!1,decode:i=>Ec(i),encode:i=>Of(i)})};class Vg extends Ws(WC,WC,{strict:!0,decode:t=>{if(xo(t)&&"message"in t&&typeof t.message=="string"){const n=new Error(t.message,{cause:t});return"name"in t&&typeof t.name=="string"&&(n.name=t.name),n.stack="stack"in t&&typeof t.stack=="string"?t.stack:"",n}return String(t)},encode:t=>t instanceof Error?{name:t.name,message:t.message}:cz(t)}).annotations({identifier:"Defect"}){}const D8=Symbol.for("effect/Schema/Serializable/symbol"),w_e=e=>PT(e[D8])(e),VT=Symbol.for("effect/Schema/Serializable/symbolResult"),VF=e=>e[VT].failure,WF=e=>e[VT].success,b_e=e=>(t,n,r)=>{var i;const s=zp({_tag:N8(t)},n.payload);return i=class extends nd({kind:"TaggedRequest",identifier:e??t,schema:ke(s),fields:s,Base:tue,annotations:r}){get[D8](){return this.constructor}get[VT](){return{failure:n.failure,success:n.success}}},p(i,"_tag",t),p(i,"success",n.success),p(i,"failure",n.failure),i},E_e=D6,k_e=Epe,C_e=xpe,x_e=Ipe,R_e=Tpe,Ui=Ope,q8=Ape,$_e=Fpe,Dl=lb,I_e=Dpe,T_e=j6,M8=U6,va=Lg,P_e=zpe,O_e=H6,Ta=zg,A_e=jpe,L8=Yge,F_e=Hpe,N_e=Wpe,D_e=Kpe,q_e=Qpe,Sn=Jpe,M_e=Xpe,WT=xT,N0=tge,Un=nge,L_e=sge,z_e=oge,z8=ub,j_e=uge,wb=dge,KF=Symbol.for("effect/Subscribable"),U_e=Lj,H_e="effect/SubscriptionRef",B_e=Symbol.for(H_e),V_e={_A:e=>e};var Zke,eCe,tCe,nCe,rCe;class W_e extends Io{constructor(n,r,s){super();p(this,"ref");p(this,"pubsub");p(this,"semaphore");p(this,Zke,xl);p(this,eCe,KF);p(this,tCe,nI);p(this,nCe,zj);p(this,rCe,V_e);p(this,"get");this.ref=n,this.pubsub=r,this.semaphore=s,this.get=Qf(this.ref)}commit(){return this.get}get changes(){return T(Qf(this.ref),we(n=>je(U6(this.pubsub,{scoped:!0}),r=>M6(H6(n),r))),this.semaphore.withPermits(1),ub)}modify(n){return this.modifyEffect(r=>Pt(n(r)))}modifyEffect(n){return T(Qf(this.ref),we(n),we(([r,s])=>T(Tg(this.ref,s),yo(r),BI(ZI(this.pubsub,s)))),this.semaphore.withPermits(1))}}Zke=xl,eCe=KF,tCe=zre,nCe=U_e,rCe=B_e;const K_e=e=>T(jw([wU(),Au(e),Ww(1)]),je(([t,n,r])=>new W_e(n,t,r))),G_e=x(2,(e,t)=>T(Tg(e.ref,t),BI(ZI(e.pubsub,t)),e.semaphore.withPermits(1))),Wg=K_e,uo=G_e,bb=Khe,Q_e=A6,KT=Ghe,J_e=Qhe,Y_e=e=>t=>Un(t,n=>Re(()=>e(n))),j8=e=>t=>A_e(t,n=>T(e(n),je(()=>n))),YC=()=>Q_e([]),kc=(e,t)=>J_e(e,n=>Dv(n,t)),XC=e=>KT(e,[]),GT=(e,t,n)=>d8(function*(){const r=yield*bb(e);if(r.length<t)return yield*oye;{const s=r.splice(0,Math.min(n,r.length));return yield*KT(e,r),s}}),X_e=e=>bb(e),Z_e=(e,t)=>d8(function*(){const n=yield*bb(e),[r,s]=_M(n,t);return yield*KT(e,s),r}),ZC=e=>bb(e).pipe(je(t=>t.length)),Kg=x(2,(e,t)=>T(e.changes,Ui(t),N0(1),q_e,je(Gv))),GF=Symbol.for("effect/Subscribable");var sCe,iCe;class eSe extends Io{constructor(n,r){super();p(this,"get");p(this,"changes");p(this,sCe,GF);p(this,iCe,xl);this.get=n,this.changes=r}commit(){return this.get}}sCe=GF,iCe=xl;const yy=e=>new eSe(e.get,e.changes);x(2,(e,t)=>yy({get:je(e.get,t),changes:Ta(e.changes,t)}));x(2,(e,t)=>yy({get:we(e.get,t),changes:L8(e.changes,t)}));yy({get:FI,changes:N_e});const tSe=e=>`${e.getHours().toString().padStart(2,"0")}:${e.getMinutes().toString().padStart(2,"0")}:${e.getSeconds().toString().padStart(2,"0")}.${e.getMilliseconds().toString().padStart(3,"0")}`,nSe=e=>Pme(Ame,Fme({formatDate:t=>`${tSe(t)} ${e}`})),ko=()=>typeof process<"u"&&process.env!==void 0||{BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}!==void 0?!1:!!(typeof globalThis<"u"&&globalThis.__DEV__),rSe=e=>{const t=e==null?void 0:e.toString();if(t!=="[object Object]")return t;try{return JSON.stringify(e,null,2)}catch(n){return console.log(e),"Error while printing error: "+n}},sSe=(e,t)=>{try{return new e(t)}catch{return e(t)}},ex=e=>e!==void 0&&e.toLowerCase()!=="false"&&e.toLowerCase()!=="0",ze=(e,...t)=>{if(console.error(e,...t),ko())debugger;throw new Error(`This should never happen: ${e}`)};var iSe=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},Cc="1.9.0",QF=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function oSe(e){var t=new Set([e]),n=new Set,r=e.match(QF);if(!r)return function(){return!1};var s={major:+r[1],minor:+r[2],patch:+r[3],prerelease:r[4]};if(s.prerelease!=null)return function(c){return c===e};function i(a){return n.add(a),!1}function o(a){return t.add(a),!0}return function(c){if(t.has(c))return!0;if(n.has(c))return!1;var f=c.match(QF);if(!f)return i(c);var d={major:+f[1],minor:+f[2],patch:+f[3],prerelease:f[4]};return d.prerelease!=null||s.major!==d.major?i(c):s.major===0?s.minor===d.minor&&s.patch<=d.patch?o(c):i(c):s.minor<=d.minor?o(c):i(c)}}var aSe=oSe(Cc),lSe=Cc.split(".")[0],Gg=Symbol.for("opentelemetry.js.api."+lSe),Qg=iSe;function QT(e,t,n,r){var s;r===void 0&&(r=!1);var i=Qg[Gg]=(s=Qg[Gg])!==null&&s!==void 0?s:{version:Cc};if(!r&&i[e]){var o=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return n.error(o.stack||o.message),!1}if(i.version!==Cc){var o=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+Cc);return n.error(o.stack||o.message),!1}return i[e]=t,n.debug("@opentelemetry/api: Registered a global for "+e+" v"+Cc+"."),!0}function Jg(e){var t,n,r=(t=Qg[Gg])===null||t===void 0?void 0:t.version;if(!(!r||!aSe(r)))return(n=Qg[Gg])===null||n===void 0?void 0:n[e]}function JT(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+Cc+".");var n=Qg[Gg];n&&delete n[e]}var cSe=globalThis&&globalThis.__read||function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},uSe=globalThis&&globalThis.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},fSe=function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Xh("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Xh("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Xh("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Xh("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Xh("verbose",this._namespace,t)},e}();function Xh(e,t,n){var r=Jg("diag");if(r)return n.unshift(t),r[e].apply(r,uSe([],cSe(n),!1))}var xs;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(xs||(xs={}));function dSe(e,t){e<xs.NONE?e=xs.NONE:e>xs.ALL&&(e=xs.ALL),t=t||{};function n(r,s){var i=t[r];return typeof i=="function"&&e>=s?i.bind(t):function(){}}return{error:n("error",xs.ERROR),warn:n("warn",xs.WARN),info:n("info",xs.INFO),debug:n("debug",xs.DEBUG),verbose:n("verbose",xs.VERBOSE)}}var hSe=globalThis&&globalThis.__read||function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},pSe=globalThis&&globalThis.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},gSe="diag",D0=function(){function e(){function t(s){return function(){for(var i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];var a=Jg("diag");if(a)return a[s].apply(a,pSe([],hSe(i),!1))}}var n=this,r=function(s,i){var o,a,c;if(i===void 0&&(i={logLevel:xs.INFO}),s===n){var f=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return n.error((o=f.stack)!==null&&o!==void 0?o:f.message),!1}typeof i=="number"&&(i={logLevel:i});var d=Jg("diag"),g=dSe((a=i.logLevel)!==null&&a!==void 0?a:xs.INFO,s);if(d&&!i.suppressOverrideMessage){var _=(c=new Error().stack)!==null&&c!==void 0?c:"<failed to generate stacktrace>";d.warn("Current logger will be overwritten from "+_),g.warn("Current logger will overwrite one already registered from "+_)}return QT("diag",g,n,!0)};n.setLogger=r,n.disable=function(){JT(gSe,n)},n.createComponentLogger=function(s){return new fSe(s)},n.verbose=t("verbose"),n.debug=t("debug"),n.info=t("info"),n.warn=t("warn"),n.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e}();function mSe(e){return Symbol.for(e)}var ySe=function(){function e(t){var n=this;n._currentContext=t?new Map(t):new Map,n.getValue=function(r){return n._currentContext.get(r)},n.setValue=function(r,s){var i=new e(n._currentContext);return i._currentContext.set(r,s),i},n.deleteValue=function(r){var s=new e(n._currentContext);return s._currentContext.delete(r),s}}return e}(),_Se=new ySe,SSe=globalThis&&globalThis.__read||function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},vSe=globalThis&&globalThis.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},wSe=function(){function e(){}return e.prototype.active=function(){return _Se},e.prototype.with=function(t,n,r){for(var s=[],i=3;i<arguments.length;i++)s[i-3]=arguments[i];return n.call.apply(n,vSe([r],SSe(s),!1))},e.prototype.bind=function(t,n){return n},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e}(),bSe=globalThis&&globalThis.__read||function(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),s,i=[],o;try{for(;(t===void 0||t-- >0)&&!(s=r.next()).done;)i.push(s.value)}catch(a){o={error:a}}finally{try{s&&!s.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return i},ESe=globalThis&&globalThis.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,i;r<s;r++)(i||!(r in t))&&(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))},iE="context",kSe=new wSe,YT=function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return QT(iE,t,D0.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,n,r){for(var s,i=[],o=3;o<arguments.length;o++)i[o-3]=arguments[o];return(s=this._getContextManager()).with.apply(s,ESe([t,n,r],bSe(i),!1))},e.prototype.bind=function(t,n){return this._getContextManager().bind(t,n)},e.prototype._getContextManager=function(){return Jg(iE)||kSe},e.prototype.disable=function(){this._getContextManager().disable(),JT(iE,D0.instance())},e}(),ql;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(ql||(ql={}));var U8="0000000000000000",H8="00000000000000000000000000000000",CSe={traceId:H8,spanId:U8,traceFlags:ql.NONE},jp=function(){function e(t){t===void 0&&(t=CSe),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,n){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,n){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,n){},e}(),XT=mSe("OpenTelemetry Context Key SPAN");function ZT(e){return e.getValue(XT)||void 0}function xSe(){return ZT(YT.getInstance().active())}function e2(e,t){return e.setValue(XT,t)}function RSe(e){return e.deleteValue(XT)}function $Se(e,t){return e2(e,new jp(t))}function B8(e){var t;return(t=ZT(e))===null||t===void 0?void 0:t.spanContext()}var ISe=/^([0-9a-f]{32})$/i,TSe=/^[0-9a-f]{16}$/i;function PSe(e){return ISe.test(e)&&e!==H8}function OSe(e){return TSe.test(e)&&e!==U8}function V8(e){return PSe(e.traceId)&&OSe(e.spanId)}function ASe(e){return new jp(e)}var oE=YT.getInstance(),W8=function(){function e(){}return e.prototype.startSpan=function(t,n,r){r===void 0&&(r=oE.active());var s=!!(n!=null&&n.root);if(s)return new jp;var i=r&&B8(r);return FSe(i)&&V8(i)?new jp(i):new jp},e.prototype.startActiveSpan=function(t,n,r,s){var i,o,a;if(!(arguments.length<2)){arguments.length===2?a=n:arguments.length===3?(i=n,a=r):(i=n,o=r,a=s);var c=o??oE.active(),f=this.startSpan(t,i,c),d=e2(c,f);return oE.with(d,a,void 0,f)}},e}();function FSe(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var NSe=new W8,DSe=function(){function e(t,n,r,s){this._provider=t,this.name=n,this.version=r,this.options=s}return e.prototype.startSpan=function(t,n,r){return this._getTracer().startSpan(t,n,r)},e.prototype.startActiveSpan=function(t,n,r,s){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):NSe},e}(),qSe=function(){function e(){}return e.prototype.getTracer=function(t,n,r){return new W8},e}(),MSe=new qSe,JF=function(){function e(){}return e.prototype.getTracer=function(t,n,r){var s;return(s=this.getDelegateTracer(t,n,r))!==null&&s!==void 0?s:new DSe(this,t,n,r)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:MSe},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,n,r){var s;return(s=this._delegate)===null||s===void 0?void 0:s.getTracer(t,n,r)},e}(),hc;(function(e){e[e.INTERNAL=0]="INTERNAL",e[e.SERVER=1]="SERVER",e[e.CLIENT=2]="CLIENT",e[e.PRODUCER=3]="PRODUCER",e[e.CONSUMER=4]="CONSUMER"})(hc||(hc={}));var nl;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(nl||(nl={}));var tx="[_0-9a-z-*/]",LSe="[a-z]"+tx+"{0,255}",zSe="[a-z0-9]"+tx+"{0,240}@[a-z]"+tx+"{0,13}",jSe=new RegExp("^(?:"+LSe+"|"+zSe+")$"),USe=/^[ -~]{0,255}[!-~]$/,HSe=/,|=/;function BSe(e){return jSe.test(e)}function VSe(e){return USe.test(e)&&!HSe.test(e)}var YF=32,WSe=512,XF=",",ZF="=",KSe=function(){function e(t){this._internalState=new Map,t&&this._parse(t)}return e.prototype.set=function(t,n){var r=this._clone();return r._internalState.has(t)&&r._internalState.delete(t),r._internalState.set(t,n),r},e.prototype.unset=function(t){var n=this._clone();return n._internalState.delete(t),n},e.prototype.get=function(t){return this._internalState.get(t)},e.prototype.serialize=function(){var t=this;return this._keys().reduce(function(n,r){return n.push(r+ZF+t.get(r)),n},[]).join(XF)},e.prototype._parse=function(t){t.length>WSe||(this._internalState=t.split(XF).reverse().reduce(function(n,r){var s=r.trim(),i=s.indexOf(ZF);if(i!==-1){var o=s.slice(0,i),a=s.slice(i+1,r.length);BSe(o)&&VSe(a)&&n.set(o,a)}return n},new Map),this._internalState.size>YF&&(this._internalState=new Map(Array.from(this._internalState.entries()).reverse().slice(0,YF))))},e.prototype._keys=function(){return Array.from(this._internalState.keys()).reverse()},e.prototype._clone=function(){var t=new e;return t._internalState=new Map(this._internalState),t},e}();function GSe(e){return new KSe(e)}var Xs=YT.getInstance(),aE="trace",QSe=function(){function e(){this._proxyTracerProvider=new JF,this.wrapSpanContext=ASe,this.isSpanContextValid=V8,this.deleteSpan=RSe,this.getSpan=ZT,this.getActiveSpan=xSe,this.getSpanContext=B8,this.setSpan=e2,this.setSpanContext=$Se}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var n=QT(aE,this._proxyTracerProvider,D0.instance());return n&&this._proxyTracerProvider.setDelegate(t),n},e.prototype.getTracerProvider=function(){return Jg(aE)||this._proxyTracerProvider},e.prototype.getTracer=function(t,n){return this.getTracerProvider().getTracer(t,n)},e.prototype.disable=function(){JT(aE,D0.instance()),this._proxyTracerProvider=new JF},e}(),ss=QSe.getInstance();const eN=1000000000n,lE=e=>[Number(e/eN),Number(e%eN)],cE=e=>Object.entries(e).reduce((t,[n,r])=>(t[n]=K8(r),t),{}),K8=e=>typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:typeof e=="bigint"?Number(e):Gc(e),K_=Symbol.for("@effect/opentelemetry/Tracer/OtelSpan"),JSe={internal:hc.INTERNAL,client:hc.CLIENT,server:hc.SERVER,producer:hc.PRODUCER,consumer:hc.CONSUMER};var oCe;class G8{constructor(t,n,r,s,i,o,a,c){p(this,"name");p(this,"parent");p(this,"context");p(this,"links");p(this,"kind");p(this,oCe);p(this,"_tag","Span");p(this,"span");p(this,"spanId");p(this,"traceId");p(this,"attributes",new Map);p(this,"sampled");p(this,"status");this.name=r,this.parent=s,this.context=i,this.links=o,this.kind=c,this[K_]=K_;const f=t.active();this.span=n.startSpan(r,{startTime:lE(a),links:o.length>0?o.map(g=>({context:rx(g.span),attributes:cE(g.attributes)})):void 0,kind:JSe[this.kind]},s._tag==="Some"?J8(f,s.value,i):ss.deleteSpan(f));const d=this.span.spanContext();this.spanId=d.spanId,this.traceId=d.traceId,this.status={_tag:"Started",startTime:a},this.sampled=(d.traceFlags&ql.SAMPLED)===ql.SAMPLED}attribute(t,n){this.span.setAttribute(t,K8(n)),this.attributes.set(t,n)}addLinks(t){this.links.push(...t),this.span.addLinks(t.map(n=>({context:rx(n.span),attributes:cE(n.attributes)})))}end(t,n){const r=lE(t);if(this.status={_tag:"Ended",endTime:t,exit:n,startTime:this.status.startTime},n._tag==="Success")this.span.setStatus({code:nl.OK});else if(ml(n.cause))this.span.setStatus({code:nl.OK,message:l0(n.cause)}),this.span.setAttribute("span.label","⚠︎ Interrupted"),this.span.setAttribute("status.interrupted",!0);else{const s=Jae(n.cause)[0];s?(s.stack=l0(n.cause,{renderErrorCause:!0}),this.span.recordException(s,r),this.span.setStatus({code:nl.ERROR,message:s.message})):this.span.setStatus({code:nl.OK})}this.span.end(r)}event(t,n,r){this.span.addEvent(t,r?cE(r):void 0,lE(n))}}oCe=K_;const Q8=Mr("@effect/opentelemetry/Tracer/OtelTracer"),YSe=je(Q8,e=>n4({span(t,n,r,s,i,o){return new G8(Xs,e,t,n,r,s.slice(),i,o)},context(t,n){const r=n.currentSpan;return r===void 0?t():Xs.with(J8(Xs.active(),r),t)}})),nx=Mr("@effect/opentelemetry/Tracer/OtelTraceFlags"),q0=Mr("@effect/opentelemetry/Tracer/OtelTraceState"),XSe=e=>{let t=tu();return e.traceFlags&&(t=$i(t,nx,e.traceFlags)),typeof e.traceState=="string"?t=bt(e0e(e.traceState),{onNone:()=>t,onSome:n=>$i(t,q0,n)}):e.traceState&&(t=$i(t,q0,e.traceState)),{_tag:"ExternalSpan",traceId:e.traceId,spanId:e.spanId,sampled:e.traceFlags?(e.traceFlags&ql.SAMPLED)===ql.SAMPLED:!0,context:t}},ZSe=we(Gw,e=>K_ in e?Pt(e.span):zs(new Lw)),e0e=cM(GSe),J8=(e,t,n)=>t instanceof G8?ss.setSpan(e,t.span):ss.setSpanContext(e,rx(t,n)),rx=(e,t)=>({spanId:e.spanId,traceId:e.traceId,isRemote:e._tag==="ExternalSpan",traceFlags:Yt(t?tN(e,t,nx):Ms(e.context,nx),()=>ql.SAMPLED),traceState:ti(t?tN(e,t,q0):Ms(e.context,q0))}),tN=(e,t,n)=>Xo(Ms(t,n),()=>Ms(e.context,n)),t0e=YSe,n0e=XSe,_y=ZSe,Y8=Q8,u_=(e,t,n=" ")=>e.split(`
206
+ `).map(r=>n.repeat(t)+r).join(`
207
+ `),X8=e=>e!==void 0,r0e=e=>e==null,nN=()=>{const e=performance.now(),t={_performanceStartTime:e,setAttribute:()=>null,setAttributes:()=>null,addEvent:()=>null,setStatus:()=>null,updateName:()=>null,recordException:()=>null,end:()=>{const r=performance.now()-e,s=r/1e3,i=r%1e3*1e6;t._duration=[s,i]},spanContext:()=>({traceId:"livestore-noop-trace-id",spanId:"livestore-noop-span-id"}),_duration:[0,0]};return t},s0e=()=>new i0e;class i0e{constructor(){p(this,"startSpan",()=>nN())}startActiveSpan(t,n,r,s){let i;if(!(arguments.length<2))return arguments.length===2?i=n:arguments.length===3?i=r:i=s,i(nN())}}const Yg=e=>{if(typeof process<"u"&&process.env!==void 0)return process.env[e];if({BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}!==void 0)return{BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}[e]},as=Yg("LS_TRACE_VERBOSE")!==void 0||Yg("VITE_LS_TRACE_VERBOSE")!==void 0,js=ex(Yg("LS_DEV"))||ex(Yg("VITE_LS_DEV"));ex(Yg("CI"));const Up=(e,t)=>{if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var n,r,s;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(!Up(e[r],t[r]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;for(r of e.entries())if(!Up(r[1],t.get(r[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(r of e.entries())if(!t.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(r=n;r--!==0;)if(e[r]!==t[r])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==void 0&&e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==void 0&&e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!Object.prototype.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){var i=s[r];if(!Up(e[i],t[i]))return!1}return!0}return e!==e&&t!==t},Z8=e=>Array.isArray(e);function wa(e){debugger;throw new Error(`A case was not handled for value: ${o0e(rSe(e),1e3)}`)}const rN=(e,t)=>{if(e===!1){debugger;throw new Error(`This should never happen: ${t}`)}},o0e=(e,t)=>e.length>t?e.slice(0,t)+"...":e,sN=e=>{debugger;throw new Error(`Not yet implemented: ${e}`)},iN=(e,t)=>{let n=!1,r=!1;const s=()=>{r?(e(),r=!1,setTimeout(s,t)):n=!1};return()=>{if(n){r=!0;return}e(),n=!0,setTimeout(s,t)}},a0e=e=>{const t=new Map;return(...n)=>{const r=JSON.stringify(n);if(t.has(r))return t.get(r);const s=e(...n);return t.set(r,s),s}},eH=e=>{const t=new Map;return n=>{if(t.has(n))return t.get(n);const r=e(n);return t.set(n,r),r}},l0e=e=>typeof(e==null?void 0:e.then)=="function",Lu=e=>X(function*(){const t=yield*ty();return yield*pr(n=>Ln(t,n)),yield*e(t).pipe(ey(t))}),gp=e=>Kl(()=>e()).pipe(d0(t=>$a(t)?t:l0e(t)?Fd(()=>t):Pt(t))),c0e=(...e)=>pr(()=>HI(...e)),st=e=>Sh(e,t=>X(function*(){if(ml(t))return;const n=yield*_y.pipe(_h("NoSuchElementException",s=>Pt(void 0))),r=t.toString().split(`
208
+ `)[0];yield*Dd(r,t).pipe(s=>n===void 0?s:yl({spanId:n.spanContext().spanId,traceId:n.spanContext().traceId})(s))})),ii=(e,t)=>mue(HI(e).pipe(yl(t??{})),Rue,()=>nw(Nme)),u0e=({label:e,duration:t})=>n=>X(function*(){const r=yield*To();let s=!1;const i=Bw(t).pipe(kr(()=>(s=!0,Ps(`${e}: Took longer than ${t}ms`))),Hn(r),Po),o=Date.now(),a=yield*n.pipe($n,oU(ay(function*(){const c=Date.now();yield*Fs(i),s&&(yield*Ps(`${e}: Interrupted after ${c-o}ms`))})));if(s){const c=Date.now();yield*Ps(`${e}: Actual duration: ${c-o}ms`)}return yield*Fs(i),yield*a}),f0e=e=>t=>kr(t,n=>Re(()=>e(n))),t2=e=>t=>DI(Re(()=>performance.mark(`${e}:start`)),()=>t,()=>Re(()=>{performance.mark(`${e}:end`),performance.measure(e,`${e}:start`,`${e}:end`)})),tH=()=>{const e=_ce();return e._tag==="None"||e.value.currentSpan===void 0?"No current fiber":""},d0e=()=>console.log(tH());globalThis.getSpanTrace=tH;globalThis.logSpanTrace=d0e;const nH=(e,t)=>{class n extends $I{constructor(){super(...arguments);p(this,"_tag",t)}}return n.prototype[e]=e,n.prototype.name=t,n},oN=Symbol.for("@effect/platform/Cookies"),aN=Symbol.for("@effect/platform/Cookies/Cookie"),h0e={[oN]:oN,...Av,toJSON(){return{_id:"@effect/platform/Cookies",cookies:BQ(this.cookies,e=>e.toJSON())}},pipe(){return pe(this,arguments)}},p0e=e=>{const t=Object.create(h0e);return t.cookies=e,t},g0e=e=>{const t={};for(const n of e)t[n.name]=n;return p0e(t)},m0e=e=>{const t=typeof e=="string"?[e]:e,n=[];for(const r of t){const s=y0e(r.trim());Wt(s)&&n.push(s.value)}return g0e(n)};function y0e(e){const t=e.split(";").map(a=>a.trim()).filter(a=>a!=="");if(t.length===0)return re();const n=t[0].indexOf("=");if(n===-1)return re();const r=t[0].slice(0,n);if(!_0e.test(r))return re();const s=t[0].slice(n+1),i=S0e(s);if(t.length===1)return oe(Object.assign(Object.create(lN),{name:r,value:i,valueEncoded:s}));const o={};for(let a=1;a<t.length;a++){const c=t[a],f=c.indexOf("="),d=f===-1?c:c.slice(0,f).trim(),g=f===-1?void 0:c.slice(f+1).trim();switch(d.toLowerCase()){case"domain":{if(g===void 0)break;const _=g.trim().replace(/^\./,"");_&&(o.domain=_);break}case"expires":{if(g===void 0)break;const _=new Date(g);isNaN(_.getTime())||(o.expires=_);break}case"max-age":{if(g===void 0)break;const _=parseInt(g,10);isNaN(_)||(o.maxAge=r$(_));break}case"path":{if(g===void 0)break;g[0]==="/"&&(o.path=g);break}case"priority":{if(g===void 0)break;switch(g.toLowerCase()){case"low":o.priority="low";break;case"medium":o.priority="medium";break;case"high":o.priority="high";break}break}case"httponly":{o.httpOnly=!0;break}case"secure":{o.secure=!0;break}case"partitioned":{o.partitioned=!0;break}case"samesite":{if(g===void 0)break;switch(g.toLowerCase()){case"lax":o.sameSite="lax";break;case"strict":o.sameSite="strict";break;case"none":o.sameSite="none";break}break}}}return oe(Object.assign(Object.create(lN),{name:r,value:i,valueEncoded:s,options:Object.keys(o).length>0?o:void 0}))}const _0e=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,lN={[aN]:aN,...Av,toJSON(){return{_id:"@effect/platform/Cookies/Cookie",name:this.name,value:this.value,options:this.options}}},S0e=e=>{try{return decodeURIComponent(e)}catch{return e}},cN=Symbol.for("@effect/platform/Headers"),Xg=Object.assign(Object.create(null),{[cN]:cN,[Fv](e){return ix(this,xw(e,sH))}}),Eb=e=>Object.assign(Object.create(Xg),e),rH=Object.create(Xg),n2=e=>{if(e===void 0)return rH;if(Symbol.iterator in e){const n=Object.create(Xg);for(const[r,s]of e)n[r.toLowerCase()]=s;return n}const t=Object.create(Xg);for(const[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(", "):r!==void 0&&(t[n.toLowerCase()]=r);return t},v0e=e=>Object.setPrototypeOf(e,Xg),sx=x(3,(e,t,n)=>{const r=Eb(e);return r[t.toLowerCase()]=n,r}),w0e=x(2,(e,t)=>Eb({...e,...n2(t)})),b0e=x(2,(e,t)=>{const n=Eb(e);return Object.assign(n,t),n}),E0e=x(2,(e,t)=>{const n=Eb(e),r=s=>{if(typeof s=="string"){const i=s.toLowerCase();i in e&&delete n[i]}else for(const i in e)s.test(i)&&delete n[i]};if(Array.isArray(t))for(let s=0;s<t.length;s++)r(t[s]);else r(t);return n}),ix=x(2,(e,t)=>{const n={...e},r=s=>{if(typeof s=="string"){const i=s.toLowerCase();i in e&&(n[i]=AF(e[i]))}else for(const i in e)s.test(i)&&(n[i]=AF(e[i]))};if(Array.isArray(t))for(let s=0;s<t.length;s++)r(t[s]);else r(t);return n}),sH=We("@effect/platform/Headers/currentRedactedNames",()=>VI(["authorization","cookie","set-cookie","x-api-key"])),k0e=Symbol.for("@effect/platform/HttpClientError"),iH=k0e;class oH extends nH(iH,"RequestError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return this.description?`${this.reason}: ${this.description} (${this.methodAndUrl})`:`${this.reason} error (${this.methodAndUrl})`}}class rc extends nH(iH,"ResponseError"){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){const t=`${this.response.status} ${this.methodAndUrl}`;return this.description?`${this.reason}: ${this.description} (${t})`:`${this.reason} error (${t})`}}const r2=e=>{const t=aH(e),n=[];for(let r=0;r<t.length;r++)if(Array.isArray(t[r][0])){const[s,i]=t[r];n.push([`${s[0]}[${s.slice(1).join("][")}]`,i])}else n.push(t[r]);return n},aH=e=>{const t=Symbol.iterator in e?gt(e):Object.entries(e),n=[];for(const[r,s]of t)if(Array.isArray(s))for(let i=0;i<s.length;i++)s[i]!==void 0&&n.push([r,String(s[i])]);else if(typeof s=="object"){const i=aH(s);for(const[o,a]of i)n.push([[r,...typeof o=="string"?[o]:o],a])}else s!==void 0&&n.push([r,String(s)]);return n},C0e=[],x0e=x(2,(e,t)=>{const n=r2(t),r=n.map(([s])=>s);return Dv(vM(e,([s])=>r.includes(s)),n)}),R0e=(e,t,n)=>{try{const r=new URL(e,$0e());for(let s=0;s<t.length;s++){const[i,o]=t[s];o!==void 0&&r.searchParams.append(i,o)}return n._tag==="Some"&&(r.hash=n.value),Pe(r)}catch(r){return $e(r)}},$0e=()=>{if("location"in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},Hp=Symbol.for("@effect/platform/HttpIncomingMessage"),I0e=(e,t)=>{const n=e.headers["content-type"]??"";let r;if(n.includes("application/json"))try{r=ur(e.json)}catch{}else if(n.includes("text/")||n.includes("urlencoded"))try{r=ur(e.text)}catch{}const s={...t,headers:Qc(e.headers),remoteAddress:e.remoteAddress.toJSON()};return r!==void 0&&(s.body=r),s},T0e=e=>v0e({b3:`${e.traceId}-${e.spanId}-${e.sampled?"1":"0"}${e.parent._tag==="Some"?`-${e.parent.value.spanId}`:""}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?"01":"00"}`}),uE=Symbol.for("@effect/platform/HttpBody");var aCe;class P0e{constructor(){p(this,aCe);this[uE]=uE}[(aCe=uE,ft)](){return this.toJSON()}toString(){return qt(this)}}class O0e extends P0e{constructor(){super(...arguments);p(this,"_tag","Empty")}toJSON(){return{_id:"@effect/platform/HttpBody",_tag:"Empty"}}}const A0e=new O0e,uN=Symbol.for("@effect/platform/HttpClientRequest"),F0e={[uN]:uN,...Av,toJSON(){return{_id:"@effect/platform/HttpClientRequest",method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Qc(this.headers),body:this.body.toJSON()}},pipe(){return pe(this,arguments)}};function ba(e,t,n,r,s,i){const o=Object.create(F0e);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=s,o.body=i,o}const N0e=ba("GET","",C0e,re(),rH,A0e),zu=e=>(t,n)=>H0e(N0e,{method:e,url:t,...n??void 0}),D0e=zu("GET"),q0e=zu("POST"),M0e=zu("PUT"),L0e=zu("PATCH"),z0e=zu("DELETE"),j0e=zu("HEAD"),U0e=zu("OPTIONS"),H0e=x(2,(e,t)=>{let n=e;return t.method&&(n=W0e(n,t.method)),t.url&&(n=K0e(n,t.url)),t.headers&&(n=lH(n,t.headers)),t.urlParams&&(n=G0e(n,t.urlParams)),t.hash&&(n=Q0e(n,t.hash)),t.body&&(n=J0e(n,t.body)),t.accept&&(n=cH(n,t.accept)),t.acceptJson&&(n=V0e(n)),n}),B0e=x(3,(e,t,n)=>ba(e.method,e.url,e.urlParams,e.hash,sx(e.headers,t,n),e.body)),lH=x(2,(e,t)=>ba(e.method,e.url,e.urlParams,e.hash,w0e(e.headers,t),e.body)),cH=x(2,(e,t)=>B0e(e,"Accept",t)),V0e=cH("application/json"),W0e=x(2,(e,t)=>ba(t,e.url,e.urlParams,e.hash,e.headers,e.body)),K0e=x(2,(e,t)=>{if(typeof t=="string")return ba(e.method,t,e.urlParams,e.hash,e.headers,e.body);const n=new URL(t.toString()),r=r2(n.searchParams),s=n.hash?oe(n.hash.slice(1)):re();return n.search="",n.hash="",ba(e.method,n.toString(),r,s,e.headers,e.body)}),G0e=x(2,(e,t)=>ba(e.method,e.url,x0e(e.urlParams,t),e.hash,e.headers,e.body)),Q0e=x(2,(e,t)=>ba(e.method,e.url,e.urlParams,oe(t),e.headers,e.body)),J0e=x(2,(e,t)=>{let n=e.headers;if(t._tag==="Empty"||t._tag==="FormData")n=E0e(n,["Content-type","Content-length"]);else{const r=t.contentType;r&&(n=sx(n,"content-type",r));const s=t.contentLength;s&&(n=sx(n,"content-length",s.toString()))}return ba(e.method,e.url,e.urlParams,e.hash,n,t)}),Bp=Symbol.for("@effect/platform/HttpClientResponse"),Y0e=(e,t)=>new X0e(e,t);var lCe,cCe;class X0e extends Wq{constructor(n,r){super();p(this,"request");p(this,"source");p(this,lCe);p(this,cCe);p(this,"cachedCookies");p(this,"textBody");p(this,"formDataBody");p(this,"arrayBufferBody");this.request=n,this.source=r,this[Hp]=Hp,this[Bp]=Bp}toJSON(){return I0e(this,{_id:"@effect/platform/HttpClientResponse",request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get headers(){return n2(this.source.headers)}get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=m0e(this.source.headers.getSetCookie())}get remoteAddress(){return re()}get stream(){return this.source.body?P_e(()=>this.source.body,n=>new rc({request:this.request,response:this,reason:"Decode",cause:n})):R_e(new rc({request:this.request,response:this,reason:"EmptyBody",description:"can not create stream from empty body"}))}get json(){return aue(this.text,{try:n=>n===""?null:JSON.parse(n),catch:n=>new rc({request:this.request,response:this,reason:"Decode",cause:n})})}get text(){return this.textBody??(this.textBody=Fp({try:()=>this.source.text(),catch:n=>new rc({request:this.request,response:this,reason:"Decode",cause:n})}).pipe(M1,ur))}get urlParamsBody(){return we(this.text,n=>Kl({try:()=>r2(new URLSearchParams(n)),catch:r=>new rc({request:this.request,response:this,reason:"Decode",cause:r})}))}get formData(){return this.formDataBody??(this.formDataBody=Fp({try:()=>this.source.formData(),catch:n=>new rc({request:this.request,response:this,reason:"Decode",cause:n})}).pipe(M1,ur))}get arrayBuffer(){return this.arrayBufferBody??(this.arrayBufferBody=Fp({try:()=>this.source.arrayBuffer(),catch:n=>new rc({request:this.request,response:this,reason:"Decode",cause:n})}).pipe(M1,ur))}}lCe=Hp,cCe=Bp;const fN=Symbol.for("@effect/platform/HttpClient"),Z0e=Mr("@effect/platform/HttpClient"),eve=We(Symbol.for("@effect/platform/HttpClient/tracerDisabledWhen"),()=>VI(ds)),tve=We(Symbol.for("@effect/platform/HttpClient/currentTracerPropagation"),()=>VI(!0)),nve=Im()("@effect/platform/HttpClient/SpanNameGenerator",{defaultValue:()=>e=>`http.client ${e.method}`}),rve={[fN]:fN,pipe(){return pe(this,arguments)},...Av,toJSON(){return{_id:"@effect/platform/HttpClient"}},get(e,t){return this.execute(D0e(e,t))},head(e,t){return this.execute(j0e(e,t))},post(e,t){return this.execute(q0e(e,t))},put(e,t){return this.execute(M0e(e,t))},patch(e,t){return this.execute(L0e(e,t))},del(e,t){return this.execute(z0e(e,t))},options(e,t){return this.execute(U0e(e,t))}},uH=(e,t)=>{const n=Object.create(rve);return n.preprocess=t,n.postprocess=e,n.execute=function(r){return e(t(r))},n},M0=We("@effect/platform/HttpClient/responseRegistry",()=>{if("FinalizationRegistry"in globalThis&&globalThis.FinalizationRegistry){const t=new FinalizationRegistry(n=>{n.abort()});return{register(n,r){t.register(n,r,n)},unregister(n){t.unregister(n)}}}const e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){const n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}}),sve=We("@effect/platform/HttpClient/scopedRequests",()=>new WeakMap),ive=e=>uH(t=>we(t,n=>_a(r=>{const s=sve.get(n),i=s??new AbortController,o=R0e(n.url,n.urlParams,n.hash);if(o._tag==="Left")return zs(new oH({request:n,reason:"InvalidUrl",cause:o.left}));const a=o.right;if(!r.getFiberRef($ue)||r.getFiberRef(eve)(n)){const d=e(n,a,i.signal,r);return s?d:Tl(g=>si(g(d),{onSuccess(_){return M0.register(_,i),Pt(new dN(_,i))},onFailure(_){return a0(_)&&i.abort(),ps(_)}}))}const f=hs(r.currentContext,nve);return Eue(f(n),{kind:"client",captureStackTrace:!1},d=>{d.attribute("http.request.method",n.method),d.attribute("server.address",a.origin),a.port!==""&&d.attribute("server.port",+a.port),d.attribute("url.full",a.toString()),d.attribute("url.path",a.pathname),d.attribute("url.scheme",a.protocol.slice(0,-1));const g=a.search.slice(1);g!==""&&d.attribute("url.query",g);const _=r.getFiberRef(sH),b=ix(n.headers,_);for(const k in b)d.attribute(`http.request.header.${k}`,String(b[k]));return n=r.getFiberRef(tve)?lH(n,T0e(d)):n,Tl(k=>k(e(n,a,i.signal,r)).pipe(vc(d),si({onSuccess:I=>{d.attribute("http.response.status_code",I.status);const E=ix(I.headers,_);for(const y in E)d.attribute(`http.response.header.${y}`,String(E[y]));return s?Pt(I):(M0.register(I,i),Pt(new dN(I,i)))},onFailure(I){return!s&&a0(I)&&i.abort(),ps(I)}})))})})),Pt);var uCe,fCe;class dN{constructor(t,n){p(this,"original");p(this,"controller");p(this,uCe,Bp);p(this,fCe,Hp);this.original=t,this.controller=n}applyInterrupt(t){return zt(()=>(M0.unregister(this.original),oU(t,()=>Re(()=>{this.controller.abort()}))))}get request(){return this.original.request}get status(){return this.original.status}get headers(){return this.original.headers}get cookies(){return this.original.cookies}get remoteAddress(){return this.original.remoteAddress}get formData(){return this.applyInterrupt(this.original.formData)}get text(){return this.applyInterrupt(this.original.text)}get json(){return this.applyInterrupt(this.original.json)}get urlParamsBody(){return this.applyInterrupt(this.original.urlParamsBody)}get arrayBuffer(){return this.applyInterrupt(this.original.arrayBuffer)}get stream(){return WT(()=>(M0.unregister(this.original),x_e(this.original.stream,t=>(nne(t)&&this.controller.abort(),Le))))}toJSON(){return this.original.toJSON()}[(uCe=Bp,fCe=Hp,ft)](){return this.original[ft]()}}const ove=x(2,(e,t)=>{const n=e;return uH(r=>t(n.postprocess(r)),n.preprocess)}),ave=e=>uU(Z0e,we(hue(),t=>je(e,n=>ove(n,pue(r=>xa(t,r)))))),lve="@effect/platform/FetchHttpClient/Fetch",cve="@effect/platform/FetchHttpClient/FetchOptions",uve=ive((e,t,n,r)=>{const s=r.getFiberRef(WI),i=s.unsafeMap.get(lve)??globalThis.fetch,o=s.unsafeMap.get(cve)??{},a=o.headers?b0e(n2(o.headers),e.headers):e.headers,c=f=>je(Fp({try:()=>i(t,{...o,method:e.method,headers:a,body:f,duplex:e.body._tag==="Stream"?"half":void 0,signal:n}),catch:d=>new oH({request:e,reason:"Transport",cause:d})}),d=>Y0e(e,d));switch(e.body._tag){case"Raw":case"Uint8Array":return c(e.body.body);case"FormData":return c(e.body.formData);case"Stream":return we(L_e(e.body.stream),c)}return c(void 0)}),fve=ave(Pt(uve)),dve=fve;var ox;try{ox=new TextDecoder}catch{}var fe,oi,H=0,Vt={},ht,rl,Js=0,so=0,fr,ia,Ss=[],ut,hN={useRecords:!1,mapsAsObjects:!0};class fH{}const dH=new fH;dH.name="MessagePack 0xC1";var _l=!1,hH=2,pN;try{new Function("")}catch{hH=1/0}class Zg{constructor(t){t&&(t.useRecords===!1&&t.mapsAsObjects===void 0&&(t.mapsAsObjects=!0),t.sequential&&t.trusted!==!1&&(t.trusted=!0,!t.structures&&t.useRecords!=!1&&(t.structures=[],t.maxSharedStructures||(t.maxSharedStructures=0))),t.structures?t.structures.sharedLength=t.structures.length:t.getStructures&&((t.structures=[]).uninitialized=!0,t.structures.sharedLength=0),t.int64AsNumber&&(t.int64AsType="number")),Object.assign(this,t)}unpack(t,n){if(fe)return SH(()=>(lx(),this?this.unpack(t,n):Zg.prototype.unpack.call(hN,t,n)));!t.buffer&&t.constructor===ArrayBuffer&&(t=typeof Buffer<"u"?Buffer.from(t):new Uint8Array(t)),typeof n=="object"?(oi=n.end||t.length,H=n.start||0):(H=0,oi=n>-1?n:t.length),so=0,rl=null,fr=null,fe=t;try{ut=t.dataView||(t.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength))}catch(r){throw fe=null,t instanceof Uint8Array?r:new Error("Source must be a Uint8Array or Buffer but was a "+(t&&typeof t=="object"?t.constructor.name:typeof t))}if(this instanceof Zg){if(Vt=this,this.structures)return ht=this.structures,f_(n);(!ht||ht.length>0)&&(ht=[])}else Vt=hN,(!ht||ht.length>0)&&(ht=[]);return f_(n)}unpackMultiple(t,n){let r,s=0;try{_l=!0;let i=t.length,o=this?this.unpack(t,i):kb.unpack(t,i);if(n){if(n(o,s,H)===!1)return;for(;H<i;)if(s=H,n(f_(),s,H)===!1)return}else{for(r=[o];H<i;)s=H,r.push(f_());return r}}catch(i){throw i.lastPosition=s,i.values=r,i}finally{_l=!1,lx()}}_mergeStructures(t,n){t=t||[],Object.isFrozen(t)&&(t=t.map(r=>r.slice(0)));for(let r=0,s=t.length;r<s;r++){let i=t[r];i&&(i.isShared=!0,r>=32&&(i.highByte=r-32>>5))}t.sharedLength=t.length;for(let r in n||[])if(r>=0){let s=t[r],i=n[r];i&&(s&&((t.restoreStructures||(t.restoreStructures=[]))[r]=s),t[r]=i)}return this.structures=t}decode(t,n){return this.unpack(t,n)}}function f_(e){try{if(!Vt.trusted&&!_l){let n=ht.sharedLength||0;n<ht.length&&(ht.length=n)}let t;if(Vt.randomAccessStructure&&fe[H]<64&&fe[H]>=32&&pN?(t=pN(fe,H,oi,Vt),fe=null,!(e&&e.lazy)&&t&&(t=t.toJSON()),H=oi):t=An(),fr&&(H=fr.postBundlePosition,fr=null),_l&&(ht.restoreStructures=null),H==oi)ht&&ht.restoreStructures&&gN(),ht=null,fe=null,ia&&(ia=null);else{if(H>oi)throw new Error("Unexpected end of MessagePack data");if(!_l){let n;try{n=JSON.stringify(t,(r,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(r){n="(JSON view not available "+r+")"}throw new Error("Data read, but end of buffer not reached "+n)}}return t}catch(t){throw ht&&ht.restoreStructures&&gN(),lx(),(t instanceof RangeError||t.message.startsWith("Unexpected end of buffer")||H>oi)&&(t.incomplete=!0),t}}function gN(){for(let e in ht.restoreStructures)ht[e]=ht.restoreStructures[e];ht.restoreStructures=null}function An(){let e=fe[H++];if(e<160)if(e<128){if(e<64)return e;{let t=ht[e&63]||Vt.getStructures&&pH()[e&63];return t?(t.read||(t.read=s2(t,e&63)),t.read()):e}}else if(e<144)if(e-=128,Vt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=mH();r==="__proto__"&&(r="__proto_"),t[r]=An()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(An(),An());return t}else{e-=144;let t=new Array(e);for(let n=0;n<e;n++)t[n]=An();return Vt.freezeData?Object.freeze(t):t}else if(e<192){let t=e-160;if(so>=H)return rl.slice(H-Js,(H+=t)-Js);if(so==0&&oi<140){let n=t<16?i2(t):gH(t);if(n!=null)return n}return ax(t)}else{let t;switch(e){case 192:return null;case 193:return fr?(t=An(),t>0?fr[1].slice(fr.position1,fr.position1+=t):fr[0].slice(fr.position0,fr.position0-=t)):dH;case 194:return!1;case 195:return!0;case 196:if(t=fe[H++],t===void 0)throw new Error("Unexpected end of buffer");return fE(t);case 197:return t=ut.getUint16(H),H+=2,fE(t);case 198:return t=ut.getUint32(H),H+=4,fE(t);case 199:return sc(fe[H++]);case 200:return t=ut.getUint16(H),H+=2,sc(t);case 201:return t=ut.getUint32(H),H+=4,sc(t);case 202:if(t=ut.getFloat32(H),Vt.useFloat32>2){let n=o2[(fe[H]&127)<<1|fe[H+1]>>7];return H+=4,(n*t+(t>0?.5:-.5)>>0)/n}return H+=4,t;case 203:return t=ut.getFloat64(H),H+=8,t;case 204:return fe[H++];case 205:return t=ut.getUint16(H),H+=2,t;case 206:return t=ut.getUint32(H),H+=4,t;case 207:return Vt.int64AsType==="number"?(t=ut.getUint32(H)*4294967296,t+=ut.getUint32(H+4)):Vt.int64AsType==="string"?t=ut.getBigUint64(H).toString():Vt.int64AsType==="auto"?(t=ut.getBigUint64(H),t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ut.getBigUint64(H),H+=8,t;case 208:return ut.getInt8(H++);case 209:return t=ut.getInt16(H),H+=2,t;case 210:return t=ut.getInt32(H),H+=4,t;case 211:return Vt.int64AsType==="number"?(t=ut.getInt32(H)*4294967296,t+=ut.getUint32(H+4)):Vt.int64AsType==="string"?t=ut.getBigInt64(H).toString():Vt.int64AsType==="auto"?(t=ut.getBigInt64(H),t>=BigInt(-2)<<BigInt(52)&&t<=BigInt(2)<<BigInt(52)&&(t=Number(t))):t=ut.getBigInt64(H),H+=8,t;case 212:if(t=fe[H++],t==114)return wN(fe[H++]&63);{let n=Ss[t];if(n)return n.read?(H++,n.read(An())):n.noBuffer?(H++,n()):n(fe.subarray(H,++H));throw new Error("Unknown extension "+t)}case 213:return t=fe[H],t==114?(H++,wN(fe[H++]&63,fe[H++])):sc(2);case 214:return sc(4);case 215:return sc(8);case 216:return sc(16);case 217:return t=fe[H++],so>=H?rl.slice(H-Js,(H+=t)-Js):pve(t);case 218:return t=ut.getUint16(H),H+=2,so>=H?rl.slice(H-Js,(H+=t)-Js):gve(t);case 219:return t=ut.getUint32(H),H+=4,so>=H?rl.slice(H-Js,(H+=t)-Js):mve(t);case 220:return t=ut.getUint16(H),H+=2,yN(t);case 221:return t=ut.getUint32(H),H+=4,yN(t);case 222:return t=ut.getUint16(H),H+=2,_N(t);case 223:return t=ut.getUint32(H),H+=4,_N(t);default:if(e>=224)return e-256;if(e===void 0){let n=new Error("Unexpected end of MessagePack data");throw n.incomplete=!0,n}throw new Error("Unknown MessagePack token "+e)}}}const hve=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function s2(e,t){function n(){if(n.count++>hH){let s=e.read=new Function("r","return function(){return "+(Vt.freezeData?"Object.freeze":"")+"({"+e.map(i=>i==="__proto__"?"__proto_:r()":hve.test(i)?i+":r()":"["+JSON.stringify(i)+"]:r()").join(",")+"})}")(An);return e.highByte===0&&(e.read=mN(t,e.read)),s()}let r={};for(let s=0,i=e.length;s<i;s++){let o=e[s];o==="__proto__"&&(o="__proto_"),r[o]=An()}return Vt.freezeData?Object.freeze(r):r}return n.count=0,e.highByte===0?mN(t,n):n}const mN=(e,t)=>function(){let n=fe[H++];if(n===0)return t();let r=e<32?-(e+(n<<5)):e+(n<<5),s=ht[r]||pH()[r];if(!s)throw new Error("Record id is not defined for "+r);return s.read||(s.read=s2(s,e)),s.read()};function pH(){let e=SH(()=>(fe=null,Vt.getStructures()));return ht=Vt._mergeStructures(e,ht)}var ax=Sy,pve=Sy,gve=Sy,mve=Sy;function Sy(e){let t;if(e<16&&(t=i2(e)))return t;if(e>64&&ox)return ox.decode(fe.subarray(H,H+=e));const n=H+e,r=[];for(t="";H<n;){const s=fe[H++];if(!(s&128))r.push(s);else if((s&224)===192){const i=fe[H++]&63;r.push((s&31)<<6|i)}else if((s&240)===224){const i=fe[H++]&63,o=fe[H++]&63;r.push((s&31)<<12|i<<6|o)}else if((s&248)===240){const i=fe[H++]&63,o=fe[H++]&63,a=fe[H++]&63;let c=(s&7)<<18|i<<12|o<<6|a;c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|c&1023),r.push(c)}else r.push(s);r.length>=4096&&(t+=ar.apply(String,r),r.length=0)}return r.length>0&&(t+=ar.apply(String,r)),t}function yN(e){let t=new Array(e);for(let n=0;n<e;n++)t[n]=An();return Vt.freezeData?Object.freeze(t):t}function _N(e){if(Vt.mapsAsObjects){let t={};for(let n=0;n<e;n++){let r=mH();r==="__proto__"&&(r="__proto_"),t[r]=An()}return t}else{let t=new Map;for(let n=0;n<e;n++)t.set(An(),An());return t}}var ar=String.fromCharCode;function gH(e){let t=H,n=new Array(e);for(let r=0;r<e;r++){const s=fe[H++];if((s&128)>0){H=t;return}n[r]=s}return ar.apply(String,n)}function i2(e){if(e<4)if(e<2){if(e===0)return"";{let t=fe[H++];if((t&128)>1){H-=1;return}return ar(t)}}else{let t=fe[H++],n=fe[H++];if((t&128)>0||(n&128)>0){H-=2;return}if(e<3)return ar(t,n);let r=fe[H++];if((r&128)>0){H-=3;return}return ar(t,n,r)}else{let t=fe[H++],n=fe[H++],r=fe[H++],s=fe[H++];if((t&128)>0||(n&128)>0||(r&128)>0||(s&128)>0){H-=4;return}if(e<6){if(e===4)return ar(t,n,r,s);{let i=fe[H++];if((i&128)>0){H-=5;return}return ar(t,n,r,s,i)}}else if(e<8){let i=fe[H++],o=fe[H++];if((i&128)>0||(o&128)>0){H-=6;return}if(e<7)return ar(t,n,r,s,i,o);let a=fe[H++];if((a&128)>0){H-=7;return}return ar(t,n,r,s,i,o,a)}else{let i=fe[H++],o=fe[H++],a=fe[H++],c=fe[H++];if((i&128)>0||(o&128)>0||(a&128)>0||(c&128)>0){H-=8;return}if(e<10){if(e===8)return ar(t,n,r,s,i,o,a,c);{let f=fe[H++];if((f&128)>0){H-=9;return}return ar(t,n,r,s,i,o,a,c,f)}}else if(e<12){let f=fe[H++],d=fe[H++];if((f&128)>0||(d&128)>0){H-=10;return}if(e<11)return ar(t,n,r,s,i,o,a,c,f,d);let g=fe[H++];if((g&128)>0){H-=11;return}return ar(t,n,r,s,i,o,a,c,f,d,g)}else{let f=fe[H++],d=fe[H++],g=fe[H++],_=fe[H++];if((f&128)>0||(d&128)>0||(g&128)>0||(_&128)>0){H-=12;return}if(e<14){if(e===12)return ar(t,n,r,s,i,o,a,c,f,d,g,_);{let b=fe[H++];if((b&128)>0){H-=13;return}return ar(t,n,r,s,i,o,a,c,f,d,g,_,b)}}else{let b=fe[H++],k=fe[H++];if((b&128)>0||(k&128)>0){H-=14;return}if(e<15)return ar(t,n,r,s,i,o,a,c,f,d,g,_,b,k);let I=fe[H++];if((I&128)>0){H-=15;return}return ar(t,n,r,s,i,o,a,c,f,d,g,_,b,k,I)}}}}}function SN(){let e=fe[H++],t;if(e<192)t=e-160;else switch(e){case 217:t=fe[H++];break;case 218:t=ut.getUint16(H),H+=2;break;case 219:t=ut.getUint32(H),H+=4;break;default:throw new Error("Expected string")}return Sy(t)}function fE(e){return Vt.copyBuffers?Uint8Array.prototype.slice.call(fe,H,H+=e):fe.subarray(H,H+=e)}function sc(e){let t=fe[H++];if(Ss[t]){let n;return Ss[t](fe.subarray(H,n=H+=e),r=>{H=r;try{return An()}finally{H=n}})}else throw new Error("Unknown extension type "+t)}var vN=new Array(4096);function mH(){let e=fe[H++];if(e>=160&&e<192){if(e=e-160,so>=H)return rl.slice(H-Js,(H+=e)-Js);if(!(so==0&&oi<180))return ax(e)}else return H--,yH(An());let t=(e<<5^(e>1?ut.getUint16(H):e>0?fe[H]:0))&4095,n=vN[t],r=H,s=H+e-3,i,o=0;if(n&&n.bytes==e){for(;r<s;){if(i=ut.getUint32(r),i!=n[o++]){r=1879048192;break}r+=4}for(s+=3;r<s;)if(i=fe[r++],i!=n[o++]){r=1879048192;break}if(r===s)return H=r,n.string;s-=3,r=H}for(n=[],vN[t]=n,n.bytes=e;r<s;)i=ut.getUint32(r),n.push(i),r+=4;for(s+=3;r<s;)i=fe[r++],n.push(i);let a=e<16?i2(e):gH(e);return a!=null?n.string=a:n.string=ax(e)}function yH(e){if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(e==null)return e+"";if(Vt.allowArraysInMapKeys&&Array.isArray(e)&&e.flat().every(t=>["string","number","boolean","bigint"].includes(typeof t)))return e.flat().toString();throw new Error(`Invalid property type for record: ${typeof e}`)}const wN=(e,t)=>{let n=An().map(yH),r=e;t!==void 0&&(e=e<32?-((t<<5)+e):(t<<5)+e,n.highByte=t);let s=ht[e];return s&&(s.isShared||_l)&&((ht.restoreStructures||(ht.restoreStructures=[]))[e]=s),ht[e]=n,n.read=s2(n,r),n.read()};Ss[0]=()=>{};Ss[0].noBuffer=!0;Ss[66]=e=>{let t=e.byteLength%8||8,n=BigInt(e[0]&128?e[0]-256:e[0]);for(let r=1;r<t;r++)n<<=BigInt(8),n+=BigInt(e[r]);if(e.byteLength!==t){let r=new DataView(e.buffer,e.byteOffset,e.byteLength),s=(i,o)=>{let a=o-i;if(a<=40){let g=r.getBigUint64(i);for(let _=i+8;_<o;_+=8)g<<=64n,g|=r.getBigUint64(_);return g}let c=i+(a>>4<<3),f=s(i,c),d=s(c,o);return f<<BigInt((o-c)*8)|d};n=n<<BigInt((r.byteLength-t)*8)|s(t,r.byteLength)}return n};let bN={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError,AggregateError:typeof AggregateError=="function"?AggregateError:null};Ss[101]=()=>{let e=An();if(!bN[e[0]]){let t=Error(e[1],{cause:e[2]});return t.name=e[0],t}return bN[e[0]](e[1],{cause:e[2]})};Ss[105]=e=>{if(Vt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=ut.getUint32(H-4);ia||(ia=new Map);let n=fe[H],r;n>=144&&n<160||n==220||n==221?r=[]:n>=128&&n<144||n==222||n==223?r=new Map:(n>=199&&n<=201||n>=212&&n<=216)&&fe[H+1]===115?r=new Set:r={};let s={target:r};ia.set(t,s);let i=An();if(s.used)Object.assign(r,i);else return s.target=i;if(r instanceof Map)for(let[o,a]of i.entries())r.set(o,a);if(r instanceof Set)for(let o of Array.from(i))r.add(o);return r};Ss[112]=e=>{if(Vt.structuredClone===!1)throw new Error("Structured clone extension is disabled");let t=ut.getUint32(H-4),n=ia.get(t);return n.used=!0,n.target};Ss[115]=()=>new Set(An());const _H=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(e=>e+"Array");let yve=typeof globalThis=="object"?globalThis:window;Ss[116]=e=>{let t=e[0],n=Uint8Array.prototype.slice.call(e,1).buffer,r=_H[t];if(!r){if(t===16)return n;if(t===17)return new DataView(n);throw new Error("Could not find typed array for code "+t)}return new yve[r](n)};Ss[120]=()=>{let e=An();return new RegExp(e[0],e[1])};const _ve=[];Ss[98]=e=>{let t=(e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3],n=H;return H+=t-e.length,fr=_ve,fr=[SN(),SN()],fr.position0=0,fr.position1=0,fr.postBundlePosition=H,H=n,An()};Ss[255]=e=>e.length==4?new Date((e[0]*16777216+(e[1]<<16)+(e[2]<<8)+e[3])*1e3):e.length==8?new Date(((e[0]<<22)+(e[1]<<14)+(e[2]<<6)+(e[3]>>2))/1e6+((e[3]&3)*4294967296+e[4]*16777216+(e[5]<<16)+(e[6]<<8)+e[7])*1e3):e.length==12?new Date(((e[0]<<24)+(e[1]<<16)+(e[2]<<8)+e[3])/1e6+((e[4]&128?-281474976710656:0)+e[6]*1099511627776+e[7]*4294967296+e[8]*16777216+(e[9]<<16)+(e[10]<<8)+e[11])*1e3):new Date("invalid");function SH(e){let t=oi,n=H,r=Js,s=so,i=rl,o=ia,a=fr,c=new Uint8Array(fe.slice(0,oi)),f=ht,d=ht.slice(0,ht.length),g=Vt,_=_l,b=e();return oi=t,H=n,Js=r,so=s,rl=i,ia=o,fr=a,fe=c,_l=_,ht=f,ht.splice(0,ht.length,...d),Vt=g,ut=new DataView(fe.buffer,fe.byteOffset,fe.byteLength),b}function lx(){fe=null,ia=null,ht=null}const o2=new Array(147);for(let e=0;e<256;e++)o2[e]=+("1e"+Math.floor(45.15-e*.30103));var kb=new Zg({useRecords:!1});kb.unpack;kb.unpackMultiple;kb.unpack;let Sve=new Float32Array(1);new Uint8Array(Sve.buffer,0,4);let G_;try{G_=new TextEncoder}catch{}let cx,vH;const Ud=typeof Buffer<"u",d_=Ud?function(e){return Buffer.allocUnsafeSlow(e)}:Uint8Array,wH=Ud?Buffer:Uint8Array,EN=Ud?4294967296:2144337920;let K,Zh,Ht,B=0,Or,hn=null,vve;const wve=21760,bve=/[\u0080-\uFFFF]/,nf=Symbol("record-id");class Eve extends Zg{constructor(t){super(t),this.offset=0;let n,r,s,i,o=wH.prototype.utf8Write?function(M,U){return K.utf8Write(M,U,K.byteLength-U)}:G_&&G_.encodeInto?function(M,U){return G_.encodeInto(M,K.subarray(U)).written}:!1,a=this;t||(t={});let c=t&&t.sequential,f=t.structures||t.saveStructures,d=t.maxSharedStructures;if(d==null&&(d=f?32:0),d>8160)throw new Error("Maximum maxSharedStructure is 8160");t.structuredClone&&t.moreTypes==null&&(this.moreTypes=!0);let g=t.maxOwnStructures;g==null&&(g=f?32:64),!this.structures&&t.useRecords!=!1&&(this.structures=[]);let _=d>32||g+d>64,b=d+64,k=d+g+64;if(k>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let I=[],E=0,y=0;this.pack=this.encode=function(M,U){if(K||(K=new d_(8192),Ht=K.dataView||(K.dataView=new DataView(K.buffer,0,8192)),B=0),Or=K.length-10,Or-B<2048?(K=new d_(K.length),Ht=K.dataView||(K.dataView=new DataView(K.buffer,0,K.length)),Or=K.length-10,B=0):B=B+7&2147483640,n=B,U&$ve&&(B+=U&255),i=a.structuredClone?new Map:null,a.bundleStrings&&typeof M!="string"?(hn=[],hn.size=1/0):hn=null,s=a.structures,s){s.uninitialized&&(s=a._mergeStructures(a.getStructures()));let L=s.sharedLength||0;if(L>d)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let G=0;G<L;G++){let V=s[G];if(!V)continue;let J,ee=s.transitions;for(let de=0,Te=V.length;de<Te;de++){let dn=V[de];J=ee[dn],J||(J=ee[dn]=Object.create(null)),ee=J}ee[nf]=G+64}this.lastNamedStructuresLength=L}c||(s.nextId=L+64)}r&&(r=!1);let Q;try{a.randomAccessStructure&&M&&M.constructor&&M.constructor===Object?le(M):w(M);let L=hn;if(hn&&CN(n,w,0),i&&i.idsToInsert){let G=i.idsToInsert.sort((de,Te)=>de.offset>Te.offset?1:-1),V=G.length,J=-1;for(;L&&V>0;){let de=G[--V].offset+n;de<L.stringsPosition+n&&J===-1&&(J=0),de>L.position+n?J>=0&&(J+=6):(J>=0&&(Ht.setUint32(L.position+n,Ht.getUint32(L.position+n)+J),J=-1),L=L.previous,V++)}J>=0&&L&&Ht.setUint32(L.position+n,Ht.getUint32(L.position+n)+J),B+=G.length*6,B>Or&&z(B),a.offset=B;let ee=kve(K.subarray(n,B),G);return i=null,ee}return a.offset=B,U&xve?(K.start=n,K.end=B,K):K.subarray(n,B)}catch(L){throw Q=L,L}finally{if(s&&(m(),r&&a.saveStructures)){let L=s.sharedLength||0,G=K.subarray(n,B),V=Cve(s,a);if(!Q)return a.saveStructures(V,V.isCompatible)===!1?a.pack(M,U):(a.lastNamedStructuresLength=L,K.length>1073741824&&(K=null),G)}K.length>1073741824&&(K=null),U&Rve&&(B=n)}};const m=()=>{y<10&&y++;let M=s.sharedLength||0;if(s.length>M&&!c&&(s.length=M),E>1e4)s.transitions=null,y=0,E=0,I.length>0&&(I=[]);else if(I.length>0&&!c){for(let U=0,Q=I.length;U<Q;U++)I[U][nf]=0;I=[]}},v=M=>{var U=M.length;U<16?K[B++]=144|U:U<65536?(K[B++]=220,K[B++]=U>>8,K[B++]=U&255):(K[B++]=221,Ht.setUint32(B,U),B+=4);for(let Q=0;Q<U;Q++)w(M[Q])},w=M=>{B>Or&&(K=z(B));var U=typeof M,Q;if(U==="string"){let L=M.length;if(hn&&L>=4&&L<4096){if((hn.size+=L)>wve){let ee,de=(hn[0]?hn[0].length*3+hn[1].length:0)+10;B+de>Or&&(K=z(B+de));let Te;hn.position?(Te=hn,K[B]=200,B+=3,K[B++]=98,ee=B-n,B+=4,CN(n,w,0),Ht.setUint16(ee+n-3,B-n-ee)):(K[B++]=214,K[B++]=98,ee=B-n,B+=4),hn=["",""],hn.previous=Te,hn.size=0,hn.position=ee}let J=bve.test(M);hn[J?0:1]+=M,K[B++]=193,w(J?-L:L);return}let G;L<32?G=1:L<256?G=2:L<65536?G=3:G=5;let V=L*3;if(B+V>Or&&(K=z(B+V)),L<64||!o){let J,ee,de,Te=B+G;for(J=0;J<L;J++)ee=M.charCodeAt(J),ee<128?K[Te++]=ee:ee<2048?(K[Te++]=ee>>6|192,K[Te++]=ee&63|128):(ee&64512)===55296&&((de=M.charCodeAt(J+1))&64512)===56320?(ee=65536+((ee&1023)<<10)+(de&1023),J++,K[Te++]=ee>>18|240,K[Te++]=ee>>12&63|128,K[Te++]=ee>>6&63|128,K[Te++]=ee&63|128):(K[Te++]=ee>>12|224,K[Te++]=ee>>6&63|128,K[Te++]=ee&63|128);Q=Te-B-G}else Q=o(M,B+G);Q<32?K[B++]=160|Q:Q<256?(G<2&&K.copyWithin(B+2,B+1,B+1+Q),K[B++]=217,K[B++]=Q):Q<65536?(G<3&&K.copyWithin(B+3,B+2,B+2+Q),K[B++]=218,K[B++]=Q>>8,K[B++]=Q&255):(G<5&&K.copyWithin(B+5,B+3,B+3+Q),K[B++]=219,Ht.setUint32(B,Q),B+=4),B+=Q}else if(U==="number")if(M>>>0===M)M<32||M<128&&this.useRecords===!1||M<64&&!this.randomAccessStructure?K[B++]=M:M<256?(K[B++]=204,K[B++]=M):M<65536?(K[B++]=205,K[B++]=M>>8,K[B++]=M&255):(K[B++]=206,Ht.setUint32(B,M),B+=4);else if(M>>0===M)M>=-32?K[B++]=256+M:M>=-128?(K[B++]=208,K[B++]=M+256):M>=-32768?(K[B++]=209,Ht.setInt16(B,M),B+=2):(K[B++]=210,Ht.setInt32(B,M),B+=4);else{let L;if((L=this.useFloat32)>0&&M<4294967296&&M>=-2147483648){K[B++]=202,Ht.setFloat32(B,M);let G;if(L<4||(G=M*o2[(K[B]&127)<<1|K[B+1]>>7])>>0===G){B+=4;return}else B--}K[B++]=203,Ht.setFloat64(B,M),B+=8}else if(U==="object"||U==="function")if(!M)K[B++]=192;else{if(i){let G=i.get(M);if(G){if(!G.id){let V=i.idsToInsert||(i.idsToInsert=[]);G.id=V.push(G)}K[B++]=214,K[B++]=112,Ht.setUint32(B,G.id),B+=4;return}else i.set(M,{offset:B-n})}let L=M.constructor;if(L===Object)A(M);else if(L===Array)v(M);else if(L===Map)if(this.mapAsEmptyObject)K[B++]=128;else{Q=M.size,Q<16?K[B++]=128|Q:Q<65536?(K[B++]=222,K[B++]=Q>>8,K[B++]=Q&255):(K[B++]=223,Ht.setUint32(B,Q),B+=4);for(let[G,V]of M)w(G),w(V)}else{for(let G=0,V=cx.length;G<V;G++){let J=vH[G];if(M instanceof J){let ee=cx[G];if(ee.write){ee.type&&(K[B++]=212,K[B++]=ee.type,K[B++]=0);let ir=ee.write.call(this,M);ir===M?Array.isArray(M)?v(M):A(M):w(ir);return}let de=K,Te=Ht,dn=B;K=null;let ln;try{ln=ee.pack.call(this,M,ir=>(K=de,de=null,B+=ir,B>Or&&z(B),{target:K,targetView:Ht,position:B-ir}),w)}finally{de&&(K=de,Ht=Te,B=dn,Or=K.length-10)}ln&&(ln.length+B>Or&&z(ln.length+B),B=kN(ln,K,B,ee.type));return}}if(Array.isArray(M))v(M);else{if(M.toJSON){const G=M.toJSON();if(G!==M)return w(G)}if(U==="function")return w(this.writeFunction&&this.writeFunction(M));A(M)}}}else if(U==="boolean")K[B++]=M?195:194;else if(U==="bigint"){if(M<9223372036854776e3&&M>=-9223372036854776e3)K[B++]=211,Ht.setBigInt64(B,M);else if(M<18446744073709552e3&&M>0)K[B++]=207,Ht.setBigUint64(B,M);else if(this.largeBigIntToFloat)K[B++]=203,Ht.setFloat64(B,Number(M));else{if(this.largeBigIntToString)return w(M.toString());if(this.useBigIntExtension||this.moreTypes){let L=M<0?BigInt(-1):BigInt(0),G;if(M>>BigInt(65536)===L){let V=BigInt(18446744073709552e3)-BigInt(1),J=[];for(;J.push(M&V),M>>BigInt(63)!==L;)M>>=BigInt(64);G=new Uint8Array(new BigUint64Array(J).buffer),G.reverse()}else{let V=M<0,J=(V?~M:M).toString(16);if(J.length%2?J="0"+J:parseInt(J.charAt(0),16)>=8&&(J="00"+J),Ud)G=Buffer.from(J,"hex");else{G=new Uint8Array(J.length/2);for(let ee=0;ee<G.length;ee++)G[ee]=parseInt(J.slice(ee*2,ee*2+2),16)}if(V)for(let ee=0;ee<G.length;ee++)G[ee]=~G[ee]}G.length+B>Or&&z(G.length+B),B=kN(G,K,B,66);return}else throw new RangeError(M+" was too large to fit in MessagePack 64-bit integer format, use useBigIntExtension, or set largeBigIntToFloat to convert to float-64, or set largeBigIntToString to convert to string")}B+=8}else if(U==="undefined")this.encodeUndefinedAsNil?K[B++]=192:(K[B++]=212,K[B++]=0,K[B++]=0);else throw new Error("Unknown type: "+U)},$=this.variableMapSize||this.coercibleKeyAsNumber||this.skipValues?M=>{let U;if(this.skipValues){U=[];for(let G in M)(typeof M.hasOwnProperty!="function"||M.hasOwnProperty(G))&&!this.skipValues.includes(M[G])&&U.push(G)}else U=Object.keys(M);let Q=U.length;Q<16?K[B++]=128|Q:Q<65536?(K[B++]=222,K[B++]=Q>>8,K[B++]=Q&255):(K[B++]=223,Ht.setUint32(B,Q),B+=4);let L;if(this.coercibleKeyAsNumber)for(let G=0;G<Q;G++){L=U[G];let V=Number(L);w(isNaN(V)?L:V),w(M[L])}else for(let G=0;G<Q;G++)w(L=U[G]),w(M[L])}:M=>{K[B++]=222;let U=B-n;B+=2;let Q=0;for(let L in M)(typeof M.hasOwnProperty!="function"||M.hasOwnProperty(L))&&(w(L),w(M[L]),Q++);if(Q>65535)throw new Error('Object is too large to serialize with fast 16-bit map size, use the "variableMapSize" option to serialize this object');K[U+++n]=Q>>8,K[U+n]=Q&255},P=this.useRecords===!1?$:t.progressiveRecords&&!_?M=>{let U,Q=s.transitions||(s.transitions=Object.create(null)),L=B++-n,G;for(let V in M)if(typeof M.hasOwnProperty!="function"||M.hasOwnProperty(V)){if(U=Q[V],U)Q=U;else{let J=Object.keys(M),ee=Q;Q=s.transitions;let de=0;for(let Te=0,dn=J.length;Te<dn;Te++){let ln=J[Te];U=Q[ln],U||(U=Q[ln]=Object.create(null),de++),Q=U}L+n+1==B?(B--,D(Q,J,de)):W(Q,J,L,de),G=!0,Q=ee[V]}w(M[V])}if(!G){let V=Q[nf];V?K[L+n]=V:W(Q,Object.keys(M),L,0)}}:M=>{let U,Q=s.transitions||(s.transitions=Object.create(null)),L=0;for(let V in M)(typeof M.hasOwnProperty!="function"||M.hasOwnProperty(V))&&(U=Q[V],U||(U=Q[V]=Object.create(null),L++),Q=U);let G=Q[nf];G?G>=96&&_?(K[B++]=((G-=96)&31)+96,K[B++]=G>>5):K[B++]=G:D(Q,Q.__keys__||Object.keys(M),L);for(let V in M)(typeof M.hasOwnProperty!="function"||M.hasOwnProperty(V))&&w(M[V])},O=typeof this.useRecords=="function"&&this.useRecords,A=O?M=>{O(M)?P(M):$(M)}:P,z=M=>{let U;if(M>16777216){if(M-n>EN)throw new Error("Packed buffer would be larger than maximum buffer size");U=Math.min(EN,Math.round(Math.max((M-n)*(M>67108864?1.25:2),4194304)/4096)*4096)}else U=(Math.max(M-n<<2,K.length-1)>>12)+1<<12;let Q=new d_(U);return Ht=Q.dataView||(Q.dataView=new DataView(Q.buffer,0,U)),M=Math.min(M,K.length),K.copy?K.copy(Q,0,n,M):Q.set(K.slice(n,M)),B-=n,n=0,Or=Q.length-10,K=Q},D=(M,U,Q)=>{let L=s.nextId;L||(L=64),L<b&&this.shouldShareStructure&&!this.shouldShareStructure(U)?(L=s.nextOwnId,L<k||(L=b),s.nextOwnId=L+1):(L>=k&&(L=b),s.nextId=L+1);let G=U.highByte=L>=96&&_?L-96>>5:-1;M[nf]=L,M.__keys__=U,s[L-64]=U,L<b?(U.isShared=!0,s.sharedLength=L-63,r=!0,G>=0?(K[B++]=(L&31)+96,K[B++]=G):K[B++]=L):(G>=0?(K[B++]=213,K[B++]=114,K[B++]=(L&31)+96,K[B++]=G):(K[B++]=212,K[B++]=114,K[B++]=L),Q&&(E+=y*Q),I.length>=g&&(I.shift()[nf]=0),I.push(M),w(U))},W=(M,U,Q,L)=>{let G=K,V=B,J=Or,ee=n;K=Zh,B=0,n=0,K||(Zh=K=new d_(8192)),Or=K.length-10,D(M,U,L),Zh=K;let de=B;if(K=G,B=V,Or=J,n=ee,de>1){let Te=B+de-1;Te>Or&&z(Te);let dn=Q+n;K.copyWithin(dn+de,dn+1,B),K.set(Zh.slice(0,de),dn),B=Te}else K[Q+n]=Zh[0]},le=M=>{let U=vve(M,K,n,B,s,z,(Q,L,G)=>{if(G)return r=!0;B=L;let V=K;return w(Q),m(),V!==K?{position:B,targetView:Ht,target:K}:B},this);if(U===0)return A(M);B=U}}useBuffer(t){K=t,K.dataView||(K.dataView=new DataView(K.buffer,K.byteOffset,K.byteLength)),Ht=K.dataView,B=0}set position(t){B=t}get position(){return B}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}vH=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,DataView,fH];cx=[{pack(e,t,n){let r=e.getTime()/1e3;if((this.useTimestamp32||e.getMilliseconds()===0)&&r>=0&&r<4294967296){let{target:s,targetView:i,position:o}=t(6);s[o++]=214,s[o++]=255,i.setUint32(o,r)}else if(r>0&&r<4294967296){let{target:s,targetView:i,position:o}=t(10);s[o++]=215,s[o++]=255,i.setUint32(o,e.getMilliseconds()*4e6+(r/1e3/4294967296>>0)),i.setUint32(o+4,r)}else if(isNaN(r)){if(this.onInvalidDate)return t(0),n(this.onInvalidDate());let{target:s,targetView:i,position:o}=t(3);s[o++]=212,s[o++]=255,s[o++]=255}else{let{target:s,targetView:i,position:o}=t(15);s[o++]=199,s[o++]=12,s[o++]=255,i.setUint32(o,e.getMilliseconds()*1e6),i.setBigInt64(o+4,BigInt(Math.floor(r)))}}},{pack(e,t,n){if(this.setAsEmptyObject)return t(0),n({});let r=Array.from(e),{target:s,position:i}=t(this.moreTypes?3:0);this.moreTypes&&(s[i++]=212,s[i++]=115,s[i++]=0),n(r)}},{pack(e,t,n){let{target:r,position:s}=t(this.moreTypes?3:0);this.moreTypes&&(r[s++]=212,r[s++]=101,r[s++]=0),n([e.name,e.message,e.cause])}},{pack(e,t,n){let{target:r,position:s}=t(this.moreTypes?3:0);this.moreTypes&&(r[s++]=212,r[s++]=120,r[s++]=0),n([e.source,e.flags])}},{pack(e,t){this.moreTypes?dE(e,16,t):hE(Ud?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let n=e.constructor;n!==wH&&this.moreTypes?dE(e,_H.indexOf(n.name),t):hE(e,t)}},{pack(e,t){this.moreTypes?dE(e,17,t):hE(Ud?Buffer.from(e):new Uint8Array(e),t)}},{pack(e,t){let{target:n,position:r}=t(1);n[r]=193}}];function dE(e,t,n,r){let s=e.byteLength;if(s+1<256){var{target:i,position:o}=n(4+s);i[o++]=199,i[o++]=s+1}else if(s+1<65536){var{target:i,position:o}=n(5+s);i[o++]=200,i[o++]=s+1>>8,i[o++]=s+1&255}else{var{target:i,position:o,targetView:a}=n(7+s);i[o++]=201,a.setUint32(o,s+1),o+=4}i[o++]=116,i[o++]=t,e.buffer||(e=new Uint8Array(e)),i.set(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),o)}function hE(e,t){let n=e.byteLength;var r,s;if(n<256){var{target:r,position:s}=t(n+2);r[s++]=196,r[s++]=n}else if(n<65536){var{target:r,position:s}=t(n+3);r[s++]=197,r[s++]=n>>8,r[s++]=n&255}else{var{target:r,position:s,targetView:i}=t(n+5);r[s++]=198,i.setUint32(s,n),s+=4}r.set(e,s)}function kN(e,t,n,r){let s=e.length;switch(s){case 1:t[n++]=212;break;case 2:t[n++]=213;break;case 4:t[n++]=214;break;case 8:t[n++]=215;break;case 16:t[n++]=216;break;default:s<256?(t[n++]=199,t[n++]=s):s<65536?(t[n++]=200,t[n++]=s>>8,t[n++]=s&255):(t[n++]=201,t[n++]=s>>24,t[n++]=s>>16&255,t[n++]=s>>8&255,t[n++]=s&255)}return t[n++]=r,t.set(e,n),n+=s,n}function kve(e,t){let n,r=t.length*6,s=e.length-r;for(;n=t.pop();){let i=n.offset,o=n.id;e.copyWithin(i+r,i,s),r-=6;let a=i+r;e[a++]=214,e[a++]=105,e[a++]=o>>24,e[a++]=o>>16&255,e[a++]=o>>8&255,e[a++]=o&255,s=i}return e}function CN(e,t,n){if(hn.length>0){Ht.setUint32(hn.position+e,B+n-hn.position-e),hn.stringsPosition=B-e;let r=hn;hn=null,t(r[0]),t(r[1])}}function Cve(e,t){return e.isCompatible=n=>{let r=!n||(t.lastNamedStructuresLength||0)===n.length;return r||t._mergeStructures(n),r},e}let bH=new Eve({useRecords:!1});bH.pack;bH.pack;const xve=512,Rve=1024,$ve=2048;class Cb extends Vv("@effect/platform/Transferable/Collector")(){}const EH=()=>{let e=[];const t=s=>{e.push(...s)},n=()=>e,r=()=>{const s=e;return e=[],s};return Cb.of({unsafeAddAll:t,addAll:s=>Re(()=>t(s)),unsafeRead:n,read:Re(n),unsafeClear:r,clear:Re(r)})},Ive=Re(EH),Tve=e=>we(gue(Cb),bt({onNone:()=>Le,onSome:t=>t.addAll(e)})),kH=x(2,(e,t)=>Nl(pb(e),e,{strict:!0,decode:Ni,encode:n=>yo(Tve(t(n)),n)})),CH=kH(Nn,e=>[e]),a2=kH(Sb,e=>[e.buffer]),Pve=Symbol.for("@effect/platform/WorkerError"),xN=Pve;var dCe;const Ua=class Ua extends Oo()("WorkerError",{reason:nt("spawn","decode","send","unknown","encode"),cause:Vg}){constructor(){super(...arguments);p(this,dCe,xN)}get message(){switch(this.reason){case"send":return"An error occurred calling .postMessage";case"spawn":return"An error occurred while spawning a worker";case"decode":return"An error occurred during decoding";case"encode":return"An error occurred during encoding";case"unknown":return"An unexpected error occurred"}}};dCe=xN,p(Ua,"Cause",v_e({error:Ua,defect:Vg})),p(Ua,"encodeCause",Jo(Ua.Cause)),p(Ua,"decodeCause",Ld(Ua.Cause));let _u=Ua;const RN=Symbol.for("@effect/platform/Worker/PlatformWorker"),l2=Mr("@effect/platform/Worker/PlatformWorker"),$N=Symbol.for("@effect/platform/Worker/WorkerManager"),em=Mr("@effect/platform/Worker/WorkerManager"),xH=Mr("@effect/platform/Worker/Spawner"),Ove=X(function*(){const e=yield*l2;let t=0;return em.of({[$N]:$N,spawn({encode:n,initialMessage:r}){return X(function*(){const s=t++;let i=0;const o=new Map,a=EH(),c=n?E=>Tt(a.clear,jI(n(E),Cb,a)):Pt,f=yield*rt(),d=yield*e.spawn(s);yield*d.run(E=>E[0]===0?ene(f,Le):g(E[1])).pipe(uue(E=>er(o.values(),y=>tc in y?Kf(y,E):y.failCause(E))),Sh(Ps),NI(Jde(1e3)),yl({package:"@effect/platform",module:"Worker"}),Jt,Dt),yield*pr(()=>Tt(er(o.values(),E=>tc in E?aA(E):E.end,{discard:!0}),Re(()=>o.clear())));const g=E=>zt(()=>{const y=o.get(E[0]);if(!y)return Le;switch(E[1]){case 0:return tc in y?jt(y,E[2][0]):y.offerAll(E[2]);case 1:return E.length===2?tc in y?aA(y):y.end:tc in y?jt(y,E[2][0]):Tt(y.offerAll(E[2]),y.end);case 2:case 3:{if(E[1]===2)return tc in y?V$(y,E[2]):y.fail(E[2]);const m=_u.decodeCause(E[2]);return tc in y?Kf(y,m):y.failCause(m)}}}),_=(E,y)=>_a(m=>{const v=m.getFiberRef(WI),w=Ms(v,t4).pipe(PQ(P=>P._tag==="Span")),$=i++;return y.pipe(kr(P=>(o.set($,P),c(E).pipe(kr(O=>d.send([$,0,O,w._tag==="Some"?[w.value.traceId,w.value.spanId,w.value.sampled]:void 0],a.unsafeRead())),sa(O=>zme(P)?P.failCause(O):Kf(P,O))))),je(P=>({id:$,mailbox:P})))}),b=({id:E},y)=>{const m=Re(()=>o.delete(E));return hh(y)?Tt(os(d.send([E,1])),m):m},k=E=>T_e(hge(_(E,jme()),({mailbox:y})=>Ume(y),b)),I=E=>DI(_(E,rt()),({mailbox:y})=>yn(y),b);return yield*yn(f),r&&(yield*Re(r).pipe(we(I),Gl(E=>new _u({reason:"spawn",cause:E})))),{id:s,execute:k,executeEffect:I}})}})}),Ave=uU(em,Ove),Fve=e=>X(function*(){const n=yield*(yield*em).spawn({...e,encode(i){return Gl(w_e(i),o=>new _u({reason:"encode",cause:o}))}}),r=i=>{const o=hp(WF(i)),a=hp(VF(i));return T(n.execute(i),C_e(c=>we(a(c),zs)),L8(o))},s=i=>{const o=hp(WF(i)),a=hp(VF(i));return _ue(n.executeEffect(i),{onFailure:c=>we(a(c),zs),onSuccess:o})};return Ce({id:n.id,execute:r,executeEffect:s})}),Nve=e=>X(function*(){const t=yield*em,n=new Set,r=T(Fve(e),kr(o=>Re(()=>n.add(o))),kr(o=>pr(()=>Re(()=>n.delete(o)))),e.onCreate?kr(e.onCreate):Ce,jI(em,t)),s=yield*"timeToLive"in e?Xme({acquire:r,min:e.minSize,max:e.maxSize,concurrency:e.concurrency,targetUtilization:e.targetUtilization,timeToLive:e.timeToLive}):Yme({acquire:r,size:e.size,concurrency:e.concurrency,targetUtilization:e.targetUtilization}),i={backing:s,broadcast:o=>er(n,a=>a.executeEffect(o),{concurrency:"unbounded",discard:!0}),execute:o=>z8(je(s.get,a=>a.execute(o))),executeEffect:o=>Pl(we(s.get,a=>a.executeEffect(o)))};return yield*Pl(s.get),i}),Dve=e=>vh(xH,e),qve=()=>e=>l2.of({[RN]:RN,spawn(t){return X(function*(){const n=yield*xH;let r;const s=[];return{run:a=>Tl(c=>X(function*(){const f=yield*qI,d=yield*e.setup({worker:n(t),scope:f});r=d,yield*Rl(f,Re(()=>{r=void 0}));const g=(yield*To()).pipe(Gde(AY(Cle))),_=yield*Uge(),b=sb(g);if(yield*e.listen({port:d,scope:f,emit(k){Bge(_,b(a(k)))},deferred:_.deferred}),s.length>0){for(const[k,I]of s)d.postMessage([0,k],I);s.length=0}return yield*c(Vge(_))}).pipe(Pl)),send:(a,c)=>Kl({try:()=>{r===void 0?s.push([a,c]):r.postMessage([0,a],c)},catch:f=>new _u({reason:"send",cause:f})})}})}}),Mve=qve,Lve=l2,zve=Ave,jve=Nve,Uve=Dve,c2=e=>{try{return tn(JSON.stringify(e.ast,null,2))}catch{return console.warn("Schema hashing failed, falling back to hashing the shortend schema AST string. This is less reliable and may cause false positives."),ce(e.ast.toString())}},u2=(e,t)=>(n,r)=>X(function*(){const s=yield*Ive;return[yield*OT(e,t)(n,r).pipe(jI(Cb,s)),s.unsafeRead()]}),Hve=e=>Nl(zi(e),pb(e),{decode:ome(e),encode:sme(e)});Hve(Hye);const Hd=tt(Y,it,Fl,FT,Je(Hg(()=>Hd)),my({key:Y,value:Hg(()=>Hd)})).annotations({title:"JsonValue"}),qr=Symbol("WebChannel"),tm=Ye("WebChannel.DebugPing",{message:Y,payload:Qr(Y)}),L0=Ye("WebChannel.Ping",{requestId:Y}),z0=Ye("WebChannel.Pong",{requestId:Y}),Bve=tt(L0,z0),IN=e=>({send:tt(e.send,tm,L0,z0),listen:tt(e.listen,tm,L0,z0)}),vy=e=>_e(e,"send")&&_e(e,"listen")?IN(e):IN({send:e,listen:e}),xb=e=>t=>t.pipe(q8(ay(function*(n){return n._tag==="Right"&&cr(tm)(n.right)?(yield*ni(`WebChannel:ping [${e}] ${n.right.message}`,n.right.payload),!1):!0}))),RH=({channelName:e,schema:t})=>Lu(n=>X(function*(){const r=vy(t),s=new BroadcastChannel(e);yield*pr(()=>Kl(()=>s.close()).pipe(Hw));const i=f=>X(function*(){const d=yield*OT(r.send)(f);s.postMessage(d)}),o=wb(s,"message").pipe(Ta(f=>gy(r.listen)(f.data)),xb(e)),a=yield*rt().pipe(Rt(Wl(_s))),c=!1;return{[qr]:qr,send:i,listen:o,closedDeferred:a,shutdown:Ln(n,_n("shutdown")),schema:r,supportsTransferables:c}}).pipe(Qe(`WebChannel:broadcastChannel(${e})`))),ux=({listenWindow:e,sendWindow:t,targetOrigin:n="*",ids:r,schema:s})=>Lu(i=>X(function*(){const o=vy(s),a={sendTotal:0,listenTotal:0,targetOrigin:n,ids:r},c=ke({message:o.listen,from:nt(r.other),to:nt(r.own)}).annotations({title:"webmesh.WindowMessageListen"}),f=ke({message:o.send,from:nt(r.own),to:nt(r.other)}).annotations({title:"webmesh.WindowMessageSend"}),d=k=>X(function*(){a.sendTotal++;const[I,E]=yield*u2(f)({message:k,from:r.own,to:r.other});t.postMessage(I,n,E)}),g=wb(e,"message").pipe(Ui(k=>cr(pb(c))(k.data)),Ta(k=>(a.listenTotal++,gy(o.listen)(k.data.message))),xb("window")),_=yield*rt().pipe(Rt(Wl(_s))),b=!0;return{[qr]:qr,send:d,listen:g,closedDeferred:_,shutdown:Ln(i,_n("shutdown")),schema:o,supportsTransferables:b,debugInfo:a}}).pipe(Qe("WebChannel:windowChannel"))),Vve=({port:e,schema:t,debugId:n})=>Lu(r=>X(function*(){const s=vy(t),i=n===void 0?"messagePort":`messagePort:${n}`,o=d=>X(function*(){const[g,_]=yield*u2(s.send)(d);e.postMessage(g,_)}),a=wb(e,"message").pipe(Ta(d=>gy(s.listen)(d.data)),xb(i));e.start();const c=yield*rt().pipe(Rt(Wl(_s))),f=!0;return yield*pr(()=>Kl(()=>e.close()).pipe(Hw)),{[qr]:qr,send:o,listen:a,closedDeferred:c,shutdown:Ln(r,_n("shutdown")),schema:s,supportsTransferables:f}}).pipe(Qe("WebChannel:messagePortChannel")));We("livestore:sameThreadChannels",()=>new Map);const TN=({port:e,schema:t,debugId:n})=>Lu(r=>X(function*(){const s=vy(t),i=n===void 0?"messagePort":`messagePort:${n}`,o=new Map,a=Ye("ChannelRequest",{id:Y,payload:tt(s.listen,s.send)}).annotations({title:"webmesh.ChannelRequest"}),c=Ye("ChannelRequestAck",{reqId:Y}).annotations({title:"webmesh.ChannelRequestAck"}),f=tt(a,c).annotations({title:"webmesh.ChannelMessage"}),d={sendTotal:0,sendPending:0,listenTotal:0,id:n},g=I=>X(function*(){d.sendTotal++,d.sendPending++;const E=crypto.randomUUID(),[y,m]=yield*u2(f)({_tag:"ChannelRequest",id:E,payload:I}),v=yield*rt();o.set(E,v),e.postMessage(y,m),yield*v,o.delete(E),d.sendPending--}),_=wb(e,"message").pipe(Ta(I=>gy(f)(I.data)),Un(I=>X(function*(){I._tag==="Right"&&(I.right._tag==="ChannelRequestAck"?yield*jt(o.get(I.right.reqId),void 0):I.right._tag==="ChannelRequest"&&(d.listenTotal++,e.postMessage(Jo(f)({_tag:"ChannelRequestAck",reqId:I.right.id}))))})),$_e(I=>I._tag==="Left"?oe(I):I.right._tag==="ChannelRequest"?oe(Pe(I.right.payload)):re()),I=>I,xb(i));e.start();const b=yield*rt().pipe(Rt(Wl(_s))),k=!0;return yield*pr(()=>Kl(()=>e.close()).pipe(Hw)),{[qr]:qr,send:g,listen:_,closedDeferred:b,shutdown:Ln(r,_n("shutdown")),schema:s,supportsTransferables:k,debugInfo:d}}).pipe(Qe("WebChannel:messagePortChannelWithAck"))),PN=(e,t)=>X(function*(){const n=yield*dr().pipe(Rt(In)),r={current:void 0};if(yield*e.listen.pipe(t!=null&&t.heartbeat?q8(ay(function*(i){if(i._tag==="Right"&&cr(Bve)(i.right)){if(i.right._tag==="WebChannel.Ping")yield*e.send(z0.make({requestId:i.right.requestId}));else{const{deferred:o,requestId:a}=r.current??ze("No pending ping");a!==i.right.requestId&&ze("Received pong for unexpected requestId",a,i.right.requestId),yield*jt(o,void 0)}return!1}return!0})):Ce,j8(i=>nT(n,i)),Sn,Dt),t!=null&&t.heartbeat){const{interval:i,timeout:o}=t.heartbeat;yield*X(function*(){for(;;){yield*Bw(i);const a=crypto.randomUUID();yield*e.send(L0.make({requestId:a}));const c=yield*rt();r.current={deferred:c,requestId:a},yield*c.pipe(Vw(o),_h("TimeoutException",()=>e.shutdown))}}).pipe(Qe("WebChannel:heartbeat"),Dt)}const s=va(n,{maxChunkSize:1});return{[qr]:qr,send:e.send,listen:s,closedDeferred:e.closedDeferred,shutdown:e.shutdown,schema:e.schema,supportsTransferables:e.supportsTransferables,debugInfo:{innerDebugInfo:e.debugInfo,listenQueueSize:n}}}),Wve=e=>t=>{if(_e(console,"createTask")===!1)return t;const n=X(function*(){const s=yield*bue;return n4({span:(i,...o)=>{const a=s.span(i,...o),c=e(i);return a.runInTask=f=>c.run(f),a},context:(i,o)=>{const a=Ms(t4)(o.currentContext);if(a._tag==="None")return s.context(i,o);const c=a.value;if(c._tag==="ExternalSpan")return s.context(i,o);const f=c;return"runInTask"in f&&typeof f.runInTask=="function"?f.runInTask(()=>s.context(i,o)):s.context(i,o)}})}),r=T(n,je(hU),fU);return Hn(t,r)},Kve=Mve()({setup({scope:e,worker:t}){const n="port"in t?t.port:t;return yo(Rl(e,Re(()=>{n.postMessage([1])})),n)},listen({deferred:e,emit:t,port:n,scope:r}){function s(o){t(o.data)}function i(o){bw(e,new _u({reason:"unknown",cause:o.error??o.message}))}return n.addEventListener("message",s),n.addEventListener("error",i),"start"in n&&n.start(),Rl(r,Re(()=>{n.removeEventListener("message",s),n.removeEventListener("error",i)}))}}),Gve=vh(Lve,Kve),Qve=Due(zve,Gve),Jve=e=>Nue(Qve,Uve(e)),Yve=Jve,Xve=iL(),j0=p8(Xve)(A0),Zve=iL(),Bd=p8(Zve)(A0),Ml=0,gr=ke({global:Bd,client:j0}).annotations({title:"LiveStore.EventSequenceNumber"}),fx=(e,t)=>e.global!==t.global?e.global-t.global:e.client-t.client,Ns=e=>e.client===0?`e${e.global}`:`e${e.global}+${e.client}`,Rb=(e,t)=>e.global===t.global&&e.client===t.client,_o={global:0,client:Ml},Q_=(e,t)=>e.global>t.global||e.global===t.global&&e.client>t.client,Su=(e,t)=>e.global>t.global||e.global===t.global&&e.client>=t.client,$H=(e,t)=>e.global>t.global||e.global===t.global&&e.client>t.client?e:t,$b=(e,t)=>t?{seqNum:{global:e.global,client:e.client+1},parentSeqNum:e}:{seqNum:{global:e.global+1,client:Ml},parentSeqNum:{global:e.global,client:Ml}},IH=e=>{const t=["text","integer","real","blob"];return typeof e=="object"&&e!==null&&"columnType"in e&&t.includes(e.columnType)},f2=Symbol.for("NoDefault"),TH=e=>typeof e=="object"&&e!==null&&"sql"in e&&typeof e.sql=="string",wy=e=>t=>{const n=(t==null?void 0:t.nullable)??!1,r=(t==null?void 0:t.schema)??AH(e),s=n===!0?tl(r):r,i=(t==null?void 0:t.default)===void 0||t.default===f2?re():oe(t.default);return{columnType:e,schema:s,default:i,nullable:n,primaryKey:(t==null?void 0:t.primaryKey)??!1}},ewe=e=>wy(e),io=wy("text"),Is=wy("integer"),twe=wy("real"),PH=wy("blob"),Ib=(e,t)=>n=>{const r=(n==null?void 0:n.nullable)??!1,s=t._tag==="baseSchemaFn"?t.baseSchemaFn(n==null?void 0:n.schema):t.baseSchema,i=r===!0?tl(s):s,o=(n==null?void 0:n.default)===void 0||n.default===f2?re():oe(n.default);return{columnType:e,schema:i,default:o,nullable:r,primaryKey:(n==null?void 0:n.primaryKey)??!1}},OH=Ib("text",{_tag:"baseSchemaFn",baseSchemaFn:e=>Bg(e??Nn)}),nwe=Ib("text",{_tag:"baseSchema",baseSchema:Kye}),rwe=Ib("integer",{_tag:"baseSchema",baseSchema:Ws(it,P8,{decode:e=>new Date(e),encode:e=>e.getTime()})}),swe=Ib("integer",{_tag:"baseSchema",baseSchema:Ws(it,Fl,{decode:e=>e===1,encode:e=>e?1:0})}),AH=e=>{switch(e){case"text":return Y;case"integer":return it;case"real":return it;case"blob":return Sb;default:return wa(e)}},iwe=e=>Array.isArray(e)?Object.fromEntries(e.map(t=>[t.name,t])):e,FH=(e,t,n)=>{const r={_tag:"table",name:e,columns:owe(t),indexes:awe(n??[])};return{name:e,columns:t,indexes:n,ast:r}},NH=e=>ke(Object.fromEntries(e.ast.columns.map(t=>[t.name,t.schema]))).annotations({title:e.name}),DH=e=>ke(Object.fromEntries(e.ast.columns.map(t=>[t.name,t.nullable===!0||t.default._tag==="Some"?Qr(t.schema):t.schema]))).annotations({title:e.name}),owe=e=>Object.entries(e).map(([t,n])=>({_tag:"column",name:t,schema:n.schema,default:n.default,nullable:n.nullable??!1,primaryKey:n.primaryKey??!1,type:{_tag:n.columnType}})),awe=e=>e.map(t=>({_tag:"index",columns:t.columns,name:t.name,unique:t.isUnique??!1})),lwe=Object.freeze(Object.defineProperty({__proto__:null,NoDefault:f2,blob:PH,boolean:swe,column:ewe,datetime:nwe,datetimeInteger:rwe,defaultSchemaForColumnType:AH,insertStructSchemaForTable:DH,integer:Is,isColumnDefinition:IH,isSqlDefaultValue:TH,json:OH,makeDbSchema:iwe,real:twe,structSchemaForTable:NH,table:FH,text:io},Symbol.toStringTag,{value:"Module"})),cwe=e=>{let t=0,n,r;if(e.length===0)return t;for(n=0;n<e.length;n++)r=e.charCodeAt(n),t=(t<<5)-t+r,t=Math.trunc(t);return t},d2=e=>cwe(JSON.stringify(J_(e))),J_=e=>{switch(e._tag){case"table":return{_tag:"table",name:e.name,columns:e.columns.map(t=>J_(t)),indexes:e.indexes.map(t=>J_(t))};case"column":return{_tag:"column",name:e.name,type:e.type._tag,primaryKey:e.primaryKey,nullable:e.nullable,default:e.default};case"index":return{_tag:"index",columns:e.columns,name:e.name,unique:e.unique,primaryKey:e.primaryKey};case"foreignKey":return{_tag:"foreignKey",references:e.references,key:e.key,columns:e.columns};case"dbSchema":return{_tag:"dbSchema",tables:e.tables.map(J_)};default:throw new Error(`Unreachable: ${e}`)}},Vd=Symbol.for("QueryBuilderAst"),nm=Symbol.for("QueryBuilder"),by=e=>_e(e,nm);ke({mergeCounter:it,eventNum:gr});ke({fileName:Y},{key:Y,value:Nn}).annotations({title:"LiveStore.PersistenceInfo"});const pE=ke({done:it,total:it});tt(ke({stage:nt("loading")}),ke({stage:nt("migrating"),progress:pE}),ke({stage:nt("rehydrating"),progress:pE}),ke({stage:nt("syncing"),progress:pE}),ke({stage:nt("done")})).annotations({title:"BootStatus"});const h2=Symbol.for("@livestore/session-id"),Ho=class Ho extends Oo()("LiveStore.UnexpectedError",{cause:Vg,note:Qr(Y),payload:Qr(Nn)}){};p(Ho,"mapToUnexpectedError",t=>t.pipe(Gl(n=>cr(Ho)(n)?n:new Ho({cause:n})),iue(n=>new Ho({cause:n})))),p(Ho,"mapToUnexpectedErrorStream",t=>t.pipe(F_e(n=>cr(Ho)(n)?n:new Ho({cause:n}))));let un=Ho;class U0 extends Oo()("LiveStore.IntentionalShutdownCause",{reason:nt("devtools-reset","devtools-import","adapter-reset","manual")}){}class DCe extends Oo()("LiveStore.StoreInterrupted",{reason:Y}){}class xc extends Oo()("LiveStore.SqliteError",{query:Qr(ke({sql:Y,bindValues:tt(my({key:Y,value:Nn}),Je(Nn))})),code:Qr(tt(it,Y)),cause:Vg,note:Qr(Y)}){}const uwe=ke({tableName:Y,hashes:ke({expected:it,actual:Qr(it)})});ke({migrations:Je(uwe)});const h_=(e,t,n)=>e.length===0?"":`WHERE ${e.map(({col:s,op:i,value:o})=>{if(o===null){if(i!=="="&&i!=="!=")throw new Error(`Unsupported operator for NULL value: ${i}`);return`${s} ${i==="="?"IS":"IS NOT"} NULL`}const a=t.sqliteDef.columns[s];if(a===void 0)throw new Error(`Column ${s} not found`);if(i==="IN"||i==="NOT IN"){if(!Array.isArray(o))return ze(`Expected array value for ${i} operator but got`,o);if(o.length===0)return i==="IN"?"0=1":"1=1";const f=o.map(g=>Jo(a.schema)(g));n.push(...f);const d=f.map(()=>"?").join(", ");return`${s} ${i} (${d})`}else{const f=Jo(a.schema)(o);return n.push(f),`${s} ${i} ?`}}).join(" AND ")}`,gE=e=>!e||e.length===0?"":` RETURNING ${e.join(", ")}`,ON=e=>{const t=[];if(e._tag==="InsertQuery"){const d=Object.keys(e.values),g=d.map(()=>"?").join(", "),_=Jo(e.tableDef.insertSchema)(e.values);d.forEach(E=>{t.push(_[E])});let b="INSERT",k="";if(e.onConflict)if(e.onConflict.action._tag==="replace")b="INSERT OR REPLACE";else if(k=` ON CONFLICT (${e.onConflict.targets.join(", ")}) `,e.onConflict.action._tag==="ignore")k+="DO NOTHING";else{const E=e.onConflict.action.update,y=Object.keys(E);if(y.length===0)throw new Error("No update columns provided for ON CONFLICT DO UPDATE");const m=y.map(v=>E[v]===void 0?`${v} = excluded.${v}`:`${v} = ?`).join(", ");y.forEach(v=>{const w=E[v];if(w!==void 0){const $=e.tableDef.sqliteDef.columns[v];if($===void 0)throw new Error(`Column ${v} not found`);const P=Jo($.schema)(w);t.push(P)}}),k+=`DO UPDATE SET ${m}`}let I=`${b} INTO '${e.tableDef.sqliteDef.name}' (${d.join(", ")}) VALUES (${g})`;return I+=k,I+=gE(e.returning),{query:I,bindValues:t}}if(e._tag==="UpdateQuery"){const d=Object.keys(e.values);if(d.length===0)return console.warn(`UPDATE query requires at least one column to set (for table ${e.tableDef.sqliteDef.name}). Running no-op query instead to skip this update query.`),{query:"SELECT 1",bindValues:[]};const g=Jo(Cye(e.tableDef.rowSchema))(e.values);d.forEach(k=>{t.push(g[k])});let _=`UPDATE '${e.tableDef.sqliteDef.name}' SET ${d.map(k=>`${k} = ?`).join(", ")}`;const b=h_(e.where,e.tableDef,t);return b&&(_+=` ${b}`),_+=gE(e.returning),{query:_,bindValues:t}}if(e._tag==="DeleteQuery"){let d=`DELETE FROM '${e.tableDef.sqliteDef.name}'`;const g=h_(e.where,e.tableDef,t);return g&&(d+=` ${g}`),d+=gE(e.returning),{query:d,bindValues:t}}if(e._tag==="CountQuery")return{query:[`SELECT COUNT(*) as count FROM '${e.tableDef.sqliteDef.name}'`,h_(e.where,e.tableDef,t)].filter(g=>g.length>0).join(" "),bindValues:t};if(e._tag==="RowQuery"){const d=e.tableDef.sqliteDef.columns.id;if(d===void 0)throw new Error("Column id not found for ROW query");const g=e.id===h2?e.id:Jo(d.schema)(e.id);return{query:`SELECT * FROM '${e.tableDef.sqliteDef.name}' WHERE id = ?`,bindValues:[g]}}const r=`SELECT ${e.select.columns.length===0?"*":e.select.columns.join(", ")}`,s=`FROM '${e.tableDef.sqliteDef.name}'`,i=h_(e.where,e.tableDef,t),o=e.orderBy.length>0?`ORDER BY ${e.orderBy.map(({col:d,direction:g})=>`${d} ${g}`).join(", ")}`:"",a=e.limit._tag==="Some"?"LIMIT ?":"",c=e.offset._tag==="Some"?"OFFSET ?":"";return e.offset._tag==="Some"&&t.push(e.offset.value),e.limit._tag==="Some"&&t.push(e.limit.value),{query:[r,s,i,o,c,a].map(d=>d.trim()).filter(d=>d.length>0).join(" "),bindValues:t}},Ar=(e,t=fwe(e))=>{const n={select(){ep(t);const r=[...arguments];if(r.length===1){const[i]=r;return Ar(e,{...t,resultSchemaSingle:t.resultSchemaSingle.pipe(jd(i)),select:{columns:[i]}})}const s=r;return Ar(e,{...t,resultSchemaSingle:s.length===0?t.resultSchemaSingle:t.resultSchemaSingle.pipe(P0(...s)),select:{columns:s}})},where:function(){if(t._tag==="InsertQuery")return tp("Cannot use where with insert");if(t._tag==="RowQuery")return tp("Cannot use where with row");if(arguments.length===1){const c=arguments[0],f=Object.entries(c).filter(([,d])=>d!==void 0).map(([d,g])=>_e(g,"op")&&_e(g,"value")?{col:d,op:g.op,value:g.value}:{col:d,op:"=",value:g});switch(t._tag){case"CountQuery":case"SelectQuery":case"UpdateQuery":case"DeleteQuery":return Ar(e,{...t,where:[...t.where,...f]});default:return wa(t)}}const[r,s,i]=arguments,o=i===void 0?"=":s,a=i===void 0?s:i;switch(t._tag){case"CountQuery":case"SelectQuery":case"UpdateQuery":case"DeleteQuery":return Ar(e,{...t,where:[...t.where,{col:r,op:o,value:a}]});default:return wa(t)}},orderBy(){if(ep(t),arguments.length===0||arguments.length>2)return tp();if(arguments.length===1){const i=arguments[0];return Ar(e,{...t,orderBy:[...t.orderBy,...i]})}const[r,s]=arguments;return Ar(e,{...t,orderBy:[...t.orderBy,{col:r,direction:s}]})},limit:r=>(ep(t),Ar(e,{...t,limit:oe(r)})),offset:r=>(ep(t),Ar(e,{...t,offset:oe(r)})),count:()=>pwe(t)||t._tag==="InsertQuery"||t._tag==="UpdateQuery"||t._tag==="DeleteQuery"?tp():Ar(e,{_tag:"CountQuery",tableDef:e,where:t.where,resultSchema:ke({count:it}).pipe(jd("count"),Je,pp())}),first:r=>(ep(t),t.limit._tag==="Some"?tp(".first() can't be called after .limit()"):Ar(e,{...t,limit:oe(1),pickFirst:(r==null?void 0:r.fallback)!==void 0&&r.fallback!=="throws"?{fallback:r.fallback}:"throws"})),insert:r=>{const s=Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0));return Ar(e,{_tag:"InsertQuery",tableDef:e,values:s,onConflict:void 0,returning:void 0,resultSchema:sE})},onConflict:(r,s,i)=>{const o=Array.isArray(r)?r:[r];dwe(t);const a=c8(s).pipe(nE("ignore",()=>({targets:o,action:{_tag:"ignore"}})),nE("replace",()=>({targets:o,action:{_tag:"replace"}})),nE("update",()=>({targets:o,action:{_tag:"update",update:i}})),u8);return Ar(e,{...t,onConflict:a})},returning:(...r)=>(hwe(t),Ar(e,{...t,returning:r,resultSchema:e.rowSchema.pipe(P0(...r),Je)})),update:r=>{const s=Object.fromEntries(Object.entries(r).filter(([,i])=>i!==void 0));return Ar(e,{_tag:"UpdateQuery",tableDef:e,values:s,where:[],returning:void 0,resultSchema:sE})},delete:()=>Ar(e,{_tag:"DeleteQuery",tableDef:e,where:[],returning:void 0,resultSchema:sE})};return{[nm]:nm,[Vd]:t,ResultType:"only-for-type-inference",asSql:()=>ON(t),toString:()=>{try{return ON(t).query}catch(r){return console.debug("QueryBuilder.toString(): Error converting query builder to string",r,t),"Error converting query builder to string"}},...n}},fwe=e=>({_tag:"SelectQuery",columns:[],pickFirst:!1,select:{columns:[]},orderBy:[],offset:re(),limit:re(),tableDef:e,where:[],resultSchemaSingle:e.rowSchema});function ep(e){if(e._tag!=="SelectQuery")return ze("Expected SelectQuery but got "+e._tag)}function dwe(e){if(e._tag!=="InsertQuery")return ze("Expected InsertQuery but got "+e._tag)}function hwe(e){if(e._tag!=="InsertQuery"&&e._tag!=="UpdateQuery"&&e._tag!=="DeleteQuery")return ze("Expected WriteQuery but got "+e._tag)}const pwe=e=>e._tag==="RowQuery",tp=e=>ze("Invalid query builder"+(e?`: ${e}`:"")),p2=e=>{const t=e[Vd];switch(t._tag){case"SelectQuery":{const n=Je(t.resultSchemaSingle);if(t.pickFirst===!1)return n;if(t.pickFirst==="throws")return n.pipe(pp());{const r=t.pickFirst.fallback();return tt(n,y8(nt(r))).pipe(pp(()=>r))}}case"CountQuery":return ke({count:it}).pipe(jd("count"),Je,pp());case"InsertQuery":case"UpdateQuery":case"DeleteQuery":return t.returning&&t.returning.length>0?t.tableDef.rowSchema.pipe(P0(...t.returning),Je):it;case"RowQuery":return t.tableDef.rowSchema.pipe(jd("value"),Iye({title:`${t.tableDef.sqliteDef.name}.value`}),Je,pp());default:wa(t)}},{blob:qCe,boolean:MCe,column:LCe,datetime:zCe,integer:AN,isColumnDefinition:jCe,json:UCe,real:HCe,text:jr}=lwe,Yl=e=>{const{name:t,columns:n,...r}=e,s=t,i={isClientDocumentTable:!1},o=IH(n)?{value:n}:n,a=FH(s,o,(r==null?void 0:r.indexes)??[]),c=NH(a),f=DH(a),d={sqliteDef:a,options:i,rowSchema:c,insertSchema:f},g=Ar(d);for(const _ of Object.keys(g))d[_]=g[_];return d[Vd]=g[Vd],d[nm]=g[nm],d},Tb="__livestore_schema",gwe=Yl({name:Tb,columns:{tableName:io({primaryKey:!0}),schemaHash:Is({nullable:!1}),updatedAt:io({nullable:!1})}}),H0="__livestore_schema_event_defs",qH=Yl({name:H0,columns:{eventName:io({primaryKey:!0}),schemaHash:Is({nullable:!1}),updatedAt:io({nullable:!1})}}),rm="__livestore_session_changeset",B0=Yl({name:rm,columns:{seqNumGlobal:Is({schema:Bd}),seqNumClient:Is({schema:j0}),changeset:PH({nullable:!0}),debug:OH({nullable:!0})},indexes:[{columns:["seqNumGlobal","seqNumClient"],name:"idx_session_changeset_id"}]}),Pb="__livestore_leader_merge_counter",mwe=Yl({name:Pb,columns:{id:Is({primaryKey:!0,schema:nt(0)}),mergeCounter:Is({primaryKey:!0})}}),sm=[gwe,qH,B0,mwe],MH=e=>sm.some(t=>t.sqliteDef.name===e),Co="eventlog",im=Yl({name:Co,columns:{seqNumGlobal:Is({primaryKey:!0,schema:Bd}),seqNumClient:Is({primaryKey:!0,schema:j0}),parentSeqNumGlobal:Is({schema:Bd}),parentSeqNumClient:Is({schema:j0}),name:io({}),argsJson:io({schema:Bg(Nn)}),clientId:io({}),sessionId:io({}),schemaHash:Is({}),syncMetadataJson:io({schema:Bg(td(Hd))})},indexes:[{columns:["seqNumGlobal"],name:"idx_eventlog_seqNumGlobal"},{columns:["seqNumGlobal","seqNumClient"],name:"idx_eventlog_seqNum"}]}),om="__livestore_sync_status",ywe=Yl({name:om,columns:{head:Is({primaryKey:!0})}}),_we=[im,ywe],FN=tt(Y,it,I8,FT),LH=tt(Je(FN),my({key:Y,value:FN})).pipe(kye("PreparedBindValues")),Ct=(e,...t)=>{let n="";for(const[r,s]of t.entries())n+=e[r]+String(s);return n+e[e.length-1]},oa=(e,t)=>{if(Array.isArray(e))return e;const n={};for(const[r,s]of Object.entries(e))t.includes(r)&&(n[`$${r}`]=s);return n},ff=(e,t,n)=>{const r=e.prepare(t),s=n?oa(n,t):void 0;r.execute(s),r.finalize()},zH=(e,t,n)=>{const r=e.prepare(t),s=r.select(n?oa(n,t):void 0);return r.finalize(),s},Swe=(e,t)=>X(function*(){const n=t.getEventDefInfos(),r=n.filter(s=>!e.eventsDefsMap.has(s.eventName));r.length>0&&(yield*new un({cause:`Missing mutation definitions: ${r.map(s=>s.eventName).join(", ")}`}));for(const[,s]of e.eventsDefsMap){const i=n.find(o=>o.eventName===s.name);vwe(s,t,i)}}),vwe=(e,t,n)=>{const r=c2(e.schema);if(n===void 0){t.setEventDefInfo({schemaHash:r,eventName:e.name});return}r!==n.schemaHash&&t.setEventDefInfo({schemaHash:r,eventName:e.name})},wwe=a0e(()=>new Date().toISOString()),bwe=e=>X(function*(){return yield*V0({db:e,tableAst:qH.sqliteDef.ast,behaviour:"create-if-not-exists"}),{getEventDefInfos:()=>zH(e,Ct`SELECT * FROM ${H0}`),setEventDefInfo:t=>{ff(e,Ct`INSERT OR REPLACE INTO ${H0} (eventName, schemaHash, updatedAt) VALUES ($eventName, $schemaHash, $updatedAt)`,{eventName:t.eventName,schemaHash:t.schemaHash,updatedAt:new Date().toISOString()})}}}),Ewe=({db:e,schema:t,onProgress:n})=>X(function*(){for(const g of sm)yield*V0({db:e,tableAst:g.sqliteDef.ast,behaviour:"create-if-not-exists"});const r=yield*bwe(e);yield*Swe(t,r);const s=zH(e,Ct`SELECT * FROM ${Tb}`),i=Object.fromEntries(s.map(({tableName:g,schemaHash:_})=>[g,_])),o=[...sm,...Array.from(t.state.sqlite.tables.values()).filter(g=>!MH(g.sqliteDef.name))],a=new Set,c=[];for(const g of o){const _=g.sqliteDef.ast,b=_.name,k=i[b],I=d2(_);I!==k&&(a.add({tableAst:_,schemaHash:I}),c.push({tableName:b,hashes:{expected:I,actual:k}}))}let f=0;const d=a.size;for(const{tableAst:g,schemaHash:_}of a)yield*V0({db:e,tableAst:g,schemaHash:_,behaviour:"create-if-not-exists"}),n!==void 0&&(f++,yield*n({done:f,total:d}));return{migrations:c}}),V0=({db:e,tableAst:t,schemaHash:n=d2(t),behaviour:r,skipMetaTable:s=!1})=>X(function*(){const i=t.name,o=Cwe(t);r==="drop-and-recreate"?(ff(e,Ct`drop table if exists '${i}'`),ff(e,Ct`create table if not exists '${i}' (${o}) strict`)):r==="create-if-not-exists"&&ff(e,Ct`create table if not exists '${i}' (${o}) strict`);for(const a of t.indexes)ff(e,kwe(i,a));if(s!==!0){const a=wwe();ff(e,Ct`
209
+ INSERT INTO ${Tb} (tableName, schemaHash, updatedAt) VALUES ($tableName, $schemaHash, $updatedAt)
210
+ ON CONFLICT (tableName) DO UPDATE SET schemaHash = $schemaHash, updatedAt = $updatedAt;
211
+ `,{tableName:i,schemaHash:n,updatedAt:a})}}).pipe(Qe("@livestore/common:migrateTable",{attributes:{"span.label":t.name,tableName:t.name}})),kwe=(e,t)=>{const n=t.unique?"UNIQUE":"";return Ct`create ${n} index if not exists '${t.name}' on '${e}' (${t.columns.join(", ")})`},Cwe=e=>{const t=e.columns.filter(r=>r.primaryKey).map(r=>`'${r.name}'`),n=e.columns.map(xwe);return t.length>0&&n.push(`PRIMARY KEY (${t.join(", ")})`),n.join(", ")},xwe=e=>{const t=e.type._tag,n=e.nullable===!1?"not null":"",r=(()=>{if(e.default._tag==="None")return"";if(e.default.value===null)return"default null";if(TH(e.default.value))return`default ${e.default.value.sql}`;const i=Jo(e.schema)(e.default.value);return t==="text"?`default '${i}'`:`default ${i}`})();return`'${e.name}' ${t} ${n} ${r}`},g2=e=>{const{name:t,schema:n,...r}=e,s=i=>{const o=dye(n)(i);return o._tag==="Left"&&ze(`Invalid event args for event '${t}':`,o.left.message,`
212
+ `),{name:t,args:i}};return Object.defineProperty(s,"name",{value:t}),Object.defineProperty(s,"schema",{value:n}),Object.defineProperty(s,"encoded",{value:i=>({name:t,args:i})}),Object.defineProperty(s,"options",{value:{clientOnly:(r==null?void 0:r.clientOnly)??!1,facts:r!=null&&r.facts?(i,o)=>{var c,f;const a=r.facts(i,o);return{modify:{set:(c=a.modify)!=null&&c.set?new Set(a.modify.set):new Set,unset:(f=a.modify)!=null&&f.unset?new Set(a.modify.unset):new Set},require:a.require?new Set(a.require):new Set}}:void 0,derived:(r==null?void 0:r.derived)??!1}}),s},dx=(e,t)=>t,W0=g2({name:"livestore.RawSql",schema:ke({sql:Y,bindValues:Qr(my({key:Y,value:Nn})),writeTables:Qr(jT(Y))}),clientOnly:!0,derived:!0}),Rwe=dx(W0,({sql:e,bindValues:t,writeTables:n})=>({sql:e,bindValues:t??{},writeTables:n})),m2=e=>e.options.isClientDocumentTable===!0,NN=Symbol("ClientDocumentTableDef"),$we=Symbol.for("livestore.LiveStoreSchema"),Iwe=e=>{var s;const t=e.state,n=e.state.sqlite.tables;for(const i of sm)n.set(i.sqliteDef.name,i);const r=new Map;if(Z8(e.events))for(const i of e.events)r.set(i.name,i);else for(const i of Object.values(e.events??{}))r.has(i.name)&&ze(`Duplicate event name: ${i.name}. Please use unique names for events.`),r.set(i.name,i);r.set(W0.name,W0);for(const i of n.values())m2(i)&&r.has(i.set.name)===!1&&r.set(i.set.name,i.set);return{LiveStoreSchemaSymbol:$we,_DbSchemaType:Symbol.for("livestore.DbSchemaType"),_EventDefMapType:Symbol.for("livestore.EventDefMapType"),state:t,eventsDefsMap:r,devtools:{alias:((s=e.devtools)==null?void 0:s.alias)??"default"}}},Di=(e,t)=>{const n=e.eventsDefsMap.get(t);if(n===void 0)return ze(`No mutation definition found for \`${t}\`.`);const r=e.state.materializers.get(t);return r===void 0?ze(`No materializer found for \`${t}\`.`):{eventDef:n,materializer:r}},y2=({eventDef:e,materializer:t,dbState:n,event:r})=>{var c;const s=r.decoded===void 0?k0(e.schema)(r.encoded.args):r.decoded.args,i=r0e((c=r.decoded)==null?void 0:c.args)?void 0:IT(e.schema)(r.decoded.args);return UH(t(s,{eventDef:e,query:f=>{if(by(f)){const{query:d,bindValues:g}=f.asSql(),_=n.select(d,oa(g,d)),b=p2(f);return Ld(b)(_)}else{const{query:d,bindValues:g}=f;return n.select(d,oa(g,d))}},currentFacts:new Map})).map(f=>{const d=f.sql,g=typeof f=="string"?i:f.bindValues,_=typeof f=="string"?void 0:f.writeTables;return{statementSql:d,bindValues:oa(g??{},d),writeTables:_}})},Twe=({schema:e,dbState:t})=>n=>{if(ko()){const{eventDef:r,materializer:s}=Di(e,n.name),i=y2({eventDef:r,materializer:s,dbState:t,event:{decoded:void 0,encoded:n}});return oe(tn(JSON.stringify(i)))}return re()},jH=e=>tn(JSON.stringify(e)),UH=e=>{if(Z8(e))return e.flatMap(UH);if(by(e)){const{query:t,bindValues:n}=e.asSql();return[{sql:t,bindValues:n,writeTables:void 0}]}else return typeof e=="string"?[{sql:e,bindValues:{},writeTables:void 0}]:[{sql:e.sql,bindValues:e.bindValues,writeTables:e.writeTables}]},Pwe=(e,t)=>{hx(e,h2,t)},hx=(e,t,n)=>{if(Array.isArray(e))for(const r in e)e[r]===t?e[r]=n:hx(e[r],t,n);else if(typeof e=="object"&&e!==null)for(const r in e)e[r]===t?e[r]=n:hx(e[r],t,n)},Owe=e=>{const t=Array.isArray(e.tables)?e.tables:Object.values(e.tables),n=new Map;for(const i of t){const o=i.sqliteDef;n.has(o.ast.name)&&ze(`Duplicate table name: ${o.ast.name}. Please use unique names for tables.`),n.set(o.ast.name,i)}for(const i of sm)n.set(i.sqliteDef.name,i);const r=new Map;for(const[i,o]of Object.entries(e.materializers))r.set(i,o);r.set(W0.name,Rwe);for(const i of t)m2(i)&&r.set(i[NN].derived.setEventDef.name,i[NN].derived.setMaterializer);const s=d2({_tag:"dbSchema",tables:[...n.values()].map(i=>i.sqliteDef.ast)});return{sqlite:{tables:n,migrations:e.migrations??{strategy:"auto"},hash:s},materializers:r}};ke({name:Y,args:Nn,seqNum:gr,parentSeqNum:gr,clientId:Y,sessionId:Y}).annotations({title:"LiveStoreEvent.AnyDecoded"});ke({name:Y,args:Nn,seqNum:gr,parentSeqNum:gr,clientId:Y,sessionId:Y}).annotations({title:"LiveStoreEvent.AnyEncoded"});const Awe=ke({name:Y,args:Nn,seqNum:Bd,parentSeqNum:Bd,clientId:Y,sessionId:Y}).annotations({title:"LiveStoreEvent.AnyEncodedGlobal"}),Fwe=ke({name:Y,args:Nn}),HH=e=>tt(...[...e.eventsDefsMap.values()].map(t=>ke({name:nt(t.name),args:t.schema,seqNum:gr,parentSeqNum:gr,clientId:Y,sessionId:Y}))).annotations({title:"EventDef"}),BH=eH(HH),Kp=class Kp extends Mu("LiveStoreEvent.EncodedWithMeta")({name:Y,args:Nn,seqNum:gr,parentSeqNum:gr,clientId:Y,sessionId:Y,meta:ke({sessionChangeset:tt(Ye("sessionChangeset",{data:I8,debug:Nn.pipe(Qr)}),Ye("no-op",{}),Ye("unset",{})),syncMetadata:td(Hd),materializerHashLeader:td(it),materializerHashSession:td(it)}).pipe(C8,Qr,b8({constructor:()=>({sessionChangeset:{_tag:"unset"},syncMetadata:re(),materializerHashLeader:re(),materializerHashSession:re()}),decoding:()=>({sessionChangeset:{_tag:"unset"},syncMetadata:re(),materializerHashLeader:re(),materializerHashSession:re()})}))}){constructor(){super(...arguments);p(this,"toJSON",()=>({seqNum:`${Ns(this.seqNum)} → ${Ns(this.parentSeqNum)} (${this.clientId}, ${this.sessionId})`,name:this.name,args:this.args}));p(this,"rebase",(n,r)=>new Kp({...this,...$b(n,r)}));p(this,"toGlobal",()=>({...this,seqNum:this.seqNum.global,parentSeqNum:this.parentSeqNum.global}))}};p(Kp,"fromGlobal",(n,r)=>new Kp({...n,seqNum:{global:n.seqNum,client:Ml},parentSeqNum:{global:n.parentSeqNum,client:Ml},meta:{sessionChangeset:{_tag:"unset"},syncMetadata:r.syncMetadata,materializerHashLeader:r.materializerHashLeader,materializerHashSession:r.materializerHashSession}}));let Rr=Kp;const K0=(e,t)=>e.seqNum.global===t.seqNum.global&&e.seqNum.client===t.seqNum.client&&e.name===t.name&&e.clientId===t.clientId&&e.sessionId===t.sessionId&&JSON.stringify(e.args)===JSON.stringify(t.args),Nwe=({dbEventlog:e,schema:t,onProgress:n,materializeEvent:r})=>X(function*(){const s=e.select(`SELECT COUNT(*) AS count FROM ${Co}`)[0].count,i=eH(d=>c2(d.schema)),o=d=>X(function*(){const g=Di(t,d.name);i(g.eventDef)!==d.schemaHash&&(yield*Ps(`Schema hash mismatch for event definition ${d.name}. Trying to materialize event anyway.`));const _=JSON.parse(d.argsJson);yield*jg(g.eventDef.schema)(_).pipe(Gl(k=>un.make({cause:k,note:`There was an error during rematerializing from the eventlog while decoding
213
+ the persisted event args for event definition "${d.name}".
214
+ This likely means the schema has changed in an incompatible way.
215
+ `})));const b=Rr.make({seqNum:{global:d.seqNumGlobal,client:d.seqNumClient},parentSeqNum:{global:d.parentSeqNumGlobal,client:d.parentSeqNumClient},name:d.name,args:_,clientId:d.clientId,sessionId:d.sessionId});yield*r(b,{skipEventlog:!0})}).pipe(Qe("@livestore/common:rematerializeFromEventlog:processEvent")),a=100,c=e.prepare(Ct`\
216
+ SELECT * FROM ${Co}
217
+ WHERE seqNumGlobal > $seqNumGlobal OR (seqNumGlobal = $seqNumGlobal AND seqNumClient > $seqNumClient)
218
+ ORDER BY seqNumGlobal ASC, seqNumClient ASC
219
+ LIMIT ${a}
220
+ `);let f=0;yield*z_e({_tag:"Initial "},d=>{if(Fc(d)&&d.length===0)return re();const g=Fc(d)?jY(d).pipe(hl(k=>({global:k.seqNumGlobal,client:k.seqNumClient})),Yt(()=>_o)):_o,_=da(c.select({$seqNumGlobal:g==null?void 0:g.global,$seqNumClient:g==null?void 0:g.client})),b=Fc(d)?d:Ut();return oe([b,_])}).pipe(k_e({capacity:2}),Un(d=>X(function*(){yield*o(d),f++,yield*n({done:f,total:s})})),Sn)}).pipe(t2("@livestore/common:rematerializeFromEventlog"),Qe("@livestore/common:rematerializeFromEventlog"));class BCe extends Oo()("IsOfflineError",{}){}class VCe extends Oo()("InvalidPushError",{reason:tt(Ye("Unexpected",{message:Y}),Ye("ServerAhead",{minimumExpectedNum:it,providedNum:it}))}){}class WCe extends Oo()("InvalidPullError",{message:Y}){}class VH extends Oo()("LeaderAheadError",{minimumExpectedNum:gr,providedNum:gr}){}class oo extends Mu("SyncState")({pending:Je(Rr),upstreamHead:gr,localHead:gr}){constructor(){super(...arguments);p(this,"toJSON",()=>({pending:this.pending.map(n=>n.toJSON()),upstreamHead:Ns(this.upstreamHead),localHead:Ns(this.localHead)}))}}class G0 extends Ye("upstream-rebase",{rollbackEvents:Je(Rr),newEvents:Je(Rr)}){}class jc extends Ye("upstream-advance",{newEvents:Je(Rr)}){}class Dwe extends Ye("local-push",{newEvents:Je(Rr)}){}class qwe extends tt(G0,jc,Dwe){}class Mwe extends tt(G0,jc){}class Ob extends Mu("MergeContext")({payload:qwe,syncState:oo}){constructor(){super(...arguments);p(this,"toJSON",()=>({payload:c8(this.payload).pipe(rE("local-push",()=>({_tag:"local-push",newEvents:this.payload.newEvents.map(r=>r.toJSON())})),rE("upstream-advance",()=>({_tag:"upstream-advance",newEvents:this.payload.newEvents.map(r=>r.toJSON())})),rE("upstream-rebase",r=>({_tag:"upstream-rebase",newEvents:r.newEvents.map(s=>s.toJSON()),rollbackEvents:r.rollbackEvents.map(s=>s.toJSON())})),u8),syncState:this.syncState.toJSON()}))}}class mp extends Mu("MergeResultAdvance")({_tag:nt("advance"),newSyncState:oo,newEvents:Je(Rr),confirmedEvents:Je(Rr),mergeContext:Ob}){constructor(){super(...arguments);p(this,"toJSON",()=>({_tag:this._tag,newSyncState:this.newSyncState.toJSON(),newEvents:this.newEvents.map(n=>n.toJSON()),confirmedEvents:this.confirmedEvents.map(n=>n.toJSON()),mergeContext:this.mergeContext.toJSON()}))}}class px extends Mu("MergeResultRebase")({_tag:nt("rebase"),newSyncState:oo,newEvents:Je(Rr),rollbackEvents:Je(Rr),mergeContext:Ob}){constructor(){super(...arguments);p(this,"toJSON",()=>({_tag:this._tag,newSyncState:this.newSyncState.toJSON(),newEvents:this.newEvents.map(n=>n.toJSON()),rollbackEvents:this.rollbackEvents.map(n=>n.toJSON()),mergeContext:this.mergeContext.toJSON()}))}}class WH extends Mu("MergeResultReject")({_tag:nt("reject"),expectedMinimumId:gr,mergeContext:Ob}){constructor(){super(...arguments);p(this,"toJSON",()=>({_tag:this._tag,expectedMinimumId:Ns(this.expectedMinimumId),mergeContext:this.mergeContext.toJSON()}))}}class KH extends Mu("MergeResultUnexpectedError")({_tag:nt("unexpected-error"),cause:un}){}class KCe extends tt(mp,px,WH,KH){}const gx=e=>{if(js)debugger;return KH.make({_tag:"unexpected-error",cause:new un({cause:e})})},Q0=({syncState:e,payload:t,isClientEvent:n,isEqualEvent:r,ignoreClientEvents:s=!1})=>{var o,a,c;GH(e),Lwe(t);const i=Ob.make({payload:t,syncState:e});switch(t._tag){case"upstream-rebase":{const f=[...t.rollbackEvents,...e.pending],d=((o=t.newEvents.at(-1))==null?void 0:o.seqNum)??e.upstreamHead,g=DN({events:e.pending,baseEventSequenceNumber:d,isClientEvent:n});return ic(px.make({_tag:"rebase",newSyncState:new oo({pending:g,upstreamHead:d,localHead:((a=g.at(-1))==null?void 0:a.seqNum)??d}),newEvents:[...t.newEvents,...g],rollbackEvents:f,mergeContext:i}))}case"upstream-advance":{if(t.newEvents.length===0)return ic(mp.make({_tag:"advance",newSyncState:new oo({pending:e.pending,upstreamHead:e.upstreamHead,localHead:e.localHead}),newEvents:[],confirmedEvents:[],mergeContext:i}));for(let g=1;g<t.newEvents.length;g++)if(Q_(t.newEvents[g-1].seqNum,t.newEvents[g].seqNum))return gx(`Events must be sorted in ascending order by event number. Received: [${t.newEvents.map(_=>Ns(_.seqNum)).join(", ")}]`);if(Q_(e.upstreamHead,t.newEvents[0].seqNum)||Rb(e.upstreamHead,t.newEvents[0].seqNum))return gx(`Incoming events must be greater than upstream head. Expected greater than: ${Ns(e.upstreamHead)}. Received: [${t.newEvents.map(g=>Ns(g.seqNum)).join(", ")}]`);const f=t.newEvents.at(-1).seqNum,d=mx({existingEvents:e.pending,incomingEvents:t.newEvents,isEqualEvent:r,isClientEvent:n,ignoreClientEvents:s});if(d===-1){const g=new Set(e.pending.map(E=>`${E.seqNum.global},${E.seqNum.client}`)),_=t.newEvents.filter(E=>!g.has(`${E.seqNum.global},${E.seqNum.client}`));let b=0;const[k,I]=_M(e.pending,(E,y)=>{if(s&&n(E))return b++,!1;const m=t.newEvents.at(y-b);return m?r(E,m)===!1:!0});return ic(mp.make({_tag:"advance",newSyncState:new oo({pending:I,upstreamHead:f,localHead:((c=I.at(-1))==null?void 0:c.seqNum)??$H(e.localHead,f)}),newEvents:_,confirmedEvents:k,mergeContext:i}))}else{const g=e.pending.slice(d),_=DN({events:g,baseEventSequenceNumber:f,isClientEvent:n}),b=mx({existingEvents:t.newEvents,incomingEvents:e.pending,isEqualEvent:r,isClientEvent:n,ignoreClientEvents:s});return ic(px.make({_tag:"rebase",newSyncState:new oo({pending:_,upstreamHead:f,localHead:_.at(-1).seqNum}),newEvents:[...t.newEvents.slice(b),..._],rollbackEvents:g,mergeContext:i}))}}case"local-push":{if(t.newEvents.length===0)return ic(mp.make({_tag:"advance",newSyncState:e,newEvents:[],confirmedEvents:[],mergeContext:i}));const f=t.newEvents.at(0);if(Q_(f.seqNum,e.localHead)===!1){const g=$b(e.localHead,!0).seqNum;return ic(WH.make({_tag:"reject",expectedMinimumId:g,mergeContext:i}))}else return ic(mp.make({_tag:"advance",newSyncState:new oo({pending:[...e.pending,...t.newEvents],upstreamHead:e.upstreamHead,localHead:t.newEvents.at(-1).seqNum}),newEvents:t.newEvents,confirmedEvents:[],mergeContext:i}))}default:wa(t)}},mx=({existingEvents:e,incomingEvents:t,isEqualEvent:n,isClientEvent:r,ignoreClientEvents:s})=>{if(s){const i=e.filter(c=>!r(c)),o=mx({existingEvents:i,incomingEvents:t,isEqualEvent:n,isClientEvent:r,ignoreClientEvents:!1});if(o===-1)return-1;const a=e[o].seqNum;return e.findIndex(c=>Rb(c.seqNum,a))}return e.findIndex((i,o)=>{const a=t[o];return a&&!n(i,a)})},DN=({events:e,baseEventSequenceNumber:t,isClientEvent:n})=>{let r=t;return e.map(s=>{const i=n(s),o=s.rebase(r,i);return r=o.seqNum,o})},Lwe=e=>{for(let t=1;t<e.newEvents.length;t++)if(Su(e.newEvents[t-1].seqNum,e.newEvents[t].seqNum))return gx(`Events must be ordered in monotonically ascending order by eventNum. Received: [${e.newEvents.map(n=>Ns(n.seqNum)).join(", ")}]`)},GH=e=>{for(let t=0;t<e.pending.length;t++){const n=e.pending[t],r=e.pending[t+1];if(r===void 0)break;Su(n.seqNum,r.seqNum)&&ze(`Events must be ordered in monotonically ascending order by eventNum. Received: [${e.pending.map(i=>Ns(i.seqNum)).join(", ")}]`,{event:n,nextEvent:r}),r.seqNum.global>n.seqNum.global?r.seqNum.client!==0&&ze(`New global events must point to clientId 0 in the parentSeqNum. Received: (${Ns(r.seqNum)})`,e.pending,{event:n,nextEvent:r}):Rb(r.parentSeqNum,n.seqNum)===!1&&ze("Events must be linked in a continuous chain via the parentSeqNum",e.pending,{event:n,nextEvent:r})}},ic=e=>(e._tag==="unexpected-error"||e._tag==="reject"||(GH(e.newSyncState),Q_(e.newSyncState.upstreamHead,e.newSyncState.localHead)&&ze("Local head must be greater than or equal to upstream head",{localHead:e.newSyncState.localHead,upstreamHead:e.newSyncState.upstreamHead}),Su(e.newSyncState.localHead,e.mergeContext.syncState.localHead)===!1&&ze("New local head must be greater than or equal to the previous local head",{localHead:e.newSyncState.localHead,previousLocalHead:e.mergeContext.syncState.localHead}),Su(e.newSyncState.upstreamHead,e.mergeContext.syncState.upstreamHead)===!1&&ze("New upstream head must be greater than or equal to the previous upstream head",{upstreamHead:e.newSyncState.upstreamHead,previousUpstreamHead:e.mergeContext.syncState.upstreamHead})),e),zwe=({schema:e,clientSession:t,runtime:n,materializeEvent:r,rollback:s,refreshTables:i,span:o,params:a,confirmUnsavedChanges:c})=>{const f=BH(e),d={current:new oo({localHead:t.leaderThread.initialState.leaderHead,upstreamHead:t.leaderThread.initialState.leaderHead,pending:[]})},g=dr().pipe(ur),_=m=>Di(e,m.name).eventDef.options.clientOnly,b=YC().pipe(ur),k=(m,{otelContext:v})=>{let w=d.current.localHead;const $=m.map(({name:A,args:z})=>{const D=Di(e,A),W=$b(w,D.eventDef.options.clientOnly);return w=W.seqNum,new Rr(IT(f)({name:A,args:z,...W,clientId:t.clientId,sessionId:t.sessionId}))}),P=Q0({syncState:d.current,payload:{_tag:"local-push",newEvents:$},isClientEvent:_,isEqualEvent:K0});if(P._tag==="unexpected-error")return ze("Unexpected error in client-session-sync-processor",P.cause);if(o.addEvent("local-push",{batchSize:$.length,mergeResult:as?JSON.stringify(P):void 0}),P._tag!=="advance")return ze(`Expected advance, got ${P._tag}`);d.current=P.newSyncState,g.offer(P.newSyncState).pipe(ur);const O=new Set;for(const A of P.newEvents){const z=Ld(f)(A),{writeTables:D,sessionChangeset:W,materializerHash:le}=r(z,{otelContext:v,withChangeset:!0,materializerHashLeader:re()});for(const M of D)O.add(M);A.meta.sessionChangeset=W,A.meta.materializerHashSession=le}return kc(b,$).pipe(ur),{writeTables:O}},I={rebaseCount:0,advanceCount:0,rejectCount:0},E=ss.setSpan(Xs.active(),o),y=X(function*(){if(c&&typeof window<"u"&&typeof window.addEventListener=="function"){const $=P=>{d.current.pending.length>0&&P.preventDefault()};yield*Rt(Re(()=>window.addEventListener("beforeunload",$)),()=>Re(()=>window.removeEventListener("beforeunload",$)))}const m=yield*RT(),v=X(function*(){const $=yield*GT(b,1,a.leaderPushBatchSize);yield*t.leaderThread.events.push($).pipe(_h("LeaderAheadError",()=>(I.rejectCount++,XC(b))))}).pipe(Nd,Jt,st);yield*Md(m,v);const w=()=>{var $;return(($=t.sqliteDb.select(Ct`SELECT mergeCounter FROM ${Pb} WHERE id = 0`)[0])==null?void 0:$.mergeCounter)??0};yield*WT(()=>t.leaderThread.events.pull({cursor:{mergeCounter:w(),eventNum:d.current.localHead}})).pipe(Un(({payload:$,mergeCounter:P})=>X(function*(){t.devtools.enabled&&(yield*t.devtools.pullLatch.await);const O=Q0({syncState:d.current,payload:$,isClientEvent:_,isEqualEvent:K0});if(O._tag==="unexpected-error")return yield*zs(O.cause);if(O._tag==="reject")return ze("Unexpected reject in client-session-sync-processor",O);if(d.current=O.newSyncState,g.offer(O.newSyncState).pipe(ur),O._tag==="rebase"){o.addEvent("merge:pull:rebase",{payloadTag:$._tag,payload:as?JSON.stringify($):void 0,newEventsCount:O.newEvents.length,rollbackCount:O.rollbackEvents.length,res:as?JSON.stringify(O):void 0,leaderMergeCounter:P}),I.rebaseCount++,yield*Q6(m),yield*XC(b),yield*Md(m,v),js&&ni("merge:pull:rebase: rollback",O.rollbackEvents.length,...O.rollbackEvents.slice(0,10).map(z=>z.toJSON()),{leaderMergeCounter:P}).pipe(Hn(n),ur);for(let z=O.rollbackEvents.length-1;z>=0;z--){const D=O.rollbackEvents[z];D.meta.sessionChangeset._tag!=="no-op"&&D.meta.sessionChangeset._tag!=="unset"&&(s(D.meta.sessionChangeset.data),D.meta.sessionChangeset={_tag:"unset"})}yield*kc(b,O.newSyncState.pending)}else o.addEvent("merge:pull:advance",{payloadTag:$._tag,payload:as?JSON.stringify($):void 0,newEventsCount:O.newEvents.length,res:as?JSON.stringify(O):void 0,leaderMergeCounter:P}),I.advanceCount++;if(O.newEvents.length===0)return;const A=new Set;for(const z of O.newEvents){const D=Ld(f)(z),{writeTables:W,sessionChangeset:le,materializerHash:M}=r(D,{otelContext:E,withChangeset:!0,materializerHashLeader:z.meta.materializerHashLeader});for(const U of W)A.add(U);z.meta.sessionChangeset=le,z.meta.materializerHashSession=M}i(A)}).pipe(st,sa(O=>t.shutdown(O)))),Sn,Nd,Jt,Qe("client-session-sync-processor:pull"),st,Dt)});return{push:k,boot:y,syncState:yy({get:X(function*(){const m=d.current;return d===void 0?ze("Not initialized"):m}),changes:va(g)}),debug:{print:()=>X(function*(){console.log("debugInfo",I),console.log("syncState",d.current);const m=yield*ZC(b);console.log("pushQueueSize",m);const v=yield*X_e(b);console.log("pushQueueItems",v.map(w=>w.toJSON()))}).pipe(Hn(n),ur),debugInfo:()=>I}}},jwe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let br=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=jwe[n[e]&63];return t};const QH=Ye("RequestSessions",{}),JH=Ye("SessionInfo",{storeId:Y,clientId:Y,sessionId:Y,schemaAlias:Y,isLeader:Fl}),YH=tt(QH,JH),XH=({webChannel:e,sessionInfo:t})=>X(function*(){yield*e.send(t),yield*e.listen.pipe(Dl(),Ui(cr(QH)),Un(()=>e.send(t)),Sn)});var bi,cm;class J0{constructor(t){Ft(this,bi,new Map);Ft(this,cm,void 0);p(this,"onEvict");p(this,"set",(t,n)=>{if(ge(this,bi).set(t,n),ge(this,bi).size>ge(this,cm)){const r=ge(this,bi).keys().next().value,s=ge(this,bi).get(r);ge(this,bi).delete(r),this.onEvict&&this.onEvict(r,s)}});p(this,"get",t=>ge(this,bi).get(t));p(this,"delete",t=>{ge(this,bi).delete(t)});p(this,"keys",()=>ge(this,bi).keys());ec(this,cm,t)}}bi=new WeakMap,cm=new WeakMap;var Rc,ev,hCe;class Uwe{constructor(t){Ft(this,Rc,void 0);Ft(this,ev,t=>{this.onEvict&&this.onEvict(t)});p(this,"onEvict");p(this,"add",t=>{ge(this,Rc).set(t,t)});p(this,hCe,()=>ge(this,Rc).keys());ec(this,Rc,new J0(t)),ge(this,Rc).onEvict=ge(this,ev)}}hCe=Symbol.iterator,Rc=new WeakMap,ev=new WeakMap;var ks,pCe;const tv=class tv{constructor(t){Ft(this,ks,[]);p(this,"sizeLimit");p(this,"onEvict");p(this,"push",t=>{if(ge(this,ks).push(t),ge(this,ks).length>this.sizeLimit){const n=ge(this,ks).shift();n&&this.onEvict&&this.onEvict(n)}});p(this,"get",t=>ge(this,ks)[t]);p(this,"delete",t=>{ge(this,ks).splice(t,1)});p(this,pCe,()=>ge(this,ks)[Symbol.iterator]());p(this,"map",t=>ge(this,ks).map(t));p(this,"clear",()=>{ec(this,ks,[])});p(this,"sort",t=>ge(this,ks).sort(t));this.sizeLimit=t}get length(){return ge(this,ks).length}};pCe=Symbol.iterator,ks=new WeakMap,p(tv,"make",(t,n=[])=>{const r=new tv(t);for(const s of n)r.push(s);return r});let fo=tv;const Hwe=ke({queryStr:Y,bindValues:Ug(LH),durationMs:it,rowsCount:Ug(it),queriedTables:jT(Y),startTimePerfNow:it}),Bwe=e=>Jl([e],{decode:t=>(n,r,s)=>{if(n instanceof fo){const i=Ph(Je(t))([...n],r);return Br(i,o=>fo.make(n.sizeLimit,o))}return Al(new Fn(s,n))},encode:t=>(n,r,s)=>{if(n instanceof fo){const i=qu(Je(t))([...n],r);return Br(i,o=>fo.make(n.sizeLimit,o))}return Al(new Fn(s,n))}},{description:`BoundArray<${Oh(e)}>`,pretty:()=>t=>`BoundArray(${t.length})`,arbitrary:()=>t=>t.anything(),equivalence:()=>(t,n)=>t===n}),qN=e=>Ws(ke({size:it,items:Je(e)}),Bwe(zi(e)),{encode:t=>({size:t.sizeLimit,items:[...t]}),decode:t=>fo.make(t.size,t.items)}),_2=ke({slowQueries:qN(Hwe),queryFrameDuration:it,queryFrameCount:it,events:qN(y8(Y,Nn))});C8(_2);const Hr="0.3.1",Vwe=ke({isConnected:Fl,timestampMs:it,latchClosed:Fl}),Vp=Y,S2=Y,ZH=Y,Y_=nt(Hr),Ab=(e,t)=>Ye(e,{liveStoreVersion:Y_,...t}).annotations({identifier:e}),Wwe=(e,t)=>Ab(e,{clientId:S2,...t}),Kwe=(e,t)=>Ab(e,{clientId:S2,sessionId:ZH,...t}),Wn=(e,t)=>Ab(e,{clientId:S2,sessionId:ZH,requestId:Vp,...t}),bn=(e,t)=>Wwe(e,{requestId:Vp,...t}),v2=(e,t)=>{const n=Ye(`${e}.Response.Success`,{requestId:Vp,liveStoreVersion:Y_,...t.success}).annotations({identifier:`${e}.Response.Success`}),r=t.error?Ye(`${e}.Response.Error`,{requestId:Vp,liveStoreVersion:Y_,...t.error}).annotations({identifier:`${e}.Response.Error`}):gb;return{Request:Ye(`${e}.Request`,{requestId:Vp,liveStoreVersion:Y_,...t.payload}).annotations({identifier:`${e}.Request`}),Response:tt(n,r),Success:n,Error:r}};class Gwe extends Wn("LSD.ClientSession.DebugInfoReq",{}){}class e5 extends Wn("LSD.ClientSession.DebugInfoRes",{debugInfo:_2}){}class Qwe extends Wn("LSD.ClientSession.DebugInfoHistorySubscribe",{subscriptionId:Y}){}class t5 extends Wn("LSD.ClientSession.DebugInfoHistoryRes",{debugInfoHistory:Je(_2),subscriptionId:Y}){}class Jwe extends Wn("LSD.ClientSession.DebugInfoHistoryUnsubscribe",{subscriptionId:Y}){}class Ywe extends Wn("LSD.ClientSession.DebugInfoResetReq",{}){}class n5 extends Wn("LSD.ClientSession.DebugInfoResetRes",{}){}class Xwe extends Wn("LSD.ClientSession.DebugInfoRerunQueryReq",{queryStr:Y,bindValues:Ug(LH),queriedTables:jT(Y)}){}class r5 extends Wn("LSD.ClientSession.DebugInfoRerunQueryRes",{}){}let Zwe=class extends Wn("LSD.ClientSession.SyncHeadSubscribe",{subscriptionId:Y}){},ebe=class extends Wn("LSD.ClientSession.SyncHeadUnsubscribe",{subscriptionId:Y}){},s5=class extends Wn("LSD.ClientSession.SyncHeadRes",{local:gr,upstream:gr,subscriptionId:Y}){};class tbe extends Wn("LSD.ClientSession.ReactivityGraphSubscribe",{includeResults:Fl,subscriptionId:Y}){}class nbe extends Wn("LSD.ClientSession.ReactivityGraphUnsubscribe",{subscriptionId:Y}){}class i5 extends Wn("LSD.ClientSession.ReactivityGraphRes",{reactivityGraph:Nn,subscriptionId:Y}){}class rbe extends Wn("LSD.ClientSession.LiveQueriesSubscribe",{subscriptionId:Y}){}class sbe extends Wn("LSD.ClientSession.LiveQueriesUnsubscribe",{subscriptionId:Y}){}class ibe extends ke({_tag:nt("computed","db","graphql","signal"),id:it,label:Y,hash:Y,runs:it,executionTimes:Je(it),lastestResult:Nn,activeSubscriptions:Je(ke({frames:Je(ke({name:Y,filePath:Y}))}))}){}class o5 extends Wn("LSD.ClientSession.LiveQueriesRes",{liveQueries:Je(ibe),subscriptionId:Y}){}let obe=class extends Wn("LSD.ClientSession.Ping",{}){},a5=class extends Wn("LSD.ClientSession.Pong",{}){},w2=class extends Kwe("LSD.ClientSession.Disconnect",{}){};const abe=tt(Gwe,Qwe,Jwe,Ywe,Xwe,tbe,nbe,rbe,sbe,w2,obe,Zwe,ebe).annotations({identifier:"LSD.ClientSession.MessageToApp"}),lbe=tt(e5,t5,n5,r5,i5,o5,w2,a5,s5).annotations({identifier:"LSD.ClientSession.MessageFromApp"});class exe extends bn("LSD.Leader.ResetAllDataReq",{mode:nt("all-data","only-app-db")}){}class cbe extends bn("LSD.Leader.DatabaseFileInfoReq",{}){}class MN extends ke({fileSize:it,persistenceInfo:ke({fileName:Y},{key:Y,value:Nn})}){}class l5 extends bn("LSD.Leader.DatabaseFileInfoRes",{state:MN,eventlog:MN}){}class ube extends bn("LSD.Leader.NetworkStatusSubscribe",{subscriptionId:Y}){}class fbe extends bn("LSD.Leader.NetworkStatusUnsubscribe",{subscriptionId:Y}){}class c5 extends bn("LSD.Leader.NetworkStatusRes",{networkStatus:Vwe,subscriptionId:Y}){}class dbe extends bn("LSD.Leader.SyncingInfoReq",{}){}class u5 extends ke({enabled:Fl,metadata:my({key:Y,value:Nn})}){}class f5 extends bn("LSD.Leader.SyncingInfoRes",{syncingInfo:u5}){}class hbe extends bn("LSD.Leader.SyncHistorySubscribe",{subscriptionId:Y}){}class pbe extends bn("LSD.Leader.SyncHistoryUnsubscribe",{subscriptionId:Y}){}class d5 extends bn("LSD.Leader.SyncHistoryRes",{eventEncoded:Awe,metadata:td(Hd),subscriptionId:Y}){}class gbe extends bn("LSD.Leader.SyncHeadSubscribe",{subscriptionId:Y}){}class mbe extends bn("LSD.Leader.SyncHeadUnsubscribe",{subscriptionId:Y}){}class h5 extends bn("LSD.Leader.SyncHeadRes",{local:gr,upstream:gr,subscriptionId:Y}){}class ybe extends bn("LSD.Leader.SnapshotReq",{}){}class p5 extends bn("LSD.Leader.SnapshotRes",{snapshot:a2}){}const Af=v2("LSD.Leader.LoadDatabaseFile",{payload:{data:a2},success:{},error:{cause:tt(Ye("unsupported-file",{}),Ye("unsupported-database",{}),Ye("unexpected-error",{cause:Vg}))}});class g5 extends Ab("LSD.Leader.SyncPull",{payload:Mwe}){}class _be extends bn("LSD.Leader.CommitEventReq",{eventEncoded:Fwe}){}class m5 extends bn("LSD.Leader.CommitEventRes",{}){}class Sbe extends bn("LSD.Leader.EventlogReq",{}){}class y5 extends bn("LSD.Leader.EventlogRes",{eventlog:a2}){}class vbe extends bn("LSD.Leader.Ping",{}){}class _5 extends bn("LSD.Leader.Pong",{}){}class S5 extends bn("LSD.Leader.Disconnect",{}){}const Fb=v2("LSD.Leader.SetSyncLatch",{payload:{closeLatch:Fl},success:{}}),Nb=v2("LSD.Leader.ResetAllData",{payload:{mode:nt("all-data","only-app-db")},success:{}}),wbe=tt(ybe,Af.Request,Sbe,Nb.Request,ube,fbe,S5,_be,vbe,cbe,hbe,pbe,dbe,gbe,mbe,Fb.Request).annotations({identifier:"LSD.Leader.MessageToApp"}),bbe=tt(p5,Af.Response,y5,S5,g5,c5,m5,_5,l5,d5,f5,h5,Nb.Success,Fb.Success).annotations({identifier:"LSD.Leader.MessageFromApp"}),Ebe=tt(Ye("node",{url:Y}),Ye("web",{}),Ye("browser-extension",{}));Ebe.pipe(jd("_tag"),zi);const v5={devtools:{random:()=>`devtools-instance-${br()}`},client:{session:({storeId:e,clientId:t,sessionId:n})=>`client-session-${e}-${t}-${n}`,leader:({storeId:e,clientId:t})=>`client-leader-${e}-${t}`}},w5={sessionInfo:()=>"session-info",devtoolsClientSession:({storeId:e,clientId:t,sessionId:n})=>`devtools-channel(client-session-${e}-${t}-${n})`,devtoolsClientLeader:({storeId:e,clientId:t,sessionId:n})=>`devtools-channel(client-leader-${e}-${t}-${n})`},b5={devtoolsClientSession:(e,{storeId:t,clientId:n,sessionId:r})=>e===w5.devtoolsClientSession({storeId:t,clientId:n,sessionId:r}),devtoolsClientLeader:(e,{storeId:t,clientId:n})=>e.startsWith(`devtools-channel(client-leader-${t}-${n}`)},kbe=e=>e.makeBroadcastChannel({channelName:w5.sessionInfo(),schema:YH}),Cbe=({otelTracer:e,parentSpanContext:t})=>n=>{const r=vh(Y8,e??s0e()),s=fU(je(t0e,hU)).pipe(que(r));return n.pipe(t?vc(n0e(ss.getSpanContext(t))):Ce,Hn(s))},yx=e=>{const t=e._duration;return t[0]*1e3+t[1]/1e6},LN=e=>e._performanceStartTime,Ey=Y.pipe(Qr,b8({constructor:()=>br(10),decoding:()=>br(10)})),ju={id:Ey,target:Y,source:Y,channelName:Y,hops:Je(Y)},E5=g8.pipe(Qr);class X_ extends Ye("DirectChannelRequest",{...ju,remainingHops:Je(Y).pipe(Qr),channelVersion:it,reqId:Ug(Y),sourceId:Y}){}class k5 extends Ye("DirectChannelResponseSuccess",{...ju,reqId:Y,port:CH,remainingHops:Je(Y),channelVersion:it}){}class b2 extends Ye("DirectChannelResponseNoTransferables",{...ju,reqId:Y,remainingHops:Je(Y)}){}class C5 extends Ye("ProxyChannelRequest",{...ju,remainingHops:E5,channelIdCandidate:Y}){}class x5 extends Ye("ProxyChannelResponseSuccess",{...ju,reqId:Y,remainingHops:Je(Y),combinedChannelId:Y,channelIdCandidate:Y}){}class R5 extends Ye("ProxyChannelPayload",{...ju,remainingHops:E5,payload:Nn,combinedChannelId:Y}){}class $5 extends Ye("ProxyChannelPayloadAck",{...ju,reqId:Y,remainingHops:Je(Y),combinedChannelId:Y}){}class _x extends Ye("NetworkEdgeAdded",{id:Ey,source:Y,target:Y}){}class Sx extends Ye("NetworkTopologyRequest",{id:Ey,hops:Je(Y),source:Y,target:nt("-")}){}class vx extends Ye("NetworkTopologyResponse",{id:Ey,reqId:Y,remainingHops:Je(Y),nodeName:Y,edges:Je(Y),source:Y,target:nt("-")}){}const Z_=Ye("BroadcastChannelPacket",{id:Ey,channelName:Y,payload:Nn,hops:Je(Y),source:Y,target:nt("-")});class wx extends tt(X_,k5,b2){}class I5 extends tt(C5,x5,R5,$5){}class E2 extends tt(wx,I5,_x,Sx,vx,Z_){}class p_ extends Ye("DirectChannelPing",{}){}class g_ extends Ye("DirectChannelPong",{}){}class xbe extends Oo()("EdgeAlreadyExistsError",{target:Y}){}const Wp=e=>({packetId:e.id,"span.label":e.id+(_e(e,"reqId")&&e.reqId!==void 0?` for ${e.reqId}`:""),...e._tag!=="DirectChannelResponseSuccess"&&e._tag!=="ProxyChannelPayload"?{packet:e}:{}});ke({channelName:Y,source:Y,mode:tt(nt("proxy"),nt("direct"))});const Rbe=rt,$be=({nodeName:e,incomingPacketsQueue:t,target:n,checkTransferableEdges:r,channelName:s,schema:i,sendPacket:o,channelVersion:a,scope:c,sourceId:f})=>X(function*(){const d=yield*Rbe(),g=yield*_y.pipe(Uw(()=>Pt(void 0))),_={send:tt(i.send,p_,g_),listen:tt(i.listen,p_,g_)},b={current:{_tag:"Initial"}},k=({packet:m,respondToSender:v})=>X(function*(){const w=b.current;if(g==null||g.addEvent(`process:${m._tag}`,{channelState:w._tag,packetId:m.id,packetReqId:m.reqId,packetChannelVersion:_e("channelVersion")(m)?m.channelVersion:void 0}),w._tag==="Initial")return ze();if(m._tag==="DirectChannelResponseNoTransferables")return yield*V$(d,m),"close";if(m.channelVersion>a)return g==null||g.addEvent(`incoming packet has higher version (${m.channelVersion}), closing channel`),yield*Ln(c,_n("higher-version-expected")),"close";if(m.channelVersion<a){const $=X_.make({source:e,sourceId:f,target:n,channelName:s,channelVersion:a,hops:[],remainingHops:m.hops,reqId:void 0});g==null||g.addEvent(`incoming packet has lower version (${m.channelVersion}), sending request to reconnect (${$.id})`),yield*o($);return}if(w._tag==="Established"&&m._tag==="DirectChannelRequest")return m.sourceId===w.otherSourceId?void 0:(g==null||g.addEvent("force-new-channel"),yield*Ln(c,_n("force-new-channel")),"close");switch(m._tag){case"DirectChannelRequest":{if(w._tag!=="RequestSent")return;if(m.reqId!==w.reqPacketId){const P=X_.make({source:e,sourceId:f,target:n,channelName:s,channelVersion:a,hops:[],remainingHops:m.hops,reqId:m.id});g==null||g.addEvent(`Re-sending new request (${P.id}) for incoming request (${m.id})`),yield*o(P)}if(e>n){g==null||g.addEvent("winner side: creating direct channel and sending response");const P=new MessageChannel,O=yield*TN({port:P.port1,schema:_,debugId:a}).pipe(d0(PN));yield*v(k5.make({reqId:m.id,target:n,source:e,channelName:m.channelName,hops:[],remainingHops:m.hops.slice(0,-1),port:P.port2,channelVersion:a})),b.current={_tag:"winner:ResponseSent",channel:O,otherSourceId:m.sourceId},yield*O.listen.pipe(Dl(),Ui(cr(p_)),N0(1),Sn),yield*O.send(g_.make({})),g==null||g.addEvent("winner side: established"),b.current={_tag:"Established",otherSourceId:m.sourceId},yield*jt(d,O)}else g==null||g.addEvent("loser side: waiting for response"),b.current={_tag:"loser:WaitingForResponse",otherSourceId:m.sourceId};break}case"DirectChannelResponseSuccess":{if(w._tag!=="loser:WaitingForResponse")return ze(`Expected to find direct channel response from ${n}, but was in ${w._tag} state`);const $=yield*TN({port:m.port,schema:_,debugId:a}).pipe(d0(PN)),P=yield*$.listen.pipe(Dl(),Ui(cr(g_)),N0(1),Sn,LI);yield*$.send(p_.make({})).pipe(Vw(10),NI({times:2})),yield*P,g==null||g.addEvent("loser side: established"),b.current={_tag:"Established",otherSourceId:w.otherSourceId},yield*jt(d,$);return}default:return wa(m)}}).pipe(Qe(`handleMessagePacket:${m._tag}:${m.source}→${m.target}`,{attributes:Wp(m)}));yield*X(function*(){for(;;){const m=yield*Ol(t);if((yield*k(m))==="close")return}}).pipe(Jt,st,Dt);const I=b.current;return I._tag!=="Initial"?ze(`Expected channel to be in Initial state, but was in ${I._tag} state`):(yield*X(function*(){const m=X_.make({source:e,sourceId:f,target:n,channelName:s,channelVersion:a,hops:[],reqId:void 0});b.current={_tag:"RequestSent",reqPacketId:m.id};const v=r(m);if(v!==void 0)return yield*ii(`No transferable edges found for ${m.source}→${m.target}`),yield*zs(v);yield*o(m),g==null||g.addEvent(`initial edge request sent (${m.id})`)}),yield*d)}).pipe(oy(`makeDirectChannel:${a}`)),Ibe=({schema:e,newEdgeAvailablePubSub:t,channelName:n,checkTransferableEdges:r,nodeName:s,incomingPacketsQueue:i,target:o,sendPacket:a})=>Lu(c=>X(function*(){const f=br(),d=yield*dr(),g=yield*dpe(),_=yield*rt(),b={pendingSends:0,totalSends:0,connectCounter:0,isConnected:!1,innerChannelRef:{current:void 0}};yield*X(function*(){const v=yield*rt();for(;;){b.connectCounter++;const O=b.connectCounter;yield*ii(`Connecting#${O}`);const A=yield*ty();yield*pr(le=>Ln(A,le));const z=yield*M8(t).pipe(Un(le=>ii(`new-conn:${le}`)),N0(1),Sn,yo("new-edge"),LI),D=$be({nodeName:s,sourceId:f,incomingPacketsQueue:i,target:o,checkTransferableEdges:r,channelName:n,schema:e,channelVersion:O,newEdgeAvailablePubSub:t,sendPacket:a,scope:A}).pipe(ey(A),gs(A),Sue(re())),W=yield*lU(D,z.pipe(lue));if(W==="new-edge")yield*Ln(A,Vm("new-edge"));else{const le=yield*W.pipe($n);if(le._tag==="Failure")yield*Ln(A,le),Sj(le.cause)&&cr(b2)(le.cause.error)&&(yield*z.pipe($n));else{const M=le.value;yield*jt(v,{channel:M,makeDirectChannelScope:A,channelVersion:O});break}}}const{channel:w,makeDirectChannelScope:$,channelVersion:P}=yield*v;yield*ii(`Connected#${P}`),b.isConnected=!0,b.innerChannelRef.current=w,yield*jt(_,void 0),yield*w.listen.pipe(Dl(),j8(O=>nT(d,O)),Sn,st,gs($)),yield*X(function*(){for(;;){const[O,A]=yield*upe(g);yield*w.send(O),yield*jt(A,void 0),yield*fpe(g)}}).pipe(gs($)),yield*w.closedDeferred,yield*Ln($,_n("channel-closed")),yield*ii(`Disconnected#${P}`),b.isConnected=!1,b.innerChannelRef.current=void 0}).pipe(Pl,Nd,st,Dt);const k=yield*Gw.pipe(os),I=v=>X(function*(){const w=yield*rt();b.pendingSends++,b.totalSends++,yield*cpe(g,[v,w]),yield*w,b.pendingSends--}).pipe(Pl,vc(k)),E=va(d,{maxChunkSize:1}).pipe(Ta(Pe)),y=yield*rt().pipe(Rt(Wl(_s)));return{webChannel:{[qr]:qr,send:I,listen:E,closedDeferred:y,supportsTransferables:!0,schema:e,debugInfo:b,shutdown:Ln(c,_n("shutdown"))},initialEdgeDeferred:_}})),Tbe=({queue:e,nodeName:t,newEdgeAvailablePubSub:n,sendPacket:r,target:s,channelName:i,schema:o})=>Lu(a=>X(function*(){const c={current:{_tag:"Initial"}},f={kind:"proxy-channel",pendingSends:0,totalSends:0,connectCounter:0,isConnected:!1},d=br(5);yield*vC({channelIdCandidate:d});const g=yield*Gw.pipe(os),_=yield*Wg(!1),b=X(function*(){return yield*Kg(_,W=>W!==!1)}),k=D=>X(function*(){yield*ii(`Connected (${D})`).pipe(vc(g)),c.current={_tag:"Established",listenSchema:o.listen,listenQueue:v,ackMap:w,combinedChannelId:D},yield*uo(_,c.current),f.isConnected=!0}),I=zt(()=>r(C5.make({channelName:i,hops:[],source:t,target:s,channelIdCandidate:d}))),E=D=>[d,D].sort().join("_"),y=yield*dr().pipe(Rt(In)),m=({packet:D,respondToSender:W})=>X(function*(){const M=`target:${D.source}, channelName:${D.channelName}`,U=c.current;switch(D._tag){case"ProxyChannelRequest":{const Q=E(D.channelIdCandidate);U._tag==="Established"?U.combinedChannelId===Q||(yield*Ps(`[${t}] Received ProxyChannelRequest with different channel ID (${Q}) while established with ${U.combinedChannelId}. Re-establishing.`),yield*uo(_,!1),c.current={_tag:"Pending",initiatedVia:"incoming-request"},yield*ii("Reconnecting (received conflicting ProxyChannelRequest)").pipe(vc(g)),f.isConnected=!1,f.connectCounter++,yield*I):U._tag==="Initial"&&(yield*uo(_,!1),c.current={_tag:"Pending",initiatedVia:"incoming-request"},yield*ii("Connecting (received ProxyChannelRequest)").pipe(vc(g)),f.isConnected=!1,f.connectCounter++),yield*W(x5.make({reqId:D.id,remainingHops:D.hops,hops:[],target:s,source:t,channelName:i,combinedChannelId:Q,channelIdCandidate:d}));return}case"ProxyChannelResponseSuccess":{if(U._tag!=="Pending"){if(U._tag==="Established"&&U.combinedChannelId!==D.combinedChannelId)return ze(`ProxyChannel[${M}]: Expected proxy channel to have the same combinedChannelId as the packet:
221
+ ${U.combinedChannelId} (channel) === ${D.combinedChannelId} (packet)`);if(U._tag==="Established")return;yield*Ps(`[${t}] Ignoring ResponseSuccess ${D.id} received in unexpected state ${U._tag}`);return}const Q=E(D.channelIdCandidate);if(Q!==D.combinedChannelId)return yield*Ad(`ProxyChannel[${M}]: Expected proxy channel to have the same combinedChannelId as the packet:
222
+ ${Q} (channel) === ${D.combinedChannelId} (packet)`);yield*k(D.combinedChannelId);const L=c.current;if(L._tag==="Established"){const G=yield*Mfe(y);for(const V of G){if(L.combinedChannelId!==V.combinedChannelId){yield*Ps(`[${t}] Discarding buffered payload ${V.id}: Combined channel ID mismatch during drain. Expected ${L.combinedChannelId}, got ${V.combinedChannelId}`);continue}const J=yield*jg(L.listenSchema)(V.payload);yield*L.listenQueue.pipe($t(J))}}else yield*Dd(`[${t}] State is not Established immediately after setStateToEstablished was called. Cannot drain buffer. State: ${L._tag}`);return}case"ProxyChannelPayload":{if(U._tag==="Established"&&U.combinedChannelId!==D.combinedChannelId)return yield*Ad(`ProxyChannel[${M}]: Expected proxy channel to have the same combinedChannelId as the packet:
223
+ ${U.combinedChannelId} (channel) === ${D.combinedChannelId} (packet)`);if(yield*W($5.make({reqId:D.id,remainingHops:D.hops,hops:[],target:s,source:t,channelName:i,combinedChannelId:U._tag==="Established"?U.combinedChannelId:D.combinedChannelId})),U._tag==="Established"){const Q=yield*jg(U.listenSchema)(D.payload);yield*U.listenQueue.pipe($t(Q))}else yield*$t(y,D);return}case"ProxyChannelPayloadAck":{if(U._tag!=="Established"){yield*ii(`Not yet connected to ${s}. dropping message`),yield*Ps(`[${t}] Received Ack but not established (State: ${U._tag}). Dropping Ack for ${D.reqId}`);return}const Q=U.ackMap.get(D.reqId)??ze(`[ProxyChannel[${M}]] Expected ack for ${D.reqId}`);yield*jt(Q,void 0),U.ackMap.delete(D.reqId);return}default:return wa(D)}}).pipe(Qe(`handleProxyPacket:${D._tag}:${D.source}->${D.target}`,{attributes:Wp(D)}));yield*va(e).pipe(Un(m),Sn,st,Dt);const v=yield*dr();yield*ii("Connecting");const w=new Map;{if(c.current._tag!=="Initial")return ze("Expected proxy channel to be Initial");c.current={_tag:"Pending",initiatedVia:"outgoing-request"},yield*I;const D=yield*M8(n).pipe(Un(()=>I),Sn,Dt),{combinedChannelId:W}=yield*b;yield*Fs(D),yield*k(W)}const $=D=>X(function*(){const W=yield*PT(o.send)(D),le=yield*RT(),M=yield*rt();f.pendingSends++,f.totalSends++;const U=X(function*(){const{combinedChannelId:L}=yield*Kg(_,V=>V!==!1);yield*X(function*(){const V=yield*rt(),J=R5.make({channelName:i,payload:W,hops:[],source:t,target:s,combinedChannelId:L});w.set(J.id,V),yield*r(J),yield*V,yield*jt(M,void 0),f.pendingSends--}).pipe(Vw(100),NI(Qde(10)),os)}).pipe(Sh(Dd)),Q=yield*_.changes.pipe(Ui(L=>L===!1),Un(()=>Md(le,U)),Sn,LI);yield*Md(le,U),yield*M,yield*Fs(Q)}).pipe(Pl,Qe("sendAckWithRetry:ProxyChannelPayload"),vc(g)),P=va(v).pipe(Ta(Pe)),O=yield*rt().pipe(Rt(Wl(_s))),A=yield*To();return{[qr]:qr,send:$,listen:P,closedDeferred:O,supportsTransferables:!1,schema:o,shutdown:Ln(a,_s),debugInfo:f,debug:{ping:(D="ping")=>$(tm.make({message:D})).pipe(Hn(A),st,Po)}}}).pipe(oy("makeProxyChannel"))),nv=class nv{constructor({timeout:t}){p(this,"values",new Map);p(this,"timeoutHandle");p(this,"timeoutMs");p(this,"onShutdown",()=>clearTimeout(this.timeoutHandle));this.timeoutMs=ru(t)}add(t){this.values.set(t,Date.now()),this.scheduleCleanup()}has(t){return this.values.has(t)}delete(t){this.values.delete(t)}scheduleCleanup(){this.timeoutHandle===void 0&&(this.timeoutHandle=setTimeout(()=>{this.cleanup(),this.timeoutHandle=void 0},this.timeoutMs))}cleanup(){const t=Date.now();for(const[n,r]of this.values.entries())t-r>=this.timeoutMs&&this.values.delete(n)}};p(nv,"make",t=>X(function*(){const n=new nv({timeout:t});return yield*pr(()=>Re(()=>n.onShutdown())),n}));let bx=nv;const T5=e=>X(function*(){const t=new Map,n=yield*bx.make(SL(1)),r=yield*wU().pipe(Rt(bC)),s=new Map,i=yield*dr().pipe(Rt(In)),o=new Map,a=new Map,c=w=>{var $;if(w._tag==="DirectChannelRequest"&&(t.size===0||(($=t.get(w.target))==null?void 0:$.channel.supportsTransferables)===!1)||![...t.values()].some(P=>P.channel.supportsTransferables===!0))return b2.make({reqId:w.id,channelName:w.channelName,source:w.target,target:w.source,remainingHops:w.hops,hops:[]})},f=w=>X(function*(){var $,P;if(cr(_x)(w)){yield*ii("NetworkEdgeAdded",{packet:w,nodeName:e}),yield*ZI(r,w.target);const O=Array.from(t).filter(([A])=>A!==w.source).map(([A,z])=>z.channel);yield*er(O,A=>A.send(w),{concurrency:"unbounded"});return}if(cr(Z_)(w)){const O=Array.from(t).filter(([D])=>!w.hops.includes(D)).map(([D,W])=>W.channel),A={...w,hops:[...w.hops,e]};if(yield*er(O,D=>D.send(A),{concurrency:"unbounded"}),w.source===e)return;const z=a.get(w.channelName);z!==void 0&&(yield*$t(z,w));return}if(cr(Sx)(w)){if(w.source!==e){const z=w.hops.at(-1)??ze(`${e}: Expected hops for packet`,w),D=t.get(z).channel,W=vx.make({reqId:w.id,source:w.source,target:w.target,remainingHops:w.hops.slice(0,-1),nodeName:e,edges:Array.from(t.keys())});yield*D.send(W)}const O=Array.from(t).filter(([z])=>!w.hops.includes(z)).map(([z,D])=>D.channel),A={...w,hops:[...w.hops,e]};yield*er(O,z=>z.send(A),{concurrency:"unbounded"});return}if(cr(vx)(w)){if(w.source===e)o.get(w.reqId).set(w.nodeName,new Set(w.edges));else{const A=w.remainingHops.at(-1)??ze(`${e}: Expected remaining hops for packet`,w);yield*((($=t.get(A))==null?void 0:$.channel)??ze(`${e}: Expected edge channel (${A}) for packet`,w,"Available edges:",Array.from(t.keys()))).send({...w,remainingHops:w.remainingHops.slice(0,-1)})}return}if(t.has(w.target)){const O=t.get(w.target).channel,A=w.source===e?[]:[...w.hops,e];yield*vC({hasDirectEdge:!0}),yield*O.send({...w,hops:A})}else if(w.remainingHops!==void 0){const O=w.remainingHops.at(-1)??ze(`${e}: Expected remaining hops for packet`,w),A=(P=t.get(O))==null?void 0:P.channel;if(A===void 0){yield*Ps(`${e}: Expected to find hop target ${O} in edges. Dropping packet.`,w);return}yield*A.send({...w,remainingHops:w.remainingHops.slice(0,-1),hops:[...w.hops,e]})}else{const O=w.source===e?[]:[...w.hops,e],A=Array.from(t).filter(([D])=>D!==w.source).map(([D,W])=>({name:D,channel:W.channel}));O.length===0&&A.length===0&&js&&(yield*Ps(e,"no route found to",w.target,w._tag,"TODO handle better"));const z={...w,hops:O};yield*vC({edgesToForwardTo:A.map(({name:D})=>D)}),yield*er(A,({channel:D})=>D.send(z),{concurrency:"unbounded"})}}).pipe(Qe(`sendPacket:${w._tag}:${w.source}→${w.target}`,{attributes:Wp(w)}),os),d=({target:w,edgeChannel:$,replaceIfExists:P=!1})=>X(function*(){if(t.has(w))if(P)yield*g(w).pipe(os);else return yield*new xbe({target:w});const O=yield*$.listen.pipe(Dl(),Un(z=>X(function*(){const D=yield*jg(E2)(z);if(!n.has(D.id))switch(n.add(D.id),D._tag){case"NetworkEdgeAdded":case"NetworkTopologyRequest":case"NetworkTopologyResponse":{yield*f(D);break}default:if(D.target===e){const W=`target:${D.source}, channelName:${D.channelName}`;if(!s.has(W)){const U=yield*dr().pipe(Rt(In));s.set(W,{queue:U,debugInfo:void 0})}const le=s.get(W).queue,M=U=>$.send(U).pipe(Qe(`respondToSender:${U._tag}:${U.source}→${U.target}`,{attributes:Wp(U)}),os);cr(I5)(D)?yield*$t(le,{packet:D,respondToSender:M}):cr(wx)(D)&&(yield*$t(le,{packet:D,respondToSender:M})),(D._tag==="ProxyChannelRequest"||D._tag==="DirectChannelRequest")&&(yield*$t(i,{channelName:D.channelName,source:D.source,mode:D._tag==="ProxyChannelRequest"?"proxy":"direct"}))}else{if(cr(wx)(D)){const W=c(D);if(W!==void 0)return yield*ii(`No transferable edges found for ${D.source}→${D.target}`),yield*$.send(W).pipe(Qe(`sendNoTransferableResponse:${D.source}→${D.target}`,{attributes:Wp(W)}))}yield*f(D)}}})),Sn,Jt,os,st,Dt);t.set(w,{channel:$,listenFiber:O});const A=_x.make({source:e,target:w});yield*f(A).pipe(os)}).pipe(yl({"addEdge:target":w,nodeName:e}),Qe(`addEdge:${e}→${w}`,{attributes:{supportsTransferables:$.supportsTransferables}})),g=w=>X(function*(){t.has(w)||(yield*new Lw(`No edge found for ${w}`)),yield*Fs(t.get(w).listenFiber),t.delete(w)}),_=({target:w,channelName:$})=>Re(()=>s.has(`target:${w}, channelName:${$}`)),b=({target:w,channelName:$,schema:P,mode:O,timeout:A=r$(1),closeExisting:z=!1})=>X(function*(){var M;const D=vy(P),W=`target:${w}, channelName:${$}`;if(s.has(W)){const U=(M=s.get(W).debugInfo)==null?void 0:M.channel;U&&(z?(yield*U.shutdown,s.delete(W)):ze(`Channel ${W} already exists`,U))}if(s.has(W)===!1){const U=yield*dr().pipe(Rt(In));s.set(W,{queue:U,debugInfo:void 0})}const le=s.get(W).queue;if(yield*pr(()=>Re(()=>s.delete(W))),O==="direct"){const U=yield*dr().pipe(Rt(In));yield*bU(le,1,10).pipe(kr(G=>nT(U,G)),Nd,Jt,st,Dt);const{webChannel:Q,initialEdgeDeferred:L}=yield*Ibe({nodeName:e,incomingPacketsQueue:U,newEdgeAvailablePubSub:r,target:w,channelName:$,schema:D,sendPacket:f,checkTransferableEdges:c});return s.set(W,{queue:le,debugInfo:{channel:Q,target:w}}),yield*L,Q}else{const U=yield*Tbe({nodeName:e,newEdgeAvailablePubSub:r,target:w,channelName:$,schema:D,queue:le,sendPacket:f});return s.set(W,{queue:le,debugInfo:{channel:U,target:w}}),U}}).pipe(oy(`makeChannel:${e}→${w}(${$})`,{attributes:{target:w,channelName:$,mode:O,timeout:A}}),yl({nodeName:e,target:w,channelName:$}));let k=!1;const I=WT(()=>{if(k)return ze("listenForChannel already started");k=!0;const w=P=>`${P.channelName}:${P.source}:${P.mode}`,$=new Set;return va(i).pipe(Ui(P=>{const O=w(P);return $.has(O)?!1:($.add(O),!0)}))}),E=({channelName:w,schema:$})=>Lu(P=>X(function*(){if(a.has(w))return ze(`Broadcast channel ${w} already exists`,a.get(w));const O={},A=yield*dr().pipe(Rt(In));a.set(w,A);const z=le=>X(function*(){const M=yield*OT($)(le),U=Z_.make({channelName:w,payload:M,source:e,target:"-",hops:[]});yield*f(U)}),D=va(A).pipe(Ui(cr(Z_)),Ta(le=>gy($)(le.payload))),W=yield*rt().pipe(Rt(Wl(_s)));return{[qr]:qr,send:z,listen:D,closedDeferred:W,supportsTransferables:!1,schema:{listen:$,send:$},shutdown:Ln(P,_s),debugInfo:O}})),y=Re(()=>new Set(t.keys())),m=yield*To();return{nodeName:e,addEdge:d,removeEdge:g,hasChannel:_,makeChannel:b,listenForChannel:I,makeBroadcastChannel:E,edgeKeys:y,debug:{print:()=>{var w,$,P,O;console.log("Webmesh debug info for node:",e),console.log("Edges:",t.size);for(const[A,z]of t)console.log(` ${A}: supportsTransferables=${z.channel.supportsTransferables}`);console.log("Channels:",s.size);for(const[A,z]of s)console.log(u_(A,2),`
224
+ `,Object.entries({target:(w=z.debugInfo)==null?void 0:w.target,supportsTransferables:($=z.debugInfo)==null?void 0:$.channel.supportsTransferables,...(P=z.debugInfo)==null?void 0:P.channel.debugInfo}).map(([D,W])=>u_(`${D}=${W}`,4)).join(`
225
+ `)," ",(O=z.debugInfo)==null?void 0:O.channel,`
226
+ `,u_(`Queue: ${z.queue.unsafeSize().pipe(ti)}`,4),z.queue);console.log("Broadcast channels:",a.size);for(const[A,z]of a)console.log(u_(A,2))},ping:w=>{X(function*(){const $=P=>tm.make({message:`ping from ${e} via ${P}`,payload:w});for(const[P,O]of t)yield*ni(`sending ping via edge ${P}`),yield*O.channel.send($(`edge ${P}`));for(const[P,O]of s){if(O.debugInfo===void 0){yield*ni(`channel ${P} has no debug info`);continue}yield*ni(`sending ping via channel ${P}`),yield*O.debugInfo.channel.send($(`channel ${P}`))}}).pipe(Hn(m),st,Po)},requestTopology:(w=1e3)=>X(function*(){const $=Sx.make({source:e,target:"-",hops:[]}),P=new Map;P.set(e,new Set(t.keys())),o.set($.id,P),yield*f($),yield*ni(`Waiting ${w}ms for topology response`),yield*Bw(w),yield*ni(`Topology response (from ${e}):`);for(const[O,A]of P)yield*ni(` node '${O}' has edge to: ${Array.from(A.values()).join(", ")}`)}).pipe(Hn(m),st,Kw)}}}).pipe(Qe(`makeMeshNode:${e}`),yl({"makeMeshNode.nodeName":e})),Pbe=({storeId:e,clientId:t,sessionId:n,isLeader:r,devtoolsEnabled:s,connectDevtoolsToStore:i,lockStatus:o,leaderThread:a,schema:c,sqliteDb:f,shutdown:d,connectWebmeshNode:g,webmeshMode:_,registerBeforeUnload:b,debugInstanceId:k})=>X(function*(){const I=s?{enabled:!0,pullLatch:yield*qg(!0),pushLatch:yield*qg(!0)}:{enabled:!1};return s&&(yield*X(function*(){const E=yield*T5(v5.client.session({storeId:e,clientId:t,sessionId:n}));globalThis.__debugWebmeshNode=E;const y=c.devtools.alias,m=JH.make({storeId:e,clientId:t,sessionId:n,schemaAlias:y,isLeader:r});yield*g({webmeshNode:E,sessionInfo:m});const v=yield*kbe(E);yield*XH({webChannel:v,sessionInfo:m}).pipe(st,Dt),yield*E.listenForChannel.pipe(Ui(w=>b5.devtoolsClientSession(w.channelName,{storeId:e,clientId:t,sessionId:n})&&w.mode===_),Un(kue(function*({channelName:w,source:$}){const P=yield*E.makeChannel({target:$,channelName:w,schema:{listen:abe,send:lbe},mode:_}),O=P.send(w2.make({clientId:t,liveStoreVersion:Hr,sessionId:n})).pipe(os);yield*pr(()=>O),yield*Rt(Re(()=>b(()=>O.pipe(Po))),A=>Re(()=>A())),yield*i(P)},st,Dt)),Sn)}).pipe(Qe("@livestore/common:make-client-session:devtools"),st,Dt)),{sqliteDb:f,leaderThread:a,devtools:I,lockStatus:o,clientId:t,sessionId:n,shutdown:d,debugInstanceId:k}}),P5=e=>(...t)=>{const[n,r,s]=t;if(by(n)){const{query:i,bindValues:o}=n.asSql();return e(i,o,r)}else return e(n,r,s)},O5=e=>(...t)=>{const[n,r]=t;if(by(n)){const{query:s,bindValues:i}=n.asSql(),o=p2(n),a=e(s,i);return Ld(o)(a)}else return e(n,r)},be=0,Obe=1,am=10,k2=12,ky=14,qa=21,mE=25,Abe=27,Ex=100,Fbe=101,Db=522,A5=778,zN=2,Y0=4,kx=8,F5=64,Nbe=256,Dbe=2048,qbe=16384,Mbe=524288,Lbe=2048,jN=1,UN=2,HN=3,BN=4,VN=5,zbe=512;class N5{constructor(t,n){p(this,"name");p(this,"mxPathname",64);p(this,"_module");this.name=t,this._module=n}close(){}isReady(){return!0}hasAsyncMethod(t){return!1}xOpen(t,n,r,s,i){return ky}xDelete(t,n,r){return be}xAccess(t,n,r,s){return be}xFullPathname(t,n,r,s){return be}xGetLastError(t,n,r){return be}xClose(t){return be}xRead(t,n,r,s,i){return be}xWrite(t,n,r,s,i){return be}xTruncate(t,n,r){return be}xSync(t,n){return be}xFileSize(t,n){return be}xLock(t,n){return be}xUnlock(t,n){return be}xCheckReservedLock(t,n){return be}xFileControl(t,n,r){return k2}xSectorSize(t){return zbe}xDeviceCharacteristics(t){return 0}}const jbe=Object.getPrototypeOf(async function(){}).constructor;var $c,yp,um,Cx,rv,D5,d3;let Ube=(d3=class extends N5{constructor(n,r){super(n,r);Ft(this,$c);Ft(this,um);Ft(this,rv)}hasAsyncMethod(n){const r=`j${n.slice(1)}`;return this[r]instanceof jbe}getFilename(n){throw new Error("unimplemented")}jOpen(n,r,s,i){return ky}jDelete(n,r){return be}jAccess(n,r,s){return be}jFullPathname(n,r){const{read:s,written:i}=new TextEncoder().encodeInto(n,r);return s<n.length||i>=r.length?am:(r[i]=0,be)}jGetLastError(n){return be}jClose(n){return be}jRead(n,r,s){return r.fill(0),Db}jWrite(n,r,s){return A5}jTruncate(n,r){return be}jSync(n,r){return be}jFileSize(n,r){return be}jLock(n,r){return be}jUnlock(n,r){return be}jCheckReservedLock(n,r){return r.setInt32(0,0,!0),be}jFileControl(n,r,s){return k2}jSectorSize(n){return super.xSectorSize(n)}jDeviceCharacteristics(n){return 0}xOpen(n,r,s,i,o){var f;const a=Et(this,rv,D5).call(this,r,i),c=Et(this,$c,yp).call(this,"Int32",o);return(f=this.log)==null||f.call(this,"jOpen",a,s,"0x"+i.toString(16)),this.jOpen(a,s,i,c)}xDelete(n,r,s){var o;const i=this._module.UTF8ToString(r);return(o=this.log)==null||o.call(this,"jDelete",i,s),this.jDelete(i,s)}xAccess(n,r,s,i){var c;const o=this._module.UTF8ToString(r),a=Et(this,$c,yp).call(this,"Int32",i);return(c=this.log)==null||c.call(this,"jAccess",o,s),this.jAccess(o,s,a)}xFullPathname(n,r,s,i){var c;const o=this._module.UTF8ToString(r),a=this._module.HEAPU8.subarray(i,i+s);return(c=this.log)==null||c.call(this,"jFullPathname",o,s),this.jFullPathname(o,a)}xGetLastError(n,r,s){var o;const i=this._module.HEAPU8.subarray(s,s+r);return(o=this.log)==null||o.call(this,"jGetLastError",r),this.jGetLastError(i)}xClose(n){var r;return(r=this.log)==null||r.call(this,"jClose",n),this.jClose(n)}xRead(n,r,s,i,o){var f;const a=Et(this,um,Cx).call(this,r,s),c=yE(i,o);return(f=this.log)==null||f.call(this,"jRead",n,s,c),this.jRead(n,a,c)}xWrite(n,r,s,i,o){var f;const a=Et(this,um,Cx).call(this,r,s),c=yE(i,o);return(f=this.log)==null||f.call(this,"jWrite",n,a,c),this.jWrite(n,a,c)}xTruncate(n,r,s){var o;const i=yE(r,s);return(o=this.log)==null||o.call(this,"jTruncate",n,i),this.jTruncate(n,i)}xSync(n,r){var s;return(s=this.log)==null||s.call(this,"jSync",n,r),this.jSync(n,r)}xFileSize(n,r){var i;const s=Et(this,$c,yp).call(this,"BigInt64",r);return(i=this.log)==null||i.call(this,"jFileSize",n),this.jFileSize(n,s)}xLock(n,r){var s;return(s=this.log)==null||s.call(this,"jLock",n,r),this.jLock(n,r)}xUnlock(n,r){var s;return(s=this.log)==null||s.call(this,"jUnlock",n,r),this.jUnlock(n,r)}xCheckReservedLock(n,r){var i;const s=Et(this,$c,yp).call(this,"Int32",r);return(i=this.log)==null||i.call(this,"jCheckReservedLock",n),this.jCheckReservedLock(n,s)}xFileControl(n,r,s){var o;const i=new DataView(this._module.HEAPU8.buffer,this._module.HEAPU8.byteOffset+s);return(o=this.log)==null||o.call(this,"jFileControl",n,r,i),this.jFileControl(n,r,i)}xSectorSize(n){var r;return(r=this.log)==null||r.call(this,"jSectorSize",n),this.jSectorSize(n)}xDeviceCharacteristics(n){var r;return(r=this.log)==null||r.call(this,"jDeviceCharacteristics",n),this.jDeviceCharacteristics(n)}},$c=new WeakSet,yp=function(n,r){const s=n==="Int32"?4:8,i=`get${n}`,o=`set${n}`,a=()=>new DataView(this._module.HEAPU8.buffer,this._module.HEAPU8.byteOffset+r,s);let c=a();return new Proxy(c,{get(f,d){if(c.buffer.byteLength===0&&(c=a()),d===i)return function(_,b){if(!b)throw new Error("must be little endian");return c[d](_,b)};if(d===o)return function(_,b,k){if(!k)throw new Error("must be little endian");return c[d](_,b,k)};if(typeof d=="string"&&d.match(/^(get)|(set)/))throw new Error("invalid type");const g=c[d];return typeof g=="function"?g.bind(c):g}})},um=new WeakSet,Cx=function(n,r){let s=this._module.HEAPU8.subarray(n,n+r);return new Proxy(s,{get:(i,o,a)=>{s.buffer.byteLength===0&&(s=this._module.HEAPU8.subarray(n,n+r));const c=s[o];return typeof c=="function"?c.bind(s):c}})},rv=new WeakSet,D5=function(n,r){if(r&F5){let s=n,i=1;const o=[];for(;i;){const a=this._module.HEAPU8[s++];if(a)o.push(a);else switch(this._module.HEAPU8[s]||(i=null),i){case 1:o.push("?".charCodeAt(0)),i=2;break;case 2:o.push("=".charCodeAt(0)),i=3;break;case 3:o.push("&".charCodeAt(0)),i=2;break}}return new TextDecoder().decode(new Uint8Array(o))}return n?this._module.UTF8ToString(n):null},d3);function yE(e,t){return t*4294967296+e+(e<0?2**32:0)}class C2 extends Ube{constructor(n,r){super(n,r);p(this,"mapNameToFile",new Map);p(this,"mapIdToFile",new Map)}static async create(n,r){const s=new C2(n,r);return await s.isReady(),s}close(){for(const n of this.mapIdToFile.keys())this.jClose(n)}jOpen(n,r,s,i){const a=new URL(n||Math.random().toString(36).slice(2),"file://").pathname;let c=this.mapNameToFile.get(a);if(!c)if(s&Y0)c={pathname:a,flags:s,size:0,data:new ArrayBuffer(0)},this.mapNameToFile.set(a,c);else return ky;return this.mapIdToFile.set(r,c),i.setInt32(0,s,!0),be}jClose(n){const r=this.mapIdToFile.get(n);return this.mapIdToFile.delete(n),r.flags&kx&&this.mapNameToFile.delete(r.pathname),be}jRead(n,r,s){const i=this.mapIdToFile.get(n),o=Math.min(s,i.size),c=Math.min(s+r.byteLength,i.size)-o;return c&&r.set(new Uint8Array(i.data,o,c)),c<r.byteLength?(r.fill(0,c),Db):be}jWrite(n,r,s){const i=this.mapIdToFile.get(n);if(s+r.byteLength>i.data.byteLength){const o=Math.max(s+r.byteLength,2*i.data.byteLength),a=new ArrayBuffer(o);new Uint8Array(a).set(new Uint8Array(i.data,0,i.size)),i.data=a}return new Uint8Array(i.data,s,r.byteLength).set(r),i.size=Math.max(i.size,s+r.byteLength),be}jTruncate(n,r){const s=this.mapIdToFile.get(n);return s.size=Math.min(s.size,r),be}jFileSize(n,r){const s=this.mapIdToFile.get(n);return r.setBigInt64(0,BigInt(s.size),!0),be}jDelete(n,r){const i=new URL(n,"file://").pathname;return this.mapNameToFile.delete(i),be}jAccess(n,r,s){const o=new URL(n,"file://").pathname,a=this.mapNameToFile.get(o);return s.setInt32(0,a?1:0,!0),be}}let WN;const q5=e=>{if(e.vfs_registered.has("memory-vfs")===!1){const r=new C2("memory-vfs",e.module);e.vfs_register(r,!1),WN=r}return{dbPointer:e.open_v2Sync(":memory:",void 0,"memory-vfs"),vfs:WN}},KN=({sqlite3:e,metadata:t})=>{const n=[],{dbPointer:r}=t;let s=!1;const i={_tag:"SqliteDb",metadata:t,prepare:o=>{try{const a=e.statements(r,o.trim(),{unscoped:!0});let c=!1;const f={execute:(d,g)=>{for(const _ of a){d!==void 0&&Object.keys(d).length>0&&e.bind_collection(_,d);try{e.step(_)}finally{g!=null&&g.onRowsChanged&&g.onRowsChanged(e.changes(r)),e.reset(_)}}},select:d=>{if(a.length!==1)throw new xc({query:{bindValues:d,sql:o},code:-1,cause:"Expected only one statement when using `select`"});const g=a[0];d!==void 0&&Object.keys(d).length>0&&e.bind_collection(g,d);const _=[];try{let b;try{b=e.column_names(g)}catch{}for(;e.step(g)===Ex;)if(b!==void 0){const k={};for(let I=0;I<b.length;I++)k[b[I]]=e.column(g,I);_.push(k)}}catch(b){throw new xc({query:{bindValues:d,sql:o},code:b.code,cause:b})}finally{e.reset(g)}return _},finalize:()=>{if(!c){c=!0;for(const d of a)e.finalize(d)}},sql:o};return n.push(f),f}catch(a){throw new xc({query:{sql:o,bindValues:{}},code:a.code,cause:a})}},export:()=>e.serialize(r,"main"),execute:P5((o,a,c)=>{const f=i.prepare(o);f.execute(a,c),f.finalize()}),select:O5((o,a)=>{const c=i.prepare(o),f=c.select(a);return c.finalize(),f}),destroy:()=>{i.close(),t.deleteDb()},close:()=>{if(!s){for(const o of n)o.finalize();e.close(r),s=!0}},import:o=>{if(o instanceof Uint8Array){const f=q5(e);e.deserialize(f.dbPointer,"main",o,o.length,o.length,3),e.backup(r,"main",f.dbPointer,"main"),e.close(f.dbPointer)}else e.backup(r,"main",o.metadata.dbPointer,"main");t.configureDb(i)},session:()=>{const o=e.session_create(r,"main");return e.session_attach(o,null),{changeset:()=>e.session_changeset(o).changeset??void 0,finish:()=>{e.session_delete(o)}}},makeChangeset:o=>({invert:()=>{const c=e.changeset_invert(o);return i.makeChangeset(c)},apply:()=>{try{e.changeset_apply(r,o),o=void 0}catch(c){throw new xc({code:c.code??-1,cause:c,note:"Failed calling makeChangeset.apply"})}}})};return t.configureDb(i),i},Hbe=Object.getPrototypeOf(async()=>{}).constructor;var Ic,_p,fm,xx,sv,M5;class Bbe extends N5{constructor(n,r){super(n,r);Ft(this,Ic);Ft(this,fm);Ft(this,sv)}hasAsyncMethod(n){const r=`j${n.slice(1)}`;return this[r]instanceof Hbe}getFilename(n){throw new Error("unimplemented")}jOpen(n,r,s,i){return ky}jDelete(n,r){return be}jAccess(n,r,s){return be}jFullPathname(n,r){const{read:s,written:i}=new TextEncoder().encodeInto(n,r);return s<n.length||i>=r.length?am:(r[i]=0,be)}jGetLastError(n){return be}jClose(n){return be}jRead(n,r,s){return r.fill(0),Db}jWrite(n,r,s){return A5}jTruncate(n,r){return be}jSync(n,r){return be}jFileSize(n,r){return be}jLock(n,r){return be}jUnlock(n,r){return be}jCheckReservedLock(n,r){return r.setInt32(0,0,!0),be}jFileControl(n,r,s){return k2}jSectorSize(n){return super.xSectorSize(n)}jDeviceCharacteristics(n){return 0}xOpen(n,r,s,i,o){var f;const a=Et(this,sv,M5).call(this,r,i),c=Et(this,Ic,_p).call(this,"Int32",o);return(f=this.log)==null||f.call(this,"jOpen",a,s,"0x"+i.toString(16)),this.jOpen(a,s,i,c)}xDelete(n,r,s){var o;const i=this._module.UTF8ToString(r);return(o=this.log)==null||o.call(this,"jDelete",i,s),this.jDelete(i,s)}xAccess(n,r,s,i){var c;const o=this._module.UTF8ToString(r),a=Et(this,Ic,_p).call(this,"Int32",i);return(c=this.log)==null||c.call(this,"jAccess",o,s),this.jAccess(o,s,a)}xFullPathname(n,r,s,i){var c;const o=this._module.UTF8ToString(r),a=this._module.HEAPU8.subarray(i,i+s);return(c=this.log)==null||c.call(this,"jFullPathname",o,s),this.jFullPathname(o,a)}xGetLastError(n,r,s){var o;const i=this._module.HEAPU8.subarray(s,s+r);return(o=this.log)==null||o.call(this,"jGetLastError",r),this.jGetLastError(i)}xClose(n){var r;return(r=this.log)==null||r.call(this,"jClose",n),this.jClose(n)}xRead(n,r,s,i,o){var f;const a=Et(this,fm,xx).call(this,r,s),c=_E(i,o);return(f=this.log)==null||f.call(this,"jRead",n,s,c),this.jRead(n,a,c)}xWrite(n,r,s,i,o){var f;const a=Et(this,fm,xx).call(this,r,s),c=_E(i,o);return(f=this.log)==null||f.call(this,"jWrite",n,a,c),this.jWrite(n,a,c)}xTruncate(n,r,s){var o;const i=_E(r,s);return(o=this.log)==null||o.call(this,"jTruncate",n,i),this.jTruncate(n,i)}xSync(n,r){var s;return(s=this.log)==null||s.call(this,"jSync",n,r),this.jSync(n,r)}xFileSize(n,r){var i;const s=Et(this,Ic,_p).call(this,"BigInt64",r);return(i=this.log)==null||i.call(this,"jFileSize",n),this.jFileSize(n,s)}xLock(n,r){var s;return(s=this.log)==null||s.call(this,"jLock",n,r),this.jLock(n,r)}xUnlock(n,r){var s;return(s=this.log)==null||s.call(this,"jUnlock",n,r),this.jUnlock(n,r)}xCheckReservedLock(n,r){var i;const s=Et(this,Ic,_p).call(this,"Int32",r);return(i=this.log)==null||i.call(this,"jCheckReservedLock",n),this.jCheckReservedLock(n,s)}xFileControl(n,r,s){var o;const i=new DataView(this._module.HEAPU8.buffer,this._module.HEAPU8.byteOffset+s);return(o=this.log)==null||o.call(this,"jFileControl",n,r,i),this.jFileControl(n,r,i)}xSectorSize(n){var r;return(r=this.log)==null||r.call(this,"jSectorSize",n),this.jSectorSize(n)}xDeviceCharacteristics(n){var r;return(r=this.log)==null||r.call(this,"jDeviceCharacteristics",n),this.jDeviceCharacteristics(n)}}Ic=new WeakSet,_p=function(n,r){const s=n==="Int32"?4:8,i=`get${n}`,o=`set${n}`,a=()=>new DataView(this._module.HEAPU8.buffer,this._module.HEAPU8.byteOffset+r,s);let c=a();return new Proxy(c,{get(f,d){if(c.buffer.byteLength===0&&(c=a()),d===i)return function(_,b){if(!b)throw new Error("must be little endian");return c[d](_,b)};if(d===o)return function(_,b,k){if(!k)throw new Error("must be little endian");return c[d](_,b,k)};if(typeof d=="string"&&/^(get)|(set)/.test(d))throw new Error("invalid type");const g=c[d];return typeof g=="function"?g.bind(c):g}})},fm=new WeakSet,xx=function(n,r){let s=this._module.HEAPU8.subarray(n,n+r);return new Proxy(s,{get:(i,o,a)=>{s.buffer.byteLength===0&&(s=this._module.HEAPU8.subarray(n,n+r));const c=s[o];return typeof c=="function"?c.bind(s):c}})},sv=new WeakSet,M5=function(n,r){if(r&F5){let s=n,i=1;const o=[];for(;i;){const a=this._module.HEAPU8[s++];if(a)o.push(a);else switch(this._module.HEAPU8[s]||(i=null),i){case 1:{o.push("?".charCodeAt(0)),i=2;break}case 2:{o.push("=".charCodeAt(0)),i=3;break}case 3:{o.push("&".charCodeAt(0)),i=2;break}}}return new TextDecoder().decode(new Uint8Array(o))}return n?this._module.UTF8ToString(n):null};function _E(e,t){return t*4294967296+e+(e<0?2**32:0)}const L5=4096,x2=512,Vbe=4,Wbe=8,Rx=x2+Vbe,GN=x2,QN=Rx,oc=L5,Kbe=Nbe|Dbe|qbe|Mbe,Gbe=6;var dm,Wa,Ei,Cs,Zi,ki,iv,z5,ov,j5,av,U5,Ka,df,hm,Ix,Ga,hf,pm,Tx;const P2=class P2 extends Bbe{constructor(n,r,s){super(n,s);Ft(this,iv);Ft(this,ov);Ft(this,av);Ft(this,Ka);Ft(this,hm);Ft(this,Ga);Ft(this,pm);p(this,"log",null);Ft(this,dm,void 0);Ft(this,Wa,void 0);Ft(this,Ei,new Map);Ft(this,Cs,new Map);Ft(this,Zi,new Set);Ft(this,ki,new Map);ec(this,dm,r)}static async create(n,r,s){const i=new P2(n,r,s);return await i.isReady(),i}getOpfsFileName(n){const r=Et(this,Ga,hf).call(this,n),s=ge(this,Cs).get(r);return ge(this,Ei).get(s)}resetAccessHandle(n){const r=Et(this,Ga,hf).call(this,n);ge(this,Cs).get(r).truncate(oc)}jOpen(n,r,s,i){try{const o=n?Et(this,Ga,hf).call(this,n):Math.random().toString(36);let a=ge(this,Cs).get(o);if(!a&&s&Y0)if(this.getSize()<this.getCapacity())[a]=ge(this,Zi).keys(),Et(this,Ka,df).call(this,a,o,s);else throw new Error("cannot create file");if(!a)throw new Error("file not found");const c={path:o,flags:s,accessHandle:a};return ge(this,ki).set(r,c),i.setInt32(0,s,!0),be}catch(o){return console.error(o.message),ky}}jClose(n){const r=ge(this,ki).get(n);return r&&(r.accessHandle.flush(),ge(this,ki).delete(n),r.flags&kx&&Et(this,pm,Tx).call(this,r.path)),be}jRead(n,r,s){const o=ge(this,ki).get(n).accessHandle.read(r.subarray(),{at:oc+s});return o<r.byteLength?(r.fill(0,o,r.byteLength),Db):be}jWrite(n,r,s){return ge(this,ki).get(n).accessHandle.write(r.subarray(),{at:oc+s})===r.byteLength?be:am}jTruncate(n,r){return ge(this,ki).get(n).accessHandle.truncate(oc+r),be}jSync(n,r){return ge(this,ki).get(n).accessHandle.flush(),be}jFileSize(n,r){const i=ge(this,ki).get(n).accessHandle.getSize()-oc;return r.setBigInt64(0,BigInt(i),!0),be}jSectorSize(n){return L5}jDeviceCharacteristics(n){return Lbe}jAccess(n,r,s){const i=Et(this,Ga,hf).call(this,n);return s.setInt32(0,ge(this,Cs).has(i)?1:0,!0),be}jDelete(n,r){const s=Et(this,Ga,hf).call(this,n);return Et(this,pm,Tx).call(this,s),be}async close(){Et(this,ov,j5).call(this)}async isReady(){if(!ge(this,Wa)){let n=await navigator.storage.getDirectory();for(const r of ge(this,dm).split("/"))r&&(n=await n.getDirectoryHandle(r,{create:!0}));ec(this,Wa,n),await Et(this,iv,z5).call(this),this.getCapacity()===0&&await this.addCapacity(Gbe)}return!0}getSize(){return ge(this,Cs).size}getCapacity(){return ge(this,Ei).size}async addCapacity(n){for(let r=0;r<n;++r){const s=Math.random().toString(36).replace("0.",""),o=await(await ge(this,Wa).getFileHandle(s,{create:!0})).createSyncAccessHandle();ge(this,Ei).set(o,s),Et(this,Ka,df).call(this,o,"",0)}return n}async removeCapacity(n){let r=0;for(const s of Array.from(ge(this,Zi))){if(r==n||this.getSize()===this.getCapacity())return r;const i=ge(this,Ei).get(s);s.close(),await ge(this,Wa).removeEntry(i),ge(this,Ei).delete(s),ge(this,Zi).delete(s),++r}return r}};dm=new WeakMap,Wa=new WeakMap,Ei=new WeakMap,Cs=new WeakMap,Zi=new WeakMap,ki=new WeakMap,iv=new WeakSet,z5=async function(){const n=[];for await(const[r,s]of ge(this,Wa))s.kind==="file"&&n.push([r,s]);await Promise.all(n.map(async([r,s])=>{const i=await s.createSyncAccessHandle();ge(this,Ei).set(i,r);const o=Et(this,av,U5).call(this,i);o?ge(this,Cs).set(o,i):ge(this,Zi).add(i)}))},ov=new WeakSet,j5=function(){for(const n of ge(this,Ei).keys())n.close();ge(this,Ei).clear(),ge(this,Cs).clear(),ge(this,Zi).clear()},av=new WeakSet,U5=function(n){const r=new Uint8Array(Rx);n.read(r,{at:0});const i=new DataView(r.buffer,r.byteOffset).getUint32(GN);if(r[0]&&(i&kx||!(i&Kbe)))return console.warn(`Remove file with unexpected flags ${i.toString(16)}`),Et(this,Ka,df).call(this,n,"",0),"";const o=new Uint32Array(Wbe/4);n.read(o,{at:QN});const a=Et(this,hm,Ix).call(this,r);if(o.every((c,f)=>c===a[f])){const c=r.indexOf(0);return c===0&&n.truncate(oc),new TextDecoder().decode(r.subarray(0,c))}else return console.warn("Disassociating file with bad digest."),Et(this,Ka,df).call(this,n,"",0),""},Ka=new WeakSet,df=function(n,r,s){const i=new Uint8Array(Rx);if(new TextEncoder().encodeInto(r,i).written>=x2)throw new Error("path too long");new DataView(i.buffer,i.byteOffset).setUint32(GN,s);const c=Et(this,hm,Ix).call(this,i);n.write(i,{at:0}),n.write(c,{at:QN}),n.flush(),r?(ge(this,Cs).set(r,n),ge(this,Zi).delete(n)):(n.truncate(oc),ge(this,Zi).add(n))},hm=new WeakSet,Ix=function(n){if(!n[0])return new Uint32Array([4274806656,2899230775]);let r=3735928559,s=1103547991;for(const i of n)r=Math.imul(r^i,2654435761),s=Math.imul(s^i,1597334677);return r=Math.imul(r^r>>>16,2246822507)^Math.imul(s^s>>>13,3266489909),s=Math.imul(s^s>>>16,2246822507)^Math.imul(r^r>>>13,3266489909),new Uint32Array([r>>>0,s>>>0])},Ga=new WeakSet,hf=function(n){return(typeof n=="string"?new URL(n,"file://localhost/"):n).pathname},pm=new WeakSet,Tx=function(n){const r=ge(this,Cs).get(n);r&&(ge(this,Cs).delete(n),Et(this,Ka,df).call(this,r,"",0))};let $x=P2;const Qbe=Ww(1).pipe(ur),JN=new Map,Jbe=({sqlite3:e,directory:t,fileName:n})=>X(function*(){const r=t.replaceAll(/["*/:<>?\\|]/g,"_"),i=`opfs${r.length===0?"":`-${r}`}`;if(e.vfs_registered.has(i)===!1){const c=yield*Fd(()=>$x.create(i,t,e.module));e.vfs_register(c,!1),JN.set(i,c)}const o=e.open_v2Sync(n,void 0,i),a=JN.get(i);return{dbPointer:o,vfs:a}}).pipe(Qbe.withPermits(1));new TextDecoder;const YN=({sqlite3:e})=>t=>X(function*(){if(t._tag==="in-memory"){const{dbPointer:o,vfs:a}=q5(e);return KN({sqlite3:e,metadata:{_tag:"in-memory",vfs:a,dbPointer:o,deleteDb:()=>{},configureDb:t.configureDb??(()=>{}),persistenceInfo:{fileName:":memory:"}}})}const n=60;let r=t.fileName;t.fileName.length>n&&(yield*Ps(`dbFilename too long: '${t.fileName}'. Max ${n} chars, got ${t.fileName.length}. Hashing...`),r=`hash-${tn(t.fileName)}.db`);const{dbPointer:s,vfs:i}=yield*Jbe({sqlite3:e,directory:t.opfsDirectory,fileName:r});return KN({sqlite3:e,metadata:{_tag:"opfs",vfs:i,dbPointer:s,deleteDb:()=>i.resetAccessHandle(t.fileName),configureDb:t.configureDb??(()=>{}),persistenceInfo:{fileName:r,opfsDirectory:t.opfsDirectory,opfsFileName:i.getOpfsFileName(r)}}})}),XN=0x7fffffffffffffffn,ZN=-0x8000000000000000n;class Ks extends Error{constructor(t,n){super(t),this.code=n}}const rf=!1;function Ybe(e){const t={};e.retryOps=[];const n=e._getSqliteFree(),r=e._malloc(8),s=[r,r+4];function i(E){if(typeof E!="string")return 0;const y=new TextEncoder().encode(E),m=e._sqlite3_malloc(y.byteLength+1);return e.HEAPU8.set(y,m),e.HEAPU8[m+y.byteLength]=0,m}function o(E,y){return BigInt(y)<<32n|BigInt(E)&0xffffffffn}const a=function(){const E=BigInt(Number.MAX_SAFE_INTEGER)>>32n,y=BigInt(Number.MIN_SAFE_INTEGER)>>32n;return function(m,v){return v>E||v<y?o(m,v):v*4294967296+(m&2147483647)-(m&2147483648)}}(),c=new Set;function f(E){if(!c.has(E))throw new Ks("not a database",qa)}const d=new Map;function g(E){if(!d.has(E))throw new Ks("not a statement",qa)}t.bind_collection=function(E,y){g(E);const m=Array.isArray(y),v=t.bind_parameter_count(E);for(let w=1;w<=v;++w){const $=m?w-1:t.bind_parameter_name(E,w),P=y[$];P!==void 0&&t.bind(E,w,P)}return be},t.bind=function(E,y,m){switch(g(E),typeof m){case"number":return m===(m|0)?t.bind_int(E,y,m):t.bind_double(E,y,m);case"string":return t.bind_text(E,y,m);default:return m instanceof Uint8Array||Array.isArray(m)?t.bind_blob(E,y,m):m===null?t.bind_null(E,y):typeof m=="bigint"?t.bind_int64(E,y,m):m===void 0?Abe:(console.warn("unknown binding converted to null",m),t.bind_null(E,y))}},t.bind_blob=function(){const E="sqlite3_bind_blob",y=e.cwrap(E,...xe("nnnnn:n"));return function(m,v,w){g(m);const $=w.byteLength??w.length,P=e._sqlite3_malloc($);e.HEAPU8.subarray(P).set(w);const O=y(m,v,P,$,n);return k(E,O,d.get(m))}}(),t.bind_parameter_count=function(){const E="sqlite3_bind_parameter_count",y=e.cwrap(E,...xe("n:n"));return function(m){return g(m),y(m)}}(),t.bind_double=function(){const E="sqlite3_bind_double",y=e.cwrap(E,...xe("nnn:n"));return function(m,v,w){g(m);const $=y(m,v,w);return k(E,$,d.get(m))}}(),t.bind_int=function(){const E="sqlite3_bind_int",y=e.cwrap(E,...xe("nnn:n"));return function(m,v,w){if(g(m),w>2147483647||w<-2147483648)return mE;const $=y(m,v,w);return k(E,$,d.get(m))}}(),t.bind_int64=function(){const E="sqlite3_bind_int64",y=e.cwrap(E,...xe("nnnn:n"));return function(m,v,w){if(g(m),w>XN||w<ZN)return mE;const $=w&0xffffffffn,P=w>>32n,O=y(m,v,Number($),Number(P));return k(E,O,d.get(m))}}(),t.bind_null=function(){const E="sqlite3_bind_null",y=e.cwrap(E,...xe("nn:n"));return function(m,v){g(m);const w=y(m,v);return k(E,w,d.get(m))}}(),t.bind_parameter_name=function(){const E="sqlite3_bind_parameter_name",y=e.cwrap(E,...xe("n:s"));return function(m,v){return g(m),y(m,v)}}(),t.bind_text=function(){const E="sqlite3_bind_text",y=e.cwrap(E,...xe("nnnnn:n"));return function(m,v,w){g(m);const $=i(w),P=y(m,v,$,-1,n);return k(E,P,d.get(m))}}(),t.changes=function(){const E="sqlite3_changes",y=e.cwrap(E,...xe("n:n"));return function(m){return f(m),y(m)}}(),t.deserialize=function(){const E="sqlite3_deserialize",y=e.cwrap(E,...xe("nnnnnn:n"));return function(m,v,w,$,P,O){f(m);const A=e._sqlite3_malloc($);return e.HEAPU8.subarray(A).set(w),y(m,v,A,$,P,O)}}();const _=1;t.serialize=function(){const E="sqlite3_serialize",y=e.cwrap(E,...xe("nsnn:n"));return function(m,v){f(m);const w=s[0];let $=y(m,v,w,0);if($===0){$=y(m,v,w,_);const P=e.getValue(w,"*"),O=e.HEAPU8.subarray($,$+P);return new Uint8Array(O.slice())}else{const P=e.getValue(w,"*"),O=e.HEAPU8.subarray($,$+P);return new Uint8Array(O)}}}(),t.backup=function(){const E=e.cwrap("sqlite3_backup_init",...xe("nsns:n")),y=e.cwrap("sqlite3_backup_step",...xe("nn:n")),m=e.cwrap("sqlite3_backup_finish",...xe("n:n"));return function(v,w,$,P){f(v),f($);const O=E(v,w,$,P);if(O===0){const A=e.ccall("sqlite3_errmsg","string",["number"],[v]);throw new Ks(`backup failed: ${A}`,Obe)}return y(O,-1),m(O)}}(),t.clear_bindings=function(){const E="sqlite3_clear_bindings",y=e.cwrap(E,...xe("n:n"));return function(m){g(m);const v=y(m);return k(E,v,d.get(m))}}(),t.close=function(){const E="sqlite3_close",y=e.cwrap(E,...xe("n:n"),{async:rf});return function(m){f(m);const v=y(m);return c.delete(m),k(E,v,m)}}(),t.column=function(E,y){g(E);const m=t.column_type(E,y);switch(m){case BN:return t.column_blob(E,y);case UN:return t.column_double(E,y);case jN:const v=t.column_int(E,y),w=e.getTempRet0();return a(v,w);case VN:return null;case HN:return t.column_text(E,y);default:throw new Ks("unknown type",m)}},t.column_blob=function(){const E="sqlite3_column_blob",y=e.cwrap(E,...xe("nn:n"));return function(m,v){g(m);const w=t.column_bytes(m,v),$=y(m,v);if($===0)return null;const P=e.HEAPU8.subarray($,$+w);return new Uint8Array(P)}}(),t.column_bytes=function(){const E="sqlite3_column_bytes",y=e.cwrap(E,...xe("nn:n"));return function(m,v){return g(m),y(m,v)}}(),t.column_count=function(){const E="sqlite3_column_count",y=e.cwrap(E,...xe("n:n"));return function(m){return g(m),y(m)}}(),t.column_double=function(){const E="sqlite3_column_double",y=e.cwrap(E,...xe("nn:n"));return function(m,v){return g(m),y(m,v)}}(),t.column_int=function(){const E="sqlite3_column_int64",y=e.cwrap(E,...xe("nn:n"));return function(m,v){return g(m),y(m,v)}}(),t.column_int64=function(){const E="sqlite3_column_int64",y=e.cwrap(E,...xe("nn:n"));return function(m,v){g(m);const w=y(m,v),$=e.getTempRet0();return o(w,$)}}(),t.column_name=function(){const E="sqlite3_column_name",y=e.cwrap(E,...xe("nn:s"));return function(m,v){return g(m),y(m,v)}}(),t.column_names=function(E){const y=[],m=t.column_count(E);for(let v=0;v<m;++v)y.push(t.column_name(E,v));return y},t.column_text=function(){const E="sqlite3_column_text",y=e.cwrap(E,...xe("nn:s"));return function(m,v){return g(m),y(m,v)}}(),t.column_type=function(){const E="sqlite3_column_type",y=e.cwrap(E,...xe("nn:n"));return function(m,v){return g(m),y(m,v)}}(),t.create_function=function(E,y,m,v,w,$,P,O){f(E);function A(D){return(W,le,M)=>D(W,e.HEAP32.subarray(M/4,M/4+le))}const z=e.create_function(E,y,m,v,w,$&&A($),P&&A(P),O);return k("sqlite3_create_function",z,E)},t.data_count=function(){const E="sqlite3_data_count",y=e.cwrap(E,...xe("n:n"));return function(m){return g(m),y(m)}}(),t.exec=function(E,y,m){const v=t.statements(E,y,{unscoped:!0});for(const w of v){let $;for(;t.step(w)===Ex;)if(m){$=$??t.column_names(w);const P=t.row(w);m(P,$),m(P,$)}}for(const w of v)t.finalize(w);return be},t.finalize=function(){const E="sqlite3_finalize",y=e.cwrap(E,...xe("n:n"),{async:rf});return function(m){const v=y(m);return d.delete(m),v}}(),t.get_autocommit=function(){const E="sqlite3_get_autocommit",y=e.cwrap(E,...xe("n:n"));return function(m){return y(m)}}(),t.libversion=function(){const E="sqlite3_libversion",y=e.cwrap(E,...xe(":s"));return function(){return y()}}(),t.libversion_number=function(){const E="sqlite3_libversion_number",y=e.cwrap(E,...xe(":n"));return function(){return y()}}(),t.limit=function(){const E="sqlite3_limit",y=e.cwrap(E,...xe("nnn:n"));return function(m,v,w){return y(m,v,w)}}(),t.open_v2=function(){const E="sqlite3_open_v2",y=e.cwrap(E,...xe("snnn:n"),{async:rf});return async function(m,v,w){v=v||Y0|zN,w=i(w);try{const $=await I(()=>y(m,s[0],v,w)),P=e.getValue(s[0],"*");return c.add(P),e.ccall("RegisterExtensionFunctions","void",["number"],[P]),k(E,$,P),P}finally{e._sqlite3_free(w)}}}(),t.open_v2Sync=function(){const E="sqlite3_open_v2",y=e.cwrap(E,...xe("snnn:n"),{async:rf});return function(m,v,w){v=v||Y0|zN,w=i(w);try{const $=y(m,s[0],v,w),P=e.getValue(s[0],"*");return c.add(P),e.ccall("RegisterExtensionFunctions","void",["number"],[P]),k(E,$,P),P}finally{e._sqlite3_free(w)}}}(),t.progress_handler=function(E,y,m,v){f(E),e.progress_handler(E,y,m,v)},t.reset=function(){const E="sqlite3_reset",y=e.cwrap(E,...xe("n:n"),{async:rf});return function(m){g(m);const v=y(m);return k(E,v,d.get(m))}}(),t.result=function(E,y){switch(typeof y){case"number":y===(y|0)?t.result_int(E,y):t.result_double(E,y);break;case"string":t.result_text(E,y);break;default:if(y instanceof Uint8Array||Array.isArray(y))t.result_blob(E,y);else if(y===null)t.result_null(E);else{if(typeof y=="bigint")return t.result_int64(E,y);console.warn("unknown result converted to null",y),t.result_null(E)}break}},t.result_blob=function(){const E="sqlite3_result_blob",y=e.cwrap(E,...xe("nnnn:n"));return function(m,v){const w=v.byteLength??v.length,$=e._sqlite3_malloc(w);e.HEAPU8.subarray($).set(v),y(m,$,w,n)}}(),t.result_double=function(){const E="sqlite3_result_double",y=e.cwrap(E,...xe("nn:n"));return function(m,v){y(m,v)}}(),t.result_int=function(){const E="sqlite3_result_int",y=e.cwrap(E,...xe("nn:n"));return function(m,v){y(m,v)}}(),t.result_int64=function(){const E="sqlite3_result_int64",y=e.cwrap(E,...xe("nnn:n"));return function(m,v){if(v>XN||v<ZN)return mE;const w=v&0xffffffffn,$=v>>32n;y(m,Number(w),Number($))}}(),t.result_null=function(){const E="sqlite3_result_null",y=e.cwrap(E,...xe("n:n"));return function(m){y(m)}}(),t.result_text=function(){const E="sqlite3_result_text",y=e.cwrap(E,...xe("nnnn:n"));return function(m,v){const w=i(v);y(m,w,-1,n)}}(),t.row=function(E){const y=[],m=t.data_count(E);for(let v=0;v<m;++v){const w=t.column(E,v);y.push((w==null?void 0:w.buffer)===e.HEAPU8.buffer?w.slice():w)}return y},t.set_authorizer=function(E,y,m){f(E);function v(P,O,A,z,D,W){return[P,O,e.UTF8ToString(A),e.UTF8ToString(z),e.UTF8ToString(D),e.UTF8ToString(W)]}function w(P){return(O,A,z,D,W,le)=>P(...v(O,A,z,D,W,le))}const $=e.set_authorizer(E,w(y),m);return k("sqlite3_set_authorizer",$,E)},t.sql=function(){const E="sqlite3_sql",y=e.cwrap(E,...xe("n:s"));return function(m){return g(m),y(m)}}(),t.statements=function(E,y,m={}){const v=e.cwrap("sqlite3_prepare_v3","number",["number","number","number","number","number","number"],{async:!1}),w=[],$=new TextEncoder().encode(y),P=$.byteLength-$.byteLength%4+12,O=e._sqlite3_malloc(P),A=O+$.byteLength+1;e.HEAPU8.set($,O),e.HEAPU8[A-1]=0;const z=O+P-8,D=O+P-4;let W;function le(){W&&!m.unscoped&&t.finalize(W),W=0}e.setValue(D,O,"*");do{le();const M=e.getValue(D,"*"),U=v(E,M,A-D,m.flags||0,z,D);U!==be&&k("sqlite3_prepare_v3",U,E),W=e.getValue(z,"*"),W&&(d.set(W,E),w.push(W))}while(W);return w},t.step=function(){const E="sqlite3_step",y=e.cwrap(E,...xe("n:n"),{async:rf});return function(m){g(m);const v=y(m);return k(E,v,d.get(m),[Ex,Fbe])}}(),t.commit_hook=function(E,y){f(E),e.commit_hook(E,y)},t.update_hook=function(E,y){f(E);function m(w,$,P,O,A){return[w,e.UTF8ToString($),e.UTF8ToString(P),o(O,A)]}function v(w){return($,P,O,A,z)=>w(...m($,P,O,A,z))}e.update_hook(E,v(y))},t.session_create=function(){const E="sqlite3session_create",y=e.cwrap(E,...xe("nsn:n"));return function(m,v){f(m);const w=e._malloc(4),$=y(m,v,w);return $!==be&&k(E,$,m),e.getValue(w,"i32")}}(),t.session_attach=function(){const E="sqlite3session_attach",y=e.cwrap(E,...xe("ns:n"));return function(m,v){if(typeof m!="number")throw new Ks("Invalid session object",qa);const w=y(m,v);return k(E,w)}}(),t.session_enable=function(){const E="sqlite3session_enable",y=e.cwrap(E,...xe("nn:n"));return function(m,v){const w=v?1:0;if(typeof m!="number")throw new Ks("Invalid session object",qa);if(y(m,w)!==w)throw new Ks("Failed to enable session",qa)}}(),t.session_changeset=function(){const E="sqlite3session_changeset",y=e.cwrap(E,...xe("nnn:n"));return function(m){if(typeof m!="number")throw new Ks("Invalid session object",qa);const v=e._malloc(4),w=e._malloc(4);try{const $=y(m,v,w);if($===be){const P=e.getValue(v,"i32"),O=e.getValue(w,"i32");if(O===0)return{result:$,size:0,changeset:null};const A=new Uint8Array(e.HEAPU8.subarray(O,O+P));return e._sqlite3_free(O),{result:$,size:P,changeset:A}}return k(E,$)}finally{e._free(v),e._free(w)}}}(),t.session_delete=function(){const E="sqlite3session_delete",y=e.cwrap(E,...xe("n:v"));return function(m){if(typeof m!="number")throw new Ks("Invalid session object",qa);return y(m)}}(),t.changeset_start=function(){const E="sqlite3changeset_start",y=e.cwrap(E,...xe("nnn:n"));return function(m){const v=e._sqlite3_malloc(m.length);e.HEAPU8.subarray(v).set(m);const w=e._malloc(4);try{const $=y(w,m.length,v);return $!==be&&k(E,$),e.getValue(w,"i32")}finally{e._sqlite3_free(v),e._free(w)}}}(),t.changeset_finalize=function(){const E="sqlite3changeset_finalize",y=e.cwrap(E,...xe("n:n"));return function(m){return y(m)}}(),t.changeset_invert=function(){const E="sqlite3changeset_invert",y=e.cwrap(E,...xe("nn:nn"));return function(m){const v=e._sqlite3_malloc(m.length);e.HEAPU8.subarray(v).set(m);const w=e._malloc(4),$=e._malloc(4),P=y(m.length,v,w,$);P!==be&&k(E,P);const O=e.getValue(w,"i32"),A=e.getValue($,"i32"),z=new Uint8Array(e.HEAPU8.buffer,A,O).slice();return e._sqlite3_free(v),e._sqlite3_free(A),z}}(),t.session_changeset_inverted=function(){const E="sqlite3session_changeset",y=e.cwrap(E,...xe("nnn:n")),m="sqlite3changeset_invert",v=e.cwrap(m,...xe("nn:nn"));return function(w){if(typeof w!="number")throw new Ks("Invalid session object",qa);const $=e._malloc(4),P=e._malloc(4),O=e._malloc(4),A=e._malloc(4);try{const z=y(w,$,P);if(z!==be)return k(E,z);const D=e.getValue($,"i32"),W=e.getValue(P,"i32"),le=v(D,W,O,A);if(le!==be)return k(m,le);const M=e.getValue(O,"i32"),U=e.getValue(A,"i32"),Q=new Uint8Array(e.HEAPU8.buffer,U,M);return e._sqlite3_free(W),e._sqlite3_free(U),{result:z,size:D,changeset:new Uint8Array(Q)}}finally{e._free($),e._free(P),e._free(O),e._free(A)}}}(),t.changeset_apply=function(){const E="sqlite3changeset_apply",y=e.cwrap(E,...xe("nnnnnn:n"));return function(m,v,w){const $=e._sqlite3_malloc(v.length);e.HEAPU8.subarray($).set(v);const P=1,O=()=>P,A=y(m,v.length,$,null,O,null);return e._sqlite3_free($),A!==be&&k(E,A),A}}(),t.value=function(E){const y=t.value_type(E);switch(y){case BN:return t.value_blob(E);case UN:return t.value_double(E);case jN:const m=t.value_int(E),v=e.getTempRet0();return a(m,v);case VN:return null;case HN:return t.value_text(E);default:throw new Ks("unknown type",y)}},t.value_blob=function(){const E="sqlite3_value_blob",y=e.cwrap(E,...xe("n:n"));return function(m){const v=t.value_bytes(m),w=y(m);return e.HEAPU8.subarray(w,w+v)}}(),t.value_bytes=function(){const E="sqlite3_value_bytes",y=e.cwrap(E,...xe("n:n"));return function(m){return y(m)}}(),t.value_double=function(){const E="sqlite3_value_double",y=e.cwrap(E,...xe("n:n"));return function(m){return y(m)}}(),t.value_int=function(){const E="sqlite3_value_int64",y=e.cwrap(E,...xe("n:n"));return function(m){return y(m)}}(),t.value_int64=function(){const E="sqlite3_value_int64",y=e.cwrap(E,...xe("n:n"));return function(m){const v=y(m),w=e.getTempRet0();return o(v,w)}}(),t.value_text=function(){const E="sqlite3_value_text",y=e.cwrap(E,...xe("n:s"));return function(m){return y(m)}}(),t.value_type=function(){const E="sqlite3_value_type",y=e.cwrap(E,...xe("n:n"));return function(m){return y(m)}}();const b=new Set;t.vfs_register=function(E,y){if(b.has(E.name))return;const m=e.vfs_register(E,y),v=k("sqlite3_vfs_register",m);return b.add(E.name),v},t.vfs_registered=b;function k(E,y,m=null,v=[be]){if(v.includes(y))return y;const w=m?e.ccall("sqlite3_errmsg","string",["number"],[m]):E;throw new Ks(w,y)}async function I(E){let y;do e.retryOps.length&&(await Promise.all(e.retryOps),e.retryOps=[]),y=await E();while(y&&e.retryOps.length);return y}return t}function xe(e){const t=[],n=e.match(/([ns@]*):([nsv@])/);switch(n[2]){case"n":t.push("number");break;case"s":t.push("string");break;case"v":t.push(null);break}const r=[];for(let s of n[1])switch(s){case"n":r.push("number");break;case"s":r.push("string");break}return t.push(r),t}var Xbe=(()=>{var e=import.meta.url;return function(t={}){var n,r=t,s,i,o=new Promise((l,u)=>{s=l,i=u}),a=typeof window=="object",c=typeof WorkerGlobalScope<"u";typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer";var f=Object.assign({},r),d="./this.program",g=(l,u)=>{throw u},_="";function b(l){return r.locateFile?r.locateFile(l,_):_+l}var k,I;(a||c)&&(c?_=self.location.href:typeof document<"u"&&document.currentScript&&(_=document.currentScript.src),e&&(_=e),_.startsWith("blob:")?_="":_=_.substr(0,_.replace(/[?#].*/,"").lastIndexOf("/")+1),c&&(I=l=>{var u=new XMLHttpRequest;return u.open("GET",l,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}),k=l=>fetch(l,{credentials:"same-origin"}).then(u=>u.ok?u.arrayBuffer():Promise.reject(new Error(u.status+" : "+u.url))));var E=r.print||console.log.bind(console),y=r.printErr||console.error.bind(console);Object.assign(r,f),f=null,r.arguments&&r.arguments,r.thisProgram&&(d=r.thisProgram);var m=r.wasmBinary,v,w=!1,$,P,O,A,z,D,W,le,M;function U(){var l=v.buffer;r.HEAP8=P=new Int8Array(l),r.HEAP16=A=new Int16Array(l),r.HEAPU8=O=new Uint8Array(l),r.HEAPU16=z=new Uint16Array(l),r.HEAP32=D=new Int32Array(l),r.HEAPU32=W=new Uint32Array(l),r.HEAPF32=le=new Float32Array(l),r.HEAPF64=M=new Float64Array(l)}var Q=[],L=[],G=[],V=[];function J(){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)dn(r.preRun.shift());Ao(Q)}function ee(){!r.noFSInit&&!C.initialized&&C.init(),C.ignorePermissions=!1,Ao(L)}function de(){Ao(G)}function Te(){if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)ir(r.postRun.shift());Ao(V)}function dn(l){Q.unshift(l)}function ln(l){L.unshift(l)}function ir(l){V.unshift(l)}var Dn=0,ns=null;function Wi(l){return l}function Kn(l){var u;Dn++,(u=r.monitorRunDependencies)==null||u.call(r,Dn)}function mi(l){var h;if(Dn--,(h=r.monitorRunDependencies)==null||h.call(r,Dn),Dn==0&&ns){var u=ns;ns=null,u()}}function $r(l){var h;(h=r.onAbort)==null||h.call(r,l),l="Aborted("+l+")",y(l),w=!0,l+=". Build with -sASSERTIONS for more info.";var u=new WebAssembly.RuntimeError(l);throw i(u),u}var qb="data:application/octet-stream;base64,",xy=l=>l.startsWith(qb);function O2(){if(r.locateFile){var l="wa-sqlite.wasm";return xy(l)?l:b(l)}return new URL("/assets/wa-sqlite-be172f22.wasm",self.location).href}var Ki;function ue(l){if(l==Ki&&m)return new Uint8Array(m);if(I)return I(l);throw"both async and sync fetching of the wasm failed"}function he(l){return m?Promise.resolve().then(()=>ue(l)):k(l).then(u=>new Uint8Array(u),()=>ue(l))}function at(l,u,h){return he(l).then(S=>WebAssembly.instantiate(S,u)).then(h,S=>{y(`failed to asynchronously prepare wasm: ${S}`),$r(S)})}function lt(l,u,h,S){return!l&&typeof WebAssembly.instantiateStreaming=="function"&&!xy(u)&&typeof fetch=="function"?fetch(u,{credentials:"same-origin"}).then(R=>{var N=WebAssembly.instantiateStreaming(R,h);return N.then(S,function(q){return y(`wasm streaming compile failed: ${q}`),y("falling back to ArrayBuffer instantiation"),at(u,h,S)})}):at(u,h,S)}function De(){return{a:rW}}function Ke(){function l(S,R){return F=S.exports,v=F.la,U(),Vu=F.of,ln(F.ma),mi(),F}Kn();function u(S){l(S.instance)}var h=De();if(r.instantiateWasm)try{return r.instantiateWasm(h,l)}catch(S){y(`Module.instantiateWasm callback failed with error: ${S}`),i(S)}return Ki??(Ki=O2()),lt(m,Ki,h,u).catch(i),{}}var Se,mt;class Pa{constructor(u){p(this,"name","ExitStatus");this.message=`Program terminated with exit(${u})`,this.status=u}}var Ao=l=>{for(;l.length>0;)l.shift()(r)};function A2(l,u="i8"){switch(u.endsWith("*")&&(u="*"),u){case"i1":return P[l];case"i8":return P[l];case"i16":return A[l>>1];case"i32":return D[l>>2];case"i64":$r("to do getValue(i64) use WASM_BIGINT");case"float":return le[l>>2];case"double":return M[l>>3];case"*":return W[l>>2];default:$r(`invalid type for getValue: ${u}`)}}var tB=r.noExitRuntime||!0;function Uu(l,u,h="i8"){switch(h.endsWith("*")&&(h="*"),h){case"i1":P[l]=u;break;case"i8":P[l]=u;break;case"i16":A[l>>1]=u;break;case"i32":D[l>>2]=u;break;case"i64":$r("to do setValue(i64) use WASM_BIGINT");case"float":le[l>>2]=u;break;case"double":M[l>>3]=u;break;case"*":W[l>>2]=u;break;default:$r(`invalid type for setValue: ${h}`)}}var nB=l=>Q2(l),rB=()=>Y2(),F2=typeof TextDecoder<"u"?new TextDecoder:void 0,Hu=(l,u=0,h=NaN)=>{for(var S=u+h,R=u;l[R]&&!(R>=S);)++R;if(R-u>16&&l.buffer&&F2)return F2.decode(l.subarray(u,R));for(var N="";u<R;){var q=l[u++];if(!(q&128)){N+=String.fromCharCode(q);continue}var j=l[u++]&63;if((q&224)==192){N+=String.fromCharCode((q&31)<<6|j);continue}var ne=l[u++]&63;if((q&240)==224?q=(q&15)<<12|j<<6|ne:q=(q&7)<<18|j<<12|ne<<6|l[u++]&63,q<65536)N+=String.fromCharCode(q);else{var me=q-65536;N+=String.fromCharCode(55296|me>>10,56320|me&1023)}}return N},Xl=(l,u)=>l?Hu(O,l,u):"",sB=(l,u,h,S)=>$r(`Assertion failed: ${Xl(l)}, at: `+[u?Xl(u):"unknown filename",h,S?Xl(S):"unknown function"]),Mt={isAbs:l=>l.charAt(0)==="/",splitPath:l=>{var u=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return u.exec(l).slice(1)},normalizeArray:(l,u)=>{for(var h=0,S=l.length-1;S>=0;S--){var R=l[S];R==="."?l.splice(S,1):R===".."?(l.splice(S,1),h++):h&&(l.splice(S,1),h--)}if(u)for(;h;h--)l.unshift("..");return l},normalize:l=>{var u=Mt.isAbs(l),h=l.substr(-1)==="/";return l=Mt.normalizeArray(l.split("/").filter(S=>!!S),!u).join("/"),!l&&!u&&(l="."),l&&h&&(l+="/"),(u?"/":"")+l},dirname:l=>{var u=Mt.splitPath(l),h=u[0],S=u[1];return!h&&!S?".":(S&&(S=S.substr(0,S.length-1)),h+S)},basename:l=>{if(l==="/")return"/";l=Mt.normalize(l),l=l.replace(/\/$/,"");var u=l.lastIndexOf("/");return u===-1?l:l.substr(u+1)},join:(...l)=>Mt.normalize(l.join("/")),join2:(l,u)=>Mt.normalize(l+"/"+u)},iB=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return l=>crypto.getRandomValues(l);$r("initRandomDevice")},N2=l=>(N2=iB())(l),Oa={resolve:(...l)=>{for(var u="",h=!1,S=l.length-1;S>=-1&&!h;S--){var R=S>=0?l[S]:C.cwd();if(typeof R!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!R)return"";u=R+"/"+u,h=Mt.isAbs(R)}return u=Mt.normalizeArray(u.split("/").filter(N=>!!N),!h).join("/"),(h?"/":"")+u||"."},relative:(l,u)=>{l=Oa.resolve(l).substr(1),u=Oa.resolve(u).substr(1);function h(me){for(var Ge=0;Ge<me.length&&me[Ge]==="";Ge++);for(var Xe=me.length-1;Xe>=0&&me[Xe]==="";Xe--);return Ge>Xe?[]:me.slice(Ge,Xe-Ge+1)}for(var S=h(l.split("/")),R=h(u.split("/")),N=Math.min(S.length,R.length),q=N,j=0;j<N;j++)if(S[j]!==R[j]){q=j;break}for(var ne=[],j=q;j<S.length;j++)ne.push("..");return ne=ne.concat(R.slice(q)),ne.join("/")}},Mb=[],Bu=l=>{for(var u=0,h=0;h<l.length;++h){var S=l.charCodeAt(h);S<=127?u++:S<=2047?u+=2:S>=55296&&S<=57343?(u+=4,++h):u+=3}return u},Lb=(l,u,h,S)=>{if(!(S>0))return 0;for(var R=h,N=h+S-1,q=0;q<l.length;++q){var j=l.charCodeAt(q);if(j>=55296&&j<=57343){var ne=l.charCodeAt(++q);j=65536+((j&1023)<<10)|ne&1023}if(j<=127){if(h>=N)break;u[h++]=j}else if(j<=2047){if(h+1>=N)break;u[h++]=192|j>>6,u[h++]=128|j&63}else if(j<=65535){if(h+2>=N)break;u[h++]=224|j>>12,u[h++]=128|j>>6&63,u[h++]=128|j&63}else{if(h+3>=N)break;u[h++]=240|j>>18,u[h++]=128|j>>12&63,u[h++]=128|j>>6&63,u[h++]=128|j&63}}return u[h]=0,h-R};function zb(l,u,h){var S=h>0?h:Bu(l)+1,R=new Array(S),N=Lb(l,R,0,R.length);return u&&(R.length=N),R}var oB=()=>{if(!Mb.length){var l=null;if(typeof window<"u"&&typeof window.prompt=="function"&&(l=window.prompt("Input: "),l!==null&&(l+=`
227
+ `)),!l)return null;Mb=zb(l,!0)}return Mb.shift()},Zl={ttys:[],init(){},shutdown(){},register(l,u){Zl.ttys[l]={input:[],output:[],ops:u},C.registerDevice(l,Zl.stream_ops)},stream_ops:{open(l){var u=Zl.ttys[l.node.rdev];if(!u)throw new C.ErrnoError(43);l.tty=u,l.seekable=!1},close(l){l.tty.ops.fsync(l.tty)},fsync(l){l.tty.ops.fsync(l.tty)},read(l,u,h,S,R){if(!l.tty||!l.tty.ops.get_char)throw new C.ErrnoError(60);for(var N=0,q=0;q<S;q++){var j;try{j=l.tty.ops.get_char(l.tty)}catch{throw new C.ErrnoError(29)}if(j===void 0&&N===0)throw new C.ErrnoError(6);if(j==null)break;N++,u[h+q]=j}return N&&(l.node.timestamp=Date.now()),N},write(l,u,h,S,R){if(!l.tty||!l.tty.ops.put_char)throw new C.ErrnoError(60);try{for(var N=0;N<S;N++)l.tty.ops.put_char(l.tty,u[h+N])}catch{throw new C.ErrnoError(29)}return S&&(l.node.timestamp=Date.now()),N}},default_tty_ops:{get_char(l){return oB()},put_char(l,u){u===null||u===10?(E(Hu(l.output)),l.output=[]):u!=0&&l.output.push(u)},fsync(l){l.output&&l.output.length>0&&(E(Hu(l.output)),l.output=[])},ioctl_tcgets(l){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(l,u,h){return 0},ioctl_tiocgwinsz(l){return[24,80]}},default_tty1_ops:{put_char(l,u){u===null||u===10?(y(Hu(l.output)),l.output=[]):u!=0&&l.output.push(u)},fsync(l){l.output&&l.output.length>0&&(y(Hu(l.output)),l.output=[])}}},aB=(l,u)=>{O.fill(0,l,l+u)},D2=(l,u)=>Math.ceil(l/u)*u,q2=l=>{l=D2(l,65536);var u=K2(65536,l);return u&&aB(u,l),u},Be={ops_table:null,mount(l){return Be.createNode(null,"/",16895,0)},createNode(l,u,h,S){if(C.isBlkdev(h)||C.isFIFO(h))throw new C.ErrnoError(63);Be.ops_table||(Be.ops_table={dir:{node:{getattr:Be.node_ops.getattr,setattr:Be.node_ops.setattr,lookup:Be.node_ops.lookup,mknod:Be.node_ops.mknod,rename:Be.node_ops.rename,unlink:Be.node_ops.unlink,rmdir:Be.node_ops.rmdir,readdir:Be.node_ops.readdir,symlink:Be.node_ops.symlink},stream:{llseek:Be.stream_ops.llseek}},file:{node:{getattr:Be.node_ops.getattr,setattr:Be.node_ops.setattr},stream:{llseek:Be.stream_ops.llseek,read:Be.stream_ops.read,write:Be.stream_ops.write,allocate:Be.stream_ops.allocate,mmap:Be.stream_ops.mmap,msync:Be.stream_ops.msync}},link:{node:{getattr:Be.node_ops.getattr,setattr:Be.node_ops.setattr,readlink:Be.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Be.node_ops.getattr,setattr:Be.node_ops.setattr},stream:C.chrdev_stream_ops}});var R=C.createNode(l,u,h,S);return C.isDir(R.mode)?(R.node_ops=Be.ops_table.dir.node,R.stream_ops=Be.ops_table.dir.stream,R.contents={}):C.isFile(R.mode)?(R.node_ops=Be.ops_table.file.node,R.stream_ops=Be.ops_table.file.stream,R.usedBytes=0,R.contents=null):C.isLink(R.mode)?(R.node_ops=Be.ops_table.link.node,R.stream_ops=Be.ops_table.link.stream):C.isChrdev(R.mode)&&(R.node_ops=Be.ops_table.chrdev.node,R.stream_ops=Be.ops_table.chrdev.stream),R.timestamp=Date.now(),l&&(l.contents[u]=R,l.timestamp=R.timestamp),R},getFileDataAsTypedArray(l){return l.contents?l.contents.subarray?l.contents.subarray(0,l.usedBytes):new Uint8Array(l.contents):new Uint8Array(0)},expandFileStorage(l,u){var h=l.contents?l.contents.length:0;if(!(h>=u)){var S=1024*1024;u=Math.max(u,h*(h<S?2:1.125)>>>0),h!=0&&(u=Math.max(u,256));var R=l.contents;l.contents=new Uint8Array(u),l.usedBytes>0&&l.contents.set(R.subarray(0,l.usedBytes),0)}},resizeFileStorage(l,u){if(l.usedBytes!=u)if(u==0)l.contents=null,l.usedBytes=0;else{var h=l.contents;l.contents=new Uint8Array(u),h&&l.contents.set(h.subarray(0,Math.min(u,l.usedBytes))),l.usedBytes=u}},node_ops:{getattr(l){var u={};return u.dev=C.isChrdev(l.mode)?l.id:1,u.ino=l.id,u.mode=l.mode,u.nlink=1,u.uid=0,u.gid=0,u.rdev=l.rdev,C.isDir(l.mode)?u.size=4096:C.isFile(l.mode)?u.size=l.usedBytes:C.isLink(l.mode)?u.size=l.link.length:u.size=0,u.atime=new Date(l.timestamp),u.mtime=new Date(l.timestamp),u.ctime=new Date(l.timestamp),u.blksize=4096,u.blocks=Math.ceil(u.size/u.blksize),u},setattr(l,u){u.mode!==void 0&&(l.mode=u.mode),u.timestamp!==void 0&&(l.timestamp=u.timestamp),u.size!==void 0&&Be.resizeFileStorage(l,u.size)},lookup(l,u){throw Be.doesNotExistError},mknod(l,u,h,S){return Be.createNode(l,u,h,S)},rename(l,u,h){if(C.isDir(l.mode)){var S;try{S=C.lookupNode(u,h)}catch{}if(S)for(var R in S.contents)throw new C.ErrnoError(55)}delete l.parent.contents[l.name],l.parent.timestamp=Date.now(),l.name=h,u.contents[h]=l,u.timestamp=l.parent.timestamp},unlink(l,u){delete l.contents[u],l.timestamp=Date.now()},rmdir(l,u){var h=C.lookupNode(l,u);for(var S in h.contents)throw new C.ErrnoError(55);delete l.contents[u],l.timestamp=Date.now()},readdir(l){var u=[".",".."];for(var h of Object.keys(l.contents))u.push(h);return u},symlink(l,u,h){var S=Be.createNode(l,u,41471,0);return S.link=h,S},readlink(l){if(!C.isLink(l.mode))throw new C.ErrnoError(28);return l.link}},stream_ops:{read(l,u,h,S,R){var N=l.node.contents;if(R>=l.node.usedBytes)return 0;var q=Math.min(l.node.usedBytes-R,S);if(q>8&&N.subarray)u.set(N.subarray(R,R+q),h);else for(var j=0;j<q;j++)u[h+j]=N[R+j];return q},write(l,u,h,S,R,N){if(u.buffer===P.buffer&&(N=!1),!S)return 0;var q=l.node;if(q.timestamp=Date.now(),u.subarray&&(!q.contents||q.contents.subarray)){if(N)return q.contents=u.subarray(h,h+S),q.usedBytes=S,S;if(q.usedBytes===0&&R===0)return q.contents=u.slice(h,h+S),q.usedBytes=S,S;if(R+S<=q.usedBytes)return q.contents.set(u.subarray(h,h+S),R),S}if(Be.expandFileStorage(q,R+S),q.contents.subarray&&u.subarray)q.contents.set(u.subarray(h,h+S),R);else for(var j=0;j<S;j++)q.contents[R+j]=u[h+j];return q.usedBytes=Math.max(q.usedBytes,R+S),S},llseek(l,u,h){var S=u;if(h===1?S+=l.position:h===2&&C.isFile(l.node.mode)&&(S+=l.node.usedBytes),S<0)throw new C.ErrnoError(28);return S},allocate(l,u,h){Be.expandFileStorage(l.node,u+h),l.node.usedBytes=Math.max(l.node.usedBytes,u+h)},mmap(l,u,h,S,R){if(!C.isFile(l.node.mode))throw new C.ErrnoError(43);var N,q,j=l.node.contents;if(!(R&2)&&j&&j.buffer===P.buffer)q=!1,N=j.byteOffset;else{if(q=!0,N=q2(u),!N)throw new C.ErrnoError(48);j&&((h>0||h+u<j.length)&&(j.subarray?j=j.subarray(h,h+u):j=Array.prototype.slice.call(j,h,h+u)),P.set(j,N))}return{ptr:N,allocated:q}},msync(l,u,h,S,R){return Be.stream_ops.write(l,u,0,S,h,!1),0}}},lB=(l,u,h,S)=>{var R=S?"":`al ${l}`;k(l).then(N=>{u(new Uint8Array(N)),R&&mi()},N=>{if(h)h();else throw`Loading data file "${l}" failed.`}),R&&Kn()},cB=(l,u,h,S,R,N)=>{C.createDataFile(l,u,h,S,R,N)},uB=r.preloadPlugins||[],fB=(l,u,h,S)=>{typeof Browser<"u"&&Browser.init();var R=!1;return uB.forEach(N=>{R||N.canHandle(u)&&(N.handle(l,u,h,S),R=!0)}),R},dB=(l,u,h,S,R,N,q,j,ne,me)=>{var Ge=u?Oa.resolve(Mt.join2(l,u)):l;function Xe(_t){function Ie(Ae){me==null||me(),j||cB(l,u,Ae,S,R,ne),N==null||N(),mi()}fB(_t,Ge,Ie,()=>{q==null||q(),mi()})||Ie(_t)}Kn(),typeof h=="string"?lB(h,Xe,q):Xe(h)},hB=l=>{var u={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},h=u[l];if(typeof h>"u")throw new Error(`Unknown file open mode: ${l}`);return h},jb=(l,u)=>{var h=0;return l&&(h|=365),u&&(h|=146),h},C={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:class{constructor(l){p(this,"name","ErrnoError");this.errno=l}},filesystems:null,syncFSRequests:0,readFiles:{},FSStream:class{constructor(){p(this,"shared",{})}get object(){return this.node}set object(l){this.node=l}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(l){this.shared.flags=l}get position(){return this.shared.position}set position(l){this.shared.position=l}},FSNode:class{constructor(l,u,h,S){p(this,"node_ops",{});p(this,"stream_ops",{});p(this,"readMode",365);p(this,"writeMode",146);p(this,"mounted",null);l||(l=this),this.parent=l,this.mount=l.mount,this.id=C.nextInode++,this.name=u,this.mode=h,this.rdev=S}get read(){return(this.mode&this.readMode)===this.readMode}set read(l){l?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(l){l?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return C.isDir(this.mode)}get isDevice(){return C.isChrdev(this.mode)}},lookupPath(l,u={}){if(l=Oa.resolve(l),!l)return{path:"",node:null};var h={follow_mount:!0,recurse_count:0};if(u=Object.assign(h,u),u.recurse_count>8)throw new C.ErrnoError(32);for(var S=l.split("/").filter(Xe=>!!Xe),R=C.root,N="/",q=0;q<S.length;q++){var j=q===S.length-1;if(j&&u.parent)break;if(R=C.lookupNode(R,S[q]),N=Mt.join2(N,S[q]),C.isMountpoint(R)&&(!j||j&&u.follow_mount)&&(R=R.mounted.root),!j||u.follow)for(var ne=0;C.isLink(R.mode);){var me=C.readlink(N);N=Oa.resolve(Mt.dirname(N),me);var Ge=C.lookupPath(N,{recurse_count:u.recurse_count+1});if(R=Ge.node,ne++>40)throw new C.ErrnoError(32)}}return{path:N,node:R}},getPath(l){for(var u;;){if(C.isRoot(l)){var h=l.mount.mountpoint;return u?h[h.length-1]!=="/"?`${h}/${u}`:h+u:h}u=u?`${l.name}/${u}`:l.name,l=l.parent}},hashName(l,u){for(var h=0,S=0;S<u.length;S++)h=(h<<5)-h+u.charCodeAt(S)|0;return(l+h>>>0)%C.nameTable.length},hashAddNode(l){var u=C.hashName(l.parent.id,l.name);l.name_next=C.nameTable[u],C.nameTable[u]=l},hashRemoveNode(l){var u=C.hashName(l.parent.id,l.name);if(C.nameTable[u]===l)C.nameTable[u]=l.name_next;else for(var h=C.nameTable[u];h;){if(h.name_next===l){h.name_next=l.name_next;break}h=h.name_next}},lookupNode(l,u){var h=C.mayLookup(l);if(h)throw new C.ErrnoError(h);for(var S=C.hashName(l.id,u),R=C.nameTable[S];R;R=R.name_next){var N=R.name;if(R.parent.id===l.id&&N===u)return R}return C.lookup(l,u)},createNode(l,u,h,S){var R=new C.FSNode(l,u,h,S);return C.hashAddNode(R),R},destroyNode(l){C.hashRemoveNode(l)},isRoot(l){return l===l.parent},isMountpoint(l){return!!l.mounted},isFile(l){return(l&61440)===32768},isDir(l){return(l&61440)===16384},isLink(l){return(l&61440)===40960},isChrdev(l){return(l&61440)===8192},isBlkdev(l){return(l&61440)===24576},isFIFO(l){return(l&61440)===4096},isSocket(l){return(l&49152)===49152},flagsToPermissionString(l){var u=["r","w","rw"][l&3];return l&512&&(u+="w"),u},nodePermissions(l,u){return C.ignorePermissions?0:u.includes("r")&&!(l.mode&292)||u.includes("w")&&!(l.mode&146)||u.includes("x")&&!(l.mode&73)?2:0},mayLookup(l){if(!C.isDir(l.mode))return 54;var u=C.nodePermissions(l,"x");return u||(l.node_ops.lookup?0:2)},mayCreate(l,u){var h;try{return h=C.lookupNode(l,u),20}catch{}return C.nodePermissions(l,"wx")},mayDelete(l,u,h){var S;try{S=C.lookupNode(l,u)}catch(N){return N.errno}var R=C.nodePermissions(l,"wx");if(R)return R;if(h){if(!C.isDir(S.mode))return 54;if(C.isRoot(S)||C.getPath(S)===C.cwd())return 10}else if(C.isDir(S.mode))return 31;return 0},mayOpen(l,u){return l?C.isLink(l.mode)?32:C.isDir(l.mode)&&(C.flagsToPermissionString(u)!=="r"||u&512)?31:C.nodePermissions(l,C.flagsToPermissionString(u)):44},MAX_OPEN_FDS:4096,nextfd(){for(var l=0;l<=C.MAX_OPEN_FDS;l++)if(!C.streams[l])return l;throw new C.ErrnoError(33)},getStreamChecked(l){var u=C.getStream(l);if(!u)throw new C.ErrnoError(8);return u},getStream:l=>C.streams[l],createStream(l,u=-1){return l=Object.assign(new C.FSStream,l),u==-1&&(u=C.nextfd()),l.fd=u,C.streams[u]=l,l},closeStream(l){C.streams[l]=null},dupStream(l,u=-1){var S,R;var h=C.createStream(l,u);return(R=(S=h.stream_ops)==null?void 0:S.dup)==null||R.call(S,h),h},chrdev_stream_ops:{open(l){var h,S;var u=C.getDevice(l.node.rdev);l.stream_ops=u.stream_ops,(S=(h=l.stream_ops).open)==null||S.call(h,l)},llseek(){throw new C.ErrnoError(70)}},major:l=>l>>8,minor:l=>l&255,makedev:(l,u)=>l<<8|u,registerDevice(l,u){C.devices[l]={stream_ops:u}},getDevice:l=>C.devices[l],getMounts(l){for(var u=[],h=[l];h.length;){var S=h.pop();u.push(S),h.push(...S.mounts)}return u},syncfs(l,u){typeof l=="function"&&(u=l,l=!1),C.syncFSRequests++,C.syncFSRequests>1&&y(`warning: ${C.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var h=C.getMounts(C.root.mount),S=0;function R(q){return C.syncFSRequests--,u(q)}function N(q){if(q)return N.errored?void 0:(N.errored=!0,R(q));++S>=h.length&&R(null)}h.forEach(q=>{if(!q.type.syncfs)return N(null);q.type.syncfs(q,l,N)})},mount(l,u,h){var S=h==="/",R=!h,N;if(S&&C.root)throw new C.ErrnoError(10);if(!S&&!R){var q=C.lookupPath(h,{follow_mount:!1});if(h=q.path,N=q.node,C.isMountpoint(N))throw new C.ErrnoError(10);if(!C.isDir(N.mode))throw new C.ErrnoError(54)}var j={type:l,opts:u,mountpoint:h,mounts:[]},ne=l.mount(j);return ne.mount=j,j.root=ne,S?C.root=ne:N&&(N.mounted=j,N.mount&&N.mount.mounts.push(j)),ne},unmount(l){var u=C.lookupPath(l,{follow_mount:!1});if(!C.isMountpoint(u.node))throw new C.ErrnoError(28);var h=u.node,S=h.mounted,R=C.getMounts(S);Object.keys(C.nameTable).forEach(q=>{for(var j=C.nameTable[q];j;){var ne=j.name_next;R.includes(j.mount)&&C.destroyNode(j),j=ne}}),h.mounted=null;var N=h.mount.mounts.indexOf(S);h.mount.mounts.splice(N,1)},lookup(l,u){return l.node_ops.lookup(l,u)},mknod(l,u,h){var S=C.lookupPath(l,{parent:!0}),R=S.node,N=Mt.basename(l);if(!N||N==="."||N==="..")throw new C.ErrnoError(28);var q=C.mayCreate(R,N);if(q)throw new C.ErrnoError(q);if(!R.node_ops.mknod)throw new C.ErrnoError(63);return R.node_ops.mknod(R,N,u,h)},statfs(l){var u={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:C.nextInode,ffree:C.nextInode-1,fsid:42,flags:2,namelen:255},h=C.lookupPath(l,{follow:!0}).node;return h!=null&&h.node_ops.statfs&&Object.assign(u,h.node_ops.statfs(h.mount.opts.root)),u},create(l,u=438){return u&=4095,u|=32768,C.mknod(l,u,0)},mkdir(l,u=511){return u&=1023,u|=16384,C.mknod(l,u,0)},mkdirTree(l,u){for(var h=l.split("/"),S="",R=0;R<h.length;++R)if(h[R]){S+="/"+h[R];try{C.mkdir(S,u)}catch(N){if(N.errno!=20)throw N}}},mkdev(l,u,h){return typeof h>"u"&&(h=u,u=438),u|=8192,C.mknod(l,u,h)},symlink(l,u){if(!Oa.resolve(l))throw new C.ErrnoError(44);var h=C.lookupPath(u,{parent:!0}),S=h.node;if(!S)throw new C.ErrnoError(44);var R=Mt.basename(u),N=C.mayCreate(S,R);if(N)throw new C.ErrnoError(N);if(!S.node_ops.symlink)throw new C.ErrnoError(63);return S.node_ops.symlink(S,R,l)},rename(l,u){var h=Mt.dirname(l),S=Mt.dirname(u),R=Mt.basename(l),N=Mt.basename(u),q,j,ne;if(q=C.lookupPath(l,{parent:!0}),j=q.node,q=C.lookupPath(u,{parent:!0}),ne=q.node,!j||!ne)throw new C.ErrnoError(44);if(j.mount!==ne.mount)throw new C.ErrnoError(75);var me=C.lookupNode(j,R),Ge=Oa.relative(l,S);if(Ge.charAt(0)!==".")throw new C.ErrnoError(28);if(Ge=Oa.relative(u,h),Ge.charAt(0)!==".")throw new C.ErrnoError(55);var Xe;try{Xe=C.lookupNode(ne,N)}catch{}if(me!==Xe){var _t=C.isDir(me.mode),Ie=C.mayDelete(j,R,_t);if(Ie)throw new C.ErrnoError(Ie);if(Ie=Xe?C.mayDelete(ne,N,_t):C.mayCreate(ne,N),Ie)throw new C.ErrnoError(Ie);if(!j.node_ops.rename)throw new C.ErrnoError(63);if(C.isMountpoint(me)||Xe&&C.isMountpoint(Xe))throw new C.ErrnoError(10);if(ne!==j&&(Ie=C.nodePermissions(j,"w"),Ie))throw new C.ErrnoError(Ie);C.hashRemoveNode(me);try{j.node_ops.rename(me,ne,N),me.parent=ne}catch(Ae){throw Ae}finally{C.hashAddNode(me)}}},rmdir(l){var u=C.lookupPath(l,{parent:!0}),h=u.node,S=Mt.basename(l),R=C.lookupNode(h,S),N=C.mayDelete(h,S,!0);if(N)throw new C.ErrnoError(N);if(!h.node_ops.rmdir)throw new C.ErrnoError(63);if(C.isMountpoint(R))throw new C.ErrnoError(10);h.node_ops.rmdir(h,S),C.destroyNode(R)},readdir(l){var u=C.lookupPath(l,{follow:!0}),h=u.node;if(!h.node_ops.readdir)throw new C.ErrnoError(54);return h.node_ops.readdir(h)},unlink(l){var u=C.lookupPath(l,{parent:!0}),h=u.node;if(!h)throw new C.ErrnoError(44);var S=Mt.basename(l),R=C.lookupNode(h,S),N=C.mayDelete(h,S,!1);if(N)throw new C.ErrnoError(N);if(!h.node_ops.unlink)throw new C.ErrnoError(63);if(C.isMountpoint(R))throw new C.ErrnoError(10);h.node_ops.unlink(h,S),C.destroyNode(R)},readlink(l){var u=C.lookupPath(l),h=u.node;if(!h)throw new C.ErrnoError(44);if(!h.node_ops.readlink)throw new C.ErrnoError(28);return h.node_ops.readlink(h)},stat(l,u){var h=C.lookupPath(l,{follow:!u}),S=h.node;if(!S)throw new C.ErrnoError(44);if(!S.node_ops.getattr)throw new C.ErrnoError(63);return S.node_ops.getattr(S)},lstat(l){return C.stat(l,!0)},chmod(l,u,h){var S;if(typeof l=="string"){var R=C.lookupPath(l,{follow:!h});S=R.node}else S=l;if(!S.node_ops.setattr)throw new C.ErrnoError(63);S.node_ops.setattr(S,{mode:u&4095|S.mode&-4096,timestamp:Date.now()})},lchmod(l,u){C.chmod(l,u,!0)},fchmod(l,u){var h=C.getStreamChecked(l);C.chmod(h.node,u)},chown(l,u,h,S){var R;if(typeof l=="string"){var N=C.lookupPath(l,{follow:!S});R=N.node}else R=l;if(!R.node_ops.setattr)throw new C.ErrnoError(63);R.node_ops.setattr(R,{timestamp:Date.now()})},lchown(l,u,h){C.chown(l,u,h,!0)},fchown(l,u,h){var S=C.getStreamChecked(l);C.chown(S.node,u,h)},truncate(l,u){if(u<0)throw new C.ErrnoError(28);var h;if(typeof l=="string"){var S=C.lookupPath(l,{follow:!0});h=S.node}else h=l;if(!h.node_ops.setattr)throw new C.ErrnoError(63);if(C.isDir(h.mode))throw new C.ErrnoError(31);if(!C.isFile(h.mode))throw new C.ErrnoError(28);var R=C.nodePermissions(h,"w");if(R)throw new C.ErrnoError(R);h.node_ops.setattr(h,{size:u,timestamp:Date.now()})},ftruncate(l,u){var h=C.getStreamChecked(l);if(!(h.flags&2097155))throw new C.ErrnoError(28);C.truncate(h.node,u)},utime(l,u,h){var S=C.lookupPath(l,{follow:!0}),R=S.node;R.node_ops.setattr(R,{timestamp:Math.max(u,h)})},open(l,u,h=438){if(l==="")throw new C.ErrnoError(44);u=typeof u=="string"?hB(u):u,u&64?h=h&4095|32768:h=0;var S;if(typeof l=="object")S=l;else{l=Mt.normalize(l);try{var R=C.lookupPath(l,{follow:!(u&131072)});S=R.node}catch{}}var N=!1;if(u&64)if(S){if(u&128)throw new C.ErrnoError(20)}else S=C.mknod(l,h,0),N=!0;if(!S)throw new C.ErrnoError(44);if(C.isChrdev(S.mode)&&(u&=-513),u&65536&&!C.isDir(S.mode))throw new C.ErrnoError(54);if(!N){var q=C.mayOpen(S,u);if(q)throw new C.ErrnoError(q)}u&512&&!N&&C.truncate(S,0),u&=-131713;var j=C.createStream({node:S,path:C.getPath(S),flags:u,seekable:!0,position:0,stream_ops:S.stream_ops,ungotten:[],error:!1});return j.stream_ops.open&&j.stream_ops.open(j),r.logReadFiles&&!(u&1)&&(l in C.readFiles||(C.readFiles[l]=1)),j},close(l){if(C.isClosed(l))throw new C.ErrnoError(8);l.getdents&&(l.getdents=null);try{l.stream_ops.close&&l.stream_ops.close(l)}catch(u){throw u}finally{C.closeStream(l.fd)}l.fd=null},isClosed(l){return l.fd===null},llseek(l,u,h){if(C.isClosed(l))throw new C.ErrnoError(8);if(!l.seekable||!l.stream_ops.llseek)throw new C.ErrnoError(70);if(h!=0&&h!=1&&h!=2)throw new C.ErrnoError(28);return l.position=l.stream_ops.llseek(l,u,h),l.ungotten=[],l.position},read(l,u,h,S,R){if(S<0||R<0)throw new C.ErrnoError(28);if(C.isClosed(l))throw new C.ErrnoError(8);if((l.flags&2097155)===1)throw new C.ErrnoError(8);if(C.isDir(l.node.mode))throw new C.ErrnoError(31);if(!l.stream_ops.read)throw new C.ErrnoError(28);var N=typeof R<"u";if(!N)R=l.position;else if(!l.seekable)throw new C.ErrnoError(70);var q=l.stream_ops.read(l,u,h,S,R);return N||(l.position+=q),q},write(l,u,h,S,R,N){if(S<0||R<0)throw new C.ErrnoError(28);if(C.isClosed(l))throw new C.ErrnoError(8);if(!(l.flags&2097155))throw new C.ErrnoError(8);if(C.isDir(l.node.mode))throw new C.ErrnoError(31);if(!l.stream_ops.write)throw new C.ErrnoError(28);l.seekable&&l.flags&1024&&C.llseek(l,0,2);var q=typeof R<"u";if(!q)R=l.position;else if(!l.seekable)throw new C.ErrnoError(70);var j=l.stream_ops.write(l,u,h,S,R,N);return q||(l.position+=j),j},allocate(l,u,h){if(C.isClosed(l))throw new C.ErrnoError(8);if(u<0||h<=0)throw new C.ErrnoError(28);if(!(l.flags&2097155))throw new C.ErrnoError(8);if(!C.isFile(l.node.mode)&&!C.isDir(l.node.mode))throw new C.ErrnoError(43);if(!l.stream_ops.allocate)throw new C.ErrnoError(138);l.stream_ops.allocate(l,u,h)},mmap(l,u,h,S,R){if(S&2&&!(R&2)&&(l.flags&2097155)!==2)throw new C.ErrnoError(2);if((l.flags&2097155)===1)throw new C.ErrnoError(2);if(!l.stream_ops.mmap)throw new C.ErrnoError(43);if(!u)throw new C.ErrnoError(28);return l.stream_ops.mmap(l,u,h,S,R)},msync(l,u,h,S,R){return l.stream_ops.msync?l.stream_ops.msync(l,u,h,S,R):0},ioctl(l,u,h){if(!l.stream_ops.ioctl)throw new C.ErrnoError(59);return l.stream_ops.ioctl(l,u,h)},readFile(l,u={}){if(u.flags=u.flags||0,u.encoding=u.encoding||"binary",u.encoding!=="utf8"&&u.encoding!=="binary")throw new Error(`Invalid encoding type "${u.encoding}"`);var h,S=C.open(l,u.flags),R=C.stat(l),N=R.size,q=new Uint8Array(N);return C.read(S,q,0,N,0),u.encoding==="utf8"?h=Hu(q):u.encoding==="binary"&&(h=q),C.close(S),h},writeFile(l,u,h={}){h.flags=h.flags||577;var S=C.open(l,h.flags,h.mode);if(typeof u=="string"){var R=new Uint8Array(Bu(u)+1),N=Lb(u,R,0,R.length);C.write(S,R,0,N,void 0,h.canOwn)}else if(ArrayBuffer.isView(u))C.write(S,u,0,u.byteLength,void 0,h.canOwn);else throw new Error("Unsupported data type");C.close(S)},cwd:()=>C.currentPath,chdir(l){var u=C.lookupPath(l,{follow:!0});if(u.node===null)throw new C.ErrnoError(44);if(!C.isDir(u.node.mode))throw new C.ErrnoError(54);var h=C.nodePermissions(u.node,"x");if(h)throw new C.ErrnoError(h);C.currentPath=u.path},createDefaultDirectories(){C.mkdir("/tmp"),C.mkdir("/home"),C.mkdir("/home/web_user")},createDefaultDevices(){C.mkdir("/dev"),C.registerDevice(C.makedev(1,3),{read:()=>0,write:(S,R,N,q,j)=>q,llseek:()=>0}),C.mkdev("/dev/null",C.makedev(1,3)),Zl.register(C.makedev(5,0),Zl.default_tty_ops),Zl.register(C.makedev(6,0),Zl.default_tty1_ops),C.mkdev("/dev/tty",C.makedev(5,0)),C.mkdev("/dev/tty1",C.makedev(6,0));var l=new Uint8Array(1024),u=0,h=()=>(u===0&&(u=N2(l).byteLength),l[--u]);C.createDevice("/dev","random",h),C.createDevice("/dev","urandom",h),C.mkdir("/dev/shm"),C.mkdir("/dev/shm/tmp")},createSpecialDirectories(){C.mkdir("/proc");var l=C.mkdir("/proc/self");C.mkdir("/proc/self/fd"),C.mount({mount(){var u=C.createNode(l,"fd",16895,73);return u.node_ops={lookup(h,S){var R=+S,N=C.getStreamChecked(R),q={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>N.path}};return q.parent=q,q}},u}},{},"/proc/self/fd")},createStandardStreams(l,u,h){l?C.createDevice("/dev","stdin",l):C.symlink("/dev/tty","/dev/stdin"),u?C.createDevice("/dev","stdout",null,u):C.symlink("/dev/tty","/dev/stdout"),h?C.createDevice("/dev","stderr",null,h):C.symlink("/dev/tty1","/dev/stderr"),C.open("/dev/stdin",0),C.open("/dev/stdout",1),C.open("/dev/stderr",1)},staticInit(){C.nameTable=new Array(4096),C.mount(Be,{},"/"),C.createDefaultDirectories(),C.createDefaultDevices(),C.createSpecialDirectories(),C.filesystems={MEMFS:Be}},init(l,u,h){C.initialized=!0,l??(l=r.stdin),u??(u=r.stdout),h??(h=r.stderr),C.createStandardStreams(l,u,h)},quit(){C.initialized=!1;for(var l=0;l<C.streams.length;l++){var u=C.streams[l];u&&C.close(u)}},findObject(l,u){var h=C.analyzePath(l,u);return h.exists?h.object:null},analyzePath(l,u){try{var h=C.lookupPath(l,{follow:!u});l=h.path}catch{}var S={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var h=C.lookupPath(l,{parent:!0});S.parentExists=!0,S.parentPath=h.path,S.parentObject=h.node,S.name=Mt.basename(l),h=C.lookupPath(l,{follow:!u}),S.exists=!0,S.path=h.path,S.object=h.node,S.name=h.node.name,S.isRoot=h.path==="/"}catch(R){S.error=R.errno}return S},createPath(l,u,h,S){l=typeof l=="string"?l:C.getPath(l);for(var R=u.split("/").reverse();R.length;){var N=R.pop();if(N){var q=Mt.join2(l,N);try{C.mkdir(q)}catch{}l=q}}return q},createFile(l,u,h,S,R){var N=Mt.join2(typeof l=="string"?l:C.getPath(l),u),q=jb(S,R);return C.create(N,q)},createDataFile(l,u,h,S,R,N){var q=u;l&&(l=typeof l=="string"?l:C.getPath(l),q=u?Mt.join2(l,u):l);var j=jb(S,R),ne=C.create(q,j);if(h){if(typeof h=="string"){for(var me=new Array(h.length),Ge=0,Xe=h.length;Ge<Xe;++Ge)me[Ge]=h.charCodeAt(Ge);h=me}C.chmod(ne,j|146);var _t=C.open(ne,577);C.write(_t,h,0,h.length,0,N),C.close(_t),C.chmod(ne,j)}},createDevice(l,u,h,S){var j;var R=Mt.join2(typeof l=="string"?l:C.getPath(l),u),N=jb(!!h,!!S);(j=C.createDevice).major??(j.major=64);var q=C.makedev(C.createDevice.major++,0);return C.registerDevice(q,{open(ne){ne.seekable=!1},close(ne){var me;(me=S==null?void 0:S.buffer)!=null&&me.length&&S(10)},read(ne,me,Ge,Xe,_t){for(var Ie=0,Ae=0;Ae<Xe;Ae++){var Lt;try{Lt=h()}catch{throw new C.ErrnoError(29)}if(Lt===void 0&&Ie===0)throw new C.ErrnoError(6);if(Lt==null)break;Ie++,me[Ge+Ae]=Lt}return Ie&&(ne.node.timestamp=Date.now()),Ie},write(ne,me,Ge,Xe,_t){for(var Ie=0;Ie<Xe;Ie++)try{S(me[Ge+Ie])}catch{throw new C.ErrnoError(29)}return Xe&&(ne.node.timestamp=Date.now()),Ie}}),C.mkdev(R,N,q)},forceLoadFile(l){if(l.isDevice||l.isFolder||l.link||l.contents)return!0;if(typeof XMLHttpRequest<"u")throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");try{l.contents=I(l.url),l.usedBytes=l.contents.length}catch{throw new C.ErrnoError(29)}},createLazyFile(l,u,h,S,R){class N{constructor(){p(this,"lengthKnown",!1);p(this,"chunks",[])}get(Ie){if(!(Ie>this.length-1||Ie<0)){var Ae=Ie%this.chunkSize,Lt=Ie/this.chunkSize|0;return this.getter(Lt)[Ae]}}setDataGetter(Ie){this.getter=Ie}cacheLength(){var Ie=new XMLHttpRequest;if(Ie.open("HEAD",h,!1),Ie.send(null),!(Ie.status>=200&&Ie.status<300||Ie.status===304))throw new Error("Couldn't load "+h+". Status: "+Ie.status);var Ae=Number(Ie.getResponseHeader("Content-length")),Lt,rs=(Lt=Ie.getResponseHeader("Accept-Ranges"))&&Lt==="bytes",bs=(Lt=Ie.getResponseHeader("Content-Encoding"))&&Lt==="gzip",yi=1024*1024;rs||(yi=Ae);var _i=(Gi,Ku)=>{if(Gi>Ku)throw new Error("invalid range ("+Gi+", "+Ku+") or no bytes requested!");if(Ku>Ae-1)throw new Error("only "+Ae+" bytes available! programmer error!");var _r=new XMLHttpRequest;if(_r.open("GET",h,!1),Ae!==yi&&_r.setRequestHeader("Range","bytes="+Gi+"-"+Ku),_r.responseType="arraybuffer",_r.overrideMimeType&&_r.overrideMimeType("text/plain; charset=x-user-defined"),_r.send(null),!(_r.status>=200&&_r.status<300||_r.status===304))throw new Error("Couldn't load "+h+". Status: "+_r.status);return _r.response!==void 0?new Uint8Array(_r.response||[]):zb(_r.responseText||"",!0)},Nh=this;Nh.setDataGetter(Gi=>{var Ku=Gi*yi,_r=(Gi+1)*yi-1;if(_r=Math.min(_r,Ae-1),typeof Nh.chunks[Gi]>"u"&&(Nh.chunks[Gi]=_i(Ku,_r)),typeof Nh.chunks[Gi]>"u")throw new Error("doXHR failed!");return Nh.chunks[Gi]}),(bs||!Ae)&&(yi=Ae=1,Ae=this.getter(0).length,yi=Ae,E("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=Ae,this._chunkSize=yi,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!c)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var q=new N,j={isDevice:!1,contents:q}}else var j={isDevice:!1,url:h};var ne=C.createFile(l,u,j,S,R);j.contents?ne.contents=j.contents:j.url&&(ne.contents=null,ne.url=j.url),Object.defineProperties(ne,{usedBytes:{get:function(){return this.contents.length}}});var me={},Ge=Object.keys(ne.stream_ops);Ge.forEach(_t=>{var Ie=ne.stream_ops[_t];me[_t]=(...Ae)=>(C.forceLoadFile(ne),Ie(...Ae))});function Xe(_t,Ie,Ae,Lt,rs){var bs=_t.node.contents;if(rs>=bs.length)return 0;var yi=Math.min(bs.length-rs,Lt);if(bs.slice)for(var _i=0;_i<yi;_i++)Ie[Ae+_i]=bs[rs+_i];else for(var _i=0;_i<yi;_i++)Ie[Ae+_i]=bs.get(rs+_i);return yi}return me.read=(_t,Ie,Ae,Lt,rs)=>(C.forceLoadFile(ne),Xe(_t,Ie,Ae,Lt,rs)),me.mmap=(_t,Ie,Ae,Lt,rs)=>{C.forceLoadFile(ne);var bs=q2(Ie);if(!bs)throw new C.ErrnoError(48);return Xe(_t,P,bs,Ie,Ae),{ptr:bs,allocated:!0}},ne.stream_ops=me,ne}},ot={DEFAULT_POLLMASK:5,calculateAt(l,u,h){if(Mt.isAbs(u))return u;var S;if(l===-100)S=C.cwd();else{var R=ot.getStreamFromFD(l);S=R.path}if(u.length==0){if(!h)throw new C.ErrnoError(44);return S}return Mt.join2(S,u)},doStat(l,u,h){var S=l(u);D[h>>2]=S.dev,D[h+4>>2]=S.mode,W[h+8>>2]=S.nlink,D[h+12>>2]=S.uid,D[h+16>>2]=S.gid,D[h+20>>2]=S.rdev,mt=[S.size>>>0,(Se=S.size,+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[h+24>>2]=mt[0],D[h+28>>2]=mt[1],D[h+32>>2]=4096,D[h+36>>2]=S.blocks;var R=S.atime.getTime(),N=S.mtime.getTime(),q=S.ctime.getTime();return mt=[Math.floor(R/1e3)>>>0,(Se=Math.floor(R/1e3),+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[h+40>>2]=mt[0],D[h+44>>2]=mt[1],W[h+48>>2]=R%1e3*1e3*1e3,mt=[Math.floor(N/1e3)>>>0,(Se=Math.floor(N/1e3),+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[h+56>>2]=mt[0],D[h+60>>2]=mt[1],W[h+64>>2]=N%1e3*1e3*1e3,mt=[Math.floor(q/1e3)>>>0,(Se=Math.floor(q/1e3),+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[h+72>>2]=mt[0],D[h+76>>2]=mt[1],W[h+80>>2]=q%1e3*1e3*1e3,mt=[S.ino>>>0,(Se=S.ino,+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[h+88>>2]=mt[0],D[h+92>>2]=mt[1],0},doMsync(l,u,h,S,R){if(!C.isFile(u.node.mode))throw new C.ErrnoError(43);if(S&2)return 0;var N=O.slice(l,l+h);C.msync(u,N,R,h,S)},getStreamFromFD(l){var u=C.getStreamChecked(l);return u},varargs:void 0,getStr(l){var u=Xl(l);return u}};function pB(l,u){try{return l=ot.getStr(l),C.chmod(l,u),0}catch(h){if(typeof C>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function gB(l,u,h,S){try{if(u=ot.getStr(u),u=ot.calculateAt(l,u),h&-8)return-28;var R=C.lookupPath(u,{follow:!0}),N=R.node;if(!N)return-44;var q="";return h&4&&(q+="r"),h&2&&(q+="w"),h&1&&(q+="x"),q&&C.nodePermissions(N,q)?-2:0}catch(j){if(typeof C>"u"||j.name!=="ErrnoError")throw j;return-j.errno}}function mB(l,u){try{return C.fchmod(l,u),0}catch(h){if(typeof C>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function yB(l,u,h){try{return C.fchown(l,u,h),0}catch(S){if(typeof C>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}var Ry=()=>{var l=D[+ot.varargs>>2];return ot.varargs+=4,l},_B=Ry;function SB(l,u,h){ot.varargs=h;try{var S=ot.getStreamFromFD(l);switch(u){case 0:{var R=Ry();if(R<0)return-28;for(;C.streams[R];)R++;var N;return N=C.dupStream(S,R),N.fd}case 1:case 2:return 0;case 3:return S.flags;case 4:{var R=Ry();return S.flags|=R,0}case 12:{var R=_B(),q=0;return A[R+q>>1]=2,0}case 13:case 14:return 0}return-28}catch(j){if(typeof C>"u"||j.name!=="ErrnoError")throw j;return-j.errno}}function vB(l,u){try{var h=ot.getStreamFromFD(l);return ot.doStat(C.stat,h.path,u)}catch(S){if(typeof C>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}var Ah=(l,u)=>u+2097152>>>0<4194305-!!l?(l>>>0)+u*4294967296:NaN;function wB(l,u,h){var S=Ah(u,h);try{return isNaN(S)?61:(C.ftruncate(l,S),0)}catch(R){if(typeof C>"u"||R.name!=="ErrnoError")throw R;return-R.errno}}var Aa=(l,u,h)=>Lb(l,O,u,h);function bB(l,u){try{if(u===0)return-28;var h=C.cwd(),S=Bu(h)+1;return u<S?-68:(Aa(h,l,u),S)}catch(R){if(typeof C>"u"||R.name!=="ErrnoError")throw R;return-R.errno}}function EB(l,u){try{return l=ot.getStr(l),ot.doStat(C.lstat,l,u)}catch(h){if(typeof C>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function kB(l,u,h){try{return u=ot.getStr(u),u=ot.calculateAt(l,u),u=Mt.normalize(u),u[u.length-1]==="/"&&(u=u.substr(0,u.length-1)),C.mkdir(u,h,0),0}catch(S){if(typeof C>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}function CB(l,u,h,S){try{u=ot.getStr(u);var R=S&256,N=S&4096;return S=S&-6401,u=ot.calculateAt(l,u,N),ot.doStat(R?C.lstat:C.stat,u,h)}catch(q){if(typeof C>"u"||q.name!=="ErrnoError")throw q;return-q.errno}}function xB(l,u,h,S){ot.varargs=S;try{u=ot.getStr(u),u=ot.calculateAt(l,u);var R=S?Ry():0;return C.open(u,h,R).fd}catch(N){if(typeof C>"u"||N.name!=="ErrnoError")throw N;return-N.errno}}function RB(l,u,h,S){try{if(u=ot.getStr(u),u=ot.calculateAt(l,u),S<=0)return-28;var R=C.readlink(u),N=Math.min(S,Bu(R)),q=P[h+N];return Aa(R,h,S+1),P[h+N]=q,N}catch(j){if(typeof C>"u"||j.name!=="ErrnoError")throw j;return-j.errno}}function $B(l){try{return l=ot.getStr(l),C.rmdir(l),0}catch(u){if(typeof C>"u"||u.name!=="ErrnoError")throw u;return-u.errno}}function IB(l,u){try{return l=ot.getStr(l),ot.doStat(C.stat,l,u)}catch(h){if(typeof C>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function TB(l,u,h){try{return u=ot.getStr(u),u=ot.calculateAt(l,u),h===0?C.unlink(u):h===512?C.rmdir(u):$r("Invalid flags passed to unlinkat"),0}catch(S){if(typeof C>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}var M2=l=>W[l>>2]+D[l+4>>2]*4294967296;function PB(l,u,h,S){try{u=ot.getStr(u),u=ot.calculateAt(l,u,!0);var R=Date.now(),N,q;if(!h)N=R,q=R;else{var j=M2(h),ne=D[h+8>>2];ne==1073741823?N=R:ne==1073741822?N=-1:N=j*1e3+ne/(1e3*1e3),h+=16,j=M2(h),ne=D[h+8>>2],ne==1073741823?q=R:ne==1073741822?q=-1:q=j*1e3+ne/(1e3*1e3)}return(q!=-1||N!=-1)&&C.utime(u,N,q),0}catch(me){if(typeof C>"u"||me.name!=="ErrnoError")throw me;return-me.errno}}var OB=l=>l%4===0&&(l%100!==0||l%400===0),AB=[0,31,60,91,121,152,182,213,244,274,305,335],FB=[0,31,59,90,120,151,181,212,243,273,304,334],NB=l=>{var u=OB(l.getFullYear()),h=u?AB:FB,S=h[l.getMonth()]+l.getDate()-1;return S};function DB(l,u,h){var S=Ah(l,u),R=new Date(S*1e3);D[h>>2]=R.getSeconds(),D[h+4>>2]=R.getMinutes(),D[h+8>>2]=R.getHours(),D[h+12>>2]=R.getDate(),D[h+16>>2]=R.getMonth(),D[h+20>>2]=R.getFullYear()-1900,D[h+24>>2]=R.getDay();var N=NB(R)|0;D[h+28>>2]=N,D[h+36>>2]=-(R.getTimezoneOffset()*60);var q=new Date(R.getFullYear(),0,1),j=new Date(R.getFullYear(),6,1).getTimezoneOffset(),ne=q.getTimezoneOffset(),me=(j!=ne&&R.getTimezoneOffset()==Math.min(ne,j))|0;D[h+32>>2]=me}function qB(l,u,h,S,R,N,q,j){var ne=Ah(R,N);try{if(isNaN(ne))return 61;var me=ot.getStreamFromFD(S),Ge=C.mmap(me,l,ne,u,h),Xe=Ge.ptr;return D[q>>2]=Ge.allocated,W[j>>2]=Xe,0}catch(_t){if(typeof C>"u"||_t.name!=="ErrnoError")throw _t;return-_t.errno}}function MB(l,u,h,S,R,N,q){var j=Ah(N,q);try{var ne=ot.getStreamFromFD(R);h&2&&ot.doMsync(l,ne,u,S,j)}catch(me){if(typeof C>"u"||me.name!=="ErrnoError")throw me;return-me.errno}}var LB=(l,u,h,S)=>{var R=new Date().getFullYear(),N=new Date(R,0,1),q=new Date(R,6,1),j=N.getTimezoneOffset(),ne=q.getTimezoneOffset(),me=Math.max(j,ne);W[l>>2]=me*60,D[u>>2]=+(j!=ne);var Ge=Ie=>{var Ae=Ie>=0?"-":"+",Lt=Math.abs(Ie),rs=String(Math.floor(Lt/60)).padStart(2,"0"),bs=String(Lt%60).padStart(2,"0");return`UTC${Ae}${rs}${bs}`},Xe=Ge(j),_t=Ge(ne);ne<j?(Aa(Xe,h,17),Aa(_t,S,17)):(Aa(Xe,S,17),Aa(_t,h,17))},zB=()=>Date.now(),jB=()=>performance.now(),UB=()=>2147483648,HB=l=>{var u=v.buffer,h=(l-u.byteLength+65535)/65536|0;try{return v.grow(h),U(),1}catch{}},BB=l=>{var u=O.length;l>>>=0;var h=UB();if(l>h)return!1;for(var S=1;S<=4;S*=2){var R=u*(1+.2/S);R=Math.min(R,l+100663296);var N=Math.min(h,D2(Math.max(l,R),65536)),q=HB(N);if(q)return!0}return!1},Ub={},VB=()=>d||"./this.program",Fh=()=>{if(!Fh.strings){var l=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",u={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:l,_:VB()};for(var h in Ub)Ub[h]===void 0?delete u[h]:u[h]=Ub[h];var S=[];for(var h in u)S.push(`${h}=${u[h]}`);Fh.strings=S}return Fh.strings},WB=(l,u)=>{for(var h=0;h<l.length;++h)P[u++]=l.charCodeAt(h);P[u]=0},KB=(l,u)=>{var h=0;return Fh().forEach((S,R)=>{var N=u+h;W[l+R*4>>2]=N,WB(S,N),h+=S.length+1}),0},GB=(l,u)=>{var h=Fh();W[l>>2]=h.length;var S=0;return h.forEach(R=>S+=R.length+1),W[u>>2]=S,0};function QB(l){try{var u=ot.getStreamFromFD(l);return C.close(u),0}catch(h){if(typeof C>"u"||h.name!=="ErrnoError")throw h;return h.errno}}function JB(l,u){try{var h=0,S=0,R=0,N=ot.getStreamFromFD(l),q=N.tty?2:C.isDir(N.mode)?3:C.isLink(N.mode)?7:4;return P[u]=q,A[u+2>>1]=R,mt=[h>>>0,(Se=h,+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[u+8>>2]=mt[0],D[u+12>>2]=mt[1],mt=[S>>>0,(Se=S,+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[u+16>>2]=mt[0],D[u+20>>2]=mt[1],0}catch(j){if(typeof C>"u"||j.name!=="ErrnoError")throw j;return j.errno}}var YB=(l,u,h,S)=>{for(var R=0,N=0;N<h;N++){var q=W[u>>2],j=W[u+4>>2];u+=8;var ne=C.read(l,P,q,j,S);if(ne<0)return-1;if(R+=ne,ne<j)break;typeof S<"u"&&(S+=ne)}return R};function XB(l,u,h,S){try{var R=ot.getStreamFromFD(l),N=YB(R,u,h);return W[S>>2]=N,0}catch(q){if(typeof C>"u"||q.name!=="ErrnoError")throw q;return q.errno}}function ZB(l,u,h,S,R){var N=Ah(u,h);try{if(isNaN(N))return 61;var q=ot.getStreamFromFD(l);return C.llseek(q,N,S),mt=[q.position>>>0,(Se=q.position,+Math.abs(Se)>=1?Se>0?+Math.floor(Se/4294967296)>>>0:~~+Math.ceil((Se-+(~~Se>>>0))/4294967296)>>>0:0)],D[R>>2]=mt[0],D[R+4>>2]=mt[1],q.getdents&&N===0&&S===0&&(q.getdents=null),0}catch(j){if(typeof C>"u"||j.name!=="ErrnoError")throw j;return j.errno}}function eV(l){var h;try{var u=ot.getStreamFromFD(l);return(h=u.stream_ops)!=null&&h.fsync?u.stream_ops.fsync(u):0}catch(S){if(typeof C>"u"||S.name!=="ErrnoError")throw S;return S.errno}}var tV=(l,u,h,S)=>{for(var R=0,N=0;N<h;N++){var q=W[u>>2],j=W[u+4>>2];u+=8;var ne=C.write(l,P,q,j,S);if(ne<0)return-1;if(R+=ne,ne<j)break;typeof S<"u"&&(S+=ne)}return R};function nV(l,u,h,S){try{var R=ot.getStreamFromFD(l),N=tV(R,u,h);return W[S>>2]=N,0}catch(q){if(typeof C>"u"||q.name!=="ErrnoError")throw q;return q.errno}}var yt=function(){const l=typeof Asyncify=="object"?Asyncify.handleAsync.bind(Asyncify):null;r.handleAsync=l;const u=new Map;r.setCallback=(h,S)=>u.set(h,S),r.getCallback=h=>u.get(h),r.deleteCallback=h=>u.delete(h),yt=function(h,S,...R){const N=u.get(S);let q=null;const j=typeof N=="function"?N:N[q=Xl(R.shift())];if(h){if(l)return l(()=>j.apply(N,R));throw new Error("Synchronous WebAssembly cannot call async function")}const ne=j.apply(N,R);if(typeof(ne==null?void 0:ne.then)=="function")throw console.error("unexpected Promise",j),new Error(`${q} unexpectedly returned a Promise`);return ne}};function rV(...l){return yt(!1,...l)}function sV(...l){return yt(!0,...l)}function iV(...l){return yt(!1,...l)}function oV(...l){return yt(!0,...l)}function aV(...l){return yt(!1,...l)}function lV(...l){return yt(!0,...l)}function cV(...l){return yt(!1,...l)}function uV(...l){return yt(!0,...l)}function fV(...l){return yt(!1,...l)}function dV(...l){return yt(!0,...l)}function hV(...l){return yt(!1,...l)}function pV(...l){return yt(!0,...l)}function gV(...l){return yt(!1,...l)}function mV(...l){return yt(!0,...l)}function yV(...l){return yt(!1,...l)}function _V(...l){return yt(!0,...l)}function SV(...l){return yt(!1,...l)}function vV(...l){return yt(!0,...l)}function wV(...l){return yt(!1,...l)}function bV(...l){return yt(!0,...l)}function EV(...l){return yt(!1,...l)}function kV(...l){return yt(!0,...l)}function CV(...l){return yt(!1,...l)}function xV(...l){return yt(!0,...l)}function RV(...l){return yt(!1,...l)}function $V(...l){return yt(!0,...l)}function IV(...l){return yt(!1,...l)}function TV(...l){return yt(!0,...l)}function PV(...l){return yt(!1,...l)}function OV(...l){return yt(!0,...l)}function AV(...l){return yt(!1,...l)}function FV(...l){return yt(!0,...l)}var NV=0,DV=()=>tB||NV>0,qV=l=>{var u;$=l,DV()||((u=r.onExit)==null||u.call(r,l),w=!0),g(l,new Pa(l))},MV=(l,u)=>{$=l,qV(l)},LV=l=>{if(l instanceof Pa||l=="unwind")return $;g(1,l)},L2=(l,u)=>{l<128?u.push(l):u.push(l%128|128,l>>7)},zV=l=>{for(var u={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},h={parameters:[],results:l[0]=="v"?[]:[u[l[0]]]},S=1;S<l.length;++S)h.parameters.push(u[l[S]]);return h},jV=(l,u)=>{var h=l.slice(0,1),S=l.slice(1),R={i:127,p:127,j:126,f:125,d:124,e:111};u.push(96),L2(S.length,u);for(var N=0;N<S.length;++N)u.push(R[S[N]]);h=="v"?u.push(0):u.push(1,R[h])},UV=(l,u)=>{if(typeof WebAssembly.Function=="function")return new WebAssembly.Function(zV(u),l);var h=[1];jV(u,h);var S=[0,97,115,109,1,0,0,0,1];L2(h.length,S),S.push(...h),S.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);var R=new WebAssembly.Module(new Uint8Array(S)),N=new WebAssembly.Instance(R,{e:{f:l}}),q=N.exports.f;return q},Vu,HV=l=>Vu.get(l),BV=(l,u)=>{if(Wu)for(var h=l;h<l+u;h++){var S=HV(h);S&&Wu.set(S,h)}},Wu,VV=l=>(Wu||(Wu=new WeakMap,BV(0,Vu.length)),Wu.get(l)||0),z2=[],WV=()=>{if(z2.length)return z2.pop();try{Vu.grow(1)}catch(l){throw l instanceof RangeError?"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.":l}return Vu.length-1},j2=(l,u)=>Vu.set(l,u),KV=(l,u)=>{var h=VV(l);if(h)return h;var S=WV();try{j2(S,l)}catch(N){if(!(N instanceof TypeError))throw N;var R=UV(l,u);j2(S,R)}return Wu.set(l,S),S},U2=l=>{var u=r["_"+l];return u},H2=(l,u)=>{P.set(l,u)},B2=l=>J2(l),GV=l=>{var u=Bu(l)+1,h=B2(u);return Aa(l,h,u),h},Fa=(l,u,h,S,R)=>{var N={string:Ae=>{var Lt=0;return Ae!=null&&Ae!==0&&(Lt=GV(Ae)),Lt},array:Ae=>{var Lt=B2(Ae.length);return H2(Ae,Lt),Lt}};function q(Ae){return u==="string"?Xl(Ae):u==="boolean"?!!Ae:Ae}var j=U2(l),ne=[],me=0;if(S)for(var Ge=0;Ge<S.length;Ge++){var Xe=N[h[Ge]];Xe?(me===0&&(me=rB()),ne[Ge]=Xe(S[Ge])):ne[Ge]=S[Ge]}var _t=j(...ne);function Ie(Ae){return me!==0&&nB(me),q(Ae)}return _t=Ie(_t),_t},QV=(l,u,h,S)=>{var R=!h||h.every(q=>q==="number"||q==="boolean"),N=u!=="string";return N&&R&&!S?U2(l):(...q)=>Fa(l,u,h,q)},JV=l=>G2(),YV=(l,u,h)=>{if(h??(h=2147483647),h<2)return 0;h-=2;for(var S=u,R=h<l.length*2?h/2:l.length,N=0;N<R;++N){var q=l.charCodeAt(N);A[u>>1]=q,u+=2}return A[u>>1]=0,u-S},XV=(l,u,h)=>{if(h??(h=2147483647),h<4)return 0;for(var S=u,R=S+h-4,N=0;N<l.length;++N){var q=l.charCodeAt(N);if(q>=55296&&q<=57343){var j=l.charCodeAt(++N);q=65536+((q&1023)<<10)|j&1023}if(D[u>>2]=q,u+=4,u+4>R)break}return D[u>>2]=0,u-S},ZV=l=>{for(var u="";;){var h=O[l++];if(!h)return u;u+=String.fromCharCode(h)}},V2=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,eW=(l,u)=>{for(var h=l,S=h>>1,R=S+u/2;!(S>=R)&&z[S];)++S;if(h=S<<1,h-l>32&&V2)return V2.decode(O.subarray(l,h));for(var N="",q=0;!(q>=u/2);++q){var j=A[l+q*2>>1];if(j==0)break;N+=String.fromCharCode(j)}return N},tW=(l,u)=>{for(var h=0,S="";!(h>=u/4);){var R=D[l+h*4>>2];if(R==0)break;if(++h,R>=65536){var N=R-65536;S+=String.fromCharCode(55296|N>>10,56320|N&1023)}else S+=String.fromCharCode(R)}return S};function nW(l){for(var u=[],h=0;h<l.length;h++){var S=l[h];S>255&&(S&=255),u.push(String.fromCharCode(S))}return u.join("")}C.createPreloadedFile=dB,C.staticInit(),Be.doesNotExistError=new C.ErrnoError(44),Be.doesNotExistError.stack="<generic error, no stack>",yt();var rW={a:sB,Y:pB,$:gB,Z:mB,X:yB,b:SB,W:vB,y:wB,Q:bB,U:EB,N:kB,S:CB,L:xB,J:RB,I:$B,V:IB,G:TB,F:PB,w:DB,u:qB,v:MB,M:LB,n:zB,m:jB,D:BB,O:KB,P:GB,o:QB,E:JB,K:XB,x:ZB,R:eV,H:nV,s:rV,t:sV,ga:iV,ka:oV,i:aV,j:lV,c:cV,d:uV,ca:fV,da:dV,ea:hV,fa:pV,g:gV,h:mV,z:yV,A:_V,e:SV,f:vV,aa:wV,ba:bV,B:EV,C:kV,p:CV,q:xV,ha:RV,ia:$V,ja:IV,r:TV,k:PV,l:OV,T:AV,_:FV},F=Ke();r._sqlite3_status64=(l,u,h,S)=>(r._sqlite3_status64=F.na)(l,u,h,S),r._sqlite3_status=(l,u,h,S)=>(r._sqlite3_status=F.oa)(l,u,h,S),r._sqlite3_db_status=(l,u,h,S,R)=>(r._sqlite3_db_status=F.pa)(l,u,h,S,R),r._sqlite3_msize=l=>(r._sqlite3_msize=F.qa)(l),r._sqlite3_vfs_find=l=>(r._sqlite3_vfs_find=F.ra)(l),r._sqlite3_vfs_register=(l,u)=>(r._sqlite3_vfs_register=F.sa)(l,u),r._sqlite3_vfs_unregister=l=>(r._sqlite3_vfs_unregister=F.ta)(l),r._sqlite3_release_memory=l=>(r._sqlite3_release_memory=F.ua)(l),r._sqlite3_soft_heap_limit64=(l,u)=>(r._sqlite3_soft_heap_limit64=F.va)(l,u),r._sqlite3_memory_used=()=>(r._sqlite3_memory_used=F.wa)(),r._sqlite3_hard_heap_limit64=(l,u)=>(r._sqlite3_hard_heap_limit64=F.xa)(l,u),r._sqlite3_memory_highwater=l=>(r._sqlite3_memory_highwater=F.ya)(l),r._sqlite3_malloc=l=>(r._sqlite3_malloc=F.za)(l),r._sqlite3_malloc64=(l,u)=>(r._sqlite3_malloc64=F.Aa)(l,u),r._sqlite3_free=l=>(r._sqlite3_free=F.Ba)(l),r._sqlite3_realloc=(l,u)=>(r._sqlite3_realloc=F.Ca)(l,u),r._sqlite3_realloc64=(l,u,h)=>(r._sqlite3_realloc64=F.Da)(l,u,h),r._sqlite3_str_vappendf=(l,u,h)=>(r._sqlite3_str_vappendf=F.Ea)(l,u,h),r._sqlite3_str_append=(l,u,h)=>(r._sqlite3_str_append=F.Fa)(l,u,h),r._sqlite3_str_appendchar=(l,u,h)=>(r._sqlite3_str_appendchar=F.Ga)(l,u,h),r._sqlite3_str_appendall=(l,u)=>(r._sqlite3_str_appendall=F.Ha)(l,u),r._sqlite3_str_appendf=(l,u,h)=>(r._sqlite3_str_appendf=F.Ia)(l,u,h),r._sqlite3_str_finish=l=>(r._sqlite3_str_finish=F.Ja)(l),r._sqlite3_str_errcode=l=>(r._sqlite3_str_errcode=F.Ka)(l),r._sqlite3_str_length=l=>(r._sqlite3_str_length=F.La)(l),r._sqlite3_str_value=l=>(r._sqlite3_str_value=F.Ma)(l),r._sqlite3_str_reset=l=>(r._sqlite3_str_reset=F.Na)(l),r._sqlite3_str_new=l=>(r._sqlite3_str_new=F.Oa)(l),r._sqlite3_vmprintf=(l,u)=>(r._sqlite3_vmprintf=F.Pa)(l,u),r._sqlite3_mprintf=(l,u)=>(r._sqlite3_mprintf=F.Qa)(l,u),r._sqlite3_vsnprintf=(l,u,h,S)=>(r._sqlite3_vsnprintf=F.Ra)(l,u,h,S),r._sqlite3_snprintf=(l,u,h,S)=>(r._sqlite3_snprintf=F.Sa)(l,u,h,S),r._sqlite3_log=(l,u,h)=>(r._sqlite3_log=F.Ta)(l,u,h),r._sqlite3_randomness=(l,u)=>(r._sqlite3_randomness=F.Ua)(l,u),r._sqlite3_stricmp=(l,u)=>(r._sqlite3_stricmp=F.Va)(l,u),r._sqlite3_strnicmp=(l,u,h)=>(r._sqlite3_strnicmp=F.Wa)(l,u,h),r._sqlite3_os_init=()=>(r._sqlite3_os_init=F.Xa)(),r._sqlite3_os_end=()=>(r._sqlite3_os_end=F.Ya)(),r._sqlite3_serialize=(l,u,h,S)=>(r._sqlite3_serialize=F.Za)(l,u,h,S),r._sqlite3_prepare_v2=(l,u,h,S,R)=>(r._sqlite3_prepare_v2=F._a)(l,u,h,S,R),r._sqlite3_step=l=>(r._sqlite3_step=F.$a)(l),r._sqlite3_column_int64=(l,u)=>(r._sqlite3_column_int64=F.ab)(l,u),r._sqlite3_reset=l=>(r._sqlite3_reset=F.bb)(l),r._sqlite3_exec=(l,u,h,S,R)=>(r._sqlite3_exec=F.cb)(l,u,h,S,R),r._sqlite3_column_int=(l,u)=>(r._sqlite3_column_int=F.db)(l,u),r._sqlite3_finalize=l=>(r._sqlite3_finalize=F.eb)(l),r._sqlite3_deserialize=(l,u,h,S,R,N,q,j)=>(r._sqlite3_deserialize=F.fb)(l,u,h,S,R,N,q,j),r._sqlite3_database_file_object=l=>(r._sqlite3_database_file_object=F.gb)(l),r._sqlite3_backup_init=(l,u,h,S)=>(r._sqlite3_backup_init=F.hb)(l,u,h,S),r._sqlite3_backup_step=(l,u)=>(r._sqlite3_backup_step=F.ib)(l,u),r._sqlite3_backup_finish=l=>(r._sqlite3_backup_finish=F.jb)(l),r._sqlite3_backup_remaining=l=>(r._sqlite3_backup_remaining=F.kb)(l),r._sqlite3_backup_pagecount=l=>(r._sqlite3_backup_pagecount=F.lb)(l),r._sqlite3_clear_bindings=l=>(r._sqlite3_clear_bindings=F.mb)(l),r._sqlite3_value_blob=l=>(r._sqlite3_value_blob=F.nb)(l),r._sqlite3_value_text=l=>(r._sqlite3_value_text=F.ob)(l),r._sqlite3_value_bytes=l=>(r._sqlite3_value_bytes=F.pb)(l),r._sqlite3_value_bytes16=l=>(r._sqlite3_value_bytes16=F.qb)(l),r._sqlite3_value_double=l=>(r._sqlite3_value_double=F.rb)(l),r._sqlite3_value_int=l=>(r._sqlite3_value_int=F.sb)(l),r._sqlite3_value_int64=l=>(r._sqlite3_value_int64=F.tb)(l),r._sqlite3_value_subtype=l=>(r._sqlite3_value_subtype=F.ub)(l),r._sqlite3_value_pointer=(l,u)=>(r._sqlite3_value_pointer=F.vb)(l,u),r._sqlite3_value_text16=l=>(r._sqlite3_value_text16=F.wb)(l),r._sqlite3_value_text16be=l=>(r._sqlite3_value_text16be=F.xb)(l),r._sqlite3_value_text16le=l=>(r._sqlite3_value_text16le=F.yb)(l),r._sqlite3_value_type=l=>(r._sqlite3_value_type=F.zb)(l),r._sqlite3_value_encoding=l=>(r._sqlite3_value_encoding=F.Ab)(l),r._sqlite3_value_nochange=l=>(r._sqlite3_value_nochange=F.Bb)(l),r._sqlite3_value_frombind=l=>(r._sqlite3_value_frombind=F.Cb)(l),r._sqlite3_value_dup=l=>(r._sqlite3_value_dup=F.Db)(l),r._sqlite3_value_free=l=>(r._sqlite3_value_free=F.Eb)(l),r._sqlite3_result_blob=(l,u,h,S)=>(r._sqlite3_result_blob=F.Fb)(l,u,h,S),r._sqlite3_result_blob64=(l,u,h,S,R)=>(r._sqlite3_result_blob64=F.Gb)(l,u,h,S,R),r._sqlite3_result_double=(l,u)=>(r._sqlite3_result_double=F.Hb)(l,u),r._sqlite3_result_error=(l,u,h)=>(r._sqlite3_result_error=F.Ib)(l,u,h),r._sqlite3_result_error16=(l,u,h)=>(r._sqlite3_result_error16=F.Jb)(l,u,h),r._sqlite3_result_int=(l,u)=>(r._sqlite3_result_int=F.Kb)(l,u),r._sqlite3_result_int64=(l,u,h)=>(r._sqlite3_result_int64=F.Lb)(l,u,h),r._sqlite3_result_null=l=>(r._sqlite3_result_null=F.Mb)(l),r._sqlite3_result_pointer=(l,u,h,S)=>(r._sqlite3_result_pointer=F.Nb)(l,u,h,S),r._sqlite3_result_subtype=(l,u)=>(r._sqlite3_result_subtype=F.Ob)(l,u),r._sqlite3_result_text=(l,u,h,S)=>(r._sqlite3_result_text=F.Pb)(l,u,h,S),r._sqlite3_result_text64=(l,u,h,S,R,N)=>(r._sqlite3_result_text64=F.Qb)(l,u,h,S,R,N),r._sqlite3_result_text16=(l,u,h,S)=>(r._sqlite3_result_text16=F.Rb)(l,u,h,S),r._sqlite3_result_text16be=(l,u,h,S)=>(r._sqlite3_result_text16be=F.Sb)(l,u,h,S),r._sqlite3_result_text16le=(l,u,h,S)=>(r._sqlite3_result_text16le=F.Tb)(l,u,h,S),r._sqlite3_result_value=(l,u)=>(r._sqlite3_result_value=F.Ub)(l,u),r._sqlite3_result_error_toobig=l=>(r._sqlite3_result_error_toobig=F.Vb)(l),r._sqlite3_result_zeroblob=(l,u)=>(r._sqlite3_result_zeroblob=F.Wb)(l,u),r._sqlite3_result_zeroblob64=(l,u,h)=>(r._sqlite3_result_zeroblob64=F.Xb)(l,u,h),r._sqlite3_result_error_code=(l,u)=>(r._sqlite3_result_error_code=F.Yb)(l,u),r._sqlite3_result_error_nomem=l=>(r._sqlite3_result_error_nomem=F.Zb)(l),r._sqlite3_user_data=l=>(r._sqlite3_user_data=F._b)(l),r._sqlite3_context_db_handle=l=>(r._sqlite3_context_db_handle=F.$b)(l),r._sqlite3_vtab_nochange=l=>(r._sqlite3_vtab_nochange=F.ac)(l),r._sqlite3_vtab_in_first=(l,u)=>(r._sqlite3_vtab_in_first=F.bc)(l,u),r._sqlite3_vtab_in_next=(l,u)=>(r._sqlite3_vtab_in_next=F.cc)(l,u),r._sqlite3_aggregate_context=(l,u)=>(r._sqlite3_aggregate_context=F.dc)(l,u),r._sqlite3_get_auxdata=(l,u)=>(r._sqlite3_get_auxdata=F.ec)(l,u),r._sqlite3_set_auxdata=(l,u,h,S)=>(r._sqlite3_set_auxdata=F.fc)(l,u,h,S),r._sqlite3_column_count=l=>(r._sqlite3_column_count=F.gc)(l),r._sqlite3_data_count=l=>(r._sqlite3_data_count=F.hc)(l),r._sqlite3_column_blob=(l,u)=>(r._sqlite3_column_blob=F.ic)(l,u),r._sqlite3_column_bytes=(l,u)=>(r._sqlite3_column_bytes=F.jc)(l,u),r._sqlite3_column_bytes16=(l,u)=>(r._sqlite3_column_bytes16=F.kc)(l,u),r._sqlite3_column_double=(l,u)=>(r._sqlite3_column_double=F.lc)(l,u),r._sqlite3_column_text=(l,u)=>(r._sqlite3_column_text=F.mc)(l,u),r._sqlite3_column_value=(l,u)=>(r._sqlite3_column_value=F.nc)(l,u),r._sqlite3_column_text16=(l,u)=>(r._sqlite3_column_text16=F.oc)(l,u),r._sqlite3_column_type=(l,u)=>(r._sqlite3_column_type=F.pc)(l,u),r._sqlite3_column_name=(l,u)=>(r._sqlite3_column_name=F.qc)(l,u),r._sqlite3_column_name16=(l,u)=>(r._sqlite3_column_name16=F.rc)(l,u),r._sqlite3_bind_blob=(l,u,h,S,R)=>(r._sqlite3_bind_blob=F.sc)(l,u,h,S,R),r._sqlite3_bind_blob64=(l,u,h,S,R,N)=>(r._sqlite3_bind_blob64=F.tc)(l,u,h,S,R,N),r._sqlite3_bind_double=(l,u,h)=>(r._sqlite3_bind_double=F.uc)(l,u,h),r._sqlite3_bind_int=(l,u,h)=>(r._sqlite3_bind_int=F.vc)(l,u,h),r._sqlite3_bind_int64=(l,u,h,S)=>(r._sqlite3_bind_int64=F.wc)(l,u,h,S),r._sqlite3_bind_null=(l,u)=>(r._sqlite3_bind_null=F.xc)(l,u),r._sqlite3_bind_pointer=(l,u,h,S,R)=>(r._sqlite3_bind_pointer=F.yc)(l,u,h,S,R),r._sqlite3_bind_text=(l,u,h,S,R)=>(r._sqlite3_bind_text=F.zc)(l,u,h,S,R),r._sqlite3_bind_text64=(l,u,h,S,R,N,q)=>(r._sqlite3_bind_text64=F.Ac)(l,u,h,S,R,N,q),r._sqlite3_bind_text16=(l,u,h,S,R)=>(r._sqlite3_bind_text16=F.Bc)(l,u,h,S,R),r._sqlite3_bind_value=(l,u,h)=>(r._sqlite3_bind_value=F.Cc)(l,u,h),r._sqlite3_bind_zeroblob=(l,u,h)=>(r._sqlite3_bind_zeroblob=F.Dc)(l,u,h),r._sqlite3_bind_zeroblob64=(l,u,h,S)=>(r._sqlite3_bind_zeroblob64=F.Ec)(l,u,h,S),r._sqlite3_bind_parameter_count=l=>(r._sqlite3_bind_parameter_count=F.Fc)(l),r._sqlite3_bind_parameter_name=(l,u)=>(r._sqlite3_bind_parameter_name=F.Gc)(l,u),r._sqlite3_bind_parameter_index=(l,u)=>(r._sqlite3_bind_parameter_index=F.Hc)(l,u),r._sqlite3_db_handle=l=>(r._sqlite3_db_handle=F.Ic)(l),r._sqlite3_stmt_readonly=l=>(r._sqlite3_stmt_readonly=F.Jc)(l),r._sqlite3_stmt_isexplain=l=>(r._sqlite3_stmt_isexplain=F.Kc)(l),r._sqlite3_stmt_explain=(l,u)=>(r._sqlite3_stmt_explain=F.Lc)(l,u),r._sqlite3_stmt_busy=l=>(r._sqlite3_stmt_busy=F.Mc)(l),r._sqlite3_next_stmt=(l,u)=>(r._sqlite3_next_stmt=F.Nc)(l,u),r._sqlite3_stmt_status=(l,u,h)=>(r._sqlite3_stmt_status=F.Oc)(l,u,h),r._sqlite3_sql=l=>(r._sqlite3_sql=F.Pc)(l),r._sqlite3_expanded_sql=l=>(r._sqlite3_expanded_sql=F.Qc)(l),r._sqlite3_value_numeric_type=l=>(r._sqlite3_value_numeric_type=F.Rc)(l),r._sqlite3_blob_open=(l,u,h,S,R,N,q,j)=>(r._sqlite3_blob_open=F.Sc)(l,u,h,S,R,N,q,j),r._sqlite3_blob_close=l=>(r._sqlite3_blob_close=F.Tc)(l),r._sqlite3_blob_read=(l,u,h,S)=>(r._sqlite3_blob_read=F.Uc)(l,u,h,S),r._sqlite3_blob_write=(l,u,h,S)=>(r._sqlite3_blob_write=F.Vc)(l,u,h,S),r._sqlite3_blob_bytes=l=>(r._sqlite3_blob_bytes=F.Wc)(l),r._sqlite3_blob_reopen=(l,u,h)=>(r._sqlite3_blob_reopen=F.Xc)(l,u,h),r._sqlite3_set_authorizer=(l,u,h)=>(r._sqlite3_set_authorizer=F.Yc)(l,u,h),r._sqlite3_strglob=(l,u)=>(r._sqlite3_strglob=F.Zc)(l,u),r._sqlite3_strlike=(l,u,h)=>(r._sqlite3_strlike=F._c)(l,u,h),r._sqlite3_errmsg=l=>(r._sqlite3_errmsg=F.$c)(l),r._sqlite3_auto_extension=l=>(r._sqlite3_auto_extension=F.ad)(l),r._sqlite3_cancel_auto_extension=l=>(r._sqlite3_cancel_auto_extension=F.bd)(l),r._sqlite3_reset_auto_extension=()=>(r._sqlite3_reset_auto_extension=F.cd)(),r._sqlite3_prepare=(l,u,h,S,R)=>(r._sqlite3_prepare=F.dd)(l,u,h,S,R),r._sqlite3_prepare_v3=(l,u,h,S,R,N)=>(r._sqlite3_prepare_v3=F.ed)(l,u,h,S,R,N),r._sqlite3_prepare16=(l,u,h,S,R)=>(r._sqlite3_prepare16=F.fd)(l,u,h,S,R),r._sqlite3_prepare16_v2=(l,u,h,S,R)=>(r._sqlite3_prepare16_v2=F.gd)(l,u,h,S,R),r._sqlite3_prepare16_v3=(l,u,h,S,R,N)=>(r._sqlite3_prepare16_v3=F.hd)(l,u,h,S,R,N),r._sqlite3_get_table=(l,u,h,S,R,N)=>(r._sqlite3_get_table=F.id)(l,u,h,S,R,N),r._sqlite3_free_table=l=>(r._sqlite3_free_table=F.jd)(l),r._sqlite3_create_module=(l,u,h,S)=>(r._sqlite3_create_module=F.kd)(l,u,h,S),r._sqlite3_create_module_v2=(l,u,h,S,R)=>(r._sqlite3_create_module_v2=F.ld)(l,u,h,S,R),r._sqlite3_drop_modules=(l,u)=>(r._sqlite3_drop_modules=F.md)(l,u),r._sqlite3_declare_vtab=(l,u)=>(r._sqlite3_declare_vtab=F.nd)(l,u),r._sqlite3_vtab_on_conflict=l=>(r._sqlite3_vtab_on_conflict=F.od)(l),r._sqlite3_vtab_config=(l,u,h)=>(r._sqlite3_vtab_config=F.pd)(l,u,h),r._sqlite3_vtab_collation=(l,u)=>(r._sqlite3_vtab_collation=F.qd)(l,u),r._sqlite3_vtab_in=(l,u,h)=>(r._sqlite3_vtab_in=F.rd)(l,u,h),r._sqlite3_vtab_rhs_value=(l,u,h)=>(r._sqlite3_vtab_rhs_value=F.sd)(l,u,h),r._sqlite3_vtab_distinct=l=>(r._sqlite3_vtab_distinct=F.td)(l),r._sqlite3_keyword_name=(l,u,h)=>(r._sqlite3_keyword_name=F.ud)(l,u,h),r._sqlite3_keyword_count=()=>(r._sqlite3_keyword_count=F.vd)(),r._sqlite3_keyword_check=(l,u)=>(r._sqlite3_keyword_check=F.wd)(l,u),r._sqlite3_complete=l=>(r._sqlite3_complete=F.xd)(l),r._sqlite3_complete16=l=>(r._sqlite3_complete16=F.yd)(l),r._sqlite3_libversion=()=>(r._sqlite3_libversion=F.zd)(),r._sqlite3_libversion_number=()=>(r._sqlite3_libversion_number=F.Ad)(),r._sqlite3_threadsafe=()=>(r._sqlite3_threadsafe=F.Bd)(),r._sqlite3_initialize=()=>(r._sqlite3_initialize=F.Cd)(),r._sqlite3_shutdown=()=>(r._sqlite3_shutdown=F.Dd)(),r._sqlite3_config=(l,u)=>(r._sqlite3_config=F.Ed)(l,u),r._sqlite3_db_mutex=l=>(r._sqlite3_db_mutex=F.Fd)(l),r._sqlite3_db_release_memory=l=>(r._sqlite3_db_release_memory=F.Gd)(l),r._sqlite3_db_cacheflush=l=>(r._sqlite3_db_cacheflush=F.Hd)(l),r._sqlite3_db_config=(l,u,h)=>(r._sqlite3_db_config=F.Id)(l,u,h),r._sqlite3_last_insert_rowid=l=>(r._sqlite3_last_insert_rowid=F.Jd)(l),r._sqlite3_set_last_insert_rowid=(l,u,h)=>(r._sqlite3_set_last_insert_rowid=F.Kd)(l,u,h),r._sqlite3_changes64=l=>(r._sqlite3_changes64=F.Ld)(l),r._sqlite3_changes=l=>(r._sqlite3_changes=F.Md)(l),r._sqlite3_total_changes64=l=>(r._sqlite3_total_changes64=F.Nd)(l),r._sqlite3_total_changes=l=>(r._sqlite3_total_changes=F.Od)(l),r._sqlite3_txn_state=(l,u)=>(r._sqlite3_txn_state=F.Pd)(l,u),r._sqlite3_close=l=>(r._sqlite3_close=F.Qd)(l),r._sqlite3_close_v2=l=>(r._sqlite3_close_v2=F.Rd)(l),r._sqlite3_busy_handler=(l,u,h)=>(r._sqlite3_busy_handler=F.Sd)(l,u,h),r._sqlite3_progress_handler=(l,u,h,S)=>(r._sqlite3_progress_handler=F.Td)(l,u,h,S),r._sqlite3_busy_timeout=(l,u)=>(r._sqlite3_busy_timeout=F.Ud)(l,u),r._sqlite3_interrupt=l=>(r._sqlite3_interrupt=F.Vd)(l),r._sqlite3_is_interrupted=l=>(r._sqlite3_is_interrupted=F.Wd)(l),r._sqlite3_create_function=(l,u,h,S,R,N,q,j)=>(r._sqlite3_create_function=F.Xd)(l,u,h,S,R,N,q,j),r._sqlite3_create_function_v2=(l,u,h,S,R,N,q,j,ne)=>(r._sqlite3_create_function_v2=F.Yd)(l,u,h,S,R,N,q,j,ne),r._sqlite3_create_window_function=(l,u,h,S,R,N,q,j,ne,me)=>(r._sqlite3_create_window_function=F.Zd)(l,u,h,S,R,N,q,j,ne,me),r._sqlite3_create_function16=(l,u,h,S,R,N,q,j)=>(r._sqlite3_create_function16=F._d)(l,u,h,S,R,N,q,j),r._sqlite3_overload_function=(l,u,h)=>(r._sqlite3_overload_function=F.$d)(l,u,h),r._sqlite3_trace_v2=(l,u,h,S)=>(r._sqlite3_trace_v2=F.ae)(l,u,h,S),r._sqlite3_commit_hook=(l,u,h)=>(r._sqlite3_commit_hook=F.be)(l,u,h),r._sqlite3_update_hook=(l,u,h)=>(r._sqlite3_update_hook=F.ce)(l,u,h),r._sqlite3_rollback_hook=(l,u,h)=>(r._sqlite3_rollback_hook=F.de)(l,u,h),r._sqlite3_autovacuum_pages=(l,u,h,S)=>(r._sqlite3_autovacuum_pages=F.ee)(l,u,h,S),r._sqlite3_wal_autocheckpoint=(l,u)=>(r._sqlite3_wal_autocheckpoint=F.fe)(l,u),r._sqlite3_wal_hook=(l,u,h)=>(r._sqlite3_wal_hook=F.ge)(l,u,h),r._sqlite3_wal_checkpoint_v2=(l,u,h,S,R)=>(r._sqlite3_wal_checkpoint_v2=F.he)(l,u,h,S,R),r._sqlite3_wal_checkpoint=(l,u)=>(r._sqlite3_wal_checkpoint=F.ie)(l,u),r._sqlite3_error_offset=l=>(r._sqlite3_error_offset=F.je)(l),r._sqlite3_errmsg16=l=>(r._sqlite3_errmsg16=F.ke)(l),r._sqlite3_errcode=l=>(r._sqlite3_errcode=F.le)(l),r._sqlite3_extended_errcode=l=>(r._sqlite3_extended_errcode=F.me)(l),r._sqlite3_system_errno=l=>(r._sqlite3_system_errno=F.ne)(l),r._sqlite3_errstr=l=>(r._sqlite3_errstr=F.oe)(l),r._sqlite3_limit=(l,u,h)=>(r._sqlite3_limit=F.pe)(l,u,h),r._sqlite3_open=(l,u)=>(r._sqlite3_open=F.qe)(l,u),r._sqlite3_open_v2=(l,u,h,S)=>(r._sqlite3_open_v2=F.re)(l,u,h,S),r._sqlite3_open16=(l,u)=>(r._sqlite3_open16=F.se)(l,u),r._sqlite3_create_collation=(l,u,h,S,R)=>(r._sqlite3_create_collation=F.te)(l,u,h,S,R),r._sqlite3_create_collation_v2=(l,u,h,S,R,N)=>(r._sqlite3_create_collation_v2=F.ue)(l,u,h,S,R,N),r._sqlite3_create_collation16=(l,u,h,S,R)=>(r._sqlite3_create_collation16=F.ve)(l,u,h,S,R),r._sqlite3_collation_needed=(l,u,h)=>(r._sqlite3_collation_needed=F.we)(l,u,h),r._sqlite3_collation_needed16=(l,u,h)=>(r._sqlite3_collation_needed16=F.xe)(l,u,h),r._sqlite3_get_clientdata=(l,u)=>(r._sqlite3_get_clientdata=F.ye)(l,u),r._sqlite3_set_clientdata=(l,u,h,S)=>(r._sqlite3_set_clientdata=F.ze)(l,u,h,S),r._sqlite3_get_autocommit=l=>(r._sqlite3_get_autocommit=F.Ae)(l),r._sqlite3_table_column_metadata=(l,u,h,S,R,N,q,j,ne)=>(r._sqlite3_table_column_metadata=F.Be)(l,u,h,S,R,N,q,j,ne),r._sqlite3_sleep=l=>(r._sqlite3_sleep=F.Ce)(l),r._sqlite3_extended_result_codes=(l,u)=>(r._sqlite3_extended_result_codes=F.De)(l,u),r._sqlite3_file_control=(l,u,h,S)=>(r._sqlite3_file_control=F.Ee)(l,u,h,S),r._sqlite3_test_control=(l,u)=>(r._sqlite3_test_control=F.Fe)(l,u),r._sqlite3_create_filename=(l,u,h,S,R)=>(r._sqlite3_create_filename=F.Ge)(l,u,h,S,R),r._sqlite3_free_filename=l=>(r._sqlite3_free_filename=F.He)(l),r._sqlite3_uri_parameter=(l,u)=>(r._sqlite3_uri_parameter=F.Ie)(l,u),r._sqlite3_uri_key=(l,u)=>(r._sqlite3_uri_key=F.Je)(l,u),r._sqlite3_uri_boolean=(l,u,h)=>(r._sqlite3_uri_boolean=F.Ke)(l,u,h),r._sqlite3_uri_int64=(l,u,h,S)=>(r._sqlite3_uri_int64=F.Le)(l,u,h,S),r._sqlite3_filename_database=l=>(r._sqlite3_filename_database=F.Me)(l),r._sqlite3_filename_journal=l=>(r._sqlite3_filename_journal=F.Ne)(l),r._sqlite3_filename_wal=l=>(r._sqlite3_filename_wal=F.Oe)(l),r._sqlite3_db_name=(l,u)=>(r._sqlite3_db_name=F.Pe)(l,u),r._sqlite3_db_filename=(l,u)=>(r._sqlite3_db_filename=F.Qe)(l,u),r._sqlite3_db_readonly=(l,u)=>(r._sqlite3_db_readonly=F.Re)(l,u),r._sqlite3_compileoption_used=l=>(r._sqlite3_compileoption_used=F.Se)(l),r._sqlite3_compileoption_get=l=>(r._sqlite3_compileoption_get=F.Te)(l),r._sqlite3session_create=(l,u,h)=>(r._sqlite3session_create=F.Ue)(l,u,h),r._sqlite3session_delete=l=>(r._sqlite3session_delete=F.Ve)(l),r._sqlite3session_attach=(l,u)=>(r._sqlite3session_attach=F.We)(l,u),r._sqlite3session_changeset=(l,u,h)=>(r._sqlite3session_changeset=F.Xe)(l,u,h),r._sqlite3session_enable=(l,u)=>(r._sqlite3session_enable=F.Ye)(l,u),r._sqlite3changeset_start=(l,u,h)=>(r._sqlite3changeset_start=F.Ze)(l,u,h),r._sqlite3changeset_finalize=l=>(r._sqlite3changeset_finalize=F._e)(l),r._sqlite3changeset_invert=(l,u,h,S)=>(r._sqlite3changeset_invert=F.$e)(l,u,h,S),r._sqlite3changeset_apply=(l,u,h,S,R,N)=>(r._sqlite3changeset_apply=F.af)(l,u,h,S,R,N),r._sqlite3_sourceid=()=>(r._sqlite3_sourceid=F.bf)(),r._malloc=l=>(r._malloc=F.cf)(l),r._free=l=>(r._free=F.df)(l),r._RegisterExtensionFunctions=l=>(r._RegisterExtensionFunctions=F.ef)(l),r._getSqliteFree=()=>(r._getSqliteFree=F.ff)();var W2=r._main=(l,u)=>(W2=r._main=F.gf)(l,u);r._libauthorizer_set_authorizer=(l,u,h)=>(r._libauthorizer_set_authorizer=F.hf)(l,u,h),r._libfunction_create_function=(l,u,h,S,R,N,q,j)=>(r._libfunction_create_function=F.jf)(l,u,h,S,R,N,q,j),r._libhook_commit_hook=(l,u,h)=>(r._libhook_commit_hook=F.kf)(l,u,h),r._libhook_update_hook=(l,u,h)=>(r._libhook_update_hook=F.lf)(l,u,h),r._libprogress_progress_handler=(l,u,h,S)=>(r._libprogress_progress_handler=F.mf)(l,u,h,S),r._libvfs_vfs_register=(l,u,h,S,R,N)=>(r._libvfs_vfs_register=F.nf)(l,u,h,S,R,N);var K2=(l,u)=>(K2=F.pf)(l,u),G2=()=>(G2=F.qf)(),Q2=l=>(Q2=F.rf)(l),J2=l=>(J2=F.sf)(l),Y2=()=>(Y2=F.tf)();r._sqlite3_version=5472,r.getTempRet0=JV,r.ccall=Fa,r.cwrap=QV,r.addFunction=KV,r.setValue=Uu,r.getValue=A2,r.UTF8ToString=Xl,r.stringToUTF8=Aa,r.lengthBytesUTF8=Bu,r.intArrayFromString=zb,r.intArrayToString=nW,r.AsciiToString=ZV,r.UTF16ToString=eW,r.stringToUTF16=YV,r.UTF32ToString=tW,r.stringToUTF32=XV,r.writeArrayToMemory=H2;var $y;ns=function l(){$y||X2(),$y||(ns=l)};function sW(){var l=W2,u=0,h=0;try{var S=l(u,h);return MV(S,!0),S}catch(R){return LV(R)}}function X2(){if(Dn>0||(J(),Dn>0))return;function l(){var u;$y||($y=!0,r.calledRun=!0,!w&&(ee(),de(),s(r),(u=r.onRuntimeInitialized)==null||u.call(r),Z2&&sW(),Te()))}r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),l()},1)):l()}if(r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();var Z2=!0;return r.noInitialRun&&(Z2=!1),X2(),function(){const l=Object.getPrototypeOf(async function(){}).constructor;let u=0;r.set_authorizer=function(h,S,R){u&&(r.deleteCallback(u),r._sqlite3_free(u),u=0),u=r._sqlite3_malloc(4),Uu(u,S instanceof l?1:0,"i32");const N=Fa("libauthorizer_set_authorizer","number",["number","number","number"],[h,S?1:0,u]);return!N&&S&&r.setCallback(u,(q,j,ne,me,Ge,Xe)=>S(R,j,ne,me,Ge,Xe)),N}}(),function(){const l=Object.getPrototypeOf(async function(){}).constructor,u=["xFunc","xStep","xFinal"],h=new Map;r.create_function=function(S,R,N,q,j,ne,me,Ge){const Xe=r._sqlite3_malloc(4),_t={xFunc:ne,xStep:me,xFinal:Ge};Uu(Xe,u.reduce((Ae,Lt,rs)=>_t[Lt]instanceof l?Ae|1<<rs:Ae,0),"i32");const Ie=Fa("libfunction_create_function","number",["number","string","number","number","number","number","number","number"],[S,R,N,q,Xe,ne?1:0,me?1:0,Ge?1:0]);if(!Ie){if(h.has(R)){const Ae=h.get(R);r.deleteCallback(Ae)}h.set(R,Xe),r.setCallback(Xe,{xFunc:ne,xStep:me,xFinal:Ge})}return Ie}}(),function(){const l=Object.getPrototypeOf(async function(){}).constructor;let u=0;r.update_hook=function(h,S){u&&(r.deleteCallback(u),r._sqlite3_free(u),u=0),u=r._sqlite3_malloc(4),Uu(u,S instanceof l?1:0,"i32"),Fa("libhook_update_hook","void",["number","number","number"],[h,S?1:0,u]),S&&r.setCallback(u,(R,N,q,j,ne,me)=>S(N,q,j,ne,me))}}(),function(){const l=Object.getPrototypeOf(async function(){}).constructor;let u=0;r.commit_hook=function(h,S){u&&(r.deleteCallback(u),r._sqlite3_free(u),u=0),u=r._sqlite3_malloc(4),Uu(u,S instanceof l?1:0,"i32"),Fa("libhook_commit_hook","void",["number","number","number"],[h,S?1:0,u]),S&&r.setCallback(u,R=>S())}}(),function(){const l=Object.getPrototypeOf(async function(){}).constructor;let u=0;r.progress_handler=function(h,S,R,N){u&&(r.deleteCallback(u),r._sqlite3_free(u),u=0),u=r._sqlite3_malloc(4),Uu(u,R instanceof l?1:0,"i32"),Fa("libprogress_progress_handler","number",["number","number","number","number"],[h,S,R?1:0,u]),R&&r.setCallback(u,q=>R(N))}}(),function(){const l=["xOpen","xDelete","xAccess","xFullPathname","xRandomness","xSleep","xCurrentTime","xGetLastError","xCurrentTimeInt64","xClose","xRead","xWrite","xTruncate","xSync","xFileSize","xLock","xUnlock","xCheckReservedLock","xFileControl","xSectorSize","xDeviceCharacteristics","xShmMap","xShmLock","xShmBarrier","xShmUnmap"],u=new Map;r.vfs_register=function(h,S){let R=0,N=0;l.forEach((j,ne)=>{h[j]&&(R|=1<<ne,h.hasAsyncMethod(j)&&(N|=1<<ne))});const q=r._sqlite3_malloc(4);try{const j=Fa("libvfs_vfs_register","number",["string","number","number","number","number","number"],[h.name,h.mxPathname,R,N,S?1:0,q]);if(!j){if(u.has(h.name)){const me=u.get(h.name);r.deleteCallback(me)}const ne=A2(q,"*");u.set(h.name,ne),r.setCallback(ne,h)}return j}finally{r._sqlite3_free(q)}}}(),n=o,n}})();const Zbe=async()=>{const e=await Xbe(),t=Ybe(e);return t.module=e,t},H5=(e,{foreignKeys:t,lockingMode:n})=>Cy(e,Ct`
228
+ -- disable WAL until we have it working properly
229
+ -- PRAGMA journal_mode=WAL;
230
+ PRAGMA page_size=8192;
231
+ PRAGMA foreign_keys=${t?"ON":"OFF"};
232
+ ${n===void 0?"":Ct`PRAGMA locking_mode=${n};`}
233
+ `,{}),Cy=(e,t,n)=>{const r=oa(n,t);return Kl({try:()=>e.execute(t,r),catch:s=>new xc({cause:s,query:{bindValues:r,sql:t},code:s.code})}).pipe(Sa,Qe("@livestore/common:execSql",{attributes:{"span.label":t,sql:t,bindValueKeys:Object.keys(r)}}))},e1e=(e,t,n)=>Kl({try:()=>e.execute(t,n),catch:r=>new xc({cause:r,query:{bindValues:n,sql:t},code:r.code})}).pipe(Sa,Qe("@livestore/common:execSqlPrepared",{attributes:{"span.label":t,sql:t,bindValueKeys:Object.keys(n)}})),t1e=Ye("Skip",{}),n1e=Ye("Blocking",{timeout:tt(zye,it)});tt(t1e,n1e);class ws extends Vv("LeaderThreadCtx")(){}class r1e extends tt(U0,un){}const s1e=e=>X(function*(){if(e.enabled===!1)return;const{syncProcessor:t,extraIncomingMessagesQueue:n,clientId:r,storeId:s}=yield*ws;yield*e3({incomingMessages:va(n),sendMessage:()=>Le}).pipe(st,Dt);const{node:i,persistenceInfo:o,mode:a}=yield*e.boot;yield*i.listenForChannel.pipe(Ui(c=>b5.devtoolsClientLeader(c.channelName,{storeId:s,clientId:r})&&c.mode===a),Un(({channelName:c,source:f})=>X(function*(){const d=yield*i.makeChannel({target:f,channelName:c,schema:{listen:wbe,send:bbe},mode:a}),g=k=>d.send(k).pipe(Qe("@livestore/common:leader-thread:devtools:sendToDevtools"),Jt,Hw),_=yield*t.syncState,b=t.getMergeCounter();yield*t.pull({cursor:{mergeCounter:b,eventNum:_.localHead}}).pipe(Un(({payload:k})=>g(g5.make({payload:k,liveStoreVersion:Hr}))),Sn,Dt),yield*e3({incomingMessages:d.listen.pipe(Dl(),D_e),sendMessage:g,persistenceInfo:o})}).pipe(st,Dt)),Sn)}).pipe(Qe("@livestore/common:leader-thread:devtools:boot")),e3=({incomingMessages:e,sendMessage:t,persistenceInfo:n})=>X(function*(){const{syncBackend:r,makeSqliteDb:s,dbState:i,dbEventlog:o,shutdownStateSubRef:a,shutdownChannel:c,syncProcessor:f,clientId:d,devtools:g}=yield*ws,_=yield*Fge(),b=new Set;yield*e.pipe(Un(k=>X(function*(){const{requestId:I}=k,E={requestId:I,liveStoreVersion:Hr,clientId:d};if(k._tag!=="LSD.Leader.Disconnect"&&!b.has(I))switch(b.add(I),k._tag){case"LSD.Leader.Ping":{yield*t(_5.make({...E}));return}case"LSD.Leader.SnapshotReq":{const y=i.export();yield*t(p5.make({snapshot:y,...E}));return}case"LSD.Leader.LoadDatabaseFile.Request":{const{data:y}=k;let m;try{const v=yield*s({_tag:"in-memory"});v.import(y);const w=v.select("select name from sqlite_master where type = 'table'");m=new Set(w.map($=>$.name)),v.close()}catch(v){yield*Dd("Error importing database file",v),yield*t(Af.Error.make({...E,cause:{_tag:"unexpected-error",cause:v}}));return}try{if(m.has(Co))yield*uo(a,"shutting-down"),o.import(y),i.destroy();else if(m.has(Tb)&&m.has(H0))yield*uo(a,"shutting-down"),i.import(y),o.destroy();else{yield*t(Af.Error.make({...E,cause:{_tag:"unsupported-database"}}));return}yield*t(Af.Success.make({...E})),yield*c.send(U0.make({reason:"devtools-import"}))??Le;return}catch(v){yield*Dd("Error importing database file",v),yield*t(Af.Error.make({...E,cause:{_tag:"unexpected-error",cause:v}}));return}}case"LSD.Leader.ResetAllData.Request":{const{mode:y}=k;yield*uo(a,"shutting-down"),i.destroy(),y==="all-data"&&o.destroy(),yield*t(Nb.Success.make({...E})),yield*c.send(U0.make({reason:"devtools-reset"}))??Le;return}case"LSD.Leader.DatabaseFileInfoReq":{if(n===void 0){console.log("[@livestore/common:leader-thread:devtools] persistenceInfo is required for this request");return}const y="SELECT page_count * page_size as size FROM pragma_page_count(), pragma_page_size();",m=i.select(y,void 0)[0].size,v=o.select(y,void 0)[0].size;yield*t(l5.make({state:{fileSize:m,persistenceInfo:n.state},eventlog:{fileSize:v,persistenceInfo:n.eventlog},...E}));return}case"LSD.Leader.EventlogReq":{const y=o.export();yield*t(y5.make({eventlog:y,...E}));return}case"LSD.Leader.CommitEventReq":{yield*f.pushPartial({event:k.eventEncoded,clientId:`devtools-${d}`,sessionId:`devtools-${d}`}),yield*t(m5.make({...E}));return}case"LSD.Leader.SyncHistorySubscribe":{const{subscriptionId:y}=k;r!==void 0&&(yield*r.pull(re()).pipe(Ta(m=>m.batch),I_e,Un(({eventEncoded:m,metadata:v})=>t(d5.make({eventEncoded:m,metadata:v,subscriptionId:y,...E,requestId:br(10)}))),Sn,Jt,st,Y1(_,y)));return}case"LSD.Leader.SyncHistoryUnsubscribe":{const{requestId:y}=k;console.log("LSD.SyncHistoryUnsubscribe",y),yield*J1(_,y);return}case"LSD.Leader.SyncingInfoReq":{const y=u5.make({enabled:r!==void 0,metadata:(r==null?void 0:r.metadata)??{}});yield*t(f5.make({syncingInfo:y,...E}));return}case"LSD.Leader.NetworkStatusSubscribe":{if(r!==void 0){const{subscriptionId:y}=k;yield*Bw(1e3),yield*j_e(r.isConnected.changes,g.enabled?g.syncBackendLatchState.changes:O_e({latchClosed:!1})).pipe(Un(([m,{latchClosed:v}])=>t(c5.make({networkStatus:{isConnected:m,timestampMs:Date.now(),latchClosed:v},subscriptionId:y,...E,requestId:br(10)}))),Sn,Jt,st,Y1(_,y))}return}case"LSD.Leader.NetworkStatusUnsubscribe":{const{requestId:y}=k;yield*J1(_,y);return}case"LSD.Leader.SyncHeadSubscribe":{const{subscriptionId:y}=k;yield*f.syncState.changes.pipe(Un(m=>t(h5.make({local:m.localHead,upstream:m.upstreamHead,subscriptionId:y,...E,requestId:br(10)}))),Sn,Jt,st,Y1(_,y));return}case"LSD.Leader.SyncHeadUnsubscribe":{const{subscriptionId:y}=k;yield*J1(_,y);return}case"LSD.Leader.SetSyncLatch.Request":{const{closeLatch:y}=k;if(g.enabled===!1)return;y===!0?yield*g.syncBackendLatch.close:yield*g.syncBackendLatch.open,yield*uo(g.syncBackendLatchState,{latchClosed:y}),yield*t(Fb.Success.make({...E}));return}default:yield*Ps("TODO implement devtools message",k)}}).pipe(Qe(`@livestore/common:leader-thread:onDevtoolsMessage:${k._tag}`))),un.mapToUnexpectedErrorStream,Sn)}),B5=e=>Object.entries(e),i1e=e=>[">","<","="].includes(e),V5=({tableName:e,columns:t,values:n,options:r={orReplace:!1}})=>[o1e({tableName:e,columns:t,options:{orReplace:r==null?void 0:r.orReplace,keys:Object.keys(n)}}),Px({columns:t,values:n})],o1e=({tableName:e,columns:t,options:n={orReplace:!1}})=>{const r=(n==null?void 0:n.keys)??Object.keys(t),s=r.join(", "),i=r.map(o=>`$${o}`).join(", ");return Ct`INSERT ${n.orReplace?"OR REPLACE ":""}INTO ${e} (${s}) VALUES (${i})`},a1e=({columns:e,tableName:t,updateValues:n,where:r})=>{const s=c1e(n);if(Object.keys(s).length===0)return[Ct`select 1`,{}];const i=Object.keys(s).map(f=>`${f} = $update_${f}`).join(", "),o={...Px({columns:e,values:s,variablePrefix:"update_"}),...Px({columns:e,values:r,variablePrefix:"where_",skipNil:!0})},a=l1e({where:r}),c=a===""?"":`WHERE ${a}`;return[Ct`UPDATE ${t} SET ${i} ${c}`,o]},Px=({columns:e,values:t,variablePrefix:n="",skipNil:r})=>{const s=T(e,B5,Zo(([i,o])=>[i,a=>{if(o.nullable===!0&&a==null)return null;const c=uye(o.schema)(a);if(c._tag==="Left"){const f=Mp.formatErrorSync(c.left),d=String(o.schema.ast);console.error(`Error making bind values for SQL query for column "${i}".
234
+
235
+ Expected schema: ${d}
236
+
237
+ Error: ${f}
238
+
239
+ Value:`,a);debugger;throw c.left}else return c.right}]),Object.fromEntries);return T(Object.entries(t).filter(([,i])=>r!==!0||i!=null).flatMap(([i,o])=>{const a=s[i]??ze(`No codec found for column "${i}"`);if(typeof o=="object"&&o!==null&&"op"in o)switch(o.op){case"in":return o.val.map((c,f)=>[`${n}${i}_${f}`,a(c)]);case"=":case">":case"<":return[[`${n}${i}`,a(o.val)]];default:throw new Error(`Unknown op: ${o.op}`)}else return[[`${n}${i}`,a(o)]]}),Object.fromEntries)},l1e=({where:e})=>{const t=(n,r)=>r===null?"IS NULL":typeof r=="object"&&typeof r.op=="string"&&i1e(r.op)?`${r.op} $where_${n}`:typeof r=="object"&&typeof r.op=="string"&&r.op==="in"?`in (${r.val.map((s,i)=>`$where_${n}_${i}`).join(", ")})`:`= $where_${n}`;return T(e,B5,Zo(([n,r])=>`${n} ${t(n,r)}`),ku(" AND "))},c1e=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0)),u1e=e=>X(function*(){for(const t of _we)yield*V0({db:e,behaviour:"create-if-not-exists",tableAst:t.sqliteDef.ast,skipMetaTable:!0});yield*Cy(e,Ct`INSERT INTO ${om} (head)
240
+ SELECT ${_o.global}
241
+ WHERE NOT EXISTS (SELECT 1 FROM ${om})`,{})}),f1e=e=>X(function*(){const{dbEventlog:t,dbState:n}=yield*ws,r=im.where("seqNumGlobal",">=",e.global).asSql(),s=t.select(r.query,oa(r.bindValues,r.query)),i=k0(im.rowSchema.pipe(Je))(s),o=B0.where("seqNumGlobal",">=",e.global).asSql(),a=n.select(o.query,oa(o.bindValues,o.query)),c=k0(B0.rowSchema.pipe(Je))(a);return i.map(f=>{const d=c.find(g=>g.seqNumGlobal===f.seqNumGlobal&&g.seqNumClient===f.seqNumClient);return Rr.make({name:f.name,args:f.argsJson,seqNum:{global:f.seqNumGlobal,client:f.seqNumClient},parentSeqNum:{global:f.parentSeqNumGlobal,client:f.parentSeqNumClient},clientId:f.clientId,sessionId:f.sessionId,meta:{sessionChangeset:d&&d.changeset!==null?{_tag:"sessionChangeset",data:d.changeset,debug:d.debug}:{_tag:"unset"},syncMetadata:f.syncMetadataJson,materializerHashLeader:re(),materializerHashSession:re()}})}).filter(f=>fx(f.seqNum,e)>0).sort((f,d)=>fx(f.seqNum,d.seqNum))}),W5=e=>{const t=e.select(Ct`select seqNumGlobal, seqNumClient from ${Co} order by seqNumGlobal DESC, seqNumClient DESC limit 1`)[0];return t?{global:t.seqNumGlobal,client:t.seqNumClient}:_o},d1e=e=>{var t;return((t=e.select(Ct`select head from ${om}`)[0])==null?void 0:t.head)??_o.global},h1e=(e,t)=>e.execute(Ct`UPDATE ${om} SET head = ${t.global}`),p1e=(e,t,n,r,s)=>X(function*(){js&&e.parentSeqNum.global!==_o.global&&t.select(`SELECT COUNT(*) as count FROM ${Co} WHERE seqNumGlobal = ? AND seqNumClient = ?`,[e.parentSeqNum.global,e.parentSeqNum.client])[0].count===1===!1&&ze(`Parent mutation ${e.parentSeqNum.global},${e.parentSeqNum.client} does not exist`),yield*Cy(t,...V5({tableName:Co,columns:im.sqliteDef.columns,values:{seqNumGlobal:e.seqNum.global,seqNumClient:e.seqNum.client,parentSeqNumGlobal:e.parentSeqNum.global,parentSeqNumClient:e.parentSeqNum.client,name:e.name,argsJson:e.args??{},clientId:r,sessionId:s,schemaHash:n,syncMetadataJson:e.meta.syncMetadata}}))}),g1e=e=>X(function*(){const{dbEventlog:t}=yield*ws;for(let n=0;n<e.length;n++){const r=e[n];yield*Cy(t,...a1e({tableName:Co,columns:im.sqliteDef.columns,where:{seqNumGlobal:r.seqNum.global,seqNumClient:r.seqNum.client},updateValues:{syncMetadataJson:r.meta.syncMetadata}}))}}),m1e=e=>X(function*(){const{dbEventlog:t}=yield*ws;if(e===_o.global)return re();const n=ke({syncMetadataJson:Bg(td(Hd))}).pipe(jd("syncMetadataJson"),Je,Bye),r=yield*Re(()=>t.select(Ct`SELECT syncMetadataJson FROM ${Co} WHERE seqNumGlobal = ${e} ORDER BY seqNumClient ASC LIMIT 1`)).pipe(d0(hp(n)),je(IQ),os);return oe({cursor:{global:e,client:Ml},metadata:r})}).pipe(Qe("@livestore/common:eventlog:getSyncBackendCursorInfo",{attributes:{remoteHead:e}})),y1e=({schema:e,dbState:t,dbEventlog:n})=>X(function*(){const r=new Map([...e.eventsDefsMap.entries()].map(([s,i])=>[s,c2(i.schema)]));return(s,i)=>X(function*(){const o=(i==null?void 0:i.skipEventlog)??!1,a=s.name,{eventDef:c,materializer:f}=Di(e,a),d=y2({eventDef:c,materializer:f,dbState:t,event:{decoded:void 0,encoded:s}}),g=ko()?oe(jH(d)):re();g._tag==="Some"&&s.meta.materializerHashSession._tag==="Some"&&s.meta.materializerHashSession.value!==g.value&&(yield*un.make({cause:`Materializer hash mismatch detected for event "${s.name}".`,note:"Please make sure your event materializer is a pure function without side effects."}));const _=t.session();for(const{statementSql:k,bindValues:I}of d)yield*e1e(t,k,I);const b=_.changeset();if(_.finish(),yield*Cy(t,...V5({tableName:rm,columns:B0.sqliteDef.columns,values:{seqNumGlobal:s.seqNum.global,seqNumClient:s.seqNum.client,changeset:b??null,debug:js?d:null}})),o===!1){const k=s.name,I=r.get(k)??ze(`Unknown event definition: ${k}`);yield*p1e(s,n,I,s.clientId,s.sessionId)}return{sessionChangeset:b?{_tag:"sessionChangeset",data:b,debug:js?d:null}:{_tag:"no-op"},hash:g}}).pipe(Qe("@livestore/common:leader-thread:materializeEvent",{attributes:{eventName:s.name,eventNum:s.seqNum,"span.label":`${Ns(s.seqNum)} ${s.name}`}}))}),_1e=({dbState:e,dbEventlog:t,eventNumsToRollback:n})=>X(function*(){const r=e.select(Ct`SELECT * FROM ${rm} WHERE (seqNumGlobal, seqNumClient) IN (${n.map(i=>`(${i.global}, ${i.client})`).join(", ")})`).map(i=>({seqNum:{global:i.seqNumGlobal,client:i.seqNumClient},changeset:i.changeset,debug:i.debug})).toSorted((i,o)=>fx(i.seqNum,o.seqNum));for(let i=r.length-1;i>=0;i--){const{changeset:o}=r[i];o!==null&&e.makeChangeset(o).invert().apply()}const s=cJ(100)(n.map(i=>`(${i.global}, ${i.client})`));for(const i of s)e.execute(Ct`DELETE FROM ${rm} WHERE (seqNumGlobal, seqNumClient) IN (${i.join(", ")})`);for(const i of s)t.execute(Ct`DELETE FROM ${Co} WHERE (seqNumGlobal, seqNumClient) IN (${i.join(", ")})`)}).pipe(Qe("@livestore/common:LeaderSyncProcessor:rollback",{attributes:{count:n.length}})),S1e=({schema:e,dbEventlogMissing:t,dbEventlog:n,dbState:r,dbStateMissing:s,initialBlockingSyncContext:i,onError:o,params:a,testing:c})=>X(function*(){const f=yield*YC(),d=a.localPushBatchSize??10,g=a.backendPushBatchSize??50,_=yield*Wg(void 0),b=U=>{const{eventDef:Q}=Di(e,U.name);return Q.options.clientOnly},k=yield*k1e,I={current:0},E={current:s?0:yield*C1e(r)},y=new Map,m={current:void 0},v=yield*YC(),w=yield*qg(!0),$=yield*qg(!0),P={current:_o},O=U=>{P.current=$H(P.current,U)},A=(U,Q)=>{var L;return X(function*(){if(U.length===0)return;yield*x1e(U,P.current),O(U.at(-1).seqNum);const G=(Q==null?void 0:Q.waitForProcessing)??!1,V=I.current;if(G){const J=yield*er(U,()=>rt()),ee=U.map((de,Te)=>[de,J[Te],V]);yield*kc(v,ee),yield*jw(J)}else{const J=U.map(ee=>[ee,void 0,V]);yield*kc(v,J)}}).pipe(Qe("@livestore/common:LeaderSyncProcessor:push",{attributes:{batchSize:U.length,batch:as?U:void 0},links:(L=m.current)!=null&&L.span?[{_tag:"SpanLink",span:m.current.span,attributes:{}}]:void 0}))},z=({event:{name:U,args:Q},clientId:L,sessionId:G})=>X(function*(){const V=yield*_;if(V===void 0)return ze("Not initialized");const{eventDef:J}=Di(e,U),ee=new Rr({name:U,args:Q,clientId:L,sessionId:G,...$b(V.localHead,J.options.clientOnly)});yield*A([ee])}).pipe(_h("LeaderAheadError",os)),D=X(function*(){var Dn,ns,Wi;const U=yield*Gw.pipe(os),Q=yield*_y.pipe(Uw(()=>Pt(void 0))),{devtools:L,shutdownChannel:G}=yield*ws,V=yield*To();m.current={otelSpan:Q,span:U,devtoolsLatch:L.enabled?L.syncBackendLatch:void 0,runtime:V};const J=t?_o:W5(n),ee=t?_o.global:d1e(n);if(ee>J.global)return ze(`During boot the backend head (${ee}) should never be greater than the local head (${J.global})`);const de=t?[]:yield*f1e({global:ee,client:Ml}),Te=new oo({pending:de,upstreamHead:{global:ee,client:Ml},localHead:J});if(yield*uo(_,Te),de.length>0){const Kn=de.filter(mi=>{const{eventDef:$r}=Di(e,mi.name);return $r.options.clientOnly===!1});Kn.length>0&&(yield*kc(f,Kn))}const dn=Kn=>X(function*(){o==="shutdown"&&(yield*G.send(un.make({cause:Kn})),yield*Ad(Kn))});yield*v1e({localPushesLatch:w,localPushesQueue:v,pullLatch:$,syncStateSref:_,syncBackendPushQueue:f,schema:e,isClientEvent:b,otelSpan:Q,currentLocalPushGenerationRef:I,connectedClientSessionPullQueues:k,mergeCounterRef:E,mergePayloads:y,localPushBatchSize:d,testing:{delay:(Dn=c==null?void 0:c.delays)==null?void 0:Dn.localPushProcessing}}).pipe(st,sa(dn),Dt);const ln=yield*RT(),ir=b1e({syncBackendPushQueue:f,otelSpan:Q,devtoolsLatch:(ns=m.current)==null?void 0:ns.devtoolsLatch,backendPushBatchSize:g}).pipe(st,sa(dn));return yield*Md(ln,ir),yield*w1e({initialBackendHead:ee,isClientEvent:b,restartBackendPushing:Kn=>X(function*(){yield*Q6(ln),yield*XC(f),yield*kc(f,Kn),yield*Md(ln,ir)}),syncStateSref:_,localPushesLatch:w,pullLatch:$,dbState:r,otelSpan:Q,initialBlockingSyncContext:i,devtoolsLatch:(Wi=m.current)==null?void 0:Wi.devtoolsLatch,connectedClientSessionPullQueues:k,mergeCounterRef:E,mergePayloads:y,advancePushHead:O}).pipe(st,sa(dn),Dt),{initialLeaderHead:J}}).pipe(oy("@livestore/common:LeaderSyncProcessor:boot")),W=({cursor:U})=>X(function*(){const Q=yield*le({cursor:U});return va(Q)}).pipe(z8),le=({cursor:U})=>{var L;const Q=((L=m.current)==null?void 0:L.runtime)??ze("Not initialized");return X(function*(){const G=yield*k.makeQueue,V=Array.from(y.entries()).map(([J,ee])=>({payload:ee,mergeCounter:J})).filter(({mergeCounter:J})=>J>U.mergeCounter).toSorted((J,ee)=>J.mergeCounter-ee.mergeCounter).map(({payload:J,mergeCounter:ee})=>J._tag==="upstream-advance"?{payload:{_tag:"upstream-advance",newEvents:rJ(J.newEvents,de=>Su(U.eventNum,de.seqNum))},mergeCounter:ee}:{payload:J,mergeCounter:ee});return yield*G.offerAll(V),G}).pipe(Hn(Q))},M=yy({get:X(function*(){const U=yield*_;return U===void 0?ze("Not initialized"):U}),changes:_.changes.pipe(Ui(X8))});return{pull:W,pullQueue:le,push:A,pushPartial:z,boot:D,syncState:M,getMergeCounter:()=>E.current}}),v1e=({localPushesLatch:e,localPushesQueue:t,pullLatch:n,syncStateSref:r,syncBackendPushQueue:s,schema:i,isClientEvent:o,otelSpan:a,currentLocalPushGenerationRef:c,connectedClientSessionPullQueues:f,mergeCounterRef:d,mergePayloads:g,localPushBatchSize:_,testing:b})=>X(function*(){for(;;){b.delay!==void 0&&(yield*b.delay.pipe(Qe("localPushProcessingDelay")));const k=yield*GT(t,1,_);yield*e.await,yield*n.close;const I=k.filter(([P,O,A])=>A===c.current).map(([P,O])=>[P,O]);if(I.length===0){yield*n.open;continue}const[E,y]=oJ(I),m=yield*r;if(m===void 0)return ze("Not initialized");const v=Q0({syncState:m,payload:{_tag:"local-push",newEvents:E},isClientEvent:o,isEqualEvent:K0}),w=yield*G5(d);switch(v._tag){case"unexpected-error":return a==null||a.addEvent(`[${w}]:push:unexpected-error`,{batchSize:E.length,newEvents:as?JSON.stringify(E):void 0}),yield*zs(v.cause);case"rebase":return ze("The leader thread should never have to rebase due to a local push");case"reject":{a==null||a.addEvent(`[${w}]:push:reject`,{batchSize:E.length,mergeResult:as?JSON.stringify(v):void 0}),c.current++;const P=c.current,O=E.at(0).seqNum,A=yield*Z_e(t,D=>D[2]>=P);if(js&&(yield*ZC(t))>0){console.log("localPushesQueue is not empty",yield*ZC(t));debugger}const z=[...y,...A.map(([D,W])=>W)].filter(X8);yield*er(z,D=>V$(D,VH.make({minimumExpectedNum:v.expectedMinimumId,providedNum:O}))),yield*n.open;continue}case"advance":break;default:wa(v)}yield*uo(r,v.newSyncState),yield*f.offer({payload:jc.make({newEvents:v.newEvents}),mergeCounter:w}),g.set(w,jc.make({newEvents:v.newEvents})),a==null||a.addEvent(`[${w}]:push:advance`,{batchSize:E.length,mergeResult:as?JSON.stringify(v):void 0});const $=v.newEvents.filter(P=>{const{eventDef:O}=Di(i,P.name);return O.options.clientOnly===!1});yield*kc(s,$),yield*K5({batchItems:v.newEvents,deferreds:y}),yield*n.open}}),K5=({batchItems:e,deferreds:t})=>X(function*(){const{dbState:n,dbEventlog:r,materializeEvent:s}=yield*ws;n.execute("BEGIN TRANSACTION",void 0),r.execute("BEGIN TRANSACTION",void 0),yield*pr(i=>X(function*(){xd(i)||(n.execute("ROLLBACK",void 0),r.execute("ROLLBACK",void 0))}));for(let i=0;i<e.length;i++){const{sessionChangeset:o,hash:a}=yield*s(e[i]);e[i].meta.sessionChangeset=o,e[i].meta.materializerHashLeader=a,(t==null?void 0:t[i])!==void 0&&(yield*jt(t[i],void 0))}n.execute("COMMIT",void 0),r.execute("COMMIT",void 0)}).pipe(Sc,Pl,Qe("@livestore/common:LeaderSyncProcessor:materializeEventItems",{attributes:{batchSize:e.length}}),st,un.mapToUnexpectedError),w1e=({initialBackendHead:e,isClientEvent:t,restartBackendPushing:n,otelSpan:r,dbState:s,syncStateSref:i,localPushesLatch:o,pullLatch:a,devtoolsLatch:c,initialBlockingSyncContext:f,connectedClientSessionPullQueues:d,mergeCounterRef:g,mergePayloads:_,advancePushHead:b})=>X(function*(){const{syncBackend:k,dbState:I,dbEventlog:E,schema:y}=yield*ws;if(k===void 0)return;const m=($,P)=>X(function*(){if($.length===0)return;c!==void 0&&(yield*c.await),yield*o.close,yield*a.await;const O=yield*i;if(O===void 0)return ze("Not initialized");const A=Q0({syncState:O,payload:jc.make({newEvents:$}),isClientEvent:t,isEqualEvent:K0,ignoreClientEvents:!0}),z=yield*G5(g);if(A._tag==="reject")return ze("The leader thread should never reject upstream advances");if(A._tag==="unexpected-error")return r==null||r.addEvent(`[${z}]:pull:unexpected-error`,{newEventsCount:$.length,newEvents:as?JSON.stringify($):void 0}),yield*zs(A.cause);const D=$.at(-1).seqNum;if(h1e(E,D),A._tag==="rebase"){r==null||r.addEvent(`[${z}]:pull:rebase`,{newEventsCount:$.length,newEvents:as?JSON.stringify($):void 0,rollbackCount:A.rollbackEvents.length,mergeResult:as?JSON.stringify(A):void 0});const W=A.newSyncState.pending.filter(le=>{const{eventDef:M}=Di(y,le.name);return M.options.clientOnly===!1});yield*n(W),A.rollbackEvents.length>0&&(yield*_1e({dbState:I,dbEventlog:E,eventNumsToRollback:A.rollbackEvents.map(le=>le.seqNum)})),yield*d.offer({payload:G0.make({newEvents:A.newEvents,rollbackEvents:A.rollbackEvents}),mergeCounter:z}),_.set(z,G0.make({newEvents:A.newEvents,rollbackEvents:A.rollbackEvents}))}else if(r==null||r.addEvent(`[${z}]:pull:advance`,{newEventsCount:$.length,mergeResult:as?JSON.stringify(A):void 0}),yield*d.offer({payload:jc.make({newEvents:A.newEvents}),mergeCounter:z}),_.set(z,jc.make({newEvents:A.newEvents})),A.confirmedEvents.length>0){const W=$.filter(le=>A.confirmedEvents.some(M=>Rb(le.seqNum,M.seqNum)));yield*g1e(W)}E1e(I,D),b(A.newSyncState.localHead),yield*K5({batchItems:A.newEvents,deferreds:void 0}),yield*uo(i,A.newSyncState),P===0&&(yield*o.open)}),v=yield*m1e(e),w=Twe({schema:y,dbState:s});yield*k.pull(v).pipe(Un(({batch:$,remaining:P})=>X(function*(){yield*Kg(k.isConnected,O=>O===!0),yield*m($.map(O=>Rr.fromGlobal(O.eventEncoded,{syncMetadata:O.metadata,materializerHashLeader:w(O.eventEncoded),materializerHashSession:re()})),P),yield*f.update({processed:$.length,remaining:P})})),Sn,Jt)}).pipe(Qe("@livestore/common:LeaderSyncProcessor:backend-pulling")),b1e=({syncBackendPushQueue:e,otelSpan:t,devtoolsLatch:n,backendPushBatchSize:r})=>X(function*(){const{syncBackend:s}=yield*ws;if(s!==void 0)for(;;){yield*Kg(s.isConnected,a=>a===!0);const i=yield*GT(e,1,r);yield*Kg(s.isConnected,a=>a===!0),n!==void 0&&(yield*n.await),t==null||t.addEvent("backend-push",{batchSize:i.length,batch:as?JSON.stringify(i):void 0});const o=yield*s.push(i.map(a=>a.toGlobal())).pipe(cc);if(o._tag==="Left")return js&&(yield*ni("handled backend-push-error",{error:o.left.toString()})),t==null||t.addEvent("backend-push-error",{error:o.left.toString()}),yield*FI}}).pipe(Jt,Qe("@livestore/common:LeaderSyncProcessor:backend-pushing")),E1e=(e,t)=>{e.execute(Ct`DELETE FROM ${rm} WHERE seqNumGlobal < ${t.global}`)},k1e=X(function*(){const e=new Set;return yield*pr(()=>X(function*(){for(const r of e)yield*In(r);e.clear()})),{makeQueue:X(function*(){const r=yield*dr().pipe(Rt(In));return yield*pr(()=>Re(()=>e.delete(r))),e.add(r),r}),offer:r=>X(function*(){if(!(r.payload._tag==="upstream-advance"&&r.payload.newEvents.length===0))for(const s of e)yield*$t(s,r)})}}),G5=e=>X(function*(){const{dbState:t}=yield*ws;return e.current++,t.execute(Ct`INSERT OR REPLACE INTO ${Pb} (id, mergeCounter) VALUES (0, ${e.current})`),e.current}),C1e=e=>X(function*(){var n;return((n=e.select(Ct`SELECT mergeCounter FROM ${Pb} WHERE id = 0`)[0])==null?void 0:n.mergeCounter)??0}),x1e=(e,t)=>X(function*(){if(e.length!==0){for(let n=1;n<e.length;n++)Su(e[n-1].seqNum,e[n].seqNum)&&ze(`Events must be ordered in monotonically ascending order by eventNum. Received: [${e.map(r=>Ns(r.seqNum)).join(", ")}]`);if(Su(t,e[0].seqNum))return yield*VH.make({minimumExpectedNum:t,providedNum:e[0].seqNum})}}),R1e=X(function*(){const{dbState:e,dbEventlog:t,schema:n,bootStatusQueue:r,materializeEvent:s}=yield*ws,i=n.state.sqlite.migrations;let o;yield*pr(ay("recreateDb:finalizer")(function*(f){f._tag==="Failure"&&e.destroy()}));const a=e;yield*H5(a,{foreignKeys:!0});const c=f=>X(function*(){yield*gp(()=>{var g;return(g=f==null?void 0:f.init)==null?void 0:g.call(f,a)}).pipe(un.mapToUnexpectedError);const d=yield*Ewe({db:a,schema:n,onProgress:({done:g,total:_})=>$t(r,{stage:"migrating",progress:{done:g,total:_}})});return yield*gp(()=>{var g;return(g=f==null?void 0:f.pre)==null?void 0:g.call(f,a)}).pipe(un.mapToUnexpectedError),{migrationsReport:d,tmpDb:a}});switch(i.strategy){case"auto":{const f=i.hooks,d=yield*c(f);o=d.migrationsReport,yield*Nwe({dbEventlog:t,schema:n,materializeEvent:s,onProgress:({done:g,total:_})=>$t(r,{stage:"rehydrating",progress:{done:g,total:_}})}),yield*gp(()=>{var g;return(g=f==null?void 0:f.post)==null?void 0:g.call(f,d.tmpDb)}).pipe(un.mapToUnexpectedError);break}case"manual":{const f=e.export();o={migrations:[]};const d=yield*gp(()=>i.migrate(f)).pipe(un.mapToUnexpectedError);a.import(d);break}default:wa(i)}return{migrationsReport:o}}).pipe(Pl,Qe("@livestore/common:leader-thread:recreateDb"),t2("@livestore/common:leader-thread:recreateDb")),$1e=({schema:e,storeId:t,clientId:n,syncPayload:r,makeSqliteDb:s,syncOptions:i,dbState:o,dbEventlog:a,devtoolsOptions:c,shutdownChannel:f,params:d,testing:g})=>X(function*(){var O;const _=yield*dr().pipe(Rt(In)),b=a.select(Ct`select count(*) as count from sqlite_master`)[0].count===0,k=o.select(Ct`select count(*) as count from sqlite_master`)[0].count===0,I=(i==null?void 0:i.backend)===void 0?void 0:yield*i.backend({storeId:t,clientId:n,payload:r});I!==void 0&&(yield*I.connect.pipe(st,Dt));const E=yield*I1e({initialSyncOptions:(i==null?void 0:i.initialSyncOptions)??{_tag:"Skip"},bootStatusQueue:_}),y=yield*S1e({schema:e,dbEventlogMissing:b,dbEventlog:a,dbState:o,dbStateMissing:k,initialBlockingSyncContext:E,onError:(i==null?void 0:i.onSyncError)??"ignore",params:{localPushBatchSize:d==null?void 0:d.localPushBatchSize,backendPushBatchSize:d==null?void 0:d.backendPushBatchSize},testing:{delays:(O=g==null?void 0:g.syncProcessor)==null?void 0:O.delays}}),m=yield*dr().pipe(Rt(In)),v=c.enabled?{enabled:!0,syncBackendLatch:yield*qg(!0),syncBackendLatchState:yield*Wg({latchClosed:!1})}:{enabled:!1},w=yield*y1e({schema:e,dbState:o,dbEventlog:a}),$={schema:e,bootStatusQueue:_,storeId:t,clientId:n,dbState:o,dbEventlog:a,makeSqliteDb:s,eventSchema:HH(e),shutdownStateSubRef:yield*Wg("running"),shutdownChannel:f,syncBackend:I,syncProcessor:y,materializeEvent:w,extraIncomingMessagesQueue:m,devtools:v,initialState:{}};globalThis.__leaderThreadCtx=$;const P=vh(ws,$);return $.initialState=yield*T1e({dbStateMissing:k,initialBlockingSyncContext:E,devtoolsOptions:c}).pipe(Hn(P)),P}).pipe(Qe("@livestore/common:leader-thread:boot"),oy("@livestore/common:leader-thread"),un.mapToUnexpectedError,st,dU),I1e=({initialSyncOptions:e,bootStatusQueue:t})=>X(function*(){const n={isDone:!1,processedEvents:0,total:-1},r=e._tag==="Blocking"?yield*rt():void 0;return r!==void 0&&e._tag==="Blocking"&&(yield*jt(r,void 0).pipe(due(e.timeout),Dt)),{blockingDeferred:r,update:({processed:s,remaining:i})=>X(function*(){n.isDone!==!0&&(n.total===-1&&(n.total=i+s),n.processedEvents+=s,yield*$t(t,{stage:"syncing",progress:{done:n.processedEvents,total:n.total}}),i===0&&r!==void 0&&(yield*jt(r,void 0),n.isDone=!0))})}}),T1e=({dbStateMissing:e,initialBlockingSyncContext:t,devtoolsOptions:n})=>X(function*(){const{dbEventlog:r,bootStatusQueue:s,syncProcessor:i}=yield*ws;yield*u1e(r);const{migrationsReport:o}=e?yield*R1e:{migrationsReport:{migrations:[]}},{initialLeaderHead:a}=yield*i.boot;return t.blockingDeferred!==void 0&&(yield*$t(s,{stage:"syncing",progress:{done:0,total:-1}}),yield*t.blockingDeferred.pipe(Qe("@livestore/common:leader-thread:initial-sync-blocking"))),yield*$t(s,{stage:"done"}),yield*s1e(n).pipe(st,Dt),{migrationsReport:o,leaderHead:a}}),P1e=e=>RH({channelName:`livestore.shutdown.${e}`,schema:r1e});class Q5 extends b_e()("DevtoolsWebCommon.CreateConnection",{payload:{from:Y,port:CH},success:ke({}),failure:gb}){}class nxe extends tt(Q5){}const O1e=RH({channelName:"session-info",schema:YH}),Ox={sharedWorker:({storeId:e})=>`shared-worker-${e}`,browserExtension:{contentscriptMain:e=>`contentscript-main-${e}`,contentscriptIframe:e=>`contentscript-iframe-${e}`}},Ax=Ye("ClientSessionContentscriptMainReq",{storeId:Y,clientId:Y,sessionId:Y}),t3=Ye("ClientSessionContentscriptMainRes",{tabId:it}),A1e={contentscriptMain:zt(()=>ux({listenWindow:window,sendWindow:window,schema:{listen:Ax,send:t3},ids:{own:"contentscript-main-static",other:"client-session-static"}})),clientSession:zt(()=>ux({listenWindow:window,sendWindow:window,schema:{listen:t3,send:Ax},ids:{own:"client-session-static",other:"contentscript-main-static"}}))},J5=({node:e,target:t,worker:n})=>X(function*(){const r=new MessageChannel,s=yield*rt();js&&(yield*c0e(`@livestore/devtools-web-common: closing message channel ${e.nodeName} → ${t}`)),yield*n.execute(Q5.make({from:e.nodeName,port:r.port1})).pipe(Un(()=>jt(s,!0)),Sn,st,Dt),yield*s;const i=yield*Vve({port:r.port2,schema:E2});yield*e.addEdge({target:t,edgeChannel:i,replaceIfExists:!0}),js&&(yield*ni(`@livestore/devtools-web-common: initiated connection: ${e.nodeName} → ${t}`))}).pipe(un.mapToUnexpectedError),F1e=({schema:e,storeId:t,clientId:n,sessionId:r})=>X(function*(){if(ko()){const s=globalThis.LIVESTORE_DEVTOOLS_PATH??"/_livestore",i=`${location.origin}${s}`,o=yield*Fd(()=>fetch(i));if(o.ok&&(yield*Fd(()=>o.text())).includes('<meta name="livestore-devtools" content="true" />')){const c=`${i}/web/${t}/${n}/${r}/${e.devtools.alias}`;yield*HI(`[@livestore/adapter-web] Devtools ready on ${c}`)}}}).pipe(Qe("@livestore/adapter-web:client-session:devtools:logDevtoolsUrl")),N1e=ay(function*({webmeshNode:e,sessionInfo:t,sharedWorker:n,devtoolsEnabled:r,schema:s}){if(r){const{clientId:i,sessionId:o,storeId:a}=t;yield*F1e({clientId:i,sessionId:o,schema:s,storeId:a}),yield*XH({webChannel:yield*O1e,sessionInfo:t}).pipe(st,Dt),yield*X(function*(){const c=yield*A1e.clientSession;yield*c.send(Ax.make({clientId:i,sessionId:o,storeId:a}));const{tabId:f}=yield*c.listen.pipe(Dl(),M_e,Va),d=Ox.browserExtension.contentscriptMain(f),g=yield*ux({listenWindow:window,sendWindow:window,schema:E2,ids:{own:e.nodeName,other:d}});yield*e.addEdge({target:d,edgeChannel:g})}).pipe(Qe("@livestore/adapter-web:client-session:devtools:browser-extension"),st,Dt),yield*J5({node:e,target:Ox.sharedWorker({storeId:a}),worker:n})}}),D1e=Zbe(),q1e=(e={})=>t=>X(function*(){var y;const{schema:n,shutdown:r,syncPayload:s,storeId:i,devtoolsEnabled:o}=t,a=yield*Fd(()=>D1e),c=yield*YN({sqlite3:a})({_tag:"in-memory"}),f=e.clientId??br(6),d=e.sessionId??br(6),g=(y=e.devtools)!=null&&y.sharedWorker?sSe(e.devtools.sharedWorker,{name:`livestore-shared-worker-${i}`}):void 0,_=g?yield*jve({size:1,concurrency:100}).pipe(Hn(Yve(()=>g)),st,un.mapToUnexpectedError,Dt):void 0,{leaderThread:b,initialSnapshot:k}=yield*M1e({schema:n,storeId:i,clientId:f,makeSqliteDb:YN({sqlite3:a}),syncOptions:e.sync,syncPayload:s,importSnapshot:e.importSnapshot,devtoolsEnabled:o,sharedWorkerFiber:_});c.import(k);const I=yield*Wg("has-lock");return yield*Pbe({...t,sqliteDb:c,clientId:f,sessionId:d,isLeader:!0,leaderThread:b,lockStatus:I,shutdown:r,webmeshMode:"direct",connectWebmeshNode:({sessionInfo:m,webmeshNode:v})=>X(function*(){if(_===void 0||o===!1)return;const w=yield*_.pipe($l);yield*N1e({webmeshNode:v,sessionInfo:m,sharedWorker:w,devtoolsEnabled:o,schema:n})}),registerBeforeUnload:m=>typeof window<"u"&&typeof window.addEventListener=="function"?(window.addEventListener("beforeunload",m),()=>window.removeEventListener("beforeunload",m)):()=>{}})}).pipe(un.mapToUnexpectedError,Hn(dve)),M1e=({schema:e,storeId:t,clientId:n,makeSqliteDb:r,syncOptions:s,syncPayload:i,importSnapshot:o,devtoolsEnabled:a,sharedWorkerFiber:c})=>X(function*(){const f=yield*To(),d=E=>r({_tag:"in-memory",configureDb:y=>H5(y,{foreignKeys:!0}).pipe(Hn(f),ur)}),g=yield*P1e(t),[_,b]=yield*jw([d(),d()],{concurrency:2});o&&_.import(o);const k=yield*L1e({devtoolsEnabled:a,sharedWorkerFiber:c,dbState:_,dbEventlog:b,storeId:t,clientId:n}),I=yield*Fue($1e({schema:e,storeId:t,clientId:n,makeSqliteDb:r,syncOptions:s,dbState:_,dbEventlog:b,devtoolsOptions:k,shutdownChannel:g,syncPayload:i}));return yield*X(function*(){const{dbState:E,dbEventlog:y,syncProcessor:m,extraIncomingMessagesQueue:v,initialState:w}=yield*ws,$=W5(y),P={events:{pull:({cursor:A})=>m.pull({cursor:A}),push:A=>m.push(A.map(z=>new Rr(z)),{waitForProcessing:!0})},initialState:{leaderHead:$,migrationsReport:w.migrationsReport},export:Re(()=>E.export()),getEventlogData:Re(()=>y.export()),getSyncState:m.syncState,sendDevtoolsMessage:A=>v.offer(A)},O=E.export();return{leaderThread:P,initialSnapshot:O}}).pipe(Hn(I))}),L1e=({devtoolsEnabled:e,sharedWorkerFiber:t,dbState:n,dbEventlog:r,storeId:s,clientId:i})=>X(function*(){return e===!1||t===void 0?{enabled:!1}:{enabled:!0,boot:X(function*(){const o={state:n.metadata.persistenceInfo,eventlog:r.metadata.persistenceInfo},a=yield*T5(v5.client.leader({storeId:s,clientId:i}));globalThis.__debugWebmeshNodeLeader=a;const c=yield*t.pipe($l);return yield*J5({node:a,worker:c,target:Ox.sharedWorker({storeId:s})}).pipe(st,Dt),{node:a,persistenceInfo:o,mode:"direct"}})}}),R2=Symbol.for("NOT_REFRESHED_YET"),n3=()=>({_tag:"unknown"}),z1e=e=>({_tag:"Some",value:e}),j1e=()=>({_tag:"None"});let U1e=0;const H1e=()=>`graph-${++U1e}`;class B1e{constructor(){p(this,"id",H1e());p(this,"atoms",new Set);p(this,"effects",new Set);p(this,"context");p(this,"debugRefreshInfos",new fo(200));p(this,"currentDebugRefresh");p(this,"deferredEffects",new Map);p(this,"refreshCallbacks",new Set);p(this,"nodeIdCounter",0);p(this,"uniqueNodeId",()=>`node-${++this.nodeIdCounter}`);p(this,"refreshInfoIdCounter",0);p(this,"uniqueRefreshInfoId",()=>`refresh-info-${++this.refreshInfoIdCounter}`);p(this,"runEffects",(t,n)=>{var s;(((s=this.context)==null?void 0:s.effectsWrapper)??(i=>i()))(()=>{this.currentDebugRefresh={refreshedAtoms:[],startMs:performance.now()};for(const c of t)c.doEffect(n==null?void 0:n.otelContext,n.debugRefreshReason);const i=this.currentDebugRefresh.refreshedAtoms,o=performance.now()-this.currentDebugRefresh.startMs;this.currentDebugRefresh=void 0;const a={id:this.uniqueRefreshInfoId(),reason:n.debugRefreshReason,skippedRefresh:!1,refreshedAtoms:i,durationMs:o,completedTimestamp:Date.now(),graphSnapshot:this.getSnapshot({includeResults:!1})};this.debugRefreshInfos.push(a),this.runRefreshCallbacks()})});p(this,"runDeferredEffects",t=>{for(const[n,r]of this.deferredEffects)this.runEffects(new Set([n]),{debugRefreshReason:{_tag:"runDeferredEffects",originalRefreshReasons:Array.from(r),manualRefreshReason:t==null?void 0:t.debugRefreshReason},otelContext:t==null?void 0:t.otelContext})});p(this,"runRefreshCallbacks",()=>{for(const t of this.refreshCallbacks)t()});p(this,"getSnapshot",t=>{const{includeResults:n=!1}=t??{},r=[];for(const o of this.atoms)r.push(s3(o,n));const s=[];for(const o of this.effects)s.push(W1e(o));const i=[];for(const[o]of this.deferredEffects)i.push(o.id);return{atoms:r,effects:s,deferredEffects:i}});p(this,"subscribeToRefresh",t=>(this.refreshCallbacks.add(t),()=>{this.refreshCallbacks.delete(t)}))}makeRef(t,n){const r={_tag:"ref",id:this.uniqueNodeId(),isDirty:!1,isDestroyed:!1,previousResult:t,computeResult:()=>r.previousResult,sub:new Set,super:new Set,label:n==null?void 0:n.label,meta:n==null?void 0:n.meta,equal:(n==null?void 0:n.equal)??Up,refreshes:0};return this.atoms.add(r),r}makeThunk(t,n){const r={_tag:"thunk",id:this.uniqueNodeId(),previousResult:R2,isDirty:!0,isDestroyed:!1,computeResult:(s,i)=>{if(r.isDirty){const o=this.currentDebugRefresh===void 0;o&&(this.currentDebugRefresh={refreshedAtoms:[],startMs:performance.now()}),r.sub=new Set;const a=(b,k)=>(this.addEdge(r,b),r3(b,k,i));let c;const d=t(a,b=>{c=b},this.context??V1e(this),s,i),g=r.equal(r.previousResult,d)===!1,_={atom:s3(r,!1),resultChanged:g,debugInfo:c??n3()};if(this.currentDebugRefresh.refreshedAtoms.push(_),r.isDirty=!1,r.previousResult=d,r.recomputations++,o){const b=this.currentDebugRefresh.refreshedAtoms,k=performance.now()-this.currentDebugRefresh.startMs;this.currentDebugRefresh=void 0,this.debugRefreshInfos.push({id:this.uniqueRefreshInfoId(),reason:i??{_tag:"makeThunk",label:n==null?void 0:n.label},skippedRefresh:!1,refreshedAtoms:b,durationMs:k,completedTimestamp:Date.now(),graphSnapshot:this.getSnapshot({includeResults:!1})})}return d}else return r.previousResult},sub:new Set,super:new Set,recomputations:0,label:n==null?void 0:n.label,meta:n==null?void 0:n.meta,equal:(n==null?void 0:n.equal)??Up,__getResult:t};return this.atoms.add(r),r}destroyNode(t){if(t._tag==="ref"||t._tag==="thunk")for(const n of t.super)this.destroyNode(n);if(t._tag!=="ref")for(const n of t.sub)this.removeEdge(t,n);t._tag==="effect"?(this.deferredEffects.delete(t),this.effects.delete(t)):this.atoms.delete(t),t.isDestroyed=!0}destroy(){for(const t of this.atoms)this.destroyNode(t)}makeEffect(t,n){const r={_tag:"effect",id:this.uniqueNodeId(),isDestroyed:!1,doEffect:(s,i)=>{r.invocations++,r.sub=new Set,t((a,c,f)=>(this.addEdge(r,a),r3(a,c,f)),s,i)},sub:new Set,label:n==null?void 0:n.label,invocations:0};return this.effects.add(r),r}setRef(t,n,r){this.setRefs([[t,n]],r)}setRefs(t,n){const r=new Set;for(const[s,i]of t)s.previousResult=i,s.refreshes++,Fx(s,r);if(n!=null&&n.skipRefresh)for(const s of r)this.deferredEffects.has(s)===!1&&this.deferredEffects.set(s,new Set),(n==null?void 0:n.debugRefreshReason)!==void 0&&this.deferredEffects.get(s).add(n.debugRefreshReason);else this.runEffects(r,{debugRefreshReason:(n==null?void 0:n.debugRefreshReason)??n3(),otelContext:n==null?void 0:n.otelContext})}addEdge(t,n){t.sub.add(n),n.super.add(t),this.currentDebugRefresh===void 0&&this.runRefreshCallbacks()}removeEdge(t,n){t.sub.delete(n);const r=new Set;Fx(n,r);for(const s of r)this.deferredEffects.set(s,new Set);n.super.delete(t),this.currentDebugRefresh===void 0&&this.runRefreshCallbacks()}}const r3=(e,t,n)=>{if(e.isDestroyed&&ze(`LiveStore Error: Attempted to compute destroyed ${e._tag} (${e.id}): ${e.label??""}`),e.isDirty){const r=e.computeResult(t,n);return e.isDirty=!1,e.previousResult=r,r}else return e.previousResult},Fx=(e,t)=>{for(const n of e.super)n._tag==="thunk"?(n.isDirty=!0,Fx(n,t)):t.add(n)},V1e=e=>{throw new Error(`LiveStore Error: \`context\` not set on ReactiveGraph (${e.id})`)},s3=(e,t)=>{const n=[];for(const i of e.sub)n.push(i.id);const r=[];for(const i of e.super)r.push(i.id);const s=t?z1e(e.previousResult===R2?'"SYMBOL_NOT_REFRESHED_YET"':JSON.stringify(e.previousResult)):j1e();return e._tag==="ref"?{_tag:e._tag,id:e.id,label:e.label,meta:e.meta,isDirty:e.isDirty,sub:n,super:r,isDestroyed:e.isDestroyed,refreshes:e.refreshes,previousResult:s}:{_tag:"thunk",id:e.id,label:e.label,meta:e.meta,isDirty:e.isDirty,sub:n,super:r,isDestroyed:e.isDestroyed,recomputations:e.recomputations,previousResult:s}},W1e=e=>{const t=[];for(const n of e.sub)t.push(n.id);return{_tag:e._tag,id:e.id,label:e.label,sub:t,invocations:e.invocations,isDestroyed:e.isDestroyed}},K1e=()=>new B1e,G1e=({id:e,explicitDefaultValues:t,table:n,otelContext:r})=>({store:s})=>{if(m2(n)===!1)return ze(`Cannot insert row for table "${n.sqliteDef.name}" which does not have 'deriveEvents: true' set`);const i=r??s.otel.queriesSpanContext,o=e===h2?s.sessionId:e;s.sqliteDbWrapper.cachedSelect(`SELECT 1 FROM '${n.sqliteDef.name}' WHERE id = ?`,[o],{otelContext:i}).length!==1&&s.commit({otelContext:i,skipRefresh:!0,label:`${n.sqliteDef.name}.set:${o}`},n.set(t,o))},Q1e=["begin","rollback","commit","savepoint","release"],i3=200;var Tc,rd,lv;class J1e{constructor(){Ft(this,Tc,new J0(i3));Ft(this,rd,new Map);p(this,"getKey",(t,n)=>n==null?t:Array.isArray(n)?t+`
242
+ `+n.join(`
243
+ `):t+`
244
+ `+Object.values(n).join(`
245
+ `));p(this,"get",t=>ge(this,Tc).get(t));p(this,"set",(t,n,r)=>{ge(this,Tc).set(n,r);for(const s of t){let i=ge(this,rd).get(s);i==null&&(i=new Uwe(i3),i.onEvict=ge(this,lv),ge(this,rd).set(s,i)),i.add(n)}});Ft(this,lv,t=>{ge(this,Tc).delete(t)});p(this,"ignoreQuery",t=>Q1e.some(n=>t.startsWith(n)));p(this,"invalidate",t=>{for(const n of t){const r=ge(this,rd).get(n);if(r!=null)for(const s of r)ge(this,Tc).delete(s)}})}}Tc=new WeakMap,rd=new WeakMap,lv=new WeakMap;const Y5=()=>({slowQueries:new fo(200),queryFrameDuration:0,queryFrameCount:0,events:new fo(1e3)});class Y1e{constructor({db:t,otel:n}){p(this,"_tag","SqliteDb");p(this,"cachedStmts",new J0(200));p(this,"tablesUsedCache",new J0(200));p(this,"resultCache",new J1e);p(this,"db");p(this,"otelTracer");p(this,"otelRootSpanContext");p(this,"tablesUsedStmt");p(this,"debugInfo",Y5());p(this,"metadata");p(this,"execute",P5((t,n)=>this.cachedExecute(t,n)));p(this,"select",O5((t,n)=>this.cachedSelect(t,n)));this.db=t,this.otelTracer=n.tracer,this.otelRootSpanContext=n.rootSpanContext,this.tablesUsedStmt=t.prepare("SELECT tbl_name FROM tables_used(?) AS u JOIN sqlite_master ON sqlite_master.name = u.name WHERE u.schema = 'main';"),this.cachedStmts.onEvict=(r,s)=>s.finalize(),X1e(this)}prepare(t){return this.db.prepare(t)}import(t){return this.db.import(t)}close(){this.db.close()}destroy(){this.db.destroy()}session(){return this.db.session()}makeChangeset(t){return this.db.makeChangeset(t)}txn(t){this.execute(Ct`begin transaction;`);let n=!1,r;try{r=t()}catch(s){throw n=!0,this.execute(Ct`rollback;`),s}return n||this.execute(Ct`commit;`),r}withChangeset(t){const n=this.db.session(),r=t(),s=n.changeset();return n.finish(),{result:r,changeset:s?{_tag:"sessionChangeset",data:s,debug:null}:{_tag:"no-op"}}}rollback(t){this.db.makeChangeset(t).invert().apply()}getTablesUsed(t){const n=Z1e(t);if(n!==void 0)return new Set([n]);const r=this.tablesUsedCache.get(t);if(r)return r;const s=this.tablesUsedStmt,i=new Set;try{const o=s.select([t]);for(const a of o)i.add(a.tbl_name)}catch(o){return console.error("Error getting tables used",o,"for query",t),new Set}return this.tablesUsedCache.set(t,i),i}cachedExecute(t,n,r){return this.otelTracer.startActiveSpan("livestore.in-memory-db:execute",{attributes:{"sql.query":t}},(r==null?void 0:r.otelContext)??this.otelRootSpanContext,s=>{try{let i=this.cachedStmts.get(t);i===void 0&&(i=this.db.prepare(t),this.cachedStmts.set(t,i)),i.execute(n),(r==null?void 0:r.hasNoEffects)!==!0&&!this.resultCache.ignoreQuery(t)&&this.resultCache.invalidate((r==null?void 0:r.writeTables)??this.getTablesUsed(t)),s.end();const o=yx(s);return this.debugInfo.queryFrameDuration+=o,this.debugInfo.queryFrameCount++,o>5&&ko()&&this.debugInfo.slowQueries.push({queryStr:t,bindValues:n,durationMs:o,rowsCount:void 0,queriedTables:new Set,startTimePerfNow:LN(s)}),{durationMs:o}}catch(i){if(s.recordException(i),s.end(),js)debugger;throw new xc({cause:i,query:{bindValues:n??{},sql:t}})}})}cachedSelect(t,n,r){const{queriedTables:s,skipCache:i=!1,otelContext:o}=r??{};return this.otelTracer.startActiveSpan("sql-in-memory-select",{},o??this.otelRootSpanContext,a=>{try{a.setAttribute("sql.query",t);const c=this.resultCache.getKey(t,n),f=this.resultCache.get(c);if(i===!1&&f!==void 0)return a.setAttribute("sql.rowsCount",f.length),a.setAttribute("sql.cached",!0),a.end(),f;let d=this.cachedStmts.get(t);d===void 0&&(d=this.db.prepare(t),this.cachedStmts.set(t,d));const g=d.select(n);a.setAttribute("sql.rowsCount",g.length),a.setAttribute("sql.cached",!1);const _=s??this.getTablesUsed(t);this.resultCache.set(_,c,g),a.end();const b=yx(a);return this.debugInfo.queryFrameDuration+=b,this.debugInfo.queryFrameCount++,b>5&&ko()&&this.debugInfo.slowQueries.push({queryStr:t,bindValues:n,durationMs:b,rowsCount:g.length,queriedTables:_,startTimePerfNow:LN(a)}),g}finally{a.end()}})}export(){for(const t of this.cachedStmts.keys())this.cachedStmts.delete(t);return this.db.export()}}const X1e=e=>{e.execute(Ct`
246
+ PRAGMA page_size=32768;
247
+ PRAGMA cache_size=10000;
248
+ PRAGMA synchronous='OFF';
249
+ PRAGMA temp_store='MEMORY';
250
+ PRAGMA foreign_keys='ON'; -- we want foreign key constraints to be enforced
251
+ `)},Z1e=e=>{const[t,n]=e.trim().match(/^delete\s+from\s+(\w+)$/i)??[];return n};class eEe{constructor(){p(this,"map");p(this,"add",t=>{const n=this.map.get(t)??0;this.map.set(t,n+1)});p(this,"remove",t=>{const n=this.map.get(t)??0;n===1?this.map.delete(t):this.map.set(t,n-1)});p(this,"has",t=>this.map.has(t));this.map=new Map}get size(){return this.map.size}*[Symbol.iterator](){for(const t of this.map.keys())yield t}}const Nx=(e,t,n="application/octet-stream")=>{const r=e instanceof Blob?e:new Blob([e],{type:n}),s=window.URL.createObjectURL(r);tEe(s,t),setTimeout(()=>window.URL.revokeObjectURL(s),1e3)},tEe=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,document.body.append(n),n.style.display="none",n.click(),n.remove()},nEe=()=>{ko()&&(globalThis.__debugLiveStoreUtils={downloadBlob:Nx,runSync:e=>ur(e),runFork:e=>Po(e)})};ko()&&nEe();class rEe extends Wq{constructor({clientSession:n,schema:r,otelOptions:s,context:i,batchUpdates:o,storeId:a,effectContext:c,params:f,confirmUnsavedChanges:d,__runningInDevtools:g}){super();p(this,"storeId");p(this,"reactivityGraph");p(this,"sqliteDbWrapper");p(this,"clientSession");p(this,"schema");p(this,"context");p(this,"otel");p(this,"tableRefs");p(this,"effectContext");p(this,"activeQueries");p(this,"__eventSchema");p(this,"syncProcessor");p(this,"boot");p(this,"subscribe",(n,r)=>this.otel.tracer.startActiveSpan("LiveStore.subscribe",{attributes:{label:r==null?void 0:r.label,queryLabel:n.label}},(r==null?void 0:r.otelContext)??this.otel.queriesSpanContext,s=>{var g;const i=ss.setSpan(Xs.active(),s),o=n._tag==="def"||n._tag==="signal-def"?n.make(this.reactivityGraph.context):{value:n,deref:()=>{}},a=o.value,c=`subscribe:${r==null?void 0:r.label}`,f=this.reactivityGraph.makeEffect((_,b,k)=>r.onUpdate(_(a.results$,i,k)),{label:c});return r!=null&&r.stackInfo&&a.activeSubscriptions.add(r.stackInfo),(g=r==null?void 0:r.onSubscribe)==null||g.call(r,a),this.activeQueries.add(a),(r==null?void 0:r.skipInitialRun)!==!0&&!a.isDestroyed&&f.doEffect(i,{_tag:"subscribe.initial",label:`subscribe-initial-run:${r==null?void 0:r.label}`}),()=>{var _;try{this.reactivityGraph.destroyNode(f),this.activeQueries.remove(a),r!=null&&r.stackInfo&&a.activeSubscriptions.delete(r.stackInfo),o.deref(),(_=r==null?void 0:r.onUnsubsubscribe)==null||_.call(r)}finally{s.end()}}}));p(this,"subscribeStream",(n,r)=>E_e(s=>X(this,function*(){const i=yield*_y.pipe(_h("NoSuchElementException",()=>Pt(void 0))),o=i?ss.setSpan(Xs.active(),i):Xs.active();yield*Rt(Re(()=>this.subscribe(n,{onUpdate:a=>s.single(a),otelContext:o,label:r==null?void 0:r.label})),a=>Re(()=>a()))})));p(this,"query",(n,r)=>{if(typeof n=="object"&&"query"in n&&"bindValues"in n)return this.sqliteDbWrapper.cachedSelect(n.query,oa(n.bindValues,n.query),{otelContext:r==null?void 0:r.otelContext});if(by(n)){const s=n[Vd];s._tag==="RowQuery"&&G1e({table:s.tableDef,id:s.id,explicitDefaultValues:s.explicitDefaultValues,otelContext:r==null?void 0:r.otelContext})(this.reactivityGraph.context);const i=n.asSql(),o=p2(n),a=this.sqliteDbWrapper.cachedSelect(i.query,i.bindValues,{otelContext:r==null?void 0:r.otelContext,queriedTables:new Set([n[Vd].tableDef.sqliteDef.name])});return Ld(o)(a)}else if(n._tag==="def"){const s=n.make(this.reactivityGraph.context),i=this.query(s.value,r);return s.deref(),i}else return n._tag==="signal-def"?n.make(this.reactivityGraph.context).value.get():n.run({otelContext:r==null?void 0:r.otelContext,debugRefreshReason:r==null?void 0:r.debugRefreshReason})});p(this,"setSignal",(n,r)=>{const s=n.make(this.reactivityGraph.context),i=typeof r=="function"?r(s.value.get()):r;s.value.set(i),s.rc>1&&s.deref()});p(this,"commit",(n,...r)=>{const{events:s,options:i}=this.getCommitArgs(n,r);for(const f of s)Pwe(f.args,this.clientSession.sessionId);if(s.length===0)return;const o=(i==null?void 0:i.skipRefresh)??!1;ss.getSpan(this.otel.commitsSpanContext).addEvent("commit");let c;return this.otel.tracer.startActiveSpan("LiveStore:commit",{attributes:{"livestore.eventsCount":s.length,"livestore.eventTags":s.map(f=>f.name),"livestore.commitLabel":i==null?void 0:i.label},links:i==null?void 0:i.spanLinks},(i==null?void 0:i.otelContext)??this.otel.commitsSpanContext,f=>{const d=ss.setSpan(Xs.active(),f);try{const{writeTables:g}=(()=>{try{const k=()=>this.syncProcessor.push(s,{otelContext:d});return s.length>1?this.sqliteDbWrapper.txn(k):k()}catch(k){throw console.error(k),f.setStatus({code:nl.ERROR,message:k.toString()}),k}finally{f.end()}})(),_=[];for(const k of g){const I=this.tableRefs[k];rN(I!==void 0,`No table ref found for ${k}`),_.push([I,null])}const b={_tag:"commit",events:s,writeTables:Array.from(g)};this.reactivityGraph.setRefs(_,{debugRefreshReason:b,otelContext:d,skipRefresh:o})}catch(g){throw console.error(g),f.setStatus({code:nl.ERROR,message:g.toString()}),g}finally{f.end(),c=yx(f)}return{durationMs:c}})});p(this,"events",n=>sN("store.events() is not yet implemented but planned soon"));p(this,"eventsStream",n=>sN("store.eventsStream() is not yet implemented but planned soon"));p(this,"manualRefresh",n=>{const{label:r}=n??{};this.otel.tracer.startActiveSpan("LiveStore:manualRefresh",{attributes:{"livestore.manualRefreshLabel":r}},this.otel.commitsSpanContext,s=>{const i=ss.setSpan(Xs.active(),s);this.reactivityGraph.runDeferredEffects({otelContext:i}),s.end()})});p(this,"shutdown",async n=>{await this.clientSession.shutdown(n??gu(U0.make({reason:"manual"}))).pipe(this.runEffectFork,$l,Kw)});p(this,"_dev",{downloadDb:(n="local")=>{X(this,function*(){const r=n==="local"?this.sqliteDbWrapper.export():yield*this.clientSession.leaderThread.export;Nx(r,`livestore-${Date.now()}.db`)}).pipe(this.runEffectFork)},downloadEventlogDb:()=>{X(this,function*(){const n=yield*this.clientSession.leaderThread.getEventlogData;Nx(n,`livestore-eventlog-${Date.now()}.db`)}).pipe(this.runEffectFork)},hardReset:(n="all-data")=>{X(this,function*(){const r=this.clientSession.clientId;yield*this.clientSession.leaderThread.sendDevtoolsMessage(Nb.Request.make({liveStoreVersion:Hr,mode:n,requestId:br(),clientId:r}))}).pipe(this.runEffectFork)},overrideNetworkStatus:n=>{const r=this.clientSession.clientId;this.clientSession.leaderThread.sendDevtoolsMessage(Fb.Request.make({clientId:r,closeLatch:n==="offline",liveStoreVersion:Hr,requestId:br()})).pipe(this.runEffectFork)},syncStates:()=>{X(this,function*(){const n=yield*this.syncProcessor.syncState;console.log("Session sync state:",n.toJSON());const r=yield*this.clientSession.leaderThread.getSyncState;console.log("Leader sync state:",r.toJSON())}).pipe(this.runEffectFork)},version:Hr,otel:{rootSpanContext:()=>{var n;return(n=ss.getSpan(this.otel.rootSpanContext))==null?void 0:n.spanContext()}}});p(this,"toJSON",()=>({_tag:"livestore.Store",reactivityGraph:this.reactivityGraph.getSnapshot({includeResults:!0})}));p(this,"runEffectFork",n=>n.pipe(gs(this.effectContext.lifetimeScope),st,sb(this.effectContext.runtime)));p(this,"getCommitArgs",(n,r)=>{let s,i;return typeof n=="function"?s=n(o=>s.push(o)):(n==null?void 0:n.label)!==void 0||(n==null?void 0:n.skipRefresh)!==void 0||(n==null?void 0:n.otelContext)!==void 0||(n==null?void 0:n.spanLinks)!==void 0?(i=n,s=r):n===void 0?s=[]:s=[n,...r],{events:s,options:i}});this.storeId=a,this.sqliteDbWrapper=new Y1e({otel:s,db:n.sqliteDb}),this.clientSession=n,this.schema=r,this.context=i,this.effectContext=c;const _=K1e(),b=s.tracer.startSpan("LiveStore:sync",{},s.rootSpanContext);this.syncProcessor=zwe({schema:r,clientSession:n,runtime:c.runtime,materializeEvent:(w,{otelContext:$,withChangeset:P,materializerHashLeader:O})=>{const{eventDef:A,materializer:z}=Di(r,w.name),D=y2({eventDef:A,materializer:z,dbState:this.sqliteDbWrapper,event:{decoded:w,encoded:void 0}}),W=ko()?oe(jH(D)):re();O._tag==="Some"&&W._tag==="Some"&&O.value!==W.value&&this.shutdown(gu(un.make({cause:`Materializer hash mismatch detected for event "${w.name}".`,note:"Please make sure your event materializer is a pure function without side effects."})));const le=new Set,M=()=>{for(const{statementSql:Q,bindValues:L,writeTables:G=this.sqliteDbWrapper.getTablesUsed(Q)}of D){try{this.sqliteDbWrapper.cachedExecute(Q,L,{otelContext:$,writeTables:G})}catch(V){throw un.make({cause:V,note:`Error executing materializer for event "${w.name}".
252
+ Statement: ${Q}
253
+ Bind values: ${JSON.stringify(L)}`})}for(const V of G)le.add(V)}};let U={_tag:"unset"};return P===!0?U=this.sqliteDbWrapper.withChangeset(M).changeset:M(),{writeTables:le,sessionChangeset:U,materializerHash:W}},rollback:w=>{this.sqliteDbWrapper.rollback(w)},refreshTables:w=>{const $=[];for(const P of w){const O=this.tableRefs[P];rN(O!==void 0,`No table ref found for ${P}`),$.push([O,null])}_.setRefs($)},span:b,params:{leaderPushBatchSize:f.leaderPushBatchSize},confirmUnsavedChanges:d}),this.__eventSchema=BH(r),this.tableRefs={},this.activeQueries=new eEe;const k=s.tracer.startSpan("LiveStore:commits",{},s.rootSpanContext),I=ss.setSpan(Xs.active(),k),E=s.tracer.startSpan("LiveStore:queries",{},s.rootSpanContext),y=ss.setSpan(Xs.active(),E);this.reactivityGraph=_,this.reactivityGraph.context={store:this,defRcMap:new Map,reactivityGraph:new WeakRef(_),otelTracer:s.tracer,rootOtelContext:y,effectsWrapper:o},this.otel={tracer:s.tracer,rootSpanContext:s.rootSpanContext,commitsSpanContext:I,queriesSpanContext:y};const m=new Set(g?this.schema.state.sqlite.tables.keys():Array.from(this.schema.state.sqlite.tables.keys()).filter(w=>!MH(w))),v=new Map(Array.from(this.reactivityGraph.atoms.values()).filter(w=>{var $;return w._tag==="ref"&&(($=w.label)==null?void 0:$.startsWith("tableRef:"))===!0}).map(w=>[w.label.slice(9),w]));for(const w of m)this.tableRefs[w]=v.get(w)??this.reactivityGraph.makeRef(null,{equal:()=>!1,label:`tableRef:${w}`,meta:{liveStoreRefType:"table"}});this.boot=X(this,function*(){yield*pr(()=>Re(()=>{for(const w of Object.values(this.tableRefs))for(const $ of w.super)this.reactivityGraph.removeEdge($,w);b.end(),k.end(),E.end()})),yield*this.syncProcessor.boot})}get sessionId(){return this.clientSession.sessionId}get clientId(){return this.clientSession.clientId}}const o3=globalThis.requestAnimationFrame===void 0?e=>setTimeout(e,1e3):globalThis.requestAnimationFrame,sEe=globalThis.cancelAnimationFrame===void 0?e=>clearTimeout(e):globalThis.cancelAnimationFrame,iEe=({storeDevtoolsChannel:e,store:t})=>X(function*(){const n=new Map,r=new Map,s=new Map,i=new Map,{clientId:o,sessionId:a}=t.clientSession;yield*pr(()=>Re(()=>{for(const g of n.values())g();for(const g of r.values())g();for(const g of s.values())g();for(const g of i.values())g()}));const c=new Set,f=g=>e.send(g).pipe(st,Po),d=g=>{var k,I,E,y;if(g.clientId!==o||g.sessionId!==a||g._tag==="LSD.ClientSession.Disconnect")return;const _=g.requestId;if(c.has(_))return;c.add(_);const b=globalThis.requestIdleCallback??(m=>m());switch(g._tag){case"LSD.ClientSession.ReactivityGraphSubscribe":{const m=g.includeResults,{subscriptionId:v}=g,w=()=>b(()=>f(i5.make({reactivityGraph:t.reactivityGraph.getSnapshot({includeResults:m}),requestId:br(10),clientId:o,sessionId:a,liveStoreVersion:Hr,subscriptionId:v})),{timeout:500});w();const $=iN(w,20);n.set(v,t.reactivityGraph.subscribeToRefresh($));break}case"LSD.ClientSession.DebugInfoReq":{f(e5.make({debugInfo:t.sqliteDbWrapper.debugInfo,requestId:_,clientId:o,sessionId:a,liveStoreVersion:Hr}));break}case"LSD.ClientSession.DebugInfoHistorySubscribe":{const{subscriptionId:m}=g,v=[];let w=!1,$;const P=()=>{v.push(t.sqliteDbWrapper.debugInfo),t.sqliteDbWrapper.debugInfo=Y5(),v.length>10&&(f(t5.make({debugInfoHistory:v,requestId:br(10),clientId:o,sessionId:a,liveStoreVersion:Hr,subscriptionId:m})),v.length=0),w===!1&&($=o3(P))};$=o3(P);const O=()=>{w=!0,$!==void 0&&(sEe($),$=void 0)};s.set(m,O);break}case"LSD.ClientSession.DebugInfoHistoryUnsubscribe":{const{subscriptionId:m}=g;(k=s.get(m))==null||k(),s.delete(m);break}case"LSD.ClientSession.DebugInfoResetReq":{t.sqliteDbWrapper.debugInfo.slowQueries.clear(),f(n5.make({requestId:_,clientId:o,sessionId:a,liveStoreVersion:Hr}));break}case"LSD.ClientSession.DebugInfoRerunQueryReq":{const{queryStr:m,bindValues:v,queriedTables:w}=g;t.sqliteDbWrapper.cachedSelect(m,v,{queriedTables:w,skipCache:!0}),f(r5.make({requestId:_,clientId:o,sessionId:a,liveStoreVersion:Hr}));break}case"LSD.ClientSession.ReactivityGraphUnsubscribe":{const{subscriptionId:m}=g;(I=n.get(m))==null||I(),n.delete(m);break}case"LSD.ClientSession.LiveQueriesSubscribe":{const{subscriptionId:m}=g,v=()=>b(()=>f(o5.make({liveQueries:[...t.activeQueries].map($=>({_tag:$._tag,id:$.id,label:$.label,hash:$.def.hash,runs:$.runs,executionTimes:$.executionTimes.map(P=>Number(P.toString().slice(0,5))),lastestResult:$.results$.previousResult===R2?"SYMBOL_NOT_REFRESHED_YET":$.results$.previousResult,activeSubscriptions:Array.from($.activeSubscriptions)})),requestId:br(10),liveStoreVersion:Hr,clientId:o,sessionId:a,subscriptionId:m})),{timeout:500});v();const w=iN(v,20);r.set(m,t.reactivityGraph.subscribeToRefresh(w));break}case"LSD.ClientSession.LiveQueriesUnsubscribe":{const{subscriptionId:m}=g;(E=r.get(m))==null||E(),r.delete(m);break}case"LSD.ClientSession.SyncHeadSubscribe":{const{subscriptionId:m}=g,v=w=>f(s5.make({local:w.localHead,upstream:w.upstreamHead,requestId:br(10),clientId:o,sessionId:a,liveStoreVersion:Hr,subscriptionId:m}));v(t.syncProcessor.syncState.pipe(ur)),i.set(m,t.syncProcessor.syncState.changes.pipe(Un(w=>v(w)),Sn,Jt,st,wue));break}case"LSD.ClientSession.SyncHeadUnsubscribe":{const{subscriptionId:m}=g;(y=i.get(m))==null||y(),i.delete(m);break}case"LSD.ClientSession.Ping":{f(a5.make({requestId:_,clientId:o,sessionId:a,liveStoreVersion:Hr}));break}default:console.warn("[LSD.ClientSession] Unknown message",g)}};yield*e.listen.pipe(Dl(),Y_e(g=>d(g)),Sn,Qe("LSD.devtools.onMessage"))}).pipe(un.mapToUnexpectedError,Qe("LSD.devtools.connectStoreToDevtools")),oEe={leaderPushBatchSize:100},cv=class cv extends Vv("@livestore/livestore/effect/LiveStoreContextRunning")(){};p(cv,"fromDeferred",X(function*(){const n=yield*yield*aEe;return vh(cv,n)}).pipe(dU));let Dx=cv;class aEe extends Vv("@livestore/livestore/effect/DeferredStoreContext")(){}const lEe=async({signal:e,otelOptions:t,...n})=>X(function*(){const r=yield*ty(),s=yield*To();return e!==void 0&&e.addEventListener("abort",()=>{Ln(r,_s).pipe(st,sb(s))}),yield*cEe({...n}).pipe(ey(r))}).pipe(Qe("createStore",{attributes:{storeId:n.storeId,disableDevtools:n.disableDevtools}}),Cbe({parentSpanContext:t==null?void 0:t.rootSpanContext,otelTracer:t==null?void 0:t.tracer}),st,yl({thread:"window"}),Hn(nSe("window")),Ome(Z$),Kw),cEe=({schema:e,adapter:t,storeId:n,context:r={},boot:s,batchUpdates:i,disableDevtools:o,onBootStatus:a,shutdownDeferred:c,params:f,debug:d,confirmUnsavedChanges:g=!0,syncPayload:_})=>X(function*(){const b=yield*ty();yield*uEe(n),yield*pr(I=>Ln(b,I));const k=(d==null?void 0:d.instanceId)??br(10);return yield*X(function*(){const I=yield*_y.pipe(os),E=ss.setSpan(Xs.active(),I),y=yield*Y8,m=yield*dr().pipe(Rt(In));yield*Ol(m).pipe(f0e(z=>a==null?void 0:a(z)),kr(z=>z.stage==="done"?In(m):Le),Nd,st,Dt);const v=yield*rt(),w=z=>X(function*(){const D=yield*v;yield*iEe({storeDevtoolsChannel:z,store:D})}),$=yield*To(),P=z=>X(function*(){yield*Ln(b,jn(z)).pipe(u0e({label:"@livestore/livestore:shutdown",duration:500}),Vw(1e3),_h("TimeoutException",()=>Dd("@livestore/livestore:shutdown: Timed out after 1 second"))),c&&(yield*Kf(c,z)),yield*ni("LiveStore shutdown complete")}).pipe(Qe("@livestore/livestore:shutdown"),Hn($),st,Po,$l),O=yield*t({schema:e,storeId:n,devtoolsEnabled:a3(o),bootStatusQueue:m,shutdown:P,connectDevtoolsToStore:w,debugInstanceId:k,syncPayload:_}).pipe(t2("livestore:makeAdapter"),Qe("createStore:makeAdapter"));js&&O.leaderThread.initialState.migrationsReport.migrations.length>0&&(yield*ni("[@livestore/livestore:createStore] migrationsReport",...O.leaderThread.initialState.migrationsReport.migrations.map(z=>z.hashes.actual===void 0?`Table '${z.tableName}' doesn't exist yet. Creating table...`:`Schema hash mismatch for table '${z.tableName}' (DB: ${z.hashes.actual}, expected: ${z.hashes.expected}), migrating table...`)));const A=new rEe({clientSession:O,schema:e,context:r,otelOptions:{tracer:y,rootSpanContext:E},effectContext:{lifetimeScope:b,runtime:$},__runningInDevtools:a3(o)===!1,confirmUnsavedChanges:g,batchUpdates:z=>z(),storeId:n,params:{leaderPushBatchSize:(f==null?void 0:f.leaderPushBatchSize)??oEe.leaderPushBatchSize}});return yield*A.boot,s!==void 0&&(yield*gp(()=>s(A,{migrationsReport:O.leaderThread.initialState.migrationsReport,parentSpan:I})).pipe(un.mapToUnexpectedError,Hn(vh(Dx,{stage:"running",store:A})),Qe("createStore:boot"))),yield*sue(),i!==void 0&&(A.reactivityGraph.context.effectsWrapper=i),yield*jt(v,A),A}).pipe(Qe("createStore",{attributes:{debugInstanceId:k,storeId:n}}),yl({debugInstanceId:k,storeId:n}),js?Wve(I=>console.createTask(I)):Ce,ey(b))}),uEe=e=>X(function*(){if(!/^[a-zA-Z0-9_-]+$/.test(e))return yield*un.make({cause:`Invalid storeId: ${e}. Only alphanumeric characters, underscores, and hyphens are allowed.`,payload:{storeId:e}})}),a3=e=>e===!0||e===!1?!e:ko()===!0,X5=Yl({name:"logs",columns:{id:jr({primaryKey:!0}),numeric_id:AN({}),request_id:jr({}),timestamp:jr({}),method:jr({}),url:jr({}),status_code:AN({}),model:jr({nullable:!0}),provider:jr({nullable:!0}),profile:jr({nullable:!0}),summary:jr({nullable:!0})},indexes:[{name:"logs_timestamp",columns:["timestamp"]},{name:"logs_status",columns:["status_code"]},{name:"logs_model",columns:["model"]}]}),Z5=Yl({name:"blobs",columns:{key:jr({primaryKey:!0}),log_id:jr({}),kind:jr({}),etag:jr({nullable:!0}),body:jr({nullable:!0}),updated_at:jr({})}}),X0=g2({name:"logs/upserted",schema:ke({id:Y,numeric_id:it,request_id:Y,timestamp:Y,method:Y,url:Y,status_code:it,model:tl(Y),provider:tl(Y),profile:tl(Y),summary:tl(Y)})}),Z0=g2({name:"blobs/cached",schema:ke({key:Y,log_id:Y,kind:Y,etag:tl(Y),body:tl(Y),updated_at:Y})}),fEe=Owe({tables:[X5,Z5],materializers:{[X0.name]:dx(X0,e=>({sql:`
254
+ INSERT OR REPLACE INTO logs (
255
+ id,
256
+ numeric_id,
257
+ request_id,
258
+ timestamp,
259
+ method,
260
+ url,
261
+ status_code,
262
+ model,
263
+ provider,
264
+ profile,
265
+ summary
266
+ ) VALUES (
267
+ $id,
268
+ $numeric_id,
269
+ $request_id,
270
+ $timestamp,
271
+ $method,
272
+ $url,
273
+ $status_code,
274
+ $model,
275
+ $provider,
276
+ $profile,
277
+ $summary
278
+ )
279
+ `,bindValues:e})),[Z0.name]:dx(Z0,e=>({sql:`
280
+ INSERT OR REPLACE INTO blobs (
281
+ key,
282
+ log_id,
283
+ kind,
284
+ etag,
285
+ body,
286
+ updated_at
287
+ ) VALUES (
288
+ $key,
289
+ $log_id,
290
+ $kind,
291
+ $etag,
292
+ $body,
293
+ $updated_at
294
+ )
295
+ `,bindValues:e}))}}),dEe=Iwe({state:fEe,events:[X0,Z0]}),hEe={logs:X5,blobs:Z5},eB={logUpserted:X0,blobCached:Z0};async function pEe(){const e=q1e();return lEe({schema:dEe,adapter:e,storeId:"ulx-logs-web",disableDevtools:!0})}const gEe={}.VITE_API_URL??window.location.origin;async function l3(e,t={}){const n=t.batchSize??200;let r=mEe(e),s=0;for(;;){const i=new URLSearchParams;r.timestamp&&i.set("timestamp",r.timestamp),r.id!==void 0&&i.set("id",String(r.id)),i.set("limit",String(n));const o=await fetch(`${gEe}/api/livestore/pull?${i.toString()}`);if(!o.ok)throw new Error(`LiveStore pull failed (${o.status})`);const a=await o.json();if(!a.items.length||(e.commit({skipRefresh:!0},...a.items.map(c=>eB.logUpserted(c))),e.manualRefresh({label:"sync-logs"}),r={timestamp:a.items[a.items.length-1].timestamp,id:a.items[a.items.length-1].numeric_id},s+=a.items.length,a.items.length<n))break}return s}function mEe(e){const n=e.query({query:`
296
+ SELECT timestamp, numeric_id FROM logs
297
+ ORDER BY timestamp DESC, numeric_id DESC
298
+ LIMIT 1
299
+ `,bindValues:{}})[0];return n?{timestamp:n.timestamp,id:n.numeric_id}:{}}const yEe={}.VITE_API_URL??"";async function _Ee(e,t,n){const r=`${t}-${n}`,s=e.query({query:"SELECT etag, body FROM blobs WHERE key = $key LIMIT 1",bindValues:{key:r}})[0],i={};s!=null&&s.etag&&(i["If-None-Match"]=s.etag);const o=await fetch(`${yEe}/api/logs/${t}/blobs/${n}`,{headers:i});if(o.status===304&&s)return s.body??"";if(!o.ok)throw new Error(`Blob fetch failed (${o.status})`);const a=await o.text(),c=o.headers.get("etag")??null;return e.commit(eB.blobCached({key:r,log_id:String(t),kind:n,etag:c,body:a,updated_at:new Date().toISOString()})),a}const SEe={}.VITE_API_URL??window.location.origin;async function vEe(e,t={}){var s;const n=new URLSearchParams;n.set("q",e),t.limit&&n.set("limit",String(t.limit)),(s=t.kinds)!=null&&s.length&&n.set("kinds",t.kinds.join(","));const r=await fetch(`${SEe}/api/logs/search?${n.toString()}`,{signal:t.signal});if(!r.ok)throw new Error(`Blob search failed (${r.status})`);return await r.json()}const wEe=pc.lazy(()=>NK(()=>import("./JSONViewer-516863bb.js"),[]));function c3(e){if(!e)return null;try{return JSON.parse(e)}catch{return e}}function bEe(e){const t=e.match(/(?:[^\s"]+|"[^"]*")+/g)||[],n=[];for(const r of t){const s=r.replace(/^"(.*)"$/,"$1").trim();s&&(/^(and|or|not)$/i.test(s)||/^\w+:.+/.test(s)||n.push(r))}return n.join(" ")}function EEe({status:e}){const t=e>=200&&e<300,n=e>=300&&e<400;return te.jsx("span",{className:`badge ${t?"badge-success":n?"badge-warning":"badge-error"}`,title:`HTTP ${e}`,children:e})}function kEe({method:e}){return te.jsx("span",{className:"method-pill",children:e})}const CEe=pc.memo(function({log:t,expanded:n,activeTab:r,onToggle:s,onTabChange:i,blobBody:o,ensureBlob:a,loadingBlob:c}){const f=t.summary?c3(t.summary):null,d=f&&typeof f=="object"&&"preview"in f?f.preview:void 0,g=f&&typeof f=="object"&&"finish_reason"in f?f.finish_reason:void 0,_=[{id:"request",label:"Request"},{id:"response",label:"Response"},{id:"provider-request",label:"Provider Request"},{id:"provider-response",label:"Provider Response"}];return ve.useEffect(()=>{n&&a(t.id,r)},[n,r,t.id]),te.jsxs("div",{className:`log-card ${n?"expanded":""}`,children:[te.jsxs("div",{className:"log-card-header",onClick:()=>s(t.id),children:[te.jsxs("div",{className:"log-card-meta",children:[te.jsx(kEe,{method:t.method}),te.jsx("span",{className:"log-url",children:t.url}),te.jsx(EEe,{status:t.status_code})]}),te.jsxs("div",{className:"log-card-details",children:[te.jsx("span",{children:new Date(t.timestamp).toLocaleString()}),te.jsxs("span",{className:"muted",children:["Model: ",t.model??"-"]}),te.jsxs("span",{className:"muted",children:["Provider: ",t.provider??"-"]}),g&&te.jsxs("span",{className:"muted",children:["Finish: ",g]})]}),d&&te.jsx("div",{className:"log-preview",children:d})]}),n&&te.jsxs("div",{className:"log-card-body",children:[te.jsx("div",{className:"tabs",children:_.map(b=>te.jsx("button",{className:`tab-btn ${r===b.id?"active":""}`,onClick:k=>{k.stopPropagation(),i(t.id,b.id),a(t.id,b.id)},children:b.label},b.id))}),te.jsx("div",{className:"tab-content",children:te.jsxs(ve.Suspense,{fallback:te.jsx("div",{className:"skeleton",children:"Loading viewer…"}),children:[c&&te.jsx("div",{className:"skeleton",children:"Fetching blob…"}),!c&&te.jsx(wEe,{data:c3(o)})]})})]})]})},(e,t)=>e.expanded===t.expanded&&e.activeTab===t.activeTab&&e.blobBody===t.blobBody&&e.loadingBlob===t.loadingBlob&&e.log.id===t.log.id&&e.log.timestamp===t.log.timestamp&&e.log.status_code===t.log.status_code&&e.log.method===t.log.method&&e.log.url===t.log.url);function xEe(){const{theme:e,setTheme:t,resolvedTheme:n}=fg(),r=()=>{t(e==="light"?"dark":e==="dark"?"system":"light")},s=()=>e==="system"?te.jsx(pG,{size:16}):n==="dark"?te.jsx(cG,{size:16}):te.jsx(mG,{size:16});return te.jsxs("button",{className:"btn theme-toggle",onClick:r,title:`Current: ${e} (${n})
300
+ Click to cycle theme`,children:[te.jsx("span",{className:"theme-icon",children:s()}),te.jsx("span",{className:"theme-text",children:e})]})}function REe(){const[e,t]=ve.useState(null),[n,r]=ve.useState([]),[s,i]=ve.useState(null),[o,a]=ve.useState({}),[c,f]=ve.useState({}),[d,g]=ve.useState({}),[_,b]=ve.useState(""),[k,I]=ve.useState(""),[E,y]=ve.useState(!0),[m,v]=ve.useState(""),[w,$]=ve.useState(""),[P,O]=ve.useState(""),[A,z]=ve.useState(null),[D,W]=ve.useState(!1),[le,M]=ve.useState(null),U=ve.useRef(!1),Q=ve.useRef(0),L=ve.useRef(null),{theme:G,initTheme:V}=fg();ve.useEffect(()=>{V()},[V]),ve.useEffect(()=>{const ue=setTimeout(()=>{I(_)},300);return()=>clearTimeout(ue)},[_]),ve.useEffect(()=>{const ue=window.matchMedia("(prefers-color-scheme: dark)"),he=()=>{G==="system"&&V()};return ue.addEventListener("change",he),()=>ue.removeEventListener("change",he)},[G,V]);const J=ve.useCallback(ue=>{const he={},at=[],lt=ue.match(/(?:[^\s"]+|"[^"]*")+/g)||[];for(const De of lt){const Ke=De.replace(/^"(.*)"$/,"$1");if(/^(and|or|not)$/i.test(Ke))continue;const Se=Ke.match(/^(\w+):(.+)$/);if(Se){const[,mt,Pa]=Se;he[mt]=Pa}else at.push(Ke)}return{terms:he,text:at.join(" "),textParts:at}},[]);ve.useEffect(()=>{const ue=he=>{var at,lt;if((he.ctrlKey||he.metaKey)&&he.key==="k"){he.preventDefault(),(at=L.current)==null||at.focus();return}if(he.key==="Escape"&&document.activeElement===L.current){_?(he.preventDefault(),b("")):(lt=L.current)==null||lt.blur();return}if((he.ctrlKey||he.metaKey)&&he.shiftKey&&he.key==="T"){he.preventDefault();const{setTheme:De,theme:Ke}=fg.getState();De(Ke==="light"?"dark":Ke==="dark"?"system":"light");return}if((he.ctrlKey||he.metaKey)&&he.key==="r"){he.preventDefault(),y(De=>!De);return}};return document.addEventListener("keydown",ue),()=>document.removeEventListener("keydown",ue)},[_]);const ee=ve.useCallback(async()=>{if(!(!e||U.current)){U.current=!0;try{await l3(e,{batchSize:200})}finally{U.current=!1}}},[e]);ve.useEffect(()=>{let ue=!1;return pEe().then(he=>{ue||(t(he),!U.current&&(U.current=!0,l3(he,{batchSize:200}).catch(at=>{console.warn("Initial LiveStore sync failed; will retry",at)}).finally(()=>{U.current=!1})))}),()=>{ue=!0}},[]),ve.useEffect(()=>{if(!e)return;const ue=()=>{var lt;if(Kn.current){const De=Kn.current.querySelector(".log-card.expanded");if(De){const Ke=(lt=De.closest("[data-log-id]"))==null?void 0:lt.getAttribute("data-log-id");if(Ke){const Se=De.getBoundingClientRect(),mt=Kn.current.getBoundingClientRect();mi.current={id:Ke,offset:Se.top-mt.top}}}}const at=e.query(hEe.logs.orderBy([{col:"timestamp",direction:"desc"},{col:"numeric_id",direction:"desc"}]));r([...at])};ue();const he=setInterval(ue,1e3);return()=>clearInterval(he)},[e]),ve.useEffect(()=>{if(!e)return;let ue=!1,he=null,at=0;const lt=2500,De=3e4,Ke=()=>Math.min(De,lt*2**at),Se=async()=>{if(!ue)try{await ee(),at=0}catch(mt){at=Math.min(10,at+1),console.warn("LiveStore sync failed; retrying",mt)}finally{!ue&&E&&(he=setTimeout(Se,Ke()))}};return E&&Se(),()=>{ue=!0,he&&clearTimeout(he)}},[e,E,ee]);const de=ve.useMemo(()=>bEe(k),[k]);ve.useEffect(()=>{const ue=Q.current+1;if(Q.current=ue,!de){z(null),W(!1),M(null);return}z(null),M(null);const he=new AbortController,at=setTimeout(()=>{W(!0),vEe(de,{signal:he.signal,limit:200}).then(lt=>{Q.current===ue&&z({query:de,ids:lt.ids.map(String),truncated:lt.truncated,engine:lt.engine})}).catch(lt=>{Q.current===ue&&(he.signal.aborted||(M(lt instanceof Error?lt.message:String(lt)),z({query:de,ids:[],truncated:!1,engine:"rg"})))}).finally(()=>{Q.current===ue&&W(!1)})},250);return()=>{he.abort(),clearTimeout(at)}},[de]);const Te=async(ue,he)=>{if(!e)return;const at=`${ue}-${he}`;if(c[at])return;const lt=e.query({query:"SELECT body FROM blobs WHERE key = $key LIMIT 1",bindValues:{key:at}})[0];if(lt!=null&&lt.body){f(De=>({...De,[at]:lt.body??""}));return}g(De=>({...De,[at]:!0}));try{const De=await _Ee(e,ue,he);f(Ke=>({...Ke,[at]:De}))}finally{g(De=>({...De,[at]:!1}))}},dn=ve.useMemo(()=>{const ue=new Set(n.map(he=>he.model).filter(Boolean));return Array.from(ue)},[n]),ln=ve.useMemo(()=>{const ue=new Set(n.map(he=>he.provider).filter(Boolean));return Array.from(ue)},[n]),ir=ve.useMemo(()=>{let ue=n;const{terms:he,textParts:at}=J(k),lt=de&&(A==null?void 0:A.query)===de?new Set(A.ids):null;if(at.length){const De=at.map(Ke=>Ke.toLowerCase());ue=ue.filter(Ke=>{const Se=lt?lt.has(Ke.id):!1;return De.some(Pa=>[Ke.request_id,Ke.url,Ke.method,Ke.model??"",Ke.provider??"",Ke.summary??""].filter(Boolean).some(Ao=>String(Ao).toLowerCase().includes(Pa)))||Se})}if(he.status){const De=he.status.match(/^(\d{3})$/);if(De){const Ke=parseInt(De[1]);ue=ue.filter(Se=>Se.status_code===Ke)}else he.status.includes("2")?ue=ue.filter(Ke=>Ke.status_code>=200&&Ke.status_code<300):(he.status.includes("4")||he.status.includes("5"))&&(ue=ue.filter(Ke=>Ke.status_code>=400))}if(he.method&&(ue=ue.filter(De=>De.method.toLowerCase()===he.method.toLowerCase())),he.model&&(ue=ue.filter(De=>{var Ke;return(Ke=De.model)==null?void 0:Ke.toLowerCase().includes(he.model.toLowerCase())})),he.provider&&(ue=ue.filter(De=>{var Ke;return(Ke=De.provider)==null?void 0:Ke.toLowerCase().includes(he.provider.toLowerCase())})),he.timestamp){const De=he.timestamp.match(/^([><])(\d{4}-\d{2}-\d{2})$/);if(De){const[,Ke,Se]=De,mt=new Date(Se);ue=ue.filter(Pa=>{const Ao=new Date(Pa.timestamp);return Ke===">"?Ao>mt:Ke==="<"?Ao<mt:!0})}}return m&&(ue=ue.filter(De=>De.model===m)),w&&(ue=ue.filter(De=>De.provider===w)),P==="success"?ue=ue.filter(De=>De.status_code>=200&&De.status_code<300):P==="error"&&(ue=ue.filter(De=>De.status_code>=400)),ue},[n,k,m,w,P,de,A,J]),Dn=ve.useMemo(()=>[{header:"ID",accessorKey:"numeric_id",cell:ue=>ue.getValue()},{header:"When",accessorKey:"timestamp",cell:ue=>new Date(String(ue.getValue())).toLocaleString()},{header:"URL",accessorKey:"url"},{header:"Model",accessorKey:"model"},{header:"Status",accessorKey:"status_code"}],[]),Wi=E9({data:ir,columns:Dn,getCoreRowModel:b9()}).getRowModel().rows,Kn=ve.useRef(null),mi=ve.useRef(null),$r=N9({count:Wi.length,getScrollElement:()=>Kn.current,estimateSize:ue=>{var he;return((he=Wi[ue])==null?void 0:he.original.id)===s?520:120},overscan:10,getItemKey:ue=>{var he;return(he=Wi[ue])==null?void 0:he.original.id}}),qb=$r.getVirtualItems();ve.useLayoutEffect(()=>{if(!mi.current||!Kn.current)return;const{id:ue,offset:he}=mi.current;mi.current=null;const at=Wi.findIndex(lt=>lt.original.id===ue);if(at!==-1){const lt=$r.getOffsetForIndex(at);Kn.current.scrollTop=(lt||0)-he}},[Wi,$r]);const xy=()=>{ee().catch(ue=>{console.warn("Manual LiveStore sync failed",ue)})},Ki=ve.useMemo(()=>{if(!_)return null;const{terms:ue,textParts:he}=J(_),at=Object.keys(ue).length>0,lt=he.length>0;return{total:n.length,filtered:ir.length,hasFieldSearch:at,hasTextSearch:lt,query:_,blobQuery:de}},[_,n.length,ir.length,de,J]);return te.jsxs("div",{className:"app",children:[te.jsxs("nav",{className:"navbar",children:[te.jsx("div",{className:"logo",children:"LLM Logs"}),te.jsxs("div",{className:"controls",children:[te.jsx(xEe,{}),te.jsx(IG,{ref:L,search:_,onSearchChange:b,selectedModel:m,onModelChange:v,selectedProvider:w,onProviderChange:$,selectedStatus:P,onStatusChange:O,models:dn,providers:ln}),te.jsx("button",{className:`btn ${E?"btn-primary":""}`,onClick:()=>y(ue=>!ue),title:`${E?"Disable":"Enable"} auto refresh (Ctrl+R)`,children:E?te.jsxs(te.Fragment,{children:[te.jsx(vO,{size:14,className:"icon-spin"})," Auto Refresh: On"]}):te.jsxs(te.Fragment,{children:[te.jsx(fG,{size:14})," Auto Refresh: Off"]})}),te.jsxs("button",{className:"btn",onClick:xy,title:"Manual refresh",children:[te.jsx(vO,{size:14})," Refresh now"]})]})]}),Ki&&te.jsxs("div",{className:"search-stats",children:[te.jsxs("span",{className:"search-stats-text",children:["Found ",Ki.filtered," of ",Ki.total," logs",Ki.hasFieldSearch&&" (field search)",Ki.hasTextSearch&&" (text search)"]}),Ki.blobQuery&&te.jsxs("span",{className:"search-stats-text muted",children:[D&&"Searching blobs…",!D&&le&&`Blob search: ${le}`,!D&&!le&&(A==null?void 0:A.engine)&&`Blob search: ${A.engine}${A.truncated?" (truncated)":""}`]})]}),te.jsx("div",{className:"table-container",ref:Kn,children:te.jsx("div",{style:{height:$r.getTotalSize(),position:"relative"},children:qb.map(ue=>{const he=Wi[ue.index];if(!he)return null;const at=s===he.original.id,lt=o[he.original.id]??"request";return te.jsx("div",{ref:De=>$r.measureElement(De),"data-log-id":he.original.id,"data-index":ue.index,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ue.start}px)`},children:te.jsx(CEe,{log:he.original,expanded:at,activeTab:lt,onToggle:De=>i(Ke=>Ke===De?null:De),onTabChange:(De,Ke)=>a(Se=>({...Se,[De]:Ke})),blobBody:c[`${he.original.id}-${lt}`],ensureBlob:Te,loadingBlob:!!d[`${he.original.id}-${lt}`]})},he.id)})})})]})}SE.createRoot(document.getElementById("root")).render(te.jsx(pc.StrictMode,{children:te.jsx(REe,{})}));export{pc as R,aW as g,te as j,ve as r,fg as u};