@herdctl/web 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,7 +57,7 @@ Error generating stack: `+u.message+`
|
|
|
57
57
|
* @license MIT
|
|
58
58
|
*/var D0="popstate";function Q5(t={}){function l(i,s){let{pathname:o,search:c,hash:d}=i.location;return Cf("",{pathname:o,search:c,hash:d},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function r(i,s){return typeof s=="string"?s:xi(s)}return P5(l,r,null,t)}function tt(t,l){if(t===!1||t===null||typeof t>"u")throw new Error(l)}function zn(t,l){if(!t){typeof console<"u"&&console.warn(l);try{throw new Error(l)}catch{}}}function K5(){return Math.random().toString(36).substring(2,10)}function O0(t,l){return{usr:t.state,key:t.key,idx:l}}function Cf(t,l,r=null,i){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof l=="string"?ua(l):l,state:r,key:l&&l.key||i||K5()}}function xi({pathname:t="/",search:l="",hash:r=""}){return l&&l!=="?"&&(t+=l.charAt(0)==="?"?l:"?"+l),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ua(t){let l={};if(t){let r=t.indexOf("#");r>=0&&(l.hash=t.substring(r),t=t.substring(0,r));let i=t.indexOf("?");i>=0&&(l.search=t.substring(i),t=t.substring(0,i)),t&&(l.pathname=t)}return l}function P5(t,l,r,i={}){let{window:s=document.defaultView,v5Compat:o=!1}=i,c=s.history,d="POP",m=null,p=x();p==null&&(p=0,c.replaceState({...c.state,idx:p},""));function x(){return(c.state||{idx:null}).idx}function y(){d="POP";let z=x(),M=z==null?null:z-p;p=z,m&&m({action:d,location:T.location,delta:M})}function v(z,M){d="PUSH";let U=Cf(T.location,z,M);p=x()+1;let N=O0(U,p),V=T.createHref(U);try{c.pushState(N,"",V)}catch(F){if(F instanceof DOMException&&F.name==="DataCloneError")throw F;s.location.assign(V)}o&&m&&m({action:d,location:T.location,delta:1})}function S(z,M){d="REPLACE";let U=Cf(T.location,z,M);p=x();let N=O0(U,p),V=T.createHref(U);c.replaceState(N,"",V),o&&m&&m({action:d,location:T.location,delta:0})}function C(z){return W5(z)}let T={get action(){return d},get location(){return t(s,c)},listen(z){if(m)throw new Error("A history only accepts one active listener");return s.addEventListener(D0,y),m=z,()=>{s.removeEventListener(D0,y),m=null}},createHref(z){return l(s,z)},createURL:C,encodeLocation(z){let M=C(z);return{pathname:M.pathname,search:M.search,hash:M.hash}},push:v,replace:S,go(z){return c.go(z)}};return T}function W5(t,l=!1){let r="http://localhost";typeof window<"u"&&(r=window.location.origin!=="null"?window.location.origin:window.location.href),tt(r,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:xi(t);return i=i.replace(/ $/,"%20"),!l&&i.startsWith("//")&&(i=r+i),new URL(i,r)}function sp(t,l,r="/"){return ey(t,l,r,!1)}function ey(t,l,r,i){let s=typeof l=="string"?ua(l):l,o=tl(s.pathname||"/",r);if(o==null)return null;let c=op(t);ty(c);let d=null;for(let m=0;d==null&&m<c.length;++m){let p=dy(o);d=cy(c[m],p,i)}return d}function op(t,l=[],r=[],i="",s=!1){let o=(c,d,m=s,p)=>{let x={relativePath:p===void 0?c.path||"":p,caseSensitive:c.caseSensitive===!0,childrenIndex:d,route:c};if(x.relativePath.startsWith("/")){if(!x.relativePath.startsWith(i)&&m)return;tt(x.relativePath.startsWith(i),`Absolute route path "${x.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),x.relativePath=x.relativePath.slice(i.length)}let y=el([i,x.relativePath]),v=r.concat(x);c.children&&c.children.length>0&&(tt(c.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${y}".`),op(c.children,l,v,y,m)),!(c.path==null&&!c.index)&&l.push({path:y,score:sy(y,c.index),routesMeta:v})};return t.forEach((c,d)=>{var m;if(c.path===""||!((m=c.path)!=null&&m.includes("?")))o(c,d);else for(let p of cp(c.path))o(c,d,!0,p)}),l}function cp(t){let l=t.split("/");if(l.length===0)return[];let[r,...i]=l,s=r.endsWith("?"),o=r.replace(/\?$/,"");if(i.length===0)return s?[o,""]:[o];let c=cp(i.join("/")),d=[];return d.push(...c.map(m=>m===""?o:[o,m].join("/"))),s&&d.push(...c),d.map(m=>t.startsWith("/")&&m===""?"/":m)}function ty(t){t.sort((l,r)=>l.score!==r.score?r.score-l.score:oy(l.routesMeta.map(i=>i.childrenIndex),r.routesMeta.map(i=>i.childrenIndex)))}var ny=/^:[\w-]+$/,ly=3,ry=2,ay=1,iy=10,uy=-2,L0=t=>t==="*";function sy(t,l){let r=t.split("/"),i=r.length;return r.some(L0)&&(i+=uy),l&&(i+=ry),r.filter(s=>!L0(s)).reduce((s,o)=>s+(ny.test(o)?ly:o===""?ay:iy),i)}function oy(t,l){return t.length===l.length&&t.slice(0,-1).every((i,s)=>i===l[s])?t[t.length-1]-l[l.length-1]:0}function cy(t,l,r=!1){let{routesMeta:i}=t,s={},o="/",c=[];for(let d=0;d<i.length;++d){let m=i[d],p=d===i.length-1,x=o==="/"?l:l.slice(o.length)||"/",y=as({path:m.relativePath,caseSensitive:m.caseSensitive,end:p},x),v=m.route;if(!y&&p&&r&&!i[i.length-1].route.index&&(y=as({path:m.relativePath,caseSensitive:m.caseSensitive,end:!1},x)),!y)return null;Object.assign(s,y.params),c.push({params:s,pathname:el([o,y.pathname]),pathnameBase:gy(el([o,y.pathnameBase])),route:v}),y.pathnameBase!=="/"&&(o=el([o,y.pathnameBase]))}return c}function as(t,l){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[r,i]=fy(t.path,t.caseSensitive,t.end),s=l.match(r);if(!s)return null;let o=s[0],c=o.replace(/(.)\/+$/,"$1"),d=s.slice(1);return{params:i.reduce((p,{paramName:x,isOptional:y},v)=>{if(x==="*"){let C=d[v]||"";c=o.slice(0,o.length-C.length).replace(/(.)\/+$/,"$1")}const S=d[v];return y&&!S?p[x]=void 0:p[x]=(S||"").replace(/%2F/g,"/"),p},{}),pathname:o,pathnameBase:c,pattern:t}}function fy(t,l=!1,r=!0){zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let i=[],s="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(c,d,m)=>(i.push({paramName:d,isOptional:m!=null}),m?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(i.push({paramName:"*"}),s+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?s+="\\/*$":t!==""&&t!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,l?void 0:"i"),i]}function dy(t){try{return t.split("/").map(l=>decodeURIComponent(l).replace(/\//g,"%2F")).join("/")}catch(l){return zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${l}).`),t}}function tl(t,l){if(l==="/")return t;if(!t.toLowerCase().startsWith(l.toLowerCase()))return null;let r=l.endsWith("/")?l.length-1:l.length,i=t.charAt(r);return i&&i!=="/"?null:t.slice(r)||"/"}var hy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function my(t,l="/"){let{pathname:r,search:i="",hash:s=""}=typeof t=="string"?ua(t):t,o;return r?(r=r.replace(/\/\/+/g,"/"),r.startsWith("/")?o=U0(r.substring(1),"/"):o=U0(r,l)):o=l,{pathname:o,search:yy(i),hash:xy(s)}}function U0(t,l){let r=l.replace(/\/+$/,"").split("/");return t.split("/").forEach(s=>{s===".."?r.length>1&&r.pop():s!=="."&&r.push(s)}),r.length>1?r.join("/"):"/"}function Xc(t,l,r,i){return`Cannot include a '${t}' character in a manually specified \`to.${l}\` field [${JSON.stringify(i)}]. 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 py(t){return t.filter((l,r)=>r===0||l.route.path&&l.route.path.length>0)}function fp(t){let l=py(t);return l.map((r,i)=>i===l.length-1?r.pathname:r.pathnameBase)}function dp(t,l,r,i=!1){let s;typeof t=="string"?s=ua(t):(s={...t},tt(!s.pathname||!s.pathname.includes("?"),Xc("?","pathname","search",s)),tt(!s.pathname||!s.pathname.includes("#"),Xc("#","pathname","hash",s)),tt(!s.search||!s.search.includes("#"),Xc("#","search","hash",s)));let o=t===""||s.pathname==="",c=o?"/":s.pathname,d;if(c==null)d=r;else{let y=l.length-1;if(!i&&c.startsWith("..")){let v=c.split("/");for(;v[0]==="..";)v.shift(),y-=1;s.pathname=v.join("/")}d=y>=0?l[y]:"/"}let m=my(s,d),p=c&&c!=="/"&&c.endsWith("/"),x=(o||c===".")&&r.endsWith("/");return!m.pathname.endsWith("/")&&(p||x)&&(m.pathname+="/"),m}var el=t=>t.join("/").replace(/\/\/+/g,"/"),gy=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),yy=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,xy=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,by=class{constructor(t,l,r,i=!1){this.status=t,this.statusText=l||"",this.internal=i,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}};function vy(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function Sy(t){return t.map(l=>l.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var hp=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mp(t,l){let r=t;if(typeof r!="string"||!hy.test(r))return{absoluteURL:void 0,isExternal:!1,to:r};let i=r,s=!1;if(hp)try{let o=new URL(window.location.href),c=r.startsWith("//")?new URL(o.protocol+r):new URL(r),d=tl(c.pathname,l);c.origin===o.origin&&d!=null?r=d+c.search+c.hash:s=!0}catch{zn(!1,`<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:s,to:r}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var pp=["POST","PUT","PATCH","DELETE"];new Set(pp);var wy=["GET",...pp];new Set(wy);var sa=E.createContext(null);sa.displayName="DataRouter";var ps=E.createContext(null);ps.displayName="DataRouterState";var ky=E.createContext(!1),gp=E.createContext({isTransitioning:!1});gp.displayName="ViewTransition";var Cy=E.createContext(new Map);Cy.displayName="Fetchers";var Ey=E.createContext(null);Ey.displayName="Await";var pn=E.createContext(null);pn.displayName="Navigation";var Ei=E.createContext(null);Ei.displayName="Location";var Tn=E.createContext({outlet:null,matches:[],isDataRoute:!1});Tn.displayName="Route";var Vf=E.createContext(null);Vf.displayName="RouteError";var yp="REACT_ROUTER_ERROR",My="REDIRECT",Ny="ROUTE_ERROR_RESPONSE";function jy(t){if(t.startsWith(`${yp}:${My}:{`))try{let l=JSON.parse(t.slice(28));if(typeof l=="object"&&l&&typeof l.status=="number"&&typeof l.statusText=="string"&&typeof l.location=="string"&&typeof l.reloadDocument=="boolean"&&typeof l.replace=="boolean")return l}catch{}}function Ay(t){if(t.startsWith(`${yp}:${Ny}:{`))try{let l=JSON.parse(t.slice(40));if(typeof l=="object"&&l&&typeof l.status=="number"&&typeof l.statusText=="string")return new by(l.status,l.statusText,l.data)}catch{}}function zy(t,{relative:l}={}){tt(Mi(),"useHref() may be used only in the context of a <Router> component.");let{basename:r,navigator:i}=E.useContext(pn),{hash:s,pathname:o,search:c}=Ni(t,{relative:l}),d=o;return r!=="/"&&(d=o==="/"?r:el([r,o])),i.createHref({pathname:d,search:c,hash:s})}function Mi(){return E.useContext(Ei)!=null}function ll(){return tt(Mi(),"useLocation() may be used only in the context of a <Router> component."),E.useContext(Ei).location}var xp="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function bp(t){E.useContext(pn).static||E.useLayoutEffect(t)}function If(){let{isDataRoute:t}=E.useContext(Tn);return t?Vy():Ty()}function Ty(){tt(Mi(),"useNavigate() may be used only in the context of a <Router> component.");let t=E.useContext(sa),{basename:l,navigator:r}=E.useContext(pn),{matches:i}=E.useContext(Tn),{pathname:s}=ll(),o=JSON.stringify(fp(i)),c=E.useRef(!1);return bp(()=>{c.current=!0}),E.useCallback((m,p={})=>{if(zn(c.current,xp),!c.current)return;if(typeof m=="number"){r.go(m);return}let x=dp(m,JSON.parse(o),s,p.relative==="path");t==null&&l!=="/"&&(x.pathname=x.pathname==="/"?l:el([l,x.pathname])),(p.replace?r.replace:r.push)(x,p.state,p)},[l,r,o,s,t])}E.createContext(null);function Jf(){let{matches:t}=E.useContext(Tn),l=t[t.length-1];return l?l.params:{}}function Ni(t,{relative:l}={}){let{matches:r}=E.useContext(Tn),{pathname:i}=ll(),s=JSON.stringify(fp(r));return E.useMemo(()=>dp(t,JSON.parse(s),i,l==="path"),[t,s,i,l])}function _y(t,l){return vp(t,l)}function vp(t,l,r,i,s){var U;tt(Mi(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=E.useContext(pn),{matches:c}=E.useContext(Tn),d=c[c.length-1],m=d?d.params:{},p=d?d.pathname:"/",x=d?d.pathnameBase:"/",y=d&&d.route;{let N=y&&y.path||"";wp(p,!y||N.endsWith("*")||N.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${p}" (under <Route path="${N}">) 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.
|
|
59
59
|
|
|
60
|
-
Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let v=ll(),S;if(l){let N=typeof l=="string"?ua(l):l;tt(x==="/"||((U=N.pathname)==null?void 0:U.startsWith(x)),`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 "${x}" but pathname "${N.pathname}" was given in the \`location\` prop.`),S=N}else S=v;let C=S.pathname||"/",T=C;if(x!=="/"){let N=x.replace(/^\//,"").split("/");T="/"+C.replace(/^\//,"").split("/").slice(N.length).join("/")}let z=sp(t,{pathname:T});zn(y||z!=null,`No routes matched location "${S.pathname}${S.search}${S.hash}" `),zn(z==null||z[z.length-1].route.element!==void 0||z[z.length-1].route.Component!==void 0||z[z.length-1].route.lazy!==void 0,`Matched leaf route at location "${S.pathname}${S.search}${S.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 M=Uy(z&&z.map(N=>Object.assign({},N,{params:Object.assign({},m,N.params),pathname:el([x,o.encodeLocation?o.encodeLocation(N.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?x:el([x,o.encodeLocation?o.encodeLocation(N.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),c,r,i,s);return l&&M?E.createElement(Ei.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...S},navigationType:"POP"}},M):M}function Ry(){let t=$y(),l=vy(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:i},o={padding:"2px 4px",backgroundColor:i},c=null;return console.error("Error handled by React Router default ErrorBoundary:",t),c=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:o},"ErrorBoundary")," or"," ",E.createElement("code",{style:o},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},l),r?E.createElement("pre",{style:s},r):null,c)}var Dy=E.createElement(Ry,null),Sp=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,l){return l.location!==t.location||l.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:l.error,location:l.location,revalidation:t.revalidation||l.revalidation}}componentDidCatch(t,l){this.props.onError?this.props.onError(t,l):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const r=Ay(t.digest);r&&(t=r)}let l=t!==void 0?E.createElement(Tn.Provider,{value:this.props.routeContext},E.createElement(Vf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?E.createElement(Oy,{error:t},l):l}};Sp.contextType=ky;var Qc=new WeakMap;function Oy({children:t,error:l}){let{basename:r}=E.useContext(pn);if(typeof l=="object"&&l&&"digest"in l&&typeof l.digest=="string"){let i=jy(l.digest);if(i){let s=Qc.get(l);if(s)throw s;let o=mp(i.location,r);if(hp&&!Qc.get(l))if(o.isExternal||i.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:i.replace}));throw Qc.set(l,c),c}return E.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return t}function Ly({routeContext:t,match:l,children:r}){let i=E.useContext(sa);return i&&i.static&&i.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=l.route.id),E.createElement(Tn.Provider,{value:t},r)}function Uy(t,l=[],r=null,i=null,s=null){if(t==null){if(!r)return null;if(r.errors)t=r.matches;else if(l.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let o=t,c=r==null?void 0:r.errors;if(c!=null){let x=o.findIndex(y=>y.route.id&&(c==null?void 0:c[y.route.id])!==void 0);tt(x>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),o=o.slice(0,Math.min(o.length,x+1))}let d=!1,m=-1;if(r)for(let x=0;x<o.length;x++){let y=o[x];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(m=x),y.route.id){let{loaderData:v,errors:S}=r,C=y.route.loader&&!v.hasOwnProperty(y.route.id)&&(!S||S[y.route.id]===void 0);if(y.route.lazy||C){d=!0,m>=0?o=o.slice(0,m+1):o=[o[0]];break}}}let p=r&&i?(x,y)=>{var v,S;i(x,{location:r.location,params:((S=(v=r.matches)==null?void 0:v[0])==null?void 0:S.params)??{},unstable_pattern:Sy(r.matches),errorInfo:y})}:void 0;return o.reduceRight((x,y,v)=>{let S,C=!1,T=null,z=null;r&&(S=c&&y.route.id?c[y.route.id]:void 0,T=y.route.errorElement||Dy,d&&(m<0&&v===0?(wp("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,z=null):m===v&&(C=!0,z=y.route.hydrateFallbackElement||null)));let M=l.concat(o.slice(0,v+1)),U=()=>{let N;return S?N=T:C?N=z:y.route.Component?N=E.createElement(y.route.Component,null):y.route.element?N=y.route.element:N=x,E.createElement(Ly,{match:y,routeContext:{outlet:x,matches:M,isDataRoute:r!=null},children:N})};return r&&(y.route.ErrorBoundary||y.route.errorElement||v===0)?E.createElement(Sp,{location:r.location,revalidation:r.revalidation,component:T,error:S,children:U(),routeContext:{outlet:null,matches:M,isDataRoute:!0},onError:p}):U()},null)}function Ff(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hy(t){let l=E.useContext(sa);return tt(l,Ff(t)),l}function By(t){let l=E.useContext(ps);return tt(l,Ff(t)),l}function Zy(t){let l=E.useContext(Tn);return tt(l,Ff(t)),l}function Yf(t){let l=Zy(t),r=l.matches[l.matches.length-1];return tt(r.route.id,`${t} can only be used on routes that contain a unique "id"`),r.route.id}function qy(){return Yf("useRouteId")}function $y(){var i;let t=E.useContext(Vf),l=By("useRouteError"),r=Yf("useRouteError");return t!==void 0?t:(i=l.errors)==null?void 0:i[r]}function Vy(){let{router:t}=Hy("useNavigate"),l=Yf("useNavigate"),r=E.useRef(!1);return bp(()=>{r.current=!0}),E.useCallback(async(s,o={})=>{zn(r.current,xp),r.current&&(typeof s=="number"?await t.navigate(s):await t.navigate(s,{fromRouteId:l,...o}))},[t,l])}var H0={};function wp(t,l,r){!l&&!H0[t]&&(H0[t]=!0,zn(!1,r))}E.memo(Iy);function Iy({routes:t,future:l,state:r,onError:i}){return vp(t,void 0,r,i,l)}function Dl(t){tt(!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 Jy({basename:t="/",children:l=null,location:r,navigationType:i="POP",navigator:s,static:o=!1,unstable_useTransitions:c}){tt(!Mi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let d=t.replace(/^\/*/,"/"),m=E.useMemo(()=>({basename:d,navigator:s,static:o,unstable_useTransitions:c,future:{}}),[d,s,o,c]);typeof r=="string"&&(r=ua(r));let{pathname:p="/",search:x="",hash:y="",state:v=null,key:S="default"}=r,C=E.useMemo(()=>{let T=tl(p,d);return T==null?null:{location:{pathname:T,search:x,hash:y,state:v,key:S},navigationType:i}},[d,p,x,y,v,S,i]);return zn(C!=null,`<Router basename="${d}"> is not able to match the URL "${p}${x}${y}" because it does not start with the basename, so the <Router> won't render anything.`),C==null?null:E.createElement(pn.Provider,{value:m},E.createElement(Ei.Provider,{children:l,value:C}))}function Fy({children:t,location:l}){return _y(Ef(t),l)}function Ef(t,l=[]){let r=[];return E.Children.forEach(t,(i,s)=>{if(!E.isValidElement(i))return;let o=[...l,s];if(i.type===E.Fragment){r.push.apply(r,Ef(i.props.children,o));return}tt(i.type===Dl,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),tt(!i.props.index||!i.props.children,"An index route cannot have child routes.");let c={id:i.props.id||o.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(c.children=Ef(i.props.children,o)),r.push(c)}),r}var es="get",ts="application/x-www-form-urlencoded";function gs(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Yy(t){return gs(t)&&t.tagName.toLowerCase()==="button"}function Gy(t){return gs(t)&&t.tagName.toLowerCase()==="form"}function Xy(t){return gs(t)&&t.tagName.toLowerCase()==="input"}function Qy(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Ky(t,l){return t.button===0&&(!l||l==="_self")&&!Qy(t)}var Yu=null;function Py(){if(Yu===null)try{new FormData(document.createElement("form"),0),Yu=!1}catch{Yu=!0}return Yu}var Wy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Kc(t){return t!=null&&!Wy.has(t)?(zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ts}"`),null):t}function ex(t,l){let r,i,s,o,c;if(Gy(t)){let d=t.getAttribute("action");i=d?tl(d,l):null,r=t.getAttribute("method")||es,s=Kc(t.getAttribute("enctype"))||ts,o=new FormData(t)}else if(Yy(t)||Xy(t)&&(t.type==="submit"||t.type==="image")){let d=t.form;if(d==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=t.getAttribute("formaction")||d.getAttribute("action");if(i=m?tl(m,l):null,r=t.getAttribute("formmethod")||d.getAttribute("method")||es,s=Kc(t.getAttribute("formenctype"))||Kc(d.getAttribute("enctype"))||ts,o=new FormData(d,t),!Py()){let{name:p,type:x,value:y}=t;if(x==="image"){let v=p?`${p}.`:"";o.append(`${v}x`,"0"),o.append(`${v}y`,"0")}else p&&o.append(p,y)}}else{if(gs(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=es,i=null,s=ts,c=t}return o&&s==="text/plain"&&(c=o,o=void 0),{action:i,method:r.toLowerCase(),encType:s,formData:o,body:c}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Gf(t,l){if(t===!1||t===null||typeof t>"u")throw new Error(l)}function tx(t,l,r,i){let s=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${i}`:s.pathname=`${s.pathname}.${i}`:s.pathname==="/"?s.pathname=`_root.${i}`:l&&tl(s.pathname,l)==="/"?s.pathname=`${l.replace(/\/$/,"")}/_root.${i}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${i}`,s}async function nx(t,l){if(t.id in l)return l[t.id];try{let r=await import(t.module);return l[t.id]=r,r}catch(r){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function lx(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function rx(t,l,r){let i=await Promise.all(t.map(async s=>{let o=l.routes[s.route.id];if(o){let c=await nx(o,r);return c.links?c.links():[]}return[]}));return sx(i.flat(1).filter(lx).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function B0(t,l,r,i,s,o){let c=(m,p)=>r[p]?m.route.id!==r[p].route.id:!0,d=(m,p)=>{var x;return r[p].pathname!==m.pathname||((x=r[p].route.path)==null?void 0:x.endsWith("*"))&&r[p].params["*"]!==m.params["*"]};return o==="assets"?l.filter((m,p)=>c(m,p)||d(m,p)):o==="data"?l.filter((m,p)=>{var y;let x=i.routes[m.route.id];if(!x||!x.hasLoader)return!1;if(c(m,p)||d(m,p))return!0;if(m.route.shouldRevalidate){let v=m.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((y=r[0])==null?void 0:y.params)||{},nextUrl:new URL(t,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function ax(t,l,{includeHydrateFallback:r}={}){return ix(t.map(i=>{let s=l.routes[i.route.id];if(!s)return[];let o=[s.module];return s.clientActionModule&&(o=o.concat(s.clientActionModule)),s.clientLoaderModule&&(o=o.concat(s.clientLoaderModule)),r&&s.hydrateFallbackModule&&(o=o.concat(s.hydrateFallbackModule)),s.imports&&(o=o.concat(s.imports)),o}).flat(1))}function ix(t){return[...new Set(t)]}function ux(t){let l={},r=Object.keys(t).sort();for(let i of r)l[i]=t[i];return l}function sx(t,l){let r=new Set;return new Set(l),t.reduce((i,s)=>{let o=JSON.stringify(ux(s));return r.has(o)||(r.add(o),i.push({key:o,link:s})),i},[])}function kp(){let t=E.useContext(sa);return Gf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function ox(){let t=E.useContext(ps);return Gf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Xf=E.createContext(void 0);Xf.displayName="FrameworkContext";function Cp(){let t=E.useContext(Xf);return Gf(t,"You must render this element inside a <HydratedRouter> element"),t}function cx(t,l){let r=E.useContext(Xf),[i,s]=E.useState(!1),[o,c]=E.useState(!1),{onFocus:d,onBlur:m,onMouseEnter:p,onMouseLeave:x,onTouchStart:y}=l,v=E.useRef(null);E.useEffect(()=>{if(t==="render"&&c(!0),t==="viewport"){let T=M=>{M.forEach(U=>{c(U.isIntersecting)})},z=new IntersectionObserver(T,{threshold:.5});return v.current&&z.observe(v.current),()=>{z.disconnect()}}},[t]),E.useEffect(()=>{if(i){let T=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(T)}}},[i]);let S=()=>{s(!0)},C=()=>{s(!1),c(!1)};return r?t!=="intent"?[o,v,{}]:[o,v,{onFocus:si(d,S),onBlur:si(m,C),onMouseEnter:si(p,S),onMouseLeave:si(x,C),onTouchStart:si(y,S)}]:[!1,v,{}]}function si(t,l){return r=>{t&&t(r),r.defaultPrevented||l(r)}}function fx({page:t,...l}){let{router:r}=kp(),i=E.useMemo(()=>sp(r.routes,t,r.basename),[r.routes,t,r.basename]);return i?E.createElement(hx,{page:t,matches:i,...l}):null}function dx(t){let{manifest:l,routeModules:r}=Cp(),[i,s]=E.useState([]);return E.useEffect(()=>{let o=!1;return rx(t,l,r).then(c=>{o||s(c)}),()=>{o=!0}},[t,l,r]),i}function hx({page:t,matches:l,...r}){let i=ll(),{future:s,manifest:o,routeModules:c}=Cp(),{basename:d}=kp(),{loaderData:m,matches:p}=ox(),x=E.useMemo(()=>B0(t,l,p,o,i,"data"),[t,l,p,o,i]),y=E.useMemo(()=>B0(t,l,p,o,i,"assets"),[t,l,p,o,i]),v=E.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let T=new Set,z=!1;if(l.forEach(U=>{var V;let N=o.routes[U.route.id];!N||!N.hasLoader||(!x.some(F=>F.route.id===U.route.id)&&U.route.id in m&&((V=c[U.route.id])!=null&&V.shouldRevalidate)||N.hasClientLoader?z=!0:T.add(U.route.id))}),T.size===0)return[];let M=tx(t,d,s.unstable_trailingSlashAwareDataRequests,"data");return z&&T.size>0&&M.searchParams.set("_routes",l.filter(U=>T.has(U.route.id)).map(U=>U.route.id).join(",")),[M.pathname+M.search]},[d,s.unstable_trailingSlashAwareDataRequests,m,i,o,x,l,t,c]),S=E.useMemo(()=>ax(y,o),[y,o]),C=dx(y);return E.createElement(E.Fragment,null,v.map(T=>E.createElement("link",{key:T,rel:"prefetch",as:"fetch",href:T,...r})),S.map(T=>E.createElement("link",{key:T,rel:"modulepreload",href:T,...r})),C.map(({key:T,link:z})=>E.createElement("link",{key:T,nonce:r.nonce,...z,crossOrigin:z.crossOrigin??r.crossOrigin})))}function mx(...t){return l=>{t.forEach(r=>{typeof r=="function"?r(l):r!=null&&(r.current=l)})}}var px=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{px&&(window.__reactRouterVersion="7.13.0")}catch{}function gx({basename:t,children:l,unstable_useTransitions:r,window:i}){let s=E.useRef();s.current==null&&(s.current=Q5({window:i,v5Compat:!0}));let o=s.current,[c,d]=E.useState({action:o.action,location:o.location}),m=E.useCallback(p=>{r===!1?d(p):E.startTransition(()=>d(p))},[r]);return E.useLayoutEffect(()=>o.listen(m),[o,m]),E.createElement(Jy,{basename:t,children:l,location:c.location,navigationType:c.action,navigator:o,unstable_useTransitions:r})}var Ep=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yt=E.forwardRef(function({onClick:l,discover:r="render",prefetch:i="none",relative:s,reloadDocument:o,replace:c,state:d,target:m,to:p,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:v,...S},C){let{basename:T,unstable_useTransitions:z}=E.useContext(pn),M=typeof p=="string"&&Ep.test(p),U=mp(p,T);p=U.to;let N=zy(p,{relative:s}),[V,F,_]=cx(i,S),I=vx(p,{replace:c,state:d,target:m,preventScrollReset:x,relative:s,viewTransition:y,unstable_defaultShouldRevalidate:v,unstable_useTransitions:z});function se(O){l&&l(O),O.defaultPrevented||I(O)}let oe=E.createElement("a",{...S,..._,href:U.absoluteURL||N,onClick:U.isExternal||o?l:se,ref:mx(C,F),target:m,"data-discover":!M&&r==="render"?"true":void 0});return V&&!M?E.createElement(E.Fragment,null,oe,E.createElement(fx,{page:N})):oe});yt.displayName="Link";var yx=E.forwardRef(function({"aria-current":l="page",caseSensitive:r=!1,className:i="",end:s=!1,style:o,to:c,viewTransition:d,children:m,...p},x){let y=Ni(c,{relative:p.relative}),v=ll(),S=E.useContext(ps),{navigator:C,basename:T}=E.useContext(pn),z=S!=null&&Ex(y)&&d===!0,M=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,U=v.pathname,N=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;r||(U=U.toLowerCase(),N=N?N.toLowerCase():null,M=M.toLowerCase()),N&&T&&(N=tl(N,T)||N);const V=M!=="/"&&M.endsWith("/")?M.length-1:M.length;let F=U===M||!s&&U.startsWith(M)&&U.charAt(V)==="/",_=N!=null&&(N===M||!s&&N.startsWith(M)&&N.charAt(M.length)==="/"),I={isActive:F,isPending:_,isTransitioning:z},se=F?l:void 0,oe;typeof i=="function"?oe=i(I):oe=[i,F?"active":null,_?"pending":null,z?"transitioning":null].filter(Boolean).join(" ");let O=typeof o=="function"?o(I):o;return E.createElement(yt,{...p,"aria-current":se,className:oe,ref:x,style:O,to:c,viewTransition:d},typeof m=="function"?m(I):m)});yx.displayName="NavLink";var xx=E.forwardRef(({discover:t="render",fetcherKey:l,navigate:r,reloadDocument:i,replace:s,state:o,method:c=es,action:d,onSubmit:m,relative:p,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:v,...S},C)=>{let{unstable_useTransitions:T}=E.useContext(pn),z=kx(),M=Cx(d,{relative:p}),U=c.toLowerCase()==="get"?"get":"post",N=typeof d=="string"&&Ep.test(d),V=F=>{if(m&&m(F),F.defaultPrevented)return;F.preventDefault();let _=F.nativeEvent.submitter,I=(_==null?void 0:_.getAttribute("formmethod"))||c,se=()=>z(_||F.currentTarget,{fetcherKey:l,method:I,navigate:r,replace:s,state:o,relative:p,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:v});T&&r!==!1?E.startTransition(()=>se()):se()};return E.createElement("form",{ref:C,method:U,action:M,onSubmit:i?m:V,...S,"data-discover":!N&&t==="render"?"true":void 0})});xx.displayName="Form";function bx(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Mp(t){let l=E.useContext(sa);return tt(l,bx(t)),l}function vx(t,{target:l,replace:r,state:i,preventScrollReset:s,relative:o,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:m}={}){let p=If(),x=ll(),y=Ni(t,{relative:o});return E.useCallback(v=>{if(Ky(v,l)){v.preventDefault();let S=r!==void 0?r:xi(x)===xi(y),C=()=>p(t,{replace:S,state:i,preventScrollReset:s,relative:o,viewTransition:c,unstable_defaultShouldRevalidate:d});m?E.startTransition(()=>C()):C()}},[x,p,y,r,i,l,t,s,o,c,d,m])}var Sx=0,wx=()=>`__${String(++Sx)}__`;function kx(){let{router:t}=Mp("useSubmit"),{basename:l}=E.useContext(pn),r=qy(),i=t.fetch,s=t.navigate;return E.useCallback(async(o,c={})=>{let{action:d,method:m,encType:p,formData:x,body:y}=ex(o,l);if(c.navigate===!1){let v=c.fetcherKey||wx();await i(v,r,c.action||d,{unstable_defaultShouldRevalidate:c.unstable_defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:x,body:y,formMethod:c.method||m,formEncType:c.encType||p,flushSync:c.flushSync})}else await s(c.action||d,{unstable_defaultShouldRevalidate:c.unstable_defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:x,body:y,formMethod:c.method||m,formEncType:c.encType||p,replace:c.replace,state:c.state,fromRouteId:r,flushSync:c.flushSync,viewTransition:c.viewTransition})},[i,s,l,r])}function Cx(t,{relative:l}={}){let{basename:r}=E.useContext(pn),i=E.useContext(Tn);tt(i,"useFormAction must be used inside a RouteContext");let[s]=i.matches.slice(-1),o={...Ni(t||".",{relative:l})},c=ll();if(t==null){o.search=c.search;let d=new URLSearchParams(o.search),m=d.getAll("index");if(m.some(x=>x==="")){d.delete("index"),m.filter(y=>y).forEach(y=>d.append("index",y));let x=d.toString();o.search=x?`?${x}`:""}}return(!t||t===".")&&s.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(o.pathname=o.pathname==="/"?r:el([r,o.pathname])),xi(o)}function Ex(t,{relative:l}={}){let r=E.useContext(gp);tt(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Mp("useViewTransitionState"),s=Ni(t,{relative:l});if(!r.isTransitioning)return!1;let o=tl(r.currentLocation.pathname,i)||r.currentLocation.pathname,c=tl(r.nextLocation.pathname,i)||r.nextLocation.pathname;return as(s.pathname,c)!=null||as(s.pathname,o)!=null}function Mx(t={}){const{url:l=Nx(),onMessage:r,onStatusChange:i,initialReconnectDelay:s=1e3,maxReconnectDelay:o=3e4,pingInterval:c=3e4}=t;let d=null,m="disconnected",p=0,x=null,y=null,v=!0;function S(O){m!==O&&(m=O,i==null||i(m))}function C(){const O=s*Math.pow(2,p);return Math.min(O,o)}function T(){z(),y=setInterval(()=>{(d==null?void 0:d.readyState)===WebSocket.OPEN&&V({type:"ping"})},c)}function z(){y!==null&&(clearInterval(y),y=null)}function M(){if(!v)return;const O=C();p++,S("reconnecting"),x=setTimeout(()=>{x=null,N()},O)}function U(){x!==null&&(clearTimeout(x),x=null)}function N(){d&&(d.onopen=null,d.onclose=null,d.onerror=null,d.onmessage=null,(d.readyState===WebSocket.OPEN||d.readyState===WebSocket.CONNECTING)&&d.close());try{d=new WebSocket(l),d.onopen=()=>{p=0,S("connected"),T()},d.onclose=()=>{z(),S("disconnected"),v&&M()},d.onerror=()=>{},d.onmessage=O=>{try{const ae=JSON.parse(O.data);r==null||r(ae)}catch{}}}catch{S("disconnected"),v&&M()}}function V(O){(d==null?void 0:d.readyState)===WebSocket.OPEN&&d.send(JSON.stringify(O))}function F(O){V({type:"subscribe",payload:{agentName:O}})}function _(O){V({type:"unsubscribe",payload:{agentName:O}})}function I(){return m}function se(){v=!1,U(),z(),d&&(d.onopen=null,d.onclose=null,d.onerror=null,d.onmessage=null,(d.readyState===WebSocket.OPEN||d.readyState===WebSocket.CONNECTING)&&d.close(),d=null),S("disconnected")}function oe(){v=!0,U(),p=0,N()}return N(),{send:V,subscribe:F,unsubscribe:_,getStatus:I,disconnect:se,reconnect:oe}}function Nx(){return typeof window>"u"?"ws://localhost:3000/ws":`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}const Z0=t=>{let l;const r=new Set,i=(p,x)=>{const y=typeof p=="function"?p(l):p;if(!Object.is(y,l)){const v=l;l=x??(typeof y!="object"||y===null)?y:Object.assign({},l,y),r.forEach(S=>S(l,v))}},s=()=>l,d={setState:i,getState:s,getInitialState:()=>m,subscribe:p=>(r.add(p),()=>r.delete(p))},m=l=t(i,s,d);return d},jx=(t=>t?Z0(t):Z0),Ax=t=>t;function zx(t,l=Ax){const r=na.useSyncExternalStore(t.subscribe,na.useCallback(()=>l(t.getState()),[t,l]),na.useCallback(()=>l(t.getInitialState()),[t,l]));return na.useDebugValue(r),r}const Tx=t=>{const l=jx(t),r=i=>zx(l,i);return Object.assign(r,l),r},_x=(t=>Tx),q0=t=>Symbol.iterator in t,$0=t=>"entries"in t,V0=(t,l)=>{const r=t instanceof Map?t:new Map(t.entries()),i=l instanceof Map?l:new Map(l.entries());if(r.size!==i.size)return!1;for(const[s,o]of r)if(!i.has(s)||!Object.is(o,i.get(s)))return!1;return!0},Rx=(t,l)=>{const r=t[Symbol.iterator](),i=l[Symbol.iterator]();let s=r.next(),o=i.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=r.next(),o=i.next()}return!!s.done&&!!o.done};function Dx(t,l){return Object.is(t,l)?!0:typeof t!="object"||t===null||typeof l!="object"||l===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(l)?!1:q0(t)&&q0(l)?$0(t)&&$0(l)?V0(t,l):Rx(t,l):V0({entries:()=>Object.entries(t)},{entries:()=>Object.entries(l)})}function Vt(t){const l=na.useRef(void 0);return r=>{const i=t(r);return Dx(l.current,i)?l.current:l.current=i}}function Ox(t){return"agent"in t}const I0=50,Lx={fleetStatus:null,agents:[],recentJobs:[],connectionStatus:"disconnected",lastUpdated:null},Ux=t=>({...Lx,setFleetStatus:l=>t({fleetStatus:l,lastUpdated:new Date().toISOString()}),setAgents:l=>t({agents:l,lastUpdated:new Date().toISOString()}),setRecentJobs:l=>t(r=>{const i=new Map;for(const o of l)i.set(o.jobId,o);for(const o of r.recentJobs)i.set(o.jobId,o);const s=Array.from(i.values());return s.sort((o,c)=>new Date(c.createdAt).getTime()-new Date(o.createdAt).getTime()),{recentJobs:s.slice(0,I0),lastUpdated:new Date().toISOString()}}),updateAgent:l=>t(r=>{if(Ox(l)){const i=r.agents.findIndex(s=>s.qualifiedName===l.agent.qualifiedName);if(i>=0){const s=[...r.agents];return s[i]=l.agent,{agents:s,lastUpdated:new Date().toISOString()}}else return{agents:[...r.agents,l.agent],lastUpdated:new Date().toISOString()}}else{const i=r.agents.findIndex(s=>s.qualifiedName===l.agentName);if(i>=0){const s=[...r.agents];return s[i]={...s[i],status:"idle",currentJobId:null},{agents:s,lastUpdated:new Date().toISOString()}}return r}}),addJob:l=>t(r=>({recentJobs:[{jobId:l.jobId,agentName:l.agentName,prompt:l.prompt,status:"running",createdAt:new Date().toISOString(),startedAt:new Date().toISOString()},...r.recentJobs].slice(0,I0),lastUpdated:new Date().toISOString()})),completeJob:l=>t(r=>{const i=r.recentJobs.findIndex(s=>s.jobId===l.jobId);if(i>=0){const s=[...r.recentJobs];return s[i]={...s[i],status:"completed",exitCode:l.exitCode,completedAt:new Date().toISOString()},{recentJobs:s,lastUpdated:new Date().toISOString()}}return r}),failJob:l=>t(r=>{const i=r.recentJobs.findIndex(s=>s.jobId===l.jobId);if(i>=0){const s=[...r.recentJobs];return s[i]={...s[i],status:"failed",error:l.error,completedAt:new Date().toISOString()},{recentJobs:s,lastUpdated:new Date().toISOString()}}return r}),cancelJob:l=>t(r=>{const i=r.recentJobs.findIndex(s=>s.jobId===l.jobId);if(i>=0){const s=[...r.recentJobs];return s[i]={...s[i],status:"cancelled",error:l.reason,completedAt:new Date().toISOString()},{recentJobs:s,lastUpdated:new Date().toISOString()}}return r}),setConnectionStatus:l=>t({connectionStatus:l,lastUpdated:new Date().toISOString()})}),Np="herd-theme";function is(){if(typeof window>"u")return"system";const t=localStorage.getItem(Np);return t==="light"||t==="dark"||t==="system"?t:"system"}function Hx(t){const l=t??is();return l==="system"?typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":l}function jp(t){if(typeof window>"u")return;const l=Hx(t);document.documentElement.classList.toggle("dark",l==="dark")}function Bx(t){typeof window>"u"||(localStorage.setItem(Np,t),jp(t))}function Zx(){const t=is();jp(t);const l=window.matchMedia("(prefers-color-scheme: dark)");function r(i){is()==="system"&&document.documentElement.classList.toggle("dark",i.matches)}return l.addEventListener("change",r),()=>{l.removeEventListener("change",r)}}const qx={sidebarCollapsed:!1,sidebarMobileOpen:!1,selectedAgent:null,activeView:"dashboard",theme:is(),rightPanelOpen:!1},$x=t=>({...qx,toggleSidebar:()=>t(l=>({sidebarCollapsed:!l.sidebarCollapsed})),setSidebarCollapsed:l=>t({sidebarCollapsed:l}),toggleSidebarMobile:()=>t(l=>({sidebarMobileOpen:!l.sidebarMobileOpen})),setSidebarMobileOpen:l=>t({sidebarMobileOpen:l}),selectAgent:l=>t({selectedAgent:l,rightPanelOpen:l!==null}),setActiveView:l=>t({activeView:l}),setTheme:l=>(Bx(l),t({theme:l})),toggleRightPanel:()=>t(l=>({rightPanelOpen:!l.rightPanelOpen})),setRightPanelOpen:l=>t({rightPanelOpen:l})}),J0=1e3,Vx={outputsByJob:{},activeJobViews:new Set,_messageCounter:0},Ix=t=>({...Vx,appendOutput:(l,r,i,s)=>t(o=>{const c=o._messageCounter+1,d={id:`msg-${c}`,jobId:l,agentName:r,data:i,stream:s,timestamp:Date.now()};let p=[...o.outputsByJob[l]??[],d];return p.length>J0&&(p=p.slice(p.length-J0)),{outputsByJob:{...o.outputsByJob,[l]:p},_messageCounter:c}}),clearJobOutput:l=>t(r=>{const{[l]:i,...s}=r.outputsByJob;return{outputsByJob:s}}),setActiveJobView:(l,r)=>t(i=>{const s=new Set(i.activeJobViews);return r?s.add(l):s.delete(l),{activeJobViews:s}}),clearAllOutput:()=>t({outputsByJob:{},activeJobViews:new Set,_messageCounter:0})});let Qf=typeof window<"u"?window.location.origin:"";class Jx extends Error{constructor(l,r,i,s){super(l),this.status=r,this.statusText=i,this.url=s,this.name="ApiError"}}async function Kf(t){if(!t.ok){let l=`HTTP ${t.status}: ${t.statusText}`;try{const r=await t.json();r.error?l=r.error:r.message&&(l=r.message)}catch{}throw new Jx(l,t.status,t.statusText,t.url)}return t.json()}async function Ll(t,l){const r=new URL(`${Qf}${t}`);if(l)for(const[s,o]of Object.entries(l))o!==void 0&&r.searchParams.set(s,String(o));const i=await fetch(r.toString(),{method:"GET",headers:{Accept:"application/json"}});return Kf(i)}async function oa(t,l){const r=await fetch(`${Qf}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(l)});return Kf(r)}async function Fx(t){const l=await fetch(`${Qf}${t}`,{method:"DELETE",headers:{Accept:"application/json"}});return Kf(l)}async function Ap(){return Ll("/api/fleet/status")}async function zp(){return Ll("/api/agents")}async function Yx(t){return Ll(`/api/agents/${encodeURIComponent(t)}`)}async function Tp(t){return Ll("/api/jobs",t)}async function Gx(t){return Ll(`/api/jobs/${encodeURIComponent(t)}`)}async function Xx(t){return oa(`/api/jobs/${encodeURIComponent(t)}/cancel`,{})}async function Qx(t,l){return oa(`/api/jobs/${encodeURIComponent(t)}/fork`,l??{})}async function Kx(){return Ll("/api/schedules")}async function _p(t,l){return oa(`/api/agents/${encodeURIComponent(t)}/trigger`,l??{})}async function Px(t,l){return oa(`/api/schedules/${encodeURIComponent(t)}/${encodeURIComponent(l)}/enable`,{})}async function Wx(t,l){return oa(`/api/schedules/${encodeURIComponent(t)}/${encodeURIComponent(l)}/disable`,{})}async function e6(t){return oa(`/api/chat/${encodeURIComponent(t)}/sessions`,{})}async function F0(t){return Ll(`/api/chat/${encodeURIComponent(t)}/sessions`)}async function t6(t,l){return Ll(`/api/chat/${encodeURIComponent(t)}/sessions/${encodeURIComponent(l)}`)}async function n6(t,l){await Fx(`/api/chat/${encodeURIComponent(t)}/sessions/${encodeURIComponent(l)}`)}const l6=20,Y0={jobs:[],totalJobs:0,jobsLoading:!1,jobsError:null,jobsFilter:{},jobsOffset:0,jobsLimit:l6,selectedJobId:null,selectedJob:null,selectedJobLoading:!1},r6=(t,l)=>({...Y0,fetchJobs:async()=>{const{jobsFilter:r,jobsOffset:i,jobsLimit:s}=l();t({jobsLoading:!0,jobsError:null});try{const o=await Tp({limit:s,offset:i,agentName:r.agentName,status:r.status});t({jobs:o.jobs,totalJobs:o.total,jobsLoading:!1})}catch(o){const c=o instanceof Error?o.message:"Failed to fetch jobs";t({jobsLoading:!1,jobsError:c})}},fetchJobDetail:async r=>{t({selectedJobLoading:!0});try{const i=await Gx(r);t({selectedJob:i,selectedJobId:r,selectedJobLoading:!1})}catch{t({selectedJob:null,selectedJobId:r,selectedJobLoading:!1})}},setJobsFilter:r=>{const i=l().jobsFilter;t({jobsFilter:{...i,...r},jobsOffset:0})},setJobsOffset:r=>{t({jobsOffset:r})},selectJob:r=>{r===null?t({selectedJobId:null,selectedJob:null,selectedJobLoading:!1}):(t({selectedJobId:r}),l().fetchJobDetail(r).catch(()=>{}))},clearJobsState:()=>{t(Y0)}}),G0=5,X0={chatSessions:[],chatSessionsLoading:!1,chatMessages:[],chatMessagesLoading:!1,activeChatSessionId:null,chatStreaming:!1,chatStreamingContent:"",chatError:null,sidebarSessions:{},sidebarSessionsLoading:!1},a6=(t,l)=>({...X0,fetchChatSessions:async r=>{t({chatSessionsLoading:!0,chatError:null});try{const i=await F0(r);t({chatSessions:i.sessions,chatSessionsLoading:!1})}catch(i){const s=i instanceof Error?i.message:"Failed to fetch chat sessions";t({chatSessionsLoading:!1,chatError:s})}},fetchChatMessages:async(r,i)=>{t({chatMessagesLoading:!0,chatError:null});try{const s=await t6(r,i);t({chatMessages:s.messages,chatMessagesLoading:!1,activeChatSessionId:i})}catch(s){const o=s instanceof Error?s.message:"Failed to fetch chat messages";t({chatMessagesLoading:!1,chatError:o})}},createChatSession:async r=>{t({chatError:null});try{const i=await e6(r),s={sessionId:i.sessionId,createdAt:i.createdAt,lastMessageAt:i.createdAt,messageCount:0,preview:""};return t(o=>{const c=[s,...o.chatSessions],d=o.sidebarSessions[r]??[],m=[s,...d].slice(0,G0);return{chatSessions:c,activeChatSessionId:i.sessionId,chatMessages:[],sidebarSessions:{...o.sidebarSessions,[r]:m}}}),i.sessionId}catch(i){const s=i instanceof Error?i.message:"Failed to create chat session";return t({chatError:s}),null}},deleteChatSession:async(r,i)=>{t({chatError:null});try{await n6(r,i);const{activeChatSessionId:s}=l();t(o=>{const c=o.sidebarSessions[r],d=c?{...o.sidebarSessions,[r]:c.filter(m=>m.sessionId!==i)}:o.sidebarSessions;return{chatSessions:o.chatSessions.filter(m=>m.sessionId!==i),activeChatSessionId:s===i?null:s,chatMessages:s===i?[]:o.chatMessages,sidebarSessions:d}})}catch(s){const o=s instanceof Error?s.message:"Failed to delete chat session";t({chatError:o})}},setActiveChatSession:r=>{t({activeChatSessionId:r,chatMessages:r===null?[]:l().chatMessages,chatStreaming:!1,chatStreamingContent:""})},appendStreamingChunk:r=>{t(i=>({chatStreaming:!0,chatStreamingContent:i.chatStreamingContent+r}))},completeStreaming:()=>{const{chatStreamingContent:r}=l();if(r){const i={role:"assistant",content:r,timestamp:new Date().toISOString()};t(s=>({chatMessages:[...s.chatMessages,i],chatStreaming:!1,chatStreamingContent:""}))}else t({chatStreaming:!1,chatStreamingContent:""})},addUserMessage:r=>{const i={role:"user",content:r,timestamp:new Date().toISOString()};t(s=>({chatMessages:[...s.chatMessages,i],chatStreaming:!0,chatStreamingContent:""}))},addToolCallMessage:r=>{const{chatStreamingContent:i}=l(),s=[];i&&s.push({role:"assistant",content:i,timestamp:new Date().toISOString()}),s.push({role:"tool",content:r.output,timestamp:new Date().toISOString(),toolCall:r}),t(o=>({chatMessages:[...o.chatMessages,...s],chatStreamingContent:""}))},setChatError:r=>{t({chatError:r,chatStreaming:!1,chatStreamingContent:""})},fetchSidebarSessions:async r=>{t({sidebarSessionsLoading:!0});try{const i=await Promise.all(r.map(o=>F0(o).then(c=>({name:o,sessions:c.sessions.slice(0,G0)})).catch(()=>({name:o,sessions:[]})))),s={};for(const{name:o,sessions:c}of i)s[o]=c;t({sidebarSessions:s,sidebarSessionsLoading:!1})}catch{t({sidebarSessionsLoading:!1})}},clearChatState:()=>{t(X0)}}),Q0={schedules:[],schedulesLoading:!1,schedulesError:null},i6=(t,l)=>({...Q0,fetchSchedules:async()=>{t({schedulesLoading:!0,schedulesError:null});try{const r=await Kx();t({schedules:r,schedulesLoading:!1})}catch(r){const i=r instanceof Error?r.message:"Failed to fetch schedules";t({schedulesLoading:!1,schedulesError:i})}},triggerSchedule:async(r,i)=>{t({schedulesError:null});try{await _p(r,{scheduleName:i}),await l().fetchSchedules()}catch(s){const o=s instanceof Error?s.message:"Failed to trigger schedule";t({schedulesError:o})}},enableSchedule:async(r,i)=>{t({schedulesError:null});try{const s=await Px(r,i);t(o=>({schedules:o.schedules.map(c=>c.agentName===r&&c.name===i?s:c)}))}catch(s){const o=s instanceof Error?s.message:"Failed to enable schedule";t({schedulesError:o})}},disableSchedule:async(r,i)=>{t({schedulesError:null});try{const s=await Wx(r,i);t(o=>({schedules:o.schedules.map(c=>c.agentName===r&&c.name===i?s:c)}))}catch(s){const o=s instanceof Error?s.message:"Failed to disable schedule";t({schedulesError:o})}},updateScheduleFromWS:()=>{l().fetchSchedules().catch(()=>{})},clearSchedulesState:()=>{t(Q0)}});let K0=0;function u6(){return K0+=1,`toast-${K0}-${Date.now()}`}const s6={toasts:[]},o6=t=>({...s6,addToast:l=>{const r=u6(),i=l.duration??3e3;t(s=>({toasts:[...s.toasts,{...l,id:r,duration:i}]})),i>0&&setTimeout(()=>{t(s=>({toasts:s.toasts.filter(o=>o.id!==r)}))},i)},removeToast:l=>t(r=>({toasts:r.toasts.filter(i=>i.id!==l)}))}),Ne=_x()((...t)=>({...Ux(...t),...$x(...t),...Ix(...t),...r6(...t),...a6(...t),...i6(...t),...o6(...t)}));function ys(){return Ne(Vt(t=>({fleetStatus:t.fleetStatus,agents:t.agents,recentJobs:t.recentJobs,connectionStatus:t.connectionStatus,lastUpdated:t.lastUpdated})))}function c6(t){return Ne(l=>t?l.agents.find(r=>r.qualifiedName===t)??null:null)}function Rp(){return Ne(Vt(t=>({sidebarCollapsed:t.sidebarCollapsed,sidebarMobileOpen:t.sidebarMobileOpen,selectedAgent:t.selectedAgent,activeView:t.activeView,theme:t.theme,rightPanelOpen:t.rightPanelOpen})))}function Dp(){return Ne(Vt(t=>({toggleSidebar:t.toggleSidebar,setSidebarCollapsed:t.setSidebarCollapsed,toggleSidebarMobile:t.toggleSidebarMobile,setSidebarMobileOpen:t.setSidebarMobileOpen,selectAgent:t.selectAgent,setActiveView:t.setActiveView,setTheme:t.setTheme,toggleRightPanel:t.toggleRightPanel,setRightPanelOpen:t.setRightPanelOpen})))}function f6(){return Ne(Vt(t=>({setFleetStatus:t.setFleetStatus,setAgents:t.setAgents,updateAgent:t.updateAgent,setRecentJobs:t.setRecentJobs,addJob:t.addJob,completeJob:t.completeJob,failJob:t.failJob,cancelJob:t.cancelJob,setConnectionStatus:t.setConnectionStatus})))}const P0=[];function d6(t){return Ne(l=>t?l.outputsByJob[t]??P0:P0)}function h6(){return Ne(Vt(t=>({jobs:t.jobs,totalJobs:t.totalJobs,jobsLoading:t.jobsLoading,jobsError:t.jobsError,jobsFilter:t.jobsFilter,jobsOffset:t.jobsOffset,jobsLimit:t.jobsLimit})))}function Op(){return Ne(Vt(t=>({fetchJobs:t.fetchJobs,fetchJobDetail:t.fetchJobDetail,setJobsFilter:t.setJobsFilter,setJobsOffset:t.setJobsOffset,selectJob:t.selectJob,clearJobsState:t.clearJobsState})))}function m6(){return Ne(Vt(t=>({selectedJobId:t.selectedJobId,selectedJob:t.selectedJob,selectedJobLoading:t.selectedJobLoading})))}function p6(){return Ne(Vt(t=>({chatSessions:t.chatSessions,chatSessionsLoading:t.chatSessionsLoading,chatError:t.chatError})))}function Pf(){return Ne(Vt(t=>({chatMessages:t.chatMessages,chatMessagesLoading:t.chatMessagesLoading,activeChatSessionId:t.activeChatSessionId,chatStreaming:t.chatStreaming,chatStreamingContent:t.chatStreamingContent,chatError:t.chatError})))}function Wf(){return Ne(Vt(t=>({fetchChatSessions:t.fetchChatSessions,fetchChatMessages:t.fetchChatMessages,createChatSession:t.createChatSession,deleteChatSession:t.deleteChatSession,setActiveChatSession:t.setActiveChatSession,appendStreamingChunk:t.appendStreamingChunk,completeStreaming:t.completeStreaming,addUserMessage:t.addUserMessage,setChatError:t.setChatError,fetchSidebarSessions:t.fetchSidebarSessions,clearChatState:t.clearChatState})))}function g6(){return Ne(Vt(t=>({sidebarSessions:t.sidebarSessions,sidebarSessionsLoading:t.sidebarSessionsLoading})))}function y6(){return Ne(Vt(t=>({schedules:t.schedules,schedulesLoading:t.schedulesLoading,schedulesError:t.schedulesError})))}function x6(){return Ne(Vt(t=>({fetchSchedules:t.fetchSchedules,triggerSchedule:t.triggerSchedule,enableSchedule:t.enableSchedule,disableSchedule:t.disableSchedule,updateScheduleFromWS:t.updateScheduleFromWS,clearSchedulesState:t.clearSchedulesState})))}function b6(){return Ne(t=>t.toasts)}function v6(){return Ne(Vt(t=>({addToast:t.addToast,removeToast:t.removeToast})))}function S6(){const t=E.useRef(null),l=E.useRef("disconnected"),r=E.useRef(!1),i=Ne(N=>N.setFleetStatus),s=Ne(N=>N.setAgents),o=Ne(N=>N.updateAgent),c=Ne(N=>N.addJob),d=Ne(N=>N.completeJob),m=Ne(N=>N.failJob),p=Ne(N=>N.cancelJob),x=Ne(N=>N.setConnectionStatus),y=Ne(N=>N.connectionStatus),v=Ne(N=>N.appendOutput),S=Ne(N=>N.appendStreamingChunk),C=Ne(N=>N.completeStreaming),T=Ne(N=>N.addToolCallMessage),z=Ne(N=>N.setChatError),M=Ne(N=>N.updateScheduleFromWS),U=Ne(N=>N.addToast);return E.useEffect(()=>{const N=F=>{switch(F.type){case"fleet:status":i(F.payload);break;case"agent:updated":o(F.payload);break;case"job:created":c(F.payload);break;case"job:completed":d(F.payload),U({message:`Job completed for ${F.payload.agentName}`,type:"success"});break;case"job:failed":m(F.payload),U({message:`Job failed for ${F.payload.agentName}`,type:"error",duration:5e3});break;case"job:cancelled":p(F.payload);break;case"schedule:triggered":M(),U({message:`Schedule triggered for ${F.payload.agentName}`,type:"info"});break;case"job:output":{const{jobId:_,agentName:I,data:se,stream:oe}=F.payload;v(_,I,se,oe);break}case"pong":break;case"chat:response":{const{chunk:_}=F.payload;S(_);break}case"chat:complete":{C();break}case"chat:tool_call":{T({toolName:F.payload.toolName,inputSummary:F.payload.inputSummary,output:F.payload.output,isError:F.payload.isError,durationMs:F.payload.durationMs});break}case"chat:error":{z(F.payload.error);break}}},V=F=>{const _=l.current;l.current=F,x(F),F==="connected"&&(_==="disconnected"||_==="reconnecting")&&r.current&&(async()=>{try{const[I,se]=await Promise.all([Ap(),zp()]);i(I),s(se)}catch{}})(),F==="connected"&&(r.current=!0)};return t.current=Mx({onMessage:N,onStatusChange:V}),window.__herdWsClient=t.current,()=>{var F;(F=t.current)==null||F.disconnect(),t.current=null,delete window.__herdWsClient}},[]),{connectionStatus:y,subscribe:N=>{var V;return(V=t.current)==null?void 0:V.subscribe(N)},unsubscribe:N=>{var V;return(V=t.current)==null?void 0:V.unsubscribe(N)},reconnect:()=>{var N;return(N=t.current)==null?void 0:N.reconnect()}}}function Lp(){const[t,l]=E.useState(!0),[r,i]=E.useState(null),[s,o]=E.useState(0),c=Ne(p=>p.setFleetStatus),d=Ne(p=>p.setAgents);return E.useEffect(()=>{let p=!1;async function x(){l(!0),i(null);try{const[y,v]=await Promise.all([Ap(),zp()]);if(p)return;c(y),d(v),l(!1)}catch(y){if(p)return;const v=y instanceof Error?y.message:"Failed to fetch fleet data";i(v),l(!1)}}return x(),()=>{p=!0}},[s]),{loading:t,error:r,retry:()=>{o(p=>p+1)}}}const xs=E.createContext(null);xs.displayName="PanelGroupContext";const rt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},e1=10,ar=E.useLayoutEffect,W0=$5.useId,w6=typeof W0=="function"?W0:()=>null;let k6=0;function t1(t=null){const l=w6(),r=E.useRef(t||l||null);return r.current===null&&(r.current=""+k6++),t??r.current}function Up({children:t,className:l="",collapsedSize:r,collapsible:i,defaultSize:s,forwardedRef:o,id:c,maxSize:d,minSize:m,onCollapse:p,onExpand:x,onResize:y,order:v,style:S,tagName:C="div",...T}){const z=E.useContext(xs);if(z===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:M,expandPanel:U,getPanelSize:N,getPanelStyle:V,groupId:F,isPanelCollapsed:_,reevaluatePanelConstraints:I,registerPanel:se,resizePanel:oe,unregisterPanel:O}=z,ae=t1(c),te=E.useRef({callbacks:{onCollapse:p,onExpand:x,onResize:y},constraints:{collapsedSize:r,collapsible:i,defaultSize:s,maxSize:d,minSize:m},id:ae,idIsFromProps:c!==void 0,order:v});E.useRef({didLogMissingDefaultSizeWarning:!1}),ar(()=>{const{callbacks:ue,constraints:P}=te.current,H={...P};te.current.id=ae,te.current.idIsFromProps=c!==void 0,te.current.order=v,ue.onCollapse=p,ue.onExpand=x,ue.onResize=y,P.collapsedSize=r,P.collapsible=i,P.defaultSize=s,P.maxSize=d,P.minSize=m,(H.collapsedSize!==P.collapsedSize||H.collapsible!==P.collapsible||H.maxSize!==P.maxSize||H.minSize!==P.minSize)&&I(te.current,H)}),ar(()=>{const ue=te.current;return se(ue),()=>{O(ue)}},[v,ae,se,O]),E.useImperativeHandle(o,()=>({collapse:()=>{M(te.current)},expand:ue=>{U(te.current,ue)},getId(){return ae},getSize(){return N(te.current)},isCollapsed(){return _(te.current)},isExpanded(){return!_(te.current)},resize:ue=>{oe(te.current,ue)}}),[M,U,N,_,ae,oe]);const be=V(te.current,s);return E.createElement(C,{...T,children:t,className:l,id:ae,style:{...be,...S},[rt.groupId]:F,[rt.panel]:"",[rt.panelCollapsible]:i||void 0,[rt.panelId]:ae,[rt.panelSize]:parseFloat(""+be.flexGrow).toFixed(1)})}const ns=E.forwardRef((t,l)=>E.createElement(Up,{...t,forwardedRef:l}));Up.displayName="Panel";ns.displayName="forwardRef(Panel)";let Mf=null,ls=-1,Ol=null;function C6(t,l){if(l){const r=(l&$p)!==0,i=(l&Vp)!==0,s=(l&Ip)!==0,o=(l&Jp)!==0;if(r)return s?"se-resize":o?"ne-resize":"e-resize";if(i)return s?"sw-resize":o?"nw-resize":"w-resize";if(s)return"s-resize";if(o)return"n-resize"}switch(t){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function E6(){Ol!==null&&(document.head.removeChild(Ol),Mf=null,Ol=null,ls=-1)}function Pc(t,l){var r,i;const s=C6(t,l);if(Mf!==s){if(Mf=s,Ol===null&&(Ol=document.createElement("style"),document.head.appendChild(Ol)),ls>=0){var o;(o=Ol.sheet)===null||o===void 0||o.removeRule(ls)}ls=(r=(i=Ol.sheet)===null||i===void 0?void 0:i.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function Hp(t){return t.type==="keydown"}function Bp(t){return t.type.startsWith("pointer")}function Zp(t){return t.type.startsWith("mouse")}function bs(t){if(Bp(t)){if(t.isPrimary)return{x:t.clientX,y:t.clientY}}else if(Zp(t))return{x:t.clientX,y:t.clientY};return{x:1/0,y:1/0}}function M6(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function N6(t,l,r){return t.x<l.x+l.width&&t.x+t.width>l.x&&t.y<l.y+l.height&&t.y+t.height>l.y}function j6(t,l){if(t===l)throw new Error("Cannot compare node with itself");const r={a:nm(t),b:nm(l)};let i;for(;r.a.at(-1)===r.b.at(-1);)t=r.a.pop(),l=r.b.pop(),i=t;Me(i,"Stacking order can only be calculated for elements with a common ancestor");const s={a:tm(em(r.a)),b:tm(em(r.b))};if(s.a===s.b){const o=i.childNodes,c={a:r.a.at(-1),b:r.b.at(-1)};let d=o.length;for(;d--;){const m=o[d];if(m===c.a)return 1;if(m===c.b)return-1}}return Math.sign(s.a-s.b)}const A6=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function z6(t){var l;const r=getComputedStyle((l=qp(t))!==null&&l!==void 0?l:t).display;return r==="flex"||r==="inline-flex"}function T6(t){const l=getComputedStyle(t);return!!(l.position==="fixed"||l.zIndex!=="auto"&&(l.position!=="static"||z6(t))||+l.opacity<1||"transform"in l&&l.transform!=="none"||"webkitTransform"in l&&l.webkitTransform!=="none"||"mixBlendMode"in l&&l.mixBlendMode!=="normal"||"filter"in l&&l.filter!=="none"||"webkitFilter"in l&&l.webkitFilter!=="none"||"isolation"in l&&l.isolation==="isolate"||A6.test(l.willChange)||l.webkitOverflowScrolling==="touch")}function em(t){let l=t.length;for(;l--;){const r=t[l];if(Me(r,"Missing node"),T6(r))return r}return null}function tm(t){return t&&Number(getComputedStyle(t).zIndex)||0}function nm(t){const l=[];for(;t;)l.push(t),t=qp(t);return l}function qp(t){const{parentNode:l}=t;return l&&l instanceof ShadowRoot?l.host:l}const $p=1,Vp=2,Ip=4,Jp=8,_6=M6()==="coarse";let kn=[],ra=!1,rr=new Map,vs=new Map;const bi=new Set;function R6(t,l,r,i,s){var o;const{ownerDocument:c}=l,d={direction:r,element:l,hitAreaMargins:i,setResizeHandlerState:s},m=(o=rr.get(c))!==null&&o!==void 0?o:0;return rr.set(c,m+1),bi.add(d),us(),function(){var x;vs.delete(t),bi.delete(d);const y=(x=rr.get(c))!==null&&x!==void 0?x:1;if(rr.set(c,y-1),us(),y===1&&rr.delete(c),kn.includes(d)){const v=kn.indexOf(d);v>=0&&kn.splice(v,1),l1(),s("up",!0,null)}}}function D6(t){const{target:l}=t,{x:r,y:i}=bs(t);ra=!0,n1({target:l,x:r,y:i}),us(),kn.length>0&&(ss("down",t),t.preventDefault(),Fp(l)||t.stopImmediatePropagation())}function Wc(t){const{x:l,y:r}=bs(t);if(ra&&t.buttons===0&&(ra=!1,ss("up",t)),!ra){const{target:i}=t;n1({target:i,x:l,y:r})}ss("move",t),l1(),kn.length>0&&t.preventDefault()}function ef(t){const{target:l}=t,{x:r,y:i}=bs(t);vs.clear(),ra=!1,kn.length>0&&(t.preventDefault(),Fp(l)||t.stopImmediatePropagation()),ss("up",t),n1({target:l,x:r,y:i}),l1(),us()}function Fp(t){let l=t;for(;l;){if(l.hasAttribute(rt.resizeHandle))return!0;l=l.parentElement}return!1}function n1({target:t,x:l,y:r}){kn.splice(0);let i=null;(t instanceof HTMLElement||t instanceof SVGElement)&&(i=t),bi.forEach(s=>{const{element:o,hitAreaMargins:c}=s,d=o.getBoundingClientRect(),{bottom:m,left:p,right:x,top:y}=d,v=_6?c.coarse:c.fine;if(l>=p-v&&l<=x+v&&r>=y-v&&r<=m+v){if(i!==null&&document.contains(i)&&o!==i&&!o.contains(i)&&!i.contains(o)&&j6(i,o)>0){let C=i,T=!1;for(;C&&!C.contains(o);){if(N6(C.getBoundingClientRect(),d)){T=!0;break}C=C.parentElement}if(T)return}kn.push(s)}})}function tf(t,l){vs.set(t,l)}function l1(){let t=!1,l=!1;kn.forEach(i=>{const{direction:s}=i;s==="horizontal"?t=!0:l=!0});let r=0;vs.forEach(i=>{r|=i}),t&&l?Pc("intersection",r):t?Pc("horizontal",r):l?Pc("vertical",r):E6()}let nf=new AbortController;function us(){nf.abort(),nf=new AbortController;const t={capture:!0,signal:nf.signal};bi.size&&(ra?(kn.length>0&&rr.forEach((l,r)=>{const{body:i}=r;l>0&&(i.addEventListener("contextmenu",ef,t),i.addEventListener("pointerleave",Wc,t),i.addEventListener("pointermove",Wc,t))}),window.addEventListener("pointerup",ef,t),window.addEventListener("pointercancel",ef,t)):rr.forEach((l,r)=>{const{body:i}=r;l>0&&(i.addEventListener("pointerdown",D6,t),i.addEventListener("pointermove",Wc,t))}))}function ss(t,l){bi.forEach(r=>{const{setResizeHandlerState:i}=r,s=kn.includes(r);i(t,s,l)})}function O6(){const[t,l]=E.useState(0);return E.useCallback(()=>l(r=>r+1),[])}function Me(t,l){if(!t)throw console.error(l),Error(l)}function ir(t,l,r=e1){return t.toFixed(r)===l.toFixed(r)?0:t>l?1:-1}function Wn(t,l,r=e1){return ir(t,l,r)===0}function en(t,l,r){return ir(t,l,r)===0}function L6(t,l,r){if(t.length!==l.length)return!1;for(let i=0;i<t.length;i++){const s=t[i],o=l[i];if(!en(s,o,r))return!1}return!0}function la({panelConstraints:t,panelIndex:l,size:r}){const i=t[l];Me(i!=null,`Panel constraints not found for index ${l}`);let{collapsedSize:s=0,collapsible:o,maxSize:c=100,minSize:d=0}=i;if(ir(r,d)<0)if(o){const m=(s+d)/2;ir(r,m)<0?r=s:r=d}else r=d;return r=Math.min(c,r),r=parseFloat(r.toFixed(e1)),r}function hi({delta:t,initialLayout:l,panelConstraints:r,pivotIndices:i,prevLayout:s,trigger:o}){if(en(t,0))return l;const c=[...l],[d,m]=i;Me(d!=null,"Invalid first pivot index"),Me(m!=null,"Invalid second pivot index");let p=0;if(o==="keyboard"){{const y=t<0?m:d,v=r[y];Me(v,`Panel constraints not found for index ${y}`);const{collapsedSize:S=0,collapsible:C,minSize:T=0}=v;if(C){const z=l[y];if(Me(z!=null,`Previous layout not found for panel index ${y}`),en(z,S)){const M=T-z;ir(M,Math.abs(t))>0&&(t=t<0?0-M:M)}}}{const y=t<0?d:m,v=r[y];Me(v,`No panel constraints found for index ${y}`);const{collapsedSize:S=0,collapsible:C,minSize:T=0}=v;if(C){const z=l[y];if(Me(z!=null,`Previous layout not found for panel index ${y}`),en(z,T)){const M=z-S;ir(M,Math.abs(t))>0&&(t=t<0?0-M:M)}}}}{const y=t<0?1:-1;let v=t<0?m:d,S=0;for(;;){const T=l[v];Me(T!=null,`Previous layout not found for panel index ${v}`);const M=la({panelConstraints:r,panelIndex:v,size:100})-T;if(S+=M,v+=y,v<0||v>=r.length)break}const C=Math.min(Math.abs(t),Math.abs(S));t=t<0?0-C:C}{let v=t<0?d:m;for(;v>=0&&v<r.length;){const S=Math.abs(t)-Math.abs(p),C=l[v];Me(C!=null,`Previous layout not found for panel index ${v}`);const T=C-S,z=la({panelConstraints:r,panelIndex:v,size:T});if(!en(C,z)&&(p+=C-z,c[v]=z,p.toPrecision(3).localeCompare(Math.abs(t).toPrecision(3),void 0,{numeric:!0})>=0))break;t<0?v--:v++}}if(L6(s,c))return s;{const y=t<0?m:d,v=l[y];Me(v!=null,`Previous layout not found for panel index ${y}`);const S=v+p,C=la({panelConstraints:r,panelIndex:y,size:S});if(c[y]=C,!en(C,S)){let T=S-C,M=t<0?m:d;for(;M>=0&&M<r.length;){const U=c[M];Me(U!=null,`Previous layout not found for panel index ${M}`);const N=U+T,V=la({panelConstraints:r,panelIndex:M,size:N});if(en(U,V)||(T-=V-U,c[M]=V),en(T,0))break;t>0?M--:M++}}}const x=c.reduce((y,v)=>v+y,0);return en(x,100)?c:s}function U6({layout:t,panelsArray:l,pivotIndices:r}){let i=0,s=100,o=0,c=0;const d=r[0];Me(d!=null,"No pivot index found"),l.forEach((y,v)=>{const{constraints:S}=y,{maxSize:C=100,minSize:T=0}=S;v===d?(i=T,s=C):(o+=T,c+=C)});const m=Math.min(s,100-o),p=Math.max(i,100-c),x=t[d];return{valueMax:m,valueMin:p,valueNow:x}}function vi(t,l=document){return Array.from(l.querySelectorAll(`[${rt.resizeHandleId}][data-panel-group-id="${t}"]`))}function Yp(t,l,r=document){const s=vi(t,r).findIndex(o=>o.getAttribute(rt.resizeHandleId)===l);return s??null}function Gp(t,l,r){const i=Yp(t,l,r);return i!=null?[i,i+1]:[-1,-1]}function Xp(t,l=document){var r;if(l instanceof HTMLElement&&(l==null||(r=l.dataset)===null||r===void 0?void 0:r.panelGroupId)==t)return l;const i=l.querySelector(`[data-panel-group][data-panel-group-id="${t}"]`);return i||null}function Ss(t,l=document){const r=l.querySelector(`[${rt.resizeHandleId}="${t}"]`);return r||null}function H6(t,l,r,i=document){var s,o,c,d;const m=Ss(l,i),p=vi(t,i),x=m?p.indexOf(m):-1,y=(s=(o=r[x])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,v=(c=(d=r[x+1])===null||d===void 0?void 0:d.id)!==null&&c!==void 0?c:null;return[y,v]}function B6({committedValuesRef:t,eagerValuesRef:l,groupId:r,layout:i,panelDataArray:s,panelGroupElement:o,setLayout:c}){E.useRef({didWarnAboutMissingResizeHandle:!1}),ar(()=>{if(!o)return;const d=vi(r,o);for(let m=0;m<s.length-1;m++){const{valueMax:p,valueMin:x,valueNow:y}=U6({layout:i,panelsArray:s,pivotIndices:[m,m+1]}),v=d[m];if(v!=null){const S=s[m];Me(S,`No panel data found for index "${m}"`),v.setAttribute("aria-controls",S.id),v.setAttribute("aria-valuemax",""+Math.round(p)),v.setAttribute("aria-valuemin",""+Math.round(x)),v.setAttribute("aria-valuenow",y!=null?""+Math.round(y):"")}}return()=>{d.forEach((m,p)=>{m.removeAttribute("aria-controls"),m.removeAttribute("aria-valuemax"),m.removeAttribute("aria-valuemin"),m.removeAttribute("aria-valuenow")})}},[r,i,s,o]),E.useEffect(()=>{if(!o)return;const d=l.current;Me(d,"Eager values not found");const{panelDataArray:m}=d,p=Xp(r,o);Me(p!=null,`No group found for id "${r}"`);const x=vi(r,o);Me(x,`No resize handles found for group id "${r}"`);const y=x.map(v=>{const S=v.getAttribute(rt.resizeHandleId);Me(S,"Resize handle element has no handle id attribute");const[C,T]=H6(r,S,m,o);if(C==null||T==null)return()=>{};const z=M=>{if(!M.defaultPrevented)switch(M.key){case"Enter":{M.preventDefault();const U=m.findIndex(N=>N.id===C);if(U>=0){const N=m[U];Me(N,`No panel data found for index ${U}`);const V=i[U],{collapsedSize:F=0,collapsible:_,minSize:I=0}=N.constraints;if(V!=null&&_){const se=hi({delta:en(V,F)?I-F:F-V,initialLayout:i,panelConstraints:m.map(oe=>oe.constraints),pivotIndices:Gp(r,S,o),prevLayout:i,trigger:"keyboard"});i!==se&&c(se)}}break}}};return v.addEventListener("keydown",z),()=>{v.removeEventListener("keydown",z)}});return()=>{y.forEach(v=>v())}},[o,t,l,r,i,s,c])}function lm(t,l){if(t.length!==l.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==l[r])return!1;return!0}function Qp(t,l){const r=t==="horizontal",{x:i,y:s}=bs(l);return r?i:s}function Z6(t,l,r,i,s){const o=r==="horizontal",c=Ss(l,s);Me(c,`No resize handle element found for id "${l}"`);const d=c.getAttribute(rt.groupId);Me(d,"Resize handle element has no group id attribute");let{initialCursorPosition:m}=i;const p=Qp(r,t),x=Xp(d,s);Me(x,`No group element found for id "${d}"`);const y=x.getBoundingClientRect(),v=o?y.width:y.height;return(p-m)/v*100}function q6(t,l,r,i,s,o){if(Hp(t)){const c=r==="horizontal";let d=0;t.shiftKey?d=100:s!=null?d=s:d=10;let m=0;switch(t.key){case"ArrowDown":m=c?0:d;break;case"ArrowLeft":m=c?-d:0;break;case"ArrowRight":m=c?d:0;break;case"ArrowUp":m=c?0:-d;break;case"End":m=100;break;case"Home":m=-100;break}return m}else return i==null?0:Z6(t,l,r,i,o)}function $6({panelDataArray:t}){const l=Array(t.length),r=t.map(o=>o.constraints);let i=0,s=100;for(let o=0;o<t.length;o++){const c=r[o];Me(c,`Panel constraints not found for index ${o}`);const{defaultSize:d}=c;d!=null&&(i++,l[o]=d,s-=d)}for(let o=0;o<t.length;o++){const c=r[o];Me(c,`Panel constraints not found for index ${o}`);const{defaultSize:d}=c;if(d!=null)continue;const m=t.length-i,p=s/m;i++,l[o]=p,s-=p}return l}function Xr(t,l,r){l.forEach((i,s)=>{const o=t[s];Me(o,`Panel data not found for index ${s}`);const{callbacks:c,constraints:d,id:m}=o,{collapsedSize:p=0,collapsible:x}=d,y=r[m];if(y==null||i!==y){r[m]=i;const{onCollapse:v,onExpand:S,onResize:C}=c;C&&C(i,y),x&&(v||S)&&(S&&(y==null||Wn(y,p))&&!Wn(i,p)&&S(),v&&(y==null||!Wn(y,p))&&Wn(i,p)&&v())}})}function Gu(t,l){if(t.length!==l.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=l[r])return!1;return!0}function V6({defaultSize:t,dragState:l,layout:r,panelData:i,panelIndex:s,precision:o=3}){const c=r[s];let d;return c==null?d=t!=null?t.toPrecision(o):"1":i.length===1?d="1":d=c.toPrecision(o),{flexBasis:0,flexGrow:d,flexShrink:1,overflow:"hidden",pointerEvents:l!==null?"none":void 0}}function I6(t,l=10){let r=null;return(...s)=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{t(...s)},l)}}function rm(t){try{if(typeof localStorage<"u")t.getItem=l=>localStorage.getItem(l),t.setItem=(l,r)=>{localStorage.setItem(l,r)};else throw new Error("localStorage not supported in this environment")}catch(l){console.error(l),t.getItem=()=>null,t.setItem=()=>{}}}function Kp(t){return`react-resizable-panels:${t}`}function Pp(t){return t.map(l=>{const{constraints:r,id:i,idIsFromProps:s,order:o}=l;return s?i:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((l,r)=>l.localeCompare(r)).join(",")}function Wp(t,l){try{const r=Kp(t),i=l.getItem(r);if(i){const s=JSON.parse(i);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function J6(t,l,r){var i,s;const o=(i=Wp(t,r))!==null&&i!==void 0?i:{},c=Pp(l);return(s=o[c])!==null&&s!==void 0?s:null}function F6(t,l,r,i,s){var o;const c=Kp(t),d=Pp(l),m=(o=Wp(t,s))!==null&&o!==void 0?o:{};m[d]={expandToSizes:Object.fromEntries(r.entries()),layout:i};try{s.setItem(c,JSON.stringify(m))}catch(p){console.error(p)}}function am({layout:t,panelConstraints:l}){const r=[...t],i=r.reduce((o,c)=>o+c,0);if(r.length!==l.length)throw Error(`Invalid ${l.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!en(i,100)&&r.length>0)for(let o=0;o<l.length;o++){const c=r[o];Me(c!=null,`No layout data found for index ${o}`);const d=100/i*c;r[o]=d}let s=0;for(let o=0;o<l.length;o++){const c=r[o];Me(c!=null,`No layout data found for index ${o}`);const d=la({panelConstraints:l,panelIndex:o,size:c});c!=d&&(s+=c-d,r[o]=d)}if(!en(s,0))for(let o=0;o<l.length;o++){const c=r[o];Me(c!=null,`No layout data found for index ${o}`);const d=c+s,m=la({panelConstraints:l,panelIndex:o,size:d});if(c!==m&&(s-=m-c,r[o]=m,en(s,0)))break}return r}const Y6=100,mi={getItem:t=>(rm(mi),mi.getItem(t)),setItem:(t,l)=>{rm(mi),mi.setItem(t,l)}},im={};function e3({autoSaveId:t=null,children:l,className:r="",direction:i,forwardedRef:s,id:o=null,onLayout:c=null,keyboardResizeBy:d=null,storage:m=mi,style:p,tagName:x="div",...y}){const v=t1(o),S=E.useRef(null),[C,T]=E.useState(null),[z,M]=E.useState([]),U=O6(),N=E.useRef({}),V=E.useRef(new Map),F=E.useRef(0),_=E.useRef({autoSaveId:t,direction:i,dragState:C,id:v,keyboardResizeBy:d,onLayout:c,storage:m}),I=E.useRef({layout:z,panelDataArray:[],panelDataArrayChanged:!1});E.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),E.useImperativeHandle(s,()=>({getId:()=>_.current.id,getLayout:()=>{const{layout:k}=I.current;return k},setLayout:k=>{const{onLayout:Q}=_.current,{layout:re,panelDataArray:ee}=I.current,ne=am({layout:k,panelConstraints:ee.map(fe=>fe.constraints)});lm(re,ne)||(M(ne),I.current.layout=ne,Q&&Q(ne),Xr(ee,ne,N.current))}}),[]),ar(()=>{_.current.autoSaveId=t,_.current.direction=i,_.current.dragState=C,_.current.id=v,_.current.onLayout=c,_.current.storage=m}),B6({committedValuesRef:_,eagerValuesRef:I,groupId:v,layout:z,panelDataArray:I.current.panelDataArray,setLayout:M,panelGroupElement:S.current}),E.useEffect(()=>{const{panelDataArray:k}=I.current;if(t){if(z.length===0||z.length!==k.length)return;let Q=im[t];Q==null&&(Q=I6(F6,Y6),im[t]=Q);const re=[...k],ee=new Map(V.current);Q(t,re,ee,z,m)}},[t,z,m]),E.useEffect(()=>{});const se=E.useCallback(k=>{const{onLayout:Q}=_.current,{layout:re,panelDataArray:ee}=I.current;if(k.constraints.collapsible){const ne=ee.map(st=>st.constraints),{collapsedSize:fe=0,panelSize:me,pivotIndices:Le}=nr(ee,k,re);if(Me(me!=null,`Panel size not found for panel "${k.id}"`),!Wn(me,fe)){V.current.set(k.id,me);const Mt=ea(ee,k)===ee.length-1?me-fe:fe-me,Fe=hi({delta:Mt,initialLayout:re,panelConstraints:ne,pivotIndices:Le,prevLayout:re,trigger:"imperative-api"});Gu(re,Fe)||(M(Fe),I.current.layout=Fe,Q&&Q(Fe),Xr(ee,Fe,N.current))}}},[]),oe=E.useCallback((k,Q)=>{const{onLayout:re}=_.current,{layout:ee,panelDataArray:ne}=I.current;if(k.constraints.collapsible){const fe=ne.map(at=>at.constraints),{collapsedSize:me=0,panelSize:Le=0,minSize:st=0,pivotIndices:Mt}=nr(ne,k,ee),Fe=Q??st;if(Wn(Le,me)){const at=V.current.get(k.id),nn=at!=null&&at>=Fe?at:Fe,al=ea(ne,k)===ne.length-1?Le-nn:nn-Le,mt=hi({delta:al,initialLayout:ee,panelConstraints:fe,pivotIndices:Mt,prevLayout:ee,trigger:"imperative-api"});Gu(ee,mt)||(M(mt),I.current.layout=mt,re&&re(mt),Xr(ne,mt,N.current))}}},[]),O=E.useCallback(k=>{const{layout:Q,panelDataArray:re}=I.current,{panelSize:ee}=nr(re,k,Q);return Me(ee!=null,`Panel size not found for panel "${k.id}"`),ee},[]),ae=E.useCallback((k,Q)=>{const{panelDataArray:re}=I.current,ee=ea(re,k);return V6({defaultSize:Q,dragState:C,layout:z,panelData:re,panelIndex:ee})},[C,z]),te=E.useCallback(k=>{const{layout:Q,panelDataArray:re}=I.current,{collapsedSize:ee=0,collapsible:ne,panelSize:fe}=nr(re,k,Q);return Me(fe!=null,`Panel size not found for panel "${k.id}"`),ne===!0&&Wn(fe,ee)},[]),be=E.useCallback(k=>{const{layout:Q,panelDataArray:re}=I.current,{collapsedSize:ee=0,collapsible:ne,panelSize:fe}=nr(re,k,Q);return Me(fe!=null,`Panel size not found for panel "${k.id}"`),!ne||ir(fe,ee)>0},[]),ue=E.useCallback(k=>{const{panelDataArray:Q}=I.current;Q.push(k),Q.sort((re,ee)=>{const ne=re.order,fe=ee.order;return ne==null&&fe==null?0:ne==null?-1:fe==null?1:ne-fe}),I.current.panelDataArrayChanged=!0,U()},[U]);ar(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:k,onLayout:Q,storage:re}=_.current,{layout:ee,panelDataArray:ne}=I.current;let fe=null;if(k){const Le=J6(k,ne,re);Le&&(V.current=new Map(Object.entries(Le.expandToSizes)),fe=Le.layout)}fe==null&&(fe=$6({panelDataArray:ne}));const me=am({layout:fe,panelConstraints:ne.map(Le=>Le.constraints)});lm(ee,me)||(M(me),I.current.layout=me,Q&&Q(me),Xr(ne,me,N.current))}}),ar(()=>{const k=I.current;return()=>{k.layout=[]}},[]);const P=E.useCallback(k=>{let Q=!1;const re=S.current;return re&&window.getComputedStyle(re,null).getPropertyValue("direction")==="rtl"&&(Q=!0),function(ne){ne.preventDefault();const fe=S.current;if(!fe)return()=>null;const{direction:me,dragState:Le,id:st,keyboardResizeBy:Mt,onLayout:Fe}=_.current,{layout:at,panelDataArray:nn}=I.current,{initialLayout:gn}=Le??{},al=Gp(st,k,fe);let mt=q6(ne,k,me,Le,Mt,fe);const Rn=me==="horizontal";Rn&&Q&&(mt=-mt);const il=nn.map(ma=>ma.constraints),yn=hi({delta:mt,initialLayout:gn??at,panelConstraints:il,pivotIndices:al,prevLayout:at,trigger:Hp(ne)?"keyboard":"mouse-or-touch"}),cr=!Gu(at,yn);(Bp(ne)||Zp(ne))&&F.current!=mt&&(F.current=mt,!cr&&mt!==0?Rn?tf(k,mt<0?$p:Vp):tf(k,mt<0?Ip:Jp):tf(k,0)),cr&&(M(yn),I.current.layout=yn,Fe&&Fe(yn),Xr(nn,yn,N.current))}},[]),H=E.useCallback((k,Q)=>{const{onLayout:re}=_.current,{layout:ee,panelDataArray:ne}=I.current,fe=ne.map(at=>at.constraints),{panelSize:me,pivotIndices:Le}=nr(ne,k,ee);Me(me!=null,`Panel size not found for panel "${k.id}"`);const Mt=ea(ne,k)===ne.length-1?me-Q:Q-me,Fe=hi({delta:Mt,initialLayout:ee,panelConstraints:fe,pivotIndices:Le,prevLayout:ee,trigger:"imperative-api"});Gu(ee,Fe)||(M(Fe),I.current.layout=Fe,re&&re(Fe),Xr(ne,Fe,N.current))},[]),W=E.useCallback((k,Q)=>{const{layout:re,panelDataArray:ee}=I.current,{collapsedSize:ne=0,collapsible:fe}=Q,{collapsedSize:me=0,collapsible:Le,maxSize:st=100,minSize:Mt=0}=k.constraints,{panelSize:Fe}=nr(ee,k,re);Fe!=null&&(fe&&Le&&Wn(Fe,ne)?Wn(ne,me)||H(k,me):Fe<Mt?H(k,Mt):Fe>st&&H(k,st))},[H]),ce=E.useCallback((k,Q)=>{const{direction:re}=_.current,{layout:ee}=I.current;if(!S.current)return;const ne=Ss(k,S.current);Me(ne,`Drag handle element not found for id "${k}"`);const fe=Qp(re,Q);T({dragHandleId:k,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:fe,initialLayout:ee})},[]),Se=E.useCallback(()=>{T(null)},[]),j=E.useCallback(k=>{const{panelDataArray:Q}=I.current,re=ea(Q,k);re>=0&&(Q.splice(re,1),delete N.current[k.id],I.current.panelDataArrayChanged=!0,U())},[U]),R=E.useMemo(()=>({collapsePanel:se,direction:i,dragState:C,expandPanel:oe,getPanelSize:O,getPanelStyle:ae,groupId:v,isPanelCollapsed:te,isPanelExpanded:be,reevaluatePanelConstraints:W,registerPanel:ue,registerResizeHandle:P,resizePanel:H,startDragging:ce,stopDragging:Se,unregisterPanel:j,panelGroupElement:S.current}),[se,C,i,oe,O,ae,v,te,be,W,ue,P,H,ce,Se,j]),J={display:"flex",flexDirection:i==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return E.createElement(xs.Provider,{value:R},E.createElement(x,{...y,children:l,className:r,id:o,ref:S,style:{...J,...p},[rt.group]:"",[rt.groupDirection]:i,[rt.groupId]:v}))}const t3=E.forwardRef((t,l)=>E.createElement(e3,{...t,forwardedRef:l}));e3.displayName="PanelGroup";t3.displayName="forwardRef(PanelGroup)";function ea(t,l){return t.findIndex(r=>r===l||r.id===l.id)}function nr(t,l,r){const i=ea(t,l),o=i===t.length-1?[i-1,i]:[i,i+1],c=r[i];return{...l.constraints,panelSize:c,pivotIndices:o}}function G6({disabled:t,handleId:l,resizeHandler:r,panelGroupElement:i}){E.useEffect(()=>{if(t||r==null||i==null)return;const s=Ss(l,i);if(s==null)return;const o=c=>{if(!c.defaultPrevented)switch(c.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{c.preventDefault(),r(c);break}case"F6":{c.preventDefault();const d=s.getAttribute(rt.groupId);Me(d,`No group element found for id "${d}"`);const m=vi(d,i),p=Yp(d,l,i);Me(p!==null,`No resize element found for id "${l}"`);const x=c.shiftKey?p>0?p-1:m.length-1:p+1<m.length?p+1:0;m[x].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[i,t,l,r])}function Nf({children:t=null,className:l="",disabled:r=!1,hitAreaMargins:i,id:s,onBlur:o,onClick:c,onDragging:d,onFocus:m,onPointerDown:p,onPointerUp:x,style:y={},tabIndex:v=0,tagName:S="div",...C}){var T,z;const M=E.useRef(null),U=E.useRef({onClick:c,onDragging:d,onPointerDown:p,onPointerUp:x});E.useEffect(()=>{U.current.onClick=c,U.current.onDragging=d,U.current.onPointerDown=p,U.current.onPointerUp=x});const N=E.useContext(xs);if(N===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:V,groupId:F,registerResizeHandle:_,startDragging:I,stopDragging:se,panelGroupElement:oe}=N,O=t1(s),[ae,te]=E.useState("inactive"),[be,ue]=E.useState(!1),[P,H]=E.useState(null),W=E.useRef({state:ae});ar(()=>{W.current.state=ae}),E.useEffect(()=>{if(r)H(null);else{const R=_(O);H(()=>R)}},[r,O,_]);const ce=(T=i==null?void 0:i.coarse)!==null&&T!==void 0?T:15,Se=(z=i==null?void 0:i.fine)!==null&&z!==void 0?z:5;E.useEffect(()=>{if(r||P==null)return;const R=M.current;Me(R,"Element ref not attached");let J=!1;return R6(O,R,V,{coarse:ce,fine:Se},(Q,re,ee)=>{if(!re){te("inactive");return}switch(Q){case"down":{te("drag"),J=!1,Me(ee,'Expected event to be defined for "down" action'),I(O,ee);const{onDragging:ne,onPointerDown:fe}=U.current;ne==null||ne(!0),fe==null||fe();break}case"move":{const{state:ne}=W.current;J=!0,ne!=="drag"&&te("hover"),Me(ee,'Expected event to be defined for "move" action'),P(ee);break}case"up":{te("hover"),se();const{onClick:ne,onDragging:fe,onPointerUp:me}=U.current;fe==null||fe(!1),me==null||me(),J||ne==null||ne();break}}})},[ce,V,r,Se,_,O,P,I,se]),G6({disabled:r,handleId:O,resizeHandler:P,panelGroupElement:oe});const j={touchAction:"none",userSelect:"none"};return E.createElement(S,{...C,children:t,className:l,id:s,onBlur:()=>{ue(!1),o==null||o()},onFocus:()=>{ue(!0),m==null||m()},ref:M,role:"separator",style:{...j,...y},tabIndex:v,[rt.groupDirection]:V,[rt.groupId]:F,[rt.resizeHandle]:"",[rt.resizeHandleActive]:ae==="drag"?"pointer":be?"keyboard":void 0,[rt.resizeHandleEnabled]:!r,[rt.resizeHandleId]:O,[rt.resizeHandleState]:ae})}Nf.displayName="PanelResizeHandle";/**
|
|
60
|
+
Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}/*`}">.`)}let v=ll(),S;if(l){let N=typeof l=="string"?ua(l):l;tt(x==="/"||((U=N.pathname)==null?void 0:U.startsWith(x)),`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 "${x}" but pathname "${N.pathname}" was given in the \`location\` prop.`),S=N}else S=v;let C=S.pathname||"/",T=C;if(x!=="/"){let N=x.replace(/^\//,"").split("/");T="/"+C.replace(/^\//,"").split("/").slice(N.length).join("/")}let z=sp(t,{pathname:T});zn(y||z!=null,`No routes matched location "${S.pathname}${S.search}${S.hash}" `),zn(z==null||z[z.length-1].route.element!==void 0||z[z.length-1].route.Component!==void 0||z[z.length-1].route.lazy!==void 0,`Matched leaf route at location "${S.pathname}${S.search}${S.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 M=Uy(z&&z.map(N=>Object.assign({},N,{params:Object.assign({},m,N.params),pathname:el([x,o.encodeLocation?o.encodeLocation(N.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?x:el([x,o.encodeLocation?o.encodeLocation(N.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:N.pathnameBase])})),c,r,i,s);return l&&M?E.createElement(Ei.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...S},navigationType:"POP"}},M):M}function Ry(){let t=$y(),l=vy(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),r=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:i},o={padding:"2px 4px",backgroundColor:i},c=null;return console.error("Error handled by React Router default ErrorBoundary:",t),c=E.createElement(E.Fragment,null,E.createElement("p",null,"💿 Hey developer 👋"),E.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",E.createElement("code",{style:o},"ErrorBoundary")," or"," ",E.createElement("code",{style:o},"errorElement")," prop on your route.")),E.createElement(E.Fragment,null,E.createElement("h2",null,"Unexpected Application Error!"),E.createElement("h3",{style:{fontStyle:"italic"}},l),r?E.createElement("pre",{style:s},r):null,c)}var Dy=E.createElement(Ry,null),Sp=class extends E.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,l){return l.location!==t.location||l.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:l.error,location:l.location,revalidation:t.revalidation||l.revalidation}}componentDidCatch(t,l){this.props.onError?this.props.onError(t,l):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const r=Ay(t.digest);r&&(t=r)}let l=t!==void 0?E.createElement(Tn.Provider,{value:this.props.routeContext},E.createElement(Vf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?E.createElement(Oy,{error:t},l):l}};Sp.contextType=ky;var Qc=new WeakMap;function Oy({children:t,error:l}){let{basename:r}=E.useContext(pn);if(typeof l=="object"&&l&&"digest"in l&&typeof l.digest=="string"){let i=jy(l.digest);if(i){let s=Qc.get(l);if(s)throw s;let o=mp(i.location,r);if(hp&&!Qc.get(l))if(o.isExternal||i.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const c=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:i.replace}));throw Qc.set(l,c),c}return E.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return t}function Ly({routeContext:t,match:l,children:r}){let i=E.useContext(sa);return i&&i.static&&i.staticContext&&(l.route.errorElement||l.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=l.route.id),E.createElement(Tn.Provider,{value:t},r)}function Uy(t,l=[],r=null,i=null,s=null){if(t==null){if(!r)return null;if(r.errors)t=r.matches;else if(l.length===0&&!r.initialized&&r.matches.length>0)t=r.matches;else return null}let o=t,c=r==null?void 0:r.errors;if(c!=null){let x=o.findIndex(y=>y.route.id&&(c==null?void 0:c[y.route.id])!==void 0);tt(x>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),o=o.slice(0,Math.min(o.length,x+1))}let d=!1,m=-1;if(r)for(let x=0;x<o.length;x++){let y=o[x];if((y.route.HydrateFallback||y.route.hydrateFallbackElement)&&(m=x),y.route.id){let{loaderData:v,errors:S}=r,C=y.route.loader&&!v.hasOwnProperty(y.route.id)&&(!S||S[y.route.id]===void 0);if(y.route.lazy||C){d=!0,m>=0?o=o.slice(0,m+1):o=[o[0]];break}}}let p=r&&i?(x,y)=>{var v,S;i(x,{location:r.location,params:((S=(v=r.matches)==null?void 0:v[0])==null?void 0:S.params)??{},unstable_pattern:Sy(r.matches),errorInfo:y})}:void 0;return o.reduceRight((x,y,v)=>{let S,C=!1,T=null,z=null;r&&(S=c&&y.route.id?c[y.route.id]:void 0,T=y.route.errorElement||Dy,d&&(m<0&&v===0?(wp("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),C=!0,z=null):m===v&&(C=!0,z=y.route.hydrateFallbackElement||null)));let M=l.concat(o.slice(0,v+1)),U=()=>{let N;return S?N=T:C?N=z:y.route.Component?N=E.createElement(y.route.Component,null):y.route.element?N=y.route.element:N=x,E.createElement(Ly,{match:y,routeContext:{outlet:x,matches:M,isDataRoute:r!=null},children:N})};return r&&(y.route.ErrorBoundary||y.route.errorElement||v===0)?E.createElement(Sp,{location:r.location,revalidation:r.revalidation,component:T,error:S,children:U(),routeContext:{outlet:null,matches:M,isDataRoute:!0},onError:p}):U()},null)}function Ff(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hy(t){let l=E.useContext(sa);return tt(l,Ff(t)),l}function By(t){let l=E.useContext(ps);return tt(l,Ff(t)),l}function Zy(t){let l=E.useContext(Tn);return tt(l,Ff(t)),l}function Yf(t){let l=Zy(t),r=l.matches[l.matches.length-1];return tt(r.route.id,`${t} can only be used on routes that contain a unique "id"`),r.route.id}function qy(){return Yf("useRouteId")}function $y(){var i;let t=E.useContext(Vf),l=By("useRouteError"),r=Yf("useRouteError");return t!==void 0?t:(i=l.errors)==null?void 0:i[r]}function Vy(){let{router:t}=Hy("useNavigate"),l=Yf("useNavigate"),r=E.useRef(!1);return bp(()=>{r.current=!0}),E.useCallback(async(s,o={})=>{zn(r.current,xp),r.current&&(typeof s=="number"?await t.navigate(s):await t.navigate(s,{fromRouteId:l,...o}))},[t,l])}var H0={};function wp(t,l,r){!l&&!H0[t]&&(H0[t]=!0,zn(!1,r))}E.memo(Iy);function Iy({routes:t,future:l,state:r,onError:i}){return vp(t,void 0,r,i,l)}function Dl(t){tt(!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 Jy({basename:t="/",children:l=null,location:r,navigationType:i="POP",navigator:s,static:o=!1,unstable_useTransitions:c}){tt(!Mi(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let d=t.replace(/^\/*/,"/"),m=E.useMemo(()=>({basename:d,navigator:s,static:o,unstable_useTransitions:c,future:{}}),[d,s,o,c]);typeof r=="string"&&(r=ua(r));let{pathname:p="/",search:x="",hash:y="",state:v=null,key:S="default"}=r,C=E.useMemo(()=>{let T=tl(p,d);return T==null?null:{location:{pathname:T,search:x,hash:y,state:v,key:S},navigationType:i}},[d,p,x,y,v,S,i]);return zn(C!=null,`<Router basename="${d}"> is not able to match the URL "${p}${x}${y}" because it does not start with the basename, so the <Router> won't render anything.`),C==null?null:E.createElement(pn.Provider,{value:m},E.createElement(Ei.Provider,{children:l,value:C}))}function Fy({children:t,location:l}){return _y(Ef(t),l)}function Ef(t,l=[]){let r=[];return E.Children.forEach(t,(i,s)=>{if(!E.isValidElement(i))return;let o=[...l,s];if(i.type===E.Fragment){r.push.apply(r,Ef(i.props.children,o));return}tt(i.type===Dl,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),tt(!i.props.index||!i.props.children,"An index route cannot have child routes.");let c={id:i.props.id||o.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(c.children=Ef(i.props.children,o)),r.push(c)}),r}var es="get",ts="application/x-www-form-urlencoded";function gs(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Yy(t){return gs(t)&&t.tagName.toLowerCase()==="button"}function Gy(t){return gs(t)&&t.tagName.toLowerCase()==="form"}function Xy(t){return gs(t)&&t.tagName.toLowerCase()==="input"}function Qy(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Ky(t,l){return t.button===0&&(!l||l==="_self")&&!Qy(t)}var Yu=null;function Py(){if(Yu===null)try{new FormData(document.createElement("form"),0),Yu=!1}catch{Yu=!0}return Yu}var Wy=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Kc(t){return t!=null&&!Wy.has(t)?(zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${ts}"`),null):t}function ex(t,l){let r,i,s,o,c;if(Gy(t)){let d=t.getAttribute("action");i=d?tl(d,l):null,r=t.getAttribute("method")||es,s=Kc(t.getAttribute("enctype"))||ts,o=new FormData(t)}else if(Yy(t)||Xy(t)&&(t.type==="submit"||t.type==="image")){let d=t.form;if(d==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let m=t.getAttribute("formaction")||d.getAttribute("action");if(i=m?tl(m,l):null,r=t.getAttribute("formmethod")||d.getAttribute("method")||es,s=Kc(t.getAttribute("formenctype"))||Kc(d.getAttribute("enctype"))||ts,o=new FormData(d,t),!Py()){let{name:p,type:x,value:y}=t;if(x==="image"){let v=p?`${p}.`:"";o.append(`${v}x`,"0"),o.append(`${v}y`,"0")}else p&&o.append(p,y)}}else{if(gs(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');r=es,i=null,s=ts,c=t}return o&&s==="text/plain"&&(c=o,o=void 0),{action:i,method:r.toLowerCase(),encType:s,formData:o,body:c}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Gf(t,l){if(t===!1||t===null||typeof t>"u")throw new Error(l)}function tx(t,l,r,i){let s=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return r?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${i}`:s.pathname=`${s.pathname}.${i}`:s.pathname==="/"?s.pathname=`_root.${i}`:l&&tl(s.pathname,l)==="/"?s.pathname=`${l.replace(/\/$/,"")}/_root.${i}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${i}`,s}async function nx(t,l){if(t.id in l)return l[t.id];try{let r=await import(t.module);return l[t.id]=r,r}catch(r){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(r),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function lx(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function rx(t,l,r){let i=await Promise.all(t.map(async s=>{let o=l.routes[s.route.id];if(o){let c=await nx(o,r);return c.links?c.links():[]}return[]}));return sx(i.flat(1).filter(lx).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function B0(t,l,r,i,s,o){let c=(m,p)=>r[p]?m.route.id!==r[p].route.id:!0,d=(m,p)=>{var x;return r[p].pathname!==m.pathname||((x=r[p].route.path)==null?void 0:x.endsWith("*"))&&r[p].params["*"]!==m.params["*"]};return o==="assets"?l.filter((m,p)=>c(m,p)||d(m,p)):o==="data"?l.filter((m,p)=>{var y;let x=i.routes[m.route.id];if(!x||!x.hasLoader)return!1;if(c(m,p)||d(m,p))return!0;if(m.route.shouldRevalidate){let v=m.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((y=r[0])==null?void 0:y.params)||{},nextUrl:new URL(t,window.origin),nextParams:m.params,defaultShouldRevalidate:!0});if(typeof v=="boolean")return v}return!0}):[]}function ax(t,l,{includeHydrateFallback:r}={}){return ix(t.map(i=>{let s=l.routes[i.route.id];if(!s)return[];let o=[s.module];return s.clientActionModule&&(o=o.concat(s.clientActionModule)),s.clientLoaderModule&&(o=o.concat(s.clientLoaderModule)),r&&s.hydrateFallbackModule&&(o=o.concat(s.hydrateFallbackModule)),s.imports&&(o=o.concat(s.imports)),o}).flat(1))}function ix(t){return[...new Set(t)]}function ux(t){let l={},r=Object.keys(t).sort();for(let i of r)l[i]=t[i];return l}function sx(t,l){let r=new Set;return new Set(l),t.reduce((i,s)=>{let o=JSON.stringify(ux(s));return r.has(o)||(r.add(o),i.push({key:o,link:s})),i},[])}function kp(){let t=E.useContext(sa);return Gf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function ox(){let t=E.useContext(ps);return Gf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Xf=E.createContext(void 0);Xf.displayName="FrameworkContext";function Cp(){let t=E.useContext(Xf);return Gf(t,"You must render this element inside a <HydratedRouter> element"),t}function cx(t,l){let r=E.useContext(Xf),[i,s]=E.useState(!1),[o,c]=E.useState(!1),{onFocus:d,onBlur:m,onMouseEnter:p,onMouseLeave:x,onTouchStart:y}=l,v=E.useRef(null);E.useEffect(()=>{if(t==="render"&&c(!0),t==="viewport"){let T=M=>{M.forEach(U=>{c(U.isIntersecting)})},z=new IntersectionObserver(T,{threshold:.5});return v.current&&z.observe(v.current),()=>{z.disconnect()}}},[t]),E.useEffect(()=>{if(i){let T=setTimeout(()=>{c(!0)},100);return()=>{clearTimeout(T)}}},[i]);let S=()=>{s(!0)},C=()=>{s(!1),c(!1)};return r?t!=="intent"?[o,v,{}]:[o,v,{onFocus:si(d,S),onBlur:si(m,C),onMouseEnter:si(p,S),onMouseLeave:si(x,C),onTouchStart:si(y,S)}]:[!1,v,{}]}function si(t,l){return r=>{t&&t(r),r.defaultPrevented||l(r)}}function fx({page:t,...l}){let{router:r}=kp(),i=E.useMemo(()=>sp(r.routes,t,r.basename),[r.routes,t,r.basename]);return i?E.createElement(hx,{page:t,matches:i,...l}):null}function dx(t){let{manifest:l,routeModules:r}=Cp(),[i,s]=E.useState([]);return E.useEffect(()=>{let o=!1;return rx(t,l,r).then(c=>{o||s(c)}),()=>{o=!0}},[t,l,r]),i}function hx({page:t,matches:l,...r}){let i=ll(),{future:s,manifest:o,routeModules:c}=Cp(),{basename:d}=kp(),{loaderData:m,matches:p}=ox(),x=E.useMemo(()=>B0(t,l,p,o,i,"data"),[t,l,p,o,i]),y=E.useMemo(()=>B0(t,l,p,o,i,"assets"),[t,l,p,o,i]),v=E.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let T=new Set,z=!1;if(l.forEach(U=>{var V;let N=o.routes[U.route.id];!N||!N.hasLoader||(!x.some(F=>F.route.id===U.route.id)&&U.route.id in m&&((V=c[U.route.id])!=null&&V.shouldRevalidate)||N.hasClientLoader?z=!0:T.add(U.route.id))}),T.size===0)return[];let M=tx(t,d,s.unstable_trailingSlashAwareDataRequests,"data");return z&&T.size>0&&M.searchParams.set("_routes",l.filter(U=>T.has(U.route.id)).map(U=>U.route.id).join(",")),[M.pathname+M.search]},[d,s.unstable_trailingSlashAwareDataRequests,m,i,o,x,l,t,c]),S=E.useMemo(()=>ax(y,o),[y,o]),C=dx(y);return E.createElement(E.Fragment,null,v.map(T=>E.createElement("link",{key:T,rel:"prefetch",as:"fetch",href:T,...r})),S.map(T=>E.createElement("link",{key:T,rel:"modulepreload",href:T,...r})),C.map(({key:T,link:z})=>E.createElement("link",{key:T,nonce:r.nonce,...z,crossOrigin:z.crossOrigin??r.crossOrigin})))}function mx(...t){return l=>{t.forEach(r=>{typeof r=="function"?r(l):r!=null&&(r.current=l)})}}var px=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{px&&(window.__reactRouterVersion="7.13.0")}catch{}function gx({basename:t,children:l,unstable_useTransitions:r,window:i}){let s=E.useRef();s.current==null&&(s.current=Q5({window:i,v5Compat:!0}));let o=s.current,[c,d]=E.useState({action:o.action,location:o.location}),m=E.useCallback(p=>{r===!1?d(p):E.startTransition(()=>d(p))},[r]);return E.useLayoutEffect(()=>o.listen(m),[o,m]),E.createElement(Jy,{basename:t,children:l,location:c.location,navigationType:c.action,navigator:o,unstable_useTransitions:r})}var Ep=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,yt=E.forwardRef(function({onClick:l,discover:r="render",prefetch:i="none",relative:s,reloadDocument:o,replace:c,state:d,target:m,to:p,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:v,...S},C){let{basename:T,unstable_useTransitions:z}=E.useContext(pn),M=typeof p=="string"&&Ep.test(p),U=mp(p,T);p=U.to;let N=zy(p,{relative:s}),[V,F,_]=cx(i,S),I=vx(p,{replace:c,state:d,target:m,preventScrollReset:x,relative:s,viewTransition:y,unstable_defaultShouldRevalidate:v,unstable_useTransitions:z});function se(O){l&&l(O),O.defaultPrevented||I(O)}let oe=E.createElement("a",{...S,..._,href:U.absoluteURL||N,onClick:U.isExternal||o?l:se,ref:mx(C,F),target:m,"data-discover":!M&&r==="render"?"true":void 0});return V&&!M?E.createElement(E.Fragment,null,oe,E.createElement(fx,{page:N})):oe});yt.displayName="Link";var yx=E.forwardRef(function({"aria-current":l="page",caseSensitive:r=!1,className:i="",end:s=!1,style:o,to:c,viewTransition:d,children:m,...p},x){let y=Ni(c,{relative:p.relative}),v=ll(),S=E.useContext(ps),{navigator:C,basename:T}=E.useContext(pn),z=S!=null&&Ex(y)&&d===!0,M=C.encodeLocation?C.encodeLocation(y).pathname:y.pathname,U=v.pathname,N=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;r||(U=U.toLowerCase(),N=N?N.toLowerCase():null,M=M.toLowerCase()),N&&T&&(N=tl(N,T)||N);const V=M!=="/"&&M.endsWith("/")?M.length-1:M.length;let F=U===M||!s&&U.startsWith(M)&&U.charAt(V)==="/",_=N!=null&&(N===M||!s&&N.startsWith(M)&&N.charAt(M.length)==="/"),I={isActive:F,isPending:_,isTransitioning:z},se=F?l:void 0,oe;typeof i=="function"?oe=i(I):oe=[i,F?"active":null,_?"pending":null,z?"transitioning":null].filter(Boolean).join(" ");let O=typeof o=="function"?o(I):o;return E.createElement(yt,{...p,"aria-current":se,className:oe,ref:x,style:O,to:c,viewTransition:d},typeof m=="function"?m(I):m)});yx.displayName="NavLink";var xx=E.forwardRef(({discover:t="render",fetcherKey:l,navigate:r,reloadDocument:i,replace:s,state:o,method:c=es,action:d,onSubmit:m,relative:p,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:v,...S},C)=>{let{unstable_useTransitions:T}=E.useContext(pn),z=kx(),M=Cx(d,{relative:p}),U=c.toLowerCase()==="get"?"get":"post",N=typeof d=="string"&&Ep.test(d),V=F=>{if(m&&m(F),F.defaultPrevented)return;F.preventDefault();let _=F.nativeEvent.submitter,I=(_==null?void 0:_.getAttribute("formmethod"))||c,se=()=>z(_||F.currentTarget,{fetcherKey:l,method:I,navigate:r,replace:s,state:o,relative:p,preventScrollReset:x,viewTransition:y,unstable_defaultShouldRevalidate:v});T&&r!==!1?E.startTransition(()=>se()):se()};return E.createElement("form",{ref:C,method:U,action:M,onSubmit:i?m:V,...S,"data-discover":!N&&t==="render"?"true":void 0})});xx.displayName="Form";function bx(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Mp(t){let l=E.useContext(sa);return tt(l,bx(t)),l}function vx(t,{target:l,replace:r,state:i,preventScrollReset:s,relative:o,viewTransition:c,unstable_defaultShouldRevalidate:d,unstable_useTransitions:m}={}){let p=If(),x=ll(),y=Ni(t,{relative:o});return E.useCallback(v=>{if(Ky(v,l)){v.preventDefault();let S=r!==void 0?r:xi(x)===xi(y),C=()=>p(t,{replace:S,state:i,preventScrollReset:s,relative:o,viewTransition:c,unstable_defaultShouldRevalidate:d});m?E.startTransition(()=>C()):C()}},[x,p,y,r,i,l,t,s,o,c,d,m])}var Sx=0,wx=()=>`__${String(++Sx)}__`;function kx(){let{router:t}=Mp("useSubmit"),{basename:l}=E.useContext(pn),r=qy(),i=t.fetch,s=t.navigate;return E.useCallback(async(o,c={})=>{let{action:d,method:m,encType:p,formData:x,body:y}=ex(o,l);if(c.navigate===!1){let v=c.fetcherKey||wx();await i(v,r,c.action||d,{unstable_defaultShouldRevalidate:c.unstable_defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:x,body:y,formMethod:c.method||m,formEncType:c.encType||p,flushSync:c.flushSync})}else await s(c.action||d,{unstable_defaultShouldRevalidate:c.unstable_defaultShouldRevalidate,preventScrollReset:c.preventScrollReset,formData:x,body:y,formMethod:c.method||m,formEncType:c.encType||p,replace:c.replace,state:c.state,fromRouteId:r,flushSync:c.flushSync,viewTransition:c.viewTransition})},[i,s,l,r])}function Cx(t,{relative:l}={}){let{basename:r}=E.useContext(pn),i=E.useContext(Tn);tt(i,"useFormAction must be used inside a RouteContext");let[s]=i.matches.slice(-1),o={...Ni(t||".",{relative:l})},c=ll();if(t==null){o.search=c.search;let d=new URLSearchParams(o.search),m=d.getAll("index");if(m.some(x=>x==="")){d.delete("index"),m.filter(y=>y).forEach(y=>d.append("index",y));let x=d.toString();o.search=x?`?${x}`:""}}return(!t||t===".")&&s.route.index&&(o.search=o.search?o.search.replace(/^\?/,"?index&"):"?index"),r!=="/"&&(o.pathname=o.pathname==="/"?r:el([r,o.pathname])),xi(o)}function Ex(t,{relative:l}={}){let r=E.useContext(gp);tt(r!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Mp("useViewTransitionState"),s=Ni(t,{relative:l});if(!r.isTransitioning)return!1;let o=tl(r.currentLocation.pathname,i)||r.currentLocation.pathname,c=tl(r.nextLocation.pathname,i)||r.nextLocation.pathname;return as(s.pathname,c)!=null||as(s.pathname,o)!=null}function Mx(t={}){const{url:l=Nx(),onMessage:r,onStatusChange:i,initialReconnectDelay:s=1e3,maxReconnectDelay:o=3e4,pingInterval:c=3e4}=t;let d=null,m="disconnected",p=0,x=null,y=null,v=!0;function S(O){m!==O&&(m=O,i==null||i(m))}function C(){const O=s*Math.pow(2,p);return Math.min(O,o)}function T(){z(),y=setInterval(()=>{(d==null?void 0:d.readyState)===WebSocket.OPEN&&V({type:"ping"})},c)}function z(){y!==null&&(clearInterval(y),y=null)}function M(){if(!v)return;const O=C();p++,S("reconnecting"),x=setTimeout(()=>{x=null,N()},O)}function U(){x!==null&&(clearTimeout(x),x=null)}function N(){d&&(d.onopen=null,d.onclose=null,d.onerror=null,d.onmessage=null,(d.readyState===WebSocket.OPEN||d.readyState===WebSocket.CONNECTING)&&d.close());try{d=new WebSocket(l),d.onopen=()=>{p=0,S("connected"),T()},d.onclose=()=>{z(),S("disconnected"),v&&M()},d.onerror=()=>{},d.onmessage=O=>{try{const ae=JSON.parse(O.data);r==null||r(ae)}catch{}}}catch{S("disconnected"),v&&M()}}function V(O){(d==null?void 0:d.readyState)===WebSocket.OPEN&&d.send(JSON.stringify(O))}function F(O){V({type:"subscribe",payload:{agentName:O}})}function _(O){V({type:"unsubscribe",payload:{agentName:O}})}function I(){return m}function se(){v=!1,U(),z(),d&&(d.onopen=null,d.onclose=null,d.onerror=null,d.onmessage=null,(d.readyState===WebSocket.OPEN||d.readyState===WebSocket.CONNECTING)&&d.close(),d=null),S("disconnected")}function oe(){v=!0,U(),p=0,N()}return N(),{send:V,subscribe:F,unsubscribe:_,getStatus:I,disconnect:se,reconnect:oe}}function Nx(){return typeof window>"u"?"ws://localhost:3000/ws":`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`}const Z0=t=>{let l;const r=new Set,i=(p,x)=>{const y=typeof p=="function"?p(l):p;if(!Object.is(y,l)){const v=l;l=x??(typeof y!="object"||y===null)?y:Object.assign({},l,y),r.forEach(S=>S(l,v))}},s=()=>l,d={setState:i,getState:s,getInitialState:()=>m,subscribe:p=>(r.add(p),()=>r.delete(p))},m=l=t(i,s,d);return d},jx=(t=>t?Z0(t):Z0),Ax=t=>t;function zx(t,l=Ax){const r=na.useSyncExternalStore(t.subscribe,na.useCallback(()=>l(t.getState()),[t,l]),na.useCallback(()=>l(t.getInitialState()),[t,l]));return na.useDebugValue(r),r}const Tx=t=>{const l=jx(t),r=i=>zx(l,i);return Object.assign(r,l),r},_x=(t=>Tx),q0=t=>Symbol.iterator in t,$0=t=>"entries"in t,V0=(t,l)=>{const r=t instanceof Map?t:new Map(t.entries()),i=l instanceof Map?l:new Map(l.entries());if(r.size!==i.size)return!1;for(const[s,o]of r)if(!i.has(s)||!Object.is(o,i.get(s)))return!1;return!0},Rx=(t,l)=>{const r=t[Symbol.iterator](),i=l[Symbol.iterator]();let s=r.next(),o=i.next();for(;!s.done&&!o.done;){if(!Object.is(s.value,o.value))return!1;s=r.next(),o=i.next()}return!!s.done&&!!o.done};function Dx(t,l){return Object.is(t,l)?!0:typeof t!="object"||t===null||typeof l!="object"||l===null||Object.getPrototypeOf(t)!==Object.getPrototypeOf(l)?!1:q0(t)&&q0(l)?$0(t)&&$0(l)?V0(t,l):Rx(t,l):V0({entries:()=>Object.entries(t)},{entries:()=>Object.entries(l)})}function Vt(t){const l=na.useRef(void 0);return r=>{const i=t(r);return Dx(l.current,i)?l.current:l.current=i}}function Ox(t){return"agent"in t}const I0=50,Lx={fleetStatus:null,agents:[],recentJobs:[],connectionStatus:"disconnected",lastUpdated:null},Ux=t=>({...Lx,setFleetStatus:l=>t({fleetStatus:l,lastUpdated:new Date().toISOString()}),setAgents:l=>t({agents:l,lastUpdated:new Date().toISOString()}),setRecentJobs:l=>t(r=>{const i=new Map;for(const o of l)i.set(o.jobId,o);for(const o of r.recentJobs)i.set(o.jobId,o);const s=Array.from(i.values());return s.sort((o,c)=>new Date(c.createdAt).getTime()-new Date(o.createdAt).getTime()),{recentJobs:s.slice(0,I0),lastUpdated:new Date().toISOString()}}),updateAgent:l=>t(r=>{if(Ox(l)){const i=r.agents.findIndex(s=>s.qualifiedName===l.agent.qualifiedName);if(i>=0){const s=[...r.agents];return s[i]=l.agent,{agents:s,lastUpdated:new Date().toISOString()}}else return{agents:[...r.agents,l.agent],lastUpdated:new Date().toISOString()}}else{const i=r.agents.findIndex(s=>s.qualifiedName===l.agentName);if(i>=0){const s=[...r.agents];return s[i]={...s[i],status:"idle",currentJobId:null},{agents:s,lastUpdated:new Date().toISOString()}}return r}}),addJob:l=>t(r=>({recentJobs:[{jobId:l.jobId,agentName:l.agentName,prompt:l.prompt,status:"running",createdAt:new Date().toISOString(),startedAt:new Date().toISOString()},...r.recentJobs].slice(0,I0),lastUpdated:new Date().toISOString()})),completeJob:l=>t(r=>{const i=r.recentJobs.findIndex(s=>s.jobId===l.jobId);if(i>=0){const s=[...r.recentJobs];return s[i]={...s[i],status:"completed",exitCode:l.exitCode,completedAt:new Date().toISOString()},{recentJobs:s,lastUpdated:new Date().toISOString()}}return r}),failJob:l=>t(r=>{const i=r.recentJobs.findIndex(s=>s.jobId===l.jobId);if(i>=0){const s=[...r.recentJobs];return s[i]={...s[i],status:"failed",error:l.error,completedAt:new Date().toISOString()},{recentJobs:s,lastUpdated:new Date().toISOString()}}return r}),cancelJob:l=>t(r=>{const i=r.recentJobs.findIndex(s=>s.jobId===l.jobId);if(i>=0){const s=[...r.recentJobs];return s[i]={...s[i],status:"cancelled",error:l.reason,completedAt:new Date().toISOString()},{recentJobs:s,lastUpdated:new Date().toISOString()}}return r}),setConnectionStatus:l=>t({connectionStatus:l,lastUpdated:new Date().toISOString()})}),Np="herd-theme";function is(){if(typeof window>"u")return"system";const t=localStorage.getItem(Np);return t==="light"||t==="dark"||t==="system"?t:"system"}function Hx(t){const l=t??is();return l==="system"?typeof window>"u"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":l}function jp(t){if(typeof window>"u")return;const l=Hx(t);document.documentElement.classList.toggle("dark",l==="dark")}function Bx(t){typeof window>"u"||(localStorage.setItem(Np,t),jp(t))}function Zx(){const t=is();jp(t);const l=window.matchMedia("(prefers-color-scheme: dark)");function r(i){is()==="system"&&document.documentElement.classList.toggle("dark",i.matches)}return l.addEventListener("change",r),()=>{l.removeEventListener("change",r)}}const qx={sidebarCollapsed:!1,sidebarMobileOpen:!1,selectedAgent:null,activeView:"dashboard",theme:is(),rightPanelOpen:!1},$x=t=>({...qx,toggleSidebar:()=>t(l=>({sidebarCollapsed:!l.sidebarCollapsed})),setSidebarCollapsed:l=>t({sidebarCollapsed:l}),toggleSidebarMobile:()=>t(l=>({sidebarMobileOpen:!l.sidebarMobileOpen})),setSidebarMobileOpen:l=>t({sidebarMobileOpen:l}),selectAgent:l=>t({selectedAgent:l,rightPanelOpen:l!==null}),setActiveView:l=>t({activeView:l}),setTheme:l=>(Bx(l),t({theme:l})),toggleRightPanel:()=>t(l=>({rightPanelOpen:!l.rightPanelOpen})),setRightPanelOpen:l=>t({rightPanelOpen:l})}),J0=1e3,Vx={outputsByJob:{},activeJobViews:new Set,_messageCounter:0},Ix=t=>({...Vx,appendOutput:(l,r,i,s)=>t(o=>{const c=o._messageCounter+1,d={id:`msg-${c}`,jobId:l,agentName:r,data:i,stream:s,timestamp:Date.now()};let p=[...o.outputsByJob[l]??[],d];return p.length>J0&&(p=p.slice(p.length-J0)),{outputsByJob:{...o.outputsByJob,[l]:p},_messageCounter:c}}),clearJobOutput:l=>t(r=>{const{[l]:i,...s}=r.outputsByJob;return{outputsByJob:s}}),setActiveJobView:(l,r)=>t(i=>{const s=new Set(i.activeJobViews);return r?s.add(l):s.delete(l),{activeJobViews:s}}),clearAllOutput:()=>t({outputsByJob:{},activeJobViews:new Set,_messageCounter:0})});let Qf=typeof window<"u"?window.location.origin:"";class Jx extends Error{constructor(l,r,i,s){super(l),this.status=r,this.statusText=i,this.url=s,this.name="ApiError"}}async function Kf(t){if(!t.ok){let l=`HTTP ${t.status}: ${t.statusText}`;try{const r=await t.json();r.error?l=r.error:r.message&&(l=r.message)}catch{}throw new Jx(l,t.status,t.statusText,t.url)}return t.json()}async function Ll(t,l){const r=new URL(`${Qf}${t}`);if(l)for(const[s,o]of Object.entries(l))o!==void 0&&r.searchParams.set(s,String(o));const i=await fetch(r.toString(),{method:"GET",headers:{Accept:"application/json"}});return Kf(i)}async function oa(t,l){const r=await fetch(`${Qf}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(l)});return Kf(r)}async function Fx(t){const l=await fetch(`${Qf}${t}`,{method:"DELETE",headers:{Accept:"application/json"}});return Kf(l)}async function Ap(){return Ll("/api/fleet/status")}async function zp(){return Ll("/api/agents")}async function Yx(t){return Ll(`/api/agents/${encodeURIComponent(t)}`)}async function Tp(t){return Ll("/api/jobs",t)}async function Gx(t){return Ll(`/api/jobs/${encodeURIComponent(t)}`)}async function Xx(t){return oa(`/api/jobs/${encodeURIComponent(t)}/cancel`,{})}async function Qx(t,l){return oa(`/api/jobs/${encodeURIComponent(t)}/fork`,l??{})}async function Kx(){return Ll("/api/schedules")}async function _p(t,l){return oa(`/api/agents/${encodeURIComponent(t)}/trigger`,l??{})}async function Px(t,l){return oa(`/api/schedules/${encodeURIComponent(t)}/${encodeURIComponent(l)}/enable`,{})}async function Wx(t,l){return oa(`/api/schedules/${encodeURIComponent(t)}/${encodeURIComponent(l)}/disable`,{})}async function e6(t){return oa(`/api/chat/${encodeURIComponent(t)}/sessions`,{})}async function F0(t){return Ll(`/api/chat/${encodeURIComponent(t)}/sessions`)}async function t6(t,l){return Ll(`/api/chat/${encodeURIComponent(t)}/sessions/${encodeURIComponent(l)}`)}async function n6(t,l){await Fx(`/api/chat/${encodeURIComponent(t)}/sessions/${encodeURIComponent(l)}`)}const l6=20,Y0={jobs:[],totalJobs:0,jobsLoading:!1,jobsError:null,jobsFilter:{},jobsOffset:0,jobsLimit:l6,selectedJobId:null,selectedJob:null,selectedJobLoading:!1},r6=(t,l)=>({...Y0,fetchJobs:async()=>{const{jobsFilter:r,jobsOffset:i,jobsLimit:s}=l();t({jobsLoading:!0,jobsError:null});try{const o=await Tp({limit:s,offset:i,agentName:r.agentName,status:r.status});t({jobs:o.jobs,totalJobs:o.total,jobsLoading:!1})}catch(o){const c=o instanceof Error?o.message:"Failed to fetch jobs";t({jobsLoading:!1,jobsError:c})}},fetchJobDetail:async r=>{t({selectedJobLoading:!0});try{const i=await Gx(r);t({selectedJob:i,selectedJobId:r,selectedJobLoading:!1})}catch{t({selectedJob:null,selectedJobId:r,selectedJobLoading:!1})}},setJobsFilter:r=>{const i=l().jobsFilter;t({jobsFilter:{...i,...r},jobsOffset:0})},setJobsOffset:r=>{t({jobsOffset:r})},selectJob:r=>{r===null?t({selectedJobId:null,selectedJob:null,selectedJobLoading:!1}):(t({selectedJobId:r}),l().fetchJobDetail(r).catch(()=>{}))},clearJobsState:()=>{t(Y0)}}),G0=5,X0={chatSessions:[],chatSessionsLoading:!1,chatMessages:[],chatMessagesLoading:!1,activeChatSessionId:null,chatStreaming:!1,chatStreamingContent:"",chatError:null,sidebarSessions:{},sidebarSessionsLoading:!1},a6=(t,l)=>({...X0,fetchChatSessions:async r=>{t({chatSessionsLoading:!0,chatError:null});try{const i=await F0(r);t({chatSessions:i.sessions,chatSessionsLoading:!1})}catch(i){const s=i instanceof Error?i.message:"Failed to fetch chat sessions";t({chatSessionsLoading:!1,chatError:s})}},fetchChatMessages:async(r,i)=>{t({chatMessagesLoading:!0,chatError:null});try{const s=await t6(r,i);t({chatMessages:s.messages,chatMessagesLoading:!1,activeChatSessionId:i})}catch(s){const o=s instanceof Error?s.message:"Failed to fetch chat messages";t({chatMessagesLoading:!1,chatError:o})}},createChatSession:async r=>{t({chatError:null});try{const i=await e6(r),s={sessionId:i.sessionId,createdAt:i.createdAt,lastMessageAt:i.createdAt,messageCount:0,preview:""};return t(o=>{const c=[s,...o.chatSessions],d=o.sidebarSessions[r]??[],m=[s,...d].slice(0,G0);return{chatSessions:c,activeChatSessionId:i.sessionId,chatMessages:[],sidebarSessions:{...o.sidebarSessions,[r]:m}}}),i.sessionId}catch(i){const s=i instanceof Error?i.message:"Failed to create chat session";return t({chatError:s}),null}},deleteChatSession:async(r,i)=>{t({chatError:null});try{await n6(r,i);const{activeChatSessionId:s}=l();t(o=>{const c=o.sidebarSessions[r],d=c?{...o.sidebarSessions,[r]:c.filter(m=>m.sessionId!==i)}:o.sidebarSessions;return{chatSessions:o.chatSessions.filter(m=>m.sessionId!==i),activeChatSessionId:s===i?null:s,chatMessages:s===i?[]:o.chatMessages,sidebarSessions:d}})}catch(s){const o=s instanceof Error?s.message:"Failed to delete chat session";t({chatError:o})}},setActiveChatSession:r=>{t({activeChatSessionId:r,chatMessages:r===null?[]:l().chatMessages,chatStreaming:!1,chatStreamingContent:""})},appendStreamingChunk:r=>{t(i=>({chatStreaming:!0,chatStreamingContent:i.chatStreamingContent+r}))},completeStreaming:()=>{const{chatStreamingContent:r}=l();if(r){const i={role:"assistant",content:r,timestamp:new Date().toISOString()};t(s=>({chatMessages:[...s.chatMessages,i],chatStreaming:!1,chatStreamingContent:""}))}else t({chatStreaming:!1,chatStreamingContent:""})},addUserMessage:r=>{const i={role:"user",content:r,timestamp:new Date().toISOString()};t(s=>({chatMessages:[...s.chatMessages,i],chatStreaming:!0,chatStreamingContent:""}))},addToolCallMessage:r=>{const{chatStreamingContent:i}=l(),s=[];i&&s.push({role:"assistant",content:i,timestamp:new Date().toISOString()}),s.push({role:"tool",content:r.output,timestamp:new Date().toISOString(),toolCall:r}),t(o=>({chatMessages:[...o.chatMessages,...s],chatStreamingContent:""}))},setChatError:r=>{t({chatError:r,chatStreaming:!1,chatStreamingContent:""})},fetchSidebarSessions:async r=>{t({sidebarSessionsLoading:!0});try{const i=await Promise.all(r.map(o=>F0(o).then(c=>({name:o,sessions:c.sessions.slice(0,G0)})).catch(()=>({name:o,sessions:[]})))),s={};for(const{name:o,sessions:c}of i)s[o]=c;t({sidebarSessions:s,sidebarSessionsLoading:!1})}catch{t({sidebarSessionsLoading:!1})}},clearActiveChatState:()=>{t({chatSessions:[],chatSessionsLoading:!1,chatMessages:[],chatMessagesLoading:!1,activeChatSessionId:null,chatStreaming:!1,chatStreamingContent:"",chatError:null})},clearChatState:()=>{t(X0)}}),Q0={schedules:[],schedulesLoading:!1,schedulesError:null},i6=(t,l)=>({...Q0,fetchSchedules:async()=>{t({schedulesLoading:!0,schedulesError:null});try{const r=await Kx();t({schedules:r,schedulesLoading:!1})}catch(r){const i=r instanceof Error?r.message:"Failed to fetch schedules";t({schedulesLoading:!1,schedulesError:i})}},triggerSchedule:async(r,i)=>{t({schedulesError:null});try{await _p(r,{scheduleName:i}),await l().fetchSchedules()}catch(s){const o=s instanceof Error?s.message:"Failed to trigger schedule";t({schedulesError:o})}},enableSchedule:async(r,i)=>{t({schedulesError:null});try{const s=await Px(r,i);t(o=>({schedules:o.schedules.map(c=>c.agentName===r&&c.name===i?s:c)}))}catch(s){const o=s instanceof Error?s.message:"Failed to enable schedule";t({schedulesError:o})}},disableSchedule:async(r,i)=>{t({schedulesError:null});try{const s=await Wx(r,i);t(o=>({schedules:o.schedules.map(c=>c.agentName===r&&c.name===i?s:c)}))}catch(s){const o=s instanceof Error?s.message:"Failed to disable schedule";t({schedulesError:o})}},updateScheduleFromWS:()=>{l().fetchSchedules().catch(()=>{})},clearSchedulesState:()=>{t(Q0)}});let K0=0;function u6(){return K0+=1,`toast-${K0}-${Date.now()}`}const s6={toasts:[]},o6=t=>({...s6,addToast:l=>{const r=u6(),i=l.duration??3e3;t(s=>({toasts:[...s.toasts,{...l,id:r,duration:i}]})),i>0&&setTimeout(()=>{t(s=>({toasts:s.toasts.filter(o=>o.id!==r)}))},i)},removeToast:l=>t(r=>({toasts:r.toasts.filter(i=>i.id!==l)}))}),Ne=_x()((...t)=>({...Ux(...t),...$x(...t),...Ix(...t),...r6(...t),...a6(...t),...i6(...t),...o6(...t)}));function ys(){return Ne(Vt(t=>({fleetStatus:t.fleetStatus,agents:t.agents,recentJobs:t.recentJobs,connectionStatus:t.connectionStatus,lastUpdated:t.lastUpdated})))}function c6(t){return Ne(l=>t?l.agents.find(r=>r.qualifiedName===t)??null:null)}function Rp(){return Ne(Vt(t=>({sidebarCollapsed:t.sidebarCollapsed,sidebarMobileOpen:t.sidebarMobileOpen,selectedAgent:t.selectedAgent,activeView:t.activeView,theme:t.theme,rightPanelOpen:t.rightPanelOpen})))}function Dp(){return Ne(Vt(t=>({toggleSidebar:t.toggleSidebar,setSidebarCollapsed:t.setSidebarCollapsed,toggleSidebarMobile:t.toggleSidebarMobile,setSidebarMobileOpen:t.setSidebarMobileOpen,selectAgent:t.selectAgent,setActiveView:t.setActiveView,setTheme:t.setTheme,toggleRightPanel:t.toggleRightPanel,setRightPanelOpen:t.setRightPanelOpen})))}function f6(){return Ne(Vt(t=>({setFleetStatus:t.setFleetStatus,setAgents:t.setAgents,updateAgent:t.updateAgent,setRecentJobs:t.setRecentJobs,addJob:t.addJob,completeJob:t.completeJob,failJob:t.failJob,cancelJob:t.cancelJob,setConnectionStatus:t.setConnectionStatus})))}const P0=[];function d6(t){return Ne(l=>t?l.outputsByJob[t]??P0:P0)}function h6(){return Ne(Vt(t=>({jobs:t.jobs,totalJobs:t.totalJobs,jobsLoading:t.jobsLoading,jobsError:t.jobsError,jobsFilter:t.jobsFilter,jobsOffset:t.jobsOffset,jobsLimit:t.jobsLimit})))}function Op(){return Ne(Vt(t=>({fetchJobs:t.fetchJobs,fetchJobDetail:t.fetchJobDetail,setJobsFilter:t.setJobsFilter,setJobsOffset:t.setJobsOffset,selectJob:t.selectJob,clearJobsState:t.clearJobsState})))}function m6(){return Ne(Vt(t=>({selectedJobId:t.selectedJobId,selectedJob:t.selectedJob,selectedJobLoading:t.selectedJobLoading})))}function p6(){return Ne(Vt(t=>({chatSessions:t.chatSessions,chatSessionsLoading:t.chatSessionsLoading,chatError:t.chatError})))}function Pf(){return Ne(Vt(t=>({chatMessages:t.chatMessages,chatMessagesLoading:t.chatMessagesLoading,activeChatSessionId:t.activeChatSessionId,chatStreaming:t.chatStreaming,chatStreamingContent:t.chatStreamingContent,chatError:t.chatError})))}function Wf(){return Ne(Vt(t=>({fetchChatSessions:t.fetchChatSessions,fetchChatMessages:t.fetchChatMessages,createChatSession:t.createChatSession,deleteChatSession:t.deleteChatSession,setActiveChatSession:t.setActiveChatSession,appendStreamingChunk:t.appendStreamingChunk,completeStreaming:t.completeStreaming,addUserMessage:t.addUserMessage,setChatError:t.setChatError,fetchSidebarSessions:t.fetchSidebarSessions,clearActiveChatState:t.clearActiveChatState,clearChatState:t.clearChatState})))}function g6(){return Ne(Vt(t=>({sidebarSessions:t.sidebarSessions,sidebarSessionsLoading:t.sidebarSessionsLoading})))}function y6(){return Ne(Vt(t=>({schedules:t.schedules,schedulesLoading:t.schedulesLoading,schedulesError:t.schedulesError})))}function x6(){return Ne(Vt(t=>({fetchSchedules:t.fetchSchedules,triggerSchedule:t.triggerSchedule,enableSchedule:t.enableSchedule,disableSchedule:t.disableSchedule,updateScheduleFromWS:t.updateScheduleFromWS,clearSchedulesState:t.clearSchedulesState})))}function b6(){return Ne(t=>t.toasts)}function v6(){return Ne(Vt(t=>({addToast:t.addToast,removeToast:t.removeToast})))}function S6(){const t=E.useRef(null),l=E.useRef("disconnected"),r=E.useRef(!1),i=Ne(N=>N.setFleetStatus),s=Ne(N=>N.setAgents),o=Ne(N=>N.updateAgent),c=Ne(N=>N.addJob),d=Ne(N=>N.completeJob),m=Ne(N=>N.failJob),p=Ne(N=>N.cancelJob),x=Ne(N=>N.setConnectionStatus),y=Ne(N=>N.connectionStatus),v=Ne(N=>N.appendOutput),S=Ne(N=>N.appendStreamingChunk),C=Ne(N=>N.completeStreaming),T=Ne(N=>N.addToolCallMessage),z=Ne(N=>N.setChatError),M=Ne(N=>N.updateScheduleFromWS),U=Ne(N=>N.addToast);return E.useEffect(()=>{const N=F=>{switch(F.type){case"fleet:status":i(F.payload);break;case"agent:updated":o(F.payload);break;case"job:created":c(F.payload);break;case"job:completed":d(F.payload),U({message:`Job completed for ${F.payload.agentName}`,type:"success"});break;case"job:failed":m(F.payload),U({message:`Job failed for ${F.payload.agentName}`,type:"error",duration:5e3});break;case"job:cancelled":p(F.payload);break;case"schedule:triggered":M(),U({message:`Schedule triggered for ${F.payload.agentName}`,type:"info"});break;case"job:output":{const{jobId:_,agentName:I,data:se,stream:oe}=F.payload;v(_,I,se,oe);break}case"pong":break;case"chat:response":{const{chunk:_}=F.payload;S(_);break}case"chat:complete":{C();break}case"chat:tool_call":{T({toolName:F.payload.toolName,inputSummary:F.payload.inputSummary,output:F.payload.output,isError:F.payload.isError,durationMs:F.payload.durationMs});break}case"chat:error":{z(F.payload.error);break}}},V=F=>{const _=l.current;l.current=F,x(F),F==="connected"&&(_==="disconnected"||_==="reconnecting")&&r.current&&(async()=>{try{const[I,se]=await Promise.all([Ap(),zp()]);i(I),s(se)}catch{}})(),F==="connected"&&(r.current=!0)};return t.current=Mx({onMessage:N,onStatusChange:V}),window.__herdWsClient=t.current,()=>{var F;(F=t.current)==null||F.disconnect(),t.current=null,delete window.__herdWsClient}},[]),{connectionStatus:y,subscribe:N=>{var V;return(V=t.current)==null?void 0:V.subscribe(N)},unsubscribe:N=>{var V;return(V=t.current)==null?void 0:V.unsubscribe(N)},reconnect:()=>{var N;return(N=t.current)==null?void 0:N.reconnect()}}}function Lp(){const[t,l]=E.useState(!0),[r,i]=E.useState(null),[s,o]=E.useState(0),c=Ne(p=>p.setFleetStatus),d=Ne(p=>p.setAgents);return E.useEffect(()=>{let p=!1;async function x(){l(!0),i(null);try{const[y,v]=await Promise.all([Ap(),zp()]);if(p)return;c(y),d(v),l(!1)}catch(y){if(p)return;const v=y instanceof Error?y.message:"Failed to fetch fleet data";i(v),l(!1)}}return x(),()=>{p=!0}},[s]),{loading:t,error:r,retry:()=>{o(p=>p+1)}}}const xs=E.createContext(null);xs.displayName="PanelGroupContext";const rt={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},e1=10,ar=E.useLayoutEffect,W0=$5.useId,w6=typeof W0=="function"?W0:()=>null;let k6=0;function t1(t=null){const l=w6(),r=E.useRef(t||l||null);return r.current===null&&(r.current=""+k6++),t??r.current}function Up({children:t,className:l="",collapsedSize:r,collapsible:i,defaultSize:s,forwardedRef:o,id:c,maxSize:d,minSize:m,onCollapse:p,onExpand:x,onResize:y,order:v,style:S,tagName:C="div",...T}){const z=E.useContext(xs);if(z===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:M,expandPanel:U,getPanelSize:N,getPanelStyle:V,groupId:F,isPanelCollapsed:_,reevaluatePanelConstraints:I,registerPanel:se,resizePanel:oe,unregisterPanel:O}=z,ae=t1(c),te=E.useRef({callbacks:{onCollapse:p,onExpand:x,onResize:y},constraints:{collapsedSize:r,collapsible:i,defaultSize:s,maxSize:d,minSize:m},id:ae,idIsFromProps:c!==void 0,order:v});E.useRef({didLogMissingDefaultSizeWarning:!1}),ar(()=>{const{callbacks:ue,constraints:P}=te.current,H={...P};te.current.id=ae,te.current.idIsFromProps=c!==void 0,te.current.order=v,ue.onCollapse=p,ue.onExpand=x,ue.onResize=y,P.collapsedSize=r,P.collapsible=i,P.defaultSize=s,P.maxSize=d,P.minSize=m,(H.collapsedSize!==P.collapsedSize||H.collapsible!==P.collapsible||H.maxSize!==P.maxSize||H.minSize!==P.minSize)&&I(te.current,H)}),ar(()=>{const ue=te.current;return se(ue),()=>{O(ue)}},[v,ae,se,O]),E.useImperativeHandle(o,()=>({collapse:()=>{M(te.current)},expand:ue=>{U(te.current,ue)},getId(){return ae},getSize(){return N(te.current)},isCollapsed(){return _(te.current)},isExpanded(){return!_(te.current)},resize:ue=>{oe(te.current,ue)}}),[M,U,N,_,ae,oe]);const be=V(te.current,s);return E.createElement(C,{...T,children:t,className:l,id:ae,style:{...be,...S},[rt.groupId]:F,[rt.panel]:"",[rt.panelCollapsible]:i||void 0,[rt.panelId]:ae,[rt.panelSize]:parseFloat(""+be.flexGrow).toFixed(1)})}const ns=E.forwardRef((t,l)=>E.createElement(Up,{...t,forwardedRef:l}));Up.displayName="Panel";ns.displayName="forwardRef(Panel)";let Mf=null,ls=-1,Ol=null;function C6(t,l){if(l){const r=(l&$p)!==0,i=(l&Vp)!==0,s=(l&Ip)!==0,o=(l&Jp)!==0;if(r)return s?"se-resize":o?"ne-resize":"e-resize";if(i)return s?"sw-resize":o?"nw-resize":"w-resize";if(s)return"s-resize";if(o)return"n-resize"}switch(t){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function E6(){Ol!==null&&(document.head.removeChild(Ol),Mf=null,Ol=null,ls=-1)}function Pc(t,l){var r,i;const s=C6(t,l);if(Mf!==s){if(Mf=s,Ol===null&&(Ol=document.createElement("style"),document.head.appendChild(Ol)),ls>=0){var o;(o=Ol.sheet)===null||o===void 0||o.removeRule(ls)}ls=(r=(i=Ol.sheet)===null||i===void 0?void 0:i.insertRule(`*{cursor: ${s} !important;}`))!==null&&r!==void 0?r:-1}}function Hp(t){return t.type==="keydown"}function Bp(t){return t.type.startsWith("pointer")}function Zp(t){return t.type.startsWith("mouse")}function bs(t){if(Bp(t)){if(t.isPrimary)return{x:t.clientX,y:t.clientY}}else if(Zp(t))return{x:t.clientX,y:t.clientY};return{x:1/0,y:1/0}}function M6(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function N6(t,l,r){return t.x<l.x+l.width&&t.x+t.width>l.x&&t.y<l.y+l.height&&t.y+t.height>l.y}function j6(t,l){if(t===l)throw new Error("Cannot compare node with itself");const r={a:nm(t),b:nm(l)};let i;for(;r.a.at(-1)===r.b.at(-1);)t=r.a.pop(),l=r.b.pop(),i=t;Me(i,"Stacking order can only be calculated for elements with a common ancestor");const s={a:tm(em(r.a)),b:tm(em(r.b))};if(s.a===s.b){const o=i.childNodes,c={a:r.a.at(-1),b:r.b.at(-1)};let d=o.length;for(;d--;){const m=o[d];if(m===c.a)return 1;if(m===c.b)return-1}}return Math.sign(s.a-s.b)}const A6=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function z6(t){var l;const r=getComputedStyle((l=qp(t))!==null&&l!==void 0?l:t).display;return r==="flex"||r==="inline-flex"}function T6(t){const l=getComputedStyle(t);return!!(l.position==="fixed"||l.zIndex!=="auto"&&(l.position!=="static"||z6(t))||+l.opacity<1||"transform"in l&&l.transform!=="none"||"webkitTransform"in l&&l.webkitTransform!=="none"||"mixBlendMode"in l&&l.mixBlendMode!=="normal"||"filter"in l&&l.filter!=="none"||"webkitFilter"in l&&l.webkitFilter!=="none"||"isolation"in l&&l.isolation==="isolate"||A6.test(l.willChange)||l.webkitOverflowScrolling==="touch")}function em(t){let l=t.length;for(;l--;){const r=t[l];if(Me(r,"Missing node"),T6(r))return r}return null}function tm(t){return t&&Number(getComputedStyle(t).zIndex)||0}function nm(t){const l=[];for(;t;)l.push(t),t=qp(t);return l}function qp(t){const{parentNode:l}=t;return l&&l instanceof ShadowRoot?l.host:l}const $p=1,Vp=2,Ip=4,Jp=8,_6=M6()==="coarse";let kn=[],ra=!1,rr=new Map,vs=new Map;const bi=new Set;function R6(t,l,r,i,s){var o;const{ownerDocument:c}=l,d={direction:r,element:l,hitAreaMargins:i,setResizeHandlerState:s},m=(o=rr.get(c))!==null&&o!==void 0?o:0;return rr.set(c,m+1),bi.add(d),us(),function(){var x;vs.delete(t),bi.delete(d);const y=(x=rr.get(c))!==null&&x!==void 0?x:1;if(rr.set(c,y-1),us(),y===1&&rr.delete(c),kn.includes(d)){const v=kn.indexOf(d);v>=0&&kn.splice(v,1),l1(),s("up",!0,null)}}}function D6(t){const{target:l}=t,{x:r,y:i}=bs(t);ra=!0,n1({target:l,x:r,y:i}),us(),kn.length>0&&(ss("down",t),t.preventDefault(),Fp(l)||t.stopImmediatePropagation())}function Wc(t){const{x:l,y:r}=bs(t);if(ra&&t.buttons===0&&(ra=!1,ss("up",t)),!ra){const{target:i}=t;n1({target:i,x:l,y:r})}ss("move",t),l1(),kn.length>0&&t.preventDefault()}function ef(t){const{target:l}=t,{x:r,y:i}=bs(t);vs.clear(),ra=!1,kn.length>0&&(t.preventDefault(),Fp(l)||t.stopImmediatePropagation()),ss("up",t),n1({target:l,x:r,y:i}),l1(),us()}function Fp(t){let l=t;for(;l;){if(l.hasAttribute(rt.resizeHandle))return!0;l=l.parentElement}return!1}function n1({target:t,x:l,y:r}){kn.splice(0);let i=null;(t instanceof HTMLElement||t instanceof SVGElement)&&(i=t),bi.forEach(s=>{const{element:o,hitAreaMargins:c}=s,d=o.getBoundingClientRect(),{bottom:m,left:p,right:x,top:y}=d,v=_6?c.coarse:c.fine;if(l>=p-v&&l<=x+v&&r>=y-v&&r<=m+v){if(i!==null&&document.contains(i)&&o!==i&&!o.contains(i)&&!i.contains(o)&&j6(i,o)>0){let C=i,T=!1;for(;C&&!C.contains(o);){if(N6(C.getBoundingClientRect(),d)){T=!0;break}C=C.parentElement}if(T)return}kn.push(s)}})}function tf(t,l){vs.set(t,l)}function l1(){let t=!1,l=!1;kn.forEach(i=>{const{direction:s}=i;s==="horizontal"?t=!0:l=!0});let r=0;vs.forEach(i=>{r|=i}),t&&l?Pc("intersection",r):t?Pc("horizontal",r):l?Pc("vertical",r):E6()}let nf=new AbortController;function us(){nf.abort(),nf=new AbortController;const t={capture:!0,signal:nf.signal};bi.size&&(ra?(kn.length>0&&rr.forEach((l,r)=>{const{body:i}=r;l>0&&(i.addEventListener("contextmenu",ef,t),i.addEventListener("pointerleave",Wc,t),i.addEventListener("pointermove",Wc,t))}),window.addEventListener("pointerup",ef,t),window.addEventListener("pointercancel",ef,t)):rr.forEach((l,r)=>{const{body:i}=r;l>0&&(i.addEventListener("pointerdown",D6,t),i.addEventListener("pointermove",Wc,t))}))}function ss(t,l){bi.forEach(r=>{const{setResizeHandlerState:i}=r,s=kn.includes(r);i(t,s,l)})}function O6(){const[t,l]=E.useState(0);return E.useCallback(()=>l(r=>r+1),[])}function Me(t,l){if(!t)throw console.error(l),Error(l)}function ir(t,l,r=e1){return t.toFixed(r)===l.toFixed(r)?0:t>l?1:-1}function Wn(t,l,r=e1){return ir(t,l,r)===0}function en(t,l,r){return ir(t,l,r)===0}function L6(t,l,r){if(t.length!==l.length)return!1;for(let i=0;i<t.length;i++){const s=t[i],o=l[i];if(!en(s,o,r))return!1}return!0}function la({panelConstraints:t,panelIndex:l,size:r}){const i=t[l];Me(i!=null,`Panel constraints not found for index ${l}`);let{collapsedSize:s=0,collapsible:o,maxSize:c=100,minSize:d=0}=i;if(ir(r,d)<0)if(o){const m=(s+d)/2;ir(r,m)<0?r=s:r=d}else r=d;return r=Math.min(c,r),r=parseFloat(r.toFixed(e1)),r}function hi({delta:t,initialLayout:l,panelConstraints:r,pivotIndices:i,prevLayout:s,trigger:o}){if(en(t,0))return l;const c=[...l],[d,m]=i;Me(d!=null,"Invalid first pivot index"),Me(m!=null,"Invalid second pivot index");let p=0;if(o==="keyboard"){{const y=t<0?m:d,v=r[y];Me(v,`Panel constraints not found for index ${y}`);const{collapsedSize:S=0,collapsible:C,minSize:T=0}=v;if(C){const z=l[y];if(Me(z!=null,`Previous layout not found for panel index ${y}`),en(z,S)){const M=T-z;ir(M,Math.abs(t))>0&&(t=t<0?0-M:M)}}}{const y=t<0?d:m,v=r[y];Me(v,`No panel constraints found for index ${y}`);const{collapsedSize:S=0,collapsible:C,minSize:T=0}=v;if(C){const z=l[y];if(Me(z!=null,`Previous layout not found for panel index ${y}`),en(z,T)){const M=z-S;ir(M,Math.abs(t))>0&&(t=t<0?0-M:M)}}}}{const y=t<0?1:-1;let v=t<0?m:d,S=0;for(;;){const T=l[v];Me(T!=null,`Previous layout not found for panel index ${v}`);const M=la({panelConstraints:r,panelIndex:v,size:100})-T;if(S+=M,v+=y,v<0||v>=r.length)break}const C=Math.min(Math.abs(t),Math.abs(S));t=t<0?0-C:C}{let v=t<0?d:m;for(;v>=0&&v<r.length;){const S=Math.abs(t)-Math.abs(p),C=l[v];Me(C!=null,`Previous layout not found for panel index ${v}`);const T=C-S,z=la({panelConstraints:r,panelIndex:v,size:T});if(!en(C,z)&&(p+=C-z,c[v]=z,p.toPrecision(3).localeCompare(Math.abs(t).toPrecision(3),void 0,{numeric:!0})>=0))break;t<0?v--:v++}}if(L6(s,c))return s;{const y=t<0?m:d,v=l[y];Me(v!=null,`Previous layout not found for panel index ${y}`);const S=v+p,C=la({panelConstraints:r,panelIndex:y,size:S});if(c[y]=C,!en(C,S)){let T=S-C,M=t<0?m:d;for(;M>=0&&M<r.length;){const U=c[M];Me(U!=null,`Previous layout not found for panel index ${M}`);const N=U+T,V=la({panelConstraints:r,panelIndex:M,size:N});if(en(U,V)||(T-=V-U,c[M]=V),en(T,0))break;t>0?M--:M++}}}const x=c.reduce((y,v)=>v+y,0);return en(x,100)?c:s}function U6({layout:t,panelsArray:l,pivotIndices:r}){let i=0,s=100,o=0,c=0;const d=r[0];Me(d!=null,"No pivot index found"),l.forEach((y,v)=>{const{constraints:S}=y,{maxSize:C=100,minSize:T=0}=S;v===d?(i=T,s=C):(o+=T,c+=C)});const m=Math.min(s,100-o),p=Math.max(i,100-c),x=t[d];return{valueMax:m,valueMin:p,valueNow:x}}function vi(t,l=document){return Array.from(l.querySelectorAll(`[${rt.resizeHandleId}][data-panel-group-id="${t}"]`))}function Yp(t,l,r=document){const s=vi(t,r).findIndex(o=>o.getAttribute(rt.resizeHandleId)===l);return s??null}function Gp(t,l,r){const i=Yp(t,l,r);return i!=null?[i,i+1]:[-1,-1]}function Xp(t,l=document){var r;if(l instanceof HTMLElement&&(l==null||(r=l.dataset)===null||r===void 0?void 0:r.panelGroupId)==t)return l;const i=l.querySelector(`[data-panel-group][data-panel-group-id="${t}"]`);return i||null}function Ss(t,l=document){const r=l.querySelector(`[${rt.resizeHandleId}="${t}"]`);return r||null}function H6(t,l,r,i=document){var s,o,c,d;const m=Ss(l,i),p=vi(t,i),x=m?p.indexOf(m):-1,y=(s=(o=r[x])===null||o===void 0?void 0:o.id)!==null&&s!==void 0?s:null,v=(c=(d=r[x+1])===null||d===void 0?void 0:d.id)!==null&&c!==void 0?c:null;return[y,v]}function B6({committedValuesRef:t,eagerValuesRef:l,groupId:r,layout:i,panelDataArray:s,panelGroupElement:o,setLayout:c}){E.useRef({didWarnAboutMissingResizeHandle:!1}),ar(()=>{if(!o)return;const d=vi(r,o);for(let m=0;m<s.length-1;m++){const{valueMax:p,valueMin:x,valueNow:y}=U6({layout:i,panelsArray:s,pivotIndices:[m,m+1]}),v=d[m];if(v!=null){const S=s[m];Me(S,`No panel data found for index "${m}"`),v.setAttribute("aria-controls",S.id),v.setAttribute("aria-valuemax",""+Math.round(p)),v.setAttribute("aria-valuemin",""+Math.round(x)),v.setAttribute("aria-valuenow",y!=null?""+Math.round(y):"")}}return()=>{d.forEach((m,p)=>{m.removeAttribute("aria-controls"),m.removeAttribute("aria-valuemax"),m.removeAttribute("aria-valuemin"),m.removeAttribute("aria-valuenow")})}},[r,i,s,o]),E.useEffect(()=>{if(!o)return;const d=l.current;Me(d,"Eager values not found");const{panelDataArray:m}=d,p=Xp(r,o);Me(p!=null,`No group found for id "${r}"`);const x=vi(r,o);Me(x,`No resize handles found for group id "${r}"`);const y=x.map(v=>{const S=v.getAttribute(rt.resizeHandleId);Me(S,"Resize handle element has no handle id attribute");const[C,T]=H6(r,S,m,o);if(C==null||T==null)return()=>{};const z=M=>{if(!M.defaultPrevented)switch(M.key){case"Enter":{M.preventDefault();const U=m.findIndex(N=>N.id===C);if(U>=0){const N=m[U];Me(N,`No panel data found for index ${U}`);const V=i[U],{collapsedSize:F=0,collapsible:_,minSize:I=0}=N.constraints;if(V!=null&&_){const se=hi({delta:en(V,F)?I-F:F-V,initialLayout:i,panelConstraints:m.map(oe=>oe.constraints),pivotIndices:Gp(r,S,o),prevLayout:i,trigger:"keyboard"});i!==se&&c(se)}}break}}};return v.addEventListener("keydown",z),()=>{v.removeEventListener("keydown",z)}});return()=>{y.forEach(v=>v())}},[o,t,l,r,i,s,c])}function lm(t,l){if(t.length!==l.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==l[r])return!1;return!0}function Qp(t,l){const r=t==="horizontal",{x:i,y:s}=bs(l);return r?i:s}function Z6(t,l,r,i,s){const o=r==="horizontal",c=Ss(l,s);Me(c,`No resize handle element found for id "${l}"`);const d=c.getAttribute(rt.groupId);Me(d,"Resize handle element has no group id attribute");let{initialCursorPosition:m}=i;const p=Qp(r,t),x=Xp(d,s);Me(x,`No group element found for id "${d}"`);const y=x.getBoundingClientRect(),v=o?y.width:y.height;return(p-m)/v*100}function q6(t,l,r,i,s,o){if(Hp(t)){const c=r==="horizontal";let d=0;t.shiftKey?d=100:s!=null?d=s:d=10;let m=0;switch(t.key){case"ArrowDown":m=c?0:d;break;case"ArrowLeft":m=c?-d:0;break;case"ArrowRight":m=c?d:0;break;case"ArrowUp":m=c?0:-d;break;case"End":m=100;break;case"Home":m=-100;break}return m}else return i==null?0:Z6(t,l,r,i,o)}function $6({panelDataArray:t}){const l=Array(t.length),r=t.map(o=>o.constraints);let i=0,s=100;for(let o=0;o<t.length;o++){const c=r[o];Me(c,`Panel constraints not found for index ${o}`);const{defaultSize:d}=c;d!=null&&(i++,l[o]=d,s-=d)}for(let o=0;o<t.length;o++){const c=r[o];Me(c,`Panel constraints not found for index ${o}`);const{defaultSize:d}=c;if(d!=null)continue;const m=t.length-i,p=s/m;i++,l[o]=p,s-=p}return l}function Xr(t,l,r){l.forEach((i,s)=>{const o=t[s];Me(o,`Panel data not found for index ${s}`);const{callbacks:c,constraints:d,id:m}=o,{collapsedSize:p=0,collapsible:x}=d,y=r[m];if(y==null||i!==y){r[m]=i;const{onCollapse:v,onExpand:S,onResize:C}=c;C&&C(i,y),x&&(v||S)&&(S&&(y==null||Wn(y,p))&&!Wn(i,p)&&S(),v&&(y==null||!Wn(y,p))&&Wn(i,p)&&v())}})}function Gu(t,l){if(t.length!==l.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!=l[r])return!1;return!0}function V6({defaultSize:t,dragState:l,layout:r,panelData:i,panelIndex:s,precision:o=3}){const c=r[s];let d;return c==null?d=t!=null?t.toPrecision(o):"1":i.length===1?d="1":d=c.toPrecision(o),{flexBasis:0,flexGrow:d,flexShrink:1,overflow:"hidden",pointerEvents:l!==null?"none":void 0}}function I6(t,l=10){let r=null;return(...s)=>{r!==null&&clearTimeout(r),r=setTimeout(()=>{t(...s)},l)}}function rm(t){try{if(typeof localStorage<"u")t.getItem=l=>localStorage.getItem(l),t.setItem=(l,r)=>{localStorage.setItem(l,r)};else throw new Error("localStorage not supported in this environment")}catch(l){console.error(l),t.getItem=()=>null,t.setItem=()=>{}}}function Kp(t){return`react-resizable-panels:${t}`}function Pp(t){return t.map(l=>{const{constraints:r,id:i,idIsFromProps:s,order:o}=l;return s?i:o?`${o}:${JSON.stringify(r)}`:JSON.stringify(r)}).sort((l,r)=>l.localeCompare(r)).join(",")}function Wp(t,l){try{const r=Kp(t),i=l.getItem(r);if(i){const s=JSON.parse(i);if(typeof s=="object"&&s!=null)return s}}catch{}return null}function J6(t,l,r){var i,s;const o=(i=Wp(t,r))!==null&&i!==void 0?i:{},c=Pp(l);return(s=o[c])!==null&&s!==void 0?s:null}function F6(t,l,r,i,s){var o;const c=Kp(t),d=Pp(l),m=(o=Wp(t,s))!==null&&o!==void 0?o:{};m[d]={expandToSizes:Object.fromEntries(r.entries()),layout:i};try{s.setItem(c,JSON.stringify(m))}catch(p){console.error(p)}}function am({layout:t,panelConstraints:l}){const r=[...t],i=r.reduce((o,c)=>o+c,0);if(r.length!==l.length)throw Error(`Invalid ${l.length} panel layout: ${r.map(o=>`${o}%`).join(", ")}`);if(!en(i,100)&&r.length>0)for(let o=0;o<l.length;o++){const c=r[o];Me(c!=null,`No layout data found for index ${o}`);const d=100/i*c;r[o]=d}let s=0;for(let o=0;o<l.length;o++){const c=r[o];Me(c!=null,`No layout data found for index ${o}`);const d=la({panelConstraints:l,panelIndex:o,size:c});c!=d&&(s+=c-d,r[o]=d)}if(!en(s,0))for(let o=0;o<l.length;o++){const c=r[o];Me(c!=null,`No layout data found for index ${o}`);const d=c+s,m=la({panelConstraints:l,panelIndex:o,size:d});if(c!==m&&(s-=m-c,r[o]=m,en(s,0)))break}return r}const Y6=100,mi={getItem:t=>(rm(mi),mi.getItem(t)),setItem:(t,l)=>{rm(mi),mi.setItem(t,l)}},im={};function e3({autoSaveId:t=null,children:l,className:r="",direction:i,forwardedRef:s,id:o=null,onLayout:c=null,keyboardResizeBy:d=null,storage:m=mi,style:p,tagName:x="div",...y}){const v=t1(o),S=E.useRef(null),[C,T]=E.useState(null),[z,M]=E.useState([]),U=O6(),N=E.useRef({}),V=E.useRef(new Map),F=E.useRef(0),_=E.useRef({autoSaveId:t,direction:i,dragState:C,id:v,keyboardResizeBy:d,onLayout:c,storage:m}),I=E.useRef({layout:z,panelDataArray:[],panelDataArrayChanged:!1});E.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),E.useImperativeHandle(s,()=>({getId:()=>_.current.id,getLayout:()=>{const{layout:k}=I.current;return k},setLayout:k=>{const{onLayout:Q}=_.current,{layout:re,panelDataArray:ee}=I.current,ne=am({layout:k,panelConstraints:ee.map(fe=>fe.constraints)});lm(re,ne)||(M(ne),I.current.layout=ne,Q&&Q(ne),Xr(ee,ne,N.current))}}),[]),ar(()=>{_.current.autoSaveId=t,_.current.direction=i,_.current.dragState=C,_.current.id=v,_.current.onLayout=c,_.current.storage=m}),B6({committedValuesRef:_,eagerValuesRef:I,groupId:v,layout:z,panelDataArray:I.current.panelDataArray,setLayout:M,panelGroupElement:S.current}),E.useEffect(()=>{const{panelDataArray:k}=I.current;if(t){if(z.length===0||z.length!==k.length)return;let Q=im[t];Q==null&&(Q=I6(F6,Y6),im[t]=Q);const re=[...k],ee=new Map(V.current);Q(t,re,ee,z,m)}},[t,z,m]),E.useEffect(()=>{});const se=E.useCallback(k=>{const{onLayout:Q}=_.current,{layout:re,panelDataArray:ee}=I.current;if(k.constraints.collapsible){const ne=ee.map(st=>st.constraints),{collapsedSize:fe=0,panelSize:me,pivotIndices:Le}=nr(ee,k,re);if(Me(me!=null,`Panel size not found for panel "${k.id}"`),!Wn(me,fe)){V.current.set(k.id,me);const Mt=ea(ee,k)===ee.length-1?me-fe:fe-me,Fe=hi({delta:Mt,initialLayout:re,panelConstraints:ne,pivotIndices:Le,prevLayout:re,trigger:"imperative-api"});Gu(re,Fe)||(M(Fe),I.current.layout=Fe,Q&&Q(Fe),Xr(ee,Fe,N.current))}}},[]),oe=E.useCallback((k,Q)=>{const{onLayout:re}=_.current,{layout:ee,panelDataArray:ne}=I.current;if(k.constraints.collapsible){const fe=ne.map(at=>at.constraints),{collapsedSize:me=0,panelSize:Le=0,minSize:st=0,pivotIndices:Mt}=nr(ne,k,ee),Fe=Q??st;if(Wn(Le,me)){const at=V.current.get(k.id),nn=at!=null&&at>=Fe?at:Fe,al=ea(ne,k)===ne.length-1?Le-nn:nn-Le,mt=hi({delta:al,initialLayout:ee,panelConstraints:fe,pivotIndices:Mt,prevLayout:ee,trigger:"imperative-api"});Gu(ee,mt)||(M(mt),I.current.layout=mt,re&&re(mt),Xr(ne,mt,N.current))}}},[]),O=E.useCallback(k=>{const{layout:Q,panelDataArray:re}=I.current,{panelSize:ee}=nr(re,k,Q);return Me(ee!=null,`Panel size not found for panel "${k.id}"`),ee},[]),ae=E.useCallback((k,Q)=>{const{panelDataArray:re}=I.current,ee=ea(re,k);return V6({defaultSize:Q,dragState:C,layout:z,panelData:re,panelIndex:ee})},[C,z]),te=E.useCallback(k=>{const{layout:Q,panelDataArray:re}=I.current,{collapsedSize:ee=0,collapsible:ne,panelSize:fe}=nr(re,k,Q);return Me(fe!=null,`Panel size not found for panel "${k.id}"`),ne===!0&&Wn(fe,ee)},[]),be=E.useCallback(k=>{const{layout:Q,panelDataArray:re}=I.current,{collapsedSize:ee=0,collapsible:ne,panelSize:fe}=nr(re,k,Q);return Me(fe!=null,`Panel size not found for panel "${k.id}"`),!ne||ir(fe,ee)>0},[]),ue=E.useCallback(k=>{const{panelDataArray:Q}=I.current;Q.push(k),Q.sort((re,ee)=>{const ne=re.order,fe=ee.order;return ne==null&&fe==null?0:ne==null?-1:fe==null?1:ne-fe}),I.current.panelDataArrayChanged=!0,U()},[U]);ar(()=>{if(I.current.panelDataArrayChanged){I.current.panelDataArrayChanged=!1;const{autoSaveId:k,onLayout:Q,storage:re}=_.current,{layout:ee,panelDataArray:ne}=I.current;let fe=null;if(k){const Le=J6(k,ne,re);Le&&(V.current=new Map(Object.entries(Le.expandToSizes)),fe=Le.layout)}fe==null&&(fe=$6({panelDataArray:ne}));const me=am({layout:fe,panelConstraints:ne.map(Le=>Le.constraints)});lm(ee,me)||(M(me),I.current.layout=me,Q&&Q(me),Xr(ne,me,N.current))}}),ar(()=>{const k=I.current;return()=>{k.layout=[]}},[]);const P=E.useCallback(k=>{let Q=!1;const re=S.current;return re&&window.getComputedStyle(re,null).getPropertyValue("direction")==="rtl"&&(Q=!0),function(ne){ne.preventDefault();const fe=S.current;if(!fe)return()=>null;const{direction:me,dragState:Le,id:st,keyboardResizeBy:Mt,onLayout:Fe}=_.current,{layout:at,panelDataArray:nn}=I.current,{initialLayout:gn}=Le??{},al=Gp(st,k,fe);let mt=q6(ne,k,me,Le,Mt,fe);const Rn=me==="horizontal";Rn&&Q&&(mt=-mt);const il=nn.map(ma=>ma.constraints),yn=hi({delta:mt,initialLayout:gn??at,panelConstraints:il,pivotIndices:al,prevLayout:at,trigger:Hp(ne)?"keyboard":"mouse-or-touch"}),cr=!Gu(at,yn);(Bp(ne)||Zp(ne))&&F.current!=mt&&(F.current=mt,!cr&&mt!==0?Rn?tf(k,mt<0?$p:Vp):tf(k,mt<0?Ip:Jp):tf(k,0)),cr&&(M(yn),I.current.layout=yn,Fe&&Fe(yn),Xr(nn,yn,N.current))}},[]),H=E.useCallback((k,Q)=>{const{onLayout:re}=_.current,{layout:ee,panelDataArray:ne}=I.current,fe=ne.map(at=>at.constraints),{panelSize:me,pivotIndices:Le}=nr(ne,k,ee);Me(me!=null,`Panel size not found for panel "${k.id}"`);const Mt=ea(ne,k)===ne.length-1?me-Q:Q-me,Fe=hi({delta:Mt,initialLayout:ee,panelConstraints:fe,pivotIndices:Le,prevLayout:ee,trigger:"imperative-api"});Gu(ee,Fe)||(M(Fe),I.current.layout=Fe,re&&re(Fe),Xr(ne,Fe,N.current))},[]),W=E.useCallback((k,Q)=>{const{layout:re,panelDataArray:ee}=I.current,{collapsedSize:ne=0,collapsible:fe}=Q,{collapsedSize:me=0,collapsible:Le,maxSize:st=100,minSize:Mt=0}=k.constraints,{panelSize:Fe}=nr(ee,k,re);Fe!=null&&(fe&&Le&&Wn(Fe,ne)?Wn(ne,me)||H(k,me):Fe<Mt?H(k,Mt):Fe>st&&H(k,st))},[H]),ce=E.useCallback((k,Q)=>{const{direction:re}=_.current,{layout:ee}=I.current;if(!S.current)return;const ne=Ss(k,S.current);Me(ne,`Drag handle element not found for id "${k}"`);const fe=Qp(re,Q);T({dragHandleId:k,dragHandleRect:ne.getBoundingClientRect(),initialCursorPosition:fe,initialLayout:ee})},[]),Se=E.useCallback(()=>{T(null)},[]),j=E.useCallback(k=>{const{panelDataArray:Q}=I.current,re=ea(Q,k);re>=0&&(Q.splice(re,1),delete N.current[k.id],I.current.panelDataArrayChanged=!0,U())},[U]),R=E.useMemo(()=>({collapsePanel:se,direction:i,dragState:C,expandPanel:oe,getPanelSize:O,getPanelStyle:ae,groupId:v,isPanelCollapsed:te,isPanelExpanded:be,reevaluatePanelConstraints:W,registerPanel:ue,registerResizeHandle:P,resizePanel:H,startDragging:ce,stopDragging:Se,unregisterPanel:j,panelGroupElement:S.current}),[se,C,i,oe,O,ae,v,te,be,W,ue,P,H,ce,Se,j]),J={display:"flex",flexDirection:i==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return E.createElement(xs.Provider,{value:R},E.createElement(x,{...y,children:l,className:r,id:o,ref:S,style:{...J,...p},[rt.group]:"",[rt.groupDirection]:i,[rt.groupId]:v}))}const t3=E.forwardRef((t,l)=>E.createElement(e3,{...t,forwardedRef:l}));e3.displayName="PanelGroup";t3.displayName="forwardRef(PanelGroup)";function ea(t,l){return t.findIndex(r=>r===l||r.id===l.id)}function nr(t,l,r){const i=ea(t,l),o=i===t.length-1?[i-1,i]:[i,i+1],c=r[i];return{...l.constraints,panelSize:c,pivotIndices:o}}function G6({disabled:t,handleId:l,resizeHandler:r,panelGroupElement:i}){E.useEffect(()=>{if(t||r==null||i==null)return;const s=Ss(l,i);if(s==null)return;const o=c=>{if(!c.defaultPrevented)switch(c.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{c.preventDefault(),r(c);break}case"F6":{c.preventDefault();const d=s.getAttribute(rt.groupId);Me(d,`No group element found for id "${d}"`);const m=vi(d,i),p=Yp(d,l,i);Me(p!==null,`No resize element found for id "${l}"`);const x=c.shiftKey?p>0?p-1:m.length-1:p+1<m.length?p+1:0;m[x].focus();break}}};return s.addEventListener("keydown",o),()=>{s.removeEventListener("keydown",o)}},[i,t,l,r])}function Nf({children:t=null,className:l="",disabled:r=!1,hitAreaMargins:i,id:s,onBlur:o,onClick:c,onDragging:d,onFocus:m,onPointerDown:p,onPointerUp:x,style:y={},tabIndex:v=0,tagName:S="div",...C}){var T,z;const M=E.useRef(null),U=E.useRef({onClick:c,onDragging:d,onPointerDown:p,onPointerUp:x});E.useEffect(()=>{U.current.onClick=c,U.current.onDragging=d,U.current.onPointerDown=p,U.current.onPointerUp=x});const N=E.useContext(xs);if(N===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:V,groupId:F,registerResizeHandle:_,startDragging:I,stopDragging:se,panelGroupElement:oe}=N,O=t1(s),[ae,te]=E.useState("inactive"),[be,ue]=E.useState(!1),[P,H]=E.useState(null),W=E.useRef({state:ae});ar(()=>{W.current.state=ae}),E.useEffect(()=>{if(r)H(null);else{const R=_(O);H(()=>R)}},[r,O,_]);const ce=(T=i==null?void 0:i.coarse)!==null&&T!==void 0?T:15,Se=(z=i==null?void 0:i.fine)!==null&&z!==void 0?z:5;E.useEffect(()=>{if(r||P==null)return;const R=M.current;Me(R,"Element ref not attached");let J=!1;return R6(O,R,V,{coarse:ce,fine:Se},(Q,re,ee)=>{if(!re){te("inactive");return}switch(Q){case"down":{te("drag"),J=!1,Me(ee,'Expected event to be defined for "down" action'),I(O,ee);const{onDragging:ne,onPointerDown:fe}=U.current;ne==null||ne(!0),fe==null||fe();break}case"move":{const{state:ne}=W.current;J=!0,ne!=="drag"&&te("hover"),Me(ee,'Expected event to be defined for "move" action'),P(ee);break}case"up":{te("hover"),se();const{onClick:ne,onDragging:fe,onPointerUp:me}=U.current;fe==null||fe(!1),me==null||me(),J||ne==null||ne();break}}})},[ce,V,r,Se,_,O,P,I,se]),G6({disabled:r,handleId:O,resizeHandler:P,panelGroupElement:oe});const j={touchAction:"none",userSelect:"none"};return E.createElement(S,{...C,children:t,className:l,id:s,onBlur:()=>{ue(!1),o==null||o()},onFocus:()=>{ue(!0),m==null||m()},ref:M,role:"separator",style:{...j,...y},tabIndex:v,[rt.groupDirection]:V,[rt.groupId]:F,[rt.resizeHandle]:"",[rt.resizeHandleActive]:ae==="drag"?"pointer":be?"keyboard":void 0,[rt.resizeHandleEnabled]:!r,[rt.resizeHandleId]:O,[rt.resizeHandleState]:ae})}Nf.displayName="PanelResizeHandle";/**
|
|
61
61
|
* @license lucide-react v0.475.0 - ISC
|
|
62
62
|
*
|
|
63
63
|
* This source code is licensed under the ISC license.
|
|
@@ -361,7 +361,7 @@ Please change the parent <Route path="${N}"> to <Route path="${N==="/"?"*":`${N}
|
|
|
361
361
|
`))+1))}const c="#".repeat(s),d=r.enter("headingAtx"),m=r.enter("phrasing");o.move(c+" ");let p=r.containerPhrasing(t,{before:"# ",after:`
|
|
362
362
|
`,...o.current()});return/^[\t ]/.test(p)&&(p=Ci(p.charCodeAt(0))+p.slice(1)),p=p?c+" "+p:c,r.options.closeAtx&&(p+=" "+c),m(),d(),p}l4.peek=CC;function l4(t){return t.value||""}function CC(){return"<"}r4.peek=EC;function r4(t,l,r,i){const s=C1(r),o=s==='"'?"Quote":"Apostrophe",c=r.enter("image");let d=r.enter("label");const m=r.createTracker(i);let p=m.move("![");return p+=m.move(r.safe(t.alt,{before:p,after:"]",...m.current()})),p+=m.move("]("),d(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(d=r.enter("destinationLiteral"),p+=m.move("<"),p+=m.move(r.safe(t.url,{before:p,after:">",...m.current()})),p+=m.move(">")):(d=r.enter("destinationRaw"),p+=m.move(r.safe(t.url,{before:p,after:t.title?" ":")",...m.current()}))),d(),t.title&&(d=r.enter(`title${o}`),p+=m.move(" "+s),p+=m.move(r.safe(t.title,{before:p,after:s,...m.current()})),p+=m.move(s),d()),p+=m.move(")"),c(),p}function EC(){return"!"}a4.peek=MC;function a4(t,l,r,i){const s=t.referenceType,o=r.enter("imageReference");let c=r.enter("label");const d=r.createTracker(i);let m=d.move("![");const p=r.safe(t.alt,{before:m,after:"]",...d.current()});m+=d.move(p+"]["),c();const x=r.stack;r.stack=[],c=r.enter("reference");const y=r.safe(r.associationId(t),{before:m,after:"]",...d.current()});return c(),r.stack=x,o(),s==="full"||!p||p!==y?m+=d.move(y+"]"):s==="shortcut"?m=m.slice(0,-1):m+=d.move("]"),m}function MC(){return"!"}i4.peek=NC;function i4(t,l,r){let i=t.value||"",s="`",o=-1;for(;new RegExp("(^|[^`])"+s+"([^`]|$)").test(i);)s+="`";for(/[^ \r\n]/.test(i)&&(/^[ \r\n]/.test(i)&&/[ \r\n]$/.test(i)||/^`|`$/.test(i))&&(i=" "+i+" ");++o<r.unsafe.length;){const c=r.unsafe[o],d=r.compilePattern(c);let m;if(c.atBreak)for(;m=d.exec(i);){let p=m.index;i.charCodeAt(p)===10&&i.charCodeAt(p-1)===13&&p--,i=i.slice(0,p)+" "+i.slice(m.index+1)}}return s+i+s}function NC(){return"`"}function u4(t,l){const r=p1(t);return!!(!l.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(r===t.url||"mailto:"+r===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}s4.peek=jC;function s4(t,l,r,i){const s=C1(r),o=s==='"'?"Quote":"Apostrophe",c=r.createTracker(i);let d,m;if(u4(t,r)){const x=r.stack;r.stack=[],d=r.enter("autolink");let y=c.move("<");return y+=c.move(r.containerPhrasing(t,{before:y,after:">",...c.current()})),y+=c.move(">"),d(),r.stack=x,y}d=r.enter("link"),m=r.enter("label");let p=c.move("[");return p+=c.move(r.containerPhrasing(t,{before:p,after:"](",...c.current()})),p+=c.move("]("),m(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(m=r.enter("destinationLiteral"),p+=c.move("<"),p+=c.move(r.safe(t.url,{before:p,after:">",...c.current()})),p+=c.move(">")):(m=r.enter("destinationRaw"),p+=c.move(r.safe(t.url,{before:p,after:t.title?" ":")",...c.current()}))),m(),t.title&&(m=r.enter(`title${o}`),p+=c.move(" "+s),p+=c.move(r.safe(t.title,{before:p,after:s,...c.current()})),p+=c.move(s),m()),p+=c.move(")"),d(),p}function jC(t,l,r){return u4(t,r)?"<":"["}o4.peek=AC;function o4(t,l,r,i){const s=t.referenceType,o=r.enter("linkReference");let c=r.enter("label");const d=r.createTracker(i);let m=d.move("[");const p=r.containerPhrasing(t,{before:m,after:"]",...d.current()});m+=d.move(p+"]["),c();const x=r.stack;r.stack=[],c=r.enter("reference");const y=r.safe(r.associationId(t),{before:m,after:"]",...d.current()});return c(),r.stack=x,o(),s==="full"||!p||p!==y?m+=d.move(y+"]"):s==="shortcut"?m=m.slice(0,-1):m+=d.move("]"),m}function AC(){return"["}function E1(t){const l=t.options.bullet||"*";if(l!=="*"&&l!=="+"&&l!=="-")throw new Error("Cannot serialize items with `"+l+"` for `options.bullet`, expected `*`, `+`, or `-`");return l}function zC(t){const l=E1(t),r=t.options.bulletOther;if(!r)return l==="*"?"-":"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(r===l)throw new Error("Expected `bullet` (`"+l+"`) and `bulletOther` (`"+r+"`) to be different");return r}function TC(t){const l=t.options.bulletOrdered||".";if(l!=="."&&l!==")")throw new Error("Cannot serialize items with `"+l+"` for `options.bulletOrdered`, expected `.` or `)`");return l}function c4(t){const l=t.options.rule||"*";if(l!=="*"&&l!=="-"&&l!=="_")throw new Error("Cannot serialize rules with `"+l+"` for `options.rule`, expected `*`, `-`, or `_`");return l}function _C(t,l,r,i){const s=r.enter("list"),o=r.bulletCurrent;let c=t.ordered?TC(r):E1(r);const d=t.ordered?c==="."?")":".":zC(r);let m=l&&r.bulletLastUsed?c===r.bulletLastUsed:!1;if(!t.ordered){const x=t.children?t.children[0]:void 0;if((c==="*"||c==="-")&&x&&(!x.children||!x.children[0])&&r.stack[r.stack.length-1]==="list"&&r.stack[r.stack.length-2]==="listItem"&&r.stack[r.stack.length-3]==="list"&&r.stack[r.stack.length-4]==="listItem"&&r.indexStack[r.indexStack.length-1]===0&&r.indexStack[r.indexStack.length-2]===0&&r.indexStack[r.indexStack.length-3]===0&&(m=!0),c4(r)===c&&x){let y=-1;for(;++y<t.children.length;){const v=t.children[y];if(v&&v.type==="listItem"&&v.children&&v.children[0]&&v.children[0].type==="thematicBreak"){m=!0;break}}}}m&&(c=d),r.bulletCurrent=c;const p=r.containerFlow(t,i);return r.bulletLastUsed=c,r.bulletCurrent=o,s(),p}function RC(t){const l=t.options.listItemIndent||"one";if(l!=="tab"&&l!=="one"&&l!=="mixed")throw new Error("Cannot serialize items with `"+l+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return l}function DC(t,l,r,i){const s=RC(r);let o=r.bulletCurrent||E1(r);l&&l.type==="list"&&l.ordered&&(o=(typeof l.start=="number"&&l.start>-1?l.start:1)+(r.options.incrementListMarker===!1?0:l.children.indexOf(t))+o);let c=o.length+1;(s==="tab"||s==="mixed"&&(l&&l.type==="list"&&l.spread||t.spread))&&(c=Math.ceil(c/4)*4);const d=r.createTracker(i);d.move(o+" ".repeat(c-o.length)),d.shift(c);const m=r.enter("listItem"),p=r.indentLines(r.containerFlow(t,d.current()),x);return m(),p;function x(y,v,S){return v?(S?"":" ".repeat(c))+y:(S?o:o+" ".repeat(c-o.length))+y}}function OC(t,l,r,i){const s=r.enter("paragraph"),o=r.enter("phrasing"),c=r.containerPhrasing(t,i);return o(),s(),c}const LC=Ns(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function UC(t,l,r,i){return(t.children.some(function(c){return LC(c)})?r.containerPhrasing:r.containerFlow).call(r,t,i)}function HC(t){const l=t.options.strong||"*";if(l!=="*"&&l!=="_")throw new Error("Cannot serialize strong with `"+l+"` for `options.strong`, expected `*`, or `_`");return l}f4.peek=BC;function f4(t,l,r,i){const s=HC(r),o=r.enter("strong"),c=r.createTracker(i),d=c.move(s+s);let m=c.move(r.containerPhrasing(t,{after:s,before:d,...c.current()}));const p=m.charCodeAt(0),x=ms(i.before.charCodeAt(i.before.length-1),p,s);x.inside&&(m=Ci(p)+m.slice(1));const y=m.charCodeAt(m.length-1),v=ms(i.after.charCodeAt(0),y,s);v.inside&&(m=m.slice(0,-1)+Ci(y));const S=c.move(s+s);return o(),r.attentionEncodeSurroundingInfo={after:v.outside,before:x.outside},d+m+S}function BC(t,l,r){return r.options.strong||"*"}function ZC(t,l,r,i){return r.safe(t.value,i)}function qC(t){const l=t.options.ruleRepetition||3;if(l<3)throw new Error("Cannot serialize rules with repetition `"+l+"` for `options.ruleRepetition`, expected `3` or more");return l}function $C(t,l,r){const i=(c4(r)+(r.options.ruleSpaces?" ":"")).repeat(qC(r));return r.options.ruleSpaces?i.slice(0,-1):i}const d4={blockquote:fC,break:tp,code:yC,definition:bC,emphasis:n4,hardBreak:tp,heading:kC,html:l4,image:r4,imageReference:a4,inlineCode:i4,link:s4,linkReference:o4,list:_C,listItem:DC,paragraph:OC,root:UC,strong:f4,text:ZC,thematicBreak:$C};function VC(){return{enter:{table:IC,tableData:np,tableHeader:np,tableRow:FC},exit:{codeText:YC,table:JC,tableData:kf,tableHeader:kf,tableRow:kf}}}function IC(t){const l=t._align;this.enter({type:"table",align:l.map(function(r){return r==="none"?null:r}),children:[]},t),this.data.inTable=!0}function JC(t){this.exit(t),this.data.inTable=void 0}function FC(t){this.enter({type:"tableRow",children:[]},t)}function kf(t){this.exit(t)}function np(t){this.enter({type:"tableCell",children:[]},t)}function YC(t){let l=this.resume();this.data.inTable&&(l=l.replace(/\\([\\|])/g,GC));const r=this.stack[this.stack.length-1];r.type,r.value=l,this.exit(t)}function GC(t,l){return l==="|"?l:t}function XC(t){const l=t||{},r=l.tableCellPadding,i=l.tablePipeAlign,s=l.stringLength,o=r?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
363
363
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:v,table:c,tableCell:m,tableRow:d}};function c(S,C,T,z){return p(x(S,T,z),S.align)}function d(S,C,T,z){const M=y(S,T,z),U=p([M]);return U.slice(0,U.indexOf(`
|
|
364
|
-
`))}function m(S,C,T,z){const M=T.enter("tableCell"),U=T.enter("phrasing"),N=T.containerPhrasing(S,{...z,before:o,after:o});return U(),M(),N}function p(S,C){return oC(S,{align:C,alignDelimiters:i,padding:r,stringLength:s})}function x(S,C,T){const z=S.children;let M=-1;const U=[],N=C.enter("table");for(;++M<z.length;)U[M]=y(z[M],C,T);return N(),U}function y(S,C,T){const z=S.children;let M=-1;const U=[],N=C.enter("tableRow");for(;++M<z.length;)U[M]=m(z[M],S,C,T);return N(),U}function v(S,C,T){let z=d4.inlineCode(S,C,T);return T.stack.includes("tableCell")&&(z=z.replace(/\|/g,"\\$&")),z}}function QC(){return{exit:{taskListCheckValueChecked:lp,taskListCheckValueUnchecked:lp,paragraph:PC}}}function KC(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:WC}}}function lp(t){const l=this.stack[this.stack.length-2];l.type,l.checked=t.type==="taskListCheckValueChecked"}function PC(t){const l=this.stack[this.stack.length-2];if(l&&l.type==="listItem"&&typeof l.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const i=r.children[0];if(i&&i.type==="text"){const s=l.children;let o=-1,c;for(;++o<s.length;){const d=s[o];if(d.type==="paragraph"){c=d;break}}c===r&&(i.value=i.value.slice(1),i.value.length===0?r.children.shift():r.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,r.position.start=Object.assign({},i.position.start)))}}this.exit(t)}function WC(t,l,r,i){const s=t.children[0],o=typeof t.checked=="boolean"&&s&&s.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",d=r.createTracker(i);o&&d.move(c);let m=d4.listItem(t,l,r,{...i,...d.current()});return o&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),m;function p(x){return x+c}}function eE(){return[_k(),Wk(),lC(),VC(),QC()]}function tE(t){return{extensions:[Rk(),eC(t),rC(),XC(t),KC()]}}const nE={tokenize:sE,partial:!0},h4={tokenize:oE,partial:!0},m4={tokenize:cE,partial:!0},p4={tokenize:fE,partial:!0},lE={tokenize:dE,partial:!0},g4={name:"wwwAutolink",tokenize:iE,previous:x4},y4={name:"protocolAutolink",tokenize:uE,previous:b4},rl={name:"emailAutolink",tokenize:aE,previous:v4},_n={};function rE(){return{text:_n}}let lr=48;for(;lr<123;)_n[lr]=rl,lr++,lr===58?lr=65:lr===91&&(lr=97);_n[43]=rl;_n[45]=rl;_n[46]=rl;_n[95]=rl;_n[72]=[rl,y4];_n[104]=[rl,y4];_n[87]=[rl,g4];_n[119]=[rl,g4];function aE(t,l,r){const i=this;let s,o;return c;function c(y){return!Zf(y)||!v4.call(i,i.previous)||M1(i.events)?r(y):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),d(y))}function d(y){return Zf(y)?(t.consume(y),d):y===64?(t.consume(y),m):r(y)}function m(y){return y===46?t.check(lE,x,p)(y):y===45||y===95||jt(y)?(o=!0,t.consume(y),m):x(y)}function p(y){return t.consume(y),s=!0,m}function x(y){return o&&s&&Rt(i.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),l(y)):r(y)}}function iE(t,l,r){const i=this;return s;function s(c){return c!==87&&c!==119||!x4.call(i,i.previous)||M1(i.events)?r(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(nE,t.attempt(h4,t.attempt(m4,o),r),r)(c))}function o(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),l(c)}}function uE(t,l,r){const i=this;let s="",o=!1;return c;function c(y){return(y===72||y===104)&&b4.call(i,i.previous)&&!M1(i.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(y),t.consume(y),d):r(y)}function d(y){if(Rt(y)&&s.length<5)return s+=String.fromCodePoint(y),t.consume(y),d;if(y===58){const v=s.toLowerCase();if(v==="http"||v==="https")return t.consume(y),m}return r(y)}function m(y){return y===47?(t.consume(y),o?p:(o=!0,m)):r(y)}function p(y){return y===null||fs(y)||Xe(y)||ur(y)||Cs(y)?r(y):t.attempt(h4,t.attempt(m4,x),r)(y)}function x(y){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),l(y)}}function sE(t,l,r){let i=0;return s;function s(c){return(c===87||c===119)&&i<3?(i++,t.consume(c),s):c===46&&i===3?(t.consume(c),o):r(c)}function o(c){return c===null?r(c):l(c)}}function oE(t,l,r){let i,s,o;return c;function c(p){return p===46||p===95?t.check(p4,m,d)(p):p===null||Xe(p)||ur(p)||p!==45&&Cs(p)?m(p):(o=!0,t.consume(p),c)}function d(p){return p===95?i=!0:(s=i,i=void 0),t.consume(p),c}function m(p){return s||i||!o?r(p):l(p)}}function cE(t,l){let r=0,i=0;return s;function s(c){return c===40?(r++,t.consume(c),s):c===41&&i<r?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(p4,l,o)(c):c===null||Xe(c)||ur(c)?l(c):(t.consume(c),s)}function o(c){return c===41&&i++,t.consume(c),s}}function fE(t,l,r){return i;function i(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(t.consume(d),i):d===38?(t.consume(d),o):d===93?(t.consume(d),s):d===60||d===null||Xe(d)||ur(d)?l(d):r(d)}function s(d){return d===null||d===40||d===91||Xe(d)||ur(d)?l(d):i(d)}function o(d){return Rt(d)?c(d):r(d)}function c(d){return d===59?(t.consume(d),i):Rt(d)?(t.consume(d),c):r(d)}}function dE(t,l,r){return i;function i(o){return t.consume(o),s}function s(o){return jt(o)?r(o):l(o)}}function x4(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Xe(t)}function b4(t){return!Rt(t)}function v4(t){return!(t===47||Zf(t))}function Zf(t){return t===43||t===45||t===46||t===95||jt(t)}function M1(t){let l=t.length,r=!1;for(;l--;){const i=t[l][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){r=!0;break}if(i._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const hE={tokenize:SE,partial:!0};function mE(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:xE,continuation:{tokenize:bE},exit:vE}},text:{91:{name:"gfmFootnoteCall",tokenize:yE},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:pE,resolveTo:gE}}}}function pE(t,l,r){const i=this;let s=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;s--;){const m=i.events[s][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return d;function d(m){if(!c||!c._balanced)return r(m);const p=Cn(i.sliceSerialize({start:c.end,end:i.now()}));return p.codePointAt(0)!==94||!o.includes(p.slice(1))?r(m):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),l(m))}}function gE(t,l){let r=t.length;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[t[r+1],t[r+2],["enter",i,l],t[r+3],t[r+4],["enter",s,l],["exit",s,l],["enter",o,l],["enter",c,l],["exit",c,l],["exit",o,l],t[t.length-2],t[t.length-1],["exit",i,l]];return t.splice(r,t.length-r+1,...d),t}function yE(t,l,r){const i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,c;return d;function d(y){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),m}function m(y){return y!==94?r(y):(t.enter("gfmFootnoteCallMarker"),t.consume(y),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",p)}function p(y){if(o>999||y===93&&!c||y===null||y===91||Xe(y))return r(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return s.includes(Cn(i.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),l):r(y)}return Xe(y)||(c=!0),o++,t.consume(y),y===92?x:p}function x(y){return y===91||y===92||y===93?(t.consume(y),o++,p):p(y)}}function xE(t,l,r){const i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,c=0,d;return m;function m(C){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(C),t.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(C){return C===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(C),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",x):r(C)}function x(C){if(c>999||C===93&&!d||C===null||C===91||Xe(C))return r(C);if(C===93){t.exit("chunkString");const T=t.exit("gfmFootnoteDefinitionLabelString");return o=Cn(i.sliceSerialize(T)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(C),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return Xe(C)||(d=!0),c++,t.consume(C),C===92?y:x}function y(C){return C===91||C===92||C===93?(t.consume(C),c++,x):x(C)}function v(C){return C===58?(t.enter("definitionMarker"),t.consume(C),t.exit("definitionMarker"),s.includes(o)||s.push(o),Oe(t,S,"gfmFootnoteDefinitionWhitespace")):r(C)}function S(C){return l(C)}}function bE(t,l,r){return t.check(Ai,l,t.attempt(hE,l,r))}function vE(t){t.exit("gfmFootnoteDefinition")}function SE(t,l,r){const i=this;return Oe(t,s,"gfmFootnoteDefinitionIndent",5);function s(o){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?l(o):r(o)}}function wE(t){let r=(t||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:s};return r==null&&(r=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function s(c,d){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let p=m;for(;p--;)if(c[p][0]==="exit"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[p][1].end.offset-c[p][1].start.offset){c[m][1].type="strikethroughSequence",c[p][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},c[p][1].start),end:Object.assign({},c[m][1].end)},y={type:"strikethroughText",start:Object.assign({},c[p][1].end),end:Object.assign({},c[m][1].start)},v=[["enter",x,d],["enter",c[p][1],d],["exit",c[p][1],d],["enter",y,d]],S=d.parser.constructs.insideSpan.null;S&&tn(v,v.length,0,Es(S,c.slice(p+1,m),d)),tn(v,v.length,0,[["exit",y,d],["enter",c[m][1],d],["exit",c[m][1],d],["exit",x,d]]),tn(c,p-1,m-p+3,v),m=p+v.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function o(c,d,m){const p=this.previous,x=this.events;let y=0;return v;function v(C){return p===126&&x[x.length-1][1].type!=="characterEscape"?m(C):(c.enter("strikethroughSequenceTemporary"),S(C))}function S(C){const T=ia(p);if(C===126)return y>1?m(C):(c.consume(C),y++,S);if(y<2&&!r)return m(C);const z=c.exit("strikethroughSequenceTemporary"),M=ia(C);return z._open=!M||M===2&&!!T,z._close=!T||T===2&&!!M,d(C)}}}class kE{constructor(){this.map=[]}add(l,r,i){CE(this,l,r,i)}consume(l){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const i=[];for(;r>0;)r-=1,i.push(l.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),l.length=this.map[r][0];i.push(l.slice()),l.length=0;let s=i.pop();for(;s;){for(const o of s)l.push(o);s=i.pop()}this.map.length=0}}function CE(t,l,r,i){let s=0;if(!(r===0&&i.length===0)){for(;s<t.map.length;){if(t.map[s][0]===l){t.map[s][1]+=r,t.map[s][2].push(...i);return}s+=1}t.map.push([l,r,i])}}function EE(t,l){let r=!1;const i=[];for(;l<t.length;){const s=t[l];if(r){if(s[0]==="enter")s[1].type==="tableContent"&&i.push(t[l+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[l-1][1].type==="tableDelimiterMarker"){const o=i.length-1;i[o]=i[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(r=!0);l+=1}return i}function ME(){return{flow:{null:{name:"table",tokenize:NE,resolveAll:jE}}}}function NE(t,l,r){const i=this;let s=0,o=0,c;return d;function d(O){let ae=i.events.length-1;for(;ae>-1;){const ue=i.events[ae][1].type;if(ue==="lineEnding"||ue==="linePrefix")ae--;else break}const te=ae>-1?i.events[ae][1].type:null,be=te==="tableHead"||te==="tableRow"?_:m;return be===_&&i.parser.lazy[i.now().line]?r(O):be(O)}function m(O){return t.enter("tableHead"),t.enter("tableRow"),p(O)}function p(O){return O===124||(c=!0,o+=1),x(O)}function x(O){return O===null?r(O):ge(O)?o>1?(o=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),S):r(O):Te(O)?Oe(t,x,"whitespace")(O):(o+=1,c&&(c=!1,s+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),c=!0,x):(t.enter("data"),y(O)))}function y(O){return O===null||O===124||Xe(O)?(t.exit("data"),x(O)):(t.consume(O),O===92?v:y)}function v(O){return O===92||O===124?(t.consume(O),y):y(O)}function S(O){return i.interrupt=!1,i.parser.lazy[i.now().line]?r(O):(t.enter("tableDelimiterRow"),c=!1,Te(O)?Oe(t,C,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):C(O))}function C(O){return O===45||O===58?z(O):O===124?(c=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),T):F(O)}function T(O){return Te(O)?Oe(t,z,"whitespace")(O):z(O)}function z(O){return O===58?(o+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),M):O===45?(o+=1,M(O)):O===null||ge(O)?V(O):F(O)}function M(O){return O===45?(t.enter("tableDelimiterFiller"),U(O)):F(O)}function U(O){return O===45?(t.consume(O),U):O===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),N):(t.exit("tableDelimiterFiller"),N(O))}function N(O){return Te(O)?Oe(t,V,"whitespace")(O):V(O)}function V(O){return O===124?C(O):O===null||ge(O)?!c||s!==o?F(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),l(O)):F(O)}function F(O){return r(O)}function _(O){return t.enter("tableRow"),I(O)}function I(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),I):O===null||ge(O)?(t.exit("tableRow"),l(O)):Te(O)?Oe(t,I,"whitespace")(O):(t.enter("data"),se(O))}function se(O){return O===null||O===124||Xe(O)?(t.exit("data"),I(O)):(t.consume(O),O===92?oe:se)}function oe(O){return O===92||O===124?(t.consume(O),se):se(O)}}function jE(t,l){let r=-1,i=!0,s=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,m=0,p,x,y;const v=new kE;for(;++r<t.length;){const S=t[r],C=S[1];S[0]==="enter"?C.type==="tableHead"?(d=!1,m!==0&&(rp(v,l,m,p,x),x=void 0,m=0),p={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(r,0,[["enter",p,l]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(i=!0,y=void 0,o=[0,0,0,0],c=[0,r+1,0,0],d&&(d=!1,x={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(r,0,[["enter",x,l]])),s=C.type==="tableDelimiterRow"?2:x?3:1):s&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],y=Wu(v,l,o,s,void 0,y),o=[0,0,0,0]),c[2]=r)):C.type==="tableCellDivider"&&(i?i=!1:(o[1]!==0&&(c[0]=c[1],y=Wu(v,l,o,s,void 0,y)),o=c,c=[o[1],r,0,0])):C.type==="tableHead"?(d=!0,m=r):C.type==="tableRow"||C.type==="tableDelimiterRow"?(m=r,o[1]!==0?(c[0]=c[1],y=Wu(v,l,o,s,r,y)):c[1]!==0&&(y=Wu(v,l,c,s,r,y)),s=0):s&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&rp(v,l,m,p,x),v.consume(l.events),r=-1;++r<l.events.length;){const S=l.events[r];S[0]==="enter"&&S[1].type==="table"&&(S[1]._align=EE(l.events,r))}return t}function Wu(t,l,r,i,s,o){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",d="tableContent";r[0]!==0&&(o.end=Object.assign({},ta(l.events,r[0])),t.add(r[0],0,[["exit",o,l]]));const m=ta(l.events,r[1]);if(o={type:c,start:Object.assign({},m),end:Object.assign({},m)},t.add(r[1],0,[["enter",o,l]]),r[2]!==0){const p=ta(l.events,r[2]),x=ta(l.events,r[3]),y={type:d,start:Object.assign({},p),end:Object.assign({},x)};if(t.add(r[2],0,[["enter",y,l]]),i!==2){const v=l.events[r[2]],S=l.events[r[3]];if(v[1].end=Object.assign({},S[1].end),v[1].type="chunkText",v[1].contentType="text",r[3]>r[2]+1){const C=r[2]+1,T=r[3]-r[2]-1;t.add(C,T,[])}}t.add(r[3]+1,0,[["exit",y,l]])}return s!==void 0&&(o.end=Object.assign({},ta(l.events,s)),t.add(s,0,[["exit",o,l]]),o=void 0),o}function rp(t,l,r,i,s){const o=[],c=ta(l.events,r);s&&(s.end=Object.assign({},c),o.push(["exit",s,l])),i.end=Object.assign({},c),o.push(["exit",i,l]),t.add(r+1,0,o)}function ta(t,l){const r=t[l],i=r[0]==="enter"?"start":"end";return r[1][i]}const AE={name:"tasklistCheck",tokenize:TE};function zE(){return{text:{91:AE}}}function TE(t,l,r){const i=this;return s;function s(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?r(m):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(m),t.exit("taskListCheckMarker"),o)}function o(m){return Xe(m)?(t.enter("taskListCheckValueUnchecked"),t.consume(m),t.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(t.enter("taskListCheckValueChecked"),t.consume(m),t.exit("taskListCheckValueChecked"),c):r(m)}function c(m){return m===93?(t.enter("taskListCheckMarker"),t.consume(m),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),d):r(m)}function d(m){return ge(m)?l(m):Te(m)?t.check({tokenize:_E},l,r)(m):r(m)}}function _E(t,l,r){return Oe(t,i,"whitespace");function i(s){return s===null?r(s):l(s)}}function RE(t){return T3([rE(),mE(),wE(t),ME(),zE()])}const DE={};function OE(t){const l=this,r=t||DE,i=l.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(RE(r)),o.push(eE()),c.push(tE(r))}function LE({text:t}){const[l,r]=E.useState(!1),i=E.useCallback(async()=>{try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[t]);return g.jsx("button",{type:"button",onClick:i,className:"absolute top-2 right-2 p-1 rounded-md bg-herd-hover hover:bg-herd-active text-herd-code-fg/60 hover:text-herd-code-fg transition-colors",title:"Copy code",children:l?g.jsx(r3,{className:"w-3.5 h-3.5"}):g.jsx(s3,{className:"w-3.5 h-3.5"})})}function UE({children:t,className:l}){const r=String(t).replace(/\n$/,"");return g.jsxs("div",{className:"relative my-3",children:[g.jsx("pre",{className:"bg-herd-code-bg text-herd-code-fg rounded-lg p-3 text-xs font-mono overflow-x-auto",children:g.jsx("code",{className:l,children:r})}),g.jsx(LE,{text:r})]})}function HE({children:t}){return g.jsx("code",{className:"bg-herd-hover px-1.5 py-0.5 rounded text-xs font-mono text-herd-fg",children:t})}function BE({content:t,useSerif:l=!1}){const r={code(i){const{className:s,children:o}=i;return(s==null?void 0:s.startsWith("language-"))?g.jsx(UE,{className:s,children:o}):g.jsx(HE,{children:o})},pre({children:i}){return g.jsx(g.Fragment,{children:i})},a({href:i,children:s}){return g.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-herd-primary hover:underline",children:s})},h1({children:i}){return g.jsx("h1",{className:"text-lg font-semibold text-herd-fg mt-4 mb-2",children:i})},h2({children:i}){return g.jsx("h2",{className:"text-sm font-semibold text-herd-fg mt-3 mb-2",children:i})},h3({children:i}){return g.jsx("h3",{className:"text-sm font-medium text-herd-fg mt-3 mb-1",children:i})},h4({children:i}){return g.jsx("h4",{className:"text-sm font-medium text-herd-muted mt-2 mb-1",children:i})},p({children:i}){return g.jsx("p",{className:"text-sm text-herd-fg mb-2 last:mb-0",children:i})},ul({children:i}){return g.jsx("ul",{className:"list-disc list-inside text-sm text-herd-fg mb-2 ml-2",children:i})},ol({children:i}){return g.jsx("ol",{className:"list-decimal list-inside text-sm text-herd-fg mb-2 ml-2",children:i})},li({children:i}){return g.jsx("li",{className:"mb-0.5",children:i})},table({children:i}){return g.jsx("div",{className:"overflow-x-auto my-3",children:g.jsx("table",{className:"w-full text-sm",children:i})})},thead({children:i}){return g.jsx("thead",{children:i})},tbody({children:i}){return g.jsx("tbody",{className:"divide-y divide-herd-border",children:i})},tr({children:i}){return g.jsx("tr",{className:"border-b border-herd-border hover:bg-herd-hover transition-colors",children:i})},th({children:i}){return g.jsx("th",{className:"text-left py-2 px-3 text-xs text-herd-muted font-medium uppercase tracking-wide",children:i})},td({children:i}){return g.jsx("td",{className:"py-2 px-3 text-herd-fg",children:i})},blockquote({children:i}){return g.jsx("blockquote",{className:"border-l-2 border-herd-primary pl-3 my-2 text-sm text-herd-muted italic",children:i})},hr(){return g.jsx("hr",{className:"border-herd-border my-4"})},strong({children:i}){return g.jsx("strong",{className:"font-semibold",children:i})},em({children:i}){return g.jsx("em",{className:"italic",children:i})}};return g.jsx("div",{className:l?"font-serif":"font-sans",children:g.jsx(wk,{remarkPlugins:[OE],components:r,children:t})})}function ZE(t){switch(t){case"interval":return"Interval";case"cron":return"Cron";case"webhook":return"Webhook";case"chat":return"Chat"}}function qE(t){return t.expression?t.expression:t.interval?t.interval:"-"}function ap(t){if(!t)return"-";const l=new Date(t),r=new Date;return l.toDateString()===r.toDateString()?l.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):l.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $E({schedule:t,onTrigger:l,onEnable:r,onDisable:i}){const s=t.status==="disabled";return g.jsxs("tr",{className:"hover:bg-herd-hover transition-colors",children:[g.jsx("td",{className:"py-2 px-3 text-herd-fg",children:g.jsx(yt,{to:`/agents/${encodeURIComponent(t.agentName)}`,className:"text-herd-primary hover:text-herd-primary-hover transition-colors",children:t.agentName})}),g.jsx("td",{className:"py-2 px-3 text-herd-fg",children:t.name}),g.jsx("td",{className:"py-2 px-3",children:g.jsx("span",{className:"inline-flex items-center bg-herd-hover rounded-lg px-2 py-0.5 text-[11px] font-medium text-herd-muted",children:ZE(t.type)})}),g.jsx("td",{className:"py-2 px-3 text-herd-muted text-xs font-mono",children:qE(t)}),g.jsx("td",{className:"py-2 px-3",children:g.jsx(sr,{status:t.status})}),g.jsx("td",{className:"py-2 px-3 text-herd-muted text-xs",children:ap(t.lastRunAt)}),g.jsx("td",{className:"py-2 px-3 text-herd-muted text-xs",children:ap(t.nextRunAt)}),g.jsx("td",{className:"py-2 px-3",children:g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsxs("button",{onClick:()=>l(t.agentName,t.name),className:"bg-herd-primary hover:bg-herd-primary-hover text-white rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors inline-flex items-center gap-1 disabled:opacity-50 disabled:cursor-not-allowed",title:"Trigger Now",children:[g.jsx(wi,{className:"w-3 h-3"}),"Trigger"]}),s?g.jsx("button",{onClick:()=>r(t.agentName,t.name),className:"hover:bg-herd-hover text-herd-muted hover:text-herd-status-running rounded-lg p-1.5 transition-colors",title:"Enable schedule",children:g.jsx(G8,{className:"w-3.5 h-3.5"})}):g.jsx("button",{onClick:()=>i(t.agentName,t.name),className:"hover:bg-herd-hover text-herd-muted hover:text-herd-status-error rounded-lg p-1.5 transition-colors",title:"Disable schedule",children:g.jsx(F8,{className:"w-3.5 h-3.5"})})]})})]})}function VE(){return g.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[g.jsx(a1,{className:"w-12 h-12 text-herd-muted"}),g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-herd-fg font-medium",children:"No schedules configured"}),g.jsx("p",{className:"text-xs text-herd-muted mt-1",children:"Schedules will appear here once agents have interval, cron, or webhook triggers defined"})]})]})}function IE({message:t,onRetry:l}){return g.jsxs("div",{className:"bg-herd-status-error/10 border border-herd-status-error/20 text-herd-status-error rounded-lg px-3 py-2 text-xs mb-4 flex items-center justify-between",children:[g.jsx("span",{children:t}),g.jsx("button",{onClick:l,className:"hover:underline font-medium ml-4",children:"Retry"})]})}function JE(){const{schedules:t,schedulesLoading:l,schedulesError:r}=y6(),{fetchSchedules:i,triggerSchedule:s,enableSchedule:o,disableSchedule:c}=x6();E.useEffect(()=>{i().catch(()=>{})},[i]);const d=(x,y)=>{s(x,y).catch(()=>{})},m=(x,y)=>{o(x,y).catch(()=>{})},p=(x,y)=>{c(x,y).catch(()=>{})};return l&&t.length===0&&!r?g.jsx(xt,{className:"p-6",children:g.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[g.jsx(nl,{size:"lg"}),g.jsx("p",{className:"text-sm text-herd-muted",children:"Loading schedules..."})]})}):g.jsxs(xt,{className:"p-4",children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("h2",{className:"text-sm font-semibold text-herd-fg",children:"All Schedules"}),l&&t.length>0&&g.jsx(nl,{size:"sm"})]}),r&&g.jsx(IE,{message:r,onRetry:i}),t.length===0&&!l?g.jsx(VE,{}):g.jsx("div",{className:"overflow-x-auto",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-herd-border text-[11px] text-herd-muted font-medium uppercase tracking-wide",children:[g.jsx("th",{className:"text-left py-2 px-3",children:"Agent"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Schedule"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Type"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Expression"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Status"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Last Run"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Next Run"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Actions"})]})}),g.jsx("tbody",{className:"divide-y divide-herd-border",children:t.map(x=>g.jsx($E,{schedule:x,onTrigger:d,onEnable:m,onDisable:p},`${x.agentName}:${x.name}`))})]})})]})}function FE(t){const l=new Date(t),i=new Date().getTime()-l.getTime(),s=Math.floor(i/6e4),o=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"just now":s<60?`${s}m ago`:o<24?`${o}h ago`:c<7?`${c}d ago`:l.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function YE(t){if(t<1e3)return`${t}ms`;const l=Math.floor(t/1e3);if(l<60)return`${l}s`;const r=Math.floor(l/60),i=l%60;return i>0?`${r}m ${i}s`:`${r}m`}const GE={Bash:"💻",bash:"💻",Read:"📄",Write:"✏️",Edit:"✏️",Glob:"🔍",Grep:"🔍",WebFetch:"🌐",WebSearch:"🌐"};function XE({message:t}){const[l,r]=E.useState(!1),i=t.toolCall,s=GE[i.toolName]??"🔧",o=200,c=i.output.length>o,d=l?i.output:i.output.substring(0,o)+(c?"...":"");return g.jsx("div",{className:"flex flex-col items-start animate-[fadeSlideIn_150ms_ease-out]",children:g.jsxs("div",{className:`max-w-[85%] px-3 py-2 rounded-lg border ${i.isError?"border-red-500/30 bg-red-500/5":"border-herd-border bg-herd-hover"}`,children:[g.jsxs("button",{type:"button",onClick:()=>r(!l),className:"flex items-center gap-1.5 w-full text-left",children:[g.jsx("span",{className:"text-xs",children:s}),g.jsx("span",{className:"text-xs font-medium text-herd-fg",children:i.toolName}),i.isError&&g.jsx("span",{className:"text-[10px] text-red-500 font-medium",children:"ERROR"}),i.durationMs!==void 0&&g.jsx("span",{className:"text-[10px] text-herd-muted ml-auto",children:YE(i.durationMs)}),g.jsx("span",{className:"text-[10px] text-herd-muted",children:l?"▲":"▼"})]}),i.inputSummary&&g.jsx("div",{className:"mt-1",children:g.jsx("code",{className:"text-[11px] text-herd-muted break-all",children:i.inputSummary})}),(l||!c)&&i.output.trim().length>0&&g.jsx("pre",{className:"mt-1.5 text-[11px] text-herd-fg/80 bg-herd-bg rounded px-2 py-1.5 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap break-all",children:d}),!l&&c&&i.output.trim().length>0&&g.jsxs("div",{className:"mt-1.5 text-[11px] text-herd-muted",children:[(i.output.length/1e3).toFixed(1),"k chars"]})]})})}function ip({message:t,isStreaming:l=!1}){if(t.role==="tool"&&t.toolCall)return g.jsx(XE,{message:t});const r=t.role==="user";return g.jsxs("div",{className:`flex flex-col ${r?"items-end":"items-start"} animate-[fadeSlideIn_150ms_ease-out]`,children:[g.jsx("div",{className:`max-w-[85%] px-4 py-2.5 ${r?"bg-herd-user-bubble text-herd-fg rounded-2xl rounded-br-md":"bg-herd-card border border-herd-border text-herd-fg rounded-2xl rounded-bl-md"}`,children:r?g.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.content}):g.jsxs("div",{className:l?"relative":"",children:[g.jsx(BE,{content:t.content,useSerif:!0}),l&&g.jsxs("span",{className:"inline-flex ml-1",children:[g.jsx("span",{className:"w-1 h-1 bg-herd-muted rounded-full animate-pulse"}),g.jsx("span",{className:"w-1 h-1 bg-herd-muted rounded-full animate-pulse ml-0.5 [animation-delay:150ms]"}),g.jsx("span",{className:"w-1 h-1 bg-herd-muted rounded-full animate-pulse ml-0.5 [animation-delay:300ms]"})]})]})}),!l&&g.jsx("span",{className:"text-[11px] text-herd-muted mt-1 px-1",children:FE(t.timestamp)})]})}function QE({agentName:t}){const{chatMessages:l,chatMessagesLoading:r,chatStreaming:i,chatStreamingContent:s}=Pf(),o=E.useRef(null),c=E.useRef(l.length);if(E.useEffect(()=>{const m=o.current;if(!m)return;const p=m.scrollHeight-m.scrollTop-m.clientHeight<100;(l.length>c.current||i||p)&&(m.scrollTop=m.scrollHeight),c.current=l.length},[l,i,s]),r)return g.jsx("div",{className:"flex-1 flex items-center justify-center",children:g.jsxs("div",{className:"flex flex-col items-center gap-2 text-herd-muted",children:[g.jsx("div",{className:"w-5 h-5 border-2 border-herd-muted border-t-transparent rounded-full animate-spin"}),g.jsx("span",{className:"text-xs",children:"Loading messages..."})]})});if(l.length===0&&!i)return g.jsx("div",{className:"flex-1 flex items-center justify-center",children:g.jsxs("div",{className:"flex flex-col items-center gap-3 text-herd-muted",children:[g.jsx(u1,{className:"w-12 h-12 opacity-50"}),g.jsx("p",{className:"text-sm",children:"Send a message to start the conversation"})]})});const d=i?{role:"assistant",content:s||"...",timestamp:new Date().toISOString()}:null;return g.jsx("div",{ref:o,className:"flex-1 overflow-y-auto px-4 py-4",children:g.jsxs("div",{className:"max-w-2xl mx-auto space-y-4",children:[l.map((m,p)=>g.jsx(ip,{message:m},`${m.timestamp}-${p}`)),d&&g.jsx(ip,{message:d,isStreaming:!0})]})})}function KE({agentName:t,sessionId:l}){const[r,i]=E.useState(""),s=E.useRef(null),{chatStreaming:o}=Pf(),{addUserMessage:c}=Wf();E.useEffect(()=>{const y=s.current;if(!y)return;y.style.height="auto";const v=Math.min(y.scrollHeight,200);y.style.height=`${v}px`},[r]);const d=r.trim().length>0&&!o,m=E.useCallback(()=>{if(!d)return;const y=r.trim();i(""),c(y);const v=window.__herdWsClient;v&&v.send({type:"chat:send",payload:{agentName:t,sessionId:l,message:y}})},[d,r,c,t,l]),p=E.useCallback(y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),m())},[m]),x=E.useCallback(y=>{i(y.target.value)},[]);return g.jsx("div",{className:"border-t border-herd-border bg-herd-card p-4",children:g.jsxs("div",{className:"max-w-2xl mx-auto",children:[g.jsxs("div",{className:"relative flex items-end gap-2",children:[g.jsx("textarea",{ref:s,value:r,onChange:x,onKeyDown:p,placeholder:`Send a message to ${t}...`,rows:1,className:"flex-1 bg-herd-input-bg border border-herd-border rounded-lg px-3 py-2.5 text-sm text-herd-fg placeholder:text-herd-muted focus:outline-none focus:border-herd-primary/60 transition-colors resize-none",style:{minHeight:"42px",maxHeight:"200px"}}),g.jsx("button",{type:"button",onClick:m,disabled:!d,className:`flex-shrink-0 w-9 h-9 rounded-lg flex items-center justify-center transition-colors ${d?"bg-herd-primary hover:bg-herd-primary-hover text-white":"bg-herd-hover text-herd-muted cursor-not-allowed"}`,title:"Send message",children:g.jsx(n8,{className:"w-4 h-4"})})]}),g.jsx("p",{className:"text-[11px] text-herd-muted mt-2 text-center",children:"Press Enter to send, Shift+Enter for new line"})]})})}function up(){const{name:t,sessionId:l}=Jf(),r=If(),{activeChatSessionId:i,chatError:s}=Pf(),{chatSessions:o}=p6(),{fetchChatMessages:c,setActiveChatSession:d,clearChatState:m,createChatSession:p}=Wf();if(E.useEffect(()=>()=>{m()},[t,m]),E.useEffect(()=>{l&&t?c(t,l):d(null)},[l,t,c,d]),!t)return g.jsx("div",{className:"flex items-center justify-center h-full text-herd-muted",children:g.jsx("p",{className:"text-sm",children:"Agent not found"})});const x=async()=>{const y=await p(t);y&&r(`/agents/${encodeURIComponent(t)}/chat/${y}`)};return g.jsx("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:l?g.jsxs(g.Fragment,{children:[s&&g.jsx("div",{className:"px-4 pt-4",children:g.jsx("div",{className:"max-w-2xl mx-auto",children:g.jsx("div",{className:"bg-herd-status-error/10 border border-herd-status-error/20 text-herd-status-error rounded-lg px-3 py-2 text-xs",children:s})})}),g.jsx(QE,{agentName:t}),g.jsx(KE,{agentName:t,sessionId:l})]}):g.jsx("div",{className:"flex-1 flex items-center justify-center",children:g.jsxs("div",{className:"flex flex-col items-center gap-4 text-center px-4",children:[g.jsx("div",{className:"w-16 h-16 rounded-full bg-herd-primary-muted flex items-center justify-center",children:g.jsx(u1,{className:"w-8 h-8 text-herd-primary"})}),g.jsxs("div",{children:[g.jsxs("h2",{className:"text-lg font-semibold text-herd-fg mb-1",children:["Chat with ",t]}),g.jsx("p",{className:"text-sm text-herd-muted max-w-sm",children:o.length>0?"Select a conversation from the sidebar or start a new one.":"Start a new conversation to chat with this agent."})]}),g.jsx("button",{type:"button",onClick:x,className:"bg-herd-primary hover:bg-herd-primary-hover text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:"New Chat"})]})})})}function PE(t){switch(t){case"success":return g.jsx(u3,{className:"w-4 h-4 text-herd-status-running flex-shrink-0"});case"error":return g.jsx(p8,{className:"w-4 h-4 text-herd-status-error flex-shrink-0"});case"info":return g.jsx(_8,{className:"w-4 h-4 text-herd-primary flex-shrink-0"})}}function WE(t){switch(t){case"success":return"bg-herd-status-running/10 border-herd-status-running/20";case"error":return"bg-herd-status-error/10 border-herd-status-error/20";case"info":return"bg-herd-primary-muted border-herd-primary/20"}}function eM({toast:t,onDismiss:l}){return g.jsxs("div",{className:`
|
|
364
|
+
`))}function m(S,C,T,z){const M=T.enter("tableCell"),U=T.enter("phrasing"),N=T.containerPhrasing(S,{...z,before:o,after:o});return U(),M(),N}function p(S,C){return oC(S,{align:C,alignDelimiters:i,padding:r,stringLength:s})}function x(S,C,T){const z=S.children;let M=-1;const U=[],N=C.enter("table");for(;++M<z.length;)U[M]=y(z[M],C,T);return N(),U}function y(S,C,T){const z=S.children;let M=-1;const U=[],N=C.enter("tableRow");for(;++M<z.length;)U[M]=m(z[M],S,C,T);return N(),U}function v(S,C,T){let z=d4.inlineCode(S,C,T);return T.stack.includes("tableCell")&&(z=z.replace(/\|/g,"\\$&")),z}}function QC(){return{exit:{taskListCheckValueChecked:lp,taskListCheckValueUnchecked:lp,paragraph:PC}}}function KC(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:WC}}}function lp(t){const l=this.stack[this.stack.length-2];l.type,l.checked=t.type==="taskListCheckValueChecked"}function PC(t){const l=this.stack[this.stack.length-2];if(l&&l.type==="listItem"&&typeof l.checked=="boolean"){const r=this.stack[this.stack.length-1];r.type;const i=r.children[0];if(i&&i.type==="text"){const s=l.children;let o=-1,c;for(;++o<s.length;){const d=s[o];if(d.type==="paragraph"){c=d;break}}c===r&&(i.value=i.value.slice(1),i.value.length===0?r.children.shift():r.position&&i.position&&typeof i.position.start.offset=="number"&&(i.position.start.column++,i.position.start.offset++,r.position.start=Object.assign({},i.position.start)))}}this.exit(t)}function WC(t,l,r,i){const s=t.children[0],o=typeof t.checked=="boolean"&&s&&s.type==="paragraph",c="["+(t.checked?"x":" ")+"] ",d=r.createTracker(i);o&&d.move(c);let m=d4.listItem(t,l,r,{...i,...d.current()});return o&&(m=m.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,p)),m;function p(x){return x+c}}function eE(){return[_k(),Wk(),lC(),VC(),QC()]}function tE(t){return{extensions:[Rk(),eC(t),rC(),XC(t),KC()]}}const nE={tokenize:sE,partial:!0},h4={tokenize:oE,partial:!0},m4={tokenize:cE,partial:!0},p4={tokenize:fE,partial:!0},lE={tokenize:dE,partial:!0},g4={name:"wwwAutolink",tokenize:iE,previous:x4},y4={name:"protocolAutolink",tokenize:uE,previous:b4},rl={name:"emailAutolink",tokenize:aE,previous:v4},_n={};function rE(){return{text:_n}}let lr=48;for(;lr<123;)_n[lr]=rl,lr++,lr===58?lr=65:lr===91&&(lr=97);_n[43]=rl;_n[45]=rl;_n[46]=rl;_n[95]=rl;_n[72]=[rl,y4];_n[104]=[rl,y4];_n[87]=[rl,g4];_n[119]=[rl,g4];function aE(t,l,r){const i=this;let s,o;return c;function c(y){return!Zf(y)||!v4.call(i,i.previous)||M1(i.events)?r(y):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),d(y))}function d(y){return Zf(y)?(t.consume(y),d):y===64?(t.consume(y),m):r(y)}function m(y){return y===46?t.check(lE,x,p)(y):y===45||y===95||jt(y)?(o=!0,t.consume(y),m):x(y)}function p(y){return t.consume(y),s=!0,m}function x(y){return o&&s&&Rt(i.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),l(y)):r(y)}}function iE(t,l,r){const i=this;return s;function s(c){return c!==87&&c!==119||!x4.call(i,i.previous)||M1(i.events)?r(c):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(nE,t.attempt(h4,t.attempt(m4,o),r),r)(c))}function o(c){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),l(c)}}function uE(t,l,r){const i=this;let s="",o=!1;return c;function c(y){return(y===72||y===104)&&b4.call(i,i.previous)&&!M1(i.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),s+=String.fromCodePoint(y),t.consume(y),d):r(y)}function d(y){if(Rt(y)&&s.length<5)return s+=String.fromCodePoint(y),t.consume(y),d;if(y===58){const v=s.toLowerCase();if(v==="http"||v==="https")return t.consume(y),m}return r(y)}function m(y){return y===47?(t.consume(y),o?p:(o=!0,m)):r(y)}function p(y){return y===null||fs(y)||Xe(y)||ur(y)||Cs(y)?r(y):t.attempt(h4,t.attempt(m4,x),r)(y)}function x(y){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),l(y)}}function sE(t,l,r){let i=0;return s;function s(c){return(c===87||c===119)&&i<3?(i++,t.consume(c),s):c===46&&i===3?(t.consume(c),o):r(c)}function o(c){return c===null?r(c):l(c)}}function oE(t,l,r){let i,s,o;return c;function c(p){return p===46||p===95?t.check(p4,m,d)(p):p===null||Xe(p)||ur(p)||p!==45&&Cs(p)?m(p):(o=!0,t.consume(p),c)}function d(p){return p===95?i=!0:(s=i,i=void 0),t.consume(p),c}function m(p){return s||i||!o?r(p):l(p)}}function cE(t,l){let r=0,i=0;return s;function s(c){return c===40?(r++,t.consume(c),s):c===41&&i<r?o(c):c===33||c===34||c===38||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===60||c===63||c===93||c===95||c===126?t.check(p4,l,o)(c):c===null||Xe(c)||ur(c)?l(c):(t.consume(c),s)}function o(c){return c===41&&i++,t.consume(c),s}}function fE(t,l,r){return i;function i(d){return d===33||d===34||d===39||d===41||d===42||d===44||d===46||d===58||d===59||d===63||d===95||d===126?(t.consume(d),i):d===38?(t.consume(d),o):d===93?(t.consume(d),s):d===60||d===null||Xe(d)||ur(d)?l(d):r(d)}function s(d){return d===null||d===40||d===91||Xe(d)||ur(d)?l(d):i(d)}function o(d){return Rt(d)?c(d):r(d)}function c(d){return d===59?(t.consume(d),i):Rt(d)?(t.consume(d),c):r(d)}}function dE(t,l,r){return i;function i(o){return t.consume(o),s}function s(o){return jt(o)?r(o):l(o)}}function x4(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Xe(t)}function b4(t){return!Rt(t)}function v4(t){return!(t===47||Zf(t))}function Zf(t){return t===43||t===45||t===46||t===95||jt(t)}function M1(t){let l=t.length,r=!1;for(;l--;){const i=t[l][1];if((i.type==="labelLink"||i.type==="labelImage")&&!i._balanced){r=!0;break}if(i._gfmAutolinkLiteralWalkedInto){r=!1;break}}return t.length>0&&!r&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),r}const hE={tokenize:SE,partial:!0};function mE(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:xE,continuation:{tokenize:bE},exit:vE}},text:{91:{name:"gfmFootnoteCall",tokenize:yE},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:pE,resolveTo:gE}}}}function pE(t,l,r){const i=this;let s=i.events.length;const o=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let c;for(;s--;){const m=i.events[s][1];if(m.type==="labelImage"){c=m;break}if(m.type==="gfmFootnoteCall"||m.type==="labelLink"||m.type==="label"||m.type==="image"||m.type==="link")break}return d;function d(m){if(!c||!c._balanced)return r(m);const p=Cn(i.sliceSerialize({start:c.end,end:i.now()}));return p.codePointAt(0)!==94||!o.includes(p.slice(1))?r(m):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(m),t.exit("gfmFootnoteCallLabelMarker"),l(m))}}function gE(t,l){let r=t.length;for(;r--;)if(t[r][1].type==="labelImage"&&t[r][0]==="enter"){t[r][1];break}t[r+1][1].type="data",t[r+3][1].type="gfmFootnoteCallLabelMarker";const i={type:"gfmFootnoteCall",start:Object.assign({},t[r+3][1].start),end:Object.assign({},t[t.length-1][1].end)},s={type:"gfmFootnoteCallMarker",start:Object.assign({},t[r+3][1].end),end:Object.assign({},t[r+3][1].end)};s.end.column++,s.end.offset++,s.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},s.end),end:Object.assign({},t[t.length-1][1].start)},c={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},d=[t[r+1],t[r+2],["enter",i,l],t[r+3],t[r+4],["enter",s,l],["exit",s,l],["enter",o,l],["enter",c,l],["exit",c,l],["exit",o,l],t[t.length-2],t[t.length-1],["exit",i,l]];return t.splice(r,t.length-r+1,...d),t}function yE(t,l,r){const i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o=0,c;return d;function d(y){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),m}function m(y){return y!==94?r(y):(t.enter("gfmFootnoteCallMarker"),t.consume(y),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",p)}function p(y){if(o>999||y===93&&!c||y===null||y===91||Xe(y))return r(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteCallString");return s.includes(Cn(i.sliceSerialize(v)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(y),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),l):r(y)}return Xe(y)||(c=!0),o++,t.consume(y),y===92?x:p}function x(y){return y===91||y===92||y===93?(t.consume(y),o++,p):p(y)}}function xE(t,l,r){const i=this,s=i.parser.gfmFootnotes||(i.parser.gfmFootnotes=[]);let o,c=0,d;return m;function m(C){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(C),t.exit("gfmFootnoteDefinitionLabelMarker"),p}function p(C){return C===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(C),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",x):r(C)}function x(C){if(c>999||C===93&&!d||C===null||C===91||Xe(C))return r(C);if(C===93){t.exit("chunkString");const T=t.exit("gfmFootnoteDefinitionLabelString");return o=Cn(i.sliceSerialize(T)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(C),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),v}return Xe(C)||(d=!0),c++,t.consume(C),C===92?y:x}function y(C){return C===91||C===92||C===93?(t.consume(C),c++,x):x(C)}function v(C){return C===58?(t.enter("definitionMarker"),t.consume(C),t.exit("definitionMarker"),s.includes(o)||s.push(o),Oe(t,S,"gfmFootnoteDefinitionWhitespace")):r(C)}function S(C){return l(C)}}function bE(t,l,r){return t.check(Ai,l,t.attempt(hE,l,r))}function vE(t){t.exit("gfmFootnoteDefinition")}function SE(t,l,r){const i=this;return Oe(t,s,"gfmFootnoteDefinitionIndent",5);function s(o){const c=i.events[i.events.length-1];return c&&c[1].type==="gfmFootnoteDefinitionIndent"&&c[2].sliceSerialize(c[1],!0).length===4?l(o):r(o)}}function wE(t){let r=(t||{}).singleTilde;const i={name:"strikethrough",tokenize:o,resolveAll:s};return r==null&&(r=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function s(c,d){let m=-1;for(;++m<c.length;)if(c[m][0]==="enter"&&c[m][1].type==="strikethroughSequenceTemporary"&&c[m][1]._close){let p=m;for(;p--;)if(c[p][0]==="exit"&&c[p][1].type==="strikethroughSequenceTemporary"&&c[p][1]._open&&c[m][1].end.offset-c[m][1].start.offset===c[p][1].end.offset-c[p][1].start.offset){c[m][1].type="strikethroughSequence",c[p][1].type="strikethroughSequence";const x={type:"strikethrough",start:Object.assign({},c[p][1].start),end:Object.assign({},c[m][1].end)},y={type:"strikethroughText",start:Object.assign({},c[p][1].end),end:Object.assign({},c[m][1].start)},v=[["enter",x,d],["enter",c[p][1],d],["exit",c[p][1],d],["enter",y,d]],S=d.parser.constructs.insideSpan.null;S&&tn(v,v.length,0,Es(S,c.slice(p+1,m),d)),tn(v,v.length,0,[["exit",y,d],["enter",c[m][1],d],["exit",c[m][1],d],["exit",x,d]]),tn(c,p-1,m-p+3,v),m=p+v.length-2;break}}for(m=-1;++m<c.length;)c[m][1].type==="strikethroughSequenceTemporary"&&(c[m][1].type="data");return c}function o(c,d,m){const p=this.previous,x=this.events;let y=0;return v;function v(C){return p===126&&x[x.length-1][1].type!=="characterEscape"?m(C):(c.enter("strikethroughSequenceTemporary"),S(C))}function S(C){const T=ia(p);if(C===126)return y>1?m(C):(c.consume(C),y++,S);if(y<2&&!r)return m(C);const z=c.exit("strikethroughSequenceTemporary"),M=ia(C);return z._open=!M||M===2&&!!T,z._close=!T||T===2&&!!M,d(C)}}}class kE{constructor(){this.map=[]}add(l,r,i){CE(this,l,r,i)}consume(l){if(this.map.sort(function(o,c){return o[0]-c[0]}),this.map.length===0)return;let r=this.map.length;const i=[];for(;r>0;)r-=1,i.push(l.slice(this.map[r][0]+this.map[r][1]),this.map[r][2]),l.length=this.map[r][0];i.push(l.slice()),l.length=0;let s=i.pop();for(;s;){for(const o of s)l.push(o);s=i.pop()}this.map.length=0}}function CE(t,l,r,i){let s=0;if(!(r===0&&i.length===0)){for(;s<t.map.length;){if(t.map[s][0]===l){t.map[s][1]+=r,t.map[s][2].push(...i);return}s+=1}t.map.push([l,r,i])}}function EE(t,l){let r=!1;const i=[];for(;l<t.length;){const s=t[l];if(r){if(s[0]==="enter")s[1].type==="tableContent"&&i.push(t[l+1][1].type==="tableDelimiterMarker"?"left":"none");else if(s[1].type==="tableContent"){if(t[l-1][1].type==="tableDelimiterMarker"){const o=i.length-1;i[o]=i[o]==="left"?"center":"right"}}else if(s[1].type==="tableDelimiterRow")break}else s[0]==="enter"&&s[1].type==="tableDelimiterRow"&&(r=!0);l+=1}return i}function ME(){return{flow:{null:{name:"table",tokenize:NE,resolveAll:jE}}}}function NE(t,l,r){const i=this;let s=0,o=0,c;return d;function d(O){let ae=i.events.length-1;for(;ae>-1;){const ue=i.events[ae][1].type;if(ue==="lineEnding"||ue==="linePrefix")ae--;else break}const te=ae>-1?i.events[ae][1].type:null,be=te==="tableHead"||te==="tableRow"?_:m;return be===_&&i.parser.lazy[i.now().line]?r(O):be(O)}function m(O){return t.enter("tableHead"),t.enter("tableRow"),p(O)}function p(O){return O===124||(c=!0,o+=1),x(O)}function x(O){return O===null?r(O):ge(O)?o>1?(o=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(O),t.exit("lineEnding"),S):r(O):Te(O)?Oe(t,x,"whitespace")(O):(o+=1,c&&(c=!1,s+=1),O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),c=!0,x):(t.enter("data"),y(O)))}function y(O){return O===null||O===124||Xe(O)?(t.exit("data"),x(O)):(t.consume(O),O===92?v:y)}function v(O){return O===92||O===124?(t.consume(O),y):y(O)}function S(O){return i.interrupt=!1,i.parser.lazy[i.now().line]?r(O):(t.enter("tableDelimiterRow"),c=!1,Te(O)?Oe(t,C,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):C(O))}function C(O){return O===45||O===58?z(O):O===124?(c=!0,t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),T):F(O)}function T(O){return Te(O)?Oe(t,z,"whitespace")(O):z(O)}function z(O){return O===58?(o+=1,c=!0,t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),M):O===45?(o+=1,M(O)):O===null||ge(O)?V(O):F(O)}function M(O){return O===45?(t.enter("tableDelimiterFiller"),U(O)):F(O)}function U(O){return O===45?(t.consume(O),U):O===58?(c=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(O),t.exit("tableDelimiterMarker"),N):(t.exit("tableDelimiterFiller"),N(O))}function N(O){return Te(O)?Oe(t,V,"whitespace")(O):V(O)}function V(O){return O===124?C(O):O===null||ge(O)?!c||s!==o?F(O):(t.exit("tableDelimiterRow"),t.exit("tableHead"),l(O)):F(O)}function F(O){return r(O)}function _(O){return t.enter("tableRow"),I(O)}function I(O){return O===124?(t.enter("tableCellDivider"),t.consume(O),t.exit("tableCellDivider"),I):O===null||ge(O)?(t.exit("tableRow"),l(O)):Te(O)?Oe(t,I,"whitespace")(O):(t.enter("data"),se(O))}function se(O){return O===null||O===124||Xe(O)?(t.exit("data"),I(O)):(t.consume(O),O===92?oe:se)}function oe(O){return O===92||O===124?(t.consume(O),se):se(O)}}function jE(t,l){let r=-1,i=!0,s=0,o=[0,0,0,0],c=[0,0,0,0],d=!1,m=0,p,x,y;const v=new kE;for(;++r<t.length;){const S=t[r],C=S[1];S[0]==="enter"?C.type==="tableHead"?(d=!1,m!==0&&(rp(v,l,m,p,x),x=void 0,m=0),p={type:"table",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(r,0,[["enter",p,l]])):C.type==="tableRow"||C.type==="tableDelimiterRow"?(i=!0,y=void 0,o=[0,0,0,0],c=[0,r+1,0,0],d&&(d=!1,x={type:"tableBody",start:Object.assign({},C.start),end:Object.assign({},C.end)},v.add(r,0,[["enter",x,l]])),s=C.type==="tableDelimiterRow"?2:x?3:1):s&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")?(i=!1,c[2]===0&&(o[1]!==0&&(c[0]=c[1],y=Wu(v,l,o,s,void 0,y),o=[0,0,0,0]),c[2]=r)):C.type==="tableCellDivider"&&(i?i=!1:(o[1]!==0&&(c[0]=c[1],y=Wu(v,l,o,s,void 0,y)),o=c,c=[o[1],r,0,0])):C.type==="tableHead"?(d=!0,m=r):C.type==="tableRow"||C.type==="tableDelimiterRow"?(m=r,o[1]!==0?(c[0]=c[1],y=Wu(v,l,o,s,r,y)):c[1]!==0&&(y=Wu(v,l,c,s,r,y)),s=0):s&&(C.type==="data"||C.type==="tableDelimiterMarker"||C.type==="tableDelimiterFiller")&&(c[3]=r)}for(m!==0&&rp(v,l,m,p,x),v.consume(l.events),r=-1;++r<l.events.length;){const S=l.events[r];S[0]==="enter"&&S[1].type==="table"&&(S[1]._align=EE(l.events,r))}return t}function Wu(t,l,r,i,s,o){const c=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",d="tableContent";r[0]!==0&&(o.end=Object.assign({},ta(l.events,r[0])),t.add(r[0],0,[["exit",o,l]]));const m=ta(l.events,r[1]);if(o={type:c,start:Object.assign({},m),end:Object.assign({},m)},t.add(r[1],0,[["enter",o,l]]),r[2]!==0){const p=ta(l.events,r[2]),x=ta(l.events,r[3]),y={type:d,start:Object.assign({},p),end:Object.assign({},x)};if(t.add(r[2],0,[["enter",y,l]]),i!==2){const v=l.events[r[2]],S=l.events[r[3]];if(v[1].end=Object.assign({},S[1].end),v[1].type="chunkText",v[1].contentType="text",r[3]>r[2]+1){const C=r[2]+1,T=r[3]-r[2]-1;t.add(C,T,[])}}t.add(r[3]+1,0,[["exit",y,l]])}return s!==void 0&&(o.end=Object.assign({},ta(l.events,s)),t.add(s,0,[["exit",o,l]]),o=void 0),o}function rp(t,l,r,i,s){const o=[],c=ta(l.events,r);s&&(s.end=Object.assign({},c),o.push(["exit",s,l])),i.end=Object.assign({},c),o.push(["exit",i,l]),t.add(r+1,0,o)}function ta(t,l){const r=t[l],i=r[0]==="enter"?"start":"end";return r[1][i]}const AE={name:"tasklistCheck",tokenize:TE};function zE(){return{text:{91:AE}}}function TE(t,l,r){const i=this;return s;function s(m){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?r(m):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(m),t.exit("taskListCheckMarker"),o)}function o(m){return Xe(m)?(t.enter("taskListCheckValueUnchecked"),t.consume(m),t.exit("taskListCheckValueUnchecked"),c):m===88||m===120?(t.enter("taskListCheckValueChecked"),t.consume(m),t.exit("taskListCheckValueChecked"),c):r(m)}function c(m){return m===93?(t.enter("taskListCheckMarker"),t.consume(m),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),d):r(m)}function d(m){return ge(m)?l(m):Te(m)?t.check({tokenize:_E},l,r)(m):r(m)}}function _E(t,l,r){return Oe(t,i,"whitespace");function i(s){return s===null?r(s):l(s)}}function RE(t){return T3([rE(),mE(),wE(t),ME(),zE()])}const DE={};function OE(t){const l=this,r=t||DE,i=l.data(),s=i.micromarkExtensions||(i.micromarkExtensions=[]),o=i.fromMarkdownExtensions||(i.fromMarkdownExtensions=[]),c=i.toMarkdownExtensions||(i.toMarkdownExtensions=[]);s.push(RE(r)),o.push(eE()),c.push(tE(r))}function LE({text:t}){const[l,r]=E.useState(!1),i=E.useCallback(async()=>{try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch{}},[t]);return g.jsx("button",{type:"button",onClick:i,className:"absolute top-2 right-2 p-1 rounded-md bg-herd-hover hover:bg-herd-active text-herd-code-fg/60 hover:text-herd-code-fg transition-colors",title:"Copy code",children:l?g.jsx(r3,{className:"w-3.5 h-3.5"}):g.jsx(s3,{className:"w-3.5 h-3.5"})})}function UE({children:t,className:l}){const r=String(t).replace(/\n$/,"");return g.jsxs("div",{className:"relative my-3",children:[g.jsx("pre",{className:"bg-herd-code-bg text-herd-code-fg rounded-lg p-3 text-xs font-mono overflow-x-auto",children:g.jsx("code",{className:l,children:r})}),g.jsx(LE,{text:r})]})}function HE({children:t}){return g.jsx("code",{className:"bg-herd-hover px-1.5 py-0.5 rounded text-xs font-mono text-herd-fg",children:t})}function BE({content:t,useSerif:l=!1}){const r={code(i){const{className:s,children:o}=i;return(s==null?void 0:s.startsWith("language-"))?g.jsx(UE,{className:s,children:o}):g.jsx(HE,{children:o})},pre({children:i}){return g.jsx(g.Fragment,{children:i})},a({href:i,children:s}){return g.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-herd-primary hover:underline",children:s})},h1({children:i}){return g.jsx("h1",{className:"text-lg font-semibold text-herd-fg mt-4 mb-2",children:i})},h2({children:i}){return g.jsx("h2",{className:"text-sm font-semibold text-herd-fg mt-3 mb-2",children:i})},h3({children:i}){return g.jsx("h3",{className:"text-sm font-medium text-herd-fg mt-3 mb-1",children:i})},h4({children:i}){return g.jsx("h4",{className:"text-sm font-medium text-herd-muted mt-2 mb-1",children:i})},p({children:i}){return g.jsx("p",{className:"text-sm text-herd-fg mb-2 last:mb-0",children:i})},ul({children:i}){return g.jsx("ul",{className:"list-disc list-inside text-sm text-herd-fg mb-2 ml-2",children:i})},ol({children:i}){return g.jsx("ol",{className:"list-decimal list-inside text-sm text-herd-fg mb-2 ml-2",children:i})},li({children:i}){return g.jsx("li",{className:"mb-0.5",children:i})},table({children:i}){return g.jsx("div",{className:"overflow-x-auto my-3",children:g.jsx("table",{className:"w-full text-sm",children:i})})},thead({children:i}){return g.jsx("thead",{children:i})},tbody({children:i}){return g.jsx("tbody",{className:"divide-y divide-herd-border",children:i})},tr({children:i}){return g.jsx("tr",{className:"border-b border-herd-border hover:bg-herd-hover transition-colors",children:i})},th({children:i}){return g.jsx("th",{className:"text-left py-2 px-3 text-xs text-herd-muted font-medium uppercase tracking-wide",children:i})},td({children:i}){return g.jsx("td",{className:"py-2 px-3 text-herd-fg",children:i})},blockquote({children:i}){return g.jsx("blockquote",{className:"border-l-2 border-herd-primary pl-3 my-2 text-sm text-herd-muted italic",children:i})},hr(){return g.jsx("hr",{className:"border-herd-border my-4"})},strong({children:i}){return g.jsx("strong",{className:"font-semibold",children:i})},em({children:i}){return g.jsx("em",{className:"italic",children:i})}};return g.jsx("div",{className:l?"font-serif":"font-sans",children:g.jsx(wk,{remarkPlugins:[OE],components:r,children:t})})}function ZE(t){switch(t){case"interval":return"Interval";case"cron":return"Cron";case"webhook":return"Webhook";case"chat":return"Chat"}}function qE(t){return t.expression?t.expression:t.interval?t.interval:"-"}function ap(t){if(!t)return"-";const l=new Date(t),r=new Date;return l.toDateString()===r.toDateString()?l.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):l.toLocaleDateString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function $E({schedule:t,onTrigger:l,onEnable:r,onDisable:i}){const s=t.status==="disabled";return g.jsxs("tr",{className:"hover:bg-herd-hover transition-colors",children:[g.jsx("td",{className:"py-2 px-3 text-herd-fg",children:g.jsx(yt,{to:`/agents/${encodeURIComponent(t.agentName)}`,className:"text-herd-primary hover:text-herd-primary-hover transition-colors",children:t.agentName})}),g.jsx("td",{className:"py-2 px-3 text-herd-fg",children:t.name}),g.jsx("td",{className:"py-2 px-3",children:g.jsx("span",{className:"inline-flex items-center bg-herd-hover rounded-lg px-2 py-0.5 text-[11px] font-medium text-herd-muted",children:ZE(t.type)})}),g.jsx("td",{className:"py-2 px-3 text-herd-muted text-xs font-mono",children:qE(t)}),g.jsx("td",{className:"py-2 px-3",children:g.jsx(sr,{status:t.status})}),g.jsx("td",{className:"py-2 px-3 text-herd-muted text-xs",children:ap(t.lastRunAt)}),g.jsx("td",{className:"py-2 px-3 text-herd-muted text-xs",children:ap(t.nextRunAt)}),g.jsx("td",{className:"py-2 px-3",children:g.jsxs("div",{className:"flex items-center gap-1.5",children:[g.jsxs("button",{onClick:()=>l(t.agentName,t.name),className:"bg-herd-primary hover:bg-herd-primary-hover text-white rounded-lg px-2.5 py-1 text-[11px] font-medium transition-colors inline-flex items-center gap-1 disabled:opacity-50 disabled:cursor-not-allowed",title:"Trigger Now",children:[g.jsx(wi,{className:"w-3 h-3"}),"Trigger"]}),s?g.jsx("button",{onClick:()=>r(t.agentName,t.name),className:"hover:bg-herd-hover text-herd-muted hover:text-herd-status-running rounded-lg p-1.5 transition-colors",title:"Enable schedule",children:g.jsx(G8,{className:"w-3.5 h-3.5"})}):g.jsx("button",{onClick:()=>i(t.agentName,t.name),className:"hover:bg-herd-hover text-herd-muted hover:text-herd-status-error rounded-lg p-1.5 transition-colors",title:"Disable schedule",children:g.jsx(F8,{className:"w-3.5 h-3.5"})})]})})]})}function VE(){return g.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-12 text-center",children:[g.jsx(a1,{className:"w-12 h-12 text-herd-muted"}),g.jsxs("div",{children:[g.jsx("p",{className:"text-sm text-herd-fg font-medium",children:"No schedules configured"}),g.jsx("p",{className:"text-xs text-herd-muted mt-1",children:"Schedules will appear here once agents have interval, cron, or webhook triggers defined"})]})]})}function IE({message:t,onRetry:l}){return g.jsxs("div",{className:"bg-herd-status-error/10 border border-herd-status-error/20 text-herd-status-error rounded-lg px-3 py-2 text-xs mb-4 flex items-center justify-between",children:[g.jsx("span",{children:t}),g.jsx("button",{onClick:l,className:"hover:underline font-medium ml-4",children:"Retry"})]})}function JE(){const{schedules:t,schedulesLoading:l,schedulesError:r}=y6(),{fetchSchedules:i,triggerSchedule:s,enableSchedule:o,disableSchedule:c}=x6();E.useEffect(()=>{i().catch(()=>{})},[i]);const d=(x,y)=>{s(x,y).catch(()=>{})},m=(x,y)=>{o(x,y).catch(()=>{})},p=(x,y)=>{c(x,y).catch(()=>{})};return l&&t.length===0&&!r?g.jsx(xt,{className:"p-6",children:g.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[g.jsx(nl,{size:"lg"}),g.jsx("p",{className:"text-sm text-herd-muted",children:"Loading schedules..."})]})}):g.jsxs(xt,{className:"p-4",children:[g.jsxs("div",{className:"flex items-center justify-between mb-4",children:[g.jsx("h2",{className:"text-sm font-semibold text-herd-fg",children:"All Schedules"}),l&&t.length>0&&g.jsx(nl,{size:"sm"})]}),r&&g.jsx(IE,{message:r,onRetry:i}),t.length===0&&!l?g.jsx(VE,{}):g.jsx("div",{className:"overflow-x-auto",children:g.jsxs("table",{className:"w-full text-sm",children:[g.jsx("thead",{children:g.jsxs("tr",{className:"border-b border-herd-border text-[11px] text-herd-muted font-medium uppercase tracking-wide",children:[g.jsx("th",{className:"text-left py-2 px-3",children:"Agent"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Schedule"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Type"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Expression"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Status"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Last Run"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Next Run"}),g.jsx("th",{className:"text-left py-2 px-3",children:"Actions"})]})}),g.jsx("tbody",{className:"divide-y divide-herd-border",children:t.map(x=>g.jsx($E,{schedule:x,onTrigger:d,onEnable:m,onDisable:p},`${x.agentName}:${x.name}`))})]})})]})}function FE(t){const l=new Date(t),i=new Date().getTime()-l.getTime(),s=Math.floor(i/6e4),o=Math.floor(i/36e5),c=Math.floor(i/864e5);return s<1?"just now":s<60?`${s}m ago`:o<24?`${o}h ago`:c<7?`${c}d ago`:l.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function YE(t){if(t<1e3)return`${t}ms`;const l=Math.floor(t/1e3);if(l<60)return`${l}s`;const r=Math.floor(l/60),i=l%60;return i>0?`${r}m ${i}s`:`${r}m`}const GE={Bash:"💻",bash:"💻",Read:"📄",Write:"✏️",Edit:"✏️",Glob:"🔍",Grep:"🔍",WebFetch:"🌐",WebSearch:"🌐"};function XE({message:t}){const[l,r]=E.useState(!1),i=t.toolCall,s=GE[i.toolName]??"🔧",o=200,c=i.output.length>o,d=l?i.output:i.output.substring(0,o)+(c?"...":"");return g.jsx("div",{className:"flex flex-col items-start animate-[fadeSlideIn_150ms_ease-out]",children:g.jsxs("div",{className:`max-w-[85%] px-3 py-2 rounded-lg border ${i.isError?"border-red-500/30 bg-red-500/5":"border-herd-border bg-herd-hover"}`,children:[g.jsxs("button",{type:"button",onClick:()=>r(!l),className:"flex items-center gap-1.5 w-full text-left",children:[g.jsx("span",{className:"text-xs",children:s}),g.jsx("span",{className:"text-xs font-medium text-herd-fg",children:i.toolName}),i.isError&&g.jsx("span",{className:"text-[10px] text-red-500 font-medium",children:"ERROR"}),i.durationMs!==void 0&&g.jsx("span",{className:"text-[10px] text-herd-muted ml-auto",children:YE(i.durationMs)}),g.jsx("span",{className:"text-[10px] text-herd-muted",children:l?"▲":"▼"})]}),i.inputSummary&&g.jsx("div",{className:"mt-1",children:g.jsx("code",{className:"text-[11px] text-herd-muted break-all",children:i.inputSummary})}),(l||!c)&&i.output.trim().length>0&&g.jsx("pre",{className:"mt-1.5 text-[11px] text-herd-fg/80 bg-herd-bg rounded px-2 py-1.5 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap break-all",children:d}),!l&&c&&i.output.trim().length>0&&g.jsxs("div",{className:"mt-1.5 text-[11px] text-herd-muted",children:[(i.output.length/1e3).toFixed(1),"k chars"]})]})})}function ip({message:t,isStreaming:l=!1}){if(t.role==="tool"&&t.toolCall)return g.jsx(XE,{message:t});const r=t.role==="user";return g.jsxs("div",{className:`flex flex-col ${r?"items-end":"items-start"} animate-[fadeSlideIn_150ms_ease-out]`,children:[g.jsx("div",{className:`max-w-[85%] px-4 py-2.5 ${r?"bg-herd-user-bubble text-herd-fg rounded-2xl rounded-br-md":"bg-herd-card border border-herd-border text-herd-fg rounded-2xl rounded-bl-md"}`,children:r?g.jsx("p",{className:"text-sm whitespace-pre-wrap",children:t.content}):g.jsxs("div",{className:l?"relative":"",children:[g.jsx(BE,{content:t.content,useSerif:!0}),l&&g.jsxs("span",{className:"inline-flex ml-1",children:[g.jsx("span",{className:"w-1 h-1 bg-herd-muted rounded-full animate-pulse"}),g.jsx("span",{className:"w-1 h-1 bg-herd-muted rounded-full animate-pulse ml-0.5 [animation-delay:150ms]"}),g.jsx("span",{className:"w-1 h-1 bg-herd-muted rounded-full animate-pulse ml-0.5 [animation-delay:300ms]"})]})]})}),!l&&g.jsx("span",{className:"text-[11px] text-herd-muted mt-1 px-1",children:FE(t.timestamp)})]})}function QE({agentName:t}){const{chatMessages:l,chatMessagesLoading:r,chatStreaming:i,chatStreamingContent:s}=Pf(),o=E.useRef(null),c=E.useRef(l.length);if(E.useEffect(()=>{const m=o.current;if(!m)return;const p=m.scrollHeight-m.scrollTop-m.clientHeight<100;(l.length>c.current||i||p)&&(m.scrollTop=m.scrollHeight),c.current=l.length},[l,i,s]),r)return g.jsx("div",{className:"flex-1 flex items-center justify-center",children:g.jsxs("div",{className:"flex flex-col items-center gap-2 text-herd-muted",children:[g.jsx("div",{className:"w-5 h-5 border-2 border-herd-muted border-t-transparent rounded-full animate-spin"}),g.jsx("span",{className:"text-xs",children:"Loading messages..."})]})});if(l.length===0&&!i)return g.jsx("div",{className:"flex-1 flex items-center justify-center",children:g.jsxs("div",{className:"flex flex-col items-center gap-3 text-herd-muted",children:[g.jsx(u1,{className:"w-12 h-12 opacity-50"}),g.jsx("p",{className:"text-sm",children:"Send a message to start the conversation"})]})});const d=i?{role:"assistant",content:s||"...",timestamp:new Date().toISOString()}:null;return g.jsx("div",{ref:o,className:"flex-1 overflow-y-auto px-4 py-4",children:g.jsxs("div",{className:"max-w-2xl mx-auto space-y-4",children:[l.map((m,p)=>g.jsx(ip,{message:m},`${m.timestamp}-${p}`)),d&&g.jsx(ip,{message:d,isStreaming:!0})]})})}function KE({agentName:t,sessionId:l}){const[r,i]=E.useState(""),s=E.useRef(null),{chatStreaming:o}=Pf(),{addUserMessage:c}=Wf();E.useEffect(()=>{const y=s.current;if(!y)return;y.style.height="auto";const v=Math.min(y.scrollHeight,200);y.style.height=`${v}px`},[r]);const d=r.trim().length>0&&!o,m=E.useCallback(()=>{if(!d)return;const y=r.trim();i(""),c(y);const v=window.__herdWsClient;v&&v.send({type:"chat:send",payload:{agentName:t,sessionId:l,message:y}})},[d,r,c,t,l]),p=E.useCallback(y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),m())},[m]),x=E.useCallback(y=>{i(y.target.value)},[]);return g.jsx("div",{className:"border-t border-herd-border bg-herd-card p-4",children:g.jsxs("div",{className:"max-w-2xl mx-auto",children:[g.jsxs("div",{className:"relative flex items-end gap-2",children:[g.jsx("textarea",{ref:s,value:r,onChange:x,onKeyDown:p,placeholder:`Send a message to ${t}...`,rows:1,className:"flex-1 bg-herd-input-bg border border-herd-border rounded-lg px-3 py-2.5 text-sm text-herd-fg placeholder:text-herd-muted focus:outline-none focus:border-herd-primary/60 transition-colors resize-none",style:{minHeight:"42px",maxHeight:"200px"}}),g.jsx("button",{type:"button",onClick:m,disabled:!d,className:`flex-shrink-0 w-9 h-9 rounded-lg flex items-center justify-center transition-colors ${d?"bg-herd-primary hover:bg-herd-primary-hover text-white":"bg-herd-hover text-herd-muted cursor-not-allowed"}`,title:"Send message",children:g.jsx(n8,{className:"w-4 h-4"})})]}),g.jsx("p",{className:"text-[11px] text-herd-muted mt-2 text-center",children:"Press Enter to send, Shift+Enter for new line"})]})})}function up(){const{name:t,sessionId:l}=Jf(),r=If(),{activeChatSessionId:i,chatError:s}=Pf(),{chatSessions:o}=p6(),{fetchChatMessages:c,setActiveChatSession:d,clearActiveChatState:m,createChatSession:p}=Wf();if(E.useEffect(()=>()=>{m()},[t,m]),E.useEffect(()=>{l&&t?c(t,l):d(null)},[l,t,c,d]),!t)return g.jsx("div",{className:"flex items-center justify-center h-full text-herd-muted",children:g.jsx("p",{className:"text-sm",children:"Agent not found"})});const x=async()=>{const y=await p(t);y&&r(`/agents/${encodeURIComponent(t)}/chat/${y}`)};return g.jsx("div",{className:"flex-1 flex flex-col min-w-0 h-full",children:l?g.jsxs(g.Fragment,{children:[s&&g.jsx("div",{className:"px-4 pt-4",children:g.jsx("div",{className:"max-w-2xl mx-auto",children:g.jsx("div",{className:"bg-herd-status-error/10 border border-herd-status-error/20 text-herd-status-error rounded-lg px-3 py-2 text-xs",children:s})})}),g.jsx(QE,{agentName:t}),g.jsx(KE,{agentName:t,sessionId:l})]}):g.jsx("div",{className:"flex-1 flex items-center justify-center",children:g.jsxs("div",{className:"flex flex-col items-center gap-4 text-center px-4",children:[g.jsx("div",{className:"w-16 h-16 rounded-full bg-herd-primary-muted flex items-center justify-center",children:g.jsx(u1,{className:"w-8 h-8 text-herd-primary"})}),g.jsxs("div",{children:[g.jsxs("h2",{className:"text-lg font-semibold text-herd-fg mb-1",children:["Chat with ",t]}),g.jsx("p",{className:"text-sm text-herd-muted max-w-sm",children:o.length>0?"Select a conversation from the sidebar or start a new one.":"Start a new conversation to chat with this agent."})]}),g.jsx("button",{type:"button",onClick:x,className:"bg-herd-primary hover:bg-herd-primary-hover text-white rounded-lg px-4 py-2 text-sm font-medium transition-colors",children:"New Chat"})]})})})}function PE(t){switch(t){case"success":return g.jsx(u3,{className:"w-4 h-4 text-herd-status-running flex-shrink-0"});case"error":return g.jsx(p8,{className:"w-4 h-4 text-herd-status-error flex-shrink-0"});case"info":return g.jsx(_8,{className:"w-4 h-4 text-herd-primary flex-shrink-0"})}}function WE(t){switch(t){case"success":return"bg-herd-status-running/10 border-herd-status-running/20";case"error":return"bg-herd-status-error/10 border-herd-status-error/20";case"info":return"bg-herd-primary-muted border-herd-primary/20"}}function eM({toast:t,onDismiss:l}){return g.jsxs("div",{className:`
|
|
365
365
|
flex items-center gap-2 px-3 py-2 rounded-[10px] border text-sm text-herd-fg
|
|
366
366
|
animate-fade-slide-in min-w-[240px] max-w-[360px]
|
|
367
367
|
${WE(t.type)}
|
package/dist/client/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&family=Lora:ital,wght@0,400;0,500;1,400&display=swap"
|
|
13
13
|
rel="stylesheet"
|
|
14
14
|
/>
|
|
15
|
-
<script type="module" crossorigin src="/assets/index-
|
|
15
|
+
<script type="module" crossorigin src="/assets/index-Bhjml_JS.js"></script>
|
|
16
16
|
<link rel="stylesheet" crossorigin href="/assets/index-COkiUjfo.css">
|
|
17
17
|
</head>
|
|
18
18
|
<body class="bg-herd-bg text-herd-fg font-sans antialiased">
|