import{a as m,b as h,e as C,f as M,i as k,w as A,u as E,j,k as H,t as N,l as R}from"./entry.731fa101.js";import{u as z}from"./composables.3f41d4a8.js";const I=()=>null;function K(...o){var D,_,x,g,P,b,w;const r=typeof o[o.length-1]=="string"?o.pop():void 0;typeof o[0]!="string"&&o.unshift(r);let[a,i,t={}]=o;if(typeof a!="string")throw new TypeError("[nuxt] [asyncData] key must be a string.");if(typeof i!="function")throw new TypeError("[nuxt] [asyncData] handler must be a function.");t.server=(D=t.server)!=null?D:!0,t.default=(_=t.default)!=null?_:I,t.lazy=(x=t.lazy)!=null?x:!1,t.immediate=(g=t.immediate)!=null?g:!0;const e=m(),u=()=>e.isHydrating?e.payload.data[a]:e.static.data[a],f=()=>u()!==void 0;e._asyncData[a]||(e._asyncData[a]={data:h((w=(b=u())!=null?b:(P=t.default)==null?void 0:P.call(t))!=null?w:null),pending:h(!f()),error:h(e.payload._errors[a]?C(e.payload._errors[a]):null)});const s={...e._asyncData[a]};s.refresh=s.execute=(c={})=>{if(e._asyncDataPromises[a]){if(c.dedupe===!1)return e._asyncDataPromises[a];e._asyncDataPromises[a].cancelled=!0}if(c._initial&&f())return u();s.pending.value=!0;const l=new Promise((n,d)=>{try{n(i(e))}catch(y){d(y)}}).then(n=>{if(l.cancelled)return e._asyncDataPromises[a];t.transform&&(n=t.transform(n)),t.pick&&(n=T(n,t.pick)),s.data.value=n,s.error.value=null}).catch(n=>{var d,y;if(l.cancelled)return e._asyncDataPromises[a];s.error.value=n,s.data.value=E((y=(d=t.default)==null?void 0:d.call(t))!=null?y:null)}).finally(()=>{l.cancelled||(s.pending.value=!1,e.payload.data[a]=s.data.value,s.error.value&&(e.payload._errors[a]=C(s.error.value)),delete e._asyncDataPromises[a])});return e._asyncDataPromises[a]=l,e._asyncDataPromises[a]};const p=()=>s.refresh({_initial:!0}),B=t.server!==!1&&e.payload.serverRendered;{const c=j();if(c&&!c._nuxtOnBeforeMountCbs){c._nuxtOnBeforeMountCbs=[];const n=c._nuxtOnBeforeMountCbs;c&&(M(()=>{n.forEach(d=>{d()}),n.splice(0,n.length)}),k(()=>n.splice(0,n.length)))}B&&e.isHydrating&&f()?s.pending.value=!1:c&&(e.payload.serverRendered&&e.isHydrating||t.lazy)&&t.immediate?c._nuxtOnBeforeMountCbs.push(p):t.immediate&&p(),t.watch&&A(t.watch,()=>s.refresh());const l=e.hook("app:data:refresh",n=>{if(!n||n.includes(a))return s.refresh()});c&&k(l)}const v=Promise.resolve(e._asyncDataPromises[a]).then(()=>s);return Object.assign(v,s),v}function T(o,r){const a={};for(const i of r)a[i]=o[i];return a}const O="__nuxt_component";async function $(o,r){const a=m(),i=H(),t=j(),{fetchKey:e}=t.proxy.$options,u=typeof e=="function"?e(()=>""):e||i.fullPath,{data:f}=await K(`options:asyncdata:${u}`,()=>r(a));f.value&&typeof f.value=="object"&&Object.assign(await o,N(R(f.value)))}const S=function(r){const{setup:a}=r;return!a&&!r.asyncData&&!r.head?{[O]:!0,...r}:{[O]:!0,...r,setup(i,t){const e=(a==null?void 0:a(i,t))||{},u=[];if(r.asyncData&&u.push($(e,r.asyncData)),r.head){const f=m();z(typeof r.head=="function"?()=>r.head(f):r.head)}return Promise.resolve(e).then(()=>Promise.all(u)).then(()=>e).finally(()=>{u.length=0})}}};export{S as d};
