@gjermundgaraba/clankerauth-dev 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +0,0 @@
1
- (function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Symbol.for(`better-auth:broadcast-channel`),t=()=>Math.floor(Date.now()/1e3),n=class{listeners=new Set;name;constructor(e=`better-auth.message`){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window<`u`)try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:t()}))}catch{}}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=e=>{if(e.key!==this.name)return;let t=JSON.parse(e.newValue??`{}`);t?.event===`session`&&t?.data&&this.listeners.forEach(e=>e(t))};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}}};function r(t=`better-auth.message`){return globalThis[e]||(globalThis[e]=new n(t)),globalThis[e]}var i=[],a=0,o=null,s=4,c=globalThis.nanostoresGlobal||={epoch:0},l=()=>{let e,t;for(;a<i.length;){t=a,a+=s;try{i[t](i[t+1].value,i[t+2],i[t+3])}catch(t){e=t}}if(i.length=a=0,e)throw e},u=e=>{let t=[],n={eq:Object.is,get(){return n.lc||n.listen(()=>{})(),n.value},init:e,lc:0,listen(e){return n.lc=t.push(e),()=>{for(let t=a;t<i.length;)i[t]===e?i.splice(t,s):t+=s;let r=t.indexOf(e);~r&&(t.splice(r,1),--n.lc||n.off())}},notify(e,r){c.epoch++;let a=!i.length&&!0;for(let a of t)o?.has(a)||(o?.add(a),i.push(a,n,e,r));a&&l()},off(){},set(e){let t=n.value;n.eq(t,e)||(n.value=e,n.notify(t))},subscribe(e){let t=n.listen(e);return e(n.value),t},value:e};return n},d=2,f=5,p=6,m=10,h=(e,t,n,r)=>(e.events=e.events||{},e.events[n+m]||(e.events[n+m]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);~i&&(r.splice(i,1),r.length||(e.events[n+m](),delete e.events[n+m]))}),ee=(e,t)=>h(e,t,d,t=>{let n=e.set,r=e.setKey;return e.setKey&&=(n,i)=>{let a;if(t({abort:()=>{a=!0},changed:n,newValue:{...e.value,[n]:i}}),!a)return r(n,i)},e.set=e=>{let r;if(t({abort:()=>{r=!0},newValue:e}),!r)return n(e)},()=>{e.set=n,e.setKey=r}}),te=1e3,ne=(e,t)=>h(e,n=>{let r=t(n);r&&e.events[p].push(r)},f,t=>{let n=e.listen;e.listen=(...r)=>(!e.lc&&!e.active&&(e.active=!0,t()),n(...r));let r=e.off;return e.events[p]=[],e.off=()=>{r(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let t of e.events[p])t();e.events[p]=[]}},te)},()=>{e.listen=n,e.off=r}});function re(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ie(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!ie(e[n],t[n]))return!1;return!0}if(re(e)&&re(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!(r in t)||!ie(e[r],t[r]))return!1;return!0}return!1}function ae(e,t){return ee(e,({newValue:n,abort:r})=>{t(e.value,n)&&r()})}var oe=Symbol.for(`better-auth:focus-manager`),se=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||typeof document>`u`||window.addEventListener===void 0)return()=>{};let e=()=>{document.visibilityState===`visible`&&this.setFocused(!0)};return document.addEventListener(`visibilitychange`,e,!1),()=>{document.removeEventListener(`visibilitychange`,e,!1)}}};function ce(){return globalThis[oe]||(globalThis[oe]=new se),globalThis[oe]}var le=Symbol.for(`better-auth:online-manager`),ue=class{listeners=new Set;isOnline=typeof navigator<`u`?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach(t=>t(e))}setup(){if(typeof window>`u`||window.addEventListener===void 0)return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(`online`,e,!1),window.addEventListener(`offline`,t,!1),()=>{window.removeEventListener(`online`,e,!1),window.removeEventListener(`offline`,t,!1)}}};function de(){return globalThis[le]||(globalThis[le]=new ue),globalThis[le]}var fe={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},pe=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,me={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:1/0,"-infinity":-1/0},he=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function ge(e){return e instanceof Date&&!isNaN(e.getTime())}function _e(e){let t=he.exec(e);if(!t)return null;let[,n,r,i,a,o,s,c,l,u,d]=t,f=new Date(Date.UTC(parseInt(n,10),parseInt(r,10)-1,parseInt(i,10),parseInt(a,10),parseInt(o,10),parseInt(s,10),c?parseInt(c.padEnd(3,`0`),10):0));if(l){let e=(parseInt(u,10)*60+parseInt(d,10))*(l===`+`?-1:1);f.setUTCMinutes(f.getUTCMinutes()+e)}return ge(f)?f:null}function ve(e,t={}){let{strict:n=!1,warnings:r=!1,reviver:i,parseDates:a=!0}=t;if(typeof e!=`string`)return e;let o=e.trim(),s=o.toLowerCase();if(s.length<=9&&s in me)return me[s];if(!pe.test(o)){if(n)throw SyntaxError(`[better-json] Invalid JSON`);return e}if(Object.entries(fe).some(([e,t])=>{let n=t.test(o);return n&&r&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`),n})&&n)throw Error(`[better-json] Potential prototype pollution attempt detected`);try{return JSON.parse(o,(e,t)=>{if(e===`__proto__`||e===`constructor`&&t&&typeof t==`object`&&`prototype`in t){r&&console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);return}if(a&&typeof t==`string`){let e=_e(t);if(e)return e}return i?i(e,t):t})}catch(t){if(n)throw t;return e}}function ye(e,t={strict:!0}){return ve(e,t)}var be=Symbol.for(`better-auth:auth-query`);function xe(e){let t=u(e);return Object.defineProperty(t,be,{value:!0}),t}var Se=()=>Math.floor(Date.now()/1e3),Ce=5;function we(e){let{fetchSession:t,shouldPollSession:n=()=>!0,sessionSignal:i,options:a={}}=e,o=a.sessionOptions?.refetchInterval??0,s=a.sessionOptions?.refetchOnWindowFocus??!0,c=a.sessionOptions?.refetchWhenOffline??!1,l={isInitialized:!1,lastSessionRequest:0},u=()=>c||de().isOnline,d=e=>{if(u()){if(e?.event===`storage`){t();return}if(e?.event===`poll`){l.lastSessionRequest=Se(),t();return}if(e?.event===`visibilitychange`){if(Se()-l.lastSessionRequest<Ce)return;l.lastSessionRequest=Se(),t();return}t()}},f=e=>{r().post({event:`session`,data:{trigger:e},clientId:Math.random().toString(36).substring(7)})},p=()=>{o&&o>0&&(l.pollInterval=setInterval(()=>{n()&&d({event:`poll`})},o*1e3))},m=()=>{l.unsubscribeBroadcast=r().subscribe(()=>{d({event:`storage`})})},h=()=>{s&&(l.unsubscribeFocus=ce().subscribe(()=>{d({event:`visibilitychange`})}))},ee=()=>{l.unsubscribeOnline=de().subscribe(e=>{e&&d({event:`visibilitychange`})})},te=()=>{l.unsubscribeSignal=i.listen(()=>{t()})};return{init:()=>{l.isInitialized||(l.isInitialized=!0,p(),m(),h(),ee(),te(),l.cleanupBroadcastSetup=r().setup(),l.cleanupFocusSetup=ce().setup(),l.cleanupOnlineSetup=de().setup())},cleanup:()=>{l.isInitialized&&(l.pollInterval&&=(clearInterval(l.pollInterval),void 0),l.unsubscribeBroadcast&&=(l.unsubscribeBroadcast(),void 0),l.unsubscribeFocus&&=(l.unsubscribeFocus(),void 0),l.unsubscribeOnline&&=(l.unsubscribeOnline(),void 0),l.unsubscribeSignal&&=(l.unsubscribeSignal(),void 0),l.cleanupBroadcastSetup&&=(l.cleanupBroadcastSetup(),void 0),l.cleanupFocusSetup&&=(l.cleanupFocusSetup(),void 0),l.cleanupOnlineSetup&&=(l.cleanupOnlineSetup(),void 0),l.isInitialized=!1,l.lastSessionRequest=0)},triggerRefetch:d,broadcastSessionUpdate:f}}var Te=Object.create(null),Ee=e=>({}),De=new Proxy(Te,{get(e,t){return Ee()[t]??Te[t]},has(e,t){return t in Ee()||t in Te},set(e,t,n){let r=Ee(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Ee(!0);return delete n[t],!0},ownKeys(){let e=Ee(!0);return Object.keys(e)}});De.NODE_ENV;function g(e,t){return typeof process<`u`?{}[e]??t:typeof Deno<`u`?Deno.env.get(e)??t:typeof Bun<`u`?Bun.env[e]??t:t}Object.freeze({get BETTER_AUTH_SECRET(){return g(`BETTER_AUTH_SECRET`)},get AUTH_SECRET(){return g(`AUTH_SECRET`)},get BETTER_AUTH_TELEMETRY(){return g(`BETTER_AUTH_TELEMETRY`)},get BETTER_AUTH_TELEMETRY_ID(){return g(`BETTER_AUTH_TELEMETRY_ID`)},get NODE_ENV(){return g(`NODE_ENV`,`development`)},get PACKAGE_VERSION(){return g(`PACKAGE_VERSION`,`0.0.0`)},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return g(`BETTER_AUTH_TELEMETRY_ENDPOINT`,``)}});var Oe=1,_=4,ke=8,Ae=24,je={eterm:_,cons25:_,console:_,cygwin:_,dtterm:_,gnome:_,hurd:_,jfbterm:_,konsole:_,kterm:_,mlterm:_,mosh:Ae,putty:_,st:_,"rxvt-unicode-24bit":Ae,terminator:Ae,"xterm-kitty":Ae},Me=new Map(Object.entries({APPVEYOR:ke,BUILDKITE:ke,CIRCLECI:Ae,DRONE:ke,GITEA_ACTIONS:Ae,GITHUB_ACTIONS:Ae,GITLAB_CI:ke,TRAVIS:ke})),Ne=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Pe(){if(g(`FORCE_COLOR`)!==void 0)switch(g(`FORCE_COLOR`)){case``:case`1`:case`true`:return _;case`2`:return ke;case`3`:return Ae;default:return Oe}if(g(`NODE_DISABLE_COLORS`)!==void 0&&g(`NODE_DISABLE_COLORS`)!==``||g(`NO_COLOR`)!==void 0&&g(`NO_COLOR`)!==``||g(`TERM`)===`dumb`)return Oe;if(g(`TMUX`))return Ae;if(`TF_BUILD`in De&&`AGENT_NAME`in De)return _;if(`CI`in De){for(let{0:e,1:t}of Me)if(e in De)return t;return g(`CI_NAME`)===`codeship`?ke:Oe}if(`TEAMCITY_VERSION`in De)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(g(`TEAMCITY_VERSION`))===null?Oe:_;switch(g(`TERM_PROGRAM`)){case`iTerm.app`:return!g(`TERM_PROGRAM_VERSION`)||/^[0-2]\./.exec(g(`TERM_PROGRAM_VERSION`))!==null?ke:Ae;case`HyperTerm`:case`MacTerm`:return Ae;case`Apple_Terminal`:return ke}if(g(`COLORTERM`)===`truecolor`||g(`COLORTERM`)===`24bit`)return Ae;if(g(`TERM`)){if(/truecolor/.exec(g(`TERM`))!==null)return Ae;if(/^xterm-256/.exec(g(`TERM`))!==null)return ke;let e=g(`TERM`).toLowerCase();if(je[e])return je[e];if(Ne.some(t=>t.exec(e)!==null))return _}return g(`COLORTERM`)?_:Oe}var Fe=Symbol.for(`better-auth:global`),Ie=null,Le={},Re=`1.7.7`;function ze(){return globalThis[Fe]||(globalThis[Fe]={version:Re,epoch:1,context:Le},Ie=globalThis[Fe]),Ie=globalThis[Fe],Ie.version!==Re&&(Ie.version=Re,Ie.epoch++),globalThis[Fe]}function Be(){return ze().context.endpointContextAsyncStorage?.getStore()}var Ve={reset:`\x1B[0m`,bright:`\x1B[1m`,dim:`\x1B[2m`,undim:`\x1B[22m`,underscore:`\x1B[4m`,blink:`\x1B[5m`,reverse:`\x1B[7m`,hidden:`\x1B[8m`,fg:{black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},bg:{black:`\x1B[40m`,red:`\x1B[41m`,green:`\x1B[42m`,yellow:`\x1B[43m`,blue:`\x1B[44m`,magenta:`\x1B[45m`,cyan:`\x1B[46m`,white:`\x1B[47m`}},He=[`debug`,`info`,`success`,`warn`,`error`];function Ue(e,t){return He.indexOf(t)>=He.indexOf(e)}var We={info:Ve.fg.blue,success:Ve.fg.green,warn:Ve.fg.yellow,error:Ve.fg.red,debug:Ve.fg.magenta},Ge=(e,t,n)=>{let r=new Date().toISOString();return n?`${Ve.dim}${r}${Ve.reset} ${We[e]}${e.toUpperCase()}${Ve.reset} ${Ve.bright}[Better Auth]:${Ve.reset} ${t}`:`${r} ${e.toUpperCase()} [Better Auth]: ${t}`},Ke=(e=>{let t=e?.disabled!==!0,n=e?.level??`warn`,r=e?.disableColors===void 0?Pe()!==1:!e.disableColors,i=(i,a,o=[])=>{if(!t||!Ue(n,i))return;let s=Ge(i,a,r);if(!e||typeof e.log!=`function`){i===`error`?console.error(s,...o):i===`warn`?console.warn(s,...o):console.log(s,...o);return}e.log(i===`success`?`info`:i,a,...o)};return{...Object.fromEntries(He.map(e=>[e,(...[t,...n])=>i(e,t,n)])),get level(){return n}}})(),qe=()=>{let e=Be()?.context.logger;return e&&e!==Je?e:Ke},Je={debug:(...e)=>qe().debug(...e),info:(...e)=>qe().info(...e),success:(...e)=>qe().success(...e),warn:(...e)=>qe().warn(...e),error:(...e)=>qe().error(...e),get level(){return qe().level}};function Ye(){let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.prototype.hasOwnProperty.call(e,`writable`)?e.writable:e.set!==void 0}function Xe(e){let t=e.split(`
2
- at `);return t.length<=1?e:(t.splice(1,1),t.join(`
3
- at `))}function Ze(e,t){class n extends e{#e;constructor(...e){if(Ye()){let t=Error.stackTraceLimit;Error.stackTraceLimit=0,super(...e),Error.stackTraceLimit=t}else super(...e);let t=Error().stack;t&&(this.#e=Xe(t.replace(/^Error/,this.name)))}get errorStack(){return this.#e}}return Object.defineProperty(n.prototype,"constructor",{get(){return t},enumerable:!1,configurable:!0}),n}var Qe={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,"I'M_A_TEAPOT":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511};Ze(class extends Error{status;body;headers;statusCode;constructor(e=`INTERNAL_SERVER_ERROR`,t=void 0,n={},r=typeof e==`number`?e:Qe[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0),this.status=e,this.body=t,this.headers=n,this.statusCode=r,this.name=`APIError`,this.status=e,this.headers=n,this.statusCode=r,this.body=t}},Error);var $e=class extends Error{constructor(e,t){super(e,t),this.name=`BetterAuthError`,this.message=e,this.stack=``}},et=47;function tt(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===et;)t--;return t===e.length?e:e.slice(0,t)}function nt(e){try{return(tt(new URL(e).pathname)||`/`)!==`/`}catch{throw new $e(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function rt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new $e(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){throw t instanceof $e?t:new $e(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function it(e,t=`/api/auth`){if(rt(e),nt(e))return e;let n=tt(e);return!t||t===`/`?n:(t=t.startsWith(`/`)?t:`/${t}`,`${n}${t}`)}function at(e,t){return!e||e.trim()===``?!1:t===`proto`?e===`http`||e===`https`:t===`host`?[/\.\./,/\0/,/[\s]/,/^[.]/,/[<>'"]/,/javascript:/i,/file:/i,/data:/i].some(t=>t.test(e))?!1:/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e):!1}function ot(e,t,n,r,i){if(e)return it(e,t);if(r!==!1){let e=De.BETTER_AUTH_URL||De.NEXT_PUBLIC_BETTER_AUTH_URL||De.PUBLIC_BETTER_AUTH_URL||De.NUXT_PUBLIC_BETTER_AUTH_URL||De.NUXT_PUBLIC_AUTH_URL||(De.BASE_URL===`/`?void 0:De.BASE_URL);if(e)return it(e,t)}let a=n?.headers.get(`x-forwarded-host`),o=n?.headers.get(`x-forwarded-proto`);if(a&&o&&i&&at(o,`proto`)&&at(a,`host`))try{return it(`${o}://${a}`,t)}catch{}if(n){let e=st(n.url);if(!e)throw new $e(`Could not get origin from request. Please provide a valid base URL.`);return it(e,t)}if(typeof window<`u`&&window.location)return it(window.location.origin,t)}function st(e){try{let t=new URL(e);return t.origin===`null`?null:t.origin}catch{return null}}var ct=[`javascript:`,`data:`,`vbscript:`];function lt(e){let t;try{t=new URL(e)}catch{return!0}return!ct.includes(t.protocol)}var ut={id:`redirect`,name:`Redirect`,hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&lt(e.data.url)&&typeof window<`u`&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}},dt=()=>typeof window>`u`,ft=te;function pt(e,t){if(typeof window>`u`)return;let n=e.get();n.data===null&&t!==null&&e.set({...n,data:t,error:null,isPending:!1})}function mt(e){return typeof e==`object`&&e&&`data`in e&&`error`in e?e:{data:e,error:null}}function ht(e){return!e||e.session===null&&e.user===null?null:e}function gt(e,t){return ie(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function _t(e,t){let n=u(!1),r,i=0,a=0;n.listen(()=>{a++,i=0});let o=e=>d(e),s=xe({data:null,error:null,isPending:!0,isRefetching:!1,refetch:o});ae(s,gt);let c=async(t,n)=>{let r=s.value;if(s.set({...r,isPending:r.data===null,isRefetching:!0,error:null,refetch:o}),t.aborted)return`aborted`;try{let r=await e(`/get-session`,{method:`GET`,query:n?.query,signal:t});if(t.aborted)return`aborted`;let{data:i,error:a}=mt(r),c=`fresh`;if(i?.needsRefresh)try{let n=await e(`/get-session`,{method:`POST`,signal:t});if(t.aborted)return`aborted`;({data:i,error:a}=mt(n))}catch{if(t.aborted)return`aborted`;c=`stale`}if(a){let e=s.value,t=a?.status===401;return s.set({data:t?null:e.data,error:a,isPending:!1,isRefetching:!1,refetch:o}),`failed`}let l=ht(i),u=s.value,d=u.data!=null&&l!=null&&ie(u.data,l)?u.data:l;return s.set({data:d,error:null,isPending:!1,isRefetching:!1,refetch:o}),c}catch(e){if(t.aborted)return`aborted`;let n=s.value;return s.set({data:n.data,error:e,isPending:!1,isRefetching:!1,refetch:o}),`failed`}},l=()=>{let e=s.value.data?.session?.expiresAt,t=e instanceof Date?e.getTime():1/0;return Math.min(Date.now()+ft,t)},d=e=>{i=0,r?.cancel();let t=new AbortController,n={cancel:()=>t.abort(),promise:Promise.resolve().then(()=>t.signal.aborted?`aborted`:c(t.signal,e)),revision:a};r=n;let o=e=>{r===n&&(r=void 0,e===`fresh`&&n.revision===a&&(i=l()))};return n.promise.then(o,()=>o(`failed`)),n.promise.then(()=>void 0)},f=()=>r?.revision===a?r.promise.then(()=>void 0):Date.now()<i?Promise.resolve():d(),p=()=>{};return ne(s,()=>{let e;dt()||(e=setTimeout(()=>{f()},0));let r=we({fetchSession:d,shouldPollSession:()=>s.value.data!=null,sessionSignal:n,options:t});return r.init(),p=r.broadcastSessionUpdate,()=>{e&&clearTimeout(e),r.cleanup()}}),{session:s,$sessionSignal:n,broadcastSessionUpdate:e=>p(e)}}function vt(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function yt(e,t,n=`.`,r){if(!vt(t))return yt(e,{},n,r);let i={...t};for(let t of Object.keys(e)){if(t===`__proto__`||t===`constructor`)continue;let a=e[t];a!=null&&(r&&r(i,t,a,n)||(i[t]=Array.isArray(a)&&Array.isArray(i[t])?[...a,...i[t]]:vt(a)&&vt(i[t])?yt(a,i[t],(n?`${n}.`:``)+t.toString(),r):a))}return i}function bt(e){return(...t)=>t.reduce((t,n)=>yt(t,n,``,e),{})}var xt=bt(),St=class extends Error{constructor(e,t,n){super(t||e.toString(),{cause:n}),this.status=e,this.statusText=t,this.error=n,Error.captureStackTrace(this,this.constructor)}},Ct=async(e,t)=>{let n=t||{},r={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:n,hooks:r};for(let i of t?.plugins||[]){if(i.init){let t=await i.init?.call(i,e.toString(),n);n=t.options||n,e=t.url}r.onRequest.push(i.hooks?.onRequest),r.onResponse.push(i.hooks?.onResponse),r.onSuccess.push(i.hooks?.onSuccess),r.onError.push(i.hooks?.onError),r.onRetry.push(i.hooks?.onRetry)}return{url:e,options:n,hooks:r}},wt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Tt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Et(e){if(typeof e==`number`)return new wt({type:`linear`,attempts:e,delay:1e3});switch(e.type){case`linear`:return new wt(e);case`exponential`:return new Tt(e);default:throw Error(`Invalid retry strategy`)}}var Dt=[`get`,`post`,`put`,`patch`,`delete`];function Ot(e){if(!e.startsWith(`@`))return{method:void 0,path:e};let t=e.indexOf(`/`),n=e.slice(1,t===-1?void 0:t);return Dt.includes(n)?{method:n,path:t===-1?e:e.slice(t+1)}:{method:void 0,path:e}}var kt=e=>e===`.`||e===`..`,At=e=>e.split(`:`).map(e=>encodeURIComponent(e)).join(`:`);function jt(e,t){let n=t.get(e);if(n===void 0)return At(e);if(kt(n))throw TypeError(`Path parameters cannot be reserved path segments`);return encodeURIComponent(n)}function Mt(e,t){let{baseURL:n,params:r,query:i}=t||{query:{},params:{},baseURL:``},a=e.startsWith(`http`)?e.split(`/`).slice(0,3).join(`/`):n||``,{path:o}=Ot(e);o!==e&&(e=`/${o}`),a.endsWith(`/`)||(a+=`/`);let[s,c]=e.replace(a,``).split(`?`),l=new URLSearchParams(c);for(let[e,t]of Object.entries(i||{})){if(t==null)continue;let n;if(typeof t==`string`)n=t;else if(Array.isArray(t)){for(let n of t)l.append(e,n);continue}else n=JSON.stringify(t);l.set(e,n)}let u=new Map;if(r){if(Array.isArray(r)){let e=s.split(`/`).filter(e=>e.startsWith(`:`));for(let[t,n]of e.entries()){let e=r[t];u.set(n,String(e))}}else for(let[e,t]of Object.entries(r))u.set(`:${e}`,String(t))}s=s.split(`/`).map(e=>jt(e,u)).join(`/`),s=s.replace(/^\/+/,``);let d=l.toString();return d=d.length>0?`?${d}`.replace(/\+/g,`%20`):``,a.startsWith(`http`)?new URL(`${s}${d}`,a):`${a}${s}${d}`}var Nt=async e=>{let t={},n=async e=>typeof e==`function`?await e():e;if(e?.auth){if(e.auth.type===`Bearer`){let r=await n(e.auth.token);if(!r)return t;t.authorization=`Bearer ${r}`}else if(e.auth.type===`Basic`){let[r,i]=await Promise.all([n(e.auth.username),n(e.auth.password)]);if(!r||!i)return t;t.authorization=`Basic ${btoa(`${r}:${i}`)}`}else if(e.auth.type===`Custom`){let[r,i]=await Promise.all([n(e.auth.prefix),n(e.auth.value)]);if(!i)return t;t.authorization=`${r??``} ${i}`}}return t},Pt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function Ft(e){let t=e.headers.get(`content-type`),n=new Set([`image/svg`,`application/xml`,`application/xhtml`,`application/html`]);if(!t)return`json`;let r=t.split(`;`).shift()||``;return Pt.test(r)?`json`:n.has(r)||r.startsWith(`text/`)?`text`:`blob`}function It(e){try{return JSON.parse(e),!0}catch{return!1}}function Lt(e){if(e===void 0)return!1;let t=typeof e;return t===`string`||t===`number`||t===`boolean`||t===null?!0:t===`object`?Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name===`Object`||typeof e.toJSON==`function`:!1}function Rt(e){try{return JSON.parse(e)}catch{return e}}function zt(e){return typeof e==`function`}function Bt(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<`u`&&zt(globalThis.fetch))return globalThis.fetch;if(typeof window<`u`&&zt(window.fetch))return window.fetch;throw Error(`No fetch implementation found`)}function Vt(...e){let t={};for(let n of e)if(n){if(n instanceof Headers)n.forEach((e,n)=>{t[n]=e});else{let e=Array.isArray(n)?n:Object.entries(n);for(let[n,r]of e)r!=null&&(t[n]=r)}}return t}async function Ht(e){let t=new Headers(Vt(e?.headers,await Nt(e)));if(!t.has(`content-type`)){let n=Ut(e?.body);n&&t.set(`content-type`,n)}return t}function Ut(e){return Lt(e)?`application/json`:null}function Wt(e){let t=e.get(`content-type`);return t?t.split(`;`)[0].trim().toLowerCase():null}function Gt(e,t){let{body:n}=e;return n?!Lt(n)||typeof n==`string`?n:Wt(t)===`application/x-www-form-urlencoded`?new URLSearchParams(n).toString():JSON.stringify(n):null}function Kt(e,t){if(t?.method)return t.method.toUpperCase();let{method:n}=Ot(e);return n?n.toUpperCase():t?.body?`POST`:`GET`}function qt(e,t){let n;return!e?.signal&&e?.timeout&&(n=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:n,clearTimeout:()=>{n&&clearTimeout(n)}}}var Jt=class e extends Error{constructor(t,n){super(n||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function Yt(e,t){let n=await e[`~standard`].validate(t);if(n.issues)throw new Jt(n.issues);return n.value}function Xt(e){"@babel/helpers - typeof";return Xt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Xt(e)}function Zt(e,t){if(Xt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Xt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Qt(e){var t=Zt(e,`string`);return Xt(t)==`symbol`?t:t+``}function $t(e,t,n){return(t=Qt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function en(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function v(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?en(Object(n),!0).forEach(function(t){$t(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):en(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var tn=async(e,t)=>{var n;let{hooks:r,url:i,options:a}=await Ct(e,t),o=Bt(a),s=new AbortController,c=a.signal??s.signal,l=Mt(i,a),u=await Ht(a),d=Gt(a,u),f=Kt(i,a),p=v(v({},a),{},{url:l,headers:u,body:d,method:f,signal:c});for(let e of r.onRequest)if(e){let t=await e(p);typeof t==`object`&&t&&Object.assign(p,t)}(`pipeTo`in p&&typeof p.pipeTo==`function`||typeof(t==null||(n=t.body)==null?void 0:n.pipe)==`function`)&&(`duplex`in p||(p.duplex=`half`));let{clearTimeout:m}=qt(a,s),h=await o(p.url,p);m();let ee={response:h,request:p};for(let e of r.onResponse)if(e){var te;let n=await e(v(v({},ee),{},{response:t!=null&&(te=t.hookOptions)!=null&&te.cloneResponse?h.clone():h}));n instanceof Response?h=n:typeof n==`object`&&n&&(h=n.response)}if(h.ok){if(p.method===`HEAD`)return{data:``,error:null};let e=Ft(h),n={data:null,response:h,request:p};if(e===`json`||e===`text`){let e=await h.text();n.data=await(p.jsonParser??Rt)(e)}else n.data=await h[e]();p?.output&&p.output&&!p.disableValidation&&(n.data=await Yt(p.output,n.data));for(let e of r.onSuccess)if(e){var ne;await e(v(v({},n),{},{response:t!=null&&(ne=t.hookOptions)!=null&&ne.cloneResponse?h.clone():h}))}return t?.throw?n.data:{data:n.data,error:null}}let re=t?.jsonParser??Rt,ie=await h.text(),ae=It(ie),oe=ae?await re(ie):null,se={response:h,responseText:ie,request:p,error:v(v({},oe),{},{status:h.status,statusText:h.statusText})};for(let e of r.onError)if(e){var ce;await e(v(v({},se),{},{response:t!=null&&(ce=t.hookOptions)!=null&&ce.cloneResponse?h.clone():h}))}if(t?.retry){let n=Et(t.retry),i=t.retryAttempt??0;if(await n.shouldAttemptRetry(i,h)){for(let e of r.onRetry)e&&await e(ee);let a=n.getDelay(i);return await new Promise(e=>setTimeout(e,a)),await tn(e,v(v({},t),{},{retryAttempt:i+1}))}}if(t?.throw)throw new St(h.status,h.statusText,ae?oe:ie);return{data:null,error:v(v({},oe),{},{status:h.status,statusText:h.statusText})}},nn=e=>({id:`apply-schema`,name:`Apply Schema`,version:`1.0.0`,async init(t,n){var r;let i=v(v({},n),e.query!==void 0&&{query:v(v({},e.query),n?.query)}),a=((r=e.plugins)==null||(r=r.find(e=>e.schema?.config?t.startsWith(e.schema.config.baseURL||``)||t.startsWith(e.schema.config.prefix||``):!1))==null?void 0:r.schema)||e.schema;if(a){let r=t;a.config?.prefix&&r.startsWith(a.config.prefix)&&(r=r.replace(a.config.prefix,``),a.config.baseURL&&(t=t.replace(a.config.prefix,a.config.baseURL))),a.config?.baseURL&&r.startsWith(a.config.baseURL)&&(r=r.replace(a.config.baseURL,``)),r.startsWith(`/`)&&r.charAt(1)===`@`&&(r=r.substring(1));let o=a.schema[r];if(o){let{method:a,path:s}=Ot(r);a&&(t=t.slice(0,t.length-r.length)+s);let c=n?.headers;if(o.headers&&!n?.disableValidation){let e={};if(n?.headers){if(n.headers instanceof Headers)n.headers.forEach((t,n)=>{e[n.toLowerCase()]=t});else if(typeof n.headers==`object`)for(let[t,r]of Object.entries(n.headers))r!=null&&(e[t.toLowerCase()]=r)}let t=await Yt(o.headers,e),r={};for(let[e,n]of Object.entries(t))r[e.toLowerCase()]=n;c=r}let l=o.method??a;if(i=v(v(v(v({},i),l!==void 0&&{method:l}),o.output!==void 0&&{output:o.output}),c!==void 0&&{headers:c}),!n?.disableValidation){if(o.query&&(i.query=await Yt(o.query,n?.query),i.query!==null&&typeof i.query==`object`)){let t=v({},e.query);for(let e of Object.keys(t))n?.query&&Object.prototype.hasOwnProperty.call(n.query,e)&&(t[e]=n.query[e]);i.query=v(v({},t),i.query)}i=v(v({},i),{},{body:o.input?await Yt(o.input,n?.body):n?.body,params:o.params?await Yt(o.params,n?.params):n?.params})}return{url:t,options:i}}}return v({url:t},(n!==void 0||e.query!==void 0)&&{options:i})}}),rn=e=>{async function t(t,n){let r=v(v(v({},e),n),{},{headers:Vt(e?.headers,n?.headers),plugins:[...e?.plugins||[],nn(e||{}),...n?.plugins||[]]});if(e?.catchAllError)try{return await tn(t,r)}catch(e){return{data:null,error:{status:500,statusText:`Fetch Error`,message:`Fetch related error. Captured by catchAllError option. See error property for more details.`,error:e}}}return await tn(t,r)}return t},an=e=>{if(typeof process>`u`)return;let t=e??`/api/auth`;if({}.NEXT_PUBLIC_AUTH_URL)return{}.NEXT_PUBLIC_AUTH_URL;if(typeof window>`u`){if({}.NEXTAUTH_URL)try{return{}.NEXTAUTH_URL}catch{}if({}.VERCEL_URL)try{let e={}.VERCEL_URL.startsWith(`http`)?``:`https://`;return`${new URL(`${e}${{}.VERCEL_URL}`).origin}${t}`}catch{}}},on=e=>e===`/sign-out`||e===`/update-user`||e===`/update-session`||e===`/sign-up/email`||e===`/sign-in/email`||e===`/delete-user`||e===`/verify-email`||e===`/revoke-sessions`||e===`/revoke-session`||e===`/revoke-other-sessions`||e===`/change-email`||e===`/change-password`,sn=(e,t)=>{let n=`credentials`in Request.prototype,r=ot(e?.baseURL,e?.basePath,void 0,t)??an(e?.basePath)??`/api/auth`,i=e?.plugins?.flatMap(e=>e.fetchPlugins).filter(e=>e!==void 0)||[],a={id:`lifecycle-hooks`,name:`lifecycle-hooks`,hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:o,onError:s,onRequest:c,onResponse:l,...u}=e?.fetchOptions||{},d=rn({baseURL:r,...n?{credentials:`include`}:{},method:`GET`,jsonParser(e){return e?ye(e,{strict:!1}):null},customFetchImpl:fetch,...u,plugins:[a,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[ut],...i]}),{$sessionSignal:f,session:p,broadcastSessionUpdate:m}=_t(d,e),h=!1,ee=e=>{h||e===null||(h=!0,pt(p,e))},te=e?.plugins||[],ne={},re={$sessionSignal:f,session:p},ie={"/sign-out":`POST`,"/revoke-sessions":`POST`,"/revoke-other-sessions":`POST`,"/delete-user":`POST`},ae=[{signal:`$sessionSignal`,matcher:on,callback(e){e===`/sign-out`?m(`signout`):(e===`/update-user`||e===`/update-session`)&&m(`updateUser`)}}];for(let e of te)e.getAtoms&&Object.assign(re,e.getAtoms?.(d)),e.pathMethods&&Object.assign(ie,e.pathMethods),e.atomListeners&&ae.push(...e.atomListeners);let oe={notify:e=>{re[e].set(!re[e].get())},listen:(e,t)=>{re[e].subscribe(t)},atoms:re};for(let t of te)t.getActions&&(ne=xt(t.getActions?.(d,oe,e)??{},ne));return{get baseURL(){return r},pluginsActions:ne,pluginsAtoms:re,pluginPathMethods:ie,atomListeners:ae,hydrateSession:ee,$sessionSignal:f,$fetch:d,$store:oe}};function cn(e){return typeof e==`object`&&!!e&&`get`in e&&typeof e.get==`function`&&`lc`in e&&typeof e.lc==`number`}function ln(e){return e.charAt(0).toUpperCase()+e.slice(1)}var un=/[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu,dn=/['\u2019]/g;function fn(e){return e.replace(dn,``).match(un)??[]}function pn(e){return fn(e).map(e=>e.toLowerCase()).join(`-`)}function mn(e,t,n){let r=t[e],{fetchOptions:i,query:a,...o}=n||{};return r||(i?.method?i.method:o&&Object.keys(o).length>0?`POST`:`GET`)}function hn(e,t,n,r,i){function a(o=[]){return new Proxy(function(){},{get(t,n){if(typeof n!=`string`||n===`then`||n===`catch`||n===`finally`)return;let r=[...o,n],i=e;for(let e of r)if(i&&typeof i==`object`&&e in i)i=i[e];else{i=void 0;break}return typeof i==`function`||cn(i)?i:a(r)},apply:async(e,a,s)=>{let c=`/`+o.map(pn).join(`/`),l=s[0]||{},u=s[1]||{},{query:d,fetchOptions:f,...p}=l,m={...u,...f},h=mn(c,n,l);return await t(c,{...m,body:h===`GET`?void 0:{...p,...m?.body||{}},query:d||m?.query,method:h,async onSuccess(e){if(await m?.onSuccess?.(e),!i||m.disableSignal)return;let t=i.filter(e=>e.matcher(c));if(!t.length)return;let n=new Set;for(let e of t){let t=r[e.signal];if(!t)return;if(n.has(e.signal))continue;n.add(e.signal);let i=t.get();setTimeout(()=>{t.set(!i)},10),e.callback?.(c)}}})}})}return a()}function gn(e){let{pluginPathMethods:t,pluginsActions:n,pluginsAtoms:r,hydrateSession:i,$fetch:a,atomListeners:o,$store:s}=sn(e),c={};for(let[e,t]of Object.entries(r))c[`use${ln(e)}`]=t;return hn({...n,...c,hydrateSession:i,$fetch:a,$store:s},a,t,r,o)}var _n=`ba_param`;function vn(e){let t=e.getAll(_n);if(t.length)return new Set(t)}function yn(e){let t=new URLSearchParams(e);if(!t.has(`sig`))return;let n=vn(t);if(!n)return;let r=new URLSearchParams;for(let[e,i]of t.entries())(e===`sig`||e===_n||n.has(e))&&r.append(e,i);return r.toString()}var bn=`1.7.7`,xn=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;function Sn(e){if(typeof e==`string`&&xn.test(e)){let t=new Date(e);if(!isNaN(t.getTime()))return t}return e}function Cn(e){if(e==null)return e;if(typeof e==`string`)return Sn(e);if(e instanceof Date)return e;if(Array.isArray(e))return e.map(Cn);if(typeof e==`object`){let t={};for(let n of Object.keys(e))t[n]=Cn(e[n]);return t}return e}function wn(e){try{return typeof e==`string`?JSON.parse(e,(e,t)=>Sn(t)):e==null?null:Cn(e)}catch(e){return Je.error(`Error parsing JSON`,{error:e}),null}}var Tn=()=>({id:`oauth-provider-client`,version:bn,fetchPlugins:[{id:`oauth-provider-signin`,name:`oauth-provider-signin`,description:`Adds the current page query to oauth requests`,hooks:{async onRequest(e){let t=e.headers,n=typeof e.body==`string`?t.get(`content-type`)===`application/x-www-form-urlencoded`?Object.fromEntries(new URLSearchParams(e.body)):wn(e.body??`{}`):e.body;n?.oauth_query||typeof window<`u`&&window?.location?.search&&e.method!==`GET`&&e.method!==`DELETE`&&(e.body=JSON.stringify({...n,oauth_query:yn(window.location.search)}))}}}],$InferServerPlugin:{}}),y=(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}}},En={pipe(){return y(this,arguments)}},Dn=function(){function e(){}return e.prototype=En,e}(),b=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)}}}},x=e=>e,On=e=>()=>e,kn=On(!0),An=On(!1),jn=On(void 0),Mn=jn;function Nn(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 Pn(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 Fn=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},In=new WeakSet,Ln=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),Rn=0,zn=()=>{Rn++};function Bn(e){return typeof e==`string`}function Vn(e){return typeof e==`number`}function Hn(e){return typeof e==`boolean`}function Un(e){return typeof e==`symbol`}function Wn(e){return Bn(e)||Vn(e)||Un(e)}function Gn(e){return typeof e==`function`}function Kn(e){return e!=null}function qn(e){return!1}function Jn(e){return!0}function Yn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Xn(e){return typeof e==`object`&&!!e||Gn(e)}var S=b(2,(e,t)=>Xn(e)&&t in e),Zn=b(2,(e,t)=>S(e,`_tag`)&&e._tag===t);function Qn(e){return e instanceof Error}function $n(e){return S(e,Symbol.iterator)||Bn(e)}var C=`~effect/Hash`,w=e=>{switch(typeof e){case`number`:return ar(e);case`bigint`:return or(e.toString(10));case`string`:return or(e);case`function`:case`object`:if(e===null)break;if(e instanceof Date)return Number.isNaN(e.getTime())?or(`Invalid Date`):or(e.toISOString());if(e instanceof RegExp)return or(e.toString());{if(In.has(e))return er(e);let t=hr.get(e);if(t!==void 0)return t;if(gr.has(e))return zn(),or(`[Circular]`);gr.add(e);let n=Rn,r;try{r=`~effect/Hash`in e?e[C]():typeof e==`function`?er(e):e instanceof DataView?ur(Ln(e)):Array.isArray(e)||ArrayBuffer.isView(e)?ur(e):e instanceof Map?dr(e):e instanceof Set?pr(e):cr(e)}finally{gr.delete(e)}return n===Rn&&hr.set(e,r),r}}return rr(tr(or(String(e))))},er=e=>(mr.has(e)||mr.set(e,rr(Math.random()*4294967296|0)),mr.get(e)),tr=e=>(e^=e>>>16,e=Math.imul(e,2246822507),e^=e>>>13,e=Math.imul(e,3266489909),e^e>>>16),nr=b(2,(e,t)=>tr(Math.imul(e,2654435761)+Math.imul(t,2246822507))),rr=e=>e&3221225471|e>>>1&1073741824,ir=new DataView(new ArrayBuffer(8)),ar=e=>{let t=e|0;return t===e?rr(t):(ir.setFloat64(0,e===e?e:NaN),rr(nr(ir.getInt32(0),ir.getInt32(4))))},or=e=>{let t=5381,n=e.length;for(;n;)t=t*33^e.charCodeAt(--n);return rr(t)},sr=(e,t)=>{let n=12289;for(let r of t)n^=nr(w(r),w(e[r]));return rr(n)},cr=e=>sr(e,Fn(e)),lr=(e,t)=>n=>{let r=e;for(let e of n)r^=t(e);return rr(r)},ur=e=>{let t=6151;for(let n of e)t=nr(t,w(n));return rr(t)},dr=lr(or(`Map`),([e,t])=>nr(w(e),w(t))),fr=or(`Set`),pr=lr(fr,e=>nr(fr,w(e))),mr=new WeakMap,hr=new WeakMap,gr=new WeakSet,T=`~effect/Equal`;function _r(){return arguments.length===1?e=>vr(e,arguments[0]):vr(arguments[0],arguments[1])}function vr(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`||In.has(e)||In.has(t)?!1:yr(e,t):!1}function yr(e,t){let n=xr.length;for(let r=n;r-->0;)if(xr[r]===e&&Sr[r]===t)return!0;if(n)return br(e,t);let r=Cr.get(e);r||Cr.set(e,r=new WeakMap);let i=r.get(t);return i===void 0&&r.set(t,i=br(e,t)),i}function br(e,t){xr.push(e),Sr.push(t);try{return wr(e,t)}finally{xr.pop(),Sr.pop()}}var xr=[],Sr=[],Cr=new WeakMap;function wr(e,t){if(w(e)!==w(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=jr(e);if(n!==jr(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:Tr(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?Er(Ln(e),Ln(t)):Er(e,t)}return e instanceof Map?!(t instanceof Map)||e.size!==t.size?!1:Or(e,t,kr,Ar):e instanceof Set?!(t instanceof Set)||e.size!==t.size?!1:Or(e,t,w,vr):Dr(e,t)}function Tr(e,t){for(let n=0;n<e.length;n++)if(!vr(e[n],t[n]))return!1;return!0}function Er(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 Dr(e,t){let n=Fn(e),r=Fn(t);if(n.size!==r.size)return!1;for(let i of n)if(!r.has(i)||!vr(e[i],t[i]))return!1;return!0}function Or(e,t,n,r){let i=new Map,a=0;for(let e of t){let t=n(e),r=i.get(t);r?r.push(e):i.set(t,[e]),a++}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(),a--;continue outer}}return!1}return a===0}var kr=e=>w(e[0]),Ar=(e,t)=>vr(e[0],t[0])&&vr(e[1],t[1]),jr=e=>S(e,T),Mr=Symbol.for(`~effect/Redactable`),Nr=e=>S(e,Mr);function Pr(e){return Nr(e)?Fr(e):e}function Fr(e){return e[Mr](globalThis[`~effect/Fiber/currentFiber`]?.context??Rr)}var Ir=`~effect/Fiber/currentFiber`,Lr=new Map,Rr={"~effect/Context":{},base:Lr,depth:0,mapUnsafe:Lr,pipe(){return y(this,arguments)}};function E(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 zr;r.add(e);let l;if(Mr in e)l=c(Fr(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(`,
4
- `+a(n+1))}\n${a(n)}]`;else if(e instanceof Date)l=Hr(e);else if(!t?.ignoreToString&&S(e,`toString`)&&typeof e.toString==`function`&&e.toString!==Object.prototype.toString&&e.toString!==Array.prototype.toString){let t=Ur(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=>`${Br(t)}:${c(Wr(e,t),n)}`).join(`,`)}}`;l=o(e,r)}else{let r=`{\n${t.map(t=>`${a(n+1)}${Br(t)}: ${c(Wr(e,t),n+1)}`).join(`,
5
- `)}\n${a(n)}}`;l=o(e,r)}}return r.delete(e),l}return String(e)}return c(e,0)}var zr=`[Circular]`;function Br(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Vr(e){return e.map(e=>`[${Br(e)}]`).join(``)}function Hr(e){try{return e.toISOString()}catch{return`Invalid Date`}}function Ur(e){try{let t=e.toString();return typeof t==`string`?t:String(t)}catch{return`[toString threw]`}}function Wr(e,t){try{return e[t]}catch{return`[property access threw]`}}function Gr(e,t){let n=[];return JSON.stringify(e,function(e,t){let r=Object.getOwnPropertyDescriptor(this,e)?.value,i=S(r,Mr)?Pr(r):Pr(t);if(typeof i==`bigint`)return E(i);if(typeof i!=`object`||!i)return i;let a=i instanceof Error&&!S(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;if(n.push(i),a!==i&&n.push(a),!Kr(a)||qr(a))return a;let o=new Proxy(a,{get(e,t){let n=Reflect.get(e,t,e);return Object.getOwnPropertyDescriptor(e,t)?.get===void 0?n:Pr(n)}});return n.push(o),o},t?.space)??`null`}function Kr(e){for(let t of Object.getOwnPropertyNames(e))if(Object.getOwnPropertyDescriptor(e,t)?.get!==void 0)return!0;return!1}function qr(e){for(let t of[Number.prototype.valueOf,Boolean.prototype.valueOf,String.prototype.valueOf])try{return Reflect.apply(t,e,[]),!0}catch{}return!1}var Jr=Symbol.for(`nodejs.util.inspect.custom`),Yr=e=>{try{return e=Pr(e),S(e,`toJSON`)&&Gn(e.toJSON)&&e.toJSON.length===0?e.toJSON():Array.isArray(e)?e.map(Yr):e}catch{return`[toJSON threw]`}},Xr={toJSON(){return Yr(this)},[Jr](){return this.toJSON()},toString(){return E(this.toJSON())}},Zr=class{[Jr](){return this.toJSON()}toString(){return E(this.toJSON())}},Qr=(()=>{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return e===void 0?Object.isExtensible(Error):Object.hasOwn(e,`writable`)?e.writable===!0:e.set!==void 0})(),$r=()=>Error.stackTraceLimit,ei=e=>{Qr&&(Error.stackTraceLimit=e)},ti=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})}},ni=(()=>{let e=`~effect/Utils/internal`,t={[e]:e=>e()},n={[e]:e=>{try{return e()}finally{}}};return $r()!==0&&t[e](()=>Error().stack)?.includes(e)===!0?t[e]:n[e]})();function ri(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[t]=n}function ii(e,t){for(let n of Reflect.ownKeys(t))Object.prototype.propertyIsEnumerable.call(t,n)&&ri(e,n,t[n])}var ai=`~effect/Effect`,oi=`~effect/Exit`,si={_A:x,_E:x,_R:x},ci=`${ai}/identifier`,D=`${ai}/args`,O=`${ai}/evaluate`,k=`${ai}/successCont`,li=`${ai}/failureCont`,ui=`${ai}/ensureCont`,di=Symbol.for(`effect/Effect/Yield`),fi={pipe(){return y(this,arguments)},toJSON(){return{...this}},toString(){return E(this.toJSON(),{ignoreToString:!0,space:2})},[Jr](){return this.toJSON()}},pi={[ai]:si,...fi,[Symbol.iterator](){return new ti(this)},toJSON(){return{_id:`Effect`,op:this[ci],...D in this?{args:this[D]}:void 0}}},mi=e=>S(e,ai),hi=e=>S(e,oi),gi=`~effect/Cause`,_i=`~effect/Cause/Reason`,vi=e=>S(e,gi),yi=e=>S(e,_i),bi=class{constructor(e){this[gi]=gi,this.reasons=e}pipe(){return y(this,arguments)}toJSON(){return{_id:`Cause`,failures:this.reasons.map(e=>e.toJSON())}}toString(){return`Cause(${E(this.reasons)})`}[Jr](){return this.toJSON()}[T](e){return vi(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>_r(t,e.reasons[n]))}[C](){return ur(this.reasons)}},xi=new WeakMap,Si=class{[_i];annotations;_tag;constructor(e,t,n){if(this[_i]=_i,this._tag=e,t!==Ci&&typeof n==`object`&&n&&t.size>0){let e=xi.get(n);e&&(t=new Map([...e,...t])),xi.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 y(this,arguments)}toString(){return E(this)}[Jr](){return this.toString()}},Ci=new Map,wi=class extends Si{constructor(e,t=Ci){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${E(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[T](e){return Mi(e)&&_r(this.error,e.error)&&_r(this.annotations,e.annotations)}[C](){return nr(or(this._tag))(nr(w(this.error))(w(this.annotations)))}},Ti=e=>new bi(e),Ei=(e,t)=>{let n=new Map,r=[];for(let i of e.concat(t)){let e=w(i),t=n.get(e);if(t===void 0)n.set(e,[i]);else if(t.some(e=>_r(e,i)))continue;else t.push(i);r.push(i)}return r},Di=b(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new bi(Ei(e.reasons,t.reasons));return _r(e,n)?e:n}),Oi=e=>new bi([new wi(e)]),ki=class extends Si{constructor(e,t=Ci){super(`Die`,t,e),this.defect=e}toString(){return`Die(${E(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[T](e){return Ni(e)&&_r(this.defect,e.defect)&&_r(this.annotations,e.annotations)}[C](){return nr(or(this._tag))(nr(w(this.defect))(w(this.annotations)))}},Ai=e=>new bi([new ki(e)]),ji=b(e=>vi(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new bi(e.reasons.map(e=>e.annotate(t,n)))),Mi=e=>e._tag===`Fail`,Ni=e=>e._tag===`Die`,Pi=e=>e._tag===`Interrupt`;function Fi(e){return Wi(`Effect.evaluate: Not implemented`)}var Ii=e=>({...pi,[ci]:e.op,[O]:e[O]??Fi,[k]:e[k],[li]:e[li],[ui]:e[ui]}),Li=e=>{let t=Ii(e),n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},Ri=e=>{let t={[oi]:oi,_tag:e.op,get[e.prop](){return this[D]},...Ii(e),toString(){return`${e.op}(${E(this[D])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[D]}},[T](e){return hi(e)&&e._tag===this._tag&&_r(this[D],e[D])},[C](){return nr(or(e.op),w(this[D]))}},n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},zi=Ri({op:`Success`,prop:`value`,[O](e){let t=e.getCont(k);return t?t[k](this[D],e,this):e.yieldWith(this)}}),Bi={key:`effect/Cause/StackTrace`},Vi={key:`effect/Cause/InterruptorStackTrace`},Hi=Ri({op:`Failure`,prop:`cause`,[O](e){let t=this[D],n=!1;e.cache.stackFrame&&(t=ji(t,{mapUnsafe:new Map([[Bi.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(li),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=ci in r,r=e.getCont(li);a&&(t=Ti(t.reasons.filter(e=>e._tag!==`Fail`))),t=Di(t,i),n=!0}return r?r[li](t,e,n?void 0:this):e.yieldWith(n?Hi(t):this)}}),Ui=e=>Hi(Oi(e)),Wi=e=>Hi(Ai(e)),A=Li({op:`WithFiber`,[O](e){return this[D](e)}}),Gi=function(){class e extends globalThis.Error{}let t=Ii({op:`YieldableError`,[O](){return Ui(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),Ki=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Gi{constructor(t){super(t?.message,t?.cause?{cause:t.cause}:void 0),t&&(ii(this,t),Object.defineProperty(this,e,{value:t,enumerable:!1}))}toJSON(){return{...this[e],...this}}}}(),qi=e=>{class t extends Ki{_tag=e}return t.prototype.name=e,t},Ji=`~effect/Cause/Done`,Yi=e=>S(e,Ji),Xi={[Ji]:Ji,_tag:`Done`,value:void 0},Zi=e=>e===void 0?Xi:{[Ji]:Ji,_tag:`Done`,value:e},Qi=Ui(Xi),$i=e=>e===void 0?Qi:Ui(Zi(e)),ea=e=>Ii({op:e.label,[O]:e.evaluate}),ta=e=>(t,n)=>t===n||e(t,n),na=(e,t)=>e===t,ra=()=>na;function ia(e){return ta((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 aa(e){return ta((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 oa=`~effect/Option`,sa={[oa]:{_A:e=>e},...fi,[Symbol.iterator](){return new ti(this)}},ca=Object.defineProperty(Object.assign(Object.create(sa),{_tag:`Some`,_op:`Some`,[T](e){return da(e)&&pa(e)&&_r(this.value,e.value)},[C](){return nr(w(this._tag))(w(this.value))},toString(){return`some(${E(this.value)})`},toJSON(){return{_id:`Option`,_tag:this._tag,value:Yr(this.value)}}}),"valueOrUndefined",{get(){return this.value}}),la=w(`None`),ua=Object.assign(Object.create(sa),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[T](e){return da(e)&&fa(e)},[C](){return la},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),da=e=>S(e,oa),fa=e=>e._tag===`None`,pa=e=>e._tag===`Some`,ma=Object.create(ua),ha=function(e){this.value=e};ha.prototype=ca;var ga=e=>new ha(e),_a=`~effect/Result`,va={[_a]:{_A:e=>e,_E:e=>e},...fi,[Symbol.iterator](){return new ti(this)}},ya=Object.assign(Object.create(va),{_tag:`Success`,_op:`Success`,[T](e){return xa(e)&&Ca(e)&&_r(this.success,e.success)},[C](){return nr(w(this._tag))(w(this.success))},toString(){return`success(${E(this.success)})`},toJSON(){return{_id:`Result`,_tag:this._tag,value:Yr(this.success)}}}),ba=Object.assign(Object.create(va),{_tag:`Failure`,_op:`Failure`,[T](e){return xa(e)&&Sa(e)&&_r(this.failure,e.failure)},[C](){return nr(w(this._tag))(w(this.failure))},toString(){return`failure(${E(this.failure)})`},toJSON(){return{_id:`Result`,_tag:this._tag,failure:Yr(this.failure)}}}),xa=e=>S(e,_a),Sa=e=>e._tag===`Failure`,Ca=e=>e._tag===`Success`,wa=function(e){this.failure=e};wa.prototype=ba;var Ta=e=>new wa(e),Ea=function(e){this.success=e};Ea.prototype=ya;var Da=e=>new Ea(e);function Oa(e){return(t,n)=>t===n?0:e(t,n)}var ka=Oa((e,t)=>e<t?-1:1),Aa=Oa((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),ja=b(2,(e,t)=>Oa((n,r)=>e(t(n),t(r)))),Ma=e=>b(2,(t,n)=>e(t,n)===-1),Na=e=>b(2,(t,n)=>e(t,n)===1),Pa=e=>b(2,(t,n)=>e(t,n)!==1),Fa=e=>b(2,(t,n)=>e(t,n)!==-1),Ia=()=>ma,La=ga,Ra=fa,za=pa,Ba=b(2,(e,{onNone:t,onSome:n})=>Ra(e)?t():n(e.value)),Va=b(2,(e,t)=>Ra(e)?t():e.value),Ha=e=>e==null?Ia():La(e),Ua=Va(jn),Wa=e=>(...t)=>{try{return La(e(...t))}catch{return Ia()}},Ga=`~effect/Context/Service`,j=function(){function e(){}let t=e;Object.setPrototypeOf(t,Ka);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Ja]=Ja,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&qa.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},Ka={[Ga]:Ga,...ea({label:`Service`,evaluate(e){return zi(yo(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return po(this,e)},use(e){return A(t=>e(yo(t.context,this)))},useSync(e){return A(t=>zi(e(yo(t.context,this))))}},qa=new Set,Ja=`~effect/Context/Reference`,Ya=`~effect/Context`,Xa=8,Za=8,Qa=(e,t,n,r)=>{let i=Object.create(ao);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},$a=(e,t)=>{t&&($a(e,t.parent),e.set(t.key,t.value))},eo=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return $a(t,e.overlay),e._flat=t},to=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),io(n)},no=Symbol(),ro=(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)?no:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Za&&(n.base=eo(n),n.overlay=void 0,n.depth=0),r)},io=e=>Qa(void 0,e,void 0,0),ao={get mapUnsafe(){return eo(this)},...fi,[Ya]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[T](e){if(!so(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)||!_r(r,n.get(e)))return!1;return!0},[C](){return ar(this.mapUnsafe.size)}},oo=(e,t)=>e.cacheRoot===t.cacheRoot,so=e=>S(e,Ya),co=e=>S(e,Ga),lo=e=>!!e[Ja],uo=()=>fo,fo=io(new Map),po=(e,t)=>io(new Map([[e.key,t]])),mo=b(3,(e,t,n)=>ho(e,t.key,n)),ho=(e,t,n)=>{let r=e,i=qa.has(t)?void 0:r.cacheRoot;if(r.depth>=Xa){let e=new Map(r.mapUnsafe);return e.set(t,n),Qa(i,e,void 0,0)}return Qa(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},go=b(2,(e,t)=>_o(e,t.key)),_o=(e,t)=>{let n=ro(e,t);return n===no?void 0:n},vo=b(2,(e,t)=>{let n=ro(e,t.key);if(n===no){if(lo(t))return xo(t);throw So(t)}return n}),yo=vo,bo=`~effect/Context/defaultValue`,xo=e=>bo in e?e[bo]:e[bo]=e.defaultValue(),So=e=>{let t=Error(`Service not found${e.key?`: ${String(e.key)}`:``}`);if(t.stack){let e=t.stack.split(`
6
- `);e.splice(1,3),t.stack=e.join(`
7
- `)}return t},Co=b(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:to(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),wo=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return io(t)},M=j,To=e=>e.length>0,Eo=Da,Do=Ta,Oo=e=>{if(Gn(e))try{return Eo(e())}catch(e){return Do(e)}try{return Eo(e.try())}catch(t){return Do(e.catch(t))}},ko=Sa,Ao=Ca,jo=b(2,(e,{onFailure:t,onSuccess:n})=>ko(e)?t(e.failure):n(e.success)),Mo=ia,No=b(2,(e,t)=>Object.hasOwn(e,t)),Po=b(2,(e,t)=>{let n={...e};for(let r of Fo(e))ri(n,r,t(e[r],r));return n}),Fo=e=>Object.keys(e),Io=e=>b(2,(t,n)=>{for(let r of Fo(t))if(!No(n,r)||!e(t[r],n[r]))return!1;return!0}),Lo=e=>{let t=Io(e);return(e,n)=>t(e,n)&&t(n,e)},Ro=globalThis.Array,zo=e=>Ro.isArray(e)?e:Ro.from(e),Bo=e=>Ro.isArray(e)?e:[e],Vo=b(2,(e,t)=>[...e,t]),Ho=b(2,(e,t)=>zo(e).concat(zo(t)));Ro.isArray;var Uo=To,Wo=To,Go=(e,t)=>{let n=w(t),r=e.get(n);if(r===void 0)return e.set(n,[t]),!0;for(let e of r)if(_r(e,t))return!1;return r.push(t),!0},Ko=()=>[],qo=e=>[e],Jo=b(2,(e,t)=>e.map(t)),Yo=aa,Xo=e=>{let t=zo(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)Go(n,e)&&r.push(e);return r},Zo=`~effect/Duration`,Qo=BigInt(0),$o=BigInt(1),es=BigInt(2),ts=BigInt(10),ns=BigInt(1e3),rs=e=>BigInt(e<0?Math.ceil(e-.5):Math.floor(e+.5)),is=e=>rs(e*1e6),as=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=ts**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t,s=o/a+(o%a*es>=a?$o:Qo);return r?-s:s},os=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,ss=e=>{switch(typeof e){case`number`:return ys(e);case`bigint`:return vs(e);case`string`:{if(e===`Infinity`)return gs;if(e===`-Infinity`)return _s;let t=os.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return vs(as(r,$o));if(i===`micro`||i===`micros`)return vs(as(r,ns));let a=Number(r);switch(i){case`milli`:case`millis`:return ys(a);case`second`:case`seconds`:return bs(a);case`minute`:case`minutes`:return xs(a);case`hour`:case`hours`:return Ss(a);case`day`:case`days`:return Cs(a);case`week`:case`weeks`:return ws(a)}break}case`object`:{if(e===null)break;if(Zo in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Vn)?cs(e):Number.isNaN(e[0])||Number.isNaN(e[1])?hs:e[0]===-1/0||e[1]===-1/0?_s:e[0]===1/0||e[1]===1/0?gs:ps(rs(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?ps(n):ps(rs(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0)))}}return cs(e)},cs=e=>{throw Error(`Invalid Input: ${e}`)},ls={_tag:`Millis`,millis:0},us={_tag:`Infinity`},ds={_tag:`NegativeInfinity`},fs={[Zo]:Zo,[C](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?w(rs(e)):ar(this.value.millis)}case`Nanos`:return w(this.value.nanos);default:return cr(this.value)}},[T](e){return ms(e)&&As(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`}}},[Jr](){return this.toJSON()},pipe(){return y(this,arguments)}},ps=e=>{let t=Object.create(fs);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?ls:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:is(e)}:e>0?us:ds:e===Qo?ls:{_tag:`Nanos`,nanos:e},t},ms=e=>S(e,Zo),hs=ps(0),gs=ps(1/0),_s=ps(-1/0),vs=e=>ps(e),ys=e=>ps(e),bs=e=>ps(e*1e3),xs=e=>ps(e*6e4),Ss=e=>ps(e*36e5),Cs=e=>ps(e*864e5),ws=e=>ps(e*6048e5),Ts=e=>Ds(ss(e),{onMillis:x,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),Es=e=>{let t=ss(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 is(t.value.millis)}},Ds=b(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)()}}),Os=b(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(Es(e),t.value.nanos):n.onNanos(e.value.nanos,Es(t))),ks=(e,t)=>Os(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),As=b(2,(e,t)=>ks(e,t)),js=M(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new Is}),Ms=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Ns=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Ps=e=>{try{return Ns(e)}catch{return Ms(e)}},Fs=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}},Is=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Ms:Ps)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new Ls(this.setImmediate)}},Ls=class{tasks=new Fs;running=void 0;setImmediate;constructor(e=Ps){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()}},Rs=M(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),zs=M(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Bs=class extends Dn{constructor(e){super(),e&&ii(this,e)}},Vs=e=>class extends Bs{_tag=e},Hs=qi,Us=`~effect/encoding/EncodingError`,Ws=class extends Hs(`EncodingError`){[Us]=Us},Gs=e=>{switch(e){case 16:return Js();case 32:return Ys();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=qs();return t}}},N=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),Ks=()=>Math.random()*4294967296>>>0,qs=()=>{let e=Ks();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15])},Js=()=>{let e=Ks(),t=Ks();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15],N[t>>>28],N[t>>>24&15],N[t>>>20&15],N[t>>>16&15],N[t>>>12&15],N[t>>>8&15],N[t>>>4&15],N[t&15])},Ys=()=>{let e=Ks(),t=Ks(),n=Ks(),r=Ks();return String.fromCharCode(N[e>>>28],N[e>>>24&15],N[e>>>20&15],N[e>>>16&15],N[e>>>12&15],N[e>>>8&15],N[e>>>4&15],N[e&15],N[t>>>28],N[t>>>24&15],N[t>>>20&15],N[t>>>16&15],N[t>>>12&15],N[t>>>8&15],N[t>>>4&15],N[t&15],N[n>>>28],N[n>>>24&15],N[n>>>20&15],N[n>>>16&15],N[n>>>12&15],N[n>>>8&15],N[n>>>4&15],N[n&15],N[r>>>28],N[r>>>24&15],N[r>>>20&15],N[r>>>16&15],N[r>>>12&15],N[r>>>8&15],N[r>>>4&15],N[r&15])},Xs=`effect/Tracer/ParentSpan`,Zs=class extends j()(Xs,{fiberCached:!0}){},Qs=e=>e,$s=M(`effect/Tracer/DisablePropagation`,{defaultValue:An}),ec=M(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),tc=M(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),nc=`effect/Tracer`,rc=Qs({span:e=>new ic(e)}),ic=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??=Ua(this.parent)?.traceId??Gs(32)}get spanId(){return this._spanId??=Gs(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)}},ac=`effect/Metric/FiberRuntimeMetrics`,oc=M(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:jn}),sc=M(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:kn}),cc=M(`effect/References/TracerTimingEnabled`,{defaultValue:kn}),lc=M(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),uc=M(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),dc=M(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),fc=M(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),pc=e=>{if(e?.captureStackTrace===!1||e?.captureStackTrace!==void 0&&typeof e.captureStackTrace!=`boolean`)return e;let t=$r();if(t===0&&e?.captureStackTrace!==!0)return{...e,captureStackTrace:!1};ei(3);let n=Error();return ei(t),{...e,captureStackTrace:mc(()=>n.stack)}},mc=(e=>t=>{let n;return()=>{if(n!==void 0)return n;let r=t();if(!r)return;let i=r.split(`
8
- `);if(i[e]!==void 0)return n=i[e].trim(),n}})(3),hc=class extends Si{constructor(e,t=Ci){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[T](e){return Pi(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[C](){return nr(or(`${this._tag}:${this.fiberId}`))(er(this.annotations))}},gc=e=>new hc(e),_c=e=>new bi([new hc(e)]),vc=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return Eo(n.error)}return Do(e)},yc=e=>e.reasons.some(Pi),bc=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?Eo(t):Do(e)},xc=b(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Mi(e)?(n=!0,new wi(t(e.error),e.annotations)):e);return n?Ti(r):e}),Sc=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},Cc=`~effect/Fiber`,wc={_A:x,_E:x},Tc={id:0},Ec=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Dc=()=>Ec===void 0?void 0:new Ec(`effect/Fiber`),Oc=()=>globalThis[Ir],kc=class{constructor(e,t=!0){this.setContext(e),this.id=++Tc.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._asyncContext=void 0,this.cache.runtimeMetrics?.recordFiberStart(this.context)}get[Cc](){return wc}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return yo(this.context,e)}addObserver(e){return this._exit?(e(this._exit),Mn):(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=_c(e);this.cache.stackFrame&&(n=ji(n,po(Bi,this.cache.stackFrame))),t&&(n=ji(n,t)),this._interruptedCause=this._interruptedCause?Di(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Vc(this._interruptedCause)))}pollUnsafe(){return this._exit}evaluate(e){if(this._exit)return;if(this._asyncContext!==void 0){let t=this._asyncContext;return this._asyncContext=void 0,t.runInAsyncScope(this.evaluate,this,e)}if(this._yielded!==void 0){let e=this._yielded;this._yielded=void 0,e()}let t=this.runLoop(e);if(t===di){this._asyncContext=Dc();return}let n=Nc.interruptChildren&&Nc.interruptChildren(this);if(n!==void 0)return this.evaluate(Sl(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=uo()}runLoop(e){let t=globalThis[Ir];globalThis[Ir]=this;let n=this._running;this._running=!0;let r=!1,i=e;this.currentOpCount=0;try{for(;;)try{this._deferredInterrupt&&(this._deferredInterrupt=!1,i=Vc(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=Sl(Gc,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[O](this),i===di){let e=this._yielded;if(oi in e)return this._deferredInterrupt=!1,this._yielded=void 0,e;if(this._deferredInterrupt){this._yielded=void 0,e();continue}return di}}catch(e){if(!S(i,O))return Wi(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=Wi(e)}}finally{this._running=n,globalThis[Ir]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,jc;for(;;){let t=this._stack.pop();if(!t)return;let n=t[ui];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&Mc-1))return zi(e);let t=this.getCont(k);return t?t[k](e,this):this.yieldWith(zi(e))}yieldWith(e){return this._yielded=e,di}children(){return this._children??=new Set}pipe(){return y(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&oo(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Ac(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}},Ac=e=>{let t=_o(e,nc);return{scheduler:yo(e,js),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:yo(e,sc),span:_o(e,Xs),logLevel:yo(e,dc),minimumLogLevel:yo(e,fc),stackFrame:yo(e,oc),runtimeMetrics:_o(e,ac),maxOpsBeforeYield:yo(e,Rs),preventYield:yo(e,zs)}},jc={[k](e,t){return Vc(t._interruptedCause)},[li](e,t){return Vc(t._interruptedCause)}},Mc=32,Nc={interruptChildren:void 0},Pc=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Vi.key,e.cache.stackFrame),io(t)},Fc=e=>{let t=e;return t._exit?P(t._exit):el(n=>t._exit?n(P(t._exit)):Uc(e.addObserver(e=>n(P(e)))))},Ic=e=>el(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(P(r))}return a(),Uc(()=>i?.())}),Lc=e=>{let t=e;return t._exit?t._exit:el(n=>t._exit?n(t._exit):Uc(e.addObserver(n)))},Rc=e=>A(t=>zc(e,t.id)),zc=b(e=>S(e[0],Cc),(e,t,n)=>A(r=>{let i=Pc(r);return i=i&&n?Co(i,n):i??n,e.interruptUnsafe(t,i),xl(Fc(e))})),Bc=e=>A(t=>{let n=Pc(t),r=Ko();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return xl(Ic(r))}),P=zi,Vc=Hi,Hc=Ui,Uc=Li({op:`Sync`,[O](e){let t=this[D](),n=e.getCont(k);return n?n[k](t,e):e.yieldWith(zi(t))}}),F=Li({op:`Suspend`,[O](e){return this[D]()}}),Wc=jo({onFailure:Hc,onSuccess:P}),Gc=Li({op:`Yield`,[O](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(jl)},this[D]??0),e.yieldWith(()=>{t=!0})}})(0),Kc=e=>F(()=>Vc(e())),qc=e=>Wi(e),Jc=e=>F(()=>Hc(e())),I=P(void 0),Yc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Id(e,`An error occurred in Effect.try`):e.catch;return F(()=>{try{return P(t())}catch(e){return Hc(n(e))}})},Xc=e=>Qc(function(t,n){e(n).then(e=>t(P(e)),e=>t(qc(e)))},e.length!==0),Zc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new Id(e,`An error occurred in Effect.tryPromise`):e.catch;return Qc(function(e,r){let i=e=>F(()=>{try{return Hc(ni(()=>n(e)))}catch(e){return qc(e)}});try{t(r).then(t=>e(P(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},Qc=function(){let e=Ii({op:`Async`,[O](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($c(()=>(t=!0,r?.abort(),i??jl))),di):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),$c=Li({op:`AsyncFinalizer`,[ui](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Hu))},[li](e,t){return yc(e)?Sl(_u(Hi(e),this[D]()),()=>Vc(e)):Vc(e)}}),el=e=>Qc(e,e.length>=2),tl=el(Mn),nl=(...e)=>{if(e.length===1){let t=e[0];return F(()=>sl(t()))}let[t,n]=e;return F(()=>sl(n.call(t.self)))},rl=(e,...t)=>{let n=t.length===0?function(){return F(()=>sl(e.apply(this,arguments)))}:function(){let n=F(()=>sl(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return il(e.length,n)},il=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),al=(e,...t)=>il(e.length,t.length===0?function(){return ol(()=>e.apply(this,arguments))}:function(){let n=ol(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),ol=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return P(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 F(()=>n?(n=!1,Sl(r.value,e=>sl(t,e))):F(()=>sl(e())))}}}catch(e){return qc(e)}},sl=function(){let e=Ii({op:`Iterator`,[k](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return P(r.value);if(!L(r.value))return t._stack.push(this),r.value;if(r.value._tag===`Failure`)return r.value;e=r.value.value}},[O](e){return this[k](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)}}(),cl=b(2,(e,t)=>new dl(e,fl,P(t))),ll=function(e){return e._stack.push(this),this[D]},ul=Ii({op:`OnSuccess`,[O]:ll}),dl=function(e,t,n){this[D]=e,this[k]=t,this.payload=n};dl.prototype=ul;var fl=function(){return this.payload},pl=function(e,t){return t.succeedWith(this.payload)},ml=(()=>{let e=`~effect/Effect/stackProbe`;return{[e]:function(){return Error().stack}}[e]()?.includes(`[as `+e+`]`)===!0})(),hl=function(e,t){let n=this.payload;return t.succeedWith(ml?n(e):ni(()=>n(e)))},gl=function(e){let t=this.payload;return t(e)},_l=function(e){let t=this.payload;return new dl(t(e),pl,e)},vl=function(e){return new dl(this.payload,pl,e)},yl=b(2,(e,t)=>new dl(e,mi(t)?fl:gl,t)),bl=b(2,(e,t)=>new dl(e,mi(t)?vl:_l,t)),xl=e=>new dl(e,fl,jl),Sl=b(2,(e,t)=>new dl(e,gl,t)),L=e=>e[oi]!==void 0,Cl=b(2,(e,t)=>L(e)?e._tag===`Success`?t(e.value):e:Sl(e,t)),wl=b(2,(e,t)=>new dl(e,hl,t)),Tl=b(2,(e,t)=>L(e)?Ml(e,t):wl(e,t)),El=b(2,(e,t)=>L(e)?Nl(e,t):Ql(e,t)),Dl=b(2,(e,t)=>L(e)?Pl(e,t):$l(e,t)),Ol=e=>e._tag===`Success`,kl=e=>e._tag===`Failure`?Eo(e.cause):Do(e),Al=e=>e._tag===`Failure`&&yc(e.cause),jl=zi(void 0),Ml=b(2,(e,t)=>e._tag===`Success`?zi(t(e.value)):e),Nl=b(2,(e,t)=>{if(e._tag===`Success`)return e;let n=vc(e.cause);return ko(n)?e:Ui(t(n.success))}),Pl=b(2,(e,t)=>{if(e._tag===`Success`)return zi(t.onSuccess(e.value));let n=vc(e.cause);return ko(n)?e:Ui(t.onFailure(n.success))}),Fl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?jl:Hi(Ti(t))},Il=b(2,(e,t)=>A(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),ju(n,()=>{n.setContext(r)}),e)})),Ll=b(3,(e,t,n)=>Il(e,e=>{let r=vo(e,t),i=n(r);return r===i?e:mo(e,t,i)})),Rl=()=>zl,zl=A(e=>P(e.context)),Bl=e=>A(t=>e(t.context)),Vl=b(2,(e,t)=>L(e)?e:Il(e,Co(t))),Hl=function(){return arguments.length===1?b(2,(e,t)=>Ul(e,arguments[0],t)):b(3,(e,t,n)=>Ul(e,t,n)).apply(this,arguments)},Ul=(e,t,n)=>Il(e,mo(t,n)),Wl=b(e=>mi(e[0]),(e,t)=>Yu({while:kn,body:On(t?.disableYield?e:Sl(e,e=>Gc)),step:Mn})),Gl=b(2,(e,t)=>new ql(e,t.length===1?t:e=>t(e))),Kl=Ii({op:`OnFailure`,[O]:ll}),ql=function(e,t){this[D]=e,this[li]=t};ql.prototype=Kl;var Jl=b(3,(e,t,n)=>Gl(e,e=>{let r=t(e);return ko(r)?Vc(r.failure):n(r.success,e)})),Yl=b(2,(e,t)=>Jl(e,vc,e=>t(e))),Xl=b(e=>mi(e[0]),(e,t,n,r)=>Gl(e,e=>{let i=vc(e);return ko(i)?Vc(i.failure):t(i.success)?n(i.success):r?r(i.success):Vc(e)})),Zl=b(e=>mi(e[0]),(e,t,n,r)=>Xl(e,Array.isArray(t)?e=>S(e,`_tag`)&&t.includes(e._tag):Zn(t),n,r)),Ql=b(2,(e,t)=>Yl(e,e=>Jc(()=>t(e)))),$l=b(2,(e,t)=>ou(e,{onFailure:e=>Jc(()=>t.onFailure(e)),onSuccess:e=>Uc(()=>t.onSuccess(e))})),eu=e=>cu(e,{onFailure:Do,onSuccess:Eo}),tu=b(2,(e,t)=>new ru(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),nu=Ii({op:`OnSuccessAndFailure`,[O]:ll}),ru=function(e,t,n){this[D]=e,this[k]=t,this[li]=n};ru.prototype=nu;var iu=function(e,t){let n=this.payload;return t.succeedWith(ml?n.onSuccess(e):ni(()=>n.onSuccess(e)))},au=((e,t)=>{let n=Ii({op:e,[O]:ll,[k]:iu,[li]:t}),r=function(e,t){this[D]=e,this.payload=t};return r.prototype=n,r})(`Match`,function(e,t){let n=e.reasons.find(Mi);if(n===void 0)return Vc(e);let r=this.payload;return t.succeedWith(ml?r.onFailure(n.error):ni(()=>r.onFailure(n.error)))}),ou=b(2,(e,t)=>tu(e,{onFailure:e=>{let n=e.reasons.find(Mi);return n?t.onFailure(n.error):Vc(e)},onSuccess:t.onSuccess})),su=b(2,(e,t)=>new au(e,t)),cu=b(2,(e,t)=>{if(L(e)){if(e._tag===`Success`)return zi(t.onSuccess(e.value));let n=vc(e.cause);return ko(n)?e:zi(t.onFailure(n.success))}return su(e,t)}),lu=e=>L(e)?zi(e):uu(e),uu=Li({op:`Exit`,[O](e){return e._stack.push(this),this[D]},[k](e,t,n){return t.succeedWith(n??zi(e))},[li](e,t,n){return t.succeedWith(n??Hi(e))}}),du=`~effect/Scope`,fu=`~effect/Scope/Closeable`,pu=j(`effect/Scope`),mu=(e,t)=>A(n=>(Gu(n),hu(e,t)??I)),hu=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&Cu(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return gu(n.finalizer,t);let r=n.finalizers;return r.size===1?gu(r.values().next().value,t):vu(e,r,t)},gu=(e,t)=>{try{return e(t)}catch(e){return Wi(e)}},_u=(e,t)=>Ol(e)?t:Gl(t,t=>Vc(Di(e.cause,t))),vu=rl(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=Oc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*lu(gu(s,n))):i.push(rd(o,gu(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*Ic(i)),yield*Fl(r)}),yu=(e,t)=>{let n=Tu(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(Su(e,n,e=>mu(n,e)),n)},bu=(e,t)=>F(()=>e.state._tag===`Closed`?t(e.state.exit):(Su(e,{},t),I)),xu=(e,t)=>bu(e,On(t)),Su=(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))}},Cu=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=Eu:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=Eu))},wu=e=>Tu(e,void 0),Tu=(e=`sequential`,t)=>({[fu]:fu,[du]:du,strategy:e,parent:t,state:Eu}),Eu={_tag:`Empty`},Du=Hl(pu),Ou=e=>F(()=>{let t=wu();return Mu(e(t),e=>F(()=>hu(t,e)??I))}),ku=function(){let e=Ii({op:`OnExit`,[O](e){return e._stack.push(this),this.effect},[ui](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Hu),e.interruptible=!1)},[k](e,t,n){n??=zi(e);let r;try{r=this.onExit(n)}catch(e){r=Wi(e)}return r?Sl(r,e=>n):n},[li](e,t,n){n??=Hi(e);let r;try{r=this.onExit(n)}catch(e){r=Wi(e)}return r?Sl(_u(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),Au=(e,t,n)=>new ku(e,t,n),ju=(e,t)=>{e._stack.push(new ku(void 0,t,void 0))},Mu=b(2,Au),Nu=b(3,(e,t,n)=>Mu(e,e=>{let r=t(e);return ko(r)?I:n(r.success,e)})),Pu=b(2,(e,t)=>Nu(e,kl,t)),Fu=b(3,(e,t,n)=>Mu(e,e=>{if(e._tag!==`Failure`)return I;let r=t(e.cause);return ko(r)?I:n(r.success,e.cause)})),Iu=b(2,(e,t)=>Fu(bc,t)(e)),Lu=On(1/0),Ru=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,ju(e,()=>{if(!(--t.awaiters>0||i!==t))return i=void 0,Rc(t.fiber)}),Lc(t.fiber));return[A(o=>{if(i!==void 0)return a(o,i);if(r!==void 0&&(n===1/0||o.getRef(Td).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(Td),c={fiber:void 0,awaiters:0};return i=c,c.fiber=rd(o,Au(e,e=>{if(i!==c||(i=void 0,Al(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e}),!0,!0),c.fiber._exit??a(o,c)}),Uc(()=>{r=void 0})]},zu=e=>Uc(()=>Ru(e,Lu)[0]),Bu=e=>A(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Hu),e):e),Vu=Li({op:`SetInterruptible`,[ui](e){if(e.interruptible=this[D],e._interruptedCause&&e.interruptible)return()=>Vc(e._interruptedCause)}}),Hu=Vu(!0),Uu=Vu(!1),Wu=e=>{if(e.interruptible=!0,e._stack.push(Uu),e._interruptedCause)return Vc(e._interruptedCause)},Gu=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Hu))},Ku=e=>A(t=>t.interruptible?e:Wu(t)??e),qu=e=>A(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Hu),e(Ku)):e(x)),Ju=(e,t)=>$n(e)?t?.mode===`result`?Xu(e,eu,t):Xu(e,x,t):t?.discard?t.mode===`result`?Xu(Object.values(e),eu,t):Xu(Object.values(e),x,t):F(()=>{let n={};return cl(Xu(Object.entries(e),([e,r])=>wl(t?.mode===`result`?eu(r):r,t=>{ri(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),Yu=Li({op:`While`,[k](e,t){return this[D].step(e),this[D].while()?(t._stack.push(this),this[D].body()):jl},[O](e){return this[D].while()?(e._stack.push(this),this[D].body()):jl}}),Xu=b(e=>typeof e[1]==`function`,(e,t,n)=>F(()=>{let r=Qu(n?.concurrency);if(r===1)return Zu(e,t,n);let i=zo(e),a=i.length;if(a===0)return n?.discard?I:P([]);let o=n?.discard?void 0:Array(a),s=nd({f:t,out:o},i,{concurrency:r});return s?cl(s,o):P(o)})),Zu=(e,t,n)=>F(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return cl(Yu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),Qu=e=>e===`unbounded`?1/0:Math.max(1,e??1),$u=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>Sl(lu(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??I),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!L(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},ed=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=Wi(e);return f=t,c=!0,u&&u.size>0?Sl(Bu(Bc(Array.from(u))),()=>f??t):t},h=()=>{let i=!1;for(;!f&&a<o;a++){let o=r[a],ee=p??t(e,o,a);if(L(ee)){if(f=n(e,o,ee,a),f)break}else if(l){p=void 0;let t=rd(l,ee,!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=Ti(e);f=Hi(f._tag===`Failure`?Di(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??I)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return el(e=>{l=Oc(),u=new Set,p=ee,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):F(()=>(f??=jl,Sl(u?Bc(u):I,()=>f?._tag===`Failure`?f:I)))})}if(c=!0,f){if(u&&u.size>0){let e=Pc(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(I);else return jl}};return h()}},td=()=>e=>ed(e),nd=ed({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)}}),rd=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new kc(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Dc(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},id=e=>(t,n)=>{let r=new kc(n?.scheduler?mo(e,js,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},ad=id(uo()),od=e=>{let t=id(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},sd=(e=>{let t=od(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Sc(e.cause);return e.value})})(uo()),cd=e=>{let t=id(e);return e=>{if(L(e))return e;let n=new Is(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Wi(new Pd(r))}},ld=cd(uo()),ud=(e=>{let t=cd(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Sc(n.cause);return n.value}})(uo()),dd=P(!0),fd=P(!1),pd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return dd;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=[],dd}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](jl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](jl)}open=A(e=>this._isOpen?fd:(this._isOpen=!0,this.scheduleUnsafe(e)));release=A(e=>this._isOpen?fd:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=el(e=>this._isOpen?e(I):(this.waiters.push(e),Uc(()=>{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=Uc(()=>this.closeUnsafe());whenOpen=e=>Sl(this.await,()=>e);isOpen(){return this._isOpen}},md=e=>new pd(e??!1),hd=BigInt(0),gd={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:hd,endTime:hd,exit:jl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},_d=e=>Object.assign(Object.create(gd),e),vd=e=>e?yo(e.annotations,$s)?e._tag===`Span`?vd(Ua(e.parent)):Ia():La(e):Ia(),yd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&yo(n.annotations,$s),i=n?.parent===void 0?n?.root?Ia():vd(e.cache.span):La(n.parent),a;if(r)a=_d({name:t,parent:i,annotations:mo(n?.annotations??uo(),$s,!0)});else{let r=e.cache.tracer??rc,o=e.getRef(Td),s=e.getRef(cc),c=e.getRef(lc),l=e.getRef(uc),u=n?.level??e.getRef(ec),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??uo(),links:d,startTime:s?o.currentTimeNanosUnsafe():hd,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(za(i)&&i.value.sampled===!1?!1:!Ld(e.getRef(tc),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},bd=(e,t)=>(t=typeof t==`function`?t:jn,Ll(oc,n=>({name:e,stack:t,parent:n}))),xd=(e,t,n,r)=>Uc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():hd,t)}),Sd=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return A(t=>{let i=yd(t,e,n),a=t.getRef(Td),o=t.getRef(cc);return ju(t,e=>xd(i,e,a,o)),r(i)})},Cd=Hl(Zs),wd=function(){let e=mi(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=x;return t._tag===`Span`&&(n=pc(n),r=bd(t.name,n?.captureStackTrace)),e?Cd(r(arguments[0]),t):e=>Cd(r(e),t)},Td=M(`effect/Clock`,{defaultValue:()=>new Dd}),Ed=2**31-1,Dd=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Uc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Ad()}currentTimeNanos=Uc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return kd()}monotonicTimeNanos=Uc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Ts(e))}sleepMillis(e){return e<=0?Gc:Number.isFinite(e)?el(t=>{let n=e>Ed?this.sleepMillis(e-Ed):I,r=setTimeout(()=>t(n),Math.min(e,Ed));return Uc(()=>clearTimeout(r))}):tl}},Od=BigInt(1e6),kd=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())*Od;return e>t&&(t=e),t}}(),Ad=function(){let e=BigInt(1e9),t;return()=>{let n=kd(),r=BigInt(Date.now())*Od;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}}(),jd=`~effect/Cause/IllegalArgumentError`,Md=class extends qi(`IllegalArgumentError`){[jd]=jd;constructor(e){super({message:e})}},Nd=`~effect/Cause/AsyncFiberError`,Pd=class extends qi(`AsyncFiberError`){[Nd]=Nd;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Fd=`~effect/Cause/UnknownError`,Id=class extends qi(`UnknownError`){[Fd]=Fd;constructor(e,t){super({message:t,cause:e})}},Ld=Na(ja(Aa,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}})),Rd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Rd.gray,Rd.blue,Rd.green,Rd.yellow,Rd.red,Rd.bgBrightRed,Rd.black;var zd=vi,Bd=yi,Vd=Mi,Hd=Ti,Ud=Oi,Wd=Ai,Gd=e=>new wi(e),Kd=e=>new ki(e),qd=gc,Jd=xc,Yd=Di,Xd=Sc,Zd=yc,Qd=Yi,$d=$i,ef=Md,tf=zi,nf=Hi,rf=Ui,af=jl,of=Ol,sf={"~effect/Deferred":{_A:x,_E:x},pipe(){return y(this,arguments)}},cf=function(){this.resumes=void 0,this.effect=void 0};cf.prototype=sf;var lf=()=>new cf,uf=e=>el(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Uc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),df=(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},ff=cc,pf=pu,mf=wu,hf=Du,gf=bu,_f=xu,vf=yu,yf=mu,bf=`~effect/Layer`,xf=`~effect/Layer/MemoMap`,Sf=(e,t)=>{let n={observers:0,deferred:lf(),scope:mf(),finalizer:r=>F(()=>--n.observers>0?I:(e.map.delete(t),yf(n.scope,r)))};return n},Cf=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,Su(t,{},e.finalizer),!0),wf={[bf]:{_ROut:x,_E:x,_RIn:x},pipe(){return y(this,arguments)}},Tf=e=>{let t=Object.create(wf);return t.build=e,t},Ef=e=>Tf((t,n)=>{let r=vf(n);return Mu(e(t,r),e=>e._tag===`Failure`?yf(r,e):I)}),Df=e=>{let t=Ef((n,r)=>n.getOrElseMemoize(t,r,e));return t},Of=class{get[xf](){return xf}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(Cf(n,t),n.deferred.effect??uf(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return F(()=>{let r;return Au(F(()=>{let i=this.get(e,t);if(i)return i;let a=Sf(this,e);return Cf(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&df(r,e)})})}},kf=()=>new Of,Af=e=>new Of(e),jf=class e extends j()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=go(t,e);return n?Af(n):kf()}},Mf=b(3,(e,t,n)=>Hl(wl(F(()=>e.build(t,n)),mo(jf,t)),jf,t)),Nf=b(2,(e,t)=>A(n=>Mf(e,jf.forkOrCreate(n.context),t))),Pf=e=>Tf(On(P(e))),Ff=function(){return arguments.length===1?e=>If(arguments[0],e):If(arguments[0],arguments[1])},If=(e,t)=>Lf(wl(t,t=>po(e,t))),Lf=e=>Df((t,n)=>hf(e,n)),Rf=e=>Lf(cl(e,uo())),zf=(e,t,n)=>{let r=vf(n,`parallel`);return Xu(e,e=>e.build(t,vf(r,`sequential`)),{concurrency:e.length}).pipe(wl(e=>wo(...e)))},Bf=(...e)=>Ef((t,n)=>zf(e,t,n)),Vf=(e,t,n)=>Ef((r,i)=>Sl(Array.isArray(t)?zf(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Vl(t),wl(e=>n(e,t))))),Hf=b(2,(e,t)=>Vf(e,t,x)),Uf=b(2,(e,t)=>Vf(e,t,(e,t)=>Co(t,e))),Wf=Td,Gf=`~effect/DateTime`,Kf=`~effect/DateTime/TimeZone`,qf={[Gf]:Gf,pipe(){return y(this,arguments)},[Jr](){return this.toString()},toJSON(){return ap(this).toJSON()}},Jf={...qf,_tag:`Utc`,[C](){return ar(this.epochMilliseconds)},[T](e){return Xf(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${ap(this).toJSON()})`}};({...qf});var Yf={[Kf]:Kf,[Jr](){return this.toString()}};({...Yf}),{...Yf};var Xf=e=>S(e,Gf),Zf=e=>Xf(e[0]),Qf=e=>e._tag===`Utc`,$f=e=>{let t=Object.create(Jf);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},ep=e=>{let t=e.getTime();if(Number.isNaN(t))throw new ef(`Invalid date`);return $f(t)},tp=e=>{if(Xf(e))return e;if(e instanceof Date)return ep(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return ep(new Date(e.epochMilliseconds));let t=new Date(0);return op(t,e),ep(t)}return typeof e==`string`&&!np(e)?ep(new Date(e+`Z`)):ep(new Date(e))},np=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),rp=Wa(tp),ip=e=>$f(e.epochMilliseconds),ap=e=>new Date(e.epochMilliseconds),op=(e,t)=>{if((t.year!==void 0||t.month!==void 0||t.day!==void 0)&&e.setUTCFullYear(t.year??e.getUTCFullYear(),t.month===void 0?e.getUTCMonth():t.month-1,t.day??e.getUTCDate()),t.weekDay!==void 0){let n=t.weekDay-e.getUTCDay();e.setUTCDate(e.getUTCDate()+n)}t.hour!==void 0&&e.setUTCHours(t.hour),t.minute!==void 0&&e.setUTCMinutes(t.minute),t.second!==void 0&&e.setUTCSeconds(t.second),t.millisecond!==void 0&&e.setUTCMilliseconds(t.millisecond)},sp=b(Zf,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),cp=e=>ap(e).toISOString(),lp=b(2,(e,t)=>Jl(e,fp,e=>t(e))),up=e=>e._tag===`Fail`&&Qd(e.error),dp=e=>{let t,n=!1;for(let r of e.reasons)up(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Do(e):n?Do(Hd(e.reasons.filter(e=>!up(e)))):Eo(t)},fp=e=>{let t=dp(e);return ko(t)?t:Eo(t.success.value)},pp=e=>{let t=dp(e);return ko(t)?nf(t.failure):tf(t.success.value)},mp=(e,t,n)=>Ou(r=>Sl(n?.local?Mf(t,kf(),r):Nf(t,r),t=>Vl(e,t))),hp=b(e=>mi(e[0]),(e,t,n)=>so(t)?Vl(e,t):mp(e,Array.isArray(t)?Bf(...t):t,n)),gp=mi,_p=Ju,vp=Xc,yp=Zc,R=P,bp=F,xp=Uc,Sp=I,Cp=nl,z=Hc,wp=Vc,Tp=Kc,Ep=qc,Dp=Yc,Op=A,kp=Wc,B=Sl,Ap=yl,jp=bl,Mp=lu,Np=wl,Pp=cl,Fp=xl,Ip=Zl,Lp=Gl,Rp=Ql,zp=tu,Bp=Rl,Vp=Bl,Hp=hp,Up=Vl,Wp=Il,Gp=Hl,Kp=Pu,qp=Mu,Jp=zu,Yp=Iu,Xp=qu,Zp=Wl,Qp=Sd,$p=wd,em=ad,tm=sd,nm=ud,rm=ld,im=rl,am=Tl,om=El,sm=Dl,cm=Cl,lm=al,um=`~effect/BigDecimal`,dm={[um]:um,[C](){let e=ym(this);return nr(or(String(e.value)),ar(e.scale))},[T](e){return fm(e)&&wm(this,e)===0},toString(){return`BigDecimal(${Em(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Jr](){return this.toJSON()},pipe(){return y(this,arguments)}},fm=e=>S(e,um),pm=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(dm);return n.value=e,n.scale=t,n},mm=(e,t)=>{let n=pm(e,t);return n.normalized=n,n},hm=BigInt(0),gm=BigInt(1),_m=BigInt(10),vm=mm(hm,0),ym=e=>{if(e.normalized===void 0){if(e.value===hm)e.normalized=vm;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=mm(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},bm=100,xm=[gm],Sm=(e,t)=>e===t?0:e<t?-1:1,Cm=(e,t)=>{let n=`${e.value<hm?-e.value:e.value}`,r=`${t.value<hm?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==hm)return i<hm?-1:1;let a=Math.max(n.length,r.length);return ka(n.padEnd(a,`0`),r.padEnd(a,`0`))},wm=(e,t)=>{if(e.scale===t.scale)return Sm(e.value,t.value);let n=Tm(e),r=Tm(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>bm)return n===-1?Cm(t,e):Cm(e,t);let o=xm[a]??=_m**BigInt(a);return i>0?Sm(e.value,t.value*o):Sm(e.value*o,t.value)},Tm=e=>e.value===hm?0:e.value<hm?-1:1,Em=e=>{let t=ym(e);if(Math.abs(t.scale)>=16)return Dm(t);let n=t.value<hm,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},Dm=e=>{if(Om(e))return`0e+0`;let t=ym(e),n=`${t.value}`,r=t.value<hm?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},Om=e=>e.value===hm,km=BigInt(1),Am=BigInt(1e3),jm=BigInt(1024),Mm=[{symbol:`B`,factor:km,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:Am,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:Am**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:Am**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:Am**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:Am**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:Am**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:Am**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:Am**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:Am**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:Am**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],Nm=[Mm[0],{symbol:`KiB`,factor:jm,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:jm**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:jm**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:jm**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:jm**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:jm**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:jm**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:jm**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}];[...Mm,...Nm.slice(1)];var Pm=Xf,Fm=Qf,Im=ep,Lm=tp,Rm=rp,zm=ip,Bm=sp,Vm=cp,Hm=e=>Wm(typeof e==`string`?Gm.encode(e):e),Um=e=>{let t=Km(e),n=t.length;if(n%4!=0)return Do(new Ws({kind:`Decode`,module:`Base64`,input:t,message:`Length must be a multiple of 4, but is ${n}`}));let r=t.indexOf(`=`);if(r!==-1&&(r<n-2||r===n-2&&t[n-1]!==`=`))return Do(new Ws({kind:`Decode`,module:`Base64`,input:t,message:`Found a '=' character, but it is not at the end`}));try{let e=t.endsWith(`==`)?2:+!!t.endsWith(`=`),r=new Uint8Array(n/4*3-e);for(let e=0,i=0;e<n;e+=4,i+=3){let n=Ym(t.charCodeAt(e))<<18|Ym(t.charCodeAt(e+1))<<12|Ym(t.charCodeAt(e+2))<<6|Ym(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Eo(r)}catch(e){return Do(new Ws({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},Wm=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=qm[e[r-2]>>2],n+=qm[(e[r-2]&3)<<4|e[r-1]>>4],n+=qm[(e[r-1]&15)<<2|e[r]>>6],n+=qm[e[r]&63];return r===t+1&&(n+=qm[e[r-2]>>2],n+=qm[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=qm[e[r-2]>>2],n+=qm[(e[r-2]&3)<<4|e[r-1]>>4],n+=qm[(e[r-1]&15)<<2],n+=`=`),n},Gm=new TextEncoder,Km=e=>e.replace(/[\n\r]/g,``),qm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Jm=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Jm[qm.charCodeAt(e)]=e;Jm[61]=0;var Ym=e=>{if(e>=Jm.length||Jm[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Jm[e]},Xm=`~effect/http/Cookies`,Zm=`~effect/http/Cookies/Cookie`,Qm={[Xm]:Xm,...Xr,toJSON(){return{_id:`effect/Cookies`,cookies:Po(this.cookies,e=>e.toJSON())}},pipe(){return y(this,arguments)}},$m=e=>{let t=Object.create(Qm);return t.cookies=e,t},eh=e=>{let t={};for(let n of e)ri(t,n.name,n);return $m(t)},th=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=nh(e.trim());t&&n.push(t)}return eh(n)};function nh(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(!rh.test(r))return;let i=t[0].slice(n+1),a=ah(i);if(t.length===1)return Object.assign(Object.create(ih),{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=bs(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(ih),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var rh=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,ih={[Zm]:Zm,...Xr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},ah=e=>{try{return decodeURIComponent(e)}catch{return e}},oh=new WeakMap,sh=`~effect/Redacted`,ch=e=>S(e,sh),lh=(e,t)=>{let n=Object.create(uh);return t?.label&&(n.label=t.label),oh.set(n,e),n},uh={[sh]:{_A:e=>e},label:void 0,...fi,toJSON(){return this.toString()},toString(){return`<redacted${Bn(this.label)?`:`+this.label:``}>`},[C](){return w(oh.get(this))},[T](e){return ch(e)&&_r(oh.get(this),oh.get(e))}},dh=Symbol.for(`~effect/http/Headers`),fh=Object.defineProperties(Object.create(null),{[dh]:{value:dh},[Mr]:{value(e){return Sh(this,yo(e,wh))}},toJSON:{value(){return Pr(this)}},[T]:{value(e){return mh(this,e)}},[C]:{value(){return cr(this)}},toString:{value:Xr.toString},[Jr]:{value:Xr[Jr]}}),ph=e=>Object.assign(Object.create(fh),e),mh=Lo(ra()),hh=Object.create(fh),gh=e=>{if(e===void 0)return hh;if(Symbol.iterator in e){let t=Object.create(fh);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(fh);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},_h=e=>Object.setPrototypeOf(e,fh),vh=b(3,(e,t,n)=>{let r=ph(e);return r[t.toLowerCase()]=n,r}),yh=b(2,(e,t)=>ph({...e,...gh(t)})),bh=b(2,(e,t)=>{let n=ph(e);return Object.assign(n,t),n}),xh=b(2,(e,t)=>{let n=ph(e);return delete n[t.toLowerCase()],n}),Sh=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=lh(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=lh(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),Ch=(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},wh=M(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]}),Th=`~effect/http/UrlParams`,Eh=e=>S(e,Th),Dh={...fi,[Th]:Th,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[T](e){return jh(this,e)},[C](){return ur(this.params.flat())}},Oh=e=>{let t=Object.create(Dh);return t.params=e,t},kh=e=>{if(Eh(e))return e;let t=Ah(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 Oh(n)},Ah=e=>{let t=typeof e[Symbol.iterator]==`function`?zo(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=Ah(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},jh=ta((e,t)=>Mh(e.params,t.params)),Mh=Yo(Mo([ra(),ra()])),Nh=Oh([]),Ph=b(2,(e,t)=>Oh(t(e.params))),Fh=b(2,(e,t)=>{let n=kh(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 Oh(n)}),Ih=b(2,(e,t)=>Ph(e,Ho(kh(t).params))),Lh=e=>new URLSearchParams(kh(e).params).toString(),Rh=e=>{let t={};for(let[n,r]of e.params)if(!Object.hasOwn(t,n))ri(t,n,r);else{let e=t[n];typeof e==`string`?ri(t,n,[e,r]):e.push(r)}return t};function zh(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Bh(e){return t=>zh(t)?.[e]}var Vh=`~structural`,Hh=`~sentinels`,Uh=`~constructor`,Wh=Nn(e=>{let t=zh(e)?.identifier;return typeof t==`string`?t:e.getExpected(Wh)}),V=Symbol(),Gh=tf,Kh=Gh(V),H=Gh(V),qh=e=>e===V?Ia():La(e),Jh=e=>e._tag===`None`?Kh:Gh(e.value),Yh=`~effect/SchemaIssue/Issue`;function Xh(e){return S(e,Yh)&&e[Yh]===Yh}function Zh(e){return Object.hasOwn(e,`input`)}var Qh=class{[Yh]=Yh;constructor(e,t){t?.reportInput===!0&&e!==V&&(this.input=e)}},$h=class extends Qh{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},eg=class extends Qh{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},tg=class extends Qh{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},ng=class extends Qh{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},rg=class extends Qh{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},ig=class extends Qh{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},ag=class extends Qh{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},og=class extends Qh{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function sg(e,t,n,r,i){return new ig(e,[new tg([t],n)],r,i)}var cg=class extends Qh{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},lg=class extends Qh{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},ug=class extends Qh{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function dg(e,t,n){if(Xh(e))return e;if(typeof e==`string`)return new og({message:e},t,n);let r=typeof e.issue==`string`?new og({message:e.issue},t,n):e.issue;return new tg(e.path,r)}function fg(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new og(void 0,t,n):dg(e,t,n)}function pg(e,t,n,r){return Array.isArray(t)?Wo(t)?t.length===1?dg(t[0],n,r):new ig(e,Jo(t,e=>dg(e,n,r)),n,r):void 0:fg(t,n,r)}var mg=e=>{let t=Tg(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return yg(Wh(e.ast),e);case`InvalidValue`:{let t=vg(e);if(t!==void 0)return yg(t,e);let n=_g(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=_g(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=_g(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},hg=e=>Tg(e.issue)??Tg(e);function gg(e){return t=>({issues:bg(t,[],e?.leafHook??mg,e?.checkHook??hg)})}function _g(e){return Zh(e)?E(e.input):void 0}function vg(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function yg(e,t){let n=_g(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function bg(e,t,n,r){switch(e._tag){case`Filter`:{let i=r(e);if(i!==void 0)return[{path:t,message:i}];if(e.issue._tag!==`InvalidValue`)return bg(e.issue,t,n,r);let a=vg(e.issue);return[{path:t,message:a===void 0?yg(xg(e.filter),e):yg(a,e.issue)}]}case`Encoding`:return bg(e.issue,t,n,r);case`Pointer`:return bg(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>bg(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:Tg(e)??yg(Wh(e.ast),e)}]:e.issues.flatMap(e=>bg(e,t,n,r));default:return[{path:t,message:n(e)}]}}function xg(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=>xg(e)).join(` & `)}}function Sg(){return e=>wg(e,``)}var Cg=Sg();function wg(e,t){let n;switch(e._tag){case`Filter`:{let r=hg(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return wg(e.issue,t);let r=vg(e.issue);n=r===void 0?yg(xg(e.filter),e):yg(r,e.issue)}break}case`Encoding`:return wg(e.issue,t);case`Pointer`:return wg(e.issue,t+Vr(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>wg(e,t)).join(`
9
- `);n=Tg(e)??yg(Wh(e.ast),e);break;default:n=mg(e)}return t?`${n}\n at ${t}`:n}function Tg(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return Tg(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 Eg(e){let t;for(let n of e.reasons){if(!Vd(n)||!Xh(n.error))return;t??=n.error}return t}function Dg(e,t){let n=Eg(e);if(n===void 0)throw Error(t,{cause:e});return n}var Og=e=>Object.assign(Object.create(En),e);function kg(e){return Fg((t,n)=>z(e(t,n)))}function Ag(e){return kg((t,n)=>{let r={message:e(t)};return za(t)?new cg(r,t.value,n):new cg(r)})}var jg=Ag(()=>`Encoding is not supported`),Mg=Og({_tag:`Passthrough`});function Ng(){return Mg}function U(e){return Og({_tag:`Transform`,transform:e})}function Pg(e){return Og({_tag:`TransformEffect`,transform:e})}function Fg(e){return Og({_tag:`TransformOptionalEffect`,transform:e})}function Ig(){return U(globalThis.String)}function Lg(){return U(globalThis.Number)}function Rg(e){return Pg((t,n)=>Dp({try:()=>JSON.parse(t,e?.reviver),catch:()=>new og({expected:`a valid JSON string`},t,n)}))}function zg(e){return Pg((t,n)=>Dp({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 og({expected:`a JSON-serializable value`},t,n)}))}function Bg(){return U(Hm)}function Vg(){return Pg((e,t)=>om(kp(Um(e)),()=>new og({expected:`a valid Base64 string`},e,t)))}var Hg=class extends Dn{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Hg(this.encode,this.decode)}},Ug=`~effect/SchemaTransformation/Transformation`,Wg=class extends Dn{[Ug]=Ug;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Wg(this.encode,this.decode)}};function Gg(e){return S(e,Ug)&&e[Ug]===Ug}var Kg=e=>Gg(e)?e:new Wg(e.decode,e.encode);function qg(e){return new Wg(Pg(e.decode),Pg(e.encode))}function Jg(e){return new Wg(U(e.decode),U(e.encode))}var Yg=new Wg(Ng(),Ng());function Xg(){return Yg}var Zg=new Wg(Lg(),Ig()),Qg=e=>Yn(e)&&typeof e.message==`string`,$g=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:r_(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},e_=e=>{try{let t=Gr(e);return t===void 0?E(e):JSON.parse(t)}catch{return E(e)}},t_=(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},n_=e=>{let t=new WeakSet,n=r=>{if(Qn(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=t_(r,e,n);return t.delete(r),i}return e_(r)};return n},r_=e=>Qg(e)?$g(e):e,i_=e=>Jg({decode:r_,encode:n_(e)}),a_=new Wg(Vg(),Bg());function o_(e){return new Wg(Rg(e??{}),zg(e))}function s_(e){return t=>t._tag===e}var c_=s_(`Declaration`),l_=s_(`Null`),u_=s_(`Void`),d_=s_(`Never`),f_=s_(`Literal`),p_=s_(`UniqueSymbol`),m_=s_(`Enum`),h_=s_(`Arrays`),g_=s_(`Objects`),__=s_(`Union`),v_=s_(`Suspend`),W=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},y_={},b_=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}},x_=`~effect/Schema`,S_=class{[x_]=x_;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}>`}},C_=class extends S_{_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===V?Kh:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=Gv(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new C_(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>`}},w_=new class extends S_{_tag=`Null`;getParser(){return ly(this,null)}getExpected(){return`null`}},T_=class extends S_{_tag=`Undefined`;getParser(){return ly(this,void 0)}toCodecJson(){return G(this,[E_])}getExpected(){return`undefined`}},E_=new W(w_,new Wg(U(()=>void 0),U(()=>null))),D_=new T_,O_=new class extends S_{_tag=`Void`;getParser(){let e=Gh(void 0);return t=>t===V?Kh:e}toCodecJson(){return G(this,[E_])}getExpected(){return`void`}},k_=new class extends S_{_tag=`Never`;getParser(){return uy(this,qn)}getExpected(){return`never`}},A_=new class extends S_{_tag=`Unknown`;getParser(){return uy(this,Jn)}getExpected(){return`unknown`}},j_=class extends S_{_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 ${E(e)}`);this.literal=e}getParser(){return ly(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?M_(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:M_(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function M_(e){let t=globalThis.String(e.literal);return G(e,[new W(new j_(t),new Wg(U(()=>e.literal),U(()=>t)))])}var N_=new class extends S_{_tag=`String`;getParser(){return uy(this,Bn)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&yy(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},P_=class extends S_{_tag=`Number`;getParser(){return uy(this,Vn)}matchKey(e,t){return this._match(my,e,t)}matchPart(e,t){return this._match(py,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:yy(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(F_(this.checks,`effect/schema/isFinite`)||F_(this.checks,`effect/schema/isInt`))?this:G(this,[kv])}toCodecStringTree(){return this.toCodecJson()===this?G(this,[_y]):G(this,[vy])}getExpected(){return`number`}};function F_(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&F_(e.checks,t))}var I_=new P_,L_=new class extends S_{_tag=`Boolean`;getParser(){return uy(this,Hn)}getExpected(){return`boolean`}},R_=class extends S_{_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(ey(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(ey(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 rg(n,t[o],i),a=new tg([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return z(new ig(n,[a],t,i))}return e.issues?z(new ig(n,e.issues,t,i)):Gh(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:Qu(t.concurrency),f=d===1?V_(i,e,0,u):H_(i,e,{concurrency:d,end:u});if(!f)return c(i);if(L(f))return cm(f,()=>c(i));let p=!0;return bp(()=>p?(p=!1,B(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===V)return Kh;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)):z(new ag(n,e,a))}catch(e){return Ep(e)}}}_rebuild(e,t,n){let r=Gv(this.elements,e),i=Gv(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new R_(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 z_(e,t,n,r){if(n._tag===`Failure`)return U_(e,e.ast,r,n);let i=n===H?t:n[D];if(i!==V)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(ey(t.ast))return;let n=new tg([r],new ng(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return rf(new ig(e.ast,[n],e.input,e.options))}}var B_={onItem(e,t,n){let r=n<e.len?t:V;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:z_},V_=$u()(B_),H_=td()(B_),U_=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=Eg(r.cause);if(i===void 0)return nf(Jd(r.cause,r=>new ig(t,[new tg([n],r)],e.input,e.options)));let a=new tg([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return rf(new ig(t,[a],e.input,e.options))},W_=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function G_(e,t,n=y_){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(dy(ay(t)))}var K_=class{name;type;constructor(e,t){this.name=e,this.type=t}};function q_(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(q_);default:return!1}}function J_(e){let t=Fv(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(J_);default:return!1}}function Y_(e){return q_(e)&&J_(e)}var X_=class{parameter;type;constructor(e,t){if(!Y_(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,ey(t)&&!cy(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},Z_=class extends S_{_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 uy(n,Kn);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(dy(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 U_(t,n,i,s)??af;let c=s===H?o:s[D];if(a!==V&&c!==V){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return af;ri(t.out,a,c)}return af},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!L(t))return B(Mp(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return U_(e,n,r,a)??af;let o=a===H?r:a[D],s=e.input[r],l=i.parserValue(s,e.options);return L(l)?t(e,r,o,s,l):B(Mp(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return L(a)?t(e,n,n,i,a):B(Mp(a),r=>t(e,n,n,i,r))},u=i?td()({onItem:(e,[t,n])=>n.is.parameter===N_?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return lm(function*(t,d){if(t===V)return V;if(typeof t!=`object`||!t||Array.isArray(t))return yield*z(new ag(n,t,d));s();let f=t,p={},m={ast:n,input:f,out:p,issues:void 0,options:d},h=d.errors===`all`,ee=d.onExcessProperty===`error`,te=d.concurrency===void 0?1:Qu(d.concurrency),ne=i&&ee?n.indexSignatures.map(e=>G_(f,e.parameter,d)):void 0;if(ee){let r=ne?new Set(e):e;if(ne)for(let e of ne)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 rg(n,f[a],d),r=new tg([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*z(new ig(n,[r],t,d))}}}if(r){let e=te===1?ev(m,a):tv(m,a,{concurrency:te});e&&(yield*e)}if(i&&te===1)for(let e=0;e<i;e++){let t=o[e],n=t.is.parameter===N_?l:c,r=ne?.[e]??(t.is.parameter===N_?Object.keys(f):G_(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!L(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=Ko();for(let t=0;t<i;t++){let n=o[t],r=ne?.[t]??(n.is.parameter===N_?Object.keys(f):G_(f,n.is.parameter,d));for(let t=0;t<r.length;t++)e.push([r[t],n])}let t=u(m,e,{concurrency:te});t&&(yield*t)}return m.issues?yield*z(new ig(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return B(Mp(n),n=>{let i=Q_(e,r,n);if(i)return i;let o=()=>Gh(e.out),s=ev(e,a.slice(t+1));return s?cm(s,o):o()})};return(e,t)=>{if(e===V)return Kh;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&Qu(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return z(new ag(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=pv(i,s),l=c?i[s]:V,d=n.parser(l,t);if(!L(d))return u(o,e,d);if(d===H){c&&ri(a,s,l);continue}let f=Q_(o,n,d);if(f)return f}}catch(e){return Ep(e)}return Gh(a)}}_rebuild(e,t,n,r){let i=Gv(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new K_(t.name,n)}),a=Gv(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new X_(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new Z_(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 Q_(e,t,n){if(n._tag===`Failure`)return U_(e,e.ast,t.name,n);if(n===H)return;let r=n[D];if(r!==V){ri(e.out,t.name,r);return}if(delete e.out[t.name],!ey(t.type)){let n=new tg([t.name],new ng(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return rf(new ig(e.ast,[n],e.input,e.options))}}var $_={onItem(e,t){if(!pv(e.input,t.name))return t.parser(V,e.options);let n=e.input[t.name];return ri(e.out,t.name,n),t.parser(n,e.options)},step:Q_},ev=$u()($_),tv=td()($_);function nv(e,t){return e?t?[...e,...t]:e:t}function rv(e,t,n){return new Z_(Reflect.ownKeys(e).map(t=>new K_(t,e[t].ast)),[],n,t)}function iv(e){return e.ast}function av(e,t=void 0){return new R_(!1,e.map(e=>e.ast),[],void 0,t)}function ov(e,t,n){return new hv(e.map(iv),t,void 0,n)}var sv=Pn(e=>{for(;;){if(v_(e))return A_;let t=e.encoding;if(!t)return e.recur?.(sv,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return A_;e=t[t.length-1].to}});function cv(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(cv)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function lv(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Hh];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ey(t)){if(f_(t))return[{key:e.name,literal:t.literal}];if(p_(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!ey(e)){if(f_(e))return[{key:t,literal:e.literal}];if(p_(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>lv(sv(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return lv(e.thunk())}}var uv=new WeakMap,dv=Object.freeze([]),fv=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,pv=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function mv(e){let t=uv.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=sv(c);if(d_(l))continue;if(f_(l)||p_(l)){a??=new Map;let e=f_(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=lv(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=cv(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??dv);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??dv;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(Xn(e)){let n=pv(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??dv;if(t)return o}return dv}}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=fv(t);if(!Xn(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=pv(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=pv(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=pv(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(fv(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return uv.set(e,t),t}var hv=class extends S_{_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===V)return Kh;let i=(o??=mv(n.types))(e,r);if(i.length===0)return z(new lg(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:L(r)?gv(n,r.cause,e,t):_v(n,r,e,t)}return vv(n,a,i,e,t)}}_rebuild(e,t,n){let r=Gv(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new hv(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=ay(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(f_);if(t.length>0)return`${Sv(n.isMutable)}[ ${t.map(t=>e(t)+Cv(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>f_(e.type));if(t.length>0)return`{ ${t.map(t=>`${Sv(t.type.context?.isMutable)}${Br(t.name)}${Cv(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function gv(e,t,n,r){let i=Eg(t);return i?rf(new lg(e,[i],n,r)):nf(t)}function _v(e,t,n,r){return Lp(t,t=>gv(e,t,n,r))}function vv(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=bv(a,n);if(!o)return a.out?a.out:z(new lg(e,a.issues??[],r,i));if(L(o))return yv(o,a);let s=!0;return bp(()=>s?(s=!1,yv(o,a)):vv(e,t,n,r,i))}function yv(e,t){return cm(e,e=>t.out===H?R(t.input):t.out?t.out:z(new lg(t.ast,t.issues??[],t.input,t.options)))}var bv=$u()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=Eg(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]),rf(new ug(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return af}}}),xv=new hv([new j_(`Infinity`),new j_(`-Infinity`),new j_(`NaN`)]);function Sv(e){return e?``:`readonly `}function Cv(e){return e?`?`:``}var wv=class extends Dn{_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 wv(this.run,{...this.annotations,...e},this.aborted)}abort(){return new wv(this.run,this.annotations,!0)}and(e,t){return new Tv([this,e],t)}},Tv=class extends Dn{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Tv(this.checks,{...this.annotations,...e})}and(e,t){return new Tv([this,e],t)}};function Ev(e,t,n=!1){return new wv((t,n,r)=>pg(n,e(t,n,r),t,r),t,n)}function Dv(e){return Ev(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 Ov=Rv(I_,[Dv()]),kv=new W(new hv([Ov,xv]),new Wg(Lg(),U(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Av(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return Ev(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 jv=new WeakMap;function Mv(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&jv.set(n,Nv(e)),n}function Nv(e){let t=jv.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 jv.set(e,n),n}function G(e,t){return e.encoding===t?e:Mv(e,{encoding:t})}function Pv(e,t){if(e.context===t)return e;let n=Nv(e);return n.context===t&&n.encoding===e.encoding?n:Mv(e,{context:t})}function Fv(e){return e.encoding?Fv(e.encoding[e.encoding.length-1].to):e}function Iv(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Lv(e,Vo(e.checks.slice(0,-1),n.annotate(t)))}return Mv(e,{annotations:{...e.annotations,...t}})}function Lv(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Mv(e,{checks:t})}function Rv(e,t){return Lv(e,nv(e.checks,t))}function zv(e,t){let n=t(e.to);return n===e.to?e:new W(n,e.transformation)}function Bv(e,t){let n=e,r=n[n.length-1],i=zv(r,t);return i===r?e:Vo(e.slice(0,e.length-1),i)}function Vv(e){return t=>t.encoding?G(t,Bv(t.encoding,e)):t}function Hv(e,t){return Vv(e=>Pv(e,t))(e)}function Uv(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:G(r,Bv(r.encoding,n))}return e(r)}return Pn(n)}function Wv(e,t,n){let r=new W(e,t);return G(n,n.encoding?[...n.encoding,r]:[r])}function Gv(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 Kv(e,t){return Pv(e,e.context?new b_(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new b_(!1,!1,void 0,t))}var qv=Pn(e=>Jv(Pv(e,e.context?e.context.isOptional===!1?new b_(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new b_(!0,!1)))),Jv=Vv(qv),Yv=Nn(e=>qv(new hv([e,D_])));function Xv(e,t){return Pv(e,e.context?new b_(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new b_(!1,!1,t))}function Zv(e,t,n){return Wv(e,n,t)}function Qv(e){let t=[],n=[];function r(e){switch(e._tag){case`Literal`:Wn(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 $v(e,t){let{literals:n,parameters:r}=Qv(e);return new Z_(n.map(e=>new K_(e,t)),r.map(e=>new X_(e,t)))}function ey(e){return e.context?.isOptional??!1}function ty(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(ty)}function ny(e){function t(e){return ty(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Uo(n)?n:void 0}function ry(e){let t=!0;function n(e){return t=t&&!e.encoding&&!v_(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var iy=Pn(e=>{let t=Nv(e);if(t!==e){let n=iy(t);return n===t&&e.encoding===void 0?e:Pv(n,e.context)}let n=`recur`in e?e.recur(iy):e;if(`encodingChecks`in n&&n.encodingChecks){let t=ry(e)?n.encodingChecks:h_(n)||g_(n)||c_(n)&&n.typeParameters.length>0?ny(n.encodingChecks):void 0;return Mv(n,{encodingChecks:void 0,checks:nv(n.checks,t)})}return n}),ay=Pn(e=>iy(sy(e)));function oy(e,t){let n=t,r=n.length,i=n[r-1],a=[new W(sy(G(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new W(sy(n[e-1].to),n[e].transformation.flip()));let o=sy(i.to);return o.encoding?G(o,[...o.encoding,...a]):G(o,a)}var sy=Nn(e=>{if(e.encoding)return oy(e,e.encoding);let t=Nv(e);if(t!==e){let n=sy(t);return n===t?e:Pv(n,e.context)}return`flip`in e?e.flip(sy):`recur`in e?e.recur(sy):e});function cy(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(cy);default:return!1}}function ly(e,t){let n=t===0?H:Gh(t);return(r,i)=>r===V?Kh:r===t?n:z(new ag(e,r,i))}function uy(e,t){return(n,r)=>n===V?Kh:t(n)?H:z(new ag(e,n,r))}var dy=Uv(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(dy)}}),fy=Uv(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(fy)}}),py=new globalThis.RegExp(`^${W_}$`),my=new globalThis.RegExp(`^(?:${W_}|Infinity|-Infinity|NaN)$`);function hy(e){return Av(py,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:py.source}),...e})}var gy=Rv(N_,[hy()]),_y=new W(gy,Zg),vy=new W(new hv([gy,xv]),Zg);function yy(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=yy(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 $h(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function by(e){if(!c_(e))return;let t=e.annotations?.[Uh];return Gn(t)?t(e.typeParameters):void 0}var xy=Bh;function Sy(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Cy(e){return e===void 0||typeof e==`string`}function wy(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 Ty(e){return wy(e,Sy)}var Ey=new C_([],()=>(e,t,n)=>Ty(e)?H:z(new ag(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>Ay}),Dy=new W(Ey,Xg()),Oy=new W(new hv([new R_(!1,[],[Ey]),new Z_([],[new X_(N_,Ey)])]),Xg());function ky(e){return wy(e,Cy)}var Ay=new W(new C_([],()=>(e,t,n)=>ky(e)?H:z(new ag(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),Xg()),jy=(e,t,n)=>e===H?n(t):cm(e,n);function My(e){if(e._tag===`Middleware`)return(t,n,r)=>Ny(t===H?e.decode(Gh(qh(n)),r):e.decode(am(t,qh),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===H?Gh(t):e;case`Transform`:{let e=e=>e===V?Kh:Gh(t.transform(e));return(t,n)=>jy(t,n,e)}case`TransformOptional`:{let e=e=>Jh(t.transform(qh(e)));return(t,n)=>jy(t,n,e)}case`TransformEffect`:return(e,n,r)=>jy(e,n,e=>e===V?Kh:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>jy(e,n,e=>Ny(t.transform(qh(e),r)))}}var Ny=e=>cm(e,Jh),Py=(e,t,n,r)=>Lp(r,r=>Tp(()=>Jd(r,r=>new eg(e,r,t,n))));function Fy(e,t){let n=My(e.link.transformation),r;return(i,a)=>{if(i===V)return Kh;if(e.isConstructed(i))return H;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function Iy(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==V&&r!==void 0)return t(r,i);let a=n;if(L(a)&&a._tag===`Success`){let e=t(a[D],i);return e===H?a:e}return cm(Py(e,r,i,a),e=>{let n=t(e,i);return n===H?Gh(e):n})}}function Ly(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:Iy(e,n)}function Ry(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?by(e):void 0,o=a?Fy(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>My(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(L(r)){if(r._tag===`Success`){let i=r===H?t:r[D];if(t!==V&&i!==V){let i=yy(u,t,void 0,e,n);i&&(r=z(new ig(e,i,t,n)))}}}else r=B(r,r=>{if(t!==V&&r!==V){let r=yy(u,t,void 0,e,n);if(r)return z(new ig(e,r,t,n))}return R(r)})}if(s&&!n.disableChecks){if(L(r)){if(r._tag===`Success`){let i=r===H?t:r[D];if(i===V)return r;let a=yy(s,i,void 0,e,n);a&&(r=z(new ig(e,a,i,n)))}}else r=B(r,t=>{if(t!==V){let r=yy(s,t,void 0,e,n);if(r)return z(new ig(e,r,t,n))}return R(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[D],o=t(a,r)):o=cm(o,e=>{let n=t(e,r);return n===H?Gh(e):n})}if(o._tag===`Success`){let e=o[D],t=p(e,r);return t===H?o:t}return o=Py(e,n,r,o),cm(o,e=>{let t=p(e,r);return t===H?Gh(e):t})}:p}var zy=Symbol(),By=new WeakMap,Vy=e=>Gy(e).parser,Hy=e=>Gy(e).makeEffect,Uy=e=>Ly(e,Hy),Wy=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Ry(this.ast,Vy)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Ry(this.ast,Hy,Uy)}};function Gy(e){let t=By.get(e);if(t!==void 0)return t;let n=new Wy(e);return By.set(e,n),n}function Ky(e){let t=e.ast,n;return(e,r)=>(n??=ib(lb,iy(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function qy(e){let t=Ky(e);return(e,n)=>{let r=rm(t(e,n));return of(r)?La(r.value):(Dg(r.cause,`Option adapter can only return none for schema issues`),Ia())}}function Jy(e){return sb(iy(e.ast))}function Yy(e){return Zy(e.ast)}function Xy(e){{let t=ab(nb(e));return e=>{let n=t(e,y_);return of(n)?!0:(Dg(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function Zy(e){let t=iy(e),n=e=>(n=Xy(t),n(e));return e=>n(e)}function Qy(e,t){let n=nb(e.ast);return t===void 0?n:(e,r)=>n(e,eb(t,r))}function $y(e,t){let n=nb(sy(e.ast));return t===void 0?n:(e,r)=>n(e,eb(t,r))}var eb=(e,t)=>t?{...e,...t}:e,tb=e=>e===V?z(new og):R(e);function nb(e){return ib(cb,e)}function rb(e,t){return e===H?R(t):L(e)?e[D]===V?tb(V):e:cm(e,tb)}function ib(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??y_);return a===H?R(r):L(a)?a[D]===V?tb(V):a:cm(a,tb)}}function ab(e){return(t,n)=>rm(e(t,n))}function ob(e,t){let n=rm(e);if(of(n))return n.value;let r=Dg(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function sb(e){let t,n;return(r,i)=>{t??=Gy(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??y_,o=t.make;if(o!==void 0&&r!==V){let e;try{e=o(r,a)}catch(e){throw Dg(Wd(e),`Constructor adapter can only throw schema issues`),e}if(e!==zy&&e!==V)return e}return ob(rb((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var cb=e=>Gy(e).parser,lb=e=>Gy(e).makeEffect,ub=`~effect/Schema/Schema`,db=Symbol(),fb={[ub]:ub,get make(){let e=Jy(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Ky(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=qy(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return y(this,arguments)},annotate(e){return this.rebuild(Iv(this.ast,e))},annotateKey(e){return this.rebuild(Kv(this.ast,e))},check(...e){return this.rebuild(Rv(this.ast,e))},rebuild(e){return pb(e,this[db])}};function pb(e,t){function n(){}let r=Object.setPrototypeOf(n,fb);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[db]=t,r.ast=e,r}function mb(e){return pb(hb(e.ast),{schema:e})}var hb=Uv(e=>{let t=bb(e,hb),n=e.context;return t===e||n===void 0?t:Hv(t,gb(n))});function gb(e){return e.constructorDefault===void 0?e:new b_(e.isOptional,e.isMutable,void 0,e.annotations)}function _b(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function vb(e){return t=>{let n=[...t].sort((t,n)=>e(ay(t))-e(ay(n)));return n.some((e,n)=>e!==t[n])?n:t}}var yb=vb(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function bb(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Gn(n))return G(e,[Dy]);let r=n(e.typeParameters.map(e=>pb(ay(e))));return r===void 0?e:G(e,[zv(r,t)])}case`Unknown`:return G(e,[Dy]);case`ObjectKeyword`:return G(e,[Oy]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return _b(e),e.recur(t,fy);case`Union`:{let n=yb(e.types);return n===e.types?e.recur(t):new hv(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}function xb(e){return pb(Db(e.ast),{schema:e})}var Sb=vb(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function Cb(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>pb(t(ay(e)))),i=e.annotations?.toCodecStringTree;if(Gn(i)){let n=i(r);return n===void 0?e:G(e,[zv(n,t)])}let a=e.annotations?.toCodecJson,o=Gn(a)?a(r):void 0,s=o===void 0?e.annotations?.toCodec:void 0,c=o??(Gn(s)?s(r):void 0);return c===void 0?n(e):G(e,[zv(c,t)])}case`Null`:return G(e,[wb]);case`Boolean`:return G(e,[Tb]);case`Unknown`:case`ObjectKeyword`:return G(e,[Ay]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return _b(e),e.recur(t,fy);case`Union`:{let n=Sb(e.types);return n===e.types?e.recur(t):new hv(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 wb=new W(new j_(`null`),new Wg(U(()=>null),U(()=>`null`))),Tb=new W(new hv([new j_(`true`),new j_(`false`)]),new Wg(U(e=>e===`true`),Ig())),Eb=new Wg(U(e=>typeof e==`string`?[e]:e),Ng()),Db=Uv(e=>{let t=Cb(e,Db,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?Hv(t,gb(e.context)):t},{stopAt:e=>e.transformation===Eb}),Ob=b(2,(e,t)=>({...e,...t})),kb=e=>e,Ab=`~effect/Schema/SchemaError`;function jb(e){return S(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}var Mb=ub;function Nb(){return(e,t,n)=>K(new C_(e.map(iv),e=>t(e.map(e=>K(e))),n))}function Pb(e,t){return Nb()([],()=>(t,n,r)=>e(t)?R(t):z(new ag(n,t,r)),t)}var Fb=class extends Hs(`SchemaError`){[Ab]=Ab;constructor(e){let t=$r();ei(0);try{super({issue:e})}finally{ei(t)}}get message(){return Cg(this.issue)}toString(){return`SchemaError(${this.message})`}};function Ib(e){return jb(e)}function Lb(e){return L(e)?Rb(e):Lp(e,e=>Tp(()=>Jd(e,e=>new Fb(e))))}function Rb(e){return of(e)?e:nf(Jd(e.cause,e=>new Fb(e)))}function zb(e,t){let n;for(let r of e.reasons){if(!Vd(r)||!Ib(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 Bb(e){let t=rm(e);if(of(t))return t.value;throw zb(t.cause,`Sync adapter can only throw schema errors`)}var Vb=Yy;function Hb(e,t){let n=Qy(e,t);return(e,t)=>Lb(n(e,t))}var Ub=Hb;function Wb(e,t){let n=Hb(e,t);return(e,t)=>Bb(n(e,t))}function Gb(e,t){let n=$y(e,t);return(e,t)=>Lb(n(e,t))}var K=pb;function Kb(e){return S(e,Mb)&&e[Mb]===Mb}var qb=kb(e=>K(qv(e.ast),{schema:e})),Jb=kb(e=>{let t=mx(e);return K(Yv(e.ast),{schema:t})}),Yb=kb(e=>K(iy(e.ast),{schema:e}));function Xb(e){let t=K(new j_(e),{literal:e,transform(n){return t.pipe(hx(Xb(n),{decode:U(()=>n),encode:U(()=>e)}))}});return t}var Zb=K(k_),Qb=K(A_),$b=K(w_),ex=K(D_),q=K(N_),tx=K(I_),nx=K(L_),rx=K(O_);function ix(e,t){return K(e,{fields:t,mapFields(e,t){let n=e(this.fields);return ix(rv(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function J(e){return ix(rv(e,void 0),e)}function ax(e){return kb(t=>t.mapFields(Ob(e)))}function ox(e,t){return K($v(e.ast,t.ast),{key:e,value:t})}function sx(e,t){return K(e,{elements:t,mapElements(e,t){let n=e(this.elements);return sx(av(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function cx(e){return sx(av(e),e)}var Y=kb(e=>K(new R_(!1,[],[e.ast]),{value:e})),lx=kb(e=>K(new R_(!1,[e.ast],[e.ast]),{value:e}));function ux(e,t){return K(e,{members:t,mapMembers(e,t){let n=e(this.members);return ux(ov(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function dx(e,t){return ux(ov(e,t,void 0),e)}function fx(e){let t=e.map(Xb);return K(ov(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return dx(e(this.members))},pick(e){return fx(e)},transform(e){return dx(t.map((t,n)=>t.transform(e[n])))}})}var px=kb(e=>dx([e,$b])),mx=kb(e=>dx([e,ex]));function hx(e,t){return n=>K(Zv(n.ast,e.ast,t?Kg(t):Xg()),{from:n,to:e})}function gx(){return(e,t)=>xx()(e,{decode:t,encode:jg})}function _x(e){return t=>K(Xv(t.ast,e),{schema:t})}function vx(e){return Xb(e).pipe(_x(R(e)))}function yx(e,t){return J({_tag:vx(e),...t})}function bx(e,t){return Pb(t=>t instanceof e,t)}function xx(){return(e,t)=>new W(e.ast,Kg(t))}var Sx=Ev;function Cx(e,t){let n=e.source,r=e.flags,i=/^[dg]*uy?$/.test(r),a=r===``?`new RegExp(${E(n)})`:`new RegExp(${E(n)}, ${E(r)})`;return Av(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var wx=K(Ov);function Tx(e){let t=Fa(e.order),n=Na(e.order),r=Pa(e.order),i=Ma(e.order),a=e.formatter??E;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return Sx(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 Ex(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${E(e)}`);return e}var Dx=Tx({order:Aa,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Ex(e.minimum),maximum:Ex(e.maximum),...t&&{exclusiveMinimum:t},...n&&{exclusiveMaximum:n}}},toJsonSchema:()=>({[t?`exclusiveMinimum`:`minimum`]:e.minimum,[n?`exclusiveMaximum`:`maximum`]:e.maximum}),toCode:()=>({runtime:`Schema.isBetween({ minimum: ${E(e.minimum)}, maximum: ${E(e.maximum)}, exclusiveMinimum: ${E(t)}, exclusiveMaximum: ${E(n)} })`})}}});function Ox(e){return Sx(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 kx=tx.check(Ox());function Ax(e,t){return e=Nx(e),jx(e,Math.ceil(e/2),t)}function jx(e,t,n){return Sx(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})`}),[Vh]:!0,arbitraryConstraint:{minLength:e},...n})}function Mx(e,t){return e=Nx(e),Sx(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})`}),[Vh]:!0,arbitraryConstraint:{maxLength:e},...t})}function Nx(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function Px(e,t){return e=Nx(e),Sx(t=>Reflect.ownKeys(t).length>=e,{expected:`a value with at least ${e===1?`1 entry`:`${e} entries`}`,representation:{id:`effect/schema/isMinProperties`,payload:{minProperties:e}},toJsonSchema:({type:t})=>t===`object`?{minProperties:e}:[{minProperties:e},!0],toCode:()=>({runtime:`Schema.isMinProperties(${e})`}),[Vh]:!0,arbitraryConstraint:{minProperties:e},...t})}function Fx(e){return Sx(e=>Xo(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:x},...e})}var Ix=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),Lx=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Rx=[];function zx(e){let t=Ix(e),n=Rx[t];if(n!==void 0)return n;let r=fS.pipe(hx(Qb,i_(Lx(t))));return Rx[t]=r,r}globalThis.RegExp,globalThis.URL;var Bx=q.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function Vx(e,t){return Bx.pipe(hx(e,o_(t)))}var Hx=Vx(Qb);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var Ux=q.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),Wx=bx(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>xx()(Ux,a_)});function Gx(e,t){return K(Nb()([e,t],([e,t])=>(n,r,i)=>{if(!Bd(n))return z(new ag(r,n,i));switch(n._tag){case`Fail`:return sm(Qy(e)(n.error,i),{onSuccess:Gd,onFailure:e=>sg(r,`error`,e,n,i)});case`Die`:return sm(Qy(t)(n.defect,i),{onSuccess:Kd,onFailure:e=>sg(r,`defect`,e,n,i)});case`Interrupt`:return R(n)}},{representation:{id:`effect/schema/CauseReason`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.CauseReason(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Failure<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause.Failure`,toCodec:([e,t])=>xx()(dx([J({_tag:Xb(`Fail`),error:e}),J({_tag:Xb(`Die`),defect:t}),J({_tag:Xb(`Interrupt`),fiberId:mx(wx)})]),Jg({decode:e=>{switch(e._tag){case`Fail`:return Gd(e.error);case`Die`:return Kd(e.defect);case`Interrupt`:return qd(e.fiberId)}},encode:e=>{switch(e._tag){case`Fail`:return{_tag:`Fail`,error:e.error};case`Die`:return{_tag:`Die`,defect:e.defect};case`Interrupt`:return{_tag:`Interrupt`,fiberId:e.fiberId}}}}))}).ast,{error:e,defect:t})}function Kx(e,t){return K(Nb()([e,t],([e,t])=>{let n=Y(Gx(e,t));return(e,t,r)=>zd(e)?sm(Qy(n)(e.reasons,r),{onSuccess:Hd,onFailure:n=>sg(t,`failures`,n,e,r)}):z(new ag(t,e,r))},{representation:{id:`effect/schema/Cause`,payload:null},toCode:({typeParameters:e})=>({runtime:`Schema.Cause(${e[0].runtime}, ${e[1].runtime})`,Type:`Cause.Cause<${e[0].Type}, ${e[1].Type}>`,importDeclarations:[`import * as Cause from "effect/Cause"`]}),expected:`Cause`,toCodec:([e,t])=>xx()(Y(Gx(e,t)),Jg({decode:Hd,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var qx=qg({decode:(e,t)=>Ba(Rm(e),{onNone:()=>z(new og({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>R(zm(e))}),encode:e=>R(Vm(e))}),Jx=-864e13,Yx=864e13;function Xx(e,t,n){let r=Math.max(t,e?.minimum===void 0?t:e.minimum.epochMilliseconds+ +(e.exclusiveMinimum===!0)),i=Math.min(n,e?.maximum===void 0?n:e.maximum.epochMilliseconds-+(e.exclusiveMaximum===!0));return r<=i?[r,i]:[t,n]}function Zx(e,t){return kx.check(Dx({minimum:e,maximum:t}))}var Qx=Pb(e=>Pm(e)&&Fm(e),{representation:{id:`effect/schema/DateTimeUtc`,payload:null},toCode:()=>({runtime:`Schema.DateTimeUtc`,Type:`DateTime.Utc`,importDeclarations:[`import * as DateTime from "effect/DateTime"`]}),expected:`DateTime.Utc`,toCodecArbitrary:({constraint:e})=>{let[t,n]=Xx(e,Jx,Yx);return gx()(Zx(t,n),U(Lm))},toCodecJson:()=>xx()(q,qx),toFormatter:()=>e=>e.toString()}),$x=q.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(hx(Qx,qx)),eS=Pb(Eh,{representation:{id:`effect/http/UrlParams`,payload:null},toCode:()=>({runtime:`Schema.UrlParams`,Type:`UrlParams.UrlParams`,importDeclarations:[`import * as UrlParams from "effect/http/UrlParams"`]}),expected:`UrlParams`,toEquivalence:()=>jh,toCodec:()=>xx()(Y(cx([q,q])),Jg({decode:Oh,encode:e=>e.params}))}).pipe(hx(ox(q,dx([q,lx(q)])),Jg({decode:Rh,encode:kh}))),tS=globalThis.Symbol.for(`immer-draftable`),nS={};function rS(e,t,n,r,i){let a=oS(n,t,r),o=aS(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===nS?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:nS,value:i}})}static[Mb]=Mb;get[o](){return o}static[tS]=!0;static identifier=t;static fields=n.fields;static get ast(){return a(this).ast}static pipe(){return y(this,arguments)}static rebuild(e){return a(this).rebuild(e)}static make(e,t){return Jy(a(this))(e??{},t)}static makeOption(e,t){return qy(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(Iv(this.ast,e))}static annotateKey(e){return this.rebuild(Kv(this.ast,e))}static check(...e){return this.rebuild(Rv(this.ast,e))}static extend(e){return(t,r)=>{let a=sS(t)?t:J(t),o={...n.fields,...a.fields},s=rv(o,n.ast.checks,{identifier:e});return rS(this,e,ix(Rv(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 iS(e){return new Wg(U(t=>new e(t,{"~payload":{token:nS,value:t}})),Ng())}function aS(e){return`~effect/Schema/Class/${e}`}function oS(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=aS(t),o=e=>e instanceof i||S(e,a),s=iS(i);return r=hx(K(new C_([e.ast],()=>(e,t,n)=>o(e)?R(e):z(new ag(t,e,n)),{identifier:t,[Uh]:([e])=>({isConstructed:o,link:new W(e,s)}),toCodec:([e])=>new W(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Hh]:lv(e.ast),...n})),s)(e)}}function sS(e){return Kb(e)}var cS=e=>(t,n)=>rS(Ki,e,sS(t)?t:J(t),n,e=>({name:e})),lS=e=>(t,n,r)=>{let i=sS(n)?n.mapFields(e=>({_tag:vx(t),...e}),{unsafePreserveChecks:!0}):yx(t,n);return cS(e??t)(i,r)},uS=mb,dS=xb,fS=K(Iv(Ey,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),pS=Rc,mS=md,hS=`~effect/MutableRef`,gS={[hS]:hS,...fi,toJSON(){return{_id:`MutableRef`,current:Yr(this.current)}}},_S=e=>{let t=Object.create(gS);return t.current=e,t},vS={"~effect/Channel":{_Env:x,_InErr:x,_InElem:x,_OutErr:x,_OutElem:x},pipe(){return y(this,arguments)}},yS=e=>{let t=Object.create(vS);return t.transform=(t,n)=>Lp(e(t,n),e=>R(wp(e))),t},bS=(e,t)=>yS((n,r)=>B(CS(e)(n,r),e=>t(e,r))),xS=e=>yS((t,n)=>e),SS=e=>yS(im(function*(t,n){let r=vf(n),i=e=>yf(r,pp(e));return Kp(yield*Kp(e(t,n,r),i),i)})),CS=e=>e.transform,wS=e=>yS((t,n)=>bp(()=>CS(e())(t,n))),TS=e=>xS(R(z(e))),ES=e=>yS((t,n)=>DS({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),DS=e=>{let t=e.readable.getReader(),n=e.exit??_S(void 0),r=bp(()=>n.current?n.current:zp(yp({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??wp(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?$d():R(qo(t))}));return Pp(_f(e.scope,e.releaseLockOnEnd?xp(()=>t.releaseLock()):vp(()=>t.cancel().catch(Mn))),r)},OS=b(2,(e,t)=>bS(e,e=>xp(()=>{let n=0;return Np(e,e=>t(e,n++))}))),kS=b(2,(e,t)=>yS((n,r)=>B(CS(e)(n,r),e=>CS(t)(e,r)))),AS=b(2,(e,t)=>SS((n,r,i)=>gf(i,t).pipe(Ap(CS(e)(n,r))))),jS=b(2,(e,t)=>AS(e,e=>t)),MS=(e,t,n)=>bp(()=>{let r=mf();return lp(B(CS(e)($d(),r),t),n||R).pipe(qp(e=>yf(r,e)))}),NS=b(2,(e,t)=>yS((n,r)=>Np(Up(CS(e)(n,r),t),Up(t)))),PS=b(2,(e,t)=>MS(e,e=>Zp(B(e,t),{disableYield:!0}))),FS=(e,t)=>CS(e)($d(),t),IS=(e,t)=>()=>{let n=Ub(lx(e),t);return yS((e,t)=>R(B(e,e=>n(e))))},LS=`~effect/Stream`,RS={_R:x,_E:x,_A:x},zS=function(e){this.channel=e};zS.prototype={[LS]:RS,pipe(){return y(this,arguments)}};var BS=e=>new zS(e),VS=`~effect/Stream`,HS=e=>S(e,VS),US=BS,WS=(e,t)=>US(yS((n,r)=>B(FS(e.channel,r),e=>t(e,r)))),GS=e=>US(wS(()=>e().channel)),KS=e=>US(TS(e)),qS=e=>US(ES(e)),JS=b(2,(e,t)=>GS(()=>{let n=0;return US(OS(e.channel,Jo(e=>t(e,n++))))})),YS=b(2,(e,t)=>US(kS(e.channel,t))),XS=b(e=>HS(e[0]),(e,t)=>GS(()=>{let n=new TextDecoder(t?.encoding);return JS(e,e=>n.decode(e,{stream:!0}))})),ZS=b(2,(e,t)=>US(jS(e.channel,t))),QS=b(2,(e,t)=>US(NS(e.channel,t))),$S=b(2,(e,t)=>PS(e.channel,t)),eC=b(e=>HS(e[0]),(e,t,n)=>{let r,i,a=mS(!1);return new ReadableStream({start(n){i=em(Up($S(e,e=>a.whenOpen(xp(()=>{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(Xd(e.cause)):n.close()})},pull(){return new Promise(e=>{r=e,a.openUnsafe()})},cancel(){if(i)return tm(Fp(pS(i)))}},n?.strategy)}),tC=b(e=>HS(e[0]),(e,t)=>Np(Bp(),n=>eC(e,n,t))),nC=b(2,(e,t)=>e===void 0?void 0:t(e)),rC=e=>q.pipe(_x(R(e))),iC={InvalidInput:400,Unauthenticated:401,Forbidden:403},aC=J({path:Y(dx([q,wx])),message:q}),oC=gg(),sC=class e extends lS()(`InvalidInput`,{message:rC(`The input does not match the action's input.`),issues:Y(aC).pipe(_x(R([])))},{httpApiStatus:iC.InvalidInput}){static fromSchemaError=({issue:t,message:n})=>new e({message:n,issues:oC(t).issues.map(e=>({path:(e.path??[]).map(e=>{let t=Wn(e)?e:e.key;return Un(t)?String(t):t}),message:e.message}))})},cC=class extends lS()(`Unauthenticated`,{message:rC(`Authentication is required.`)},{httpApiStatus:iC.Unauthenticated}){},lC=q.check(Cx(/^[\x21\x23-\x5B\x5D-\x7E]+$/)),uC=[cC,class extends lS()(`Forbidden`,{message:rC(`Not allowed.`),scopes:qb(lx(lC))},{httpApiStatus:iC.Forbidden}){}];dx(uC);var dC=[sC,...uC],fC=dx(dC),pC=e=>e===void 0?[]:Kb(e)?[e]:e,mC=(e,t=[])=>[...new Set([...dC,...e.error,...t])],hC=Symbol.for(`@gjermundgaraba/effect-actions/Anyone`),gC=/^[A-Za-z0-9_-]{1,128}$/,_C=(e,t)=>{if(!gC.test(t)||t===`then`)throw Error(`Invalid ${e}: ${t}`)},vC=(e,t,n,r=n)=>{let i=new Map;for(let a of t){let t=n(a),o=r(a),s=i.get(t);if(s!==void 0){let n=s===o?``:`, claimed by ${s} and ${o}`;throw Error(`Duplicate ${e}: ${t}${n}`)}i.set(t,o)}},yC=(e,t)=>vC(e,t,e=>e.name),bC=e=>v_(e)?bC(e.thunk()):e,xC=e=>{let t=bC(e);return __(t)?t.types.flatMap(xC):[t]},SC=e=>f_(e)?[e.literal]:m_(e)?e.enums.map(([,e])=>e):[void 0],CC=e=>xC(ay(e)).flatMap(e=>{let t=g_(e)?e.propertySignatures.find(e=>e.name===`_tag`)?.type:void 0;return t===void 0?[]:xC(t).flatMap(SC).filter(Bn)}),wC=(e,t)=>{let n=t.flatMap(e=>CC(e.ast)).find(e=>Object.hasOwn(iC,e));if(n!==void 0)throw Error(`${e}: error _tag "${n}" is built in, and declared on every surface`)},TC=(e,t)=>t.length===0?Hb(uS(e.input))({}):R(t[0]),EC=ox(q,Zb),DC=e=>Kb(e)?e:Reflect.ownKeys(e).length===0?EC:J(e);function X(e,t){_C(`action name`,e);let{caller:n,readOnly:r}=t;if(n!==hC&&!co(n))throw Error(`Missing caller: declare Action.Anyone or an identity service key`);if(n!==hC&&lo(n))throw Error(`Invalid caller: an identity is a Context.Service, not a Context.Reference`);if(r!==!0&&r!==!1)throw Error(`Invalid readOnly: ${String(r)}`);let i={caller:n,name:e,description:t.description,input:DC(t.input??{}),success:t.success===void 0?rx:DC(t.success),error:pC(t.error),readOnly:r,mcp:{...t.mcp}};return wC(`Action "${i.name}"`,i.error),i}var OC=(e,t)=>{for(let n of e)if(n.caller!==hC&&(t===void 0||n.caller.key!==t.identity.key))throw Error(`Protected action '${n.name}' requires its matching authentication descriptor`)},kC=`~effect/http/HttpBody`,AC=e=>S(e,kC),jC=class{[kC];constructor(){this[kC]=kC}[Jr](){return this.toJSON()}toString(){return E(this,{ignoreToString:!0})}},MC=new class extends jC{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},NC=class extends jC{_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??=LC(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}}},PC=(e,t)=>new NC(e,t??`application/octet-stream`,e.length),FC=new TextEncoder,IC=globalThis.Buffer,LC=IC===void 0?e=>FC.encode(e):e=>IC.from(e,`utf8`),RC=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),IC!==void 0)return new NC(void 0,t??`text/plain`,IC.byteLength(e,`utf8`),e);let n=FC.encode(e);return new NC(n,t??`text/plain`,n.length,e)},zC=(e,t)=>RC(Lh(kh(e)),t??`application/x-www-form-urlencoded`),BC=class extends jC{_tag=`FormData`;contentType=void 0;contentLength=void 0;formData;constructor(e){super(),this.formData=e}toJSON(){return{_id:`effect/HttpBody`,_tag:`FormData`,formData:this.formData}}},VC=e=>new BC(e),HC=`~effect/http/HttpClientError`,UC=class extends Hs(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[HC]=HC;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},WC=e=>e.endsWith(`Error`)?e.slice(0,-5):e,GC=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,KC=class extends Hs(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return GC(WC(this._tag),this.description,this.methodAndUrl)}},qC=class extends Hs(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return GC(WC(this._tag),this.description,this.methodAndUrl)}},JC=class extends Hs(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return GC(WC(this._tag),this.description,e)}},YC=class extends Hs(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return GC(WC(this._tag),this.description,e)}},XC=class extends Hs(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return GC(WC(this._tag),this.description,e)}},ZC=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,QC=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],$C=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?xh(xh(e,`content-type`),`content-length`):(e=t.contentType===void 0?xh(e,`content-type`):vh(e,`content-type`,t.contentType),t.contentLength===void 0?xh(e,`content-length`):vh(e,`content-length`,t.contentLength.toString())),ew=class extends Hs(`UrlError`){},tw=(e,t,n)=>Oo({try:()=>{let r=new URL(e,nw());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 ew({cause:e})}),nw=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},rw=`~effect/http/HttpClientRequest`,iw={[rw]:rw,...Xr,toJSON(){return{_id:`HttpClientRequest`,method:this.method,url:this.url,urlParams:this.urlParams,hash:this.hash,headers:Pr(this.headers),body:this.body.toJSON()}},pipe(){return y(this,arguments)}};function aw(e,t,n,r,i,a){let o=Object.create(iw);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var ow=aw(`GET`,``,Nh,Ia(),hh,MC),sw=e=>(t,n)=>cw(ow,{method:e,url:t,...n??void 0}),cw=b(2,(e,t)=>{let n=e;return t.method&&(n=lw(n,t.method)),t.url&&(n=mw(n,t.url)),t.headers&&(n=dw(n,t.headers)),t.urlParams&&(n=_w(n,t.urlParams)),t.hash&&(n=yw(n,t.hash)),t.body&&(n=bw(n,t.body)),t.accept&&(n=fw(n,t.accept)),t.acceptJson&&(n=pw(n)),n}),lw=b(2,(e,t)=>aw(t,e.url,e.urlParams,e.hash,e.headers,e.body)),uw=b(3,(e,t,n)=>aw(e.method,e.url,e.urlParams,e.hash,vh(e.headers,t,n),e.body)),dw=b(2,(e,t)=>aw(e.method,e.url,e.urlParams,e.hash,yh(e.headers,t),e.body)),fw=b(2,(e,t)=>uw(e,`Accept`,t)),pw=fw(`application/json`),mw=b(2,(e,t)=>{if(typeof t==`string`)return aw(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=kh(n.searchParams),i=Ha(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,aw(e.method,n.toString(),r,i,e.headers,e.body)}),hw=b(2,(e,t)=>t===``?e:aw(e.method,gw(t,e.url),e.urlParams,e.hash,e.headers,e.body)),gw=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},_w=b(2,(e,t)=>aw(e.method,e.url,Fh(e.urlParams,t),e.hash,e.headers,e.body)),vw=b(2,(e,t)=>aw(e.method,e.url,Ih(e.urlParams,t),e.hash,e.headers,e.body)),yw=b(2,(e,t)=>aw(e.method,e.url,e.urlParams,La(t),e.headers,e.body)),bw=b(2,(e,t)=>aw(e.method,e.url,e.urlParams,e.hash,$C(e.headers,t),t)),xw=b(2,(e,t)=>bw(e,VC(t)));function Sw(e){let t=tw(e.url,e.urlParams,Ua(e.hash));return Ao(t)?La(t.success):Ia()}var Cw=`~effect/http/HttpIncomingMessage`,ww=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=nm(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=nm(e.text)}catch{}let i={...t,headers:Pr(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},Tw=`~effect/http/HttpClientResponse`,Ew=(e,t)=>new Dw(e,t),Dw=class extends Zr{[Cw];[Tw];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[Cw]=Cw,this[Tw]=Tw}toJSON(){return ww(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=Sw(this.request);return Ra(e)?``:(e.value.hash=``,e.value.href)}get headers(){return gh(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=th(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return Ia()}get stream(){return this.source.body?qS({evaluate:()=>this.source.body,onError:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}):KS(new UC({reason:new XC({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return B(this.text,e=>Dp({try:()=>e===``?null:JSON.parse(e),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=Np(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return B(this.text,e=>Dp({try:()=>kh(new URLSearchParams(e)),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=yp({try:()=>this.source.formData(),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}).pipe(Jp,nm)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=yp({try:()=>this.source.arrayBuffer(),catch:e=>new UC({reason:new YC({request:this.request,response:this,cause:e})})}).pipe(Jp,nm),this.arrayBufferBody}pipe(){return y(this,arguments)}},Ow=e=>_h({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Ba(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),kw={"http:":80,"https:":443,"ws:":80,"wss:":443},Aw=(e,t)=>{let n=t.search.slice(1);if(e.attribute(`url.full`,t.toString()),e.attribute(`url.path`,t.pathname),n!==``&&e.attribute(`url.query`,n),e.attribute(`url.scheme`,t.protocol.slice(0,-1)),t.hostname!==``){e.attribute(`server.address`,t.hostname.startsWith(`[`)?t.hostname.slice(1,-1):t.hostname);let n=t.port===``?kw[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},jw=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,Ch(a,i)?`<redacted>`:n[a])},Mw=`~effect/http/HttpClient`,Nw=j(`effect/HttpClient`),Pw=b(2,(e,t)=>Fw(n=>t(e.postprocess(n)),e.preprocess)),Fw=(e,t)=>{let n=Object.create(Iw);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Iw={[Mw]:Mw,pipe(){return y(this,arguments)},...Xr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(QC.map(([e,t])=>[t,function(t,n){return this.execute(sw(e)(t,n))}]))},Lw=e=>Fw(t=>B(t,t=>Op(n=>{let r=Kw.get(t),i=r??new AbortController,a=tw(t.url,t.urlParams,Ua(t.hash));if(ko(a))return z(new UC({reason:new qC({request:t,cause:a.failure})}));let o=a.success;if(n.getRef($s)||n.getRef(Bw)(t)){let a=e(t,o,i.signal,n);return r?a:Xp(e=>zp(e(a),{onSuccess(e){return Gw.register(e,i),R(new qw(e,i))},onFailure(e){return Zd(e)&&i.abort(),wp(e)}}))}return Qp(n.getRef(Uw)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(wh);Aw(a,o);let c=n.getRef(Vw);return jw(a,`request`,t.headers,c,s),t=n.getRef(Hw)?dw(t,Ow(a)):t,Xp(l=>l(e(t,o,i.signal,n)).pipe($p(a,{captureStackTrace:!1}),zp({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),jw(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),Rw(n,a,t,e)),r?R(e):(Gw.register(e,i),R(new qw(e,i)))),onFailure(e){return!r&&Zd(e)&&i.abort(),wp(e)}})))})})),R),Rw=(e,t,n,r)=>{let i=$r();ei(0);let a;try{a=rf(new UC({reason:new JC({request:n,response:r})}))}finally{ei(i)}t.end(e.getRef(ff)?e.getRef(Wf).currentTimeNanosUnsafe():BigInt(0),a)},zw=b(2,(e,t)=>Fw(e.postprocess,n=>Np(e.preprocess(n),t))),Bw=M(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>An}),Vw=M(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>An}),Hw=M(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:kn}),Uw=M(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),Ww=e=>Ff(Nw)(Vp(t=>Np(e,e=>Pw(e,Wp(e=>Co(t,e)))))),Gw=(()=>{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 WeakMap;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))}}})(),Kw=new WeakMap,qw=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[Tw]=Tw;[Cw]=Cw;applyInterrupt(e){return bp(()=>(Gw.unregister(this.original),Yp(e,()=>xp(()=>{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 GS(()=>(Gw.unregister(this.original),ZS(this.original.stream,xp(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Jr](){return this.original[Jr]()}pipe(){return y(this,arguments)}},Jw=M(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),Yw=class extends j()(`effect/http/FetchHttpClient/RequestInit`){},Xw=Ww(R(Lw((e,t,n,r)=>{let i=r.getRef(Jw),a=go(r.context,Yw)??{},o=a.headers?bh(gh(a.headers),e.headers):e.headers;o[`content-length`]&&(o=xh(o,`content-length`));let s=r=>Np(yp({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 UC({reason:new KC({request:e,cause:t})})}),t=>Ew(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 B(tC(e.body.stream),s)}return s(void 0)})));({...fi});var Zw=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")Zw[e.charCodeAt(0)]=1;var Qw=new Uint8Array(256);Qw[9]=1;for(let e=32;e<=126;e++)Qw[e]=1;for(let e=128;e<=255;e++)Qw[e]=1;var $w=j(`effect/http/HttpServerRequest`),eT=new WeakSet,tT=e=>Op(t=>{let n=vo(t.context,$w);return eT.add(n.source),e}),nT=j(`effect/http/HttpRouter`),rT=e=>e.endsWith(`/`)?e.slice(0,-1):e,iT=b(2,(e,t)=>(t=rT(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),aT=`~effect/http/HttpRouter/Middleware`,oT=function(){return arguments.length===0?sT:sT(arguments[0],arguments[1])},sT=(e,t)=>t?.global?Rf(Cp(function*(){let t=yield*nT,n=gp(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new uT(gp(e)?Lf(Np(e,e=>io(new Map([[lT,e]])))):Pf(io(new Map([[lT,e]])))),cT=0,lT=`effect/http/HttpRouter/MiddlewareFn`,uT=class e{[aT]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++cT}`;this.layer=Lf(Cp({self:this},function*(){let e=yield*Bp(),t=[_o(e,lT)];if(this.dependencies){let n=yield*jf,r=yo(e,pf),i=yield*Mf(this.dependencies,n,r);t.push(...fT(i))}return io(new Map([[n,t]]))})).pipe(Hf(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?Uf(this.dependencies,t.layer):t.layer)}},dT=new WeakMap,fT=e=>{let t=dT.get(e);if(t)return t;let n=Ko(),r=0;for(let[t,i]of e.mapUnsafe)t.startsWith(`effect/http/HttpRouter/Middleware-`)&&(n.push(i),i.length>r&&(r=i.length));if(n.length===0)t=[];else{let e=new Set;for(let t=r-1;t>=0;t--)for(let r of n)t<r.length&&e.add(r[t]);t=zo(e).reverse()}return dT.set(e,t),t};oT(tT).layer;var pT={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,OK:200,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511},mT=e=>pT[e],hT=`~effect/encoding/Sse/SseError`,gT=class extends Hs(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},_T=class extends Hs(`SseError`){[hT]=hT;get message(){return this.reason.message}},vT=10485760,yT=e=>yS((t,n)=>xp(()=>{let n=[],r,i=xT(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=B(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return z(n)}return Sp});return bp(function e(){if(Uo(n)){let e=n;return n=[],R(e)}return r?z(r):B(a,e)})})),bT=(e,t,n)=>kS(yT(t),IS(CT.pipe(hx(e,wT)),n)());function xT(e,t){let n=t?.maxEventSize??vT,r,i,a,o,s,c,l,u;return d(),{feed:f,reset:d};function d(){r=!0,i=``,a=0,o=-1,s=!1,c=void 0,l=void 0,u=``}function f(e){i=i?i+e:e,r&&i.startsWith(ST)&&(i=i.slice(ST.length)),r=!1;let t=i.length,c=0;for(;c<t;){s&&=(i[c]===`
10
- `&&++c,!1);let e=-1,n=o,r;for(let o=c+a;e<0&&o<t;++o)r=i[o],r===`:`&&n<0?n=o-c:r===`\r`?(s=!0,e=o-c):r===`
11
- `&&(e=o-c);if(e<0){a=t-c,o=n;break}a=0,o=-1,p(i,c,n,e),c+=e+1}if(c===t?i=``:c>0&&(i=i.slice(c)),i.length+u.length>n){let e=new _T({reason:new gT({maxEventSize:n})});return d(),e}}function p(t,n,r,i){if(i===0){u.length>0&&(e({_tag:`Event`,id:c,event:l||`message`,data:u.slice(0,-1)}),u=``),l=void 0;return}let a=r<0,o=t.slice(n,n+(a?i:r)),s=0;s=a?i:t[n+r+1]===` `?r+2:r+1;let d=n+s,f=i-s,p=t.slice(d,d+f).toString();o===`data`?u+=p?`${p}\n`:`
12
- `:o===`event`?l=p:o===`id`&&!p.includes(`\0`)?c=p:o===`retry`&&/^\d+$/.test(p)&&e(new ET({duration:ys(parseInt(p,10)),lastEventId:c}))}}var ST=``,CT=J({_tag:vx(`Event`),id:mx(q),event:q,data:q}),wT=Jg({decode:e=>e.id===void 0?{event:e.event,data:e.data}:{id:e.id,event:e.event,data:e.data},encode:e=>({_tag:`Event`,id:e.id,event:e.event??`message`,data:e.data})}),TT=`~effect/encoding/Sse/Retry`,ET=class e extends Vs(`Retry`){[TT]=TT;static is(e){return S(e,TT)}static filter(t){return e.is(t)?Eo(t):Do(t)}},DT=`~effect/http-api/HttpApiSchema/Stream`;function OT(e){let t=typeof e==`string`?mT(e):e;return e=>e.annotate({httpApiStatus:t})}var kT=(e=>rx.pipe(OT(e)))(204),AT=e=>Kb(e)&&S(e,DT),jT=e=>AT(e)&&e._tag===`StreamSse`,MT=e=>AT(e)&&e._tag===`StreamUint8Array`,NT=`~effect/http-api/HttpApiSchema/WithHeaders`,PT=`~effect/http-api/HttpApiSchema/WithHeadersValue`,FT=e=>({[PT]:PT,body:e.body,headers:e.headers}),IT=e=>Kb(e)&&S(e,`~effect/http-api/HttpApiSchema/WithHeaders`);function LT(e,t,n){return K(e.ast,{[NT]:NT,schema:t,headers:n})}function RT(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??zT(t._tag)}})}function zT(e){switch(e){case`Multipart`:return`multipart/form-data`;case`Json`:return`application/json`;case`FormUrlEncoded`:return`application/x-www-form-urlencoded`;case`Uint8Array`:return`application/octet-stream`;case`Text`:return`text/plain`}}function BT(e){return t=>RT(t,{_tag:`Json`,...e})}function VT(e){return t=>RT(t,{_tag:`FormUrlEncoded`,...e})}var HT=e=>{if(u_(e)||u_(ay(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&u_(t)},UT=xy(`~httpApiEncoding`),WT=xy(`~httpApiWithHeaders`),GT=xy(`httpApiStatus`),KT={_tag:`Json`,contentType:`application/json`},qT={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function JT(e){return UT(e)??KT}function YT(e,t){return UT(e)||(ZC(t)?KT:qT)}function XT(e){let t=JT(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function ZT(e){return GT(e)??200}function QT(e){return IT(e)?GT(e.ast)??ZT(e.schema.ast):ZT(e.ast)}function $T(e){return IT(e)&&UT(e.ast)===void 0?XT(e.schema.ast):XT(e.ast)}function eE(e){return GT(e)??500}function tE(e){return IT(e)?GT(e.ast)??eE(e.schema.ast):eE(e.ast)}function nE(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var rE=`~effect/http-api/HttpApiEndpoint`;function iE(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function aE(e){let t=Array.from(e.success);return Uo(t)?t:[kT]}function oE(e){let t=new Set(e.error),n=e.disableCodecs?x:hE;for(let r of e.middlewares){let e=r;for(let r of e.error)t.add(n(r))}return Array.from(t)}var sE={[rE]:rE,pipe(){return y(this,arguments)},prefix(e){return lE({...cE(this),path:iT(this.path,e)})},middleware(e){return lE({...cE(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return lE({...cE(this),annotations:mo(this.annotations,e,t)})},annotateMerge(e){return lE({...cE(this),annotations:Co(this.annotations,e)})}},cE=e=>({identifier:e.identifier,path:e.path,method:e.method,params:e.params,query:e.query,headers:e.headers,payload:e.payload,success:e.success,error:e.error,annotations:e.annotations,middlewares:e.middlewares,disableCodecs:e.disableCodecs});function lE(e){function t(){}return Object.setPrototypeOf(t,sE),Object.assign(t,e)}var uE=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?x:dS;return lE({identifier:t,path:n,method:e,params:dE(r?.params,a),query:dE(r?.query,a),headers:dE(r?.headers,a),payload:fE(r?.payload,e,i),success:mE(r?.success,e,i),error:gE(r?.error,i),annotations:uo(),middlewares:new Set,disableCodecs:i})};function dE(e,t){if(e!==void 0)return Kb(e)?t(e):t(J(e))}function fE(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:Kb(e)?[e]:[J(e).pipe(VT())],a=n?x:EE;for(let e of i){let n=YT(e.ast,t),i=nE(n.contentType),o=r.get(i);if(o){if(o.encoding._tag!==n._tag)throw Error(`Multiple payload encodings for content-type: ${n.contentType}`);if(o.encoding._tag===`Multipart`)throw Error(`Multiple multipart payloads for content-type: ${n.contentType}`);o.schemas.push(a(e,t))}else r.set(i,{encoding:n,schemas:[a(e,t)]})}return r}var pE=`effect/http-api/stream/failure`;function mE(e,t,n){if(e===void 0)return new Set;let r=Bo(e);return _E(r,t),new Set(n?r:r.map(hE))}var hE=Nn(e=>AT(e)?e:IT(e)?LT(e,AT(e.schema)?e.schema:TE(e.schema,$T(e)),dS(e.headers)):wE(e));function gE(e,t){if(e===void 0)return new Set;let n=Bo(e);for(let e of n)if(AT(IT(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return yE(n,tE),new Set(t?n:n.map(hE))}function _E(e,t){let n=!1,r=new Map;for(let i of e){let e=IT(i)?i.schema:i,a=QT(i);if(AT(e)){if(bE(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=vE(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(nE(e.contentType)))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`);r.set(a,{...i,stream:e})}else{let t=vE(r,a),n=HT(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=$T(i);if(nE(e.contentType)===nE(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(nE($T(i).contentType)),t.noContent=t.noContent||n}}yE(e,QT)}function vE(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function yE(e,t){let n=new Map;for(let r of e){let e=t(r),i=WT(r.ast),a=IT(r)?r.schema:i?.body??r,o=HT(a.ast)?``:nE(AT(a)?a.contentType:$T(r).contentType),s=n.get(e);s===void 0&&(s={headerContentType:void 0,plainContentTypes:new Set},n.set(e,s));let c=()=>Error(`Cannot combine a response with headers with another response for status ${e} and content-type: ${o||`<no content>`}`);if(IT(r)||i!==void 0){if(s.headerContentType!==void 0)throw Error(`Cannot declare multiple responses with headers for status ${e}`);if(s.plainContentTypes.has(o))throw c();s.headerContentType=o}else{if(s.headerContentType===o)throw c();s.plainContentTypes.add(o)}}}function bE(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(jT(e)&&xE(e.events.ast))throw Error(`SSE event name is reserved: ${pE}`)}function xE(e){return SE(ay(e),new Set)}function SE(e,t){if(t.has(e))return!1;if(t.add(e),__(e))return e.types.some(e=>SE(e,t));if(v_(e))return SE(e.thunk(),t);if(!g_(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&CE(n.type,t)}function CE(e,t){if(t.has(e))return!1;t.add(e);let n=ay(e);return n===e?f_(e)?e.literal===pE:__(e)?e.types.some(e=>CE(e,t)):v_(e)?CE(e.thunk(),t):!1:CE(n,t)}function wE(e){let t=XT(e.ast),n=WT(e.ast);return n===void 0?TE(e,t):e.annotate({"~httpApiWithHeaders":{...n,bodyCodec:TE(n.body,t),headersCodec:dS(n.headers)}})}function TE(e,t){switch(t._tag){case`Json`:return uS(e);case`FormUrlEncoded`:return dS(e);case`Text`:case`Uint8Array`:return e}}function EE(e,t){switch(YT(e.ast,t)._tag){case`Json`:return uS(e);case`FormUrlEncoded`:return dS(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var DE=uE(`POST`),OE=`~effect/http-api/HttpApi`,kE={[OE]:OE,pipe(){return y(this,arguments)},add(...e){let t={...this.groups};for(let n of e)ri(t,n.identifier,n);return jE({...AE(this),groups:t})},addHttpApi(e){let t={...this.groups};for(let n of Object.keys(e.groups)){let r=e.groups[n];ri(t,n,r.annotateMerge(Co(e.annotations,r.annotations)))}return jE({...AE(this),groups:t})},prefix(e){return jE({...AE(this),groups:Po(this.groups,t=>t.prefix(e))})},middleware(e){return jE({...AE(this),groups:Po(this.groups,t=>t.middleware(e))})},annotate(e,t){return jE({...AE(this),annotations:mo(this.annotations,e,t)})},annotateMerge(e){return jE({...AE(this),annotations:Co(this.annotations,e)})}},AE=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),jE=e=>{function t(){}return Object.setPrototypeOf(t,kE),Object.assign(t,e)},ME=e=>jE({identifier:e,groups:{},annotations:uo()}),NE=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=Co(e.annotations,r.annotations);t.onGroup({group:r,mergedAnnotations:n});let i=Object.values(r.endpoints);for(let e of i)(!t.predicate||t.predicate({endpoint:e,group:r}))&&t.onEndpoint({group:r,endpoint:e,middleware:e.middlewares,mergedAnnotations:Co(n,e.annotations),successes:PE(aE(e),QT),errors:PE(oE(e),tE)})}},PE=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(AT(IT(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}},FE=class extends j()(`effect/http-api/HttpApi/ParseOptions`){},IE=class extends j()(`effect/http-api/HttpApi/ParamsParseOptions`){},LE=class extends j()(`effect/http-api/HttpApi/QueryParseOptions`){},RE=class extends j()(`effect/http-api/HttpApi/HeadersParseOptions`){},zE=class extends j()(`effect/http-api/HttpApi/PayloadParseOptions`){},BE=class extends j()(`effect/http-api/HttpApi/SuccessParseOptions`){},VE=class extends j()(`effect/http-api/HttpApi/ErrorParseOptions`){},HE=e=>{let t=go(e,FE);return{params:go(e,IE)??t,query:go(e,LE)??t,headers:go(e,RE)??t,payload:go(e,zE)??t,success:go(e,BE)??t,error:go(e,VE)??t}},UE=`~effect/http-api/HttpApiMiddleware`,WE=`~effect/http-api/HttpApiMiddleware/Security`,GE=()=>(e,t)=>{let n=$r(),r;n!==0&&(ei(2),r=new globalThis.Error,ei(n));class i extends j()(e){}let a=i;if(Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[UE]=UE,a.error=KE(t?.error),a.requiredForClient=t?.requiredForClient??!1,t?.security!==void 0){if(Object.keys(t.security).length===0)throw Error(`HttpApiMiddleware.Service: security object must not be empty`);a[WE]=WE,a.security=t.security}return a};function KE(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var qE=new Set;function JE(e){if(e===void 0)return qE;let t=Fv(e.ast);return g_(t)&&t.indexSignatures.length===0?new Set(t.propertySignatures.map(e=>String(e.name))):void 0}var YE=class extends j()(`effect/http-api/OpenApi/Description`){},XE=(e,t)=>Cp(function*(){let n=yield*Bp(),r=t.httpClient.pipe(t?.baseUrl===void 0?x:zw(hw(t.baseUrl.toString())));function i(e,t,a,o,s){if(s===-1)return r.execute(a);let c=n.mapUnsafe.get(o[s]);return c===void 0?i(e,t,a,o,s-1):c({endpoint:t,group:e,request:a,next(n){return i(e,t,n,o,s-1)}})}NE(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o,mergedAnnotations:s}=e,c=HE(s),l=eD(r.path,r.params),u={orElse:bD},d=new Map;for(let[e,t]of a.entries()){let n=oD(t);for(let[t,r]of n.entries())iD(d,e,t,tD(r,c.error,c.headers))}for(let[e,t]of d.entries()){let n=aD(t);u[e]=e=>B(Lp(n(e),t=>wp(Yd(Ud(new UC({reason:new JC({request:e.request,response:e})})),t))),z)}let f=new Map;for(let[e,t]of o.entries()){let n=oD(t);for(let[t,r]of n.entries())iD(f,e,t,tD(r,c.success,c.headers))}for(let e of uD(r)){let t=lD(e)?e.schema:e;iD(f,QT(e),t.contentType,dD(e,c.success,c.headers))}for(let[e,t]of f.entries())u[e]=aD(t);let p=nC(r.params,e=>Gb(e,c.params)),m=iE(r),h=Uo(m)?Gb(ZC(r.method)?SD(m,r.method):dx(m),c.payload):void 0,ee=nC(r.headers,e=>Gb(e,c.headers)),te=nC(r.query,e=>Gb(e,c.query)),ne=Array.from(e.middleware,e=>`${e.key}/Client`),re=im(function*(e){let a=sw(r.method)(r.path);if(e!==void 0){if(p!==void 0){let t=yield*p(e.params);a=mw(a,l(t))}if(h!==void 0){if(ZC(r.method)){if(e.payload instanceof FormData)a=xw(a,e.payload);else{let t=yield*h(e.payload);a=bw(a,t)}}else{let t=yield*h(e.payload);a=vw(a,t)}}if(ee!==void 0){let t=yield*ee(e.headers);a=dw(a,t)}if(te!==void 0){let t=yield*te(e.query);a=vw(a,t)}}let o=yield*i(n,r,a,ne,ne.length-1);if(e?.responseMode===`response-only`)return o;let s=(u[o.status]??u.orElse)(o,e?.sseOptions),c=yield*t.transformResponse===void 0?s:t.transformResponse(s);return e?.responseMode===`decoded-and-response`?[c,o]:c});t.onEndpoint({...e,endpointFn:re})}})}),ZE=(e,t)=>B(Nw,n=>QE(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),QE=(e,t)=>{let n={};return XE(e,{...t,onGroup({group:e}){e.topLevel||ri(n,e.identifier,{})},onEndpoint({endpoint:e,endpointFn:t,group:r}){ri(r.topLevel?n:n[r.identifier],e.identifier,t)}}).pipe(Pp(n))},$E=/(\/?):(\w+)(\?)?/g,eD=(e,t)=>{if(t===void 0||!e.includes(`:`))return t=>e;let n=JE(t);return t=>e.replace($E,(e,r,i,a)=>{if(n!==void 0&&!n.has(i))return e;let o=t[i];if(o===void 0){if(a!==void 0)return``;throw Error(`Missing path parameter: ${i}`)}return`${r}${encodeURIComponent(o)}`})};function tD(e,t,n){let r=e.some(e=>IT(e)||WT(e.ast)!==void 0),i=Hb(r?dx(e.map(e=>rD(e,t,n))):vD(e),t);return e=>B(e.arrayBuffer,r?t=>i({body:t,headers:e.headers}):i)}var nD=J({body:Qb,headers:Qb});function rD(e,t,n){let r=WT(e.ast),i=r===void 0?IT(e)?{body:e.schema,headers:e.headers,toValue:FT}:{body:e,headers:Qb,toValue:e=>e.body}:{body:r.bodyCodec,headers:r.headersCodec,toValue:r.transformation.decode},a=Hb(yD(i.body).pipe(hx(i.body)),t),o=Hb(i.headers,n);return nD.pipe(hx(IT(e)?e:Yb(e),qg({decode:e=>_p({body:a(e.body),headers:o(e.headers)}).pipe(Np(i.toValue),Rp(e=>e.issue)),encode:(e,t)=>z(new cg({message:`Decode only schema`},e,t))})))}function iD(e,t,n,r){let i=nE(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function aD(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:(t,n)=>{let r=nE(t.headers[`content-type`]??``),i=e.find(e=>e.contentType===r);return i===void 0?sD(t,r,e):i.decode(t,n)}}function oD(e){let t=new Map;for(let n of e){let e=HT((IT(n)?n.schema:n).ast)?``:nE($T(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function sD(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return z(new UC({reason:new YC({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var cD=`effect/http-api/stream/failure`,lD=e=>IT(e);function uD(e){let t=[];for(let n of e.success)AT(IT(n)?n.schema:n)&&t.push(n);return t}function dD(e,t,n){let r=lD(e),i=r?e.schema:e,a=MT(i)?void 0:{declaration:i,decoder:fD(i,t)},o=(e,t)=>Np(Bp(),n=>QS(a===void 0?e.stream:pD(e.stream,a.declaration,a.decoder(t)),n));if(!r)return o;let s=Hb(e.headers,n);return(e,t)=>B(s(e.headers),n=>Np(o(e,t),e=>FT({body:e,headers:n})))}function fD(e,t){let n=dx([J({id:Jb(q),event:Xb(cD),data:Vx(uS(Kx(e.error,zx())))}),e.events]),r=bT(n,void 0,t);return e=>e===void 0?r:bT(n,e,t)}function pD(e,t,n){let r=WS(e.pipe(XS,YS(n)),e=>xp(()=>{let t;return bp(()=>t===void 0?B(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===cD&&zd(r.data)){if(n===0)return wp(r.data);t=r.data,e=e.slice(0,n);break}}return R(e)}):wp(t))}));return t.sseMode===`data`?JS(r,e=>e.data):r}var mD=bx(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),hD=mD.pipe(hx(Wx,Jg({decode(e){return new Uint8Array(e)},encode(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}))),gD=mD.pipe(hx(q,Jg({decode(e){return new TextDecoder().decode(e)},encode(e){let t=new TextEncoder().encode(e);return t.byteLength===t.buffer.byteLength?t.buffer:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}}))),_D=gD.pipe(hx(dx([Xb(``).pipe(hx(ex,Jg({decode:()=>void 0,encode:()=>``}))),Hx])));function vD(e){return dx(e.map(t));function t(e){return yD(e).pipe(hx(e))}}function yD(e){switch(XT(e.ast)._tag){case`Json`:return l_(ay(e.ast))?_D.pipe(hx(Qb,Jg({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):_D;case`FormUrlEncoded`:return gD.pipe(hx(eS,Jg({decode:e=>kh(new URLSearchParams(e)),encode:Lh})));case`Uint8Array`:return hD;case`Text`:return gD}}var bD=e=>z(new UC({reason:new YC({request:e.request,response:e})})),xD=Pb(AC);function SD(e,t){return dx(e.map(e=>wD(e,t)))}var CD=new WeakMap;function wD(e,t){let n=e.ast,r=CD.get(n);if(r!==void 0)return r;let i=YT(n,t),a=xD.pipe(hx(e,qg({decode(e,t){return z(new cg({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return z(new cg({message:`Payload must be a FormData`},e,t));case`Json`:try{return R(RC(JSON.stringify(e),i.contentType))}catch{return z(new og({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?R(RC(e,i.contentType)):z(new og({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Yn(e)?R(zC(kh(e),i.contentType)):z(new og({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?R(PC(e,i.contentType)):z(new og({message:`Expected a Uint8Array`},e,t))}}})));return CD.set(n,a),a}var TD=`~effect/http-api/HttpApiGroup`,ED={[TD]:TD,add(...e){let t={...this.endpoints};for(let n of e)ri(t,n.identifier,n);return OD({...DD(this),endpoints:t})},prefix(e){return OD({...DD(this),endpoints:Po(this.endpoints,t=>t.prefix(e))})},middleware(e){return OD({...DD(this),endpoints:Po(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return OD({...DD(this),annotations:Co(this.annotations,e)})},annotate(e,t){return OD({...DD(this),annotations:mo(this.annotations,e,t)})},annotateEndpointsMerge(e){return OD({...DD(this),endpoints:Po(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return OD({...DD(this),endpoints:Po(this.endpoints,n=>n.annotate(e,t))})},pipe(){return y(this,arguments)}},DD=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),OD=e=>{function t(){}return Object.setPrototypeOf(t,ED),t.key=`effect/http-api/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},kD=(e,t)=>OD({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:uo()}),AD=`~effect/http-api/HttpApiSecurity`,jD={[AD]:AD,pipe(){return y(this,arguments)}},MD=(e=>Object.assign(Object.create(jD),{_tag:`Http`,scheme:e.scheme,schemeLength:e.scheme.length,annotations:uo()}))({scheme:`Bearer`}),ND=e=>Object.assign(Object.create(jD),{_tag:`ApiKey`,key:e.key,in:e.in??`header`,annotations:uo()}),PD=xy(`httpApiStatus`),FD=e=>PD(e)??(v_(e)?FD(e.thunk()):void 0),ID=e=>{let t=FD(e.ast);if(t!==void 0)return[PD(e.ast)===void 0?OT(t)(e):e];let n=bC(e.ast);return __(n)&&n.checks===void 0&&n.encoding===void 0?n.types.flatMap(e=>ID(K(e))):[OT(422)(e)]},LD=(e,t={})=>Np(ZE(e.api,t),e=>{let t=e;return e=>{let n=t[e.name];if(n===void 0)throw Error(`No client method for ${e.name}`);let r=Gb(uS(e.input),{errors:`all`});return(...t)=>TC(e,t).pipe(jp(r),Rp(sC.fromSchemaError),B(e=>n({payload:e})))}}),RD=e=>(e??`/api`).split(`/`).filter(e=>e!==``),zD=e=>`/${e.join(`/`)}`,BD=e=>e.join(`/`)||`/`,VD=(e,t)=>{let n=kD(e,{topLevel:!0}),[r,...i]=t;return ME(`actions`).annotate(FE,{errors:`all`}).add(r===void 0?n:n.add(r,...i))},HD=(e,t,n)=>DE(e.name,t,{payload:e.input.pipe(BT()),success:e.success,error:mC(e,n).flatMap(ID)});function UD(e,t={}){yC(`action`,e);let n=pC(t.error);wC(`ActionHttp binding`,n),OC(e,t.authentication);let r=RD(t.prefix),i=t.authentication?.[`~middleware`],a=t.authentication?.error??[],o=e.map(e=>{let t=i===void 0||e.caller===hC,o=HD(e,zD([...r,e.name]),t?n:[...n,...a]).annotate(YE,e.description);return t?o:o.middleware(i)}),s=VD(BD(r),o);return{actions:e,error:n,prefix:zD(r),api:s,authentication:t.authentication}}GE()(`effect-actions/ActionHttp/StepUp`),GE()(`effect-actions/ActionHttp/JsonContentType`);var WD=(e,t)=>Np(LD(e,t),t=>Object.fromEntries(e.actions.map(e=>[e.name,t(e)])));function GD(e,{fetch:t,...n}={}){return WD(e,n).pipe(Hp(Xw),Gp(Jw,t??((e,t)=>globalThis.fetch(e,t))),nm)}var KD=/^[\w.-]+$/,qD=(e,t,...n)=>{let r=n[0]?.security??MD,i=pC(n[0]?.error);if(!KD.test(e))throw Error(`Invalid authentication name: ${JSON.stringify(e)}, not an OpenAPI key`);if(wC(`Authentication "${e}"`,i),!Zn(r,`Http`)&&!Zn(r,`ApiKey`)&&!Zn(r,`Basic`))throw Error(`Authentication takes one native HttpApiSecurity scheme`);return{name:e,identity:t,security:r,error:i,"~provider":j(`effect-actions/Authentication/Provider/${e}`),"~middleware":GE()(`effect-actions/Authentication/Security/${e}`,{security:{[e]:r}}),"~verified":j(`effect-actions/Authentication/Verified/${e}`)}},JD=[class extends lS()(`BadRequest`,{error:q},{httpApiStatus:400}){},class extends lS()(`NotFound`,{error:q},{httpApiStatus:404}){},class extends lS()(`Conflict`,{error:q},{httpApiStatus:409}){},class extends lS()(`TooManyRequests`,{error:q},{httpApiStatus:429}){},class extends lS()(`InternalServerError`,{error:q},{httpApiStatus:500}){cause},class extends lS()(`ServiceUnavailable`,{error:q},{httpApiStatus:503}){}];[...JD];var YD=class extends j()(`clankerauth/CurrentOwner`){},XD=(e=>qD(`clankerauth.OwnerSession`,YD,{security:ND({in:`cookie`,key:e}),error:JD}))(`better-auth.session_token`);qD(`clankerauth.OwnerToken`,YD,{error:JD});var ZD=J({email:q,password:q}),QD=fx([`none`,`client_secret_basic`,`client_secret_post`]),$D=fx([`web`,`native`]),eO=Y(q).check(Fx({message:`Choose unique Resources`})),tO=J({client_name:q,redirect_uris:Y(q),resources:eO,token_endpoint_auth_method:QD,application_type:$D}),nO=J({client_id:q,client_name:q,redirect_uris:Y(q),application_type:$D}),rO=J({client_id:q}),iO=J({client_id:q,resource:Jb(q)}),aO=J({client_id:q,blocked:nx}),oO=J({onboarding:Jb(fx([`managed`,`dcr`,`cimd`])),blocked:Jb(nx),client_id:q,client_name:Jb(q),redirect_uris:Y(q),token_endpoint_auth_method:Jb(q),application_type:Jb(px(q)),scope:Jb(q),grant_types:Jb(Y(q))}),sO=oO.pipe(ax({client_secret:Jb(q),client_secret_expires_at:Jb(tx)})),cO=J({identifier:q,name:q,scopes:Y(q)}),lO=cO.pipe(ax({builtIn:nx})),uO=J({identifier:q,name:q.check(Cx(/\S/u,{message:`Resources require a name`})),scopes:Y(q.check(Cx(/^\s*[\x21\x23-\x5B\x5D-\x7E]+\s*$/u,{message:`Resources require well-formed custom scopes`})))}),dO=J({identifier:q}),fO=J({client_id:q,resource:q}),pO=J({client_id:q,resources:eO}),mO=J({clientAccess:Y(fO)}),hO=ox(q,Y(q)),gO=ox(q,Y(q).check(Ax(1,{message:`Select explicitly granted, currently available Resource scopes`}),Fx({message:`Select explicitly granted, currently available Resource scopes`}))).check(Px(1,{message:`Select at least one Resource and scope`})),_O=q.check(Mx(100,{message:`Key names require 1–100 characters`}),Cx(/\S/u,{message:`Key names require 1–100 characters`})),vO=$x,yO=J({client_id:q,resource:q,scopes:Y(q),approvedAt:px(vO),refreshedAt:px(vO)}),bO=J({name:_O,permissions:gO,expiresAt:px(vO)}),xO=J({keyId:q}),SO=J({keyId:q,name:Jb(_O),permissions:Jb(gO),enabled:Jb(nx)}),CO=J({keyId:q,name:q,enabled:nx,permissions:hO,expiresAt:px(vO),createdAt:vO}),wO={caller:hC,error:JD},TO={caller:YD,error:JD},EO=[X(`setupStatus`,{description:`Check whether the issuer needs its first owner account.`,readOnly:!0,...wO,success:J({required:nx})}),X(`setupOwner`,{description:`Create the first owner account.`,readOnly:!1,...wO,input:ZD,success:J({created:nx}).pipe(OT(201))}),X(`keyList`,{description:`The signed list a resource server verifies API keys against: one sealed entry per key granted on the resource, readable only with that key.`,readOnly:!0,...wO,input:J({resource:q}),success:J({list:q})})],DO=J({clients:Y(oO),resources:Y(lO),clientAccess:Y(fO),connections:Y(yO),email:q,issuer:q}),OO=[X(`listClients`,{description:`List clients, resources, managed clients' resource access (what they may obtain), and every client's connections (what it holds).`,readOnly:!0,...TO,success:DO}),X(`createClient`,{description:`Register a first-party OAuth client. Returns its secret once when confidential.`,readOnly:!1,...TO,input:tO,success:sO.pipe(OT(201))}),X(`updateClient`,{description:`Rename a first-party client or change its redirect URIs and application type.`,readOnly:!1,...TO,input:nO,success:oO}),X(`deleteClient`,{description:`Delete a client and its stored authorization. An automatic client can register again; block it to keep it out.`,readOnly:!1,...TO,input:rO,success:J({deleted:nx})}),X(`revokeClient`,{description:`Revoke a client’s stored authorization, for one resource or all. It must authorize again; an automatic client asks for consent.`,readOnly:!1,...TO,input:iO,success:J({revoked:nx})}),X(`blockClient`,{description:`Block or unblock OAuth authorization for a client.`,readOnly:!1,...TO,input:aO,success:J({blocked:nx})}),X(`rotateClientSecret`,{description:`Rotate a confidential client secret. Returns the new secret once.`,readOnly:!1,...TO,input:rO,success:sO}),X(`setClientAccess`,{description:`Set the resources a managed client may obtain. Removing one revokes its authorization for it. Automatic clients may ask for any resource with consent.`,readOnly:!1,...TO,input:pO,success:mO}),X(`createResource`,{description:`Create an OAuth resource and its scopes.`,readOnly:!1,...TO,input:uO,success:cO.pipe(OT(201))}),X(`updateResource`,{description:`Update an OAuth resource and its scopes.`,readOnly:!1,...TO,input:uO,success:cO}),X(`deleteResource`,{description:`Delete a resource, its client access and every client’s authorization for it. API-key permissions are retained; recreating the resource restores them.`,readOnly:!1,...TO,input:dO,success:J({deleted:nx})}),X(`listApiKeys`,{description:`List API key metadata without secret values.`,readOnly:!0,...TO,success:J({keys:Y(CO)})}),X(`createApiKey`,{description:`Create a scoped API key. Returns its secret once.`,readOnly:!1,...TO,input:bO,success:CO.pipe(ax({key:q}),OT(201))}),X(`updateApiKey`,{description:`Update an API key’s name, permissions or enabled state.`,readOnly:!1,...TO,input:SO,success:CO}),X(`deleteApiKey`,{description:`Delete an API key.`,readOnly:!1,...TO,input:xO,success:J({deleted:nx})})],Z=GD((e=>UD([...OO,...EO],{authentication:e}))(XD)),kO=Vb(dx(JD)),AO=Vb(fC),jO=e=>kO(e)?Error(e.error):e instanceof sC&&e.issues.length?Error([...new Set(e.issues.map(e=>e.message))].join(` `)):AO(e)?Error(e.message):Error(`Request could not be completed. Please try again.`);async function Q(e){try{return await tm(e)}catch(e){throw jO(e)}}var MO=gn({plugins:[Tn()]}),NO=document.querySelector(`#app`);NO.innerHTML=`<header><a href="/" class="brand"><span class="mark">c.</span> clanker<span class="muted">auth</span></a><span class="tag">PRIVATE IDENTITY</span></header><main id="main"></main><footer>Local accounts. Explicit access.<span>Self-hosted authorization server</span></footer>`;var PO=document.querySelector(`#main`),$=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]);function FO(e){let t=document.querySelector(`#message`);t.textContent=e,e&&t.hasAttribute(`tabindex`)&&(t.focus(),t.scrollIntoView({behavior:`smooth`,block:`center`}))}var IO=!1;async function LO(e){if(IO)return;IO=!0;let t=Array.from(PO.querySelectorAll(`button`),e=>({button:e,disabled:e.disabled}));t.forEach(({button:e})=>e.disabled=!0),FO(``);try{await e()}catch(e){FO(e instanceof Error?e.message:`Request failed`)}finally{t.forEach(({button:e,disabled:t})=>e.disabled=t),IO=!1}}function RO(e,t){!IO&&confirm(e)&&LO(t)}function zO(){PO.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>Your identity.<br>Starts here.</h1><p>Create the owner account for your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> One owner · Explicit access</div></section>
13
- <section class="card login"><p class="eyebrow">FIRST-TIME SETUP</p><h2>Create your account</h2><p class="muted">This account manages Clients and Resources and approves access.</p>
14
- <form id="setup"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
15
- <label>Password<input name="password" type="password" autocomplete="new-password" required minlength="8" maxlength="128" aria-describedby="password-help"></label><p id="password-help" class="help">Use 8–128 characters. Save your password somewhere safe.</p>
16
- <label>Confirm password<input name="confirmation" type="password" autocomplete="new-password" required minlength="8" maxlength="128"></label>
17
- <p id="message" role="alert"></p><button>Create account <span>→</span></button></form></section>`;let e=document.querySelector(`#setup`);e.addEventListener(`submit`,t=>{t.preventDefault(),LO(async()=>{let t=e.querySelector(`[name="password"]`).value,n=e.querySelector(`[name="confirmation"]`).value;if(t.length<8||t.length>128)throw Error(`Use a password between 8 and 128 characters.`);if(t!==n)throw Error(`Passwords do not match.`);let r=await Q(Z.setupOwner({email:e.querySelector(`[name="email"]`).value,password:t}).pipe(Pp(`/`),Ip(`Conflict`,()=>R(`/login`))));location.replace(r)})})}function BO(){PO.innerHTML=`<section class="intro"><p class="eyebrow">YOUR NETWORK, YOUR IDENTITY</p><h1>One identity.<br>Deliberate access.</h1><p>Sign in to authorize your private applications.<br>Your account stays on your infrastructure.</p><div class="note"><span class="dot"></span> Password login · No external identity provider</div></section>
18
- <section class="card login"><p class="eyebrow">OWNER ACCESS</p><h2>Welcome back</h2><p class="muted">Use your local account to continue.</p>
19
- <form id="login"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
20
- <label>Password<input name="password" type="password" autocomplete="current-password" required></label>
21
- <p id="message" role="alert"></p><button>Sign in <span>→</span></button></form></section>`;let e=document.querySelector(`#login`);e.addEventListener(`submit`,t=>{t.preventDefault(),LO(async()=>{if((await MO.signIn.email({email:e.querySelector(`[name="email"]`).value,password:e.querySelector(`[name="password"]`).value})).error)throw Error(`Sign-in failed. Check your credentials or try again later.`);let t=new URLSearchParams(location.search),n=t.get(`rd`)??`/`;t.has(`sig`)||location.assign(new URL(n,location.origin).origin===location.origin?n:`/`)})})}async function VO(){let e=new URLSearchParams(location.search),t=e.get(`client_id`);if(!t||!e.has(`sig`))throw Error(`Start authorization from your application; this consent link is incomplete.`);let n=await MO.oauth2.publicClient({query:{client_id:t}});if(n.error||!n.data)throw Error(`Sign in through your application to continue authorization.`);let r=(e.get(`scope`)??``).split(` `).filter(Boolean),i=e.getAll(`resource`),a;try{let e=new URL(t);e.protocol===`https:`&&(a=e.hostname)}catch{}let o=e.get(`redirect_uri`);PO.className=`center`,PO.innerHTML=`<section class="card consent"><p class="eyebrow">PERMISSION REQUEST</p><h1>Allow this connection?</h1>
22
- <p><strong>${$(n.data.client_name??t)}</strong> wants to act on your behalf.</p>
23
- ${a?`<p>Client metadata host: <strong>${$(a)}</strong></p>`:``}
24
- <label>Client ID<code>${$(t)}</code></label>
25
- <label>Callback destination<code>${$(o??`Not supplied in this request`)}</code></label>
26
- <p class="help">The client supplies its display name. Review the identifier and callback before approving.</p>
27
- <div class="resource"><span class="eyebrow">ONLY FOR THIS RESOURCE</span>${i.map(e=>`<code>${$(e)}</code>`).join(``)}</div>
28
- <form id="consent"><h3>Requested access</h3><ul class="scopes">${r.map(e=>`<li><label class="checkbox"><input type="checkbox" name="scope" value="${$(e)}" checked><code>${$(e)}</code></label></li>`).join(``)}</ul>
29
- <p class="help">Untick anything this Client should not get. It receives only what stays ticked.</p>
30
- ${e.has(`claims`)?`<h3>Additional identity claims</h3><pre>${$(e.get(`claims`))}</pre>`:``}
31
- <p class="help">Access tokens expire after fifteen minutes. Offline access lets the Client renew them until you revoke its authorization.</p>
32
- <p id="message" role="alert"></p><div class="actions"><button type="submit" name="decision" value="deny" class="secondary">Deny</button><button type="submit" name="decision" value="allow">Allow access →</button></div></form></section>`;let s=document.querySelector(`#consent`);s.addEventListener(`submit`,e=>{e.preventDefault();let t=e.submitter;if(!(t instanceof HTMLButtonElement))throw Error(`Consent must be decided with the Allow or Deny button.`);let n=t.value===`allow`,i=Array.from(new FormData(s).getAll(`scope`),String);LO(async()=>{if(n&&r.length&&!i.length)throw Error(`Tick at least one permission, or deny the request.`);if((await MO.oauth2.consent(n&&i.length?{accept:n,scope:i.join(` `)}:{accept:n})).error)throw Error(`Authorization could not be completed. Restart from your application.`)})})}function HO(e,t){let n=e.get(t);if(n===null||n instanceof File)throw Error(`Missing form field: ${t}`);return n.trim()}function UO(e){return Array.from(e.querySelectorAll(`input[name="resources"]:checked`),e=>e.value)}function WO(e){let t=[...new Set(HO(e,`scopes`).split(/\s+/).filter(Boolean))];return{name:HO(e,`name`),scopes:t}}function GO(e){let t=[...new Set(HO(e,`redirect_uris`).split(/\s+/).filter(Boolean))];if(!t.length)throw Error(`Add at least one redirect URI.`);return t}var KO={none:`Public client (PKCE only)`,client_secret_basic:`Confidential client · HTTP Basic secret`,client_secret_post:`Confidential client · secret in request body`},qO=e=>Wb(QD)(HO(e,`token_endpoint_auth_method`)),JO=e=>Wb($D)(e.has(`native`)?`native`:`web`);function YO(e){let t={};for(let n of e.querySelectorAll(`input[name="key-scope"]:checked`))(t[n.dataset.resource]??=[]).push(n.value);return t}var XO=new Map,ZO=new Map;function QO(){let e=document.querySelector(`#credentials`);if(e.classList.toggle(`hidden`,ZO.size===0&&XO.size===0),e.replaceChildren(),!ZO.size&&!XO.size)return;e.innerHTML=`<h2>Save these credentials now</h2><p>API keys and client secrets are shown only once.</p><button class="secondary">Saved — dismiss credentials</button>`;let t=e.querySelector(`button`);for(let e of ZO.values()){let n=document.createElement(`pre`);n.textContent=JSON.stringify(e,null,2),t.before(n)}for(let e of XO.values()){let n=document.createElement(`pre`);n.textContent=e,t.before(n)}t.addEventListener(`click`,()=>{XO.clear(),ZO.clear(),QO()})}function $O(){QO(),document.querySelector(`#credentials`).scrollIntoView({behavior:`smooth`})}async function ek(){try{await _k()}catch{document.querySelector(`#dashboard-mutations`).disabled=!0,FO(`Saved, but the dashboard could not refresh.`);let e=document.createElement(`button`);e.type=`button`,e.className=`secondary`,e.textContent=`Retry refresh`,e.addEventListener(`click`,()=>{LO(ek)}),document.querySelector(`#message`).append(` `,e)}}var tk=`Optional. Separate scopes with spaces. offline_access is reserved.`,nk={managed:`Managed registration · first party, no consent screen`,dcr:`Dynamic registration`,cimd:`Client ID Metadata Document`},rk=e=>!e.onboarding||e.onboarding===`managed`,ik=(e,t,n,r,i)=>`<div class="columns dashboard-section"><section><h2>${e} <span class="count">${t}</span></h2><p class="muted">${n}</p>${r}</section><section class="card registration">${i}</section></div>`,ak=(e,t)=>`<div class="empty"><h3>${e}</h3><p>${t}</p></div>`,ok=e=>`<code>${$(e.identifier)}</code><span class="muted">${$(e.scopes.join(` · `))}</span>`,sk=(e,t)=>e.map(e=>`<label class="checkbox resource-choice"><input type="checkbox" name="resources" value="${$(e.identifier)}" ${t.includes(e.identifier)?`checked`:``}><span>${$(e.name)}${ok(e)}</span></label>`).join(``),ck=(e,t)=>e.map(e=>`<fieldset><legend>${$(e.name)}</legend><code>${$(e.identifier)}</code>${e.scopes.map(n=>`<label class="checkbox"><input type="checkbox" name="key-scope" data-resource="${$(e.identifier)}" value="${$(n)}" ${t[e.identifier]?.includes(n)?`checked`:``}><code>${$(n)}</code></label>`).join(``)}</fieldset>`).join(``)||`<p class="help">Add a Resource to grant access.</p>`,lk=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3>${ok(e)}
33
- <p class="help dependencies">Connected Clients: ${t.length?t.map(e=>$(e.client_name??e.client_id)).join(`, `):`None`}</p>
34
- ${e.builtIn?`<p class="help">Built-in administration resource, fixed. OAuth access tokens are required. clankerauth:read allows listing; clankerauth:write also allows every change.</p>`:`<details><summary>Edit resource</summary><form data-resource-edit="${$(e.identifier)}"><label>Name<input name="name" value="${$(e.name)}" required maxlength="100"></label><label>Scopes<input name="scopes" value="${$(e.scopes.join(` `))}"></label><p class="help">Added scopes need new consent. Removed scopes are no longer issued, but approvals are kept and work again if the scope is restored.</p><button>Save resource</button></form></details>
35
- <button class="danger" data-resource-delete="${$(e.identifier)}">Delete resource</button>`}</article>`,uk=()=>`<h2>Add resource</h2><form id="resource-create"><label>Name<input name="name" required maxlength="100" placeholder="Notes MCP"></label><label>HTTP or HTTPS identifier<input name="identifier" type="url" required placeholder="https://notes.internal/mcp"></label><p class="help">The identifier is the token audience and cannot be changed later. Use the canonical form a client sends back, such as the application\u2019s origin root with its trailing slash.</p><label>Scopes<input name="scopes" placeholder="notes:read notes:write"></label><p class="help">${tk}</p><button>Add resource +</button></form>`,dk=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3><p>${e.enabled?`Enabled`:`Disabled`} · ${e.expiresAt?`Expires ${$(Bm(e.expiresAt,{dateStyle:`medium`,timeStyle:`short`}))}`:`Valid until revoked`}</p>${Object.entries(e.permissions).map(([e,t])=>`<code>${$(e)}</code><p class="help">${$(t.join(` · `))}</p>`).join(``)}
36
- <details><summary>Rename key</summary><form data-key-rename="${$(e.keyId)}"><label>Name<input name="name" required maxlength="100" value="${$(e.name)}"></label><button>Save name</button></form></details>
37
- <details><summary>Edit grants</summary><form data-key-grants="${$(e.keyId)}">${ck(t,e.permissions)}<p class="help">Saving replaces all grants, including any not currently available, with the selected scopes.</p><button>Save grants</button></form></details>
38
- <div class="actions"><button class="secondary" data-key-toggle="${$(e.keyId)}" data-enabled="${e.enabled}">${e.enabled?`Disable key`:`Enable key`}</button><button class="danger" data-key-delete="${$(e.keyId)}">Delete key</button></div></article>`,fk=e=>`<h2>Create API key</h2><form id="key-create"><label>Name<input name="name" required maxlength="100" placeholder="Backup script"></label>${ck(e,{})}<label>Expiry (optional)<input name="expiry" type="datetime-local"></label><p class="help">Blank means valid until revoked. The key is shown once and works within about a minute.</p><button ${e.length?``:`disabled`}>Create API key</button></form>`,pk=e=>$(Bm(e,{dateStyle:`medium`,timeStyle:`short`})),mk=(e,t)=>{let n=t.find(t=>t.identifier===e.resource),r=[e.approvedAt?`Approved ${pk(e.approvedAt)}`:`First party, no consent`,e.refreshedAt?`last token ${pk(e.refreshedAt)}`:`no refresh token`].join(` · `);return`<div class="allowed-resource connection"><strong>${$(n?.name??e.resource)}</strong><code>${$(e.resource)}</code><span class="muted">${$(e.scopes.join(` · `)||`No Resource scopes`)}</span><p class="help">${r}</p><button class="secondary" data-disconnect="${$(e.client_id)}" data-resource="${$(e.resource)}">Revoke</button></div>`},hk=(e,t,n,r)=>{let i=rk(e),a=$(e.client_id),o=r.map(e=>mk(e,t)).join(``)||`<p class="help">${i?`Holds no refresh token.`:`No Resource approved yet.`}</p>`,s=i?`<details><summary>Allowed Resources · ${n.length} of ${t.length}</summary><form data-client-access="${a}"><fieldset><legend>Allowed Resources</legend>${sk(t,n)||`<p class="help">Add a Resource above to configure access.</p>`}</fieldset><p class="help">This Client skips consent for the Resources ticked here. Unticking one revokes its authorization for it.</p><button>Save access</button></form></details>`:`<p class="help">May ask for any Resource; each needs your consent. Revoke a connection, or block the Client to keep it out.</p>`,c=i?`<details><summary>Edit client</summary><form data-client-edit="${a}"><label>Client name<input name="name" required maxlength="100" value="${$(e.client_name??``)}"></label><label>Redirect URIs (one per line)<textarea name="redirect_uris" required rows="3">${$(e.redirect_uris.join(`
39
- `))}</textarea></label><label class="checkbox"><input type="checkbox" name="native" ${e.application_type===`native`?`checked`:``}>Native / desktop client (loopback redirect)</label><p class="help">The authentication method is fixed at registration.</p><button>Save client</button></form></details>`:``,l=[`<button class="secondary" data-revoke="${a}">Revoke all</button>`,`<button class="secondary" data-block="${a}" data-blocked="${e.blocked?`true`:`false`}">${e.blocked?`Unblock client`:`Block client`}</button>`,i&&e.token_endpoint_auth_method!==`none`?`<button class="secondary" data-rotate="${a}">Rotate secret</button>`:``,`<button class="danger" data-delete="${a}" data-managed="${i}">Delete client</button>`].join(``);return`<article class="card client"><div class="client-heading"><h3>${$(e.client_name??`Unnamed client`)}</h3><span class="tag">${e.token_endpoint_auth_method===`none`?`PUBLIC · PKCE`:`CONFIDENTIAL · PKCE`}</span></div><p class="help">${nk[e.onboarding??`managed`]}${e.blocked?` · BLOCKED`:``}</p><label>Client ID<code>${a}</code></label><label>Redirect URIs${e.redirect_uris.map(e=>`<code>${$(e)}</code>`).join(``)}</label>
40
- <h3>Connections</h3>${o}${s}${c}<div class="actions">${l}</div></article>`},gk=e=>`<p class="eyebrow">MANAGED REGISTRATION</p><h2>Register client</h2><form id="register"><fieldset><label>Client name<input name="name" required maxlength="100" placeholder="My MCP client"></label><label>Redirect URIs (one per line)<textarea name="redirect_uris" required rows="3" placeholder="https://app.internal/callback"></textarea></label><fieldset><legend>Allowed Resources (optional)</legend>${sk(e,[])||`<p class="help">You can configure Resource access after registration.</p>`}</fieldset><label class="checkbox"><input type="checkbox" name="native">Native / desktop client (loopback redirect)</label><label>Client authentication<select name="token_endpoint_auth_method">${Object.entries(KO).map(([e,t])=>`<option value="${e}">${t}</option>`).join(``)}</select></label><button>Register client +</button></fieldset><p class="help">S256 PKCE is always required. Clients you register here are first party and skip the consent screen.</p></form>`;async function _k(){let[e,t]=await Q(_p([Z.listClients(),Z.listApiKeys()],{concurrency:`unbounded`})),{resources:n}=e,r=n.filter(e=>!e.builtIn),i=t=>e.clientAccess.filter(e=>e.client_id===t).map(e=>e.resource),a=t=>e.connections.filter(e=>e.client_id===t);PO.className=`dashboard`,PO.innerHTML=`
41
- <div class="page-title"><div><p class="eyebrow">CONTROL PLANE</p><h1>Clients and Resources</h1><p class="muted">Signed in as ${$(e.email)}</p></div><button id="logout" class="secondary">Sign out</button></div>
42
- <div class="issuer"><span class="dot"></span><span>Canonical issuer</span><code>${$(e.issuer)}</code></div>
43
- <p id="message" role="alert" tabindex="-1"></p>
44
- <section id="credentials" class="card hidden" aria-live="polite"></section>
45
- <fieldset id="dashboard-mutations" aria-label="Clients and Resources">
46
- ${ik(`Resources`,n.length,`Protected APIs and MCP servers, and the scopes they define.`,n.map(t=>lk(t,e.clients.filter(e=>a(e.client_id).some(e=>e.resource===t.identifier)))).join(``)||ak(`Add your first Resource`,`Define a protected API or MCP server. Compatible MCP clients onboard automatically when you connect.`),uk())}
47
- ${ik(`API keys`,t.keys.length,`Direct access for CLIs and automation. Keys carry only the scopes you select, filtered by current Resource policy. Policy changes do not revoke stored grants; restoring policy restores access. Resource servers verify keys offline: a new key works within seconds and a key's expiry applies at once; any other change takes effect within about a minute, and a Resource server that cannot reach this issuer keeps accepting the keys it last saw for up to 24 hours.`,t.keys.map(e=>dk(e,r)).join(``)||ak(`No API keys`,`Create a key for a CLI or automation that needs direct access.`),fk(r))}
48
- ${ik(`Clients`,e.clients.length,`Compatible MCP clients register themselves when they connect; registration alone grants no access. Revoking or blocking stops new authorization and refresh at once; already-issued access tokens stay valid until they expire, at most fifteen minutes.`,e.clients.map(e=>hk(e,n,i(e.client_id),a(e.client_id))).join(``)||ak(`No Clients registered`,`Connect your MCP client to a configured server to onboard automatically, or register a managed Client here.`),gk(n))}
49
- </fieldset>`,QO();let o=e=>document.querySelector(e),s=(e,t)=>e.addEventListener(`submit`,n=>{n.preventDefault(),LO(()=>t(e))}),c=(e,t)=>{for(let n of PO.querySelectorAll(e))n.addEventListener(`click`,()=>t(n))};document.querySelector(`#logout`).addEventListener(`click`,()=>{LO(async()=>{await MO.signOut(),location.assign(`/login`)})}),s(o(`#register`),async e=>{let t=new FormData(e),n=await Q(Z.createClient({client_name:HO(t,`name`),redirect_uris:GO(t),resources:UO(e),application_type:JO(t),token_endpoint_auth_method:qO(t)}));e.reset(),ZO.set(n.client_id,n),$O(),await ek()}),s(o(`#key-create`),async e=>{let t=new FormData(e),n=HO(t,`expiry`),r=await Q(Z.createApiKey({name:HO(t,`name`),permissions:YO(e),expiresAt:n?Im(new Date(n)):null}));XO.set(r.keyId,`${r.name}\n${r.key}`),e.reset(),$O(),await ek()}),s(o(`#resource-create`),async e=>{let t=new FormData(e);await Q(Z.createResource({identifier:HO(t,`identifier`),...WO(t)})),e.reset(),await ek()});for(let e of PO.querySelectorAll(`[data-key-rename]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyRename,name:HO(new FormData(e),`name`)})),await ek()});for(let e of PO.querySelectorAll(`[data-key-grants]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyGrants,permissions:YO(e)})),await ek()});for(let e of PO.querySelectorAll(`[data-resource-edit]`))s(e,async e=>{await Q(Z.updateResource({identifier:e.dataset.resourceEdit,...WO(new FormData(e))})),await ek()});for(let e of PO.querySelectorAll(`[data-client-edit]`))s(e,async e=>{let t=new FormData(e);await Q(Z.updateClient({client_id:e.dataset.clientEdit,client_name:HO(t,`name`),redirect_uris:GO(t),application_type:JO(t)})),await ek()});for(let e of PO.querySelectorAll(`[data-client-access]`))e.addEventListener(`submit`,t=>{t.preventDefault();let n=e.dataset.clientAccess,r=UO(e),a=i(n).filter(e=>!r.includes(e)),o=async()=>{await Q(Z.setClientAccess({client_id:n,resources:r})),await ek()};a.length?RO(`Remove access to ${a.join(`, `)}? This revokes the Client\u2019s authorization for ${a.length===1?`it`:`them`}.`,o):LO(o)});c(`[data-key-toggle]`,e=>{LO(async()=>{await Q(Z.updateApiKey({keyId:e.dataset.keyToggle,enabled:e.dataset.enabled!==`true`})),await ek()})}),c(`[data-key-delete]`,e=>{let t=e.dataset.keyDelete;RO(`Delete this API key?`,async()=>{await Q(Z.deleteApiKey({keyId:t})),XO.delete(t),QO(),await ek()})}),c(`[data-revoke]`,e=>{let t=e.dataset.revoke;RO(`Revoke all of this Client’s authorization? It must authorize again, and an automatic Client asks for consent.`,async()=>{await Q(Z.revokeClient({client_id:t})),await ek()})}),c(`[data-disconnect]`,e=>{let t=e.dataset.disconnect,n=e.dataset.resource;RO(`Revoke this Client’s authorization for ${n}? It must authorize again, and an automatic Client asks for consent.`,async()=>{await Q(Z.revokeClient({client_id:t,resource:n})),await ek()})}),c(`[data-block]`,e=>{let t=e.dataset.block,n=e.dataset.blocked!==`true`;RO(n?`Block this Client and revoke its authorization?`:`Unblock this Client?`,async()=>{await Q(Z.blockClient({client_id:t,blocked:n})),await ek()})}),c(`[data-rotate]`,e=>{let t=e.dataset.rotate;RO(`Rotate the secret? The old one stops working immediately.`,async()=>{let e=await Q(Z.rotateClientSecret({client_id:t}));ZO.set(e.client_id,e),$O()})}),c(`[data-delete]`,e=>{let t=e.dataset.delete;RO(e.dataset.managed===`true`?`Delete this Client and its authorization?`:`Forget this Client and its authorization? It can register again; block it to keep it out.`,async()=>{await Q(Z.deleteClient({client_id:t})),ZO.delete(t),QO(),await ek()})}),c(`[data-resource-delete]`,e=>{let t=e.dataset.resourceDelete;RO(`Delete Resource ${t}? Every Client\u2019s authorization for it is revoked; API-key grants are kept.`,async()=>{await Q(Z.deleteResource({identifier:t})),await ek()})})}try{if((await Q(Z.setupStatus())).required)location.pathname===`/setup`?zO():location.replace(`/setup`);else if(location.pathname===`/setup`){let e=await MO.getSession();location.replace(e.data?`/`:`/login`)}else location.pathname===`/consent`?await VO():!(await MO.getSession()).data||location.pathname===`/login`?BO():await _k()}catch(e){PO.innerHTML=`<section class="card"><h1>Unable to continue</h1><p>${$(e instanceof Error?e.message:`Please try again`)}</p><a href="/login">Return to sign in</a></section>`}