@uniweb/runtime 0.9.10 → 0.11.0
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/app/_importmap/@uniweb-core.js +1 -1
- package/dist/app/_importmap/@uniweb-runtime-default-fetcher.js +1 -0
- package/dist/app/_importmap/@uniweb-runtime-foundation-loader.js +1 -0
- package/dist/app/_importmap/@uniweb-runtime-provider.js +1 -0
- package/dist/app/_importmap/@uniweb-runtime-setup.js +1 -0
- package/dist/app/_importmap/@uniweb-theming.js +53 -0
- package/dist/app/_importmap/react-dom-client.js +1 -0
- package/dist/app/_importmap/react-router-dom.js +1 -0
- package/dist/app/assets/_importmap_react-router-dom-CLbp1nUY.js +3 -0
- package/dist/app/assets/client-CQjOKqaN.js +9 -0
- package/dist/app/assets/index-BjwnhO24.js +1 -0
- package/dist/app/assets/index-C_CSAb0x.js +59 -0
- package/dist/app/assets/index-n0uF7vTr.js +74 -0
- package/dist/app/assets/normalize-DbApPPeG.js +1 -0
- package/dist/app/assets/setup-BeQi33In.js +1 -0
- package/dist/app/assets/shade-generator-BBzWo1IN.js +1 -0
- package/dist/app/index.html +21 -3
- package/dist/app/manifest.json +17 -4
- package/package.json +2 -2
- package/dist/app/assets/core-BI26Dvfl.js +0 -132
- package/dist/app/assets/index-Dfiy0YWz.js +0 -63
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as
|
|
1
|
+
import{B as g,D as f,a as p,E as d,F as _,O as m,P as S,U as b,W as V,c as v,b as y,d as C,g as x,i as F,e as L,f as O,n as k,h as w,r as P,j as T,k as U,v as j}from"../assets/index-C_CSAb0x.js";import{H as E,G as R,I as $,J as D,K as I,O as N,F as W}from"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";import"../assets/normalize-DbApPPeG.js";const n=[50,100,200,300,400,500,600,700,800,900,950],r=["light","medium","dark"];class i{constructor(e={}){this._data=e,this._palettes=e.palettes||e.colors||{},this._rawColors=e.colors||{},this._contexts=e.contexts||{},this._fonts=e.fonts||{},this._appearance=e.appearance||{default:"light"},this._foundationVars=e.foundationVars||{},this._css=e.css||null,Object.seal(this)}get css(){return this._css}get data(){return this._data}getColor(e,t=500){const s=this._palettes[e];return s&&s[t]||null}getPalette(e){return this._palettes[e]||null}getPaletteNames(){return Object.keys(this._palettes)}hasPalette(e){return e in this._palettes}getColorVar(e,t=500){return`var(--${e}-${t})`}getContextClass(e){return r.includes(e)?`context-${e}`:(console.warn(`Invalid context: ${e}. Using 'light'.`),"context-light")}isValidContext(e){return r.includes(e)}getValidContexts(){return[...r]}getAppearance(){return{default:this._appearance.default||"light",allowToggle:this._appearance.allowToggle||!1,respectSystemPreference:this._appearance.respectSystemPreference??!0,schemes:this._appearance.schemes||["light"]}}getDefaultScheme(){return this._appearance.default||"light"}supportsScheme(e){return(this._appearance.schemes||["light"]).includes(e)}hasSchemeToggle(){return this._appearance.allowToggle===!0}getSchemeClass(e){return`scheme-${e}`}getFonts(){return{...this._fonts}}getFont(e){return this._fonts[e]||null}getFontVar(e){return`var(--font-${e})`}getFoundationVar(e){const t=this._foundationVars[e];return t?typeof t=="object"?t.default:t:null}getFoundationVars(){const e={};for(const[t,s]of Object.entries(this._foundationVars))e[t]=typeof s=="object"?s.default:s;return e}getFoundationVarRef(e){return`var(--${e})`}getShadeLevels(){return[...n]}hasCustomization(){return Object.keys(this._palettes).length>0||Object.keys(this._contexts).length>0||Object.keys(this._fonts).length>0}toJSON(){return{palettes:this._palettes,colors:this._rawColors,contexts:this._contexts,fonts:this._fonts,appearance:this._appearance,foundationVars:this._foundationVars}}}function c(a={}){return!!(a.allowToggle||a.default==="dark"||a.default==="system"||a.schemes?.includes("dark"))}export{g as Block,f as DATA_DIR,p as DATA_URL_PREFIX,E as DataStore,d as EntityStore,_ as FetcherDispatcher,m as ObservableState,S as Page,i as Theme,b as Uniweb,V as Website,v as collectionDataUrl,y as collectionNameFromUrl,C as createUniweb,R as deriveCacheKey,$ as evaluateWhere,x as getUniweb,c as hasDarkScheme,F as isDataUrl,L as isRichSchema,O as isWildcardLanguages,D as listRequestStyleNames,I as matchWhere,k as normalizeLanguageList,w as normalizeSchema,P as recordDataUrl,T as resolveDefaultLocale,U as resolvePublishableLocales,N as resolveRequestStyle,W as substitutePlaceholders,j as validateLanguageConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{O as L,F as D,G as I,K as V}from"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";const R=new Set(["where","limit","sort"]);function se({basePath:e="",config:t={},dev:n=!1}={}){const r=e&&e!=="/"?e.replace(/\/$/,""):"",a=typeof t?.baseUrl=="string"?t.baseUrl.replace(/\/$/,""):"",i=B(t?.headers),m=Q(t?.supports),y=t?.request&&typeof t.request=="object"?t.request:{},w=typeof y.style=="string"?y.style:null,p=L(w,{dev:n}),U=M(y.rename,p,{dev:n}),G=t?.envelope&&typeof t.envelope=="object"?t.envelope:null,z={...p.defaultEnvelope||{},...G||{}};return{cacheKey(s){const S=I(s),l={};for(const f of m)p.canPush.has(f)&&s[f]!==void 0&&(l[f]=s[f]);return Object.keys(l).length===0&&p.name==="json-body"?S:S+"::style="+p.name+"::"+JSON.stringify(l)},async resolve(s,S={}){if(!s)return{data:null};const{path:l,url:f,transform:J,body:j}=s;let d=(s.method||"GET").toUpperCase();d!=="GET"&&d!=="POST"&&(console.warn(`[default-fetcher] method "${s.method}" is not supported — falling back to GET.`),d="GET");let h,v;if(l)h=r&&l.startsWith("/")&&!l.startsWith("//")?r+l:l,v=!1;else if(f)h=ee(f)?f:te(a,f),v=!0;else return{data:[],error:"No path or url specified"};const P={signal:S.signal,method:d},b={};v&&i&&Object.assign(b,i);const C=new Set;if(v)for(const o of R)m.has(o)&&p.canPush.has(o)&&s[o]!==void 0&&s[o]!==null&&C.add(o);const O=C.size>0?p.encode(s,{method:d,pushCandidates:C,rename:U}):{queryParams:[],bodyMerge:null,pushed:new Set},K=O.pushed;if(O.queryParams.length>0&&d==="GET"&&(h=_(h,O.queryParams)),d==="POST"){const o=s.dynamicContext,k=j!=null&&o&&o.paramName?D(j,{[o.paramName]:o.paramValue},{encode:!1}):j,u=X(k,O.bodyMerge);u!==null&&(q(b,"Content-Type")||(b["Content-Type"]="application/json"),P.body=typeof u=="string"?u:JSON.stringify(u))}Object.keys(b).length&&(P.headers=b);try{const o=await fetch(h,P),u=(s.envelope&&typeof s.envelope=="object"?s.envelope:null)??z;if(!o.ok){let g;if(u.error)try{const H=await o.text(),A=ne(H);if(A!==void 0){const N=T(A,u.error);typeof N=="string"&&N.length&&(g=N)}}catch{}return{data:[],error:g??`HTTP ${o.status}: ${o.statusText}`}}const W=o.headers.get("content-type")||"";let c;if(W.includes("application/json"))c=await o.json();else{const g=await o.text();try{c=JSON.parse(g)}catch{c=g}}const F=!!s.dynamicContext,E=J||(F?u.item:u.collection);return E&&c!==null&&c!==void 0&&(c=T(c,E)),c=Y(c,s,K),{data:c??[]}}catch(o){return o?.name==="AbortError"?{data:[],error:"aborted"}:{data:[],error:o?.message||String(o)}}}}}function M(e,t,{dev:n}){if(!e||typeof e!="object"||Array.isArray(e))return null;const r={};for(const[a,i]of Object.entries(e))typeof i!="string"||i.length===0||(n&&!t.canPush.has(a)&&!x.has(a)&&(x.add(a),console.warn(`[default-fetcher] request.rename: operator "${a}" is not pushed by style "${t.name}" — rename has no effect. Known operators for this style: ${[...t.canPush].join(", ")||"(none)"}.`)),r[a]=i);return Object.keys(r).length?r:null}const x=new Set;function Q(e){const t=new Set;if(!Array.isArray(e))return t;for(const n of e)typeof n=="string"&&(R.has(n)?t.add(n):$.has(n)||($.add(n),console.warn(`[default-fetcher] supports: unknown operator "${n}" — ignored.`)));return t}const $=new Set;function _(e,t){if(!t||t.length===0)return e;const n=t.map(([a,i])=>encodeURIComponent(a)+"="+encodeURIComponent(i)),r=e.includes("?")?"&":"?";return e+r+n.join("&")}function X(e,t){return t?typeof e=="string"?e:{...e&&typeof e=="object"?e:{},...t}:e===void 0?null:e}function Y(e,t,n){if(!Array.isArray(e))return e;let r=e;return t.where&&!n.has("where")&&(r=V(t.where,r)),t.sort&&!n.has("sort")&&(r=Z(r,t.sort)),typeof t.limit=="number"&&t.limit>0&&!n.has("limit")&&(r=r.slice(0,t.limit)),r}function Z(e,t){const n=String(t).split(",").map(r=>{const[a,i="asc"]=r.trim().split(/\s+/);return{field:a,desc:i.toLowerCase()==="desc"}});return[...e].sort((r,a)=>{for(const{field:i,desc:m}of n){const y=T(r,i)??"",w=T(a,i)??"";if(y<w)return m?1:-1;if(y>w)return m?-1:1}return 0})}function B(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t={};for(const[n,r]of Object.entries(e))r!=null&&(t[n]=String(r));return Object.keys(t).length?t:null}function q(e,t){const n=t.toLowerCase();return Object.keys(e).some(r=>r.toLowerCase()===n)}function ee(e){return typeof e!="string"?!1:e.startsWith("//")?!0:/^[a-z][a-z0-9+.-]*:\/\//i.test(e)}function te(e,t){return e?t.startsWith("/")?e+t:e+"/"+t:t}function T(e,t){if(!e||!t)return e;let n=e;for(const r of t.split(".")){if(n==null)return;n=n[r]}return n}function ne(e){try{return JSON.parse(e)}catch{return}}export{se as createDefaultFetcher};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function s(n){return typeof n!="string"||!n||typeof window>"u"||!window.location||/^([a-z][a-z0-9+.-]*:)?\/\//i.test(n)?n:n.startsWith("/")?window.location.origin+n:n}async function d(n){if(n&&!document.querySelector(`link[rel="stylesheet"][href="${n}"]`))return new Promise(t=>{const o=document.createElement("link");o.rel="stylesheet",o.href=n,o.onload=()=>{console.log("[Runtime] Foundation CSS loaded"),t()},o.onerror=()=>{console.warn("[Runtime] Could not load foundation CSS from:",n),t()},document.head.appendChild(o)})}async function c(n){const t=typeof n=="string"?n:n.url,o=typeof n=="object"?n.cssUrl:t.replace(/[^/]+\.js$/,"assets/style.css"),e=s(t),a=o&&s(o);console.log(`[Runtime] Loading foundation from: ${e}`);try{const[,i]=await Promise.all([a?d(a):Promise.resolve(),import(e)]),l=Object.keys(i).filter(r=>r!=="default");return console.log("[Runtime] Foundation loaded. Available components:",l),i}catch(i){throw console.error("[Runtime] Failed to load foundation:",i),i}}async function f(n){if(!n?.length)return[];const t=await Promise.allSettled(n.map(e=>c(e))),o=[];for(let e=0;e<t.length;e++)t[e].status==="fulfilled"?(o.push(t[e].value),console.log(`[Runtime] Extension loaded: ${n[e]}`)):console.warn(`[Runtime] Extension failed to load: ${n[e]}`,t[e].reason);return o}export{f as loadExtensions,c as loadFoundation};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as i}from"../assets/jsx-runtime-0PlsXv6K.js";import{r as a,R}from"../assets/_importmap_react-CrAkajDz.js";import{p as j,a as P,P as A}from"../assets/setup-BeQi33In.js";import{u as T,a as C,b as B,B as M,R as W,c as I}from"../assets/_importmap_react-router-dom-CLbp1nUY.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";import"../assets/index-C_CSAb0x.js";import"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";import"../assets/normalize-DbApPPeG.js";import"./@uniweb-runtime-default-fetcher.js";import"./@uniweb-theming.js";const w="uniweb-theme";function N(){return typeof document>"u"?!1:document.getElementById(w)!==null}function F({css:e,children:t}){const n=a.useRef(null);return a.useEffect(()=>{if(!e||N())return;const r=document.createElement("style");return r.id=w,r.textContent=e,document.head.appendChild(r),n.current=r,()=>{n.current&&n.current.parentNode&&(n.current.parentNode.removeChild(n.current),n.current=null)}},[e]),a.useEffect(()=>{if(!e)return;const r=document.getElementById(w);r&&r.textContent!==e&&(r.textContent=e)},[e]),i.jsx(i.Fragment,{children:t})}const E=new Map;function v(e){return e===window?window.scrollY:e.scrollTop}function D(){const e=globalThis.uniweb.activeWebsite,t=e.activePage?.getLayoutName(),r=(t?e.getLayoutMeta(t):null)?.scroll??globalThis.uniweb.foundationConfig?.scroll??null;return r==="self"?null:r&&document.querySelector(r)||window}function q(e={}){const{enabled:t=!0,resetBlockStates:n=!0}=e,r=T(),s=C(),f=a.useRef(r.key),d=a.useRef(null),c=a.useRef(window),h=a.useCallback(()=>{const o=c.current;o&&E.set(f.current,v(o))},[]);a.useEffect(()=>{if(!t)return;const o=c.current;if(o)return o.addEventListener("scroll",h,{passive:!0}),()=>o.removeEventListener("scroll",h)},[r.key,t,h]),a.useLayoutEffect(()=>{s==="POP"?d.current=E.get(r.key)??null:d.current=null,f.current=r.key,c.current=t?D():null},[r.key,s,t]),a.useEffect(()=>{if(!t)return;const o=c.current;if(o){if(n){const l=globalThis.uniweb.activeWebsite.activePage;l&&typeof l.resetBlockStates=="function"&&l.resetBlockStates()}if(!r.hash)if(s==="POP"){const l=d.current;if(l==null)return;let u,p=0;const m=()=>{o.scrollTo(0,l),Math.abs(v(o)-l)>5&&p<30&&(p++,u=requestAnimationFrame(m))};return u=requestAnimationFrame(m),()=>cancelAnimationFrame(u)}else o.scrollTo(0,0)}},[r.key,s,t,n,r.hash])}function K(e){if(!e)return!1;if(e.startsWith("#")||e.startsWith("/")&&!e.startsWith("//"))return!0;try{return new URL(e,window.location.origin).origin===window.location.origin}catch{return!0}}function V(e){return!(e.defaultPrevented||e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.button!==0)}function Y(e){let t=e;for(;t&&t!==document.body;){if(t.tagName==="A")return t;t=t.parentElement}return null}function y(e,t=5){const n=document.getElementById(e);if(n){n.scrollIntoView({behavior:"smooth"});return}t>0&&requestAnimationFrame(()=>{setTimeout(()=>y(e,t-1),50)})}function _(e={}){const{enabled:t=!0}=e,n=B(),r=T();a.useEffect(()=>{if(!t||!r.hash)return;const s=r.hash.slice(1);s&&requestAnimationFrame(()=>{y(s)})},[t,r.pathname,r.hash]),a.useEffect(()=>{if(!t)return;function s(f){if(!V(f))return;const d=Y(f.target);if(!d)return;const c=d.getAttribute("href");if(!c||!K(c)||d.hasAttribute("download")||d.hasAttribute("data-reload"))return;const h=d.getAttribute("target");if(h&&h!=="_self")return;const o=globalThis.uniweb?.activeWebsite,l=o?.basePath||"";let u=c;if(l&&c.startsWith(l)&&(u=c.slice(l.length)||"/"),o?.hasMultipleLocales()){const m=o.getActiveLocale(),L=o.getDefaultLocale(),S=o.getLocales().map(k=>k.code),g=u.match(/^\/([a-z]{2,3}(?:-[A-Za-z]{2,4})?)(?:\/|$)/)?.[1];let b=!1;if(g&&S.includes(g)?b=g!==m:b=m!==L,b)return}if(f.preventDefault(),u.startsWith("#")){const m=u.slice(1);m&&(y(m),window.history.pushState(null,"",c));return}o?.viewTransitions&&document.startViewTransition&&!j?document.startViewTransition(async()=>{await P(u),n(u)}):n(u)}return document.addEventListener("click",s),()=>{document.removeEventListener("click",s)}},[t,n])}function z(){const e=globalThis.uniweb.activeWebsite;if(_({enabled:!0}),q({enabled:!0}),!e)return i.jsx("div",{className:"website-loading",style:{padding:"2rem",textAlign:"center",color:"#64748b"},children:"Loading website..."});const t=e.themeData?.css;return i.jsx(F,{css:t,children:i.jsx(A,{})})}class x extends R.Component{constructor(t){super(t),this.state={hasError:!1,error:null}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("[Runtime] Error caught by boundary:",t,n)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:i.jsxs("div",{style:{padding:"2rem",margin:"1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"0.5rem",color:"#dc2626"},children:[i.jsx("h2",{style:{margin:"0 0 1rem"},children:"Something went wrong"}),i.jsx("p",{children:this.state.error?.message||"An unexpected error occurred"}),!1]}):this.props.children}}function oe({basename:e,development:t=!1,externalRouter:n=!1}){const r=globalThis.uniweb?.activeWebsite;if(!r)return null;r.setBasePath&&r.setBasePath(e||"");const s=i.jsx(W,{children:i.jsx(I,{path:"/*",element:i.jsx(z,{})})}),f=n?i.jsx(x,{children:s}):i.jsx(x,{children:i.jsx(M,{basename:e,children:s})});return t?i.jsx(R.StrictMode,{children:f}):f}export{oe as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as h,h as D,i as b,p as u,a as w}from"../assets/setup-BeQi33In.js";import"../assets/_importmap_react-CrAkajDz.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";import"../assets/index-C_CSAb0x.js";import"../assets/index-n0uF7vTr.js";import"../assets/shade-generator-BBzWo1IN.js";import"../assets/normalize-DbApPPeG.js";import"./@uniweb-runtime-default-fetcher.js";import"../assets/jsx-runtime-0PlsXv6K.js";import"./@uniweb-theming.js";import"../assets/_importmap_react-router-dom-CLbp1nUY.js";export{h as decodeData,D as hydrateDataStore,b as initUniweb,u as prefersReducedMotion,w as prefetchContent};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import{g as U,i as R}from"../assets/shade-generator-BBzWo1IN.js";import{f as De,a as ze,b as Me,c as We,p as Be}from"../assets/shade-generator-BBzWo1IN.js";import{n as W}from"../assets/normalize-DbApPPeG.js";const A={light:{section:"var(--neutral-50)",card:"var(--neutral-100)",muted:"var(--neutral-200)",body:"var(--neutral-950)",heading:"var(--neutral-900)",subtle:"var(--neutral-600)",border:"var(--neutral-200)",ring:"var(--primary-500)",link:"var(--primary-600)","link-hover":"var(--primary-700)",accent:"var(--accent-500)",primary:"var(--primary-600)","primary-foreground":"white","primary-hover":"var(--primary-700)","primary-border":"transparent",secondary:"white","secondary-foreground":"var(--neutral-900)","secondary-hover":"var(--neutral-100)","secondary-border":"var(--neutral-300)",success:"#16a34a","success-subtle":"#f0fdf4",warning:"#d97706","warning-subtle":"#fffbeb",error:"#dc2626","error-subtle":"#fef2f2",info:"#2563eb","info-subtle":"#eff6ff"},medium:{section:"var(--neutral-100)",card:"var(--neutral-200)",muted:"var(--neutral-300)",body:"var(--neutral-950)",heading:"var(--neutral-900)",subtle:"var(--neutral-700)",border:"var(--neutral-300)",ring:"var(--primary-500)",link:"var(--primary-600)","link-hover":"var(--primary-700)",accent:"var(--accent-500)",primary:"var(--primary-600)","primary-foreground":"white","primary-hover":"var(--primary-700)","primary-border":"transparent",secondary:"white","secondary-foreground":"var(--neutral-900)","secondary-hover":"var(--neutral-100)","secondary-border":"var(--neutral-300)",success:"#16a34a","success-subtle":"#f0fdf4",warning:"#d97706","warning-subtle":"#fffbeb",error:"#dc2626","error-subtle":"#fef2f2",info:"#2563eb","info-subtle":"#eff6ff"},dark:{section:"var(--neutral-950)",card:"var(--neutral-800)",muted:"var(--neutral-700)",body:"var(--neutral-50)",heading:"white",subtle:"var(--neutral-400)",border:"var(--neutral-700)",ring:"var(--primary-500)",link:"var(--primary-400)","link-hover":"var(--primary-300)",accent:"var(--accent-400)",primary:"var(--primary-500)","primary-foreground":"white","primary-hover":"var(--primary-400)","primary-border":"transparent",secondary:"var(--neutral-800)","secondary-foreground":"var(--neutral-100)","secondary-hover":"var(--neutral-700)","secondary-border":"var(--neutral-600)",success:"#4ade80","success-subtle":"#052e16",warning:"#fbbf24","warning-subtle":"#451a03",error:"#f87171","error-subtle":"#450a0a",info:"#60a5fa","info-subtle":"#172554"}},B={primary:"#3b82f6",secondary:"#64748b",accent:"#8b5cf6",neutral:"#78716c"},Q=[50,100,200,300,400,500,600,700,800,900,950];function I(e,t=" "){return Object.entries(e).map(([o,n])=>`${t}--${o}: ${n};`).join(`
|
|
2
|
+
`)}function X(e){const t=[];for(const[o,n]of Object.entries(e))for(const r of Q)n[r]&&t.push(` --${o}-${r}: ${n[r]};`);return t.join(`
|
|
3
|
+
`)}function N(e,t={},o={}){const r={...A[e]||A.light,...t},s=o[e]||{},i={...r,...s},l=I(i);return`.context-${e} {
|
|
4
|
+
${l}
|
|
5
|
+
}`}function q(e={},t={},o={}){const n=e.default==="system",r=o.dark||{},s={...A.dark,...t,...r},i=I(s);let l=`/* Dark scheme (user preference) */
|
|
6
|
+
`;if(l+=`.scheme-dark {
|
|
7
|
+
${i}
|
|
8
|
+
}
|
|
9
|
+
`,n){l+=`
|
|
10
|
+
@media (prefers-color-scheme: dark) {
|
|
11
|
+
`,l+=` :root:not(.scheme-light) {
|
|
12
|
+
`;for(const[p,u]of Object.entries(s))l+=` --${p}: ${u};
|
|
13
|
+
`;l+=` }
|
|
14
|
+
`,l+=`}
|
|
15
|
+
`}return l}const Z=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-monospace","ui-serif","ui-sans-serif","ui-rounded","math","emoji","fangsong","inherit","initial","revert","unset"]);function ee(e={}){const t=new Set,o=n=>{if(typeof n=="string")for(const r of n.split(",")){const s=r.trim().replace(/^["']|["']$/g,"").toLowerCase();!s||Z.has(s)||/^\d/.test(s)||t.add(s)}};for(const n of Object.values(e))n&&n.load&&o(n.value);return t}function te(e,t){try{const o=new URL(e),n=o.searchParams.getAll("family");if(n.length===0)return e;const r=n.filter(s=>{const i=s.split(":")[0].trim().toLowerCase();return t.has(i)});if(r.length===0)return null;o.searchParams.delete("family");for(const s of r)o.searchParams.append("family",s);return o.toString()}catch{return e}}function ne(e,t){if(!e||!t||t==="/"||!e.startsWith("/")||e.startsWith("//"))return e;const o=t.endsWith("/")?t.slice(0,-1):t;return e===o||e.startsWith(o+"/")?e:o+e}function oe(e){try{return new URL(e).hostname==="fonts.googleapis.com"}catch{return!1}}const Re="<!--uniweb-fonts-->";function re(e={},t={},o="/"){const n=[],r=[],s=ee(e),i={woff2:"font/woff2",woff:"font/woff",truetype:"font/ttf",opentype:"font/otf"};if(t.faces&&Array.isArray(t.faces)){for(const a of t.faces){if(!a.family||!a.src||!s.has(a.family.toLowerCase()))continue;const f=a.format||(a.src.endsWith(".woff2")?"woff2":"woff"),y=ne(a.src,o);n.push("@font-face {",` font-family: ${a.family};`,` src: url('${y}') format('${f}');`,` font-weight: ${a.weight||400};`,` font-style: ${a.style||"normal"};`," font-display: swap;","}");const m=i[f];m&&r.push(`<link rel="preload" href="${y}" as="font" type="${m}" crossorigin>`)}n.length>0&&n.push("")}const l=[],p=new Set;if(t.import&&Array.isArray(t.import)){for(const a of t.import)if(a.url)if(oe(a.url)){const f=te(a.url,s);f&&l.push(f)}else{r.push(`<link rel="stylesheet" href="${a.url}">`);try{p.add(new URL(a.url).origin)}catch{}}}for(const a of p)r.unshift(`<link rel="preconnect" href="${a}">`);if(l.length>0){const a=[];let f="swap";for(const y of l)try{const m=new URL(y);a.push(...m.searchParams.getAll("family")),m.searchParams.get("display")&&(f=m.searchParams.get("display"))}catch{}if(a.length>0){const m=`https://fonts.googleapis.com/css2?${a.map(k=>`family=${k.trim().replace(/\s+/g,"+")}`).join("&")}&display=${f}`;r.unshift('<link rel="preconnect" href="https://fonts.googleapis.com">','<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>',`<link rel="stylesheet" href="${m}">`)}}const u=[];for(const[a,f]of Object.entries(e))f.value&&u.push(` --font-${a}: ${f.value};`);u.length>0&&(n.push(":root {"),n.push(...u),n.push("}"));const h=[];for(const[a,f]of Object.entries(e)){if(!f.apply||!f.applyTo?.length)continue;const y=f.applyTo.join(", ");h.push(`${y} { font-family: var(--font-${a}); }`)}return h.length>0&&(n.push(""),n.push(...h)),{css:n.join(`
|
|
16
|
+
`),links:r.join(`
|
|
17
|
+
`)}}const se=new Set(["section","card","muted","body","heading","subtle","border","ring","link","link-hover","accent","primary","primary-foreground","primary-hover","primary-border","secondary","secondary-foreground","secondary-hover","secondary-border","success","success-subtle","warning","warning-subtle","error","error-subtle","info","info-subtle"]),ae=/^(primary|secondary|accent|neutral)-\d+$/;function ie(e={}){if(!e||Object.keys(e).length===0)return"";const t=[];for(const[o,n]of Object.entries(e)){(se.has(o)||ae.test(o))&&console.warn(`Warning: Foundation var '${o}' collides with a theme token. Rename it to avoid unexpected behavior (e.g., '${o}-value' or '${o}-size').`);const r=typeof n=="object"?n.default:n;r!==void 0&&t.push(` --${o}: ${r};`)}return t.length===0?"":`:root {
|
|
18
|
+
${t.join(`
|
|
19
|
+
`)}
|
|
20
|
+
}`}function G(e={},t={}){const{base:o="/"}=t,{colors:n=B,contexts:r={},fonts:s={},fontRoles:i={},appearance:l={},foundationVars:p={},colorVars:u={}}=e,h=[],a=re(i,s,o);a.css&&h.push(`/* Typography */
|
|
21
|
+
`+a.css);const f=U(n),y=X(f);h.push(`/* Color Palettes */
|
|
22
|
+
:root {
|
|
23
|
+
${y}
|
|
24
|
+
}`);const m=u.light||{},k={...A.light,...r.light||{},...m},w=I(k);h.push(`/* Default Semantic Tokens */
|
|
25
|
+
:root {
|
|
26
|
+
${w}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Section backgrounds — applied once, resolves via context tokens */
|
|
30
|
+
[id^="section-"] {
|
|
31
|
+
background-color: var(--section);
|
|
32
|
+
}`);const g=[N("light",r.light,u),N("medium",r.medium,u),N("dark",r.dark,u)];h.push(`/* Color Contexts */
|
|
33
|
+
`+g.join(`
|
|
34
|
+
|
|
35
|
+
`));const $=ie(p);if($&&h.push(`/* Foundation Variables */
|
|
36
|
+
`+$),(l.allowToggle||l.default==="dark"||l.default==="system"||l.schemes?.includes("dark"))&&h.push(q(l,r.dark,u)),h.push(`/* Site Background */
|
|
37
|
+
body {
|
|
38
|
+
background: ${e.background||"var(--section)"};
|
|
39
|
+
}`),e.inline&&typeof e.inline=="object"){const j=Object.entries(e.inline).filter(([,v])=>v&&typeof v=="object").map(([v,V])=>{const b=Object.entries(V).map(([F,L])=>` ${F}: ${L};`).join(`
|
|
40
|
+
`);return`span[${v}] {
|
|
41
|
+
${b}
|
|
42
|
+
}`});j.length>0&&h.push(`/* Inline Text Styles */
|
|
43
|
+
`+j.join(`
|
|
44
|
+
|
|
45
|
+
`))}return{css:h.join(`
|
|
46
|
+
|
|
47
|
+
`),links:a.links}}function ce(){return JSON.parse(JSON.stringify(A))}function le(){return{...B}}const P={stone:"#78716c",zinc:"#71717a",gray:"#6b7280",slate:"#64748b",neutral:"#737373"},fe={accent:{color:"var(--accent)","font-weight":"600"},callout:{color:"var(--accent)","font-weight":"600"},muted:{color:"var(--subtle)"}},D={default:"light",allowToggle:!1,respectSystemPreference:!0},ue={body:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',heading:'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',code:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, monospace'},de={body:["body"],heading:["h1","h2","h3"],code:["code","pre","kbd","samp"]},pe=new Set(["font-weight","font-style","font-size","font-stretch","font-feature-settings","font-variation-settings","font-variant","font-kerning","font-optical-sizing","font-synthesis","font-size-adjust","font-smoothing","font-palette","font-language-override"]);function he(e,t){return(typeof t=="object"?t?.type:void 0)==="font"?!0:e.startsWith("font-")&&!pe.has(e)}function z(e){return e.startsWith("font-")?e.slice(5):e}function me(e){if(e==null)return null;const o=(Array.isArray(e)?e:String(e).split(",")).map(n=>String(n).trim()).filter(Boolean);return o.length?o:null}function ye(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};for(const[o,n]of Object.entries(e))if(!(typeof n=="object"&&n!==null)){if(typeof n!="string"){t.push(`Color "${o}" must be a string or shade object, got ${typeof n}`);continue}o==="neutral"&&P[n]||R(n)||t.push(`Color "${o}" has invalid value: ${n}`)}return{valid:t.length===0,errors:t}}function ge(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};const o=["light","medium","dark"];for(const[n,r]of Object.entries(e)){if(!o.includes(n)){t.push(`Unknown context "${n}". Valid contexts: ${o.join(", ")}`);continue}(typeof r!="object"||r===null)&&t.push(`Context "${n}" must be an object`)}return{valid:t.length===0,errors:t}}function be(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};if(e.import!==void 0)if(!Array.isArray(e.import))t.push("fonts.import must be an array");else for(const[o,n]of e.import.entries())(typeof n!="object"||!n.url)&&t.push(`fonts.import[${o}] must have a "url" property`);return{valid:t.length===0,errors:t}}function ve(e){const t=[];if(!e||typeof e!="object")return typeof e=="string"&&(["light","dark","system"].includes(e)||t.push(`Invalid appearance value: ${e}. Must be "light", "dark", or "system"`)),{valid:t.length===0,errors:t};if(e.default&&!["light","dark","system"].includes(e.default)&&t.push(`Invalid appearance.default: ${e.default}`),e.schemes!==void 0)if(!Array.isArray(e.schemes))t.push("appearance.schemes must be an array");else{const o=["light","dark"];for(const n of e.schemes)o.includes(n)||t.push(`Invalid scheme: ${n}. Valid schemes: ${o.join(", ")}`)}return{valid:t.length===0,errors:t}}function je(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};for(const[o,n]of Object.entries(e)){if(typeof n!="string"){t.push(`code.${o} must be a string, got ${typeof n}`);continue}R(n)||t.push(`code.${o} has invalid color value: ${n}`)}return{valid:t.length===0,errors:t}}const M=new Set(["color","gradient"]);function ke(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:t};for(const[o,n]of Object.entries(e))/^[a-z][a-z0-9-]*$/i.test(o)||t.push(`Invalid variable name "${o}". Use lowercase letters, numbers, and hyphens.`),typeof n!="object"&&typeof n!="string"&&typeof n!="number"&&t.push(`Variable "${o}" must have a string, number, or config object value`);return{valid:t.length===0,errors:t}}function $e(e){const t=[];if(!e||typeof e!="object")return{valid:!0,errors:[]};const o=ye(e.colors),n=ge(e.contexts),r=be(e.fonts),s=ve(e.appearance),i=je(e.code);return t.push(...o.errors),t.push(...n.errors),t.push(...r.errors),t.push(...s.errors),t.push(...i.errors),{valid:t.length===0,errors:t}}function Oe(e,t){const o={...e};for(const[n,r]of Object.entries(t||{}))o[n]=r&&typeof r=="object"&&!Array.isArray(r)?{...e[n]||{},...r}:r;return o}function Se(e){return e?typeof e=="string"?{default:e,allowToggle:!1,respectSystemPreference:e==="system"}:{...D,...e}:{...D}}function we(e={},t={}){const o={},n={};for(const[r,s]of Object.entries(e)){const i=typeof s=="object"?{...s}:{default:s};if(M.has(i.type)){const p=i.default||"";n[r]={light:p,dark:p}}else o[r]=i}for(const[r,s]of Object.entries(t)){const i=e[r],l=typeof i=="object"?i?.type:void 0;if(M.has(l))if(typeof s=="object"&&s!==null&&(s.light||s.dark))n[r]={...n[r]||{},...s};else{const u=String(s);n[r]={light:u,dark:u}}else o[r]?o[r].default=s:o[r]={default:s}}return{flat:o,colorVars:n}}function H(e={},t={}){const{foundationVars:o={},strict:n=!1}=t,r=[],s=[],i=$e(e);if(!i.valid&&(r.push(...i.errors),n))throw new Error(`Theme configuration errors:
|
|
48
|
+
${r.join(`
|
|
49
|
+
`)}`);const l=le(),p={...e.colors||{}};typeof p.neutral=="string"&&P[p.neutral]&&(p.neutral=P[p.neutral]);const u=p.primary??l.primary,h=c=>typeof c=="object"&&c!==null||R(c);p.accent===void 0&&h(u)&&(p.accent=u);const a={};for(const[c,d]of Object.entries({...l,...p}))(typeof d=="object"&&d!==null||R(d))&&(a[c]=d);const f=a,y=U(f);e.colors?.primary||s.push("No primary color specified, using default blue (#3b82f6)"),e.colors?.neutral||s.push("No neutral color specified, using default stone (#78716c)");const m=ce(),k=e.contexts||{},w={};for(const c of["light","medium","dark"]){const d=k[c]||{},O={};for(const[S,x]of Object.entries(d))O[S]=W(x);w[c]={...m[c],...O}}const g={...e.fonts||{}},$=Se(e.appearance),{flat:j,colorVars:v}=we(o,e.vars||e.foundationVars||{}),V=ke(j);V.valid||s.push(...V.errors);const b={};for(const[c,d]of Object.entries(de))b[c]={value:ue[c],applyTo:[...d],foundationOwned:!1,userSet:!1};const F={};for(const[c,d]of Object.entries(j)){if(!he(c,d)){F[c]=d;continue}const O=z(c),S=typeof d=="object"?d:{default:d},x=b[O];b[O]={value:S.default??x?.value,applyTo:S.applyTo!==void 0?me(S.applyTo):x?.applyTo??null,foundationOwned:!0,userSet:!1}}const L=new Set(["import","faces"]);for(const[c,d]of Object.entries(g)){if(L.has(c))continue;const O=z(c),S=b[O];b[O]={value:d,applyTo:S?.applyTo??null,foundationOwned:S?.foundationOwned??!1,userSet:!0}}for(const c of Object.values(b)){const d=c.foundationOwned||c.userSet;c.apply=d&&Array.isArray(c.applyTo)&&c.applyTo.length>0,c.load=d}g.mono!==void 0&&!b.mono?.foundationOwned&&s.push("theme.yml `fonts.mono` is not a built-in font role — the code/monospace role is `code`. Rename `fonts.mono` → `fonts.code`.");const E={};g.import!==void 0&&(E.import=g.import),g.faces!==void 0&&(E.faces=g.faces);for(const[c,d]of Object.entries(b))E[c]=d.value;const K=e.code??null,Y=e.background||null,J=Oe(fe,e.inline);return{config:{colors:f,palettes:y,contexts:w,fonts:E,fontRoles:b,appearance:$,foundationVars:F,colorVars:v,code:K,background:Y,inline:J},errors:r,warnings:s}}function Le(e){if(!e)return{};const t=e.default||e;return t.vars||t}function Ne(e){return e?._self?.vars!=null||e?._self?.themeVars!=null||e?.themeVars!=null}function Ve(e){if(!e)return!1;const{colors:t,foundationStyles:o}=e;if(o&&Object.keys(o).length>0)return!0;if(!t)return!1;const n=t.colors?.light&&Object.keys(t.colors.light).length>0,r=t.elements&&Object.values(t.elements).some(s=>s&&Object.keys(s).length>0);return n||r}function Te(e){if(!e||Object.keys(e).length===0)return[];const t=[],o=U(e);for(const[n,r]of Object.entries(o))for(const[s,i]of Object.entries(r))t.push(` --${n}-${s}: ${i};`);return t}function _(e){if(!e||Object.keys(e).length===0)return[];const t=[];for(const[o,n]of Object.entries(e))n===""||n==null||t.push(` --${o}: ${W(n)};`);return t}function T(e){if(!e||Object.keys(e).length===0)return[];const t=[];for(const[o,n]of Object.entries(e))n===""||n==null||typeof n=="object"||t.push(` --${o}: ${n};`);return t}function Ae(e){if(!e||Object.keys(e).length===0)return{flat:{},contexts:{}};const t={},o={};for(const[n,r]of Object.entries(e))if(r!=null)if(typeof r=="object")for(const[s,i]of Object.entries(r))i===""||i==null||(o[s]||(o[s]={}),o[s][n]=i);else t[n]=r;return{flat:t,contexts:o}}function C(e,t){return t.length===0?"":`${e} {
|
|
50
|
+
${t.join(`
|
|
51
|
+
`)}
|
|
52
|
+
}
|
|
53
|
+
`}function _e(e,t={}){if(!e||e.length===0)return"";let o="";for(const n of e){const r=Ve(n.standardOptions),s=n.componentVars&&Object.keys(n.componentVars).length>0;if(!r&&!s)continue;const{colors:i,foundationStyles:l}=n.standardOptions||{},u=`#section-${n.stableId||n.id}`,h=!n.themeName,a=t.allowToggle,f=Te(i?.colors?.light),{flat:y,contexts:m}=Ae(l),k=T(y),w=T(n.componentVars);if(h&&a){const g=_(i?.elements?.light),$=_(i?.elements?.dark),j=T(m.light),v=T(m.dark),V=[...f,...k,...w];o+=C(u,V),o+=C(`:root:not(.scheme-dark) ${u}`,[...g,...j]),o+=C(`.scheme-dark ${u}`,[...$,...v])}else{const g=a&&n.themeName||"light",$=_(i?.elements?.[g]),j=T(m[g]),v=[...f,...$,...k,...w,...j];o+=C(u,v)}}return o}function Fe(e={},t={}){const{config:o,errors:n,warnings:r}=H(e,t),{css:s,links:i}=G(o,{base:t.base});return{css:s,links:i,config:o,errors:n,warnings:r}}const Pe={buildTheme:Fe,processTheme:H,generateThemeCSS:G};export{Re as FONT_LINKS_MARKER,_e as buildSectionOverrides,Fe as buildTheme,Pe as default,Le as extractFoundationVars,ee as extractUsedFamilies,De as formatHex,ze as formatOklch,Ne as foundationHasVars,N as generateContextCSS,ie as generateFoundationVars,X as generatePaletteVars,U as generatePalettes,Me as generateShades,G as generateThemeCSS,le as getDefaultColors,ce as getDefaultContextTokens,We as getShadeLevels,he as isFontVar,R as isValidColor,W as normalizeTokenValue,Be as parseColor,H as processTheme,$e as validateThemeConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as o}from"../assets/client-CQjOKqaN.js";import{a as n}from"../assets/client-CQjOKqaN.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";import"../assets/index-VvOM7xKK.js";const s=o.createRoot,c=o.hydrateRoot,i=o.version;export{s as createRoot,n as default,c as hydrateRoot,i as version};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as r,H as u,L as i,M as R,N as m,e as h,O as n,c,R as p,f as v,g as L,u as N,h as f,b as g,d as H,i as M,j as P}from"../assets/_importmap_react-router-dom-CLbp1nUY.js";import"../assets/_importmap_react-CrAkajDz.js";import"../assets/_commonjsHelpers-CqkleIqs.js";import"../assets/index-CxUeIbEw.js";export{r as BrowserRouter,u as HashRouter,i as Link,R as MemoryRouter,m as NavLink,h as Navigate,n as Outlet,c as Route,p as Routes,v as useHref,L as useInRouterContext,N as useLocation,f as useMatch,g as useNavigate,H as useParams,M as useResolvedPath,P as useSearchParams};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as i}from"./_importmap_react-CrAkajDz.js";var ue="popstate";function De(e={}){let{initialEntries:t=["/"],initialIndex:r,v5Compat:n=!1}=e,a;a=t.map((d,v)=>h(d,typeof d=="string"?null:d.state,v===0?"default":void 0));let o=u(r??a.length-1),l="POP",s=null;function u(d){return Math.min(Math.max(d,0),a.length-1)}function c(){return a[o]}function h(d,v=null,y){let m=_(a?c().pathname:"/",d,v,y);return C(m.pathname.charAt(0)==="/",`relative pathnames are not supported in memory history: ${JSON.stringify(d)}`),m}function f(d){return typeof d=="string"?d:N(d)}return{get index(){return o},get action(){return l},get location(){return c()},createHref:f,createURL(d){return new URL(f(d),"http://localhost")},encodeLocation(d){let v=typeof d=="string"?T(d):d;return{pathname:v.pathname||"",search:v.search||"",hash:v.hash||""}},push(d,v){l="PUSH";let y=h(d,v);o+=1,a.splice(o,a.length,y),n&&s&&s({action:l,location:y,delta:1})},replace(d,v){l="REPLACE";let y=h(d,v);a[o]=y,n&&s&&s({action:l,location:y,delta:0})},go(d){l="POP";let v=u(o+d),y=a[v];o=v,s&&s({action:l,location:y,delta:d})},listen(d){return s=d,()=>{s=null}}}}function Ue(e={}){function t(n,a){let{pathname:o,search:l,hash:s}=n.location;return _("",{pathname:o,search:l,hash:s},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function r(n,a){return typeof a=="string"?a:N(a)}return me(t,r,null,e)}function Ae(e={}){function t(a,o){let{pathname:l="/",search:s="",hash:u=""}=T(a.location.hash.substring(1));return!l.startsWith("/")&&!l.startsWith(".")&&(l="/"+l),_("",{pathname:l,search:s,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default")}function r(a,o){let l=a.document.querySelector("base"),s="";if(l&&l.getAttribute("href")){let u=a.location.href,c=u.indexOf("#");s=c===-1?u:u.slice(0,c)}return s+"#"+(typeof o=="string"?o:N(o))}function n(a,o){C(a.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(o)})`)}return me(t,r,n,e)}function E(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function C(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function Be(){return Math.random().toString(36).substring(2,10)}function ce(e,t){return{usr:e.state,key:e.key,idx:t}}function _(e,t,r=null,n){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?T(t):t,state:r,key:t&&t.key||n||Be()}}function N({pathname:e="/",search:t="",hash:r=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),r&&r!=="#"&&(e+=r.charAt(0)==="#"?r:"#"+r),e}function T(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substring(r),e=e.substring(0,r));let n=e.indexOf("?");n>=0&&(t.search=e.substring(n),e=e.substring(0,n)),e&&(t.pathname=e)}return t}function me(e,t,r,n={}){let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,s="POP",u=null,c=h();c==null&&(c=0,l.replaceState({...l.state,idx:c},""));function h(){return(l.state||{idx:null}).idx}function f(){s="POP";let m=h(),R=m==null?null:m-c;c=m,u&&u({action:s,location:y.location,delta:R})}function g(m,R){s="PUSH";let p=_(y.location,m,R);r&&r(p,m),c=h()+1;let w=ce(p,c),P=y.createHref(p);try{l.pushState(w,"",P)}catch(x){if(x instanceof DOMException&&x.name==="DataCloneError")throw x;a.location.assign(P)}o&&u&&u({action:s,location:y.location,delta:1})}function d(m,R){s="REPLACE";let p=_(y.location,m,R);r&&r(p,m),c=h();let w=ce(p,c),P=y.createHref(p);l.replaceState(w,"",P),o&&u&&u({action:s,location:y.location,delta:0})}function v(m){return He(m)}let y={get action(){return s},get location(){return e(a,l)},listen(m){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(ue,f),u=m,()=>{a.removeEventListener(ue,f),u=null}},createHref(m){return t(a,m)},createURL:v,encodeLocation(m){let R=v(m);return{pathname:R.pathname,search:R.search,hash:R.hash}},push:g,replace:d,go(m){return l.go(m)}};return y}function He(e,t=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),E(r,"No window.location.(origin|href) available to create URL");let n=typeof e=="string"?e:N(e);return n=n.replace(/ $/,"%20"),!t&&n.startsWith("//")&&(n=r+n),new URL(n,r)}function ye(e,t,r="/"){return _e(e,t,r,!1)}function _e(e,t,r,n){let a=typeof t=="string"?T(t):t,o=k(a.pathname||"/",r);if(o==null)return null;let l=ge(e);We(l);let s=null;for(let u=0;s==null&&u<l.length;++u){let c=Re(o);s=Xe(l[u],c,n)}return s}function ge(e,t=[],r=[],n="",a=!1){let o=(l,s,u=a,c)=>{let h={relativePath:c===void 0?l.path||"":c,caseSensitive:l.caseSensitive===!0,childrenIndex:s,route:l};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(n)&&u)return;E(h.relativePath.startsWith(n),`Absolute route path "${h.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(n.length)}let f=$([n,h.relativePath]),g=r.concat(h);l.children&&l.children.length>0&&(E(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),ge(l.children,t,g,f,u)),!(l.path==null&&!l.index)&&t.push({path:f,score:qe(f,l.index),routesMeta:g})};return e.forEach((l,s)=>{if(l.path===""||!l.path?.includes("?"))o(l,s);else for(let u of ve(l.path))o(l,s,!0,u)}),t}function ve(e){let t=e.split("/");if(t.length===0)return[];let[r,...n]=t,a=r.endsWith("?"),o=r.replace(/\?$/,"");if(n.length===0)return a?[o,""]:[o];let l=ve(n.join("/")),s=[];return s.push(...l.map(u=>u===""?o:[o,u].join("/"))),a&&s.push(...l),s.map(u=>e.startsWith("/")&&u===""?"/":u)}function We(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:Ge(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var je=/^:[\w-]+$/,ze=3,Je=2,Ve=1,Ke=10,Ye=-2,fe=e=>e==="*";function qe(e,t){let r=e.split("/"),n=r.length;return r.some(fe)&&(n+=Ye),t&&(n+=Je),r.filter(a=>!fe(a)).reduce((a,o)=>a+(je.test(o)?ze:o===""?Ve:Ke),n)}function Ge(e,t){return e.length===t.length&&e.slice(0,-1).every((n,a)=>n===t[a])?e[e.length-1]-t[t.length-1]:0}function Xe(e,t,r=!1){let{routesMeta:n}=e,a={},o="/",l=[];for(let s=0;s<n.length;++s){let u=n[s],c=s===n.length-1,h=o==="/"?t:t.slice(o.length)||"/",f=W({path:u.relativePath,caseSensitive:u.caseSensitive,end:c},h),g=u.route;if(!f&&c&&r&&!n[n.length-1].route.index&&(f=W({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},h)),!f)return null;Object.assign(a,f.params),l.push({params:a,pathname:$([o,f.pathname]),pathnameBase:rt($([o,f.pathnameBase])),route:g}),f.pathnameBase!=="/"&&(o=$([o,f.pathnameBase]))}return l}function W(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=Qe(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let o=a[0],l=o.replace(/(.)\/+$/,"$1"),s=a.slice(1);return{params:n.reduce((c,{paramName:h,isOptional:f},g)=>{if(h==="*"){let v=s[g]||"";l=o.slice(0,o.length-v.length).replace(/(.)\/+$/,"$1")}const d=s[g];return f&&!d?c[h]=void 0:c[h]=(d||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:l,pattern:e}}function Qe(e,t=!1,r=!0){C(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let n=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,s,u)=>(n.push({paramName:s,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(n.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),n]}function Re(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return C(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function k(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,n=e.charAt(r);return n&&n!=="/"?null:e.slice(r)||"/"}var we=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ze=e=>we.test(e);function et(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?T(e):e,o;if(r)if(Ze(r))o=r;else{if(r.includes("//")){let l=r;r=r.replace(/\/\/+/g,"/"),C(!1,`Pathnames cannot have embedded double slashes - normalizing ${l} -> ${r}`)}r.startsWith("/")?o=he(r.substring(1),"/"):o=he(r,t)}else o=t;return{pathname:o,search:nt(n),hash:at(a)}}function he(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function q(e,t,r,n){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(n)}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function tt(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function ee(e){let t=tt(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function te(e,t,r,n=!1){let a;typeof e=="string"?a=T(e):(a={...e},E(!a.pathname||!a.pathname.includes("?"),q("?","pathname","search",a)),E(!a.pathname||!a.pathname.includes("#"),q("#","pathname","hash",a)),E(!a.search||!a.search.includes("#"),q("#","search","hash",a)));let o=e===""||a.pathname==="",l=o?"/":a.pathname,s;if(l==null)s=r;else{let f=t.length-1;if(!n&&l.startsWith("..")){let g=l.split("/");for(;g[0]==="..";)g.shift(),f-=1;a.pathname=g.join("/")}s=f>=0?t[f]:"/"}let u=et(a,s),c=l&&l!=="/"&&l.endsWith("/"),h=(o||l===".")&&r.endsWith("/");return!u.pathname.endsWith("/")&&(c||h)&&(u.pathname+="/"),u}var $=e=>e.join("/").replace(/\/\/+/g,"/"),rt=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),nt=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,at=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,ot=class{constructor(e,t,r,n=!1){this.status=e,this.statusText=t||"",this.internal=n,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function lt(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function it(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Ee=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function xe(e,t){let r=e;if(typeof r!="string"||!we.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let n=r,a=!1;if(Ee)try{let o=new URL(window.location.href),l=r.startsWith("//")?new URL(o.protocol+r):new URL(r),s=k(l.pathname,t);l.origin===o.origin&&s!=null?r=s+l.search+l.hash:a=!0}catch{C(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:n,isExternal:a,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var Ce=["POST","PUT","PATCH","DELETE"];new Set(Ce);var st=["GET",...Ce];new Set(st);var U=i.createContext(null);U.displayName="DataRouter";var K=i.createContext(null);K.displayName="DataRouterState";var ut=i.createContext(!1),be=i.createContext({isTransitioning:!1});be.displayName="ViewTransition";var ct=i.createContext(new Map);ct.displayName="Fetchers";var ft=i.createContext(null);ft.displayName="Await";var b=i.createContext(null);b.displayName="Navigation";var A=i.createContext(null);A.displayName="Location";var S=i.createContext({outlet:null,matches:[],isDataRoute:!1});S.displayName="Route";var re=i.createContext(null);re.displayName="RouteError";var Pe="REACT_ROUTER_ERROR",ht="REDIRECT",dt="ROUTE_ERROR_RESPONSE";function pt(e){if(e.startsWith(`${Pe}:${ht}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function mt(e){if(e.startsWith(`${Pe}:${dt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new ot(t.status,t.statusText,t.data)}catch{}}function yt(e,{relative:t}={}){E(F(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:n}=i.useContext(b),{hash:a,pathname:o,search:l}=j(e,{relative:t}),s=o;return r!=="/"&&(s=o==="/"?r:$([r,o])),n.createHref({pathname:s,search:l,hash:a})}function F(){return i.useContext(A)!=null}function L(){return E(F(),"useLocation() may be used only in the context of a <Router> component."),i.useContext(A).location}function pr(){return i.useContext(A).navigationType}function mr(e){E(F(),"useMatch() may be used only in the context of a <Router> component.");let{pathname:t}=L();return i.useMemo(()=>W(e,Re(t)),[t,e])}var Se="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Le(e){i.useContext(b).static||i.useLayoutEffect(e)}function ne(){let{isDataRoute:e}=i.useContext(S);return e?Ot():gt()}function gt(){E(F(),"useNavigate() may be used only in the context of a <Router> component.");let e=i.useContext(U),{basename:t,navigator:r}=i.useContext(b),{matches:n}=i.useContext(S),{pathname:a}=L(),o=JSON.stringify(ee(n)),l=i.useRef(!1);return Le(()=>{l.current=!0}),i.useCallback((u,c={})=>{if(C(l.current,Se),!l.current)return;if(typeof u=="number"){r.go(u);return}let h=te(u,JSON.parse(o),a,c.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:$([t,h.pathname])),(c.replace?r.replace:r.push)(h,c.state,c)},[t,r,o,a,e])}var vt=i.createContext(null);function Rt(e){let t=i.useContext(S).outlet;return i.useMemo(()=>t&&i.createElement(vt.Provider,{value:e},t),[t,e])}function yr(){let{matches:e}=i.useContext(S),t=e[e.length-1];return t?t.params:{}}function j(e,{relative:t}={}){let{matches:r}=i.useContext(S),{pathname:n}=L(),a=JSON.stringify(ee(r));return i.useMemo(()=>te(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function wt(e,t){return $e(e,t)}function $e(e,t,r,n,a){E(F(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=i.useContext(b),{matches:l}=i.useContext(S),s=l[l.length-1],u=s?s.params:{},c=s?s.pathname:"/",h=s?s.pathnameBase:"/",f=s&&s.route;{let p=f&&f.path||"";Te(c,!f||p.endsWith("*")||p.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${p}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
2
|
+
|
|
3
|
+
Please change the parent <Route path="${p}"> to <Route path="${p==="/"?"*":`${p}/*`}">.`)}let g=L(),d;if(t){let p=typeof t=="string"?T(t):t;E(h==="/"||p.pathname?.startsWith(h),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${h}" but pathname "${p.pathname}" was given in the \`location\` prop.`),d=p}else d=g;let v=d.pathname||"/",y=v;if(h!=="/"){let p=h.replace(/^\//,"").split("/");y="/"+v.replace(/^\//,"").split("/").slice(p.length).join("/")}let m=ye(e,{pathname:y});C(f||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),C(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let R=Pt(m&&m.map(p=>Object.assign({},p,{params:Object.assign({},u,p.params),pathname:$([h,o.encodeLocation?o.encodeLocation(p.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathname]),pathnameBase:p.pathnameBase==="/"?h:$([h,o.encodeLocation?o.encodeLocation(p.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:p.pathnameBase])})),l,r,n,a);return t&&R?i.createElement(A.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...d},navigationType:"POP"}},R):R}function Et(){let e=Tt(),t=lt(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,n="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:n},o={padding:"2px 4px",backgroundColor:n},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=i.createElement(i.Fragment,null,i.createElement("p",null,"💿 Hey developer 👋"),i.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",i.createElement("code",{style:o},"ErrorBoundary")," or"," ",i.createElement("code",{style:o},"errorElement")," prop on your route.")),i.createElement(i.Fragment,null,i.createElement("h2",null,"Unexpected Application Error!"),i.createElement("h3",{style:{fontStyle:"italic"}},t),r?i.createElement("pre",{style:a},r):null,l)}var xt=i.createElement(Et,null),ke=class extends i.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const r=mt(e.digest);r&&(e=r)}let t=e!==void 0?i.createElement(S.Provider,{value:this.props.routeContext},i.createElement(re.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?i.createElement(Ct,{error:e},t):t}};ke.contextType=ut;var G=new WeakMap;function Ct({children:e,error:t}){let{basename:r}=i.useContext(b);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let n=pt(t.digest);if(n){let a=G.get(t);if(a)throw a;let o=xe(n.location,r);if(Ee&&!G.get(t))if(o.isExternal||n.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:n.replace}));throw G.set(t,l),l}return i.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function bt({routeContext:e,match:t,children:r}){let n=i.useContext(U);return n&&n.static&&n.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(n.staticContext._deepestRenderedBoundaryId=t.route.id),i.createElement(S.Provider,{value:e},r)}function Pt(e,t=[],r=null,n=null,a=null){if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,l=r?.errors;if(l!=null){let h=o.findIndex(f=>f.route.id&&l?.[f.route.id]!==void 0);E(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),o=o.slice(0,Math.min(o.length,h+1))}let s=!1,u=-1;if(r)for(let h=0;h<o.length;h++){let f=o[h];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(u=h),f.route.id){let{loaderData:g,errors:d}=r,v=f.route.loader&&!g.hasOwnProperty(f.route.id)&&(!d||d[f.route.id]===void 0);if(f.route.lazy||v){s=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}let c=r&&n?(h,f)=>{n(h,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:it(r.matches),errorInfo:f})}:void 0;return o.reduceRight((h,f,g)=>{let d,v=!1,y=null,m=null;r&&(d=l&&f.route.id?l[f.route.id]:void 0,y=f.route.errorElement||xt,s&&(u<0&&g===0?(Te("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,m=null):u===g&&(v=!0,m=f.route.hydrateFallbackElement||null)));let R=t.concat(o.slice(0,g+1)),p=()=>{let w;return d?w=y:v?w=m:f.route.Component?w=i.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=h,i.createElement(bt,{match:f,routeContext:{outlet:h,matches:R,isDataRoute:r!=null},children:w})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?i.createElement(ke,{location:r.location,revalidation:r.revalidation,component:y,error:d,children:p(),routeContext:{outlet:null,matches:R,isDataRoute:!0},onError:c}):p()},null)}function ae(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function St(e){let t=i.useContext(U);return E(t,ae(e)),t}function Lt(e){let t=i.useContext(K);return E(t,ae(e)),t}function $t(e){let t=i.useContext(S);return E(t,ae(e)),t}function oe(e){let t=$t(e),r=t.matches[t.matches.length-1];return E(r.route.id,`${e} can only be used on routes that contain a unique "id"`),r.route.id}function kt(){return oe("useRouteId")}function Tt(){let e=i.useContext(re),t=Lt("useRouteError"),r=oe("useRouteError");return e!==void 0?e:t.errors?.[r]}function Ot(){let{router:e}=St("useNavigate"),t=oe("useNavigate"),r=i.useRef(!1);return Le(()=>{r.current=!0}),i.useCallback(async(a,o={})=>{C(r.current,Se),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var de={};function Te(e,t,r){!t&&!de[e]&&(de[e]=!0,C(!1,r))}i.memo(It);function It({routes:e,future:t,state:r,onError:n}){return $e(e,void 0,r,n,t)}function gr({basename:e,children:t,initialEntries:r,initialIndex:n,unstable_useTransitions:a}){let o=i.useRef();o.current==null&&(o.current=De({initialEntries:r,initialIndex:n,v5Compat:!0}));let l=o.current,[s,u]=i.useState({action:l.action,location:l.location}),c=i.useCallback(h=>{a===!1?u(h):i.startTransition(()=>u(h))},[a]);return i.useLayoutEffect(()=>l.listen(c),[l,c]),i.createElement(le,{basename:e,children:t,location:s.location,navigationType:s.action,navigator:l,unstable_useTransitions:a})}function vr({to:e,replace:t,state:r,relative:n}){E(F(),"<Navigate> may be used only in the context of a <Router> component.");let{static:a}=i.useContext(b);C(!a,"<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.");let{matches:o}=i.useContext(S),{pathname:l}=L(),s=ne(),u=te(e,ee(o),l,n==="path"),c=JSON.stringify(u);return i.useEffect(()=>{s(JSON.parse(c),{replace:t,state:r,relative:n})},[s,c,n,t,r]),null}function Rr(e){return Rt(e.context)}function Nt(e){E(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function le({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:o=!1,unstable_useTransitions:l}){E(!F(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let s=e.replace(/^\/*/,"/"),u=i.useMemo(()=>({basename:s,navigator:a,static:o,unstable_useTransitions:l,future:{}}),[s,a,o,l]);typeof r=="string"&&(r=T(r));let{pathname:c="/",search:h="",hash:f="",state:g=null,key:d="default"}=r,v=i.useMemo(()=>{let y=k(c,s);return y==null?null:{location:{pathname:y,search:h,hash:f,state:g,key:d},navigationType:n}},[s,c,h,f,g,d,n]);return C(v!=null,`<Router basename="${s}"> is not able to match the URL "${c}${h}${f}" because it does not start with the basename, so the <Router> won't render anything.`),v==null?null:i.createElement(b.Provider,{value:u},i.createElement(A.Provider,{children:t,value:v}))}function wr({children:e,location:t}){return wt(Q(e),t)}function Q(e,t=[]){let r=[];return i.Children.forEach(e,(n,a)=>{if(!i.isValidElement(n))return;let o=[...t,a];if(n.type===i.Fragment){r.push.apply(r,Q(n.props.children,o));return}E(n.type===Nt,`[${typeof n.type=="string"?n.type:n.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),E(!n.props.index||!n.props.children,"An index route cannot have child routes.");let l={id:n.props.id||o.join("-"),caseSensitive:n.props.caseSensitive,element:n.props.element,Component:n.props.Component,index:n.props.index,path:n.props.path,middleware:n.props.middleware,loader:n.props.loader,action:n.props.action,hydrateFallbackElement:n.props.hydrateFallbackElement,HydrateFallback:n.props.HydrateFallback,errorElement:n.props.errorElement,ErrorBoundary:n.props.ErrorBoundary,hasErrorBoundary:n.props.hasErrorBoundary===!0||n.props.ErrorBoundary!=null||n.props.errorElement!=null,shouldRevalidate:n.props.shouldRevalidate,handle:n.props.handle,lazy:n.props.lazy};n.props.children&&(l.children=Q(n.props.children,o)),r.push(l)}),r}var J="get",V="application/x-www-form-urlencoded";function Y(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Ft(e){return Y(e)&&e.tagName.toLowerCase()==="button"}function Mt(e){return Y(e)&&e.tagName.toLowerCase()==="form"}function Dt(e){return Y(e)&&e.tagName.toLowerCase()==="input"}function Ut(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function At(e,t){return e.button===0&&(!t||t==="_self")&&!Ut(e)}function Z(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let n=e[r];return t.concat(Array.isArray(n)?n.map(a=>[r,a]):[[r,n]])},[]))}function Bt(e,t){let r=Z(e);return t&&t.forEach((n,a)=>{r.has(a)||t.getAll(a).forEach(o=>{r.append(a,o)})}),r}var z=null;function Ht(){if(z===null)try{new FormData(document.createElement("form"),0),z=!1}catch{z=!0}return z}var _t=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function X(e){return e!=null&&!_t.has(e)?(C(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${V}"`),null):e}function Wt(e,t){let r,n,a,o,l;if(Mt(e)){let s=e.getAttribute("action");n=s?k(s,t):null,r=e.getAttribute("method")||J,a=X(e.getAttribute("enctype"))||V,o=new FormData(e)}else if(Ft(e)||Dt(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let u=e.getAttribute("formaction")||s.getAttribute("action");if(n=u?k(u,t):null,r=e.getAttribute("formmethod")||s.getAttribute("method")||J,a=X(e.getAttribute("formenctype"))||X(s.getAttribute("enctype"))||V,o=new FormData(s,e),!Ht()){let{name:c,type:h,value:f}=e;if(h==="image"){let g=c?`${c}.`:"";o.append(`${g}x`,"0"),o.append(`${g}y`,"0")}else c&&o.append(c,f)}}else{if(Y(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=J,n=null,a=V,l=e}return o&&a==="text/plain"&&(l=o,o=void 0),{action:n,method:r.toLowerCase(),encType:a,formData:o,body:l}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function ie(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function jt(e,t,r,n){let a=typeof e=="string"?new URL(e,typeof window>"u"?"server://singlefetch/":window.location.origin):e;return r?a.pathname.endsWith("/")?a.pathname=`${a.pathname}_.${n}`:a.pathname=`${a.pathname}.${n}`:a.pathname==="/"?a.pathname=`_root.${n}`:t&&k(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${n}`,a}async function zt(e,t){if(e.id in t)return t[e.id];try{let r=await import(e.module);return t[e.id]=r,r}catch(r){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function Jt(e){return e==null?!1:e.href==null?e.rel==="preload"&&typeof e.imageSrcSet=="string"&&typeof e.imageSizes=="string":typeof e.rel=="string"&&typeof e.href=="string"}async function Vt(e,t,r){let n=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let l=await zt(o,r);return l.links?l.links():[]}return[]}));return Gt(n.flat(1).filter(Jt).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function pe(e,t,r,n,a,o){let l=(u,c)=>r[c]?u.route.id!==r[c].route.id:!0,s=(u,c)=>r[c].pathname!==u.pathname||r[c].route.path?.endsWith("*")&&r[c].params["*"]!==u.params["*"];return o==="assets"?t.filter((u,c)=>l(u,c)||s(u,c)):o==="data"?t.filter((u,c)=>{let h=n.routes[u.route.id];if(!h||!h.hasLoader)return!1;if(l(u,c)||s(u,c))return!0;if(u.route.shouldRevalidate){let f=u.route.shouldRevalidate({currentUrl:new URL(a.pathname+a.search+a.hash,window.origin),currentParams:r[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:u.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function Kt(e,t,{includeHydrateFallback:r}={}){return Yt(e.map(n=>{let a=t.routes[n.route.id];if(!a)return[];let o=[a.module];return a.clientActionModule&&(o=o.concat(a.clientActionModule)),a.clientLoaderModule&&(o=o.concat(a.clientLoaderModule)),r&&a.hydrateFallbackModule&&(o=o.concat(a.hydrateFallbackModule)),a.imports&&(o=o.concat(a.imports)),o}).flat(1))}function Yt(e){return[...new Set(e)]}function qt(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function Gt(e,t){let r=new Set;return new Set(t),e.reduce((n,a)=>{let o=JSON.stringify(qt(a));return r.has(o)||(r.add(o),n.push({key:o,link:a})),n},[])}function Oe(){let e=i.useContext(U);return ie(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Xt(){let e=i.useContext(K);return ie(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var se=i.createContext(void 0);se.displayName="FrameworkContext";function Ie(){let e=i.useContext(se);return ie(e,"You must render this element inside a <HydratedRouter> element"),e}function Qt(e,t){let r=i.useContext(se),[n,a]=i.useState(!1),[o,l]=i.useState(!1),{onFocus:s,onBlur:u,onMouseEnter:c,onMouseLeave:h,onTouchStart:f}=t,g=i.useRef(null);i.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let y=R=>{R.forEach(p=>{l(p.isIntersecting)})},m=new IntersectionObserver(y,{threshold:.5});return g.current&&m.observe(g.current),()=>{m.disconnect()}}},[e]),i.useEffect(()=>{if(n){let y=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(y)}}},[n]);let d=()=>{a(!0)},v=()=>{a(!1),l(!1)};return r?e!=="intent"?[o,g,{}]:[o,g,{onFocus:H(s,d),onBlur:H(u,v),onMouseEnter:H(c,d),onMouseLeave:H(h,v),onTouchStart:H(f,d)}]:[!1,g,{}]}function H(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function Zt({page:e,...t}){let{router:r}=Oe(),n=i.useMemo(()=>ye(r.routes,e,r.basename),[r.routes,e,r.basename]);return n?i.createElement(tr,{page:e,matches:n,...t}):null}function er(e){let{manifest:t,routeModules:r}=Ie(),[n,a]=i.useState([]);return i.useEffect(()=>{let o=!1;return Vt(e,t,r).then(l=>{o||a(l)}),()=>{o=!0}},[e,t,r]),n}function tr({page:e,matches:t,...r}){let n=L(),{future:a,manifest:o,routeModules:l}=Ie(),{basename:s}=Oe(),{loaderData:u,matches:c}=Xt(),h=i.useMemo(()=>pe(e,t,c,o,n,"data"),[e,t,c,o,n]),f=i.useMemo(()=>pe(e,t,c,o,n,"assets"),[e,t,c,o,n]),g=i.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let y=new Set,m=!1;if(t.forEach(p=>{let w=o.routes[p.route.id];!w||!w.hasLoader||(!h.some(P=>P.route.id===p.route.id)&&p.route.id in u&&l[p.route.id]?.shouldRevalidate||w.hasClientLoader?m=!0:y.add(p.route.id))}),y.size===0)return[];let R=jt(e,s,a.unstable_trailingSlashAwareDataRequests,"data");return m&&y.size>0&&R.searchParams.set("_routes",t.filter(p=>y.has(p.route.id)).map(p=>p.route.id).join(",")),[R.pathname+R.search]},[s,a.unstable_trailingSlashAwareDataRequests,u,n,o,h,t,e,l]),d=i.useMemo(()=>Kt(f,o),[f,o]),v=er(f);return i.createElement(i.Fragment,null,g.map(y=>i.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...r})),d.map(y=>i.createElement("link",{key:y,rel:"modulepreload",href:y,...r})),v.map(({key:y,link:m})=>i.createElement("link",{key:y,nonce:r.nonce,...m})))}function rr(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var nr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{nr&&(window.__reactRouterVersion="7.12.0")}catch{}function Er({basename:e,children:t,unstable_useTransitions:r,window:n}){let a=i.useRef();a.current==null&&(a.current=Ue({window:n,v5Compat:!0}));let o=a.current,[l,s]=i.useState({action:o.action,location:o.location}),u=i.useCallback(c=>{r===!1?s(c):i.startTransition(()=>s(c))},[r]);return i.useLayoutEffect(()=>o.listen(u),[o,u]),i.createElement(le,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,unstable_useTransitions:r})}function xr({basename:e,children:t,unstable_useTransitions:r,window:n}){let a=i.useRef();a.current==null&&(a.current=Ae({window:n,v5Compat:!0}));let o=a.current,[l,s]=i.useState({action:o.action,location:o.location}),u=i.useCallback(c=>{r===!1?s(c):i.startTransition(()=>s(c))},[r]);return i.useLayoutEffect(()=>o.listen(u),[o,u]),i.createElement(le,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,unstable_useTransitions:r})}var Ne=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fe=i.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:o,replace:l,state:s,target:u,to:c,preventScrollReset:h,viewTransition:f,unstable_defaultShouldRevalidate:g,...d},v){let{basename:y,unstable_useTransitions:m}=i.useContext(b),R=typeof c=="string"&&Ne.test(c),p=xe(c,y);c=p.to;let w=yt(c,{relative:a}),[P,x,O]=Qt(n,d),I=ir(c,{replace:l,state:s,target:u,preventScrollReset:h,relative:a,viewTransition:f,unstable_defaultShouldRevalidate:g,unstable_useTransitions:m});function M(B){t&&t(B),B.defaultPrevented||I(B)}let D=i.createElement("a",{...d,...O,href:p.absoluteURL||w,onClick:p.isExternal||o?t:M,ref:rr(v,x),target:u,"data-discover":!R&&r==="render"?"true":void 0});return P&&!R?i.createElement(i.Fragment,null,D,i.createElement(Zt,{page:w})):D});Fe.displayName="Link";var ar=i.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:o,to:l,viewTransition:s,children:u,...c},h){let f=j(l,{relative:c.relative}),g=L(),d=i.useContext(K),{navigator:v,basename:y}=i.useContext(b),m=d!=null&&hr(f)&&s===!0,R=v.encodeLocation?v.encodeLocation(f).pathname:f.pathname,p=g.pathname,w=d&&d.navigation&&d.navigation.location?d.navigation.location.pathname:null;r||(p=p.toLowerCase(),w=w?w.toLowerCase():null,R=R.toLowerCase()),w&&y&&(w=k(w,y)||w);const P=R!=="/"&&R.endsWith("/")?R.length-1:R.length;let x=p===R||!a&&p.startsWith(R)&&p.charAt(P)==="/",O=w!=null&&(w===R||!a&&w.startsWith(R)&&w.charAt(R.length)==="/"),I={isActive:x,isPending:O,isTransitioning:m},M=x?t:void 0,D;typeof n=="function"?D=n(I):D=[n,x?"active":null,O?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(I):o;return i.createElement(Fe,{...c,"aria-current":M,className:D,ref:h,style:B,to:l,viewTransition:s},typeof u=="function"?u(I):u)});ar.displayName="NavLink";var or=i.forwardRef(({discover:e="render",fetcherKey:t,navigate:r,reloadDocument:n,replace:a,state:o,method:l=J,action:s,onSubmit:u,relative:c,preventScrollReset:h,viewTransition:f,unstable_defaultShouldRevalidate:g,...d},v)=>{let{unstable_useTransitions:y}=i.useContext(b),m=cr(),R=fr(s,{relative:c}),p=l.toLowerCase()==="get"?"get":"post",w=typeof s=="string"&&Ne.test(s),P=x=>{if(u&&u(x),x.defaultPrevented)return;x.preventDefault();let O=x.nativeEvent.submitter,I=O?.getAttribute("formmethod")||l,M=()=>m(O||x.currentTarget,{fetcherKey:t,method:I,navigate:r,replace:a,state:o,relative:c,preventScrollReset:h,viewTransition:f,unstable_defaultShouldRevalidate:g});y&&r!==!1?i.startTransition(()=>M()):M()};return i.createElement("form",{ref:v,method:p,action:R,onSubmit:n?u:P,...d,"data-discover":!w&&e==="render"?"true":void 0})});or.displayName="Form";function lr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Me(e){let t=i.useContext(U);return E(t,lr(e)),t}function ir(e,{target:t,replace:r,state:n,preventScrollReset:a,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:s,unstable_useTransitions:u}={}){let c=ne(),h=L(),f=j(e,{relative:o});return i.useCallback(g=>{if(At(g,t)){g.preventDefault();let d=r!==void 0?r:N(h)===N(f),v=()=>c(e,{replace:d,state:n,preventScrollReset:a,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:s});u?i.startTransition(()=>v()):v()}},[h,c,f,r,n,t,e,a,o,l,s,u])}function Cr(e){C(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let t=i.useRef(Z(e)),r=i.useRef(!1),n=L(),a=i.useMemo(()=>Bt(n.search,r.current?null:t.current),[n.search]),o=ne(),l=i.useCallback((s,u)=>{const c=Z(typeof s=="function"?s(new URLSearchParams(a)):s);r.current=!0,o("?"+c,u)},[o,a]);return[a,l]}var sr=0,ur=()=>`__${String(++sr)}__`;function cr(){let{router:e}=Me("useSubmit"),{basename:t}=i.useContext(b),r=kt(),n=e.fetch,a=e.navigate;return i.useCallback(async(o,l={})=>{let{action:s,method:u,encType:c,formData:h,body:f}=Wt(o,t);if(l.navigate===!1){let g=l.fetcherKey||ur();await n(g,r,l.action||s,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:h,body:f,formMethod:l.method||u,formEncType:l.encType||c,flushSync:l.flushSync})}else await a(l.action||s,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:h,body:f,formMethod:l.method||u,formEncType:l.encType||c,replace:l.replace,state:l.state,fromRouteId:r,flushSync:l.flushSync,viewTransition:l.viewTransition})},[n,a,t,r])}function fr(e,{relative:t}={}){let{basename:r}=i.useContext(b),n=i.useContext(S);E(n,"useFormAction must be used inside a RouteContext");let[a]=n.matches.slice(-1),o={...j(e||".",{relative:t})},l=L();if(e==null){o.search=l.search;let s=new URLSearchParams(o.search),u=s.getAll("index");if(u.some(h=>h==="")){s.delete("index"),u.filter(f=>f).forEach(f=>s.append("index",f));let h=s.toString();o.search=h?`?${h}`:""}}return(!e||e===".")&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(o.pathname=o.pathname==="/"?r:$([r,o.pathname])),N(o)}function hr(e,{relative:t}={}){let r=i.useContext(be);E(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=Me("useViewTransitionState"),a=j(e,{relative:t});if(!r.isTransitioning)return!1;let o=k(r.currentLocation.pathname,n)||r.currentLocation.pathname,l=k(r.nextLocation.pathname,n)||r.nextLocation.pathname;return W(a.pathname,l)!=null||W(a.pathname,o)!=null}export{Er as B,xr as H,Fe as L,gr as M,ar as N,Rr as O,wr as R,pr as a,ne as b,Nt as c,yr as d,vr as e,yt as f,F as g,mr as h,j as i,Cr as j,L as u};
|