import{l as e}from"./cache-request-state-CDdKGw_d.js";import{n as t,t as n}from"./root-params-BRJbrazk.js";function r(e){return typeof e==`function`}function i(e){return typeof e==`object`&&!!e&&`load`in e&&typeof e.load==`function`}function a(t){return e(t)}function o(e,o){let s=e.filter(e=>r(e)||i(e));if(s.length===0)return null;let c=e=>n(e,o??[]),l=null,u=null,d=()=>l?Promise.resolve(l):(u||=(async()=>(l=(await Promise.all(s.map(async e=>{if(r(e))return e;let t=await e.load(),n=t&&typeof t==`object`?t.generateStaticParams:void 0;return r(n)?n:null}))).filter(e=>e!==null),l))(),u);return async e=>{let n=await d();if(n.length===0)return null;if(n.length===1){let r=n[0];return t(c(e.params),async()=>{let t=await r(e);if(!Array.isArray(t))return[];for(let e of t)if(!a(e))return[];return t})}let r=[e.params];for(let e of n){let n=[];for(let i of r){let r=await t(c(i),async()=>e({params:i}));if(!Array.isArray(r))return[];for(let e of r){if(!a(e))return[];n.push({...i,...e})}}r=n}return r}}async function s(e){return t(n(e.params,e.rootParamNamesByPattern[e.pattern]),()=>e.fn({params:e.params}))}export{o as n,s as t};