ignotum 0.0.18 → 0.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +73 -62
- package/dist/cli/Undici-C6Asbalt.mjs +30 -0
- package/dist/cli/Undici-C6Asbalt.mjs.map +1 -0
- package/dist/cli/bin.mjs +732 -24022
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/platform/_headers +1 -1
- package/dist/platform/_ignotum/v1.1/client.js +12 -0
- package/dist/runtime/{api-BnUKx9cj-D49Tf0rX.d.ts → api-BnUKx9cj-K-F-SOLs.d.ts} +4 -4
- package/dist/runtime/{api-C-tltz6s.js → api-CrrSjYL1.js} +2 -2
- package/dist/runtime/{api-C-tltz6s.js.map → api-CrrSjYL1.js.map} +1 -1
- package/dist/runtime/{bootstrap-DlNIfH-r.js → bootstrap-CLVnD5vS.js} +4 -4
- package/dist/runtime/bootstrap-CLVnD5vS.js.map +1 -0
- package/dist/runtime/{bootstrap-DjTwGJao-DBx5zdFI.d.ts → bootstrap-DjTwGJao-DPi768T4.d.ts} +3 -3
- package/dist/runtime/client.d.ts +9 -9
- package/dist/runtime/client.js +4 -4
- package/dist/runtime/id-BPFV3D3V.d.ts +1 -0
- package/dist/runtime/{id-7an3nxTu-DZJSM5xh.d.ts → id-D87q-n2D-CDMwTSUR.d.ts} +2 -2
- package/dist/runtime/{id-BrEnxY-r.js → id-rzjaCxeF.js} +11 -2
- package/dist/runtime/{id-BrEnxY-r.js.map → id-rzjaCxeF.js.map} +1 -1
- package/dist/runtime/{index-Biaw5vdF.d.ts → index-BWHInzfU.d.ts} +3 -3
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +1 -1
- package/dist/runtime/internal/bootstrap.d.ts +1 -1
- package/dist/runtime/internal/bootstrap.js +1 -1
- package/dist/runtime/internal/client.d.ts +1 -1
- package/dist/runtime/internal/client.js +4 -4
- package/dist/runtime/internal/client.js.map +1 -1
- package/dist/runtime/internal/host.d.ts +6 -6
- package/dist/runtime/internal/host.js +3 -3
- package/dist/runtime/internal/routes.d.ts +1 -1
- package/dist/runtime/internal/server.d.ts +1 -1
- package/dist/runtime/internal/server.js +1 -1
- package/dist/runtime/internal/types.d.ts +2 -2
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/pagination-BPFV3D3V.d.ts +1 -0
- package/dist/runtime/{pagination--f4kMKf6.js → pagination-CfEleffG.js} +3 -2
- package/dist/runtime/pagination-CfEleffG.js.map +1 -0
- package/dist/runtime/result-Bq32FA7g.d.ts +1 -0
- package/dist/runtime/{router-C1eC9yy5.js → router-CfNPtoVO.js} +109 -60
- package/dist/runtime/router-CfNPtoVO.js.map +1 -0
- package/dist/runtime/{schema-BSjepoNF.js → schema-JtFb4BbG.js} +3 -3
- package/dist/runtime/{schema-BSjepoNF.js.map → schema-JtFb4BbG.js.map} +1 -1
- package/dist/runtime/server.d.ts +5 -5
- package/dist/runtime/server.js +2 -2
- package/dist/runtime/{sync-By2hX5ev.d.ts → sync-BMmV8oYt.d.ts} +2 -2
- package/dist/runtime/{sync-BwgS19Xy.js → sync-DUfp7S5R.js} +2 -2
- package/dist/runtime/{sync-BwgS19Xy.js.map → sync-DUfp7S5R.js.map} +1 -1
- package/dist/runtime/{types-DeCCyqLU-CHx7KFtx.d.ts → types-BeT6F0Pg-DMvRDN0c.d.ts} +5 -5
- package/package.json +9 -8
- package/src/cli/app-configuration.ts +44 -5
- package/src/cli/auth-client.ts +3 -3
- package/src/cli/build/managed-server.ts +3 -2
- package/src/cli/build/server.ts +2 -2
- package/src/cli/command.ts +18 -11
- package/src/cli/control-client.ts +2 -2
- package/src/cli/deploy.ts +27 -2
- package/src/cli/dev.ts +1 -1
- package/src/cli/managed-dev-platform.ts +13 -4
- package/src/cli/module-boundaries.ts +1 -1
- package/src/cli/new-app.ts +35 -6
- package/src/cli/package-manager.ts +1 -1
- package/src/cli/route-static.ts +7 -2
- package/src/cli/typecheck.ts +66 -0
- package/src/cli/upload-journal.ts +3 -3
- package/src/dev-runtime/database.ts +1 -1
- package/src/dev-runtime/files.ts +1 -1
- package/src/dev-runtime/managed-functions.ts +3 -2
- package/src/dev-runtime/managed-sync.ts +114 -105
- package/src/dev-runtime/managed-websocket.ts +11 -7
- package/src/dev-runtime/migrations.ts +2 -2
- package/src/dev-runtime/sync.ts +3 -3
- package/dist/platform/_ignotum/v1.0/client.js +0 -12
- package/dist/runtime/bootstrap-DlNIfH-r.js.map +0 -1
- package/dist/runtime/id-BI08JkmR.d.ts +0 -1
- package/dist/runtime/pagination--f4kMKf6.js.map +0 -1
- package/dist/runtime/pagination-BI08JkmR.d.ts +0 -1
- package/dist/runtime/result-BkziOG1L.d.ts +0 -1
- package/dist/runtime/router-C1eC9yy5.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r},n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v={},y=[],b=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ee=Array.isArray;function x(e,t){for(var n in t)e[n]=t[n];return e}function te(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function S(e,t,r){var i,a,o,s={};for(o in t)o==`key`?i=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?n.call(arguments,2):r),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return ne(e,s,i,a,null)}function ne(e,t,n,a,o){var s={type:e,props:t,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++i,__i:-1,__u:0};return o==null&&r.vnode!=null&&r.vnode(s),s}function re(){return{current:null}}function ie(e){return e.children}function ae(e,t){this.props=e,this.context=t}function oe(e,t){if(t==null)return e.__?oe(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?oe(e):null}function se(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],a=[],o=x({},t);o.__v=t.__v+1,r.vnode&&r.vnode(o),ye(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??oe(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,xe(i,o,a),t.__e=t.__=null,o.__e!=n&&ce(o)}}function ce(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),ce(e)}function le(e){(!e.__d&&(e.__d=!0)&&o.push(e)&&!ue.__r++||s!=r.debounceRendering)&&((s=r.debounceRendering)||c)(ue)}function ue(){try{for(var e,t=1;o.length;)o.length>t&&o.sort(l),e=o.shift(),t=o.length,se(e)}finally{o.length=ue.__r=0}}function de(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||y,b=t.length;for(c=fe(n,t,_,c,b),d=0;d<b;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||v,p.__i=d,g=ye(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&we(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=pe(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function fe(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=ne(null,o,null,null,null):ee(o)?o=e.__k[a]=ne(ie,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=ne(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=he(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=oe(s)),Te(s,s));return r}function pe(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=pe(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=oe(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function me(e,t){return t||=[],e==null||typeof e==`boolean`||(ee(e)?e.some(function(e){me(e,t)}):t.push(e)),t}function he(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ge(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||b.test(t)?n:n+`px`}function _e(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ge(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ge(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(p,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[f]=r[f]:(n[f]=m,e.addEventListener(t,a?g:h,a)):e.removeEventListener(t,a?g:h,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function ve(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[d]==null)t[d]=m++;else if(t[d]<n[f])return;return n(r.event?r.event(t):t)}}}function ye(e,t,n,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,v,b,S,ne,re,se,ce,le,ue,fe=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=r.__b)&&d(t);n:if(typeof fe==`function`){f=s.length;try{if(b=t.props,S=fe.prototype&&fe.prototype.render,ne=(d=fe.contextType)&&i[d.__c],re=d?ne?ne.props.value:d.__:i,n.__c?v=(p=t.__c=n.__c).__=p.__E:(S?t.__c=p=new fe(b,re):(t.__c=p=new ae(b,re),p.constructor=fe,p.render=Ee),ne&&ne.sub(p),p.state||(p.state={}),p.__n=i,m=p.__d=!0,p.__h=[],p._sb=[]),S&&p.__s==null&&(p.__s=p.state),S&&fe.getDerivedStateFromProps!=null&&(p.__s==p.state&&(p.__s=x({},p.__s)),x(p.__s,fe.getDerivedStateFromProps(b,p.__s))),h=p.props,g=p.state,p.__v=t,m)S&&fe.getDerivedStateFromProps==null&&p.componentWillMount!=null&&p.componentWillMount(),S&&p.componentDidMount!=null&&p.__h.push(p.componentDidMount);else{if(S&&fe.getDerivedStateFromProps==null&&b!==h&&p.componentWillReceiveProps!=null&&p.componentWillReceiveProps(b,re),t.__v==n.__v||!p.__e&&p.shouldComponentUpdate!=null&&!1===p.shouldComponentUpdate(b,p.__s,re)){t.__v!=n.__v&&(p.props=b,p.state=p.__s,p.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),y.push.apply(p.__h,p._sb),p._sb=[],p.__h.length&&s.push(p),c=oe(n);break n}p.componentWillUpdate!=null&&p.componentWillUpdate(b,p.__s,re),S&&p.componentDidUpdate!=null&&p.__h.push(function(){p.componentDidUpdate(h,g,_)})}if(p.context=re,p.props=b,p.__P=e,p.__e=!1,se=r.__r,ce=0,S)p.state=p.__s,p.__d=!1,se&&se(t),d=p.render(p.props,p.state,p.context),y.push.apply(p.__h,p._sb),p._sb=[];else do p.__d=!1,se&&se(t),d=p.render(p.props,p.state,p.context),p.state=p.__s;while(p.__d&&++ce<25);p.state=p.__s,p.getChildContext!=null&&(i=x(x({},i),p.getChildContext())),S&&!m&&p.getSnapshotBeforeUpdate!=null&&(_=p.getSnapshotBeforeUpdate(h,g)),le=d!=null&&d.type===ie&&d.key==null?Se(d.props.children):d,c=de(e,ee(le)?le:[le],t,n,i,a,o,s,c,l,u),p.base=t.__e,t.__u&=-161,p.__h.length&&s.push(p),v&&(p.__E=p.__=null)}catch(e){if(s.length=f,t.__v=null,l||o!=null){if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(ue=o.length;ue--;)te(o[ue])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||be(t),r.__e(e,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=Ce(n.__e,t,n,i,a,o,s,l,u);return(d=r.diffed)&&d(t),128&t.__u?void 0:c}function be(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(be))}function xe(e,t,n){for(var i=0;i<n.length;i++)we(n[i],n[++i],n[++i]);r.__c&&r.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){r.__e(e,t.__v)}})}function Se(e){return typeof e!=`object`||!e||e.__b>0?e:ee(e)?e.map(Se):e.constructor===void 0?x({},e):null}function Ce(e,t,i,a,o,s,c,l,u){var d,f,p,m,h,g,_,y=i.props||v,b=t.props,x=t.type;if(x==`svg`?o=`http://www.w3.org/2000/svg`:x==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((h=s[d])&&`setAttribute`in h==!!x&&(x?h.localName==x:h.nodeType==3)){e=h,s[d]=null;break}}if(e==null){if(x==null)return document.createTextNode(b);e=document.createElementNS(o,x,b.is&&b),l&&=(r.__m&&r.__m(t,s),!1),s=null}if(x==null)y===b||l&&e.data==b||(e.data=b);else{if(s=x==`textarea`&&b.defaultValue!=null?null:s&&n.call(e.childNodes),!l&&s!=null)for(y={},d=0;d<e.attributes.length;d++)y[(h=e.attributes[d]).name]=h.value;for(d in y)h=y[d],d==`dangerouslySetInnerHTML`?p=h:d==`children`||d in b||d==`value`&&`defaultValue`in b||d==`checked`&&`defaultChecked`in b||_e(e,d,null,h,o);for(d in b)h=b[d],d==`children`?m=h:d==`dangerouslySetInnerHTML`?f=h:d==`value`?g=h:d==`checked`?_=h:l&&typeof h!=`function`||y[d]===h||_e(e,d,h,y[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),de(t.type==`template`?e.content:e,ee(m)?m:[m],t,i,a,x==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:i.__k&&oe(i,0),l,u),s!=null)for(d=s.length;d--;)te(s[d]);l&&x!=`textarea`||(d=`value`,x==`progress`&&g==null?e.removeAttribute(`value`):g!=null&&(g!==e[d]||x==`progress`&&!g||x==`option`&&g!=y[d])&&_e(e,d,g,y[d],o),d=`checked`,_!=null&&_!=e[d]&&_e(e,d,_,y[d],o))}return e}function we(e,t,n){try{if(typeof e==`function`){var i=typeof e.__u==`function`;i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(e){r.__e(e,n)}}function Te(e,t,n){var i,a;if(r.unmount&&r.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||we(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(e){r.__e(e,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(a=0;a<i.length;a++)i[a]&&Te(i[a],t,n||typeof e.type!=`function`);n||te(e.__e),e.__c=e.__=e.__e=void 0}function Ee(e,t,n){return this.constructor(e,n)}function De(e,t,i){var a,o,s,c;t==document&&(t=document.documentElement),r.__&&r.__(e,t),o=(a=typeof i==`function`)?null:i&&i.__k||t.__k,s=[],c=[],ye(t,e=(!a&&i||t).__k=S(ie,null,[e]),o||v,v,t.namespaceURI,!a&&i?[i]:o?null:t.firstChild?n.call(t.childNodes):null,s,!a&&i?i:o?o.__e:t.firstChild,a,c),xe(s,e,c),e.props.children=null}function Oe(e,t,r){var i,a,o,s,c=x({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?i=t[o]:o==`ref`?a=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?n.call(arguments,2):r),ne(e.type,c,i||e.key,a||e.ref,null)}function ke(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,le(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+_++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}n=y.slice,r={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},i=0,a=function(e){return e!=null&&e.constructor===void 0},ae.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state);typeof e==`function`&&(e=e(x({},n),this.props)),e&&x(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),le(this))},ae.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),le(this))},ae.prototype.render=ie,o=[],c=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,l=function(e,t){return e.__v.__b-t.__v.__b},ue.__r=0,u=Math.random().toString(8),d=`__d`+u,f=`__a`+u,p=/(PointerCapture)$|Capture$/i,m=0,h=ve(!1),g=ve(!0),_=0;var Ae,C,je,Me,Ne=0,Pe=[],w=r,Fe=w.__b,Ie=w.__r,Le=w.diffed,Re=w.__c,ze=w.unmount,Be=w.__;function Ve(e,t){w.__h&&w.__h(C,e,Ne||t),Ne=0;var n=C.__H||(C.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function He(e){return Ne=1,Ue(ot,e)}function Ue(e,t,n){var r=Ve(Ae++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):ot(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=C,!C.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};C.__f=!0;var a=C.shouldComponentUpdate,o=C.componentWillUpdate;C.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},C.shouldComponentUpdate=i}return r.__N||r.__}function We(e,t){var n=Ve(Ae++,3);!w.__s&&at(n.__H,t)&&(n.__=e,n.u=t,C.__H.__h.push(n))}function Ge(e,t){var n=Ve(Ae++,4);!w.__s&&at(n.__H,t)&&(n.__=e,n.u=t,C.__h.push(n))}function Ke(e){return Ne=5,Je(function(){return{current:e}},[])}function qe(e,t,n){Ne=6,Ge(function(){if(typeof e==`function`){var n=e(t());return function(){e(null),n&&typeof n==`function`&&n()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function Je(e,t){var n=Ve(Ae++,7);return at(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function Ye(e,t){return Ne=8,Je(function(){return e},t)}function Xe(e){var t=C.context[e.__c],n=Ve(Ae++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub(C)),t.props.value):e.__}function Ze(e,t){w.useDebugValue&&w.useDebugValue(t?t(e):e)}function Qe(e){var t=Ve(Ae++,10),n=He();return t.__=e,C.componentDidCatch||(C.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]}function $e(){var e=Ve(Ae++,11);if(!e.__){for(var t=C.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function et(){for(var e;e=Pe.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(rt),t.__h.some(it),t.__h=[]}catch(n){t.__h=[],w.__e(n,e.__v)}}}w.__b=function(e){C=null,Fe&&Fe(e)},w.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Be&&Be(e,t)},w.__r=function(e){Ie&&Ie(e),Ae=0;var t=(C=e.__c).__H;t&&(je===C?(t.__h=[],C.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(rt),t.__h.some(it),t.__h=[],Ae=0)),je=C},w.diffed=function(e){Le&&Le(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Pe.push(t)!==1&&Me===w.requestAnimationFrame||((Me=w.requestAnimationFrame)||nt)(et)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),je=C=null},w.__c=function(e,t){t.some(function(e){try{e.__h.some(rt),e.__h=e.__h.filter(function(e){return!e.__||it(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],w.__e(n,e.__v)}}),Re&&Re(e,t)},w.unmount=function(e){ze&&ze(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{rt(e)}catch(e){t=e}}),n.__H=void 0,t&&w.__e(t,n.__v))};var tt=typeof requestAnimationFrame==`function`;function nt(e){var t,n=function(){clearTimeout(r),tt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);tt&&(t=requestAnimationFrame(n))}function rt(e){var t=C,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),C=t}function it(e){var t=C;e.__c=e.__(),C=t}function at(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function ot(e,t){return typeof t==`function`?t(e):t}var st=(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 e=0,r=t.length;e<r;e++)n=t[e](n);return n}}},ct={pipe(){return st(this,arguments)}},lt=function(){function e(){}return e.prototype=ct,e}(),T=function(e,t){if(typeof e==`function`)return function(){return e(arguments)?t.apply(this,arguments):e=>t(e,...arguments)};switch(e){case 0:case 1:throw RangeError(`Invalid arity ${e}`);case 2:return function(e,n){return arguments.length>=2?t(e,n):function(n){return t(n,e)}};case 3:return function(e,n,r){return arguments.length>=3?t(e,n,r):function(r){return t(r,e,n)}};default:return function(){if(arguments.length>=e)return t.apply(this,arguments);let n=arguments;return function(e){return t(e,...n)}}}},E=e=>e,ut=e=>()=>e,dt=ut(!0),ft=ut(!1),pt=ut(void 0),mt=pt;function ht(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i}}function gt(e){let t=new WeakMap;return n=>{let r=t.get(n);if(r!==void 0)return r;let i=e(n);return t.set(n,i),i!==n&&t.set(i,i),i}}var _t=e=>{let t=new Set(Reflect.ownKeys(e));if(e.constructor===Object)return t;e instanceof Error&&t.delete(`stack`);let n=Object.getPrototypeOf(e),r=n;for(;r!==null&&r!==Object.prototype;){let e=Reflect.ownKeys(r);for(let n=0;n<e.length;n++)t.add(e[n]);r=Object.getPrototypeOf(r)}return t.has(`constructor`)&&typeof e.constructor==`function`&&n===e.constructor.prototype&&t.delete(`constructor`),t},vt=new WeakSet,yt=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),bt=0,xt=()=>{bt++};function St(e){return typeof e==`string`}function Ct(e){return typeof e==`number`}function wt(e){return typeof e==`boolean`}function Tt(e){return typeof e==`symbol`}function Et(e){return St(e)||Ct(e)||Tt(e)}function Dt(e){return typeof e==`function`}function Ot(e){return e===null}function kt(e){return e!=null}function At(e){return!0}function jt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Mt(e){return typeof e==`object`&&!!e||Dt(e)}var D=T(2,(e,t)=>Mt(e)&&t in e);function Nt(e){return e instanceof Error}function Pt(e){return e instanceof Date}var Ft=`~effect/Hash`,O=e=>{switch(typeof e){case`number`:return Vt(e);case`bigint`:return Ht(e.toString(10));case`string`:return Ht(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?Ht(`Invalid Date`):Ht(e.toISOString());if(e instanceof RegExp)return Ht(e.toString());{if(vt.has(e))return It(e);let t=Zt.get(e);if(t!==void 0)return t;if(Qt.has(e))return xt(),Ht(`[Circular]`);Qt.add(e);let n=bt,r;try{r=`~effect/Hash`in e?e[Ft]():typeof e==`function`?It(e):e instanceof DataView?Kt(yt(e)):Array.isArray(e)||ArrayBuffer.isView(e)?Kt(e):e instanceof Map?qt(e):e instanceof Set?Yt(e):Wt(e)}finally{Qt.delete(e)}return n===bt&&Zt.set(e,r),r}}return zt(Lt(Ht(String(e))))},It=e=>(Xt.has(e)||Xt.set(e,zt(Math.random()*4294967296|0)),Xt.get(e)),Lt=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),Rt=T(2,(e,t)=>Lt(Math.imul(e,2654435761)+Math.imul(t,2246822507))),zt=e=>e&3221225471|e>>>1&1073741824,Bt=new DataView(new ArrayBuffer(8)),Vt=e=>{let t=e|0;return t===e?zt(t):(Bt.setFloat64(0,e===e?e:NaN),zt(Rt(Bt.getInt32(0),Bt.getInt32(4))))},Ht=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return zt(t)},Ut=(e,t)=>{let n=12289;for(let r of t)n^=Rt(O(r),O(e[r]));return zt(n)},Wt=e=>Ut(e,_t(e)),Gt=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return zt(r)},Kt=e=>{let t=6151;for(let n of e)t=Rt(t,O(n));return zt(t)},qt=Gt(Ht(`Map`),([e,t])=>Rt(O(e),O(t))),Jt=Ht(`Set`),Yt=Gt(Jt,e=>Rt(Jt,O(e))),Xt=new WeakMap,Zt=new WeakMap,Qt=new WeakSet,$t=`~effect/Equal`;function en(){return arguments.length===1?e=>tn(e,arguments[0]):tn(arguments[0],arguments[1])}function tn(e,t){if(e===t)return!0;if(e==null||t==null)return!1;let n=typeof e;return n===typeof t?n===`number`&&e!==e&&t!==t?!0:n!==`object`&&n!==`function`||vt.has(e)||vt.has(t)?!1:nn(e,t):!1}function nn(e,t){let n=an.length;for(let r=n;r-->0;)if(an[r]===e&&on[r]===t)return!0;if(n)return rn(e,t);let r=sn.get(e);r||sn.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=rn(e,t)),i}function rn(e,t){an.push(e),on.push(t);try{return cn(e,t)}finally{an.pop(),on.pop()}}var an=[],on=[],sn=new WeakMap;function cn(e,t){if(O(e)!==O(t))return!1;if(e instanceof Date){if(!(t instanceof Date))return!1;let n=e.getTime(),r=t.getTime();return n===r||Number.isNaN(n)&&Number.isNaN(r)}if(e instanceof RegExp)return t instanceof RegExp&&e.toString()===t.toString();let n=hn(e);if(n!==hn(t)||typeof e==`function`&&!n)return!1;if(n)return e[$t](t);if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:ln(e,t);if(ArrayBuffer.isView(e)){let n=e instanceof DataView;return!ArrayBuffer.isView(t)||e.byteLength!==t.byteLength||n!==t instanceof DataView?!1:n?un(yt(e),yt(t)):un(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:fn(e,t,pn,mn):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:fn(e,t,O,tn):dn(e,t)}function ln(e,t){for(let n=0;n<e.length;n++)if(!tn(e[n],t[n]))return!1;return!0}function un(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function dn(e,t){let n=_t(e),r=_t(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!tn(e[i],t[i]))return!1;return!0}function fn(e,t,n,r){let i=new Map;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e])}outer:for(let t of e){let e=i.get(n(t));if(e){for(let n=0;n<e.length;n++)if(r(t,e[n])){e[n]=e[e.length-1],e.pop();continue outer}}return!1}return!0}var pn=e=>O(e[0]),mn=(e,t)=>tn(e[0],t[0])&&tn(e[1],t[1]),hn=e=>D(e,$t),gn=Symbol.for(`~effect/Redactable`),_n=e=>D(e,gn);function vn(e){return _n(e)?yn(e):e}function yn(e){return e[gn](globalThis[`~effect/Fiber/currentFiber`]?.context??Sn)}var bn=`~effect/Fiber/currentFiber`,xn=new Map,Sn={"~effect/Context":{},base:xn,depth:0,mapUnsafe:xn,pipe(){return st(this,arguments)}};function k(e,t){let n=t?.space??0,r=new WeakSet,i=n?typeof n==`number`?` `.repeat(n):n:``,a=e=>i.repeat(e),o=(e,t)=>{let n=e?.constructor;return n&&n!==Object.prototype.constructor&&n.name?`${n.name}(${t})`:t},s=e=>{try{return Reflect.ownKeys(e)}catch{return[`[ownKeys threw]`]}};function c(e,t=0){try{return l(e,t)}catch{return(typeof e==`object`&&e||typeof e==`function`)&&r.delete(e),`[inspection threw]`}}function l(e,n=0){if(typeof e==`string`)return JSON.stringify(e);if(typeof e==`number`||e==null||typeof e==`boolean`||typeof e==`symbol`)return String(e);if(typeof e==`bigint`)return String(e)+`n`;if(typeof e==`object`||typeof e==`function`){if(r.has(e))return Cn;r.add(e);let l;if(gn in e)l=c(yn(e),n);else if(Array.isArray(e))l=!i||e.length<=1?`[${e.map(e=>c(e,n)).join(`,`)}]`:`[\n${a(n+1)}${e.map(e=>c(e,n+1)).join(`,
|
|
2
|
+
`+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=En(e);else if(!t?.ignoreToString&&D(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Dn(e);l=e instanceof Error&&e.cause!==void 0?`${t} (cause: ${c(e.cause,n)})`:t}else if(Symbol.iterator in e)l=`${e.constructor.name}(${c(Array.from(e),n)})`;else{let t=s(e);if(!i||t.length<=1){let r=`{${t.map(t=>`${wn(t)}:${c(On(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${wn(t)}: ${c(On(e,t),n+1)}`).join(`,
|
|
3
|
+
`)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var Cn=`[Circular]`;function wn(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Tn(e){return e.map(e=>`[${wn(e)}]`).join(``)}function En(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Dn(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function On(e,t){try{return e[t]}catch{return`[property access threw]`}}function kn(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=D(r,gn)?vn(r):vn(t);if(typeof i==`bigint`)return k(i);if(typeof i!=`object`||!i)return i;let a=i instanceof Error&&!D(i,`toJSON`)?{...i,name:i.name,message:i.message}:i;for(;n.length>0&&n[n.length-1]!==this;)n.pop();if(!n.includes(i))return n.push(i),a!==i&&n.push(a),a},t?.space)??`null`}var An=Symbol.for(`nodejs.util.inspect.custom`),jn=e=>{try{return e=vn(e),D(e,`toJSON`)&&Dt(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(jn):e}catch{return`[toJSON threw]`}},Mn={toJSON(){return jn(this)},[An](){return this.toJSON()},toString(){return k(this.toJSON())}},Nn=class{[An](){return this.toJSON()}toString(){return k(this.toJSON())}},Pn=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),Fn=()=>Error.stackTraceLimit,In=e=>{Pn&&(Error.stackTraceLimit=e)},Ln=class{constructor(e){this.value=e,this.done=!1}next(e){return this.done?(this.value=e,this):(this.done=!0,{value:this.value,done:!1})}},Rn=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return Fn()!==0&&t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})();function zn(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function Bn(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&zn(e,n,t[n])}var Vn=`~effect/Effect`,Hn=`~effect/Exit`,Un={_A:E,_E:E,_R:E},Wn=`${Vn}/identifier`,A=`${Vn}/args`,Gn=`${Vn}/evaluate`,Kn=`${Vn}/successCont`,qn=`${Vn}/failureCont`,Jn=`${Vn}/ensureCont`,Yn=Symbol.for(`effect/Effect/Yield`),Xn={pipe(){return st(this,arguments)},toJSON(){return{...this}},toString(){return k(this.toJSON(),{ignoreToString:!0,space:2})},[An](){return this.toJSON()}},Zn={[Vn]:Un,...Xn,[Symbol.iterator](){return new Ln(this)},toJSON(){return{_id:`Effect`,op:this[Wn],...A in this?{args:this[A]}:void 0}}},Qn=e=>D(e,Vn),$n=e=>D(e,Hn),er=`~effect/Cause`,tr=`~effect/Cause/Reason`,nr=e=>D(e,er),rr=class{constructor(e){this[er]=er,this.reasons=e}pipe(){return st(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${k(this.reasons)})`}[An](){return this.toJSON()}[$t](e){return nr(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>en(t,e.reasons[n]))}[Ft](){return Kt(this.reasons)}},ir=new WeakMap,ar=class{[tr];annotations;_tag;constructor(e,t,n){if(this[tr]=tr,this._tag=e,t!==or&&typeof n==`object`&&n&&t.size>0){let e=ir.get(n);e&&(t=new Map([...e,...t])),ir.set(n,t)}this.annotations=t}annotate(e,t){if(e.mapUnsafe.size===0)return this;let n=new Map(this.annotations);e.mapUnsafe.forEach((e,r)=>{t?.overwrite!==!0&&n.has(r)||n.set(r,e)});let r=Object.assign(Object.create(Object.getPrototypeOf(this)),this);return r.annotations=n,r}pipe(){return st(this,arguments)}toString(){return k(this)}[An](){return this.toString()}},or=new Map,sr=class extends ar{constructor(e,t=or){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${k(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[$t](e){return pr(e)&&en(this.error,e.error)&&en(this.annotations,e.annotations)}[Ft](){return Rt(Ht(this._tag))(Rt(O(this.error))(O(this.annotations)))}},cr=e=>new rr(e),lr=e=>new rr([new sr(e)]),ur=class extends ar{constructor(e,t=or){super(`Die`,t,e),this.defect=e}toString(){return`Die(${k(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[$t](e){return mr(e)&&en(this.defect,e.defect)&&en(this.annotations,e.annotations)}[Ft](){return Rt(Ht(this._tag))(Rt(O(this.defect))(O(this.annotations)))}},dr=e=>new rr([new ur(e)]),fr=T(e=>nr(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new rr(e.reasons.map(e=>e.annotate(t,n)))),pr=e=>e._tag===`Fail`,mr=e=>e._tag===`Die`,hr=e=>e._tag===`Interrupt`;function gr(e){return Tr(`Effect.evaluate: Not implemented`)}var _r=e=>({...Zn,[Wn]:e.op,[Gn]:e[Gn]??gr,[Kn]:e[Kn],[qn]:e[qn],[Jn]:e[Jn]}),vr=e=>{let t=_r(e),n=function(e){this[A]=e};return n.prototype=t,function(e){return new n(e)}},yr=e=>{let t={[Hn]:Hn,_tag:e.op,get[e.prop](){return this[A]},..._r(e),toString(){return`${e.op}(${k(this[A])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[A]}},[$t](e){return $n(e)&&e._tag===this._tag&&en(this[A],e[A])},[Ft](){return Rt(Ht(e.op),O(this[A]))}},n=function(e){this[A]=e};return n.prototype=t,function(e){return new n(e)}},br=yr({op:`Success`,prop:`value`,[Gn](e){let t=e.getCont(Kn);return t?t[Kn](this[A],e,this):e.yieldWith(this)}}),xr={key:`effect/Cause/StackTrace`},Sr={key:`effect/Cause/InterruptorStackTrace`},Cr=yr({op:`Failure`,prop:`cause`,[Gn](e){let t=this[A],n=!1;e.cache.stackFrame&&(t=fr(t,{mapUnsafe:new Map([[xr.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(qn);for(;e.interruptible&&e._interruptedCause&&r;)r=e.getCont(qn);return r?r[qn](t,e,n?void 0:this):e.yieldWith(n?Cr(t):this)}}),wr=e=>Cr(lr(e)),Tr=e=>Cr(dr(e)),Er=vr({op:`WithFiber`,[Gn](e){return this[A](e)}}),Dr=function(){class e extends globalThis.Error{}let t=_r({op:`YieldableError`,[Gn](){return wr(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Or=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Dr{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(Bn(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),kr=e=>{class t extends Or{_tag=e}return t.prototype.name=e,t};kr(`NoSuchElementError`);var Ar=`~effect/Cause/Done`,jr=e=>D(e,Ar),Mr={[Ar]:Ar,_tag:`Done`,value:void 0},Nr=e=>e===void 0?Mr:{[Ar]:Ar,_tag:`Done`,value:e},Pr=wr(Mr),Fr=e=>e===void 0?Pr:wr(Nr(e)),Ir=e=>_r({op:e.label,[Gn]:e.evaluate}),Lr=e=>(t,n)=>t===n||e(t,n),Rr=(e,t)=>e===t,zr=()=>Rr;function Br(e){return Lr((t,n)=>{if(t.length!==n.length)return!1;for(let r=0;r<t.length;r++)if(!e[r](t[r],n[r]))return!1;return!0})}function Vr(e){return Lr((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})}var Hr=`~effect/Option`,Ur={[Hr]:{_A:e=>e},...Xn,[Symbol.iterator](){return new Ln(this)}},Wr=Object.defineProperty(Object.assign(Object.create(Ur),{_tag:`Some`,_op:`Some`,[$t](e){return qr(e)&&Yr(e)&&en(this.value,e.value)},[Ft](){return Rt(O(this._tag))(O(this.value))},toString(){return`some(${k(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:jn(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),Gr=O(`None`),Kr=Object.assign(Object.create(Ur),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[$t](e){return qr(e)&&Jr(e)},[Ft](){return Gr},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),qr=e=>D(e,Hr),Jr=e=>e._tag===`None`,Yr=e=>e._tag===`Some`,Xr=Object.create(Kr),Zr=function(e){this.value=e};Zr.prototype=Wr;var Qr=e=>new Zr(e),$r=`~effect/Result`,ei={[$r]:{_A:e=>e,_E:e=>e},...Xn,[Symbol.iterator](){return new Ln(this)}},ti=Object.assign(Object.create(ei),{_tag:`Success`,_op:`Success`,[$t](e){return ri(e)&&ai(e)&&en(this.success,e.success)},[Ft](){return Rt(O(this._tag))(O(this.success))},toString(){return`success(${k(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:jn(this.success)}}}),ni=Object.assign(Object.create(ei),{_tag:`Failure`,_op:`Failure`,[$t](e){return ri(e)&&ii(e)&&en(this.failure,e.failure)},[Ft](){return Rt(O(this._tag))(O(this.failure))},toString(){return`failure(${k(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:jn(this.failure)}}}),ri=e=>D(e,$r),ii=e=>e._tag===`Failure`,ai=e=>e._tag===`Success`,oi=function(e){this.failure=e};oi.prototype=ni;var si=e=>new oi(e),ci=function(e){this.success=e};ci.prototype=ti;var li=e=>new ci(e);function ui(e){return(t,n)=>t===n?0:e(t,n)}var di=ui((e,t)=>e<t?-1:1),fi=ui((e,t)=>globalThis.Number.isNaN(e)&&globalThis.Number.isNaN(t)?0:globalThis.Number.isNaN(e)?-1:globalThis.Number.isNaN(t)?1:e<t?-1:1),pi=T(2,(e,t)=>ui((n,r)=>e(t(n),t(r)))),mi=e=>T(2,(t,n)=>e(t,n)===-1),hi=e=>T(2,(t,n)=>e(t,n)===1),gi=e=>T(2,(t,n)=>e(t,n)!==1),_i=e=>T(2,(t,n)=>e(t,n)!==-1),vi=()=>Xr,yi=Qr,bi=Jr,xi=Yr,Si=T(2,(e,{onNone:t,onSome:n})=>bi(e)?t():n(e.value)),Ci=T(2,(e,t)=>bi(e)?t():e.value),wi=e=>e==null?vi():yi(e),Ti=Ci(pt),Ei=`~effect/Context/Service`,Di=function(){function e(){}let t=e;Object.setPrototypeOf(t,Oi);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Ai]=Ai,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&ki.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Oi={[Ei]:Ei,...Ir({label:`Service`,evaluate(e){return br($i(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return qi(this,e)},use(e){return Er(t=>e($i(t.context,this)))},useSync(e){return Er(t=>br(e($i(t.context,this))))}},ki=new Set,Ai=`~effect/Context/Reference`,ji=`~effect/Context`,Mi=8,Ni=8,Pi=(e,t,n,r)=>{let i=Object.create(Vi);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},Fi=(e,t)=>{t&&(Fi(e,t.parent),e.set(t.key,t.value))},Ii=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return Fi(t,e.overlay),e._flat=t},Li=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),Bi(n)},Ri=Symbol(),zi=(e,t)=>{let n=e;for(let e=n.overlay;e;e=e.parent)if(e.key===t)return e.value;let r=n.base.get(t);return r===void 0&&!n.base.has(t)?Ri:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Ni&&(n.base=Ii(n),n.overlay=void 0,n.depth=0),r)},Bi=e=>Pi(void 0,e,void 0,0),Vi={get mapUnsafe(){return Ii(this)},...Xn,[ji]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[$t](e){if(!Ui(e))return!1;let t=this.mapUnsafe,n=e.mapUnsafe;if(t.size!==n.size)return!1;for(let[e,r]of t)if(!n.has(e)||!en(r,n.get(e)))return!1;return!0},[Ft](){return Vt(this.mapUnsafe.size)}},Hi=(e,t)=>e.cacheRoot===t.cacheRoot,Ui=e=>D(e,ji),Wi=e=>!!e[Ai],Gi=()=>Ki,Ki=Bi(new Map),qi=(e,t)=>Bi(new Map([[e.key,t]])),Ji=T(3,(e,t,n)=>Yi(e,t.key,n)),Yi=(e,t,n)=>{let r=e,i=ki.has(t)?void 0:r.cacheRoot;if(r.depth>=Mi){let e=new Map(r.mapUnsafe);return e.set(t,n),Pi(i,e,void 0,0)}return Pi(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},Xi=T(2,(e,t)=>Zi(e,t.key)),Zi=(e,t)=>{let n=zi(e,t);return n===Ri?void 0:n},Qi=T(2,(e,t)=>{let n=zi(e,t.key);if(n===Ri){if(Wi(t))return ta(t);throw na(t)}return n}),$i=Qi,ea=`~effect/Context/defaultValue`,ta=e=>ea in e?e[ea]:e[ea]=e.defaultValue(),na=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
|
|
4
|
+
`);e.splice(1,3),t.stack=e.join(`
|
|
5
|
+
`)}return t},ra=T(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:Li(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),ia=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return Bi(t)},aa=Di,oa=e=>e.length>0,sa=li,ca=si,la=e=>{if(Dt(e))try{return sa(e())}catch(e){return ca(e)}try{return sa(e.try())}catch(t){return ca(e.catch(t))}},ua=ii,da=ai,fa=Br,pa=T(2,(e,t)=>Object.hasOwn(e,t)),ma=T(2,(e,t)=>{let n={...e};for(let r of ha(e))zn(n,r,t(e[r],r));return n}),ha=e=>Object.keys(e),ga=e=>T(2,(t,n)=>{for(let r of ha(t))if(!pa(n,r)||!e(t[r],n[r]))return!1;return!0}),_a=e=>{let t=ga(e);return(e,n)=>t(e,n)&&t(n,e)},va=globalThis.Array,ya=e=>va.isArray(e)?e:va.from(e),ba=e=>va.isArray(e)?e:[e],xa=T(2,(e,t)=>[...e,t]),Sa=va.isArray,Ca=oa,wa=oa,Ta=T(3,(e,t,n)=>va.from(e).map(e=>[e,t(e)]).sort(([,e],[,t])=>n(e,t)).map(([e])=>e)),Ea=(e,t)=>{let n=O(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(en(e,t))return!1;return r.push(t),!0},Da=()=>[],Oa=e=>[e],ka=T(2,(e,t)=>e.map(t)),Aa=Vr,ja=e=>{let t=ya(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)Ea(n,e)&&r.push(e);return r},Ma=`~effect/Duration`,Na=BigInt(0),Pa=BigInt(1),Fa=BigInt(2),Ia=BigInt(10),La=BigInt(1e3),Ra=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),za=e=>Ra(e*1e6),Ba=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=Ia**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*Fa>=a?Pa:Na);return r?-s:s},Va=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,Ha=e=>{switch(typeof e){case`number`:return eo(e);case`bigint`:return $a(e);case`string`:{if(e===`Infinity`)return Za;if(e===`-Infinity`)return Qa;let t=Va.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return $a(Ba(r,Pa));if(i===`micro`||i===`micros`)return $a(Ba(r,La));let a=Number(r);switch(i){case`milli`:case`millis`:return eo(a);case`second`:case`seconds`:return to(a);case`minute`:case`minutes`:return no(a);case`hour`:case`hours`:return ro(a);case`day`:case`days`:return io(a);case`week`:case`weeks`:return ao(a)}break}case`object`:{if(e===null)break;if(Ma in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Ct)?Ua(e):Number.isNaN(e[0])||Number.isNaN(e[1])?Xa:e[0]===-1/0||e[1]===-1/0?Qa:e[0]===1/0||e[1]===1/0?Za:Ja(Ra(e[0]*1e9+e[1]));let t=e,n=0;return t.weeks&&(n+=t.weeks*6048e5),t.days&&(n+=t.days*864e5),t.hours&&(n+=t.hours*36e5),t.minutes&&(n+=t.minutes*6e4),t.seconds&&(n+=t.seconds*1e3),t.milliseconds&&(n+=t.milliseconds),!t.microseconds&&!t.nanoseconds?Ja(n):Ja(Ra(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return Ua(e)},Ua=e=>{throw Error(`Invalid Input: ${e}`)},Wa={_tag:`Millis`,millis:0},Ga={_tag:`Infinity`},Ka={_tag:`NegativeInfinity`},qa={[Ma]:Ma,[Ft](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?O(Ra(e)):Vt(this.value.millis)}case`Nanos`:return O(this.value.nanos);default:return Wt(this.value)}},[$t](e){return Ya(e)&&fo(this,e)},toString(){switch(this.value._tag){case`Infinity`:return`Infinity`;case`NegativeInfinity`:return`-Infinity`;case`Nanos`:return`${this.value.nanos} nanos`;case`Millis`:return`${this.value.millis} millis`}},toJSON(){switch(this.value._tag){case`Millis`:return{_id:`Duration`,_tag:`Millis`,millis:this.value.millis};case`Nanos`:return{_id:`Duration`,_tag:`Nanos`,nanos:String(this.value.nanos)};case`Infinity`:return{_id:`Duration`,_tag:`Infinity`};case`NegativeInfinity`:return{_id:`Duration`,_tag:`NegativeInfinity`}}},[An](){return this.toJSON()},pipe(){return st(this,arguments)}},Ja=e=>{let t=Object.create(qa);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?Wa:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:za(e)}:e>0?Ga:Ka:e===Na?Wa:{_tag:`Nanos`,nanos:e},t},Ya=e=>D(e,Ma),Xa=Ja(0),Za=Ja(1/0),Qa=Ja(-1/0),$a=e=>Ja(e),eo=e=>Ja(e),to=e=>Ja(e*1e3),no=e=>Ja(e*6e4),ro=e=>Ja(e*36e5),io=e=>Ja(e*864e5),ao=e=>Ja(e*6048e5),oo=e=>co(Ha(e),{onMillis:E,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),so=e=>{let t=Ha(e);switch(t.value._tag){case`Infinity`:case`NegativeInfinity`:throw Error(`Cannot convert infinite duration to nanos`);case`Nanos`:return t.value.nanos;case`Millis`:return za(t.value.millis)}},co=T(2,(e,t)=>{switch(e.value._tag){case`Millis`:return t.onMillis(e.value.millis);case`Nanos`:return t.onNanos(e.value.nanos);case`Infinity`:return t.onInfinity();case`NegativeInfinity`:return(t.onNegativeInfinity??t.onInfinity)()}}),lo=T(3,(e,t,n)=>e.value._tag===`Infinity`||e.value._tag===`NegativeInfinity`||t.value._tag===`Infinity`||t.value._tag===`NegativeInfinity`?n.onInfinity(e,t):e.value._tag===`Millis`?t.value._tag===`Millis`?n.onMillis(e.value.millis,t.value.millis):n.onNanos(so(e),t.value.nanos):n.onNanos(e.value.nanos,so(t))),uo=(e,t)=>lo(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),fo=T(2,(e,t)=>uo(e,t)),po=aa(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new vo}),mo=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},ho=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},go=e=>{try{return ho(e)}catch{return mo(e)}},_o=class{buckets=[];scheduleTask(e,t){let n=this.buckets,r=n.length,i,a=0;for(;a<r&&!(n[a][0]>t);a++)i=n[a];i&&i[0]===t?i[1].push(e):a===r?n.push([t,[e]]):n.splice(a,0,[t,[e]])}drain(){let e=this.buckets;return this.buckets=[],e}},vo=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?mo:go)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new yo(this.setImmediate)}},yo=class{tasks=new _o;running=void 0;setImmediate;constructor(e=go){this.setImmediate=e}scheduleTask(e,t){this.tasks.scheduleTask(e,t),this.running===void 0&&(this.running=this.setImmediate(this.afterScheduled))}afterScheduled=()=>{this.running=void 0,this.runTasks()};runTasks(){let e=this.tasks.drain();for(let t=0;t<e.length;t++){let n=e[t][1];for(let e=0;e<n.length;e++)n[e]()}}flush(){for(;this.tasks.buckets.length>0;)this.running!==void 0&&(this.running(),this.running=void 0),this.runTasks()}},bo=aa(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),xo=aa(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),So=kr;So(`EncodingError`);var Co=e=>{switch(e){case 16:return Eo();case 32:return Do();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=To();return t}}},j=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),wo=()=>Math.random()*4294967296>>>0,To=()=>{let e=wo();return String.fromCharCode(j[e>>>28],j[e>>>24&15],j[e>>>20&15],j[e>>>16&15],j[e>>>12&15],j[e>>>8&15],j[e>>>4&15],j[e&15])},Eo=()=>{let e=wo(),t=wo();return String.fromCharCode(j[e>>>28],j[e>>>24&15],j[e>>>20&15],j[e>>>16&15],j[e>>>12&15],j[e>>>8&15],j[e>>>4&15],j[e&15],j[t>>>28],j[t>>>24&15],j[t>>>20&15],j[t>>>16&15],j[t>>>12&15],j[t>>>8&15],j[t>>>4&15],j[t&15])},Do=()=>{let e=wo(),t=wo(),n=wo(),r=wo();return String.fromCharCode(j[e>>>28],j[e>>>24&15],j[e>>>20&15],j[e>>>16&15],j[e>>>12&15],j[e>>>8&15],j[e>>>4&15],j[e&15],j[t>>>28],j[t>>>24&15],j[t>>>20&15],j[t>>>16&15],j[t>>>12&15],j[t>>>8&15],j[t>>>4&15],j[t&15],j[n>>>28],j[n>>>24&15],j[n>>>20&15],j[n>>>16&15],j[n>>>12&15],j[n>>>8&15],j[n>>>4&15],j[n&15],j[r>>>28],j[r>>>24&15],j[r>>>20&15],j[r>>>16&15],j[r>>>12&15],j[r>>>8&15],j[r>>>4&15],j[r&15])},Oo=`effect/Tracer/ParentSpan`,ko=class extends Di()(Oo,{fiberCached:!0}){},Ao=e=>e,jo=aa(`effect/Tracer/DisablePropagation`,{defaultValue:ft}),Mo=aa(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),No=aa(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),Po=`effect/Tracer`,Fo=Ao({span:e=>new Io(e)}),Io=class{_tag=`Span`;sampled;name;parent;annotations;links;startTime;kind;status;_traceId=void 0;_spanId=void 0;_attributes=void 0;_events=void 0;constructor(e){this.name=e.name,this.parent=e.parent,this.annotations=e.annotations,this.links=e.links,this.startTime=e.startTime,this.kind=e.kind,this.sampled=e.sampled,this.status={_tag:`Started`,startTime:e.startTime}}get traceId(){return this._traceId??=Ti(this.parent)?.traceId??Co(32)}get spanId(){return this._spanId??=Co(16)}get attributes(){return this._attributes??=new Map}get events(){return this._events??=[]}end(e,t){this.status={_tag:`Ended`,endTime:e,exit:t,startTime:this.status.startTime}}attribute(e,t){this.attributes.set(e,t)}event(e,t,n){this.events.push([e,t,n??{}])}addLinks(e){this.links.push(...e)}},Lo=`effect/Metric/FiberRuntimeMetrics`,Ro=aa(`effect/ErrorReporter/CurrentErrorReporters`,{defaultValue:()=>new Set}),zo=aa(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:pt}),Bo=aa(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:dt}),Vo=aa(`effect/References/TracerTimingEnabled`,{defaultValue:dt}),Ho=aa(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),Uo=aa(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),Wo=aa(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Go=aa(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),Ko=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=Fn();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};In(3);let n=Error();return In(t),{...e,captureStackTrace:Jo(()=>n.stack)}},qo=e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
|
|
6
|
+
`);if(i[e]!==void 0)return n=i[e].trim(),n}},Jo=qo(3),Yo=class extends ar{constructor(e,t=or){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[$t](e){return hr(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[Ft](){return Rt(Ht(`${this._tag}:${this.fiberId}`))(It(this.annotations))}},Xo=e=>new rr([new Yo(e)]),Zo=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return sa(n.error)}return ca(e)},Qo=e=>e.reasons.some(mr),$o=e=>e.reasons.some(hr),es=e=>{let t;for(let n=0;n<e.reasons.length;n++){let r=e.reasons[n];r._tag===`Interrupt`&&(t??=new Set,r.fiberId!==void 0&&t.add(r.fiberId))}return t?sa(t):ca(e)},ts=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=O(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>en(e,i)))continue;else t.push(i);r.push(i)}return r},ns=T(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new rr(ts(e.reasons,t.reasons));return en(e,n)?e:n}),rs=T(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>pr(e)?(n=!0,new sr(t(e.error),e.annotations)):e);return n?cr(r):e}),is=e=>{let t;for(let n of e.reasons){if(n._tag===`Fail`)return n.error;n._tag===`Die`&&(t??=n)}return t===void 0?e.reasons.length>0?new globalThis.Error(`All fibers interrupted without error`):new globalThis.Error(`Empty cause`):t.defect},as=(e,t,n)=>{let r=typeof e,i;if(e&&r===`object`){if(i=new globalThis.Error(os(e),{cause:e.cause?as(e.cause):void 0}),typeof e.name==`string`&&(i.name=e.name),typeof e.stack==`string`)i.stack=cs(e.stack,i,t);else{let e=`${i.name}: ${i.message}`;i.stack=t?ls(e,t):e}n?.includeCauseInStack&&(i.stack=ds(i));for(let t of Object.keys(e))t in i||(i[t]=e[t])}else i=new globalThis.Error(e?r===`string`?e:kn(e):`Unknown error: ${e}`);return i},os=e=>{if(typeof e.message==`string`)return e.message;if(typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString)try{return e.toString()}catch{}return kn(e)},ss=/\((.*)\)/g,cs=(e,t,n)=>{let r=`${t.name}: ${t.message}`,i=(e.startsWith(r)?e.slice(r.length):e).split(`
|
|
7
|
+
`),a=[r];for(let e=1;e<i.length&&!/Generator\.next|~effect\/(?:Effect|Utils)/.test(i[e]);e++)a.push(i[e]);return n?ls(a.join(`
|
|
8
|
+
`),n):a.join(`
|
|
9
|
+
`)},ls=(e,t)=>{let n=t?.get(xr.key);return n&&(e=`${e}\n${us(n)}`),e},us=e=>{let t=[],n=e,r=0;for(;n&&r<10;){let e=n.stack();if(e){let r=e.matchAll(ss),i=!1;for(let[,e]of r)i=!0,t.push(` at ${n.name} (${e})`);i||t.push(` at ${n.name} (${e.replace(/^at /,``)})`)}else t.push(` at ${n.name}`);n=n.parent,r++}return t.join(`
|
|
10
|
+
`)},ds=e=>e.cause?`${e.stack} {\n${fs(e.cause,` `)}\n}`:e.stack,fs=(e,t)=>{let n=e.stack.split(`
|
|
11
|
+
`),r=`${t}[cause]: ${n[0]}`;for(let e=1,i=n.length;e<i;e++)r+=`\n${t}${n[e]}`;return e.cause&&(r+=` {\n${fs(e.cause,`${t} `)}\n${t}}`),r},ps=`~effect/Fiber`,ms={_A:E,_E:E},hs={id:0},gs=()=>globalThis[bn],_s=class{constructor(e,t=!0){this.setContext(e),this.id=++hs.id,this.currentOpCount=0,this.interruptible=t,this._stack=[],this._observers=void 0,this._exit=void 0,this._children=void 0,this._interruptedCause=void 0,this._yielded=void 0,this._running=!1,this._deferredInterrupt=!1,this._parent=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[ps](){return ms}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return $i(this.context,e)}addObserver(e){return this._exit?(e(this._exit),mt):(this._observers===void 0?this._observers=[e]:this._observers.push(e),()=>this.removeObserver(e))}removeObserver(e){if(this._exit||this._observers===void 0)return;let t=this._observers.indexOf(e);t>=0&&this._observers.splice(t,1)}interruptUnsafe(e,t){if(this._exit)return;let n=Xo(e);this.cache.stackFrame&&(n=fr(n,qi(xr,this.cache.stackFrame))),t&&(n=fr(n,t)),this._interruptedCause=this._interruptedCause?ns(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Os(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===Yn)return;let n=xs.interruptChildren&&xs.interruptChildren(this);if(n!==void 0)return this.evaluate(hc(n,()=>t));if(this._exit=t,this.cache.runtimeMetrics?.recordFiberEnd(this.context,this._exit),this._parent&&=(this._parent._children?.delete(this),void 0),this._observers!==void 0){let e=this._observers;this._observers=void 0;for(let n=0;n<e.length;n++)e[n](t)}this._stack.length=0,this._children=void 0,this.context=Gi()}runLoop(e){let t=globalThis[bn];globalThis[bn]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;){this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Os(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=hc(Ms,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[Gn](this),i===Yn){let e=this._yielded;if(Hn in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return Yn}}}catch(e){return D(i,Gn)?this.runLoop(Tr(e)):Tr(`Fiber.runLoop: Not a valid effect: ${String(i)}`)}finally{this._running=n,globalThis[bn]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,ys;for(;;){let t=this._stack.pop();if(!t)return;let n=t[Jn];if(n!==void 0){let r=n.call(t,this);if(r)return r[e]=r,r}if(t[e])return t}}succeedWith(e){if(!(++this.currentOpCount&bs-1))return br(e);let t=this.getCont(Kn);return t?t[Kn](e,this):this.yieldWith(br(e))}yieldWith(e){return this._yielded=e,Yn}children(){return this._children??=new Set}pipe(){return st(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&Hi(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=vs(e);this.cache?.scheduler!==r.scheduler&&(this._dispatcher=void 0),this.cache=r}get currentSpanLocal(){let e=this.cache.span;return e?._tag===`Span`?e:void 0}},vs=e=>{let t=Zi(e,Po);return{scheduler:$i(e,po),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:$i(e,Bo),span:Zi(e,Oo),logLevel:$i(e,Wo),minimumLogLevel:$i(e,Go),stackFrame:$i(e,zo),runtimeMetrics:Zi(e,Lo),maxOpsBeforeYield:$i(e,bo),preventYield:$i(e,xo)}},ys={[Kn](e,t){return Os(t._interruptedCause)},[qn](e,t){return Os(t._interruptedCause)}},bs=32,xs={interruptChildren:void 0},Ss=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Sr.key,e.cache.stackFrame),Bi(t)},Cs=e=>{let t=e;return t._exit?M(t._exit):Us(n=>t._exit?n(M(t._exit)):As(e.addObserver(e=>n(M(e)))))},ws=e=>Us(t=>{let n=e[Symbol.iterator](),r=[],i;function a(){let e=n.next();for(;!e.done;){if(e.value._exit){r.push(e.value._exit),e=n.next();continue}i=e.value.addObserver(e=>{r.push(e),a()});return}t(M(r))}return a(),As(()=>i?.())}),Ts=e=>Er(t=>Es(e,t.id)),Es=T(e=>D(e[0],ps),(e,t,n)=>Er(r=>{let i=Ss(r);return i=i&&n?ra(i,n):i??n,e.interruptUnsafe(t,i),mc(Cs(e))})),Ds=e=>Er(t=>{let n=Ss(t),r=Da();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return mc(ws(r))}),M=br,Os=Cr,ks=wr,As=vr({op:`Sync`,[Gn](e){let t=this[A](),n=e.getCont(Kn);return n?n[Kn](t,e):e.yieldWith(br(t))}}),js=vr({op:`Suspend`,[Gn](e){return this[A]()}}),Ms=vr({op:`Yield`,[Gn](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Cc)},this[A]??0),e.yieldWith(()=>{t=!0})}})(0),Ns=M(vi()),Ps=e=>js(()=>Os(e())),Fs=e=>Tr(e),Is=e=>js(()=>ks(e())),Ls=M(void 0),Rs=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Pu(e,`An error occurred in Effect.try`):e.catch;return js(()=>{try{return M(t())}catch(e){return ks(n(e))}})},zs=e=>Vs(function(t,n){e(n).then(e=>t(M(e)),e=>t(Fs(e)))},e.length!==0),Bs=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Pu(e,`An error occurred in Effect.tryPromise`):e.catch;return Vs(function(e,r){let i=t=>{try{e(ks(Rn(()=>n(t))))}catch(t){e(Fs(t))}};try{t(r).then(t=>e(M(t)),i)}catch(e){i(e)}},t.length!==0)},Vs=function(){let e=_r({op:`Async`,[Gn](e){let t=!1,n=!1,r=this.withSignal?new AbortController:void 0,i=this.register.call(e.cache.scheduler,r=>{t||(t=!0,n?e.evaluate(r):n=r)},r?.signal);return n===!1?(n=!0,e._yielded=()=>{t=!0},r===void 0&&i===void 0||e._stack.push(Hs(()=>(t=!0,r?.abort(),i??Cc))),Yn):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),Hs=vr({op:`AsyncFinalizer`,[Jn](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Fl))},[qn](e,t){return $o(e)?hc(ul(Cr(e),this[A]()),()=>Os(e)):Os(e)}}),Us=e=>Vs(e,e.length>=2),Ws=Us(mt),Gs=(...e)=>{if(e.length===1){let t=e[0];return js(()=>$s(t()))}let[t,n]=e;return js(()=>$s(n.call(t.self)))},Ks=(e,...t)=>{let n=t.length===0?function(){return js(()=>$s(e.apply(this,arguments)))}:function(){let n=js(()=>$s(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return qs(e.length,n)},qs=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),Js=qo(2),Ys=function(){let e=typeof arguments[0]==`string`,t=e?arguments[0]:`Effect.fn`,n=e?arguments[1]:void 0,r=Fn(),i;return r!==0&&(In(2),i=new globalThis.Error,In(r)),e?(r,...a)=>Xs(t,r,i,a,e,n):Xs(t,arguments[0],i,Array.prototype.slice.call(arguments,1),e,n)},Xs=(e,t,n,r,i,a)=>{let o=typeof t==`function`?t:r.shift().bind(t.self),s=`${e} (definition)`,c=n?Js(()=>n.stack):pt;return qs(o.length,function(...t){let n=js(()=>{let e=o.apply(this,arguments);return Qn(e)?e:$s(e)});for(let e=0;e<r.length;e++)n=r[e](n,...t);if(!Qn(n))return n;let l=Fn(),u;return l!==0&&(In(2),u=new globalThis.Error,In(l)),Oc(i?bu(e,a,e=>xu(n,e)):n,zo,t=>({name:e,stack:u?Js(()=>u.stack):pt,parent:{name:s,stack:c,parent:t}}))})},Zs=(e,...t)=>qs(e.length,t.length===0?function(){return Qs(()=>e.apply(this,arguments))}:function(){let n=Qs(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),Qs=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return M(r.value);let i=r.value;if(i&&i._tag===`Success`){n=i.value;continue}if(i&&i._tag===`Failure`)return r.value;{let n=!0;return js(()=>n?(n=!1,hc(r.value,e=>$s(t,e))):js(()=>$s(e())))}}}catch(e){return Fs(e)}},$s=function(){let e=_r({op:`Iterator`,[Kn](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return M(r.value);if(!N(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[Gn](e){return this[Kn](this.initial,e)}}),t=function(e,t){this.iterator=e,this.initial=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),ec=T(2,(e,t)=>new rc(e,ic,M(t))),tc=function(e){return e._stack.push(this),this[A]},nc=_r({op:`OnSuccess`,[Gn]:tc}),rc=function(e,t,n){this[A]=e,this[Kn]=t,this.payload=n};rc.prototype=nc;var ic=function(){return this.payload},ac=function(e,t){return t.succeedWith(this.payload)},oc=(()=>{let e=`~effect/Effect/stackProbe`;return{[e]:function(){return Error().stack}}[e]()?.includes(`[as `+e+`]`)===!0})(),sc=function(e,t){let n=this.payload;return t.succeedWith(oc?n(e):Rn(()=>n(e)))},cc=function(e){let t=this.payload;return t(e)},lc=function(e){let t=this.payload;return new rc(t(e),ac,e)},uc=function(e){return new rc(this.payload,ac,e)},dc=e=>vc(e,yi),fc=T(2,(e,t)=>new rc(e,Qn(t)?ic:cc,t)),pc=T(2,(e,t)=>new rc(e,Qn(t)?uc:lc,t)),mc=e=>new rc(e,ic,Cc),hc=T(2,(e,t)=>new rc(e,cc,t)),N=e=>e[Hn]!==void 0,gc=T(2,(e,t)=>N(e)?e._tag===`Success`?t(e.value):e:hc(e,t)),_c=e=>hc(e,E),vc=T(2,(e,t)=>new rc(e,sc,t)),yc=T(2,(e,t)=>N(e)?wc(e,t):vc(e,t)),bc=T(2,(e,t)=>N(e)?Tc(e,t):Kc(e,t)),xc=e=>e._tag===`Success`,Sc=e=>e._tag===`Failure`?sa(e.cause):ca(e),Cc=br(void 0),wc=T(2,(e,t)=>e._tag===`Success`?br(t(e.value)):e),Tc=T(2,(e,t)=>{if(e._tag===`Success`)return br(t.onSuccess(e.value));let n=Zo(e.cause);return ua(n)?e:wr(t.onFailure(n.success))}),Ec=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Cc:Cr(cr(t))},Dc=T(2,(e,t)=>Er(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Tl(n,()=>{n.setContext(r)}),e)})),Oc=T(3,(e,t,n)=>Dc(e,e=>{let r=Qi(e,t),i=n(r);return r===i?e:Ji(e,t,i)})),kc=()=>Ac,Ac=Er(e=>M(e.context)),jc=e=>Er(t=>e(t.context)),Mc=T(2,(e,t)=>N(e)?e:Dc(e,ra(t))),Nc=function(){return arguments.length===1?T(2,(e,t)=>Pc(e,arguments[0],t)):T(3,(e,t,n)=>Pc(e,t,n)).apply(this,arguments)},Pc=(e,t,n)=>Dc(e,Ji(t,n)),Fc=T(e=>Qn(e[0]),(e,t)=>Vl({while:dt,body:ut(t?.disableYield?e:hc(e,e=>Ms)),step:mt})),Ic=T(2,(e,t)=>new Rc(e,t.length===1?t:e=>t(e))),Lc=_r({op:`OnFailure`,[Gn]:tc}),Rc=function(e,t){this[A]=e,this[qn]=t};Rc.prototype=Lc;var zc=T(3,(e,t,n)=>Ic(e,e=>{let r=t(e);return ua(r)?Os(r.failure):n(r.success,e)})),Bc=T(2,(e,t)=>zc(e,Zo,e=>t(e))),Vc=T(3,(e,t,n)=>Ic(e,e=>{let r=t(e);return ua(r)?Os(e):fc(n(r.success,e),Os(e))})),Hc=T(2,(e,t)=>Vc(e,Zo,e=>t(e))),Uc=T(e=>Qn(e[0]),(e,t,n,r)=>Ic(e,e=>{let i=Zo(e);if(ua(i))return Os(i.failure);let a=t(i.success);return ua(a)?r?r(a.failure):Os(e):n(a.success)})),Wc=T(e=>Qn(e[0]),(e,t,n)=>{let r;return Uc(e,e=>(r??=Object.keys(t),D(e,`_tag`)&&St(e._tag)&&r.includes(e._tag)?sa(e):ca(e)),e=>t[e._tag](e),n)}),Gc=T(2,(e,t)=>Bc(e,e=>Is(()=>t(e)))),Kc=T(2,(e,t)=>$c(e,{onFailure:e=>Is(()=>t.onFailure(e)),onSuccess:e=>As(()=>t.onSuccess(e))})),qc=e=>tl(e,{onFailure:ca,onSuccess:sa}),Jc=T(2,(e,t)=>new Xc(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),Yc=_r({op:`OnSuccessAndFailure`,[Gn]:tc}),Xc=function(e,t,n){this[A]=e,this[Kn]=t,this[qn]=n};Xc.prototype=Yc;var Zc=function(e,t){let n=this.payload;return t.succeedWith(oc?n.onSuccess(e):Rn(()=>n.onSuccess(e)))},Qc=((e,t)=>{let n=_r({op:e,[Gn]:tc,[Kn]:Zc,[qn]:t}),r=function(e,t){this[A]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=e.reasons.find(pr);if(n===void 0)return Os(e);let r=this.payload;return t.succeedWith(oc?r.onFailure(n.error):Rn(()=>r.onFailure(n.error)))}),$c=T(2,(e,t)=>Jc(e,{onFailure:e=>{let n=e.reasons.find(pr);return n?t.onFailure(n.error):Os(e)},onSuccess:t.onSuccess})),el=T(2,(e,t)=>new Qc(e,t)),tl=T(2,(e,t)=>{if(N(e)){if(e._tag===`Success`)return br(t.onSuccess(e.value));let n=Zo(e.cause);return ua(n)?e:br(t.onFailure(n.success))}return el(e,t)}),nl=e=>N(e)?br(e):rl(e),rl=vr({op:`Exit`,[Gn](e){return e._stack.push(this),this[A]},[Kn](e,t,n){return t.succeedWith(n??br(e))},[qn](e,t,n){return t.succeedWith(n??Cr(e))}}),il=`~effect/Scope`,al=`~effect/Scope/Closeable`,ol=Di(`effect/Scope`),sl=(e,t)=>Er(n=>{let r=cl(e,t);return r===void 0?Ls:(Rl(n),r)}),cl=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&gl(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return ll(n.finalizer,t);let r=n.finalizers;return r.size===1?ll(r.values().next().value,t):dl(e,r,t)},ll=(e,t)=>{try{return e(t)}catch(e){return Tr(e)}},ul=(e,t)=>xc(e)?t:Ic(t,t=>Os(ns(e.cause,t))),dl=Ks(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=gs();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*nl(ll(s,n))):i.push(Yl(o,ll(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*ws(i)),yield*Ec(r)}),fl=(e,t)=>{let n=vl(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(hl(e,n,e=>sl(n,e)),n)},pl=(e,t)=>js(()=>e.state._tag===`Closed`?t(e.state.exit):(hl(e,{},t),Ls)),ml=(e,t)=>pl(e,ut(t)),hl=(e,t,n)=>{if(e.state._tag===`Empty`)e.state={_tag:`Open`,finalizerKey:t,finalizer:n,finalizers:void 0};else if(e.state._tag===`Open`){let r=e.state;r.finalizer===void 0?r.finalizers.set(t,n):(r.finalizers=new Map([[r.finalizerKey,r.finalizer]]),r.finalizerKey=void 0,r.finalizer=void 0,r.finalizers.set(t,n))}},gl=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=yl:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=yl))},_l=e=>vl(e,void 0),vl=(e=`sequential`,t)=>({[al]:al,[il]:il,strategy:e,parent:t,state:yl}),yl={_tag:`Empty`},bl=ol,xl=Nc(ol),Sl=e=>hc(bl,t=>jc(n=>pl(t,t=>Mc(e(t),n)))),Cl=function(){let e=_r({op:`OnExit`,[Gn](e){return e._stack.push(this),this.effect},[Jn](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Fl),e.interruptible=!1)},[Kn](e,t,n){n??=br(e);let r;try{r=this.onExit(n)}catch(e){r=Tr(e)}return r?hc(r,e=>n):n},[qn](e,t,n){n??=Cr(e);let r;try{r=this.onExit(n)}catch(e){r=Tr(e)}return r?hc(ul(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),wl=(e,t,n)=>new Cl(e,t,n),Tl=(e,t)=>{e._stack.push(new Cl(void 0,t,void 0))},El=T(2,wl),Dl=T(2,(e,t)=>El(e,e=>t)),Ol=T(3,(e,t,n)=>El(e,e=>{let r=t(e);return ua(r)?Ls:n(r.success,e)})),kl=T(2,(e,t)=>Ol(e,Sc,t)),Al=T(3,(e,t,n)=>El(e,e=>{if(e._tag!==`Failure`)return Ls;let r=t(e.cause);return ua(r)?Ls:n(r.success,e.cause)})),jl=T(2,(e,t)=>Al(es,t)(e)),Ml=e=>As(()=>{let t=fu(!1),n=!1,r,i=hc(t.await,()=>r);return Er(a=>r===void 0?n?i:(n=!0,Tl(a,e=>As(()=>{r=e,t.openUnsafe()})),e):r)}),Nl=e=>Er(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Fl),e):e),Pl=vr({op:`SetInterruptible`,[Jn](e){if(e.interruptible=this[A],e._interruptedCause&&e.interruptible)return()=>Os(e._interruptedCause)}}),Fl=Pl(!0),Il=Pl(!1),Ll=e=>{if(e.interruptible=!0,e._stack.push(Il),e._interruptedCause)return Os(e._interruptedCause)},Rl=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Fl))},zl=e=>Er(t=>t.interruptible?e:Ll(t)??e),Bl=e=>Er(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Fl),e(zl)):e(E)),Vl=vr({op:`While`,[Kn](e,t){return this[A].step(e),this[A].while()?(t._stack.push(this),this[A].body()):Cc},[Gn](e){return this[A].while()?(e._stack.push(this),this[A].body()):Cc}}),Hl=T(e=>typeof e[1]==`function`,(e,t,n)=>js(()=>{let r=Wl(n?.concurrency);if(r===1)return Ul(e,t,n);let i=ya(e),a=i.length;if(a===0)return n?.discard?Ls:M([]);let o=n?.discard?void 0:Array(a),s=Jl({f:t,out:o},i,{concurrency:r});return s?ec(s,o):M(o)})),Ul=(e,t,n)=>js(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return ec(Vl({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Wl=e=>e===`unbounded`?1/0:Math.max(1,e??1),Gl=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>hc(nl(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??Ls),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!N(c))return r(e,i,a,o,c);let l=n(e,s,c,a);if(l)return l._tag===`Failure`?l:void 0}};return i},Kl=e=>{let t=e.onItem,n=e.step;return(e,r,i)=>{let a=0,o=i.end??r.length,s=i.concurrency,c=!1,l,u,d,f,p,m=e=>{let t=Tr(e);return f=t,c=!0,u&&u.size>0?hc(Nl(Ds(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],g=p??t(e,o,a);if(N(g)){if(f=n(e,o,g,a),f)break}else if(l){p=void 0;let t=Yl(l,g,!0,!0,`inherit`);if(t._exit){if(f=n(e,o,t._exit,a),f)break;continue}u.add(t);let r=a;if(t.addObserver(a=>{u.delete(t);try{if(f){if(a._tag===`Failure`){let e=a.cause.reasons.filter(e=>e._tag!==`Interrupt`);if(e.length>0){let t=cr(e);f=Cr(f._tag===`Failure`?ns(f.cause,t):t)}}}else{let t=n(e,o,a,r);t&&(f=t,h())}if(i){let e=h();e&&d(e)}else c&&u.size===0&&d(f??Ls)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return Us(e=>{l=gs(),u=new Set,p=g,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):js(()=>(f??=Cc,hc(u?Ds(u):Ls,()=>f?._tag===`Failure`?f:Ls)))})}if(c=!0,f){if(u&&u.size>0){let e=Ss(l);u.forEach(t=>t.interruptUnsafe(l.id,e));return}if(d||f._tag===`Failure`)return f}else if(d){if(u)u.size===0&&d(Ls);else return Cc}};return h()}},ql=()=>e=>Kl(e),Jl=Kl({onItem(e,t,n){return e.f(t,n)},step(e,t,n,r){if(n._tag===`Failure`)return n;e.out&&(e.out[r]=n.value)}}),Yl=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new _s(a.context,o);return n?s.evaluate(t):a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0),!r&&!s._exit&&(a.children().add(s),s._parent=a),s},Xl=e=>(t,n)=>{let r=new _s(n?.scheduler?Ji(e,po,n.scheduler):e,n?.uninterruptible!==!0);if(r.evaluate(t),r._exit)return r;if(n?.signal){if(n.signal.aborted)r.interruptUnsafe();else{let e=()=>r.interruptUnsafe();n.signal.addEventListener(`abort`,e,{once:!0}),r.addObserver(()=>n.signal.removeEventListener(`abort`,e))}}return n?.onFiberStart&&n.onFiberStart(r),r},Zl=T(2,(e,t)=>{if(e._exit)return e;if(t.state._tag===`Closed`)return e.interruptUnsafe(e.id),e;let n={};return hl(t,n,()=>Ts(e)),e.addObserver(()=>gl(t,n)),e}),Ql=Xl(Gi()),$l=e=>{let t=Xl(e);return(e,n)=>{let r=t(e,n);return n?.onExit&&r.addObserver(n.onExit),e=>r.interruptUnsafe(e)}},eu=$l(Gi()),tu=e=>{let t=Xl(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},nu=tu(Gi()),ru=e=>{let t=tu(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw is(e.cause);return e.value})},iu=ru(Gi()),au=e=>{let t=Xl(e);return e=>{if(N(e))return e;let n=new vo(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Tr(new Mu(r))}},ou=au(Gi()),su=e=>{let t=au(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw is(n.cause);return n.value}},cu=su(Gi()),lu=M(!0),uu=M(!1),du=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return lu;if(this.scheduled===void 0)this.scheduled=this.waiters,e.currentDispatcher.scheduleTask(this.flushScheduled,0);else for(let e=0;e<this.waiters.length;e++)this.scheduled.push(this.waiters[e]);return this.waiters=[],lu}flushScheduled=()=>{if(this.scheduled===void 0)return;let e=this.scheduled;this.scheduled=void 0;for(let t=0;t<e.length;t++)e[t](Cc)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Cc)}open=Er(e=>this._isOpen?uu:(this._isOpen=!0,this.scheduleUnsafe(e)));release=Er(e=>this._isOpen?uu:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=Us(e=>this._isOpen?e(Ls):(this.waiters.push(e),As(()=>{let t=this.waiters.indexOf(e);t===-1?this.scheduled!==void 0&&(t=this.scheduled.indexOf(e),t!==-1&&this.scheduled.splice(t,1)):this.waiters.splice(t,1)})));closeUnsafe(){return this._isOpen?(this._isOpen=!1,!0):!1}close=As(()=>this.closeUnsafe());whenOpen=e=>hc(this.await,()=>e);isOpen(){return this._isOpen}},fu=e=>new du(e??!1),pu=BigInt(0),mu={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:pu,endTime:pu,exit:Cc},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},hu=e=>Object.assign(Object.create(mu),e),gu=e=>e?$i(e.annotations,jo)?e._tag===`Span`?gu(Ti(e.parent)):vi():yi(e):vi(),_u=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&$i(n.annotations,jo),i=n?.parent===void 0?n?.root?vi():gu(e.cache.span):yi(n.parent),a;if(r)a=hu({name:t,parent:i,annotations:Ji(n?.annotations??Gi(),jo,!0)});else{let r=e.cache.tracer??Fo,o=e.getRef(Cu),s=e.getRef(Vo),c=e.getRef(Ho),l=e.getRef(Uo),u=n?.level??e.getRef(Mo),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??Gi(),links:d,startTime:s?o.currentTimeNanosUnsafe():pu,kind:n?.kind??`internal`,root:n?.root??bi(i),sampled:n?.sampled??(xi(i)&&i.value.sampled===!1?!1:!Fu(e.getRef(No),u))});for(let e in c)a.attribute(e,c[e]);if(n?.attributes!==void 0)for(let e in n.attributes)a.attribute(e,n.attributes[e])}return a},vu=(e,t)=>(t=typeof t==`function`?t:pt,Oc(zo,n=>({name:e,stack:t,parent:n}))),yu=(e,t,n,r)=>As(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():pu,t)}),bu=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return Er(t=>{let i=_u(t,e,n),a=t.getRef(Cu),o=t.getRef(Vo);return Tl(t,e=>yu(i,e,a,o)),r(i)})},xu=Nc(ko),Su=function(){let e=Qn(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=E;return t._tag===`Span`&&(n=Ko(n),r=vu(t.name,n?.captureStackTrace)),e?xu(r(arguments[0]),t):e=>xu(r(e),t)},Cu=aa(`effect/Clock`,{defaultValue:()=>new Tu}),wu=2**31-1,Tu=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=As(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Ou()}currentTimeNanos=As(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Du()}monotonicTimeNanos=As(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(oo(e))}sleepMillis(e){return e<=0?Ms:Number.isFinite(e)?Us(t=>{let n=e>wu?this.sleepMillis(e-wu):Ls,r=setTimeout(()=>t(n),Math.min(e,wu));return As(()=>clearTimeout(r))}):Ws}},Eu=BigInt(1e6),Du=function(){let e=globalThis.process?.hrtime;if(typeof e?.bigint==`function`)return()=>e.bigint();if(typeof performance<`u`&&typeof performance.now==`function`)return()=>BigInt(Math.round(performance.now()*1e6));let t=BigInt(0);return()=>{let e=BigInt(Date.now())*Eu;return e>t&&(t=e),t}}(),Ou=function(){let e=BigInt(1e9),t;return()=>{let n=Du(),r=BigInt(Date.now())*Eu;if(t===void 0)t=r-n;else{let i=t+n;(r>i?r-i:i-r)>e&&(t=r-n)}return t+n}}(),ku=e=>Er(t=>e(t.getRef(Cu))),Au=e=>ku(t=>t.sleep(Ha(e)));kr(`TimeoutError`),kr(`IllegalArgumentError`),kr(`ExceededCapacityError`);var ju=`~effect/Cause/AsyncFiberError`,Mu=class extends kr(`AsyncFiberError`){[ju]=ju;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Nu=`~effect/Cause/UnknownError`,Pu=class extends kr(`UnknownError`){[Nu]=Nu;constructor(e,t){super({message:t,cause:e})}},Fu=hi(pi(fi,e=>{switch(e){case`All`:return-(2**53-1);case`Fatal`:return 5e4;case`Error`:return 4e4;case`Warn`:return 3e4;case`Info`:return 2e4;case`Debug`:return 1e4;case`Trace`:return 0;case`None`:return 2**53-1}})),Iu={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Iu.gray,Iu.blue,Iu.green,Iu.yellow,Iu.red,Iu.bgBrightRed,Iu.black;var Lu=(e,t,n)=>{let r=e.getRef(Ro);if(r.size===0||n&&!Qo(t))return;let i={cause:t,fiber:e,timestamp:e.getRef(Cu).currentTimeNanosUnsafe()};r.forEach(e=>e.report(i))},Ru=pr,zu=cr,Bu=lr,Vu=dr,Hu=rs,Uu=is,Wu=$o,Gu=jr,Ku=Fr;Di()(`effect/Cause/StackTrace`),Di()(`effect/Cause/InterruptorStackTrace`);var qu=br,Ju=Cr,Yu=wr,Xu=Cc,Zu=xc,Qu={"~effect/Deferred":{_A:E,_E:E},pipe(){return st(this,arguments)}},$u=function(){this.resumes=void 0,this.effect=void 0};$u.prototype=Qu;var ed=()=>new $u,td=()=>As(()=>ed()),nd=e=>Us(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),As(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),rd=T(2,(e,t)=>As(()=>ad(e,t))),id=T(2,(e,t)=>rd(e,br(t))),ad=(e,t)=>{if(e.effect)return!1;if(e.effect=t,e.resumes){let n=e.resumes;e.resumes=void 0;for(let e=0;e<n.length;e++)n[e](t)}return!0},od=_l,sd=xl,cd=pl,ld=ml,ud=fl,dd=sl,fd=`~effect/Layer`,pd=`~effect/Layer/MemoMap`,md=(e,t)=>{let n={observers:0,deferred:ed(),scope:od(),finalizer:r=>js(()=>--n.observers>0?Ls:(e.map.delete(t),dd(n.scope,r)))};return n},hd=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,hl(t,{},e.finalizer),!0),gd={[fd]:{_ROut:E,_E:E,_RIn:E},pipe(){return st(this,arguments)}},_d=e=>{let t=Object.create(gd);return t.build=e,t},vd=e=>_d((t,n)=>{let r=ud(n);return El(e(t,r),e=>e._tag===`Failure`?dd(r,e):Ls)}),yd=e=>{let t=vd((n,r)=>n.getOrElseMemoize(t,r,e));return t},bd=class{get[pd](){return pd}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(hd(n,t),n.deferred.effect??nd(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return js(()=>{let r;return wl(js(()=>{let i=this.get(e,t);if(i)return i;let a=md(this,e);return hd(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&ad(r,e)})})}},xd=()=>new bd,Sd=e=>new bd(e),Cd=class e extends Di()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=Xi(t,e);return n?Sd(n):xd()}},wd=T(3,(e,t,n)=>Nc(vc(e.build(t,n),Ji(Cd,t)),Cd,t)),Td=function(){return arguments.length===1?e=>Ed(qi(arguments[0],e)):Ed(qi(arguments[0],arguments[1]))},Ed=e=>_d(ut(M(e))),Dd=function(){return arguments.length===1?e=>Od(()=>qi(arguments[0],e())):Od(()=>qi(arguments[0],arguments[1]()))},Od=e=>yd(ut(As(e))),kd=function(){return arguments.length===1?e=>Ad(arguments[0],e):Ad(arguments[0],arguments[1])},Ad=(e,t)=>jd(vc(t,t=>qi(e,t))),jd=e=>yd((t,n)=>sd(e,n)),Md=(e,t,n)=>{let r=ud(n,`parallel`);return Hl(e,e=>e.build(t,ud(r,`sequential`)),{concurrency:e.length}).pipe(vc(e=>ia(...e)))},Nd=(e,t,n)=>vd((r,i)=>hc(Array.isArray(t)?Md(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Mc(t),vc(e=>n(e,t))))),Pd=T(2,(e,t)=>Nd(e,t,E)),Fd=T(2,(e,t)=>Nd(e,t,(e,t)=>ra(t,e))),Id=`~effect/DateTime`,Ld=`~effect/DateTime/TimeZone`,Rd={[Id]:Id,pipe(){return st(this,arguments)},[An](){return this.toString()},toJSON(){return Wd(this).toJSON()}},zd={...Rd,_tag:`Utc`,[Ft](){return Vt(this.epochMilliseconds)},[$t](e){return Vd(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${Wd(this).toJSON()})`}};({...Rd});var Bd={[Ld]:Ld,[An](){return this.toString()}};({...Bd}),{...Bd};var Vd=e=>D(e,Id),Hd=e=>{let t=Object.create(zd);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},Ud=()=>Hd(Date.now()),Wd=e=>new Date(e.epochMilliseconds),Gd=e=>e.epochMilliseconds;globalThis.String;var Kd=di,qd=T(2,(e,t)=>zc(e,Xd,e=>t(e))),Jd=e=>e._tag===`Fail`&&Gu(e.error),Yd=e=>{let t,n=!1;for(let r of e.reasons)Jd(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?ca(e):n?ca(zu(e.reasons.filter(e=>!Jd(e)))):sa(t)},Xd=e=>{let t=Yd(e);return ua(t)?t:sa(t.success.value)},Zd=e=>{let t=Yd(e);return ua(t)?Ju(t.failure):qu(t.success.value)},Qd=Qn,$d=Hl,ef=zs,tf=Bs,P=M,nf=js,rf=As,af=Ls,of=Us,sf=Gs,F=ks,cf=Os,lf=Ps,uf=Fs,df=Rs,ff=Er,pf=hc,mf=_c,hf=fc,gf=pc,_f=qc,vf=nl,yf=vc,bf=ec,xf=mc,Sf=Wc,Cf=Ic,I=Gc,wf=Hc,Tf=Au,Ef=Jc,Df=kc,Of=jc,kf=Mc,Af=Dc,jf=Nc,Mf=Sl,Nf=Dl,Pf=kl,Ff=El,If=Ml,Lf=jl,Rf=Bl,zf=Fc,Bf=bu,Vf=Su,Hf=Ql,Uf=Xl,Wf=$l,Gf=eu,Kf=iu,qf=ru,Jf=nu,Yf=tu,L=cu,Xf=su,Zf=ou,Qf=au,$f=Ks,R=Ys;Di()(`effect/Effect/Transaction`);var ep=yc,tp=bc,np=gc,rp=Zs,ip=`~effect/BigDecimal`,ap={[ip]:ip,[Ft](){let e=pp(this);return Rt(Ht(String(e.value)),Vt(e.scale))},[$t](e){return op(e)&&vp(this,e)===0},toString(){return`BigDecimal(${bp(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[An](){return this.toJSON()},pipe(){return st(this,arguments)}},op=e=>D(e,ip),sp=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(ap);return n.value=e,n.scale=t,n},cp=(e,t)=>{let n=sp(e,t);return n.normalized=n,n},lp=BigInt(0),up=BigInt(1),dp=BigInt(10),fp=cp(lp,0),pp=e=>{if(e.normalized===void 0){if(e.value===lp)e.normalized=fp;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=cp(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},mp=100,hp=[up],gp=(e,t)=>e===t?0:e<t?-1:1,_p=(e,t)=>{let n=`${e.value<lp?-e.value:e.value}`,r=`${t.value<lp?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==lp)return i<lp?-1:1;let a=Math.max(n.length,r.length);return di(n.padEnd(a,`0`),r.padEnd(a,`0`))},vp=(e,t)=>{if(e.scale===t.scale)return gp(e.value,t.value);let n=yp(e),r=yp(t);if(n!==r)return n<r?-1:1;if(n===0)return 0;let i=e.scale-t.scale,a=Math.abs(i);if(a>mp)return n===-1?_p(t,e):_p(e,t);let o=hp[a]??=dp**BigInt(a);return i>0?gp(e.value,t.value*o):gp(e.value*o,t.value)},yp=e=>e.value===lp?0:e.value<lp?-1:1,bp=e=>{let t=pp(e);if(Math.abs(t.scale)>=16)return xp(t);let n=t.value<lp,r=`${n?-t.value:t.value}`,i=t.scale>0?r.padStart(t.scale+1,`0`):r.padEnd(r.length-t.scale,`0`),a=i.length-t.scale,o=t.scale>0?`${i.slice(0,a)}.${i.slice(a)}`:i;return n?`-${o}`:o},xp=e=>{if(Sp(e))return`0e+0`;let t=pp(e),n=`${t.value}`,r=t.value<lp?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},Sp=e=>e.value===lp,Cp=Ud,wp=Gd;Di()(`effect/DateTime/CurrentTimeZone`);var Tp=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Ep=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Ep[Tp.charCodeAt(e)]=e;Ep[61]=0;var Dp=`~effect/http/Cookies`,Op=`~effect/http/Cookies/Cookie`;So(`CookiesError`);var kp={[Dp]:Dp,...Mn,toJSON(){return{_id:`effect/Cookies`,cookies:ma(this.cookies,e=>e.toJSON())}},pipe(){return st(this,arguments)}},Ap=e=>{let t=Object.create(kp);return t.cookies=e,t},jp=e=>{let t={};for(let n of e)zn(t,n.name,n);return Ap(t)},Mp=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=Np(e.trim());t&&n.push(t)}return jp(n)};function Np(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``);if(t.length===0)return;let n=t[0].indexOf(`=`);if(n===-1)return;let r=t[0].slice(0,n);if(!Pp.test(r))return;let i=t[0].slice(n+1),a=Ip(i);if(t.length===1)return Object.assign(Object.create(Fp),{name:r,value:a,valueEncoded:i});let o={};for(let e=1;e<t.length;e++){let n=t[e],r=n.indexOf(`=`),i=r===-1?n:n.slice(0,r).trim(),a=r===-1?void 0:n.slice(r+1).trim();switch(i.toLowerCase()){case`domain`:{if(a===void 0)break;let e=a.trim().replace(/^\./,``);e&&(o.domain=e);break}case`expires`:{if(a===void 0)break;let e=new Date(a);isNaN(e.getTime())||(o.expires=e);break}case`max-age`:{if(a===void 0)break;let e=parseInt(a,10);isNaN(e)||(o.maxAge=to(e));break}case`path`:if(a===void 0)break;a[0]===`/`&&(o.path=a);break;case`priority`:if(a===void 0)break;switch(a.toLowerCase()){case`low`:o.priority=`low`;break;case`medium`:o.priority=`medium`;break;case`high`:o.priority=`high`}break;case`httponly`:o.httpOnly=!0;break;case`secure`:o.secure=!0;break;case`partitioned`:o.partitioned=!0;break;case`samesite`:if(a===void 0)break;switch(a.toLowerCase()){case`lax`:o.sameSite=`lax`;break;case`strict`:o.sameSite=`strict`;break;case`none`:o.sameSite=`none`}}}return Object.assign(Object.create(Fp),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var Pp=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,Fp={[Op]:Op,...Mn,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},Ip=e=>{try{return decodeURIComponent(e)}catch{return e}},Lp=new WeakMap,Rp=`~effect/Redacted`,zp=e=>D(e,Rp),Bp=(e,t)=>{let n=Object.create(Vp);return t?.label&&(n.label=t.label),Lp.set(n,e),n},Vp={[Rp]:{_A:e=>e},label:void 0,...Xn,toJSON(){return this.toString()},toString(){return`<redacted${St(this.label)?`:`+this.label:``}>`},[Ft](){return O(Lp.get(this))},[$t](e){return zp(e)&&en(Lp.get(this),Lp.get(e))}},Hp=Symbol.for(`~effect/http/Headers`),Up=Object.defineProperties(Object.create(null),{[Hp]:{value:Hp},[gn]:{value(e){return $p(this,$i(e,tm))}},toJSON:{value(){return vn(this)}},[$t]:{value(e){return Gp(this,e)}},[Ft]:{value(){return Wt(this)}},toString:{value:Mn.toString},[An]:{value:Mn[An]}}),Wp=e=>Object.assign(Object.create(Up),e),Gp=_a(zr()),Kp=Object.create(Up),qp=e=>{if(e===void 0)return Kp;if(Symbol.iterator in e){let t=Object.create(Up);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(Up);for(let[n,r]of Object.entries(e))Array.isArray(r)?t[n.toLowerCase()]=r.join(`, `):r!==void 0&&(t[n.toLowerCase()]=r);return t},Jp=e=>Object.setPrototypeOf(e,Up),Yp=T(3,(e,t,n)=>{let r=Wp(e);return r[t.toLowerCase()]=n,r}),Xp=T(2,(e,t)=>Wp({...e,...qp(t)})),Zp=T(2,(e,t)=>{let n=Wp(e);return Object.assign(n,t),n}),Qp=T(2,(e,t)=>{let n=Wp(e);return delete n[t.toLowerCase()],n}),$p=T(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=Bp(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=Bp(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),em=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(typeof r==`string`){if(r.toLowerCase()===e.toLowerCase())return!0}else if(e.search(r)!==-1)return!0}return!1},tm=aa(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`]}),nm=`~effect/http/UrlParams`,rm=e=>D(e,nm),im={...Xn,[nm]:nm,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[$t](e){return cm(this,e)},[Ft](){return Kt(this.params.flat())}},am=e=>{let t=Object.create(im);return t.params=e,t},om=e=>{if(rm(e))return e;let t=sm(e),n=[];for(let e=0;e<t.length;e++)if(Array.isArray(t[e][0])){let[r,i]=t[e];n.push([`${r[0]}[${r.slice(1).join(`][`)}]`,i])}else n.push(t[e]);return am(n)},sm=e=>{let t=typeof e[Symbol.iterator]==`function`?ya(e):Object.entries(e),n=[];for(let[e,r]of t)if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t]!==void 0&&n.push([e,String(r[t])]);else if(typeof r==`object`&&r){let t=sm(r);for(let[r,i]of t)n.push([[e,...typeof r==`string`?[r]:r],i])}else r!==void 0&&n.push([e,String(r)]);return n},cm=Lr((e,t)=>lm(e.params,t.params)),lm=Aa(fa([zr(),zr()])),um=am([]),dm=T(2,(e,t)=>{let n=om(t).params.slice(),r=new Set;for(let e=0;e<n.length;e++)r.add(n[e][0]);for(let t=0;t<e.params.length;t++)r.has(e.params[t][0])||n.push(e.params[t]);return am(n)});function fm(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}var pm=`~structural`,mm=`~sentinels`,hm=`~constructor`,gm=ht(e=>{let t=fm(e)?.identifier;return typeof t==`string`?t:e.getExpected(gm)}),z=Symbol(),_m=qu,vm=_m(z),B=_m(z),ym=e=>e===z?vi():yi(e),bm=e=>e._tag===`None`?vm:_m(e.value),xm=`~effect/SchemaIssue/Issue`;function Sm(e){return D(e,xm)&&e[xm]===xm}function Cm(e){return Object.hasOwn(e,`input`)}var wm=class{[xm]=xm;constructor(e,t){t?.reportInput===!0&&e!==z&&(this.input=e)}},Tm=class extends wm{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},Em=class extends wm{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},Dm=class extends wm{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},Om=class extends wm{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},km=class extends wm{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Am=class extends wm{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},jm=class extends wm{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},Mm=class extends wm{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},Nm=class extends wm{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},Pm=class extends wm{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function Fm(e,t,n){if(Sm(e))return e;if(typeof e==`string`)return new Mm({message:e},t,n);let r=typeof e.issue==`string`?new Mm({message:e.issue},t,n):e.issue;return new Dm(e.path,r)}function Im(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new Mm(void 0,t,n):Fm(e,t,n)}function Lm(e,t,n,r){return Array.isArray(t)?wa(t)?t.length===1?Fm(t[0],n,r):new Am(e,ka(t,e=>Fm(e,n,r)),n,r):void 0:Im(t,n,r)}var Rm=e=>{let t=qm(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Hm(gm(e.ast),e);case`InvalidValue`:{let t=Vm(e);if(t!==void 0)return Hm(t,e);let n=Bm(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=Bm(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=Bm(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},zm=e=>qm(e.issue)??qm(e);function Bm(e){return Cm(e)?k(e.input):void 0}function Vm(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Hm(e,t){let n=Bm(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Um(e){let t=e.annotations?.expected;if(typeof t==`string`)return t;switch(e._tag){case`Filter`:return`<filter>`;case`FilterGroup`:return e.checks.map(e=>Um(e)).join(` & `)}}function Wm(){return e=>Km(e,``)}var Gm=Wm();function Km(e,t){let n;switch(e._tag){case`Filter`:{let r=zm(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Km(e.issue,t);let r=Vm(e.issue);n=r===void 0?Hm(Um(e.filter),e):Hm(r,e.issue)}break}case`Encoding`:return Km(e.issue,t);case`Pointer`:return Km(e.issue,t+Tn(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Km(e,t)).join(`
|
|
12
|
+
`);n=qm(e)??Hm(gm(e.ast),e);break;default:n=Rm(e)}return t?`${n}\n at ${t}`:n}function qm(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return qm(e.issue);let t=(e._tag===`Filter`?e.filter.annotations:`annotations`in e?e.annotations:e.ast.annotations)?.[e._tag===`MissingKey`?`messageMissingKey`:e._tag===`UnexpectedKey`?`messageUnexpectedKey`:`message`];if(typeof t==`string`)return t}function Jm(e){let t;for(let n of e.reasons){if(!Ru(n)||!Sm(n.error))return;t??=n.error}return t}function Ym(e,t){let n=Jm(e);if(n===void 0)throw Error(t,{cause:e});return n}var Xm=e=>Object.assign(Object.create(ct),e),Zm=Xm({_tag:`Passthrough`});function Qm(){return Zm}function $m(e){return Xm({_tag:`Transform`,transform:e})}function eh(e){return Xm({_tag:`TransformEffect`,transform:e})}function th(){return $m(globalThis.String)}function nh(){return $m(globalThis.Number)}function rh(){return $m(e=>new globalThis.Date(e))}function ih(e){return eh((t,n)=>df({try:()=>JSON.parse(t,e?.reviver),catch:()=>new Mm({expected:`a valid JSON string`},t,n)}))}function ah(e){return eh((t,n)=>df({try:()=>{let n=JSON.stringify(t,e?.replacer,e?.space);if(n===void 0)throw TypeError(`Value cannot be represented as JSON`);return n},catch:()=>new Mm({expected:`a JSON-serializable value`},t,n)}))}var oh=class extends lt{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new oh(this.encode,this.decode)}},sh=`~effect/SchemaTransformation/Transformation`,ch=class extends lt{[sh]=sh;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new ch(this.encode,this.decode)}};function lh(e){return D(e,sh)&&e[sh]===sh}var uh=e=>lh(e)?e:new ch(e.decode,e.encode);function dh(e){return new ch($m(e.decode),$m(e.encode))}var fh=new ch(Qm(),Qm());function ph(){return fh}var mh=new ch(nh(),th()),hh=new ch(rh(),$m(En)),gh=new ch(rh(),$m(e=>e.getTime())),_h=e=>jt(e)&&typeof e.message==`string`,vh=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:Sh(e.cause)}):Error(e.message);return typeof e.name==`string`&&e.name!==`Error`&&(t.name=e.name),typeof e.stack==`string`&&(t.stack=e.stack),t},yh=e=>{try{let t=kn(e);return t===void 0?k(e):JSON.parse(t)}catch{return k(e)}},bh=(e,t,n)=>{let r={name:e.name,message:typeof e.message==`string`?e.message:``};return t?.includeStack&&typeof e.stack==`string`&&(r.stack=e.stack),!t?.excludeCause&&e.cause!==void 0&&(r.cause=n(e.cause)),r},xh=e=>{let t=new WeakSet,n=r=>{if(Nt(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=bh(r,e,n);return t.delete(r),i}return yh(r)};return n},Sh=e=>_h(e)?vh(e):e,Ch=e=>dh({decode:Sh,encode:xh(e)});function wh(e){return new ch(ih(e??{}),ah(e))}function Th(e){return t=>t._tag===e}var Eh=Th(`Declaration`),Dh=Th(`Never`),Oh=Th(`Literal`),kh=Th(`UniqueSymbol`),Ah=Th(`Arrays`),jh=Th(`Objects`),Mh=Th(`Suspend`),Nh=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},Ph={},Fh=class{isOptional;isMutable;constructorDefault;annotations;constructor(e,t,n=void 0,r=void 0){this.isOptional=e,this.isMutable=t,this.constructorDefault=n,this.annotations=r}},Ih=`~effect/Schema`,Lh=class{[Ih]=Ih;annotations;checks;encoding;context;constructor(e=void 0,t=void 0,n=void 0,r=void 0){this.annotations=e,this.checks=t,this.encoding=n,this.context=r}toString(){return`<${this._tag}>`}},Rh=class extends Lh{_tag=`Declaration`;typeParameters;run;encodingChecks;encodingRun;constructor(e,t,n,r,i,a,o,s){super(n,r,i,a),this.typeParameters=e,this.run=t,this.encodingChecks=o,this.encodingRun=s}getParser(){let e;return(t,n)=>t===z?vm:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=f_(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new Rh(a,r,this.annotations,t,void 0,this.context,n,i)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks,this.run,this.encodingRun)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks,this.encodingRun??this.run,this.run)}getExpected(){let e=this.annotations?.expected;return typeof e==`string`?e:`<Declaration>`}},zh=new class extends Lh{_tag=`Null`;getParser(){return A_(this,null)}getExpected(){return`null`}},Bh=class extends Lh{_tag=`Undefined`;getParser(){return A_(this,void 0)}toCodecJson(){return e_(this,[Vh])}getExpected(){return`undefined`}},Vh=new Nh(zh,new ch($m(()=>void 0),$m(()=>null))),Hh=new Bh,Uh=new class extends Lh{_tag=`Unknown`;getParser(){return j_(this,At)}getExpected(){return`unknown`}},Wh=new class extends Lh{_tag=`ObjectKeyword`;getParser(){return j_(this,Mt)}getExpected(){return`object | array | function`}};function Gh(e){return typeof e==`number`?`parts[${e}]`:e}function Kh(e,t,n){if(n.has(e))return!0;if(e.encoding)throw Error(`TemplateLiteral parts cannot have an encoding at ${Gh(t)}`);let r;switch(e._tag){case`String`:case`Number`:case`BigInt`:r=!0;break;case`Literal`:r=!e.checks;break;case`TemplateLiteral`:{let i=Gh(t);r=!e.checks&&e.parts.every((e,t)=>Kh(e,`${i}.parts[${t}]`,n));break}case`Union`:{let i=Gh(t);r=!e.checks&&e.types.every((e,t)=>Kh(e,`${i}.types[${t}]`,n));break}default:return!1}return r&&n.add(e),r}var qh=class extends Lh{_tag=`TemplateLiteral`;parts;encodedParts;literals;suffixLengths;constructor(e,t,n,r,i){super(t,n,r,i);let a=[],o=[],s=new Set;for(let t=0;t<e.length;t++){let n=e[t];if(!Kh(n,t,s))throw Error(`Invalid TemplateLiteral part ${n._tag}`);a.push(n),o.push(n._tag===`Literal`?globalThis.String(n.literal):void 0)}let c=Array(a.length+1);c[a.length]=0;for(let e=a.length-1;e>=0;e--)c[e]=c[e+1]+(o[e]?.length??0);this.parts=e,this.encodedParts=a,this.literals=o,this.suffixLengths=c}getParser(e){let t=e(v_(Qh,new rg(!1,this.parts.map(F_),[]),Yh(this)));return(e,n)=>{if(e===z)return vm;let r=t(e,n);return r._tag===`Success`?B:tp(r,{onSuccess:()=>e,onFailure:t=>new Am(this,[t],e,n)})}}getExpected(){return`string`}matchPart(e,t){return M_(this,e,t)===void 0?void 0:e}};function Jh(e){let t=ht(e=>{if(e._tag!==`Union`)return e;let n=f_(e.types,t);return(e.options?.mode??`anyOf`)===`anyOf`&&n===e.types?e:new Pg(n,e.options===void 0?void 0:{...e.options,mode:`anyOf`},e.annotations,e.checks,void 0,e.context)}),n=new qh(e.map(e=>t(E_(e))));return v_(n,new rg(!1,e.map(F_),[]),Yh(n))}function Yh(e){return new ch(eh((t,n)=>{let r=M_(e,t,n);return r?P(r):F(new Mm({expected:`a string matching template literal parts`},t,n))}),$m(e=>e.join(``)))}var Xh=class extends Lh{_tag=`Literal`;literal;constructor(e,t,n,r,i){if(super(t,n,r,i),typeof e==`number`&&!globalThis.Number.isFinite(e))throw Error(`A numeric literal must be finite, got ${k(e)}`);this.literal=e}getParser(){return A_(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?Zh(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:Zh(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function Zh(e){let t=globalThis.String(e.literal);return e_(e,[new Nh(new Xh(t),new ch($m(()=>e.literal),$m(()=>t)))])}var Qh=new class extends Lh{_tag=`String`;getParser(){return j_(this,St)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&H_(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},$h=class extends Lh{_tag=`Number`;getParser(){return j_(this,Ct)}matchKey(e,t){return this._match(L_,e,t)}matchPart(e,t){return this._match(I_,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:H_(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(eg(this.checks,`effect/schema/isFinite`)||eg(this.checks,`effect/schema/isInt`))?this:e_(this,[Yg])}toCodecStringTree(){return this.toCodecJson()===this?e_(this,[B_]):e_(this,[V_])}getExpected(){return`number`}};function eg(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&eg(e.checks,t))}var tg=new $h,ng=new class extends Lh{_tag=`Boolean`;getParser(){return j_(this,wt)}getExpected(){return`boolean`}},rg=class extends Lh{_tag=`Arrays`;isMutable;elements;rest;encodingChecks;constructor(e,t,n,r,i,a,o,s){super(r,i,a,o),this.isMutable=e,this.elements=t,this.rest=n,this.encodingChecks=s;let c=!1;for(let e=0;e<t.length;e++)if(x_(t[e]))c=!0;else if(c)throw Error(`A required element cannot follow an optional element. ts(1257)`);if(c&&n.length>1)throw Error(`A required element cannot follow an optional element. ts(1257)`);for(let e=1;e<n.length;e++)if(x_(n[e]))throw Error(`An optional element cannot follow a rest element. ts(1266)`)}getParser(e,t=e){let n=this,r,i,a=n.elements.length,o=Math.max(0,n.rest.length-1);function s(e,t){return t<a?r[t]:t>=e?i[t-e+1]:i[0]}let c=e=>{let{input:t,len:r,options:i}=e;if(n.rest.length===0&&r>a)for(let o=a;o<r;o++){let r=new km(n,t[o],i),a=new Dm([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return F(new Am(n,[a],t,i))}return e.issues?F(new Am(n,e.issues,t,i)):_m(e.output)},l=(e,t)=>{let r=e.length,i={ast:n,getParser:s,input:e,len:r,tailThreshold:Math.max(a,r-o),output:new globalThis.Array(r),issues:void 0,options:t},u=n.rest.length===0?a:Math.max(r,a+o),d=t.concurrency===void 0?1:Wl(t.concurrency),f=d===1?og(i,e,0,u):sg(i,e,{concurrency:d,end:u});if(!f)return c(i);if(N(f))return np(f,()=>c(i));let p=!0;return nf(()=>p?(p=!1,pf(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===z)return vm;try{return Array.isArray(e)?(r||(r=n.elements.map(e=>({ast:e,parser:t(e)})),i=n.rest.map(e=>({ast:e,parser:t(e)}))),l(e,a)):F(new jm(n,e,a))}catch(e){return uf(e)}}}_rebuild(e,t,n){let r=f_(this.elements,e),i=f_(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new rg(this.isMutable,r,i,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}getExpected(){return`array`}};function ig(e,t,n,r){if(n._tag===`Failure`)return cg(e,e.ast,r,n);let i=n===B?t:n[A];if(i!==z)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(x_(t.ast))return;let n=new Dm([r],new Om(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return Yu(new Am(e.ast,[n],e.input,e.options))}}var ag={onItem(e,t,n){let r=n<e.len?t:z;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:ig},og=Gl()(ag),sg=ql()(ag),cg=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Jm(r.cause);if(i===void 0)return Ju(Hu(r.cause,r=>new Am(t,[new Dm([n],r)],e.input,e.options)));let a=new Dm([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return Yu(new Am(t,[a],e.input,e.options))},lg=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function ug(e,t,n=Ph){let r,i;function a(t){switch(t._tag){case`String`:case`TemplateLiteral`:return(r??=Object.keys(e)).filter(e=>t.matchPart(e,n)!==void 0);case`Number`:return(r??=Object.keys(e)).filter(e=>t.matchKey(e,n)!==void 0);case`Symbol`:return(i??=Object.getOwnPropertySymbols(e)).filter(r=>Object.prototype.propertyIsEnumerable.call(e,r)&&t.matchKey(r,n)!==void 0);case`Union`:return[...new Set(t.types.flatMap(a))];default:return[]}}return a(N_(E_(t)))}var dg=class{name;type;constructor(e,t){this.name=e,this.type=t}};function fg(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(fg);default:return!1}}function pg(e){let t=n_(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(pg);default:return!1}}function mg(e){return fg(e)&&pg(e)}var hg=class{parameter;type;constructor(e,t){if(!mg(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,x_(t)&&!k_(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},gg=class extends Lh{_tag=`Objects`;propertySignatures;indexSignatures;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.propertySignatures=e,this.indexSignatures=t,this.encodingChecks=o}getParser(e,t=e){let n=this,r=n.propertySignatures.length,i=n.indexSignatures.length;if(!r&&!i)return j_(n,kt);let a,o,s=()=>(a||(a=n.propertySignatures.map(e=>({parser:t(e.type),name:e.name,type:e.type})),o=i?n.indexSignatures.map(n=>({is:n,parserKey:e(N_(n.parameter)),parserValue:t(n.type)})):void 0),a),c=()=>{let e=new Set(n.propertySignatures.map(e=>typeof e.name==`number`?globalThis.String(e.name):e.name)),t=(t,i,a,o,s)=>{if(s._tag===`Failure`)return cg(t,n,i,s)??Xu;let c=s===B?o:s[A];if(a!==z&&c!==z){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return Xu;zn(t.out,a,c)}return Xu},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!N(t))return pf(vf(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return cg(e,n,r,a)??Xu;let o=a===B?r:a[A],s=e.input[r],l=i.parserValue(s,e.options);return N(l)?t(e,r,o,s,l):pf(vf(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return N(a)?t(e,n,n,i,a):pf(vf(a),r=>t(e,n,n,i,r))},u=i?ql()({onItem:(e,[t,n])=>n.is.parameter===Qh?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return rp(function*(t,d){if(t===z)return z;if(!(typeof t==`object`&&t&&!Array.isArray(t)))return yield*F(new jm(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,g=d.onExcessProperty===`error`,_=d.concurrency===void 0?1:Wl(d.concurrency),v=i&&g?n.indexSignatures.map(e=>ug(f,e.parameter,d)):void 0;if(g){let r=v?new Set(e):e;if(v)for(let e of v)for(let t of e)r.add(t);let i=Reflect.ownKeys(f);for(let e=0;e<i.length;e++){let a=i[e];if(!r.has(a)&&Object.prototype.propertyIsEnumerable.call(f,a)){let e=new km(n,f[a],d),r=new Dm([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*F(new Am(n,[r],t,d))}}}if(r){let e=_===1?yg(m,a):bg(m,a,{concurrency:_});e&&(yield*e)}if(i&&_===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===Qh?l:c,r=v?.[e]??(t.is.parameter===Qh?Object.keys(f):ug(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!N(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=Da();for(let t=0;t<i;t++){let n=o[t],r=v?.[t]??(n.is.parameter===Qh?Object.keys(f):ug(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:_});t&&(yield*t)}return m.issues?yield*F(new Am(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return pf(vf(n),n=>{let i=_g(e,r,n);if(i)return i;let o=()=>_m(e.out),s=yg(e,a.slice(t+1));return s?np(s,o):o()})};return(e,t)=>{if(e===z)return vm;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Wl(t.concurrency)!==1)return(l??=c())(e,t);if(!(typeof e==`object`&&e&&!Array.isArray(e)))return F(new jm(n,e,t));let r=s(),i=e,a={},o={ast:n,input:i,out:a,issues:void 0,options:t};try{for(let e=0;e<r.length;e++){let n=r[e],s=n.name,c=Mg(i,s),l=c?i[s]:z,d=n.parser(l,t);if(!N(d))return u(o,e,d);if(d===B){c&&zn(a,s,l);continue}let f=_g(o,n,d);if(f)return f}}catch(e){return uf(e)}return _m(a)}}_rebuild(e,t,n,r){let i=f_(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new dg(t.name,n)}),a=f_(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new hg(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new gg(i,a,this.annotations,n,void 0,this.context,r)}flip(e){return this._rebuild(e,e,this.encodingChecks,this.checks)}recur(e,t=e){return this._rebuild(e,t,this.checks,this.encodingChecks)}getExpected(){return this.propertySignatures.length===0&&this.indexSignatures.length===0?`object | array`:`object`}};function _g(e,t,n){if(n._tag===`Failure`)return cg(e,e.ast,t.name,n);if(n===B)return;let r=n[A];if(r!==z){zn(e.out,t.name,r);return}if(delete e.out[t.name],!x_(t.type)){let n=new Dm([t.name],new Om(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return Yu(new Am(e.ast,[n],e.input,e.options))}}var vg={onItem(e,t){if(!Mg(e.input,t.name))return t.parser(z,e.options);let n=e.input[t.name];return zn(e.out,t.name,n),t.parser(n,e.options)},step:_g},yg=Gl()(vg),bg=ql()(vg);function xg(e,t){return e?t?[...e,...t]:e:t}function Sg(e,t,n){return new gg(Reflect.ownKeys(e).map(t=>new dg(t,e[t].ast)),[],n,t)}function Cg(e){return e.ast}function wg(e,t,n){return new Pg(e.map(Cg),t,void 0,n)}function Tg(e,t){if(e.encoding||t.some(e=>e.encoding))throw Error(`StructWithRest does not support encodings`);let n=e.propertySignatures,r=e.indexSignatures,i=e.checks;for(let e of t){for(let t of e.propertySignatures)if(n.some(e=>e.name===t.name))throw Error(`Duplicate identifier: ${JSON.stringify(t.name)}. ts(2300)`);n=n.concat(e.propertySignatures),r=r.concat(e.indexSignatures),i=xg(i,e.checks)}return new gg(n,r,void 0,i)}var Eg=gt(e=>{for(;;){if(Mh(e))return Uh;let t=e.encoding;if(!t)return e.recur?.(Eg,E)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==E))return Uh;e=t[t.length-1].to}});function Dg(e){switch(e._tag){case`Null`:return[`null`];case`Undefined`:return[`undefined`];case`String`:case`TemplateLiteral`:return[`string`];case`Number`:return[`number`];case`Boolean`:return[`boolean`];case`Symbol`:case`UniqueSymbol`:return[`symbol`];case`BigInt`:return[`bigint`];case`Arrays`:return[`array`];case`ObjectKeyword`:return[`object`,`array`,`function`];case`Objects`:return e.propertySignatures.length||e.indexSignatures.length?[`object`]:[`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`];case`Enum`:return Array.from(new Set(e.enums.map(([,e])=>typeof e)));case`Literal`:return[typeof e.literal];case`Union`:return Array.from(new Set(e.types.flatMap(Dg)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function Og(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[mm];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!x_(t)){if(Oh(t))return[{key:e.name,literal:t.literal}];if(kh(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!x_(e)){if(Oh(e))return[{key:t,literal:e.literal}];if(kh(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>Og(Eg(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return Og(e.thunk())}}var kg=new WeakMap,Ag=Object.freeze([]),jg=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,Mg=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function Ng(e){let t=kg.get(e);if(t)return t;let n,r=0,i,a,o=!0,s=[];for(let t=0;t<e.length;t++){let c=e[t],l=Eg(c);if(Dh(l))continue;if(Oh(l)||kh(l)){a??=new Map;let e=Oh(l)?l.literal:l.symbol;s[t]=e;let n=a.get(e);n||a.set(e,n=[]),n.push(t)}else o=!1;let u=Og(l);if(u.length){n??=new Map,r++;for(let{key:e,literal:r}of u){let i=n.get(e);i||n.set(e,i=[new Map,new Set]),i[1].add(t);let a=i[0].get(r);a||i[0].set(r,a=new Set),a.add(t)}}else{i??={};let e=Dg(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??Ag);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??Ag;else if(n?.size===1&&!i){let[r,[i]]=n.entries().next().value,a=new Map;for(let[e,t]of i)a.set(e,Object.freeze(Array.from(t)));let o=Object.freeze(e.map((e,t)=>t));t=(e,t)=>{if(Mt(e)){let n=Mg(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??Ag;if(t)return o}return Ag}}else if(n){let e;for(let t of n)(!e||t[1][0].size>e[1][0].size)&&t[1][1].size===r&&(e=t);t=(t,r)=>{let a=jg(t);if(!Mt(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=Mg(t,n),u=c?t[n]:void 0;if(c&&(!r||u!==void 0)){let e=i.get(u);if(!e)return l(a);for(let t of e)o.add(t);s=n}}if(s===void 0)for(let[e,[i,a]]of n){let n=Mg(t,e),s=n?t[e]:void 0;if(n&&(!r||s!==void 0)){let e=i.get(s);if(e)for(let t of e)o.add(t)}else if(r)for(let e of a)o.add(e)}for(let[e,[i,a]]of n){if(e===s)continue;let n=Mg(t,e),c=n?t[e]:void 0;if(n&&(!r||c!==void 0)){let e=i.get(c);for(let t of o)a.has(t)&&!e?.has(t)&&o.delete(t)}}return Array.from(o).sort((e,t)=>e-t)}}else t=e=>{let t=l(jg(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return kg.set(e,t),t}var Pg=class extends Lh{_tag=`Union`;types;options;encodingChecks;constructor(e,t,n,r,i,a,o){super(n,r,i,a),this.types=e,this.options=t,this.encodingChecks=o}getParser(e,t){let n=this,r=t!==void 0,i=[],a=t=>i[t]??=e(n.types[t]),o;return(e,t)=>{if(e===z)return vm;let i=(o??=Ng(n.types))(e,r);if(i.length===0)return F(new Nm(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:N(r)?Fg(n,r.cause,e,t):Ig(n,r,e,t)}return Lg(n,a,i,e,t)}}_rebuild(e,t,n){let r=f_(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new Pg(r,this.options,this.annotations,t,void 0,this.context,n)}recur(e){return this._rebuild(e,this.checks,this.encodingChecks)}flip(e){return this._rebuild(e,this.encodingChecks,this.checks)}matchPart(e,t){for(let n of this.types){let r=n.matchPart(e,t);if(r!==void 0)return r}}getExpected(e){let t=this.annotations?.expected;if(typeof t==`string`)return t;if(this.types.length===0)return`never`;let n=this.types.map(t=>{let n=E_(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(Oh);if(t.length>0)return`${Vg(n.isMutable)}[ ${t.map(t=>e(t)+Hg(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>Oh(e.type));if(t.length>0)return`{ ${t.map(t=>`${Vg(t.type.context?.isMutable)}${wn(t.name)}${Hg(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function Fg(e,t,n,r){let i=Jm(t);return i?Yu(new Nm(e,[i],n,r)):Ju(t)}function Ig(e,t,n,r){return Cf(t,t=>Fg(e,t,n,r))}function Lg(e,t,n,r,i){let a={ast:e,parser:t,input:r,out:void 0,successes:e.options?.mode===`oneOf`?[]:void 0,issues:void 0,options:i},o=zg(a,n);return o?Rg(o,a):a.out?a.out:F(new Nm(e,a.issues??[],r,i))}function Rg(e,t){return np(e,e=>t.out===B?P(t.input):t.out?t.out:F(new Nm(t.ast,t.issues??[],t.input,t.options)))}var zg=Gl()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Jm(n.cause);if(t===void 0)return n;e.issues?e.issues.push(t):e.issues=[t]}else{if(e.out&&e.successes)return e.successes.push(e.ast.types[t]),Yu(new Pm(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return Xu}}}),Bg=new Pg([new Xh(`Infinity`),new Xh(`-Infinity`),new Xh(`NaN`)]);function Vg(e){return e?``:`readonly `}function Hg(e){return e?`?`:``}var Ug=class extends Lh{_tag=`Suspend`;thunk;constructor(e,t,n,r,i){if(n)throw Error(`Cannot add checks to Suspend`);super(t,void 0,r,i);let a;this.thunk=()=>a??=e()}getParser(e){let t;return(n,r)=>(t??=e(this.thunk()))(n,r)}recur(e){return new Ug(()=>e(this.thunk()),this.annotations,void 0,void 0,this.context)}getExpected(e){return e(this.thunk())}},Wg=class extends lt{_tag=`Filter`;run;annotations;aborted;constructor(e,t=void 0,n=!1){super(),this.run=e,this.annotations=t,this.aborted=n}annotate(e){return new Wg(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Wg(this.run,this.annotations,!0)}and(e,t){return new Gg([this,e],t)}},Gg=class extends lt{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Gg(this.checks,{...this.annotations,...e})}and(e,t){return new Gg([this,e],t)}};function Kg(e,t,n=!1){return new Wg((t,n,r)=>Lm(n,e(t,n,r),t,r),t,n)}function qg(e){return Kg(e=>globalThis.Number.isFinite(e),{expected:`a finite number`,representation:{id:`effect/schema/isFinite`,payload:null},toJsonSchema:()=>({type:`number`}),toCode:()=>({runtime:`Schema.isFinite()`}),arbitraryConstraint:{number:`finite`},...e})}var Jg=a_(tg,[qg()]),Yg=new Nh(new Pg([Jg,Bg]),new ch(nh(),$m(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Xg(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Kg(e=>(n.lastIndex=0,n.test(e)),{expected:`a string matching the RegExp ${r.source}`,representation:{id:`effect/schema/isPattern`,payload:r},toJsonSchema:()=>[{},!0],arbitraryConstraint:{patterns:[r]},...t})}var Zg=new WeakMap;function Qg(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Zg.set(n,$g(e)),n}function $g(e){let t=Zg.get(e);if(t!==void 0)return t;if(e.encoding===void 0)return e;let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:void 0});return Zg.set(e,n),n}function e_(e,t){return e.encoding===t?e:Qg(e,{encoding:t})}function t_(e,t){if(e.context===t)return e;let n=$g(e);return n.context===t&&n.encoding===e.encoding?n:Qg(e,{context:t})}function n_(e){return e.encoding?n_(e.encoding[e.encoding.length-1].to):e}function r_(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return i_(e,xa(e.checks.slice(0,-1),n.annotate(t)))}return Qg(e,{annotations:{...e.annotations,...t}})}function i_(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Qg(e,{checks:t})}function a_(e,t){return i_(e,xg(e.checks,t))}function o_(e,t){let n=t(e.to);return n===e.to?e:new Nh(n,e.transformation)}function s_(e,t){let n=e,r=n[n.length-1],i=o_(r,t);return i===r?e:xa(e.slice(0,e.length-1),i)}function c_(e){return t=>t.encoding?e_(t,s_(t.encoding,e)):t}function l_(e,t){return c_(e=>t_(e,t))(e)}function u_(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:e_(r,s_(r.encoding,n))}return e(r)}return gt(n)}function d_(e,t,n){let r=new Nh(e,t);return e_(n,n.encoding?[...n.encoding,r]:[r])}function f_(e,t){let n;for(let r=0;r<e.length;r++){let i=e[r],a=t(i);if(n)n[r]=a;else if(a!==i){n=Array(e.length);for(let t=0;t<r;t++)n[t]=e[t];n[r]=a}}return n??e}function p_(e,t){return t_(e,e.context?new Fh(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new Fh(!1,!1,void 0,t))}var m_=gt(e=>h_(t_(e,e.context?e.context.isOptional===!1?new Fh(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new Fh(!0,!1)))),h_=c_(m_),g_=ht(e=>m_(new Pg([e,Hh])));function __(e,t){return t_(e,e.context?new Fh(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new Fh(!1,!1,t))}function v_(e,t,n){return d_(e,n,t)}function y_(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:Et(e.literal)&&!t.includes(e.literal)&&t.push(e.literal);return;case`UniqueSymbol`:t.includes(e.symbol)||t.push(e.symbol);return;case`Never`:return;case`Union`:for(let t=0;t<e.types.length;t++)r(e.types[t]);return;default:n.push(e)}}return r(e),{literals:t,parameters:n}}function b_(e,t){let{literals:n,parameters:r}=y_(e);return new gg(n.map(e=>new dg(e,t)),r.map(e=>new hg(e,t)))}function x_(e){return e.context?.isOptional??!1}function S_(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(S_)}function C_(e){function t(e){return S_(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Ca(n)?n:void 0}function w_(e){let t=!0;function n(e){return t=t&&!e.encoding&&!Mh(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var T_=gt(e=>{let t=$g(e);if(t!==e){let n=T_(t);return n===t&&e.encoding===void 0?e:t_(n,e.context)}let n=`recur`in e?e.recur(T_):e;if(`encodingChecks`in n&&n.encodingChecks){let t=w_(e)?n.encodingChecks:Ah(n)||jh(n)||Eh(n)&&n.typeParameters.length>0?C_(n.encodingChecks):void 0;return Qg(n,{encodingChecks:void 0,checks:xg(n.checks,t)})}return n}),E_=gt(e=>T_(O_(e)));function D_(e,t){let n=t,r=n.length,i=n[r-1],a=[new Nh(O_(e_(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new Nh(O_(n[e-1].to),n[e].transformation.flip()));let o=O_(i.to);return o.encoding?e_(o,[...o.encoding,...a]):e_(o,a)}var O_=ht(e=>{if(e.encoding)return D_(e,e.encoding);let t=$g(e);if(t!==e){let n=O_(t);return n===t?e:t_(n,e.context)}return`flip`in e?e.flip(O_):`recur`in e?e.recur(O_):e});function k_(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(k_);default:return!1}}function A_(e,t){let n=t===0?B:_m(t);return(r,i)=>r===z?vm:r===t?n:F(new jm(e,r,i))}function j_(e,t){return(n,r)=>n===z?vm:t(n)?B:F(new jm(e,n,r))}function M_(e,t,n){let r=e.encodedParts,i=e.literals,a=t.length;for(let e=0;e<i.length;e++){let n=i[e];if(n&&!t.includes(n))return}if(e.suffixLengths[0]>a)return;let o=Array(r.length),s;function c(l,u){if(l===r.length)return u===a;if(s?.has(l*(a+1)+u))return!1;let d=r[l];if(l===r.length-1){let e=t.slice(u);if(d.matchPart(e,n)!==void 0)return o[l]=e,!0}else if(d._tag===`Literal`){let e=i[l];if(t.startsWith(e,u)&&c(l+1,u+e.length))return o[l]=e,!0}else{let r=a-e.suffixLengths[l+1],s=i[l+1],f=s===void 0?r:t.lastIndexOf(s,r);for(;f>=u;){let e=t.slice(u,f);if(d.matchPart(e,n)!==void 0&&c(l+1,f))return o[l]=e,!0;if(f===0)break;f=s===void 0?f-1:t.lastIndexOf(s,f-1)}}return s??=new Set,s.add(l*(a+1)+u),!1}return c(0,0)?o:void 0}var N_=u_(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(N_)}}),P_=u_(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(P_)}}),F_=u_(e=>{switch(e._tag){default:return e;case`Number`:case`Literal`:case`BigInt`:return e.toCodecStringTree();case`Union`:return e.recur(F_)}}),I_=new globalThis.RegExp(`^${lg}$`),L_=new globalThis.RegExp(`^(?:${lg}|Infinity|-Infinity|NaN)$`);function R_(e){return Xg(I_,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:I_.source}),...e})}var z_=a_(Qh,[R_()]),B_=new Nh(z_,mh),V_=new Nh(new Pg([z_,Bg]),mh);function H_(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=H_(o.checks,t,n,r,i),n&&(i.errors!==`all`||n[n.length-1].filter.aborted))return n}else{let e=o.run(t,r,i);if(e){let r=new Tm(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function U_(e){if(!Eh(e))return;let t=e.annotations?.[hm];return Dt(t)?t(e.typeParameters):void 0}function W_(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function G_(e){return e===void 0||typeof e==`string`}function K_(e,t){let n=new WeakMap,r=[];outer:for(;;){if(typeof e!=`object`||!e){if(!t(e))return!1}else{let t=e,i=n.get(t);if(i===!1)return!1;if(i===void 0){let e=Array.isArray(t);if(!e){let e=Object.getPrototypeOf(t);if(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null)return!1}n.set(t,!1),r.push({value:t,keys:e?t.length:Object.keys(t),index:0})}}for(;r.length>0;){let t=r[r.length-1],i=t.keys;if(typeof i==`number`){if(t.index<i){e=t.value[t.index++];continue outer}}else if(t.index<i.length){e=t.value[i[t.index++]];continue outer}n.set(t.value,!0),r.pop()}return!0}}function q_(e){return K_(e,W_)}var J_=new Rh([],()=>(e,t,n)=>q_(e)?B:F(new jm(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>Q_}),Y_=new Nh(J_,ph()),X_=new Nh(new Pg([new rg(!1,[],[J_]),new gg([],[new hg(Qh,J_)])]),ph());function Z_(e){return K_(e,G_)}var Q_=new Nh(new Rh([],()=>(e,t,n)=>Z_(e)?B:F(new jm(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),ph()),$_=(e,t,n)=>e===B?n(t):np(e,n);function ev(e){if(e._tag===`Middleware`)return(t,n,r)=>tv(t===B?e.decode(_m(ym(n)),r):e.decode(ep(t,ym),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===B?_m(t):e;case`Transform`:{let e=e=>e===z?vm:_m(t.transform(e));return(t,n)=>$_(t,n,e)}case`TransformOptional`:{let e=e=>bm(t.transform(ym(e)));return(t,n)=>$_(t,n,e)}case`TransformEffect`:return(e,n,r)=>$_(e,n,e=>e===z?vm:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>$_(e,n,e=>tv(t.transform(ym(e),r)))}}var tv=e=>np(e,bm),nv=(e,t,n,r)=>Cf(r,r=>lf(()=>Hu(r,r=>new Em(e,r,t,n))));function rv(e,t){let n=ev(e.link.transformation),r;return(i,a)=>{if(i===z)return vm;if(e.isConstructed(i))return B;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function iv(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==z&&r!==void 0)return t(r,i);let a=n;if(N(a)&&a._tag===`Success`){let e=t(a[A],i);return e===B?a:e}return np(nv(e,r,i,a),e=>{let n=t(e,i);return n===B?_m(e):n})}}function av(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:iv(e,n)}function ov(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?U_(e):void 0,o=a?rv(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>ev(e.transformation)),u=e.encodingChecks;if(!c&&!s&&!u)return o;let d,f=(t,n)=>{let r=o(t,n);if(u&&!n.disableChecks){if(N(r)){if(r._tag===`Success`){let i=r===B?t:r[A];if(t!==z&&i!==z){let i=H_(u,t,void 0,e,n);i&&(r=F(new Am(e,i,t,n)))}}}else r=pf(r,r=>{if(t!==z&&r!==z){let r=H_(u,t,void 0,e,n);if(r)return F(new Am(e,r,t,n))}return P(r)})}if(s&&!n.disableChecks){if(N(r)){if(r._tag===`Success`){let i=r===B?t:r[A];if(i===z)return r;let a=H_(s,i,void 0,e,n);a&&(r=F(new Am(e,a,i,n)))}}else r=pf(r,t=>{if(t!==z){let r=H_(s,t,void 0,e,n);if(r)return F(new Am(e,r,t,n))}return P(t)})}return r},p=i===void 0?f:i(f);return c?(n,r)=>{let i=d??=c.map(e=>t(e.to)),a=n,o=i[i.length-1](n,r);for(let e=c.length-1;e>=0;e--)if(o=l[e](o,a,r),e!==0){let t=i[e-1];o._tag===`Success`?(a=o[A],o=t(a,r)):o=np(o,e=>{let n=t(e,r);return n===B?_m(e):n})}if(o._tag===`Success`){let e=o[A],t=p(e,r);return t===B?o:t}return o=nv(e,n,r,o),np(o,e=>{let t=p(e,r);return t===B?_m(e):t})}:p}var sv=Symbol(),cv=new WeakMap,lv=e=>pv(e).parser,uv=e=>pv(e).makeEffect,dv=e=>av(e,uv),fv=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=ov(this.ast,lv)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=ov(this.ast,uv,dv)}};function pv(e){let t=cv.get(e);if(t!==void 0)return t;let n=new fv(e);return cv.set(e,n),n}function mv(e){let t=e.ast,n;return(e,r)=>(n??=Av(Iv,T_(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function hv(e){let t=mv(e);return(e,n)=>{let r=Zf(t(e,n));return Zu(r)?yi(r.value):(Ym(r.cause,`Option adapter can only return none for schema issues`),vi())}}function gv(e){return Pv(T_(e.ast))}function _v(e){return yv(e.ast)}function vv(e){{let t=jv(Ov(e));return e=>{let n=t(e,Ph);return Zu(n)?!0:(Ym(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function yv(e){let t=T_(e),n=e=>(n=vv(t),n(e));return e=>n(e)}function bv(e,t){let n=Ov(e.ast);return t===void 0?n:(e,r)=>n(e,Ev(t,r))}function xv(e,t){return Mv(bv(e,t))}var Sv=xv;function Cv(e,t){let n=Ov(O_(e.ast));return t===void 0?n:(e,r)=>n(e,Ev(t,r))}function wv(e,t){return Mv(Cv(e,t))}var Tv=wv,Ev=(e,t)=>t?{...e,...t}:e,Dv=e=>e===z?F(new Mm):P(e);function Ov(e){return Av(Fv,e)}function kv(e,t){return e===B?P(t):N(e)?e[A]===z?Dv(z):e:np(e,Dv)}function Av(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??Ph);return a===B?P(r):N(a)?a[A]===z?Dv(z):a:np(a,Dv)}}function jv(e){return(t,n)=>Zf(e(t,n))}function Mv(e){let t=jv(e);return(e,n)=>{let r=t(e,n);return Zu(r)?yi(r.value):(Ym(r.cause,`Option adapter can only return none for schema issues`),vi())}}function Nv(e,t){let n=Zf(e);if(Zu(n))return n.value;let r=Ym(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function Pv(e){let t,n;return(r,i)=>{t??=pv(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??Ph,o=t.make;if(o!==void 0&&r!==z){let e;try{e=o(r,a)}catch(e){throw Ym(Vu(e),`Constructor adapter can only throw schema issues`),e}if(e!==sv&&e!==z)return e}return Nv(kv((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var Fv=e=>pv(e).parser,Iv=e=>pv(e).makeEffect,Lv=`~effect/Schema/Schema`,Rv=Symbol(),zv={[Lv]:Lv,get make(){let e=gv(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=mv(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=hv(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return st(this,arguments)},annotate(e){return this.rebuild(r_(this.ast,e))},annotateKey(e){return this.rebuild(p_(this.ast,e))},check(...e){return this.rebuild(a_(this.ast,e))},rebuild(e){return Bv(e,this[Rv])}};function Bv(e,t){function n(){}let r=Object.setPrototypeOf(n,zv);return t&&(Object.hasOwn(t,`name`)||Object.hasOwn(t,`length`)||Object.hasOwn(t,`__proto__`))?Object.defineProperties(r,Object.getOwnPropertyDescriptors({...t})):Object.assign(r,t),r[Rv]=t,r.ast=e,r}function Vv(e){return Bv(Hv(e.ast),{schema:e})}var Hv=u_(e=>{let t=qv(e,Hv),n=e.context;return t===e||n===void 0?t:l_(t,Uv(n))});function Uv(e){return e.constructorDefault===void 0?e:new Fh(e.isOptional,e.isMutable,void 0,e.annotations)}function Wv(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function Gv(e){return t=>{let n=[...t].sort((t,n)=>e(E_(t))-e(E_(n)));return n.some((e,n)=>e!==t[n])?n:t}}var Kv=Gv(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function qv(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Dt(n))return e_(e,[Y_]);let r=n(e.typeParameters.map(e=>Bv(E_(e))));return r===void 0?e:e_(e,[o_(r,t)])}case`Unknown`:return e_(e,[Y_]);case`ObjectKeyword`:return e_(e,[X_]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return Wv(e),e.recur(t,P_);case`Union`:{let n=Kv(e.types);return n===e.types?e.recur(t):new Pg(n,e.options,e.annotations,e.checks,e.encoding,e.context,e.encodingChecks).recur(t)}case`Arrays`:case`Suspend`:return e.recur(t)}return e}var Jv=e=>e,Yv=`~effect/Schema/SchemaError`;function Xv(e){return D(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Zv=Lv;function Qv(){return(e,t,n)=>V(new Rh(e.map(Cg),e=>t(e.map(e=>V(e))),n))}function $v(e,t){return Qv()([],()=>(t,n,r)=>e(t)?P(t):F(new jm(n,t,r)),t)}var ey=class extends So(`SchemaError`){[Yv]=Yv;constructor(e){let t=Fn();In(0);try{super({issue:e})}finally{In(t)}}get message(){return Gm(this.issue)}toString(){return`SchemaError(${this.message})`}};function ty(e){return Xv(e)}function ny(e){return N(e)?ry(e):Cf(e,e=>lf(()=>Hu(e,e=>new ey(e))))}function ry(e){return Zu(e)?e:Ju(Hu(e.cause,e=>new ey(e)))}function iy(e,t){let n;for(let r of e.reasons){if(!Ru(r)||!ty(r.error))throw new globalThis.Error(t,{cause:e});n??=r.error}if(n===void 0)throw new globalThis.Error(t,{cause:e});return n}function ay(e){let t=Zf(e);if(Zu(t))return t.value;throw iy(t.cause,`Sync adapter can only throw schema errors`)}var oy=_v;function sy(e,t){let n=bv(e,t);return(e,t)=>ny(n(e,t))}var cy=sy,ly=xv,uy=Sv;function dy(e,t){let n=sy(e,t);return(e,t)=>ay(n(e,t))}var fy=dy;function py(e,t){let n=Cv(e,t);return(e,t)=>ny(n(e,t))}var my=Tv;function hy(e,t){let n=py(e,t);return(e,t)=>ay(n(e,t))}var gy=hy,V=Bv;function _y(e){return D(e,Zv)&&e[Zv]===Zv}var H=Jv(e=>{let t=Ny(e);return V(g_(e.ast),{schema:t})}),vy=Jv(e=>V(T_(e.ast),{schema:e}));function U(e){let t=V(new Xh(e),{literal:e,transform(n){return t.pipe(Iy(U(n),{decode:$m(()=>n),encode:$m(()=>e)}))}});return t}function yy(e){return e.map(e=>_y(e)?e.ast:new Xh(e))}function by(e){return V(new qh(yy(e)),{parts:e})}function xy(e){return V(Jh(yy(e)),{parts:e})}var Sy=V(Uh),Cy=V(zh),wy=V(Hh),W=V(Qh),Ty=V(tg),Ey=V(ng),Dy=V(Wh);function Oy(e,t){return V(e,{fields:t,mapFields(e,t){let n=e(this.fields);return Oy(Sg(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function G(e){return Oy(Sg(e,void 0),e)}function ky(e,t){return V(b_(e.ast,t.ast),{key:e,value:t})}function Ay(e,t){return V(Tg(e.ast,t.map(Cg)),{schema:e,records:t})}var K=Jv(e=>V(new rg(!1,[],[e.ast]),{value:e}));function jy(e,t){return V(e,{members:t,mapMembers(e,t){let n=e(this.members);return jy(wg(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function q(e,t){return jy(wg(e,t,void 0),e)}function J(e){let t=e.map(U);return V(wg(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return q(e(this.members))},pick(e){return J(e)},transform(e){return q(t.map((t,n)=>t.transform(e[n])))}})}var My=Jv(e=>q([e,Cy])),Ny=Jv(e=>q([e,wy]));function Py(e){return V(new Ug(()=>e().ast))}function Fy(...e){return t=>t.check(...e)}function Y(e){return t=>V(t.ast,{schema:t,identifier:e})}function Iy(e,t){return n=>V(v_(n.ast,e.ast,t?uh(t):ph()),{from:n,to:e})}function Ly(e){return t=>V(__(t.ast,e),{schema:t})}function Ry(e){return U(e).pipe(Ly(P(e)))}function zy(e,t){return G({_tag:Ry(e),...t})}function By(){return(e,t)=>new Nh(e.ast,uh(t))}var X=Kg,Vy=`^\\S[\\s\\S]*\\S$|^\\S$|^$`;function Hy(e){let t=new globalThis.RegExp(Vy);return X(e=>e.trim()===e,{expected:`a string with no leading or trailing whitespace`,representation:{id:`effect/schema/isTrimmed`,payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:`Schema.isTrimmed()`}),arbitraryConstraint:{patterns:[{source:Vy,flags:``}]},...e})}function Uy(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${k(n)})`:`new RegExp(${k(n)}, ${k(r)})`;return Xg(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}function Wy(e){let t=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;return Uy(t,{expected:`a base64url encoded string`,representation:{id:`effect/schema/isBase64Url`,payload:null},toJsonSchema:()=>({pattern:t.source}),toCode:()=>({runtime:`Schema.isBase64Url()`}),...e})}var Gy=V(Jg);function Ky(e){let t=hi(e.order),n=e.formatter??k;return(r,i)=>X(e=>t(e,r),{expected:`a value greater than ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r,exclusiveMinimum:!0},...e.annotate?.(r),...i})}function qy(e){let t=_i(e.order),n=e.formatter??k;return(r,i)=>X(e=>t(e,r),{expected:`a value greater than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,minimum:r},...e.annotate?.(r),...i})}function Jy(e){let t=gi(e.order),n=e.formatter??k;return(r,i)=>X(e=>t(e,r),{expected:`a value less than or equal to ${n(r)}`,arbitraryConstraint:{order:e.order,maximum:r},...e.annotate?.(r),...i})}function Yy(e){let t=_i(e.order),n=hi(e.order),r=gi(e.order),i=mi(e.order),a=e.formatter??k;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return X(e=>c(e,o.minimum)&&l(e,o.maximum),{expected:`a value between ${a(o.minimum)}${o.exclusiveMinimum?` (excluded)`:``} and ${a(o.maximum)}${o.exclusiveMaximum?` (excluded)`:``}`,arbitraryConstraint:{order:e.order,minimum:o.minimum,maximum:o.maximum,...o.exclusiveMinimum&&{exclusiveMinimum:!0},...o.exclusiveMaximum&&{exclusiveMaximum:!0}},...e.annotate?.(o),...s})}}function Xy(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${k(e)}`);return e}var Zy=Ky({order:fi,annotate:e=>({representation:{id:`effect/schema/isGreaterThan`,payload:{exclusiveMinimum:Xy(e)}},toJsonSchema:()=>({exclusiveMinimum:e}),toCode:()=>({runtime:`Schema.isGreaterThan(${k(e)})`})})}),Qy=qy({order:fi,annotate:e=>({representation:{id:`effect/schema/isGreaterThanOrEqualTo`,payload:{minimum:Xy(e)}},toJsonSchema:()=>({minimum:e}),toCode:()=>({runtime:`Schema.isGreaterThanOrEqualTo(${k(e)})`})})}),$y=Jy({order:fi,annotate:e=>({representation:{id:`effect/schema/isLessThanOrEqualTo`,payload:{maximum:Xy(e)}},toJsonSchema:()=>({maximum:e}),toCode:()=>({runtime:`Schema.isLessThanOrEqualTo(${k(e)})`})})}),eb=Yy({order:fi,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Xy(e.minimum),maximum:Xy(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${k(e.minimum)}, maximum: ${k(e.maximum)}, exclusiveMinimum: ${k(t)}, exclusiveMaximum: ${k(n)} })`})}}});function tb(e){return X(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>[{type:`integer`},!0],toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var nb=Ty.check(tb()),rb=nb.check(Qy(0));function ib(e,t){return e=cb(e),ab(e,Math.ceil(e/2),t)}function ab(e,t,n){return X(t=>t.length>=e,{expected:`a value with a length of at least ${e}`,representation:{id:`effect/schema/isMinLength`,payload:{minLength:e}},toJsonSchema:({type:n})=>n===`string`?e<=1?{minLength:t}:[{minLength:t},!0]:n===`array`?{minItems:e}:n===void 0?[{minLength:t,minItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMinLength(${e})`}),[pm]:!0,arbitraryConstraint:{minLength:e},...n})}function ob(e){return ab(1,1,e)}function sb(e,t){return e=cb(e),X(t=>t.length<=e,{expected:`a value with a length of at most ${e}`,representation:{id:`effect/schema/isMaxLength`,payload:{maxLength:e}},toJsonSchema:({type:t})=>t===`string`?e===0?{maxLength:e}:[{maxLength:e},!0]:t===`array`?{maxItems:e}:t===void 0?[{maxLength:e,maxItems:e},!0]:[{},!0],toCode:()=>({runtime:`Schema.isMaxLength(${e})`}),[pm]:!0,arbitraryConstraint:{maxLength:e},...t})}function cb(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function lb(e){return X(e=>ja(e).length===e.length,{expected:`an array with unique items`,representation:{id:`effect/schema/isUnique`,payload:null},toJsonSchema:()=>({uniqueItems:!0}),toCode:()=>({runtime:`Schema.isUnique()`}),arbitraryConstraint:{uniqueBy:E},...e})}var ub=W.check(ob()),db=e=>e?.includeStack===!0|(e?.excludeCause===!0?2:0),fb=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},pb=[];function mb(e){let t=db(e),n=pb[t];if(n!==void 0)return n;let r=Ab.pipe(Iy(Sy,Ch(fb(t))));return pb[t]=r,r}globalThis.RegExp,globalThis.URL;var hb=W.annotate({expected:`a string that will be decoded as a Date`}),gb=$v(e=>e instanceof globalThis.Date&&!globalThis.Number.isNaN(e.getTime()),{representation:{id:`effect/schema/Date`,payload:null},toCode:()=>({runtime:`Schema.Date`,Type:`globalThis.Date`}),expected:`a valid Date`,toCodecJson:()=>By()(hb,hh)}),_b=nb.pipe(Iy(gb,gh)),vb=W.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function yb(e,t){return vb.pipe(Iy(e,wh(t)))}globalThis.File,globalThis.FormData,globalThis.URLSearchParams,globalThis.Uint8Array;var bb=globalThis.Symbol.for(`immer-draftable`),xb={};function Sb(e,t,n,r,i){let a=Tb(n,t,r),o=wb(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===xb?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:xb,value:i}})}static[Zv]=Zv;get[o](){return o}static[bb]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return st(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return gv(a(this))(e??{},t)}static makeOption(e,t){return hv(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(r_(this.ast,e))}static annotateKey(e){return this.rebuild(p_(this.ast,e))}static check(...e){return this.rebuild(a_(this.ast,e))}static extend(e){return(t,r)=>{let a=Eb(t)?t:G(t),o={...n.fields,...a.fields},s=Sg(o,n.ast.checks,{identifier:e});return Sb(this,e,Oy(a_(s,a.ast.checks),o),r,i)}}static mapFields(e,t){return n.mapFields(e,t)}};return i!==void 0&&Object.assign(s.prototype,i(t)),s}function Cb(e){return new ch($m(t=>new e(t,{"~payload":{token:xb,value:t}})),Qm())}function wb(e){return`~effect/Schema/Class/${e}`}function Tb(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=wb(t),o=e=>e instanceof i||D(e,a),s=Cb(i);return r=Iy(V(new Rh([e.ast],()=>(e,t,n)=>o(e)?P(e):F(new jm(t,e,n)),{identifier:t,[hm]:([e])=>({isConstructed:o,link:new Nh(e,s)}),toCodec:([e])=>new Nh(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[mm]:Og(e.ast),...n})),s)(e)}}function Eb(e){return _y(e)}var Db=e=>(t,n)=>Sb(Or,e,Eb(t)?t:G(t),n,e=>({name:e})),Ob=e=>(t,n,r)=>{let i=Eb(n)?n.mapFields(e=>({_tag:Ry(t),...e}),{unsafePreserveChecks:!0}):zy(t,n);return Db(e??t)(i,r)},kb=Vv,Ab=V(r_(J_,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),jb=ky(W,Ab);function Mb(){return Object.assign(e=>e,{option:e=>yi(e),result:e=>sa(e),is:e=>!0})}var Nb=Cs,Pb=Ts,Fb=Zl,Ib=fu,Lb=`~effect/MutableRef`,Rb={[Lb]:Lb,...Xn,toJSON(){return{_id:`MutableRef`,current:jn(this.current)}}},zb=e=>{let t=Object.create(Rb);return t.current=e,t},Bb=(e,t,n)=>Us(r=>{if(e.free>=t)return r(n);let i=()=>{e.free<t||(e.waiters.delete(i),r(n))};return e.waiters.add(i),As(()=>{e.waiters.delete(i)})}),Vb=class{waiters=new Set;taken=0;permits;constructor(e){this.permits=e}get free(){return this.permits-this.taken}take(e){let t=js(()=>this.free<e?Bb(this,e,t):(this.taken+=e,M(e)));return t}takeIfAvailable(e){return js(()=>this.free<e?M(!1):(this.taken+=e,M(!0)))}releaseUnsafe(e,t){return this.taken-=t,this.waiters.size>0&&e.currentDispatcher.scheduleTask(()=>{for(let e of this.waiters){if(this.free<=0)break;e()}},0),this.free}resize(e){return Er(t=>(this.permits=e,this.free<0||this.releaseUnsafe(t,0),Ls))}release(e){return Er(t=>M(this.releaseUnsafe(t,e)))}get releaseAll(){return Er(e=>M(this.releaseUnsafe(e,this.taken)))}withPermits(e){return t=>Bl(n=>{let r=js(()=>this.free<e?hc(n(Bb(this,e,Ls)),()=>r):(this.taken+=e,wl(n(t),()=>{this.releaseUnsafe(gs(),e)},!0)));return r})}withPermit=this.withPermits(1);withPermitsIfAvailable(e){return t=>Bl(n=>this.free<e?Ns:(this.taken+=e,wl(n(dc(t)),()=>{this.releaseUnsafe(gs(),e)},!0)))}},Hb=e=>As(()=>new Vb(e)),Ub={"~effect/Channel":{_Env:E,_InErr:E,_InElem:E,_OutErr:E,_OutElem:E},pipe(){return st(this,arguments)}},Wb=e=>{let t=Object.create(Ub);return t.transform=(t,n)=>Cf(e(t,n),e=>P(cf(e))),t},Gb=e=>Wb((t,n)=>e),Kb=e=>Wb($f(function*(t,n){let r=ud(n),i=e=>dd(r,Zd(e));return Pf(yield*Pf(e(t,n,r),i),i)})),qb=e=>e.transform,Jb=e=>Wb((t,n)=>nf(()=>qb(e())(t,n))),Yb=e=>Gb(P(F(e))),Xb=e=>Wb((t,n)=>Zb({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),Zb=e=>{let t=e.readable.getReader(),n=e.exit??zb(void 0),r=nf(()=>n.current?n.current:Ef(tf({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??cf(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?Ku():P(Oa(t))}));return bf(ld(e.scope,e.releaseLockOnEnd?rf(()=>t.releaseLock()):ef(()=>t.cancel().catch(mt))),r)},Qb=T(2,(e,t)=>Kb((n,r,i)=>cd(i,t).pipe(hf(qb(e)(n,r))))),$b=T(2,(e,t)=>Qb(e,e=>t)),ex=(e,t,n)=>nf(()=>{let r=od();return qd(pf(qb(e)(Ku(),r),t),n||P).pipe(Ff(e=>dd(r,e)))}),tx=T(2,(e,t)=>ex(e,e=>zf(pf(e,t),{disableYield:!0}))),nx=`~effect/Stream`,rx={_R:E,_E:E,_A:E},ix=function(e){this.channel=e};ix.prototype={[nx]:rx,pipe(){return st(this,arguments)}};var ax=e=>new ix(e),ox=`~effect/Stream`,sx=e=>D(e,ox),cx=ax,lx=e=>cx(Jb(()=>e().channel)),ux=e=>cx(Yb(e)),dx=e=>cx(Xb(e)),fx=T(2,(e,t)=>cx($b(e.channel,t))),px=T(2,(e,t)=>tx(e.channel,t)),mx=T(e=>sx(e[0]),(e,t,n)=>{let r,i,a=Ib(!1);return new ReadableStream({start(n){i=Hf(kf(px(e,e=>a.whenOpen(rf(()=>{a.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{e._tag===`Failure`?n.error(Uu(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return Kf(xf(Pb(i)))}},n?.strategy)}),hx=T(e=>sx(e[0]),(e,t)=>yf(Df(),n=>mx(e,n,t))),gx=[`All`,`Fatal`,`Error`,`Warn`,`Info`,`Debug`,`Trace`,`None`],_x=`~effect/ErrorReporter`,vx=e=>{let t=new WeakSet;return{[_x]:_x,report(n){if(!t.has(n.cause)){t.add(n.cause);for(let r=0;r<n.cause.reasons.length;r++){let i=n.cause.reasons[r];if(i._tag===`Interrupt`)continue;let a=i._tag===`Fail`?i.error:i.defect,o=typeof a==`object`&&!!a;if(o){if(t.has(a))continue;t.add(a)}if(Sx(a))continue;let s=as(a,i.annotations);e({...n,error:s,severity:o?wx(a):`Info`,attributes:o?Ex(a):Dx})}}}}},yx=Ro,bx=(e,t)=>kd(yx,ff($f(function*(n){let r=new Set(t?.mergeWithExisting===!0?n.getRef(Ro):[]);for(let t of e)r.add(Qd(t)?yield*t:t);return r}))),xx=e=>ff(t=>(Lu(t,e),af)),Sx=e=>typeof e==`object`&&!!e&&`~effect/ErrorReporter/ignore`in e&&e[`~effect/ErrorReporter/ignore`]===!0,Cx=`~effect/ErrorReporter/severity`,wx=e=>`~effect/ErrorReporter/severity`in e&&gx.includes(e[`~effect/ErrorReporter/severity`])?e[Cx]:`Info`,Tx=`~effect/ErrorReporter/attributes`,Ex=e=>`~effect/ErrorReporter/attributes`in e?e[Tx]:Dx,Dx={},Ox=`~effect/ManagedRuntime`,kx=(e,t)=>{let n=t?.memoMap??xd(),r=od(`sequential`),i=ud(r,`sequential`),a={onFiberStart:Fb(ud(r,`parallel`))},o=e=>e?{...e,onFiberStart:e.onFiberStart?t=>{a.onFiberStart(t),e.onFiberStart(t)}:a.onFiberStart}:a,s,c=ff(t=>(s||=Hf(gf(wd(e,n,i),e=>rf(()=>{l.cachedContext=e})),{...a,scheduler:t.cache.scheduler}),mf(Nb(s)))),l={[Ox]:Ox,memoMap:n,scope:r,contextEffect:c,cachedContext:void 0,context(){return l.cachedContext===void 0?Kf(l.contextEffect):Promise.resolve(l.cachedContext)},dispose(){return Kf(l.disposeEffect)},[Symbol.asyncDispose](){return l.dispose()},disposeEffect:nf(()=>(l.contextEffect=uf(`ManagedRuntime disposed`),l.cachedContext=void 0,dd(l.scope,Xu))),runFork(e,t){return l.cachedContext===void 0?Hf(Ax(l,e),o(t)):Uf(l.cachedContext)(e,o(t))},runCallback(e,t){return l.cachedContext===void 0?Gf(Ax(l,e),o(t)):Wf(l.cachedContext)(e,o(t))},runSyncExit(e){return l.cachedContext===void 0?Zf(Ax(l,e)):Qf(l.cachedContext)(e)},runSync(e){return l.cachedContext===void 0?L(Ax(l,e)):Xf(l.cachedContext)(e)},runPromiseExit(e,t){return l.cachedContext===void 0?Jf(Ax(l,e),o(t)):Yf(l.cachedContext)(e,o(t))},runPromise(e,t){return l.cachedContext===void 0?Kf(Ax(l,e),o(t)):qf(l.cachedContext)(e,o(t))}};return l};function Ax(e,t){return pf(e.contextEffect,e=>kf(t,e))}var jx=`~effect/http/HttpBody`;So(`HttpBodyError`);var Mx=class{[jx];constructor(){this[jx]=jx}[An](){return this.toJSON()}toString(){return k(this,{ignoreToString:!0})}},Nx=new class extends Mx{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},Px=class extends Mx{_tag=`Uint8Array`;contentType;contentLength;text;_body;constructor(e,t,n,r){super(),this._body=e,this.text=r,this.contentType=t,this.contentLength=n}get body(){return this._body??=Lx(this.text)}toJSON(){return{_id:`effect/HttpBody`,_tag:`Uint8Array`,body:this.contentType.startsWith(`text/`)||this.contentType.endsWith(`json`)?new TextDecoder().decode(this.body):`Uint8Array(${this.body.length})`,contentType:this.contentType,contentLength:this.contentLength}}},Fx=new TextEncoder,Ix=globalThis.Buffer,Lx=Ix===void 0?e=>Fx.encode(e):e=>Ix.from(e,`utf8`),Rx=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),Ix!==void 0)return new Px(void 0,t??`text/plain`,Ix.byteLength(e,`utf8`),e);let n=Fx.encode(e);return new Px(n,t??`text/plain`,n.length,e)},zx=(e,t)=>Rx(JSON.stringify(e),t??`application/json`),Bx=`~effect/http/HttpClientError`,Vx=class extends So(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[Bx]=Bx;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},Hx=e=>e.endsWith(`Error`)?e.slice(0,-5):e,Ux=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,Wx=class extends So(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Ux(Hx(this._tag),this.description,this.methodAndUrl)}};So(`EncodeError`);var Gx=class extends So(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return Ux(Hx(this._tag),this.description,this.methodAndUrl)}},Kx=class extends So(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Ux(Hx(this._tag),this.description,e)}},qx=class extends So(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Ux(Hx(this._tag),this.description,e)}},Jx=class extends So(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return Ux(Hx(this._tag),this.description,e)}};Db(Bx)({_tag:Ry(`HttpError`),kind:J([`EncodeError`,`DecodeError`,`TransportError`,`InvalidUrlError`,`StatusCodeError`,`EmptyBodyError`]),cause:H(mb())});var Yx=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],Xx=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?Qp(Qp(e,`content-type`),`content-length`):(e=t.contentType===void 0?Qp(e,`content-type`):Yp(e,`content-type`,t.contentType),t.contentLength===void 0?Qp(e,`content-length`):Yp(e,`content-length`,t.contentLength.toString())),Zx=class extends So(`UrlError`){},Qx=(e,t,n)=>la({try:()=>{let r=new URL(e,$x());for(let e=0;e<t.params.length;e++){let[n,i]=t.params[e];i!==void 0&&r.searchParams.append(n,i)}return n!==void 0&&(r.hash=n),r},catch:e=>new Zx({cause:e})}),$x=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},eS=`~effect/http/HttpClientRequest`,tS={[eS]:eS,...Mn,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:vn(this.headers),body:this.body.toJSON()}},pipe(){return st(this,arguments)}};function nS(e,t,n,r,i,a){let o=Object.create(tS);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var rS=nS(`GET`,``,um,vi(),Kp,Nx),iS=e=>(t,n)=>sS(rS,{method:e,url:t,...n??void 0}),aS=iS(`POST`),oS=iS(`DELETE`),sS=T(2,(e,t)=>{let n=e;return t.method&&(n=cS(n,t.method)),t.url&&(n=pS(n,t.url)),t.headers&&(n=uS(n,t.headers)),t.urlParams&&(n=mS(n,t.urlParams)),t.hash&&(n=hS(n,t.hash)),t.body&&(n=gS(n,t.body)),t.accept&&(n=dS(n,t.accept)),t.acceptJson&&(n=fS(n)),n}),cS=T(2,(e,t)=>nS(t,e.url,e.urlParams,e.hash,e.headers,e.body)),lS=T(3,(e,t,n)=>nS(e.method,e.url,e.urlParams,e.hash,Yp(e.headers,t,n),e.body)),uS=T(2,(e,t)=>nS(e.method,e.url,e.urlParams,e.hash,Xp(e.headers,t),e.body)),dS=T(2,(e,t)=>lS(e,`Accept`,t)),fS=dS(`application/json`),pS=T(2,(e,t)=>{if(typeof t==`string`)return nS(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=om(n.searchParams),i=wi(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,nS(e.method,n.toString(),r,i,e.headers,e.body)}),mS=T(2,(e,t)=>nS(e.method,e.url,dm(e.urlParams,t),e.hash,e.headers,e.body)),hS=T(2,(e,t)=>nS(e.method,e.url,e.urlParams,yi(t),e.headers,e.body)),gS=T(2,(e,t)=>nS(e.method,e.url,e.urlParams,e.hash,Xx(e.headers,t),t)),_S=T(2,(e,t)=>gS(e,zx(t)));function vS(e){let t=Qx(e.url,e.urlParams,Ti(e.hash));return da(t)?yi(t.success):vi()}var yS=`~effect/http/HttpIncomingMessage`,bS=(e,t)=>{let n=cy(kb(e)),r=t?.reviver===void 0?void 0:cy(yb(kb(e),t));return e=>r===void 0?pf(e.json,e=>n(e,t)):pf(e.text,i=>i===``?pf(e.json,e=>n(e,t)):r(i,t))},xS=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=L(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=L(e.text)}catch{}let i={...t,headers:vn(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},SS=`~effect/http/HttpClientResponse`,CS=(e,t)=>new TS(e,t),wS=e=>e.status>=200&&e.status<300?P(e):F(new Vx({reason:new Kx({response:e,request:e.request,description:`non 2xx status code`})})),TS=class extends Nn{[yS];[SS];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[yS]=yS,this[SS]=SS}toJSON(){return xS(this,{_id:`HttpClientResponse`,request:this.request.toJSON(),status:this.status})}get status(){return this.source.status}get url(){if(this.source.url)return this.source.url.split(`#`)[0];let e=vS(this.request);return bi(e)?``:(e.value.hash=``,e.value.href)}get headers(){return qp(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=Mp(this.source.headers.getSetCookie())}get remoteAddress(){return vi()}get stream(){return this.source.body?dx({evaluate:()=>this.source.body,onError:e=>new Vx({reason:new qx({request:this.request,response:this,cause:e})})}):ux(new Vx({reason:new Jx({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return pf(this.text,e=>df({try:()=>e===``?null:JSON.parse(e),catch:e=>new Vx({reason:new qx({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=yf(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return pf(this.text,e=>df({try:()=>om(new URLSearchParams(e)),catch:e=>new Vx({reason:new qx({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=tf({try:()=>this.source.formData(),catch:e=>new Vx({reason:new qx({request:this.request,response:this,cause:e})})}).pipe(If,L)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=tf({try:()=>this.source.arrayBuffer(),catch:e=>new Vx({reason:new qx({request:this.request,response:this,cause:e})})}).pipe(If,L),this.arrayBufferBody}pipe(){return st(this,arguments)}},ES=e=>Jp({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Si(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),DS=`~effect/http/HttpClient`,OS=Di(`effect/HttpClient`),kS=T(2,(e,t)=>jS(n=>t(e.postprocess(n)),e.preprocess)),AS=kS(pf(wS)),jS=(e,t)=>{let n=Object.create(MS);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},MS={[DS]:DS,pipe(){return st(this,arguments)},...Mn,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(Yx.map(([e,t])=>[t,function(t,n){return this.execute(iS(e)(t,n))}]))},NS=e=>jS(t=>pf(t,t=>ff(n=>{let r=BS.get(t),i=r??new AbortController,a=Qx(t.url,t.urlParams,Ti(t.hash));if(ua(a))return F(new Vx({reason:new Gx({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(jo)||n.getRef(PS)(t)){let a=e(t,o,i.signal,n);return r?a:Rf(e=>Ef(e(a),{onSuccess(e){return zS.register(e,i),P(new VS(e,i))},onFailure(e){return Wu(e)&&i.abort(),cf(e)}}))}return Bf(n.getRef(LS)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method),a.attribute(`server.address`,o.origin),o.port!==``&&a.attribute(`server.port`,+o.port),a.attribute(`url.full`,o.toString()),a.attribute(`url.path`,o.pathname),a.attribute(`url.scheme`,o.protocol.slice(0,-1));let s=o.search.slice(1);s!==``&&a.attribute(`url.query`,s);let c=n.getRef(tm),l=n.getRef(FS);for(let e in t.headers)l(e,`request`)&&a.attribute(`http.request.header.${e}`,em(e,c)?`<redacted>`:t.headers[e]);return t=n.getRef(IS)?uS(t,ES(a)):t,Rf(s=>s(e(t,o,i.signal,n)).pipe(Vf(a,{captureStackTrace:!1}),Ef({onSuccess:e=>{a.attribute(`http.response.status_code`,e.status);for(let t in e.headers)l(t,`response`)&&a.attribute(`http.response.header.${t}`,em(t,c)?`<redacted>`:e.headers[t]);return r?P(e):(zS.register(e,i),P(new VS(e,i)))},onFailure(e){return!r&&Wu(e)&&i.abort(),cf(e)}})))})})),P),PS=aa(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>ft}),FS=aa(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>dt}),IS=aa(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:dt}),LS=aa(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>`http.client ${e.method}`}),RS=e=>kd(OS)(Of(t=>yf(e,e=>kS(e,Af(e=>ra(t,e)))))),zS=(()=>{if(`FinalizationRegistry`in globalThis&&globalThis.FinalizationRegistry){let e=new FinalizationRegistry(e=>{e.abort()});return{register(t,n){e.register(t,n,t)},unregister(t){e.unregister(t)}}}let e=new Map;return{register(t,n){e.set(t,setTimeout(()=>n.abort(),5e3))},unregister(t){let n=e.get(t);n!==void 0&&(clearTimeout(n),e.delete(t))}}})(),BS=new WeakMap,VS=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[SS]=SS;[yS]=yS;applyInterrupt(e){return nf(()=>(zS.unregister(this.original),Lf(e,()=>rf(()=>{this.controller.abort()}))))}get request(){return this.original.request}get url(){return this.original.url}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 lx(()=>(zS.unregister(this.original),fx(this.original.stream,rf(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[An](){return this.original[An]()}pipe(){return st(this,arguments)}},HS=aa(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),US=class extends Di()(`effect/http/FetchHttpClient/RequestInit`){},WS=RS(P(NS((e,t,n,r)=>{let i=r.getRef(HS),a=Xi(r.context,US)??{},o=a.headers?Zp(qp(a.headers),e.headers):e.headers;o[`content-length`]&&(o=Qp(o,`content-length`));let s=r=>yf(tf({try:()=>i(t,{...a,method:e.method,headers:o,body:r,duplex:typeof ReadableStream<`u`&&r instanceof ReadableStream?`half`:void 0,signal:n}),catch:t=>new Vx({reason:new Wx({request:e,cause:t})})}),t=>CS(e,t));switch(e.body._tag){case`Raw`:case`Uint8Array`:return s(e.body.body);case`FormData`:return s(e.body.formData);case`Stream`:return pf(hx(e.body.stream),s)}return s(void 0)}))),GS=e=>e,KS=(e,t,n)=>{let r=q([e,t]),i=oy(t);return r.pipe(Iy(vy(t),{decode:$m(e=>i(e)?e:n(e)),encode:$m(e=>e)}))},qS=e=>Sa(e)?`[${e.map(qS).join(`,`)}]`:e===null||St(e)||Ct(e)||wt(e)?JSON.stringify(e):`{${Ta(Object.entries(e),([e])=>e,Kd).map(([e,t])=>`${JSON.stringify(e)}:${qS(t)}`).join(`,`)}}`,JS=e=>qS(fy(Ab)(e)),YS=`0123456789abcdefghijklmnopqrstuvwxyz`,XS=W.check(Uy(/^[a-z]+$/)),ZS=/^[0-9a-z]{24}$/,QS=(e,t)=>Object.assign(e,{idPrefix:t}),Z=(e,t)=>{let n=fy(XS)(e);return QS(W.check(Uy(RegExp(`^${n}_[0-9a-z]{24}$`))).pipe(Y(t)),n)},$S=QS(W.check(Uy(ZS)).pipe(Y(`ignotum/id`)),void 0),eC=Z(`app`,`ignotum/hosted/AppId`),tC=Z(`dep`,`ignotum/hosted/VersionId`);Z(`team`,`ignotum/hosted/TeamId`);var nC=Z(`table`,`ignotum/runtime/TableId`);Z(`prn`,`ignotum/control/PlatformPrincipalId`),Z(`ses`,`ignotum/auth/SessionId`),Z(`acct`,`ignotum/auth/AccountId`),Z(`ver`,`ignotum/auth/VerificationId`),Z(`mbr`,`ignotum/auth/MemberId`),Z(`invt`,`ignotum/auth/InvitationId`),Z(`dvc`,`ignotum/auth/DeviceCodeId`),Z(`auth`,`ignotum/auth/InternalId`);var rC=Z(`inv`,`ignotum/sync/InvocationId`),iC=Z(`sub`,`ignotum/sync/SubscriptionId`);Z(`conn`,`ignotum/gateway/ConnectionId`),Z(`nonce`,`ignotum/runtime/RequestNonce`);var aC=Z(`req`,`ignotum/runtime/RequestId`);Z(`lock`,`ignotum/dev/DatabaseLockId`),Z(`iid`,`ignotum/id/AppUserId`),Z(`idu`,`ignotum/id/GlobalUserId`),Z(`ids`,`ignotum/id/SessionId`),Z(`idr`,`ignotum/id/RequestId`);var oC=Z(`epoch`,`ignotum/id/SessionEpoch`),sC=[`jpeg`,`png`,`webp`,`avif`,`gif`],cC=J(sC),lC={avif:`image/avif`,gif:`image/gif`,jpeg:`image/jpeg`,png:`image/png`,webp:`image/webp`},uC={activeGrantsPerConnection:1024,distinctFilesPerQuerySnapshot:256,fileBytes:10485760,filesPerMutation:8,filenameBytes:255,mutationBytes:26214400,preparationLifetimeMillis:9e5,stagedBytesPerApp:104857600},dC=Object.assign(W.pipe(Fy(Uy(/^file_[0-9A-Za-z_-]{20,128}$/)),Y(`ignotum/file/FileId`)),{idPrefix:`file`});Z(`upload`,`ignotum/file/FileUploadToken`),Z(`grant`,`ignotum/file/FileGrantToken`);var fC=Symbol.for(`ignotum/file/FileValue`),pC=Symbol.for(`ignotum/file/FileGrant`),mC=e=>jt(e)&&D(e,fC)&&jt(e[fC])&&D(e[fC],`id`)&&oy(dC)(e[fC].id)&&D(e,`format`)&&oy(cC)(e.format)&&D(e,`name`)&&St(e.name)&&D(e,`size`)&&Ct(e.size)&&D(e,`mimeType`)&&e.mimeType===lC[e.format],hC=(e,t,n)=>{let r={format:t.format,mimeType:lC[t.format],name:t.name,size:t.size};return Object.defineProperty(r,fC,{configurable:!1,enumerable:!1,value:Object.freeze({id:e}),writable:!1}),n!==void 0&&Object.defineProperty(r,pC,{configurable:!1,enumerable:!1,value:n,writable:!1}),Object.freeze(r)},gC=(e,t)=>hC(e,t),_C=e=>e[fC].id,vC=(e,t)=>hC(_C(e),e,t),yC=e=>e[pC],bC=G({$ignotum:U(`file`),id:dC,format:cC,name:W,size:nb.check(eb({minimum:0,maximum:uC.fileBytes}))}),xC=G({id:dC,format:cC,name:W,size:nb.check(eb({minimum:0,maximum:uC.fileBytes}))}),SC=G({path:K(q([W,rb])),file:xC}),CC=$v(mC,{title:`FileValue`}),wC=bC.pipe(Iy(CC,{decode:$m(e=>gC(e.id,{format:e.format,name:e.name,size:e.size})),encode:$m(e=>({$ignotum:`file`,format:e.format,id:_C(e),name:e.name,size:e.size}))})),TC=Py(()=>q([Cy,Ey,Gy,W,gb,wC,K(TC),ky(W,Ny(TC))])),EC=ky(W,Ny(vy(TC))),DC=e=>Pt(e)?gy(_b)(e):mC(e)?gy(wC)(e):globalThis.Array.isArray(e)?e.map(DC):Ct(e)?fy(Gy)(e):Ot(e)||St(e)||wt(e)?e:Object.fromEntries(Object.entries(e).flatMap(([e,t])=>t===void 0?[]:[[e,DC(t)]])),OC=e=>dy(jb)(DC(dy(EC)(e))),kC=e=>JSON.stringify(e),AC=(e,t,n)=>n.has(kC(t))?dy(_b)(e):oy(bC)(e)?fy(wC)(e):globalThis.Array.isArray(e)?e.map((e,r)=>AC(e,[...t,r],n)):Ot(e)||St(e)||Ct(e)||wt(e)?e:Object.fromEntries(Object.entries(e).map(([e,r])=>[e,AC(r,[...t,e],n)])),jC=(e,t)=>AC(e,[],new Set(t.map(kC))),MC=(e,t)=>{let n=new Set(t.map(kC));return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,AC(t,[e],n)]))},NC=Symbol.for(`ignotum/runtime/result/Result`),PC=Symbol.for(`ignotum/runtime/result/Completed`),FC=Symbol.for(`ignotum/runtime/result/Pending`),IC=`ignotum/error`,LC=Mb(),RC=Ay(G({_tag:W}),[ky(W,Ab)]).pipe(Y(IC)),zC=class extends Ob()(`InternalServerError`,{requestId:aC}){}.pipe(Y(IC)),BC=e=>D(e,NC)?e[NC]:P(e);function VC(){let e=function(){};return e.prototype=Ir({label:`IgnotumResult`,evaluate(){return this[NC]}}),e}var HC=VC(),UC=class e extends HC{[NC];constructor(e,t){super(),this[NC]=e,t!==void 0&&Object.defineProperty(this,PC,{value:t})}catch(t){let n={};for(let[e,r]of Object.entries(t))Dt(r)&&(n[e]=e=>BC(r(e)));let r=this[NC],i=Sf(r,n);return new e(i)}},WC=class{[FC]=FC},GC=e=>{if(D(e,PC))return e[PC]},KC=e=>D(e,PC)&&jt(e[PC])&&D(e[PC],`type`)&&e[PC].type===`Failure`,qC=e=>new UC(P(e),{type:`Success`,value:e}),JC=e=>new UC(F(e),{type:`Failure`,error:e}),YC=e=>new UC(sf(e)),XC=T(2,(e,t)=>{if(e instanceof WC){if(t.pending===void 0)throw Error(`A pending Result requires a pending matcher.`);return t.pending()}if(!D(e,NC))throw Error(`Unknown Result implementation.`);let n=GC(e);if(n?.type===`Success`){let e=n.value;return t.value(e)}if(!KC(e))throw Error(`Unknown or incomplete Result operation.`);let r=e[PC].error;if(r._tag===`InternalServerError`){let e=dy(zC)(r),n=t.internalError;if(n===void 0)throw e;return n(e)}let i=t.error;if(i===void 0)throw Error(`No matcher was provided for ${r._tag}.`);if(Dt(i))return i(r);let a=i,o=Object.hasOwn(a,r._tag)?a[r._tag]:void 0;if(o===void 0)throw Error(`No matcher was provided for ${r._tag}.`);return o(r)}),ZC=()=>new WC,QC=(e,t=[])=>{let n=ly(zC)(e);if(xi(n))return JC(n.value);let r=ly(RC)(e);if(bi(r))throw Error(`The server returned an invalid application error.`);return JC(LC({...MC(r.value,t),_tag:r.value._tag}))},$C={fail:JC,match:XC,succeed:qC,try:YC},ew=W.check(Uy(/^(?!\/)(?![A-Za-z]:\/)(?!.*(?:^|\/)\.\.(?:\/|$))(?!.*(?:^|\/)\.(?:\/|$))(?!.*\/\/)[^\\\0]+$/)).pipe(Y(`ignotum/version/ArtifactPath`)),tw=W.check(Uy(/^[0-9a-f]{64}$/)).pipe(Y(`ignotum/version/Sha256`)),nw=W.pipe(Y(`ignotum/hosted/InvocationKey`)),rw=rb.pipe(Y(`ignotum/hosted/ActivationGeneration`)),iw=rb.pipe(Y(`ignotum/hosted/AppStateRevision`)),aw=nb.check(Zy(0)).pipe(Y(`ignotum/hosted/VersionNumber`));nb.check(Zy(0)).pipe(Y(`ignotum/platform/ClientApiVersion`)),nb.check(Zy(0)).pipe(Y(`ignotum/platform/ServerApiVersion`)),W.check(Hy(),Uy(/^[a-z][a-z0-9]*(?:[./-][a-z0-9]+)*$/),sb(128)).pipe(Y(`ignotum/platform/CapabilityId`)),nb.check(Zy(0)).pipe(Y(`ignotum/platform/ProtocolVersion`));var ow=Z(`hist`,`ignotum/hosted/DataHistoryId`),sw=e=>G(e).annotate({parseOptions:{onExcessProperty:`error`}}),cw=nb.check(Qy(0),$y(2**53-1)),lw=cw.check(Zy(0)),uw=sw({major:lw,minor:cw});sw({major:lw,minimumMinor:cw});var dw=(e,t)=>e.major-t.major||e.minor-t.minor,fw=e=>`/_ignotum/v${e.major}.${e.minor}`;J([`client.js`,`selection`,`sync`,`session`,`session/requests`,`session/callback`]);var pw=(e,t)=>`${fw(e)}/${t}`;W.check(Uy(/^v[1-9][0-9]*\.(?:0|[1-9][0-9]*)$/));var mw=GS(sw({formatVersion:U(1),appId:eC,versionNumber:aw.check($y(2**53-1)),platform:uw,activationGeneration:rw.check(Zy(0),$y(2**53-1)),deploymentEpoch:lw,dataHistoryId:ow})),hw=(e,t)=>e.appId===t.appId&&e.versionNumber===t.versionNumber&&dw(e.platform,t.platform)===0&&e.activationGeneration===t.activationGeneration&&e.deploymentEpoch===t.deploymentEpoch&&e.dataHistoryId===t.dataHistoryId;sw({deploymentProtocol:U(3),selection:mw}),sw({formatVersion:U(1),operationId:ub,source:My(mw),target:mw,phase:J([`Closing`,`Preparing`,`Committed`,`Opening`,`Complete`,`Aborting`,`Aborted`])}).check(X(e=>{if(e.source!==null){if(e.source.appId!==e.target.appId)return`A transition belongs to one app`;if(e.target.activationGeneration<=e.source.activationGeneration)return`A transition must advance the activation generation, including rollback`}})).annotate({parseOptions:{onExcessProperty:`error`}});var gw=K(uw).check(X(e=>new Set(e.map(e=>e.major)).size===e.length?void 0:`Select exactly one minor for each supported major`));sw({formatVersion:U(1),operationId:ub,deploymentEpoch:lw,phase:J([`Closing`,`Deploying`,`Verifying`,`Resuming`,`Complete`]),expectedBuild:W.check(Uy(/^[a-f0-9]{64}$/)),previousBuild:My(W.check(Uy(/^[a-f0-9]{64}$/))),aborted:Ey,previous:gw,target:gw,diagnostic:My(W.check(sb(4096))),cursor:My(ub)}).check(X(e=>e.aborted&&e.previousBuild===null?`Bootstrap has no previous build to restore`:void 0)),G({buildSha256:tw,revisions:K(uw)});var _w=W.check(Uy(/^[a-z][a-z0-9_-]{0,63}$/)),vw=G({id:_w.pipe(Y(`ignotum/id/UserId`)),name:H(W),email:H(W),image:H(W)}),yw=K(J([`name`,`email`,`image`])).check(lb());zy(`IdRequired`,{}).pipe(Y(IC));var bw=G({sessionEpoch:W,viewRevision:rb,user:My(vw),validUntil:Gy}),xw=G({development:H(U(!0)),outcome:H(J([`SignedIn`,`ProfileUpdated`,`Cancelled`])),...bw.fields,serverTime:Gy,expiresAt:Gy}),Sw=W.check(X(e=>{if(!e.startsWith(`/`)||e.startsWith(`//`)||e.includes(`\\`))return!1;let t=new URL(e,`https://app.ignotum.invalid`);return t.origin===`https://app.ignotum.invalid`&&t.pathname!==`/_ignotum`&&!t.pathname.startsWith(`/_ignotum/`)},{message:`Return to a path within this app.`})),Cw=G({intent:J([`signIn`,`requestProfile`]),profile:yw,returnTo:Sw,sessionEpoch:W}),ww=G({redirectUrl:W,expiresAt:Gy}),Tw=J([`SignedIn`,`ProfileUpdated`,`Cancelled`]),Ew={sessionMillis:2592e6,leaseMillis:3e4,refreshMillis:2e4,requestMillis:6e5,codeMillis:6e4,requestBytes:16384,pendingRequests:5},Dw={major:1,minor:0},Ow=pw(Dw,`session`),kw=pw(Dw,`session/requests`);pw(Dw,`session/callback`);var Aw=GS(G({formatVersion:U(1),username:My(_w),epoch:W})),jw=`ignotum.id.development`,Mw=e=>crypto.getRandomValues(new Uint8Array(e)),Nw=(e,t,n)=>{let r=256-256%e.length;if(r===256){let r=e.length-1;return(i=t)=>{if(!i)return``;let a=``;for(;;){let t=n(i),o=i;for(;o--;)if(a+=e[t[o]&r],a.length>=i)return a}}}let i=Math.ceil(409.6*t/r);return(a=t)=>{if(!a)return``;let o=``;for(;;){let t=n(i),s=i;for(;s--;)if(t[s]<r&&(o+=e[t[s]%e.length],o.length>=a))return o}}},Pw=(e,t=21)=>Nw(e,t|0,Mw),Fw=(e,t)=>fy(e)(e.idPrefix===void 0?t:`${e.idPrefix}_${t}`),Iw=class e extends Di()(`@ignotum/shared/id/IdGenerator`){static layer=Dd(e,()=>{let t=Pw(YS,24);return e.of({generate:e=>rf(()=>Fw(e,t()))})});static deterministic=(t=1)=>Dd(e,()=>{let n=new Map;return e.of({generate:e=>rf(()=>{let r=(n.get(e.idPrefix)??t-1)+1;return n.set(e.idPrefix,r),Fw(e,r.toString(36).padStart(24,`0`))})})})},Lw=class extends Ob()(`IdRequestError`,{message:W}){},Rw=`ignotum.id.outcome`,zw=yb(Aw),Bw=class e extends Di()(`ignotum/client/id/BrowserSession`){static layer=kd(e,sf(function*(){let t=(yield*OS).pipe(AS),n=yield*Iw,r=yield*Hb(1),i=new Set,a={status:`pending`},o,s=0,c=1/0,l=!1,u,d,f=()=>{for(let e of i)e()},p=e=>{s+=1,c=1/0,d!==void 0&&clearTimeout(d),o=void 0,a=e===void 0?{status:`pending`,outcome:a.outcome}:{status:`error`,error:e,outcome:a.outcome},f()},m=(e,t)=>{s+=1,d!==void 0&&clearTimeout(d),o=e,a=e.user===null?{status:`signedOut`,outcome:a.outcome}:{status:`signedIn`,user:e.user,outcome:a.outcome};let n=Math.max(0,e.validUntil-t);c=performance.now()+n,n<2147483647&&(d=setTimeout(()=>p(),n)),f()},h=()=>{o!==void 0&&performance.now()>=c&&p()};globalThis.addEventListener?.(`focus`,h),globalThis.document?.addEventListener(`visibilitychange`,h),yield*Mf(()=>rf(()=>{d!==void 0&&clearTimeout(d),i.clear(),globalThis.removeEventListener?.(`focus`,h),globalThis.document?.removeEventListener(`visibilitychange`,h)}));let g=()=>{try{let e=globalThis.sessionStorage.getItem(Rw);if(e!==null){let t=ly(Tw)(e);xi(t)&&(a={...a,outcome:t.value}),globalThis.sessionStorage.removeItem(Rw)}}catch{}},_=()=>{if(!l||u===void 0)return``;let e=new URLSearchParams({epoch:u.epoch});return u.username!==null&&e.set(`username`,u.username),`?${e}`},v=R(`BrowserSession.read`)(function*(){return yield*t.get(`${Ow}${_()}`,{headers:{"x-ignotum-request":`1`}}).pipe(pf(bS(xw)))}),y=e=>r.withPermits(1)(sf(function*(){let t=s;return yield*sf(function*(){let e=performance.now(),r=yield*v();if(l=r.development===!0,l&&u===void 0){let e=globalThis.sessionStorage.getItem(jw);u=Ci(e===null?vi():uy(zw)(e),()=>({formatVersion:1,username:null,epoch:``})),u.epoch===``&&(u={...u,epoch:yield*n.generate(oC)}),globalThis.sessionStorage.setItem(jw,gy(zw)(u)),r=yield*v()}return s===t?(g(),r.outcome!==void 0&&(a={...a,outcome:r.outcome}),m(r,r.serverTime+performance.now()-e),r):o===void 0?yield*Lw.make({message:`Your ID session changed while loading.`}):o}).pipe(I(()=>Lw.make({message:`Could not load your ID session.`})),wf(n=>e&&s===t?rf(()=>p(n.message)):af))})),b=y(!0),ee=y(!1),x=R(`BrowserSession.start`)(function*(e,n,r){let i=o??(yield*b);if(e===`requestProfile`&&i.user===null)return yield*Lw.make({message:`Sign in before requesting profile information.`});let a=yield*sy(Cw)({intent:e,profile:n,sessionEpoch:i.sessionEpoch,returnTo:r??`${globalThis.location.pathname}${globalThis.location.search}${globalThis.location.hash}`}).pipe(I(()=>Lw.make({message:`The ID request is invalid.`}))),s=yield*aS(kw).pipe(lS(`x-ignotum-request`,`1`),_S(a),t.execute,pf(bS(ww)),I(()=>Lw.make({message:`Could not start the ID request.`})));if(o?.sessionEpoch!==i.sessionEpoch)return yield*Lw.make({message:`Your ID session changed. Try again.`});globalThis.location.assign(s.redirectUrl)}),te=sf(function*(){let e=o??(yield*b);yield*oS(Ow).pipe(lS(`x-ignotum-request`,`1`),_S({sessionEpoch:e.sessionEpoch}),t.execute,I(()=>Lw.make({message:`Could not sign out.`}))),p(),l&&(u={formatVersion:1,username:null,epoch:yield*n.generate(oC)},globalThis.sessionStorage.setItem(jw,gy(zw)(u))),globalThis.location.reload()});return e.of({snapshot:()=>(h(),a),current:()=>(h(),o),remainingLeaseMillis:()=>(h(),o===void 0?0:Math.max(0,c-performance.now())),subscribe:e=>(i.add(e),()=>{i.delete(e)}),accept:m,suspend:p,bootstrap:b,renew:ee,start:x,signOut:te,socketParameters:_})})).pipe(Pd(WS))},Vw=e=>G(e).annotate({parseOptions:{onExcessProperty:`error`}}),Hw=Z(`rec`,`ignotum/platform/RecoverySessionId`),Uw=Vw({invocationId:rC,originalSelection:mw}),Ww={maxOperations:1024,maxRetentionMs:6048e5};Vw({formatVersion:U(1),appId:eC,clientSessionId:Hw,recordedAt:rb,expiresAt:rb,operations:K(Uw).check(sb(Ww.maxOperations))}).check(X(e=>{let t=[];(e.expiresAt<=e.recordedAt||e.expiresAt-e.recordedAt>Ww.maxRetentionMs)&&t.push({path:[`expiresAt`],issue:`Recovery retention must be positive and bounded`}),e.operations.some(t=>t.originalSelection.appId!==e.appId)&&t.push({path:[`operations`],issue:`Recovery operations must belong to the record's app`});let n=e.operations.map(e=>`${e.originalSelection.dataHistoryId}/${e.invocationId}`);return new Set(n).size!==n.length&&t.push({path:[`operations`],issue:`Recovery operation identities must be unique within a data history`}),t})).annotate({parseOptions:{onExcessProperty:`error`}});var Gw=W.check(Wy()).pipe(Y(`ignotum/runtime/PaginationCursor`)),Kw=nb.check(eb({minimum:1,maximum:1e3})).pipe(Y(`ignotum/runtime/PaginationPageSize`));G({cursor:My(Gw),pageSize:Kw});var qw=q([G({type:U(`Table`),createdAt:nb,id:W}),G({type:U(`Index`),key:W.check(Uy(/^(?:[0-9a-f]{2})*$/)).pipe(Y(`ignotum/runtime/EncodedIndexKey`))})]);yb(GS(G({version:U(1),query:W,position:qw})));var Jw=W.pipe(Y(`ignotum/runtime/IndexIdentity`)),Yw=W.check(Uy(/^(?:[0-9a-f]{2})*$/)).pipe(Y(`ignotum/runtime/EncodedIndexKey`));q([Ey,Gy,W]);var Xw=W.check(Uy(/^[A-Za-z_$][A-Za-z0-9_$]*$/));xy([`api.`,Xw,`.`,Xw]);var Zw=by([`api.`,Xw,`.`,Xw]),Qw=G({type:U(`Subscribe`),id:iC,function:Zw,args:Ab}),$w=G({type:U(`Unsubscribe`),id:iC}),eT=G({type:U(`Invoke`),id:rC,kind:U(`Mutation`),function:Zw,args:Ab}),tT=q([Qw,$w,G({type:U(`Prepare`),id:rC,kind:U(`Mutation`),function:Zw,args:Ab,files:K(dC)}),eT]),nT=q([G({type:U(`Subscription`),id:iC}),G({type:U(`Invocation`),id:rC})]),rT=K(K(q([W,rb]))),iT=G({type:U(`Success`),value:H(Ab),dates:H(rT)}),aT=G({type:U(`Failure`),error:Ab,dates:H(rT)}),oT=q([iT,aT]),sT=G({session:H(bw),serverTime:H(Gy),type:U(`Handshake`),appId:eC,versionId:tC,generation:rw}),cT=G({identity:H(G({sessionEpoch:W,viewRevision:rb,dependsOnId:Ey})),type:U(`Snapshot`),id:iC,result:oT,revision:iw,files:H(K(G({id:dC,url:W})))}),lT=G({sessionEpoch:H(W),type:U(`Preparation`),id:rC,kind:U(`Mutation`),uploads:K(G({id:dC,url:H(W)}))}),uT=G({sessionEpoch:H(W),type:U(`Result`),id:rC,result:iT,committedRevision:iw}),dT=G({sessionEpoch:H(W),type:U(`Result`),id:rC,result:aT}),fT=J([`SessionChanged`,`SessionExpired`,`DuplicateOperationId`,`FunctionUnavailable`,`InvalidArguments`,`InvalidMessage`,`InvocationIdConflict`,`ResourceLimitExceeded`,`UnknownFunction`,`WrongFunctionKind`]),pT=G({sessionEpoch:H(W),type:U(`Error`),operation:H(nT),code:fT,message:W}),mT=G({type:U(`Version`),versionId:tC,generation:rw}),hT=q([q([G({type:U(`Session`),event:U(`Updated`),serverTime:Gy,session:bw}),G({type:U(`Session`),event:J([`SignedOut`,`Revoked`,`Expired`,`Unavailable`,`Replaced`]),sessionEpoch:W})]),G({type:U(`Invalidate`),sessionEpoch:W,ids:K(iC)}),sT,cT,lT,uT,dT,pT,mT]);yb(tT),yb(hT),W.pipe(Y(`ignotum/hosted/QueryKey`));var gT=G({type:U(`Table`),tableId:nC}),_T=G({type:U(`Document`),tableId:nC,id:$S}),vT=G({type:U(`IndexRange`),tableId:nC,index:Jw,lower:H(Yw),upper:H(Yw)}),yT=G({type:U(`IndexPoint`),tableId:nC,index:Jw,key:Yw}),bT=q([G({type:U(`Id`)}),gT,_T,vT]),xT=q([gT,_T,yT]);q([bT,yT]);var ST=K(bT),CT=K(xT),wT=G({type:U(`Query`),result:oT,dependencies:ST,observedRevision:iw,files:H(K(SC))}),TT=q([G({type:U(`AddReference`),file:xC,tableId:nC,documentId:$S}),G({type:U(`RemoveReference`),fileId:dC,tableId:nC,documentId:$S})]),ET=G({id:rC,dataHistoryId:H(ow),committedRevision:iw,effects:K(TT)});G({appId:eC}),G({batches:K(ET)}),G({appId:eC,invocationId:rC,acknowledgedAt:nb,dataHistoryId:ow}),G({completed:U(!0)});var DT=q([G({type:U(`Mutation`),result:iT,invalidations:CT,committedRevision:iw,fileEffects:H(ET)}),G({type:U(`Mutation`),result:aT})]);q([wT,DT]);var OT=G({clientSessionId:Hw,sessionEpoch:My(W)});G({appId:eC,identity:Uw,owner:OT});var kT=q([G({type:U(`Settled`),result:DT}),G({type:U(`Interrupted`)}),G({type:U(`Pending`)}),G({type:U(`Uncertain`)})]),AT={appId:eC,versionId:tC,generation:rw,selection:H(mw),invocationKey:nw,function:Zw,args:Ab,identity:H(bw)};q([G({...AT,type:U(`Query`)}),G({...AT,type:U(`Mutation`),invocationId:rC,recoveryOwner:H(OT),files:H(K(SC))})]),G({appId:eC,expectedRevision:iw}),G({currentRevision:iw});var jT=class extends Ob()(`RuntimeVersionUnavailable`,{versionId:tC,message:W}){},MT=J([`SessionExpired`,`FunctionUnavailable`,`InvalidArguments`,`InvocationIdConflict`,`ResourceLimitExceeded`,`UnknownFunction`,`WrongFunctionKind`]),NT=class extends Ob()(`RuntimeInvocationRejected`,{code:MT,invocationKey:nw,message:W}){},PT=class extends Ob()(`RuntimeInvocationUnavailable`,{invocationKey:nw,message:W}){};Ob()(`RuntimeRevisionRejected`,{appId:eC,message:W}),q([jT,NT,PT]);var FT={major:1,minor:0},IT=pw(FT,`sync`),LT=pw(FT,`selection`),RT=G({protocolVersion:U(1),selection:mw}),zT=q([G({type:U(`Connect`),protocolVersion:rb,selection:mw,clientSessionId:Hw}),G({type:U(`Prepare`),invocationId:rC,function:Zw,args:Ab,files:K(dC).check(sb(uC.filesPerMutation))}),G({type:U(`Invoke`),invocationId:rC,function:Zw,args:Ab}),G({type:U(`RecoverMutation`),id:W.check(sb(128)),identity:Uw}),G({type:U(`Subscribe`),id:iC,function:Zw,args:Ab}),G({type:U(`Unsubscribe`),id:iC})]),BT=G({type:U(`UpgradeRequired`),selection:mw}),VT=q([BT,G({type:U(`Handshake`),protocolVersion:U(1),selection:mw,session:bw,serverTime:Gy}),G({type:U(`Preparation`),invocationId:rC,uploads:K(G({id:dC,url:H(W)}))}),G({type:U(`MutationOutcome`),id:W,identity:Uw,outcome:kT}),G({type:U(`QuerySnapshot`),selection:mw,id:iC,result:wT,files:H(K(G({id:dC,url:W})))}),G({type:U(`Error`),id:H(W),code:J([`PlatformUpgrading`,`SessionExpired`,`InvalidMessage`,`Unavailable`,`InvalidArguments`,`InvocationIdConflict`,`ResourceLimitExceeded`]),message:W})]),HT=class extends Ob()(`ConnectionUnavailable`,{cause:H(mb()),message:W}){},UT=class extends Ob()(`PlatformUpgrading`,{message:W}){},WT=class extends Ob()(`InvalidMutationArguments`,{cause:mb(),function:Zw,message:W}){},GT=class extends Ob()(`InvalidServerMessage`,{cause:mb(),message:W}){},KT=class extends Ob()(`ServerError`,{code:J([`PlatformUpgrading`,`SessionExpired`,`InvalidMessage`,`Unavailable`,`InvalidArguments`,`InvocationIdConflict`,`ResourceLimitExceeded`]),message:W}){},qT=q([UT,HT,WT,GT,KT]),JT=bx([vx(({attributes:e,error:t})=>{globalThis.console.error(`Ignotum infrastructure error`,t,e)})]);R(`ClientErrorReporter.report`)(function*(e){yield*xx(Bu(e))});var YT=GS(G({formatVersion:U(1),appId:eC,clientSessionId:Hw,attempts:rb.check($y(3)),attemptedAt:rb,target:My(mw),uncertainStorage:Ey}).annotate({parseOptions:{onExcessProperty:`error`}})),XT=yb(YT),ZT=class{selection;browser;callbacks;clientSessionId;key;tab;snapshot={phase:`connecting`,recovery:[]};listeners=new Set;target;attempt;disposed=!1;storageAvailable=!0;readyTimer;constructor(e,t,n){this.selection=e,this.browser=t,this.callbacks=n,this.key=`ignotum.v3.tab.${e.appId}`,this.tab={formatVersion:1,appId:e.appId,clientSessionId:Hw.make(`rec_${t.crypto.randomUUID().replaceAll(`-`,``).slice(0,24)}`),attempts:0,attemptedAt:0,target:null,uncertainStorage:!1};try{let n=t.sessionStorage.getItem(this.key);if(n!==null){let t=uy(XT,{onExcessProperty:`error`})(n);xi(t)&&t.value.appId===e.appId&&(t.value.target===null||t.value.target.appId===e.appId)?this.tab=t.value:this.reportRecovery(`Saved update information could not be read. Previous mutation outcomes may be unknown.`)}}catch{this.storageAvailable=!1}let r=ly(G({__ignotumUpdate:YT}))(t.history.state);xi(r)&&r.value.__ignotumUpdate.appId===e.appId&&r.value.__ignotumUpdate.attemptedAt>=this.tab.attemptedAt&&(r.value.__ignotumUpdate.target===null||r.value.__ignotumUpdate.target.appId===e.appId)&&(this.tab=r.value.__ignotumUpdate),this.tab.uncertainStorage&&this.reportRecovery(`Some previous mutation outcomes could not be saved in browser storage and remain unknown.`),this.clientSessionId=this.tab.clientSessionId,this.save()}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));update(e){if(!this.disposed){this.snapshot=e;for(let e of this.listeners)e()}}reportRecovery(e){this.snapshot.recovery.includes(e)||this.update({...this.snapshot,recovery:[...this.snapshot.recovery,e].slice(-100)})}dismissRecovery=()=>{this.tab={...this.tab,uncertainStorage:!1},this.save(),this.update({...this.snapshot,recovery:[]})};save(){let e=!1;try{this.browser.sessionStorage.setItem(this.key,gy(XT)(this.tab)),this.storageAvailable=!0,e=!0}catch{this.storageAvailable=!1}try{let t=ly(ky(W,Sy))(this.browser.history.state);this.browser.history.replaceState({...Ci(t,()=>({})),__ignotumUpdate:gy(YT)(this.tab)},``),e=!0}catch{}return e}get obsolete(){return this.target!==void 0||this.attempt!==void 0}get ready(){return this.snapshot.phase===`ready`&&!this.obsolete}connecting(){this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.obsolete||this.update({...this.snapshot,phase:`connecting`,message:void 0})}accepted(){this.obsolete||(this.update({...this.snapshot,phase:`ready`,message:void 0}),this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.readyTimer=setTimeout(()=>{this.tab={...this.tab,attempts:0,attemptedAt:0,target:null},this.save()},6e4))}unavailable(e=`The app could not check for updates. Reconnect and try again.`){this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.obsolete||this.update({...this.snapshot,phase:`error`,message:e})}require(e){return this.disposed?Promise.resolve():(e!==void 0&&(this.target=e),this.callbacks.stopAdmission(),this.attempt!==void 0&&this.snapshot.phase!==`error`?this.attempt:(this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.update({...this.snapshot,phase:`settling`,message:`Updating the app. Waiting briefly for pending changes…`}),this.attempt=this.run(),this.attempt))}async run(){let e=Date.now()+2e3;for(;!this.disposed&&this.callbacks.unresolved()>0&&Date.now()<e;)await new Promise(e=>setTimeout(e,25));if(!this.disposed)try{let e=this.callbacks.persist();for(let t of e)this.reportRecovery(t);e.length>0&&(this.tab={...this.tab,uncertainStorage:!0},await new Promise(e=>setTimeout(e,1e3)));let t=await this.callbacks.freshSelection();if(t!==void 0&&t.appId!==this.selection.appId)throw Error(`The app address now refers to a different app.`);this.target=t??this.target;let n=await this.browser.fetch(this.browser.location.href,{cache:`no-store`,credentials:`same-origin`,headers:{accept:`text/html`},signal:AbortSignal.timeout(1e4)});if(!n.ok)throw Error(`The updated app document is temporarily unavailable.`);if(await n.body?.cancel(),this.disposed)return;let r=t!==void 0&&this.tab.target!==null&&!hw(this.tab.target,t)?0:this.tab.attempts;if(r>=2)throw Error(`The app update could not load a consistent release. Try again when the connection or release is available.`);if(this.tab={...this.tab,attempts:r+1,attemptedAt:Date.now(),target:t??this.target??this.selection},!this.save())throw Error(`Browser storage is unavailable. Pending changes may have unknown outcomes. Use Reload app to continue the update.`);this.update({...this.snapshot,phase:`reloading`,message:`Loading the updated app…`}),this.callbacks.reload()}catch(e){this.update({...this.snapshot,phase:`error`,message:e instanceof Error?e.message:`The app update could not be loaded. Try again.`})}}retry=()=>{if(!this.disposed){if(!this.storageAvailable){this.callbacks.persist(),this.callbacks.reload();return}this.tab={...this.tab,attempts:0,attemptedAt:0},this.save(),this.attempt=void 0,this.require(this.target)}};async check(){if(this.obsolete||this.disposed)return!1;try{let e=await this.callbacks.freshSelection();return e===void 0||!hw(this.selection,e)?(this.require(e),!1):!this.obsolete&&!this.disposed}catch{return this.unavailable(),!1}}dispose(){this.disposed=!0,this.readyTimer!==void 0&&clearTimeout(this.readyTimer),this.listeners.clear()}},QT={maxEntries:100,retentionMs:864e5,maxBytes:65536},$T=G({identity:Uw,recordedAt:rb,expiresAt:rb,state:J([`pending`,`settled`,`interrupted`,`uncertain`])}),eE=GS(G({formatVersion:U(1),appId:eC,sessionEpoch:W,clientSessionId:Hw,entries:K($T).check(sb(QT.maxEntries))}).check(X(e=>{let t=e.entries.map(e=>tE(e.identity));return new Set(t).size===t.length&&e.entries.every(t=>t.identity.originalSelection.appId===e.appId&&t.expiresAt>t.recordedAt&&t.expiresAt-t.recordedAt<=QT.retentionMs)})).annotate({parseOptions:{onExcessProperty:`error`}})),tE=e=>`${e.originalSelection.dataHistoryId}/${e.invocationId}`,nE=e=>new TextEncoder().encode(e).byteLength,rE=class{options;storageKey;clientSessionId;constructor(e){this.options=e,this.storageKey=`ignotum:recovery:${e.appId}`,this.clientSessionId=e.clientSessionId}storage(){let e=this.options.storage;return e===void 0?globalThis.sessionStorage:Dt(e)?e():e}now(){return this.options.now?.()??wp(Cp())}snapshot(e,t){return{clientSessionId:this.clientSessionId,entries:e,issues:t}}read(){let e;try{e=this.storage().getItem(this.storageKey)}catch{return this.snapshot([],[`denied`])}if(e===null)return this.snapshot([],[]);if(nE(e)>QT.maxBytes)return this.discard(`full`);let t=ly(yb(eE),{onExcessProperty:`error`})(e);if(t._tag===`None`||t.value.appId!==this.options.appId)return this.discard(`corrupt`);if(t.value.sessionEpoch!==this.options.sessionEpoch)return this.discard(`session-changed`);this.clientSessionId=t.value.clientSessionId;let n=this.now(),r=t.value.entries.filter(e=>e.expiresAt>n&&e.recordedAt<=n),i=r.length===t.value.entries.length?[]:[`expired`];return i.length===0?this.snapshot(r,i):this.persist(r,i)}discard(e){try{return this.storage().removeItem(this.storageKey),this.snapshot([],[e])}catch{return this.snapshot([],[e,`denied`])}}persist(e,t){let n={formatVersion:1,appId:this.options.appId,sessionEpoch:this.options.sessionEpoch,clientSessionId:this.clientSessionId,entries:e},r=my(yb(eE))(n);if(r._tag===`None`)return this.snapshot(e,[...t,`corrupt`]);if(nE(r.value)>QT.maxBytes)return this.snapshot(e,[...t,`full`]);try{return this.storage().setItem(this.storageKey,r.value),this.snapshot(e,t)}catch(n){return this.snapshot(e,[...t,n instanceof DOMException&&n.name===`QuotaExceededError`?`full`:`denied`])}}write(e){let t=this.read();if(t.issues.includes(`denied`))return t;let n=new Map(t.entries.map(e=>[tE(e.identity),e])),r=this.now();for(let i of e){if(i.originalSelection.appId!==this.options.appId)return this.snapshot(t.entries,[...t.issues,`corrupt`]);let e=tE(i);n.has(e)||n.set(e,{identity:{invocationId:i.invocationId,originalSelection:i.originalSelection},recordedAt:r,expiresAt:r+QT.retentionMs,state:`pending`})}return n.size>QT.maxEntries?this.snapshot(t.entries,[...t.issues,`full`]):this.persist([...n.values()],t.issues)}reconcile(e,t){let n=this.read();return n.issues.includes(`denied`)?n:this.persist(n.entries.map(n=>tE(n.identity)===tE(e)?{...n,state:t}:n),n.issues)}remove(e){let t=this.read();return t.issues.includes(`denied`)?t:this.persist(t.entries.filter(t=>tE(t.identity)!==tE(e)),t.issues)}clear(){try{return this.storage().removeItem(this.storageKey),this.snapshot([],[])}catch{return this.snapshot([],[`denied`])}}},iE={url:e=>{let t=yC(e);if(t===void 0)throw Error(`This FileValue has no active query grant.`);return t}},aE={};for(let e of sC)aE[lC[e]]=e;var oE=Dy.check(X(e=>Object.prototype.toString.call(e)===`[object Object]`,{message:`Mutation objects must contain ordinary fields; built-in collections are unsupported.`})),sE=(e,t)=>{if(e instanceof File){t.add(e);return}if(!(mC(e)||Pt(e))){if(globalThis.Array.isArray(e)){for(let n of e)sE(n,t);return}if(jt(e))for(let n of Object.values(fy(oE)(e)))sE(n,t)}},cE=(e,t)=>e instanceof File?t.get(e):mC(e)||Pt(e)?e:globalThis.Array.isArray(e)?e.map(e=>cE(e,t)):jt(e)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,cE(n,t)])):e,lE=R(`SyncClient.prepareMutationArguments`)(function*(e){let t=yield*Iw,n=yield*df(()=>{let t=new Set;if(sE(e,t),t.size>uC.filesPerMutation)throw Error(`A mutation may upload at most ${uC.filesPerMutation} files.`);if([...t].reduce((e,t)=>e+t.size,0)>uC.mutationBytes)throw Error(`Mutation uploads may total at most ${uC.mutationBytes} bytes.`);return t}),r=new Map,i=new Map;for(let e of n){let n=yield*df(()=>{let t=aE[e.type.toLowerCase()];if(t===void 0)throw Error(`File '${e.name}' has unsupported media type '${e.type||`unknown`}'.`);if(e.size===0||e.size>uC.fileBytes)throw Error(`File '${e.name}' must be between 1 and ${uC.fileBytes} bytes.`);if(new TextEncoder().encode(e.name).byteLength>uC.filenameBytes)throw Error(`File '${e.name}' has a filename that is too long.`);return t}),a=yield*t.generate(dC);r.set(e,gC(a,{format:n,name:e.name,size:e.size})),i.set(a,e)}return{value:n.size===0?e:yield*df(()=>cE(e,r)),nativeFiles:i,fileIds:Array.from(i.keys())}}),uE=(e,t)=>{if(t.length===0)return e;let n=new Map;for(let e of t){if(n.has(e.id))throw Error(`A query file grant ID is duplicated.`);n.set(e.id,e.url)}let r=new Set,i=e=>{if(mC(e)){let t=_C(e),i=n.get(t);return i===void 0?e:(r.add(t),vC(e,i))}return globalThis.Array.isArray(e)?e.map(i):!jt(e)||Pt(e)?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,i(t)]))},a=i(e);if(r.size!==n.size)throw Error(`A query file grant has no result value.`);return a},dE=R(`uploadPreparedFiles`)(function*(e,t,n){let r=new Set(e.keys()),i=new Set,a=[];for(let n of t){if(!r.has(n.id)||i.has(n.id))return yield*GT.make({cause:Error(`Unexpected prepared file '${n.id}'.`),message:`The server returned invalid application file preparation data.`});i.add(n.id);let t=e.get(n.id);if(t===void 0)return yield*GT.make({cause:Error(`Missing native file '${n.id}'.`),message:`The server prepared an unknown application file.`});n.url!==void 0&&a.push({file:t,url:n.url})}if(i.size!==r.size)return yield*GT.make({cause:Error(`The server omitted a prepared file.`),message:`The server returned incomplete application file preparation data.`});yield*$d(a,R(`SyncClient.uploadFile`)(function*({file:e,url:t}){let r=yield*tf({try:n=>fetch(t,{method:`PUT`,body:e,headers:{"content-type":e.type},signal:n}),catch:t=>HT.make({cause:t,message:`File '${e.name}' could not be uploaded.`})});if(!r.ok){let t=yield*ef(()=>r.text());return yield*WT.make({cause:Error(t),function:n,message:`File '${e.name}' was rejected by application storage.`})}}),{concurrency:3,discard:!0})}),fE=yb(zT),pE=yb(Sy),mE=gy(fE),hE=ly(pE),gE=ly(BT),_E=ly(VT),vE=2147483647,yE=Ew.leaseMillis-Ew.refreshMillis,bE=e=>{switch(e){case`denied`:return`Browser storage is unavailable. Some previous mutation outcomes may be unknown.`;case`full`:return`Browser recovery storage is full. Some mutation outcomes could not be saved.`;case`corrupt`:return`Saved mutation information could not be read. Its outcomes remain unknown.`;case`expired`:return`Some saved mutation information expired. Its outcomes remain unknown.`;case`session-changed`:return`The browser session changed. Previous mutation outcomes cannot be retrieved in this session.`}},xE=class{selection;browser;helpers;upgrade;queries;socket;acceptedSocket;session;ids;sessionEpoch;sessionViewRevision;unsubscribeSession;sessionDeadline=0;clientSessionId;journal;pending=new Map;recovery=new Map;recoveryDeadlines=new Map;recoveryTimeouts=new Map;recoveryTimers=new Set;reconnectTimer;handshakeTimer;sessionTimer;heartbeat;reconnectDelay=250;disposed=!1;readyWaiters=new Set;suspended=!0;lastActivity=Date.now();validation;connectionGeneration=0;constructor(e,t,n,r){this.selection=e,this.browser=t,this.helpers=n,this.upgrade=new ZT(e,t,{stopAdmission:()=>{this.suspended=!0;for(let e of this.pending.values())e.preparation!==void 0&&ad(e.prepared,F(UT.make({message:`The app is updating. This upload was interrupted before its mutation ran.`})));r.stopAdmission()},unresolved:()=>this.pending.size,persist:()=>this.persistPending(),reload:r.reload,freshSelection:this.freshSelection}),this.clientSessionId=this.upgrade.clientSessionId,this.queries=n.makeQueryCache(nf(()=>this.ids===void 0?uf(`The client identity service is not ready.`):this.ids.generate(iC)),e=>rf(()=>{this.canSend()&&this.send(e)}))}attachSession(e,t){this.disposed||(this.unsubscribeSession?.(),this.session=e,this.ids=t,this.unsubscribeSession=e.subscribe(()=>{let t=e.current();(t===void 0||this.sessionEpoch!==void 0&&(t.sessionEpoch!==this.sessionEpoch||t.viewRevision!==this.sessionViewRevision))&&(this.queries.invalidatePrivate(),this.suspended=!0,this.acceptedSocket=void 0,this.socket?.close())}))}whenReady(){return this.upgrade.ready?Promise.resolve(!0):this.upgrade.obsolete||this.disposed?Promise.resolve(!1):new Promise(e=>{let t=r=>{n(),this.readyWaiters.delete(t),e(r)},n=this.upgrade.subscribe(()=>{(this.upgrade.ready||this.upgrade.obsolete||this.disposed)&&t(this.upgrade.ready)});this.readyWaiters.add(t)})}retry=()=>{this.upgrade.obsolete?this.upgrade.retry():this.wake()};recoverLoad=async()=>{await this.upgrade.check()};freshSelection=async()=>{let e=await this.browser.fetch(LT,{cache:`no-store`,credentials:`same-origin`,signal:AbortSignal.timeout(1e4)});if(!e.ok)throw Error(`The current app selection is unavailable.`);return Ti(ly(RT)(await e.json()))?.selection};start(){this.disposed||(this.browser.addEventListener(`pageshow`,this.wake),this.browser.addEventListener(`pagehide`,this.hide),this.browser.addEventListener(`online`,this.resume),this.browser.addEventListener(`offline`,this.offline),this.browser.addEventListener(`focus`,this.wake),this.browser.document.addEventListener(`visibilitychange`,this.visibility),this.heartbeat=setInterval(()=>{let e=Date.now();e-this.lastActivity>15e3&&this.wake(),this.lastActivity=e},5e3),this.connect())}canSend(){return!this.disposed&&!this.suspended&&!this.upgrade.obsolete&&this.acceptedSocket!==void 0&&this.acceptedSocket===this.socket&&this.socket.readyState===1&&Date.now()<this.sessionDeadline}send(e){this.socket?.readyState===1&&this.socket.send(mE(e))}scheduleSessionRefresh(){if(this.sessionTimer!==void 0&&clearTimeout(this.sessionTimer),this.sessionTimer=void 0,this.session===void 0)return;let e=this.session.remainingLeaseMillis();if(this.sessionDeadline=Date.now()+e,e>=vE)return;let t=Math.min(yE,e/2);this.sessionTimer=setTimeout(()=>this.refreshSession(),Math.max(0,e-t))}refreshSession(){if(this.disposed||this.upgrade.obsolete||this.session===void 0)return;let e=this.connectionGeneration;Kf(this.session.renew).then(t=>{if(!(this.disposed||this.upgrade.obsolete||e!==this.connectionGeneration)){if(t.sessionEpoch!==this.sessionEpoch||t.viewRevision!==this.sessionViewRevision){this.connect();return}this.scheduleSessionRefresh()}},()=>{if(this.disposed||this.upgrade.obsolete||e!==this.connectionGeneration)return;let t=this.session?.remainingLeaseMillis()??0;if(this.sessionDeadline=Date.now()+t,t<=0){this.connect();return}this.sessionTimer=setTimeout(()=>this.refreshSession(),Math.min(1e3,t))})}connect(){if(this.disposed||this.upgrade.obsolete)return;this.suspended=!0,this.upgrade.connecting(),this.acceptedSocket=void 0,this.recovery.clear();for(let e of this.recoveryTimers)clearTimeout(e);this.recoveryTimers.clear(),this.recoveryTimeouts.clear(),this.reconnectTimer!==void 0&&clearTimeout(this.reconnectTimer),this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer),this.socket?.close(),this.socket=void 0;let e=++this.connectionGeneration;this.session!==void 0&&Kf(this.session.bootstrap).then(()=>{this.disposed||this.upgrade.obsolete||e!==this.connectionGeneration||this.openSocket()},()=>{this.disposed||this.upgrade.obsolete||e!==this.connectionGeneration||(this.upgrade.unavailable(`The browser session could not be verified. Reconnecting…`),this.reconnectTimer=setTimeout(()=>this.connect(),1e3))})}openSocket(){let e=new URL(IT,this.browser.location.href);e.protocol=e.protocol===`https:`?`wss:`:`ws:`;let t=new WebSocket(e);this.socket=t,t.onopen=()=>{this.socket!==t||this.disposed||this.send({type:`Connect`,protocolVersion:1,selection:this.selection,clientSessionId:this.clientSessionId})},this.handshakeTimer=setTimeout(()=>{this.socket===t&&this.acceptedSocket!==t&&t.close()},1e4),t.onmessage=e=>{if(this.socket!==t||this.disposed)return;let n=hE(e.data);if(bi(n)){this.upgrade.require();return}let r=gE(n.value);if(xi(r)){this.upgrade.require(r.value.selection);return}let i=_E(n.value);if(bi(i)){this.upgrade.require();return}this.message(t,i.value)},t.onerror=()=>t.close(),t.onclose=e=>{this.socket!==t||this.disposed||((e.code===1012||e.code===1008)&&this.queries.invalidatePrivate(),this.acceptedSocket=void 0,this.suspended=!0,this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer),!this.upgrade.obsolete&&(this.upgrade.unavailable(`The connection was lost. Checking for updates before resuming…`),this.reconnectTimer=setTimeout(()=>this.connect(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,5e3)))}}message(e,t){if(t.type===`UpgradeRequired`){this.upgrade.require(t.selection);return}if(t.type===`Handshake`){if(!hw(this.selection,t.selection)){this.upgrade.require(t.selection);return}if(this.upgrade.obsolete)return;this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer);let n=this.sessionEpoch;n!==void 0&&(n!==t.session.sessionEpoch||this.sessionViewRevision!==t.session.viewRevision)&&this.queries.invalidatePrivate(),this.sessionEpoch=t.session.sessionEpoch,this.sessionViewRevision=t.session.viewRevision,this.session?.accept(t.session,t.serverTime),this.scheduleSessionRefresh(),this.journal=new rE({appId:this.selection.appId,sessionEpoch:t.session.sessionEpoch,clientSessionId:this.clientSessionId,storage:()=>this.browser.sessionStorage});let r=this.journal.read();for(let e of r.issues)this.upgrade.reportRecovery(bE(e));if(r.clientSessionId!==this.clientSessionId){this.clientSessionId=r.clientSessionId,this.connect();return}if(n!==void 0&&n!==this.sessionEpoch){for(let[e,t]of this.pending)ad(t.prepared,F(HT.make({message:`The session changed before file preparation completed.`}))),this.upgrade.reportRecovery(`Mutation ${e} has an unknown outcome because the session changed.`),ad(t.done,F(HT.make({message:`The session changed. This mutation may already have completed.`})));this.pending.clear()}this.acceptedSocket=e,this.suspended=!1,this.reconnectDelay=250,this.upgrade.accepted();for(let e of this.queries.entries())this.send({type:`Subscribe`,id:e.subscriptionId,function:e.function,args:e.args});for(let e of r.entries)e.state===`pending`?this.pending.has(e.identity.invocationId)||this.recover(e.identity):(this.upgrade.reportRecovery(`Mutation ${e.identity.invocationId}: ${e.state}.`),this.journal.remove(e.identity));for(let e of this.pending.values())e.preparation===void 0?this.recover(e.identity):this.send(e.preparation);this.journal.write([]);return}if(this.acceptedSocket!==e){e.close();return}switch(t.type){case`Preparation`:{if(!this.canSend())return;let e=this.pending.get(t.invocationId);e?.preparation!==void 0&&ad(e.prepared,P(t.uploads));return}case`QuerySnapshot`:{if(!this.canSend())return;if(!hw(this.selection,t.selection)){this.upgrade.require(t.selection);return}let e=L(this.helpers.resultFromWire(t.result.result,t.files).pipe(Sf({InvalidServerMessage:e=>P(e)})));this.queries.setResult(t.id,e,t.result.observedRevision);return}case`MutationOutcome`:if(!hw(t.identity.originalSelection,this.selection)&&!this.recovery.has(t.id))return;this.outcome(t.id,t.identity,t.outcome);return;case`Error`:if(t.code===`PlatformUpgrading`){this.upgrade.require();return}if(t.code===`SessionExpired`){this.suspended=!0,this.session?.suspend(),this.queries.invalidatePrivate(),e.close();return}if(t.code===`InvalidArguments`||t.code===`InvocationIdConflict`||t.code===`ResourceLimitExceeded`){for(let[e,n]of this.pending){if(e!==t.id)continue;let r=F(KT.make({code:t.code,message:t.message}));ad(n.prepared,r),ad(n.done,r),this.pending.delete(e),this.journal?.remove(n.identity);return}for(let e of this.queries.entries())if(e.subscriptionId===t.id){this.queries.setResult(e.subscriptionId,KT.make({code:t.code,message:t.message}));return}return}this.upgrade.unavailable(t.message),e.close();return}}recover(e){if(!this.canSend())return;let t=`recovery:${e.originalSelection.dataHistoryId}:${e.invocationId}`;if(this.recovery.has(t))return;this.recovery.set(t,e);let n=this.recoveryDeadlines.get(t)??Date.now()+3e4;if(this.recoveryDeadlines.set(t,n),Date.now()>=n){this.outcome(t,e,{type:`Uncertain`});return}this.send({type:`RecoverMutation`,id:t,identity:e});let r=setTimeout(()=>{this.recoveryTimers.delete(r),this.recoveryTimeouts.delete(t),this.recovery.has(t)&&(this.recovery.delete(t),this.recover(e))},5e3);this.recoveryTimers.add(r),this.recoveryTimeouts.set(t,r)}outcome(e,t,n){let r=this.recovery.get(e),i=this.pending.get(t.invocationId);if(r===void 0&&i===void 0)return;let a=r??i.identity;if(a.invocationId!==t.invocationId||!hw(a.originalSelection,t.originalSelection))return;this.recovery.delete(e);let o=this.recoveryTimeouts.get(e);if(o!==void 0&&(clearTimeout(o),this.recoveryTimers.delete(o),this.recoveryTimeouts.delete(e)),n.type===`Pending`){let e=setTimeout(()=>{this.recoveryTimers.delete(e),this.recover(t)},1e3);this.recoveryTimers.add(e);return}let s=`recovery:${t.originalSelection.dataHistoryId}:${t.invocationId}`;this.recovery.delete(s),this.recoveryDeadlines.delete(s),i!==void 0&&(this.pending.delete(t.invocationId),n.type===`Settled`?ad(i.done,this.helpers.resultFromWire(n.result.result)):ad(i.done,F(HT.make({message:n.type===`Interrupted`?`The mutation was interrupted before it committed.`:`The mutation outcome is unknown. Check the app before trying it again.`}))));let c=n.type===`Settled`?`settled`:n.type===`Interrupted`?`interrupted`:`uncertain`;if(r!==void 0||n.type!==`Settled`){let e=n.type===`Settled`?n.result.result.type===`Success`?`completed`:`completed with an error`:c;this.upgrade.reportRecovery(`Mutation ${t.invocationId}: ${e}.`)}for(let e of this.journal?.reconcile(t,c).issues??[])this.upgrade.reportRecovery(bE(e));for(let e of this.journal?.remove(t).issues??[])this.upgrade.reportRecovery(bE(e))}persistPending(){return this.pending.size===0?[]:this.journal===void 0?[`Pending mutation outcomes could not be saved and remain unknown.`]:this.journal.write([...this.pending.values()].map(e=>e.identity)).issues.map(bE)}observe=R(`ManagedBrowserClient.observe`)((e,t)=>this.queries.observe(e,t));mutate=R(`ManagedBrowserClient.mutate`)(function*(e,t){if(this.upgrade.obsolete)return yield*UT.make({message:`The platform is updating. Try again after the app reloads.`});let n=yield*ef(()=>this.validate());if(this.upgrade.obsolete)return yield*UT.make({message:`The platform is updating. Try again after the app reloads.`});if(!n||!this.canSend()||this.sessionEpoch===void 0)return yield*HT.make({message:`The app must reconnect and verify its selection before accepting a mutation.`});if(this.pending.size>=QT.maxEntries)return yield*HT.make({message:`Too many mutations are waiting for outcomes. Wait for them to settle before trying again.`});let r=this.ids;if(r===void 0)return yield*HT.make({message:`The client is not ready.`});let i=yield*lE(t).pipe(jf(Iw,r),I(t=>WT.make({cause:t,function:e,message:`The mutation arguments cannot be sent.`}))),a=yield*df({try:()=>OC(i.value),catch:t=>WT.make({cause:t,function:e,message:`The mutation arguments cannot be sent.`})});if(!this.canSend())return yield*UT.make({message:`The app is reconnecting or updating. Try again when it is ready.`});let o=yield*r.generate(rC),s=yield*td(),c={invocationId:o,originalSelection:this.selection},l=yield*td(),u=i.fileIds.length===0?void 0:{type:`Prepare`,invocationId:o,function:e,args:a,files:i.fileIds};this.pending.set(o,{identity:c,sessionEpoch:this.sessionEpoch,done:s,prepared:l,preparation:u});for(let e of this.persistPending())this.upgrade.reportRecovery(e);if(u!==void 0){this.send(u),yield*sf({self:this},function*(){let t=yield*nd(l);if(yield*dE(i.nativeFiles,t,e),!this.canSend())return yield*UT.make({message:`The app is reconnecting or updating. Try again when it is ready.`})}).pipe(wf(()=>rf(()=>{this.pending.delete(o),this.journal?.remove(c)})));let t=this.pending.get(o);if(t===void 0)return yield*nd(s);this.pending.set(o,{...t,preparation:void 0})}this.send({type:`Invoke`,invocationId:o,function:e,args:a});let d=setTimeout(()=>{this.recoveryTimers.delete(d),this.pending.has(o)&&this.recover(c)},5e3);return this.recoveryTimers.add(d),yield*nd(s)}).bind(this);validate=()=>this.upgrade.obsolete||this.disposed?Promise.resolve(!1):(this.validation===void 0&&(this.validation=this.upgrade.check().then(e=>{let t=e&&this.canSend();return t&&this.upgrade.getSnapshot().phase!==`ready`&&this.upgrade.accepted(),t}).finally(()=>{this.validation=void 0})),this.validation);resume=()=>{this.disposed||this.upgrade.obsolete||this.socket!==void 0&&this.socket.readyState<=WebSocket.OPEN||(this.suspended=!0,this.acceptedSocket=void 0,this.recovery.clear(),this.queries.invalidate(void 0),this.connect())};wake=()=>{let e=this.socket!==void 0&&this.socket.readyState<=WebSocket.OPEN&&this.acceptedSocket===this.socket;this.resume(),e&&this.validate()};offline=()=>{this.suspended=!0,this.acceptedSocket=void 0,this.upgrade.unavailable(`The app is offline. Reconnect to check for updates and mutation outcomes.`),this.socket?.close()};hide=()=>{for(let e of this.persistPending())this.upgrade.reportRecovery(e);this.suspended=!0,this.acceptedSocket=void 0,this.socket?.close()};visibility=()=>{if(this.browser.document.visibilityState===`visible`)this.wake();else for(let e of this.persistPending())this.upgrade.reportRecovery(e)};dispose(){if(!this.disposed){this.disposed=!0;for(let e of this.readyWaiters)e(!1);this.unsubscribeSession?.(),this.persistPending(),this.socket?.close(),this.reconnectTimer!==void 0&&clearTimeout(this.reconnectTimer),this.handshakeTimer!==void 0&&clearTimeout(this.handshakeTimer),this.sessionTimer!==void 0&&clearTimeout(this.sessionTimer),this.heartbeat!==void 0&&clearInterval(this.heartbeat);for(let e of this.recoveryTimers)clearTimeout(e);this.browser.removeEventListener(`pageshow`,this.wake),this.browser.removeEventListener(`pagehide`,this.hide),this.browser.removeEventListener(`online`,this.resume),this.browser.removeEventListener(`offline`,this.offline),this.browser.removeEventListener(`focus`,this.wake),this.browser.document.removeEventListener(`visibilitychange`,this.visibility),this.upgrade.dispose()}}},SE=(e,t)=>JS([e,t]),CE=e=>({type:`Subscribe`,id:e.subscriptionId,function:e.function,args:e.args}),wE={makeQueryCache:(e,t)=>{let n=new Map,r=new Map,i=R(`SyncClient.QueryCache.observe`)(function*(i,a){let o=SE(i,a),s=n.get(o);if(s===void 0){let c={args:a,function:i,generation:0,listeners:new Set,revision:void 0,references:0,result:ZC(),subscriptionId:yield*e};n.set(o,c),r.set(c.subscriptionId,c),yield*t(CE(c)),s=c}let c=s;c.references+=1,c.generation+=1;let l=!1;return{getSnapshot:()=>c.result,subscribe:e=>(c.listeners.add(e),()=>c.listeners.delete(e)),release:sf(function*(){if(l||(l=!0,--c.references,c.references!==0))return;let e=++c.generation;yield*Tf(`25 millis`),c.references===0&&c.generation===e&&n.get(o)===c&&(n.delete(o),r.delete(c.subscriptionId),yield*t({type:`Unsubscribe`,id:c.subscriptionId}))})}}),a=e=>{e.result=ZC(),e.revision=void 0;for(let t of e.listeners)t()};return{invalidate:e=>{for(let t of n.values())(e===void 0||e.includes(t.subscriptionId))&&a(t)},invalidatePrivate:()=>{for(let e of n.values())e.dependsOnId!==!1&&a(e)},entries:()=>n.values(),getById:e=>r.get(e),observe:i,setResult:(e,t,n)=>{let i=r.get(e);if(i!==void 0){if(n!==void 0){if(i.revision!==void 0&&n<i.revision)return;i.revision=n}i.result=t;for(let e of i.listeners)e()}}}},queryIdentity:SE,resultFromWire:R(`SyncClient.resultFromWire`)((e,t=[])=>df({try:()=>e.type===`Success`?$C.succeed(e.value===void 0?void 0:uE(jC(e.value,e.dates??[]),t)):QC(e.error,e.dates),catch:e=>GT.make({cause:e,message:`The server returned an invalid function result.`})}))},TE=class extends Di()(`ignotum/client/sync/SyncClient`){},EE=()=>kx(Td(TE)({observe:()=>F(HT.make({message:`The application has not mounted.`})),mutate:()=>F(HT.make({message:`The application has not mounted.`}))}).pipe(Fd(Bw.layer),Fd(JT),Fd(Iw.layer))),DE=EE(),OE=(e,t,n)=>{let r=new xE(e,t,wE,n);DE.dispose(),DE=kx(kd(TE,sf(function*(){return r.attachSession(yield*Bw,yield*Iw),TE.of({observe:r.observe,mutate:r.mutate})})).pipe(Fd(Bw.layer),Fd(JT),Fd(Iw.layer)));let i=DE;return i.runPromise(TE).then(()=>r.start(),()=>r.dispose()),{client:r,dispose:()=>{r.dispose(),i.dispose(),DE===i&&(DE=EE())}}},kE={declarationBytes:1048576,artifactBytes:16777216,totalArtifactBytes:134217728,serverArtifactBytes:67108864,artifacts:512,modules:512,importsPerModule:256,routes:512,layouts:128,functions:512,conversions:512,urlFields:64,literalValues:64,textLength:4096,configurationDepth:96,configurationNodes:65536,descriptorDepth:32,descriptorNodes:8192,graphDepth:64,moduleTokens:1e5},AE=e=>G(e).annotate({parseOptions:{onExcessProperty:`error`}}),jE=W.check(ib(1),sb(256)),ME=W.check(sb(kE.textLength)),NE=W.check(Uy(/^[A-Za-z_$][A-Za-z0-9_$]*$/),Hy());ew.check(Hy(),sb(512),Uy(/^(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*\/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*$/));var PE=W.check(Hy(),sb(512),Uy(/^app\/(?:client|server)\/(?:[A-Za-z0-9_-][A-Za-z0-9_.-]*\/)*[A-Za-z0-9_-][A-Za-z0-9_.-]*$/)).pipe(Y(`ignotum/app-definition/AppModuleId`)),FE=jE.pipe(Y(`ignotum/app-definition/RouteId`)),IE=jE.pipe(Y(`ignotum/app-definition/LayoutId`)),LE=AE({module:PE,exportName:NE}),RE=q([ME,Gy,Ey]),zE=q([AE({type:U(`string`)}),AE({type:U(`id`),table:jE}),AE({type:U(`number`)}),AE({type:U(`integer`)}),AE({type:U(`boolean`)}),AE({type:U(`literal`),value:RE}),AE({type:U(`literals`),values:K(RE).check(ib(1),sb(kE.literalValues),X(e=>new Set(e.map(String)).size===e.length||`URL literal encodings must be unique`))})]),BE=e=>{switch(e.type){case`string`:return ME;case`id`:return $S;case`number`:return Gy;case`integer`:return nb;case`boolean`:return Ey;case`literal`:return U(e.value);case`literals`:return J(e.values)}},VE=q([zE,AE({type:U(`array`),value:zE})]),HE=q([RE,K(RE).check(sb(256))]),UE=q([VE,AE({type:U(`optional`),value:VE}),AE({type:U(`default`),value:VE,default:HE}).check(X(e=>oy(e.value.type===`array`?K(BE(e.value.value)):BE(e.value))(e.default)||`The URL default must satisfy its value descriptor`)).annotate({parseOptions:{onExcessProperty:`error`}})]),WE=AE({name:jE,value:UE}),GE=AE({name:jE,value:q([zE,AE({type:U(`array`),value:AE({type:U(`string`)})})])}),KE=AE({description:H(ME),robots:H(ME)}),qE=AE({title:H(ME),meta:H(KE)}),JE=AE({title:H(ME),titleTemplate:H(ME.check(X(e=>e.split(`%s`).length===2||`A title template must contain exactly one %s placeholder`))),meta:H(KE)}),YE=W.check(sb(2048),Uy(/^\/(?!_ignotum(?:\/|$))[^?#\\\0]*$/)),XE=AE({id:FE,pattern:YE,directoryScope:H(YE),precedence:K(rb).check(sb(128)),params:K(GE).check(sb(kE.urlFields)),searchParams:K(WE).check(sb(kE.urlFields)),page:LE,layouts:K(IE).check(sb(kE.layouts)),metadata:qE,boundaries:AE({error:Ey,invalid:Ey})}),ZE=AE({id:IE,scope:YE,parent:H(IE),module:LE,metadata:JE,boundaries:AE({error:Ey,invalid:Ey,notFound:Ey})}),QE=class extends Ob()(`RoutingDefinitionError`,{message:W,pattern:H(W)}){},$E=new Set(`await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield`.split(`.`)),eD=W.check(Uy(/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u),X(e=>!$E.has(e)||`Parameter names must be TypeScript identifiers`)),tD=XE.fields.pattern.check(X(e=>e===`/`||!e.endsWith(`/`)&&!e.includes(`//`)||`Patterns must not contain empty segments or trailing slashes`),X(e=>!/[[\]()\u0000-\u001F\u007F\uD800-\uDFFF]/u.test(e)||`Patterns must use decoded literal segments and supported parameter syntax`)),nD=(e,t)=>new QE({message:e,pattern:t}),rD=e=>e.kind===`Literal`?3:e.kind===`Parameter`?2:1,iD=e=>e.kind===`Literal`?e.value:`${e.kind===`Parameter`?`:`:`*`}${e.name}`,aD=e=>({pattern:`/${e.map(iD).join(`/`)}`,segments:e,precedence:e.map(rD)}),oD=e=>JSON.stringify(e.segments.map(e=>e.kind===`Literal`?[e.kind,e.value]:[e.kind])),sD=(e,t)=>{for(let n=0;n<Math.max(e.precedence.length,t.precedence.length);n++){let r=(t.precedence[n]??0)-(e.precedence[n]??0);if(r!==0)return r}return 0},cD=(e,t)=>e.segments.length<=t.segments.length&&e.segments.every((e,n)=>iD(e)===iD(t.segments[n])),lD=R(`Routing.parsePattern`)(function*(e){let t=yield*sy(tD)(e).pipe(I(()=>nD(`Route patterns must be canonical absolute paths outside /_ignotum.`,e)));if(t===`/`)return aD([]);let n=t.slice(1).split(`/`);if(n.length>128)return yield*nD(`Route patterns exceed the segment limit.`,t);let r=[],i=new Set;for(let[e,a]of n.entries())if(a.startsWith(`:`)||a.startsWith(`*`)){let o=yield*sy(eD)(a.slice(1)).pipe(I(()=>nD(`Route parameter names must be valid TypeScript identifiers.`,t)));if(i.has(o))return yield*nD(`Repeated route parameter '${o}'.`,t);if(i.add(o),a.startsWith(`*`)){if(e!==n.length-1)return yield*nD(`A catch-all must be the final segment.`,t);r.push({kind:`CatchAll`,name:o})}else r.push({kind:`Parameter`,name:o})}else{if(a===`.`||a===`..`||/[:*]/.test(a))return yield*nD(`Route literals must not contain dot segments or parameter syntax.`,t);r.push({kind:`Literal`,value:a})}return aD(r)}),uD=R(`Routing.compileRoute`)(function*(e){let t=yield*sy(XE)(e).pipe(I(()=>nD(`The route definition is invalid.`))),n=yield*lD(t.pattern),r=yield*lD(t.directoryScope??t.pattern);if(!cD(r,n)||r.segments.length<n.segments.length-1)return yield*nD(`A route directory must be its full pattern for an index page or its immediate parent for a page file.`,t.pattern);if(t.precedence.length!==n.precedence.length||t.precedence.some((e,t)=>e!==n.precedence[t]))return yield*nD(`Stored route precedence does not match its pattern.`,t.pattern);let i=n.segments.filter(e=>e.kind!==`Literal`);if(t.params.length!==i.length||new Set(t.params.map(e=>e.name)).size!==t.params.length)return yield*nD(`Route parameters must describe each dynamic name exactly once.`,t.pattern);for(let e of i){let n=t.params.find(t=>t.name===e.name);if(n===void 0||(e.kind===`CatchAll`?n.value.type!==`array`:n.value.type===`array`))return yield*nD(`Single parameters require scalar values and catch-alls require string arrays.`,t.pattern)}return new Set(t.searchParams.map(e=>e.name)).size===t.searchParams.length?{pattern:n,directory:r}:yield*nD(`Search parameter names must be unique.`,t.pattern)}),dD=R(`Routing.validateRoutePattern`)(function*(e){return(yield*uD(e)).pattern}),fD=R(`Routing.compilePatterns`)(function*(e,t){let n=yield*sy(K(XE).check(sb(kE.routes)))(e).pipe(I(()=>nD(`Route definitions are invalid or exceed the route limit.`))),r=yield*sy(K(ZE).check(sb(kE.layouts)))(t).pipe(I(()=>nD(`Layout definitions are invalid or exceed the layout limit.`)));if(new Set(n.map(e=>e.id)).size!==n.length)return yield*nD(`Route identities must be unique.`);if(new Set(r.map(e=>e.id)).size!==r.length)return yield*nD(`Layout identities must be unique.`);let i=yield*$d(n,e=>uD(e)),a=yield*$d(r,e=>lD(e.scope));if(new Set(i.map(e=>oD(e.pattern))).size!==n.length)return yield*nD(`Duplicate or structurally ambiguous route patterns.`);if(new Set(a.map(oD)).size!==r.length)return yield*nD(`Duplicate or structurally ambiguous layout scopes.`);let o=r.map((e,t)=>({layout:e,pattern:a[t]})),s=e=>o.filter(t=>cD(t.pattern,e)).sort((e,t)=>e.pattern.segments.length-t.pattern.segments.length).map(e=>e.layout);for(let{layout:e,pattern:t}of o){let n=s(t).filter(t=>t.id!==e.id);if(e.parent!==n.at(-1)?.id)return yield*nD(`Layout '${e.id}' must name its nearest directory layout as parent.`,e.scope)}let c=new Map,l=R(`Routing.addDirectory`)(function*(e){let t=oD(e),n=c.get(t);if(n!==void 0&&n.pattern!==e.pattern)return yield*nD(`Dynamic directory parameter names are structurally ambiguous.`,e.pattern);c.set(t,e)});yield*l(aD([]));for(let e of a)for(let t=1;t<=e.segments.length;t++)yield*l(aD(e.segments.slice(0,t)));let u=[];for(let[e,t]of n.entries()){let{pattern:n,directory:r}=i[e],a=s(r);if(t.layouts.length!==a.length||t.layouts.some((e,t)=>e!==a[t]?.id))return yield*nD(`Route '${t.id}' must include its complete directory layout branch.`,t.pattern);for(let e=1;e<=r.segments.length;e++)yield*l(aD(r.segments.slice(0,e)));u.push({route:t,pattern:n,layouts:a})}return{routes:u.sort((e,t)=>sD(e.pattern,t.pattern)),directories:[...c.values()].map(e=>({pattern:e,layouts:s(e)})).sort((e,t)=>sD(e.pattern,t.pattern))}}),pD=(e,t,n)=>{let r=[];for(let[n,i]of e.segments.entries()){let e=t[n];if(e===void 0||e.length===0)return;if(i.kind===`Literal`){if(i.value!==e)return}else if(i.kind===`Parameter`)r.push([i.name,e]);else return r.push([i.name,t.slice(n)]),Object.fromEntries(r)}if(!(!n&&t.length!==e.segments.length))return Object.fromEntries(r)},mD=(e,t)=>{if(t[0]===`_ignotum`)return{route:void 0,layouts:[],params:{}};for(let n of e.directories){let e=pD(n.pattern,t,!0);if(e!==void 0)return{route:void 0,layouts:n.layouts,params:e}}return{route:void 0,layouts:[],params:{}}},hD=(e,t)=>{if(t[0]===`_ignotum`)return{route:void 0,layouts:[],params:{}};for(let n of e.routes){let e=pD(n.pattern,t,!1);if(e!==void 0)return{route:n.route,layouts:n.layouts,params:e}}return mD(e,t)},gD=G({source:J([`params`,`searchParams`]),field:H(W),message:W}),_D=G({...G({segments:K(W),pathname:W,search:W,hash:W,canonicalUrl:W}).fields,pathComplete:Ey}),vD=class extends Ob()(`InvalidUrl`,{issues:K(gD),partial:H(_D)}){},yD=(e,t,n,r)=>vD.make({issues:[{source:e,field:n,message:t}],partial:r}),bD=(e,t)=>yD(e,`The URL field '${t}' does not match its declaration.`,t),xD=W.check(ib(1),Uy(/^[^/\\\u0000-\u001f\u007f]+$/u),X(e=>e!==`.`&&e!==`..`||`Dot segments are not allowed`)),SD=W.check(Uy(/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/)),CD=ky(W,Sy),wD=G({params:H(Sy),searchParams:H(Sy),hash:H(W.check(X(e=>!e.startsWith(`#`)||`Hash input must omit the leading #`)))}).annotate({parseOptions:{onExcessProperty:`error`}}),TD=R(`Routing.decodeComponent`)(function*(e,t,n,r){return yield*df({try:()=>decodeURIComponent(e),catch:()=>yD(t,`The URL contains malformed escapes or Unicode.`,n,r)})}),ED=R(`Routing.encodeComponent`)(function*(e,t,n){return yield*df({try:()=>encodeURIComponent(e),catch:()=>yD(t,`The URL contains malformed Unicode.`,n)})}),DD=R(`Routing.searchEntries`)(function*(e,t){yield*sy(W)(e).pipe(I(()=>yD(`searchParams`,`Search parameters must be URL query text.`,void 0,t)));let n=e.startsWith(`?`)?e.slice(1):e,r=[];for(let e of n.split(`&`)){if(e===``)continue;let n=e.indexOf(`=`),i=n<0?e:e.slice(0,n),a=n<0?``:e.slice(n+1),o=yield*TD(i.replaceAll(`+`,` `),`searchParams`,void 0,t);r.push([o,yield*TD(a.replaceAll(`+`,` `),`searchParams`,o,t)])}return r}),OD=R(`Routing.parseLocation`)(function*(e){yield*sy(W)(e).pipe(I(()=>yD(`params`,`A location must be URL text.`)));let t=e.indexOf(`#`),n=t<0?``:e.slice(t),r=t<0?e:e.slice(0,t),i=r.indexOf(`?`),a=i<0?``:r.slice(i),o=i<0?r:r.slice(0,i),s=o.length>1&&o.endsWith(`/`)?o.slice(0,-1):o,c=[],l=e=>({segments:[...c],pathname:s,search:a,hash:n,canonicalUrl:`${s}${a}${n}`,pathComplete:e});if(!o.startsWith(`/`)||o.startsWith(`//`))return yield*yD(`params`,`A location must start with exactly one application-root slash.`,void 0,l(!1));if(s!==`/`)for(let e of s.slice(1).split(`/`)){let t=yield*TD(e,`params`,void 0,l(!1));yield*cy(xD)(t).pipe(I(()=>yD(`params`,`Path segments must be nonempty and cannot contain slashes, dot navigation or control characters.`,void 0,l(!1)))),c.push(t)}return yield*DD(a,l(!0)),yield*TD(n.slice(1),`params`,void 0,l(!0)),{segments:c,pathname:s,search:a,hash:n,canonicalUrl:`${s}${a}${n}`}}),kD=e=>{switch(e.type){case`string`:return W;case`id`:return $S;case`number`:return Gy;case`integer`:return nb;case`boolean`:return Ey;case`literal`:return U(e.value);case`literals`:return J(e.values)}},AD=R(`Routing.scalarText`)(function*(e,t,n,r){switch(e.type){case`number`:case`integer`:return yield*cy(SD)(t).pipe(I(()=>bD(n,r))),yield*sy(kD(e))(Number(t)).pipe(I(()=>bD(n,r)));case`boolean`:return(yield*sy(J([`true`,`false`]))(t).pipe(I(()=>bD(n,r))))===`true`;case`literal`:return yield*cy(U(String(e.value)))(t).pipe(I(()=>bD(n,r))),e.value;case`literals`:return yield*cy(J(e.values.map(String)))(t).pipe(I(()=>bD(n,r))),e.values.find(e=>String(e)===t);default:return yield*sy(kD(e))(t).pipe(I(()=>bD(n,r)))}}),jD=R(`Routing.suppliedValue`)(function*(e,t,n,r){let i=yield*sy(e.type===`array`?K(kD(e.value)):kD(e))(t).pipe(I(()=>bD(n,r)));for(let e of ba(i))yield*ED(String(e),n,r);return i}),MD=R(`Routing.validateUrlDefinition`)(function*(e){let t=yield*sy(XE)(e).pipe(I(()=>yD(`params`,`The route's URL declaration is invalid.`))),n=yield*dD(t).pipe(I(e=>yD(`params`,e.message)));for(let e of t.searchParams)yield*ED(e.name,`searchParams`,e.name),e.value.type==="default"&&(yield*jD(e.value.value,e.value.default,`searchParams`,e.name));return{route:t,pattern:n}}),ND=R(`Routing.inputRecord`)(function*(e,t,n){let r=yield*sy(CD)(e===void 0?{}:e).pipe(I(()=>yD(n,`The ${n} input must be an object.`)));for(let e of Object.keys(r))if(!t.some(t=>t.name===e))return yield*yD(n,`The URL field '${e}' is not declared.`,e);return r}),PD=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0,FD=R(`Routing.pathValue`)(function*(e,t){let n=String(e);return yield*cy(xD)(n).pipe(I(()=>bD(`params`,t))),yield*ED(n,`params`,t),n}),ID=R(`Routing.decodeRouteInputs`)(function*(e,t,n){let{route:r}=yield*MD(e),i=yield*ND(t,r.params,`params`),a=[];for(let e of r.params){let t=PD(i,e.name);if(e.value.type===`array`){let n=yield*sy(K(W).check(ib(1)))(t).pipe(I(()=>bD(`params`,e.name)));a.push([e.name,yield*$d(n,t=>FD(t,e.name))])}else{let n=yield*sy(W)(t).pipe(I(()=>bD(`params`,e.name)));yield*FD(n,e.name),a.push([e.name,yield*AD(e.value,n,`params`,e.name)])}}let o=yield*DD(n),s=[];for(let e of r.searchParams){let t=o.filter(([t])=>t===e.name).map(([,e])=>e),n=e.value;if(t.length===0){if(n.type===`optional`){s.push([e.name,void 0]);continue}if(n.type==="default"){s.push([e.name,yield*jD(n.value,n.default,`searchParams`,e.name)]);continue}return yield*yD(`searchParams`,`The required URL field '${e.name}' is missing.`,e.name)}let r=n.type===`optional`||n.type==="default"?n.value:n;if(r.type===`array`)s.push([e.name,yield*$d(t,t=>AD(r.value,t,`searchParams`,e.name))]);else{if(t.length!==1)return yield*yD(`searchParams`,`The scalar URL field '${e.name}' occurs more than once.`,e.name);s.push([e.name,yield*AD(r,t[0],`searchParams`,e.name)])}}return{params:Object.fromEntries(a),searchParams:Object.fromEntries(s)}}),LD=(e,t)=>Sa(e)&&Sa(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e===t,RD=R(`Routing.buildUrl`)(function*(e,t={}){let{route:n,pattern:r}=yield*MD(e),i=yield*sy(wD,{onExcessProperty:`error`})(t).pipe(I(()=>yD(`params`,`The URL navigation input is invalid.`))),a=yield*ND(i.params,n.params,`params`),o=yield*ND(i.searchParams,n.searchParams,`searchParams`),s=[];for(let e of r.segments){if(e.kind===`Literal`){s.push(yield*ED(e.value,`params`));continue}let t=n.params.find(t=>t.name===e.name),r=ba(yield*jD(t.value,PD(a,t.name),`params`,t.name));if(r.length===0)return yield*yD(`params`,`Catch-all parameters must contain at least one segment.`,t.name);for(let e of r)s.push(yield*ED(yield*FD(e,t.name),`params`,t.name))}if(s[0]===`_ignotum`){let e=r.segments[0];return yield*yD(`params`,`The /_ignotum path is reserved for the platform.`,e?.kind===`Parameter`||e?.kind===`CatchAll`?e.name:void 0)}let c=new URLSearchParams;for(let e of n.searchParams){let t=PD(o,e.name),n=e.value;if(t===void 0){if(n.type===`optional`||n.type==="default")continue;return yield*yD(`searchParams`,`The required URL field '${e.name}' is missing.`,e.name)}let r=yield*jD(n.type===`optional`||n.type==="default"?n.value:n,t,`searchParams`,e.name);if(n.type==="default"&&LD(r,n.default))continue;let i=ba(r);if(i.length===0&&n.type!==`optional`&&n.type!=="default")return yield*yD(`searchParams`,`A required array cannot serialize as an absent search key.`,e.name);for(let t of i)c.append(e.name,String(t))}let l=c.toString(),u=i.hash===void 0||i.hash===``?``:`#${yield*ED(i.hash,`params`)}`;return`/${s.join(`/`)}${l===``?``:`?${l}`}${u}`}),zD=G({applicationName:W.check(ib(1),sb(256)),layouts:K(JE).check(sb(kE.layouts)),page:H(qE),outcome:J([`Matched`,`Invalid`,`NotFound`])}).annotate({parseOptions:{onExcessProperty:`error`}}),BD=class extends Ob()(`InvalidMetadata`,{message:W}){},VD=R(`Routing.resolveMetadata`)(function*(e){let{applicationName:t,layouts:n,page:r,outcome:i}=yield*cy(zD,{onExcessProperty:`error`})(e).pipe(I(()=>BD.make({message:`Static metadata is invalid.`}))),a=t,o,s,c;for(let e of n)a=e.title??a,o=e.titleTemplate??o,s=e.meta?.description??s,c=e.meta?.robots??c;let l=i===`NotFound`?void 0:r,u=l?.title;u!==void 0&&(a=o===void 0?u:o.replace(`%s`,()=>u)),s=l?.meta?.description??s,c=i===`Matched`?l?.meta?.robots??c:`noindex`;let d=[];return s===void 0&&d.push(`description`),c===void 0&&d.push(`robots`),{title:a,meta:{description:s,robots:c},remove:d}}),HD=e=>e[0]===`_ignotum`,UD=R(`Routing.matchLocation`)(function*(e,t){let n=yield*OD(t).pipe(_f);if(n._tag===`Failure`){let t=n.failure,r=t.partial,i=r?.segments??[],a=HD(i),o=r?.pathComplete?hD(e,i):mD(e,i);return{_tag:`Invalid`,status:400,route:!a&&r?.pathComplete?o.route:void 0,layouts:a?[]:o.layouts,reserved:a,location:void 0,issues:t.issues}}let r=n.success,i=HD(r.segments),a=hD(e,r.segments);if(i||a.route===void 0)return{_tag:`NotFound`,status:404,layouts:i?[]:a.layouts,reserved:i,location:r};let o=a.route,s=yield*ID(o,a.params,r.search).pipe(_f);return s._tag===`Failure`?{_tag:`Invalid`,status:400,route:o,layouts:a.layouts,reserved:!1,location:r,issues:s.failure.issues}:{_tag:`Matched`,status:200,route:o,layouts:a.layouts,reserved:!1,location:r,...s.success}}),WD=t({createRouteReference:()=>KD,getRouteDefinition:()=>qD}),GD=Symbol.for(`ignotum/internal/routes/RouteReference`),KD=e=>({[GD]:dy(XE)(e)}),qD=e=>e[GD],JD=ke(void 0),YD=()=>{let e=Xe(JD);if(e===void 0)throw Error(`Ignotum routing hooks require a managed client mount.`);return e},XD=e=>{let[t,n]=He(e.getSnapshot);return Ge(()=>{let t=()=>n(e.getSnapshot()),r=e.subscribe(t);return t(),r},[e]),t};function ZD(e,...t){return L(RD(qD(e),t[0]))}var QD=(e,t={})=>L(RD(qD(e),{params:t.params,searchParams:t.searchParams,hash:t.hash})),$D=G({params:H(Sy),searchParams:H(Sy),hash:H(W),replace:H(Ey),scroll:H(J([`auto`,`preserve`]))}).annotate({parseOptions:{onExcessProperty:`error`}}),eO=()=>{let e=YD(),[t]=He(()=>Object.assign((t,...n)=>{let r=dy($D,{onExcessProperty:`error`})(n[0]??{});return e.navigate(QD(t,r),r)},{back:e.back,forward:e.forward}));return t},tO=()=>{let e=XD(YD());if(e.location===void 0)throw Error(`The initial Ignotum location has not committed.`);return e.location},nO=()=>XD(YD()).navigation,rO=({when:e})=>{let t=YD(),[n]=He(()=>Symbol(`blocker`));return XD(t),Ge(()=>{t.setBlocker(n,e)},[t,n,e]),Ge(()=>()=>t.setBlocker(n,!1),[t,n]),t.getBlocker(n)},iO=(e,t,n)=>{let r=t.location,i=t.branch?.outcome;if(r===void 0||i===void 0)return;let a=qD(e);if(n&&(i._tag!==`Matched`||i.route.id!==a.id))return;let o=L(OD(`${r.pathname}${r.search}`).pipe(_f));if(o._tag===`Failure`)return;let s=L(fD([{...a,layouts:[]}],[]));for(let e=o.success.segments.length;e>=0&&(e!==0||o.success.segments.length===0);e--){let t=hD(s,o.success.segments.slice(0,e));if(t.route!==void 0){let e=L(ID(a,t.params,r.search).pipe(_f));return e._tag===`Failure`?void 0:{...e.success,hash:r.hash}}if(n)break}};function aO(e,t){return iO(e,XD(YD()),t?.end??!0)}function oO(e){let t=YD(),n=iO(e,XD(t),!0);if(n===void 0)throw Error(`useRoute requires page '${qD(e).id}' to be active.`);return{...n,setSearchParams:(n,r)=>{let i=iO(e,t.getSnapshot(),!0),a=t.getSnapshot().location;if(i===void 0||a===void 0)throw Error(`Cannot update search parameters for an inactive route.`);let o=Dt(n)?n(i.searchParams):n,s=QD(e,{params:i.params,searchParams:o,hash:i.hash}),c=new URL(s,t.browser.location.origin);c.pathname=a.pathname;let l=new Set(qD(e).searchParams.map(e=>e.name));for(let[e,t]of new URLSearchParams(a.search))l.has(e)||c.searchParams.append(e,t);return t.navigate(`${c.pathname}${c.search}${c.hash}`,{scroll:`preserve`,...r})}}}var sO=(e,t,n)=>{let r=L(OD(e).pipe(_f)),i=L(OD(t).pipe(_f));if(r._tag===`Failure`||i._tag===`Failure`)return!1;let a=r.success.segments,o=i.success.segments;return a.length!==o.length&&(n||o.length===0||a.length<o.length)?!1:o.every((e,t)=>a[t]===e)};function cO(e){let t=YD(),n=XD(t),{to:r,params:i,searchParams:a,hash:o,replace:s,scroll:c,preload:l=`intent`,end:u=!0,active:d=!1,class:f,onClick:p,onMouseEnter:m,onFocus:h,...g}=e,_=QD(r,{params:i,searchParams:a,hash:o}),v=d&&n.location!==void 0&&sO(n.location.pathname,_.split(/[?#]/)[0],u),y=()=>{l!==`none`&&t.preload(_).catch(()=>{})};return S(`a`,{...g,href:_,class:Dt(f)?f({isActive:v}):f,"aria-current":v?`page`:g[`aria-current`],onClick:e=>{p?.(e);let n=e.currentTarget;e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||n.target!==``&&n.target.toLowerCase()!==`_self`||n.hasAttribute(`download`)||n.relList.contains(`external`)||n.origin!==t.browser.location.origin||`${n.pathname}${n.search}${n.hash}`!==_||(e.preventDefault(),t.navigate(_,{replace:s,scroll:c}))},onMouseEnter:e=>{m?.(e),e.defaultPrevented||y()},onFocus:e=>{h?.(e),e.defaultPrevented||y()}})}function lO(e){return S(cO,e)}function uO(e){return S(cO,{...e,active:!0})}function dO(e){let t=YD(),n=QD(e.to,e),r=Ke(),i=e.replace??!0;return We(()=>{let a=JSON.stringify([n,i,e.scroll]);r.current!==a&&(r.current=a,t.navigate(n,{replace:i,scroll:e.scroll},!0))},[t,n,i,e.scroll]),null}var fO=G({formatVersion:U(1),key:W}),pO=G({formatVersion:U(2),key:W,index:My(nb)}),mO=KS(GS(fO),pO,e=>({formatVersion:2,key:e.key,index:null})),hO=G({__ignotumRouter:mO}),gO=ky(W,Sy),_O=e=>`${e.location.pathname}${e.location.search}${e.location.hash}`,vO=class{browser;onTraversal;committed;actual;positions=new Map;seeking;originalScrollRestoration;direction=-1;scrollPending=!1;expectedKey;scroll=new Map;constructor(e,t){this.browser=e,this.onTraversal=t;let n=ly(hO)(e.history.state),r=n._tag===`Some`?n.value.__ignotumRouter:void 0;this.actual=this.committed={key:r?.key??e.crypto.randomUUID(),index:r?.index??0,href:_O(e)},this.write(this.actual,!1),this.originalScrollRestoration=e.history.scrollRestoration,e.history.scrollRestoration=`manual`,e.addEventListener(`popstate`,this.onPop),e.addEventListener(`scroll`,this.saveScroll)}write(e,t){let n=ly(gO)(this.browser.history.state),r={__ignotumRouter:gy(mO)({formatVersion:2,key:e.key,index:e.index})},i=n._tag===`Some`?{...n.value,...r}:r;t?this.browser.history.pushState(i,``,e.href):this.browser.history.replaceState(i,``,e.href),this.positions.set(e.key,e.index)}saveScroll=()=>{this.scrollPending||this.scroll.set(this.committed.key,{x:this.browser.scrollX,y:this.browser.scrollY})};captureScroll(){return this.saveScroll(),this.scrollPending=!0,this.scroll.get(this.committed.key)??{x:this.browser.scrollX,y:this.browser.scrollY}}finishScroll(){this.scrollPending=!1,this.saveScroll()}restoreSourceScroll(){if(!this.scrollPending)return;let e=this.scroll.get(this.committed.key);e!==void 0&&this.browser.scrollTo(e.x,e.y),this.finishScroll()}onPop=()=>{let e=ly(hO)(this.browser.history.state),t=e._tag===`Some`?e.value.__ignotumRouter:void 0,n=t?.key??this.browser.crypto.randomUUID(),r=t?.index??this.positions.get(n)??this.actual.index+this.direction;this.actual={key:n,index:r,href:_O(this.browser)},this.write(this.actual,!1);let i=this.expectedKey;this.expectedKey=void 0;let a=this.seeking;if(a!==void 0&&(i===n||a.position.key===n)){this.advanceSeek();return}a!==void 0&&(this.seeking=void 0,L(id(a.done,!1))),this.onTraversal(this.actual)};advanceSeek(){let e=this.seeking;e!==void 0&&this.expectedKey===void 0&&(this.actual.key===e.position.key?(this.seeking=void 0,L(id(e.done,!0))):(this.expectedKey=e.position.key,this.browser.history.go(e.position.index-this.actual.index)))}seek(e){if(this.seeking!==void 0){if(this.seeking.position.key===e.key)return Kf(nd(this.seeking.done));L(id(this.seeking.done,!1))}let t=ed();return this.seeking={position:e,done:t},this.advanceSeek(),Kf(nd(t))}commit(e,t){(t===`push`||t===`replace`)&&this.write(e,t===`push`),this.actual=this.committed=e}back=()=>{this.direction=-1,this.browser.history.back()};forward=()=>{this.direction=1,this.browser.history.forward()};dispose(){this.browser.removeEventListener(`popstate`,this.onPop),this.browser.removeEventListener(`scroll`,this.saveScroll),this.browser.history.scrollRestoration=this.originalScrollRestoration,this.seeking!==void 0&&L(id(this.seeking.done,!1))}},yO=$v(e=>Dt(e)),bO=$v(e=>Dt(e)),xO=$v(e=>Dt(e)),SO=G({error:H(yO),invalid:H(bO),component:$v(e=>Dt(e))}),CO=G({error:H(yO),invalid:H(bO),notFound:H(xO),component:$v(e=>Dt(e))}),wO=ky(W,Sy),TO=class extends Ob()(`BranchLoadError`,{error:Sy,branch:$v(e=>jt(e))}){},EO=(e,t,n)=>{let r=new URL(e,n),i=r.hash.slice(1);try{i=decodeURIComponent(i)}catch{}return{pathname:r.pathname,search:r.search,hash:i,key:t}},DO=class{registration;browser;selection;patterns;listeners=new Set;modules=new Map;styles=new Map;styleCleanups=new Set;redirects=new Set;history;blockers=new Set;blocked;upgrading=!1;admission;serial=0;transition;committedHref;disposed=!1;started=!1;snapshot={location:void 0,branch:void 0,navigation:{status:`idle`},failure:void 0,commit:0};constructor(e,t,n){this.registration=e,this.browser=n,this.selection=fy(mw)(t),this.patterns=L(fD(e.routes,e.layouts));for(let t of[...e.routes.map(e=>e.page),...e.layouts.map(e=>e.module)])if(!e.modules.has(t.module))throw Error(`Client module '${t.module}' is missing from registration.`)}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));update(e){this.snapshot=e;for(let e of this.listeners)e()}start(){if(this.started)throw Error(`The Ignotum router has already started.`);this.started=!0,this.history=new vO(this.browser,this.onTraversal),this.browser.addEventListener(`beforeunload`,this.onBeforeUnload);let e=this.history.committed;return this.transitionTo(e.href,`initial`,e.key,{},e)}onTraversal=e=>{this.redirects.clear(),this.history?.seek(this.history.committed),this.transitionTo(e.href,`traverse`,e.key,{},e)};back=()=>this.history?.back();forward=()=>this.history?.forward();onBeforeUnload=e=>{this.upgrading||this.blockers.size===0||(e.preventDefault(),e.returnValue=``)};stopForUpgrade=()=>{this.disposed||(this.upgrading=!0,this.browser.removeEventListener(`beforeunload`,this.onBeforeUnload),this.blockers.clear(),this.cancelPending())};upgrade=()=>{this.disposed||(this.stopForUpgrade(),this.browser.location.reload())};setAdmission(e){this.admission=e}setBlocker(e,t){t?this.blockers.add(e):this.blockers.delete(e),!t&&this.blocked?.remaining.delete(e)===!0&&this.releaseBlocked()}getBlocker(e){let t=this.blocked,n=this.snapshot.location;return t===void 0||n===void 0||!t.remaining.has(e)?{status:`idle`}:{status:`blocked`,from:n,to:t.transition.location,proceed:()=>{this.blocked===t&&(t.remaining.delete(e),this.releaseBlocked())},reset:()=>{this.blocked===t&&(this.cancelPending(),this.update({...this.snapshot,navigation:{status:`idle`}}))}}}releaseBlocked(){let e=this.blocked;e!==void 0&&(e.remaining.size===0?(this.blocked=void 0,this.loadTransition(e.transition)):this.update({...this.snapshot}))}navigate(e,t={},n=!1){if(this.disposed||this.upgrading)return Promise.resolve({status:`cancelled`});if(n||this.redirects.clear(),e===this.committedHref)return this.cancelPending(),this.update({...this.snapshot,navigation:{status:`idle`},failure:void 0}),Promise.resolve({status:`committed`});if(n&&(this.committedHref!==void 0&&this.redirects.add(this.committedHref),this.redirects.has(e)||this.redirects.size>=32)){let n=Error(`Ignotum redirect loop at '${e}'.`);return this.cancelPending(),this.update({...this.snapshot,navigation:{status:`idle`},failure:{error:n,retry:()=>{this.redirects.clear(),this.navigate(e,t,!0)}}}),Promise.resolve({status:`failed`,error:n})}let r=t.replace===!0?this.snapshot.location?.key??this.browser.crypto.randomUUID():this.browser.crypto.randomUUID();return this.transitionTo(e,t.replace===!0?`replace`:`push`,r,t)}preload=async e=>{if(this.disposed||this.upgrading||this.admission!==void 0&&!await this.admission.validate())return;let t=L(UD(this.patterns,e));await this.loadBranch(t,!1)};cancelPending(){this.history!==void 0&&this.history.seek(this.history.committed),this.blocked=void 0,this.transition!==void 0&&L(id(this.transition.completion,{status:`cancelled`})),this.transition=void 0}transitionTo(e,t,n,r={},i){if(this.disposed||this.upgrading)return Promise.resolve({status:`cancelled`});let a=this.history?.captureScroll()??{x:this.browser.scrollX,y:this.browser.scrollY};this.cancelPending();let o=EO(e,n,this.browser.location.origin),s=this.snapshot.location,c=s!==void 0&&s.pathname===o.pathname&&s.hash===o.hash,l=ed(),u=i??{key:n,href:e,index:(this.history?.committed.index??0)+ +(t===`push`)},d={id:++this.serial,href:e,location:o,kind:t,completion:l,position:u,scroll:r.scroll??(c?`preserve`:`auto`),searchOnly:c,sourceScroll:a};return this.transition=d,t!==`initial`&&this.blockers.size>0&&this.snapshot.location!==void 0?(this.blocked={transition:d,remaining:new Set(this.blockers)},this.update({...this.snapshot,navigation:{status:`idle`},failure:void 0})):this.loadTransition(d),Kf(nd(l))}loadTransition(e){let{href:t,location:n,kind:r}=e,i=L(UD(this.patterns,t));this.update({...this.snapshot,navigation:{status:`loading`,to:n},failure:void 0}),(async()=>{if(this.admission!==void 0&&!await this.admission.validate())throw Error(`The app must verify its current selection before navigating.`);if(this.upgrading||this.disposed)throw Error(`The app is updating.`);return this.loadBranch(i)})().then(async a=>{if(!(this.transition!==e||this.disposed))try{let o=this.history;if(o!==void 0){if(!await o.seek(o.committed)||this.transition!==e||this.disposed||r===`traverse`&&(!await o.seek(e.position)||this.transition!==e||this.disposed))return;o.commit(e.position,r)}this.applyMetadata(i),this.committedHref=t,this.update({location:n,branch:a,navigation:{status:`idle`},failure:void 0,commit:e.id})}catch(t){this.fail(e,t)}},t=>{this.fail(e,t),this.upgrading||this.admission?.recoverLoad()})}rendered(e){if(this.transition?.id!==e||this.snapshot.commit!==e){this.snapshot.navigation.status===`idle`&&this.blocked===void 0&&this.history?.restoreSourceScroll();return}let t=this.transition,n=this.browser.document;if(!t.searchOnly){let e=n.querySelector(`#app main, #app [role=main]`)??n.getElementById(`app`);e!==null&&(e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`-1`),e.focus({preventScroll:!0}))}let r=this.history?.scroll.get(t.location.key);if(t.kind===`traverse`&&r!==void 0)this.browser.scrollTo(r.x,r.y);else if(t.scroll===`auto`){let e=t.location.hash===``?null:n.getElementById(t.location.hash);e===null?this.browser.scrollTo(0,0):e.scrollIntoView()}else this.browser.scrollTo(t.sourceScroll.x,t.sourceScroll.y);this.history?.finishScroll(),L(id(this.transition.completion,{status:`committed`})),this.transition=void 0}fail(e,t){if(this.transition!==e||this.disposed)return;this.transition=void 0;let n=t instanceof TO?t:void 0,r=n===void 0?t:n.error;this.update({...this.snapshot,navigation:{status:`idle`},failure:{error:r,branch:e.kind===`initial`?void 0:n?.branch,retry:()=>{this.transitionTo(e.href,e.kind,e.location.key,{scroll:e.scroll},e.position)}}}),L(id(e.completion,{status:`failed`,error:r}))}loadStyle(e){let t=new URL(e,this.browser.location.origin).href,n=this.styles.get(t);if(n!==void 0)return n;let r=this.browser.document,i=Array.from(r.querySelectorAll(`link[rel="stylesheet"]`)).find(e=>e.href===t);if(i?.sheet!==null&&i?.sheet!==void 0)return Promise.resolve();let a=i??r.createElement(`link`),o=Kf(of(n=>{let o=()=>{a.removeEventListener(`load`,s),a.removeEventListener(`error`,c),this.styleCleanups.delete(l)},s=()=>{o(),n(af)},c=()=>{o(),a.remove(),n(F(Error(`Could not load route stylesheet '${e}'.`)))},l=()=>{o(),i===void 0&&a.remove(),n(F(Error(`Router disposed.`)))};return this.styleCleanups.add(l),a.addEventListener(`load`,s),a.addEventListener(`error`,c),i===void 0&&(a.rel=`stylesheet`,a.crossOrigin=`anonymous`,a.href=t,r.head.append(a)),rf(o)})).catch(e=>{throw this.styles.delete(t),e});return this.styles.set(t,o),o}loadModule(e){let t=this.modules.get(e);if(t!==void 0)return t;let n=this.registration.modules.get(e);if(n===void 0)return Promise.reject(Error(`Client module '${e}' is not registered.`));let r=Promise.resolve().then(n.load).then(dy(wO)).catch(t=>{throw this.modules.delete(e),t});return this.modules.set(e,r),r}async loadExport(e){let t=await this.loadModule(e.module);if(!Object.hasOwn(t,e.exportName))throw Error(`Module '${e.module}' has no '${e.exportName}' export.`);return t[e.exportName]}async loadBranch(e,t=!0){let n=e._tag===`NotFound`?void 0:e.route,r=new Map;try{let[i,a]=await Promise.all([Promise.all(e.layouts.map(async e=>{let[n]=await Promise.all([this.loadExport(e.module).then(dy(CO)),t?Promise.all((this.registration.modules.get(e.module.module)?.styles??[]).map(e=>this.loadStyle(e))):void 0]),i={id:e.id,...n};return r.set(e.id,i),i})),n===void 0?void 0:this.loadExport(n.page).then(dy(SO)),Promise.all(t?[...this.registration.styles??[],...n===void 0?[]:this.registration.modules.get(n.page.module)?.styles??[]].map(async e=>this.loadStyle(e)):[])]);return{outcome:e,layouts:i,page:a?.component,pageBoundaries:a}}catch(t){let n=[];for(let t of e.layouts){let e=r.get(t.id);if(e===void 0)break;n.push(e)}throw TO.make({error:t,branch:{outcome:e,layouts:n,page:void 0}})}}setRenderError(e){this.snapshot.branch!==void 0&&this.applyMetadata(this.snapshot.branch.outcome,e)}applyMetadata(e,t=!1){let n=L(VD({applicationName:this.registration.applicationName,layouts:e.layouts.map(e=>e.metadata),page:e._tag===`NotFound`?void 0:e.route?.metadata,outcome:t?`Invalid`:e._tag})),r=this.browser.document;r.title=n.title;for(let e of[`description`,`robots`]){let t=Array.from(r.head.querySelectorAll(`meta[name="${e}"]`)),i=n.meta[e];if(i===void 0){for(let e of t)e.remove();continue}let a=t.shift()??r.createElement(`meta`);for(let e of t)e.remove();a.name=e,a.content=i,a.isConnected||r.head.append(a)}}dispose(){this.disposed=!0,this.cancelPending(),this.history?.dispose(),this.browser.removeEventListener(`beforeunload`,this.onBeforeUnload);for(let e of this.styleCleanups)e();this.listeners.clear()}},OO=({error:e,retry:t})=>S(`div`,{role:`alert`},e instanceof Error?e.message:`This page could not load or render. `,S(`button`,{onClick:t},`Retry`)),kO=({children:e,component:t,branch:n,router:r,onRetry:i})=>{let[a,o]=He(),[,s]=Qe(e=>{o({branch:n,error:e}),r.setRenderError(!0)});return a?.branch===n?S(t,{error:a.error,retry:()=>{r.setRenderError(!1),i?.(),o(void 0),s()}}):e},AO=({branch:e,location:t,router:n,failure:r})=>{let i=e.outcome,a,o=e.layouts.length-1,s;if(i._tag===`Matched`&&e.page!==void 0)a=S(e.page,{key:i.route.id,params:i.params,searchParams:i.searchParams});else if(i._tag===`Invalid`&&e.pageBoundaries?.invalid!==void 0)a=S(e.pageBoundaries.invalid,{location:t,issues:i.issues});else{a=S(`main`,{"data-ignotum-outcome":i._tag},i._tag===`Invalid`?`Invalid URL`:`Page not found`);for(let n=o;n>=0;n--){let r=e.layouts[n];if(i._tag===`Invalid`&&r.invalid!==void 0){a=S(r.invalid,{location:t,issues:i.issues}),o=n,s=n;break}if(i._tag===`NotFound`&&r.notFound!==void 0){a=S(r.notFound,{location:t}),o=n,s=n;break}}}e.pageBoundaries?.error!==void 0&&i._tag===`Matched`&&(a=S(kO,{key:`page-boundary`,component:e.pageBoundaries.error,branch:e,router:n,children:a}));let c=0;for(;c<=o&&e.layouts[c]?.id===r?.branch?.layouts[c]?.id;)c++;let l=r===void 0?null:S(jO,{failure:r,router:n,layouts:e.layouts.slice(0,c)});for(let t=o;t>=0;t--){let r=e.layouts[t];r.error!==void 0&&t!==s&&(a=S(kO,{key:r.id,component:r.error,branch:e,router:n,children:a})),a=S(r.component,{key:r.id,children:S(ie,{},a,t===c-1?l:null)})}return S(kO,{component:OO,branch:e,router:n,children:S(ie,{},a,c===0?l:null)})},jO=({failure:e,router:t,layouts:n})=>{let r=e.branch;if(r===void 0)return S(`div`,{"data-ignotum-load-error":``},S(OO,e));let i=S(OO,e),a=!1;for(let o of[...n??r.layouts].reverse())o.error!==void 0&&(a?i=S(kO,{component:o.error,branch:r,router:t,onRetry:e.retry,children:i}):(i=S(o.error,{error:e.error,retry:e.retry}),a=!0));return S(`div`,{"data-ignotum-load-error":``},S(kO,{component:OO,branch:r,router:t,onRetry:e.retry,children:i}))},MO=({router:e})=>{let t=XD(e);return Ge(()=>{e.rendered(t.commit)},[e,t]),S(JD.Provider,{value:e},t.branch===void 0||t.location===void 0?S(`div`,{role:`status`},t.failure===void 0?`Loading…`:null):S(AO,{branch:t.branch,location:t.location,router:e,failure:t.failure}),t.failure!==void 0&&t.branch===void 0?S(jO,{failure:t.failure,router:e}):null)},NO=new WeakSet,PO=({client:e})=>{let[t,n]=He(e.upgrade.getSnapshot);return Ge(()=>e.upgrade.subscribe(()=>n(e.upgrade.getSnapshot())),[e]),t.phase===`ready`&&t.recovery.length===0?null:S(`aside`,{"data-ignotum-update":t.phase,role:t.phase===`error`?`alert`:`status`},t.message??(t.phase===`connecting`?`Connecting to the app…`:null),t.recovery.length===0?null:S(`ul`,null,t.recovery.map(e=>S(`li`,{key:e},e))),t.phase===`error`?S(`button`,{type:`button`,onClick:()=>e.retry()},`Reload app`):null,t.recovery.length===0?null:S(`button`,{type:`button`,onClick:e.upgrade.dismissRecovery},`Dismiss`))},FO=(e,t)=>{let n=window.document.getElementById(`app`);if(n===null)throw Error(`Ignotum mount element is missing.`);if(NO.has(n))throw Error(`The Ignotum client is already mounted.`);let r=new DO(e,t,window),i=OE(t,window,{stopAdmission:r.stopForUpgrade,reload:r.upgrade});r.setAdmission({validate:i.client.validate,recoverLoad:i.client.recoverLoad}),De(S(ie,null,S(PO,{client:i.client}),S(MO,{router:r})),n);let a=i.client.whenReady().then(e=>e?r.start():{status:`cancelled`});NO.add(n);let o=!1;return{ready:a,upgrade:()=>i.client.upgrade.require(),dispose:()=>{o||(o=!0,NO.delete(n),r.dispose(),i.dispose(),De(null,n))}}},IO=t({createApi:()=>BO,functionPathOf:()=>RO}),LO=Symbol.for(`ignotum/internal/api/FunctionReference`),RO=e=>e[LO],zO=e=>{let t=new Map;return new Proxy({},{get:(n,r)=>{if(!St(r))return;let i=t.get(r);if(i!==void 0)return i;let a={[LO]:Zw.make(`api.${e}.${r}`)};return t.set(r,a),a}})};function BO(){let e=new Map;return new Proxy({},{get:(t,n)=>{if(!St(n))return;let r=e.get(n);if(r!==void 0)return r;let i=zO(n);return e.set(n,i),i}})}var VO=Symbol.for(`ignotum/client/QuerySkip`),HO=Object.freeze(new class{[VO]=VO}),UO={skip:HO},WO=e=>e===HO,GO=(e,t)=>{let n=new Map,r=!1,i=e=>{e.released=!0,e.release?.()};return{observe:R(`PageObservers.observe`)(function*(i,a){if(r)return;let o=wE.queryIdentity(i,a),s=n.get(o);if(s!==void 0)return yield*s.acquire;let c={acquire:yield*If(sf(function*(){let n=yield*(yield*TE).observe(i,a);if(c.released){t(n.release);return}let r=n.subscribe(e);return c.release=()=>{r(),t(n.release)},n})),release:void 0,released:!1};return n.set(o,c),yield*c.acquire}),retain:e=>{for(let[t,r]of n)e.has(t)||(n.delete(t),i(r))},release:()=>{if(!r){r=!0;for(let e of n.values())i(e);n.clear()}}}};function KO(e,t){let n=RO(e),r=WO(t),i=t===void 0||r?{}:t,a=OC(i),o=r?`skip:${n}`:wE.queryIdentity(n,a),[s,c]=He(()=>({identity:o,result:ZC()}));if(Ze({args:i,function:n,result:s.result}),We(()=>{if(r)return;let e=!0,t;return DE.runPromise(sf(function*(){return yield*(yield*TE).observe(n,a)})).then(n=>{if(!e){DE.runFork(n.release);return}let r=()=>{let e=n.getSnapshot();c({identity:o,result:e})};t=n.subscribe(r),r();let i=t;t=()=>{i(),DE.runFork(n.release)}},t=>{e&&oy(qT)(t)&&c({identity:o,result:t})}),()=>{e=!1,t?.()}},[o]),r||s.identity!==o)return ZC();let l=s.result;if(oy(qT)(l))throw l;return l}function qO(e,t,n={}){let r=RO(e),i=WO(t),a=t===void 0||i?{}:t,o=OC(a),s=fy(Kw)(n.pageSize??20),c=i?`skip:${r}`:wE.queryIdentity(r,o),[l,u]=He(1),[d,f]=He(0),[p,m]=He(()=>({identity:c,result:ZC()})),h=Ye(()=>u(e=>e+1),[]),g=Je(()=>GO(()=>f(e=>e+1),e=>{DE.runFork(e)}),[c,s]);if(We(()=>()=>g.release(),[g]),Ze({args:a,function:r,result:p.result}),We(()=>{u(1),m({identity:c,result:ZC()})},[c,s]),We(()=>{if(i)return;let e=!0,t=new Set;return DE.runPromise(sf(function*(){let n=[],i=null;for(let o=0;o<l;o+=1){let o=OC({...a,pagination:{cursor:i,pageSize:s}});t.add(wE.queryIdentity(r,o));let l=yield*g.observe(r,o);if(!e||l===void 0)return;let u=l.getSnapshot();if(oy(qT)(u)){m({identity:c,result:u});return}let d=GC(u);if(d===void 0){m({identity:c,result:n.length===0?ZC():$C.succeed({items:n,loadMore:h,status:`LoadingMore`})});return}if(d.type===`Failure`){m({identity:c,result:u});return}let f=d.value;if(n.push(...f.items),i=f.nextCursor,i===null){m({identity:c,result:$C.succeed({items:n,loadMore:h,status:`Exhausted`})});return}}m({identity:c,result:$C.succeed({items:n,loadMore:h,status:`CanLoadMore`})})}).pipe(Nf(rf(()=>{e&&g.retain(t)})))).catch(t=>{e&&oy(qT)(t)&&m({identity:c,result:t})}),()=>{e=!1}},[r,c,h,s,g,d,l,i]),i||p.identity!==c)return ZC();let _=p.result;if(oy(qT)(_))throw _;return _}var JO=e=>Je(()=>t=>{let n=RO(e),r=t===void 0?{}:t;return DE.runPromise(sf(function*(){return yield*(yield*TE).mutate(n,r)}))},[e]);function YO(){let[e,t]=He({status:`pending`});We(()=>{let e=!0,n;return DE.runPromise(Bw).then(r=>{if(!e)return;let i=()=>t(r.snapshot());n=r.subscribe(i),i()}),()=>{e=!1,n?.()}},[]);let n=Je(()=>({signIn:e=>DE.runPromise(sf(function*(){return yield*(yield*Bw).start(`signIn`,e?.profile??[],e?.returnTo)})),requestProfile:(e,t)=>DE.runPromise(sf(function*(){return yield*(yield*Bw).start(`requestProfile`,e,t?.returnTo)})),signOut:()=>DE.runPromise(sf(function*(){return yield*(yield*Bw).signOut}))}),[]);return{...e,...n}}var XO=({src:e,alt:t,...n})=>S(`img`,{...n,src:e.url,alt:t}),ZO=e=>({type:`ImageSource`,url:e}),QO=t({Component:()=>ae,Files:()=>iE,Fragment:()=>ie,Image:()=>XO,Link:()=>lO,NavLink:()=>uO,Query:()=>UO,Redirect:()=>dO,Result:()=>$O,cloneElement:()=>Oe,createContext:()=>ke,createElement:()=>S,createRef:()=>re,h:()=>S,isValidElement:()=>a,toChildArray:()=>me,url:()=>ZD,useBlocker:()=>rO,useCallback:()=>Ye,useContext:()=>Xe,useDebugValue:()=>Ze,useEffect:()=>We,useElementId:()=>$e,useErrorBoundary:()=>Qe,useId:()=>YO,useImperativeHandle:()=>qe,useLayoutEffect:()=>Ge,useLocation:()=>tO,useMatch:()=>aO,useMemo:()=>Je,useMutation:()=>JO,useNavigate:()=>eO,useNavigation:()=>nO,usePaginatedQuery:()=>qO,useQuery:()=>KO,useReducer:()=>Ue,useRef:()=>Ke,useRoute:()=>oO,useState:()=>He}),$O={match:$C.match},ek=0;Array.isArray;function tk(e,t,n,i,a,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ek,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}var nk=t({Fragment:()=>ie,jsx:()=>tk,jsxDEV:()=>tk,jsxs:()=>tk}),rk=t({Fragment:()=>ie,jsx:()=>tk,jsxDEV:()=>tk,jsxs:()=>tk}),ik=t({bindSchema:()=>sk,createImageSource:()=>ZO,createRouteReference:()=>KD,getRouteDefinition:()=>qD,mountClient:()=>FO}),ak=dy(UE,{onExcessProperty:`error`}),ok=e=>{let t=ak(e);return{descriptor:t,default:e=>({descriptor:ak({type:`default`,value:t,default:e})})}},sk=()=>({route:e=>{dy(qE,{onExcessProperty:`error`})({title:e.title,meta:e.meta});let t=e.params??{};dy(XE.fields.params)(Object.entries(t).map(([e,t])=>({name:e,value:t.descriptor})));for(let t of Object.values(e.searchParams??{}))ak(t.descriptor);return e},layout:e=>(dy(JE,{onExcessProperty:`error`})({title:e.title,titleTemplate:e.titleTemplate,meta:e.meta}),e),values:{string:()=>ok({type:`string`}),id:e=>ok({type:`id`,table:e}),number:()=>ok({type:`number`}),integer:()=>ok({type:`integer`}),boolean:()=>ok({type:`boolean`}),literal:e=>ok({type:`literal`,value:e}),literals:(...e)=>ok({type:`literals`,values:e}),optional:e=>({descriptor:ak({type:`optional`,value:e.descriptor})}),array:e=>ok({type:`array`,value:dy(zE)(e.descriptor)})}}),ck=t({Component:()=>Pk,Fragment:()=>Nk,cloneElement:()=>iA,createContext:()=>aA,createElement:()=>Ak,createRef:()=>Mk,h:()=>Ak,hydrate:()=>rA,isValidElement:()=>dk,options:()=>Q,render:()=>nA,toChildArray:()=>Uk}),lk,Q,uk,dk,fk,pk,mk,hk,gk,_k,vk,yk,bk,xk,Sk,Ck,wk={},Tk=[],Ek=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Dk=Array.isArray;function Ok(e,t){for(var n in t)e[n]=t[n];return e}function kk(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Ak(e,t,n){var r,i,a,o={};for(a in t)a==`key`?r=t[a]:a==`ref`?i=t[a]:o[a]=t[a];if(arguments.length>2&&(o.children=arguments.length>3?lk.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(a in e.defaultProps)o[a]===void 0&&(o[a]=e.defaultProps[a]);return jk(e,o,r,i,null)}function jk(e,t,n,r,i){var a={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++uk,__i:-1,__u:0};return i==null&&Q.vnode!=null&&Q.vnode(a),a}function Mk(){return{current:null}}function Nk(e){return e.children}function Pk(e,t){this.props=e,this.context=t}function Fk(e,t){if(t==null)return e.__?Fk(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?Fk(e):null}function Ik(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],a=Ok({},t);a.__v=t.__v+1,Q.vnode&&Q.vnode(a),Jk(e.__P,a,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??Fk(t),!!(32&t.__u),i),a.__v=t.__v,a.__.__k[a.__i]=a,Xk(r,a,i),t.__e=t.__=null,a.__e!=n&&Lk(a)}}function Lk(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Lk(e)}function Rk(e){(!e.__d&&(e.__d=!0)&&fk.push(e)&&!zk.__r++||pk!=Q.debounceRendering)&&((pk=Q.debounceRendering)||mk)(zk)}function zk(){try{for(var e,t=1;fk.length;)fk.length>t&&fk.sort(hk),e=fk.shift(),t=fk.length,Ik(e)}finally{fk.length=zk.__r=0}}function Bk(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,h,g,_=r&&r.__k||Tk,v=t.length;for(c=Vk(n,t,_,c,v),d=0;d<v;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&_[p.__i]||wk,p.__i=d,g=Jk(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&$k(f.ref,null,p),u.push(p.ref,p.__c||m,p)),h==null&&m!=null&&(h=m),4&p.__u?(c=Hk(p,c,e),f.__e&&(f.__e=null)):typeof p.type==`function`&&g!==void 0?c=g:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=h,c}function Vk(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=jk(null,o,null,null,null):Dk(o)?o=e.__k[a]=jk(Nk,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=jk(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=Wk(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=Fk(s)),eA(s,s));return r}function Hk(e,t,n){var r,i;if(typeof e.type==`function`){for(r=e.__k,i=0;r&&i<r.length;i++)r[i]&&(r[i].__=e,t=Hk(r[i],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Fk(e)),t=n.insertBefore(e.__e,t||null));do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Uk(e,t){return t||=[],e==null||typeof e==`boolean`||(Dk(e)?e.some(function(e){Uk(e,t)}):t.push(e)),t}function Wk(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&!(2&l.__u);if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function Gk(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||Ek.test(t)?n:n+`px`}function Kk(e,t,n,r,i){var a,o;n:if(t==`style`){if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||Gk(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||Gk(e.style,t,n[t])}}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(yk,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n[vk]=r[vk]:(n[vk]=bk,e.addEventListener(t,a?Sk:xk,a)):e.removeEventListener(t,a?Sk:xk,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function qk(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[_k]==null)t[_k]=bk++;else if(t[_k]<n[vk])return;return n(Q.event?Q.event(t):t)}}}function Jk(e,t,n,r,i,a,o,s,c,l){var u,d,f,p,m,h,g,_,v,y,b,ee,x,te,S,ne,re=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),a=[s=t.__e=n.__e]),(u=Q.__b)&&u(t);n:if(typeof re==`function`){d=o.length;try{if(v=t.props,y=re.prototype&&re.prototype.render,b=(u=re.contextType)&&r[u.__c],ee=u?b?b.props.value:u.__:r,n.__c?_=(f=t.__c=n.__c).__=f.__E:(y?t.__c=f=new re(v,ee):(t.__c=f=new Pk(v,ee),f.constructor=re,f.render=tA),b&&b.sub(f),f.state||(f.state={}),f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),y&&f.__s==null&&(f.__s=f.state),y&&re.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Ok({},f.__s)),Ok(f.__s,re.getDerivedStateFromProps(v,f.__s))),m=f.props,h=f.state,f.__v=t,p)y&&re.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),y&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(y&&re.getDerivedStateFromProps==null&&v!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(v,ee),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(v,f.__s,ee)){t.__v!=n.__v&&(f.props=v,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),Tk.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&o.push(f),s=Fk(n);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(v,f.__s,ee),y&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,g)})}if(f.context=ee,f.props=v,f.__P=e,f.__e=!1,x=Q.__r,te=0,y)f.state=f.__s,f.__d=!1,x&&x(t),u=f.render(f.props,f.state,f.context),Tk.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,x&&x(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++te<25);f.state=f.__s,f.getChildContext!=null&&(r=Ok(Ok({},r),f.getChildContext())),y&&!p&&f.getSnapshotBeforeUpdate!=null&&(g=f.getSnapshotBeforeUpdate(m,h)),S=u!=null&&u.type===Nk&&u.key==null?Zk(u.props.children):u,s=Bk(e,Dk(S)?S:[S],t,n,r,i,a,o,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&o.push(f),_&&(f.__E=f.__=null)}catch(e){if(o.length=d,t.__v=null,c||a!=null){if(e.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;a!=null&&(a[a.indexOf(s)]=null),t.__e=s}else if(a!=null)for(ne=a.length;ne--;)kk(a[ne])}else t.__e=n.__e;t.__k??=n.__k||[],e.then||Yk(t),Q.__e(e,t,n)}}else a==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=Qk(n.__e,t,n,r,i,a,o,c,l);return(u=Q.diffed)&&u(t),128&t.__u?void 0:s}function Yk(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(Yk))}function Xk(e,t,n){for(var r=0;r<n.length;r++)$k(n[r],n[++r],n[++r]);Q.__c&&Q.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){Q.__e(e,t.__v)}})}function Zk(e){return typeof e!=`object`||!e||e.__b>0?e:Dk(e)?e.map(Zk):e.constructor===void 0?Ok({},e):null}function Qk(e,t,n,r,i,a,o,s,c){var l,u,d,f,p,m,h,g=n.props||wk,_=t.props,v=t.type;if(v==`svg`?i=`http://www.w3.org/2000/svg`:v==`math`?i=`http://www.w3.org/1998/Math/MathML`:i||=`http://www.w3.org/1999/xhtml`,a!=null){for(l=0;l<a.length;l++)if((p=a[l])&&`setAttribute`in p==!!v&&(v?p.localName==v:p.nodeType==3)){e=p,a[l]=null;break}}if(e==null){if(v==null)return document.createTextNode(_);e=document.createElementNS(i,v,_.is&&_),s&&=(Q.__m&&Q.__m(t,a),!1),a=null}if(v==null)g===_||s&&e.data==_||(e.data=_);else{if(a=v==`textarea`&&_.defaultValue!=null?null:a&&lk.call(e.childNodes),!s&&a!=null)for(g={},l=0;l<e.attributes.length;l++)g[(p=e.attributes[l]).name]=p.value;for(l in g)p=g[l],l==`dangerouslySetInnerHTML`?d=p:l==`children`||l in _||l==`value`&&`defaultValue`in _||l==`checked`&&`defaultChecked`in _||Kk(e,l,null,p,i);for(l in _)p=_[l],l==`children`?f=p:l==`dangerouslySetInnerHTML`?u=p:l==`value`?m=p:l==`checked`?h=p:s&&typeof p!=`function`||g[l]===p||Kk(e,l,p,g[l],i);if(u)s||d&&(u.__html==d.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=``),Bk(t.type==`template`?e.content:e,Dk(f)?f:[f],t,n,r,v==`foreignObject`?`http://www.w3.org/1999/xhtml`:i,a,o,a?a[0]:n.__k&&Fk(n,0),s,c),a!=null)for(l=a.length;l--;)kk(a[l]);s&&v!=`textarea`||(l=`value`,v==`progress`&&m==null?e.removeAttribute(`value`):m!=null&&(m!==e[l]||v==`progress`&&!m||v==`option`&&m!=g[l])&&Kk(e,l,m,g[l],i),l=`checked`,h!=null&&h!=e[l]&&Kk(e,l,h,g[l],i))}return e}function $k(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){Q.__e(e,n)}}function eA(e,t,n){var r,i;if(Q.unmount&&Q.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||$k(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){Q.__e(e,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&eA(r[i],t,n||typeof e.type!=`function`);n||kk(e.__e),e.__c=e.__=e.__e=void 0}function tA(e,t,n){return this.constructor(e,n)}function nA(e,t,n){var r,i,a,o;t==document&&(t=document.documentElement),Q.__&&Q.__(e,t),i=(r=typeof n==`function`)?null:n&&n.__k||t.__k,a=[],o=[],Jk(t,e=(!r&&n||t).__k=Ak(Nk,null,[e]),i||wk,wk,t.namespaceURI,!r&&n?[n]:i?null:t.firstChild?lk.call(t.childNodes):null,a,!r&&n?n:i?i.__e:t.firstChild,r,o),Xk(a,e,o),e.props.children=null}function rA(e,t){nA(e,t,rA)}function iA(e,t,n){var r,i,a,o,s=Ok({},e.props);for(a in e.type&&e.type.defaultProps&&(o=e.type.defaultProps),t)a==`key`?r=t[a]:a==`ref`?i=t[a]:s[a]=t[a]===void 0&&o!=null?o[a]:t[a];return arguments.length>2&&(s.children=arguments.length>3?lk.call(arguments,2):n),jk(e.type,s,r||e.key,i||e.ref,null)}function aA(e){function t(e){var n,r;return this.getChildContext||(n=new Set,(r={})[t.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(e){this.props.value!=e.value&&n.forEach(function(e){e.__e=!0,Rk(e)})},this.sub=function(e){n.add(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){n&&n.delete(e),t&&t.call(e)}}),e.children}return t.__c=`__cC`+Ck++,t.__=e,t.Provider=t.__l=(t.Consumer=function(e,t){return e.children(t)}).contextType=t,t}lk=Tk.slice,Q={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},uk=0,dk=function(e){return e!=null&&e.constructor===void 0},Pk.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Ok({},this.state);typeof e==`function`&&(e=e(Ok({},n),this.props)),e&&Ok(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Rk(this))},Pk.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Rk(this))},Pk.prototype.render=Nk,fk=[],mk=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,hk=function(e,t){return e.__v.__b-t.__v.__b},zk.__r=0,gk=Math.random().toString(8),_k=`__d`+gk,vk=`__a`+gk,yk=/(PointerCapture)$|Capture$/i,bk=0,xk=qk(!1),Sk=qk(!0),Ck=0;var oA=t({useCallback:()=>DA,useContext:()=>OA,useDebugValue:()=>kA,useEffect:()=>SA,useErrorBoundary:()=>AA,useId:()=>jA,useImperativeHandle:()=>TA,useLayoutEffect:()=>CA,useMemo:()=>EA,useReducer:()=>xA,useRef:()=>wA,useState:()=>bA}),sA,$,cA,lA,uA=0,dA=[],fA=r,pA=fA.__b,mA=fA.__r,hA=fA.diffed,gA=fA.__c,_A=fA.unmount,vA=fA.__;function yA(e,t){fA.__h&&fA.__h($,e,uA||t),uA=0;var n=$.__H||($.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function bA(e){return uA=1,xA(RA,e)}function xA(e,t,n){var r=yA(sA++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):RA(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=$,!$.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=!1,o=r.__c.props!==e;if(r.__c.__H.__.some(function(e){if(e.__N){i=!0;var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a){var s=a.call(this,e,t,n);return i?s||o:s}return!i||o};$.__f=!0;var a=$.shouldComponentUpdate,o=$.componentWillUpdate;$.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},$.shouldComponentUpdate=i}return r.__N||r.__}function SA(e,t){var n=yA(sA++,3);!fA.__s&&LA(n.__H,t)&&(n.__=e,n.u=t,$.__H.__h.push(n))}function CA(e,t){var n=yA(sA++,4);!fA.__s&&LA(n.__H,t)&&(n.__=e,n.u=t,$.__h.push(n))}function wA(e){return uA=5,EA(function(){return{current:e}},[])}function TA(e,t,n){uA=6,CA(function(){if(typeof e==`function`){var n=e(t());return function(){e(null),n&&typeof n==`function`&&n()}}if(e)return e.current=t(),function(){return e.current=null}},n==null?n:n.concat(e))}function EA(e,t){var n=yA(sA++,7);return LA(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function DA(e,t){return uA=8,EA(function(){return e},t)}function OA(e){var t=$.context[e.__c],n=yA(sA++,9);return n.c=e,t?(n.__??(n.__=!0,t.sub($)),t.props.value):e.__}function kA(e,t){fA.useDebugValue&&fA.useDebugValue(t?t(e):e)}function AA(e){var t=yA(sA++,10),n=bA();return t.__=e,$.componentDidCatch||($.componentDidCatch=function(e,r){t.__&&t.__(e,r),n[1](e)}),[n[0],function(){n[1](void 0)}]}function jA(){var e=yA(sA++,11);if(!e.__){for(var t=$.__v;t!==null&&!t.__m&&t.__!==null;)t=t.__;var n=t.__m||(t.__m=[0,0]);e.__=`P`+n[0]+`-`+n[1]++}return e.__}function MA(){for(var e;e=dA.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(FA),t.__h.some(IA),t.__h=[]}catch(n){t.__h=[],fA.__e(n,e.__v)}}}fA.__b=function(e){$=null,pA&&pA(e)},fA.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),vA&&vA(e,t)},fA.__r=function(e){mA&&mA(e),sA=0;var t=($=e.__c).__H;t&&(cA===$?(t.__h=[],$.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(FA),t.__h.some(IA),t.__h=[],sA=0)),cA=$},fA.diffed=function(e){hA&&hA(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(dA.push(t)!==1&&lA===fA.requestAnimationFrame||((lA=fA.requestAnimationFrame)||PA)(MA)),t.__H.__.some(function(e){e.u&&=(e.__H=e.u,void 0)})),cA=$=null},fA.__c=function(e,t){t.some(function(e){try{e.__h.some(FA),e.__h=e.__h.filter(function(e){return!e.__||IA(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],fA.__e(n,e.__v)}}),gA&&gA(e,t)},fA.unmount=function(e){_A&&_A(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{FA(e)}catch(e){t=e}}),n.__H=void 0,t&&fA.__e(t,n.__v))};var NA=typeof requestAnimationFrame==`function`;function PA(e){var t,n=function(){clearTimeout(r),NA&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);NA&&(t=requestAnimationFrame(n))}function FA(e){var t=$,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),$=t}function IA(e){var t=$;e.__c=e.__(),$=t}function LA(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function RA(e,t){return typeof t==`function`?t(e):t}var zA=t({Fragment:()=>ie,jsx:()=>GA,jsxAttr:()=>YA,jsxDEV:()=>GA,jsxEscape:()=>XA,jsxTemplate:()=>KA,jsxs:()=>GA}),BA=/["&<]/;function VA(e){if(e.length===0||!1===BA.test(e))return e;for(var t=0,n=0,r=``,i=``;n<e.length;n++){switch(e.charCodeAt(n)){case 34:i=`"`;break;case 38:i=`&`;break;case 60:i=`<`;break;default:continue}n!==t&&(r+=e.slice(t,n)),r+=i,t=n+1}return n!==t&&(r+=e.slice(t,n)),r}var HA=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,UA=0,WA=Array.isArray;function GA(e,t,n,i,a,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--UA,__i:-1,__u:0,__source:a,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return r.vnode&&r.vnode(u),u}function KA(e){var t=GA(ie,{tpl:e,exprs:[].slice.call(arguments,1)});return t.key=t.__v,t}var qA={},JA=/[A-Z]/g;function YA(e,t){if(r.attr){var n=r.attr(e,t);if(typeof n==`string`)return n}if(t=function(e){return typeof e==`object`&&e&&typeof e.valueOf==`function`?e.valueOf():e}(t),e===`ref`||e===`key`)return``;if(e===`style`&&typeof t==`object`){var i=``;for(var a in t){var o=t[a];if(o!=null&&o!==``){var s=a[0]==`-`?a:qA[a]||(qA[a]=a.replace(JA,`-$&`).toLowerCase()),c=`;`;typeof o!=`number`||s.startsWith(`--`)||HA.test(s)||(c=`px;`),i=i+s+`:`+o+c}}return e+`="`+VA(i)+`"`}return t==null||!1===t||typeof t==`function`||typeof t==`object`?``:!0===t?e:e+`="`+VA(``+t)+`"`}function XA(e){if(e==null||typeof e==`boolean`||typeof e==`function`)return null;if(typeof e==`object`){if(e.constructor===void 0)return e;if(WA(e)){for(var t=0;t<e.length;t++)e[t]=XA(e[t]);return e}}return VA(``+e)}export{IO as api,ik as bindings,QO as client,oA as hooks,nk as jsx,rk as jsxDev,FO as mount,ck as preact,zA as preactJsx,zA as preactJsxDev,WD as routes};
|