rari 0.17.0 → 0.17.2
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/font/google-catalog.d.mts +1952 -0
- package/dist/font/google.d.mts +1 -1946
- package/dist/font/google.mjs +1 -1
- package/dist/image.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/platform.mjs +1 -1
- package/dist/runtime/AppRouterProvider.mjs +1 -1
- package/dist/runtime/ClientRouter.mjs +4 -4
- package/dist/runtime/ErrorBoundaryWrapper.mjs +1 -1
- package/dist/runtime/merge-flight-refresh.d.mts +1 -0
- package/dist/runtime/merge-flight-refresh.mjs +1 -1
- package/dist/{types-DfSnnFaF.d.mts → types-CkJ_86mo.d.mts} +9 -9
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +56 -56
- package/package.json +11 -11
package/dist/vite.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./api-routes-Dc2tv31o.mjs";import{T as n,a as r,b as i,c as a,d as o,n as s,r as c,t as l,v as u,w as d,x as f,y as p}from"./type-guards-BJXKlA6x.mjs";import{a as m,i as h,r as g,s as _}from"./constants-CRK2JRKf.mjs";import{a as v,d as y,f as ee,i as te,m as ne,n as b,o as x,p as S,r as re,s as ie,u as ae}from"./regex-constants-DzXwNGh2.mjs";import{a as
|
|
1
|
+
import{r as e,t}from"./api-routes-Dc2tv31o.mjs";import{T as n,a as r,b as i,c as a,d as o,n as s,r as c,t as l,v as u,w as d,x as f,y as p}from"./type-guards-BJXKlA6x.mjs";import{a as m,i as h,r as g,s as _}from"./constants-CRK2JRKf.mjs";import{a as v,d as y,f as ee,i as te,m as ne,n as b,o as x,p as S,r as re,s as ie,u as ae}from"./regex-constants-DzXwNGh2.mjs";import{a as oe,i as se,n as C,o as w,t as ce}from"./path-CTEC1xmy.mjs";import{a as le,c as ue,i as de,l as fe,n as pe,o as me,r as he,s as T,u as ge}from"./rsc-vite-build-CSnu8C3P.mjs";import{t as _e}from"./timer-Duul5JHq.mjs";import{t as ve}from"./names-CLmM0CPi.mjs";import{a as ye,i as be,n as xe,r as Se}from"./dist-paths-C4EV064W.mjs";import{builtinModules as Ce,createRequire as we}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 ke}from"node:url";import{createHash as Ae}from"node:crypto";import{isFileLoadingAllowed as je}from"vite-plus";import{fromBuffer as Me}from"@capsizecss/unpack";import j 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 He=6e4;async function Ue(e){let t=ke(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=
|
|
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 ${He}ms for ${e}`)))},He),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 We=/\\\*/g;function Ge(e,t={}){let{escapeAsterisk:n=!0}=t,r=RegExp.escape(e);return n?r:r.replace(We,`*`)}const Ke=[`.ico`],qe=[`.ico`,`.jpg`,`.jpeg`,`.png`,`.svg`],Je=[`.jpg`,`.jpeg`,`.png`],Ye={".ico":`image/x-icon`,".png":`image/png`,".jpg":`image/jpeg`,".jpeg":`image/jpeg`,".svg":`image/svg+xml`};function Xe(e){return Ye[e.toLowerCase()]??`application/octet-stream`}function Ze(e,t,n){let r=n.map(e=>Ge(e.replace(/^\./,``))).join(`|`),i=RegExp(`^${Ge(t)}(\\d*)\\.(${r})$`,`i`);return e.filter(e=>i.test(e)).sort((e,t)=>e.localeCompare(t))}function Qe(e,t){let n=w(e).replace(/^\/+|\/+$/g,``);return n===``?`/${t}`:`/${n}/${t}`.replace(/\/+/g,`/`)}function $e(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 et(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=$e(n);if(e)return{...e,sizes:`${e.width}x${e.height}`}}}catch{}return{sizes:`any`}}function tt(e){let t=w(O.join(e.relativeDir,e.fileName)),n=O.extname(e.fileName).toLowerCase();return{path:e.routePath,filePath:t,kind:e.kind,url:Qe(e.relativeDir,e.fileName),contentType:Xe(n),width:e.width,height:e.height,sizes:e.sizes}}async function nt(e){let{appDir:t,relativeDir:n,routePath:r,files:i}=e,a=[],o=async(e,o,s,c)=>{if(c&&r!==`/`)return;let l=Ze(i,o,s);for(let i of l){let o=await et(O.join(t,n,i));a.push(tt({routePath:r,relativeDir:n,fileName:i,kind:e,width:o.width,height:o.height,sizes:o.sizes}))}};return await o(`favicon`,`favicon`,Ke,!0),await o(`icon`,`icon`,qe,!1),await o(`apple-icon`,`apple-icon`,Je,!1),a}async function rt(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 it(e){return u(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 at(e){let t;try{t=JSON.parse(e)}catch{return[]}return!u(t)||!Array.isArray(t.appIcons)?[]:t.appIcons.filter(it)}const N={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`},ot={DYNAMIC:/^\[([^\]]+)\]$/,CATCH_ALL:/^\[\.\.\.([^\]]+)\]$/,OPTIONAL_CATCH_ALL:/^\[\[\.\.\.([^\]]+)\]\]$/},st=[{pattern:ot.OPTIONAL_CATCH_ALL,type:`optional-catch-all`,format:e=>`[[...${e}]]`},{pattern:ot.CATCH_ALL,type:`catch-all`,format:e=>`[...${e}]`},{pattern:ot.DYNAMIC,type:`dynamic`,format:e=>`[${e}]`}],ct=/^\([^/]+\)$/;function lt(e){return ct.test(e)}function ut(e){return e?w(e).split(`/`).filter(Boolean).some(lt):!1}function dt(e){for(let t of st){let n=e.match(t.pattern);if(n)return{type:t.type,param:n[1],format:t.format}}}function ft(e){let t=dt(e);return t?t.format(t.param):e}function pt(e){let t=dt(e);return t?{type:t.type,value:e,param:t.param}:{type:`static`,value:e}}const mt=/export\s+const\s+size\s*=\s*\{\s*width\s*:\s*(\d+)\s*,\s*height\s*:\s*(\d+)\s*[,}]/,ht=/export\s+const\s+contentType\s*=\s*['"]([^'"]+)['"]/,gt=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];var _t=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=w(O.dirname(r.filePath));if(!ut(i))continue;let a=e.filter(e=>{let t=w(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,N.LOADING,i),this.pushNamedSpecial(e,t,d,N.ERROR,a),this.pushNamedSpecial(e,t,d,N.NOT_FOUND,o),this.pushTemplateEntry(e,t,d,s),await this.pushOgImageEntry(e,t,d,l);let f=await nt({appDir:this.appDir,relativeDir:e,routePath:d,files:t});u.push(...f);let p=this.findFile(t,N.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,N.PAGE);if(i==null||i===``)return;let a=this.parseRouteSegments(e),o=this.extractParams(a);r.push({path:n,filePath:w(O.join(e,i)),segments:a,params:o,isDynamic:o.length>0})}pushLayoutEntry(e,t,n,r){let i=this.findFile(t,N.LAYOUT);if(i==null||i===``)return;let a=this.getParentPath(e);r.push({path:n,filePath:w(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:w(O.join(e,a))})}pushTemplateEntry(e,t,n,r){let i=this.findFile(t,N.TEMPLATE);if(i==null||i===``)return;let a=this.getParentPath(e);r.push({path:n,filePath:w(O.join(e,i)),parentPath:a===null?void 0:this.pathToRoute(a)})}async pushOgImageEntry(e,t,n,r){let i=this.findFile(t,N.OG_IMAGE);if(i==null||i===``)return;let a=w(O.join(e,i)),o=O.join(this.appDir,a),s,c,l;try{let e=await D.readFile(o,`utf-8`),t=mt.exec(e);t&&(s=Number.parseInt(t[1],10),c=Number.parseInt(t[2],10));let n=ht.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?`/${w(e).split(`/`).filter(Boolean).filter(e=>!lt(e)).map(ft).join(`/`)}`:`/`}parseRouteSegments(e){return e?e.split(ae).filter(Boolean).filter(e=>!lt(e)).map(pt):[]}extractParams(e){return e.filter(e=>e.param!==void 0).map(e=>e.param)}getParentPath(e){if(!e)return null;let t=e.split(ae).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=
|
|
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 gt){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=w(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 vt(e,t={}){return new _t({appDir:e,...t}).generateManifest()}const yt=/export\s+const\s+metadata\s*(?::\s*\w+\s*)?=\s*(\{[\s\S]*?\n\})/,bt=/title\s*:\s*['"]([^'"]+)['"]/,xt=/description\s*:\s*['"]([^'"]+)['"]/,St=/keywords\s*:\s*\[([\s\S]*?)\]/,Ct={appDir:`src/app`,extensions:[`.tsx`,`.jsx`,`.ts`,`.js`],outDir:`dist`};function wt(e){switch(O.basename(e).replace(S,``)){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 Tt(e){if(!e||e===`/`)return`/`;let t=w(e).split(`/`).filter(e=>!!e&&!lt(e));return t.length>0?`/${t.join(`/`)}`:`/`}function Et(e,t){let n=O.relative(O.normalize(t),O.normalize(O.dirname(e)));return!n||n===`.`?`/`:Tt(`/${w(n).split(`/`).filter(Boolean).join(`/`)}`)}function Dt(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 Ot(e){try{let t=yt.exec(e);if(!t)return null;let n=t[1],r={},i=bt.exec(n);i&&(r.title=i[1]);let a=xt.exec(n);a&&(r.description=a[1]);let o=St.exec(n);o&&(r.keywords=o[1].split(`,`).map(e=>e.trim().replace(y,``)).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 kt(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 At(e){return u(e)&&Array.isArray(e.routes)}async function jt(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=f(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 Mt(e={}){let t={...Ct,...e},r=null,i=/* @__PURE__ */ new Map,a=null,o=/* @__PURE__ */ new Set,s=e=>[...e].toSorted().join(`|`),c=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))&&wt(i)&&n.add(w(i))}}catch{}};return await r(e),n},l=async(e,n=!1)=>{let i=O.resolve(e,t.appDir);try{await D.access(i)}catch{return null}try{let l=await c(i),u=s(l);if(!n&&a===u&&r!=null&&r!==``)return r;let d=await vt(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`),a=u,o.clear(),l.forEach(e=>{o.add(e)}),f}catch(e){return console.error(`[rari] Router: Failed to generate app routes:`,e),null}},u=e=>{let n=O.resolve(e.config.root,t.appDir);e.watcher.on(`all`,(r,i)=>{(async()=>{if(ce(i,n)&&t.extensions.some(e=>i.endsWith(e)))try{let t=wt(i)!==null,a=r===`add`||r===`unlink`,s=t&&!o.has(w(i));(a||s)&&(await l(e.config.root,!0),ce(i,n)&&e.ws.send({type:`full-reload`,path:`*`}))}catch(e){console.error(`[rari] Router: Failed to regenerate app routes:`,e)}})()})},d;return Ie({name:`rari-router`,configResolved(e){d=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=d||k.cwd();r=await l(e,!0)},configureServer(e){u(e)},async handleHotUpdate(e){let{file:n,server:a}=e,s=O.resolve(a.config.root,t.appDir);if(ce(n,s)&&t.extensions.some(e=>n.endsWith(e))){let e=wt(n);if(e){let t=i.get(n);t&&clearTimeout(t);let c=setTimeout(()=>{(async()=>{i.delete(n);let t=w(n),c=!o.has(t),u=r;r=await l(a.config.root,c);let d=u!==r,p=Et(n,s),m=[p];if(r!=null&&r!==``)try{let e=f(r);e&&At(e)&&(m=e.routes.map(e=>e.path))}catch(e){console.error(`[rari] Router: Failed to parse manifest for affected routes:`,e)}let h=Dt(p,e,m),g,_=!1,v;if(e===`page`||e===`layout`)try{let e=Ot(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=kt(await D.readFile(n,`utf-8`)),await jt(O.relative(s,n))}catch(e){console.error(`[rari] Router: Failed to detect HTTP methods:`,e)}let y={fileType:e,filePath:w(O.relative(a.config.root,n)),routePath:p,affectedRoutes:h,manifestUpdated:d,timestamp:Date.now(),metadata:g,metadataChanged:_,methods:v};a.ws.send({type:`custom`,event:`rari:app-router-updated`,data:y})})()},200);return i.set(n,c),[]}return r=await l(a.config.root),[]}},async closeBundle(){for(let e of i.values())clearTimeout(e);i.clear();let e=d||k.cwd(),r=O.resolve(e,t.outDir,`server`),a=O.join(r,`routes.json`);try{let e=await D.readFile(a,`utf-8`),t=f(e);if(!t||!At(t))return;let i=t,o=i.routes.flatMap(e=>{if(!e.isDynamic)return[];let t=e.componentId;return t==null||t===``?[]:[{route:e,componentId:t}]}),s=Math.min(8,Math.max(1,o.length)),c=o.map(()=>!1),l=0,u=0;await new Promise(e=>{let t=()=>{for(;u<s&&l<o.length;){let i=l++,{route:a,componentId:s}=o[i],d=O.join(r,`${s}.js`);u++,(async()=>{try{let e=await Ue(d);if(e==null)return;p(e)?(a.staticParams=e,c[i]=!0):n(s)}catch(e){console.warn(`[rari] Failed to evaluate generateStaticParams for ${s}:`,e)}finally{u--,l>=o.length&&u===0?e():t()}})()}o.length===0&&e()};t()}),c.some(Boolean)&&await D.writeFile(a,JSON.stringify(i),`utf-8`)}catch(e){console.warn(`[rari] Failed to enrich routes manifest with static params:`,e)}}})}const Nt=/return \{\s*name: referenceClosure,\s*method: "POST",\s*encType: "multipart\/form-data",\s*data: data\s*\};/,Pt=/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*\}/,Ft=/Object\.defineProperty\(value\._store, "validated", \{\s*configurable: !1,\s*enumerable: !1,\s*writable: !0,\s*value: i\s*\}\);/;function It(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 Lt(e){return Ft.test(e)?(Ft.lastIndex=0,It(e,Ft,`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 Rt(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}`,It(a,Nt,`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 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 u(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(u(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:k.resolve(e.root,e.build.outDir),assetsDir:w(e.build.assetsDir)}}function F(e,t=8){return ke(`sha256`).update(e).digest(`hex`).slice(0,t)}function Ut(e,t=A.cwd()){let n=k.isAbsolute(e)?e:k.resolve(t,e),r=k.relative(t,n);return k.isAbsolute(r)?T(n):T(r)}function Wt(e){return e.replace(S,``).replace(b,`_`).replace(ee,``)}function Gt(e,t=A.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:!1,nextI:r,endDirectivesPhase:r>=n}}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&&!nr(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){return V(e).hasDefaultExport}function Wn(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 Gn(e,t){for(t-=2;t>=1;){if(e.charCodeAt(t)===42&&e.charCodeAt(t-1)===47)return t-2;t--}return-1}function Kn(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 I(n)?t-1:t>=1&&n===47&&e.charCodeAt(t-1)===42?Gn(e,t):t>=1&&n===47&&e.charCodeAt(t-1)===47?t-2:Kn(e,t)}function Jn(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||!L(e.charCodeAt(n)))return;let r=n;for(;n>=0&&L(e.charCodeAt(n));)n--;return e.slice(n+1,r+1)}function Yn(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 Xn(e,t){let n=Yn(e,t);if(n===-1||Wn(n))return!0;let r=Jn(e,t);return r!=null&&r!==``&&Kt.has(r)}const Zn=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`default`,`else`,`do`,`typeof`,`void`,`yield`,`await`,`delete`]);function Qn(e,t){let n=Yn(e,t);if(n===-1)return!0;if(L(n)||n>=48&&n<=57){let n=Jn(e,t);return n!=null&&n!==``&&Zn.has(n)}return n!==41&&n!==93&&n!==125}function $n(e,t,n){if(!Qn(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 er(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 tr(e,t,n){t++;let r=!1;for(;t<n;){let i=er(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&&Xn(e,t))return tr(e,t,n);if(r===60){let r=$n(e,t,n);if(r!==-1)return r}return-1}function nr(e,t){let n=e.charCodeAt(t);return I(n)?!0:n===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42)}function rr(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 ir(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=rr(e,a,t),s=mr(e,a,t);return{exportStart:n,valueStart:a,valueEnd:s,statementEnd:wn(e,s,t),bindingName:o}}return null}function ar(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 or=/* @__PURE__ */ new Set([`typeof`,`void`,`delete`,`await`,`yield`,`new`]);function sr(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&&Xn(e,t.i)?(t.i=tr(e,t.i,n),t.lastCanTerminate=!0,!0):!1}function cr(e,t,n){if(e.charCodeAt(t.i)!==60||t.paren!==0||t.brace!==0||t.bracket!==0)return!1;let r=$n(e,t.i,n);return r!==-1&&(t.i=r,t.lastCanTerminate=!0,!0)}function lr(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 ur(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||ar(e,i,n)?(t.i++,-1):t.i}function dr(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 fr(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 pr(e,t,n){let r=e.charCodeAt(t.i);if(Xt(r)){let r=H(e,t.i,n);if(r){t.lastCanTerminate=!or.has(r.name),t.i=r.end;return}}if(r>=48&&r<=57){t.lastCanTerminate=!0,t.i=dr(e,t.i,n);return}if(r===61&&e.charCodeAt(t.i+1)===62){t.lastCanTerminate=!1,t.i+=2;return}if(fr(r)){t.lastCanTerminate=!1,t.i++;return}t.i++}function mr(e,t,n){let r={i:t,paren:0,brace:0,bracket:0,lastCanTerminate:!1};for(;r.i<n;){if(sr(e,r,n)||cr(e,r,n))continue;let t=e.charCodeAt(r.i),i=lr(t,r);if(i===!0)return r.i;if(i===!1)continue;let a=ur(e,r,n,t);if(a!==-1){if(a!==null)return a;pr(e,r,n)}}return r.i}function hr(e,t){let n=ir(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 gr=/* @__PURE__ */ new Set([`node_modules`,`.git`,`.cache`,`dist`]);function _r(e,t){let n=/* @__PURE__ */ new Set,r=e=>{if(!D.existsSync(e))return;let i=D.readdirSync(e,{withFileTypes:!0});for(let a of i){let i=k.join(e,a.name);if(a.isDirectory()){if(gr.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&&D.existsSync(t)&&r(t)}function vr(e){let t=[];return _r(e,e=>{t.push(e)}),t}function yr(e,t=[]){let n=[e],r=k.resolve(e);for(let e of t){if(!e)continue;let t=k.resolve(e);if(t===r)continue;let i=k.relative(r,t);if(i!==``&&(i.startsWith(`..`)||k.isAbsolute(i)))try{D.statSync(e).isDirectory()&&n.push(e)}catch{}}return n}const br=new Set(Se);function xr(e){return br.has(e)}function Sr(e){for(let t of e.importSources)if(t.startsWith(`node:`)||xr(t))return!0;return!1}function Cr(e,t=br){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 wr(e){let t=[];for(let n of e)(n.startsWith(`./`)||n.startsWith(`../`)||n.startsWith(`@/`))&&t.push(n);return t}function W(e){try{return D.realpathSync(e)}catch{return k.resolve(e)}}function Tr(e,t){e.delete(t);try{e.delete(D.realpathSync(t))}catch{e.delete(k.resolve(t))}}function Er(e,t){let n=[];for(let r of vr(e))try{t.get(r).directives.hasUseClient&&n.push(r)}catch{}return n}var Dr=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??=D.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){Tr(this.cache,e)}clear(){this.cache.clear()}readMtimeMs(e){try{return D.statSync(e).mtimeMs}catch{return-1}}};function Or(e){return e.code===`MODULE_LEVEL_DIRECTIVE`&&(e.message?.includes(`use client`)===!0||e.message?.includes(`use server`)===!0)}function kr(){return{name:`rari:silence-react-directive-logs`,onLog(e,t){return!Or(t)&&void 0}}}const Ar=`virtual:rari-entry-client`,jr=/^layout\.(?:tsx|ts|jsx|js)$/,Mr=/\.css(?:\?.*)?$/,Nr=/* @__PURE__ */ new Set;function Pr(){Nr.clear()}function Fr(e){let t=e.trim();t!==``&&Nr.add(t)}function Ir(){return[...Nr]}function Lr(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Mr.test(i))return null;if(i.startsWith(`./`)||i.startsWith(`../`)){let e=k.resolve(k.dirname(t),i);return!D.existsSync(e)||!D.statSync(e).isFile()?null:e}let a=E(i,r,n);return a!=null&&a!==``&&D.existsSync(a)&&D.statSync(a).isFile()?a:i}function Rr(e,t,n,r){if(D.existsSync(e))for(let i of D.readdirSync(e,{withFileTypes:!0})){let a=k.join(e,i.name);if(i.isDirectory()){Rr(a,t,n,r);continue}if(!i.isFile()||!jr.test(i.name))continue;let o=D.readFileSync(a,`utf-8`);for(let e of Nn(o)){let i=Lr(e.source,a,t,n);i!=null&&r.add(i)}}}function zr(e,t={}){let n=/* @__PURE__ */ new Set;return Rr(k.join(e,`src`,`app`),e,t,n),n}function Br(e,t){if(!k.isAbsolute(e))return e.startsWith(`/`)?e:`/${e}`;let n=T(k.relative(t,e));return n.startsWith(`..`)||k.isAbsolute(n)?`/@fs/${e}`:`/${n}`}function Vr(e,t={}){return[...zr(e,t)].sort().map(t=>Br(t,e))}function Hr(e,t){if(!k.isAbsolute(e))return e;let n=T(k.relative(t,e));return n.startsWith(`..`)||k.isAbsolute(n)?e:`/${n}`}function Ur(e,t={}){return[...zr(e,t)].sort().map(t=>`import ${JSON.stringify(Hr(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 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 qr(e){return e.startsWith(`/`)?e:`/${e}`}function Jr(e){let t=[...zr()],n=new Set(t),r=e=>{n.has(e)||(n.add(e),t.push(e))};return Yr(e,r)||Xr(e,r),t.length>0?`${t.join(`
|
|
46
|
+
`)}\n`:``}function Yr(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="${qr(e)}" />`)}t(`<script type="module" src="${qr(r)}"><\/script>`)}return n}function Xr(e,t){for(let[n,r]of Object.entries(e))r.type===`asset`&&n.endsWith(`.css`)&&!n.includes(`/server/`)&&t(`<link rel="stylesheet" href="${qr(n)}" />`)}function Zr(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 Qr(e){let t=[],n=0;for(let r of e){if(r==null){t.push(``);continue}let e=r-n;n=r,t.push(`${Zr(0)}${Zr(0)}${Zr(e)}${Zr(0)}`)}return t.join(`;`)}function $r(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:Qr(r)}}function ei(e,t){let n=e.length,r=t.length,i=Array.from({length:r}).fill(null);if(r===0||n===0)return i;if(ni(t,e)){let e=r-n;for(let t=0;t<n;t+=1)i[e+t]=t;return i}if(ri(t,e)){for(let e=0;e<n;e+=1)i[e]=e;return i}return n*r>2e6?ii(e,t):ti(e,t)}function ti(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 ni(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 ri(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 ii(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 ai(e,t,n){let r=ei(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 Li(e,t,n,r=`sans-serif`){let i=[`"${Mi(e)}"`];n&&i.push(`"${Mi(`${e} Fallback`)}"`);for(let e of t??[])i.push(e.includes(` `)?`"${Mi(e)}"`:e);return ji(t)||i.push(r),i.join(`, `)}function Ri(e){return e??`swap`}function zi(e){return e==null?`400`:String(e)}function Bi(e){return e??`normal`}const Vi=/* @__PURE__ */ new Map,Hi=/* @__PURE__ */ new Map;function Ui(e){return!u(e)||!Array.isArray(e.familyMetadataList)?!1:e.familyMetadataList.every(e=>u(e)&&typeof e.family==`string`&&e.family!==``)}function Wi(e){let t=e.replace(/^\)\]\}'\n?/,``);return JSON.parse(t)}function Gi(e){return[...new Set(e)].sort((e,t)=>e.localeCompare(t))}function Ki(e){let t=Gi((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 qi(e){if(!Ui(e))throw Error(`Unexpected fonts.google.com/metadata/fonts shape`);let t=/* @__PURE__ */ new Map;for(let n of e.familyMetadataList){let e=Ki(n);t.set(e.family,e)}return t}async function Ji(e){let t=Vi.get(e);if(t!=null)return t;let n=Hi.get(e);if(n!=null)return n;let r=Promise.resolve().then(async()=>{let t=k.join(e,`google-fonts-metadata.json`);if(D.existsSync(t))try{let n=qi(Wi(D.readFileSync(t,`utf8`)));return Vi.set(e,n),n}catch{try{D.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=qi(Wi(r));return Ci(e),D.writeFileSync(t,r.replace(/^\)\]\}'\n?/,``)),Vi.set(e,i),i});return Hi.set(e,r),r.finally(()=>{Hi.get(e)===r&&Hi.delete(e)})}async function Yi(e,t){try{return(await Ji(e)).get(t)??null}catch(e){return console.warn(`[rari/font] Failed to load Google font metadata for ${t}:`,e),null}}function Xi(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 Zi=1e4,Qi=/* @__PURE__ */ new Set([`fonts.gstatic.com`]);function $i(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(!Qi.has(t.hostname))throw Error(`Google font URL host not allowlisted (${t.hostname}): ${e}. Allowed: ${[...Qi].join(`, `)}`);return t}function ea(e){return e.subsets!=null&&e.subsets.length>0?e.preload!==!1:e.preload===!0}function ta(e){return e.trim().replaceAll(` `,`+`)}function na(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 ra=/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)$/;function ia(e){return ra.test(e.trim())}function aa(e){return e===`variable`||typeof e==`string`&&ia(e)?!0:Array.isArray(e)?e.some(e=>e===`variable`||typeof e==`string`&&ia(e)):!1}function oa(e){if(typeof e==`string`){let t=ra.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=ra.exec(t.trim());if(e!=null)return`${e[1]}..${e[2]}`}return`100..900`}function sa(e,t){if(e==null)return null;let n=e.find(e=>e.tag===t);return n==null?null:`${n.min}..${n.max}`}function ca(e,t){if(aa(e))return la(e,t);if(e!=null){let t=na(e);if(t.length===1)return`${t[0]}..${t[0]}`}return sa(t,`wght`)??`100..900`}function la(e,t){if(typeof e==`string`&&ia(e))return oa(e);if(Array.isArray(e)){for(let t of e)if(typeof t==`string`&&ia(t))return oa(t)}return sa(t,`wght`)??oa(e)}function ua(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 da(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 fa(e){return e==null||aa(e)?null:na(e)}function pa(e,t,n){let r=ta(e),i=Ri(t.display),a=ua(t.style),o=a.includes(`italic`),s=a.includes(`normal`)||!o,c=da(t);return`https://fonts.googleapis.com/css2?family=${r}:${aa(t.weight)||c.length>0?ma(t,n,c,o,s):_a(t.weight,o,s)}&display=${i}`}function ma(e,t,n,r,i){let a=[`wght`,...n.filter(e=>e!==`wght`&&e!==`ital`)].sort((e,t)=>e.localeCompare(t)),o=fa(e.weight),s=(e,n)=>e===`wght`?n:sa(t,e)??`1..1000`;if(o!=null)return ha(a,o,s,r,i);let c=ca(e.weight,t);return ga(a,a.map(e=>s(e,c)),r,i)}function ha(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 ga(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 _a(e,t,n){let r=na(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 va(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 ya(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 ba(e,t){if(D.existsSync(t))return D.readFileSync(t);let n=$i(e).href,r=null;for(let e=0;e<=3;e+=1){let e=await fetch(n,{signal:AbortSignal.timeout(Zi),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=$i(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 Ci(k.dirname(t)),D.writeFileSync(t,i),i}async function xa(e,t,n){let r=await Yi(n,e);Xi(e,t,r?.subsets);let i=pa(e,t,r?.axisRanges),a=k.join(n,`${F(i)}.css`),o;if(D.existsSync(a))o=D.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(Zi)});if(!t.ok)throw Error(`Failed to fetch Google Font CSS for ${e}: ${t.status} ${t.statusText}`);o=await t.text(),Ci(n),D.writeFileSync(a,o)}let s=ya(va(o),t.subsets);if(s.length===0)throw Error(`No @font-face rules returned for Google font "${e}"`);let c=Ri(t.display),l=ea(t),u=[];for(let r of s){let i=$i(r.url),a=F(r.url),o=k.extname(i.pathname)||`.woff2`,s=`${e.replaceAll(/\s+/g,``)}-${r.weight}-${r.style}-${a}${o}`,d=k.join(n,s);await ba(r.url,d),u.push({family:r.family,style:Bi(r.style),weight:zi(r.weight),display:c,src:[{url:``,format:Pi(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 Sa(e){return e.replaceAll(`_`,` `)}function Ca(e){return typeof e==`string`?[{path:e}]:e.map(e=>({...e}))}function wa(e,t,n){let r=Ri(e.display),i=e.preload!==!1,a=Ca(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=k.isAbsolute(r.path)?r.path:k.resolve(t,r.path);if(!D.existsSync(i))throw Error(`rari/font/local: font file not found: ${r.path} (from ${t})`);let a=k.relative(n,i);if(a.startsWith(`..`)||k.isAbsolute(a))throw Error(`rari/font/local: font file must be inside the project: ${r.path}`);return{absolute:i,weight:zi(r.weight??e.weight),style:Bi(r.style??e.style),familyBase:k.basename(i,k.extname(i))}}),s=o[0].familyBase;return o.map(t=>({family:s,style:t.style,weight:t.weight,display:r,src:[{url:``,format:Pi(t.absolute)}],preload:i,variable:e.variable,fallback:e.fallback,adjustFontFallback:e.adjustFontFallback,declarations:e.declarations,filePaths:[t.absolute]}))}function Ta(e,t){if(e[t]!==`{`)return null;try{let{json:n,end:r}=Ea(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 Ea(e,t){let n=G(e,t),r=e[n];if(r===`{`)return Aa(e,n);if(r===`[`)return ka(e,n);if(r===`'`||r===`"`)return Da(e,n);if(r===`-`||r>=`0`&&r<=`9`)return Oa(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 Da(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 Oa(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 ka(e,t){let n=[],r=G(e,t+1);if(e[r]===`]`)return{json:n,end:r+1};for(;r<e.length;){let t=Ea(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 Aa(e,t){let n={},r=G(e,t+1);if(e[r]===`}`)return{json:n,end:r+1};for(;r<e.length;){let t=ja(e,r),i=t.key;if(r=t.end,e[r]!==`:`)throw Error(`Expected :`);let a=Ea(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 ja(e,t){let n=t;if(e[n]===`'`||e[n]===`"`){let t=Da(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 Ma=`rari/font/local`,Na=`rari/font/google`,Pa=`\0rari-font-css:`,Fa=/\.(?:woff2?|ttf|otf)$/i;function Ia(e){if(e!=null){if(typeof e==`string`)return[e];if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}}function La(e){if(e===`auto`||e===`block`||e===`swap`||e===`fallback`||e===`optional`)return e}function Ra(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:La(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:Ia(e.fallback),adjustFontFallback:e.adjustFontFallback===!1?!1:e.adjustFontFallback===`Arial`||e.adjustFontFallback===`Times New Roman`?e.adjustFontFallback:void 0,declarations:za(e.declarations)}}function za(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 Ba(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:Ia(e.subsets),display:La(e.display),variable:typeof e.variable==`string`?e.variable:void 0,preload:typeof e.preload==`boolean`?e.preload:void 0,fallback:Ia(e.fallback),adjustFontFallback:typeof e.adjustFontFallback==`boolean`?e.adjustFontFallback:void 0,axes:Ia(e.axes)}}function Va(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 Ha(e){try{let t=await je(D.readFileSync(e));return{ascent:t.ascent,descent:t.descent,lineGap:t.lineGap,unitsPerEm:t.unitsPerEm,xWidthAvg:t.xWidthAvg}}catch{return null}}async function Ua(e,t){let n=await Di(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 Ha(e.filePaths[0]),n==null?{overrides:null,metrics:n}:(r??=Oi(n.category),{overrides:Ei(n,r),metrics:n})}function Wa(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 Ga(e,t,n){let r=[],i=[],a=[];for(let o of e){if(o.filePaths.length===0)continue;let e=o.filePaths[0],s=D.readFileSync(e),c=F(s);a.push(c);let l=xi(e,c,t);r.push({fileName:l,source:s}),i.push({...o,family:n,src:[{url:Si(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=wi(`rari_font`,c),u=o.variable==null?null:wi(`rari_font_var`,c),d=await Ua(o,n),f=d.overrides,p=d.metrics,m=``;for(let e of i)m+=Ii(e);m+=Wa(n,f);let h=Li(n,o.fallback,f!=null,Ai(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:`${Pa}${c}.css`,assets:r,preloadUrls:v}}function Ka(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=qa(e,r);if(t!=null){n(r,t),r=t;continue}r+=1}return t}function qa(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 K(e,t){return e.readUInt16BE(t)}function q(e,t){return e.readUInt32BE(t)}function Eo(e,t){return e.readUInt32LE(t)}function Do(e){return e.length<24||e.toString(`ascii`,1,4)!==`PNG`?null:{width:q(e,16),height:q(e,20)}}function Oo(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 ko(e){return e>=192&&e<=195||e>=197&&e<=199||e>=201&&e<=203||e>=205&&e<=207}function Ao(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 jo(e,t){if(t+1>=e.length)return null;let n=K(e,t);return n<2?null:t+n}function Mo(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,ko(n))return Ao(e,t);if(n===217||n===218)return null;let r=jo(e,t);if(r==null)return null;t=r}return null}function No(e,t){return(e[t]??0)|(e[t+1]??0)<<8|(e[t+2]??0)<<16}function Po(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:No(e,24)+1,height:No(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=Eo(e,21);return{width:(t&16383)+1,height:(t>>14&16383)+1}}return null}function Fo(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*Io(e,t,n){let r=t;for(;r+8<=n;){let t=Fo(e,r,n);if(t==null)return;yield t,r=t.end}}function Lo(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 Ro(e,t){let n=Lo(e,t);return n==null||n.dataOffset+8>t.end?null:{width:q(e,n.dataOffset),height:q(e,n.dataOffset+4)}}function zo(e,t){let n=Lo(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 Bo(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 Vo(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 Ho(e,t){let n=Lo(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=Bo(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=Vo(e,i,t.end,s,o);if(c==null)return null;i=c.nextOffset,a.set(r.itemId,c.propertyIndexes)}return a}function Uo(e){for(let t of Io(e,0,e.length))if(t.type===`meta`)return t;return null}function Wo(e,t,n){let r=1,i=null;for(let a of Io(e,t.start+t.headerSize,t.end)){if(a.type===`ispe`){let t=Ro(e,a);t!=null&&(n.set(r,t),i??=t)}r+=1}return i}function Go(e,t){let n=/* @__PURE__ */ new Map,r=null,i=null;for(let a of Io(e,t.start+t.headerSize,t.end))if(a.type===`ipco`){let t=Wo(e,a,n);i??=t}else a.type===`ipma`&&(r=Ho(e,a));return{ispeByIndex:n,associations:r,firstIspe:i}}function Ko(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=Uo(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 Io(e,n,t.end)){if(s.type===`pitm`){r=zo(e,s);continue}if(s.type!==`iprp`)continue;let t=Go(e,s);i=t.ispeByIndex,a=t.associations,o??=t.firstIspe}return Ko(r,a,i)??o}function Jo(e){return e.length<4?null:e[0]===137&&e.toString(`ascii`,1,4)===`PNG`?Do(e):e[0]===255&&e[1]===216?Mo(e):e.toString(`ascii`,0,3)===`GIF`?Oo(e):e.toString(`ascii`,0,4)===`RIFF`?Po(e):qo(e)}const Yo=/\.(?:avif|gif|jpe?g|png|webp)$/i,Xo=`\0rari-static-image:`,Zo=/* @__PURE__ */ new Set([`raw`,`url`,`inline`,`no-inline`]);function Qo(e){let t=e.indexOf(`?`);return t===-1?[]:e.slice(t+1).split(`&`).map(e=>e.split(`=`)[0]??``).filter(Boolean)}function $o(e){return Qo(e).includes(`rari-static-bypass`)}function es(e){return Qo(e).some(e=>Zo.has(e))}function ts(e,t,n){return yi(e,t,n,{encodeBase:!0})}function ns(e,t,n){return`const src = ${JSON.stringify(e)};\nexport default {\n src,\n width: ${t},\n height: ${n},\n};\n`}function rs(e){return Yo.test(C(e))&&!$o(e)&&!es(e)}function is(e,t=`assets`){let n=D.readFileSync(e),r=F(n),i=ts(e,r,t),a=vi(e,r,t),o=Jo(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:ns(i,o.width,o.height),publicPath:i,source:n,fileName:a}}const as=/* @__PURE__ */ new Map,os=/* @__PURE__ */ new Map;function ss(e,t){let n=as.get(e);if(n!=null)return n;let r=/* @__PURE__ */ new Map;if(D.existsSync(t))try{let e=f(D.readFileSync(t,`utf8`));if(e!=null)for(let[t,n]of Object.entries(e))typeof n==`string`&&r.set(t,n)}catch{}return as.set(e,r),r}function cs(e,t,n){for(let[r,i]of e)i===n&&r!==t&&e.delete(r);e.set(t,n)}function ls(e,t){let n=new Set(t.values());for(let[r,i]of e){if(!D.existsSync(i)){e.delete(r);continue}n.has(i)&&t.get(r)!==i&&e.delete(r)}}function us(e){return k.basename(e)===`client`?k.dirname(e):e}function ds(e){return k.join(us(e),`server`,`static-image-sources.json`)}function fs(e,t){let n=us(e),i=ds(e);if(t.size===0){try{D.unlinkSync(i)}catch(e){if(r(e)!==`ENOENT`)throw e}as.delete(n);return}D.mkdirSync(k.dirname(i),{recursive:!0});let a=Object.fromEntries(t);D.writeFileSync(i,`${JSON.stringify(a,null,2)}\n`)}function ps(e){let t=us(e);os.has(t)||os.set(t,/* @__PURE__ */ new Map)}function ms(e){let t=us(e),n=os.get(t);if(n==null)return;let r=ss(t,ds(e));r.clear();for(let[e,t]of n)D.existsSync(t)&&r.set(e,t);fs(e,r),os.delete(t)}function hs(e,t){let n=us(e),r=ss(n,ds(e));for(let[e,n]of t)r.set(e,n);let i=os.get(n);if(i!=null){for(let[e,n]of t)cs(i,e,n);return}ls(r,t),fs(e,r)}function gs(e,t){let n=!1;for(let[r,i]of e)i===t&&(e.delete(r),n=!0);return n}function _s(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 vs(e){try{return decodeURIComponent(e)}catch{return e}}function ys(e,t,n,r){let i=t?.split(`?`)[0];if(i==null||i===``){r();return}let a=vs(i),o=e.get(i)??e.get(a);if(o==null||o===``){r();return}n.setHeader(`Content-Type`,_s(k.extname(o).toLowerCase())),n.setHeader(`Cache-Control`,`no-cache`),D.createReadStream(o).on(`error`,()=>{n.headersSent||(n.statusCode=404),n.end()}).pipe(n)}function bs(){let e=process.cwd(),t=k.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&&ps(t)},async resolveId(e,t){if(t==null||t===``||!rs(e))return null;let n=await this.resolve(e,t,{skipSelf:!0});if(n==null||n.id===``)return null;let r=C(n.id);return D.existsSync(r)?Xo+r:null},load(e){if(!e.startsWith(Xo))return null;let r=e.slice(19),a=is(r,n);return cs(i,a.publicPath,r),hs(t,i),this.emitFile({type:`asset`,fileName:a.fileName,source:a.source}),a.code},watchChange(e,n){if(n.event!==`delete`)return;let r=C(e);if(!gs(i,r))return;let a=os.get(us(t));a!=null&&gs(a,r),hs(t,i)},configureServer(e){e.middlewares.use((e,t,n)=>{ys(i,e.url,t,n)})}}}function xs(e){let t=T(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 Ss(e,t){let n=e=>{if(D.existsSync(e))for(let r of D.readdirSync(e,{withFileTypes:!0})){let i=k.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&&D.existsSync(t)&&n(t)}function Cs(e){let t=/* @__PURE__ */ new Set;return Ss(e,e=>{try{let n=D.readFileSync(e,`utf-8`);for(let e of _e(n))t.add(e)}catch{}}),t}function ws(e,t){try{if(t.get(e).hasDefaultExport)return k.basename(e,k.extname(e));let n=t.getSource(e).match(x);if(n?.[1]!=null&&n[1]!==``)return n[1]}catch{}return k.basename(e,k.extname(e))}function Ts(e){let t=Cs(e.contentDirs.map(t=>k.join(e.projectRoot,t)));if(t.size===0)return[];let n=Er(e.componentScanDirs,e.cache),r=[],i=/* @__PURE__ */ new Set;for(let a of n){let n=ws(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 Es(e){let t=Os(e.projectRoot,e.mdxOptions),n=e.srcDir??k.join(e.projectRoot,`src`),r=Ms(e.projectRoot,t.componentsDir,yr(n,Object.values(e.alias??{})));return Ts({projectRoot:e.projectRoot,componentsDir:t.componentsDir,contentDirs:t.contentDirs,cache:e.cache,componentScanDirs:r})}function Ds(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:Qr(r)}}function oi(e,t,n){return e===t?null:{code:e,map:ai(n,t,e)}}const si=/\.(?:[cm]?[jt]sx?|vue|svelte|mdx?)$/i;function ci(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 li(e){if(!(`sourceRoot`in e))return;let t=Reflect.get(e,`sourceRoot`);return typeof t==`string`&&t!==``?t:void 0}function ui(e){return e.startsWith(`//`)||/^[a-z][a-z\d+.-]*:/i.test(e)}function di(e,t){if(t==null||ui(e)||e.startsWith(`/`))return e;if(ui(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 fi(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 pi(e,t,n,r){return e==null?null:ci(di(e,r),t,n)}function mi(e,t,n){let r=fi(e);if(r==null)return e;let i=li(e),a={...e,sources:r.map(e=>pi(e,t,n,i))};return delete a.sourceRoot,a}function hi(e,t,n,r){if(t.startsWith(`file://`))return gi(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 _i(e,t,i);if(o)return vi(e,t,i)}function gi(e,t,n){let r;try{r=w(A(t))}catch{return}if(!ce(r,n)||!je(e.config,r)||!si.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 $r(r,a)}function _i(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 mi(a,i.url,n)}function vi(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:mi(o,a.url,n)}catch{return}}function yi(e){let t=O.resolve(e);return{name:`rari:find-source-map-url`,apply:`serve`,configureServer(e){e.middlewares.use((n,r,i)=>{if(se(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=hi(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 bi(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 xi(e,t,n,r={}){let{base:i,ext:a}=bi(e,r);return`${C(n)}/${i}-${t}${a}`}function Si(e,t,n,r={}){return`/${xi(e,t,n,r)}`}function Ci(e){return`/${e.split(O.sep).join(`/`)}`}function wi(e,t,n){return xi(e,t,n,{defaultExt:`.woff2`,sanitizeBase:!0})}function Ti(e){return Ci(e)}function Ei(e){E.mkdirSync(e,{recursive:!0})}function Di(e,t){return`${e}_${t}`}function Oi(e){return`${(e*100).toFixed(2)}%`}function ki(e,t){if(!Number.isFinite(e.unitsPerEm)||e.unitsPerEm===0||!Number.isFinite(e.xWidthAvg))return null;let n=t===`Times New Roman`?Ne:j;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:Oi(a),ascentOverride:Oi(e.ascent/e.unitsPerEm/a),descentOverride:Oi(Math.abs(e.descent)/e.unitsPerEm/a),lineGapOverride:Oi(e.lineGap/e.unitsPerEm/a)}}async function Ai(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 ji(e){return e===`serif`?`Times New Roman`:`Arial`}const Mi=/* @__PURE__ */ new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`]);function Ni(e){return e===`serif`?`serif`:e===`monospace`?`monospace`:`sans-serif`}function Pi(e){return(e??[]).some(e=>Mi.has(e))}function Fi(e){return e.replaceAll(`\\`,`\\\\`).replaceAll(`"`,`\\"`)}function Ii(e,t){return`url("${Fi(e)}") format("${t}")`}function Li(e){let t=e.toLowerCase();return t.endsWith(`.woff2`)?`woff2`:t.endsWith(`.woff`)?`woff`:t.endsWith(`.ttf`)?`truetype`:t.endsWith(`.otf`)?`opentype`:`woff2`}function Ri(e){return e===`woff`?`font/woff`:e===`truetype`?`font/ttf`:e===`opentype`?`font/otf`:`font/woff2`}function zi(e){let t=e.src.map(e=>Ii(e.url,e.format)).join(`, `),n=(e.declarations??[]).map(e=>` ${e.prop}: ${e.value};`).join(`
|
|
50
|
+
`),r=`@font-face {\n font-family: "${Fi(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 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?so(e,t):null}function Za(e,t){let n=Ya(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 Qa(e,t){let n=Ya(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 $a(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 eo(e){return e>=65&&e<=90||e>=97&&e<=122||e===36||e===95||e>=128}function to(e){return eo(e)||e>=48&&e<=57}function no(e,t){let n=e.indexOf(`
|
|
53
|
+
`,t+2);return n===-1?e.length:n+1}function ro(e,t){let n=e.indexOf(`*/`,t+2);return n===-1?e.length:n+2}function io(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=so(e,n);continue}if(t===47&&e.charCodeAt(n+1)===47){n=no(e,n);continue}if(t===47&&e.charCodeAt(n+1)===42){n=ro(e,n);continue}t===123?r+=1:t===125&&--r,n+=1}return n}function ao(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 oo(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=io(e,n+2);continue}n+=1}return n}function so(e,t){let n=e.charCodeAt(t);return n===96?oo(e,t):ao(e,t,n)}function co(e,t){let n=e.charCodeAt(t);return n===47&&e.charCodeAt(t+1)===47?no(e,t):n===47&&e.charCodeAt(t+1)===42?ro(e,t):n===34||n===39||n===96?so(e,t):null}function lo(e,t,n){if(!eo(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&&to(i)||r<e.length&&to(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 uo(e,t){let n=[],r=0;for(;r<e.length;){let i=co(e,r);if(i!=null){r=i;continue}let a=lo(e,t,r);if(a!=null){n.push(a),r=a.openParen+1;continue}r+=1}return n}async function fo(e,t,n,r){if(!e.includes(`rari/font/`))return null;let i=Za(e,Fa),a=Za(e,Ia);if(Qa(e,Fa)||Qa(e,Ia))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 uo(o,e).sort((e,t)=>t.start-e.start)){let e=Wa(o,r.openParen);e===-1&&n(`unbalanced parentheses`);let i=po(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=$a(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=Da(Va(e),d,n),i=`Rari ${O.basename(t[0].filePaths[0],O.extname(t[0].filePaths[0]))}`;return Ja(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?{}:Ua(t),i=Ta(e.imported);return Ja(await wa(i,n,f),r,i)});let g=[...i.defaultNames,...a.names.map(e=>e.local)];for(let e of g)if(uo(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=go(o,_)),o===e?null:{code:o,cssModules:s,assets:c,preloadUrls:l}}function po(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=Oa(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 mo(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=no(e,n);continue}if(t===`/`&&e[n+1]===`*`){n=ro(e,n);continue}break}return n}function ho(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),mo(e,r)}function go(e,t){let n=+(e.charCodeAt(0)===65279),r=0;for(;;){n=mo(e,n);let t=ho(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 _o(e){return e===`.woff`?`font/woff`:e===`.ttf`?`font/ttf`:e===`.otf`?`font/otf`:`font/woff2`}function vo(e){return e===`.woff`?`woff`:e===`.ttf`?`truetype`:e===`.otf`?`opentype`:`woff2`}function yo(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()||!Ra.test(i))return null}catch{return null}return i}function bo(){let e=process.cwd(),t=`assets`,n=O.join(e,`dist`,`client`),r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;return{name:`rari:font`,enforce:`pre`,configResolved(r){let i=Ut(r);e=i.projectRoot,t=i.assetsDir,n=i.outDir},resolveId(e){return e.startsWith(La)?e:null},load(e){return e.startsWith(La)?r.get(e)??null:null},async transform(n,a){let o=await fo(n,a,e,t);if(o==null)return null;for(let e of o.cssModules)r.set(e.id,e.css);for(let e of o.assets)i.set(e.fileName,e.source);for(let e of o.preloadUrls)Rr(`<link rel="preload" href="${e}" as="font" type="${Ri(vo(O.extname(e).toLowerCase()))}" crossorigin />`);return{code:o.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`,_o(O.extname(o).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),t.end(s);return}let c=yo(n,o);if(c==null){r();return}t.setHeader(`Content-Type`,_o(O.extname(c).toLowerCase())),t.setHeader(`Cache-Control`,`no-cache`),E.createReadStream(c).pipe(t)})}}}var xo=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 So(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 xo(e.status,e.statusText,n)}}var Co=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=_e(this.resetTimer),this.resetTimer=setTimeout(()=>{this.reset()},this.resetTimeout),this.errorCount>=this.maxErrors&&this.handleMaxErrorsReached()}reset(){this.errorCount=0,this.lastError=null,this.resetTimer=_e(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 wo(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 To(e){return u(e)&&e.success===!0&&typeof e.componentId==`string`&&typeof e.filePath==`string`&&typeof e.relativePath==`string`}function Eo(e){return u(e)&&e.success===!1&&typeof e.filePath==`string`&&typeof e.relativePath==`string`&&o(e.error)}function Do(e){return e===`info`||e===`success`||e===`warning`||e===`error`}var Oo=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 Co({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=c(e,String(e));this.queueLog(`error`,`Failed to update client component: ${n} - ${t}`),this.errorHandler.recordError(d(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 r=[...e,...n],i=await Promise.allSettled(r.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:d(n)}}})),a=[],o=[];if(i.forEach(e=>{e.status===`fulfilled`&&To(e.value)?a.push(e.value):e.status===`fulfilled`&&Eo(e.value)?o.push(e.value):e.status===`rejected`&&o.push({filePath:``,relativePath:`unknown`,error:Error(String(e.reason))})}),a.length>0){let e=Date.now();a.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(o.length>0){let e=Date.now();o.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=w(e);if(!O.isAbsolute(e))return t;let n=w(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(!u(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 So(t);let r=await t.text(),i;try{i=JSON.parse(r)}catch(e){throw Error(`Failed to parse server response (status ${t.status}): ${c(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[...wo(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(Do(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 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'
|
|
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`?vc(e,r,t,n):null}function bc(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 xc(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 Sc(e,t){let n=t+1,r=1,i=n,a=[{kind:`code`,braceDepth:0}];for(;i<e.length&&r>0;){let t=yc(a,e,i);if(t!=null){if(t.forceRuntime)return{forceRuntime:!0,endIndex:e.length};i=t.j;continue}let n=bc(a,e,i);if(n!=null){i=n;continue}let o=xc(e,i,r);if(o.forceRuntime)return{forceRuntime:!0,endIndex:o.j};i=o.j,r=o.depth}return r===0?{...Ac(e.slice(n,i-1)),endIndex:i}:{forceRuntime:!0,endIndex:e.length}}function Cc(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==="`"?_c(e,n,r):r===`[`?Sc(e,n):{forceRuntime:!0,endIndex:n+1}}function wc(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=Cc(e,s);return c==null||c.forceRuntime?{nextI:t,forceRuntime:!0}:{nextI:c.endIndex,binding:{matcher:c.matcher,forceRuntime:!1}}}function Tc(e,t,n,r){let i=e.at(-1);if(i===void 0)return{nextI:n,forceRuntime:!0};let a=dc(e,t,n);if(a!=null)return{nextI:a};if(i.kind!==`code`)return{nextI:n,forceRuntime:!0};let o=fc(e,t,n);if(o!=null)return{nextI:o};if(pc(i,e,t.charAt(n)))return{nextI:n+1};let s=wc(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 Ec(e){let t=[{kind:`code`,braceDepth:0}],n=[];for(let r=0;r<e.length;){let i=Tc(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 Dc(e){let t=e.trim();if(t===``||t.includes(`&&`))return null;let n=t.split(/\|\|/),r=[],i;for(let e of n){let t=Is.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 Oc(e){let t=[];Fs.lastIndex=0;for(let n of e.matchAll(Fs)){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=Dc(e);if(s==null)return[];for(let e of s)t.push({source:e,type:r,destination:i,...r===`redirect`?{permanent:Js(o)}:{}})}return t}function kc(e){let t=Rs.exec(e);return t==null?null:gc(e,t.index+t[0].length-1)}function Ac(e){if(e.includes(`{`))return{forceRuntime:!0};let t=[];Ks.lastIndex=0;for(let n of e.matchAll(Ks)){let e=n[1],r=n[2];if(r===``||e!==`'`&&e!==`"`&&e!=="`")continue;let i=ac(r,e);if(i==null)return{forceRuntime:!0};i!==``&&t.push(i)}return e.replace(Ks,``).replace(/[\s,]/g,``)===``&&t.length>0?{matcher:t,forceRuntime:!1}:{forceRuntime:!0}}function jc(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=dc(n,e,r,t);if(a!=null){r=a;continue}if(i.kind!==`code`)return null;let o=fc(n,e,r);if(o!=null){r=o;continue}if(pc(i,n,e.charAt(r))){r+=1;continue}r+=1}let r=n.at(-1);return r?.kind===`code`?r.braceDepth:null}function Mc(e,t){return jc(e,t)===1}function Nc(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=Nc(t[0])?t.index:t.index+t[0].indexOf(`matcher`);if(n>=t.index&&Mc(e,n))return t}return null}function Pc(e,t){let n=t;for(;n<e.length;){let t=Ic(e,n);if(t!=null){n=t;continue}let r=e.charAt(n);return r===`,`||r===`}`}return!0}function Fc(e,t){let n=t;for(;n<e.length;){let t=Ic(e,n);if(t==null)break;n=t}return n}function Ic(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&&!Xs(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 Lc(e,t){if(e.charAt(t)!==`[`)return null;let n=Fc(e,t+1);if(n>=e.length)return{endIndex:e.length,forceRuntime:!0};let r=e.charAt(n);if(r===`'`||r===`"`||r==="`"){let t=oc(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=ac(i,r);return n=Fc(e,t),e.charAt(n)===`]`?{endIndex:n+1,forceRuntime:a===`matcher`}:{endIndex:n,forceRuntime:!0}}return{endIndex:t+1,forceRuntime:!0}}function Rc(e,t,n,r){return n===`'`||n===`"`||n==="`"?{entered:!0,expectPropertyKey:r&&t.braceDepth===1?!1:r}:{entered:!1,expectPropertyKey:r}}function zc(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 Bc(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=Lc(e,t);return n?.forceRuntime===!0||n==null?{unsafe:!0}:{unsafe:!1,nextI:n.endIndex,clearExpect:!0}}return{unsafe:!1,clearExpect:!0}}function Vc(e,t,n,r){let i=e.at(-1);if(i===void 0)return null;let a=dc(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=Rc(e,i,o,r);if(c.entered)return{nextI:fc(e,t,n)??n+1,expectPropertyKey:c.expectPropertyKey};let l=fc(e,t,n);if(l!=null)return{nextI:l,expectPropertyKey:r};let u=zc(i,e,o,r);if(u.handled)return{nextI:n+1,expectPropertyKey:u.expectPropertyKey};let d=Bc(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 Hc(e){let t=[{kind:`code`,braceDepth:0}],n=!1;for(let r=0;r<e.length;){let i=Vc(t,e,r,n);if(i==null)return!1;if(i.unsafe)return!0;n=i.expectPropertyKey,r=i.nextI}return!1}function Uc(e,t){let n=Nc(t[0]),r=n?t[2]:t[1],i=n?t[3]:t[2];if(r!==`'`&&r!==`"`&&r!=="`")return null;if(r==="`"&&i.includes("${")||!Pc(e,t.index+t[0].length))return{forceRuntime:!0};let a=ac(i,r);return a==null||a===``?{forceRuntime:!0}:{matcher:a,forceRuntime:!1}}function Wc(e){if(!Ls.test(e)||!Rs.test(e))return{forceRuntime:!1};let t=kc(e);if(t==null||Hc(t)||J(t,zs)!=null||J(t,Hs)!=null)return{forceRuntime:!0};let n=J(t,Bs)??J(t,Us);if(n!=null)return Uc(t,n)??{forceRuntime:!1};let r=J(t,Vs)??J(t,Ws);return r==null?J(t,qs)==null?J(t,/matcher\s*:/)!=null||J(t,Gs)!=null?{forceRuntime:!0}:{forceRuntime:!1}:Ec(e)??{forceRuntime:!0}:Pc(t,r.index+r[0].length)?Ac(Nc(r[0])?r[2]:r[1]):{forceRuntime:!0}}function Gc(e){let{matcher:t,forceRuntime:n}=Wc(e);if(n||Ns.test(e))return{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}};let r=Ps.test(e),i=Oc(e);return r&&i.length===0?{requiresRuntime:!0,rules:[],...t==null?{}:{matcher:t}}:{requiresRuntime:!1,rules:i,...t==null?{}:{matcher:t}}}function Kc(e){let t=Gc(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,Jc=/@import\s+(?:url\(\s*((?:\.\/|\.\.\/)[^)\s]+)\s*\)|url\(\s*['"]((?:\.\/|\.\.\/)[^'"]+)['"]\s*\)|['"]((?:\.\/|\.\.\/)[^'"]+)['"])([^;]*)(?:;|$)/g,Yc=/\.css(?:\?.*)?$/,Xc=/\.module\.css(?:\?.*)?$/i;function Zc(e){return Xc.test(e.replace(/[?#].*$/,``))}function Qc(e){return e.replace(qc,``).trim()}function $c(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 el(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 tl(e){let t=e.trim().replace(/^\)\s*/,``),n=el(t);t=n.rest;let r=$c(t);t=r.rest;let i=t.trim()===``?null:t.trim();return{layerName:n.layerName,supportsCondition:r.supportsCondition,mediaQuery:i}}function nl(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 rl(e,t,n=/* @__PURE__ */ new Set){let r=k.resolve(e);return n.has(r)?``:(n.add(r),t.replace(Jc,(e,t,i,a,o)=>{let s=t??i??a;if(s==null||s===``)return e;let c=k.resolve(k.dirname(r),s);try{return!D.existsSync(c)||!D.statSync(c).isFile()?e:nl(il(c,D.readFileSync(c,`utf-8`),new Set(n)),tl(o))}catch{return e}}).trim())}function il(e,t,n=/* @__PURE__ */ new Set){return rl(e,Qc(t),n)}function al(e,t){let n=/* @__PURE__ */ new Set;for(let r of zr(e,t)){if(k.isAbsolute(r)){n.add(k.resolve(r));continue}try{n.add(Ce(k.join(e,`package.json`)).resolve(r))}catch{}}return n}function ol(e){return D.existsSync(e)&&D.statSync(e).isFile()?e:null}function sl(e,t,n){let r=[t,k.join(n,`package.json`)];for(let t of r)try{let n=ol(Ce(t).resolve(e));if(n!=null)return n}catch{try{let n=ol(j(import.meta.resolve(e,Oe(t).href)));if(n!=null)return n}catch{}}return null}function cl(e,t,n,r){let i=e.replace(/[?#].*$/,``);if(!Yc.test(i))return null;if(k.isAbsolute(i))return ol(i);if(i.startsWith(`./`)||i.startsWith(`../`))return ol(k.resolve(k.dirname(t),i));let a=E(i,r,n);if(a!=null&&a!==``){let e=ol(a);if(e!=null)return e}return sl(i,t,n)}function ll(e){let t=e.includes(`?`)?e.slice(e.indexOf(`?`)):``;return/(?:\?|&)raw(?:&|$)/.test(t)||/(?:\?|&)url(?:&|$)/.test(t)}function ul(e,t){if(Zc(e)||t.has(k.resolve(e)))return null;try{let t=il(e,D.readFileSync(e,`utf-8`));return t===``?null:t}catch{return null}}function dl(e){let t=[];for(let n of Nn(e.code)){if(!Yc.test(n.source)||Zc(n.source)||ll(n.source))continue;let r=cl(n.source,e.filePath,e.projectRoot,e.aliases);if(r==null)continue;let i=ul(r,e.layoutCssSkip);i!=null&&t.push(i)}return t}const fl=/^proxy\.(?:tsx?|jsx?|mts|mjs)$/,pl=/^(?:robots|sitemap|feed)\.(?:tsx?|jsx?)$/,ml=/^(?:favicon|icon\d*|apple-icon\d*)\.(?:ico|png|jpe?g|svg)$/i,hl=/^layout\.(?:tsx|ts|jsx|js)$/,gl=[{componentId:`rari/image`,devSourceSegments:[`src`,`image`,`image.tsx`],publishedExport:`rari/image`,exports:[`Image`]}],_l=k.dirname(j(import.meta.url)),vl=k.dirname(_l);function yl(e){return e.startsWith(vl)}function bl(){let e=k.join(vl,`src`,`runtime`,`boundaries`,`error-boundary-wrapper.tsx`);if(D.existsSync(e))return e;try{let e=j(import.meta.resolve(`rari/runtime/ErrorBoundaryWrapper`));if(D.existsSync(e))return e}catch{}return null}function xl(e){let t=T(e);return t.includes(`ErrorBoundaryWrapper`)||t.includes(`/boundaries/error-boundary-wrapper`)||t.endsWith(`/error-boundary-wrapper.tsx`)}function Sl(e){return u(e)&&u(e.components)}function Cl(e,t){if(xl(e))return`virtual:error-boundary-wrapper.tsx`;let n=T(k.relative(t,e));return n.startsWith(`..`)||k.isAbsolute(n)?T(e):n}function wl(e,t){if(xl(e))return`error_boundary_wrapper_${F(`virtual:error-boundary-wrapper.tsx`)}`;if(yl(e)){let t=T(k.relative(vl,e));return`${Wt(t)}_${F(t)}`}return Gt(e,t)}function Tl(e,t){return!e.includes(`node_modules`)&&!t.directives.hasUseClient&&!t.directives.hasUseServer}var El=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??=al(this.projectRoot,this.options.alias),this.layoutCssSkipSet}resolveServerCssSources(e,t){return dl({filePath:e,code:t,projectRoot:this.projectRoot,aliases:this.options.alias,layoutCssSkip:this.getLayoutCssSkipSet()})}resolveExtraFileOutPath(e){let t=T(e);return t===this.options.assetsDir||t.startsWith(`${this.options.assetsDir}/`)?k.join(this.options.clientOutDir,t):k.join(this.options.outDir,this.options.rscDir,t)}setViteBuilder(e){this.viteBuilder=e}getProjectRoot(){return this.projectRoot}async getEmitBuilder(){return this.viteBuilder??=await ce({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 fe({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=k.join(this.options.clientOutDir,`assets`,`server`);await D.promises.mkdir(n,{recursive:!0});let r=`${t.join(`
|
|
81
|
-
`)}\n`,i=`${F(e+r,12)}.css`,a=k.join(n,i);return await D.promises.writeFile(a,r,`utf-8`),[`/assets/server/${i}`]}getComponentIdFromRouteManifestPath(e){return this.getComponentId(k.join(this.projectRoot,`src`,`app`,e))}getComponentReferenceId(e){return this.getReadableComponentId(this.getProjectRelativePath(e))}async writeRouteCssEntries(e){let t=k.join(this.options.outDir,this.options.rscDir,`routes.json`);if(!D.existsSync(t))return;let n=await D.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 D.promises.writeFile(t,JSON.stringify(i),`utf-8`)}constructor(e,t={}){this.projectRoot=k.resolve(e),this.moduleAnalysisCache=t.moduleAnalysisCache??new Dr;let n=t.rscDir!=null&&t.rscDir!==``?t.rscDir:`server`,r=t.outDir!=null&&t.outDir!==``?t.outDir:be,i=xe(this.projectRoot,r),a=t.clientOutDir!=null&&t.clientOutDir!==``?xe(this.projectRoot,t.clientOutDir):k.join(i,`client`);this.options={outDir:i,clientOutDir:a,rscDir:n,manifestPath:t.manifestPath!=null&&t.manifestPath!==``?t.manifestPath:k.join(n,`manifest.json`),serverConfigPath:t.serverConfigPath!=null&&t.serverConfigPath!==``?t.serverConfigPath:k.join(n,`config.json`),minify:t.minify??A.env.NODE_ENV===`production`,alias:t.alias??{},assetsDir:t.assetsDir!=null&&t.assetsDir!==``?w(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 Tl(e,this.moduleAnalysisCache.get(e,t))}catch{return!1}}isClientComponent(e,t){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=k.dirname(e);n=k.resolve(r,t)}else if(n=E(t,this.options.alias,this.projectRoot),(n==null||n===``)&&t.startsWith(`@/`)){let e=t.slice(2);n=k.join(this.projectRoot,`src`,e)}return n==null||n===``?null:he(n,[``,`.ts`,`.tsx`,`.js`,`.jsx`])}populateImportGraphFromFiles(e){this.fileImporters.clear();for(let{filePath:t,analysis:n}of e)for(let e of wr(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=Dl(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??D.readFileSync(e,`utf-8`),i=n??this.moduleAnalysisCache.get(e,r),a=Cr(i.importSources),o=Sr(i);if(i.directives.hasUseServer){this.serverActions.set(e,{filePath:e,originalCode:r,dependencies:a,hasNodeImports:o});return}Tl(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 Cr((t!=null&&t!==``?this.moduleAnalysisCache.get(t,e):V(e)).importSources)}hasNodeImports(e,t){return Sr(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 D.promises.mkdir(k.dirname(t),{recursive:!0}),await D.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=k.join(e,`proxy.json`),n=[...this.serverComponents.entries()].filter(([e])=>fl.test(k.basename(e)));if(n.length===0){try{await D.promises.unlink(t)}catch(e){r(e)!==`ENOENT`&&console.warn(`Failed to remove proxy manifest file:`,e)}return}let[i,a]=n[0],o=T(this.getProjectRelativePath(i)),s=this.getComponentId(o),c=T(k.join(this.options.rscDir,`${s}.js`)),l=Kc({proxyFile:o,code:a.originalCode,bundlePath:c});l.requiresRuntime||this.serverComponents.delete(i),await D.promises.writeFile(t,JSON.stringify(l),`utf-8`)}async buildServerComponents(){let e=k.join(this.options.outDir,this.options.rscDir);await D.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=k.join(this.options.outDir,this.options.manifestPath);await D.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=k.join(this.options.outDir,this.options.serverConfigPath);if(Object.keys(e).length===0){try{await D.promises.unlink(t)}catch(e){r(e)!==`ENOENT`&&console.warn(`Failed to remove server config file:`,e)}return}await D.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 D.promises.mkdir(k.dirname(t),{recursive:!0}),await D.promises.writeFile(t,e.code)}for(let[n,r]of t.entries){let t=k.relative(this.projectRoot,n),i=this.getComponentId(n),a=pe(this.options.rscDir,i),o=k.join(this.options.outDir,a);await D.promises.mkdir(k.dirname(o),{recursive:!0}),await D.promises.writeFile(o,r.code,`utf-8`);let s=this.serverComponents.get(n)??this.serverActions.get(n),c=this.resolveServerCssSources(n,s?.originalCode??await D.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:Oe(k.resolve(this.projectRoot,o)).href,dependencies:[...s?.dependencies??[]],hasNodeImports:s?.hasNodeImports??!1,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 fe({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=Es({projectRoot:this.projectRoot,mdxOptions:e,alias:this.options.alias,cache:this.moduleAnalysisCache}),n=k.join(this.options.outDir,this.options.manifestPath),r;if(D.existsSync(n)){let e=await D.promises.readFile(n,`utf-8`),t=f(e);r=t&&Sl(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 D.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=D.readFileSync(t,`utf-8`);e.push({filePath:t,code:n})}catch{}try{let t=bl();if(t!=null&&t!==``){let n=D.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 gl){let a=this.resolveExternalClientSourcePath(n,r);if(a!=null&&a!==``)try{let n=D.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=k.join(this.options.outDir,`ssr`);await D.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=T(t.fileName),r=n===this.options.assetsDir||n.startsWith(`${this.options.assetsDir}/`)?k.join(this.options.clientOutDir,n):k.join(e,n);await D.promises.mkdir(k.dirname(r),{recursive:!0}),await D.promises.writeFile(r,t.code)}for(let[e,a]of i.entries){let i=n.find(t=>t.filePath===e),o=i?.componentId??Cl(e,this.projectRoot),s=`ssr/${i?.bundleName??wl(e,this.projectRoot)}.js`,c=k.join(this.options.outDir,s);await D.promises.mkdir(k.dirname(c),{recursive:!0}),await D.promises.writeFile(c,a.code,`utf-8`);let l=i?.code??t.find(t=>t.filePath===e)?.code??D.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:wl(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 me({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=k.join(e,`manifest.json`);await D.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=k.join(this.options.outDir,`server`);await D.promises.mkdir(i,{recursive:!0});let a=k.join(i,`client-reference-manifest.json`);await D.promises.writeFile(a,JSON.stringify(r),`utf-8`)}resolveExternalClientSourcePath(e,t){let n=k.join(vl,...e);if(D.existsSync(n))return n;try{let e=j(import.meta.resolve(t));if(D.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){hl.test(k.basename(e))&&(this.layoutCssSkipSet=null);let t=this.getComponentId(e),n=await D.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=k.join(this.options.rscDir,`${t}.js`),o=k.join(this.options.outDir,a),s=this.buildCache.get(e),c=(await D.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 D.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=k.dirname(o);await D.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 D.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 D.promises.mkdir(k.dirname(t),{recursive:!0}),await D.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 T(k.relative(this.projectRoot,e))}manifestCache=null;async updateManifestForComponent(e,t,n,r=[]){let i=k.join(this.options.outDir,this.options.manifestPath),a;if(this.manifestCache)a=this.manifestCache;else if(D.existsSync(i)){let e=await D.promises.readFile(i,`utf-8`),t=f(e);t&&Sl(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=k.join(this.options.outDir,n),c=Oe(k.resolve(this.projectRoot,s)).href;if(o)a.components[e]={id:e,filePath:t,relativePath:k.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:[...o.dependencies],hasNodeImports:o.hasNodeImports,css:r};else{let i=await D.promises.readFile(t,`utf-8`);a.components[e]={id:e,filePath:t,relativePath:k.relative(this.projectRoot,t),bundlePath:n,moduleSpecifier:c,dependencies:this.extractDependencies(i,t),hasNodeImports:this.hasNodeImports(i,t),css:r}}a.buildTime=(/* @__PURE__ */ new Date()).toISOString(),await D.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 Dl(e,t){let n=[];for(let r of vr(t))try{let t=W(r),i=D.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 Ol(e,t){return(t??V(e)).hasComponentExport||v.test(e)||te.test(e)||re.test(e)}function kl(e,t,n,r){let i=k.basename(e);if(pl.test(i)||ml.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)&&Tl(e,a)&&Ol(t,a)}function Al(e,t,n=[]){let r=Dl(t,yr(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)),kl(e,n,t,o)&&(t.addServerComponent(e,n,o),i.push(e));return{serverComponentPaths:i,clientComponentPaths:a}}function jl(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:k.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:k.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:k.join(n,`src`,`app`),outDir:r,aliases:a})}catch(e){console.warn(`[rari] Failed to generate feed:`,e)}try{let e=k.join(i,`server`,`routes.json`);if(D.existsSync(e)){let t=it(D.readFileSync(e,`utf-8`));t.length>0&&await nt({appDir:k.join(n,`src`,`app`),outDir:r,icons:t})}}catch(e){console.warn(`[rari] Failed to copy app icons:`,e)}try{let t=Os(n,e.mdx),a=[`public/content`,T(k.relative(n,k.join(i,`content`))),T(k.relative(n,k.join(r,`content`)))].filter(e=>e!==``&&!e.startsWith(`..`)&&!k.isAbsolute(e)),o=ks(n,t.contentDirs).filter(e=>{let t=T(k.relative(n,e));return!a.some(e=>t===e||t.startsWith(`${e}/`))});o.length>0&&js(o,k.join(i,`content`))}catch(e){console.warn(`[rari] Failed to copy MDX content:`,e)}ms(r)}}return{name:`rari-server-build`,sharedDuringBuild:!0,configResolved(s){n=s.root,r=ye(s.root,s.build.outDir),i=ve(r),o=!1;let c=Vt(s);a=c;let l=typeof s.build.assetsDir==`string`&&s.build.assetsDir!==``?w(s.build.assetsDir):`assets`;t=new El(n,{...e,alias:c,assetsDir:l,outDir:i,clientOutDir:r,minify:e.minify??s.mode===`production`})},buildStart(){if(!t)return;let e=k.join(n,`src`);D.existsSync(e)&&Al(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 Ml(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 Nl(e,t){return`const ${e} = createClientModuleProxy(${JSON.stringify(t)});`}function Pl(e,t,n){return`const ${e} = registerClientReference(
|
|
74
|
+
`}function ks(e,t){return{componentsDir:t?.componentsDir??`src/components`,contentDirs:t?.contentDirs??[`src/content`,`content`,`public/content`]}}function As(e,t){return t.map(t=>O.join(e,t)).filter(e=>E.existsSync(e))}function js(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(w(O.relative(e,a)))}};return n(e),t}function Ms(e,t){for(let n of e)for(let e of js(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 Ns(e,t,n){let r=O.join(e,t),i=new Set(n);return E.existsSync(r)&&i.add(r),[...i]}const Ps=/\.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|`[^`]*\$\{/,Fs=/RariResponse\.(?:redirect|rewrite)\s*\(/,Is=/if\s*\(([^)]+)\)(?:\s*\{)?\s+return\s+RariResponse\.(redirect|rewrite)\(\s*new\s+URL\(\s*(['"`])([^'"`]+)\3\s*,[^)]+\)(?:\s*,\s*(\d+))?\s*\)/g,Ls=/^(?:(request\.rariUrl\.pathname|pathname|normalizedPath)\s*(?:===|==)\s*(['"`])([^'"`]+)\2|(['"`])([^'"`]+)\4\s*(?:===|==)\s*(request\.rariUrl\.pathname|pathname|normalizedPath))$/,Rs=/export\s+const\s+config\s*=/,zs=/export\s+const\s+config\s*=\s*\{/,Bs=/matcher\s*:\s*\{/,Vs=/matcher\s*:\s*(['"`])([^'"`]+)\1/,Hs=/matcher\s*:\s*\[([^\]]*)\]/,Us=/(['"`])matcher\1\s*:\s*\{/,Ws=/(['"`])matcher\1\s*:\s*(['"`])([^'"`]+)\2/,Gs=/(['"`])matcher\1\s*:\s*\[([^\]]*)\]/,Ks=/(['"`])matcher\1\s*:/,qs=/(['"`])([^'"`]+)\1/g,Js=/(?:^|[{,]\s*)matcher\s*[,}]/;function Ys(e){return e===301||e===308}const Xs=/* @__PURE__ */ new Set([`return`,`throw`,`case`,`else`,`do`,`typeof`,`delete`,`void`,`await`,`yield`,`new`,`in`,`of`,`instanceof`]);function Zs(e){return e===`
|
|
75
|
+
`||e===`\r`||e===`\u2028`||e===`\u2029`}function Qs(e,t){for(t-=2;t>=1;){if(e.charAt(t-1)===`/`&&e.charAt(t)===`*`)return t-2;--t}return t}function $s(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 ec(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=Qs(e,n);continue}let t=n;for(;t>0&&!Zs(e.charAt(t-1));)--t;let r=$s(e,t,n);if(r!==-1){n=r-1;continue}break}return n}function tc(e,t){let n=ec(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 Xs.has(e.slice(i+1,n+1))}function nc(e){return e===`
|
|
76
|
+
`||e===`\r`||e===`\u2028`||e===`\u2029`}function rc(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 ic(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 ac(e,t,n,r){if(nc(n)){let i=t;return n===`\r`&&e.charAt(t+1)===`
|
|
78
|
+
`&&(i=t+1),{out:r,i}}let i=rc(n);if(i!=null)return{out:r+i,i:t};let a=ic(e,t,n);return a==null?n===`x`||n===`u`?null:{out:r+n,i:t}:{out:r+a.char,i:a.end}}function oc(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=ac(e,r,e.charAt(r),n);if(a==null)return null;n=a.out,r=a.i}return n}function sc(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 cc(e,t,n,r){return n===`\\`?r+2:((t===`single`&&n===`'`||t===`double`&&n===`"`)&&e.pop(),r+1)}function lc(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 uc(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 dc(e,t,n){return t===`\\`?n+2:(t===`]`&&e.pop(),n+1)}function fc(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`?cc(e,i.kind,a,n):i.kind===`template`?lc(e,a,o,n):i.kind===`regex`?uc(e,t,a,n,r):dc(e,a,n)}function pc(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===`/`&&tc(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 mc(e,t,n){return n===`{`?(e.braceDepth+=1,!0):n===`}`&&(--e.braceDepth,e.braceDepth===0&&t.length>1&&t.pop(),!0)}function hc(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 gc(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{i:a,done:null};if(i.kind!==`code`)return null;let o=pc(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===`}`?hc(i,e,t,r,n):{i:n+1,done:null}}function _c(e,t){let n=[{kind:`code`,braceDepth:0}];for(let r=t;r<e.length;){let i=gc(n,e,r,t);if(i==null)return null;if(i.done!=null)return i.done;r=i.i}return null}function vc(e,t,n){if(n==="`"&&sc(e,t,"`")==null)return{forceRuntime:!0,endIndex:e.length};let r=sc(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=oc(i,n);return a==null||a===``?{forceRuntime:!0,endIndex:r}:{matcher:a,forceRuntime:!1,endIndex:r}}function yc(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 bc(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`?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(
|
|
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 Il=/(?:^|[\n\r;])\s*import\s*\{[^}]*\bregisterServerReference\b[^}]*\}\s*from\s*["'][^"'\n]+["']/;function Ll(e){return Il.test(e)}const Rl=/* @__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(`.`)),zl=/* @__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 Bl(e){return e>=97&&e<=122||e>=65&&e<=90||e===95||e===36}function Vl(e){return Bl(e)||e>=48&&e<=57}function Y(e,t){let n=e.length;for(;t<n;){let r=Hl(e,t,n);if(r==null)break;t=r}return t}function Hl(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 Ul(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 Wl(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 Gl(e,t,n){for(let r=0;r<n.length;r++)if(e.charCodeAt(t+r)!==n.charCodeAt(r))return!1;return!0}function Kl(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=Ul(e,r,i);return o-1-a!=10||!Gl(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 Jl(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,Ul(e,r,i)),e.charCodeAt(r)===59&&r++,r=Y(e,r),e.slice(r,n))}function X(e,t){if(!Bl(e.charCodeAt(t)))return null;let n=t+1;for(;n<e.length&&Vl(e.charCodeAt(n));)n++;return{name:e.slice(t,n),end:n}}function Yl(e,t,n){if(!Gl(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&&Vl(r)||i!==-1&&Vl(i))}function Xl(e,t,n){return e===0&&t===0&&n===0}function Zl(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?Xl(t.paren,t.brace,t.bracket)?-1:(t.brace=Math.max(0,t.brace-1),null):e===91?(t.bracket++,null):e===93?Xl(t.paren,t.brace,t.bracket)?-1:(t.bracket=Math.max(0,t.bracket-1),null):e===44&&Xl(t.paren,t.brace,t.bracket)?-1:null}function Ql(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(Zl(e.charCodeAt(r),i)===-1)return r;r++}return r}function $l(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=Ql(e,c,r-1)),s}function eu(e,t,n){let r=e.charCodeAt(t),i=Wl(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=eu(e,a,n);continue}if(t===46&&e.charCodeAt(a+1)===46&&e.charCodeAt(a+2)===46){a=tu(e,a,n);continue}a=$l(e,a,r,i,n)}return i}function tu(e,t,n){t+=3,t=Y(e,t);let r=X(e,t);return r?(n.add(r.name),r.end):t}function nu(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=eu(e,n,t);continue}if(r===46&&e.charCodeAt(n+1)===46&&e.charCodeAt(n+2)===46){n=tu(e,n,t);continue}let i=X(e,n);if(i){t.add(i.name),n=i.end;continue}n++}return t}function ru(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 iu(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 au(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]&&iu(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 ou(e,t){return t<=0||e.charCodeAt(t-1)!==46?!1:t<2||e.charCodeAt(t-2)!==46}function su(e,t,n,r,i){let a=t;for(;a<n;){let t=U(e,a,n);if(t!==-1){a=t;continue}if(!Bl(e.charCodeAt(a))){a++;continue}let o=X(e,a);if(o==null){a++;continue}if(ou(e,a)){a=o.end;continue}if(hu(e,a,o.end)){a=o.end;continue}r.has(o.name)||i.add(o.name),a=o.end}}function cu(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=Ql(e,r,i);su(e,r+1,o,t,n),r=o;continue}r++}}function lu(e,t,n,r){let i=/* @__PURE__ */ new Set([...nu(t),...ru(e),...n,...Rl,...zl]);r!=null&&r!==``&&i.add(r);let a=/* @__PURE__ */ new Set;return su(e,0,e.length,i,a),cu(t,i,a),[...a]}function uu(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(!Bl(e.charCodeAt(i))){i++;continue}let c=X(e,i);if(c==null){i++;continue}c.name===t&&!ou(e,i)&&!hu(e,i,c.end)&&(r+=e.slice(a,i)+n,a=c.end),i=c.end}return r+e.slice(a)}function du(e){return e===32||e===9||e===10||e===13||e===65279}function fu(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(du(e.charCodeAt(t-1))){t--;continue}let n=fu(e,t);if(n==null)break;t=n}return t}function Q(e,t,n){let r=t-n.length;return r<0||!Yl(e,r,n)?null:r}const pu=/* @__PURE__ */ new Set([40,91,44,61,58,63,46,43,45,42,47,37,38,124,94,33,126,60,62]);function mu(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?!pu.has(i):!1}function hu(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 gu(e,t,n){if(t<=0||e.charCodeAt(t-1)!==61)return null;let r=Z(e,t-1),i=r;for(;i>0&&Vl(e.charCodeAt(i-1));)i--;if(i>=r||!Bl(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 _u(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=gu(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 vu(e,t,n,r){if(!Yl(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=Wl(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=Wl(e,n,123,125)-1;if(!Kl(e,n,c))return{action:null,nextI:n+1};let l=i!=null&&mu(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 yu(e,t,n,r){let i,a;if(e.charCodeAt(n)===40)i=Wl(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=Wl(e,o,123,125)-1;return Kl(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 bu(e,t,n){if(!Yl(e,t,`async`)&&!Yl(e,t,`function`))return null;let r=t,i=t,a=!1;Yl(e,i,`async`)&&(a=!0,i=Y(e,i+5));let o=vu(e,r,i,a);if(o!=null)return o.action!=null&&n.push(o.action),o.nextI;if(!a)return null;let s=yu(e,r,i,!0);return s==null?null:(s.action!=null&&n.push(s.action),s.nextI)}function xu(e,t,n){let r=e.charCodeAt(t);if(r===39||r===34||r===96)return Ul(e,t,r);if(r===47&&(e.charCodeAt(t+1)===47||e.charCodeAt(t+1)===42))return Y(e,t);let i=bu(e,t,n);if(i!=null)return i;let a=yu(e,t,t,!1);return a==null?t+1:(a.action!=null&&n.push(a.action),a.nextI)}function Su(e){let t=[],n=e.length,r=0;for(;r<n;)r=xu(e,r,t);return t}function Cu(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 wu(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 Tu(e,t){let n=Su(e);if(n.length===0)return null;let r=au(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=Jl(o,e.bodyOpen,e.bodyClose),f=e.kind===`expression`&&e.name!=null?e.name:null,p=lu(d,e.paramsRaw,r,f),m=f==null?d:uu(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}=_u(o,e.start),{replacement:te,rewrittenExport:ne}=Cu(e,_,t,y,ee);wu(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&&!Ll(o)?d:``}${o}\n\n${s.join(`
|
|
89
|
-
`)}\n`,actionNames:i,rewrittenExportNames:a}}const
|
|
90
|
-
`)},\n])`;return t.replace(
|
|
87
|
+
);`}function Il(e,t){let n=[],r=/* @__PURE__ */ new Set;e.namespaceBinding!=null&&(r.add(`createClientModuleProxy`),n.push(Pl(e.namespaceBinding,t))),e.defaultBinding!=null&&(r.add(`registerClientReference`),n.push(Fl(e.defaultBinding,t,`default`)));for(let i of e.named)i.typeOnly||(r.add(`registerClientReference`),n.push(Fl(i.local,t,i.imported)));return n.length===0?{code:``,helpers:[]}:{code:n.join(`
|
|
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 Du=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,Ou=/import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,ku=/import\s+(\w+)\s*,\s*\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/g,Au=/defineMdxComponents\s*\(\s*\{([\s\S]*?)\}\s*\)/;function ju(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 Mu(e){let t=/* @__PURE__ */ new Map;for(let n of e.matchAll(ku))t.set(n[1],n[3]),ju(n[3],n[2],t);for(let n of e.matchAll(Du))t.set(n[1],n[2]);for(let n of e.matchAll(Ou))ju(n[2],n[1],t);return t}function Nu(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 Pu(e){try{return z(E.readFileSync(e,`utf-8`)).topLevelUseClient}catch{return!1}}function Fu(e){let{code:t,id:n,projectRoot:r,resolvedAlias:i}=e;if(!t.includes(`defineMdxComponents`)||t.includes(`__RARI_MDX_RESOLVED__`))return null;let a=Au.exec(t);if(!a)return null;let o=Mu(t),s=Nu(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=fe(a,n,i),c=Wt(s,r),l=Pu(s);return` { name: ${JSON.stringify(e)}, component: ${t}, id: ${JSON.stringify(c)}, client: ${l} }`}).join(`,
|
|
90
|
+
`)},\n])`;return t.replace(Au,c)}const Iu=/forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/,Lu=/\.[cm]?[jt]sx?$/,Ru=/['"]use memo['"]/;function zu(e){return{...e===!0?{}:e,target:`19`}}function Bu(e,t){return t.compilationMode===`annotation`?Ru.test(e):Iu.test(e)}function Vu(e){if(e.startsWith(`\0`)||e.includes(`virtual:`))return!1;let t=oe(e);return/\.d\.[cm]?ts$/.test(t)||t.includes(`/dist/`)?!1:Lu.test(t)&&!t.includes(`/node_modules/`)}const Hu=/\.[jt]sx$/;function Uu(e,t=`app`){let n=zu(e),r,i=!0,a=!1,o=!1,c=async e=>{if(r)return r;try{return r=await import(`oxc-transform-react`),r}catch(t){let n=s(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 c(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,s){if(!Vu(s))return null;let l=oe(s);if(t===`library`&&!Hu.test(l)||Wn(e)||t===`app`&&this.environment.config.consumer===`server`)return null;let{transform:u}=r??await c(e=>this.error(e)),d=Bu(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 Wu=/\.[cm]?[jt]sx?$/,Gu=[/node_modules/,/\/dist\//];function Ku(){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`&&
|
|
778
|
+
`:null}},{name:`rari:react-refresh-wrapper`,apply:`serve`,applyToEnvironment(e){return e.config.consumer===`client`&&Pe({cwd:process.cwd(),include:[Wu],exclude:Gu,jsxImportSource:`react`,reactRefreshHost:``})}}]}let qu;async function Ju(){return qu??=(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}`)}})(),qu}async function Yu(e){let t=await import(
|
|
779
779
|
/* @vite-ignore */
|
|
780
|
-
e);return u(t)?t:{}}function
|
|
780
|
+
e);return u(t)?t:{}}function Xu(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 Zu(t,n){try{Xu(await t(),n)}catch(t){if(e(t)){n.notFound=!0;return}throw t}}async function Qu(e,t,n,r){let i=e.getData;typeof i==`function`&&await Zu(async()=>i({params:t,searchParams:n}),r)}async function $u(e,t,n,r){let i=e.getServerSideProps;typeof i==`function`&&await Zu(async()=>i({params:t,searchParams:n}),r)}async function ed(e,t,n){let r=e.getStaticProps;typeof r==`function`&&await Zu(async()=>r({params:t}),n)}
|
|
781
781
|
/* v8 ignore start - requires dynamic imports, better tested in integration/e2e */
|
|
782
|
-
async function
|
|
782
|
+
async function td(e,t,n){try{let r=await Yu(e),i={props:{}};return await Qu(r,t,n,i),await $u(r,t,n,i),await ed(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 nd(e,t,n){try{let r=await Yu(e);if(typeof r.generateMetadata==`function`){let e=await r.generateMetadata({params:t,searchParams:n});if(u(e))return e}return u(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 rd(e){try{let t=await Ue(e);return t==null?[]:p(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 id(e){try{let t=await Yu(e);return!!(t.getData??t.getServerSideProps??t.getStaticProps??t.generateMetadata??t.generateStaticParams)}catch{return!1}}
|
|
791
791
|
/* v8 ignore stop */
|
|
792
|
-
const
|
|
792
|
+
const ad=/* @__PURE__ */ new Map;
|
|
793
793
|
/* v8 ignore start - depends on extractServerProps which requires dynamic imports */
|
|
794
|
-
async function
|
|
794
|
+
async function od(e,t,n,r=6e4){let i=`${e}:${JSON.stringify(t)}:${JSON.stringify(n)}`,a=ad.get(i);if(a&&Date.now()-a.timestamp<r)return a.result;let o=await td(e,t,n);return ad.set(i,{result:o,timestamp:Date.now()}),o}
|
|
795
795
|
/* v8 ignore stop */
|
|
796
|
-
function
|
|
796
|
+
function sd(){ad.clear()}
|
|
797
797
|
/* v8 ignore start - cache clearing logic, difficult to test without populating cache via dynamic imports */
|
|
798
|
-
function
|
|
798
|
+
function cd(e){for(let t of ad.keys())t.startsWith(e)&&ad.delete(t)}
|
|
799
799
|
/* v8 ignore stop */
|
|
800
|
-
const
|
|
800
|
+
const ld=/\.(?: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 ud(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 dd(e){let t=e.slice(e.lastIndexOf(`/`)+1);return ld.test(t)}function $(e,t){return e===t||e.startsWith(`${t}/`)}const fd=/import\s+type\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,pd=/import\s+type\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,md=/import\s+type\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,hd=/import\s+(\{[^}]+\})\s+from\s+["']\.\.?\/([^"']+)["'];?/g,gd=/import\s+(\*\s+as\s+\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,_d=/import\s+(\w+)\s+from\s+["']\.\.?\/([^"']+)["'];?/g,vd=/import\s+["']\.\.?\/([^"']+)["'];?/g,yd=/export\s+default\s+(?:async\s+)?function\s+(\w+)/,bd=/^['"]use client['"];?\s*$/gm,xd=/^[./@~#]/;function Sd(e,t){for(let n of Object.keys(t))if(e===n||e.startsWith(`${n}/`))return!0;return!1}function Cd(e){let t=r(e);return t===`ENOENT`||t===`ERR_PACKAGE_PATH_NOT_EXPORTED`||t===`ERR_MODULE_NOT_FOUND`}function wd(e){return e===`react`||e instanceof RegExp&&e.source===`^react$`&&e.flags===``}const Td=/import\s+\{[^}]*\}\s+from\s+['"]react['"]/,Ed=/import\s+[^,\s]+\s*,\s*\{[^}]*\}\s+from\s+['"]react['"]/,Dd=/import React(,\s*\{([^}]*)\})?\s+from\s+['"]react['"];?/,Od=/from(\s*)(['"])(?:\.\/vendor\/react-flight-client\/index|rari\/runtime\/vendor\/react-flight-client\/index)\.mjs\2/g,kd=/\bJSX\b/,Ad=/\{([^}]*)\}/,jd={remotePatterns:[],localPatterns:[],deviceSizes:g,imageSizes:m,formats:h,qualityAllowlist:_,minimumCacheTTL:60};function Md(e){return[{pathname:`/${C(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,i=A(n),a=O.dirname(i),o=[O.join(a,`runtime`,e),O.join(a,`../runtime`,e)];for(let t of o)try{let n=await E.promises.readFile(t,`utf-8`);return t.endsWith(`.ts`)&&(n=n.replace(fd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(pd,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(md,(e,t,n)=>`import type ${t} from "rari/${n}";`),n=n.replace(hd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(gd,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(_d,(e,t,n)=>`import ${t} from "rari/${n}";`),n=n.replace(vd,(e,t)=>`import "rari/${t}";`)),Pd.set(e,n),n}catch(e){let n=r(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 a=O.join(e,`src`),{getBinaryPath:o}=await import(`./platform.mjs`),s=o(),l=De(s,[`scan-images`,`--src`,a],{encoding:`utf8`,cwd:e,shell:!1,timeout:6e4});if(l.error)throw Error(`Failed to scan for image usage: ${l.error.message}`);if(l.signal)throw Error(`Failed to scan for image usage: process terminated by signal ${l.signal}`);if(l.status!==0)throw Error(`Failed to scan for image usage: ${l.stderr||l.stdout||`exit code ${l.status}`}`);let u;try{u={images:i(l.stdout,`images`)??[]}}catch(e){let t=e instanceof SyntaxError?e.message:c(e,String(e)),n=(l.stdout||l.stderr||`(empty)`).slice(0,500);throw Error(`Failed to parse image scanner output as JSON: ${t}. Scanner output: ${n}`,{cause:e})}let d=C(n),f=(()=>{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(f)===`client`?O.dirname(f):f,m=w(O.relative(e,f))||`dist/client`,h={...jd,...t.images,assetsDir:d,outDir:m,localPatterns:Nd(t.images?.localPatterns,d,t.images?.includeBundledAssets!==!1),preoptimizeManifest:u.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){Cd(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){return e.includes(`import React`)||e.includes(`from "react"`)||e.includes(`from 'react'`)?e:`import * as React from 'react';\n${e}`}function Xd(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 Zd(e,t,n,r){return!e&&!t||n===``||$(r,`/api`)||$(r,`/rsc`)}function Qd(e){let{browserClientPath:t,edgeClientPath:n}=Xd(e),r=zt(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 $d(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 ef(e,t){if(!e.endsWith(`.mjs`)||!E.existsSync(e))return null;try{return $d(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 tf=/* @__PURE__ */ new Map([[`virtual:app-router-provider.tsx`,`AppRouterProvider.mjs`],[`virtual:client-router.tsx`,`ClientRouter.mjs`]]);async function nf(e,t){if(e===`virtual:rari-mdx-components.ts`)return t.buildMdxRegistryModule();if(e===`virtual:rari-entry-client.ts`)return gf(t.resolveProjectRoot(),t.resolvedAlias,t.moduleAnalysisCache,t.getKnownClientComponentPaths);if(e===`react-server-dom-rari/server`)return Wd();let n=tf.get(e);if(n!=null)return Jd(n);if(e===`virtual:error-boundary-wrapper.tsx`)return Yd(Jd(`ErrorBoundaryWrapper.mjs`));if(e===`virtual:rsc-integration.ts`)return(await Hd()).replace(Od,(e,t,n)=>`from${t}${n}virtual:react-flight-client.ts${n}`);if(e===`virtual:react-flight-client.ts`)return Qd(t.environmentMode===`dev`?`development`:`production`)}function rf(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){r(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error resolving server component:`,e,t)}return null}function af(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 of(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`)&&!dd(n)}function sf(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 cf(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 lf=/* @__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 uf(e){return Ss(e)?`virtual:rari-mdx-components.ts`:lf.get(e)??null}function df(e){for(let t of e)if(E.existsSync(t))return t;return null}function ff(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=df([O.join(n,`runtime`),O.join(n,`../runtime`)]);if(r!=null){let t=df([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 df([O.join(n,e),O.join(n,`../dist`,O.basename(e))])}function pf(e,t){let n=!1,i=``;try{if(!t.get(e).hasDefaultExport){let r=t.getSource(e).match(x);r&&(n=!0,i=r[1])}}catch(t){r(t)!==`ENOENT`&&console.warn(`[rari] Unexpected error reading component for export detection:`,e,t)}return{exportName:n?i:`default`,displayName:n?i:O.basename(e,O.extname(e))}}function mf(e,t){let n=w(O.relative(k.cwd(),e)),r=n.replace(S,``),i=n.startsWith(`..`)?w(e):n,{exportName:a,displayName:o}=pf(e,t),s=w(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 hf(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 gf(e,t,n,r){let i=jr(wr(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=>mf(e,n)).join(`,
|
|
879
|
+
`),c=hf(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=Kr(e,t);return Ud(c.imports,l,u)}function _f(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 vf(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 yf(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 bf=/* @__PURE__ */ new WeakMap;function xf(e){let t=!1;for(let n=e.length-1;n>=0;n--){let r=e[n];if(bf.has(r)){if(bf.get(r)===e){t=!0;continue}e.splice(n,1)}}if(t)return;let n={debugName:`rari-vendor`,name(t){return af(t,e)}};bf.set(n,e),e.push(n)}function Sf(e){e.build??={},e.build.rolldownOptions??={},e.build.rolldownOptions.input={main:Nr},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??=[],xf(e.codeSplitting.groups))}function Cf(e){e.environments.client.build??={},e.environments.client.build.rolldownOptions??={},e.environments.client.build.rolldownOptions.input={main:Nr},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 wf(e){let t=[];return a(e.alias)?t=e.alias:u(e.alias)&&(t=l(e.alias)),t.map(e=>e.find===`react`?{find:/^react$/,replacement:e.replacement}:e)}function Tf(e,t,n){if((u(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 Ef(e){return e}function Df(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 Mr,i=null,a=null,o=null,s={},l=`assets`,u=O.join(k.cwd(),`dist`),d=null;function p(){d=null}function m(){return d!=null&&d!==``||(d=Os(Ds({projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),mdxOptions:e.mdx,alias:s,cache:r}))),d}function h(e){return t.get(H(e))}function g(t){let n=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),r=w(O.relative(n,t));return r.startsWith(`..`)||O.isAbsolute(r)?w(t):r}function _(e,n){t.set(H(e),n)}function v(e){Ar(t,e)}function y(e){n.add(H(e))}function ee(e){return n.has(H(e))}function te(e){n.delete(e);try{n.delete(E.realpathSync(e))}catch{n.delete(O.resolve(e))}}function ne(){let e=new Set(n);if(i)for(let t of i.getClientComponentPaths())e.add(t);return e}function b(e){if(e.includes(`node_modules`)||Vd(e))return!1;let t=H(e);try{return El(t,r.get(e))}catch{return!1}}function x(e,t){try{let n=new Set(Vn(e));return(t?.hasDefaultExport??Jn(e))&&n.add(`default`),[...n]}catch{return[]}}function re(e){return`${e}
|
|
893
893
|
|
|
894
894
|
if (import.meta.hot) {
|
|
895
895
|
import.meta.hot.accept(() => {
|
|
896
896
|
});
|
|
897
|
-
}`}function ae(e,t){let n=
|
|
897
|
+
}`}function ae(e,t){let n=yd.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=br(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 oe(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 C(t,n,r){let i=Kt(n,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd()),a=Eu(t,i),o=a?.code??t;if(!r.topLevelUseServer)return a==null?t:re(o);let s=x(o,r);if(s.length===0&&a==null)return qn(o,`use server`);let c=JSON.stringify(i);Rl(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=ae(o,c);else if(a?.rewrittenExportNames.includes(e))continue;else o=
|
|
907
|
+
`;for(let e of s)if(e==="default")o=ae(o,c);else if(a?.rewrittenExportNames.includes(e))continue;else o=oe(o,e,c);return o=qn(o,`use server`),re(o)}function pe(e,t,n,r){let i=x(e,n);if(i.length===0)return``;let a=Kt(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 me(t,n,r){let i=e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),a=b(n);if(r.topLevelUseServer)return pe(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=x(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 he(e,t,n){return!n.topLevelUseClient||x(e,n).length===0?e:e.replace(bd,``)}let T=!1;async function ge(){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 _e=null;async function ve(e){return await ge()?!0:(_e??=(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 ge())return!0;n=Math.min(n*2,500)}return!1}finally{_e=null}})(),_e)}function ye(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 be(e,t){let n=e,r=[],i=/* @__PURE__ */ new Set;for(let e of Fn(n)){if(e.typeOnly||e.sideEffectOnly||!xd.test(e.source)&&!Sd(e.source,s))continue;let n=fe(e.source,t,s);if(!ye(n))continue;_(n,`client`),y(n);let a=Il(e,g(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=Nl(n,`react-server-dom-rari/server`,[...i])),n}function xe(e,t){for(let n of t.importSources){if(!xd.test(n)&&!Sd(n,s))continue;let t=fe(n,e,s);E.existsSync(t)&&(r.get(t).topLevelUseServer||(_(t,`client`),y(t)))}}function Se(e){if(e.includes(`Suspense`))return e;let t=Dd.exec(e);return t?t[1]&&!t[2].includes(`Suspense`)?e.replace(t[0],t[0].replace(Ad,`{ Suspense, $1 }`)):t[1]?e:e.replace(t[0],`import React, { Suspense } from 'react';`):e}function Ce(e,t,n){return e&&!t&&(n===`rsc`||n===`ssr`)}function we(e,t,n){let r=t.includes(`entry-client`),i=[],a=/* @__PURE__ */ new Set,o=!1;for(let c of Fn(e)){if(c.typeOnly||c.sideEffectOnly||!xd.test(c.source)&&!Sd(c.source,s))continue;let e=fe(c.source,t,s),l=ye(e);if(l&&(_(e,`client`),y(e)),!Ce(l,r,n))continue;let u=Il(c,g(e));if(u.code!==``){for(let e of u.helpers)a.add(e);i.push({start:c.start,end:c.end,replacement:u.code}),o=!0}}return i.length===0?null:{replacements:i,clientRefHelpers:a,needsReactImport:o}}function Te(e,t,n){let r=we(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=Nl(i,`react-server-dom-rari/server`,[...r.clientRefHelpers]));let a=i.includes(`import React`)||Td.test(i)||Ed.test(i);r.needsReactImport&&!a&&(i=`import React from 'react';\n${i}`),i=Se(i);let o=k.env.NODE_ENV!==`production`;return(i.includes(`</`)||i.includes(`/>`)||kd.test(i))&&o&&_(t,`client`),i}function De(e,t,n,r){if(r===`rsc`||r===`ssr`)return be(C(e,t,n),t);let i=me(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 m=async()=>{try{let a=new
|
|
920
|
+
${i}`}function D(e,t){if(t.startsWith(`\0`)||t.includes(`virtual:`))return z(e);try{return r.get(t)}catch{return z(e)}}async function A(t,n){if(!e.experimental?.useCache&&!e.experimental?.useCacheRemote)return{code:t,wasTransformed:!1};let r=(await Ju())(t,n);return r==null||r===``?{code:t,wasTransformed:!1}:{code:r,wasTransformed:!0}}function ke(e,t,n,r){if(n.topLevelUseServer)return _(t,`server`),r===`rsc`?C(e,t,n):me(e,t,n);if(n.topLevelUseClient)return _(t,`client`),y(t),xe(t,n),he(e,t,n);if(r!==`rsc`&&r!==`ssr`&&(h(t)===`client`||ee(t)))return he(e,t,n);if(b(t))return _(t,`server`),De(e,t,n,r);let i=h(t);return i===`server`?r===`rsc`||r===`ssr`?be(C(e,t,n),t):me(e,t,n):i===`client`?he(e,t,n):(_(t,`unknown`),Te(e,t,r))}let Ae={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=wf(r),o=new Set(a.map(e=>String(e.find))),s=a.some(e=>wd(e.find));try{r.alias=[...a,...qd(o,s)]}catch(e){Cd(e)||console.warn(`[rari] Unexpected error configuring React aliases:`,e)}if(_f(e),e.builder??={},e.builder.sharedPlugins=!0,e.builder.sharedConfigBuild=!1,vf(e),t===`build`)for(let t of[`rsc`,`ssr`,`client`]){let n=e.environments[t];n.build!=null&&(n.build.rolldownOptions??={})}return yf(e),t===`build`&&Sf(e),Cf(e),e},async buildStart(){if(Lr(),e.experimental?.useCache||e.experimental?.useCacheRemote)try{await Ju()}catch(e){this.error(e instanceof Error?e:Error(String(e)))}},configResolved(e){let t=Ut(e);l=t.assetsDir,u=t.outDir,Object.assign(s,Ht(e))},async transform(t,n){if(n.endsWith(`.mdx`)&&p(),/\.(?:tsx?|jsx?|mts|mjs)$/.test(n)&&t.includes(`defineMdxComponents`)){let r=Fu({code:t,id:n,projectRoot:e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),resolvedAlias:s});if(r!=null&&r!==``)return oi(r,t,n)}if(!S.test(n))return null;let r=t,i=await A(t,n);t=i.code;let a=ke(t,n,D(t,n),this.environment.name);return a==null?i.wasTransformed?oi(t,r,n):null:oi(a,r,n)},async configureServer(t){let n=O.resolve(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd()),d=O.join(n,`src`);await Gd(n,e,l,u);let p=/* @__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=se(e.url??``);if(!p.has(r)){n();return}let i=p.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 m=async()=>{try{let a=new Dl(n,{outDir:u,rscDir:`server`,manifestPath:`server/manifest.json`,serverConfigPath:`server/config.json`,alias:s,assetsDir:l,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 le({root:n,configFile:t.config.configFile,logLevel:`error`})),i=a,o??=new Oo(a,M()),E.existsSync(d)){let e=jl(d,a,Object.values(s));e.serverComponentPaths.length>0&&t.ws.send({type:`custom`,event:`rari:server-components-registry`,data:{serverComponents:e.serverComponentPaths}})}let f=await a.getTransformedComponentsForDevelopment(),p=`http://localhost:${M()}`;await Promise.all(f.map(async e=>{try{if(e.id.startsWith(`app/`)||e.isAction)return;let t=await fetch(`${p}/_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}:`,c(t,String(t)))}}))}catch(e){console.error(`[rari] Runtime: Component discovery failed:`,c(e,String(e)))}},h=async()=>{try{let e=`http://localhost:${M()}`,t=ne();await Promise.all([...t].map(async t=>{let n=O.relative(k.cwd(),t),r=O.basename(t).replace(ie,``);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)}},g=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(` ${c(e,String(e))}`),console.error(i());return}let l=M(),u=k.env.NODE_ENV===`production`?`production`:`development`,d=t.config.server.port,f=e.origin?.trim().replace(/\/+$/,``),p=k.env.RARI_ORIGIN?.trim().replace(/\/+$/,``),g=Wr(n,s),_=[`--mode`,u,`--port`,l.toString(),`--host`,`127.0.0.1`];a=Ee(o,_,{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(),...g.length>0?{RARI_DEV_LAYOUT_CSS:g.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 ve(1e4)?(await m(),await h()):console.error(`Server failed to become ready for component registration`)},_=async e=>{try{if(!b(e))return;i??await m();let t=i;if(t==null)return;let n=r.getSource(e);t.addServerComponent(e,n);let a=wo(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}:`,c(t,String(t)))}}))}catch(t){console.error(`[rari] Targeted HMR failed for`,`${e}:`,c(t,String(t)))}};g().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=se(a),s=r!=null&&r!==``&&r.includes(`text/x-component`);if(Zd(s,of(i,r,o),a,o)){n();return}if(!T&&!await ve(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=sf(e.headers,c),r=i!==`GET`&&i!==`HEAD`?await ud(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 cf(o,t,i)}catch(e){Tf(e,t,s)}})()}),t.watcher.on(`change`,e=>{(async()=>{S.test(e)&&(v(e),te(e),r.invalidate(e)),S.test(e)&&ce(e,d)&&b(e)&&(t.ws.send({type:`custom`,event:`rari:register-server-component`,data:{filePath:e}}),await _(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=f(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 _(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:c(e,String(e))}))}})()}),t.httpServer?.on(`close`,()=>{if(de(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=uf(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=ff(e,t);if(n!=null)return n}return rf(e,b)},async load(t){if(S.test(t)&&this.environment.name===`client`)try{let e=r.get(t);if(e.topLevelUseServer)return me(r.getSource(t),t,e)}catch{}let n=await nf(t,{buildMdxRegistryModule:m,resolveProjectRoot:()=>e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd(),resolvedAlias:s,moduleAnalysisCache:r,getKnownClientComponentPaths:ne,environmentMode:this.environment.mode});return n===void 0?ef(t,e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd())??void 0:n},async handleHotUpdate({file:e,server:t}){if(ue(),e.endsWith(`.mdx`)&&p(),!S.test(e))return;if(v(e),te(e),r.invalidate(e),p(),e.includes(`/dist/`)||e.includes(`\\dist\\`))return[];let n=o?.detectComponentType(e)??`unknown`,i=e.includes(`/app/`)||e.includes(`\\app\\`),a=(e,t)=>e.endsWith(`${t}.tsx`)||e.endsWith(`${t}.jsx`)||e.endsWith(`${t}.ts`)||e.endsWith(`${t}.js`),s=[`page`,`layout`,`template`,`loading`,`error`,`not-found`].some(t=>a(e,t));if(i&&s){if(o)try{await o.rebuildAndNotifyNow(e,t)}catch(t){console.error(`[rari] HMR: Failed to rebuild app router file`,`${e}:`,c(t,String(t)))}return}if(n!==`client`&&n===`server`)return o&&await o.handleServerComponentUpdate(e,t),[]},generateBundle(e,t){if(this.environment.name!==`client`)return;let n=Jr(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,l,u)}},je=Ml({...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}),Me={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}}},j=[...Ku()];return e.compiler!=null&&e.compiler!==!1&&j.push(Uu(e.compiler)),j.push(Ae,xs(),bo(),Me,je,yi(e.projectRoot!=null&&e.projectRoot!==``?e.projectRoot:k.cwd())),e.proxy!==!1&&j.push(ze(e.proxy??{})),e.router!==!1&&j.push(Mt(e.router??{})),Fe(j)}function Of(e){return{...e,plugins:[Df(),...e.plugins??[]]}}export{t as ApiResponse,sd as clearPropsCache,cd as clearPropsCacheForComponent,Of as defineRariConfig,Ef as defineRariOptions,nd as extractMetadata,td as extractServerProps,od as extractServerPropsWithCache,rd as extractStaticParams,vt as generateAppRouteManifest,id as hasServerSideDataFetching,Df as rari,ze as rariProxy,Mt as rariRouter};
|