1import{o as _,r as x,q as p,t as A,T as v,v as E}from"./index-NapLAG4V.js";function F(r){if(Array.isArray(r))return r.flatMap(i=>F(i));if(typeof r!="string")return[];const s=[];let e=0,n,l,t,a,o;const d=()=>{for(;e<r.length&&/\s/.test(r.charAt(e));)e+=1;return e<r.length},c=()=>(l=r.charAt(e),l!=="="&&l!==";"&&l!==",");for(;e<r.length;){for(n=e,o=!1;d();)if(l=r.charAt(e),l===","){for(t=e,e+=1,d(),a=e;e<r.length&&c();)e+=1;e<r.length&&r.charAt(e)==="="?(o=!0,e=a,s.push(r.slice(n,t)),n=e):e=t+1}else e+=1;(!o||e>=r.length)&&s.push(r.slice(n))}return s}function R(r){return r instanceof Headers?r:Array.isArray(r)?new Headers(r):typeof r=="object"?new Headers(r):null}function j(...r){return r.reduce((s,e)=>{const n=R(e);if(!n)return s;for(const[l,t]of n.entries())l==="set-cookie"?F(t).forEach(a=>s.append("set-cookie",a)):s.set(l,t);return s},new Headers)}function H(r){const s=_();return x.useCallback(async(...e)=>{try{const n=await r(...e);if(p(n))throw n;return n}catch(n){if(p(n))return n.options._fromLocation=s.stores.location.get(),s.navigate(s.resolveRedirect(n).options);throw n}},[s,r])}function m(r){return r!=="__proto__"&&r!=="constructor"&&r!=="prototype"}function y(r,s){const e=Object.create(null);if(r)for(const n of Object.keys(r))m(n)&&(e[n]=r[n]);if(s&&typeof s=="object")for(const n of Object.keys(s))m(n)&&(e[n]=s[n]);return e}function O(r){return Object.create(null)}var b=()=>{throw new Error("createServerOnlyFn() functions can only be called on the server!")},w=(r,s)=>{const e=s||r||{};return typeof e.method>"u"&&(e.method="GET"),Object.assign(t=>w(void 0,{...e,...t}),{options:e,middleware:t=>{const a=[...e.middleware||[]];t.map(d=>{v in d?d.options.middleware&&a.push(...d.options.middleware):a.push(d)});const o=w(void 0,{...e,middleware:a});return o[v]=!0,o},inputValidator:t=>w(void 0,{...e,inputValidator:t}),handler:(...t)=>{const[a,o]=t,d={...e,extractedFn:a,serverFn:o},c=[...d.middleware||[],V(d)];return a.method=e.method,Object.assign(async i=>{const u=await M(c,"client",{...a,...d,data:i?.data,headers:i?.headers,signal:i?.signal,fetch:i?.fetch,context:O()}),f=A(u.error);if(f)throw f;if(u.error)throw u.error;return u.result},{...a,method:e.method,__executeServer:async i=>{const u=b(),f=u.contextAfterGlobalMiddlewares;return await M(c,"server",{...a,...i,serverFnMeta:a.serverFnMeta,context:y(i.context,f),request:u.request}).then(h=>({result:h.result,error:h.error,context:h.sendContext}))}})}})};async function M(r,s,e){let n=S([...E()?.functionMiddleware||[],...r]);if(s==="server"){const t=b();t?.executedRequestMiddlewares&&(n=n.filter(a=>!t.executedRequestMiddlewares.has(a)))}const l=async t=>{const a=n.shift();if(!a)return t;try{"inputValidator"in a.options&&a.options.inputValidator&&s==="server"&&(t.data=await C(a.options.inputValidator,t.data));let o;if(s==="client"?"client"in a.options&&(o=a.options.client):"server"in a.options&&(o=a.options.server),o){const c=await o({...t,next:async(i={})=>{const u=await l({...t,...i,context:y(t.context,i.context),sendContext:y(t.sendContext,i.sendContext),headers:j(t.headers,i.headers),_callSiteFetch:t._callSiteFetch,fetch:t._callSiteFetch??i.fetch??t.fetch,result:i.result!==void 0?i.result:i instanceof Response?i:t.result,error:i.error??t.error});if(u.error)throw u.error;return u}});if(p(c))return{...t,error:c};if(c instanceof Response)return{...t,result:c};if(!c)throw new Error("User middleware returned undefined. You must call next() or return a result in your middlewares.");return c}return l(t)}catch(o){return{...t,error:o}}};return l({...e,headers:e.headers||{},sendContext:e.sendContext||{},context:e.context||O(),_callSiteFetch:e.fetch})}function S(r,s=100){const e=new Set,n=[],l=(t,a)=>{if(a>s)throw new Error(`Middleware nesting depth exceeded maximum of ${s}. Check for circular references.`);t.forEach(o=>{o.options.middleware&&l(o.options.middleware,a+1),e.has(o)||(e.add(o),n.push(o))})};return l(r,0),n}async function C(r,s){if(r==null)return{};if("~standard"in r){const e=await r["~standard"].validate(s);if(e.issues)throw new Error(JSON.stringify(e.issues,void 0,2));return e.value}if("parse"in r)return r.parse(s);if(typeof r=="function")return r(s);throw new Error("Invalid validator type!")}function V(r){return{"~types":void 0,options:{inputValidator:r.inputValidator,client:async({next:s,sendContext:e,fetch:n,...l})=>{const t={...l,context:e,fetch:n};return s(await r.extractedFn?.(t))},server:async({next:s,...e})=>{const n=await r.serverFn?.(e);return s({...e,result:n})}}}}export{w as c,H as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.