rari 0.17.2 → 0.17.4
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.
- package/dist/cli.mjs +1 -1
- package/dist/{define-B_ozIapW.mjs → define-CuBTL1jt.mjs} +1 -1
- package/dist/{execute-CbhDMAQ3.mjs → execute-DJ7w3uhW.mjs} +1 -1
- package/dist/{feed-NrJzjZyg.mjs → feed-CfjUO7Zz.mjs} +1 -1
- package/dist/get-client-component-D2K213pV.mjs +1 -0
- package/dist/image/static.d.mts +1 -1
- package/dist/image.d.mts +1 -1
- package/dist/image.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/mdx/define.mjs +1 -1
- package/dist/mdx.mjs +1 -1
- package/dist/navigation-transition-store-dfNJmkIX.mjs +1 -0
- package/dist/og.mjs +1 -1
- package/dist/preload-modules-BDQFWAlZ.mjs +2 -0
- package/dist/proxy/{runtime-executor.d.mts → executor.d.mts} +1 -1
- package/dist/proxy/{runtime-executor.mjs → executor.mjs} +2 -2
- package/dist/react-helpers-GTRYJwF2.d.mts +5 -0
- package/dist/react-helpers-duOBWuYF.mjs +1 -0
- package/dist/{robots-BOPIkPcN.mjs → robots-C4JcczMZ.mjs} +1 -1
- package/dist/route-cache-D2iIKQIU.mjs +1 -0
- package/dist/router-Cc9lVbtA.mjs +1 -0
- package/dist/router.d.mts +2 -1
- package/dist/router.mjs +1 -1
- package/dist/{rsc-vite-build-CSnu8C3P.mjs → rsc-vite-build-Cyc5ad0S.mjs} +1 -1
- package/dist/runtime/AppRouterProvider.d.mts +15 -5
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.d.mts +3 -3
- package/dist/runtime/ClientRouter.mjs +4 -4
- package/dist/runtime/ErrorBoundaryWrapper.d.mts +3 -4
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/action-flight-refresh.mjs +1 -1
- package/dist/runtime/call-server.mjs +1 -1
- package/dist/runtime/entry-client.mjs +2 -2
- package/dist/runtime/merge-flight-refresh.d.mts +7 -7
- package/dist/runtime/merge-flight-refresh.mjs +1 -1
- package/dist/runtime/rsc-client-runtime.mjs +1 -1
- package/dist/{sitemap--bdIkWl5.mjs → sitemap-BcUkIffd.mjs} +1 -1
- package/dist/{static-modules-DBL6iFbg.d.mts → static-modules-e8GEN_C9.d.mts} +4 -3
- package/dist/type-guards-BLY2PlGR.mjs +1 -0
- package/dist/{types-CkJ_86mo.d.mts → types-Cp7dbLe7.d.mts} +10 -14
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +56 -56
- package/package.json +12 -20
- package/dist/get-client-component-s7qprTUa.mjs +0 -1
- package/dist/navigation-transition-store-CSKrbtbK.mjs +0 -1
- package/dist/preload-modules-Dv_GzGCm.mjs +0 -2
- package/dist/router-Cl4J7j1A.mjs +0 -1
- package/dist/runtime/flight-route-cache.d.mts +0 -27
- package/dist/runtime/flight-route-cache.mjs +0 -1
- package/dist/runtime/flight-router-state.d.mts +0 -11
- package/dist/runtime/flight-router-state.mjs +0 -1
- package/dist/serialize-router-state-uOGGpmBr.mjs +0 -1
- package/dist/type-guards-BJXKlA6x.mjs +0 -1
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./api-routes-Dc2tv31o.mjs";import{
|
|
1
|
+
import{r as e,t}from"./api-routes-Dc2tv31o.mjs";import{C as n,S as r,_ as i,a,c as o,d as s,g as c,n as l,r as u,t as d,v as f,y as p}from"./type-guards-BLY2PlGR.mjs";import{a as m,i as h,r as g,s as _}from"./constants-CRK2JRKf.mjs";import{a as v,d as ee,f as y,i as te,m as ne,n as re,o as b,p as x,r as ie,s as ae,u as oe}from"./regex-constants-DzXwNGh2.mjs";import{a as se,i as ce,n as S,o as C,t as le}from"./path-CTEC1xmy.mjs";import{a as ue,i as de,n as fe,r as w}from"./dist-paths-C4EV064W.mjs";import{a as pe,c as me,i as he,l as ge,n as _e,o as ve,r as ye,s as be,u as xe}from"./rsc-vite-build-Cyc5ad0S.mjs";import{t as Se}from"./timer-Duul5JHq.mjs";import{t as Ce}from"./names-CLmM0CPi.mjs";import{builtinModules as we,createRequire as T}from"node:module";import{Buffer as Te}from"node:buffer";import{spawn as Ee,spawnSync as De}from"node:child_process";import E,{promises as D}from"node:fs";import O from"node:path";import k from"node:process";import{text as Oe}from"node:stream/consumers";import{fileURLToPath as A,pathToFileURL as j}from"node:url";import{createHash as ke}from"node:crypto";import{isFileLoadingAllowed as Ae}from"vite-plus";import{fromBuffer as je}from"@capsizecss/unpack";import Me from"@capsizecss/metrics/arial";import Ne from"@capsizecss/metrics/timesNewRoman";import{reactRefreshWrapperPlugin as Pe}from"vite-plus/internal";function Fe(e){return e.map(e=>e)}function Ie(e){return e}const Le=[`.ts`,`.tsx`,`.js`,`.jsx`,`.mts`,`.mjs`];async function Re(e=k.cwd(),t=`src`,n={}){let r=n.proxyFileName??`proxy`,i=n.extensions??Le;for(let t of i){let n=O.join(e,`${r}${t}`);try{return await D.access(n),n}catch{}}for(let n of i){let i=O.join(e,t,`${r}${n}`);try{return await D.access(i),i}catch{}}return null}function ze(e={}){let{root:t=k.cwd(),srcDir:n=`src`,proxyFileName:r=`proxy`,extensions:i=Le,verbose:a=!1}=e,o=null,s=e=>{a&&console.warn(`[rari] Proxy: ${e}`)};async function c(){let e=await Re(t,n,{proxyFileName:r,extensions:i});if(e==null)return null;let a=O.relative(t,e);return s(`Found proxy file: ${a}`),{filePath:e,exists:!0,relativePath:a}}return Ie({name:`rari:proxy`,async buildStart(){o=await c(),s(o?`Proxy enabled: ${o.relativePath}`:`No proxy file found`)},configureServer(e){o&&(e.watcher.add(o.filePath),e.watcher.on(`change`,t=>{t===o?.filePath&&(s(`Proxy file changed, reloading...`),e.ws.send({type:`custom`,event:`rari:proxy-reload`}))}))},handleHotUpdate({file:e,server:t}){if(e===o?.filePath)return s(`Hot reloading proxy...`),t.ws.send({type:`custom`,event:`rari:proxy-reload`,data:{file:o.relativePath}}),[]}})}function Be(e){if(e==null||e===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}function M(){let{SERVER_PORT:e,PORT:t,RSC_PORT:n}=k.env;return Be(e)??Be(t)??Be(n)??3e3}function Ve(){return`http://localhost:${M()}`}const N=6e4;async function He(e){let t=j(e).href,n=`
|
|
2
2
|
import { registerHooks } from "node:module";
|
|
3
3
|
registerHooks({
|
|
4
4
|
resolve(specifier, context, nextResolve) {
|
|
@@ -16,17 +16,17 @@ const result =
|
|
|
16
16
|
process.send(result, () => {
|
|
17
17
|
process.disconnect();
|
|
18
18
|
});
|
|
19
|
-
`;return new Promise((t,r)=>{let i=Ee(k.execPath,[`--conditions=react-server`,`--input-type=module`,`--eval`,n],{stdio:[`ignore`,`pipe`,`pipe`,`ipc`],env:k.env}),a=``,o=``,s=!1,c=!1,l,u,d,f=()=>{u!==void 0&&clearTimeout(u),d!==void 0&&clearTimeout(d),u=void 0,d=void 0};u=setTimeout(()=>{s||(s=!0,u!==void 0&&clearTimeout(u),u=void 0,i.kill(`SIGTERM`),d=setTimeout(()=>{i.kill(`SIGKILL`)},1e3),r(/* @__PURE__ */ Error(`generateStaticParams timed out after ${
|
|
20
|
-
`);if(n!==0){r(Error(i||`generateStaticParams worker exited with code ${n}`));return}if(!c){r(Error(i||`generateStaticParams worker exited without an IPC result for ${e}`));return}t(l)})})}const
|
|
19
|
+
`;return new Promise((t,r)=>{let i=Ee(k.execPath,[`--conditions=react-server`,`--input-type=module`,`--eval`,n],{stdio:[`ignore`,`pipe`,`pipe`,`ipc`],env:k.env}),a=``,o=``,s=!1,c=!1,l,u,d,f=()=>{u!==void 0&&clearTimeout(u),d!==void 0&&clearTimeout(d),u=void 0,d=void 0};u=setTimeout(()=>{s||(s=!0,u!==void 0&&clearTimeout(u),u=void 0,i.kill(`SIGTERM`),d=setTimeout(()=>{i.kill(`SIGKILL`)},1e3),r(/* @__PURE__ */ Error(`generateStaticParams timed out after ${N}ms for ${e}`)))},N),i.stdout?.setEncoding(`utf8`),i.stderr?.setEncoding(`utf8`),i.stdout?.on(`data`,e=>{a+=e}),i.stderr?.on(`data`,e=>{o+=e}),i.on(`message`,e=>{c=!0,l=e}),i.on(`error`,e=>{s||(s=!0,f(),r(e))}),i.on(`close`,n=>{if(f(),s)return;s=!0;let i=[o.trim(),a.trim()].filter(Boolean).join(`
|
|
20
|
+
`);if(n!==0){r(Error(i||`generateStaticParams worker exited with code ${n}`));return}if(!c){r(Error(i||`generateStaticParams worker exited without an IPC result for ${e}`));return}t(l)})})}const Ue=/\\\*/g;function We(e,t={}){let{escapeAsterisk:n=!0}=t,r=RegExp.escape(e);return n?r:r.replace(Ue,`*`)}const Ge=[`.ico`],Ke=[`.ico`,`.jpg`,`.jpeg`,`.png`,`.svg`],qe=[`.jpg`,`.jpeg`,`.png`],Je={".ico":`image/x-icon`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".svg":`image/svg+xml`};function Ye(e){return Je[e.toLowerCase()]??`application/octet-stream`}function Xe(e,t,n){let r=n.map(e=>We(e.replace(/^\./,``))).join(`|`),i=RegExp(`^${We(t)}(\\d*)\\.(${r})$`,`i`);return e.filter(e=>i.test(e)).sort((e,t)=>e.localeCompare(t))}function Ze(e,t){let n=C(e).replace(/^\/+|\/+$/g,``);return n===``?`/${t}`:`/${n}/${t}`.replace(/\/+/g,`/`)}function Qe(e){if(e.length<24||e[0]!==137||e[1]!==80||e[2]!==78||e[3]!==71)return;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:t.getUint32(16),height:t.getUint32(20)}}async function $e(e){let t=O.extname(e).toLowerCase();if(t===`.svg`||t===`.ico`)return{sizes:`any`};try{let n=await D.readFile(e);if(t===`.png`){let e=Qe(n);if(e)return{...e,sizes:`${e.width}x${e.height}`}}}catch{}return{sizes:`any`}}function et(e){let t=C(O.join(e.relativeDir,e.fileName)),n=O.extname(e.fileName).toLowerCase();return{path:e.routePath,filePath:t,kind:e.kind,url:Ze(e.relativeDir,e.fileName),contentType:Ye(n),width:e.width,height:e.height,sizes:e.sizes}}async function tt(e){let{appDir:t,relativeDir:n,routePath:r,files:i}=e,a=[],o=async(e,o,s,c)=>{if(c&&r!==`/`)return;let l=Xe(i,o,s);for(let i of l){let o=await $e(O.join(t,n,i));a.push(et({routePath:r,relativeDir:n,fileName:i,kind:e,width:o.width,height:o.height,sizes:o.sizes}))}};return await o(`favicon`,`favicon`,Ge,!0),await o(`icon`,`icon`,Ke,!1),await o(`apple-icon`,`apple-icon`,qe,!1),a}async function nt(e){let{appDir:t,outDir:n,icons:r}=e,i=0;for(let e of r){let r=O.join(t,e.filePath),a=O.join(n,e.url.replace(/^\//,``));await D.mkdir(O.dirname(a),{recursive:!0}),await D.copyFile(r,a),i+=1}return i}function rt(e){return c(e)?typeof e.path==`string`&&typeof e.filePath==`string`&&(e.kind===`favicon`||e.kind===`icon`||e.kind===`apple-icon`)&&typeof e.url==`string`&&typeof e.contentType==`string`&&(e.sizes===void 0||typeof e.sizes==`string`)&&(e.width===void 0||typeof e.width==`number`)&&(e.height===void 0||typeof e.height==`number`):!1}function it(e){let t;try{t=JSON.parse(e)}catch{return[]}return!c(t)||!Array.isArray(t.appIcons)?[]:t.appIcons.filter(rt)}const P={PAGE:`page`,LAYOUT:`layout`,LOADING:`loading`,ERROR:`error`,NOT_FOUND:`not-found`,TEMPLATE:`template`,DEFAULT:`default`,ROUTE:`route`,OG_IMAGE:`opengraph-image`,TWITTER_IMAGE:`twitter-image`,ICON:`icon`,APPLE_ICON:`apple-icon`},at={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},ot=[{pattern:at.OPTIONAL_CATCH_ALL,type:`optional-catch-all`,format:e=>`[[...${e}]]`},{pattern:at.CATCH_ALL,type:`catch-all`,format:e=>`[...${e}]`},{pattern:at.DYNAMIC,type:`dynamic`,format:e=>`[${e}]`}],st=/^\([^/]+\)$/;function ct(e){return st.test(e)}function lt(e){return e?C(e).split(`/`).filter(Boolean).some(ct):!1}function ut(e){for(let t of ot){let n=e.match(t.pattern);if(n)return{type:t.type,param:n[1],format:t.format}}}function dt(e){let t=ut(e);return t?t.format(t.param):e}function ft(e){let t=ut(e);return t?{type:t.type,value:e,param:t.param}:{type:`static`,value:e}}const pt=/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/,mt=/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/,ht=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var gt=class{appDir;extensions;verbose;constructor(e){this.appDir=O.resolve(e.appDir),this.extensions=[...e.extensions??[`.tsx`,`.jsx`,`.ts`,`.js`]],this.verbose=e.verbose??!1}async generateManifest(){this.verbose&&console.warn(`[rari] Router: Scanning app directory: ${this.appDir}`);let e=[],t=[],n=[],r=[],i=[],a=[],o=[],s=[],c=[];await this.scanDirectory(``,e,t,n,r,i,a,o,s,c);for(let o of[t,n,r,i,a,s])this.finalizeGroupEntries(e,o);return this.assertNoDuplicateRoutes(e),this.assertNoDuplicateRoutes(o),this.verbose&&(console.warn(`[rari] Router: Found ${e.length} routes`),console.warn(`[rari] Router: Found ${t.length} layouts`),console.warn(`[rari] Router: Found ${n.length} loading components`),console.warn(`[rari] Router: Found ${r.length} error boundaries`),console.warn(`[rari] Router: Found ${a.length} templates`),console.warn(`[rari] Router: Found ${o.length} API routes`),console.warn(`[rari] Router: Found ${s.length} OG images`),console.warn(`[rari] Router: Found ${c.length} app icons`)),{routes:this.sortRoutes(e),layouts:this.sortLayouts(t),loading:n,errors:r,notFound:i,templates:this.sortTemplates(a),apiRoutes:this.sortApiRoutes(o),ogImages:s,appIcons:c,generated:(/* @__PURE__ */ new Date()).toISOString()}}finalizeGroupEntries(e,t){for(let n=t.length-1;n>=0;n--){let r=t[n],i=C(O.dirname(r.filePath));if(!lt(i))continue;let a=e.filter(e=>{let t=C(O.dirname(e.filePath));return t===i||t.startsWith(`${i}/`)}).map(e=>e.path);if(a.length===0){t.splice(n,1);continue}let o=Array.from(new Set(a)).sort();r.path=o[0],o.length>1&&(r.additionalPaths=o.slice(1))}}assertNoDuplicateRoutes(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.path);if(e!=null&&e!==``)throw Error(`[rari] Route conflict: path '${n.path}' is defined by both '${e}' and '${n.filePath}'.`);t.set(n.path,n.filePath)}}async scanDirectory(e,t,n,r,i,a,o,s,c,l){let u=O.join(this.appDir,e),d;try{d=await D.readdir(u)}catch{return}let f=[],p=[];for(let e of d){let t=O.join(u,e),n=await D.stat(t);n.isDirectory()?this.shouldScanDirectory(e)&&p.push(e):n.isFile()&&f.push(e)}await this.processSpecialFiles(e,f,t,n,r,i,a,o,s,c,l);for(let u of p){let d=e?O.join(e,u):u;await this.scanDirectory(d,t,n,r,i,a,o,s,c,l)}}async processSpecialFiles(e,t,n,r,i,a,o,s,c,l,u){let d=this.pathToRoute(e);this.pushPageRoute(e,t,d,n),this.pushLayoutEntry(e,t,d,r),this.pushNamedSpecial(e,t,d,P.LOADING,i),this.pushNamedSpecial(e,t,d,P.ERROR,a),this.pushNamedSpecial(e,t,d,P.NOT_FOUND,o),this.pushTemplateEntry(e,t,d,s),await this.pushOgImageEntry(e,t,d,l);let f=await tt({appDir:this.appDir,relativeDir:e,routePath:d,files:t});u.push(...f);let p=this.findFile(t,P.ROUTE);if(p!=null&&p!==``){let t=await this.processApiRouteFile(e,p);c.push(t)}}pushPageRoute(e,t,n,r){let i=this.findFile(t,P.PAGE);if(i==null||i===``)return;let a=this.parseRouteSegments(e),o=this.extractParams(a);r.push({path:n,filePath:C(O.join(e,i)),segments:a,params:o,isDynamic:o.length>0})}pushLayoutEntry(e,t,n,r){let i=this.findFile(t,P.LAYOUT);if(i==null||i===``)return;let a=this.getParentPath(e);r.push({path:n,filePath:C(O.join(e,i)),parentPath:a===null?void 0:this.pathToRoute(a)})}pushNamedSpecial(e,t,n,r,i){let a=this.findFile(t,r);a!=null&&a!==``&&i.push({path:n,filePath:C(O.join(e,a))})}pushTemplateEntry(e,t,n,r){let i=this.findFile(t,P.TEMPLATE);if(i==null||i===``)return;let a=this.getParentPath(e);r.push({path:n,filePath:C(O.join(e,i)),parentPath:a===null?void 0:this.pathToRoute(a)})}async pushOgImageEntry(e,t,n,r){let i=this.findFile(t,P.OG_IMAGE);if(i==null||i===``)return;let a=C(O.join(e,i)),o=O.join(this.appDir,a),s,c,l;try{let e=await D.readFile(o,`utf-8`),t=pt.exec(e);t&&(s=Number.parseInt(t[1],10),c=Number.parseInt(t[2],10));let n=mt.exec(e);n&&(l=n[1])}catch{}r.push({path:n,filePath:a,width:s,height:c,contentType:l})}findFile(e,t){for(let n of this.extensions){let r=`${t}${n}`;if(e.includes(r))return r}}pathToRoute(e){return e?`/${C(e).split(`/`).filter(Boolean).filter(e=>!ct(e)).map(dt).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(oe).filter(Boolean).filter(e=>!ct(e)).map(ft):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let t=e.split(oe).filter(Boolean);
|
|
21
21
|
/* v8 ignore stop */
|
|
22
22
|
return t.length===0?null:t.slice(0,-1).join(`/`)}shouldScanDirectory(e){return![`node_modules`,`.git`,`dist`,`build`,`__tests__`,`test`,`tests`,`coverage`].includes(e)&&!e.startsWith(`_`)&&!e.startsWith(`.`)}sortRoutes(e){return e.sort((e,t)=>{let n=e=>{if(!e.isDynamic)return 0;let t=e.segments.some(e=>e.type===`catch-all`);return e.segments.some(e=>e.type===`optional-catch-all`)?3:t?2:1},r=n(e),i=n(t);if(r!==i)return r-i;let a=e.path.split(`/`).length,o=t.path.split(`/`).length;return a===o?e.path.localeCompare(t.path):o-a})}sortApiRoutes(e){return e.sort((e,t)=>{if(!e.isDynamic&&t.isDynamic)return-1;if(e.isDynamic&&!t.isDynamic)return 1;let n=e.path.split(`/`).length,r=t.path.split(`/`).length;
|
|
23
23
|
/* v8 ignore stop */
|
|
24
|
-
return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}sortTemplates(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let t=O.join(this.appDir,e),n=await D.readFile(t,`utf-8`),r=[];for(let e of
|
|
24
|
+
return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}sortTemplates(e){return e.sort((e,t)=>e.path===`/`&&t.path!==`/`?-1:t.path===`/`&&e.path!==`/`?1:e.path.split(`/`).length-t.path.split(`/`).length)}async detectHttpMethods(e){let t=O.join(this.appDir,e),n=await D.readFile(t,`utf-8`),r=[];for(let e of ht){let t=RegExp(`export\\s+(?:async\\s+)?function\\s+${e}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${e}\\s*=`);(t.test(n)||i.test(n))&&r.push(e)}return r}async processApiRouteFile(e,t){let n=C(O.join(e,t)),r=this.pathToRoute(e),i=this.parseRouteSegments(e),a=this.extractParams(i),o=await this.detectHttpMethods(n);return{path:r,filePath:n,segments:i,params:a,isDynamic:a.length>0,methods:o}}};async function _t(e,t={}){return new gt({appDir:e,...t}).generateManifest()}const vt=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,yt=/title\s*:\s*['"]([^'"]+)['"]/,bt=/description\s*:\s*['"]([^'"]+)['"]/,xt=/keywords\s*:\s*\[([\s\S]*?)\]/,St={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function Ct(e){switch(O.basename(e).replace(x,``)){case`page`:return`page`;case`layout`:return`layout`;case`template`:return`template`;case`loading`:return`loading`;case`error`:return`error`;case`not-found`:return`not-found`;case`route`:return`route`;default:return null}}function wt(e){if(!e||e===`/`)return`/`;let t=C(e).split(`/`).filter(e=>!!e&&!ct(e));return t.length>0?`/${t.join(`/`)}`:`/`}function Tt(e,t){let n=O.relative(O.normalize(t),O.normalize(O.dirname(e)));return!n||n===`.`?`/`:wt(`/${C(n).split(`/`).filter(Boolean).join(`/`)}`)}function Et(e,t,n){if(t===`page`)return[e];let r=`${e}${e===`/`?``:`/`}`,i=n.filter(t=>t===e||t.startsWith(r));return i.length>0?i:[e]}function Dt(e){try{let t=vt.exec(e);if(!t)return null;let n=t[1],r={},i=yt.exec(n);i&&(r.title=i[1]);let a=bt.exec(n);a&&(r.description=a[1]);let o=xt.exec(n);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(ee,``)).filter(Boolean));for(let e of[`author`,`viewport`,`themeColor`,`robots`,`openGraph`,`twitter`]){let t=RegExp(`${e}\\s*:\\s*['"]([^'"]+)['"]`,`m`),i=n.match(t);i&&(r[e]=i[1])}return Object.keys(r).length>0?r:null}catch(e){return console.error(`[rari] Router: Failed to extract metadata:`,e),null}}function Ot(e){let t=[];for(let n of[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`]){let r=RegExp(`export\\s+(?:async\\s+)?function\\s+${n}\\s*\\(`),i=RegExp(`export\\s+(?:async\\s+)?(?:const|let|var)\\s+${n}\\s*=`);(r.test(e)||i.test(e))&&t.push(n)}return t}function kt(e){return c(e)&&Array.isArray(e.routes)}async function At(e){try{let t=await fetch(`${Ve()}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`invalidate-api-route`,filePath:e})});if(!t.ok){console.error(`[rari] Router: Failed to invalidate API route cache: ${t.statusText}`);return}let n=p(await t.text());if(n?.success!==!0){let e=typeof n?.error==`string`&&n.error!==``?n.error:`Unknown error`;console.error(`[rari] HMR: Failed to invalidate API route cache: ${e}`)}}catch(e){console.error(`[rari] Router: Failed to notify API route invalidation:`,e)}}function jt(e={}){let t={...St,...e},r=null,a=/* @__PURE__ */ new Map,o=null,s=/* @__PURE__ */ new Set,c=e=>[...e].toSorted().join(`|`),l=async e=>{let n=/* @__PURE__ */ new Set,r=async e=>{try{let i=await D.readdir(e,{withFileTypes:!0});for(let a of i){let i=O.join(e,a.name);a.isDirectory()?await r(i):a.isFile()&&t.extensions.some(e=>a.name.endsWith(e))&&Ct(i)&&n.add(C(i))}}catch{}};return await r(e),n},u=async(e,n=!1)=>{let i=O.resolve(e,t.appDir);try{await D.access(i)}catch{return null}try{let a=await l(i),u=c(a);if(!n&&o===u&&r!=null&&r!==``)return r;let d=await _t(i,{extensions:t.extensions}),f=JSON.stringify(d),p=O.resolve(e,t.outDir);await D.mkdir(p,{recursive:!0});let m=O.join(p,`server`);return await D.mkdir(m,{recursive:!0}),await D.writeFile(O.join(m,`routes.json`),f,`utf-8`),o=u,s.clear(),a.forEach(e=>{s.add(e)}),f}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},d=e=>{let n=O.resolve(e.config.root,t.appDir);e.watcher.on(`all`,(r,i)=>{(async()=>{if(le(i,n)&&t.extensions.some(e=>i.endsWith(e)))try{let t=Ct(i)!==null,a=r===`add`||r===`unlink`,o=t&&!s.has(C(i));(a||o)&&(await u(e.config.root,!0),le(i,n)&&e.ws.send({type:`full-reload`,path:`*`}))}catch(e){console.error(`[rari] Router: Failed to regenerate app routes:`,e)}})()})},f;return Ie({name:`rari-router`,configResolved(e){f=e.root;let t=e.logger.warn.bind(e.logger);e.logger.warn=(e,n)=>{typeof e==`string`&&e.includes(`The above dynamic import cannot be analyzed`)&&e.includes(`packages/rari/dist/`)||t(e,n)}},async writeBundle(){let e=f||k.cwd();r=await u(e,!0)},configureServer(e){d(e)},async handleHotUpdate(e){let{file:n,server:i}=e,o=O.resolve(i.config.root,t.appDir);if(le(n,o)&&t.extensions.some(e=>n.endsWith(e))){let e=Ct(n);if(e){let t=a.get(n);t&&clearTimeout(t);let c=setTimeout(()=>{(async()=>{a.delete(n);let t=C(n),c=!s.has(t),l=r;r=await u(i.config.root,c);let d=l!==r,f=Tt(n,o),m=[f];if(r!=null&&r!==``)try{let e=p(r);e&&kt(e)&&(m=e.routes.map(e=>e.path))}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let h=Et(f,e,m),g,_=!1,v;if(e===`page`||e===`layout`)try{let e=Dt(await D.readFile(n,`utf-8`));e&&(g=e,_=!0)}catch(e){console.error(`[rari] Router: Failed to extract metadata:`,e)}if(e===`route`)try{v=Ot(await D.readFile(n,`utf-8`)),await At(O.relative(o,n))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let ee={fileType:e,filePath:C(O.relative(i.config.root,n)),routePath:f,affectedRoutes:h,manifestUpdated:d,timestamp:Date.now(),metadata:g,metadataChanged:_,methods:v};i.ws.send({type:`custom`,event:`rari:app-router-updated`,data:ee})})()},200);return a.set(n,c),[]}return r=await u(i.config.root),[]}},async closeBundle(){for(let e of a.values())clearTimeout(e);a.clear();let e=f||k.cwd(),r=O.resolve(e,t.outDir,`server`),o=O.join(r,`routes.json`);try{let e=await D.readFile(o,`utf-8`),t=p(e);if(!t||!kt(t))return;let a=t,s=a.routes.flatMap(e=>{if(!e.isDynamic)return[];let t=e.componentId;return t==null||t===``?[]:[{route:e,componentId:t}]}),c=Math.min(8,Math.max(1,s.length)),l=s.map(()=>!1),u=0,d=0;await new Promise(e=>{let t=()=>{for(;d<c&&u<s.length;){let a=u++,{route:o,componentId:c}=s[a],f=O.join(r,`${c}.js`);d++,(async()=>{try{let e=await He(f);if(e==null)return;i(e)?(o.staticParams=e,l[a]=!0):n(c)}catch(e){console.warn(`[rari] Failed to evaluate generateStaticParams for ${c}:`,e)}finally{d--,u>=s.length&&d===0?e():t()}})()}s.length===0&&e()};t()}),l.some(Boolean)&&await D.writeFile(o,JSON.stringify(a),`utf-8`)}catch(e){console.warn(`[rari] Failed to enrich routes manifest with static params:`,e)}}})}const Mt=/return \{\s*name: referenceClosure,\s*method: "POST",\s*encType: "multipart\/form-data",\s*data: data\s*\};/,Nt=/function registerBoundServerReference\(reference, id, bound\) \{\s*knownServerReferences\.has\(reference\) \|\|\s*knownServerReferences\.set\(reference, \{\s*id: id,\s*originalBind: reference\.bind,\s*bound: bound\s*\}\);\s*\}/,Pt=/Object\.defineProperty\(value\._store, "validated", \{\s*configurable: !1,\s*enumerable: !1,\s*writable: !0,\s*value: i\s*\}\);/;function Ft(e,t,n,r){let i=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`),a=[...e.matchAll(i)];if(a.length===0)throw Error(`Failed to patch flight browser client: pattern for ${r} not found. The react-server-dom-webpack sources likely changed shape after a version bump; update the anchors in patch-flight-browser-client.ts.`);if(a.length>1)throw Error(`Failed to patch flight browser client: pattern for ${r} matched more than once. Update the anchors in patch-flight-browser-client.ts to be unambiguous.`);let o=a[0];return e.slice(0,o.index)+n+e.slice(o.index+o[0].length)}function It(e){return Pt.test(e)?(Pt.lastIndex=0,Ft(e,Pt,`Object.defineProperty(value._store, "validated", {
|
|
25
25
|
configurable: !1,
|
|
26
26
|
enumerable: !1,
|
|
27
27
|
writable: !0,
|
|
28
28
|
value: void 0 === i ? 1 : i
|
|
29
|
-
});`,`DEV _store.validated default for production wire`)):e}function
|
|
29
|
+
});`,`DEV _store.validated default for production wire`)):e}function Lt(e){let t=e.indexOf(`var boundCache = new WeakMap();`),n=e.indexOf(`function encodeFormData`),r=t===-1?n===-1?-1:n:t,i=e.indexOf(`function createBoundServerReference`,r);if(r===-1||i===-1)throw Error(`Failed to locate edge client form-action helpers for browser patch`);let a=e.slice(r,i);a.includes(`var boundCache = new WeakMap()`)||(a=`var boundCache = new WeakMap();\n${a}`);let o=/FunctionBind\s*=\s*Function\.prototype\.bind/.test(a),s=/ArraySlice\s*=\s*Array\.prototype\.slice/.test(a);return!o&&!s?a=`var FunctionBind = Function.prototype.bind,\n ArraySlice = Array.prototype.slice;\n${a}`:o?s||(a=`var ArraySlice = Array.prototype.slice;\n${a}`):a=`var FunctionBind = Function.prototype.bind;\n${a}`,Ft(a,Mt,`function resolveRariFormActionUrl() {
|
|
30
30
|
var g = typeof globalThis !== "undefined" ? globalThis : {};
|
|
31
31
|
var rari = g["~rari"];
|
|
32
32
|
if (rari && rari.actionPostUrl)
|
|
@@ -41,20 +41,20 @@ return n===r?e.path.localeCompare(t.path):n-r})}sortLayouts(e){return e.sort((e,
|
|
|
41
41
|
encType: "multipart/form-data",
|
|
42
42
|
action: resolveRariFormActionUrl(),
|
|
43
43
|
data: data
|
|
44
|
-
};`,`edge $$FORM_ACTION return block`)}function zt(e,t){let n=Rt(t);return Lt(It(e,Pt,n,`browser registerBoundServerReference`))}const Bt=[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,`react-dom/client`];function Vt(e){return u(e)&&typeof e.find==`string`&&typeof e.replacement==`string`}function Ht(e,t=new Set(Bt)){let n={},r=e.resolve?.alias;if(Array.isArray(r))for(let e of r)Vt(e)&&!t.has(e.find)&&(n[e.find]=e.replacement);else if(u(r))for(let[e,i]of Object.entries(r))typeof i==`string`&&!t.has(e)&&(n[e]=i);return n}function Ut(e){return{projectRoot:e.root,outDir:O.resolve(e.root,e.build.outDir),assetsDir:C(e.build.assetsDir)}}function P(e,t=8){return Ae(`sha256`).update(e).digest(`hex`).slice(0,t)}function Wt(e,t=k.cwd()){let n=O.isAbsolute(e)?e:O.resolve(t,e),r=O.relative(t,n);return O.isAbsolute(r)?w(n):w(r)}function Gt(e){return e.replace(S,``).replace(b,`_`).replace(ee,``)}function Kt(e,t=k.cwd()){let n=Wt(e,t);return`${Gt(n)}_${P(n)}`}const qt=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`typeof`,`instanceof`,`new`,`delete`,`void`,`in`,`of`]),Jt=8232,Yt=8233;function Xt(e){return e===32||e===9||e===13||e===10||e===Jt||e===Yt||e===65279}function Zt(e){return e===13||e===10||e===Jt||e===Yt}function F(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function Qt(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function $t(e,t,n){for(;t<n&&Xt(e.charCodeAt(t));)t++;return t}function I(e,t,n){for(;t<n;){let r=$t(e,t,n);if(r!==t){t=r;continue}let i=e.charCodeAt(t);if(i===47&&e.charCodeAt(t+1)===47){t=en(e,t,n);continue}if(i===47&&e.charCodeAt(t+1)===42){t=tn(e,t,n);continue}break}return t}function en(e,t,n){for(;t<n&&!Zt(e.charCodeAt(t));)t++;return t}function tn(e,t,n){for(t+=2;t<n-1&&(e.charCodeAt(t)!==42||e.charCodeAt(t+1)!==47);)t++;return t+2}function L(e,t,n,r){for(t++;t<n;){let n=e.charCodeAt(t);if(n===92){t+=2;continue}if(n===r)return t+1;t++}return t}function nn(e,t,n){for(;t<n;){let n=e.charCodeAt(t);if(F(n)||n===46||n===45)t++;else break}return t}function rn(e,t,n){t++;let r=1;for(;t<n&&r>0;){let i=e.charCodeAt(t);if(i===39||i===34||i===96){t=L(e,t,n,i);continue}i===123&&r++,i===125&&r--,t++}return t}function an(e,t,n,r){let i=e.charCodeAt(t+1);if(i!==47&&i!==46&&i!==62&&!Qt(i))return{i:t+1,depth:r};let a=r;return i===47?(a--,t++):i!==33&&a++,t++,{i:nn(e,t,n),depth:a}}function on(e,t,n,r,i){let a=e.charCodeAt(t);return a===39||a===34||a===96?{i:L(e,t,n,a),depth:r}:a===123?{i:rn(e,t,n),depth:r}:a===47&&e.charCodeAt(t+1)===62?{i:t+2,depth:r-1}:a===62?{i:t+1,depth:i?r-1:r}:a===60?an(e,t,n,r):{i:t+1,depth:r}}function sn(e,t,n){t++;let r=e.charCodeAt(t)===47;r&&t++,t=nn(e,t,n);let i=+!r;for(;t<n&&i>0;)({i:t,depth:i}=on(e,t,n,i,r));return t}function cn(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function R(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length,a=i<e.length?e.charCodeAt(i):-1;return!(r!==-1&&F(r)||a!==-1&&F(a))}function ln(e,t,n){let r=I(e,t,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i!==39&&i!==34)return null;let a=r+1,o=L(e,r,n,i);return o<=a?null:{source:e.slice(a,o-1),end:o}}function un(e,t,n){for(t++;t<n&&F(e.charCodeAt(t));)t++;for(;t<n&&e.charCodeAt(t)===46;)for(t++;t<n&&F(e.charCodeAt(t));)t++;return t}function dn(e,t){return e===123||e===40||e===91?t+1:e===125||e===41||e===93?Math.max(0,t-1):t}function fn(e,t,n){let r=0;for(;t<n&&(t=I(e,t,n),!(t>=n));){let i=e.charCodeAt(t);if(r===0&&R(e,t,`from`)){let r=ln(e,t+4,n);if(r)return{sources:[r.source],end:r.end};break}if(i===39||i===34||i===96){t=L(e,t,n,i);continue}r=dn(i,r),t++}return{sources:[],end:t}}function pn(e,t,n){if(!R(e,t,`import`))return{sources:[],end:t+6};let r=I(e,t+6,n);if(R(e,r,`type`)&&(r=I(e,r+4,n)),e.charCodeAt(r)===46)return{sources:[],end:un(e,r,n)};if(e.charCodeAt(r)===40){r++;let t=ln(e,r,n);return t?{sources:[t.source],end:t.end}:{sources:[],end:r}}let i=ln(e,r,n);return i?{sources:[i.source],end:i.end}:fn(e,r,n)}function mn(e,t){return e.charCodeAt(t)===101&&e.charCodeAt(t+1)===120&&e.charCodeAt(t+2)===112&&e.charCodeAt(t+3)===111&&e.charCodeAt(t+4)===114&&e.charCodeAt(t+5)===116}function hn(e,t){return e.charCodeAt(t)===100&&e.charCodeAt(t+1)===101&&e.charCodeAt(t+2)===102&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===117&&e.charCodeAt(t+5)===108&&e.charCodeAt(t+6)===116}function gn(e,t,n){e.sawFirstDirective||(e.sawFirstDirective=!0,e.topLevelUseClient=t,e.topLevelUseServer=n),t&&(e.directives.hasUseClient=!0),n&&(e.directives.hasUseServer=!0)}function _n(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(Xt(t)&&!Zt(t)){r++;continue}if(Zt(t)||t===59)return{stillDirective:!0,nextI:r+1,endDirectivesPhase:!1};if(t===47&&e.charCodeAt(r+1)===47){r=en(e,r,n);continue}if(t===47&&e.charCodeAt(r+1)===42){r=tn(e,r,n);continue}return{stillDirective:!1,nextI:r,endDirectivesPhase:!0}}return{stillDirective:!0,nextI:t,endDirectivesPhase:!0}}function vn(e,t,n,r){if(!r.directivesPhase)return null;let i=e.charCodeAt(t);if(i!==39&&i!==34)return null;let a=t+1,o=L(e,t,n,i);if(o<=a)return r.directivesPhase=!1,t+1;let s=o-1-a;gn(r,s===10&&cn(e,a,`use client`),s===10&&cn(e,a,`use server`));let c=_n(e,o,n);return c.stillDirective?c.nextI:(c.endDirectivesPhase&&(r.directivesPhase=!1),r.directivesPhase?o:c.nextI)}function yn(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t);return Xt(r)||r===123?!0:r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function bn(e){e.hasDefaultExportResult=!0,e.hasComponentExportResult=!0}function xn(e,t,n,r){if(e.charCodeAt(t)!==97||e.charCodeAt(t+1)!==115)return{k:t,hasAlias:!1};let i=t+2;if(i>=n||F(e.charCodeAt(i)))return{k:t,hasAlias:!0};t=I(e,i,n);let a=t;for(;t<n&&F(e.charCodeAt(t));)t++;return t-a===7&&hn(e,a)&&bn(r),{k:t,hasAlias:!0}}function Sn(e,t,n,r){let i=t;for(;t<n&&F(e.charCodeAt(t));)t++;let a=t-i;if(a===0)return null;t=I(e,t,n);let o=xn(e,t,n,r);return t=o.k,!o.hasAlias&&a===7&&hn(e,i)&&bn(r),e.charCodeAt(t)===44?t+1:e.charCodeAt(t)===125?t:t+1}function Cn(e,t,n,r){let i=t+1;for(;i<n&&(i=I(e,i,n),e.charCodeAt(i)!==125);){let t=Sn(e,i,n,r);if(t===null)break;i=t}}function wn(e,t,n,r){if(!mn(e,t))return null;let i=t+6;if(!yn(e,i,n))return null;let a=I(e,i,n);if(hn(e,a)){bn(r);let t=a+7;if(t>=n||!F(e.charCodeAt(t)))return i}return e.charCodeAt(a)===123?(Cn(e,a,n,r),null):((R(e,a,`async`)||R(e,a,`function`)||R(e,a,`class`))&&(r.hasComponentExportResult=!0),null)}function Tn(e,t,n,r){let i=vn(e,t,n,r);if(i!==null)return i;let a=V(e,t,n);if(a!==-1)return r.directivesPhase&&!sr(e,t)&&(r.directivesPhase=!1),a;if(r.directivesPhase=!1,R(e,t,`import`)){let i=pn(e,t,n);for(let e of i.sources)r.importSources.push(e);return i.end}let o=wn(e,t,n,r);return o===null?t+1:o}function z(e){let t={directives:{hasUseClient:!1,hasUseServer:!1},topLevelUseClient:!1,topLevelUseServer:!1,hasDefaultExportResult:!1,hasComponentExportResult:!1,importSources:[],directivesPhase:!0,sawFirstDirective:!1},n=0,r=e.length;for(;n<r;)n=Tn(e,n,r,t);return{directives:t.directives,topLevelUseClient:t.topLevelUseClient,topLevelUseServer:t.topLevelUseServer,hasDefaultExport:t.hasDefaultExportResult,hasComponentExport:t.hasComponentExportResult,importSources:[...new Set(t.importSources)]}}function B(e,t,n){if(t>=n||!Qt(e.charCodeAt(t)))return null;let r=t+1;for(;r<n&&F(e.charCodeAt(r));)r++;return{name:e.slice(t,r),end:r}}function En(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}if(t===59)return r+1;break}return t}function Dn(e,t,n){if(!R(e,t,`type`))return null;let r=I(e,t+4,n),i=e.charCodeAt(r);return(i===39||i===34||B(e,r,n)!==null)&&!R(e,r,`as`)?r:null}function On(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34){let i=L(e,t,n,r);return{imported:e.slice(t+1,i-1),end:i}}let i=B(e,t,n);return i?{imported:i.name,end:i.end}:null}function kn(e,t,n){let r=Dn(e,t,n),i=r!==null;r!==null&&(t=r);let a=On(e,t,n);if(!a)return null;let o=a.imported;t=I(e,a.end,n);let s=o;if(R(e,t,`as`)){t=I(e,t+2,n);let r=B(e,t,n);if(!r)return null;s=r.name,t=I(e,r.end,n)}return{specifier:{imported:o,local:s,typeOnly:i},end:t}}function An(e,t,n){let r=[],i=t+1;for(;;){if(i=I(e,i,n),i>=n)return null;if(e.charCodeAt(i)===125)return{named:r,end:i+1};let t=kn(e,i,n);if(!t)return null;r.push(t.specifier),i=t.end;let a=e.charCodeAt(i);if(a===44){i++;continue}return a===125?{named:r,end:i+1}:null}}function jn(e,t,n,r){let i=e.charCodeAt(n);if(i!==39&&i!==34)return null;let a=ln(e,n,r);return a?{start:t,end:En(e,a.end,r),source:a.source,typeOnly:!1,sideEffectOnly:!0,defaultBinding:null,namespaceBinding:null,named:[]}:null}function Mn(e,t,n){if(!R(e,t,`type`))return{typeOnly:!1,pos:t};let r=I(e,t+4,n);return!R(e,r,`from`)&&e.charCodeAt(r)!==44?{typeOnly:!0,pos:r}:{typeOnly:!1,pos:t}}function Nn(e,t,n){let r=null,i=null,a=[],o=e.charCodeAt(t);if(o!==123&&o!==42){let i=B(e,t,n);if(!i)return null;r=i.name,t=I(e,i.end,n),e.charCodeAt(t)===44?(t=I(e,t+1,n),o=e.charCodeAt(t)):o=-1}if(o===42){if(t=I(e,t+1,n),!R(e,t,`as`))return null;t=I(e,t+2,n);let r=B(e,t,n);if(!r)return null;i=r.name,t=r.end}else if(o===123){let r=An(e,t,n);if(!r)return null;a=r.named,t=r.end}return{defaultBinding:r,namespaceBinding:i,named:a,pos:t}}function Pn(e,t,n){let r=I(e,t+6,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i===40||i===46)return null;let a=jn(e,t,r,n);if(a)return a;let o=Mn(e,r,n);r=o.pos;let s=Nn(e,r,n);if(!s||(r=I(e,s.pos,n),!R(e,r,`from`)))return null;let c=ln(e,r+4,n);return c?{start:t,end:En(e,c.end,n),source:c.source,typeOnly:o.typeOnly,sideEffectOnly:!1,defaultBinding:s.defaultBinding,namespaceBinding:s.namespaceBinding,named:s.named}:null}function Fn(e){let t=[],n=0,r=e.length;for(;n<r;){let i=V(e,n,r);if(i!==-1){n=i;continue}if(R(e,n,`import`)){let i=Pn(e,n,r);if(i){t.push(i),n=i.end;continue}n+=6;continue}n++}return t}function In(e,t,n,r){let i=I(e,t+1,n);if(R(e,i,`as`)){i=I(e,i+2,n);let t=B(e,i,n);return t&&r.add(t.name),t?.end??i+1}return t+1}function Ln(e,t,n,r){let i=Hn(e,t,n),a=e.slice(t+1,i-1);for(let e of a.split(`,`)){let t=e.trim();if(!t||t.startsWith(`type `)||t.startsWith(`typeof `))continue;let n=(t.split(/\s+as\s+/).at(-1)??``).trim();n!==``&&n!==`type`&&r.add(n)}return i}function Rn(e,t){return R(e,t,`function`)?8:R(e,t,`class`)||R(e,t,`const`)?5:3}function zn(e,t,n,r){if(R(e,t,`async`)&&(t=I(e,t+5,n)),!R(e,t,`function`)&&!R(e,t,`class`)&&!R(e,t,`const`)&&!R(e,t,`let`)&&!R(e,t,`var`))return null;let i=Rn(e,t),a=I(e,t+i,n);e.charCodeAt(a)===42&&(a=I(e,a+1,n));let o=B(e,a,n);return o&&r.add(o.name),o?.end??a+1}function Bn(e,t,n,r){let i=I(e,t+6,n);if(R(e,i,`type`)||R(e,i,`interface`))return i+1;if(e.charCodeAt(i)===42)return In(e,i,n,r);if(R(e,i,`default`))return r.add(`default`),i+7;if(e.charCodeAt(i)===123)return Ln(e,i,n,r);let a=zn(e,i,n,r);return a===null?t+1:a}function Vn(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r;){let i=V(e,n,r);if(i!==-1){n=i;continue}if(!R(e,n,`export`)){n++;continue}n=Bn(e,n,r,t)}return[...t]}function Hn(e,t,n){let r=t,i=0;for(;r<n;){let t=Un(e,r,n);if(t!=null){r=t;continue}let a=e.charCodeAt(r);if(a===123){i++,r++;continue}if(a===125){if(i--,r++,i===0)return r;continue}r++}return r}function Un(e,t,n){let r=e.charCodeAt(t);return r===39||r===34||r===96?L(e,t,n,r):r===47&&e.charCodeAt(t+1)===47?en(e,t,n):r===47&&e.charCodeAt(t+1)===42?tn(e,t,n):null}function Wn(e){return z(e).topLevelUseServer}function Gn(e,t,n){let r=e.charCodeAt(t);if(r!==39&&r!==34)return null;let i=t+1,a=L(e,t,n,r);if(a<=i)return null;let o=a-1-i,s=o===10&&cn(e,i,`use client`),c=o===10&&cn(e,i,`use server`);return!s&&!c?null:{kind:s?`use client`:`use server`,term:_n(e,a,n)}}function Kn(e,t){return!e.stillDirective&&e.endDirectivesPhase||!e.stillDirective?!1:t}function qn(e,t){let n=0,r=e.length,i=!0;for(;n<r&&i&&(n=I(e,n,r),!(n>=r));){let a=Gn(e,n,r);if(a==null)break;if(i=Kn(a.term,i),a.kind===t&&a.term.stillDirective)return e.slice(0,n)+e.slice(a.term.nextI);if(!a.term.stillDirective)break;n=a.term.nextI}return e}function Jn(e){return z(e).hasDefaultExport}function Yn(e){return e===40||e===91||e===123||e===44||e===59||e===61||e===58||e===63||e===33||e===43||e===45||e===42||e===37||e===38||e===124||e===94||e===126||e===60||e===62}function Xn(e,t){for(t-=2;t>=1;){if(e.charCodeAt(t)===42&&e.charCodeAt(t-1)===47)return t-2;t--}return-1}function Zn(e,t){let n=t;for(;n>=0&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13;)n--;let r=n+1;for(;r<t&&(e.charCodeAt(r)===32||e.charCodeAt(r)===9);)r++;return r<t&&e.charCodeAt(r)===47&&e.charCodeAt(r+1)===47?r-1:null}function Qn(e,t){let n=e.charCodeAt(t);return Xt(n)?t-1:t>=1&&n===47&&e.charCodeAt(t-1)===42?Xn(e,t):t>=1&&n===47&&e.charCodeAt(t-1)===47?t-2:Zn(e,t)}function $n(e,t){let n=t-1;for(;n>=0;){let t=Qn(e,n);if(t!==null){if(n=t,n<0)return;continue}break}if(n<0||!F(e.charCodeAt(n)))return;let r=n;for(;n>=0&&F(e.charCodeAt(n));)n--;return e.slice(n+1,r+1)}function er(e,t){let n=t-1;for(;n>=0;){let t=Qn(e,n);if(t!==null){if(n=t,n<0)return-1;continue}return e.charCodeAt(n)}return-1}function tr(e,t){let n=er(e,t);if(n===-1||Yn(n))return!0;let r=$n(e,t);return r!=null&&r!==``&&qt.has(r)}const nr=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`default`,`else`,`do`,`typeof`,`void`,`yield`,`await`,`delete`]);function rr(e,t){let n=er(e,t);if(n===-1)return!0;if(F(n)||n>=48&&n<=57){let n=$n(e,t);return n!=null&&n!==``&&nr.has(n)}return n!==41&&n!==93&&n!==125}function ir(e,t,n){if(!rr(e,t))return-1;let r=e.charCodeAt(t+1);if(r!==47&&r!==46&&r!==62&&!Qt(r))return-1;let i=sn(e,t,n);return i<n&&e.charCodeAt(i)===62&&i++,i>t&&e.charCodeAt(i-1)===62?i:-1}function ar(e,t,n,r){let i=e.charCodeAt(t);if(i===92)return{i:t+2,inCharClass:r,done:!1};if(r)return{i:t+1,inCharClass:i!==93,done:!1};if(i===91)return{i:t+1,inCharClass:!0,done:!1};if(i===47){for(t++;t<n&&F(e.charCodeAt(t));)t++;return{i:t,inCharClass:r,done:!0}}return Zt(i)?{i:t,inCharClass:r,done:!0}:{i:t+1,inCharClass:r,done:!1}}function or(e,t,n){t++;let r=!1;for(;t<n;){let i=ar(e,t,n,r);if(t=i.i,r=i.inCharClass,i.done)return t}return t}function V(e,t,n){if(t>=n)return-1;let r=e.charCodeAt(t);if(Xt(r))return t+1;if(r===47&&e.charCodeAt(t+1)===47)return en(e,t,n);if(r===47&&e.charCodeAt(t+1)===42)return tn(e,t,n);if(r===39||r===34||r===96)return L(e,t,n,r);if(r===47&&e.charCodeAt(t+1)!==47&&e.charCodeAt(t+1)!==42&&tr(e,t))return or(e,t,n);if(r===60){let r=ir(e,t,n);if(r!==-1)return r}return-1}function sr(e,t){let n=e.charCodeAt(t);return Xt(n)?!0:n===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function cr(e,t,n){let r=t;if(R(e,r,`async`)){let t=I(e,r+5,n);R(e,t,`function`)&&(r=t)}if(!R(e,r,`function`)&&!R(e,r,`class`))return null;let i=R(e,r,`function`)?8:5,a=I(e,r+i,n);e.charCodeAt(a)===42&&(a=I(e,a+1,n));let o=B(e,a,n);return o?o.name:null}function lr(e){let t=e.length,n=0;for(;n<t;){let r=V(e,n,t);if(r!==-1){n=r;continue}if(!R(e,n,`export`)){n++;continue}let i=I(e,n+6,t);if(!R(e,i,`default`)){n++;continue}let a=I(e,i+7,t),o=cr(e,a,t),s=yr(e,a,t);return{exportStart:n,valueStart:a,valueEnd:s,statementEnd:En(e,s,t),bindingName:o}}return null}function ur(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t),i=t+1<n?e.charCodeAt(t+1):-1;return r===46||r===63&&i===46||r===40||r===91||r===96||r===61&&i===62||r===43||r===45||r===42||r===47||r===37||r===38||r===124||r===94||r===60||r===62||r===61||r===33||r===63||r===58||r===44||r===126||R(e,t,`instanceof`)||R(e,t,`in`)||R(e,t,`of`)||R(e,t,`as`)}const dr=/* @__PURE__ */ new Set([`typeof`,`void`,`delete`,`await`,`yield`,`new`]);function fr(e,t,n){let r=e.charCodeAt(t.i);return r===39||r===34||r===96?(t.i=L(e,t.i,n,r),t.lastCanTerminate=!0,!0):r===47&&e.charCodeAt(t.i+1)===47?(t.i=en(e,t.i,n),!0):r===47&&e.charCodeAt(t.i+1)===42?(t.i=tn(e,t.i,n),!0):r===47&&e.charCodeAt(t.i+1)!==47&&e.charCodeAt(t.i+1)!==42&&tr(e,t.i)?(t.i=or(e,t.i,n),t.lastCanTerminate=!0,!0):!1}function pr(e,t,n){if(e.charCodeAt(t.i)!==60||t.paren!==0||t.brace!==0||t.bracket!==0)return!1;let r=ir(e,t.i,n);return r!==-1&&(t.i=r,t.lastCanTerminate=!0,!0)}function mr(e,t){return e===40?(t.paren++,t.lastCanTerminate=!1,t.i++,!1):e===41?(t.paren=Math.max(0,t.paren-1),t.lastCanTerminate=!0,t.i++,!1):e===123?(t.brace++,t.lastCanTerminate=!1,t.i++,!1):e===125?(t.brace=Math.max(0,t.brace-1),t.lastCanTerminate=!0,t.i++,t.paren===0&&t.brace===0&&t.bracket===0):e===91?(t.bracket++,t.lastCanTerminate=!1,t.i++,!1):e===93?(t.bracket=Math.max(0,t.bracket-1),t.lastCanTerminate=!0,t.i++,!1):null}function hr(e,t,n,r){if(t.paren!==0||t.brace!==0||t.bracket!==0)return null;if(r===59)return t.i;if(!Zt(r))return null;let i=I(e,t.i+1,n);return!t.lastCanTerminate||ur(e,i,n)?(t.i++,-1):t.i}function gr(e,t,n){for(t++;t<n;){let n=e.charCodeAt(t);if(n>=48&&n<=57||n===46||n===110||n===101||n===69){t++;continue}break}return t}function _r(e){return e===46||e===44||e===58||e===63||e===61||e===43||e===45||e===42||e===47||e===37||e===38||e===124||e===94||e===33||e===126||e===60||e===62}function vr(e,t,n){let r=e.charCodeAt(t.i);if(Qt(r)){let r=B(e,t.i,n);if(r){t.lastCanTerminate=!dr.has(r.name),t.i=r.end;return}}if(r>=48&&r<=57){t.lastCanTerminate=!0,t.i=gr(e,t.i,n);return}if(r===61&&e.charCodeAt(t.i+1)===62){t.lastCanTerminate=!1,t.i+=2;return}if(_r(r)){t.lastCanTerminate=!1,t.i++;return}t.i++}function yr(e,t,n){let r={i:t,paren:0,brace:0,bracket:0,lastCanTerminate:!1};for(;r.i<n;){if(fr(e,r,n)||pr(e,r,n))continue;let t=e.charCodeAt(r.i),i=mr(t,r);if(i===!0)return r.i;if(i===!1)continue;let a=hr(e,r,n,t);if(a!==-1){if(a!==null)return a;vr(e,r,n)}}return r.i}function br(e,t){let n=lr(e);if(n==null||n.bindingName!=null)return null;let r=`const ${t} = ${e.slice(n.valueStart,n.valueEnd).trimEnd()};\nexport default ${t}${e.slice(n.statementEnd)}`;return e.slice(0,n.exportStart)+r}const xr=/* @__PURE__ */ new Set([`node_modules`,`.git`,`.cache`,`dist`]);function Sr(e,t){let n=/* @__PURE__ */ new Set,r=e=>{if(!E.existsSync(e))return;let i=E.readdirSync(e,{withFileTypes:!0});for(let a of i){let i=O.join(e,a.name);if(a.isDirectory()){if(xr.has(a.name))continue;r(i)}else if(a.isFile()&&S.test(a.name)){if(n.has(i))continue;n.add(i),t(i)}}};for(let t of e)t&&E.existsSync(t)&&r(t)}function Cr(e){let t=[];return Sr(e,e=>{t.push(e)}),t}function wr(e,t=[]){let n=[e],r=O.resolve(e);for(let e of t){if(!e)continue;let t=O.resolve(e);if(t===r)continue;let i=O.relative(r,t);if(i!==``&&(i.startsWith(`..`)||O.isAbsolute(i)))try{E.statSync(e).isDirectory()&&n.push(e)}catch{}}return n}const Tr=new Set(Ce);function Er(e){return Tr.has(e)}function Dr(e){for(let t of e.importSources)if(t.startsWith(`node:`)||Er(t))return!0;return!1}function Or(e,t=Tr){let n=[];for(let r of e)!r.startsWith(`.`)&&!r.startsWith(`/`)&&!r.startsWith(`@/`)&&!r.startsWith(`node:`)&&!t.has(r)&&n.push(r);return[...new Set(n)]}function kr(e){let t=[];for(let n of e)(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`@/`))&&t.push(n);return t}function H(e){try{return E.realpathSync(e)}catch{return O.resolve(e)}}function Ar(e,t){e.delete(t);try{e.delete(E.realpathSync(t))}catch{e.delete(O.resolve(t))}}function jr(e,t){let n=[];for(let r of Cr(e))try{t.get(r).directives.hasUseClient&&n.push(r)}catch{}return n}var Mr=class{cache=/* @__PURE__ */ new Map;get(e,t){let n=H(e),r=this.cache.get(n);if(t!==void 0){if(r?.source===t)return r.analysis}else if(r){let e=this.readMtimeMs(n);if(e>=0&&r.mtimeMs===e)return r.analysis}t??=E.readFileSync(n,`utf-8`);let i=this.readMtimeMs(n),a=z(t);return this.cache.set(n,{mtimeMs:i,source:t,analysis:a}),a}getSource(e){return this.get(e),this.cache.get(H(e)).source}invalidate(e){Ar(this.cache,e)}clear(){this.cache.clear()}readMtimeMs(e){try{return E.statSync(e).mtimeMs}catch{return-1}}};const Nr=`virtual:rari-entry-client`,Pr=/^layout\.(?:tsx|ts|jsx|js)$/,Fr=/\.css(?:\?.*)?$/,Ir=/* @__PURE__ */ new Set;function Lr(){Ir.clear()}function Rr(e){let t=e.trim();t!==``&&Ir.add(t)}function zr(){return[...Ir]}function Br(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Fr.test(i))return null;if(i.startsWith(`./`)||i.startsWith(`../`)){let e=O.resolve(O.dirname(t),i);return!E.existsSync(e)||!E.statSync(e).isFile()?null:e}let a=T(i,r,n);return a!=null&&a!==``&&E.existsSync(a)&&E.statSync(a).isFile()?a:i}function Vr(e,t,n,r){if(E.existsSync(e))for(let i of E.readdirSync(e,{withFileTypes:!0})){let a=O.join(e,i.name);if(i.isDirectory()){Vr(a,t,n,r);continue}if(!i.isFile()||!Pr.test(i.name))continue;let o=E.readFileSync(a,`utf-8`);for(let e of Fn(o)){let i=Br(e.source,a,t,n);i!=null&&r.add(i)}}}function Hr(e,t={}){let n=/* @__PURE__ */ new Set;return Vr(O.join(e,`src`,`app`),e,t,n),n}function Ur(e,t){if(!O.isAbsolute(e))return e.startsWith(`/`)?e:`/${e}`;let n=w(O.relative(t,e));return n.startsWith(`..`)||O.isAbsolute(n)?`/@fs/${e}`:`/${n}`}function Wr(e,t={}){return[...Hr(e,t)].sort().map(t=>Ur(t,e))}function Gr(e,t){if(!O.isAbsolute(e))return e;let n=w(O.relative(t,e));return n.startsWith(`..`)||O.isAbsolute(n)?e:`/${n}`}function Kr(e,t={}){return[...Hr(e,t)].sort().map(t=>`import ${JSON.stringify(Gr(t,e))};`).join(`
|
|
45
|
-
`)}function
|
|
46
|
-
`)}\n`:``}function
|
|
47
|
-
`).length),r=Array.from({length:n},(e,t)=>t);return{version:3,file:e,sources:[e],sourcesContent:[t],names:[],mappings:
|
|
44
|
+
};`,`edge $$FORM_ACTION return block`)}function Rt(e,t){let n=Lt(t);return It(Ft(e,Nt,n,`browser registerBoundServerReference`))}const zt=[`react`,`react-dom`,`react/jsx-runtime`,`react/jsx-dev-runtime`,`react/compiler-runtime`,`react-dom/client`];function Bt(e){return c(e)&&typeof e.find==`string`&&typeof e.replacement==`string`}function Vt(e,t=new Set(zt)){let n={},r=e.resolve?.alias;if(Array.isArray(r))for(let e of r)Bt(e)&&!t.has(e.find)&&(n[e.find]=e.replacement);else if(c(r))for(let[e,i]of Object.entries(r))typeof i==`string`&&!t.has(e)&&(n[e]=i);return n}function Ht(e){return{projectRoot:e.root,outDir:O.resolve(e.root,e.build.outDir),assetsDir:S(e.build.assetsDir)}}function F(e,t=8){return ke(`sha256`).update(e).digest(`hex`).slice(0,t)}function Ut(e,t=k.cwd()){let n=O.isAbsolute(e)?e:O.resolve(t,e),r=O.relative(t,n);return O.isAbsolute(r)?C(n):C(r)}function Wt(e){return e.replace(x,``).replace(re,`_`).replace(y,``)}function Gt(e,t=k.cwd()){let n=Ut(e,t);return`${Wt(n)}_${F(n)}`}const Kt=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`typeof`,`instanceof`,`new`,`delete`,`void`,`in`,`of`]),qt=8232,Jt=8233;function I(e){return e===32||e===9||e===13||e===10||e===qt||e===Jt||e===65279}function Yt(e){return e===13||e===10||e===qt||e===Jt}function L(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===95||e===36}function Xt(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Zt(e,t,n){for(;t<n&&I(e.charCodeAt(t));)t++;return t}function R(e,t,n){for(;t<n;){let r=Zt(e,t,n);if(r!==t){t=r;continue}let i=e.charCodeAt(t);if(i===47&&e.charCodeAt(t+1)===47){t=Qt(e,t,n);continue}if(i===47&&e.charCodeAt(t+1)===42){t=$t(e,t,n);continue}break}return t}function Qt(e,t,n){for(;t<n&&!Yt(e.charCodeAt(t));)t++;return t}function $t(e,t,n){for(t+=2;t<n-1&&(e.charCodeAt(t)!==42||e.charCodeAt(t+1)!==47);)t++;return t+2}function z(e,t,n,r){for(t++;t<n;){let n=e.charCodeAt(t);if(n===92){t+=2;continue}if(n===r)return t+1;t++}return t}function en(e,t,n){for(;t<n;){let n=e.charCodeAt(t);if(L(n)||n===46||n===45)t++;else break}return t}function tn(e,t,n){t++;let r=1;for(;t<n&&r>0;){let i=e.charCodeAt(t);if(i===39||i===34||i===96){t=z(e,t,n,i);continue}i===123&&r++,i===125&&r--,t++}return t}function nn(e,t,n,r){let i=e.charCodeAt(t+1);if(i!==47&&i!==46&&i!==62&&!Xt(i))return{i:t+1,depth:r};let a=r;return i===47?(a--,t++):i!==33&&a++,t++,{i:en(e,t,n),depth:a}}function rn(e,t,n,r,i){let a=e.charCodeAt(t);return a===39||a===34||a===96?{i:z(e,t,n,a),depth:r}:a===123?{i:tn(e,t,n),depth:r}:a===47&&e.charCodeAt(t+1)===62?{i:t+2,depth:r-1}:a===62?{i:t+1,depth:i?r-1:r}:a===60?nn(e,t,n,r):{i:t+1,depth:r}}function an(e,t,n){t++;let r=e.charCodeAt(t)===47;r&&t++,t=en(e,t,n);let i=+!r;for(;t<n&&i>0;)({i:t,depth:i}=rn(e,t,n,i,r));return t}function on(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function B(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length,a=i<e.length?e.charCodeAt(i):-1;return!(r!==-1&&L(r)||a!==-1&&L(a))}function sn(e,t,n){let r=R(e,t,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i!==39&&i!==34)return null;let a=r+1,o=z(e,r,n,i);return o<=a?null:{source:e.slice(a,o-1),end:o}}function cn(e,t,n){for(t++;t<n&&L(e.charCodeAt(t));)t++;for(;t<n&&e.charCodeAt(t)===46;)for(t++;t<n&&L(e.charCodeAt(t));)t++;return t}function ln(e,t){return e===123||e===40||e===91?t+1:e===125||e===41||e===93?Math.max(0,t-1):t}function un(e,t,n){let r=0;for(;t<n&&(t=R(e,t,n),!(t>=n));){let i=e.charCodeAt(t);if(r===0&&B(e,t,`from`)){let r=sn(e,t+4,n);if(r)return{sources:[r.source],end:r.end};break}if(i===39||i===34||i===96){t=z(e,t,n,i);continue}r=ln(i,r),t++}return{sources:[],end:t}}function dn(e,t,n){if(!B(e,t,`import`))return{sources:[],end:t+6};let r=R(e,t+6,n);if(B(e,r,`type`)&&(r=R(e,r+4,n)),e.charCodeAt(r)===46)return{sources:[],end:cn(e,r,n)};if(e.charCodeAt(r)===40){r++;let t=sn(e,r,n);return t?{sources:[t.source],end:t.end}:{sources:[],end:r}}let i=sn(e,r,n);return i?{sources:[i.source],end:i.end}:un(e,r,n)}function fn(e,t){return e.charCodeAt(t)===101&&e.charCodeAt(t+1)===120&&e.charCodeAt(t+2)===112&&e.charCodeAt(t+3)===111&&e.charCodeAt(t+4)===114&&e.charCodeAt(t+5)===116}function pn(e,t){return e.charCodeAt(t)===100&&e.charCodeAt(t+1)===101&&e.charCodeAt(t+2)===102&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===117&&e.charCodeAt(t+5)===108&&e.charCodeAt(t+6)===116}function mn(e,t,n){e.sawFirstDirective||(e.sawFirstDirective=!0,e.topLevelUseClient=t,e.topLevelUseServer=n),t&&(e.directives.hasUseClient=!0),n&&(e.directives.hasUseServer=!0)}function hn(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(I(t)&&!Yt(t)){r++;continue}if(Yt(t)||t===59)return{stillDirective:!0,nextI:r+1,endDirectivesPhase:!1};if(t===47&&e.charCodeAt(r+1)===47){r=Qt(e,r,n);continue}if(t===47&&e.charCodeAt(r+1)===42){r=$t(e,r,n);continue}return{stillDirective:!1,nextI:r,endDirectivesPhase:!0}}return{stillDirective:!0,nextI:t,endDirectivesPhase:!0}}function gn(e,t,n,r){if(!r.directivesPhase)return null;let i=e.charCodeAt(t);if(i!==39&&i!==34)return null;let a=t+1,o=z(e,t,n,i);if(o<=a)return r.directivesPhase=!1,t+1;let s=o-1-a;mn(r,s===10&&on(e,a,`use client`),s===10&&on(e,a,`use server`));let c=hn(e,o,n);return c.stillDirective?c.nextI:(c.endDirectivesPhase&&(r.directivesPhase=!1),r.directivesPhase?o:c.nextI)}function _n(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t);return I(r)||r===123?!0:r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function vn(e){e.hasDefaultExportResult=!0,e.hasComponentExportResult=!0}function yn(e,t,n,r){if(e.charCodeAt(t)!==97||e.charCodeAt(t+1)!==115)return{k:t,hasAlias:!1};let i=t+2;if(i>=n||L(e.charCodeAt(i)))return{k:t,hasAlias:!0};t=R(e,i,n);let a=t;for(;t<n&&L(e.charCodeAt(t));)t++;return t-a===7&&pn(e,a)&&vn(r),{k:t,hasAlias:!0}}function bn(e,t,n,r){let i=t;for(;t<n&&L(e.charCodeAt(t));)t++;let a=t-i;if(a===0)return null;t=R(e,t,n);let o=yn(e,t,n,r);return t=o.k,!o.hasAlias&&a===7&&pn(e,i)&&vn(r),e.charCodeAt(t)===44?t+1:e.charCodeAt(t)===125?t:t+1}function xn(e,t,n,r){let i=t+1;for(;i<n&&(i=R(e,i,n),e.charCodeAt(i)!==125);){let t=bn(e,i,n,r);if(t===null)break;i=t}}function Sn(e,t,n,r){if(!fn(e,t))return null;let i=t+6;if(!_n(e,i,n))return null;let a=R(e,i,n);if(pn(e,a)){vn(r);let t=a+7;if(t>=n||!L(e.charCodeAt(t)))return i}return e.charCodeAt(a)===123?(xn(e,a,n,r),null):((B(e,a,`async`)||B(e,a,`function`)||B(e,a,`class`))&&(r.hasComponentExportResult=!0),null)}function Cn(e,t,n,r){let i=gn(e,t,n,r);if(i!==null)return i;let a=U(e,t,n);if(a!==-1)return r.directivesPhase&&!ar(e,t)&&(r.directivesPhase=!1),a;if(r.directivesPhase=!1,B(e,t,`import`)){let i=dn(e,t,n);for(let e of i.sources)r.importSources.push(e);return i.end}let o=Sn(e,t,n,r);return o===null?t+1:o}function V(e){let t={directives:{hasUseClient:!1,hasUseServer:!1},topLevelUseClient:!1,topLevelUseServer:!1,hasDefaultExportResult:!1,hasComponentExportResult:!1,importSources:[],directivesPhase:!0,sawFirstDirective:!1},n=0,r=e.length;for(;n<r;)n=Cn(e,n,r,t);return{directives:t.directives,topLevelUseClient:t.topLevelUseClient,topLevelUseServer:t.topLevelUseServer,hasDefaultExport:t.hasDefaultExportResult,hasComponentExport:t.hasComponentExportResult,importSources:[...new Set(t.importSources)]}}function H(e,t,n){if(t>=n||!Xt(e.charCodeAt(t)))return null;let r=t+1;for(;r<n&&L(e.charCodeAt(r));)r++;return{name:e.slice(t,r),end:r}}function wn(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}if(t===59)return r+1;break}return t}function Tn(e,t,n){if(!B(e,t,`type`))return null;let r=R(e,t+4,n),i=e.charCodeAt(r);return(i===39||i===34||H(e,r,n)!==null)&&!B(e,r,`as`)?r:null}function En(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34){let i=z(e,t,n,r);return{imported:e.slice(t+1,i-1),end:i}}let i=H(e,t,n);return i?{imported:i.name,end:i.end}:null}function Dn(e,t,n){let r=Tn(e,t,n),i=r!==null;r!==null&&(t=r);let a=En(e,t,n);if(!a)return null;let o=a.imported;t=R(e,a.end,n);let s=o;if(B(e,t,`as`)){t=R(e,t+2,n);let r=H(e,t,n);if(!r)return null;s=r.name,t=R(e,r.end,n)}return{specifier:{imported:o,local:s,typeOnly:i},end:t}}function On(e,t,n){let r=[],i=t+1;for(;;){if(i=R(e,i,n),i>=n)return null;if(e.charCodeAt(i)===125)return{named:r,end:i+1};let t=Dn(e,i,n);if(!t)return null;r.push(t.specifier),i=t.end;let a=e.charCodeAt(i);if(a===44){i++;continue}return a===125?{named:r,end:i+1}:null}}function kn(e,t,n,r){let i=e.charCodeAt(n);if(i!==39&&i!==34)return null;let a=sn(e,n,r);return a?{start:t,end:wn(e,a.end,r),source:a.source,typeOnly:!1,sideEffectOnly:!0,defaultBinding:null,namespaceBinding:null,named:[]}:null}function An(e,t,n){if(!B(e,t,`type`))return{typeOnly:!1,pos:t};let r=R(e,t+4,n);return!B(e,r,`from`)&&e.charCodeAt(r)!==44?{typeOnly:!0,pos:r}:{typeOnly:!1,pos:t}}function jn(e,t,n){let r=null,i=null,a=[],o=e.charCodeAt(t);if(o!==123&&o!==42){let i=H(e,t,n);if(!i)return null;r=i.name,t=R(e,i.end,n),e.charCodeAt(t)===44?(t=R(e,t+1,n),o=e.charCodeAt(t)):o=-1}if(o===42){if(t=R(e,t+1,n),!B(e,t,`as`))return null;t=R(e,t+2,n);let r=H(e,t,n);if(!r)return null;i=r.name,t=r.end}else if(o===123){let r=On(e,t,n);if(!r)return null;a=r.named,t=r.end}return{defaultBinding:r,namespaceBinding:i,named:a,pos:t}}function Mn(e,t,n){let r=R(e,t+6,n);if(r>=n)return null;let i=e.charCodeAt(r);if(i===40||i===46)return null;let a=kn(e,t,r,n);if(a)return a;let o=An(e,r,n);r=o.pos;let s=jn(e,r,n);if(!s||(r=R(e,s.pos,n),!B(e,r,`from`)))return null;let c=sn(e,r+4,n);return c?{start:t,end:wn(e,c.end,n),source:c.source,typeOnly:o.typeOnly,sideEffectOnly:!1,defaultBinding:s.defaultBinding,namespaceBinding:s.namespaceBinding,named:s.named}:null}function Nn(e){let t=[],n=0,r=e.length;for(;n<r;){let i=U(e,n,r);if(i!==-1){n=i;continue}if(B(e,n,`import`)){let i=Mn(e,n,r);if(i){t.push(i),n=i.end;continue}n+=6;continue}n++}return t}function Pn(e,t,n,r){let i=R(e,t+1,n);if(B(e,i,`as`)){i=R(e,i+2,n);let t=H(e,i,n);return t&&r.add(t.name),t?.end??i+1}return t+1}function Fn(e,t,n,r){let i=Bn(e,t,n),a=e.slice(t+1,i-1);for(let e of a.split(`,`)){let t=e.trim();if(!t||t.startsWith(`type `)||t.startsWith(`typeof `))continue;let n=(t.split(/\s+as\s+/).at(-1)??``).trim();n!==``&&n!==`type`&&r.add(n)}return i}function In(e,t){return B(e,t,`function`)?8:B(e,t,`class`)||B(e,t,`const`)?5:3}function Ln(e,t,n,r){if(B(e,t,`async`)&&(t=R(e,t+5,n)),!B(e,t,`function`)&&!B(e,t,`class`)&&!B(e,t,`const`)&&!B(e,t,`let`)&&!B(e,t,`var`))return null;let i=In(e,t),a=R(e,t+i,n);e.charCodeAt(a)===42&&(a=R(e,a+1,n));let o=H(e,a,n);return o&&r.add(o.name),o?.end??a+1}function Rn(e,t,n,r){let i=R(e,t+6,n);if(B(e,i,`type`)||B(e,i,`interface`))return i+1;if(e.charCodeAt(i)===42)return Pn(e,i,n,r);if(B(e,i,`default`))return r.add(`default`),i+7;if(e.charCodeAt(i)===123)return Fn(e,i,n,r);let a=Ln(e,i,n,r);return a===null?t+1:a}function zn(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r;){let i=U(e,n,r);if(i!==-1){n=i;continue}if(!B(e,n,`export`)){n++;continue}n=Rn(e,n,r,t)}return[...t]}function Bn(e,t,n){let r=t,i=0;for(;r<n;){let t=Vn(e,r,n);if(t!=null){r=t;continue}let a=e.charCodeAt(r);if(a===123){i++,r++;continue}if(a===125){if(i--,r++,i===0)return r;continue}r++}return r}function Vn(e,t,n){let r=e.charCodeAt(t);return r===39||r===34||r===96?z(e,t,n,r):r===47&&e.charCodeAt(t+1)===47?Qt(e,t,n):r===47&&e.charCodeAt(t+1)===42?$t(e,t,n):null}function Hn(e){return V(e).topLevelUseServer}function Un(e,t,n){let r=e.charCodeAt(t);if(r!==39&&r!==34)return null;let i=t+1,a=z(e,t,n,r);if(a<=i)return null;let o=a-1-i,s=o===10&&on(e,i,`use client`),c=o===10&&on(e,i,`use server`);return!s&&!c?null:{kind:s?`use client`:`use server`,term:hn(e,a,n)}}function Wn(e,t){return!e.stillDirective&&e.endDirectivesPhase||!e.stillDirective?!1:t}function Gn(e,t){let n=0,r=e.length,i=!0;for(;n<r&&i&&(n=R(e,n,r),!(n>=r));){let a=Un(e,n,r);if(a==null)break;if(i=Wn(a.term,i),a.kind===t&&a.term.stillDirective)return e.slice(0,n)+e.slice(a.term.nextI);if(!a.term.stillDirective)break;n=a.term.nextI}return e}function Kn(e){return V(e).hasDefaultExport}function qn(e){return e===40||e===91||e===123||e===44||e===59||e===61||e===58||e===63||e===33||e===43||e===45||e===42||e===37||e===38||e===124||e===94||e===126||e===60||e===62}function Jn(e,t){for(t-=2;t>=1;){if(e.charCodeAt(t)===42&&e.charCodeAt(t-1)===47)return t-2;t--}return-1}function Yn(e,t){let n=t;for(;n>=0&&e.charCodeAt(n)!==10&&e.charCodeAt(n)!==13;)n--;let r=n+1;for(;r<t&&(e.charCodeAt(r)===32||e.charCodeAt(r)===9);)r++;return r<t&&e.charCodeAt(r)===47&&e.charCodeAt(r+1)===47?r-1:null}function Xn(e,t){let n=e.charCodeAt(t);return I(n)?t-1:t>=1&&n===47&&e.charCodeAt(t-1)===42?Jn(e,t):t>=1&&n===47&&e.charCodeAt(t-1)===47?t-2:Yn(e,t)}function Zn(e,t){let n=t-1;for(;n>=0;){let t=Xn(e,n);if(t!==null){if(n=t,n<0)return;continue}break}if(n<0||!L(e.charCodeAt(n)))return;let r=n;for(;n>=0&&L(e.charCodeAt(n));)n--;return e.slice(n+1,r+1)}function Qn(e,t){let n=t-1;for(;n>=0;){let t=Xn(e,n);if(t!==null){if(n=t,n<0)return-1;continue}return e.charCodeAt(n)}return-1}function $n(e,t){let n=Qn(e,t);if(n===-1||qn(n))return!0;let r=Zn(e,t);return r!=null&&r!==``&&Kt.has(r)}const er=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`default`,`else`,`do`,`typeof`,`void`,`yield`,`await`,`delete`]);function tr(e,t){let n=Qn(e,t);if(n===-1)return!0;if(L(n)||n>=48&&n<=57){let n=Zn(e,t);return n!=null&&n!==``&&er.has(n)}return n!==41&&n!==93&&n!==125}function nr(e,t,n){if(!tr(e,t))return-1;let r=e.charCodeAt(t+1);if(r!==47&&r!==46&&r!==62&&!Xt(r))return-1;let i=an(e,t,n);return i<n&&e.charCodeAt(i)===62&&i++,i>t&&e.charCodeAt(i-1)===62?i:-1}function rr(e,t,n,r){let i=e.charCodeAt(t);if(i===92)return{i:t+2,inCharClass:r,done:!1};if(r)return{i:t+1,inCharClass:i!==93,done:!1};if(i===91)return{i:t+1,inCharClass:!0,done:!1};if(i===47){for(t++;t<n&&L(e.charCodeAt(t));)t++;return{i:t,inCharClass:r,done:!0}}return Yt(i)?{i:t,inCharClass:r,done:!0}:{i:t+1,inCharClass:r,done:!1}}function ir(e,t,n){t++;let r=!1;for(;t<n;){let i=rr(e,t,n,r);if(t=i.i,r=i.inCharClass,i.done)return t}return t}function U(e,t,n){if(t>=n)return-1;let r=e.charCodeAt(t);if(I(r))return t+1;if(r===47&&e.charCodeAt(t+1)===47)return Qt(e,t,n);if(r===47&&e.charCodeAt(t+1)===42)return $t(e,t,n);if(r===39||r===34||r===96)return z(e,t,n,r);if(r===47&&e.charCodeAt(t+1)!==47&&e.charCodeAt(t+1)!==42&&$n(e,t))return ir(e,t,n);if(r===60){let r=nr(e,t,n);if(r!==-1)return r}return-1}function ar(e,t){let n=e.charCodeAt(t);return I(n)?!0:n===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function or(e,t,n){let r=t;if(B(e,r,`async`)){let t=R(e,r+5,n);B(e,t,`function`)&&(r=t)}if(!B(e,r,`function`)&&!B(e,r,`class`))return null;let i=B(e,r,`function`)?8:5,a=R(e,r+i,n);e.charCodeAt(a)===42&&(a=R(e,a+1,n));let o=H(e,a,n);return o?o.name:null}function sr(e){let t=e.length,n=0;for(;n<t;){let r=U(e,n,t);if(r!==-1){n=r;continue}if(!B(e,n,`export`)){n++;continue}let i=R(e,n+6,t);if(!B(e,i,`default`)){n++;continue}let a=R(e,i+7,t),o=or(e,a,t),s=_r(e,a,t);return{exportStart:n,valueStart:a,valueEnd:s,statementEnd:wn(e,s,t),bindingName:o}}return null}function cr(e,t,n){if(t>=n)return!1;let r=e.charCodeAt(t),i=t+1<n?e.charCodeAt(t+1):-1;return r===46||r===63&&i===46||r===40||r===91||r===96||r===61&&i===62||r===43||r===45||r===42||r===47||r===37||r===38||r===124||r===94||r===60||r===62||r===61||r===33||r===63||r===58||r===44||r===126||B(e,t,`instanceof`)||B(e,t,`in`)||B(e,t,`of`)||B(e,t,`as`)}const lr=/* @__PURE__ */ new Set([`typeof`,`void`,`delete`,`await`,`yield`,`new`]);function ur(e,t,n){let r=e.charCodeAt(t.i);return r===39||r===34||r===96?(t.i=z(e,t.i,n,r),t.lastCanTerminate=!0,!0):r===47&&e.charCodeAt(t.i+1)===47?(t.i=Qt(e,t.i,n),!0):r===47&&e.charCodeAt(t.i+1)===42?(t.i=$t(e,t.i,n),!0):r===47&&e.charCodeAt(t.i+1)!==47&&e.charCodeAt(t.i+1)!==42&&$n(e,t.i)?(t.i=ir(e,t.i,n),t.lastCanTerminate=!0,!0):!1}function dr(e,t,n){if(e.charCodeAt(t.i)!==60||t.paren!==0||t.brace!==0||t.bracket!==0)return!1;let r=nr(e,t.i,n);return r!==-1&&(t.i=r,t.lastCanTerminate=!0,!0)}function fr(e,t){return e===40?(t.paren++,t.lastCanTerminate=!1,t.i++,!1):e===41?(t.paren=Math.max(0,t.paren-1),t.lastCanTerminate=!0,t.i++,!1):e===123?(t.brace++,t.lastCanTerminate=!1,t.i++,!1):e===125?(t.brace=Math.max(0,t.brace-1),t.lastCanTerminate=!0,t.i++,t.paren===0&&t.brace===0&&t.bracket===0):e===91?(t.bracket++,t.lastCanTerminate=!1,t.i++,!1):e===93?(t.bracket=Math.max(0,t.bracket-1),t.lastCanTerminate=!0,t.i++,!1):null}function pr(e,t,n,r){if(t.paren!==0||t.brace!==0||t.bracket!==0)return null;if(r===59)return t.i;if(!Yt(r))return null;let i=R(e,t.i+1,n);return!t.lastCanTerminate||cr(e,i,n)?(t.i++,-1):t.i}function mr(e,t,n){for(t++;t<n;){let n=e.charCodeAt(t);if(n>=48&&n<=57||n===46||n===110||n===101||n===69){t++;continue}break}return t}function hr(e){return e===46||e===44||e===58||e===63||e===61||e===43||e===45||e===42||e===47||e===37||e===38||e===124||e===94||e===33||e===126||e===60||e===62}function gr(e,t,n){let r=e.charCodeAt(t.i);if(Xt(r)){let r=H(e,t.i,n);if(r){t.lastCanTerminate=!lr.has(r.name),t.i=r.end;return}}if(r>=48&&r<=57){t.lastCanTerminate=!0,t.i=mr(e,t.i,n);return}if(r===61&&e.charCodeAt(t.i+1)===62){t.lastCanTerminate=!1,t.i+=2;return}if(hr(r)){t.lastCanTerminate=!1,t.i++;return}t.i++}function _r(e,t,n){let r={i:t,paren:0,brace:0,bracket:0,lastCanTerminate:!1};for(;r.i<n;){if(ur(e,r,n)||dr(e,r,n))continue;let t=e.charCodeAt(r.i),i=fr(t,r);if(i===!0)return r.i;if(i===!1)continue;let a=pr(e,r,n,t);if(a!==-1){if(a!==null)return a;gr(e,r,n)}}return r.i}function vr(e,t){let n=sr(e);if(n==null||n.bindingName!=null)return null;let r=`const ${t} = ${e.slice(n.valueStart,n.valueEnd).trimEnd()};\nexport default ${t}${e.slice(n.statementEnd)}`;return e.slice(0,n.exportStart)+r}const yr=/* @__PURE__ */ new Set([`node_modules`,`.git`,`.cache`,`dist`]);function br(e,t){let n=/* @__PURE__ */ new Set,r=e=>{if(!E.existsSync(e))return;let i=E.readdirSync(e,{withFileTypes:!0});for(let a of i){let i=O.join(e,a.name);if(a.isDirectory()){if(yr.has(a.name))continue;r(i)}else if(a.isFile()&&x.test(a.name)){if(n.has(i))continue;n.add(i),t(i)}}};for(let t of e)t&&E.existsSync(t)&&r(t)}function xr(e){let t=[];return br(e,e=>{t.push(e)}),t}function Sr(e,t=[]){let n=[e],r=O.resolve(e);for(let e of t){if(!e)continue;let t=O.resolve(e);if(t===r)continue;let i=O.relative(r,t);if(i!==``&&(i.startsWith(`..`)||O.isAbsolute(i)))try{E.statSync(e).isDirectory()&&n.push(e)}catch{}}return n}const Cr=new Set(we);function wr(e){return Cr.has(e)}function Tr(e){for(let t of e.importSources)if(t.startsWith(`node:`)||wr(t))return!0;return!1}function Er(e,t=Cr){let n=[];for(let r of e)!r.startsWith(`.`)&&!r.startsWith(`/`)&&!r.startsWith(`@/`)&&!r.startsWith(`node:`)&&!t.has(r)&&n.push(r);return[...new Set(n)]}function Dr(e){let t=[];for(let n of e)(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`@/`))&&t.push(n);return t}function W(e){try{return E.realpathSync(e)}catch{return O.resolve(e)}}function Or(e,t){e.delete(t);try{e.delete(E.realpathSync(t))}catch{e.delete(O.resolve(t))}}function kr(e,t){let n=[];for(let r of xr(e))try{t.get(r).directives.hasUseClient&&n.push(r)}catch{}return n}var Ar=class{cache=/* @__PURE__ */ new Map;get(e,t){let n=W(e),r=this.cache.get(n);if(t!==void 0){if(r?.source===t)return r.analysis}else if(r){let e=this.readMtimeMs(n);if(e>=0&&r.mtimeMs===e)return r.analysis}t??=E.readFileSync(n,`utf-8`);let i=this.readMtimeMs(n),a=V(t);return this.cache.set(n,{mtimeMs:i,source:t,analysis:a}),a}getSource(e){return this.get(e),this.cache.get(W(e)).source}invalidate(e){Or(this.cache,e)}clear(){this.cache.clear()}readMtimeMs(e){try{return E.statSync(e).mtimeMs}catch{return-1}}};const jr=`virtual:rari-entry-client`,Mr=/^layout\.(?:tsx|ts|jsx|js)$/,Nr=/\.css(?:\?.*)?$/,Pr=/* @__PURE__ */ new Set;function Fr(){Pr.clear()}function Ir(e){let t=e.trim();t!==``&&Pr.add(t)}function Lr(){return[...Pr]}function Rr(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Nr.test(i))return null;if(i.startsWith(`./`)||i.startsWith(`../`)){let e=O.resolve(O.dirname(t),i);return!E.existsSync(e)||!E.statSync(e).isFile()?null:e}let a=be(i,r,n);return a!=null&&a!==``&&E.existsSync(a)&&E.statSync(a).isFile()?a:i}function zr(e,t,n,r){if(E.existsSync(e))for(let i of E.readdirSync(e,{withFileTypes:!0})){let a=O.join(e,i.name);if(i.isDirectory()){zr(a,t,n,r);continue}if(!i.isFile()||!Mr.test(i.name))continue;let o=E.readFileSync(a,`utf-8`);for(let e of Nn(o)){let i=Rr(e.source,a,t,n);i!=null&&r.add(i)}}}function Br(e,t={}){let n=/* @__PURE__ */ new Set;return zr(O.join(e,`src`,`app`),e,t,n),n}function Vr(e,t){if(!O.isAbsolute(e))return e.startsWith(`/`)?e:`/${e}`;let n=C(O.relative(t,e));return n.startsWith(`..`)||O.isAbsolute(n)?`/@fs/${e}`:`/${n}`}function Hr(e,t={}){return[...Br(e,t)].sort().map(t=>Vr(t,e))}function Ur(e,t){if(!O.isAbsolute(e))return e;let n=C(O.relative(t,e));return n.startsWith(`..`)||O.isAbsolute(n)?e:`/${n}`}function Wr(e,t={}){return[...Br(e,t)].sort().map(t=>`import ${JSON.stringify(Ur(t,e))};`).join(`
|
|
45
|
+
`)}function Gr(e){return e.startsWith(`/`)?e:`/${e}`}function Kr(e){let t=[...Lr()],n=new Set(t),r=e=>{n.has(e)||(n.add(e),t.push(e))};return qr(e,r)||Jr(e,r),t.length>0?`${t.join(`
|
|
46
|
+
`)}\n`:``}function qr(e,t){let n=!1;for(let[r,i]of Object.entries(e)){if(i.type!==`chunk`||i.isEntry!==!0)continue;let e=i.viteMetadata?.importedCss;if(e){let r=[...e];r.length>0&&(n=!0);for(let e of r)t(`<link rel="stylesheet" href="${Gr(e)}" />`)}t(`<script type="module" src="${Gr(r)}"><\/script>`)}return n}function Jr(e,t){for(let[n,r]of Object.entries(e))r.type===`asset`&&n.endsWith(`.css`)&&!n.includes(`/server/`)&&t(`<link rel="stylesheet" href="${Gr(n)}" />`)}function Yr(e){let t=e<0?(-e<<1)+1:e<<1,n=``;do{let e=t&31;t>>>=5,t>0&&(e|=32),n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`[e]}while(t>0);return n}function Xr(e){let t=[],n=0;for(let r of e){if(r==null){t.push(``);continue}let e=r-n;n=r,t.push(`${Yr(0)}${Yr(0)}${Yr(e)}${Yr(0)}`)}return t.join(`;`)}function Zr(e,t){let n=Math.max(1,t.split(`
|
|
47
|
+
`).length),r=Array.from({length:n},(e,t)=>t);return{version:3,file:e,sources:[e],sourcesContent:[t],names:[],mappings:Xr(r)}}function Qr(e,t){let n=e.length,r=t.length,i=Array.from({length:r}).fill(null);if(r===0||n===0)return i;if(ei(t,e)){let e=r-n;for(let t=0;t<n;t+=1)i[e+t]=t;return i}if(ti(t,e)){for(let e=0;e<n;e+=1)i[e]=e;return i}return n*r>2e6?ni(e,t):$r(e,t)}function $r(e,t){let n=e.length,r=t.length,i=Array.from({length:r}).fill(null),a=Array.from({length:n+1},()=>new Uint32Array(r+1));for(let i=1;i<=n;i+=1){let n=e[i-1],o=a[i],s=a[i-1];for(let e=1;e<=r;e+=1)o[e]=n===t[e-1]?s[e-1]+1:Math.max(s[e],o[e-1])}let o=n,s=r;for(;o>0&&s>0;)e[o-1]===t[s-1]?(i[s-1]=o-1,--o,--s):a[o-1][s]>=a[o][s-1]?--o:--s;return i}function ei(e,t){if(t.length>e.length)return!1;let n=e.length-t.length;for(let r=0;r<t.length;r+=1)if(e[n+r]!==t[r])return!1;return!0}function ti(e,t){if(t.length>e.length)return!1;for(let n=0;n<t.length;n+=1)if(e[n]!==t[n])return!1;return!0}function ni(e,t){let n=Array.from({length:t.length}).fill(null),r=0,i=0;for(;r<e.length&&i<t.length;)if(e[r]===t[i])n[i]=r,r+=1,i+=1;else{if(i+1<t.length&&e[r]===t[i+1]){i+=1;continue}if(r+1<e.length&&e[r+1]===t[i]){r+=1;continue}i+=1,r+=1}return n}function ri(e,t,n){let r=Qr(t.split(`
|
|
48
48
|
`),n.split(`
|
|
49
|
-
`));return{version:3,file:e,sources:[e],sourcesContent:[t],names:[],mappings:
|
|
50
|
-
`),r=`@font-face {\n font-family: "${
|
|
51
|
-
`,r}function Bi(e,t,n,r=`sans-serif`){let i=[`"${Fi(e)}"`];n&&i.push(`"${Fi(`${e} Fallback`)}"`);for(let e of t??[])i.push(e.includes(` `)?`"${Fi(e)}"`:e);return Pi(t)||i.push(r),i.join(`, `)}function Vi(e){return e??`swap`}function Hi(e){return e==null?`400`:String(e)}function Ui(e){return e??`normal`}const Wi=/* @__PURE__ */ new Map,Gi=/* @__PURE__ */ new Map;function Ki(e){return!u(e)||!Array.isArray(e.familyMetadataList)?!1:e.familyMetadataList.every(e=>u(e)&&typeof e.family==`string`&&e.family!==``)}function qi(e){let t=e.replace(/^\)\]\}'\n?/,``);return JSON.parse(t)}function Ji(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function Yi(e){let t=Ji((e.subsets??[]).filter(e=>e!==`menu`&&e!==``)),n=(e.axes??[]).filter(e=>typeof e.tag==`string`&&e.tag!==``&&typeof e.min==`number`&&typeof e.max==`number`).map(e=>({tag:e.tag,min:e.min,max:e.max})).sort((e,t)=>e.tag.localeCompare(t.tag));return{family:e.family,subsets:t,axisRanges:n}}function Xi(e){if(!Ki(e))throw Error(`Unexpected fonts.google.com/metadata/fonts shape`);let t=/* @__PURE__ */ new Map;for(let n of e.familyMetadataList){let e=Yi(n);t.set(e.family,e)}return t}async function Zi(e){let t=Wi.get(e);if(t!=null)return t;let n=Gi.get(e);if(n!=null)return n;let r=Promise.resolve().then(async()=>{let t=O.join(e,`google-fonts-metadata.json`);if(E.existsSync(t))try{let n=Xi(qi(E.readFileSync(t,`utf8`)));return Wi.set(e,n),n}catch{try{E.unlinkSync(t)}catch{}}let n=await fetch(`https://fonts.google.com/metadata/fonts`,{headers:{"User-Agent":`rari-google-font-meta`},signal:AbortSignal.timeout(3e4)});if(!n.ok)throw Error(`Failed to fetch Google font metadata: ${n.status} ${n.statusText}`);let r=await n.text(),i=Xi(qi(r));return Ei(e),E.writeFileSync(t,r.replace(/^\)\]\}'\n?/,``)),Wi.set(e,i),i});return Gi.set(e,r),r.finally(()=>{Gi.get(e)===r&&Gi.delete(e)})}async function Qi(e,t){try{return(await Zi(e)).get(t)??null}catch(e){return console.warn(`[rari/font] Failed to load Google font metadata for ${t}:`,e),null}}function $i(e,t,n){let r=t.subsets!=null&&t.subsets.length>0,i=r?t.preload!==!1:t.preload===!0,a=t.subsets;if(i&&!r&&console.warn(`[rari/font] ${e}: \`preload\` is true but no \`subsets\` were specified. Specify subsets to avoid downloading unused glyphs, or set \`preload: false\`.`),a==null||a.length===0||n==null||n.length===0)return;let o=new Set(n.map(e=>e.toLowerCase())),s=[...new Set(a.map(e=>e.toLowerCase())).difference(o)];s.length!==0&&console.warn(`[rari/font] ${e}: unknown subset(s) ${s.map(e=>JSON.stringify(e)).join(`, `)}. Available: ${n.join(`, `)}`)}const ea=1e4,ta=/* @__PURE__ */ new Set([`fonts.gstatic.com`]);function na(e){let t=URL.parse(e);if(t==null)throw Error(`Invalid Google font URL: ${e}`);if(t.protocol!==`https:`)throw Error(`Google font URL must use HTTPS: ${e}`);if(!ta.has(t.hostname))throw Error(`Google font URL host not allowlisted (${t.hostname}): ${e}. Allowed: ${[...ta].join(`, `)}`);return t}function ra(e){return e.subsets!=null&&e.subsets.length>0?e.preload!==!1:e.preload===!0}function ia(e){return e.trim().replaceAll(` `,`+`)}function aa(e){if(e==null)return[`400`];if(Array.isArray(e)){let t=e.map(String);return t.length>0?t:[`400`]}return[String(e)]}const oa=/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)$/;function sa(e){return oa.test(e.trim())}function ca(e){return e===`variable`||typeof e==`string`&&sa(e)?!0:Array.isArray(e)?e.some(e=>e===`variable`||typeof e==`string`&&sa(e)):!1}function la(e){if(typeof e==`string`){let t=oa.exec(e.trim());if(t!=null)return`${t[1]}..${t[2]}`}if(Array.isArray(e))for(let t of e){if(typeof t!=`string`)continue;let e=oa.exec(t.trim());if(e!=null)return`${e[1]}..${e[2]}`}return`100..900`}function ua(e,t){if(e==null)return null;let n=e.find(e=>e.tag===t);return n==null?null:`${n.min}..${n.max}`}function da(e,t){if(ca(e))return fa(e,t);if(e!=null){let t=aa(e);if(t.length===1)return`${t[0]}..${t[0]}`}return ua(t,`wght`)??`100..900`}function fa(e,t){if(typeof e==`string`&&sa(e))return la(e);if(Array.isArray(e)){for(let t of e)if(typeof t==`string`&&sa(t))return la(t)}return ua(t,`wght`)??la(e)}function pa(e){if(e==null)return[`normal`];if(typeof e==`string`)return[e];let t=e.filter(e=>e!==``);return t.length>0?[...t]:[`normal`]}function ma(e){let t=(e.axes??[]).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t)n.includes(e)||n.push(e);return n}function ha(e){return e==null||ca(e)?null:aa(e)}function ga(e,t,n){let r=ia(e),i=Vi(t.display),a=pa(t.style),o=a.includes(`italic`),s=a.includes(`normal`)||!o,c=ma(t);return`https://fonts.googleapis.com/css2?family=${r}:${ca(t.weight)||c.length>0?_a(t,n,c,o,s):ba(t.weight,o,s)}&display=${i}`}function _a(e,t,n,r,i){let a=[`wght`,...n.filter(e=>e!==`wght`&&e!==`ital`)].sort((e,t)=>e.localeCompare(t)),o=ha(e.weight),s=(e,n)=>e===`wght`?n:ua(t,e)??`1..1000`;if(o!=null)return va(a,o,s,r,i);let c=da(e.weight,t);return ya(a,a.map(e=>s(e,c)),r,i)}function va(e,t,n,r,i){let a=t.map(t=>e.map(e=>n(e,t)).join(`,`));return r&&i?`ital,${e.join(`,`)}@${[...a.map(e=>`0,${e}`),...a.map(e=>`1,${e}`)].join(`;`)}`:r?`ital,${e.join(`,`)}@${a.map(e=>`1,${e}`).join(`;`)}`:e.length===1&&e[0]===`wght`?`wght@${t.join(`;`)}`:`${e.join(`,`)}@${a.join(`;`)}`}function ya(e,t,n,r){return n&&r?`ital,${e.join(`,`)}@0,${t.join(`,`)};1,${t.join(`,`)}`:n?`ital,${e.join(`,`)}@1,${t.join(`,`)}`:e.length===1&&e[0]===`wght`?`wght@${t[0]}`:`${e.join(`,`)}@${t.join(`,`)}`}function ba(e,t,n){let r=aa(e);return t&&n?`ital,wght@${[...r.map(e=>`0,${e}`),...r.map(e=>`1,${e}`)].join(`;`)}`:t?`ital,wght@${r.map(e=>`1,${e}`).join(`;`)}`:`wght@${r.join(`;`)}`}function xa(e){let t=[],n=e.split(`@font-face`);for(let e=1;e<n.length;e+=1){let r=n[e-1]??``,i=n[e]??``,a=i.indexOf(`{`),o=i.indexOf(`}`,a);if(a===-1||o===-1)continue;let s=i.slice(a+1,o),c=/\/\*\s*([\w-]+)\s*\*\/\s*$/.exec(r)?.[1]??null,l=/font-family:\s*'([^']+)'/.exec(s)?.[1]??/font-family:\s*"([^"]+)"/.exec(s)?.[1],u=/font-style:\s*([^;\s]+)\s*;/.exec(s)?.[1]??`normal`,d=/font-weight:([^;]+);/.exec(s)?.[1]?.trim()??`400`,f=/src:\s*url\(([^)]+)\)/.exec(s)?.[1]?.replaceAll(/['"]/g,``),p=/unicode-range:([^;]+);/.exec(s)?.[1]?.trim()??null;l!=null&&f!=null&&f!==``&&t.push({family:l,style:u,weight:d,url:f,subset:c,unicodeRange:p})}return t}function Sa(e,t){if(t==null||t.length===0)return[...e];let n=new Set(t.map(e=>e.toLowerCase()));return e.filter(e=>e.subset!=null&&n.has(e.subset.toLowerCase()))}async function Ca(e,t){if(E.existsSync(t))return E.readFileSync(t);let n=na(e).href,r=null;for(let e=0;e<=3;e+=1){let e=await fetch(n,{signal:AbortSignal.timeout(ea),redirect:`manual`});if(e.status>=300&&e.status<400){let t=e.headers.get(`location`);if(t==null||t===``)throw Error(`Font download redirect missing Location from ${n}`);n=na(new URL(t,n).href).href;continue}r=e;break}if(r==null)throw Error(`Too many redirects downloading font ${e}`);if(!r.ok)throw Error(`Failed to download font ${e}: ${r.status} ${r.statusText}`);let i=Buffer.from(await r.arrayBuffer());return Ei(O.dirname(t)),E.writeFileSync(t,i),i}async function wa(e,t,n){let r=await Qi(n,e);$i(e,t,r?.subsets);let i=ga(e,t,r?.axisRanges),a=O.join(n,`${P(i)}.css`),o;if(E.existsSync(a))o=E.readFileSync(a,`utf8`);else{let t=await fetch(i,{headers:{"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`},signal:AbortSignal.timeout(ea)});if(!t.ok)throw Error(`Failed to fetch Google Font CSS for ${e}: ${t.status} ${t.statusText}`);o=await t.text(),Ei(n),E.writeFileSync(a,o)}let s=Sa(xa(o),t.subsets);if(s.length===0)throw Error(`No @font-face rules returned for Google font "${e}"`);let c=Vi(t.display),l=ra(t),u=[];for(let r of s){let i=na(r.url),a=P(r.url),o=O.extname(i.pathname)||`.woff2`,s=`${e.replaceAll(/\s+/g,``)}-${r.weight}-${r.style}-${a}${o}`,d=O.join(n,s);await Ca(r.url,d),u.push({family:r.family,style:Ui(r.style),weight:Hi(r.weight),display:c,src:[{url:``,format:Li(d)}],preload:l,variable:t.variable,fallback:t.fallback,adjustFontFallback:t.adjustFontFallback!==!1&&void 0,unicodeRange:r.unicodeRange??void 0,filePaths:[d]})}return u}function Ta(e){return e.replaceAll(`_`,` `)}function Ea(e){return typeof e==`string`?[{path:e}]:e.map(e=>({...e}))}function Da(e,t,n){let r=Vi(e.display),i=e.preload!==!1,a=Ea(e.src);if(a.length===0)throw Error("rari/font/local: `src` must include at least one font file");let o=a.map(r=>{let i=O.isAbsolute(r.path)?r.path:O.resolve(t,r.path);if(!E.existsSync(i))throw Error(`rari/font/local: font file not found: ${r.path} (from ${t})`);let a=O.relative(n,i);if(a.startsWith(`..`)||O.isAbsolute(a))throw Error(`rari/font/local: font file must be inside the project: ${r.path}`);return{absolute:i,weight:Hi(r.weight??e.weight),style:Ui(r.style??e.style),familyBase:O.basename(i,O.extname(i))}}),s=o[0].familyBase;return o.map(t=>({family:s,style:t.style,weight:t.weight,display:r,src:[{url:``,format:Li(t.absolute)}],preload:i,variable:e.variable,fallback:e.fallback,adjustFontFallback:e.adjustFontFallback,declarations:e.declarations,filePaths:[t.absolute]}))}function Oa(e,t){if(e[t]!==`{`)return null;try{let{json:n,end:r}=ka(e,t);return typeof n!=`object`||!n||Array.isArray(n)?null:{value:n,end:r}}catch{return null}}function U(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??``);)n+=1;return n}function ka(e,t){let n=U(e,t),r=e[n];if(r===`{`)return Na(e,n);if(r===`[`)return Ma(e,n);if(r===`'`||r===`"`)return Aa(e,n);if(r===`-`||r>=`0`&&r<=`9`)return ja(e,n);if(e.startsWith(`true`,n))return{json:!0,end:n+4};if(e.startsWith(`false`,n))return{json:!1,end:n+5};if(e.startsWith(`null`,n))return{json:null,end:n+4};throw Error(`Unsupported token at ${n}`)}function Aa(e,t){let n=e[t],r=t+1,i=``;for(;r<e.length;){let t=e[r];if(t===`\\`){if(r+1>=e.length)throw Error(`Unterminated string escape`);i+=e[r+1],r+=2;continue}if(t===n)return{json:i,end:r+1};i+=t,r+=1}throw Error(`Unterminated string`)}function ja(e,t){let n=/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/i.exec(e.slice(t));if(n==null)throw Error(`Invalid number`);return{json:Number(n[0]),end:t+n[0].length}}function Ma(e,t){let n=[],r=U(e,t+1);if(e[r]===`]`)return{json:n,end:r+1};for(;r<e.length;){let t=ka(e,r);if(n.push(t.json),r=U(e,t.end),e[r]===`,`){if(r=U(e,r+1),e[r]===`]`)return{json:n,end:r+1};continue}if(e[r]===`]`)return{json:n,end:r+1};throw Error(`Expected comma or ]`)}throw Error(`Unterminated array`)}function Na(e,t){let n={},r=U(e,t+1);if(e[r]===`}`)return{json:n,end:r+1};for(;r<e.length;){let t=Pa(e,r),i=t.key;if(r=t.end,e[r]!==`:`)throw Error(`Expected :`);let a=ka(e,r+1);if(n[i]=a.json,r=U(e,a.end),e[r]===`,`){if(r=U(e,r+1),e[r]===`}`)return{json:n,end:r+1};continue}if(e[r]===`}`)return{json:n,end:r+1};throw Error(`Expected comma or }`)}throw Error(`Unterminated object`)}function Pa(e,t){let n=t;if(e[n]===`'`||e[n]===`"`){let t=Aa(e,n);return{key:t.json,end:U(e,t.end)}}let r=/^[A-Z_$][\w$]*/i.exec(e.slice(n));if(r==null)throw Error(`Expected property name`);return{key:r[0],end:U(e,n+r[0].length)}}const Fa=`rari/font/local`,Ia=`rari/font/google`,La=`\0rari-font-css:`,Ra=/\.(?:woff2?|ttf|otf)$/i;function za(e){if(e!=null){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}}function Ba(e){if(e===`auto`||e===`block`||e===`swap`||e===`fallback`||e===`optional`)return e}function Va(e){let t=e.src,n;if(typeof t==`string`)n=t;else if(Array.isArray(t))n=t.map(e=>{if(typeof e==`string`)return{path:e};if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`rari/font/local: invalid src entry`);let t=e.path;if(typeof t!=`string`)throw Error(`rari/font/local: src.path must be a string`);return{path:t,weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0}});else throw TypeError("rari/font/local: `src` is required");return{src:n,display:Ba(e.display),weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0,variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:za(e.fallback),adjustFontFallback:e.adjustFontFallback===!1?!1:e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:void 0,declarations:Ha(e.declarations)}}function Ha(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`object`||!n||Array.isArray(n))continue;let e=n.prop,r=n.value;typeof e==`string`&&typeof r==`string`&&t.push({prop:e,value:r})}return t.length>0?t:void 0}function Ua(e){let t=e.weight,n=e.style;return{weight:typeof t==`string`||typeof t==`number`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):void 0,style:typeof n==`string`?n:Array.isArray(n)?n.filter(e=>typeof e==`string`):void 0,subsets:za(e.subsets),display:Ba(e.display),variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:za(e.fallback),adjustFontFallback:typeof e.adjustFontFallback==`boolean`?e.adjustFontFallback:void 0,axes:za(e.axes)}}function Wa(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0))return r}return-1}async function Ga(e){try{let t=await Me(E.readFileSync(e));return{ascent:t.ascent,descent:t.descent,lineGap:t.lineGap,unitsPerEm:t.unitsPerEm,xWidthAvg:t.xWidthAvg}}catch{return null}}async function Ka(e,t){let n=await Ai(t);if(e.adjustFontFallback===!1)return{overrides:null,metrics:n};let r=e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:null;return n??=await Ga(e.filePaths[0]),n==null?{overrides:null,metrics:n}:(r??=ji(n.category),{overrides:ki(n,r),metrics:n})}function qa(e,t){return t==null?``:`@font-face {\n font-family: "${e} Fallback";\n src: local("${t.fallbackFont}");\n ascent-override: ${t.ascentOverride};\n descent-override: ${t.descentOverride};\n line-gap-override: ${t.lineGapOverride};\n size-adjust: ${t.sizeAdjust};\n}\n`}async function Ja(e,t,n){let r=[],i=[],a=[];for(let o of e){if(o.filePaths.length===0)continue;let e=o.filePaths[0],s=E.readFileSync(e),c=P(s);a.push(c);let l=wi(e,c,t);r.push({fileName:l,source:s}),i.push({...o,family:n,src:[{url:Ti(l),format:o.src[0]?.format??`woff2`}]})}if(i.length===0)throw Error(`rari/font: no font files resolved`);let o=i[0],s=JSON.stringify({display:o.display,weight:i.map(e=>e.weight),style:i.map(e=>e.style),fallback:o.fallback??null,adjustFontFallback:o.adjustFontFallback??null,declarations:o.declarations??null,unicodeRange:i.map(e=>e.unicodeRange??null),variable:o.variable??null}),c=P(`${a.join(`|`)}|${n}|${s}`),l=Di(`rari_font`,c),u=o.variable==null?null:Di(`rari_font_var`,c),d=await Ka(o,n),f=d.overrides,p=d.metrics,m=``;for(let e of i)m+=zi(e);m+=qa(n,f);let h=Bi(n,o.fallback,f!=null,Ni(p?.category));m+=`.${l} {\n font-family: ${h};\n}\n`,o.variable!=null&&u!=null&&(m+=`.${u} {\n ${o.variable}: ${h};\n}\n`);let g=Number(o.weight),_={className:l,style:{fontFamily:h,fontWeight:Number.isFinite(g)?g:o.weight,fontStyle:o.style===`normal`?void 0:o.style},variable:u??void 0},v=i.filter(e=>e.preload).flatMap(e=>e.src.map(e=>e.url)).filter(e=>e!==``);return{font:_,css:m,cssId:`${La}${c}.css`,assets:r,preloadUrls:v}}function Ya(e){let t=[];for(let n=0;n<e.length;n+=1)t.push(!0);let n=(e,n)=>{for(let r=e;r<n;r+=1)t[r]=!1},r=0;for(;r<e.length;){let t=Xa(e,r);if(t!=null){n(r,t),r=t;continue}r+=1}return t}function Xa(e,t){let n=e.charCodeAt(t);if(n===47&&e.charCodeAt(t+1)===47){let n=e.indexOf(`
|
|
52
|
-
`,t+2);return n===-1?e.length:n}if(n===47&&e.charCodeAt(t+1)===42){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}return n===34||n===39||n===96?
|
|
53
|
-
`,t+2);return n===-1?e.length:n+1}function
|
|
54
|
-
`||e[a]===`\r`);)a+=1;return e[a]===`(`?{start:n,openParen:a}:null}function
|
|
55
|
-
`);return _!==``&&(o=
|
|
56
|
-
`){n+=1;continue}if(t===`/`&&e[n+1]===`/`){n=
|
|
57
|
-
• `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`)}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};function W(e,t){return e.readUInt16BE(t)}function G(e,t){return e.readUInt32BE(t)}function ko(e,t){return e.readUInt32LE(t)}function Ao(e){return e.length<24||e.toString(`ascii`,1,4)!==`PNG`?null:{width:G(e,16),height:G(e,20)}}function jo(e){if(e.length<10)return null;let t=e.toString(`ascii`,0,6);return t!==`GIF87a`&&t!==`GIF89a`?null:{width:e.readUInt16LE(6),height:e.readUInt16LE(8)}}function Mo(e){return e>=192&&e<=195||e>=197&&e<=199||e>=201&&e<=203||e>=205&&e<=207}function No(e,t){if(t+7>=e.length)return null;let n=W(e,t),r=e[t+7]??0,i=8+3*r;if(r<1||n<i||t+n>e.length)return null;let a=W(e,t+3),o=W(e,t+5);return o===0||a===0?null:{height:a,width:o}}function Po(e,t){if(t+1>=e.length)return null;let n=W(e,t);return n<2?null:t+n}function Fo(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<=e.length;){if(e[t]!==255){t+=1;continue}if(t+1>=e.length)return null;let n=e[t+1];if(t+=2,Mo(n))return No(e,t);if(n===217||n===218)return null;let r=Po(e,t);if(r==null)return null;t=r}return null}function Io(e,t){return(e[t]??0)|(e[t+1]??0)<<8|(e[t+2]??0)<<16}function Lo(e){if(e.length<20||e.toString(`ascii`,0,4)!==`RIFF`||e.toString(`ascii`,8,12)!==`WEBP`)return null;let t=e.toString(`ascii`,12,16);if(t===`VP8X`&&e.length>=30)return{width:Io(e,24)+1,height:Io(e,27)+1};if(t===`VP8 `&&e.length>=30)return{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t===`VP8L`&&e.length>=25){if(e[20]!==47)return null;let t=ko(e,21);return{width:(t&16383)+1,height:(t>>14&16383)+1}}return null}function Ro(e,t,n){if(t+8>n)return null;let r=G(e,t),i=e.toString(`ascii`,t+4,t+8),a=8;if(r===1){if(t+16>n)return null;r=Number(e.readBigUInt64BE(t+8)),a=16}else r===0&&(r=n-t);let o=t+r;return r<a||o>n?null:{type:i,headerSize:a,start:t,end:o}}function*zo(e,t,n){let r=t;for(;r+8<=n;){let t=Ro(e,r,n);if(t==null)return;yield t,r=t.end}}function Bo(e,t){let n=t.start+t.headerSize;return n+4>t.end?null:{version:e[n]??0,flags:(e[n+1]??0)<<16|(e[n+2]??0)<<8|(e[n+3]??0),dataOffset:n+4}}function Vo(e,t){let n=Bo(e,t);return n==null||n.dataOffset+8>t.end?null:{width:G(e,n.dataOffset),height:G(e,n.dataOffset+4)}}function Ho(e,t){let n=Bo(e,t);return n==null?null:n.version===0?n.dataOffset+2>t.end?null:W(e,n.dataOffset):n.dataOffset+4>t.end?null:G(e,n.dataOffset)}function Uo(e,t,n,r){return r<1?t+2>n?null:{itemId:W(e,t),nextOffset:t+2}:t+4>n?null:{itemId:G(e,t),nextOffset:t+4}}function Wo(e,t,n,r,i){let a=t,o=[];for(let t=0;t<r;t+=1)if(i){if(a+2>n)return null;let t=W(e,a);a+=2,o.push(t&32767)}else{if(a+1>n)return null;let t=e[a]??0;a+=1,o.push(t&127)}return{propertyIndexes:o,nextOffset:a}}function Go(e,t){let n=Bo(e,t);if(n==null||n.dataOffset+4>t.end)return null;let r=G(e,n.dataOffset),i=n.dataOffset+4,a=/* @__PURE__ */ new Map,o=!!(n.flags&1);for(let s=0;s<r;s+=1){let r=Uo(e,i,t.end,n.version);if(r==null||(i=r.nextOffset,i+1>t.end))return null;let s=e[i]??0;i+=1;let c=Wo(e,i,t.end,s,o);if(c==null)return null;i=c.nextOffset,a.set(r.itemId,c.propertyIndexes)}return a}function Ko(e){for(let t of zo(e,0,e.length))if(t.type===`meta`)return t;return null}function qo(e,t,n){let r=1,i=null;for(let a of zo(e,t.start+t.headerSize,t.end)){if(a.type===`ispe`){let t=Vo(e,a);t!=null&&(n.set(r,t),i??=t)}r+=1}return i}function Jo(e,t){let n=/* @__PURE__ */ new Map,r=null,i=null;for(let a of zo(e,t.start+t.headerSize,t.end))if(a.type===`ipco`){let t=qo(e,a,n);i??=t}else a.type===`ipma`&&(r=Go(e,a));return{ispeByIndex:n,associations:r,firstIspe:i}}function Yo(e,t,n){if(e==null||t==null)return null;let r=t.get(e);if(r==null)return null;for(let e of r){let t=n.get(e);if(t!=null)return t}return null}function Xo(e){if(e.length<12||e.toString(`ascii`,4,8)!==`ftyp`)return null;let t=Ko(e);if(t==null)return null;let n=t.start+t.headerSize+4;if(n>t.end)return null;let r=null,i=/* @__PURE__ */ new Map,a=null,o=null;for(let s of zo(e,n,t.end)){if(s.type===`pitm`){r=Ho(e,s);continue}if(s.type!==`iprp`)continue;let t=Jo(e,s);i=t.ispeByIndex,a=t.associations,o??=t.firstIspe}return Yo(r,a,i)??o}function Zo(e){return e.length<4?null:e[0]===137&&e.toString(`ascii`,1,4)===`PNG`?Ao(e):e[0]===255&&e[1]===216?Fo(e):e.toString(`ascii`,0,3)===`GIF`?jo(e):e.toString(`ascii`,0,4)===`RIFF`?Lo(e):Xo(e)}const Qo=/\.(?:avif|gif|jpe?g|png|webp)$/i,$o=`\0rari-static-image:`,es=/* @__PURE__ */ new Set([`raw`,`url`,`inline`,`no-inline`]);function ts(e){let t=e.indexOf(`?`);return t===-1?[]:e.slice(t+1).split(`&`).map(e=>e.split(`=`)[0]??``).filter(Boolean)}function ns(e){return ts(e).includes(`rari-static-bypass`)}function rs(e){return ts(e).some(e=>es.has(e))}function is(e,t,n){return Si(e,t,n,{encodeBase:!0})}function as(e,t,n){return`const src = ${JSON.stringify(e)};\nexport default {\n src,\n width: ${t},\n height: ${n},\n};\n`}function os(e){return Qo.test(oe(e))&&!ns(e)&&!rs(e)}function ss(e,t=`assets`){let n=E.readFileSync(e),r=P(n),i=is(e,r,t),a=xi(e,r,t),o=Zo(n);if(o==null)throw Error(`[rari] Unable to read dimensions for static image import: ${e}. Pass explicit width/height to <Image>, or convert the file to png/jpeg/webp/gif/avif.`);return{code:as(i,o.width,o.height),publicPath:i,source:n,fileName:a}}const cs=/* @__PURE__ */ new Map,K=/* @__PURE__ */ new Map;function ls(e,t){let n=cs.get(e);if(n!=null)return n;let r=/* @__PURE__ */ new Map;if(E.existsSync(t))try{let e=f(E.readFileSync(t,`utf8`));if(e!=null)for(let[t,n]of Object.entries(e))typeof n==`string`&&r.set(t,n)}catch{}return cs.set(e,r),r}function us(e,t,n){for(let[r,i]of e)i===n&&r!==t&&e.delete(r);e.set(t,n)}function ds(e,t){let n=new Set(t.values());for(let[r,i]of e){if(!E.existsSync(i)){e.delete(r);continue}n.has(i)&&t.get(r)!==i&&e.delete(r)}}function q(e){return O.basename(e)===`client`?O.dirname(e):e}function fs(e){return O.join(q(e),`server`,`static-image-sources.json`)}function ps(e,t){let n=q(e),i=fs(e);if(t.size===0){try{E.unlinkSync(i)}catch(e){if(r(e)!==`ENOENT`)throw e}cs.delete(n);return}E.mkdirSync(O.dirname(i),{recursive:!0});let a=Object.fromEntries(t);E.writeFileSync(i,`${JSON.stringify(a,null,2)}\n`)}function ms(e){let t=q(e);K.has(t)||K.set(t,/* @__PURE__ */ new Map)}function hs(e){let t=q(e),n=K.get(t);if(n==null)return;let r=ls(t,fs(e));r.clear();for(let[e,t]of n)E.existsSync(t)&&r.set(e,t);ps(e,r),K.delete(t)}function gs(e,t){let n=q(e),r=ls(n,fs(e));for(let[e,n]of t)r.set(e,n);let i=K.get(n);if(i!=null){for(let[e,n]of t)us(i,e,n);return}ds(r,t),ps(e,r)}function _s(e,t){let n=!1;for(let[r,i]of e)i===t&&(e.delete(r),n=!0);return n}function vs(e){switch(e){case`.png`:return`image/png`;case`.gif`:return`image/gif`;case`.webp`:return`image/webp`;case`.avif`:return`image/avif`;case`.svg`:return`image/svg+xml`;default:return`image/jpeg`}}function ys(e){try{return decodeURIComponent(e)}catch{return e}}function bs(e,t,n,r){let i=t?.split(`?`)[0];if(i==null||i===``){r();return}let a=ys(i),o=e.get(i)??e.get(a);if(o==null||o===``){r();return}n.setHeader(`Content-Type`,vs(O.extname(o).toLowerCase())),n.setHeader(`Cache-Control`,`no-cache`),E.createReadStream(o).on(`error`,()=>{n.headersSent||(n.statusCode=404),n.end()}).pipe(n)}function xs(){let e=process.cwd(),t=O.join(e,`dist`,`client`),n=`assets`,r=!1,i=/* @__PURE__ */ new Map;return{name:`rari:static-image`,enforce:`pre`,configResolved(i){let a=Ut(i);e=a.projectRoot,t=a.outDir,n=a.assetsDir,r=i.command===`build`},buildStart(){r&&ms(t)},async resolveId(e,t){if(t==null||t===``||!os(e))return null;let n=await this.resolve(e,t,{skipSelf:!0});if(n==null||n.id===``)return null;let r=oe(n.id);return E.existsSync(r)?$o+r:null},load(e){if(!e.startsWith($o))return null;let r=e.slice(19),a=ss(r,n);return us(i,a.publicPath,r),gs(t,i),this.emitFile({type:`asset`,fileName:a.fileName,source:a.source}),a.code},watchChange(e,n){if(n.event!==`delete`)return;let r=oe(e);if(!_s(i,r))return;let a=K.get(q(t));a!=null&&_s(a,r),gs(t,i)},configureServer(e){e.middlewares.use((e,t,n)=>{bs(i,e.url,t,n)})}}}function Ss(e){let t=w(e);return t===`rari/mdx/registry`||t.startsWith(`rari/mdx/registry?`)?!0:t.endsWith(`/mdx/registry.ts`)||t.endsWith(`/mdx/registry.mts`)||t.endsWith(`/mdx/registry.mjs`)||t.endsWith(`/mdx/registry.js`)||t.endsWith(`/mdx/registry`)?t.includes(`/node_modules/rari/`)||t.includes(`/packages/rari/`):!1}function Cs(e,t){let n=e=>{if(E.existsSync(e))for(let r of E.readdirSync(e,{withFileTypes:!0})){let i=O.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`||r.name===`.git`||r.name===`dist`)continue;n(i)}else r.isFile()&&r.name.endsWith(`.mdx`)&&t(i)}};for(let t of e)t&&E.existsSync(t)&&n(t)}function ws(e){let t=/* @__PURE__ */ new Set;return Cs(e,e=>{try{let n=E.readFileSync(e,`utf-8`);for(let e of ve(n))t.add(e)}catch{}}),t}function Ts(e,t){try{if(t.get(e).hasDefaultExport)return O.basename(e,O.extname(e));let n=t.getSource(e).match(x);if(n?.[1]!=null&&n[1]!==``)return n[1]}catch{}return O.basename(e,O.extname(e))}function Es(e){let t=ws(e.contentDirs.map(t=>O.join(e.projectRoot,t)));if(t.size===0)return[];let n=jr(e.componentScanDirs,e.cache),r=[],i=/* @__PURE__ */ new Set;for(let a of n){let n=Ts(a,e.cache);if(n==null||n===``||!t.has(n))continue;let o=Wt(a,e.projectRoot),s=o.startsWith(`/`)?o:`/${o}`,c=n.replace(/[^\w$]/g,`_`);i.has(c)&&(c=`${c}_${r.length}`),i.add(c),r.push({name:n,binding:c,importPath:s,moduleId:o,client:!0})}return r.sort((e,t)=>e.name.localeCompare(t.name))}function Ds(e){let t=ks(e.projectRoot,e.mdxOptions),n=e.srcDir??O.join(e.projectRoot,`src`),r=Ns(e.projectRoot,t.componentsDir,wr(n,Object.values(e.alias??{})));return Es({projectRoot:e.projectRoot,componentsDir:t.componentsDir,contentDirs:t.contentDirs,cache:e.cache,componentScanDirs:r})}function Os(e,t={}){let n=t.importStyle??`root-absolute`,r=t.mode??`vite`;return e.length===0?`import { defineMdxComponents } from 'rari/mdx/define'
|
|
49
|
+
`));return{version:3,file:e,sources:[e],sourcesContent:[t],names:[],mappings:Xr(r)}}function ii(e,t,n){return e===t?null:{code:e,map:ri(n,t,e)}}const ai=/\.(?:[cm]?[jt]sx?|vue|svelte|mdx?)$/i;function oi(e,t,n){return e.startsWith(`//`)||/^[a-z][a-z\d+.-]*:/i.test(e)?e:e===``||e===t?`${n}${t}`:e.startsWith(`/`)?`${n}${e}`:`${n}${O.posix.normalize(`${O.posix.dirname(t)}/${e}`)}`}function si(e){if(!(`sourceRoot`in e))return;let t=Reflect.get(e,`sourceRoot`);return typeof t==`string`&&t!==``?t:void 0}function ci(e){return e.startsWith(`//`)||/^[a-z][a-z\d+.-]*:/i.test(e)}function li(e,t){if(t==null||ci(e)||e.startsWith(`/`))return e;if(ci(t))try{if(t.startsWith(`//`)){let n=new URL(e,`https:${t}`);return`//${n.host}${n.pathname}${n.search}${n.hash}`}return new URL(e,t).href}catch{let n=t.lastIndexOf(`/`);return`${n>=0?t.slice(0,n+1):`${t}/`}${e}`}let n=t.endsWith(`/`)?`${t}${e}`:`${t}/${e}`;return O.posix.normalize(n)}function ui(e){if(!(`sources`in e))return;let t=Reflect.get(e,`sources`);if(Array.isArray(t))return t.every(e=>e===null||typeof e==`string`)?t:void 0}function di(e,t,n,r){return e==null?null:oi(li(e,r),t,n)}function fi(e,t,n){let r=ui(e);if(r==null)return e;let i=si(e),a={...e,sources:r.map(e=>di(e,t,n,i))};return delete a.sourceRoot,a}function pi(e,t,n,r){if(t.startsWith(`file://`))return mi(e,t,r);let i=e.config.base.endsWith(`/`)?e.config.base.slice(0,-1):e.config.base,a=n===`Server`||n===`rsc`,o=n===`Client`||n===`client`;if(a)return hi(e,t,i);if(o)return gi(e,t,i)}function mi(e,t,n){let r;try{r=C(A(t))}catch{return}if(!le(r,n)||!Ae(e.config,r)||!ai.test(r)||!E.existsSync(r))return;let i=E.statSync(r);if(!i.isFile()||i.size>1048576)return;let a=E.readFileSync(r,`utf-8`);return Zr(r,a)}function hi(e,t,n){let r=e.environments.rsc.moduleGraph,i=r.getModuleById(t)??(t.startsWith(`/`)?r.urlToModuleMap.get(t):void 0),a=i?.transformResult?.map;if(i!=null&&a!=null)return fi(a,i.url,n)}function gi(e,t,n){try{let r=new URL(t,`http://localhost`).pathname,i=n!==``&&r.startsWith(n)?r.slice(n.length):r,a=e.environments.client.moduleGraph.urlToModuleMap.get(i),o=a?.transformResult?.map;return a==null||o==null?void 0:fi(o,a.url,n)}catch{return}}function _i(e){let t=O.resolve(e);return{name:`rari:find-source-map-url`,apply:`serve`,configureServer(e){e.middlewares.use((n,r,i)=>{if(ce(n.url??``)!==`/__rari_findSourceMapURL`){i();return}let a=new URL(n.url??``,`http://localhost`),o=a.searchParams.get(`filename`),s=a.searchParams.get(`environmentName`)??`Server`;if(o==null||o===``){r.statusCode=400,r.end(`{}`);return}try{let n=pi(e,o,s,t);r.statusCode=n==null?404:200,r.setHeader(`Content-Type`,`application/json`),r.setHeader(`Cache-Control`,`no-store`),r.end(JSON.stringify(n??{}))}catch(e){i(e)}})}}}function vi(e,t={}){let n=O.extname(e),r=n.toLowerCase(),i=r===``?t.defaultExt??``:r,a=O.basename(e,n);return t.sanitizeBase&&(a=a.replaceAll(/[?#]/g,`_`)),t.encodeBase&&(a=encodeURIComponent(a)),{base:a,ext:i}}function yi(e,t,n,r={}){let{base:i,ext:a}=vi(e,r);return`${S(n)}/${i}-${t}${a}`}function bi(e,t,n,r={}){return`/${yi(e,t,n,r)}`}function xi(e){return`/${e.split(O.sep).join(`/`)}`}function Si(e,t,n){return yi(e,t,n,{defaultExt:`.woff2`,sanitizeBase:!0})}function Ci(e){return xi(e)}function wi(e,t){let n=e.split(/[?#]/,1)[0]??e;return t.has(n)}function Ti(e){E.mkdirSync(e,{recursive:!0})}function Ei(e,t){return`${e}_${t}`}function Di(e){return`${(e*100).toFixed(2)}%`}function Oi(e,t){if(!Number.isFinite(e.unitsPerEm)||e.unitsPerEm===0||!Number.isFinite(e.xWidthAvg))return null;let n=t===`Times New Roman`?Ne:Me;if(!Number.isFinite(n.unitsPerEm)||n.unitsPerEm===0||!Number.isFinite(n.xWidthAvg))return null;let r=e.xWidthAvg/e.unitsPerEm,i=n.xWidthAvg/n.unitsPerEm;if(!Number.isFinite(i)||i===0)return null;let a=r/i;return!Number.isFinite(a)||a===0?null:{fallbackFont:t,sizeAdjust:Di(a),ascentOverride:Di(e.ascent/e.unitsPerEm/a),descentOverride:Di(Math.abs(e.descent)/e.unitsPerEm/a),lineGapOverride:Di(e.lineGap/e.unitsPerEm/a)}}async function ki(e){let t=e.replaceAll(/\s+/g,``).replace(/^(.)/,e=>e.toLowerCase());try{let e=await import(`@capsizecss/metrics/${t}`);if(typeof e!=`object`||!e||!(`default`in e))return null;let n=e.default;return typeof n!=`object`||!n||!(`ascent`in n)||!(`descent`in n)||!(`lineGap`in n)||!(`unitsPerEm`in n)||!(`xWidthAvg`in n)||typeof n.ascent!=`number`||typeof n.descent!=`number`||typeof n.lineGap!=`number`||typeof n.unitsPerEm!=`number`||typeof n.xWidthAvg!=`number`?null:{ascent:n.ascent,descent:n.descent,lineGap:n.lineGap,unitsPerEm:n.unitsPerEm,xWidthAvg:n.xWidthAvg,category:`category`in n&&typeof n.category==`string`?n.category:void 0}}catch{return null}}function Ai(e){return e===`serif`?`Times New Roman`:`Arial`}const ji=/* @__PURE__ */ new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`]);function Mi(e){return e===`serif`?`serif`:e===`monospace`?`monospace`:`sans-serif`}function Ni(e){return(e??[]).some(e=>ji.has(e))}function Pi(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function Fi(e,t){return`url("${Pi(e)}") format("${t}")`}function Ii(e){let t=e.toLowerCase();return t.endsWith(`.woff2`)?`woff2`:t.endsWith(`.woff`)?`woff`:t.endsWith(`.ttf`)?`truetype`:t.endsWith(`.otf`)?`opentype`:`woff2`}function Li(e){return e===`woff`?`font/woff`:e===`truetype`?`font/ttf`:e===`opentype`?`font/otf`:`font/woff2`}function Ri(e){let t=e.src.map(e=>Fi(e.url,e.format)).join(`, `),n=(e.declarations??[]).map(e=>` ${e.prop}: ${e.value};`).join(`
|
|
50
|
+
`),r=`@font-face {\n font-family: "${Pi(e.family)}";\n src: ${t};\n font-display: ${e.display};\n font-weight: ${e.weight};\n font-style: ${e.style};\n`;return e.unicodeRange!=null&&e.unicodeRange!==``&&(r+=` unicode-range: ${e.unicodeRange};\n`),n!==``&&(r+=`${n}\n`),r+=`}
|
|
51
|
+
`,r}function zi(e,t,n,r=`sans-serif`){let i=[`"${Pi(e)}"`];n&&i.push(`"${Pi(`${e} Fallback`)}"`);for(let e of t??[])i.push(e.includes(` `)?`"${Pi(e)}"`:e);return Ni(t)||i.push(r),i.join(`, `)}function Bi(e){return e??`swap`}function Vi(e){return e==null?`400`:String(e)}function Hi(e){return e??`normal`}const Ui=/* @__PURE__ */ new Map,Wi=/* @__PURE__ */ new Map;function Gi(e){return!c(e)||!Array.isArray(e.familyMetadataList)?!1:e.familyMetadataList.every(e=>c(e)&&typeof e.family==`string`&&e.family!==``)}function Ki(e){let t=e.replace(/^\)\]\}'\n?/,``);return JSON.parse(t)}function qi(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function Ji(e){let t=qi((e.subsets??[]).filter(e=>e!==`menu`&&e!==``)),n=(e.axes??[]).filter(e=>typeof e.tag==`string`&&e.tag!==``&&typeof e.min==`number`&&typeof e.max==`number`).map(e=>({tag:e.tag,min:e.min,max:e.max})).sort((e,t)=>e.tag.localeCompare(t.tag));return{family:e.family,subsets:t,axisRanges:n}}function Yi(e){if(!Gi(e))throw Error(`Unexpected fonts.google.com/metadata/fonts shape`);let t=/* @__PURE__ */ new Map;for(let n of e.familyMetadataList){let e=Ji(n);t.set(e.family,e)}return t}async function Xi(e){let t=Ui.get(e);if(t!=null)return t;let n=Wi.get(e);if(n!=null)return n;let r=Promise.resolve().then(async()=>{let t=O.join(e,`google-fonts-metadata.json`);if(E.existsSync(t))try{let n=Yi(Ki(E.readFileSync(t,`utf8`)));return Ui.set(e,n),n}catch{try{E.unlinkSync(t)}catch{}}let n=await fetch(`https://fonts.google.com/metadata/fonts`,{headers:{"User-Agent":`rari-google-font-meta`},signal:AbortSignal.timeout(3e4)});if(!n.ok)throw Error(`Failed to fetch Google font metadata: ${n.status} ${n.statusText}`);let r=await n.text(),i=Yi(Ki(r));return Ti(e),E.writeFileSync(t,r.replace(/^\)\]\}'\n?/,``)),Ui.set(e,i),i});return Wi.set(e,r),r.finally(()=>{Wi.get(e)===r&&Wi.delete(e)})}async function Zi(e,t){try{return(await Xi(e)).get(t)??null}catch(e){return console.warn(`[rari/font] Failed to load Google font metadata for ${t}:`,e),null}}function Qi(e,t,n){let r=t.subsets!=null&&t.subsets.length>0,i=r?t.preload!==!1:t.preload===!0,a=t.subsets;if(i&&!r&&console.warn(`[rari/font] ${e}: \`preload\` is true but no \`subsets\` were specified. Specify subsets to avoid downloading unused glyphs, or set \`preload: false\`.`),a==null||a.length===0||n==null||n.length===0)return;let o=new Set(n.map(e=>e.toLowerCase())),s=[...new Set(a.map(e=>e.toLowerCase())).difference(o)];s.length!==0&&console.warn(`[rari/font] ${e}: unknown subset(s) ${s.map(e=>JSON.stringify(e)).join(`, `)}. Available: ${n.join(`, `)}`)}const $i=1e4,ea=/* @__PURE__ */ new Set([`fonts.gstatic.com`]);function ta(e){let t=URL.parse(e);if(t==null)throw Error(`Invalid Google font URL: ${e}`);if(t.protocol!==`https:`)throw Error(`Google font URL must use HTTPS: ${e}`);if(!ea.has(t.hostname))throw Error(`Google font URL host not allowlisted (${t.hostname}): ${e}. Allowed: ${[...ea].join(`, `)}`);return t}function na(e){return e.subsets!=null&&e.subsets.length>0?e.preload!==!1:e.preload===!0}function ra(e){return e.trim().replaceAll(` `,`+`)}function ia(e){if(e==null)return[`400`];if(Array.isArray(e)){let t=e.map(String);return t.length>0?t:[`400`]}return[String(e)]}const aa=/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)$/;function oa(e){return aa.test(e.trim())}function sa(e){return e===`variable`||typeof e==`string`&&oa(e)?!0:Array.isArray(e)?e.some(e=>e===`variable`||typeof e==`string`&&oa(e)):!1}function ca(e){if(typeof e==`string`){let t=aa.exec(e.trim());if(t!=null)return`${t[1]}..${t[2]}`}if(Array.isArray(e))for(let t of e){if(typeof t!=`string`)continue;let e=aa.exec(t.trim());if(e!=null)return`${e[1]}..${e[2]}`}return`100..900`}function la(e,t){if(e==null)return null;let n=e.find(e=>e.tag===t);return n==null?null:`${n.min}..${n.max}`}function ua(e,t){if(sa(e))return da(e,t);if(e!=null){let t=ia(e);if(t.length===1)return`${t[0]}..${t[0]}`}return la(t,`wght`)??`100..900`}function da(e,t){if(typeof e==`string`&&oa(e))return ca(e);if(Array.isArray(e)){for(let t of e)if(typeof t==`string`&&oa(t))return ca(t)}return la(t,`wght`)??ca(e)}function fa(e){if(e==null)return[`normal`];if(typeof e==`string`)return[e];let t=e.filter(e=>e!==``);return t.length>0?[...t]:[`normal`]}function pa(e){let t=(e.axes??[]).map(e=>e.trim()).filter(Boolean),n=[];for(let e of t)n.includes(e)||n.push(e);return n}function ma(e){return e==null||sa(e)?null:ia(e)}function ha(e,t,n){let r=ra(e),i=Bi(t.display),a=fa(t.style),o=a.includes(`italic`),s=a.includes(`normal`)||!o,c=pa(t);return`https://fonts.googleapis.com/css2?family=${r}:${sa(t.weight)||c.length>0?ga(t,n,c,o,s):ya(t.weight,o,s)}&display=${i}`}function ga(e,t,n,r,i){let a=[`wght`,...n.filter(e=>e!==`wght`&&e!==`ital`)].sort((e,t)=>e.localeCompare(t)),o=ma(e.weight),s=(e,n)=>e===`wght`?n:la(t,e)??`1..1000`;if(o!=null)return _a(a,o,s,r,i);let c=ua(e.weight,t);return va(a,a.map(e=>s(e,c)),r,i)}function _a(e,t,n,r,i){let a=t.map(t=>e.map(e=>n(e,t)).join(`,`));return r&&i?`ital,${e.join(`,`)}@${[...a.map(e=>`0,${e}`),...a.map(e=>`1,${e}`)].join(`;`)}`:r?`ital,${e.join(`,`)}@${a.map(e=>`1,${e}`).join(`;`)}`:e.length===1&&e[0]===`wght`?`wght@${t.join(`;`)}`:`${e.join(`,`)}@${a.join(`;`)}`}function va(e,t,n,r){return n&&r?`ital,${e.join(`,`)}@0,${t.join(`,`)};1,${t.join(`,`)}`:n?`ital,${e.join(`,`)}@1,${t.join(`,`)}`:e.length===1&&e[0]===`wght`?`wght@${t[0]}`:`${e.join(`,`)}@${t.join(`,`)}`}function ya(e,t,n){let r=ia(e);return t&&n?`ital,wght@${[...r.map(e=>`0,${e}`),...r.map(e=>`1,${e}`)].join(`;`)}`:t?`ital,wght@${r.map(e=>`1,${e}`).join(`;`)}`:`wght@${r.join(`;`)}`}function ba(e){let t=[],n=e.split(`@font-face`);for(let e=1;e<n.length;e+=1){let r=n[e-1]??``,i=n[e]??``,a=i.indexOf(`{`),o=i.indexOf(`}`,a);if(a===-1||o===-1)continue;let s=i.slice(a+1,o),c=/\/\*\s*([\w-]+)\s*\*\/\s*$/.exec(r)?.[1]??null,l=/font-family:\s*'([^']+)'/.exec(s)?.[1]??/font-family:\s*"([^"]+)"/.exec(s)?.[1],u=/font-style:\s*([^;\s]+)\s*;/.exec(s)?.[1]??`normal`,d=/font-weight:([^;]+);/.exec(s)?.[1]?.trim()??`400`,f=/src:\s*url\(([^)]+)\)/.exec(s)?.[1]?.replaceAll(/['"]/g,``),p=/unicode-range:([^;]+);/.exec(s)?.[1]?.trim()??null;l!=null&&f!=null&&f!==``&&t.push({family:l,style:u,weight:d,url:f,subset:c,unicodeRange:p})}return t}function xa(e,t){if(t==null||t.length===0)return[...e];let n=new Set(t.map(e=>e.toLowerCase()));return e.filter(e=>e.subset!=null&&n.has(e.subset.toLowerCase()))}async function Sa(e,t){if(E.existsSync(t))return E.readFileSync(t);let n=ta(e).href,r=null;for(let e=0;e<=3;e+=1){let e=await fetch(n,{signal:AbortSignal.timeout($i),redirect:`manual`});if(e.status>=300&&e.status<400){let t=e.headers.get(`location`);if(t==null||t===``)throw Error(`Font download redirect missing Location from ${n}`);n=ta(new URL(t,n).href).href;continue}r=e;break}if(r==null)throw Error(`Too many redirects downloading font ${e}`);if(!r.ok)throw Error(`Failed to download font ${e}: ${r.status} ${r.statusText}`);let i=Buffer.from(await r.arrayBuffer());return Ti(O.dirname(t)),E.writeFileSync(t,i),i}async function Ca(e,t,n){let r=await Zi(n,e);Qi(e,t,r?.subsets);let i=ha(e,t,r?.axisRanges),a=O.join(n,`${F(i)}.css`),o;if(E.existsSync(a))o=E.readFileSync(a,`utf8`);else{let t=await fetch(i,{headers:{"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36`},signal:AbortSignal.timeout($i)});if(!t.ok)throw Error(`Failed to fetch Google Font CSS for ${e}: ${t.status} ${t.statusText}`);o=await t.text(),Ti(n),E.writeFileSync(a,o)}let s=xa(ba(o),t.subsets);if(s.length===0)throw Error(`No @font-face rules returned for Google font "${e}"`);let c=Bi(t.display),l=na(t),u=[];for(let r of s){let i=ta(r.url),a=F(r.url),o=O.extname(i.pathname)||`.woff2`,s=`${e.replaceAll(/\s+/g,``)}-${r.weight}-${r.style}-${a}${o}`,d=O.join(n,s);await Sa(r.url,d),u.push({family:r.family,style:Hi(r.style),weight:Vi(r.weight),display:c,src:[{url:``,format:Ii(d)}],preload:l,variable:t.variable,fallback:t.fallback,adjustFontFallback:t.adjustFontFallback!==!1&&void 0,unicodeRange:r.unicodeRange??void 0,filePaths:[d]})}return u}function wa(e){return e.replaceAll(`_`,` `)}function Ta(e){return typeof e==`string`?[{path:e}]:e.map(e=>({...e}))}function Ea(e,t,n){let r=Bi(e.display),i=e.preload!==!1,a=Ta(e.src);if(a.length===0)throw Error("rari/font/local: `src` must include at least one font file");let o=a.map(r=>{let i=O.isAbsolute(r.path)?r.path:O.resolve(t,r.path);if(!E.existsSync(i))throw Error(`rari/font/local: font file not found: ${r.path} (from ${t})`);let a=O.relative(n,i);if(a.startsWith(`..`)||O.isAbsolute(a))throw Error(`rari/font/local: font file must be inside the project: ${r.path}`);return{absolute:i,weight:Vi(r.weight??e.weight),style:Hi(r.style??e.style),familyBase:O.basename(i,O.extname(i))}}),s=o[0].familyBase;return o.map(t=>({family:s,style:t.style,weight:t.weight,display:r,src:[{url:``,format:Ii(t.absolute)}],preload:i,variable:e.variable,fallback:e.fallback,adjustFontFallback:e.adjustFontFallback,declarations:e.declarations,filePaths:[t.absolute]}))}function Da(e,t){if(e[t]!==`{`)return null;try{let{json:n,end:r}=Oa(e,t);return typeof n!=`object`||!n||Array.isArray(n)?null:{value:n,end:r}}catch{return null}}function G(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]??``);)n+=1;return n}function Oa(e,t){let n=G(e,t),r=e[n];if(r===`{`)return Ma(e,n);if(r===`[`)return ja(e,n);if(r===`'`||r===`"`)return ka(e,n);if(r===`-`||r>=`0`&&r<=`9`)return Aa(e,n);if(e.startsWith(`true`,n))return{json:!0,end:n+4};if(e.startsWith(`false`,n))return{json:!1,end:n+5};if(e.startsWith(`null`,n))return{json:null,end:n+4};throw Error(`Unsupported token at ${n}`)}function ka(e,t){let n=e[t],r=t+1,i=``;for(;r<e.length;){let t=e[r];if(t===`\\`){if(r+1>=e.length)throw Error(`Unterminated string escape`);i+=e[r+1],r+=2;continue}if(t===n)return{json:i,end:r+1};i+=t,r+=1}throw Error(`Unterminated string`)}function Aa(e,t){let n=/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?/i.exec(e.slice(t));if(n==null)throw Error(`Invalid number`);return{json:Number(n[0]),end:t+n[0].length}}function ja(e,t){let n=[],r=G(e,t+1);if(e[r]===`]`)return{json:n,end:r+1};for(;r<e.length;){let t=Oa(e,r);if(n.push(t.json),r=G(e,t.end),e[r]===`,`){if(r=G(e,r+1),e[r]===`]`)return{json:n,end:r+1};continue}if(e[r]===`]`)return{json:n,end:r+1};throw Error(`Expected comma or ]`)}throw Error(`Unterminated array`)}function Ma(e,t){let n={},r=G(e,t+1);if(e[r]===`}`)return{json:n,end:r+1};for(;r<e.length;){let t=Na(e,r),i=t.key;if(r=t.end,e[r]!==`:`)throw Error(`Expected :`);let a=Oa(e,r+1);if(n[i]=a.json,r=G(e,a.end),e[r]===`,`){if(r=G(e,r+1),e[r]===`}`)return{json:n,end:r+1};continue}if(e[r]===`}`)return{json:n,end:r+1};throw Error(`Expected comma or }`)}throw Error(`Unterminated object`)}function Na(e,t){let n=t;if(e[n]===`'`||e[n]===`"`){let t=ka(e,n);return{key:t.json,end:G(e,t.end)}}let r=/^[A-Z_$][\w$]*/i.exec(e.slice(n));if(r==null)throw Error(`Expected property name`);return{key:r[0],end:G(e,n+r[0].length)}}const Pa=`rari/font/local`,Fa=`rari/font/google`,Ia=`\0rari-font-css:`,La=/\.(?:woff2?|ttf|otf)$/i;function Ra(e){if(e!=null){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}}function za(e){if(e===`auto`||e===`block`||e===`swap`||e===`fallback`||e===`optional`)return e}function Ba(e){let t=e.src,n;if(typeof t==`string`)n=t;else if(Array.isArray(t))n=t.map(e=>{if(typeof e==`string`)return{path:e};if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`rari/font/local: invalid src entry`);let t=e.path;if(typeof t!=`string`)throw Error(`rari/font/local: src.path must be a string`);return{path:t,weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0}});else throw TypeError("rari/font/local: `src` is required");return{src:n,display:za(e.display),weight:typeof e.weight==`string`||typeof e.weight==`number`?e.weight:void 0,style:typeof e.style==`string`?e.style:void 0,variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ra(e.fallback),adjustFontFallback:e.adjustFontFallback===!1?!1:e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:void 0,declarations:Va(e.declarations)}}function Va(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(typeof n!=`object`||!n||Array.isArray(n))continue;let e=n.prop,r=n.value;typeof e==`string`&&typeof r==`string`&&t.push({prop:e,value:r})}return t.length>0?t:void 0}function Ha(e){let t=e.weight,n=e.style;return{weight:typeof t==`string`||typeof t==`number`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`||typeof e==`number`):void 0,style:typeof n==`string`?n:Array.isArray(n)?n.filter(e=>typeof e==`string`):void 0,subsets:Ra(e.subsets),display:za(e.display),variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ra(e.fallback),adjustFontFallback:typeof e.adjustFontFallback==`boolean`?e.adjustFontFallback:void 0,axes:Ra(e.axes)}}function Ua(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`)n+=1;else if(t===`)`&&(--n,n===0))return r}return-1}async function Wa(e){try{let t=await je(E.readFileSync(e));return{ascent:t.ascent,descent:t.descent,lineGap:t.lineGap,unitsPerEm:t.unitsPerEm,xWidthAvg:t.xWidthAvg}}catch{return null}}async function Ga(e,t){let n=await ki(t);if(e.adjustFontFallback===!1)return{overrides:null,metrics:n};let r=e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:null;return n??=await Wa(e.filePaths[0]),n==null?{overrides:null,metrics:n}:(r??=Ai(n.category),{overrides:Oi(n,r),metrics:n})}function Ka(e,t){return t==null?``:`@font-face {\n font-family: "${e} Fallback";\n src: local("${t.fallbackFont}");\n ascent-override: ${t.ascentOverride};\n descent-override: ${t.descentOverride};\n line-gap-override: ${t.lineGapOverride};\n size-adjust: ${t.sizeAdjust};\n}\n`}async function qa(e,t,n){let r=[],i=[],a=[];for(let o of e){if(o.filePaths.length===0)continue;let e=o.filePaths[0],s=E.readFileSync(e),c=F(s);a.push(c);let l=Si(e,c,t);r.push({fileName:l,source:s}),i.push({...o,family:n,src:[{url:Ci(l),format:o.src[0]?.format??`woff2`}]})}if(i.length===0)throw Error(`rari/font: no font files resolved`);let o=i[0],s=JSON.stringify({display:o.display,weight:i.map(e=>e.weight),style:i.map(e=>e.style),fallback:o.fallback??null,adjustFontFallback:o.adjustFontFallback??null,declarations:o.declarations??null,unicodeRange:i.map(e=>e.unicodeRange??null),variable:o.variable??null}),c=F(`${a.join(`|`)}|${n}|${s}`),l=Ei(`rari_font`,c),u=o.variable==null?null:Ei(`rari_font_var`,c),d=await Ga(o,n),f=d.overrides,p=d.metrics,m=``;for(let e of i)m+=Ri(e);m+=Ka(n,f);let h=zi(n,o.fallback,f!=null,Mi(p?.category));m+=`.${l} {\n font-family: ${h};\n}\n`,o.variable!=null&&u!=null&&(m+=`.${u} {\n ${o.variable}: ${h};\n}\n`);let g=Number(o.weight),_={className:l,style:{fontFamily:h,fontWeight:Number.isFinite(g)?g:o.weight,fontStyle:o.style===`normal`?void 0:o.style},variable:u??void 0},v=i.filter(e=>e.preload).flatMap(e=>e.src.map(e=>e.url)).filter(e=>e!==``);return{font:_,css:m,cssId:`${Ia}${c}.css`,assets:r,preloadUrls:v}}function Ja(e){let t=[];for(let n=0;n<e.length;n+=1)t.push(!0);let n=(e,n)=>{for(let r=e;r<n;r+=1)t[r]=!1},r=0;for(;r<e.length;){let t=Ya(e,r);if(t!=null){n(r,t),r=t;continue}r+=1}return t}function Ya(e,t){let n=e.charCodeAt(t);if(n===47&&e.charCodeAt(t+1)===47){let n=e.indexOf(`
|
|
52
|
+
`,t+2);return n===-1?e.length:n}if(n===47&&e.charCodeAt(t+1)===42){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}return n===34||n===39||n===96?oo(e,t):null}function Xa(e,t){let n=Ja(e),r=t.replaceAll(`/`,`\\/`),i=RegExp(`import\\s+(\\w+)\\s*,\\s*\\{([^}]+)\\}\\s*from\\s*['"]${r}['"]`,`g`),a=RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*['"]${r}['"]`,`g`),o=RegExp(`import\\s+(\\w+)\\s*from\\s*['"]${r}['"]`,`g`),s=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.split(/\s+as\s+/),n=t[0]?.trim()??``;return{imported:n,local:t[1]?.trim()??n}}).filter(e=>e.imported!==``&&e.local!==``),c=[],l=[],u=[],d=e=>u.some(t=>e>=t.start&&e<t.end);for(let t of e.matchAll(i))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),l.push(t[1]),c.push(...s(t[2])));for(let t of e.matchAll(a))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),c.push(...s(t[1])));for(let t of e.matchAll(o))n[t.index]&&!d(t.index)&&(u.push({start:t.index,end:t.index+t[0].length}),l.push(t[1]));return{names:c.filter(e=>e.imported!==``),defaultNames:l.filter(e=>e!==``),statements:u}}function Za(e,t){let n=Ja(e),r=t.replaceAll(`/`,`\\/`),i=RegExp(`import\\s+\\*\\s+as\\s+\\w+\\s+from\\s*['"]${r}['"]`,`g`),a=RegExp(`import\\s*['"]${r}['"]`,`g`);for(let t of e.matchAll(i))if(n[t.index])return!0;for(let t of e.matchAll(a))if(n[t.index])return!0;return!1}function Qa(e){let t=[`fontFamily: ${JSON.stringify(e.style.fontFamily)}`,e.style.fontWeight==null?null:`fontWeight: ${JSON.stringify(e.style.fontWeight)}`,e.style.fontStyle==null?null:`fontStyle: ${JSON.stringify(e.style.fontStyle)}`].filter(Boolean),n=e.variable==null?``:` variable: ${JSON.stringify(e.variable)},\n`;return`{\n className: ${JSON.stringify(e.className)},\n style: { ${t.join(`, `)} },\n${n}}`}function $a(e){return e>=65&&e<=90||e>=97&&e<=122||e===36||e===95||e>=128}function eo(e){return $a(e)||e>=48&&e<=57}function to(e,t){let n=e.indexOf(`
|
|
53
|
+
`,t+2);return n===-1?e.length:n+1}function no(e,t){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}function ro(e,t){let n=t,r=1;for(;n<e.length&&r>0;){let t=e.charCodeAt(n);if(t===34||t===39||t===96){n=oo(e,n);continue}if(t===47&&e.charCodeAt(n+1)===47){n=to(e,n);continue}if(t===47&&e.charCodeAt(n+1)===42){n=no(e,n);continue}t===123?r+=1:t===125&&--r,n+=1}return n}function io(e,t,n){let r=t+1;for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===n)return r+1;r+=1}return r}function ao(e,t){let n=t+1;for(;n<e.length;){let t=e.charCodeAt(n);if(t===92){n+=2;continue}if(t===96)return n+1;if(t===36&&e.charCodeAt(n+1)===123){n=ro(e,n+2);continue}n+=1}return n}function oo(e,t){let n=e.charCodeAt(t);return n===96?ao(e,t):io(e,t,n)}function so(e,t){let n=e.charCodeAt(t);return n===47&&e.charCodeAt(t+1)===47?to(e,t):n===47&&e.charCodeAt(t+1)===42?no(e,t):n===34||n===39||n===96?oo(e,t):null}function co(e,t,n){if(!$a(e.charCodeAt(n))||!e.startsWith(t,n))return null;let r=n+t.length,i=n===0?0:e.charCodeAt(n-1);if(n!==0&&eo(i)||r<e.length&&eo(e.charCodeAt(r)))return null;let a=r;for(;a<e.length&&(e[a]===` `||e[a]===` `||e[a]===`
|
|
54
|
+
`||e[a]===`\r`);)a+=1;return e[a]===`(`?{start:n,openParen:a}:null}function lo(e,t){let n=[],r=0;for(;r<e.length;){let i=so(e,r);if(i!=null){r=i;continue}let a=co(e,t,r);if(a!=null){n.push(a),r=a.openParen+1;continue}r+=1}return n}async function uo(e,t,n,r){if(!e.includes(`rari/font/`))return null;let i=Xa(e,Pa),a=Xa(e,Fa);if(Za(e,Pa)||Za(e,Fa))throw Error("rari/font only supports default imports from `rari/font/local` and named imports from `rari/font/google` (optionally with `as`). Namespace and side-effect imports are not supported.");if(i.statements.length===0&&a.statements.length===0)return null;let o=e,s=[],c=[],l=[],u=/* @__PURE__ */ new Set,d=O.dirname(t),f=O.join(n,`node_modules`,`.cache`,`rari-fonts`),p=[...i.statements,...a.statements].map(e=>({start:e.start,end:e.end})),m=(e,t,n)=>{for(let e of p)e.start>=t&&(e.start+=n,e.end+=n)},h=async(e,t)=>{let n=t=>{throw Error(`rari/font: failed to transform \`${e}()\` call: ${t}`)};for(let r of lo(o,e).sort((e,t)=>t.start-e.start)){let e=Ua(o,r.openParen);e===-1&&n(`unbalanced parentheses`);let i=fo(o,r.openParen,e,n),a=await t(i.optionsLiteral);s.push({id:a.cssId,css:a.css}),u.add(a.cssId);for(let e of a.assets)c.push(e);for(let e of a.preloadUrls)l.includes(e)||l.push(e);let d=Qa(a.font);m(r.start,i.spliceEnd,d.length-(i.spliceEnd-r.start)),o=o.slice(0,r.start)+d+o.slice(i.spliceEnd)}};for(let e of i.defaultNames)await h(e,async e=>{if(e==null)throw Error(`rari/font/local: options object required`);let t=Ea(Ba(e),d,n),i=`Rari ${O.basename(t[0].filePaths[0],O.extname(t[0].filePaths[0]))}`;return qa(t.map(e=>Object.assign({},e,{family:i})),r,i)});for(let e of a.names)await h(e.local,async t=>{let n=t==null?{}:Ha(t),i=wa(e.imported);return qa(await Ca(i,n,f),r,i)});let g=[...i.defaultNames,...a.names.map(e=>e.local)];for(let e of g)if(lo(o,e).length>0)throw Error(`rari/font: failed to transform all \`${e}()\` calls; leaving imports in place`);for(let e of p.sort((e,t)=>t.start-e.start))o=o.slice(0,e.start)+o.slice(e.end);let _=[...u].map(e=>`import ${JSON.stringify(e)};`).join(`
|
|
55
|
+
`);return _!==``&&(o=ho(o,_)),o===e?null:{code:o,cssModules:s,assets:c,preloadUrls:l}}function fo(e,t,n,r){let i=e.slice(t+1,n).trim();if(i===``)return{optionsLiteral:null,spliceEnd:n+1};i.startsWith(`{`)||r(`options must be a static object literal`);let a=Da(e,e.indexOf(`{`,t));a??r(`options must be a static object literal`);let o=a.end;for(;o<e.length&&/\s/.test(e[o]??``);)o+=1;return e[o]!==`)`&&r(`options must be a static object literal`),{optionsLiteral:a.value,spliceEnd:o+1}}function po(e,t){let n=t;for(;n<e.length;){let t=e[n];if(t===` `||t===` `||t===`\r`||t===`
|
|
56
|
+
`){n+=1;continue}if(t===`/`&&e[n+1]===`/`){n=to(e,n);continue}if(t===`/`&&e[n+1]===`*`){n=no(e,n);continue}break}return n}function mo(e,t){let n=e[t];if(n!==`'`&&n!==`"`||!e.startsWith(`use client`,t+1)&&!e.startsWith(`use server`,t+1)||e[t+11]!==n)return null;let r=t+12;return e[r]===`;`&&(r+=1),po(e,r)}function ho(e,t){let n=+(e.charCodeAt(0)===65279),r=0;for(;;){n=po(e,n);let t=mo(e,n);if(t==null)break;n=t,r=n}return r===0?`${t}\n${e}`:`${e.slice(0,r)}${t}\n${e.slice(r)}`}function go(e){return e===`.woff`?`font/woff`:e===`.ttf`?`font/ttf`:e===`.otf`?`font/otf`:`font/woff2`}function _o(e){return e===`.woff`?`woff`:e===`.ttf`?`truetype`:e===`.otf`?`opentype`:`woff2`}function vo(e,t){let n=O.resolve(e,t),r;try{r=E.realpathSync(e)}catch{r=O.resolve(e)}let i;try{i=E.realpathSync(n)}catch{return null}let a=O.relative(r,i);if(a.startsWith(`..`)||O.isAbsolute(a))return null;try{if(!E.statSync(i).isFile()||!La.test(i))return null}catch{return null}return i}function yo(e,t){if(typeof t==`function`)return!!t(e,void 0,!1);if(typeof t==`string`)return e===t;let{lastIndex:n}=t,r=t.test(e);return t.lastIndex=n,r}function bo(e,t,n,r){return e==null?!1:typeof e==`function`?!!e(t,n,r):typeof e==`string`||e instanceof RegExp?yo(t,e):e.some(e=>typeof e==`function`?!!e(t,n,r):yo(t,e))}function xo(e,t){e.rolldownOptions??={};let n=e.rolldownOptions.external;e.rolldownOptions.external=(e,r,i)=>wi(e,t)?!0:bo(n,e,r,i)}function So(){let e=process.cwd(),t=`assets`,n=O.join(e,`dist`,`client`),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map,a=/* @__PURE__ */ new Set;return{name:`rari:font`,enforce:`pre`,configResolved(r){let i=Ht(r);e=i.projectRoot,t=i.assetsDir,n=i.outDir,xo(r.build,a);for(let e of Object.values(r.environments))xo(e.build,a)},resolveId(e){return e.startsWith(Ia)?e:null},load(e){return e.startsWith(Ia)?r.get(e)??null:null},async transform(n,o){let s=await uo(n,o,e,t);if(s==null)return null;for(let e of s.cssModules)r.set(e.id,e.css);for(let e of s.assets)i.set(e.fileName,e.source),a.add(Ci(e.fileName));for(let e of s.preloadUrls)Ir(`<link rel="preload" href="${e}" as="font" type="${Li(_o(O.extname(e).toLowerCase()))}" crossorigin />`);return{code:s.code,map:null}},generateBundle(){for(let[e,t]of i)this.emitFile({type:`asset`,fileName:e,source:t})},configureServer(e){e.middlewares.use((e,t,r)=>{let a=e.url?.split(`?`)[0];if(a==null||a===``){r();return}let o;try{o=decodeURIComponent(a.replace(/^\//,``))}catch{r();return}let s=i.get(o);if(s!=null){t.setHeader(`Content-Type`,go(O.extname(o).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),t.end(s);return}let c=vo(n,o);if(c==null){r();return}t.setHeader(`Content-Type`,go(O.extname(c).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),E.createReadStream(c).pipe(t)})}}}var Co=class extends Error{status;statusText;bodyPreview;constructor(e,t,n){super(`HTTP ${e}: ${t}`),this.name=`HttpError`,this.status=e,this.statusText=t,this.bodyPreview=n}};async function wo(e){if(!e.ok){let t;try{t=await e.text()}catch{t=`<unable to read response body>`}let n=t.length>200?`${t.slice(0,200)}...`:t;throw new Co(e.status,e.statusText,n)}}var To=class{errorCount=0;maxErrors;resetTimeout;resetTimer=null;lastError=null;constructor(e={}){this.maxErrors=e.maxErrors??5,this.resetTimeout=e.resetTimeout??3e4}recordError(e){this.errorCount++,this.lastError=e,this.resetTimer=Se(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=Se(this.resetTimer)}getErrorCount(){return this.errorCount}getLastError(){return this.lastError}hasReachedMaxErrors(){return this.errorCount>=this.maxErrors}handleMaxErrorsReached(){console.error(`[rari] HMR: Maximum error count (${this.maxErrors}) reached. Consider restarting the dev server if issues persist.`)}dispose(){this.reset()}};function Eo(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Set,a=[...t];for(;a.length>0;){let t=a.pop();if(t==null)break;let o=e.get(t);if(o)for(let e of o)r.has(e)||(r.add(e),a.push(e),(n==null||n(e))&&i.add(e))}return i}function Do(e){return c(e)&&e.success===!0&&typeof e.componentId==`string`&&typeof e.filePath==`string`&&typeof e.relativePath==`string`}function Oo(e){return c(e)&&e.success===!1&&typeof e.filePath==`string`&&typeof e.relativePath==`string`&&s(e.error)}function ko(e){return e===`info`||e===`success`||e===`warning`||e===`error`}var Ao=class{serverComponentBuilder;rustServerUrl;pendingUpdates=/* @__PURE__ */ new Map;pendingFiles=/* @__PURE__ */ new Set;batchTimer=null;DEBOUNCE_DELAY=200;errorHandler;logBatch=[];logBatchTimer=null;LOG_BATCH_DELAY=500;constructor(e,t=M()){this.serverComponentBuilder=e,this.rustServerUrl=`http://localhost:${t}`,this.errorHandler=new To({maxErrors:5,resetTimeout:3e4})}getErrorCount(){return this.errorHandler.getErrorCount()}async handleClientComponentUpdate(e,t){let n=O.relative(k.cwd(),e);try{let r=t.moduleGraph.getModuleById(e);r?(t.moduleGraph.invalidateModule(r),this.errorHandler.reset()):this.queueLog(`warning`,`Client component module not found in graph: ${n}`)}catch(e){let t=u(e,String(e));this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(r(e))}return Promise.resolve()}async rebuildAndNotifyNow(e,t){this.serverComponentBuilder.invalidateBuildCacheFor(e);let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),t?.hot.send(`rari:server-component-updated`,{id:n.componentId,t:Date.now()}),n}async handleServerComponentUpdate(e,t){this.pendingFiles.add(e);let n=this.pendingUpdates.get(e);return n&&(clearTimeout(n),this.pendingUpdates.delete(e)),this.batchTimer&&clearTimeout(this.batchTimer),this.batchTimer=setTimeout(()=>{(async()=>{let e=[...this.pendingFiles];if(this.pendingFiles.clear(),this.batchTimer=null,e.length===0)return;let n=this.collectDependentPageComponents(e);for(let e of n)this.serverComponentBuilder.invalidateBuildCacheFor(e);let i=[...e,...n],a=await Promise.allSettled(i.map(async e=>{let t=O.relative(k.cwd(),e);try{let n=await this.serverComponentBuilder.rebuildComponent(e);if(!n.success)throw Error(n.error!=null&&n.error!==``?n.error:`Build failed`);return await this.notifyRustServer(n.componentId,n.bundlePath),{success:!0,componentId:n.componentId,filePath:e,relativePath:t}}catch(n){return{success:!1,filePath:e,relativePath:t,error:r(n)}}})),o=[],s=[];if(a.forEach(e=>{e.status===`fulfilled`&&Do(e.value)?o.push(e.value):e.status===`fulfilled`&&Oo(e.value)?s.push(e.value):e.status===`rejected`&&s.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),o.length>0){let e=Date.now();o.forEach(({componentId:n})=>{t.hot.send(`rari:server-component-updated`,{id:n,t:e})}),this.errorHandler.reset(),t.ws.send({type:`custom`,event:`rari:hmr-error-cleared`,data:{t:e}})}if(s.length>0){let e=Date.now();s.forEach(({relativePath:n,error:r})=>{let i=r.message,a=(r.stack!=null&&r.stack!==``?r.stack:``).substring(0,500);this.queueLog(`error`,`Failed to rebuild: ${n} - ${i}`),this.errorHandler.recordError(r),t.ws.send({type:`custom`,event:`rari:hmr-error`,data:{msg:i,stack:a,file:n,t:e,count:this.errorHandler.getErrorCount(),max:5}})}),this.errorHandler.hasReachedMaxErrors()&&this.queueLog(`error`,`Maximum error count reached (${this.errorHandler.getErrorCount()}). Consider restarting the dev server if issues persist.`)}})()},this.DEBOUNCE_DELAY),Promise.resolve()}relativeBundlePathInsideProject(e){let t=C(e);if(!O.isAbsolute(e))return t;let n=C(O.relative(this.serverComponentBuilder.getProjectRoot(),e));if(n.startsWith(`..`)||O.isAbsolute(n))throw Error(`Bundle path must be inside the project root: ${e}`);return n}assertSuccessfulHmrResponse(e,t,n){if(!c(e))throw Error(`Invalid server response (status ${n}): expected object, got ${typeof e}. Response body: ${t.substring(0,200)}${t.length>200?`...`:``}`);if(e.success===!0)return;let r=typeof e.message==`string`&&e.message!==``?e.message:typeof e.error==`string`&&e.error!==``?e.error:`Component reload failed`;throw Error(r)}async notifyRustServer(e,t){let n=this.relativeBundlePathInsideProject(t);try{let t=await fetch(`${this.rustServerUrl}/_rari/hmr`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`reload-component`,component_id:e,bundle_path:n})});await wo(t);let r=await t.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${t.status}): ${u(e,String(e))}. Response body: ${r.substring(0,200)}${r.length>200?`...`:``}`)}this.assertSuccessfulHmrResponse(i,r,t.status)}catch(e){throw console.error(`[rari] HMR: Failed to notify Rust server:`,e),e}}collectDependentPageComponents(e){return[...Eo(this.serverComponentBuilder.getImportGraph(),e,e=>e.includes(`/app/`)||e.includes(`\\app\\`))]}detectComponentType(e){try{return this.serverComponentBuilder.getModuleAnalysis(e).topLevelUseClient?`client`:`server`}catch{return`unknown`}}queueLog(e,t){this.logBatch.push({type:e,message:t,timestamp:Date.now()}),this.logBatchTimer&&clearTimeout(this.logBatchTimer),this.logBatchTimer=setTimeout(()=>{this.flushLogs()},this.LOG_BATCH_DELAY)}flushLogs(){if(this.logBatch.length===0)return;let e=this.logBatch.reduce((e,t)=>(e[t.type]??=[],e[t.type].push(t),e),{});for(let[t,n]of Object.entries(e))if(ko(t)){if(n.length===1){let e=n[0];this.outputLog(t,e.message)}else{let e=n.map(e=>e.message).join(`
|
|
57
|
+
• `);this.outputLog(t,`${n.length} updates:\n • ${e}`)}}this.logBatch=[],this.logBatchTimer=null}outputLog(e,t){let n=`[rari] HMR:`;switch(e){case`success`:console.warn(`\x1B[32m${n}\x1B[0m ${t}`);break;case`warning`:console.warn(`\x1B[33m${n}\x1B[0m ${t}`);break;case`error`:console.error(`\x1B[31m${n}\x1B[0m ${t}`);break;default:console.warn(`${n} ${t}`)}}dispose(){this.logBatchTimer&&(clearTimeout(this.logBatchTimer),this.flushLogs()),this.batchTimer&&=(clearTimeout(this.batchTimer),null);for(let e of this.pendingUpdates.values())clearTimeout(e);this.pendingUpdates.clear(),this.pendingFiles.clear(),this.errorHandler.dispose()}};function K(e,t){return e.readUInt16BE(t)}function q(e,t){return e.readUInt32BE(t)}function jo(e,t){return e.readUInt32LE(t)}function Mo(e){return e.length<24||e.toString(`ascii`,1,4)!==`PNG`?null:{width:q(e,16),height:q(e,20)}}function No(e){if(e.length<10)return null;let t=e.toString(`ascii`,0,6);return t!==`GIF87a`&&t!==`GIF89a`?null:{width:e.readUInt16LE(6),height:e.readUInt16LE(8)}}function Po(e){return e>=192&&e<=195||e>=197&&e<=199||e>=201&&e<=203||e>=205&&e<=207}function Fo(e,t){if(t+7>=e.length)return null;let n=K(e,t),r=e[t+7]??0,i=8+3*r;if(r<1||n<i||t+n>e.length)return null;let a=K(e,t+3),o=K(e,t+5);return o===0||a===0?null:{height:a,width:o}}function Io(e,t){if(t+1>=e.length)return null;let n=K(e,t);return n<2?null:t+n}function Lo(e){if(e.length<4||e[0]!==255||e[1]!==216)return null;let t=2;for(;t+9<=e.length;){if(e[t]!==255){t+=1;continue}if(t+1>=e.length)return null;let n=e[t+1];if(t+=2,Po(n))return Fo(e,t);if(n===217||n===218)return null;let r=Io(e,t);if(r==null)return null;t=r}return null}function Ro(e,t){return(e[t]??0)|(e[t+1]??0)<<8|(e[t+2]??0)<<16}function zo(e){if(e.length<20||e.toString(`ascii`,0,4)!==`RIFF`||e.toString(`ascii`,8,12)!==`WEBP`)return null;let t=e.toString(`ascii`,12,16);if(t===`VP8X`&&e.length>=30)return{width:Ro(e,24)+1,height:Ro(e,27)+1};if(t===`VP8 `&&e.length>=30)return{width:e.readUInt16LE(26)&16383,height:e.readUInt16LE(28)&16383};if(t===`VP8L`&&e.length>=25){if(e[20]!==47)return null;let t=jo(e,21);return{width:(t&16383)+1,height:(t>>14&16383)+1}}return null}function Bo(e,t,n){if(t+8>n)return null;let r=q(e,t),i=e.toString(`ascii`,t+4,t+8),a=8;if(r===1){if(t+16>n)return null;r=Number(e.readBigUInt64BE(t+8)),a=16}else r===0&&(r=n-t);let o=t+r;return r<a||o>n?null:{type:i,headerSize:a,start:t,end:o}}function*Vo(e,t,n){let r=t;for(;r+8<=n;){let t=Bo(e,r,n);if(t==null)return;yield t,r=t.end}}function Ho(e,t){let n=t.start+t.headerSize;return n+4>t.end?null:{version:e[n]??0,flags:(e[n+1]??0)<<16|(e[n+2]??0)<<8|(e[n+3]??0),dataOffset:n+4}}function Uo(e,t){let n=Ho(e,t);return n==null||n.dataOffset+8>t.end?null:{width:q(e,n.dataOffset),height:q(e,n.dataOffset+4)}}function Wo(e,t){let n=Ho(e,t);return n==null?null:n.version===0?n.dataOffset+2>t.end?null:K(e,n.dataOffset):n.dataOffset+4>t.end?null:q(e,n.dataOffset)}function Go(e,t,n,r){return r<1?t+2>n?null:{itemId:K(e,t),nextOffset:t+2}:t+4>n?null:{itemId:q(e,t),nextOffset:t+4}}function Ko(e,t,n,r,i){let a=t,o=[];for(let t=0;t<r;t+=1)if(i){if(a+2>n)return null;let t=K(e,a);a+=2,o.push(t&32767)}else{if(a+1>n)return null;let t=e[a]??0;a+=1,o.push(t&127)}return{propertyIndexes:o,nextOffset:a}}function qo(e,t){let n=Ho(e,t);if(n==null||n.dataOffset+4>t.end)return null;let r=q(e,n.dataOffset),i=n.dataOffset+4,a=/* @__PURE__ */ new Map,o=!!(n.flags&1);for(let s=0;s<r;s+=1){let r=Go(e,i,t.end,n.version);if(r==null||(i=r.nextOffset,i+1>t.end))return null;let s=e[i]??0;i+=1;let c=Ko(e,i,t.end,s,o);if(c==null)return null;i=c.nextOffset,a.set(r.itemId,c.propertyIndexes)}return a}function Jo(e){for(let t of Vo(e,0,e.length))if(t.type===`meta`)return t;return null}function Yo(e,t,n){let r=1,i=null;for(let a of Vo(e,t.start+t.headerSize,t.end)){if(a.type===`ispe`){let t=Uo(e,a);t!=null&&(n.set(r,t),i??=t)}r+=1}return i}function Xo(e,t){let n=/* @__PURE__ */ new Map,r=null,i=null;for(let a of Vo(e,t.start+t.headerSize,t.end))if(a.type===`ipco`){let t=Yo(e,a,n);i??=t}else a.type===`ipma`&&(r=qo(e,a));return{ispeByIndex:n,associations:r,firstIspe:i}}function Zo(e,t,n){if(e==null||t==null)return null;let r=t.get(e);if(r==null)return null;for(let e of r){let t=n.get(e);if(t!=null)return t}return null}function Qo(e){if(e.length<12||e.toString(`ascii`,4,8)!==`ftyp`)return null;let t=Jo(e);if(t==null)return null;let n=t.start+t.headerSize+4;if(n>t.end)return null;let r=null,i=/* @__PURE__ */ new Map,a=null,o=null;for(let s of Vo(e,n,t.end)){if(s.type===`pitm`){r=Wo(e,s);continue}if(s.type!==`iprp`)continue;let t=Xo(e,s);i=t.ispeByIndex,a=t.associations,o??=t.firstIspe}return Zo(r,a,i)??o}function $o(e){return e.length<4?null:e[0]===137&&e.toString(`ascii`,1,4)===`PNG`?Mo(e):e[0]===255&&e[1]===216?Lo(e):e.toString(`ascii`,0,3)===`GIF`?No(e):e.toString(`ascii`,0,4)===`RIFF`?zo(e):Qo(e)}const es=/\.(?:avif|gif|jpe?g|png|webp)$/i,ts=`\0rari-static-image:`,ns=/* @__PURE__ */ new Set([`raw`,`url`,`inline`,`no-inline`]);function rs(e){let t=e.indexOf(`?`);return t===-1?[]:e.slice(t+1).split(`&`).map(e=>e.split(`=`)[0]??``).filter(Boolean)}function is(e){return rs(e).includes(`rari-static-bypass`)}function as(e){return rs(e).some(e=>ns.has(e))}function os(e,t,n){return bi(e,t,n,{encodeBase:!0})}function ss(e,t,n){return`const src = ${JSON.stringify(e)};\nexport default {\n src,\n width: ${t},\n height: ${n},\n};\n`}function cs(e){return es.test(se(e))&&!is(e)&&!as(e)}function ls(e,t=`assets`){let n=E.readFileSync(e),r=F(n),i=os(e,r,t),a=yi(e,r,t),o=$o(n);if(o==null)throw Error(`[rari] Unable to read dimensions for static image import: ${e}. Pass explicit width/height to <Image>, or convert the file to png/jpeg/webp/gif/avif.`);return{code:ss(i,o.width,o.height),publicPath:i,source:n,fileName:a}}const us=/* @__PURE__ */ new Map,ds=/* @__PURE__ */ new Map;function fs(e,t){let n=us.get(e);if(n!=null)return n;let r=/* @__PURE__ */ new Map;if(E.existsSync(t))try{let e=p(E.readFileSync(t,`utf8`));if(e!=null)for(let[t,n]of Object.entries(e))typeof n==`string`&&r.set(t,n)}catch{}return us.set(e,r),r}function ps(e,t,n){for(let[r,i]of e)i===n&&r!==t&&e.delete(r);e.set(t,n)}function ms(e,t){let n=new Set(t.values());for(let[r,i]of e){if(!E.existsSync(i)){e.delete(r);continue}n.has(i)&&t.get(r)!==i&&e.delete(r)}}function hs(e){return O.basename(e)===`client`?O.dirname(e):e}function gs(e){return O.join(hs(e),`server`,`static-image-sources.json`)}function _s(e,t){let n=hs(e),r=gs(e);if(t.size===0){try{E.unlinkSync(r)}catch(e){if(a(e)!==`ENOENT`)throw e}us.delete(n);return}E.mkdirSync(O.dirname(r),{recursive:!0});let i=Object.fromEntries(t);E.writeFileSync(r,`${JSON.stringify(i,null,2)}\n`)}function vs(e){let t=hs(e);ds.has(t)||ds.set(t,/* @__PURE__ */ new Map)}function ys(e){let t=hs(e),n=ds.get(t);if(n==null)return;let r=fs(t,gs(e));r.clear();for(let[e,t]of n)E.existsSync(t)&&r.set(e,t);_s(e,r),ds.delete(t)}function bs(e,t){let n=hs(e),r=fs(n,gs(e));for(let[e,n]of t)r.set(e,n);let i=ds.get(n);if(i!=null){for(let[e,n]of t)ps(i,e,n);return}ms(r,t),_s(e,r)}function xs(e,t){let n=!1;for(let[r,i]of e)i===t&&(e.delete(r),n=!0);return n}function Ss(e){switch(e){case`.png`:return`image/png`;case`.gif`:return`image/gif`;case`.webp`:return`image/webp`;case`.avif`:return`image/avif`;case`.svg`:return`image/svg+xml`;default:return`image/jpeg`}}function Cs(e){try{return decodeURIComponent(e)}catch{return e}}function ws(e,t,n,r){let i=t?.split(`?`)[0];if(i==null||i===``){r();return}let a=Cs(i),o=e.get(i)??e.get(a);if(o==null||o===``){r();return}n.setHeader(`Content-Type`,Ss(O.extname(o).toLowerCase())),n.setHeader(`Cache-Control`,`no-cache`),E.createReadStream(o).on(`error`,()=>{n.headersSent||(n.statusCode=404),n.end()}).pipe(n)}function Ts(){let e=process.cwd(),t=O.join(e,`dist`,`client`),n=`assets`,r=!1,i=/* @__PURE__ */ new Map;return{name:`rari:static-image`,enforce:`pre`,configResolved(i){let a=Ht(i);e=a.projectRoot,t=a.outDir,n=a.assetsDir,r=i.command===`build`},buildStart(){r&&vs(t)},async resolveId(e,t){if(t==null||t===``||!cs(e))return null;let n=await this.resolve(e,t,{skipSelf:!0});if(n==null||n.id===``)return null;let r=se(n.id);return E.existsSync(r)?ts+r:null},load(e){if(!e.startsWith(ts))return null;let r=e.slice(19),a=ls(r,n);return ps(i,a.publicPath,r),bs(t,i),this.emitFile({type:`asset`,fileName:a.fileName,source:a.source}),a.code},watchChange(e,n){if(n.event!==`delete`)return;let r=se(e);if(!xs(i,r))return;let a=ds.get(hs(t));a!=null&&xs(a,r),bs(t,i)},configureServer(e){e.middlewares.use((e,t,n)=>{ws(i,e.url,t,n)})}}}function Es(e){let t=C(e);return t===`rari/mdx/registry`||t.startsWith(`rari/mdx/registry?`)?!0:t.endsWith(`/mdx/registry.ts`)||t.endsWith(`/mdx/registry.mts`)||t.endsWith(`/mdx/registry.mjs`)||t.endsWith(`/mdx/registry.js`)||t.endsWith(`/mdx/registry`)?t.includes(`/node_modules/rari/`)||t.includes(`/packages/rari/`):!1}function Ds(e,t){let n=e=>{if(E.existsSync(e))for(let r of E.readdirSync(e,{withFileTypes:!0})){let i=O.join(e,r.name);if(r.isDirectory()){if(r.name===`node_modules`||r.name===`.git`||r.name===`dist`)continue;n(i)}else r.isFile()&&r.name.endsWith(`.mdx`)&&t(i)}};for(let t of e)t&&E.existsSync(t)&&n(t)}function Os(e){let t=/* @__PURE__ */ new Set;return Ds(e,e=>{try{let n=E.readFileSync(e,`utf-8`);for(let e of Ce(n))t.add(e)}catch{}}),t}function ks(e,t){try{if(t.get(e).hasDefaultExport)return O.basename(e,O.extname(e));let n=t.getSource(e).match(b);if(n?.[1]!=null&&n[1]!==``)return n[1]}catch{}return O.basename(e,O.extname(e))}function As(e){let t=Os(e.contentDirs.map(t=>O.join(e.projectRoot,t)));if(t.size===0)return[];let n=kr(e.componentScanDirs,e.cache),r=[],i=/* @__PURE__ */ new Set;for(let a of n){let n=ks(a,e.cache);if(n==null||n===``||!t.has(n))continue;let o=Ut(a,e.projectRoot),s=o.startsWith(`/`)?o:`/${o}`,c=n.replace(/[^\w$]/g,`_`);i.has(c)&&(c=`${c}_${r.length}`),i.add(c),r.push({name:n,binding:c,importPath:s,moduleId:o,client:!0})}return r.sort((e,t)=>e.name.localeCompare(t.name))}function js(e){let t=Ns(e.projectRoot,e.mdxOptions),n=e.srcDir??O.join(e.projectRoot,`src`),r=Ls(e.projectRoot,t.componentsDir,Sr(n,Object.values(e.alias??{})));return As({projectRoot:e.projectRoot,componentsDir:t.componentsDir,contentDirs:t.contentDirs,cache:e.cache,componentScanDirs:r})}function Ms(e,t={}){let n=t.importStyle??`root-absolute`,r=t.mode??`vite`;return e.length===0?`import { defineMdxComponents } from 'rari/mdx/define'
|
|
58
58
|
|
|
59
59
|
export const getMDXComponents = defineMdxComponents([])
|
|
60
60
|
`:r===`production`?`import { defineMdxComponents } from 'rari/mdx/define'
|
|
@@ -71,25 +71,25 @@ export const getMDXComponents = defineMdxComponents([
|
|
|
71
71
|
${e.map(e=>` { name: ${JSON.stringify(e.name)}, component: ${e.binding}, id: ${JSON.stringify(e.moduleId)}, client: ${e.client} }`).join(`,
|
|
72
72
|
`)},
|
|
73
73
|
])
|
|
74
|
-
`}function
|
|
75
|
-
`||e===`\r`||e===`\u2028`||e===`\u2029`}function
|
|
76
|
-
`||e===`\r`||e===`\u2028`||e===`\u2029`}function
|
|
77
|
-
`;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;case`v`:return`\v`;case`0`:return`\0`;case`\\`:case`'`:case`"`:case"`":case`/`:return e;default:return null}}function
|
|
78
|
-
`&&(i=t+1),{out:r,i}}let i=
|
|
79
|
-
`&&e.pop(),n+1):i.kind===`block-comment`?a===`*`&&o===`/`?(e.pop(),n+2):n+1:i.kind===`single`||i.kind===`double`?
|
|
80
|
-
`&&e.pop(),{j:n+1}):r.kind===`block-comment`?t[n]===`*`&&t[n+1]===`/`?(e.pop(),{j:n+2}):{j:n+1}:r.kind===`single`||r.kind===`double`||r.kind===`template`?yc(e,r,t,n):null}function xc(e,t,n){let r=t[n],i=t[n+1];return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function Sc(e,t,n){let r=e[t];return r===`[`?{j:t+1,depth:n+1}:r===`]`?{j:t+1,depth:n-1}:r===`{`?{j:t,depth:n,forceRuntime:!0}:{j:t+1,depth:n}}function Cc(e,t){let n=t+1,r=1,i=n,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=bc(a,e,i);if(t!=null){if(t.forceRuntime)return{forceRuntime:!0,endIndex:e.length};i=t.j;continue}let n=xc(a,e,i);if(n!=null){i=n;continue}let o=Sc(e,i,r);if(o.forceRuntime)return{forceRuntime:!0,endIndex:o.j};i=o.j,r=o.depth}return r===0?{...jc(e.slice(n,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}function wc(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(n>=e.length)return null;let r=e[n];return r===`'`||r===`"`||r==="`"?vc(e,n,r):r===`[`?Cc(e,n):{forceRuntime:!0,endIndex:n+1}}function Tc(e,t,n,r){let i=t===0?``:e.charAt(t-1),a=t===0||/[\s;{}]/.test(i);if(n.braceDepth!==0||r.length!==1||!a)return null;if(e.startsWith(`let matcher`,t)||e.startsWith(`var matcher`,t))return{nextI:t,forceRuntime:!0};if(!e.startsWith(`const matcher`,t))return null;let o=t+13;if(o<e.length&&/[\w$]/.test(e.charAt(o)))return{nextI:t+1};let s=o;for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;if(e.charAt(s)!==`=`)return{nextI:t+1};let c=wc(e,s);return c==null||c.forceRuntime?{nextI:t,forceRuntime:!0}:{nextI:c.endIndex,binding:{matcher:c.matcher,forceRuntime:!1}}}function Ec(e,t,n,r){let i=e.at(-1);if(i===void 0)return{nextI:n,forceRuntime:!0};let a=fc(e,t,n);if(a!=null)return{nextI:a};if(i.kind!==`code`)return{nextI:n,forceRuntime:!0};let o=pc(e,t,n);if(o!=null)return{nextI:o};if(mc(i,e,t.charAt(n)))return{nextI:n+1};let s=Tc(t,n,i,e);return s==null?{nextI:n+1}:s.forceRuntime?{nextI:n,forceRuntime:!0}:(s.binding&&r.push(s.binding),{nextI:s.nextI})}function Dc(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=Ec(t,e,r,n);if(i==null||i.forceRuntime)return{forceRuntime:!0};r=i.nextI}return n.length===0?null:n.length>1?{forceRuntime:!0}:n[0]??null}function Oc(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=Ls.exec(e.trim());if(t==null)return null;let n=t[1]||t[6]||``,a=t[3]||t[5]||``;if(n===``||a===``)return null;if(i==null)i=n;else if(i!==n)return null;r.push(a)}return r.length>0?r:null}function kc(e){let t=[];Is.lastIndex=0;for(let n of e.matchAll(Is)){let e=n[1],r=n[2],i=n[4],a=Number.parseInt(n[5],10),o=Number.isFinite(a)?a:void 0;if(e===``||i===``||r!==`redirect`&&r!==`rewrite`)continue;let s=Oc(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:Ys(o)}:{}})}return t}function Ac(e){let t=zs.exec(e);return t==null?null:_c(e,t.index+t[0].length-1)}function jc(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];qs.lastIndex=0;for(let n of e.matchAll(qs)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=oc(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(qs,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function Mc(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=0;r<t;){let i=n.at(-1);if(i===void 0)return null;let a=fc(n,e,r,t);if(a!=null){r=a;continue}if(i.kind!==`code`)return null;let o=pc(n,e,r);if(o!=null){r=o;continue}if(mc(i,n,e.charAt(r))){r+=1;continue}r+=1}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function Nc(e,t){return Mc(e,t)===1}function Pc(e){return e.startsWith(`'`)||e.startsWith(`"`)||e.startsWith("`")}function J(e,t){let n=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`);for(let t of e.matchAll(n)){let n=Pc(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&Nc(e,n))return t}return null}function Fc(e,t){let n=t;for(;n<e.length;){let t=Lc(e,n);if(t!=null){n=t;continue}let r=e.charAt(n);return r===`,`||r===`}`}return!0}function Ic(e,t){let n=t;for(;n<e.length;){let t=Lc(e,n);if(t==null)break;n=t}return n}function Lc(e,t){let n=e.charAt(t),r=e.charAt(t+1);if(/\s/.test(n))return t+1;if(n===`/`&&r===`/`){let n=t+2;for(;n<e.length&&!Zs(e.charAt(n));)n+=1;return n}if(n===`/`&&r===`*`){let n=t+2;for(;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;return n+2}return null}function Rc(e,t){if(e.charAt(t)!==`[`)return null;let n=Ic(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=sc(e,n,r);if(t==null)return{endIndex:e.length,forceRuntime:!0};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{endIndex:t,forceRuntime:!0};let a=oc(i,r);return n=Ic(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function zc(e,t,n,r){return n===`'`||n===`"`||n==="`"?{entered:!0,expectPropertyKey:r&&t.braceDepth===1?!1:r}:{entered:!1,expectPropertyKey:r}}function Bc(e,t,n,r){return n===`{`?(e.braceDepth+=1,{handled:!0,expectPropertyKey:e.braceDepth===1||r}):n===`}`?(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),{handled:!0,expectPropertyKey:!1}):n===`,`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!0}:n===`:`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!1}:{handled:!1,expectPropertyKey:r}}function Vc(e,t,n,r,i,a){if(!r||n.braceDepth!==1||/\s/.test(i))return null;if(i===`.`&&a===`.`&&e.charAt(t+2)===`.`)return{unsafe:!0};if(i===`[`){let n=Rc(e,t);return n?.forceRuntime===!0||n==null?{unsafe:!0}:{unsafe:!1,nextI:n.endIndex,clearExpect:!0}}return{unsafe:!1,clearExpect:!0}}function Hc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=fc(e,t,n);if(a!=null)return{nextI:a,expectPropertyKey:r};if(i.kind!==`code`)return null;let o=t.charAt(n),s=t.charAt(n+1),c=zc(e,i,o,r);if(c.entered)return{nextI:pc(e,t,n)??n+1,expectPropertyKey:c.expectPropertyKey};let l=pc(e,t,n);if(l!=null)return{nextI:l,expectPropertyKey:r};let u=Bc(i,e,o,r);if(u.handled)return{nextI:n+1,expectPropertyKey:u.expectPropertyKey};let d=Vc(t,n,i,r,o,s);return d==null?{nextI:n+1,expectPropertyKey:r}:d.unsafe?{nextI:n,expectPropertyKey:r,unsafe:!0}:{nextI:d.nextI??n+1,expectPropertyKey:!d.clearExpect&&r}}function Uc(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=Hc(t,e,r,n);if(i==null)return!1;if(i.unsafe)return!0;n=i.expectPropertyKey,r=i.nextI}return!1}function Wc(e,t){let n=Pc(t[0]),r=n?t[2]:t[1],i=n?t[3]:t[2];if(r!==`'`&&r!==`"`&&r!=="`")return null;if(r==="`"&&i.includes("${")||!Fc(e,t.index+t[0].length))return{forceRuntime:!0};let a=oc(i,r);return a==null||a===``?{forceRuntime:!0}:{matcher:a,forceRuntime:!1}}function Gc(e){if(!Rs.test(e)||!zs.test(e))return{forceRuntime:!1};let t=Ac(e);if(t==null||Uc(t)||J(t,Bs)!=null||J(t,Us)!=null)return{forceRuntime:!0};let n=J(t,Vs)??J(t,Ws);if(n!=null)return Wc(t,n)??{forceRuntime:!1};let r=J(t,Hs)??J(t,Gs);return r==null?J(t,Js)==null?J(t,/matcher\s*:/)!=null||J(t,Ks)!=null?{forceRuntime:!0}:{forceRuntime:!1}:Dc(e)??{forceRuntime:!0}:Fc(t,r.index+r[0].length)?jc(Pc(r[0])?r[2]:r[1]):{forceRuntime:!0}}function Kc(e){let{matcher:t,forceRuntime:n}=Gc(e);if(n||Ps.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=Fs.test(e),i=kc(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function qc(e){let t=Kc(e.code),n=t.requiresRuntime;return{proxyFile:e.proxyFile,enabled:!0,generated:e.generated??(/* @__PURE__ */ new Date()).toISOString(),rules:t.rules,requiresRuntime:n,...n&&e.bundlePath!=null&&e.bundlePath!==``?{bundlePath:e.bundlePath}:{},...t.matcher==null?{}:{matcher:t.matcher}}}const Jc=/@import\s+(?:url\(\s*)?['"](?![a-zA-Z][a-zA-Z0-9+.-]*:|\/\/|\.\/|\.\.\/|\/)[^'"]+['"][^;]*(?:;|$)/g,Yc=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,Xc=/\.css(?:\?.*)?$/,Zc=/\.module\.css(?:\?.*)?$/i;function Qc(e){return Zc.test(e.replace(/[?#].*$/,``))}function $c(e){return e.replace(Jc,``).trim()}function el(e){if(!/^supports\s*\(/i.test(e))return{supportsCondition:null,rest:e};let t=e.indexOf(`(`),n=0,r=-1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`(`)n++;else if(t===`)`&&(n--,n===0)){r=i;break}}return r===-1?{supportsCondition:null,rest:e}:{supportsCondition:e.slice(t+1,r).trim(),rest:e.slice(r+1).trim()}}function tl(e){if(/^layer\s*\(/i.exec(e)){let t=e.indexOf(`(`),n=e.indexOf(`)`,t);return n===-1?{layerName:null,rest:e}:{layerName:e.slice(t+1,n).trim(),rest:e.slice(n+1).trim()}}return/^layer(?:\s|$)/i.test(e)?{layerName:``,rest:e.replace(/^layer\s*/i,``)}:{layerName:null,rest:e}}function nl(e){let t=e.trim().replace(/^\)\s*/,``),n=tl(t);t=n.rest;let r=el(t);t=r.rest;let i=t.trim()===``?null:t.trim();return{layerName:n.layerName,supportsCondition:r.supportsCondition,mediaQuery:i}}function rl(e,t){let n=e.trim();return n===``?``:(t.layerName!==null&&(n=t.layerName===``?`@layer {\n${n}\n}`:`@layer ${t.layerName} {\n${n}\n}`),t.supportsCondition!=null&&t.supportsCondition!==``&&(n=`@supports (${t.supportsCondition}) {\n${n}\n}`),t.mediaQuery!=null&&t.mediaQuery!==``&&(n=`@media ${t.mediaQuery} {\n${n}\n}`),n)}function il(e,t,n=/* @__PURE__ */ new Set){let r=O.resolve(e);return n.has(r)?``:(n.add(r),t.replace(Yc,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=O.resolve(O.dirname(r),s);try{return!E.existsSync(c)||!E.statSync(c).isFile()?e:rl(al(c,E.readFileSync(c,`utf-8`),new Set(n)),nl(o))}catch{return e}}).trim())}function al(e,t,n=/* @__PURE__ */ new Set){return il(e,$c(t),n)}function ol(e,t){let n=/* @__PURE__ */ new Set;for(let r of Hr(e,t)){if(O.isAbsolute(r)){n.add(O.resolve(r));continue}try{n.add(we(O.join(e,`package.json`)).resolve(r))}catch{}}return n}function sl(e){return E.existsSync(e)&&E.statSync(e).isFile()?e:null}function cl(e,t,n){let r=[t,O.join(n,`package.json`)];for(let t of r)try{let n=sl(we(t).resolve(e));if(n!=null)return n}catch{try{let n=sl(A(import.meta.resolve(e,ke(t).href)));if(n!=null)return n}catch{}}return null}function ll(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Xc.test(i))return null;if(O.isAbsolute(i))return sl(i);if(i.startsWith(`./`)||i.startsWith(`../`))return sl(O.resolve(O.dirname(t),i));let a=T(i,r,n);if(a!=null&&a!==``){let e=sl(a);if(e!=null)return e}return cl(i,t,n)}function ul(e){let t=e.includes(`?`)?e.slice(e.indexOf(`?`)):``;return/(?:\?|&)raw(?:&|$)/.test(t)||/(?:\?|&)url(?:&|$)/.test(t)}function dl(e,t){if(Qc(e)||t.has(O.resolve(e)))return null;try{let t=al(e,E.readFileSync(e,`utf-8`));return t===``?null:t}catch{return null}}function fl(e){let t=[];for(let n of Fn(e.code)){if(!Xc.test(n.source)||Qc(n.source)||ul(n.source))continue;let r=ll(n.source,e.filePath,e.projectRoot,e.aliases);if(r==null)continue;let i=dl(r,e.layoutCssSkip);i!=null&&t.push(i)}return t}const pl=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,ml=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,hl=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,gl=/^layout\.(?:tsx|ts|jsx|js)$/,_l=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],vl=O.dirname(A(import.meta.url)),yl=O.dirname(vl);function bl(e){return e.startsWith(yl)}function xl(){let e=O.join(yl,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(E.existsSync(e))return e;try{let e=A(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(E.existsSync(e))return e}catch{}return null}function Sl(e){let t=w(e);if(t===`virtual:error-boundary-wrapper.tsx`||t.includes(`virtual:error-boundary-wrapper`))return!0;let n=xl();return n!=null&&O.resolve(e)===O.resolve(n)||t.endsWith(`/runtime/boundaries/error-boundary-wrapper.tsx`)}function Cl(e){return u(e)&&u(e.components)}function wl(e,t){if(Sl(e))return`virtual:error-boundary-wrapper.tsx`;let n=w(O.relative(t,e));return n.startsWith(`..`)||O.isAbsolute(n)?w(e):n}function Tl(e,t){if(Sl(e))return`error_boundary_wrapper_${P(`virtual:error-boundary-wrapper.tsx`)}`;if(bl(e)){let t=w(O.relative(yl,e));return`${Gt(t)}_${P(t)}`}return Kt(e,t)}function El(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var Dl=class{serverComponents=/* @__PURE__ */ new Map;serverActions=/* @__PURE__ */ new Map;options;projectRoot;buildCache=/* @__PURE__ */ new Map;useCacheBuildId=null;fileImporters=/* @__PURE__ */ new Map;moduleAnalysisCache;discoveredExternalClientComponents=/* @__PURE__ */ new Set;clientComponentFiles=/* @__PURE__ */ new Map;layoutCssSkipSet=null;viteBuilder=null;envEmitLock=Promise.resolve();getLayoutCssSkipSet(){return this.layoutCssSkipSet??=ol(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return fl({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=w(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?O.join(this.options.clientOutDir,t):O.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await le({root:this.projectRoot,logLevel:`error`}),this.viteBuilder}async withEnvEmitLock(e){let t=this.envEmitLock,n;this.envEmitLock=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}async emitRscEntries(e,t){return this.withEnvEmitLock(async()=>{let n=await this.getEmitBuilder(),r=await pe({viteBuilder:n,entries:e,minify:t?.minify??this.options.minify,codeSplitting:t?.codeSplitting});if(r==null)throw Error(`Vite RSC environment build failed`);return r})}recordClientComponent(e,t){this.clientComponentFiles.set(e,t)}getClientComponentFiles(){return[...this.clientComponentFiles.entries()].map(([e,t])=>({filePath:e,code:t}))}getClientComponentPaths(){return[...this.clientComponentFiles.keys()]}getModuleAnalysisCache(){return this.moduleAnalysisCache}clearClientComponentFiles(){this.clientComponentFiles.clear()}getComponentCount(){return this.serverComponents.size+this.serverActions.size}hasComponent(e){return this.serverComponents.has(e)||this.serverActions.has(e)}removeComponent(e){this.serverComponents.delete(e),this.serverActions.delete(e),this.moduleAnalysisCache.invalidate(e)}getImportGraph(){let e=/* @__PURE__ */ new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=O.join(this.options.clientOutDir,`assets`,`server`);await E.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
|
|
81
|
-
`)}\n`,i=`${P(e+r,12)}.css`,a=O.join(n,i);return await E.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(O.join(this.projectRoot,`src`,`app`,e))}getComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=O.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!E.existsSync(t))return;let n=await E.promises.readFile(t,`utf-8`),r=JSON.parse(n);if(!u(r))return;let i=r,a=t=>{if(Array.isArray(t))for(let n of t){if(!u(n))continue;let t=n.filePath;if(typeof t!=`string`||t===``)continue;let r=this.getComponentIdFromRouteManifestPath(t);n.componentId=r;let i=e.components[r]?.css??[];i.length?n.css=i:delete n.css}};a(i.routes),a(i.layouts),a(i.loading),a(i.errors),a(i.notFound),a(i.templates);let o=i.apiRoutes;if(Array.isArray(o))for(let e of o){if(!u(e))continue;let t=e.filePath;typeof t==`string`&&t!==``&&(e.componentId=this.getComponentIdFromRouteManifestPath(t))}await E.promises.writeFile(t,JSON.stringify(i),`utf-8`)}constructor(e,t={}){this.projectRoot=O.resolve(e),this.moduleAnalysisCache=t.moduleAnalysisCache??new Mr;let n=t.rscDir!=null&&t.rscDir!==``?t.rscDir:`server`,r=t.outDir!=null&&t.outDir!==``?t.outDir:xe,i=Se(this.projectRoot,r),a=t.clientOutDir!=null&&t.clientOutDir!==``?Se(this.projectRoot,t.clientOutDir):O.join(i,`client`);this.options={outDir:i,clientOutDir:a,rscDir:n,manifestPath:t.manifestPath!=null&&t.manifestPath!==``?t.manifestPath:O.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath!=null&&t.serverConfigPath!==``?t.serverConfigPath:O.join(n,`config.json`),minify:t.minify??k.env.NODE_ENV===`production`,alias:t.alias??{},assetsDir:t.assetsDir!=null&&t.assetsDir!==``?C(t.assetsDir):`assets`,define:t.define,csp:t.csp,cacheControl:t.cacheControl,cache:t.cache,action:t.action,jsPoolSize:t.jsPoolSize,origin:t.origin,htmlLimitedBots:t.htmlLimitedBots,experimental:t.experimental,mdx:t.mdx}}getModuleAnalysis(e,t){return this.moduleAnalysisCache.get(e,t)}isServerComponent(e,t){try{return El(e,this.moduleAnalysisCache.get(e,t))}catch{return!1}}isClientComponent(e,t){if(Sl(e))return!0;try{return this.moduleAnalysisCache.get(e,t).directives.hasUseClient}catch{return!1}}resolveImportedFilePath(e,t){let n=null;if(t.startsWith(`./`)||t.startsWith(`../`)){let r=O.dirname(e);n=O.resolve(r,t)}else if(n=T(t,this.options.alias,this.projectRoot),(n==null||n===``)&&t.startsWith(`@/`)){let e=t.slice(2);n=O.join(this.projectRoot,`src`,e)}return n==null||n===``?null:ge(n,[``,`.ts`,`.tsx`,`.js`,`.jsx`])}populateImportGraphFromFiles(e){this.fileImporters.clear();for(let{filePath:t,analysis:n}of e)for(let e of kr(n.importSources)){let n=this.resolveImportedFilePath(t,e);n!=null&&n!==``&&(this.fileImporters.has(n)||this.fileImporters.set(n,/* @__PURE__ */ new Set),this.fileImporters.get(n).add(t))}}buildImportGraph(e){let t=Ol(this,[e]);this.populateImportGraphFromFiles(t)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t,n){let r=t??E.readFileSync(e,`utf-8`),i=n??this.moduleAnalysisCache.get(e,r),a=Or(i.importSources),o=Dr(i);if(i.directives.hasUseServer){this.serverActions.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o});return}El(e,i)&&this.serverComponents.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o})}isServerAction(e,t){return t!=null&&t!==``?this.moduleAnalysisCache.get(t,e).directives.hasUseServer:z(e).directives.hasUseServer}extractDependencies(e,t){return Or((t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):z(e)).importSources)}hasNodeImports(e,t){return Dr(t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):z(e))}async getTransformedComponentsForDevelopment(e){let t=[];for(let[n]of this.serverComponents)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!1});for(let[n]of this.serverActions)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!0});if(t.length===0)return[];let n=await this.emitRscEntries(t.map(({componentId:e,filePath:t})=>({componentId:e,filePath:t})),{minify:this.options.minify,codeSplitting:!1});for(let e of n.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await E.promises.mkdir(O.dirname(t),{recursive:!0}),await E.promises.writeFile(t,e.code)}return t.map(e=>{let t=n.outputs.get(e.componentId);if(t==null)throw Error(`Vite RSC environment build missed entry: ${e.componentId}`);return{id:e.componentId,code:t.code,isAction:e.isAction}})}async emitProxyManifest(e){let t=O.join(e,`proxy.json`),n=[...this.serverComponents.entries()].filter(([e])=>pl.test(O.basename(e)));if(n.length===0){try{await E.promises.unlink(t)}catch(e){r(e)!==`ENOENT`&&console.warn(`Failed to remove proxy manifest file:`,e)}return}let[i,a]=n[0],o=w(this.getProjectRelativePath(i)),s=this.getComponentId(o),c=w(O.join(this.options.rscDir,`${s}.js`)),l=qc({proxyFile:o,code:a.originalCode,bundlePath:c});l.requiresRuntime||this.serverComponents.delete(i),await E.promises.writeFile(t,JSON.stringify(l),`utf-8`)}async buildServerComponents(){let e=O.join(this.options.outDir,this.options.rscDir);await E.promises.mkdir(e,{recursive:!0}),await this.emitProxyManifest(e);let t={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},n=this.options.experimental?.useCache===!0||this.options.experimental?.useCacheRemote!=null,r=[...this.serverComponents.entries(),...this.serverActions.entries()],i=await this.buildRscEntriesWithVite(r);await this.writeViteBuiltRscEntries(t,i),n&&(this.useCacheBuildId=P(JSON.stringify(t.components),16),t.useCacheBuildId=this.useCacheBuildId);let a=O.join(this.options.outDir,this.options.manifestPath);await E.promises.writeFile(a,JSON.stringify(t),`utf-8`),await this.writeRouteCssEntries(t);let o=this.buildServerConfigObject();return await this.persistServerConfig(o),t}buildServerConfigObject(){let e={};this.options.csp&&(e.csp=this.options.csp),this.options.cacheControl&&(e.cacheControl=this.options.cacheControl),this.options.cache&&(e.cache=this.options.cache),this.options.action&&(e.action=this.options.action),this.options.jsPoolSize!=null&&(e.jsPoolSize=this.options.jsPoolSize);let t=this.options.origin?.trim().replace(/\/+$/,``);return t!=null&&t!==``&&(e.origin=t),this.options.htmlLimitedBots!=null&&(e.htmlLimitedBots=this.options.htmlLimitedBots),this.applyUseCacheServerConfig(e),e}applyUseCacheServerConfig(e){(this.options.experimental?.useCacheRemote!=null||this.useCacheBuildId!=null&&this.useCacheBuildId!==``)&&(e.useCache={...this.options.experimental?.useCacheRemote?{remote:this.options.experimental.useCacheRemote}:{},...this.useCacheBuildId!=null&&this.useCacheBuildId!==``?{buildId:this.useCacheBuildId}:{}},!this.options.experimental?.useCache&&this.options.experimental?.useCacheRemote&&console.warn(`[server-build] experimental.useCacheRemote is set without experimental.useCache; the 'use cache' transform will still run because useCacheRemote is configured.`))}async persistServerConfig(e){let t=O.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(e).length===0){try{await E.promises.unlink(t)}catch(e){r(e)!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}return}await E.promises.writeFile(t,JSON.stringify(e),`utf-8`)}async writeViteBuiltRscEntries(e,t){for(let e of t.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await E.promises.mkdir(O.dirname(t),{recursive:!0}),await E.promises.writeFile(t,e.code)}for(let[n,r]of t.entries){let t=O.relative(this.projectRoot,n),i=this.getComponentId(n),a=me(this.options.rscDir,i),o=O.join(this.options.outDir,a);await E.promises.mkdir(O.dirname(o),{recursive:!0}),await E.promises.writeFile(o,r.code,`utf-8`);let s=this.serverComponents.get(n)??this.serverActions.get(n),c=this.resolveServerCssSources(n,s?.originalCode??await E.promises.readFile(n,`utf-8`)),l=[...await this.writeComponentCssAsset(i,r.cssAssetSources.length>0?[...r.cssAssetSources]:c)];e.components[i]={id:i,filePath:n,relativePath:t,bundlePath:a,moduleSpecifier:ke(O.resolve(this.projectRoot,o)).href,dependencies:[...s?.dependencies??[]],hasNodeImports:s?.hasNodeImports??!1,isServerAction:this.serverActions.has(n),css:l}}}async buildRscEntriesWithVite(e){let t={entries:/* @__PURE__ */ new Map,extraFiles:[]};if(e.length===0)return t;if(this.viteBuilder==null)throw Error(`Vite builder is required for RSC environment emit`);let n=this.viteBuilder;return this.withEnvEmitLock(async()=>{let t=e.map(([e])=>({componentId:this.getComponentId(e),filePath:e})),r=await pe({viteBuilder:n,entries:t,minify:this.options.minify});if(r==null)throw Error(`Vite RSC environment build failed`);let i=/* @__PURE__ */ new Map;for(let[t]of e){let e=this.getComponentId(t),n=r.outputs.get(e);if(n==null)throw Error(`Vite RSC environment build missed entry: ${e}`);i.set(t,n)}return{entries:i,extraFiles:[...r.extraFiles]}})}async buildMdxRegistry(e){let t=Ds({projectRoot:this.projectRoot,mdxOptions:e,alias:this.options.alias,cache:this.moduleAnalysisCache}),n=O.join(this.options.outDir,this.options.manifestPath),r;if(E.existsSync(n)){let e=await E.promises.readFile(n,`utf-8`),t=f(e);r=t&&Cl(t)?t:{components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()}}else r={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()};r.mdxRegistry=t.map(e=>({name:e.name,id:e.moduleId,client:e.client})),await E.promises.writeFile(n,JSON.stringify(r),`utf-8`)}collectSsrClientFiles(){let e=[...this.getClientComponentFiles()];for(let t of this.discoveredExternalClientComponents)if(!e.some(e=>e.filePath===t))try{let n=E.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}catch{}try{let t=xl();if(t!=null&&t!==``){let n=E.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}}catch{}return e}collectExternalSsrSources(){let e=[];for(let{componentId:t,devSourceSegments:n,publishedExport:r,exports:i}of _l){let a=this.resolveExternalClientSourcePath(n,r);if(a!=null&&a!==``)try{let n=E.readFileSync(a,`utf-8`);e.push({componentId:t,filePath:a,code:n,exports:[...i],bundleName:`external_${P(t)}`})}catch{}}return e}async buildSSRClientComponents(){let e=O.join(this.options.outDir,`ssr`);await E.promises.mkdir(e,{recursive:!0});let t=this.collectSsrClientFiles(),n=this.collectExternalSsrSources(),r={},i=await this.buildSsrEntriesWithVite(t,n);for(let t of i.extraFiles){let n=w(t.fileName),r=n===this.options.assetsDir||n.startsWith(`${this.options.assetsDir}/`)?O.join(this.options.clientOutDir,n):O.join(e,n);await E.promises.mkdir(O.dirname(r),{recursive:!0}),await E.promises.writeFile(r,t.code)}for(let[e,a]of i.entries){let i=n.find(t=>t.filePath===e),o=i?.componentId??wl(e,this.projectRoot),s=`ssr/${i?.bundleName??Tl(e,this.projectRoot)}.js`,c=O.join(this.options.outDir,s);await E.promises.mkdir(O.dirname(c),{recursive:!0}),await E.promises.writeFile(c,a.code,`utf-8`);let l=i?.code??t.find(t=>t.filePath===e)?.code??E.readFileSync(e,`utf-8`);r[o]={id:o,filePath:e,bundlePath:s,exports:i?.exports??this.extractExportNames(l)}}await this.writeClientReferenceManifest(e,r)}async buildSsrEntriesWithVite(e,t=[]){let n={entries:/* @__PURE__ */ new Map,extraFiles:[]},r=[...e.map(({filePath:e})=>({entryName:Tl(e,this.projectRoot),filePath:e})),...t.map(e=>({entryName:e.bundleName,filePath:e.filePath}))];if(r.length===0)return n;if(this.viteBuilder==null)throw Error(`Vite builder is required for SSR environment emit`);let i=this.viteBuilder;return this.withEnvEmitLock(async()=>{let e=await he({viteBuilder:i,entries:r,minify:this.options.minify});if(e==null)throw Error(`Vite SSR environment build failed`);let t=/* @__PURE__ */ new Map;for(let n of r){let r=e.outputs.get(n.entryName);if(r==null)throw Error(`Vite SSR environment build missed entry: ${n.entryName}`);t.set(n.filePath,{code:r.code})}return{entries:t,extraFiles:[...e.extraFiles]}})}async writeClientReferenceManifest(e,t){let n=O.join(e,`manifest.json`);await E.promises.writeFile(n,JSON.stringify(t),`utf-8`);let r={};for(let[e,n]of Object.entries(t))for(let t of n.exports){let i=`${e}#${t}`;r[i]={id:i,chunks:`/${n.bundlePath}`,name:t}}let i=O.join(this.options.outDir,`server`);await E.promises.mkdir(i,{recursive:!0});let a=O.join(i,`client-reference-manifest.json`);await E.promises.writeFile(a,JSON.stringify(r),`utf-8`)}resolveExternalClientSourcePath(e,t){let n=O.join(yl,...e);if(E.existsSync(n))return n;try{let e=A(import.meta.resolve(t));if(E.existsSync(e))return e}catch{}return null}extractExportNames(e){return Vn(e)}getProjectRelativePath(e){return Wt(e,this.projectRoot)}getReadableComponentId(e){return Gt(e)}getComponentId(e){return Kt(e,this.projectRoot)}async rebuildComponent(e){gl.test(O.basename(e))&&(this.layoutCssSkipSet=null);let t=this.getComponentId(e),n=await E.promises.readFile(e,`utf-8`),r=this.extractDependencies(n,e),i={filePath:e,originalCode:n,dependencies:r,hasNodeImports:this.hasNodeImports(n,e)};this.isServerAction(n,e)?(this.serverActions.set(e,i),this.serverComponents.delete(e)):(this.serverComponents.set(e,i),this.serverActions.delete(e));let a=O.join(this.options.rscDir,`${t}.js`),o=O.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await E.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.sourceDependencies)===JSON.stringify(r)){let n=this.serverActions.get(e)??this.serverComponents.get(e);return n&&s.bundledDependencies.length>0&&(n.dependencies=s.bundledDependencies),await E.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a,s.css),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}let l=O.dirname(o);await E.promises.mkdir(l,{recursive:!0});let u=await this.emitRscEntries([{componentId:t,filePath:e}],{minify:this.options.minify}),d=u.outputs.get(t);if(d==null)throw Error(`Vite RSC environment build missed entry: ${t}`);await E.promises.writeFile(o,d.code,`utf-8`);let f=this.resolveServerCssSources(e,n),p=[...await this.writeComponentCssAsset(t,d.cssAssetSources.length>0?[...d.cssAssetSources]:f)];for(let e of u.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await E.promises.mkdir(O.dirname(t),{recursive:!0}),await E.promises.writeFile(t,e.code)}let m=this.serverActions.get(e)??this.serverComponents.get(e);return this.buildCache.set(e,{code:d.code,css:p,timestamp:Date.now(),sourceDependencies:r,bundledDependencies:m?.dependencies??r}),await this.updateManifestForComponent(t,e,a,p),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}bundlePathForRuntime(e){return w(O.relative(this.projectRoot,e))}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=O.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(E.existsSync(i)){let e=await E.promises.readFile(i,`utf-8`),t=f(e);t&&Cl(t)?(a=t,this.manifestCache=a):(a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a)}else a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a;let o=this.serverComponents.get(t)??this.serverActions.get(t),s=O.join(this.options.outDir,n),c=ke(O.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:O.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:[...o.dependencies],hasNodeImports:o.hasNodeImports,isServerAction:this.serverActions.has(t),css:r};else{let i=await E.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:O.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i,t),hasNodeImports:this.hasNodeImports(i,t),isServerAction:this.isServerAction(i,t),css:r}}a.buildTime=(/* @__PURE__ */ new Date()).toISOString(),await E.promises.writeFile(i,JSON.stringify(a),`utf-8`),await this.writeRouteCssEntries(a),this.manifestCache=a}clearCache(){this.buildCache.clear(),this.manifestCache=null}invalidateBuildCacheFor(e){this.buildCache.delete(e)}};function Ol(e,t){let n=[];for(let r of Cr(t))try{let t=H(r),i=E.readFileSync(r,`utf-8`),a=e.getModuleAnalysis(r,i);n.push({filePath:r,cacheKey:t,code:i,analysis:a})}catch(e){console.warn(`[server-build] Error reading ${r}:`,c(e,String(e)))}return n}function kl(e,t){return(t??z(e)).hasComponentExport||v.test(e)||te.test(e)||re.test(e)}function Al(e,t,n,r){let i=O.basename(e);if(ml.test(i)||hl.test(i)||i.endsWith(`.d.ts`))return!1;let a=r??n.getModuleAnalysis(e,t);return a.directives.hasUseClient?!1:a.directives.hasUseServer?!0:!n.isOnlyImportedByClientComponents(e)&&El(e,a)&&kl(t,a)}function jl(e,t,n=[]){let r=Ol(t,wr(e,n));t.clearClientComponentFiles(),t.populateImportGraphFromFiles(r);let i=[],a=[];for(let{filePath:e,code:n,analysis:o}of r)o.directives.hasUseClient&&(a.push(e),t.recordClientComponent(e,n)),Al(e,n,t,o)&&(t.addServerComponent(e,n,o),i.push(e));return{serverComponentPaths:i,clientComponentPaths:a}}function Ml(e={}){let t=null,n,r,i,a={},o=!1;async function s(){if(t){try{await t.buildMdxRegistry(e.mdx)}catch(e){console.warn(`[rari] Failed to build MDX component registry:`,e)}try{let{generateRobotsFile:e}=await import(`./robots-BOPIkPcN.mjs`);await e({appDir:O.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}try{let{generateSitemapFiles:e}=await import(`./sitemap--bdIkWl5.mjs`);await e({appDir:O.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}try{let{generateFeedFile:e}=await import(`./feed-NrJzjZyg.mjs`);await e({appDir:O.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate feed:`,e)}try{let e=O.join(i,`server`,`routes.json`);if(E.existsSync(e)){let t=at(E.readFileSync(e,`utf-8`));t.length>0&&await rt({appDir:O.join(n,`src`,`app`),outDir:r,icons:t})}}catch(e){console.warn(`[rari] Failed to copy app icons:`,e)}try{let t=ks(n,e.mdx),a=[`public/content`,w(O.relative(n,O.join(i,`content`))),w(O.relative(n,O.join(r,`content`)))].filter(e=>e!==``&&!e.startsWith(`..`)&&!O.isAbsolute(e)),o=As(n,t.contentDirs).filter(e=>{let t=w(O.relative(n,e));return!a.some(e=>t===e||t.startsWith(`${e}/`))});o.length>0&&Ms(o,O.join(i,`content`))}catch(e){console.warn(`[rari] Failed to copy MDX content:`,e)}hs(r)}}return{name:`rari-server-build`,sharedDuringBuild:!0,configResolved(s){n=s.root,r=be(s.root,s.build.outDir),i=ye(r),o=!1;let c=Ht(s);a=c;let l=typeof s.build.assetsDir==`string`&&s.build.assetsDir!==``?C(s.build.assetsDir):`assets`;t=new Dl(n,{...e,alias:c,assetsDir:l,outDir:i,clientOutDir:r,minify:e.minify??s.mode===`production`})},buildStart(){if(!t)return;let e=O.join(n,`src`);E.existsSync(e)&&jl(e,t,Object.values(a))},async buildApp(e){if(!t||o)return;let n=e.environments.client;n.isBuilt||await e.build(n);let r=e.environments.rsc,i=e.environments.ssr;await r.init(),await i.init(),t.setViteBuilder(e),await t.buildServerComponents(),await t.buildSSRClientComponents(),o=!0,await s()}}}function Nl(e,t,n){if(n.length===0)return e;let r=Fn(e).find(e=>e.source===t&&!e.typeOnly&&!e.sideEffectOnly),i=/* @__PURE__ */ new Map;if(r!=null)for(let e of r.named)e.typeOnly||i.set(e.imported,e.local);for(let e of n)i.has(e)||i.set(e,e);let a=[...i.entries()].map(([e,t])=>e===t?e:`${e} as ${t}`);if(r?.namespaceBinding!=null||r?.named.some(e=>e.typeOnly)){let i=n.filter(e=>!r.named.some(t=>!t.typeOnly&&t.imported===e));return i.length===0?e:`${`import { ${[...new Set(i)].join(`, `)} } from ${JSON.stringify(t)};`}\n${e}`}let o=`import ${r?.defaultBinding==null?``:`${r.defaultBinding}, `}{ ${a.join(`, `)} } from ${JSON.stringify(t)};`;return r==null?`${o}\n\n${e}`:e.slice(0,r.start)+o+e.slice(r.end)}function Pl(e,t){return`const ${e} = createClientModuleProxy(${JSON.stringify(t)});`}function Fl(e,t,n){return`const ${e} = registerClientReference(
|
|
74
|
+
`}function Ns(e,t){return{componentsDir:t?.componentsDir??`src/components`,contentDirs:t?.contentDirs??[`src/content`,`content`,`public/content`]}}function Ps(e,t){return t.map(t=>O.join(e,t)).filter(e=>E.existsSync(e))}function Fs(e){let t=[],n=r=>{if(E.existsSync(r))for(let i of E.readdirSync(r,{withFileTypes:!0})){let a=O.join(r,i.name);i.isDirectory()?n(a):i.isFile()&&t.push(C(O.relative(e,a)))}};return n(e),t}function Is(e,t){for(let n of e)for(let e of Fs(n)){let r=O.join(n,e),i=O.join(t,e);if(E.existsSync(i)){console.warn(`[rari] Skipping MDX content conflict: ${e} already copied from an earlier content dir`);continue}E.mkdirSync(O.dirname(i),{recursive:!0}),E.copyFileSync(r,i)}}function Ls(e,t,n){let r=O.join(e,t),i=new Set(n);return E.existsSync(r)&&i.add(r),[...i]}const Rs=/\.cookies\b|\.headers\b|\.searchParams\b|\.geo\b|\.ip\b|\bwaitUntil\b|\bfetch\s*\(|RariResponse\.json\b|\.startsWith\s*\(|\.includes\s*\(|\.endsWith\s*\(|\bawait\b|`[^`]*\$\{/,zs=/RariResponse\.(?:redirect|rewrite)\s*\(/,Bs=/if\s*\(([^)]+)\)(?:\s*\{)?\s+return\s+RariResponse\.(redirect|rewrite)\(\s*new\s+URL\(\s*(['"`])([^'"`]+)\3\s*,[^)]+\)(?:\s*,\s*(\d+))?\s*\)/g,Vs=/^(?:(request\.rariUrl\.pathname|pathname|normalizedPath)\s*(?:===|==)\s*(['"`])([^'"`]+)\2|(['"`])([^'"`]+)\4\s*(?:===|==)\s*(request\.rariUrl\.pathname|pathname|normalizedPath))$/,Hs=/export\s+const\s+config\s*=/,Us=/export\s+const\s+config\s*=\s*\{/,Ws=/matcher\s*:\s*\{/,Gs=/matcher\s*:\s*(['"`])([^'"`]+)\1/,Ks=/matcher\s*:\s*\[([^\]]*)\]/,qs=/(['"`])matcher\1\s*:\s*\{/,Js=/(['"`])matcher\1\s*:\s*(['"`])([^'"`]+)\2/,Ys=/(['"`])matcher\1\s*:\s*\[([^\]]*)\]/,Xs=/(['"`])matcher\1\s*:/,Zs=/(['"`])([^'"`]+)\1/g,Qs=/(?:^|[{,]\s*)matcher\s*[,}]/;function $s(e){return e===301||e===308}const ec=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`else`,`do`,`typeof`,`delete`,`void`,`await`,`yield`,`new`,`in`,`of`,`instanceof`]);function tc(e){return e===`
|
|
75
|
+
`||e===`\r`||e===`\u2028`||e===`\u2029`}function nc(e,t){for(t-=2;t>=1;){if(e.charAt(t-1)===`/`&&e.charAt(t)===`*`)return t-2;--t}return t}function rc(e,t,n){for(let r=t;r<n;r++){if(e.charAt(r)===`/`&&e.charAt(r+1)===`/`)return r;if(e.charAt(r)===`/`&&e.charAt(r+1)===`*`){for(r+=2;r<n&&(e.charAt(r)!==`*`||e.charAt(r+1)!==`/`);)r+=1;r+=1}}return-1}function ic(e,t){let n=t-1;for(;n>=0;){for(;n>=0&&/\s/.test(e.charAt(n));)--n;if(n<0)return n;if(e.charAt(n)===`/`&&n>0&&e.charAt(n-1)===`*`){n=nc(e,n);continue}let t=n;for(;t>0&&!tc(e.charAt(t-1));)--t;let r=rc(e,t,n);if(r!==-1){n=r-1;continue}break}return n}function ac(e,t){let n=ic(e,t);if(n<0)return!0;let r=e.charAt(n);if(/[)}\]]/.test(r))return!1;if(!/[\w$]/.test(r))return!0;let i=n;for(;i>=0&&/[\w$]/.test(e.charAt(i));)--i;return ec.has(e.slice(i+1,n+1))}function oc(e){return e===`
|
|
76
|
+
`||e===`\r`||e===`\u2028`||e===`\u2029`}function sc(e){switch(e){case`n`:return`
|
|
77
|
+
`;case`r`:return`\r`;case`t`:return` `;case`b`:return`\b`;case`f`:return`\f`;case`v`:return`\v`;case`0`:return`\0`;case`\\`:case`'`:case`"`:case"`":case`/`:return e;default:return null}}function cc(e,t,n){if(n===`x`){let n=e.slice(t+1,t+3);return/^[\da-f]{2}$/i.test(n)?{char:String.fromCharCode(Number.parseInt(n,16)),end:t+2}:null}if(n!==`u`)return null;if(e.charAt(t+1)===`{`){let n=e.indexOf(`}`,t+2);if(n===-1)return null;let r=e.slice(t+2,n);return/^[\da-f]+$/i.test(r)?{char:String.fromCodePoint(Number.parseInt(r,16)),end:n}:null}let r=e.slice(t+1,t+5);return/^[\da-f]{4}$/i.test(r)?{char:String.fromCharCode(Number.parseInt(r,16)),end:t+4}:null}function lc(e,t,n,r){if(oc(n)){let i=t;return n===`\r`&&e.charAt(t+1)===`
|
|
78
|
+
`&&(i=t+1),{out:r,i}}let i=sc(n);if(i!=null)return{out:r+i,i:t};let a=cc(e,t,n);return a==null?n===`x`||n===`u`?null:{out:r+n,i:t}:{out:r+a.char,i:a.end}}function uc(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(t==="`"&&i===`$`&&e.charAt(r+1)===`{`)return null;if(i!==`\\`){n+=i;continue}if(r+=1,r>=e.length)return null;let a=lc(e,r,e.charAt(r),n);if(a==null)return null;n=a.out,r=a.i}return n}function dc(e,t,n){for(let r=t+1;r<e.length;r++){let t=e[r];if(t===`\\`){r+=1;continue}if(n==="`"&&t===`$`&&e[r+1]===`{`)return null;if(t===n)return r+1}return null}function fc(e,t,n,r){return n===`\\`?r+2:((t===`single`&&n===`'`||t===`double`&&n===`"`)&&e.pop(),r+1)}function pc(e,t,n,r){return t===`\\`?r+2:t==="`"?(e.pop(),r+1):t===`$`&&n===`{`?(e.push({kind:`code`,braceDepth:1}),r+2):r+1}function mc(e,t,n,r,i){if(n===`\\`)return r+2;if(n===`[`)return e.push({kind:`regex-class`}),r+1;if(n===`/`){e.pop();let n=r+1;for(;n<i&&/[a-z]/i.test(t.charAt(n));)n+=1;return n}return r+1}function hc(e,t,n){return t===`\\`?n+2:(t===`]`&&e.pop(),n+1)}function gc(e,t,n,r=t.length){let i=e.at(-1);if(i===void 0||i.kind===`code`)return null;let a=t.charAt(n),o=t.charAt(n+1);return i.kind===`line-comment`?(a===`
|
|
79
|
+
`&&e.pop(),n+1):i.kind===`block-comment`?a===`*`&&o===`/`?(e.pop(),n+2):n+1:i.kind===`single`||i.kind===`double`?fc(e,i.kind,a,n):i.kind===`template`?pc(e,a,o,n):i.kind===`regex`?mc(e,t,a,n,r):hc(e,a,n)}function _c(e,t,n){let r=t.charAt(n),i=t.charAt(n+1);return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`/`&&ac(t,n)?(e.push({kind:`regex`}),n+1):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function vc(e,t,n){return n===`{`?(e.braceDepth+=1,!0):n===`}`&&(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),!0)}function yc(e,t,n,r,i){--e.braceDepth;let a=i+1;return e.braceDepth===0?t.length===1?{i:a,done:n.slice(r,a)}:(t.pop(),{i:a,done:null}):{i:a,done:null}}function bc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=gc(e,t,n);if(a!=null)return{i:a,done:null};if(i.kind!==`code`)return null;let o=_c(e,t,n);if(o!=null)return{i:o,done:null};let s=t.charAt(n);return s===`{`?(i.braceDepth+=1,{i:n+1,done:null}):s===`}`?yc(i,e,t,r,n):{i:n+1,done:null}}function xc(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=t;r<e.length;){let i=bc(n,e,r,t);if(i==null)return null;if(i.done!=null)return i.done;r=i.i}return null}function Sc(e,t,n){if(n==="`"&&dc(e,t,"`")==null)return{forceRuntime:!0,endIndex:e.length};let r=dc(e,t,n);if(r==null)return{forceRuntime:!0,endIndex:e.length};let i=e.slice(t+1,r-1);if(n==="`"&&i.includes("${"))return{forceRuntime:!0,endIndex:r};let a=uc(i,n);return a==null||a===``?{forceRuntime:!0,endIndex:r}:{matcher:a,forceRuntime:!1,endIndex:r}}function Cc(e,t,n,r){let i=n[r],a=n[r+1];return i===`\\`?{j:r+2}:t.kind===`template`&&i===`$`&&a===`{`?{j:r,forceRuntime:!0}:((t.kind===`single`&&i===`'`||t.kind===`double`&&i===`"`||t.kind===`template`&&i==="`")&&e.pop(),{j:r+1})}function wc(e,t,n){let r=e.at(-1);return r===void 0?{j:n,forceRuntime:!0}:r.kind===`line-comment`?(t[n]===`
|
|
80
|
+
`&&e.pop(),{j:n+1}):r.kind===`block-comment`?t[n]===`*`&&t[n+1]===`/`?(e.pop(),{j:n+2}):{j:n+1}:r.kind===`single`||r.kind===`double`||r.kind===`template`?Cc(e,r,t,n):null}function Tc(e,t,n){let r=t[n],i=t[n+1];return r===`/`&&i===`/`?(e.push({kind:`line-comment`}),n+2):r===`/`&&i===`*`?(e.push({kind:`block-comment`}),n+2):r===`'`?(e.push({kind:`single`}),n+1):r===`"`?(e.push({kind:`double`}),n+1):r==="`"?(e.push({kind:`template`}),n+1):null}function Ec(e,t,n){let r=e[t];return r===`[`?{j:t+1,depth:n+1}:r===`]`?{j:t+1,depth:n-1}:r===`{`?{j:t,depth:n,forceRuntime:!0}:{j:t+1,depth:n}}function Dc(e,t){let n=t+1,r=1,i=n,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=wc(a,e,i);if(t!=null){if(t.forceRuntime)return{forceRuntime:!0,endIndex:e.length};i=t.j;continue}let n=Tc(a,e,i);if(n!=null){i=n;continue}let o=Ec(e,i,r);if(o.forceRuntime)return{forceRuntime:!0,endIndex:o.j};i=o.j,r=o.depth}return r===0?{...Fc(e.slice(n,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}function Oc(e,t){let n=t+1;for(;n<e.length&&/\s/.test(e[n]);)n+=1;if(n>=e.length)return null;let r=e[n];return r===`'`||r===`"`||r==="`"?Sc(e,n,r):r===`[`?Dc(e,n):{forceRuntime:!0,endIndex:n+1}}function kc(e,t,n,r){let i=t===0?``:e.charAt(t-1),a=t===0||/[\s;{}]/.test(i);if(n.braceDepth!==0||r.length!==1||!a)return null;if(e.startsWith(`let matcher`,t)||e.startsWith(`var matcher`,t))return{nextI:t,forceRuntime:!0};if(!e.startsWith(`const matcher`,t))return null;let o=t+13;if(o<e.length&&/[\w$]/.test(e.charAt(o)))return{nextI:t+1};let s=o;for(;s<e.length&&/\s/.test(e.charAt(s));)s+=1;if(e.charAt(s)!==`=`)return{nextI:t+1};let c=Oc(e,s);return c==null||c.forceRuntime?{nextI:t,forceRuntime:!0}:{nextI:c.endIndex,binding:{matcher:c.matcher,forceRuntime:!1}}}function Ac(e,t,n,r){let i=e.at(-1);if(i===void 0)return{nextI:n,forceRuntime:!0};let a=gc(e,t,n);if(a!=null)return{nextI:a};if(i.kind!==`code`)return{nextI:n,forceRuntime:!0};let o=_c(e,t,n);if(o!=null)return{nextI:o};if(vc(i,e,t.charAt(n)))return{nextI:n+1};let s=kc(t,n,i,e);return s==null?{nextI:n+1}:s.forceRuntime?{nextI:n,forceRuntime:!0}:(s.binding&&r.push(s.binding),{nextI:s.nextI})}function jc(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=Ac(t,e,r,n);if(i==null||i.forceRuntime)return{forceRuntime:!0};r=i.nextI}return n.length===0?null:n.length>1?{forceRuntime:!0}:n[0]??null}function Mc(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=Vs.exec(e.trim());if(t==null)return null;let n=t[1]||t[6]||``,a=t[3]||t[5]||``;if(n===``||a===``)return null;if(i==null)i=n;else if(i!==n)return null;r.push(a)}return r.length>0?r:null}function Nc(e){let t=[];Bs.lastIndex=0;for(let n of e.matchAll(Bs)){let e=n[1],r=n[2],i=n[4],a=Number.parseInt(n[5],10),o=Number.isFinite(a)?a:void 0;if(e===``||i===``||r!==`redirect`&&r!==`rewrite`)continue;let s=Mc(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:$s(o)}:{}})}return t}function Pc(e){let t=Us.exec(e);return t==null?null:xc(e,t.index+t[0].length-1)}function Fc(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];Zs.lastIndex=0;for(let n of e.matchAll(Zs)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=uc(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(Zs,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function Ic(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=0;r<t;){let i=n.at(-1);if(i===void 0)return null;let a=gc(n,e,r,t);if(a!=null){r=a;continue}if(i.kind!==`code`)return null;let o=_c(n,e,r);if(o!=null){r=o;continue}if(vc(i,n,e.charAt(r))){r+=1;continue}r+=1}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function Lc(e,t){return Ic(e,t)===1}function Rc(e){return e.startsWith(`'`)||e.startsWith(`"`)||e.startsWith("`")}function J(e,t){let n=new RegExp(t.source,t.flags.includes(`g`)?t.flags:`${t.flags}g`);for(let t of e.matchAll(n)){let n=Rc(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&Lc(e,n))return t}return null}function zc(e,t){let n=t;for(;n<e.length;){let t=Vc(e,n);if(t!=null){n=t;continue}let r=e.charAt(n);return r===`,`||r===`}`}return!0}function Bc(e,t){let n=t;for(;n<e.length;){let t=Vc(e,n);if(t==null)break;n=t}return n}function Vc(e,t){let n=e.charAt(t),r=e.charAt(t+1);if(/\s/.test(n))return t+1;if(n===`/`&&r===`/`){let n=t+2;for(;n<e.length&&!tc(e.charAt(n));)n+=1;return n}if(n===`/`&&r===`*`){let n=t+2;for(;n+1<e.length&&(e.charAt(n)!==`*`||e.charAt(n+1)!==`/`);)n+=1;return n+2}return null}function Hc(e,t){if(e.charAt(t)!==`[`)return null;let n=Bc(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=dc(e,n,r);if(t==null)return{endIndex:e.length,forceRuntime:!0};let i=e.slice(n+1,t-1);if(r==="`"&&i.includes("${"))return{endIndex:t,forceRuntime:!0};let a=uc(i,r);return n=Bc(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function Uc(e,t,n,r){return n===`'`||n===`"`||n==="`"?{entered:!0,expectPropertyKey:r&&t.braceDepth===1?!1:r}:{entered:!1,expectPropertyKey:r}}function Wc(e,t,n,r){return n===`{`?(e.braceDepth+=1,{handled:!0,expectPropertyKey:e.braceDepth===1||r}):n===`}`?(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),{handled:!0,expectPropertyKey:!1}):n===`,`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!0}:n===`:`&&e.braceDepth===1?{handled:!0,expectPropertyKey:!1}:{handled:!1,expectPropertyKey:r}}function Gc(e,t,n,r,i,a){if(!r||n.braceDepth!==1||/\s/.test(i))return null;if(i===`.`&&a===`.`&&e.charAt(t+2)===`.`)return{unsafe:!0};if(i===`[`){let n=Hc(e,t);return n?.forceRuntime===!0||n==null?{unsafe:!0}:{unsafe:!1,nextI:n.endIndex,clearExpect:!0}}return{unsafe:!1,clearExpect:!0}}function Kc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=gc(e,t,n);if(a!=null)return{nextI:a,expectPropertyKey:r};if(i.kind!==`code`)return null;let o=t.charAt(n),s=t.charAt(n+1),c=Uc(e,i,o,r);if(c.entered)return{nextI:_c(e,t,n)??n+1,expectPropertyKey:c.expectPropertyKey};let l=_c(e,t,n);if(l!=null)return{nextI:l,expectPropertyKey:r};let u=Wc(i,e,o,r);if(u.handled)return{nextI:n+1,expectPropertyKey:u.expectPropertyKey};let d=Gc(t,n,i,r,o,s);return d==null?{nextI:n+1,expectPropertyKey:r}:d.unsafe?{nextI:n,expectPropertyKey:r,unsafe:!0}:{nextI:d.nextI??n+1,expectPropertyKey:!d.clearExpect&&r}}function qc(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=Kc(t,e,r,n);if(i==null)return!1;if(i.unsafe)return!0;n=i.expectPropertyKey,r=i.nextI}return!1}function Jc(e,t){let n=Rc(t[0]),r=n?t[2]:t[1],i=n?t[3]:t[2];if(r!==`'`&&r!==`"`&&r!=="`")return null;if(r==="`"&&i.includes("${")||!zc(e,t.index+t[0].length))return{forceRuntime:!0};let a=uc(i,r);return a==null||a===``?{forceRuntime:!0}:{matcher:a,forceRuntime:!1}}function Yc(e){if(!Hs.test(e)||!Us.test(e))return{forceRuntime:!1};let t=Pc(e);if(t==null||qc(t)||J(t,Ws)!=null||J(t,qs)!=null)return{forceRuntime:!0};let n=J(t,Gs)??J(t,Js);if(n!=null)return Jc(t,n)??{forceRuntime:!1};let r=J(t,Ks)??J(t,Ys);return r==null?J(t,Qs)==null?J(t,/matcher\s*:/)!=null||J(t,Xs)!=null?{forceRuntime:!0}:{forceRuntime:!1}:jc(e)??{forceRuntime:!0}:zc(t,r.index+r[0].length)?Fc(Rc(r[0])?r[2]:r[1]):{forceRuntime:!0}}function Xc(e){let{matcher:t,forceRuntime:n}=Yc(e);if(n||Rs.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=zs.test(e),i=Nc(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function Zc(e){let t=Xc(e.code),n=t.requiresRuntime;return{proxyFile:e.proxyFile,enabled:!0,generated:e.generated??(/* @__PURE__ */ new Date()).toISOString(),rules:t.rules,requiresRuntime:n,...n&&e.bundlePath!=null&&e.bundlePath!==``?{bundlePath:e.bundlePath}:{},...t.matcher==null?{}:{matcher:t.matcher}}}const Qc=/@import\s+(?:url\(\s*)?['"](?![a-zA-Z][a-zA-Z0-9+.-]*:|\/\/|\.\/|\.\.\/|\/)[^'"]+['"][^;]*(?:;|$)/g,$c=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,el=/\.css(?:\?.*)?$/,tl=/\.module\.css(?:\?.*)?$/i;function nl(e){return tl.test(e.replace(/[?#].*$/,``))}function rl(e){return e.replace(Qc,``).trim()}function il(e){if(!/^supports\s*\(/i.test(e))return{supportsCondition:null,rest:e};let t=e.indexOf(`(`),n=0,r=-1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`(`)n++;else if(t===`)`&&(n--,n===0)){r=i;break}}return r===-1?{supportsCondition:null,rest:e}:{supportsCondition:e.slice(t+1,r).trim(),rest:e.slice(r+1).trim()}}function al(e){if(/^layer\s*\(/i.exec(e)){let t=e.indexOf(`(`),n=e.indexOf(`)`,t);return n===-1?{layerName:null,rest:e}:{layerName:e.slice(t+1,n).trim(),rest:e.slice(n+1).trim()}}return/^layer(?:\s|$)/i.test(e)?{layerName:``,rest:e.replace(/^layer\s*/i,``)}:{layerName:null,rest:e}}function ol(e){let t=e.trim().replace(/^\)\s*/,``),n=al(t);t=n.rest;let r=il(t);t=r.rest;let i=t.trim()===``?null:t.trim();return{layerName:n.layerName,supportsCondition:r.supportsCondition,mediaQuery:i}}function sl(e,t){let n=e.trim();return n===``?``:(t.layerName!==null&&(n=t.layerName===``?`@layer {\n${n}\n}`:`@layer ${t.layerName} {\n${n}\n}`),t.supportsCondition!=null&&t.supportsCondition!==``&&(n=`@supports (${t.supportsCondition}) {\n${n}\n}`),t.mediaQuery!=null&&t.mediaQuery!==``&&(n=`@media ${t.mediaQuery} {\n${n}\n}`),n)}function cl(e,t,n=/* @__PURE__ */ new Set){let r=O.resolve(e);return n.has(r)?``:(n.add(r),t.replace($c,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=O.resolve(O.dirname(r),s);try{return!E.existsSync(c)||!E.statSync(c).isFile()?e:sl(ll(c,E.readFileSync(c,`utf-8`),new Set(n)),ol(o))}catch{return e}}).trim())}function ll(e,t,n=/* @__PURE__ */ new Set){return cl(e,rl(t),n)}function ul(e,t){let n=/* @__PURE__ */ new Set;for(let r of Br(e,t)){if(O.isAbsolute(r)){n.add(O.resolve(r));continue}try{n.add(T(O.join(e,`package.json`)).resolve(r))}catch{}}return n}function dl(e){return E.existsSync(e)&&E.statSync(e).isFile()?e:null}function fl(e,t,n){let r=[t,O.join(n,`package.json`)];for(let t of r)try{let n=dl(T(t).resolve(e));if(n!=null)return n}catch{try{let n=dl(A(import.meta.resolve(e,j(t).href)));if(n!=null)return n}catch{}}return null}function pl(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!el.test(i))return null;if(O.isAbsolute(i))return dl(i);if(i.startsWith(`./`)||i.startsWith(`../`))return dl(O.resolve(O.dirname(t),i));let a=be(i,r,n);if(a!=null&&a!==``){let e=dl(a);if(e!=null)return e}return fl(i,t,n)}function ml(e){let t=e.includes(`?`)?e.slice(e.indexOf(`?`)):``;return/(?:\?|&)raw(?:&|$)/.test(t)||/(?:\?|&)url(?:&|$)/.test(t)}function hl(e,t){if(nl(e)||t.has(O.resolve(e)))return null;try{let t=ll(e,E.readFileSync(e,`utf-8`));return t===``?null:t}catch{return null}}function gl(e){let t=[];for(let n of Nn(e.code)){if(!el.test(n.source)||nl(n.source)||ml(n.source))continue;let r=pl(n.source,e.filePath,e.projectRoot,e.aliases);if(r==null)continue;let i=hl(r,e.layoutCssSkip);i!=null&&t.push(i)}return t}const _l=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,vl=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,yl=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,bl=/^layout\.(?:tsx|ts|jsx|js)$/,xl=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],Sl=O.dirname(A(import.meta.url)),Cl=O.dirname(Sl);function wl(e){return e.startsWith(Cl)}function Tl(){let e=O.join(Cl,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(E.existsSync(e))return e;try{let e=A(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(E.existsSync(e))return e}catch{}return null}function El(e){let t=C(e);if(t===`virtual:error-boundary-wrapper.tsx`||t.includes(`virtual:error-boundary-wrapper`))return!0;let n=Tl();return n!=null&&O.resolve(e)===O.resolve(n)||t.endsWith(`/runtime/boundaries/error-boundary-wrapper.tsx`)}function Dl(e){return c(e)&&c(e.components)}function Ol(e,t){if(El(e))return`virtual:error-boundary-wrapper.tsx`;let n=C(O.relative(t,e));return n.startsWith(`..`)||O.isAbsolute(n)?C(e):n}function kl(e,t){if(El(e))return`error_boundary_wrapper_${F(`virtual:error-boundary-wrapper.tsx`)}`;if(wl(e)){let t=C(O.relative(Cl,e));return`${Wt(t)}_${F(t)}`}return Gt(e,t)}function Al(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var jl=class{serverComponents=/* @__PURE__ */ new Map;serverActions=/* @__PURE__ */ new Map;options;projectRoot;buildCache=/* @__PURE__ */ new Map;useCacheBuildId=null;fileImporters=/* @__PURE__ */ new Map;moduleAnalysisCache;discoveredExternalClientComponents=/* @__PURE__ */ new Set;clientComponentFiles=/* @__PURE__ */ new Map;layoutCssSkipSet=null;viteBuilder=null;envEmitLock=Promise.resolve();getLayoutCssSkipSet(){return this.layoutCssSkipSet??=ul(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return gl({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=C(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?O.join(this.options.clientOutDir,t):O.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await pe({root:this.projectRoot,logLevel:`error`}),this.viteBuilder}async withEnvEmitLock(e){let t=this.envEmitLock,n;this.envEmitLock=new Promise(e=>{n=e}),await t;try{return await e()}finally{n()}}async emitRscEntries(e,t){return this.withEnvEmitLock(async()=>{let n=await this.getEmitBuilder(),r=await _e({viteBuilder:n,entries:e,minify:t?.minify??this.options.minify,codeSplitting:t?.codeSplitting});if(r==null)throw Error(`Vite RSC environment build failed`);return r})}recordClientComponent(e,t){this.clientComponentFiles.set(e,t)}getClientComponentFiles(){return[...this.clientComponentFiles.entries()].map(([e,t])=>({filePath:e,code:t}))}getClientComponentPaths(){return[...this.clientComponentFiles.keys()]}getModuleAnalysisCache(){return this.moduleAnalysisCache}clearClientComponentFiles(){this.clientComponentFiles.clear()}getComponentCount(){return this.serverComponents.size+this.serverActions.size}hasComponent(e){return this.serverComponents.has(e)||this.serverActions.has(e)}removeComponent(e){this.serverComponents.delete(e),this.serverActions.delete(e),this.moduleAnalysisCache.invalidate(e)}getImportGraph(){let e=/* @__PURE__ */ new Map;for(let[t,n]of this.fileImporters)e.set(t,new Set(n));return e}async writeComponentCssAsset(e,t){if(t.length===0)return[];let n=O.join(this.options.clientOutDir,`assets`,`server`);await E.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
|
|
81
|
+
`)}\n`,i=`${F(e+r,12)}.css`,a=O.join(n,i);return await E.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(O.join(this.projectRoot,`src`,`app`,e))}getComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=O.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!E.existsSync(t))return;let n=await E.promises.readFile(t,`utf-8`),r=JSON.parse(n);if(!c(r))return;let i=r,a=t=>{if(Array.isArray(t))for(let n of t){if(!c(n))continue;let t=n.filePath;if(typeof t!=`string`||t===``)continue;let r=this.getComponentIdFromRouteManifestPath(t);n.componentId=r;let i=e.components[r]?.css??[];i.length?n.css=i:delete n.css}};a(i.routes),a(i.layouts),a(i.loading),a(i.errors),a(i.notFound),a(i.templates);let o=i.apiRoutes;if(Array.isArray(o))for(let e of o){if(!c(e))continue;let t=e.filePath;typeof t==`string`&&t!==``&&(e.componentId=this.getComponentIdFromRouteManifestPath(t))}await E.promises.writeFile(t,JSON.stringify(i),`utf-8`)}constructor(e,t={}){this.projectRoot=O.resolve(e),this.moduleAnalysisCache=t.moduleAnalysisCache??new Ar;let n=t.rscDir!=null&&t.rscDir!==``?t.rscDir:`server`,r=t.outDir!=null&&t.outDir!==``?t.outDir:fe,i=w(this.projectRoot,r),a=t.clientOutDir!=null&&t.clientOutDir!==``?w(this.projectRoot,t.clientOutDir):O.join(i,`client`);this.options={outDir:i,clientOutDir:a,rscDir:n,manifestPath:t.manifestPath!=null&&t.manifestPath!==``?t.manifestPath:O.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath!=null&&t.serverConfigPath!==``?t.serverConfigPath:O.join(n,`config.json`),minify:t.minify??k.env.NODE_ENV===`production`,alias:t.alias??{},assetsDir:t.assetsDir!=null&&t.assetsDir!==``?S(t.assetsDir):`assets`,define:t.define,csp:t.csp,cacheControl:t.cacheControl,cache:t.cache,action:t.action,jsPoolSize:t.jsPoolSize,origin:t.origin,htmlLimitedBots:t.htmlLimitedBots,experimental:t.experimental,mdx:t.mdx}}getModuleAnalysis(e,t){return this.moduleAnalysisCache.get(e,t)}isServerComponent(e,t){try{return Al(e,this.moduleAnalysisCache.get(e,t))}catch{return!1}}isClientComponent(e,t){if(El(e))return!0;try{return this.moduleAnalysisCache.get(e,t).directives.hasUseClient}catch{return!1}}resolveImportedFilePath(e,t){let n=null;if(t.startsWith(`./`)||t.startsWith(`../`)){let r=O.dirname(e);n=O.resolve(r,t)}else if(n=be(t,this.options.alias,this.projectRoot),(n==null||n===``)&&t.startsWith(`@/`)){let e=t.slice(2);n=O.join(this.projectRoot,`src`,e)}return n==null||n===``?null:xe(n,[``,`.ts`,`.tsx`,`.js`,`.jsx`])}populateImportGraphFromFiles(e){this.fileImporters.clear();for(let{filePath:t,analysis:n}of e)for(let e of Dr(n.importSources)){let n=this.resolveImportedFilePath(t,e);n!=null&&n!==``&&(this.fileImporters.has(n)||this.fileImporters.set(n,/* @__PURE__ */ new Set),this.fileImporters.get(n).add(t))}}buildImportGraph(e){let t=Ml(this,[e]);this.populateImportGraphFromFiles(t)}isOnlyImportedByClientComponents(e){let t=this.fileImporters.get(e);if(!t||t.size===0)return!1;for(let e of t)if(!this.isClientComponent(e)&&!this.isOnlyImportedByClientComponents(e))return!1;return!0}addServerComponent(e,t,n){let r=t??E.readFileSync(e,`utf-8`),i=n??this.moduleAnalysisCache.get(e,r),a=Er(i.importSources),o=Tr(i);if(i.directives.hasUseServer){this.serverActions.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o});return}Al(e,i)&&this.serverComponents.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o})}isServerAction(e,t){return t!=null&&t!==``?this.moduleAnalysisCache.get(t,e).directives.hasUseServer:V(e).directives.hasUseServer}extractDependencies(e,t){return Er((t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e)).importSources)}hasNodeImports(e,t){return Tr(t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e))}async getTransformedComponentsForDevelopment(e){let t=[];for(let[n]of this.serverComponents)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!1});for(let[n]of this.serverActions)(!e||e(n))&&t.push({componentId:this.getComponentId(n),filePath:n,isAction:!0});if(t.length===0)return[];let n=await this.emitRscEntries(t.map(({componentId:e,filePath:t})=>({componentId:e,filePath:t})),{minify:this.options.minify,codeSplitting:!1});for(let e of n.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await E.promises.mkdir(O.dirname(t),{recursive:!0}),await E.promises.writeFile(t,e.code)}return t.map(e=>{let t=n.outputs.get(e.componentId);if(t==null)throw Error(`Vite RSC environment build missed entry: ${e.componentId}`);return{id:e.componentId,code:t.code,isAction:e.isAction}})}async emitProxyManifest(e){let t=O.join(e,`proxy.json`),n=[...this.serverComponents.entries()].filter(([e])=>_l.test(O.basename(e)));if(n.length===0){try{await E.promises.unlink(t)}catch(e){a(e)!==`ENOENT`&&console.warn(`Failed to remove proxy manifest file:`,e)}return}let[r,i]=n[0],o=C(this.getProjectRelativePath(r)),s=this.getComponentId(o),c=C(O.join(this.options.rscDir,`${s}.js`)),l=Zc({proxyFile:o,code:i.originalCode,bundlePath:c});l.requiresRuntime||this.serverComponents.delete(r),await E.promises.writeFile(t,JSON.stringify(l),`utf-8`)}async buildServerComponents(){let e=O.join(this.options.outDir,this.options.rscDir);await E.promises.mkdir(e,{recursive:!0}),await this.emitProxyManifest(e);let t={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},n=this.options.experimental?.useCache===!0||this.options.experimental?.useCacheRemote!=null,r=[...this.serverComponents.entries(),...this.serverActions.entries()],i=await this.buildRscEntriesWithVite(r);await this.writeViteBuiltRscEntries(t,i),n&&(this.useCacheBuildId=F(JSON.stringify(t.components),16),t.useCacheBuildId=this.useCacheBuildId);let a=O.join(this.options.outDir,this.options.manifestPath);await E.promises.writeFile(a,JSON.stringify(t),`utf-8`),await this.writeRouteCssEntries(t);let o=this.buildServerConfigObject();return await this.persistServerConfig(o),t}buildServerConfigObject(){let e={};this.options.csp&&(e.csp=this.options.csp),this.options.cacheControl&&(e.cacheControl=this.options.cacheControl),this.options.cache&&(e.cache=this.options.cache),this.options.action&&(e.action=this.options.action),this.options.jsPoolSize!=null&&(e.jsPoolSize=this.options.jsPoolSize);let t=this.options.origin?.trim().replace(/\/+$/,``);return t!=null&&t!==``&&(e.origin=t),this.options.htmlLimitedBots!=null&&(e.htmlLimitedBots=this.options.htmlLimitedBots),this.applyUseCacheServerConfig(e),e}applyUseCacheServerConfig(e){(this.options.experimental?.useCacheRemote!=null||this.useCacheBuildId!=null&&this.useCacheBuildId!==``)&&(e.useCache={...this.options.experimental?.useCacheRemote?{remote:this.options.experimental.useCacheRemote}:{},...this.useCacheBuildId!=null&&this.useCacheBuildId!==``?{buildId:this.useCacheBuildId}:{}},!this.options.experimental?.useCache&&this.options.experimental?.useCacheRemote&&console.warn(`[server-build] experimental.useCacheRemote is set without experimental.useCache; the 'use cache' transform will still run because useCacheRemote is configured.`))}async persistServerConfig(e){let t=O.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(e).length===0){try{await E.promises.unlink(t)}catch(e){a(e)!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}return}await E.promises.writeFile(t,JSON.stringify(e),`utf-8`)}async writeViteBuiltRscEntries(e,t){for(let e of t.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await E.promises.mkdir(O.dirname(t),{recursive:!0}),await E.promises.writeFile(t,e.code)}for(let[n,r]of t.entries){let t=O.relative(this.projectRoot,n),i=this.getComponentId(n),a=ve(this.options.rscDir,i),o=O.join(this.options.outDir,a);await E.promises.mkdir(O.dirname(o),{recursive:!0}),await E.promises.writeFile(o,r.code,`utf-8`);let s=this.serverComponents.get(n)??this.serverActions.get(n),c=this.resolveServerCssSources(n,s?.originalCode??await E.promises.readFile(n,`utf-8`)),l=[...await this.writeComponentCssAsset(i,r.cssAssetSources.length>0?[...r.cssAssetSources]:c)];e.components[i]={id:i,filePath:n,relativePath:t,bundlePath:a,moduleSpecifier:j(O.resolve(this.projectRoot,o)).href,dependencies:[...s?.dependencies??[]],hasNodeImports:s?.hasNodeImports??!1,isServerAction:this.serverActions.has(n),css:l}}}async buildRscEntriesWithVite(e){let t={entries:/* @__PURE__ */ new Map,extraFiles:[]};if(e.length===0)return t;if(this.viteBuilder==null)throw Error(`Vite builder is required for RSC environment emit`);let n=this.viteBuilder;return this.withEnvEmitLock(async()=>{let t=e.map(([e])=>({componentId:this.getComponentId(e),filePath:e})),r=await _e({viteBuilder:n,entries:t,minify:this.options.minify});if(r==null)throw Error(`Vite RSC environment build failed`);let i=/* @__PURE__ */ new Map;for(let[t]of e){let e=this.getComponentId(t),n=r.outputs.get(e);if(n==null)throw Error(`Vite RSC environment build missed entry: ${e}`);i.set(t,n)}return{entries:i,extraFiles:[...r.extraFiles]}})}async buildMdxRegistry(e){let t=js({projectRoot:this.projectRoot,mdxOptions:e,alias:this.options.alias,cache:this.moduleAnalysisCache}),n=O.join(this.options.outDir,this.options.manifestPath),r;if(E.existsSync(n)){let e=await E.promises.readFile(n,`utf-8`),t=p(e);r=t&&Dl(t)?t:{components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()}}else r={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()};r.mdxRegistry=t.map(e=>({name:e.name,id:e.moduleId,client:e.client})),await E.promises.writeFile(n,JSON.stringify(r),`utf-8`)}collectSsrClientFiles(){let e=[...this.getClientComponentFiles()];for(let t of this.discoveredExternalClientComponents)if(!e.some(e=>e.filePath===t))try{let n=E.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}catch{}try{let t=Tl();if(t!=null&&t!==``){let n=E.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}}catch{}return e}collectExternalSsrSources(){let e=[];for(let{componentId:t,devSourceSegments:n,publishedExport:r,exports:i}of xl){let a=this.resolveExternalClientSourcePath(n,r);if(a!=null&&a!==``)try{let n=E.readFileSync(a,`utf-8`);e.push({componentId:t,filePath:a,code:n,exports:[...i],bundleName:`external_${F(t)}`})}catch{}}return e}async buildSSRClientComponents(){let e=O.join(this.options.outDir,`ssr`);await E.promises.mkdir(e,{recursive:!0});let t=this.collectSsrClientFiles(),n=this.collectExternalSsrSources(),r={},i=await this.buildSsrEntriesWithVite(t,n);for(let t of i.extraFiles){let n=C(t.fileName),r=n===this.options.assetsDir||n.startsWith(`${this.options.assetsDir}/`)?O.join(this.options.clientOutDir,n):O.join(e,n);await E.promises.mkdir(O.dirname(r),{recursive:!0}),await E.promises.writeFile(r,t.code)}for(let[e,a]of i.entries){let i=n.find(t=>t.filePath===e),o=i?.componentId??Ol(e,this.projectRoot),s=`ssr/${i?.bundleName??kl(e,this.projectRoot)}.js`,c=O.join(this.options.outDir,s);await E.promises.mkdir(O.dirname(c),{recursive:!0}),await E.promises.writeFile(c,a.code,`utf-8`);let l=i?.code??t.find(t=>t.filePath===e)?.code??E.readFileSync(e,`utf-8`);r[o]={id:o,filePath:e,bundlePath:s,exports:i?.exports??this.extractExportNames(l)}}await this.writeClientReferenceManifest(e,r)}async buildSsrEntriesWithVite(e,t=[]){let n={entries:/* @__PURE__ */ new Map,extraFiles:[]},r=[...e.map(({filePath:e})=>({entryName:kl(e,this.projectRoot),filePath:e})),...t.map(e=>({entryName:e.bundleName,filePath:e.filePath}))];if(r.length===0)return n;if(this.viteBuilder==null)throw Error(`Vite builder is required for SSR environment emit`);let i=this.viteBuilder;return this.withEnvEmitLock(async()=>{let e=await ye({viteBuilder:i,entries:r,minify:this.options.minify});if(e==null)throw Error(`Vite SSR environment build failed`);let t=/* @__PURE__ */ new Map;for(let n of r){let r=e.outputs.get(n.entryName);if(r==null)throw Error(`Vite SSR environment build missed entry: ${n.entryName}`);t.set(n.filePath,{code:r.code})}return{entries:t,extraFiles:[...e.extraFiles]}})}async writeClientReferenceManifest(e,t){let n=O.join(e,`manifest.json`);await E.promises.writeFile(n,JSON.stringify(t),`utf-8`);let r={};for(let[e,n]of Object.entries(t))for(let t of n.exports){let i=`${e}#${t}`;r[i]={id:i,chunks:`/${n.bundlePath}`,name:t}}let i=O.join(this.options.outDir,`server`);await E.promises.mkdir(i,{recursive:!0});let a=O.join(i,`client-reference-manifest.json`);await E.promises.writeFile(a,JSON.stringify(r),`utf-8`)}resolveExternalClientSourcePath(e,t){let n=O.join(Cl,...e);if(E.existsSync(n))return n;try{let e=A(import.meta.resolve(t));if(E.existsSync(e))return e}catch{}return null}extractExportNames(e){return zn(e)}getProjectRelativePath(e){return Ut(e,this.projectRoot)}getReadableComponentId(e){return Wt(e)}getComponentId(e){return Gt(e,this.projectRoot)}async rebuildComponent(e){bl.test(O.basename(e))&&(this.layoutCssSkipSet=null);let t=this.getComponentId(e),n=await E.promises.readFile(e,`utf-8`),r=this.extractDependencies(n,e),i={filePath:e,originalCode:n,dependencies:r,hasNodeImports:this.hasNodeImports(n,e)};this.isServerAction(n,e)?(this.serverActions.set(e,i),this.serverComponents.delete(e)):(this.serverComponents.set(e,i),this.serverActions.delete(e));let a=O.join(this.options.rscDir,`${t}.js`),o=O.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await E.promises.stat(e)).mtimeMs;if(s&&s.timestamp>=c&&JSON.stringify(s.sourceDependencies)===JSON.stringify(r)){let n=this.serverActions.get(e)??this.serverComponents.get(e);return n&&s.bundledDependencies.length>0&&(n.dependencies=s.bundledDependencies),await E.promises.writeFile(o,s.code,`utf-8`),await this.updateManifestForComponent(t,e,a,s.css),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}let l=O.dirname(o);await E.promises.mkdir(l,{recursive:!0});let u=await this.emitRscEntries([{componentId:t,filePath:e}],{minify:this.options.minify,codeSplitting:!1}),d=u.outputs.get(t);if(d==null)throw Error(`Vite RSC environment build missed entry: ${t}`);await E.promises.writeFile(o,d.code,`utf-8`);let f=this.resolveServerCssSources(e,n),p=[...await this.writeComponentCssAsset(t,d.cssAssetSources.length>0?[...d.cssAssetSources]:f)];for(let e of u.extraFiles){let t=this.resolveExtraFileOutPath(e.fileName);await E.promises.mkdir(O.dirname(t),{recursive:!0}),await E.promises.writeFile(t,e.code)}let m=this.serverActions.get(e)??this.serverComponents.get(e);return this.buildCache.set(e,{code:d.code,css:p,timestamp:Date.now(),sourceDependencies:r,bundledDependencies:m?.dependencies??r}),await this.updateManifestForComponent(t,e,a,p),{componentId:t,bundlePath:this.bundlePathForRuntime(o),success:!0}}bundlePathForRuntime(e){return C(O.relative(this.projectRoot,e))}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=O.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(E.existsSync(i)){let e=await E.promises.readFile(i,`utf-8`),t=p(e);t&&Dl(t)?(a=t,this.manifestCache=a):(a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a)}else a={components:{},buildTime:(/* @__PURE__ */ new Date()).toISOString()},this.manifestCache=a;let o=this.serverComponents.get(t)??this.serverActions.get(t),s=O.join(this.options.outDir,n),c=j(O.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:O.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:[...o.dependencies],hasNodeImports:o.hasNodeImports,isServerAction:this.serverActions.has(t),css:r};else{let i=await E.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:O.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i,t),hasNodeImports:this.hasNodeImports(i,t),isServerAction:this.isServerAction(i,t),css:r}}a.buildTime=(/* @__PURE__ */ new Date()).toISOString(),await E.promises.writeFile(i,JSON.stringify(a),`utf-8`),await this.writeRouteCssEntries(a),this.manifestCache=a}clearCache(){this.buildCache.clear(),this.manifestCache=null}invalidateBuildCacheFor(e){this.buildCache.delete(e)}};function Ml(e,t){let n=[];for(let r of xr(t))try{let t=W(r),i=E.readFileSync(r,`utf-8`),a=e.getModuleAnalysis(r,i);n.push({filePath:r,cacheKey:t,code:i,analysis:a})}catch(e){console.warn(`[server-build] Error reading ${r}:`,u(e,String(e)))}return n}function Nl(e,t){return(t??V(e)).hasComponentExport||v.test(e)||te.test(e)||ie.test(e)}function Pl(e,t,n,r){let i=O.basename(e);if(vl.test(i)||yl.test(i)||i.endsWith(`.d.ts`))return!1;let a=r??n.getModuleAnalysis(e,t);return a.directives.hasUseClient?!1:a.directives.hasUseServer?!0:!n.isOnlyImportedByClientComponents(e)&&Al(e,a)&&Nl(t,a)}function Fl(e,t,n=[]){let r=Ml(t,Sr(e,n));t.clearClientComponentFiles(),t.populateImportGraphFromFiles(r);let i=[],a=[];for(let{filePath:e,code:n,analysis:o}of r)o.directives.hasUseClient&&(a.push(e),t.recordClientComponent(e,n)),Pl(e,n,t,o)&&(t.addServerComponent(e,n,o),i.push(e));return{serverComponentPaths:i,clientComponentPaths:a}}function Il(e={}){let t=null,n,r,i,a={},o=!1;async function s(){if(t){try{await t.buildMdxRegistry(e.mdx)}catch(e){console.warn(`[rari] Failed to build MDX component registry:`,e)}try{let{generateRobotsFile:e}=await import(`./robots-C4JcczMZ.mjs`);await e({appDir:O.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate robots.txt:`,e)}try{let{generateSitemapFiles:e}=await import(`./sitemap-BcUkIffd.mjs`);await e({appDir:O.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate sitemap:`,e)}try{let{generateFeedFile:e}=await import(`./feed-CfjUO7Zz.mjs`);await e({appDir:O.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate feed:`,e)}try{let e=O.join(i,`server`,`routes.json`);if(E.existsSync(e)){let t=it(E.readFileSync(e,`utf-8`));t.length>0&&await nt({appDir:O.join(n,`src`,`app`),outDir:r,icons:t})}}catch(e){console.warn(`[rari] Failed to copy app icons:`,e)}try{let t=Ns(n,e.mdx),a=[`public/content`,C(O.relative(n,O.join(i,`content`))),C(O.relative(n,O.join(r,`content`)))].filter(e=>e!==``&&!e.startsWith(`..`)&&!O.isAbsolute(e)),o=Ps(n,t.contentDirs).filter(e=>{let t=C(O.relative(n,e));return!a.some(e=>t===e||t.startsWith(`${e}/`))});o.length>0&&Is(o,O.join(i,`content`))}catch(e){console.warn(`[rari] Failed to copy MDX content:`,e)}ys(r)}}return{name:`rari-server-build`,sharedDuringBuild:!0,configResolved(s){n=s.root,r=de(s.root,s.build.outDir),i=ue(r),o=!1;let c=Vt(s);a=c;let l=typeof s.build.assetsDir==`string`&&s.build.assetsDir!==``?S(s.build.assetsDir):`assets`;t=new jl(n,{...e,alias:c,assetsDir:l,outDir:i,clientOutDir:r,minify:e.minify??s.mode===`production`})},buildStart(){if(!t)return;let e=O.join(n,`src`);E.existsSync(e)&&Fl(e,t,Object.values(a))},async buildApp(e){if(!t||o)return;let n=e.environments.client;n.isBuilt||await e.build(n);let r=e.environments.rsc,i=e.environments.ssr;await r.init(),await i.init(),t.setViteBuilder(e),await t.buildServerComponents(),await t.buildSSRClientComponents(),o=!0,await s()}}}function Ll(e,t,n){if(n.length===0)return e;let r=Nn(e).find(e=>e.source===t&&!e.typeOnly&&!e.sideEffectOnly),i=/* @__PURE__ */ new Map;if(r!=null)for(let e of r.named)e.typeOnly||i.set(e.imported,e.local);for(let e of n)i.has(e)||i.set(e,e);let a=[...i.entries()].map(([e,t])=>e===t?e:`${e} as ${t}`);if(r?.namespaceBinding!=null||r?.named.some(e=>e.typeOnly)){let i=n.filter(e=>!r.named.some(t=>!t.typeOnly&&t.imported===e));return i.length===0?e:`${`import { ${[...new Set(i)].join(`, `)} } from ${JSON.stringify(t)};`}\n${e}`}let o=`import ${r?.defaultBinding==null?``:`${r.defaultBinding}, `}{ ${a.join(`, `)} } from ${JSON.stringify(t)};`;return r==null?`${o}\n\n${e}`:e.slice(0,r.start)+o+e.slice(r.end)}function Rl(e,t){return`const ${e} = createClientModuleProxy(${JSON.stringify(t)});`}function zl(e,t,n){return`const ${e} = registerClientReference(
|
|
82
82
|
function() {
|
|
83
83
|
throw new Error("Attempted to call ${e} from the server but it's on the client. It can only be rendered as a Component or passed to props of a Client Component.");
|
|
84
84
|
},
|
|
85
85
|
${JSON.stringify(t)},
|
|
86
86
|
${JSON.stringify(n)}
|
|
87
|
-
);`}function
|
|
88
|
-
`),helpers:[...r]}}const Ll=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Rl(e){return Ll.test(e)}const zl=/* @__PURE__ */ new Set(/* @__PURE__ */ `undefined.NaN.Infinity.arguments.Object.Array.String.Number.Boolean.Symbol.BigInt.Math.Date.JSON.Promise.Error.TypeError.RangeError.Map.Set.WeakMap.WeakSet.RegExp.Proxy.Reflect.Function.console.fetch.process.Buffer.globalThis.global.window.document.navigator.location.crypto.TextEncoder.TextDecoder.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.setTimeout.clearTimeout.setInterval.clearInterval.queueMicrotask.structuredClone.atob.btoa.React.jsx.jsxs.Fragment`.split(`.`)),Bl=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.return.throw.if.else.for.while.do.switch.case.break.continue.new.typeof.instanceof.void.delete.yield.class.extends.super.this.try.catch.finally.with.debugger.default.of.in.from.as.import.export.async.function.const.let.var.true.false.null.static.get.set.typeof`.split(`.`));function Vl(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Hl(e){return Vl(e)||e>=48&&e<=57}function Y(e,t){let n=e.length;for(;t<n;){let r=Ul(e,t,n);if(r==null)break;t=r}return t}function Ul(e,t,n){let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===65279)return t+1;if(r===47&&e.charCodeAt(t+1)===47){let r=t+2;for(;r<n&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r++;return r}if(r===47&&e.charCodeAt(t+1)===42){let r=t+2;for(;r<n-1&&(e.charCodeAt(r)!==42||e.charCodeAt(r+1)!==47);)r++;return r+2}return null}function Wl(e,t,n){t++;let r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(r===92){t+=2;continue}if(r===n)return t+1;t++}return t}function Gl(e,t,n,r){let i=t,a=0,o=e.length;for(;i<o;){let t=V(e,i,o);if(t!==-1){i=t;continue}let s=e.charCodeAt(i);if(s===n)a++;else if(s===r&&(a--,a===0))return i+1;i++}return i}function Kl(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function ql(e,t,n){let r=Y(e,t+1);if(r>=n)return!1;let i=e.charCodeAt(r);if(i!==39&&i!==34)return!1;let a=r+1,o=Wl(e,r,i);return o-1-a!=10||!Kl(e,a,`use server`)?!1:Jl(e,o,n)}function Jl(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}return t===59||t===10||t===13||t===47&&e.charCodeAt(r+1)===47||t===47&&e.charCodeAt(r+1)===42}return!0}function Yl(e,t,n){let r=Y(e,t+1),i=e.charCodeAt(r);return i!==39&&i!==34?e.slice(t+1,n):(r=Y(e,Wl(e,r,i)),e.charCodeAt(r)===59&&r++,r=Y(e,r),e.slice(r,n))}function X(e,t){if(!Vl(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&Hl(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function Xl(e,t,n){if(!Kl(e,t,n))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length<e.length?e.charCodeAt(t+n.length):-1;return!(r!==-1&&Hl(r)||i!==-1&&Hl(i))}function Zl(e,t,n){return e===0&&t===0&&n===0}function Ql(e,t){return e===40?(t.paren++,null):e===41?(t.paren=Math.max(0,t.paren-1),null):e===123?(t.brace++,null):e===125?Zl(t.paren,t.brace,t.bracket)?-1:(t.brace=Math.max(0,t.brace-1),null):e===91?(t.bracket++,null):e===93?Zl(t.paren,t.brace,t.bracket)?-1:(t.bracket=Math.max(0,t.bracket-1),null):e===44&&Zl(t.paren,t.brace,t.bracket)?-1:null}function $l(e,t,n){let r=Y(e,t+1),i={paren:0,brace:0,bracket:0};for(;r<n;){let t=V(e,r,n);if(t!==-1){r=t;continue}if(Ql(e.charCodeAt(r),i)===-1)return r;r++}return r}function eu(e,t,n,r,i){let a=X(e,t);if(a==null)return t+1;let o=Y(e,a.end);if(n===123&&e.charCodeAt(o)===58)return o+1;i.add(a.name);let s=a.end,c=Y(e,s);return e.charCodeAt(c)===61&&(s=$l(e,c,r-1)),s}function tu(e,t,n){let r=e.charCodeAt(t),i=Gl(e,t,r,r===123?125:93),a=t+1;for(;a<i-1&&(a=Y(e,a),!(a>=i-1));){let t=e.charCodeAt(a);if(t===123||t===91){a=tu(e,a,n);continue}if(t===46&&e.charCodeAt(a+1)===46&&e.charCodeAt(a+2)===46){a=nu(e,a,n);continue}a=eu(e,a,r,i,n)}return i}function nu(e,t,n){t+=3,t=Y(e,t);let r=X(e,t);return r?(n.add(r.name),r.end):t}function ru(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r&&(n=Y(e,n),!(n>=r));){let r=e.charCodeAt(n);if(r===123||r===91){n=tu(e,n,t);continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n=nu(e,n,t);continue}let i=X(e,n);if(i){t.add(i.name),n=i.end;continue}n++}return t}function iu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:const|let|var|function|class|async\s+function)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function au(e,t){for(let n of e.split(`,`)){let e=n.trim();if(!e||e.startsWith(`type `))continue;let r=(e.split(/\s+as\s+/).at(-1)??``).trim();r&&t.add(r)}}function ou(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:import|export)\s+(?:type\s+)?(?:\{([^}]+)\}|(\*\s+as\s+[A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*))/g)){if(n[1]&&au(n[1],t),n[2]){let e=/as\s+([A-Za-z_$][\w$]*)/.exec(n[2]);e&&t.add(e[1])}n[3]&&n[3]!==`type`&&n[3]!==`async`&&n[3]!==`function`&&n[3]!==`class`&&t.add(n[3])}for(let n of e.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?(?:function|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function su(e,t){return t<=0||e.charCodeAt(t-1)!==46?!1:t<2||e.charCodeAt(t-2)!==46}function cu(e,t,n,r,i){let a=t;for(;a<n;){let t=V(e,a,n);if(t!==-1){a=t;continue}if(!Vl(e.charCodeAt(a))){a++;continue}let o=X(e,a);if(o==null){a++;continue}if(su(e,a)){a=o.end;continue}if(gu(e,a,o.end)){a=o.end;continue}r.has(o.name)||i.add(o.name),a=o.end}}function lu(e,t,n){let r=0,i=e.length;for(;r<i;){let a=V(e,r,i);if(a!==-1){r=a;continue}if(e.charCodeAt(r)===61){let a=e.charCodeAt(r+1);if(a===62||a===61){r++;continue}let o=$l(e,r,i);cu(e,r+1,o,t,n),r=o;continue}r++}}function uu(e,t,n,r){let i=/* @__PURE__ */ new Set([...ru(t),...iu(e),...n,...zl,...Bl]);r!=null&&r!==``&&i.add(r);let a=/* @__PURE__ */ new Set;return cu(e,0,e.length,i,a),lu(t,i,a),[...a]}function du(e,t,n){if(t===n)return e;let r=``,i=0,a=0,o=e.length;for(;i<o;){let s=V(e,i,o);if(s!==-1){i=s;continue}if(!Vl(e.charCodeAt(i))){i++;continue}let c=X(e,i);if(c==null){i++;continue}c.name===t&&!su(e,i)&&!gu(e,i,c.end)&&(r+=e.slice(a,i)+n,a=c.end),i=c.end}return r+e.slice(a)}function fu(e){return e===32||e===9||e===10||e===13||e===65279}function pu(e,t){if(t<2||e.charCodeAt(t-1)!==47||e.charCodeAt(t-2)!==42)return null;let n=-1,r=t-3;for(;r>=0;){let t=e.charCodeAt(r),i=e.charCodeAt(r+1);if(t===47&&i===42){n=r,r--;continue}if(t===42&&i===47){if(r>0&&e.charCodeAt(r-1)===47){r--;continue}break}r--}return n>=0?n:null}function Z(e,t){for(;t>0;){if(fu(e.charCodeAt(t-1))){t--;continue}let n=pu(e,t);if(n==null)break;t=n}return t}function Q(e,t,n){let r=t-n.length;return r<0||!Xl(e,r,n)?null:r}const mu=/* @__PURE__ */ new Set([40,91,44,61,58,63,46,43,45,42,47,37,38,124,94,33,126,60,62]);function hu(e,t){let n=Z(e,t);if(n<=0)return!0;let r=Q(e,n,`default`);if(r!=null)return Q(e,Z(e,r),`export`)!=null;if(Q(e,n,`export`)!=null)return!0;let i=e.charCodeAt(n-1);if(i===59||i===125)return!0;if(i===123){let t=Z(e,n-1);return t<=0||e.charCodeAt(t-1)!==61}let a=!1;for(let r=n;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===13){a=!0;break}}return a?!mu.has(i):!1}function gu(e,t,n){let r=Y(e,n);if(e.charCodeAt(r)!==58)return!1;let i=Z(e,t);if(i===0)return!1;let a=e.charCodeAt(i-1);return a===123||a===44}function _u(e,t,n){if(t<=0||e.charCodeAt(t-1)!==61)return null;let r=Z(e,t-1),i=r;for(;i>0&&Hl(e.charCodeAt(i-1));)i--;if(i>=r||!Vl(e.charCodeAt(i)))return null;let a=e.slice(i,r),o=Z(e,i),s=Q(e,o,`const`)??Q(e,o,`let`)??Q(e,o,`var`);return s==null?null:Q(e,Z(e,s),`export`)==null?{start:n,exportKind:null,bindingName:a}:{start:n,exportKind:`named`,bindingName:a}}function vu(e,t){let n=Z(e,t),r=Q(e,n,`default`);if(r!=null){n=Z(e,r);let t=Q(e,n,`export`);if(t!=null)return{start:t,exportKind:`default`,bindingName:null}}let i=_u(e,n,t);if(i!=null)return i;let a=Q(e,n,`export`);return a==null?{start:t,exportKind:null,bindingName:null}:{start:a,exportKind:`named`,bindingName:null}}function yu(e,t,n,r){if(!Xl(e,n,`function`))return null;n=Y(e,n+8),e.charCodeAt(n)===42&&(n=Y(e,n+1));let i=null,a=X(e,n);if(a&&(i=a.name,n=Y(e,a.end)),e.charCodeAt(n)!==40)return{action:null,nextI:t+1};let o=Gl(e,n,40,41),s=e.slice(n+1,o-1);if(n=Y(e,o),e.charCodeAt(n)!==123)return{action:null,nextI:t+1};let c=Gl(e,n,123,125)-1;if(!ql(e,n,c))return{action:null,nextI:n+1};let l=i!=null&&hu(e,t);return{action:{start:t,end:c+1,bodyOpen:n,bodyClose:c,paramsRaw:s,isAsync:r,name:i,kind:l?`declaration`:`expression`},nextI:c+1}}function bu(e,t,n,r){let i,a;if(e.charCodeAt(n)===40)i=Gl(e,n,40,41),a=e.slice(n+1,i-1);else{let t=X(e,n);if(t==null)return null;i=t.end,a=t.name}let o=Y(e,i);if(e.charCodeAt(o)!==61||e.charCodeAt(o+1)!==62||(o=Y(e,o+2),e.charCodeAt(o)!==123))return null;let s=Gl(e,o,123,125)-1;return ql(e,o,s)?{action:{start:t,end:s+1,bodyOpen:o,bodyClose:s,paramsRaw:a,isAsync:r,name:null,kind:`arrow`},nextI:s+1}:{action:null,nextI:o+1}}function xu(e,t,n){if(!Xl(e,t,`async`)&&!Xl(e,t,`function`))return null;let r=t,i=t,a=!1;Xl(e,i,`async`)&&(a=!0,i=Y(e,i+5));let o=yu(e,r,i,a);if(o!=null)return o.action!=null&&n.push(o.action),o.nextI;if(!a)return null;let s=bu(e,r,i,!0);return s==null?null:(s.action!=null&&n.push(s.action),s.nextI)}function Su(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34||r===96)return Wl(e,t,r);if(r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42))return Y(e,t);let i=xu(e,t,n);if(i!=null)return i;let a=bu(e,t,t,!1);return a==null?t+1:(a.action!=null&&n.push(a.action),a.nextI)}function Cu(e){let t=[],n=e.length,r=0;for(;r<n;)r=Su(e,r,t);return t}function wu(e,t,n,r,i){return r==="default"?{rewrittenExport:`default`,replacement:`export default registerServerReference(${t}, ${JSON.stringify(n)}, "default")`}:r===`named`&&e.name!=null&&e.kind===`declaration`?{rewrittenExport:e.name,replacement:`export const ${e.name} = registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(e.name)})`}:r===`named`&&i!=null?{rewrittenExport:i,replacement:`registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(i)})`}:e.kind===`declaration`&&e.name!=null?{replacement:`const ${e.name} = ${t}`,rewrittenExport:null}:{replacement:t,rewrittenExport:null}}function Tu(e,t,n,r,i,a,o,s){if(s==null){e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`,`registerServerReference(${r}, ${JSON.stringify(o)}, ${JSON.stringify(r)});`);return}e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`),t.unshift(s)}function Eu(e,t){let n=Cu(e);if(n.length===0)return null;let r=ou(e),i=[],a=[],o=e,s=[],c=!1,l=[...n].sort((e,t)=>t.start-e.start),u=n.length-1;for(let e of l){let n=e.name??`anonymous_server_function`,l=`$$ACTION_${u}_${n.replace(/\W/g,`_`)}`;u--,i.unshift(l);let d=Yl(o,e.bodyOpen,e.bodyClose),f=e.kind===`expression`&&e.name!=null?e.name:null,p=uu(d,e.paramsRaw,r,f),m=f==null?d:du(d,f,l),h=[...p,e.paramsRaw.trim()].filter(e=>e!==``).join(`, `),g=e.isAsync?`async `:``,_=p.length>0?`${l}.bind(null, ${p.join(`, `)})`:l,{start:v,exportKind:y,bindingName:ee}=vu(o,e.start),{replacement:te,rewrittenExport:ne}=wu(e,_,t,y,ee);Tu(s,a,g,l,h,m,t,ne),c=!0,o=o.slice(0,v)+te+o.slice(e.end)}let d=c?`import { registerServerReference } from ${JSON.stringify(`react-server-dom-rari/server`)};\n`:``;return{code:`${c&&!Rl(o)?d:``}${o}\n\n${s.join(`
|
|
89
|
-
`)}\n`,actionNames:i,rewrittenExportNames:a}}const
|
|
90
|
-
`)},\n])`;return t.replace(
|
|
87
|
+
);`}function Bl(e,t){let n=[],r=/* @__PURE__ */ new Set;e.namespaceBinding!=null&&(r.add(`createClientModuleProxy`),n.push(Rl(e.namespaceBinding,t))),e.defaultBinding!=null&&(r.add(`registerClientReference`),n.push(zl(e.defaultBinding,t,`default`)));for(let i of e.named)i.typeOnly||(r.add(`registerClientReference`),n.push(zl(i.local,t,i.imported)));return n.length===0?{code:``,helpers:[]}:{code:n.join(`
|
|
88
|
+
`),helpers:[...r]}}const Vl=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Hl(e){return Vl.test(e)}const Ul=/* @__PURE__ */ new Set(/* @__PURE__ */ `undefined.NaN.Infinity.arguments.Object.Array.String.Number.Boolean.Symbol.BigInt.Math.Date.JSON.Promise.Error.TypeError.RangeError.Map.Set.WeakMap.WeakSet.RegExp.Proxy.Reflect.Function.console.fetch.process.Buffer.globalThis.global.window.document.navigator.location.crypto.TextEncoder.TextDecoder.URL.URLSearchParams.FormData.Headers.Request.Response.AbortController.AbortSignal.setTimeout.clearTimeout.setInterval.clearInterval.queueMicrotask.structuredClone.atob.btoa.React.jsx.jsxs.Fragment`.split(`.`)),Wl=/* @__PURE__ */ new Set(/* @__PURE__ */ `await.return.throw.if.else.for.while.do.switch.case.break.continue.new.typeof.instanceof.void.delete.yield.class.extends.super.this.try.catch.finally.with.debugger.default.of.in.from.as.import.export.async.function.const.let.var.true.false.null.static.get.set.typeof`.split(`.`));function Gl(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Kl(e){return Gl(e)||e>=48&&e<=57}function Y(e,t){let n=e.length;for(;t<n;){let r=ql(e,t,n);if(r==null)break;t=r}return t}function ql(e,t,n){let r=e.charCodeAt(t);if(r===32||r===9||r===10||r===13||r===65279)return t+1;if(r===47&&e.charCodeAt(t+1)===47){let r=t+2;for(;r<n&&e.charCodeAt(r)!==10&&e.charCodeAt(r)!==13;)r++;return r}if(r===47&&e.charCodeAt(t+1)===42){let r=t+2;for(;r<n-1&&(e.charCodeAt(r)!==42||e.charCodeAt(r+1)!==47);)r++;return r+2}return null}function Jl(e,t,n){t++;let r=e.length;for(;t<r;){let r=e.charCodeAt(t);if(r===92){t+=2;continue}if(r===n)return t+1;t++}return t}function Yl(e,t,n,r){let i=t,a=0,o=e.length;for(;i<o;){let t=U(e,i,o);if(t!==-1){i=t;continue}let s=e.charCodeAt(i);if(s===n)a++;else if(s===r&&(a--,a===0))return i+1;i++}return i}function Xl(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function Zl(e,t,n){let r=Y(e,t+1);if(r>=n)return!1;let i=e.charCodeAt(r);if(i!==39&&i!==34)return!1;let a=r+1,o=Jl(e,r,i);return o-1-a!=10||!Xl(e,a,`use server`)?!1:Ql(e,o,n)}function Ql(e,t,n){let r=t;for(;r<n;){let t=e.charCodeAt(r);if(t===32||t===9){r++;continue}return t===59||t===10||t===13||t===47&&e.charCodeAt(r+1)===47||t===47&&e.charCodeAt(r+1)===42}return!0}function $l(e,t,n){let r=Y(e,t+1),i=e.charCodeAt(r);return i!==39&&i!==34?e.slice(t+1,n):(r=Y(e,Jl(e,r,i)),e.charCodeAt(r)===59&&r++,r=Y(e,r),e.slice(r,n))}function X(e,t){if(!Gl(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&Kl(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function eu(e,t,n){if(!Xl(e,t,n))return!1;let r=t>0?e.charCodeAt(t-1):-1,i=t+n.length<e.length?e.charCodeAt(t+n.length):-1;return!(r!==-1&&Kl(r)||i!==-1&&Kl(i))}function tu(e,t,n){return e===0&&t===0&&n===0}function nu(e,t){return e===40?(t.paren++,null):e===41?(t.paren=Math.max(0,t.paren-1),null):e===123?(t.brace++,null):e===125?tu(t.paren,t.brace,t.bracket)?-1:(t.brace=Math.max(0,t.brace-1),null):e===91?(t.bracket++,null):e===93?tu(t.paren,t.brace,t.bracket)?-1:(t.bracket=Math.max(0,t.bracket-1),null):e===44&&tu(t.paren,t.brace,t.bracket)?-1:null}function ru(e,t,n){let r=Y(e,t+1),i={paren:0,brace:0,bracket:0};for(;r<n;){let t=U(e,r,n);if(t!==-1){r=t;continue}if(nu(e.charCodeAt(r),i)===-1)return r;r++}return r}function iu(e,t,n,r,i){let a=X(e,t);if(a==null)return t+1;let o=Y(e,a.end);if(n===123&&e.charCodeAt(o)===58)return o+1;i.add(a.name);let s=a.end,c=Y(e,s);return e.charCodeAt(c)===61&&(s=ru(e,c,r-1)),s}function au(e,t,n){let r=e.charCodeAt(t),i=Yl(e,t,r,r===123?125:93),a=t+1;for(;a<i-1&&(a=Y(e,a),!(a>=i-1));){let t=e.charCodeAt(a);if(t===123||t===91){a=au(e,a,n);continue}if(t===46&&e.charCodeAt(a+1)===46&&e.charCodeAt(a+2)===46){a=ou(e,a,n);continue}a=iu(e,a,r,i,n)}return i}function ou(e,t,n){t+=3,t=Y(e,t);let r=X(e,t);return r?(n.add(r.name),r.end):t}function su(e){let t=/* @__PURE__ */ new Set,n=0,r=e.length;for(;n<r&&(n=Y(e,n),!(n>=r));){let r=e.charCodeAt(n);if(r===123||r===91){n=au(e,n,t);continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n=ou(e,n,t);continue}let i=X(e,n);if(i){t.add(i.name),n=i.end;continue}n++}return t}function cu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:const|let|var|function|class|async\s+function)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function lu(e,t){for(let n of e.split(`,`)){let e=n.trim();if(!e||e.startsWith(`type `))continue;let r=(e.split(/\s+as\s+/).at(-1)??``).trim();r&&t.add(r)}}function uu(e){let t=/* @__PURE__ */ new Set;for(let n of e.matchAll(/\b(?:import|export)\s+(?:type\s+)?(?:\{([^}]+)\}|(\*\s+as\s+[A-Za-z_$][\w$]*)|([A-Za-z_$][\w$]*))/g)){if(n[1]&&lu(n[1],t),n[2]){let e=/as\s+([A-Za-z_$][\w$]*)/.exec(n[2]);e&&t.add(e[1])}n[3]&&n[3]!==`type`&&n[3]!==`async`&&n[3]!==`function`&&n[3]!==`class`&&t.add(n[3])}for(let n of e.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:async\s+)?(?:function|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))t.add(n[1]);return t}function du(e,t){return t<=0||e.charCodeAt(t-1)!==46?!1:t<2||e.charCodeAt(t-2)!==46}function fu(e,t,n,r,i){let a=t;for(;a<n;){let t=U(e,a,n);if(t!==-1){a=t;continue}if(!Gl(e.charCodeAt(a))){a++;continue}let o=X(e,a);if(o==null){a++;continue}if(du(e,a)){a=o.end;continue}if(bu(e,a,o.end)){a=o.end;continue}r.has(o.name)||i.add(o.name),a=o.end}}function pu(e,t,n){let r=0,i=e.length;for(;r<i;){let a=U(e,r,i);if(a!==-1){r=a;continue}if(e.charCodeAt(r)===61){let a=e.charCodeAt(r+1);if(a===62||a===61){r++;continue}let o=ru(e,r,i);fu(e,r+1,o,t,n),r=o;continue}r++}}function mu(e,t,n,r){let i=/* @__PURE__ */ new Set([...su(t),...cu(e),...n,...Ul,...Wl]);r!=null&&r!==``&&i.add(r);let a=/* @__PURE__ */ new Set;return fu(e,0,e.length,i,a),pu(t,i,a),[...a]}function hu(e,t,n){if(t===n)return e;let r=``,i=0,a=0,o=e.length;for(;i<o;){let s=U(e,i,o);if(s!==-1){i=s;continue}if(!Gl(e.charCodeAt(i))){i++;continue}let c=X(e,i);if(c==null){i++;continue}c.name===t&&!du(e,i)&&!bu(e,i,c.end)&&(r+=e.slice(a,i)+n,a=c.end),i=c.end}return r+e.slice(a)}function gu(e){return e===32||e===9||e===10||e===13||e===65279}function _u(e,t){if(t<2||e.charCodeAt(t-1)!==47||e.charCodeAt(t-2)!==42)return null;let n=-1,r=t-3;for(;r>=0;){let t=e.charCodeAt(r),i=e.charCodeAt(r+1);if(t===47&&i===42){n=r,r--;continue}if(t===42&&i===47){if(r>0&&e.charCodeAt(r-1)===47){r--;continue}break}r--}return n>=0?n:null}function Z(e,t){for(;t>0;){if(gu(e.charCodeAt(t-1))){t--;continue}let n=_u(e,t);if(n==null)break;t=n}return t}function Q(e,t,n){let r=t-n.length;return r<0||!eu(e,r,n)?null:r}const vu=/* @__PURE__ */ new Set([40,91,44,61,58,63,46,43,45,42,47,37,38,124,94,33,126,60,62]);function yu(e,t){let n=Z(e,t);if(n<=0)return!0;let r=Q(e,n,`default`);if(r!=null)return Q(e,Z(e,r),`export`)!=null;if(Q(e,n,`export`)!=null)return!0;let i=e.charCodeAt(n-1);if(i===59||i===125)return!0;if(i===123){let t=Z(e,n-1);return t<=0||e.charCodeAt(t-1)!==61}let a=!1;for(let r=n;r<t;r++){let t=e.charCodeAt(r);if(t===10||t===13){a=!0;break}}return a?!vu.has(i):!1}function bu(e,t,n){let r=Y(e,n);if(e.charCodeAt(r)!==58)return!1;let i=Z(e,t);if(i===0)return!1;let a=e.charCodeAt(i-1);return a===123||a===44}function xu(e,t,n){if(t<=0||e.charCodeAt(t-1)!==61)return null;let r=Z(e,t-1),i=r;for(;i>0&&Kl(e.charCodeAt(i-1));)i--;if(i>=r||!Gl(e.charCodeAt(i)))return null;let a=e.slice(i,r),o=Z(e,i),s=Q(e,o,`const`)??Q(e,o,`let`)??Q(e,o,`var`);return s==null?null:Q(e,Z(e,s),`export`)==null?{start:n,exportKind:null,bindingName:a}:{start:n,exportKind:`named`,bindingName:a}}function Su(e,t){let n=Z(e,t),r=Q(e,n,`default`);if(r!=null){n=Z(e,r);let t=Q(e,n,`export`);if(t!=null)return{start:t,exportKind:`default`,bindingName:null}}let i=xu(e,n,t);if(i!=null)return i;let a=Q(e,n,`export`);return a==null?{start:t,exportKind:null,bindingName:null}:{start:a,exportKind:`named`,bindingName:null}}function Cu(e,t,n,r){if(!eu(e,n,`function`))return null;n=Y(e,n+8),e.charCodeAt(n)===42&&(n=Y(e,n+1));let i=null,a=X(e,n);if(a&&(i=a.name,n=Y(e,a.end)),e.charCodeAt(n)!==40)return{action:null,nextI:t+1};let o=Yl(e,n,40,41),s=e.slice(n+1,o-1);if(n=Y(e,o),e.charCodeAt(n)!==123)return{action:null,nextI:t+1};let c=Yl(e,n,123,125)-1;if(!Zl(e,n,c))return{action:null,nextI:n+1};let l=i!=null&&yu(e,t);return{action:{start:t,end:c+1,bodyOpen:n,bodyClose:c,paramsRaw:s,isAsync:r,name:i,kind:l?`declaration`:`expression`},nextI:c+1}}function wu(e,t,n,r){let i,a;if(e.charCodeAt(n)===40)i=Yl(e,n,40,41),a=e.slice(n+1,i-1);else{let t=X(e,n);if(t==null)return null;i=t.end,a=t.name}let o=Y(e,i);if(e.charCodeAt(o)!==61||e.charCodeAt(o+1)!==62||(o=Y(e,o+2),e.charCodeAt(o)!==123))return null;let s=Yl(e,o,123,125)-1;return Zl(e,o,s)?{action:{start:t,end:s+1,bodyOpen:o,bodyClose:s,paramsRaw:a,isAsync:r,name:null,kind:`arrow`},nextI:s+1}:{action:null,nextI:o+1}}function Tu(e,t,n){if(!eu(e,t,`async`)&&!eu(e,t,`function`))return null;let r=t,i=t,a=!1;eu(e,i,`async`)&&(a=!0,i=Y(e,i+5));let o=Cu(e,r,i,a);if(o!=null)return o.action!=null&&n.push(o.action),o.nextI;if(!a)return null;let s=wu(e,r,i,!0);return s==null?null:(s.action!=null&&n.push(s.action),s.nextI)}function Eu(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34||r===96)return Jl(e,t,r);if(r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42))return Y(e,t);let i=Tu(e,t,n);if(i!=null)return i;let a=wu(e,t,t,!1);return a==null?t+1:(a.action!=null&&n.push(a.action),a.nextI)}function Du(e){let t=[],n=e.length,r=0;for(;r<n;)r=Eu(e,r,t);return t}function Ou(e,t,n,r,i){return r==="default"?{rewrittenExport:`default`,replacement:`export default registerServerReference(${t}, ${JSON.stringify(n)}, "default")`}:r===`named`&&e.name!=null&&e.kind===`declaration`?{rewrittenExport:e.name,replacement:`export const ${e.name} = registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(e.name)})`}:r===`named`&&i!=null?{rewrittenExport:i,replacement:`registerServerReference(${t}, ${JSON.stringify(n)}, ${JSON.stringify(i)})`}:e.kind===`declaration`&&e.name!=null?{replacement:`const ${e.name} = ${t}`,rewrittenExport:null}:{replacement:t,rewrittenExport:null}}function ku(e,t,n,r,i,a,o,s){if(s==null){e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`,`registerServerReference(${r}, ${JSON.stringify(o)}, ${JSON.stringify(r)});`);return}e.unshift(`${n}function ${r}(${i}) {\n${a}\n}`),t.unshift(s)}function Au(e,t){let n=Du(e);if(n.length===0)return null;let r=uu(e),i=[],a=[],o=e,s=[],c=!1,l=[...n].sort((e,t)=>t.start-e.start),u=n.length-1;for(let e of l){let n=e.name??`anonymous_server_function`,l=`$$ACTION_${u}_${n.replace(/\W/g,`_`)}`;u--,i.unshift(l);let d=$l(o,e.bodyOpen,e.bodyClose),f=e.kind===`expression`&&e.name!=null?e.name:null,p=mu(d,e.paramsRaw,r,f),m=f==null?d:hu(d,f,l),h=[...p,e.paramsRaw.trim()].filter(e=>e!==``).join(`, `),g=e.isAsync?`async `:``,_=p.length>0?`${l}.bind(null, ${p.join(`, `)})`:l,{start:v,exportKind:ee,bindingName:y}=Su(o,e.start),{replacement:te,rewrittenExport:ne}=Ou(e,_,t,ee,y);ku(s,a,g,l,h,m,t,ne),c=!0,o=o.slice(0,v)+te+o.slice(e.end)}let d=c?`import { registerServerReference } from ${JSON.stringify(`react-server-dom-rari/server`)};\n`:``;return{code:`${c&&!Hl(o)?d:``}${o}\n\n${s.join(`
|
|
89
|
+
`)}\n`,actionNames:i,rewrittenExportNames:a}}const ju=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,Mu=/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Nu=/import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Pu=/defineMdxComponents\s*\(\s*\{([\s\S]*?)\}\s*\)/;function Fu(e,t,n){for(let r of t.split(`,`)){let t=r.trim();if(!t||(t=t.replace(/^type\s+/i,``).trim(),!t))continue;let i=t.split(/\s+as\s+/i),a=(i[1]??i[0]).trim();a&&n.set(a,e)}}function Iu(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(Nu))t.set(n[1],n[3]),Fu(n[3],n[2],t);for(let n of e.matchAll(ju))t.set(n[1],n[2]);for(let n of e.matchAll(Mu))Fu(n[2],n[1],t);return t}function Lu(e){let t=[];for(let n of e.split(`,`)){let e=n.trim();if(!e)continue;let r=e.indexOf(`:`);if(r===-1){t.push({name:e,binding:e});continue}let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();i&&a&&t.push({name:i,binding:a})}return t}function Ru(e){try{return V(E.readFileSync(e,`utf-8`)).topLevelUseClient}catch{return!1}}function zu(e){let{code:t,id:n,projectRoot:r,resolvedAlias:i}=e;if(!t.includes(`defineMdxComponents`)||t.includes(`__RARI_MDX_RESOLVED__`))return null;let a=Pu.exec(t);if(!a)return null;let o=Iu(t),s=Lu(a[1]);if(s.length===0)return null;let c=`defineMdxComponents(/* __RARI_MDX_RESOLVED__ */[\n${s.map(({name:e,binding:t})=>{let a=o.get(t);if(a==null||a===``)throw Error(`[rari/mdx] Could not resolve import for MDX component "${e}" (binding "${t}") in ${n}`);let s=ge(a,n,i),c=Ut(s,r),l=Ru(s);return` { name: ${JSON.stringify(e)}, component: ${t}, id: ${JSON.stringify(c)}, client: ${l} }`}).join(`,
|
|
90
|
+
`)},\n])`;return t.replace(Pu,c)}const Bu=/forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/,Vu=/\.[cm]?[jt]sx?$/,Hu=/['"]use memo['"]/;function Uu(e){return{...e===!0?{}:e,target:`19`}}function Wu(e,t){return t.compilationMode===`annotation`?Hu.test(e):Bu.test(e)}function Gu(e){if(e.startsWith(`\0`)||e.includes(`virtual:`))return!1;let t=se(e);return/\.d\.[cm]?ts$/.test(t)||t.includes(`/dist/`)?!1:Vu.test(t)&&!t.includes(`/node_modules/`)}const Ku=/\.[jt]sx$/;function qu(e,t=`app`){let n=Uu(e),r,i=!0,a=!1,o=!1,s=async e=>{if(r)return r;try{return r=await import(`oxc-transform-react`),r}catch(t){let n=l(t);return e(`React Compiler requires the optional \`oxc-transform-react\` package. Install it before enabling \`rari({ compiler: true })\`.${n==null?``:`\n${n.message}`}`)}};return{name:t===`library`?`rari:react-compiler-library`:`rari:react-compiler`,enforce:`pre`,async config(e,{command:n}){return await s(e=>this.error(e)),t===`library`?(o=!1,a=!1,{}):(o=n===`serve`,{oxc:{jsx:{refresh:!1}},optimizeDeps:{include:[`react/compiler-runtime`]}})},configResolved(e){if(t===`library`){i=e.build.sourcemap!==!1,a=!1,o=!1;return}i=e.command!==`build`||e.build.sourcemap!==!1,a=!e.isProduction,o=!e.isProduction&&e.command===`serve`&&e.server.hmr!==!1},async transform(e,c){if(!Gu(c))return null;let l=se(c);if(t===`library`&&!Ku.test(l)||Hn(e)||t===`app`&&this.environment.config.consumer===`server`)return null;let{transform:u}=r??await s(e=>this.error(e)),d=Wu(e,n),f=await u(l,e,{jsx:{runtime:`automatic`,development:a,importSource:`react`,refresh:o},reactCompiler:d?n:!1,sourcemap:i}),p=f.errors.map(e=>{let t=e.codeframe;return t!=null&&t!==``?`${e.message}\n${t}`:e.message});if(f.fatal){let e=p.join(`
|
|
91
91
|
|
|
92
|
-
`);this.error(e===``?`React Compiler transform failed.`:e)}for(let e of p)this.warn(e);return{code:f.code,map:f.map}}}}const
|
|
92
|
+
`);this.error(e===``?`React Compiler transform failed.`:e)}for(let e of p)this.warn(e);return{code:f.code,map:f.map}}}}const Ju=/\.[cm]?[jt]sx?$/,Yu=[/node_modules/,/\/dist\//];function Xu(){return[{name:`rari:react-refresh-runtime`,enforce:`pre`,apply:`serve`,resolveId(e){return e===`/@react-refresh`?e:null},load(e){return e===`/@react-refresh`?`/* global window */
|
|
93
93
|
/* eslint-disable eqeqeq, prefer-const, @typescript-eslint/no-empty-function */
|
|
94
94
|
|
|
95
95
|
/*! Copyright (c) Meta Platforms, Inc. and affiliates. **/
|
|
@@ -775,29 +775,29 @@ export const __hmr_import = (module) => import(/* @vite-ignore */ module)
|
|
|
775
775
|
|
|
776
776
|
// For backwards compatibility with @vitejs/plugin-react.
|
|
777
777
|
export default { injectIntoGlobalHook }
|
|
778
|
-
`:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&Pe({cwd:process.cwd(),include:[
|
|
778
|
+
`:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&Pe({cwd:process.cwd(),include:[Ju],exclude:Yu,jsxImportSource:`react`,reactRefreshHost:``})}}]}let Zu;async function Qu(){return Zu??=(async()=>{try{let e=await import(`@rari/use-cache`);e.requireNativeAddon();let t=e.transformUseCacheModule;if(typeof t!=`function`)throw TypeError("`@rari/use-cache` did not export transformUseCacheModule");return t}catch(e){let t=e instanceof Error&&e.message!==``?` ${e.message}`:``;throw Error(`\`experimental.useCache\` / \`experimental.useCacheRemote\` requires a working \`@rari/use-cache\` native addon. Install the optional platform package, or run \`just build-addon-dev\` in the monorepo.${t}`)}})(),Zu}async function $u(e){let t=await import(
|
|
779
779
|
/* @vite-ignore */
|
|
780
|
-
e);return
|
|
780
|
+
e);return c(t)?t:{}}function ed(e,t){e&&(e.notFound&&(t.notFound=!0),e.redirect!=null&&(t.redirect=typeof e.redirect==`string`?e.redirect:e.redirect.destination),e.revalidate!==void 0&&(t.revalidate=e.revalidate),e.props&&(t.props={...t.props,...e.props}))}async function td(t,n){try{ed(await t(),n)}catch(t){if(e(t)){n.notFound=!0;return}throw t}}async function nd(e,t,n,r){let i=e.getData;typeof i==`function`&&await td(async()=>i({params:t,searchParams:n}),r)}async function rd(e,t,n,r){let i=e.getServerSideProps;typeof i==`function`&&await td(async()=>i({params:t,searchParams:n}),r)}async function id(e,t,n){let r=e.getStaticProps;typeof r==`function`&&await td(async()=>r({params:t}),n)}
|
|
781
781
|
/* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
|
|
782
|
-
async function
|
|
782
|
+
async function ad(e,t,n){try{let r=await $u(e),i={props:{}};return await nd(r,t,n,i),await rd(r,t,n,i),await id(r,t,i),i}catch(t){return console.error(`[rari] Router: Failed to extract server props from ${e}:`,t),{props:{}}}}
|
|
783
783
|
/* v8 ignore stop */
|
|
784
784
|
/* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
|
|
785
|
-
async function
|
|
785
|
+
async function od(e,t,n){try{let r=await $u(e);if(typeof r.generateMetadata==`function`){let e=await r.generateMetadata({params:t,searchParams:n});if(c(e))return e}return c(r.metadata)?r.metadata:{}}catch(t){return console.error(`[rari] Router: Failed to extract metadata from ${e}:`,t),{}}}
|
|
786
786
|
/* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
|
|
787
|
-
async function
|
|
787
|
+
async function sd(e){try{let t=await He(e);return t==null?[]:i(t)?t:(n(e),[])}catch(t){return console.error(`[rari] Router: Failed to extract static params from ${e}:`,t),[]}}
|
|
788
788
|
/* v8 ignore stop */
|
|
789
789
|
/* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
|
|
790
|
-
async function
|
|
790
|
+
async function cd(e){try{let t=await $u(e);return!!(t.getData??t.getServerSideProps??t.getStaticProps??t.generateMetadata??t.generateStaticParams)}catch{return!1}}
|
|
791
791
|
/* v8 ignore stop */
|
|
792
|
-
const
|
|
792
|
+
const ld=/* @__PURE__ */ new Map;
|
|
793
793
|
/* v8 ignore start - depends on extractServerProps which requires dynamic imports */
|
|
794
|
-
async function
|
|
794
|
+
async function ud(e,t,n,r=6e4){let i=`${e}:${JSON.stringify(t)}:${JSON.stringify(n)}`,a=ld.get(i);if(a&&Date.now()-a.timestamp<r)return a.result;let o=await ad(e,t,n);return ld.set(i,{result:o,timestamp:Date.now()}),o}
|
|
795
795
|
/* v8 ignore stop */
|
|
796
|
-
function
|
|
796
|
+
function dd(){ld.clear()}
|
|
797
797
|
/* v8 ignore start - cache clearing logic, difficult to test without populating cache via dynamic imports */
|
|
798
|
-
function
|
|
798
|
+
function fd(e){for(let t of ld.keys())t.startsWith(e)&&ld.delete(t)}
|
|
799
799
|
/* v8 ignore stop */
|
|
800
|
-
const
|
|
800
|
+
const pd=/\.(?:js|mjs|cjs|ts|tsx|jsx|css|map|json|svg|png|jpe?g|gif|webp|avif|ico|woff2?|ttf|eot|txt|xml|html|wasm)$/i;async function md(e,t){let n=[],r=0;for await(let i of e){let a=Uint8Array.from(Te.from(i));if(r+=a.byteLength,r>t)throw e.destroy(),Object.assign(/* @__PURE__ */ Error(`Request body too large`),{statusCode:413});n.push(a)}let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.byteLength;return new Blob([i])}function hd(e){let t=e.slice(e.lastIndexOf(`/`)+1);return pd.test(t)}function $(e,t){return e===t||e.startsWith(`${t}/`)}const gd=/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,_d=/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,vd=/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,yd=/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,bd=/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,xd=/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,Sd=/import\s+["']\.\.?\/([^"']+)["'];?/g,Cd=/export\s+default\s+(?:async\s+)?function\s+(\w+)/,wd=/^['"]use client['"];?\s*$/gm,Td=/^[./@~#]/;function Ed(e,t){for(let n of Object.keys(t))if(e===n||e.startsWith(`${n}/`))return!0;return!1}function Dd(e){let t=a(e);return t===`ENOENT`||t===`ERR_PACKAGE_PATH_NOT_EXPORTED`||t===`ERR_MODULE_NOT_FOUND`}function Od(e){return e===`react`||e instanceof RegExp&&e.source===`^react$`&&e.flags===``}const kd=/from(\s*)(['"])(?:\.\/vendor\/react-flight-client\/index|rari\/runtime\/vendor\/react-flight-client\/index)\.mjs\2/g,Ad=/\bJSX\b/,jd={remotePatterns:[],localPatterns:[],deviceSizes:g,imageSizes:m,formats:h,qualityAllowlist:_,minimumCacheTTL:60};function Md(e){return[{pathname:`/${S(e)}/**`}]}function Nd(e,t,n=!0){let r=[...e??[]];if(!n)return r;for(let e of Md(t))r.some(t=>t.pathname===e.pathname)||r.push({...e});return r}const Pd=/* @__PURE__ */ new Map;async function Fd(e){let t=Pd.get(e);if(t!=null&&t!==``)return t;let n=import.meta.url,r=A(n),i=O.dirname(r),o=[O.join(i,`runtime`,e),O.join(i,`../runtime`,e)];for(let t of o)try{let n=await E.promises.readFile(t,`utf-8`);return t.endsWith(`.ts`)&&(n=n.replace(gd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(_d,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(vd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(yd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(bd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(xd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(Sd,(e,t)=>`import "rari/${t}";`)),Pd.set(e,n),n}catch(e){let n=a(e);n!==`ENOENT`&&n!==`EISDIR`&&console.warn(`[rari] Unexpected error reading ${t}:`,e)}throw Error(`Could not find ${e}. Tried: ${o.join(`, `)}`)}const Id=O.dirname(A(import.meta.url)),Ld=O.dirname(Id);function Rd(){let e=O.join(Ld,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(E.existsSync(e))return O.resolve(e);try{let e=A(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(E.existsSync(e))return O.resolve(e)}catch{}return null}const zd=Rd();function Bd(e){let t=[O.join(Id,`runtime`,e),O.join(Id,`../runtime`,e)];for(let e of t)if(E.existsSync(e))return e;return null}function Vd(e){return e.startsWith(Ld)}async function Hd(){return Fd(`rsc-client-runtime.mjs`)}async function Ud(e,t,n=``){let r=(await Fd(`entry-client.mjs`)).replace(`/*! @preserve CLIENT_COMPONENT_IMPORTS_PLACEHOLDER */`,e).replace(`/*! @preserve CLIENT_COMPONENT_REGISTRATIONS_PLACEHOLDER */`,t);return n===``?r:`${n}\n${r}`}async function Wd(){return Fd(`rsc-references.mjs`)}async function Gd(e,t,n=`assets`,r){let i=O.join(e,`src`),{getBinaryPath:a}=await import(`./platform.mjs`),o=a(),s=De(o,[`scan-images`,`--src`,i],{encoding:`utf8`,cwd:e,shell:!1,timeout:6e4});if(s.error)throw Error(`Failed to scan for image usage: ${s.error.message}`);if(s.signal)throw Error(`Failed to scan for image usage: process terminated by signal ${s.signal}`);if(s.status!==0)throw Error(`Failed to scan for image usage: ${s.stderr||s.stdout||`exit code ${s.status}`}`);let c;try{c={images:f(s.stdout,`images`)??[]}}catch(e){let t=e instanceof SyntaxError?e.message:u(e,String(e)),n=(s.stdout||s.stderr||`(empty)`).slice(0,500);throw Error(`Failed to parse image scanner output as JSON: ${t}. Scanner output: ${n}`,{cause:e})}let l=S(n),d=(()=>{let n=r??t.serverBuild?.clientOutDir??t.serverBuild?.outDir;return n!=null&&n!==``?O.isAbsolute(n)?n:O.resolve(e,n):O.join(e,`dist`,`client`)})(),p=O.basename(d)===`client`?O.dirname(d):d,m=C(O.relative(e,d))||`dist/client`,h={...jd,...t.images,assetsDir:l,outDir:m,localPatterns:Nd(t.images?.localPatterns,l,t.images?.includeBundledAssets!==!1),preoptimizeManifest:c.images},g=O.join(p,`server`);E.existsSync(g)||E.mkdirSync(g,{recursive:!0});let _=O.join(g,`image.json`);E.writeFileSync(_,JSON.stringify(h))}function Kd(e,t,n){try{let r=A(import.meta.resolve(n));t.has(n)||e.push({find:n,replacement:r})}catch(e){Dd(e)||console.warn(`[rari] Unexpected error resolving ${n}:`,e)}}function qd(e,t){let n=A(import.meta.resolve(`react`)),r=A(import.meta.resolve(`react-dom/client`)),i=A(import.meta.resolve(`react/jsx-runtime`)),a=[];return e.has(`react/jsx-runtime`)||a.push({find:`react/jsx-runtime`,replacement:i}),Kd(a,e,`react/jsx-dev-runtime`),Kd(a,e,`react/compiler-runtime`),t||a.push({find:/^react$/,replacement:n}),e.has(`react-dom/client`)||a.push({find:`react-dom/client`,replacement:r}),a}function Jd(e){let t=Bd(e);if(t!=null&&t!==``)return E.readFileSync(t,`utf-8`);throw Error("[rari] Runtime dist not built. Run `pnpm build` in the rari package first.")}function Yd(e){let t=`react-server-dom-webpack-client.browser.${e}.js`,n=`react-server-dom-webpack-client.edge.${e}.js`;try{let e=O.dirname(A(import.meta.resolve(`react-server-dom-webpack/package.json`)));return{browserClientPath:O.join(e,`cjs`,t),edgeClientPath:O.join(e,`cjs`,n)}}catch{let e=O.dirname(A(import.meta.url)),r=O.resolve(e,`../../node_modules`);return{browserClientPath:O.join(r,`react-server-dom-webpack/cjs`,t),edgeClientPath:O.join(r,`react-server-dom-webpack/cjs`,n)}}}function Xd(e,t,n,r){return!e&&!t||n===``||$(r,`/api`)||$(r,`/rsc`)}function Zd(e){let{browserClientPath:t,edgeClientPath:n}=Yd(e),r=Rt(E.readFileSync(t,`utf-8`),E.readFileSync(n,`utf-8`));return{code:`
|
|
801
801
|
import * as React from 'react';
|
|
802
802
|
import * as ReactDOM from 'react-dom';
|
|
803
803
|
import { callServer as rariCallServer } from 'rari/runtime/call-server';
|
|
@@ -849,7 +849,7 @@ export function createServerReference(id, callServer, encodeFormAction, findSour
|
|
|
849
849
|
|
|
850
850
|
export const encodeReply = module.exports.encodeReply;
|
|
851
851
|
export const createTemporaryReferenceSet = module.exports.createTemporaryReferenceSet;
|
|
852
|
-
`}}function
|
|
852
|
+
`}}function Qd(e,t){let n=O.relative(t,e),r=!n.startsWith(`..`)&&!O.isAbsolute(n),i=e.includes(`${O.sep}node_modules${O.sep}`),a=e.includes(`${O.sep}packages${O.sep}rari${O.sep}`)||e.includes(`${O.sep}packages${O.sep}use-cache${O.sep}`)||e.includes(`${O.sep}node_modules${O.sep}rari${O.sep}`)||e.includes(`${O.sep}node_modules${O.sep}@rari${O.sep}use-cache${O.sep}`);return r||i||a}function $d(e,t){if(!e.endsWith(`.mjs`)||!E.existsSync(e))return null;try{return Qd(E.realpathSync(e),t)?E.readFileSync(e,`utf-8`):(console.warn(`[rari] Refusing to load .mjs file outside project root and node_modules: ${e}`),null)}catch(t){return console.warn(`[rari] Error validating .mjs file path: ${e}`,t),null}}const ef=/* @__PURE__ */ new Map([[`virtual:app-router-provider.tsx`,`AppRouterProvider.mjs`],[`virtual:client-router.tsx`,`ClientRouter.mjs`]]);async function tf(e,t){if(e===`virtual:rari-mdx-components.ts`)return t.buildMdxRegistryModule();if(e===`virtual:rari-entry-client.ts`)return hf(t.resolveProjectRoot(),t.resolvedAlias,t.moduleAnalysisCache,t.getKnownClientComponentPaths);if(e===`react-server-dom-rari/server`)return Wd();let n=ef.get(e);if(n!=null)return Jd(n);if(e===`virtual:error-boundary-wrapper.tsx`)return Jd(`ErrorBoundaryWrapper.mjs`);if(e===`virtual:rsc-integration.ts`)return(await Hd()).replace(kd,(e,t,n)=>`from${t}${n}virtual:react-flight-client.ts${n}`);if(e===`virtual:react-flight-client.ts`)return Zd(t.environmentMode===`dev`?`development`:`production`)}function nf(e,t){if(k.env.NODE_ENV!==`production`)return null;try{let n=O.resolve(e);if(E.existsSync(n)&&t(n))return{id:e,external:!0}}catch(t){a(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error resolving server component:`,e,t)}return null}function rf(e,t){if(!e.includes(`node_modules`))return null;for(let n of t){if(n.test==null)continue;let t=!1;if(typeof n.test==`function`){let r=n.test;t=!!r(e)}else n.test instanceof RegExp?t=n.test.test(e):typeof n.test==`string`&&(t=e.includes(n.test));if(t)return null}return e.includes(`node_modules/react-dom`)?`react-dom`:e.includes(`node_modules/react`)?`react`:`vendor`}function af(e,t,n){return(e===`GET`||e===`HEAD`)&&(t?.includes(`text/html`)??!1)&&!n.startsWith(`/@`)&&!$(n,`/node_modules`)&&!$(n,`/api`)&&!$(n,`/_rari`)&&!$(n,`/assets`)&&!$(n,`/vite-server`)&&!hd(n)}function of(e,t){let n={};for(let[t,r]of Object.entries(e))typeof r==`string`?n[t]=r:Array.isArray(r)&&(n[t]=r.join(`,`));return n.host=`localhost:${t}`,n[`accept-encoding`]=`identity`,n}async function sf(e,t,n){if(n===`HEAD`||!e.body){t.end();return}let r=e.body.getReader();try{let e=!1;for(;!e;){let{done:n,value:i}=await r.read();e=n,!e&&i!=null&&t.write(Te.from(i))}t.end()}catch(e){console.error(`[rari] Stream error:`,e),t.headersSent||(t.statusCode=500),t.end()}}const cf=/* @__PURE__ */ new Map([[`virtual:rsc-integration`,`virtual:rsc-integration.ts`],[`virtual:rsc-integration.ts`,`virtual:rsc-integration.ts`],[`virtual:rari-entry-client`,`virtual:rari-entry-client.ts`],[`virtual:rari-entry-client.ts`,`virtual:rari-entry-client.ts`],[`virtual:react-flight-client`,`virtual:react-flight-client.ts`],[`virtual:react-flight-client.ts`,`virtual:react-flight-client.ts`],[`virtual:app-router-provider`,`virtual:app-router-provider.tsx`],[`virtual:app-router-provider.tsx`,`virtual:app-router-provider.tsx`],[`virtual:client-router`,`virtual:client-router.tsx`],[`virtual:client-router.tsx`,`virtual:client-router.tsx`],[`virtual:error-boundary-wrapper`,`virtual:error-boundary-wrapper.tsx`],[`virtual:error-boundary-wrapper.tsx`,`virtual:error-boundary-wrapper.tsx`],[`virtual:rari-mdx-components`,`virtual:rari-mdx-components.ts`],[`virtual:rari-mdx-components.ts`,`virtual:rari-mdx-components.ts`]]);function lf(e){return Es(e)?`virtual:rari-mdx-components.ts`:cf.get(e)??null}function uf(e){for(let t of e)if(E.existsSync(t))return t;return null}function df(e,t){if(e.startsWith(`./`)){let t=Bd(O.basename(e));return t!=null&&t!==``?t:null}if(!e.startsWith(`../`))return null;let n=O.dirname(A(import.meta.url)),r=uf([O.join(n,`runtime`),O.join(n,`../runtime`)]);if(r!=null){let t=uf([O.join(r,e),O.join(r,`../dist`,O.basename(e))]);if(t!=null)return t}else console.warn(`[rari] Runtime directory not found, attempting fallback resolution for virtual import.\n Importer: ${t}\n ID: ${e}\n Current Dir: ${n}\n Hint: Runtime lookup failed, trying currentDir as fallback`);return uf([O.join(n,e),O.join(n,`../dist`,O.basename(e))])}function ff(e,t){let n=!1,r=``;try{if(!t.get(e).hasDefaultExport){let i=t.getSource(e).match(b);i&&(n=!0,r=i[1])}}catch(t){a(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error reading component for export detection:`,e,t)}return{exportName:n?r:`default`,displayName:n?r:O.basename(e,O.extname(e))}}function pf(e,t){let n=C(O.relative(k.cwd(),e)),r=n.replace(x,``),i=n.startsWith(`..`)?C(e):n,{exportName:a,displayName:o}=ff(e,t),s=C(i),c=s.startsWith(`/`)||ne.test(s)?s:`/${s}`;return` "${i}": {
|
|
853
853
|
id: "${r}",
|
|
854
854
|
path: "${i}",
|
|
855
855
|
exportName: "${a}",
|
|
@@ -859,7 +859,7 @@ export const createTemporaryReferenceSet = module.exports.createTemporaryReferen
|
|
|
859
859
|
component: null,
|
|
860
860
|
loading: false,
|
|
861
861
|
registered: false
|
|
862
|
-
}`}function
|
|
862
|
+
}`}function mf(e){return{imports:e.map((e,t)=>`import * as ExternalModule${t} from '${e.path}';`).join(`
|
|
863
863
|
`),registrations:e.flatMap((e,t)=>e.exports.map(n=>{let r=`${e.path}#${n}`;return`
|
|
864
864
|
globalThis['~clientComponents'] = globalThis['~clientComponents'] || {};
|
|
865
865
|
{
|
|
@@ -875,8 +875,8 @@ globalThis['~clientComponents'] = globalThis['~clientComponents'] || {};
|
|
|
875
875
|
}
|
|
876
876
|
globalThis['~clientComponentPaths'] = globalThis['~clientComponentPaths'] || {};
|
|
877
877
|
globalThis['~clientComponentPaths']["${e.path}"] = "${n}";`})).join(`
|
|
878
|
-
`)}}async function
|
|
879
|
-
`),c=
|
|
878
|
+
`)}}async function hf(e,t,n,r){let i=kr(Sr(O.join(e,`src`),Object.values(t)),n),a=r().union(new Set(i)),o=[{path:`rari/image`,exports:[`Image`]},{path:`virtual:error-boundary-wrapper.tsx`,exports:[`ErrorBoundaryWrapper`]}],s=[...a].filter(e=>{try{return n.get(e).topLevelUseClient}catch{return!1}}).map(e=>pf(e,n)).join(`,
|
|
879
|
+
`),c=mf(o),l=[`
|
|
880
880
|
const lazyComponentRegistry = {
|
|
881
881
|
${s}
|
|
882
882
|
};
|
|
@@ -889,25 +889,25 @@ for (const [path, config] of Object.entries(lazyComponentRegistry)) {
|
|
|
889
889
|
globalThis['~clientComponentPaths'][path] = config.id;
|
|
890
890
|
}
|
|
891
891
|
`,c.registrations].filter(Boolean).join(`
|
|
892
|
-
`),u=
|
|
892
|
+
`),u=Wr(e,t);return Ud(c.imports,l,u)}function gf(e){e.build??={},e.build.outDir??=`dist/client`,e.environments??={},e.environments.rsc={consumer:`server`,resolve:{conditions:[`react-server`,`node`,`import`]},build:{outDir:`dist/server`,write:!1,copyPublicDir:!1,emitAssets:!0},...e.environments.rsc},e.environments.ssr={consumer:`server`,resolve:{conditions:[`node`,`import`]},build:{outDir:`dist/ssr`,write:!1,copyPublicDir:!1,emitAssets:!0},...e.environments.ssr},e.environments.client={consumer:`client`,resolve:{conditions:[`browser`,`import`]},build:{outDir:e.build.outDir,copyPublicDir:!0},...e.environments.client}}function _f(e){e.optimizeDeps??={},e.optimizeDeps.include??=[];for(let t of[`react`,`react-dom`,`react-dom/client`,`react-dom/server`,`react/jsx-runtime`,`react/jsx-dev-runtime`])e.optimizeDeps.include.includes(t)||e.optimizeDeps.include.push(t);e.optimizeDeps.exclude??=[],e.optimizeDeps.exclude.includes(`rari`)||e.optimizeDeps.exclude.push(`rari`)}function vf(e){e.server??={},e.server.proxy??={};let t={target:`http://localhost:${M()}`,changeOrigin:!0,secure:!1};e.server.proxy[`/api`]={...t,ws:!0},e.server.proxy[`/_rari`]={...t,ws:!0},e.server.proxy[`/assets`]=t}const yf=/* @__PURE__ */ new WeakMap;function bf(e){let t=!1;for(let n=e.length-1;n>=0;n--){let r=e[n];if(yf.has(r)){if(yf.get(r)===e){t=!0;continue}e.splice(n,1)}}if(t)return;let n={debugName:`rari-vendor`,name(t){return rf(t,e)}};yf.set(n,e),e.push(n)}function xf(e){e.build??={},e.build.rolldownOptions??={},e.build.rolldownOptions.input={main:jr},e.build.rolldownOptions.output??={};let t=Array.isArray(e.build.rolldownOptions.output)?e.build.rolldownOptions.output:[e.build.rolldownOptions.output];for(let e of t)e.codeSplitting!==!1&&typeof e.codeSplitting!=`object`&&(e.codeSplitting={}),typeof e.codeSplitting==`object`&&(e.codeSplitting.groups??=[],bf(e.codeSplitting.groups))}function Sf(e){e.environments.client.build??={},e.environments.client.build.rolldownOptions??={},e.environments.client.build.rolldownOptions.input={main:jr},e.environments.client.build.rolldownOptions.external??=[];let t=e.environments.client.build.rolldownOptions.external;if(Array.isArray(t)){let e=t.indexOf(`react-server-dom-webpack/client`);e!==-1&&t.splice(e,1)}}function Cf(e){let t=[];return o(e.alias)?t=e.alias:c(e.alias)&&(t=d(e.alias)),t.map(e=>e.find===`react`?{find:/^react$/,replacement:e.replacement}:e)}function wf(e,t,n){if((c(e)&&typeof e.statusCode==`number`?e.statusCode:void 0)===413){t.headersSent||(t.statusCode=413,t.end(`Request Entity Too Large`));return}console.error(`[rari] Failed to proxy ${n?`RSC`:`HTML`} request:`,e),t.headersSent||(t.statusCode=500,t.end(`Internal Server Error`))}function Tf(e){return e}function Ef(e={}){if(e.jsPoolSize!=null){let t=e.jsPoolSize;if(!Number.isInteger(t)||t<1||!Number.isFinite(t))throw Error(`jsPoolSize must be a finite positive integer; received ${String(t)}`)}let t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Set,r=new Ar,i=null,a=null,o=null,s={},c=`assets`,l=O.join(k.cwd(),`dist`,`client`),d=O.join(k.cwd(),`dist`),f=null,m=null,h=[`page`,`layout`,`template`,`loading`,`error`,`not-found`];function g(e){return e.includes(`/app/`)||e.includes(`\\app\\`)?h.some(t=>e.endsWith(`${t}.tsx`)||e.endsWith(`${t}.jsx`)||e.endsWith(`${t}.ts`)||e.endsWith(`${t}.js`)):!1}let _=/* @__PURE__ */ new Map,v=/* @__PURE__ */ new Set;async function ee(e,t){let n=_.get(e);if(n!=null)return v.add(e),n;let r=(async()=>{let n=!1;do{if(v.delete(e),o==null&&m!=null&&await m(),o==null)return console.error(`[rari] HMR: coordinator not ready for ${e}`),n;try{await o.rebuildAndNotifyNow(e,t),n=!0}catch(t){console.error(`[rari] HMR: Failed to rebuild app router file`,`${e}:`,u(t,String(t)))}}while(v.has(e));return n})().finally(()=>{_.delete(e)});return _.set(e,r),r}function y(){f=null}function te(){return f!=null&&f!==``||(f=Ms(js({projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),mdxOptions:e.mdx,alias:s,cache:r}))),f}function ne(e){return t.get(W(e))}function re(t){let n=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),r=C(O.relative(n,t));return r.startsWith(`..`)||O.isAbsolute(r)?C(t):r}function b(e,n){t.set(W(e),n)}function ie(e){Or(t,e)}function oe(e){n.add(W(e))}function se(e){return n.has(W(e))}function S(e){n.delete(e);try{n.delete(E.realpathSync(e))}catch{n.delete(O.resolve(e))}}function fe(){let e=new Set(n);if(i)for(let t of i.getClientComponentPaths())e.add(t);return e}function w(e){if(e.includes(`node_modules`)||Vd(e))return!1;let t=W(e);try{return Al(t,r.get(e))}catch{return!1}}function _e(e,t){try{let n=new Set(zn(e));return(t?.hasDefaultExport??Kn(e))&&n.add(`default`),[...n]}catch{return[]}}function ve(e){return`${e}
|
|
893
893
|
|
|
894
894
|
if (import.meta.hot) {
|
|
895
895
|
import.meta.hot.accept(() => {
|
|
896
896
|
});
|
|
897
|
-
}`}function
|
|
897
|
+
}`}function ye(e,t){let n=Cd.exec(e);if(n){let r=n[1];return e+=`
|
|
898
898
|
// Register server reference for default export
|
|
899
|
-
`,e+=`registerServerReference(${r}, ${t}, ${JSON.stringify(`default`)});\n`,e}let r=`__default_export__`,i=
|
|
899
|
+
`,e+=`registerServerReference(${r}, ${t}, ${JSON.stringify(`default`)});\n`,e}let r=`__default_export__`,i=vr(e,r);return i==null?e:(e=i,e+=`
|
|
900
900
|
// Register server reference for default export
|
|
901
901
|
`,e+=`if (typeof ${r} === "function") {\n`,e+=` registerServerReference(${r}, ${t}, ${JSON.stringify(`default`)});\n`,e+=`}
|
|
902
|
-
`,e)}function
|
|
903
|
-
`,e}function
|
|
902
|
+
`,e)}function be(e,t,n){return e+=`\n// Register server reference for ${t}\n`,e+=`if (typeof ${t} === "function") {\n`,e+=` registerServerReference(${t}, ${n}, ${JSON.stringify(t)});\n`,e+=`}
|
|
903
|
+
`,e}function xe(t,n,r){let i=Gt(n,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd()),a=Au(t,i),o=a?.code??t;if(!r.topLevelUseServer)return a==null?t:ve(o);let s=_e(o,r);if(s.length===0&&a==null)return Gn(o,`use server`);let c=JSON.stringify(i);Hl(o)?o+=`
|
|
904
904
|
`:o+=`
|
|
905
905
|
|
|
906
906
|
import {registerServerReference} from "react-server-dom-rari/server";
|
|
907
|
-
`;for(let e of s)if(e==="default")o=
|
|
907
|
+
`;for(let e of s)if(e==="default")o=ye(o,c);else if(a?.rewrittenExportNames.includes(e))continue;else o=be(o,e,c);return o=Gn(o,`use server`),ve(o)}function Se(e,t,n,r){let i=_e(e,n);if(i.length===0)return``;let a=Gt(t,r),o=`import { createServerReference } from "virtual:react-flight-client";
|
|
908
908
|
`;o+=`import { callServer } from "rari/runtime/call-server";
|
|
909
|
-
`;for(let e of i){let t=`${a}#${e}`,n=JSON.stringify(t);o+=e==="default"?`export default createServerReference(${n}, callServer);\n`:`export const ${e} = createServerReference(${n}, callServer);\n`}return o}function
|
|
910
|
-
`;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export default `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export const ${e} = `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(t)});`}c+=`},`,c+=`${s},`,c+=`${JSON.stringify(e)});\n`}return c}function
|
|
909
|
+
`;for(let e of i){let t=`${a}#${e}`,n=JSON.stringify(t);o+=e==="default"?`export default createServerReference(${n}, callServer);\n`:`export const ${e} = createServerReference(${n}, callServer);\n`}return o}function Ce(t,n,r){let i=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),a=w(n);if(r.topLevelUseServer)return Se(t,n,r,i);if(a)return console.warn(`[rari] Server component ${n} should not be imported in client bundle`),``;if(!r.topLevelUseClient)return t;let o=_e(t,r);if(o.length===0)return``;let s=JSON.stringify(n),c=`import {registerClientReference} from "react-server-dom-rari/server";
|
|
910
|
+
`;for(let e of o){if(e==="default"){let e=`Attempted to call the default export of ${n} from the server but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export default `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(e)});`}else{let t=`Attempted to call ${e}() from the server but ${e} is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.`;c+=`export const ${e} = `,c+=`registerClientReference(function() {`,c+=`throw new Error(${JSON.stringify(t)});`}c+=`},`,c+=`${s},`,c+=`${JSON.stringify(e)});\n`}return c}function we(e,t,n){return!n.topLevelUseClient||_e(e,n).length===0?e:e.replace(wd,``)}let T=!1;async function Te(){let e=`http://localhost:${M()}`;try{let t=(await fetch(`${e}/_rari/health`,{signal:AbortSignal.timeout(1e3)})).ok;return T=t,t}catch{return T=!1,!1}}let De=null;async function D(e){return await Te()?!0:(De??=(async()=>{try{let t=Date.now()+e,n=50;for(;Date.now()<t;){if(await new Promise(e=>{setTimeout(e,Math.min(n,t-Date.now()))}),await Te())return!0;n=Math.min(n*2,500)}return!1}finally{De=null}})(),De)}function A(e){if(e.includes(`virtual:client-router`)||e.includes(`virtual:app-router-provider`)||e.includes(`virtual:error-boundary-wrapper`)||e.includes(`/navigation/client-router`)||e.includes(`/flight/app-router-provider`)||zd!=null&&O.resolve(e)===zd)return!0;if(!E.existsSync(e))return!1;try{return r.get(e).topLevelUseClient}catch{return!1}}function j(e,t){let n=e,r=[],i=/* @__PURE__ */ new Set;for(let e of Nn(n)){if(e.typeOnly||e.sideEffectOnly||!Td.test(e.source)&&!Ed(e.source,s))continue;let n=ge(e.source,t,s);if(!A(n))continue;b(n,`client`),oe(n);let a=Bl(e,re(n));if(a.code!==``){for(let e of a.helpers)i.add(e);r.push({start:e.start,end:e.end,replacement:a.code})}}if(r.length===0)return n;for(let{start:e,end:t,replacement:i}of[...r].sort((e,t)=>t.start-e.start))n=n.slice(0,e)+i+n.slice(t);return i.size>0&&(n=Ll(n,`react-server-dom-rari/server`,[...i])),n}function ke(e,t){for(let n of t.importSources){if(!Td.test(n)&&!Ed(n,s))continue;let t=ge(n,e,s);E.existsSync(t)&&(r.get(t).topLevelUseServer||(b(t,`client`),oe(t)))}}function Ae(e,t,n){return e&&!t&&(n===`rsc`||n===`ssr`)}function je(e,t,n){let r=t.includes(`entry-client`),i=[],a=/* @__PURE__ */ new Set;for(let o of Nn(e)){if(o.typeOnly||o.sideEffectOnly||!Td.test(o.source)&&!Ed(o.source,s))continue;let e=ge(o.source,t,s),c=A(e);if(c&&(b(e,`client`),oe(e)),!Ae(c,r,n))continue;let l=Bl(o,re(e));if(l.code!==``){for(let e of l.helpers)a.add(e);i.push({start:o.start,end:o.end,replacement:l.code})}}return i.length===0?null:{replacements:i,clientRefHelpers:a}}function Me(e,t,n){let r=je(e,t,n);if(r==null)return null;let i=e;for(let{start:e,end:t,replacement:n}of[...r.replacements].sort((e,t)=>t.start-e.start))i=i.slice(0,e)+n+i.slice(t);r.clientRefHelpers.size>0&&(i=Ll(i,`react-server-dom-rari/server`,[...r.clientRefHelpers]));let a=k.env.NODE_ENV!==`production`;return(i.includes(`</`)||i.includes(`/>`)||Ad.test(i))&&a&&b(t,`client`),i}function Ne(e,t,n,r){if(r===`rsc`||r===`ssr`)return j(xe(e,t,n),t);let i=Ce(e,t,n);return`// HMR acceptance for server component
|
|
911
911
|
if (import.meta.hot) {
|
|
912
912
|
import.meta.hot.accept();
|
|
913
913
|
if (typeof globalThis !== 'undefined') {
|
|
@@ -917,5 +917,5 @@ if (import.meta.hot) {
|
|
|
917
917
|
}
|
|
918
918
|
}
|
|
919
919
|
|
|
920
|
-
${i}`}function
|
|
921
|
-
`)});let
|
|
920
|
+
${i}`}function Pe(e,t){if(t.startsWith(`\0`)||t.includes(`virtual:`))return V(e);try{return r.get(t)}catch{return V(e)}}async function Ie(t,n){if(!e.experimental?.useCache&&!e.experimental?.useCacheRemote)return{code:t,wasTransformed:!1};let r=(await Qu())(t,n);return r==null||r===``?{code:t,wasTransformed:!1}:{code:r,wasTransformed:!0}}function Le(e,t,n,r){if(n.topLevelUseServer)return b(t,`server`),r===`rsc`?xe(e,t,n):Ce(e,t,n);if(n.topLevelUseClient)return b(t,`client`),oe(t),ke(t,n),we(e,t,n);if(r!==`rsc`&&r!==`ssr`&&(ne(t)===`client`||se(t)))return we(e,t,n);if(w(t))return b(t,`server`),Ne(e,t,n,r);let i=ne(t);return i===`server`?r===`rsc`||r===`ssr`?j(xe(e,t,n),t):Ce(e,t,n):i===`client`?we(e,t,n):(b(t,`unknown`),Me(e,t,r))}let Re={name:`rari`,config(e,{command:t}){e.appType=`custom`,e.define??={};let n=typeof e.css?.modules==`object`?e.css.modules:{};e.css={...e.css,transformer:e.css?.transformer??`lightningcss`,modules:{...n,pattern:`[hash]_[local]`}},e.resolve??={};let r=e.resolve,i=Array.isArray(r.dedupe)?r.dedupe:[];r.dedupe=[...new Set(i).union(/* @__PURE__ */ new Set([`react`,`react-dom`]))];let a=Cf(r),o=new Set(a.map(e=>String(e.find))),s=a.some(e=>Od(e.find));try{r.alias=[...a,...qd(o,s)]}catch(e){Dd(e)||console.warn(`[rari] Unexpected error configuring React aliases:`,e)}if(gf(e),e.builder??={},e.builder.sharedPlugins=!0,e.builder.sharedConfigBuild=!1,_f(e),t===`build`)for(let t of[`rsc`,`ssr`,`client`]){let n=e.environments[t];n.build!=null&&(n.build.rolldownOptions??={})}return vf(e),t===`build`&&xf(e),Sf(e),e},async buildStart(){if(Fr(),e.experimental?.useCache||e.experimental?.useCacheRemote)try{await Qu()}catch(e){this.error(e instanceof Error?e:Error(String(e)))}},configResolved(e){let t=Ht(e);c=t.assetsDir,l=de(t.projectRoot,e.build.outDir),d=ue(l),Object.assign(s,Vt(e))},async transform(t,n){if(n.endsWith(`.mdx`)&&y(),/\.(?:tsx?|jsx?|mts|mjs)$/.test(n)&&t.includes(`defineMdxComponents`)){let r=zu({code:t,id:n,projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),resolvedAlias:s});if(r!=null&&r!==``)return ii(r,t,n)}if(!x.test(n))return null;let r=t,i=await Ie(t,n);t=i.code;let a=Le(t,n,Pe(t,n),this.environment.name);return a==null?i.wasTransformed?ii(t,r,n):null:ii(a,r,n)},async configureServer(t){let n=O.resolve(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd()),f=O.join(n,`src`);await Gd(n,e,c,l);let h=/* @__PURE__ */ new Map([[`/installHook.js.map`,`installHook.js`],[`/react_devtools_backend_compact.js.map`,`react_devtools_backend_compact.js`],[`/installHook.js`,null],[`/react_devtools_backend_compact.js`,null]]);t.middlewares.use((e,t,n)=>{let r=ce(e.url??``);if(!h.has(r)){n();return}let i=h.get(r);if(t.statusCode=200,t.setHeader(`Cache-Control`,`no-store`),i!=null){t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({version:3,file:i,sources:[i],sourcesContent:[`/* react-devtools extension stub */`],names:[],mappings:`AAAA`}));return}t.setHeader(`Content-Type`,`application/javascript; charset=utf-8`),t.end(`/* react-devtools extension stub */
|
|
921
|
+
`)});let _=async()=>{try{let a=new jl(n,{outDir:d,clientOutDir:l,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:s,assetsDir:c,csp:e.csp,cacheControl:e.cacheControl,cache:e.cache,action:e.action,jsPoolSize:e.jsPoolSize,origin:e.origin,htmlLimitedBots:e.htmlLimitedBots,experimental:e.experimental,moduleAnalysisCache:r});if(a.setViteBuilder(await pe({root:n,configFile:t.config.configFile,logLevel:`error`})),i=a,o??=new Ao(a,M()),E.existsSync(f)){let e=Fl(f,a,Object.values(s));e.serverComponentPaths.length>0&&t.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:e.serverComponentPaths}})}let p=await a.getTransformedComponentsForDevelopment(),m=`http://localhost:${M()}`;await Promise.all(p.map(async e=>{try{if(e.id.startsWith(`app/`)||e.isAction)return;let t=await fetch(`${m}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Runtime: Failed to register component ${e.id}:`,u(t,String(t)))}}))}catch(e){console.error(`[rari] Runtime: Component discovery failed:`,u(e,String(e)))}},v=async()=>{try{let e=`http://localhost:${M()}`,t=fe();await Promise.all([...t].map(async t=>{let n=O.relative(k.cwd(),t),r=O.basename(t).replace(ae,``);try{await fetch(`${e}/_rari/register-client`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:r,file_path:n,export_name:`default`})})}catch(e){console.error(`[rari] Runtime: Failed to pre-register client component ${r}:`,e)}}))}catch(e){console.error(`[rari] Runtime: Failed to pre-register client components:`,e)}},ee=async()=>{if(a)return;let{getBinaryPath:r,getInstallationInstructions:i}=await import(`./platform.mjs`),o;try{o=r()}catch(e){console.error(`rari binary not found`),console.error(` ${u(e,String(e))}`),console.error(i());return}let c=M(),l=k.env.NODE_ENV===`production`?`production`:`development`,d=t.config.server.port,f=e.origin?.trim().replace(/\/+$/,``),p=k.env.RARI_ORIGIN?.trim().replace(/\/+$/,``),m=Hr(n,s),h=[`--mode`,l,`--port`,c.toString(),`--host`,`127.0.0.1`];a=Ee(o,h,{stdio:[`ignore`,`pipe`,`pipe`],cwd:n,env:{...k.env,RUST_LOG:k.env.RUST_LOG!=null&&k.env.RUST_LOG!==``?k.env.RUST_LOG:`error`,RARI_VITE_PORT:d.toString(),...m.length>0?{RARI_DEV_LAYOUT_CSS:m.join(`,`)}:{},...e.jsPoolSize!=null&&(k.env.RARI_JS_POOL_SIZE==null||k.env.RARI_JS_POOL_SIZE===``)?{RARI_JS_POOL_SIZE:String(e.jsPoolSize)}:{},...f!=null&&f!==``&&(p==null||p===``)?{RARI_ORIGIN:f}:{},...e.htmlLimitedBots!=null&&(k.env.RARI_HTML_LIMITED_BOTS==null||k.env.RARI_HTML_LIMITED_BOTS===``)?{RARI_HTML_LIMITED_BOTS:e.htmlLimitedBots}:{}}}),a.stdout?.on(`data`,e=>{let t=e.toString().trim();t&&console.error(t)}),a.stderr?.on(`data`,e=>{let t=e.toString().trim();t&&!t.includes(`warning`)&&console.error(t)}),a.on(`error`,e=>{T=!1,console.error(`Failed to start rari server:`,e.message),e.message.includes(`ENOENT`)&&console.error(` Binary not found. Please ensure rari is properly installed.`)}),a.on(`exit`,(e,t)=>{a=null,T=!1,t?console.error(`rari server stopped by signal ${t}`):e===0?console.error(`rari server stopped successfully`):e&&console.error(`rari server exited with code ${e}`)}),await D(1e4)?(await _(),await v()):console.error(`Server failed to become ready for component registration`)},y=async e=>{try{if(!w(e))return;i??await _();let t=i;if(t==null)return;let n=r.getSource(e);t.addServerComponent(e,n);let a=Eo(t.getImportGraph(),[e]);a.add(e);let o=await t.getTransformedComponentsForDevelopment(e=>a.has(e));if(o.length===0)return;let s=`http://localhost:${M()}`;await Promise.all(o.map(async e=>{try{let t=await fetch(`${s}/_rari/register`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({component_id:e.id,component_code:e.code})});if(!t.ok){let e=await t.text();throw Error(`HTTP ${t.status}: ${e}`)}}catch(t){console.error(`[rari] Failed to register component`,`${e.id}:`,u(t,String(t)))}}))}catch(t){console.error(`[rari] Targeted HMR failed for`,`${e}:`,u(t,String(t)))}};m=async()=>{i??await _()},ee().catch(e=>{console.error(`[rari] Failed to start Rust server:`,e)}),t.middlewares.use((e,t,n)=>{(async()=>{let r=e.headers.accept,i=e.method??`GET`,a=e.url??``,o=ce(a),s=r!=null&&r!==``&&r.includes(`text/x-component`);if(Xd(s,af(i,r,o),a,o)){n();return}if(!T&&!await D(1e4)){console.error(`[rari] Rust server not ready, cannot proxy ${s?`RSC`:`HTML`} request`),t.headersSent||(t.statusCode=503,t.end(`Server not ready`));return}let c=M();try{let n=of(e.headers,c),r=i!==`GET`&&i!==`HEAD`?await md(e,10485760):void 0,o=await fetch(`http://localhost:${c}${a}`,{method:i,headers:n,...r==null?{}:{body:r}});t.statusCode=o.status,o.headers.forEach((e,n)=>{n.toLowerCase()!==`content-encoding`&&t.setHeader(n,e)}),await sf(o,t,i)}catch(e){wf(e,t,s)}})()}),t.watcher.on(`change`,e=>{(async()=>{x.test(e)&&le(e,f)&&(e.includes(`/dist/`)||e.includes(`\\dist\\`)||(ie(e),S(e),r.invalidate(e),!g(e)&&w(e)&&(t.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await y(e))))})()}),t.middlewares.use(`/api/vite/hmr-transform`,(e,t)=>{if(e.method!==`POST`){t.statusCode=405,t.end(`Method Not Allowed`);return}(async()=>{try{let n=await Oe(e),r=p(n),i=r&&typeof r.filePath==`string`?r.filePath:void 0;if(i==null||i===``){t.statusCode=400,t.end(JSON.stringify({error:`filePath is required`}));return}await y(i),t.statusCode=200,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!0,filePath:i,message:`Component transformation completed`}))}catch(e){t.statusCode=500,t.setHeader(`Content-Type`,`application/json`),t.end(JSON.stringify({success:!1,error:u(e,String(e))}))}})()}),t.httpServer?.on(`close`,()=>{if(he(n),i!=null&&(i.setViteBuilder(null),i=null),o&&=(o.dispose(),null),a){let e=a;a=null,T=!1;let t=!1,n=setTimeout(()=>{t||e.kill(`SIGKILL`)},5e3);n.unref(),e.once(`exit`,()=>{t=!0,clearTimeout(n)}),e.kill(`SIGTERM`);return}T=!1})},resolveId(e,t){let n=lf(e);if(n!=null)return n;if(e===`react-server-dom-webpack/client`||e===`react-server-dom-webpack/client.browser`)return`virtual:react-flight-client.ts`;if(e===`react-server-dom-rari/server`)return e;if(t!=null&&t!==``&&t.startsWith(`virtual:`)){let n=df(e,t);if(n!=null)return n}return nf(e,w)},async load(t){if(x.test(t)&&this.environment.name===`client`)try{let e=r.get(t);if(e.topLevelUseServer)return Ce(r.getSource(t),t,e)}catch{}let n=await tf(t,{buildMdxRegistryModule:te,resolveProjectRoot:()=>e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),resolvedAlias:s,moduleAnalysisCache:r,getKnownClientComponentPaths:fe,environmentMode:this.environment.mode});return n===void 0?$d(t,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd())??void 0:n},async handleHotUpdate({file:e,server:t}){if(me(),e.endsWith(`.mdx`)&&y(),!x.test(e))return;if(ie(e),S(e),r.invalidate(e),y(),e.includes(`/dist/`)||e.includes(`\\dist\\`))return[];let n=o?.detectComponentType(e)??`unknown`;if(g(e))return[];if(n!==`client`&&n===`server`)return o&&await o.handleServerComponentUpdate(e,t),[]},async hotUpdate(e){if(this.environment.name!==`client`)return;let{file:t,server:n}=e;if(x.test(t)&&!(t.includes(`/dist/`)||t.includes(`\\dist\\`))){if(me(),t.endsWith(`.mdx`)&&y(),ie(t),S(t),r.invalidate(t),g(t))return await ee(t,n)?[]:void 0;if((o?.detectComponentType(t)??`unknown`)===`server`&&o)return await o.handleServerComponentUpdate(t,n),[]}},generateBundle(e,t){if(this.environment.name!==`client`)return;let n=Kr(t);this.emitFile({type:`asset`,fileName:`rari-client-head.html`,source:n})},async writeBundle(){await Gd(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),e,c,l)}},Be=Il({...e.serverBuild,csp:e.csp,cacheControl:e.cacheControl,cache:e.cache,action:e.action,jsPoolSize:e.jsPoolSize,origin:e.origin,htmlLimitedBots:e.htmlLimitedBots,experimental:e.experimental,moduleAnalysisCache:r,mdx:e.mdx}),Ve={name:`rari:patch-react-server-dom-webpack`,transform(e){if(!e.includes(`__webpack_require__`)&&!e.includes(`__webpack_chunk_load__`)&&!e.includes(`__webpack_get_script_filename__`))return null;let t=e;return t.includes(`__webpack_chunk_load__`)&&(t=t.replaceAll(`__webpack_chunk_load__`,`__rari_chunk_load__`)),t.includes(`__webpack_get_script_filename__`)&&(t=t.replaceAll(`__webpack_get_script_filename__`,`__rari_get_script_filename__`)),t.includes(`__webpack_require__.u`)&&(t=t.replaceAll(`__webpack_require__.u`,`({}).u`)),t.includes(`__webpack_require__`)&&(t=t.replaceAll(`__webpack_require__`,`__rari_rsc_require__`)),t===e?null:{code:t,map:null}}},N=[...Xu()];return e.compiler!=null&&e.compiler!==!1&&N.push(qu(e.compiler)),N.push(Re,Ts(),So(),Ve,Be,_i(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd())),e.proxy!==!1&&N.push(ze(e.proxy??{})),e.router!==!1&&N.push(jt(e.router??{})),Fe(N)}function Df(e){return{...e,plugins:[Ef(),...e.plugins??[]]}}export{t as ApiResponse,dd as clearPropsCache,fd as clearPropsCacheForComponent,Df as defineRariConfig,Tf as defineRariOptions,od as extractMetadata,ad as extractServerProps,ud as extractServerPropsWithCache,sd as extractStaticParams,_t as generateAppRouteManifest,cd as hasServerSideDataFetching,Ef as rari,ze as rariProxy,jt as rariRouter};
|