@saga-ai/dashboard 3.0.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/README.md +62 -0
- package/dist/cli.cjs +1736 -0
- package/dist/client/assets/index-BBUWGVOv.css +1 -0
- package/dist/client/assets/index-C_MbLZJP.js +15 -0
- package/dist/client/assets/vendor-markdown-Cy8XX9Jb.js +29 -0
- package/dist/client/assets/vendor-radix-BuqlnHDi.js +6 -0
- package/dist/client/assets/vendor-react-BQ8AP4vp.js +3 -0
- package/dist/client/assets/vendor-xstate-Dogcz2PC.js +3 -0
- package/dist/client/index.html +18 -0
- package/package.json +112 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{r as i}from"./vendor-xstate-Dogcz2PC.js";var oe="popstate";function Fe(e={}){function t(n,a){let{pathname:o,search:l,hash:s}=n.location;return X("",{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:B(a)}return Ie(t,r,null,e)}function E(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function P(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function De(){return Math.random().toString(36).substring(2,10)}function le(e,t){return{usr:e.state,key:e.key,idx:t}}function X(e,t,r=null,n){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?I(t):t,state:r,key:t&&t.key||n||De()}}function B({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 I(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 Ie(e,t,r,n={}){let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,s="POP",u=null,c=d();c==null&&(c=0,l.replaceState({...l.state,idx:c},""));function d(){return(l.state||{idx:null}).idx}function f(){s="POP";let p=d(),v=p==null?null:p-c;c=p,u&&u({action:s,location:g.location,delta:v})}function m(p,v){s="PUSH";let h=X(g.location,p,v);c=d()+1;let w=le(h,c),C=g.createHref(h);try{l.pushState(w,"",C)}catch(x){if(x instanceof DOMException&&x.name==="DataCloneError")throw x;a.location.assign(C)}o&&u&&u({action:s,location:g.location,delta:1})}function y(p,v){s="REPLACE";let h=X(g.location,p,v);c=d();let w=le(h,c),C=g.createHref(h);l.replaceState(w,"",C),o&&u&&u({action:s,location:g.location,delta:0})}function R(p){return Ne(p)}let g={get action(){return s},get location(){return e(a,l)},listen(p){if(u)throw new Error("A history only accepts one active listener");return a.addEventListener(oe,f),u=p,()=>{a.removeEventListener(oe,f),u=null}},createHref(p){return t(a,p)},createURL:R,encodeLocation(p){let v=R(p);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:y,go(p){return l.go(p)}};return g}function Ne(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:B(e);return n=n.replace(/ $/,"%20"),!t&&n.startsWith("//")&&(n=r+n),new URL(n,r)}function fe(e,t,r="/"){return Me(e,t,r,!1)}function Me(e,t,r,n){let a=typeof t=="string"?I(t):t,o=$(a.pathname||"/",r);if(o==null)return null;let l=de(e);Ue(l);let s=null;for(let u=0;s==null&&u<l.length;++u){let c=Ye(o);s=Je(l[u],c,n)}return s}function de(e,t=[],r=[],n="",a=!1){let o=(l,s,u=a,c)=>{let d={relativePath:c===void 0?l.path||"":c,caseSensitive:l.caseSensitive===!0,childrenIndex:s,route:l};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(n)&&u)return;E(d.relativePath.startsWith(n),`Absolute route path "${d.relativePath}" nested under path "${n}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(n.length)}let f=L([n,d.relativePath]),m=r.concat(d);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}".`),de(l.children,t,m,f,u)),!(l.path==null&&!l.index)&&t.push({path:f,score:ze(f,l.index),routesMeta:m})};return e.forEach((l,s)=>{if(l.path===""||!l.path?.includes("?"))o(l,s);else for(let u of he(l.path))o(l,s,!0,u)}),t}function he(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=he(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 Ue(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:Ve(t.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}var Be=/^:[\w-]+$/,Ae=3,_e=2,We=1,He=10,je=-2,ie=e=>e==="*";function ze(e,t){let r=e.split("/"),n=r.length;return r.some(ie)&&(n+=je),t&&(n+=_e),r.filter(a=>!ie(a)).reduce((a,o)=>a+(Be.test(o)?Ae:o===""?We:He),n)}function Ve(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 Je(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,d=o==="/"?t:t.slice(o.length)||"/",f=V({path:u.relativePath,caseSensitive:u.caseSensitive,end:c},d),m=u.route;if(!f&&c&&r&&!n[n.length-1].route.index&&(f=V({path:u.relativePath,caseSensitive:u.caseSensitive,end:!1},d)),!f)return null;Object.assign(a,f.params),l.push({params:a,pathname:L([o,f.pathname]),pathnameBase:Qe(L([o,f.pathnameBase])),route:m}),f.pathnameBase!=="/"&&(o=L([o,f.pathnameBase]))}return l}function V(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,n]=Ke(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:d,isOptional:f},m)=>{if(d==="*"){let R=s[m]||"";l=o.slice(0,o.length-R.length).replace(/(.)\/+$/,"$1")}const y=s[m];return f&&!y?c[d]=void 0:c[d]=(y||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:l,pattern:e}}function Ke(e,t=!1,r=!0){P(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 Ye(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return P(!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 $(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 Ge=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function qe(e,t="/"){let{pathname:r,search:n="",hash:a=""}=typeof e=="string"?I(e):e,o;return r?(r=r.replace(/\/\/+/g,"/"),r.startsWith("/")?o=se(r.substring(1),"/"):o=se(r,t)):o=t,{pathname:o,search:Ze(n),hash:et(a)}}function se(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 Y(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 Xe(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function pe(e){let t=Xe(e);return t.map((r,n)=>n===t.length-1?r.pathname:r.pathnameBase)}function me(e,t,r,n=!1){let a;typeof e=="string"?a=I(e):(a={...e},E(!a.pathname||!a.pathname.includes("?"),Y("?","pathname","search",a)),E(!a.pathname||!a.pathname.includes("#"),Y("#","pathname","hash",a)),E(!a.search||!a.search.includes("#"),Y("#","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 m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;a.pathname=m.join("/")}s=f>=0?t[f]:"/"}let u=qe(a,s),c=l&&l!=="/"&&l.endsWith("/"),d=(o||l===".")&&r.endsWith("/");return!u.pathname.endsWith("/")&&(c||d)&&(u.pathname+="/"),u}var L=e=>e.join("/").replace(/\/\/+/g,"/"),Qe=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ze=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,et=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,tt=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 rt(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function nt(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var ye=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ge(e,t){let r=e;if(typeof r!="string"||!Ge.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let n=r,a=!1;if(ye)try{let o=new URL(window.location.href),l=r.startsWith("//")?new URL(o.protocol+r):new URL(r),s=$(l.pathname,t);l.origin===o.origin&&s!=null?r=s+l.search+l.hash:a=!0}catch{P(!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 ve=["POST","PUT","PATCH","DELETE"];new Set(ve);var at=["GET",...ve];new Set(at);var N=i.createContext(null);N.displayName="DataRouter";var J=i.createContext(null);J.displayName="DataRouterState";var ot=i.createContext(!1),Re=i.createContext({isTransitioning:!1});Re.displayName="ViewTransition";var lt=i.createContext(new Map);lt.displayName="Fetchers";var it=i.createContext(null);it.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 ee=i.createContext(null);ee.displayName="RouteError";var we="REACT_ROUTER_ERROR",st="REDIRECT",ut="ROUTE_ERROR_RESPONSE";function ct(e){if(e.startsWith(`${we}:${st}:{`))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 ft(e){if(e.startsWith(`${we}:${ut}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new tt(t.status,t.statusText,t.data)}catch{}}function dt(e,{relative:t}={}){E(_(),"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}=W(e,{relative:t}),s=o;return r!=="/"&&(s=o==="/"?r:L([r,o])),n.createHref({pathname:s,search:l,hash:a})}function _(){return i.useContext(A)!=null}function k(){return E(_(),"useLocation() may be used only in the context of a <Router> component."),i.useContext(A).location}var Ee="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function xe(e){i.useContext(b).static||i.useLayoutEffect(e)}function Ce(){let{isDataRoute:e}=i.useContext(S);return e?Lt():ht()}function ht(){E(_(),"useNavigate() may be used only in the context of a <Router> component.");let e=i.useContext(N),{basename:t,navigator:r}=i.useContext(b),{matches:n}=i.useContext(S),{pathname:a}=k(),o=JSON.stringify(pe(n)),l=i.useRef(!1);return xe(()=>{l.current=!0}),i.useCallback((u,c={})=>{if(P(l.current,Ee),!l.current)return;if(typeof u=="number"){r.go(u);return}let d=me(u,JSON.parse(o),a,c.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:L([t,d.pathname])),(c.replace?r.replace:r.push)(d,c.state,c)},[t,r,o,a,e])}var pt=i.createContext(null);function mt(e){let t=i.useContext(S).outlet;return i.useMemo(()=>t&&i.createElement(pt.Provider,{value:e},t),[t,e])}function fr(){let{matches:e}=i.useContext(S),t=e[e.length-1];return t?t.params:{}}function W(e,{relative:t}={}){let{matches:r}=i.useContext(S),{pathname:n}=k(),a=JSON.stringify(pe(r));return i.useMemo(()=>me(e,JSON.parse(a),n,t==="path"),[e,a,n,t])}function yt(e,t){return be(e,t)}function be(e,t,r,n,a){E(_(),"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:"/",d=s?s.pathnameBase:"/",f=s&&s.route;{let h=f&&f.path||"";Se(c,!f||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${h}">) 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="${h}"> to <Route path="${h==="/"?"*":`${h}/*`}">.`)}let m=k(),y;if(t){let h=typeof t=="string"?I(t):t;E(d==="/"||h.pathname?.startsWith(d),`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 "${d}" but pathname "${h.pathname}" was given in the \`location\` prop.`),y=h}else y=m;let R=y.pathname||"/",g=R;if(d!=="/"){let h=d.replace(/^\//,"").split("/");g="/"+R.replace(/^\//,"").split("/").slice(h.length).join("/")}let p=fe(e,{pathname:g});P(f||p!=null,`No routes matched location "${y.pathname}${y.search}${y.hash}" `),P(p==null||p[p.length-1].route.element!==void 0||p[p.length-1].route.Component!==void 0||p[p.length-1].route.lazy!==void 0,`Matched leaf route at location "${y.pathname}${y.search}${y.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 v=Et(p&&p.map(h=>Object.assign({},h,{params:Object.assign({},u,h.params),pathname:L([d,o.encodeLocation?o.encodeLocation(h.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?d:L([d,o.encodeLocation?o.encodeLocation(h.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),l,r,n,a);return t&&v?i.createElement(A.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...y},navigationType:"POP"}},v):v}function gt(){let e=St(),t=rt(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 vt=i.createElement(gt,null),Pe=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=ft(e.digest);r&&(e=r)}let t=e!==void 0?i.createElement(S.Provider,{value:this.props.routeContext},i.createElement(ee.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?i.createElement(Rt,{error:e},t):t}};Pe.contextType=ot;var G=new WeakMap;function Rt({children:e,error:t}){let{basename:r}=i.useContext(b);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let n=ct(t.digest);if(n){let a=G.get(t);if(a)throw a;let o=ge(n.location,r);if(ye&&!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 wt({routeContext:e,match:t,children:r}){let n=i.useContext(N);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 Et(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 d=o.findIndex(f=>f.route.id&&l?.[f.route.id]!==void 0);E(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(l).join(",")}`),o=o.slice(0,Math.min(o.length,d+1))}let s=!1,u=-1;if(r)for(let d=0;d<o.length;d++){let f=o[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(u=d),f.route.id){let{loaderData:m,errors:y}=r,R=f.route.loader&&!m.hasOwnProperty(f.route.id)&&(!y||y[f.route.id]===void 0);if(f.route.lazy||R){s=!0,u>=0?o=o.slice(0,u+1):o=[o[0]];break}}}let c=r&&n?(d,f)=>{n(d,{location:r.location,params:r.matches?.[0]?.params??{},unstable_pattern:nt(r.matches),errorInfo:f})}:void 0;return o.reduceRight((d,f,m)=>{let y,R=!1,g=null,p=null;r&&(y=l&&f.route.id?l[f.route.id]:void 0,g=f.route.errorElement||vt,s&&(u<0&&m===0?(Se("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),R=!0,p=null):u===m&&(R=!0,p=f.route.hydrateFallbackElement||null)));let v=t.concat(o.slice(0,m+1)),h=()=>{let w;return y?w=g:R?w=p:f.route.Component?w=i.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=d,i.createElement(wt,{match:f,routeContext:{outlet:d,matches:v,isDataRoute:r!=null},children:w})};return r&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?i.createElement(Pe,{location:r.location,revalidation:r.revalidation,component:g,error:y,children:h(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:c}):h()},null)}function te(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xt(e){let t=i.useContext(N);return E(t,te(e)),t}function Ct(e){let t=i.useContext(J);return E(t,te(e)),t}function bt(e){let t=i.useContext(S);return E(t,te(e)),t}function re(e){let t=bt(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 Pt(){return re("useRouteId")}function St(){let e=i.useContext(ee),t=Ct("useRouteError"),r=re("useRouteError");return e!==void 0?e:t.errors?.[r]}function Lt(){let{router:e}=xt("useNavigate"),t=re("useNavigate"),r=i.useRef(!1);return xe(()=>{r.current=!0}),i.useCallback(async(a,o={})=>{P(r.current,Ee),r.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var ue={};function Se(e,t,r){!t&&!ue[e]&&(ue[e]=!0,P(!1,r))}i.memo($t);function $t({routes:e,future:t,state:r,onError:n}){return be(e,void 0,r,n,t)}function dr(e){return mt(e.context)}function kt(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 Tt({basename:e="/",children:t=null,location:r,navigationType:n="POP",navigator:a,static:o=!1,unstable_useTransitions:l}){E(!_(),"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=I(r));let{pathname:c="/",search:d="",hash:f="",state:m=null,key:y="default"}=r,R=i.useMemo(()=>{let g=$(c,s);return g==null?null:{location:{pathname:g,search:d,hash:f,state:m,key:y},navigationType:n}},[s,c,d,f,m,y,n]);return P(R!=null,`<Router basename="${s}"> is not able to match the URL "${c}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),R==null?null:i.createElement(b.Provider,{value:u},i.createElement(A.Provider,{children:t,value:R}))}function hr({children:e,location:t}){return yt(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===kt,`[${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",z="application/x-www-form-urlencoded";function K(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function Ot(e){return K(e)&&e.tagName.toLowerCase()==="button"}function Ft(e){return K(e)&&e.tagName.toLowerCase()==="form"}function Dt(e){return K(e)&&e.tagName.toLowerCase()==="input"}function It(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Nt(e,t){return e.button===0&&(!t||t==="_self")&&!It(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 Mt(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 H=null;function Ut(){if(H===null)try{new FormData(document.createElement("form"),0),H=!1}catch{H=!0}return H}var Bt=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function q(e){return e!=null&&!Bt.has(e)?(P(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${z}"`),null):e}function At(e,t){let r,n,a,o,l;if(Ft(e)){let s=e.getAttribute("action");n=s?$(s,t):null,r=e.getAttribute("method")||j,a=q(e.getAttribute("enctype"))||z,o=new FormData(e)}else if(Ot(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?$(u,t):null,r=e.getAttribute("formmethod")||s.getAttribute("method")||j,a=q(e.getAttribute("formenctype"))||q(s.getAttribute("enctype"))||z,o=new FormData(s,e),!Ut()){let{name:c,type:d,value:f}=e;if(d==="image"){let m=c?`${c}.`:"";o.append(`${m}x`,"0"),o.append(`${m}y`,"0")}else c&&o.append(c,f)}}else{if(K(e))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=j,n=null,a=z,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 ne(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function _t(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&&$(a.pathname,t)==="/"?a.pathname=`${t.replace(/\/$/,"")}/_root.${n}`:a.pathname=`${a.pathname.replace(/\/$/,"")}.${n}`,a}async function Wt(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 Ht(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 jt(e,t,r){let n=await Promise.all(e.map(async a=>{let o=t.routes[a.route.id];if(o){let l=await Wt(o,r);return l.links?l.links():[]}return[]}));return Kt(n.flat(1).filter(Ht).filter(a=>a.rel==="stylesheet"||a.rel==="preload").map(a=>a.rel==="stylesheet"?{...a,rel:"prefetch",as:"style"}:{...a,rel:"prefetch"}))}function ce(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 d=n.routes[u.route.id];if(!d||!d.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 zt(e,t,{includeHydrateFallback:r}={}){return Vt(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 Vt(e){return[...new Set(e)]}function Jt(e){let t={},r=Object.keys(e).sort();for(let n of r)t[n]=e[n];return t}function Kt(e,t){let r=new Set;return new Set(t),e.reduce((n,a)=>{let o=JSON.stringify(Jt(a));return r.has(o)||(r.add(o),n.push({key:o,link:a})),n},[])}function Le(){let e=i.useContext(N);return ne(e,"You must render this element inside a <DataRouterContext.Provider> element"),e}function Yt(){let e=i.useContext(J);return ne(e,"You must render this element inside a <DataRouterStateContext.Provider> element"),e}var ae=i.createContext(void 0);ae.displayName="FrameworkContext";function $e(){let e=i.useContext(ae);return ne(e,"You must render this element inside a <HydratedRouter> element"),e}function Gt(e,t){let r=i.useContext(ae),[n,a]=i.useState(!1),[o,l]=i.useState(!1),{onFocus:s,onBlur:u,onMouseEnter:c,onMouseLeave:d,onTouchStart:f}=t,m=i.useRef(null);i.useEffect(()=>{if(e==="render"&&l(!0),e==="viewport"){let g=v=>{v.forEach(h=>{l(h.isIntersecting)})},p=new IntersectionObserver(g,{threshold:.5});return m.current&&p.observe(m.current),()=>{p.disconnect()}}},[e]),i.useEffect(()=>{if(n){let g=setTimeout(()=>{l(!0)},100);return()=>{clearTimeout(g)}}},[n]);let y=()=>{a(!0)},R=()=>{a(!1),l(!1)};return r?e!=="intent"?[o,m,{}]:[o,m,{onFocus:U(s,y),onBlur:U(u,R),onMouseEnter:U(c,y),onMouseLeave:U(d,R),onTouchStart:U(f,y)}]:[!1,m,{}]}function U(e,t){return r=>{e&&e(r),r.defaultPrevented||t(r)}}function qt({page:e,...t}){let{router:r}=Le(),n=i.useMemo(()=>fe(r.routes,e,r.basename),[r.routes,e,r.basename]);return n?i.createElement(Qt,{page:e,matches:n,...t}):null}function Xt(e){let{manifest:t,routeModules:r}=$e(),[n,a]=i.useState([]);return i.useEffect(()=>{let o=!1;return jt(e,t,r).then(l=>{o||a(l)}),()=>{o=!0}},[e,t,r]),n}function Qt({page:e,matches:t,...r}){let n=k(),{future:a,manifest:o,routeModules:l}=$e(),{basename:s}=Le(),{loaderData:u,matches:c}=Yt(),d=i.useMemo(()=>ce(e,t,c,o,n,"data"),[e,t,c,o,n]),f=i.useMemo(()=>ce(e,t,c,o,n,"assets"),[e,t,c,o,n]),m=i.useMemo(()=>{if(e===n.pathname+n.search+n.hash)return[];let g=new Set,p=!1;if(t.forEach(h=>{let w=o.routes[h.route.id];!w||!w.hasLoader||(!d.some(C=>C.route.id===h.route.id)&&h.route.id in u&&l[h.route.id]?.shouldRevalidate||w.hasClientLoader?p=!0:g.add(h.route.id))}),g.size===0)return[];let v=_t(e,s,a.unstable_trailingSlashAwareDataRequests,"data");return p&&g.size>0&&v.searchParams.set("_routes",t.filter(h=>g.has(h.route.id)).map(h=>h.route.id).join(",")),[v.pathname+v.search]},[s,a.unstable_trailingSlashAwareDataRequests,u,n,o,d,t,e,l]),y=i.useMemo(()=>zt(f,o),[f,o]),R=Xt(f);return i.createElement(i.Fragment,null,m.map(g=>i.createElement("link",{key:g,rel:"prefetch",as:"fetch",href:g,...r})),y.map(g=>i.createElement("link",{key:g,rel:"modulepreload",href:g,...r})),R.map(({key:g,link:p})=>i.createElement("link",{key:g,nonce:r.nonce,...p,crossOrigin:p.crossOrigin??r.crossOrigin})))}function Zt(...e){return t=>{e.forEach(r=>{typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var er=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{er&&(window.__reactRouterVersion="7.13.0")}catch{}function pr({basename:e,children:t,unstable_useTransitions:r,window:n}){let a=i.useRef();a.current==null&&(a.current=Fe({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(Tt,{basename:e,children:t,location:l.location,navigationType:l.action,navigator:o,unstable_useTransitions:r})}var ke=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Te=i.forwardRef(function({onClick:t,discover:r="render",prefetch:n="none",relative:a,reloadDocument:o,replace:l,state:s,target:u,to:c,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...y},R){let{basename:g,unstable_useTransitions:p}=i.useContext(b),v=typeof c=="string"&&ke.test(c),h=ge(c,g);c=h.to;let w=dt(c,{relative:a}),[C,x,T]=Gt(n,y),O=ar(c,{replace:l,state:s,target:u,preventScrollReset:d,relative:a,viewTransition:f,unstable_defaultShouldRevalidate:m,unstable_useTransitions:p});function F(M){t&&t(M),M.defaultPrevented||O(M)}let D=i.createElement("a",{...y,...T,href:h.absoluteURL||w,onClick:h.isExternal||o?t:F,ref:Zt(R,x),target:u,"data-discover":!v&&r==="render"?"true":void 0});return C&&!v?i.createElement(i.Fragment,null,D,i.createElement(qt,{page:w})):D});Te.displayName="Link";var tr=i.forwardRef(function({"aria-current":t="page",caseSensitive:r=!1,className:n="",end:a=!1,style:o,to:l,viewTransition:s,children:u,...c},d){let f=W(l,{relative:c.relative}),m=k(),y=i.useContext(J),{navigator:R,basename:g}=i.useContext(b),p=y!=null&&ur(f)&&s===!0,v=R.encodeLocation?R.encodeLocation(f).pathname:f.pathname,h=m.pathname,w=y&&y.navigation&&y.navigation.location?y.navigation.location.pathname:null;r||(h=h.toLowerCase(),w=w?w.toLowerCase():null,v=v.toLowerCase()),w&&g&&(w=$(w,g)||w);const C=v!=="/"&&v.endsWith("/")?v.length-1:v.length;let x=h===v||!a&&h.startsWith(v)&&h.charAt(C)==="/",T=w!=null&&(w===v||!a&&w.startsWith(v)&&w.charAt(v.length)==="/"),O={isActive:x,isPending:T,isTransitioning:p},F=x?t:void 0,D;typeof n=="function"?D=n(O):D=[n,x?"active":null,T?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let M=typeof o=="function"?o(O):o;return i.createElement(Te,{...c,"aria-current":F,className:D,ref:d,style:M,to:l,viewTransition:s},typeof u=="function"?u(O):u)});tr.displayName="NavLink";var rr=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:d,viewTransition:f,unstable_defaultShouldRevalidate:m,...y},R)=>{let{unstable_useTransitions:g}=i.useContext(b),p=ir(),v=sr(s,{relative:c}),h=l.toLowerCase()==="get"?"get":"post",w=typeof s=="string"&&ke.test(s),C=x=>{if(u&&u(x),x.defaultPrevented)return;x.preventDefault();let T=x.nativeEvent.submitter,O=T?.getAttribute("formmethod")||l,F=()=>p(T||x.currentTarget,{fetcherKey:t,method:O,navigate:r,replace:a,state:o,relative:c,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:m});g&&r!==!1?i.startTransition(()=>F()):F()};return i.createElement("form",{ref:R,method:h,action:v,onSubmit:n?u:C,...y,"data-discover":!w&&e==="render"?"true":void 0})});rr.displayName="Form";function nr(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Oe(e){let t=i.useContext(N);return E(t,nr(e)),t}function ar(e,{target:t,replace:r,state:n,preventScrollReset:a,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:s,unstable_useTransitions:u}={}){let c=Ce(),d=k(),f=W(e,{relative:o});return i.useCallback(m=>{if(Nt(m,t)){m.preventDefault();let y=r!==void 0?r:B(d)===B(f),R=()=>c(e,{replace:y,state:n,preventScrollReset:a,relative:o,viewTransition:l,unstable_defaultShouldRevalidate:s});u?i.startTransition(()=>R()):R()}},[d,c,f,r,n,t,e,a,o,l,s,u])}function mr(e){P(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=k(),a=i.useMemo(()=>Mt(n.search,r.current?null:t.current),[n.search]),o=Ce(),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 or=0,lr=()=>`__${String(++or)}__`;function ir(){let{router:e}=Oe("useSubmit"),{basename:t}=i.useContext(b),r=Pt(),n=e.fetch,a=e.navigate;return i.useCallback(async(o,l={})=>{let{action:s,method:u,encType:c,formData:d,body:f}=At(o,t);if(l.navigate===!1){let m=l.fetcherKey||lr();await n(m,r,l.action||s,{unstable_defaultShouldRevalidate:l.unstable_defaultShouldRevalidate,preventScrollReset:l.preventScrollReset,formData:d,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:d,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 sr(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={...W(e||".",{relative:t})},l=k();if(e==null){o.search=l.search;let s=new URLSearchParams(o.search),u=s.getAll("index");if(u.some(d=>d==="")){s.delete("index"),u.filter(f=>f).forEach(f=>s.append("index",f));let d=s.toString();o.search=d?`?${d}`:""}}return(!e||e===".")&&a.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(o.pathname=o.pathname==="/"?r:L([r,o.pathname])),B(o)}function ur(e,{relative:t}={}){let r=i.useContext(Re);E(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:n}=Oe("useViewTransitionState"),a=W(e,{relative:t});if(!r.isTransitioning)return!1;let o=$(r.currentLocation.pathname,n)||r.currentLocation.pathname,l=$(r.nextLocation.pathname,n)||r.nextLocation.pathname;return V(a.pathname,l)!=null||V(a.pathname,o)!=null}export{pr as B,Te as L,dr as O,hr as R,mr as a,kt as b,fr as u};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function je(e,t){for(var n=0;n<t.length;n++){const s=t[n];if(typeof s!="string"&&!Array.isArray(s)){for(const r in s)if(r!=="default"&&!(r in e)){const i=Object.getOwnPropertyDescriptor(s,r);i&&Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>s[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function Me(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var lt={exports:{}},g={};var Wt;function De(){if(Wt)return g;Wt=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),a=Symbol.iterator;function p(o){return o===null||typeof o!="object"?null:(o=a&&o[a]||o["@@iterator"],typeof o=="function"?o:null)}var y={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,E={};function A(o,l,S){this.props=o,this.context=l,this.refs=E,this.updater=S||y}A.prototype.isReactComponent={},A.prototype.setState=function(o,l){if(typeof o!="object"&&typeof o!="function"&&o!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,o,l,"setState")},A.prototype.forceUpdate=function(o){this.updater.enqueueForceUpdate(this,o,"forceUpdate")};function $(){}$.prototype=A.prototype;function O(o,l,S){this.props=o,this.context=l,this.refs=E,this.updater=S||y}var D=O.prototype=new $;D.constructor=O,m(D,A.prototype),D.isPureReactComponent=!0;var X=Array.isArray;function k(){}var b={H:null,A:null,T:null,S:null},Z=Object.prototype.hasOwnProperty;function ft(o,l,S){var _=S.ref;return{$$typeof:e,type:o,key:l,ref:_!==void 0?_:null,props:S}}function Ie(o,l){return ft(o.type,l,o.props)}function ht(o){return typeof o=="object"&&o!==null&&o.$$typeof===e}function Re(o){var l={"=":"=0",":":"=2"};return"$"+o.replace(/[=:]/g,function(S){return l[S]})}var Ut=/\/+/g;function dt(o,l){return typeof o=="object"&&o!==null&&o.key!=null?Re(""+o.key):l.toString(36)}function ke(o){switch(o.status){case"fulfilled":return o.value;case"rejected":throw o.reason;default:switch(typeof o.status=="string"?o.then(k,k):(o.status="pending",o.then(function(l){o.status==="pending"&&(o.status="fulfilled",o.value=l)},function(l){o.status==="pending"&&(o.status="rejected",o.reason=l)})),o.status){case"fulfilled":return o.value;case"rejected":throw o.reason}}throw o}function U(o,l,S,_,w){var T=typeof o;(T==="undefined"||T==="boolean")&&(o=null);var x=!1;if(o===null)x=!0;else switch(T){case"bigint":case"string":case"number":x=!0;break;case"object":switch(o.$$typeof){case e:case t:x=!0;break;case v:return x=o._init,U(x(o._payload),l,S,_,w)}}if(x)return w=w(o),x=_===""?"."+dt(o,0):_,X(w)?(S="",x!=null&&(S=x.replace(Ut,"$&/")+"/"),U(w,l,S,"",function(Oe){return Oe})):w!=null&&(ht(w)&&(w=Ie(w,S+(w.key==null||o&&o.key===w.key?"":(""+w.key).replace(Ut,"$&/")+"/")+x)),l.push(w)),1;x=0;var j=_===""?".":_+":";if(X(o))for(var I=0;I<o.length;I++)_=o[I],T=j+dt(_,I),x+=U(_,l,S,T,w);else if(I=p(o),typeof I=="function")for(o=I.call(o),I=0;!(_=o.next()).done;)_=_.value,T=j+dt(_,I++),x+=U(_,l,S,T,w);else if(T==="object"){if(typeof o.then=="function")return U(ke(o),l,S,_,w);throw l=String(o),Error("Objects are not valid as a React child (found: "+(l==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":l)+"). If you meant to render a collection of children, use an array instead.")}return x}function F(o,l,S){if(o==null)return o;var _=[],w=0;return U(o,_,"","",function(T){return l.call(S,T,w++)}),_}function $e(o){if(o._status===-1){var l=o._result;l=l(),l.then(function(S){(o._status===0||o._status===-1)&&(o._status=1,o._result=S)},function(S){(o._status===0||o._status===-1)&&(o._status=2,o._result=S)}),o._status===-1&&(o._status=0,o._result=l)}if(o._status===1)return o._result.default;throw o._result}var Yt=typeof reportError=="function"?reportError:function(o){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var l=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof o=="object"&&o!==null&&typeof o.message=="string"?String(o.message):String(o),error:o});if(!window.dispatchEvent(l))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",o);return}console.error(o)},Ce={map:F,forEach:function(o,l,S){F(o,function(){l.apply(this,arguments)},S)},count:function(o){var l=0;return F(o,function(){l++}),l},toArray:function(o){return F(o,function(l){return l})||[]},only:function(o){if(!ht(o))throw Error("React.Children.only expected to receive a single React element child.");return o}};return g.Activity=f,g.Children=Ce,g.Component=A,g.Fragment=n,g.Profiler=r,g.PureComponent=O,g.StrictMode=s,g.Suspense=h,g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=b,g.__COMPILER_RUNTIME={__proto__:null,c:function(o){return b.H.useMemoCache(o)}},g.cache=function(o){return function(){return o.apply(null,arguments)}},g.cacheSignal=function(){return null},g.cloneElement=function(o,l,S){if(o==null)throw Error("The argument must be a React element, but you passed "+o+".");var _=m({},o.props),w=o.key;if(l!=null)for(T in l.key!==void 0&&(w=""+l.key),l)!Z.call(l,T)||T==="key"||T==="__self"||T==="__source"||T==="ref"&&l.ref===void 0||(_[T]=l[T]);var T=arguments.length-2;if(T===1)_.children=S;else if(1<T){for(var x=Array(T),j=0;j<T;j++)x[j]=arguments[j+2];_.children=x}return ft(o.type,w,_)},g.createContext=function(o){return o={$$typeof:u,_currentValue:o,_currentValue2:o,_threadCount:0,Provider:null,Consumer:null},o.Provider=o,o.Consumer={$$typeof:i,_context:o},o},g.createElement=function(o,l,S){var _,w={},T=null;if(l!=null)for(_ in l.key!==void 0&&(T=""+l.key),l)Z.call(l,_)&&_!=="key"&&_!=="__self"&&_!=="__source"&&(w[_]=l[_]);var x=arguments.length-2;if(x===1)w.children=S;else if(1<x){for(var j=Array(x),I=0;I<x;I++)j[I]=arguments[I+2];w.children=j}if(o&&o.defaultProps)for(_ in x=o.defaultProps,x)w[_]===void 0&&(w[_]=x[_]);return ft(o,T,w)},g.createRef=function(){return{current:null}},g.forwardRef=function(o){return{$$typeof:c,render:o}},g.isValidElement=ht,g.lazy=function(o){return{$$typeof:v,_payload:{_status:-1,_result:o},_init:$e}},g.memo=function(o,l){return{$$typeof:d,type:o,compare:l===void 0?null:l}},g.startTransition=function(o){var l=b.T,S={};b.T=S;try{var _=o(),w=b.S;w!==null&&w(S,_),typeof _=="object"&&_!==null&&typeof _.then=="function"&&_.then(k,Yt)}catch(T){Yt(T)}finally{l!==null&&S.types!==null&&(l.types=S.types),b.T=l}},g.unstable_useCacheRefresh=function(){return b.H.useCacheRefresh()},g.use=function(o){return b.H.use(o)},g.useActionState=function(o,l,S){return b.H.useActionState(o,l,S)},g.useCallback=function(o,l){return b.H.useCallback(o,l)},g.useContext=function(o){return b.H.useContext(o)},g.useDebugValue=function(){},g.useDeferredValue=function(o,l){return b.H.useDeferredValue(o,l)},g.useEffect=function(o,l){return b.H.useEffect(o,l)},g.useEffectEvent=function(o){return b.H.useEffectEvent(o)},g.useId=function(){return b.H.useId()},g.useImperativeHandle=function(o,l,S){return b.H.useImperativeHandle(o,l,S)},g.useInsertionEffect=function(o,l){return b.H.useInsertionEffect(o,l)},g.useLayoutEffect=function(o,l){return b.H.useLayoutEffect(o,l)},g.useMemo=function(o,l){return b.H.useMemo(o,l)},g.useOptimistic=function(o,l){return b.H.useOptimistic(o,l)},g.useReducer=function(o,l,S){return b.H.useReducer(o,l,S)},g.useRef=function(o){return b.H.useRef(o)},g.useState=function(o){return b.H.useState(o)},g.useSyncExternalStore=function(o,l,S){return b.H.useSyncExternalStore(o,l,S)},g.useTransition=function(){return b.H.useTransition()},g.version="19.2.4",g}var Jt;function It(){return Jt||(Jt=1,lt.exports=De()),lt.exports}var C=It();const Pe=Me(C),as=je({__proto__:null,default:Pe},[C]);var Le=C.useLayoutEffect;function He(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global}function qe(){const e=He();if(e.__xstate__)return e.__xstate__}const ze=e=>{if(typeof window>"u")return;const t=qe();t&&t.register(e)};class Gt{constructor(t){this._process=t,this._active=!1,this._current=null,this._last=null}start(){this._active=!0,this.flush()}clear(){this._current&&(this._current.next=null,this._last=this._current)}enqueue(t){const n={value:t,next:null};if(this._current){this._last.next=n,this._last=n;return}this._current=n,this._last=n,this._active&&this.flush()}flush(){for(;this._current;){const t=this._current;this._process(t.value),this._current=t.next}this._last=null}}const re=".",Ue="",ie="",Ye="#",We="*",oe="xstate.init",Je="xstate.error",et="xstate.stop";function Ge(e,t){return{type:`xstate.after.${e}.${t}`}}function bt(e,t){return{type:`xstate.done.state.${e}`,output:t}}function Be(e,t){return{type:`xstate.done.actor.${e}`,output:t,actorId:e}}function ce(e,t){return{type:`xstate.error.actor.${e}`,error:t,actorId:e}}function ue(e){return{type:oe,input:e}}function M(e){setTimeout(()=>{throw e})}const Ne=typeof Symbol=="function"&&Symbol.observable||"@@observable";function ae(e,t){const n=Bt(e),s=Bt(t);return typeof s=="string"?typeof n=="string"?s===n:!1:typeof n=="string"?n in s:Object.keys(n).every(r=>r in s?ae(n[r],s[r]):!1)}function Rt(e){if(he(e))return e;const t=[];let n="";for(let s=0;s<e.length;s++){switch(e.charCodeAt(s)){case 92:n+=e[s+1],s++;continue;case 46:t.push(n),n="";continue}n+=e[s]}return t.push(n),t}function Bt(e){if(In(e))return e.value;if(typeof e!="string")return e;const t=Rt(e);return Ke(t)}function Ke(e){if(e.length===1)return e[0];const t={};let n=t;for(let s=0;s<e.length-1;s++)if(s===e.length-2)n[e[s]]=e[s+1];else{const r=n;n={},r[e[s]]=n}return t}function Nt(e,t){const n={},s=Object.keys(e);for(let r=0;r<s.length;r++){const i=s[r];n[i]=t(e[i],i,e,r)}return n}function fe(e){return he(e)?e:[e]}function P(e){return e===void 0?[]:fe(e)}function wt(e,t,n,s){return typeof e=="function"?e({context:t,event:n,self:s}):e}function he(e){return Array.isArray(e)}function Xe(e){return e.type.startsWith("xstate.error.actor")}function W(e){return fe(e).map(t=>typeof t>"u"||typeof t=="string"?{target:t}:t)}function de(e){if(!(e===void 0||e===Ue))return P(e)}function nt(e,t,n){const s=typeof e=="object",r=s?e:void 0;return{next:(s?e.next:e)?.bind(r),error:(s?e.error:t)?.bind(r),complete:(s?e.complete:n)?.bind(r)}}function Kt(e,t){return`${t}.${e}`}function kt(e,t){const n=t.match(/^xstate\.invoke\.(\d+)\.(.*)/);if(!n)return e.implementations.actors[t];const[,s,r]=n,u=e.getStateNodeById(r).config.invoke;return(Array.isArray(u)?u[s]:u).src}function Ze(e,t){if(t===e||t===We)return!0;if(!t.endsWith(".*"))return!1;const n=t.split("."),s=e.split(".");for(let r=0;r<n.length;r++){const i=n[r],u=s[r];if(i==="*")return r===n.length-1;if(i!==u)return!1}return!0}function Xt(e,t){return`${e.sessionId}.${t}`}let Ve=0;function Qe(e,t){const n=new Map,s=new Map,r=new WeakMap,i=new Set,u={},{clock:c,logger:h}=t,d={schedule:(a,p,y,m,E=Math.random().toString(36).slice(2))=>{const A={source:a,target:p,event:y,delay:m,id:E,startedAt:Date.now()},$=Xt(a,E);f._snapshot._scheduledEvents[$]=A;const O=c.setTimeout(()=>{delete u[$],delete f._snapshot._scheduledEvents[$],f._relay(a,p,y)},m);u[$]=O},cancel:(a,p)=>{const y=Xt(a,p),m=u[y];delete u[y],delete f._snapshot._scheduledEvents[y],m!==void 0&&c.clearTimeout(m)},cancelAll:a=>{for(const p in f._snapshot._scheduledEvents){const y=f._snapshot._scheduledEvents[p];y.source===a&&d.cancel(a,y.id)}}},v=a=>{if(!i.size)return;const p={...a,rootId:e.sessionId};i.forEach(y=>y.next?.(p))},f={_snapshot:{_scheduledEvents:(t?.snapshot&&t.snapshot.scheduler)??{}},_bookId:()=>`x:${Ve++}`,_register:(a,p)=>(n.set(a,p),a),_unregister:a=>{n.delete(a.sessionId);const p=r.get(a);p!==void 0&&(s.delete(p),r.delete(a))},get:a=>s.get(a),getAll:()=>Object.fromEntries(s.entries()),_set:(a,p)=>{const y=s.get(a);if(y&&y!==p)throw new Error(`Actor with system ID '${a}' already exists.`);s.set(a,p),r.set(p,a)},inspect:a=>{const p=nt(a);return i.add(p),{unsubscribe(){i.delete(p)}}},_sendInspectionEvent:v,_relay:(a,p,y)=>{f._sendInspectionEvent({type:"@xstate.event",sourceRef:a,actorRef:p,event:y}),p._send(y)},scheduler:d,getSnapshot:()=>({_scheduledEvents:{...f._snapshot._scheduledEvents}}),start:()=>{const a=f._snapshot._scheduledEvents;f._snapshot._scheduledEvents={};for(const p in a){const{source:y,target:m,event:E,delay:A,id:$}=a[p];d.schedule(y,m,E,A,$)}},_clock:c,_logger:h};return f}let pt=!1;const $t=1;let R=(function(e){return e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped",e})({});const Fe={clock:{setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e)},logger:console.log.bind(console),devTools:!1};class tn{constructor(t,n){this.logic=t,this._snapshot=void 0,this.clock=void 0,this.options=void 0,this.id=void 0,this.mailbox=new Gt(this._process.bind(this)),this.observers=new Set,this.eventListeners=new Map,this.logger=void 0,this._processingStatus=R.NotStarted,this._parent=void 0,this._syncSnapshot=void 0,this.ref=void 0,this._actorScope=void 0,this.systemId=void 0,this.sessionId=void 0,this.system=void 0,this._doneEvent=void 0,this.src=void 0,this._deferred=[];const s={...Fe,...n},{clock:r,logger:i,parent:u,syncSnapshot:c,id:h,systemId:d,inspect:v}=s;this.system=u?u.system:Qe(this,{clock:r,logger:i}),v&&!u&&this.system.inspect(nt(v)),this.sessionId=this.system._bookId(),this.id=h??this.sessionId,this.logger=n?.logger??this.system._logger,this.clock=n?.clock??this.system._clock,this._parent=u,this._syncSnapshot=c,this.options=s,this.src=s.src??t,this.ref=this,this._actorScope={self:this,id:this.id,sessionId:this.sessionId,logger:this.logger,defer:f=>{this._deferred.push(f)},system:this.system,stopChild:f=>{if(f._parent!==this)throw new Error(`Cannot stop child actor ${f.id} of ${this.id} because it is not a child`);f._stop()},emit:f=>{const a=this.eventListeners.get(f.type),p=this.eventListeners.get("*");if(!a&&!p)return;const y=[...a?a.values():[],...p?p.values():[]];for(const m of y)try{m(f)}catch(E){M(E)}},actionExecutor:f=>{const a=()=>{if(this._actorScope.system._sendInspectionEvent({type:"@xstate.action",actorRef:this,action:{type:f.type,params:f.params}}),!f.exec)return;const p=pt;try{pt=!0,f.exec(f.info,f.params)}finally{pt=p}};this._processingStatus===R.Running?a():this._deferred.push(a)}},this.send=this.send.bind(this),this.system._sendInspectionEvent({type:"@xstate.actor",actorRef:this}),d&&(this.systemId=d,this.system._set(d,this)),this._initState(n?.snapshot??n?.state),d&&this._snapshot.status!=="active"&&this.system._unregister(this)}_initState(t){try{this._snapshot=t?this.logic.restoreSnapshot?this.logic.restoreSnapshot(t,this._actorScope):t:this.logic.getInitialSnapshot(this._actorScope,this.options?.input)}catch(n){this._snapshot={status:"error",output:void 0,error:n}}}update(t,n){this._snapshot=t;let s;for(;s=this._deferred.shift();)try{s()}catch(r){this._deferred.length=0,this._snapshot={...t,status:"error",error:r}}switch(this._snapshot.status){case"active":for(const r of this.observers)try{r.next?.(t)}catch(i){M(i)}break;case"done":for(const r of this.observers)try{r.next?.(t)}catch(i){M(i)}this._stopProcedure(),this._complete(),this._doneEvent=Be(this.id,this._snapshot.output),this._parent&&this.system._relay(this,this._parent,this._doneEvent);break;case"error":this._error(this._snapshot.error);break}this.system._sendInspectionEvent({type:"@xstate.snapshot",actorRef:this,event:n,snapshot:t})}subscribe(t,n,s){const r=nt(t,n,s);if(this._processingStatus!==R.Stopped)this.observers.add(r);else switch(this._snapshot.status){case"done":try{r.complete?.()}catch(i){M(i)}break;case"error":{const i=this._snapshot.error;if(!r.error)M(i);else try{r.error(i)}catch(u){M(u)}break}}return{unsubscribe:()=>{this.observers.delete(r)}}}on(t,n){let s=this.eventListeners.get(t);s||(s=new Set,this.eventListeners.set(t,s));const r=n.bind(void 0);return s.add(r),{unsubscribe:()=>{s.delete(r)}}}start(){if(this._processingStatus===R.Running)return this;this._syncSnapshot&&this.subscribe({next:s=>{s.status==="active"&&this.system._relay(this,this._parent,{type:`xstate.snapshot.${this.id}`,snapshot:s})},error:()=>{}}),this.system._register(this.sessionId,this),this.systemId&&this.system._set(this.systemId,this),this._processingStatus=R.Running;const t=ue(this.options.input);switch(this.system._sendInspectionEvent({type:"@xstate.event",sourceRef:this._parent,actorRef:this,event:t}),this._snapshot.status){case"done":return this.update(this._snapshot,t),this;case"error":return this._error(this._snapshot.error),this}if(this._parent||this.system.start(),this.logic.start)try{this.logic.start(this._snapshot,this._actorScope)}catch(s){return this._snapshot={...this._snapshot,status:"error",error:s},this._error(s),this}return this.update(this._snapshot,t),this.options.devTools&&this.attachDevTools(),this.mailbox.start(),this}_process(t){let n,s;try{n=this.logic.transition(this._snapshot,t,this._actorScope)}catch(r){s={err:r}}if(s){const{err:r}=s;this._snapshot={...this._snapshot,status:"error",error:r},this._error(r);return}this.update(n,t),t.type===et&&(this._stopProcedure(),this._complete())}_stop(){return this._processingStatus===R.Stopped?this:(this.mailbox.clear(),this._processingStatus===R.NotStarted?(this._processingStatus=R.Stopped,this):(this.mailbox.enqueue({type:et}),this))}stop(){if(this._parent)throw new Error("A non-root actor cannot be stopped directly.");return this._stop()}_complete(){for(const t of this.observers)try{t.complete?.()}catch(n){M(n)}this.observers.clear(),this.eventListeners.clear()}_reportError(t){if(!this.observers.size){this._parent||M(t),this.eventListeners.clear();return}let n=!1;for(const s of this.observers){const r=s.error;n||=!r;try{r?.(t)}catch(i){M(i)}}this.observers.clear(),this.eventListeners.clear(),n&&M(t)}_error(t){this._stopProcedure(),this._reportError(t),this._parent&&this.system._relay(this,this._parent,ce(this.id,t))}_stopProcedure(){return this._processingStatus!==R.Running?this:(this.system.scheduler.cancelAll(this),this.mailbox.clear(),this.mailbox=new Gt(this._process.bind(this)),this._processingStatus=R.Stopped,this.system._unregister(this),this)}_send(t){this._processingStatus!==R.Stopped&&this.mailbox.enqueue(t)}send(t){this.system._relay(void 0,this,t)}attachDevTools(){const{devTools:t}=this.options;t&&(typeof t=="function"?t:ze)(this)}toJSON(){return{xstate$$type:$t,id:this.id}}getPersistedSnapshot(t){return this.logic.getPersistedSnapshot(this._snapshot,t)}[Ne](){return this}getSnapshot(){return this._snapshot}}function G(e,...[t]){return new tn(e,t)}function en(e,t,n,s,{sendId:r}){const i=typeof r=="function"?r(n,s):r;return[t,{sendId:i},void 0]}function nn(e,t){e.defer(()=>{e.system.scheduler.cancel(e.self,t.sendId)})}function Ct(e){function t(n,s){}return t.type="xstate.cancel",t.sendId=e,t.resolve=en,t.execute=nn,t}function sn(e,t,n,s,{id:r,systemId:i,src:u,input:c,syncSnapshot:h}){const d=typeof u=="string"?kt(t.machine,u):u,v=typeof r=="function"?r(n):r;let f,a;return d&&(a=typeof c=="function"?c({context:t.context,event:n.event,self:e.self}):c,f=G(d,{id:v,src:u,parent:e.self,syncSnapshot:h,systemId:i,input:a})),[z(t,{children:{...t.children,[v]:f}}),{id:r,systemId:i,actorRef:f,src:u,input:a},void 0]}function rn(e,{actorRef:t}){t&&e.defer(()=>{t._processingStatus!==R.Stopped&&t.start()})}function Ot(...[e,{id:t,systemId:n,input:s,syncSnapshot:r=!1}={}]){function i(u,c){}return i.type="xstate.spawnChild",i.id=t,i.systemId=n,i.src=e,i.input=s,i.syncSnapshot=r,i.resolve=sn,i.execute=rn,i}function on(e,t,n,s,{actorRef:r}){const i=typeof r=="function"?r(n,s):r,u=typeof i=="string"?t.children[i]:i;let c=t.children;return u&&(c={...c},delete c[u.id]),[z(t,{children:c}),u,void 0]}function le(e,t){const n=t.getSnapshot();if(n&&"children"in n)for(const s of Object.values(n.children))le(e,s);e.system._unregister(t)}function cn(e,t){if(t){if(le(e,t),t._processingStatus!==R.Running){e.stopChild(t);return}e.defer(()=>{e.stopChild(t)})}}function ct(e){function t(n,s){}return t.type="xstate.stopChild",t.actorRef=e,t.resolve=on,t.execute=cn,t}function ut(e,t,n,s){const{machine:r}=s,i=typeof e=="function",u=i?e:r.implementations.guards[typeof e=="string"?e:e.type];if(!i&&!u)throw new Error(`Guard '${typeof e=="string"?e:e.type}' is not implemented.'.`);if(typeof u!="function")return ut(u,t,n,s);const c={context:t,event:n},h=i||typeof e=="string"?void 0:"params"in e?typeof e.params=="function"?e.params({context:t,event:n}):e.params:void 0;return"check"in u?u.check(s,c,u):u(c,h)}function jt(e){return e.type==="atomic"||e.type==="final"}function B(e){return Object.values(e.states).filter(t=>t.type!=="history")}function Q(e,t){const n=[];if(t===e)return n;let s=e.parent;for(;s&&s!==t;)n.push(s),s=s.parent;return n}function st(e){const t=new Set(e),n=ye(t);for(const s of t)if(s.type==="compound"&&(!n.get(s)||!n.get(s).length))Zt(s).forEach(r=>t.add(r));else if(s.type==="parallel"){for(const r of B(s))if(r.type!=="history"&&!t.has(r)){const i=Zt(r);for(const u of i)t.add(u)}}for(const s of t){let r=s.parent;for(;r;)t.add(r),r=r.parent}return t}function pe(e,t){const n=t.get(e);if(!n)return{};if(e.type==="compound"){const r=n[0];if(r){if(jt(r))return r.key}else return{}}const s={};for(const r of n)s[r.key]=pe(r,t);return s}function ye(e){const t=new Map;for(const n of e)t.has(n)||t.set(n,[]),n.parent&&(t.has(n.parent)||t.set(n.parent,[]),t.get(n.parent).push(n));return t}function ve(e,t){const n=st(t);return pe(e,ye(n))}function Mt(e,t){return t.type==="compound"?B(t).some(n=>n.type==="final"&&e.has(n)):t.type==="parallel"?B(t).every(n=>Mt(e,n)):t.type==="final"}const at=e=>e[0]===Ye;function un(e,t){return e.transitions.get(t)||[...e.transitions.keys()].filter(s=>Ze(t,s)).sort((s,r)=>r.length-s.length).flatMap(s=>e.transitions.get(s))}function an(e){const t=e.config.after;if(!t)return[];const n=r=>{const i=Ge(r,e.id),u=i.type;return e.entry.push(Lt(i,{id:u,delay:r})),e.exit.push(Ct(u)),u};return Object.keys(t).flatMap(r=>{const i=t[r],u=typeof i=="string"?{target:i}:i,c=Number.isNaN(+r)?r:+r,h=n(c);return P(u).map(d=>({...d,event:h,delay:c}))}).map(r=>{const{delay:i}=r;return{...H(e,r.event,r),delay:i}})}function H(e,t,n){const s=de(n.target),r=n.reenter??!1,i=dn(e,s),u={...n,actions:P(n.actions),guard:n.guard,target:i,source:e,reenter:r,eventType:t,toJSON:()=>({...u,source:`#${e.id}`,target:i?i.map(c=>`#${c.id}`):void 0})};return u}function fn(e){const t=new Map;if(e.config.on)for(const n of Object.keys(e.config.on)){if(n===ie)throw new Error('Null events ("") cannot be specified as a transition key. Use `always: { ... }` instead.');const s=e.config.on[n];t.set(n,W(s).map(r=>H(e,n,r)))}if(e.config.onDone){const n=`xstate.done.state.${e.id}`;t.set(n,W(e.config.onDone).map(s=>H(e,n,s)))}for(const n of e.invoke){if(n.onDone){const s=`xstate.done.actor.${n.id}`;t.set(s,W(n.onDone).map(r=>H(e,s,r)))}if(n.onError){const s=`xstate.error.actor.${n.id}`;t.set(s,W(n.onError).map(r=>H(e,s,r)))}if(n.onSnapshot){const s=`xstate.snapshot.${n.id}`;t.set(s,W(n.onSnapshot).map(r=>H(e,s,r)))}}for(const n of e.after){let s=t.get(n.eventType);s||(s=[],t.set(n.eventType,s)),s.push(n)}return t}function hn(e,t){const n=typeof t=="string"?e.states[t]:t?e.states[t.target]:void 0;if(!n&&t)throw new Error(`Initial state node "${t}" not found on parent state node #${e.id}`);const s={source:e,actions:!t||typeof t=="string"?[]:P(t.actions),eventType:null,reenter:!1,target:n?[n]:[],toJSON:()=>({...s,source:`#${e.id}`,target:n?[`#${n.id}`]:[]})};return s}function dn(e,t){if(t!==void 0)return t.map(n=>{if(typeof n!="string")return n;if(at(n))return e.machine.getStateNodeById(n);const s=n[0]===re;if(s&&!e.parent)return rt(e,n.slice(1));const r=s?e.key+n:n;if(e.parent)try{return rt(e.parent,r)}catch(i){throw new Error(`Invalid transition definition for state node '${e.id}':
|
|
2
|
+
${i.message}`)}else throw new Error(`Invalid target: "${n}" is not a valid target from the root node. Did you mean ".${n}"?`)})}function me(e){const t=de(e.config.target);return t?{target:t.map(n=>typeof n=="string"?rt(e.parent,n):n)}:e.parent.initial}function q(e){return e.type==="history"}function Zt(e){const t=ge(e);for(const n of t)for(const s of Q(n,e))t.add(s);return t}function ge(e){const t=new Set;function n(s){if(!t.has(s)){if(t.add(s),s.type==="compound")n(s.initial.target[0]);else if(s.type==="parallel")for(const r of B(s))n(r)}}return n(e),t}function N(e,t){if(at(t))return e.machine.getStateNodeById(t);if(!e.states)throw new Error(`Unable to retrieve child state '${t}' from '${e.id}'; no child states exist.`);const n=e.states[t];if(!n)throw new Error(`Child state '${t}' does not exist on '${e.id}'`);return n}function rt(e,t){if(typeof t=="string"&&at(t))try{return e.machine.getStateNodeById(t)}catch{}const n=Rt(t).slice();let s=e;for(;n.length;){const r=n.shift();if(!r.length)break;s=N(s,r)}return s}function it(e,t){if(typeof t=="string"){const r=e.states[t];if(!r)throw new Error(`State '${t}' does not exist on '${e.id}'`);return[e,r]}const n=Object.keys(t),s=n.map(r=>N(e,r)).filter(Boolean);return[e.machine.root,e].concat(s,n.reduce((r,i)=>{const u=N(e,i);if(!u)return r;const c=it(u,t[i]);return r.concat(c)},[]))}function ln(e,t,n,s){const i=N(e,t).next(n,s);return!i||!i.length?e.next(n,s):i}function pn(e,t,n,s){const r=Object.keys(t),i=N(e,r[0]),u=Dt(i,t[r[0]],n,s);return!u||!u.length?e.next(n,s):u}function yn(e,t,n,s){const r=[];for(const i of Object.keys(t)){const u=t[i];if(!u)continue;const c=N(e,i),h=Dt(c,u,n,s);h&&r.push(...h)}return r.length?r:e.next(n,s)}function Dt(e,t,n,s){return typeof t=="string"?ln(e,t,n,s):Object.keys(t).length===1?pn(e,t,n,s):yn(e,t,n,s)}function vn(e){return Object.keys(e.states).map(t=>e.states[t]).filter(t=>t.type==="history")}function L(e,t){let n=e;for(;n.parent&&n.parent!==t;)n=n.parent;return n.parent===t}function mn(e,t){const n=new Set(e),s=new Set(t);for(const r of n)if(s.has(r))return!0;for(const r of s)if(n.has(r))return!0;return!1}function _e(e,t,n){const s=new Set;for(const r of e){let i=!1;const u=new Set;for(const c of s)if(mn(Tt([r],t,n),Tt([c],t,n)))if(L(r.source,c.source))u.add(c);else{i=!0;break}if(!i){for(const c of u)s.delete(c);s.add(r)}}return Array.from(s)}function gn(e){const[t,...n]=e;for(const s of Q(t,void 0))if(n.every(r=>L(r,s)))return s}function Pt(e,t){if(!e.target)return[];const n=new Set;for(const s of e.target)if(q(s))if(t[s.id])for(const r of t[s.id])n.add(r);else for(const r of Pt(me(s),t))n.add(r);else n.add(s);return[...n]}function Se(e,t){const n=Pt(e,t);if(!n)return;if(!e.reenter&&n.every(r=>r===e.source||L(r,e.source)))return e.source;const s=gn(n.concat(e.source));if(s)return s;if(!e.reenter)return e.source.machine.root}function Tt(e,t,n){const s=new Set;for(const r of e)if(r.target?.length){const i=Se(r,n);r.reenter&&r.source===i&&s.add(i);for(const u of t)L(u,i)&&s.add(u)}return[...s]}function _n(e,t){if(e.length!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function xt(e,t,n,s,r,i){if(!e.length)return t;const u=new Set(t._nodes);let c=t.historyValue;const h=_e(e,u,c);let d=t;r||([d,c]=wn(d,s,n,h,u,c,i,n.actionExecutor)),d=K(d,s,n,h.flatMap(f=>f.actions),i,void 0),d=En(d,s,n,h,u,i,c,r);const v=[...u];d.status==="done"&&(d=K(d,s,n,v.sort((f,a)=>a.order-f.order).flatMap(f=>f.exit),i,void 0));try{return c===t.historyValue&&_n(t._nodes,u)?d:z(d,{_nodes:v,historyValue:c})}catch(f){throw f}}function Sn(e,t,n,s,r){if(s.output===void 0)return;const i=bt(r.id,r.output!==void 0&&r.parent?wt(r.output,e.context,t,n.self):void 0);return wt(s.output,e.context,i,n.self)}function En(e,t,n,s,r,i,u,c){let h=e;const d=new Set,v=new Set;bn(s,u,v,d),c&&v.add(e.machine.root);const f=new Set;for(const a of[...d].sort((p,y)=>p.order-y.order)){r.add(a);const p=[];p.push(...a.entry);for(const y of a.invoke)p.push(Ot(y.src,{...y,syncSnapshot:!!y.onSnapshot}));if(v.has(a)){const y=a.initial.actions;p.push(...y)}if(h=K(h,t,n,p,i,a.invoke.map(y=>y.id)),a.type==="final"){const y=a.parent;let m=y?.type==="parallel"?y:y?.parent,E=m||a;for(y?.type==="compound"&&i.push(bt(y.id,a.output!==void 0?wt(a.output,h.context,t,n.self):void 0));m?.type==="parallel"&&!f.has(m)&&Mt(r,m);)f.add(m),i.push(bt(m.id)),E=m,m=m.parent;if(m)continue;h=z(h,{status:"done",output:Sn(h,t,n,h.machine.root,E)})}}return h}function bn(e,t,n,s){for(const r of e){const i=Se(r,t);for(const c of r.target||[])!q(c)&&(r.source!==c||r.source!==i||r.reenter)&&(s.add(c),n.add(c)),J(c,t,n,s);const u=Pt(r,t);for(const c of u){const h=Q(c,i);i?.type==="parallel"&&h.push(i),Ee(s,t,n,h,!r.source.parent&&r.reenter?void 0:i)}}}function J(e,t,n,s){if(q(e))if(t[e.id]){const r=t[e.id];for(const i of r)s.add(i),J(i,t,n,s);for(const i of r)yt(i,e.parent,s,t,n)}else{const r=me(e);for(const i of r.target)s.add(i),r===e.parent?.initial&&n.add(e.parent),J(i,t,n,s);for(const i of r.target)yt(i,e.parent,s,t,n)}else if(e.type==="compound"){const[r]=e.initial.target;q(r)||(s.add(r),n.add(r)),J(r,t,n,s),yt(r,e,s,t,n)}else if(e.type==="parallel")for(const r of B(e).filter(i=>!q(i)))[...s].some(i=>L(i,r))||(q(r)||(s.add(r),n.add(r)),J(r,t,n,s))}function Ee(e,t,n,s,r){for(const i of s)if((!r||L(i,r))&&e.add(i),i.type==="parallel")for(const u of B(i).filter(c=>!q(c)))[...e].some(c=>L(c,u))||(e.add(u),J(u,t,n,e))}function yt(e,t,n,s,r){Ee(n,s,r,Q(e,t))}function wn(e,t,n,s,r,i,u,c){let h=e;const d=Tt(s,r,i);d.sort((f,a)=>a.order-f.order);let v;for(const f of d)for(const a of vn(f)){let p;a.history==="deep"?p=y=>jt(y)&&L(y,f):p=y=>y.parent===f,v??={...i},v[a.id]=Array.from(r).filter(p)}for(const f of d)h=K(h,t,n,[...f.exit,...f.invoke.map(a=>ct(a.id))],u,void 0),r.delete(f);return[h,v||i]}function Tn(e,t){return e.implementations.actions[t]}function be(e,t,n,s,r,i){const{machine:u}=e;let c=e;for(const h of s){const d=typeof h=="function",v=d?h:Tn(u,typeof h=="string"?h:h.type),f={context:c.context,event:t,self:n.self,system:n.system},a=d||typeof h=="string"?void 0:"params"in h?typeof h.params=="function"?h.params({context:c.context,event:t}):h.params:void 0;if(!v||!("resolve"in v)){n.actionExecutor({type:typeof h=="string"?h:typeof h=="object"?h.type:h.name||"(anonymous)",info:f,params:a,exec:v});continue}const p=v,[y,m,E]=p.resolve(n,c,f,a,v,r);c=y,"retryResolve"in p&&i?.push([p,m]),"execute"in p&&n.actionExecutor({type:p.type,info:f,params:m,exec:p.execute.bind(null,n,m)}),E&&(c=be(c,t,n,E,r,i))}return c}function K(e,t,n,s,r,i){const u=i?[]:void 0,c=be(e,t,n,s,{internalQueue:r,deferredActorIds:i},u);return u?.forEach(([h,d])=>{h.retryResolve(n,c,d)}),c}function vt(e,t,n,s){let r=e;const i=[];function u(d,v,f){n.system._sendInspectionEvent({type:"@xstate.microstep",actorRef:n.self,event:v,snapshot:d,_transitions:f}),i.push(d)}if(t.type===et)return r=z(Vt(r,t,n),{status:"stopped"}),u(r,t,[]),{snapshot:r,microstates:i};let c=t;if(c.type!==oe){const d=c,v=Xe(d),f=Qt(d,r);if(v&&!f.length)return r=z(e,{status:"error",error:d.error}),u(r,d,[]),{snapshot:r,microstates:i};r=xt(f,e,n,c,!1,s),u(r,d,f)}let h=!0;for(;r.status==="active";){let d=h?xn(r,c):[];const v=d.length?r:void 0;if(!d.length){if(!s.length)break;c=s.shift(),d=Qt(c,r)}r=xt(d,r,n,c,!1,s),h=r!==v,u(r,c,d)}return r.status!=="active"&&Vt(r,c,n),{snapshot:r,microstates:i}}function Vt(e,t,n){return K(e,t,n,Object.values(e.children).map(s=>ct(s)),[],void 0)}function Qt(e,t){return t.machine.getTransitionData(t,e)}function xn(e,t){const n=new Set,s=e._nodes.filter(jt);for(const r of s)t:for(const i of[r].concat(Q(r,void 0)))if(i.always){for(const u of i.always)if(u.guard===void 0||ut(u.guard,e.context,t,e)){n.add(u);break t}}return _e(Array.from(n),new Set(e._nodes),e.historyValue)}function An(e,t){const n=st(it(e,t));return ve(e,[...n])}function In(e){return!!e&&typeof e=="object"&&"machine"in e&&"value"in e}const Rn=function(t){return ae(t,this.value)},kn=function(t){return this.tags.has(t)},$n=function(t){const n=this.machine.getTransitionData(this,t);return!!n?.length&&n.some(s=>s.target!==void 0||s.actions.length)},Cn=function(){const{_nodes:t,tags:n,machine:s,getMeta:r,toJSON:i,can:u,hasTag:c,matches:h,...d}=this;return{...d,tags:Array.from(n)}},On=function(){return this._nodes.reduce((t,n)=>(n.meta!==void 0&&(t[n.id]=n.meta),t),{})};function tt(e,t){return{status:e.status,output:e.output,error:e.error,machine:t,context:e.context,_nodes:e._nodes,value:ve(t.root,e._nodes),tags:new Set(e._nodes.flatMap(n=>n.tags)),children:e.children,historyValue:e.historyValue||{},matches:Rn,hasTag:kn,can:$n,getMeta:On,toJSON:Cn}}function z(e,t={}){return tt({...e,...t},e.machine)}function jn(e){if(typeof e!="object"||e===null)return{};const t={};for(const n in e){const s=e[n];Array.isArray(s)&&(t[n]=s.map(r=>({id:r.id})))}return t}function Mn(e,t){const{_nodes:n,tags:s,machine:r,children:i,context:u,can:c,hasTag:h,matches:d,getMeta:v,toJSON:f,...a}=e,p={};for(const m in i){const E=i[m];p[m]={snapshot:E.getPersistedSnapshot(t),src:E.src,systemId:E.systemId,syncSnapshot:E._syncSnapshot}}return{...a,context:we(u),children:p,historyValue:jn(a.historyValue)}}function we(e){let t;for(const n in e){const s=e[n];if(s&&typeof s=="object")if("sessionId"in s&&"send"in s&&"ref"in s)t??=Array.isArray(e)?e.slice():{...e},t[n]={xstate$$type:$t,id:s.id};else{const r=we(s);r!==s&&(t??=Array.isArray(e)?e.slice():{...e},t[n]=r)}}return t??e}function Dn(e,t,n,s,{event:r,id:i,delay:u},{internalQueue:c}){const h=t.machine.implementations.delays;if(typeof r=="string")throw new Error(`Only event objects may be used with raise; use raise({ type: "${r}" }) instead`);const d=typeof r=="function"?r(n,s):r;let v;if(typeof u=="string"){const f=h&&h[u];v=typeof f=="function"?f(n,s):f}else v=typeof u=="function"?u(n,s):u;return typeof v!="number"&&c.push(d),[t,{event:d,id:i,delay:v},void 0]}function Pn(e,t){const{event:n,delay:s,id:r}=t;if(typeof s=="number"){e.defer(()=>{const i=e.self;e.system.scheduler.schedule(i,i,n,s,r)});return}}function Lt(e,t){function n(s,r){}return n.type="xstate.raise",n.event=e,n.id=t?.id,n.delay=t?.delay,n.resolve=Dn,n.execute=Pn,n}const mt=new WeakMap;function fs(e){return{config:e,start:(n,s)=>{const{self:r,system:i,emit:u}=s,c={receivers:void 0,dispose:void 0};mt.set(r,c),c.dispose=e({input:n.input,system:i,self:r,sendBack:h=>{r.getSnapshot().status!=="stopped"&&r._parent&&i._relay(r,r._parent,h)},receive:h=>{c.receivers??=new Set,c.receivers.add(h)},emit:u})},transition:(n,s,r)=>{const i=mt.get(r.self);return s.type===et?(n={...n,status:"stopped",error:void 0},mt.delete(r.self),i.receivers?.clear(),i.dispose?.(),n):(i.receivers?.forEach(u=>u(s)),n)},getInitialSnapshot:(n,s)=>({status:"active",output:void 0,error:void 0,input:s}),getPersistedSnapshot:n=>n,restoreSnapshot:n=>n}}function Ln(e,{machine:t,context:n},s,r){const i=(u,c)=>{if(typeof u=="string"){const h=kt(t,u);if(!h)throw new Error(`Actor logic '${u}' not implemented in machine '${t.id}'`);const d=G(h,{id:c?.id,parent:e.self,syncSnapshot:c?.syncSnapshot,input:typeof c?.input=="function"?c.input({context:n,event:s,self:e.self}):c?.input,src:u,systemId:c?.systemId});return r[d.id]=d,d}else return G(u,{id:c?.id,parent:e.self,syncSnapshot:c?.syncSnapshot,input:c?.input,src:u,systemId:c?.systemId})};return(u,c)=>{const h=i(u,c);return r[h.id]=h,e.defer(()=>{h._processingStatus!==R.Stopped&&h.start()}),h}}function Hn(e,t,n,s,{assignment:r}){if(!t.context)throw new Error("Cannot assign to undefined `context`. Ensure that `context` is defined in the machine config.");const i={},u={context:t.context,event:n.event,spawn:Ln(e,t,n.event,i),self:e.self,system:e.system};let c={};if(typeof r=="function")c=r(u,s);else for(const d of Object.keys(r)){const v=r[d];c[d]=typeof v=="function"?v(u,s):v}const h=Object.assign({},t.context,c);return[z(t,{context:h,children:Object.keys(i).length?{...t.children,...i}:t.children}),void 0,void 0]}function Ht(e){function t(n,s){}return t.type="xstate.assign",t.assignment=e,t.resolve=Hn,t}const Ft=new WeakMap;function Y(e,t,n){let s=Ft.get(e);return s?t in s||(s[t]=n()):(s={[t]:n()},Ft.set(e,s)),s[t]}const qn={},V=e=>typeof e=="string"?{type:e}:typeof e=="function"?"resolve"in e?{type:e.type}:{type:e.name}:e;class ot{constructor(t,n){if(this.config=t,this.key=void 0,this.id=void 0,this.type=void 0,this.path=void 0,this.states=void 0,this.history=void 0,this.entry=void 0,this.exit=void 0,this.parent=void 0,this.machine=void 0,this.meta=void 0,this.output=void 0,this.order=-1,this.description=void 0,this.tags=[],this.transitions=void 0,this.always=void 0,this.parent=n._parent,this.key=n._key,this.machine=n._machine,this.path=this.parent?this.parent.path.concat(this.key):[],this.id=this.config.id||[this.machine.id,...this.path].join(re),this.type=this.config.type||(this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.description=this.config.description,this.order=this.machine.idMap.size,this.machine.idMap.set(this.id,this),this.states=this.config.states?Nt(this.config.states,(s,r)=>new ot(s,{_parent:this,_key:r,_machine:this.machine})):qn,this.type==="compound"&&!this.config.initial)throw new Error(`No initial state specified for compound state node "#${this.id}". Try adding { initial: "${Object.keys(this.states)[0]}" } to the state config.`);this.history=this.config.history===!0?"shallow":this.config.history||!1,this.entry=P(this.config.entry).slice(),this.exit=P(this.config.exit).slice(),this.meta=this.config.meta,this.output=this.type==="final"||!this.parent?this.config.output:void 0,this.tags=P(t.tags).slice()}_initialize(){this.transitions=fn(this),this.config.always&&(this.always=W(this.config.always).map(t=>H(this,ie,t))),Object.keys(this.states).forEach(t=>{this.states[t]._initialize()})}get definition(){return{id:this.id,key:this.key,version:this.machine.version,type:this.type,initial:this.initial?{target:this.initial.target,source:this,actions:this.initial.actions.map(V),eventType:null,reenter:!1,toJSON:()=>({target:this.initial.target.map(t=>`#${t.id}`),source:`#${this.id}`,actions:this.initial.actions.map(V),eventType:null})}:void 0,history:this.history,states:Nt(this.states,t=>t.definition),on:this.on,transitions:[...this.transitions.values()].flat().map(t=>({...t,actions:t.actions.map(V)})),entry:this.entry.map(V),exit:this.exit.map(V),meta:this.meta,order:this.order||-1,output:this.output,invoke:this.invoke,description:this.description,tags:this.tags}}toJSON(){return this.definition}get invoke(){return Y(this,"invoke",()=>P(this.config.invoke).map((t,n)=>{const{src:s,systemId:r}=t,i=t.id??Kt(this.id,n),u=typeof s=="string"?s:`xstate.invoke.${Kt(this.id,n)}`;return{...t,src:u,id:i,systemId:r,toJSON(){const{onDone:c,onError:h,...d}=t;return{...d,type:"xstate.invoke",src:u,id:i}}}}))}get on(){return Y(this,"on",()=>[...this.transitions].flatMap(([n,s])=>s.map(r=>[n,r])).reduce((n,[s,r])=>(n[s]=n[s]||[],n[s].push(r),n),{}))}get after(){return Y(this,"delayedTransitions",()=>an(this))}get initial(){return Y(this,"initial",()=>hn(this,this.config.initial))}next(t,n){const s=n.type,r=[];let i;const u=Y(this,`candidates-${s}`,()=>un(this,s));for(const c of u){const{guard:h}=c,d=t.context;let v=!1;try{v=!h||ut(h,d,n,t)}catch(f){const a=typeof h=="string"?h:typeof h=="object"?h.type:void 0;throw new Error(`Unable to evaluate guard ${a?`'${a}' `:""}in transition for event '${s}' in state node '${this.id}':
|
|
3
|
+
${f.message}`)}if(v){r.push(...c.actions),i=c;break}}return i?[i]:void 0}get events(){return Y(this,"events",()=>{const{states:t}=this,n=new Set(this.ownEvents);if(t)for(const s of Object.keys(t)){const r=t[s];if(r.states)for(const i of r.events)n.add(`${i}`)}return Array.from(n)})}get ownEvents(){const t=Object.keys(Object.fromEntries(this.transitions)),n=new Set(t.filter(s=>this.transitions.get(s).some(r=>!(!r.target&&!r.actions.length&&!r.reenter))));return Array.from(n)}}const zn="#";class qt{constructor(t,n){this.config=t,this.version=void 0,this.schemas=void 0,this.implementations=void 0,this.__xstatenode=!0,this.idMap=new Map,this.root=void 0,this.id=void 0,this.states=void 0,this.events=void 0,this.id=t.id||"(machine)",this.implementations={actors:n?.actors??{},actions:n?.actions??{},delays:n?.delays??{},guards:n?.guards??{}},this.version=this.config.version,this.schemas=this.config.schemas,this.transition=this.transition.bind(this),this.getInitialSnapshot=this.getInitialSnapshot.bind(this),this.getPersistedSnapshot=this.getPersistedSnapshot.bind(this),this.restoreSnapshot=this.restoreSnapshot.bind(this),this.start=this.start.bind(this),this.root=new ot(t,{_key:this.id,_machine:this}),this.root._initialize(),this.states=this.root.states,this.events=this.root.events}provide(t){const{actions:n,guards:s,actors:r,delays:i}=this.implementations;return new qt(this.config,{actions:{...n,...t.actions},guards:{...s,...t.guards},actors:{...r,...t.actors},delays:{...i,...t.delays}})}resolveState(t){const n=An(this.root,t.value),s=st(it(this.root,n));return tt({_nodes:[...s],context:t.context||{},children:{},status:Mt(s,this.root)?"done":t.status||"active",output:t.output,error:t.error,historyValue:t.historyValue},this)}transition(t,n,s){return vt(t,n,s,[]).snapshot}microstep(t,n,s){return vt(t,n,s,[]).microstates}getTransitionData(t,n){return Dt(this.root,t.value,t,n)||[]}getPreInitialState(t,n,s){const{context:r}=this.config,i=tt({context:typeof r!="function"&&r?r:{},_nodes:[this.root],children:{},status:"active"},this);return typeof r=="function"?K(i,n,t,[Ht(({spawn:c,event:h,self:d})=>r({spawn:c,input:h.input,self:d}))],s,void 0):i}getInitialSnapshot(t,n){const s=ue(n),r=[],i=this.getPreInitialState(t,s,r),u=xt([{target:[...ge(this.root)],source:this.root,reenter:!0,actions:[],eventType:null,toJSON:null}],i,t,s,!0,r),{snapshot:c}=vt(u,s,t,r);return c}start(t){Object.values(t.children).forEach(n=>{n.getSnapshot().status==="active"&&n.start()})}getStateNodeById(t){const n=Rt(t),s=n.slice(1),r=at(n[0])?n[0].slice(zn.length):n[0],i=this.idMap.get(r);if(!i)throw new Error(`Child state node '#${r}' does not exist on machine '${this.id}'`);return rt(i,s)}get definition(){return this.root.definition}toJSON(){return this.definition}getPersistedSnapshot(t,n){return Mn(t,n)}restoreSnapshot(t,n){const s={},r=t.children;Object.keys(r).forEach(f=>{const a=r[f],p=a.snapshot,y=a.src,m=typeof y=="string"?kt(this,y):y;if(!m)return;const E=G(m,{id:f,parent:n.self,syncSnapshot:a.syncSnapshot,snapshot:p,src:y,systemId:a.systemId});s[f]=E});function i(f,a){if(a instanceof ot)return a;try{return f.machine.getStateNodeById(a.id)}catch{}}function u(f,a){if(!a||typeof a!="object")return{};const p={};for(const y in a){const m=a[y];for(const E of m){const A=i(f,E);A&&(p[y]??=[],p[y].push(A))}}return p}const c=u(this.root,t.historyValue),h=tt({...t,children:s,_nodes:Array.from(st(it(this.root,t.value))),historyValue:c},this),d=new Set;function v(f,a){if(!d.has(f)){d.add(f);for(const p in f){const y=f[p];if(y&&typeof y=="object"){if("xstate$$type"in y&&y.xstate$$type===$t){f[p]=a[y.id];continue}v(y,a)}}}}return v(h.context,s),h}}function Un(e,t,n,s,{event:r}){const i=typeof r=="function"?r(n,s):r;return[t,{event:i},void 0]}function Yn(e,{event:t}){e.defer(()=>e.emit(t))}function Te(e){function t(n,s){}return t.type="xstate.emit",t.event=e,t.resolve=Un,t.execute=Yn,t}let At=(function(e){return e.Parent="#_parent",e.Internal="#_internal",e})({});function Wn(e,t,n,s,{to:r,event:i,id:u,delay:c},h){const d=t.machine.implementations.delays;if(typeof i=="string")throw new Error(`Only event objects may be used with sendTo; use sendTo({ type: "${i}" }) instead`);const v=typeof i=="function"?i(n,s):i;let f;if(typeof c=="string"){const y=d&&d[c];f=typeof y=="function"?y(n,s):y}else f=typeof c=="function"?c(n,s):c;const a=typeof r=="function"?r(n,s):r;let p;if(typeof a=="string"){if(a===At.Parent?p=e.self._parent:a===At.Internal?p=e.self:a.startsWith("#_")?p=t.children[a.slice(2)]:p=h.deferredActorIds?.includes(a)?a:t.children[a],!p)throw new Error(`Unable to send event to actor '${a}' from machine '${t.machine.id}'.`)}else p=a||e.self;return[t,{to:p,targetId:typeof a=="string"?a:void 0,event:v,id:u,delay:f},void 0]}function Jn(e,t,n){typeof n.to=="string"&&(n.to=t.children[n.to])}function Gn(e,t){e.defer(()=>{const{to:n,event:s,delay:r,id:i}=t;if(typeof r=="number"){e.system.scheduler.schedule(e.self,n,s,r,i);return}e.system._relay(e.self,n,s.type===Je?ce(e.self.id,s.data):s)})}function zt(e,t,n){function s(r,i){}return s.type="xstate.sendTo",s.to=e,s.event=t,s.id=n?.id,s.delay=n?.delay,s.resolve=Wn,s.retryResolve=Jn,s.execute=Gn,s}function Bn(e,t){return zt(At.Parent,e,t)}function Nn(e,t,n,s,{collect:r}){const i=[],u=function(h){i.push(h)};return u.assign=(...c)=>{i.push(Ht(...c))},u.cancel=(...c)=>{i.push(Ct(...c))},u.raise=(...c)=>{i.push(Lt(...c))},u.sendTo=(...c)=>{i.push(zt(...c))},u.sendParent=(...c)=>{i.push(Bn(...c))},u.spawnChild=(...c)=>{i.push(Ot(...c))},u.stopChild=(...c)=>{i.push(ct(...c))},u.emit=(...c)=>{i.push(Te(...c))},r({context:n.context,event:n.event,enqueue:u,check:c=>ut(c,t.context,n.event,t),self:e.self,system:e.system},s),[t,void 0,i]}function Kn(e){function t(n,s){}return t.type="xstate.enqueueActions",t.collect=e,t.resolve=Nn,t}function Xn(e,t,n,s,{value:r,label:i}){return[t,{value:typeof r=="function"?r(n,s):r,label:i},void 0]}function Zn({logger:e},{value:t,label:n}){n?e(n,t):e(t)}function Vn(e=({context:n,event:s})=>({context:n,event:s}),t){function n(s,r){}return n.type="xstate.log",n.value=e,n.label=t,n.resolve=Xn,n.execute=Zn,n}function Qn(e,t){return new qt(e,t)}function Fn({schemas:e,actors:t,actions:n,guards:s,delays:r}){return{assign:Ht,sendTo:zt,raise:Lt,log:Vn,cancel:Ct,stopChild:ct,enqueueActions:Kn,emit:Te,spawnChild:Ot,createStateConfig:i=>i,createAction:i=>i,createMachine:i=>Qn({...i,schemas:e},{actors:t,actions:n,guards:s,delays:r}),extend:i=>Fn({schemas:e,actors:t,actions:{...n,...i.actions},guards:{...s,...i.guards},delays:{...r,...i.delays}})}}var gt={exports:{}},_t={},St={exports:{}},Et={};var te;function ts(){if(te)return Et;te=1;var e=It();function t(f,a){return f===a&&(f!==0||1/f===1/a)||f!==f&&a!==a}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,r=e.useEffect,i=e.useLayoutEffect,u=e.useDebugValue;function c(f,a){var p=a(),y=s({inst:{value:p,getSnapshot:a}}),m=y[0].inst,E=y[1];return i(function(){m.value=p,m.getSnapshot=a,h(m)&&E({inst:m})},[f,p,a]),r(function(){return h(m)&&E({inst:m}),f(function(){h(m)&&E({inst:m})})},[f]),u(p),p}function h(f){var a=f.getSnapshot;f=f.value;try{var p=a();return!n(f,p)}catch{return!0}}function d(f,a){return a()}var v=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:c;return Et.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:v,Et}var ee;function xe(){return ee||(ee=1,St.exports=ts()),St.exports}var ne;function es(){if(ne)return _t;ne=1;var e=It(),t=xe();function n(d,v){return d===v&&(d!==0||1/d===1/v)||d!==d&&v!==v}var s=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,u=e.useEffect,c=e.useMemo,h=e.useDebugValue;return _t.useSyncExternalStoreWithSelector=function(d,v,f,a,p){var y=i(null);if(y.current===null){var m={hasValue:!1,value:null};y.current=m}else m=y.current;y=c(function(){function A(k){if(!$){if($=!0,O=k,k=a(k),p!==void 0&&m.hasValue){var b=m.value;if(p(b,k))return D=b}return D=k}if(b=D,s(O,k))return b;var Z=a(k);return p!==void 0&&p(b,Z)?(O=k,b):(O=k,D=Z)}var $=!1,O,D,X=f===void 0?null:f;return[function(){return A(v())},X===null?void 0:function(){return A(X())}]},[v,f,a,p]);var E=r(d,y[0],y[1]);return u(function(){m.hasValue=!0,m.value=E},[E]),h(E),E},_t}var se;function ns(){return se||(se=1,gt.exports=es()),gt.exports}var ss=ns();xe();const Ae=(e,t)=>{t(e);const n=e.getSnapshot().children;n&&Object.values(n).forEach(s=>{Ae(s,t)})};function rs(e){const t=[];Ae(e,s=>{t.push([s,s.getSnapshot()]),s.observers=new Set});const n=e.system.getSnapshot?.();e.stop(),e.system._snapshot=n,t.forEach(([s,r])=>{s._processingStatus=0,s._snapshot=r})}function is(e,...[t]){let[[n,s],r]=C.useState(()=>{const i=G(e,t);return[e.config,i]});if(e.config!==n){const i=G(e,{...t,snapshot:s.getPersistedSnapshot({__unsafeAllowInlineActors:!0})});r([e.config,i]),s=i}return Le(()=>{s.logic.implementations=e.implementations}),s}function os(e,...[t,n]){const s=is(e,t);return C.useEffect(()=>{if(!n)return;const r=s.subscribe(nt(n));return()=>{r.unsubscribe()}},[n]),C.useEffect(()=>(s.start(),()=>{rs(s)}),[s]),s}function cs(e,t){return e===t}function us(e,t,n=cs){const s=C.useCallback(u=>{if(!e)return()=>{};const{unsubscribe:c}=e.subscribe(u);return c},[e]),r=C.useCallback(()=>e?.getSnapshot(),[e]);return ss.useSyncExternalStoreWithSelector(s,r,r,t,n)}function hs(e,t){const n=C.createContext(null),s=n.Provider;function r({children:c,logic:h=e,machine:d,options:v}){if(d)throw new Error('The "machine" prop has been deprecated. Please use "logic" instead.');const f=os(h,{...t,...v});return C.createElement(s,{value:f,children:c})}r.displayName="ActorProvider";function i(){const c=C.useContext(n);if(!c)throw new Error(`You used a hook from "${r.displayName}" but it's not inside a <${r.displayName}> component.`);return c}function u(c,h){const d=i();return us(d,c,h)}return{Provider:r,useActorRef:i,useSelector:u}}export{Pe as R,It as a,as as b,zt as c,Ht as d,hs as e,fs as f,Me as g,C as r,Fn as s};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>SAGA Dashboard</title>
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-C_MbLZJP.js"></script>
|
|
9
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-xstate-Dogcz2PC.js">
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-radix-BuqlnHDi.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BQ8AP4vp.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-markdown-Cy8XX9Jb.js">
|
|
13
|
+
<link rel="stylesheet" crossorigin href="/assets/index-BBUWGVOv.css">
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="root"></div>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@saga-ai/dashboard",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "Dashboard and session monitoring for SAGA - Structured Autonomous Goal Achievement",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"saga": "./dist/cli.cjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/cli.cjs",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"claude",
|
|
12
|
+
"saga",
|
|
13
|
+
"dashboard",
|
|
14
|
+
"monitoring",
|
|
15
|
+
"sessions"
|
|
16
|
+
],
|
|
17
|
+
"author": "Roei Avrahami <roei.avrahami2@gmail.com>",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Roeia1/saga.git",
|
|
22
|
+
"directory": "packages/dashboard"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/Roeia1/saga#readme",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"chokidar": "^5.0.0",
|
|
27
|
+
"commander": "^14.0.2",
|
|
28
|
+
"express": "^5.2.1",
|
|
29
|
+
"gray-matter": "^4.0.3",
|
|
30
|
+
"ws": "^8.19.0",
|
|
31
|
+
"@saga-ai/types": "0.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@chromatic-com/storybook": "^5.0.0",
|
|
35
|
+
"@playwright/test": "^1.58.0",
|
|
36
|
+
"@radix-ui/react-collapsible": "^1.1.12",
|
|
37
|
+
"@radix-ui/react-progress": "^1.1.8",
|
|
38
|
+
"@radix-ui/react-slot": "^1.2.4",
|
|
39
|
+
"@radix-ui/react-tabs": "^1.1.13",
|
|
40
|
+
"@radix-ui/react-toast": "^1.2.15",
|
|
41
|
+
"@storybook/addon-a11y": "^10.2.1",
|
|
42
|
+
"@storybook/addon-docs": "^10.2.1",
|
|
43
|
+
"@storybook/addon-onboarding": "^10.2.1",
|
|
44
|
+
"@storybook/addon-vitest": "^10.2.1",
|
|
45
|
+
"@storybook/react-vite": "^10.2.1",
|
|
46
|
+
"@tailwindcss/postcss": "^4.1.18",
|
|
47
|
+
"@tailwindcss/typography": "^0.5.19",
|
|
48
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
49
|
+
"@tanstack/react-virtual": "^3.13.18",
|
|
50
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
51
|
+
"@testing-library/react": "^16.3.2",
|
|
52
|
+
"@types/express": "^5.0.6",
|
|
53
|
+
"@types/node": "^25.1.0",
|
|
54
|
+
"@types/react": "^19.2.10",
|
|
55
|
+
"@types/react-dom": "^19.2.3",
|
|
56
|
+
"@types/supertest": "^6.0.3",
|
|
57
|
+
"@types/ws": "^8.18.1",
|
|
58
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
59
|
+
"@vitest/browser": "^4.0.18",
|
|
60
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
61
|
+
"@xstate/react": "^6.0.0",
|
|
62
|
+
"class-variance-authority": "^0.7.1",
|
|
63
|
+
"clsx": "^2.1.1",
|
|
64
|
+
"concurrently": "^9.2.1",
|
|
65
|
+
"esbuild": "^0.27.2",
|
|
66
|
+
"jsdom": "^27.4.0",
|
|
67
|
+
"lucide-react": "^0.563.0",
|
|
68
|
+
"playwright": "^1.58.0",
|
|
69
|
+
"postcss": "^8.5.6",
|
|
70
|
+
"react": "^19.2.4",
|
|
71
|
+
"react-dom": "^19.2.4",
|
|
72
|
+
"react-markdown": "^10.1.0",
|
|
73
|
+
"react-router": "^7.13.0",
|
|
74
|
+
"remark-gfm": "^4.0.1",
|
|
75
|
+
"storybook": "^10.2.1",
|
|
76
|
+
"supertest": "^7.2.2",
|
|
77
|
+
"tailwind-merge": "^3.4.0",
|
|
78
|
+
"tailwindcss": "^4.1.18",
|
|
79
|
+
"tw-animate-css": "^1.4.0",
|
|
80
|
+
"typescript": "^5.7.0",
|
|
81
|
+
"vite": "^7.3.1",
|
|
82
|
+
"vitest": "^4.0.18",
|
|
83
|
+
"xstate": "^5.26.0"
|
|
84
|
+
},
|
|
85
|
+
"engines": {
|
|
86
|
+
"node": ">=18.0.0"
|
|
87
|
+
},
|
|
88
|
+
"files": [
|
|
89
|
+
"dist/",
|
|
90
|
+
"README.md"
|
|
91
|
+
],
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build:cli": "esbuild src/cli.ts --bundle --platform=node --outfile=dist/cli.cjs --format=cjs --banner:js='#!/usr/bin/env node' --external:express --external:ws --external:chokidar --external:gray-matter --external:commander",
|
|
94
|
+
"build:client": "vite build --config src/client/vite.config.ts",
|
|
95
|
+
"build": "pnpm lint && concurrently -g \"pnpm build:cli\" \"pnpm build:client\"",
|
|
96
|
+
"test": "pnpm build && vitest run && pnpm test:integration && pnpm test:e2e",
|
|
97
|
+
"test:watch": "vitest",
|
|
98
|
+
"test:integration": "playwright test --config src/client/playwright.config.ts",
|
|
99
|
+
"test:integration:ui": "playwright test --config src/client/playwright.config.ts --ui",
|
|
100
|
+
"test:e2e": "playwright test --config src/client/playwright.e2e.config.ts",
|
|
101
|
+
"test:e2e:ui": "playwright test --config src/client/playwright.e2e.config.ts --ui",
|
|
102
|
+
"test-storybook": "vitest --project=storybook",
|
|
103
|
+
"test:storybook": "vitest run --project=storybook",
|
|
104
|
+
"test:storybook:update": "vitest run --project=storybook --update",
|
|
105
|
+
"publish:npm": "pnpm build && pnpm test && pnpm publish --access public",
|
|
106
|
+
"storybook": "storybook dev -p 6006 -c src/client/.storybook",
|
|
107
|
+
"build-storybook": "storybook build -c src/client/.storybook -o storybook-static",
|
|
108
|
+
"lint": "biome check .",
|
|
109
|
+
"lint:fix": "biome check --write .",
|
|
110
|
+
"format": "biome format --write ."
|
|
111
|
+
}
|
|
112
|
+
}
|