@gjermundgaraba/clankerauth-dev 0.19.0 → 0.20.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,47 +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{}}},r=$r();if(r===0)return n[e];ei(2);let i=t[e](()=>Error());return ei(r),i.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`,li=`${ai}/successCont`,ui=`${ai}/failureCont`,di=`${ai}/ensureCont`,fi=Symbol.for(`effect/Effect/Yield`),pi={pipe(){return y(this,arguments)},toJSON(){return{...this}},toString(){return E(this.toJSON(),{ignoreToString:!0,space:2})},[Jr](){return this.toJSON()}},mi={[ai]:si,...pi,[Symbol.iterator](){return new ti(this)},toJSON(){return{_id:`Effect`,op:this[ci],...D in this?{args:this[D]}:void 0}}},hi=e=>S(e,ai),gi=e=>S(e,oi),_i=`~effect/Cause`,vi=`~effect/Cause/Reason`,yi=e=>S(e,_i),bi=e=>S(e,vi),xi=class{constructor(e){this[_i]=_i,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 yi(e)&&this.reasons.length===e.reasons.length&&this.reasons.every((t,n)=>_r(t,e.reasons[n]))}[C](){return ur(this.reasons)}},Si=new WeakMap,Ci=class{[vi];annotations;_tag;constructor(e,t,n){if(this[vi]=vi,this._tag=e,t!==wi&&typeof n==`object`&&n&&t.size>0){let e=Si.get(n);e&&(t=new Map([...e,...t])),Si.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()}},wi=new Map,Ti=class extends Ci{constructor(e,t=wi){super(`Fail`,t,e),this.error=e}toString(){return`Fail(${E(this.error)})`}toJSON(){return{_tag:`Fail`,error:this.error}}[T](e){return Ni(e)&&_r(this.error,e.error)&&_r(this.annotations,e.annotations)}[C](){return nr(or(this._tag))(nr(w(this.error))(w(this.annotations)))}},Ei=e=>new xi(e),Di=(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},Oi=b(2,(e,t)=>{if(e.reasons.length===0)return t;if(t.reasons.length===0)return e;let n=new xi(Di(e.reasons,t.reasons));return _r(e,n)?e:n}),ki=e=>new xi([new Ti(e)]),Ai=class extends Ci{constructor(e,t=wi){super(`Die`,t,e),this.defect=e}toString(){return`Die(${E(this.defect)})`}toJSON(){return{_tag:`Die`,defect:this.defect}}[T](e){return Pi(e)&&_r(this.defect,e.defect)&&_r(this.annotations,e.annotations)}[C](){return nr(or(this._tag))(nr(w(this.defect))(w(this.annotations)))}},ji=e=>new xi([new Ai(e)]),Mi=b(e=>yi(e[0]),(e,t,n)=>t.mapUnsafe.size===0?e:new xi(e.reasons.map(e=>e.annotate(t,n)))),Ni=e=>e._tag===`Fail`,Pi=e=>e._tag===`Die`,Fi=e=>e._tag===`Interrupt`;function Ii(e){return Gi(`Effect.evaluate: Not implemented`)}var Li=e=>({...mi,[ci]:e.op,[O]:e[O]??Ii,[li]:e[li],[ui]:e[ui],[di]:e[di]}),Ri=e=>{let t=Li(e),n=function(e){this[D]=e};return n.prototype=t,function(e){return new n(e)}},zi=e=>{let t={[oi]:oi,_tag:e.op,get[e.prop](){return this[D]},...Li(e),toString(){return`${e.op}(${E(this[D])})`},toJSON(){return{_id:`Exit`,_tag:e.op,[e.prop]:this[D]}},[T](e){return gi(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)}},Bi=zi({op:`Success`,prop:`value`,[O](e){let t=e.getCont(li);return t?t[li](this[D],e,this):e.yieldWith(this)}}),Vi={key:`effect/Cause/StackTrace`},Hi={key:`effect/Cause/InterruptorStackTrace`},Ui=zi({op:`Failure`,prop:`cause`,[O](e){let t=this[D],n=!1;e.cache.stackFrame&&(t=Mi(t,{mapUnsafe:new Map([[Vi.key,e.cache.stackFrame]])}),n=!0);let r=e.getCont(ui),i=e._interruptedCause;if(i&&e.interruptible){let a=!1;for(;r&&e.interruptible;)a||=ci in r,r=e.getCont(ui);a&&(t=Ei(t.reasons.filter(e=>e._tag!==`Fail`))),t=Oi(t,i),n=!0}return r?r[ui](t,e,n?void 0:this):e.yieldWith(n?Ui(t):this)}}),Wi=e=>Ui(ki(e)),Gi=e=>Ui(ji(e)),k=Ri({op:`WithFiber`,[O](e){return this[D](e)}}),Ki=function(){class e extends globalThis.Error{}let t=Li({op:`YieldableError`,[O](){return Wi(this)}});return delete t.toString,Object.assign(e.prototype,t),e}(),qi=function(){let e=Symbol.for(`effect/Data/Error/plainArgs`);return class extends Ki{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}}}}(),Ji=e=>{class t extends qi{_tag=e}return t.prototype.name=e,t},Yi=`~effect/Cause/Done`,Xi=e=>S(e,Yi),Zi={[Yi]:Yi,_tag:`Done`,value:void 0},Qi=e=>e===void 0?Zi:{[Yi]:Yi,_tag:`Done`,value:e},$i=Wi(Zi),ea=e=>e===void 0?$i:Wi(Qi(e)),ta=e=>Li({op:e.label,[O]:e.evaluate}),na=e=>(t,n)=>t===n||e(t,n),ra=(e,t)=>e===t,ia=()=>ra;function aa(e){return na((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 oa(e){return na((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 sa=`~effect/Option`,ca={[sa]:{_A:e=>e},...pi,[Symbol.iterator](){return new ti(this)}},la=Object.defineProperty(Object.assign(Object.create(ca),{_tag:`Some`,_op:`Some`,[T](e){return fa(e)&&ma(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}}),ua=w(`None`),da=Object.assign(Object.create(ca),{_tag:`None`,_op:`None`,valueOrUndefined:void 0,[T](e){return fa(e)&&pa(e)},[C](){return ua},toString(){return`none()`},toJSON(){return{_id:`Option`,_tag:this._tag}}}),fa=e=>S(e,sa),pa=e=>e._tag===`None`,ma=e=>e._tag===`Some`,ha=Object.create(da),ga=function(e){this.value=e};ga.prototype=la;var _a=e=>new ga(e),va=`~effect/Result`,ya={[va]:{_A:e=>e,_E:e=>e},...pi,[Symbol.iterator](){return new ti(this)}},ba=Object.assign(Object.create(ya),{_tag:`Success`,_op:`Success`,[T](e){return Sa(e)&&wa(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)}}}),xa=Object.assign(Object.create(ya),{_tag:`Failure`,_op:`Failure`,[T](e){return Sa(e)&&Ca(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)}}}),Sa=e=>S(e,va),Ca=e=>e._tag===`Failure`,wa=e=>e._tag===`Success`,Ta=function(e){this.failure=e};Ta.prototype=xa;var Ea=e=>new Ta(e),Da=function(e){this.success=e};Da.prototype=ba;var Oa=e=>new Da(e);function ka(e){return(t,n)=>t===n?0:e(t,n)}var Aa=ka((e,t)=>e<t?-1:1),ja=ka((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),Ma=b(2,(e,t)=>ka((n,r)=>e(t(n),t(r)))),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=e=>b(2,(t,n)=>e(t,n)!==-1),La=()=>ha,Ra=_a,za=pa,Ba=ma,Va=b(2,(e,{onNone:t,onSome:n})=>za(e)?t():n(e.value)),Ha=b(2,(e,t)=>za(e)?t():e.value),Ua=e=>e==null?La():Ra(e),Wa=Ha(jn),Ga=e=>(...t)=>{try{return Ra(e(...t))}catch{return La()}},Ka=`~effect/Context/Service`,A=function(){function e(){}let t=e;Object.setPrototypeOf(t,qa);let n=(e,n)=>(t.key=e,n?.defaultValue&&(t[Ya]=Ya,t.defaultValue=n.defaultValue),n?.make&&(t.make=n.make),n?.fiberCached&&Ja.add(e),t);return arguments.length>0?n(arguments[0],arguments[1]):n},qa={[Ka]:Ka,...ta({label:`Service`,evaluate(e){return Bi(bo(e.context,this))}}),toJSON(){return{_id:`Service`,key:this.key}},of(e){return e},context(e){return mo(this,e)},use(e){return k(t=>e(bo(t.context,this)))},useSync(e){return k(t=>Bi(e(bo(t.context,this))))}},Ja=new Set,Ya=`~effect/Context/Reference`,Xa=`~effect/Context`,Za=8,Qa=8,$a=(e,t,n,r)=>{let i=Object.create(oo);return i.cacheRoot=e??i,i.base=t,i.overlay=n,i.depth=r,i._flat=void 0,i.baseHits=0,i},eo=(e,t)=>{t&&(eo(e,t.parent),e.set(t.key,t.value))},to=e=>{if(e._flat)return e._flat;if(!e.overlay)return e._flat=e.base;let t=new Map(e.base);return eo(t,e.overlay),e._flat=t},no=(e,t)=>{let n=new Map(e.mapUnsafe);return t(n),ao(n)},ro=Symbol(),io=(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)?ro:(n.overlay&&++n.baseHits>=n.base.size&&n.baseHits>=Qa&&(n.base=to(n),n.overlay=void 0,n.depth=0),r)},ao=e=>$a(void 0,e,void 0,0),oo={get mapUnsafe(){return to(this)},...pi,[Xa]:{_Services:e=>e},toJSON(){return{_id:`Context`,services:Array.from(this.mapUnsafe).map(([e,t])=>({key:e,value:t}))}},[T](e){if(!co(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)}},so=(e,t)=>e.cacheRoot===t.cacheRoot,co=e=>S(e,Xa),lo=e=>S(e,Ka),uo=e=>!!e[Ya],fo=()=>po,po=ao(new Map),mo=(e,t)=>ao(new Map([[e.key,t]])),ho=b(3,(e,t,n)=>go(e,t.key,n)),go=(e,t,n)=>{let r=e,i=Ja.has(t)?void 0:r.cacheRoot;if(r.depth>=Za){let e=new Map(r._flat??r.base);return r._flat||eo(e,r.overlay),e.set(t,n),$a(i,e,void 0,0)}return $a(i,r.base,{key:t,value:n,parent:r.overlay},r.depth+1)},_o=b(2,(e,t)=>vo(e,t.key)),vo=(e,t)=>{let n=io(e,t);return n===ro?void 0:n},yo=b(2,(e,t)=>{let n=io(e,t.key);if(n===ro){if(uo(t))return So(t);throw Co(t)}return n}),bo=yo,xo=`~effect/Context/defaultValue`,So=e=>xo in e?e[xo]:e[xo]=e.defaultValue(),Co=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},wo=b(2,(e,t)=>e.mapUnsafe.size===0?t:t.mapUnsafe.size===0?e:no(e,e=>t.mapUnsafe.forEach((t,n)=>e.set(n,t)))),To=(...e)=>{let t=new Map;for(let n=0;n<e.length;n++)e[n].mapUnsafe.forEach((e,n)=>{t.set(n,e)});return ao(t)},j=A,Eo=e=>e.length>0,Do=Oa,Oo=Ea,ko=e=>{if(Gn(e))try{return Do(e())}catch(e){return Oo(e)}try{return Do(e.try())}catch(t){return Oo(e.catch(t))}},Ao=Ca,jo=wa,Mo=b(2,(e,{onFailure:t,onSuccess:n})=>Ao(e)?t(e.failure):n(e.success)),No=aa,Po=b(2,(e,t)=>Object.hasOwn(e,t)),Fo=b(2,(e,t)=>{let n={...e};for(let r of Io(e))ri(n,r,t(e[r],r));return n}),Io=e=>Object.keys(e),Lo=e=>b(2,(t,n)=>{for(let r of Io(t))if(!Po(n,r)||!e(t[r],n[r]))return!1;return!0}),Ro=e=>{let t=Lo(e);return(e,n)=>t(e,n)&&t(n,e)},zo=globalThis.Array,Bo=e=>zo.isArray(e)?e:zo.from(e),Vo=e=>zo.isArray(e)?e:[e],Ho=b(2,(e,t)=>[...e,t]),Uo=b(2,(e,t)=>Bo(e).concat(Bo(t)));zo.isArray;var Wo=Eo,Go=Eo,Ko=(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},qo=()=>[],Jo=e=>[e],Yo=b(2,(e,t)=>e.map(t)),Xo=oa,Zo=e=>{let t=Bo(e);if(t.length<2)return[...t];let n=new Map,r=[];for(let e of t)Ko(n,e)&&r.push(e);return r},Qo=`~effect/Duration`,$o=BigInt(0),es=BigInt(1),ts=BigInt(2),ns=BigInt(10),rs=BigInt(1e3),is=e=>BigInt(Math.sign(e)*Math.round(Math.abs(e))),as=e=>is(e*1e6),os=e=>gs(Number.isFinite(e)?is(e):e),ss=(e,t)=>{let n=e.indexOf(`.`);if(n===-1)return BigInt(e)*t;let r=e[0]===`-`,i=e.slice(n+1),a=ns**BigInt(i.length),o=(BigInt(e.slice(+!!r,n))*a+BigInt(i))*t;return cs(r?-o:o,a)},cs=(e,t)=>{let n=e<$o?-e:e,r=n/t+(n%t*ts>=t?es:$o);return e<$o?-r:r},ls=/^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/,us=e=>{switch(typeof e){case`number`:return Ss(e);case`bigint`:return xs(e);case`string`:{if(e===`Infinity`)return ys;if(e===`-Infinity`)return bs;let t=ls.exec(e);if(!t)break;let[n,r,i]=t;if(i===`nano`||i===`nanos`)return xs(ss(r,es));if(i===`micro`||i===`micros`)return xs(ss(r,rs));let a=Number(r);switch(i){case`milli`:case`millis`:return Ss(a);case`second`:case`seconds`:return Cs(a);case`minute`:case`minutes`:return ws(a);case`hour`:case`hours`:return Ts(a);case`day`:case`days`:return Es(a);case`week`:case`weeks`:return Ds(a)}break}case`object`:{if(e===null)break;if(Qo in e)return e;if(Array.isArray(e))return e.length!==2||!e.every(Vn)?ds(e):Number.isNaN(e[0])||Number.isNaN(e[1])?vs:e[0]===-1/0||e[1]===-1/0?bs:e[0]===1/0||e[1]===1/0?ys:os(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?gs(n):os(n*1e6+(t.microseconds??0)*1e3+(t.nanoseconds??0))}}return ds(e)},ds=e=>{throw Error(`Invalid Input: ${e}`)},fs={_tag:`Millis`,millis:0},ps={_tag:`Infinity`},ms={_tag:`NegativeInfinity`},hs={[Qo]:Qo,[C](){switch(this.value._tag){case`Millis`:{let e=this.value.millis*1e6;return Number.isFinite(e)?w(is(e)):ar(this.value.millis)}case`Nanos`:return w(this.value.nanos);default:return cr(this.value)}},[T](e){return _s(e)&&Ns(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)}},gs=e=>{let t=Object.create(hs);return t.value=typeof e==`number`?isNaN(e)||e===0||Object.is(e,-0)?fs:Number.isFinite(e)?Number.isInteger(e)?{_tag:`Millis`,millis:e}:{_tag:`Nanos`,nanos:as(e)}:e>0?ps:ms:e===$o?fs:{_tag:`Nanos`,nanos:e},t},_s=e=>S(e,Qo),vs=gs(0),ys=gs(1/0),bs=gs(-1/0),xs=e=>gs(e),Ss=e=>gs(e),Cs=e=>gs(e*1e3),ws=e=>gs(e*6e4),Ts=e=>gs(e*36e5),Es=e=>gs(e*864e5),Ds=e=>gs(e*6048e5),Os=e=>As(us(e),{onMillis:x,onNanos:e=>Number(e)/1e6,onInfinity:()=>1/0,onNegativeInfinity:()=>-1/0}),ks=e=>{let t=us(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 as(t.value.millis)}},As=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)()}}),js=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(ks(e),t.value.nanos):n.onNanos(e.value.nanos,ks(t))),Ms=(e,t)=>js(e,t,{onMillis:(e,t)=>e===t,onNanos:(e,t)=>e===t,onInfinity:(e,t)=>e.value._tag===t.value._tag}),Ns=b(2,(e,t)=>Ms(e,t)),Ps=j(`effect/Scheduler`,{fiberCached:!0,defaultValue:()=>new zs}),Fs=e=>{let t=!1;return Promise.resolve().then(()=>{t||e()}),()=>{t=!0}},Is=`setImmediate`in globalThis?e=>{let t=globalThis.setImmediate(e);return()=>globalThis.clearImmediate(t)}:e=>{let t=setTimeout(e,0);return()=>clearTimeout(t)},Ls=e=>{try{return Is(e)}catch{return Fs(e)}},Rs=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}},zs=class{executionMode;setImmediate;constructor(e=`async`,t){this.executionMode=e,this.setImmediate=t??(e===`sync`?Fs:Ls)}shouldYield(e){return e.currentOpCount>=e.cache.maxOpsBeforeYield}makeDispatcher(){return new Bs(this.setImmediate)}},Bs=class{tasks=new Rs;running=void 0;setImmediate;constructor(e=Ls){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()}},Vs=j(`effect/Scheduler/MaxOpsBeforeYield`,{fiberCached:!0,defaultValue:()=>2048}),Hs=j(`effect/Scheduler/PreventSchedulerYield`,{fiberCached:!0,defaultValue:()=>!1}),Us=class extends Dn{constructor(e){super(),e&&ii(this,e)}},Ws=e=>class extends Us{_tag=e},Gs=Ji,Ks=`~effect/encoding/EncodingError`,qs=class extends Gs(`EncodingError`){[Ks]=Ks},Js=e=>{switch(e){case 16:return Zs();case 32:return Qs();default:{let t=``;for(let n=e>>>3;n>0;n--)t+=Xs();return t}}},M=Uint8Array.from(`0123456789abcdef`,e=>e.charCodeAt(0)),Ys=()=>Math.random()*4294967296>>>0,Xs=()=>{let e=Ys();return String.fromCharCode(M[e>>>28],M[e>>>24&15],M[e>>>20&15],M[e>>>16&15],M[e>>>12&15],M[e>>>8&15],M[e>>>4&15],M[e&15])},Zs=()=>{let e=Ys(),t=Ys();return String.fromCharCode(M[e>>>28],M[e>>>24&15],M[e>>>20&15],M[e>>>16&15],M[e>>>12&15],M[e>>>8&15],M[e>>>4&15],M[e&15],M[t>>>28],M[t>>>24&15],M[t>>>20&15],M[t>>>16&15],M[t>>>12&15],M[t>>>8&15],M[t>>>4&15],M[t&15])},Qs=()=>{let e=Ys(),t=Ys(),n=Ys(),r=Ys();return String.fromCharCode(M[e>>>28],M[e>>>24&15],M[e>>>20&15],M[e>>>16&15],M[e>>>12&15],M[e>>>8&15],M[e>>>4&15],M[e&15],M[t>>>28],M[t>>>24&15],M[t>>>20&15],M[t>>>16&15],M[t>>>12&15],M[t>>>8&15],M[t>>>4&15],M[t&15],M[n>>>28],M[n>>>24&15],M[n>>>20&15],M[n>>>16&15],M[n>>>12&15],M[n>>>8&15],M[n>>>4&15],M[n&15],M[r>>>28],M[r>>>24&15],M[r>>>20&15],M[r>>>16&15],M[r>>>12&15],M[r>>>8&15],M[r>>>4&15],M[r&15])},$s=`effect/Tracer/ParentSpan`,ec=class extends A()($s,{fiberCached:!0}){},tc=e=>e,nc=j(`effect/Tracer/DisablePropagation`,{defaultValue:An}),rc=j(`effect/Tracer/CurrentTraceLevel`,{defaultValue:()=>`Info`}),ic=j(`effect/Tracer/MinimumTraceLevel`,{defaultValue:()=>`All`}),ac=`effect/Tracer`,oc=tc({span:e=>new sc(e)}),sc=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??=Wa(this.parent)?.traceId??Js(32)}get spanId(){return this._spanId??=Js(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)}},cc=`effect/Metric/FiberRuntimeMetrics`,lc=j(`effect/References/CurrentStackFrame`,{fiberCached:!0,defaultValue:jn}),uc=j(`effect/References/TracerEnabled`,{fiberCached:!0,defaultValue:kn}),dc=j(`effect/References/TracerTimingEnabled`,{defaultValue:kn}),fc=j(`effect/References/TracerSpanAnnotations`,{defaultValue:()=>({})}),pc=j(`effect/References/TracerSpanLinks`,{defaultValue:()=>[]}),mc=j(`effect/References/CurrentLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),hc=j(`effect/References/MinimumLogLevel`,{fiberCached:!0,defaultValue:()=>`Info`}),gc=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:_c(()=>n.stack)}},_c=(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),vc=class extends Ci{constructor(e,t=wi){super(`Interrupt`,t,`Interrupted`),this.fiberId=e}toString(){return`Interrupt(${this.fiberId})`}toJSON(){return{_tag:`Interrupt`,fiberId:this.fiberId}}[T](e){return Fi(e)&&this.fiberId===e.fiberId&&this.annotations===e.annotations}[C](){return nr(or(`${this._tag}:${this.fiberId}`))(er(this.annotations))}},yc=e=>new vc(e),bc=e=>new xi([new vc(e)]),xc=e=>{for(let t=0;t<e.reasons.length;t++){let n=e.reasons[t];if(n._tag===`Fail`)return Do(n.error)}return Oo(e)},Sc=e=>e.reasons.some(Fi),Cc=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?Do(t):Oo(e)},wc=b(2,(e,t)=>{let n=!1,r=e.reasons.map(e=>Ni(e)?(n=!0,new Ti(t(e.error),e.annotations)):e);return n?Ei(r):e}),Tc=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},Ec=`~effect/Fiber`,Dc={_A:x,_E:x},Oc={id:0},kc=(()=>{try{return globalThis.process?.getBuiltinModule?.(`node:async_hooks`)?.AsyncResource}catch{return}})(),Ac=()=>kc===void 0?void 0:new kc(`effect/Fiber`),jc=()=>globalThis[Ir],Mc=class{constructor(e,t=!0){this.setContext(e),this.id=++Oc.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[Ec](){return Dc}get currentDispatcher(){return this._dispatcher??=this.cache.scheduler.makeDispatcher()}getRef(e){return bo(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=bc(e);this.cache.stackFrame&&(n=Mi(n,mo(Vi,this.cache.stackFrame))),t&&(n=Mi(n,t)),this._interruptedCause=this._interruptedCause?Oi(this._interruptedCause,n):n,this.interruptible&&(this._running?this._deferredInterrupt=!0:this.evaluate(Wc(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===fi){this._asyncContext=Ac();return}let n=Ic.interruptChildren&&Ic.interruptChildren(this);if(n!==void 0)return this.evaluate(Tl(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=fo()}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=Wc(this._interruptedCause)),this.currentOpCount++;let e=this.cache;if(!r&&!e.preventYield&&e.scheduler.shouldYield(this)){r=!0;let e=i;i=Tl(Jc,()=>e)}if(i=e.tracerContext?e.tracerContext(i,this):i[O](this),i===fi){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 fi}}catch(e){if(!S(i,O))return Gi(`Fiber.runLoop: Not a valid effect: ${String(i)}`);i=Gi(e)}}finally{this._running=n,globalThis[Ir]=t}}getCont(e){if(this._deferredInterrupt)return this._deferredInterrupt=!1,Pc;for(;;){let t=this._stack.pop();if(!t)return;let n=t[di];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&Fc-1))return Bi(e);let t=this.getCont(li);return t?t[li](e,this):this.yieldWith(Bi(e))}yieldWith(e){return this._yielded=e,fi}children(){return this._children??=new Set}pipe(){return y(this,arguments)}setContext(e){let t=this.context;if(this.context=e,t!==void 0&&so(t,e))return;let n=e.cacheRoot,r=n._fiberCache??=Nc(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}},Nc=e=>{let t=vo(e,ac);return{scheduler:bo(e,Ps),tracer:t,tracerContext:t?t.context:void 0,tracerEnabled:bo(e,uc),span:vo(e,$s),logLevel:bo(e,mc),minimumLogLevel:bo(e,hc),stackFrame:bo(e,lc),runtimeMetrics:vo(e,cc),maxOpsBeforeYield:bo(e,Vs),preventYield:bo(e,Hs)}},Pc={[li](e,t){return Wc(t._interruptedCause)},[ui](e,t){return Wc(t._interruptedCause)}},Fc=32,Ic={interruptChildren:void 0},Lc=e=>{if(!e.cache.stackFrame)return;let t=new Map;return t.set(Hi.key,e.cache.stackFrame),ao(t)},Rc=e=>{let t=e;return t._exit?N(t._exit):rl(n=>t._exit?n(N(t._exit)):Kc(e.addObserver(e=>n(N(e)))))},zc=e=>rl(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(N(r))}return a(),Kc(()=>i?.())}),Bc=e=>{let t=e;return t._exit?t._exit:rl(n=>t._exit?n(t._exit):Kc(e.addObserver(n)))},Vc=e=>k(t=>Hc(e,t.id)),Hc=b(e=>S(e[0],Ec),(e,t,n)=>k(r=>{let i=Lc(r);return i=i&&n?wo(i,n):i??n,e.interruptUnsafe(t,i),wl(Rc(e))})),Uc=e=>k(t=>{let n=Lc(t),r=qo();for(let i of e)i.interruptUnsafe(t.id,n),r.push(i);return wl(zc(r))}),N=Bi,Wc=Ui,Gc=Wi,Kc=Ri({op:`Sync`,[O](e){let t=this[D](),n=e.getCont(li);return n?n[li](t,e):e.yieldWith(Bi(t))}}),P=Ri({op:`Suspend`,[O](e){return this[D]()}}),qc=Mo({onFailure:Gc,onSuccess:N}),Jc=Ri({op:`Yield`,[O](e){let t=!1;return e.currentDispatcher.scheduleTask(()=>{t||e.evaluate(Pl)},this[D]??0),e.yieldWith(()=>{t=!0})}})(0),Yc=e=>P(()=>Wc(e())),Xc=e=>Gi(e),Zc=e=>P(()=>Gc(e())),F=N(void 0),Qc=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new zd(e,`An error occurred in Effect.try`):e.catch;return P(()=>{try{return N(t())}catch(e){return Gc(n(e))}})},$c=e=>tl(function(t,n){e(n).then(e=>t(N(e)),e=>t(Xc(e)))},e.length!==0),el=e=>{let t=typeof e==`function`?e:e.try,n=typeof e==`function`?e=>new zd(e,`An error occurred in Effect.tryPromise`):e.catch;return tl(function(e,r){let i=e=>P(()=>{try{return Gc(ni(()=>n(e)))}catch(e){return Xc(e)}});try{t(r).then(t=>e(N(t)),t=>e(i(t)))}catch(t){e(i(t))}},t.length!==0)},tl=function(){let e=Li({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(nl(()=>(t=!0,r?.abort(),i??Pl))),fi):n}}),t=function(e,t){this.register=e,this.withSignal=t};return t.prototype=e,function(e,n){return new t(e,n)}}(),nl=Ri({op:`AsyncFinalizer`,[di](e){e.interruptible&&(e.interruptible=!1,e._stack.push(Gu))},[ui](e,t){return Sc(e)?Tl(bu(Ui(e),this[D]()),()=>Wc(e)):Wc(e)}}),rl=e=>tl(e,e.length>=2),il=rl(Mn),al=(...e)=>{if(e.length===1){let t=e[0];return P(()=>ul(t()))}let[t,n]=e;return P(()=>ul(n.call(t.self)))},ol=(e,...t)=>{let n=t.length===0?function(){return P(()=>ul(e.apply(this,arguments)))}:function(){let n=P(()=>ul(e.apply(this,arguments)));for(let e=0;e<t.length;e++)n=t[e](n,...arguments);return n};return sl(e.length,n)},sl=(e,t)=>Object.defineProperty(t,"length",{value:e,configurable:!0}),cl=(e,...t)=>sl(e.length,t.length===0?function(){return ll(()=>e.apply(this,arguments))}:function(){let n=ll(()=>e.apply(this,arguments));for(let e of t)n=e(n,...arguments);return n}),ll=e=>{try{let t=e(),n;for(;;){let r=t.next(n);if(r.done)return N(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 P(()=>n?(n=!1,Tl(r.value,e=>ul(t,e))):P(()=>ul(e())))}}}catch(e){return Xc(e)}},ul=function(){let e=Li({op:`Iterator`,[li](e,t){let n=this.iterator;for(;;){let r=n.next(e);if(r.done)return N(r.value);if(!I(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[li](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)}}(),dl=b(2,(e,t)=>new ml(e,hl,N(t))),fl=function(e){return e._stack.push(this),this[D]},pl=Li({op:`OnSuccess`,[O]:fl}),ml=function(e,t,n){this[D]=e,this[li]=t,this.payload=n};ml.prototype=pl;var hl=function(){return this.payload},gl=function(e,t){return t.succeedWith(this.payload)},_l=(()=>{let e=$r();if(e===0)return!1;let t=`~effect/Effect/stackProbe`,n={[t]:function(){return Error()}};ei(1);let r=n[t]();return ei(e),r.stack?.includes(`[as `+t+`]`)===!0})(),vl=function(e,t){let n=this.payload;return t.succeedWith(_l?n(e):ni(()=>n(e)))},yl=function(e){let t=this.payload;return t(e)},bl=function(e){let t=this.payload;return new ml(t(e),gl,e)},xl=function(e){return new ml(this.payload,gl,e)},Sl=b(2,(e,t)=>new ml(e,hi(t)?hl:yl,t)),Cl=b(2,(e,t)=>new ml(e,hi(t)?xl:bl,t)),wl=e=>new ml(e,hl,Pl),Tl=b(2,(e,t)=>new ml(e,yl,t)),I=e=>e[oi]!==void 0,El=b(2,(e,t)=>I(e)?e._tag===`Success`?t(e.value):e:Tl(e,t)),Dl=b(2,(e,t)=>new ml(e,vl,t)),Ol=b(2,(e,t)=>I(e)?Fl(e,t):Dl(e,t)),kl=b(2,(e,t)=>I(e)?Il(e,t):tu(e,t)),Al=b(2,(e,t)=>I(e)?Ll(e,t):nu(e,t)),jl=e=>e._tag===`Success`,Ml=e=>e._tag===`Failure`?Do(e.cause):Oo(e),Nl=e=>e._tag===`Failure`&&Sc(e.cause),Pl=Bi(void 0),Fl=b(2,(e,t)=>e._tag===`Success`?Bi(t(e.value)):e),Il=b(2,(e,t)=>{if(e._tag===`Success`)return e;let n=xc(e.cause);return Ao(n)?e:Wi(t(n.success))}),Ll=b(2,(e,t)=>{if(e._tag===`Success`)return Bi(t.onSuccess(e.value));let n=xc(e.cause);return Ao(n)?e:Wi(t.onFailure(n.success))}),Rl=e=>{let t=[];for(let n of e)n._tag===`Failure`&&t.push(...n.cause.reasons);return t.length===0?Pl:Ui(Ei(t))},zl=b(2,(e,t)=>k(n=>{let r=n.context,i=t(r);return r===i?e:(n.setContext(i),Pu(n,()=>{n.setContext(r)}),e)})),Bl=b(3,(e,t,n)=>zl(e,e=>{let r=yo(e,t),i=n(r);return r===i?e:ho(e,t,i)})),Vl=()=>Hl,Hl=k(e=>N(e.context)),Ul=e=>k(t=>e(t.context)),Wl=b(2,(e,t)=>I(e)?e:zl(e,wo(t))),Gl=function(){return arguments.length===1?b(2,(e,t)=>Kl(e,arguments[0],t)):b(3,(e,t,n)=>Kl(e,t,n)).apply(this,arguments)},Kl=(e,t,n)=>zl(e,ho(t,n)),ql=b(e=>hi(e[0]),(e,t)=>Qu({while:kn,body:On(t?.disableYield?e:Tl(e,e=>Jc)),step:Mn})),Jl=b(2,(e,t)=>new Xl(e,t.length===1?t:e=>t(e))),Yl=Li({op:`OnFailure`,[O]:fl}),Xl=function(e,t){this[D]=e,this[ui]=t};Xl.prototype=Yl;var Zl=b(3,(e,t,n)=>Jl(e,e=>{let r=t(e);return Ao(r)?Wc(r.failure):n(r.success,e)})),Ql=b(2,(e,t)=>Zl(e,xc,e=>t(e))),$l=b(e=>hi(e[0]),(e,t,n,r)=>Jl(e,e=>{let i=xc(e);return Ao(i)?Wc(i.failure):t(i.success)?n(i.success):r?r(i.success):Wc(e)})),eu=b(e=>hi(e[0]),(e,t,n,r)=>$l(e,Array.isArray(t)?e=>S(e,`_tag`)&&t.includes(e._tag):Zn(t),n,r)),tu=b(2,(e,t)=>Ql(e,e=>Zc(()=>t(e)))),nu=b(2,(e,t)=>lu(e,{onFailure:e=>Zc(()=>t.onFailure(e)),onSuccess:e=>Kc(()=>t.onSuccess(e))})),ru=e=>du(e,{onFailure:Oo,onSuccess:Do}),iu=b(2,(e,t)=>new ou(e,t.onSuccess.length===1?t.onSuccess:e=>t.onSuccess(e),t.onFailure.length===1?t.onFailure:e=>t.onFailure(e))),au=Li({op:`OnSuccessAndFailure`,[O]:fl}),ou=function(e,t,n){this[D]=e,this[li]=t,this[ui]=n};ou.prototype=au;var su=function(e,t){let n=this.payload;return t.succeedWith(_l?n.onSuccess(e):ni(()=>n.onSuccess(e)))},cu=((e,t)=>{let n=Li({op:e,[O]:fl,[li]:su,[ui]: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(Ni);if(n===void 0)return Wc(e);let r=this.payload;return t.succeedWith(_l?r.onFailure(n.error):ni(()=>r.onFailure(n.error)))}),lu=b(2,(e,t)=>iu(e,{onFailure:e=>{let n=e.reasons.find(Ni);return n?t.onFailure(n.error):Wc(e)},onSuccess:t.onSuccess})),uu=b(2,(e,t)=>new cu(e,t)),du=b(2,(e,t)=>{if(I(e)){if(e._tag===`Success`)return Bi(t.onSuccess(e.value));let n=xc(e.cause);return Ao(n)?e:Bi(t.onFailure(n.success))}return uu(e,t)}),fu=e=>I(e)?Bi(e):pu(e),pu=Ri({op:`Exit`,[O](e){return e._stack.push(this),this[D]},[li](e,t,n){return t.succeedWith(n??Bi(e))},[ui](e,t,n){return t.succeedWith(n??Ui(e))}}),mu=`~effect/Scope`,hu=`~effect/Scope/Closeable`,gu=A(`effect/Scope`),_u=(e,t)=>k(n=>(Ju(n),vu(e,t)??F)),vu=(e,t)=>{let n=e.state;if(n._tag===`Closed`||(e.state={_tag:`Closed`,exit:t},e.parent!==void 0&&Eu(e.parent,e),n._tag===`Empty`))return;if(n.finalizer!==void 0)return yu(n.finalizer,t);let r=n.finalizers;return r.size===1?yu(r.values().next().value,t):xu(e,r,t)},yu=(e,t)=>{try{return e(t)}catch(e){return Gi(e)}},bu=(e,t)=>jl(e)?t:Jl(t,t=>Wc(Oi(e.cause,t))),xu=ol(function*(e,t,n){let r=[],i=[],a=Array.from(t.values()),o=jc();for(let t=a.length-1;t>=0;t--){let s=a[t];e.strategy===`sequential`?r.push(yield*fu(yu(s,n))):i.push(od(o,yu(s,n),!0,!0,`inherit`))}return i.length>0&&(r=yield*zc(i)),yield*Rl(r)}),Su=(e,t)=>{let n=Ou(t,e);return e.state._tag===`Closed`?(n.state=e.state,n):(Tu(e,n,e=>_u(n,e)),n)},Cu=(e,t)=>P(()=>e.state._tag===`Closed`?t(e.state.exit):(Tu(e,{},t),F)),wu=(e,t)=>Cu(e,On(t)),Tu=(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))}},Eu=(e,t)=>{if(e.state._tag!==`Open`)return;let n=e.state;n.finalizerKey===t?e.state=ku:n.finalizers!==void 0&&(n.finalizers.delete(t),n.finalizers.size===0&&(e.state=ku))},Du=e=>Ou(e,void 0),Ou=(e=`sequential`,t)=>({[hu]:hu,[mu]:mu,strategy:e,parent:t,state:ku}),ku={_tag:`Empty`},Au=Gl(gu),ju=e=>P(()=>{let t=Du();return Fu(e(t),e=>P(()=>vu(t,e)??F))}),Mu=function(){let e=Li({op:`OnExit`,[O](e){return e._stack.push(this),this.effect},[di](e){e.interruptible&&this.interruptible!==!0&&(e._stack.push(Gu),e.interruptible=!1)},[li](e,t,n){n??=Bi(e);let r;try{r=this.onExit(n)}catch(e){r=Gi(e)}return r?Tl(r,e=>n):n},[ui](e,t,n){n??=Ui(e);let r;try{r=this.onExit(n)}catch(e){r=Gi(e)}return r?Tl(bu(n,r),e=>n):n}}),t=function(e,t,n){this.effect=e,this.onExit=t,this.interruptible=n};return t.prototype=e,t}(),Nu=(e,t,n)=>new Mu(e,t,n),Pu=(e,t)=>{e._stack.push(new Mu(void 0,t,void 0))},Fu=b(2,Nu),Iu=b(3,(e,t,n)=>Fu(e,e=>{let r=t(e);return Ao(r)?F:n(r.success,e)})),Lu=b(2,(e,t)=>Iu(e,Ml,t)),Ru=b(3,(e,t,n)=>Fu(e,e=>{if(e._tag!==`Failure`)return F;let r=t(e.cause);return Ao(r)?F:n(r.success,e.cause)})),zu=b(2,(e,t)=>Ru(Cc,t)(e)),Bu=On(1/0),Vu=(e,t)=>{let n=0,r,i,a=(e,t)=>(t.awaiters++,Pu(e,()=>{if(!(--t.awaiters>0||i!==t))return i=void 0,Vc(t.fiber)}),Bc(t.fiber));return[k(o=>{if(i!==void 0)return o===i.fiber?Bc(i.fiber):a(o,i);if(r!==void 0&&(n===1/0||o.getRef(Od).currentTimeMillisUnsafe()<n))return r;r=void 0;let s=o.getRef(Od),c={fiber:new Mc(o.context),awaiters:0};i=c;let l=a(o,c);return c.fiber.evaluate(Nu(e,e=>{if(i!==c||(i=void 0,Nl(e)))return;let a=t(e);n=a===1/0?1/0:s.currentTimeMillisUnsafe()+a,r=e})),c.fiber._exit??l}),Kc(()=>{r=void 0})]},Hu=e=>Kc(()=>Vu(e,Bu)[0]),Uu=e=>k(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Gu),e):e),Wu=Ri({op:`SetInterruptible`,[di](e){if(e.interruptible=this[D],e._interruptedCause&&e.interruptible)return()=>Wc(e._interruptedCause)}}),Gu=Wu(!0),Ku=Wu(!1),qu=e=>{if(e.interruptible=!0,e._stack.push(Ku),e._interruptedCause)return Wc(e._interruptedCause)},Ju=e=>{let t=e;t.interruptible&&(t.interruptible=!1,t._stack.push(Gu))},Yu=e=>k(t=>t.interruptible?e:qu(t)??e),Xu=e=>k(t=>t.interruptible?(t.interruptible=!1,t._stack.push(Gu),e(Yu)):e(x)),Zu=(e,t)=>$n(e)?t?.mode===`result`?$u(e,ru,t):$u(e,x,t):t?.discard?t.mode===`result`?$u(Object.values(e),ru,t):$u(Object.values(e),x,t):P(()=>{let n={};return dl($u(Object.entries(e),([e,r])=>Dl(t?.mode===`result`?ru(r):r,t=>{ri(n,e,t)}),{discard:!0,concurrency:t?.concurrency}),n)}),Qu=Ri({op:`While`,[li](e,t){return this[D].step(e),this[D].while()?(t._stack.push(this),this[D].body()):Pl},[O](e){return this[D].while()?(e._stack.push(this),this[D].body()):Pl}}),$u=b(e=>typeof e[1]==`function`,(e,t,n)=>P(()=>{let r=td(n?.concurrency);if(r===1)return ed(e,t,n);let i=Bo(e),a=i.length;if(a===0)return n?.discard?F:N([]);let o=n?.discard?void 0:Array(a),s=ad({f:t,out:o},i,{concurrency:r});return s?dl(s,o):N(o)})),ed=(e,t,n)=>P(()=>{let r=n?.discard?void 0:[],i=e[Symbol.iterator](),a=i.next(),o=0;return dl(Qu({while:()=>!a.done,body:()=>t(a.value,o++),step:e=>{r&&r.push(e),a=i.next()}}),r)}),td=e=>e===`unbounded`?1/0:Math.max(1,e??1),nd=()=>e=>{let t=e.onItem,n=e.step,r=(e,t,r,a,o)=>Tl(fu(o),o=>n(e,t[r],o,r)??i(e,t,r+1,a)??F),i=(e,i,a=0,o=i.length)=>{for(;a<o;a++){let s=i[a],c=t(e,s,a);if(!I(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},rd=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=Gi(e);return f=t,c=!0,u&&u.size>0?Tl(Uu(Uc(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(I(ee)){if(f=n(e,o,ee,a),f)break}else if(l){p=void 0;let t=od(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=Ei(e);f=Ui(f._tag===`Failure`?Oi(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??F)}catch(e){d(m(e))}}),u.size<s)continue;i=!0,a++;return}else return rl(e=>{l=jc(),u=new Set,p=ee,d=e;let t;try{t=h()}catch(t){return e(m(t))}return t?e(t):P(()=>(f??=Pl,Tl(u?Uc(u):F,()=>f?._tag===`Failure`?f:F)))})}if(c=!0,f){if(u&&u.size>0){let e=Lc(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(F);else return Pl}};return h()}},id=()=>e=>rd(e),ad=rd({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)}}),od=(e,t,n=!1,r=!1,i=!1)=>{let a=e,o=i===`inherit`?a.interruptible:!i,s=new Mc(a.context,o);return r||(a.children().add(s),s._parent=a),n?s.evaluate(t):(s._asyncContext=Ac(),a.currentDispatcher.scheduleTask(()=>s.evaluate(t),0)),s},sd=e=>(t,n)=>{let r=new Mc(n?.scheduler?ho(e,Ps,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},cd=sd(fo()),ld=e=>{let t=sd(e);return(e,n)=>{let r=t(e,n);return new Promise(e=>{r.addObserver(t=>e(t))})}},ud=(e=>{let t=ld(e);return(e,n)=>t(e,n).then(e=>{if(e._tag===`Failure`)throw Tc(e.cause);return e.value})})(fo()),dd=e=>{let t=sd(e);return e=>{if(I(e))return e;let n=new zs(`sync`),r=t(e,{scheduler:n});return r._dispatcher?.flush(),r._exit??Gi(new Ld(r))}},fd=dd(fo()),pd=(e=>{let t=dd(e);return e=>{let n=t(e);if(n._tag===`Failure`)throw Tc(n.cause);return n.value}})(fo()),md=N(!0),hd=N(!1),gd=class{waiters=[];scheduled=void 0;_isOpen;constructor(e){this._isOpen=e}scheduleUnsafe(e){if(this.waiters.length===0)return md;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=[],md}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](Pl)};flushWaiters(){let e=this.waiters;this.waiters=[],this.flushScheduled();for(let t=0;t<e.length;t++)e[t](Pl)}open=k(e=>this._isOpen?hd:(this._isOpen=!0,this.scheduleUnsafe(e)));release=k(e=>this._isOpen?hd:this.scheduleUnsafe(e));openUnsafe(){return!this._isOpen&&(this._isOpen=!0,this.flushWaiters(),!0)}await=rl(e=>this._isOpen?e(F):(this.waiters.push(e),Kc(()=>{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=Kc(()=>this.closeUnsafe());whenOpen=e=>Tl(this.await,()=>e);isOpen(){return this._isOpen}},_d=e=>new gd(e??!1),vd=BigInt(0),yd={_tag:`Span`,spanId:`noop`,traceId:`noop`,sampled:!1,status:{_tag:`Ended`,startTime:vd,endTime:vd,exit:Pl},attributes:new Map,links:[],kind:`internal`,attribute(){},event(){},end(){},addLinks(){}},bd=e=>Object.assign(Object.create(yd),e),xd=e=>e?bo(e.annotations,nc)?e._tag===`Span`?xd(Wa(e.parent)):La():Ra(e):La(),Sd=(e,t,n)=>{let r=!e.cache.tracerEnabled||n?.annotations&&bo(n.annotations,nc),i=n?.parent===void 0?n?.root?La():xd(e.cache.span):Ra(n.parent),a;if(r)a=bd({name:t,parent:i,annotations:ho(n?.annotations??fo(),nc,!0)});else{let r=e.cache.tracer??oc,o=e.getRef(Od),s=e.getRef(dc),c=e.getRef(fc),l=e.getRef(pc),u=n?.level??e.getRef(rc),d=n?.links===void 0?l.length===0?[]:l.slice():[...l,...n.links];a=r.span({name:t,parent:i,annotations:n?.annotations??fo(),links:d,startTime:s?o.currentTimeNanosUnsafe():vd,kind:n?.kind??`internal`,root:n?.root??!1,sampled:n?.sampled??(Ba(i)&&i.value.sampled===!1?!1:!Bd(e.getRef(ic),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},Cd=(e,t)=>(t=typeof t==`function`?t:jn,Bl(lc,n=>({name:e,stack:t,parent:n}))),wd=(e,t,n,r)=>Kc(()=>{e.status._tag!==`Ended`&&e.end(r?n.currentTimeNanosUnsafe():vd,t)}),Td=(e,...t)=>{let n=t.length===1?void 0:t[0],r=t[t.length-1];return k(t=>{let i=Sd(t,e,n),a=t.getRef(Od),o=t.getRef(dc);return Pu(t,e=>wd(i,e,a,o)),r(i)})},Ed=Gl(ec),Dd=function(){let e=hi(arguments[0]),t=e?arguments[1]:arguments[0],n=e?arguments[2]:arguments[1],r=x;return t._tag===`Span`&&(n=gc(n),r=Cd(t.name,n?.captureStackTrace)),e?Ed(r(arguments[0]),t):e=>Ed(r(e),t)},Od=j(`effect/Clock`,{defaultValue:()=>new Ad}),kd=2**31-1,Ad=class{currentTimeMillisUnsafe(){return Date.now()}currentTimeMillis=Kc(()=>this.currentTimeMillisUnsafe());currentTimeNanosUnsafe(){return Nd()}currentTimeNanos=Kc(()=>this.currentTimeNanosUnsafe());monotonicTimeNanosUnsafe(){return Md()}monotonicTimeNanos=Kc(()=>this.monotonicTimeNanosUnsafe());sleep(e){return this.sleepMillis(Os(e))}sleepMillis(e){return e<=0?Jc:Number.isFinite(e)?rl(t=>{let n=e>kd?this.sleepMillis(e-kd):F,r=setTimeout(()=>t(n),Math.min(e,kd));return Kc(()=>clearTimeout(r))}):il}},jd=BigInt(1e6),Md=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())*jd;return e>t&&(t=e),t}}(),Nd=function(){let e=BigInt(1e9),t;return()=>{let n=Md(),r=BigInt(Date.now())*jd;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}}(),Pd=`~effect/Cause/IllegalArgumentError`,Fd=class extends Ji(`IllegalArgumentError`){[Pd]=Pd;constructor(e){super({message:e})}},Id=`~effect/Cause/AsyncFiberError`,Ld=class extends Ji(`AsyncFiberError`){[Id]=Id;constructor(e){super({message:`An asynchronous Effect was executed with Effect.runSync`,fiber:e})}},Rd=`~effect/Cause/UnknownError`,zd=class extends Ji(`UnknownError`){[Rd]=Rd;constructor(e,t){super({message:t,cause:e})}},Bd=Pa(Ma(ja,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}})),Vd={bold:`1`,red:`31`,green:`32`,yellow:`33`,blue:`34`,cyan:`36`,white:`37`,gray:`90`,black:`30`,bgBrightRed:`101`};Vd.gray,Vd.blue,Vd.green,Vd.yellow,Vd.red,Vd.bgBrightRed,Vd.black;var Hd=yi,Ud=bi,Wd=Ni,Gd=Ei,Kd=ki,qd=ji,Jd=e=>new Ti(e),Yd=e=>new Ai(e),Xd=yc,Zd=wc,Qd=Oi,$d=Tc,ef=Sc,tf=Xi,nf=ea,rf=Fd,af=Bi,of=Ui,sf=Wi,cf=Pl,lf=jl,uf={"~effect/Deferred":{_A:x,_E:x},pipe(){return y(this,arguments)}},df=function(){this.resumes=void 0,this.effect=void 0};df.prototype=uf;var ff=()=>new df,pf=e=>rl(t=>e.effect?t(e.effect):(e.resumes??=[],e.resumes.push(t),Kc(()=>{let n=e.resumes;if(n===void 0)return;let r=n.indexOf(t);r>=0&&n.splice(r,1)}))),mf=(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},hf=dc,gf=gu,_f=Du,vf=Au,yf=Cu,bf=wu,xf=Su,Sf=_u,Cf=`~effect/Layer`,wf=`~effect/Layer/MemoMap`,Tf=(e,t)=>{let n={observers:0,deferred:ff(),scope:_f(),finalizer:r=>P(()=>--n.observers>0?F:(e.map.delete(t),Sf(n.scope,r)))};return n},Ef=(e,t)=>t.state._tag!==`Closed`&&(e.observers++,Tu(t,{},e.finalizer),!0),Df={[Cf]:{_ROut:x,_E:x,_RIn:x},pipe(){return y(this,arguments)}},Of=e=>{let t=Object.create(Df);return t.build=e,t},kf=e=>Of((t,n)=>{let r=xf(n);return Fu(e(t,r),e=>e._tag===`Failure`?Sf(r,e):F)}),Af=e=>{let t=kf((n,r)=>n.getOrElseMemoize(t,r,e));return t},jf=class{get[wf](){return wf}parent;constructor(e){this.parent=e}map=new Map;get(e,t){let n=this.map.get(e);return n?(Ef(n,t),n.deferred.effect??pf(n.deferred)):this.parent?.get(e,t)}getOrElseMemoize(e,t,n){return P(()=>{let r;return Nu(P(()=>{let i=this.get(e,t);if(i)return i;let a=Tf(this,e);return Ef(a,t)?(r=a.deferred,this.map.set(e,a),n(this,a.scope)):n(this,t)}),e=>{r&&mf(r,e)})})}},Mf=()=>new jf,Nf=e=>new jf(e),Pf=class e extends A()(`effect/Layer/CurrentMemoMap`){static forkOrCreate(t){let n=_o(t,e);return n?Nf(n):Mf()}},Ff=b(3,(e,t,n)=>Gl(Dl(P(()=>e.build(t,n)),ho(Pf,t)),Pf,t)),If=b(2,(e,t)=>k(n=>Ff(e,Pf.forkOrCreate(n.context),t))),Lf=e=>Of(On(N(e))),Rf=function(){return arguments.length===1?e=>zf(arguments[0],e):zf(arguments[0],arguments[1])},zf=(e,t)=>Bf(Dl(t,t=>mo(e,t))),Bf=e=>Af((t,n)=>vf(e,n)),Vf=e=>Bf(dl(e,fo())),Hf=(e,t,n)=>{let r=xf(n,`parallel`);return $u(e,e=>e.build(t,xf(r,`sequential`)),{concurrency:e.length}).pipe(Dl(e=>To(...e)))},Uf=(...e)=>kf((t,n)=>Hf(e,t,n)),Wf=(e,t,n)=>kf((r,i)=>Tl(Array.isArray(t)?Hf(t,r,i):t.build(r,i),t=>e.build(r,i).pipe(Wl(t),Dl(e=>n(e,t))))),Gf=b(2,(e,t)=>Wf(e,t,x)),Kf=b(2,(e,t)=>Wf(e,t,(e,t)=>wo(t,e))),qf=Od,Jf=`~effect/DateTime`,Yf=`~effect/DateTime/TimeZone`,Xf={[Jf]:Jf,pipe(){return y(this,arguments)},[Jr](){return this.toString()},toJSON(){return cp(this).toJSON()}},Zf={...Xf,_tag:`Utc`,[C](){return ar(this.epochMilliseconds)},[T](e){return $f(e)&&e._tag===`Utc`&&this.epochMilliseconds===e.epochMilliseconds},toString(){return`DateTime.Utc(${cp(this).toJSON()})`}};({...Xf});var Qf={[Yf]:Yf,[Jr](){return this.toString()}};({...Qf}),{...Qf};var $f=e=>S(e,Jf),ep=e=>$f(e[0]),tp=e=>e._tag===`Utc`,np=e=>{let t=Object.create(Zf);return t.epochMilliseconds=e,Object.defineProperty(t,"partsUtc",{value:void 0,enumerable:!1,writable:!0}),t},rp=e=>{let t=e.getTime();if(Number.isNaN(t))throw new rf(`Invalid date`);return np(t)},ip=e=>{if($f(e))return e;if(e instanceof Date)return rp(e);if(typeof e==`object`){if(`epochMilliseconds`in e)return rp(new Date(e.epochMilliseconds));let t=new Date(0);return lp(t,e),rp(t)}return typeof e==`string`&&!ap(e)?rp(new Date(e+`Z`)):rp(new Date(e))},ap=e=>/Z|GMT|[+-]\d{2}$|[+-]\d{2}:?\d{2}$|\]$/.test(e),op=Ga(ip),sp=e=>np(e.epochMilliseconds),cp=e=>new Date(e.epochMilliseconds),lp=(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)},up=b(ep,(e,t)=>new Intl.DateTimeFormat(t?.locale,t).format(e.epochMilliseconds)),dp=e=>cp(e).toISOString(),fp=b(2,(e,t)=>Zl(e,hp,e=>t(e))),pp=e=>e._tag===`Fail`&&tf(e.error),mp=e=>{let t,n=!1;for(let r of e.reasons)pp(r)?t??=r.error:r._tag!==`Interrupt`&&(n=!0);return t===void 0?Oo(e):n?Oo(Gd(e.reasons.filter(e=>!pp(e)))):Do(t)},hp=e=>{let t=mp(e);return Ao(t)?t:Do(t.success.value)},gp=e=>{let t=mp(e);return Ao(t)?of(t.failure):af(t.success.value)},_p=(e,t,n)=>ju(r=>Tl(n?.local?Ff(t,Mf(),r):If(t,r),t=>Wl(e,t))),vp=b(e=>hi(e[0]),(e,t,n)=>co(t)?Wl(e,t):_p(e,Array.isArray(t)?Uf(...t):t,n)),yp=hi,bp=Zu,xp=$c,Sp=el,L=N,Cp=P,wp=Kc,Tp=F,Ep=al,R=Gc,Dp=Wc,Op=Yc,kp=Xc,Ap=Qc,jp=k,Mp=qc,z=Tl,Np=Sl,Pp=Cl,Fp=fu,Ip=Dl,Lp=dl,Rp=wl,zp=eu,Bp=Jl,Vp=tu,Hp=iu,Up=Vl,Wp=Ul,Gp=vp,Kp=Wl,qp=zl,Jp=Gl,Yp=Lu,Xp=Fu,Zp=Hu,Qp=zu,$p=Xu,em=ql,tm=Td,nm=Dd,rm=cd,im=ud,am=pd,om=fd,sm=ol,cm=Ol,lm=kl,um=Al,dm=El,fm=cl,pm=`~effect/BigDecimal`,mm={[pm]:pm,[C](){let e=Sm(this);return nr(or(String(e.value)),ar(e.scale))},[T](e){return hm(e)&&Dm(this,e)===0},toString(){return`BigDecimal(${km(this)})`},toJSON(){return{_id:`BigDecimal`,value:String(this.value),scale:this.scale}},[Jr](){return this.toJSON()},pipe(){return y(this,arguments)}},hm=e=>S(e,pm),gm=(e,t)=>{if(!Number.isSafeInteger(t))throw RangeError(`Scale must be a safe integer, got ${t}`);let n=Object.create(mm);return n.value=e,n.scale=t,n},_m=(e,t)=>{let n=gm(e,t);return n.normalized=n,n},vm=BigInt(0),ym=BigInt(1),bm=BigInt(10),xm=_m(vm,0),Sm=e=>{if(e.normalized===void 0){if(e.value===vm)e.normalized=xm;else{let t=`${e.value}`,n=t.length;for(;t[n-1]===`0`;)n--;e.normalized=_m(BigInt(t.slice(0,n)),e.scale-(t.length-n))}}return e.normalized},Cm=100,wm=[ym],Tm=(e,t)=>e===t?0:e<t?-1:1,Em=(e,t)=>{let n=`${e.value<vm?-e.value:e.value}`,r=`${t.value<vm?-t.value:t.value}`,i=BigInt(n.length-r.length)-BigInt(e.scale)+BigInt(t.scale);if(i!==vm)return i<vm?-1:1;let a=Math.max(n.length,r.length);return Aa(n.padEnd(a,`0`),r.padEnd(a,`0`))},Dm=(e,t)=>{if(e.scale===t.scale)return Tm(e.value,t.value);let n=Om(e),r=Om(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>Cm)return n===-1?Em(t,e):Em(e,t);let o=wm[a]??=bm**BigInt(a);return i>0?Tm(e.value,t.value*o):Tm(e.value*o,t.value)},Om=e=>e.value===vm?0:e.value<vm?-1:1,km=e=>{let t=Sm(e);if(Math.abs(t.scale)>=16)return Am(t);let n=t.value<vm,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},Am=e=>{if(jm(e))return`0e+0`;let t=Sm(e),n=`${t.value}`,r=t.value<vm?2:1,i=n.slice(0,r),a=n.slice(r),o=a.length-t.scale;return`${i}${a===``?``:`.${a}`}e${o>=0?`+`:``}${o}`},jm=e=>e.value===vm,Mm=BigInt(1),Nm=BigInt(1e3),Pm=BigInt(1024),Fm=[{symbol:`B`,factor:Mm,names:[`B`,`byte`,`bytes`]},{symbol:`kB`,factor:Nm,names:[`kB`,`kilobyte`,`kilobytes`]},{symbol:`MB`,factor:Nm**BigInt(2),names:[`MB`,`megabyte`,`megabytes`]},{symbol:`GB`,factor:Nm**BigInt(3),names:[`GB`,`gigabyte`,`gigabytes`]},{symbol:`TB`,factor:Nm**BigInt(4),names:[`TB`,`terabyte`,`terabytes`]},{symbol:`PB`,factor:Nm**BigInt(5),names:[`PB`,`petabyte`,`petabytes`]},{symbol:`EB`,factor:Nm**BigInt(6),names:[`EB`,`exabyte`,`exabytes`]},{symbol:`ZB`,factor:Nm**BigInt(7),names:[`ZB`,`zettabyte`,`zettabytes`]},{symbol:`YB`,factor:Nm**BigInt(8),names:[`YB`,`yottabyte`,`yottabytes`]},{symbol:`RB`,factor:Nm**BigInt(9),names:[`RB`,`ronnabyte`,`ronnabytes`]},{symbol:`QB`,factor:Nm**BigInt(10),names:[`QB`,`quettabyte`,`quettabytes`]}],Im=[Fm[0],{symbol:`KiB`,factor:Pm,names:[`KiB`,`kibibyte`,`kibibytes`]},{symbol:`MiB`,factor:Pm**BigInt(2),names:[`MiB`,`mebibyte`,`mebibytes`]},{symbol:`GiB`,factor:Pm**BigInt(3),names:[`GiB`,`gibibyte`,`gibibytes`]},{symbol:`TiB`,factor:Pm**BigInt(4),names:[`TiB`,`tebibyte`,`tebibytes`]},{symbol:`PiB`,factor:Pm**BigInt(5),names:[`PiB`,`pebibyte`,`pebibytes`]},{symbol:`EiB`,factor:Pm**BigInt(6),names:[`EiB`,`exbibyte`,`exbibytes`]},{symbol:`ZiB`,factor:Pm**BigInt(7),names:[`ZiB`,`zebibyte`,`zebibytes`]},{symbol:`YiB`,factor:Pm**BigInt(8),names:[`YiB`,`yobibyte`,`yobibytes`]}];[...Fm,...Im.slice(1)];var Lm=$f,Rm=tp,zm=rp,Bm=ip,Vm=op,Hm=sp,Um=up,Wm=dp,Gm=e=>qm(typeof e==`string`?Jm.encode(e):e),Km=e=>{let t=Ym(e),n=t.length;if(n%4!=0)return Oo(new qs({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 Oo(new qs({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=Qm(t.charCodeAt(e))<<18|Qm(t.charCodeAt(e+1))<<12|Qm(t.charCodeAt(e+2))<<6|Qm(t.charCodeAt(e+3));r[i]=n>>16,r[i+1]=n>>8&255,r[i+2]=n&255}return Do(r)}catch(e){return Oo(new qs({kind:`Decode`,module:`Base64`,input:t,message:e instanceof Error?e.message:`Invalid input`}))}},qm=e=>{let t=e.length,n=``,r=2;for(;r<t;r+=3)n+=Xm[e[r-2]>>2],n+=Xm[(e[r-2]&3)<<4|e[r-1]>>4],n+=Xm[(e[r-1]&15)<<2|e[r]>>6],n+=Xm[e[r]&63];return r===t+1&&(n+=Xm[e[r-2]>>2],n+=Xm[(e[r-2]&3)<<4],n+=`==`),r===t&&(n+=Xm[e[r-2]>>2],n+=Xm[(e[r-2]&3)<<4|e[r-1]>>4],n+=Xm[(e[r-1]&15)<<2],n+=`=`),n},Jm=new TextEncoder,Ym=e=>e.replace(/[\n\r]/g,``),Xm=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Zm=new Uint8Array(123).fill(255);for(let e=0;e<64;e++)Zm[Xm.charCodeAt(e)]=e;Zm[61]=0;var Qm=e=>{if(e>=Zm.length||Zm[e]===255)throw TypeError(`Invalid character ${String.fromCharCode(e)}`);return Zm[e]},$m=`~effect/http/Cookies`,eh=`~effect/http/Cookies/Cookie`,th={[$m]:$m,...Xr,toJSON(){return{_id:`effect/Cookies`,cookies:Fo(this.cookies,e=>e.toJSON())}},pipe(){return y(this,arguments)}},nh=e=>{let t=Object.create(th);return t.cookies=e,t},rh=e=>{let t={};for(let n of e)ri(t,n.name,n);return nh(t)},ih=e=>{let t=typeof e==`string`?[e]:e,n=[];for(let e of t){let t=ah(e.trim());t&&n.push(t)}return rh(n)};function ah(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(!oh.test(r))return;let i=t[0].slice(n+1),a=ch(i);if(t.length===1)return Object.assign(Object.create(sh),{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=Cs(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(sh),{name:r,value:a,valueEncoded:i,options:Object.keys(o).length>0?o:void 0})}var oh=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,sh={[eh]:eh,...Xr,toJSON(){return{_id:`effect/Cookies/Cookie`,name:this.name,value:this.value,options:this.options}}},ch=e=>{try{return decodeURIComponent(e)}catch{return e}},lh=new WeakMap,uh=`~effect/Redacted`,dh=e=>S(e,uh),fh=(e,t)=>{let n=Object.create(ph);return t?.label&&(n.label=t.label),lh.set(n,e),n},ph={[uh]:{_A:e=>e},label:void 0,...pi,toJSON(){return this.toString()},toString(){return`<redacted${Bn(this.label)?`:`+this.label:``}>`},[C](){return w(lh.get(this))},[T](e){return dh(e)&&_r(lh.get(this),lh.get(e))}},mh=Symbol.for(`~effect/http/Headers`),hh=Object.defineProperties(Object.create(null),{[mh]:{value:mh},[Mr]:{value(e){return Th(this,bo(e,Dh))}},toJSON:{value(){return Pr(this)}},[T]:{value(e){return _h(this,e)}},[C]:{value(){return cr(this)}},toString:{value:Xr.toString},[Jr]:{value:Xr[Jr]}}),gh=e=>Object.assign(Object.create(hh),e),_h=Ro(ia()),vh=Object.create(hh),yh=e=>{if(e===void 0)return vh;if(Symbol.iterator in e){let t=Object.create(hh);for(let[n,r]of e)t[n.toLowerCase()]=r;return t}let t=Object.create(hh);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},bh=e=>Object.setPrototypeOf(e,hh),xh=b(3,(e,t,n)=>{let r=gh(e);return r[t.toLowerCase()]=n,r}),Sh=b(2,(e,t)=>gh({...e,...yh(t)})),Ch=b(2,(e,t)=>{let n=gh(e);return Object.assign(n,t),n}),wh=b(2,(e,t)=>{let n=gh(e);return delete n[t.toLowerCase()],n}),Th=b(2,(e,t)=>{let n={...e},r=t=>{if(typeof t==`string`){let r=t.toLowerCase();r in e&&(n[r]=fh(e[r]))}else for(let r in e)r.search(t)!==-1&&(n[r]=fh(e[r]))};if(Array.isArray(t))for(let e=0;e<t.length;e++)r(t[e]);else r(t);return n}),Eh=(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},Dh=j(`effect/Headers/CurrentRedactedNames`,{defaultValue:()=>[`authorization`,`cookie`,`set-cookie`,`x-api-key`,`AWSAccessKeyId`,`Signature`,`sig`,`X-Goog-Signature`]}),Oh=`~effect/http/UrlParams`,kh=e=>S(e,Oh),Ah={...pi,[Oh]:Oh,[Symbol.iterator](){return this.params[Symbol.iterator]()},toJSON(){return{_id:`UrlParams`,params:Object.fromEntries(this.params)}},[T](e){return Ph(this,e)},[C](){return ur(this.params.flat())}},jh=e=>{let t=Object.create(Ah);return t.params=e,t},Mh=e=>{if(kh(e))return e;let t=Nh(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 jh(n)},Nh=e=>{let t=typeof e[Symbol.iterator]==`function`?Bo(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=Nh(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},Ph=na((e,t)=>Fh(e.params,t.params)),Fh=Xo(No([ia(),ia()])),Ih=jh([]),Lh=b(2,(e,t)=>jh(t(e.params))),Rh=b(2,(e,t)=>{let n=Mh(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 jh(n)}),zh=b(2,(e,t)=>Lh(e,Uo(Mh(t).params))),Bh=e=>new URLSearchParams(Mh(e).params).toString(),Vh=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 Hh(e){return e.checks?e.checks[e.checks.length-1].annotations:e.annotations}function Uh(e){return t=>Hh(t)?.[e]}var Wh=`~structural`,Gh=`~sentinels`,Kh=`~constructor`,qh=Nn(e=>{let t=Hh(e)?.identifier;return typeof t==`string`?t:e.getExpected(qh)}),B=Symbol(),Jh=af,Yh=Jh(B),V=Jh(B),Xh=e=>e===B?La():Ra(e),Zh=e=>e._tag===`None`?Yh:Jh(e.value),Qh=`~effect/SchemaIssue/Issue`;function $h(e){return S(e,Qh)&&e[Qh]===Qh}function eg(e){return Object.hasOwn(e,`input`)}var tg=class{[Qh]=Qh;constructor(e,t){t?.reportInput===!0&&e!==B&&(this.input=e)}},ng=class extends tg{_tag=`Filter`;filter;issue;constructor(e,t,n,r){super(n,r),this.filter=e,this.issue=t}},rg=class extends tg{_tag=`Encoding`;ast;issue;constructor(e,t,n,r){super(n,r),this.ast=e,this.issue=t}},ig=class extends tg{_tag=`Pointer`;path;issue;constructor(e,t){super(),this.path=e,this.issue=t}},ag=class extends tg{_tag=`MissingKey`;annotations;constructor(e){super(),this.annotations=e}},og=class extends tg{_tag=`UnexpectedKey`;ast;constructor(e,t,n){super(t,n),this.ast=e}},sg=class extends tg{_tag=`Composite`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},cg=class extends tg{_tag=`InvalidType`;ast;constructor(e,t,n){super(t,n),this.ast=e}},lg=class extends tg{_tag=`InvalidValue`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}};function ug(e,t,n,r,i){return new sg(e,[new ig([t],n)],r,i)}var dg=class extends tg{_tag=`Forbidden`;annotations;constructor(e,t,n){super(t,n),this.annotations=e}},fg=class extends tg{_tag=`AnyOf`;ast;issues;constructor(e,t,n,r){super(n,r),this.ast=e,this.issues=t}},pg=class extends tg{_tag=`OneOf`;ast;successes;constructor(e,t,n,r){super(n,r),this.ast=e,this.successes=t}};function mg(e,t,n){if($h(e))return e;if(typeof e==`string`)return new lg({message:e},t,n);let r=typeof e.issue==`string`?new lg({message:e.issue},t,n):e.issue;return new ig(e.path,r)}function hg(e,t,n){if(e!==void 0)return typeof e==`boolean`?e?void 0:new lg(void 0,t,n):mg(e,t,n)}function gg(e,t,n,r){return Array.isArray(t)?Go(t)?t.length===1?mg(t[0],n,r):new sg(e,Yo(t,e=>mg(e,n,r)),n,r):void 0:hg(t,n,r)}var _g=e=>{let t=Og(e);if(t!==void 0)return t;switch(e._tag){case`InvalidType`:return Sg(qh(e.ast),e);case`InvalidValue`:{let t=xg(e);if(t!==void 0)return Sg(t,e);let n=bg(e);return n===void 0?`Expected a valid value`:`Invalid data ${n}`}case`MissingKey`:return`Missing key`;case`UnexpectedKey`:{let t=bg(e);return t===void 0?`Expected no excess property`:`Unexpected key with value ${t}`}case`Forbidden`:return`Forbidden operation`;case`OneOf`:{let t=bg(e);return t===void 0?`Expected exactly one member to match`:`Expected exactly one member to match the input ${t}`}}},vg=e=>Og(e.issue)??Og(e);function yg(e){return t=>({issues:Cg(t,[],e?.leafHook??_g,e?.checkHook??vg)})}function bg(e){return eg(e)?E(e.input):void 0}function xg(e){let t=e.annotations?.expected;return typeof t==`string`?t:void 0}function Sg(e,t){let n=bg(t);return n===void 0?`Expected ${e}`:`Expected ${e}, got ${n}`}function Cg(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 Cg(e.issue,t,n,r);let a=xg(e.issue);return[{path:t,message:a===void 0?Sg(wg(e.filter),e):Sg(a,e.issue)}]}case`Encoding`:return Cg(e.issue,t,n,r);case`Pointer`:return Cg(e.issue,[...t,...e.path],n,r);case`Composite`:return e.issues.flatMap(e=>Cg(e,t,n,r));case`AnyOf`:return e.issues.length===0?[{path:t,message:Og(e)??Sg(qh(e.ast),e)}]:e.issues.flatMap(e=>Cg(e,t,n,r));default:return[{path:t,message:n(e)}]}}function wg(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=>wg(e)).join(` & `)}}function Tg(){return e=>Dg(e,``)}var Eg=Tg();function Dg(e,t){let n;switch(e._tag){case`Filter`:{let r=vg(e);if(r!==void 0)n=r;else{if(e.issue._tag!==`InvalidValue`)return Dg(e.issue,t);let r=xg(e.issue);n=r===void 0?Sg(wg(e.filter),e):Sg(r,e.issue)}break}case`Encoding`:return Dg(e.issue,t);case`Pointer`:return Dg(e.issue,t+Vr(e.path));case`Composite`:case`AnyOf`:if(e._tag===`Composite`||e.issues.length>0)return e.issues.map(e=>Dg(e,t)).join(`
9
- `);n=Og(e)??Sg(qh(e.ast),e);break;default:n=_g(e)}return t?`${n}\n at ${t}`:n}function Og(e){if(e._tag===`Pointer`)return;if(e._tag===`Encoding`)return Og(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 kg(e){let t;for(let n of e.reasons){if(!Wd(n)||!$h(n.error))return;t??=n.error}return t}function Ag(e,t){let n=kg(e);if(n===void 0)throw Error(t,{cause:e});return n}var jg=e=>Object.assign(Object.create(En),e);function Mg(e){return Rg((t,n)=>R(e(t,n)))}function Ng(e){return Mg((t,n)=>{let r={message:e(t)};return Ba(t)?new dg(r,t.value,n):new dg(r)})}var Pg=Ng(()=>`Encoding is not supported`),Fg=jg({_tag:`Passthrough`});function Ig(){return Fg}function H(e){return jg({_tag:`Transform`,transform:e})}function Lg(e){return jg({_tag:`TransformEffect`,transform:e})}function Rg(e){return jg({_tag:`TransformOptionalEffect`,transform:e})}function zg(){return H(globalThis.String)}function Bg(){return H(globalThis.Number)}function Vg(e){return Lg((t,n)=>Ap({try:()=>JSON.parse(t,e?.reviver),catch:()=>new lg({expected:`a valid JSON string`},t,n)}))}function Hg(e){return Lg((t,n)=>Ap({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 lg({expected:`a JSON-serializable value`},t,n)}))}function Ug(){return H(Gm)}function Wg(){return Lg((e,t)=>lm(Mp(Km(e)),()=>new lg({expected:`a valid Base64 string`},e,t)))}var Gg=class extends Dn{_tag=`Middleware`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new Gg(this.encode,this.decode)}},Kg=`~effect/SchemaTransformation/Transformation`,qg=class extends Dn{[Kg]=Kg;_tag=`Transformation`;decode;encode;constructor(e,t){super(),this.decode=e,this.encode=t}flip(){return new qg(this.encode,this.decode)}};function Jg(e){return S(e,Kg)&&e[Kg]===Kg}var Yg=e=>Jg(e)?e:new qg(e.decode,e.encode);function Xg(e){return new qg(Lg(e.decode),Lg(e.encode))}function Zg(e){return new qg(H(e.decode),H(e.encode))}var Qg=new qg(Ig(),Ig());function $g(){return Qg}var e_=new qg(Bg(),zg()),t_=e=>Yn(e)&&typeof e.message==`string`,n_=e=>{let t=Object.hasOwn(e,`cause`)?Error(e.message,{cause:o_(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},r_=e=>{try{let t=Gr(e);return t===void 0?E(e):JSON.parse(t)}catch{return E(e)}},i_=(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},a_=e=>{let t=new WeakSet,n=r=>{if(Qn(r)){if(t.has(r))return`[Circular]`;t.add(r);let i=i_(r,e,n);return t.delete(r),i}return r_(r)};return n},o_=e=>t_(e)?n_(e):e,s_=e=>Zg({decode:o_,encode:a_(e)}),c_=new qg(Wg(),Ug());function l_(e){return new qg(Vg(e??{}),Hg(e))}function u_(e){return t=>t._tag===e}var d_=u_(`Declaration`),f_=u_(`Null`),p_=u_(`Void`),m_=u_(`Never`),h_=u_(`Literal`),g_=u_(`UniqueSymbol`),__=u_(`Enum`),v_=u_(`Arrays`),y_=u_(`Objects`),b_=u_(`Union`),x_=u_(`Suspend`),U=class{to;transformation;constructor(e,t){this.to=e,this.transformation=t}},S_={},C_=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}},w_=`~effect/Schema`,T_=class{[w_]=w_;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}>`}},E_=class extends T_{_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===B?Yh:(e??=this.run(this.typeParameters))(t,this,n)}_rebuild(e,t,n,r,i){let a=Jv(this.typeParameters,e);return a===this.typeParameters&&t===this.checks&&n===this.encodingChecks&&r===this.run&&i===this.encodingRun?this:new E_(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>`}},D_=new class extends T_{_tag=`Null`;getParser(){return fy(this,null)}getExpected(){return`null`}},O_=class extends T_{_tag=`Undefined`;getParser(){return fy(this,void 0)}toCodecJson(){return W(this,[k_])}getExpected(){return`undefined`}},k_=new U(D_,new qg(H(()=>void 0),H(()=>null))),A_=new O_,j_=new class extends T_{_tag=`Void`;getParser(){let e=Jh(void 0);return t=>t===B?Yh:e}toCodecJson(){return W(this,[k_])}getExpected(){return`void`}},M_=new class extends T_{_tag=`Never`;getParser(){return py(this,qn)}getExpected(){return`never`}},N_=new class extends T_{_tag=`Unknown`;getParser(){return py(this,Jn)}getExpected(){return`unknown`}},P_=class extends T_{_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 fy(this,this.literal)}matchPart(e,t){return e===globalThis.String(this.literal)?this.literal:void 0}toCodecJson(){return typeof this.literal==`bigint`?F_(this):this}toCodecStringTree(){return typeof this.literal==`string`?this:F_(this)}getExpected(){return typeof this.literal==`string`?JSON.stringify(this.literal):globalThis.String(this.literal)}};function F_(e){let t=globalThis.String(e.literal);return W(e,[new U(new P_(t),new qg(H(()=>e.literal),H(()=>t)))])}var I_=new class extends T_{_tag=`String`;getParser(){return py(this,Bn)}matchPart(e,t){let n=this.checks;return n&&!t.disableChecks&&Sy(n,e,void 0,this,t)?void 0:e}getExpected(){return`string`}},L_=class extends T_{_tag=`Number`;getParser(){return py(this,Vn)}matchKey(e,t){return this._match(_y,e,t)}matchPart(e,t){return this._match(gy,e,t)}_match(e,t,n){if(!e.test(t))return;let r=globalThis.Number(t);return n.disableChecks||!this.checks?r:Sy(this.checks,r,void 0,this,n)?void 0:r}toCodecJson(){return this.checks&&(R_(this.checks,`effect/schema/isFinite`)||R_(this.checks,`effect/schema/isInt`))?this:W(this,[Mv])}toCodecStringTree(){return this.toCodecJson()===this?W(this,[by]):W(this,[xy])}getExpected(){return`number`}};function R_(e,t){return e.some(e=>e.annotations?.representation?.id===t||e._tag===`FilterGroup`&&R_(e.checks,t))}var z_=new L_,B_=new class extends T_{_tag=`Boolean`;getParser(){return py(this,Hn)}getExpected(){return`boolean`}},V_=class extends T_{_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(ry(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(ry(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 og(n,t[o],i),a=new ig([o],r);if(i.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return R(new sg(n,[a],t,i))}return e.issues?R(new sg(n,e.issues,t,i)):Jh(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:td(t.concurrency),f=d===1?W_(i,e,0,u):G_(i,e,{concurrency:d,end:u});if(!f)return c(i);if(I(f))return dm(f,()=>c(i));let p=!0;return Cp(()=>p?(p=!1,z(f,()=>c(i))):l(e,t))};return(e,a)=>{if(e===B)return Yh;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)):R(new cg(n,e,a))}catch(e){return kp(e)}}}_rebuild(e,t,n){let r=Jv(this.elements,e),i=Jv(this.rest,e);return r===this.elements&&i===this.rest&&t===this.checks&&n===this.encodingChecks?this:new V_(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 H_(e,t,n,r){if(n._tag===`Failure`)return K_(e,e.ast,r,n);let i=n===V?t:n[D];if(i!==B)e.output[r]=i;else{let t=e.getParser(e.tailThreshold,r);if(ry(t.ast))return;let n=new ig([r],new ag(t.ast.context?.annotations));if(e.options.errors===`all`)e.issues?e.issues.push(n):e.issues=[n];else return sf(new sg(e.ast,[n],e.input,e.options))}}var U_={onItem(e,t,n){let r=n<e.len?t:B;return e.getParser(e.tailThreshold,n).parser(r,e.options)},step:H_},W_=nd()(U_),G_=id()(U_),K_=(e,t,n,r)=>{if(r.cause.reasons.length===0)return r;let i=kg(r.cause);if(i===void 0)return of(Zd(r.cause,r=>new sg(t,[new ig([n],r)],e.input,e.options)));let a=new ig([n],i);if(e.options.errors===`all`)e.issues?e.issues.push(a):e.issues=[a];else return sf(new sg(t,[a],e.input,e.options))},q_=`[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?`;function J_(e,t,n=S_){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(my(cy(t)))}var Y_=class{name;type;constructor(e,t){this.name=e,this.type=t}};function X_(e){switch(e._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return e.types.every(X_);default:return!1}}function Z_(e){let t=Rv(e);switch(t._tag){case`String`:case`Number`:case`Symbol`:case`TemplateLiteral`:return!0;case`Union`:return t.types.every(Z_);default:return!1}}function Q_(e){return X_(e)&&Z_(e)}var $_=class{parameter;type;constructor(e,t){if(!Q_(e))throw Error(`Invalid index signature parameter ${e._tag}`);if(this.parameter=e,this.type=t,ry(t)&&!dy(t))throw Error("Cannot use `Schema.optionalKey` with index signatures, use `Schema.optional` instead.")}},ev=class extends T_{_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 py(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(my(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 K_(t,n,i,s)??cf;let c=s===V?o:s[D];if(a!==B&&c!==B){if(r&&(e.has(i)||e.has(typeof a==`number`?globalThis.String(a):a)))return cf;ri(t.out,a,c)}return cf},c=(e,r,i,a)=>{if(!a){let t=i.parserKey(r,e.options);if(!I(t))return z(Fp(t),t=>c(e,r,i,t));a=t}if(a._tag===`Failure`)return K_(e,n,r,a)??cf;let o=a===V?r:a[D],s=e.input[r],l=i.parserValue(s,e.options);return I(l)?t(e,r,o,s,l):z(Fp(l),n=>t(e,r,o,s,n))},l=(e,n,r)=>{let i=e.input[n],a=r.parserValue(i,e.options);return I(a)?t(e,n,n,i,a):z(Fp(a),r=>t(e,n,n,i,r))},u=i?id()({onItem:(e,[t,n])=>n.is.parameter===I_?l(e,t,n):c(e,t,n),step:(e,t,n)=>n._tag===`Failure`?n:void 0}):void 0;return fm(function*(t,d){if(t===B)return B;if(typeof t!=`object`||!t||Array.isArray(t))return yield*R(new cg(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:td(d.concurrency),ne=i&&ee?n.indexSignatures.map(e=>J_(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 og(n,f[a],d),r=new ig([a],e);if(h){m.issues?m.issues.push(r):m.issues=[r];continue}return yield*R(new sg(n,[r],t,d))}}}if(r){let e=te===1?rv(m,a):iv(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===I_?l:c,r=ne?.[e]??(t.is.parameter===I_?Object.keys(f):J_(f,t.is.parameter,d));for(let e=0;e<r.length;e++){let i=n(m,r[e],t);if(!I(i))yield*i;else if(i._tag===`Failure`)return yield*i}}else if(u){let e=qo();for(let t=0;t<i;t++){let n=o[t],r=ne?.[t]??(n.is.parameter===I_?Object.keys(f):J_(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*R(new sg(n,m.issues,t,d)):p})};if(i)return c();let l,u=(e,t,n)=>{let r=a[t];return z(Fp(n),n=>{let i=tv(e,r,n);if(i)return i;let o=()=>Jh(e.out),s=rv(e,a.slice(t+1));return s?dm(s,o):o()})};return(e,t)=>{if(e===B)return Yh;if(t.errors===`all`||t.onExcessProperty!==void 0||t.concurrency!==void 0&&td(t.concurrency)!==1)return(l??=c())(e,t);if(typeof e!=`object`||!e||Array.isArray(e))return R(new cg(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=gv(i,s),l=c?i[s]:B,d=n.parser(l,t);if(!I(d))return u(o,e,d);if(d===V){c&&ri(a,s,l);continue}let f=tv(o,n,d);if(f)return f}}catch(e){return kp(e)}return Jh(a)}}_rebuild(e,t,n,r){let i=Jv(this.propertySignatures,t=>{let n=e(t.type);return n===t.type?t:new Y_(t.name,n)}),a=Jv(this.indexSignatures,n=>{let r=t(n.parameter),i=e(n.type);return r===n.parameter&&i===n.type?n:new $_(r,i)});return i===this.propertySignatures&&a===this.indexSignatures&&n===this.checks&&r===this.encodingChecks?this:new ev(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 tv(e,t,n){if(n._tag===`Failure`)return K_(e,e.ast,t.name,n);if(n===V)return;let r=n[D];if(r!==B){ri(e.out,t.name,r);return}if(delete e.out[t.name],!ry(t.type)){let n=new ig([t.name],new ag(t.type.context?.annotations));if(e.options.errors===`all`){e.issues?e.issues.push(n):e.issues=[n];return}return sf(new sg(e.ast,[n],e.input,e.options))}}var nv={onItem(e,t){if(!gv(e.input,t.name))return t.parser(B,e.options);let n=e.input[t.name];return ri(e.out,t.name,n),t.parser(n,e.options)},step:tv},rv=nd()(nv),iv=id()(nv);function av(e,t){return e?t?[...e,...t]:e:t}function ov(e,t,n){return new ev(Reflect.ownKeys(e).map(t=>new Y_(t,e[t].ast)),[],n,t)}function sv(e){return e.ast}function cv(e,t=void 0){return new V_(!1,e.map(e=>e.ast),[],void 0,t)}function lv(e,t,n){return new vv(e.map(sv),t,void 0,n)}var uv=Pn(e=>{for(;;){if(x_(e))return N_;let t=e.encoding;if(!t)return e.recur?.(uv,x)??e;if(t.some(e=>e.transformation._tag===`Middleware`&&e.transformation.decode!==x))return N_;e=t[t.length-1].to}});function dv(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(dv)));default:return[`null`,`undefined`,`string`,`number`,`boolean`,`symbol`,`bigint`,`object`,`array`,`function`]}}function fv(e){switch(e._tag){default:return[];case`Declaration`:{let t=e.annotations?.[Gh];return Array.isArray(t)?t:[]}case`Objects`:return e.propertySignatures.flatMap(e=>{let t=e.type;if(!ry(t)){if(h_(t))return[{key:e.name,literal:t.literal}];if(g_(t))return[{key:e.name,literal:t.symbol}]}return[]});case`Arrays`:return e.elements.flatMap((e,t)=>{if(!ry(e)){if(h_(e))return[{key:t,literal:e.literal}];if(g_(e))return[{key:t,literal:e.symbol}]}return[]});case`Union`:{if(e.types.length===0)return[];let t=e.types.map(e=>fv(uv(e)));return t[0].filter(e=>t.every(t=>t.some(t=>t.key===e.key&&t.literal===e.literal)))}case`Suspend`:return fv(e.thunk())}}var pv=new WeakMap,mv=Object.freeze([]),hv=e=>e===null?`null`:Array.isArray(e)?`array`:typeof e,gv=(e,t)=>t===`__proto__`?Object.hasOwn(e,t):t in e;function _v(e){let t=pv.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=uv(c);if(m_(l))continue;if(h_(l)||g_(l)){a??=new Map;let e=h_(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=fv(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=dv(l);for(let n of e)(i[n]??=[]).push(t)}}let c={},l=e=>c[e]??=Object.freeze(i?.[e]??mv);if(o&&a)a.forEach(Object.freeze),t=e=>a.get(e)??mv;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=gv(e,r)?e[r]:void 0;if(n!==void 0)return a.get(n)??mv;if(t)return o}return mv}}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=hv(t);if(!Xn(t))return l(a);let o=new Set(i?.[a]),s;if(e){let[n,[i]]=e,c=gv(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=gv(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=gv(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(hv(e));return a?t.filter(t=>s[t]===void 0||s[t]===e):t};return pv.set(e,t),t}var vv=class extends T_{_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===B)return Yh;let i=(o??=_v(n.types))(e,r);if(i.length===0)return R(new fg(n,[],e,t));if(i.length===1){let r=a(i[0])(e,t);return r._tag===`Success`?r:I(r)?yv(n,r.cause,e,t):bv(n,r,e,t)}return xv(n,a,i,e,t)}}_rebuild(e,t,n){let r=Jv(this.types,e);return r===this.types&&t===this.checks&&n===this.encodingChecks?this:new vv(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=cy(t);switch(n._tag){case`Arrays`:{let t=n.elements.filter(h_);if(t.length>0)return`${Tv(n.isMutable)}[ ${t.map(t=>e(t)+Ev(t.context?.isOptional)).join(`, `)}, ... ]`;break}case`Objects`:{let t=n.propertySignatures.filter(e=>h_(e.type));if(t.length>0)return`{ ${t.map(t=>`${Tv(t.type.context?.isMutable)}${Br(t.name)}${Ev(t.type.context?.isOptional)}: ${e(t.type)}`).join(`, `)}, ... }`;break}}return e(n)});return Array.from(new Set(n)).join(` | `)}};function yv(e,t,n,r){let i=kg(t);return i?sf(new fg(e,[i],n,r)):of(t)}function bv(e,t,n,r){return Bp(t,t=>yv(e,t,n,r))}function xv(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=Cv(a,n);if(!o)return a.out?a.out:R(new fg(e,a.issues??[],r,i));if(I(o))return Sv(o,a);let s=!0;return Cp(()=>s?(s=!1,Sv(o,a)):xv(e,t,n,r,i))}function Sv(e,t){return dm(e,e=>t.out===V?L(t.input):t.out?t.out:R(new fg(t.ast,t.issues??[],t.input,t.options)))}var Cv=nd()({onItem(e,t){return e.parser(t)(e.input,e.options)},step(e,t,n){if(n._tag===`Failure`){let t=kg(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]),sf(new pg(e.ast,e.successes,e.input,e.options));if(e.out=n,e.successes)e.successes.push(e.ast.types[t]);else return cf}}}),wv=new vv([new P_(`Infinity`),new P_(`-Infinity`),new P_(`NaN`)]);function Tv(e){return e?``:`readonly `}function Ev(e){return e?`?`:``}var Dv=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 Dv(this.run,{...this.annotations,...e},this.aborted)}abort(){return new Dv(this.run,this.annotations,!0)}and(e,t){return new Ov([this,e],t)}},Ov=class extends Dn{_tag=`FilterGroup`;checks;annotations;constructor(e,t=void 0){super(),this.checks=e,this.annotations=t}annotate(e){return new Ov(this.checks,{...this.annotations,...e})}and(e,t){return new Ov([this,e],t)}};function kv(e,t,n=!1){return new Dv((t,n,r)=>gg(n,e(t,n,r),t,r),t,n)}function Av(e){return kv(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 jv=Vv(z_,[Av()]),Mv=new U(new vv([jv,wv]),new qg(Bg(),H(e=>globalThis.Number.isFinite(e)?e:globalThis.String(e))));function Nv(e,t){let n=new globalThis.RegExp(e),r={source:n.source,flags:n.flags};return kv(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 Pv=new WeakMap;function Fv(e,t){let n=Object.assign(Object.create(Object.getPrototypeOf(e)),e,t);return Reflect.ownKeys(t).every(e=>e===`context`||e===`encoding`)&&Pv.set(n,Iv(e)),n}function Iv(e){let t=Pv.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 Pv.set(e,n),n}function W(e,t){return e.encoding===t?e:Fv(e,{encoding:t})}function Lv(e,t){if(e.context===t)return e;let n=Iv(e);return n.context===t&&n.encoding===e.encoding?n:Fv(e,{context:t})}function Rv(e){return e.encoding?Rv(e.encoding[e.encoding.length-1].to):e}function zv(e,t){if(e.checks){let n=e.checks[e.checks.length-1];return Bv(e,Ho(e.checks.slice(0,-1),n.annotate(t)))}return Fv(e,{annotations:{...e.annotations,...t}})}function Bv(e,t){if(e._tag===`Suspend`&&t)throw Error(`Cannot add checks to Suspend`);return e.checks===t?e:Fv(e,{checks:t})}function Vv(e,t){return Bv(e,av(e.checks,t))}function Hv(e,t){let n=t(e.to);return n===e.to?e:new U(n,e.transformation)}function Uv(e,t){let n=e,r=n[n.length-1],i=Hv(r,t);return i===r?e:Ho(e.slice(0,e.length-1),i)}function Wv(e){return t=>t.encoding?W(t,Uv(t.encoding,e)):t}function Gv(e,t){return Wv(e=>Lv(e,t))(e)}function Kv(e,t){function n(r){if(r.encoding){let e=r.encoding[r.encoding.length-1];return t?.stopAt?.(e)?r:W(r,Uv(r.encoding,n))}return e(r)}return Pn(n)}function qv(e,t,n){let r=new U(e,t);return W(n,n.encoding?[...n.encoding,r]:[r])}function Jv(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 Yv(e,t){return Lv(e,e.context?new C_(e.context.isOptional,e.context.isMutable,e.context.constructorDefault,{...e.context.annotations,...t}):new C_(!1,!1,void 0,t))}var Xv=Pn(e=>Zv(Lv(e,e.context?e.context.isOptional===!1?new C_(!0,e.context.isMutable,e.context.constructorDefault,e.context.annotations):e.context:new C_(!0,!1)))),Zv=Wv(Xv),Qv=Nn(e=>Xv(new vv([e,A_])));function $v(e,t){return Lv(e,e.context?new C_(e.context.isOptional,e.context.isMutable,t,e.context.annotations):new C_(!1,!1,t))}function ey(e,t,n){return qv(e,n,t)}function ty(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 ny(e,t){let{literals:n,parameters:r}=ty(e);return new ev(n.map(e=>new Y_(e,t)),r.map(e=>new $_(e,t)))}function ry(e){return e.context?.isOptional??!1}function iy(e){return e.annotations?.[`~structural`]===!0||e._tag===`FilterGroup`&&e.checks.every(iy)}function ay(e){function t(e){return iy(e)?[e]:e._tag===`FilterGroup`?e.checks.flatMap(t):[]}let n=e.flatMap(t);return Wo(n)?n:void 0}function oy(e){let t=!0;function n(e){return t=t&&!e.encoding&&!x_(e),t&&`recur`in e&&e.recur(n),e}return`recur`in e&&e.recur(n),t}var sy=Pn(e=>{let t=Iv(e);if(t!==e){let n=sy(t);return n===t&&e.encoding===void 0?e:Lv(n,e.context)}let n=`recur`in e?e.recur(sy):e;if(`encodingChecks`in n&&n.encodingChecks){let t=oy(e)?n.encodingChecks:v_(n)||y_(n)||d_(n)&&n.typeParameters.length>0?ay(n.encodingChecks):void 0;return Fv(n,{encodingChecks:void 0,checks:av(n.checks,t)})}return n}),cy=Pn(e=>sy(uy(e)));function ly(e,t){let n=t,r=n.length,i=n[r-1],a=[new U(uy(W(e,void 0)),n[0].transformation.flip())];for(let e=1;e<r;e++)a.unshift(new U(uy(n[e-1].to),n[e].transformation.flip()));let o=uy(i.to);return o.encoding?W(o,[...o.encoding,...a]):W(o,a)}var uy=Nn(e=>{if(e.encoding)return ly(e,e.encoding);let t=Iv(e);if(t!==e){let n=uy(t);return n===t?e:Lv(n,e.context)}return`flip`in e?e.flip(uy):`recur`in e?e.recur(uy):e});function dy(e){switch(e._tag){case`Undefined`:return!0;case`Union`:return e.types.some(dy);default:return!1}}function fy(e,t){let n=t===0?V:Jh(t);return(r,i)=>r===B?Yh:r===t?n:R(new cg(e,r,i))}function py(e,t){return(n,r)=>n===B?Yh:t(n)?V:R(new cg(e,n,r))}var my=Kv(e=>{switch(e._tag){default:return e;case`Number`:return e.toCodecStringTree();case`Union`:return e.recur(my)}}),hy=Kv(e=>{switch(e._tag){default:return e;case`Symbol`:case`UniqueSymbol`:return e.toCodecStringTree();case`Union`:return e.recur(hy)}}),gy=new globalThis.RegExp(`^${q_}$`),_y=new globalThis.RegExp(`^(?:${q_}|Infinity|-Infinity|NaN)$`);function vy(e){return Nv(gy,{expected:`a string representing a finite number`,representation:{id:`effect/schema/isStringFinite`,payload:null},toJsonSchema:()=>({pattern:gy.source}),...e})}var yy=Vv(I_,[vy()]),by=new U(yy,e_),xy=new U(new vv([yy,wv]),e_);function Sy(e,t,n,r,i){for(let a=0;a<e.length;a++){let o=e[a];if(o._tag===`FilterGroup`){if(n=Sy(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 ng(o,e,t,i);if(n?n.push(r):n=[r],i.errors!==`all`||o.aborted)return n}}}return n}function Cy(e){if(!d_(e))return;let t=e.annotations?.[Kh];return Gn(t)?t(e.typeParameters):void 0}var wy=Uh;function Ty(e){return e===null||typeof e==`string`||typeof e==`boolean`||typeof e==`number`&&globalThis.Number.isFinite(e)}function Ey(e){return e===void 0||typeof e==`string`}function Dy(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 Oy(e){return Dy(e,Ty)}var ky=new E_([],()=>(e,t,n)=>Oy(e)?V:R(new cg(t,e,n)),{representation:{id:`effect/schema/Json`,payload:null},expected:`JSON value`,toCodecJson:()=>void 0,toCodecStringTree:()=>Ny}),Ay=new U(ky,$g()),jy=new U(new vv([new V_(!1,[],[ky]),new ev([],[new $_(I_,ky)])]),$g());function My(e){return Dy(e,Ey)}var Ny=new U(new E_([],()=>(e,t,n)=>My(e)?V:R(new cg(t,e,n)),{expected:`StringTree`,toCodecStringTree:()=>void 0}),$g()),Py=(e,t,n)=>e===V?n(t):dm(e,n);function Fy(e){if(e._tag===`Middleware`)return(t,n,r)=>Iy(t===V?e.decode(Jh(Xh(n)),r):e.decode(cm(t,Xh),r));let t=e.decode;switch(t._tag){case`Passthrough`:return(e,t)=>e===V?Jh(t):e;case`Transform`:{let e=e=>e===B?Yh:Jh(t.transform(e));return(t,n)=>Py(t,n,e)}case`TransformOptional`:{let e=e=>Zh(t.transform(Xh(e)));return(t,n)=>Py(t,n,e)}case`TransformEffect`:return(e,n,r)=>Py(e,n,e=>e===B?Yh:t.transform(e,r));case`TransformOptionalEffect`:return(e,n,r)=>Py(e,n,e=>Iy(t.transform(Xh(e),r)))}}var Iy=e=>dm(e,Zh),Ly=(e,t,n,r)=>Bp(r,r=>Op(()=>Zd(r,r=>new rg(e,r,t,n))));function Ry(e,t){let n=Fy(e.link.transformation),r;return(i,a)=>{if(i===B)return Yh;if(e.isConstructed(i))return V;let o=(r??=t(e.link.to))(i,a);return n(o,i,a)}}function zy(e,t){let n=e.context.constructorDefault;return(r,i)=>{if(r!==B&&r!==void 0)return t(r,i);let a=n;if(I(a)&&a._tag===`Success`){let e=t(a[D],i);return e===V?a:e}return dm(Ly(e,r,i,a),e=>{let n=t(e,i);return n===V?Jh(e):n})}}function By(e,t){let n=t(e);return e.context?.constructorDefault===void 0?n:zy(e,n)}function Vy(e,t,n,r,i){if(e._tag===`Declaration`)for(let n of e.typeParameters)t(n);let a=n?Cy(e):void 0,o=a?Ry(a,t):r??e.getParser(t,n),s=e.checks,c=e.encoding,l=c?.map(e=>Fy(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(I(r)){if(r._tag===`Success`){let i=r===V?t:r[D];if(t!==B&&i!==B){let i=Sy(u,t,void 0,e,n);i&&(r=R(new sg(e,i,t,n)))}}}else r=z(r,r=>{if(t!==B&&r!==B){let r=Sy(u,t,void 0,e,n);if(r)return R(new sg(e,r,t,n))}return L(r)})}if(s&&!n.disableChecks){if(I(r)){if(r._tag===`Success`){let i=r===V?t:r[D];if(i===B)return r;let a=Sy(s,i,void 0,e,n);a&&(r=R(new sg(e,a,i,n)))}}else r=z(r,t=>{if(t!==B){let r=Sy(s,t,void 0,e,n);if(r)return R(new sg(e,r,t,n))}return L(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=dm(o,e=>{let n=t(e,r);return n===V?Jh(e):n})}if(o._tag===`Success`){let e=o[D],t=p(e,r);return t===V?o:t}return o=Ly(e,n,r,o),dm(o,e=>{let t=p(e,r);return t===V?Jh(e):t})}:p}var Hy=Symbol(),Uy=new WeakMap,Wy=e=>Jy(e).parser,Gy=e=>Jy(e).makeEffect,Ky=e=>By(e,Gy),qy=class{ast;constructor(e){this.ast=e}get decodeEffect(){return this.cachedDecodeEffect??=Vy(this.ast,Wy)}get parser(){return this.decodeEffect}get makeEffect(){return this.cachedMakeEffect??=Vy(this.ast,Gy,Ky)}};function Jy(e){let t=Uy.get(e);if(t!==void 0)return t;let n=new qy(e);return Uy.set(e,n),n}function Yy(e){let t=e.ast,n;return(e,r)=>(n??=sb(fb,sy(t)))(e,r?.disableChecks?r?.parseOptions?{...r.parseOptions,disableChecks:!0}:{disableChecks:!0}:r?.parseOptions)}function Xy(e){let t=Yy(e);return(e,n)=>{let r=om(t(e,n));return lf(r)?Ra(r.value):(Ag(r.cause,`Option adapter can only return none for schema issues`),La())}}function Zy(e){return ub(sy(e.ast))}function Qy(e){return eb(e.ast)}function $y(e){{let t=cb(ab(e));return e=>{let n=t(e,S_);return lf(n)?!0:(Ag(n.cause,`Type guard adapter can only return false for schema issues`),!1)}}}function eb(e){let t=sy(e),n=e=>(n=$y(t),n(e));return e=>n(e)}function tb(e,t){let n=ab(e.ast);return t===void 0?n:(e,r)=>n(e,rb(t,r))}function nb(e,t){let n=ab(uy(e.ast));return t===void 0?n:(e,r)=>n(e,rb(t,r))}var rb=(e,t)=>t?{...e,...t}:e,ib=e=>e===B?R(new lg):L(e);function ab(e){return sb(db,e)}function ob(e,t){return e===V?L(t):I(e)?e[D]===B?ib(B):e:dm(e,ib)}function sb(e,t){let n;return(r,i)=>{let a=(n??=e(t))(r,i??S_);return a===V?L(r):I(a)?a[D]===B?ib(B):a:dm(a,ib)}}function cb(e){return(t,n)=>om(e(t,n))}function lb(e,t){let n=om(e);if(lf(n))return n.value;let r=Ag(n.cause,t);throw Error(`Schema validation failed`,{cause:r})}function ub(e){let t,n;return(r,i)=>{t??=Jy(e);let a=i?.disableChecks?i.parseOptions?{...i.parseOptions,disableChecks:!0}:{disableChecks:!0}:i?.parseOptions??S_,o=t.make;if(o!==void 0&&r!==B){let e;try{e=o(r,a)}catch(e){throw Ag(qd(e),`Constructor adapter can only throw schema issues`),e}if(e!==Hy&&e!==B)return e}return lb(ob((n??=t.makeEffect)(r,a),r),`Constructor adapter can only throw schema issues`)}}var db=e=>Jy(e).parser,fb=e=>Jy(e).makeEffect,pb=`~effect/Schema/Schema`,mb=Symbol(),hb={[pb]:pb,get make(){let e=Zy(this);return Object.defineProperty(this,"make",{value:e,enumerable:!0}),e},get makeEffect(){let e=Yy(this);return Object.defineProperty(this,"makeEffect",{value:e,enumerable:!0}),e},get makeOption(){let e=Xy(this);return Object.defineProperty(this,"makeOption",{value:e,enumerable:!0}),e},pipe(){return y(this,arguments)},annotate(e){return this.rebuild(zv(this.ast,e))},annotateKey(e){return this.rebuild(Yv(this.ast,e))},check(...e){return this.rebuild(Vv(this.ast,e))},rebuild(e){return gb(e,this[mb])}};function gb(e,t){function n(){}let r=Object.setPrototypeOf(n,hb);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[mb]=t,r.ast=e,r}function _b(e){return gb(vb(e.ast),{schema:e})}var vb=Kv(e=>{let t=Cb(e,vb),n=e.context;return t===e||n===void 0?t:Gv(t,yb(n))});function yb(e){return e.constructorDefault===void 0?e:new C_(e.isOptional,e.isMutable,void 0,e.annotations)}function bb(e){if(e.propertySignatures.some(e=>typeof e.name!=`string`))throw new globalThis.Error(`Objects property names must be strings`,{cause:e})}function xb(e){return t=>{let n=[...t].sort((t,n)=>e(cy(t))-e(cy(n)));return n.some((e,n)=>e!==t[n])?n:t}}var Sb=xb(e=>{switch(e._tag){case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function Cb(e,t){switch(e._tag){case`Declaration`:{let n=e.annotations?.toCodecJson??e.annotations?.toCodec;if(!Gn(n))return W(e,[Ay]);let r=n(e.typeParameters.map(e=>gb(cy(e))));return r===void 0?e:W(e,[Hv(r,t)])}case`Unknown`:return W(e,[Ay]);case`ObjectKeyword`:return W(e,[jy]);case`Undefined`:case`Void`:case`Literal`:case`Number`:return e.toCodecJson();case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return bb(e),e.recur(t,hy);case`Union`:{let n=Sb(e.types);return n===e.types?e.recur(t):new vv(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 wb(e){return gb(Ab(e.ast),{schema:e})}var Tb=xb(e=>{switch(e._tag){case`Null`:case`Boolean`:case`Number`:case`BigInt`:case`Symbol`:case`UniqueSymbol`:return 0;default:return 1}});function Eb(e,t,n){switch(e._tag){case`Declaration`:{let r=e.typeParameters.map(e=>gb(t(cy(e)))),i=e.annotations?.toCodecStringTree;if(Gn(i)){let n=i(r);return n===void 0?e:W(e,[Hv(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):W(e,[Hv(c,t)])}case`Null`:return W(e,[Db]);case`Boolean`:return W(e,[Ob]);case`Unknown`:case`ObjectKeyword`:return W(e,[Ny]);case`Enum`:case`Number`:case`Literal`:case`UniqueSymbol`:case`Symbol`:case`BigInt`:return e.toCodecStringTree();case`Objects`:return bb(e),e.recur(t,hy);case`Union`:{let n=Tb(e.types);return n===e.types?e.recur(t):new vv(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 Db=new U(new P_(`null`),new qg(H(()=>null),H(()=>`null`))),Ob=new U(new vv([new P_(`true`),new P_(`false`)]),new qg(H(e=>e===`true`),zg())),kb=new qg(H(e=>typeof e==`string`?[e]:e),Ig()),Ab=Kv(e=>{let t=Eb(e,Ab,e=>{throw new globalThis.Error(`Missing structural codec for StringTree`,{cause:e})});return t!==e&&e.context!==void 0?Gv(t,yb(e.context)):t},{stopAt:e=>e.transformation===kb}),jb=b(2,(e,t)=>({...e,...t})),Mb=e=>e,Nb=`~effect/Schema/SchemaError`;function Pb(e){return S(e,`~effect/Schema/SchemaError`)&&e[`~effect/Schema/SchemaError`]===`~effect/Schema/SchemaError`}({...Xr}),{...Xr},{...Xr},{...Xr},{...Xr},{...Xr},{...Xr},{...Xr};var Fb=pb;function Ib(){return(e,t,n)=>G(new E_(e.map(sv),e=>t(e.map(e=>G(e))),n))}function Lb(e,t){return Ib()([],()=>(t,n,r)=>e(t)?L(t):R(new cg(n,t,r)),t)}var Rb=class extends Gs(`SchemaError`){[Nb]=Nb;constructor(e){let t=$r();ei(0);try{super({issue:e})}finally{ei(t)}}get message(){return Eg(this.issue)}toJSON(){return{_tag:this._tag,message:this.message}}[Jr](){return this.toJSON()}toString(){return`SchemaError(${this.message})`}};function zb(e){return Pb(e)}function Bb(e){return I(e)?Vb(e):Bp(e,e=>Op(()=>Zd(e,e=>new Rb(e))))}function Vb(e){return lf(e)?e:of(Zd(e.cause,e=>new Rb(e)))}function Hb(e,t){let n;for(let r of e.reasons){if(!Wd(r)||!zb(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 Ub(e){let t=om(e);if(lf(t))return t.value;throw Hb(t.cause,`Sync adapter can only throw schema errors`)}var Wb=Qy;function Gb(e,t){let n=tb(e,t);return(e,t)=>Bb(n(e,t))}var Kb=Gb;function qb(e,t){let n=Gb(e,t);return(e,t)=>Ub(n(e,t))}function Jb(e,t){let n=nb(e,t);return(e,t)=>Bb(n(e,t))}var G=gb;function Yb(e){return S(e,Fb)&&e[Fb]===Fb}var Xb=Mb(e=>G(Xv(e.ast),{schema:e})),Zb=Mb(e=>{let t=_x(e);return G(Qv(e.ast),{schema:t})}),Qb=Mb(e=>G(sy(e.ast),{schema:e}));function $b(e){let t=G(new P_(e),{literal:e,transform(n){return t.pipe(Y($b(n),{decode:H(()=>n),encode:H(()=>e)}))}});return t}var ex=G(M_),tx=G(N_),nx=G(D_),rx=G(A_),K=G(I_),ix=G(z_),ax=G(B_),ox=G(j_);function sx(e,t){return G(e,{fields:t,mapFields(e,t){let n=e(this.fields);return sx(ov(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function q(e){return sx(ov(e,void 0),e)}function cx(e){return Mb(t=>t.mapFields(jb(e)))}function lx(e,t){return G(ny(e.ast,t.ast),{key:e,value:t})}function ux(e,t){return G(e,{elements:t,mapElements(e,t){let n=e(this.elements);return ux(cv(n,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function dx(e){return ux(cv(e),e)}var J=Mb(e=>G(new V_(!1,[],[e.ast]),{value:e})),fx=Mb(e=>G(new V_(!1,[e.ast],[e.ast]),{value:e}));function px(e,t){return G(e,{members:t,mapMembers(e,t){let n=e(this.members);return px(lv(n,this.ast.options,t?.unsafePreserveChecks?this.ast.checks:void 0),n)}})}function mx(e,t){return px(lv(e,t,void 0),e)}function hx(e){let t=e.map($b);return G(lv(t,void 0,void 0),{literals:e,members:t,mapMembers(e){return mx(e(this.members))},pick(e){return hx(e)},transform(e){return mx(t.map((t,n)=>t.transform(e[n])))}})}var gx=Mb(e=>mx([e,nx])),_x=Mb(e=>mx([e,rx]));function Y(e,t){return n=>G(ey(n.ast,e.ast,t?Yg(t):$g()),{from:n,to:e})}function vx(){return(e,t)=>Cx()(e,{decode:t,encode:Pg})}function yx(e){return t=>G($v(t.ast,e),{schema:t})}function bx(e){return $b(e).pipe(yx(L(e)))}function xx(e,t){return q({_tag:bx(e),...t})}function Sx(e,t){return Lb(t=>t instanceof e,t)}function Cx(){return(e,t)=>new U(e.ast,Yg(t))}var wx=kv;function Tx(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 Nv(e,{toJsonSchema:()=>i?{pattern:r.endsWith(`y`)?`^(?:${n})`:n}:[{},!0],toCode:()=>({runtime:`Schema.isPattern(${a})`}),...t})}var Ex=G(jv);function Dx(e){let t=Ia(e.order),n=Pa(e.order),r=Fa(e.order),i=Na(e.order),a=e.formatter??E;return(o,s)=>{let c=o.exclusiveMinimum?n:t,l=o.exclusiveMaximum?i:r;return wx(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 Ox(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${E(e)}`);return e}var kx=Dx({order:ja,annotate:e=>{let t=e.exclusiveMinimum?!0:void 0,n=e.exclusiveMaximum?!0:void 0;return{representation:{id:`effect/schema/isBetween`,payload:{minimum:Ox(e.minimum),maximum:Ox(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 Ax(e){return wx(e=>globalThis.Number.isSafeInteger(e),{expected:`an integer`,representation:{id:`effect/schema/isInt`,payload:null},toJsonSchema:()=>({type:`integer`,minimum:globalThis.Number.MIN_SAFE_INTEGER,maximum:globalThis.Number.MAX_SAFE_INTEGER}),toCode:()=>({runtime:`Schema.isInt()`}),arbitraryConstraint:{number:`integer`},...e})}var jx=ix.check(Ax());function Mx(e,t){return e=Fx(e),Nx(e,Math.ceil(e/2),t)}function Nx(e,t,n){return wx(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})`}),[Wh]:!0,arbitraryConstraint:{minLength:e},...n})}function Px(e,t){return e=Fx(e),wx(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})`}),[Wh]:!0,arbitraryConstraint:{maxLength:e},...t})}function Fx(e){if(!globalThis.Number.isFinite(e))throw new globalThis.RangeError(`Expected a finite number, got ${e}`);return Math.max(0,Math.floor(e))}function Ix(e,t){return e=Fx(e),wx(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})`}),[Wh]:!0,arbitraryConstraint:{minProperties:e},...t})}function Lx(e){return wx(e=>Zo(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 Rx=e=>+(e?.includeStack===!0)|(e?.excludeCause===!0?2:0),zx=e=>{switch(e){case 0:return;case 1:return{includeStack:!0};case 2:return{excludeCause:!0};case 3:return{includeStack:!0,excludeCause:!0}}},Bx=[];function Vx(e){let t=Rx(e),n=Bx[t];if(n!==void 0)return n;let r=mS.pipe(Y(tx,s_(zx(t))));return Bx[t]=r,r}globalThis.RegExp,globalThis.URL;var Hx=K.annotate({expected:`a string that will be decoded as JSON`,contentMediaType:`application/json`});function Ux(e,t){return Hx.pipe(Y(e,l_(t)))}var Wx=Ux(tx);globalThis.File,globalThis.FormData,globalThis.URLSearchParams;var Gx=K.annotate({expected:`a base64 encoded string that will be decoded as Uint8Array`,format:`byte`,contentEncoding:`base64`}),Kx=Sx(globalThis.Uint8Array,{representation:{id:`effect/schema/Uint8Array`,payload:null},toCode:()=>({runtime:`Schema.Uint8Array`,Type:`globalThis.Uint8Array`}),expected:`Uint8Array`,toCodecJson:()=>Cx()(Gx,c_)});function qx(e,t){return G(Ib()([e,t],([e,t])=>(n,r,i)=>{if(!Ud(n))return R(new cg(r,n,i));switch(n._tag){case`Fail`:return um(tb(e)(n.error,i),{onSuccess:Jd,onFailure:e=>ug(r,`error`,e,n,i)});case`Die`:return um(tb(t)(n.defect,i),{onSuccess:Yd,onFailure:e=>ug(r,`defect`,e,n,i)});case`Interrupt`:return L(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])=>Cx()(mx([q({_tag:$b(`Fail`),error:e}),q({_tag:$b(`Die`),defect:t}),q({_tag:$b(`Interrupt`),fiberId:_x(Ex)})]),Zg({decode:e=>{switch(e._tag){case`Fail`:return Jd(e.error);case`Die`:return Yd(e.defect);case`Interrupt`:return Xd(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 Jx(e,t){return G(Ib()([e,t],([e,t])=>{let n=J(qx(e,t));return(e,t,r)=>Hd(e)?um(tb(n)(e.reasons,r),{onSuccess:Gd,onFailure:n=>ug(t,`failures`,n,e,r)}):R(new cg(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])=>Cx()(J(qx(e,t)),Zg({decode:Gd,encode:({reasons:e})=>e}))}).ast,{error:e,defect:t})}var Yx=Xg({decode:(e,t)=>Va(Vm(e),{onNone:()=>R(new lg({expected:`a valid UTC DateTime string`},e,t)),onSome:e=>L(Hm(e))}),encode:e=>L(Wm(e))}),Xx=-864e13,Zx=864e13;function Qx(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 $x(e,t){return jx.check(kx({minimum:e,maximum:t}))}var eS=Lb(e=>Lm(e)&&Rm(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]=Qx(e,Xx,Zx);return vx()($x(t,n),H(Bm))},toCodecJson:()=>Cx()(K,Yx),toFormatter:()=>e=>e.toString()}),tS=K.annotate({expected:`a string that will be decoded as a DateTime.Utc`}).pipe(Y(eS,Yx)),nS=Lb(kh,{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:()=>Ph,toCodec:()=>Cx()(J(dx([K,K])),Zg({decode:jh,encode:e=>e.params}))}).pipe(Y(lx(K,mx([K,fx(K)])),Zg({decode:Vh,encode:Mh}))),rS=globalThis.Symbol.for(`immer-draftable`),iS={};function aS(e,t,n,r,i){let a=cS(n,t,r),o=sS(t),s=class extends e{constructor(...[e,t]){let r=t?.[`~payload`],i=r?.token===iS?r.value:n.make(e??{},t);super(i,{...t,disableChecks:!0,"~payload":{token:iS,value:i}})}static[Fb]=Fb;get[o](){return o}static[rS]=!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 Zy(a(this))(e??{},t)}static makeOption(e,t){return Xy(a(this))(e??{},t)}static makeEffect(e,t){return a(this).makeEffect(e??{},t)}static annotate(e){return this.rebuild(zv(this.ast,e))}static annotateKey(e){return this.rebuild(Yv(this.ast,e))}static check(...e){return this.rebuild(Vv(this.ast,e))}static extend(e){return(t,r)=>{let a=lS(t)?t:q(t),o={...n.fields,...a.fields},s=ov(o,n.ast.checks,{identifier:e});return aS(this,e,sx(Vv(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 oS(e){return new qg(H(t=>new e(t,{"~payload":{token:iS,value:t}})),Ig())}function sS(e){return`~effect/Schema/Class/${e}`}function cS(e,t,n){let r;return i=>{if(r!==void 0)return r;let a=sS(t),o=e=>e instanceof i||S(e,a),s=oS(i);return r=Y(G(new E_([e.ast],()=>(e,t,n)=>o(e)?L(e):R(new cg(t,e,n)),{identifier:t,[Kh]:([e])=>({isConstructed:o,link:new U(e,s)}),toCodec:([e])=>new U(e.ast,s),toEquivalence:([e])=>e,toFormatter:([e])=>t=>`${i.identifier}(${e(t)})`,[Gh]:fv(e.ast),...n})),s)(e)}}function lS(e){return Yb(e)}var uS=e=>(t,n)=>aS(qi,e,lS(t)?t:q(t),n,e=>({name:e})),dS=e=>(t,n,r)=>{let i=lS(n)?n.mapFields(e=>({_tag:bx(t),...e}),{unsafePreserveChecks:!0}):xx(t,n);return uS(e??t)(i,r)},fS=_b,pS=wb,mS=G(zv(ky,{toCode:()=>({runtime:`Schema.Json`,Type:`Schema.Json`})})),hS=Vc,gS=_d,_S=`~effect/MutableRef`,vS={[_S]:_S,...pi,toJSON(){return{_id:`MutableRef`,current:Yr(this.current)}}},yS=e=>{let t=Object.create(vS);return t.current=e,t},bS={"~effect/Channel":{_Env:x,_InErr:x,_InElem:x,_OutErr:x,_OutElem:x},pipe(){return y(this,arguments)}},xS=e=>{let t=Object.create(bS);return t.transform=(t,n)=>Bp(e(t,n),e=>L(Dp(e))),t},SS=(e,t)=>xS((n,r)=>z(TS(e)(n,r),e=>t(e,r))),CS=e=>xS((t,n)=>e),wS=e=>xS(sm(function*(t,n){let r=xf(n),i=e=>Sf(r,gp(e));return Yp(yield*Yp(e(t,n,r),i),i)})),TS=e=>e.transform,ES=e=>xS((t,n)=>Cp(()=>TS(e())(t,n))),DS=e=>CS(L(R(e))),OS=e=>xS((t,n)=>kS({scope:n,readable:e.evaluate(),onError:e.onError,releaseLockOnEnd:e.releaseLockOnEnd})),kS=e=>{let t=e.readable.getReader(),n=e.exit??yS(void 0),r=Cp(()=>n.current?n.current:Hp(Sp({try:()=>t.read(),catch:e.onError}),{onFailure:e=>n.current??Dp(e),onSuccess:({done:e,value:t})=>n.current?n.current:e?nf():L(Jo(t))}));return Lp(bf(e.scope,e.releaseLockOnEnd?wp(()=>t.releaseLock()):xp(()=>t.cancel().catch(Mn))),r)},AS=b(2,(e,t)=>SS(e,e=>wp(()=>{let n=0;return Ip(e,e=>t(e,n++))}))),jS=b(2,(e,t)=>xS((n,r)=>z(TS(e)(n,r),e=>TS(t)(e,r)))),MS=b(2,(e,t)=>wS((n,r,i)=>yf(i,t).pipe(Np(TS(e)(n,r))))),NS=b(2,(e,t)=>MS(e,e=>t)),PS=(e,t,n)=>Cp(()=>{let r=_f();return fp(z(TS(e)(nf(),r),t),n||L).pipe(Xp(e=>Sf(r,e)))}),FS=b(2,(e,t)=>xS((n,r)=>Ip(Kp(TS(e)(n,r),t),Kp(t)))),IS=b(2,(e,t)=>PS(e,e=>em(z(e,t),{disableYield:!0}))),LS=(e,t)=>TS(e)(nf(),t),RS=(e,t)=>()=>{let n=Kb(fx(e),t);return xS((e,t)=>L(z(e,e=>n(e))))},zS=`~effect/Stream`,BS={_R:x,_E:x,_A:x},VS=function(e){this.channel=e};VS.prototype={[zS]:BS,pipe(){return y(this,arguments)}};var HS=e=>new VS(e),US=`~effect/Stream`,WS=e=>S(e,US),GS=HS,KS=(e,t)=>GS(xS((n,r)=>z(LS(e.channel,r),e=>t(e,r)))),qS=e=>GS(ES(()=>e().channel)),JS=e=>GS(DS(e)),YS=e=>GS(OS(e)),XS=b(2,(e,t)=>qS(()=>{let n=0;return GS(AS(e.channel,Yo(e=>t(e,n++))))})),ZS=b(2,(e,t)=>GS(jS(e.channel,t))),QS=b(e=>WS(e[0]),(e,t)=>qS(()=>{let n=new TextDecoder(t?.encoding);return XS(e,e=>n.decode(e,{stream:!0}))})),$S=b(2,(e,t)=>GS(NS(e.channel,t))),eC=b(2,(e,t)=>GS(FS(e.channel,t))),tC=b(2,(e,t)=>IS(e.channel,t)),nC=b(e=>WS(e[0]),(e,t,n)=>{let r,i,a=!1,o=gS(!1),s=n?.signal,c=()=>i.interruptUnsafe();return new ReadableStream({start(n){i=rm(Kp(tC(e,e=>o.whenOpen(wp(()=>{o.closeUnsafe();for(let t=0;t<e.length;t++)n.enqueue(e[t]);r(),r=void 0}))),t)),i.addObserver(e=>{s?.removeEventListener(`abort`,c),!a&&(e._tag===`Failure`&&s?.aborted!==!0?n.error($d(e.cause)):n.close())}),s!==void 0&&i.pollUnsafe()===void 0&&(s.aborted?c():s.addEventListener(`abort`,c,{once:!0}))},pull(){return new Promise(e=>{r=e,o.openUnsafe()})},cancel(){if(i)return a=!0,im(Rp(hS(i)))}},n?.strategy)}),rC=b(e=>WS(e[0]),(e,t)=>Ip(Up(),n=>nC(e,n,t))),iC=b(2,(e,t)=>e===void 0?void 0:t(e)),aC=e=>K.pipe(yx(L(e))),oC={InvalidInput:400,Unauthenticated:401,Forbidden:403},sC=q({path:J(mx([K,Ex])),message:K}),cC=yg(),lC=class e extends dS()(`InvalidInput`,{message:aC(`The input does not match the action's input.`),issues:J(sC).pipe(yx(L([])))},{httpApiStatus:oC.InvalidInput}){static fromSchemaError=({issue:t,message:n})=>new e({message:n,issues:cC(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}))})},uC=class extends dS()(`Unauthenticated`,{message:aC(`Authentication is required.`)},{httpApiStatus:oC.Unauthenticated}){},dC=K.check(Tx(/^[\x21\x23-\x5B\x5D-\x7E]+$/)),fC=[uC,class extends dS()(`Forbidden`,{message:aC(`Not allowed.`),scopes:Xb(fx(dC))},{httpApiStatus:oC.Forbidden}){}];mx(fC);var pC=[lC,...fC],mC=mx(pC),hC=e=>e===void 0?[]:Yb(e)?[e]:e,gC=(e,t=[])=>[...new Set([...pC,...e.error,...t])],_C=Symbol.for(`@gjermundgaraba/effect-actions/Anyone`),vC=/^[A-Za-z0-9_-]{1,128}$/,yC=(e,t)=>{if(!vC.test(t)||t===`then`)throw Error(`Invalid ${e}: ${t}`)},bC=(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)}},xC=(e,t)=>bC(e,t,e=>e.name),SC=e=>x_(e)?SC(e.thunk()):e,CC=e=>{let t=SC(e);return b_(t)?t.types.flatMap(CC):[t]},wC=e=>h_(e)?[e.literal]:__(e)?e.enums.map(([,e])=>e):[void 0],TC=e=>CC(cy(e)).flatMap(e=>{let t=y_(e)?e.propertySignatures.find(e=>e.name===`_tag`)?.type:void 0;return t===void 0?[]:CC(t).flatMap(wC).filter(Bn)}),EC=(e,t)=>{let n=t.flatMap(e=>TC(e.ast)).find(e=>Object.hasOwn(oC,e));if(n!==void 0)throw Error(`${e}: error _tag "${n}" is built in, and declared on every surface`)},DC=(e,t)=>t.length===0?Gb(fS(e.input))({}):L(t[0]),OC=(e,t)=>{let n=Jb(fS(e.input),{errors:`all`});return(...r)=>DC(e,r).pipe(Pp(n),Vp(lC.fromSchemaError),z(t))},kC=lx(K,ex),AC=e=>Yb(e)?e:Reflect.ownKeys(e).length===0?kC:q(e);function X(e,t){yC(`action name`,e);let{caller:n,readOnly:r}=t;if(n!==_C&&!lo(n))throw Error(`Missing caller: declare Action.Anyone or an identity service key`);if(n!==_C&&uo(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:AC(t.input??{}),success:t.success===void 0?ox:AC(t.success),error:hC(t.error),readOnly:r,mcp:{...t.mcp}};return EC(`Action "${i.name}"`,i.error),i}var jC=(e,t,n)=>e.caller===_C||n===void 0?t:[...t,...n],MC=(e,t)=>{for(let n of e)if(n.caller!==_C&&(t===void 0||n.caller.key!==t.identity.key))throw Error(`Protected action '${n.name}' requires its matching authentication descriptor`)},NC=`~effect/http/HttpBody`,PC=e=>S(e,NC),FC=class{[NC];constructor(){this[NC]=NC}[Jr](){return this.toJSON()}toString(){return E(this,{ignoreToString:!0})}},IC=new class extends FC{_tag=`Empty`;toJSON(){return{_id:`effect/HttpBody`,_tag:`Empty`}}},LC=class extends FC{_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??=VC(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}}},RC=(e,t)=>new LC(e,t??`application/octet-stream`,e.length),zC=new TextEncoder,BC=globalThis.Buffer,VC=BC===void 0?e=>zC.encode(e):e=>BC.from(e,`utf8`),HC=(e,t)=>{if(typeof e!=`string`&&(e=e===void 0?``:String(e)),BC!==void 0)return new LC(void 0,t??`text/plain`,BC.byteLength(e,`utf8`),e);let n=zC.encode(e);return new LC(n,t??`text/plain`,n.length,e)},UC=(e,t)=>HC(Bh(Mh(e)),t??`application/x-www-form-urlencoded`),WC=class extends FC{_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}}},GC=e=>new WC(e),KC=`~effect/http/HttpClientError`,qC=class extends Gs(`HttpClientError`){constructor(e){`cause`in e.reason?super({...e,cause:e.reason.cause}):super(e)}[KC]=KC;get request(){return this.reason.request}get response(){return`response`in this.reason?this.reason.response:void 0}get message(){return this.reason.message}},JC=e=>e.endsWith(`Error`)?e.slice(0,-5):e,YC=(e,t,n)=>t?`${e}: ${t} (${n})`:`${e} error (${n})`,XC=class extends Gs(`TransportError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return YC(JC(this._tag),this.description,this.methodAndUrl)}},ZC=class extends Gs(`InvalidUrlError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){return YC(JC(this._tag),this.description,this.methodAndUrl)}},QC=class extends Gs(`StatusCodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return YC(JC(this._tag),this.description,e)}},$C=class extends Gs(`DecodeError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return YC(JC(this._tag),this.description,e)}},ew=class extends Gs(`EmptyBodyError`){get methodAndUrl(){return`${this.request.method} ${this.request.url}`}get message(){let e=`${this.response.status} ${this.methodAndUrl}`;return YC(JC(this._tag),this.description,e)}},tw=e=>e!==`GET`&&e!==`HEAD`&&e!==`OPTIONS`&&e!==`TRACE`,nw=[[`GET`,`get`],[`POST`,`post`],[`PUT`,`put`],[`DELETE`,`del`],[`PATCH`,`patch`],[`HEAD`,`head`],[`OPTIONS`,`options`],[`TRACE`,`trace`],[`QUERY`,`query`]],rw=(e,t)=>t._tag===`Empty`||t._tag===`FormData`?wh(wh(e,`content-type`),`content-length`):(e=t.contentType===void 0?wh(e,`content-type`):xh(e,`content-type`,t.contentType),t.contentLength===void 0?wh(e,`content-length`):xh(e,`content-length`,t.contentLength.toString())),iw=class extends Gs(`UrlError`){},aw=(e,t,n)=>ko({try:()=>{let r=new URL(e,ow());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 iw({cause:e})}),ow=()=>{if(`location`in globalThis&&globalThis.location!==void 0&&globalThis.location.origin!==void 0&&globalThis.location.pathname!==void 0)return location.origin+location.pathname},sw=`~effect/http/HttpClientRequest`,cw={[sw]:sw,...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 lw(e,t,n,r,i,a){let o=Object.create(cw);return o.method=e,o.url=t,o.urlParams=n,o.hash=r,o.headers=i,o.body=a,o}var uw=lw(`GET`,``,Ih,La(),vh,IC),dw=e=>(t,n)=>fw(uw,{method:e,url:t,...n??void 0}),fw=b(2,(e,t)=>{let n=e;return t.method&&(n=pw(n,t.method)),t.url&&(n=vw(n,t.url)),t.headers&&(n=hw(n,t.headers)),t.urlParams&&(n=xw(n,t.urlParams)),t.hash&&(n=Cw(n,t.hash)),t.body&&(n=ww(n,t.body)),t.accept&&(n=gw(n,t.accept)),t.acceptJson&&(n=_w(n)),n}),pw=b(2,(e,t)=>lw(t,e.url,e.urlParams,e.hash,e.headers,e.body)),mw=b(3,(e,t,n)=>lw(e.method,e.url,e.urlParams,e.hash,xh(e.headers,t,n),e.body)),hw=b(2,(e,t)=>lw(e.method,e.url,e.urlParams,e.hash,Sh(e.headers,t),e.body)),gw=b(2,(e,t)=>mw(e,`Accept`,t)),_w=gw(`application/json`),vw=b(2,(e,t)=>{if(typeof t==`string`)return lw(e.method,t,e.urlParams,e.hash,e.headers,e.body);let n=new URL(t.toString()),r=Mh(n.searchParams),i=Ua(n.hash===``?void 0:n.hash.slice(1));return n.search=``,n.hash=``,lw(e.method,n.toString(),r,i,e.headers,e.body)}),yw=b(2,(e,t)=>t===``?e:lw(e.method,bw(t,e.url),e.urlParams,e.hash,e.headers,e.body)),bw=(e,t)=>{let n=e.endsWith(`/`),r=t.startsWith(`/`);return n&&r?e+t.slice(1):!n&&!r?e+`/`+t:e+t},xw=b(2,(e,t)=>lw(e.method,e.url,Rh(e.urlParams,t),e.hash,e.headers,e.body)),Sw=b(2,(e,t)=>lw(e.method,e.url,zh(e.urlParams,t),e.hash,e.headers,e.body)),Cw=b(2,(e,t)=>lw(e.method,e.url,e.urlParams,Ra(t),e.headers,e.body)),ww=b(2,(e,t)=>lw(e.method,e.url,e.urlParams,e.hash,rw(e.headers,t),t)),Tw=b(2,(e,t)=>ww(e,GC(t)));function Ew(e){let t=aw(e.url,e.urlParams,Wa(e.hash));return jo(t)?Ra(t.success):La()}var Dw=`~effect/http/HttpIncomingMessage`,Ow=(e,t)=>{let n=e.headers[`content-type`]??``,r;if(n.includes(`application/json`))try{r=am(e.json)}catch{}else if(n.includes(`text/`)||n.includes(`urlencoded`))try{r=am(e.text)}catch{}let i={...t,headers:Pr(e.headers),remoteAddress:e.remoteAddress};return r!==void 0&&(i.body=r),i},kw=`~effect/http/HttpClientResponse`,Aw=(e,t)=>new jw(e,t),jw=class extends Zr{[Dw];[kw];request;source;constructor(e,t){super(),this.request=e,this.source=t,this[Dw]=Dw,this[kw]=kw}toJSON(){return Ow(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=Ew(this.request);return za(e)?``:(e.value.hash=``,e.value.href)}get headers(){return yh(this.source.headers)}cachedCookies;get cookies(){return this.cachedCookies?this.cachedCookies:this.cachedCookies=ih(this.source.headers.getSetCookie?.()??[])}get remoteAddress(){return La()}get stream(){return this.source.body?YS({evaluate:()=>this.source.body,onError:e=>new qC({reason:new $C({request:this.request,response:this,cause:e})})}):JS(new qC({reason:new ew({request:this.request,response:this,description:`can not create stream from empty body`})}))}get json(){return z(this.text,e=>Ap({try:()=>e===``?null:JSON.parse(e),catch:e=>new qC({reason:new $C({request:this.request,response:this,cause:e})})}))}textBody;get text(){return this.textBody??=Ip(this.arrayBuffer,e=>new TextDecoder().decode(e))}get urlParamsBody(){return z(this.text,e=>Ap({try:()=>Mh(new URLSearchParams(e)),catch:e=>new qC({reason:new $C({request:this.request,response:this,cause:e})})}))}formDataBody;get formData(){return this.formDataBody??=Sp({try:()=>this.source.formData(),catch:e=>new qC({reason:new $C({request:this.request,response:this,cause:e})})}).pipe(Zp,am)}arrayBufferBody;get arrayBuffer(){return this.arrayBufferBody||=Sp({try:()=>this.source.arrayBuffer(),catch:e=>new qC({reason:new $C({request:this.request,response:this,cause:e})})}).pipe(Zp,am),this.arrayBufferBody}pipe(){return y(this,arguments)}},Mw=e=>bh({b3:`${e.traceId}-${e.spanId}-${e.sampled?`1`:`0`}${Va(e.parent,{onNone:()=>``,onSome:e=>`-${e.spanId}`})}`,traceparent:`00-${e.traceId}-${e.spanId}-${e.sampled?`01`:`00`}`}),Nw={"http:":80,"https:":443,"ws:":80,"wss:":443},Pw=(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===``?Nw[t.protocol]:Number(t.port);n!==void 0&&e.attribute(`server.port`,n)}},Fw=(e,t,n,r,i)=>{for(let a in n)r(a,t)&&e.attribute(`http.${t}.header.${a}`,Eh(a,i)?`<redacted>`:n[a])},Iw=`~effect/http/HttpClient`,Lw=A(`effect/HttpClient`),Rw=b(2,(e,t)=>zw(n=>t(e.postprocess(n)),e.preprocess)),zw=(e,t)=>{let n=Object.create(Bw);return n.preprocess=t,n.postprocess=e,n.execute=function(n){return e(t(n))},n},Bw={[Iw]:Iw,pipe(){return y(this,arguments)},...Xr,toJSON(){return{_id:`effect/HttpClient`}},...Object.fromEntries(nw.map(([e,t])=>[t,function(t,n){return this.execute(dw(e)(t,n))}]))},Vw=e=>zw(t=>z(t,t=>jp(n=>{let r=Xw.get(t),i=r??new AbortController,a=aw(t.url,t.urlParams,Wa(t.hash));if(Ao(a))return R(new qC({reason:new ZC({request:t,cause:a.failure})}));let o=a.success;if(n.getRef(nc)||n.getRef(Ww)(t)){let a=e(t,o,i.signal,n);return r?a:$p(e=>Hp(e(a),{onSuccess(e){return Yw.register(e,i),L(new Zw(e,i))},onFailure(e){return ef(e)&&i.abort(),Dp(e)}}))}return tm(n.getRef(qw)(t),{kind:`client`},a=>{a.attribute(`http.request.method`,t.method);let s=n.getRef(Dh);Pw(a,o);let c=n.getRef(Gw);return Fw(a,`request`,t.headers,c,s),t=n.getRef(Kw)?hw(t,Mw(a)):t,$p(l=>l(e(t,o,i.signal,n)).pipe(nm(a,{captureStackTrace:!1}),Hp({onSuccess:e=>(a.attribute(`http.response.status_code`,e.status),Fw(a,`response`,e.headers,c,s),e.status>=400&&e.status<600&&(a.attribute(`error.type`,String(e.status)),Hw(n,a,t,e)),r?L(e):(Yw.register(e,i),L(new Zw(e,i)))),onFailure(e){return!r&&ef(e)&&i.abort(),Dp(e)}})))})})),L),Hw=(e,t,n,r)=>{let i=$r();ei(0);let a;try{a=sf(new qC({reason:new QC({request:n,response:r})}))}finally{ei(i)}t.end(e.getRef(hf)?e.getRef(qf).currentTimeNanosUnsafe():BigInt(0),a)},Uw=b(2,(e,t)=>zw(e.postprocess,n=>Ip(e.preprocess(n),t))),Ww=j(`effect/http/HttpClient/TracerDisabledWhen`,{defaultValue:()=>An}),Gw=j(`effect/http/HttpClient/TracerHeaderFilter`,{defaultValue:()=>An}),Kw=j(`effect/http/HttpClient/TracerPropagationEnabled`,{defaultValue:kn}),qw=j(`effect/http/HttpClient/SpanNameGenerator`,{defaultValue:()=>e=>e.method}),Jw=e=>Rf(Lw)(Wp(t=>Ip(e,e=>Rw(e,qp(e=>wo(t,e)))))),Yw=(()=>{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))}}})(),Xw=new WeakMap,Zw=class{original;controller;constructor(e,t){this.original=e,this.controller=t}[kw]=kw;[Dw]=Dw;applyInterrupt(e){return Cp(()=>(Yw.unregister(this.original),Qp(e,()=>wp(()=>{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 qS(()=>(Yw.unregister(this.original),$S(this.original.stream,wp(()=>{this.controller.abort()}))))}toJSON(){return this.original.toJSON()}[Jr](){return this.original[Jr]()}pipe(){return y(this,arguments)}},Qw=j(`effect/http/FetchHttpClient/Fetch`,{defaultValue:()=>globalThis.fetch}),$w=class extends A()(`effect/http/FetchHttpClient/RequestInit`){},eT=Jw(L(Vw((e,t,n,r)=>{let i=r.getRef(Qw),a=_o(r.context,$w)??{},o=a.headers?Ch(yh(a.headers),e.headers):e.headers;o[`content-length`]&&(o=wh(o,`content-length`));let s=r=>Ip(Sp({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 qC({reason:new XC({request:e,cause:t})})}),t=>Aw(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 z(rC(e.body.stream),s)}return s(void 0)})));({...pi});var tT=new Uint8Array(256);for(let e of"!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")tT[e.charCodeAt(0)]=1;var nT=new Uint8Array(256);nT[9]=1;for(let e=32;e<=126;e++)nT[e]=1;for(let e=128;e<=255;e++)nT[e]=1;var rT=A(`effect/http/HttpServerRequest`),iT=new WeakSet,aT=e=>jp(t=>{let n=yo(t.context,rT);return iT.add(n.source),e}),oT=A(`effect/http/HttpRouter`),sT=e=>e.endsWith(`/`)?e.slice(0,-1):e,cT=b(2,(e,t)=>(t=sT(t),e===`*`?`${t}/*`:e===`/`?t:t+e)),lT=`~effect/http/HttpRouter/Middleware`,uT=function(){return arguments.length===0?dT:dT(arguments[0],arguments[1])},dT=(e,t)=>t?.global?Vf(Ep(function*(){let t=yield*oT,n=yp(e)?yield*e:e;yield*t.addGlobalMiddleware(n)})):new mT(yp(e)?Bf(Ip(e,e=>ao(new Map([[pT,e]])))):Lf(ao(new Map([[pT,e]])))),fT=0,pT=`effect/http/HttpRouter/MiddlewareFn`,mT=class e{[lT]={};layerFn;dependencies;constructor(e,t){this.layerFn=e,this.dependencies=t;let n=`effect/http/HttpRouter/Middleware-${++fT}`;this.layer=Bf(Ep({self:this},function*(){let e=yield*Up(),t=[vo(e,pT)];if(this.dependencies){let n=yield*Pf,r=bo(e,gf),i=yield*Ff(this.dependencies,n,r);t.push(...gT(i))}return ao(new Map([[n,t]]))})).pipe(Gf(this.layerFn))}layer;combine(t){return new e(this.layerFn,this.dependencies?Kf(this.dependencies,t.layer):t.layer)}},hT=new WeakMap,gT=e=>{let t=hT.get(e);if(t)return t;let n=qo(),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=Bo(e).reverse()}return hT.set(e,t),t};uT(aT).layer;var _T={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},vT=e=>_T[e],yT=`~effect/encoding/Sse/SseError`,bT=class extends Gs(`EventTooLarge`){get message(){return`Pending SSE event exceeded the maximum size of ${this.maxEventSize}`}},xT=class extends Gs(`SseError`){[yT]=yT;get message(){return this.reason.message}},ST=10485760,CT=e=>xS((t,n)=>wp(()=>{let n=[],r,i=TT(e=>{e._tag===`Retry`?r=e:n.push(e)},e),a=z(t,e=>{for(let t=0;t<e.length;t++){let n=i.feed(e[t]);if(n!==void 0)return R(n)}return Tp});return Cp(function e(){if(Wo(n)){let e=n;return n=[],L(e)}return r?R(r):z(a,e)})})),wT=(e,t,n)=>jS(CT(t),RS(AT.pipe(Y(e,jT)),n)());function TT(e,t){let n=t?.maxEventSize??ST,r=t?.dispatchEmptyNamedEvents===!0,i,a,o,s,c=0,l,u,d;return f(),{feed:p,reset:f};function f(){c++,i=!0,a=[],o=0,s=!1,l=void 0,u=void 0,d=``}function p(e){i&&e.startsWith(ET)&&(e=e.slice(ET.length)),i=!1;let t=e.length,r=c,l=0;for(;l<t;){if(s&&(s=!1,e.charCodeAt(l)===DT)){++l;continue}let n=l;for(;n<t;){let t=e.charCodeAt(n);if(t===OT||t===DT)break;++n}if(n===t){a.push(e.slice(l)),o+=t-l;break}s=e.charCodeAt(n)===OT;let i=e.slice(l,n);if(a.length>0&&(a.push(i),i=a.join(``),a=[],o=0),m(i),c!==r)return;l=n+1}if(o+d.length>n){let e=new xT({reason:new bT({maxEventSize:n})});return f(),e}}function m(t){if(t.length===0){let t=u!==void 0&&u!==``,n=u||`message`,i=d;u=void 0,d=``,(i.length>0||r&&t)&&e({_tag:`Event`,id:l,event:n,data:i.slice(0,-1)});return}let n=t.indexOf(`:`),i=t,a=``;n>=0&&(i=t.slice(0,n),a=t.slice(t.charCodeAt(n+1)===kT?n+2:n+1)),i===`data`?d+=a+`
10
- `:i===`event`?u=a:i===`id`&&!a.includes(`\0`)?l=a:i===`retry`&&/^\d+$/.test(a)&&e(new NT({duration:Ss(parseInt(a,10)),lastEventId:l}))}}var ET=``,DT=10,OT=13,kT=32,AT=q({_tag:bx(`Event`),id:_x(K),event:K,data:K}),jT=Zg({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})}),MT=`~effect/encoding/Sse/Retry`,NT=class e extends Ws(`Retry`){[MT]=MT;static is(e){return S(e,MT)}static filter(t){return e.is(t)?Do(t):Oo(t)}},PT=`~effect/http-api/HttpApiSchema/Stream`;function FT(e){let t=typeof e==`string`?vT(e):e;return e=>e.annotate({httpApiStatus:t})}var IT=(e=>ox.pipe(FT(e)))(204),LT=e=>Yb(e)&&S(e,PT),RT=e=>LT(e)&&e._tag===`StreamSse`,zT=e=>LT(e)&&e._tag===`StreamUint8Array`,BT=`~effect/http-api/HttpApiSchema/WithHeaders`,VT=`~effect/http-api/HttpApiSchema/WithHeadersValue`,HT=e=>({[VT]:VT,body:e.body,headers:e.headers}),UT=e=>Yb(e)&&S(e,`~effect/http-api/HttpApiSchema/WithHeaders`);function WT(e,t,n){return G(e.ast,{[BT]:BT,schema:t,headers:n})}function GT(e,t){return e.annotate({"~httpApiEncoding":{_tag:t._tag,contentType:t.contentType??KT(t._tag)}})}function KT(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 qT(e){return t=>GT(t,{_tag:`Json`,...e})}function JT(e){return t=>GT(t,{_tag:`FormUrlEncoded`,...e})}var YT=e=>{if(p_(e)||p_(cy(e)))return!0;let t=e.encoding?.[0].to;return t!==void 0&&p_(t)},XT=wy(`~httpApiEncoding`),ZT=wy(`~httpApiWithHeaders`),QT=wy(`httpApiStatus`),$T={_tag:`Json`,contentType:`application/json`},eE={_tag:`FormUrlEncoded`,contentType:`application/x-www-form-urlencoded`};function tE(e){return XT(e)??$T}function nE(e,t){return XT(e)||(tw(t)?$T:eE)}function rE(e){let t=tE(e);if(t._tag===`Multipart`)throw Error(`Multipart is not supported in response`);return t}function iE(e){return QT(e)??200}function aE(e){return UT(e)?QT(e.ast)??iE(e.schema.ast):iE(e.ast)}function oE(e){return UT(e)&&XT(e.ast)===void 0?rE(e.schema.ast):rE(e.ast)}function sE(e){return QT(e)??500}function cE(e){return UT(e)?QT(e.ast)??sE(e.schema.ast):sE(e.ast)}function lE(e){let t=e.toLowerCase().trim(),n=t.indexOf(`;`);return n===-1?t:t.slice(0,n).trim()}var uE=`~effect/http-api/HttpApiEndpoint`;function dE(e){let t=[];for(let{schemas:n}of e.payload.values())t.push(...n);return t}function fE(e){let t=Array.from(e.success);return Wo(t)?t:[IT]}function pE(e){let t=new Set(e.error),n=e.disableCodecs?x:SE;for(let r of e.middlewares){let e=r;for(let r of e.error)t.add(n(r))}return Array.from(t)}var mE={[uE]:uE,pipe(){return y(this,arguments)},prefix(e){return gE({...hE(this),path:cT(this.path,e)})},middleware(e){return gE({...hE(this),middlewares:new Set([...this.middlewares,e])})},annotate(e,t){return gE({...hE(this),annotations:ho(this.annotations,e,t)})},annotateMerge(e){return gE({...hE(this),annotations:wo(this.annotations,e)})}},hE=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 gE(e){function t(){}return Object.setPrototypeOf(t,mE),Object.assign(t,e)}var _E=e=>(t,n,r)=>{let i=r?.disableCodecs??!1,a=i?x:pS;return gE({identifier:t,path:n,method:e,params:vE(r?.params,a),query:vE(r?.query,a),headers:vE(r?.headers,a),payload:yE(r?.payload,e,i),success:xE(r?.success,e,i),error:CE(r?.error,i),annotations:fo(),middlewares:new Set,disableCodecs:i})};function vE(e,t){if(e!==void 0)return Yb(e)?t(e):t(q(e))}function yE(e,t,n){let r=new Map;if(e===void 0)return r;let i=Array.isArray(e)?e:Yb(e)?[e]:[q(e).pipe(JT())],a=n?x:NE;for(let e of i){let n=nE(e.ast,t),i=lE(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 bE=`effect/http-api/stream/failure`;function xE(e,t,n){if(e===void 0)return new Set;let r=Vo(e);return wE(r,t),new Set(n?r:r.map(SE))}var SE=Nn(e=>LT(e)?e:UT(e)?WT(e,LT(e.schema)?e.schema:ME(e.schema,oE(e)),pS(e.headers)):jE(e));function CE(e,t){if(e===void 0)return new Set;let n=Vo(e);for(let e of n)if(LT(UT(e)?e.schema:e))throw Error(`Streaming schemas are not supported in error responses`);return EE(n,cE),new Set(t?n:n.map(SE))}function wE(e,t){let n=!1,r=new Map;for(let i of e){let e=UT(i)?i.schema:i,a=aE(i);if(LT(e)){if(DE(e,t),n)throw Error(`Multiple streaming success responses are not supported`);n=!0;let i=TE(r,a);if(i.noContent)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);if(i.bufferedContentTypes.has(lE(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=TE(r,a),n=YT(e.ast);if(t.stream!==void 0){if(n)throw Error(`Cannot combine no-content and streaming success responses for status: ${a}`);let e=oE(i);if(lE(e.contentType)===lE(t.stream.contentType))throw Error(`Cannot combine buffered and streaming success responses for status ${a} and content-type: ${e.contentType}`)}n||t.bufferedContentTypes.add(lE(oE(i).contentType)),t.noContent=t.noContent||n}}EE(e,aE)}function TE(e,t){let n=e.get(t);return n===void 0&&(n={bufferedContentTypes:new Set,noContent:!1},e.set(t,n)),n}function EE(e,t){let n=new Map;for(let r of e){let e=t(r),i=ZT(r.ast),a=UT(r)?r.schema:i?.body??r,o=YT(a.ast)?``:lE(LT(a)?a.contentType:oE(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(UT(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 DE(e,t){if(t===`HEAD`)throw Error(`HEAD endpoints cannot declare streaming success responses`);if(RT(e)&&OE(e.events.ast))throw Error(`SSE event name is reserved: ${bE}`)}function OE(e){return kE(cy(e),new Set)}function kE(e,t){if(t.has(e))return!1;if(t.add(e),b_(e))return e.types.some(e=>kE(e,t));if(x_(e))return kE(e.thunk(),t);if(!y_(e))return!1;let n=e.propertySignatures.find(e=>e.name===`event`);return n!==void 0&&AE(n.type,t)}function AE(e,t){if(t.has(e))return!1;t.add(e);let n=cy(e);return n===e?h_(e)?e.literal===bE:b_(e)?e.types.some(e=>AE(e,t)):x_(e)?AE(e.thunk(),t):!1:AE(n,t)}function jE(e){let t=rE(e.ast),n=ZT(e.ast);return n===void 0?ME(e,t):e.annotate({"~httpApiWithHeaders":{...n,bodyCodec:ME(n.body,t),headersCodec:pS(n.headers)}})}function ME(e,t){switch(t._tag){case`Json`:return fS(e);case`FormUrlEncoded`:return pS(e);case`Text`:case`Uint8Array`:return e}}function NE(e,t){switch(nE(e.ast,t)._tag){case`Json`:return fS(e);case`FormUrlEncoded`:return pS(e);case`Text`:case`Uint8Array`:case`Multipart`:return e}}var PE=_E(`POST`),FE=`~effect/http-api/HttpApi`,IE={[FE]:FE,pipe(){return y(this,arguments)},add(...e){let t={...this.groups};for(let n of e)ri(t,n.identifier,n);return RE({...LE(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(wo(e.annotations,r.annotations)))}return RE({...LE(this),groups:t})},prefix(e){return RE({...LE(this),groups:Fo(this.groups,t=>t.prefix(e))})},middleware(e){return RE({...LE(this),groups:Fo(this.groups,t=>t.middleware(e))})},annotate(e,t){return RE({...LE(this),annotations:ho(this.annotations,e,t)})},annotateMerge(e){return RE({...LE(this),annotations:wo(this.annotations,e)})}},LE=e=>({identifier:e.identifier,groups:e.groups,annotations:e.annotations}),RE=e=>{function t(){}return Object.setPrototypeOf(t,IE),Object.assign(t,e)},zE=e=>RE({identifier:e,groups:{},annotations:fo()}),BE=(e,t)=>{let n=Object.values(e.groups);for(let r of n){let n=wo(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:wo(n,e.annotations),successes:VE(fE(e),aE),errors:VE(pE(e),cE)})}},VE=(e,t)=>{let n=new Map;return e.forEach(r),n;function r(e){if(LT(UT(e)?e.schema:e))return;let r=t(e),i=n.get(r);i===void 0?n.set(r,[e]):i.push(e)}},HE=class extends A()(`effect/http-api/HttpApi/ParseOptions`){},UE=class extends A()(`effect/http-api/HttpApi/ParamsParseOptions`){},WE=class extends A()(`effect/http-api/HttpApi/QueryParseOptions`){},GE=class extends A()(`effect/http-api/HttpApi/HeadersParseOptions`){},KE=class extends A()(`effect/http-api/HttpApi/PayloadParseOptions`){},qE=class extends A()(`effect/http-api/HttpApi/SuccessParseOptions`){},JE=class extends A()(`effect/http-api/HttpApi/ErrorParseOptions`){},YE=e=>{let t=_o(e,HE);return{params:_o(e,UE)??t,query:_o(e,WE)??t,headers:_o(e,GE)??t,payload:_o(e,KE)??t,success:_o(e,qE)??t,error:_o(e,JE)??t}},XE=`~effect/http-api/HttpApiMiddleware`,ZE=`~effect/http-api/HttpApiMiddleware/Security`,QE=()=>(e,t)=>{let n=$r(),r;n!==0&&(ei(2),r=new globalThis.Error,ei(n));class i extends A()(e){}let a=i;if(Object.defineProperty(i,"stack",{get(){return r?.stack}}),a[XE]=XE,a.error=$E(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[ZE]=ZE,a.security=t.security}return a};function $E(e){return e===void 0?new Set:new Set(Array.isArray(e)?e:[e])}var eD=new Set;function tD(e){if(e===void 0)return eD;let t=Rv(e.ast);return y_(t)&&t.indexSignatures.length===0?new Set(t.propertySignatures.map(e=>String(e.name))):void 0}var nD=class extends A()(`effect/http-api/OpenApi/Description`){},rD=(e,t)=>Ep(function*(){let n=yield*Up(),r=t.httpClient.pipe(t?.baseUrl===void 0?x:Uw(yw(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)}})}BE(e,{predicate:t?.predicate,onGroup(e){t.onGroup?.(e)},onEndpoint(e){let{group:n,endpoint:r,errors:a,successes:o,mergedAnnotations:s}=e,c=YE(s),l=sD(r.path,r.params),u={orElse:DD},d=new Map;for(let[e,t]of a.entries()){let n=pD(t);for(let[t,r]of n.entries())dD(d,e,t,cD(r,c.error,c.headers))}for(let[e,t]of d.entries()){let n=fD(t);u[e]=e=>z(Bp(n(e),t=>Dp(Qd(Kd(new qC({reason:new QC({request:e.request,response:e})})),t))),R)}let f=new Map;for(let[e,t]of o.entries()){let n=pD(t);for(let[t,r]of n.entries())dD(f,e,t,cD(r,c.success,c.headers))}for(let e of _D(r)){let t=gD(e)?e.schema:e;dD(f,aE(e),t.contentType,vD(e,c.success,c.headers))}for(let[e,t]of f.entries())u[e]=fD(t);let p=iC(r.params,e=>Jb(e,c.params)),m=dE(r),h=Wo(m)?Jb(tw(r.method)?kD(m,r.method):mx(m),c.payload):void 0,ee=iC(r.headers,e=>Jb(e,c.headers)),te=iC(r.query,e=>Jb(e,c.query)),ne=Array.from(e.middleware,e=>`${e.key}/Client`),re=sm(function*(e){let a=dw(r.method)(r.path);if(e!==void 0){if(p!==void 0){let t=yield*p(e.params);a=vw(a,l(t))}if(h!==void 0){if(tw(r.method)){if(e.payload instanceof FormData)a=Tw(a,e.payload);else{let t=yield*h(e.payload);a=ww(a,t)}}else{let t=yield*h(e.payload);a=Sw(a,t)}}if(ee!==void 0){let t=yield*ee(e.headers);a=hw(a,t)}if(te!==void 0){let t=yield*te(e.query);a=Sw(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})}})}),iD=(e,t)=>z(Lw,n=>aD(e,{...t,httpClient:t?.transformClient?t.transformClient(n):n})),aD=(e,t)=>{let n={};return rD(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(Lp(n))},oD=/(\/?):(\w+)(\?)?/g,sD=(e,t)=>{if(t===void 0||!e.includes(`:`))return t=>e;let n=tD(t);return t=>e.replace(oD,(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 cD(e,t,n){let r=e.some(e=>UT(e)||ZT(e.ast)!==void 0),i=Gb(r?mx(e.map(e=>uD(e,t,n))):TD(e),t);return e=>z(e.arrayBuffer,r?t=>i({body:t,headers:e.headers}):i)}var lD=q({body:tx,headers:tx});function uD(e,t,n){let r=ZT(e.ast),i=r===void 0?UT(e)?{body:e.schema,headers:e.headers,toValue:HT}:{body:e,headers:tx,toValue:e=>e.body}:{body:r.bodyCodec,headers:r.headersCodec,toValue:r.transformation.decode},a=Gb(ED(i.body).pipe(Y(i.body)),t),o=Gb(i.headers,n);return lD.pipe(Y(UT(e)?e:Qb(e),Xg({decode:e=>bp({body:a(e.body),headers:o(e.headers)}).pipe(Ip(i.toValue),Vp(e=>e.issue)),encode:(e,t)=>R(new dg({message:`Decode only schema`},e,t))})))}function dD(e,t,n,r){let i=lE(n),a=e.get(t);a===void 0?e.set(t,[{contentType:i,decode:r}]):a.push({contentType:i,decode:r})}function fD(e){let t=e[0];return e.length===1&&t!==void 0?t.decode:(t,n)=>{let r=lE(t.headers[`content-type`]??``),i=e.find(e=>e.contentType===r);return i===void 0?mD(t,r,e):i.decode(t,n)}}function pD(e){let t=new Map;for(let n of e){let e=YT((UT(n)?n.schema:n).ast)?``:lE(oE(n).contentType),r=t.get(e);r===void 0?t.set(e,[n]):r.push(n)}return t}function mD(e,t,n){let r=Array.from(new Set(n.map(e=>e.contentType))).join(`, `);return R(new qC({reason:new $C({request:e.request,response:e,description:`Unsupported response content-type for status ${e.status}: ${t||`<missing>`}. Expected one of: ${r}`})}))}var hD=`effect/http-api/stream/failure`,gD=e=>UT(e);function _D(e){let t=[];for(let n of e.success)LT(UT(n)?n.schema:n)&&t.push(n);return t}function vD(e,t,n){let r=gD(e),i=r?e.schema:e,a=zT(i)?void 0:{declaration:i,decoder:yD(i,t)},o=(e,t)=>Ip(Up(),n=>eC(a===void 0?e.stream:bD(e.stream,a.declaration,a.decoder(t)),n));if(!r)return o;let s=Gb(e.headers,n);return(e,t)=>z(s(e.headers),n=>Ip(o(e,t),e=>HT({body:e,headers:n})))}function yD(e,t){let n=mx([q({id:Zb(K),event:$b(hD),data:Ux(fS(Jx(e.error,Vx())))}),e.events]),r=wT(n,void 0,t);return e=>e===void 0?r:wT(n,e,t)}function bD(e,t,n){let r=KS(e.pipe(QS,ZS(n)),e=>wp(()=>{let t;return Cp(()=>t===void 0?z(e,e=>{for(let n=0;n<e.length;n++){let r=e[n];if(r.event===hD&&Hd(r.data)){if(n===0)return Dp(r.data);t=r.data,e=e.slice(0,n);break}}return L(e)}):Dp(t))}));return t.sseMode===`data`?XS(r,e=>e.data):r}var xD=Sx(globalThis.ArrayBuffer,{expected:`ArrayBuffer`}),SD=xD.pipe(Y(Kx,Zg({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)}}))),CD=xD.pipe(Y(K,Zg({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)}}))),wD=CD.pipe(Y(mx([$b(``).pipe(Y(rx,Zg({decode:()=>void 0,encode:()=>``}))),Wx])));function TD(e){return mx(e.map(t));function t(e){return ED(e).pipe(Y(e))}}function ED(e){switch(rE(e.ast)._tag){case`Json`:return f_(cy(e.ast))?wD.pipe(Y(tx,Zg({decode:e=>e===void 0?null:e,encode:e=>e===null?void 0:e}))):wD;case`FormUrlEncoded`:return CD.pipe(Y(nS,Zg({decode:e=>Mh(new URLSearchParams(e)),encode:Bh})));case`Uint8Array`:return SD;case`Text`:return CD}}var DD=e=>R(new qC({reason:new $C({request:e.request,response:e})})),OD=Lb(PC);function kD(e,t){return mx(e.map(e=>jD(e,t)))}var AD=new WeakMap;function jD(e,t){let n=e.ast,r=AD.get(n);if(r!==void 0)return r;let i=nE(n,t),a=OD.pipe(Y(e,Xg({decode(e,t){return R(new dg({message:`Encode only schema`},e,t))},encode(e,t){switch(i._tag){case`Multipart`:return R(new dg({message:`Payload must be a FormData`},e,t));case`Json`:try{return L(HC(JSON.stringify(e),i.contentType))}catch{return R(new lg({expected:`a JSON-serializable request body`},e,t))}case`Text`:return typeof e==`string`?L(HC(e,i.contentType)):R(new lg({message:`Expected a string`},e,t));case`FormUrlEncoded`:return Yn(e)?L(UC(Mh(e),i.contentType)):R(new lg({message:`Expected a record`},e,t));case`Uint8Array`:return e instanceof Uint8Array?L(RC(e,i.contentType)):R(new lg({message:`Expected a Uint8Array`},e,t))}}})));return AD.set(n,a),a}var MD=`~effect/http-api/HttpApiGroup`,ND={[MD]:MD,add(...e){let t={...this.endpoints};for(let n of e)ri(t,n.identifier,n);return FD({...PD(this),endpoints:t})},prefix(e){return FD({...PD(this),endpoints:Fo(this.endpoints,t=>t.prefix(e))})},middleware(e){return FD({...PD(this),endpoints:Fo(this.endpoints,t=>t.middleware(e))})},annotateMerge(e){return FD({...PD(this),annotations:wo(this.annotations,e)})},annotate(e,t){return FD({...PD(this),annotations:ho(this.annotations,e,t)})},annotateEndpointsMerge(e){return FD({...PD(this),endpoints:Fo(this.endpoints,t=>t.annotateMerge(e))})},annotateEndpoints(e,t){return FD({...PD(this),endpoints:Fo(this.endpoints,n=>n.annotate(e,t))})},pipe(){return y(this,arguments)}},PD=e=>({identifier:e.identifier,topLevel:e.topLevel,endpoints:e.endpoints,annotations:e.annotations}),FD=e=>{function t(){}return Object.setPrototypeOf(t,ND),t.key=`effect/http-api/HttpApiGroup/${e.identifier}`,Object.assign(t,e)},ID=(e,t)=>FD({identifier:e,topLevel:t?.topLevel??!1,endpoints:{},annotations:fo()}),LD=`~effect/http-api/HttpApiSecurity`,RD={[LD]:LD,pipe(){return y(this,arguments)}},zD=(e=>Object.assign(Object.create(RD),{_tag:`Http`,scheme:e.scheme,schemeLength:e.scheme.length,annotations:fo()}))({scheme:`Bearer`}),BD=e=>Object.assign(Object.create(RD),{_tag:`ApiKey`,key:e.key,in:e.in??`header`,annotations:fo()}),VD=wy(`httpApiStatus`),HD=e=>VD(e)??(x_(e)?HD(e.thunk()):void 0),UD=e=>{let t=HD(e.ast);if(t!==void 0)return[VD(e.ast)===void 0?FT(t)(e):e];let n=SC(e.ast);return b_(n)&&n.checks===void 0&&n.encoding===void 0?n.types.flatMap(e=>UD(G(e))):[FT(422)(e)]},WD=(e,t={})=>Ip(iD(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}`);return OC(e,e=>n({payload:e}))}}),GD=e=>(e??`/api`).split(`/`).filter(e=>e!==``),KD=e=>`/${e.join(`/`)}`,qD=e=>e.join(`/`)||`/`,JD=(e,t)=>{let n=ID(e,{topLevel:!0}),[r,...i]=t;return zE(`actions`).annotate(HE,{errors:`all`}).add(r===void 0?n:n.add(r,...i))},YD=(e,t,n)=>PE(e.name,t,{payload:e.input.pipe(qT()),success:e.success,error:gC(e,n).flatMap(UD)});function XD(e,t={}){xC(`action`,e);let n=hC(t.error);EC(`ActionHttp binding`,n),MC(e,t.authentication);let r=GD(t.prefix),i=t.authentication?.[`~middleware`],a=e.map(e=>{let a=i===void 0||e.caller===_C,o=YD(e,KD([...r,e.name]),jC(e,n,t.authentication?.error)).annotate(nD,e.description);return a?o:o.middleware(i)}),o=JD(qD(r),a);return{actions:e,error:n,prefix:KD(r),api:o,authentication:t.authentication}}QE()(`effect-actions/ActionHttp/StepUp`),QE()(`effect-actions/ActionHttp/JsonContentType`);var ZD=(e,t)=>Ip(WD(e,t),t=>Object.fromEntries(e.actions.map(e=>[e.name,t(e)])));function QD(e,{fetch:t,...n}={}){return ZD(e,n).pipe(Gp(eT),Jp(Qw,t??((e,t)=>globalThis.fetch(e,t))),am)}var $D=/^[\w.-]+$/,eO=(e,t,...n)=>{let r=n[0]?.security??zD,i=hC(n[0]?.error);if(!$D.test(e))throw Error(`Invalid authentication name: ${JSON.stringify(e)}, not an OpenAPI key`);if(EC(`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":A(`effect-actions/Authentication/Provider/${e}`),"~middleware":QE()(`effect-actions/Authentication/Security/${e}`,{security:{[e]:r}}),"~verified":A(`effect-actions/Authentication/Verified/${e}`)}},tO=[class extends dS()(`BadRequest`,{error:K},{httpApiStatus:400}){},class extends dS()(`NotFound`,{error:K},{httpApiStatus:404}){},class extends dS()(`Conflict`,{error:K},{httpApiStatus:409}){},class extends dS()(`TooManyRequests`,{error:K},{httpApiStatus:429}){},class extends dS()(`InternalServerError`,{error:K},{httpApiStatus:500}){cause},class extends dS()(`ServiceUnavailable`,{error:K},{httpApiStatus:503}){}];[...tO];var nO=class extends A()(`clankerauth/CurrentOwner`){},rO=(e=>eO(`clankerauth.OwnerSession`,nO,{security:BD({in:`cookie`,key:e}),error:tO}))(`better-auth.session_token`),iO=eO(`clankerauth.OwnerToken`,nO,{error:tO}),aO=q({email:K,password:K}),oO=hx([`none`,`client_secret_basic`,`client_secret_post`]),sO=hx([`web`,`native`]),cO=J(K).check(Lx({message:`Choose unique Resources`})),lO=q({client_name:K,redirect_uris:J(K),resources:cO,token_endpoint_auth_method:oO,application_type:sO}),uO=q({client_id:K,client_name:K,redirect_uris:J(K),application_type:sO}),dO=q({client_id:K}),fO=q({client_id:K,resource:Zb(K)}),pO=q({client_id:K,blocked:ax}),mO=q({onboarding:Zb(hx([`managed`,`dcr`,`cimd`])),blocked:Zb(ax),client_id:K,client_name:Zb(K),redirect_uris:J(K),token_endpoint_auth_method:Zb(K),application_type:Zb(gx(K)),scope:Zb(K),grant_types:Zb(J(K))}),hO=mO.pipe(cx({client_secret:Zb(K),client_secret_expires_at:Zb(ix)})),gO=q({identifier:K,name:K,scopes:J(K)}),_O=gO.pipe(cx({builtIn:ax})),vO=q({identifier:K,name:K.check(Tx(/\S/u,{message:`Resources require a name`})),scopes:J(K.check(Tx(/^\s*[\x21\x23-\x5B\x5D-\x7E]+\s*$/u,{message:`Resources require well-formed custom scopes`})))}),yO=q({identifier:K}),bO=q({client_id:K,resource:K}),xO=q({client_id:K,resources:cO}),SO=q({clientAccess:J(bO)}),CO=lx(K,J(K)),wO=lx(K,J(K).check(Mx(1,{message:`Select explicitly granted, currently available Resource scopes`}),Lx({message:`Select explicitly granted, currently available Resource scopes`}))).check(Ix(1,{message:`Select at least one Resource and scope`})),TO=K.check(Px(100,{message:`Key names require 1–100 characters`}),Tx(/\S/u,{message:`Key names require 1–100 characters`})),EO=tS,DO=q({client_id:K,resource:K,scopes:J(K),approvedAt:gx(EO),refreshedAt:gx(EO)}),OO=q({name:TO,permissions:wO,expiresAt:gx(EO)}),kO=q({keyId:K}),AO=q({keyId:K,name:Zb(TO),permissions:Zb(wO),enabled:Zb(ax)}),jO=q({keyId:K,name:K,enabled:ax,permissions:CO,expiresAt:gx(EO),createdAt:EO}),MO={caller:_C,error:tO},NO={caller:nO,error:tO},PO=[X(`setupStatus`,{description:`Check whether the issuer needs its first owner account.`,readOnly:!0,...MO,success:q({required:ax})}),X(`setupOwner`,{description:`Create the first owner account.`,readOnly:!1,...MO,input:aO,success:q({created:ax}).pipe(FT(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,...MO,input:q({resource:K}),success:q({list:K})})],FO=q({clients:J(mO),resources:J(_O),clientAccess:J(bO),connections:J(DO),email:K,issuer:K}),IO=[X(`listClients`,{description:`List clients, resources, managed clients' resource access (what they may obtain), and every client's connections (what it holds).`,readOnly:!0,...NO,success:FO}),X(`createClient`,{description:`Register a first-party OAuth client. Returns its secret once when confidential.`,readOnly:!1,...NO,input:lO,success:hO.pipe(FT(201))}),X(`updateClient`,{description:`Rename a first-party client or change its redirect URIs and application type.`,readOnly:!1,...NO,input:uO,success:mO}),X(`deleteClient`,{description:`Delete a client and its stored authorization. An automatic client can register again; block it to keep it out.`,readOnly:!1,...NO,input:dO,success:q({deleted:ax})}),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,...NO,input:fO,success:q({revoked:ax})}),X(`blockClient`,{description:`Block or unblock OAuth authorization for a client.`,readOnly:!1,...NO,input:pO,success:q({blocked:ax})}),X(`rotateClientSecret`,{description:`Rotate a confidential client secret. Returns the new secret once.`,readOnly:!1,...NO,input:dO,success:hO}),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,...NO,input:xO,success:SO}),X(`createResource`,{description:`Create an OAuth resource and its scopes.`,readOnly:!1,...NO,input:vO,success:gO.pipe(FT(201))}),X(`updateResource`,{description:`Update an OAuth resource and its scopes.`,readOnly:!1,...NO,input:vO,success:gO}),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,...NO,input:yO,success:q({deleted:ax})}),X(`listApiKeys`,{description:`List API key metadata without secret values.`,readOnly:!0,...NO,success:q({keys:J(jO)})}),X(`createApiKey`,{description:`Create a scoped API key. Returns its secret once.`,readOnly:!1,...NO,input:OO,success:jO.pipe(cx({key:K}),FT(201))}),X(`updateApiKey`,{description:`Update an API key’s name, permissions or enabled state.`,readOnly:!1,...NO,input:AO,success:jO}),X(`deleteApiKey`,{description:`Delete an API key.`,readOnly:!1,...NO,input:kO,success:q({deleted:ax})})],LO=(e=>XD([...IO,...PO],{authentication:e}))(rO);XD(IO,{prefix:`/api/owner`,authentication:iO});var Z=QD(LO),RO=Wb(mx(tO)),zO=Wb(mC),BO=e=>RO(e)?Error(e.error):e instanceof lC&&e.issues.length?Error([...new Set(e.issues.map(e=>e.message))].join(` `)):zO(e)?Error(e.message):Error(`Request could not be completed. Please try again.`);async function Q(e){try{return await im(e)}catch(e){throw BO(e)}}var VO=gn({plugins:[Tn()]}),HO=document.querySelector(`#app`);HO.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 UO=document.querySelector(`#main`),$=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]);function WO(e){let t=document.querySelector(`#message`);t.textContent=e,e&&t.hasAttribute(`tabindex`)&&(t.focus(),t.scrollIntoView({behavior:`smooth`,block:`center`}))}var GO=!1;async function KO(e){if(GO)return;GO=!0;let t=Array.from(UO.querySelectorAll(`button`),e=>({button:e,disabled:e.disabled}));t.forEach(({button:e})=>e.disabled=!0),WO(``);try{await e()}catch(e){WO(e instanceof Error?e.message:`Request failed`)}finally{t.forEach(({button:e,disabled:t})=>e.disabled=t),GO=!1}}function qO(e,t){!GO&&confirm(e)&&KO(t)}function JO(){UO.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>
11
- <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>
12
- <form id="setup"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
13
- <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>
14
- <label>Confirm password<input name="confirmation" type="password" autocomplete="new-password" required minlength="8" maxlength="128"></label>
15
- <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(),KO(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(Lp(`/`),zp(`Conflict`,()=>L(`/login`))));location.replace(r)})})}function YO(){UO.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>
16
- <section class="card login"><p class="eyebrow">OWNER ACCESS</p><h2>Welcome back</h2><p class="muted">Use your local account to continue.</p>
17
- <form id="login"><label>Email<input name="email" type="email" autocomplete="username" required placeholder="owner@example.internal"></label>
18
- <label>Password<input name="password" type="password" autocomplete="current-password" required></label>
19
- <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(),KO(async()=>{if((await VO.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 XO(){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 VO.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`);UO.className=`center`,UO.innerHTML=`<section class="card consent"><p class="eyebrow">PERMISSION REQUEST</p><h1>Allow this connection?</h1>
20
- <p><strong>${$(n.data.client_name??t)}</strong> wants to act on your behalf.</p>
21
- ${a?`<p>Client metadata host: <strong>${$(a)}</strong></p>`:``}
22
- <label>Client ID<code>${$(t)}</code></label>
23
- <label>Callback destination<code>${$(o??`Not supplied in this request`)}</code></label>
24
- <p class="help">The client supplies its display name. Review the identifier and callback before approving.</p>
25
- <div class="resource"><span class="eyebrow">ONLY FOR THIS RESOURCE</span>${i.map(e=>`<code>${$(e)}</code>`).join(``)}</div>
26
- <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>
27
- <p class="help">Untick anything this Client should not get. It receives only what stays ticked.</p>
28
- ${e.has(`claims`)?`<h3>Additional identity claims</h3><pre>${$(e.get(`claims`))}</pre>`:``}
29
- <p class="help">Access tokens expire after fifteen minutes. Offline access lets the Client renew them until you revoke its authorization.</p>
30
- <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);KO(async()=>{if(n&&r.length&&!i.length)throw Error(`Tick at least one permission, or deny the request.`);if((await VO.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 ZO(e,t){let n=e.get(t);if(n===null||n instanceof File)throw Error(`Missing form field: ${t}`);return n.trim()}function QO(e){return Array.from(e.querySelectorAll(`input[name="resources"]:checked`),e=>e.value)}function $O(e){let t=[...new Set(ZO(e,`scopes`).split(/\s+/).filter(Boolean))];return{name:ZO(e,`name`),scopes:t}}function ek(e){let t=[...new Set(ZO(e,`redirect_uris`).split(/\s+/).filter(Boolean))];if(!t.length)throw Error(`Add at least one redirect URI.`);return t}var tk={none:`Public client (PKCE only)`,client_secret_basic:`Confidential client · HTTP Basic secret`,client_secret_post:`Confidential client · secret in request body`},nk=e=>qb(oO)(ZO(e,`token_endpoint_auth_method`)),rk=e=>qb(sO)(e.has(`native`)?`native`:`web`);function ik(e){let t={};for(let n of e.querySelectorAll(`input[name="key-scope"]:checked`))(t[n.dataset.resource]??=[]).push(n.value);return t}var ak=new Map,ok=new Map;function sk(){let e=document.querySelector(`#credentials`);if(e.classList.toggle(`hidden`,ok.size===0&&ak.size===0),e.replaceChildren(),!ok.size&&!ak.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 ok.values()){let n=document.createElement(`pre`);n.textContent=JSON.stringify(e,null,2),t.before(n)}for(let e of ak.values()){let n=document.createElement(`pre`);n.textContent=e,t.before(n)}t.addEventListener(`click`,()=>{ak.clear(),ok.clear(),sk()})}function ck(){sk(),document.querySelector(`#credentials`).scrollIntoView({behavior:`smooth`})}async function lk(){try{await Ek()}catch{document.querySelector(`#dashboard-mutations`).disabled=!0,WO(`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`,()=>{KO(lk)}),document.querySelector(`#message`).append(` `,e)}}var uk=`Optional. Separate scopes with spaces. offline_access is reserved.`,dk={managed:`Managed registration · first party, no consent screen`,dcr:`Dynamic registration`,cimd:`Client ID Metadata Document`},fk=e=>!e.onboarding||e.onboarding===`managed`,pk=(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>`,mk=(e,t)=>`<div class="empty"><h3>${e}</h3><p>${t}</p></div>`,hk=e=>`<code>${$(e.identifier)}</code><span class="muted">${$(e.scopes.join(` · `))}</span>`,gk=(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)}${hk(e)}</span></label>`).join(``),_k=(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>`,vk=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3>${hk(e)}
31
- <p class="help dependencies">Connected Clients: ${t.length?t.map(e=>$(e.client_name??e.client_id)).join(`, `):`None`}</p>
32
- ${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>
33
- <button class="danger" data-resource-delete="${$(e.identifier)}">Delete resource</button>`}</article>`,yk=()=>`<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/"></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">${uk}</p><button>Add resource +</button></form>`,bk=(e,t)=>`<article class="resource"><h3>${$(e.name)}</h3><p>${e.enabled?`Enabled`:`Disabled`} · ${e.expiresAt?`Expires ${$(Um(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(``)}
34
- <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>
35
- <details><summary>Edit grants</summary><form data-key-grants="${$(e.keyId)}">${_k(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>
36
- <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>`,xk=e=>`<h2>Create API key</h2><form id="key-create"><label>Name<input name="name" required maxlength="100" placeholder="Backup script"></label>${_k(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>`,Sk=e=>$(Um(e,{dateStyle:`medium`,timeStyle:`short`})),Ck=(e,t)=>{let n=t.find(t=>t.identifier===e.resource),r=[e.approvedAt?`Approved ${Sk(e.approvedAt)}`:`First party, no consent`,e.refreshedAt?`last token ${Sk(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>`},wk=(e,t,n,r)=>{let i=fk(e),a=$(e.client_id),o=r.map(e=>Ck(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>${gk(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(`
37
- `))}</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">${dk[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>
38
- <h3>Connections</h3>${o}${s}${c}<div class="actions">${l}</div></article>`},Tk=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>${gk(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(tk).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 Ek(){let[e,t]=await Q(bp([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);UO.className=`dashboard`,UO.innerHTML=`
39
- <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>
40
- <div class="issuer"><span class="dot"></span><span>Canonical issuer</span><code>${$(e.issuer)}</code></div>
41
- <p id="message" role="alert" tabindex="-1"></p>
42
- <section id="credentials" class="card hidden" aria-live="polite"></section>
43
- <fieldset id="dashboard-mutations" aria-label="Clients and Resources">
44
- ${pk(`Resources`,n.length,`Protected APIs and MCP servers, and the scopes they define.`,n.map(t=>vk(t,e.clients.filter(e=>a(e.client_id).some(e=>e.resource===t.identifier)))).join(``)||mk(`Add your first Resource`,`Define a protected API or MCP server. Compatible MCP clients onboard automatically when you connect.`),yk())}
45
- ${pk(`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=>bk(e,r)).join(``)||mk(`No API keys`,`Create a key for a CLI or automation that needs direct access.`),xk(r))}
46
- ${pk(`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=>wk(e,n,i(e.client_id),a(e.client_id))).join(``)||mk(`No Clients registered`,`Connect your MCP client to a configured server to onboard automatically, or register a managed Client here.`),Tk(n))}
47
- </fieldset>`,sk();let o=e=>document.querySelector(e),s=(e,t)=>e.addEventListener(`submit`,n=>{n.preventDefault(),KO(()=>t(e))}),c=(e,t)=>{for(let n of UO.querySelectorAll(e))n.addEventListener(`click`,()=>t(n))};document.querySelector(`#logout`).addEventListener(`click`,()=>{KO(async()=>{await VO.signOut(),location.assign(`/login`)})}),s(o(`#register`),async e=>{let t=new FormData(e),n=await Q(Z.createClient({client_name:ZO(t,`name`),redirect_uris:ek(t),resources:QO(e),application_type:rk(t),token_endpoint_auth_method:nk(t)}));e.reset(),ok.set(n.client_id,n),ck(),await lk()}),s(o(`#key-create`),async e=>{let t=new FormData(e),n=ZO(t,`expiry`),r=await Q(Z.createApiKey({name:ZO(t,`name`),permissions:ik(e),expiresAt:n?zm(new Date(n)):null}));ak.set(r.keyId,`${r.name}\n${r.key}`),e.reset(),ck(),await lk()}),s(o(`#resource-create`),async e=>{let t=new FormData(e);await Q(Z.createResource({identifier:ZO(t,`identifier`),...$O(t)})),e.reset(),await lk()});for(let e of UO.querySelectorAll(`[data-key-rename]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyRename,name:ZO(new FormData(e),`name`)})),await lk()});for(let e of UO.querySelectorAll(`[data-key-grants]`))s(e,async e=>{await Q(Z.updateApiKey({keyId:e.dataset.keyGrants,permissions:ik(e)})),await lk()});for(let e of UO.querySelectorAll(`[data-resource-edit]`))s(e,async e=>{await Q(Z.updateResource({identifier:e.dataset.resourceEdit,...$O(new FormData(e))})),await lk()});for(let e of UO.querySelectorAll(`[data-client-edit]`))s(e,async e=>{let t=new FormData(e);await Q(Z.updateClient({client_id:e.dataset.clientEdit,client_name:ZO(t,`name`),redirect_uris:ek(t),application_type:rk(t)})),await lk()});for(let e of UO.querySelectorAll(`[data-client-access]`))e.addEventListener(`submit`,t=>{t.preventDefault();let n=e.dataset.clientAccess,r=QO(e),a=i(n).filter(e=>!r.includes(e)),o=async()=>{await Q(Z.setClientAccess({client_id:n,resources:r})),await lk()};a.length?qO(`Remove access to ${a.join(`, `)}? This revokes the Client\u2019s authorization for ${a.length===1?`it`:`them`}.`,o):KO(o)});c(`[data-key-toggle]`,e=>{KO(async()=>{await Q(Z.updateApiKey({keyId:e.dataset.keyToggle,enabled:e.dataset.enabled!==`true`})),await lk()})}),c(`[data-key-delete]`,e=>{let t=e.dataset.keyDelete;qO(`Delete this API key?`,async()=>{await Q(Z.deleteApiKey({keyId:t})),ak.delete(t),sk(),await lk()})}),c(`[data-revoke]`,e=>{let t=e.dataset.revoke;qO(`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 lk()})}),c(`[data-disconnect]`,e=>{let t=e.dataset.disconnect,n=e.dataset.resource;qO(`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 lk()})}),c(`[data-block]`,e=>{let t=e.dataset.block,n=e.dataset.blocked!==`true`;qO(n?`Block this Client and revoke its authorization?`:`Unblock this Client?`,async()=>{await Q(Z.blockClient({client_id:t,blocked:n})),await lk()})}),c(`[data-rotate]`,e=>{let t=e.dataset.rotate;qO(`Rotate the secret? The old one stops working immediately.`,async()=>{let e=await Q(Z.rotateClientSecret({client_id:t}));ok.set(e.client_id,e),ck()})}),c(`[data-delete]`,e=>{let t=e.dataset.delete;qO(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})),ok.delete(t),sk(),await lk()})}),c(`[data-resource-delete]`,e=>{let t=e.dataset.resourceDelete;qO(`Delete Resource ${t}? Every Client\u2019s authorization for it is revoked; API-key grants are kept.`,async()=>{await Q(Z.deleteResource({identifier:t})),await lk()})})}try{if((await Q(Z.setupStatus())).required)location.pathname===`/setup`?JO():location.replace(`/setup`);else if(location.pathname===`/setup`){let e=await VO.getSession();location.replace(e.data?`/`:`/login`)}else location.pathname===`/consent`?await XO():!(await VO.getSession()).data||location.pathname===`/login`?YO():await Ek()}catch(e){UO.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>`}